mirror of
https://github.com/idanoo/GoScrobble
synced 2025-07-01 13:42:20 +00:00
0.2.0 - Mid migration
This commit is contained in:
parent
139e6a915e
commit
7e38fdbd7d
42393 changed files with 5358157 additions and 62 deletions
9
web/node_modules/rollup-pluginutils/src/addExtension.ts
generated
vendored
Normal file
9
web/node_modules/rollup-pluginutils/src/addExtension.ts
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
import { extname } from 'path';
|
||||
import { AddExtension } from './pluginutils';
|
||||
|
||||
const addExtension: AddExtension = function addExtension(filename, ext = '.js') {
|
||||
if (!extname(filename)) filename += ext;
|
||||
return filename;
|
||||
};
|
||||
|
||||
export { addExtension as default };
|
125
web/node_modules/rollup-pluginutils/src/attachScopes.ts
generated
vendored
Normal file
125
web/node_modules/rollup-pluginutils/src/attachScopes.ts
generated
vendored
Normal file
|
@ -0,0 +1,125 @@
|
|||
import { Node, walk } from 'estree-walker';
|
||||
import extractAssignedNames from './extractAssignedNames';
|
||||
import { AttachedScope, AttachScopes } from './pluginutils';
|
||||
|
||||
const blockDeclarations = {
|
||||
const: true,
|
||||
let: true
|
||||
};
|
||||
|
||||
interface ScopeOptions {
|
||||
parent?: AttachedScope;
|
||||
block?: boolean;
|
||||
params?: Array<Node>;
|
||||
}
|
||||
|
||||
class Scope implements AttachedScope {
|
||||
parent?: AttachedScope;
|
||||
isBlockScope: boolean;
|
||||
declarations: { [key: string]: boolean };
|
||||
|
||||
constructor(options: ScopeOptions = {}) {
|
||||
this.parent = options.parent;
|
||||
this.isBlockScope = !!options.block;
|
||||
|
||||
this.declarations = Object.create(null);
|
||||
|
||||
if (options.params) {
|
||||
options.params.forEach(param => {
|
||||
extractAssignedNames(param).forEach(name => {
|
||||
this.declarations[name] = true;
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
addDeclaration(node: Node, isBlockDeclaration: boolean, isVar: boolean): void {
|
||||
if (!isBlockDeclaration && this.isBlockScope) {
|
||||
// it's a `var` or function node, and this
|
||||
// is a block scope, so we need to go up
|
||||
this.parent!.addDeclaration(node, isBlockDeclaration, isVar);
|
||||
} else if (node.id) {
|
||||
extractAssignedNames(node.id).forEach(name => {
|
||||
this.declarations[name] = true;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
contains(name: string): boolean {
|
||||
return this.declarations[name] || (this.parent ? this.parent.contains(name) : false);
|
||||
}
|
||||
}
|
||||
|
||||
const attachScopes: AttachScopes = function attachScopes(ast, propertyName = 'scope') {
|
||||
let scope = new Scope();
|
||||
|
||||
walk(ast, {
|
||||
enter(node, parent) {
|
||||
// function foo () {...}
|
||||
// class Foo {...}
|
||||
if (/(Function|Class)Declaration/.test(node.type)) {
|
||||
scope.addDeclaration(node, false, false);
|
||||
}
|
||||
|
||||
// var foo = 1
|
||||
if (node.type === 'VariableDeclaration') {
|
||||
const kind: keyof typeof blockDeclarations = node.kind;
|
||||
const isBlockDeclaration = blockDeclarations[kind];
|
||||
|
||||
node.declarations.forEach((declaration: Node) => {
|
||||
scope.addDeclaration(declaration, isBlockDeclaration, true);
|
||||
});
|
||||
}
|
||||
|
||||
let newScope: AttachedScope | undefined;
|
||||
|
||||
// create new function scope
|
||||
if (/Function/.test(node.type)) {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: false,
|
||||
params: node.params
|
||||
});
|
||||
|
||||
// named function expressions - the name is considered
|
||||
// part of the function's scope
|
||||
if (node.type === 'FunctionExpression' && node.id) {
|
||||
newScope.addDeclaration(node, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
// create new block scope
|
||||
if (node.type === 'BlockStatement' && !/Function/.test(parent!.type)) {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
block: true
|
||||
});
|
||||
}
|
||||
|
||||
// catch clause has its own block scope
|
||||
if (node.type === 'CatchClause') {
|
||||
newScope = new Scope({
|
||||
parent: scope,
|
||||
params: node.param ? [node.param] : [],
|
||||
block: true
|
||||
});
|
||||
}
|
||||
|
||||
if (newScope) {
|
||||
Object.defineProperty(node, propertyName, {
|
||||
value: newScope,
|
||||
configurable: true
|
||||
});
|
||||
|
||||
scope = newScope;
|
||||
}
|
||||
},
|
||||
leave(node) {
|
||||
if (node[propertyName]) scope = scope.parent!;
|
||||
}
|
||||
});
|
||||
|
||||
return scope;
|
||||
};
|
||||
|
||||
export { attachScopes as default };
|
52
web/node_modules/rollup-pluginutils/src/createFilter.ts
generated
vendored
Normal file
52
web/node_modules/rollup-pluginutils/src/createFilter.ts
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
import mm from 'micromatch';
|
||||
import { resolve, sep } from 'path';
|
||||
import { CreateFilter } from './pluginutils';
|
||||
import ensureArray from './utils/ensureArray';
|
||||
|
||||
function getMatcherString(id: string, resolutionBase: string | false | null | undefined) {
|
||||
if (resolutionBase === false) {
|
||||
return id;
|
||||
}
|
||||
return resolve(...(typeof resolutionBase === 'string' ? [resolutionBase, id] : [id]));
|
||||
}
|
||||
|
||||
const createFilter: CreateFilter = function createFilter(include?, exclude?, options?) {
|
||||
const resolutionBase = options && options.resolve;
|
||||
|
||||
const getMatcher = (id: string | RegExp) => {
|
||||
return id instanceof RegExp
|
||||
? id
|
||||
: {
|
||||
test: mm.matcher(
|
||||
getMatcherString(id, resolutionBase)
|
||||
.split(sep)
|
||||
.join('/'),
|
||||
{ dot: true }
|
||||
)
|
||||
};
|
||||
};
|
||||
|
||||
const includeMatchers = ensureArray(include).map(getMatcher);
|
||||
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
||||
|
||||
return function(id: string | any): boolean {
|
||||
if (typeof id !== 'string') return false;
|
||||
if (/\0/.test(id)) return false;
|
||||
|
||||
id = id.split(sep).join('/');
|
||||
|
||||
for (let i = 0; i < excludeMatchers.length; ++i) {
|
||||
const matcher = excludeMatchers[i];
|
||||
if (matcher.test(id)) return false;
|
||||
}
|
||||
|
||||
for (let i = 0; i < includeMatchers.length; ++i) {
|
||||
const matcher = includeMatchers[i];
|
||||
if (matcher.test(id)) return true;
|
||||
}
|
||||
|
||||
return !includeMatchers.length;
|
||||
};
|
||||
};
|
||||
|
||||
export { createFilter as default };
|
92
web/node_modules/rollup-pluginutils/src/dataToEsm.ts
generated
vendored
Normal file
92
web/node_modules/rollup-pluginutils/src/dataToEsm.ts
generated
vendored
Normal file
|
@ -0,0 +1,92 @@
|
|||
import makeLegalIdentifier from './makeLegalIdentifier';
|
||||
import { DataToEsm } from './pluginutils';
|
||||
|
||||
export type Indent = string | null | undefined;
|
||||
|
||||
function stringify(obj: any): string {
|
||||
return (JSON.stringify(obj) || 'undefined').replace(/[\u2028\u2029]/g, char => `\\u${('000' + char.charCodeAt(0).toString(16)).slice(-4)}`);
|
||||
}
|
||||
|
||||
function serializeArray<T>(arr: Array<T>, indent: Indent, baseIndent: string): string {
|
||||
let output = '[';
|
||||
const separator = indent ? '\n' + baseIndent + indent : '';
|
||||
for (let i = 0; i < arr.length; i++) {
|
||||
const key = arr[i];
|
||||
output += `${i > 0 ? ',' : ''}${separator}${serialize(key, indent, baseIndent + indent)}`;
|
||||
}
|
||||
return output + `${indent ? '\n' + baseIndent : ''}]`;
|
||||
}
|
||||
|
||||
function serializeObject<T>(obj: { [key: string]: T }, indent: Indent, baseIndent: string): string {
|
||||
let output = '{';
|
||||
const separator = indent ? '\n' + baseIndent + indent : '';
|
||||
const keys = Object.keys(obj);
|
||||
for (let i = 0; i < keys.length; i++) {
|
||||
const key = keys[i];
|
||||
const stringKey = makeLegalIdentifier(key) === key ? key : stringify(key);
|
||||
output += `${i > 0 ? ',' : ''}${separator}${stringKey}:${indent ? ' ' : ''}${serialize(
|
||||
obj[key],
|
||||
indent,
|
||||
baseIndent + indent
|
||||
)}`;
|
||||
}
|
||||
return output + `${indent ? '\n' + baseIndent : ''}}`;
|
||||
}
|
||||
|
||||
function serialize(obj: any, indent: Indent, baseIndent: string): string {
|
||||
if (obj === Infinity) return 'Infinity';
|
||||
if (obj === -Infinity) return '-Infinity';
|
||||
if (obj === 0 && 1/obj === -Infinity) return '-0';
|
||||
if (obj instanceof Date) return 'new Date(' + obj.getTime() + ')';
|
||||
if (obj instanceof RegExp) return obj.toString();
|
||||
if (obj !== obj) return 'NaN';
|
||||
if (Array.isArray(obj)) return serializeArray(obj, indent, baseIndent);
|
||||
if (obj === null) return 'null';
|
||||
if (typeof obj === 'object') return serializeObject(obj, indent, baseIndent);
|
||||
return stringify(obj);
|
||||
}
|
||||
|
||||
const dataToEsm: DataToEsm = function dataToEsm(data, options = {}) {
|
||||
const t = options.compact ? '' : 'indent' in options ? options.indent : '\t';
|
||||
const _ = options.compact ? '' : ' ';
|
||||
const n = options.compact ? '' : '\n';
|
||||
const declarationType = options.preferConst ? 'const' : 'var';
|
||||
|
||||
if (
|
||||
options.namedExports === false ||
|
||||
typeof data !== 'object' ||
|
||||
Array.isArray(data) ||
|
||||
data instanceof Date ||
|
||||
data instanceof RegExp ||
|
||||
data === null
|
||||
) {
|
||||
const code = serialize(data, options.compact ? null : t, '');
|
||||
const __ = _ || (/^[{[\-\/]/.test(code) ? '' : ' ');
|
||||
return `export default${__}${code};`;
|
||||
}
|
||||
|
||||
let namedExportCode = '';
|
||||
const defaultExportRows = [];
|
||||
const dataKeys = Object.keys(data);
|
||||
for (let i = 0; i < dataKeys.length; i++) {
|
||||
const key = dataKeys[i];
|
||||
if (key === makeLegalIdentifier(key)) {
|
||||
if (options.objectShorthand) defaultExportRows.push(key);
|
||||
else defaultExportRows.push(`${key}:${_}${key}`);
|
||||
namedExportCode += `export ${declarationType} ${key}${_}=${_}${serialize(
|
||||
data[key],
|
||||
options.compact ? null : t,
|
||||
''
|
||||
)};${n}`;
|
||||
} else {
|
||||
defaultExportRows.push(
|
||||
`${stringify(key)}:${_}${serialize(data[key], options.compact ? null : t, '')}`
|
||||
);
|
||||
}
|
||||
}
|
||||
return (
|
||||
namedExportCode + `export default${_}{${n}${t}${defaultExportRows.join(`,${n}${t}`)}${n}};${n}`
|
||||
);
|
||||
};
|
||||
|
||||
export { dataToEsm as default };
|
46
web/node_modules/rollup-pluginutils/src/extractAssignedNames.ts
generated
vendored
Normal file
46
web/node_modules/rollup-pluginutils/src/extractAssignedNames.ts
generated
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
import { Node } from 'estree-walker';
|
||||
|
||||
interface Extractors {
|
||||
[key: string]: (names: Array<string>, param: Node) => void;
|
||||
}
|
||||
|
||||
const extractors: Extractors = {
|
||||
ArrayPattern(names: Array<string>, param: Node) {
|
||||
for (const element of param.elements) {
|
||||
if (element) extractors[element.type](names, element);
|
||||
}
|
||||
},
|
||||
|
||||
AssignmentPattern(names: Array<string>, param: Node) {
|
||||
extractors[param.left.type](names, param.left);
|
||||
},
|
||||
|
||||
Identifier(names: Array<string>, param: Node) {
|
||||
names.push(param.name);
|
||||
},
|
||||
|
||||
MemberExpression() {},
|
||||
|
||||
ObjectPattern(names: Array<string>, param: Node) {
|
||||
for (const prop of param.properties) {
|
||||
if (prop.type === 'RestElement') {
|
||||
extractors.RestElement(names, prop);
|
||||
} else {
|
||||
extractors[prop.value.type](names, prop.value);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
RestElement(names: Array<string>, param: Node) {
|
||||
extractors[param.argument.type](names, param.argument);
|
||||
}
|
||||
};
|
||||
|
||||
const extractAssignedNames = function extractAssignedNames(param: Node): Array<string> {
|
||||
const names: Array<string> = [];
|
||||
|
||||
extractors[param.type](names, param);
|
||||
return names;
|
||||
};
|
||||
|
||||
export { extractAssignedNames as default };
|
6
web/node_modules/rollup-pluginutils/src/index.ts
generated
vendored
Normal file
6
web/node_modules/rollup-pluginutils/src/index.ts
generated
vendored
Normal file
|
@ -0,0 +1,6 @@
|
|||
export { default as addExtension } from './addExtension';
|
||||
export { default as attachScopes } from './attachScopes';
|
||||
export { default as createFilter } from './createFilter';
|
||||
export { default as makeLegalIdentifier } from './makeLegalIdentifier';
|
||||
export { default as dataToEsm } from './dataToEsm';
|
||||
export { default as extractAssignedNames } from './extractAssignedNames';
|
21
web/node_modules/rollup-pluginutils/src/makeLegalIdentifier.ts
generated
vendored
Normal file
21
web/node_modules/rollup-pluginutils/src/makeLegalIdentifier.ts
generated
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { MakeLegalIdentifier } from './pluginutils';
|
||||
|
||||
const reservedWords =
|
||||
'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
||||
const builtins =
|
||||
'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
||||
|
||||
const forbiddenIdentifiers = new Set<string>(`${reservedWords} ${builtins}`.split(' '));
|
||||
forbiddenIdentifiers.add('');
|
||||
|
||||
export const makeLegalIdentifier: MakeLegalIdentifier = function makeLegalIdentifier(str) {
|
||||
str = str.replace(/-(\w)/g, (_, letter) => letter.toUpperCase()).replace(/[^$_a-zA-Z0-9]/g, '_');
|
||||
|
||||
if (/\d/.test(str[0]) || forbiddenIdentifiers.has(str)) {
|
||||
str = `_${str}`;
|
||||
}
|
||||
|
||||
return str || '_';
|
||||
};
|
||||
|
||||
export { makeLegalIdentifier as default };
|
39
web/node_modules/rollup-pluginutils/src/pluginutils.d.ts
generated
vendored
Normal file
39
web/node_modules/rollup-pluginutils/src/pluginutils.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,39 @@
|
|||
import { Node } from 'estree-walker';
|
||||
|
||||
export interface AttachedScope {
|
||||
parent?: AttachedScope;
|
||||
isBlockScope: boolean;
|
||||
declarations: { [key: string]: boolean };
|
||||
addDeclaration(node: Node, isBlockDeclaration: boolean, isVar: boolean): void;
|
||||
contains(name: string): boolean;
|
||||
}
|
||||
|
||||
export interface DataToEsmOptions {
|
||||
compact?: boolean;
|
||||
indent?: string;
|
||||
namedExports?: boolean;
|
||||
objectShorthand?: boolean;
|
||||
preferConst?: boolean;
|
||||
}
|
||||
|
||||
export type AddExtension = (filename: string, ext?: string) => string;
|
||||
export const addExtension: AddExtension;
|
||||
|
||||
export type AttachScopes = (ast: Node, propertyName?: string) => AttachedScope;
|
||||
export const attachScopes: AttachScopes;
|
||||
|
||||
export type CreateFilter = (
|
||||
include?: Array<string | RegExp> | string | RegExp | null,
|
||||
exclude?: Array<string | RegExp> | string | RegExp | null,
|
||||
options?: { resolve?: string | false | null }
|
||||
) => (id: string | any) => boolean;
|
||||
export const createFilter: CreateFilter;
|
||||
|
||||
export type MakeLegalIdentifier = (str: string) => string;
|
||||
export const makeLegalIdentifier: MakeLegalIdentifier;
|
||||
|
||||
export type DataToEsm = (data: any, options?: DataToEsmOptions) => string;
|
||||
export const dataToEsm: DataToEsm;
|
||||
|
||||
export type ExtractAssignedNames = (param: Node) => Array<string>;
|
||||
export const extractAssignedNames: ExtractAssignedNames;
|
5
web/node_modules/rollup-pluginutils/src/utils/ensureArray.ts
generated
vendored
Normal file
5
web/node_modules/rollup-pluginutils/src/utils/ensureArray.ts
generated
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
export default function ensureArray<T>(thing: Array<T> | T | undefined | null): Array<T> {
|
||||
if (Array.isArray(thing)) return thing;
|
||||
if (thing == undefined) return [];
|
||||
return [thing];
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue