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