@vicin/sigil 3.3.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 -235
- package/CONTRIBUTING.md +24 -0
- package/LICENSE +3 -1
- package/README.md +199 -204
- package/dist/index.cjs +269 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +374 -0
- package/dist/index.d.ts +86 -258
- package/dist/index.global.js +113 -367
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +110 -376
- package/dist/index.js.map +1 -1
- package/package.json +43 -59
- package/dist/index.d.mts +0 -546
- package/dist/index.mjs +0 -510
- 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<L extends string = string> {
|
|
22
|
-
/** Class-level label constant (identity). */
|
|
23
|
-
readonly SigilLabel: L;
|
|
24
|
-
/** Class-level label constant (human readable). */
|
|
25
|
-
readonly SigilEffectiveLabel: L;
|
|
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> = ConstructorAbstract<ISigilInstance<L, P>> & ISigilStatic<L>;
|
|
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,24 +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
|
-
get SigilLabel():
|
|
183
|
-
get SigilEffectiveLabel(): "Sigil";
|
|
76
|
+
get SigilLabel(): string;
|
|
184
77
|
get SigilLabelLineage(): readonly string[];
|
|
185
|
-
get
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
} & {
|
|
189
|
-
new (): {};
|
|
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>;
|
|
190
81
|
};
|
|
191
82
|
type Sigil = InstanceType<typeof Sigil>;
|
|
192
83
|
/**
|
|
@@ -194,28 +85,26 @@ type Sigil = InstanceType<typeof Sigil>;
|
|
|
194
85
|
* to represent Sigil-specific errors.
|
|
195
86
|
*
|
|
196
87
|
* Use `SigilError` when you want an Error type that is identifiable via sigil
|
|
197
|
-
* runtime checks (e.g. `SigilError.
|
|
88
|
+
* runtime checks (e.g. `SigilError.isInstance(someError)`).
|
|
198
89
|
*/
|
|
199
90
|
declare const SigilError: {
|
|
200
91
|
new (...args: any[]): {
|
|
201
|
-
|
|
202
|
-
isExactType<T extends ISigilInstance>(this: T, other: unknown): other is T;
|
|
203
|
-
getSigilLabel(): string;
|
|
204
|
-
getSigilEffectiveLabel(): string;
|
|
205
|
-
getSigilLabelLineage(): readonly string[];
|
|
206
|
-
getSigilLabelSet(): Readonly<Set<string>>;
|
|
207
|
-
readonly [sigil]: {
|
|
92
|
+
[sigil]: {
|
|
208
93
|
Sigil: true;
|
|
209
94
|
SigilError: true;
|
|
210
95
|
};
|
|
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;
|
|
211
101
|
};
|
|
212
|
-
get SigilLabel():
|
|
213
|
-
get SigilEffectiveLabel(): "SigilError";
|
|
102
|
+
get SigilLabel(): string;
|
|
214
103
|
get SigilLabelLineage(): readonly string[];
|
|
215
|
-
get
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
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>;
|
|
107
|
+
};
|
|
219
108
|
type SigilError = InstanceType<typeof SigilError>;
|
|
220
109
|
|
|
221
110
|
/** -----------------------------------------
|
|
@@ -237,18 +126,6 @@ interface SigilOptions {
|
|
|
237
126
|
* Defaults to `null`.
|
|
238
127
|
*/
|
|
239
128
|
labelValidation?: ((label: string) => boolean) | RegExp | null;
|
|
240
|
-
/**
|
|
241
|
-
* When enabled, non-decorated subclasses that would otherwise inherit an ancestor's label
|
|
242
|
-
* will be assigned an autogenerated random label (so that explicit labels stay unique).
|
|
243
|
-
*/
|
|
244
|
-
autofillLabels?: boolean;
|
|
245
|
-
/**
|
|
246
|
-
* Option for Hot module reload set-ups, reload of files can result in class redefinition which will throw
|
|
247
|
-
* duplicate label error, setting this to 'true' will disabel this error.
|
|
248
|
-
* However as it disables unique label check bugs can appear if the same label is passed to two different
|
|
249
|
-
* classes so set this to 'true' only when needed and ensure uniqueness of passed labels.
|
|
250
|
-
*/
|
|
251
|
-
skipLabelUniquenessCheck?: boolean;
|
|
252
129
|
}
|
|
253
130
|
/** -----------------------------------------
|
|
254
131
|
* Update options
|
|
@@ -259,7 +136,7 @@ interface SigilOptions {
|
|
|
259
136
|
*
|
|
260
137
|
* @param opts - Partial options to merge into the global `OPTIONS` object.
|
|
261
138
|
*/
|
|
262
|
-
declare const updateSigilOptions: (
|
|
139
|
+
declare const updateSigilOptions: ({ labelValidation }?: SigilOptions) => void;
|
|
263
140
|
/** -----------------------------------------
|
|
264
141
|
* Label validation
|
|
265
142
|
* ----------------------------------------- */
|
|
@@ -271,8 +148,6 @@ declare const updateSigilOptions: (opts: SigilOptions) => void;
|
|
|
271
148
|
* It's advised to use this regex in 'SigilOptions.labelValidation'.
|
|
272
149
|
*/
|
|
273
150
|
declare const RECOMMENDED_LABEL_REGEX: RegExp;
|
|
274
|
-
/** @deprecated - Use 'RECOMMENDED_LABEL_REGEX' instead, will be removed in v4 */
|
|
275
|
-
declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
276
151
|
|
|
277
152
|
/**
|
|
278
153
|
* Class decorator factory that attaches sigil statics to a class constructor.
|
|
@@ -281,11 +156,10 @@ declare const DEFAULT_LABEL_REGEX: RegExp;
|
|
|
281
156
|
* @param opts - Options object to override any global options if needed.
|
|
282
157
|
* @returns A class decorator compatible with the ECMAScript decorator context.
|
|
283
158
|
*/
|
|
284
|
-
declare function
|
|
285
|
-
|
|
159
|
+
declare function AttachSigil(label: string, opts?: SigilOptions): (target: Function, ctx: any) => void;
|
|
286
160
|
/**
|
|
287
|
-
*
|
|
288
|
-
* Alternative to '@
|
|
161
|
+
* Function that attaches runtime sigil metadata to Sigil class.
|
|
162
|
+
* Alternative to '@AttachSigil' if you prefer normal functions.
|
|
289
163
|
*
|
|
290
164
|
* @typeParam S - Constructor type (should be an instance of sigil class).
|
|
291
165
|
* @param Class - The constructor (class) to enhance.
|
|
@@ -293,18 +167,15 @@ declare function WithSigil(label: string, opts?: SigilOptions): (value: Function
|
|
|
293
167
|
* @param opts - Options object to override any global options if needed.
|
|
294
168
|
* @returns The same constructor value, with runtime metadata ensured.
|
|
295
169
|
*/
|
|
296
|
-
declare function
|
|
170
|
+
declare function attachSigil<S extends Function>(Class: S, label: string, opts?: SigilOptions): S;
|
|
297
171
|
|
|
298
|
-
/** -----------------------------------------
|
|
299
|
-
* Inspection helpers
|
|
300
|
-
* ----------------------------------------- */
|
|
301
172
|
/**
|
|
302
173
|
* Runtime predicate that checks whether the provided value is a sigil constructor.
|
|
303
174
|
*
|
|
304
175
|
* @param ctor - Constructor to test.
|
|
305
176
|
* @returns `true` if `value` is a sigil constructor, otherwise `false`.
|
|
306
177
|
*/
|
|
307
|
-
declare function isSigilCtor(ctor: unknown): ctor is
|
|
178
|
+
declare function isSigilCtor(ctor: unknown): ctor is typeof Sigil;
|
|
308
179
|
/**
|
|
309
180
|
* Runtime predicate that checks whether the provided object is an instance
|
|
310
181
|
* of a sigil class.
|
|
@@ -312,12 +183,7 @@ declare function isSigilCtor(ctor: unknown): ctor is ISigil;
|
|
|
312
183
|
* @param inst - The instanca to test.
|
|
313
184
|
* @returns `true` if `obj` is an instance produced by a sigil constructor.
|
|
314
185
|
*/
|
|
315
|
-
declare function isSigilInstance(inst: unknown): inst is
|
|
316
|
-
/**
|
|
317
|
-
* Helper function to get labels registered by 'Sigil'
|
|
318
|
-
* @returns Sigil labels registered
|
|
319
|
-
*/
|
|
320
|
-
declare function getSigilLabels(): string[];
|
|
186
|
+
declare function isSigilInstance(inst: unknown): inst is Sigil;
|
|
321
187
|
|
|
322
188
|
/**
|
|
323
189
|
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers.
|
|
@@ -328,8 +194,11 @@ declare function getSigilLabels(): string[];
|
|
|
328
194
|
* @returns A new constructor that extends `Base` and includes Sigil statics/instance methods.
|
|
329
195
|
* @throws Error if `Base` is already sigilified.
|
|
330
196
|
*/
|
|
331
|
-
declare function Sigilify<
|
|
197
|
+
declare function Sigilify<L extends string>(Base: Constructor, label: L, opts?: SigilOptions): {
|
|
332
198
|
new (...args: any[]): {
|
|
199
|
+
[sigil]: {
|
|
200
|
+
Sigil: true;
|
|
201
|
+
} & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
333
202
|
/**
|
|
334
203
|
* Check whether `other` is (or inherits from) the instance represented by the
|
|
335
204
|
* calling constructor.
|
|
@@ -342,7 +211,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
342
211
|
* @param other - The object to test.
|
|
343
212
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
344
213
|
*/
|
|
345
|
-
|
|
214
|
+
isInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
346
215
|
/**
|
|
347
216
|
* Check whether `other` is exactly the same instance represented by the
|
|
348
217
|
* calling constructor.
|
|
@@ -352,61 +221,38 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
352
221
|
* @param other - The object to test.
|
|
353
222
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
354
223
|
*/
|
|
355
|
-
|
|
224
|
+
isExactInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
356
225
|
/**
|
|
357
226
|
* Returns the identity sigil label of this instance's constructor.
|
|
358
227
|
*
|
|
359
228
|
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:1:pnf11bgl').
|
|
360
229
|
*/
|
|
361
|
-
|
|
230
|
+
get SigilLabel(): string;
|
|
362
231
|
/**
|
|
363
|
-
*
|
|
232
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
364
233
|
*
|
|
365
|
-
*
|
|
366
|
-
*/
|
|
367
|
-
getSigilEffectiveLabel(): string;
|
|
368
|
-
/**
|
|
369
|
-
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
370
|
-
*
|
|
371
|
-
* @returns readonly array of labels representing the type lineage.
|
|
372
|
-
*/
|
|
373
|
-
getSigilLabelLineage(): readonly string[];
|
|
374
|
-
/**
|
|
375
|
-
* Returns a copy of the sigil type label lineage set for this instance's constructor.
|
|
234
|
+
* Useful for debugging and logging.
|
|
376
235
|
*
|
|
377
|
-
* @returns
|
|
378
|
-
*/
|
|
379
|
-
getSigilLabelSet(): Readonly<Set<string>>;
|
|
380
|
-
/**
|
|
381
|
-
* Compile-time nominal brand that encodes the class sigil labels object.
|
|
236
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
382
237
|
*/
|
|
383
|
-
readonly [
|
|
384
|
-
|
|
385
|
-
|
|
238
|
+
get SigilLabelLineage(): readonly string[];
|
|
239
|
+
/** Check if sigil label has been attached to this class */
|
|
240
|
+
get hasOwnSigil(): boolean;
|
|
386
241
|
};
|
|
387
242
|
/**
|
|
388
243
|
* Class-level identity label constant for this sigil constructor.
|
|
389
244
|
*/
|
|
390
|
-
get SigilLabel():
|
|
391
|
-
/**
|
|
392
|
-
* Class-level human-readable label constant for this sigil constructor, last passed label in 'Sigil' chain by developer.
|
|
393
|
-
*/
|
|
394
|
-
get SigilEffectiveLabel(): L;
|
|
245
|
+
get SigilLabel(): string;
|
|
395
246
|
/**
|
|
396
|
-
*
|
|
247
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
397
248
|
*
|
|
398
|
-
* Useful for debugging and
|
|
249
|
+
* Useful for debugging and logging.
|
|
399
250
|
*
|
|
400
|
-
* @returns An array of labels representing parent → child
|
|
251
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
401
252
|
*/
|
|
402
253
|
get SigilLabelLineage(): readonly string[];
|
|
403
|
-
/**
|
|
404
|
-
|
|
405
|
-
* Useful for debugging.
|
|
406
|
-
*
|
|
407
|
-
* @returns A Readonly Set of labels that represent the type lineage.
|
|
408
|
-
*/
|
|
409
|
-
get SigilLabelSet(): Readonly<Set<string>>;
|
|
254
|
+
/** Check if sigil label has been attached to this class */
|
|
255
|
+
get hasOwnSigil(): boolean;
|
|
410
256
|
/**
|
|
411
257
|
* Check whether `other` is (or inherits from) the instance represented by the
|
|
412
258
|
* calling constructor.
|
|
@@ -419,7 +265,7 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
419
265
|
* @param other - The object to test.
|
|
420
266
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
421
267
|
*/
|
|
422
|
-
|
|
268
|
+
isInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
423
269
|
/**
|
|
424
270
|
* Check whether `other` is exactly the same instance represented by the
|
|
425
271
|
* calling constructor.
|
|
@@ -429,8 +275,8 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
429
275
|
* @param other - The object to test.
|
|
430
276
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
431
277
|
*/
|
|
432
|
-
|
|
433
|
-
}
|
|
278
|
+
isExactInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
279
|
+
};
|
|
434
280
|
/**
|
|
435
281
|
* Mixin factory that augments an existing class with Sigil runtime metadata and helpers. Accept and return 'abstract' class.
|
|
436
282
|
*
|
|
@@ -440,7 +286,10 @@ declare function Sigilify<B extends Constructor, L extends string>(Base: B, labe
|
|
|
440
286
|
* @returns A new abstract constructor that extends `Base` and includes Sigil statics/instance methods.
|
|
441
287
|
* @throws Error if `Base` is already sigilified.
|
|
442
288
|
*/
|
|
443
|
-
declare function SigilifyAbstract<
|
|
289
|
+
declare function SigilifyAbstract<L extends string>(Base: ConstructorAbstract, label: L, opts?: SigilOptions): (abstract new (...args: any[]) => {
|
|
290
|
+
[sigil]: {
|
|
291
|
+
Sigil: true;
|
|
292
|
+
} & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
444
293
|
/**
|
|
445
294
|
* Check whether `other` is (or inherits from) the instance represented by the
|
|
446
295
|
* calling constructor.
|
|
@@ -453,7 +302,7 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
453
302
|
* @param other - The object to test.
|
|
454
303
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
455
304
|
*/
|
|
456
|
-
|
|
305
|
+
isInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
457
306
|
/**
|
|
458
307
|
* Check whether `other` is exactly the same instance represented by the
|
|
459
308
|
* calling constructor.
|
|
@@ -463,61 +312,38 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
463
312
|
* @param other - The object to test.
|
|
464
313
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
465
314
|
*/
|
|
466
|
-
|
|
315
|
+
isExactInstance<T_1>(this: T_1, other: any): other is T_1;
|
|
467
316
|
/**
|
|
468
317
|
* Returns the identity sigil label of this instance's constructor.
|
|
469
318
|
*
|
|
470
319
|
* @returns The label string if passed (e.g. '@scope/pkg.ClassName'), random label if not passed (e.g. '@Sigil-auto:ClassName:1:pnf11bgl').
|
|
471
320
|
*/
|
|
472
|
-
|
|
321
|
+
get SigilLabel(): string;
|
|
473
322
|
/**
|
|
474
|
-
*
|
|
323
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
475
324
|
*
|
|
476
|
-
*
|
|
477
|
-
*/
|
|
478
|
-
getSigilEffectiveLabel(): string;
|
|
479
|
-
/**
|
|
480
|
-
* Returns a copy of the sigil type label lineage for this instance's constructor.
|
|
325
|
+
* Useful for debugging and logging.
|
|
481
326
|
*
|
|
482
|
-
* @returns
|
|
327
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
483
328
|
*/
|
|
484
|
-
|
|
485
|
-
/**
|
|
486
|
-
|
|
487
|
-
*
|
|
488
|
-
* @returns readonly array of labels representing the type lineage.
|
|
489
|
-
*/
|
|
490
|
-
getSigilLabelSet(): Readonly<Set<string>>;
|
|
491
|
-
/**
|
|
492
|
-
* Compile-time nominal brand that encodes the class sigil labels object.
|
|
493
|
-
*/
|
|
494
|
-
readonly [sigil]: {
|
|
495
|
-
Sigil: true;
|
|
496
|
-
} & { [K_1 in L]: true; } extends infer T ? { [K in keyof T]: T[K]; } : never;
|
|
329
|
+
get SigilLabelLineage(): readonly string[];
|
|
330
|
+
/** Check if sigil label has been attached to this class */
|
|
331
|
+
get hasOwnSigil(): boolean;
|
|
497
332
|
}) & {
|
|
498
333
|
/**
|
|
499
334
|
* Class-level identity label constant for this sigil constructor.
|
|
500
335
|
*/
|
|
501
|
-
get SigilLabel():
|
|
336
|
+
get SigilLabel(): string;
|
|
502
337
|
/**
|
|
503
|
-
*
|
|
504
|
-
*/
|
|
505
|
-
get SigilEffectiveLabel(): L;
|
|
506
|
-
/**
|
|
507
|
-
* Linearized sigil type label chain for the current constructor.
|
|
338
|
+
* Copy of the sigil label lineage for this instance's constructor.
|
|
508
339
|
*
|
|
509
|
-
* Useful for debugging and
|
|
340
|
+
* Useful for debugging and logging.
|
|
510
341
|
*
|
|
511
|
-
* @returns An array of labels representing parent → child
|
|
342
|
+
* @returns An array of sigil labels representing parent → child labels.
|
|
512
343
|
*/
|
|
513
344
|
get SigilLabelLineage(): readonly string[];
|
|
514
|
-
/**
|
|
515
|
-
|
|
516
|
-
* Useful for debugging.
|
|
517
|
-
*
|
|
518
|
-
* @returns A Readonly Set of labels that represent the type lineage.
|
|
519
|
-
*/
|
|
520
|
-
get SigilLabelSet(): Readonly<Set<string>>;
|
|
345
|
+
/** Check if sigil label has been attached to this class */
|
|
346
|
+
get hasOwnSigil(): boolean;
|
|
521
347
|
/**
|
|
522
348
|
* Check whether `other` is (or inherits from) the instance represented by the
|
|
523
349
|
* calling constructor.
|
|
@@ -530,7 +356,7 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
530
356
|
* @param other - The object to test.
|
|
531
357
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
532
358
|
*/
|
|
533
|
-
|
|
359
|
+
isInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
534
360
|
/**
|
|
535
361
|
* Check whether `other` is exactly the same instance represented by the
|
|
536
362
|
* calling constructor.
|
|
@@ -540,7 +366,9 @@ declare function SigilifyAbstract<B extends ConstructorAbstract, L extends strin
|
|
|
540
366
|
* @param other - The object to test.
|
|
541
367
|
* @returns A type guard asserting `other` is an instance of the constructor.
|
|
542
368
|
*/
|
|
543
|
-
|
|
544
|
-
}
|
|
369
|
+
isExactInstance<T>(this: T, other: any): other is GetPrototype<T>;
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
declare function hasOwnSigil(ctor: Function): boolean;
|
|
545
373
|
|
|
546
|
-
export {
|
|
374
|
+
export { AttachSigil, type ExtendSigil, type GetPrototype, RECOMMENDED_LABEL_REGEX, Sigil, SigilError, type SigilOf, type SigilOptions, Sigilify, SigilifyAbstract, attachSigil, hasOwnSigil, isSigilCtor, isSigilInstance, sigil, updateSigilOptions };
|