source: frontend/node_modules/@babel/plugin-transform-classes/lib/index.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 3.4 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 _helperCompilationTargets = require("@babel/helper-compilation-targets");
9var _helperAnnotateAsPure = require("@babel/helper-annotate-as-pure");
10var _core = require("@babel/core");
11var _transformClass = require("./transformClass.js");
12const globalsBrowserUpper = require("@babel/helper-globals/data/browser-upper.json"),
13 globalsBuiltinUpper = require("@babel/helper-globals/data/builtin-upper.json");
14const builtinClasses = new Set([...globalsBrowserUpper, ...globalsBuiltinUpper]);
15builtinClasses.delete("Iterator");
16var _default = exports.default = (0, _helperPluginUtils.declare)((api, options) => {
17 var _api$assumption, _api$assumption2, _api$assumption3, _api$assumption4;
18 api.assertVersion(7);
19 const {
20 loose = false
21 } = options;
22 const setClassMethods = (_api$assumption = api.assumption("setClassMethods")) != null ? _api$assumption : loose;
23 const constantSuper = (_api$assumption2 = api.assumption("constantSuper")) != null ? _api$assumption2 : loose;
24 const superIsCallableConstructor = (_api$assumption3 = api.assumption("superIsCallableConstructor")) != null ? _api$assumption3 : loose;
25 const noClassCalls = (_api$assumption4 = api.assumption("noClassCalls")) != null ? _api$assumption4 : loose;
26 const supportUnicodeId = !(0, _helperCompilationTargets.isRequired)("transform-unicode-escapes", api.targets());
27 const VISITED = new WeakSet();
28 return {
29 name: "transform-classes",
30 visitor: {
31 ExportDefaultDeclaration(path) {
32 var _path$splitExportDecl;
33 if (!path.get("declaration").isClassDeclaration()) return;
34 (_path$splitExportDecl = path.splitExportDeclaration) != null ? _path$splitExportDecl : path.splitExportDeclaration = require("@babel/traverse").NodePath.prototype.splitExportDeclaration;
35 path.splitExportDeclaration();
36 },
37 ClassDeclaration(path) {
38 const {
39 node
40 } = path;
41 const ref = node.id ? _core.types.cloneNode(node.id) : path.scope.generateUidIdentifier("class");
42 path.replaceWith(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(ref, _core.types.toExpression(node))]));
43 },
44 ClassExpression(path, state) {
45 var _path$ensureFunctionN;
46 const {
47 node
48 } = path;
49 if (VISITED.has(node)) return;
50 (_path$ensureFunctionN = path.ensureFunctionName) != null ? _path$ensureFunctionN : path.ensureFunctionName = require("@babel/traverse").NodePath.prototype.ensureFunctionName;
51 const replacement = path.ensureFunctionName(supportUnicodeId);
52 if (replacement && replacement.node !== node) return;
53 VISITED.add(node);
54 const [replacedPath] = path.replaceWith((0, _transformClass.default)(path, state.file, builtinClasses, loose, {
55 setClassMethods,
56 constantSuper,
57 superIsCallableConstructor,
58 noClassCalls
59 }, supportUnicodeId));
60 if (replacedPath.isCallExpression()) {
61 (0, _helperAnnotateAsPure.default)(replacedPath);
62 const callee = replacedPath.get("callee");
63 if (callee.isArrowFunctionExpression()) {
64 callee.arrowFunctionToExpression();
65 }
66 }
67 }
68 }
69 };
70});
71
72//# sourceMappingURL=index.js.map
Note: See TracBrowser for help on using the repository browser.