solid-js 1.2.6 → 1.3.0-beta.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/README.md +3 -1
- package/dist/dev.cjs +66 -33
- package/dist/dev.js +67 -33
- package/dist/server.cjs +67 -60
- package/dist/server.js +68 -60
- package/dist/solid.cjs +66 -33
- package/dist/solid.js +67 -33
- package/package.json +3 -3
- package/types/index.d.ts +0 -1
- 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 +7 -5
- package/web/dist/dev.cjs +21 -16
- package/web/dist/dev.js +22 -16
- package/web/dist/server.cjs +251 -104
- package/web/dist/server.js +252 -106
- package/web/dist/web.cjs +21 -16
- package/web/dist/web.js +22 -16
- package/web/types/client.d.ts +0 -1
- package/web/types/core.d.ts +2 -2
|
@@ -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;
|
|
@@ -56,9 +56,9 @@ declare type MatchProps<T> = {
|
|
|
56
56
|
};
|
|
57
57
|
export declare function Match<T>(props: MatchProps<T>): MatchProps<T>;
|
|
58
58
|
export declare function ErrorBoundary(props: {
|
|
59
|
-
fallback: string | ((err: any) => string);
|
|
59
|
+
fallback: string | ((err: any, reset: () => void) => string);
|
|
60
60
|
children: string;
|
|
61
|
-
}):
|
|
61
|
+
}): any;
|
|
62
62
|
export interface Resource<T> {
|
|
63
63
|
(): T | undefined;
|
|
64
64
|
loading: boolean;
|
|
@@ -91,11 +91,14 @@ export declare function useTransition(): [() => boolean, (fn: () => any) => void
|
|
|
91
91
|
declare type HydrationContext = {
|
|
92
92
|
id: string;
|
|
93
93
|
count: number;
|
|
94
|
-
writeResource?: (id: string, v: Promise<any>) => void;
|
|
94
|
+
writeResource?: (id: string, v: Promise<any> | any, error?: boolean) => void;
|
|
95
95
|
resources: Record<string, any>;
|
|
96
96
|
suspense: Record<string, SuspenseContextType>;
|
|
97
|
+
registerFragment: (v: string) => (v?: string, err?: any) => boolean;
|
|
97
98
|
async?: boolean;
|
|
98
99
|
streaming?: boolean;
|
|
100
|
+
dataOnly?: boolean;
|
|
101
|
+
noHydrate: boolean;
|
|
99
102
|
};
|
|
100
103
|
export declare function SuspenseList(props: {
|
|
101
104
|
children: string;
|
|
@@ -103,8 +106,7 @@ export declare function SuspenseList(props: {
|
|
|
103
106
|
tail?: "collapsed" | "hidden";
|
|
104
107
|
}): string;
|
|
105
108
|
export declare function Suspense(props: {
|
|
106
|
-
fallback
|
|
109
|
+
fallback?: string;
|
|
107
110
|
children: string;
|
|
108
111
|
}): any;
|
|
109
|
-
export declare function awaitSuspense(fn: () => any): Promise<unknown>;
|
|
110
112
|
export {};
|
package/web/dist/dev.cjs
CHANGED
|
@@ -219,27 +219,20 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
function hydrate(code, element) {
|
|
222
|
-
solidJs.sharedConfig.
|
|
223
|
-
solidJs.sharedConfig.
|
|
224
|
-
solidJs.sharedConfig.
|
|
222
|
+
solidJs.sharedConfig.completed = globalThis._$HY.completed;
|
|
223
|
+
solidJs.sharedConfig.events = globalThis._$HY.events;
|
|
224
|
+
solidJs.sharedConfig.load = globalThis._$HY.load;
|
|
225
|
+
solidJs.sharedConfig.gather = root => gatherHydratable(element, root);
|
|
226
|
+
solidJs.sharedConfig.registry = new Map();
|
|
225
227
|
solidJs.sharedConfig.context = {
|
|
226
228
|
id: "",
|
|
227
|
-
count: 0
|
|
228
|
-
loadResource: globalThis._$HYDRATION.loadResource
|
|
229
|
+
count: 0
|
|
229
230
|
};
|
|
230
|
-
solidJs.sharedConfig.registry = new Map();
|
|
231
231
|
gatherHydratable(element);
|
|
232
232
|
const dispose = render(code, element, [...element.childNodes]);
|
|
233
233
|
solidJs.sharedConfig.context = null;
|
|
234
234
|
return dispose;
|
|
235
235
|
}
|
|
236
|
-
function gatherHydratable(element) {
|
|
237
|
-
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
238
|
-
for (let i = 0; i < templates.length; i++) {
|
|
239
|
-
const node = templates[i];
|
|
240
|
-
solidJs.sharedConfig.registry.set(node.getAttribute("data-hk"), node);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
236
|
function getNextElement(template) {
|
|
244
237
|
let node, key;
|
|
245
238
|
if (!solidJs.sharedConfig.context || !(node = solidJs.sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
@@ -333,7 +326,7 @@ function eventHandler(e) {
|
|
|
333
326
|
Object.defineProperty(e, "currentTarget", {
|
|
334
327
|
configurable: true,
|
|
335
328
|
get() {
|
|
336
|
-
return node;
|
|
329
|
+
return node || document;
|
|
337
330
|
}
|
|
338
331
|
});
|
|
339
332
|
while (node !== null) {
|
|
@@ -388,7 +381,12 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
388
381
|
solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
389
382
|
return () => current;
|
|
390
383
|
}
|
|
391
|
-
if (solidJs.sharedConfig.context && current && current.length)
|
|
384
|
+
if (solidJs.sharedConfig.context && current && current.length) {
|
|
385
|
+
for (let i = 0; i < array.length; i++) {
|
|
386
|
+
if (array[i].parentNode) return current = array;
|
|
387
|
+
}
|
|
388
|
+
return current;
|
|
389
|
+
}
|
|
392
390
|
if (array.length === 0) {
|
|
393
391
|
current = cleanChildren(parent, current, marker);
|
|
394
392
|
if (multi) return current;
|
|
@@ -456,6 +454,14 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
456
454
|
} else parent.insertBefore(node, marker);
|
|
457
455
|
return [node];
|
|
458
456
|
}
|
|
457
|
+
function gatherHydratable(element, root) {
|
|
458
|
+
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
459
|
+
for (let i = 0; i < templates.length; i++) {
|
|
460
|
+
const node = templates[i];
|
|
461
|
+
const key = node.getAttribute("data-hk");
|
|
462
|
+
if (!root || key.startsWith(root)) solidJs.sharedConfig.registry.set(key, node);
|
|
463
|
+
}
|
|
464
|
+
}
|
|
459
465
|
function getHydrationKey() {
|
|
460
466
|
const hydrate = solidJs.sharedConfig.context;
|
|
461
467
|
return `${hydrate.id}${hydrate.count++}`;
|
|
@@ -630,7 +636,6 @@ exports.clearDelegatedEvents = clearDelegatedEvents;
|
|
|
630
636
|
exports.delegateEvents = delegateEvents;
|
|
631
637
|
exports.dynamicProperty = dynamicProperty;
|
|
632
638
|
exports.escape = escape;
|
|
633
|
-
exports.gatherHydratable = gatherHydratable;
|
|
634
639
|
exports.generateHydrationScript = generateHydrationScript;
|
|
635
640
|
exports.getHydrationKey = getHydrationKey;
|
|
636
641
|
exports.getNextElement = getNextElement;
|
package/web/dist/dev.js
CHANGED
|
@@ -216,27 +216,20 @@ function assign(node, props, isSVG, skipChildren, prevProps = {}) {
|
|
|
216
216
|
}
|
|
217
217
|
}
|
|
218
218
|
function hydrate(code, element) {
|
|
219
|
-
sharedConfig.
|
|
220
|
-
sharedConfig.
|
|
221
|
-
sharedConfig.
|
|
219
|
+
sharedConfig.completed = globalThis._$HY.completed;
|
|
220
|
+
sharedConfig.events = globalThis._$HY.events;
|
|
221
|
+
sharedConfig.load = globalThis._$HY.load;
|
|
222
|
+
sharedConfig.gather = root => gatherHydratable(element, root);
|
|
223
|
+
sharedConfig.registry = new Map();
|
|
222
224
|
sharedConfig.context = {
|
|
223
225
|
id: "",
|
|
224
|
-
count: 0
|
|
225
|
-
loadResource: globalThis._$HYDRATION.loadResource
|
|
226
|
+
count: 0
|
|
226
227
|
};
|
|
227
|
-
sharedConfig.registry = new Map();
|
|
228
228
|
gatherHydratable(element);
|
|
229
229
|
const dispose = render(code, element, [...element.childNodes]);
|
|
230
230
|
sharedConfig.context = null;
|
|
231
231
|
return dispose;
|
|
232
232
|
}
|
|
233
|
-
function gatherHydratable(element) {
|
|
234
|
-
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
235
|
-
for (let i = 0; i < templates.length; i++) {
|
|
236
|
-
const node = templates[i];
|
|
237
|
-
sharedConfig.registry.set(node.getAttribute("data-hk"), node);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
233
|
function getNextElement(template) {
|
|
241
234
|
let node, key;
|
|
242
235
|
if (!sharedConfig.context || !(node = sharedConfig.registry.get(key = getHydrationKey()))) {
|
|
@@ -330,7 +323,7 @@ function eventHandler(e) {
|
|
|
330
323
|
Object.defineProperty(e, "currentTarget", {
|
|
331
324
|
configurable: true,
|
|
332
325
|
get() {
|
|
333
|
-
return node;
|
|
326
|
+
return node || document;
|
|
334
327
|
}
|
|
335
328
|
});
|
|
336
329
|
while (node !== null) {
|
|
@@ -385,7 +378,12 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
385
378
|
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
386
379
|
return () => current;
|
|
387
380
|
}
|
|
388
|
-
if (sharedConfig.context && current && current.length)
|
|
381
|
+
if (sharedConfig.context && current && current.length) {
|
|
382
|
+
for (let i = 0; i < array.length; i++) {
|
|
383
|
+
if (array[i].parentNode) return current = array;
|
|
384
|
+
}
|
|
385
|
+
return current;
|
|
386
|
+
}
|
|
389
387
|
if (array.length === 0) {
|
|
390
388
|
current = cleanChildren(parent, current, marker);
|
|
391
389
|
if (multi) return current;
|
|
@@ -453,6 +451,14 @@ function cleanChildren(parent, current, marker, replacement) {
|
|
|
453
451
|
} else parent.insertBefore(node, marker);
|
|
454
452
|
return [node];
|
|
455
453
|
}
|
|
454
|
+
function gatherHydratable(element, root) {
|
|
455
|
+
const templates = element.querySelectorAll(`*[data-hk]`);
|
|
456
|
+
for (let i = 0; i < templates.length; i++) {
|
|
457
|
+
const node = templates[i];
|
|
458
|
+
const key = node.getAttribute("data-hk");
|
|
459
|
+
if (!root || key.startsWith(root)) sharedConfig.registry.set(key, node);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
456
462
|
function getHydrationKey() {
|
|
457
463
|
const hydrate = sharedConfig.context;
|
|
458
464
|
return `${hydrate.id}${hydrate.count++}`;
|
|
@@ -536,4 +542,4 @@ function Dynamic(props) {
|
|
|
536
542
|
});
|
|
537
543
|
}
|
|
538
544
|
|
|
539
|
-
export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape,
|
|
545
|
+
export { Aliases, Assets, ChildProperties, DelegatedEvents, Dynamic, Assets as HydrationScript, NoHydration, Portal, PropAliases, Properties, SVGElements, SVGNamespace, addEventListener, assign, classList, clearDelegatedEvents, delegateEvents, dynamicProperty, escape, generateHydrationScript, getHydrationKey, getNextElement, getNextMarker, getNextMatch, hydrate, insert, isServer, memo, pipeToNodeWritable, pipeToWritable, render, renderToString, renderToStringAsync, resolveSSRNode, runHydrationEvents, setAttribute, setAttributeNS, spread, ssr, ssrBoolean, ssrClassList, ssrHydrationKey, ssrSpread, ssrStyle, style, template };
|