@babel/plugin-proposal-decorators 7.22.7 → 8.0.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,7 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.default = _default;
7
- var _core = require("@babel/core");
8
- var _pluginSyntaxDecorators = require("@babel/plugin-syntax-decorators");
9
- var _helperReplaceSupers = require("@babel/helper-replace-supers");
10
- var _helperSplitExportDeclaration = require("@babel/helper-split-export-declaration");
1
+ import { types as t, template } from "@babel/core";
2
+ import syntaxDecorators from "@babel/plugin-syntax-decorators";
3
+ import ReplaceSupers from "@babel/helper-replace-supers";
4
+ import splitExportDeclaration from "@babel/helper-split-export-declaration";
11
5
  function incrementId(id, idx = id.length - 1) {
12
6
  if (idx === -1) {
13
7
  id.unshift(65);
@@ -37,7 +31,7 @@ function createPrivateUidGeneratorForClass(classPath) {
37
31
  incrementId(currentPrivateId);
38
32
  reifiedId = String.fromCharCode(...currentPrivateId);
39
33
  } while (privateNames.has(reifiedId));
40
- return _core.types.privateName(_core.types.identifier(reifiedId));
34
+ return t.privateName(t.identifier(reifiedId));
41
35
  };
42
36
  }
43
37
  function createLazyPrivateUidGeneratorForClass(classPath) {
@@ -52,11 +46,11 @@ function createLazyPrivateUidGeneratorForClass(classPath) {
52
46
  function replaceClassWithVar(path) {
53
47
  if (path.type === "ClassDeclaration") {
54
48
  const varId = path.scope.generateUidIdentifierBasedOnNode(path.node.id);
55
- const classId = _core.types.identifier(path.node.id.name);
49
+ const classId = t.identifier(path.node.id.name);
56
50
  path.scope.rename(classId.name, varId.name);
57
- path.insertBefore(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(varId)]));
51
+ path.insertBefore(t.variableDeclaration("let", [t.variableDeclarator(varId)]));
58
52
  path.get("id").replaceWith(classId);
59
- return [_core.types.cloneNode(varId), path];
53
+ return [t.cloneNode(varId), path];
60
54
  } else {
61
55
  let className;
62
56
  let varId;
@@ -70,52 +64,52 @@ function replaceClassWithVar(path) {
70
64
  } else {
71
65
  varId = path.scope.parent.generateDeclaredUidIdentifier("decorated_class");
72
66
  }
73
- const newClassExpr = _core.types.classExpression(className && _core.types.identifier(className), path.node.superClass, path.node.body);
74
- const [newPath] = path.replaceWith(_core.types.sequenceExpression([newClassExpr, varId]));
75
- return [_core.types.cloneNode(varId), newPath.get("expressions.0")];
67
+ const newClassExpr = t.classExpression(className && t.identifier(className), path.node.superClass, path.node.body);
68
+ const [newPath] = path.replaceWith(t.sequenceExpression([newClassExpr, varId]));
69
+ return [t.cloneNode(varId), newPath.get("expressions.0")];
76
70
  }
77
71
  }
78
72
  function generateClassProperty(key, value, isStatic) {
79
73
  if (key.type === "PrivateName") {
80
- return _core.types.classPrivateProperty(key, value, undefined, isStatic);
74
+ return t.classPrivateProperty(key, value, undefined, isStatic);
81
75
  } else {
82
- return _core.types.classProperty(key, value, undefined, undefined, isStatic);
76
+ return t.classProperty(key, value, undefined, undefined, isStatic);
83
77
  }
84
78
  }
