solid-js 1.9.3 → 2.0.0-experimental.0
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 +213 -1603
- package/dist/dev.js +159 -1749
- package/dist/server.cjs +88 -11
- package/dist/server.js +91 -11
- package/dist/solid.cjs +196 -1558
- package/dist/solid.js +139 -1682
- package/package.json +8 -154
- package/types/{render → client}/component.d.ts +0 -61
- package/types/client/core.d.ts +75 -0
- package/types/client/flow.d.ts +114 -0
- package/types/{render → client}/hydration.d.ts +0 -2
- package/types/{reactive → client}/observable.d.ts +1 -1
- package/types/index.d.ts +44 -55
- package/types/jsx.d.ts +1944 -174
- package/types/server/index.d.ts +1 -1
- package/types/server/reactive.d.ts +6 -1
- package/types/server/store.d.ts +6 -0
- package/h/dist/h.cjs +0 -115
- package/h/dist/h.js +0 -144
- package/h/jsx-dev-runtime/package.json +0 -8
- package/h/jsx-runtime/dist/jsx.cjs +0 -15
- package/h/jsx-runtime/dist/jsx.js +0 -10
- package/h/jsx-runtime/package.json +0 -8
- package/h/jsx-runtime/types/index.d.ts +0 -14
- package/h/jsx-runtime/types/jsx.d.ts +0 -2276
- package/h/package.json +0 -8
- package/h/types/hyperscript.d.ts +0 -20
- package/h/types/index.d.ts +0 -3
- package/html/dist/html.cjs +0 -583
- package/html/dist/html.js +0 -706
- package/html/package.json +0 -8
- package/html/types/index.d.ts +0 -3
- package/html/types/lit.d.ts +0 -60
- package/store/dist/dev.cjs +0 -454
- package/store/dist/dev.js +0 -525
- package/store/dist/server.cjs +0 -126
- package/store/dist/server.js +0 -126
- package/store/dist/store.cjs +0 -434
- package/store/dist/store.js +0 -499
- package/store/package.json +0 -46
- package/store/types/index.d.ts +0 -26
- package/store/types/modifiers.d.ts +0 -9
- package/store/types/mutable.d.ts +0 -8
- package/store/types/server.d.ts +0 -37
- package/store/types/store.d.ts +0 -263
- package/types/reactive/array.d.ts +0 -52
- package/types/reactive/scheduler.d.ts +0 -13
- package/types/reactive/signal.d.ts +0 -664
- package/types/render/Suspense.d.ts +0 -26
- package/types/render/flow.d.ts +0 -130
- package/types/render/index.d.ts +0 -4
- package/universal/dist/dev.cjs +0 -243
- package/universal/dist/dev.js +0 -257
- package/universal/dist/universal.cjs +0 -243
- package/universal/dist/universal.js +0 -257
- package/universal/package.json +0 -20
- package/universal/types/index.d.ts +0 -4
- package/universal/types/universal.d.ts +0 -29
- package/web/dist/dev.cjs +0 -804
- package/web/dist/dev.js +0 -1241
- package/web/dist/server.cjs +0 -793
- package/web/dist/server.js +0 -1214
- package/web/dist/web.cjs +0 -793
- package/web/dist/web.js +0 -1220
- package/web/package.json +0 -46
- package/web/storage/dist/storage.cjs +0 -12
- package/web/storage/dist/storage.js +0 -10
- package/web/storage/package.json +0 -15
- package/web/storage/types/index.d.ts +0 -2
- package/web/storage/types/index.js +0 -13
- package/web/types/client.d.ts +0 -79
- package/web/types/core.d.ts +0 -10
- package/web/types/index.d.ts +0 -54
- package/web/types/jsx.d.ts +0 -1
- package/web/types/server-mock.d.ts +0 -80
- package/web/types/server.d.ts +0 -177
package/types/render/flow.d.ts
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { Accessor } from "../reactive/signal.js";
|
|
2
|
-
import type { JSX } from "../jsx.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a list elements from a list
|
|
5
|
-
*
|
|
6
|
-
* it receives a map function as its child that receives a list element and an accessor with the index and returns a JSX-Element; if the list is empty, an optional fallback is returned:
|
|
7
|
-
* ```typescript
|
|
8
|
-
* <For each={items} fallback={<div>No items</div>}>
|
|
9
|
-
* {(item, index) => <div data-index={index()}>{item}</div>}
|
|
10
|
-
* </For>
|
|
11
|
-
* ```
|
|
12
|
-
* If you have a list with fixed indices and changing values, consider using `<Index>` instead.
|
|
13
|
-
*
|
|
14
|
-
* @description https://docs.solidjs.com/reference/components/for
|
|
15
|
-
*/
|
|
16
|
-
export declare function For<T extends readonly any[], U extends JSX.Element>(props: {
|
|
17
|
-
each: T | undefined | null | false;
|
|
18
|
-
fallback?: JSX.Element;
|
|
19
|
-
children: (item: T[number], index: Accessor<number>) => U;
|
|
20
|
-
}): JSX.Element;
|
|
21
|
-
/**
|
|
22
|
-
* Non-keyed iteration over a list creating elements from its items
|
|
23
|
-
*
|
|
24
|
-
* To be used if you have a list with fixed indices, but changing values.
|
|
25
|
-
* ```typescript
|
|
26
|
-
* <Index each={items} fallback={<div>No items</div>}>
|
|
27
|
-
* {(item, index) => <div data-index={index}>{item()}</div>}
|
|
28
|
-
* </Index>
|
|
29
|
-
* ```
|
|
30
|
-
* If you have a list with changing indices, better use `<For>`.
|
|
31
|
-
*
|
|
32
|
-
* @description https://docs.solidjs.com/reference/components/index
|
|
33
|
-
*/
|
|
34
|
-
export declare function Index<T extends readonly any[], U extends JSX.Element>(props: {
|
|
35
|
-
each: T | undefined | null | false;
|
|
36
|
-
fallback?: JSX.Element;
|
|
37
|
-
children: (item: Accessor<T[number]>, index: number) => U;
|
|
38
|
-
}): JSX.Element;
|
|
39
|
-
type RequiredParameter<T> = T extends () => unknown ? never : T;
|
|
40
|
-
/**
|
|
41
|
-
* Conditionally render its children or an optional fallback component
|
|
42
|
-
* @description https://docs.solidjs.com/reference/components/show
|
|
43
|
-
*/
|
|
44
|
-
export declare function Show<
|
|
45
|
-
T,
|
|
46
|
-
TRenderFunction extends (item: Accessor<NonNullable<T>>) => JSX.Element
|
|
47
|
-
>(props: {
|
|
48
|
-
when: T | undefined | null | false;
|
|
49
|
-
keyed?: false;
|
|
50
|
-
fallback?: JSX.Element;
|
|
51
|
-
children: JSX.Element | RequiredParameter<TRenderFunction>;
|
|
52
|
-
}): JSX.Element;
|
|
53
|
-
export declare function Show<
|
|
54
|
-
T,
|
|
55
|
-
TRenderFunction extends (item: NonNullable<T>) => JSX.Element
|
|
56
|
-
>(props: {
|
|
57
|
-
when: T | undefined | null | false;
|
|
58
|
-
keyed: true;
|
|
59
|
-
fallback?: JSX.Element;
|
|
60
|
-
children: JSX.Element | RequiredParameter<TRenderFunction>;
|
|
61
|
-
}): JSX.Element;
|
|
62
|
-
/**
|
|
63
|
-
* Switches between content based on mutually exclusive conditions
|
|
64
|
-
* ```typescript
|
|
65
|
-
* <Switch fallback={<FourOhFour />}>
|
|
66
|
-
* <Match when={state.route === 'home'}>
|
|
67
|
-
* <Home />
|
|
68
|
-
* </Match>
|
|
69
|
-
* <Match when={state.route === 'settings'}>
|
|
70
|
-
* <Settings />
|
|
71
|
-
* </Match>
|
|
72
|
-
* </Switch>
|
|
73
|
-
* ```
|
|
74
|
-
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
75
|
-
*/
|
|
76
|
-
export declare function Switch(props: {
|
|
77
|
-
fallback?: JSX.Element;
|
|
78
|
-
children: JSX.Element;
|
|
79
|
-
}): JSX.Element;
|
|
80
|
-
export type MatchProps<T> = {
|
|
81
|
-
when: T | undefined | null | false;
|
|
82
|
-
keyed?: boolean;
|
|
83
|
-
children: JSX.Element | ((item: NonNullable<T> | Accessor<NonNullable<T>>) => JSX.Element);
|
|
84
|
-
};
|
|
85
|
-
/**
|
|
86
|
-
* Selects a content based on condition when inside a `<Switch>` control flow
|
|
87
|
-
* ```typescript
|
|
88
|
-
* <Match when={condition()}>
|
|
89
|
-
* <Content/>
|
|
90
|
-
* </Match>
|
|
91
|
-
* ```
|
|
92
|
-
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
93
|
-
*/
|
|
94
|
-
export declare function Match<
|
|
95
|
-
T,
|
|
96
|
-
TRenderFunction extends (item: Accessor<NonNullable<T>>) => JSX.Element
|
|
97
|
-
>(props: {
|
|
98
|
-
when: T | undefined | null | false;
|
|
99
|
-
keyed?: false;
|
|
100
|
-
children: JSX.Element | RequiredParameter<TRenderFunction>;
|
|
101
|
-
}): JSX.Element;
|
|
102
|
-
export declare function Match<
|
|
103
|
-
T,
|
|
104
|
-
TRenderFunction extends (item: NonNullable<T>) => JSX.Element
|
|
105
|
-
>(props: {
|
|
106
|
-
when: T | undefined | null | false;
|
|
107
|
-
keyed: true;
|
|
108
|
-
children: JSX.Element | RequiredParameter<TRenderFunction>;
|
|
109
|
-
}): JSX.Element;
|
|
110
|
-
export declare function resetErrorBoundaries(): void;
|
|
111
|
-
/**
|
|
112
|
-
* Catches uncaught errors inside components and renders a fallback content
|
|
113
|
-
*
|
|
114
|
-
* Also supports a callback form that passes the error and a reset function:
|
|
115
|
-
* ```typescript
|
|
116
|
-
* <ErrorBoundary fallback={
|
|
117
|
-
* (err, reset) => <div onClick={reset}>Error: {err.toString()}</div>
|
|
118
|
-
* }>
|
|
119
|
-
* <MyComp />
|
|
120
|
-
* </ErrorBoundary>
|
|
121
|
-
* ```
|
|
122
|
-
* Errors thrown from the fallback can be caught by a parent ErrorBoundary
|
|
123
|
-
*
|
|
124
|
-
* @description https://docs.solidjs.com/reference/components/error-boundary
|
|
125
|
-
*/
|
|
126
|
-
export declare function ErrorBoundary(props: {
|
|
127
|
-
fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
|
|
128
|
-
children: JSX.Element;
|
|
129
|
-
}): JSX.Element;
|
|
130
|
-
export {};
|
package/types/render/index.d.ts
DELETED
package/universal/dist/dev.cjs
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var solidJs = require('solid-js');
|
|
4
|
-
|
|
5
|
-
function createRenderer$1({
|
|
6
|
-
createElement,
|
|
7
|
-
createTextNode,
|
|
8
|
-
isTextNode,
|
|
9
|
-
replaceText,
|
|
10
|
-
insertNode,
|
|
11
|
-
removeNode,
|
|
12
|
-
setProperty,
|
|
13
|
-
getParentNode,
|
|
14
|
-
getFirstChild,
|
|
15
|
-
getNextSibling
|
|
16
|
-
}) {
|
|
17
|
-
function insert(parent, accessor, marker, initial) {
|
|
18
|
-
if (marker !== undefined && !initial) initial = [];
|
|
19
|
-
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
20
|
-
solidJs.createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial);
|
|
21
|
-
}
|
|
22
|
-
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
23
|
-
while (typeof current === "function") current = current();
|
|
24
|
-
if (value === current) return current;
|
|
25
|
-
const t = typeof value,
|
|
26
|
-
multi = marker !== undefined;
|
|
27
|
-
if (t === "string" || t === "number") {
|
|
28
|
-
if (t === "number") value = value.toString();
|
|
29
|
-
if (multi) {
|
|
30
|
-
let node = current[0];
|
|
31
|
-
if (node && isTextNode(node)) {
|
|
32
|
-
replaceText(node, value);
|
|
33
|
-
} else node = createTextNode(value);
|
|
34
|
-
current = cleanChildren(parent, current, marker, node);
|
|
35
|
-
} else {
|
|
36
|
-
if (current !== "" && typeof current === "string") {
|
|
37
|
-
replaceText(getFirstChild(parent), current = value);
|
|
38
|
-
} else {
|
|
39
|
-
cleanChildren(parent, current, marker, createTextNode(value));
|
|
40
|
-
current = value;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
} else if (value == null || t === "boolean") {
|
|
44
|
-
current = cleanChildren(parent, current, marker);
|
|
45
|
-
} else if (t === "function") {
|
|
46
|
-
solidJs.createRenderEffect(() => {
|
|
47
|
-
let v = value();
|
|
48
|
-
while (typeof v === "function") v = v();
|
|
49
|
-
current = insertExpression(parent, v, current, marker);
|
|
50
|
-
});
|
|
51
|
-
return () => current;
|
|
52
|
-
} else if (Array.isArray(value)) {
|
|
53
|
-
const array = [];
|
|
54
|
-
if (normalizeIncomingArray(array, value, unwrapArray)) {
|
|
55
|
-
solidJs.createRenderEffect(() => current = insertExpression(parent, array, current, marker, true));
|
|
56
|
-
return () => current;
|
|
57
|
-
}
|
|
58
|
-
if (array.length === 0) {
|
|
59
|
-
const replacement = cleanChildren(parent, current, marker);
|
|
60
|
-
if (multi) return current = replacement;
|
|
61
|
-
} else {
|
|
62
|
-
if (Array.isArray(current)) {
|
|
63
|
-
if (current.length === 0) {
|
|
64
|
-
appendNodes(parent, array, marker);
|
|
65
|
-
} else reconcileArrays(parent, current, array);
|
|
66
|
-
} else if (current == null || current === "") {
|
|
67
|
-
appendNodes(parent, array);
|
|
68
|
-
} else {
|
|
69
|
-
reconcileArrays(parent, multi && current || [getFirstChild(parent)], array);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
current = array;
|
|
73
|
-
} else {
|
|
74
|
-
if (Array.isArray(current)) {
|
|
75
|
-
if (multi) return current = cleanChildren(parent, current, marker, value);
|
|
76
|
-
cleanChildren(parent, current, null, value);
|
|
77
|
-
} else if (current == null || current === "" || !getFirstChild(parent)) {
|
|
78
|
-
insertNode(parent, value);
|
|
79
|
-
} else replaceNode(parent, value, getFirstChild(parent));
|
|
80
|
-
current = value;
|
|
81
|
-
}
|
|
82
|
-
return current;
|
|
83
|
-
}
|
|
84
|
-
function normalizeIncomingArray(normalized, array, unwrap) {
|
|
85
|
-
let dynamic = false;
|
|
86
|
-
for (let i = 0, len = array.length; i < len; i++) {
|
|
87
|
-
let item = array[i],
|
|
88
|
-
t;
|
|
89
|
-
if (item == null || item === true || item === false) ; else if (Array.isArray(item)) {
|
|
90
|
-
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
|
|
91
|
-
} else if ((t = typeof item) === "string" || t === "number") {
|
|
92
|
-
normalized.push(createTextNode(item));
|
|
93
|
-
} else if (t === "function") {
|
|
94
|
-
if (unwrap) {
|
|
95
|
-
while (typeof item === "function") item = item();
|
|
96
|
-
dynamic = normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
97
|
-
} else {
|
|
98
|
-
normalized.push(item);
|
|
99
|
-
dynamic = true;
|
|
100
|
-
}
|
|
101
|
-
} else normalized.push(item);
|
|
102
|
-
}
|
|
103
|
-
return dynamic;
|
|
104
|
-
}
|
|
105
|
-
function reconcileArrays(parentNode, a, b) {
|
|
106
|
-
let bLength = b.length,
|
|
107
|
-
aEnd = a.length,
|
|
108
|
-
bEnd = bLength,
|
|
109
|
-
aStart = 0,
|
|
110
|
-
bStart = 0,
|
|
111
|
-
after = getNextSibling(a[aEnd - 1]),
|
|
112
|
-
map = null;
|
|
113
|
-
while (aStart < aEnd || bStart < bEnd) {
|
|
114
|
-
if (a[aStart] === b[bStart]) {
|
|
115
|
-
aStart++;
|
|
116
|
-
bStart++;
|
|
117
|
-
continue;
|
|
118
|
-
}
|
|
119
|
-
while (a[aEnd - 1] === b[bEnd - 1]) {
|
|
120
|
-
aEnd--;
|
|
121
|
-
bEnd--;
|
|
122
|
-
}
|
|
123
|
-
if (aEnd === aStart) {
|
|
124
|
-
const node = bEnd < bLength ? bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart] : after;
|
|
125
|
-
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
|
|
126
|
-
} else if (bEnd === bStart) {
|
|
127
|
-
while (aStart < aEnd) {
|
|
128
|
-
if (!map || !map.has(a[aStart])) removeNode(parentNode, a[aStart]);
|
|
129
|
-
aStart++;
|
|
130
|
-
}
|
|
131
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
132
|
-
const node = getNextSibling(a[--aEnd]);
|
|
133
|
-
insertNode(parentNode, b[bStart++], getNextSibling(a[aStart++]));
|
|
134
|
-
insertNode(parentNode, b[--bEnd], node);
|
|
135
|
-
a[aEnd] = b[bEnd];
|
|
136
|
-
} else {
|
|
137
|
-
if (!map) {
|
|
138
|
-
map = new Map();
|
|
139
|
-
let i = bStart;
|
|
140
|
-
while (i < bEnd) map.set(b[i], i++);
|
|
141
|
-
}
|
|
142
|
-
const index = map.get(a[aStart]);
|
|
143
|
-
if (index != null) {
|
|
144
|
-
if (bStart < index && index < bEnd) {
|
|
145
|
-
let i = aStart,
|
|
146
|
-
sequence = 1,
|
|
147
|
-
t;
|
|
148
|
-
while (++i < aEnd && i < bEnd) {
|
|
149
|
-
if ((t = map.get(a[i])) == null || t !== index + sequence) break;
|
|
150
|
-
sequence++;
|
|
151
|
-
}
|
|
152
|
-
if (sequence > index - bStart) {
|
|
153
|
-
const node = a[aStart];
|
|
154
|
-
while (bStart < index) insertNode(parentNode, b[bStart++], node);
|
|
155
|
-
} else replaceNode(parentNode, b[bStart++], a[aStart++]);
|
|
156
|
-
} else aStart++;
|
|
157
|
-
} else removeNode(parentNode, a[aStart++]);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function cleanChildren(parent, current, marker, replacement) {
|
|
162
|
-
if (marker === undefined) {
|
|
163
|
-
let removed;
|
|
164
|
-
while (removed = getFirstChild(parent)) removeNode(parent, removed);
|
|
165
|
-
replacement && insertNode(parent, replacement);
|
|
166
|
-
return "";
|
|
167
|
-
}
|
|
168
|
-
const node = replacement || createTextNode("");
|
|
169
|
-
if (current.length) {
|
|
170
|
-
let inserted = false;
|
|
171
|
-
for (let i = current.length - 1; i >= 0; i--) {
|
|
172
|
-
const el = current[i];
|
|
173
|
-
if (node !== el) {
|
|
174
|
-
const isParent = getParentNode(el) === parent;
|
|
175
|
-
if (!inserted && !i) isParent ? replaceNode(parent, node, el) : insertNode(parent, node, marker);else isParent && removeNode(parent, el);
|
|
176
|
-
} else inserted = true;
|
|
177
|
-
}
|
|
178
|
-
} else insertNode(parent, node, marker);
|
|
179
|
-
return [node];
|
|
180
|
-
}
|
|
181
|
-
function appendNodes(parent, array, marker) {
|
|
182
|
-
for (let i = 0, len = array.length; i < len; i++) insertNode(parent, array[i], marker);
|
|
183
|
-
}
|
|
184
|
-
function replaceNode(parent, newNode, oldNode) {
|
|
185
|
-
insertNode(parent, newNode, oldNode);
|
|
186
|
-
removeNode(parent, oldNode);
|
|
187
|
-
}
|
|
188
|
-
function spreadExpression(node, props, prevProps = {}, skipChildren) {
|
|
189
|
-
props || (props = {});
|
|
190
|
-
if (!skipChildren) {
|
|
191
|
-
solidJs.createRenderEffect(() => prevProps.children = insertExpression(node, props.children, prevProps.children));
|
|
192
|
-
}
|
|
193
|
-
solidJs.createRenderEffect(() => props.ref && props.ref(node));
|
|
194
|
-
solidJs.createRenderEffect(() => {
|
|
195
|
-
for (const prop in props) {
|
|
196
|
-
if (prop === "children" || prop === "ref") continue;
|
|
197
|
-
const value = props[prop];
|
|
198
|
-
if (value === prevProps[prop]) continue;
|
|
199
|
-
setProperty(node, prop, value, prevProps[prop]);
|
|
200
|
-
prevProps[prop] = value;
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
return prevProps;
|
|
204
|
-
}
|
|
205
|
-
return {
|
|
206
|
-
render(code, element) {
|
|
207
|
-
let disposer;
|
|
208
|
-
solidJs.createRoot(dispose => {
|
|
209
|
-
disposer = dispose;
|
|
210
|
-
insert(element, code());
|
|
211
|
-
});
|
|
212
|
-
return disposer;
|
|
213
|
-
},
|
|
214
|
-
insert,
|
|
215
|
-
spread(node, accessor, skipChildren) {
|
|
216
|
-
if (typeof accessor === "function") {
|
|
217
|
-
solidJs.createRenderEffect(current => spreadExpression(node, accessor(), current, skipChildren));
|
|
218
|
-
} else spreadExpression(node, accessor, undefined, skipChildren);
|
|
219
|
-
},
|
|
220
|
-
createElement,
|
|
221
|
-
createTextNode,
|
|
222
|
-
insertNode,
|
|
223
|
-
setProp(node, name, value, prev) {
|
|
224
|
-
setProperty(node, name, value, prev);
|
|
225
|
-
return value;
|
|
226
|
-
},
|
|
227
|
-
mergeProps: solidJs.mergeProps,
|
|
228
|
-
effect: solidJs.createRenderEffect,
|
|
229
|
-
memo: solidJs.createMemo,
|
|
230
|
-
createComponent: solidJs.createComponent,
|
|
231
|
-
use(fn, element, arg) {
|
|
232
|
-
return solidJs.untrack(() => fn(element, arg));
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function createRenderer(options) {
|
|
238
|
-
const renderer = createRenderer$1(options);
|
|
239
|
-
renderer.mergeProps = solidJs.mergeProps;
|
|
240
|
-
return renderer;
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
exports.createRenderer = createRenderer;
|
package/universal/dist/dev.js
DELETED
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createRoot,
|
|
3
|
-
createRenderEffect,
|
|
4
|
-
mergeProps,
|
|
5
|
-
createMemo,
|
|
6
|
-
createComponent,
|
|
7
|
-
untrack
|
|
8
|
-
} from "solid-js";
|
|
9
|
-
|
|
10
|
-
function createRenderer$1({
|
|
11
|
-
createElement,
|
|
12
|
-
createTextNode,
|
|
13
|
-
isTextNode,
|
|
14
|
-
replaceText,
|
|
15
|
-
insertNode,
|
|
16
|
-
removeNode,
|
|
17
|
-
setProperty,
|
|
18
|
-
getParentNode,
|
|
19
|
-
getFirstChild,
|
|
20
|
-
getNextSibling
|
|
21
|
-
}) {
|
|
22
|
-
function insert(parent, accessor, marker, initial) {
|
|
23
|
-
if (marker !== undefined && !initial) initial = [];
|
|
24
|
-
if (typeof accessor !== "function") return insertExpression(parent, accessor, initial, marker);
|
|
25
|
-
createRenderEffect(current => insertExpression(parent, accessor(), current, marker), initial);
|
|
26
|
-
}
|
|
27
|
-
function insertExpression(parent, value, current, marker, unwrapArray) {
|
|
28
|
-
while (typeof current === "function") current = current();
|
|
29
|
-
if (value === current) return current;
|
|
30
|
-
const t = typeof value,
|
|
31
|
-
multi = marker !== undefined;
|
|
32
|
-
if (t === "string" || t === "number") {
|
|
33
|
-
if (t === "number") value = value.toString();
|
|
34
|
-
if (multi) {
|
|
35
|
-
let node = current[0];
|
|
36
|
-
if (node && isTextNode(node)) {
|
|
37
|
-
replaceText(node, value);
|
|
38
|
-
} else node = createTextNode(value);
|
|
39
|
-
current = cleanChildren(parent, current, marker, node);
|
|
40
|
-
} else {
|
|
41
|
-
if (current !== "" && typeof current === "string") {
|
|
42
|
-
replaceText(getFirstChild(parent), (current = value));
|
|
43
|
-
} else {
|
|
44
|
-
cleanChildren(parent, current, marker, createTextNode(value));
|
|
45
|
-
current = value;
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
} else if (value == null || t === "boolean") {
|
|
49
|
-
current = cleanChildren(parent, current, marker);
|
|
50
|
-
} else if (t === "function") {
|
|
51
|
-
createRenderEffect(() => {
|
|
52
|
-
let v = value();
|
|
53
|
-
while (typeof v === "function") v = v();
|
|
54
|
-
current = insertExpression(parent, v, current, marker);
|
|
55
|
-
});
|
|
56
|
-
return () => current;
|
|
57
|
-
} else if (Array.isArray(value)) {
|
|
58
|
-
const array = [];
|
|
59
|
-
if (normalizeIncomingArray(array, value, unwrapArray)) {
|
|
60
|
-
createRenderEffect(
|
|
61
|
-
() => (current = insertExpression(parent, array, current, marker, true))
|
|
62
|
-
);
|
|
63
|
-
return () => current;
|
|
64
|
-
}
|
|
65
|
-
if (array.length === 0) {
|
|
66
|
-
const replacement = cleanChildren(parent, current, marker);
|
|
67
|
-
if (multi) return (current = replacement);
|
|
68
|
-
} else {
|
|
69
|
-
if (Array.isArray(current)) {
|
|
70
|
-
if (current.length === 0) {
|
|
71
|
-
appendNodes(parent, array, marker);
|
|
72
|
-
} else reconcileArrays(parent, current, array);
|
|
73
|
-
} else if (current == null || current === "") {
|
|
74
|
-
appendNodes(parent, array);
|
|
75
|
-
} else {
|
|
76
|
-
reconcileArrays(parent, (multi && current) || [getFirstChild(parent)], array);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
current = array;
|
|
80
|
-
} else {
|
|
81
|
-
if (Array.isArray(current)) {
|
|
82
|
-
if (multi) return (current = cleanChildren(parent, current, marker, value));
|
|
83
|
-
cleanChildren(parent, current, null, value);
|
|
84
|
-
} else if (current == null || current === "" || !getFirstChild(parent)) {
|
|
85
|
-
insertNode(parent, value);
|
|
86
|
-
} else replaceNode(parent, value, getFirstChild(parent));
|
|
87
|
-
current = value;
|
|
88
|
-
}
|
|
89
|
-
return current;
|
|
90
|
-
}
|
|
91
|
-
function normalizeIncomingArray(normalized, array, unwrap) {
|
|
92
|
-
let dynamic = false;
|
|
93
|
-
for (let i = 0, len = array.length; i < len; i++) {
|
|
94
|
-
let item = array[i],
|
|
95
|
-
t;
|
|
96
|
-
if (item == null || item === true || item === false);
|
|
97
|
-
else if (Array.isArray(item)) {
|
|
98
|
-
dynamic = normalizeIncomingArray(normalized, item) || dynamic;
|
|
99
|
-
} else if ((t = typeof item) === "string" || t === "number") {
|
|
100
|
-
normalized.push(createTextNode(item));
|
|
101
|
-
} else if (t === "function") {
|
|
102
|
-
if (unwrap) {
|
|
103
|
-
while (typeof item === "function") item = item();
|
|
104
|
-
dynamic =
|
|
105
|
-
normalizeIncomingArray(normalized, Array.isArray(item) ? item : [item]) || dynamic;
|
|
106
|
-
} else {
|
|
107
|
-
normalized.push(item);
|
|
108
|
-
dynamic = true;
|
|
109
|
-
}
|
|
110
|
-
} else normalized.push(item);
|
|
111
|
-
}
|
|
112
|
-
return dynamic;
|
|
113
|
-
}
|
|
114
|
-
function reconcileArrays(parentNode, a, b) {
|
|
115
|
-
let bLength = b.length,
|
|
116
|
-
aEnd = a.length,
|
|
117
|
-
bEnd = bLength,
|
|
118
|
-
aStart = 0,
|
|
119
|
-
bStart = 0,
|
|
120
|
-
after = getNextSibling(a[aEnd - 1]),
|
|
121
|
-
map = null;
|
|
122
|
-
while (aStart < aEnd || bStart < bEnd) {
|
|
123
|
-
if (a[aStart] === b[bStart]) {
|
|
124
|
-
aStart++;
|
|
125
|
-
bStart++;
|
|
126
|
-
continue;
|
|
127
|
-
}
|
|
128
|
-
while (a[aEnd - 1] === b[bEnd - 1]) {
|
|
129
|
-
aEnd--;
|
|
130
|
-
bEnd--;
|
|
131
|
-
}
|
|
132
|
-
if (aEnd === aStart) {
|
|
133
|
-
const node =
|
|
134
|
-
bEnd < bLength ? (bStart ? getNextSibling(b[bStart - 1]) : b[bEnd - bStart]) : after;
|
|
135
|
-
while (bStart < bEnd) insertNode(parentNode, b[bStart++], node);
|
|
136
|
-
} else if (bEnd === bStart) {
|
|
137
|
-
while (aStart < aEnd) {
|
|
138
|
-
if (!map || !map.has(a[aStart])) removeNode(parentNode, a[aStart]);
|
|
139
|
-
aStart++;
|
|
140
|
-
}
|
|
141
|
-
} else if (a[aStart] === b[bEnd - 1] && b[bStart] === a[aEnd - 1]) {
|
|
142
|
-
const node = getNextSibling(a[--aEnd]);
|
|
143
|
-
insertNode(parentNode, b[bStart++], getNextSibling(a[aStart++]));
|
|
144
|
-
insertNode(parentNode, b[--bEnd], node);
|
|
145
|
-
a[aEnd] = b[bEnd];
|
|
146
|
-
} else {
|
|
147
|
-
if (!map) {
|
|
148
|
-
map = new Map();
|
|
149
|
-
let i = bStart;
|
|
150
|
-
while (i < bEnd) map.set(b[i], i++);
|
|
151
|
-
}
|
|
152
|
-
const index = map.get(a[aStart]);
|
|
153
|
-
if (index != null) {
|
|
154
|
-
if (bStart < index && index < bEnd) {
|
|
155
|
-
let i = aStart,
|
|
156
|
-
sequence = 1,
|
|
157
|
-
t;
|
|
158
|
-
while (++i < aEnd && i < bEnd) {
|
|
159
|
-
if ((t = map.get(a[i])) == null || t !== index + sequence) break;
|
|
160
|
-
sequence++;
|
|
161
|
-
}
|
|
162
|
-
if (sequence > index - bStart) {
|
|
163
|
-
const node = a[aStart];
|
|
164
|
-
while (bStart < index) insertNode(parentNode, b[bStart++], node);
|
|
165
|
-
} else replaceNode(parentNode, b[bStart++], a[aStart++]);
|
|
166
|
-
} else aStart++;
|
|
167
|
-
} else removeNode(parentNode, a[aStart++]);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
function cleanChildren(parent, current, marker, replacement) {
|
|
172
|
-
if (marker === undefined) {
|
|
173
|
-
let removed;
|
|
174
|
-
while ((removed = getFirstChild(parent))) removeNode(parent, removed);
|
|
175
|
-
replacement && insertNode(parent, replacement);
|
|
176
|
-
return "";
|
|
177
|
-
}
|
|
178
|
-
const node = replacement || createTextNode("");
|
|
179
|
-
if (current.length) {
|
|
180
|
-
let inserted = false;
|
|
181
|
-
for (let i = current.length - 1; i >= 0; i--) {
|
|
182
|
-
const el = current[i];
|
|
183
|
-
if (node !== el) {
|
|
184
|
-
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);
|
|
188
|
-
} else inserted = true;
|
|
189
|
-
}
|
|
190
|
-
} else insertNode(parent, node, marker);
|
|
191
|
-
return [node];
|
|
192
|
-
}
|
|
193
|
-
function appendNodes(parent, array, marker) {
|
|
194
|
-
for (let i = 0, len = array.length; i < len; i++) insertNode(parent, array[i], marker);
|
|
195
|
-
}
|
|
196
|
-
function replaceNode(parent, newNode, oldNode) {
|
|
197
|
-
insertNode(parent, newNode, oldNode);
|
|
198
|
-
removeNode(parent, oldNode);
|
|
199
|
-
}
|
|
200
|
-
function spreadExpression(node, props, prevProps = {}, skipChildren) {
|
|
201
|
-
props || (props = {});
|
|
202
|
-
if (!skipChildren) {
|
|
203
|
-
createRenderEffect(
|
|
204
|
-
() => (prevProps.children = insertExpression(node, props.children, prevProps.children))
|
|
205
|
-
);
|
|
206
|
-
}
|
|
207
|
-
createRenderEffect(() => props.ref && props.ref(node));
|
|
208
|
-
createRenderEffect(() => {
|
|
209
|
-
for (const prop in props) {
|
|
210
|
-
if (prop === "children" || prop === "ref") continue;
|
|
211
|
-
const value = props[prop];
|
|
212
|
-
if (value === prevProps[prop]) continue;
|
|
213
|
-
setProperty(node, prop, value, prevProps[prop]);
|
|
214
|
-
prevProps[prop] = value;
|
|
215
|
-
}
|
|
216
|
-
});
|
|
217
|
-
return prevProps;
|
|
218
|
-
}
|
|
219
|
-
return {
|
|
220
|
-
render(code, element) {
|
|
221
|
-
let disposer;
|
|
222
|
-
createRoot(dispose => {
|
|
223
|
-
disposer = dispose;
|
|
224
|
-
insert(element, code());
|
|
225
|
-
});
|
|
226
|
-
return disposer;
|
|
227
|
-
},
|
|
228
|
-
insert,
|
|
229
|
-
spread(node, accessor, skipChildren) {
|
|
230
|
-
if (typeof accessor === "function") {
|
|
231
|
-
createRenderEffect(current => spreadExpression(node, accessor(), current, skipChildren));
|
|
232
|
-
} else spreadExpression(node, accessor, undefined, skipChildren);
|
|
233
|
-
},
|
|
234
|
-
createElement,
|
|
235
|
-
createTextNode,
|
|
236
|
-
insertNode,
|
|
237
|
-
setProp(node, name, value, prev) {
|
|
238
|
-
setProperty(node, name, value, prev);
|
|
239
|
-
return value;
|
|
240
|
-
},
|
|
241
|
-
mergeProps,
|
|
242
|
-
effect: createRenderEffect,
|
|
243
|
-
memo: createMemo,
|
|
244
|
-
createComponent,
|
|
245
|
-
use(fn, element, arg) {
|
|
246
|
-
return untrack(() => fn(element, arg));
|
|
247
|
-
}
|
|
248
|
-
};
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
function createRenderer(options) {
|
|
252
|
-
const renderer = createRenderer$1(options);
|
|
253
|
-
renderer.mergeProps = mergeProps;
|
|
254
|
-
return renderer;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
export { createRenderer };
|