diff options
Diffstat (limited to 'node_modules/@babel/plugin-transform-unicode-escapes/lib')
| -rw-r--r-- | node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js | 118 | ||||
| -rw-r--r-- | node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js.map | 1 |
2 files changed, 0 insertions, 119 deletions
diff --git a/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js b/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js deleted file mode 100644 index 4e91337f..00000000 --- a/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js +++ /dev/null @@ -1,118 +0,0 @@ -"use strict"; - -Object.defineProperty(exports, "__esModule", { - value: true -}); -exports.default = void 0; -var _helperPluginUtils = require("@babel/helper-plugin-utils"); -var _core = require("@babel/core"); -var _default = exports.default = (0, _helperPluginUtils.declare)(api => { - api.assertVersion(7); - const surrogate = /[\ud800-\udfff]/g; - const unicodeEscape = /(\\+)u\{([0-9a-fA-F]+)\}/g; - function escape(code) { - { - let str = code.toString(16); - while (str.length < 4) str = "0" + str; - return "\\u" + str; - } - } - function replacer(match, backslashes, code) { - if (backslashes.length % 2 === 0) { - return match; - } - const char = String.fromCodePoint(parseInt(code, 16)); - const escaped = backslashes.slice(0, -1) + escape(char.charCodeAt(0)); - return char.length === 1 ? escaped : escaped + escape(char.charCodeAt(1)); - } - function replaceUnicodeEscapes(str) { - return str.replace(unicodeEscape, replacer); - } - function getUnicodeEscape(str) { - let match; - while (match = unicodeEscape.exec(str)) { - if (match[1].length % 2 === 0) continue; - unicodeEscape.lastIndex = 0; - return match[0]; - } - return null; - } - return { - name: "transform-unicode-escapes", - manipulateOptions({ - generatorOpts - }) { - var _generatorOpts$jsescO, _generatorOpts$jsescO2; - if (!generatorOpts.jsescOption) { - generatorOpts.jsescOption = {}; - } - (_generatorOpts$jsescO2 = (_generatorOpts$jsescO = generatorOpts.jsescOption).minimal) != null ? _generatorOpts$jsescO2 : _generatorOpts$jsescO.minimal = false; - }, - visitor: { - Identifier(path) { - const { - node, - key - } = path; - const { - name - } = node; - const replaced = name.replace(surrogate, c => { - return `_u${c.charCodeAt(0).toString(16)}`; - }); - if (name === replaced) return; - const str = _core.types.inherits(_core.types.stringLiteral(name), node); - if (key === "key") { - path.replaceWith(str); - return; - } - const { - parentPath, - scope - } = path; - if (parentPath.isMemberExpression({ - property: node - }) || parentPath.isOptionalMemberExpression({ - property: node - })) { - parentPath.node.computed = true; - path.replaceWith(str); - return; - } - const binding = scope.getBinding(name); - if (binding) { - scope.rename(name, scope.generateUid(replaced)); - return; - } - throw path.buildCodeFrameError(`Can't reference '${name}' as a bare identifier`); - }, - "StringLiteral|DirectiveLiteral"(path) { - const { - node - } = path; - const { - extra - } = node; - if (extra != null && extra.raw) extra.raw = replaceUnicodeEscapes(extra.raw); - }, - TemplateElement(path) { - const { - node, - parentPath - } = path; - const { - value - } = node; - const firstEscape = getUnicodeEscape(value.raw); - if (!firstEscape) return; - const grandParent = parentPath.parentPath; - if (grandParent.isTaggedTemplateExpression()) { - throw path.buildCodeFrameError(`Can't replace Unicode escape '${firstEscape}' inside tagged template literals. You can enable '@babel/plugin-transform-template-literals' to compile them to classic strings.`); - } - value.raw = replaceUnicodeEscapes(value.raw); - } - } - }; -}); - -//# sourceMappingURL=index.js.map diff --git a/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js.map b/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js.map deleted file mode 100644 index 8dbd9635..00000000 --- a/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"names":["_helperPluginUtils","require","_core","_default","exports","default","declare","api","assertVersion","surrogate","unicodeEscape","escape","code","str","toString","length","replacer","match","backslashes","char","String","fromCodePoint","parseInt","escaped","slice","charCodeAt","replaceUnicodeEscapes","replace","getUnicodeEscape","exec","lastIndex","name","manipulateOptions","generatorOpts","_generatorOpts$jsescO","_generatorOpts$jsescO2","jsescOption","minimal","visitor","Identifier","path","node","key","replaced","c","t","inherits","stringLiteral","replaceWith","parentPath","scope","isMemberExpression","property","isOptionalMemberExpression","computed","binding","getBinding","rename","generateUid","buildCodeFrameError","StringLiteral|DirectiveLiteral","extra","raw","TemplateElement","value","firstEscape","grandParent","isTaggedTemplateExpression"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { types as t, type NodePath } from \"@babel/core\";\n\nexport default declare(api => {\n api.assertVersion(REQUIRED_VERSION(7));\n\n const surrogate = /[\\ud800-\\udfff]/g;\n const unicodeEscape = /(\\\\+)u\\{([0-9a-fA-F]+)\\}/g;\n\n function escape(code: number) {\n if (process.env.BABEL_8_BREAKING) {\n return \"\\\\u\" + code.toString(16).padStart(4, \"0\");\n } else {\n let str = code.toString(16);\n while (str.length < 4) str = \"0\" + str;\n return \"\\\\u\" + str;\n }\n }\n\n function replacer(match: string, backslashes: string, code: string) {\n if (backslashes.length % 2 === 0) {\n return match;\n }\n\n const char = String.fromCodePoint(parseInt(code, 16));\n const escaped = backslashes.slice(0, -1) + escape(char.charCodeAt(0));\n\n return char.length === 1 ? escaped : escaped + escape(char.charCodeAt(1));\n }\n\n function replaceUnicodeEscapes(str: string) {\n return str.replace(unicodeEscape, replacer);\n }\n\n function getUnicodeEscape(str: string) {\n let match;\n while ((match = unicodeEscape.exec(str))) {\n if (match[1].length % 2 === 0) continue;\n unicodeEscape.lastIndex = 0;\n return match[0];\n }\n return null;\n }\n\n return {\n name: \"transform-unicode-escapes\",\n manipulateOptions({ generatorOpts }) {\n // Babel 8 will enable jsesc minimal mode by default, which outputs\n // unescaped unicode string\n if (!generatorOpts.jsescOption) {\n generatorOpts.jsescOption = {};\n }\n generatorOpts.jsescOption.minimal ??= false;\n },\n visitor: {\n Identifier(path) {\n const { node, key } = path;\n const { name } = node;\n const replaced = name.replace(surrogate, c => {\n return `_u${c.charCodeAt(0).toString(16)}`;\n });\n if (name === replaced) return;\n\n const str = t.inherits(t.stringLiteral(name), node);\n\n if (key === \"key\") {\n path.replaceWith(str);\n return;\n }\n\n const { parentPath, scope } = path;\n if (\n parentPath.isMemberExpression({ property: node }) ||\n parentPath.isOptionalMemberExpression({ property: node })\n ) {\n parentPath.node.computed = true;\n path.replaceWith(str);\n return;\n }\n\n const binding = scope.getBinding(name);\n if (binding) {\n scope.rename(name, scope.generateUid(replaced));\n return;\n }\n\n throw path.buildCodeFrameError(\n `Can't reference '${name}' as a bare identifier`,\n );\n },\n\n \"StringLiteral|DirectiveLiteral\"(\n path: NodePath<t.StringLiteral | t.DirectiveLiteral>,\n ) {\n const { node } = path;\n const { extra } = node;\n\n if (extra?.raw) extra.raw = replaceUnicodeEscapes(extra.raw as string);\n },\n\n TemplateElement(path) {\n const { node, parentPath } = path;\n const { value } = node;\n\n const firstEscape = getUnicodeEscape(value.raw);\n if (!firstEscape) return;\n\n const grandParent = parentPath.parentPath;\n if (grandParent.isTaggedTemplateExpression()) {\n throw path.buildCodeFrameError(\n `Can't replace Unicode escape '${firstEscape}' inside tagged template literals. You can enable '@babel/plugin-transform-template-literals' to compile them to classic strings.`,\n );\n }\n\n value.raw = replaceUnicodeEscapes(value.raw);\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AAAwD,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEzC,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAAkB,CAAE,CAAC;EAEtC,MAAMC,SAAS,GAAG,kBAAkB;EACpC,MAAMC,aAAa,GAAG,2BAA2B;EAEjD,SAASC,MAAMA,CAACC,IAAY,EAAE;IAGrB;MACL,IAAIC,GAAG,GAAGD,IAAI,CAACE,QAAQ,CAAC,EAAE,CAAC;MAC3B,OAAOD,GAAG,CAACE,MAAM,GAAG,CAAC,EAAEF,GAAG,GAAG,GAAG,GAAGA,GAAG;MACtC,OAAO,KAAK,GAAGA,GAAG;IACpB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