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