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