solid-js 1.7.8 → 1.7.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/dist/dev.cjs +35 -19
- package/dist/dev.js +558 -309
- package/dist/server.cjs +38 -23
- package/dist/server.js +202 -94
- package/dist/solid.cjs +35 -19
- package/dist/solid.js +485 -267
- package/h/dist/h.cjs +2 -2
- package/h/dist/h.js +36 -10
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +11 -8
- package/h/jsx-runtime/types/jsx.d.ts +3 -0
- package/h/types/hyperscript.d.ts +11 -11
- package/h/types/index.d.ts +3 -2
- package/html/dist/html.cjs +2 -2
- package/html/dist/html.js +218 -96
- package/html/types/index.d.ts +3 -2
- package/html/types/lit.d.ts +45 -31
- package/package.json +1 -1
- package/store/dist/dev.cjs +36 -33
- package/store/dist/dev.js +143 -68
- package/store/dist/server.js +19 -8
- package/store/dist/store.cjs +36 -33
- package/store/dist/store.js +134 -65
- package/store/types/index.d.ts +21 -7
- package/store/types/modifiers.d.ts +6 -3
- package/store/types/mutable.d.ts +5 -2
- package/store/types/server.d.ts +12 -4
- package/store/types/store.d.ts +220 -63
- package/types/index.d.ts +72 -9
- package/types/jsx.d.ts +3 -0
- package/types/reactive/array.d.ts +12 -4
- package/types/reactive/observable.d.ts +25 -17
- package/types/reactive/scheduler.d.ts +9 -6
- package/types/reactive/signal.d.ts +237 -146
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +62 -31
- package/types/render/flow.d.ts +43 -31
- package/types/render/hydration.d.ts +12 -12
- package/types/server/index.d.ts +56 -2
- package/types/server/reactive.d.ts +71 -45
- package/types/server/rendering.d.ts +171 -95
- package/universal/dist/dev.js +28 -12
- package/universal/dist/universal.js +28 -12
- package/universal/types/index.d.ts +3 -1
- package/universal/types/universal.d.ts +0 -1
- package/web/dist/dev.js +610 -79
- package/web/dist/server.cjs +5 -1
- package/web/dist/server.js +181 -78
- package/web/dist/web.js +610 -79
- package/web/types/client.d.ts +2 -2
- package/web/types/core.d.ts +10 -1
- package/web/types/index.d.ts +27 -10
- package/web/types/server-mock.d.ts +47 -32
- package/web/types/server.d.ts +1 -1
package/dist/dev.js
CHANGED
|
@@ -52,9 +52,11 @@ function enqueue(taskQueue, task) {
|
|
|
52
52
|
let m = 0;
|
|
53
53
|
let n = taskQueue.length - 1;
|
|
54
54
|
while (m <= n) {
|
|
55
|
-
const k = n + m >> 1;
|
|
55
|
+
const k = (n + m) >> 1;
|
|
56
56
|
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
57
|
-
if (cmp > 0) m = k + 1;
|
|
57
|
+
if (cmp > 0) m = k + 1;
|
|
58
|
+
else if (cmp < 0) n = k - 1;
|
|
59
|
+
else return k;
|
|
58
60
|
}
|
|
59
61
|
return m;
|
|
60
62
|
}
|
|
@@ -159,25 +161,31 @@ const DevHooks = {
|
|
|
159
161
|
afterUpdate: null,
|
|
160
162
|
afterCreateOwner: null
|
|
161
163
|
};
|
|
162
|
-
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
164
|
+
const [transPending, setTransPending] = /*@__PURE__*/ createSignal(false);
|
|
163
165
|
function createRoot(fn, detachedOwner) {
|
|
164
166
|
const listener = Listener,
|
|
165
167
|
owner = Owner,
|
|
166
168
|
unowned = fn.length === 0,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
169
|
+
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
170
|
+
root = unowned
|
|
171
|
+
? {
|
|
172
|
+
owned: null,
|
|
173
|
+
cleanups: null,
|
|
174
|
+
context: null,
|
|
175
|
+
owner: null
|
|
176
|
+
}
|
|
177
|
+
: {
|
|
178
|
+
owned: null,
|
|
179
|
+
cleanups: null,
|
|
180
|
+
context: current ? current.context : null,
|
|
181
|
+
owner: current
|
|
182
|
+
},
|
|
183
|
+
updateFn = unowned
|
|
184
|
+
? () =>
|
|
185
|
+
fn(() => {
|
|
186
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
187
|
+
})
|
|
188
|
+
: () => fn(() => untrack(() => cleanNode(root)));
|
|
181
189
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
182
190
|
Owner = root;
|
|
183
191
|
Listener = null;
|
|
@@ -202,35 +210,44 @@ function createSignal(value, options) {
|
|
|
202
210
|
}
|
|
203
211
|
const setter = value => {
|
|
204
212
|
if (typeof value === "function") {
|
|
205
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
213
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
214
|
+
else value = value(s.value);
|
|
206
215
|
}
|
|
207
216
|
return writeSignal(s, value);
|
|
208
217
|
};
|
|
209
218
|
return [readSignal.bind(s), setter];
|
|
210
219
|
}
|
|
211
220
|
function createComputed(fn, value, options) {
|
|
212
|
-
const c = createComputation(fn, value, true, STALE, options
|
|
213
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
221
|
+
const c = createComputation(fn, value, true, STALE, options);
|
|
222
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
223
|
+
else updateComputation(c);
|
|
214
224
|
}
|
|
215
225
|
function createRenderEffect(fn, value, options) {
|
|
216
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
217
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
226
|
+
const c = createComputation(fn, value, false, STALE, options);
|
|
227
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
228
|
+
else updateComputation(c);
|
|
218
229
|
}
|
|
219
230
|
function createEffect(fn, value, options) {
|
|
220
231
|
runEffects = runUserEffects;
|
|
221
|
-
const c = createComputation(fn, value, false, STALE, options
|
|
222
|
-
s = SuspenseContext &&
|
|
232
|
+
const c = createComputation(fn, value, false, STALE, options),
|
|
233
|
+
s = SuspenseContext && useContext(SuspenseContext);
|
|
223
234
|
if (s) c.suspense = s;
|
|
224
235
|
if (!options || !options.render) c.user = true;
|
|
225
236
|
Effects ? Effects.push(c) : updateComputation(c);
|
|
226
237
|
}
|
|
227
238
|
function createReaction(onInvalidate, options) {
|
|
228
239
|
let fn;
|
|
229
|
-
const c = createComputation(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
240
|
+
const c = createComputation(
|
|
241
|
+
() => {
|
|
242
|
+
fn ? fn() : untrack(onInvalidate);
|
|
243
|
+
fn = undefined;
|
|
244
|
+
},
|
|
245
|
+
undefined,
|
|
246
|
+
false,
|
|
247
|
+
0,
|
|
248
|
+
options
|
|
249
|
+
),
|
|
250
|
+
s = SuspenseContext && useContext(SuspenseContext);
|
|
234
251
|
if (s) c.suspense = s;
|
|
235
252
|
c.user = true;
|
|
236
253
|
return tracking => {
|
|
@@ -240,7 +257,7 @@ function createReaction(onInvalidate, options) {
|
|
|
240
257
|
}
|
|
241
258
|
function createMemo(fn, value, options) {
|
|
242
259
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
243
|
-
const c = createComputation(fn, value, true, 0, options
|
|
260
|
+
const c = createComputation(fn, value, true, 0, options);
|
|
244
261
|
c.observers = null;
|
|
245
262
|
c.observerSlots = null;
|
|
246
263
|
c.comparator = options.equals || undefined;
|
|
@@ -254,7 +271,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
254
271
|
let source;
|
|
255
272
|
let fetcher;
|
|
256
273
|
let options;
|
|
257
|
-
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
274
|
+
if ((arguments.length === 2 && typeof pFetcher === "object") || arguments.length === 1) {
|
|
258
275
|
source = true;
|
|
259
276
|
fetcher = pSource;
|
|
260
277
|
options = pFetcher || {};
|
|
@@ -268,7 +285,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
268
285
|
id = null,
|
|
269
286
|
loadedUnderTransition = false,
|
|
270
287
|
scheduled = false,
|
|
271
|
-
resolved =
|
|
288
|
+
resolved = "initialValue" in options,
|
|
272
289
|
dynamic = typeof source === "function" && createMemo(source);
|
|
273
290
|
const contexts = new Set(),
|
|
274
291
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -280,15 +297,19 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
280
297
|
if (sharedConfig.context) {
|
|
281
298
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
282
299
|
let v;
|
|
283
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
300
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
301
|
+
else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = v[0];
|
|
284
302
|
}
|
|
285
303
|
function loadEnd(p, v, error, key) {
|
|
286
304
|
if (pr === p) {
|
|
287
305
|
pr = null;
|
|
288
306
|
key !== undefined && (resolved = true);
|
|
289
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
290
|
-
|
|
291
|
-
|
|
307
|
+
if ((p === initP || v === initP) && options.onHydrated)
|
|
308
|
+
queueMicrotask(() =>
|
|
309
|
+
options.onHydrated(key, {
|
|
310
|
+
value: v
|
|
311
|
+
})
|
|
312
|
+
);
|
|
292
313
|
initP = NO_INIT;
|
|
293
314
|
if (Transition && p && loadedUnderTransition) {
|
|
294
315
|
Transition.promises.delete(p);
|
|
@@ -311,7 +332,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
311
332
|
}, false);
|
|
312
333
|
}
|
|
313
334
|
function read() {
|
|
314
|
-
const c = SuspenseContext &&
|
|
335
|
+
const c = SuspenseContext && useContext(SuspenseContext),
|
|
315
336
|
v = value(),
|
|
316
337
|
err = error();
|
|
317
338
|
if (err !== undefined && !pr) throw err;
|
|
@@ -319,7 +340,8 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
319
340
|
createComputed(() => {
|
|
320
341
|
track();
|
|
321
342
|
if (pr) {
|
|
322
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
343
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
344
|
+
else if (!contexts.has(c)) {
|
|
323
345
|
c.increment();
|
|
324
346
|
contexts.add(c);
|
|
325
347
|
}
|
|
@@ -338,22 +360,30 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
338
360
|
return;
|
|
339
361
|
}
|
|
340
362
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
341
|
-
const p =
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
363
|
+
const p =
|
|
364
|
+
initP !== NO_INIT
|
|
365
|
+
? initP
|
|
366
|
+
: untrack(() =>
|
|
367
|
+
fetcher(lookup, {
|
|
368
|
+
value: value(),
|
|
369
|
+
refetching
|
|
370
|
+
})
|
|
371
|
+
);
|
|
345
372
|
if (typeof p !== "object" || !(p && "then" in p)) {
|
|
346
373
|
loadEnd(pr, p, undefined, lookup);
|
|
347
374
|
return p;
|
|
348
375
|
}
|
|
349
376
|
pr = p;
|
|
350
377
|
scheduled = true;
|
|
351
|
-
queueMicrotask(() => scheduled = false);
|
|
378
|
+
queueMicrotask(() => (scheduled = false));
|
|
352
379
|
runUpdates(() => {
|
|
353
380
|
setState(resolved ? "refreshing" : "pending");
|
|
354
381
|
trigger();
|
|
355
382
|
}, false);
|
|
356
|
-
return p.then(
|
|
383
|
+
return p.then(
|
|
384
|
+
v => loadEnd(p, v, undefined, lookup),
|
|
385
|
+
e => loadEnd(p, undefined, castError(e), lookup)
|
|
386
|
+
);
|
|
357
387
|
}
|
|
358
388
|
Object.defineProperties(read, {
|
|
359
389
|
state: {
|
|
@@ -377,21 +407,35 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
377
407
|
}
|
|
378
408
|
}
|
|
379
409
|
});
|
|
380
|
-
if (dynamic) createComputed(() => load(false));
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
410
|
+
if (dynamic) createComputed(() => load(false));
|
|
411
|
+
else load(false);
|
|
412
|
+
return [
|
|
413
|
+
read,
|
|
414
|
+
{
|
|
415
|
+
refetch: load,
|
|
416
|
+
mutate: setValue
|
|
417
|
+
}
|
|
418
|
+
];
|
|
385
419
|
}
|
|
386
420
|
function createDeferred(source, options) {
|
|
387
421
|
let t,
|
|
388
422
|
timeout = options ? options.timeoutMs : undefined;
|
|
389
|
-
const node = createComputation(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
423
|
+
const node = createComputation(
|
|
424
|
+
() => {
|
|
425
|
+
if (!t || !t.fn)
|
|
426
|
+
t = requestCallback(
|
|
427
|
+
() => setDeferred(() => node.value),
|
|
428
|
+
timeout !== undefined
|
|
429
|
+
? {
|
|
430
|
+
timeout
|
|
431
|
+
}
|
|
432
|
+
: undefined
|
|
433
|
+
);
|
|
434
|
+
return source();
|
|
435
|
+
},
|
|
436
|
+
undefined,
|
|
437
|
+
true
|
|
438
|
+
);
|
|
395
439
|
const [deferred, setDeferred] = createSignal(node.value, options);
|
|
396
440
|
updateComputation(node);
|
|
397
441
|
setDeferred(() => node.value);
|
|
@@ -399,28 +443,40 @@ function createDeferred(source, options) {
|
|
|
399
443
|
}
|
|
400
444
|
function createSelector(source, fn = equalFn, options) {
|
|
401
445
|
const subs = new Map();
|
|
402
|
-
const node = createComputation(
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
for (const
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
446
|
+
const node = createComputation(
|
|
447
|
+
p => {
|
|
448
|
+
const v = source();
|
|
449
|
+
for (const [key, val] of subs.entries())
|
|
450
|
+
if (fn(key, v) !== fn(key, p)) {
|
|
451
|
+
for (const c of val.values()) {
|
|
452
|
+
c.state = STALE;
|
|
453
|
+
if (c.pure) Updates.push(c);
|
|
454
|
+
else Effects.push(c);
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
return v;
|
|
458
|
+
},
|
|
459
|
+
undefined,
|
|
460
|
+
true,
|
|
461
|
+
STALE,
|
|
462
|
+
options
|
|
463
|
+
);
|
|
412
464
|
updateComputation(node);
|
|
413
465
|
return key => {
|
|
414
466
|
const listener = Listener;
|
|
415
467
|
if (listener) {
|
|
416
468
|
let l;
|
|
417
|
-
if (l = subs.get(key)) l.add(listener);
|
|
469
|
+
if ((l = subs.get(key))) l.add(listener);
|
|
470
|
+
else subs.set(key, (l = new Set([listener])));
|
|
418
471
|
onCleanup(() => {
|
|
419
472
|
l.delete(listener);
|
|
420
473
|
!l.size && subs.delete(key);
|
|
421
474
|
});
|
|
422
475
|
}
|
|
423
|
-
return fn(
|
|
476
|
+
return fn(
|
|
477
|
+
key,
|
|
478
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
479
|
+
);
|
|
424
480
|
};
|
|
425
481
|
}
|
|
426
482
|
function batch(fn) {
|
|
@@ -459,13 +515,17 @@ function onMount(fn) {
|
|
|
459
515
|
createEffect(() => untrack(fn));
|
|
460
516
|
}
|
|
461
517
|
function onCleanup(fn) {
|
|
462
|
-
if (Owner === null)
|
|
518
|
+
if (Owner === null)
|
|
519
|
+
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
520
|
+
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
521
|
+
else Owner.cleanups.push(fn);
|
|
463
522
|
return fn;
|
|
464
523
|
}
|
|
465
524
|
function catchError(fn, handler) {
|
|
466
525
|
ERROR || (ERROR = Symbol("error"));
|
|
467
526
|
Owner = createComputation(undefined, undefined, true);
|
|
468
527
|
Owner.context = {
|
|
528
|
+
...Owner.context,
|
|
469
529
|
[ERROR]: [handler]
|
|
470
530
|
};
|
|
471
531
|
if (Transition && Transition.running) Transition.sources.add(Owner);
|
|
@@ -477,12 +537,6 @@ function catchError(fn, handler) {
|
|
|
477
537
|
Owner = Owner.owner;
|
|
478
538
|
}
|
|
479
539
|
}
|
|
480
|
-
function onError(fn) {
|
|
481
|
-
ERROR || (ERROR = Symbol("error"));
|
|
482
|
-
if (Owner === null) console.warn("error handlers created outside a `createRoot` or `render` will never be run");else if (Owner.context === null) Owner.context = {
|
|
483
|
-
[ERROR]: [fn]
|
|
484
|
-
};else if (!Owner.context[ERROR]) Owner.context[ERROR] = [fn];else Owner.context[ERROR].push(fn);
|
|
485
|
-
}
|
|
486
540
|
function getListener() {
|
|
487
541
|
return Listener;
|
|
488
542
|
}
|
|
@@ -518,15 +572,17 @@ function startTransition(fn) {
|
|
|
518
572
|
Owner = o;
|
|
519
573
|
let t;
|
|
520
574
|
if (Scheduler || SuspenseContext) {
|
|
521
|
-
t =
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
575
|
+
t =
|
|
576
|
+
Transition ||
|
|
577
|
+
(Transition = {
|
|
578
|
+
sources: new Set(),
|
|
579
|
+
effects: [],
|
|
580
|
+
promises: new Set(),
|
|
581
|
+
disposed: new Set(),
|
|
582
|
+
queue: new Set(),
|
|
583
|
+
running: true
|
|
584
|
+
});
|
|
585
|
+
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
530
586
|
t.running = true;
|
|
531
587
|
}
|
|
532
588
|
runUpdates(fn, false);
|
|
@@ -542,12 +598,18 @@ function resumeEffects(e) {
|
|
|
542
598
|
e.length = 0;
|
|
543
599
|
}
|
|
544
600
|
function devComponent(Comp, props) {
|
|
545
|
-
const c = createComputation(
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
601
|
+
const c = createComputation(
|
|
602
|
+
() =>
|
|
603
|
+
untrack(() => {
|
|
604
|
+
Object.assign(Comp, {
|
|
605
|
+
[$DEVCOMP]: true
|
|
606
|
+
});
|
|
607
|
+
return Comp(props);
|
|
608
|
+
}),
|
|
609
|
+
undefined,
|
|
610
|
+
true,
|
|
611
|
+
0
|
|
612
|
+
);
|
|
551
613
|
c.props = props;
|
|
552
614
|
c.observers = null;
|
|
553
615
|
c.observerSlots = null;
|
|
@@ -558,7 +620,8 @@ function devComponent(Comp, props) {
|
|
|
558
620
|
}
|
|
559
621
|
function registerGraph(value) {
|
|
560
622
|
if (!Owner) return;
|
|
561
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
623
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
624
|
+
else Owner.sourceMap = [value];
|
|
562
625
|
value.graph = Owner;
|
|
563
626
|
}
|
|
564
627
|
function createContext(defaultValue, options) {
|
|
@@ -570,14 +633,15 @@ function createContext(defaultValue, options) {
|
|
|
570
633
|
};
|
|
571
634
|
}
|
|
572
635
|
function useContext(context) {
|
|
573
|
-
|
|
574
|
-
|
|
636
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
637
|
+
? Owner.context[context.id]
|
|
638
|
+
: context.defaultValue;
|
|
575
639
|
}
|
|
576
640
|
function children(fn) {
|
|
577
641
|
const children = createMemo(fn);
|
|
578
642
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
579
643
|
name: "children"
|
|
580
|
-
})
|
|
644
|
+
});
|
|
581
645
|
memo.toArray = () => {
|
|
582
646
|
const c = memo();
|
|
583
647
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -609,7 +673,8 @@ function enableExternalSource(factory) {
|
|
|
609
673
|
function readSignal() {
|
|
610
674
|
const runningTransition = Transition && Transition.running;
|
|
611
675
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
612
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
676
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
677
|
+
else {
|
|
613
678
|
const updates = Updates;
|
|
614
679
|
Updates = null;
|
|
615
680
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -637,11 +702,12 @@ function readSignal() {
|
|
|
637
702
|
return this.value;
|
|
638
703
|
}
|
|
639
704
|
function writeSignal(node, value, isComp) {
|
|
640
|
-
let current =
|
|
705
|
+
let current =
|
|
706
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
641
707
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
642
708
|
if (Transition) {
|
|
643
709
|
const TransitionRunning = Transition.running;
|
|
644
|
-
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
710
|
+
if (TransitionRunning || (!isComp && Transition.sources.has(node))) {
|
|
645
711
|
Transition.sources.add(node);
|
|
646
712
|
node.tValue = value;
|
|
647
713
|
}
|
|
@@ -654,10 +720,12 @@ function writeSignal(node, value, isComp) {
|
|
|
654
720
|
const TransitionRunning = Transition && Transition.running;
|
|
655
721
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
656
722
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
657
|
-
if (o.pure) Updates.push(o);
|
|
723
|
+
if (o.pure) Updates.push(o);
|
|
724
|
+
else Effects.push(o);
|
|
658
725
|
if (o.observers) markDownstream(o);
|
|
659
726
|
}
|
|
660
|
-
if (!TransitionRunning) o.state = STALE;
|
|
727
|
+
if (!TransitionRunning) o.state = STALE;
|
|
728
|
+
else o.tState = STALE;
|
|
661
729
|
}
|
|
662
730
|
if (Updates.length > 10e5) {
|
|
663
731
|
Updates = [];
|
|
@@ -676,7 +744,11 @@ function updateComputation(node) {
|
|
|
676
744
|
listener = Listener,
|
|
677
745
|
time = ExecCount;
|
|
678
746
|
Listener = Owner = node;
|
|
679
|
-
runComputation(
|
|
747
|
+
runComputation(
|
|
748
|
+
node,
|
|
749
|
+
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
750
|
+
time
|
|
751
|
+
);
|
|
680
752
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
681
753
|
queueMicrotask(() => {
|
|
682
754
|
runUpdates(() => {
|
|
@@ -730,18 +802,22 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
730
802
|
cleanups: null,
|
|
731
803
|
value: init,
|
|
732
804
|
owner: Owner,
|
|
733
|
-
context: null,
|
|
805
|
+
context: Owner ? Owner.context : null,
|
|
734
806
|
pure
|
|
735
807
|
};
|
|
736
808
|
if (Transition && Transition.running) {
|
|
737
809
|
c.state = 0;
|
|
738
810
|
c.tState = state;
|
|
739
811
|
}
|
|
740
|
-
if (Owner === null)
|
|
812
|
+
if (Owner === null)
|
|
813
|
+
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
814
|
+
else if (Owner !== UNOWNED) {
|
|
741
815
|
if (Transition && Transition.running && Owner.pure) {
|
|
742
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
816
|
+
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
817
|
+
else Owner.tOwned.push(c);
|
|
743
818
|
} else {
|
|
744
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
819
|
+
if (!Owner.owned) Owner.owned = [c];
|
|
820
|
+
else Owner.owned.push(c);
|
|
745
821
|
}
|
|
746
822
|
}
|
|
747
823
|
if (options && options.name) c.name = options.name;
|
|
@@ -794,7 +870,8 @@ function runUpdates(fn, init) {
|
|
|
794
870
|
if (Updates) return fn();
|
|
795
871
|
let wait = false;
|
|
796
872
|
if (!init) Updates = [];
|
|
797
|
-
if (Effects) wait = true;
|
|
873
|
+
if (Effects) wait = true;
|
|
874
|
+
else Effects = [];
|
|
798
875
|
ExecCount++;
|
|
799
876
|
try {
|
|
800
877
|
const res = fn();
|
|
@@ -808,7 +885,8 @@ function runUpdates(fn, init) {
|
|
|
808
885
|
}
|
|
809
886
|
function completeUpdates(wait) {
|
|
810
887
|
if (Updates) {
|
|
811
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
888
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
889
|
+
else runQueue(Updates);
|
|
812
890
|
Updates = null;
|
|
813
891
|
}
|
|
814
892
|
if (wait) return;
|
|
@@ -848,7 +926,8 @@ function completeUpdates(wait) {
|
|
|
848
926
|
}
|
|
849
927
|
const e = Effects;
|
|
850
928
|
Effects = null;
|
|
851
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
929
|
+
if (e.length) runUpdates(() => runEffects(e), false);
|
|
930
|
+
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
852
931
|
if (res) res();
|
|
853
932
|
}
|
|
854
933
|
function runQueue(queue) {
|
|
@@ -876,7 +955,8 @@ function runUserEffects(queue) {
|
|
|
876
955
|
userLength = 0;
|
|
877
956
|
for (i = 0; i < queue.length; i++) {
|
|
878
957
|
const e = queue[i];
|
|
879
|
-
if (!e.user) runTop(e);
|
|
958
|
+
if (!e.user) runTop(e);
|
|
959
|
+
else queue[userLength++] = e;
|
|
880
960
|
}
|
|
881
961
|
if (sharedConfig.context) {
|
|
882
962
|
if (sharedConfig.count) {
|
|
@@ -894,13 +974,15 @@ function runUserEffects(queue) {
|
|
|
894
974
|
}
|
|
895
975
|
function lookUpstream(node, ignore) {
|
|
896
976
|
const runningTransition = Transition && Transition.running;
|
|
897
|
-
if (runningTransition) node.tState = 0;
|
|
977
|
+
if (runningTransition) node.tState = 0;
|
|
978
|
+
else node.state = 0;
|
|
898
979
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
899
980
|
const source = node.sources[i];
|
|
900
981
|
if (source.sources) {
|
|
901
982
|
const state = runningTransition ? source.tState : source.state;
|
|
902
983
|
if (state === STALE) {
|
|
903
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
984
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
985
|
+
runTop(source);
|
|
904
986
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
905
987
|
}
|
|
906
988
|
}
|
|
@@ -910,8 +992,10 @@ function markDownstream(node) {
|
|
|
910
992
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
911
993
|
const o = node.observers[i];
|
|
912
994
|
if (runningTransition ? !o.tState : !o.state) {
|
|
913
|
-
if (runningTransition) o.tState = PENDING;
|
|
914
|
-
|
|
995
|
+
if (runningTransition) o.tState = PENDING;
|
|
996
|
+
else o.state = PENDING;
|
|
997
|
+
if (o.pure) Updates.push(o);
|
|
998
|
+
else Effects.push(o);
|
|
915
999
|
o.observers && markDownstream(o);
|
|
916
1000
|
}
|
|
917
1001
|
}
|
|
@@ -948,8 +1032,8 @@ function cleanNode(node) {
|
|
|
948
1032
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
949
1033
|
node.cleanups = null;
|
|
950
1034
|
}
|
|
951
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
952
|
-
node.
|
|
1035
|
+
if (Transition && Transition.running) node.tState = 0;
|
|
1036
|
+
else node.state = 0;
|
|
953
1037
|
delete node.sourceMap;
|
|
954
1038
|
}
|
|
955
1039
|
function reset(node, top) {
|
|
@@ -971,22 +1055,21 @@ function runErrors(err, fns, owner) {
|
|
|
971
1055
|
try {
|
|
972
1056
|
for (const f of fns) f(err);
|
|
973
1057
|
} catch (e) {
|
|
974
|
-
handleError(e, owner && owner.owner || null);
|
|
1058
|
+
handleError(e, (owner && owner.owner) || null);
|
|
975
1059
|
}
|
|
976
1060
|
}
|
|
977
1061
|
function handleError(err, owner = Owner) {
|
|
978
|
-
const fns = ERROR &&
|
|
1062
|
+
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
979
1063
|
const error = castError(err);
|
|
980
1064
|
if (!fns) throw error;
|
|
981
|
-
if (Effects)
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
}
|
|
988
|
-
|
|
989
|
-
return owner ? owner.context && owner.context[key] !== undefined ? owner.context[key] : lookup(owner.owner, key) : undefined;
|
|
1065
|
+
if (Effects)
|
|
1066
|
+
Effects.push({
|
|
1067
|
+
fn() {
|
|
1068
|
+
runErrors(error, fns, owner);
|
|
1069
|
+
},
|
|
1070
|
+
state: STALE
|
|
1071
|
+
});
|
|
1072
|
+
else runErrors(error, fns, owner);
|
|
990
1073
|
}
|
|
991
1074
|
function resolveChildren(children) {
|
|
992
1075
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1003,15 +1086,47 @@ function resolveChildren(children) {
|
|
|
1003
1086
|
function createProvider(id, options) {
|
|
1004
1087
|
return function provider(props) {
|
|
1005
1088
|
let res;
|
|
1006
|
-
createRenderEffect(
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1089
|
+
createRenderEffect(
|
|
1090
|
+
() =>
|
|
1091
|
+
(res = untrack(() => {
|
|
1092
|
+
Owner.context = {
|
|
1093
|
+
...Owner.context,
|
|
1094
|
+
[id]: props.value
|
|
1095
|
+
};
|
|
1096
|
+
return children(() => props.children);
|
|
1097
|
+
})),
|
|
1098
|
+
undefined,
|
|
1099
|
+
options
|
|
1100
|
+
);
|
|
1012
1101
|
return res;
|
|
1013
1102
|
};
|
|
1014
1103
|
}
|
|
1104
|
+
function onError(fn) {
|
|
1105
|
+
ERROR || (ERROR = Symbol("error"));
|
|
1106
|
+
if (Owner === null)
|
|
1107
|
+
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1108
|
+
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1109
|
+
Owner.context = {
|
|
1110
|
+
...Owner.context,
|
|
1111
|
+
[ERROR]: [fn]
|
|
1112
|
+
};
|
|
1113
|
+
mutateContext(Owner, ERROR, [fn]);
|
|
1114
|
+
} else Owner.context[ERROR].push(fn);
|
|
1115
|
+
}
|
|
1116
|
+
function mutateContext(o, key, value) {
|
|
1117
|
+
if (o.owned) {
|
|
1118
|
+
for (let i = 0; i < o.owned.length; i++) {
|
|
1119
|
+
if (o.owned[i].context === o.context) mutateContext(o.owned[i], key, value);
|
|
1120
|
+
if (!o.owned[i].context) {
|
|
1121
|
+
o.owned[i].context = o.context;
|
|
1122
|
+
mutateContext(o.owned[i], key, value);
|
|
1123
|
+
} else if (!o.owned[i].context[key]) {
|
|
1124
|
+
o.owned[i].context[key] = value;
|
|
1125
|
+
mutateContext(o.owned[i], key, value);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1015
1130
|
|
|
1016
1131
|
function observable(input) {
|
|
1017
1132
|
return {
|
|
@@ -1019,7 +1134,8 @@ function observable(input) {
|
|
|
1019
1134
|
if (!(observer instanceof Object) || observer == null) {
|
|
1020
1135
|
throw new TypeError("Expected the observer to be an object.");
|
|
1021
1136
|
}
|
|
1022
|
-
const handler =
|
|
1137
|
+
const handler =
|
|
1138
|
+
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1023
1139
|
if (!handler) {
|
|
1024
1140
|
return {
|
|
1025
1141
|
unsubscribe() {}
|
|
@@ -1050,7 +1166,7 @@ function from(producer) {
|
|
|
1050
1166
|
});
|
|
1051
1167
|
if ("subscribe" in producer) {
|
|
1052
1168
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1053
|
-
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1169
|
+
onCleanup(() => ("unsubscribe" in unsub ? unsub.unsubscribe() : unsub()));
|
|
1054
1170
|
} else {
|
|
1055
1171
|
const clean = producer(set);
|
|
1056
1172
|
onCleanup(clean);
|
|
@@ -1102,8 +1218,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1102
1218
|
});
|
|
1103
1219
|
len = 1;
|
|
1104
1220
|
}
|
|
1105
|
-
}
|
|
1106
|
-
else if (len === 0) {
|
|
1221
|
+
} else if (len === 0) {
|
|
1107
1222
|
mapped = new Array(newLen);
|
|
1108
1223
|
for (j = 0; j < newLen; j++) {
|
|
1109
1224
|
items[j] = newItems[j];
|
|
@@ -1114,8 +1229,16 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1114
1229
|
temp = new Array(newLen);
|
|
1115
1230
|
tempdisposers = new Array(newLen);
|
|
1116
1231
|
indexes && (tempIndexes = new Array(newLen));
|
|
1117
|
-
for (
|
|
1118
|
-
|
|
1232
|
+
for (
|
|
1233
|
+
start = 0, end = Math.min(len, newLen);
|
|
1234
|
+
start < end && items[start] === newItems[start];
|
|
1235
|
+
start++
|
|
1236
|
+
);
|
|
1237
|
+
for (
|
|
1238
|
+
end = len - 1, newEnd = newLen - 1;
|
|
1239
|
+
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1240
|
+
end--, newEnd--
|
|
1241
|
+
) {
|
|
1119
1242
|
temp[newEnd] = mapped[end];
|
|
1120
1243
|
tempdisposers[newEnd] = disposers[end];
|
|
1121
1244
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1149,7 +1272,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1149
1272
|
}
|
|
1150
1273
|
} else mapped[j] = createRoot(mapper);
|
|
1151
1274
|
}
|
|
1152
|
-
mapped = mapped.slice(0, len = newLen);
|
|
1275
|
+
mapped = mapped.slice(0, (len = newLen));
|
|
1153
1276
|
items = newItems.slice(0);
|
|
1154
1277
|
}
|
|
1155
1278
|
return mapped;
|
|
@@ -1159,7 +1282,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1159
1282
|
if (indexes) {
|
|
1160
1283
|
const [s, set] = createSignal(j, {
|
|
1161
1284
|
name: "index"
|
|
1162
|
-
})
|
|
1285
|
+
});
|
|
1163
1286
|
indexes[j] = set;
|
|
1164
1287
|
return mapFn(newItems[j], s);
|
|
1165
1288
|
}
|
|
@@ -1217,13 +1340,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1217
1340
|
}
|
|
1218
1341
|
len = signals.length = disposers.length = newItems.length;
|
|
1219
1342
|
items = newItems.slice(0);
|
|
1220
|
-
return mapped = mapped.slice(0, len);
|
|
1343
|
+
return (mapped = mapped.slice(0, len));
|
|
1221
1344
|
});
|
|
1222
1345
|
function mapper(disposer) {
|
|
1223
1346
|
disposers[i] = disposer;
|
|
1224
1347
|
const [s, set] = createSignal(newItems[i], {
|
|
1225
1348
|
name: "value"
|
|
1226
|
-
})
|
|
1349
|
+
});
|
|
1227
1350
|
signals[i] = set;
|
|
1228
1351
|
return mapFn(s, i);
|
|
1229
1352
|
}
|
|
@@ -1239,7 +1362,7 @@ function createComponent(Comp, props) {
|
|
|
1239
1362
|
if (sharedConfig.context) {
|
|
1240
1363
|
const c = sharedConfig.context;
|
|
1241
1364
|
setHydrateContext(nextHydrateContext());
|
|
1242
|
-
const r = devComponent(Comp, props || {})
|
|
1365
|
+
const r = devComponent(Comp, props || {});
|
|
1243
1366
|
setHydrateContext(c);
|
|
1244
1367
|
return r;
|
|
1245
1368
|
}
|
|
@@ -1288,29 +1411,33 @@ function mergeProps(...sources) {
|
|
|
1288
1411
|
let proxy = false;
|
|
1289
1412
|
for (let i = 0; i < sources.length; i++) {
|
|
1290
1413
|
const s = sources[i];
|
|
1291
|
-
proxy = proxy || !!s && $PROXY in s;
|
|
1292
|
-
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1414
|
+
proxy = proxy || (!!s && $PROXY in s);
|
|
1415
|
+
sources[i] = typeof s === "function" ? ((proxy = true), createMemo(s)) : s;
|
|
1293
1416
|
}
|
|
1294
1417
|
if (proxy) {
|
|
1295
|
-
return new Proxy(
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1418
|
+
return new Proxy(
|
|
1419
|
+
{
|
|
1420
|
+
get(property) {
|
|
1421
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1422
|
+
const v = resolveSource(sources[i])[property];
|
|
1423
|
+
if (v !== undefined) return v;
|
|
1424
|
+
}
|
|
1425
|
+
},
|
|
1426
|
+
has(property) {
|
|
1427
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1428
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1429
|
+
}
|
|
1430
|
+
return false;
|
|
1431
|
+
},
|
|
1432
|
+
keys() {
|
|
1433
|
+
const keys = [];
|
|
1434
|
+
for (let i = 0; i < sources.length; i++)
|
|
1435
|
+
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1436
|
+
return [...new Set(keys)];
|
|
1305
1437
|
}
|
|
1306
|
-
return false;
|
|
1307
1438
|
},
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1311
|
-
return [...new Set(keys)];
|
|
1312
|
-
}
|
|
1313
|
-
}, propTraps);
|
|
1439
|
+
propTraps
|
|
1440
|
+
);
|
|
1314
1441
|
}
|
|
1315
1442
|
const target = {};
|
|
1316
1443
|
const sourcesMap = {};
|
|
@@ -1329,7 +1456,7 @@ function mergeProps(...sources) {
|
|
|
1329
1456
|
Object.defineProperty(target, key, {
|
|
1330
1457
|
enumerable: true,
|
|
1331
1458
|
configurable: true,
|
|
1332
|
-
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1459
|
+
get: resolveSources.bind((sourcesMap[key] = [desc.get.bind(source)]))
|
|
1333
1460
|
});
|
|
1334
1461
|
} else {
|
|
1335
1462
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1353,47 +1480,60 @@ function splitProps(props, ...keys) {
|
|
|
1353
1480
|
if ($PROXY in props) {
|
|
1354
1481
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1355
1482
|
const res = keys.map(k => {
|
|
1356
|
-
return new Proxy(
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1483
|
+
return new Proxy(
|
|
1484
|
+
{
|
|
1485
|
+
get(property) {
|
|
1486
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1487
|
+
},
|
|
1488
|
+
has(property) {
|
|
1489
|
+
return k.includes(property) && property in props;
|
|
1490
|
+
},
|
|
1491
|
+
keys() {
|
|
1492
|
+
return k.filter(property => property in props);
|
|
1493
|
+
}
|
|
1362
1494
|
},
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1366
|
-
}, propTraps);
|
|
1495
|
+
propTraps
|
|
1496
|
+
);
|
|
1367
1497
|
});
|
|
1368
|
-
res.push(
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1498
|
+
res.push(
|
|
1499
|
+
new Proxy(
|
|
1500
|
+
{
|
|
1501
|
+
get(property) {
|
|
1502
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1503
|
+
},
|
|
1504
|
+
has(property) {
|
|
1505
|
+
return blocked.has(property) ? false : property in props;
|
|
1506
|
+
},
|
|
1507
|
+
keys() {
|
|
1508
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1509
|
+
}
|
|
1510
|
+
},
|
|
1511
|
+
propTraps
|
|
1512
|
+
)
|
|
1513
|
+
);
|
|
1379
1514
|
return res;
|
|
1380
1515
|
}
|
|
1381
1516
|
const otherObject = {};
|
|
1382
1517
|
const objects = keys.map(() => ({}));
|
|
1383
1518
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1384
1519
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1385
|
-
const isDefaultDesc =
|
|
1520
|
+
const isDefaultDesc =
|
|
1521
|
+
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1386
1522
|
let blocked = false;
|
|
1387
1523
|
let objectIndex = 0;
|
|
1388
1524
|
for (const k of keys) {
|
|
1389
1525
|
if (k.includes(propName)) {
|
|
1390
1526
|
blocked = true;
|
|
1391
|
-
isDefaultDesc
|
|
1527
|
+
isDefaultDesc
|
|
1528
|
+
? (objects[objectIndex][propName] = desc.value)
|
|
1529
|
+
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1392
1530
|
}
|
|
1393
1531
|
++objectIndex;
|
|
1394
1532
|
}
|
|
1395
1533
|
if (!blocked) {
|
|
1396
|
-
isDefaultDesc
|
|
1534
|
+
isDefaultDesc
|
|
1535
|
+
? (otherObject[propName] = desc.value)
|
|
1536
|
+
: Object.defineProperty(otherObject, propName, desc);
|
|
1397
1537
|
}
|
|
1398
1538
|
}
|
|
1399
1539
|
return [...objects, otherObject];
|
|
@@ -1419,19 +1559,24 @@ function lazy(fn) {
|
|
|
1419
1559
|
comp = s;
|
|
1420
1560
|
}
|
|
1421
1561
|
let Comp;
|
|
1422
|
-
return createMemo(
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1562
|
+
return createMemo(
|
|
1563
|
+
() =>
|
|
1564
|
+
(Comp = comp()) &&
|
|
1565
|
+
untrack(() => {
|
|
1566
|
+
if (true)
|
|
1567
|
+
Object.assign(Comp, {
|
|
1568
|
+
[$DEVCOMP]: true
|
|
1569
|
+
});
|
|
1570
|
+
if (!ctx) return Comp(props);
|
|
1571
|
+
const c = sharedConfig.context;
|
|
1572
|
+
setHydrateContext(ctx);
|
|
1573
|
+
const r = Comp(props);
|
|
1574
|
+
setHydrateContext(c);
|
|
1575
|
+
return r;
|
|
1576
|
+
})
|
|
1577
|
+
);
|
|
1433
1578
|
};
|
|
1434
|
-
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1579
|
+
wrap.preload = () => p || ((p = fn()).then(mod => (comp = () => mod.default)), p);
|
|
1435
1580
|
return wrap;
|
|
1436
1581
|
}
|
|
1437
1582
|
let counter = 0;
|
|
@@ -1440,75 +1585,113 @@ function createUniqueId() {
|
|
|
1440
1585
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1441
1586
|
}
|
|
1442
1587
|
|
|
1443
|
-
const narrowedError = name =>
|
|
1588
|
+
const narrowedError = name =>
|
|
1589
|
+
`Attempting to access a stale value from <${name}> that could possibly be undefined. This may occur because you are reading the accessor returned from the component at a time where it has already been unmounted. We recommend cleaning up any stale timers or async, or reading from the initial condition.`;
|
|
1444
1590
|
function For(props) {
|
|
1445
1591
|
const fallback = "fallback" in props && {
|
|
1446
1592
|
fallback: () => props.fallback
|
|
1447
1593
|
};
|
|
1448
|
-
return createMemo(
|
|
1449
|
-
|
|
1450
|
-
|
|
1594
|
+
return createMemo(
|
|
1595
|
+
mapArray(() => props.each, props.children, fallback || undefined),
|
|
1596
|
+
undefined,
|
|
1597
|
+
{
|
|
1598
|
+
name: "value"
|
|
1599
|
+
}
|
|
1600
|
+
);
|
|
1451
1601
|
}
|
|
1452
1602
|
function Index(props) {
|
|
1453
1603
|
const fallback = "fallback" in props && {
|
|
1454
1604
|
fallback: () => props.fallback
|
|
1455
1605
|
};
|
|
1456
|
-
return createMemo(
|
|
1457
|
-
|
|
1458
|
-
|
|
1606
|
+
return createMemo(
|
|
1607
|
+
indexArray(() => props.each, props.children, fallback || undefined),
|
|
1608
|
+
undefined,
|
|
1609
|
+
{
|
|
1610
|
+
name: "value"
|
|
1611
|
+
}
|
|
1612
|
+
);
|
|
1459
1613
|
}
|
|
1460
1614
|
function Show(props) {
|
|
1461
1615
|
const keyed = props.keyed;
|
|
1462
1616
|
const condition = createMemo(() => props.when, undefined, {
|
|
1463
|
-
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1617
|
+
equals: (a, b) => (keyed ? a === b : !a === !b),
|
|
1464
1618
|
name: "condition"
|
|
1465
|
-
}
|
|
1466
|
-
return createMemo(
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1619
|
+
});
|
|
1620
|
+
return createMemo(
|
|
1621
|
+
() => {
|
|
1622
|
+
const c = condition();
|
|
1623
|
+
if (c) {
|
|
1624
|
+
const child = props.children;
|
|
1625
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1626
|
+
return fn
|
|
1627
|
+
? untrack(() =>
|
|
1628
|
+
child(
|
|
1629
|
+
keyed
|
|
1630
|
+
? c
|
|
1631
|
+
: () => {
|
|
1632
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1633
|
+
return props.when;
|
|
1634
|
+
}
|
|
1635
|
+
)
|
|
1636
|
+
)
|
|
1637
|
+
: child;
|
|
1638
|
+
}
|
|
1639
|
+
return props.fallback;
|
|
1640
|
+
},
|
|
1641
|
+
undefined,
|
|
1642
|
+
{
|
|
1643
|
+
name: "value"
|
|
1475
1644
|
}
|
|
1476
|
-
|
|
1477
|
-
}, undefined, {
|
|
1478
|
-
name: "value"
|
|
1479
|
-
} );
|
|
1645
|
+
);
|
|
1480
1646
|
}
|
|
1481
1647
|
function Switch(props) {
|
|
1482
1648
|
let keyed = false;
|
|
1483
|
-
const equals = (a, b) =>
|
|
1649
|
+
const equals = (a, b) =>
|
|
1650
|
+
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1484
1651
|
const conditions = children(() => props.children),
|
|
1485
|
-
evalConditions = createMemo(
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1652
|
+
evalConditions = createMemo(
|
|
1653
|
+
() => {
|
|
1654
|
+
let conds = conditions();
|
|
1655
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1656
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1657
|
+
const c = conds[i].when;
|
|
1658
|
+
if (c) {
|
|
1659
|
+
keyed = !!conds[i].keyed;
|
|
1660
|
+
return [i, c, conds[i]];
|
|
1661
|
+
}
|
|
1493
1662
|
}
|
|
1663
|
+
return [-1];
|
|
1664
|
+
},
|
|
1665
|
+
undefined,
|
|
1666
|
+
{
|
|
1667
|
+
equals,
|
|
1668
|
+
name: "eval conditions"
|
|
1494
1669
|
}
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1670
|
+
);
|
|
1671
|
+
return createMemo(
|
|
1672
|
+
() => {
|
|
1673
|
+
const [index, when, cond] = evalConditions();
|
|
1674
|
+
if (index < 0) return props.fallback;
|
|
1675
|
+
const c = cond.children;
|
|
1676
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1677
|
+
return fn
|
|
1678
|
+
? untrack(() =>
|
|
1679
|
+
c(
|
|
1680
|
+
keyed
|
|
1681
|
+
? when
|
|
1682
|
+
: () => {
|
|
1683
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1684
|
+
return cond.when;
|
|
1685
|
+
}
|
|
1686
|
+
)
|
|
1687
|
+
)
|
|
1688
|
+
: c;
|
|
1689
|
+
},
|
|
1690
|
+
undefined,
|
|
1691
|
+
{
|
|
1692
|
+
name: "value"
|
|
1693
|
+
}
|
|
1694
|
+
);
|
|
1512
1695
|
}
|
|
1513
1696
|
function Match(props) {
|
|
1514
1697
|
return props;
|
|
@@ -1520,27 +1703,37 @@ function resetErrorBoundaries() {
|
|
|
1520
1703
|
function ErrorBoundary(props) {
|
|
1521
1704
|
let err;
|
|
1522
1705
|
let v;
|
|
1523
|
-
if (
|
|
1706
|
+
if (
|
|
1707
|
+
sharedConfig.context &&
|
|
1708
|
+
sharedConfig.load &&
|
|
1709
|
+
(v = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count))
|
|
1710
|
+
)
|
|
1711
|
+
err = v[0];
|
|
1524
1712
|
const [errored, setErrored] = createSignal(err, {
|
|
1525
1713
|
name: "errored"
|
|
1526
|
-
}
|
|
1714
|
+
});
|
|
1527
1715
|
Errors || (Errors = new Set());
|
|
1528
1716
|
Errors.add(setErrored);
|
|
1529
1717
|
onCleanup(() => Errors.delete(setErrored));
|
|
1530
|
-
return createMemo(
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1718
|
+
return createMemo(
|
|
1719
|
+
() => {
|
|
1720
|
+
let e;
|
|
1721
|
+
if ((e = errored())) {
|
|
1722
|
+
const f = props.fallback;
|
|
1723
|
+
if (typeof f !== "function" || f.length == 0) console.error(e);
|
|
1724
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1725
|
+
}
|
|
1726
|
+
return catchError(() => props.children, setErrored);
|
|
1727
|
+
},
|
|
1728
|
+
undefined,
|
|
1729
|
+
{
|
|
1730
|
+
name: "value"
|
|
1536
1731
|
}
|
|
1537
|
-
|
|
1538
|
-
}, undefined, {
|
|
1539
|
-
name: "value"
|
|
1540
|
-
} );
|
|
1732
|
+
);
|
|
1541
1733
|
}
|
|
1542
1734
|
|
|
1543
|
-
const suspenseListEquals = (a, b) =>
|
|
1735
|
+
const suspenseListEquals = (a, b) =>
|
|
1736
|
+
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1544
1737
|
const SuspenseListContext = createContext();
|
|
1545
1738
|
function SuspenseList(props) {
|
|
1546
1739
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1552,51 +1745,51 @@ function SuspenseList(props) {
|
|
|
1552
1745
|
if (listContext) {
|
|
1553
1746
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1554
1747
|
}
|
|
1555
|
-
const resolved = createMemo(
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
showContent = true,
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
const res = reg.map(() => ({
|
|
1567
|
-
showContent: all && showContent,
|
|
1568
|
-
showFallback
|
|
1569
|
-
}));
|
|
1570
|
-
res.inFallback = !all;
|
|
1571
|
-
return res;
|
|
1572
|
-
}
|
|
1573
|
-
let stop = false;
|
|
1574
|
-
let inFallback = prev.inFallback;
|
|
1575
|
-
const res = [];
|
|
1576
|
-
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1577
|
-
const n = reverse ? len - i - 1 : i,
|
|
1578
|
-
s = reg[n]();
|
|
1579
|
-
if (!stop && !s) {
|
|
1580
|
-
res[n] = {
|
|
1581
|
-
showContent,
|
|
1748
|
+
const resolved = createMemo(
|
|
1749
|
+
prev => {
|
|
1750
|
+
const reveal = props.revealOrder,
|
|
1751
|
+
tail = props.tail,
|
|
1752
|
+
{ showContent = true, showFallback = true } = show ? show() : {},
|
|
1753
|
+
reg = registry(),
|
|
1754
|
+
reverse = reveal === "backwards";
|
|
1755
|
+
if (reveal === "together") {
|
|
1756
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1757
|
+
const res = reg.map(() => ({
|
|
1758
|
+
showContent: all && showContent,
|
|
1582
1759
|
showFallback
|
|
1583
|
-
};
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1760
|
+
}));
|
|
1761
|
+
res.inFallback = !all;
|
|
1762
|
+
return res;
|
|
1763
|
+
}
|
|
1764
|
+
let stop = false;
|
|
1765
|
+
let inFallback = prev.inFallback;
|
|
1766
|
+
const res = [];
|
|
1767
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1768
|
+
const n = reverse ? len - i - 1 : i,
|
|
1769
|
+
s = reg[n]();
|
|
1770
|
+
if (!stop && !s) {
|
|
1771
|
+
res[n] = {
|
|
1772
|
+
showContent,
|
|
1773
|
+
showFallback
|
|
1774
|
+
};
|
|
1775
|
+
} else {
|
|
1776
|
+
const next = !stop;
|
|
1777
|
+
if (next) inFallback = true;
|
|
1778
|
+
res[n] = {
|
|
1779
|
+
showContent: next,
|
|
1780
|
+
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1781
|
+
};
|
|
1782
|
+
stop = true;
|
|
1783
|
+
}
|
|
1592
1784
|
}
|
|
1785
|
+
if (!stop) inFallback = false;
|
|
1786
|
+
res.inFallback = inFallback;
|
|
1787
|
+
return res;
|
|
1788
|
+
},
|
|
1789
|
+
{
|
|
1790
|
+
inFallback: false
|
|
1593
1791
|
}
|
|
1594
|
-
|
|
1595
|
-
res.inFallback = inFallback;
|
|
1596
|
-
return res;
|
|
1597
|
-
}, {
|
|
1598
|
-
inFallback: false
|
|
1599
|
-
});
|
|
1792
|
+
);
|
|
1600
1793
|
setWrapper(() => resolved);
|
|
1601
1794
|
return createComponent(SuspenseListContext.Provider, {
|
|
1602
1795
|
value: {
|
|
@@ -1670,17 +1863,14 @@ function Suspense(props) {
|
|
|
1670
1863
|
ctx = sharedConfig.context;
|
|
1671
1864
|
if (flicker) {
|
|
1672
1865
|
flicker();
|
|
1673
|
-
return flicker = undefined;
|
|
1866
|
+
return (flicker = undefined);
|
|
1674
1867
|
}
|
|
1675
1868
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1676
1869
|
const rendered = createMemo(() => props.children);
|
|
1677
1870
|
return createMemo(prev => {
|
|
1678
1871
|
const inFallback = store.inFallback(),
|
|
1679
|
-
{
|
|
1680
|
-
|
|
1681
|
-
showFallback = true
|
|
1682
|
-
} = show ? show() : {};
|
|
1683
|
-
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1872
|
+
{ showContent = true, showFallback = true } = show ? show() : {};
|
|
1873
|
+
if ((!inFallback || (p && p !== "$$f")) && showContent) {
|
|
1684
1874
|
store.resolved = true;
|
|
1685
1875
|
dispose && dispose();
|
|
1686
1876
|
dispose = ctx = p = undefined;
|
|
@@ -1710,9 +1900,68 @@ const DEV = {
|
|
|
1710
1900
|
hooks: DevHooks,
|
|
1711
1901
|
writeSignal,
|
|
1712
1902
|
registerGraph
|
|
1713
|
-
}
|
|
1903
|
+
};
|
|
1714
1904
|
if (globalThis) {
|
|
1715
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1905
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1906
|
+
else
|
|
1907
|
+
console.warn(
|
|
1908
|
+
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1909
|
+
);
|
|
1716
1910
|
}
|
|
1717
1911
|
|
|
1718
|
-
export {
|
|
1912
|
+
export {
|
|
1913
|
+
$DEVCOMP,
|
|
1914
|
+
$PROXY,
|
|
1915
|
+
$TRACK,
|
|
1916
|
+
DEV,
|
|
1917
|
+
ErrorBoundary,
|
|
1918
|
+
For,
|
|
1919
|
+
Index,
|
|
1920
|
+
Match,
|
|
1921
|
+
Show,
|
|
1922
|
+
Suspense,
|
|
1923
|
+
SuspenseList,
|
|
1924
|
+
Switch,
|
|
1925
|
+
batch,
|
|
1926
|
+
cancelCallback,
|
|
1927
|
+
catchError,
|
|
1928
|
+
children,
|
|
1929
|
+
createComponent,
|
|
1930
|
+
createComputed,
|
|
1931
|
+
createContext,
|
|
1932
|
+
createDeferred,
|
|
1933
|
+
createEffect,
|
|
1934
|
+
createMemo,
|
|
1935
|
+
createReaction,
|
|
1936
|
+
createRenderEffect,
|
|
1937
|
+
createResource,
|
|
1938
|
+
createRoot,
|
|
1939
|
+
createSelector,
|
|
1940
|
+
createSignal,
|
|
1941
|
+
createUniqueId,
|
|
1942
|
+
enableExternalSource,
|
|
1943
|
+
enableHydration,
|
|
1944
|
+
enableScheduling,
|
|
1945
|
+
equalFn,
|
|
1946
|
+
from,
|
|
1947
|
+
getListener,
|
|
1948
|
+
getOwner,
|
|
1949
|
+
indexArray,
|
|
1950
|
+
lazy,
|
|
1951
|
+
mapArray,
|
|
1952
|
+
mergeProps,
|
|
1953
|
+
observable,
|
|
1954
|
+
on,
|
|
1955
|
+
onCleanup,
|
|
1956
|
+
onError,
|
|
1957
|
+
onMount,
|
|
1958
|
+
requestCallback,
|
|
1959
|
+
resetErrorBoundaries,
|
|
1960
|
+
runWithOwner,
|
|
1961
|
+
sharedConfig,
|
|
1962
|
+
splitProps,
|
|
1963
|
+
startTransition,
|
|
1964
|
+
untrack,
|
|
1965
|
+
useContext,
|
|
1966
|
+
useTransition
|
|
1967
|
+
};
|