85
79
  function addProxyAccessorsFor(className, element, originalKey, targetKey, version, isComputed = false) {
86
80
  const {
87
81
  static: isStatic
88
82
  } = element.node;
89
- const thisArg = version === "2023-05" && isStatic ? className : _core.types.thisExpression();
90
- const getterBody = _core.types.blockStatement([_core.types.returnStatement(_core.types.memberExpression(_core.types.cloneNode(thisArg), _core.types.cloneNode(targetKey)))]);
91
- const setterBody = _core.types.blockStatement([_core.types.expressionStatement(_core.types.assignmentExpression("=", _core.types.memberExpression(_core.types.cloneNode(thisArg), _core.types.cloneNode(targetKey)), _core.types.identifier("v")))]);
83
+ const thisArg = version === "2023-05" && isStatic ? className : t.thisExpression();
84
+ const getterBody = t.blockStatement([t.returnStatement(t.memberExpression(t.cloneNode(thisArg), t.cloneNode(targetKey)))]);
85
+ const setterBody = t.blockStatement([t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.cloneNode(thisArg), t.cloneNode(targetKey)), t.identifier("v")))]);
92
86
  let getter, setter;
93
87
  if (originalKey.type === "PrivateName") {
94
- getter = _core.types.classPrivateMethod("get", _core.types.cloneNode(originalKey), [], getterBody, isStatic);
95
- setter = _core.types.classPrivateMethod("set", _core.types.cloneNode(originalKey), [_core.types.identifier("v")], setterBody, isStatic);
88
+ getter = t.classPrivateMethod("get", t.cloneNode(originalKey), [], getterBody, isStatic);
89
+ setter = t.classPrivateMethod("set", t.cloneNode(originalKey), [t.identifier("v")], setterBody, isStatic);
96
90
  } else {
97
- getter = _core.types.classMethod("get", _core.types.cloneNode(originalKey), [], getterBody, isComputed, isStatic);
98
- setter = _core.types.classMethod("set", _core.types.cloneNode(originalKey), [_core.types.identifier("v")], setterBody, isComputed, isStatic);
91
+ getter = t.classMethod("get", t.cloneNode(originalKey), [], getterBody, isComputed, isStatic);
92
+ setter = t.classMethod("set", t.cloneNode(originalKey), [t.identifier("v")], setterBody, isComputed, isStatic);
99
93
  }
100
94
  element.insertAfter(setter);
101
95
  element.insertAfter(getter);
102
96
  }
