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