solid-js 1.8.2 → 1.8.4
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 +1 -1
- package/dist/dev.js +534 -299
- package/dist/server.js +170 -75
- package/dist/solid.cjs +1 -1
- package/dist/solid.js +461 -257
- 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/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +216 -94
- package/html/types/lit.d.ts +47 -31
- package/package.json +7 -3
- package/store/dist/dev.js +114 -42
- package/store/dist/server.js +19 -8
- package/store/dist/store.js +105 -39
- 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 +218 -61
- package/types/index.d.ts +72 -9
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +228 -140
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- 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 +166 -95
- 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 +3 -0
- package/web/dist/dev.js +620 -81
- package/web/dist/server.cjs +17 -5
- package/web/dist/server.js +188 -95
- package/web/dist/storage.cjs +12 -0
- package/web/dist/storage.js +10 -0
- package/web/dist/web.cjs +3 -0
- package/web/dist/web.js +614 -80
- package/web/types/client.d.ts +8 -3
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +10 -1
- package/web/types/storage.d.ts +2 -0
|
@@ -2,155 +2,226 @@ 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
|
-
|
|
199
|
+
id: string;
|
|
200
|
+
count: number;
|
|
201
|
+
serialize: (id: string, v: Promise<any> | any, deferStream?: boolean) => void;
|
|
202
|
+
replace: (id: string, replacement: () => any) => void;
|
|
203
|
+
block: (p: Promise<any>) => void;
|
|
204
|
+
resources: Record<string, any>;
|
|
205
|
+
suspense: Record<string, SuspenseContextType>;
|
|
206
|
+
registerFragment: (v: string) => (v?: string, err?: any) => boolean;
|
|
207
|
+
lazy: Record<string, Promise<any>>;
|
|
208
|
+
async?: boolean;
|
|
209
|
+
noHydrate: boolean;
|
|
144
210
|
};
|
|
145
211
|
export declare function SuspenseList(props: {
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
212
|
+
children: string;
|
|
213
|
+
revealOrder: "forwards" | "backwards" | "together";
|
|
214
|
+
tail?: "collapsed" | "hidden";
|
|
149
215
|
}): string;
|
|
150
|
-
export declare function Suspense(props: {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
216
|
+
export declare function Suspense(props: { fallback?: string; children: string }):
|
|
217
|
+
| string
|
|
218
|
+
| number
|
|
219
|
+
| boolean
|
|
220
|
+
| Node
|
|
221
|
+
| JSX.ArrayElement
|
|
222
|
+
| {
|
|
223
|
+
t: string;
|
|
224
|
+
}
|
|
225
|
+
| null
|
|
226
|
+
| undefined;
|
|
156
227
|
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
|
@@ -537,6 +537,7 @@ function Hydration(props) {
|
|
|
537
537
|
return props.children;
|
|
538
538
|
}
|
|
539
539
|
function voidFn() {}
|
|
540
|
+
const RequestContext = Symbol();
|
|
540
541
|
function innerHTML(parent, content) {
|
|
541
542
|
!solidJs.sharedConfig.context && (parent.innerHTML = content);
|
|
542
543
|
}
|
|
@@ -700,6 +701,7 @@ exports.HydrationScript = voidFn;
|
|
|
700
701
|
exports.NoHydration = NoHydration;
|
|
701
702
|
exports.Portal = Portal;
|
|
702
703
|
exports.Properties = Properties;
|
|
704
|
+
exports.RequestContext = RequestContext;
|
|
703
705
|
exports.SVGElements = SVGElements;
|
|
704
706
|
exports.SVGNamespace = SVGNamespace;
|
|
705
707
|
exports.addEventListener = addEventListener;
|
|
@@ -717,6 +719,7 @@ exports.getNextElement = getNextElement;
|
|
|
717
719
|
exports.getNextMarker = getNextMarker;
|
|
718
720
|
exports.getNextMatch = getNextMatch;
|
|
719
721
|
exports.getPropAlias = getPropAlias;
|
|
722
|
+
exports.getRequestEvent = voidFn;
|
|
720
723
|
exports.hydrate = hydrate;
|
|
721
724
|
exports.innerHTML = innerHTML;
|
|
722
725
|
exports.insert = insert;
|