solid-js 2.0.0-experimental.2 → 2.0.0-experimental.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 -0
- package/dist/dev.js +1 -0
- package/dist/server.cjs +228 -628
- package/dist/server.js +218 -667
- package/dist/solid.cjs +1 -0
- package/dist/solid.js +1 -0
- package/package.json +2 -2
- package/types/client/flow.d.ts +1 -0
- package/types/jsx.d.ts +10 -5
- package/types/server/index.d.ts +22 -39
- package/types/server/reactive.d.ts +5 -98
- package/types/server/rendering.d.ts +11 -159
- package/types/server/signals.d.ts +85 -0
- package/types/server/store.d.ts +10 -1
package/dist/server.cjs
CHANGED
|
@@ -1,130 +1,129 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const $TRACK = Symbol("solid-track");
|
|
6
|
-
const $DEVCOMP = Symbol("solid-dev-component");
|
|
7
|
-
const DEV = undefined;
|
|
8
|
-
const ERROR = Symbol("error");
|
|
9
|
-
function castError(err) {
|
|
10
|
-
if (err instanceof Error) return err;
|
|
11
|
-
return new Error(typeof err === "string" ? err : "Unknown error", {
|
|
12
|
-
cause: err
|
|
13
|
-
});
|
|
14
|
-
}
|
|
15
|
-
function handleError(err, owner = Owner) {
|
|
16
|
-
const fns = owner && owner.context && owner.context[ERROR];
|
|
17
|
-
const error = castError(err);
|
|
18
|
-
if (!fns) throw error;
|
|
19
|
-
try {
|
|
20
|
-
for (const f of fns) f(error);
|
|
21
|
-
} catch (e) {
|
|
22
|
-
handleError(e, owner && owner.owner || null);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
const UNOWNED = {
|
|
26
|
-
context: null,
|
|
27
|
-
owner: null,
|
|
28
|
-
owned: null,
|
|
29
|
-
cleanups: null
|
|
30
|
-
};
|
|
3
|
+
var signals = require('@solidjs/signals');
|
|
4
|
+
|
|
31
5
|
let Owner = null;
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
owner: Owner,
|
|
35
|
-
context: Owner ? Owner.context : null,
|
|
36
|
-
owned: null,
|
|
37
|
-
cleanups: null
|
|
38
|
-
};
|
|
39
|
-
if (Owner) {
|
|
40
|
-
if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o);
|
|
41
|
-
}
|
|
42
|
-
return o;
|
|
43
|
-
}
|
|
44
|
-
function createRoot(fn, detachedOwner) {
|
|
6
|
+
let Observer = null;
|
|
7
|
+
function createRoot(fn) {
|
|
45
8
|
const owner = Owner,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
owner: current,
|
|
9
|
+
root = {
|
|
10
|
+
context: owner ? owner.context : null,
|
|
11
|
+
owner: owner,
|
|
50
12
|
owned: null,
|
|
51
13
|
cleanups: null
|
|
52
14
|
};
|
|
53
15
|
Owner = root;
|
|
54
|
-
let result;
|
|
55
16
|
try {
|
|
56
|
-
|
|
57
|
-
} catch (err) {
|
|
58
|
-
handleError(err);
|
|
17
|
+
return fn(fn.length === 0 ? () => {} : () => cleanNode(root));
|
|
59
18
|
} finally {
|
|
60
19
|
Owner = owner;
|
|
61
20
|
}
|
|
62
|
-
return result;
|
|
63
21
|
}
|
|
64
|
-
function createSignal(
|
|
65
|
-
|
|
66
|
-
|
|
22
|
+
function createSignal(first, second, third) {
|
|
23
|
+
if (typeof first === "function") {
|
|
24
|
+
const memo = createMemo(p => {
|
|
25
|
+
let value = first(p ? p[0]() : second);
|
|
26
|
+
return [() => value, v => {
|
|
27
|
+
return value = typeof v === "function" ? v(first) : v;
|
|
28
|
+
}];
|
|
29
|
+
});
|
|
30
|
+
return [() => memo()[0](), v => memo()[1](v)];
|
|
31
|
+
}
|
|
32
|
+
return [() => first, v => {
|
|
33
|
+
return first = typeof v === "function" ? v(first) : v;
|
|
67
34
|
}];
|
|
68
35
|
}
|
|
69
|
-
function
|
|
36
|
+
function createMemo(compute, value, options) {
|
|
70
37
|
Owner = createOwner();
|
|
38
|
+
let v;
|
|
71
39
|
try {
|
|
72
|
-
|
|
73
|
-
} catch (err) {
|
|
74
|
-
handleError(err);
|
|
40
|
+
v = compute(value);
|
|
75
41
|
} finally {
|
|
76
42
|
Owner = Owner.owner;
|
|
77
43
|
}
|
|
44
|
+
return () => v;
|
|
78
45
|
}
|
|
79
|
-
|
|
80
|
-
function createEffect(fn, value) {}
|
|
81
|
-
function createReaction(fn) {
|
|
82
|
-
return fn => {
|
|
83
|
-
fn();
|
|
84
|
-
};
|
|
85
|
-
}
|
|
86
|
-
function createMemo(fn, value) {
|
|
46
|
+
function createRenderEffect(compute, effect, value, options) {
|
|
87
47
|
Owner = createOwner();
|
|
88
|
-
let v;
|
|
89
48
|
try {
|
|
90
|
-
|
|
49
|
+
effect(compute(value), value);
|
|
91
50
|
} catch (err) {
|
|
92
|
-
handleError(err);
|
|
93
51
|
} finally {
|
|
94
52
|
Owner = Owner.owner;
|
|
95
53
|
}
|
|
96
|
-
return () => v;
|
|
97
54
|
}
|
|
98
|
-
function
|
|
99
|
-
|
|
55
|
+
function createEffect(compute, effect, error, value, options) {}
|
|
56
|
+
function createAsync() {
|
|
100
57
|
}
|
|
101
|
-
function
|
|
102
|
-
return k => fn(k, source());
|
|
58
|
+
function isPending() {
|
|
103
59
|
}
|
|
104
|
-
function
|
|
105
|
-
return fn();
|
|
60
|
+
function latest() {
|
|
106
61
|
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
62
|
+
function resolve() {
|
|
63
|
+
}
|
|
64
|
+
function flushSync() {}
|
|
65
|
+
function getObserver() {
|
|
66
|
+
return Observer;
|
|
67
|
+
}
|
|
68
|
+
function getOwner() {
|
|
69
|
+
return Owner;
|
|
70
|
+
}
|
|
71
|
+
function runWithOwner(o, fn) {
|
|
72
|
+
const prev = Owner;
|
|
73
|
+
Owner = o;
|
|
74
|
+
try {
|
|
75
|
+
return fn();
|
|
76
|
+
} finally {
|
|
77
|
+
Owner = prev;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
function runWithObserver(o, fn) {
|
|
81
|
+
const prev = Observer;
|
|
82
|
+
Observer = o;
|
|
83
|
+
try {
|
|
84
|
+
return fn();
|
|
85
|
+
} finally {
|
|
86
|
+
Observer = prev;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function untrack(fn) {
|
|
90
|
+
return fn();
|
|
120
91
|
}
|
|
121
|
-
function onMount(fn) {}
|
|
122
92
|
function onCleanup(fn) {
|
|
123
93
|
if (Owner) {
|
|
124
94
|
if (!Owner.cleanups) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
125
95
|
}
|
|
126
96
|
return fn;
|
|
127
97
|
}
|
|
98
|
+
function mapArray(list, mapFn, options = {}) {
|
|
99
|
+
const items = list();
|
|
100
|
+
let s = [];
|
|
101
|
+
if (items && items.length) {
|
|
102
|
+
for (let i = 0, len = items.length; i < len; i++) s.push(mapFn(() => items[i], () => i));
|
|
103
|
+
} else if (options.fallback) s = [options.fallback()];
|
|
104
|
+
return () => s;
|
|
105
|
+
}
|
|
106
|
+
function repeat(count, mapFn, options = {}) {
|
|
107
|
+
const len = count();
|
|
108
|
+
const offset = options.from?.() || 0;
|
|
109
|
+
let s = [];
|
|
110
|
+
if (len) {
|
|
111
|
+
for (let i = 0; i < len; i++) s.push(mapFn(i + offset));
|
|
112
|
+
} else if (options.fallback) s = [options.fallback()];
|
|
113
|
+
return () => s;
|
|
114
|
+
}
|
|
115
|
+
function createOwner() {
|
|
116
|
+
const o = {
|
|
117
|
+
owner: Owner,
|
|
118
|
+
context: Owner ? Owner.context : null,
|
|
119
|
+
owned: null,
|
|
120
|
+
cleanups: null
|
|
121
|
+
};
|
|
122
|
+
if (Owner) {
|
|
123
|
+
if (!Owner.owned) Owner.owned = [o];else Owner.owned.push(o);
|
|
124
|
+
}
|
|
125
|
+
return o;
|
|
126
|
+
}
|
|
128
127
|
function cleanNode(node) {
|
|
129
128
|
if (node.owned) {
|
|
130
129
|
for (let i = 0; i < node.owned.length; i++) cleanNode(node.owned[i]);
|
|
@@ -135,128 +134,45 @@ function cleanNode(node) {
|
|
|
135
134
|
node.cleanups = null;
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
owner.context = {
|
|
141
|
-
...owner.context,
|
|
142
|
-
[ERROR]: [handler]
|
|
143
|
-
};
|
|
144
|
-
Owner = owner;
|
|
145
|
-
try {
|
|
146
|
-
return fn();
|
|
147
|
-
} catch (err) {
|
|
148
|
-
handleError(err);
|
|
149
|
-
} finally {
|
|
150
|
-
Owner = Owner.owner;
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
function getListener() {
|
|
154
|
-
return null;
|
|
155
|
-
}
|
|
137
|
+
|
|
138
|
+
function onMount(fn) {}
|
|
156
139
|
function createContext(defaultValue) {
|
|
157
140
|
const id = Symbol("context");
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
};
|
|
141
|
+
const P = createProvider(id);
|
|
142
|
+
P.id = id;
|
|
143
|
+
P.defaultValue = defaultValue;
|
|
144
|
+
return P;
|
|
163
145
|
}
|
|
164
146
|
function useContext(context) {
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
function getOwner() {
|
|
168
|
-
return Owner;
|
|
147
|
+
const owner = getOwner();
|
|
148
|
+
return owner && owner.context && owner.context[context.id] !== undefined ? owner.context[context.id] : context.defaultValue;
|
|
169
149
|
}
|
|
170
150
|
function children(fn) {
|
|
171
|
-
const
|
|
151
|
+
const children = createMemo(fn);
|
|
152
|
+
const memo = createMemo(() => signals.flatten(children()));
|
|
172
153
|
memo.toArray = () => {
|
|
173
154
|
const c = memo();
|
|
174
155
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
175
156
|
};
|
|
176
157
|
return memo;
|
|
177
158
|
}
|
|
178
|
-
function runWithOwner(o, fn) {
|
|
179
|
-
const prev = Owner;
|
|
180
|
-
Owner = o;
|
|
181
|
-
try {
|
|
182
|
-
return fn();
|
|
183
|
-
} catch (err) {
|
|
184
|
-
handleError(err);
|
|
185
|
-
} finally {
|
|
186
|
-
Owner = prev;
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
function resolveChildren(children) {
|
|
190
|
-
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
191
|
-
if (Array.isArray(children)) {
|
|
192
|
-
const results = [];
|
|
193
|
-
for (let i = 0; i < children.length; i++) {
|
|
194
|
-
const result = resolveChildren(children[i]);
|
|
195
|
-
Array.isArray(result) ? results.push.apply(results, result) : results.push(result);
|
|
196
|
-
}
|
|
197
|
-
return results;
|
|
198
|
-
}
|
|
199
|
-
return children;
|
|
200
|
-
}
|
|
201
159
|
function createProvider(id) {
|
|
202
160
|
return function provider(props) {
|
|
203
161
|
return createMemo(() => {
|
|
204
|
-
|
|
205
|
-
|
|
162
|
+
const owner = getOwner();
|
|
163
|
+
owner.context = {
|
|
164
|
+
...owner.context,
|
|
206
165
|
[id]: props.value
|
|
207
166
|
};
|
|
208
167
|
return children(() => props.children);
|
|
209
168
|
});
|
|
210
169
|
};
|
|
211
170
|
}
|
|
212
|
-
function requestCallback(fn, options) {
|
|
213
|
-
return {
|
|
214
|
-
id: 0,
|
|
215
|
-
fn: () => {},
|
|
216
|
-
startTime: 0,
|
|
217
|
-
expirationTime: 0
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
function mapArray(list, mapFn, options = {}) {
|
|
221
|
-
const items = list();
|
|
222
|
-
let s = [];
|
|
223
|
-
if (items && items.length) {
|
|
224
|
-
for (let i = 0, len = items.length; i < len; i++) s.push(mapFn(items[i], () => i));
|
|
225
|
-
} else if (options.fallback) s = [options.fallback()];
|
|
226
|
-
return () => s;
|
|
227
|
-
}
|
|
228
|
-
function indexArray(list, mapFn, options = {}) {
|
|
229
|
-
const items = list();
|
|
230
|
-
let s = [];
|
|
231
|
-
if (items && items.length) {
|
|
232
|
-
for (let i = 0, len = items.length; i < len; i++) s.push(mapFn(() => items[i], i));
|
|
233
|
-
} else if (options.fallback) s = [options.fallback()];
|
|
234
|
-
return () => s;
|
|
235
|
-
}
|
|
236
171
|
function observable(input) {
|
|
237
172
|
return {
|
|
238
173
|
subscribe(observer) {
|
|
239
|
-
if (!(observer instanceof Object) || observer == null) {
|
|
240
|
-
throw new TypeError("Expected the observer to be an object.");
|
|
241
|
-
}
|
|
242
|
-
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
243
|
-
if (!handler) {
|
|
244
|
-
return {
|
|
245
|
-
unsubscribe() {}
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
const dispose = createRoot(disposer => {
|
|
249
|
-
createEffect(() => {
|
|
250
|
-
const v = input();
|
|
251
|
-
untrack(() => handler(v));
|
|
252
|
-
});
|
|
253
|
-
return disposer;
|
|
254
|
-
});
|
|
255
|
-
if (getOwner()) onCleanup(dispose);
|
|
256
174
|
return {
|
|
257
|
-
unsubscribe() {
|
|
258
|
-
dispose();
|
|
259
|
-
}
|
|
175
|
+
unsubscribe() {}
|
|
260
176
|
};
|
|
261
177
|
},
|
|
262
178
|
[Symbol.observable || "@@observable"]() {
|
|
@@ -265,7 +181,9 @@ function observable(input) {
|
|
|
265
181
|
};
|
|
266
182
|
}
|
|
267
183
|
function from(producer) {
|
|
268
|
-
const [s, set] = createSignal(undefined
|
|
184
|
+
const [s, set] = createSignal(undefined, {
|
|
185
|
+
equals: false
|
|
186
|
+
});
|
|
269
187
|
if ("subscribe" in producer) {
|
|
270
188
|
const unsub = producer.subscribe(v => set(() => v));
|
|
271
189
|
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
@@ -275,95 +193,85 @@ function from(producer) {
|
|
|
275
193
|
}
|
|
276
194
|
return s;
|
|
277
195
|
}
|
|
278
|
-
|
|
279
|
-
function
|
|
280
|
-
|
|
281
|
-
if (Owner.context === null || !Owner.context[ERROR]) {
|
|
282
|
-
Owner.context = {
|
|
283
|
-
...Owner.context,
|
|
284
|
-
[ERROR]: [fn]
|
|
285
|
-
};
|
|
286
|
-
mutateContext(Owner, ERROR, [fn]);
|
|
287
|
-
} else Owner.context[ERROR].push(fn);
|
|
288
|
-
}
|
|
196
|
+
|
|
197
|
+
function isWrappable(obj) {
|
|
198
|
+
return obj != null && typeof obj === "object" && !Object.isFrozen(obj);
|
|
289
199
|
}
|
|
290
|
-
function
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
200
|
+
function unwrap(item) {
|
|
201
|
+
return item;
|
|
202
|
+
}
|
|
203
|
+
function setProperty(state, property, value) {
|
|
204
|
+
if (state[property] === value) return;
|
|
205
|
+
if (value === undefined) {
|
|
206
|
+
delete state[property];
|
|
207
|
+
} else state[property] = value;
|
|
208
|
+
}
|
|
209
|
+
function createStore(state) {
|
|
210
|
+
function setStore(fn) {
|
|
211
|
+
fn(state);
|
|
302
212
|
}
|
|
213
|
+
return [state, setStore];
|
|
303
214
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
215
|
+
function createProjection(fn, initialValue = {}) {
|
|
216
|
+
const [state] = createStore(initialValue);
|
|
217
|
+
fn(state);
|
|
218
|
+
return state;
|
|
219
|
+
}
|
|
220
|
+
function reconcile(value) {
|
|
221
|
+
return state => {
|
|
222
|
+
if (!isWrappable(state) || !isWrappable(value)) return value;
|
|
223
|
+
const targetKeys = Object.keys(value);
|
|
224
|
+
const previousKeys = Object.keys(state);
|
|
225
|
+
for (let i = 0, len = targetKeys.length; i < len; i++) {
|
|
226
|
+
const key = targetKeys[i];
|
|
227
|
+
setProperty(state, key, value[key]);
|
|
312
228
|
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
if (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
229
|
+
for (let i = 0, len = previousKeys.length; i < len; i++) {
|
|
230
|
+
if (value[previousKeys[i]] === undefined) setProperty(state, previousKeys[i], undefined);
|
|
231
|
+
}
|
|
232
|
+
return state;
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
function merge(...sources) {
|
|
236
|
+
const target = {};
|
|
237
|
+
for (let i = 0; i < sources.length; i++) {
|
|
238
|
+
let source = sources[i];
|
|
239
|
+
if (typeof source === "function") source = source();
|
|
240
|
+
if (source) {
|
|
241
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
242
|
+
for (const key in descriptors) {
|
|
243
|
+
if (key in target) continue;
|
|
244
|
+
Object.defineProperty(target, key, {
|
|
245
|
+
enumerable: true,
|
|
246
|
+
get() {
|
|
247
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
248
|
+
let v,
|
|
249
|
+
s = sources[i],
|
|
250
|
+
t = typeof s;
|
|
251
|
+
if (t === "function") s = s();
|
|
252
|
+
if (t === "object" && t !== null && key in s) return v;
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
});
|
|
256
|
+
}
|
|
333
257
|
}
|
|
334
258
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
if (
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
iAmp = s.indexOf("&", left);
|
|
347
|
-
}
|
|
348
|
-
return left < s.length ? out + s.substring(left) : out;
|
|
349
|
-
}
|
|
350
|
-
function resolveSSRNode(node) {
|
|
351
|
-
const t = typeof node;
|
|
352
|
-
if (t === "string") return node;
|
|
353
|
-
if (node == null || t === "boolean") return "";
|
|
354
|
-
if (Array.isArray(node)) {
|
|
355
|
-
let prev = {};
|
|
356
|
-
let mapped = "";
|
|
357
|
-
for (let i = 0, len = node.length; i < len; i++) {
|
|
358
|
-
if (typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
|
|
359
|
-
mapped += resolveSSRNode(prev = node[i]);
|
|
259
|
+
return target;
|
|
260
|
+
}
|
|
261
|
+
function omit(props, ...keys) {
|
|
262
|
+
const descriptors = Object.getOwnPropertyDescriptors(props),
|
|
263
|
+
descriptorKeys = Object.keys(descriptors),
|
|
264
|
+
clone = {};
|
|
265
|
+
for (let i = 0; i < descriptorKeys.length; i++) {
|
|
266
|
+
const key = descriptorKeys[i];
|
|
267
|
+
if (keys.indexOf(key) === -1) {
|
|
268
|
+
Object.defineProperty(clone, key, descriptors[key]);
|
|
269
|
+
delete descriptors[key];
|
|
360
270
|
}
|
|
361
|
-
return mapped;
|
|
362
271
|
}
|
|
363
|
-
|
|
364
|
-
if (t === "function") return resolveSSRNode(node());
|
|
365
|
-
return String(node);
|
|
272
|
+
return clone;
|
|
366
273
|
}
|
|
274
|
+
|
|
367
275
|
const sharedConfig = {
|
|
368
276
|
context: undefined,
|
|
369
277
|
getContextId() {
|
|
@@ -403,67 +311,20 @@ function createComponent(Comp, props) {
|
|
|
403
311
|
}
|
|
404
312
|
return Comp(props || {});
|
|
405
313
|
}
|
|
406
|
-
function mergeProps(...sources) {
|
|
407
|
-
const target = {};
|
|
408
|
-
for (let i = 0; i < sources.length; i++) {
|
|
409
|
-
let source = sources[i];
|
|
410
|
-
if (typeof source === "function") source = source();
|
|
411
|
-
if (source) {
|
|
412
|
-
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
413
|
-
for (const key in descriptors) {
|
|
414
|
-
if (key in target) continue;
|
|
415
|
-
Object.defineProperty(target, key, {
|
|
416
|
-
enumerable: true,
|
|
417
|
-
get() {
|
|
418
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
419
|
-
let v,
|
|
420
|
-
s = sources[i];
|
|
421
|
-
if (typeof s === "function") s = s();
|
|
422
|
-
v = (s || {})[key];
|
|
423
|
-
if (v !== undefined) return v;
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
});
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
return target;
|
|
431
|
-
}
|
|
432
|
-
function splitProps(props, ...keys) {
|
|
433
|
-
const descriptors = Object.getOwnPropertyDescriptors(props),
|
|
434
|
-
split = k => {
|
|
435
|
-
const clone = {};
|
|
436
|
-
for (let i = 0; i < k.length; i++) {
|
|
437
|
-
const key = k[i];
|
|
438
|
-
if (descriptors[key]) {
|
|
439
|
-
Object.defineProperty(clone, key, descriptors[key]);
|
|
440
|
-
delete descriptors[key];
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
return clone;
|
|
444
|
-
};
|
|
445
|
-
return keys.map(split).concat(split(Object.keys(descriptors)));
|
|
446
|
-
}
|
|
447
|
-
function simpleMap(props, wrap) {
|
|
448
|
-
const list = props.each || [],
|
|
449
|
-
len = list.length,
|
|
450
|
-
fn = props.children;
|
|
451
|
-
if (len) {
|
|
452
|
-
let mapped = Array(len);
|
|
453
|
-
for (let i = 0; i < len; i++) mapped[i] = wrap(fn, list[i], i);
|
|
454
|
-
return mapped;
|
|
455
|
-
}
|
|
456
|
-
return props.fallback;
|
|
457
|
-
}
|
|
458
314
|
function For(props) {
|
|
459
|
-
return
|
|
315
|
+
return mapArray(() => props.each, props.children, {
|
|
316
|
+
fallback: () => props.fallback
|
|
317
|
+
});
|
|
460
318
|
}
|
|
461
|
-
function
|
|
462
|
-
return
|
|
319
|
+
function Repeat(props) {
|
|
320
|
+
return repeat(() => props.count, index => props.children(index), {
|
|
321
|
+
fallback: () => props.fallback,
|
|
322
|
+
from: () => props.from
|
|
323
|
+
});
|
|
463
324
|
}
|
|
464
325
|
function Show(props) {
|
|
465
326
|
let c;
|
|
466
|
-
return props.when ? typeof (c = props.children) === "function" ? c(
|
|
327
|
+
return props.when ? typeof (c = props.children) === "function" ? c(() => props.when) : c : props.fallback || "";
|
|
467
328
|
}
|
|
468
329
|
function Switch(props) {
|
|
469
330
|
let conditions = props.children;
|
|
@@ -472,7 +333,7 @@ function Switch(props) {
|
|
|
472
333
|
const w = conditions[i].when;
|
|
473
334
|
if (w) {
|
|
474
335
|
const c = conditions[i].children;
|
|
475
|
-
return typeof c === "function" ? c(
|
|
336
|
+
return typeof c === "function" ? c(() => w) : c;
|
|
476
337
|
}
|
|
477
338
|
}
|
|
478
339
|
return props.fallback || "";
|
|
@@ -480,348 +341,87 @@ function Switch(props) {
|
|
|
480
341
|
function Match(props) {
|
|
481
342
|
return props;
|
|
482
343
|
}
|
|
483
|
-
function resetErrorBoundaries() {}
|
|
484
344
|
function ErrorBoundary(props) {
|
|
485
|
-
let error,
|
|
486
|
-
res,
|
|
487
|
-
clean,
|
|
488
|
-
sync = true;
|
|
489
|
-
const ctx = sharedConfig.context;
|
|
490
|
-
const id = sharedConfig.getContextId();
|
|
491
|
-
function displayFallback() {
|
|
492
|
-
cleanNode(clean);
|
|
493
|
-
ctx.serialize(id, error);
|
|
494
|
-
setHydrateContext({
|
|
495
|
-
...ctx,
|
|
496
|
-
count: 0
|
|
497
|
-
});
|
|
498
|
-
const f = props.fallback;
|
|
499
|
-
return typeof f === "function" && f.length ? f(error, () => {}) : f;
|
|
500
|
-
}
|
|
501
|
-
createMemo(() => {
|
|
502
|
-
clean = Owner;
|
|
503
|
-
return catchError(() => res = props.children, err => {
|
|
504
|
-
error = err;
|
|
505
|
-
!sync && ctx.replace("e" + id, displayFallback);
|
|
506
|
-
sync = true;
|
|
507
|
-
});
|
|
508
|
-
});
|
|
509
|
-
if (error) return displayFallback();
|
|
510
|
-
sync = false;
|
|
511
|
-
return {
|
|
512
|
-
t: `<!--!$e${id}-->${resolveSSRNode(escape(res))}<!--!$/e${id}-->`
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
|
-
const SuspenseContext = createContext();
|
|
516
|
-
let resourceContext = null;
|
|
517
|
-
function createResource(source, fetcher, options = {}) {
|
|
518
|
-
if (typeof fetcher !== "function") {
|
|
519
|
-
options = fetcher || {};
|
|
520
|
-
fetcher = source;
|
|
521
|
-
source = true;
|
|
522
|
-
}
|
|
523
|
-
const contexts = new Set();
|
|
524
|
-
const id = sharedConfig.getNextContextId();
|
|
525
|
-
let resource = {};
|
|
526
|
-
let value = options.storage ? options.storage(options.initialValue)[0]() : options.initialValue;
|
|
527
|
-
let p;
|
|
528
|
-
let error;
|
|
529
|
-
if (sharedConfig.context.async && options.ssrLoadFrom !== "initial") {
|
|
530
|
-
resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
|
|
531
|
-
if (resource.ref) {
|
|
532
|
-
if (!resource.data && !resource.ref[0].loading && !resource.ref[0].error) resource.ref[1].refetch();
|
|
533
|
-
return resource.ref;
|
|
534
|
-
}
|
|
535
|
-
}
|
|
536
|
-
const read = () => {
|
|
537
|
-
if (error) throw error;
|
|
538
|
-
const resolved = options.ssrLoadFrom !== "initial" && sharedConfig.context.async && "data" in sharedConfig.context.resources[id];
|
|
539
|
-
if (!resolved && resourceContext) resourceContext.push(id);
|
|
540
|
-
if (!resolved && read.loading) {
|
|
541
|
-
const ctx = useContext(SuspenseContext);
|
|
542
|
-
if (ctx) {
|
|
543
|
-
ctx.resources.set(id, read);
|
|
544
|
-
contexts.add(ctx);
|
|
545
|
-
}
|
|
546
|
-
}
|
|
547
|
-
return resolved ? sharedConfig.context.resources[id].data : value;
|
|
548
|
-
};
|
|
549
|
-
read.loading = false;
|
|
550
|
-
read.error = undefined;
|
|
551
|
-
read.state = "initialValue" in options ? "ready" : "unresolved";
|
|
552
|
-
Object.defineProperty(read, "latest", {
|
|
553
|
-
get() {
|
|
554
|
-
return read();
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
function load() {
|
|
558
|
-
const ctx = sharedConfig.context;
|
|
559
|
-
if (!ctx.async) return read.loading = !!(typeof source === "function" ? source() : source);
|
|
560
|
-
if (ctx.resources && id in ctx.resources && "data" in ctx.resources[id]) {
|
|
561
|
-
value = ctx.resources[id].data;
|
|
562
|
-
return;
|
|
563
|
-
}
|
|
564
|
-
let lookup;
|
|
565
|
-
try {
|
|
566
|
-
resourceContext = [];
|
|
567
|
-
lookup = typeof source === "function" ? source() : source;
|
|
568
|
-
if (resourceContext.length) return;
|
|
569
|
-
} finally {
|
|
570
|
-
resourceContext = null;
|
|
571
|
-
}
|
|
572
|
-
if (!p) {
|
|
573
|
-
if (lookup == null || lookup === false) return;
|
|
574
|
-
p = fetcher(lookup, {
|
|
575
|
-
value
|
|
576
|
-
});
|
|
577
|
-
}
|
|
578
|
-
if (p != undefined && typeof p === "object" && "then" in p) {
|
|
579
|
-
read.loading = true;
|
|
580
|
-
read.state = "pending";
|
|
581
|
-
p = p.then(res => {
|
|
582
|
-
read.loading = false;
|
|
583
|
-
read.state = "ready";
|
|
584
|
-
ctx.resources[id].data = res;
|
|
585
|
-
p = null;
|
|
586
|
-
notifySuspense(contexts);
|
|
587
|
-
return res;
|
|
588
|
-
}).catch(err => {
|
|
589
|
-
read.loading = false;
|
|
590
|
-
read.state = "errored";
|
|
591
|
-
read.error = error = castError(err);
|
|
592
|
-
p = null;
|
|
593
|
-
notifySuspense(contexts);
|
|
594
|
-
throw error;
|
|
595
|
-
});
|
|
596
|
-
if (ctx.serialize) ctx.serialize(id, p, options.deferStream);
|
|
597
|
-
return p;
|
|
598
|
-
}
|
|
599
|
-
ctx.resources[id].data = p;
|
|
600
|
-
if (ctx.serialize) ctx.serialize(id, p);
|
|
601
|
-
p = null;
|
|
602
|
-
return ctx.resources[id].data;
|
|
603
|
-
}
|
|
604
|
-
if (options.ssrLoadFrom !== "initial") load();
|
|
605
|
-
return resource.ref = [read, {
|
|
606
|
-
refetch: load,
|
|
607
|
-
mutate: v => value = v
|
|
608
|
-
}];
|
|
609
345
|
}
|
|
610
346
|
function lazy(fn) {
|
|
611
|
-
|
|
612
|
-
let load = id => {
|
|
613
|
-
if (!p) {
|
|
614
|
-
p = fn();
|
|
615
|
-
p.then(mod => p.resolved = mod.default);
|
|
616
|
-
if (id) sharedConfig.context.lazy[id] = p;
|
|
617
|
-
}
|
|
618
|
-
return p;
|
|
619
|
-
};
|
|
620
|
-
const contexts = new Set();
|
|
621
|
-
const wrap = props => {
|
|
622
|
-
const id = sharedConfig.context.id;
|
|
623
|
-
let ref = sharedConfig.context.lazy[id];
|
|
624
|
-
if (ref) p = ref;else load(id);
|
|
625
|
-
if (p.resolved) return p.resolved(props);
|
|
626
|
-
const ctx = useContext(SuspenseContext);
|
|
627
|
-
const track = {
|
|
628
|
-
loading: true,
|
|
629
|
-
error: undefined
|
|
630
|
-
};
|
|
631
|
-
if (ctx) {
|
|
632
|
-
ctx.resources.set(id, track);
|
|
633
|
-
contexts.add(ctx);
|
|
634
|
-
}
|
|
635
|
-
if (sharedConfig.context.async) {
|
|
636
|
-
sharedConfig.context.block(p.then(() => {
|
|
637
|
-
track.loading = false;
|
|
638
|
-
notifySuspense(contexts);
|
|
639
|
-
}));
|
|
640
|
-
}
|
|
641
|
-
return "";
|
|
642
|
-
};
|
|
643
|
-
wrap.preload = load;
|
|
644
|
-
return wrap;
|
|
347
|
+
return {};
|
|
645
348
|
}
|
|
646
|
-
function suspenseComplete(c) {
|
|
647
|
-
for (const r of c.resources.values()) {
|
|
648
|
-
if (r.loading) return false;
|
|
649
|
-
}
|
|
650
|
-
return true;
|
|
651
|
-
}
|
|
652
|
-
function notifySuspense(contexts) {
|
|
653
|
-
for (const c of contexts) {
|
|
654
|
-
if (!suspenseComplete(c)) {
|
|
655
|
-
continue;
|
|
656
|
-
}
|
|
657
|
-
c.completed();
|
|
658
|
-
contexts.delete(c);
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
function enableScheduling() {}
|
|
662
349
|
function enableHydration() {}
|
|
663
|
-
function startTransition(fn) {
|
|
664
|
-
fn();
|
|
665
|
-
}
|
|
666
|
-
function useTransition() {
|
|
667
|
-
return [() => false, fn => {
|
|
668
|
-
fn();
|
|
669
|
-
}];
|
|
670
|
-
}
|
|
671
|
-
function SuspenseList(props) {
|
|
672
|
-
return props.children;
|
|
673
|
-
}
|
|
674
350
|
function Suspense(props) {
|
|
675
|
-
let done;
|
|
676
|
-
const ctx = sharedConfig.context;
|
|
677
|
-
const id = sharedConfig.getContextId();
|
|
678
|
-
const o = createOwner();
|
|
679
|
-
const value = ctx.suspense[id] || (ctx.suspense[id] = {
|
|
680
|
-
resources: new Map(),
|
|
681
|
-
completed: () => {
|
|
682
|
-
const res = runSuspense();
|
|
683
|
-
if (suspenseComplete(value)) {
|
|
684
|
-
done(resolveSSRNode(escape(res)));
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
});
|
|
688
|
-
function suspenseError(err) {
|
|
689
|
-
if (!done || !done(undefined, err)) {
|
|
690
|
-
runWithOwner(o.owner, () => {
|
|
691
|
-
throw err;
|
|
692
|
-
});
|
|
693
|
-
}
|
|
694
|
-
}
|
|
695
|
-
function runSuspense() {
|
|
696
|
-
setHydrateContext({
|
|
697
|
-
...ctx,
|
|
698
|
-
count: 0
|
|
699
|
-
});
|
|
700
|
-
cleanNode(o);
|
|
701
|
-
return runWithOwner(o, () => createComponent(SuspenseContext.Provider, {
|
|
702
|
-
value,
|
|
703
|
-
get children() {
|
|
704
|
-
return catchError(() => props.children, suspenseError);
|
|
705
|
-
}
|
|
706
|
-
}));
|
|
707
|
-
}
|
|
708
|
-
const res = runSuspense();
|
|
709
|
-
if (suspenseComplete(value)) {
|
|
710
|
-
delete ctx.suspense[id];
|
|
711
|
-
return res;
|
|
712
|
-
}
|
|
713
|
-
done = ctx.async ? ctx.registerFragment(id) : undefined;
|
|
714
|
-
return catchError(() => {
|
|
715
|
-
if (ctx.async) {
|
|
716
|
-
setHydrateContext({
|
|
717
|
-
...ctx,
|
|
718
|
-
count: 0,
|
|
719
|
-
id: ctx.id + "0F",
|
|
720
|
-
noHydrate: true
|
|
721
|
-
});
|
|
722
|
-
const res = {
|
|
723
|
-
t: `<template id="pl-${id}"></template>${resolveSSRNode(escape(props.fallback))}<!--pl-${id}-->`
|
|
724
|
-
};
|
|
725
|
-
setHydrateContext(ctx);
|
|
726
|
-
return res;
|
|
727
|
-
}
|
|
728
|
-
setHydrateContext({
|
|
729
|
-
...ctx,
|
|
730
|
-
count: 0,
|
|
731
|
-
id: ctx.id + "0F"
|
|
732
|
-
});
|
|
733
|
-
ctx.serialize(id, "$$f");
|
|
734
|
-
return props.fallback;
|
|
735
|
-
}, suspenseError);
|
|
736
351
|
}
|
|
737
352
|
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
}
|
|
741
|
-
function unwrap(item) {
|
|
742
|
-
return item;
|
|
743
|
-
}
|
|
744
|
-
function setProperty(state, property, value) {
|
|
745
|
-
if (state[property] === value) return;
|
|
746
|
-
if (value === undefined) {
|
|
747
|
-
delete state[property];
|
|
748
|
-
} else state[property] = value;
|
|
749
|
-
}
|
|
750
|
-
function createStore(state) {
|
|
751
|
-
function setStore(fn) {
|
|
752
|
-
fn(state);
|
|
753
|
-
}
|
|
754
|
-
return [state, setStore];
|
|
755
|
-
}
|
|
756
|
-
function reconcile(value) {
|
|
757
|
-
return state => {
|
|
758
|
-
if (!isWrappable(state) || !isWrappable(value)) return value;
|
|
759
|
-
const targetKeys = Object.keys(value);
|
|
760
|
-
const previousKeys = Object.keys(state);
|
|
761
|
-
for (let i = 0, len = targetKeys.length; i < len; i++) {
|
|
762
|
-
const key = targetKeys[i];
|
|
763
|
-
setProperty(state, key, value[key]);
|
|
764
|
-
}
|
|
765
|
-
for (let i = 0, len = previousKeys.length; i < len; i++) {
|
|
766
|
-
if (value[previousKeys[i]] === undefined) setProperty(state, previousKeys[i], undefined);
|
|
767
|
-
}
|
|
768
|
-
return state;
|
|
769
|
-
};
|
|
770
|
-
}
|
|
353
|
+
const $DEVCOMP = Symbol("solid-dev-component");
|
|
354
|
+
const DEV = undefined;
|
|
771
355
|
|
|
356
|
+
Object.defineProperty(exports, "$PROXY", {
|
|
357
|
+
enumerable: true,
|
|
358
|
+
get: function () { return signals.$PROXY; }
|
|
359
|
+
});
|
|
360
|
+
Object.defineProperty(exports, "$RAW", {
|
|
361
|
+
enumerable: true,
|
|
362
|
+
get: function () { return signals.$RAW; }
|
|
363
|
+
});
|
|
364
|
+
Object.defineProperty(exports, "$TRACK", {
|
|
365
|
+
enumerable: true,
|
|
366
|
+
get: function () { return signals.$TRACK; }
|
|
367
|
+
});
|
|
368
|
+
Object.defineProperty(exports, "catchError", {
|
|
369
|
+
enumerable: true,
|
|
370
|
+
get: function () { return signals.catchError; }
|
|
371
|
+
});
|
|
372
|
+
Object.defineProperty(exports, "flatten", {
|
|
373
|
+
enumerable: true,
|
|
374
|
+
get: function () { return signals.flatten; }
|
|
375
|
+
});
|
|
376
|
+
Object.defineProperty(exports, "isEqual", {
|
|
377
|
+
enumerable: true,
|
|
378
|
+
get: function () { return signals.isEqual; }
|
|
379
|
+
});
|
|
380
|
+
Object.defineProperty(exports, "isWrappable", {
|
|
381
|
+
enumerable: true,
|
|
382
|
+
get: function () { return signals.isWrappable; }
|
|
383
|
+
});
|
|
772
384
|
exports.$DEVCOMP = $DEVCOMP;
|
|
773
|
-
exports.$PROXY = $PROXY;
|
|
774
|
-
exports.$TRACK = $TRACK;
|
|
775
385
|
exports.DEV = DEV;
|
|
776
386
|
exports.ErrorBoundary = ErrorBoundary;
|
|
777
387
|
exports.For = For;
|
|
778
|
-
exports.Index = Index;
|
|
779
388
|
exports.Match = Match;
|
|
389
|
+
exports.Repeat = Repeat;
|
|
780
390
|
exports.Show = Show;
|
|
781
391
|
exports.Suspense = Suspense;
|
|
782
|
-
exports.SuspenseList = SuspenseList;
|
|
783
392
|
exports.Switch = Switch;
|
|
784
|
-
exports.batch = batch;
|
|
785
|
-
exports.catchError = catchError;
|
|
786
393
|
exports.children = children;
|
|
394
|
+
exports.createAsync = createAsync;
|
|
787
395
|
exports.createComponent = createComponent;
|
|
788
396
|
exports.createContext = createContext;
|
|
789
|
-
exports.createDeferred = createDeferred;
|
|
790
397
|
exports.createEffect = createEffect;
|
|
791
398
|
exports.createMemo = createMemo;
|
|
792
|
-
exports.
|
|
399
|
+
exports.createProjection = createProjection;
|
|
793
400
|
exports.createRenderEffect = createRenderEffect;
|
|
794
|
-
exports.createResource = createResource;
|
|
795
401
|
exports.createRoot = createRoot;
|
|
796
|
-
exports.createSelector = createSelector;
|
|
797
402
|
exports.createSignal = createSignal;
|
|
798
403
|
exports.createStore = createStore;
|
|
799
404
|
exports.createUniqueId = createUniqueId;
|
|
800
|
-
exports.enableExternalSource = enableExternalSource;
|
|
801
405
|
exports.enableHydration = enableHydration;
|
|
802
|
-
exports.
|
|
803
|
-
exports.equalFn = equalFn;
|
|
406
|
+
exports.flushSync = flushSync;
|
|
804
407
|
exports.from = from;
|
|
805
|
-
exports.
|
|
408
|
+
exports.getObserver = getObserver;
|
|
806
409
|
exports.getOwner = getOwner;
|
|
807
|
-
exports.
|
|
808
|
-
exports.
|
|
410
|
+
exports.isPending = isPending;
|
|
411
|
+
exports.latest = latest;
|
|
809
412
|
exports.lazy = lazy;
|
|
810
413
|
exports.mapArray = mapArray;
|
|
811
|
-
exports.
|
|
414
|
+
exports.merge = merge;
|
|
812
415
|
exports.observable = observable;
|
|
813
|
-
exports.
|
|
416
|
+
exports.omit = omit;
|
|
814
417
|
exports.onCleanup = onCleanup;
|
|
815
|
-
exports.onError = onError;
|
|
816
418
|
exports.onMount = onMount;
|
|
817
419
|
exports.reconcile = reconcile;
|
|
818
|
-
exports.
|
|
819
|
-
exports.
|
|
420
|
+
exports.repeat = repeat;
|
|
421
|
+
exports.resolve = resolve;
|
|
422
|
+
exports.runWithObserver = runWithObserver;
|
|
820
423
|
exports.runWithOwner = runWithOwner;
|
|
821
424
|
exports.sharedConfig = sharedConfig;
|
|
822
|
-
exports.splitProps = splitProps;
|
|
823
|
-
exports.startTransition = startTransition;
|
|
824
425
|
exports.untrack = untrack;
|
|
825
426
|
exports.unwrap = unwrap;
|
|
826
427
|
exports.useContext = useContext;
|
|
827
|
-
exports.useTransition = useTransition;
|