source: imaps-frontend/node_modules/@babel/plugin-transform-object-super/lib/index.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.0 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7var _helperPluginUtils = require("@babel/helper-plugin-utils");
8var _helperReplaceSupers = require("@babel/helper-replace-supers");
9var _core = require("@babel/core");
10function replacePropertySuper(path, getObjectRef, file) {
11 const replaceSupers = new _helperReplaceSupers.default({
12 getObjectRef: getObjectRef,
13 methodPath: path,
14 file: file
15 });
16 replaceSupers.replace();
17}
18var _default = exports.default = (0, _helperPluginUtils.declare)(api => {
19 api.assertVersion(7);
20 const newLets = new Set();
21 return {
22 name: "transform-object-super",
23 visitor: {
24 Loop: {
25 exit(path) {
26 newLets.forEach(v => {
27 if (v.scopePath === path) {
28 path.scope.push({
29 id: v.id,
30 kind: "let"
31 });
32 path.scope.crawl();
33 path.requeue();
34 newLets.delete(v);
35 }
36 });
37 }
38 },
39 ObjectExpression(path, state) {
40 let objectRef;
41 const getObjectRef = () => objectRef = objectRef || path.scope.generateUidIdentifier("obj");
42 path.get("properties").forEach(propPath => {
43 if (!propPath.isMethod()) return;
44 replacePropertySuper(propPath, getObjectRef, state.file);
45 });
46 if (objectRef) {
47 const scopePath = path.findParent(p => p.isFunction() || p.isProgram() || p.isLoop());
48 const useLet = scopePath.isLoop();
49 if (useLet) {
50 newLets.add({
51 scopePath,
52 id: _core.types.cloneNode(objectRef)
53 });
54 } else {
55 path.scope.push({
56 id: _core.types.cloneNode(objectRef),
57 kind: "var"
58 });
59 }
60 path.replaceWith(_core.types.assignmentExpression("=", _core.types.cloneNode(objectRef), path.node));
61 }
62 }
63 }
64 };
65});
66
67//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.