@jsenv/core 40.3.1 → 40.3.3

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.
Files changed (116) hide show
  1. package/README.md +42 -33
  2. package/dist/browserslist_index/browserslist_index.js +4951 -0
  3. package/dist/build/build.js +189 -62
  4. package/dist/jsenv_core_node_modules.js +25 -1
  5. package/dist/jsenv_core_packages.js +6384 -11580
  6. package/dist/start_build_server/start_build_server.js +0 -5
  7. package/dist/start_dev_server/start_dev_server.js +108 -60
  8. package/package.json +20 -21
  9. package/src/build/build.js +80 -1
  10. package/src/kitchen/errors.js +6 -1
  11. package/src/kitchen/kitchen.js +95 -7
  12. package/src/plugins/package_side_effects/jsenv_plugin_package_side_effects.js +5 -51
  13. package/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +0 -112
  14. package/dist/babel_helpers/AwaitValue/AwaitValue.js +0 -3
  15. package/dist/babel_helpers/OverloadYield/OverloadYield.js +0 -11
  16. package/dist/babel_helpers/applyDecoratedDescriptor/applyDecoratedDescriptor.js +0 -32
  17. package/dist/babel_helpers/applyDecs/applyDecs.js +0 -813
  18. package/dist/babel_helpers/applyDecs2203/applyDecs2203.js +0 -635
  19. package/dist/babel_helpers/applyDecs2203R/applyDecs2203R.js +0 -654
  20. package/dist/babel_helpers/applyDecs2301/applyDecs2301.js +0 -721
  21. package/dist/babel_helpers/applyDecs2305/applyDecs2305.js +0 -531
  22. package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +0 -7
  23. package/dist/babel_helpers/arrayWithHoles/arrayWithHoles.js +0 -4
  24. package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +0 -6
  25. package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +0 -9
  26. package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +0 -55
  27. package/dist/babel_helpers/asyncIterator/asyncIterator.js +0 -68
  28. package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +0 -34
  29. package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +0 -5
  30. package/dist/babel_helpers/callSuper/callSuper.js +0 -25
  31. package/dist/babel_helpers/checkInRHS/checkInRHS.js +0 -11
  32. package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -23
  33. package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -6
  34. package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -13
  35. package/dist/babel_helpers/classCallCheck/classCallCheck.js +0 -5
  36. package/dist/babel_helpers/classCheckPrivateStaticAccess/classCheckPrivateStaticAccess.js +0 -8
  37. package/dist/babel_helpers/classCheckPrivateStaticFieldDescriptor/classCheckPrivateStaticFieldDescriptor.js +0 -11
  38. package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -13
  39. package/dist/babel_helpers/classNameTDZError/classNameTDZError.js +0 -6
  40. package/dist/babel_helpers/classPrivateFieldDestructureSet/classPrivateFieldDestructureSet.js +0 -7
  41. package/dist/babel_helpers/classPrivateFieldGet/classPrivateFieldGet.js +0 -7
  42. package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -6
  43. package/dist/babel_helpers/classPrivateFieldLooseKey/classPrivateFieldLooseKey.js +0 -5
  44. package/dist/babel_helpers/classPrivateFieldSet/classPrivateFieldSet.js +0 -8
  45. package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +0 -6
  46. package/dist/babel_helpers/classPrivateMethodSet/classPrivateMethodSet.js +0 -3
  47. package/dist/babel_helpers/classStaticPrivateFieldSpecGet/classStaticPrivateFieldSpecGet.js +0 -13
  48. package/dist/babel_helpers/classStaticPrivateFieldSpecSet/classStaticPrivateFieldSpecSet.js +0 -15
  49. package/dist/babel_helpers/classStaticPrivateMethodGet/classStaticPrivateMethodGet.js +0 -10
  50. package/dist/babel_helpers/classStaticPrivateMethodSet/classStaticPrivateMethodSet.js +0 -3
  51. package/dist/babel_helpers/construct/construct.js +0 -20
  52. package/dist/babel_helpers/createClass/createClass.js +0 -17
  53. package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +0 -61
  54. package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +0 -24
  55. package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +0 -50
  56. package/dist/babel_helpers/createSuper/createSuper.js +0 -22
  57. package/dist/babel_helpers/decorate/decorate.js +0 -488
  58. package/dist/babel_helpers/defaults/defaults.js +0 -11
  59. package/dist/babel_helpers/defineAccessor/defineAccessor.js +0 -6
  60. package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +0 -23
  61. package/dist/babel_helpers/defineProperty/defineProperty.js +0 -21
  62. package/dist/babel_helpers/dispose/dispose.js +0 -45
  63. package/dist/babel_helpers/extends/extends.js +0 -14
  64. package/dist/babel_helpers/get/get.js +0 -19
  65. package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +0 -4
  66. package/dist/babel_helpers/identity/identity.js +0 -3
  67. package/dist/babel_helpers/importDeferProxy/importDeferProxy.js +0 -31
  68. package/dist/babel_helpers/inherits/inherits.js +0 -19
  69. package/dist/babel_helpers/inheritsLoose/inheritsLoose.js +0 -7
  70. package/dist/babel_helpers/initializerDefineProperty/initializerDefineProperty.js +0 -12
  71. package/dist/babel_helpers/initializerWarningHelper/initializerWarningHelper.js +0 -6
  72. package/dist/babel_helpers/instanceof/instanceof.js +0 -10
  73. package/dist/babel_helpers/interopRequireDefault/interopRequireDefault.js +0 -3
  74. package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +0 -47
  75. package/dist/babel_helpers/isNativeFunction/isNativeFunction.js +0 -9
  76. package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +0 -19
  77. package/dist/babel_helpers/iterableToArray/iterableToArray.js +0 -7
  78. package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +0 -54
  79. package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +0 -16
  80. package/dist/babel_helpers/jsx/jsx.js +0 -50
  81. package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +0 -10
  82. package/dist/babel_helpers/newArrowCheck/newArrowCheck.js +0 -5
  83. package/dist/babel_helpers/nonIterableRest/nonIterableRest.js +0 -5
  84. package/dist/babel_helpers/nonIterableSpread/nonIterableSpread.js +0 -5
  85. package/dist/babel_helpers/nullishReceiverError/nullishReceiverError.js +0 -3
  86. package/dist/babel_helpers/objectDestructuringEmpty/objectDestructuringEmpty.js +0 -3
  87. package/dist/babel_helpers/objectSpread/objectSpread.js +0 -23
  88. package/dist/babel_helpers/objectSpread2/objectSpread2.js +0 -43
  89. package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +0 -19
  90. package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -13
  91. package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +0 -12
  92. package/dist/babel_helpers/readOnlyError/readOnlyError.js +0 -4
  93. package/dist/babel_helpers/regeneratorRuntime/regeneratorRuntime.js +0 -698
  94. package/dist/babel_helpers/set/set.js +0 -47
  95. package/dist/babel_helpers/setFunctionName/setFunctionName.js +0 -19
  96. package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +0 -7
  97. package/dist/babel_helpers/skipFirstGeneratorNext/skipFirstGeneratorNext.js +0 -8
  98. package/dist/babel_helpers/slicedToArray/slicedToArray.js +0 -10
  99. package/dist/babel_helpers/slicedToArrayLoose/slicedToArrayLoose.js +0 -13
  100. package/dist/babel_helpers/superPropBase/superPropBase.js +0 -10
  101. package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -10
  102. package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -7
  103. package/dist/babel_helpers/tdz/tdz.js +0 -4
  104. package/dist/babel_helpers/temporalRef/temporalRef.js +0 -6
  105. package/dist/babel_helpers/temporalUndefined/temporalUndefined.js +0 -3
  106. package/dist/babel_helpers/toArray/toArray.js +0 -10
  107. package/dist/babel_helpers/toConsumableArray/toConsumableArray.js +0 -10
  108. package/dist/babel_helpers/toPrimitive/toPrimitive.js +0 -14
  109. package/dist/babel_helpers/toPropertyKey/toPropertyKey.js +0 -10
  110. package/dist/babel_helpers/typeof/typeof.js +0 -15
  111. package/dist/babel_helpers/unsupportedIterableToArray/unsupportedIterableToArray.js +0 -12
  112. package/dist/babel_helpers/using/using.js +0 -23
  113. package/dist/babel_helpers/wrapAsyncGenerator/wrapAsyncGenerator.js +0 -8
  114. package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +0 -30
  115. package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +0 -79
  116. package/dist/babel_helpers/writeOnlyError/writeOnlyError.js +0 -3
