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

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

F4 Finalna Verzija

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