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