@jsenv/core 27.0.0-alpha.81 → 27.0.0-alpha.82
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/applyDecs/applyDecs.js +756 -0
- package/dist/babel_helpers/construct/construct.js +1 -1
- package/dist/babel_helpers/extends/extends.js +1 -1
- package/dist/babel_helpers/get/get.js +1 -1
- package/dist/babel_helpers/getPrototypeOf/getPrototypeOf.js +1 -1
- package/dist/babel_helpers/identity/identity.js +3 -0
- package/dist/babel_helpers/setPrototypeOf/setPrototypeOf.js +2 -2
- package/dist/main.js +7 -3
- package/package.json +7 -8
- package/dist/babel_helpers/readme.md +0 -8
|
@@ -0,0 +1,756 @@
|
|
|
1
|
+
/* @minVersion 7.16.6 */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Enums are used in this file, but not assigned to vars to avoid non-hoistable values
|
|
5
|
+
|
|
6
|
+
CONSTRUCTOR = 0;
|
|
7
|
+
PUBLIC = 1;
|
|
8
|
+
PRIVATE = 2;
|
|
9
|
+
|
|
10
|
+
FIELD = 0;
|
|
11
|
+
ACCESSOR = 1;
|
|
12
|
+
METHOD = 2;
|
|
13
|
+
GETTER = 3;
|
|
14
|
+
SETTER = 4;
|
|
15
|
+
|
|
16
|
+
STATIC = 5;
|
|
17
|
+
*/
|
|
18
|
+
function createMetadataMethodsForProperty(metadataMap, kind, property) {
|
|
19
|
+
return {
|
|
20
|
+
getMetadata(key) {
|
|
21
|
+
if (typeof key !== "symbol") {
|
|
22
|
+
throw new TypeError("Metadata keys must be symbols, received: " + key);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
var metadataForKey = metadataMap[key];
|
|
26
|
+
if (metadataForKey === void 0) return void 0;
|
|
27
|
+
|
|
28
|
+
if (kind === 1
|
|
29
|
+
/* PUBLIC */
|
|
30
|
+
) {
|
|
31
|
+
var pub = metadataForKey.public;
|
|
32
|
+
|
|
33
|
+
if (pub !== void 0) {
|
|
34
|
+
return pub[property];
|
|
35
|
+
}
|
|
36
|
+
} else if (kind === 2
|
|
37
|
+
/* PRIVATE */
|
|
38
|
+
) {
|
|
39
|
+
var priv = metadataForKey.private;
|
|
40
|
+
|
|
41
|
+
if (priv !== void 0) {
|
|
42
|
+
return priv.get(property);
|
|
43
|
+
}
|
|
44
|
+
} else if (Object.hasOwnProperty.call(metadataForKey, "constructor")) {
|
|
45
|
+
return metadataForKey.constructor;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
|
|
49
|
+
setMetadata(key, value) {
|
|
50
|
+
if (typeof key !== "symbol") {
|
|
51
|
+
throw new TypeError("Metadata keys must be symbols, received: " + key);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var metadataForKey = metadataMap[key];
|
|
55
|
+
|
|
56
|
+
if (metadataForKey === void 0) {
|
|
57
|
+
metadataForKey = metadataMap[key] = {};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
if (kind === 1
|
|
61
|
+
/* PUBLIC */
|
|
62
|
+
) {
|
|
63
|
+
var pub = metadataForKey.public;
|
|
64
|
+
|
|
65
|
+
if (pub === void 0) {
|
|
66
|
+
pub = metadataForKey.public = {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
pub[property] = value;
|
|
70
|
+
} else if (kind === 2
|
|
71
|
+
/* PRIVATE */
|
|
72
|
+
) {
|
|
73
|
+
var priv = metadataForKey.priv;
|
|
74
|
+
|
|
75
|
+
if (priv === void 0) {
|
|
76
|
+
priv = metadataForKey.private = new Map();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
priv.set(property, value);
|
|
80
|
+
} else {
|
|
81
|
+
metadataForKey.constructor = value;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function convertMetadataMapToFinal(obj, metadataMap) {
|
|
89
|
+
var parentMetadataMap = obj[Symbol.metadata || Symbol.for("Symbol.metadata")];
|
|
90
|
+
var metadataKeys = Object.getOwnPropertySymbols(metadataMap);
|
|
91
|
+
if (metadataKeys.length === 0) return;
|
|
92
|
+
|
|
93
|
+
for (var i = 0; i < metadataKeys.length; i++) {
|
|
94
|
+
var key = metadataKeys[i];
|
|
95
|
+
var metaForKey = metadataMap[key];
|
|
96
|
+
var parentMetaForKey = parentMetadataMap ? parentMetadataMap[key] : null;
|
|
97
|
+
var pub = metaForKey.public;
|
|
98
|
+
var parentPub = parentMetaForKey ? parentMetaForKey.public : null;
|
|
99
|
+
|
|
100
|
+
if (pub && parentPub) {
|
|
101
|
+
Object.setPrototypeOf(pub, parentPub);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
var priv = metaForKey.private;
|
|
105
|
+
|
|
106
|
+
if (priv) {
|
|
107
|
+
var privArr = Array.from(priv.values());
|
|
108
|
+
var parentPriv = parentMetaForKey ? parentMetaForKey.private : null;
|
|
109
|
+
|
|
110
|
+
if (parentPriv) {
|
|
111
|
+
privArr = privArr.concat(parentPriv);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
metaForKey.private = privArr;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (parentMetaForKey) {
|
|
118
|
+
Object.setPrototypeOf(metaForKey, parentMetaForKey);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
if (parentMetadataMap) {
|
|
123
|
+
Object.setPrototypeOf(metadataMap, parentMetadataMap);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
obj[Symbol.metadata || Symbol.for("Symbol.metadata")] = metadataMap;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function createAddInitializerMethod(initializers) {
|
|
130
|
+
return function addInitializer(initializer) {
|
|
131
|
+
assertValidInitializer(initializer);
|
|
132
|
+
initializers.push(initializer);
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function memberDecCtx(base, name, desc, metadataMap, initializers, kind, isStatic, isPrivate) {
|
|
137
|
+
var kindStr;
|
|
138
|
+
|
|
139
|
+
switch (kind) {
|
|
140
|
+
case 1
|
|
141
|
+
/* ACCESSOR */
|
|
142
|
+
:
|
|
143
|
+
kindStr = "accessor";
|
|
144
|
+
break;
|
|
145
|
+
|
|
146
|
+
case 2
|
|
147
|
+
/* METHOD */
|
|
148
|
+
:
|
|
149
|
+
kindStr = "method";
|
|
150
|
+
break;
|
|
151
|
+
|
|
152
|
+
case 3
|
|
153
|
+
/* GETTER */
|
|
154
|
+
:
|
|
155
|
+
kindStr = "getter";
|
|
156
|
+
break;
|
|
157
|
+
|
|
158
|
+
case 4
|
|
159
|
+
/* SETTER */
|
|
160
|
+
:
|
|
161
|
+
kindStr = "setter";
|
|
162
|
+
break;
|
|
163
|
+
|
|
164
|
+
default:
|
|
165
|
+
kindStr = "field";
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
var ctx = {
|
|
169
|
+
kind: kindStr,
|
|
170
|
+
name: isPrivate ? "#" + name : name,
|
|
171
|
+
isStatic: isStatic,
|
|
172
|
+
isPrivate: isPrivate
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
if (kind !== 0
|
|
176
|
+
/* FIELD */
|
|
177
|
+
) {
|
|
178
|
+
ctx.addInitializer = createAddInitializerMethod(initializers);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
var metadataKind, metadataName;
|
|
182
|
+
|
|
183
|
+
if (isPrivate) {
|
|
184
|
+
metadataKind = 2
|
|
185
|
+
/* PRIVATE */
|
|
186
|
+
;
|
|
187
|
+
metadataName = Symbol(name);
|
|
188
|
+
var access = {};
|
|
189
|
+
|
|
190
|
+
if (kind === 0
|
|
191
|
+
/* FIELD */
|
|
192
|
+
) {
|
|
193
|
+
access.get = desc.get;
|
|
194
|
+
access.set = desc.set;
|
|
195
|
+
} else if (kind === 2
|
|
196
|
+
/* METHOD */
|
|
197
|
+
) {
|
|
198
|
+
access.get = function () {
|
|
199
|
+
return desc.value;
|
|
200
|
+
};
|
|
201
|
+
} else {
|
|
202
|
+
// replace with values that will go through the final getter and setter
|
|
203
|
+
if (kind === 1
|
|
204
|
+
/* ACCESSOR */
|
|
205
|
+
|| kind === 3
|
|
206
|
+
/* GETTER */
|
|
207
|
+
) {
|
|
208
|
+
access.get = function () {
|
|
209
|
+
return desc.get.call(this);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
if (kind === 1
|
|
214
|
+
/* ACCESSOR */
|
|
215
|
+
|| kind === 4
|
|
216
|
+
/* SETTER */
|
|
217
|
+
) {
|
|
218
|
+
access.set = function (v) {
|
|
219
|
+
desc.set.call(this, v);
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
ctx.access = access;
|
|
225
|
+
} else {
|
|
226
|
+
metadataKind = 1
|
|
227
|
+
/* PUBLIC */
|
|
228
|
+
;
|
|
229
|
+
metadataName = name;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return Object.assign(ctx, createMetadataMethodsForProperty(metadataMap, metadataKind, metadataName));
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
function assertValidInitializer(initializer) {
|
|
236
|
+
if (typeof initializer !== "function") {
|
|
237
|
+
throw new Error("initializers must be functions");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function assertValidReturnValue(kind, value) {
|
|
242
|
+
var type = typeof value;
|
|
243
|
+
|
|
244
|
+
if (kind === 1
|
|
245
|
+
/* ACCESSOR */
|
|
246
|
+
) {
|
|
247
|
+
if (type !== "object" || value === null) {
|
|
248
|
+
throw new Error("accessor decorators must return an object with get, set, or initializer properties or void 0");
|
|
249
|
+
}
|
|
250
|
+
} else if (type !== "function") {
|
|
251
|
+
if (kind === 0
|
|
252
|
+
/* FIELD */
|
|
253
|
+
) {
|
|
254
|
+
throw new Error("field decorators must return a initializer function or void 0");
|
|
255
|
+
} else {
|
|
256
|
+
throw new Error("method decorators must return a function or void 0");
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers) {
|
|
262
|
+
var decs = decInfo[0];
|
|
263
|
+
var desc, initializer, value;
|
|
264
|
+
|
|
265
|
+
if (isPrivate) {
|
|
266
|
+
if (kind === 0
|
|
267
|
+
/* FIELD */
|
|
268
|
+
|| kind === 1
|
|
269
|
+
/* ACCESSOR */
|
|
270
|
+
) {
|
|
271
|
+
desc = {
|
|
272
|
+
get: decInfo[3],
|
|
273
|
+
set: decInfo[4]
|
|
274
|
+
};
|
|
275
|
+
} else if (kind === 3
|
|
276
|
+
/* GETTER */
|
|
277
|
+
) {
|
|
278
|
+
desc = {
|
|
279
|
+
get: decInfo[3]
|
|
280
|
+
};
|
|
281
|
+
} else if (kind === 4
|
|
282
|
+
/* SETTER */
|
|
283
|
+
) {
|
|
284
|
+
desc = {
|
|
285
|
+
set: decInfo[3]
|
|
286
|
+
};
|
|
287
|
+
} else {
|
|
288
|
+
desc = {
|
|
289
|
+
value: decInfo[3]
|
|
290
|
+
};
|
|
291
|
+
}
|
|
292
|
+
} else if (kind !== 0
|
|
293
|
+
/* FIELD */
|
|
294
|
+
) {
|
|
295
|
+
desc = Object.getOwnPropertyDescriptor(base, name);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (kind === 1
|
|
299
|
+
/* ACCESSOR */
|
|
300
|
+
) {
|
|
301
|
+
value = {
|
|
302
|
+
get: desc.get,
|
|
303
|
+
set: desc.set
|
|
304
|
+
};
|
|
305
|
+
} else if (kind === 2
|
|
306
|
+
/* METHOD */
|
|
307
|
+
) {
|
|
308
|
+
value = desc.value;
|
|
309
|
+
} else if (kind === 3
|
|
310
|
+
/* GETTER */
|
|
311
|
+
) {
|
|
312
|
+
value = desc.get;
|
|
313
|
+
} else if (kind === 4
|
|
314
|
+
/* SETTER */
|
|
315
|
+
) {
|
|
316
|
+
value = desc.set;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
var ctx = memberDecCtx(base, name, desc, metadataMap, initializers, kind, isStatic, isPrivate);
|
|
320
|
+
var newValue, get, set;
|
|
321
|
+
|
|
322
|
+
if (typeof decs === "function") {
|
|
323
|
+
newValue = decs(value, ctx);
|
|
324
|
+
|
|
325
|
+
if (newValue !== void 0) {
|
|
326
|
+
assertValidReturnValue(kind, newValue);
|
|
327
|
+
|
|
328
|
+
if (kind === 0
|
|
329
|
+
/* FIELD */
|
|
330
|
+
) {
|
|
331
|
+
initializer = newValue;
|
|
332
|
+
} else if (kind === 1
|
|
333
|
+
/* ACCESSOR */
|
|
334
|
+
) {
|
|
335
|
+
initializer = newValue.initializer;
|
|
336
|
+
get = newValue.get || value.get;
|
|
337
|
+
set = newValue.set || value.set;
|
|
338
|
+
value = {
|
|
339
|
+
get: get,
|
|
340
|
+
set: set
|
|
341
|
+
};
|
|
342
|
+
} else {
|
|
343
|
+
value = newValue;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
} else {
|
|
347
|
+
for (var i = 0; i < decs.length; i++) {
|
|
348
|
+
var dec = decs[i];
|
|
349
|
+
newValue = dec(value, ctx);
|
|
350
|
+
|
|
351
|
+
if (newValue !== void 0) {
|
|
352
|
+
assertValidReturnValue(kind, newValue);
|
|
353
|
+
var newInit;
|
|
354
|
+
|
|
355
|
+
if (kind === 0
|
|
356
|
+
/* FIELD */
|
|
357
|
+
) {
|
|
358
|
+
newInit = newValue;
|
|
359
|
+
} else if (kind === 1
|
|
360
|
+
/* ACCESSOR */
|
|
361
|
+
) {
|
|
362
|
+
newInit = newValue.initializer;
|
|
363
|
+
get = newValue.get || value.get;
|
|
364
|
+
set = newValue.set || value.set;
|
|
365
|
+
value = {
|
|
366
|
+
get: get,
|
|
367
|
+
set: set
|
|
368
|
+
};
|
|
369
|
+
} else {
|
|
370
|
+
value = newValue;
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
if (newInit !== void 0) {
|
|
374
|
+
if (initializer === void 0) {
|
|
375
|
+
initializer = newInit;
|
|
376
|
+
} else if (typeof initializer === "function") {
|
|
377
|
+
initializer = [initializer, newInit];
|
|
378
|
+
} else {
|
|
379
|
+
initializer.push(newInit);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
if (kind === 0
|
|
387
|
+
/* FIELD */
|
|
388
|
+
|| kind === 1
|
|
389
|
+
/* ACCESSOR */
|
|
390
|
+
) {
|
|
391
|
+
if (initializer === void 0) {
|
|
392
|
+
// If the initializer was void 0, sub in a dummy initializer
|
|
393
|
+
initializer = function (instance, init) {
|
|
394
|
+
return init;
|
|
395
|
+
};
|
|
396
|
+
} else if (typeof initializer !== "function") {
|
|
397
|
+
var ownInitializers = initializer;
|
|
398
|
+
|
|
399
|
+
initializer = function (instance, init) {
|
|
400
|
+
var value = init;
|
|
401
|
+
|
|
402
|
+
for (var i = 0; i < ownInitializers.length; i++) {
|
|
403
|
+
value = ownInitializers[i].call(instance, value);
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
return value;
|
|
407
|
+
};
|
|
408
|
+
} else {
|
|
409
|
+
var originalInitializer = initializer;
|
|
410
|
+
|
|
411
|
+
initializer = function (instance, init) {
|
|
412
|
+
return originalInitializer.call(instance, init);
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
ret.push(initializer);
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
if (kind !== 0
|
|
420
|
+
/* FIELD */
|
|
421
|
+
) {
|
|
422
|
+
if (kind === 1
|
|
423
|
+
/* ACCESSOR */
|
|
424
|
+
) {
|
|
425
|
+
desc.get = value.get;
|
|
426
|
+
desc.set = value.set;
|
|
427
|
+
} else if (kind === 2
|
|
428
|
+
/* METHOD */
|
|
429
|
+
) {
|
|
430
|
+
desc.value = value;
|
|
431
|
+
} else if (kind === 3
|
|
432
|
+
/* GETTER */
|
|
433
|
+
) {
|
|
434
|
+
desc.get = value;
|
|
435
|
+
} else if (kind === 4
|
|
436
|
+
/* SETTER */
|
|
437
|
+
) {
|
|
438
|
+
desc.set = value;
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
if (isPrivate) {
|
|
442
|
+
if (kind === 1
|
|
443
|
+
/* ACCESSOR */
|
|
444
|
+
) {
|
|
445
|
+
ret.push(function (instance, args) {
|
|
446
|
+
return value.get.call(instance, args);
|
|
447
|
+
});
|
|
448
|
+
ret.push(function (instance, args) {
|
|
449
|
+
return value.set.call(instance, args);
|
|
450
|
+
});
|
|
451
|
+
} else if (kind === 2
|
|
452
|
+
/* METHOD */
|
|
453
|
+
) {
|
|
454
|
+
ret.push(value);
|
|
455
|
+
} else {
|
|
456
|
+
ret.push(function (instance, args) {
|
|
457
|
+
return value.call(instance, args);
|
|
458
|
+
});
|
|
459
|
+
}
|
|
460
|
+
} else {
|
|
461
|
+
Object.defineProperty(base, name, desc);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
function applyMemberDecs(ret, Class, protoMetadataMap, staticMetadataMap, decInfos) {
|
|
467
|
+
var protoInitializers;
|
|
468
|
+
var staticInitializers;
|
|
469
|
+
var existingProtoNonFields = new Map();
|
|
470
|
+
var existingStaticNonFields = new Map();
|
|
471
|
+
|
|
472
|
+
for (var i = 0; i < decInfos.length; i++) {
|
|
473
|
+
var decInfo = decInfos[i]; // skip computed property names
|
|
474
|
+
|
|
475
|
+
if (!Array.isArray(decInfo)) continue;
|
|
476
|
+
var kind = decInfo[1];
|
|
477
|
+
var name = decInfo[2];
|
|
478
|
+
var isPrivate = decInfo.length > 3;
|
|
479
|
+
var isStatic = kind >= 5;
|
|
480
|
+
/* STATIC */
|
|
481
|
+
|
|
482
|
+
var base;
|
|
483
|
+
var metadataMap;
|
|
484
|
+
var initializers;
|
|
485
|
+
|
|
486
|
+
if (isStatic) {
|
|
487
|
+
base = Class;
|
|
488
|
+
metadataMap = staticMetadataMap;
|
|
489
|
+
kind = kind - 5
|
|
490
|
+
/* STATIC */
|
|
491
|
+
;
|
|
492
|
+
|
|
493
|
+
if (!staticInitializers) {
|
|
494
|
+
staticInitializers = [];
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
initializers = staticInitializers;
|
|
498
|
+
} else {
|
|
499
|
+
base = Class.prototype;
|
|
500
|
+
metadataMap = protoMetadataMap;
|
|
501
|
+
|
|
502
|
+
if (!protoInitializers) {
|
|
503
|
+
protoInitializers = [];
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
initializers = protoInitializers;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
if (kind !== 0
|
|
510
|
+
/* FIELD */
|
|
511
|
+
&& !isPrivate) {
|
|
512
|
+
var existingNonFields = isStatic ? existingStaticNonFields : existingProtoNonFields;
|
|
513
|
+
var existingKind = existingNonFields.get(name) || 0;
|
|
514
|
+
|
|
515
|
+
if (existingKind === true || existingKind === 3
|
|
516
|
+
/* GETTER */
|
|
517
|
+
&& kind !== 4
|
|
518
|
+
/* SETTER */
|
|
519
|
+
|| existingKind === 4
|
|
520
|
+
/* SETTER */
|
|
521
|
+
&& kind !== 3
|
|
522
|
+
/* GETTER */
|
|
523
|
+
) {
|
|
524
|
+
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);
|
|
525
|
+
} else if (!existingKind && kind > 2
|
|
526
|
+
/* METHOD */
|
|
527
|
+
) {
|
|
528
|
+
existingNonFields.set(name, kind);
|
|
529
|
+
} else {
|
|
530
|
+
existingNonFields.set(name, true);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
applyMemberDec(ret, base, decInfo, name, kind, isStatic, isPrivate, metadataMap, initializers);
|
|
535
|
+
}
|
|
536
|
+
|
|
537
|
+
if (protoInitializers) {
|
|
538
|
+
pushInitializers(ret, protoInitializers);
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
if (staticInitializers) {
|
|
542
|
+
pushInitializers(ret, staticInitializers);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
function pushInitializers(ret, initializers) {
|
|
547
|
+
if (initializers.length > 0) {
|
|
548
|
+
// Slice the array, which means that `addInitializer` can no longer add
|
|
549
|
+
// additional initializers to the array
|
|
550
|
+
initializers = initializers.slice();
|
|
551
|
+
ret.push(function (instance) {
|
|
552
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
553
|
+
initializers[i].call(instance, instance);
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
return instance;
|
|
557
|
+
});
|
|
558
|
+
} else {
|
|
559
|
+
ret.push(function (instance) {
|
|
560
|
+
return instance;
|
|
561
|
+
});
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function applyClassDecs(ret, targetClass, metadataMap, classDecs) {
|
|
566
|
+
var initializers = [];
|
|
567
|
+
var newClass = targetClass;
|
|
568
|
+
var name = targetClass.name;
|
|
569
|
+
var ctx = Object.assign({
|
|
570
|
+
kind: "class",
|
|
571
|
+
name: name,
|
|
572
|
+
addInitializer: createAddInitializerMethod(initializers)
|
|
573
|
+
}, createMetadataMethodsForProperty(metadataMap, 0
|
|
574
|
+
/* CONSTRUCTOR */
|
|
575
|
+
, name));
|
|
576
|
+
|
|
577
|
+
for (var i = 0; i < classDecs.length; i++) {
|
|
578
|
+
newClass = classDecs[i](newClass, ctx) || newClass;
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
ret.push(newClass);
|
|
582
|
+
|
|
583
|
+
if (initializers.length > 0) {
|
|
584
|
+
ret.push(function () {
|
|
585
|
+
for (var i = 0; i < initializers.length; i++) {
|
|
586
|
+
initializers[i].call(newClass, newClass);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
} else {
|
|
590
|
+
ret.push(function () {});
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
/**
|
|
594
|
+
Basic usage:
|
|
595
|
+
|
|
596
|
+
applyDecs(
|
|
597
|
+
Class,
|
|
598
|
+
[
|
|
599
|
+
// member decorators
|
|
600
|
+
[
|
|
601
|
+
dec, // dec or array of decs
|
|
602
|
+
0, // kind of value being decorated
|
|
603
|
+
'prop', // name of public prop on class containing the value being decorated,
|
|
604
|
+
'#p', // the name of the private property (if is private, void 0 otherwise),
|
|
605
|
+
]
|
|
606
|
+
],
|
|
607
|
+
[
|
|
608
|
+
// class decorators
|
|
609
|
+
dec1, dec2
|
|
610
|
+
]
|
|
611
|
+
)
|
|
612
|
+
```
|
|
613
|
+
|
|
614
|
+
Fully transpiled example:
|
|
615
|
+
|
|
616
|
+
```js
|
|
617
|
+
@dec
|
|
618
|
+
class Class {
|
|
619
|
+
@dec
|
|
620
|
+
a = 123;
|
|
621
|
+
|
|
622
|
+
@dec
|
|
623
|
+
#a = 123;
|
|
624
|
+
|
|
625
|
+
@dec
|
|
626
|
+
@dec2
|
|
627
|
+
accessor b = 123;
|
|
628
|
+
|
|
629
|
+
@dec
|
|
630
|
+
accessor #b = 123;
|
|
631
|
+
|
|
632
|
+
@dec
|
|
633
|
+
c() { console.log('c'); }
|
|
634
|
+
|
|
635
|
+
@dec
|
|
636
|
+
#c() { console.log('privC'); }
|
|
637
|
+
|
|
638
|
+
@dec
|
|
639
|
+
get d() { console.log('d'); }
|
|
640
|
+
|
|
641
|
+
@dec
|
|
642
|
+
get #d() { console.log('privD'); }
|
|
643
|
+
|
|
644
|
+
@dec
|
|
645
|
+
set e(v) { console.log('e'); }
|
|
646
|
+
|
|
647
|
+
@dec
|
|
648
|
+
set #e(v) { console.log('privE'); }
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
|
|
652
|
+
// becomes
|
|
653
|
+
let initializeInstance;
|
|
654
|
+
let initializeClass;
|
|
655
|
+
|
|
656
|
+
let initA;
|
|
657
|
+
let initPrivA;
|
|
658
|
+
|
|
659
|
+
let initB;
|
|
660
|
+
let initPrivB, getPrivB, setPrivB;
|
|
661
|
+
|
|
662
|
+
let privC;
|
|
663
|
+
let privD;
|
|
664
|
+
let privE;
|
|
665
|
+
|
|
666
|
+
let Class;
|
|
667
|
+
class _Class {
|
|
668
|
+
static {
|
|
669
|
+
let ret = applyDecs(
|
|
670
|
+
this,
|
|
671
|
+
[
|
|
672
|
+
[dec, 0, 'a'],
|
|
673
|
+
[dec, 0, 'a', (i) => i.#a, (i, v) => i.#a = v],
|
|
674
|
+
[[dec, dec2], 1, 'b'],
|
|
675
|
+
[dec, 1, 'b', (i) => i.#privBData, (i, v) => i.#privBData = v],
|
|
676
|
+
[dec, 2, 'c'],
|
|
677
|
+
[dec, 2, 'c', () => console.log('privC')],
|
|
678
|
+
[dec, 3, 'd'],
|
|
679
|
+
[dec, 3, 'd', () => console.log('privD')],
|
|
680
|
+
[dec, 4, 'e'],
|
|
681
|
+
[dec, 4, 'e', () => console.log('privE')],
|
|
682
|
+
],
|
|
683
|
+
[
|
|
684
|
+
dec
|
|
685
|
+
]
|
|
686
|
+
)
|
|
687
|
+
|
|
688
|
+
initA = ret[0];
|
|
689
|
+
|
|
690
|
+
initPrivA = ret[1];
|
|
691
|
+
|
|
692
|
+
initB = ret[2];
|
|
693
|
+
|
|
694
|
+
initPrivB = ret[3];
|
|
695
|
+
getPrivB = ret[4];
|
|
696
|
+
setPrivB = ret[5];
|
|
697
|
+
|
|
698
|
+
privC = ret[6];
|
|
699
|
+
|
|
700
|
+
privD = ret[7];
|
|
701
|
+
|
|
702
|
+
privE = ret[8];
|
|
703
|
+
|
|
704
|
+
initializeInstance = ret[9];
|
|
705
|
+
|
|
706
|
+
Class = ret[10]
|
|
707
|
+
|
|
708
|
+
initializeClass = ret[11];
|
|
709
|
+
}
|
|
710
|
+
|
|
711
|
+
a = (initializeInstance(this), initA(this, 123));
|
|
712
|
+
|
|
713
|
+
#a = initPrivA(this, 123);
|
|
714
|
+
|
|
715
|
+
#bData = initB(this, 123);
|
|
716
|
+
get b() { return this.#bData }
|
|
717
|
+
set b(v) { this.#bData = v }
|
|
718
|
+
|
|
719
|
+
#privBData = initPrivB(this, 123);
|
|
720
|
+
get #b() { return getPrivB(this); }
|
|
721
|
+
set #b(v) { setPrivB(this, v); }
|
|
722
|
+
|
|
723
|
+
c() { console.log('c'); }
|
|
724
|
+
|
|
725
|
+
#c(...args) { return privC(this, ...args) }
|
|
726
|
+
|
|
727
|
+
get d() { console.log('d'); }
|
|
728
|
+
|
|
729
|
+
get #d() { return privD(this); }
|
|
730
|
+
|
|
731
|
+
set e(v) { console.log('e'); }
|
|
732
|
+
|
|
733
|
+
set #e(v) { privE(this, v); }
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
initializeClass(Class);
|
|
737
|
+
*/
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+
export default function applyDecs(targetClass, memberDecs, classDecs) {
|
|
741
|
+
var ret = [];
|
|
742
|
+
var staticMetadataMap = {};
|
|
743
|
+
|
|
744
|
+
if (memberDecs) {
|
|
745
|
+
var protoMetadataMap = {};
|
|
746
|
+
applyMemberDecs(ret, targetClass, protoMetadataMap, staticMetadataMap, memberDecs);
|
|
747
|
+
convertMetadataMapToFinal(targetClass.prototype, protoMetadataMap);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
if (classDecs) {
|
|
751
|
+
applyClassDecs(ret, targetClass, staticMetadataMap, classDecs);
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
convertMetadataMapToFinal(targetClass, staticMetadataMap);
|
|
755
|
+
return ret;
|
|
756
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import superPropBase from "../superPropBase/superPropBase.js";
|
|
2
2
|
export default function _get() {
|
|
3
3
|
if (typeof Reflect !== "undefined" && Reflect.get) {
|
|
4
|
-
_get = Reflect.get;
|
|
4
|
+
_get = Reflect.get.bind();
|
|
5
5
|
} else {
|
|
6
6
|
_get = function _get(target, property, receiver) {
|
|
7
7
|
var base = superPropBase(target, property);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export default Object.setPrototypeOf ? Object.getPrototypeOf : // eslint-disable-next-line no-proto
|
|
1
|
+
export default Object.setPrototypeOf ? Object.getPrototypeOf.bind() : // eslint-disable-next-line no-proto
|
|
2
2
|
o => o.__proto__ || Object.getPrototypeOf(o);
|
package/dist/main.js
CHANGED
|
@@ -3386,9 +3386,13 @@ const getFeatureCompat = feature => {
|
|
|
3386
3386
|
return feature;
|
|
3387
3387
|
};
|
|
3388
3388
|
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
3389
|
+
/*
|
|
3390
|
+
* Generated helpers
|
|
3391
|
+
* - https://github.com/babel/babel/commits/main/packages/babel-helpers/src/helpers.ts
|
|
3392
|
+
* File helpers
|
|
3393
|
+
* - https://github.com/babel/babel/tree/main/packages/babel-helpers/src/helpers
|
|
3394
|
+
*
|
|
3395
|
+
*/
|
|
3392
3396
|
const babelHelperClientDirectoryUrl = new URL("./babel_helpers/", import.meta.url).href; // we cannot use "@jsenv/core/src/*" because babel helper might be injected
|
|
3393
3397
|
// into node_modules not depending on "@jsenv/core"
|
|
3394
3398
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/core",
|
|
3
|
-
"version": "27.0.0-alpha.
|
|
3
|
+
"version": "27.0.0-alpha.82",
|
|
4
4
|
"description": "Tool to develop, test and build js projects",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": {
|
|
@@ -42,9 +42,9 @@
|
|
|
42
42
|
"scripts": {
|
|
43
43
|
"eslint": "npx eslint . --ext=.js,.mjs,.cjs,.html",
|
|
44
44
|
"dev": "node --conditions=development ./scripts/dev/dev.mjs",
|
|
45
|
-
"build": "node --conditions=development ./scripts/build/build.mjs",
|
|
46
45
|
"test": "node --conditions=development ./scripts/test/test.mjs",
|
|
47
46
|
"test-packages": "npm run test --workspaces --if-present -- --workspace",
|
|
47
|
+
"build": "node --conditions=development ./scripts/build/build.mjs",
|
|
48
48
|
"start_file_server": "node ./scripts/dev/start_file_server.mjs",
|
|
49
49
|
"workspace-versions": "node ./scripts/publish/workspace_versions.mjs",
|
|
50
50
|
"workspace-publish": "node ./scripts/publish/workspace_publish.mjs",
|
|
@@ -60,14 +60,13 @@
|
|
|
60
60
|
"playwright": "1.x"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@babel/parser": "7.17.9",
|
|
64
63
|
"@babel/plugin-proposal-dynamic-import": "7.16.7",
|
|
65
|
-
"@babel/plugin-transform-modules-systemjs": "7.
|
|
66
|
-
"@babel/plugin-transform-modules-umd": "7.
|
|
64
|
+
"@babel/plugin-transform-modules-systemjs": "7.18.5",
|
|
65
|
+
"@babel/plugin-transform-modules-umd": "7.18.0",
|
|
67
66
|
"@c88/v8-coverage": "0.1.1",
|
|
68
67
|
"@financial-times/polyfill-useragent-normaliser": "2.0.1",
|
|
69
68
|
"@jsenv/abort": "4.2.2",
|
|
70
|
-
"@jsenv/babel-plugins": "1.0.
|
|
69
|
+
"@jsenv/babel-plugins": "1.0.5",
|
|
71
70
|
"@jsenv/filesystem": "4.0.9",
|
|
72
71
|
"@jsenv/importmap": "1.2.0",
|
|
73
72
|
"@jsenv/integrity": "0.0.1",
|
|
@@ -94,8 +93,8 @@
|
|
|
94
93
|
"wrap-ansi": "8.0.1"
|
|
95
94
|
},
|
|
96
95
|
"devDependencies": {
|
|
97
|
-
"@babel/eslint-parser": "7.
|
|
98
|
-
"@babel/plugin-syntax-import-assertions": "7.
|
|
96
|
+
"@babel/eslint-parser": "7.18.2",
|
|
97
|
+
"@babel/plugin-syntax-import-assertions": "7.17.12",
|
|
99
98
|
"@jsenv/assert": "2.5.4",
|
|
100
99
|
"@jsenv/eslint-config": "16.0.9",
|
|
101
100
|
"@jsenv/file-size-impact": "12.1.13",
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
# Babel helpers
|
|
2
|
-
|
|
3
|
-
Babel helpers are copied in there to properly appear in sourcemap.
|
|
4
|
-
|
|
5
|
-
- Last sync date: 31 January 2022
|
|
6
|
-
|
|
7
|
-
- Helpers file: https://github.com/babel/babel/blob/main/packages/babel-helpers/src/helpers.ts
|
|
8
|
-
- Individual helpers: https://github.com/babel/babel/tree/main/packages/babel-helpers/src/helpers
|