solid-js 1.8.14 → 1.8.16
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 +8 -7
- package/dist/dev.js +561 -319
- package/dist/server.js +170 -75
- package/dist/solid.cjs +8 -7
- package/dist/solid.js +488 -277
- package/h/dist/h.js +34 -8
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +7 -2
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -33
- package/package.json +2 -2
- package/store/dist/dev.js +122 -43
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +113 -40
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +219 -62
- package/types/index.d.ts +75 -10
- package/types/jsx.d.ts +7 -2
- package/types/reactive/array.d.ts +14 -6
- package/types/reactive/observable.d.ts +26 -18
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +239 -147
- package/types/render/Suspense.d.ts +7 -7
- package/types/render/component.d.ts +64 -33
- package/types/render/flow.d.ts +47 -35
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +57 -2
- package/types/server/reactive.d.ts +73 -42
- package/types/server/rendering.d.ts +167 -96
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.cjs +13 -11
- package/web/dist/dev.js +635 -92
- package/web/dist/server.js +210 -96
- package/web/dist/web.cjs +13 -11
- package/web/dist/web.js +626 -90
- package/web/storage/dist/storage.js +3 -3
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +29 -12
- package/web/types/server-mock.d.ts +47 -32
|
@@ -2,156 +2,227 @@ import { Accessor, Setter, Signal } from "./reactive.js";
|
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
3
|
export type Component<P = {}> = (props: P) => JSX.Element;
|
|
4
4
|
export type VoidProps<P = {}> = P & {
|
|
5
|
-
|
|
5
|
+
children?: never;
|
|
6
6
|
};
|
|
7
7
|
export type VoidComponent<P = {}> = Component<VoidProps<P>>;
|
|
8
8
|
export type ParentProps<P = {}> = P & {
|
|
9
|
-
|
|
9
|
+
children?: JSX.Element;
|
|
10
10
|
};
|
|
11
11
|
export type ParentComponent<P = {}> = Component<ParentProps<P>>;
|
|
12
12
|
export type FlowProps<P = {}, C = JSX.Element> = P & {
|
|
13
|
-
|
|
13
|
+
children: C;
|
|
14
14
|
};
|
|
15
15
|
export type FlowComponent<P = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
|
|
16
16
|
export type Ref<T> = T | ((val: T) => void);
|
|
17
17
|
export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
|
|
18
|
-
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P>
|
|
18
|
+
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P>
|
|
19
|
+
? P
|
|
20
|
+
: T extends keyof JSX.IntrinsicElements
|
|
21
|
+
? JSX.IntrinsicElements[T]
|
|
22
|
+
: Record<string, unknown>;
|
|
19
23
|
type SharedConfig = {
|
|
20
|
-
|
|
24
|
+
context?: HydrationContext;
|
|
21
25
|
};
|
|
22
26
|
export declare const sharedConfig: SharedConfig;
|
|
23
27
|
export declare function createUniqueId(): string;
|
|
24
28
|
export declare function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
25
29
|
export declare function mergeProps<T, U>(source: T, source1: U): T & U;
|
|
26
30
|
export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V;
|
|
27
|
-
export declare function mergeProps<T, U, V, W>(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
export declare function mergeProps<T, U, V, W>(
|
|
32
|
+
source: T,
|
|
33
|
+
source1: U,
|
|
34
|
+
source2: V,
|
|
35
|
+
source3: W
|
|
36
|
+
): T & U & V & W;
|
|
37
|
+
export declare function splitProps<T extends object, K1 extends keyof T>(
|
|
38
|
+
props: T,
|
|
39
|
+
...keys: [K1[]]
|
|
40
|
+
): [Pick<T, K1>, Omit<T, K1>];
|
|
41
|
+
export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T>(
|
|
42
|
+
props: T,
|
|
43
|
+
...keys: [K1[], K2[]]
|
|
44
|
+
): [Pick<T, K1>, Pick<T, K2>, Omit<T, K1 | K2>];
|
|
45
|
+
export declare function splitProps<
|
|
46
|
+
T extends object,
|
|
47
|
+
K1 extends keyof T,
|
|
48
|
+
K2 extends keyof T,
|
|
49
|
+
K3 extends keyof T
|
|
50
|
+
>(
|
|
51
|
+
props: T,
|
|
52
|
+
...keys: [K1[], K2[], K3[]]
|
|
53
|
+
): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Omit<T, K1 | K2 | K3>];
|
|
54
|
+
export declare function splitProps<
|
|
55
|
+
T extends object,
|
|
56
|
+
K1 extends keyof T,
|
|
57
|
+
K2 extends keyof T,
|
|
58
|
+
K3 extends keyof T,
|
|
59
|
+
K4 extends keyof T
|
|
60
|
+
>(
|
|
61
|
+
props: T,
|
|
62
|
+
...keys: [K1[], K2[], K3[], K4[]]
|
|
63
|
+
): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Omit<T, K1 | K2 | K3 | K4>];
|
|
64
|
+
export declare function splitProps<
|
|
65
|
+
T extends object,
|
|
66
|
+
K1 extends keyof T,
|
|
67
|
+
K2 extends keyof T,
|
|
68
|
+
K3 extends keyof T,
|
|
69
|
+
K4 extends keyof T,
|
|
70
|
+
K5 extends keyof T
|
|
71
|
+
>(
|
|
72
|
+
props: T,
|
|
73
|
+
...keys: [K1[], K2[], K3[], K4[], K5[]]
|
|
74
|
+
): [
|
|
75
|
+
Pick<T, K1>,
|
|
76
|
+
Pick<T, K2>,
|
|
77
|
+
Pick<T, K3>,
|
|
78
|
+
Pick<T, K4>,
|
|
79
|
+
Pick<T, K5>,
|
|
80
|
+
Omit<T, K1 | K2 | K3 | K4 | K5>
|
|
39
81
|
];
|
|
40
82
|
export declare function For<T>(props: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
83
|
+
each: T[];
|
|
84
|
+
fallback?: string;
|
|
85
|
+
children: (item: T, index: () => number) => string;
|
|
44
86
|
}): string | any[] | undefined;
|
|
45
87
|
export declare function Index<T>(props: {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
88
|
+
each: T[];
|
|
89
|
+
fallback?: string;
|
|
90
|
+
children: (item: () => T, index: number) => string;
|
|
49
91
|
}): string | any[] | undefined;
|
|
50
92
|
/**
|
|
51
93
|
* Conditionally render its children or an optional fallback component
|
|
52
94
|
* @description https://www.solidjs.com/docs/latest/api#show
|
|
53
95
|
*/
|
|
54
96
|
export declare function Show<T>(props: {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
97
|
+
when: T | undefined | null | false;
|
|
98
|
+
keyed?: boolean;
|
|
99
|
+
fallback?: string;
|
|
100
|
+
children: string | ((item: NonNullable<T> | Accessor<NonNullable<T>>) => string);
|
|
59
101
|
}): string;
|
|
60
102
|
export declare function Switch(props: {
|
|
61
|
-
|
|
62
|
-
|
|
103
|
+
fallback?: string;
|
|
104
|
+
children: MatchProps<unknown> | MatchProps<unknown>[];
|
|
63
105
|
}): string;
|
|
64
106
|
type MatchProps<T> = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
107
|
+
when: T | false;
|
|
108
|
+
keyed?: boolean;
|
|
109
|
+
children: string | ((item: NonNullable<T> | Accessor<NonNullable<T>>) => string);
|
|
68
110
|
};
|
|
69
111
|
export declare function Match<T>(props: MatchProps<T>): MatchProps<T>;
|
|
70
112
|
export declare function resetErrorBoundaries(): void;
|
|
71
113
|
export declare function ErrorBoundary(props: {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}):
|
|
75
|
-
|
|
76
|
-
|
|
114
|
+
fallback: string | ((err: any, reset: () => void) => string);
|
|
115
|
+
children: string;
|
|
116
|
+
}):
|
|
117
|
+
| string
|
|
118
|
+
| ((err: any, reset: () => void) => string)
|
|
119
|
+
| {
|
|
120
|
+
t: string;
|
|
121
|
+
};
|
|
77
122
|
export interface Resource<T> {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
123
|
+
(): T | undefined;
|
|
124
|
+
state: "unresolved" | "pending" | "ready" | "refreshing" | "errored";
|
|
125
|
+
loading: boolean;
|
|
126
|
+
error: any;
|
|
127
|
+
latest: T | undefined;
|
|
83
128
|
}
|
|
84
129
|
type SuspenseContextType = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
130
|
+
resources: Map<
|
|
131
|
+
string,
|
|
132
|
+
{
|
|
133
|
+
loading: boolean;
|
|
134
|
+
error: any;
|
|
135
|
+
}
|
|
136
|
+
>;
|
|
137
|
+
completed: () => void;
|
|
90
138
|
};
|
|
91
139
|
export type ResourceActions<T> = {
|
|
92
|
-
|
|
93
|
-
|
|
140
|
+
mutate: Setter<T>;
|
|
141
|
+
refetch: (info?: unknown) => void;
|
|
94
142
|
};
|
|
95
143
|
export type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
|
|
96
144
|
export type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
|
|
97
145
|
export type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
|
|
98
146
|
export type ResourceFetcherInfo<T> = {
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
export type ResourceOptions<T> = undefined extends T ? {
|
|
103
|
-
initialValue?: T;
|
|
104
|
-
name?: string;
|
|
105
|
-
deferStream?: boolean;
|
|
106
|
-
ssrLoadFrom?: "initial" | "server";
|
|
107
|
-
storage?: () => Signal<T | undefined>;
|
|
108
|
-
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
109
|
-
} : {
|
|
110
|
-
initialValue: T;
|
|
111
|
-
name?: string;
|
|
112
|
-
deferStream?: boolean;
|
|
113
|
-
ssrLoadFrom?: "initial" | "server";
|
|
114
|
-
storage?: (v?: T) => Signal<T | undefined>;
|
|
115
|
-
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
147
|
+
value: T | undefined;
|
|
148
|
+
refetching?: unknown;
|
|
116
149
|
};
|
|
117
|
-
export
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
150
|
+
export type ResourceOptions<T> = undefined extends T
|
|
151
|
+
? {
|
|
152
|
+
initialValue?: T;
|
|
153
|
+
name?: string;
|
|
154
|
+
deferStream?: boolean;
|
|
155
|
+
ssrLoadFrom?: "initial" | "server";
|
|
156
|
+
storage?: () => Signal<T | undefined>;
|
|
157
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
158
|
+
}
|
|
159
|
+
: {
|
|
160
|
+
initialValue: T;
|
|
161
|
+
name?: string;
|
|
162
|
+
deferStream?: boolean;
|
|
163
|
+
ssrLoadFrom?: "initial" | "server";
|
|
164
|
+
storage?: (v?: T) => Signal<T | undefined>;
|
|
165
|
+
onHydrated?: <S, T>(k: S, info: ResourceFetcherInfo<T>) => void;
|
|
166
|
+
};
|
|
167
|
+
export declare function createResource<T, S = true>(
|
|
168
|
+
fetcher: ResourceFetcher<S, T>,
|
|
169
|
+
options?: ResourceOptions<undefined>
|
|
170
|
+
): ResourceReturn<T | undefined>;
|
|
171
|
+
export declare function createResource<T, S = true>(
|
|
172
|
+
fetcher: ResourceFetcher<S, T>,
|
|
173
|
+
options: ResourceOptions<T>
|
|
174
|
+
): ResourceReturn<T>;
|
|
175
|
+
export declare function createResource<T, S>(
|
|
176
|
+
source: ResourceSource<S>,
|
|
177
|
+
fetcher: ResourceFetcher<S, T>,
|
|
178
|
+
options?: ResourceOptions<undefined>
|
|
179
|
+
): ResourceReturn<T | undefined>;
|
|
180
|
+
export declare function createResource<T, S>(
|
|
181
|
+
source: ResourceSource<S>,
|
|
182
|
+
fetcher: ResourceFetcher<S, T>,
|
|
183
|
+
options: ResourceOptions<T>
|
|
184
|
+
): ResourceReturn<T>;
|
|
185
|
+
export declare function lazy<T extends Component<any>>(
|
|
186
|
+
fn: () => Promise<{
|
|
187
|
+
default: T;
|
|
188
|
+
}>
|
|
189
|
+
): T & {
|
|
190
|
+
preload: () => Promise<{
|
|
122
191
|
default: T;
|
|
123
|
-
}
|
|
124
|
-
preload: () => Promise<{
|
|
125
|
-
default: T;
|
|
126
|
-
}>;
|
|
192
|
+
}>;
|
|
127
193
|
};
|
|
128
194
|
export declare function enableScheduling(): void;
|
|
129
195
|
export declare function enableHydration(): void;
|
|
130
196
|
export declare function startTransition(fn: () => any): void;
|
|
131
197
|
export declare function useTransition(): [() => boolean, (fn: () => any) => void];
|
|
132
198
|
type HydrationContext = {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
199
|
+
id: string;
|
|
200
|
+
count: number;
|
|
201
|
+
serialize: (id: string, v: Promise<any> | any, deferStream?: boolean) => void;
|
|
202
|
+
nextRoot: (v: any) => string;
|
|
203
|
+
replace: (id: string, replacement: () => any) => void;
|
|
204
|
+
block: (p: Promise<any>) => void;
|
|
205
|
+
resources: Record<string, any>;
|
|
206
|
+
suspense: Record<string, SuspenseContextType>;
|
|
207
|
+
registerFragment: (v: string) => (v?: string, err?: any) => boolean;
|
|
208
|
+
lazy: Record<string, Promise<any>>;
|
|
209
|
+
async?: boolean;
|
|
210
|
+
noHydrate: boolean;
|
|
145
211
|
};
|
|
146
212
|
export declare function SuspenseList(props: {
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
213
|
+
children: string;
|
|
214
|
+
revealOrder: "forwards" | "backwards" | "together";
|
|
215
|
+
tail?: "collapsed" | "hidden";
|
|
150
216
|
}): string;
|
|
151
|
-
export declare function Suspense(props: {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
217
|
+
export declare function Suspense(props: { fallback?: string; children: string }):
|
|
218
|
+
| string
|
|
219
|
+
| number
|
|
220
|
+
| boolean
|
|
221
|
+
| Node
|
|
222
|
+
| JSX.ArrayElement
|
|
223
|
+
| {
|
|
224
|
+
t: string;
|
|
225
|
+
}
|
|
226
|
+
| null
|
|
227
|
+
| undefined;
|
|
157
228
|
export {};
|
package/universal/dist/dev.js
CHANGED
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createRoot,
|
|
3
|
+
createRenderEffect,
|
|
4
|
+
mergeProps,
|
|
5
|
+
createMemo,
|
|
6
|
+
createComponent,
|
|
7
|
+
untrack
|
|
8
|
+
} from "solid-js";
|
|
2
9
|
|
|
3
10
|
function createRenderer$1({
|
|
4
11
|
createElement,
|
|
@@ -32,7 +39,7 @@ function createRenderer$1({
|
|
|
32
39
|
current = cleanChildren(parent, current, marker, node);
|
|
33
40
|
} else {
|
|
34
41
|
if (current !== "" && typeof current === "string") {
|
|
35
|
-
replaceText(getFirstChild(parent), current = value);
|
|
42
|
+
replaceText(getFirstChild(parent), (current = value));
|
|
36
43
|
} else {
|
|
37
44
|
cleanChildren(parent, current, marker, createTextNode(value));
|
|
38
45
|
current = value;
|
|
@@ -50,12 +57,14 @@ function createRenderer$1({
|
|
|
50
57
|
} else if (Array.isArray(value)) {
|
|
51
58
|
const array = [];
|
|
52
59
|
if (normalizeIncomingArray(array, value, unwrapArray)) {
|
|
53
|
-
createRenderEffect(
|
|
60
|
+
createRenderEffect(
|
|
61
|
+
() => (current = insertExpression(parent, array, current, marker, true))
|
|
62
|
+
);
|
|
54
63
|
return () => current;
|
|
55
64
|
}
|
|
56
65
|
if (array.length === 0) {
|
|
57
66
|
const replacement = cleanChildren(parent, current, marker);
|
|
58
|
-
if (multi) return current = replacement;
|
|
67
|
+
if (multi) return (current = replacement);
|
|
59
68
|
} else {
|
|
60
69
|
if (Array.isArray(current)) {
|
|
61
70
|
if (current.length === 0) {
|
|
@@ -64,13 +73,13 @@ function createRenderer$1({
|
|
|
64
73
|
} else if (current == null || current === "") {
|
|
65
74
|
appendNodes(parent, array);
|
|
66
75
|
} else {
|
|
67
|
-
reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
|
|
76
|
+
reconcileArrays(parent, (multi && current) || [getFirstChild(parent)], array);
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
current = array;
|
|
71
80
|
} else {
|
|
72
81
|
if (Array.isArray(current)) {
|
|
73
|
-
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
82
|
+
if (multi) return (current = cleanChildren(parent, current, marker, value));
|
|
74
83
|
cleanChildren(parent, current, null, value);
|
|
75
84
|
} else if (current == null || current === "" || !getFirstChild(parent)) {
|
|
76
85
|
insertNode(parent, value);
|
|
@@ -84,14 +93,16 @@ function createRenderer$1({
|
|
|
84
93
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
85
94
|
let item = array[i],
|
|
86
95
|
t;
|
|
87
|
-
if (item == null || item === true || item === false)
|
|
96
|
+
if (item == null || item === true || item === false);
|
|
97
|
+
else if (Array.isArray(item)) {
|
|
88
98
|
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
|
|
89
99
|
} else if ((t = typeof item) === "string" || t === "number") {
|
|
90
100
|
normalized.push(createTextNode(item));
|
|
91
101
|
} else if (t === "function") {
|
|
92
102
|
if (unwrap) {
|
|
93
103
|
while (typeof item === "function") item = item();
|
|
94
|
-
dynamic =
|
|
104
|
+
dynamic =
|
|
105
|
+
normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
95
106
|
} else {
|
|
96
107
|
normalized.push(item);
|
|
97
108
|
dynamic = true;
|
|
@@ -119,7 +130,8 @@ function createRenderer$1({
|
|
|
119
130
|
bEnd--;
|
|
120
131
|
}
|
|
121
132
|
if (aEnd === aStart) {
|
|
122
|
-
const node =
|
|
133
|
+
const node =
|
|
134
|
+
bEnd < bLength ? (bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart]) : after;
|
|
123
135
|
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
|
|
124
136
|
} else if (bEnd === bStart) {
|
|
125
137
|
while (aStart < aEnd) {
|
|
@@ -159,7 +171,7 @@ function createRenderer$1({
|
|
|
159
171
|
function cleanChildren(parent, current, marker, replacement) {
|
|
160
172
|
if (marker === undefined) {
|
|
161
173
|
let removed;
|
|
162
|
-
while (removed = getFirstChild(parent)) removeNode(parent, removed);
|
|
174
|
+
while ((removed = getFirstChild(parent))) removeNode(parent, removed);
|
|
163
175
|
replacement && insertNode(parent, replacement);
|
|
164
176
|
return "";
|
|
165
177
|
}
|
|
@@ -170,7 +182,9 @@ function createRenderer$1({
|
|
|
170
182
|
const el = current[i];
|
|
171
183
|
if (node !== el) {
|
|
172
184
|
const isParent = getParentNode(el) === parent;
|
|
173
|
-
if (!inserted && !i)
|
|
185
|
+
if (!inserted && !i)
|
|
186
|
+
isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);
|
|
187
|
+
else isParent && removeNode(parent, el);
|
|
174
188
|
} else inserted = true;
|
|
175
189
|
}
|
|
176
190
|
} else insertNode(parent, node, marker);
|
|
@@ -186,7 +200,9 @@ function createRenderer$1({
|
|
|
186
200
|
function spreadExpression(node, props, prevProps = {}, skipChildren) {
|
|
187
201
|
props || (props = {});
|
|
188
202
|
if (!skipChildren) {
|
|
189
|
-
createRenderEffect(
|
|
203
|
+
createRenderEffect(
|
|
204
|
+
() => (prevProps.children = insertExpression(node, props.children, prevProps.children))
|
|
205
|
+
);
|
|
190
206
|
}
|
|
191
207
|
createRenderEffect(() => props.ref && props.ref(node));
|
|
192
208
|
createRenderEffect(() => {
|
|
@@ -1,4 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
createRoot,
|
|
3
|
+
createRenderEffect,
|
|
4
|
+
mergeProps,
|
|
5
|
+
createMemo,
|
|
6
|
+
createComponent,
|
|
7
|
+
untrack
|
|
8
|
+
} from "solid-js";
|
|
2
9
|
|
|
3
10
|
function createRenderer$1({
|
|
4
11
|
createElement,
|
|
@@ -32,7 +39,7 @@ function createRenderer$1({
|
|
|
32
39
|
current = cleanChildren(parent, current, marker, node);
|
|
33
40
|
} else {
|
|
34
41
|
if (current !== "" && typeof current === "string") {
|
|
35
|
-
replaceText(getFirstChild(parent), current = value);
|
|
42
|
+
replaceText(getFirstChild(parent), (current = value));
|
|
36
43
|
} else {
|
|
37
44
|
cleanChildren(parent, current, marker, createTextNode(value));
|
|
38
45
|
current = value;
|
|
@@ -50,12 +57,14 @@ function createRenderer$1({
|
|
|
50
57
|
} else if (Array.isArray(value)) {
|
|
51
58
|
const array = [];
|
|
52
59
|
if (normalizeIncomingArray(array, value, unwrapArray)) {
|
|
53
|
-
createRenderEffect(
|
|
60
|
+
createRenderEffect(
|
|
61
|
+
() => (current = insertExpression(parent, array, current, marker, true))
|
|
62
|
+
);
|
|
54
63
|
return () => current;
|
|
55
64
|
}
|
|
56
65
|
if (array.length === 0) {
|
|
57
66
|
const replacement = cleanChildren(parent, current, marker);
|
|
58
|
-
if (multi) return current = replacement;
|
|
67
|
+
if (multi) return (current = replacement);
|
|
59
68
|
} else {
|
|
60
69
|
if (Array.isArray(current)) {
|
|
61
70
|
if (current.length === 0) {
|
|
@@ -64,13 +73,13 @@ function createRenderer$1({
|
|
|
64
73
|
} else if (current == null || current === "") {
|
|
65
74
|
appendNodes(parent, array);
|
|
66
75
|
} else {
|
|
67
|
-
reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
|
|
76
|
+
reconcileArrays(parent, (multi && current) || [getFirstChild(parent)], array);
|
|
68
77
|
}
|
|
69
78
|
}
|
|
70
79
|
current = array;
|
|
71
80
|
} else {
|
|
72
81
|
if (Array.isArray(current)) {
|
|
73
|
-
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
82
|
+
if (multi) return (current = cleanChildren(parent, current, marker, value));
|
|
74
83
|
cleanChildren(parent, current, null, value);
|
|
75
84
|
} else if (current == null || current === "" || !getFirstChild(parent)) {
|
|
76
85
|
insertNode(parent, value);
|
|
@@ -84,14 +93,16 @@ function createRenderer$1({
|
|
|
84
93
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
85
94
|
let item = array[i],
|
|
86
95
|
t;
|
|
87
|
-
if (item == null || item === true || item === false)
|
|
96
|
+
if (item == null || item === true || item === false);
|
|
97
|
+
else if (Array.isArray(item)) {
|
|
88
98
|
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
|
|
89
99
|
} else if ((t = typeof item) === "string" || t === "number") {
|
|
90
100
|
normalized.push(createTextNode(item));
|
|
91
101
|
} else if (t === "function") {
|
|
92
102
|
if (unwrap) {
|
|
93
103
|
while (typeof item === "function") item = item();
|
|
94
|
-
dynamic =
|
|
104
|
+
dynamic =
|
|
105
|
+
normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
95
106
|
} else {
|
|
96
107
|
normalized.push(item);
|
|
97
108
|
dynamic = true;
|
|
@@ -119,7 +130,8 @@ function createRenderer$1({
|
|
|
119
130
|
bEnd--;
|
|
120
131
|
}
|
|
121
132
|
if (aEnd === aStart) {
|
|
122
|
-
const node =
|
|
133
|
+
const node =
|
|
134
|
+
bEnd < bLength ? (bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart]) : after;
|
|
123
135
|
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
|
|
124
136
|
} else if (bEnd === bStart) {
|
|
125
137
|
while (aStart < aEnd) {
|
|
@@ -159,7 +171,7 @@ function createRenderer$1({
|
|
|
159
171
|
function cleanChildren(parent, current, marker, replacement) {
|
|
160
172
|
if (marker === undefined) {
|
|
161
173
|
let removed;
|
|
162
|
-
while (removed = getFirstChild(parent)) removeNode(parent, removed);
|
|
174
|
+
while ((removed = getFirstChild(parent))) removeNode(parent, removed);
|
|
163
175
|
replacement && insertNode(parent, replacement);
|
|
164
176
|
return "";
|
|
165
177
|
}
|
|
@@ -170,7 +182,9 @@ function createRenderer$1({
|
|
|
170
182
|
const el = current[i];
|
|
171
183
|
if (node !== el) {
|
|
172
184
|
const isParent = getParentNode(el) === parent;
|
|
173
|
-
if (!inserted && !i)
|
|
185
|
+
if (!inserted && !i)
|
|
186
|
+
isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);
|
|
187
|
+
else isParent && removeNode(parent, el);
|
|
174
188
|
} else inserted = true;
|
|
175
189
|
}
|
|
176
190
|
} else insertNode(parent, node, marker);
|
|
@@ -186,7 +200,9 @@ function createRenderer$1({
|
|
|
186
200
|
function spreadExpression(node, props, prevProps = {}, skipChildren) {
|
|
187
201
|
props || (props = {});
|
|
188
202
|
if (!skipChildren) {
|
|
189
|
-
createRenderEffect(
|
|
203
|
+
createRenderEffect(
|
|
204
|
+
() => (prevProps.children = insertExpression(node, props.children, prevProps.children))
|
|
205
|
+
);
|
|
190
206
|
}
|
|
191
207
|
createRenderEffect(() => props.ref && props.ref(node));
|
|
192
208
|
createRenderEffect(() => {
|
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
import type { RendererOptions, Renderer } from "./universal.js";
|
|
2
|
-
export declare function createRenderer<NodeType>(
|
|
2
|
+
export declare function createRenderer<NodeType>(
|
|
3
|
+
options: RendererOptions<NodeType>
|
|
4
|
+
): Renderer<NodeType>;
|
package/web/dist/dev.cjs
CHANGED
|
@@ -151,18 +151,19 @@ function clearDelegatedEvents(document = window.document) {
|
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
153
|
function setProperty(node, name, value) {
|
|
154
|
-
|
|
154
|
+
if (!!solidJs.sharedConfig.context && node.isConnected) return;
|
|
155
|
+
node[name] = value;
|
|
155
156
|
}
|
|
156
157
|
function setAttribute(node, name, value) {
|
|
157
|
-
if (solidJs.sharedConfig.context) return;
|
|
158
|
+
if (!!solidJs.sharedConfig.context && node.isConnected) return;
|
|
158
159
|
if (value == null) node.removeAttribute(name);else node.setAttribute(name, value);
|
|
159
160
|
}
|
|
160
161
|
function setAttributeNS(node, namespace, name, value) {
|
|
161
|
-
if (solidJs.sharedConfig.context) return;
|
|
162
|
+
if (!!solidJs.sharedConfig.context && node.isConnected) return;
|
|
162
163
|
if (value == null) node.removeAttributeNS(namespace, name);else node.setAttributeNS(namespace, name, value);
|
|
163
164
|
}
|
|
164
165
|
function className(node, value) {
|
|
165
|
-
if (solidJs.sharedConfig.context) return;
|
|
166
|
+
if (!!solidJs.sharedConfig.context && node.isConnected) return;
|
|
166
167
|
if (value == null) node.removeAttribute("class");else node.className = value;
|
|
167
168
|
}
|
|
168
169
|
function addEventListener(node, name, handler, delegate) {
|
|
@@ -366,7 +367,7 @@ function assignProp(node, prop, value, prev, isSVG, skipRef) {
|
|
|
366
367
|
if (forceProp) {
|
|
367
368
|
prop = prop.slice(5);
|
|
368
369
|
isProp = true;
|
|
369
|
-
} else if (solidJs.sharedConfig.context) return value;
|
|
370
|
+
} else if (!!solidJs.sharedConfig.context && node.isConnected) return value;
|
|
370
371
|
if (prop === "class" || prop === "className") className(node, value);else if (isCE && !isProp && !isChildProp) node[toPropertyName(prop)] = value;else node[propAlias || prop] = value;
|
|
371
372
|
} else {
|
|
372
373
|
const ns = isSVG && prop.indexOf(":") > -1 && SVGNamespace[prop.split(":")[0]];
|
|
@@ -401,7 +402,8 @@ function eventHandler(e) {
|
|
|
401
402
|
}
|
|
402
403
|
}
|
|
403
404
|
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
404
|
-
|
|
405
|
+
const hydrating = !!solidJs.sharedConfig.context && parent.isConnected;
|
|
406
|
+
if (hydrating) {
|
|
405
407
|
!current && (current = [...parent.childNodes]);
|
|
406
408
|
let cleaned = [];
|
|
407
409
|
for (let i = 0; i < current.length; i++) {
|
|
@@ -416,7 +418,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
416
418
|
multi = marker !== undefined;
|
|
417
419
|
parent = multi && current[0] && current[0].parentNode || parent;
|
|
418
420
|
if (t === "string" || t === "number") {
|
|
419
|
-
if (
|
|
421
|
+
if (hydrating) return current;
|
|
420
422
|
if (t === "number") value = value.toString();
|
|
421
423
|
if (multi) {
|
|
422
424
|
let node = current[0];
|
|
@@ -430,7 +432,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
430
432
|
} else current = parent.textContent = value;
|
|
431
433
|
}
|
|
432
434
|
} else if (value == null || t === "boolean") {
|
|
433
|
-
if (
|
|
435
|
+
if (hydrating) return current;
|
|
434
436
|
current = cleanChildren(parent, current, marker);
|
|
435
437
|
} else if (t === "function") {
|
|
436
438
|
solidJs.createRenderEffect(() => {
|
|
@@ -446,7 +448,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
446
448
|
solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
447
449
|
return () => current;
|
|
448
450
|
}
|
|
449
|
-
if (
|
|
451
|
+
if (hydrating) {
|
|
450
452
|
if (!array.length) return current;
|
|
451
453
|
if (marker === undefined) return [...parent.childNodes];
|
|
452
454
|
let node = array[0];
|
|
@@ -467,7 +469,7 @@ function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
|
467
469
|
}
|
|
468
470
|
current = array;
|
|
469
471
|
} else if (value.nodeType) {
|
|
470
|
-
if (
|
|
472
|
+
if (hydrating && value.parentNode) return current = multi ? [value] : value;
|
|
471
473
|
if (Array.isArray(current)) {
|
|
472
474
|
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
473
475
|
cleanChildren(parent, current, null, value);
|
|
@@ -482,7 +484,7 @@ function normalizeIncomingArray(normalized, array, current, unwrap) {
|
|
|
482
484
|
let dynamic = false;
|
|
483
485
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
484
486
|
let item = array[i],
|
|
485
|
-
prev = current && current[
|
|
487
|
+
prev = current && current[normalized.length],
|
|
486
488
|
t;
|
|
487
489
|
if (item == null || item === true || item === false) ; else if ((t = typeof item) === "object" && item.nodeType) {
|
|
488
490
|
normalized.push(item);
|