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