summaryrefslogtreecommitdiff
path: root/node_modules/@babel/plugin-transform-object-super/lib
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-object-super/lib
parentc5a5384e846f242e901e859fe600d695d8990a9a (diff)
added babel
Diffstat (limited to 'node_modules/@babel/plugin-transform-object-super/lib')
-rw-r--r--node_modules/@babel/plugin-transform-object-super/lib/index.js42
-rw-r--r--node_modules/@babel/plugin-transform-object-super/lib/index.js.map1
2 files changed, 43 insertions, 0 deletions
diff --git a/node_modules/@babel/plugin-transform-object-super/lib/index.js b/node_modules/@babel/plugin-transform-object-super/lib/index.js
new file mode 100644
index 00000000..59dad106
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-object-super/lib/index.js
@@ -0,0 +1,42 @@
+"use strict";
+
+Object.defineProperty(exports, "__esModule", {
+ value: true
+});
+exports.default = void 0;
+var _helperPluginUtils = require("@babel/helper-plugin-utils");
+var _helperReplaceSupers = require("@babel/helper-replace-supers");
+var _core = require("@babel/core");
+function replacePropertySuper(path, getObjectRef, file) {
+ const replaceSupers = new _helperReplaceSupers.default({
+ getObjectRef: getObjectRef,
+ methodPath: path,
+ file: file
+ });
+ replaceSupers.replace();
+}
+var _default = (0, _helperPluginUtils.declare)(api => {
+ api.assertVersion(7);
+ return {
+ name: "transform-object-super",
+ visitor: {
+ ObjectExpression(path, state) {
+ let objectRef;
+ const getObjectRef = () => objectRef = objectRef || path.scope.generateUidIdentifier("obj");
+ path.get("properties").forEach(propPath => {
+ if (!propPath.isMethod()) return;
+ replacePropertySuper(propPath, getObjectRef, state.file);
+ });
+ if (objectRef) {
+ path.scope.push({
+ id: _core.types.cloneNode(objectRef)
+ });
+ path.replaceWith(_core.types.assignmentExpression("=", _core.types.cloneNode(objectRef), path.node));
+ }
+ }
+ }
+ };
+});
+exports.default = _default;
+
+//# sourceMappingURL=index.js.map
diff --git a/node_modules/@babel/plugin-transform-object-super/lib/index.js.map b/node_modules/@babel/plugin-transform-object-super/lib/index.js.map
new file mode 100644
index 00000000..60a70759
--- /dev/null
+++ b/node_modules/@babel/plugin-transform-object-super/lib/index.js.map
@@ -0,0 +1 @@
+{"version":3,"names":["_helperPluginUtils","require","_helperReplaceSupers","_core","replacePropertySuper","path","getObjectRef","file","replaceSupers","ReplaceSupers","methodPath","replace","_default","declare","api","assertVersion","name","visitor","ObjectExpression","state","objectRef","scope","generateUidIdentifier","get","forEach","propPath","isMethod","push","id","t","cloneNode","replaceWith","assignmentExpression","node","exports","default"],"sources":["../src/index.ts"],"sourcesContent":["import { declare } from \"@babel/helper-plugin-utils\";\nimport ReplaceSupers from \"@babel/helper-replace-supers\";\nimport { types as t, type File } from \"@babel/core\";\nimport type { NodePath } from \"@babel/traverse\";\n\nfunction replacePropertySuper(\n path: NodePath<t.ObjectMethod>,\n getObjectRef: () => t.Identifier,\n file: File,\n) {\n // @ts-expect-error todo(flow->ts):\n const replaceSupers = new ReplaceSupers({\n getObjectRef: getObjectRef,\n methodPath: path,\n file: file,\n });\n\n replaceSupers.replace();\n}\n\nexport default declare(api => {\n api.assertVersion(7);\n\n return {\n name: \"transform-object-super\",\n\n visitor: {\n ObjectExpression(path, state) {\n let objectRef: t.Identifier;\n const getObjectRef = () =>\n (objectRef = objectRef || path.scope.generateUidIdentifier(\"obj\"));\n\n path.get(\"properties\").forEach(propPath => {\n if (!propPath.isMethod()) return;\n\n replacePropertySuper(propPath, getObjectRef, state.file);\n });\n\n if (objectRef) {\n path.scope.push({ id: t.cloneNode(objectRef) });\n path.replaceWith(\n t.assignmentExpression(\"=\", t.cloneNode(objectRef), path.node),\n );\n }\n },\n },\n };\n});\n"],"mappings":";;;;;;AAAA,IAAAA,kBAAA,GAAAC,OAAA;AACA,IAAAC,oBAAA,GAAAD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