@vicin/sigil 2.0.2 → 2.1.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 +14 -3
- package/README.md +9 -9
- package/dist/index.d.mts +5 -54
- package/dist/index.d.ts +5 -54
- package/dist/index.global.js +20 -10
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +20 -10
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +20 -10
- 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.1.0] - 2026-02-22
|
|
6
|
+
|
|
7
|
+
### Changed
|
|
8
|
+
|
|
9
|
+
- Changed name of `updateOptions` to be `updateSigilOptions`
|
|
10
|
+
- Updated JSDOCs of multiple APIs
|
|
11
|
+
|
|
12
|
+
## [2.0.3] - 2026-02-21
|
|
13
|
+
|
|
14
|
+
- Patched types
|
|
15
|
+
|
|
5
16
|
## [2.0.2] - 2026-02-21
|
|
6
17
|
|
|
7
18
|
### Changed
|
|
@@ -22,19 +33,19 @@ All notable changes to this project will be documented in this file.
|
|
|
22
33
|
|
|
23
34
|
### Breaking changes
|
|
24
35
|
|
|
25
|
-
- All `SigilRegistry`options, methods and classes are removed
|
|
36
|
+
- All `SigilRegistry`options, methods and classes are removed
|
|
26
37
|
|
|
27
38
|
## [1.3.0] - 2026-02-18
|
|
28
39
|
|
|
29
40
|
### Added
|
|
30
41
|
|
|
31
|
-
- `isOfType()` & `isOfTypeStrict()` now can be called from instances
|
|
42
|
+
- `isOfType()` & `isOfTypeStrict()` now can be called from instances
|
|
32
43
|
|
|
33
44
|
## [1.2.7] - 2026-02-13
|
|
34
45
|
|
|
35
46
|
### Added
|
|
36
47
|
|
|
37
|
-
- Support for `abstract` classes using `SigilifyAbstract` factory
|
|
48
|
+
- Support for `abstract` classes using `SigilifyAbstract` factory
|
|
38
49
|
|
|
39
50
|
## [1.2.6] - 2026-02-11
|
|
40
51
|
|
package/README.md
CHANGED
|
@@ -156,8 +156,8 @@ Migrating old code into `Sigil` can be done seamlessly with this set-up:
|
|
|
156
156
|
1. Set `SigilOptions.autofillLabels` to `true` at the start of the app so no errors are thrown in the migration stage:
|
|
157
157
|
|
|
158
158
|
```ts
|
|
159
|
-
import {
|
|
160
|
-
|
|
159
|
+
import { updateSigilOptions } from '@vicin/sigil';
|
|
160
|
+
updateSigilOptions({ autofillLabels: true });
|
|
161
161
|
```
|
|
162
162
|
|
|
163
163
|
2. Pass your base class to `Sigilify` mixin:
|
|
@@ -384,7 +384,7 @@ class X extends Sigil {
|
|
|
384
384
|
- `isInheritanceChecked(ctor)`
|
|
385
385
|
|
|
386
386
|
- **Options:**
|
|
387
|
-
- `
|
|
387
|
+
- `updateSigilOptions(opts)`
|
|
388
388
|
- `DEFAULT_LABEL_REGEX`
|
|
389
389
|
|
|
390
390
|
- **Types:**
|
|
@@ -407,7 +407,7 @@ class X extends Sigil {
|
|
|
407
407
|
- `withSigilTyped(Class, label?, opts?)`: like `withSigil` but narrows the TypeScript type to include brands.
|
|
408
408
|
- `isSigilCtor(value)`: `true` if `value` is a `Sigil` constructor.
|
|
409
409
|
- `isSigilInstance(value)`: `true` if `value` is an instance of a `Sigil` constructor.
|
|
410
|
-
- `
|
|
410
|
+
- `updateSigilOptions(opts)`: change global runtime options before `Sigil` decoration (e.g., `autofillLabels`).
|
|
411
411
|
- `DEFAULT_LABEL_REGEX`: regex that ensures structure of `@scope/package.ClassName` to all labels, it's advised to use it as your `SigilOptions.labelValidation`
|
|
412
412
|
|
|
413
413
|
### Instance & static helpers provided by Sigilified constructors
|
|
@@ -437,9 +437,9 @@ Instances of sigilified classes expose instance helpers:
|
|
|
437
437
|
Customize behavior globally at startup:
|
|
438
438
|
|
|
439
439
|
```ts
|
|
440
|
-
import {
|
|
440
|
+
import { updateSigilOptions } from '@vicin/sigil';
|
|
441
441
|
|
|
442
|
-
|
|
442
|
+
updateSigilOptions({
|
|
443
443
|
autofillLabels: false, // Automatically label unlabeled subclasses
|
|
444
444
|
skipLabelInheritanceCheck: false, // Bypass dev inheritance checks -- ALMOST NEVER WANT TO SET THIS TO TRUE, Use 'autofillLabels: true' instead.
|
|
445
445
|
labelValidation: null, // Function or regex, Enforce label format
|
|
@@ -452,13 +452,13 @@ Values defined in previous example are defaults, per-class overrides available i
|
|
|
452
452
|
|
|
453
453
|
## Minimal mode
|
|
454
454
|
|
|
455
|
-
`
|
|
455
|
+
`updateSigilOptions({ autofillLabels: true });` – Enables background operation without explicit labels:
|
|
456
456
|
|
|
457
457
|
```ts
|
|
458
|
-
import { Sigil,
|
|
458
|
+
import { Sigil, updateSigilOptions } from '@vicin/sigil';
|
|
459
459
|
|
|
460
460
|
// run at the start of the app
|
|
461
|
-
|
|
461
|
+
updateSigilOptions({ autofillLabels: true });
|
|
462
462
|
|
|
463
463
|
// No decorators or HOF needed to use 'isOfType' ('instanceof' replacement)
|
|
464
464
|
class A extends Sigil {}
|
package/dist/index.d.mts
CHANGED
|
@@ -93,8 +93,6 @@ interface ISigilInstance<L extends string = string, P extends Function = never>
|
|
|
93
93
|
} & SigilBrandOf<P>>;
|
|
94
94
|
/** Returns human-readable sigil label of the class constructor. */
|
|
95
95
|
getSigilLabel(): string;
|
|
96
|
-
/** Returns runtime sigil type label of the class constructor. */
|
|
97
|
-
getSigilType(): string;
|
|
98
96
|
/** Returns copy of sigil type label lineage of the class constructor. */
|
|
99
97
|
getSigilLabelLineage(): readonly string[];
|
|
100
98
|
/** Returns copy of sigil type label set of the class constructor. */
|
|
@@ -324,7 +322,7 @@ interface SigilOptions {
|
|
|
324
322
|
*
|
|
325
323
|
* @param opts - Partial options to merge into the global `OPTIONS` object.
|
|
326
324
|
*/
|
|
327
|
-
declare const
|
|
325
|
+
declare const updateSigilOptions: (opts: SigilOptions) => void;
|
|
328
326
|
/** -----------------------------------------
|
|
329
327
|
* Label validation
|
|
330
328
|
* ----------------------------------------- */
|
|
@@ -340,17 +338,6 @@ declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
|
340
338
|
/**
|
|
341
339
|
* Class decorator factory that attaches sigil statics to a class constructor.
|
|
342
340
|
*
|
|
343
|
-
* Usage:
|
|
344
|
-
* ```ts
|
|
345
|
-
* @WithSigil('@myorg/mypkg.MyClass')
|
|
346
|
-
* class MyClass { ... }
|
|
347
|
-
* ```
|
|
348
|
-
*
|
|
349
|
-
* The returned decorator:
|
|
350
|
-
* - validates the provided label (via `verifyLabel`)
|
|
351
|
-
* - performs inheritance checks (via `checkInheritance`) in DEV builds
|
|
352
|
-
* - attaches sigil-related statics to the constructor (via `decorateCtor`)
|
|
353
|
-
*
|
|
354
341
|
* Notes:
|
|
355
342
|
* - This decorator is intended to be applied to classes only. When used
|
|
356
343
|
* incorrectly (e.g. on a property), it is a no-op.
|
|
@@ -368,13 +355,6 @@ declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (v
|
|
|
368
355
|
* HOF (class inhancer) that attaches runtime sigil metadata to Sigil class.
|
|
369
356
|
* Alternative to '@WithSigil' if you prefer HOFs.
|
|
370
357
|
*
|
|
371
|
-
* This does both:
|
|
372
|
-
* - validate (and autofill) a label,
|
|
373
|
-
* - perform runtime decoration (via `decorateCtor`),
|
|
374
|
-
*
|
|
375
|
-
* The helper is idempotent: `decorateCtor` will register the label and throw if already
|
|
376
|
-
* decorated; we handle this gracefully in DEV to support HMR flows.
|
|
377
|
-
*
|
|
378
358
|
* @typeParam S - Constructor type (should be an ISigil).
|
|
379
359
|
* @typeParam L - Label literal to attach.
|
|
380
360
|
* @param Class - The constructor (class) to enhance.
|
|
@@ -384,15 +364,7 @@ declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (v
|
|
|
384
364
|
*/
|
|
385
365
|
declare function withSigil<S extends Function, L extends string = string>(Class: S, label?: L, opts?: SigilOptions): S;
|
|
386
366
|
/**
|
|
387
|
-
* Convenience helper that combine 'withSigil' and '
|
|
388
|
-
*
|
|
389
|
-
* This does both:
|
|
390
|
-
* - validate (and autofill) a label,
|
|
391
|
-
* - perform runtime decoration (via `decorateCtor`),
|
|
392
|
-
* - return the constructor typed as `TypedSigil`.
|
|
393
|
-
*
|
|
394
|
-
* The helper is idempotent: `decorateCtor` will register the label and throw if already
|
|
395
|
-
* decorated; we handle this gracefully in DEV to support HMR flows.
|
|
367
|
+
* Convenience helper that combine 'withSigil' and update 'SigilBrand'.
|
|
396
368
|
*
|
|
397
369
|
* @typeParam S - Constructor type (should be an ISigil).
|
|
398
370
|
* @typeParam L - Label literal to attach.
|
|
@@ -407,9 +379,6 @@ declare function withSigilTyped<S extends Function, L extends string = string>(C
|
|
|
407
379
|
/**
|
|
408
380
|
* Runtime predicate that checks whether the provided value is a sigil constructor.
|
|
409
381
|
*
|
|
410
|
-
* This is a lightweight check that verifies the presence of an internal
|
|
411
|
-
* symbol attached to the constructor.
|
|
412
|
-
*
|
|
413
382
|
* @param ctor - Constructor to test.
|
|
414
383
|
* @returns `true` if `value` is a sigil constructor, otherwise `false`.
|
|
415
384
|
*/
|
|
@@ -425,8 +394,6 @@ declare function isSigilInstance(inst: unknown): inst is GetInstance<ISigil>;
|
|
|
425
394
|
/**
|
|
426
395
|
* Check whether the provided constructor was marked as a sigil base constructor.
|
|
427
396
|
*
|
|
428
|
-
* Uses `Object.hasOwn` to ensure we only check own properties.
|
|
429
|
-
*
|
|
430
397
|
* @param ctor - Constructor to check.
|
|
431
398
|
* @returns `true` if `ctor` is a sigil base constructor.
|
|
432
399
|
*/
|
|
@@ -434,8 +401,6 @@ declare function isSigilBaseCtor(ctor: Function): ctor is ISigil;
|
|
|
434
401
|
/**
|
|
435
402
|
* Check whether the provided object is an instance of a sigil base constructor.
|
|
436
403
|
*
|
|
437
|
-
* This resolves the instance's constructor and delegates to `isSigilBaseCtor`.
|
|
438
|
-
*
|
|
439
404
|
* @param inst - The instance to test.
|
|
440
405
|
* @returns `true` if `inst` is an instance of a sigil base constructor.
|
|
441
406
|
*/
|
|
@@ -443,8 +408,6 @@ declare function isSigilBaseInstance(inst: unknown): inst is GetInstance<ISigil>
|
|
|
443
408
|
/**
|
|
444
409
|
* Returns whether the constructor has been explicitly decorated with `WithSigil`.
|
|
445
410
|
*
|
|
446
|
-
* This is an own-property check and does not traverse the prototype chain.
|
|
447
|
-
*
|
|
448
411
|
* @internal
|
|
449
412
|
* @param ctor - Constructor to test.
|
|
450
413
|
* @returns `true` if the constructor is explicitly decorated.
|
|
@@ -453,8 +416,6 @@ declare function isDecorated(ctor: Function): boolean;
|
|
|
453
416
|
/**
|
|
454
417
|
* Returns whether inheritance checks have already been performed for the constructor.
|
|
455
418
|
*
|
|
456
|
-
* This is used to avoid repeated checks during development (DEV-only checks).
|
|
457
|
-
*
|
|
458
419
|
* @internal
|
|
459
420
|
* @param ctor - Constructor to test.
|
|
460
421
|
* @returns `true` if inheritance checks were marked as completed.
|
|
@@ -462,12 +423,7 @@ declare function isDecorated(ctor: Function): boolean;
|
|
|
462
423
|
declare function isInheritanceChecked(ctor: Function): boolean;
|
|
463
424
|
|
|
464
425
|
/**
|
|
465
|
-
* Mixin factory that augments an existing class with Sigil runtime metadata and
|
|
466
|
-
* helpers.
|
|
467
|
-
*
|
|
468
|
-
* The returned class:
|
|
469
|
-
* - exposes static helpers such as `SigilLabel`, `SigilType`, `isOfType`, and `isOfTypeStrict`
|
|
470
|
-
* - exposes instance helpers such as `getSigilLabel`, `getSigilType`, etc.
|
|
426
|
+
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers.
|
|
471
427
|
*
|
|
472
428
|
* @param Base - The base constructor to extend.
|
|
473
429
|
* @param label - Optional identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').
|
|
@@ -589,12 +545,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
589
545
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
590
546
|
} & B;
|
|
591
547
|
/**
|
|
592
|
-
* Mixin factory that augments an existing class with Sigil runtime metadata and
|
|
593
|
-
* helpers. Accept and return 'abstract' class.
|
|
594
|
-
*
|
|
595
|
-
* The returned class:
|
|
596
|
-
* - exposes static helpers such as `SigilLabel`, `SigilType`, `isOfType`, and `isOfTypeStrict`
|
|
597
|
-
* - exposes instance helpers such as `getSigilLabel`, `getSigilType`, etc.
|
|
548
|
+
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers. Accept and return 'abstract' class.
|
|
598
549
|
*
|
|
599
550
|
* @param Base - The base constructor to extend.
|
|
600
551
|
* @param label - Optional identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').
|
|
@@ -723,4 +674,4 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
723
674
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
724
675
|
}) & B;
|
|
725
676
|
|
|
726
|
-
export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, type ISigilInstance, type ISigilStatic, Sigil, type SigilBrandOf, SigilError, type SigilOptions, Sigilify, SigilifyAbstract, type TypedSigil, type UpdateSigilBrand, WithSigil, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance,
|
|
677
|
+
export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, type ISigilInstance, type ISigilStatic, Sigil, type SigilBrandOf, SigilError, type SigilOptions, Sigilify, SigilifyAbstract, type TypedSigil, type UpdateSigilBrand, WithSigil, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, updateSigilOptions, withSigil, withSigilTyped };
|
package/dist/index.d.ts
CHANGED
|
@@ -93,8 +93,6 @@ interface ISigilInstance<L extends string = string, P extends Function = never>
|
|
|
93
93
|
} & SigilBrandOf<P>>;
|
|
94
94
|
/** Returns human-readable sigil label of the class constructor. */
|
|
95
95
|
getSigilLabel(): string;
|
|
96
|
-
/** Returns runtime sigil type label of the class constructor. */
|
|
97
|
-
getSigilType(): string;
|
|
98
96
|
/** Returns copy of sigil type label lineage of the class constructor. */
|
|
99
97
|
getSigilLabelLineage(): readonly string[];
|
|
100
98
|
/** Returns copy of sigil type label set of the class constructor. */
|
|
@@ -324,7 +322,7 @@ interface SigilOptions {
|
|
|
324
322
|
*
|
|
325
323
|
* @param opts - Partial options to merge into the global `OPTIONS` object.
|
|
326
324
|
*/
|
|
327
|
-
declare const
|
|
325
|
+
declare const updateSigilOptions: (opts: SigilOptions) => void;
|
|
328
326
|
/** -----------------------------------------
|
|
329
327
|
* Label validation
|
|
330
328
|
* ----------------------------------------- */
|
|
@@ -340,17 +338,6 @@ declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
|
340
338
|
/**
|
|
341
339
|
* Class decorator factory that attaches sigil statics to a class constructor.
|
|
342
340
|
*
|
|
343
|
-
* Usage:
|
|
344
|
-
* ```ts
|
|
345
|
-
* @WithSigil('@myorg/mypkg.MyClass')
|
|
346
|
-
* class MyClass { ... }
|
|
347
|
-
* ```
|
|
348
|
-
*
|
|
349
|
-
* The returned decorator:
|
|
350
|
-
* - validates the provided label (via `verifyLabel`)
|
|
351
|
-
* - performs inheritance checks (via `checkInheritance`) in DEV builds
|
|
352
|
-
* - attaches sigil-related statics to the constructor (via `decorateCtor`)
|
|
353
|
-
*
|
|
354
341
|
* Notes:
|
|
355
342
|
* - This decorator is intended to be applied to classes only. When used
|
|
356
343
|
* incorrectly (e.g. on a property), it is a no-op.
|
|
@@ -368,13 +355,6 @@ declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (v
|
|
|
368
355
|
* HOF (class inhancer) that attaches runtime sigil metadata to Sigil class.
|
|
369
356
|
* Alternative to '@WithSigil' if you prefer HOFs.
|
|
370
357
|
*
|
|
371
|
-
* This does both:
|
|
372
|
-
* - validate (and autofill) a label,
|
|
373
|
-
* - perform runtime decoration (via `decorateCtor`),
|
|
374
|
-
*
|
|
375
|
-
* The helper is idempotent: `decorateCtor` will register the label and throw if already
|
|
376
|
-
* decorated; we handle this gracefully in DEV to support HMR flows.
|
|
377
|
-
*
|
|
378
358
|
* @typeParam S - Constructor type (should be an ISigil).
|
|
379
359
|
* @typeParam L - Label literal to attach.
|
|
380
360
|
* @param Class - The constructor (class) to enhance.
|
|
@@ -384,15 +364,7 @@ declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (v
|
|
|
384
364
|
*/
|
|
385
365
|
declare function withSigil<S extends Function, L extends string = string>(Class: S, label?: L, opts?: SigilOptions): S;
|
|
386
366
|
/**
|
|
387
|
-
* Convenience helper that combine 'withSigil' and '
|
|
388
|
-
*
|
|
389
|
-
* This does both:
|
|
390
|
-
* - validate (and autofill) a label,
|
|
391
|
-
* - perform runtime decoration (via `decorateCtor`),
|
|
392
|
-
* - return the constructor typed as `TypedSigil`.
|
|
393
|
-
*
|
|
394
|
-
* The helper is idempotent: `decorateCtor` will register the label and throw if already
|
|
395
|
-
* decorated; we handle this gracefully in DEV to support HMR flows.
|
|
367
|
+
* Convenience helper that combine 'withSigil' and update 'SigilBrand'.
|
|
396
368
|
*
|
|
397
369
|
* @typeParam S - Constructor type (should be an ISigil).
|
|
398
370
|
* @typeParam L - Label literal to attach.
|
|
@@ -407,9 +379,6 @@ declare function withSigilTyped<S extends Function, L extends string = string>(C
|
|
|
407
379
|
/**
|
|
408
380
|
* Runtime predicate that checks whether the provided value is a sigil constructor.
|
|
409
381
|
*
|
|
410
|
-
* This is a lightweight check that verifies the presence of an internal
|
|
411
|
-
* symbol attached to the constructor.
|
|
412
|
-
*
|
|
413
382
|
* @param ctor - Constructor to test.
|
|
414
383
|
* @returns `true` if `value` is a sigil constructor, otherwise `false`.
|
|
415
384
|
*/
|
|
@@ -425,8 +394,6 @@ declare function isSigilInstance(inst: unknown): inst is GetInstance<ISigil>;
|
|
|
425
394
|
/**
|
|
426
395
|
* Check whether the provided constructor was marked as a sigil base constructor.
|
|
427
396
|
*
|
|
428
|
-
* Uses `Object.hasOwn` to ensure we only check own properties.
|
|
429
|
-
*
|
|
430
397
|
* @param ctor - Constructor to check.
|
|
431
398
|
* @returns `true` if `ctor` is a sigil base constructor.
|
|
432
399
|
*/
|
|
@@ -434,8 +401,6 @@ declare function isSigilBaseCtor(ctor: Function): ctor is ISigil;
|
|
|
434
401
|
/**
|
|
435
402
|
* Check whether the provided object is an instance of a sigil base constructor.
|
|
436
403
|
*
|
|
437
|
-
* This resolves the instance's constructor and delegates to `isSigilBaseCtor`.
|
|
438
|
-
*
|
|
439
404
|
* @param inst - The instance to test.
|
|
440
405
|
* @returns `true` if `inst` is an instance of a sigil base constructor.
|
|
441
406
|
*/
|
|
@@ -443,8 +408,6 @@ declare function isSigilBaseInstance(inst: unknown): inst is GetInstance<ISigil>
|
|
|
443
408
|
/**
|
|
444
409
|
* Returns whether the constructor has been explicitly decorated with `WithSigil`.
|
|
445
410
|
*
|
|
446
|
-
* This is an own-property check and does not traverse the prototype chain.
|
|
447
|
-
*
|
|
448
411
|
* @internal
|
|
449
412
|
* @param ctor - Constructor to test.
|
|
450
413
|
* @returns `true` if the constructor is explicitly decorated.
|
|
@@ -453,8 +416,6 @@ declare function isDecorated(ctor: Function): boolean;
|
|
|
453
416
|
/**
|
|
454
417
|
* Returns whether inheritance checks have already been performed for the constructor.
|
|
455
418
|
*
|
|
456
|
-
* This is used to avoid repeated checks during development (DEV-only checks).
|
|
457
|
-
*
|
|
458
419
|
* @internal
|
|
459
420
|
* @param ctor - Constructor to test.
|
|
460
421
|
* @returns `true` if inheritance checks were marked as completed.
|
|
@@ -462,12 +423,7 @@ declare function isDecorated(ctor: Function): boolean;
|
|
|
462
423
|
declare function isInheritanceChecked(ctor: Function): boolean;
|
|
463
424
|
|
|
464
425
|
/**
|
|
465
|
-
* Mixin factory that augments an existing class with Sigil runtime metadata and
|
|
466
|
-
* helpers.
|
|
467
|
-
*
|
|
468
|
-
* The returned class:
|
|
469
|
-
* - exposes static helpers such as `SigilLabel`, `SigilType`, `isOfType`, and `isOfTypeStrict`
|
|
470
|
-
* - exposes instance helpers such as `getSigilLabel`, `getSigilType`, etc.
|
|
426
|
+
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers.
|
|
471
427
|
*
|
|
472
428
|
* @param Base - The base constructor to extend.
|
|
473
429
|
* @param label - Optional identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').
|
|
@@ -589,12 +545,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
589
545
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
590
546
|
} & B;
|
|
591
547
|
/**
|
|
592
|
-
* Mixin factory that augments an existing class with Sigil runtime metadata and
|
|
593
|
-
* helpers. Accept and return 'abstract' class.
|
|
594
|
-
*
|
|
595
|
-
* The returned class:
|
|
596
|
-
* - exposes static helpers such as `SigilLabel`, `SigilType`, `isOfType`, and `isOfTypeStrict`
|
|
597
|
-
* - exposes instance helpers such as `getSigilLabel`, `getSigilType`, etc.
|
|
548
|
+
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers. Accept and return 'abstract' class.
|
|
598
549
|
*
|
|
599
550
|
* @param Base - The base constructor to extend.
|
|
600
551
|
* @param label - Optional identity label to attach to the resulting class (e.g. '@scope/pkg.ClassName').
|
|
@@ -723,4 +674,4 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
723
674
|
isOfTypeStrict<T>(this: T, other: unknown): other is GetInstance<T>;
|
|
724
675
|
}) & B;
|
|
725
676
|
|
|
726
|
-
export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, type ISigilInstance, type ISigilStatic, Sigil, type SigilBrandOf, SigilError, type SigilOptions, Sigilify, SigilifyAbstract, type TypedSigil, type UpdateSigilBrand, WithSigil, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance,
|
|
677
|
+
export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, type ISigilInstance, type ISigilStatic, Sigil, type SigilBrandOf, SigilError, type SigilOptions, Sigilify, SigilifyAbstract, type TypedSigil, type UpdateSigilBrand, WithSigil, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, updateSigilOptions, withSigil, withSigilTyped };
|
package/dist/index.global.js
CHANGED
|
@@ -11,15 +11,25 @@
|
|
|
11
11
|
skipLabelInheritanceCheck: false,
|
|
12
12
|
autofillLabels: false
|
|
13
13
|
};
|
|
14
|
-
var
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
var updateSigilOptions = (opts) => {
|
|
15
|
+
if (opts.autofillLabels) {
|
|
16
|
+
if (typeof opts.autofillLabels !== "boolean")
|
|
17
|
+
throw new Error("'updateSigilOptions.autofillLabels' must be boolean");
|
|
18
|
+
OPTIONS.autofillLabels = opts.autofillLabels;
|
|
19
|
+
}
|
|
20
|
+
if (opts.skipLabelInheritanceCheck) {
|
|
21
|
+
if (typeof opts.skipLabelInheritanceCheck !== "boolean")
|
|
22
|
+
throw new Error("'updateSigilOptions.skipLabelInheritanceCheck' must be boolean");
|
|
23
|
+
OPTIONS.skipLabelInheritanceCheck = opts.skipLabelInheritanceCheck;
|
|
24
|
+
}
|
|
25
|
+
if (opts.labelValidation) {
|
|
26
|
+
if (opts.labelValidation !== null && typeof opts.labelValidation !== "function" && !(opts.labelValidation instanceof RegExp))
|
|
27
|
+
throw new Error(
|
|
28
|
+
"'updateSigilOptions.labelValidation' must be null, function or regex expression"
|
|
29
|
+
);
|
|
30
|
+
OPTIONS.labelValidation = opts.labelValidation;
|
|
31
|
+
}
|
|
21
32
|
};
|
|
22
|
-
updateOptions(DEFAULT_OPTIONS);
|
|
23
33
|
var DEFAULT_LABEL_REGEX = /^@[\w-]+(?:\/[\w-]+)*\.[A-Z][A-Za-z0-9]*$/;
|
|
24
34
|
|
|
25
35
|
// src/core/symbols.ts
|
|
@@ -2257,7 +2267,7 @@
|
|
|
2257
2267
|
};
|
|
2258
2268
|
}
|
|
2259
2269
|
|
|
2260
|
-
// src/core/
|
|
2270
|
+
// src/core/hof.ts
|
|
2261
2271
|
function withSigil(Class, label, opts) {
|
|
2262
2272
|
var _a;
|
|
2263
2273
|
if (!isSigilCtor(Class))
|
|
@@ -2308,7 +2318,7 @@
|
|
|
2308
2318
|
exports.isSigilBaseInstance = isSigilBaseInstance;
|
|
2309
2319
|
exports.isSigilCtor = isSigilCtor;
|
|
2310
2320
|
exports.isSigilInstance = isSigilInstance;
|
|
2311
|
-
exports.
|
|
2321
|
+
exports.updateSigilOptions = updateSigilOptions;
|
|
2312
2322
|
exports.withSigil = withSigil;
|
|
2313
2323
|
exports.withSigilTyped = withSigilTyped;
|
|
2314
2324
|
|