xenopomp-essentials 0.0.1-beta.3 → 0.0.1-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +64 -7
- package/dist/index.d.ts +64 -7
- package/dist/next.d.mts +28 -0
- package/dist/next.d.ts +28 -0
- package/dist/next.mjs +1 -0
- package/package.json +4 -1
- package/dist/next/index.d.mts +0 -2
- package/dist/next/index.d.ts +0 -2
- package/dist/next/index.mjs +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { ElementType, ComponentProps, FC, ReactNode, Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { Jsonifiable } from 'type-fest';
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Matches any object but not arrays, class instances etc.
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
*/
|
|
5
8
|
type AnyObject = Record<PropertyKey, unknown>;
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* This type stands for empty object type.
|
|
9
12
|
*
|
|
13
|
+
* @since 0.0.1
|
|
10
14
|
* @example
|
|
11
15
|
* const message: EmptyObject = { type: string; }; // Will cause error.
|
|
12
16
|
*/
|
|
@@ -17,21 +21,31 @@ type EmptyObject = Record<PropertyKey, never>;
|
|
|
17
21
|
* as representation of any function, also you can create cleaner type declarations
|
|
18
22
|
* for functions.
|
|
19
23
|
*
|
|
24
|
+
* @since 0.0.1
|
|
20
25
|
* @example
|
|
21
26
|
* type MyFn = Fn<[a: string, b: string], string>;
|
|
22
27
|
*/
|
|
23
28
|
type Fn<Args extends any[] = any[], Res = unknown> = (...args: Args) => Res;
|
|
24
29
|
|
|
25
30
|
type ParamObj<P extends string> = Record<P, string>;
|
|
26
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Represents Next.js routing params.
|
|
33
|
+
* @since 0.0.1
|
|
34
|
+
*/
|
|
27
35
|
interface NextParams<P extends string> {
|
|
28
36
|
params: ParamObj<P>;
|
|
29
37
|
}
|
|
30
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Represents Next.js routing search params.
|
|
40
|
+
* @since 0.0.1
|
|
41
|
+
*/
|
|
31
42
|
interface NextSearchParams<P extends string> {
|
|
32
43
|
searchParams: ParamObj<P>;
|
|
33
44
|
}
|
|
34
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* This type describes Next error page params.
|
|
47
|
+
* @since 0.0.1
|
|
48
|
+
*/
|
|
35
49
|
interface NextErrorParams<E extends Error = any> {
|
|
36
50
|
error: E;
|
|
37
51
|
reset: () => void;
|
|
@@ -44,6 +58,8 @@ interface NextErrorParams<E extends Error = any> {
|
|
|
44
58
|
* * __P__ - wrapping props
|
|
45
59
|
* * __Ex__ - excluded component props (for example, if you do not want to include 'children' prop in component)
|
|
46
60
|
*
|
|
61
|
+
* @since 0.0.1
|
|
62
|
+
*
|
|
47
63
|
* @example
|
|
48
64
|
* type VariableComponentPropsWithChildren = ComponentProps<VariableFC<'div'>>;
|
|
49
65
|
* type VariableComponentPropsWithoutChildren = ComponentProps<VariableFC<'div', {}, 'children'>>;
|
|
@@ -67,12 +83,14 @@ interface NextErrorParams<E extends Error = any> {
|
|
|
67
83
|
type VariableFC<A extends ElementType, P = unknown, Ex extends keyof ComponentProps<A> | undefined = undefined> = FC<P & WeakOmit<ComponentProps<A>, Ex>>;
|
|
68
84
|
/**
|
|
69
85
|
* Works similar to {@link VariableFC}, but return type is Promise<ReactNode>;
|
|
86
|
+
* @since 0.0.1
|
|
70
87
|
*/
|
|
71
88
|
type AsyncVariableFC<A extends ElementType, P = unknown, Ex extends keyof ComponentProps<A> | undefined = undefined> = AsyncFC<P & WeakOmit<ComponentProps<A>, Ex>>;
|
|
72
89
|
|
|
73
90
|
/**
|
|
74
91
|
* Same as **FC** (or FunctionalComponent), but it returns Promise.
|
|
75
92
|
*
|
|
93
|
+
* @since 0.0.1
|
|
76
94
|
* @example
|
|
77
95
|
* const Header: AsyncFC<HeaderProps> = async ({}) => {
|
|
78
96
|
* // Do async stuff here...
|
|
@@ -85,6 +103,7 @@ type AsyncFC<T = unknown> = ReplaceReturnType<FC<T>, Promise<ReactNode>>;
|
|
|
85
103
|
/**
|
|
86
104
|
* Type of set state function from useState.
|
|
87
105
|
*
|
|
106
|
+
* @since 0.0.1
|
|
88
107
|
* @example
|
|
89
108
|
* // typeof setState => SetState<string>
|
|
90
109
|
* const [state, setState] = useState<string>('example');
|
|
@@ -94,6 +113,7 @@ type SetState<TType> = Dispatch<SetStateAction<TType>>;
|
|
|
94
113
|
/**
|
|
95
114
|
* This type allows you to make children that can be function.
|
|
96
115
|
*
|
|
116
|
+
* @since 0.0.1
|
|
97
117
|
* @example
|
|
98
118
|
* type Child = FunctionalChildren<[options: string]>;
|
|
99
119
|
* // ReactNode | ((options: string) => ReactNode)
|
|
@@ -103,6 +123,7 @@ type FunctionalChildren<Args extends any[]> = ReactNode | ((...args: Args) => Re
|
|
|
103
123
|
/**
|
|
104
124
|
* Extracts type of props from FC type.
|
|
105
125
|
*
|
|
126
|
+
* @since 0.0.1
|
|
106
127
|
* @example
|
|
107
128
|
* type Props = FcProps<FC<{ align?: boolean }>>;
|
|
108
129
|
* // ^? { align?: boolean }
|
|
@@ -117,6 +138,7 @@ type FcProps<Comp> = Comp extends FC<infer Props> ? Props : never;
|
|
|
117
138
|
*
|
|
118
139
|
* Return never, if __Func__ is not a function, actually.
|
|
119
140
|
*
|
|
141
|
+
* @since 0.0.1
|
|
120
142
|
* @example
|
|
121
143
|
* type NormalFunc = Synchronous<(one: string, two: number) => void>; // (one: string, two: number) => void
|
|
122
144
|
* type AsyncFunc = Synchronous<(one: string, two: number) => Promise<void>>; // (one: string, two: number) => void
|
|
@@ -126,12 +148,14 @@ type Synchronous<Func> = Func extends Fn ? Func extends (...args: any[]) => Prom
|
|
|
126
148
|
|
|
127
149
|
/**
|
|
128
150
|
* Removes readonly from type.
|
|
151
|
+
* @since 0.0.1
|
|
129
152
|
*/
|
|
130
153
|
type Writeable<T> = {
|
|
131
154
|
-readonly [P in keyof T]: T[P];
|
|
132
155
|
};
|
|
133
156
|
/**
|
|
134
157
|
* Removes readonly from type deeply.
|
|
158
|
+
* @since 0.0.1
|
|
135
159
|
*/
|
|
136
160
|
type DeepWriteable<T> = {
|
|
137
161
|
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
@@ -140,6 +164,8 @@ type DeepWriteable<T> = {
|
|
|
140
164
|
/**
|
|
141
165
|
* Checks if type **T** matches type **M**.
|
|
142
166
|
*
|
|
167
|
+
* @since 0.0.1
|
|
168
|
+
*
|
|
143
169
|
* @example Not matching
|
|
144
170
|
* type ViewStyles = {
|
|
145
171
|
* paddingHorizontal: number
|
|
@@ -165,6 +191,7 @@ type MatchType<T extends M, M> = T extends M ? T : never;
|
|
|
165
191
|
/**
|
|
166
192
|
* This type gets type of array`s item.
|
|
167
193
|
*
|
|
194
|
+
* @since 0.0.1
|
|
168
195
|
* @example
|
|
169
196
|
* type Super = ArrayType<string[]>; // string
|
|
170
197
|
*
|
|
@@ -176,6 +203,7 @@ type ArrayItemType<T> = ArrayType<T>;
|
|
|
176
203
|
/**
|
|
177
204
|
* Get return type of function that returns Promise ((...args: any) => Promise<any>).
|
|
178
205
|
*
|
|
206
|
+
* @since 0.0.1
|
|
179
207
|
* @example
|
|
180
208
|
* const doSomething = async (): Promise<string|number> => {
|
|
181
209
|
* return 'result';
|
|
@@ -189,6 +217,7 @@ type AsyncReturnType<F extends (...args: any[]) => Promise<any>> = Awaited<Retur
|
|
|
189
217
|
/**
|
|
190
218
|
* Recursevely add some type inside all keys of target type.
|
|
191
219
|
*
|
|
220
|
+
* @since 0.0.1
|
|
192
221
|
* @example
|
|
193
222
|
* type Sups = DeepInject<{ supa: { sups: number } }, { _ignore: boolean }>;
|
|
194
223
|
* const asp: Sups = { supa: { sups: 1, _ignore: false }, _ignore: false };
|
|
@@ -199,12 +228,14 @@ type DeepInject<T, I extends AnyObject> = T extends object ? {
|
|
|
199
228
|
|
|
200
229
|
/**
|
|
201
230
|
* Removes undefined from union type.
|
|
231
|
+
* @since 0.0.1
|
|
202
232
|
*/
|
|
203
233
|
type Defined<T> = Exclude<T, undefined>;
|
|
204
234
|
|
|
205
235
|
/**
|
|
206
236
|
* Return never if type does not match JSON schema.
|
|
207
237
|
*
|
|
238
|
+
* @since 0.0.1
|
|
208
239
|
* @example
|
|
209
240
|
* type Schema = Jsonish<{ sus: string; am: string; }>; // OK
|
|
210
241
|
* type AlterSchema = Jsonish<{ sus: string; am: () => {}; }>; // Causes error
|
|
@@ -214,6 +245,7 @@ type Jsonish<T extends Jsonifiable> = T extends Jsonifiable ? T : never;
|
|
|
214
245
|
/**
|
|
215
246
|
* Modifies K (Key) in T (Type), replace it with R (Replacement).
|
|
216
247
|
*
|
|
248
|
+
* @since 0.0.1
|
|
217
249
|
* @example
|
|
218
250
|
* type ExcludedStore = Modify<IStore, 'appSettings', { appName: 'Simple name' }>; // Key in IStore has been replaced with new type.
|
|
219
251
|
*/
|
|
@@ -221,12 +253,16 @@ type Modify<T, K extends keyof T, R> = Omit<T, K> & {
|
|
|
221
253
|
[Key in K]: R;
|
|
222
254
|
};
|
|
223
255
|
|
|
224
|
-
/**
|
|
256
|
+
/**
|
|
257
|
+
* Make union type of T and null.
|
|
258
|
+
* @since 0.0.1
|
|
259
|
+
*/
|
|
225
260
|
type Nullable<T> = T | null;
|
|
226
261
|
|
|
227
262
|
/**
|
|
228
263
|
* Get typeof key of Record.
|
|
229
264
|
*
|
|
265
|
+
* @since 0.0.1
|
|
230
266
|
* @example
|
|
231
267
|
* type Key = RecordKey<Record<string, number>>; // string
|
|
232
268
|
*/
|
|
@@ -235,6 +271,7 @@ type RecordKey<R extends Record<any, any>> = R extends Record<infer K, any> ? K
|
|
|
235
271
|
/**
|
|
236
272
|
* Get typeof value of Record.
|
|
237
273
|
*
|
|
274
|
+
* @since 0.0.1
|
|
238
275
|
* @example
|
|
239
276
|
* type Value = RecordValue<Record<string, number>>; // number
|
|
240
277
|
*/
|
|
@@ -243,6 +280,7 @@ type RecordValue<R extends Record<any, any>> = R extends Record<any, infer V> ?
|
|
|
243
280
|
/**
|
|
244
281
|
* This type replace return type of function with other type.
|
|
245
282
|
*
|
|
283
|
+
* @since 0.0.1
|
|
246
284
|
* @example
|
|
247
285
|
* type StringFC<T = {}> = ReplaceReturnType<FC<T>, string>;
|
|
248
286
|
*/
|
|
@@ -251,6 +289,7 @@ type ReplaceReturnType<TFn, TR> = TFn extends (...a: infer A) => any ? (...a: A)
|
|
|
251
289
|
/**
|
|
252
290
|
* Works as Partial, but makes only specified keys partial.
|
|
253
291
|
*
|
|
292
|
+
* @since 0.0.1
|
|
254
293
|
* @example
|
|
255
294
|
* type Super = SelectivePartial<{
|
|
256
295
|
* name: string;
|
|
@@ -266,6 +305,7 @@ type SelectivePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
|
266
305
|
|
|
267
306
|
/**
|
|
268
307
|
* Makes type union of type T and undefined
|
|
308
|
+
* @since 0.0.1
|
|
269
309
|
*/
|
|
270
310
|
type Undefinable<T> = T | undefined;
|
|
271
311
|
|
|
@@ -273,6 +313,7 @@ type Undefinable<T> = T | undefined;
|
|
|
273
313
|
* The strict version of Omit. Allows to remove only
|
|
274
314
|
* keys that are presented in T type.
|
|
275
315
|
*
|
|
316
|
+
* @since 0.0.1
|
|
276
317
|
* @example
|
|
277
318
|
* type Tree = {
|
|
278
319
|
* height: number;
|
|
@@ -290,6 +331,7 @@ type StrictOmit<T, K extends keyof T> = Omit<T, K>;
|
|
|
290
331
|
|
|
291
332
|
/**
|
|
292
333
|
* Extracts first type from two generics. Is helper type for {@link OneOf} type.
|
|
334
|
+
* @since 0.0.1
|
|
293
335
|
*/
|
|
294
336
|
type OnlyFirst<F, S> = F & {
|
|
295
337
|
[Key in keyof Omit<S, keyof F>]?: never;
|
|
@@ -297,6 +339,7 @@ type OnlyFirst<F, S> = F & {
|
|
|
297
339
|
/**
|
|
298
340
|
* Chooses only one of types array.
|
|
299
341
|
*
|
|
342
|
+
* @since 0.0.1
|
|
300
343
|
* @example
|
|
301
344
|
* type Email = {
|
|
302
345
|
* person: string;
|
|
@@ -324,12 +367,14 @@ type OneOf<TypesArray extends any[], Res = never, AllProperties = MergeTypes<Typ
|
|
|
324
367
|
|
|
325
368
|
/**
|
|
326
369
|
* Merge array of types to one type.
|
|
370
|
+
* @since 0.0.1
|
|
327
371
|
*/
|
|
328
372
|
type MergeTypes<TypesArray extends any[], Res = EmptyObject> = TypesArray extends [infer Head, ...infer Rem] ? MergeTypes<Rem, Res & Head> : Res;
|
|
329
373
|
|
|
330
374
|
/**
|
|
331
375
|
* Allows to pass undefined as Omit`s generic. Weakly omits type.
|
|
332
376
|
*
|
|
377
|
+
* @since 0.0.1
|
|
333
378
|
* @example
|
|
334
379
|
* // Will not omit any keys
|
|
335
380
|
* type Lib = WeakOmit<{ bookCount: number; date: string }, undefined>;
|
|
@@ -342,6 +387,7 @@ type WeakOmit<Obj extends AnyObject, Keys extends keyof Obj | undefined = undefi
|
|
|
342
387
|
/**
|
|
343
388
|
* Makes types don`t merging in unions.
|
|
344
389
|
*
|
|
390
|
+
* @since 0.0.1
|
|
345
391
|
* @example
|
|
346
392
|
* type Languages = 'TypeScript' | 'JavaScript' | Lenient<string>;
|
|
347
393
|
* // ^? "TypeScript" | "JavaScript" | string
|
|
@@ -351,6 +397,7 @@ type Lenient<T> = T & {};
|
|
|
351
397
|
* This type allows any string, but also saves compiler`s autocomplete
|
|
352
398
|
* feature.
|
|
353
399
|
*
|
|
400
|
+
* @since 0.0.1
|
|
354
401
|
* @example
|
|
355
402
|
* type Languages = 'TypeScript' | 'JavaScript';
|
|
356
403
|
*
|
|
@@ -365,6 +412,8 @@ type LenientAutocomplete<T extends string> = T | Lenient<string>;
|
|
|
365
412
|
* Creates pipelines of functions that will be executed only
|
|
366
413
|
* when you will call whole pipeline.
|
|
367
414
|
*
|
|
415
|
+
* @since 0.0.1
|
|
416
|
+
*
|
|
368
417
|
* @param fn
|
|
369
418
|
*
|
|
370
419
|
* @example
|
|
@@ -414,9 +463,15 @@ declare function pipe<A, B>(fn: (a: A) => B): {
|
|
|
414
463
|
};
|
|
415
464
|
};
|
|
416
465
|
|
|
417
|
-
/**
|
|
466
|
+
/**
|
|
467
|
+
* Capitalizes string (makes first letter uppercase).
|
|
468
|
+
* @since 0.0.1
|
|
469
|
+
*/
|
|
418
470
|
declare function capitalize<T extends string>(str: T): Capitalize<T>;
|
|
419
|
-
/**
|
|
471
|
+
/**
|
|
472
|
+
* Un-capitalizes string (makes first letter lowercase).
|
|
473
|
+
* @since 0.0.1
|
|
474
|
+
*/
|
|
420
475
|
declare function uncapitalize<T extends string>(str: T): Uncapitalize<T>;
|
|
421
476
|
|
|
422
477
|
type Preid = 'alpha' | 'beta' | 'rc';
|
|
@@ -431,6 +486,8 @@ interface VersionData {
|
|
|
431
486
|
/**
|
|
432
487
|
* Parses version with preid.
|
|
433
488
|
*
|
|
489
|
+
* @since 0.0.1
|
|
490
|
+
*
|
|
434
491
|
* @param raw
|
|
435
492
|
*
|
|
436
493
|
* @example
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { ElementType, ComponentProps, FC, ReactNode, Dispatch, SetStateAction } from 'react';
|
|
2
2
|
import { Jsonifiable } from 'type-fest';
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/**
|
|
5
|
+
* Matches any object but not arrays, class instances etc.
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
*/
|
|
5
8
|
type AnyObject = Record<PropertyKey, unknown>;
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* This type stands for empty object type.
|
|
9
12
|
*
|
|
13
|
+
* @since 0.0.1
|
|
10
14
|
* @example
|
|
11
15
|
* const message: EmptyObject = { type: string; }; // Will cause error.
|
|
12
16
|
*/
|
|
@@ -17,21 +21,31 @@ type EmptyObject = Record<PropertyKey, never>;
|
|
|
17
21
|
* as representation of any function, also you can create cleaner type declarations
|
|
18
22
|
* for functions.
|
|
19
23
|
*
|
|
24
|
+
* @since 0.0.1
|
|
20
25
|
* @example
|
|
21
26
|
* type MyFn = Fn<[a: string, b: string], string>;
|
|
22
27
|
*/
|
|
23
28
|
type Fn<Args extends any[] = any[], Res = unknown> = (...args: Args) => Res;
|
|
24
29
|
|
|
25
30
|
type ParamObj<P extends string> = Record<P, string>;
|
|
26
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Represents Next.js routing params.
|
|
33
|
+
* @since 0.0.1
|
|
34
|
+
*/
|
|
27
35
|
interface NextParams<P extends string> {
|
|
28
36
|
params: ParamObj<P>;
|
|
29
37
|
}
|
|
30
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* Represents Next.js routing search params.
|
|
40
|
+
* @since 0.0.1
|
|
41
|
+
*/
|
|
31
42
|
interface NextSearchParams<P extends string> {
|
|
32
43
|
searchParams: ParamObj<P>;
|
|
33
44
|
}
|
|
34
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* This type describes Next error page params.
|
|
47
|
+
* @since 0.0.1
|
|
48
|
+
*/
|
|
35
49
|
interface NextErrorParams<E extends Error = any> {
|
|
36
50
|
error: E;
|
|
37
51
|
reset: () => void;
|
|
@@ -44,6 +58,8 @@ interface NextErrorParams<E extends Error = any> {
|
|
|
44
58
|
* * __P__ - wrapping props
|
|
45
59
|
* * __Ex__ - excluded component props (for example, if you do not want to include 'children' prop in component)
|
|
46
60
|
*
|
|
61
|
+
* @since 0.0.1
|
|
62
|
+
*
|
|
47
63
|
* @example
|
|
48
64
|
* type VariableComponentPropsWithChildren = ComponentProps<VariableFC<'div'>>;
|
|
49
65
|
* type VariableComponentPropsWithoutChildren = ComponentProps<VariableFC<'div', {}, 'children'>>;
|
|
@@ -67,12 +83,14 @@ interface NextErrorParams<E extends Error = any> {
|
|
|
67
83
|
type VariableFC<A extends ElementType, P = unknown, Ex extends keyof ComponentProps<A> | undefined = undefined> = FC<P & WeakOmit<ComponentProps<A>, Ex>>;
|
|
68
84
|
/**
|
|
69
85
|
* Works similar to {@link VariableFC}, but return type is Promise<ReactNode>;
|
|
86
|
+
* @since 0.0.1
|
|
70
87
|
*/
|
|
71
88
|
type AsyncVariableFC<A extends ElementType, P = unknown, Ex extends keyof ComponentProps<A> | undefined = undefined> = AsyncFC<P & WeakOmit<ComponentProps<A>, Ex>>;
|
|
72
89
|
|
|
73
90
|
/**
|
|
74
91
|
* Same as **FC** (or FunctionalComponent), but it returns Promise.
|
|
75
92
|
*
|
|
93
|
+
* @since 0.0.1
|
|
76
94
|
* @example
|
|
77
95
|
* const Header: AsyncFC<HeaderProps> = async ({}) => {
|
|
78
96
|
* // Do async stuff here...
|
|
@@ -85,6 +103,7 @@ type AsyncFC<T = unknown> = ReplaceReturnType<FC<T>, Promise<ReactNode>>;
|
|
|
85
103
|
/**
|
|
86
104
|
* Type of set state function from useState.
|
|
87
105
|
*
|
|
106
|
+
* @since 0.0.1
|
|
88
107
|
* @example
|
|
89
108
|
* // typeof setState => SetState<string>
|
|
90
109
|
* const [state, setState] = useState<string>('example');
|
|
@@ -94,6 +113,7 @@ type SetState<TType> = Dispatch<SetStateAction<TType>>;
|
|
|
94
113
|
/**
|
|
95
114
|
* This type allows you to make children that can be function.
|
|
96
115
|
*
|
|
116
|
+
* @since 0.0.1
|
|
97
117
|
* @example
|
|
98
118
|
* type Child = FunctionalChildren<[options: string]>;
|
|
99
119
|
* // ReactNode | ((options: string) => ReactNode)
|
|
@@ -103,6 +123,7 @@ type FunctionalChildren<Args extends any[]> = ReactNode | ((...args: Args) => Re
|
|
|
103
123
|
/**
|
|
104
124
|
* Extracts type of props from FC type.
|
|
105
125
|
*
|
|
126
|
+
* @since 0.0.1
|
|
106
127
|
* @example
|
|
107
128
|
* type Props = FcProps<FC<{ align?: boolean }>>;
|
|
108
129
|
* // ^? { align?: boolean }
|
|
@@ -117,6 +138,7 @@ type FcProps<Comp> = Comp extends FC<infer Props> ? Props : never;
|
|
|
117
138
|
*
|
|
118
139
|
* Return never, if __Func__ is not a function, actually.
|
|
119
140
|
*
|
|
141
|
+
* @since 0.0.1
|
|
120
142
|
* @example
|
|
121
143
|
* type NormalFunc = Synchronous<(one: string, two: number) => void>; // (one: string, two: number) => void
|
|
122
144
|
* type AsyncFunc = Synchronous<(one: string, two: number) => Promise<void>>; // (one: string, two: number) => void
|
|
@@ -126,12 +148,14 @@ type Synchronous<Func> = Func extends Fn ? Func extends (...args: any[]) => Prom
|
|
|
126
148
|
|
|
127
149
|
/**
|
|
128
150
|
* Removes readonly from type.
|
|
151
|
+
* @since 0.0.1
|
|
129
152
|
*/
|
|
130
153
|
type Writeable<T> = {
|
|
131
154
|
-readonly [P in keyof T]: T[P];
|
|
132
155
|
};
|
|
133
156
|
/**
|
|
134
157
|
* Removes readonly from type deeply.
|
|
158
|
+
* @since 0.0.1
|
|
135
159
|
*/
|
|
136
160
|
type DeepWriteable<T> = {
|
|
137
161
|
-readonly [P in keyof T]: DeepWriteable<T[P]>;
|
|
@@ -140,6 +164,8 @@ type DeepWriteable<T> = {
|
|
|
140
164
|
/**
|
|
141
165
|
* Checks if type **T** matches type **M**.
|
|
142
166
|
*
|
|
167
|
+
* @since 0.0.1
|
|
168
|
+
*
|
|
143
169
|
* @example Not matching
|
|
144
170
|
* type ViewStyles = {
|
|
145
171
|
* paddingHorizontal: number
|
|
@@ -165,6 +191,7 @@ type MatchType<T extends M, M> = T extends M ? T : never;
|
|
|
165
191
|
/**
|
|
166
192
|
* This type gets type of array`s item.
|
|
167
193
|
*
|
|
194
|
+
* @since 0.0.1
|
|
168
195
|
* @example
|
|
169
196
|
* type Super = ArrayType<string[]>; // string
|
|
170
197
|
*
|
|
@@ -176,6 +203,7 @@ type ArrayItemType<T> = ArrayType<T>;
|
|
|
176
203
|
/**
|
|
177
204
|
* Get return type of function that returns Promise ((...args: any) => Promise<any>).
|
|
178
205
|
*
|
|
206
|
+
* @since 0.0.1
|
|
179
207
|
* @example
|
|
180
208
|
* const doSomething = async (): Promise<string|number> => {
|
|
181
209
|
* return 'result';
|
|
@@ -189,6 +217,7 @@ type AsyncReturnType<F extends (...args: any[]) => Promise<any>> = Awaited<Retur
|
|
|
189
217
|
/**
|
|
190
218
|
* Recursevely add some type inside all keys of target type.
|
|
191
219
|
*
|
|
220
|
+
* @since 0.0.1
|
|
192
221
|
* @example
|
|
193
222
|
* type Sups = DeepInject<{ supa: { sups: number } }, { _ignore: boolean }>;
|
|
194
223
|
* const asp: Sups = { supa: { sups: 1, _ignore: false }, _ignore: false };
|
|
@@ -199,12 +228,14 @@ type DeepInject<T, I extends AnyObject> = T extends object ? {
|
|
|
199
228
|
|
|
200
229
|
/**
|
|
201
230
|
* Removes undefined from union type.
|
|
231
|
+
* @since 0.0.1
|
|
202
232
|
*/
|
|
203
233
|
type Defined<T> = Exclude<T, undefined>;
|
|
204
234
|
|
|
205
235
|
/**
|
|
206
236
|
* Return never if type does not match JSON schema.
|
|
207
237
|
*
|
|
238
|
+
* @since 0.0.1
|
|
208
239
|
* @example
|
|
209
240
|
* type Schema = Jsonish<{ sus: string; am: string; }>; // OK
|
|
210
241
|
* type AlterSchema = Jsonish<{ sus: string; am: () => {}; }>; // Causes error
|
|
@@ -214,6 +245,7 @@ type Jsonish<T extends Jsonifiable> = T extends Jsonifiable ? T : never;
|
|
|
214
245
|
/**
|
|
215
246
|
* Modifies K (Key) in T (Type), replace it with R (Replacement).
|
|
216
247
|
*
|
|
248
|
+
* @since 0.0.1
|
|
217
249
|
* @example
|
|
218
250
|
* type ExcludedStore = Modify<IStore, 'appSettings', { appName: 'Simple name' }>; // Key in IStore has been replaced with new type.
|
|
219
251
|
*/
|
|
@@ -221,12 +253,16 @@ type Modify<T, K extends keyof T, R> = Omit<T, K> & {
|
|
|
221
253
|
[Key in K]: R;
|
|
222
254
|
};
|
|
223
255
|
|
|
224
|
-
/**
|
|
256
|
+
/**
|
|
257
|
+
* Make union type of T and null.
|
|
258
|
+
* @since 0.0.1
|
|
259
|
+
*/
|
|
225
260
|
type Nullable<T> = T | null;
|
|
226
261
|
|
|
227
262
|
/**
|
|
228
263
|
* Get typeof key of Record.
|
|
229
264
|
*
|
|
265
|
+
* @since 0.0.1
|
|
230
266
|
* @example
|
|
231
267
|
* type Key = RecordKey<Record<string, number>>; // string
|
|
232
268
|
*/
|
|
@@ -235,6 +271,7 @@ type RecordKey<R extends Record<any, any>> = R extends Record<infer K, any> ? K
|
|
|
235
271
|
/**
|
|
236
272
|
* Get typeof value of Record.
|
|
237
273
|
*
|
|
274
|
+
* @since 0.0.1
|
|
238
275
|
* @example
|
|
239
276
|
* type Value = RecordValue<Record<string, number>>; // number
|
|
240
277
|
*/
|
|
@@ -243,6 +280,7 @@ type RecordValue<R extends Record<any, any>> = R extends Record<any, infer V> ?
|
|
|
243
280
|
/**
|
|
244
281
|
* This type replace return type of function with other type.
|
|
245
282
|
*
|
|
283
|
+
* @since 0.0.1
|
|
246
284
|
* @example
|
|
247
285
|
* type StringFC<T = {}> = ReplaceReturnType<FC<T>, string>;
|
|
248
286
|
*/
|
|
@@ -251,6 +289,7 @@ type ReplaceReturnType<TFn, TR> = TFn extends (...a: infer A) => any ? (...a: A)
|
|
|
251
289
|
/**
|
|
252
290
|
* Works as Partial, but makes only specified keys partial.
|
|
253
291
|
*
|
|
292
|
+
* @since 0.0.1
|
|
254
293
|
* @example
|
|
255
294
|
* type Super = SelectivePartial<{
|
|
256
295
|
* name: string;
|
|
@@ -266,6 +305,7 @@ type SelectivePartial<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
|
266
305
|
|
|
267
306
|
/**
|
|
268
307
|
* Makes type union of type T and undefined
|
|
308
|
+
* @since 0.0.1
|
|
269
309
|
*/
|
|
270
310
|
type Undefinable<T> = T | undefined;
|
|
271
311
|
|
|
@@ -273,6 +313,7 @@ type Undefinable<T> = T | undefined;
|
|
|
273
313
|
* The strict version of Omit. Allows to remove only
|
|
274
314
|
* keys that are presented in T type.
|
|
275
315
|
*
|
|
316
|
+
* @since 0.0.1
|
|
276
317
|
* @example
|
|
277
318
|
* type Tree = {
|
|
278
319
|
* height: number;
|
|
@@ -290,6 +331,7 @@ type StrictOmit<T, K extends keyof T> = Omit<T, K>;
|
|
|
290
331
|
|
|
291
332
|
/**
|
|
292
333
|
* Extracts first type from two generics. Is helper type for {@link OneOf} type.
|
|
334
|
+
* @since 0.0.1
|
|
293
335
|
*/
|
|
294
336
|
type OnlyFirst<F, S> = F & {
|
|
295
337
|
[Key in keyof Omit<S, keyof F>]?: never;
|
|
@@ -297,6 +339,7 @@ type OnlyFirst<F, S> = F & {
|
|
|
297
339
|
/**
|
|
298
340
|
* Chooses only one of types array.
|
|
299
341
|
*
|
|
342
|
+
* @since 0.0.1
|
|
300
343
|
* @example
|
|
301
344
|
* type Email = {
|
|
302
345
|
* person: string;
|
|
@@ -324,12 +367,14 @@ type OneOf<TypesArray extends any[], Res = never, AllProperties = MergeTypes<Typ
|
|
|
324
367
|
|
|
325
368
|
/**
|
|
326
369
|
* Merge array of types to one type.
|
|
370
|
+
* @since 0.0.1
|
|
327
371
|
*/
|
|
328
372
|
type MergeTypes<TypesArray extends any[], Res = EmptyObject> = TypesArray extends [infer Head, ...infer Rem] ? MergeTypes<Rem, Res & Head> : Res;
|
|
329
373
|
|
|
330
374
|
/**
|
|
331
375
|
* Allows to pass undefined as Omit`s generic. Weakly omits type.
|
|
332
376
|
*
|
|
377
|
+
* @since 0.0.1
|
|
333
378
|
* @example
|
|
334
379
|
* // Will not omit any keys
|
|
335
380
|
* type Lib = WeakOmit<{ bookCount: number; date: string }, undefined>;
|
|
@@ -342,6 +387,7 @@ type WeakOmit<Obj extends AnyObject, Keys extends keyof Obj | undefined = undefi
|
|
|
342
387
|
/**
|
|
343
388
|
* Makes types don`t merging in unions.
|
|
344
389
|
*
|
|
390
|
+
* @since 0.0.1
|
|
345
391
|
* @example
|
|
346
392
|
* type Languages = 'TypeScript' | 'JavaScript' | Lenient<string>;
|
|
347
393
|
* // ^? "TypeScript" | "JavaScript" | string
|
|
@@ -351,6 +397,7 @@ type Lenient<T> = T & {};
|
|
|
351
397
|
* This type allows any string, but also saves compiler`s autocomplete
|
|
352
398
|
* feature.
|
|
353
399
|
*
|
|
400
|
+
* @since 0.0.1
|
|
354
401
|
* @example
|
|
355
402
|
* type Languages = 'TypeScript' | 'JavaScript';
|
|
356
403
|
*
|
|
@@ -365,6 +412,8 @@ type LenientAutocomplete<T extends string> = T | Lenient<string>;
|
|
|
365
412
|
* Creates pipelines of functions that will be executed only
|
|
366
413
|
* when you will call whole pipeline.
|
|
367
414
|
*
|
|
415
|
+
* @since 0.0.1
|
|
416
|
+
*
|
|
368
417
|
* @param fn
|
|
369
418
|
*
|
|
370
419
|
* @example
|
|
@@ -414,9 +463,15 @@ declare function pipe<A, B>(fn: (a: A) => B): {
|
|
|
414
463
|
};
|
|
415
464
|
};
|
|
416
465
|
|
|
417
|
-
/**
|
|
466
|
+
/**
|
|
467
|
+
* Capitalizes string (makes first letter uppercase).
|
|
468
|
+
* @since 0.0.1
|
|
469
|
+
*/
|
|
418
470
|
declare function capitalize<T extends string>(str: T): Capitalize<T>;
|
|
419
|
-
/**
|
|
471
|
+
/**
|
|
472
|
+
* Un-capitalizes string (makes first letter lowercase).
|
|
473
|
+
* @since 0.0.1
|
|
474
|
+
*/
|
|
420
475
|
declare function uncapitalize<T extends string>(str: T): Uncapitalize<T>;
|
|
421
476
|
|
|
422
477
|
type Preid = 'alpha' | 'beta' | 'rc';
|
|
@@ -431,6 +486,8 @@ interface VersionData {
|
|
|
431
486
|
/**
|
|
432
487
|
* Parses version with preid.
|
|
433
488
|
*
|
|
489
|
+
* @since 0.0.1
|
|
490
|
+
*
|
|
434
491
|
* @param raw
|
|
435
492
|
*
|
|
436
493
|
* @example
|
package/dist/next.d.mts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds react-scan to your Next.js application.
|
|
5
|
+
* @constructor
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { ReactScan } from 'xenopomp-essentials/next';
|
|
10
|
+
*
|
|
11
|
+
* export default function RootLayout({
|
|
12
|
+
* children,
|
|
13
|
+
* }: {
|
|
14
|
+
* children: React.ReactNode
|
|
15
|
+
* }) {
|
|
16
|
+
* return (
|
|
17
|
+
* <html lang="en">
|
|
18
|
+
* <head>
|
|
19
|
+
* <ReactScan />
|
|
20
|
+
* </head>
|
|
21
|
+
* <body>{children}</body>
|
|
22
|
+
* </html>
|
|
23
|
+
* )
|
|
24
|
+
*}
|
|
25
|
+
*/
|
|
26
|
+
declare const ReactScan: FC<unknown>;
|
|
27
|
+
|
|
28
|
+
export { ReactScan };
|
package/dist/next.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Adds react-scan to your Next.js application.
|
|
5
|
+
* @constructor
|
|
6
|
+
* @since 0.0.1
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* import { ReactScan } from 'xenopomp-essentials/next';
|
|
10
|
+
*
|
|
11
|
+
* export default function RootLayout({
|
|
12
|
+
* children,
|
|
13
|
+
* }: {
|
|
14
|
+
* children: React.ReactNode
|
|
15
|
+
* }) {
|
|
16
|
+
* return (
|
|
17
|
+
* <html lang="en">
|
|
18
|
+
* <head>
|
|
19
|
+
* <ReactScan />
|
|
20
|
+
* </head>
|
|
21
|
+
* <body>{children}</body>
|
|
22
|
+
* </html>
|
|
23
|
+
* )
|
|
24
|
+
*}
|
|
25
|
+
*/
|
|
26
|
+
declare const ReactScan: FC<unknown>;
|
|
27
|
+
|
|
28
|
+
export { ReactScan };
|
package/dist/next.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import t from"react";const c=()=>t.createElement("script",{src:"https://unpkg.com/react-scan/dist/auto.global.js",async:!0});export{c as ReactScan};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "xenopomp-essentials",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.5",
|
|
4
4
|
"author": "XenoPOMP <101574433+XenoPOMP@users.noreply.github.com>",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
@@ -43,8 +43,10 @@
|
|
|
43
43
|
"typescript": "^5.7.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
+
"@testing-library/dom": "^10.4.0",
|
|
46
47
|
"@testing-library/react": "^16.2.0",
|
|
47
48
|
"@trivago/prettier-plugin-sort-imports": "^5.2.1",
|
|
49
|
+
"@vitejs/plugin-react": "^4.3.4",
|
|
48
50
|
"@vitest/coverage-istanbul": "^3.0.4",
|
|
49
51
|
"eslint": "^9.19.0",
|
|
50
52
|
"eslint-config-xeno": "^2.0.3-rc.3",
|
|
@@ -56,6 +58,7 @@
|
|
|
56
58
|
"npm-run-all": "^4.1.5",
|
|
57
59
|
"pinst": "^3.0.0",
|
|
58
60
|
"prettier": "^3.4.2",
|
|
61
|
+
"react-dom": "^19.0.0",
|
|
59
62
|
"tsd": "^0.31.2",
|
|
60
63
|
"unbuild": "^3.3.1",
|
|
61
64
|
"vite": "^6.0.11",
|
package/dist/next/index.d.mts
DELETED
package/dist/next/index.d.ts
DELETED
package/dist/next/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|