solid-js 1.8.7 → 1.8.8
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 +30 -20
- package/dist/dev.js +327 -552
- package/dist/server.js +75 -170
- package/dist/solid.cjs +30 -20
- package/dist/solid.js +285 -479
- package/h/dist/h.js +8 -34
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +8 -11
- package/h/jsx-runtime/types/jsx.d.ts +15 -1
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -216
- package/html/types/lit.d.ts +33 -47
- package/package.json +2 -2
- package/store/dist/dev.cjs +3 -2
- package/store/dist/dev.js +44 -115
- package/store/dist/server.js +8 -19
- package/store/dist/store.cjs +3 -2
- package/store/dist/store.js +41 -106
- package/store/types/index.d.ts +7 -21
- package/store/types/modifiers.d.ts +3 -6
- package/store/types/mutable.d.ts +2 -5
- package/store/types/server.d.ts +4 -12
- package/store/types/store.d.ts +61 -218
- package/types/index.d.ts +10 -75
- package/types/jsx.d.ts +15 -1
- package/types/reactive/array.d.ts +4 -12
- package/types/reactive/observable.d.ts +17 -25
- package/types/reactive/scheduler.d.ts +6 -9
- package/types/reactive/signal.d.ts +142 -231
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +33 -62
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +2 -57
- package/types/server/reactive.d.ts +42 -73
- package/types/server/rendering.d.ts +96 -167
- package/universal/dist/dev.js +12 -28
- package/universal/dist/universal.js +12 -28
- package/universal/types/index.d.ts +1 -3
- package/universal/types/universal.d.ts +1 -0
- package/web/dist/dev.js +81 -620
- package/web/dist/server.cjs +7 -2
- package/web/dist/server.js +102 -179
- package/web/dist/storage.js +3 -3
- package/web/dist/web.js +80 -614
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +1 -10
- package/web/types/index.d.ts +10 -27
- package/web/types/server-mock.d.ts +32 -47
|
@@ -2,227 +2,156 @@ 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>
|
|
19
|
-
? P
|
|
20
|
-
: T extends keyof JSX.IntrinsicElements
|
|
21
|
-
? JSX.IntrinsicElements[T]
|
|
22
|
-
: Record<string, unknown>;
|
|
18
|
+
export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
|
|
23
19
|
type SharedConfig = {
|
|
24
|
-
|
|
20
|
+
context?: HydrationContext;
|
|
25
21
|
};
|
|
26
22
|
export declare const sharedConfig: SharedConfig;
|
|
27
23
|
export declare function createUniqueId(): string;
|
|
28
24
|
export declare function createComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
|
|
29
25
|
export declare function mergeProps<T, U>(source: T, source1: U): T & U;
|
|
30
26
|
export declare function mergeProps<T, U, V>(source: T, source1: U, source2: V): T & U & V;
|
|
31
|
-
export declare function mergeProps<T, U, V, W>(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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>
|
|
27
|
+
export declare function mergeProps<T, U, V, W>(source: T, source1: U, source2: V, source3: W): T & U & V & W;
|
|
28
|
+
export declare function splitProps<T extends object, K1 extends keyof T>(props: T, ...keys: [K1[]]): [Pick<T, K1>, Omit<T, K1>];
|
|
29
|
+
export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T>(props: T, ...keys: [K1[], K2[]]): [Pick<T, K1>, Pick<T, K2>, Omit<T, K1 | K2>];
|
|
30
|
+
export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T>(props: T, ...keys: [K1[], K2[], K3[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Omit<T, K1 | K2 | K3>];
|
|
31
|
+
export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T>(props: T, ...keys: [K1[], K2[], K3[], K4[]]): [Pick<T, K1>, Pick<T, K2>, Pick<T, K3>, Pick<T, K4>, Omit<T, K1 | K2 | K3 | K4>];
|
|
32
|
+
export declare function splitProps<T extends object, K1 extends keyof T, K2 extends keyof T, K3 extends keyof T, K4 extends keyof T, K5 extends keyof T>(props: T, ...keys: [K1[], K2[], K3[], K4[], K5[]]): [
|
|
33
|
+
Pick<T, K1>,
|
|
34
|
+
Pick<T, K2>,
|
|
35
|
+
Pick<T, K3>,
|
|
36
|
+
Pick<T, K4>,
|
|
37
|
+
Pick<T, K5>,
|
|
38
|
+
Omit<T, K1 | K2 | K3 | K4 | K5>
|
|
81
39
|
];
|
|
82
40
|
export declare function For<T>(props: {
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
41
|
+
each: T[];
|
|
42
|
+
fallback?: string;
|
|
43
|
+
children: (item: T, index: () => number) => string;
|
|
86
44
|
}): string | any[] | undefined;
|
|
87
45
|
export declare function Index<T>(props: {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
46
|
+
each: T[];
|
|
47
|
+
fallback?: string;
|
|
48
|
+
children: (item: () => T, index: number) => string;
|
|
91
49
|
}): string | any[] | undefined;
|
|
92
50
|
/**
|
|
93
51
|
* Conditionally render its children or an optional fallback component
|
|
94
52
|
* @description https://www.solidjs.com/docs/latest/api#show
|
|
95
53
|
*/
|
|
96
54
|
export declare function Show<T>(props: {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
55
|
+
when: T | undefined | null | false;
|
|
56
|
+
keyed?: boolean;
|
|
57
|
+
fallback?: string;
|
|
58
|
+
children: string | ((item: NonNullable<T> | Accessor<NonNullable<T>>) => string);
|
|
101
59
|
}): string;
|
|
102
60
|
export declare function Switch(props: {
|
|
103
|
-
|
|
104
|
-
|
|
61
|
+
fallback?: string;
|
|
62
|
+
children: MatchProps<unknown> | MatchProps<unknown>[];
|
|
105
63
|
}): string;
|
|
106
64
|
type MatchProps<T> = {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
65
|
+
when: T | false;
|
|
66
|
+
keyed?: boolean;
|
|
67
|
+
children: string | ((item: NonNullable<T> | Accessor<NonNullable<T>>) => string);
|
|
110
68
|
};
|
|
111
69
|
export declare function Match<T>(props: MatchProps<T>): MatchProps<T>;
|
|
112
70
|
export declare function resetErrorBoundaries(): void;
|
|
113
71
|
export declare function ErrorBoundary(props: {
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}):
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
| {
|
|
120
|
-
t: string;
|
|
121
|
-
};
|
|
72
|
+
fallback: string | ((err: any, reset: () => void) => string);
|
|
73
|
+
children: string;
|
|
74
|
+
}): string | ((err: any, reset: () => void) => string) | {
|
|
75
|
+
t: string;
|
|
76
|
+
};
|
|
122
77
|
export interface Resource<T> {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
78
|
+
(): T | undefined;
|
|
79
|
+
state: "unresolved" | "pending" | "ready" | "refreshing" | "errored";
|
|
80
|
+
loading: boolean;
|
|
81
|
+
error: any;
|
|
82
|
+
latest: T | undefined;
|
|
128
83
|
}
|
|
129
84
|
type SuspenseContextType = {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
}
|
|
136
|
-
>;
|
|
137
|
-
completed: () => void;
|
|
85
|
+
resources: Map<string, {
|
|
86
|
+
loading: boolean;
|
|
87
|
+
error: any;
|
|
88
|
+
}>;
|
|
89
|
+
completed: () => void;
|
|
138
90
|
};
|
|
139
91
|
export type ResourceActions<T> = {
|
|
140
|
-
|
|
141
|
-
|
|
92
|
+
mutate: Setter<T>;
|
|
93
|
+
refetch: (info?: unknown) => void;
|
|
142
94
|
};
|
|
143
95
|
export type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
|
|
144
96
|
export type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
|
|
145
97
|
export type ResourceFetcher<S, T> = (k: S, info: ResourceFetcherInfo<T>) => T | Promise<T>;
|
|
146
98
|
export type ResourceFetcherInfo<T> = {
|
|
147
|
-
|
|
148
|
-
|
|
99
|
+
value: T | undefined;
|
|
100
|
+
refetching?: unknown;
|
|
149
101
|
};
|
|
150
|
-
export type ResourceOptions<T> = undefined extends T
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
export declare function createResource<T, S
|
|
168
|
-
|
|
169
|
-
|
|
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<{
|
|
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;
|
|
116
|
+
};
|
|
117
|
+
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
118
|
+
export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
119
|
+
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): ResourceReturn<T | undefined>;
|
|
120
|
+
export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): ResourceReturn<T>;
|
|
121
|
+
export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
191
122
|
default: T;
|
|
192
|
-
|
|
123
|
+
}>): T & {
|
|
124
|
+
preload: () => Promise<{
|
|
125
|
+
default: T;
|
|
126
|
+
}>;
|
|
193
127
|
};
|
|
194
128
|
export declare function enableScheduling(): void;
|
|
195
129
|
export declare function enableHydration(): void;
|
|
196
130
|
export declare function startTransition(fn: () => any): void;
|
|
197
131
|
export declare function useTransition(): [() => boolean, (fn: () => any) => void];
|
|
198
132
|
type HydrationContext = {
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
133
|
+
id: string;
|
|
134
|
+
count: number;
|
|
135
|
+
serialize: (id: string, v: Promise<any> | any, deferStream?: boolean) => void;
|
|
136
|
+
nextRoot: (v: any) => string;
|
|
137
|
+
replace: (id: string, replacement: () => any) => void;
|
|
138
|
+
block: (p: Promise<any>) => void;
|
|
139
|
+
resources: Record<string, any>;
|
|
140
|
+
suspense: Record<string, SuspenseContextType>;
|
|
141
|
+
registerFragment: (v: string) => (v?: string, err?: any) => boolean;
|
|
142
|
+
lazy: Record<string, Promise<any>>;
|
|
143
|
+
async?: boolean;
|
|
144
|
+
noHydrate: boolean;
|
|
211
145
|
};
|
|
212
146
|
export declare function SuspenseList(props: {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
147
|
+
children: string;
|
|
148
|
+
revealOrder: "forwards" | "backwards" | "together";
|
|
149
|
+
tail?: "collapsed" | "hidden";
|
|
216
150
|
}): string;
|
|
217
|
-
export declare function Suspense(props: {
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
| {
|
|
224
|
-
t: string;
|
|
225
|
-
}
|
|
226
|
-
| null
|
|
227
|
-
| undefined;
|
|
151
|
+
export declare function Suspense(props: {
|
|
152
|
+
fallback?: string;
|
|
153
|
+
children: string;
|
|
154
|
+
}): string | number | boolean | Node | JSX.ArrayElement | {
|
|
155
|
+
t: string;
|
|
156
|
+
} | null | undefined;
|
|
228
157
|
export {};
|
package/universal/dist/dev.js
CHANGED
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRoot,
|
|
3
|
-
createRenderEffect,
|
|
4
|
-
mergeProps,
|
|
5
|
-
createMemo,
|
|
6
|
-
createComponent,
|
|
7
|
-
untrack
|
|
8
|
-
} from "solid-js";
|
|
1
|
+
import { createRoot, createRenderEffect, mergeProps, createMemo, createComponent, untrack } from 'solid-js';
|
|
9
2
|
|
|
10
3
|
function createRenderer$1({
|
|
11
4
|
createElement,
|
|
@@ -39,7 +32,7 @@ function createRenderer$1({
|
|
|
39
32
|
current = cleanChildren(parent, current, marker, node);
|
|
40
33
|
} else {
|
|
41
34
|
if (current !== "" && typeof current === "string") {
|
|
42
|
-
replaceText(getFirstChild(parent),
|
|
35
|
+
replaceText(getFirstChild(parent), current = value);
|
|
43
36
|
} else {
|
|
44
37
|
cleanChildren(parent, current, marker, createTextNode(value));
|
|
45
38
|
current = value;
|
|
@@ -57,14 +50,12 @@ function createRenderer$1({
|
|
|
57
50
|
} else if (Array.isArray(value)) {
|
|
58
51
|
const array = [];
|
|
59
52
|
if (normalizeIncomingArray(array, value, unwrapArray)) {
|
|
60
|
-
createRenderEffect(
|
|
61
|
-
() => (current = insertExpression(parent, array, current, marker, true))
|
|
62
|
-
);
|
|
53
|
+
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
63
54
|
return () => current;
|
|
64
55
|
}
|
|
65
56
|
if (array.length === 0) {
|
|
66
57
|
const replacement = cleanChildren(parent, current, marker);
|
|
67
|
-
if (multi) return
|
|
58
|
+
if (multi) return current = replacement;
|
|
68
59
|
} else {
|
|
69
60
|
if (Array.isArray(current)) {
|
|
70
61
|
if (current.length === 0) {
|
|
@@ -73,13 +64,13 @@ function createRenderer$1({
|
|
|
73
64
|
} else if (current == null || current === "") {
|
|
74
65
|
appendNodes(parent, array);
|
|
75
66
|
} else {
|
|
76
|
-
reconcileArrays(parent,
|
|
67
|
+
reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
|
|
77
68
|
}
|
|
78
69
|
}
|
|
79
70
|
current = array;
|
|
80
71
|
} else {
|
|
81
72
|
if (Array.isArray(current)) {
|
|
82
|
-
if (multi) return
|
|
73
|
+
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
83
74
|
cleanChildren(parent, current, null, value);
|
|
84
75
|
} else if (current == null || current === "" || !getFirstChild(parent)) {
|
|
85
76
|
insertNode(parent, value);
|
|
@@ -93,16 +84,14 @@ function createRenderer$1({
|
|
|
93
84
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
94
85
|
let item = array[i],
|
|
95
86
|
t;
|
|
96
|
-
if (item == null || item === true || item === false);
|
|
97
|
-
else if (Array.isArray(item)) {
|
|
87
|
+
if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
|
|
98
88
|
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
|
|
99
89
|
} else if ((t = typeof item) === "string" || t === "number") {
|
|
100
90
|
normalized.push(createTextNode(item));
|
|
101
91
|
} else if (t === "function") {
|
|
102
92
|
if (unwrap) {
|
|
103
93
|
while (typeof item === "function") item = item();
|
|
104
|
-
dynamic =
|
|
105
|
-
normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
94
|
+
dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
106
95
|
} else {
|
|
107
96
|
normalized.push(item);
|
|
108
97
|
dynamic = true;
|
|
@@ -130,8 +119,7 @@ function createRenderer$1({
|
|
|
130
119
|
bEnd--;
|
|
131
120
|
}
|
|
132
121
|
if (aEnd === aStart) {
|
|
133
|
-
const node =
|
|
134
|
-
bEnd < bLength ? (bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart]) : after;
|
|
122
|
+
const node = bEnd < bLength ? bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart] : after;
|
|
135
123
|
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
|
|
136
124
|
} else if (bEnd === bStart) {
|
|
137
125
|
while (aStart < aEnd) {
|
|
@@ -171,7 +159,7 @@ function createRenderer$1({
|
|
|
171
159
|
function cleanChildren(parent, current, marker, replacement) {
|
|
172
160
|
if (marker === undefined) {
|
|
173
161
|
let removed;
|
|
174
|
-
while (
|
|
162
|
+
while (removed = getFirstChild(parent)) removeNode(parent, removed);
|
|
175
163
|
replacement && insertNode(parent, replacement);
|
|
176
164
|
return "";
|
|
177
165
|
}
|
|
@@ -182,9 +170,7 @@ function createRenderer$1({
|
|
|
182
170
|
const el = current[i];
|
|
183
171
|
if (node !== el) {
|
|
184
172
|
const isParent = getParentNode(el) === parent;
|
|
185
|
-
if (!inserted && !i)
|
|
186
|
-
isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);
|
|
187
|
-
else isParent && removeNode(parent, el);
|
|
173
|
+
if (!inserted && !i) isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);else isParent && removeNode(parent, el);
|
|
188
174
|
} else inserted = true;
|
|
189
175
|
}
|
|
190
176
|
} else insertNode(parent, node, marker);
|
|
@@ -200,9 +186,7 @@ function createRenderer$1({
|
|
|
200
186
|
function spreadExpression(node, props, prevProps = {}, skipChildren) {
|
|
201
187
|
props || (props = {});
|
|
202
188
|
if (!skipChildren) {
|
|
203
|
-
createRenderEffect(
|
|
204
|
-
() => (prevProps.children = insertExpression(node, props.children, prevProps.children))
|
|
205
|
-
);
|
|
189
|
+
createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
|
|
206
190
|
}
|
|
207
191
|
createRenderEffect(() => props.ref && props.ref(node));
|
|
208
192
|
createRenderEffect(() => {
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRoot,
|
|
3
|
-
createRenderEffect,
|
|
4
|
-
mergeProps,
|
|
5
|
-
createMemo,
|
|
6
|
-
createComponent,
|
|
7
|
-
untrack
|
|
8
|
-
} from "solid-js";
|
|
1
|
+
import { createRoot, createRenderEffect, mergeProps, createMemo, createComponent, untrack } from 'solid-js';
|
|
9
2
|
|
|
10
3
|
function createRenderer$1({
|
|
11
4
|
createElement,
|
|
@@ -39,7 +32,7 @@ function createRenderer$1({
|
|
|
39
32
|
current = cleanChildren(parent, current, marker, node);
|
|
40
33
|
} else {
|
|
41
34
|
if (current !== "" && typeof current === "string") {
|
|
42
|
-
replaceText(getFirstChild(parent),
|
|
35
|
+
replaceText(getFirstChild(parent), current = value);
|
|
43
36
|
} else {
|
|
44
37
|
cleanChildren(parent, current, marker, createTextNode(value));
|
|
45
38
|
current = value;
|
|
@@ -57,14 +50,12 @@ function createRenderer$1({
|
|
|
57
50
|
} else if (Array.isArray(value)) {
|
|
58
51
|
const array = [];
|
|
59
52
|
if (normalizeIncomingArray(array, value, unwrapArray)) {
|
|
60
|
-
createRenderEffect(
|
|
61
|
-
() => (current = insertExpression(parent, array, current, marker, true))
|
|
62
|
-
);
|
|
53
|
+
createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
63
54
|
return () => current;
|
|
64
55
|
}
|
|
65
56
|
if (array.length === 0) {
|
|
66
57
|
const replacement = cleanChildren(parent, current, marker);
|
|
67
|
-
if (multi) return
|
|
58
|
+
if (multi) return current = replacement;
|
|
68
59
|
} else {
|
|
69
60
|
if (Array.isArray(current)) {
|
|
70
61
|
if (current.length === 0) {
|
|
@@ -73,13 +64,13 @@ function createRenderer$1({
|
|
|
73
64
|
} else if (current == null || current === "") {
|
|
74
65
|
appendNodes(parent, array);
|
|
75
66
|
} else {
|
|
76
|
-
reconcileArrays(parent,
|
|
67
|
+
reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
|
|
77
68
|
}
|
|
78
69
|
}
|
|
79
70
|
current = array;
|
|
80
71
|
} else {
|
|
81
72
|
if (Array.isArray(current)) {
|
|
82
|
-
if (multi) return
|
|
73
|
+
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
83
74
|
cleanChildren(parent, current, null, value);
|
|
84
75
|
} else if (current == null || current === "" || !getFirstChild(parent)) {
|
|
85
76
|
insertNode(parent, value);
|
|
@@ -93,16 +84,14 @@ function createRenderer$1({
|
|
|
93
84
|
for (let i = 0, len = array.length; i < len; i++) {
|
|
94
85
|
let item = array[i],
|
|
95
86
|
t;
|
|
96
|
-
if (item == null || item === true || item === false);
|
|
97
|
-
else if (Array.isArray(item)) {
|
|
87
|
+
if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
|
|
98
88
|
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
|
|
99
89
|
} else if ((t = typeof item) === "string" || t === "number") {
|
|
100
90
|
normalized.push(createTextNode(item));
|
|
101
91
|
} else if (t === "function") {
|
|
102
92
|
if (unwrap) {
|
|
103
93
|
while (typeof item === "function") item = item();
|
|
104
|
-
dynamic =
|
|
105
|
-
normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
94
|
+
dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
106
95
|
} else {
|
|
107
96
|
normalized.push(item);
|
|
108
97
|
dynamic = true;
|
|
@@ -130,8 +119,7 @@ function createRenderer$1({
|
|
|
130
119
|
bEnd--;
|
|
131
120
|
}
|
|
132
121
|
if (aEnd === aStart) {
|
|
133
|
-
const node =
|
|
134
|
-
bEnd < bLength ? (bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart]) : after;
|
|
122
|
+
const node = bEnd < bLength ? bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart] : after;
|
|
135
123
|
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
|
|
136
124
|
} else if (bEnd === bStart) {
|
|
137
125
|
while (aStart < aEnd) {
|
|
@@ -171,7 +159,7 @@ function createRenderer$1({
|
|
|
171
159
|
function cleanChildren(parent, current, marker, replacement) {
|
|
172
160
|
if (marker === undefined) {
|
|
173
161
|
let removed;
|
|
174
|
-
while (
|
|
162
|
+
while (removed = getFirstChild(parent)) removeNode(parent, removed);
|
|
175
163
|
replacement && insertNode(parent, replacement);
|
|
176
164
|
return "";
|
|
177
165
|
}
|
|
@@ -182,9 +170,7 @@ function createRenderer$1({
|
|
|
182
170
|
const el = current[i];
|
|
183
171
|
if (node !== el) {
|
|
184
172
|
const isParent = getParentNode(el) === parent;
|
|
185
|
-
if (!inserted && !i)
|
|
186
|
-
isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);
|
|
187
|
-
else isParent && removeNode(parent, el);
|
|
173
|
+
if (!inserted && !i) isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);else isParent && removeNode(parent, el);
|
|
188
174
|
} else inserted = true;
|
|
189
175
|
}
|
|
190
176
|
} else insertNode(parent, node, marker);
|
|
@@ -200,9 +186,7 @@ function createRenderer$1({
|
|
|
200
186
|
function spreadExpression(node, props, prevProps = {}, skipChildren) {
|
|
201
187
|
props || (props = {});
|
|
202
188
|
if (!skipChildren) {
|
|
203
|
-
createRenderEffect(
|
|
204
|
-
() => (prevProps.children = insertExpression(node, props.children, prevProps.children))
|
|
205
|
-
);
|
|
189
|
+
createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
|
|
206
190
|
}
|
|
207
191
|
createRenderEffect(() => props.ref && props.ref(node));
|
|
208
192
|
createRenderEffect(() => {
|
|
@@ -1,4 +1,2 @@
|
|
|
1
1
|
import type { RendererOptions, Renderer } from "./universal.js";
|
|
2
|
-
export declare function createRenderer<NodeType>(
|
|
3
|
-
options: RendererOptions<NodeType>
|
|
4
|
-
): Renderer<NodeType>;
|
|
2
|
+
export declare function createRenderer<NodeType>(options: RendererOptions<NodeType>): Renderer<NodeType>;
|