@solid-primitives/utils 7.0.0-next.0 → 7.0.0-next.2
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/colors/helpers.d.ts +46 -41
- package/dist/colors/helpers.js +776 -851
- package/dist/colors/index.d.ts +6 -4
- package/dist/colors/index.js +5 -4
- package/dist/colors/intl.d.ts +56 -52
- package/dist/colors/intl.js +55 -66
- package/dist/colors/manipulation.d.ts +136 -131
- package/dist/colors/manipulation.js +215 -242
- package/dist/colors/types.d.ts +73 -68
- package/dist/colors/types.js +1 -14
- package/dist/immutable/array.d.ts +113 -108
- package/dist/immutable/array.js +122 -128
- package/dist/immutable/copy.d.ts +25 -21
- package/dist/immutable/copy.js +31 -29
- package/dist/immutable/index.d.ts +8 -6
- package/dist/immutable/index.js +7 -6
- package/dist/immutable/number.d.ts +11 -7
- package/dist/immutable/number.js +21 -27
- package/dist/immutable/object.d.ts +55 -58
- package/dist/immutable/object.js +46 -48
- package/dist/immutable/types.d.ts +9 -7
- package/dist/immutable/types.js +1 -1
- package/dist/immutable/update.d.ts +33 -28
- package/dist/immutable/update.js +27 -27
- package/dist/index.d.ts +226 -222
- package/dist/index.js +285 -311
- package/dist/types.d.ts +63 -75
- package/dist/types.js +1 -1
- package/package.json +11 -7
package/dist/types.d.ts
CHANGED
|
@@ -1,91 +1,79 @@
|
|
|
1
|
-
|
|
1
|
+
/* @ts-self-types="./types.d.ts" */
|
|
2
|
+
import { Accessor, Setter } from "solid-js";
|
|
3
|
+
|
|
4
|
+
//#region src/types.d.ts
|
|
2
5
|
/**
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
* Can be single or in an array
|
|
7
|
+
*/
|
|
8
|
+
type Many<T> = T | T[];
|
|
9
|
+
type Values<O extends Object> = O[keyof O];
|
|
10
|
+
type Noop = (...a: any[]) => void;
|
|
11
|
+
type Directive<P = true> = (el: Element, props: Accessor<P>) => void;
|
|
9
12
|
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
* Infers the type of the array elements
|
|
14
|
+
*/
|
|
15
|
+
type ItemsOf<T> = T extends (infer E)[] ? E : never;
|
|
16
|
+
type ItemsOfMany<T> = T extends any[] ? ItemsOf<T> : T;
|
|
17
|
+
type SetterParam<T> = Parameters<Setter<T>>[0];
|
|
15
18
|
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
+
* T or a reactive/non-reactive function returning T
|
|
20
|
+
*/
|
|
21
|
+
type MaybeAccessor<T> = T | Accessor<T>;
|
|
19
22
|
/**
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export type OnAccessEffectFunction<S, Prev, Next extends Prev = Prev> = (input: AccessReturnTypes<S>, prevInput: AccessReturnTypes<S>, v: Prev) => Next;
|
|
36
|
-
export type AccessReturnTypes<S> = S extends MaybeAccessor<any>[] ? {
|
|
37
|
-
[I in keyof S]: AccessReturnTypes<S[I]>;
|
|
38
|
-
} : MaybeAccessorValue<S>;
|
|
23
|
+
* Accessed value of a MaybeAccessor
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* MaybeAccessorValue<MaybeAccessor<string>>
|
|
27
|
+
* // => string
|
|
28
|
+
* MaybeAccessorValue<MaybeAccessor<() => string>>
|
|
29
|
+
* // => string | (() => string)
|
|
30
|
+
* MaybeAccessorValue<MaybeAccessor<string> | Function>
|
|
31
|
+
* // => string | void
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends (() => any) ? ReturnType<T> : T;
|
|
35
|
+
type AccessorArray<T> = [...Extract<{ [K in keyof T]: Accessor<T[K]> }, readonly unknown[]>];
|
|
36
|
+
type OnAccessEffectFunction<S, Prev, Next extends Prev = Prev> = (input: AccessReturnTypes<S>, prevInput: AccessReturnTypes<S>, v: Prev) => Next;
|
|
37
|
+
type AccessReturnTypes<S> = S extends MaybeAccessor<any>[] ? { [I in keyof S]: AccessReturnTypes<S[I]> } : MaybeAccessorValue<S>;
|
|
39
38
|
/** Allows to make shallow overwrites to an interface */
|
|
40
|
-
|
|
39
|
+
type Modify<T, R> = Omit<T, keyof R> & R;
|
|
41
40
|
/** Allows to make nested overwrites to an interface */
|
|
42
|
-
|
|
43
|
-
[K in keyof A]: B[K] extends never ? A[K] : B[K] extends AnyObject ? ModifyDeep<A[K], B[K]> : B[K];
|
|
44
|
-
} & (A extends AnyObject ? Omit<B, keyof A> : A);
|
|
41
|
+
type ModifyDeep<A extends AnyObject, B extends DeepPartialAny<A>> = { [K in keyof A]: B[K] extends never ? A[K] : B[K] extends AnyObject ? ModifyDeep<A[K], B[K]> : B[K] } & (A extends AnyObject ? Omit<B, keyof A> : A);
|
|
45
42
|
/** Makes each property optional and turns each leaf property into any, allowing for type overrides by narrowing any. */
|
|
46
|
-
|
|
47
|
-
[P in keyof T]?: T[P] extends AnyObject ? DeepPartialAny<T[P]> : any;
|
|
48
|
-
};
|
|
43
|
+
type DeepPartialAny<T> = { [P in keyof T]?: T[P] extends AnyObject ? DeepPartialAny<T[P]> : any };
|
|
49
44
|
/** Removes the `[...list]` functionality */
|
|
50
|
-
|
|
51
|
-
|
|
45
|
+
type NonIterable<T> = T & {
|
|
46
|
+
[Symbol.iterator]: never;
|
|
52
47
|
};
|
|
53
48
|
/** Get the required keys of an object */
|
|
54
|
-
|
|
55
|
-
[K in keyof T as T extends {
|
|
56
|
-
[_ in K]: unknown;
|
|
57
|
-
} ? K : never]: 0;
|
|
58
|
-
};
|
|
49
|
+
type RequiredKeys<T> = keyof { [K in keyof T as T extends { [_ in K]: unknown } ? K : never]: 0 };
|
|
59
50
|
/** Remove the first item of a tuple [1, 2, 3, 4] => [2, 3, 4] */
|
|
60
|
-
|
|
51
|
+
type Tail<T extends any[]> = ((...t: T) => void) extends ((x: any, ...u: infer U) => void) ? U : never;
|
|
61
52
|
/** `A | B => A & B` */
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
53
|
+
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
54
|
+
type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>;
|
|
55
|
+
type AnyObject = Record<PropertyKey, any>;
|
|
56
|
+
type AnyStatic = [] | any[] | AnyObject;
|
|
57
|
+
type AnyFunction = (...args: any[]) => any;
|
|
58
|
+
type AnyClass = abstract new (...args: any) => any;
|
|
59
|
+
type PrimitiveValue = PropertyKey | boolean | bigint | null | undefined;
|
|
60
|
+
type FalsyValue = false | 0 | "" | null | undefined;
|
|
61
|
+
type Truthy<T> = Exclude<T, FalsyValue>;
|
|
62
|
+
type Falsy<T> = Extract<T, FalsyValue>;
|
|
63
|
+
type Position = {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
75
66
|
};
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
67
|
+
type Size = {
|
|
68
|
+
width: number;
|
|
69
|
+
height: number;
|
|
79
70
|
};
|
|
80
71
|
/** Unwraps the type definition of an object, making it more readable */
|
|
81
|
-
|
|
82
|
-
[K in keyof T]: T[K];
|
|
83
|
-
} : T;
|
|
72
|
+
type Simplify<T> = T extends object ? { [K in keyof T]: T[K] } : T;
|
|
84
73
|
/** Unboxes type definition, making it more readable */
|
|
85
|
-
|
|
86
|
-
type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
export
|
|
91
|
-
export {};
|
|
74
|
+
type UnboxLazy<T> = T extends (() => infer U) ? U : T;
|
|
75
|
+
type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | { [K in keyof T]: T[K] extends Function ? T[K] : RawNarrow<T[K]> };
|
|
76
|
+
type Narrow<T> = T extends [] ? T : RawNarrow<T>;
|
|
77
|
+
type NoInfer<T> = [T][T extends any ? 0 : never];
|
|
78
|
+
//#endregion
|
|
79
|
+
export { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, ExtractIfPossible, Falsy, FalsyValue, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values };
|
package/dist/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
/* @ts-self-types="./types.d.ts" */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solid-primitives/utils",
|
|
3
|
-
"version": "7.0.0-next.
|
|
3
|
+
"version": "7.0.0-next.2",
|
|
4
4
|
"description": "A bunch of reactive utility types and functions, for building primitives with Solid.js",
|
|
5
5
|
"author": "Damian Tarnawski @thetarnav <gthetarnav@gmail.com>",
|
|
6
6
|
"contributors": [
|
|
@@ -57,6 +57,10 @@
|
|
|
57
57
|
]
|
|
58
58
|
}
|
|
59
59
|
},
|
|
60
|
+
"tsdown": {
|
|
61
|
+
"entry": "src/**/*.{ts,tsx}",
|
|
62
|
+
"outDir": "dist"
|
|
63
|
+
},
|
|
60
64
|
"keywords": [
|
|
61
65
|
"utilities",
|
|
62
66
|
"reactivity",
|
|
@@ -130,19 +134,19 @@
|
|
|
130
134
|
"COLOR_INTL_TRANSLATIONS"
|
|
131
135
|
],
|
|
132
136
|
"category": "Utilities",
|
|
133
|
-
"gzip":
|
|
137
|
+
"gzip": 1511
|
|
134
138
|
},
|
|
135
139
|
"peerDependencies": {
|
|
136
|
-
"@solidjs/web": "^2.0.0-beta.
|
|
137
|
-
"solid-js": "^2.0.0-beta.
|
|
140
|
+
"@solidjs/web": "^2.0.0-beta.20",
|
|
141
|
+
"solid-js": "^2.0.0-beta.20"
|
|
138
142
|
},
|
|
139
143
|
"devDependencies": {
|
|
140
|
-
"@solidjs/web": "2.0.0-beta.
|
|
141
|
-
"solid-js": "2.0.0-beta.
|
|
144
|
+
"@solidjs/web": "2.0.0-beta.20",
|
|
145
|
+
"solid-js": "2.0.0-beta.20"
|
|
142
146
|
},
|
|
143
147
|
"scripts": {
|
|
144
148
|
"dev": "node --import=@nothing-but/node-resolve-ts --experimental-transform-types ../../scripts/dev.ts",
|
|
145
|
-
"build": "
|
|
149
|
+
"build": "pnpm -w build",
|
|
146
150
|
"vitest": "vitest -c ../../configs/vitest.config.ts",
|
|
147
151
|
"test": "pnpm run vitest",
|
|
148
152
|
"test:ssr": "pnpm run vitest --mode ssr"
|