solid-js 1.2.3 → 1.3.0-beta.1
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/dev.cjs +69 -35
- package/dist/dev.js +70 -35
- package/dist/server.cjs +20 -51
- package/dist/server.js +21 -51
- package/dist/solid.cjs +69 -35
- package/dist/solid.js +70 -35
- package/html/dist/html.cjs +3 -2
- package/html/dist/html.js +3 -2
- package/package.json +2 -2
- package/store/dist/dev.cjs +1 -1
- package/store/dist/dev.js +2 -2
- package/store/dist/store.cjs +1 -1
- package/store/dist/store.js +1 -1
- package/store/types/store.d.ts +1 -1
- package/types/index.d.ts +0 -1
- package/types/jsx.d.ts +2 -0
- package/types/reactive/signal.d.ts +76 -78
- package/types/render/hydration.d.ts +3 -2
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +1 -2
- package/types/server/rendering.d.ts +2 -1
- package/web/dist/dev.cjs +57 -40
- package/web/dist/dev.js +58 -40
- package/web/dist/server.cjs +205 -101
- package/web/dist/server.js +206 -103
- package/web/dist/web.cjs +57 -40
- package/web/dist/web.js +58 -40
- package/web/types/client.d.ts +0 -1
- package/web/types/core.d.ts +2 -2
package/types/index.d.ts
CHANGED
|
@@ -7,7 +7,6 @@ export * from "./render";
|
|
|
7
7
|
import type { JSX } from "./jsx";
|
|
8
8
|
declare type JSXElement = JSX.Element;
|
|
9
9
|
export type { JSXElement, JSX };
|
|
10
|
-
export declare function awaitSuspense(): void;
|
|
11
10
|
import { writeSignal, serializeGraph, registerGraph, hashValue } from "./reactive/signal";
|
|
12
11
|
declare let DEV: {
|
|
13
12
|
writeSignal: typeof writeSignal;
|
package/types/jsx.d.ts
CHANGED
|
@@ -92,6 +92,7 @@ export namespace JSX {
|
|
|
92
92
|
onFocusIn?: EventHandlerUnion<T, FocusEvent>;
|
|
93
93
|
onBlur?: EventHandlerUnion<T, FocusEvent>;
|
|
94
94
|
onChange?: EventHandlerUnion<T, Event>;
|
|
95
|
+
onInvalid?: EventHandlerUnion<T, Event>;
|
|
95
96
|
onInput?: EventHandlerUnion<T, InputEvent>;
|
|
96
97
|
onBeforeInput?: EventHandlerUnion<T, InputEvent>;
|
|
97
98
|
onReset?: EventHandlerUnion<T, Event>;
|
|
@@ -180,6 +181,7 @@ export namespace JSX {
|
|
|
180
181
|
onfocusin?: EventHandlerUnion<T, FocusEvent>;
|
|
181
182
|
onblur?: EventHandlerUnion<T, FocusEvent>;
|
|
182
183
|
onchange?: EventHandlerUnion<T, Event>;
|
|
184
|
+
oninvalid?: EventHandlerUnion<T, Event>;
|
|
183
185
|
oninput?: EventHandlerUnion<T, InputEvent>;
|
|
184
186
|
onbeforeinput?: EventHandlerUnion<T, InputEvent>;
|
|
185
187
|
onreset?: EventHandlerUnion<T, Event>;
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { requestCallback } from "./scheduler";
|
|
2
2
|
import type { JSX } from "../jsx";
|
|
3
|
-
export declare type Accessor<T> = () => T;
|
|
4
|
-
export declare type Setter<T> = undefined extends T ? <U extends T>(v?: (U extends Function ? never : U) | ((prev?: T) => U)) => U : <U extends T>(v: (U extends Function ? never : U) | ((prev: T) => U)) => U;
|
|
5
3
|
export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
6
4
|
export declare const $PROXY: unique symbol;
|
|
7
5
|
export declare const NOTPENDING: {};
|
|
8
6
|
export declare var Owner: Owner | null;
|
|
9
|
-
export declare let Transition:
|
|
7
|
+
export declare let Transition: TransitionState | null;
|
|
10
8
|
declare global {
|
|
11
9
|
var _$afterUpdate: () => void;
|
|
12
10
|
}
|
|
13
|
-
interface
|
|
11
|
+
export interface SignalState<T> {
|
|
14
12
|
value?: T;
|
|
15
13
|
observers: Computation<any>[] | null;
|
|
16
14
|
observerSlots: number[] | null;
|
|
@@ -19,7 +17,7 @@ interface Signal<T> {
|
|
|
19
17
|
comparator?: (prev: T, next: T) => boolean;
|
|
20
18
|
name?: string;
|
|
21
19
|
}
|
|
22
|
-
interface Owner {
|
|
20
|
+
export interface Owner {
|
|
23
21
|
owned: Computation<any>[] | null;
|
|
24
22
|
cleanups: (() => void)[] | null;
|
|
25
23
|
owner: Owner | null;
|
|
@@ -30,23 +28,20 @@ interface Owner {
|
|
|
30
28
|
name?: string;
|
|
31
29
|
componentName?: string;
|
|
32
30
|
}
|
|
33
|
-
interface Computation<
|
|
34
|
-
fn:
|
|
31
|
+
export interface Computation<Init, Next extends Init = Init> extends Owner {
|
|
32
|
+
fn: EffectFunction<Init, Next>;
|
|
35
33
|
state: number;
|
|
36
34
|
tState?: number;
|
|
37
|
-
sources:
|
|
35
|
+
sources: SignalState<Next>[] | null;
|
|
38
36
|
sourceSlots: number[] | null;
|
|
39
|
-
value?:
|
|
37
|
+
value?: Init;
|
|
40
38
|
updatedAt: number | null;
|
|
41
39
|
pure: boolean;
|
|
42
40
|
user?: boolean;
|
|
43
41
|
suspense?: SuspenseContextType;
|
|
44
42
|
}
|
|
45
|
-
interface
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
interface Transition {
|
|
49
|
-
sources: Set<Signal<any>>;
|
|
43
|
+
export interface TransitionState {
|
|
44
|
+
sources: Set<SignalState<any>>;
|
|
50
45
|
effects: Computation<any>[];
|
|
51
46
|
promises: Set<Promise<any>>;
|
|
52
47
|
disposed: Set<Computation<any>>;
|
|
@@ -55,6 +50,7 @@ interface Transition {
|
|
|
55
50
|
running: boolean;
|
|
56
51
|
cb: (() => void)[];
|
|
57
52
|
}
|
|
53
|
+
export declare type RootFunction<T> = (dispose: () => void) => T;
|
|
58
54
|
/**
|
|
59
55
|
* Creates a new non-tracked reactive context that doesn't auto-dispose
|
|
60
56
|
*
|
|
@@ -64,11 +60,13 @@ interface Transition {
|
|
|
64
60
|
*
|
|
65
61
|
* @description https://www.solidjs.com/docs/latest/api#createroot
|
|
66
62
|
*/
|
|
67
|
-
export declare function createRoot<T>(fn:
|
|
68
|
-
export declare type
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
63
|
+
export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: Owner): T;
|
|
64
|
+
export declare type Accessor<T> = () => T;
|
|
65
|
+
export declare type Setter<T> = undefined extends T ? <U extends T>(value?: (U extends Function ? never : U) | ((prev?: T) => U)) => U : <U extends T>(value: (U extends Function ? never : U) | ((prev: T) => U)) => U;
|
|
66
|
+
export declare type Signal<T> = [get: Accessor<T>, set: Setter<T>];
|
|
67
|
+
export interface SignalOptions<T> extends MemoOptions<T> {
|
|
68
|
+
internal?: boolean;
|
|
69
|
+
}
|
|
72
70
|
/**
|
|
73
71
|
* Creates a simple reactive state with a getter and setter
|
|
74
72
|
* ```typescript
|
|
@@ -92,18 +90,21 @@ export declare type SignalOptions<T> = {
|
|
|
92
90
|
*
|
|
93
91
|
* @description https://www.solidjs.com/docs/latest/api#createsignal
|
|
94
92
|
*/
|
|
95
|
-
export declare function createSignal<T>():
|
|
96
|
-
export declare function createSignal<T>(value: T, options?:
|
|
97
|
-
|
|
93
|
+
export declare function createSignal<T>(): Signal<T | undefined>;
|
|
94
|
+
export declare function createSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
|
|
95
|
+
export interface BaseOptions {
|
|
98
96
|
name?: string;
|
|
99
|
-
|
|
100
|
-
|
|
97
|
+
}
|
|
98
|
+
export declare type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
99
|
+
export interface EffectOptions extends BaseOptions {
|
|
100
|
+
}
|
|
101
|
+
export declare type EffectFunction<Prev, Next extends Prev = Prev> = (v: Prev) => Next;
|
|
101
102
|
/**
|
|
102
103
|
* Creates a reactive computation that runs immediately before render, mainly used to write to other reactive primitives
|
|
103
104
|
* ```typescript
|
|
104
|
-
* export function createComputed<
|
|
105
|
-
* fn: (v:
|
|
106
|
-
* value?:
|
|
105
|
+
* export function createComputed<Next, Init = Next>(
|
|
106
|
+
* fn: (v: Init | Next) => Next,
|
|
107
|
+
* value?: Init,
|
|
107
108
|
* options?: { name?: string }
|
|
108
109
|
* ): void;
|
|
109
110
|
* ```
|
|
@@ -113,10 +114,8 @@ export declare function createSignal<T>(value: T, options?: {
|
|
|
113
114
|
*
|
|
114
115
|
* @description https://www.solidjs.com/docs/latest/api#createcomputed
|
|
115
116
|
*/
|
|
116
|
-
export declare function createComputed<
|
|
117
|
-
export declare function createComputed<
|
|
118
|
-
name?: string;
|
|
119
|
-
}): void;
|
|
117
|
+
export declare function createComputed<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
118
|
+
export declare function createComputed<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
120
119
|
/**
|
|
121
120
|
* Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
|
|
122
121
|
* ```typescript
|
|
@@ -132,10 +131,8 @@ export declare function createComputed<T>(fn: (v: T) => T, value: T, options?: {
|
|
|
132
131
|
*
|
|
133
132
|
* @description https://www.solidjs.com/docs/latest/api#createrendereffect
|
|
134
133
|
*/
|
|
135
|
-
export declare function createRenderEffect<
|
|
136
|
-
export declare function createRenderEffect<
|
|
137
|
-
name?: string;
|
|
138
|
-
}): void;
|
|
134
|
+
export declare function createRenderEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
135
|
+
export declare function createRenderEffect<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
139
136
|
/**
|
|
140
137
|
* Creates a reactive computation that runs after the render phase
|
|
141
138
|
* ```typescript
|
|
@@ -151,10 +148,14 @@ export declare function createRenderEffect<T>(fn: (v: T) => T, value: T, options
|
|
|
151
148
|
*
|
|
152
149
|
* @description https://www.solidjs.com/docs/latest/api#createeffect
|
|
153
150
|
*/
|
|
154
|
-
export declare function createEffect<
|
|
155
|
-
export declare function createEffect<
|
|
156
|
-
|
|
157
|
-
|
|
151
|
+
export declare function createEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
|
|
152
|
+
export declare function createEffect<Next, Init = undefined>(..._: undefined extends Init ? [fn: EffectFunction<Init | Next, Next>, value?: Init, options?: EffectOptions] : [fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions]): void;
|
|
153
|
+
interface Memo<Prev, Next = Prev> extends SignalState<Next>, Computation<Next> {
|
|
154
|
+
tOwned?: Computation<Prev | Next, Next>[];
|
|
155
|
+
}
|
|
156
|
+
export interface MemoOptions<T> extends EffectOptions {
|
|
157
|
+
equals?: false | ((prev: T, next: T) => boolean);
|
|
158
|
+
}
|
|
158
159
|
/**
|
|
159
160
|
* Creates a readonly derived reactive memoized signal
|
|
160
161
|
* ```typescript
|
|
@@ -170,14 +171,8 @@ export declare function createEffect<T>(fn: (v: T) => T, value: T, options?: {
|
|
|
170
171
|
*
|
|
171
172
|
* @description https://www.solidjs.com/docs/latest/api#creatememo
|
|
172
173
|
*/
|
|
173
|
-
export declare function createMemo<
|
|
174
|
-
|
|
175
|
-
name?: string;
|
|
176
|
-
}): Accessor<T>;
|
|
177
|
-
export declare function createMemo<T>(fn: (v: T) => T, value: T, options?: {
|
|
178
|
-
equals?: false | ((prev: T, next: T) => boolean);
|
|
179
|
-
name?: string;
|
|
180
|
-
}): Accessor<T>;
|
|
174
|
+
export declare function createMemo<Next extends _Next, Init = Next, _Next = Next>(fn: EffectFunction<Init | _Next, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
|
|
175
|
+
export declare function createMemo<Next extends _Next, Init = undefined, _Next = Next>(..._: undefined extends Init ? [fn: EffectFunction<Init | _Next, Next>, value?: Init, options?: MemoOptions<Next>] : [fn: EffectFunction<Init | _Next, Next>, value: Init, options?: MemoOptions<Next>]): Accessor<Next>;
|
|
181
176
|
export interface Resource<T> extends Accessor<T> {
|
|
182
177
|
loading: boolean;
|
|
183
178
|
error: any;
|
|
@@ -221,30 +216,30 @@ export declare type ResourceOptions<T> = T extends undefined ? {
|
|
|
221
216
|
*
|
|
222
217
|
* @description https://www.solidjs.com/docs/latest/api#createresource
|
|
223
218
|
*/
|
|
224
|
-
export declare function createResource<T
|
|
225
|
-
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>):
|
|
226
|
-
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>):
|
|
227
|
-
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>):
|
|
219
|
+
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
220
|
+
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
221
|
+
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
222
|
+
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
223
|
+
export interface DeferredOptions<T> {
|
|
224
|
+
equals?: false | ((prev: T, next: T) => boolean);
|
|
225
|
+
name?: string;
|
|
226
|
+
timeoutMs?: number;
|
|
227
|
+
}
|
|
228
228
|
/**
|
|
229
229
|
* Creates a reactive computation that only runs and notifies the reactive context when the browser is idle
|
|
230
230
|
* ```typescript
|
|
231
231
|
* export function createDeferred<T>(
|
|
232
232
|
* fn: (v: T) => T,
|
|
233
|
-
* value?: T,
|
|
234
233
|
* options?: { timeoutMs?: number, name?: string, equals?: false | ((prev: T, next: T) => boolean) }
|
|
235
234
|
* ): () => T);
|
|
236
235
|
* ```
|
|
237
236
|
* @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
|
|
238
|
-
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
|
|
239
237
|
* @param options allows to set the timeout in milliseconds, use a custom comparison function and set a name in dev mode for debugging purposes
|
|
240
238
|
*
|
|
241
239
|
* @description https://www.solidjs.com/docs/latest/api#createdeferred
|
|
242
240
|
*/
|
|
243
|
-
export declare function createDeferred<T>(source: Accessor<T>, options?:
|
|
244
|
-
|
|
245
|
-
name?: string;
|
|
246
|
-
timeoutMs?: number;
|
|
247
|
-
}): Accessor<T>;
|
|
241
|
+
export declare function createDeferred<T>(source: Accessor<T>, options?: DeferredOptions<T>): Accessor<T>;
|
|
242
|
+
export declare type EqualityCheckerFunction<T, U> = (a: U, b: T) => boolean;
|
|
248
243
|
/**
|
|
249
244
|
* Creates a conditional signal that only notifies subscribers when entering or exiting their key matching the value
|
|
250
245
|
* ```typescript
|
|
@@ -269,9 +264,7 @@ export declare function createDeferred<T>(source: Accessor<T>, options?: {
|
|
|
269
264
|
*
|
|
270
265
|
* @description https://www.solidjs.com/docs/latest/api#createselector
|
|
271
266
|
*/
|
|
272
|
-
export declare function createSelector<T, U>(source: Accessor<T>, fn?:
|
|
273
|
-
name?: string;
|
|
274
|
-
}): (key: U) => boolean;
|
|
267
|
+
export declare function createSelector<T, U>(source: Accessor<T>, fn?: EqualityCheckerFunction<T, U>, options?: BaseOptions): (key: U) => boolean;
|
|
275
268
|
/**
|
|
276
269
|
* Holds changes inside the block before the reactive context is updated
|
|
277
270
|
* @param fn wraps the reactive updates that should be batched
|
|
@@ -279,7 +272,7 @@ export declare function createSelector<T, U>(source: Accessor<T>, fn?: (a: U, b:
|
|
|
279
272
|
*
|
|
280
273
|
* @description https://www.solidjs.com/docs/latest/api#batch
|
|
281
274
|
*/
|
|
282
|
-
export declare function batch<T>(fn:
|
|
275
|
+
export declare function batch<T>(fn: Accessor<T>): T;
|
|
283
276
|
/**
|
|
284
277
|
* Ignores tracking context inside its scope
|
|
285
278
|
* @param fn the scope that is out of the tracking context
|
|
@@ -291,6 +284,10 @@ export declare function untrack<T>(fn: Accessor<T>): T;
|
|
|
291
284
|
export declare type ReturnTypes<T> = T extends (() => any)[] ? {
|
|
292
285
|
[I in keyof T]: ReturnTypes<T[I]>;
|
|
293
286
|
} : T extends () => any ? ReturnType<T> : never;
|
|
287
|
+
export declare type OnEffectFunction<S, Prev, Next extends Prev = Prev> = (input: ReturnTypes<S>, prevInput: ReturnTypes<S>, v: Prev) => Next;
|
|
288
|
+
export interface OnOptions {
|
|
289
|
+
defer?: boolean;
|
|
290
|
+
}
|
|
294
291
|
/**
|
|
295
292
|
* on - make dependencies of a computation explicit
|
|
296
293
|
* ```typescript
|
|
@@ -303,6 +300,8 @@ export declare type ReturnTypes<T> = T extends (() => any)[] ? {
|
|
|
303
300
|
* @param deps list of reactive dependencies or a single reactive dependency
|
|
304
301
|
* @param fn computation on input; the current previous content(s) of input and the previous value are given as arguments and it returns a new value
|
|
305
302
|
* @param options optional, allows deferred computation until at the end of the next change
|
|
303
|
+
* @returns an effect function that is passed into createEffect. For example:
|
|
304
|
+
*
|
|
306
305
|
* ```typescript
|
|
307
306
|
* createEffect(on(a, (v) => console.log(v, b())));
|
|
308
307
|
*
|
|
@@ -315,12 +314,7 @@ export declare type ReturnTypes<T> = T extends (() => any)[] ? {
|
|
|
315
314
|
*
|
|
316
315
|
* @description https://www.solidjs.com/docs/latest/api#on
|
|
317
316
|
*/
|
|
318
|
-
export declare function on<
|
|
319
|
-
defer?: boolean;
|
|
320
|
-
}): (prevValue?: U) => U;
|
|
321
|
-
export declare function on<T extends () => any, U>(deps: T, fn: (input: ReturnType<T>, prevInput: ReturnType<T>, prevValue?: U) => U, options?: {
|
|
322
|
-
defer?: boolean;
|
|
323
|
-
}): (prevValue?: U) => U;
|
|
317
|
+
export declare function on<S extends Accessor<unknown> | Accessor<unknown>[] | [], Next, Init = unknown>(deps: S, fn: OnEffectFunction<S, Init | Next, Next>, options?: OnOptions): EffectFunction<NoInfer<Init> | NoInfer<Next>, NoInfer<Next>>;
|
|
324
318
|
/**
|
|
325
319
|
* onMount - run an effect only after initial render on mount
|
|
326
320
|
* @param fn an effect that should run only once on mount
|
|
@@ -344,11 +338,12 @@ export declare function onCleanup(fn: () => void): () => void;
|
|
|
344
338
|
* @description https://www.solidjs.com/docs/latest/api#onerror
|
|
345
339
|
*/
|
|
346
340
|
export declare function onError(fn: (err: any) => void): void;
|
|
347
|
-
export declare function getListener(): Computation<any> | null;
|
|
341
|
+
export declare function getListener(): Computation<any, any> | null;
|
|
348
342
|
export declare function getOwner(): Owner | null;
|
|
349
343
|
export declare function runWithOwner(o: Owner, fn: () => any): any;
|
|
350
344
|
export declare function enableScheduling(scheduler?: typeof requestCallback): void;
|
|
351
345
|
export declare function startTransition(fn: () => void, cb?: () => void): void;
|
|
346
|
+
export declare type Transition = [Accessor<boolean>, (fn: () => void, cb?: () => void) => void];
|
|
352
347
|
/**
|
|
353
348
|
* ```typescript
|
|
354
349
|
* export function useTransition(): [
|
|
@@ -359,7 +354,7 @@ export declare function startTransition(fn: () => void, cb?: () => void): void;
|
|
|
359
354
|
*
|
|
360
355
|
* @description https://www.solidjs.com/docs/latest/api#usetransition
|
|
361
356
|
*/
|
|
362
|
-
export declare function useTransition():
|
|
357
|
+
export declare function useTransition(): Transition;
|
|
363
358
|
export declare function resumeEffects(e: Computation<any>[]): void;
|
|
364
359
|
export declare function devComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
365
360
|
export declare function hashValue(v: any): string;
|
|
@@ -370,12 +365,13 @@ interface GraphRecord {
|
|
|
370
365
|
[k: string]: GraphRecord | unknown;
|
|
371
366
|
}
|
|
372
367
|
export declare function serializeGraph(owner?: Owner | null): GraphRecord;
|
|
368
|
+
export declare type ContextProviderComponent<T> = (props: {
|
|
369
|
+
value: T;
|
|
370
|
+
children: any;
|
|
371
|
+
}) => any;
|
|
373
372
|
export interface Context<T> {
|
|
374
373
|
id: symbol;
|
|
375
|
-
Provider:
|
|
376
|
-
value: T;
|
|
377
|
-
children: any;
|
|
378
|
-
}) => any;
|
|
374
|
+
Provider: ContextProviderComponent<T>;
|
|
379
375
|
defaultValue: T;
|
|
380
376
|
}
|
|
381
377
|
/**
|
|
@@ -413,18 +409,20 @@ export declare function useContext<T>(context: Context<T>): T;
|
|
|
413
409
|
* @description https://www.solidjs.com/docs/latest/api#children
|
|
414
410
|
*/
|
|
415
411
|
export declare function children(fn: Accessor<JSX.Element>): Accessor<JSX.Element>;
|
|
416
|
-
declare type SuspenseContextType = {
|
|
412
|
+
export declare type SuspenseContextType = {
|
|
417
413
|
increment?: () => void;
|
|
418
414
|
decrement?: () => void;
|
|
419
415
|
inFallback?: () => boolean;
|
|
420
416
|
effects?: Computation<any>[];
|
|
421
417
|
resolved?: boolean;
|
|
422
418
|
};
|
|
423
|
-
|
|
419
|
+
declare type SuspenseContext = Context<SuspenseContextType> & {
|
|
424
420
|
active?(): boolean;
|
|
425
421
|
increment?(): void;
|
|
426
422
|
decrement?(): void;
|
|
427
423
|
};
|
|
428
|
-
|
|
429
|
-
export declare function
|
|
424
|
+
declare let SuspenseContext: SuspenseContext;
|
|
425
|
+
export declare function getSuspenseContext(): SuspenseContext;
|
|
426
|
+
export declare function readSignal(this: SignalState<any> | Memo<any>): any;
|
|
427
|
+
export declare function writeSignal(node: SignalState<any> | Memo<any>, value: any, isComp?: boolean): any;
|
|
430
428
|
export {};
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
declare type HydrationContext = {
|
|
1
|
+
export declare type HydrationContext = {
|
|
2
2
|
id: string;
|
|
3
3
|
count: number;
|
|
4
|
-
loadResource?: (id: string) => Promise<any>;
|
|
5
4
|
};
|
|
6
5
|
declare type SharedConfig = {
|
|
7
6
|
context?: HydrationContext;
|
|
8
7
|
resources?: {
|
|
9
8
|
[key: string]: any;
|
|
10
9
|
};
|
|
10
|
+
load?: (id: string) => Promise<any> | undefined;
|
|
11
|
+
gather?: (key: string) => void;
|
|
11
12
|
registry?: Map<string, Element>;
|
|
12
13
|
};
|
|
13
14
|
export declare const sharedConfig: SharedConfig;
|
package/types/server/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export { createRoot, createSignal, createComputed, createRenderEffect, createEffect, createDeferred, createSelector, createMemo, getListener, onMount, onCleanup, onError, untrack, batch, on, children, createContext, useContext, getOwner, runWithOwner, equalFn, requestCallback, mapArray, observable, from, $PROXY, DEV } from "./reactive";
|
|
2
|
-
export {
|
|
2
|
+
export { mergeProps, splitProps, createComponent, For, Index, Show, Switch, Match, ErrorBoundary, Suspense, SuspenseList, createResource, enableScheduling, startTransition, useTransition, createUniqueId, lazy, sharedConfig } from "./rendering";
|
|
3
3
|
export type { Component, Resource } from "./rendering";
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import type { Accessor, Setter } from "../reactive/signal";
|
|
1
2
|
export declare const equalFn: <T>(a: T, b: T) => boolean;
|
|
2
3
|
export declare const $PROXY: unique symbol;
|
|
3
4
|
export declare const DEV: {};
|
|
4
5
|
export declare let Owner: Owner | null;
|
|
5
|
-
export declare type Accessor<T> = () => T;
|
|
6
|
-
export declare type Setter<T> = undefined extends T ? <U extends T>(v?: (U extends Function ? never : U) | ((prev?: U) => U)) => U : <U extends T>(v: (U extends Function ? never : U) | ((prev: U) => U)) => U;
|
|
7
6
|
interface Owner {
|
|
8
7
|
owner: Owner | null;
|
|
9
8
|
context: any | null;
|
|
@@ -94,8 +94,10 @@ declare type HydrationContext = {
|
|
|
94
94
|
writeResource?: (id: string, v: Promise<any>) => void;
|
|
95
95
|
resources: Record<string, any>;
|
|
96
96
|
suspense: Record<string, SuspenseContextType>;
|
|
97
|
+
registerFragment: (v: string) => (v?: string) => void;
|
|
97
98
|
async?: boolean;
|
|
98
99
|
streaming?: boolean;
|
|
100
|
+
noHydrate: boolean;
|
|
99
101
|
};
|
|
100
102
|
export declare function SuspenseList(props: {
|
|
101
103
|
children: string;
|
|
@@ -106,5 +108,4 @@ export declare function Suspense(props: {
|
|
|
106
108
|
fallback: string;
|
|
107
109
|
children: string;
|
|
108
110
|
}): any;
|
|
109
|
-
export declare function awaitSuspense(fn: () => any): Promise<unknown>;
|
|
110
111
|
export {};
|
package/web/dist/dev.cjs
CHANGED
|
@@ -203,60 +203,41 @@ function insert(parent, accessor, marker, initial) {
|
|
|
203
203
|
solidJs.createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial);
|
|
204
204
|
}
|
|
205
205
|
function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
206
|
-
|
|
206
|
+
for (const prop in prevProps) {
|
|
207
|
+
if (!(prop in props)) {
|
|
208
|
+
if (prop === "children") continue;
|
|
209
|
+
assignProp(node, prop, null, prevProps[prop], isSVG);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
207
212
|
for (const prop in props) {
|
|
208
213
|
if (prop === "children") {
|
|
209
214
|
if (!skipChildren) insertExpression(node, props.children);
|
|
210
215
|
continue;
|
|
211
216
|
}
|
|
212
217
|
const value = props[prop];
|
|
213
|
-
|
|
214
|
-
if (prop === "style") {
|
|
215
|
-
style(node, value, prevProps[prop]);
|
|
216
|
-
} else if (prop === "classList") {
|
|
217
|
-
classList(node, value, prevProps[prop]);
|
|
218
|
-
} else if (prop === "ref") {
|
|
219
|
-
value(node);
|
|
220
|
-
} else if (prop.slice(0, 3) === "on:") {
|
|
221
|
-
node.addEventListener(prop.slice(3), value);
|
|
222
|
-
} else if (prop.slice(0, 10) === "oncapture:") {
|
|
223
|
-
node.addEventListener(prop.slice(10), value, true);
|
|
224
|
-
} else if (prop.slice(0, 2) === "on") {
|
|
225
|
-
const name = prop.slice(2).toLowerCase();
|
|
226
|
-
const delegate = DelegatedEvents.has(name);
|
|
227
|
-
addEventListener(node, name, value, delegate);
|
|
228
|
-
delegate && delegateEvents([name]);
|
|
229
|
-
} else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
|
|
230
|
-
if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
|
|
231
|
-
} else {
|
|
232
|
-
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
233
|
-
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
|
|
234
|
-
}
|
|
235
|
-
prevProps[prop] = value;
|
|
218
|
+
prevProps[prop] = assignProp(node, prop, value, prevProps[prop], isSVG);
|
|
236
219
|
}
|
|
237
220
|
}
|
|
238
221
|
function hydrate(code, element) {
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
222
|
+
if (!globalThis._$HY.sync) {
|
|
223
|
+
let dispose;
|
|
224
|
+
globalThis._$HY.queue.push(() => dispose = hydrate(code, element));
|
|
225
|
+
return () => dispose();
|
|
226
|
+
}
|
|
227
|
+
solidJs.sharedConfig.completed = globalThis._$HY.completed;
|
|
228
|
+
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
229
|
+
solidJs.sharedConfig.load = globalThis._$HY.load;
|
|
230
|
+
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
231
|
+
solidJs.sharedConfig.registry = new Map();
|
|
242
232
|
solidJs.sharedConfig.context = {
|
|
243
233
|
id: "",
|
|
244
|
-
count: 0
|
|
245
|
-
loadResource: globalThis._$HYDRATION.loadResource
|
|
234
|
+
count: 0
|
|
246
235
|
};
|
|
247
|
-
solidJs.sharedConfig.registry = new Map();
|
|
248
236
|
gatherHydratable(element);
|
|
249
237
|
const dispose = render(code, element, [...element.childNodes]);
|
|
250
238
|
solidJs.sharedConfig.context = null;
|
|
251
239
|
return dispose;
|
|
252
240
|
}
|
|
253
|
-
function gatherHydratable(element) {
|
|
254
|
-
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
255
|
-
for (let i = 0; i < templates.length; i++) {
|
|
256
|
-
const node = templates[i];
|
|
257
|
-
solidJs.sharedConfig.registry.set(node.getAttribute("data-hk"), node);
|
|
258
|
-
}
|
|
259
|
-
}
|
|
260
241
|
function getNextElement(template) {
|
|
261
242
|
let node, key;
|
|
262
243
|
if (!solidJs.sharedConfig.context || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
@@ -314,6 +295,30 @@ function toggleClassKey(node, key, value) {
|
|
|
314
295
|
const classNames = key.trim().split(/\s+/);
|
|
315
296
|
for (let i = 0, nameLen = classNames.length; i < nameLen; i++) node.classList.toggle(classNames[i], value);
|
|
316
297
|
}
|
|
298
|
+
function assignProp(node, prop, value, prev, isSVG) {
|
|
299
|
+
let isCE, isProp, isChildProp;
|
|
300
|
+
if (prop === "style") return style(node, value, prev);
|
|
301
|
+
if (prop === "classList") return classList(node, value, prev);
|
|
302
|
+
if (value === prev) return prev;
|
|
303
|
+
if (prop === "ref") {
|
|
304
|
+
value(node);
|
|
305
|
+
} else if (prop.slice(0, 3) === "on:") {
|
|
306
|
+
node.addEventListener(prop.slice(3), value);
|
|
307
|
+
} else if (prop.slice(0, 10) === "oncapture:") {
|
|
308
|
+
node.addEventListener(prop.slice(10), value, true);
|
|
309
|
+
} else if (prop.slice(0, 2) === "on") {
|
|
310
|
+
const name = prop.slice(2).toLowerCase();
|
|
311
|
+
const delegate = DelegatedEvents.has(name);
|
|
312
|
+
addEventListener(node, name, value, delegate);
|
|
313
|
+
delegate && delegateEvents([name]);
|
|
314
|
+
} else if ((isChildProp = ChildProperties.has(prop)) || !isSVG && (PropAliases[prop] || (isProp = Properties.has(prop))) || (isCE = node.nodeName.includes("-"))) {
|
|
315
|
+
if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[PropAliases[prop] || prop] = value;
|
|
316
|
+
} else {
|
|
317
|
+
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
318
|
+
if (ns) setAttributeNS(node, ns, prop, value);else setAttribute(node, Aliases[prop] || prop, value);
|
|
319
|
+
}
|
|
320
|
+
return value;
|
|
321
|
+
}
|
|
317
322
|
function eventHandler(e) {
|
|
318
323
|
const key = `$$${e.type}`;
|
|
319
324
|
let node = e.composedPath && e.composedPath()[0] || e.target;
|
|
@@ -326,7 +331,7 @@ function eventHandler(e) {
|
|
|
326
331
|
Object.defineProperty(e, "currentTarget", {
|
|
327
332
|
configurable: true,
|
|
328
333
|
get() {
|
|
329
|
-
return node;
|
|
334
|
+
return node || document;
|
|
330
335
|
}
|
|
331
336
|
});
|
|
332
337
|
while (node !== null) {
|
|
@@ -381,7 +386,12 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
381
386
|
solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
382
387
|
return () => current;
|
|
383
388
|
}
|
|
384
|
-
if (solidJs.sharedConfig.context && current && current.length)
|
|
389
|
+
if (solidJs.sharedConfig.context && current && current.length) {
|
|
390
|
+
for (let i; i < array.length; i++) {
|
|
391
|
+
if (array[i].parentNode) return array;
|
|
392
|
+
}
|
|
393
|
+
return current;
|
|
394
|
+
}
|
|
385
395
|
if (array.length === 0) {
|
|
386
396
|
current = cleanChildren(parent, current, marker);
|
|
387
397
|
if (multi) return current;
|
|
@@ -449,6 +459,14 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
449
459
|
} else parent.insertBefore(node, marker);
|
|
450
460
|
return [node];
|
|
451
461
|
}
|
|
462
|
+
function gatherHydratable(element, root) {
|
|
463
|
+
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
464
|
+
for (let i = 0; i < templates.length; i++) {
|
|
465
|
+
const node = templates[i];
|
|
466
|
+
const key = node.getAttribute("data-hk");
|
|
467
|
+
if (!root || key.startsWith(root)) solidJs.sharedConfig.registry.set(key, node);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
452
470
|
function getHydrationKey() {
|
|
453
471
|
const hydrate = solidJs.sharedConfig.context;
|
|
454
472
|
return `${hydrate.id}${hydrate.count++}`;
|
|
@@ -623,7 +641,6 @@ exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
|
623
641
|
exports.delegateEvents = delegateEvents;
|
|
624
642
|
exports.dynamicProperty = dynamicProperty;
|
|
625
643
|
exports.escape = escape;
|
|
626
|
-
exports.gatherHydratable = gatherHydratable;
|
|
627
644
|
exports.generateHydrationScript = generateHydrationScript;
|
|
628
645
|
exports.getHydrationKey = getHydrationKey;
|
|
629
646
|
exports.getNextElement = getNextElement;
|