@vicin/sigil 1.1.0 → 1.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/dist/index.d.mts CHANGED
@@ -304,9 +304,9 @@ interface SigilOptions {
304
304
  * predicates implemented by the `Sigilify` mixin.
305
305
  *
306
306
  * @template L - Narrow string literal type representing the label.
307
- * @template US - Optinal original Untyped Sigil constructor type being augmented.
307
+ * @template P - Optinal parent to extend its '__SIGIL_BRAND__'.
308
308
  */
309
- interface ISigilStatic<L extends string = string, US extends Function = never> {
309
+ interface ISigilStatic<L extends string = string, P extends Function = never> {
310
310
  /**
311
311
  * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
312
312
  *
@@ -320,7 +320,7 @@ interface ISigilStatic<L extends string = string, US extends Function = never> {
320
320
  */
321
321
  readonly __SIGIL_BRAND__: Prettify<{
322
322
  [k in L]: true;
323
- } & SigilBrandOf<US>>;
323
+ } & SigilBrandOf<P>>;
324
324
  /** Class-level label constant (human readable). */
325
325
  readonly SigilLabel: string;
326
326
  /** Class-level unique symbol used as the runtime type identifier. */
@@ -379,9 +379,9 @@ interface ISigilStatic<L extends string = string, US extends Function = never> {
379
379
  * The methods mirror the instance helpers injected by the mixin.
380
380
  *
381
381
  * @template L - Narrow string literal type for the label returned by `getSigilLabel`.
382
- * @template US - Optinal original Untyped Sigil constructor type being augmented.
382
+ * @template P - Optinal parent to extend its '__SIGIL_BRAND__'.
383
383
  */
384
- interface ISigilInstance<L extends string = string, US extends Function = never> {
384
+ interface ISigilInstance<L extends string = string, P extends Function = never> {
385
385
  /**
386
386
  * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
387
387
  *
@@ -395,7 +395,7 @@ interface ISigilInstance<L extends string = string, US extends Function = never>
395
395
  */
396
396
  readonly __SIGIL_BRAND__: Prettify<{
397
397
  [k in L]: true;
398
- } & SigilBrandOf<US>>;
398
+ } & SigilBrandOf<P>>;
399
399
  /** Returns human-readable sigil label of the class constructor. */
400
400
  getSigilLabel(): string;
401
401
  /** Returns runtime sigil type symbol of the class constructor. */
@@ -413,46 +413,59 @@ interface ISigilInstance<L extends string = string, US extends Function = never>
413
413
  * by `Sigilify`.
414
414
  *
415
415
  * @template L - Narrow string literal type for the label.
416
- * @template US - Optinal original Untyped Sigil constructor type being augmented.
416
+ * @template P - Optinal parent to extend its '__SIGIL_BRAND__'.
417
417
  */
418
- type ISigil<L extends string = string, US extends Function = never> = Constructor<ISigilInstance<L, US>> & ISigilStatic<L, US>;
418
+ type ISigil<L extends string = string, P extends Function = never> = Constructor<ISigilInstance<L, P>> & ISigilStatic<L, P>;
419
419
  /** -----------------------------------------
420
- * Helper sigil types
420
+ * HOF pattern types
421
421
  * ----------------------------------------- */
422
- /**
423
- * Extract the compile-time brand map from a sigil constructor `S`.
424
- *
425
- * @typeParam S - A sigil constructor type (e.g. `typeof SomeSigilClass`).
426
- * @returns The brand record carried on the constructor's instance type (e.g. `{ User: true, Admin: true }`).
427
- *
428
- * @remarks
429
- * - This helper is used purely at the type level to compute the set of brand keys
430
- * that should be propagated to derived sigils.
431
- * - If `S` does not carry a `__SIGIL_BRAND__`, the resulting type is `never` and `IfNever<>`
432
- * collapses it to an empty record.
433
- */
434
- type SigilBrandOf<S> = IfNever<S extends {
435
- readonly __SIGIL_BRAND__: infer Brand;
436
- } ? Prettify<Brand> : never, Record<string, true>>;
437
422
  /**
438
423
  * Combine an existing sigil constructor type `S` with a **new** label `L`,
439
424
  * while inheriting/propagating compile-time brands from an optional parent sigil `P`.
440
425
  *
441
- * @template US - The original Untyped Sigil constructor type being augmented.
426
+ * @template S - The original Untyped Sigil constructor type being augmented.
442
427
  * @template L - The new label literal to associate with the resulting constructor.
443
428
  */
444
- type TypedSigil<US extends Function, L extends string = string> = US & ISigil<L, US>;
429
+ type TypedSigil<S extends Function, L extends string = string> = S & AppendLabel<L> & Constructor<AppendLabel<L>>;
445
430
  /**
446
431
  * Generic helper extract instance of the class even in protected and private constructors.
447
432
  */
448
433
  type GetInstance<T> = T extends {
449
434
  prototype: infer R;
450
- } ? Prettify<R & {
435
+ } ? PrettifyBrand<R & {
451
436
  __SIGIL_BRAND__: SigilBrandOf<T>;
452
437
  }> : never;
438
+ /** Helper to append label into a class. */
439
+ type AppendLabel<L extends string> = {
440
+ readonly __SIGIL_BRAND__: Prettify<{
441
+ [K in L]: true;
442
+ }>;
443
+ };
444
+ /** -----------------------------------------
445
+ * Manual pattern types
446
+ * ----------------------------------------- */
447
+ /** Update '__SIGIL_BRAND__' field when manual typing is used. */
448
+ type UpdateSigilBrand<L extends string, P extends ISigilInstance> = Prettify<SigilBrandOf<P> & {
449
+ [K in L]: true;
450
+ }>;
453
451
  /** -----------------------------------------
454
452
  * Generic types
455
453
  * ----------------------------------------- */
454
+ /**
455
+ * Extract the compile-time brand map from a sigil constructor `S`.
456
+ *
457
+ * @typeParam S - A sigil constructor type (e.g. `typeof SomeSigilClass`).
458
+ * @returns The brand record carried on the constructor's instance type (e.g. `{ User: true, Admin: true }`).
459
+ *
460
+ * @remarks
461
+ * - This helper is used purely at the type level to compute the set of brand keys
462
+ * that should be propagated to derived sigils.
463
+ * - If `S` does not carry a `__SIGIL_BRAND__`, the resulting type is `never` and `IfNever<>`
464
+ * collapses it to an empty record.
465
+ */
466
+ type SigilBrandOf<S> = IfNever<S extends {
467
+ readonly __SIGIL_BRAND__: infer Brand;
468
+ } ? Brand : never, Record<string, true>>;
456
469
  /**
457
470
  * Generic type for class constructors used by the Sigil utilities.
458
471
  *
@@ -463,10 +476,14 @@ type GetInstance<T> = T extends {
463
476
  * @template P - Parameter tuple type for the constructor.
464
477
  */
465
478
  type Constructor<T = object, P extends any[] = any[]> = new (...args: P) => T;
466
- /** Helper type to prettify value. */
479
+ /** Helper type to prettify value */
467
480
  type Prettify<T> = {
468
481
  [K in keyof T]: T[K];
469
482
  } & {};
483
+ /** Helper type to prettify value, handles nested '__SIGIL_BRAND__' field */
484
+ type PrettifyBrand<T> = {
485
+ [K in keyof T]: K extends '__SIGIL_BRAND__' ? PrettifyBrand<T[K]> : T[K];
486
+ } & {};
470
487
  /** Helper type to replace 'never' with another type */
471
488
  type IfNever<T, R = {}> = [T] extends [never] ? R : T;
472
489
 
@@ -478,13 +495,17 @@ type IfNever<T, R = {}> = [T] extends [never] ? R : T;
478
495
  */
479
496
  declare const Sigil: {
480
497
  new (...args: any[]): {
481
- readonly __SIGIL_BRAND__: Record<string, true>;
498
+ readonly __SIGIL_BRAND__: {
499
+ Sigil: true;
500
+ };
482
501
  getSigilLabel(): string;
483
502
  getSigilType(): symbol;
484
503
  getSigilTypeLineage(): readonly symbol[];
485
504
  getSigilTypeSet(): Readonly<Set<symbol>>;
486
505
  };
487
- readonly __SIGIL_BRAND__: Record<string, true>;
506
+ readonly __SIGIL_BRAND__: {
507
+ Sigil: true;
508
+ };
488
509
  get SigilLabel(): string;
489
510
  get SigilType(): symbol;
490
511
  get SigilTypeLineage(): readonly symbol[];
@@ -492,7 +513,10 @@ declare const Sigil: {
492
513
  isSigilified(obj: unknown): obj is ISigil;
493
514
  isOfType<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
494
515
  isOfTypeStrict<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
516
+ } & {
517
+ new (): {};
495
518
  };
519
+ type Sigil = InstanceType<typeof Sigil>;
496
520
  /**
497
521
  * A sigil variant of the built-in `Error` constructor used by the library
498
522
  * to represent Sigil-specific errors.
@@ -502,13 +526,19 @@ declare const Sigil: {
502
526
  */
503
527
  declare const SigilError: {
504
528
  new (...args: any[]): {
505
- readonly __SIGIL_BRAND__: Record<string, true>;
529
+ readonly __SIGIL_BRAND__: {
530
+ Sigil: true;
531
+ SigilError: true;
532
+ };
506
533
  getSigilLabel(): string;
507
534
  getSigilType(): symbol;
508
535
  getSigilTypeLineage(): readonly symbol[];
509
536
  getSigilTypeSet(): Readonly<Set<symbol>>;
510
537
  };
511
- readonly __SIGIL_BRAND__: Record<string, true>;
538
+ readonly __SIGIL_BRAND__: {
539
+ Sigil: true;
540
+ SigilError: true;
541
+ };
512
542
  get SigilLabel(): string;
513
543
  get SigilType(): symbol;
514
544
  get SigilTypeLineage(): readonly symbol[];
@@ -516,7 +546,8 @@ declare const SigilError: {
516
546
  isSigilified(obj: unknown): obj is ISigil;
517
547
  isOfType<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
518
548
  isOfTypeStrict<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
519
- };
549
+ } & ErrorConstructor;
550
+ type SigilError = InstanceType<typeof SigilError>;
520
551
 
521
552
  /**
522
553
  * Class decorator factory that attaches sigil statics to a class constructor.
@@ -543,7 +574,7 @@ declare const SigilError: {
543
574
  * @param opts - Options object to override any global options if needed.
544
575
  * @returns A class decorator compatible with the ECMAScript decorator context.
545
576
  */
546
- declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (value: Function, context: ClassDecoratorContext) => void;
577
+ declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (value: Function, context: any) => void;
547
578
 
548
579
  /**
549
580
  * HOF (class inhancer) that attaches runtime sigil metadata to Sigil class.
@@ -573,6 +604,7 @@ declare function withSigil<S extends Function, L extends string = string>(Class:
573
604
  * Use this when the runtime metadata is already present (for example the class
574
605
  * is already decorated or was created via `Sigilify`).
575
606
  *
607
+ * @deprecated
576
608
  * @typeParam S - Constructor type (should be an ISigil).
577
609
  * @typeParam L - Label literal to associate at compile-time.
578
610
  * @param Class - The constructor to assert as typed sigil.
@@ -607,10 +639,10 @@ declare function withSigilTyped<S extends Function, L extends string = string>(C
607
639
  * This is a lightweight check that verifies the presence of an internal
608
640
  * symbol attached to the constructor.
609
641
  *
610
- * @param value - Value to test.
642
+ * @param ctor - Constructor to test.
611
643
  * @returns `true` if `value` is a sigil constructor, otherwise `false`.
612
644
  */
613
- declare function isSigilCtor(value: unknown): value is ISigil;
645
+ declare function isSigilCtor(ctor: unknown): ctor is ISigil;
614
646
  /**
615
647
  * Runtime predicate that checks whether the provided object is an instance
616
648
  * of a sigil class.
@@ -621,7 +653,7 @@ declare function isSigilCtor(value: unknown): value is ISigil;
621
653
  * @param obj - The value to test.
622
654
  * @returns `true` if `obj` is an instance produced by a sigil constructor.
623
655
  */
624
- declare function isSigilInstance(obj: unknown): obj is ISigilInstance;
656
+ declare function isSigilInstance(obj: unknown): obj is InstanceType<ISigil>;
625
657
  /**
626
658
  * Check whether the provided constructor was marked as a sigil base constructor.
627
659
  *
@@ -630,7 +662,7 @@ declare function isSigilInstance(obj: unknown): obj is ISigilInstance;
630
662
  * @param ctor - Constructor to check.
631
663
  * @returns `true` if `ctor` is a sigil base constructor.
632
664
  */
633
- declare function isSigilBaseCtor(ctor: Function): boolean;
665
+ declare function isSigilBaseCtor(ctor: Function): ctor is ISigil;
634
666
  /**
635
667
  * Check whether the provided object is an instance of a sigil base constructor.
636
668
  *
@@ -639,7 +671,7 @@ declare function isSigilBaseCtor(ctor: Function): boolean;
639
671
  * @param obj - The object to test.
640
672
  * @returns `true` if `obj` is an instance of a sigil base constructor.
641
673
  */
642
- declare function isSigilBaseInstance(obj: unknown): obj is ISigilInstance;
674
+ declare function isSigilBaseInstance(obj: unknown): obj is InstanceType<ISigil>;
643
675
  /**
644
676
  * Returns whether the constructor has been explicitly decorated with `WithSigil`.
645
677
  *
@@ -680,9 +712,22 @@ declare function isInheritanceChecked(ctor: Function): boolean;
680
712
  * @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.
681
713
  * @throws Error if `Base` is already sigilized.
682
714
  */
683
- declare function Sigilify(Base: Constructor, label?: string, opts?: SigilOptions): {
715
+ declare function Sigilify<B extends Constructor, L extends string>(Base: B, label?: L, opts?: SigilOptions): {
684
716
  new (...args: any[]): {
685
- readonly __SIGIL_BRAND__: Record<string, true>;
717
+ /**
718
+ * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
719
+ *
720
+ * - Provides a *type-only* unique marker that makes instances nominally
721
+ * distinct by label and allows propagation/merging of brand keys across inheritance.
722
+ * - Runtime: **no runtime value is required**; this property exists only for the type system.
723
+ *
724
+ * @remarks
725
+ * Consumers should not read or set this property at runtime. It is used by helper
726
+ * types (e.g. `SigilBrandOf`, `TypedSigil`) to extract/propagate compile-time brands.
727
+ */
728
+ readonly __SIGIL_BRAND__: {
729
+ Sigil: true;
730
+ } & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
686
731
  /**
687
732
  * Returns the human-readable sigil label of this instance's constructor.
688
733
  *
@@ -708,7 +753,20 @@ declare function Sigilify(Base: Constructor, label?: string, opts?: SigilOptions
708
753
  */
709
754
  getSigilTypeSet(): Readonly<Set<symbol>>;
710
755
  };
711
- readonly __SIGIL_BRAND__: Record<string, true>;
756
+ /**
757
+ * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
758
+ *
759
+ * - Provides a *type-only* unique marker that makes instances nominally
760
+ * distinct by label and allows propagation/merging of brand keys across inheritance.
761
+ * - Runtime: **no runtime value is required**; this property exists only for the type system.
762
+ *
763
+ * @remarks
764
+ * Consumers should not read or set this property at runtime. It is used by helper
765
+ * types (e.g. `SigilBrandOf`, `TypedSigil`) to extract/propagate compile-time brands.
766
+ */
767
+ readonly __SIGIL_BRAND__: Prettify<{
768
+ Sigil: true;
769
+ } & { [K in L]: true; }>;
712
770
  /**
713
771
  * Class-level human-readable label constant for this sigil constructor.
714
772
  */
@@ -772,6 +830,6 @@ declare function Sigilify(Base: Constructor, label?: string, opts?: SigilOptions
772
830
  * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
773
831
  */
774
832
  isOfTypeStrict<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
775
- };
833
+ } & B;
776
834
 
777
- export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, type ISigilInstance, type ISigilStatic, REGISTRY, Sigil, type SigilBrandOf, SigilError, type SigilOptions, SigilRegistry, Sigilify, type TypedSigil, WithSigil, getActiveRegistry, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, typed, updateOptions, withSigil, withSigilTyped };
835
+ export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, REGISTRY, Sigil, type SigilBrandOf, SigilError, type SigilOptions, SigilRegistry, Sigilify, type TypedSigil, type UpdateSigilBrand, WithSigil, getActiveRegistry, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, typed, updateOptions, withSigil, withSigilTyped };
package/dist/index.d.ts CHANGED
@@ -304,9 +304,9 @@ interface SigilOptions {
304
304
  * predicates implemented by the `Sigilify` mixin.
305
305
  *
306
306
  * @template L - Narrow string literal type representing the label.
307
- * @template US - Optinal original Untyped Sigil constructor type being augmented.
307
+ * @template P - Optinal parent to extend its '__SIGIL_BRAND__'.
308
308
  */
309
- interface ISigilStatic<L extends string = string, US extends Function = never> {
309
+ interface ISigilStatic<L extends string = string, P extends Function = never> {
310
310
  /**
311
311
  * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
312
312
  *
@@ -320,7 +320,7 @@ interface ISigilStatic<L extends string = string, US extends Function = never> {
320
320
  */
321
321
  readonly __SIGIL_BRAND__: Prettify<{
322
322
  [k in L]: true;
323
- } & SigilBrandOf<US>>;
323
+ } & SigilBrandOf<P>>;
324
324
  /** Class-level label constant (human readable). */
325
325
  readonly SigilLabel: string;
326
326
  /** Class-level unique symbol used as the runtime type identifier. */
@@ -379,9 +379,9 @@ interface ISigilStatic<L extends string = string, US extends Function = never> {
379
379
  * The methods mirror the instance helpers injected by the mixin.
380
380
  *
381
381
  * @template L - Narrow string literal type for the label returned by `getSigilLabel`.
382
- * @template US - Optinal original Untyped Sigil constructor type being augmented.
382
+ * @template P - Optinal parent to extend its '__SIGIL_BRAND__'.
383
383
  */
384
- interface ISigilInstance<L extends string = string, US extends Function = never> {
384
+ interface ISigilInstance<L extends string = string, P extends Function = never> {
385
385
  /**
386
386
  * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
387
387
  *
@@ -395,7 +395,7 @@ interface ISigilInstance<L extends string = string, US extends Function = never>
395
395
  */
396
396
  readonly __SIGIL_BRAND__: Prettify<{
397
397
  [k in L]: true;
398
- } & SigilBrandOf<US>>;
398
+ } & SigilBrandOf<P>>;
399
399
  /** Returns human-readable sigil label of the class constructor. */
400
400
  getSigilLabel(): string;
401
401
  /** Returns runtime sigil type symbol of the class constructor. */
@@ -413,46 +413,59 @@ interface ISigilInstance<L extends string = string, US extends Function = never>
413
413
  * by `Sigilify`.
414
414
  *
415
415
  * @template L - Narrow string literal type for the label.
416
- * @template US - Optinal original Untyped Sigil constructor type being augmented.
416
+ * @template P - Optinal parent to extend its '__SIGIL_BRAND__'.
417
417
  */
418
- type ISigil<L extends string = string, US extends Function = never> = Constructor<ISigilInstance<L, US>> & ISigilStatic<L, US>;
418
+ type ISigil<L extends string = string, P extends Function = never> = Constructor<ISigilInstance<L, P>> & ISigilStatic<L, P>;
419
419
  /** -----------------------------------------
420
- * Helper sigil types
420
+ * HOF pattern types
421
421
  * ----------------------------------------- */
422
- /**
423
- * Extract the compile-time brand map from a sigil constructor `S`.
424
- *
425
- * @typeParam S - A sigil constructor type (e.g. `typeof SomeSigilClass`).
426
- * @returns The brand record carried on the constructor's instance type (e.g. `{ User: true, Admin: true }`).
427
- *
428
- * @remarks
429
- * - This helper is used purely at the type level to compute the set of brand keys
430
- * that should be propagated to derived sigils.
431
- * - If `S` does not carry a `__SIGIL_BRAND__`, the resulting type is `never` and `IfNever<>`
432
- * collapses it to an empty record.
433
- */
434
- type SigilBrandOf<S> = IfNever<S extends {
435
- readonly __SIGIL_BRAND__: infer Brand;
436
- } ? Prettify<Brand> : never, Record<string, true>>;
437
422
  /**
438
423
  * Combine an existing sigil constructor type `S` with a **new** label `L`,
439
424
  * while inheriting/propagating compile-time brands from an optional parent sigil `P`.
440
425
  *
441
- * @template US - The original Untyped Sigil constructor type being augmented.
426
+ * @template S - The original Untyped Sigil constructor type being augmented.
442
427
  * @template L - The new label literal to associate with the resulting constructor.
443
428
  */
444
- type TypedSigil<US extends Function, L extends string = string> = US & ISigil<L, US>;
429
+ type TypedSigil<S extends Function, L extends string = string> = S & AppendLabel<L> & Constructor<AppendLabel<L>>;
445
430
  /**
446
431
  * Generic helper extract instance of the class even in protected and private constructors.
447
432
  */
448
433
  type GetInstance<T> = T extends {
449
434
  prototype: infer R;
450
- } ? Prettify<R & {
435
+ } ? PrettifyBrand<R & {
451
436
  __SIGIL_BRAND__: SigilBrandOf<T>;
452
437
  }> : never;
438
+ /** Helper to append label into a class. */
439
+ type AppendLabel<L extends string> = {
440
+ readonly __SIGIL_BRAND__: Prettify<{
441
+ [K in L]: true;
442
+ }>;
443
+ };
444
+ /** -----------------------------------------
445
+ * Manual pattern types
446
+ * ----------------------------------------- */
447
+ /** Update '__SIGIL_BRAND__' field when manual typing is used. */
448
+ type UpdateSigilBrand<L extends string, P extends ISigilInstance> = Prettify<SigilBrandOf<P> & {
449
+ [K in L]: true;
450
+ }>;
453
451
  /** -----------------------------------------
454
452
  * Generic types
455
453
  * ----------------------------------------- */
454
+ /**
455
+ * Extract the compile-time brand map from a sigil constructor `S`.
456
+ *
457
+ * @typeParam S - A sigil constructor type (e.g. `typeof SomeSigilClass`).
458
+ * @returns The brand record carried on the constructor's instance type (e.g. `{ User: true, Admin: true }`).
459
+ *
460
+ * @remarks
461
+ * - This helper is used purely at the type level to compute the set of brand keys
462
+ * that should be propagated to derived sigils.
463
+ * - If `S` does not carry a `__SIGIL_BRAND__`, the resulting type is `never` and `IfNever<>`
464
+ * collapses it to an empty record.
465
+ */
466
+ type SigilBrandOf<S> = IfNever<S extends {
467
+ readonly __SIGIL_BRAND__: infer Brand;
468
+ } ? Brand : never, Record<string, true>>;
456
469
  /**
457
470
  * Generic type for class constructors used by the Sigil utilities.
458
471
  *
@@ -463,10 +476,14 @@ type GetInstance<T> = T extends {
463
476
  * @template P - Parameter tuple type for the constructor.
464
477
  */
465
478
  type Constructor<T = object, P extends any[] = any[]> = new (...args: P) => T;
466
- /** Helper type to prettify value. */
479
+ /** Helper type to prettify value */
467
480
  type Prettify<T> = {
468
481
  [K in keyof T]: T[K];
469
482
  } & {};
483
+ /** Helper type to prettify value, handles nested '__SIGIL_BRAND__' field */
484
+ type PrettifyBrand<T> = {
485
+ [K in keyof T]: K extends '__SIGIL_BRAND__' ? PrettifyBrand<T[K]> : T[K];
486
+ } & {};
470
487
  /** Helper type to replace 'never' with another type */
471
488
  type IfNever<T, R = {}> = [T] extends [never] ? R : T;
472
489
 
@@ -478,13 +495,17 @@ type IfNever<T, R = {}> = [T] extends [never] ? R : T;
478
495
  */
479
496
  declare const Sigil: {
480
497
  new (...args: any[]): {
481
- readonly __SIGIL_BRAND__: Record<string, true>;
498
+ readonly __SIGIL_BRAND__: {
499
+ Sigil: true;
500
+ };
482
501
  getSigilLabel(): string;
483
502
  getSigilType(): symbol;
484
503
  getSigilTypeLineage(): readonly symbol[];
485
504
  getSigilTypeSet(): Readonly<Set<symbol>>;
486
505
  };
487
- readonly __SIGIL_BRAND__: Record<string, true>;
506
+ readonly __SIGIL_BRAND__: {
507
+ Sigil: true;
508
+ };
488
509
  get SigilLabel(): string;
489
510
  get SigilType(): symbol;
490
511
  get SigilTypeLineage(): readonly symbol[];
@@ -492,7 +513,10 @@ declare const Sigil: {
492
513
  isSigilified(obj: unknown): obj is ISigil;
493
514
  isOfType<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
494
515
  isOfTypeStrict<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
516
+ } & {
517
+ new (): {};
495
518
  };
519
+ type Sigil = InstanceType<typeof Sigil>;
496
520
  /**
497
521
  * A sigil variant of the built-in `Error` constructor used by the library
498
522
  * to represent Sigil-specific errors.
@@ -502,13 +526,19 @@ declare const Sigil: {
502
526
  */
503
527
  declare const SigilError: {
504
528
  new (...args: any[]): {
505
- readonly __SIGIL_BRAND__: Record<string, true>;
529
+ readonly __SIGIL_BRAND__: {
530
+ Sigil: true;
531
+ SigilError: true;
532
+ };
506
533
  getSigilLabel(): string;
507
534
  getSigilType(): symbol;
508
535
  getSigilTypeLineage(): readonly symbol[];
509
536
  getSigilTypeSet(): Readonly<Set<symbol>>;
510
537
  };
511
- readonly __SIGIL_BRAND__: Record<string, true>;
538
+ readonly __SIGIL_BRAND__: {
539
+ Sigil: true;
540
+ SigilError: true;
541
+ };
512
542
  get SigilLabel(): string;
513
543
  get SigilType(): symbol;
514
544
  get SigilTypeLineage(): readonly symbol[];
@@ -516,7 +546,8 @@ declare const SigilError: {
516
546
  isSigilified(obj: unknown): obj is ISigil;
517
547
  isOfType<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
518
548
  isOfTypeStrict<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
519
- };
549
+ } & ErrorConstructor;
550
+ type SigilError = InstanceType<typeof SigilError>;
520
551
 
521
552
  /**
522
553
  * Class decorator factory that attaches sigil statics to a class constructor.
@@ -543,7 +574,7 @@ declare const SigilError: {
543
574
  * @param opts - Options object to override any global options if needed.
544
575
  * @returns A class decorator compatible with the ECMAScript decorator context.
545
576
  */
546
- declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (value: Function, context: ClassDecoratorContext) => void;
577
+ declare function WithSigil<L extends string>(label?: L, opts?: SigilOptions): (value: Function, context: any) => void;
547
578
 
548
579
  /**
549
580
  * HOF (class inhancer) that attaches runtime sigil metadata to Sigil class.
@@ -573,6 +604,7 @@ declare function withSigil<S extends Function, L extends string = string>(Class:
573
604
  * Use this when the runtime metadata is already present (for example the class
574
605
  * is already decorated or was created via `Sigilify`).
575
606
  *
607
+ * @deprecated
576
608
  * @typeParam S - Constructor type (should be an ISigil).
577
609
  * @typeParam L - Label literal to associate at compile-time.
578
610
  * @param Class - The constructor to assert as typed sigil.
@@ -607,10 +639,10 @@ declare function withSigilTyped<S extends Function, L extends string = string>(C
607
639
  * This is a lightweight check that verifies the presence of an internal
608
640
  * symbol attached to the constructor.
609
641
  *
610
- * @param value - Value to test.
642
+ * @param ctor - Constructor to test.
611
643
  * @returns `true` if `value` is a sigil constructor, otherwise `false`.
612
644
  */
613
- declare function isSigilCtor(value: unknown): value is ISigil;
645
+ declare function isSigilCtor(ctor: unknown): ctor is ISigil;
614
646
  /**
615
647
  * Runtime predicate that checks whether the provided object is an instance
616
648
  * of a sigil class.
@@ -621,7 +653,7 @@ declare function isSigilCtor(value: unknown): value is ISigil;
621
653
  * @param obj - The value to test.
622
654
  * @returns `true` if `obj` is an instance produced by a sigil constructor.
623
655
  */
624
- declare function isSigilInstance(obj: unknown): obj is ISigilInstance;
656
+ declare function isSigilInstance(obj: unknown): obj is InstanceType<ISigil>;
625
657
  /**
626
658
  * Check whether the provided constructor was marked as a sigil base constructor.
627
659
  *
@@ -630,7 +662,7 @@ declare function isSigilInstance(obj: unknown): obj is ISigilInstance;
630
662
  * @param ctor - Constructor to check.
631
663
  * @returns `true` if `ctor` is a sigil base constructor.
632
664
  */
633
- declare function isSigilBaseCtor(ctor: Function): boolean;
665
+ declare function isSigilBaseCtor(ctor: Function): ctor is ISigil;
634
666
  /**
635
667
  * Check whether the provided object is an instance of a sigil base constructor.
636
668
  *
@@ -639,7 +671,7 @@ declare function isSigilBaseCtor(ctor: Function): boolean;
639
671
  * @param obj - The object to test.
640
672
  * @returns `true` if `obj` is an instance of a sigil base constructor.
641
673
  */
642
- declare function isSigilBaseInstance(obj: unknown): obj is ISigilInstance;
674
+ declare function isSigilBaseInstance(obj: unknown): obj is InstanceType<ISigil>;
643
675
  /**
644
676
  * Returns whether the constructor has been explicitly decorated with `WithSigil`.
645
677
  *
@@ -680,9 +712,22 @@ declare function isInheritanceChecked(ctor: Function): boolean;
680
712
  * @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.
681
713
  * @throws Error if `Base` is already sigilized.
682
714
  */
683
- declare function Sigilify(Base: Constructor, label?: string, opts?: SigilOptions): {
715
+ declare function Sigilify<B extends Constructor, L extends string>(Base: B, label?: L, opts?: SigilOptions): {
684
716
  new (...args: any[]): {
685
- readonly __SIGIL_BRAND__: Record<string, true>;
717
+ /**
718
+ * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
719
+ *
720
+ * - Provides a *type-only* unique marker that makes instances nominally
721
+ * distinct by label and allows propagation/merging of brand keys across inheritance.
722
+ * - Runtime: **no runtime value is required**; this property exists only for the type system.
723
+ *
724
+ * @remarks
725
+ * Consumers should not read or set this property at runtime. It is used by helper
726
+ * types (e.g. `SigilBrandOf`, `TypedSigil`) to extract/propagate compile-time brands.
727
+ */
728
+ readonly __SIGIL_BRAND__: {
729
+ Sigil: true;
730
+ } & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
686
731
  /**
687
732
  * Returns the human-readable sigil label of this instance's constructor.
688
733
  *
@@ -708,7 +753,20 @@ declare function Sigilify(Base: Constructor, label?: string, opts?: SigilOptions
708
753
  */
709
754
  getSigilTypeSet(): Readonly<Set<symbol>>;
710
755
  };
711
- readonly __SIGIL_BRAND__: Record<string, true>;
756
+ /**
757
+ * Compile-time nominal brand that encodes the class label `L` plus parent's brand keys `BrandOf<P>`.
758
+ *
759
+ * - Provides a *type-only* unique marker that makes instances nominally
760
+ * distinct by label and allows propagation/merging of brand keys across inheritance.
761
+ * - Runtime: **no runtime value is required**; this property exists only for the type system.
762
+ *
763
+ * @remarks
764
+ * Consumers should not read or set this property at runtime. It is used by helper
765
+ * types (e.g. `SigilBrandOf`, `TypedSigil`) to extract/propagate compile-time brands.
766
+ */
767
+ readonly __SIGIL_BRAND__: Prettify<{
768
+ Sigil: true;
769
+ } & { [K in L]: true; }>;
712
770
  /**
713
771
  * Class-level human-readable label constant for this sigil constructor.
714
772
  */
@@ -772,6 +830,6 @@ declare function Sigilify(Base: Constructor, label?: string, opts?: SigilOptions
772
830
  * @returns `true` if `other` has an identical lineage up to the length of this constructor's lineage.
773
831
  */
774
832
  isOfTypeStrict<T extends ISigil>(this: T, other: unknown): other is InstanceType<T>;
775
- };
833
+ } & B;
776
834
 
777
- export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, type ISigilInstance, type ISigilStatic, REGISTRY, Sigil, type SigilBrandOf, SigilError, type SigilOptions, SigilRegistry, Sigilify, type TypedSigil, WithSigil, getActiveRegistry, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, typed, updateOptions, withSigil, withSigilTyped };
835
+ export { DEFAULT_LABEL_REGEX, type GetInstance, type ISigil, REGISTRY, Sigil, type SigilBrandOf, SigilError, type SigilOptions, SigilRegistry, Sigilify, type TypedSigil, type UpdateSigilBrand, WithSigil, getActiveRegistry, isDecorated, isInheritanceChecked, isSigilBaseCtor, isSigilBaseInstance, isSigilCtor, isSigilInstance, typed, updateOptions, withSigil, withSigilTyped };