@solid-primitives/utils 7.0.0-next.4 → 7.0.0-next.8

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