@babel/plugin-proposal-decorators 7.21.4-esm.4 → 7.22.0

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,7 +1,13 @@
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";
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");
5
11
  function incrementId(id, idx = id.length - 1) {
6
12
  if (idx === -1) {
7
13
  id.unshift(65);
@@ -31,7 +37,7 @@ function createPrivateUidGeneratorForClass(classPath) {
31
37
  incrementId(currentPrivateId);
32
38
  reifiedId = String.fromCharCode(...currentPrivateId);
33
39
  } while (privateNames.has(reifiedId));
34
- return t.privateName(t.identifier(reifiedId));
40
+ return _core.types.privateName(_core.types.identifier(reifiedId));
35
41
  };
36
42
  }
37
43
  function createLazyPrivateUidGeneratorForClass(classPath) {
@@ -46,11 +52,11 @@ function createLazyPrivateUidGeneratorForClass(classPath) {
46
52
  function replaceClassWithVar(path) {
47
53
  if (path.type === "ClassDeclaration") {
48
54
  const varId = path.scope.generateUidIdentifierBasedOnNode(path.node.id);
49
- const classId = t.identifier(path.node.id.name);
55
+ const classId = _core.types.identifier(path.node.id.name);
50
56
  path.scope.rename(classId.name, varId.name);
51
- path.insertBefore(t.variableDeclaration("let", [t.variableDeclarator(varId)]));
57
+ path.insertBefore(_core.types.variableDeclaration("let", [_core.types.variableDeclarator(varId)]));
52
58
  path.get("id").replaceWith(classId);
53
- return [t.cloneNode(varId), path];
59
+ return [_core.types.cloneNode(varId), path];
54
60
  } else {
55
61
  let className;
56
62
  let varId;
@@ -64,51 +70,52 @@ function replaceClassWithVar(path) {
64
70
  } else {
65
71
  varId = path.scope.parent.generateDeclaredUidIdentifier("decorated_class");
66
72
  }
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")];
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")];
70
76
  }
71
77
  }
72
78
  function generateClassProperty(key, value, isStatic) {
73
79
  if (key.type === "PrivateName") {
74
- return t.classPrivateProperty(key, value, undefined, isStatic);
80
+ return _core.types.classPrivateProperty(key, value, undefined, isStatic);
75
81
  } else {
76
- return t.classProperty(key, value, undefined, undefined, isStatic);
82
+ return _core.types.classProperty(key, value, undefined, undefined, isStatic);
77
83
  }
78
84
  }
79
- function addProxyAccessorsFor(element, originalKey, targetKey, isComputed = false) {
85
+ function addProxyAccessorsFor(className, element, originalKey, targetKey, version, isComputed = false) {
80
86
  const {
81
87
  static: isStatic
82
88
  } = element.node;
83
- const getterBody = t.blockStatement([t.returnStatement(t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)))]);
84
- const setterBody = t.blockStatement([t.expressionStatement(t.assignmentExpression("=", t.memberExpression(t.thisExpression(), t.cloneNode(targetKey)), t.identifier("v")))]);
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")))]);
85
92
  let getter, setter;
86
93
  if (originalKey.type === "PrivateName") {
87
- getter = t.classPrivateMethod("get", t.cloneNode(originalKey), [], getterBody, isStatic);
88
- setter = t.classPrivateMethod("set", t.cloneNode(originalKey), [t.identifier("v")], setterBody, isStatic);
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);
89
96
  } else {
90
- getter = t.classMethod("get", t.cloneNode(originalKey), [], getterBody, isComputed, isStatic);
91
- setter = t.classMethod("set", t.cloneNode(originalKey), [t.identifier("v")], setterBody, isComputed, isStatic);
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);
92
99
  }
93
100
  element.insertAfter(setter);
94
101
  element.insertAfter(getter);
95
102
  }
