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