103
97
  function extractProxyAccessorsFor(targetKey, version) {
104
98
  if (version !== "2023-05" && version !== "2023-01") {
105
- return [_core.template.expression.ast`
99
+ return [template.expression.ast`
106
100
  function () {
107
- return this.${_core.types.cloneNode(targetKey)};
101
+ return this.${t.cloneNode(targetKey)};
108
102
  }
109
- `, _core.template.expression.ast`
103
+ `, template.expression.ast`
110
104
  function (value) {
111
- this.${_core.types.cloneNode(targetKey)} = value;
105
+ this.${t.cloneNode(targetKey)} = value;
112
106
  }
113
107
  `];
114
108
  }
115
- return [_core.template.expression.ast`
116
- o => o.${_core.types.cloneNode(targetKey)}
117
- `, _core.template.expression.ast`
118
- (o, v) => o.${_core.types.cloneNode(targetKey)} = v
109
+ return [template.expression.ast`
110
+ o => o.${t.cloneNode(targetKey)}
111
+ `, template.expression.ast`
112
+ (o, v) => o.${t.cloneNode(targetKey)} = v
119
113
  `];
120
114
  }
121
115
  const FIELD = 0;
@@ -157,7 +151,7 @@ function generateDecorationList(decorators, decoratorsThis, version) {
157
151
  const decs = [];
158
152
  for (let i = 0; i < decsCount; i++) {
159
153
  if (version === "2023-05" && hasOneThis) {
160
- decs.push(decoratorsThis[i] || _core.types.unaryExpression("void", _core.types.numericLiteral(0)));
154
+ decs.push(decoratorsThis[i] || t.unaryExpression("void", t.numericLiteral(0)));
161
155
  }
162
156
  decs.push(decorators[i]);
163
157
  }
@@ -167,7 +161,7 @@ function generateDecorationList(decorators, decoratorsThis, version) {
167
161
  };
168
162
  }
169
163
  function generateDecorationExprs(info, version) {
170
- return _core.types.arrayExpression(filteredOrderedDecoratorInfo(info).map(el => {
164
+ return t.arrayExpression(filteredOrderedDecoratorInfo(info).map(el => {
171
165
  const {
172
166
  decs,
173
167
  hasThis
@@ -177,7 +171,7 @@ function generateDecorationExprs(info, version) {
177
171
  flag += version === "2023-05" ? STATIC : STATIC_OLD_VERSION;
178
172
  }
179
173
  if (hasThis) flag += DECORATORS_HAVE_THIS;
180
- return _core.types.arrayExpression([decs.length === 1 ? decs[0] : _core.types.arrayExpression(decs), _core.types.numericLiteral(flag), el.name, ...(el.privateMethods || [])]);
174
+ return t.arrayExpression([decs.length === 1 ? decs[0] : t.arrayExpression(decs), t.numericLiteral(flag), el.name, ...(el.privateMethods || [])]);
181
175
  }));
182
176
  }
183
177
  function extractElementLocalAssignments(decorationInfo) {
@@ -195,8 +189,8 @@ function extractElementLocalAssignments(decorationInfo) {
195
189
  return localIds;
196
190
  }
197
191
  function addCallAccessorsFor(element, key, getId, setId) {
198
- element.insertAfter(_core.types.classPrivateMethod("get", _core.types.cloneNode(key), [], _core.types.blockStatement([_core.types.returnStatement(_core.types.callExpression(_core.types.cloneNode(getId), [_core.types.thisExpression()]))])));
199
- element.insertAfter(_core.types.classPrivateMethod("set", _core.types.cloneNode(key), [_core.types.identifier("v")], _core.types.blockStatement([_core.types.expressionStatement(_core.types.callExpression(_core.types.cloneNode(setId), [_core.types.thisExpression(), _core.types.identifier("v")]))])));
192
+ element.insertAfter(t.classPrivateMethod("get", t.cloneNode(key), [], t.blockStatement([t.returnStatement(t.callExpression(t.cloneNode(getId), [t.thisExpression()]))])));
193
+ element.insertAfter(t.classPrivateMethod("set", t.cloneNode(key), [t.identifier("v")], t.blockStatement([t.expressionStatement(t.callExpression(t.cloneNode(setId), [t.thisExpression(), t.identifier("v")]))])));
200
194
  }
201
195
  function isNotTsParameter(node) {
202
196
  return node.type !== "TSParameterProperty";
@@ -205,13 +199,13 @@ function movePrivateAccessor(element, key, methodLocalVar, isStatic) {
205
199
  let params;
206
200
  let block;
207
201
  if (element.node.kind === "set") {
208
- params = [_core.types.identifier("v")];
209
- block = [_core.types.expressionStatement(_core.types.callExpression(methodLocalVar, [_core.types.thisExpression(), _core.types.identifier("v")]))];
202
+ params = [t.identifier("v")];
203
+ block = [t.expressionStatement(t.callExpression(methodLocalVar, [t.thisExpression(), t.identifier("v")]))];
210
204
  } else {
211
205
  params = [];
212
- block = [_core.types.returnStatement(_core.types.callExpression(methodLocalVar, [_core.types.thisExpression()]))];
206
+ block = [t.returnStatement(t.callExpression(methodLocalVar, [t.thisExpression()]))];
213
207
  }
214
- element.replaceWith(_core.types.classPrivateMethod(element.node.kind, _core.types.cloneNode(key), params, _core.types.blockStatement(block), isStatic));
208
+ element.replaceWith(t.classPrivateMethod(element.node.kind, t.cloneNode(key), params, t.blockStatement(block), isStatic));
215
209
  }
216
210
  function isClassDecoratableElementPath(path) {
217
211
  const {
@@ -220,12 +214,12 @@ function isClassDecoratableElementPath(path) {
220
214
  return type !== "TSDeclareMethod" && type !== "TSIndexSignature" && type !== "StaticBlock";
221
215
  }
222
216
  function staticBlockToIIFE(block) {
223
- return _core.types.callExpression(_core.types.arrowFunctionExpression([], _core.types.blockStatement(block.body)), []);
217
+ return t.callExpression(t.arrowFunctionExpression([], t.blockStatement(block.body)), []);
224
218
  }
225
219
  function maybeSequenceExpression(exprs) {
226
- if (exprs.length === 0) return _core.types.unaryExpression("void", _core.types.numericLiteral(0));
220
+ if (exprs.length === 0) return t.unaryExpression("void", t.numericLiteral(0));
227
221
  if (exprs.length === 1) return exprs[0];
228
- return _core.types.sequenceExpression(exprs);
222
+ return t.sequenceExpression(exprs);
229
223
  }
230
224
  function transformClass(path, state, constantSuper, version) {
231
225
  const body = path.get("body.body");
@@ -246,7 +240,7 @@ function transformClass(path, state, constantSuper, version) {
246
240
  computed
247
241
  } = element.node;
248
242
  const newId = generateClassPrivateUid();
249
- const valueNode = value ? _core.types.cloneNode(value) : undefined;
243
+ const valueNode = value ? t.cloneNode(value) : undefined;
250
244
  const newField = generateClassProperty(newId, valueNode, isStatic);
251
245
  const [newPath] = element.replaceWith(newField);
252
246
  addProxyAccessorsFor(path.node.id, newPath, key, newId, version, computed);
@@ -264,25 +258,25 @@ function transformClass(path, state, constantSuper, version) {
264
258
  const scopeParent = path.scope.parent;
265
259
  const memoiseExpression = (expression, hint) => {
266
260
  const localEvaluatedId = scopeParent.generateDeclaredUidIdentifier(hint);
267
- assignments.push(_core.types.assignmentExpression("=", localEvaluatedId, expression));
268
- return _core.types.cloneNode(localEvaluatedId);
261
+ assignments.push(t.assignmentExpression("=", localEvaluatedId, expression));
262
+ return t.cloneNode(localEvaluatedId);
269
263
  };
270
264
  const decoratorsThis = new Map();
271
265
  const maybeExtractDecorator = decorator => {
272
266
  const {
273
267
  expression
274
268
  } = decorator;
275
- if (version === "2023-05" && _core.types.isMemberExpression(expression)) {
269
+ if (version === "2023-05" && t.isMemberExpression(expression)) {
276
270
  let object;
277
- if (_core.types.isSuper(expression.object) || _core.types.isThisExpression(expression.object)) {
278
- object = memoiseExpression(_core.types.thisExpression(), "obj");
271
+ if (t.isSuper(expression.object) || t.isThisExpression(expression.object)) {
272
+ object = memoiseExpression(t.thisExpression(), "obj");
279
273
  } else if (!scopeParent.isStatic(expression.object)) {
280
274
  object = memoiseExpression(expression.object, "obj");
281
275
  expression.object = object;
282
276
  } else {
283
277
  object = expression.object;
284
278
  }
285
- decoratorsThis.set(decorator, _core.types.cloneNode(object));
279
+ decoratorsThis.set(decorator, t.cloneNode(object));
286
280
  }
287
281
  if (!scopeParent.isStatic(expression)) {
288
282
  decorator.expression = memoiseExpression(expression, "dec");
@@ -301,7 +295,7 @@ function transformClass(path, state, constantSuper, version) {
301
295
  if (!path.node.id) {
302
296
  path.node.id = path.scope.generateUidIdentifier("Class");
303
297
  }
304
- classIdLocal = _core.types.cloneNode(path.node.id);
298
+ classIdLocal = t.cloneNode(path.node.id);
305
299
  }
306
300
  let lastInstancePrivateName;
307
301
  let needsInstancePrivateBrandCheck = false;
@@ -342,7 +336,7 @@ function transformClass(path, state, constantSuper, version) {
342
336
  if (hasDecorators) {
343
337
  needsInstancePrivateBrandCheck = true;
344
338
  }
345
- if (_core.types.isClassPrivateProperty(node) || !lastInstancePrivateName) {
339
+ if (t.isClassPrivateProperty(node) || !lastInstancePrivateName) {
346
340
  lastInstancePrivateName = key;
347
341
  }
348
342
  }
@@ -358,13 +352,13 @@ function transformClass(path, state, constantSuper, version) {
358
352
  const {
359
353
  value
360
354
  } = element.node;
361
- const params = [_core.types.thisExpression()];
355
+ const params = [t.thisExpression()];
362
356
  if (value) {
363
- params.push(_core.types.cloneNode(value));
357
+ params.push(t.cloneNode(value));
364
358
  }
365
359
  const newId = generateClassPrivateUid();
366
360
  const newFieldInitId = element.scope.parent.generateDeclaredUidIdentifier(`init_${name}`);
367
- const newValue = _core.types.callExpression(_core.types.cloneNode(newFieldInitId), params);
361
+ const newValue = t.callExpression(t.cloneNode(newFieldInitId), params);
368
362
  const newField = generateClassProperty(newId, newValue, isStatic);
369
363
  const [newPath] = element.replaceWith(newField);
370
364
  if (isPrivate) {
@@ -380,14 +374,14 @@ function transformClass(path, state, constantSuper, version) {
380
374
  } else if (kind === FIELD) {
381
375
  const initId = element.scope.parent.generateDeclaredUidIdentifier(`init_${name}`);
382
376
  const valuePath = element.get("value");
383
- valuePath.replaceWith(_core.types.callExpression(_core.types.cloneNode(initId), [_core.types.thisExpression(), valuePath.node].filter(v => v)));
377
+ valuePath.replaceWith(t.callExpression(t.cloneNode(initId), [t.thisExpression(), valuePath.node].filter(v => v)));
384
378
  locals = initId;
385
379
  if (isPrivate) {
386
380
  privateMethods = extractProxyAccessorsFor(key, version);
387
381
  }
388
382
  } else if (isPrivate) {
389
383
  locals = element.scope.parent.generateDeclaredUidIdentifier(`call_${name}`);
390
- const replaceSupers = new _helperReplaceSupers.default({
384
+ const replaceSupers = new ReplaceSupers({
391
385
  constantSuper,
392
386
  methodPath: element,
393
387
  objectRef: classIdLocal,
@@ -401,25 +395,25 @@ function transformClass(path, state, constantSuper, version) {
401
395
  body,
402
396
  async: isAsync
403
397
  } = element.node;
404
- privateMethods = [_core.types.functionExpression(undefined, params.filter(isNotTsParameter), body, isAsync)];
398
+ privateMethods = [t.functionExpression(undefined, params.filter(isNotTsParameter), body, isAsync)];
405
399
  if (kind === GETTER || kind === SETTER) {
406
- movePrivateAccessor(element, _core.types.cloneNode(key), _core.types.cloneNode(locals), isStatic);
400
+ movePrivateAccessor(element, t.cloneNode(key), t.cloneNode(locals), isStatic);
407
401
  } else {
408
402
  const node = element.node;
409
- path.node.body.body.unshift(_core.types.classPrivateProperty(key, _core.types.cloneNode(locals), [], node.static));
403
+ path.node.body.body.unshift(t.classPrivateProperty(key, t.cloneNode(locals), [], node.static));
410
404
  decoratedPrivateMethods.add(key.id.name);
411
405
  element.remove();
412
406
  }
413
407
  }
414
408
  let nameExpr;
415
409
  if (isComputed) {
416
- nameExpr = _core.types.cloneNode(key);
410
+ nameExpr = t.cloneNode(key);
417
411
  } else if (key.type === "PrivateName") {
418
- nameExpr = _core.types.stringLiteral(key.id.name);
412
+ nameExpr = t.stringLiteral(key.id.name);
419
413
  } else if (key.type === "Identifier") {
420
- nameExpr = _core.types.stringLiteral(key.name);
414
+ nameExpr = t.stringLiteral(key.name);
421
415
  } else {
422
- nameExpr = _core.types.cloneNode(key);
416
+ nameExpr = t.cloneNode(key);
423
417
  }
424
418
  elementDecoratorInfo.push({
425
419
  kind,
@@ -461,34 +455,34 @@ function transformClass(path, state, constantSuper, version) {
461
455
  if (requiresProtoInit) {
462
456
  protoInitLocal = scopeParent.generateDeclaredUidIdentifier("initProto");
463
457
  elementLocals.push(protoInitLocal);
464
- const protoInitCall = _core.types.callExpression(_core.types.cloneNode(protoInitLocal), [_core.types.thisExpression()]);
458
+ const protoInitCall = t.callExpression(t.cloneNode(protoInitLocal), [t.thisExpression()]);
465
459
  if (firstFieldPath) {
466
460
  const value = firstFieldPath.get("value");
467
461
  const body = [protoInitCall];
468
462
  if (value.node) {
469
463
  body.push(value.node);
470
464
  }
471
- value.replaceWith(_core.types.sequenceExpression(body));
465
+ value.replaceWith(t.sequenceExpression(body));
472
466
  } else if (constructorPath) {
473
467
  if (path.node.superClass) {
474
468
  path.traverse({
475
469
  CallExpression: {
476
470
  exit(path) {
477
471
  if (!path.get("callee").isSuper()) return;
478
- path.replaceWith(_core.types.callExpression(_core.types.cloneNode(protoInitLocal), [path.node]));
472
+ path.replaceWith(t.callExpression(t.cloneNode(protoInitLocal), [path.node]));
479
473
  path.skip();
480
474
  }
481
475
  }
482
476
  });
483
477
  } else {
484
- constructorPath.node.body.body.unshift(_core.types.expressionStatement(protoInitCall));
478
+ constructorPath.node.body.body.unshift(t.expressionStatement(protoInitCall));
485
479
  }
486
480
  } else {
487
- const body = [_core.types.expressionStatement(protoInitCall)];
481
+ const body = [t.expressionStatement(protoInitCall)];
488
482
  if (path.node.superClass) {
489
- body.unshift(_core.types.expressionStatement(_core.types.callExpression(_core.types.super(), [_core.types.spreadElement(_core.types.identifier("args"))])));
483
+ body.unshift(t.expressionStatement(t.callExpression(t.super(), [t.spreadElement(t.identifier("args"))])));
490
484
  }
491
- path.node.body.body.unshift(_core.types.classMethod("constructor", _core.types.identifier("constructor"), [_core.types.restElement(_core.types.identifier("args"))], _core.types.blockStatement(body)));
485
+ path.node.body.body.unshift(t.classMethod("constructor", t.identifier("constructor"), [t.restElement(t.identifier("args"))], t.blockStatement(body)));
492
486
  }
493
487
  }
494
488
  if (requiresStaticInit) {
@@ -509,7 +503,7 @@ function transformClass(path, state, constantSuper, version) {
509
503
  }
510
504
  const classLocals = [];
511
505
  let classInitInjected = false;
512
- const classInitCall = classInitLocal && _core.types.callExpression(_core.types.cloneNode(classInitLocal), []);
506
+ const classInitCall = classInitLocal && t.callExpression(t.cloneNode(classInitLocal), []);
513
507
  const originalClass = path.node;
514
508
  if (classDecorators) {
515
509
  classLocals.push(classIdLocal, classInitLocal);
@@ -535,12 +529,12 @@ function transformClass(path, state, constantSuper, version) {
535
529
  }
536
530
  });
537
531
  if (statics.length > 0 || staticBlocks.length > 0) {
538
- const staticsClass = _core.template.expression.ast`
532
+ const staticsClass = template.expression.ast`
539
533
  class extends ${state.addHelper("identity")} {}
540
534
  `;
541
- staticsClass.body.body = [_core.types.staticBlock([_core.types.toStatement(originalClass, true) || _core.types.expressionStatement(originalClass)]), ...statics];
535
+ staticsClass.body.body = [t.staticBlock([t.toStatement(originalClass, true) || t.expressionStatement(originalClass)]), ...statics];
542
536
  const constructorBody = [];
543
- const newExpr = _core.types.newExpression(staticsClass, []);
537
+ const newExpr = t.newExpression(staticsClass, []);
544
538
  if (staticBlocks.length > 0) {
545
539
  constructorBody.push(...staticBlocks.map(staticBlockToIIFE));
546
540
  }
@@ -549,94 +543,80 @@ function transformClass(path, state, constantSuper, version) {
549
543
  constructorBody.push(classInitCall);
550
544
  }
551
545
  if (constructorBody.length > 0) {
552
- constructorBody.unshift(_core.types.callExpression(_core.types.super(), [_core.types.cloneNode(classIdLocal)]));
553
- staticsClass.body.body.push(_core.types.classMethod("constructor", _core.types.identifier("constructor"), [], _core.types.blockStatement([_core.types.expressionStatement(_core.types.sequenceExpression(constructorBody))])));
546
+ constructorBody.unshift(t.callExpression(t.super(), [t.cloneNode(classIdLocal)]));
547
+ staticsClass.body.body.push(t.classMethod("constructor", t.identifier("constructor"), [], t.blockStatement([t.expressionStatement(t.sequenceExpression(constructorBody))])));
554
548
  } else {
555
- newExpr.arguments.push(_core.types.cloneNode(classIdLocal));
549
+ newExpr.arguments.push(t.cloneNode(classIdLocal));
556
550
  }
557
551
  path.replaceWith(newExpr);
558
552
  }
559
553
  }
560
554
  if (!classInitInjected && classInitCall) {
561
- path.node.body.body.push(_core.types.staticBlock([_core.types.expressionStatement(classInitCall)]));
555
+ path.node.body.body.push(t.staticBlock([t.expressionStatement(classInitCall)]));
562
556
  }
563
- originalClass.body.body.unshift(_core.types.staticBlock([_core.types.expressionStatement(createLocalsAssignment(elementLocals, classLocals, elementDecorations, _core.types.arrayExpression(classDecorations), _core.types.numericLiteral(classDecorationsFlag), needsInstancePrivateBrandCheck ? lastInstancePrivateName : null, state, version)), requiresStaticInit && _core.types.expressionStatement(_core.types.callExpression(_core.types.cloneNode(staticInitLocal), [_core.types.thisExpression()]))].filter(Boolean)));
564
- path.insertBefore(assignments.map(expr => _core.types.expressionStatement(expr)));
557
+ originalClass.body.body.unshift(t.staticBlock([t.expressionStatement(createLocalsAssignment(elementLocals, classLocals, elementDecorations, t.arrayExpression(classDecorations), t.numericLiteral(classDecorationsFlag), needsInstancePrivateBrandCheck ? lastInstancePrivateName : null, state, version)), requiresStaticInit && t.expressionStatement(t.callExpression(t.cloneNode(staticInitLocal), [t.thisExpression()]))].filter(Boolean)));
558
+ path.insertBefore(assignments.map(expr => t.expressionStatement(expr)));
565
559
  path.scope.crawl();
566
560
  return path;
567
561
  }
568
562
  function createLocalsAssignment(elementLocals, classLocals, elementDecorations, classDecorations, classDecorationsFlag, maybePrivateBranName, state, version) {
569
563
  let lhs, rhs;
570
- const args = [_core.types.thisExpression(), elementDecorations, classDecorations];
571
- {
572
- if (version === "2021-12" || version === "2022-03" && !state.availableHelper("applyDecs2203R")) {
573
- const lhs = _core.types.arrayPattern([...elementLocals, ...classLocals]);
574
- const rhs = _core.types.callExpression(state.addHelper(version === "2021-12" ? "applyDecs" : "applyDecs2203"), args);
575
- return _core.types.assignmentExpression("=", lhs, rhs);
576
- }
577
- }
578
- if (version === "2023-05") {
564
+ const args = [t.thisExpression(), elementDecorations, classDecorations];
565
+ ;
566
+ if (true) {
579
567
  if (maybePrivateBranName || classDecorationsFlag.value !== 0) {
580
568
  args.push(classDecorationsFlag);
581
569
  }
582
570
  if (maybePrivateBranName) {
583
- args.push(_core.template.expression.ast`
584
- _ => ${_core.types.cloneNode(maybePrivateBranName)} in _
571
+ args.push(template.expression.ast`
572
+ _ => ${t.cloneNode(maybePrivateBranName)} in _
585
573
  `);
586
574
  }
587
- rhs = _core.types.callExpression(state.addHelper("applyDecs2305"), args);
575
+ rhs = t.callExpression(state.addHelper("applyDecs2305"), args);
588
576
  } else if (version === "2023-01") {
589
577
  if (maybePrivateBranName) {
590
- args.push(_core.template.expression.ast`
591
- _ => ${_core.types.cloneNode(maybePrivateBranName)} in _
578
+ args.push(template.expression.ast`
579
+ _ => ${t.cloneNode(maybePrivateBranName)} in _
592
580
  `);
593
581
  }
594
- rhs = _core.types.callExpression(state.addHelper("applyDecs2301"), args);
582
+ rhs = t.callExpression(state.addHelper("applyDecs2301"), args);
595
583
  } else {
596
- rhs = _core.types.callExpression(state.addHelper("applyDecs2203R"), args);
584
+ rhs = t.callExpression(state.addHelper("applyDecs2203R"), args);
597
585
  }
598
586
  if (elementLocals.length > 0) {
599
587
  if (classLocals.length > 0) {
600
- lhs = _core.types.objectPattern([_core.types.objectProperty(_core.types.identifier("e"), _core.types.arrayPattern(elementLocals)), _core.types.objectProperty(_core.types.identifier("c"), _core.types.arrayPattern(classLocals))]);
588
+ lhs = t.objectPattern([t.objectProperty(t.identifier("e"), t.arrayPattern(elementLocals)), t.objectProperty(t.identifier("c"), t.arrayPattern(classLocals))]);
601
589
  } else {
602
- lhs = _core.types.arrayPattern(elementLocals);
603
- rhs = _core.types.memberExpression(rhs, _core.types.identifier("e"), false, false);
590
+ lhs = t.arrayPattern(elementLocals);
591
+ rhs = t.memberExpression(rhs, t.identifier("e"), false, false);
604
592
  }
605
593
  } else {
606
- lhs = _core.types.arrayPattern(classLocals);
607
- rhs = _core.types.memberExpression(rhs, _core.types.identifier("c"), false, false);
594
+ lhs = t.arrayPattern(classLocals);
595
+ rhs = t.memberExpression(rhs, t.identifier("c"), false, false);
608
596
  }
609
- return _core.types.assignmentExpression("=", lhs, rhs);
597
+ return t.assignmentExpression("=", lhs, rhs);
610
598
  }
611
- function _default({
599
+ export default function ({
612
600
  assertVersion,
613
601
  assumption
614
602
  }, {
615
603
  loose
616
604
  }, version) {
617
- var _assumption;
618
605
  {
619
- if (version === "2023-05" || version === "2023-01") {
620
- assertVersion("^7.21.0");
621
- } else if (version === "2021-12") {
622
- assertVersion("^7.16.0");
623
- } else {
624
- assertVersion("^7.19.0");
625
- }
606
+ assertVersion("^7.21.0");
626
607
  }
627
608
  const VISITED = new WeakSet();
628
- const constantSuper = (_assumption = assumption("constantSuper")) != null ? _assumption : loose;
609
+ const constantSuper = assumption("constantSuper") ?? loose;
629
610
  return {
630
611
  name: "proposal-decorators",
631
- inherits: _pluginSyntaxDecorators.default,
612
+ inherits: syntaxDecorators,
632
613
  visitor: {
633
614
  "ExportNamedDeclaration|ExportDefaultDeclaration"(path) {
634
- var _declaration$decorato;
635
615
  const {
636
616
  declaration
637
617
  } = path.node;
638
- if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0) {
639
- (0, _helperSplitExportDeclaration.default)(path);
618
+ if (declaration?.type === "ClassDeclaration" && declaration.decorators?.length > 0) {
619
+ splitExportDeclaration(path);
640
620
  }
641
621
  },
642
622
  Class(path, state) {