1 | "use strict";
|
2 |
|
3 | Object.defineProperty(exports, "__esModule", {
|
4 | value: true
|
5 | });
|
6 | exports.default = void 0;
|
7 |
|
8 | function _helperPluginUtils() {
|
9 | const data = require("@babel/helper-plugin-utils");
|
10 |
|
11 | _helperPluginUtils = function () {
|
12 | return data;
|
13 | };
|
14 |
|
15 | return data;
|
16 | }
|
17 |
|
18 | function _helperReplaceSupers() {
|
19 | const data = _interopRequireDefault(require("@babel/helper-replace-supers"));
|
20 |
|
21 | _helperReplaceSupers = function () {
|
22 | return data;
|
23 | };
|
24 |
|
25 | return data;
|
26 | }
|
27 |
|
28 | function _core() {
|
29 | const data = require("@babel/core");
|
30 |
|
31 | _core = function () {
|
32 | return data;
|
33 | };
|
34 |
|
35 | return data;
|
36 | }
|
37 |
|
38 | function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
39 |
|
40 | function replacePropertySuper(path, getObjectRef, file) {
|
41 | const replaceSupers = new (_helperReplaceSupers().default)({
|
42 | getObjectRef: getObjectRef,
|
43 | methodPath: path,
|
44 | file: file
|
45 | });
|
46 | replaceSupers.replace();
|
47 | }
|
48 |
|
49 | var _default = (0, _helperPluginUtils().declare)(api => {
|
50 | api.assertVersion(7);
|
51 | return {
|
52 | visitor: {
|
53 | ObjectExpression(path, state) {
|
54 | let objectRef;
|
55 |
|
56 | const getObjectRef = () => objectRef = objectRef || path.scope.generateUidIdentifier("obj");
|
57 |
|
58 | path.get("properties").forEach(propPath => {
|
59 | if (!propPath.isMethod()) return;
|
60 | replacePropertySuper(propPath, getObjectRef, state);
|
61 | });
|
62 |
|
63 | if (objectRef) {
|
64 | path.scope.push({
|
65 | id: _core().types.cloneNode(objectRef)
|
66 | });
|
67 | path.replaceWith(_core().types.assignmentExpression("=", _core().types.cloneNode(objectRef), path.node));
|
68 | }
|
69 | }
|
70 |
|
71 | }
|
72 | };
|
73 | });
|
74 |
|
75 | exports.default = _default; |
\ | No newline at end of file |