Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
22
my-app/node_modules/@babel/template/LICENSE
generated
vendored
Executable file
22
my-app/node_modules/@babel/template/LICENSE
generated
vendored
Executable file
|
@ -0,0 +1,22 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2014-present Sebastian McKenzie and other contributors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
19
my-app/node_modules/@babel/template/README.md
generated
vendored
Executable file
19
my-app/node_modules/@babel/template/README.md
generated
vendored
Executable file
|
@ -0,0 +1,19 @@
|
|||
# @babel/template
|
||||
|
||||
> Generate an AST from a string template.
|
||||
|
||||
See our website [@babel/template](https://babeljs.io/docs/babel-template) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen) associated with this package.
|
||||
|
||||
## Install
|
||||
|
||||
Using npm:
|
||||
|
||||
```sh
|
||||
npm install --save-dev @babel/template
|
||||
```
|
||||
|
||||
or using yarn:
|
||||
|
||||
```sh
|
||||
yarn add @babel/template --dev
|
||||
```
|
69
my-app/node_modules/@babel/template/lib/builder.js
generated
vendored
Executable file
69
my-app/node_modules/@babel/template/lib/builder.js
generated
vendored
Executable file
|
@ -0,0 +1,69 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = createTemplateBuilder;
|
||||
var _options = require("./options.js");
|
||||
var _string = require("./string.js");
|
||||
var _literal = require("./literal.js");
|
||||
const NO_PLACEHOLDER = (0, _options.validate)({
|
||||
placeholderPattern: false
|
||||
});
|
||||
function createTemplateBuilder(formatter, defaultOpts) {
|
||||
const templateFnCache = new WeakMap();
|
||||
const templateAstCache = new WeakMap();
|
||||
const cachedOpts = defaultOpts || (0, _options.validate)(null);
|
||||
return Object.assign((tpl, ...args) => {
|
||||
if (typeof tpl === "string") {
|
||||
if (args.length > 1) throw new Error("Unexpected extra params.");
|
||||
return extendedTrace((0, _string.default)(formatter, tpl, (0, _options.merge)(cachedOpts, (0, _options.validate)(args[0]))));
|
||||
} else if (Array.isArray(tpl)) {
|
||||
let builder = templateFnCache.get(tpl);
|
||||
if (!builder) {
|
||||
builder = (0, _literal.default)(formatter, tpl, cachedOpts);
|
||||
templateFnCache.set(tpl, builder);
|
||||
}
|
||||
return extendedTrace(builder(args));
|
||||
} else if (typeof tpl === "object" && tpl) {
|
||||
if (args.length > 0) throw new Error("Unexpected extra params.");
|
||||
return createTemplateBuilder(formatter, (0, _options.merge)(cachedOpts, (0, _options.validate)(tpl)));
|
||||
}
|
||||
throw new Error(`Unexpected template param ${typeof tpl}`);
|
||||
}, {
|
||||
ast: (tpl, ...args) => {
|
||||
if (typeof tpl === "string") {
|
||||
if (args.length > 1) throw new Error("Unexpected extra params.");
|
||||
return (0, _string.default)(formatter, tpl, (0, _options.merge)((0, _options.merge)(cachedOpts, (0, _options.validate)(args[0])), NO_PLACEHOLDER))();
|
||||
} else if (Array.isArray(tpl)) {
|
||||
let builder = templateAstCache.get(tpl);
|
||||
if (!builder) {
|
||||
builder = (0, _literal.default)(formatter, tpl, (0, _options.merge)(cachedOpts, NO_PLACEHOLDER));
|
||||
templateAstCache.set(tpl, builder);
|
||||
}
|
||||
return builder(args)();
|
||||
}
|
||||
throw new Error(`Unexpected template param ${typeof tpl}`);
|
||||
}
|
||||
});
|
||||
}
|
||||
function extendedTrace(fn) {
|
||||
let rootStack = "";
|
||||
try {
|
||||
throw new Error();
|
||||
} catch (error) {
|
||||
if (error.stack) {
|
||||
rootStack = error.stack.split("\n").slice(3).join("\n");
|
||||
}
|
||||
}
|
||||
return arg => {
|
||||
try {
|
||||
return fn(arg);
|
||||
} catch (err) {
|
||||
err.stack += `\n =============\n${rootStack}`;
|
||||
throw err;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=builder.js.map
|
1
my-app/node_modules/@babel/template/lib/builder.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/builder.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
61
my-app/node_modules/@babel/template/lib/formatters.js
generated
vendored
Executable file
61
my-app/node_modules/@babel/template/lib/formatters.js
generated
vendored
Executable file
|
@ -0,0 +1,61 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.statements = exports.statement = exports.smart = exports.program = exports.expression = void 0;
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
assertExpressionStatement
|
||||
} = _t;
|
||||
function makeStatementFormatter(fn) {
|
||||
return {
|
||||
code: str => `/* @babel/template */;\n${str}`,
|
||||
validate: () => {},
|
||||
unwrap: ast => {
|
||||
return fn(ast.program.body.slice(1));
|
||||
}
|
||||
};
|
||||
}
|
||||
const smart = exports.smart = makeStatementFormatter(body => {
|
||||
if (body.length > 1) {
|
||||
return body;
|
||||
} else {
|
||||
return body[0];
|
||||
}
|
||||
});
|
||||
const statements = exports.statements = makeStatementFormatter(body => body);
|
||||
const statement = exports.statement = makeStatementFormatter(body => {
|
||||
if (body.length === 0) {
|
||||
throw new Error("Found nothing to return.");
|
||||
}
|
||||
if (body.length > 1) {
|
||||
throw new Error("Found multiple statements but wanted one");
|
||||
}
|
||||
return body[0];
|
||||
});
|
||||
const expression = exports.expression = {
|
||||
code: str => `(\n${str}\n)`,
|
||||
validate: ast => {
|
||||
if (ast.program.body.length > 1) {
|
||||
throw new Error("Found multiple statements but wanted one");
|
||||
}
|
||||
if (expression.unwrap(ast).start === 0) {
|
||||
throw new Error("Parse result included parens.");
|
||||
}
|
||||
},
|
||||
unwrap: ({
|
||||
program
|
||||
}) => {
|
||||
const [stmt] = program.body;
|
||||
assertExpressionStatement(stmt);
|
||||
return stmt.expression;
|
||||
}
|
||||
};
|
||||
const program = exports.program = {
|
||||
code: str => str,
|
||||
validate: () => {},
|
||||
unwrap: ast => ast.program
|
||||
};
|
||||
|
||||
//# sourceMappingURL=formatters.js.map
|
1
my-app/node_modules/@babel/template/lib/formatters.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/formatters.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["_t","require","assertExpressionStatement","makeStatementFormatter","fn","code","str","validate","unwrap","ast","program","body","slice","smart","exports","length","statements","statement","Error","expression","start","stmt"],"sources":["../src/formatters.ts"],"sourcesContent":["import { assertExpressionStatement } from \"@babel/types\";\nimport type * as t from \"@babel/types\";\n\nexport type Formatter<T> = {\n code: (source: string) => string;\n validate: (ast: t.File) => void;\n unwrap: (ast: t.File) => T;\n};\n\nfunction makeStatementFormatter<T>(\n fn: (statements: Array<t.Statement>) => T,\n): Formatter<T> {\n return {\n // We need to prepend a \";\" to force statement parsing so that\n // ExpressionStatement strings won't be parsed as directives.\n // Alongside that, we also prepend a comment so that when a syntax error\n // is encountered, the user will be less likely to get confused about\n // where the random semicolon came from.\n code: str => `/* @babel/template */;\\n${str}`,\n validate: () => {},\n unwrap: (ast: t.File): T => {\n return fn(ast.program.body.slice(1));\n },\n };\n}\n\nexport const smart = makeStatementFormatter(body => {\n if (body.length > 1) {\n return body;\n } else {\n return body[0];\n }\n});\n\nexport const statements = makeStatementFormatter(body => body);\n\nexport const statement = makeStatementFormatter(body => {\n // We do this validation when unwrapping since the replacement process\n // could have added or removed statements.\n if (body.length === 0) {\n throw new Error(\"Found nothing to return.\");\n }\n if (body.length > 1) {\n throw new Error(\"Found multiple statements but wanted one\");\n }\n\n return body[0];\n});\n\nexport const expression: Formatter<t.Expression> = {\n code: str => `(\\n${str}\\n)`,\n validate: ast => {\n if (ast.program.body.length > 1) {\n throw new Error(\"Found multiple statements but wanted one\");\n }\n if (expression.unwrap(ast).start === 0) {\n throw new Error(\"Parse result included parens.\");\n }\n },\n unwrap: ({ program }) => {\n const [stmt] = program.body;\n assertExpressionStatement(stmt);\n return stmt.expression;\n },\n};\n\nexport const program: Formatter<t.Program> = {\n code: str => str,\n validate: () => {},\n unwrap: ast => ast.program,\n};\n"],"mappings":";;;;;;AAAA,IAAAA,EAAA,GAAAC,OAAA;AAAyD;EAAhDC;AAAyB,IAAAF,EAAA;AASlC,SAASG,sBAAsBA,CAC7BC,EAAyC,EAC3B;EACd,OAAO;IAMLC,IAAI,EAAEC,GAAG,IAAK,2BAA0BA,GAAI,EAAC;IAC7CC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;IAClBC,MAAM,EAAGC,GAAW,IAAQ;MAC1B,OAAOL,EAAE,CAACK,GAAG,CAACC,OAAO,CAACC,IAAI,CAACC,KAAK,CAAC,CAAC,CAAC,CAAC;IACtC;EACF,CAAC;AACH;AAEO,MAAMC,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAGV,sBAAsB,CAACQ,IAAI,IAAI;EAClD,IAAIA,IAAI,CAACI,MAAM,GAAG,CAAC,EAAE;IACnB,OAAOJ,IAAI;EACb,CAAC,MAAM;IACL,OAAOA,IAAI,CAAC,CAAC,CAAC;EAChB;AACF,CAAC,CAAC;AAEK,MAAMK,UAAU,GAAAF,OAAA,CAAAE,UAAA,GAAGb,sBAAsB,CAACQ,IAAI,IAAIA,IAAI,CAAC;AAEvD,MAAMM,SAAS,GAAAH,OAAA,CAAAG,SAAA,GAAGd,sBAAsB,CAACQ,IAAI,IAAI;EAGtD,IAAIA,IAAI,CAACI,MAAM,KAAK,CAAC,EAAE;IACrB,MAAM,IAAIG,KAAK,CAAC,0BAA0B,CAAC;EAC7C;EACA,IAAIP,IAAI,CAACI,MAAM,GAAG,CAAC,EAAE;IACnB,MAAM,IAAIG,KAAK,CAAC,0CAA0C,CAAC;EAC7D;EAEA,OAAOP,IAAI,CAAC,CAAC,CAAC;AAChB,CAAC,CAAC;AAEK,MAAMQ,UAAmC,GAAAL,OAAA,CAAAK,UAAA,GAAG;EACjDd,IAAI,EAAEC,GAAG,IAAK,MAAKA,GAAI,KAAI;EAC3BC,QAAQ,EAAEE,GAAG,IAAI;IACf,IAAIA,GAAG,CAACC,OAAO,CAACC,IAAI,CAACI,MAAM,GAAG,CAAC,EAAE;MAC/B,MAAM,IAAIG,KAAK,CAAC,0CAA0C,CAAC;IAC7D;IACA,IAAIC,UAAU,CAACX,MAAM,CAACC,GAAG,CAAC,CAACW,KAAK,KAAK,CAAC,EAAE;MACtC,MAAM,IAAIF,KAAK,CAAC,+BAA+B,CAAC;IAClD;EACF,CAAC;EACDV,MAAM,EAAEA,CAAC;IAAEE;EAAQ,CAAC,KAAK;IACvB,MAAM,CAACW,IAAI,CAAC,GAAGX,OAAO,CAACC,IAAI;IAC3BT,yBAAyB,CAACmB,IAAI,CAAC;IAC/B,OAAOA,IAAI,CAACF,UAAU;EACxB;AACF,CAAC;AAEM,MAAMT,OAA6B,GAAAI,OAAA,CAAAJ,OAAA,GAAG;EAC3CL,IAAI,EAAEC,GAAG,IAAIA,GAAG;EAChBC,QAAQ,EAAEA,CAAA,KAAM,CAAC,CAAC;EAClBC,MAAM,EAAEC,GAAG,IAAIA,GAAG,CAACC;AACrB,CAAC"}
|
23
my-app/node_modules/@babel/template/lib/index.js
generated
vendored
Executable file
23
my-app/node_modules/@babel/template/lib/index.js
generated
vendored
Executable file
|
@ -0,0 +1,23 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.statements = exports.statement = exports.smart = exports.program = exports.expression = exports.default = void 0;
|
||||
var formatters = require("./formatters.js");
|
||||
var _builder = require("./builder.js");
|
||||
const smart = exports.smart = (0, _builder.default)(formatters.smart);
|
||||
const statement = exports.statement = (0, _builder.default)(formatters.statement);
|
||||
const statements = exports.statements = (0, _builder.default)(formatters.statements);
|
||||
const expression = exports.expression = (0, _builder.default)(formatters.expression);
|
||||
const program = exports.program = (0, _builder.default)(formatters.program);
|
||||
var _default = exports.default = Object.assign(smart.bind(undefined), {
|
||||
smart,
|
||||
statement,
|
||||
statements,
|
||||
expression,
|
||||
program,
|
||||
ast: smart.ast
|
||||
});
|
||||
|
||||
//# sourceMappingURL=index.js.map
|
1
my-app/node_modules/@babel/template/lib/index.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/index.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["formatters","require","_builder","smart","exports","createTemplateBuilder","statement","statements","expression","program","_default","default","Object","assign","bind","undefined","ast"],"sources":["../src/index.ts"],"sourcesContent":["import * as formatters from \"./formatters.ts\";\nimport createTemplateBuilder from \"./builder.ts\";\n\nexport const smart = createTemplateBuilder(formatters.smart);\nexport const statement = createTemplateBuilder(formatters.statement);\nexport const statements = createTemplateBuilder(formatters.statements);\nexport const expression = createTemplateBuilder(formatters.expression);\nexport const program = createTemplateBuilder(formatters.program);\n\ntype DefaultTemplateBuilder = typeof smart & {\n smart: typeof smart;\n statement: typeof statement;\n statements: typeof statements;\n expression: typeof expression;\n program: typeof program;\n};\n\nexport default Object.assign(smart.bind(undefined) as DefaultTemplateBuilder, {\n smart,\n statement,\n statements,\n expression,\n program,\n ast: smart.ast,\n});\n\nexport type {\n PublicOpts as Options,\n PublicReplacements as Replacements,\n} from \"./options.ts\";\n"],"mappings":";;;;;;AAAA,IAAAA,UAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AAEO,MAAME,KAAK,GAAAC,OAAA,CAAAD,KAAA,GAAG,IAAAE,gBAAqB,EAACL,UAAU,CAACG,KAAK,CAAC;AACrD,MAAMG,SAAS,GAAAF,OAAA,CAAAE,SAAA,GAAG,IAAAD,gBAAqB,EAACL,UAAU,CAACM,SAAS,CAAC;AAC7D,MAAMC,UAAU,GAAAH,OAAA,CAAAG,UAAA,GAAG,IAAAF,gBAAqB,EAACL,UAAU,CAACO,UAAU,CAAC;AAC/D,MAAMC,UAAU,GAAAJ,OAAA,CAAAI,UAAA,GAAG,IAAAH,gBAAqB,EAACL,UAAU,CAACQ,UAAU,CAAC;AAC/D,MAAMC,OAAO,GAAAL,OAAA,CAAAK,OAAA,GAAG,IAAAJ,gBAAqB,EAACL,UAAU,CAACS,OAAO,CAAC;AAAC,IAAAC,QAAA,GAAAN,OAAA,CAAAO,OAAA,GAUlDC,MAAM,CAACC,MAAM,CAACV,KAAK,CAACW,IAAI,CAACC,SAAS,CAAC,EAA4B;EAC5EZ,KAAK;EACLG,SAAS;EACTC,UAAU;EACVC,UAAU;EACVC,OAAO;EACPO,GAAG,EAAEb,KAAK,CAACa;AACb,CAAC,CAAC"}
|
69
my-app/node_modules/@babel/template/lib/literal.js
generated
vendored
Executable file
69
my-app/node_modules/@babel/template/lib/literal.js
generated
vendored
Executable file
|
@ -0,0 +1,69 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = literalTemplate;
|
||||
var _options = require("./options.js");
|
||||
var _parse = require("./parse.js");
|
||||
var _populate = require("./populate.js");
|
||||
function literalTemplate(formatter, tpl, opts) {
|
||||
const {
|
||||
metadata,
|
||||
names
|
||||
} = buildLiteralData(formatter, tpl, opts);
|
||||
return arg => {
|
||||
const defaultReplacements = {};
|
||||
arg.forEach((replacement, i) => {
|
||||
defaultReplacements[names[i]] = replacement;
|
||||
});
|
||||
return arg => {
|
||||
const replacements = (0, _options.normalizeReplacements)(arg);
|
||||
if (replacements) {
|
||||
Object.keys(replacements).forEach(key => {
|
||||
if (Object.prototype.hasOwnProperty.call(defaultReplacements, key)) {
|
||||
throw new Error("Unexpected replacement overlap.");
|
||||
}
|
||||
});
|
||||
}
|
||||
return formatter.unwrap((0, _populate.default)(metadata, replacements ? Object.assign(replacements, defaultReplacements) : defaultReplacements));
|
||||
};
|
||||
};
|
||||
}
|
||||
function buildLiteralData(formatter, tpl, opts) {
|
||||
let prefix = "BABEL_TPL$";
|
||||
const raw = tpl.join("");
|
||||
do {
|
||||
prefix = "$$" + prefix;
|
||||
} while (raw.includes(prefix));
|
||||
const {
|
||||
names,
|
||||
code
|
||||
} = buildTemplateCode(tpl, prefix);
|
||||
const metadata = (0, _parse.default)(formatter, formatter.code(code), {
|
||||
parser: opts.parser,
|
||||
placeholderWhitelist: new Set(names.concat(opts.placeholderWhitelist ? Array.from(opts.placeholderWhitelist) : [])),
|
||||
placeholderPattern: opts.placeholderPattern,
|
||||
preserveComments: opts.preserveComments,
|
||||
syntacticPlaceholders: opts.syntacticPlaceholders
|
||||
});
|
||||
return {
|
||||
metadata,
|
||||
names
|
||||
};
|
||||
}
|
||||
function buildTemplateCode(tpl, prefix) {
|
||||
const names = [];
|
||||
let code = tpl[0];
|
||||
for (let i = 1; i < tpl.length; i++) {
|
||||
const value = `${prefix}${i - 1}`;
|
||||
names.push(value);
|
||||
code += value + tpl[i];
|
||||
}
|
||||
return {
|
||||
names,
|
||||
code
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=literal.js.map
|
1
my-app/node_modules/@babel/template/lib/literal.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/literal.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
73
my-app/node_modules/@babel/template/lib/options.js
generated
vendored
Executable file
73
my-app/node_modules/@babel/template/lib/options.js
generated
vendored
Executable file
|
@ -0,0 +1,73 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.merge = merge;
|
||||
exports.normalizeReplacements = normalizeReplacements;
|
||||
exports.validate = validate;
|
||||
const _excluded = ["placeholderWhitelist", "placeholderPattern", "preserveComments", "syntacticPlaceholders"];
|
||||
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
||||
function merge(a, b) {
|
||||
const {
|
||||
placeholderWhitelist = a.placeholderWhitelist,
|
||||
placeholderPattern = a.placeholderPattern,
|
||||
preserveComments = a.preserveComments,
|
||||
syntacticPlaceholders = a.syntacticPlaceholders
|
||||
} = b;
|
||||
return {
|
||||
parser: Object.assign({}, a.parser, b.parser),
|
||||
placeholderWhitelist,
|
||||
placeholderPattern,
|
||||
preserveComments,
|
||||
syntacticPlaceholders
|
||||
};
|
||||
}
|
||||
function validate(opts) {
|
||||
if (opts != null && typeof opts !== "object") {
|
||||
throw new Error("Unknown template options.");
|
||||
}
|
||||
const _ref = opts || {},
|
||||
{
|
||||
placeholderWhitelist,
|
||||
placeholderPattern,
|
||||
preserveComments,
|
||||
syntacticPlaceholders
|
||||
} = _ref,
|
||||
parser = _objectWithoutPropertiesLoose(_ref, _excluded);
|
||||
if (placeholderWhitelist != null && !(placeholderWhitelist instanceof Set)) {
|
||||
throw new Error("'.placeholderWhitelist' must be a Set, null, or undefined");
|
||||
}
|
||||
if (placeholderPattern != null && !(placeholderPattern instanceof RegExp) && placeholderPattern !== false) {
|
||||
throw new Error("'.placeholderPattern' must be a RegExp, false, null, or undefined");
|
||||
}
|
||||
if (preserveComments != null && typeof preserveComments !== "boolean") {
|
||||
throw new Error("'.preserveComments' must be a boolean, null, or undefined");
|
||||
}
|
||||
if (syntacticPlaceholders != null && typeof syntacticPlaceholders !== "boolean") {
|
||||
throw new Error("'.syntacticPlaceholders' must be a boolean, null, or undefined");
|
||||
}
|
||||
if (syntacticPlaceholders === true && (placeholderWhitelist != null || placeholderPattern != null)) {
|
||||
throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'");
|
||||
}
|
||||
return {
|
||||
parser,
|
||||
placeholderWhitelist: placeholderWhitelist || undefined,
|
||||
placeholderPattern: placeholderPattern == null ? undefined : placeholderPattern,
|
||||
preserveComments: preserveComments == null ? undefined : preserveComments,
|
||||
syntacticPlaceholders: syntacticPlaceholders == null ? undefined : syntacticPlaceholders
|
||||
};
|
||||
}
|
||||
function normalizeReplacements(replacements) {
|
||||
if (Array.isArray(replacements)) {
|
||||
return replacements.reduce((acc, replacement, i) => {
|
||||
acc["$" + i] = replacement;
|
||||
return acc;
|
||||
}, {});
|
||||
} else if (typeof replacements === "object" || replacements == null) {
|
||||
return replacements || undefined;
|
||||
}
|
||||
throw new Error("Template replacements must be an array, object, null, or undefined");
|
||||
}
|
||||
|
||||
//# sourceMappingURL=options.js.map
|
1
my-app/node_modules/@babel/template/lib/options.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/options.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
160
my-app/node_modules/@babel/template/lib/parse.js
generated
vendored
Executable file
160
my-app/node_modules/@babel/template/lib/parse.js
generated
vendored
Executable file
|
@ -0,0 +1,160 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = parseAndBuildMetadata;
|
||||
var _t = require("@babel/types");
|
||||
var _parser = require("@babel/parser");
|
||||
var _codeFrame = require("@babel/code-frame");
|
||||
const {
|
||||
isCallExpression,
|
||||
isExpressionStatement,
|
||||
isFunction,
|
||||
isIdentifier,
|
||||
isJSXIdentifier,
|
||||
isNewExpression,
|
||||
isPlaceholder,
|
||||
isStatement,
|
||||
isStringLiteral,
|
||||
removePropertiesDeep,
|
||||
traverse
|
||||
} = _t;
|
||||
const PATTERN = /^[_$A-Z0-9]+$/;
|
||||
function parseAndBuildMetadata(formatter, code, opts) {
|
||||
const {
|
||||
placeholderWhitelist,
|
||||
placeholderPattern,
|
||||
preserveComments,
|
||||
syntacticPlaceholders
|
||||
} = opts;
|
||||
const ast = parseWithCodeFrame(code, opts.parser, syntacticPlaceholders);
|
||||
removePropertiesDeep(ast, {
|
||||
preserveComments
|
||||
});
|
||||
formatter.validate(ast);
|
||||
const state = {
|
||||
syntactic: {
|
||||
placeholders: [],
|
||||
placeholderNames: new Set()
|
||||
},
|
||||
legacy: {
|
||||
placeholders: [],
|
||||
placeholderNames: new Set()
|
||||
},
|
||||
placeholderWhitelist,
|
||||
placeholderPattern,
|
||||
syntacticPlaceholders
|
||||
};
|
||||
traverse(ast, placeholderVisitorHandler, state);
|
||||
return Object.assign({
|
||||
ast
|
||||
}, state.syntactic.placeholders.length ? state.syntactic : state.legacy);
|
||||
}
|
||||
function placeholderVisitorHandler(node, ancestors, state) {
|
||||
var _state$placeholderWhi;
|
||||
let name;
|
||||
let hasSyntacticPlaceholders = state.syntactic.placeholders.length > 0;
|
||||
if (isPlaceholder(node)) {
|
||||
if (state.syntacticPlaceholders === false) {
|
||||
throw new Error("%%foo%%-style placeholders can't be used when " + "'.syntacticPlaceholders' is false.");
|
||||
}
|
||||
name = node.name.name;
|
||||
hasSyntacticPlaceholders = true;
|
||||
} else if (hasSyntacticPlaceholders || state.syntacticPlaceholders) {
|
||||
return;
|
||||
} else if (isIdentifier(node) || isJSXIdentifier(node)) {
|
||||
name = node.name;
|
||||
} else if (isStringLiteral(node)) {
|
||||
name = node.value;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (hasSyntacticPlaceholders && (state.placeholderPattern != null || state.placeholderWhitelist != null)) {
|
||||
throw new Error("'.placeholderWhitelist' and '.placeholderPattern' aren't compatible" + " with '.syntacticPlaceholders: true'");
|
||||
}
|
||||
if (!hasSyntacticPlaceholders && (state.placeholderPattern === false || !(state.placeholderPattern || PATTERN).test(name)) && !((_state$placeholderWhi = state.placeholderWhitelist) != null && _state$placeholderWhi.has(name))) {
|
||||
return;
|
||||
}
|
||||
ancestors = ancestors.slice();
|
||||
const {
|
||||
node: parent,
|
||||
key
|
||||
} = ancestors[ancestors.length - 1];
|
||||
let type;
|
||||
if (isStringLiteral(node) || isPlaceholder(node, {
|
||||
expectedNode: "StringLiteral"
|
||||
})) {
|
||||
type = "string";
|
||||
} else if (isNewExpression(parent) && key === "arguments" || isCallExpression(parent) && key === "arguments" || isFunction(parent) && key === "params") {
|
||||
type = "param";
|
||||
} else if (isExpressionStatement(parent) && !isPlaceholder(node)) {
|
||||
type = "statement";
|
||||
ancestors = ancestors.slice(0, -1);
|
||||
} else if (isStatement(node) && isPlaceholder(node)) {
|
||||
type = "statement";
|
||||
} else {
|
||||
type = "other";
|
||||
}
|
||||
const {
|
||||
placeholders,
|
||||
placeholderNames
|
||||
} = !hasSyntacticPlaceholders ? state.legacy : state.syntactic;
|
||||
placeholders.push({
|
||||
name,
|
||||
type,
|
||||
resolve: ast => resolveAncestors(ast, ancestors),
|
||||
isDuplicate: placeholderNames.has(name)
|
||||
});
|
||||
placeholderNames.add(name);
|
||||
}
|
||||
function resolveAncestors(ast, ancestors) {
|
||||
let parent = ast;
|
||||
for (let i = 0; i < ancestors.length - 1; i++) {
|
||||
const {
|
||||
key,
|
||||
index
|
||||
} = ancestors[i];
|
||||
if (index === undefined) {
|
||||
parent = parent[key];
|
||||
} else {
|
||||
parent = parent[key][index];
|
||||
}
|
||||
}
|
||||
const {
|
||||
key,
|
||||
index
|
||||
} = ancestors[ancestors.length - 1];
|
||||
return {
|
||||
parent,
|
||||
key,
|
||||
index
|
||||
};
|
||||
}
|
||||
function parseWithCodeFrame(code, parserOpts, syntacticPlaceholders) {
|
||||
const plugins = (parserOpts.plugins || []).slice();
|
||||
if (syntacticPlaceholders !== false) {
|
||||
plugins.push("placeholders");
|
||||
}
|
||||
parserOpts = Object.assign({
|
||||
allowReturnOutsideFunction: true,
|
||||
allowSuperOutsideMethod: true,
|
||||
sourceType: "module"
|
||||
}, parserOpts, {
|
||||
plugins
|
||||
});
|
||||
try {
|
||||
return (0, _parser.parse)(code, parserOpts);
|
||||
} catch (err) {
|
||||
const loc = err.loc;
|
||||
if (loc) {
|
||||
err.message += "\n" + (0, _codeFrame.codeFrameColumns)(code, {
|
||||
start: loc
|
||||
});
|
||||
err.code = "BABEL_TEMPLATE_PARSE_ERROR";
|
||||
}
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=parse.js.map
|
1
my-app/node_modules/@babel/template/lib/parse.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/parse.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
122
my-app/node_modules/@babel/template/lib/populate.js
generated
vendored
Executable file
122
my-app/node_modules/@babel/template/lib/populate.js
generated
vendored
Executable file
|
@ -0,0 +1,122 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = populatePlaceholders;
|
||||
var _t = require("@babel/types");
|
||||
const {
|
||||
blockStatement,
|
||||
cloneNode,
|
||||
emptyStatement,
|
||||
expressionStatement,
|
||||
identifier,
|
||||
isStatement,
|
||||
isStringLiteral,
|
||||
stringLiteral,
|
||||
validate
|
||||
} = _t;
|
||||
function populatePlaceholders(metadata, replacements) {
|
||||
const ast = cloneNode(metadata.ast);
|
||||
if (replacements) {
|
||||
metadata.placeholders.forEach(placeholder => {
|
||||
if (!Object.prototype.hasOwnProperty.call(replacements, placeholder.name)) {
|
||||
const placeholderName = placeholder.name;
|
||||
throw new Error(`Error: No substitution given for "${placeholderName}". If this is not meant to be a
|
||||
placeholder you may want to consider passing one of the following options to @babel/template:
|
||||
- { placeholderPattern: false, placeholderWhitelist: new Set(['${placeholderName}'])}
|
||||
- { placeholderPattern: /^${placeholderName}$/ }`);
|
||||
}
|
||||
});
|
||||
Object.keys(replacements).forEach(key => {
|
||||
if (!metadata.placeholderNames.has(key)) {
|
||||
throw new Error(`Unknown substitution "${key}" given`);
|
||||
}
|
||||
});
|
||||
}
|
||||
metadata.placeholders.slice().reverse().forEach(placeholder => {
|
||||
try {
|
||||
applyReplacement(placeholder, ast, replacements && replacements[placeholder.name] || null);
|
||||
} catch (e) {
|
||||
e.message = `@babel/template placeholder "${placeholder.name}": ${e.message}`;
|
||||
throw e;
|
||||
}
|
||||
});
|
||||
return ast;
|
||||
}
|
||||
function applyReplacement(placeholder, ast, replacement) {
|
||||
if (placeholder.isDuplicate) {
|
||||
if (Array.isArray(replacement)) {
|
||||
replacement = replacement.map(node => cloneNode(node));
|
||||
} else if (typeof replacement === "object") {
|
||||
replacement = cloneNode(replacement);
|
||||
}
|
||||
}
|
||||
const {
|
||||
parent,
|
||||
key,
|
||||
index
|
||||
} = placeholder.resolve(ast);
|
||||
if (placeholder.type === "string") {
|
||||
if (typeof replacement === "string") {
|
||||
replacement = stringLiteral(replacement);
|
||||
}
|
||||
if (!replacement || !isStringLiteral(replacement)) {
|
||||
throw new Error("Expected string substitution");
|
||||
}
|
||||
} else if (placeholder.type === "statement") {
|
||||
if (index === undefined) {
|
||||
if (!replacement) {
|
||||
replacement = emptyStatement();
|
||||
} else if (Array.isArray(replacement)) {
|
||||
replacement = blockStatement(replacement);
|
||||
} else if (typeof replacement === "string") {
|
||||
replacement = expressionStatement(identifier(replacement));
|
||||
} else if (!isStatement(replacement)) {
|
||||
replacement = expressionStatement(replacement);
|
||||
}
|
||||
} else {
|
||||
if (replacement && !Array.isArray(replacement)) {
|
||||
if (typeof replacement === "string") {
|
||||
replacement = identifier(replacement);
|
||||
}
|
||||
if (!isStatement(replacement)) {
|
||||
replacement = expressionStatement(replacement);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (placeholder.type === "param") {
|
||||
if (typeof replacement === "string") {
|
||||
replacement = identifier(replacement);
|
||||
}
|
||||
if (index === undefined) throw new Error("Assertion failure.");
|
||||
} else {
|
||||
if (typeof replacement === "string") {
|
||||
replacement = identifier(replacement);
|
||||
}
|
||||
if (Array.isArray(replacement)) {
|
||||
throw new Error("Cannot replace single expression with an array.");
|
||||
}
|
||||
}
|
||||
if (index === undefined) {
|
||||
validate(parent, key, replacement);
|
||||
parent[key] = replacement;
|
||||
} else {
|
||||
const items = parent[key].slice();
|
||||
if (placeholder.type === "statement" || placeholder.type === "param") {
|
||||
if (replacement == null) {
|
||||
items.splice(index, 1);
|
||||
} else if (Array.isArray(replacement)) {
|
||||
items.splice(index, 1, ...replacement);
|
||||
} else {
|
||||
items[index] = replacement;
|
||||
}
|
||||
} else {
|
||||
items[index] = replacement;
|
||||
}
|
||||
validate(parent, key, items);
|
||||
parent[key] = items;
|
||||
}
|
||||
}
|
||||
|
||||
//# sourceMappingURL=populate.js.map
|
1
my-app/node_modules/@babel/template/lib/populate.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/populate.js.map
generated
vendored
Executable file
File diff suppressed because one or more lines are too long
20
my-app/node_modules/@babel/template/lib/string.js
generated
vendored
Executable file
20
my-app/node_modules/@babel/template/lib/string.js
generated
vendored
Executable file
|
@ -0,0 +1,20 @@
|
|||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.default = stringTemplate;
|
||||
var _options = require("./options.js");
|
||||
var _parse = require("./parse.js");
|
||||
var _populate = require("./populate.js");
|
||||
function stringTemplate(formatter, code, opts) {
|
||||
code = formatter.code(code);
|
||||
let metadata;
|
||||
return arg => {
|
||||
const replacements = (0, _options.normalizeReplacements)(arg);
|
||||
if (!metadata) metadata = (0, _parse.default)(formatter, code, opts);
|
||||
return formatter.unwrap((0, _populate.default)(metadata, replacements));
|
||||
};
|
||||
}
|
||||
|
||||
//# sourceMappingURL=string.js.map
|
1
my-app/node_modules/@babel/template/lib/string.js.map
generated
vendored
Executable file
1
my-app/node_modules/@babel/template/lib/string.js.map
generated
vendored
Executable file
|
@ -0,0 +1 @@
|
|||
{"version":3,"names":["_options","require","_parse","_populate","stringTemplate","formatter","code","opts","metadata","arg","replacements","normalizeReplacements","parseAndBuildMetadata","unwrap","populatePlaceholders"],"sources":["../src/string.ts"],"sourcesContent":["import type { Formatter } from \"./formatters.ts\";\nimport type { TemplateOpts } from \"./options.ts\";\nimport type { Metadata } from \"./parse.ts\";\nimport { normalizeReplacements } from \"./options.ts\";\nimport parseAndBuildMetadata from \"./parse.ts\";\nimport populatePlaceholders from \"./populate.ts\";\n\nexport default function stringTemplate<T>(\n formatter: Formatter<T>,\n code: string,\n opts: TemplateOpts,\n): (arg?: unknown) => T {\n code = formatter.code(code);\n\n let metadata: Metadata;\n\n return (arg?: unknown) => {\n const replacements = normalizeReplacements(arg);\n\n if (!metadata) metadata = parseAndBuildMetadata(formatter, code, opts);\n\n return formatter.unwrap(populatePlaceholders(metadata, replacements));\n };\n}\n"],"mappings":";;;;;;AAGA,IAAAA,QAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAF,OAAA;AAEe,SAASG,cAAcA,CACpCC,SAAuB,EACvBC,IAAY,EACZC,IAAkB,EACI;EACtBD,IAAI,GAAGD,SAAS,CAACC,IAAI,CAACA,IAAI,CAAC;EAE3B,IAAIE,QAAkB;EAEtB,OAAQC,GAAa,IAAK;IACxB,MAAMC,YAAY,GAAG,IAAAC,8BAAqB,EAACF,GAAG,CAAC;IAE/C,IAAI,CAACD,QAAQ,EAAEA,QAAQ,GAAG,IAAAI,cAAqB,EAACP,SAAS,EAAEC,IAAI,EAAEC,IAAI,CAAC;IAEtE,OAAOF,SAAS,CAACQ,MAAM,CAAC,IAAAC,iBAAoB,EAACN,QAAQ,EAAEE,YAAY,CAAC,CAAC;EACvE,CAAC;AACH"}
|
27
my-app/node_modules/@babel/template/package.json
generated
vendored
Executable file
27
my-app/node_modules/@babel/template/package.json
generated
vendored
Executable file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"name": "@babel/template",
|
||||
"version": "7.23.9",
|
||||
"description": "Generate an AST from a string template.",
|
||||
"author": "The Babel Team (https://babel.dev/team)",
|
||||
"homepage": "https://babel.dev/docs/en/next/babel-template",
|
||||
"bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20template%22+is%3Aopen",
|
||||
"license": "MIT",
|
||||
"publishConfig": {
|
||||
"access": "public"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/babel/babel.git",
|
||||
"directory": "packages/babel-template"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
"@babel/code-frame": "^7.23.5",
|
||||
"@babel/parser": "^7.23.9",
|
||||
"@babel/types": "^7.23.9"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=6.9.0"
|
||||
},
|
||||
"type": "commonjs"
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue