@pawover/kit 0.0.0-alpha.8 → 0.0.0-beta.1

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.
Files changed (82) hide show
  1. package/dist/enums.d.ts +25 -0
  2. package/dist/enums.d.ts.map +1 -0
  3. package/dist/enums.js +25 -0
  4. package/dist/enums.js.map +1 -0
  5. package/dist/hooks-alova.d.ts +23 -0
  6. package/dist/hooks-alova.d.ts.map +1 -0
  7. package/dist/hooks-alova.js +39 -0
  8. package/dist/hooks-alova.js.map +1 -0
  9. package/dist/hooks-react.d.ts +89 -0
  10. package/dist/hooks-react.d.ts.map +1 -0
  11. package/dist/hooks-react.js +334 -0
  12. package/dist/hooks-react.js.map +1 -0
  13. package/dist/index.d.ts +2411 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +1375 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/patches-fetchEventSource.d.ts +806 -0
  18. package/dist/patches-fetchEventSource.d.ts.map +1 -0
  19. package/dist/patches-fetchEventSource.js +315 -0
  20. package/dist/patches-fetchEventSource.js.map +1 -0
  21. package/dist/vite.d.ts +13 -0
  22. package/dist/vite.d.ts.map +1 -0
  23. package/dist/vite.js +23 -0
  24. package/dist/vite.js.map +1 -0
  25. package/dist/zod.d.ts +105 -0
  26. package/dist/zod.d.ts.map +1 -0
  27. package/dist/zod.js +138 -0
  28. package/dist/zod.js.map +1 -0
  29. package/metadata.json +157 -0
  30. package/package.json +51 -35
  31. package/dist/enums/index.js +0 -20
  32. package/dist/hooks/react/index.js +0 -5
  33. package/dist/hooks/react/useCreation.js +0 -19
  34. package/dist/hooks/react/useLatest.js +0 -13
  35. package/dist/hooks/react/useMount.js +0 -29
  36. package/dist/hooks/react/useResponsive.js +0 -59
  37. package/dist/hooks/react/useUnmount.js +0 -18
  38. package/dist/types/enums/index.d.ts +0 -20
  39. package/dist/types/hooks/react/index.d.ts +0 -5
  40. package/dist/types/hooks/react/useCreation.d.ts +0 -10
  41. package/dist/types/hooks/react/useLatest.d.ts +0 -8
  42. package/dist/types/hooks/react/useMount.d.ts +0 -11
  43. package/dist/types/hooks/react/useResponsive.d.ts +0 -16
  44. package/dist/types/hooks/react/useUnmount.d.ts +0 -7
  45. package/dist/types/utils/array.d.ts +0 -76
  46. package/dist/types/utils/clone.d.ts +0 -13
  47. package/dist/types/utils/index.d.ts +0 -7
  48. package/dist/types/utils/object.d.ts +0 -54
  49. package/dist/types/utils/string.d.ts +0 -15
  50. package/dist/types/utils/to.d.ts +0 -5
  51. package/dist/types/utils/tree/index.d.ts +0 -6
  52. package/dist/types/utils/tree/rowsToTree.d.ts +0 -10
  53. package/dist/types/utils/tree/treeFilter.d.ts +0 -6
  54. package/dist/types/utils/tree/treeFind.d.ts +0 -8
  55. package/dist/types/utils/tree/treeForEach.d.ts +0 -5
  56. package/dist/types/utils/tree/treeMap.d.ts +0 -6
  57. package/dist/types/utils/tree/treeToRows.d.ts +0 -9
  58. package/dist/types/utils/tree/types.d.ts +0 -24
  59. package/dist/types/utils/typeof.d.ts +0 -37
  60. package/dist/types/zod/index.d.ts +0 -3
  61. package/dist/types/zod/primitive.d.ts +0 -32
  62. package/dist/types/zod/validator/input.d.ts +0 -27
  63. package/dist/types/zod/validator/societal.d.ts +0 -39
  64. package/dist/utils/array.js +0 -196
  65. package/dist/utils/clone.js +0 -75
  66. package/dist/utils/index.js +0 -7
  67. package/dist/utils/object.js +0 -149
  68. package/dist/utils/string.js +0 -73
  69. package/dist/utils/to.js +0 -16
  70. package/dist/utils/tree/index.js +0 -6
  71. package/dist/utils/tree/rowsToTree.js +0 -35
  72. package/dist/utils/tree/treeFilter.js +0 -92
  73. package/dist/utils/tree/treeFind.js +0 -82
  74. package/dist/utils/tree/treeForEach.js +0 -60
  75. package/dist/utils/tree/treeMap.js +0 -79
  76. package/dist/utils/tree/treeToRows.js +0 -13
  77. package/dist/utils/tree/types.js +0 -10
  78. package/dist/utils/typeof.js +0 -149
  79. package/dist/zod/index.js +0 -3
  80. package/dist/zod/primitive.js +0 -32
  81. package/dist/zod/validator/input.js +0 -39
  82. package/dist/zod/validator/societal.js +0 -57
@@ -0,0 +1,806 @@
1
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-any.d.ts
2
+ /**
3
+ Returns a boolean for whether the given type is `any`.
4
+
5
+ @link https://stackoverflow.com/a/49928360/1490091
6
+
7
+ Useful in type utilities, such as disallowing `any`s to be passed to a function.
8
+
9
+ @example
10
+ ```
11
+ import type {IsAny} from 'type-fest';
12
+
13
+ const typedObject = {a: 1, b: 2} as const;
14
+ const anyObject: any = {a: 1, b: 2};
15
+
16
+ function get<O extends (IsAny<O> extends true ? {} : Record<string, number>), K extends keyof O = keyof O>(object: O, key: K) {
17
+ return object[key];
18
+ }
19
+
20
+ const typedA = get(typedObject, 'a');
21
+ //=> 1
22
+
23
+ const anyA = get(anyObject, 'a');
24
+ //=> any
25
+ ```
26
+
27
+ @category Type Guard
28
+ @category Utilities
29
+ */
30
+ type IsAny<T> = 0 extends 1 & NoInfer<T> ? true : false;
31
+ //#endregion
32
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-optional-key-of.d.ts
33
+ /**
34
+ Returns a boolean for whether the given key is an optional key of type.
35
+
36
+ This is useful when writing utility types or schema validators that need to differentiate `optional` keys.
37
+
38
+ @example
39
+ ```
40
+ import type {IsOptionalKeyOf} from 'type-fest';
41
+
42
+ type User = {
43
+ name: string;
44
+ surname: string;
45
+
46
+ luckyNumber?: number;
47
+ };
48
+
49
+ type Admin = {
50
+ name: string;
51
+ surname?: string;
52
+ };
53
+
54
+ type T1 = IsOptionalKeyOf<User, 'luckyNumber'>;
55
+ //=> true
56
+
57
+ type T2 = IsOptionalKeyOf<User, 'name'>;
58
+ //=> false
59
+
60
+ type T3 = IsOptionalKeyOf<User, 'name' | 'luckyNumber'>;
61
+ //=> boolean
62
+
63
+ type T4 = IsOptionalKeyOf<User | Admin, 'name'>;
64
+ //=> false
65
+
66
+ type T5 = IsOptionalKeyOf<User | Admin, 'surname'>;
67
+ //=> boolean
68
+ ```
69
+
70
+ @category Type Guard
71
+ @category Utilities
72
+ */
73
+ type IsOptionalKeyOf<Type extends object, Key$1 extends keyof Type> = IsAny<Type | Key$1> extends true ? never : Key$1 extends keyof Type ? Type extends Record<Key$1, Type[Key$1]> ? false : true : false;
74
+ //#endregion
75
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/optional-keys-of.d.ts
76
+ /**
77
+ Extract all optional keys from the given type.
78
+
79
+ This is useful when you want to create a new type that contains different type values for the optional keys only.
80
+
81
+ @example
82
+ ```
83
+ import type {OptionalKeysOf, Except} from 'type-fest';
84
+
85
+ type User = {
86
+ name: string;
87
+ surname: string;
88
+
89
+ luckyNumber?: number;
90
+ };
91
+
92
+ const REMOVE_FIELD = Symbol('remove field symbol');
93
+ type UpdateOperation<Entity extends object> = Except<Partial<Entity>, OptionalKeysOf<Entity>> & {
94
+ [Key in OptionalKeysOf<Entity>]?: Entity[Key] | typeof REMOVE_FIELD;
95
+ };
96
+
97
+ const update1: UpdateOperation<User> = {
98
+ name: 'Alice',
99
+ };
100
+
101
+ const update2: UpdateOperation<User> = {
102
+ name: 'Bob',
103
+ luckyNumber: REMOVE_FIELD,
104
+ };
105
+ ```
106
+
107
+ @category Utilities
108
+ */
109
+ type OptionalKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
110
+ ? (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`
111
+ : never;
112
+ //#endregion
113
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/required-keys-of.d.ts
114
+ /**
115
+ Extract all required keys from the given type.
116
+
117
+ 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...
118
+
119
+ @example
120
+ ```
121
+ import type {RequiredKeysOf} from 'type-fest';
122
+
123
+ declare function createValidation<
124
+ Entity extends object,
125
+ Key extends RequiredKeysOf<Entity> = RequiredKeysOf<Entity>,
126
+ >(field: Key, validator: (value: Entity[Key]) => boolean): (entity: Entity) => boolean;
127
+
128
+ type User = {
129
+ name: string;
130
+ surname: string;
131
+ luckyNumber?: number;
132
+ };
133
+
134
+ const validator1 = createValidation<User>('name', value => value.length < 25);
135
+ const validator2 = createValidation<User>('surname', value => value.length < 25);
136
+
137
+ // @ts-expect-error
138
+ const validator3 = createValidation<User>('luckyNumber', value => value > 0);
139
+ // Error: Argument of type '"luckyNumber"' is not assignable to parameter of type '"name" | "surname"'.
140
+ ```
141
+
142
+ @category Utilities
143
+ */
144
+ type RequiredKeysOf<Type extends object> = Type extends unknown // For distributing `Type`
145
+ ? Exclude<keyof Type, OptionalKeysOf<Type>> : never;
146
+ //#endregion
147
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-never.d.ts
148
+ /**
149
+ Returns a boolean for whether the given type is `never`.
150
+
151
+ @link https://github.com/microsoft/TypeScript/issues/31751#issuecomment-498526919
152
+ @link https://stackoverflow.com/a/53984913/10292952
153
+ @link https://www.zhenghao.io/posts/ts-never
154
+
155
+ Useful in type utilities, such as checking if something does not occur.
156
+
157
+ @example
158
+ ```
159
+ import type {IsNever, And} from 'type-fest';
160
+
161
+ type A = IsNever<never>;
162
+ //=> true
163
+
164
+ type B = IsNever<any>;
165
+ //=> false
166
+
167
+ type C = IsNever<unknown>;
168
+ //=> false
169
+
170
+ type D = IsNever<never[]>;
171
+ //=> false
172
+
173
+ type E = IsNever<object>;
174
+ //=> false
175
+
176
+ type F = IsNever<string>;
177
+ //=> false
178
+ ```
179
+
180
+ @example
181
+ ```
182
+ import type {IsNever} from 'type-fest';
183
+
184
+ type IsTrue<T> = T extends true ? true : false;
185
+
186
+ // When a distributive conditional is instantiated with `never`, the entire conditional results in `never`.
187
+ type A = IsTrue<never>;
188
+ // ^? type A = never
189
+
190
+ // If you don't want that behaviour, you can explicitly add an `IsNever` check before the distributive conditional.
191
+ type IsTrueFixed<T> =
192
+ IsNever<T> extends true ? false : T extends true ? true : false;
193
+
194
+ type B = IsTrueFixed<never>;
195
+ // ^? type B = false
196
+ ```
197
+
198
+ @category Type Guard
199
+ @category Utilities
200
+ */
201
+ type IsNever<T> = [T] extends [never] ? true : false;
202
+ //#endregion
203
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/if.d.ts
204
+ /**
205
+ An if-else-like type that resolves depending on whether the given `boolean` type is `true` or `false`.
206
+
207
+ Use-cases:
208
+ - 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'>`.
209
+
210
+ Note:
211
+ - 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'`.
212
+ - Returns the else branch if the given type is `never`. For example, `If<never, 'Y', 'N'>` will return `'N'`.
213
+
214
+ @example
215
+ ```
216
+ import type {If} from 'type-fest';
217
+
218
+ type A = If<true, 'yes', 'no'>;
219
+ //=> 'yes'
220
+
221
+ type B = If<false, 'yes', 'no'>;
222
+ //=> 'no'
223
+
224
+ type C = If<boolean, 'yes', 'no'>;
225
+ //=> 'yes' | 'no'
226
+
227
+ type D = If<any, 'yes', 'no'>;
228
+ //=> 'yes' | 'no'
229
+
230
+ type E = If<never, 'yes', 'no'>;
231
+ //=> 'no'
232
+ ```
233
+
234
+ @example
235
+ ```
236
+ import type {If, IsAny, IsNever} from 'type-fest';
237
+
238
+ type A = If<IsAny<unknown>, 'is any', 'not any'>;
239
+ //=> 'not any'
240
+
241
+ type B = If<IsNever<never>, 'is never', 'not never'>;
242
+ //=> 'is never'
243
+ ```
244
+
245
+ @example
246
+ ```
247
+ import type {If, IsEqual} from 'type-fest';
248
+
249
+ type IfEqual<T, U, IfBranch, ElseBranch> = If<IsEqual<T, U>, IfBranch, ElseBranch>;
250
+
251
+ type A = IfEqual<string, string, 'equal', 'not equal'>;
252
+ //=> 'equal'
253
+
254
+ type B = IfEqual<string, number, 'equal', 'not equal'>;
255
+ //=> 'not equal'
256
+ ```
257
+
258
+ 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:
259
+
260
+ @example
261
+ ```
262
+ import type {If, IsEqual, StringRepeat} from 'type-fest';
263
+
264
+ type HundredZeroes = StringRepeat<'0', 100>;
265
+
266
+ // The following implementation is not tail recursive
267
+ type Includes<S extends string, Char extends string> =
268
+ S extends `${infer First}${infer Rest}`
269
+ ? If<IsEqual<First, Char>,
270
+ 'found',
271
+ Includes<Rest, Char>>
272
+ : 'not found';
273
+
274
+ // Hence, instantiations with long strings will fail
275
+ // @ts-expect-error
276
+ type Fails = Includes<HundredZeroes, '1'>;
277
+ // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
278
+ // Error: Type instantiation is excessively deep and possibly infinite.
279
+
280
+ // However, if we use a simple conditional instead of `If`, the implementation becomes tail-recursive
281
+ type IncludesWithoutIf<S extends string, Char extends string> =
282
+ S extends `${infer First}${infer Rest}`
283
+ ? IsEqual<First, Char> extends true
284
+ ? 'found'
285
+ : IncludesWithoutIf<Rest, Char>
286
+ : 'not found';
287
+
288
+ // Now, instantiations with long strings will work
289
+ type Works = IncludesWithoutIf<HundredZeroes, '1'>;
290
+ //=> 'not found'
291
+ ```
292
+
293
+ @category Type Guard
294
+ @category Utilities
295
+ */
296
+ type If<Type extends boolean, IfBranch, ElseBranch> = IsNever<Type> extends true ? ElseBranch : Type extends true ? IfBranch : ElseBranch;
297
+ //#endregion
298
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/simplify.d.ts
299
+ /**
300
+ 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.
301
+
302
+ @example
303
+ ```
304
+ import type {Simplify} from 'type-fest';
305
+
306
+ type PositionProps = {
307
+ top: number;
308
+ left: number;
309
+ };
310
+
311
+ type SizeProps = {
312
+ width: number;
313
+ height: number;
314
+ };
315
+
316
+ // In your editor, hovering over `Props` will show a flattened object with all the properties.
317
+ type Props = Simplify<PositionProps & SizeProps>;
318
+ ```
319
+
320
+ 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.
321
+
322
+ 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`.
323
+
324
+ @example
325
+ ```
326
+ import type {Simplify} from 'type-fest';
327
+
328
+ interface SomeInterface {
329
+ foo: number;
330
+ bar?: string;
331
+ baz: number | undefined;
332
+ }
333
+
334
+ type SomeType = {
335
+ foo: number;
336
+ bar?: string;
337
+ baz: number | undefined;
338
+ };
339
+
340
+ const literal = {foo: 123, bar: 'hello', baz: 456};
341
+ const someType: SomeType = literal;
342
+ const someInterface: SomeInterface = literal;
343
+
344
+ declare function fn(object: Record<string, unknown>): void;
345
+
346
+ fn(literal); // Good: literal object type is sealed
347
+ fn(someType); // Good: type is sealed
348
+ // @ts-expect-error
349
+ fn(someInterface); // Error: Index signature for type 'string' is missing in type 'someInterface'. Because `interface` can be re-opened
350
+ fn(someInterface as Simplify<SomeInterface>); // Good: transform an `interface` into a `type`
351
+ ```
352
+
353
+ @link https://github.com/microsoft/TypeScript/issues/15300
354
+ @see {@link SimplifyDeep}
355
+ @category Object
356
+ */
357
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
358
+ //#endregion
359
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/is-equal.d.ts
360
+ /**
361
+ Returns a boolean for whether the two given types are equal.
362
+
363
+ @link https://github.com/microsoft/TypeScript/issues/27024#issuecomment-421529650
364
+ @link https://stackoverflow.com/questions/68961864/how-does-the-equals-work-in-typescript/68963796#68963796
365
+
366
+ Use-cases:
367
+ - If you want to make a conditional branch based on the result of a comparison of two types.
368
+
369
+ @example
370
+ ```
371
+ import type {IsEqual} from 'type-fest';
372
+
373
+ // This type returns a boolean for whether the given array includes the given item.
374
+ // `IsEqual` is used to compare the given array at position 0 and the given item and then return true if they are equal.
375
+ type Includes<Value extends readonly any[], Item> =
376
+ Value extends readonly [Value[0], ...infer rest]
377
+ ? IsEqual<Value[0], Item> extends true
378
+ ? true
379
+ : Includes<rest, Item>
380
+ : false;
381
+ ```
382
+
383
+ @category Type Guard
384
+ @category Utilities
385
+ */
386
+ type IsEqual<A, B> = [A] extends [B] ? [B] extends [A] ? _IsEqual<A, B> : false : false;
387
+ // This version fails the `equalWrappedTupleIntersectionToBeNeverAndNeverExpanded` test in `test-d/is-equal.ts`.
388
+ type _IsEqual<A, B> = (<G>() => G extends A & G | G ? 1 : 2) extends (<G>() => G extends B & G | G ? 1 : 2) ? true : false;
389
+ //#endregion
390
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/omit-index-signature.d.ts
391
+ /**
392
+ Omit any index signatures from the given object type, leaving only explicitly defined properties.
393
+
394
+ This is the counterpart of `PickIndexSignature`.
395
+
396
+ Use-cases:
397
+ - Remove overly permissive signatures from third-party types.
398
+
399
+ This type was taken from this [StackOverflow answer](https://stackoverflow.com/a/68261113/420747).
400
+
401
+ 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>`.
402
+
403
+ (The actual value type, `unknown`, is irrelevant and could be any type. Only the key type matters.)
404
+
405
+ ```
406
+ const indexed: Record<string, unknown> = {}; // Allowed
407
+
408
+ // @ts-expect-error
409
+ const keyed: Record<'foo', unknown> = {}; // Error
410
+ // => TS2739: Type '{}' is missing the following properties from type 'Record<"foo" | "bar", unknown>': foo, bar
411
+ ```
412
+
413
+ 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:
414
+
415
+ ```
416
+ type Indexed = {} extends Record<string, unknown>
417
+ ? '✅ `{}` is assignable to `Record<string, unknown>`'
418
+ : '❌ `{}` is NOT assignable to `Record<string, unknown>`';
419
+ // => '✅ `{}` is assignable to `Record<string, unknown>`'
420
+
421
+ type Keyed = {} extends Record<'foo' | 'bar', unknown>
422
+ ? '✅ `{}` is assignable to `Record<\'foo\' | \'bar\', unknown>`'
423
+ : '❌ `{}` is NOT assignable to `Record<\'foo\' | \'bar\', unknown>`';
424
+ // => "❌ `{}` is NOT assignable to `Record<'foo' | 'bar', unknown>`"
425
+ ```
426
+
427
+ 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`...
428
+
429
+ ```
430
+ type OmitIndexSignature<ObjectType> = {
431
+ [KeyType in keyof ObjectType // Map each key of `ObjectType`...
432
+ ]: ObjectType[KeyType]; // ...to its original value, i.e. `OmitIndexSignature<Foo> == Foo`.
433
+ };
434
+ ```
435
+
436
+ ...whether an empty object (`{}`) would be assignable to an object with that `KeyType` (`Record<KeyType, unknown>`)...
437
+
438
+ ```
439
+ type OmitIndexSignature<ObjectType> = {
440
+ [KeyType in keyof ObjectType
441
+ // Is `{}` assignable to `Record<KeyType, unknown>`?
442
+ as {} extends Record<KeyType, unknown>
443
+ ? never // ✅ `{}` is assignable to `Record<KeyType, unknown>`
444
+ : KeyType // ❌ `{}` is NOT assignable to `Record<KeyType, unknown>`
445
+ ]: ObjectType[KeyType];
446
+ };
447
+ ```
448
+
449
+ 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.
450
+
451
+ @example
452
+ ```
453
+ import type {OmitIndexSignature} from 'type-fest';
454
+
455
+ type Example = {
456
+ // These index signatures will be removed.
457
+ [x: string]: any;
458
+ [x: number]: any;
459
+ [x: symbol]: any;
460
+ [x: `head-${string}`]: string;
461
+ [x: `${string}-tail`]: string;
462
+ [x: `head-${string}-tail`]: string;
463
+ [x: `${bigint}`]: string;
464
+ [x: `embedded-${number}`]: string;
465
+
466
+ // These explicitly defined keys will remain.
467
+ foo: 'bar';
468
+ qux?: 'baz';
469
+ };
470
+
471
+ type ExampleWithoutIndexSignatures = OmitIndexSignature<Example>;
472
+ // => { foo: 'bar'; qux?: 'baz' | undefined; }
473
+ ```
474
+
475
+ @see {@link PickIndexSignature}
476
+ @category Object
477
+ */
478
+ type OmitIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? never : KeyType]: ObjectType[KeyType] };
479
+ //#endregion
480
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/pick-index-signature.d.ts
481
+ /**
482
+ Pick only index signatures from the given object type, leaving out all explicitly defined properties.
483
+
484
+ This is the counterpart of `OmitIndexSignature`.
485
+
486
+ @example
487
+ ```
488
+ import type {PickIndexSignature} from 'type-fest';
489
+
490
+ declare const symbolKey: unique symbol;
491
+
492
+ type Example = {
493
+ // These index signatures will remain.
494
+ [x: string]: unknown;
495
+ [x: number]: unknown;
496
+ [x: symbol]: unknown;
497
+ [x: `head-${string}`]: string;
498
+ [x: `${string}-tail`]: string;
499
+ [x: `head-${string}-tail`]: string;
500
+ [x: `${bigint}`]: string;
501
+ [x: `embedded-${number}`]: string;
502
+
503
+ // These explicitly defined keys will be removed.
504
+ ['kebab-case-key']: string;
505
+ [symbolKey]: string;
506
+ foo: 'bar';
507
+ qux?: 'baz';
508
+ };
509
+
510
+ type ExampleIndexSignature = PickIndexSignature<Example>;
511
+ // {
512
+ // [x: string]: unknown;
513
+ // [x: number]: unknown;
514
+ // [x: symbol]: unknown;
515
+ // [x: `head-${string}`]: string;
516
+ // [x: `${string}-tail`]: string;
517
+ // [x: `head-${string}-tail`]: string;
518
+ // [x: `${bigint}`]: string;
519
+ // [x: `embedded-${number}`]: string;
520
+ // }
521
+ ```
522
+
523
+ @see {@link OmitIndexSignature}
524
+ @category Object
525
+ */
526
+ type PickIndexSignature<ObjectType> = { [KeyType in keyof ObjectType as {} extends Record<KeyType, unknown> ? KeyType : never]: ObjectType[KeyType] };
527
+ //#endregion
528
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/merge.d.ts
529
+ // Merges two objects without worrying about index signatures.
530
+ type SimpleMerge<Destination, Source> = { [Key in keyof Destination as Key extends keyof Source ? never : Key]: Destination[Key] } & Source;
531
+
532
+ /**
533
+ Merge two types into a new type. Keys of the second type overrides keys of the first type.
534
+
535
+ @example
536
+ ```
537
+ import type {Merge} from 'type-fest';
538
+
539
+ type Foo = {
540
+ [x: string]: unknown;
541
+ [x: number]: unknown;
542
+ foo: string;
543
+ bar: symbol;
544
+ };
545
+
546
+ type Bar = {
547
+ [x: number]: number;
548
+ [x: symbol]: unknown;
549
+ bar: Date;
550
+ baz: boolean;
551
+ };
552
+
553
+ export type FooBar = Merge<Foo, Bar>;
554
+ // => {
555
+ // [x: string]: unknown;
556
+ // [x: number]: number;
557
+ // [x: symbol]: unknown;
558
+ // foo: string;
559
+ // bar: Date;
560
+ // baz: boolean;
561
+ // }
562
+ ```
563
+
564
+ @category Object
565
+ */
566
+ type Merge<Destination, Source> = Simplify<SimpleMerge<PickIndexSignature<Destination>, PickIndexSignature<Source>> & SimpleMerge<OmitIndexSignature<Destination>, OmitIndexSignature<Source>>>;
567
+ //#endregion
568
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/internal/object.d.ts
569
+
570
+ /**
571
+ Merges user specified options with default options.
572
+
573
+ @example
574
+ ```
575
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
576
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
577
+ type SpecifiedOptions = {leavesOnly: true};
578
+
579
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
580
+ //=> {maxRecursionDepth: 10; leavesOnly: true}
581
+ ```
582
+
583
+ @example
584
+ ```
585
+ // Complains if default values are not provided for optional options
586
+
587
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
588
+ type DefaultPathsOptions = {maxRecursionDepth: 10};
589
+ type SpecifiedOptions = {};
590
+
591
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
592
+ // ~~~~~~~~~~~~~~~~~~~
593
+ // Property 'leavesOnly' is missing in type 'DefaultPathsOptions' but required in type '{ maxRecursionDepth: number; leavesOnly: boolean; }'.
594
+ ```
595
+
596
+ @example
597
+ ```
598
+ // Complains if an option's default type does not conform to the expected type
599
+
600
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
601
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: 'no'};
602
+ type SpecifiedOptions = {};
603
+
604
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
605
+ // ~~~~~~~~~~~~~~~~~~~
606
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
607
+ ```
608
+
609
+ @example
610
+ ```
611
+ // Complains if an option's specified type does not conform to the expected type
612
+
613
+ type PathsOptions = {maxRecursionDepth?: number; leavesOnly?: boolean};
614
+ type DefaultPathsOptions = {maxRecursionDepth: 10; leavesOnly: false};
615
+ type SpecifiedOptions = {leavesOnly: 'yes'};
616
+
617
+ type Result = ApplyDefaultOptions<PathsOptions, DefaultPathsOptions, SpecifiedOptions>;
618
+ // ~~~~~~~~~~~~~~~~
619
+ // Types of property 'leavesOnly' are incompatible. Type 'string' is not assignable to type 'boolean'.
620
+ ```
621
+ */
622
+ type ApplyDefaultOptions<Options extends object, Defaults extends Simplify<Omit<Required<Options>, RequiredKeysOf<Options>> & Partial<Record<RequiredKeysOf<Options>, never>>>, SpecifiedOptions extends Options> = If<IsAny<SpecifiedOptions>, Defaults, If<IsNever<SpecifiedOptions>, Defaults, Simplify<Merge<Defaults, { [Key in keyof SpecifiedOptions as Key extends OptionalKeysOf<Options> ? undefined extends SpecifiedOptions[Key] ? never : Key : Key]: SpecifiedOptions[Key] }> & Required<Options>>>>;
623
+ //#endregion
624
+ //#region node_modules/.pnpm/type-fest@5.3.1/node_modules/type-fest/source/except.d.ts
625
+ /**
626
+ Filter out keys from an object.
627
+
628
+ Returns `never` if `Exclude` is strictly equal to `Key`.
629
+ Returns `never` if `Key` extends `Exclude`.
630
+ Returns `Key` otherwise.
631
+
632
+ @example
633
+ ```
634
+ type Filtered = Filter<'foo', 'foo'>;
635
+ //=> never
636
+ ```
637
+
638
+ @example
639
+ ```
640
+ type Filtered = Filter<'bar', string>;
641
+ //=> never
642
+ ```
643
+
644
+ @example
645
+ ```
646
+ type Filtered = Filter<'bar', 'foo'>;
647
+ //=> 'bar'
648
+ ```
649
+
650
+ @see {Except}
651
+ */
652
+ type Filter<KeyType$1, ExcludeType> = IsEqual<KeyType$1, ExcludeType> extends true ? never : (KeyType$1 extends ExcludeType ? never : KeyType$1);
653
+ type ExceptOptions = {
654
+ /**
655
+ Disallow assigning non-specified properties.
656
+ Note that any omitted properties in the resulting type will be present in autocomplete as `undefined`.
657
+ @default false
658
+ */
659
+ requireExactProps?: boolean;
660
+ };
661
+ type DefaultExceptOptions = {
662
+ requireExactProps: false;
663
+ };
664
+
665
+ /**
666
+ Create a type from an object type without certain keys.
667
+
668
+ We recommend setting the `requireExactProps` option to `true`.
669
+
670
+ This type is a stricter version of [`Omit`](https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-5.html#the-omit-helper-type). The `Omit` type does not restrict the omitted keys to be keys present on the given type, while `Except` does. The benefits of a stricter type are avoiding typos and allowing the compiler to pick up on rename refactors automatically.
671
+
672
+ This type was proposed to the TypeScript team, which declined it, saying they prefer that libraries implement stricter versions of the built-in types ([microsoft/TypeScript#30825](https://github.com/microsoft/TypeScript/issues/30825#issuecomment-523668235)).
673
+
674
+ @example
675
+ ```
676
+ import type {Except} from 'type-fest';
677
+
678
+ type Foo = {
679
+ a: number;
680
+ b: string;
681
+ };
682
+
683
+ type FooWithoutA = Except<Foo, 'a'>;
684
+ //=> {b: string}
685
+
686
+ // @ts-expect-error
687
+ const fooWithoutA: FooWithoutA = {a: 1, b: '2'};
688
+ //=> errors: 'a' does not exist in type '{ b: string; }'
689
+
690
+ type FooWithoutB = Except<Foo, 'b', {requireExactProps: true}>;
691
+ //=> {a: number} & Partial<Record<"b", never>>
692
+
693
+ // @ts-expect-error
694
+ const fooWithoutB: FooWithoutB = {a: 1, b: '2'};
695
+ //=> errors at 'b': Type 'string' is not assignable to type 'undefined'.
696
+
697
+ // The `Omit` utility type doesn't work when omitting specific keys from objects containing index signatures.
698
+
699
+ // Consider the following example:
700
+
701
+ type UserData = {
702
+ [metadata: string]: string;
703
+ email: string;
704
+ name: string;
705
+ role: 'admin' | 'user';
706
+ };
707
+
708
+ // `Omit` clearly doesn't behave as expected in this case:
709
+ type PostPayload = Omit<UserData, 'email'>;
710
+ //=> { [x: string]: string; [x: number]: string; }
711
+
712
+ // In situations like this, `Except` works better.
713
+ // It simply removes the `email` key while preserving all the other keys.
714
+ type PostPayloadFixed = Except<UserData, 'email'>;
715
+ //=> { [x: string]: string; name: string; role: 'admin' | 'user'; }
716
+ ```
717
+
718
+ @category Object
719
+ */
720
+ type Except<ObjectType, KeysType extends keyof ObjectType, Options extends ExceptOptions = {}> = _Except<ObjectType, KeysType, ApplyDefaultOptions<ExceptOptions, DefaultExceptOptions, Options>>;
721
+ type _Except<ObjectType, KeysType extends keyof ObjectType, Options extends Required<ExceptOptions>> = { [KeyType in keyof ObjectType as Filter<KeyType, KeysType>]: ObjectType[KeyType] } & (Options['requireExactProps'] extends true ? Partial<Record<KeysType, never>> : {});
722
+ //#endregion
723
+ //#region src/patches/fetchEventSource/parse.d.ts
724
+ /**
725
+ * Represents a message sent in an event stream
726
+ * https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#Event_stream_format
727
+ */
728
+ interface EventSourceMessage {
729
+ /**
730
+ * The event ID to set the EventSource object's last event ID value.
731
+ */
732
+ id: string;
733
+ /**
734
+ * A string identifying the type of event described.
735
+ */
736
+ event: string;
737
+ /**
738
+ * The event data
739
+ */
740
+ data: string;
741
+ /**
742
+ * The delay to wait before reconnection.
743
+ * @unit ms
744
+ */
745
+ reconnectionDelay?: number | undefined;
746
+ }
747
+ //#endregion
748
+ //#region src/patches/fetchEventSource/fetchEventSource.d.ts
749
+ type FetchEventSourceOpenEvent = (response: Response) => void | Promise<void>;
750
+ type FetchEventSourceCloseEvent = () => void | Promise<void>;
751
+ type FetchEventSourceMessageEvent = (event: EventSourceMessage) => void | Promise<void>;
752
+ type FetchEventSourceErrorEvent = (error: unknown) => number | undefined | Promise<number | undefined>;
753
+ interface FetchEventSourceOptions extends Except<RequestInit, "headers"> {
754
+ /**
755
+ * The request headers.
756
+ * FetchEventSource only supports the plain object format.
757
+ */
758
+ headers?: PlainObject | AnyFunction<unknown[], PlainObject> | undefined;
759
+ /**
760
+ * Called when a response is received.
761
+ * Use this to validate that the response actually matches what you expect (and throw if it doesn't.) If not provided, will default to a basic validation to ensure the content-type is text/event-stream.
762
+ */
763
+ onopen?: FetchEventSourceOpenEvent | undefined;
764
+ /**
765
+ * Called when a response finishes.
766
+ * If you don't expect the server to kill the connection, you can throw an exception here and retry using onerror.
767
+ */
768
+ onclose?: FetchEventSourceCloseEvent | undefined;
769
+ /**
770
+ * Called when a message is received.
771
+ * Unlike the default browser EventSource.onmessage, this callback is called for _all_ events, even ones with a custom `event` field.
772
+ */
773
+ onmessage?: FetchEventSourceMessageEvent | undefined;
774
+ /**
775
+ * Called when there is any error making the request / processing messages / handling callbacks etc.
776
+ * Use this to control the retry strategy: if the error is fatal, rethrow the error inside the callback to stop the entire operation.
777
+ * Otherwise, you can return an interval (in milliseconds) after which the request will automatically retry (with the last-event-id).
778
+ * If this callback is not specified, or it returns undefined, fetchEventSource will treat every error as retryable and will try again after 1 second.
779
+ */
780
+ onerror?: FetchEventSourceErrorEvent | undefined;
781
+ /**
782
+ * By default, will keep the request open even if the document is hidden.
783
+ * If false, fetchEventSource will close the request and reopen it automatically when the document becomes visible again.
784
+ * @default true
785
+ */
786
+ isKeepConnect?: boolean | undefined;
787
+ /**
788
+ * The delay to wait before reconnection.
789
+ * @unit ms
790
+ * @default 1000
791
+ */
792
+ reconnectionDelay?: number | undefined;
793
+ /**
794
+ * The Fetch function to use.
795
+ * @default fetch
796
+ */
797
+ fetch?: typeof fetch | undefined;
798
+ }
799
+ /**
800
+ * `@microsoft/fetch-event-source` 的修补版本
801
+ * @see https://github.com/Azure/fetch-event-source
802
+ */
803
+ declare function fetchEventSource(input: RequestInfo, options?: FetchEventSourceOptions | undefined): Promise<void>;
804
+ //#endregion
805
+ export { FetchEventSourceCloseEvent, FetchEventSourceErrorEvent, FetchEventSourceMessageEvent, FetchEventSourceOpenEvent, FetchEventSourceOptions, fetchEventSource };
806
+ //# sourceMappingURL=patches-fetchEventSource.d.ts.map