96
103
  function extractProxyAccessorsFor(targetKey, version) {
97
- if (version !== "2023-01") {
98
- return [template.expression.ast`
104
+ if (version !== "2023-05" && version !== "2023-01") {
105
+ return [_core.template.expression.ast`
99
106
  function () {
100
- return this.${t.cloneNode(targetKey)};
107
+ return this.${_core.types.cloneNode(targetKey)};
101
108
  }
102
- `, template.expression.ast`
109
+ `, _core.template.expression.ast`
103
110
  function (value) {
104
- this.${t.cloneNode(targetKey)} = value;
111
+ this.${_core.types.cloneNode(targetKey)} = value;
105
112
  }
106
113
  `];
107
114
  }
108
- return [template.expression.ast`
109
- o => o.${t.cloneNode(targetKey)}
110
- `, template.expression.ast`
111
- (o, v) => o.${t.cloneNode(targetKey)} = v
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
112
119
  `];
113
120
  }
114
121
  const FIELD = 0;
@@ -116,7 +123,9 @@ const ACCESSOR = 1;
116
123
  const METHOD = 2;
117
124
  const GETTER = 3;
118
125
  const SETTER = 4;
119
- const STATIC = 5;
126
+ const STATIC_OLD_VERSION = 5;
127
+ const STATIC = 8;
128
+ const DECORATORS_HAVE_THIS = 16;
120
129
  function getElementKind(element) {
121
130
  switch (element.node.type) {
122
131
  case "ClassProperty":
@@ -142,11 +151,33 @@ function filteredOrderedDecoratorInfo(info) {
142
151
  const filtered = info.filter(isDecoratorInfo);
143
152
  return [...filtered.filter(el => el.isStatic && el.kind >= ACCESSOR && el.kind <= SETTER), ...filtered.filter(el => !el.isStatic && el.kind >= ACCESSOR && el.kind <= SETTER), ...filtered.filter(el => el.isStatic && el.kind === FIELD), ...filtered.filter(el => !el.isStatic && el.kind === FIELD)];
144
153
  }
145
- function generateDecorationExprs(info) {
146
- return t.arrayExpression(filteredOrderedDecoratorInfo(info).map(el => {
147
- const decs = el.decorators.length > 1 ? t.arrayExpression(el.decorators) : el.decorators[0];
148
- const kind = el.isStatic ? el.kind + STATIC : el.kind;
149
- return t.arrayExpression([decs, t.numericLiteral(kind), el.name, ...(el.privateMethods || [])]);
154
+ function generateDecorationList(decorators, decoratorsThis, version) {
155
+ const decsCount = decorators.length;
156
+ const hasOneThis = decoratorsThis.some(Boolean);
157
+ const decs = [];
158
+ for (let i = 0; i < decsCount; i++) {
159
+ if (version === "2023-05" && hasOneThis) {
160
+ decs.push(decoratorsThis[i] || _core.types.unaryExpression("void", _core.types.numericLiteral(0)));
161
+ }
162
+ decs.push(decorators[i]);
163
+ }
164
+ return {
165
+ hasThis: hasOneThis,
166
+ decs
167
+ };
168
+ }
169
+ function generateDecorationExprs(info, version) {
170
+ return _core.types.arrayExpression(filteredOrderedDecoratorInfo(info).map(el => {
171
+ const {
172
+ decs,
173
+ hasThis
174
+ } = generateDecorationList(el.decorators, el.decoratorsThis, version);
175
+ let flag = el.kind;
176
+ if (el.isStatic) {
177
+ flag += version === "2023-05" ? STATIC : STATIC_OLD_VERSION;
178
+ }
179
+ 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 || [])]);
150
181
  }));
151
182
  }
152
183
  function extractElementLocalAssignments(decorationInfo) {
@@ -164,8 +195,8 @@ function extractElementLocalAssignments(decorationInfo) {
164
195
  return localIds;
165
196
  }
166
197
  function addCallAccessorsFor(element, key, getId, setId) {
167
- element.insertAfter(t.classPrivateMethod("get", t.cloneNode(key), [], t.blockStatement([t.returnStatement(t.callExpression(t.cloneNode(getId), [t.thisExpression()]))])));
168
- 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")]))])));
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")]))])));
169
200
  }
170
201
  function isNotTsParameter(node) {
171
202
  return node.type !== "TSParameterProperty";
@@ -174,13 +205,13 @@ function movePrivateAccessor(element, key, methodLocalVar, isStatic) {
174
205
  let params;
175
206
  let block;
176
207
  if (element.node.kind === "set") {
177
- params = [t.identifier("v")];
178
- block = [t.expressionStatement(t.callExpression(methodLocalVar, [t.thisExpression(), t.identifier("v")]))];
208
+ params = [_core.types.identifier("v")];
209
+ block = [_core.types.expressionStatement(_core.types.callExpression(methodLocalVar, [_core.types.thisExpression(), _core.types.identifier("v")]))];
179
210
  } else {
180
211
  params = [];
181
- block = [t.returnStatement(t.callExpression(methodLocalVar, [t.thisExpression()]))];
212
+ block = [_core.types.returnStatement(_core.types.callExpression(methodLocalVar, [_core.types.thisExpression()]))];
182
213
  }
183
- element.replaceWith(t.classPrivateMethod(element.node.kind, t.cloneNode(key), params, t.blockStatement(block), isStatic));
214
+ element.replaceWith(_core.types.classPrivateMethod(element.node.kind, _core.types.cloneNode(key), params, _core.types.blockStatement(block), isStatic));
184
215
  }
185
216
  function isClassDecoratableElementPath(path) {
186
217
  const {
@@ -189,12 +220,12 @@ function isClassDecoratableElementPath(path) {
189
220
  return type !== "TSDeclareMethod" && type !== "TSIndexSignature" && type !== "StaticBlock";
190
221
  }
191
222
  function staticBlockToIIFE(block) {
192
- return t.callExpression(t.arrowFunctionExpression([], t.blockStatement(block.body)), []);
223
+ return _core.types.callExpression(_core.types.arrowFunctionExpression([], _core.types.blockStatement(block.body)), []);
193
224
  }
194
225
  function maybeSequenceExpression(exprs) {
195
- if (exprs.length === 0) return t.unaryExpression("void", t.numericLiteral(0));
226
+ if (exprs.length === 0) return _core.types.unaryExpression("void", _core.types.numericLiteral(0));
196
227
  if (exprs.length === 1) return exprs[0];
197
- return t.sequenceExpression(exprs);
228
+ return _core.types.sequenceExpression(exprs);
198
229
  }
199
230
  function transformClass(path, state, constantSuper, version) {
200
231
  const body = path.get("body.body");
@@ -215,10 +246,10 @@ function transformClass(path, state, constantSuper, version) {
215
246
  computed
216
247
  } = element.node;
217
248
  const newId = generateClassPrivateUid();
218
- const valueNode = value ? t.cloneNode(value) : undefined;
249
+ const valueNode = value ? _core.types.cloneNode(value) : undefined;
219
250
  const newField = generateClassProperty(newId, valueNode, isStatic);
220
251
  const [newPath] = element.replaceWith(newField);
221
- addProxyAccessorsFor(newPath, key, newId, computed);
252
+ addProxyAccessorsFor(path.node.id, newPath, key, newId, version, computed);
222
253
  }
223
254
  }
224
255
  if (!classDecorators && !hasElementDecorators) return;
@@ -233,8 +264,29 @@ function transformClass(path, state, constantSuper, version) {
233
264
  const scopeParent = path.scope.parent;
234
265
  const memoiseExpression = (expression, hint) => {
235
266
  const localEvaluatedId = scopeParent.generateDeclaredUidIdentifier(hint);
236
- assignments.push(t.assignmentExpression("=", localEvaluatedId, expression));
237
- return t.cloneNode(localEvaluatedId);
267
+ assignments.push(_core.types.assignmentExpression("=", localEvaluatedId, expression));
268
+ return _core.types.cloneNode(localEvaluatedId);
269
+ };
270
+ const decoratorsThis = new Map();
271
+ const maybeExtractDecorator = decorator => {
272
+ const {
273
+ expression
274
+ } = decorator;
275
+ if (version === "2023-05" && _core.types.isMemberExpression(expression)) {
276
+ let object;
277
+ if (_core.types.isSuper(expression.object) || _core.types.isThisExpression(expression.object)) {
278
+ object = memoiseExpression(_core.types.thisExpression(), "obj");
279
+ } else if (!scopeParent.isStatic(expression.object)) {
280
+ object = memoiseExpression(expression.object, "obj");
281
+ expression.object = object;
282
+ } else {
283
+ object = expression.object;
284
+ }
285
+ decoratorsThis.set(decorator, _core.types.cloneNode(object));
286
+ }
287
+ if (!scopeParent.isStatic(expression)) {
288
+ decorator.expression = memoiseExpression(expression, "dec");
289
+ }
238
290
  };
239
291
  if (classDecorators) {
240
292
  classInitLocal = scopeParent.generateDeclaredUidIdentifier("initClass");
@@ -243,15 +295,13 @@ function transformClass(path, state, constantSuper, version) {
243
295
  classIdLocal = classId;
244
296
  path.node.decorators = null;
245
297
  for (const classDecorator of classDecorators) {
246
- if (!scopeParent.isStatic(classDecorator.expression)) {
247
- classDecorator.expression = memoiseExpression(classDecorator.expression, "dec");
248
- }
298
+ maybeExtractDecorator(classDecorator);
249
299
  }
250
300
  } else {
251
301
  if (!path.node.id) {
252
302
  path.node.id = path.scope.generateUidIdentifier("Class");
253
303
  }
254
- classIdLocal = t.cloneNode(path.node.id);
304
+ classIdLocal = _core.types.cloneNode(path.node.id);
255
305
  }
256
306
  let lastInstancePrivateName;
257
307
  let needsInstancePrivateBrandCheck = false;
@@ -267,9 +317,7 @@ function transformClass(path, state, constantSuper, version) {
267
317
  const hasDecorators = Array.isArray(decorators) && decorators.length > 0;
268
318
  if (hasDecorators) {
269
319
  for (const decoratorPath of decorators) {
270
- if (!scopeParent.isStatic(decoratorPath.node.expression)) {
271
- decoratorPath.node.expression = memoiseExpression(decoratorPath.node.expression, "dec");
272
- }
320
+ maybeExtractDecorator(decoratorPath.node);
273
321
  }
274
322
  }
275
323
  const isComputed = "computed" in element.node && element.node.computed === true;
@@ -294,7 +342,7 @@ function transformClass(path, state, constantSuper, version) {
294
342
  if (hasDecorators) {
295
343
  needsInstancePrivateBrandCheck = true;
296
344
  }
297
- if (t.isClassPrivateProperty(node) || !lastInstancePrivateName) {
345
+ if (_core.types.isClassPrivateProperty(node) || !lastInstancePrivateName) {
298
346
  lastInstancePrivateName = key;
299
347
  }
300
348
  }
@@ -310,13 +358,13 @@ function transformClass(path, state, constantSuper, version) {
310
358
  const {
311
359
  value
312
360
  } = element.node;
313
- const params = [t.thisExpression()];
361
+ const params = [_core.types.thisExpression()];
314
362
  if (value) {
315
- params.push(t.cloneNode(value));
363
+ params.push(_core.types.cloneNode(value));
316
364
  }
317
365
  const newId = generateClassPrivateUid();
318
366
  const newFieldInitId = element.scope.parent.generateDeclaredUidIdentifier(`init_${name}`);
319
- const newValue = t.callExpression(t.cloneNode(newFieldInitId), params);
367
+ const newValue = _core.types.callExpression(_core.types.cloneNode(newFieldInitId), params);
320
368
  const newField = generateClassProperty(newId, newValue, isStatic);
321
369
  const [newPath] = element.replaceWith(newField);
322
370
  if (isPrivate) {
@@ -326,20 +374,20 @@ function transformClass(path, state, constantSuper, version) {
326
374
  addCallAccessorsFor(newPath, key, getId, setId);
327
375
  locals = [newFieldInitId, getId, setId];
328
376
  } else {
329
- addProxyAccessorsFor(newPath, key, newId, isComputed);
377
+ addProxyAccessorsFor(path.node.id, newPath, key, newId, version, isComputed);
330
378
  locals = newFieldInitId;
331
379
  }
332
380
  } else if (kind === FIELD) {
333
381
  const initId = element.scope.parent.generateDeclaredUidIdentifier(`init_${name}`);
334
382
  const valuePath = element.get("value");
335
- valuePath.replaceWith(t.callExpression(t.cloneNode(initId), [t.thisExpression(), valuePath.node].filter(v => v)));
383
+ valuePath.replaceWith(_core.types.callExpression(_core.types.cloneNode(initId), [_core.types.thisExpression(), valuePath.node].filter(v => v)));
336
384
  locals = initId;
337
385
  if (isPrivate) {
338
386
  privateMethods = extractProxyAccessorsFor(key, version);
339
387
  }
340
388
  } else if (isPrivate) {
341
389
  locals = element.scope.parent.generateDeclaredUidIdentifier(`call_${name}`);
342
- const replaceSupers = new ReplaceSupers({
390
+ const replaceSupers = new _helperReplaceSupers.default({
343
391
  constantSuper,
344
392
  methodPath: element,
345
393
  objectRef: classIdLocal,
@@ -353,29 +401,30 @@ function transformClass(path, state, constantSuper, version) {
353
401
  body,
354
402
  async: isAsync
355
403
  } = element.node;
356
- privateMethods = [t.functionExpression(undefined, params.filter(isNotTsParameter), body, isAsync)];
404
+ privateMethods = [_core.types.functionExpression(undefined, params.filter(isNotTsParameter), body, isAsync)];
357
405
  if (kind === GETTER || kind === SETTER) {
358
- movePrivateAccessor(element, t.cloneNode(key), t.cloneNode(locals), isStatic);
406
+ movePrivateAccessor(element, _core.types.cloneNode(key), _core.types.cloneNode(locals), isStatic);
359
407
  } else {
360
408
  const node = element.node;
361
- path.node.body.body.unshift(t.classPrivateProperty(key, t.cloneNode(locals), [], node.static));
409
+ path.node.body.body.unshift(_core.types.classPrivateProperty(key, _core.types.cloneNode(locals), [], node.static));
362
410
  decoratedPrivateMethods.add(key.id.name);
363
411
  element.remove();
364
412
  }
365
413
  }
366
414
  let nameExpr;
367
415
  if (isComputed) {
368
- nameExpr = t.cloneNode(key);
416
+ nameExpr = _core.types.cloneNode(key);
369
417
  } else if (key.type === "PrivateName") {
370
- nameExpr = t.stringLiteral(key.id.name);
418
+ nameExpr = _core.types.stringLiteral(key.id.name);
371
419
  } else if (key.type === "Identifier") {
372
- nameExpr = t.stringLiteral(key.name);
420
+ nameExpr = _core.types.stringLiteral(key.name);
373
421
  } else {
374
- nameExpr = t.cloneNode(key);
422
+ nameExpr = _core.types.cloneNode(key);
375
423
  }
376
424
  elementDecoratorInfo.push({
377
425
  kind,
378
426
  decorators: decorators.map(d => d.node.expression),
427
+ decoratorsThis: decorators.map(d => decoratorsThis.get(d.node)),
379
428
  name: nameExpr,
380
429
  isStatic,
381
430
  privateMethods,
@@ -397,40 +446,49 @@ function transformClass(path, state, constantSuper, version) {
397
446
  }
398
447
  }
399
448
  }
400
- const elementDecorations = generateDecorationExprs(elementDecoratorInfo);
401
- const classDecorations = t.arrayExpression((classDecorators || []).map(d => d.expression));
449
+ const elementDecorations = generateDecorationExprs(elementDecoratorInfo, version);
450
+ let classDecorationsFlag = 0;
451
+ let classDecorations = [];
452
+ if (classDecorators) {
453
+ const {
454
+ hasThis,
455
+ decs
456
+ } = generateDecorationList(classDecorators.map(el => el.expression), classDecorators.map(dec => decoratorsThis.get(dec)), version);
457
+ classDecorationsFlag = hasThis ? 1 : 0;
458
+ classDecorations = decs;
459
+ }
402
460
  const elementLocals = extractElementLocalAssignments(elementDecoratorInfo);
403
461
  if (requiresProtoInit) {
404
462
  protoInitLocal = scopeParent.generateDeclaredUidIdentifier("initProto");
405
463
  elementLocals.push(protoInitLocal);
406
- const protoInitCall = t.callExpression(t.cloneNode(protoInitLocal), [t.thisExpression()]);
464
+ const protoInitCall = _core.types.callExpression(_core.types.cloneNode(protoInitLocal), [_core.types.thisExpression()]);
407
465
  if (firstFieldPath) {
408
466
  const value = firstFieldPath.get("value");
409
467
  const body = [protoInitCall];
410
468
  if (value.node) {
411
469
  body.push(value.node);
412
470
  }
413
- value.replaceWith(t.sequenceExpression(body));
471
+ value.replaceWith(_core.types.sequenceExpression(body));
414
472
  } else if (constructorPath) {
415
473
  if (path.node.superClass) {
416
474
  path.traverse({
417
475
  CallExpression: {
418
476
  exit(path) {
419
477
  if (!path.get("callee").isSuper()) return;
420
- path.replaceWith(t.callExpression(t.cloneNode(protoInitLocal), [path.node]));
478
+ path.replaceWith(_core.types.callExpression(_core.types.cloneNode(protoInitLocal), [path.node]));
421
479
  path.skip();
422
480
  }
423
481
  }
424
482
  });
425
483
  } else {
426
- constructorPath.node.body.body.unshift(t.expressionStatement(protoInitCall));
484
+ constructorPath.node.body.body.unshift(_core.types.expressionStatement(protoInitCall));
427
485
  }
428
486
  } else {
429
- const body = [t.expressionStatement(protoInitCall)];
487
+ const body = [_core.types.expressionStatement(protoInitCall)];
430
488
  if (path.node.superClass) {
431
- body.unshift(t.expressionStatement(t.callExpression(t.super(), [t.spreadElement(t.identifier("args"))])));
489
+ body.unshift(_core.types.expressionStatement(_core.types.callExpression(_core.types.super(), [_core.types.spreadElement(_core.types.identifier("args"))])));
432
490
  }
433
- path.node.body.body.unshift(t.classMethod("constructor", t.identifier("constructor"), [t.restElement(t.identifier("args"))], t.blockStatement(body)));
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)));
434
492
  }
435
493
  }
436
494
  if (requiresStaticInit) {
@@ -451,7 +509,7 @@ function transformClass(path, state, constantSuper, version) {
451
509
  }
452
510
  const classLocals = [];
453
511
  let classInitInjected = false;
454
- const classInitCall = classInitLocal && t.callExpression(t.cloneNode(classInitLocal), []);
512
+ const classInitCall = classInitLocal && _core.types.callExpression(_core.types.cloneNode(classInitLocal), []);
455
513
  const originalClass = path.node;
456
514
  if (classDecorators) {
457
515
  classLocals.push(classIdLocal, classInitLocal);
@@ -477,12 +535,12 @@ function transformClass(path, state, constantSuper, version) {
477
535
  }
478
536
  });
479
537
  if (statics.length > 0 || staticBlocks.length > 0) {
480
- const staticsClass = template.expression.ast`
538
+ const staticsClass = _core.template.expression.ast`
481
539
  class extends ${state.addHelper("identity")} {}
482
540
  `;
483
- staticsClass.body.body = [t.staticBlock([t.toStatement(originalClass, true) || t.expressionStatement(originalClass)]), ...statics];
541
+ staticsClass.body.body = [_core.types.staticBlock([_core.types.toStatement(originalClass, true) || _core.types.expressionStatement(originalClass)]), ...statics];
484
542
  const constructorBody = [];
485
- const newExpr = t.newExpression(staticsClass, []);
543
+ const newExpr = _core.types.newExpression(staticsClass, []);
486
544
  if (staticBlocks.length > 0) {
487
545
  constructorBody.push(...staticBlocks.map(staticBlockToIIFE));
488
546
  }
@@ -491,61 +549,71 @@ function transformClass(path, state, constantSuper, version) {
491
549
  constructorBody.push(classInitCall);
492
550
  }
493
551
  if (constructorBody.length > 0) {
494
- constructorBody.unshift(t.callExpression(t.super(), [t.cloneNode(classIdLocal)]));
495
- staticsClass.body.body.push(t.classMethod("constructor", t.identifier("constructor"), [], t.blockStatement([t.expressionStatement(t.sequenceExpression(constructorBody))])));
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))])));
496
554
  } else {
497
- newExpr.arguments.push(t.cloneNode(classIdLocal));
555
+ newExpr.arguments.push(_core.types.cloneNode(classIdLocal));
498
556
  }
