@vicin/sigil 2.1.0 → 2.2.1
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 +11 -0
- package/README.md +56 -47
- package/dist/index.d.mts +40 -12
- package/dist/index.d.ts +40 -12
- package/dist/index.global.js +122 -70
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +122 -72
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +122 -72
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,17 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [2.2.1] - 2026-02-23
|
|
6
|
+
|
|
7
|
+
### Added
|
|
8
|
+
|
|
9
|
+
- `SigilEffectiveLabel`/`getSigilEffectiveLabel()` which are last passed label for logging purposes.
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Patched multiple bugs.
|
|
14
|
+
- Updated defualt options, now `SigilOptions.autofillLabels` is `true` by default.
|
|
15
|
+
|
|
5
16
|
## [2.1.0] - 2026-02-22
|
|
6
17
|
|
|
7
18
|
### Changed
|
package/README.md
CHANGED
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
> - 🎉 v2.0.0 is out! Happy coding! 😄💻
|
|
6
6
|
> - 📄 **Changelog:** [CHANGELOG.md](./CHANGELOG.md)
|
|
7
7
|
|
|
8
|
-
`Sigil`
|
|
8
|
+
`Sigil` replaces `instanceof` across bundles, enforces nominal class identity, and makes inheritance-aware runtime type checks reliable in large TypeScript systems. It organizes class identities across your codebase and gives you the power of **nominal typing** and **safe cross-bundle class checks** where each class constructor is stored under a unique label.
|
|
9
9
|
|
|
10
10
|
> **Key ideas:**
|
|
11
11
|
>
|
|
12
|
+
> - **Reliable Runtime Checks:** Uses labels instead of instanceof for cross-bundle reliability.
|
|
12
13
|
> - **Nominal Typing at Compile Time:** Distinguishes structurally similar types (e.g., UserId vs. PostId).
|
|
13
|
-
> - **Reliable Runtime Checks:** Uses symbols instead of instanceof for cross-bundle reliability.
|
|
14
14
|
> - **Inheritance Awareness:** Tracks lineages for subtype/supertype checks.
|
|
15
15
|
|
|
16
16
|
## Important Notes Before Using
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
|
|
23
23
|
## Why Registry is dropped
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
In v2 we simplified the architecture to remove global registries and reduce complexity across packages.
|
|
26
26
|
|
|
27
27
|
---
|
|
28
28
|
|
|
@@ -48,8 +48,9 @@ Although registry added label checks and central class management but it also in
|
|
|
48
48
|
- [API reference](#api-reference)
|
|
49
49
|
- [Options & configuration](#options--configuration)
|
|
50
50
|
- [Minimal mode](#minimal-mode)
|
|
51
|
+
- [Strict mode](#strict-mode)
|
|
52
|
+
- [## Which pattern should I use?](#which-pattern-should-i-use)
|
|
51
53
|
- [Troubleshooting & FAQ](#troubleshooting--faq)
|
|
52
|
-
- [Phantom](#phantom)
|
|
53
54
|
- [Contributing](#contributing)
|
|
54
55
|
- [License](#license)
|
|
55
56
|
- [Author](#author)
|
|
@@ -151,16 +152,9 @@ console.log(User.isOfType(u)); // true
|
|
|
151
152
|
|
|
152
153
|
### Migration
|
|
153
154
|
|
|
154
|
-
Migrating old code into `Sigil` can be done
|
|
155
|
+
Migrating old code into `Sigil` can be done with extra couple lines of code only:
|
|
155
156
|
|
|
156
|
-
1.
|
|
157
|
-
|
|
158
|
-
```ts
|
|
159
|
-
import { updateSigilOptions } from '@vicin/sigil';
|
|
160
|
-
updateSigilOptions({ autofillLabels: true });
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
2. Pass your base class to `Sigilify` mixin:
|
|
157
|
+
1. Pass your base class to `Sigilify` mixin:
|
|
164
158
|
|
|
165
159
|
```ts
|
|
166
160
|
import { Sigilify } from '@vicin/sigil';
|
|
@@ -168,7 +162,7 @@ import { Sigilify } from '@vicin/sigil';
|
|
|
168
162
|
const MySigilBaseClass = Sigilify(MyBaseClass);
|
|
169
163
|
```
|
|
170
164
|
|
|
171
|
-
|
|
165
|
+
2. Or extend it with `Sigil`:
|
|
172
166
|
|
|
173
167
|
```ts
|
|
174
168
|
import { Sigil } from '@vicin/sigil';
|
|
@@ -186,11 +180,9 @@ This section states clearly what `Sigil` provides and what it does **not** provi
|
|
|
186
180
|
|
|
187
181
|
### What Sigil guarantees
|
|
188
182
|
|
|
189
|
-
**1.
|
|
190
|
-
|
|
191
|
-
**2. Reliable runtime identity (when used as intended).**
|
|
183
|
+
**1. Reliable runtime identity (when used as intended).**
|
|
192
184
|
|
|
193
|
-
**
|
|
185
|
+
**2. Nominal typing that is inheritance-aware**
|
|
194
186
|
|
|
195
187
|
### What Sigil does not guarantee
|
|
196
188
|
|
|
@@ -204,10 +196,10 @@ This section states clearly what `Sigil` provides and what it does **not** provi
|
|
|
204
196
|
|
|
205
197
|
### Terminology
|
|
206
198
|
|
|
207
|
-
- **Label**:
|
|
208
|
-
- **
|
|
209
|
-
- **
|
|
210
|
-
- **
|
|
199
|
+
- **Label**: An identity (string) such as `@scope/pkg.ClassName`, but can be random string (e.g. `@Sigil.auto-dq62ib6jnvmmlfbjhxh2937h`) if no label passed.
|
|
200
|
+
- **EffictiveLabel:** A human-readable (string) such as `@scope/pkg.ClassName`, if no label is passed it inherit the last defined label.
|
|
201
|
+
- **Label lineage**: Array of labels for ancestry.
|
|
202
|
+
- **Label set**: Set of labels for fast checks.
|
|
211
203
|
- **Brand**: TypeScript marker (`__SIGIL_BRAND__`) for nominal types.
|
|
212
204
|
|
|
213
205
|
---
|
|
@@ -217,6 +209,15 @@ This section states clearly what `Sigil` provides and what it does **not** provi
|
|
|
217
209
|
Sigil addresses issues in large monorepos and Domain-Driven Design (DDD):
|
|
218
210
|
|
|
219
211
|
- **Unreliable `instanceof`:** Bundling and HMR cause class redefinitions, breaking checks.
|
|
212
|
+
|
|
213
|
+
```ts
|
|
214
|
+
// Broken in monorepo or HMR
|
|
215
|
+
if (obj instanceof User) { ... }
|
|
216
|
+
|
|
217
|
+
// With Sigil
|
|
218
|
+
if (User.isOfType(obj)) { ... } // This still works even if User was bundled twice.
|
|
219
|
+
```
|
|
220
|
+
|
|
220
221
|
- **Manual Branding Overhead:** Custom identifiers lead to boilerplate and maintenance issues.
|
|
221
222
|
|
|
222
223
|
`Sigil` abstracts these into a **centralized system**, making identity management **explicit** and **error-resistant** if defined the right way.
|
|
@@ -225,7 +226,7 @@ Sigil addresses issues in large monorepos and Domain-Driven Design (DDD):
|
|
|
225
226
|
|
|
226
227
|
- **Runtime Contract:** Established via extending `Sigil` or using `Sigilify` mixin.
|
|
227
228
|
- **Update metadata:** With each new child, HOF or decorators are used to attach metadata and update nominal type.
|
|
228
|
-
- **Accessors & Type guards:** Classes expose `SigilLabel
|
|
229
|
+
- **Accessors & Type guards:** Classes expose `SigilLabel`; instances provide `getSigilLabel()` for querying unique identifier label. also when typed it hold nominal identity used to prevent subtle bugs.
|
|
229
230
|
|
|
230
231
|
```ts
|
|
231
232
|
import { Sigil, withSigilTyped, GetInstance } from '@vicin/sigil';
|
|
@@ -239,9 +240,9 @@ type MyClass = GetInstance<typeof MyClass>;
|
|
|
239
240
|
|
|
240
241
|
// Accessors & Type guards
|
|
241
242
|
console.log(MyClass.SigilLabel); // '@scope/package.MyClass'
|
|
242
|
-
console.log(new MyClass().
|
|
243
|
+
console.log(new MyClass().getSigilLabel()); // '@scope/package.MyClass'
|
|
243
244
|
console.log(MyClass.isOfType(new MyClass())); // true
|
|
244
|
-
function x(c: MyClass) {} // Only instances
|
|
245
|
+
function x(c: MyClass) {} // Only instances of 'MyClass' can be passed
|
|
245
246
|
```
|
|
246
247
|
|
|
247
248
|
---
|
|
@@ -315,7 +316,7 @@ type Y = GetInstance<typeof Y>;
|
|
|
315
316
|
const y = new Y(); // <-- Type here is any
|
|
316
317
|
```
|
|
317
318
|
|
|
318
|
-
|
|
319
|
+
This is a known TypeScript limitation.
|
|
319
320
|
|
|
320
321
|
---
|
|
321
322
|
|
|
@@ -414,7 +415,8 @@ class X extends Sigil {
|
|
|
414
415
|
|
|
415
416
|
When a constructor is decorated/sigilified it will expose the following **static** getters/methods:
|
|
416
417
|
|
|
417
|
-
- `SigilLabel` — the
|
|
418
|
+
- `SigilLabel` — the identity label string.
|
|
419
|
+
- `SigilEffectiveLabel` — the human label string.
|
|
418
420
|
- `SigilLabelLineage` — readonly array of labels representing parent → child.
|
|
419
421
|
- `SigilLabelSet` — readonly `Set<string>` for O(1) checks.
|
|
420
422
|
- `isSigilified(obj)` — runtime predicate that delegates to `isSigilInstance`.
|
|
@@ -423,10 +425,10 @@ When a constructor is decorated/sigilified it will expose the following **static
|
|
|
423
425
|
|
|
424
426
|
Instances of sigilified classes expose instance helpers:
|
|
425
427
|
|
|
426
|
-
- `getSigilLabel()` — returns the
|
|
427
|
-
- `
|
|
428
|
-
- `
|
|
429
|
-
- `
|
|
428
|
+
- `getSigilLabel()` — returns the identity label.
|
|
429
|
+
- `getSigilEffectiveLabel()` — returns the human label.
|
|
430
|
+
- `getSigilLabelLineage()` — returns lineage array.
|
|
431
|
+
- `getSigilLabelSet()` — returns readonly Set.
|
|
430
432
|
- `isOfType(other)` — O(1) membership test using `other`'s `__LABEL_SET__`.
|
|
431
433
|
- `isOfTypeStrict(other)` — strict lineage comparison element-by-element.
|
|
432
434
|
|
|
@@ -440,8 +442,8 @@ Customize behavior globally at startup:
|
|
|
440
442
|
import { updateSigilOptions } from '@vicin/sigil';
|
|
441
443
|
|
|
442
444
|
updateSigilOptions({
|
|
443
|
-
autofillLabels:
|
|
444
|
-
skipLabelInheritanceCheck: false, // Bypass dev inheritance checks -- ALMOST NEVER WANT TO SET THIS TO TRUE
|
|
445
|
+
autofillLabels: true, // Automatically label unlabeled subclasses
|
|
446
|
+
skipLabelInheritanceCheck: false, // Bypass dev inheritance checks -- ALMOST NEVER WANT TO SET THIS TO TRUE
|
|
445
447
|
labelValidation: null, // Function or regex, Enforce label format
|
|
446
448
|
});
|
|
447
449
|
```
|
|
@@ -452,38 +454,45 @@ Values defined in previous example are defaults, per-class overrides available i
|
|
|
452
454
|
|
|
453
455
|
## Minimal mode
|
|
454
456
|
|
|
455
|
-
|
|
457
|
+
You can ignore all decorators and HOFs and just make base class extend `Sigil`:
|
|
456
458
|
|
|
457
459
|
```ts
|
|
458
460
|
import { Sigil, updateSigilOptions } from '@vicin/sigil';
|
|
459
461
|
|
|
460
|
-
// run at the start of the app
|
|
461
|
-
updateSigilOptions({ autofillLabels: true });
|
|
462
|
-
|
|
463
462
|
// No decorators or HOF needed to use 'isOfType' ('instanceof' replacement)
|
|
464
463
|
class A extends Sigil {}
|
|
465
464
|
class B extends A {}
|
|
466
465
|
class C extends B {}
|
|
467
466
|
```
|
|
468
467
|
|
|
469
|
-
|
|
468
|
+
## Strict mode
|
|
470
469
|
|
|
471
|
-
|
|
470
|
+
If you want to inforce passing a label to every class defined in your codebase, you can set `autofillLabels` to `false` at the start of app:
|
|
472
471
|
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
472
|
+
```ts
|
|
473
|
+
import { updateSigilOptions } from '@vicin/sigil';
|
|
474
|
+
|
|
475
|
+
updateSigilOptions({ autofillLabels: false });
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
Now if you forgot to pass a label error is thrown.
|
|
476
479
|
|
|
477
480
|
---
|
|
478
481
|
|
|
479
|
-
##
|
|
482
|
+
## Which pattern should I use?
|
|
483
|
+
|
|
484
|
+
- Want simplest setup? → Extend `Sigil`
|
|
485
|
+
- Want full nominal typing? → Use HOF pattern
|
|
486
|
+
- Want clean class bodies? → Use HOF
|
|
487
|
+
- Want fewer wrapper exports? → Use Decorators
|
|
480
488
|
|
|
481
|
-
|
|
489
|
+
---
|
|
482
490
|
|
|
483
|
-
|
|
491
|
+
## Troubleshooting & FAQ
|
|
484
492
|
|
|
485
|
-
- **
|
|
486
|
-
- **
|
|
493
|
+
- **Dev Extension Errors:** Add labels or enable autofillLabels.
|
|
494
|
+
- **Anonymous Class Errors:** Export untyped bases.
|
|
495
|
+
- **Selective Labeling:** Use `autofillLabels: true` or empty `@WithSigil()` for auto-generation.
|
|
487
496
|
|
|
488
497
|
---
|
|
489
498
|
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* ----------------------------------------- */
|
|
4
4
|
/**
|
|
5
5
|
* Static-side interface describing methods and properties added to a class
|
|
6
|
-
* constructor when it is
|
|
6
|
+
* constructor when it is sigilified.
|
|
7
7
|
*
|
|
8
8
|
* The properties and methods described here mirror the getters and static
|
|
9
9
|
* predicates implemented by the `Sigilify` mixin.
|
|
@@ -22,8 +22,10 @@ interface ISigilStatic<L extends string = string, P extends Function = never> {
|
|
|
22
22
|
readonly __SIGIL_BRAND__: Prettify<{
|
|
23
23
|
[k in L]: true;
|
|
24
24
|
} & SigilBrandOf<P>>;
|
|
25
|
-
/** Class-level label constant (
|
|
25
|
+
/** Class-level label constant (identity). */
|
|
26
26
|
readonly SigilLabel: string;
|
|
27
|
+
/** Class-level label constant (human readable). */
|
|
28
|
+
readonly SigilEffectiveLabel: string;
|
|
27
29
|
/**
|
|
28
30
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
29
31
|
* Useful for debugging and strict lineage comparisons.
|
|
@@ -91,8 +93,10 @@ interface ISigilInstance<L extends string = string, P extends Function = never>
|
|
|
91
93
|
readonly __SIGIL_BRAND__: Prettify<{
|
|
92
94
|
[k in L]: true;
|
|
93
95
|
} & SigilBrandOf<P>>;
|
|
94
|
-
/** Returns
|
|
96
|
+
/** Returns identity sigil label of the class constructor. */
|
|
95
97
|
getSigilLabel(): string;
|
|
98
|
+
/** Returns human-readable sigil label of the class constructor. */
|
|
99
|
+
getSigilEffectiveLabel(): string;
|
|
96
100
|
/** Returns copy of sigil type label lineage of the class constructor. */
|
|
97
101
|
getSigilLabelLineage(): readonly string[];
|
|
98
102
|
/** Returns copy of sigil type label set of the class constructor. */
|
|
@@ -228,6 +232,7 @@ declare const Sigil: {
|
|
|
228
232
|
isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
229
233
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
230
234
|
getSigilLabel(): string;
|
|
235
|
+
getSigilEffectiveLabel(): string;
|
|
231
236
|
getSigilLabelLineage(): readonly string[];
|
|
232
237
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
233
238
|
};
|
|
@@ -235,6 +240,7 @@ declare const Sigil: {
|
|
|
235
240
|
Sigil: true;
|
|
236
241
|
};
|
|
237
242
|
get SigilLabel(): string;
|
|
243
|
+
get SigilEffectiveLabel(): string;
|
|
238
244
|
get SigilLabelLineage(): readonly string[];
|
|
239
245
|
get SigilLabelSet(): Readonly<Set<string>>;
|
|
240
246
|
isSigilified(obj: unknown): obj is ISigil;
|
|
@@ -260,6 +266,7 @@ declare const SigilError: {
|
|
|
260
266
|
isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
261
267
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
262
268
|
getSigilLabel(): string;
|
|
269
|
+
getSigilEffectiveLabel(): string;
|
|
263
270
|
getSigilLabelLineage(): readonly string[];
|
|
264
271
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
265
272
|
};
|
|
@@ -268,6 +275,7 @@ declare const SigilError: {
|
|
|
268
275
|
SigilError: true;
|
|
269
276
|
};
|
|
270
277
|
get SigilLabel(): string;
|
|
278
|
+
get SigilEffectiveLabel(): string;
|
|
271
279
|
get SigilLabelLineage(): readonly string[];
|
|
272
280
|
get SigilLabelSet(): Readonly<Set<string>>;
|
|
273
281
|
isSigilified(obj: unknown): obj is ISigil;
|
|
@@ -341,7 +349,7 @@ declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
|
341
349
|
* Notes:
|
|
342
350
|
* - This decorator is intended to be applied to classes only. When used
|
|
343
351
|
* incorrectly (e.g. on a property), it is a no-op.
|
|
344
|
-
* - Throws an error during class creation if the label validation fails.
|
|
352
|
+
* - Throws an error during class creation if the label validation fails (in development only).
|
|
345
353
|
*
|
|
346
354
|
* @typeParam L - Narrow string literal type for the provided label.
|
|
347
355
|
* @param label - Optional sigil label to assign to the decorated class (e.g. `@scope/pkg.ClassName`).
|
|
@@ -430,7 +438,7 @@ declare function isInheritanceChecked(ctor: Function): boolean;
|
|
|
430
438
|
* If not passed a random label is generated instead.
|
|
431
439
|
* @param opts - Options object to override any global options if needed.
|
|
432
440
|
* @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.
|
|
433
|
-
* @throws Error if `Base` is already
|
|
441
|
+
* @throws Error if `Base` is already sigilified.
|
|
434
442
|
*/
|
|
435
443
|
declare function Sigilify<B extends Constructor, L extends string>(Base: B, label?: L, opts?: SigilOptions): {
|
|
436
444
|
new (...args: any[]): {
|
|
@@ -467,11 +475,17 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
467
475
|
*/
|
|
468
476
|
isOfTypeStrict<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
|
|
469
477
|
/**
|
|
470
|
-
* Returns the
|
|
478
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
471
479
|
*
|
|
472
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
480
|
+
* @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.
|
|
473
481
|
*/
|
|
474
482
|
getSigilLabel(): string;
|
|
483
|
+
/**
|
|
484
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
485
|
+
*
|
|
486
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
487
|
+
*/
|
|
488
|
+
getSigilEffectiveLabel(): string;
|
|
475
489
|
/**
|
|
476
490
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
477
491
|
*
|
|
@@ -496,9 +510,13 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
496
510
|
Sigil: true;
|
|
497
511
|
} & { [K in L]: true; }>;
|
|
498
512
|
/**
|
|
499
|
-
* Class-level
|
|
513
|
+
* Class-level identity label constant for this sigil constructor.
|
|
500
514
|
*/
|
|
501
515
|
get SigilLabel(): string;
|
|
516
|
+
/**
|
|
517
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
518
|
+
*/
|
|
519
|
+
get SigilEffectiveLabel(): string;
|
|
502
520
|
/**
|
|
503
521
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
504
522
|
*
|
|
@@ -552,7 +570,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
552
570
|
* If not passed a random label is generated instead.
|
|
553
571
|
* @param opts - Options object to override any global options if needed.
|
|
554
572
|
* @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.
|
|
555
|
-
* @throws Error if `Base` is already
|
|
573
|
+
* @throws Error if `Base` is already sigilified.
|
|
556
574
|
*/
|
|
557
575
|
declare function SigilifyAbstract<B extends ConstructorAbstract, L extends string>(Base: B, label?: L, opts?: SigilOptions): ((abstract new (...args: any[]) => {
|
|
558
576
|
/**
|
|
@@ -588,11 +606,17 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
588
606
|
*/
|
|
589
607
|
isOfTypeStrict<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
|
|
590
608
|
/**
|
|
591
|
-
* Returns the
|
|
609
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
592
610
|
*
|
|
593
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
611
|
+
* @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.
|
|
594
612
|
*/
|
|
595
613
|
getSigilLabel(): string;
|
|
614
|
+
/**
|
|
615
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
616
|
+
*
|
|
617
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
618
|
+
*/
|
|
619
|
+
getSigilEffectiveLabel(): string;
|
|
596
620
|
/**
|
|
597
621
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
598
622
|
*
|
|
@@ -617,9 +641,13 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
617
641
|
Sigil: true;
|
|
618
642
|
} & { [K in L]: true; }>;
|
|
619
643
|
/**
|
|
620
|
-
* Class-level
|
|
644
|
+
* Class-level identity label constant for this sigil constructor.
|
|
621
645
|
*/
|
|
622
646
|
get SigilLabel(): string;
|
|
647
|
+
/**
|
|
648
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
649
|
+
*/
|
|
650
|
+
get SigilEffectiveLabel(): string;
|
|
623
651
|
/**
|
|
624
652
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
625
653
|
*
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* ----------------------------------------- */
|
|
4
4
|
/**
|
|
5
5
|
* Static-side interface describing methods and properties added to a class
|
|
6
|
-
* constructor when it is
|
|
6
|
+
* constructor when it is sigilified.
|
|
7
7
|
*
|
|
8
8
|
* The properties and methods described here mirror the getters and static
|
|
9
9
|
* predicates implemented by the `Sigilify` mixin.
|
|
@@ -22,8 +22,10 @@ interface ISigilStatic<L extends string = string, P extends Function = never> {
|
|
|
22
22
|
readonly __SIGIL_BRAND__: Prettify<{
|
|
23
23
|
[k in L]: true;
|
|
24
24
|
} & SigilBrandOf<P>>;
|
|
25
|
-
/** Class-level label constant (
|
|
25
|
+
/** Class-level label constant (identity). */
|
|
26
26
|
readonly SigilLabel: string;
|
|
27
|
+
/** Class-level label constant (human readable). */
|
|
28
|
+
readonly SigilEffectiveLabel: string;
|
|
27
29
|
/**
|
|
28
30
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
29
31
|
* Useful for debugging and strict lineage comparisons.
|
|
@@ -91,8 +93,10 @@ interface ISigilInstance<L extends string = string, P extends Function = never>
|
|
|
91
93
|
readonly __SIGIL_BRAND__: Prettify<{
|
|
92
94
|
[k in L]: true;
|
|
93
95
|
} & SigilBrandOf<P>>;
|
|
94
|
-
/** Returns
|
|
96
|
+
/** Returns identity sigil label of the class constructor. */
|
|
95
97
|
getSigilLabel(): string;
|
|
98
|
+
/** Returns human-readable sigil label of the class constructor. */
|
|
99
|
+
getSigilEffectiveLabel(): string;
|
|
96
100
|
/** Returns copy of sigil type label lineage of the class constructor. */
|
|
97
101
|
getSigilLabelLineage(): readonly string[];
|
|
98
102
|
/** Returns copy of sigil type label set of the class constructor. */
|
|
@@ -228,6 +232,7 @@ declare const Sigil: {
|
|
|
228
232
|
isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
229
233
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
230
234
|
getSigilLabel(): string;
|
|
235
|
+
getSigilEffectiveLabel(): string;
|
|
231
236
|
getSigilLabelLineage(): readonly string[];
|
|
232
237
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
233
238
|
};
|
|
@@ -235,6 +240,7 @@ declare const Sigil: {
|
|
|
235
240
|
Sigil: true;
|
|
236
241
|
};
|
|
237
242
|
get SigilLabel(): string;
|
|
243
|
+
get SigilEffectiveLabel(): string;
|
|
238
244
|
get SigilLabelLineage(): readonly string[];
|
|
239
245
|
get SigilLabelSet(): Readonly<Set<string>>;
|
|
240
246
|
isSigilified(obj: unknown): obj is ISigil;
|
|
@@ -260,6 +266,7 @@ declare const SigilError: {
|
|
|
260
266
|
isOfType<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
261
267
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
262
268
|
getSigilLabel(): string;
|
|
269
|
+
getSigilEffectiveLabel(): string;
|
|
263
270
|
getSigilLabelLineage(): readonly string[];
|
|
264
271
|
getSigilLabelSet(): Readonly<Set<string>>;
|
|
265
272
|
};
|
|
@@ -268,6 +275,7 @@ declare const SigilError: {
|
|
|
268
275
|
SigilError: true;
|
|
269
276
|
};
|
|
270
277
|
get SigilLabel(): string;
|
|
278
|
+
get SigilEffectiveLabel(): string;
|
|
271
279
|
get SigilLabelLineage(): readonly string[];
|
|
272
280
|
get SigilLabelSet(): Readonly<Set<string>>;
|
|
273
281
|
isSigilified(obj: unknown): obj is ISigil;
|
|
@@ -341,7 +349,7 @@ declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
|
341
349
|
* Notes:
|
|
342
350
|
* - This decorator is intended to be applied to classes only. When used
|
|
343
351
|
* incorrectly (e.g. on a property), it is a no-op.
|
|
344
|
-
* - Throws an error during class creation if the label validation fails.
|
|
352
|
+
* - Throws an error during class creation if the label validation fails (in development only).
|
|
345
353
|
*
|
|
346
354
|
* @typeParam L - Narrow string literal type for the provided label.
|
|
347
355
|
* @param label - Optional sigil label to assign to the decorated class (e.g. `@scope/pkg.ClassName`).
|
|
@@ -430,7 +438,7 @@ declare function isInheritanceChecked(ctor: Function): boolean;
|
|
|
430
438
|
* If not passed a random label is generated instead.
|
|
431
439
|
* @param opts - Options object to override any global options if needed.
|
|
432
440
|
* @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.
|
|
433
|
-
* @throws Error if `Base` is already
|
|
441
|
+
* @throws Error if `Base` is already sigilified.
|
|
434
442
|
*/
|
|
435
443
|
declare function Sigilify<B extends Constructor, L extends string>(Base: B, label?: L, opts?: SigilOptions): {
|
|
436
444
|
new (...args: any[]): {
|
|
@@ -467,11 +475,17 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
467
475
|
*/
|
|
468
476
|
isOfTypeStrict<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
|
|
469
477
|
/**
|
|
470
|
-
* Returns the
|
|
478
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
471
479
|
*
|
|
472
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
480
|
+
* @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.
|
|
473
481
|
*/
|
|
474
482
|
getSigilLabel(): string;
|
|
483
|
+
/**
|
|
484
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
485
|
+
*
|
|
486
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
487
|
+
*/
|
|
488
|
+
getSigilEffectiveLabel(): string;
|
|
475
489
|
/**
|
|
476
490
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
477
491
|
*
|
|
@@ -496,9 +510,13 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
496
510
|
Sigil: true;
|
|
497
511
|
} & { [K in L]: true; }>;
|
|
498
512
|
/**
|
|
499
|
-
* Class-level
|
|
513
|
+
* Class-level identity label constant for this sigil constructor.
|
|
500
514
|
*/
|
|
501
515
|
get SigilLabel(): string;
|
|
516
|
+
/**
|
|
517
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
518
|
+
*/
|
|
519
|
+
get SigilEffectiveLabel(): string;
|
|
502
520
|
/**
|
|
503
521
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
504
522
|
*
|
|
@@ -552,7 +570,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
552
570
|
* If not passed a random label is generated instead.
|
|
553
571
|
* @param opts - Options object to override any global options if needed.
|
|
554
572
|
* @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.
|
|
555
|
-
* @throws Error if `Base` is already
|
|
573
|
+
* @throws Error if `Base` is already sigilified.
|
|
556
574
|
*/
|
|
557
575
|
declare function SigilifyAbstract<B extends ConstructorAbstract, L extends string>(Base: B, label?: L, opts?: SigilOptions): ((abstract new (...args: any[]) => {
|
|
558
576
|
/**
|
|
@@ -588,11 +606,17 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
588
606
|
*/
|
|
589
607
|
isOfTypeStrict<T_1>(this: T_1, other: unknown): other is GetInstance<T_1>;
|
|
590
608
|
/**
|
|
591
|
-
* Returns the
|
|
609
|
+
* Returns the identity sigil label of this instance's constructor.
|
|
592
610
|
*
|
|
593
|
-
* @returns The label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown'
|
|
611
|
+
* @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.
|
|
594
612
|
*/
|
|
595
613
|
getSigilLabel(): string;
|
|
614
|
+
/**
|
|
615
|
+
* Returns the human-readable sigil label of this instance's constructor.
|
|
616
|
+
*
|
|
617
|
+
* @returns The last passed label string (e.g. '@scope/pkg.ClassName') or '@Sigil.unknown' if constructor is missing.
|
|
618
|
+
*/
|
|
619
|
+
getSigilEffectiveLabel(): string;
|
|
596
620
|
/**
|
|
597
621
|
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
598
622
|
*
|
|
@@ -617,9 +641,13 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
617
641
|
Sigil: true;
|
|
618
642
|
} & { [K in L]: true; }>;
|
|
619
643
|
/**
|
|
620
|
-
* Class-level
|
|
644
|
+
* Class-level identity label constant for this sigil constructor.
|
|
621
645
|
*/
|
|
622
646
|
get SigilLabel(): string;
|
|
647
|
+
/**
|
|
648
|
+
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
649
|
+
*/
|
|
650
|
+
get SigilEffectiveLabel(): string;
|
|
623
651
|
/**
|
|
624
652
|
* Copy of the linearized sigil type label chain for the current constructor.
|
|
625
653
|
*
|