| | |
| | | Object.defineProperty(exports, "__esModule", { |
| | | value: true |
| | | }); |
| | | exports.createClassFeaturePlugin = createClassFeaturePlugin; |
| | | Object.defineProperty(exports, "injectInitialization", { |
| | | Object.defineProperty(exports, "FEATURES", { |
| | | enumerable: true, |
| | | get: function () { |
| | | return _misc.injectInitialization; |
| | | return _features.FEATURES; |
| | | } |
| | | }); |
| | | exports.createClassFeaturePlugin = createClassFeaturePlugin; |
| | | Object.defineProperty(exports, "enableFeature", { |
| | | enumerable: true, |
| | | get: function () { |
| | | return _features.enableFeature; |
| | | } |
| | | }); |
| | | Object.defineProperty(exports, "FEATURES", { |
| | | Object.defineProperty(exports, "injectInitialization", { |
| | | enumerable: true, |
| | | get: function () { |
| | | return _features.FEATURES; |
| | | return _misc.injectInitialization; |
| | | } |
| | | }); |
| | | |
| | |
| | | |
| | | var _features = require("./features"); |
| | | |
| | | const version = "7.15.4".split(".").reduce((v, x) => v * 1e5 + +x, 0); |
| | | var _typescript = require("./typescript"); |
| | | |
| | | const version = "7.17.12".split(".").reduce((v, x) => v * 1e5 + +x, 0); |
| | | const versionKey = "@babel/plugin-class-features/version"; |
| | | |
| | | function createClassFeaturePlugin({ |
| | |
| | | manipulateOptions, |
| | | api = { |
| | | assumption: () => void 0 |
| | | } |
| | | }, |
| | | inherits |
| | | }) { |
| | | const setPublicClassFields = api.assumption("setPublicClassFields"); |
| | | const privateFieldsAsProperties = api.assumption("privateFieldsAsProperties"); |
| | |
| | | return { |
| | | name, |
| | | manipulateOptions, |
| | | inherits, |
| | | |
| | | pre() { |
| | | (0, _features.enableFeature)(this.file, feature, loose); |
| | |
| | | visitor: { |
| | | Class(path, state) { |
| | | if (this.file.get(versionKey) !== version) return; |
| | | (0, _features.verifyUsedFeatures)(path, this.file); |
| | | if (!(0, _features.shouldTransform)(path, this.file)) return; |
| | | if (path.isClassDeclaration()) (0, _typescript.assertFieldTransformed)(path); |
| | | const loose = (0, _features.isLoose)(this.file, feature); |
| | | let constructor; |
| | | const isDecorated = (0, _decorators.hasDecorators)(path.node); |
| | |
| | | const body = path.get("body"); |
| | | |
| | | for (const path of body.get("body")) { |
| | | (0, _features.verifyUsedFeatures)(path, this.file); |
| | | |
| | | if ((path.isClassProperty() || path.isClassMethod()) && path.node.computed) { |
| | | computedPaths.push(path); |
| | | } |
| | |
| | | if (isDecorated) return; |
| | | |
| | | for (const prop of props) { |
| | | if (prop.node.static) continue; |
| | | if (_core.types.isStaticBlock != null && _core.types.isStaticBlock(prop.node) || prop.node.static) continue; |
| | | prop.traverse(referenceVisitor, state); |
| | | } |
| | | }); |
| | |
| | | if (pureStaticNodes.length > 0) { |
| | | wrappedPath.find(parent => parent.isStatement() || parent.isDeclaration()).insertAfter(pureStaticNodes); |
| | | } |
| | | }, |
| | | |
| | | PrivateName(path) { |
| | | if (this.file.get(versionKey) !== version || path.parentPath.isPrivate({ |
| | | key: path.node |
| | | })) { |
| | | return; |
| | | } |
| | | |
| | | throw path.buildCodeFrameError(`Unknown PrivateName "${path}"`); |
| | | }, |
| | | |
| | | ExportDefaultDeclaration(path) { |