499
557
  path.replaceWith(newExpr);
500
558
  }
501
559
  }
502
560
  if (!classInitInjected && classInitCall) {
503
- path.node.body.body.push(t.staticBlock([t.expressionStatement(classInitCall)]));
561
+ path.node.body.body.push(_core.types.staticBlock([_core.types.expressionStatement(classInitCall)]));
504
562
  }
505
- originalClass.body.body.unshift(t.staticBlock([t.expressionStatement(createLocalsAssignment(elementLocals, classLocals, elementDecorations, classDecorations, needsInstancePrivateBrandCheck ? lastInstancePrivateName : null, state, version)), requiresStaticInit && t.expressionStatement(t.callExpression(t.cloneNode(staticInitLocal), [t.thisExpression()]))].filter(Boolean)));
506
- path.insertBefore(assignments.map(expr => t.expressionStatement(expr)));
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)));
507
565
  path.scope.crawl();
508
566
  return path;
509
567
  }
510
- function createLocalsAssignment(elementLocals, classLocals, elementDecorations, classDecorations, maybePrivateBranName, state, version) {
568
+ function createLocalsAssignment(elementLocals, classLocals, elementDecorations, classDecorations, classDecorationsFlag, maybePrivateBranName, state, version) {
511
569
  let lhs, rhs;
512
- const args = [t.thisExpression(), elementDecorations, classDecorations];
570
+ const args = [_core.types.thisExpression(), elementDecorations, classDecorations];
513
571
  if (version === "2021-12" || version === "2022-03" && !state.availableHelper("applyDecs2203R")) {
514
- lhs = t.arrayPattern([...elementLocals, ...classLocals]);
515
- rhs = t.callExpression(state.addHelper(version === "2021-12" ? "applyDecs" : "applyDecs2203"), args);
572
+ lhs = _core.types.arrayPattern([...elementLocals, ...classLocals]);
573
+ rhs = _core.types.callExpression(state.addHelper(version === "2021-12" ? "applyDecs" : "applyDecs2203"), args);
516
574
  } else {
517
- if (version === "2023-01") {
575
+ if (version === "2023-05") {
576
+ if (maybePrivateBranName || classDecorationsFlag.value !== 0) {
577
+ args.push(classDecorationsFlag);
578
+ }
579
+ if (maybePrivateBranName) {
580
+ args.push(_core.template.expression.ast`
581
+ _ => ${_core.types.cloneNode(maybePrivateBranName)} in _
582
+ `);
583
+ }
584
+ rhs = _core.types.callExpression(state.addHelper("applyDecs2305"), args);
585
+ } else if (version === "2023-01") {
518
586
  if (maybePrivateBranName) {
519
- args.push(template.expression.ast`
520
- _ => ${t.cloneNode(maybePrivateBranName)} in _
587
+ args.push(_core.template.expression.ast`
588
+ _ => ${_core.types.cloneNode(maybePrivateBranName)} in _
521
589
  `);
522
590
  }
523
- rhs = t.callExpression(state.addHelper("applyDecs2301"), args);
591
+ rhs = _core.types.callExpression(state.addHelper("applyDecs2301"), args);
524
592
  } else {
525
- rhs = t.callExpression(state.addHelper("applyDecs2203R"), args);
593
+ rhs = _core.types.callExpression(state.addHelper("applyDecs2203R"), args);
526
594
  }
527
595
  if (elementLocals.length > 0) {
528
596
  if (classLocals.length > 0) {
529
- lhs = t.objectPattern([t.objectProperty(t.identifier("e"), t.arrayPattern(elementLocals)), t.objectProperty(t.identifier("c"), t.arrayPattern(classLocals))]);
597
+ 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))]);
530
598
  } else {
531
- lhs = t.arrayPattern(elementLocals);
532
- rhs = t.memberExpression(rhs, t.identifier("e"), false, false);
599
+ lhs = _core.types.arrayPattern(elementLocals);
600
+ rhs = _core.types.memberExpression(rhs, _core.types.identifier("e"), false, false);
533
601
  }
534
602
  } else {
535
- lhs = t.arrayPattern(classLocals);
536
- rhs = t.memberExpression(rhs, t.identifier("c"), false, false);
603
+ lhs = _core.types.arrayPattern(classLocals);
604
+ rhs = _core.types.memberExpression(rhs, _core.types.identifier("c"), false, false);
537
605
  }
538
606
  }
539
- return t.assignmentExpression("=", lhs, rhs);
607
+ return _core.types.assignmentExpression("=", lhs, rhs);
540
608
  }
541
- export default function ({
609
+ function _default({
542
610
  assertVersion,
543
611
  assumption
544
612
  }, {
545
613
  loose
546
614
  }, version) {
547
615
  var _assumption;
548
- if (version === "2023-01") {
616
+ if (version === "2023-05" || version === "2023-01") {
549
617
  assertVersion("^7.21.0");
550
618
  } else if (version === "2021-12") {
551
619
  assertVersion("^7.16.0");
@@ -556,7 +624,7 @@ export default function ({
556
624
  const constantSuper = (_assumption = assumption("constantSuper")) != null ? _assumption : loose;
557
625
  return {
558
626
  name: "proposal-decorators",
559
- inherits: syntaxDecorators,
627
+ inherits: _pluginSyntaxDecorators.default,
560
628
  visitor: {
561
629
  "ExportNamedDeclaration|ExportDefaultDeclaration"(path) {
562
630
  var _declaration$decorato;
@@ -564,7 +632,7 @@ export default function ({
564
632
  declaration
565
633
  } = path.node;
566
634
  if ((declaration == null ? void 0 : declaration.type) === "ClassDeclaration" && ((_declaration$decorato = declaration.decorators) == null ? void 0 : _declaration$decorato.length) > 0) {
567
- splitExportDeclaration(path);
635
+ (0, _helperSplitExportDeclaration.default)(path);
568
636
  }
569
637
  },
570
638
  Class(path, state) {
@@ -576,4 +644,4 @@ export default function ({
576
644
  };
577
645
  }
578
646
 
579
- //# sourceMappingURL=transformer-2023-01.js.map
647
+ //# sourceMappingURL=transformer-2023-05.js.map