solid-js 1.8.0 → 1.8.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.cjs +5 -1
- package/dist/dev.js +301 -532
- package/dist/server.cjs +18 -4
- package/dist/server.js +89 -170
- package/dist/solid.cjs +5 -1
- package/dist/solid.js +259 -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/types/hyperscript.d.ts +11 -11
- package/html/dist/html.js +94 -216
- package/html/types/lit.d.ts +31 -45
- package/package.json +2 -2
- 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/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 +14 -14
- package/types/server/index.d.ts +2 -56
- package/types/server/reactive.d.ts +44 -68
- 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 +2 -2
- package/web/dist/dev.js +81 -613
- package/web/dist/server.cjs +1 -1
- package/web/dist/server.js +93 -176
- package/web/dist/web.cjs +1 -6
- package/web/dist/web.js +80 -617
- package/web/types/client.d.ts +2 -2
- 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 = 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,26 @@ 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
|
}
|
|
353
|
+
if ("value" in p) {
|
|
354
|
+
if (p.status === "success") loadEnd(pr, p.value, undefined, lookup);else loadEnd(pr, undefined, undefined, lookup);
|
|
355
|
+
return p;
|
|
356
|
+
}
|
|
380
357
|
pr = p;
|
|
381
358
|
scheduled = true;
|
|
382
|
-
queueMicrotask(() =>
|
|
359
|
+
queueMicrotask(() => scheduled = false);
|
|
383
360
|
runUpdates(() => {
|
|
384
361
|
setState(resolved ? "refreshing" : "pending");
|
|
385
362
|
trigger();
|
|
386
363
|
}, false);
|
|
387
|
-
return p.then(
|
|
388
|
-
v => loadEnd(p, v, undefined, lookup),
|
|
389
|
-
e => loadEnd(p, undefined, castError(e), lookup)
|
|
390
|
-
);
|
|
364
|
+
return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, undefined, castError(e), lookup));
|
|
391
365
|
}
|
|
392
366
|
Object.defineProperties(read, {
|
|
393
367
|
state: {
|
|
@@ -411,81 +385,50 @@ function createResource(pSource, pFetcher, pOptions) {
|
|
|
411
385
|
}
|
|
412
386
|
}
|
|
413
387
|
});
|
|
414
|
-
if (dynamic) createComputed(() => load(false));
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
refetch: load,
|
|
420
|
-
mutate: setValue
|
|
421
|
-
}
|
|
422
|
-
];
|
|
388
|
+
if (dynamic) createComputed(() => load(false));else load(false);
|
|
389
|
+
return [read, {
|
|
390
|
+
refetch: load,
|
|
391
|
+
mutate: setValue
|
|
392
|
+
}];
|
|
423
393
|
}
|
|
424
394
|
function createDeferred(source, options) {
|
|
425
395
|
let t,
|
|
426
396
|
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
|
-
);
|
|
397
|
+
const node = createComputation(() => {
|
|
398
|
+
if (!t || !t.fn) t = requestCallback(() => setDeferred(() => node.value), timeout !== undefined ? {
|
|
399
|
+
timeout
|
|
400
|
+
} : undefined);
|
|
401
|
+
return source();
|
|
402
|
+
}, undefined, true);
|
|
403
|
+
const [deferred, setDeferred] = createSignal(Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, options);
|
|
447
404
|
updateComputation(node);
|
|
448
|
-
setDeferred(() =>
|
|
449
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
450
|
-
);
|
|
405
|
+
setDeferred(() => Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
451
406
|
return deferred;
|
|
452
407
|
}
|
|
453
408
|
function createSelector(source, fn = equalFn, options) {
|
|
454
409
|
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
|
-
);
|
|
410
|
+
const node = createComputation(p => {
|
|
411
|
+
const v = source();
|
|
412
|
+
for (const [key, val] of subs.entries()) if (fn(key, v) !== fn(key, p)) {
|
|
413
|
+
for (const c of val.values()) {
|
|
414
|
+
c.state = STALE;
|
|
415
|
+
if (c.pure) Updates.push(c);else Effects.push(c);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
return v;
|
|
419
|
+
}, undefined, true, STALE, options );
|
|
473
420
|
updateComputation(node);
|
|
474
421
|
return key => {
|
|
475
422
|
const listener = Listener;
|
|
476
423
|
if (listener) {
|
|
477
424
|
let l;
|
|
478
|
-
if (
|
|
479
|
-
else subs.set(key, (l = new Set([listener])));
|
|
425
|
+
if (l = subs.get(key)) l.add(listener);else subs.set(key, l = new Set([listener]));
|
|
480
426
|
onCleanup(() => {
|
|
481
427
|
l.delete(listener);
|
|
482
428
|
!l.size && subs.delete(key);
|
|
483
429
|
});
|
|
484
430
|
}
|
|
485
|
-
return fn(
|
|
486
|
-
key,
|
|
487
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value
|
|
488
|
-
);
|
|
431
|
+
return fn(key, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value);
|
|
489
432
|
};
|
|
490
433
|
}
|
|
491
434
|
function batch(fn) {
|
|
@@ -524,10 +467,7 @@ function onMount(fn) {
|
|
|
524
467
|
createEffect(() => untrack(fn));
|
|
525
468
|
}
|
|
526
469
|
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);
|
|
470
|
+
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
471
|
return fn;
|
|
532
472
|
}
|
|
533
473
|
function catchError(fn, handler) {
|
|
@@ -581,17 +521,15 @@ function startTransition(fn) {
|
|
|
581
521
|
Owner = o;
|
|
582
522
|
let t;
|
|
583
523
|
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)));
|
|
524
|
+
t = Transition || (Transition = {
|
|
525
|
+
sources: new Set(),
|
|
526
|
+
effects: [],
|
|
527
|
+
promises: new Set(),
|
|
528
|
+
disposed: new Set(),
|
|
529
|
+
queue: new Set(),
|
|
530
|
+
running: true
|
|
531
|
+
});
|
|
532
|
+
t.done || (t.done = new Promise(res => t.resolve = res));
|
|
595
533
|
t.running = true;
|
|
596
534
|
}
|
|
597
535
|
runUpdates(fn, false);
|
|
@@ -607,18 +545,12 @@ function resumeEffects(e) {
|
|
|
607
545
|
e.length = 0;
|
|
608
546
|
}
|
|
609
547
|
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
|
-
);
|
|
548
|
+
const c = createComputation(() => untrack(() => {
|
|
549
|
+
Object.assign(Comp, {
|
|
550
|
+
[$DEVCOMP]: true
|
|
551
|
+
});
|
|
552
|
+
return Comp(props);
|
|
553
|
+
}), undefined, true, 0);
|
|
622
554
|
c.props = props;
|
|
623
555
|
c.observers = null;
|
|
624
556
|
c.observerSlots = null;
|
|
@@ -629,8 +561,7 @@ function devComponent(Comp, props) {
|
|
|
629
561
|
}
|
|
630
562
|
function registerGraph(value) {
|
|
631
563
|
if (!Owner) return;
|
|
632
|
-
if (Owner.sourceMap) Owner.sourceMap.push(value);
|
|
633
|
-
else Owner.sourceMap = [value];
|
|
564
|
+
if (Owner.sourceMap) Owner.sourceMap.push(value);else Owner.sourceMap = [value];
|
|
634
565
|
value.graph = Owner;
|
|
635
566
|
}
|
|
636
567
|
function createContext(defaultValue, options) {
|
|
@@ -642,15 +573,13 @@ function createContext(defaultValue, options) {
|
|
|
642
573
|
};
|
|
643
574
|
}
|
|
644
575
|
function useContext(context) {
|
|
645
|
-
return Owner && Owner.context && Owner.context[context.id] !== undefined
|
|
646
|
-
? Owner.context[context.id]
|
|
647
|
-
: context.defaultValue;
|
|
576
|
+
return Owner && Owner.context && Owner.context[context.id] !== undefined ? Owner.context[context.id] : context.defaultValue;
|
|
648
577
|
}
|
|
649
578
|
function children(fn) {
|
|
650
579
|
const children = createMemo(fn);
|
|
651
580
|
const memo = createMemo(() => resolveChildren(children()), undefined, {
|
|
652
581
|
name: "children"
|
|
653
|
-
});
|
|
582
|
+
}) ;
|
|
654
583
|
memo.toArray = () => {
|
|
655
584
|
const c = memo();
|
|
656
585
|
return Array.isArray(c) ? c : c != null ? [c] : [];
|
|
@@ -682,8 +611,7 @@ function enableExternalSource(factory) {
|
|
|
682
611
|
function readSignal() {
|
|
683
612
|
const runningTransition = Transition && Transition.running;
|
|
684
613
|
if (this.sources && (runningTransition ? this.tState : this.state)) {
|
|
685
|
-
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);
|
|
686
|
-
else {
|
|
614
|
+
if ((runningTransition ? this.tState : this.state) === STALE) updateComputation(this);else {
|
|
687
615
|
const updates = Updates;
|
|
688
616
|
Updates = null;
|
|
689
617
|
runUpdates(() => lookUpstream(this), false);
|
|
@@ -711,12 +639,11 @@ function readSignal() {
|
|
|
711
639
|
return this.value;
|
|
712
640
|
}
|
|
713
641
|
function writeSignal(node, value, isComp) {
|
|
714
|
-
let current =
|
|
715
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
642
|
+
let current = Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value;
|
|
716
643
|
if (!node.comparator || !node.comparator(current, value)) {
|
|
717
644
|
if (Transition) {
|
|
718
645
|
const TransitionRunning = Transition.running;
|
|
719
|
-
if (TransitionRunning ||
|
|
646
|
+
if (TransitionRunning || !isComp && Transition.sources.has(node)) {
|
|
720
647
|
Transition.sources.add(node);
|
|
721
648
|
node.tValue = value;
|
|
722
649
|
}
|
|
@@ -729,12 +656,10 @@ function writeSignal(node, value, isComp) {
|
|
|
729
656
|
const TransitionRunning = Transition && Transition.running;
|
|
730
657
|
if (TransitionRunning && Transition.disposed.has(o)) continue;
|
|
731
658
|
if (TransitionRunning ? !o.tState : !o.state) {
|
|
732
|
-
if (o.pure) Updates.push(o);
|
|
733
|
-
else Effects.push(o);
|
|
659
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
734
660
|
if (o.observers) markDownstream(o);
|
|
735
661
|
}
|
|
736
|
-
if (!TransitionRunning) o.state = STALE;
|
|
737
|
-
else o.tState = STALE;
|
|
662
|
+
if (!TransitionRunning) o.state = STALE;else o.tState = STALE;
|
|
738
663
|
}
|
|
739
664
|
if (Updates.length > 10e5) {
|
|
740
665
|
Updates = [];
|
|
@@ -753,11 +678,7 @@ function updateComputation(node) {
|
|
|
753
678
|
listener = Listener,
|
|
754
679
|
time = ExecCount;
|
|
755
680
|
Listener = Owner = node;
|
|
756
|
-
runComputation(
|
|
757
|
-
node,
|
|
758
|
-
Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value,
|
|
759
|
-
time
|
|
760
|
-
);
|
|
681
|
+
runComputation(node, Transition && Transition.running && Transition.sources.has(node) ? node.tValue : node.value, time);
|
|
761
682
|
if (Transition && !Transition.running && Transition.sources.has(node)) {
|
|
762
683
|
queueMicrotask(() => {
|
|
763
684
|
runUpdates(() => {
|
|
@@ -818,15 +739,11 @@ function createComputation(fn, init, pure, state = STALE, options) {
|
|
|
818
739
|
c.state = 0;
|
|
819
740
|
c.tState = state;
|
|
820
741
|
}
|
|
821
|
-
if (Owner === null)
|
|
822
|
-
console.warn("computations created outside a `createRoot` or `render` will never be disposed");
|
|
823
|
-
else if (Owner !== UNOWNED) {
|
|
742
|
+
if (Owner === null) console.warn("computations created outside a `createRoot` or `render` will never be disposed");else if (Owner !== UNOWNED) {
|
|
824
743
|
if (Transition && Transition.running && Owner.pure) {
|
|
825
|
-
if (!Owner.tOwned) Owner.tOwned = [c];
|
|
826
|
-
else Owner.tOwned.push(c);
|
|
744
|
+
if (!Owner.tOwned) Owner.tOwned = [c];else Owner.tOwned.push(c);
|
|
827
745
|
} else {
|
|
828
|
-
if (!Owner.owned) Owner.owned = [c];
|
|
829
|
-
else Owner.owned.push(c);
|
|
746
|
+
if (!Owner.owned) Owner.owned = [c];else Owner.owned.push(c);
|
|
830
747
|
}
|
|
831
748
|
}
|
|
832
749
|
if (options && options.name) c.name = options.name;
|
|
@@ -879,8 +796,7 @@ function runUpdates(fn, init) {
|
|
|
879
796
|
if (Updates) return fn();
|
|
880
797
|
let wait = false;
|
|
881
798
|
if (!init) Updates = [];
|
|
882
|
-
if (Effects) wait = true;
|
|
883
|
-
else Effects = [];
|
|
799
|
+
if (Effects) wait = true;else Effects = [];
|
|
884
800
|
ExecCount++;
|
|
885
801
|
try {
|
|
886
802
|
const res = fn();
|
|
@@ -894,8 +810,7 @@ function runUpdates(fn, init) {
|
|
|
894
810
|
}
|
|
895
811
|
function completeUpdates(wait) {
|
|
896
812
|
if (Updates) {
|
|
897
|
-
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);
|
|
898
|
-
else runQueue(Updates);
|
|
813
|
+
if (Scheduler && Transition && Transition.running) scheduleQueue(Updates);else runQueue(Updates);
|
|
899
814
|
Updates = null;
|
|
900
815
|
}
|
|
901
816
|
if (wait) return;
|
|
@@ -935,8 +850,7 @@ function completeUpdates(wait) {
|
|
|
935
850
|
}
|
|
936
851
|
const e = Effects;
|
|
937
852
|
Effects = null;
|
|
938
|
-
if (e.length) runUpdates(() => runEffects(e), false);
|
|
939
|
-
else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
853
|
+
if (e.length) runUpdates(() => runEffects(e), false);else DevHooks.afterUpdate && DevHooks.afterUpdate();
|
|
940
854
|
if (res) res();
|
|
941
855
|
}
|
|
942
856
|
function runQueue(queue) {
|
|
@@ -964,8 +878,7 @@ function runUserEffects(queue) {
|
|
|
964
878
|
userLength = 0;
|
|
965
879
|
for (i = 0; i < queue.length; i++) {
|
|
966
880
|
const e = queue[i];
|
|
967
|
-
if (!e.user) runTop(e);
|
|
968
|
-
else queue[userLength++] = e;
|
|
881
|
+
if (!e.user) runTop(e);else queue[userLength++] = e;
|
|
969
882
|
}
|
|
970
883
|
if (sharedConfig.context) {
|
|
971
884
|
if (sharedConfig.count) {
|
|
@@ -983,15 +896,13 @@ function runUserEffects(queue) {
|
|
|
983
896
|
}
|
|
984
897
|
function lookUpstream(node, ignore) {
|
|
985
898
|
const runningTransition = Transition && Transition.running;
|
|
986
|
-
if (runningTransition) node.tState = 0;
|
|
987
|
-
else node.state = 0;
|
|
899
|
+
if (runningTransition) node.tState = 0;else node.state = 0;
|
|
988
900
|
for (let i = 0; i < node.sources.length; i += 1) {
|
|
989
901
|
const source = node.sources[i];
|
|
990
902
|
if (source.sources) {
|
|
991
903
|
const state = runningTransition ? source.tState : source.state;
|
|
992
904
|
if (state === STALE) {
|
|
993
|
-
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount))
|
|
994
|
-
runTop(source);
|
|
905
|
+
if (source !== ignore && (!source.updatedAt || source.updatedAt < ExecCount)) runTop(source);
|
|
995
906
|
} else if (state === PENDING) lookUpstream(source, ignore);
|
|
996
907
|
}
|
|
997
908
|
}
|
|
@@ -1001,10 +912,8 @@ function markDownstream(node) {
|
|
|
1001
912
|
for (let i = 0; i < node.observers.length; i += 1) {
|
|
1002
913
|
const o = node.observers[i];
|
|
1003
914
|
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);
|
|
915
|
+
if (runningTransition) o.tState = PENDING;else o.state = PENDING;
|
|
916
|
+
if (o.pure) Updates.push(o);else Effects.push(o);
|
|
1008
917
|
o.observers && markDownstream(o);
|
|
1009
918
|
}
|
|
1010
919
|
}
|
|
@@ -1041,8 +950,7 @@ function cleanNode(node) {
|
|
|
1041
950
|
for (i = node.cleanups.length - 1; i >= 0; i--) node.cleanups[i]();
|
|
1042
951
|
node.cleanups = null;
|
|
1043
952
|
}
|
|
1044
|
-
if (Transition && Transition.running) node.tState = 0;
|
|
1045
|
-
else node.state = 0;
|
|
953
|
+
if (Transition && Transition.running) node.tState = 0;else node.state = 0;
|
|
1046
954
|
delete node.sourceMap;
|
|
1047
955
|
}
|
|
1048
956
|
function reset(node, top) {
|
|
@@ -1064,21 +972,19 @@ function runErrors(err, fns, owner) {
|
|
|
1064
972
|
try {
|
|
1065
973
|
for (const f of fns) f(err);
|
|
1066
974
|
} catch (e) {
|
|
1067
|
-
handleError(e,
|
|
975
|
+
handleError(e, owner && owner.owner || null);
|
|
1068
976
|
}
|
|
1069
977
|
}
|
|
1070
978
|
function handleError(err, owner = Owner) {
|
|
1071
979
|
const fns = ERROR && owner && owner.context && owner.context[ERROR];
|
|
1072
980
|
const error = castError(err);
|
|
1073
981
|
if (!fns) throw error;
|
|
1074
|
-
if (Effects)
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
});
|
|
1081
|
-
else runErrors(error, fns, owner);
|
|
982
|
+
if (Effects) Effects.push({
|
|
983
|
+
fn() {
|
|
984
|
+
runErrors(error, fns, owner);
|
|
985
|
+
},
|
|
986
|
+
state: STALE
|
|
987
|
+
});else runErrors(error, fns, owner);
|
|
1082
988
|
}
|
|
1083
989
|
function resolveChildren(children) {
|
|
1084
990
|
if (typeof children === "function" && !children.length) return resolveChildren(children());
|
|
@@ -1095,26 +1001,19 @@ function resolveChildren(children) {
|
|
|
1095
1001
|
function createProvider(id, options) {
|
|
1096
1002
|
return function provider(props) {
|
|
1097
1003
|
let res;
|
|
1098
|
-
createRenderEffect(
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
return children(() => props.children);
|
|
1106
|
-
})),
|
|
1107
|
-
undefined,
|
|
1108
|
-
options
|
|
1109
|
-
);
|
|
1004
|
+
createRenderEffect(() => res = untrack(() => {
|
|
1005
|
+
Owner.context = {
|
|
1006
|
+
...Owner.context,
|
|
1007
|
+
[id]: props.value
|
|
1008
|
+
};
|
|
1009
|
+
return children(() => props.children);
|
|
1010
|
+
}), undefined, options);
|
|
1110
1011
|
return res;
|
|
1111
1012
|
};
|
|
1112
1013
|
}
|
|
1113
1014
|
function onError(fn) {
|
|
1114
1015
|
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]) {
|
|
1016
|
+
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
1017
|
Owner.context = {
|
|
1119
1018
|
...Owner.context,
|
|
1120
1019
|
[ERROR]: [fn]
|
|
@@ -1143,8 +1042,7 @@ function observable(input) {
|
|
|
1143
1042
|
if (!(observer instanceof Object) || observer == null) {
|
|
1144
1043
|
throw new TypeError("Expected the observer to be an object.");
|
|
1145
1044
|
}
|
|
1146
|
-
const handler =
|
|
1147
|
-
typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1045
|
+
const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
|
|
1148
1046
|
if (!handler) {
|
|
1149
1047
|
return {
|
|
1150
1048
|
unsubscribe() {}
|
|
@@ -1175,7 +1073,7 @@ function from(producer) {
|
|
|
1175
1073
|
});
|
|
1176
1074
|
if ("subscribe" in producer) {
|
|
1177
1075
|
const unsub = producer.subscribe(v => set(() => v));
|
|
1178
|
-
onCleanup(() =>
|
|
1076
|
+
onCleanup(() => "unsubscribe" in unsub ? unsub.unsubscribe() : unsub());
|
|
1179
1077
|
} else {
|
|
1180
1078
|
const clean = producer(set);
|
|
1181
1079
|
onCleanup(clean);
|
|
@@ -1227,7 +1125,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1227
1125
|
});
|
|
1228
1126
|
len = 1;
|
|
1229
1127
|
}
|
|
1230
|
-
}
|
|
1128
|
+
}
|
|
1129
|
+
else if (len === 0) {
|
|
1231
1130
|
mapped = new Array(newLen);
|
|
1232
1131
|
for (j = 0; j < newLen; j++) {
|
|
1233
1132
|
items[j] = newItems[j];
|
|
@@ -1238,16 +1137,8 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1238
1137
|
temp = new Array(newLen);
|
|
1239
1138
|
tempdisposers = new Array(newLen);
|
|
1240
1139
|
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
|
-
) {
|
|
1140
|
+
for (start = 0, end = Math.min(len, newLen); start < end && items[start] === newItems[start]; start++);
|
|
1141
|
+
for (end = len - 1, newEnd = newLen - 1; end >= start && newEnd >= start && items[end] === newItems[newEnd]; end--, newEnd--) {
|
|
1251
1142
|
temp[newEnd] = mapped[end];
|
|
1252
1143
|
tempdisposers[newEnd] = disposers[end];
|
|
1253
1144
|
indexes && (tempIndexes[newEnd] = indexes[end]);
|
|
@@ -1281,7 +1172,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1281
1172
|
}
|
|
1282
1173
|
} else mapped[j] = createRoot(mapper);
|
|
1283
1174
|
}
|
|
1284
|
-
mapped = mapped.slice(0,
|
|
1175
|
+
mapped = mapped.slice(0, len = newLen);
|
|
1285
1176
|
items = newItems.slice(0);
|
|
1286
1177
|
}
|
|
1287
1178
|
return mapped;
|
|
@@ -1291,7 +1182,7 @@ function mapArray(list, mapFn, options = {}) {
|
|
|
1291
1182
|
if (indexes) {
|
|
1292
1183
|
const [s, set] = createSignal(j, {
|
|
1293
1184
|
name: "index"
|
|
1294
|
-
});
|
|
1185
|
+
}) ;
|
|
1295
1186
|
indexes[j] = set;
|
|
1296
1187
|
return mapFn(newItems[j], s);
|
|
1297
1188
|
}
|
|
@@ -1349,13 +1240,13 @@ function indexArray(list, mapFn, options = {}) {
|
|
|
1349
1240
|
}
|
|
1350
1241
|
len = signals.length = disposers.length = newItems.length;
|
|
1351
1242
|
items = newItems.slice(0);
|
|
1352
|
-
return
|
|
1243
|
+
return mapped = mapped.slice(0, len);
|
|
1353
1244
|
});
|
|
1354
1245
|
function mapper(disposer) {
|
|
1355
1246
|
disposers[i] = disposer;
|
|
1356
1247
|
const [s, set] = createSignal(newItems[i], {
|
|
1357
1248
|
name: "value"
|
|
1358
|
-
});
|
|
1249
|
+
}) ;
|
|
1359
1250
|
signals[i] = set;
|
|
1360
1251
|
return mapFn(s, i);
|
|
1361
1252
|
}
|
|
@@ -1371,7 +1262,7 @@ function createComponent(Comp, props) {
|
|
|
1371
1262
|
if (sharedConfig.context) {
|
|
1372
1263
|
const c = sharedConfig.context;
|
|
1373
1264
|
setHydrateContext(nextHydrateContext());
|
|
1374
|
-
const r = devComponent(Comp, props || {});
|
|
1265
|
+
const r = devComponent(Comp, props || {}) ;
|
|
1375
1266
|
setHydrateContext(c);
|
|
1376
1267
|
return r;
|
|
1377
1268
|
}
|
|
@@ -1420,33 +1311,29 @@ function mergeProps(...sources) {
|
|
|
1420
1311
|
let proxy = false;
|
|
1421
1312
|
for (let i = 0; i < sources.length; i++) {
|
|
1422
1313
|
const s = sources[i];
|
|
1423
|
-
proxy = proxy ||
|
|
1424
|
-
sources[i] = typeof s === "function" ? (
|
|
1314
|
+
proxy = proxy || !!s && $PROXY in s;
|
|
1315
|
+
sources[i] = typeof s === "function" ? (proxy = true, createMemo(s)) : s;
|
|
1425
1316
|
}
|
|
1426
1317
|
if (proxy) {
|
|
1427
|
-
return new Proxy(
|
|
1428
|
-
{
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
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)];
|
|
1318
|
+
return new Proxy({
|
|
1319
|
+
get(property) {
|
|
1320
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1321
|
+
const v = resolveSource(sources[i])[property];
|
|
1322
|
+
if (v !== undefined) return v;
|
|
1323
|
+
}
|
|
1324
|
+
},
|
|
1325
|
+
has(property) {
|
|
1326
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
1327
|
+
if (property in resolveSource(sources[i])) return true;
|
|
1446
1328
|
}
|
|
1329
|
+
return false;
|
|
1447
1330
|
},
|
|
1448
|
-
|
|
1449
|
-
|
|
1331
|
+
keys() {
|
|
1332
|
+
const keys = [];
|
|
1333
|
+
for (let i = 0; i < sources.length; i++) keys.push(...Object.keys(resolveSource(sources[i])));
|
|
1334
|
+
return [...new Set(keys)];
|
|
1335
|
+
}
|
|
1336
|
+
}, propTraps);
|
|
1450
1337
|
}
|
|
1451
1338
|
const target = {};
|
|
1452
1339
|
const sourcesMap = {};
|
|
@@ -1465,7 +1352,7 @@ function mergeProps(...sources) {
|
|
|
1465
1352
|
Object.defineProperty(target, key, {
|
|
1466
1353
|
enumerable: true,
|
|
1467
1354
|
configurable: true,
|
|
1468
|
-
get: resolveSources.bind(
|
|
1355
|
+
get: resolveSources.bind(sourcesMap[key] = [desc.get.bind(source)])
|
|
1469
1356
|
});
|
|
1470
1357
|
} else {
|
|
1471
1358
|
if (desc.value !== undefined) defined.add(key);
|
|
@@ -1489,60 +1376,47 @@ function splitProps(props, ...keys) {
|
|
|
1489
1376
|
if ($PROXY in props) {
|
|
1490
1377
|
const blocked = new Set(keys.length > 1 ? keys.flat() : keys[0]);
|
|
1491
1378
|
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
|
-
}
|
|
1379
|
+
return new Proxy({
|
|
1380
|
+
get(property) {
|
|
1381
|
+
return k.includes(property) ? props[property] : undefined;
|
|
1503
1382
|
},
|
|
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
|
-
}
|
|
1383
|
+
has(property) {
|
|
1384
|
+
return k.includes(property) && property in props;
|
|
1519
1385
|
},
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1386
|
+
keys() {
|
|
1387
|
+
return k.filter(property => property in props);
|
|
1388
|
+
}
|
|
1389
|
+
}, propTraps);
|
|
1390
|
+
});
|
|
1391
|
+
res.push(new Proxy({
|
|
1392
|
+
get(property) {
|
|
1393
|
+
return blocked.has(property) ? undefined : props[property];
|
|
1394
|
+
},
|
|
1395
|
+
has(property) {
|
|
1396
|
+
return blocked.has(property) ? false : property in props;
|
|
1397
|
+
},
|
|
1398
|
+
keys() {
|
|
1399
|
+
return Object.keys(props).filter(k => !blocked.has(k));
|
|
1400
|
+
}
|
|
1401
|
+
}, propTraps));
|
|
1523
1402
|
return res;
|
|
1524
1403
|
}
|
|
1525
1404
|
const otherObject = {};
|
|
1526
1405
|
const objects = keys.map(() => ({}));
|
|
1527
1406
|
for (const propName of Object.getOwnPropertyNames(props)) {
|
|
1528
1407
|
const desc = Object.getOwnPropertyDescriptor(props, propName);
|
|
1529
|
-
const isDefaultDesc =
|
|
1530
|
-
!desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1408
|
+
const isDefaultDesc = !desc.get && !desc.set && desc.enumerable && desc.writable && desc.configurable;
|
|
1531
1409
|
let blocked = false;
|
|
1532
1410
|
let objectIndex = 0;
|
|
1533
1411
|
for (const k of keys) {
|
|
1534
1412
|
if (k.includes(propName)) {
|
|
1535
1413
|
blocked = true;
|
|
1536
|
-
isDefaultDesc
|
|
1537
|
-
? (objects[objectIndex][propName] = desc.value)
|
|
1538
|
-
: Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1414
|
+
isDefaultDesc ? objects[objectIndex][propName] = desc.value : Object.defineProperty(objects[objectIndex], propName, desc);
|
|
1539
1415
|
}
|
|
1540
1416
|
++objectIndex;
|
|
1541
1417
|
}
|
|
1542
1418
|
if (!blocked) {
|
|
1543
|
-
isDefaultDesc
|
|
1544
|
-
? (otherObject[propName] = desc.value)
|
|
1545
|
-
: Object.defineProperty(otherObject, propName, desc);
|
|
1419
|
+
isDefaultDesc ? otherObject[propName] = desc.value : Object.defineProperty(otherObject, propName, desc);
|
|
1546
1420
|
}
|
|
1547
1421
|
}
|
|
1548
1422
|
return [...objects, otherObject];
|
|
@@ -1568,24 +1442,19 @@ function lazy(fn) {
|
|
|
1568
1442
|
comp = s;
|
|
1569
1443
|
}
|
|
1570
1444
|
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
|
-
);
|
|
1445
|
+
return createMemo(() => (Comp = comp()) && untrack(() => {
|
|
1446
|
+
if (true) Object.assign(Comp, {
|
|
1447
|
+
[$DEVCOMP]: true
|
|
1448
|
+
});
|
|
1449
|
+
if (!ctx) return Comp(props);
|
|
1450
|
+
const c = sharedConfig.context;
|
|
1451
|
+
setHydrateContext(ctx);
|
|
1452
|
+
const r = Comp(props);
|
|
1453
|
+
setHydrateContext(c);
|
|
1454
|
+
return r;
|
|
1455
|
+
}));
|
|
1587
1456
|
};
|
|
1588
|
-
wrap.preload = () => p || ((p = fn()).then(mod =>
|
|
1457
|
+
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
1589
1458
|
return wrap;
|
|
1590
1459
|
}
|
|
1591
1460
|
let counter = 0;
|
|
@@ -1594,113 +1463,75 @@ function createUniqueId() {
|
|
|
1594
1463
|
return ctx ? `${ctx.id}${ctx.count++}` : `cl-${counter++}`;
|
|
1595
1464
|
}
|
|
1596
1465
|
|
|
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.`;
|
|
1466
|
+
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
1467
|
function For(props) {
|
|
1600
1468
|
const fallback = "fallback" in props && {
|
|
1601
1469
|
fallback: () => props.fallback
|
|
1602
1470
|
};
|
|
1603
|
-
return createMemo(
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
{
|
|
1607
|
-
name: "value"
|
|
1608
|
-
}
|
|
1609
|
-
);
|
|
1471
|
+
return createMemo(mapArray(() => props.each, props.children, fallback || undefined), undefined, {
|
|
1472
|
+
name: "value"
|
|
1473
|
+
}) ;
|
|
1610
1474
|
}
|
|
1611
1475
|
function Index(props) {
|
|
1612
1476
|
const fallback = "fallback" in props && {
|
|
1613
1477
|
fallback: () => props.fallback
|
|
1614
1478
|
};
|
|
1615
|
-
return createMemo(
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
{
|
|
1619
|
-
name: "value"
|
|
1620
|
-
}
|
|
1621
|
-
);
|
|
1479
|
+
return createMemo(indexArray(() => props.each, props.children, fallback || undefined), undefined, {
|
|
1480
|
+
name: "value"
|
|
1481
|
+
}) ;
|
|
1622
1482
|
}
|
|
1623
1483
|
function Show(props) {
|
|
1624
1484
|
const keyed = props.keyed;
|
|
1625
1485
|
const condition = createMemo(() => props.when, undefined, {
|
|
1626
|
-
equals: (a, b) =>
|
|
1486
|
+
equals: (a, b) => keyed ? a === b : !a === !b,
|
|
1627
1487
|
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"
|
|
1488
|
+
} );
|
|
1489
|
+
return createMemo(() => {
|
|
1490
|
+
const c = condition();
|
|
1491
|
+
if (c) {
|
|
1492
|
+
const child = props.children;
|
|
1493
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
1494
|
+
return fn ? untrack(() => child(keyed ? c : () => {
|
|
1495
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
1496
|
+
return props.when;
|
|
1497
|
+
})) : child;
|
|
1653
1498
|
}
|
|
1654
|
-
|
|
1499
|
+
return props.fallback;
|
|
1500
|
+
}, undefined, {
|
|
1501
|
+
name: "value"
|
|
1502
|
+
} );
|
|
1655
1503
|
}
|
|
1656
1504
|
function Switch(props) {
|
|
1657
1505
|
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];
|
|
1506
|
+
const equals = (a, b) => a[0] === b[0] && (keyed ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2];
|
|
1660
1507
|
const conditions = children(() => props.children),
|
|
1661
|
-
evalConditions = createMemo(
|
|
1662
|
-
()
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
return [i, c, conds[i]];
|
|
1670
|
-
}
|
|
1508
|
+
evalConditions = createMemo(() => {
|
|
1509
|
+
let conds = conditions();
|
|
1510
|
+
if (!Array.isArray(conds)) conds = [conds];
|
|
1511
|
+
for (let i = 0; i < conds.length; i++) {
|
|
1512
|
+
const c = conds[i].when;
|
|
1513
|
+
if (c) {
|
|
1514
|
+
keyed = !!conds[i].keyed;
|
|
1515
|
+
return [i, c, conds[i]];
|
|
1671
1516
|
}
|
|
1672
|
-
return [-1];
|
|
1673
|
-
},
|
|
1674
|
-
undefined,
|
|
1675
|
-
{
|
|
1676
|
-
equals,
|
|
1677
|
-
name: "eval conditions"
|
|
1678
1517
|
}
|
|
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
|
-
);
|
|
1518
|
+
return [-1];
|
|
1519
|
+
}, undefined, {
|
|
1520
|
+
equals,
|
|
1521
|
+
name: "eval conditions"
|
|
1522
|
+
} );
|
|
1523
|
+
return createMemo(() => {
|
|
1524
|
+
const [index, when, cond] = evalConditions();
|
|
1525
|
+
if (index < 0) return props.fallback;
|
|
1526
|
+
const c = cond.children;
|
|
1527
|
+
const fn = typeof c === "function" && c.length > 0;
|
|
1528
|
+
return fn ? untrack(() => c(keyed ? when : () => {
|
|
1529
|
+
if (untrack(evalConditions)[0] !== index) throw narrowedError("Match");
|
|
1530
|
+
return cond.when;
|
|
1531
|
+
})) : c;
|
|
1532
|
+
}, undefined, {
|
|
1533
|
+
name: "value"
|
|
1534
|
+
} );
|
|
1704
1535
|
}
|
|
1705
1536
|
function Match(props) {
|
|
1706
1537
|
return props;
|
|
@@ -1711,33 +1542,27 @@ function resetErrorBoundaries() {
|
|
|
1711
1542
|
}
|
|
1712
1543
|
function ErrorBoundary(props) {
|
|
1713
1544
|
let err;
|
|
1714
|
-
if (sharedConfig.context && sharedConfig.load)
|
|
1715
|
-
err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1545
|
+
if (sharedConfig.context && sharedConfig.load) err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
|
|
1716
1546
|
const [errored, setErrored] = createSignal(err, {
|
|
1717
1547
|
name: "errored"
|
|
1718
|
-
});
|
|
1548
|
+
} );
|
|
1719
1549
|
Errors || (Errors = new Set());
|
|
1720
1550
|
Errors.add(setErrored);
|
|
1721
1551
|
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"
|
|
1552
|
+
return createMemo(() => {
|
|
1553
|
+
let e;
|
|
1554
|
+
if (e = errored()) {
|
|
1555
|
+
const f = props.fallback;
|
|
1556
|
+
if ((typeof f !== "function" || f.length == 0)) console.error(e);
|
|
1557
|
+
return typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
|
|
1735
1558
|
}
|
|
1736
|
-
|
|
1559
|
+
return catchError(() => props.children, setErrored);
|
|
1560
|
+
}, undefined, {
|
|
1561
|
+
name: "value"
|
|
1562
|
+
} );
|
|
1737
1563
|
}
|
|
1738
1564
|
|
|
1739
|
-
const suspenseListEquals = (a, b) =>
|
|
1740
|
-
a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1565
|
+
const suspenseListEquals = (a, b) => a.showContent === b.showContent && a.showFallback === b.showFallback;
|
|
1741
1566
|
const SuspenseListContext = createContext();
|
|
1742
1567
|
function SuspenseList(props) {
|
|
1743
1568
|
let [wrapper, setWrapper] = createSignal(() => ({
|
|
@@ -1749,51 +1574,51 @@ function SuspenseList(props) {
|
|
|
1749
1574
|
if (listContext) {
|
|
1750
1575
|
show = listContext.register(createMemo(() => wrapper()().inFallback));
|
|
1751
1576
|
}
|
|
1752
|
-
const resolved = createMemo(
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1577
|
+
const resolved = createMemo(prev => {
|
|
1578
|
+
const reveal = props.revealOrder,
|
|
1579
|
+
tail = props.tail,
|
|
1580
|
+
{
|
|
1581
|
+
showContent = true,
|
|
1582
|
+
showFallback = true
|
|
1583
|
+
} = show ? show() : {},
|
|
1584
|
+
reg = registry(),
|
|
1585
|
+
reverse = reveal === "backwards";
|
|
1586
|
+
if (reveal === "together") {
|
|
1587
|
+
const all = reg.every(inFallback => !inFallback());
|
|
1588
|
+
const res = reg.map(() => ({
|
|
1589
|
+
showContent: all && showContent,
|
|
1590
|
+
showFallback
|
|
1591
|
+
}));
|
|
1592
|
+
res.inFallback = !all;
|
|
1593
|
+
return res;
|
|
1594
|
+
}
|
|
1595
|
+
let stop = false;
|
|
1596
|
+
let inFallback = prev.inFallback;
|
|
1597
|
+
const res = [];
|
|
1598
|
+
for (let i = 0, len = reg.length; i < len; i++) {
|
|
1599
|
+
const n = reverse ? len - i - 1 : i,
|
|
1600
|
+
s = reg[n]();
|
|
1601
|
+
if (!stop && !s) {
|
|
1602
|
+
res[n] = {
|
|
1603
|
+
showContent,
|
|
1763
1604
|
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
|
-
}
|
|
1605
|
+
};
|
|
1606
|
+
} else {
|
|
1607
|
+
const next = !stop;
|
|
1608
|
+
if (next) inFallback = true;
|
|
1609
|
+
res[n] = {
|
|
1610
|
+
showContent: next,
|
|
1611
|
+
showFallback: !tail || next && tail === "collapsed" ? showFallback : false
|
|
1612
|
+
};
|
|
1613
|
+
stop = true;
|
|
1788
1614
|
}
|
|
1789
|
-
if (!stop) inFallback = false;
|
|
1790
|
-
res.inFallback = inFallback;
|
|
1791
|
-
return res;
|
|
1792
|
-
},
|
|
1793
|
-
{
|
|
1794
|
-
inFallback: false
|
|
1795
1615
|
}
|
|
1796
|
-
|
|
1616
|
+
if (!stop) inFallback = false;
|
|
1617
|
+
res.inFallback = inFallback;
|
|
1618
|
+
return res;
|
|
1619
|
+
}, {
|
|
1620
|
+
inFallback: false
|
|
1621
|
+
});
|
|
1797
1622
|
setWrapper(() => resolved);
|
|
1798
1623
|
return createComponent(SuspenseListContext.Provider, {
|
|
1799
1624
|
value: {
|
|
@@ -1868,14 +1693,17 @@ function Suspense(props) {
|
|
|
1868
1693
|
ctx = sharedConfig.context;
|
|
1869
1694
|
if (flicker) {
|
|
1870
1695
|
flicker();
|
|
1871
|
-
return
|
|
1696
|
+
return flicker = undefined;
|
|
1872
1697
|
}
|
|
1873
1698
|
if (ctx && p === "$$f") setHydrateContext();
|
|
1874
1699
|
const rendered = createMemo(() => props.children);
|
|
1875
1700
|
return createMemo(prev => {
|
|
1876
1701
|
const inFallback = store.inFallback(),
|
|
1877
|
-
{
|
|
1878
|
-
|
|
1702
|
+
{
|
|
1703
|
+
showContent = true,
|
|
1704
|
+
showFallback = true
|
|
1705
|
+
} = show ? show() : {};
|
|
1706
|
+
if ((!inFallback || p && p !== "$$f") && showContent) {
|
|
1879
1707
|
store.resolved = true;
|
|
1880
1708
|
dispose && dispose();
|
|
1881
1709
|
dispose = ctx = p = undefined;
|
|
@@ -1905,68 +1733,9 @@ const DEV = {
|
|
|
1905
1733
|
hooks: DevHooks,
|
|
1906
1734
|
writeSignal,
|
|
1907
1735
|
registerGraph
|
|
1908
|
-
};
|
|
1736
|
+
} ;
|
|
1909
1737
|
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
|
-
);
|
|
1738
|
+
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
1915
1739
|
}
|
|
1916
1740
|
|
|
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
|
-
};
|
|
1741
|
+
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 };
|