@seedcord/core 0.1.0-next.6 → 0.1.0-next.7
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/{AutocompleteOptions-eKhIe6Qt.d.mts → AutocompleteOptions-DLp_B8as.d.mts} +61 -112
- package/dist/HmrModuleHandler-3sNgKHdf.mjs +163 -0
- package/dist/HmrModuleHandler-3sNgKHdf.mjs.map +1 -0
- package/dist/HmrModuleHandler-CTBng7wV.cjs +170 -0
- package/dist/HmrModuleHandler-CTBng7wV.cjs.map +1 -0
- package/dist/Plugin-3rlH0uxH.d.mts +620 -0
- package/dist/{Plugin-C2-VHrsX.cjs → Plugin-Cgp1a0uQ.cjs} +13 -4
- package/dist/Plugin-Cgp1a0uQ.cjs.map +1 -0
- package/dist/{Plugin-PcdPjAzc.mjs → Plugin-j9GYdroS.mjs} +13 -4
- package/dist/Plugin-j9GYdroS.mjs.map +1 -0
- package/dist/{permissions-DSW_EZfN.cjs → Silence-DiP95iwD.cjs} +38 -307
- package/dist/Silence-DiP95iwD.cjs.map +1 -0
- package/dist/{permissions-RVCBhL2n.mjs → Silence-dbC2slOB.mjs} +35 -238
- package/dist/Silence-dbC2slOB.mjs.map +1 -0
- package/dist/basic-D7bDlgSP.d.mts +10 -0
- package/dist/hmr.index.cjs +2 -164
- package/dist/hmr.index.mjs +2 -162
- package/dist/index-Dueqztyy.d.mts +142 -0
- package/dist/index.cjs +50 -72
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +7 -5
- package/dist/index.mjs +8 -35
- package/dist/index.mjs.map +1 -1
- package/dist/internal.index.cjs +262 -74
- package/dist/internal.index.cjs.map +1 -1
- package/dist/internal.index.d.mts +68 -4
- package/dist/internal.index.mjs +216 -35
- package/dist/internal.index.mjs.map +1 -1
- package/dist/node-internal.index.cjs +123 -52
- package/dist/node-internal.index.cjs.map +1 -1
- package/dist/node-internal.index.d.mts +67 -2158
- package/dist/node-internal.index.mjs +124 -54
- package/dist/node-internal.index.mjs.map +1 -1
- package/dist/plugin.index.cjs +1 -1
- package/dist/plugin.index.d.mts +1 -1
- package/dist/plugin.index.mjs +1 -1
- package/dist/publishDefault-CCf1azzW.mjs +264 -0
- package/dist/publishDefault-CCf1azzW.mjs.map +1 -0
- package/dist/publishDefault-l0NQ-SHo.cjs +353 -0
- package/dist/publishDefault-l0NQ-SHo.cjs.map +1 -0
- package/dist/subscribers-B1G6_LlK.cjs +517 -0
- package/dist/subscribers-B1G6_LlK.cjs.map +1 -0
- package/dist/subscribers-DYqFVP1X.mjs +480 -0
- package/dist/subscribers-DYqFVP1X.mjs.map +1 -0
- package/package.json +7 -6
- package/dist/Plugin-C2-VHrsX.cjs.map +0 -1
- package/dist/Plugin-CNyRKDHT.d.mts +0 -226
- package/dist/Plugin-PcdPjAzc.mjs.map +0 -1
- package/dist/hmr.index.cjs.map +0 -1
- package/dist/hmr.index.mjs.map +0 -1
- package/dist/is-never-Ddaba1Su.d.mts +0 -58
- package/dist/permissions-DSW_EZfN.cjs.map +0 -1
- package/dist/permissions-RVCBhL2n.mjs.map +0 -1
|
@@ -1,2137 +1,8 @@
|
|
|
1
|
-
import { t as
|
|
2
|
-
import { c as PluginCapabilities, f as CoreBase, i as PluginCtor, n as Plugin, o as ShutdownPhase, r as PluginArgs, s as StartupPhase } from "./Plugin-CNyRKDHT.mjs";
|
|
1
|
+
import { _ as Transport, a as PluginCtor, b as Bus, c as ShutdownPhase, g as RuntimeAssert, h as Runtime, i as PluginArgs, l as StartupPhase, n as Initializeable, o as PluginLike, p as ChannelKeyAssert, t as CoreParamAssert, u as PluginCapabilities, v as TransportAssert, y as CoreBase } from "./Plugin-3rlH0uxH.mjs";
|
|
3
2
|
import { Logger } from "@seedcord/logger";
|
|
4
|
-
import {
|
|
5
|
-
import { Config, HealthCheckConfig, HealthCheckOption, IRateLimiter, Store, TypedExclude } from "@seedcord/types";
|
|
3
|
+
import { Config, HealthCheckConfig, HealthCheckOption, HmrAware, HmrUpdateEvent, IRateLimiter, Store } from "@seedcord/types";
|
|
6
4
|
|
|
7
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/characters.d.ts
|
|
8
|
-
/**
|
|
9
|
-
Matches any digit as a string ('0'-'9').
|
|
10
|
-
|
|
11
|
-
@example
|
|
12
|
-
```
|
|
13
|
-
import type {DigitCharacter} from 'type-fest';
|
|
14
|
-
|
|
15
|
-
const a: DigitCharacter = '0'; // Valid
|
|
16
|
-
// @ts-expect-error
|
|
17
|
-
const b: DigitCharacter = 0; // Invalid
|
|
18
|
-
```
|
|
19
|
-
|
|
20
|
-
@category Type
|
|
21
|
-
*/
|
|
22
|
-
type DigitCharacter = '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9';
|
|
23
|
-
//#endregion
|
|
24
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-intersection.d.ts
|
|
25
|
-
/**
|
|
26
|
-
Convert a union type to an intersection type.
|
|
27
|
-
|
|
28
|
-
Inspired by [this Stack Overflow answer](https://stackoverflow.com/a/50375286/2172153).
|
|
29
|
-
|
|
30
|
-
@example
|
|
31
|
-
```
|
|
32
|
-
import type {UnionToIntersection} from 'type-fest';
|
|
33
|
-
|
|
34
|
-
type Union = {the(): void} | {great(arg: string): void} | {escape: boolean};
|
|
35
|
-
|
|
36
|
-
type Intersection = UnionToIntersection<Union>;
|
|
37
|
-
//=> {the(): void} & {great(arg: string): void} & {escape: boolean}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
@category Type
|
|
41
|
-
*/
|
|
42
|
-
type UnionToIntersection<Union> = (// `extends unknown` is always going to be the case and is used to convert the
|
|
43
|
-
// `Union` into a [distributive conditional
|
|
44
|
-
// type](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-8.html#distributive-conditional-types).
|
|
45
|
-
Union extends unknown // The union type is used as the only argument to a function since the union
|
|
46
|
-
// of function arguments is an intersection.
|
|
47
|
-
? (distributedUnion: Union) => void // This won't happen.
|
|
48
|
-
: never // Infer the `Intersection` type since TypeScript represents the positional
|
|
49
|
-
// arguments of unions of functions as an intersection of the union.
|
|
50
|
-
) extends ((mergedIntersection: infer Intersection) => void) // The `& Union` is to ensure result of `UnionToIntersection<A | B>` is always assignable to `A | B`
|
|
51
|
-
? Intersection & Union : never;
|
|
52
|
-
//#endregion
|
|
53
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-any.d.ts
|
|
54
|
-
/**
|
|
55
|
-
Returns a boolean for whether the given type is `any`.
|
|
56
|
-
|
|
57
|
-
@link https://stackoverflow.com/a/49928360/1490091
|
|
58
|
-
|
|
59
|
-
Useful in type utilities, such as disallowing `any`s to be passed to a function.
|
|
60
|
-
|
|
61
|
-
@example
|
|
62
|
-
```
|
|
63
|
-
import type {IsAny} from 'type-fest';
|
|
64
|
-
|
|
65
|
-
const typedObject = {a: 1, b: 2} as const;
|
|
66
|
-
const anyObject: any = {a: 1, b: 2};
|
|
67
|
-
|
|
68
|
-
function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
|
|
69
|
-
return object[key];
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
const typedA = get(typedObject, 'a');
|
|
73
|
-
//=> 1
|
|
74
|
-
|
|
75
|
-
const anyA = get(anyObject, 'a');
|
|
76
|
-
//=> any
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
@category Type Guard
|
|
80
|
-
@category Utilities
|
|
81
|
-
*/
|
|
82
|
-
type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
|
|
83
|
-
//#endregion
|
|
84
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-optional-key-of.d.ts
|
|
85
|
-
/**
|
|
86
|
-
Returns a boolean for whether the given key is an optional key of type.
|
|
87
|
-
|
|
88
|
-
This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
|
|
89
|
-
|
|
90
|
-
@example
|
|
91
|
-
```
|
|
92
|
-
import type {IsOptionalKeyOf} from 'type-fest';
|
|
93
|
-
|
|
94
|
-
type User = {
|
|
95
|
-
name: string;
|
|
96
|
-
surname: string;
|
|
97
|
-
|
|
98
|
-
luckyNumber?: number;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
type Admin = {
|
|
102
|
-
name: string;
|
|
103
|
-
surname?: string;
|
|
104
|
-
};
|
|
105
|
-
|
|
106
|
-
type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
|
|
107
|
-
//=> true
|
|
108
|
-
|
|
109
|
-
type T2 = IsOptionalKeyOf<User, 'name'>;
|
|
110
|
-
//=> false
|
|
111
|
-
|
|
112
|
-
type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
|
|
113
|
-
//=> boolean
|
|
114
|
-
|
|
115
|
-
type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
|
|
116
|
-
//=> false
|
|
117
|
-
|
|
118
|
-
type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
|
|
119
|
-
//=> boolean
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
@category Type Guard
|
|
123
|
-
@category Utilities
|
|
124
|
-
*/
|
|
125
|
-
type IsOptionalKeyOf<Type extends object, Key extends keyof Type> = IsAny<Type | Key> extends true ? never : Key extends keyof Type ? Type extends Record<Key, Type[Key]> ? false : true : false;
|
|
126
|
-
//#endregion
|
|
127
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/optional-keys-of.d.ts
|
|
128
|
-
/**
|
|
129
|
-
Extract all optional keys from the given type.
|
|
130
|
-
|
|
131
|
-
This is useful when you want to create a new type that contains different type values for the optional keys only.
|
|
132
|
-
|
|
133
|
-
@example
|
|
134
|
-
```
|
|
135
|
-
import type {OptionalKeysOf, Except} from 'type-fest';
|
|
136
|
-
|
|
137
|
-
type User = {
|
|
138
|
-
name: string;
|
|
139
|
-
surname: string;
|
|
140
|
-
|
|
141
|
-
luckyNumber?: number;
|
|
142
|
-
};
|
|
143
|
-
|
|
144
|
-
const REMOVE_FIELD = Symbol('remove field symbol');
|
|
145
|
-
type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
|
|
146
|
-
[Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const update1: UpdateOperation<User> = {
|
|
150
|
-
name: 'Alice',
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
const update2: UpdateOperation<User> = {
|
|
154
|
-
name: 'Bob',
|
|
155
|
-
luckyNumber: REMOVE_FIELD,
|
|
156
|
-
};
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
@category Utilities
|
|
160
|
-
*/
|
|
161
|
-
type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
162
|
-
? (keyof { [Key in keyof Type as IsOptionalKeyOf<Type, Key> extends false ? never : Key]: never }) & keyof Type // Intersect with `keyof Type` to ensure result of `OptionalKeysOf<Type>` is always assignable to `keyof Type`
|
|
163
|
-
: never;
|
|
164
|
-
//#endregion
|
|
165
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/required-keys-of.d.ts
|
|
166
|
-
/**
|
|
167
|
-
Extract all required keys from the given type.
|
|
168
|
-
|
|
169
|
-
This is useful when you want to create a new type that contains different type values for the required keys only or use the list of keys for validation purposes, etc...
|
|
170
|
-
|
|
171
|
-
@example
|
|
172
|
-
```
|
|
173
|
-
import type {RequiredKeysOf} from 'type-fest';
|
|
174
|
-
|
|
175
|
-
declare function createValidation<
|
|
176
|
-
Entity extends object,
|
|
177
|
-
Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
|
|
178
|
-
>(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
|
|
179
|
-
|
|
180
|
-
type User = {
|
|
181
|
-
name: string;
|
|
182
|
-
surname: string;
|
|
183
|
-
luckyNumber?: number;
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
const validator1 = createValidation<User>('name', value => value.length < 25);
|
|
187
|
-
const validator2 = createValidation<User>('surname', value => value.length < 25);
|
|
188
|
-
|
|
189
|
-
// @ts-expect-error
|
|
190
|
-
const validator3 = createValidation<User>('luckyNumber', value => value > 0);
|
|
191
|
-
// Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
|
|
192
|
-
```
|
|
193
|
-
|
|
194
|
-
@category Utilities
|
|
195
|
-
*/
|
|
196
|
-
type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
|
|
197
|
-
? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
|
|
198
|
-
//#endregion
|
|
199
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/if.d.ts
|
|
200
|
-
/**
|
|
201
|
-
An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
|
|
202
|
-
|
|
203
|
-
Use-cases:
|
|
204
|
-
- You can use this in combination with `Is*` types to create an if-else-like experience. For example, `If<IsAny<any>, 'is any', 'not any'>`.
|
|
205
|
-
|
|
206
|
-
Note:
|
|
207
|
-
- Returns a union of if branch and else branch if the given type is `boolean` or `any`. For example, `If<boolean, 'Y', 'N'>` will return `'Y' | 'N'`.
|
|
208
|
-
- Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
|
|
209
|
-
|
|
210
|
-
@example
|
|
211
|
-
```
|
|
212
|
-
import type {If} from 'type-fest';
|
|
213
|
-
|
|
214
|
-
type A = If<true, 'yes', 'no'>;
|
|
215
|
-
//=> 'yes'
|
|
216
|
-
|
|
217
|
-
type B = If<false, 'yes', 'no'>;
|
|
218
|
-
//=> 'no'
|
|
219
|
-
|
|
220
|
-
type C = If<boolean, 'yes', 'no'>;
|
|
221
|
-
//=> 'yes' | 'no'
|
|
222
|
-
|
|
223
|
-
type D = If<any, 'yes', 'no'>;
|
|
224
|
-
//=> 'yes' | 'no'
|
|
225
|
-
|
|
226
|
-
type E = If<never, 'yes', 'no'>;
|
|
227
|
-
//=> 'no'
|
|
228
|
-
```
|
|
229
|
-
|
|
230
|
-
@example
|
|
231
|
-
```
|
|
232
|
-
import type {If, IsAny, IsNever} from 'type-fest';
|
|
233
|
-
|
|
234
|
-
type A = If<IsAny<unknown>, 'is any', 'not any'>;
|
|
235
|
-
//=> 'not any'
|
|
236
|
-
|
|
237
|
-
type B = If<IsNever<never>, 'is never', 'not never'>;
|
|
238
|
-
//=> 'is never'
|
|
239
|
-
```
|
|
240
|
-
|
|
241
|
-
@example
|
|
242
|
-
```
|
|
243
|
-
import type {If, IsEqual} from 'type-fest';
|
|
244
|
-
|
|
245
|
-
type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
|
|
246
|
-
|
|
247
|
-
type A = IfEqual<string, string, 'equal', 'not equal'>;
|
|
248
|
-
//=> 'equal'
|
|
249
|
-
|
|
250
|
-
type B = IfEqual<string, number, 'equal', 'not equal'>;
|
|
251
|
-
//=> 'not equal'
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
Note: Sometimes using the `If` type can make an implementation non–tail-recursive, which can impact performance. In such cases, it’s better to use a conditional directly. Refer to the following example:
|
|
255
|
-
|
|
256
|
-
@example
|
|
257
|
-
```
|
|
258
|
-
import type {If, IsEqual, StringRepeat} from 'type-fest';
|
|
259
|
-
|
|
260
|
-
type HundredZeroes = StringRepeat<'0', 100>;
|
|
261
|
-
|
|
262
|
-
// The following implementation is not tail recursive
|
|
263
|
-
type Includes<S extends string, Char extends string> =
|
|
264
|
-
S extends `${infer First}${infer Rest}`
|
|
265
|
-
? If<IsEqual<First, Char>,
|
|
266
|
-
'found',
|
|
267
|
-
Includes<Rest, Char>>
|
|
268
|
-
: 'not found';
|
|
269
|
-
|
|
270
|
-
// Hence, instantiations with long strings will fail
|
|
271
|
-
// @ts-expect-error
|
|
272
|
-
type Fails = Includes<HundredZeroes, '1'>;
|
|
273
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
274
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
275
|
-
|
|
276
|
-
// However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
|
|
277
|
-
type IncludesWithoutIf<S extends string, Char extends string> =
|
|
278
|
-
S extends `${infer First}${infer Rest}`
|
|
279
|
-
? IsEqual<First, Char> extends true
|
|
280
|
-
? 'found'
|
|
281
|
-
: IncludesWithoutIf<Rest, Char>
|
|
282
|
-
: 'not found';
|
|
283
|
-
|
|
284
|
-
// Now, instantiations with long strings will work
|
|
285
|
-
type Works = IncludesWithoutIf<HundredZeroes, '1'>;
|
|
286
|
-
//=> 'not found'
|
|
287
|
-
```
|
|
288
|
-
|
|
289
|
-
@category Type Guard
|
|
290
|
-
@category Utilities
|
|
291
|
-
*/
|
|
292
|
-
type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
|
|
293
|
-
//#endregion
|
|
294
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/unknown-array.d.ts
|
|
295
|
-
/**
|
|
296
|
-
Represents an array with `unknown` value.
|
|
297
|
-
|
|
298
|
-
Use case: You want a type that all arrays can be assigned to, but you don't care about the value.
|
|
299
|
-
|
|
300
|
-
@example
|
|
301
|
-
```
|
|
302
|
-
import type {UnknownArray} from 'type-fest';
|
|
303
|
-
|
|
304
|
-
type IsArray<T> = T extends UnknownArray ? true : false;
|
|
305
|
-
|
|
306
|
-
type A = IsArray<['foo']>;
|
|
307
|
-
//=> true
|
|
308
|
-
|
|
309
|
-
type B = IsArray<readonly number[]>;
|
|
310
|
-
//=> true
|
|
311
|
-
|
|
312
|
-
type C = IsArray<string>;
|
|
313
|
-
//=> false
|
|
314
|
-
```
|
|
315
|
-
|
|
316
|
-
@category Type
|
|
317
|
-
@category Array
|
|
318
|
-
*/
|
|
319
|
-
type UnknownArray = readonly unknown[];
|
|
320
|
-
//#endregion
|
|
321
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/type.d.ts
|
|
322
|
-
/**
|
|
323
|
-
Returns a boolean for whether A is false.
|
|
324
|
-
|
|
325
|
-
@example
|
|
326
|
-
```
|
|
327
|
-
type A = Not<true>;
|
|
328
|
-
//=> false
|
|
329
|
-
|
|
330
|
-
type B = Not<false>;
|
|
331
|
-
//=> true
|
|
332
|
-
```
|
|
333
|
-
*/
|
|
334
|
-
type Not<A extends boolean> = A extends true ? false : A extends false ? true : never;
|
|
335
|
-
/**
|
|
336
|
-
An if-else-like type that resolves depending on whether the given type is `any` or `never`.
|
|
337
|
-
|
|
338
|
-
@example
|
|
339
|
-
```
|
|
340
|
-
// When `T` is a NOT `any` or `never` (like `string`) => Returns `IfNotAnyOrNever` branch
|
|
341
|
-
type A = IfNotAnyOrNever<string, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
342
|
-
//=> 'VALID'
|
|
343
|
-
|
|
344
|
-
// When `T` is `any` => Returns `IfAny` branch
|
|
345
|
-
type B = IfNotAnyOrNever<any, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
346
|
-
//=> 'IS_ANY'
|
|
347
|
-
|
|
348
|
-
// When `T` is `never` => Returns `IfNever` branch
|
|
349
|
-
type C = IfNotAnyOrNever<never, 'VALID', 'IS_ANY', 'IS_NEVER'>;
|
|
350
|
-
//=> 'IS_NEVER'
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
Note: Wrapping a tail-recursive type with `IfNotAnyOrNever` makes the implementation non-tail-recursive. To fix this, move the recursion into a helper type. Refer to the following example:
|
|
354
|
-
|
|
355
|
-
@example
|
|
356
|
-
```ts
|
|
357
|
-
import type {StringRepeat} from 'type-fest';
|
|
358
|
-
|
|
359
|
-
type NineHundredNinetyNineSpaces = StringRepeat<' ', 999>;
|
|
360
|
-
|
|
361
|
-
// The following implementation is not tail recursive
|
|
362
|
-
type TrimLeft<S extends string> = IfNotAnyOrNever<S, S extends ` ${infer R}` ? TrimLeft<R> : S>;
|
|
363
|
-
|
|
364
|
-
// Hence, instantiations with long strings will fail
|
|
365
|
-
// @ts-expect-error
|
|
366
|
-
type T1 = TrimLeft<NineHundredNinetyNineSpaces>;
|
|
367
|
-
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
368
|
-
// Error: Type instantiation is excessively deep and possibly infinite.
|
|
369
|
-
|
|
370
|
-
// To fix this, move the recursion into a helper type
|
|
371
|
-
type TrimLeftOptimised<S extends string> = IfNotAnyOrNever<S, _TrimLeftOptimised<S>>;
|
|
372
|
-
|
|
373
|
-
type _TrimLeftOptimised<S extends string> = S extends ` ${infer R}` ? _TrimLeftOptimised<R> : S;
|
|
374
|
-
|
|
375
|
-
type T2 = TrimLeftOptimised<NineHundredNinetyNineSpaces>;
|
|
376
|
-
//=> ''
|
|
377
|
-
```
|
|
378
|
-
*/
|
|
379
|
-
type IfNotAnyOrNever<T, IfNotAnyOrNever, IfAny = any, IfNever = never> = If<IsAny<T>, IfAny, If<IsNever<T>, IfNever, IfNotAnyOrNever>>;
|
|
380
|
-
/**
|
|
381
|
-
Indicates the value of `exactOptionalPropertyTypes` compiler option.
|
|
382
|
-
*/
|
|
383
|
-
type IsExactOptionalPropertyTypesEnabled = [(string | undefined)?] extends [string?] ? false : true;
|
|
384
|
-
//#endregion
|
|
385
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/array.d.ts
|
|
386
|
-
/**
|
|
387
|
-
Transforms a tuple type by replacing it's rest element with a single element that has the same type as the rest element, while keeping all the non-rest elements intact.
|
|
388
|
-
|
|
389
|
-
@example
|
|
390
|
-
```
|
|
391
|
-
type A = CollapseRestElement<[string, string, ...number[]]>;
|
|
392
|
-
//=> [string, string, number]
|
|
393
|
-
|
|
394
|
-
type B = CollapseRestElement<[...string[], number, number]>;
|
|
395
|
-
//=> [string, number, number]
|
|
396
|
-
|
|
397
|
-
type C = CollapseRestElement<[string, string, ...Array<number | bigint>]>;
|
|
398
|
-
//=> [string, string, number | bigint]
|
|
399
|
-
|
|
400
|
-
type D = CollapseRestElement<[string, number]>;
|
|
401
|
-
//=> [string, number]
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
Note: Optional modifiers (`?`) are removed from elements unless the `exactOptionalPropertyTypes` compiler option is disabled. When disabled, there's an additional `| undefined` for optional elements.
|
|
405
|
-
|
|
406
|
-
@example
|
|
407
|
-
```
|
|
408
|
-
// `exactOptionalPropertyTypes` enabled
|
|
409
|
-
type A = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
410
|
-
//=> [string, string, number]
|
|
411
|
-
|
|
412
|
-
// `exactOptionalPropertyTypes` disabled
|
|
413
|
-
type B = CollapseRestElement<[string?, string?, ...number[]]>;
|
|
414
|
-
//=> [string | undefined, string | undefined, number]
|
|
415
|
-
```
|
|
416
|
-
*/
|
|
417
|
-
type CollapseRestElement<TArray extends UnknownArray> = IfNotAnyOrNever<TArray, _CollapseRestElement<TArray>>;
|
|
418
|
-
type _CollapseRestElement<TArray extends UnknownArray, ForwardAccumulator extends UnknownArray = [], BackwardAccumulator extends UnknownArray = []> = TArray extends UnknownArray // For distributing `TArray`
|
|
419
|
-
? keyof TArray & `${number}` extends never // Enters this branch, if `TArray` is empty (e.g., []),
|
|
420
|
-
// or `TArray` contains no non-rest elements preceding the rest element (e.g., `[...string[]]` or `[...string[], string]`).
|
|
421
|
-
? TArray extends readonly [...infer Rest, infer Last] ? _CollapseRestElement<Rest, ForwardAccumulator, [Last, ...BackwardAccumulator]> // Accumulate elements that are present after the rest element.
|
|
422
|
-
: TArray extends readonly [] ? [...ForwardAccumulator, ...BackwardAccumulator] : [...ForwardAccumulator, TArray[number], ...BackwardAccumulator] // Add the rest element between the accumulated elements.
|
|
423
|
-
: TArray extends readonly [(infer First)?, ...infer Rest] ? _CollapseRestElement<Rest, [...ForwardAccumulator, '0' extends OptionalKeysOf<TArray> ? If<IsExactOptionalPropertyTypesEnabled, First, First | undefined> // Add `| undefined` for optional elements, if `exactOptionalPropertyTypes` is disabled.
|
|
424
|
-
: First], BackwardAccumulator> : never // Should never happen, since `[(infer First)?, ...infer Rest]` is a top-type for arrays.
|
|
425
|
-
: never; // Should never happen
|
|
426
|
-
//#endregion
|
|
427
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/numeric.d.ts
|
|
428
|
-
type _Numeric = number | bigint;
|
|
429
|
-
type Zero = 0 | 0n;
|
|
430
|
-
/**
|
|
431
|
-
Matches the hidden `Infinity` type.
|
|
432
|
-
|
|
433
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
434
|
-
|
|
435
|
-
@see {@link NegativeInfinity}
|
|
436
|
-
|
|
437
|
-
@category Numeric
|
|
438
|
-
*/
|
|
439
|
-
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
440
|
-
// eslint-disable-next-line no-loss-of-precision
|
|
441
|
-
type PositiveInfinity = 1e999;
|
|
442
|
-
/**
|
|
443
|
-
Matches the hidden `-Infinity` type.
|
|
444
|
-
|
|
445
|
-
Please upvote [this issue](https://github.com/microsoft/TypeScript/issues/32277) if you want to have this type as a built-in in TypeScript.
|
|
446
|
-
|
|
447
|
-
@see {@link PositiveInfinity}
|
|
448
|
-
|
|
449
|
-
@category Numeric
|
|
450
|
-
*/
|
|
451
|
-
// See https://github.com/microsoft/TypeScript/issues/31752
|
|
452
|
-
// eslint-disable-next-line no-loss-of-precision
|
|
453
|
-
type NegativeInfinity = -1e999;
|
|
454
|
-
/**
|
|
455
|
-
A negative `number`/`bigint` (`-∞ < x < 0`)
|
|
456
|
-
|
|
457
|
-
Use-case: Validating and documenting parameters.
|
|
458
|
-
|
|
459
|
-
@see {@link NegativeInteger}
|
|
460
|
-
@see {@link NonNegative}
|
|
461
|
-
|
|
462
|
-
@category Numeric
|
|
463
|
-
*/
|
|
464
|
-
type Negative<T extends _Numeric> = T extends Zero ? never : `${T}` extends `-${string}` ? T : never;
|
|
465
|
-
/**
|
|
466
|
-
Returns a boolean for whether the given number is a negative number.
|
|
467
|
-
|
|
468
|
-
@see {@link Negative}
|
|
469
|
-
|
|
470
|
-
@example
|
|
471
|
-
```
|
|
472
|
-
import type {IsNegative} from 'type-fest';
|
|
473
|
-
|
|
474
|
-
type ShouldBeFalse = IsNegative<1>;
|
|
475
|
-
type ShouldBeTrue = IsNegative<-1>;
|
|
476
|
-
```
|
|
477
|
-
|
|
478
|
-
@category Numeric
|
|
479
|
-
*/
|
|
480
|
-
type IsNegative<T extends _Numeric> = T extends Negative<T> ? true : false;
|
|
481
|
-
//#endregion
|
|
482
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/tuple-of.d.ts
|
|
483
|
-
/**
|
|
484
|
-
Create a tuple type of the specified length with elements of the specified type.
|
|
485
|
-
|
|
486
|
-
@example
|
|
487
|
-
```
|
|
488
|
-
import type {TupleOf} from 'type-fest';
|
|
489
|
-
|
|
490
|
-
type RGB = TupleOf<3, number>;
|
|
491
|
-
//=> [number, number, number]
|
|
492
|
-
|
|
493
|
-
type Line = TupleOf<2, {x: number; y: number}>;
|
|
494
|
-
//=> [{x: number; y: number}, {x: number; y: number}]
|
|
495
|
-
|
|
496
|
-
type TicTacToeBoard = TupleOf<3, TupleOf<3, 'X' | 'O' | null>>;
|
|
497
|
-
//=> [['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null], ['X' | 'O' | null, 'X' | 'O' | null, 'X' | 'O' | null]]
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
@example
|
|
501
|
-
```
|
|
502
|
-
import type {TupleOf} from 'type-fest';
|
|
503
|
-
|
|
504
|
-
type Range<Start extends number, End extends number> = Exclude<keyof TupleOf<End>, keyof TupleOf<Start>>;
|
|
505
|
-
|
|
506
|
-
type ZeroToFour = Range<0, 5>;
|
|
507
|
-
//=> '0' | '1' | '2' | '3' | '4'
|
|
508
|
-
|
|
509
|
-
type ThreeToEight = Range<3, 9>;
|
|
510
|
-
//=> '3' | '4' | '5' | '6' | '7' | '8'
|
|
511
|
-
```
|
|
512
|
-
|
|
513
|
-
Note: If the specified length is the non-literal `number` type, the result will not be a tuple but a regular array.
|
|
514
|
-
|
|
515
|
-
@example
|
|
516
|
-
```
|
|
517
|
-
import type {TupleOf} from 'type-fest';
|
|
518
|
-
|
|
519
|
-
type StringArray = TupleOf<number, string>;
|
|
520
|
-
//=> string[]
|
|
521
|
-
```
|
|
522
|
-
|
|
523
|
-
Note: If the type for elements is not specified, it will default to `unknown`.
|
|
524
|
-
|
|
525
|
-
@example
|
|
526
|
-
```
|
|
527
|
-
import type {TupleOf} from 'type-fest';
|
|
528
|
-
|
|
529
|
-
type UnknownTriplet = TupleOf<3>;
|
|
530
|
-
//=> [unknown, unknown, unknown]
|
|
531
|
-
```
|
|
532
|
-
|
|
533
|
-
Note: If the specified length is negative, the result will be an empty tuple.
|
|
534
|
-
|
|
535
|
-
@example
|
|
536
|
-
```
|
|
537
|
-
import type {TupleOf} from 'type-fest';
|
|
538
|
-
|
|
539
|
-
type EmptyTuple = TupleOf<-3, string>;
|
|
540
|
-
//=> []
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
Note: If the specified length has a decimal part, the decimal part will be ignored.
|
|
544
|
-
|
|
545
|
-
@example
|
|
546
|
-
```
|
|
547
|
-
import type {TupleOf} from 'type-fest';
|
|
548
|
-
|
|
549
|
-
type DecimalLength = TupleOf<3.5, string>;
|
|
550
|
-
//=> [string, string, string]
|
|
551
|
-
```
|
|
552
|
-
|
|
553
|
-
Note: If you need a readonly tuple, simply wrap this type with `Readonly`, for example, to create `readonly [number, number, number]` use `Readonly<TupleOf<3, number>>`.
|
|
554
|
-
|
|
555
|
-
@category Array
|
|
556
|
-
*/
|
|
557
|
-
type TupleOf<Length extends number, Fill = unknown> = IfNotAnyOrNever<Length, _TupleOf<If<IsNegative<Length>, 0, Length>, Fill>, Fill[], []>;
|
|
558
|
-
type _TupleOf<Length extends number, Fill> = number extends Length ? Fill[] : BuildTupleDigitByDigit<`${Length}`, Fill>;
|
|
559
|
-
type BuildTupleDigitByDigit<Length extends string, Fill, Accumulator extends UnknownArray = []> = Length extends `${infer First extends DigitCharacter}${infer Rest}` ? BuildTupleDigitByDigit<Rest, Fill, [...RepeatTupleTenTimes<Accumulator>, ...DigitTupleOf<First, Fill>]> : Accumulator;
|
|
560
|
-
type RepeatTupleTenTimes<Tuple extends UnknownArray> = [...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple, ...Tuple];
|
|
561
|
-
type DigitTupleOf<Digit extends DigitCharacter, Fill> = [[], [Fill], [Fill, Fill], [Fill, Fill, Fill], [Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill], [Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill, Fill]][Digit];
|
|
562
|
-
//#endregion
|
|
563
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/string.d.ts
|
|
564
|
-
/**
|
|
565
|
-
Converts a numeric string to a number.
|
|
566
|
-
|
|
567
|
-
@example
|
|
568
|
-
```
|
|
569
|
-
type PositiveInt = StringToNumber<'1234'>;
|
|
570
|
-
//=> 1234
|
|
571
|
-
|
|
572
|
-
type NegativeInt = StringToNumber<'-1234'>;
|
|
573
|
-
//=> -1234
|
|
574
|
-
|
|
575
|
-
type PositiveFloat = StringToNumber<'1234.56'>;
|
|
576
|
-
//=> 1234.56
|
|
577
|
-
|
|
578
|
-
type NegativeFloat = StringToNumber<'-1234.56'>;
|
|
579
|
-
//=> -1234.56
|
|
580
|
-
|
|
581
|
-
type PositiveInfinity = StringToNumber<'Infinity'>;
|
|
582
|
-
//=> Infinity
|
|
583
|
-
|
|
584
|
-
type NegativeInfinity = StringToNumber<'-Infinity'>;
|
|
585
|
-
//=> -Infinity
|
|
586
|
-
```
|
|
587
|
-
|
|
588
|
-
@category String
|
|
589
|
-
@category Numeric
|
|
590
|
-
@category Template literal
|
|
591
|
-
*/
|
|
592
|
-
type StringToNumber<S extends string> = S extends `${infer N extends number}` ? N : S extends 'Infinity' ? PositiveInfinity : S extends '-Infinity' ? NegativeInfinity : never;
|
|
593
|
-
/**
|
|
594
|
-
Returns an array of the characters of the string.
|
|
595
|
-
|
|
596
|
-
@example
|
|
597
|
-
```
|
|
598
|
-
type A = StringToArray<'abcde'>;
|
|
599
|
-
//=> ['a', 'b', 'c', 'd', 'e']
|
|
600
|
-
|
|
601
|
-
type B = StringToArray<string>;
|
|
602
|
-
//=> never
|
|
603
|
-
```
|
|
604
|
-
|
|
605
|
-
@category String
|
|
606
|
-
*/
|
|
607
|
-
type StringToArray<S extends string, Result extends string[] = []> = string extends S ? never : S extends `${infer F}${infer R}` ? StringToArray<R, [...Result, F]> : Result;
|
|
608
|
-
/**
|
|
609
|
-
Returns the length of the given string.
|
|
610
|
-
|
|
611
|
-
@example
|
|
612
|
-
```
|
|
613
|
-
type A = StringLength<'abcde'>;
|
|
614
|
-
//=> 5
|
|
615
|
-
|
|
616
|
-
type B = StringLength<string>;
|
|
617
|
-
//=> never
|
|
618
|
-
```
|
|
619
|
-
|
|
620
|
-
@category String
|
|
621
|
-
@category Template literal
|
|
622
|
-
*/
|
|
623
|
-
type StringLength<S extends string> = string extends S ? never : StringToArray<S>['length'];
|
|
624
|
-
/**
|
|
625
|
-
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both numeric strings and have the same length.
|
|
626
|
-
|
|
627
|
-
@example
|
|
628
|
-
```
|
|
629
|
-
type A = SameLengthPositiveNumericStringGt<'50', '10'>;
|
|
630
|
-
//=> true
|
|
631
|
-
|
|
632
|
-
type B = SameLengthPositiveNumericStringGt<'10', '10'>;
|
|
633
|
-
//=> false
|
|
634
|
-
```
|
|
635
|
-
*/
|
|
636
|
-
type SameLengthPositiveNumericStringGt<A extends string, B extends string> = A extends `${infer FirstA}${infer RestA}` ? B extends `${infer FirstB}${infer RestB}` ? FirstA extends FirstB ? SameLengthPositiveNumericStringGt<RestA, RestB> : PositiveNumericCharacterGt<FirstA, FirstB> : never : false;
|
|
637
|
-
type NumericString = '0123456789';
|
|
638
|
-
/**
|
|
639
|
-
Returns a boolean for whether `A` is greater than `B`, where `A` and `B` are both positive numeric strings.
|
|
640
|
-
|
|
641
|
-
@example
|
|
642
|
-
```
|
|
643
|
-
type A = PositiveNumericStringGt<'500', '1'>;
|
|
644
|
-
//=> true
|
|
645
|
-
|
|
646
|
-
type B = PositiveNumericStringGt<'1', '1'>;
|
|
647
|
-
//=> false
|
|
648
|
-
|
|
649
|
-
type C = PositiveNumericStringGt<'1', '500'>;
|
|
650
|
-
//=> false
|
|
651
|
-
```
|
|
652
|
-
*/
|
|
653
|
-
type PositiveNumericStringGt<A extends string, B extends string> = A extends B ? false : [TupleOf<StringLength<A>, 0>, TupleOf<StringLength<B>, 0>] extends infer R extends [readonly unknown[], readonly unknown[]] ? R[0] extends [...R[1], ...infer Remain extends readonly unknown[]] ? 0 extends Remain['length'] ? SameLengthPositiveNumericStringGt<A, B> : true : false : never;
|
|
654
|
-
/**
|
|
655
|
-
Returns a boolean for whether `A` represents a number greater than `B`, where `A` and `B` are both positive numeric characters.
|
|
656
|
-
|
|
657
|
-
@example
|
|
658
|
-
```
|
|
659
|
-
type A = PositiveNumericCharacterGt<'5', '1'>;
|
|
660
|
-
//=> true
|
|
661
|
-
|
|
662
|
-
type B = PositiveNumericCharacterGt<'1', '1'>;
|
|
663
|
-
//=> false
|
|
664
|
-
```
|
|
665
|
-
*/
|
|
666
|
-
type PositiveNumericCharacterGt<A extends string, B extends string> = NumericString extends `${infer HeadA}${A}${infer TailA}` ? NumericString extends `${infer HeadB}${B}${infer TailB}` ? HeadA extends `${HeadB}${infer _}${infer __}` ? true : false : never : never;
|
|
667
|
-
//#endregion
|
|
668
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/numeric.d.ts
|
|
669
|
-
/**
|
|
670
|
-
Returns the number with reversed sign.
|
|
671
|
-
|
|
672
|
-
@example
|
|
673
|
-
```
|
|
674
|
-
type A = ReverseSign<-1>;
|
|
675
|
-
//=> 1
|
|
676
|
-
|
|
677
|
-
type B = ReverseSign<1>;
|
|
678
|
-
//=> -1
|
|
679
|
-
|
|
680
|
-
type C = ReverseSign<NegativeInfinity>;
|
|
681
|
-
//=> PositiveInfinity
|
|
682
|
-
|
|
683
|
-
type D = ReverseSign<PositiveInfinity>;
|
|
684
|
-
//=> NegativeInfinity
|
|
685
|
-
```
|
|
686
|
-
*/
|
|
687
|
-
type ReverseSign<N extends number> = // Handle edge cases
|
|
688
|
-
N extends 0 ? 0 : N extends PositiveInfinity ? NegativeInfinity : N extends NegativeInfinity ? PositiveInfinity // Handle negative numbers
|
|
689
|
-
: `${N}` extends `-${infer P extends number}` ? P // Handle positive numbers
|
|
690
|
-
: `-${N}` extends `${infer R extends number}` ? R : never;
|
|
691
|
-
//#endregion
|
|
692
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/simplify.d.ts
|
|
693
|
-
/**
|
|
694
|
-
Useful to flatten the type output to improve type hints shown in editors. And also to transform an interface into a type to aide with assignability.
|
|
695
|
-
|
|
696
|
-
@example
|
|
697
|
-
```
|
|
698
|
-
import type {Simplify} from 'type-fest';
|
|
699
|
-
|
|
700
|
-
type PositionProps = {
|
|
701
|
-
top: number;
|
|
702
|
-
left: number;
|
|
703
|
-
};
|
|
704
|
-
|
|
705
|
-
type SizeProps = {
|
|
706
|
-
width: number;
|
|
707
|
-
height: number;
|
|
708
|
-
};
|
|
709
|
-
|
|
710
|
-
// In your editor, hovering over `Props` will show a flattened object with all the properties.
|
|
711
|
-
type Props = Simplify<PositionProps & SizeProps>;
|
|
712
|
-
```
|
|
713
|
-
|
|
714
|
-
Sometimes it is desired to pass a value as a function argument that has a different type. At first inspection it may seem assignable, and then you discover it is not because the `value`'s type definition was defined as an interface. In the following example, `fn` requires an argument of type `Record<string, unknown>`. If the value is defined as a literal, then it is assignable. And if the `value` is defined as type using the `Simplify` utility the value is assignable. But if the `value` is defined as an interface, it is not assignable because the interface is not sealed and elsewhere a non-string property could be added to the interface.
|
|
715
|
-
|
|
716
|
-
If the type definition must be an interface (perhaps it was defined in a third-party npm package), then the `value` can be defined as `const value: Simplify<SomeInterface> = ...`. Then `value` will be assignable to the `fn` argument. Or the `value` can be cast as `Simplify<SomeInterface>` if you can't re-declare the `value`.
|
|
717
|
-
|
|
718
|
-
@example
|
|
719
|
-
```
|
|
720
|
-
import type {Simplify} from 'type-fest';
|
|
721
|
-
|
|
722
|
-
interface SomeInterface {
|
|
723
|
-
foo: number;
|
|
724
|
-
bar?: string;
|
|
725
|
-
baz: number | undefined;
|
|
726
|
-
}
|
|
727
|
-
|
|
728
|
-
type SomeType = {
|
|
729
|
-
foo: number;
|
|
730
|
-
bar?: string;
|
|
731
|
-
baz: number | undefined;
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
const literal = {foo: 123, bar: 'hello', baz: 456};
|
|
735
|
-
const someType: SomeType = literal;
|
|
736
|
-
const someInterface: SomeInterface = literal;
|
|
737
|
-
|
|
738
|
-
declare function fn(object: Record<string, unknown>): void;
|
|
739
|
-
|
|
740
|
-
fn(literal); // Good: literal object type is sealed
|
|
741
|
-
fn(someType); // Good: type is sealed
|
|
742
|
-
// @ts-expect-error
|
|
743
|
-
fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
|
|
744
|
-
fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
|
|
745
|
-
```
|
|
746
|
-
|
|
747
|
-
@link https://github.com/microsoft/TypeScript/issues/15300
|
|
748
|
-
@see {@link SimplifyDeep}
|
|
749
|
-
@category Object
|
|
750
|
-
*/
|
|
751
|
-
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
|
|
752
|
-
//#endregion
|
|
753
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/is-equal.d.ts
|
|
754
|
-
/**
|
|
755
|
-
Returns a boolean for whether the two given types are equal.
|
|
756
|
-
|
|
757
|
-
@link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
|
|
758
|
-
@link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
|
|
759
|
-
|
|
760
|
-
Use-cases:
|
|
761
|
-
- If you want to make a conditional branch based on the result of a comparison of two types.
|
|
762
|
-
|
|
763
|
-
@example
|
|
764
|
-
```
|
|
765
|
-
import type {IsEqual} from 'type-fest';
|
|
766
|
-
|
|
767
|
-
// This type returns a boolean for whether the given array includes the given item.
|
|
768
|
-
// `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
|
|
769
|
-
type Includes<Value extends readonly any[], Item> =
|
|
770
|
-
Value extends readonly [Value[0], ...infer rest]
|
|
771
|
-
? IsEqual<Value[0], Item> extends true
|
|
772
|
-
? true
|
|
773
|
-
: Includes<rest, Item>
|
|
774
|
-
: false;
|
|
775
|
-
```
|
|
776
|
-
|
|
777
|
-
@category Type Guard
|
|
778
|
-
@category Utilities
|
|
779
|
-
*/
|
|
780
|
-
type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
|
|
781
|
-
// This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
|
|
782
|
-
type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
|
|
783
|
-
//#endregion
|
|
784
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/omit-index-signature.d.ts
|
|
785
|
-
/**
|
|
786
|
-
Omit any index signatures from the given object type, leaving only explicitly defined properties.
|
|
787
|
-
|
|
788
|
-
This is the counterpart of `PickIndexSignature`.
|
|
789
|
-
|
|
790
|
-
Use-cases:
|
|
791
|
-
- Remove overly permissive signatures from third-party types.
|
|
792
|
-
|
|
793
|
-
This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
|
|
794
|
-
|
|
795
|
-
It relies on the fact that an empty object (`{}`) is assignable to an object with just an index signature, like `Record<string, unknown>`, but not to an object with explicitly defined keys, like `Record<'foo' | 'bar', unknown>`.
|
|
796
|
-
|
|
797
|
-
(The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
|
|
798
|
-
|
|
799
|
-
```
|
|
800
|
-
const indexed: Record<string, unknown> = {}; // Allowed
|
|
801
|
-
|
|
802
|
-
// @ts-expect-error
|
|
803
|
-
const keyed: Record<'foo', unknown> = {}; // Error
|
|
804
|
-
// TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
|
|
805
|
-
```
|
|
806
|
-
|
|
807
|
-
Instead of causing a type error like the above, you can also use a [conditional type](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html) to test whether a type is assignable to another:
|
|
808
|
-
|
|
809
|
-
```
|
|
810
|
-
type Indexed = {} extends Record<string, unknown>
|
|
811
|
-
? '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
812
|
-
: '❌ `{}` is NOT assignable to `Record<string, unknown>`';
|
|
813
|
-
|
|
814
|
-
type IndexedResult = Indexed;
|
|
815
|
-
//=> '✅ `{}` is assignable to `Record<string, unknown>`'
|
|
816
|
-
|
|
817
|
-
type Keyed = {} extends Record<'foo' | 'bar', unknown>
|
|
818
|
-
? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
819
|
-
: '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
|
|
820
|
-
|
|
821
|
-
type KeyedResult = Keyed;
|
|
822
|
-
//=> '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`'
|
|
823
|
-
```
|
|
824
|
-
|
|
825
|
-
Using a [mapped type](https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#further-exploration), you can then check for each `KeyType` of `ObjectType`...
|
|
826
|
-
|
|
827
|
-
```
|
|
828
|
-
type OmitIndexSignature<ObjectType> = {
|
|
829
|
-
[KeyType in keyof ObjectType // Map each key of `ObjectType`...
|
|
830
|
-
]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
|
|
831
|
-
};
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
|
|
835
|
-
|
|
836
|
-
```
|
|
837
|
-
type OmitIndexSignature<ObjectType> = {
|
|
838
|
-
[KeyType in keyof ObjectType
|
|
839
|
-
// Is `{}` assignable to `Record<KeyType, unknown>`?
|
|
840
|
-
as {} extends Record<KeyType, unknown>
|
|
841
|
-
? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
|
|
842
|
-
: KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
|
|
843
|
-
]: ObjectType[KeyType];
|
|
844
|
-
};
|
|
845
|
-
```
|
|
846
|
-
|
|
847
|
-
If `{}` is assignable, it means that `KeyType` is an index signature and we want to remove it. If it is not assignable, `KeyType` is a "real" key and we want to keep it.
|
|
848
|
-
|
|
849
|
-
@example
|
|
850
|
-
```
|
|
851
|
-
import type {OmitIndexSignature} from 'type-fest';
|
|
852
|
-
|
|
853
|
-
type Example = {
|
|
854
|
-
// These index signatures will be removed.
|
|
855
|
-
[x: string]: any;
|
|
856
|
-
[x: number]: any;
|
|
857
|
-
[x: symbol]: any;
|
|
858
|
-
[x: `head-${string}`]: string;
|
|
859
|
-
[x: `${string}-tail`]: string;
|
|
860
|
-
[x: `head-${string}-tail`]: string;
|
|
861
|
-
[x: `${bigint}`]: string;
|
|
862
|
-
[x: `embedded-${number}`]: string;
|
|
863
|
-
|
|
864
|
-
// These explicitly defined keys will remain.
|
|
865
|
-
foo: 'bar';
|
|
866
|
-
qux?: 'baz';
|
|
867
|
-
};
|
|
868
|
-
|
|
869
|
-
type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
|
|
870
|
-
//=> {foo: 'bar'; qux?: 'baz'}
|
|
871
|
-
```
|
|
872
|
-
|
|
873
|
-
@see {@link PickIndexSignature}
|
|
874
|
-
@category Object
|
|
875
|
-
*/
|
|
876
|
-
type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
|
|
877
|
-
//#endregion
|
|
878
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/pick-index-signature.d.ts
|
|
879
|
-
/**
|
|
880
|
-
Pick only index signatures from the given object type, leaving out all explicitly defined properties.
|
|
881
|
-
|
|
882
|
-
This is the counterpart of `OmitIndexSignature`.
|
|
883
|
-
|
|
884
|
-
@example
|
|
885
|
-
```
|
|
886
|
-
import type {PickIndexSignature} from 'type-fest';
|
|
887
|
-
|
|
888
|
-
declare const symbolKey: unique symbol;
|
|
889
|
-
|
|
890
|
-
type Example = {
|
|
891
|
-
// These index signatures will remain.
|
|
892
|
-
[x: string]: unknown;
|
|
893
|
-
[x: number]: unknown;
|
|
894
|
-
[x: symbol]: unknown;
|
|
895
|
-
[x: `head-${string}`]: string;
|
|
896
|
-
[x: `${string}-tail`]: string;
|
|
897
|
-
[x: `head-${string}-tail`]: string;
|
|
898
|
-
[x: `${bigint}`]: string;
|
|
899
|
-
[x: `embedded-${number}`]: string;
|
|
900
|
-
|
|
901
|
-
// These explicitly defined keys will be removed.
|
|
902
|
-
['kebab-case-key']: string;
|
|
903
|
-
[symbolKey]: string;
|
|
904
|
-
foo: 'bar';
|
|
905
|
-
qux?: 'baz';
|
|
906
|
-
};
|
|
907
|
-
|
|
908
|
-
type ExampleIndexSignature = PickIndexSignature<Example>;
|
|
909
|
-
// {
|
|
910
|
-
// [x: string]: unknown;
|
|
911
|
-
// [x: number]: unknown;
|
|
912
|
-
// [x: symbol]: unknown;
|
|
913
|
-
// [x: `head-${string}`]: string;
|
|
914
|
-
// [x: `${string}-tail`]: string;
|
|
915
|
-
// [x: `head-${string}-tail`]: string;
|
|
916
|
-
// [x: `${bigint}`]: string;
|
|
917
|
-
// [x: `embedded-${number}`]: string;
|
|
918
|
-
// }
|
|
919
|
-
```
|
|
920
|
-
|
|
921
|
-
@see {@link OmitIndexSignature}
|
|
922
|
-
@category Object
|
|
923
|
-
*/
|
|
924
|
-
type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
|
|
925
|
-
//#endregion
|
|
926
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/merge.d.ts
|
|
927
|
-
// Merges two objects without worrying about index signatures.
|
|
928
|
-
type SimpleMerge<Destination, Source> = Simplify<{ [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source>;
|
|
929
|
-
/**
|
|
930
|
-
Merge two types into a new type. Keys of the second type overrides keys of the first type.
|
|
931
|
-
|
|
932
|
-
This is different from the TypeScript `&` (intersection) operator. With `&`, conflicting property types are intersected, which often results in `never`. For example, `{a: string} & {a: number}` makes `a` become `string & number`, which resolves to `never`. With `Merge`, the second type's keys cleanly override the first, so `Merge<{a: string}, {a: number}>` gives `{a: number}` as expected. `Merge` also produces a flattened type (via `Simplify`), making it more readable in IDE tooltips compared to `A & B`.
|
|
933
|
-
|
|
934
|
-
@example
|
|
935
|
-
```
|
|
936
|
-
import type {Merge} from 'type-fest';
|
|
937
|
-
|
|
938
|
-
type Foo = {
|
|
939
|
-
a: string;
|
|
940
|
-
b: number;
|
|
941
|
-
};
|
|
942
|
-
|
|
943
|
-
type Bar = {
|
|
944
|
-
a: number; // Conflicts with Foo['a']
|
|
945
|
-
c: boolean;
|
|
946
|
-
};
|
|
947
|
-
|
|
948
|
-
// With `&`, `a` becomes `string & number` which is `never`. Not what you want.
|
|
949
|
-
type WithIntersection = (Foo & Bar)['a'];
|
|
950
|
-
//=> never
|
|
951
|
-
|
|
952
|
-
// With `Merge`, `a` is cleanly overridden to `number`.
|
|
953
|
-
type WithMerge = Merge<Foo, Bar>['a'];
|
|
954
|
-
//=> number
|
|
955
|
-
```
|
|
956
|
-
|
|
957
|
-
@example
|
|
958
|
-
```
|
|
959
|
-
import type {Merge} from 'type-fest';
|
|
960
|
-
|
|
961
|
-
type Foo = {
|
|
962
|
-
[x: string]: unknown;
|
|
963
|
-
[x: number]: unknown;
|
|
964
|
-
foo: string;
|
|
965
|
-
bar: symbol;
|
|
966
|
-
};
|
|
967
|
-
|
|
968
|
-
type Bar = {
|
|
969
|
-
[x: number]: number;
|
|
970
|
-
[x: symbol]: unknown;
|
|
971
|
-
bar: Date;
|
|
972
|
-
baz: boolean;
|
|
973
|
-
};
|
|
974
|
-
|
|
975
|
-
export type FooBar = Merge<Foo, Bar>;
|
|
976
|
-
//=> {
|
|
977
|
-
// [x: string]: unknown;
|
|
978
|
-
// [x: number]: number;
|
|
979
|
-
// [x: symbol]: unknown;
|
|
980
|
-
// foo: string;
|
|
981
|
-
// bar: Date;
|
|
982
|
-
// baz: boolean;
|
|
983
|
-
// }
|
|
984
|
-
```
|
|
985
|
-
|
|
986
|
-
Note: If you want a merge type that more accurately reflects the runtime behavior of object spread or `Object.assign`, refer to the {@link ObjectMerge} type.
|
|
987
|
-
|
|
988
|
-
@see {@link ObjectMerge}
|
|
989
|
-
@category Object
|
|
990
|
-
*/
|
|
991
|
-
type Merge<Destination, Source> = Destination extends unknown // For distributing `Destination`
|
|
992
|
-
? Source extends unknown // For distributing `Source`
|
|
993
|
-
? If<IsEqual<Destination, Source>, Destination, _Merge<Destination, Source>> : never // Should never happen
|
|
994
|
-
: never;
|
|
995
|
-
// Should never happen
|
|
996
|
-
type _Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
|
|
997
|
-
//#endregion
|
|
998
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/object.d.ts
|
|
999
|
-
/**
|
|
1000
|
-
Merges user specified options with default options.
|
|
1001
|
-
|
|
1002
|
-
@example
|
|
1003
|
-
```
|
|
1004
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1005
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1006
|
-
type SpecifiedOptions = {leavesOnly: true};
|
|
1007
|
-
|
|
1008
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1009
|
-
//=> {maxRecursionDepth: 10; leavesOnly: true}
|
|
1010
|
-
```
|
|
1011
|
-
|
|
1012
|
-
@example
|
|
1013
|
-
```
|
|
1014
|
-
// Complains if default values are not provided for optional options
|
|
1015
|
-
|
|
1016
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1017
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10};
|
|
1018
|
-
type SpecifiedOptions = {};
|
|
1019
|
-
|
|
1020
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1021
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
1022
|
-
// Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
|
|
1023
|
-
```
|
|
1024
|
-
|
|
1025
|
-
@example
|
|
1026
|
-
```
|
|
1027
|
-
// Complains if an option's default type does not conform to the expected type
|
|
1028
|
-
|
|
1029
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1030
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
|
|
1031
|
-
type SpecifiedOptions = {};
|
|
1032
|
-
|
|
1033
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1034
|
-
// ~~~~~~~~~~~~~~~~~~~
|
|
1035
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1036
|
-
```
|
|
1037
|
-
|
|
1038
|
-
@example
|
|
1039
|
-
```
|
|
1040
|
-
// Complains if an option's specified type does not conform to the expected type
|
|
1041
|
-
|
|
1042
|
-
type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
|
|
1043
|
-
type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
|
|
1044
|
-
type SpecifiedOptions = {leavesOnly: 'yes'};
|
|
1045
|
-
|
|
1046
|
-
type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
|
|
1047
|
-
// ~~~~~~~~~~~~~~~~
|
|
1048
|
-
// Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
|
|
1049
|
-
```
|
|
1050
|
-
*/
|
|
1051
|
-
type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> extends infer Result extends Required<Options> // `extends Required<Options>` ensures that `ApplyDefaultOptions<SomeOption, ...>` is always assignable to `Required<SomeOption>`
|
|
1052
|
-
? Result : never;
|
|
1053
|
-
type _ApplyDefaultOptions<Options, Defaults, SpecifiedOptions> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Merge<Defaults, { [Key in keyof SpecifiedOptions as undefined extends Required<Options>[Key & keyof Options] ? Key : undefined extends SpecifiedOptions[Key] ? never : Key]: SpecifiedOptions[Key] }>>>;
|
|
1054
|
-
/**
|
|
1055
|
-
Collapses literal types in a union into their corresponding primitive types, when possible. For example, `CollapseLiterals<'foo' | 'bar' | (string & {})>` returns `string`.
|
|
1056
|
-
|
|
1057
|
-
Note: This doesn't collapse literals within tagged types. For example, `CollapseLiterals<Tagged<'foo' | (string & {}), 'Tag'>>` returns `("foo" & Tag<"Tag", never>) | (string & Tag<"Tag", never>)` and not `string & Tag<"Tag", never>`.
|
|
1058
|
-
|
|
1059
|
-
Use-case: For collapsing unions created using {@link LiteralUnion}.
|
|
1060
|
-
|
|
1061
|
-
@example
|
|
1062
|
-
```
|
|
1063
|
-
import type {LiteralUnion} from 'type-fest';
|
|
1064
|
-
|
|
1065
|
-
type A = CollapseLiterals<'foo' | 'bar' | (string & {})>;
|
|
1066
|
-
//=> string
|
|
1067
|
-
|
|
1068
|
-
type B = CollapseLiterals<LiteralUnion<1 | 2 | 3, number>>;
|
|
1069
|
-
//=> number
|
|
1070
|
-
|
|
1071
|
-
type C = CollapseLiterals<LiteralUnion<'onClick' | 'onChange', `on${string}`>>;
|
|
1072
|
-
//=> `on${string}`
|
|
1073
|
-
|
|
1074
|
-
type D = CollapseLiterals<'click' | 'change' | (`on${string}` & {})>;
|
|
1075
|
-
//=> 'click' | 'change' | `on${string}`
|
|
1076
|
-
|
|
1077
|
-
type E = CollapseLiterals<LiteralUnion<'foo' | 'bar', string> | null | undefined>;
|
|
1078
|
-
//=> string | null | undefined
|
|
1079
|
-
```
|
|
1080
|
-
*/
|
|
1081
|
-
//#endregion
|
|
1082
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/some-extend.d.ts
|
|
1083
|
-
/**
|
|
1084
|
-
@see {@link SomeExtend}
|
|
1085
|
-
*/
|
|
1086
|
-
type SomeExtendOptions = {
|
|
1087
|
-
/**
|
|
1088
|
-
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
1089
|
-
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
1090
|
-
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
1091
|
-
@default true
|
|
1092
|
-
@example
|
|
1093
|
-
```
|
|
1094
|
-
import type {SomeExtend} from 'type-fest';
|
|
1095
|
-
type A = SomeExtend<[1, 2, never], string, {strictNever: true}>;
|
|
1096
|
-
//=> false
|
|
1097
|
-
type B = SomeExtend<[1, 2, never], string, {strictNever: false}>;
|
|
1098
|
-
//=> true
|
|
1099
|
-
type C = SomeExtend<[1, never], never, {strictNever: true}>;
|
|
1100
|
-
//=> true
|
|
1101
|
-
type D = SomeExtend<[1, never], never, {strictNever: false}>;
|
|
1102
|
-
//=> true
|
|
1103
|
-
type E = SomeExtend<[never], any, {strictNever: true}>;
|
|
1104
|
-
//=> true
|
|
1105
|
-
type F = SomeExtend<[never], any, {strictNever: false}>;
|
|
1106
|
-
//=> true
|
|
1107
|
-
```
|
|
1108
|
-
*/
|
|
1109
|
-
strictNever?: boolean;
|
|
1110
|
-
};
|
|
1111
|
-
type DefaultSomeExtendOptions = {
|
|
1112
|
-
strictNever: true;
|
|
1113
|
-
};
|
|
1114
|
-
/**
|
|
1115
|
-
Returns a boolean for whether some element in an array type extends another type.
|
|
1116
|
-
|
|
1117
|
-
@example
|
|
1118
|
-
```
|
|
1119
|
-
import type {SomeExtend} from 'type-fest';
|
|
1120
|
-
|
|
1121
|
-
type A = SomeExtend<['1', '2', 3], number>;
|
|
1122
|
-
//=> true
|
|
1123
|
-
|
|
1124
|
-
type B = SomeExtend<[1, 2, 3], string>;
|
|
1125
|
-
//=> false
|
|
1126
|
-
|
|
1127
|
-
type C = SomeExtend<[string, number | string], number>;
|
|
1128
|
-
//=> boolean
|
|
1129
|
-
|
|
1130
|
-
type D = SomeExtend<[true, boolean, true], false>;
|
|
1131
|
-
//=> boolean
|
|
1132
|
-
```
|
|
1133
|
-
|
|
1134
|
-
Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
|
|
1135
|
-
|
|
1136
|
-
```
|
|
1137
|
-
// @exactOptionalPropertyTypes: true
|
|
1138
|
-
import type {SomeExtend} from 'type-fest';
|
|
1139
|
-
|
|
1140
|
-
type A = SomeExtend<[1?, 2?, '3'?], string>;
|
|
1141
|
-
//=> true
|
|
1142
|
-
```
|
|
1143
|
-
|
|
1144
|
-
```
|
|
1145
|
-
// @exactOptionalPropertyTypes: false
|
|
1146
|
-
import type {SomeExtend} from 'type-fest';
|
|
1147
|
-
|
|
1148
|
-
type A = SomeExtend<[1?, 2?, '3'?], string>;
|
|
1149
|
-
//=> boolean
|
|
1150
|
-
|
|
1151
|
-
type B = SomeExtend<[1?, 2?, '3'?], string | undefined>;
|
|
1152
|
-
//=> true
|
|
1153
|
-
```
|
|
1154
|
-
|
|
1155
|
-
@see {@link SomeExtendOptions}
|
|
1156
|
-
|
|
1157
|
-
@category Utilities
|
|
1158
|
-
@category Array
|
|
1159
|
-
*/
|
|
1160
|
-
type SomeExtend<TArray extends UnknownArray, Type, Options extends SomeExtendOptions = {}> = _SomeExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<SomeExtendOptions, DefaultSomeExtendOptions, Options>>;
|
|
1161
|
-
type _SomeExtend<TArray extends UnknownArray, Type, Options extends Required<SomeExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, return `true`.
|
|
1162
|
-
? true : _SomeExtend<Rest, Type, Options> : First extends Type ? true : _SomeExtend<Rest, Type, Options> : false, false, false>;
|
|
1163
|
-
//#endregion
|
|
1164
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or-all.d.ts
|
|
1165
|
-
/**
|
|
1166
|
-
Returns a boolean for whether any of the given elements is `true`.
|
|
1167
|
-
|
|
1168
|
-
Use-cases:
|
|
1169
|
-
- Check if at least one condition in a list of booleans is met.
|
|
1170
|
-
|
|
1171
|
-
@example
|
|
1172
|
-
```
|
|
1173
|
-
import type {OrAll} from 'type-fest';
|
|
1174
|
-
|
|
1175
|
-
type FFT = OrAll<[false, false, true]>;
|
|
1176
|
-
//=> true
|
|
1177
|
-
|
|
1178
|
-
type FFF = OrAll<[false, false, false]>;
|
|
1179
|
-
//=> false
|
|
1180
|
-
```
|
|
1181
|
-
|
|
1182
|
-
Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1183
|
-
For example, `OrAll<[false, boolean]>` expands to `OrAll<[false, true]> | OrAll<[false, false]>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1184
|
-
|
|
1185
|
-
@example
|
|
1186
|
-
```
|
|
1187
|
-
import type {OrAll} from 'type-fest';
|
|
1188
|
-
|
|
1189
|
-
type A = OrAll<[false, boolean]>;
|
|
1190
|
-
//=> boolean
|
|
1191
|
-
|
|
1192
|
-
type B = OrAll<[true, boolean]>;
|
|
1193
|
-
//=> true
|
|
1194
|
-
```
|
|
1195
|
-
|
|
1196
|
-
Note: If `never` is passed as an element, it is treated as `false` and the result is computed accordingly.
|
|
1197
|
-
|
|
1198
|
-
@example
|
|
1199
|
-
```
|
|
1200
|
-
import type {OrAll} from 'type-fest';
|
|
1201
|
-
|
|
1202
|
-
type A = OrAll<[never, never, true]>;
|
|
1203
|
-
//=> true
|
|
1204
|
-
|
|
1205
|
-
type B = OrAll<[never, never, false]>;
|
|
1206
|
-
//=> false
|
|
1207
|
-
|
|
1208
|
-
type C = OrAll<[never, never, never]>;
|
|
1209
|
-
//=> false
|
|
1210
|
-
|
|
1211
|
-
type D = OrAll<[never, never, boolean]>;
|
|
1212
|
-
//=> boolean
|
|
1213
|
-
```
|
|
1214
|
-
|
|
1215
|
-
Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
|
|
1216
|
-
|
|
1217
|
-
@example
|
|
1218
|
-
```
|
|
1219
|
-
import type {OrAll} from 'type-fest';
|
|
1220
|
-
|
|
1221
|
-
type A = OrAll<[false, any]>;
|
|
1222
|
-
//=> boolean
|
|
1223
|
-
|
|
1224
|
-
type B = OrAll<[true, any]>;
|
|
1225
|
-
//=> true
|
|
1226
|
-
```
|
|
1227
|
-
|
|
1228
|
-
Note: `OrAll<[]>` evaluates to `false` because there are no `true` elements in an empty tuple. See [Wikipedia: Clause (logic) > Empty clauses](https://en.wikipedia.org/wiki/Clause_(logic)#Empty_clauses:~:text=The%20truth%20evaluation%20of%20an%20empty%20disjunctive%20clause%20is%20always%20false.).
|
|
1229
|
-
|
|
1230
|
-
@see {@link Or}
|
|
1231
|
-
@see {@link AndAll}
|
|
1232
|
-
*/
|
|
1233
|
-
type OrAll<T extends readonly boolean[]> = SomeExtend<T, true>;
|
|
1234
|
-
//#endregion
|
|
1235
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/or.d.ts
|
|
1236
|
-
/**
|
|
1237
|
-
Returns a boolean for whether either of two given types is `true`.
|
|
1238
|
-
|
|
1239
|
-
Use-case: Constructing complex conditional types where at least one condition must be satisfied.
|
|
1240
|
-
|
|
1241
|
-
@example
|
|
1242
|
-
```
|
|
1243
|
-
import type {Or} from 'type-fest';
|
|
1244
|
-
|
|
1245
|
-
type TT = Or<true, true>;
|
|
1246
|
-
//=> true
|
|
1247
|
-
|
|
1248
|
-
type TF = Or<true, false>;
|
|
1249
|
-
//=> true
|
|
1250
|
-
|
|
1251
|
-
type FT = Or<false, true>;
|
|
1252
|
-
//=> true
|
|
1253
|
-
|
|
1254
|
-
type FF = Or<false, false>;
|
|
1255
|
-
//=> false
|
|
1256
|
-
```
|
|
1257
|
-
|
|
1258
|
-
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1259
|
-
For example, `Or<false, boolean>` expands to `Or<false, true> | Or<false, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1260
|
-
|
|
1261
|
-
@example
|
|
1262
|
-
```
|
|
1263
|
-
import type {Or} from 'type-fest';
|
|
1264
|
-
|
|
1265
|
-
type A = Or<false, boolean>;
|
|
1266
|
-
//=> boolean
|
|
1267
|
-
|
|
1268
|
-
type B = Or<boolean, false>;
|
|
1269
|
-
//=> boolean
|
|
1270
|
-
|
|
1271
|
-
type C = Or<true, boolean>;
|
|
1272
|
-
//=> true
|
|
1273
|
-
|
|
1274
|
-
type D = Or<boolean, true>;
|
|
1275
|
-
//=> true
|
|
1276
|
-
|
|
1277
|
-
type E = Or<boolean, boolean>;
|
|
1278
|
-
//=> boolean
|
|
1279
|
-
```
|
|
1280
|
-
|
|
1281
|
-
Note: If `never` is passed as an argument, it is treated as `false` and the result is computed accordingly.
|
|
1282
|
-
|
|
1283
|
-
@example
|
|
1284
|
-
```
|
|
1285
|
-
import type {Or} from 'type-fest';
|
|
1286
|
-
|
|
1287
|
-
type A = Or<true, never>;
|
|
1288
|
-
//=> true
|
|
1289
|
-
|
|
1290
|
-
type B = Or<never, true>;
|
|
1291
|
-
//=> true
|
|
1292
|
-
|
|
1293
|
-
type C = Or<false, never>;
|
|
1294
|
-
//=> false
|
|
1295
|
-
|
|
1296
|
-
type D = Or<never, false>;
|
|
1297
|
-
//=> false
|
|
1298
|
-
|
|
1299
|
-
type E = Or<boolean, never>;
|
|
1300
|
-
//=> boolean
|
|
1301
|
-
|
|
1302
|
-
type F = Or<never, boolean>;
|
|
1303
|
-
//=> boolean
|
|
1304
|
-
|
|
1305
|
-
type G = Or<never, never>;
|
|
1306
|
-
//=> false
|
|
1307
|
-
```
|
|
1308
|
-
|
|
1309
|
-
@see {@link OrAll}
|
|
1310
|
-
@see {@link And}
|
|
1311
|
-
@see {@link Xor}
|
|
1312
|
-
*/
|
|
1313
|
-
type Or<A extends boolean, B extends boolean> = OrAll<[A, B]>;
|
|
1314
|
-
//#endregion
|
|
1315
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/all-extend.d.ts
|
|
1316
|
-
/**
|
|
1317
|
-
@see {@link AllExtend}
|
|
1318
|
-
*/
|
|
1319
|
-
type AllExtendOptions = {
|
|
1320
|
-
/**
|
|
1321
|
-
Consider `never` elements to match the target type only if the target type itself is `never` (or `any`).
|
|
1322
|
-
- When set to `true` (default), `never` is _not_ treated as a bottom type, instead, it is treated as a type that matches only itself (or `any`).
|
|
1323
|
-
- When set to `false`, `never` is treated as a bottom type, and behaves as it normally would.
|
|
1324
|
-
@default true
|
|
1325
|
-
@example
|
|
1326
|
-
```
|
|
1327
|
-
import type {AllExtend} from 'type-fest';
|
|
1328
|
-
type A = AllExtend<[1, 2, never], number, {strictNever: true}>;
|
|
1329
|
-
//=> false
|
|
1330
|
-
type B = AllExtend<[1, 2, never], number, {strictNever: false}>;
|
|
1331
|
-
//=> true
|
|
1332
|
-
type C = AllExtend<[never, never], never, {strictNever: true}>;
|
|
1333
|
-
//=> true
|
|
1334
|
-
type D = AllExtend<[never, never], never, {strictNever: false}>;
|
|
1335
|
-
//=> true
|
|
1336
|
-
type E = AllExtend<['a', 'b', never], any, {strictNever: true}>;
|
|
1337
|
-
//=> true
|
|
1338
|
-
type F = AllExtend<['a', 'b', never], any, {strictNever: false}>;
|
|
1339
|
-
//=> true
|
|
1340
|
-
type G = AllExtend<[never, 1], never, {strictNever: true}>;
|
|
1341
|
-
//=> false
|
|
1342
|
-
type H = AllExtend<[never, 1], never, {strictNever: false}>;
|
|
1343
|
-
//=> false
|
|
1344
|
-
```
|
|
1345
|
-
*/
|
|
1346
|
-
strictNever?: boolean;
|
|
1347
|
-
};
|
|
1348
|
-
type DefaultAllExtendOptions = {
|
|
1349
|
-
strictNever: true;
|
|
1350
|
-
};
|
|
1351
|
-
/**
|
|
1352
|
-
Returns a boolean for whether every element in an array type extends another type.
|
|
1353
|
-
|
|
1354
|
-
@example
|
|
1355
|
-
```
|
|
1356
|
-
import type {AllExtend} from 'type-fest';
|
|
1357
|
-
|
|
1358
|
-
type A = AllExtend<[1, 2, 3], number>;
|
|
1359
|
-
//=> true
|
|
1360
|
-
|
|
1361
|
-
type B = AllExtend<[1, 2, '3'], number>;
|
|
1362
|
-
//=> false
|
|
1363
|
-
|
|
1364
|
-
type C = AllExtend<[number, number | string], number>;
|
|
1365
|
-
//=> boolean
|
|
1366
|
-
|
|
1367
|
-
type D = AllExtend<[true, boolean, true], true>;
|
|
1368
|
-
//=> boolean
|
|
1369
|
-
```
|
|
1370
|
-
|
|
1371
|
-
Note: Behaviour of optional elements depend on the `exactOptionalPropertyTypes` compiler option. When the option is disabled, the target type must include `undefined` for a successful match.
|
|
1372
|
-
|
|
1373
|
-
```
|
|
1374
|
-
// @exactOptionalPropertyTypes: true
|
|
1375
|
-
import type {AllExtend} from 'type-fest';
|
|
1376
|
-
|
|
1377
|
-
type A = AllExtend<[1?, 2?, 3?], number>;
|
|
1378
|
-
//=> true
|
|
1379
|
-
```
|
|
1380
|
-
|
|
1381
|
-
```
|
|
1382
|
-
// @exactOptionalPropertyTypes: false
|
|
1383
|
-
import type {AllExtend} from 'type-fest';
|
|
1384
|
-
|
|
1385
|
-
type A = AllExtend<[1?, 2?, 3?], number>;
|
|
1386
|
-
//=> boolean
|
|
1387
|
-
|
|
1388
|
-
type B = AllExtend<[1?, 2?, 3?], number | undefined>;
|
|
1389
|
-
//=> true
|
|
1390
|
-
```
|
|
1391
|
-
|
|
1392
|
-
@see {@link AllExtendOptions}
|
|
1393
|
-
|
|
1394
|
-
@category Utilities
|
|
1395
|
-
@category Array
|
|
1396
|
-
*/
|
|
1397
|
-
type AllExtend<TArray extends UnknownArray, Type, Options extends AllExtendOptions = {}> = _AllExtend<CollapseRestElement<TArray>, Type, ApplyDefaultOptions<AllExtendOptions, DefaultAllExtendOptions, Options>>;
|
|
1398
|
-
type _AllExtend<TArray extends UnknownArray, Type, Options extends Required<AllExtendOptions>> = IfNotAnyOrNever<TArray, TArray extends readonly [infer First, ...infer Rest] ? IsNever<First> extends true ? Or<Or<IsNever<Type>, IsAny<Type>>, Not<Options['strictNever']>> extends true // If target `Type` is also `never`, or is `any`, or `strictNever` is disabled, recurse further.
|
|
1399
|
-
? _AllExtend<Rest, Type, Options> : false : First extends Type ? _AllExtend<Rest, Type, Options> : false : true, false, false>;
|
|
1400
|
-
//#endregion
|
|
1401
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and-all.d.ts
|
|
1402
|
-
/**
|
|
1403
|
-
Returns a boolean for whether all of the given elements are `true`.
|
|
1404
|
-
|
|
1405
|
-
Use-cases:
|
|
1406
|
-
- Check if all conditions in a list of booleans are met.
|
|
1407
|
-
|
|
1408
|
-
@example
|
|
1409
|
-
```
|
|
1410
|
-
import type {AndAll} from 'type-fest';
|
|
1411
|
-
|
|
1412
|
-
type TTT = AndAll<[true, true, true]>;
|
|
1413
|
-
//=> true
|
|
1414
|
-
|
|
1415
|
-
type TTF = AndAll<[true, true, false]>;
|
|
1416
|
-
//=> false
|
|
1417
|
-
|
|
1418
|
-
type TFT = AndAll<[true, false, true]>;
|
|
1419
|
-
//=> false
|
|
1420
|
-
```
|
|
1421
|
-
|
|
1422
|
-
Note: When `boolean` is passed as an element, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1423
|
-
For example, `AndAll<[true, boolean]>` expands to `AndAll<[true, true]> | AndAll<[true, false]>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1424
|
-
|
|
1425
|
-
@example
|
|
1426
|
-
```
|
|
1427
|
-
import type {AndAll} from 'type-fest';
|
|
1428
|
-
|
|
1429
|
-
type A = AndAll<[true, boolean]>;
|
|
1430
|
-
//=> boolean
|
|
1431
|
-
|
|
1432
|
-
type B = AndAll<[false, boolean]>;
|
|
1433
|
-
//=> false
|
|
1434
|
-
```
|
|
1435
|
-
|
|
1436
|
-
Note: If any of the elements is `never`, the result becomes `false`.
|
|
1437
|
-
|
|
1438
|
-
@example
|
|
1439
|
-
```
|
|
1440
|
-
import type {AndAll} from 'type-fest';
|
|
1441
|
-
|
|
1442
|
-
type A = AndAll<[true, true, never]>;
|
|
1443
|
-
//=> false
|
|
1444
|
-
|
|
1445
|
-
type B = AndAll<[false, never, never]>;
|
|
1446
|
-
//=> false
|
|
1447
|
-
|
|
1448
|
-
type C = AndAll<[never, never, never]>;
|
|
1449
|
-
//=> false
|
|
1450
|
-
|
|
1451
|
-
type D = AndAll<[boolean, true, never]>;
|
|
1452
|
-
//=> false
|
|
1453
|
-
```
|
|
1454
|
-
|
|
1455
|
-
Note: If `any` is passed as an element, it is treated as `boolean` and the result is computed accordingly.
|
|
1456
|
-
|
|
1457
|
-
@example
|
|
1458
|
-
```
|
|
1459
|
-
import type {AndAll} from 'type-fest';
|
|
1460
|
-
|
|
1461
|
-
type A = AndAll<[false, any]>;
|
|
1462
|
-
//=> false
|
|
1463
|
-
|
|
1464
|
-
type B = AndAll<[true, any]>;
|
|
1465
|
-
//=> boolean
|
|
1466
|
-
```
|
|
1467
|
-
|
|
1468
|
-
Note: `AndAll<[]>` evaluates to `true` due to the concept of [vacuous truth](https://en.wikipedia.org/wiki/Logical_conjunction#:~:text=In%20keeping%20with%20the%20concept%20of%20vacuous%20truth%2C%20when%20conjunction%20is%20defined%20as%20an%20operator%20or%20function%20of%20arbitrary%20arity%2C%20the%20empty%20conjunction%20(AND%2Ding%20over%20an%20empty%20set%20of%20operands)%20is%20often%20defined%20as%20having%20the%20result%20true.), i.e., there are no `false` elements in an empty tuple.
|
|
1469
|
-
|
|
1470
|
-
@see {@link And}
|
|
1471
|
-
@see {@link OrAll}
|
|
1472
|
-
*/
|
|
1473
|
-
type AndAll<T extends readonly boolean[]> = AllExtend<T, true>;
|
|
1474
|
-
//#endregion
|
|
1475
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/and.d.ts
|
|
1476
|
-
/**
|
|
1477
|
-
Returns a boolean for whether two given types are both `true`.
|
|
1478
|
-
|
|
1479
|
-
Use-case: Constructing complex conditional types where multiple conditions must be satisfied.
|
|
1480
|
-
|
|
1481
|
-
@example
|
|
1482
|
-
```
|
|
1483
|
-
import type {And} from 'type-fest';
|
|
1484
|
-
|
|
1485
|
-
type TT = And<true, true>;
|
|
1486
|
-
//=> true
|
|
1487
|
-
|
|
1488
|
-
type TF = And<true, false>;
|
|
1489
|
-
//=> false
|
|
1490
|
-
|
|
1491
|
-
type FT = And<false, true>;
|
|
1492
|
-
//=> false
|
|
1493
|
-
|
|
1494
|
-
type FF = And<false, false>;
|
|
1495
|
-
//=> false
|
|
1496
|
-
```
|
|
1497
|
-
|
|
1498
|
-
Note: When `boolean` is passed as an argument, it is distributed into separate cases, and the final result is a union of those cases.
|
|
1499
|
-
For example, `And<true, boolean>` expands to `And<true, true> | And<true, false>`, which simplifies to `true | false` (i.e., `boolean`).
|
|
1500
|
-
|
|
1501
|
-
@example
|
|
1502
|
-
```
|
|
1503
|
-
import type {And} from 'type-fest';
|
|
1504
|
-
|
|
1505
|
-
type A = And<true, boolean>;
|
|
1506
|
-
//=> boolean
|
|
1507
|
-
|
|
1508
|
-
type B = And<boolean, true>;
|
|
1509
|
-
//=> boolean
|
|
1510
|
-
|
|
1511
|
-
type C = And<false, boolean>;
|
|
1512
|
-
//=> false
|
|
1513
|
-
|
|
1514
|
-
type D = And<boolean, false>;
|
|
1515
|
-
//=> false
|
|
1516
|
-
|
|
1517
|
-
type E = And<boolean, boolean>;
|
|
1518
|
-
//=> boolean
|
|
1519
|
-
```
|
|
1520
|
-
|
|
1521
|
-
Note: If either of the types is `never`, the result becomes `false`.
|
|
1522
|
-
|
|
1523
|
-
@example
|
|
1524
|
-
```
|
|
1525
|
-
import type {And} from 'type-fest';
|
|
1526
|
-
|
|
1527
|
-
type A = And<true, never>;
|
|
1528
|
-
//=> false
|
|
1529
|
-
|
|
1530
|
-
type B = And<never, true>;
|
|
1531
|
-
//=> false
|
|
1532
|
-
|
|
1533
|
-
type C = And<false, never>;
|
|
1534
|
-
//=> false
|
|
1535
|
-
|
|
1536
|
-
type D = And<never, false>;
|
|
1537
|
-
//=> false
|
|
1538
|
-
|
|
1539
|
-
type E = And<boolean, never>;
|
|
1540
|
-
//=> false
|
|
1541
|
-
|
|
1542
|
-
type F = And<never, boolean>;
|
|
1543
|
-
//=> false
|
|
1544
|
-
|
|
1545
|
-
type G = And<never, never>;
|
|
1546
|
-
//=> false
|
|
1547
|
-
```
|
|
1548
|
-
|
|
1549
|
-
@see {@link AndAll}
|
|
1550
|
-
@see {@link Or}
|
|
1551
|
-
@see {@link Xor}
|
|
1552
|
-
*/
|
|
1553
|
-
type And<A extends boolean, B extends boolean> = AndAll<[A, B]>;
|
|
1554
|
-
//#endregion
|
|
1555
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/absolute.d.ts
|
|
1556
|
-
/**
|
|
1557
|
-
Returns the absolute value of the specified number or bigint.
|
|
1558
|
-
|
|
1559
|
-
@example
|
|
1560
|
-
```
|
|
1561
|
-
import type {Absolute} from 'type-fest';
|
|
1562
|
-
|
|
1563
|
-
type A = Absolute<-1>;
|
|
1564
|
-
//=> 1
|
|
1565
|
-
|
|
1566
|
-
type B = Absolute<1>;
|
|
1567
|
-
//=> 1
|
|
1568
|
-
|
|
1569
|
-
type C = Absolute<0>;
|
|
1570
|
-
//=> 0
|
|
1571
|
-
|
|
1572
|
-
type D = Absolute<-1.025>;
|
|
1573
|
-
//=> 1.025
|
|
1574
|
-
|
|
1575
|
-
type E = Absolute<-9999n>;
|
|
1576
|
-
//=> 9999n
|
|
1577
|
-
```
|
|
1578
|
-
|
|
1579
|
-
Returns back the same type if the input is not a literal type.
|
|
1580
|
-
|
|
1581
|
-
@example
|
|
1582
|
-
```
|
|
1583
|
-
import type {Absolute} from 'type-fest';
|
|
1584
|
-
|
|
1585
|
-
type A = Absolute<number>;
|
|
1586
|
-
//=> number
|
|
1587
|
-
|
|
1588
|
-
type B = Absolute<bigint>;
|
|
1589
|
-
//=> bigint
|
|
1590
|
-
|
|
1591
|
-
type C = Absolute<number | bigint>;
|
|
1592
|
-
//=> number | bigint
|
|
1593
|
-
```
|
|
1594
|
-
|
|
1595
|
-
@category Numeric
|
|
1596
|
-
*/
|
|
1597
|
-
type Absolute<N extends number | bigint> = N extends bigint // Also, distributes `N`
|
|
1598
|
-
? `${N}` extends `-${infer Magnitude extends bigint}` ? Magnitude : N : `${N}` extends `-${infer Magnitude}` // This doesn't use the `extends number` constraint approach because that fails with the `-Infinity` case
|
|
1599
|
-
? StringToNumber<Magnitude> : N;
|
|
1600
|
-
//#endregion
|
|
1601
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/greater-than.d.ts
|
|
1602
|
-
/**
|
|
1603
|
-
Returns a boolean for whether a given number is greater than another number.
|
|
1604
|
-
|
|
1605
|
-
@example
|
|
1606
|
-
```
|
|
1607
|
-
import type {GreaterThan} from 'type-fest';
|
|
1608
|
-
|
|
1609
|
-
type A = GreaterThan<1, -5>;
|
|
1610
|
-
//=> true
|
|
1611
|
-
|
|
1612
|
-
type B = GreaterThan<1, 1>;
|
|
1613
|
-
//=> false
|
|
1614
|
-
|
|
1615
|
-
type C = GreaterThan<1, 5>;
|
|
1616
|
-
//=> false
|
|
1617
|
-
```
|
|
1618
|
-
|
|
1619
|
-
Note: If either argument is the non-literal `number` type, the result is `boolean`.
|
|
1620
|
-
|
|
1621
|
-
@example
|
|
1622
|
-
```
|
|
1623
|
-
import type {GreaterThan} from 'type-fest';
|
|
1624
|
-
|
|
1625
|
-
type A = GreaterThan<number, 1>;
|
|
1626
|
-
//=> boolean
|
|
1627
|
-
|
|
1628
|
-
type B = GreaterThan<1, number>;
|
|
1629
|
-
//=> boolean
|
|
1630
|
-
|
|
1631
|
-
type C = GreaterThan<number, number>;
|
|
1632
|
-
//=> boolean
|
|
1633
|
-
```
|
|
1634
|
-
|
|
1635
|
-
@example
|
|
1636
|
-
```
|
|
1637
|
-
import type {GreaterThan} from 'type-fest';
|
|
1638
|
-
|
|
1639
|
-
// Use `GreaterThan` to constrain a function parameter to positive numbers.
|
|
1640
|
-
declare function setPositive<N extends number>(value: GreaterThan<N, 0> extends true ? N : never): void;
|
|
1641
|
-
|
|
1642
|
-
setPositive(1); // ✅ Allowed
|
|
1643
|
-
setPositive(2); // ✅ Allowed
|
|
1644
|
-
|
|
1645
|
-
// @ts-expect-error
|
|
1646
|
-
setPositive(0);
|
|
1647
|
-
|
|
1648
|
-
// @ts-expect-error
|
|
1649
|
-
setPositive(-1);
|
|
1650
|
-
```
|
|
1651
|
-
*/
|
|
1652
|
-
type GreaterThan<A extends number, B extends number> = A extends number // For distributing `A`
|
|
1653
|
-
? B extends number // For distributing `B`
|
|
1654
|
-
? number extends A | B ? boolean : [IsEqual<A, PositiveInfinity>, IsEqual<A, NegativeInfinity>, IsEqual<B, PositiveInfinity>, IsEqual<B, NegativeInfinity>] extends infer R extends [boolean, boolean, boolean, boolean] ? Or<And<IsEqual<R[0], true>, IsEqual<R[2], false>>, And<IsEqual<R[3], true>, IsEqual<R[1], false>>> extends true ? true : Or<And<IsEqual<R[1], true>, IsEqual<R[3], false>>, And<IsEqual<R[2], true>, IsEqual<R[0], false>>> extends true ? false : true extends R[number] ? false : [IsNegative<A>, IsNegative<B>] extends infer R extends [boolean, boolean] ? [true, false] extends R ? false : [false, true] extends R ? true : [false, false] extends R ? PositiveNumericStringGt<`${A}`, `${B}`> : PositiveNumericStringGt<`${Absolute<B>}`, `${Absolute<A>}`> : never : never : never // Should never happen
|
|
1655
|
-
: never;
|
|
1656
|
-
//#endregion
|
|
1657
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/greater-than-or-equal.d.ts
|
|
1658
|
-
/**
|
|
1659
|
-
Returns a boolean for whether a given number is greater than or equal to another number.
|
|
1660
|
-
|
|
1661
|
-
@example
|
|
1662
|
-
```
|
|
1663
|
-
import type {GreaterThanOrEqual} from 'type-fest';
|
|
1664
|
-
|
|
1665
|
-
type A = GreaterThanOrEqual<1, -5>;
|
|
1666
|
-
//=> true
|
|
1667
|
-
|
|
1668
|
-
type B = GreaterThanOrEqual<1, 1>;
|
|
1669
|
-
//=> true
|
|
1670
|
-
|
|
1671
|
-
type C = GreaterThanOrEqual<1, 5>;
|
|
1672
|
-
//=> false
|
|
1673
|
-
```
|
|
1674
|
-
|
|
1675
|
-
Note: If either argument is the non-literal `number` type, the result is `boolean`.
|
|
1676
|
-
|
|
1677
|
-
@example
|
|
1678
|
-
```
|
|
1679
|
-
import type {GreaterThanOrEqual} from 'type-fest';
|
|
1680
|
-
|
|
1681
|
-
type A = GreaterThanOrEqual<number, 1>;
|
|
1682
|
-
//=> boolean
|
|
1683
|
-
|
|
1684
|
-
type B = GreaterThanOrEqual<1, number>;
|
|
1685
|
-
//=> boolean
|
|
1686
|
-
|
|
1687
|
-
type C = GreaterThanOrEqual<number, number>;
|
|
1688
|
-
//=> boolean
|
|
1689
|
-
```
|
|
1690
|
-
|
|
1691
|
-
@example
|
|
1692
|
-
```
|
|
1693
|
-
import type {GreaterThanOrEqual} from 'type-fest';
|
|
1694
|
-
|
|
1695
|
-
// Use `GreaterThanOrEqual` to constrain a function parameter to non-negative numbers.
|
|
1696
|
-
declare function setNonNegative<N extends number>(value: GreaterThanOrEqual<N, 0> extends true ? N : never): void;
|
|
1697
|
-
|
|
1698
|
-
setNonNegative(0); // ✅ Allowed
|
|
1699
|
-
setNonNegative(1); // ✅ Allowed
|
|
1700
|
-
|
|
1701
|
-
// @ts-expect-error
|
|
1702
|
-
setNonNegative(-1);
|
|
1703
|
-
|
|
1704
|
-
// @ts-expect-error
|
|
1705
|
-
setNonNegative(-2);
|
|
1706
|
-
```
|
|
1707
|
-
*/
|
|
1708
|
-
type GreaterThanOrEqual<A extends number, B extends number> = number extends A | B ? boolean : A extends number // For distributing `A`
|
|
1709
|
-
? B extends number // For distributing `B`
|
|
1710
|
-
? A extends B ? true : GreaterThan<A, B> : never // Should never happen
|
|
1711
|
-
: never;
|
|
1712
|
-
//#endregion
|
|
1713
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/less-than.d.ts
|
|
1714
|
-
/**
|
|
1715
|
-
Returns a boolean for whether a given number is less than another number.
|
|
1716
|
-
|
|
1717
|
-
@example
|
|
1718
|
-
```
|
|
1719
|
-
import type {LessThan} from 'type-fest';
|
|
1720
|
-
|
|
1721
|
-
type A = LessThan<1, -5>;
|
|
1722
|
-
//=> false
|
|
1723
|
-
|
|
1724
|
-
type B = LessThan<1, 1>;
|
|
1725
|
-
//=> false
|
|
1726
|
-
|
|
1727
|
-
type C = LessThan<1, 5>;
|
|
1728
|
-
//=> true
|
|
1729
|
-
```
|
|
1730
|
-
|
|
1731
|
-
Note: If either argument is the non-literal `number` type, the result is `boolean`.
|
|
1732
|
-
|
|
1733
|
-
@example
|
|
1734
|
-
```
|
|
1735
|
-
import type {LessThan} from 'type-fest';
|
|
1736
|
-
|
|
1737
|
-
type A = LessThan<number, 1>;
|
|
1738
|
-
//=> boolean
|
|
1739
|
-
|
|
1740
|
-
type B = LessThan<1, number>;
|
|
1741
|
-
//=> boolean
|
|
1742
|
-
|
|
1743
|
-
type C = LessThan<number, number>;
|
|
1744
|
-
//=> boolean
|
|
1745
|
-
```
|
|
1746
|
-
|
|
1747
|
-
@example
|
|
1748
|
-
```
|
|
1749
|
-
import type {LessThan} from 'type-fest';
|
|
1750
|
-
|
|
1751
|
-
// Use `LessThan` to constrain a function parameter to negative numbers.
|
|
1752
|
-
declare function setNegative<N extends number>(value: LessThan<N, 0> extends true ? N : never): void;
|
|
1753
|
-
|
|
1754
|
-
setNegative(-1); // ✅ Allowed
|
|
1755
|
-
setNegative(-2); // ✅ Allowed
|
|
1756
|
-
|
|
1757
|
-
// @ts-expect-error
|
|
1758
|
-
setNegative(0);
|
|
1759
|
-
|
|
1760
|
-
// @ts-expect-error
|
|
1761
|
-
setNegative(1);
|
|
1762
|
-
```
|
|
1763
|
-
*/
|
|
1764
|
-
type LessThan<A extends number, B extends number> = GreaterThanOrEqual<A, B> extends infer Result ? Result extends true ? false : true : never;
|
|
1765
|
-
//#endregion
|
|
1766
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/internal/tuple.d.ts
|
|
1767
|
-
// Should never happen
|
|
1768
|
-
/**
|
|
1769
|
-
Returns the maximum value from a tuple of integers.
|
|
1770
|
-
|
|
1771
|
-
Note:
|
|
1772
|
-
- Float numbers are not supported.
|
|
1773
|
-
|
|
1774
|
-
@example
|
|
1775
|
-
```
|
|
1776
|
-
type A = TupleMax<[1, 2, 5, 3]>;
|
|
1777
|
-
//=> 5
|
|
1778
|
-
|
|
1779
|
-
type B = TupleMax<[1, 2, 5, 3, 99, -1]>;
|
|
1780
|
-
//=> 99
|
|
1781
|
-
```
|
|
1782
|
-
*/
|
|
1783
|
-
type TupleMax<A extends number[], Result extends number = NegativeInfinity> = number extends A[number] ? never : A extends [infer F extends number, ...infer R extends number[]] ? GreaterThan<F, Result> extends true ? TupleMax<R, F> : TupleMax<R, Result> : Result;
|
|
1784
|
-
//#endregion
|
|
1785
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/subtract.d.ts
|
|
1786
|
-
/**
|
|
1787
|
-
Returns the difference between two numbers.
|
|
1788
|
-
|
|
1789
|
-
Note:
|
|
1790
|
-
- A or B can only support `-999` ~ `999`.
|
|
1791
|
-
|
|
1792
|
-
@example
|
|
1793
|
-
```
|
|
1794
|
-
import type {Subtract, PositiveInfinity} from 'type-fest';
|
|
1795
|
-
|
|
1796
|
-
type A = Subtract<333, 222>;
|
|
1797
|
-
//=> 111
|
|
1798
|
-
|
|
1799
|
-
type B = Subtract<111, -222>;
|
|
1800
|
-
//=> 333
|
|
1801
|
-
|
|
1802
|
-
type C = Subtract<-111, 222>;
|
|
1803
|
-
//=> -333
|
|
1804
|
-
|
|
1805
|
-
type D = Subtract<18, 96>;
|
|
1806
|
-
//=> -78
|
|
1807
|
-
|
|
1808
|
-
type E = Subtract<PositiveInfinity, 9999>;
|
|
1809
|
-
//=> Infinity
|
|
1810
|
-
|
|
1811
|
-
type F = Subtract<PositiveInfinity, PositiveInfinity>;
|
|
1812
|
-
//=> number
|
|
1813
|
-
```
|
|
1814
|
-
|
|
1815
|
-
@category Numeric
|
|
1816
|
-
*/
|
|
1817
|
-
// TODO: Support big integer.
|
|
1818
|
-
type Subtract<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
|
|
1819
|
-
number extends A | B ? number // Handle cases when A and B are both +/- infinity
|
|
1820
|
-
: A extends B & (PositiveInfinity | NegativeInfinity) ? number // Handle cases when A is - infinity or B is + infinity
|
|
1821
|
-
: A extends NegativeInfinity ? NegativeInfinity : B extends PositiveInfinity ? NegativeInfinity // Handle cases when A is + infinity or B is - infinity
|
|
1822
|
-
: A extends PositiveInfinity ? PositiveInfinity : B extends NegativeInfinity ? PositiveInfinity // Handle case when numbers are equal to each other
|
|
1823
|
-
: A extends B ? 0 // Handle cases when A or B is 0
|
|
1824
|
-
: A extends 0 ? ReverseSign<B> : B extends 0 ? A // Handle remaining regular cases
|
|
1825
|
-
: SubtractPostChecks<A, B>;
|
|
1826
|
-
/**
|
|
1827
|
-
Subtracts two numbers A and B, such that they are not equal and neither of them are 0, +/- infinity or the `number` type
|
|
1828
|
-
*/
|
|
1829
|
-
type SubtractPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] ? SubtractPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we subtract the absolute values and then reverse the sign
|
|
1830
|
-
? ReverseSign<SubtractPositives<Absolute<A>, Absolute<B>>> // When the signs are different we can add the absolute values and then reverse the sign if A < B
|
|
1831
|
-
: [...TupleOf<Absolute<A>>, ...TupleOf<Absolute<B>>] extends infer R extends unknown[] ? LessThan<A, B> extends true ? ReverseSign<R['length']> : R['length'] : never;
|
|
1832
|
-
/**
|
|
1833
|
-
Subtracts two positive numbers.
|
|
1834
|
-
*/
|
|
1835
|
-
type SubtractPositives<A extends number, B extends number> = LessThan<A, B> extends true // When A < B we can reverse the result of B - A
|
|
1836
|
-
? ReverseSign<SubtractIfAGreaterThanB<B, A>> : SubtractIfAGreaterThanB<A, B>;
|
|
1837
|
-
/**
|
|
1838
|
-
Subtracts two positive numbers A and B such that A > B.
|
|
1839
|
-
*/
|
|
1840
|
-
type SubtractIfAGreaterThanB<A extends number, B extends number> = // This is where we always want to end up and do the actual subtraction
|
|
1841
|
-
TupleOf<A> extends [...TupleOf<B>, ...infer R] ? R['length'] : never;
|
|
1842
|
-
//#endregion
|
|
1843
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/sum.d.ts
|
|
1844
|
-
/**
|
|
1845
|
-
Returns the sum of two numbers.
|
|
1846
|
-
|
|
1847
|
-
Note:
|
|
1848
|
-
- A or B can only support `-999` ~ `999`.
|
|
1849
|
-
|
|
1850
|
-
@example
|
|
1851
|
-
```
|
|
1852
|
-
import type {Sum, PositiveInfinity, NegativeInfinity} from 'type-fest';
|
|
1853
|
-
|
|
1854
|
-
type A = Sum<111, 222>;
|
|
1855
|
-
//=> 333
|
|
1856
|
-
|
|
1857
|
-
type B = Sum<-111, 222>;
|
|
1858
|
-
//=> 111
|
|
1859
|
-
|
|
1860
|
-
type C = Sum<111, -222>;
|
|
1861
|
-
//=> -111
|
|
1862
|
-
|
|
1863
|
-
type D = Sum<PositiveInfinity, -9999>;
|
|
1864
|
-
//=> Infinity
|
|
1865
|
-
|
|
1866
|
-
type E = Sum<PositiveInfinity, NegativeInfinity>;
|
|
1867
|
-
//=> number
|
|
1868
|
-
```
|
|
1869
|
-
|
|
1870
|
-
@category Numeric
|
|
1871
|
-
*/
|
|
1872
|
-
// TODO: Support big integer.
|
|
1873
|
-
type Sum<A extends number, B extends number> = // Handle cases when A or B is the actual "number" type
|
|
1874
|
-
number extends A | B ? number // Handle cases when A and B are both +/- infinity
|
|
1875
|
-
: A extends B & (PositiveInfinity | NegativeInfinity) ? A // A or B could be used here as they are equal
|
|
1876
|
-
// Handle cases when A and B are opposite infinities
|
|
1877
|
-
: A | B extends PositiveInfinity | NegativeInfinity ? number // Handle cases when A is +/- infinity
|
|
1878
|
-
: A extends PositiveInfinity | NegativeInfinity ? A // Handle cases when B is +/- infinity
|
|
1879
|
-
: B extends PositiveInfinity | NegativeInfinity ? B // Handle cases when A or B is 0 or it's the same number with different signs
|
|
1880
|
-
: A extends 0 ? B : B extends 0 ? A : A extends ReverseSign<B> ? 0 // Handle remaining regular cases
|
|
1881
|
-
: SumPostChecks<A, B>;
|
|
1882
|
-
/**
|
|
1883
|
-
Adds two numbers A and B, such that they are not equal with different signs and neither of them are 0, +/- infinity or the `number` type
|
|
1884
|
-
*/
|
|
1885
|
-
type SumPostChecks<A extends number, B extends number, AreNegative = [IsNegative<A>, IsNegative<B>]> = AreNegative extends [false, false] // When both numbers are positive we can add them together
|
|
1886
|
-
? SumPositives<A, B> : AreNegative extends [true, true] // When both numbers are negative we add the absolute values and then reverse the sign
|
|
1887
|
-
? ReverseSign<SumPositives<Absolute<A>, Absolute<B>>> // When the signs are different we can subtract the absolute values, remove the sign
|
|
1888
|
-
// and then reverse the sign if the larger absolute value is negative
|
|
1889
|
-
: Absolute<Subtract<Absolute<A>, Absolute<B>>> extends infer Result extends number ? TupleMax<[Absolute<A>, Absolute<B>]> extends infer Max_ extends number ? Max_ extends A | B // The larger absolute value is positive, so the result is positive
|
|
1890
|
-
? Result // The larger absolute value is negative, so the result is negative
|
|
1891
|
-
: ReverseSign<Result> : never : never;
|
|
1892
|
-
/**
|
|
1893
|
-
Adds two positive numbers.
|
|
1894
|
-
*/
|
|
1895
|
-
type SumPositives<A extends number, B extends number> = [...TupleOf<A>, ...TupleOf<B>]['length'] extends infer Result extends number ? Result : never;
|
|
1896
|
-
//#endregion
|
|
1897
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/exclude-exactly.d.ts
|
|
1898
|
-
/**
|
|
1899
|
-
A stricter version of `Exclude<T, U>` that excludes types only when they are exactly identical.
|
|
1900
|
-
|
|
1901
|
-
@example
|
|
1902
|
-
```
|
|
1903
|
-
import type {ExcludeExactly} from 'type-fest';
|
|
1904
|
-
|
|
1905
|
-
type TestExclude1 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
|
|
1906
|
-
//=> 1 | 2 | 3
|
|
1907
|
-
|
|
1908
|
-
type TestExcludeExactly1 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, string>;
|
|
1909
|
-
//=> 'a' | 'b' | 'c' | 1 | 2 | 3
|
|
1910
|
-
|
|
1911
|
-
type TestExclude2 = Exclude<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
|
|
1912
|
-
//=> never
|
|
1913
|
-
|
|
1914
|
-
type TestExcludeExactly2 = ExcludeExactly<'a' | 'b' | 'c' | 1 | 2 | 3, any>;
|
|
1915
|
-
//=> 'a' | 'b' | 'c' | 1 | 2 | 3
|
|
1916
|
-
|
|
1917
|
-
type TestExclude3 = Exclude<{a: string} | {a: string; b: string}, {a: string}>;
|
|
1918
|
-
//=> never
|
|
1919
|
-
|
|
1920
|
-
type TestExcludeExactly3 = ExcludeExactly<{a: string} | {a: string; b: string}, {a: string}>;
|
|
1921
|
-
//=> {a: string; b: string}
|
|
1922
|
-
```
|
|
1923
|
-
|
|
1924
|
-
@category Improved Built-in
|
|
1925
|
-
*/
|
|
1926
|
-
type ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Union, _ExcludeExactly<Union, Delete>, // If `Union` is `any`, then if `Delete` is `any`, return `never`, else return `Union`.
|
|
1927
|
-
If<IsAny<Delete>, never, Union>, // If `Union` is `never`, then if `Delete` is `never`, return `never`, else return `Union`.
|
|
1928
|
-
If<IsNever<Delete>, never, Union>>;
|
|
1929
|
-
type _ExcludeExactly<Union, Delete> = IfNotAnyOrNever<Delete, Union extends unknown // For distributing `Union`
|
|
1930
|
-
? [Delete extends unknown // For distributing `Delete`
|
|
1931
|
-
? If<IsEqual<Union, Delete>, true, never> : never] extends [never] ? Union : never : never, // If `Delete` is `any` or `never`, then return `Union`,
|
|
1932
|
-
// because `Union` cannot be `any` or `never` here.
|
|
1933
|
-
Union, Union>;
|
|
1934
|
-
//#endregion
|
|
1935
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-member.d.ts
|
|
1936
|
-
/**
|
|
1937
|
-
Returns an arbitrary member of a union type.
|
|
1938
|
-
|
|
1939
|
-
Use-cases:
|
|
1940
|
-
- Implementing recursive type functions that accept a union type.
|
|
1941
|
-
|
|
1942
|
-
@example
|
|
1943
|
-
```
|
|
1944
|
-
import type {UnionMember, IsNever} from 'type-fest';
|
|
1945
|
-
|
|
1946
|
-
type UnionLength<T, Acc extends any[] = []> =
|
|
1947
|
-
UnionMember<T> extends infer Member
|
|
1948
|
-
? IsNever<Member> extends false
|
|
1949
|
-
? UnionLength<Exclude<T, Member>, [...Acc, Member]>
|
|
1950
|
-
: Acc['length']
|
|
1951
|
-
: never;
|
|
1952
|
-
|
|
1953
|
-
type T1 = UnionLength<'foo' | 'bar' | 'baz'>;
|
|
1954
|
-
//=> 3
|
|
1955
|
-
|
|
1956
|
-
type T2 = UnionLength<{a: string}>;
|
|
1957
|
-
//=> 1
|
|
1958
|
-
```
|
|
1959
|
-
|
|
1960
|
-
- Picking an arbitrary member from a union
|
|
1961
|
-
|
|
1962
|
-
@example
|
|
1963
|
-
```
|
|
1964
|
-
import type {UnionMember, Primitive, LiteralToPrimitive} from 'type-fest';
|
|
1965
|
-
|
|
1966
|
-
type IsHomogenous<T extends Primitive> = [T] extends [LiteralToPrimitive<UnionMember<T>>] ? true : false;
|
|
1967
|
-
|
|
1968
|
-
type T1 = IsHomogenous<1 | 2 | 3 | 4>;
|
|
1969
|
-
//=> true
|
|
1970
|
-
|
|
1971
|
-
type T2 = IsHomogenous<'foo' | 'bar'>;
|
|
1972
|
-
//=> true
|
|
1973
|
-
|
|
1974
|
-
type T3 = IsHomogenous<'foo' | 'bar' | 1>;
|
|
1975
|
-
//=> false
|
|
1976
|
-
```
|
|
1977
|
-
|
|
1978
|
-
Returns `never` when the input is `never`.
|
|
1979
|
-
|
|
1980
|
-
@example
|
|
1981
|
-
```
|
|
1982
|
-
import type {UnionMember} from 'type-fest';
|
|
1983
|
-
|
|
1984
|
-
type LastNever = UnionMember<never>;
|
|
1985
|
-
//=> never
|
|
1986
|
-
```
|
|
1987
|
-
|
|
1988
|
-
@category Type
|
|
1989
|
-
*/
|
|
1990
|
-
type UnionMember<T> = IsNever<T> extends true ? never : UnionToIntersection<T extends any ? () => T : never> extends (() => (infer R)) ? R : never;
|
|
1991
|
-
//#endregion
|
|
1992
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/union-to-tuple.d.ts
|
|
1993
|
-
/**
|
|
1994
|
-
Convert a union type into an unordered tuple type of its elements.
|
|
1995
|
-
|
|
1996
|
-
"Unordered" means the elements of the tuple are not guaranteed to be in the same order as in the union type. The arrangement can appear random and may change at any time.
|
|
1997
|
-
|
|
1998
|
-
This can be useful when you have objects with a finite set of keys and want a type defining only the allowed keys, but do not want to repeat yourself.
|
|
1999
|
-
|
|
2000
|
-
@example
|
|
2001
|
-
```
|
|
2002
|
-
import type {UnionToTuple} from 'type-fest';
|
|
2003
|
-
|
|
2004
|
-
type Numbers = 1 | 2 | 3;
|
|
2005
|
-
type NumbersTuple = UnionToTuple<Numbers>;
|
|
2006
|
-
//=> [1, 2, 3]
|
|
2007
|
-
```
|
|
2008
|
-
|
|
2009
|
-
@example
|
|
2010
|
-
```
|
|
2011
|
-
import type {UnionToTuple} from 'type-fest';
|
|
2012
|
-
|
|
2013
|
-
const pets = {
|
|
2014
|
-
dog: '🐶',
|
|
2015
|
-
cat: '🐱',
|
|
2016
|
-
snake: '🐍',
|
|
2017
|
-
};
|
|
2018
|
-
|
|
2019
|
-
type Pet = keyof typeof pets;
|
|
2020
|
-
//=> 'dog' | 'cat' | 'snake'
|
|
2021
|
-
|
|
2022
|
-
const petList = Object.keys(pets) as UnionToTuple<Pet>;
|
|
2023
|
-
//=> ['dog', 'cat', 'snake']
|
|
2024
|
-
```
|
|
2025
|
-
|
|
2026
|
-
@category Array
|
|
2027
|
-
*/
|
|
2028
|
-
type UnionToTuple<Union> = _UnionToTuple<Union> extends infer Result extends UnknownArray ? Result : never;
|
|
2029
|
-
// Nudges the compiler that `UnionToTuple` always yields an array.
|
|
2030
|
-
type _UnionToTuple<Union, Accumulator extends UnknownArray = [], Member = UnionMember<Union>> = IsNever<Union> extends true ? Accumulator : _UnionToTuple<ExcludeExactly<Union, Member>, [Member, ...Accumulator]>;
|
|
2031
|
-
//#endregion
|
|
2032
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/int-range.d.ts
|
|
2033
|
-
/**
|
|
2034
|
-
Generate a union of numbers between a specified start (inclusive) and end (exclusive), with an optional step.
|
|
2035
|
-
|
|
2036
|
-
You skip over numbers using the `Step` parameter (defaults to `1`). For example, `IntRange<0, 10, 2>` will create a union of `0 | 2 | 4 | 6 | 8`.
|
|
2037
|
-
|
|
2038
|
-
Note: `Start` or `End` must be non-negative and smaller than `1000`.
|
|
2039
|
-
|
|
2040
|
-
Use-cases:
|
|
2041
|
-
1. This can be used to define a set of valid input/output values. for example:
|
|
2042
|
-
|
|
2043
|
-
@example
|
|
2044
|
-
```
|
|
2045
|
-
import type {IntRange} from 'type-fest';
|
|
2046
|
-
|
|
2047
|
-
type Age = IntRange<0, 20>;
|
|
2048
|
-
//=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
|
|
2049
|
-
|
|
2050
|
-
type FontSize = IntRange<10, 20>;
|
|
2051
|
-
//=> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19
|
|
2052
|
-
|
|
2053
|
-
type EvenNumber = IntRange<0, 11, 2>;
|
|
2054
|
-
//=> 0 | 2 | 4 | 6 | 8 | 10
|
|
2055
|
-
```
|
|
2056
|
-
|
|
2057
|
-
2. This can be used to define random numbers in a range. For example, `type RandomNumber = IntRange<0, 100>;`
|
|
2058
|
-
|
|
2059
|
-
@example
|
|
2060
|
-
```
|
|
2061
|
-
import type {IntRange} from 'type-fest';
|
|
2062
|
-
|
|
2063
|
-
type ZeroToNine = IntRange<0, 10>;
|
|
2064
|
-
//=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
2065
|
-
|
|
2066
|
-
type Hundreds = IntRange<100, 901, 100>;
|
|
2067
|
-
//=> 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
|
2068
|
-
```
|
|
2069
|
-
|
|
2070
|
-
@see {@link IntClosedRange}
|
|
2071
|
-
*/
|
|
2072
|
-
type IntRange<Start extends number, End extends number, Step extends number = 1> = PrivateIntRange<Start, End, Step>;
|
|
2073
|
-
/**
|
|
2074
|
-
The actual implementation of `IntRange`. It's private because it has some arguments that don't need to be exposed.
|
|
2075
|
-
*/
|
|
2076
|
-
type PrivateIntRange<Start extends number, End extends number, Step extends number, // The gap between each number, gap = step - 1
|
|
2077
|
-
Gap extends number = Subtract<Step, 1>, // The final `List` is `[...StartLengthTuple, ...[number, ...GapLengthTuple], ...[number, ...GapLengthTuple], ... ...]`, so can initialize the `List` with `[...StartLengthTuple]`
|
|
2078
|
-
List extends unknown[] = TupleOf<Start, never>, EndLengthTuple extends unknown[] = TupleOf<End>> = Gap extends 0 // Handle the case that without `Step`
|
|
2079
|
-
? List['length'] extends End // The result of "List[length] === End"
|
|
2080
|
-
? Exclude<List[number], never> // All unused elements are `never`, so exclude them
|
|
2081
|
-
: PrivateIntRange<Start, End, Step, Gap, [...List, List['length']]> // Handle the case that with `Step`
|
|
2082
|
-
: List extends [...(infer U), ...EndLengthTuple] // The result of "List[length] >= End", because the `...TupleOf<Gap, never>` maybe make `List` too long.
|
|
2083
|
-
? Exclude<List[number], never> : PrivateIntRange<Start, End, Step, Gap, [...List, List['length'], ...TupleOf<Gap, never>]>;
|
|
2084
|
-
//#endregion
|
|
2085
|
-
//#region ../../node_modules/.pnpm/type-fest@5.7.0/node_modules/type-fest/source/int-closed-range.d.ts
|
|
2086
|
-
/**
|
|
2087
|
-
Generate a union of numbers between a specified start and end (both inclusive), with an optional step.
|
|
2088
|
-
|
|
2089
|
-
You skip over numbers using the `Step` parameter (defaults to `1`). For example, `IntClosedRange<0, 10, 2>` will create a union of `0 | 2 | 4 | 6 | 8 | 10`.
|
|
2090
|
-
|
|
2091
|
-
Note: `Start` or `End` must be non-negative and smaller than `999`.
|
|
2092
|
-
|
|
2093
|
-
Use-cases:
|
|
2094
|
-
1. This can be used to define a set of valid input/output values. for example:
|
|
2095
|
-
|
|
2096
|
-
@example
|
|
2097
|
-
```
|
|
2098
|
-
import type {IntClosedRange} from 'type-fest';
|
|
2099
|
-
|
|
2100
|
-
type Age = IntClosedRange<0, 20>;
|
|
2101
|
-
//=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
|
|
2102
|
-
|
|
2103
|
-
type FontSize = IntClosedRange<10, 20>;
|
|
2104
|
-
//=> 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
|
|
2105
|
-
|
|
2106
|
-
type EvenNumber = IntClosedRange<0, 10, 2>;
|
|
2107
|
-
//=> 0 | 2 | 4 | 6 | 8 | 10
|
|
2108
|
-
```
|
|
2109
|
-
|
|
2110
|
-
2. This can be used to define random numbers in a range. For example, `type RandomNumber = IntClosedRange<0, 100>;`
|
|
2111
|
-
|
|
2112
|
-
@example
|
|
2113
|
-
```
|
|
2114
|
-
import type {IntClosedRange} from 'type-fest';
|
|
2115
|
-
|
|
2116
|
-
type ZeroToNine = IntClosedRange<0, 9>;
|
|
2117
|
-
//=> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
|
|
2118
|
-
|
|
2119
|
-
type Hundreds = IntClosedRange<100, 900, 100>;
|
|
2120
|
-
//=> 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900
|
|
2121
|
-
```
|
|
2122
|
-
|
|
2123
|
-
@see {@link IntRange}
|
|
2124
|
-
*/
|
|
2125
|
-
type IntClosedRange<Start extends number, End extends number, Skip extends number = 1> = IntRange<Start, Sum<End, 1>, Skip>;
|
|
2126
|
-
//#endregion
|
|
2127
5
|
//#region src/node/Lifecycle/LifecycleTypes.d.ts
|
|
2128
|
-
type LifecycleAction = 'start' | 'complete' | 'error';
|
|
2129
|
-
type PhaseEvents<Prefix extends string, Phases extends number[]> = `phase:${IntClosedRange<1, Phases['length']>}:${TypedExclude<LifecycleAction, 'error'>}` | `${Prefix}:${LifecycleAction}`;
|
|
2130
|
-
/**
|
|
2131
|
-
* Event payload map for a lifecycle. The phase and prefix `start`/`complete` events have an empty
|
|
2132
|
-
* payload, and the `${Prefix}:error` event's payload is the thrown error.
|
|
2133
|
-
*/
|
|
2134
|
-
type PhaseEventMap<Prefix extends string, Phases extends number[]> = { [K in PhaseEvents<Prefix, Phases>]: K extends `${string}:error` ? readonly [error: unknown] : readonly [] };
|
|
2135
6
|
interface LifecycleTask {
|
|
2136
7
|
name: string;
|
|
2137
8
|
task: () => Promise<void>;
|
|
@@ -2144,7 +15,7 @@ interface LifecycleTask {
|
|
|
2144
15
|
*
|
|
2145
16
|
* @internal
|
|
2146
17
|
*/
|
|
2147
|
-
declare abstract class CoordinatedLifecycle<TPhase extends number
|
|
18
|
+
declare abstract class CoordinatedLifecycle<TPhase extends number> {
|
|
2148
19
|
protected readonly phaseOrder: TPhase[];
|
|
2149
20
|
protected readonly phaseEnum: Record<number, string>;
|
|
2150
21
|
protected readonly logger: Logger;
|
|
@@ -2169,8 +40,6 @@ declare abstract class CoordinatedLifecycle<TPhase extends number, TEvents exten
|
|
|
2169
40
|
removeTask(phase: TPhase, taskName: string): boolean;
|
|
2170
41
|
protected runPhase(phase: TPhase): Promise<void>;
|
|
2171
42
|
protected runTaskWithTimeout(phase: TPhase, task: LifecycleTask): Promise<void>;
|
|
2172
|
-
private emitPhase;
|
|
2173
|
-
protected onListenerError(error: unknown, event: string | symbol): void;
|
|
2174
43
|
protected abstract canAddTask(): boolean;
|
|
2175
44
|
protected abstract canRemoveTask(): boolean;
|
|
2176
45
|
protected abstract getTaskType(): string;
|
|
@@ -2178,12 +47,11 @@ declare abstract class CoordinatedLifecycle<TPhase extends number, TEvents exten
|
|
|
2178
47
|
}
|
|
2179
48
|
//#endregion
|
|
2180
49
|
//#region src/node/Lifecycle/CoordinatedShutdown.d.ts
|
|
2181
|
-
type CoordinatedShutdownEvents = PhaseEventMap<'shutdown', UnionToTuple<ShutdownPhase>>;
|
|
2182
50
|
/**
|
|
2183
51
|
* Runs registered shutdown tasks across `ShutdownPhase` in order. Registers SIGINT and SIGTERM
|
|
2184
52
|
* handlers. Tasks within a phase run in parallel.
|
|
2185
53
|
*/
|
|
2186
|
-
declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase
|
|
54
|
+
declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase> {
|
|
2187
55
|
private isShuttingDown;
|
|
2188
56
|
private hasShutdown;
|
|
2189
57
|
private exitCode;
|
|
@@ -2198,9 +66,16 @@ declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase, Co
|
|
|
2198
66
|
private registerSignalHandlers;
|
|
2199
67
|
/** @internal */
|
|
2200
68
|
removeSignalHandlers(): void;
|
|
2201
|
-
/** @internal run() awaits this so
|
|
69
|
+
/** @internal run() awaits this so boot finishes registering its dispose tasks first */
|
|
2202
70
|
gateOnStartup(settled: Promise<void>): void;
|
|
2203
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* Adds a shutdown-phase task.
|
|
73
|
+
*
|
|
74
|
+
* @param phase - The shutdown phase to run the task in.
|
|
75
|
+
* @param taskName - A descriptive name for the task.
|
|
76
|
+
* @param task - The async function to run.
|
|
77
|
+
* @param timeoutMs - Task timeout in ms. {@default `5000` }
|
|
78
|
+
*/
|
|
2204
79
|
addTask(phase: ShutdownPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
|
|
2205
80
|
/** Removes a shutdown-phase task, returning whether one was removed. */
|
|
2206
81
|
removeTask(phase: ShutdownPhase, taskName: string): boolean;
|
|
@@ -2208,8 +83,8 @@ declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase, Co
|
|
|
2208
83
|
* Runs registered tasks across shutdown phases in `ShutdownPhase` order.
|
|
2209
84
|
* Tasks within each phase run in parallel.
|
|
2210
85
|
*
|
|
2211
|
-
* @param exitCode - Process exit code. {@default `0`}
|
|
2212
|
-
* @param exitProcess - Whether to exit the process after shutdown. {@default `true`}
|
|
86
|
+
* @param exitCode - Process exit code. {@default `0` }
|
|
87
|
+
* @param exitProcess - Whether to exit the process after shutdown. {@default `true` }
|
|
2213
88
|
* @example
|
|
2214
89
|
* ```typescript
|
|
2215
90
|
* shutdown.addTask(ShutdownPhase.Disconnect, 'database', () => db.disconnect(), 5000);
|
|
@@ -2217,19 +92,24 @@ declare class CoordinatedShutdown extends CoordinatedLifecycle<ShutdownPhase, Co
|
|
|
2217
92
|
* ```
|
|
2218
93
|
*/
|
|
2219
94
|
run(exitCode?: number, exitProcess?: boolean): Promise<void>;
|
|
2220
|
-
private emitFailures;
|
|
2221
95
|
}
|
|
2222
96
|
//#endregion
|
|
2223
97
|
//#region src/node/Lifecycle/CoordinatedStartup.d.ts
|
|
2224
|
-
type CoordinatedStartupEvents = PhaseEventMap<'startup', UnionToTuple<StartupPhase>>;
|
|
2225
98
|
/**
|
|
2226
99
|
* Runs registered startup tasks across `StartupPhase` in order. Tasks within a phase run in parallel.
|
|
2227
100
|
*/
|
|
2228
|
-
declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase
|
|
101
|
+
declare class CoordinatedStartup extends CoordinatedLifecycle<StartupPhase> {
|
|
2229
102
|
private isStartingUp;
|
|
2230
103
|
private hasStarted;
|
|
2231
104
|
constructor();
|
|
2232
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* Adds a startup-phase task.
|
|
107
|
+
*
|
|
108
|
+
* @param phase - The startup phase to run the task in.
|
|
109
|
+
* @param taskName - A descriptive name for the task.
|
|
110
|
+
* @param task - The async function to run.
|
|
111
|
+
* @param timeoutMs - Task timeout in ms. {@default `10000` }
|
|
112
|
+
*/
|
|
2233
113
|
addTask(phase: StartupPhase, taskName: string, task: () => Promise<void>, timeoutMs?: number): void;
|
|
2234
114
|
protected canAddTask(): boolean;
|
|
2235
115
|
protected canRemoveTask(): boolean;
|
|
@@ -2288,14 +168,17 @@ declare class HealthCheck {
|
|
|
2288
168
|
* Plugins are attached during configuration and initialized during startup, sequentially in attach
|
|
2289
169
|
* order within each phase. Not constructed directly, the host is a transport `Seedcord` class.
|
|
2290
170
|
*/
|
|
2291
|
-
declare abstract class Pluggable<
|
|
171
|
+
declare abstract class Pluggable<BotT extends Transport, BotRt extends Runtime> implements CoreBase {
|
|
2292
172
|
abstract readonly config: Config;
|
|
2293
173
|
abstract readonly rateLimiter: IRateLimiter;
|
|
174
|
+
abstract readonly bus: Bus;
|
|
175
|
+
/** @see {@link CoordinatedShutdown} */
|
|
176
|
+
readonly shutdown: CoordinatedShutdown;
|
|
177
|
+
/** @see {@link CoordinatedStartup} */
|
|
178
|
+
readonly startup: CoordinatedStartup;
|
|
2294
179
|
protected isInitialized: boolean;
|
|
2295
180
|
protected startFailed: boolean;
|
|
2296
|
-
protected readonly
|
|
2297
|
-
protected readonly startup: CoordinatedStartup;
|
|
2298
|
-
protected readonly plugins: Plugin[];
|
|
181
|
+
protected readonly plugins: PluginLike[];
|
|
2299
182
|
private readonly pluginLogger;
|
|
2300
183
|
private readonly attachments;
|
|
2301
184
|
private readonly completedInits;
|
|
@@ -2308,14 +191,20 @@ declare abstract class Pluggable<TPluggableEvents extends EventMap<TPluggableEve
|
|
|
2308
191
|
protected init(): Promise<this>;
|
|
2309
192
|
protected pluginCapabilities(): PluginCapabilities;
|
|
2310
193
|
protected pluginStore(): Store<'charge'>;
|
|
194
|
+
/** @internal codegen reads these to emit the `Core` augmentation */
|
|
195
|
+
get pluginKeys(): readonly string[];
|
|
2311
196
|
/** @internal releases the signal handlers and clears the singleton so the next host can construct */
|
|
2312
197
|
protected static reset(): void;
|
|
2313
198
|
/**
|
|
2314
199
|
* Attaches a plugin to this instance.
|
|
2315
200
|
*
|
|
2316
201
|
* The plugin initializes during startup, after every plugin attached before it, and becomes
|
|
2317
|
-
* available as a property on `core`.
|
|
2318
|
-
*
|
|
202
|
+
* available as a property on `core`. `seedcord codegen` writes the `Core` augmentation that
|
|
203
|
+
* types it.
|
|
204
|
+
*
|
|
205
|
+
* A plugin declaring a `transport` or `runtime` this host does not run is a compile error on
|
|
206
|
+
* this call. An edge host takes no plugins at all. A plugin constructor narrowing its first
|
|
207
|
+
* parameter past `CoreBase` is a compile error here too. Read the transport `Core` off `this.core`.
|
|
2319
208
|
*
|
|
2320
209
|
* @typeParam Key - The property name for accessing the plugin
|
|
2321
210
|
* @typeParam Ctor - The plugin constructor type
|
|
@@ -2323,13 +212,13 @@ declare abstract class Pluggable<TPluggableEvents extends EventMap<TPluggableEve
|
|
|
2323
212
|
* @param Plugin - Plugin constructor class
|
|
2324
213
|
* @param args - Additional arguments to pass to the plugin constructor
|
|
2325
214
|
* @returns This instance with the plugin attached as a typed property
|
|
2326
|
-
* @throws A **SeedcordError** When called after initialization or if key already exists
|
|
215
|
+
* @throws A **SeedcordError** When called after initialization or if key already exists or is reserved
|
|
2327
216
|
* @example
|
|
2328
217
|
* ```typescript
|
|
2329
|
-
* seedcord.attach('db',
|
|
218
|
+
* seedcord.attach('db', Mongoose, { uri: 'mongodb://...', name: 'seedcord', dir: ... })
|
|
2330
219
|
* ```
|
|
2331
220
|
*/
|
|
2332
|
-
attach<Key extends string, Ctor extends PluginCtor>(this: this, key: Key
|
|
221
|
+
attach<Key extends string, Ctor extends PluginCtor>(this: this, key: ChannelKeyAssert<Key>, Plugin: Ctor & TransportAssert<InstanceType<Ctor>, BotT> & RuntimeAssert<InstanceType<Ctor>, BotRt> & CoreParamAssert<Ctor>, ...args: PluginArgs<Ctor>): this & Record<Key, InstanceType<Ctor>>;
|
|
2333
222
|
private finalizeContext;
|
|
2334
223
|
private registerPluginTasks;
|
|
2335
224
|
private runInits;
|
|
@@ -2338,15 +227,35 @@ declare abstract class Pluggable<TPluggableEvents extends EventMap<TPluggableEve
|
|
|
2338
227
|
private runDisposals;
|
|
2339
228
|
private disposeCompleted;
|
|
2340
229
|
private rollback;
|
|
2341
|
-
/** @internal */
|
|
2342
|
-
removeListener<TEventKey extends Extract<keyof TPluggableEvents, string | symbol>>(event: TEventKey, listener: (...args: TPluggableEvents[TEventKey]) => void): this;
|
|
2343
|
-
/** @internal */
|
|
2344
|
-
removeAllListeners(event?: Extract<keyof TPluggableEvents, string | symbol>): this;
|
|
2345
230
|
}
|
|
2346
231
|
//#endregion
|
|
2347
232
|
//#region src/node/Lifecycle/withTimeout.d.ts
|
|
2348
233
|
/** @internal resolves when `work` settles or the bound elapses, whichever is first. */
|
|
2349
234
|
declare function settleWithin(work: Promise<unknown>, timeoutMs: number): Promise<void>;
|
|
2350
235
|
//#endregion
|
|
2351
|
-
|
|
236
|
+
//#region src/node/subscribers/SubscriberLoader.d.ts
|
|
237
|
+
/**
|
|
238
|
+
* Loads subscribers off the filesystem into a {@link Bus} and stores their hot-reload wiring. Node
|
|
239
|
+
* only, a bundled isolate registers from the manifest instead.
|
|
240
|
+
*
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
declare class SubscriberLoader implements Initializeable, HmrAware {
|
|
244
|
+
private readonly bus;
|
|
245
|
+
private readonly directory;
|
|
246
|
+
private isInitialized;
|
|
247
|
+
private readonly hmrHandler?;
|
|
248
|
+
constructor(bus: Bus, directory: string | null);
|
|
249
|
+
/** @internal */
|
|
250
|
+
init(): Promise<void>;
|
|
251
|
+
/** @internal */
|
|
252
|
+
onHmr(event: HmrUpdateEvent): Promise<void>;
|
|
253
|
+
private load;
|
|
254
|
+
private registerSubscriber;
|
|
255
|
+
private unregisterSubscriber;
|
|
256
|
+
private getArtifacts;
|
|
257
|
+
private isSubscriber;
|
|
258
|
+
}
|
|
259
|
+
//#endregion
|
|
260
|
+
export { CoordinatedShutdown, CoordinatedStartup, HealthCheck, type LifecycleTask, Pluggable, type PluginCapabilities, ShutdownPhase, StartupPhase, SubscriberLoader, settleWithin };
|
|
2352
261
|
//# sourceMappingURL=node-internal.index.d.mts.map
|