marko 6.3.20 → 6.3.22
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/cheatsheet.md +29 -3
- package/dist/common/accessor.d.ts +21 -75
- package/dist/common/accessor.debug.d.ts +21 -75
- package/dist/common/constants/accessor-prefix.d.ts +16 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +16 -0
- package/dist/common/constants/accessor-prop.d.ts +30 -0
- package/dist/common/constants/accessor-prop.debug.d.ts +30 -0
- package/dist/common/constants/closure-signal-prop.d.ts +6 -0
- package/dist/common/constants/closure-signal-prop.debug.d.ts +6 -0
- package/dist/common/constants/controlled-type.d.ts +9 -0
- package/dist/common/constants/keyed-scopes-prop.d.ts +4 -0
- package/dist/common/constants/keyed-scopes-prop.debug.d.ts +4 -0
- package/dist/common/constants/load-signal-value.d.ts +5 -0
- package/dist/common/constants/load-signal-value.debug.d.ts +5 -0
- package/dist/common/constants/node-type.d.ts +7 -0
- package/dist/common/constants/pending-render-prop.d.ts +9 -0
- package/dist/common/constants/pending-render-prop.debug.d.ts +9 -0
- package/dist/common/constants/renderer-prop.d.ts +12 -0
- package/dist/common/constants/renderer-prop.debug.d.ts +12 -0
- package/dist/common/constants/resume-symbol.d.ts +10 -0
- package/dist/common/constants/walk-code.d.ts +17 -0
- package/dist/common/constants/walk-range-size.d.ts +7 -0
- package/dist/common/types.d.ts +15 -45
- package/dist/debug/dom.js +291 -225
- package/dist/debug/dom.mjs +291 -225
- package/dist/debug/html.js +187 -41
- package/dist/debug/html.mjs +187 -42
- package/dist/dom/compat.d.ts +1 -1
- package/dist/dom/control-flow.d.ts +1 -1
- package/dist/dom/renderer.d.ts +2 -2
- package/dist/dom/scope.d.ts +1 -1
- package/dist/dom.js +8 -6
- package/dist/dom.mjs +8 -6
- package/dist/html/constants/char.d.ts +11 -0
- package/dist/html/constants/flush-status.d.ts +6 -0
- package/dist/html/constants/mark.d.ts +6 -0
- package/dist/html/constants/runtime-key.d.ts +7 -0
- package/dist/html/writer.d.ts +20 -23
- package/dist/html.d.ts +1 -1
- package/dist/html.js +131 -29
- package/dist/html.mjs +131 -29
- package/dist/translator/core/if.d.ts +7 -7
- package/dist/translator/core/index.d.ts +7 -7
- package/dist/translator/index.d.ts +9 -9
- package/dist/translator/index.js +245 -139
- package/dist/translator/interop/constants/feature-type.d.ts +5 -0
- package/dist/translator/interop/index.d.ts +2 -2
- package/dist/translator/util/body-to-text-literal.d.ts +2 -2
- package/dist/translator/util/constants/binding-type.d.ts +10 -0
- package/dist/translator/util/constants/compile-stage.d.ts +8 -0
- package/dist/translator/util/constants/content-type.d.ts +8 -0
- package/dist/translator/util/constants/step.d.ts +5 -0
- package/dist/translator/util/constants/tag-name-type.d.ts +7 -0
- package/dist/translator/util/is-static.d.ts +1 -1
- package/dist/translator/util/references.d.ts +9 -12
- package/dist/translator/util/sections.d.ts +4 -8
- package/dist/translator/util/signals.d.ts +1 -0
- package/dist/translator/util/tag-name-type.d.ts +4 -7
- package/dist/translator/util/walks.d.ts +4 -6
- package/dist/translator/visitors/constants/sibling-text.d.ts +7 -0
- package/dist/translator/visitors/placeholder.d.ts +2 -6
- package/dist/translator/visitors/program/index.d.ts +1 -0
- package/dist/translator/visitors/tag/constants/class-hydration.d.ts +5 -0
- package/dist/translator/visitors/tag/dynamic-tag.d.ts +2 -4
- package/package.json +16 -16
- package/tags-html.d.ts +98 -22
package/dist/debug/dom.mjs
CHANGED
|
@@ -19,6 +19,70 @@ function* attrTagIterator() {
|
|
|
19
19
|
yield* this[rest];
|
|
20
20
|
}
|
|
21
21
|
//#endregion
|
|
22
|
+
//#region src/common/constants/accessor-prefix.debug.ts
|
|
23
|
+
const BranchScopes$1 = "BranchScopes:";
|
|
24
|
+
const ClosureScopes = "ClosureScopes:";
|
|
25
|
+
const ClosureSignalIndex = "ClosureSignalIndex:";
|
|
26
|
+
const ConditionalRenderer = "ConditionalRenderer:";
|
|
27
|
+
const ControlledHandler = "ControlledHandler:";
|
|
28
|
+
const ControlledType = "ControlledType:";
|
|
29
|
+
const ControlledValue = "ControlledValue:";
|
|
30
|
+
const DynamicHTMLLastChild = "DynamicHTMLLastChild:";
|
|
31
|
+
const EventAttributes = "EventAttributes:";
|
|
32
|
+
const KeyedScopes = "KeyedScopes:";
|
|
33
|
+
const Lifecycle = "Lifecycle:";
|
|
34
|
+
const Promise$1 = "Promise:";
|
|
35
|
+
const TagVariableChange$1 = "TagVariableChange:";
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/common/constants/accessor-prop.debug.ts
|
|
38
|
+
const Global = "$global";
|
|
39
|
+
const AbortControllers = "#AbortControllers";
|
|
40
|
+
const AbortScopes = "#AbortScopes";
|
|
41
|
+
const AwaitCounter = "#AwaitCounter";
|
|
42
|
+
const BranchAccessor = "#BranchAccessor";
|
|
43
|
+
const BranchScopes = "#BranchScopes";
|
|
44
|
+
const CatchContent = "#CatchContent";
|
|
45
|
+
const ClosestBranch = "#ClosestBranch";
|
|
46
|
+
const ClosestBranchId = "#ClosestBranchId";
|
|
47
|
+
const Gen$1 = "#Gen";
|
|
48
|
+
const DetachedAwait = "#DetachedAwait";
|
|
49
|
+
const EndNode = "#EndNode";
|
|
50
|
+
const Load = "#Load";
|
|
51
|
+
const LoopKey = "#LoopKey";
|
|
52
|
+
const ParentBranch = "#ParentBranch";
|
|
53
|
+
const PendingEffects = "#PendingEffects";
|
|
54
|
+
const PendingRenders = "#PendingRenders";
|
|
55
|
+
const PendingScopes = "#PendingScopes";
|
|
56
|
+
const PlaceholderBranch = "#PlaceholderBranch";
|
|
57
|
+
const PlaceholderContent = "#PlaceholderContent";
|
|
58
|
+
const Renderer = "#Renderer";
|
|
59
|
+
const StartNode = "#StartNode";
|
|
60
|
+
const TagVariable = "#TagVariable";
|
|
61
|
+
const TagVariableChange = "#TagVariableChange";
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/common/constants/closure-signal-prop.debug.ts
|
|
64
|
+
const ScopeInstancesAccessor = "scopeInstancesAccessor";
|
|
65
|
+
const SignalIndexAccessor = "signalIndexAccessor";
|
|
66
|
+
const Index = "index";
|
|
67
|
+
//#endregion
|
|
68
|
+
//#region src/common/constants/keyed-scopes-prop.debug.ts
|
|
69
|
+
const PreviousKey = "PreviousKey:";
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/common/constants/load-signal-value.debug.ts
|
|
72
|
+
const Value$1 = "value";
|
|
73
|
+
const Signal$1 = "signal";
|
|
74
|
+
const Scope = "scope";
|
|
75
|
+
const Signal = "signal";
|
|
76
|
+
const Value = "value";
|
|
77
|
+
const Pending = "pending";
|
|
78
|
+
const Clone = "clone";
|
|
79
|
+
const Setup = "setup";
|
|
80
|
+
const Params = "params";
|
|
81
|
+
const Owner = "owner";
|
|
82
|
+
const Accessor = "accessor";
|
|
83
|
+
const LocalClosures = "localClosures";
|
|
84
|
+
const LocalClosureValues = "localClosureValues";
|
|
85
|
+
//#endregion
|
|
22
86
|
//#region src/common/helpers.ts
|
|
23
87
|
const htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
24
88
|
const knownWrongAttrs = {
|
|
@@ -310,15 +374,15 @@ let collectingScopes;
|
|
|
310
374
|
function createScope($global, closestBranch) {
|
|
311
375
|
const scope = {
|
|
312
376
|
["#Id"]: nextScopeId++,
|
|
313
|
-
[
|
|
314
|
-
[
|
|
315
|
-
[
|
|
377
|
+
[Gen$1]: runId,
|
|
378
|
+
[ClosestBranch]: closestBranch,
|
|
379
|
+
[Global]: $global
|
|
316
380
|
};
|
|
317
381
|
collectingScopes?.push(scope);
|
|
318
382
|
return scope;
|
|
319
383
|
}
|
|
320
384
|
function syncGen(scope) {
|
|
321
|
-
scope[
|
|
385
|
+
scope[Gen$1] = runId;
|
|
322
386
|
}
|
|
323
387
|
function _assert_init(scope, accessor) {
|
|
324
388
|
if (scope["#Gen"] === runId || !(accessor in scope)) throw new ReferenceError(`Cannot access '${accessor}' before initialization`);
|
|
@@ -338,12 +402,12 @@ function skipScope() {
|
|
|
338
402
|
return nextScopeId++;
|
|
339
403
|
}
|
|
340
404
|
function findBranchWithKey(scope, key) {
|
|
341
|
-
let branch = scope[
|
|
342
|
-
while (branch && branch[key] == null) branch = branch[
|
|
405
|
+
let branch = scope[ClosestBranch];
|
|
406
|
+
while (branch && branch[key] == null) branch = branch[ParentBranch];
|
|
343
407
|
return branch;
|
|
344
408
|
}
|
|
345
409
|
function destroyBranch(branch) {
|
|
346
|
-
branch[
|
|
410
|
+
branch[ParentBranch]?.[BranchScopes]?.delete(branch);
|
|
347
411
|
destroyNestedScopes(branch);
|
|
348
412
|
}
|
|
349
413
|
function destroyScope(scope) {
|
|
@@ -353,24 +417,24 @@ function destroyScope(scope) {
|
|
|
353
417
|
}
|
|
354
418
|
}
|
|
355
419
|
const destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
356
|
-
scope[
|
|
357
|
-
scope[
|
|
358
|
-
scope[
|
|
420
|
+
scope[Gen$1] = 0;
|
|
421
|
+
scope[BranchScopes]?.forEach(destroyNestedScopes);
|
|
422
|
+
scope[AbortScopes]?.forEach(resetControllers);
|
|
359
423
|
};
|
|
360
424
|
function resetControllers(scope) {
|
|
361
|
-
for (const id in scope[
|
|
425
|
+
for (const id in scope[AbortControllers]) $signalReset(scope, id);
|
|
362
426
|
}
|
|
363
427
|
function removeAndDestroyBranch(branch) {
|
|
364
428
|
destroyBranch(branch);
|
|
365
|
-
removeChildNodes(branch[
|
|
429
|
+
removeChildNodes(branch[StartNode], branch[EndNode]);
|
|
366
430
|
}
|
|
367
431
|
function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
368
|
-
insertChildNodes(parentNode, nextSibling, branch[
|
|
432
|
+
insertChildNodes(parentNode, nextSibling, branch[StartNode], branch[EndNode]);
|
|
369
433
|
}
|
|
370
434
|
function tempDetachBranch(branch) {
|
|
371
435
|
const fragment = new DocumentFragment();
|
|
372
|
-
fragment.namespaceURI = branch[
|
|
373
|
-
insertChildNodes(fragment, null, branch[
|
|
436
|
+
fragment.namespaceURI = branch[StartNode].parentNode.namespaceURI;
|
|
437
|
+
insertChildNodes(fragment, null, branch[StartNode], branch[EndNode]);
|
|
374
438
|
}
|
|
375
439
|
//#endregion
|
|
376
440
|
//#region src/dom/schedule.ts
|
|
@@ -425,7 +489,7 @@ function _let(id, fn) {
|
|
|
425
489
|
}
|
|
426
490
|
function _let_change(id, fn) {
|
|
427
491
|
const valueAccessor = id.slice(0, id.lastIndexOf("/"));
|
|
428
|
-
const valueChangeAccessor =
|
|
492
|
+
const valueChangeAccessor = TagVariableChange$1 + valueAccessor;
|
|
429
493
|
const base = _let(id, fn);
|
|
430
494
|
return (scope, value, valueChange) => {
|
|
431
495
|
if (rendering) if ((scope[valueChangeAccessor] = valueChange) && (scope[valueAccessor] !== value || !(valueAccessor in scope))) {
|
|
@@ -454,7 +518,7 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
|
454
518
|
};
|
|
455
519
|
}
|
|
456
520
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
457
|
-
const scopeAccessor =
|
|
521
|
+
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
458
522
|
const ownerSignal = (ownerScope) => {
|
|
459
523
|
const scopes = toArray(ownerScope[scopeAccessor]);
|
|
460
524
|
if (scopes.length) queueRender(ownerScope, () => {
|
|
@@ -465,9 +529,9 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
465
529
|
return ownerSignal;
|
|
466
530
|
}
|
|
467
531
|
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, keyValueAccessor, fn) {
|
|
468
|
-
const scopeAccessor =
|
|
469
|
-
const mapAccessor =
|
|
470
|
-
const prevKeyProp =
|
|
532
|
+
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
533
|
+
const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
|
|
534
|
+
const prevKeyProp = `${PreviousKey}${ownerValueAccessor}`;
|
|
471
535
|
const ownerSignal = (ownerScope) => {
|
|
472
536
|
const scopes = toArray(ownerScope[scopeAccessor]);
|
|
473
537
|
if (ownerScope["#Gen"] < runId && scopes.length) {
|
|
@@ -494,7 +558,7 @@ function keyedScopes(ownerScope, scopeAccessor, mapAccessor, keyValueAccessor) {
|
|
|
494
558
|
if (!map.size) for (const scope of toArray(ownerScope[scopeAccessor])) {
|
|
495
559
|
const key = scope["#LoopKey"] ?? scope[keyValueAccessor];
|
|
496
560
|
if (key === void 0) return ownerScope[mapAccessor] = null;
|
|
497
|
-
scope[
|
|
561
|
+
scope[LoopKey] = key;
|
|
498
562
|
map.set(key, scope);
|
|
499
563
|
}
|
|
500
564
|
return map;
|
|
@@ -503,8 +567,8 @@ function runLiveBranch(scope, fn) {
|
|
|
503
567
|
if (scope && scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
|
|
504
568
|
}
|
|
505
569
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
506
|
-
const scopeAccessor =
|
|
507
|
-
const branchAccessor =
|
|
570
|
+
const scopeAccessor = BranchScopes$1 + ownerConditionalNodeAccessor;
|
|
571
|
+
const branchAccessor = ConditionalRenderer + ownerConditionalNodeAccessor;
|
|
508
572
|
const ownerSignal = (scope) => {
|
|
509
573
|
const ifScope = scope[scopeAccessor];
|
|
510
574
|
if (ifScope && ifScope["#Gen"] > 0 && ifScope["#Gen"] < runId && (scope[branchAccessor] || 0) === branch) queueRender(ifScope, fn, -1);
|
|
@@ -521,9 +585,9 @@ function subscribeToScopeSet(ownerScope, accessor, scope) {
|
|
|
521
585
|
}
|
|
522
586
|
function _closure(...closureSignals) {
|
|
523
587
|
const [firstSignal] = closureSignals;
|
|
524
|
-
const scopeInstances = firstSignal[
|
|
525
|
-
const signalIndex = firstSignal[
|
|
526
|
-
for (let i = closureSignals.length; i--;) closureSignals[i][
|
|
588
|
+
const scopeInstances = firstSignal[ScopeInstancesAccessor];
|
|
589
|
+
const signalIndex = firstSignal[SignalIndexAccessor];
|
|
590
|
+
for (let i = closureSignals.length; i--;) closureSignals[i][Index] = i;
|
|
527
591
|
return (scope) => {
|
|
528
592
|
if (scope[scopeInstances]) {
|
|
529
593
|
for (const childScope of scope[scopeInstances]) if (childScope["#Gen"] > 0 && childScope["#Gen"] < runId) queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
|
|
@@ -532,12 +596,12 @@ function _closure(...closureSignals) {
|
|
|
532
596
|
}
|
|
533
597
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
534
598
|
const closureSignal = ((scope) => {
|
|
535
|
-
scope[closureSignal[
|
|
599
|
+
scope[closureSignal[SignalIndexAccessor]] = closureSignal[Index];
|
|
536
600
|
fn(scope);
|
|
537
|
-
subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope["_"], closureSignal[
|
|
601
|
+
subscribeToScopeSet(getOwnerScope ? getOwnerScope(scope) : scope["_"], closureSignal[ScopeInstancesAccessor], scope);
|
|
538
602
|
});
|
|
539
|
-
closureSignal[
|
|
540
|
-
closureSignal[
|
|
603
|
+
closureSignal[ScopeInstancesAccessor] = ClosureScopes + valueAccessor;
|
|
604
|
+
closureSignal[SignalIndexAccessor] = ClosureSignalIndex + valueAccessor;
|
|
541
605
|
resumeId && _resume(resumeId, closureSignal);
|
|
542
606
|
return closureSignal;
|
|
543
607
|
}
|
|
@@ -549,18 +613,18 @@ function _child_setup(setup) {
|
|
|
549
613
|
return setup;
|
|
550
614
|
}
|
|
551
615
|
function _var(scope, childAccessor, signal) {
|
|
552
|
-
scope[childAccessor][
|
|
616
|
+
scope[childAccessor][TagVariable] = (value) => signal(scope, value);
|
|
553
617
|
}
|
|
554
|
-
const _return = (scope, value) => scope[
|
|
618
|
+
const _return = (scope, value) => scope[TagVariable]?.(value);
|
|
555
619
|
function _return_change(scope, changeHandler) {
|
|
556
|
-
if (changeHandler) scope[
|
|
620
|
+
if (changeHandler) scope[TagVariableChange] = changeHandler;
|
|
557
621
|
}
|
|
558
622
|
const _var_change = (scope, value, name = "This") => {
|
|
559
623
|
if (typeof scope["#TagVariableChange"] !== "function") throw new TypeError(`${name} is a readonly tag variable.`);
|
|
560
|
-
scope[
|
|
624
|
+
scope[TagVariableChange](value);
|
|
561
625
|
};
|
|
562
626
|
const tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
|
563
|
-
function _id({ [
|
|
627
|
+
function _id({ [Global]: $global }) {
|
|
564
628
|
const id = tagIdsByGlobal.get($global) || 0;
|
|
565
629
|
tagIdsByGlobal.set($global, id + 1);
|
|
566
630
|
return "c" + $global.runtimeId + $global.renderId + id.toString(36);
|
|
@@ -618,7 +682,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
618
682
|
if (value === 49) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
|
|
619
683
|
} else if (value === 38) return currentWalkIndex;
|
|
620
684
|
else if (value === 47 || value === 48) {
|
|
621
|
-
currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[getDebugKey(currentScopeIndex++, "#childScope")] = createScope(scope[
|
|
685
|
+
currentWalkIndex = walkInternal(currentWalkIndex, walkCodes, scope[getDebugKey(currentScopeIndex++, "#childScope")] = createScope(scope[Global], scope[ClosestBranch]));
|
|
622
686
|
if (value === 48) scope[getDebugKey(currentScopeIndex++, "#scopeOffset")] = skipScope();
|
|
623
687
|
} else if (value < 92) {
|
|
624
688
|
value = 20 * currentMultiplier + value - 67;
|
|
@@ -648,23 +712,23 @@ function getDebugKey(index, node) {
|
|
|
648
712
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
649
713
|
const branch = createScope($global);
|
|
650
714
|
branch["_"] = renderer["owner"] || parentScope;
|
|
651
|
-
setParentBranch(branch, parentScope?.[
|
|
652
|
-
branch[
|
|
653
|
-
renderer[
|
|
715
|
+
setParentBranch(branch, parentScope?.[ClosestBranch]);
|
|
716
|
+
branch[Renderer] = renderer;
|
|
717
|
+
renderer[Clone]?.(branch, parentNode.namespaceURI);
|
|
654
718
|
return branch;
|
|
655
719
|
}
|
|
656
720
|
function setParentBranch(branch, parentBranch) {
|
|
657
721
|
if (parentBranch) {
|
|
658
|
-
branch[
|
|
659
|
-
(parentBranch[
|
|
722
|
+
branch[ParentBranch] = parentBranch;
|
|
723
|
+
(parentBranch[BranchScopes] ||= /* @__PURE__ */ new Set()).add(branch);
|
|
660
724
|
}
|
|
661
|
-
branch[
|
|
725
|
+
branch[ClosestBranch] = branch;
|
|
662
726
|
}
|
|
663
727
|
function createAndSetupBranch($global, renderer, parentScope, parentNode) {
|
|
664
728
|
return setupBranch(renderer, createBranch($global, renderer, parentScope, parentNode));
|
|
665
729
|
}
|
|
666
730
|
function setupBranch(renderer, branch) {
|
|
667
|
-
if (renderer["setup"]) queueRender(branch, renderer[
|
|
731
|
+
if (renderer["setup"]) queueRender(branch, renderer[Setup], -1);
|
|
668
732
|
return branch;
|
|
669
733
|
}
|
|
670
734
|
function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
@@ -674,16 +738,16 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
674
738
|
const clone = template ? (branch, ns) => {
|
|
675
739
|
((cloneCache[ns] ||= {})[template] ||= createCloneableHTML(template, ns))(branch, walks);
|
|
676
740
|
} : (branch) => {
|
|
677
|
-
walk(branch[
|
|
741
|
+
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
678
742
|
};
|
|
679
743
|
return (owner) => {
|
|
680
744
|
return {
|
|
681
745
|
["id"]: id,
|
|
682
|
-
[
|
|
683
|
-
[
|
|
684
|
-
[
|
|
685
|
-
[
|
|
686
|
-
[
|
|
746
|
+
[Clone]: clone,
|
|
747
|
+
[Owner]: owner,
|
|
748
|
+
[Setup]: setup,
|
|
749
|
+
[Params]: params,
|
|
750
|
+
[Accessor]: dynamicScopesAccessor
|
|
687
751
|
};
|
|
688
752
|
};
|
|
689
753
|
}
|
|
@@ -695,8 +759,8 @@ function _content_closures(renderer, closureFns) {
|
|
|
695
759
|
for (const key in closureFns) closureSignals[key] = _const(key, closureFns[key]);
|
|
696
760
|
return (owner, closureValues) => {
|
|
697
761
|
const instance = renderer(owner);
|
|
698
|
-
instance[
|
|
699
|
-
instance[
|
|
762
|
+
instance[LocalClosures] = closureSignals;
|
|
763
|
+
instance[LocalClosureValues] = closureValues;
|
|
700
764
|
return instance;
|
|
701
765
|
};
|
|
702
766
|
}
|
|
@@ -706,12 +770,12 @@ function createCloneableHTML(html, ns) {
|
|
|
706
770
|
const parent = document.createElementNS(ns, "t");
|
|
707
771
|
insertChildNodes(parent, null, firstChild, lastChild);
|
|
708
772
|
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
709
|
-
walk(branch[
|
|
773
|
+
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
710
774
|
} : (branch, walks) => {
|
|
711
775
|
const clone = parent.cloneNode(true);
|
|
712
776
|
walk(clone.firstChild, walks, branch);
|
|
713
|
-
branch[
|
|
714
|
-
branch[
|
|
777
|
+
branch[StartNode] = clone.firstChild;
|
|
778
|
+
branch[EndNode] = clone.lastChild;
|
|
715
779
|
};
|
|
716
780
|
}
|
|
717
781
|
//#endregion
|
|
@@ -766,9 +830,9 @@ function init(runtimeId = "M") {
|
|
|
766
830
|
renderId
|
|
767
831
|
};
|
|
768
832
|
const initScope = (scope) => {
|
|
769
|
-
scope[
|
|
770
|
-
scope[
|
|
771
|
-
if (branchesEnabled && scope["#ClosestBranchId"]) scope[
|
|
833
|
+
scope[Gen$1] = 1;
|
|
834
|
+
scope[Global] = initGlobal();
|
|
835
|
+
if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
|
|
772
836
|
return scope;
|
|
773
837
|
};
|
|
774
838
|
const applyScopes = (partials) => {
|
|
@@ -788,18 +852,18 @@ function init(runtimeId = "M") {
|
|
|
788
852
|
return (branchId, branch, endedBranches, accessor, singleNode, parent = visit.parentNode, startVisit = visit, i = orphanBranches.length, j = deferredOwners.length) => {
|
|
789
853
|
if (visitType !== "[") {
|
|
790
854
|
visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
|
|
791
|
-
accessor =
|
|
855
|
+
accessor = BranchScopes$1 + lastToken;
|
|
792
856
|
singleNode = visitType !== "]" && visitType !== ")";
|
|
793
857
|
nextToken();
|
|
794
858
|
}
|
|
795
859
|
while (branchId = +lastToken) {
|
|
796
860
|
(endedBranches ||= []).push(branch = getScope(branchId));
|
|
797
|
-
setParentBranch(branch, branch[
|
|
798
|
-
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[
|
|
861
|
+
setParentBranch(branch, branch[ClosestBranch]);
|
|
862
|
+
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
|
|
799
863
|
if (singleNode) {
|
|
800
864
|
while (startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling));
|
|
801
865
|
branch["_"] ??= visitScope;
|
|
802
|
-
branch[
|
|
866
|
+
branch[EndNode] = branch[StartNode] = startVisit;
|
|
803
867
|
if (visitType === "'") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
804
868
|
} else {
|
|
805
869
|
curBranchScopes = push(curBranchScopes, branch);
|
|
@@ -810,8 +874,8 @@ function init(runtimeId = "M") {
|
|
|
810
874
|
}
|
|
811
875
|
startVisit = branchStarts.pop();
|
|
812
876
|
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
813
|
-
branch[
|
|
814
|
-
branch[
|
|
877
|
+
branch[StartNode] = startVisit;
|
|
878
|
+
branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
815
879
|
}
|
|
816
880
|
while (i && orphanBranches[i - 1]["#Id"] > branchId) {
|
|
817
881
|
i--;
|
|
@@ -820,7 +884,7 @@ function init(runtimeId = "M") {
|
|
|
820
884
|
while (j && deferredOwners[j - 1]["#Id"] > branchId) {
|
|
821
885
|
j--;
|
|
822
886
|
const owner = deferredOwners.pop();
|
|
823
|
-
if (owner["#ClosestBranch"] !== owner) owner[
|
|
887
|
+
if (owner["#ClosestBranch"] !== owner) owner[ClosestBranch] = branch;
|
|
824
888
|
}
|
|
825
889
|
nextToken();
|
|
826
890
|
}
|
|
@@ -949,15 +1013,15 @@ function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
|
949
1013
|
const el = scope[nodeAccessor];
|
|
950
1014
|
const normalizedChecked = isNotVoid(checked);
|
|
951
1015
|
assertHandlerIsFunction("checkedChange", checkedChange);
|
|
952
|
-
scope[
|
|
953
|
-
scope[
|
|
1016
|
+
scope[ControlledHandler + nodeAccessor] = checkedChange;
|
|
1017
|
+
scope[ControlledType + nodeAccessor] = checkedChange ? 0 : 5;
|
|
954
1018
|
if (checkedChange && scope["#Gen"] < runId) el.checked = normalizedChecked;
|
|
955
1019
|
else _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
|
|
956
1020
|
}
|
|
957
1021
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
958
1022
|
const el = scope[nodeAccessor];
|
|
959
1023
|
syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
960
|
-
const checkedChange = scope[
|
|
1024
|
+
const checkedChange = scope[ControlledHandler + nodeAccessor];
|
|
961
1025
|
if (checkedChange) {
|
|
962
1026
|
const newValue = el.checked;
|
|
963
1027
|
el.checked = !newValue;
|
|
@@ -976,10 +1040,10 @@ function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, val
|
|
|
976
1040
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
977
1041
|
const el = scope[nodeAccessor];
|
|
978
1042
|
const multiple = Array.isArray(checkedValue);
|
|
979
|
-
const normalizedCheckedValue = scope[
|
|
1043
|
+
const normalizedCheckedValue = scope[ControlledValue + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
980
1044
|
assertHandlerIsFunction("checkedValueChange", checkedValueChange);
|
|
981
|
-
scope[
|
|
982
|
-
scope[
|
|
1045
|
+
scope[ControlledHandler + nodeAccessor] = checkedValueChange;
|
|
1046
|
+
scope[ControlledType + nodeAccessor] = checkedValueChange ? 1 : 5;
|
|
983
1047
|
if (checkedValueChange && scope["#Gen"] < runId) {
|
|
984
1048
|
el.checked = multiple ? normalizedCheckedValue.includes(normalizeStrProp(value)) : normalizeStrProp(value) === normalizedCheckedValue;
|
|
985
1049
|
_attr(el, "value", value);
|
|
@@ -987,12 +1051,12 @@ function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValu
|
|
|
987
1051
|
}
|
|
988
1052
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
989
1053
|
const el = scope[nodeAccessor];
|
|
990
|
-
if (isResuming && el.defaultChecked) if (scope["ControlledValue:" + nodeAccessor]) scope[
|
|
991
|
-
else scope[
|
|
1054
|
+
if (isResuming && el.defaultChecked) if (scope["ControlledValue:" + nodeAccessor]) scope[ControlledValue + nodeAccessor].push(el.value);
|
|
1055
|
+
else scope[ControlledValue + nodeAccessor] = el.value;
|
|
992
1056
|
syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
993
|
-
const checkedValueChange = scope[
|
|
1057
|
+
const checkedValueChange = scope[ControlledHandler + nodeAccessor];
|
|
994
1058
|
if (checkedValueChange) {
|
|
995
|
-
const controlledValueKey =
|
|
1059
|
+
const controlledValueKey = ControlledValue + nodeAccessor;
|
|
996
1060
|
const oldValue = scope[controlledValueKey];
|
|
997
1061
|
let newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
|
|
998
1062
|
if (el.name && el.type[0] === "r") {
|
|
@@ -1024,9 +1088,9 @@ function _attr_input_value(scope, nodeAccessor, value, valueChange, setDefault =
|
|
|
1024
1088
|
const el = scope[nodeAccessor];
|
|
1025
1089
|
const normalizedValue = normalizeAttrValue(value) || "";
|
|
1026
1090
|
assertHandlerIsFunction("valueChange", valueChange);
|
|
1027
|
-
scope[
|
|
1028
|
-
scope[
|
|
1029
|
-
scope[
|
|
1091
|
+
scope[ControlledHandler + nodeAccessor] = valueChange;
|
|
1092
|
+
scope[ControlledValue + nodeAccessor] = normalizedValue;
|
|
1093
|
+
scope[ControlledType + nodeAccessor] = valueChange ? 2 : 5;
|
|
1030
1094
|
if (valueChange && scope["#Gen"] < runId) setInputValue(el, normalizedValue);
|
|
1031
1095
|
else setDefault(scope, nodeAccessor, normalizedValue);
|
|
1032
1096
|
}
|
|
@@ -1035,14 +1099,14 @@ function _attr_input_value_attribute_default(scope, nodeAccessor, value) {
|
|
|
1035
1099
|
}
|
|
1036
1100
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
1037
1101
|
const el = scope[nodeAccessor];
|
|
1038
|
-
if (isResuming) scope[
|
|
1102
|
+
if (isResuming) scope[ControlledValue + nodeAccessor] = el.defaultValue;
|
|
1039
1103
|
syncControllableFormInput(el, hasValueChanged, (ev) => {
|
|
1040
|
-
const valueChange = scope[
|
|
1104
|
+
const valueChange = scope[ControlledHandler + nodeAccessor];
|
|
1041
1105
|
if (valueChange) {
|
|
1042
1106
|
inputType = ev?.inputType;
|
|
1043
1107
|
valueChange(el.value);
|
|
1044
1108
|
run();
|
|
1045
|
-
setInputValue(el, scope[
|
|
1109
|
+
setInputValue(el, scope[ControlledValue + nodeAccessor]);
|
|
1046
1110
|
inputType = "";
|
|
1047
1111
|
}
|
|
1048
1112
|
});
|
|
@@ -1056,7 +1120,7 @@ function setInputValue(el, value) {
|
|
|
1056
1120
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
1057
1121
|
let restoreValue;
|
|
1058
1122
|
const el = scope[nodeAccessor];
|
|
1059
|
-
const live = scope[
|
|
1123
|
+
const live = scope[Gen$1] < runId;
|
|
1060
1124
|
const multiple = Array.isArray(value);
|
|
1061
1125
|
const normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
1062
1126
|
pendingEffects.unshift(() => {
|
|
@@ -1072,12 +1136,12 @@ function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
|
1072
1136
|
}
|
|
1073
1137
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
1074
1138
|
const el = scope[nodeAccessor];
|
|
1075
|
-
const existing = scope[
|
|
1139
|
+
const existing = scope[Gen$1] < runId;
|
|
1076
1140
|
const multiple = Array.isArray(value);
|
|
1077
|
-
const normalizedValue = scope[
|
|
1141
|
+
const normalizedValue = scope[ControlledValue + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
1078
1142
|
assertHandlerIsFunction("valueChange", valueChange);
|
|
1079
|
-
scope[
|
|
1080
|
-
scope[
|
|
1143
|
+
scope[ControlledHandler + nodeAccessor] = valueChange;
|
|
1144
|
+
scope[ControlledType + nodeAccessor] = valueChange ? 3 : 5;
|
|
1081
1145
|
if (valueChange) pendingEffects.unshift(() => assertSelectValueMatchesOption(el, normalizedValue, value), scope);
|
|
1082
1146
|
if (valueChange && existing) pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope);
|
|
1083
1147
|
else _attr_select_value_default(scope, nodeAccessor, normalizedValue);
|
|
@@ -1085,9 +1149,9 @@ function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
|
1085
1149
|
function _attr_select_value_script(scope, nodeAccessor) {
|
|
1086
1150
|
const el = scope[nodeAccessor];
|
|
1087
1151
|
const onChange = () => {
|
|
1088
|
-
const valueChange = scope[
|
|
1152
|
+
const valueChange = scope[ControlledHandler + nodeAccessor];
|
|
1089
1153
|
if (valueChange) {
|
|
1090
|
-
const oldValue = scope[
|
|
1154
|
+
const oldValue = scope[ControlledValue + nodeAccessor];
|
|
1091
1155
|
const multiple = Array.isArray(oldValue);
|
|
1092
1156
|
const newValue = getSelectValue(el, multiple);
|
|
1093
1157
|
setSelectValue(el, oldValue, multiple);
|
|
@@ -1096,18 +1160,18 @@ function _attr_select_value_script(scope, nodeAccessor) {
|
|
|
1096
1160
|
}
|
|
1097
1161
|
};
|
|
1098
1162
|
if (isResuming) if (el.multiple) {
|
|
1099
|
-
scope[
|
|
1100
|
-
for (const opt of el.options) if (opt.defaultSelected) scope[
|
|
1163
|
+
scope[ControlledValue + nodeAccessor] = [];
|
|
1164
|
+
for (const opt of el.options) if (opt.defaultSelected) scope[ControlledValue + nodeAccessor].push(opt.value);
|
|
1101
1165
|
} else {
|
|
1102
|
-
scope[
|
|
1166
|
+
scope[ControlledValue + nodeAccessor] = "";
|
|
1103
1167
|
for (const opt of el.options) if (opt.defaultSelected) {
|
|
1104
|
-
scope[
|
|
1168
|
+
scope[ControlledValue + nodeAccessor] = opt.value;
|
|
1105
1169
|
break;
|
|
1106
1170
|
}
|
|
1107
1171
|
}
|
|
1108
1172
|
syncControllableFormInput(el, hasSelectChanged, onChange);
|
|
1109
1173
|
new MutationObserver(() => {
|
|
1110
|
-
const value = scope[
|
|
1174
|
+
const value = scope[ControlledValue + nodeAccessor];
|
|
1111
1175
|
if (Array.isArray(value) ? value.length !== el.selectedOptions.length || value.some((_, i) => !value.includes(el.selectedOptions[i].value)) : el.value !== value) onChange();
|
|
1112
1176
|
}).observe(el, {
|
|
1113
1177
|
childList: true,
|
|
@@ -1132,17 +1196,17 @@ function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
|
1132
1196
|
if (scope["#Gen"] === runId) scope[nodeAccessor].open = isNotVoid(open);
|
|
1133
1197
|
}
|
|
1134
1198
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
1135
|
-
const normalizedOpen = scope[
|
|
1199
|
+
const normalizedOpen = scope[ControlledValue + nodeAccessor] = isNotVoid(open);
|
|
1136
1200
|
assertHandlerIsFunction("openChange", openChange);
|
|
1137
|
-
scope[
|
|
1138
|
-
scope[
|
|
1201
|
+
scope[ControlledHandler + nodeAccessor] = openChange;
|
|
1202
|
+
scope[ControlledType + nodeAccessor] = openChange ? 4 : 5;
|
|
1139
1203
|
if (openChange && scope["#Gen"] < runId) scope[nodeAccessor].open = normalizedOpen;
|
|
1140
1204
|
else _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
|
|
1141
1205
|
}
|
|
1142
1206
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
1143
1207
|
const el = scope[nodeAccessor];
|
|
1144
1208
|
new MutationObserver(() => {
|
|
1145
|
-
const openChange = scope[
|
|
1209
|
+
const openChange = scope[ControlledHandler + nodeAccessor];
|
|
1146
1210
|
if (openChange && el.open === !scope["ControlledValue:" + nodeAccessor]) {
|
|
1147
1211
|
const newValue = el.open;
|
|
1148
1212
|
el.open = !newValue;
|
|
@@ -1236,7 +1300,7 @@ function _style_rule_item(element, name, value) {
|
|
|
1236
1300
|
_text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
1237
1301
|
}
|
|
1238
1302
|
function _attr_nonce(scope, nodeAccessor) {
|
|
1239
|
-
_attr(scope[nodeAccessor], "nonce", scope[
|
|
1303
|
+
_attr(scope[nodeAccessor], "nonce", scope[Global].cspNonce);
|
|
1240
1304
|
}
|
|
1241
1305
|
function _text(node, value) {
|
|
1242
1306
|
const normalizedValue = _to_text(value);
|
|
@@ -1285,11 +1349,11 @@ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
1285
1349
|
}
|
|
1286
1350
|
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
1287
1351
|
const el = scope[nodeAccessor];
|
|
1288
|
-
let events = scope[
|
|
1352
|
+
let events = scope[EventAttributes + nodeAccessor];
|
|
1289
1353
|
let skip;
|
|
1290
1354
|
for (const name in events) events[name] = 0;
|
|
1291
|
-
scope[
|
|
1292
|
-
scope[
|
|
1355
|
+
scope[ControlledType + nodeAccessor] = 5;
|
|
1356
|
+
scope[ControlledHandler + nodeAccessor] = 0;
|
|
1293
1357
|
switch (nextAttrs && el.tagName) {
|
|
1294
1358
|
case "INPUT":
|
|
1295
1359
|
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) {
|
|
@@ -1334,7 +1398,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
|
1334
1398
|
break;
|
|
1335
1399
|
default:
|
|
1336
1400
|
assertValidAttrName(name);
|
|
1337
|
-
if (isEventHandler(name)) (events ||= scope[
|
|
1401
|
+
if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1338
1402
|
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1339
1403
|
break;
|
|
1340
1404
|
}
|
|
@@ -1344,14 +1408,14 @@ function _attr_content(scope, nodeAccessor, value) {
|
|
|
1344
1408
|
const content = normalizeClientRender(value);
|
|
1345
1409
|
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = content?.["id"])) {
|
|
1346
1410
|
setConditionalRenderer(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1347
|
-
if (content?.["accessor"]) subscribeToScopeSet(content[
|
|
1411
|
+
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
1348
1412
|
}
|
|
1349
|
-
for (const accessor in content?.[
|
|
1413
|
+
for (const accessor in content?.[LocalClosures]) content[LocalClosures][accessor](scope[BranchScopes$1 + nodeAccessor], content[LocalClosureValues][accessor]);
|
|
1350
1414
|
}
|
|
1351
1415
|
function _attrs_script(scope, nodeAccessor) {
|
|
1352
1416
|
const el = scope[nodeAccessor];
|
|
1353
|
-
const events = scope[
|
|
1354
|
-
switch (scope[
|
|
1417
|
+
const events = scope[EventAttributes + nodeAccessor];
|
|
1418
|
+
switch (scope[ControlledType + nodeAccessor]) {
|
|
1355
1419
|
case 0:
|
|
1356
1420
|
_attr_input_checked_script(scope, nodeAccessor);
|
|
1357
1421
|
break;
|
|
@@ -1375,7 +1439,7 @@ function _html(scope, value, accessor) {
|
|
|
1375
1439
|
const parentNode = firstChild.parentNode;
|
|
1376
1440
|
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1377
1441
|
const newContent = parseHTML(_to_text(value), parentNode.namespaceURI);
|
|
1378
|
-
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope[
|
|
1442
|
+
insertChildNodes(parentNode, firstChild, scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()), scope[DynamicHTMLLastChild + accessor] = newContent.lastChild);
|
|
1379
1443
|
removeChildNodes(firstChild, lastChild);
|
|
1380
1444
|
}
|
|
1381
1445
|
function normalizeClientRender(value) {
|
|
@@ -1387,7 +1451,7 @@ function normalizeAttrValue(value) {
|
|
|
1387
1451
|
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
1388
1452
|
}
|
|
1389
1453
|
function _lifecycle(scope, thisObj, index = 0) {
|
|
1390
|
-
const accessor =
|
|
1454
|
+
const accessor = Lifecycle + index;
|
|
1391
1455
|
const instance = scope[accessor];
|
|
1392
1456
|
if (instance) {
|
|
1393
1457
|
Object.assign(instance, thisObj);
|
|
@@ -1427,8 +1491,8 @@ function toInsertNode(startNode, endNode) {
|
|
|
1427
1491
|
//#endregion
|
|
1428
1492
|
//#region src/dom/control-flow.ts
|
|
1429
1493
|
function _await_promise(nodeAccessor, params) {
|
|
1430
|
-
const promiseAccessor =
|
|
1431
|
-
const branchAccessor =
|
|
1494
|
+
const promiseAccessor = Promise$1 + nodeAccessor;
|
|
1495
|
+
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
1432
1496
|
_enable_catch();
|
|
1433
1497
|
return (scope, promise) => {
|
|
1434
1498
|
if (!isPromise(promise)) {
|
|
@@ -1441,24 +1505,24 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1441
1505
|
promise = Promise.resolve(promise);
|
|
1442
1506
|
}
|
|
1443
1507
|
let awaitBranch = scope[branchAccessor];
|
|
1444
|
-
const tryPlaceholder = findBranchWithKey(scope,
|
|
1508
|
+
const tryPlaceholder = findBranchWithKey(scope, PlaceholderContent);
|
|
1445
1509
|
const tryBranch = tryPlaceholder || awaitBranch;
|
|
1446
|
-
let awaitCounter = tryBranch[
|
|
1510
|
+
let awaitCounter = tryBranch[AwaitCounter];
|
|
1447
1511
|
placeholderShown.add(pendingEffects);
|
|
1448
1512
|
if (tryPlaceholder) {
|
|
1449
1513
|
if (!scope[promiseAccessor]) {
|
|
1450
|
-
if (awaitBranch) awaitBranch[
|
|
1514
|
+
if (awaitBranch) awaitBranch[PendingRenders] ||= [];
|
|
1451
1515
|
awaitCounter = addAwaitCounter(scope, tryPlaceholder);
|
|
1452
1516
|
}
|
|
1453
1517
|
} else {
|
|
1454
|
-
if (!awaitCounter?.i) awaitCounter = tryBranch[
|
|
1518
|
+
if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
|
|
1455
1519
|
i: 0,
|
|
1456
1520
|
c() {
|
|
1457
1521
|
if (--awaitCounter.i) return 1;
|
|
1458
1522
|
if (tryBranch === scope[branchAccessor]) {
|
|
1459
1523
|
const anchor = scope[nodeAccessor];
|
|
1460
1524
|
if (anchor.parentNode) {
|
|
1461
|
-
const detachedParent = scope[branchAccessor][
|
|
1525
|
+
const detachedParent = scope[branchAccessor][StartNode].parentNode;
|
|
1462
1526
|
if (detachedParent === anchor.parentNode) anchor.remove();
|
|
1463
1527
|
else anchor.replaceWith(detachedParent);
|
|
1464
1528
|
}
|
|
@@ -1467,7 +1531,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1467
1531
|
}
|
|
1468
1532
|
};
|
|
1469
1533
|
if (!scope[promiseAccessor]) {
|
|
1470
|
-
if (awaitBranch) awaitBranch[
|
|
1534
|
+
if (awaitBranch) awaitBranch[PendingRenders] ||= [];
|
|
1471
1535
|
if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, () => {
|
|
1472
1536
|
if (!awaitBranch["#DetachedAwait"]) {
|
|
1473
1537
|
awaitBranch["#StartNode"].parentNode.insertBefore(scope[nodeAccessor], awaitBranch["#StartNode"]);
|
|
@@ -1482,8 +1546,8 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1482
1546
|
scope[promiseAccessor] = 0;
|
|
1483
1547
|
queueAsyncRender(scope, () => {
|
|
1484
1548
|
awaitBranch = resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, data);
|
|
1485
|
-
const pendingRenders = awaitBranch[
|
|
1486
|
-
awaitBranch[
|
|
1549
|
+
const pendingRenders = awaitBranch[PendingRenders];
|
|
1550
|
+
awaitBranch[PendingRenders] = 0;
|
|
1487
1551
|
pendingRenders?.forEach(queuePendingRender);
|
|
1488
1552
|
placeholderShown.add(pendingEffects);
|
|
1489
1553
|
awaitCounter.c();
|
|
@@ -1517,9 +1581,9 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1517
1581
|
function resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params, value) {
|
|
1518
1582
|
const awaitBranch = scope[branchAccessor];
|
|
1519
1583
|
if (awaitBranch["#DetachedAwait"]) {
|
|
1520
|
-
awaitBranch[
|
|
1521
|
-
setupBranch(awaitBranch[
|
|
1522
|
-
awaitBranch[
|
|
1584
|
+
awaitBranch[PendingScopes] = awaitBranch[PendingScopes]?.forEach(syncGen);
|
|
1585
|
+
setupBranch(awaitBranch[DetachedAwait], awaitBranch);
|
|
1586
|
+
awaitBranch[DetachedAwait] = 0;
|
|
1523
1587
|
insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
|
|
1524
1588
|
referenceNode.remove();
|
|
1525
1589
|
}
|
|
@@ -1527,12 +1591,12 @@ function resolveAwait(scope, branchAccessor, nodeAccessor, referenceNode, params
|
|
|
1527
1591
|
return awaitBranch;
|
|
1528
1592
|
}
|
|
1529
1593
|
function _await_content(nodeAccessor, template, walks, setup) {
|
|
1530
|
-
const branchAccessor =
|
|
1531
|
-
const promiseAccessor =
|
|
1594
|
+
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
1595
|
+
const promiseAccessor = Promise$1 + nodeAccessor;
|
|
1532
1596
|
const renderer = _content("", template, walks, setup)();
|
|
1533
1597
|
return (scope) => {
|
|
1534
|
-
const pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope[
|
|
1535
|
-
scope[branchAccessor][
|
|
1598
|
+
const pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope[Global], renderer, scope, scope[nodeAccessor].parentNode))[DetachedAwait] = renderer);
|
|
1599
|
+
scope[branchAccessor][PendingScopes] = pendingScopes;
|
|
1536
1600
|
const resolveSync = scope[promiseAccessor];
|
|
1537
1601
|
if (typeof resolveSync === "function") {
|
|
1538
1602
|
scope[promiseAccessor] = 0;
|
|
@@ -1540,10 +1604,10 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
1540
1604
|
}
|
|
1541
1605
|
};
|
|
1542
1606
|
}
|
|
1543
|
-
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope,
|
|
1607
|
+
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, PlaceholderContent)) {
|
|
1544
1608
|
if (!tryBranch) return;
|
|
1545
|
-
let awaitCounter = tryBranch[
|
|
1546
|
-
if (!awaitCounter?.i) awaitCounter = tryBranch[
|
|
1609
|
+
let awaitCounter = tryBranch[AwaitCounter];
|
|
1610
|
+
if (!awaitCounter?.i) awaitCounter = tryBranch[AwaitCounter] = {
|
|
1547
1611
|
i: 0,
|
|
1548
1612
|
c() {
|
|
1549
1613
|
if (--awaitCounter.i) return 1;
|
|
@@ -1559,51 +1623,51 @@ function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "#Placehold
|
|
|
1559
1623
|
return awaitCounter;
|
|
1560
1624
|
}
|
|
1561
1625
|
function runPendingEffects(scope) {
|
|
1562
|
-
const effects = scope[
|
|
1626
|
+
const effects = scope[PendingEffects];
|
|
1563
1627
|
if (effects) {
|
|
1564
|
-
scope[
|
|
1628
|
+
scope[PendingEffects] = [];
|
|
1565
1629
|
runEffects(effects, 1);
|
|
1566
1630
|
}
|
|
1567
1631
|
}
|
|
1568
1632
|
function dismissPlaceholder(tryBranch) {
|
|
1569
|
-
const placeholderBranch = tryBranch[
|
|
1633
|
+
const placeholderBranch = tryBranch[PlaceholderBranch];
|
|
1570
1634
|
if (placeholderBranch) {
|
|
1571
|
-
tryBranch[
|
|
1572
|
-
placeholderBranch[
|
|
1635
|
+
tryBranch[PlaceholderBranch] = 0;
|
|
1636
|
+
placeholderBranch[StartNode].parentNode.insertBefore(tryBranch[StartNode].parentNode, placeholderBranch[StartNode]);
|
|
1573
1637
|
removeAndDestroyBranch(placeholderBranch);
|
|
1574
1638
|
}
|
|
1575
1639
|
}
|
|
1576
1640
|
function _try(nodeAccessor, template, walks, setup) {
|
|
1577
|
-
const branchAccessor =
|
|
1641
|
+
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
1578
1642
|
const renderer = _content("", template, walks, setup)();
|
|
1579
1643
|
return (scope, input) => {
|
|
1580
1644
|
if (!scope[branchAccessor]) setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
|
|
1581
1645
|
const branch = scope[branchAccessor];
|
|
1582
1646
|
if (branch) {
|
|
1583
|
-
branch[
|
|
1584
|
-
branch[
|
|
1585
|
-
branch[
|
|
1647
|
+
branch[BranchAccessor] = nodeAccessor;
|
|
1648
|
+
branch[CatchContent] = input.catch && (normalizeDynamicRenderer(input.catch) || 0);
|
|
1649
|
+
branch[PlaceholderContent] = normalizeDynamicRenderer(input.placeholder);
|
|
1586
1650
|
}
|
|
1587
1651
|
};
|
|
1588
1652
|
}
|
|
1589
1653
|
function renderCatch(scope, error) {
|
|
1590
|
-
const tryWithCatch = findBranchWithKey(scope,
|
|
1654
|
+
const tryWithCatch = findBranchWithKey(scope, CatchContent);
|
|
1591
1655
|
if (!tryWithCatch) throw error;
|
|
1592
1656
|
else {
|
|
1593
1657
|
const owner = tryWithCatch["_"];
|
|
1594
|
-
const placeholderBranch = tryWithCatch[
|
|
1658
|
+
const placeholderBranch = tryWithCatch[PlaceholderBranch];
|
|
1595
1659
|
if (placeholderBranch) {
|
|
1596
|
-
if (tryWithCatch["#AwaitCounter"]) tryWithCatch[
|
|
1597
|
-
owner[
|
|
1660
|
+
if (tryWithCatch["#AwaitCounter"]) tryWithCatch[AwaitCounter].i = 0;
|
|
1661
|
+
owner[BranchScopes$1 + tryWithCatch[BranchAccessor]] = placeholderBranch;
|
|
1598
1662
|
destroyBranch(tryWithCatch);
|
|
1599
1663
|
}
|
|
1600
1664
|
caughtError.add(pendingEffects);
|
|
1601
|
-
setConditionalRenderer(owner, tryWithCatch[
|
|
1602
|
-
tryWithCatch[
|
|
1665
|
+
setConditionalRenderer(owner, tryWithCatch[BranchAccessor], tryWithCatch[CatchContent], createAndSetupBranch);
|
|
1666
|
+
tryWithCatch[CatchContent]?.[Params]?.(owner[BranchScopes$1 + tryWithCatch[BranchAccessor]], [error]);
|
|
1603
1667
|
}
|
|
1604
1668
|
}
|
|
1605
1669
|
function _if(nodeAccessor, ...branchesArgs) {
|
|
1606
|
-
const branchAccessor =
|
|
1670
|
+
const branchAccessor = ConditionalRenderer + nodeAccessor;
|
|
1607
1671
|
const branches = [];
|
|
1608
1672
|
let i = 0;
|
|
1609
1673
|
while (i < branchesArgs.length) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
|
|
@@ -1613,7 +1677,7 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
1613
1677
|
};
|
|
1614
1678
|
}
|
|
1615
1679
|
function _show(nodeAccessor, startNodeAccessor) {
|
|
1616
|
-
const rangeAccessor =
|
|
1680
|
+
const rangeAccessor = BranchScopes$1 + nodeAccessor;
|
|
1617
1681
|
enableBranches();
|
|
1618
1682
|
return (scope, display) => {
|
|
1619
1683
|
const referenceNode = scope[nodeAccessor];
|
|
@@ -1622,16 +1686,16 @@ function _show(nodeAccessor, startNodeAccessor) {
|
|
|
1622
1686
|
let range = scope[rangeAccessor];
|
|
1623
1687
|
if (!range) {
|
|
1624
1688
|
range = scope[rangeAccessor] = {};
|
|
1625
|
-
range[
|
|
1626
|
-
range[
|
|
1689
|
+
range[StartNode] = onlyChild ? parentNode.firstChild : scope[startNodeAccessor];
|
|
1690
|
+
range[EndNode] = onlyChild ? parentNode.lastChild : referenceNode.previousSibling;
|
|
1627
1691
|
}
|
|
1628
|
-
let startNode = range[
|
|
1692
|
+
let startNode = range[StartNode];
|
|
1629
1693
|
if (range["#Id"] && startNode === range["#EndNode"] && startNode.tagName === "T") {
|
|
1630
1694
|
const wrapper = startNode;
|
|
1631
1695
|
if (!wrapper.firstChild) wrapper.appendChild(new Text());
|
|
1632
1696
|
range = scope[rangeAccessor] = {};
|
|
1633
|
-
range[
|
|
1634
|
-
range[
|
|
1697
|
+
range[StartNode] = startNode = wrapper.firstChild;
|
|
1698
|
+
range[EndNode] = wrapper.lastChild;
|
|
1635
1699
|
wrapper.replaceWith(...wrapper.childNodes);
|
|
1636
1700
|
}
|
|
1637
1701
|
const inDom = startNode.parentNode === parentNode;
|
|
@@ -1644,21 +1708,21 @@ function patchDynamicTag(fn) {
|
|
|
1644
1708
|
_dynamic_tag = fn(_dynamic_tag);
|
|
1645
1709
|
}
|
|
1646
1710
|
let _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
|
1647
|
-
const childScopeAccessor =
|
|
1648
|
-
const rendererAccessor =
|
|
1711
|
+
const childScopeAccessor = BranchScopes$1 + nodeAccessor;
|
|
1712
|
+
const rendererAccessor = ConditionalRenderer + nodeAccessor;
|
|
1649
1713
|
enableBranches();
|
|
1650
1714
|
return (scope, newRenderer, getInput) => {
|
|
1651
1715
|
const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
|
1652
1716
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.["id"] || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
|
1653
1717
|
setConditionalRenderer(scope, nodeAccessor, normalizedRenderer || (getContent ? getContent(scope) : void 0), createBranchWithTagNameOrRenderer);
|
|
1654
|
-
if (getTagVar) scope[childScopeAccessor][
|
|
1718
|
+
if (getTagVar) scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
|
|
1655
1719
|
if (typeof normalizedRenderer === "string") {
|
|
1656
1720
|
if (getContent) {
|
|
1657
1721
|
const content = getContent(scope);
|
|
1658
1722
|
setConditionalRenderer(scope[childScopeAccessor], `#${normalizedRenderer}/0`, content, createAndSetupBranch);
|
|
1659
|
-
if (content["accessor"]) subscribeToScopeSet(content[
|
|
1723
|
+
if (content["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[childScopeAccessor][`BranchScopes:#${normalizedRenderer}/0`]);
|
|
1660
1724
|
}
|
|
1661
|
-
} else if (normalizedRenderer?.["accessor"]) subscribeToScopeSet(normalizedRenderer[
|
|
1725
|
+
} else if (normalizedRenderer?.["accessor"]) subscribeToScopeSet(normalizedRenderer[Owner], normalizedRenderer[Accessor], scope[childScopeAccessor]);
|
|
1662
1726
|
}
|
|
1663
1727
|
if (normalizedRenderer) {
|
|
1664
1728
|
const childScope = scope[childScopeAccessor];
|
|
@@ -1667,42 +1731,42 @@ let _dynamic_tag = function dynamicTag(nodeAccessor, getContent, getTagVar, inpu
|
|
|
1667
1731
|
(getContent ? _attrs : _attrs_content)(childScope, `#${normalizedRenderer}/0`, (inputIsArgs ? args[0] : args) || {});
|
|
1668
1732
|
if (childScope[`EventAttributes:#${normalizedRenderer}/0`] || childScope[`ControlledHandler:#${normalizedRenderer}/0`]) queueEffect(childScope, dynamicTagScript);
|
|
1669
1733
|
} else {
|
|
1670
|
-
for (const accessor in normalizedRenderer[
|
|
1671
|
-
if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer[
|
|
1734
|
+
for (const accessor in normalizedRenderer[LocalClosures]) normalizedRenderer[LocalClosures][accessor](childScope, normalizedRenderer[LocalClosureValues][accessor]);
|
|
1735
|
+
if (normalizedRenderer["params"]) if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
|
|
1672
1736
|
else {
|
|
1673
1737
|
const inputWithContent = getContent ? {
|
|
1674
1738
|
...args,
|
|
1675
1739
|
content: getContent(scope)
|
|
1676
1740
|
} : args || {};
|
|
1677
|
-
normalizedRenderer[
|
|
1741
|
+
normalizedRenderer[Params](childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
|
|
1678
1742
|
}
|
|
1679
1743
|
}
|
|
1680
1744
|
}
|
|
1681
1745
|
};
|
|
1682
1746
|
};
|
|
1683
1747
|
function _dynamic_tag_content(nodeAccessor) {
|
|
1684
|
-
const childScopeAccessor =
|
|
1685
|
-
const rendererAccessor =
|
|
1748
|
+
const childScopeAccessor = BranchScopes$1 + nodeAccessor;
|
|
1749
|
+
const rendererAccessor = ConditionalRenderer + nodeAccessor;
|
|
1686
1750
|
enableBranches();
|
|
1687
1751
|
return (scope, renderer) => {
|
|
1688
1752
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = renderer?.["id"] || renderer)) {
|
|
1689
1753
|
setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
|
|
1690
|
-
if (renderer?.["accessor"]) subscribeToScopeSet(renderer[
|
|
1754
|
+
if (renderer?.["accessor"]) subscribeToScopeSet(renderer[Owner], renderer[Accessor], scope[childScopeAccessor]);
|
|
1691
1755
|
}
|
|
1692
|
-
if (renderer) for (const accessor in renderer[
|
|
1756
|
+
if (renderer) for (const accessor in renderer[LocalClosures]) renderer[LocalClosures][accessor](scope[childScopeAccessor], renderer[LocalClosureValues][accessor]);
|
|
1693
1757
|
};
|
|
1694
1758
|
}
|
|
1695
1759
|
function _resume_dynamic_tag() {
|
|
1696
1760
|
_resume(DYNAMIC_TAG_SCRIPT_REGISTER_ID, dynamicTagScript);
|
|
1697
1761
|
}
|
|
1698
1762
|
function dynamicTagScript(branch) {
|
|
1699
|
-
_attrs_script(branch, `#${branch[
|
|
1763
|
+
_attrs_script(branch, `#${branch[Renderer]}/0`);
|
|
1700
1764
|
}
|
|
1701
1765
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch) {
|
|
1702
1766
|
const referenceNode = scope[nodeAccessor];
|
|
1703
|
-
const prevBranch = scope[
|
|
1767
|
+
const prevBranch = scope[BranchScopes$1 + nodeAccessor];
|
|
1704
1768
|
const parentNode = referenceNode.nodeType > 1 ? (prevBranch?.["#StartNode"] || referenceNode).parentNode : referenceNode;
|
|
1705
|
-
const newBranch = scope[
|
|
1769
|
+
const newBranch = scope[BranchScopes$1 + nodeAccessor] = newRenderer && createBranch(scope["$global"], newRenderer, scope, parentNode);
|
|
1706
1770
|
if (referenceNode === parentNode) {
|
|
1707
1771
|
if (prevBranch) {
|
|
1708
1772
|
destroyBranch(prevBranch);
|
|
@@ -1710,8 +1774,8 @@ function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch)
|
|
|
1710
1774
|
}
|
|
1711
1775
|
if (newBranch) insertBranchBefore(newBranch, parentNode, null);
|
|
1712
1776
|
} else if (prevBranch) {
|
|
1713
|
-
if (newBranch) insertBranchBefore(newBranch, parentNode, prevBranch[
|
|
1714
|
-
else parentNode.insertBefore(referenceNode, prevBranch[
|
|
1777
|
+
if (newBranch) insertBranchBefore(newBranch, parentNode, prevBranch[StartNode]);
|
|
1778
|
+
else parentNode.insertBefore(referenceNode, prevBranch[StartNode]);
|
|
1715
1779
|
removeAndDestroyBranch(prevBranch);
|
|
1716
1780
|
} else if (newBranch) {
|
|
1717
1781
|
insertBranchBefore(newBranch, parentNode, referenceNode);
|
|
@@ -1728,8 +1792,8 @@ const _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], c
|
|
|
1728
1792
|
/* @__NO_SIDE_EFFECTS__ */
|
|
1729
1793
|
function loop(forEach) {
|
|
1730
1794
|
return (nodeAccessor, template, walks, setup, params) => {
|
|
1731
|
-
const scopesAccessor =
|
|
1732
|
-
const keyedScopesAccessor =
|
|
1795
|
+
const scopesAccessor = BranchScopes$1 + nodeAccessor;
|
|
1796
|
+
const keyedScopesAccessor = KeyedScopes + nodeAccessor;
|
|
1733
1797
|
const renderer = _content("", template, walks, setup)();
|
|
1734
1798
|
enableBranches();
|
|
1735
1799
|
return (scope, value) => {
|
|
@@ -1751,8 +1815,8 @@ function loop(forEach) {
|
|
|
1751
1815
|
if (branch) {
|
|
1752
1816
|
hasPotentialMoves = true;
|
|
1753
1817
|
oldScopesByKey?.delete(key);
|
|
1754
|
-
} else branch = createAndSetupBranch(scope[
|
|
1755
|
-
branch[
|
|
1818
|
+
} else branch = createAndSetupBranch(scope[Global], renderer, scope, parentNode);
|
|
1819
|
+
branch[LoopKey] = key;
|
|
1756
1820
|
newScopes.push(branch);
|
|
1757
1821
|
params?.(branch, args);
|
|
1758
1822
|
});
|
|
@@ -1763,7 +1827,7 @@ function loop(forEach) {
|
|
|
1763
1827
|
let newEnd = newLen - 1;
|
|
1764
1828
|
if (hasSiblings) {
|
|
1765
1829
|
if (oldLen) {
|
|
1766
|
-
afterReference = oldScopes[oldEnd][
|
|
1830
|
+
afterReference = oldScopes[oldEnd][EndNode].nextSibling;
|
|
1767
1831
|
if (!newLen) parentNode.insertBefore(referenceNode, afterReference);
|
|
1768
1832
|
} else if (newLen) {
|
|
1769
1833
|
afterReference = referenceNode.nextSibling;
|
|
@@ -1784,7 +1848,7 @@ function loop(forEach) {
|
|
|
1784
1848
|
oldEnd--;
|
|
1785
1849
|
newEnd--;
|
|
1786
1850
|
}
|
|
1787
|
-
if (oldEnd + 1 < oldLen) afterReference = oldScopes[oldEnd + 1][
|
|
1851
|
+
if (oldEnd + 1 < oldLen) afterReference = oldScopes[oldEnd + 1][StartNode];
|
|
1788
1852
|
if (start > oldEnd || start > newEnd) {
|
|
1789
1853
|
for (let i = start; i <= newEnd; i++) insertBranchBefore(newScopes[i], parentNode, afterReference);
|
|
1790
1854
|
return;
|
|
@@ -1823,7 +1887,7 @@ function loop(forEach) {
|
|
|
1823
1887
|
for (let i = diffLen; i--;) {
|
|
1824
1888
|
if (~tail && i === tails[tail]) tail--;
|
|
1825
1889
|
else insertBranchBefore(newScopes[start + i], parentNode, afterReference);
|
|
1826
|
-
afterReference = newScopes[start + i][
|
|
1890
|
+
afterReference = newScopes[start + i][StartNode];
|
|
1827
1891
|
}
|
|
1828
1892
|
};
|
|
1829
1893
|
};
|
|
@@ -1831,7 +1895,7 @@ function loop(forEach) {
|
|
|
1831
1895
|
function createBranchWithTagNameOrRenderer($global, tagNameOrRenderer, parentScope, parentNode) {
|
|
1832
1896
|
if (typeof tagNameOrRenderer === "string") assertValidTagName(tagNameOrRenderer);
|
|
1833
1897
|
const branch = createBranch($global, tagNameOrRenderer, parentScope, parentNode);
|
|
1834
|
-
if (typeof tagNameOrRenderer === "string") branch[`#${tagNameOrRenderer}/0`] = branch[
|
|
1898
|
+
if (typeof tagNameOrRenderer === "string") branch[`#${tagNameOrRenderer}/0`] = branch[StartNode] = branch[EndNode] = document.createElementNS(tagNameOrRenderer === "svg" ? "http://www.w3.org/2000/svg" : tagNameOrRenderer === "math" ? "http://www.w3.org/1998/Math/MathML" : parentNode.namespaceURI, tagNameOrRenderer);
|
|
1835
1899
|
else setupBranch(tagNameOrRenderer, branch);
|
|
1836
1900
|
return branch;
|
|
1837
1901
|
}
|
|
@@ -1853,15 +1917,15 @@ const scopeKeyOffset = 1e6;
|
|
|
1853
1917
|
function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"]) {
|
|
1854
1918
|
let render;
|
|
1855
1919
|
if (signalKey >= 0 && (render = scope[signalKey])) {
|
|
1856
|
-
render[
|
|
1920
|
+
render[Value] = value;
|
|
1857
1921
|
if (render["gen"] === runId || catchEnabled && render["pending"]) return;
|
|
1858
1922
|
render["gen"] = runId;
|
|
1859
1923
|
} else {
|
|
1860
1924
|
render = {
|
|
1861
1925
|
["key"]: scopeKey * scopeKeyOffset + signalKey,
|
|
1862
|
-
[
|
|
1863
|
-
[
|
|
1864
|
-
[
|
|
1926
|
+
[Scope]: scope,
|
|
1927
|
+
[Signal]: signal,
|
|
1928
|
+
[Value]: value,
|
|
1865
1929
|
["gen"]: runId
|
|
1866
1930
|
};
|
|
1867
1931
|
if (signalKey >= 0) scope[signalKey] = render;
|
|
@@ -1942,7 +2006,7 @@ function runRenders() {
|
|
|
1942
2006
|
runRender(render);
|
|
1943
2007
|
}
|
|
1944
2008
|
}
|
|
1945
|
-
let runRender = (render) => render[
|
|
2009
|
+
let runRender = (render) => render[Signal](render[Scope], render[Value]);
|
|
1946
2010
|
function skipDestroyedRenders() {
|
|
1947
2011
|
runRender = ((runRender) => (render) => {
|
|
1948
2012
|
if (render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) runRender(render);
|
|
@@ -1955,8 +2019,8 @@ function _enable_catch() {
|
|
|
1955
2019
|
enableBranches();
|
|
1956
2020
|
const handlePendingTry = (fn, scope, branch) => {
|
|
1957
2021
|
while (branch) {
|
|
1958
|
-
if (branch["#AwaitCounter"]?.i) return (branch[
|
|
1959
|
-
branch = branch[
|
|
2022
|
+
if (branch["#AwaitCounter"]?.i) return (branch[PendingEffects] ||= []).push(fn, scope);
|
|
2023
|
+
branch = branch[ParentBranch];
|
|
1960
2024
|
}
|
|
1961
2025
|
};
|
|
1962
2026
|
runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
@@ -1974,18 +2038,18 @@ function _enable_catch() {
|
|
|
1974
2038
|
})(runEffects);
|
|
1975
2039
|
runRender = ((runRender) => (render) => {
|
|
1976
2040
|
try {
|
|
1977
|
-
let branch = render[
|
|
2041
|
+
let branch = render[Scope][ClosestBranch];
|
|
1978
2042
|
while (branch) {
|
|
1979
2043
|
if (branch["#PendingRenders"]) {
|
|
1980
|
-
render[
|
|
1981
|
-
return branch[
|
|
2044
|
+
render[Pending] = 1;
|
|
2045
|
+
return branch[PendingRenders].push(render);
|
|
1982
2046
|
}
|
|
1983
|
-
branch = branch[
|
|
2047
|
+
branch = branch[ParentBranch];
|
|
1984
2048
|
}
|
|
1985
|
-
render[
|
|
2049
|
+
render[Pending] = 0;
|
|
1986
2050
|
runRender(render);
|
|
1987
2051
|
} catch (error) {
|
|
1988
|
-
renderCatch(render[
|
|
2052
|
+
renderCatch(render[Scope], error);
|
|
1989
2053
|
}
|
|
1990
2054
|
})(runRender);
|
|
1991
2055
|
}
|
|
@@ -1993,15 +2057,15 @@ function _enable_catch() {
|
|
|
1993
2057
|
//#endregion
|
|
1994
2058
|
//#region src/dom/abort-signal.ts
|
|
1995
2059
|
function $signalReset(scope, id) {
|
|
1996
|
-
const ctrl = scope[
|
|
2060
|
+
const ctrl = scope[AbortControllers]?.[id];
|
|
1997
2061
|
if (ctrl) {
|
|
1998
2062
|
queueEffect(ctrl, abort);
|
|
1999
|
-
scope[
|
|
2063
|
+
scope[AbortControllers][id] = void 0;
|
|
2000
2064
|
}
|
|
2001
2065
|
}
|
|
2002
2066
|
function $signal(scope, id) {
|
|
2003
|
-
if (scope["#ClosestBranch"]) (scope[
|
|
2004
|
-
return ((scope[
|
|
2067
|
+
if (scope["#ClosestBranch"]) (scope[ClosestBranch][AbortScopes] ||= /* @__PURE__ */ new Set()).add(scope);
|
|
2068
|
+
return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
|
|
2005
2069
|
}
|
|
2006
2070
|
function abort(ctrl) {
|
|
2007
2071
|
ctrl.abort();
|
|
@@ -2026,7 +2090,7 @@ const compat = {
|
|
|
2026
2090
|
queueEffect,
|
|
2027
2091
|
init(warp10Noop) {
|
|
2028
2092
|
_resume(SET_SCOPE_REGISTER_ID, (scope) => {
|
|
2029
|
-
getRenderScopes(scope[
|
|
2093
|
+
getRenderScopes(scope[Global])[scope["#Id"]] = scope;
|
|
2030
2094
|
if (scope.m5c) classIdToBranch.set(scope.m5c, scope);
|
|
2031
2095
|
if (classEventResolver) for (const key in scope) {
|
|
2032
2096
|
const resolved = classEventResolver(scope[key], scope);
|
|
@@ -2045,17 +2109,17 @@ const compat = {
|
|
|
2045
2109
|
renderer["id"] = id;
|
|
2046
2110
|
},
|
|
2047
2111
|
isRenderer(renderer) {
|
|
2048
|
-
return renderer[
|
|
2112
|
+
return renderer[Clone];
|
|
2049
2113
|
},
|
|
2050
2114
|
getStartNode(branch) {
|
|
2051
|
-
return branch[
|
|
2115
|
+
return branch[StartNode];
|
|
2052
2116
|
},
|
|
2053
2117
|
getEndNode(branch) {
|
|
2054
|
-
return branch[
|
|
2118
|
+
return branch[EndNode];
|
|
2055
2119
|
},
|
|
2056
2120
|
setScopeNodes(branch, startNode, endNode) {
|
|
2057
|
-
branch[
|
|
2058
|
-
branch[
|
|
2121
|
+
branch[StartNode] = startNode;
|
|
2122
|
+
branch[EndNode] = endNode;
|
|
2059
2123
|
},
|
|
2060
2124
|
runComponentEffects() {
|
|
2061
2125
|
if (this.effects) runEffects(this.effects);
|
|
@@ -2069,10 +2133,10 @@ const compat = {
|
|
|
2069
2133
|
},
|
|
2070
2134
|
createRenderer(params, clone) {
|
|
2071
2135
|
const renderer = _content("", 0, 0, 0, params)();
|
|
2072
|
-
renderer[
|
|
2136
|
+
renderer[Clone] = (branch) => {
|
|
2073
2137
|
const cloned = clone();
|
|
2074
|
-
branch[
|
|
2075
|
-
branch[
|
|
2138
|
+
branch[StartNode] = cloned.startNode;
|
|
2139
|
+
branch[EndNode] = cloned.endNode;
|
|
2076
2140
|
};
|
|
2077
2141
|
return renderer;
|
|
2078
2142
|
},
|
|
@@ -2091,11 +2155,11 @@ const compat = {
|
|
|
2091
2155
|
component.effects = prepareEffects(() => {
|
|
2092
2156
|
if (!branch) {
|
|
2093
2157
|
created = 1;
|
|
2094
|
-
branch = component.scope = createAndSetupBranch(out.global, renderer, renderer[
|
|
2158
|
+
branch = component.scope = createAndSetupBranch(out.global, renderer, renderer[Owner], document.body);
|
|
2095
2159
|
}
|
|
2096
|
-
renderer[
|
|
2160
|
+
renderer[Params]?.(branch, renderer._ ? args[0] : args);
|
|
2097
2161
|
});
|
|
2098
|
-
if (created) return toInsertNode(branch[
|
|
2162
|
+
if (created) return toInsertNode(branch[StartNode], branch[EndNode]);
|
|
2099
2163
|
}
|
|
2100
2164
|
};
|
|
2101
2165
|
//#endregion
|
|
@@ -2141,16 +2205,16 @@ function mount(input = {}, reference, position) {
|
|
|
2141
2205
|
break;
|
|
2142
2206
|
}
|
|
2143
2207
|
let curValue;
|
|
2144
|
-
const args = this[
|
|
2208
|
+
const args = this[Params];
|
|
2145
2209
|
const effects = prepareEffects(() => {
|
|
2146
2210
|
branch = createBranch($global, this, void 0, parentNode);
|
|
2147
|
-
branch[
|
|
2211
|
+
branch[TagVariable] = (newValue) => {
|
|
2148
2212
|
curValue = newValue;
|
|
2149
2213
|
};
|
|
2150
|
-
this[
|
|
2214
|
+
this[Setup]?.(branch);
|
|
2151
2215
|
args?.(branch, input);
|
|
2152
2216
|
});
|
|
2153
|
-
insertChildNodes(parentNode, nextSibling, branch[
|
|
2217
|
+
insertChildNodes(parentNode, nextSibling, branch[StartNode], branch[EndNode]);
|
|
2154
2218
|
runEffects(effects);
|
|
2155
2219
|
return {
|
|
2156
2220
|
get value() {
|
|
@@ -2176,12 +2240,12 @@ function _load_template(id, load) {
|
|
|
2176
2240
|
let pending;
|
|
2177
2241
|
const lazyTemplate = _template(id, 0, 0, (branch) => {
|
|
2178
2242
|
const awaitCounter = addAwaitCounter(branch);
|
|
2179
|
-
branch[
|
|
2243
|
+
branch[Load] ||= /* @__PURE__ */ new Map();
|
|
2180
2244
|
(pending ||= load()).then((renderer) => {
|
|
2181
2245
|
Object.assign(lazyTemplate, renderer);
|
|
2182
|
-
queueAsyncRender(branch, (branch) => insertLoaded(renderer, branch, branch[
|
|
2246
|
+
queueAsyncRender(branch, (branch) => insertLoaded(renderer, branch, branch[StartNode], awaitCounter));
|
|
2183
2247
|
}, loadFailed(branch, awaitCounter));
|
|
2184
|
-
}, _load_signal(() => (pending ||= load()).then((r) => ({ _: r[
|
|
2248
|
+
}, _load_signal(() => (pending ||= load()).then((r) => ({ _: r[Params] }))));
|
|
2185
2249
|
return lazyTemplate;
|
|
2186
2250
|
}
|
|
2187
2251
|
function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
@@ -2193,7 +2257,7 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
2193
2257
|
if (renderer) insertLoaded(renderer, child, owner[nodeAccessor]);
|
|
2194
2258
|
else {
|
|
2195
2259
|
const awaitCounter = addAwaitCounter(owner);
|
|
2196
|
-
child[
|
|
2260
|
+
child[Load] ||= /* @__PURE__ */ new Map();
|
|
2197
2261
|
(pending ||= load()).then((mod) => {
|
|
2198
2262
|
renderer = _content("", ...mod._)();
|
|
2199
2263
|
queueAsyncRender(child, (child) => insertLoaded(renderer, child, owner[nodeAccessor], awaitCounter));
|
|
@@ -2202,25 +2266,27 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
2202
2266
|
};
|
|
2203
2267
|
}
|
|
2204
2268
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
2205
|
-
const parent = marker.parentNode, values = branch[
|
|
2269
|
+
const parent = marker.parentNode, values = branch[Load], insert = () => {
|
|
2206
2270
|
insertBranchBefore(branch, parent, marker);
|
|
2207
2271
|
marker.remove();
|
|
2208
2272
|
awaitCounter?.c();
|
|
2209
2273
|
};
|
|
2210
2274
|
let remaining;
|
|
2211
2275
|
syncGen(branch);
|
|
2212
|
-
renderer[
|
|
2213
|
-
branch[
|
|
2214
|
-
if (remaining = values?.size)
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2276
|
+
renderer[Clone](branch, parent.namespaceURI);
|
|
2277
|
+
branch[Load] = 0;
|
|
2278
|
+
if (remaining = values?.size) {
|
|
2279
|
+
const fail = loadFailed(branch, awaitCounter);
|
|
2280
|
+
for (const [promise, entry] of values) promise.then((signal) => {
|
|
2281
|
+
entry[Signal$1] = signal;
|
|
2282
|
+
if (!--remaining) queueAsyncRender(branch, (branch) => {
|
|
2283
|
+
syncGen(branch);
|
|
2284
|
+
renderer[Setup]?.(branch);
|
|
2285
|
+
values.forEach((e) => e[Signal$1]._(branch, e[Value$1]));
|
|
2286
|
+
insert();
|
|
2287
|
+
});
|
|
2288
|
+
}, (error) => remaining > 0 && (remaining = 0, fail(error)));
|
|
2289
|
+
} else {
|
|
2224
2290
|
setupBranch(renderer, branch);
|
|
2225
2291
|
insert();
|
|
2226
2292
|
}
|
|
@@ -2237,7 +2303,7 @@ function _load_signal(load) {
|
|
|
2237
2303
|
let signal;
|
|
2238
2304
|
return (scope, value) => {
|
|
2239
2305
|
pending ||= load();
|
|
2240
|
-
if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === runId) (scope[
|
|
2306
|
+
if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === runId) (scope[Load] ||= /* @__PURE__ */ new Map()).set(pending, { [Value$1]: value });
|
|
2241
2307
|
else if (signal) signal(scope, value);
|
|
2242
2308
|
else pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
|
|
2243
2309
|
};
|