@solid-primitives/utils 7.0.0-next.1 → 7.0.0-next.3
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 +241 -223
- package/dist/index.js +302 -315
- package/dist/types.d.ts +63 -75
- package/dist/types.js +1 -1
- package/package.json +11 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,271 +1,289 @@
|
|
|
1
|
-
|
|
1
|
+
/* @ts-self-types="./index.d.ts" */
|
|
2
|
+
import { 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 } from "./types.js";
|
|
3
|
+
import { Accessor, ComputeFunction, NoInfer as NoInfer$1, Setter, Signal, SignalOptions, Store, StoreSetter, createSignal, onCleanup } from "solid-js";
|
|
4
|
+
|
|
5
|
+
//#region src/index.d.ts
|
|
2
6
|
declare const isServer: boolean;
|
|
3
|
-
import type { AccessorArray, AnyClass, MaybeAccessor, MaybeAccessorValue, Noop, AnyObject, AnyFunction } from "./types.js";
|
|
4
|
-
export * from "./types.js";
|
|
5
|
-
/** `true` on the server (SSR), `false` in the browser. */
|
|
6
|
-
export { isServer };
|
|
7
7
|
/** `true` in the browser, `false` on the server. */
|
|
8
|
-
|
|
8
|
+
declare const isClient: boolean;
|
|
9
9
|
/** `true` in the browser with Solid's DEV mode active. */
|
|
10
|
-
|
|
10
|
+
declare const isDev: boolean;
|
|
11
11
|
/** `true` when DEV mode is off (i.e. production browser builds and all SSR). */
|
|
12
|
-
|
|
12
|
+
declare const isProd: boolean;
|
|
13
13
|
/** No-operation function — accepts any arguments and returns `undefined`. */
|
|
14
|
-
|
|
14
|
+
declare const noop: Noop;
|
|
15
15
|
/** A function that always returns `true`. Useful as a default predicate prop. */
|
|
16
|
-
|
|
16
|
+
declare const trueFn: () => boolean;
|
|
17
17
|
/** A function that always returns `false`. Useful as a default predicate prop. */
|
|
18
|
-
|
|
18
|
+
declare const falseFn: () => boolean;
|
|
19
19
|
/** @deprecated use {@link equalFn} from "solid-js" */
|
|
20
|
-
|
|
20
|
+
declare const defaultEquals: typeof Object.is;
|
|
21
21
|
/**
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
* Signal options that disable equality checking, causing the signal to always
|
|
23
|
+
* notify subscribers even when the value hasn't changed. Useful for signals
|
|
24
|
+
* holding mutable objects where structural equality cannot be assumed.
|
|
25
|
+
*/
|
|
26
|
+
declare const EQUALS_FALSE_OPTIONS: {
|
|
27
|
+
readonly equals: false;
|
|
28
28
|
};
|
|
29
29
|
/**
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
* Signal options that allow writes from inside an owned reactive scope
|
|
31
|
+
* (component body, memo, or effect) without throwing `SIGNAL_WRITE_IN_OWNED_SCOPE`
|
|
32
|
+
* in Solid 2.0 dev mode.
|
|
33
|
+
*
|
|
34
|
+
* Use only for implementation-detail signals that genuinely need to be written
|
|
35
|
+
* from within a scope — not as a general escape hatch.
|
|
36
|
+
*/
|
|
37
|
+
declare const INTERNAL_OPTIONS: {
|
|
38
|
+
readonly ownedWrite: true;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
* Returns `true` if `v` is an instance of `c`. Checks both `instanceof` and
|
|
42
|
+
* `constructor` so that values created across different realms (e.g. iframes) match.
|
|
43
|
+
*/
|
|
44
|
+
declare const ofClass: (v: any, c: AnyClass) => boolean;
|
|
45
45
|
/** Check if value is typeof "object" or "function" */
|
|
46
|
-
|
|
46
|
+
declare function isObject(value: any): value is AnyObject;
|
|
47
47
|
/** Type guard: returns `true` when `i` is neither `null` nor `undefined`. */
|
|
48
|
-
|
|
48
|
+
declare const isNonNullable: <T>(i: T) => i is NonNullable<T>;
|
|
49
49
|
/** Returns a new array with all `null` and `undefined` items removed. */
|
|
50
|
-
|
|
50
|
+
declare const filterNonNullable: <T extends readonly unknown[]>(arr: T) => NonNullable<T[number]>[];
|
|
51
51
|
/** Three-way comparison: returns `-1` if `a < b`, `1` if `a > b`, `0` if equal. */
|
|
52
|
-
|
|
52
|
+
declare const compare: (a: any, b: any) => number;
|
|
53
53
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
* Check shallow array equality
|
|
55
|
+
*/
|
|
56
|
+
declare const arrayEquals: (a: readonly unknown[], b: readonly unknown[]) => boolean;
|
|
57
57
|
/**
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
* Returns a function that will call all functions in the order they were chained with the same arguments.
|
|
59
|
+
*/
|
|
60
|
+
declare function chain<Args extends [] | any[]>(callbacks: {
|
|
61
|
+
[Symbol.iterator](): IterableIterator<((...args: Args) => any) | undefined>;
|
|
62
62
|
}): (...args: Args) => void;
|
|
63
63
|
/**
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
* Returns a function that will call all functions in the reversed order with the same arguments.
|
|
65
|
+
*/
|
|
66
|
+
declare function reverseChain<Args extends [] | any[]>(callbacks: (((...args: Args) => any) | undefined)[]): (...args: Args) => void;
|
|
67
67
|
/** Clamps `n` to the inclusive range `[min, max]`. */
|
|
68
|
-
|
|
68
|
+
declare const clamp: (n: number, min: number, max: number) => number;
|
|
69
69
|
/** Creates an ID generator with its own isolated counter and per-generator random segment. Each call to the returned function produces a `timestamp-sequence-random` string that is unique within the generator and with high probability unique across independent generators (e.g. separate processes or SSR requests). */
|
|
70
|
-
|
|
70
|
+
declare const createIdGenerator: () => (() => string);
|
|
71
71
|
/**
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
72
|
+
* Accesses the value of a MaybeAccessor
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* access("foo") // => "foo"
|
|
76
|
+
* access(() => "foo") // => "foo"
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
declare const access: <T extends MaybeAccessor<any>>(v: T) => MaybeAccessorValue<T>;
|
|
80
80
|
/**
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
81
|
+
* Wraps `value` in a single-element array. If `value` is already an array it is
|
|
82
|
+
* returned as-is. Falsy values (except `0` and `false`) produce an empty array.
|
|
83
|
+
*/
|
|
84
|
+
declare const asArray: <T>(value: T) => (T extends any[] ? T[number] : NonNullable<T>)[];
|
|
85
85
|
/**
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
86
|
+
* Access an array of MaybeAccessors
|
|
87
|
+
* @example
|
|
88
|
+
* const list = [1, 2, () => 3)] // T: MaybeAccessor<number>[]
|
|
89
|
+
* const newList = accessArray(list) // T: number[]
|
|
90
|
+
*/
|
|
91
|
+
declare const accessArray: <A extends MaybeAccessor<any>>(list: readonly A[]) => MaybeAccessorValue<A>[];
|
|
92
92
|
/**
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
* Run the function if the accessed value is not `undefined` nor `null`
|
|
94
|
+
* @param value
|
|
95
|
+
* @param fn
|
|
96
|
+
*/
|
|
97
|
+
declare const withAccess: <T, A extends MaybeAccessor<T>, V = MaybeAccessorValue<A>>(value: A, fn: (value: NonNullable<V>) => void) => void;
|
|
98
98
|
/**
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
99
|
+
* Wraps a plain value in a zero-argument accessor `() => value`.
|
|
100
|
+
* If `v` is already a function it is returned unchanged.
|
|
101
|
+
*/
|
|
102
|
+
declare const asAccessor: <A extends MaybeAccessor<unknown>>(v: A) => Accessor<MaybeAccessorValue<A>>;
|
|
103
103
|
/** If value is a function – call it with a given arguments – otherwise get the value as is */
|
|
104
|
-
|
|
104
|
+
declare function accessWith<T>(valueOrFn: T, ...args: T extends AnyFunction ? Parameters<T> : never): T extends AnyFunction ? ReturnType<T> : T;
|
|
105
105
|
/**
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
* A deferred effect compute function. Skips the first reactive run and returns
|
|
107
|
+
* `initialValue` instead, then calls `fn` on subsequent dependency changes.
|
|
108
|
+
* Useful as the compute phase of `createEffect(defer(...), apply)` when the
|
|
109
|
+
* initial run should be suppressed.
|
|
110
|
+
*
|
|
111
|
+
* @param deps - a single accessor or an array of accessors to track
|
|
112
|
+
* @param fn - called with the current input, previous input, and previous return value
|
|
113
|
+
* @param initialValue - returned on the skipped first run (defaults to `undefined`)
|
|
114
|
+
*/
|
|
115
|
+
declare function defer<S, Next extends Prev, Prev = Next>(deps: AccessorArray<S> | Accessor<S>, fn: (input: S, prevInput: S, prev: undefined | NoInfer$1<Prev>) => Next, initialValue: Next): ComputeFunction<undefined | NoInfer$1<Next>, NoInfer$1<Next>>;
|
|
116
|
+
declare function defer<S, Next extends Prev, Prev = Next>(deps: AccessorArray<S> | Accessor<S>, fn: (input: S, prevInput: S, prev: undefined | NoInfer$1<Prev>) => Next, initialValue?: undefined): ComputeFunction<undefined | NoInfer$1<Next>>;
|
|
117
117
|
/**
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
118
|
+
* Get entries of an object
|
|
119
|
+
*/
|
|
120
|
+
declare const entries: <T extends object>(obj: T) => [keyof T, T[keyof T]][];
|
|
121
121
|
/**
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
122
|
+
* Get keys of an object
|
|
123
|
+
*/
|
|
124
|
+
declare const keys: <T extends object>(object: T) => (keyof T)[];
|
|
125
125
|
/**
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
126
|
+
* Solid's `onCleanup` that doesn't warn in development if used outside of a component.
|
|
127
|
+
*/
|
|
128
|
+
declare const tryOnCleanup: typeof onCleanup;
|
|
129
129
|
/**
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
130
|
+
* Creates a stack of callbacks that can be pushed to, executed all at once, or cleared.
|
|
131
|
+
* All callbacks receive the same arguments when `execute` is called; the stack is
|
|
132
|
+
* automatically cleared after execution.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```ts
|
|
136
|
+
* const stack = createCallbackStack<string>();
|
|
137
|
+
* stack.push(s => console.log("a:", s));
|
|
138
|
+
* stack.push(s => console.log("b:", s));
|
|
139
|
+
* stack.execute("hello"); // logs "a: hello", "b: hello" — stack is now empty
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
declare const createCallbackStack: <A0 = void, A1 = void, A2 = void, A3 = void>() => {
|
|
143
|
+
push: (...callbacks: ((arg0: A0, arg1: A1, arg2: A2, arg3: A3) => void)[]) => void;
|
|
144
|
+
execute: (arg0: A0, arg1: A1, arg2: A2, arg3: A3) => void;
|
|
145
|
+
clear: VoidFunction;
|
|
146
146
|
};
|
|
147
147
|
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
148
|
+
* Returns a debounced wrapper around `fn` that batches rapid synchronous calls
|
|
149
|
+
* into a single invocation. Only the most-recently-passed arguments are forwarded.
|
|
150
|
+
* The counter resets on cleanup so stale microtasks are silently discarded.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```ts
|
|
154
|
+
* const flush = createMicrotask((value: string) => console.log(value));
|
|
155
|
+
* flush("a");
|
|
156
|
+
* flush("b");
|
|
157
|
+
* flush("c"); // only "c" is logged (in the next microtask)
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
declare function createMicrotask<A extends any[] | []>(fn: (...a: A) => void): (...a: A) => void;
|
|
161
161
|
/**
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
162
|
+
* A hydratable version of the {@link createSignal}. It will use the serverValue on the server and the update function on the client. If initialized during hydration it will use serverValue as the initial value and update it once hydration is complete.
|
|
163
|
+
*
|
|
164
|
+
* @param serverValue initial value of the state on the server
|
|
165
|
+
* @param update called once on the client or on hydration to initialize the value
|
|
166
|
+
* @param options {@link SignalOptions}
|
|
167
|
+
* @returns
|
|
168
|
+
* ```ts
|
|
169
|
+
* [state: Accessor<T>, setState: Setter<T>]
|
|
170
|
+
* ```
|
|
171
|
+
* @see {@link createSignal}
|
|
172
|
+
*/
|
|
173
|
+
declare function createHydratableSignal<T>(serverValue: T, update: () => T, options?: SignalOptions<T>): ReturnType<typeof createSignal<T>>;
|
|
174
174
|
/** @deprecated use {@link createHydratableSignal} instead */
|
|
175
|
-
|
|
175
|
+
declare const createHydrateSignal: typeof createHydratableSignal;
|
|
176
176
|
/**
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
177
|
+
* Diffs two arrays by reference and calls `handleAdded` / `handleRemoved` for
|
|
178
|
+
* each item that appeared or disappeared. Items are compared with `===`.
|
|
179
|
+
*
|
|
180
|
+
* @param current - the new array
|
|
181
|
+
* @param prev - the previous array snapshot
|
|
182
|
+
* @param handleAdded - called once for each item present in `current` but not `prev`
|
|
183
|
+
* @param handleRemoved - called once for each item present in `prev` but not `current`
|
|
184
|
+
*/
|
|
185
|
+
declare function handleDiffArray<T>(current: readonly T[], prev: readonly T[], handleAdded: (item: T) => void, handleRemoved: (item: T) => void): void;
|
|
186
186
|
/**
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
187
|
+
* Schedules `fn` to run after the browser has painted by nesting two
|
|
188
|
+
* requestAnimationFrame calls. No-op in non-browser environments.
|
|
189
|
+
*/
|
|
190
|
+
declare const afterPaint: (fn: () => void) => void;
|
|
191
191
|
/**
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
192
|
+
* Parse a string as a single JSON value.
|
|
193
|
+
*
|
|
194
|
+
* ```ts
|
|
195
|
+
* const { data } = createSSE<{ status: string }>(url, { transform: json });
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
declare const json: <T>(raw: string) => T;
|
|
199
199
|
/**
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
200
|
+
* Parse a string as newline-delimited JSON (NDJSON / JSON Lines).
|
|
201
|
+
*
|
|
202
|
+
* Each non-empty line is parsed as a separate JSON value and returned as an array.
|
|
203
|
+
*
|
|
204
|
+
* ```ts
|
|
205
|
+
* const { data } = createSSE<TickEvent[]>(url, { transform: ndjson });
|
|
206
|
+
* // data() === [{ id: 1, type: "tick" }, { id: 2, type: "tick" }]
|
|
207
|
+
* ```
|
|
208
|
+
*/
|
|
209
|
+
declare const ndjson: <T>(raw: string) => T[];
|
|
210
210
|
/**
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
211
|
+
* Split a string into individual lines, returning a `string[]`. Empty lines are filtered out.
|
|
212
|
+
*
|
|
213
|
+
* ```ts
|
|
214
|
+
* const { data } = createSSE<string[]>(url, { transform: lines });
|
|
215
|
+
* // data() === ["line one", "line two"]
|
|
216
|
+
* ```
|
|
217
|
+
*/
|
|
218
|
+
declare const lines: (raw: string) => string[];
|
|
219
219
|
/**
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
220
|
+
* Parse a string as a number using `Number()` semantics.
|
|
221
|
+
*
|
|
222
|
+
* Note: `""` → `0`, non-numeric strings → `NaN`.
|
|
223
|
+
*
|
|
224
|
+
* ```ts
|
|
225
|
+
* const { data } = createSSE<number>(url, { transform: number });
|
|
226
|
+
* // data() === 42
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
declare const number: (raw: string) => number;
|
|
230
230
|
/**
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
231
|
+
* Wrap any `(string) => T` transform in a `try/catch`. Returns `fallback`
|
|
232
|
+
* (default `undefined`) instead of throwing on malformed input.
|
|
233
|
+
*
|
|
234
|
+
* ```ts
|
|
235
|
+
* const { data } = createSSE<MyEvent>(url, { transform: safe(json) });
|
|
236
|
+
* const { data } = createSSE<number>(url, { transform: safe(number, 0) });
|
|
237
|
+
* ```
|
|
238
|
+
*/
|
|
239
|
+
declare function safe<T>(transform: (raw: string) => T): (raw: string) => T | undefined;
|
|
240
|
+
declare function safe<T>(transform: (raw: string) => T, fallback: T): (raw: string) => T;
|
|
241
241
|
/**
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
242
|
+
* Compose two transforms into one: the output of `a` is passed as the input of `b`.
|
|
243
|
+
*
|
|
244
|
+
* ```ts
|
|
245
|
+
* const { data } = createSSE<RawEvent[]>(url, {
|
|
246
|
+
* transform: pipe(ndjson<RawEvent>, rows => rows.filter(r => r.type === "tick")),
|
|
247
|
+
* });
|
|
248
|
+
* ```
|
|
249
|
+
*/
|
|
250
|
+
declare function pipe<A, B>(a: (raw: string) => A, b: (a: A) => B): (raw: string) => B;
|
|
251
251
|
/**
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
252
|
+
* Check if a wrapper element contains a target element.
|
|
253
|
+
* Portal-aware: follows SolidJS `_$host` links so elements rendered inside
|
|
254
|
+
* a `<Portal>` are correctly treated as children of the portal's anchor.
|
|
255
|
+
*/
|
|
256
|
+
declare const contains: (wrapper: HTMLElement, target: HTMLElement) => boolean;
|
|
257
257
|
/**
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
258
|
+
* Returns a singleton value keyed by `key`, shared across every copy of the calling module that
|
|
259
|
+
* ends up loaded in the same JS realm (a `Symbol.for(key)` slot on `globalThis`, not a module-scope
|
|
260
|
+
* binding). Use this instead of a plain module-scope `let`/`const` for state that must stay
|
|
261
|
+
* consistent (ref-counts, active-instance stacks) even if the app's dependency graph ends up with
|
|
262
|
+
* more than one installed copy of the package — module-scope state would otherwise be split across
|
|
263
|
+
* copies and go out of sync (e.g. a "topmost instance" check disagreeing between copies).
|
|
264
|
+
*
|
|
265
|
+
* ```ts
|
|
266
|
+
* const registry = globalRegistry("@solid-primitives/my-package:my-state", () => ({
|
|
267
|
+
* stack: createSignal<string[]>([], { ownedWrite: true }),
|
|
268
|
+
* nextId: 0,
|
|
269
|
+
* }));
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
declare function globalRegistry<T>(key: string, init: () => T): T;
|
|
273
|
+
/**
|
|
274
|
+
* Wraps a setter function of any signal or store
|
|
275
|
+
*
|
|
276
|
+
* ```ts
|
|
277
|
+
* const [data, setData] = wrapSetter(
|
|
278
|
+
* createSignal(initialData),
|
|
279
|
+
* (setter) => (next) => { console.log(next); return setter(next); },
|
|
280
|
+
* );
|
|
281
|
+
* ```
|
|
282
|
+
* If you destructure signal or store in a longer tuple, you need to use a const assertion for the types to work.
|
|
283
|
+
*/
|
|
284
|
+
declare function wrapSetter<T>(signal: Signal<T>, wrapper: (setter: Setter<T>) => Setter<T>): Signal<T>;
|
|
285
|
+
declare function wrapSetter<T>(store: [Store<T>, StoreSetter<T>], wrapper: (setter: StoreSetter<T>) => StoreSetter<T>): [Store<T>, StoreSetter<T>];
|
|
286
|
+
declare function wrapSetter<T, S extends Signal<T> | [Store<T>, StoreSetter<T>] | [...Signal<T>, ...any[]] | [Store<T>, StoreSetter<T>, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S;
|
|
287
|
+
declare function wrapSetter<T, S extends Signal<T> | [Store<T>, StoreSetter<T>] | readonly [...Signal<T>, ...any[]] | readonly [Store<T>, StoreSetter<T>, ...any[]]>(signalOrStore: S, wrapper: (setter: S[1]) => S[1]): S;
|
|
288
|
+
//#endregion
|
|
289
|
+
export { AccessReturnTypes, AccessorArray, AnyClass, AnyFunction, AnyObject, AnyStatic, DeepPartialAny, Directive, EQUALS_FALSE_OPTIONS, ExtractIfPossible, Falsy, FalsyValue, INTERNAL_OPTIONS, ItemsOf, ItemsOfMany, Many, MaybeAccessor, MaybeAccessorValue, Modify, ModifyDeep, Narrow, NoInfer, NonIterable, Noop, OnAccessEffectFunction, Position, PrimitiveValue, RequiredKeys, SetterParam, Simplify, Size, Tail, Truthy, UnboxLazy, UnionToIntersection, Values, access, accessArray, accessWith, afterPaint, arrayEquals, asAccessor, asArray, chain, clamp, compare, contains, createCallbackStack, createHydratableSignal, createHydrateSignal, createIdGenerator, createMicrotask, defaultEquals, defer, entries, falseFn, filterNonNullable, globalRegistry, handleDiffArray, isClient, isDev, isNonNullable, isObject, isProd, isServer, json, keys, lines, ndjson, noop, number, ofClass, pipe, reverseChain, safe, trueFn, tryOnCleanup, withAccess, wrapSetter };
|