@vicin/sigil 3.4.0 → 4.0.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 +4 -252
- package/CONTRIBUTING.md +24 -0
- package/LICENSE +3 -1
- package/README.md +134 -180
- package/dist/index.cjs +269 -0
- package/dist/index.cjs.map +1 -0
- package/dist/{index.d.mts → index.d.cts} +67 -242
- package/dist/index.d.ts +67 -242
- package/dist/index.global.js +88 -208
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +87 -219
- package/dist/index.js.map +1 -1
- package/package.json +43 -59
- package/dist/index.mjs +0 -374
- package/dist/index.mjs.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,117 +1,12 @@
|
|
|
1
1
|
/** -----------------------------------------
|
|
2
|
-
*
|
|
2
|
+
* Public
|
|
3
3
|
* ----------------------------------------- */
|
|
4
4
|
/**
|
|
5
5
|
* Symbol used for nominal typing
|
|
6
6
|
*/
|
|
7
7
|
declare const sigil: unique symbol;
|
|
8
|
-
/** -----------------------------------------
|
|
9
|
-
* Class and instance
|
|
10
|
-
* ----------------------------------------- */
|
|
11
|
-
/**
|
|
12
|
-
* Static-side interface describing methods and properties added to a class
|
|
13
|
-
* constructor when it is sigilified.
|
|
14
|
-
*
|
|
15
|
-
* The properties and methods described here mirror the getters and static
|
|
16
|
-
* predicates implemented by the `Sigilify` mixin.
|
|
17
|
-
*
|
|
18
|
-
* @template L - Narrow string literal type representing the label.
|
|
19
|
-
* @template P - Optinal parent to extend its '[sigil]'.
|
|
20
|
-
*/
|
|
21
|
-
interface ISigilStatic {
|
|
22
|
-
/** Class-level label constant (identity). */
|
|
23
|
-
readonly SigilLabel: string;
|
|
24
|
-
/** Class-level label constant (human readable). */
|
|
25
|
-
readonly SigilEffectiveLabel: string;
|
|
26
|
-
/**
|
|
27
|
-
* Copy of the linearized sigil type label chain for the current constructor.
|
|
28
|
-
* Useful for debugging.
|
|
29
|
-
*/
|
|
30
|
-
readonly SigilLabelLineage: readonly string[];
|
|
31
|
-
/**
|
|
32
|
-
* Copy of the sigil type label set for the current constructor.
|
|
33
|
-
* Useful for debugging.
|
|
34
|
-
*/
|
|
35
|
-
readonly SigilLabelSet: Readonly<Set<string>>;
|
|
36
|
-
/**
|
|
37
|
-
* Check whether `other` is (or inherits from) the instance represented by the
|
|
38
|
-
* calling constructor.
|
|
39
|
-
*
|
|
40
|
-
* This replaces `instanceof` so that checks remain valid across bundles/realms
|
|
41
|
-
* and when subclassing.
|
|
42
|
-
*
|
|
43
|
-
* @typeParam T - The specific sigil constructor (`this`).
|
|
44
|
-
* @param this - The constructor performing the type check.
|
|
45
|
-
* @param other - The object to test.
|
|
46
|
-
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
47
|
-
*/
|
|
48
|
-
isOfType<T extends ISigilStatic>(this: T, other: unknown): other is GetPrototype<T>;
|
|
49
|
-
/**
|
|
50
|
-
* Check whether `other` is exactly the same instance represented by the
|
|
51
|
-
* calling constructor.
|
|
52
|
-
*
|
|
53
|
-
* @typeParam T - The specific sigil constructor (`this`).
|
|
54
|
-
* @param this - The constructor performing the type check.
|
|
55
|
-
* @param other - The object to test.
|
|
56
|
-
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
57
|
-
*/
|
|
58
|
-
isExactType<T extends ISigilStatic>(this: T, other: unknown): other is GetPrototype<T>;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Instance-side interface describing properties present on sigil instances.
|
|
62
|
-
* The methods mirror the instance helpers injected by the mixin.
|
|
63
|
-
*
|
|
64
|
-
* @template L - Narrow string literal type for the label returned by `getSigilLabel`.
|
|
65
|
-
* @template P - Optinal parent to extend its '[sigil]'.
|
|
66
|
-
*/
|
|
67
|
-
interface ISigilInstance<L extends string = string, P extends Function = never> {
|
|
68
|
-
/** Compile-time nominal brand that encodes the class label `L` plus parent's sigil labels `SigilOf<P>`. */
|
|
69
|
-
readonly [sigil]: Prettify<{
|
|
70
|
-
Sigil: true;
|
|
71
|
-
} & IfNever<SigilOf<P>, {}> & {
|
|
72
|
-
[k in L]: true;
|
|
73
|
-
}>;
|
|
74
|
-
/** Returns identity sigil label of the class constructor. */
|
|
75
|
-
getSigilLabel(): string;
|
|
76
|
-
/** Returns human-readable sigil label of the class constructor. */
|
|
77
|
-
getSigilEffectiveLabel(): string;
|
|
78
|
-
/** Returns copy of sigil type label lineage of the class constructor. */
|
|
79
|
-
getSigilLabelLineage(): readonly string[];
|
|
80
|
-
/** Returns copy of sigil type label set of the class constructor. */
|
|
81
|
-
getSigilLabelSet(): Readonly<Set<string>>;
|
|
82
|
-
/**
|
|
83
|
-
* Check whether `other` is (or inherits from) the instance represented by the
|
|
84
|
-
* calling constructor.
|
|
85
|
-
*
|
|
86
|
-
* This replaces `instanceof` so that checks remain valid across bundles/realms
|
|
87
|
-
* and when subclassing.
|
|
88
|
-
*
|
|
89
|
-
* @typeParam T - The specific sigil constructor (`this`).
|
|
90
|
-
* @param this - The constructor performing the type check.
|
|
91
|
-
* @param other - The object to test.
|
|
92
|
-
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
93
|
-
*/
|
|
94
|
-
isOfType<T extends ISigilInstance>(this: T, other: unknown): other is T;
|
|
95
|
-
/**
|
|
96
|
-
* Check whether `other` is exactly the same instance represented by the
|
|
97
|
-
* calling constructor.
|
|
98
|
-
*
|
|
99
|
-
* @typeParam T - The specific sigil constructor (`this`).
|
|
100
|
-
* @param this - The constructor performing the type check.
|
|
101
|
-
* @param other - The object to test.
|
|
102
|
-
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
103
|
-
*/
|
|
104
|
-
isExactType<T extends ISigilInstance>(this: T, other: unknown): other is T;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Combined constructor + static interface for a sigil class.
|
|
108
|
-
*
|
|
109
|
-
* @template L - Narrow string literal type for the label.
|
|
110
|
-
* @template P - Optinal parent to extend its '[sigil]'.
|
|
111
|
-
*/
|
|
112
|
-
type ISigil<L extends string = string, P extends Function = never> = ISigilStatic & ConstructorAbstract<ISigilInstance<L, P>>;
|
|
113
8
|
/** Update '[sigil]' field for nominal typing */
|
|
114
|
-
type ExtendSigil<L extends string, P extends
|
|
9
|
+
type ExtendSigil<L extends string, P extends Sigil> = Prettify<IfNever<SigilOf<P>, {}> & {
|
|
115
10
|
[K in L]: true;
|
|
116
11
|
}>;
|
|
117
12
|
/**
|
|
@@ -123,8 +18,16 @@ type ExtendSigil<L extends string, P extends ISigilInstance> = Prettify<IfNever<
|
|
|
123
18
|
type SigilOf<S> = S extends {
|
|
124
19
|
readonly [sigil]: infer Sigil;
|
|
125
20
|
} ? Sigil : never;
|
|
21
|
+
/**
|
|
22
|
+
* Helper type to get prototype of class
|
|
23
|
+
*
|
|
24
|
+
* @template T - Class constructor.
|
|
25
|
+
*/
|
|
26
|
+
type GetPrototype<T> = T extends {
|
|
27
|
+
prototype: infer P;
|
|
28
|
+
} ? P : never;
|
|
126
29
|
/** -----------------------------------------
|
|
127
|
-
*
|
|
30
|
+
* Internal
|
|
128
31
|
* ----------------------------------------- */
|
|
129
32
|
/**
|
|
130
33
|
* Generic type for class constructors used by the Sigil utilities.
|
|
@@ -152,14 +55,6 @@ type Prettify<T> = {
|
|
|
152
55
|
} & {};
|
|
153
56
|
/** Helper type to replace 'never' with another type */
|
|
154
57
|
type IfNever<T, R = {}> = [T] extends [never] ? R : T;
|
|
155
|
-
/**
|
|
156
|
-
* Helper type to get prototype of class
|
|
157
|
-
*
|
|
158
|
-
* @template T - Class constructor.
|
|
159
|
-
*/
|
|
160
|
-
type GetPrototype<T> = T extends {
|
|
161
|
-
prototype: infer P;
|
|
162
|
-
} ? P : never;
|
|
163
58
|
|
|
164
59
|
/**
|
|
165
60
|
* A minimal root Sigil class used by the library as a base identity.
|
|
@@ -169,22 +64,20 @@ type GetPrototype<T> = T extends {
|
|
|
169
64
|
*/
|
|
170
65
|
declare const Sigil: {
|
|
171
66
|
new (...args: any[]): {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
getSigilLabelSet(): Readonly<Set<string>>;
|
|
67
|
+
isInstance<T>(this: T, other: any): other is T;
|
|
68
|
+
isExactInstance<T>(this: T, other: any): other is T;
|
|
69
|
+
get SigilLabel(): string;
|
|
70
|
+
get SigilLabelLineage(): readonly string[];
|
|
71
|
+
get hasOwnSigil(): boolean;
|
|
178
72
|
readonly [sigil]: {
|
|
179
73
|
Sigil: true;
|
|
180
74
|
};
|
|
181
75
|
};
|
|
182
76
|
get SigilLabel(): string;
|
|
183
|
-
get SigilEffectiveLabel(): string;
|
|
184
77
|
get SigilLabelLineage(): readonly string[];
|
|
185
|
-
get
|
|
186
|
-
|
|
187
|
-
|
|
78
|
+
get hasOwnSigil(): boolean;
|
|
79
|
+
isInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
80
|
+
isExactInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
188
81
|
};
|
|
189
82
|
type Sigil = InstanceType<typeof Sigil>;
|
|
190
83
|
/**
|
|
@@ -192,7 +85,7 @@ type Sigil = InstanceType<typeof Sigil>;
|
|
|
192
85
|
* to represent Sigil-specific errors.
|
|
193
86
|
*
|
|
194
87
|
* Use `SigilError` when you want an Error type that is identifiable via sigil
|
|
195
|
-
* runtime checks (e.g. `SigilError.
|
|
88
|
+
* runtime checks (e.g. `SigilError.isInstance(someError)`).
|
|
196
89
|
*/
|
|
197
90
|
declare const SigilError: {
|
|
198
91
|
new (...args: any[]): {
|
|
@@ -200,19 +93,17 @@ declare const SigilError: {
|
|
|
200
93
|
Sigil: true;
|
|
201
94
|
SigilError: true;
|
|
202
95
|
};
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
getSigilLabelSet(): Readonly<Set<string>>;
|
|
96
|
+
isInstance<T>(this: T, other: any): other is T;
|
|
97
|
+
isExactInstance<T>(this: T, other: any): other is T;
|
|
98
|
+
get SigilLabel(): string;
|
|
99
|
+
get SigilLabelLineage(): readonly string[];
|
|
100
|
+
get hasOwnSigil(): boolean;
|
|
209
101
|
};
|
|
210
102
|
get SigilLabel(): string;
|
|
211
|
-
get SigilEffectiveLabel(): string;
|
|
212
103
|
get SigilLabelLineage(): readonly string[];
|
|
213
|
-
get
|
|
214
|
-
|
|
215
|
-
|
|
104
|
+
get hasOwnSigil(): boolean;
|
|
105
|
+
isInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
106
|
+
isExactInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
216
107
|
};
|
|
217
108
|
type SigilError = InstanceType<typeof SigilError>;
|
|
218
109
|
|
|
@@ -235,18 +126,6 @@ interface SigilOptions {
|
|
|
235
126
|
* Defaults to `null`.
|
|
236
127
|
*/
|
|
237
128
|
labelValidation?: ((label: string) => boolean) | RegExp | null;
|
|
238
|
-
/**
|
|
239
|
-
* When enabled, non-decorated subclasses that would otherwise inherit an ancestor's label
|
|
240
|
-
* will be assigned an autogenerated random label (so that explicit labels stay unique).
|
|
241
|
-
*/
|
|
242
|
-
autofillLabels?: boolean;
|
|
243
|
-
/**
|
|
244
|
-
* Option for Hot module reload set-ups, reload of files can result in class redefinition which will throw
|
|
245
|
-
* duplicate label error, setting this to 'true' will disabel this error.
|
|
246
|
-
* However as it disables unique label check bugs can appear if the same label is passed to two different
|
|
247
|
-
* classes so set this to 'true' only when needed and ensure uniqueness of passed labels.
|
|
248
|
-
*/
|
|
249
|
-
skipLabelUniquenessCheck?: boolean;
|
|
250
129
|
}
|
|
251
130
|
/** -----------------------------------------
|
|
252
131
|
* Update options
|
|
@@ -257,7 +136,7 @@ interface SigilOptions {
|
|
|
257
136
|
*
|
|
258
137
|
* @param opts - Partial options to merge into the global `OPTIONS` object.
|
|
259
138
|
*/
|
|
260
|
-
declare const updateSigilOptions: (
|
|
139
|
+
declare const updateSigilOptions: ({ labelValidation }?: SigilOptions) => void;
|
|
261
140
|
/** -----------------------------------------
|
|
262
141
|
* Label validation
|
|
263
142
|
* ----------------------------------------- */
|
|
@@ -269,8 +148,6 @@ declare const updateSigilOptions: (opts: SigilOptions) => void;
|
|
|
269
148
|
* It's advised to use this regex in 'SigilOptions.labelValidation'.
|
|
270
149
|
*/
|
|
271
150
|
declare const RECOMMENDED_LABEL_REGEX: RegExp;
|
|
272
|
-
/** @deprecated - Use 'RECOMMENDED_LABEL_REGEX' instead, will be removed in v4 */
|
|
273
|
-
declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
274
151
|
|
|
275
152
|
/**
|
|
276
153
|
* Class decorator factory that attaches sigil statics to a class constructor.
|
|
@@ -279,11 +156,7 @@ declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
|
279
156
|
* @param opts - Options object to override any global options if needed.
|
|
280
157
|
* @returns A class decorator compatible with the ECMAScript decorator context.
|
|
281
158
|
*/
|
|
282
|
-
declare function AttachSigil(label: string, opts?: SigilOptions): (
|
|
283
|
-
/**
|
|
284
|
-
* @deprecated Use 'AttachSigil' instead, updated for clarity. will be removed in v4
|
|
285
|
-
*/
|
|
286
|
-
declare const WithSigil: typeof AttachSigil;
|
|
159
|
+
declare function AttachSigil(label: string, opts?: SigilOptions): (target: Function, ctx: any) => void;
|
|
287
160
|
/**
|
|
288
161
|
* Function that attaches runtime sigil metadata to Sigil class.
|
|
289
162
|
* Alternative to '@AttachSigil' if you prefer normal functions.
|
|
@@ -295,21 +168,14 @@ declare const WithSigil: typeof AttachSigil;
|
|
|
295
168
|
* @returns The same constructor value, with runtime metadata ensured.
|
|
296
169
|
*/
|
|
297
170
|
declare function attachSigil<S extends Function>(Class: S, label: string, opts?: SigilOptions): S;
|
|
298
|
-
/**
|
|
299
|
-
* @deprecated Use 'attachSigil' instead, updated for clarity. will be removed in v4
|
|
300
|
-
*/
|
|
301
|
-
declare const withSigil: typeof attachSigil;
|
|
302
171
|
|
|
303
|
-
/** -----------------------------------------
|
|
304
|
-
* Inspection helpers
|
|
305
|
-
* ----------------------------------------- */
|
|
306
172
|
/**
|
|
307
173
|
* Runtime predicate that checks whether the provided value is a sigil constructor.
|
|
308
174
|
*
|
|
309
175
|
* @param ctor - Constructor to test.
|
|
310
176
|
* @returns `true` if `value` is a sigil constructor, otherwise `false`.
|
|
311
177
|
*/
|
|
312
|
-
declare function isSigilCtor(ctor: unknown): ctor is
|
|
178
|
+
declare function isSigilCtor(ctor: unknown): ctor is typeof Sigil;
|
|
313
179
|
/**
|
|
314
180
|
* Runtime predicate that checks whether the provided object is an instance
|
|
315
181
|
* of a sigil class.
|
|
@@ -317,12 +183,7 @@ declare function isSigilCtor(ctor: unknown): ctor is ISigil;
|
|
|
317
183
|
* @param inst - The instanca to test.
|
|
318
184
|
* @returns `true` if `obj` is an instance produced by a sigil constructor.
|
|
319
185
|
*/
|
|
320
|
-
declare function isSigilInstance(inst: unknown): inst is
|
|
321
|
-
/**
|
|
322
|
-
* Helper function to get labels registered by 'Sigil'
|
|
323
|
-
* @returns Sigil labels registered
|
|
324
|
-
*/
|
|
325
|
-
declare function getSigilLabels(): string[];
|
|
186
|
+
declare function isSigilInstance(inst: unknown): inst is Sigil;
|
|
326
187
|
|
|
327
188
|
/**
|
|
328
189
|
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers.
|
|
@@ -350,7 +211,7 @@ declare function Sigilify<L extends string>(Base: Constructor, label: L, opts?:
|
|
|
350
211
|
* @param other - The object to test.
|
|
351
212
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
352
213
|
*/
|
|
353
|
-
|
|
214
|
+
isInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
354
215
|
/**
|
|
355
216
|
* Check whether `other` is exactly the same instance represented by the
|
|
356
217
|
* calling constructor.
|
|
@@ -360,57 +221,38 @@ declare function Sigilify<L extends string>(Base: Constructor, label: L, opts?:
|
|
|
360
221
|
* @param other - The object to test.
|
|
361
222
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
362
223
|
*/
|
|
363
|
-
|
|
224
|
+
isExactInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
364
225
|
/**
|
|
365
226
|
* Returns the identity sigil label of this instance's constructor.
|
|
366
227
|
*
|
|
367
228
|
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:1:pnf11bgl').
|
|
368
229
|
*/
|
|
369
|
-
|
|
370
|
-
/**
|
|
371
|
-
* Returns the human-readable sigil label of this instance's constructor.
|
|
372
|
-
*
|
|
373
|
-
* @returns The last passed label string (e.g. '@scope/pkg.ClassName').
|
|
374
|
-
*/
|
|
375
|
-
getSigilEffectiveLabel(): string;
|
|
230
|
+
get SigilLabel(): string;
|
|
376
231
|
/**
|
|
377
|
-
*
|
|
232
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
378
233
|
*
|
|
379
|
-
*
|
|
380
|
-
*/
|
|
381
|
-
getSigilLabelLineage(): readonly string[];
|
|
382
|
-
/**
|
|
383
|
-
* Returns a copy of the sigil type label lineage set for this instance's constructor.
|
|
234
|
+
* Useful for debugging and logging.
|
|
384
235
|
*
|
|
385
|
-
* @
|
|
386
|
-
* @returns readonly array of labels representing the type lineage.
|
|
236
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
387
237
|
*/
|
|
388
|
-
|
|
238
|
+
get SigilLabelLineage(): readonly string[];
|
|
239
|
+
/** Check if sigil label has been attached to this class */
|
|
240
|
+
get hasOwnSigil(): boolean;
|
|
389
241
|
};
|
|
390
242
|
/**
|
|
391
243
|
* Class-level identity label constant for this sigil constructor.
|
|
392
244
|
*/
|
|
393
245
|
get SigilLabel(): string;
|
|
394
246
|
/**
|
|
395
|
-
*
|
|
396
|
-
*/
|
|
397
|
-
get SigilEffectiveLabel(): string;
|
|
398
|
-
/**
|
|
399
|
-
* Linearized sigil type label chain for the current constructor.
|
|
247
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
400
248
|
*
|
|
401
|
-
* Useful for debugging and
|
|
249
|
+
* Useful for debugging and logging.
|
|
402
250
|
*
|
|
403
|
-
* @returns An array of labels representing parent → child
|
|
251
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
404
252
|
*/
|
|
405
253
|
get SigilLabelLineage(): readonly string[];
|
|
406
|
-
/**
|
|
407
|
-
|
|
408
|
-
* Useful for debugging.
|
|
409
|
-
*
|
|
410
|
-
* @deprecated To minize API and bundle size, internally this method is 'new Set(this.SigilLabelLineage)' only. will be removed in v4
|
|
411
|
-
* @returns A Readonly Set of labels that represent the type lineage.
|
|
412
|
-
*/
|
|
413
|
-
get SigilLabelSet(): Readonly<Set<string>>;
|
|
254
|
+
/** Check if sigil label has been attached to this class */
|
|
255
|
+
get hasOwnSigil(): boolean;
|
|
414
256
|
/**
|
|
415
257
|
* Check whether `other` is (or inherits from) the instance represented by the
|
|
416
258
|
* calling constructor.
|
|
@@ -423,7 +265,7 @@ declare function Sigilify<L extends string>(Base: Constructor, label: L, opts?:
|
|
|
423
265
|
* @param other - The object to test.
|
|
424
266
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
425
267
|
*/
|
|
426
|
-
|
|
268
|
+
isInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
427
269
|
/**
|
|
428
270
|
* Check whether `other` is exactly the same instance represented by the
|
|
429
271
|
* calling constructor.
|
|
@@ -433,7 +275,7 @@ declare function Sigilify<L extends string>(Base: Constructor, label: L, opts?:
|
|
|
433
275
|
* @param other - The object to test.
|
|
434
276
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
435
277
|
*/
|
|
436
|
-
|
|
278
|
+
isExactInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
437
279
|
};
|
|
438
280
|
/**
|
|
439
281
|
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers. Accept and return 'abstract' class.
|
|
@@ -460,7 +302,7 @@ declare function SigilifyAbstract<L extends string>(Base: ConstructorAbstract, l
|
|
|
460
302
|
* @param other - The object to test.
|
|
461
303
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
462
304
|
*/
|
|
463
|
-
|
|
305
|
+
isInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
464
306
|
/**
|
|
465
307
|
* Check whether `other` is exactly the same instance represented by the
|
|
466
308
|
* calling constructor.
|
|
@@ -470,57 +312,38 @@ declare function SigilifyAbstract<L extends string>(Base: ConstructorAbstract, l
|
|
|
470
312
|
* @param other - The object to test.
|
|
471
313
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
472
314
|
*/
|
|
473
|
-
|
|
315
|
+
isExactInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
474
316
|
/**
|
|
475
317
|
* Returns the identity sigil label of this instance's constructor.
|
|
476
318
|
*
|
|
477
319
|
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:1:pnf11bgl').
|
|
478
320
|
*/
|
|
479
|
-
|
|
480
|
-
/**
|
|
481
|
-
* Returns the human-readable sigil label of this instance's constructor.
|
|
482
|
-
*
|
|
483
|
-
* @returns The last passed label string (e.g. '@scope/pkg.ClassName').
|
|
484
|
-
*/
|
|
485
|
-
getSigilEffectiveLabel(): string;
|
|
321
|
+
get SigilLabel(): string;
|
|
486
322
|
/**
|
|
487
|
-
*
|
|
323
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
488
324
|
*
|
|
489
|
-
*
|
|
490
|
-
*/
|
|
491
|
-
getSigilLabelLineage(): readonly string[];
|
|
492
|
-
/**
|
|
493
|
-
* Returns a copy of the sigil type label lineage set for this instance's constructor.
|
|
325
|
+
* Useful for debugging and logging.
|
|
494
326
|
*
|
|
495
|
-
* @
|
|
496
|
-
* @returns readonly array of labels representing the type lineage.
|
|
327
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
497
328
|
*/
|
|
498
|
-
|
|
329
|
+
get SigilLabelLineage(): readonly string[];
|
|
330
|
+
/** Check if sigil label has been attached to this class */
|
|
331
|
+
get hasOwnSigil(): boolean;
|
|
499
332
|
}) & {
|
|
500
333
|
/**
|
|
501
334
|
* Class-level identity label constant for this sigil constructor.
|
|
502
335
|
*/
|
|
503
336
|
get SigilLabel(): string;
|
|
504
337
|
/**
|
|
505
|
-
*
|
|
506
|
-
*/
|
|
507
|
-
get SigilEffectiveLabel(): string;
|
|
508
|
-
/**
|
|
509
|
-
* Linearized sigil type label chain for the current constructor.
|
|
338
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
510
339
|
*
|
|
511
|
-
* Useful for debugging and
|
|
340
|
+
* Useful for debugging and logging.
|
|
512
341
|
*
|
|
513
|
-
* @returns An array of labels representing parent → child
|
|
342
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
514
343
|
*/
|
|
515
344
|
get SigilLabelLineage(): readonly string[];
|
|
516
|
-
/**
|
|
517
|
-
|
|
518
|
-
* Useful for debugging.
|
|
519
|
-
*
|
|
520
|
-
* @deprecated To minize API and bundle size, internally this method is 'new Set(this.SigilLabelLineage)' only. will be removed in v4
|
|
521
|
-
* @returns A Readonly Set of labels that represent the type lineage.
|
|
522
|
-
*/
|
|
523
|
-
get SigilLabelSet(): Readonly<Set<string>>;
|
|
345
|
+
/** Check if sigil label has been attached to this class */
|
|
346
|
+
get hasOwnSigil(): boolean;
|
|
524
347
|
/**
|
|
525
348
|
* Check whether `other` is (or inherits from) the instance represented by the
|
|
526
349
|
* calling constructor.
|
|
@@ -533,7 +356,7 @@ declare function SigilifyAbstract<L extends string>(Base: ConstructorAbstract, l
|
|
|
533
356
|
* @param other - The object to test.
|
|
534
357
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
535
358
|
*/
|
|
536
|
-
|
|
359
|
+
isInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
537
360
|
/**
|
|
538
361
|
* Check whether `other` is exactly the same instance represented by the
|
|
539
362
|
* calling constructor.
|
|
@@ -543,7 +366,9 @@ declare function SigilifyAbstract<L extends string>(Base: ConstructorAbstract, l
|
|
|
543
366
|
* @param other - The object to test.
|
|
544
367
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
545
368
|
*/
|
|
546
|
-
|
|
369
|
+
isExactInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
547
370
|
};
|
|
548
371
|
|
|
549
|
-
|
|
372
|
+
declare function hasOwnSigil(ctor: Function): boolean;
|
|
373
|
+
|
|
374
|
+
export { AttachSigil, type ExtendSigil, type GetPrototype, RECOMMENDED_LABEL_REGEX, Sigil, SigilError, type SigilOf, type SigilOptions, Sigilify, SigilifyAbstract, attachSigil, hasOwnSigil, isSigilCtor, isSigilInstance, sigil, updateSigilOptions };
|