@jsenv/core 29.1.18 → 29.2.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.
- package/dist/babel_helpers/AsyncGenerator/AsyncGenerator.js +3 -16
- package/dist/babel_helpers/applyDecoratorDescriptor/applyDecoratorDescriptor.js +0 -5
- package/dist/babel_helpers/applyDecs/applyDecs.js +54 -241
- package/dist/babel_helpers/applyDecs2023/applyDecs2023.js +47 -195
- package/dist/babel_helpers/arrayLikeToArray/arrayLikeToArray.js +0 -2
- package/dist/babel_helpers/arrayWithoutHoles/arrayWithoutHoles.js +2 -1
- package/dist/babel_helpers/assertThisInitialized/assertThisInitialized.js +0 -1
- package/dist/babel_helpers/asyncGeneratorDelegate/asyncGeneratorDelegate.js +4 -14
- package/dist/babel_helpers/asyncIterator/asyncIterator.js +5 -20
- package/dist/babel_helpers/asyncToGenerator/asyncToGenerator.js +2 -8
- package/dist/babel_helpers/awaitAsyncGenerator/awaitAsyncGenerator.js +1 -3
- package/dist/babel_helpers/classApplyDescriptorDestructureSet/classApplyDescriptorDestructureSet.js +0 -4
- package/dist/babel_helpers/classApplyDescriptorGet/classApplyDescriptorGet.js +0 -1
- package/dist/babel_helpers/classApplyDescriptorSet/classApplyDescriptorSet.js +0 -1
- package/dist/babel_helpers/classExtractFieldDescriptor/classExtractFieldDescriptor.js +0 -1
- package/dist/babel_helpers/classPrivateFieldLooseBase/classPrivateFieldLooseBase.js +0 -1
- package/dist/babel_helpers/classPrivateMethodGet/classPrivateMethodGet.js +0 -1
- package/dist/babel_helpers/construct/construct.js +5 -5
- package/dist/babel_helpers/createClass/createClass.js +0 -1
- package/dist/babel_helpers/createForOfIteratorHelper/createForOfIteratorHelper.js +5 -9
- package/dist/babel_helpers/createForOfIteratorHelperLoose/createForOfIteratorHelperLoose.js +2 -3
- package/dist/babel_helpers/createRawReactElement/createRawReactElement.js +2 -8
- package/dist/babel_helpers/createSuper/createSuper.js +2 -4
- package/dist/babel_helpers/decorate/decorate.js +60 -311
- package/dist/babel_helpers/defaults/defaults.js +0 -3
- package/dist/babel_helpers/defineEnumerableProperties/defineEnumerableProperties.js +2 -5
- package/dist/babel_helpers/defineProperty/defineProperty.js +0 -1
- package/dist/babel_helpers/extends/extends.js +0 -3
- package/dist/babel_helpers/get/get.js +0 -3
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +2 -1
- package/dist/babel_helpers/inherits/inherits.js +2 -3
- package/dist/babel_helpers/instanceof/instanceof.js +0 -1
- package/dist/babel_helpers/interopRequireWildcard/interopRequireWildcard.js +0 -10
- package/dist/babel_helpers/isNativeReflectConstruct/isNativeReflectConstruct.js +6 -6
- package/dist/babel_helpers/iterableToArrayLimit/iterableToArrayLimit.js +0 -5
- package/dist/babel_helpers/iterableToArrayLimitLoose/iterableToArrayLimitLoose.js +2 -5
- package/dist/babel_helpers/jsx/jsx.js +2 -8
- package/dist/babel_helpers/maybeArrayLike/maybeArrayLike.js +2 -3
- package/dist/babel_helpers/objectSpread/objectSpread.js +4 -6
- package/dist/babel_helpers/objectSpread2/objectSpread2.js +3 -8
- package/dist/babel_helpers/objectWithoutProperties/objectWithoutProperties.js +0 -3
- package/dist/babel_helpers/objectWithoutPropertiesLoose/objectWithoutPropertiesLoose.js +0 -2
- package/dist/babel_helpers/possibleConstructorReturn/possibleConstructorReturn.js +0 -1
- package/dist/babel_helpers/set/set.js +2 -12
- package/dist/babel_helpers/superPropBase/superPropBase.js +0 -1
- package/dist/babel_helpers/taggedTemplateLiteral/taggedTemplateLiteral.js +0 -1
- package/dist/babel_helpers/taggedTemplateLiteralLoose/taggedTemplateLiteralLoose.js +0 -1
- package/dist/babel_helpers/toPrimitive/toPrimitive.js +1 -5
- package/dist/babel_helpers/typeof/typeof.js +0 -2
- package/dist/babel_helpers/wrapNativeSuper/wrapNativeSuper.js +0 -7
- package/dist/babel_helpers/wrapRegExp/wrapRegExp.js +5 -19
- package/dist/controllable_child_process.mjs +17 -27
- package/dist/controllable_worker_thread.mjs +4 -16
- package/dist/js/autoreload.js +13 -56
- package/dist/js/execute_using_dynamic_import.js +40 -164
- package/dist/js/global_this.js +2 -10
- package/dist/js/import_meta_hot.js +3 -9
- package/dist/js/new_stylesheet.js +0 -59
- package/dist/js/regenerator_runtime.js +80 -156
- package/dist/js/s.js +25 -113
- package/dist/js/s.js.map +10 -10
- package/dist/js/script_type_module_supervisor.js +4 -13
- package/dist/js/server_events_client.js +10 -38
- package/dist/js/supervisor.js +25 -167
- package/dist/js/v8_coverage.js +29 -92
- package/dist/js/ws.js +226 -704
- package/dist/main.js +761 -4155
- package/package.json +8 -8
- package/src/plugins/import_meta_url/client/import_meta_url_browser.js +1 -2
- package/src/plugins/import_meta_url/client/import_meta_url_commonjs.mjs +1 -1
- package/src/plugins/plugins.js +1 -1
- package/src/plugins/transpilation/as_js_classic/helpers-string.js +1 -0
- package/src/plugins/transpilation/babel/global_this/client/global_this.js +0 -2
|
@@ -3,29 +3,26 @@ import { Session } from "node:inspector";
|
|
|
3
3
|
import { PerformanceObserver, performance } from "node:perf_hooks";
|
|
4
4
|
|
|
5
5
|
// https://developer.mozilla.org/en-US/docs/Glossary/Primitive
|
|
6
|
+
|
|
6
7
|
const isComposite = value => {
|
|
7
8
|
if (value === null) {
|
|
8
9
|
return false;
|
|
9
10
|
}
|
|
10
|
-
|
|
11
11
|
const type = typeof value;
|
|
12
|
-
|
|
13
12
|
if (type === "object") {
|
|
14
13
|
return true;
|
|
15
14
|
}
|
|
16
|
-
|
|
17
15
|
if (type === "function") {
|
|
18
16
|
return true;
|
|
19
17
|
}
|
|
20
|
-
|
|
21
18
|
return false;
|
|
22
19
|
};
|
|
23
20
|
|
|
21
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/WeakMap
|
|
24
22
|
const compositeWellKnownMap = new WeakMap();
|
|
25
23
|
const primitiveWellKnownMap = new Map();
|
|
26
24
|
const getCompositeGlobalPath = value => compositeWellKnownMap.get(value);
|
|
27
25
|
const getPrimitiveGlobalPath = value => primitiveWellKnownMap.get(value);
|
|
28
|
-
|
|
29
26
|
const visitGlobalObject = value => {
|
|
30
27
|
const visitValue = (value, path) => {
|
|
31
28
|
if (isComposite(value)) {
|
|
@@ -33,47 +30,38 @@ const visitGlobalObject = value => {
|
|
|
33
30
|
if (compositeWellKnownMap.has(value)) {
|
|
34
31
|
return;
|
|
35
32
|
}
|
|
36
|
-
|
|
37
33
|
compositeWellKnownMap.set(value, path);
|
|
38
|
-
|
|
39
34
|
const visitProperty = property => {
|
|
40
35
|
let descriptor;
|
|
41
|
-
|
|
42
36
|
try {
|
|
43
37
|
descriptor = Object.getOwnPropertyDescriptor(value, property);
|
|
44
38
|
} catch (e) {
|
|
45
39
|
if (e.name === "SecurityError") {
|
|
46
40
|
return;
|
|
47
41
|
}
|
|
48
|
-
|
|
49
42
|
throw e;
|
|
50
43
|
}
|
|
51
|
-
|
|
52
44
|
if (!descriptor) {
|
|
53
45
|
// it's apparently possible to have getOwnPropertyNames returning
|
|
54
46
|
// a property that later returns a null descriptor
|
|
55
47
|
// for instance window.showModalDialog in webkit 13.0
|
|
56
48
|
return;
|
|
57
|
-
}
|
|
58
|
-
|
|
49
|
+
}
|
|
59
50
|
|
|
51
|
+
// do not trigger getter/setter
|
|
60
52
|
if ("value" in descriptor) {
|
|
61
53
|
const propertyValue = descriptor.value;
|
|
62
54
|
visitValue(propertyValue, [...path, property]);
|
|
63
55
|
}
|
|
64
56
|
};
|
|
65
|
-
|
|
66
57
|
Object.getOwnPropertyNames(value).forEach(name => visitProperty(name));
|
|
67
58
|
Object.getOwnPropertySymbols(value).forEach(symbol => visitProperty(symbol));
|
|
68
59
|
}
|
|
69
|
-
|
|
70
60
|
primitiveWellKnownMap.set(value, path);
|
|
71
61
|
return;
|
|
72
62
|
};
|
|
73
|
-
|
|
74
63
|
visitValue(value, []);
|
|
75
64
|
};
|
|
76
|
-
|
|
77
65
|
if (typeof window === "object") visitGlobalObject(window);
|
|
78
66
|
if (typeof global === "object") visitGlobalObject(global);
|
|
79
67
|
|
|
@@ -88,58 +76,46 @@ const decompose = (mainValue, {
|
|
|
88
76
|
}) => {
|
|
89
77
|
const valueMap = {};
|
|
90
78
|
const recipeArray = [];
|
|
91
|
-
|
|
92
79
|
const valueToIdentifier = (value, path = []) => {
|
|
93
80
|
if (!isComposite(value)) {
|
|
94
81
|
const existingIdentifier = identifierForPrimitive(value);
|
|
95
|
-
|
|
96
82
|
if (existingIdentifier !== undefined) {
|
|
97
83
|
return existingIdentifier;
|
|
98
84
|
}
|
|
99
|
-
|
|
100
85
|
const identifier = identifierForNewValue(value);
|
|
101
86
|
recipeArray[identifier] = primitiveToRecipe(value);
|
|
102
87
|
return identifier;
|
|
103
88
|
}
|
|
104
|
-
|
|
105
89
|
if (typeof Promise === "function" && value instanceof Promise) {
|
|
106
90
|
throw new Error(createPromiseAreNotSupportedMessage({
|
|
107
91
|
path
|
|
108
92
|
}));
|
|
109
93
|
}
|
|
110
|
-
|
|
111
94
|
if (typeof WeakSet === "function" && value instanceof WeakSet) {
|
|
112
95
|
throw new Error(createWeakSetAreNotSupportedMessage({
|
|
113
96
|
path
|
|
114
97
|
}));
|
|
115
98
|
}
|
|
116
|
-
|
|
117
99
|
if (typeof WeakMap === "function" && value instanceof WeakMap) {
|
|
118
100
|
throw new Error(createWeakMapAreNotSupportedMessage({
|
|
119
101
|
path
|
|
120
102
|
}));
|
|
121
103
|
}
|
|
122
|
-
|
|
123
104
|
if (typeof value === "function" && !functionAllowed) {
|
|
124
105
|
throw new Error(createForbiddenFunctionMessage({
|
|
125
106
|
path
|
|
126
107
|
}));
|
|
127
108
|
}
|
|
128
|
-
|
|
129
109
|
const existingIdentifier = identifierForComposite(value);
|
|
130
|
-
|
|
131
110
|
if (existingIdentifier !== undefined) {
|
|
132
111
|
return existingIdentifier;
|
|
133
112
|
}
|
|
134
|
-
|
|
135
113
|
const identifier = identifierForNewValue(value);
|
|
136
114
|
const compositeGlobalPath = getCompositeGlobalPath(value);
|
|
137
|
-
|
|
138
115
|
if (compositeGlobalPath) {
|
|
139
116
|
recipeArray[identifier] = createGlobalReferenceRecipe(compositeGlobalPath);
|
|
140
117
|
return identifier;
|
|
141
118
|
}
|
|
142
|
-
|
|
143
119
|
const propertyDescriptionArray = [];
|
|
144
120
|
Object.getOwnPropertyNames(value).forEach(propertyName => {
|
|
145
121
|
const propertyDescriptor = Object.getOwnPropertyDescriptor(value, propertyName);
|
|
@@ -151,7 +127,6 @@ const decompose = (mainValue, {
|
|
|
151
127
|
});
|
|
152
128
|
});
|
|
153
129
|
const symbolDescriptionArray = [];
|
|
154
|
-
|
|
155
130
|
if (!ignoreSymbols) {
|
|
156
131
|
Object.getOwnPropertySymbols(value).forEach(symbol => {
|
|
157
132
|
const propertyDescriptor = Object.getOwnPropertyDescriptor(value, symbol);
|
|
@@ -163,7 +138,6 @@ const decompose = (mainValue, {
|
|
|
163
138
|
});
|
|
164
139
|
});
|
|
165
140
|
}
|
|
166
|
-
|
|
167
141
|
const methodDescriptionArray = computeMethodDescriptionArray(value, path);
|
|
168
142
|
const extensible = Object.isExtensible(value);
|
|
169
143
|
recipeArray[identifier] = createCompositeRecipe({
|
|
@@ -174,7 +148,6 @@ const decompose = (mainValue, {
|
|
|
174
148
|
});
|
|
175
149
|
return identifier;
|
|
176
150
|
};
|
|
177
|
-
|
|
178
151
|
const computePropertyDescription = (propertyDescriptor, propertyNameOrSymbol, path) => {
|
|
179
152
|
if (propertyDescriptor.set && !functionAllowed) {
|
|
180
153
|
throw new Error(createForbiddenPropertySetterMessage({
|
|
@@ -182,14 +155,12 @@ const decompose = (mainValue, {
|
|
|
182
155
|
propertyNameOrSymbol
|
|
183
156
|
}));
|
|
184
157
|
}
|
|
185
|
-
|
|
186
158
|
if (propertyDescriptor.get && !functionAllowed) {
|
|
187
159
|
throw new Error(createForbiddenPropertyGetterMessage({
|
|
188
160
|
path,
|
|
189
161
|
propertyNameOrSymbol
|
|
190
162
|
}));
|
|
191
163
|
}
|
|
192
|
-
|
|
193
164
|
return {
|
|
194
165
|
configurable: propertyDescriptor.configurable,
|
|
195
166
|
writable: propertyDescriptor.writable,
|
|
@@ -199,10 +170,8 @@ const decompose = (mainValue, {
|
|
|
199
170
|
valueIdentifier: "value" in propertyDescriptor ? valueToIdentifier(propertyDescriptor.value, [...path, String(propertyNameOrSymbol), "[[descriptor:value]]"]) : undefined
|
|
200
171
|
};
|
|
201
172
|
};
|
|
202
|
-
|
|
203
173
|
const computeMethodDescriptionArray = (value, path) => {
|
|
204
174
|
const methodDescriptionArray = [];
|
|
205
|
-
|
|
206
175
|
if (typeof Set === "function" && value instanceof Set) {
|
|
207
176
|
const callArray = [];
|
|
208
177
|
value.forEach((entryValue, index) => {
|
|
@@ -214,7 +183,6 @@ const decompose = (mainValue, {
|
|
|
214
183
|
callArray
|
|
215
184
|
});
|
|
216
185
|
}
|
|
217
|
-
|
|
218
186
|
if (typeof Map === "function" && value instanceof Map) {
|
|
219
187
|
const callArray = [];
|
|
220
188
|
value.forEach((entryValue, entryKey) => {
|
|
@@ -227,10 +195,8 @@ const decompose = (mainValue, {
|
|
|
227
195
|
callArray
|
|
228
196
|
});
|
|
229
197
|
}
|
|
230
|
-
|
|
231
198
|
return methodDescriptionArray;
|
|
232
199
|
};
|
|
233
|
-
|
|
234
200
|
const identifierForPrimitive = value => {
|
|
235
201
|
return Object.keys(valueMap).find(existingIdentifier => {
|
|
236
202
|
const existingValue = valueMap[existingIdentifier];
|
|
@@ -238,94 +204,79 @@ const decompose = (mainValue, {
|
|
|
238
204
|
return value === existingValue;
|
|
239
205
|
});
|
|
240
206
|
};
|
|
241
|
-
|
|
242
207
|
const identifierForComposite = value => {
|
|
243
208
|
return Object.keys(valueMap).find(existingIdentifier => {
|
|
244
209
|
const existingValue = valueMap[existingIdentifier];
|
|
245
210
|
return value === existingValue;
|
|
246
211
|
});
|
|
247
212
|
};
|
|
248
|
-
|
|
249
213
|
const identifierForNewValue = value => {
|
|
250
214
|
const identifier = nextIdentifier();
|
|
251
215
|
valueMap[identifier] = value;
|
|
252
216
|
return identifier;
|
|
253
217
|
};
|
|
254
|
-
|
|
255
218
|
let currentIdentifier = -1;
|
|
256
|
-
|
|
257
219
|
const nextIdentifier = () => {
|
|
258
220
|
const identifier = String(parseInt(currentIdentifier) + 1);
|
|
259
221
|
currentIdentifier = identifier;
|
|
260
222
|
return identifier;
|
|
261
223
|
};
|
|
224
|
+
const mainIdentifier = valueToIdentifier(mainValue);
|
|
262
225
|
|
|
263
|
-
|
|
226
|
+
// prototype, important to keep after the whole structure was visited
|
|
264
227
|
// so that we discover if any prototype is part of the value
|
|
265
|
-
|
|
266
228
|
const prototypeValueToIdentifier = prototypeValue => {
|
|
267
229
|
// prototype is null
|
|
268
230
|
if (prototypeValue === null) {
|
|
269
231
|
return valueToIdentifier(prototypeValue);
|
|
270
|
-
}
|
|
271
|
-
|
|
232
|
+
}
|
|
272
233
|
|
|
234
|
+
// prototype found somewhere already
|
|
273
235
|
const prototypeExistingIdentifier = identifierForComposite(prototypeValue);
|
|
274
|
-
|
|
275
236
|
if (prototypeExistingIdentifier !== undefined) {
|
|
276
237
|
return prototypeExistingIdentifier;
|
|
277
|
-
}
|
|
278
|
-
|
|
238
|
+
}
|
|
279
239
|
|
|
280
|
-
|
|
240
|
+
// mark prototype as visited
|
|
241
|
+
const prototypeIdentifier = identifierForNewValue(prototypeValue);
|
|
281
242
|
|
|
243
|
+
// prototype is a global reference ?
|
|
282
244
|
const prototypeGlobalPath = getCompositeGlobalPath(prototypeValue);
|
|
283
|
-
|
|
284
245
|
if (prototypeGlobalPath) {
|
|
285
246
|
recipeArray[prototypeIdentifier] = createGlobalReferenceRecipe(prototypeGlobalPath);
|
|
286
247
|
return prototypeIdentifier;
|
|
287
|
-
}
|
|
288
|
-
|
|
248
|
+
}
|
|
289
249
|
|
|
250
|
+
// otherwise prototype is unknown
|
|
290
251
|
if (prototypeStrict) {
|
|
291
252
|
throw new Error(createUnknownPrototypeMessage({
|
|
292
253
|
prototypeValue
|
|
293
254
|
}));
|
|
294
255
|
}
|
|
295
|
-
|
|
296
256
|
return prototypeValueToIdentifier(Object.getPrototypeOf(prototypeValue));
|
|
297
257
|
};
|
|
298
|
-
|
|
299
258
|
const identifierForValueOf = (value, path = []) => {
|
|
300
259
|
if (value instanceof Array) {
|
|
301
260
|
return valueToIdentifier(value.length, [...path, "length"]);
|
|
302
261
|
}
|
|
303
|
-
|
|
304
262
|
if ("valueOf" in value === false) {
|
|
305
263
|
return undefined;
|
|
306
264
|
}
|
|
307
|
-
|
|
308
265
|
if (typeof value.valueOf !== "function") {
|
|
309
266
|
return undefined;
|
|
310
267
|
}
|
|
311
|
-
|
|
312
268
|
const valueOfReturnValue = value.valueOf();
|
|
313
|
-
|
|
314
269
|
if (!isComposite(valueOfReturnValue)) {
|
|
315
270
|
return valueToIdentifier(valueOfReturnValue, [...path, "valueOf()"]);
|
|
316
271
|
}
|
|
317
|
-
|
|
318
272
|
if (valueOfReturnValue === value) {
|
|
319
273
|
return undefined;
|
|
320
274
|
}
|
|
321
|
-
|
|
322
275
|
throw new Error(createUnexpectedValueOfReturnValueMessage());
|
|
323
276
|
};
|
|
324
|
-
|
|
325
277
|
recipeArray.slice().forEach((recipe, index) => {
|
|
326
278
|
if (recipe.type === "composite") {
|
|
327
279
|
const value = valueMap[index];
|
|
328
|
-
|
|
329
280
|
if (typeof value === "function") {
|
|
330
281
|
const valueOfIdentifier = nextIdentifier();
|
|
331
282
|
recipeArray[valueOfIdentifier] = {
|
|
@@ -335,7 +286,6 @@ const decompose = (mainValue, {
|
|
|
335
286
|
recipe.valueOfIdentifier = valueOfIdentifier;
|
|
336
287
|
return;
|
|
337
288
|
}
|
|
338
|
-
|
|
339
289
|
if (value instanceof RegExp) {
|
|
340
290
|
const valueOfIdentifier = nextIdentifier();
|
|
341
291
|
recipeArray[valueOfIdentifier] = {
|
|
@@ -344,9 +294,9 @@ const decompose = (mainValue, {
|
|
|
344
294
|
};
|
|
345
295
|
recipe.valueOfIdentifier = valueOfIdentifier;
|
|
346
296
|
return;
|
|
347
|
-
}
|
|
348
|
-
|
|
297
|
+
}
|
|
349
298
|
|
|
299
|
+
// valueOf, mandatory to uneval new Date(10) for instance.
|
|
350
300
|
recipe.valueOfIdentifier = identifierForValueOf(value);
|
|
351
301
|
const prototypeValue = Object.getPrototypeOf(value);
|
|
352
302
|
recipe.prototypeIdentifier = prototypeValueToIdentifier(prototypeValue);
|
|
@@ -358,40 +308,31 @@ const decompose = (mainValue, {
|
|
|
358
308
|
valueMap
|
|
359
309
|
};
|
|
360
310
|
};
|
|
361
|
-
|
|
362
311
|
const primitiveToRecipe = value => {
|
|
363
312
|
if (typeof value === "symbol") {
|
|
364
313
|
return symbolToRecipe(value);
|
|
365
314
|
}
|
|
366
|
-
|
|
367
315
|
return createPimitiveRecipe(value);
|
|
368
316
|
};
|
|
369
|
-
|
|
370
317
|
const symbolToRecipe = symbol => {
|
|
371
318
|
const globalSymbolKey = Symbol.keyFor(symbol);
|
|
372
|
-
|
|
373
319
|
if (globalSymbolKey !== undefined) {
|
|
374
320
|
return createGlobalSymbolRecipe(globalSymbolKey);
|
|
375
321
|
}
|
|
376
|
-
|
|
377
322
|
const symbolGlobalPath = getPrimitiveGlobalPath(symbol);
|
|
378
|
-
|
|
379
323
|
if (!symbolGlobalPath) {
|
|
380
324
|
throw new Error(createUnknownSymbolMessage({
|
|
381
325
|
symbol
|
|
382
326
|
}));
|
|
383
327
|
}
|
|
384
|
-
|
|
385
328
|
return createGlobalReferenceRecipe(symbolGlobalPath);
|
|
386
329
|
};
|
|
387
|
-
|
|
388
330
|
const createPimitiveRecipe = value => {
|
|
389
331
|
return {
|
|
390
332
|
type: "primitive",
|
|
391
333
|
value
|
|
392
334
|
};
|
|
393
335
|
};
|
|
394
|
-
|
|
395
336
|
const createGlobalReferenceRecipe = path => {
|
|
396
337
|
const recipe = {
|
|
397
338
|
type: "global-reference",
|
|
@@ -399,14 +340,12 @@ const createGlobalReferenceRecipe = path => {
|
|
|
399
340
|
};
|
|
400
341
|
return recipe;
|
|
401
342
|
};
|
|
402
|
-
|
|
403
343
|
const createGlobalSymbolRecipe = key => {
|
|
404
344
|
return {
|
|
405
345
|
type: "global-symbol",
|
|
406
346
|
key
|
|
407
347
|
};
|
|
408
348
|
};
|
|
409
|
-
|
|
410
349
|
const createCompositeRecipe = ({
|
|
411
350
|
prototypeIdentifier,
|
|
412
351
|
valueOfIdentifier,
|
|
@@ -425,72 +364,59 @@ const createCompositeRecipe = ({
|
|
|
425
364
|
extensible
|
|
426
365
|
};
|
|
427
366
|
};
|
|
428
|
-
|
|
429
367
|
const createPromiseAreNotSupportedMessage = ({
|
|
430
368
|
path
|
|
431
369
|
}) => {
|
|
432
370
|
if (path.length === 0) {
|
|
433
371
|
return `promise are not supported.`;
|
|
434
372
|
}
|
|
435
|
-
|
|
436
373
|
return `promise are not supported.
|
|
437
374
|
promise found at: ${path.join("")}`;
|
|
438
375
|
};
|
|
439
|
-
|
|
440
376
|
const createWeakSetAreNotSupportedMessage = ({
|
|
441
377
|
path
|
|
442
378
|
}) => {
|
|
443
379
|
if (path.length === 0) {
|
|
444
380
|
return `weakSet are not supported.`;
|
|
445
381
|
}
|
|
446
|
-
|
|
447
382
|
return `weakSet are not supported.
|
|
448
383
|
weakSet found at: ${path.join("")}`;
|
|
449
384
|
};
|
|
450
|
-
|
|
451
385
|
const createWeakMapAreNotSupportedMessage = ({
|
|
452
386
|
path
|
|
453
387
|
}) => {
|
|
454
388
|
if (path.length === 0) {
|
|
455
389
|
return `weakMap are not supported.`;
|
|
456
390
|
}
|
|
457
|
-
|
|
458
391
|
return `weakMap are not supported.
|
|
459
392
|
weakMap found at: ${path.join("")}`;
|
|
460
393
|
};
|
|
461
|
-
|
|
462
394
|
const createForbiddenFunctionMessage = ({
|
|
463
395
|
path
|
|
464
396
|
}) => {
|
|
465
397
|
if (path.length === 0) {
|
|
466
398
|
return `function are not allowed.`;
|
|
467
399
|
}
|
|
468
|
-
|
|
469
400
|
return `function are not allowed.
|
|
470
401
|
function found at: ${path.join("")}`;
|
|
471
402
|
};
|
|
472
|
-
|
|
473
403
|
const createForbiddenPropertyGetterMessage = ({
|
|
474
404
|
path,
|
|
475
405
|
propertyNameOrSymbol
|
|
476
406
|
}) => `property getter are not allowed.
|
|
477
407
|
getter found on property: ${String(propertyNameOrSymbol)}
|
|
478
408
|
at: ${path.join("")}`;
|
|
479
|
-
|
|
480
409
|
const createForbiddenPropertySetterMessage = ({
|
|
481
410
|
path,
|
|
482
411
|
propertyNameOrSymbol
|
|
483
412
|
}) => `property setter are not allowed.
|
|
484
413
|
setter found on property: ${String(propertyNameOrSymbol)}
|
|
485
414
|
at: ${path.join("")}`;
|
|
486
|
-
|
|
487
415
|
const createUnexpectedValueOfReturnValueMessage = () => `valueOf() must return a primitive of the object itself.`;
|
|
488
|
-
|
|
489
416
|
const createUnknownSymbolMessage = ({
|
|
490
417
|
symbol
|
|
491
418
|
}) => `symbol must be global, like Symbol.iterator, or created using Symbol.for().
|
|
492
419
|
symbol: ${symbol.toString()}`;
|
|
493
|
-
|
|
494
420
|
const createUnknownPrototypeMessage = ({
|
|
495
421
|
prototypeValue
|
|
496
422
|
}) => `prototype must be global, like Object.prototype, or somewhere in the value.
|
|
@@ -501,68 +427,58 @@ prototype constructor name: ${prototypeValue.constructor.name}`;
|
|
|
501
427
|
// when used internally by uneval
|
|
502
428
|
const sortRecipe = recipeArray => {
|
|
503
429
|
const findInRecipePrototypeChain = (recipe, callback) => {
|
|
504
|
-
let currentRecipe = recipe;
|
|
505
|
-
|
|
430
|
+
let currentRecipe = recipe;
|
|
431
|
+
// eslint-disable-next-line no-constant-condition
|
|
506
432
|
while (true) {
|
|
507
433
|
if (currentRecipe.type !== "composite") {
|
|
508
434
|
break;
|
|
509
435
|
}
|
|
510
|
-
|
|
511
436
|
const prototypeIdentifier = currentRecipe.prototypeIdentifier;
|
|
512
|
-
|
|
513
437
|
if (prototypeIdentifier === undefined) {
|
|
514
438
|
break;
|
|
515
439
|
}
|
|
516
|
-
|
|
517
440
|
currentRecipe = recipeArray[prototypeIdentifier];
|
|
518
|
-
|
|
519
441
|
if (callback(currentRecipe, prototypeIdentifier)) {
|
|
520
442
|
return prototypeIdentifier;
|
|
521
443
|
}
|
|
522
444
|
}
|
|
523
|
-
|
|
524
445
|
return undefined;
|
|
525
446
|
};
|
|
526
|
-
|
|
527
447
|
const recipeArrayOrdered = recipeArray.slice();
|
|
528
448
|
recipeArrayOrdered.sort((leftRecipe, rightRecipe) => {
|
|
529
449
|
const leftType = leftRecipe.type;
|
|
530
450
|
const rightType = rightRecipe.type;
|
|
531
|
-
|
|
532
451
|
if (leftType === "composite" && rightType === "composite") {
|
|
533
|
-
const rightRecipeIsInLeftRecipePrototypeChain = findInRecipePrototypeChain(leftRecipe, recipeCandidate => recipeCandidate === rightRecipe);
|
|
534
|
-
|
|
452
|
+
const rightRecipeIsInLeftRecipePrototypeChain = findInRecipePrototypeChain(leftRecipe, recipeCandidate => recipeCandidate === rightRecipe);
|
|
453
|
+
// if left recipe requires right recipe, left must be after right
|
|
535
454
|
if (rightRecipeIsInLeftRecipePrototypeChain) {
|
|
536
455
|
return 1;
|
|
537
456
|
}
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
457
|
+
const leftRecipeIsInRightRecipePrototypeChain = findInRecipePrototypeChain(rightRecipe, recipeCandidate => recipeCandidate === leftRecipe);
|
|
458
|
+
// if right recipe requires left recipe, right must be after left
|
|
541
459
|
if (leftRecipeIsInRightRecipePrototypeChain) {
|
|
542
460
|
return -1;
|
|
543
461
|
}
|
|
544
462
|
}
|
|
545
|
-
|
|
546
463
|
if (leftType !== rightType) {
|
|
547
464
|
// if left is a composite, left must be after right
|
|
548
465
|
if (leftType === "composite") {
|
|
549
466
|
return 1;
|
|
550
|
-
}
|
|
551
|
-
|
|
467
|
+
}
|
|
552
468
|
|
|
469
|
+
// if right is a composite, right must be after left
|
|
553
470
|
if (rightType === "composite") {
|
|
554
471
|
return -1;
|
|
555
472
|
}
|
|
556
473
|
}
|
|
557
|
-
|
|
558
474
|
const leftIndex = recipeArray.indexOf(leftRecipe);
|
|
559
|
-
const rightIndex = recipeArray.indexOf(rightRecipe);
|
|
560
|
-
|
|
475
|
+
const rightIndex = recipeArray.indexOf(rightRecipe);
|
|
476
|
+
// left was before right, don't change that
|
|
561
477
|
if (leftIndex < rightIndex) {
|
|
562
478
|
return -1;
|
|
563
|
-
}
|
|
564
|
-
|
|
479
|
+
}
|
|
565
480
|
|
|
481
|
+
// right was after left, don't change that
|
|
566
482
|
return 1;
|
|
567
483
|
});
|
|
568
484
|
return recipeArrayOrdered;
|
|
@@ -575,11 +491,9 @@ const escapeString = value => {
|
|
|
575
491
|
let i = 0;
|
|
576
492
|
const j = string.length;
|
|
577
493
|
var escapedString = "";
|
|
578
|
-
|
|
579
494
|
while (i < j) {
|
|
580
495
|
const char = string[i];
|
|
581
496
|
let escapedChar;
|
|
582
|
-
|
|
583
497
|
if (char === '"' || char === "'" || char === "\\") {
|
|
584
498
|
escapedChar = `\\${char}`;
|
|
585
499
|
} else if (char === "\n") {
|
|
@@ -593,11 +507,9 @@ const escapeString = value => {
|
|
|
593
507
|
} else {
|
|
594
508
|
escapedChar = char;
|
|
595
509
|
}
|
|
596
|
-
|
|
597
510
|
escapedString += escapedChar;
|
|
598
511
|
i++;
|
|
599
512
|
}
|
|
600
|
-
|
|
601
513
|
return escapedString;
|
|
602
514
|
};
|
|
603
515
|
|
|
@@ -635,45 +547,35 @@ function safeDefineProperty(object, propertyNameOrSymbol, descriptor) {
|
|
|
635
547
|
const indexSorted = recipeArraySorted.indexOf(recipe);
|
|
636
548
|
variableNameMap[index] = `_${indexSorted}`;
|
|
637
549
|
});
|
|
638
|
-
|
|
639
550
|
const identifierToVariableName = identifier => variableNameMap[identifier];
|
|
640
|
-
|
|
641
551
|
const recipeToSetupSource = recipe => {
|
|
642
552
|
if (recipe.type === "primitive") return primitiveRecipeToSetupSource(recipe);
|
|
643
553
|
if (recipe.type === "global-symbol") return globalSymbolRecipeToSetupSource(recipe);
|
|
644
554
|
if (recipe.type === "global-reference") return globalReferenceRecipeToSetupSource(recipe);
|
|
645
555
|
return compositeRecipeToSetupSource(recipe);
|
|
646
556
|
};
|
|
647
|
-
|
|
648
557
|
const primitiveRecipeToSetupSource = ({
|
|
649
558
|
value
|
|
650
559
|
}) => {
|
|
651
560
|
const type = typeof value;
|
|
652
|
-
|
|
653
561
|
if (type === "string") {
|
|
654
562
|
return `"${escapeString(value)}";`;
|
|
655
563
|
}
|
|
656
|
-
|
|
657
564
|
if (type === "bigint") {
|
|
658
565
|
return `${value.toString()}n`;
|
|
659
566
|
}
|
|
660
|
-
|
|
661
567
|
if (Object.is(value, -0)) {
|
|
662
568
|
return "-0;";
|
|
663
569
|
}
|
|
664
|
-
|
|
665
570
|
return `${String(value)};`;
|
|
666
571
|
};
|
|
667
|
-
|
|
668
572
|
const globalSymbolRecipeToSetupSource = recipe => {
|
|
669
573
|
return `Symbol.for("${escapeString(recipe.key)}");`;
|
|
670
574
|
};
|
|
671
|
-
|
|
672
575
|
const globalReferenceRecipeToSetupSource = recipe => {
|
|
673
576
|
const pathSource = recipe.path.map(part => `["${escapeString(part)}"]`).join("");
|
|
674
577
|
return `globalObject${pathSource};`;
|
|
675
578
|
};
|
|
676
|
-
|
|
677
579
|
const compositeRecipeToSetupSource = ({
|
|
678
580
|
prototypeIdentifier,
|
|
679
581
|
valueOfIdentifier
|
|
@@ -681,44 +583,33 @@ function safeDefineProperty(object, propertyNameOrSymbol, descriptor) {
|
|
|
681
583
|
if (prototypeIdentifier === undefined) {
|
|
682
584
|
return identifierToVariableName(valueOfIdentifier);
|
|
683
585
|
}
|
|
684
|
-
|
|
685
586
|
const prototypeValue = valueMap[prototypeIdentifier];
|
|
686
|
-
|
|
687
587
|
if (prototypeValue === null) {
|
|
688
588
|
return `Object.create(null);`;
|
|
689
589
|
}
|
|
690
|
-
|
|
691
590
|
const prototypeConstructor = prototypeValue.constructor;
|
|
692
|
-
|
|
693
591
|
if (prototypeConstructor === Object) {
|
|
694
592
|
return `Object.create(${identifierToVariableName(prototypeIdentifier)});`;
|
|
695
593
|
}
|
|
696
|
-
|
|
697
594
|
if (valueOfIdentifier === undefined) {
|
|
698
595
|
return `new ${prototypeConstructor.name}();`;
|
|
699
596
|
}
|
|
700
|
-
|
|
701
597
|
if (prototypeConstructor.name === "BigInt") {
|
|
702
598
|
return `Object(${identifierToVariableName(valueOfIdentifier)})`;
|
|
703
599
|
}
|
|
704
|
-
|
|
705
600
|
return `new ${prototypeConstructor.name}(${identifierToVariableName(valueOfIdentifier)});`;
|
|
706
601
|
};
|
|
707
|
-
|
|
708
602
|
recipeArraySorted.forEach(recipe => {
|
|
709
603
|
const recipeVariableName = identifierToVariableName(recipeArray.indexOf(recipe));
|
|
710
604
|
source += `var ${recipeVariableName} = ${recipeToSetupSource(recipe)}
|
|
711
605
|
`;
|
|
712
606
|
});
|
|
713
|
-
|
|
714
607
|
const recipeToMutateSource = (recipe, recipeVariableName) => {
|
|
715
608
|
if (recipe.type === "composite") {
|
|
716
609
|
return compositeRecipeToMutateSource(recipe, recipeVariableName);
|
|
717
610
|
}
|
|
718
|
-
|
|
719
611
|
return ``;
|
|
720
612
|
};
|
|
721
|
-
|
|
722
613
|
const compositeRecipeToMutateSource = ({
|
|
723
614
|
propertyDescriptionArray,
|
|
724
615
|
symbolDescriptionArray,
|
|
@@ -744,20 +635,16 @@ function safeDefineProperty(object, propertyNameOrSymbol, descriptor) {
|
|
|
744
635
|
}) => {
|
|
745
636
|
mutateSource += generateMethodCallSource(recipeVariableName, methodNameIdentifier, callArray);
|
|
746
637
|
});
|
|
747
|
-
|
|
748
638
|
if (!extensible) {
|
|
749
639
|
mutateSource += generatePreventExtensionSource(recipeVariableName);
|
|
750
640
|
}
|
|
751
|
-
|
|
752
641
|
return mutateSource;
|
|
753
642
|
};
|
|
754
|
-
|
|
755
643
|
const generateDefinePropertySource = (recipeVariableName, propertyNameOrSymbolIdentifier, propertyDescription) => {
|
|
756
644
|
const propertyOrSymbolVariableName = identifierToVariableName(propertyNameOrSymbolIdentifier);
|
|
757
645
|
const propertyDescriptorSource = generatePropertyDescriptorSource(propertyDescription);
|
|
758
646
|
return `safeDefineProperty(${recipeVariableName}, ${propertyOrSymbolVariableName}, ${propertyDescriptorSource});`;
|
|
759
647
|
};
|
|
760
|
-
|
|
761
648
|
const generatePropertyDescriptorSource = ({
|
|
762
649
|
configurable,
|
|
763
650
|
writable,
|
|
@@ -774,7 +661,6 @@ function safeDefineProperty(object, propertyNameOrSymbol, descriptor) {
|
|
|
774
661
|
set: ${setIdentifier === undefined ? undefined : identifierToVariableName(setIdentifier)},
|
|
775
662
|
}`;
|
|
776
663
|
}
|
|
777
|
-
|
|
778
664
|
return `{
|
|
779
665
|
configurable: ${configurable},
|
|
780
666
|
writable: ${writable},
|
|
@@ -782,7 +668,6 @@ function safeDefineProperty(object, propertyNameOrSymbol, descriptor) {
|
|
|
782
668
|
value: ${valueIdentifier === undefined ? undefined : identifierToVariableName(valueIdentifier)}
|
|
783
669
|
}`;
|
|
784
670
|
};
|
|
785
|
-
|
|
786
671
|
const generateMethodCallSource = (recipeVariableName, methodNameIdentifier, callArray) => {
|
|
787
672
|
let methodCallSource = ``;
|
|
788
673
|
const methodVariableName = identifierToVariableName(methodNameIdentifier);
|
|
@@ -792,11 +677,9 @@ function safeDefineProperty(object, propertyNameOrSymbol, descriptor) {
|
|
|
792
677
|
});
|
|
793
678
|
return methodCallSource;
|
|
794
679
|
};
|
|
795
|
-
|
|
796
680
|
const generatePreventExtensionSource = recipeVariableName => {
|
|
797
681
|
return `Object.preventExtensions(${recipeVariableName});`;
|
|
798
682
|
};
|
|
799
|
-
|
|
800
683
|
recipeArraySorted.forEach(recipe => {
|
|
801
684
|
const recipeVariableName = identifierToVariableName(recipeArray.indexOf(recipe));
|
|
802
685
|
source += `${recipeToMutateSource(recipe, recipeVariableName)}`;
|
|
@@ -825,7 +708,6 @@ const startJsCoverage = async ({
|
|
|
825
708
|
} = {}) => {
|
|
826
709
|
const session = new Session();
|
|
827
710
|
session.connect();
|
|
828
|
-
|
|
829
711
|
const postSession = (action, options) => {
|
|
830
712
|
const promise = new Promise((resolve, reject) => {
|
|
831
713
|
session.post(action, options, (error, data) => {
|
|
@@ -838,25 +720,21 @@ const startJsCoverage = async ({
|
|
|
838
720
|
});
|
|
839
721
|
return promise;
|
|
840
722
|
};
|
|
841
|
-
|
|
842
723
|
await postSession("Profiler.enable");
|
|
843
724
|
await postSession("Profiler.startPreciseCoverage", {
|
|
844
725
|
callCount,
|
|
845
726
|
detailed
|
|
846
727
|
});
|
|
847
|
-
|
|
848
728
|
const takeJsCoverage = async () => {
|
|
849
729
|
const coverage = await postSession("Profiler.takePreciseCoverage");
|
|
850
730
|
return coverage;
|
|
851
731
|
};
|
|
852
|
-
|
|
853
732
|
const stopJsCoverage = async () => {
|
|
854
733
|
const coverage = await takeJsCoverage();
|
|
855
734
|
await postSession("Profiler.stopPreciseCoverage");
|
|
856
735
|
await postSession("Profiler.disable");
|
|
857
736
|
return coverage;
|
|
858
737
|
};
|
|
859
|
-
|
|
860
738
|
return {
|
|
861
739
|
takeJsCoverage,
|
|
862
740
|
stopJsCoverage
|
|
@@ -864,9 +742,10 @@ const startJsCoverage = async ({
|
|
|
864
742
|
};
|
|
865
743
|
|
|
866
744
|
const startObservingPerformances = () => {
|
|
867
|
-
const measureEntries = [];
|
|
868
|
-
|
|
869
|
-
const perfObserver = new PerformanceObserver((
|
|
745
|
+
const measureEntries = [];
|
|
746
|
+
// https://nodejs.org/dist/latest-v16.x/docs/api/perf_hooks.html
|
|
747
|
+
const perfObserver = new PerformanceObserver((
|
|
748
|
+
// https://nodejs.org/dist/latest-v16.x/docs/api/perf_hooks.html#perf_hooks_class_performanceobserverentrylist
|
|
870
749
|
list) => {
|
|
871
750
|
const perfMeasureEntries = list.getEntriesByType("measure");
|
|
872
751
|
measureEntries.push(...perfMeasureEntries);
|
|
@@ -881,12 +760,12 @@ const startObservingPerformances = () => {
|
|
|
881
760
|
});
|
|
882
761
|
performance.clearMarks();
|
|
883
762
|
perfObserver.disconnect();
|
|
884
|
-
return {
|
|
763
|
+
return {
|
|
764
|
+
...readNodePerformance(),
|
|
885
765
|
measures: measuresFromMeasureEntries(measureEntries)
|
|
886
766
|
};
|
|
887
767
|
};
|
|
888
768
|
};
|
|
889
|
-
|
|
890
769
|
const readNodePerformance = () => {
|
|
891
770
|
const nodePerformance = {
|
|
892
771
|
nodeTiming: asPlainObject(performance.nodeTiming),
|
|
@@ -894,9 +773,9 @@ const readNodePerformance = () => {
|
|
|
894
773
|
eventLoopUtilization: performance.eventLoopUtilization()
|
|
895
774
|
};
|
|
896
775
|
return nodePerformance;
|
|
897
|
-
};
|
|
898
|
-
|
|
776
|
+
};
|
|
899
777
|
|
|
778
|
+
// remove getters that cannot be stringified
|
|
900
779
|
const asPlainObject = objectWithGetters => {
|
|
901
780
|
const objectWithoutGetters = {};
|
|
902
781
|
Object.keys(objectWithGetters).forEach(key => {
|
|
@@ -904,16 +783,16 @@ const asPlainObject = objectWithGetters => {
|
|
|
904
783
|
});
|
|
905
784
|
return objectWithoutGetters;
|
|
906
785
|
};
|
|
907
|
-
|
|
908
786
|
const measuresFromMeasureEntries = measureEntries => {
|
|
909
|
-
const measures = {};
|
|
787
|
+
const measures = {};
|
|
788
|
+
// Sort to ensure measures order is predictable
|
|
910
789
|
// It seems to be already predictable on Node 16+ but
|
|
911
790
|
// it's not the case on Node 14.
|
|
912
|
-
|
|
913
791
|
measureEntries.sort((a, b) => {
|
|
914
792
|
return a.startTime - b.startTime;
|
|
915
793
|
});
|
|
916
|
-
measureEntries.forEach((
|
|
794
|
+
measureEntries.forEach((
|
|
795
|
+
// https://nodejs.org/dist/latest-v16.x/docs/api/perf_hooks.html#perf_hooks_class_performanceentry
|
|
917
796
|
perfMeasureEntry) => {
|
|
918
797
|
measures[perfMeasureEntry.name] = perfMeasureEntry.duration;
|
|
919
798
|
});
|
|
@@ -931,7 +810,6 @@ const executeUsingDynamicImport = async ({
|
|
|
931
810
|
}) => {
|
|
932
811
|
const result = {};
|
|
933
812
|
const afterImportCallbacks = [];
|
|
934
|
-
|
|
935
813
|
if (coverageEnabled && coverageMethodForNodeJs === "Profiler") {
|
|
936
814
|
const {
|
|
937
815
|
filterV8Coverage
|
|
@@ -948,7 +826,6 @@ const executeUsingDynamicImport = async ({
|
|
|
948
826
|
writeFileSync(new URL(coverageFileUrl), JSON.stringify(coverageLight, null, " "));
|
|
949
827
|
});
|
|
950
828
|
}
|
|
951
|
-
|
|
952
829
|
if (collectPerformance) {
|
|
953
830
|
const getPerformance = startObservingPerformances();
|
|
954
831
|
afterImportCallbacks.push(async () => {
|
|
@@ -956,7 +833,6 @@ const executeUsingDynamicImport = async ({
|
|
|
956
833
|
result.performance = performance;
|
|
957
834
|
});
|
|
958
835
|
}
|
|
959
|
-
|
|
960
836
|
const namespace = await import(fileUrl);
|
|
961
837
|
const namespaceResolved = {};
|
|
962
838
|
await Promise.all(Object.keys(namespace).map(async key => {
|