@@ -1,721 +0,0 @@
1
- /* @minVersion 7.21.0 */
2
-
3
- import checkInRHS from "../checkInRHS/checkInRHS.js";
4
- import setFunctionName from "../setFunctionName/setFunctionName.js";
5
- import toPropertyKey from "../toPropertyKey/toPropertyKey.js";
6
-
7
- /**
8
- Enums are used in this file, but not assigned to vars to avoid non-hoistable values
9
-
10
- CONSTRUCTOR = 0;
11
- PUBLIC = 1;
12
- PRIVATE = 2;
13
-
14
- FIELD = 0;
15
- ACCESSOR = 1;
16
- METHOD = 2;
17
- GETTER = 3;
18
- SETTER = 4;
19
-
20
- STATIC = 5;
21
-
22
- CLASS = 10; // only used in assertValidReturnValue
23
- */
24
-
25
- function applyDecs2301Factory() {
26
- function createAddInitializerMethod(initializers, decoratorFinishedRef) {
27
- return function addInitializer(initializer) {
28
- assertNotFinished(decoratorFinishedRef, "addInitializer");
29
- assertCallable(initializer, "An initializer");
30
- initializers.push(initializer);
31
- };
32
- }
33
-
34
- function assertInstanceIfPrivate(has, target) {
35
- if (!has(target)) {
36
- throw new TypeError(
37
- "Attempted to access private element on non-instance",
38
- );
39
- }
40
- }
41
-
42
- function memberDec(
43
- dec,
44
- name,
45
- desc,
46
- initializers,
47
- kind,
48
- isStatic,
49
- isPrivate,
50
- value,
51
- hasPrivateBrand,
52
- ) {
53
- var kindStr;
54
-
55
- switch (kind) {
56
- case 1 /* ACCESSOR */:
57
- kindStr = "accessor";
58
- break;
59
- case 2 /* METHOD */:
60
- kindStr = "method";
61
- break;
62
- case 3 /* GETTER */:
63
- kindStr = "getter";
64
- break;
65
- case 4 /* SETTER */:
66
- kindStr = "setter";
67
- break;
68
- default:
69
- kindStr = "field";
70
- }
71
-
72
- var ctx = {
73
- kind: kindStr,
74
- name: isPrivate ? "#" + name : toPropertyKey(name),
75
- static: isStatic,
76
- private: isPrivate,
77
- };
78
-
79
- var decoratorFinishedRef = { v: false };
80
-
81
- if (kind !== 0 /* FIELD */) {
82
- ctx.addInitializer = createAddInitializerMethod(
83
- initializers,
84
- decoratorFinishedRef,
85
- );
86
- }
87
-
88
- var get, set;
89
- if (!isPrivate && (kind === 0 /* FIELD */ || kind === 2) /* METHOD */) {
90
- get = function (target) {
91
- return target[name];
92
- };
93
- if (kind === 0 /* FIELD */) {
94
- set = function (target, v) {
95
- target[name] = v;
96
- };
97
- }
98
- } else if (kind === 2 /* METHOD */) {
99
- // Assert: isPrivate is true.
100
- get = function (target) {
101
- assertInstanceIfPrivate(hasPrivateBrand, target);
102
- return desc.value;
103
- };
104
- } else {
105
- // Assert: If kind === 0, then isPrivate is true.
106
- var t = kind === 0 /* FIELD */ || kind === 1; /* ACCESSOR */
107
- if (t || kind === 3 /* GETTER */) {
108
- if (isPrivate) {
109
- get = function (target) {
110
- assertInstanceIfPrivate(hasPrivateBrand, target);
111
- return desc.get.call(target);
112
- };
113
- } else {
114
- get = function (target) {
115
- return desc.get.call(target);
116
- };
117
- }
118
- }
119
- if (t || kind === 4 /* SETTER */) {
120
- if (isPrivate) {
121
- set = function (target, value) {
122
- assertInstanceIfPrivate(hasPrivateBrand, target);
123
- desc.set.call(target, value);
124
- };
125
- } else {
126
- set = function (target, value) {
127
- desc.set.call(target, value);
128
- };
129
- }
130
- }
131
- }
132
- var has = isPrivate
133
- ? hasPrivateBrand.bind()
134
- : function (target) {
135
- return name in target;
136
- };
137
- ctx.access =
138
- get && set
139
- ? { get: get, set: set, has: has }
140
- : get
141
- ? { get: get, has: has }
142
- : { set: set, has: has };
143
-
144
- try {
145
- return dec(value, ctx);
146
- } finally {
147
- decoratorFinishedRef.v = true;
148
- }
149
- }
150
-
151
- function assertNotFinished(decoratorFinishedRef, fnName) {
152
- if (decoratorFinishedRef.v) {
153
- throw new Error(
154
- "attempted to call " + fnName + " after decoration was finished",
155
- );
156
- }
157
- }
158
-
159
- function assertCallable(fn, hint) {
160
- if (typeof fn !== "function") {
161
- throw new TypeError(hint + " must be a function");
162
- }
163
- }
164
-
165
- function assertValidReturnValue(kind, value) {
166
- var type = typeof value;
167
-
168
- if (kind === 1 /* ACCESSOR */) {
169
- if (type !== "object" || value === null) {
170
- throw new TypeError(
171
- "accessor decorators must return an object with get, set, or init properties or void 0",
172
- );
173
- }
174
- if (value.get !== undefined) {
175
- assertCallable(value.get, "accessor.get");
176
- }
177
- if (value.set !== undefined) {
178
- assertCallable(value.set, "accessor.set");
179
- }
180
- if (value.init !== undefined) {
181
- assertCallable(value.init, "accessor.init");
182
- }
183
- } else if (type !== "function") {
184
- var hint;
185
- if (kind === 0 /* FIELD */) {
186
- hint = "field";
187
- } else if (kind === 10 /* CLASS */) {
188
- hint = "class";
189
- } else {
190
- hint = "method";
191
- }
192
- throw new TypeError(
193
- hint + " decorators must return a function or void 0",
194
- );
195
- }
196
- }
197
-
198
- function curryThis1(fn) {
199
- return function () {
200
- return fn(this);
201
- };
202
- }
203
- function curryThis2(fn) {
204
- return function (value) {
205
- fn(this, value);
206
- };
207
- }
208
-
209
- function applyMemberDec(
210
- ret,
211
- base,
212
- decInfo,
213
- name,
214
- kind,
215
- isStatic,
216
- isPrivate,
217
- initializers,
218
- hasPrivateBrand,
219
- ) {
220
- var decs = decInfo[0];
221
-
222
- var desc, init, prefix, value;
223
-
224
- if (isPrivate) {
225
- if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
226
- desc = {
227
- get: curryThis1(decInfo[3]),
228
- set: curryThis2(decInfo[4]),
229
- };
230
- prefix = "get";
231
- } else {
232
- if (kind === 3 /* GETTER */) {
233
- desc = {
234
- get: decInfo[3],
235
- };
236
- prefix = "get";
237
- } else if (kind === 4 /* SETTER */) {
238
- desc = {
239
- set: decInfo[3],
240
- };
241
- prefix = "set";
242
- } else {
243
- desc = {
244
- value: decInfo[3],
245
- };
246
- }
247
- }
248
- if (kind !== 0 /* FIELD */) {
249
- if (kind === 1 /* ACCESSOR */) {
250
- setFunctionName(desc.set, "#" + name, "set");
251
- }
252
- setFunctionName(desc[prefix || "value"], "#" + name, prefix);
253
- }
254
- } else if (kind !== 0 /* FIELD */) {
255
- desc = Object.getOwnPropertyDescriptor(base, name);
256
- }
257
-
258
- if (kind === 1 /* ACCESSOR */) {
259
- value = {
260
- get: desc.get,
261
- set: desc.set,
262
- };
263
- } else if (kind === 2 /* METHOD */) {
264
- value = desc.value;
265
- } else if (kind === 3 /* GETTER */) {
266
- value = desc.get;
267
- } else if (kind === 4 /* SETTER */) {
268
- value = desc.set;
269
- }
270
-
271
- var newValue, get, set;
272
-
273
- if (typeof decs === "function") {
274
- newValue = memberDec(
275
- decs,
276
- name,
277
- desc,
278
- initializers,
279
- kind,
280
- isStatic,
281
- isPrivate,
282
- value,
283
- hasPrivateBrand,
284
- );
285
-
286
- if (newValue !== void 0) {
287
- assertValidReturnValue(kind, newValue);
288
-
289
- if (kind === 0 /* FIELD */) {
290
- init = newValue;
291
- } else if (kind === 1 /* ACCESSOR */) {
292
- init = newValue.init;
293
- get = newValue.get || value.get;
294
- set = newValue.set || value.set;
295
-
296
- value = { get: get, set: set };
297
- } else {
298
- value = newValue;
299
- }
300
- }
301
- } else {
302
- for (var i = decs.length - 1; i >= 0; i--) {
303
- var dec = decs[i];
304
-
305
- newValue = memberDec(
306
- dec,
307
- name,
308
- desc,
309
- initializers,
310
- kind,
311
- isStatic,
312
- isPrivate,
313
- value,
314
- hasPrivateBrand,
315
- );
316
-
317
- if (newValue !== void 0) {
318
- assertValidReturnValue(kind, newValue);
319
- var newInit;
320
-
321
- if (kind === 0 /* FIELD */) {
322
- newInit = newValue;
323
- } else if (kind === 1 /* ACCESSOR */) {
324
- newInit = newValue.init;
325
- get = newValue.get || value.get;
326
- set = newValue.set || value.set;
327
-
328
- value = { get: get, set: set };
329
- } else {
330
- value = newValue;
331
- }
332
-
333
- if (newInit !== void 0) {
334
- if (init === void 0) {
335
- init = newInit;
336
- } else if (typeof init === "function") {
337
- init = [init, newInit];
338
- } else {
339
- init.push(newInit);
340
- }
341
- }
342
- }
343
- }
344
- }
345
-
346
- if (kind === 0 /* FIELD */ || kind === 1 /* ACCESSOR */) {
347
- if (init === void 0) {
348
- // If the initializer was void 0, sub in a dummy initializer
349
- init = function (instance, init) {
350
- return init;
351
- };
352
- } else if (typeof init !== "function") {
353
- var ownInitializers = init;
354
-
355
- init = function (instance, init) {
356
- var value = init;
357
-
358
- for (var i = 0; i < ownInitializers.length; i++) {
359
- value = ownInitializers[i].call(instance, value);
360
- }
361
-
362
- return value;
363
- };
364
- } else {
365
- var originalInitializer = init;
366
-
367
- init = function (instance, init) {
368
- return originalInitializer.call(instance, init);
369
- };
370
- }
371
-
372
- ret.push(init);
373
- }
374
-
375
- if (kind !== 0 /* FIELD */) {
376
- if (kind === 1 /* ACCESSOR */) {
377
- desc.get = value.get;
378
- desc.set = value.set;
379
- } else if (kind === 2 /* METHOD */) {
380
- desc.value = value;
381
- } else if (kind === 3 /* GETTER */) {
382
- desc.get = value;
383
- } else if (kind === 4 /* SETTER */) {
384
- desc.set = value;
385
- }
386
-
387
- if (isPrivate) {
388
- if (kind === 1 /* ACCESSOR */) {
389
- ret.push(function (instance, args) {
390
- return value.get.call(instance, args);
391
- });
392
- ret.push(function (instance, args) {
393
- return value.set.call(instance, args);
394
- });
395
- } else if (kind === 2 /* METHOD */) {
396
- ret.push(value);
397
- } else {
398
- ret.push(function (instance, args) {
399
- return value.call(instance, args);
400
- });
401
- }
402
- } else {
403
- Object.defineProperty(base, name, desc);
404
- }
405
- }
406
- }
407
-
408
- function applyMemberDecs(Class, decInfos, instanceBrand) {
409
- var ret = [];
410
- var protoInitializers;
411
- var staticInitializers;
412
- var staticBrand;
413
-
414
- var existingProtoNonFields = new Map();
415
- var existingStaticNonFields = new Map();
416
-
417
- for (var i = 0; i < decInfos.length; i++) {
418
- var decInfo = decInfos[i];
419
-
420
- // skip computed property names
421
- if (!Array.isArray(decInfo)) continue;
422
-
423
- var kind = decInfo[1];
424
- var name = decInfo[2];
425
- var isPrivate = decInfo.length > 3;
426
-
427
- var isStatic = kind >= 5; /* STATIC */
428
- var base;
429
- var initializers;
430
- var hasPrivateBrand = instanceBrand;
431
-
432
- if (isStatic) {
433
- base = Class;
434
- kind = kind - 5 /* STATIC */;
435
- // initialize staticInitializers when we see a non-field static member
436
- if (kind !== 0 /* FIELD */) {
437
- staticInitializers = staticInitializers || [];
438
- initializers = staticInitializers;
439
- }
440
- if (isPrivate && !staticBrand) {
441
- staticBrand = function (_) {
442
- return checkInRHS(_) === Class;
443
- };
444
- }
445
- hasPrivateBrand = staticBrand;
446
- } else {
447
- base = Class.prototype;
448
- // initialize protoInitializers when we see a non-field member
449
- if (kind !== 0 /* FIELD */) {
450
- protoInitializers = protoInitializers || [];
451
- initializers = protoInitializers;
452
- }
453
- }
454
-
455
- if (kind !== 0 /* FIELD */ && !isPrivate) {
456
- var existingNonFields = isStatic
457
- ? existingStaticNonFields
458
- : existingProtoNonFields;
459
-
460
- var existingKind = existingNonFields.get(name) || 0;
461
-
462
- if (
463
- existingKind === true ||
464
- (existingKind === 3 /* GETTER */ && kind !== 4) /* SETTER */ ||
465
- (existingKind === 4 /* SETTER */ && kind !== 3) /* GETTER */
466
- ) {
467
- throw new Error(
468
- "Attempted to decorate a public method/accessor that has the same name as a previously decorated public method/accessor. This is not currently supported by the decorators plugin. Property name was: " +
469
- name,
470
- );
471
- } else if (!existingKind && kind > 2 /* METHOD */) {
472
- existingNonFields.set(name, kind);
473
- } else {
474
- existingNonFields.set(name, true);
475
- }
476
- }
477
-
478
- applyMemberDec(
479
- ret,
480
- base,
481
- decInfo,
482
- name,
483
- kind,
484
- isStatic,
485
- isPrivate,
486
- initializers,
487
- hasPrivateBrand,
488
- );
489
- }
490
-
491
- pushInitializers(ret, protoInitializers);
492
- pushInitializers(ret, staticInitializers);
493
- return ret;
494
- }
495
-
496
- function pushInitializers(ret, initializers) {
497
- if (initializers) {
498
- ret.push(function (instance) {
499
- for (var i = 0; i < initializers.length; i++) {
500
- initializers[i].call(instance);
501
- }
502
- return instance;
503
- });
504
- }
505
- }
506
-
507
- function applyClassDecs(targetClass, classDecs) {
508
- if (classDecs.length > 0) {
509
- var initializers = [];
510
- var newClass = targetClass;
511
- var name = targetClass.name;
512
-
513
- for (var i = classDecs.length - 1; i >= 0; i--) {
514
- var decoratorFinishedRef = { v: false };
515
-
516
- try {
517
- var nextNewClass = classDecs[i](newClass, {
518
- kind: "class",
519
- name: name,
520
- addInitializer: createAddInitializerMethod(
521
- initializers,
522
- decoratorFinishedRef,
523
- ),
524
- });
525
- } finally {
526
- decoratorFinishedRef.v = true;
527
- }
528
-
529
- if (nextNewClass !== undefined) {
530
- assertValidReturnValue(10 /* CLASS */, nextNewClass);
531
- newClass = nextNewClass;
532
- }
533
- }
534
-
535
- return [
536
- newClass,
537
- function () {
538
- for (var i = 0; i < initializers.length; i++) {
539
- initializers[i].call(newClass);
540
- }
541
- },
542
- ];
543
- }
544
- // The transformer will not emit assignment when there are no class decorators,
545
- // so we don't have to return an empty array here.
546
- }
547
-
548
- /**
549
- Basic usage:
550
-
551
- applyDecs(
552
- Class,
553
- [
554
- // member decorators
555
- [
556
- dec, // dec or array of decs
557
- 0, // kind of value being decorated
558
- 'prop', // name of public prop on class containing the value being decorated,
559
- '#p', // the name of the private property (if is private, void 0 otherwise),
560
- ]
561
- ],
562
- [
563
- // class decorators
564
- dec1, dec2
565
- ]
566
- )
567
- ```
568
-
569
- Fully transpiled example:
570
-
571
- ```js
572
- @dec
573
- class Class {
574
- @dec
575
- a = 123;
576
-
577
- @dec
578
- #a = 123;
579
-
580
- @dec
581
- @dec2
582
- accessor b = 123;
583
-
584
- @dec
585
- accessor #b = 123;
586
-
587
- @dec
588
- c() { console.log('c'); }
589
-
590
- @dec
591
- #c() { console.log('privC'); }
592
-
593
- @dec
594
- get d() { console.log('d'); }
595
-
596
- @dec
597
- get #d() { console.log('privD'); }
598
-
599
- @dec
600
- set e(v) { console.log('e'); }
601
-
602
- @dec
603
- set #e(v) { console.log('privE'); }
604
- }
605
-
606
-
607
- // becomes
608
- let initializeInstance;
609
- let initializeClass;
610
-
611
- let initA;
612
- let initPrivA;
613
-
614
- let initB;
615
- let initPrivB, getPrivB, setPrivB;
616
-
617
- let privC;
618
- let privD;
619
- let privE;
620
-
621
- let Class;
622
- class _Class {
623
- static {
624
- let ret = applyDecs(
625
- this,
626
- [
627
- [dec, 0, 'a'],
628
- [dec, 0, 'a', (i) => i.#a, (i, v) => i.#a = v],
629
- [[dec, dec2], 1, 'b'],
630
- [dec, 1, 'b', (i) => i.#privBData, (i, v) => i.#privBData = v],
631
- [dec, 2, 'c'],
632
- [dec, 2, 'c', () => console.log('privC')],
633
- [dec, 3, 'd'],
634
- [dec, 3, 'd', () => console.log('privD')],
635
- [dec, 4, 'e'],
636
- [dec, 4, 'e', () => console.log('privE')],
637
- ],
638
- [
639
- dec
640
- ]
641
- )
642
-
643
- initA = ret[0];
644
-
645
- initPrivA = ret[1];
646
-
647
- initB = ret[2];
648
-
649
- initPrivB = ret[3];
650
- getPrivB = ret[4];
651
- setPrivB = ret[5];
652
-
653
- privC = ret[6];
654
-
655
- privD = ret[7];
656
-
657
- privE = ret[8];
658
-
659
- initializeInstance = ret[9];
660
-
661
- Class = ret[10]
662
-
663
- initializeClass = ret[11];
664
- }
665
-
666
- a = (initializeInstance(this), initA(this, 123));
667
-
668
- #a = initPrivA(this, 123);
669
-
670
- #bData = initB(this, 123);
671
- get b() { return this.#bData }
672
- set b(v) { this.#bData = v }
673
-
674
- #privBData = initPrivB(this, 123);
675
- get #b() { return getPrivB(this); }
676
- set #b(v) { setPrivB(this, v); }
677
-
678
- c() { console.log('c'); }
679
-
680
- #c(...args) { return privC(this, ...args) }
681
-
682
- get d() { console.log('d'); }
683
-
684
- get #d() { return privD(this); }
685
-
686
- set e(v) { console.log('e'); }
687
-
688
- set #e(v) { privE(this, v); }
689
- }
690
-
691
- initializeClass(Class);
692
- */
693
- return function applyDecs2301(
694
- targetClass,
695
- memberDecs,
696
- classDecs,
697
- instanceBrand,
698
- ) {
699
- return {
700
- e: applyMemberDecs(targetClass, memberDecs, instanceBrand),
701
- // Lazily apply class decorations so that member init locals can be properly bound.
702
- get c() {
703
- return applyClassDecs(targetClass, classDecs);
704
- },
705
- };
706
- };
707
- }
708
-
709
- export default function applyDecs2301(
710
- targetClass,
711
- memberDecs,
712
- classDecs,
713
- instanceBrand,
714
- ) {
715
- return (applyDecs2301 = applyDecs2301Factory())(
716
- targetClass,
717
- memberDecs,
718
- classDecs,
719
- instanceBrand,
720
- );
721
- }