@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/types.d.ts CHANGED
@@ -1,91 +1,79 @@
1
- import type { Accessor, Setter } from "solid-js";
1
+ /* @ts-self-types="./types.d.ts" */
2
+ import { Accessor, Setter } from "solid-js";
3
+
4
+ //#region src/types.d.ts
2
5
  /**
3
- * Can be single or in an array
4
- */
5
- export type Many<T> = T | T[];
6
- export type Values<O extends Object> = O[keyof O];
7
- export type Noop = (...a: any[]) => void;
8
- export type Directive<P = true> = (el: Element, props: Accessor<P>) => void;
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
- * Infers the type of the array elements
11
- */
12
- export type ItemsOf<T> = T extends (infer E)[] ? E : never;
13
- export type ItemsOfMany<T> = T extends any[] ? ItemsOf<T> : T;
14
- export type SetterParam<T> = Parameters<Setter<T>>[0];
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
- * T or a reactive/non-reactive function returning T
17
- */
18
- export type MaybeAccessor<T> = T | Accessor<T>;
19
+ * T or a reactive/non-reactive function returning T
20
+ */
21
+ type MaybeAccessor<T> = T | Accessor<T>;
19
22
  /**
20
- * Accessed value of a MaybeAccessor
21
- * @example
22
- * ```ts
23
- * MaybeAccessorValue<MaybeAccessor<string>>
24
- * // => string
25
- * MaybeAccessorValue<MaybeAccessor<() => string>>
26
- * // => string | (() => string)
27
- * MaybeAccessorValue<MaybeAccessor<string> | Function>
28
- * // => string | void
29
- * ```
30
- */
31
- export type MaybeAccessorValue<T extends MaybeAccessor<any>> = T extends () => any ? ReturnType<T> : T;
32
- export type AccessorArray<T> = [...Extract<{
33
- [K in keyof T]: Accessor<T[K]>;
34
- }, readonly unknown[]>];
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
- export type Modify<T, R> = Omit<T, keyof R> & R;
39
+ type Modify<T, R> = Omit<T, keyof R> & R;
41
40
  /** Allows to make nested overwrites to an interface */
42
- export type ModifyDeep<A extends AnyObject, B extends DeepPartialAny<A>> = {
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
- export type DeepPartialAny<T> = {
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
- export type NonIterable<T> = T & {
51
- [Symbol.iterator]: never;
45
+ type NonIterable<T> = T & {
46
+ [Symbol.iterator]: never;
52
47
  };
53
48
  /** Get the required keys of an object */
54
- export type RequiredKeys<T> = keyof {
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
- export type Tail<T extends any[]> = ((...t: T) => void) extends (x: any, ...u: infer U) => void ? U : never;
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
- export type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
63
- export type ExtractIfPossible<T, U> = Extract<T, U> extends never ? U : Extract<T, U>;
64
- export type AnyObject = Record<PropertyKey, any>;
65
- export type AnyStatic = [] | any[] | AnyObject;
66
- export type AnyFunction = (...args: any[]) => any;
67
- export type AnyClass = abstract new (...args: any) => any;
68
- export type PrimitiveValue = PropertyKey | boolean | bigint | null | undefined;
69
- export type FalsyValue = false | 0 | "" | null | undefined;
70
- export type Truthy<T> = Exclude<T, FalsyValue>;
71
- export type Falsy<T> = Extract<T, FalsyValue>;
72
- export type Position = {
73
- x: number;
74
- y: number;
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
- export type Size = {
77
- width: number;
78
- height: number;
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
- export type Simplify<T> = T extends object ? {
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
- export type UnboxLazy<T> = T extends () => infer U ? U : T;
86
- type RawNarrow<T> = (T extends [] ? [] : never) | (T extends string | number | bigint | boolean ? T : never) | {
87
- [K in keyof T]: T[K] extends Function ? T[K] : RawNarrow<T[K]>;
88
- };
89
- export type Narrow<T> = T extends [] ? T : RawNarrow<T>;
90
- export type NoInfer<T> = [T][T extends any ? 0 : never];
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
- export {};
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.0",
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": 1399
137
+ "gzip": 1511
134
138
  },
135
139
  "peerDependencies": {
136
- "@solidjs/web": "^2.0.0-beta.15",
137
- "solid-js": "^2.0.0-beta.15"
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.15",
141
- "solid-js": "2.0.0-beta.15"
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": "node --import=@nothing-but/node-resolve-ts --experimental-transform-types ../../scripts/build.ts",
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"