summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-unicode-escapes
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
committerlittleblack111 <littleblack11111@gmail.com>2023-10-14 15:31:11 +0800
commitaa773172311dcada759dfbaac485f4bc6e00bc21 (patch)
treeca6d9a5eff3ab8f689f9acb4f0df791d9486813d /node_modules/@babel/plugin-transform-unicode-escapes
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/plugin-transform-unicode-escapes')
-rw-r--r--node_modules/@babel/plugin-transform-unicode-escapes/LICENSE22
-rw-r--r--node_modules/@babel/plugin-transform-unicode-escapes/README.md19
-rw-r--r--node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js119
-rw-r--r--node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js.map1
-rw-r--r--node_modules/@babel/plugin-transform-unicode-escapes/package.json34
5 files changed, 195 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-unicode-escapes/LICENSE b/node_modules/@babel/plugin-transform-unicode-escapes/LICENSE
new file mode 100644
index 00000000..f31575ec
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-unicode-escapes/LICENSE
@@ -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.
diff --git a/node_modules/@babel/plugin-transform-unicode-escapes/README.md b/node_modules/@babel/plugin-transform-unicode-escapes/README.md
new file mode 100644
index 00000000..5bfb0729
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-unicode-escapes/README.md
@@ -0,0 +1,19 @@
+# @babel/plugin-transform-unicode-escapes
+
+> Compile ES2015 Unicode escapes to ES5
+
+See our website [@babel/plugin-transform-unicode-escapes](https://babeljs.io/docs/babel-plugin-transform-unicode-escapes) for more information.
+
+## Install
+
+Using npm:
+
+```sh
+npm install --save-dev @babel/plugin-transform-unicode-escapes
+```
+
+or using yarn:
+
+```sh
+yarn add @babel/plugin-transform-unicode-escapes --dev
+```
diff --git a/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js b/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js
new file mode 100644
index 00000000..14feafc1
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js
@@ -0,0 +1,119 @@
+"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 = (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);
+ }
+ }
+ };
+});
+exports.default = _default;
+
+//# 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
new file mode 100644
index 00000000..38e159d9
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-unicode-escapes/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"names":["_helperPluginUtils","require","_core","_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","exports","default"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport { types as t } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\n\nexport default declare(api => {\n api.assertVersion(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;AAAyC,IAAAE,QAAA,GAG1B,IAAAC,0BAAO,EAACC,GAAG,IAAI;EAC5BA,GAAG,CAACC,aAAa,CAAC,CAAC,CAAC;EAEpB,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;EACF;EAEA,SAASG,QAAQA,CAACC,KAAa,EAAEC,WAAmB,EAAEN,IAAY,EAAE;IAClE,IAAIM,WAAW,CAACH,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE;MAChC,OAAOE,KAAK;IACd;IAEA,MAAME,IAAI,GAAGC,MAAM,CAACC,aAAa,CAACC,QAAQ,CAACV,IAAI,EAAE,EAAE,CAAC,CAAC;IACrD,MAAMW,OAAO,GAAGL,WAAW,CAACM,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAGb,MAAM,CAACQ,IAAI,CAACM,UAAU,CAAC,CAAC,CAAC,CAAC;IAErE,OAAON,IAAI,CAACJ,MAAM,KAAK,CAAC,GAAGQ,OAAO,GAAGA,OAAO,GAAGZ,MAAM,CAACQ,IAAI,CAACM,UAAU,CAAC,CAAC,CAAC,CAAC;EAC3E;EAEA,SAASC,qBAAqBA,CAACb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,WAAW,GAAGjB,UAAU,CAACA,UAAU;QACzC,IAAIiB,WAAW,CAACC,0BAA0B,CAAC,CAAC,EAAE;UAC5C,MAAM3B,IAAI,CAACmB,mBAAmB,CAC3B,iCAAgCM,WAAY,mIAC/C,CAAC;QACH;QAEAD,KAAK,CAACF,GAAG,GAAGpC,qBAAqB,CAACsC,KAAK,CAACF,GAAG,CAAC;MAC9C;IACF;EACF,CAAC;AACH,CAAC,CAAC;AAAAM,OAAA,CAAAC,OAAA,GAAAhE,QAAA"} \ No newline at end of file
diff --git a/node_modules/@babel/plugin-transform-unicode-escapes/package.json b/node_modules/@babel/plugin-transform-unicode-escapes/package.json
new file mode 100644
index 00000000..7593d68f
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-unicode-escapes/package.json
@@ -0,0 +1,34 @@
+{
+ "name": "@babel/plugin-transform-unicode-escapes",
+ "version": "7.22.10",
+ "description": "Compile ES2015 Unicode escapes to ES5",
+ "repository": {
+ "type": "git",
+ "url": "https://github.com/babel/babel.git",
+ "directory": "packages/babel-plugin-transform-unicode-escapes"
+ },
+ "license": "MIT",
+ "publishConfig": {
+ "access": "public"
+ },
+ "main": "./lib/index.js",
+ "keywords": [
+ "babel-plugin"
+ ],
+ "dependencies": {
+ "@babel/helper-plugin-utils": "^7.22.5"
+ },
+ "peerDependencies": {
+ "@babel/core": "^7.0.0-0"
+ },
+ "devDependencies": {
+ "@babel/core": "^7.22.10",
+ "@babel/helper-plugin-test-runner": "^7.22.5"
+ },
+ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-unicode-escapes",
+ "engines": {
+ "node": ">=6.9.0"
+ },
+ "author": "The Babel Team (https://babel.dev/team)",
+ "type": "commonjs"
+} \ No newline at end of file