@vicin/sigil 2.0.3 → 2.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/CHANGELOG.md +21 -3
- package/README.md +61 -52
- package/dist/index.d.mts +45 -64
- package/dist/index.d.ts +45 -64
- package/dist/index.global.js +134 -72
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +134 -74
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +134 -74
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -6,17 +6,26 @@ var cuid2 = require('@paralleldrive/cuid2');
|
|
|
6
6
|
var OPTIONS = {
|
|
7
7
|
labelValidation: null,
|
|
8
8
|
skipLabelInheritanceCheck: false,
|
|
9
|
-
autofillLabels:
|
|
9
|
+
autofillLabels: true
|
|
10
10
|
};
|
|
11
|
-
var
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
11
|
+
var updateSigilOptions = (opts) => {
|
|
12
|
+
if ("autofillLabels" in opts) {
|
|
13
|
+
if (typeof opts.autofillLabels !== "boolean")
|
|
14
|
+
throw new Error("'updateSigilOptions.autofillLabels' must be boolean");
|
|
15
|
+
OPTIONS.autofillLabels = opts.autofillLabels;
|
|
16
|
+
}
|
|
17
|
+
if ("skipLabelInheritanceCheck" in opts) {
|
|
18
|
+
if (typeof opts.skipLabelInheritanceCheck !== "boolean")
|
|
19
|
+
throw new Error("'updateSigilOptions.skipLabelInheritanceCheck' must be boolean");
|
|
20
|
+
OPTIONS.skipLabelInheritanceCheck = opts.skipLabelInheritanceCheck;
|
|
21
|
+
}
|
|
22
|
+
if ("labelValidation" in opts) {
|
|
23
|
+
const val = opts.labelValidation;
|
|
24
|
+
if (val !== null && typeof val !== "function" && !(val instanceof RegExp))
|
|
25
|
+
throw new Error("'updateSigilOptions.labelValidation' must be null, function or RegExp");
|
|
26
|
+
OPTIONS.labelValidation = val != null ? val : null;
|
|
27
|
+
}
|
|
18
28
|
};
|
|
19
|
-
updateOptions(DEFAULT_OPTIONS);
|
|
20
29
|
var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
|
|
21
30
|
|
|
22
31
|
// src/core/symbols.ts
|
|
@@ -25,47 +34,50 @@ var __SIGIL_BASE__ = /* @__PURE__ */ Symbol.for("@Sigil.__SIGIL_BASE__");
|
|
|
25
34
|
var __DECORATED__ = /* @__PURE__ */ Symbol.for("@Sigil.__DECORATED__");
|
|
26
35
|
var __INHERITANCE_CHECKED__ = /* @__PURE__ */ Symbol.for("@Sigil.__INHERITANCE_CHECKED__");
|
|
27
36
|
var __LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL__");
|
|
37
|
+
var __EFFECTIVE_LABEL__ = /* @__PURE__ */ Symbol.for("@Sigil.__EFFECTIVE_LABEL__");
|
|
28
38
|
var __LABEL_LINEAGE__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_LINEAGE__");
|
|
29
39
|
var __LABEL_SET__ = /* @__PURE__ */ Symbol.for("@Sigil.__LABEL_SET__");
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
throw new Error(
|
|
38
|
-
`Constructor ${ctor} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`
|
|
39
|
-
);
|
|
40
|
+
function decorateCtor(ctor, label, runtime) {
|
|
41
|
+
if (process.env.NODE_ENV !== "production") {
|
|
42
|
+
if (isDecorated(ctor))
|
|
43
|
+
throw new Error(
|
|
44
|
+
`Constructor ${ctor} is already decorated. if you are using 'withSigilTyped()' & '@WithSigil()' at the same time remove one of them.`
|
|
45
|
+
);
|
|
46
|
+
}
|
|
40
47
|
Object.defineProperty(ctor, __LABEL__, {
|
|
41
48
|
value: label,
|
|
42
|
-
configurable:
|
|
49
|
+
configurable: true,
|
|
43
50
|
enumerable: false,
|
|
44
51
|
writable: false
|
|
45
52
|
});
|
|
53
|
+
if (!(runtime == null ? void 0 : runtime.isInheritanceCheck))
|
|
54
|
+
Object.defineProperty(ctor, __EFFECTIVE_LABEL__, {
|
|
55
|
+
value: label,
|
|
56
|
+
configurable: true,
|
|
57
|
+
enumerable: false,
|
|
58
|
+
writable: false
|
|
59
|
+
});
|
|
46
60
|
const parent = Object.getPrototypeOf(ctor);
|
|
47
61
|
const parentChain = parent && parent[__LABEL_LINEAGE__] ? parent[__LABEL_LINEAGE__] : [];
|
|
48
|
-
const ctorChain = isMixin && label !== "Sigil" ? ["Sigil", ...parentChain, label] : [...parentChain, label];
|
|
62
|
+
const ctorChain = (runtime == null ? void 0 : runtime.isMixin) && label !== "Sigil" ? ["Sigil", ...parentChain, label] : [...parentChain, label];
|
|
49
63
|
Object.defineProperty(ctor, __LABEL_LINEAGE__, {
|
|
50
64
|
value: ctorChain,
|
|
51
|
-
configurable:
|
|
65
|
+
configurable: true,
|
|
52
66
|
enumerable: false,
|
|
53
67
|
writable: false
|
|
54
68
|
});
|
|
55
69
|
Object.defineProperty(ctor, __LABEL_SET__, {
|
|
56
70
|
value: new Set(ctorChain),
|
|
57
|
-
configurable:
|
|
71
|
+
configurable: true,
|
|
58
72
|
enumerable: false,
|
|
59
73
|
writable: false
|
|
60
74
|
});
|
|
61
|
-
markDecorated(ctor);
|
|
75
|
+
if (!(runtime == null ? void 0 : runtime.isInheritanceCheck)) markDecorated(ctor);
|
|
62
76
|
}
|
|
63
77
|
function checkInheritance(ctor, opts) {
|
|
64
78
|
var _a, _b;
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if (!isSigilCtor(ctor)) return;
|
|
68
|
-
if (isInheritanceChecked(ctor) || skipLabelInheritanceCheck) return;
|
|
79
|
+
if (isInheritanceChecked(ctor) || ((_a = opts == null ? void 0 : opts.skipLabelInheritanceCheck) != null ? _a : OPTIONS.skipLabelInheritanceCheck))
|
|
80
|
+
return;
|
|
69
81
|
const ctors = [ctor];
|
|
70
82
|
let ancestor = Object.getPrototypeOf(ctor);
|
|
71
83
|
while (isSigilCtor(ancestor)) {
|
|
@@ -76,16 +88,16 @@ function checkInheritance(ctor, opts) {
|
|
|
76
88
|
for (let i = ctors.length - 1; i >= 0; i--) {
|
|
77
89
|
const ctor2 = ctors[i];
|
|
78
90
|
if (!ctor2) continue;
|
|
79
|
-
let label = ctor2
|
|
91
|
+
let label = ctor2[__LABEL__];
|
|
80
92
|
if (labelOwner.has(label)) {
|
|
81
|
-
if (
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
93
|
+
if (process.env.NODE_ENV !== "production") {
|
|
94
|
+
if (isDecorated(ctor2) || !((_b = opts == null ? void 0 : opts.autofillLabels) != null ? _b : OPTIONS.autofillLabels))
|
|
95
|
+
throw new Error(
|
|
96
|
+
`[Sigil Error] Class "${ctor2.name}" re-uses Sigil label "${label}" from ancestor "${labelOwner.get(label)}". Each Sigil subclass must use a unique label. Did you forget to use "WithSigil(newLabel)" on the subclass?`
|
|
97
|
+
);
|
|
86
98
|
}
|
|
87
99
|
label = generateRandomLabel();
|
|
88
|
-
decorateCtor(ctor2, label);
|
|
100
|
+
decorateCtor(ctor2, label, { isInheritanceCheck: true });
|
|
89
101
|
}
|
|
90
102
|
labelOwner.set(label, ctor2.name);
|
|
91
103
|
}
|
|
@@ -98,10 +110,12 @@ function verifyLabel(label, opts) {
|
|
|
98
110
|
let valid;
|
|
99
111
|
if (labelValidation instanceof RegExp) valid = labelValidation.test(label);
|
|
100
112
|
else valid = labelValidation(label);
|
|
101
|
-
if (
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
113
|
+
if (process.env.NODE_ENV !== "production") {
|
|
114
|
+
if (!valid)
|
|
115
|
+
throw new Error(
|
|
116
|
+
`[Sigil] Invalid identity label "${label}". Make sure that supplied label matches validation regex or function.`
|
|
117
|
+
);
|
|
118
|
+
}
|
|
105
119
|
}
|
|
106
120
|
}
|
|
107
121
|
function generateRandomLabel() {
|
|
@@ -170,7 +184,7 @@ function getConstructor(obj) {
|
|
|
170
184
|
|
|
171
185
|
// src/core/mixin.ts
|
|
172
186
|
function Sigilify(Base, label, opts) {
|
|
173
|
-
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already
|
|
187
|
+
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
|
|
174
188
|
let l;
|
|
175
189
|
if (label) {
|
|
176
190
|
verifyLabel(label, opts);
|
|
@@ -178,11 +192,18 @@ function Sigilify(Base, label, opts) {
|
|
|
178
192
|
} else l = generateRandomLabel();
|
|
179
193
|
class Sigilified extends Base {
|
|
180
194
|
/**
|
|
181
|
-
* Class-level
|
|
195
|
+
* Class-level identity label constant for this sigil constructor.
|
|
182
196
|
*/
|
|
183
197
|
static get SigilLabel() {
|
|
198
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
184
199
|
return this[__LABEL__];
|
|
185
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
203
|
+
*/
|
|
204
|
+
static get SigilEffectiveLabel() {
|
|
205
|
+
return this[__EFFECTIVE_LABEL__];
|
|
206
|
+
}
|
|
186
207
|
/**
|
|
187
208
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
188
209
|
*
|
|
@@ -192,6 +213,7 @@ function Sigilify(Base, label, opts) {
|
|
|
192
213
|
*/
|
|
193
214
|
static get SigilLabelLineage() {
|
|
194
215
|
var _a;
|
|
216
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
195
217
|
return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
|
|
196
218
|
}
|
|
197
219
|
/**
|
|
@@ -202,6 +224,7 @@ function Sigilify(Base, label, opts) {
|
|
|
202
224
|
* @returns A Readonly Set of labels that represent the type lineage.
|
|
203
225
|
*/
|
|
204
226
|
static get SigilLabelSet() {
|
|
227
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
205
228
|
const set = /* @__PURE__ */ new Set();
|
|
206
229
|
for (const s of this[__LABEL_SET__]) set.add(s);
|
|
207
230
|
return set;
|
|
@@ -212,11 +235,11 @@ function Sigilify(Base, label, opts) {
|
|
|
212
235
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
213
236
|
const ctor = getConstructor(this);
|
|
214
237
|
if (!ctor) {
|
|
215
|
-
if (
|
|
238
|
+
if (process.env.NODE_ENV !== "production")
|
|
216
239
|
throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
|
|
217
240
|
return;
|
|
218
241
|
}
|
|
219
|
-
|
|
242
|
+
checkInheritance(ctor);
|
|
220
243
|
}
|
|
221
244
|
/**
|
|
222
245
|
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
@@ -295,19 +318,33 @@ function Sigilify(Base, label, opts) {
|
|
|
295
318
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
296
319
|
}
|
|
297
320
|
/**
|
|
298
|
-
* Returns the
|
|
321
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
299
322
|
*
|
|
300
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
323
|
+
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil.auto-dq62ib6jnvmmlfbjhxh2937h') or '@Sigil.unknown' if constructor is missing.
|
|
301
324
|
*/
|
|
302
325
|
getSigilLabel() {
|
|
303
326
|
const ctor = getConstructor(this);
|
|
304
327
|
if (!ctor) {
|
|
305
|
-
if (
|
|
306
|
-
throw new Error(`[Sigil Error]
|
|
328
|
+
if (process.env.NODE_ENV !== "production")
|
|
329
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
307
330
|
return "@Sigil.unknown";
|
|
308
331
|
}
|
|
309
332
|
return ctor.SigilLabel;
|
|
310
333
|
}
|
|
334
|
+
/**
|
|
335
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
336
|
+
*
|
|
337
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
338
|
+
*/
|
|
339
|
+
getSigilEffectiveLabel() {
|
|
340
|
+
const ctor = getConstructor(this);
|
|
341
|
+
if (!ctor) {
|
|
342
|
+
if (process.env.NODE_ENV !== "production")
|
|
343
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
344
|
+
return "@Sigil.unknown";
|
|
345
|
+
}
|
|
346
|
+
return ctor.SigilEffectiveLabel;
|
|
347
|
+
}
|
|
311
348
|
/**
|
|
312
349
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
313
350
|
*
|
|
@@ -316,8 +353,8 @@ function Sigilify(Base, label, opts) {
|
|
|
316
353
|
getSigilLabelLineage() {
|
|
317
354
|
const ctor = getConstructor(this);
|
|
318
355
|
if (!ctor) {
|
|
319
|
-
if (
|
|
320
|
-
throw new Error(`[Sigil Error]
|
|
356
|
+
if (process.env.NODE_ENV !== "production")
|
|
357
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
321
358
|
return ["@Sigil.unknown"];
|
|
322
359
|
}
|
|
323
360
|
return ctor.SigilLabelLineage;
|
|
@@ -330,20 +367,20 @@ function Sigilify(Base, label, opts) {
|
|
|
330
367
|
getSigilLabelSet() {
|
|
331
368
|
const ctor = getConstructor(this);
|
|
332
369
|
if (!ctor) {
|
|
333
|
-
if (
|
|
334
|
-
throw new Error(`[Sigil Error]
|
|
370
|
+
if (process.env.NODE_ENV !== "production")
|
|
371
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
335
372
|
return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
|
|
336
373
|
}
|
|
337
374
|
return ctor.SigilLabelSet;
|
|
338
375
|
}
|
|
339
376
|
}
|
|
340
|
-
decorateCtor(Sigilified, l, true);
|
|
377
|
+
decorateCtor(Sigilified, l, { isMixin: true });
|
|
341
378
|
markSigil(Sigilified);
|
|
342
379
|
markSigilBase(Sigilified);
|
|
343
380
|
return Sigilified;
|
|
344
381
|
}
|
|
345
382
|
function SigilifyAbstract(Base, label, opts) {
|
|
346
|
-
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already
|
|
383
|
+
if (isSigilCtor(Base)) throw new Error(`[Sigil Error] 'Sigilify(${label})' already sigilified.`);
|
|
347
384
|
let l;
|
|
348
385
|
if (label) {
|
|
349
386
|
verifyLabel(label, opts);
|
|
@@ -351,11 +388,18 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
351
388
|
} else l = generateRandomLabel();
|
|
352
389
|
class Sigilified extends Base {
|
|
353
390
|
/**
|
|
354
|
-
* Class-level
|
|
391
|
+
* Class-level identity label constant for this sigil constructor.
|
|
355
392
|
*/
|
|
356
393
|
static get SigilLabel() {
|
|
394
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
357
395
|
return this[__LABEL__];
|
|
358
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
399
|
+
*/
|
|
400
|
+
static get SigilEffectiveLabel() {
|
|
401
|
+
return this[__EFFECTIVE_LABEL__];
|
|
402
|
+
}
|
|
359
403
|
/**
|
|
360
404
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
361
405
|
*
|
|
@@ -365,6 +409,7 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
365
409
|
*/
|
|
366
410
|
static get SigilLabelLineage() {
|
|
367
411
|
var _a;
|
|
412
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
368
413
|
return [...(_a = this[__LABEL_LINEAGE__]) != null ? _a : []];
|
|
369
414
|
}
|
|
370
415
|
/**
|
|
@@ -375,6 +420,7 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
375
420
|
* @returns A Readonly Set of labels that represent the type lineage.
|
|
376
421
|
*/
|
|
377
422
|
static get SigilLabelSet() {
|
|
423
|
+
if (!isInheritanceChecked(this)) checkInheritance(this);
|
|
378
424
|
const set = /* @__PURE__ */ new Set();
|
|
379
425
|
for (const s of this[__LABEL_SET__]) set.add(s);
|
|
380
426
|
return set;
|
|
@@ -385,11 +431,11 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
385
431
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
386
432
|
const ctor = getConstructor(this);
|
|
387
433
|
if (!ctor) {
|
|
388
|
-
if (
|
|
434
|
+
if (process.env.NODE_ENV !== "production")
|
|
389
435
|
throw new Error(`[Sigil Error] 'Sigilify(${label})' instance without constructor`);
|
|
390
436
|
return;
|
|
391
437
|
}
|
|
392
|
-
|
|
438
|
+
checkInheritance(ctor);
|
|
393
439
|
}
|
|
394
440
|
/**
|
|
395
441
|
* Runtime predicate indicating whether `obj` is an instance produced by a sigil class.
|
|
@@ -417,7 +463,7 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
417
463
|
*/
|
|
418
464
|
static isOfType(other) {
|
|
419
465
|
var _a;
|
|
420
|
-
if (!isSigilInstance(other)
|
|
466
|
+
if (!isSigilInstance(other)) return false;
|
|
421
467
|
const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
|
|
422
468
|
const thisType = this[__LABEL__];
|
|
423
469
|
return !!otherSet && otherSet.has(thisType);
|
|
@@ -436,7 +482,7 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
436
482
|
*/
|
|
437
483
|
static isOfTypeStrict(other) {
|
|
438
484
|
var _a;
|
|
439
|
-
if (!isSigilInstance(other)
|
|
485
|
+
if (!isSigilInstance(other)) return false;
|
|
440
486
|
const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
|
|
441
487
|
const thisLineage = this[__LABEL_LINEAGE__];
|
|
442
488
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
@@ -453,7 +499,7 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
453
499
|
*/
|
|
454
500
|
isOfType(other) {
|
|
455
501
|
var _a;
|
|
456
|
-
if (!isSigilInstance(other)
|
|
502
|
+
if (!isSigilInstance(other)) return false;
|
|
457
503
|
const otherSet = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_SET__];
|
|
458
504
|
const thisType = getConstructor(this)[__LABEL__];
|
|
459
505
|
return !!otherSet && otherSet.has(thisType);
|
|
@@ -470,25 +516,39 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
470
516
|
*/
|
|
471
517
|
isOfTypeStrict(other) {
|
|
472
518
|
var _a, _b;
|
|
473
|
-
if (!isSigilInstance(other)
|
|
519
|
+
if (!isSigilInstance(other)) return false;
|
|
474
520
|
const otherLineage = (_a = getConstructor(other)) == null ? void 0 : _a[__LABEL_LINEAGE__];
|
|
475
521
|
const thisLineage = (_b = getConstructor(this)) == null ? void 0 : _b[__LABEL_LINEAGE__];
|
|
476
522
|
return !!otherLineage && thisLineage.every((s, i) => s === otherLineage[i]);
|
|
477
523
|
}
|
|
478
524
|
/**
|
|
479
|
-
* Returns the
|
|
525
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
480
526
|
*
|
|
481
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
527
|
+
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil.auto-dq62ib6jnvmmlfbjhxh2937h') or '@Sigil.unknown' if constructor is missing.
|
|
482
528
|
*/
|
|
483
529
|
getSigilLabel() {
|
|
484
530
|
const ctor = getConstructor(this);
|
|
485
531
|
if (!ctor) {
|
|
486
|
-
if (
|
|
487
|
-
throw new Error(`[Sigil Error]
|
|
532
|
+
if (process.env.NODE_ENV !== "production")
|
|
533
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
488
534
|
return "@Sigil.unknown";
|
|
489
535
|
}
|
|
490
536
|
return ctor.SigilLabel;
|
|
491
537
|
}
|
|
538
|
+
/**
|
|
539
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
540
|
+
*
|
|
541
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
542
|
+
*/
|
|
543
|
+
getSigilEffectiveLabel() {
|
|
544
|
+
const ctor = getConstructor(this);
|
|
545
|
+
if (!ctor) {
|
|
546
|
+
if (process.env.NODE_ENV !== "production")
|
|
547
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
548
|
+
return "@Sigil.unknown";
|
|
549
|
+
}
|
|
550
|
+
return ctor.SigilEffectiveLabel;
|
|
551
|
+
}
|
|
492
552
|
/**
|
|
493
553
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
494
554
|
*
|
|
@@ -497,8 +557,8 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
497
557
|
getSigilLabelLineage() {
|
|
498
558
|
const ctor = getConstructor(this);
|
|
499
559
|
if (!ctor) {
|
|
500
|
-
if (
|
|
501
|
-
throw new Error(`[Sigil Error]
|
|
560
|
+
if (process.env.NODE_ENV !== "production")
|
|
561
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
502
562
|
return ["@Sigil.unknown"];
|
|
503
563
|
}
|
|
504
564
|
return ctor.SigilLabelLineage;
|
|
@@ -511,14 +571,14 @@ function SigilifyAbstract(Base, label, opts) {
|
|
|
511
571
|
getSigilLabelSet() {
|
|
512
572
|
const ctor = getConstructor(this);
|
|
513
573
|
if (!ctor) {
|
|
514
|
-
if (
|
|
515
|
-
throw new Error(`[Sigil Error]
|
|
574
|
+
if (process.env.NODE_ENV !== "production")
|
|
575
|
+
throw new Error(`[Sigil Error] Sigil class instance without constructor`);
|
|
516
576
|
return /* @__PURE__ */ new Set(["@Sigil.unknown"]);
|
|
517
577
|
}
|
|
518
578
|
return ctor.SigilLabelSet;
|
|
519
579
|
}
|
|
520
580
|
}
|
|
521
|
-
decorateCtor(Sigilified, l, true);
|
|
581
|
+
decorateCtor(Sigilified, l, { isMixin: true });
|
|
522
582
|
markSigil(Sigilified);
|
|
523
583
|
markSigilBase(Sigilified);
|
|
524
584
|
return Sigilified;
|
|
@@ -543,11 +603,11 @@ function WithSigil(label, opts) {
|
|
|
543
603
|
`[Sigil Error] 'WithSigil' decorator accept only Sigil classes but used on class ${value.name}`
|
|
544
604
|
);
|
|
545
605
|
decorateCtor(value, l);
|
|
546
|
-
|
|
606
|
+
checkInheritance(value, opts);
|
|
547
607
|
};
|
|
548
608
|
}
|
|
549
609
|
|
|
550
|
-
// src/core/
|
|
610
|
+
// src/core/hof.ts
|
|
551
611
|
function withSigil(Class, label, opts) {
|
|
552
612
|
var _a;
|
|
553
613
|
if (!isSigilCtor(Class))
|
|
@@ -561,7 +621,7 @@ function withSigil(Class, label, opts) {
|
|
|
561
621
|
} else l = generateRandomLabel();
|
|
562
622
|
const ctor = Class;
|
|
563
623
|
decorateCtor(ctor, l);
|
|
564
|
-
|
|
624
|
+
checkInheritance(ctor, opts);
|
|
565
625
|
return Class;
|
|
566
626
|
}
|
|
567
627
|
function withSigilTyped(Class, label, opts) {
|
|
@@ -577,7 +637,7 @@ function withSigilTyped(Class, label, opts) {
|
|
|
577
637
|
} else l = generateRandomLabel();
|
|
578
638
|
const ctor = Class;
|
|
579
639
|
decorateCtor(ctor, l);
|
|
580
|
-
|
|
640
|
+
checkInheritance(ctor, opts);
|
|
581
641
|
return Class;
|
|
582
642
|
}
|
|
583
643
|
|
|
@@ -593,7 +653,7 @@ exports.isSigilBaseCtor = isSigilBaseCtor;
|
|
|
593
653
|
exports.isSigilBaseInstance = isSigilBaseInstance;
|
|
594
654
|
exports.isSigilCtor = isSigilCtor;
|
|
595
655
|
exports.isSigilInstance = isSigilInstance;
|
|
596
|
-
exports.
|
|
656
|
+
exports.updateSigilOptions = updateSigilOptions;
|
|
597
657
|
exports.withSigil = withSigil;
|
|
598
658
|
exports.withSigilTyped = withSigilTyped;
|
|
599
659
|
//# sourceMappingURL=index.js.map
|