solid-js 1.8.0-beta.1 → 1.8.0-beta.2
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.js +297 -532
- package/dist/server.js +74 -168
- package/dist/solid.js +255 -459
- package/h/dist/h.js +8 -34
- package/h/jsx-runtime/dist/jsx.js +1 -1
- package/h/jsx-runtime/types/index.d.ts +8 -11
- package/h/jsx-runtime/types/jsx.d.ts +19 -5
- package/h/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -216
- package/html/types/lit.d.ts +31 -45
- package/package.json +1 -1
- package/store/dist/dev.js +42 -114
- package/store/dist/server.js +8 -19
- package/store/dist/store.js +39 -105
- package/store/types/index.d.ts +7 -21
- package/store/types/modifiers.d.ts +3 -6
- package/store/types/mutable.d.ts +2 -5
- package/store/types/server.d.ts +4 -12
- package/store/types/store.d.ts +61 -218
- package/types/index.d.ts +9 -72
- package/types/jsx.d.ts +19 -5
- package/types/reactive/array.d.ts +4 -12
- package/types/reactive/observable.d.ts +17 -25
- package/types/reactive/scheduler.d.ts +6 -9
- package/types/reactive/signal.d.ts +140 -228
- package/types/render/Suspense.d.ts +5 -5
- package/types/render/component.d.ts +31 -62
- package/types/render/flow.d.ts +31 -43
- package/types/render/hydration.d.ts +13 -13
- package/types/server/index.d.ts +2 -56
- package/types/server/reactive.d.ts +40 -67
- package/types/server/rendering.d.ts +95 -166
- package/universal/dist/dev.js +12 -28
- package/universal/dist/universal.js +12 -28
- package/universal/types/index.d.ts +1 -3
- package/universal/types/universal.d.ts +1 -0
- package/web/dist/dev.cjs +11 -4
- package/web/dist/dev.js +89 -614
- package/web/dist/server.js +92 -175
- package/web/dist/web.cjs +11 -4
- package/web/dist/web.js +89 -614
- package/web/types/client.d.ts +3 -3
- package/web/types/core.d.ts +1 -10
- package/web/types/index.d.ts +10 -27
- package/web/types/server-mock.d.ts +32 -47
package/dist/dev.js
CHANGED
|
@@ -52,11 +52,9 @@ function enqueue(taskQueue, task) {
|
|
|
52
52
|
let m = 0;
|
|
53
53
|
let n = taskQueue.length - 1;
|
|
54
54
|
while (m <= n) {
|
|
55
|
-
const k =
|
|
55
|
+
const k = n + m >> 1;
|
|
56
56
|
const cmp = task.expirationTime - taskQueue[k].expirationTime;
|
|
57
|
-
if (cmp > 0) m = k + 1;
|
|
58
|
-
else if (cmp < 0) n = k - 1;
|
|
59
|
-
else return k;
|
|
57
|
+
if (cmp > 0) m = k + 1;else if (cmp < 0) n = k - 1;else return k;
|
|
60
58
|
}
|
|
61
59
|
return m;
|
|
62
60
|
}
|
|
@@ -161,31 +159,26 @@ const DevHooks = {
|
|
|
161
159
|
afterUpdate: null,
|
|
162
160
|
afterCreateOwner: null
|
|
163
161
|
};
|
|
164
|
-
const [transPending, setTransPending] = /*@__PURE__*/
|
|
162
|
+
const [transPending, setTransPending] = /*@__PURE__*/createSignal(false);
|
|
165
163
|
function createRoot(fn, detachedOwner) {
|
|
166
164
|
const listener = Listener,
|
|
167
165
|
owner = Owner,
|
|
168
166
|
unowned = fn.length === 0,
|
|
169
167
|
current = detachedOwner === undefined ? owner : detachedOwner,
|
|
170
|
-
root = unowned
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
:
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
? () =>
|
|
185
|
-
fn(() => {
|
|
186
|
-
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
187
|
-
})
|
|
188
|
-
: () => fn(() => untrack(() => cleanNode(root)));
|
|
168
|
+
root = unowned ? {
|
|
169
|
+
owned: null,
|
|
170
|
+
cleanups: null,
|
|
171
|
+
context: null,
|
|
172
|
+
owner: null
|
|
173
|
+
} : {
|
|
174
|
+
owned: null,
|
|
175
|
+
cleanups: null,
|
|
176
|
+
context: current ? current.context : null,
|
|
177
|
+
owner: current
|
|
178
|
+
},
|
|
179
|
+
updateFn = unowned ? () => fn(() => {
|
|
180
|
+
throw new Error("Dispose method must be an explicit argument to createRoot function");
|
|
181
|
+
}) : () => fn(() => untrack(() => cleanNode(root)));
|
|
189
182
|
DevHooks.afterCreateOwner && DevHooks.afterCreateOwner(root);
|
|
190
183
|
Owner = root;
|
|
191
184
|
Listener = null;
|
|
@@ -210,26 +203,23 @@ function createSignal(value, options) {
|
|
|
210
203
|
}
|
|
211
204
|
const setter = value => {
|
|
212
205
|
if (typeof value === "function") {
|
|
213
|
-
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);
|
|
214
|
-
else value = value(s.value);
|
|
206
|
+
if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.tValue);else value = value(s.value);
|
|
215
207
|
}
|
|
216
208
|
return writeSignal(s, value);
|
|
217
209
|
};
|
|
218
210
|
return [readSignal.bind(s), setter];
|
|
219
211
|
}
|
|
220
212
|
function createComputed(fn, value, options) {
|
|
221
|
-
const c = createComputation(fn, value, true, STALE, options);
|
|
222
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
223
|
-
else updateComputation(c);
|
|
213
|
+
const c = createComputation(fn, value, true, STALE, options );
|
|
214
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
224
215
|
}
|
|
225
216
|
function createRenderEffect(fn, value, options) {
|
|
226
|
-
const c = createComputation(fn, value, false, STALE, options);
|
|
227
|
-
if (Scheduler && Transition && Transition.running) Updates.push(c);
|
|
228
|
-
else updateComputation(c);
|
|
217
|
+
const c = createComputation(fn, value, false, STALE, options );
|
|
218
|
+
if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
|
|
229
219
|
}
|
|
230
220
|
function createEffect(fn, value, options) {
|
|
231
221
|
runEffects = runUserEffects;
|
|
232
|
-
const c = createComputation(fn, value, false, STALE, options),
|
|
222
|
+
const c = createComputation(fn, value, false, STALE, options ),
|
|
233
223
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
234
224
|
if (s) c.suspense = s;
|
|
235
225
|
if (!options || !options.render) c.user = true;
|
|
@@ -237,16 +227,10 @@ function createEffect(fn, value, options) {
|
|
|
237
227
|
}
|
|
238
228
|
function createReaction(onInvalidate, options) {
|
|
239
229
|
let fn;
|
|
240
|
-
const c = createComputation(
|
|
241
|
-
()
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
},
|
|
245
|
-
undefined,
|
|
246
|
-
false,
|
|
247
|
-
0,
|
|
248
|
-
options
|
|
249
|
-
),
|
|
230
|
+
const c = createComputation(() => {
|
|
231
|
+
fn ? fn() : untrack(onInvalidate);
|
|
232
|
+
fn = undefined;
|
|
233
|
+
}, undefined, false, 0, options ),
|
|
250
234
|
s = SuspenseContext && useContext(SuspenseContext);
|
|
251
235
|
if (s) c.suspense = s;
|
|
252
236
|
c.user = true;
|
|
@@ -257,7 +241,7 @@ function createReaction(onInvalidate, options) {
|
|
|
257
241
|
}
|
|
258
242
|
function createMemo(fn, value, options) {
|
|
259
243
|
options = options ? Object.assign({}, signalOptions, options) : signalOptions;
|
|
260
|
-
const c = createComputation(fn, value, true, 0, options);
|
|
244
|
+
const c = createComputation(fn, value, true, 0, options );
|
|
261
245
|
c.observers = null;
|
|
262
246
|
c.observerSlots = null;
|
|
263
247
|
c.comparator = options.equals || undefined;
|
|
@@ -274,7 +258,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
274
258
|
let source;
|
|
275
259
|
let fetcher;
|
|
276
260
|
let options;
|
|
277
|
-
if (
|
|
261
|
+
if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
|
|
278
262
|
source = true;
|
|
279
263
|
fetcher = pSource;
|
|
280
264
|
options = pFetcher || {};
|
|
@@ -288,7 +272,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
288
272
|
id = null,
|
|
289
273
|
loadedUnderTransition = false,
|
|
290
274
|
scheduled = false,
|
|
291
|
-
resolved = "initialValue" in options,
|
|
275
|
+
resolved = ("initialValue" in options),
|
|
292
276
|
dynamic = typeof source === "function" && createMemo(source);
|
|
293
277
|
const contexts = new Set(),
|
|
294
278
|
[value, setValue] = (options.storage || createSignal)(options.initialValue),
|
|
@@ -300,20 +284,15 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
300
284
|
if (sharedConfig.context) {
|
|
301
285
|
id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
|
|
302
286
|
let v;
|
|
303
|
-
if (options.ssrLoadFrom === "initial") initP = options.initialValue;
|
|
304
|
-
else if (sharedConfig.load && (v = sharedConfig.load(id)))
|
|
305
|
-
initP = isPromise(v) && "value" in v ? v.value : v;
|
|
287
|
+
if (options.ssrLoadFrom === "initial") initP = options.initialValue;else if (sharedConfig.load && (v = sharedConfig.load(id))) initP = isPromise(v) && "value" in v ? v.value : v;
|
|
306
288
|
}
|
|
307
289
|
function loadEnd(p, v, error, key) {
|
|
308
290
|
if (pr === p) {
|
|
309
291
|
pr = null;
|
|
310
292
|
key !== undefined && (resolved = true);
|
|
311
|
-
if ((p === initP || v === initP) && options.onHydrated)
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
value: v
|
|
315
|
-
})
|
|
316
|
-
);
|
|
293
|
+
if ((p === initP || v === initP) && options.onHydrated) queueMicrotask(() => options.onHydrated(key, {
|
|
294
|
+
value: v
|
|
295
|
+
}));
|
|
317
296
|
initP = NO_INIT;
|
|
318
297
|
if (Transition && p && loadedUnderTransition) {
|
|
319
298
|
Transition.promises.delete(p);
|
|
@@ -344,8 +323,7 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
344
323
|
createComputed(() => {
|
|
345
324
|
track();
|
|
346
325
|
if (pr) {
|
|
347
|
-
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);
|
|
348
|
-
else if (!contexts.has(c)) {
|
|
326
|
+
if (c.resolved && Transition && loadedUnderTransition) Transition.promises.add(pr);else if (!contexts.has(c)) {
|
|
349
327
|
c.increment();
|
|
350
328
|
contexts.add(c);
|
|
351
329
|
}
|
|
@@ -364,30 +342,22 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
364
342
|
return;
|
|
365
343
|
}
|
|
366
344
|
if (Transition && pr) Transition.promises.delete(pr);
|
|
367
|
-
const p =
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
fetcher(lookup, {
|
|
372
|
-
value: value(),
|
|
373
|
-
refetching
|
|
374
|
-
})
|
|
375
|
-
);
|
|
345
|
+
const p = initP !== NO_INIT ? initP : untrack(() => fetcher(lookup, {
|
|
346
|
+
value: value(),
|
|
347
|
+
refetching
|
|
348
|
+
}));
|
|
376
349
|
if (!isPromise(p)) {
|
|
377
350
|
loadEnd(pr, p, undefined, lookup);
|
|
378
351
|
return p;
|
|
379
352
|
}
|
|
380
353
|
pr = p;
|
|
381
354
|
scheduled = true;
|
|
382
|
-
queueMicrotask(() =>
|
|
355
|
+
queueMicrotask(() => scheduled = false);
|
|
383
356
|
runUpdates(() => {
|
|
384
357
|
setState(resolved ? "refreshing" : "pending");
|
|
385
358
|
trigger();
|
|
386
359
|
}, false);
|
|
387
|
-
return p.then(
|
|
388
|
-
v => loadEnd(p, v, undefined, lookup),
|
|
389
|
-
e => loadEnd(p, undefined, castError(e), lookup)
|
|
390
|
-
);
|
|
360
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
|
|
391
361
|
}
|
|
392
362
|
Object.defineProperties(read, {
|
|
393
363
|
state: {
|
|
@@ -411,81 +381,50 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
411
381
|
}
|
|
412
382
|
}
|
|
413
383
|
});
|
|
414
|
-
if (dynamic) createComputed(() => load(false));
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
refetch: load,
|
|
420
|
-
mutate: setValue
|
|
421
|
-
}
|
|
422
|
-
];
|
|
384
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
385
|
+
return [read, {
|
|
386
|
+
refetch: load,
|
|
387
|
+
mutate: setValue
|
|
388
|
+
}];
|
|
423
389
|
}
|
|
424
390
|
function createDeferred(source, options) {
|
|
425
391
|
let t,
|
|
426
392
|
timeout = options ? options.timeoutMs : undefined;
|
|
427
|
-
const node = createComputation(
|
|
428
|
-
() => {
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
timeout
|
|
435
|
-
}
|
|
436
|
-
: undefined
|
|
437
|
-
);
|
|
438
|
-
return source();
|
|
439
|
-
},
|
|
440
|
-
undefined,
|
|
441
|
-
true
|
|
442
|
-
);
|
|
443
|
-
const [deferred, setDeferred] = createSignal(
|
|
444
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
445
|
-
options
|
|
446
|
-
);
|
|
393
|
+
const node = createComputation(() => {
|
|
394
|
+
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
395
|
+
timeout
|
|
396
|
+
} : undefined);
|
|
397
|
+
return source();
|
|
398
|
+
}, undefined, true);
|
|
399
|
+
const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
|
|
447
400
|
updateComputation(node);
|
|
448
|
-
setDeferred(() =>
|
|
449
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
450
|
-
);
|
|
401
|
+
setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
451
402
|
return deferred;
|
|
452
403
|
}
|
|
453
404
|
function createSelector(source, fn = equalFn, options) {
|
|
454
405
|
const subs = new Map();
|
|
455
|
-
const node = createComputation(
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
for (const
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
}
|
|
466
|
-
return v;
|
|
467
|
-
},
|
|
468
|
-
undefined,
|
|
469
|
-
true,
|
|
470
|
-
STALE,
|
|
471
|
-
options
|
|
472
|
-
);
|
|
406
|
+
const node = createComputation(p => {
|
|
407
|
+
const v = source();
|
|
408
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
409
|
+
for (const c of val.values()) {
|
|
410
|
+
c.state = STALE;
|
|
411
|
+
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
return v;
|
|
415
|
+
}, undefined, true, STALE, options );
|
|
473
416
|
updateComputation(node);
|
|
474
417
|
return key => {
|
|
475
418
|
const listener = Listener;
|
|
476
419
|
if (listener) {
|
|
477
420
|
let l;
|
|
478
|
-
if (
|
|
479
|
-
else subs.set(key, (l = new Set([listener])));
|
|
421
|
+
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
480
422
|
onCleanup(() => {
|
|
481
423
|
l.delete(listener);
|
|
482
424
|
!l.size && subs.delete(key);
|
|
483
425
|
});
|
|
484
426
|
}
|
|
485
|
-
return fn(
|
|
486
|
-
key,
|
|
487
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
488
|
-
);
|
|
427
|
+
return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
489
428
|
};
|
|
490
429
|
}
|
|
491
430
|
function batch(fn) {
|
|
@@ -524,10 +463,7 @@ function onMount(fn) {
|
|
|
524
463
|
createEffect(() => untrack(fn));
|
|
525
464
|
}
|
|
526
465
|
function onCleanup(fn) {
|
|
527
|
-
if (Owner === null)
|
|
528
|
-
console.warn("cleanups created outside a `createRoot` or `render` will never be run");
|
|
529
|
-
else if (Owner.cleanups === null) Owner.cleanups = [fn];
|
|
530
|
-
else Owner.cleanups.push(fn);
|
|
466
|
+
if (Owner === null) console.warn("cleanups created outside a `createRoot` or `render` will never be run");else if (Owner.cleanups === null) Owner.cleanups = [fn];else Owner.cleanups.push(fn);
|
|
531
467
|
return fn;
|
|
532
468
|
}
|
|
533
469
|
function catchError(fn, handler) {
|
|
@@ -581,17 +517,15 @@ function startTransition(fn) {
|
|
|
581
517
|
Owner = o;
|
|
582
518
|
let t;
|
|
583
519
|
if (Scheduler || SuspenseContext) {
|
|
584
|
-
t =
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
});
|
|
594
|
-
t.done || (t.done = new Promise(res => (t.resolve = res)));
|
|
520
|
+
t = Transition || (Transition = {
|
|
521
|
+
sources: new Set(),
|
|
522
|
+
effects: [],
|
|
523
|
+
promises: new Set(),
|
|
524
|
+
disposed: new Set(),
|
|
525
|
+
queue: new Set(),
|
|
526
|
+
running: true
|
|
527
|
+
});
|
|
528
|
+
t.done || (t.done = new Promise(res => t.resolve = res));
|
|
595
529
|
t.running = true;
|
|
596
530
|
}
|
|
597
531
|
runUpdates(fn, false);
|
|
@@ -607,18 +541,12 @@ function resumeEffects(e) {
|
|
|
607
541
|
e.length = 0;
|
|
608
542
|
}
|
|
609
543
|
function devComponent(Comp, props) {
|
|
610
|
-
const c = createComputation(
|
|
611
|
-
(
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
return Comp(props);
|
|
617
|
-
}),
|
|
618
|
-
undefined,
|
|
619
|
-
true,
|
|
620
|
-
0
|
|
621
|
-
);
|
|
544
|
+
const c = createComputation(() => untrack(() => {
|
|
545
|
+
Object.assign(Comp, {
|
|
546
|
+
[$DEVCOMP]: true
|
|
547
|
+
});
|
|
548
|
+
return Comp(props);
|
|
549
|
+
}), undefined, true, 0);
|
|
622
550
|
c.props = props;
|
|
623
551
|
c.observers = null;
|
|
624
552
|
c.observerSlots = null;
|
|
@@ -629,8 +557,7 @@ function devComponent(Comp, props) {
|
|
|
629
557
|
}
|
|
630
558
|
function registerGraph(value) {
|
|
631
559
|
if (!Owner) return;
|
|
632
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
633
|
-
else Owner.sourceMap = [value];
|
|
560
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);else Owner.sourceMap = [value];
|
|
634
561
|
value.graph = Owner;
|
|
635
562
|
}
|
|
636
563
|
function createContext(defaultValue, options) {
|
|
@@ -642,15 +569,13 @@ function createContext(defaultValue, options) {
|
|
|
642
569
|
};
|
|
643
570
|
}
|
|
644
571
|
function useContext(context) {
|
|
645
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
646
|
-
? Owner.context[context.id]
|
|
647
|
-
: context.defaultValue;
|
|
572
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
|
|
648
573
|
}
|
|
649
574
|
function children(fn) {
|
|
650
575
|
const children = createMemo(fn);
|
|
651
576
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
652
577
|
name: "children"
|
|
653
|
-
});
|
|
578
|
+
}) ;
|
|
654
579
|
memo.toArray = () => {
|
|
655
580
|
const c = memo();
|
|
656
581
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -682,8 +607,7 @@ function enableExternalSource(factory) {
|
|
|
682
607
|
function readSignal() {
|
|
683
608
|
const runningTransition = Transition && Transition.running;
|
|
684
609
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
685
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
686
|
-
else {
|
|
610
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
|
|
687
611
|
const updates = Updates;
|
|
688
612
|
Updates = null;
|
|
689
613
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -711,12 +635,11 @@ function readSignal() {
|
|
|
711
635
|
return this.value;
|
|
712
636
|
}
|
|
713
637
|
function writeSignal(node, value, isComp) {
|
|
714
|
-
let current =
|
|
715
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
638
|
+
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
716
639
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
717
640
|
if (Transition) {
|
|
718
641
|
const TransitionRunning = Transition.running;
|
|
719
|
-
if (TransitionRunning ||
|
|
642
|
+
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
720
643
|
Transition.sources.add(node);
|
|
721
644
|
node.tValue = value;
|
|
722
645
|
}
|
|
@@ -729,12 +652,10 @@ function writeSignal(node, value, isComp) {
|
|
|
729
652
|
const TransitionRunning = Transition && Transition.running;
|
|
730
653
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
731
654
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
732
|
-
if (o.pure) Updates.push(o);
|
|
733
|
-
else Effects.push(o);
|
|
655
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
734
656
|
if (o.observers) markDownstream(o);
|
|
735
657
|
}
|
|
736
|
-
if (!TransitionRunning) o.state = STALE;
|
|
737
|
-
else o.tState = STALE;
|
|
658
|
+
if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
|
|
738
659
|
}
|
|
739
660
|
if (Updates.length > 10e5) {
|
|
740
661
|
Updates = [];
|
|
@@ -753,11 +674,7 @@ function updateComputation(node) {
|
|
|
753
674
|
listener = Listener,
|
|
754
675
|
time = ExecCount;
|
|
755
676
|
Listener = Owner = node;
|
|
756
|
-
runComputation(
|
|
757
|
-
node,
|
|
758
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
759
|
-
time
|
|
760
|
-
);
|
|
677
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
761
678
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
762
679
|
queueMicrotask(() => {
|
|
763
680
|
runUpdates(() => {
|
|
@@ -818,15 +735,11 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
818
735
|
c.state = 0;
|
|
819
736
|
c.tState = state;
|
|
820
737
|
}
|
|
821
|
-
if (Owner === null)
|
|
822
|
-
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
823
|
-
else if (Owner !== UNOWNED) {
|
|
738
|
+
if (Owner === null) console.warn("computations created outside a `createRoot` or `render` will never be disposed");else if (Owner !== UNOWNED) {
|
|
824
739
|
if (Transition && Transition.running && Owner.pure) {
|
|
825
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
826
|
-
else Owner.tOwned.push(c);
|
|
740
|
+
if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
|
|
827
741
|
} else {
|
|
828
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
829
|
-
else Owner.owned.push(c);
|
|
742
|
+
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
830
743
|
}
|
|
831
744
|
}
|
|
832
745
|
if (options && options.name) c.name = options.name;
|
|
@@ -879,8 +792,7 @@ function runUpdates(fn, init) {
|
|
|
879
792
|
if (Updates) return fn();
|
|
880
793
|
let wait = false;
|
|
881
794
|
if (!init) Updates = [];
|
|
882
|
-
if (Effects) wait = true;
|
|
883
|
-
else Effects = [];
|
|
795
|
+
if (Effects) wait = true;else Effects = [];
|
|
884
796
|
ExecCount++;
|
|
885
797
|
try {
|
|
886
798
|
const res = fn();
|
|
@@ -894,8 +806,7 @@ function runUpdates(fn, init) {
|
|
|
894
806
|
}
|
|
895
807
|
function completeUpdates(wait) {
|
|
896
808
|
if (Updates) {
|
|
897
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
898
|
-
else runQueue(Updates);
|
|
809
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);else runQueue(Updates);
|
|
899
810
|
Updates = null;
|
|
900
811
|
}
|
|
901
812
|
if (wait) return;
|
|
@@ -935,8 +846,7 @@ function completeUpdates(wait) {
|
|
|
935
846
|
}
|
|
936
847
|
const e = Effects;
|
|
937
848
|
Effects = null;
|
|
938
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
939
|
-
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
849
|
+
if (e.length) runUpdates(() => runEffects(e), false);else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
940
850
|
if (res) res();
|
|
941
851
|
}
|
|
942
852
|
function runQueue(queue) {
|
|
@@ -964,8 +874,7 @@ function runUserEffects(queue) {
|
|
|
964
874
|
userLength = 0;
|
|
965
875
|
for (i = 0; i < queue.length; i++) {
|
|
966
876
|
const e = queue[i];
|
|
967
|
-
if (!e.user) runTop(e);
|
|
968
|
-
else queue[userLength++] = e;
|
|
877
|
+
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
969
878
|
}
|
|
970
879
|
if (sharedConfig.context) {
|
|
971
880
|
if (sharedConfig.count) {
|
|
@@ -983,15 +892,13 @@ function runUserEffects(queue) {
|
|
|
983
892
|
}
|
|
984
893
|
function lookUpstream(node, ignore) {
|
|
985
894
|
const runningTransition = Transition && Transition.running;
|
|
986
|
-
if (runningTransition) node.tState = 0;
|
|
987
|
-
else node.state = 0;
|
|
895
|
+
if (runningTransition) node.tState = 0;else node.state = 0;
|
|
988
896
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
989
897
|
const source = node.sources[i];
|
|
990
898
|
if (source.sources) {
|
|
991
899
|
const state = runningTransition ? source.tState : source.state;
|
|
992
900
|
if (state === STALE) {
|
|
993
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
994
|
-
runTop(source);
|
|
901
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
995
902
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
996
903
|
}
|
|
997
904
|
}
|
|
@@ -1001,10 +908,8 @@ function markDownstream(node) {
|
|
|
1001
908
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
1002
909
|
const o = node.observers[i];
|
|
1003
910
|
if (runningTransition ? !o.tState : !o.state) {
|
|
1004
|
-
if (runningTransition) o.tState = PENDING;
|
|
1005
|
-
|
|
1006
|
-
if (o.pure) Updates.push(o);
|
|
1007
|
-
else Effects.push(o);
|
|
911
|
+
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
912
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
1008
913
|
o.observers && markDownstream(o);
|
|
1009
914
|
}
|
|
1010
915
|
}
|
|
@@ -1041,8 +946,7 @@ function cleanNode(node) {
|
|
|
1041
946
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
1042
947
|
node.cleanups = null;
|
|
1043
948
|
}
|
|
1044
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1045
|
-
else node.state = 0;
|
|
949
|
+
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
1046
950
|
delete node.sourceMap;
|
|
1047
951
|
}
|
|
1048
952
|
function reset(node, top) {
|
|
@@ -1064,21 +968,19 @@ function runErrors(err, fns, owner) {
|
|
|
1064
968
|
try {
|
|
1065
969
|
for (const f of fns) f(err);
|
|
1066
970
|
} catch (e) {
|
|
1067
|
-
handleError(e,
|
|
971
|
+
handleError(e, owner && owner.owner || null);
|
|
1068
972
|
}
|
|
1069
973
|
}
|
|
1070
974
|
function handleError(err, owner = Owner) {
|
|
1071
975
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1072
976
|
const error = castError(err);
|
|
1073
977
|
if (!fns) throw error;
|
|
1074
|
-
if (Effects)
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
});
|
|
1081
|
-
else runErrors(error, fns, owner);
|
|
978
|
+
if (Effects) Effects.push({
|
|
979
|
+
fn() {
|
|
980
|
+
runErrors(error, fns, owner);
|
|
981
|
+
},
|
|
982
|
+
state: STALE
|
|
983
|
+
});else runErrors(error, fns, owner);
|
|
1082
984
|
}
|
|
1083
985
|
function resolveChildren(children) {
|
|
1084
986
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1095,26 +997,19 @@ function resolveChildren(children) {
|
|
|
1095
997
|
function createProvider(id, options) {
|
|
1096
998
|
return function provider(props) {
|
|
1097
999
|
let res;
|
|
1098
|
-
createRenderEffect(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
return children(() => props.children);
|
|
1106
|
-
})),
|
|
1107
|
-
undefined,
|
|
1108
|
-
options
|
|
1109
|
-
);
|
|
1000
|
+
createRenderEffect(() => res = untrack(() => {
|
|
1001
|
+
Owner.context = {
|
|
1002
|
+
...Owner.context,
|
|
1003
|
+
[id]: props.value
|
|
1004
|
+
};
|
|
1005
|
+
return children(() => props.children);
|
|
1006
|
+
}), undefined, options);
|
|
1110
1007
|
return res;
|
|
1111
1008
|
};
|
|
1112
1009
|
}
|
|
1113
1010
|
function onError(fn) {
|
|
1114
1011
|
ERROR || (ERROR = Symbol("error"));
|
|
1115
|
-
if (Owner === null)
|
|
1116
|
-
console.warn("error handlers created outside a `createRoot` or `render` will never be run");
|
|
1117
|
-
else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1012
|
+
if (Owner === null) console.warn("error handlers created outside a `createRoot` or `render` will never be run");else if (Owner.context === null || !Owner.context[ERROR]) {
|
|
1118
1013
|
Owner.context = {
|
|
1119
1014
|
...Owner.context,
|
|
1120
1015
|
[ERROR]: [fn]
|
|
@@ -1143,8 +1038,7 @@ function observable(input) {
|
|
|
1143
1038
|
if (!(observer instanceof Object) || observer == null) {
|
|
1144
1039
|
throw new TypeError("Expected the observer to be an object.");
|
|
1145
1040
|
}
|
|
1146
|
-
const handler =
|
|
1147
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1041
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1148
1042
|
if (!handler) {
|
|
1149
1043
|
return {
|
|
1150
1044
|
unsubscribe() {}
|
|
@@ -1175,7 +1069,7 @@ function from(producer) {
|
|
|
1175
1069
|
});
|
|
1176
1070
|
if ("subscribe" in producer) {
|
|
1177
1071
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1178
|
-
onCleanup(() =>
|
|
1072
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1179
1073
|
} else {
|
|
1180
1074
|
const clean = producer(set);
|
|
1181
1075
|
onCleanup(clean);
|
|
@@ -1227,7 +1121,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1227
1121
|
});
|
|
1228
1122
|
len = 1;
|
|
1229
1123
|
}
|
|
1230
|
-
}
|
|
1124
|
+
}
|
|
1125
|
+
else if (len === 0) {
|
|
1231
1126
|
mapped = new Array(newLen);
|
|
1232
1127
|
for (j = 0; j < newLen; j++) {
|
|
1233
1128
|
items[j] = newItems[j];
|
|
@@ -1238,16 +1133,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1238
1133
|
temp = new Array(newLen);
|
|
1239
1134
|
tempdisposers = new Array(newLen);
|
|
1240
1135
|
indexes && (tempIndexes = new Array(newLen));
|
|
1241
|
-
for (
|
|
1242
|
-
|
|
1243
|
-
start < end && items[start] === newItems[start];
|
|
1244
|
-
start++
|
|
1245
|
-
);
|
|
1246
|
-
for (
|
|
1247
|
-
end = len - 1, newEnd = newLen - 1;
|
|
1248
|
-
end >= start && newEnd >= start && items[end] === newItems[newEnd];
|
|
1249
|
-
end--, newEnd--
|
|
1250
|
-
) {
|
|
1136
|
+
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
|
|
1137
|
+
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
1251
1138
|
temp[newEnd] = mapped[end];
|
|
1252
1139
|
tempdisposers[newEnd] = disposers[end];
|
|
1253
1140
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1281,7 +1168,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1281
1168
|
}
|
|
1282
1169
|
} else mapped[j] = createRoot(mapper);
|
|
1283
1170
|
}
|
|
1284
|
-
mapped = mapped.slice(0,
|
|
1171
|
+
mapped = mapped.slice(0, len = newLen);
|
|
1285
1172
|
items = newItems.slice(0);
|
|
1286
1173
|
}
|
|
1287
1174
|
return mapped;
|
|
@@ -1291,7 +1178,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1291
1178
|
if (indexes) {
|
|
1292
1179
|
const [s, set] = createSignal(j, {
|
|
1293
1180
|
name: "index"
|
|
1294
|
-
});
|
|
1181
|
+
}) ;
|
|
1295
1182
|
indexes[j] = set;
|
|
1296
1183
|
return mapFn(newItems[j], s);
|
|
1297
1184
|
}
|
|
@@ -1349,13 +1236,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1349
1236
|
}
|
|
1350
1237
|
len = signals.length = disposers.length = newItems.length;
|
|
1351
1238
|
items = newItems.slice(0);
|
|
1352
|
-
return
|
|
1239
|
+
return mapped = mapped.slice(0, len);
|
|
1353
1240
|
});
|
|
1354
1241
|
function mapper(disposer) {
|
|
1355
1242
|
disposers[i] = disposer;
|
|
1356
1243
|
const [s, set] = createSignal(newItems[i], {
|
|
1357
1244
|
name: "value"
|
|
1358
|
-
});
|
|
1245
|
+
}) ;
|
|
1359
1246
|
signals[i] = set;
|
|
1360
1247
|
return mapFn(s, i);
|
|
1361
1248
|
}
|
|
@@ -1371,7 +1258,7 @@ function createComponent(Comp, props) {
|
|
|
1371
1258
|
if (sharedConfig.context) {
|
|
1372
1259
|
const c = sharedConfig.context;
|
|
1373
1260
|
setHydrateContext(nextHydrateContext());
|
|
1374
|
-
const r = devComponent(Comp, props || {});
|
|
1261
|
+
const r = devComponent(Comp, props || {}) ;
|
|
1375
1262
|
setHydrateContext(c);
|
|
1376
1263
|
return r;
|
|
1377
1264
|
}
|
|
@@ -1420,33 +1307,29 @@ function mergeProps(...sources) {
|
|
|
1420
1307
|
let proxy = false;
|
|
1421
1308
|
for (let i = 0; i < sources.length; i++) {
|
|
1422
1309
|
const s = sources[i];
|
|
1423
|
-
proxy = proxy ||
|
|
1424
|
-
sources[i] = typeof s === "function" ? (
|
|
1310
|
+
proxy = proxy || !!s && $PROXY in s;
|
|
1311
|
+
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1425
1312
|
}
|
|
1426
1313
|
if (proxy) {
|
|
1427
|
-
return new Proxy(
|
|
1428
|
-
{
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
if (v !== undefined) return v;
|
|
1433
|
-
}
|
|
1434
|
-
},
|
|
1435
|
-
has(property) {
|
|
1436
|
-
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1437
|
-
if (property in resolveSource(sources[i])) return true;
|
|
1438
|
-
}
|
|
1439
|
-
return false;
|
|
1440
|
-
},
|
|
1441
|
-
keys() {
|
|
1442
|
-
const keys = [];
|
|
1443
|
-
for (let i = 0; i < sources.length; i++)
|
|
1444
|
-
keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1445
|
-
return [...new Set(keys)];
|
|
1314
|
+
return new Proxy({
|
|
1315
|
+
get(property) {
|
|
1316
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1317
|
+
const v = resolveSource(sources[i])[property];
|
|
1318
|
+
if (v !== undefined) return v;
|
|
1446
1319
|
}
|
|
1447
1320
|
},
|
|
1448
|
-
|
|
1449
|
-
|
|
1321
|
+
has(property) {
|
|
1322
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1323
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1324
|
+
}
|
|
1325
|
+
return false;
|
|
1326
|
+
},
|
|
1327
|
+
keys() {
|
|
1328
|
+
const keys = [];
|
|
1329
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1330
|
+
return [...new Set(keys)];
|
|
1331
|
+
}
|
|
1332
|
+
}, propTraps);
|
|
1450
1333
|
}
|
|
1451
1334
|
const target = {};
|
|
1452
1335
|
const sourcesMap = {};
|
|
@@ -1465,7 +1348,7 @@ function mergeProps(...sources) {
|
|
|
1465
1348
|
Object.defineProperty(target, key, {
|
|
1466
1349
|
enumerable: true,
|
|
1467
1350
|
configurable: true,
|
|
1468
|
-
get: resolveSources.bind(
|
|
1351
|
+
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1469
1352
|
});
|
|
1470
1353
|
} else {
|
|
1471
1354
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1489,60 +1372,47 @@ function splitProps(props, ...keys) {
|
|
|
1489
1372
|
if ($PROXY in props) {
|
|
1490
1373
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1491
1374
|
const res = keys.map(k => {
|
|
1492
|
-
return new Proxy(
|
|
1493
|
-
{
|
|
1494
|
-
|
|
1495
|
-
return k.includes(property) ? props[property] : undefined;
|
|
1496
|
-
},
|
|
1497
|
-
has(property) {
|
|
1498
|
-
return k.includes(property) && property in props;
|
|
1499
|
-
},
|
|
1500
|
-
keys() {
|
|
1501
|
-
return k.filter(property => property in props);
|
|
1502
|
-
}
|
|
1375
|
+
return new Proxy({
|
|
1376
|
+
get(property) {
|
|
1377
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1503
1378
|
},
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
});
|
|
1507
|
-
res.push(
|
|
1508
|
-
new Proxy(
|
|
1509
|
-
{
|
|
1510
|
-
get(property) {
|
|
1511
|
-
return blocked.has(property) ? undefined : props[property];
|
|
1512
|
-
},
|
|
1513
|
-
has(property) {
|
|
1514
|
-
return blocked.has(property) ? false : property in props;
|
|
1515
|
-
},
|
|
1516
|
-
keys() {
|
|
1517
|
-
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1518
|
-
}
|
|
1379
|
+
has(property) {
|
|
1380
|
+
return k.includes(property) && property in props;
|
|
1519
1381
|
},
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1382
|
+
keys() {
|
|
1383
|
+
return k.filter(property => property in props);
|
|
1384
|
+
}
|
|
1385
|
+
}, propTraps);
|
|
1386
|
+
});
|
|
1387
|
+
res.push(new Proxy({
|
|
1388
|
+
get(property) {
|
|
1389
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1390
|
+
},
|
|
1391
|
+
has(property) {
|
|
1392
|
+
return blocked.has(property) ? false : property in props;
|
|
1393
|
+
},
|
|
1394
|
+
keys() {
|
|
1395
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1396
|
+
}
|
|
1397
|
+
}, propTraps));
|
|
1523
1398
|
return res;
|
|
1524
1399
|
}
|
|
1525
1400
|
const otherObject = {};
|
|
1526
1401
|
const objects = keys.map(() => ({}));
|
|
1527
1402
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1528
1403
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1529
|
-
const isDefaultDesc =
|
|
1530
|
-
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1404
|
+
const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1531
1405
|
let blocked = false;
|
|
1532
1406
|
let objectIndex = 0;
|
|
1533
1407
|
for (const k of keys) {
|
|
1534
1408
|
if (k.includes(propName)) {
|
|
1535
1409
|
blocked = true;
|
|
1536
|
-
isDefaultDesc
|
|
1537
|
-
? (objects[objectIndex][propName] = desc.value)
|
|
1538
|
-
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1410
|
+
isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1539
1411
|
}
|
|
1540
1412
|
++objectIndex;
|
|
1541
1413
|
}
|
|
1542
1414
|
if (!blocked) {
|
|
1543
|
-
isDefaultDesc
|
|
1544
|
-
? (otherObject[propName] = desc.value)
|
|
1545
|
-
: Object.defineProperty(otherObject, propName, desc);
|
|
1415
|
+
isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
|
|
1546
1416
|
}
|
|
1547
1417
|
}
|
|
1548
1418
|
return [...objects, otherObject];
|
|
@@ -1568,24 +1438,19 @@ function lazy(fn) {
|
|
|
1568
1438
|
comp = s;
|
|
1569
1439
|
}
|
|
1570
1440
|
let Comp;
|
|
1571
|
-
return createMemo(
|
|
1572
|
-
()
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
const r = Comp(props);
|
|
1583
|
-
setHydrateContext(c);
|
|
1584
|
-
return r;
|
|
1585
|
-
})
|
|
1586
|
-
);
|
|
1441
|
+
return createMemo(() => (Comp = comp()) && untrack(() => {
|
|
1442
|
+
if (true) Object.assign(Comp, {
|
|
1443
|
+
[$DEVCOMP]: true
|
|
1444
|
+
});
|
|
1445
|
+
if (!ctx) return Comp(props);
|
|
1446
|
+
const c = sharedConfig.context;
|
|
1447
|
+
setHydrateContext(ctx);
|
|
1448
|
+
const r = Comp(props);
|
|
1449
|
+
setHydrateContext(c);
|
|
1450
|
+
return r;
|
|
1451
|
+
}));
|
|
1587
1452
|
};
|
|
1588
|
-
wrap.preload = () => p || ((p = fn()).then(mod =>
|
|
1453
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1589
1454
|
return wrap;
|
|
1590
1455
|
}
|
|
1591
1456
|
let counter = 0;
|
|
@@ -1594,113 +1459,75 @@ function createUniqueId() {
|
|
|
1594
1459
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1595
1460
|
}
|
|
1596
1461
|
|
|
1597
|
-
const narrowedError = name =>
|
|
1598
|
-
`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.`;
|
|
1462
|
+
const narrowedError = name => `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.` ;
|
|
1599
1463
|
function For(props) {
|
|
1600
1464
|
const fallback = "fallback" in props && {
|
|
1601
1465
|
fallback: () => props.fallback
|
|
1602
1466
|
};
|
|
1603
|
-
return createMemo(
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
{
|
|
1607
|
-
name: "value"
|
|
1608
|
-
}
|
|
1609
|
-
);
|
|
1467
|
+
return createMemo(mapArray(() => props.each, props.children, fallback || undefined), undefined, {
|
|
1468
|
+
name: "value"
|
|
1469
|
+
}) ;
|
|
1610
1470
|
}
|
|
1611
1471
|
function Index(props) {
|
|
1612
1472
|
const fallback = "fallback" in props && {
|
|
1613
1473
|
fallback: () => props.fallback
|
|
1614
1474
|
};
|
|
1615
|
-
return createMemo(
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
{
|
|
1619
|
-
name: "value"
|
|
1620
|
-
}
|
|
1621
|
-
);
|
|
1475
|
+
return createMemo(indexArray(() => props.each, props.children, fallback || undefined), undefined, {
|
|
1476
|
+
name: "value"
|
|
1477
|
+
}) ;
|
|
1622
1478
|
}
|
|
1623
1479
|
function Show(props) {
|
|
1624
1480
|
const keyed = props.keyed;
|
|
1625
1481
|
const condition = createMemo(() => props.when, undefined, {
|
|
1626
|
-
equals: (a, b) =>
|
|
1482
|
+
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1627
1483
|
name: "condition"
|
|
1628
|
-
});
|
|
1629
|
-
return createMemo(
|
|
1630
|
-
()
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
keyed
|
|
1639
|
-
? c
|
|
1640
|
-
: () => {
|
|
1641
|
-
if (!untrack(condition)) throw narrowedError("Show");
|
|
1642
|
-
return props.when;
|
|
1643
|
-
}
|
|
1644
|
-
)
|
|
1645
|
-
)
|
|
1646
|
-
: child;
|
|
1647
|
-
}
|
|
1648
|
-
return props.fallback;
|
|
1649
|
-
},
|
|
1650
|
-
undefined,
|
|
1651
|
-
{
|
|
1652
|
-
name: "value"
|
|
1484
|
+
} );
|
|
1485
|
+
return createMemo(() => {
|
|
1486
|
+
const c = condition();
|
|
1487
|
+
if (c) {
|
|
1488
|
+
const child = props.children;
|
|
1489
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1490
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1491
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1492
|
+
return props.when;
|
|
1493
|
+
})) : child;
|
|
1653
1494
|
}
|
|
1654
|
-
|
|
1495
|
+
return props.fallback;
|
|
1496
|
+
}, undefined, {
|
|
1497
|
+
name: "value"
|
|
1498
|
+
} );
|
|
1655
1499
|
}
|
|
1656
1500
|
function Switch(props) {
|
|
1657
1501
|
let keyed = false;
|
|
1658
|
-
const equals = (a, b) =>
|
|
1659
|
-
a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1502
|
+
const equals = (a, b) => a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1660
1503
|
const conditions = children(() => props.children),
|
|
1661
|
-
evalConditions = createMemo(
|
|
1662
|
-
()
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
return [i, c, conds[i]];
|
|
1670
|
-
}
|
|
1504
|
+
evalConditions = createMemo(() => {
|
|
1505
|
+
let conds = conditions();
|
|
1506
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1507
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1508
|
+
const c = conds[i].when;
|
|
1509
|
+
if (c) {
|
|
1510
|
+
keyed = !!conds[i].keyed;
|
|
1511
|
+
return [i, c, conds[i]];
|
|
1671
1512
|
}
|
|
1672
|
-
return [-1];
|
|
1673
|
-
},
|
|
1674
|
-
undefined,
|
|
1675
|
-
{
|
|
1676
|
-
equals,
|
|
1677
|
-
name: "eval conditions"
|
|
1678
1513
|
}
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
)
|
|
1697
|
-
: c;
|
|
1698
|
-
},
|
|
1699
|
-
undefined,
|
|
1700
|
-
{
|
|
1701
|
-
name: "value"
|
|
1702
|
-
}
|
|
1703
|
-
);
|
|
1514
|
+
return [-1];
|
|
1515
|
+
}, undefined, {
|
|
1516
|
+
equals,
|
|
1517
|
+
name: "eval conditions"
|
|
1518
|
+
} );
|
|
1519
|
+
return createMemo(() => {
|
|
1520
|
+
const [index, when, cond] = evalConditions();
|
|
1521
|
+
if (index < 0) return props.fallback;
|
|
1522
|
+
const c = cond.children;
|
|
1523
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1524
|
+
return fn ? untrack(() => c(keyed ? when : () => {
|
|
1525
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1526
|
+
return cond.when;
|
|
1527
|
+
})) : c;
|
|
1528
|
+
}, undefined, {
|
|
1529
|
+
name: "value"
|
|
1530
|
+
} );
|
|
1704
1531
|
}
|
|
1705
1532
|
function Match(props) {
|
|
1706
1533
|
return props;
|
|
@@ -1711,33 +1538,27 @@ function resetErrorBoundaries() {
|
|
|
1711
1538
|
}
|
|
1712
1539
|
function ErrorBoundary(props) {
|
|
1713
1540
|
let err;
|
|
1714
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1715
|
-
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1541
|
+
if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1716
1542
|
const [errored, setErrored] = createSignal(err, {
|
|
1717
1543
|
name: "errored"
|
|
1718
|
-
});
|
|
1544
|
+
} );
|
|
1719
1545
|
Errors || (Errors = new Set());
|
|
1720
1546
|
Errors.add(setErrored);
|
|
1721
1547
|
onCleanup(() => Errors.delete(setErrored));
|
|
1722
|
-
return createMemo(
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1729
|
-
}
|
|
1730
|
-
return catchError(() => props.children, setErrored);
|
|
1731
|
-
},
|
|
1732
|
-
undefined,
|
|
1733
|
-
{
|
|
1734
|
-
name: "value"
|
|
1548
|
+
return createMemo(() => {
|
|
1549
|
+
let e;
|
|
1550
|
+
if (e = errored()) {
|
|
1551
|
+
const f = props.fallback;
|
|
1552
|
+
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1553
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1735
1554
|
}
|
|
1736
|
-
|
|
1555
|
+
return catchError(() => props.children, setErrored);
|
|
1556
|
+
}, undefined, {
|
|
1557
|
+
name: "value"
|
|
1558
|
+
} );
|
|
1737
1559
|
}
|
|
1738
1560
|
|
|
1739
|
-
const suspenseListEquals = (a, b) =>
|
|
1740
|
-
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1561
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1741
1562
|
const SuspenseListContext = createContext();
|
|
1742
1563
|
function SuspenseList(props) {
|
|
1743
1564
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1749,51 +1570,51 @@ function SuspenseList(props) {
|
|
|
1749
1570
|
if (listContext) {
|
|
1750
1571
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1751
1572
|
}
|
|
1752
|
-
const resolved = createMemo(
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1573
|
+
const resolved = createMemo(prev => {
|
|
1574
|
+
const reveal = props.revealOrder,
|
|
1575
|
+
tail = props.tail,
|
|
1576
|
+
{
|
|
1577
|
+
showContent = true,
|
|
1578
|
+
showFallback = true
|
|
1579
|
+
} = show ? show() : {},
|
|
1580
|
+
reg = registry(),
|
|
1581
|
+
reverse = reveal === "backwards";
|
|
1582
|
+
if (reveal === "together") {
|
|
1583
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1584
|
+
const res = reg.map(() => ({
|
|
1585
|
+
showContent: all && showContent,
|
|
1586
|
+
showFallback
|
|
1587
|
+
}));
|
|
1588
|
+
res.inFallback = !all;
|
|
1589
|
+
return res;
|
|
1590
|
+
}
|
|
1591
|
+
let stop = false;
|
|
1592
|
+
let inFallback = prev.inFallback;
|
|
1593
|
+
const res = [];
|
|
1594
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1595
|
+
const n = reverse ? len - i - 1 : i,
|
|
1596
|
+
s = reg[n]();
|
|
1597
|
+
if (!stop && !s) {
|
|
1598
|
+
res[n] = {
|
|
1599
|
+
showContent,
|
|
1763
1600
|
showFallback
|
|
1764
|
-
}
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
s = reg[n]();
|
|
1774
|
-
if (!stop && !s) {
|
|
1775
|
-
res[n] = {
|
|
1776
|
-
showContent,
|
|
1777
|
-
showFallback
|
|
1778
|
-
};
|
|
1779
|
-
} else {
|
|
1780
|
-
const next = !stop;
|
|
1781
|
-
if (next) inFallback = true;
|
|
1782
|
-
res[n] = {
|
|
1783
|
-
showContent: next,
|
|
1784
|
-
showFallback: !tail || (next && tail === "collapsed") ? showFallback : false
|
|
1785
|
-
};
|
|
1786
|
-
stop = true;
|
|
1787
|
-
}
|
|
1601
|
+
};
|
|
1602
|
+
} else {
|
|
1603
|
+
const next = !stop;
|
|
1604
|
+
if (next) inFallback = true;
|
|
1605
|
+
res[n] = {
|
|
1606
|
+
showContent: next,
|
|
1607
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1608
|
+
};
|
|
1609
|
+
stop = true;
|
|
1788
1610
|
}
|
|
1789
|
-
if (!stop) inFallback = false;
|
|
1790
|
-
res.inFallback = inFallback;
|
|
1791
|
-
return res;
|
|
1792
|
-
},
|
|
1793
|
-
{
|
|
1794
|
-
inFallback: false
|
|
1795
1611
|
}
|
|
1796
|
-
|
|
1612
|
+
if (!stop) inFallback = false;
|
|
1613
|
+
res.inFallback = inFallback;
|
|
1614
|
+
return res;
|
|
1615
|
+
}, {
|
|
1616
|
+
inFallback: false
|
|
1617
|
+
});
|
|
1797
1618
|
setWrapper(() => resolved);
|
|
1798
1619
|
return createComponent(SuspenseListContext.Provider, {
|
|
1799
1620
|
value: {
|
|
@@ -1868,14 +1689,17 @@ function Suspense(props) {
|
|
|
1868
1689
|
ctx = sharedConfig.context;
|
|
1869
1690
|
if (flicker) {
|
|
1870
1691
|
flicker();
|
|
1871
|
-
return
|
|
1692
|
+
return flicker = undefined;
|
|
1872
1693
|
}
|
|
1873
1694
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1874
1695
|
const rendered = createMemo(() => props.children);
|
|
1875
1696
|
return createMemo(prev => {
|
|
1876
1697
|
const inFallback = store.inFallback(),
|
|
1877
|
-
{
|
|
1878
|
-
|
|
1698
|
+
{
|
|
1699
|
+
showContent = true,
|
|
1700
|
+
showFallback = true
|
|
1701
|
+
} = show ? show() : {};
|
|
1702
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1879
1703
|
store.resolved = true;
|
|
1880
1704
|
dispose && dispose();
|
|
1881
1705
|
dispose = ctx = p = undefined;
|
|
@@ -1905,68 +1729,9 @@ const DEV = {
|
|
|
1905
1729
|
hooks: DevHooks,
|
|
1906
1730
|
writeSignal,
|
|
1907
1731
|
registerGraph
|
|
1908
|
-
};
|
|
1732
|
+
} ;
|
|
1909
1733
|
if (globalThis) {
|
|
1910
|
-
if (!globalThis.Solid$$) globalThis.Solid$$ = true;
|
|
1911
|
-
else
|
|
1912
|
-
console.warn(
|
|
1913
|
-
"You appear to have multiple instances of Solid. This can lead to unexpected behavior."
|
|
1914
|
-
);
|
|
1734
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1915
1735
|
}
|
|
1916
1736
|
|
|
1917
|
-
export {
|
|
1918
|
-
$DEVCOMP,
|
|
1919
|
-
$PROXY,
|
|
1920
|
-
$TRACK,
|
|
1921
|
-
DEV,
|
|
1922
|
-
ErrorBoundary,
|
|
1923
|
-
For,
|
|
1924
|
-
Index,
|
|
1925
|
-
Match,
|
|
1926
|
-
Show,
|
|
1927
|
-
Suspense,
|
|
1928
|
-
SuspenseList,
|
|
1929
|
-
Switch,
|
|
1930
|
-
batch,
|
|
1931
|
-
cancelCallback,
|
|
1932
|
-
catchError,
|
|
1933
|
-
children,
|
|
1934
|
-
createComponent,
|
|
1935
|
-
createComputed,
|
|
1936
|
-
createContext,
|
|
1937
|
-
createDeferred,
|
|
1938
|
-
createEffect,
|
|
1939
|
-
createMemo,
|
|
1940
|
-
createReaction,
|
|
1941
|
-
createRenderEffect,
|
|
1942
|
-
createResource,
|
|
1943
|
-
createRoot,
|
|
1944
|
-
createSelector,
|
|
1945
|
-
createSignal,
|
|
1946
|
-
createUniqueId,
|
|
1947
|
-
enableExternalSource,
|
|
1948
|
-
enableHydration,
|
|
1949
|
-
enableScheduling,
|
|
1950
|
-
equalFn,
|
|
1951
|
-
from,
|
|
1952
|
-
getListener,
|
|
1953
|
-
getOwner,
|
|
1954
|
-
indexArray,
|
|
1955
|
-
lazy,
|
|
1956
|
-
mapArray,
|
|
1957
|
-
mergeProps,
|
|
1958
|
-
observable,
|
|
1959
|
-
on,
|
|
1960
|
-
onCleanup,
|
|
1961
|
-
onError,
|
|
1962
|
-
onMount,
|
|
1963
|
-
requestCallback,
|
|
1964
|
-
resetErrorBoundaries,
|
|
1965
|
-
runWithOwner,
|
|
1966
|
-
sharedConfig,
|
|
1967
|
-
splitProps,
|
|
1968
|
-
startTransition,
|
|
1969
|
-
untrack,
|
|
1970
|
-
useContext,
|
|
1971
|
-
useTransition
|
|
1972
|
-
};
|
|
1737
|
+
export { $DEVCOMP, $PROXY, $TRACK, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, catchError, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createReaction, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, resetErrorBoundaries, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
|