marko 6.0.0-next.3.59 → 6.0.0-next.3.61
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/accessor.d.ts +24 -0
- package/dist/common/accessor.debug.d.ts +24 -0
- package/dist/common/types.d.ts +2 -17
- package/dist/debug/dom.js +348 -183
- package/dist/debug/dom.mjs +348 -183
- package/dist/debug/html.js +123 -44
- package/dist/debug/html.mjs +123 -44
- package/dist/dom/control-flow.d.ts +5 -0
- package/dist/dom/queue.d.ts +2 -1
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +282 -159
- package/dist/dom.mjs +282 -159
- package/dist/html/dynamic-tag.d.ts +3 -4
- package/dist/html/serializer.d.ts +2 -1
- package/dist/html/writer.d.ts +2 -3
- package/dist/html.js +107 -39
- package/dist/html.mjs +107 -39
- package/dist/translator/core/await.d.ts +7 -0
- package/dist/translator/core/try.d.ts +7 -0
- package/dist/translator/index.js +222 -43
- package/dist/translator/util/get-accessor-char.d.ts +4 -0
- package/dist/translator/util/sections.d.ts +1 -1
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
@@ -25,6 +25,7 @@ __export(dom_exports, {
|
|
25
25
|
attrTags: () => attrTags,
|
26
26
|
attrs: () => attrs,
|
27
27
|
attrsEvents: () => attrsEvents,
|
28
|
+
awaitTag: () => awaitTag,
|
28
29
|
classAttr: () => classAttr,
|
29
30
|
compat: () => compat,
|
30
31
|
conditional: () => conditional,
|
@@ -44,11 +45,13 @@ __export(dom_exports, {
|
|
44
45
|
createContent: () => createContent,
|
45
46
|
createRenderer: () => createRenderer,
|
46
47
|
createTemplate: () => createTemplate,
|
48
|
+
createTry: () => createTry,
|
47
49
|
data: () => data,
|
48
50
|
dynamicClosure: () => dynamicClosure,
|
49
51
|
dynamicClosureRead: () => dynamicClosureRead,
|
50
52
|
dynamicTag: () => dynamicTag,
|
51
53
|
effect: () => effect,
|
54
|
+
enableCatch: () => enableCatch,
|
52
55
|
forIn: () => forIn,
|
53
56
|
forOf: () => forOf,
|
54
57
|
forTo: () => forTo,
|
@@ -319,7 +322,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
319
322
|
const token = commentText[commentPrefixLen];
|
320
323
|
if (token === "*" /* Node */) {
|
321
324
|
const node = scope[data2] = visit.previousSibling;
|
322
|
-
scope[
|
325
|
+
scope["Getter:" /* Getter */ + data2] = () => node;
|
323
326
|
} else if (token === "$" /* ClosestBranch */) {
|
324
327
|
closestBranchMarkers.set(scopeId, visit);
|
325
328
|
} else if (token === "[" /* BranchStart */) {
|
@@ -464,7 +467,7 @@ function controllable_input_checked(scope, nodeAccessor, checked, checkedChange)
|
|
464
467
|
function controllable_input_checked_effect(scope, nodeAccessor) {
|
465
468
|
const el = scope[nodeAccessor];
|
466
469
|
syncControllable(el, "input", hasCheckboxChanged, () => {
|
467
|
-
const checkedChange = scope[
|
470
|
+
const checkedChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
468
471
|
if (checkedChange) {
|
469
472
|
const newValue = el.checked;
|
470
473
|
el.checked = !newValue;
|
@@ -474,7 +477,7 @@ function controllable_input_checked_effect(scope, nodeAccessor) {
|
|
474
477
|
});
|
475
478
|
}
|
476
479
|
function controllable_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value2) {
|
477
|
-
scope[
|
480
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = checkedValue;
|
478
481
|
attr(scope[nodeAccessor], "value", value2);
|
479
482
|
setCheckboxValue(
|
480
483
|
scope,
|
@@ -487,9 +490,9 @@ function controllable_input_checkedValue(scope, nodeAccessor, checkedValue, chec
|
|
487
490
|
function controllable_input_checkedValue_effect(scope, nodeAccessor) {
|
488
491
|
const el = scope[nodeAccessor];
|
489
492
|
syncControllable(el, "input", hasCheckboxChanged, () => {
|
490
|
-
const checkedValueChange = scope[
|
493
|
+
const checkedValueChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
491
494
|
if (checkedValueChange) {
|
492
|
-
const oldValue = scope[
|
495
|
+
const oldValue = scope["ControlledValue:" /* ControlledValue */ + nodeAccessor];
|
493
496
|
const newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
|
494
497
|
if (el.name && el.type[0] === "r") {
|
495
498
|
for (const radio of el.getRootNode().querySelectorAll(
|
@@ -510,33 +513,33 @@ function controllable_input_checkedValue_effect(scope, nodeAccessor) {
|
|
510
513
|
function controllable_input_value(scope, nodeAccessor, value2, valueChange) {
|
511
514
|
const el = scope[nodeAccessor];
|
512
515
|
const normalizedValue = normalizeStrProp(value2);
|
513
|
-
scope[
|
516
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = valueChange;
|
514
517
|
if (valueChange) {
|
515
|
-
scope[
|
516
|
-
scope[
|
518
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 0 /* InputChecked */;
|
519
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = value2;
|
517
520
|
if (el.isConnected) {
|
518
521
|
setValueAndUpdateSelection(el, normalizedValue);
|
519
522
|
} else {
|
520
523
|
el.defaultValue = normalizedValue;
|
521
524
|
}
|
522
525
|
} else {
|
523
|
-
scope[
|
526
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
524
527
|
el.defaultValue = normalizedValue;
|
525
528
|
}
|
526
529
|
}
|
527
530
|
function controllable_input_value_effect(scope, nodeAccessor) {
|
528
531
|
const el = scope[nodeAccessor];
|
529
532
|
if (isResuming) {
|
530
|
-
scope[
|
533
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = el.defaultValue;
|
531
534
|
}
|
532
535
|
syncControllable(el, "input", hasValueChanged, (ev) => {
|
533
|
-
const valueChange = scope[
|
536
|
+
const valueChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
534
537
|
if (valueChange) {
|
535
538
|
const newValue = el.value;
|
536
539
|
inputType = ev?.inputType;
|
537
540
|
setValueAndUpdateSelection(
|
538
541
|
el,
|
539
|
-
scope[
|
542
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor]
|
540
543
|
);
|
541
544
|
valueChange(newValue);
|
542
545
|
run();
|
@@ -545,12 +548,12 @@ function controllable_input_value_effect(scope, nodeAccessor) {
|
|
545
548
|
});
|
546
549
|
}
|
547
550
|
function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
548
|
-
scope[
|
551
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = valueChange;
|
549
552
|
if (valueChange) {
|
550
|
-
scope[
|
551
|
-
scope[
|
553
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 3 /* SelectValue */;
|
554
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = value2;
|
552
555
|
} else {
|
553
|
-
scope[
|
556
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
554
557
|
}
|
555
558
|
pendingEffects.unshift(
|
556
559
|
() => setSelectOptions(
|
@@ -564,14 +567,14 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
564
567
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
565
568
|
const el = scope[nodeAccessor];
|
566
569
|
const onChange = () => {
|
567
|
-
const valueChange = scope[
|
570
|
+
const valueChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
568
571
|
if (valueChange) {
|
569
572
|
const newValue = Array.isArray(
|
570
|
-
scope[
|
573
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor]
|
571
574
|
) ? Array.from(el.selectedOptions, toValueProp) : el.value;
|
572
575
|
setSelectOptions(
|
573
576
|
el,
|
574
|
-
scope[
|
577
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor],
|
575
578
|
valueChange
|
576
579
|
);
|
577
580
|
valueChange(newValue);
|
@@ -580,7 +583,7 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
580
583
|
};
|
581
584
|
if (!el._) {
|
582
585
|
new MutationObserver(() => {
|
583
|
-
const value2 = scope[
|
586
|
+
const value2 = scope["ControlledValue:" /* ControlledValue */ + nodeAccessor];
|
584
587
|
if (Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) {
|
585
588
|
onChange();
|
586
589
|
}
|
@@ -613,23 +616,23 @@ function setSelectOptions(el, value2, valueChange) {
|
|
613
616
|
}
|
614
617
|
}
|
615
618
|
function controllable_detailsOrDialog_open(scope, nodeAccessor, open, openChange) {
|
616
|
-
scope[
|
619
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = openChange;
|
617
620
|
if (openChange) {
|
618
|
-
scope[
|
621
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 4 /* DetailsOrDialogOpen */;
|
619
622
|
} else {
|
620
|
-
scope[
|
623
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
621
624
|
}
|
622
|
-
scope[nodeAccessor].open = scope[
|
625
|
+
scope[nodeAccessor].open = scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = normalizeBoolProp(open);
|
623
626
|
}
|
624
627
|
function controllable_detailsOrDialog_open_effect(scope, nodeAccessor) {
|
625
628
|
const el = scope[nodeAccessor];
|
626
|
-
const hasChanged = () => el.open !== scope[
|
629
|
+
const hasChanged = () => el.open !== scope["ControlledValue:" /* ControlledValue */ + nodeAccessor];
|
627
630
|
syncControllable(
|
628
631
|
el,
|
629
632
|
el.tagName === "DIALOG" ? "close" : "toggle",
|
630
633
|
hasChanged,
|
631
634
|
() => {
|
632
|
-
const openChange = scope[
|
635
|
+
const openChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
633
636
|
if (openChange && hasChanged()) {
|
634
637
|
const newValue = el.open;
|
635
638
|
el.open = !newValue;
|
@@ -654,12 +657,12 @@ function setValueAndUpdateSelection(el, value2) {
|
|
654
657
|
}
|
655
658
|
}
|
656
659
|
function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
657
|
-
scope[
|
660
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = checkedChange;
|
658
661
|
if (checkedChange) {
|
659
|
-
scope[
|
662
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = type;
|
660
663
|
scope[nodeAccessor].checked = checked;
|
661
664
|
} else {
|
662
|
-
scope[
|
665
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
663
666
|
scope[nodeAccessor].defaultChecked = checked;
|
664
667
|
}
|
665
668
|
}
|
@@ -871,7 +874,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
871
874
|
break;
|
872
875
|
default: {
|
873
876
|
if (isEventHandler(name)) {
|
874
|
-
(events ||= scope[
|
877
|
+
(events ||= scope["EventAttributes:" /* EventAttributes */ + nodeAccessor] = {})[getEventHandlerName(name)] = value2;
|
875
878
|
} else if (!skip?.test(name)) {
|
876
879
|
attr(el, name, value2);
|
877
880
|
}
|
@@ -881,8 +884,8 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
881
884
|
}
|
882
885
|
function attrsEvents(scope, nodeAccessor) {
|
883
886
|
const el = scope[nodeAccessor];
|
884
|
-
const events = scope[
|
885
|
-
switch (scope[
|
887
|
+
const events = scope["EventAttributes:" /* EventAttributes */ + nodeAccessor];
|
888
|
+
switch (scope["ControlledType:" /* ControlledType */ + nodeAccessor]) {
|
886
889
|
case 0 /* InputChecked */:
|
887
890
|
controllable_input_checked_effect(scope, nodeAccessor);
|
888
891
|
break;
|
@@ -906,7 +909,7 @@ function attrsEvents(scope, nodeAccessor) {
|
|
906
909
|
function html(scope, value2, accessor) {
|
907
910
|
const firstChild = scope[accessor];
|
908
911
|
const parentNode = firstChild.parentNode;
|
909
|
-
const lastChild = scope[
|
912
|
+
const lastChild = scope["DynamicPlaceholderLastChild:" /* DynamicPlaceholderLastChild */ + accessor] || firstChild;
|
910
913
|
const newContent = parseHTML(
|
911
914
|
value2 || value2 === 0 ? value2 + "" : "",
|
912
915
|
parentNode.namespaceURI
|
@@ -915,7 +918,7 @@ function html(scope, value2, accessor) {
|
|
915
918
|
parentNode,
|
916
919
|
firstChild,
|
917
920
|
scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
|
918
|
-
scope[
|
921
|
+
scope["DynamicPlaceholderLastChild:" /* DynamicPlaceholderLastChild */ + accessor] = newContent.lastChild
|
919
922
|
);
|
920
923
|
removeChildNodes(firstChild, lastChild);
|
921
924
|
}
|
@@ -953,7 +956,7 @@ function lifecycle(scope, index, thisObj) {
|
|
953
956
|
thisObj.onMount?.();
|
954
957
|
getAbortSignal(
|
955
958
|
scope,
|
956
|
-
"
|
959
|
+
"LifecycleAbortController:" /* LifecycleAbortController */ + index
|
957
960
|
).onabort = () => thisObj.onDestroy?.();
|
958
961
|
}
|
959
962
|
}
|
@@ -1028,134 +1031,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
1028
1031
|
branch.___endNode
|
1029
1032
|
);
|
1030
1033
|
}
|
1031
|
-
|
1032
|
-
|
1033
|
-
|
1034
|
-
|
1035
|
-
|
1036
|
-
|
1037
|
-
|
1038
|
-
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
|
1039
|
-
const key = scopeKey * scopeKeyOffset + signalKey;
|
1040
|
-
const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1041
|
-
if (existingRender) {
|
1042
|
-
existingRender.___value = value2;
|
1043
|
-
} else {
|
1044
|
-
const render = {
|
1045
|
-
___key: key,
|
1046
|
-
___scope: scope,
|
1047
|
-
___signal: signal,
|
1048
|
-
___value: value2
|
1049
|
-
};
|
1050
|
-
let i = pendingRenders.push(render) - 1;
|
1051
|
-
while (i) {
|
1052
|
-
const parentIndex = i - 1 >> 1;
|
1053
|
-
const parent = pendingRenders[parentIndex];
|
1054
|
-
if (key - parent.___key >= 0) break;
|
1055
|
-
pendingRenders[i] = parent;
|
1056
|
-
i = parentIndex;
|
1057
|
-
}
|
1058
|
-
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
1059
|
-
pendingRenders[i] = render;
|
1060
|
-
}
|
1061
|
-
}
|
1062
|
-
function queueEffect(scope, fn) {
|
1063
|
-
pendingEffects.push(fn, scope);
|
1064
|
-
}
|
1065
|
-
function run() {
|
1066
|
-
const effects = pendingEffects;
|
1067
|
-
try {
|
1068
|
-
rendering = true;
|
1069
|
-
runRenders();
|
1070
|
-
} finally {
|
1071
|
-
pendingRenders = [];
|
1072
|
-
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1073
|
-
pendingEffects = [];
|
1074
|
-
rendering = false;
|
1075
|
-
}
|
1076
|
-
runEffects(effects);
|
1077
|
-
}
|
1078
|
-
function prepareEffects(fn) {
|
1079
|
-
const prevRenders = pendingRenders;
|
1080
|
-
const prevRendersLookup = pendingRendersLookup;
|
1081
|
-
const prevEffects = pendingEffects;
|
1082
|
-
const preparedEffects = pendingEffects = [];
|
1083
|
-
pendingRenders = [];
|
1084
|
-
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1085
|
-
try {
|
1086
|
-
rendering = true;
|
1087
|
-
fn();
|
1088
|
-
runRenders();
|
1089
|
-
} finally {
|
1090
|
-
rendering = false;
|
1091
|
-
pendingRenders = prevRenders;
|
1092
|
-
pendingRendersLookup = prevRendersLookup;
|
1093
|
-
pendingEffects = prevEffects;
|
1094
|
-
}
|
1095
|
-
return preparedEffects;
|
1096
|
-
}
|
1097
|
-
function runEffects(effects) {
|
1098
|
-
for (let i = 0, scope; i < effects.length; ) {
|
1099
|
-
effects[i++](
|
1100
|
-
scope = effects[i++],
|
1101
|
-
scope
|
1102
|
-
);
|
1103
|
-
}
|
1104
|
-
}
|
1105
|
-
function runRenders() {
|
1106
|
-
while (pendingRenders.length) {
|
1107
|
-
const render = pendingRenders[0];
|
1108
|
-
const item = pendingRenders.pop();
|
1109
|
-
if (render !== item) {
|
1110
|
-
let i = 0;
|
1111
|
-
const mid = pendingRenders.length >> 1;
|
1112
|
-
const key = (pendingRenders[0] = item).___key;
|
1113
|
-
while (i < mid) {
|
1114
|
-
let bestChild = (i << 1) + 1;
|
1115
|
-
const right = bestChild + 1;
|
1116
|
-
if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
|
1117
|
-
bestChild = right;
|
1118
|
-
}
|
1119
|
-
if (pendingRenders[bestChild].___key - key >= 0) {
|
1120
|
-
break;
|
1121
|
-
} else {
|
1122
|
-
pendingRenders[i] = pendingRenders[bestChild];
|
1123
|
-
i = bestChild;
|
1124
|
-
}
|
1125
|
-
}
|
1126
|
-
pendingRenders[i] = item;
|
1127
|
-
}
|
1128
|
-
if (!render.___scope.___closestBranch?.___destroyed) {
|
1129
|
-
render.___signal(render.___scope, render.___value);
|
1130
|
-
}
|
1131
|
-
}
|
1132
|
-
finishPendingScopes();
|
1133
|
-
}
|
1134
|
-
|
1135
|
-
// src/dom/abort-signal.ts
|
1136
|
-
function resetAbortSignal(scope, id) {
|
1137
|
-
const ctrl = scope.___abortControllers?.[id];
|
1138
|
-
if (ctrl) {
|
1139
|
-
queueEffect(ctrl, abort);
|
1140
|
-
scope.___abortControllers[id] = void 0;
|
1141
|
-
}
|
1142
|
-
}
|
1143
|
-
function getAbortSignal(scope, id) {
|
1144
|
-
if (scope.___closestBranch) {
|
1145
|
-
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1146
|
-
}
|
1147
|
-
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1148
|
-
}
|
1149
|
-
function abort(ctrl) {
|
1150
|
-
ctrl.abort();
|
1034
|
+
function tempDetatchBranch(branch) {
|
1035
|
+
insertChildNodes(
|
1036
|
+
new DocumentFragment(),
|
1037
|
+
null,
|
1038
|
+
branch.___startNode,
|
1039
|
+
branch.___endNode
|
1040
|
+
);
|
1151
1041
|
}
|
1152
1042
|
|
1153
|
-
// src/common/compat-meta.ts
|
1154
|
-
var prefix = true ? "$compat_" : "$C_";
|
1155
|
-
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1156
|
-
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1157
|
-
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
1158
|
-
|
1159
1043
|
// src/dom/reconcile.ts
|
1160
1044
|
var WRONG_POS = 2147483647;
|
1161
1045
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -1340,7 +1224,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
1340
1224
|
if (value2 === 32 /* Get */) {
|
1341
1225
|
const node = walker.currentNode;
|
1342
1226
|
scope[true ? getDebugKey(currentScopeIndex, walker.currentNode) : currentScopeIndex] = node;
|
1343
|
-
scope[(true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++)
|
1227
|
+
scope["Getter:" /* Getter */ + (true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++)] = () => node;
|
1344
1228
|
} else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */) {
|
1345
1229
|
walker.currentNode.replaceWith(
|
1346
1230
|
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text()
|
@@ -1553,7 +1437,7 @@ function state(valueAccessor, fn) {
|
|
1553
1437
|
valueAccessor.lastIndexOf("/")
|
1554
1438
|
);
|
1555
1439
|
}
|
1556
|
-
const valueChangeAccessor =
|
1440
|
+
const valueChangeAccessor = "@TagVariableChange" /* TagVariableChange */ + valueAccessor;
|
1557
1441
|
const update = (scope, value2) => {
|
1558
1442
|
if (scope[valueAccessor] !== value2) {
|
1559
1443
|
scope[valueAccessor] = value2;
|
@@ -1604,8 +1488,8 @@ function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__
|
|
1604
1488
|
}
|
1605
1489
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
1606
1490
|
const childSignal = closure(valueAccessor, fn);
|
1607
|
-
const loopScopeAccessor =
|
1608
|
-
const loopScopeMapAccessor =
|
1491
|
+
const loopScopeAccessor = "LoopScopeArray:" /* LoopScopeArray */ + ownerLoopNodeAccessor;
|
1492
|
+
const loopScopeMapAccessor = "LoopScopeMap:" /* LoopScopeMap */ + ownerLoopNodeAccessor;
|
1609
1493
|
const ownerSignal = (ownerScope) => {
|
1610
1494
|
const scopes = ownerScope[loopScopeAccessor] || ownerScope[loopScopeMapAccessor]?.values() || [];
|
1611
1495
|
const [firstScope] = scopes;
|
@@ -1630,8 +1514,8 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1630
1514
|
}
|
1631
1515
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
1632
1516
|
const childSignal = closure(valueAccessor, fn);
|
1633
|
-
const scopeAccessor =
|
1634
|
-
const branchAccessor =
|
1517
|
+
const scopeAccessor = "ConditionalScope:" /* ConditionalScope */ + ownerConditionalNodeAccessor;
|
1518
|
+
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + ownerConditionalNodeAccessor;
|
1635
1519
|
const ownerSignal = (scope) => {
|
1636
1520
|
const ifScope = scope[scopeAccessor];
|
1637
1521
|
if (ifScope && !ifScope.___pending && scope[branchAccessor] === branch) {
|
@@ -1681,8 +1565,8 @@ function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
|
1681
1565
|
scope
|
1682
1566
|
);
|
1683
1567
|
};
|
1684
|
-
closureSignal.___scopeInstancesAccessor =
|
1685
|
-
closureSignal.___signalIndexAccessor =
|
1568
|
+
closureSignal.___scopeInstancesAccessor = "ClosureScopes:" /* ClosureScopes */ + valueAccessor;
|
1569
|
+
closureSignal.___signalIndexAccessor = "ClosureSignalIndex:" /* ClosureSignalIndex */ + valueAccessor;
|
1686
1570
|
return closureSignal;
|
1687
1571
|
}
|
1688
1572
|
function closure(valueAccessor, fn, getOwnerScope) {
|
@@ -1691,13 +1575,13 @@ function closure(valueAccessor, fn, getOwnerScope) {
|
|
1691
1575
|
};
|
1692
1576
|
}
|
1693
1577
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1694
|
-
scope[childAccessor]["/" /* TagVariable */] = (value2) => tagVarSignal2(scope, value2);
|
1578
|
+
scope[childAccessor]["/TagVariable" /* TagVariable */] = (value2) => tagVarSignal2(scope, value2);
|
1695
1579
|
}
|
1696
|
-
var tagVarSignal = (scope, value2) => scope["/" /* TagVariable */]?.(value2);
|
1580
|
+
var tagVarSignal = (scope, value2) => scope["/TagVariable" /* TagVariable */]?.(value2);
|
1697
1581
|
function setTagVarChange(scope, changeHandler) {
|
1698
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
1582
|
+
scope["@TagVariableChange" /* TagVariableChange */] = changeHandler;
|
1699
1583
|
}
|
1700
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1584
|
+
var tagVarSignalChange = (scope, value2) => scope["@TagVariableChange" /* TagVariableChange */]?.(value2);
|
1701
1585
|
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1702
1586
|
function nextTagId({ $global }) {
|
1703
1587
|
const id = tagIdsByGlobal.get($global) || 0;
|
@@ -1732,8 +1616,134 @@ function hoist(...path) {
|
|
1732
1616
|
}
|
1733
1617
|
|
1734
1618
|
// src/dom/control-flow.ts
|
1619
|
+
function awaitTag(nodeAccessor, renderer) {
|
1620
|
+
const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
|
1621
|
+
const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1622
|
+
return (scope, promise) => {
|
1623
|
+
let tryBranch = scope.___closestBranch;
|
1624
|
+
let awaitBranch = scope[branchAccessor];
|
1625
|
+
const referenceNode = scope[nodeAccessor];
|
1626
|
+
const namespaceNode = (awaitBranch?.___startNode ?? referenceNode).parentNode;
|
1627
|
+
while (tryBranch && !tryBranch["%PlaceholderContent" /* PlaceholderContent */]) {
|
1628
|
+
tryBranch = tryBranch.___parentBranch;
|
1629
|
+
}
|
1630
|
+
const thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1631
|
+
if (scope.___closestBranch?.___destroyed || scope[promiseAccessor] !== thisPromise) {
|
1632
|
+
return;
|
1633
|
+
}
|
1634
|
+
scope[promiseAccessor] = void 0;
|
1635
|
+
const effects = prepareEffects(() => {
|
1636
|
+
if (!awaitBranch || !tryBranch) {
|
1637
|
+
insertBranchBefore(
|
1638
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1639
|
+
scope.$global,
|
1640
|
+
renderer,
|
1641
|
+
scope,
|
1642
|
+
namespaceNode
|
1643
|
+
),
|
1644
|
+
referenceNode.parentNode,
|
1645
|
+
referenceNode
|
1646
|
+
);
|
1647
|
+
referenceNode.remove();
|
1648
|
+
}
|
1649
|
+
renderer.___params?.(awaitBranch, [data2]);
|
1650
|
+
});
|
1651
|
+
if (tryBranch) {
|
1652
|
+
if (!--tryBranch.___pendingAsyncCount) {
|
1653
|
+
const placeholderBranch = tryBranch["#PlaceholderBranch" /* PlaceholderBranch */];
|
1654
|
+
if (placeholderBranch) {
|
1655
|
+
insertBranchBefore(
|
1656
|
+
tryBranch,
|
1657
|
+
placeholderBranch.___startNode.parentNode,
|
1658
|
+
placeholderBranch.___startNode
|
1659
|
+
);
|
1660
|
+
removeAndDestroyBranch(placeholderBranch);
|
1661
|
+
} else {
|
1662
|
+
insertBranchBefore(
|
1663
|
+
tryBranch,
|
1664
|
+
referenceNode.parentNode,
|
1665
|
+
referenceNode
|
1666
|
+
);
|
1667
|
+
}
|
1668
|
+
}
|
1669
|
+
} else {
|
1670
|
+
runEffects(effects);
|
1671
|
+
}
|
1672
|
+
}).catch((error) => {
|
1673
|
+
let tryBranch2 = scope.___closestBranch;
|
1674
|
+
while (tryBranch2 && !tryBranch2["^CatchContent" /* CatchContent */]) {
|
1675
|
+
tryBranch2 = tryBranch2.___parentBranch;
|
1676
|
+
}
|
1677
|
+
if (!tryBranch2) {
|
1678
|
+
setTimeout(() => {
|
1679
|
+
throw error;
|
1680
|
+
});
|
1681
|
+
} else {
|
1682
|
+
setConditionalRenderer(
|
1683
|
+
tryBranch2._,
|
1684
|
+
tryBranch2["*BranchAccessor" /* BranchAccessor */],
|
1685
|
+
tryBranch2["^CatchContent" /* CatchContent */],
|
1686
|
+
createAndSetupBranch
|
1687
|
+
);
|
1688
|
+
tryBranch2["^CatchContent" /* CatchContent */].___params?.(
|
1689
|
+
tryBranch2._["ConditionalScope:" /* ConditionalScope */ + tryBranch2["*BranchAccessor" /* BranchAccessor */]],
|
1690
|
+
[error]
|
1691
|
+
);
|
1692
|
+
}
|
1693
|
+
});
|
1694
|
+
if (tryBranch) {
|
1695
|
+
if (!tryBranch.___pendingAsyncCount) {
|
1696
|
+
tryBranch.___pendingAsyncCount = 0;
|
1697
|
+
requestAnimationFrame(() => {
|
1698
|
+
if (tryBranch.___pendingAsyncCount && !tryBranch.___destroyed) {
|
1699
|
+
const placeholderBranch = tryBranch["#PlaceholderBranch" /* PlaceholderBranch */] = createAndSetupBranch(
|
1700
|
+
scope.$global,
|
1701
|
+
tryBranch["%PlaceholderContent" /* PlaceholderContent */],
|
1702
|
+
tryBranch._,
|
1703
|
+
tryBranch.___startNode.parentNode
|
1704
|
+
);
|
1705
|
+
insertBranchBefore(
|
1706
|
+
placeholderBranch,
|
1707
|
+
tryBranch.___startNode.parentNode,
|
1708
|
+
tryBranch.___startNode
|
1709
|
+
);
|
1710
|
+
tempDetatchBranch(tryBranch);
|
1711
|
+
}
|
1712
|
+
});
|
1713
|
+
}
|
1714
|
+
tryBranch.___pendingAsyncCount++;
|
1715
|
+
} else if (awaitBranch) {
|
1716
|
+
awaitBranch.___startNode.parentNode.insertBefore(
|
1717
|
+
referenceNode,
|
1718
|
+
awaitBranch.___startNode
|
1719
|
+
);
|
1720
|
+
tempDetatchBranch(awaitBranch);
|
1721
|
+
}
|
1722
|
+
};
|
1723
|
+
}
|
1724
|
+
function createTry(nodeAccessor, tryContent) {
|
1725
|
+
const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1726
|
+
return (scope, input) => {
|
1727
|
+
if (!scope[branchAccessor]) {
|
1728
|
+
setConditionalRenderer(
|
1729
|
+
scope,
|
1730
|
+
nodeAccessor,
|
1731
|
+
tryContent,
|
1732
|
+
createAndSetupBranch
|
1733
|
+
);
|
1734
|
+
}
|
1735
|
+
const branch = scope[branchAccessor];
|
1736
|
+
if (branch) {
|
1737
|
+
branch["*BranchAccessor" /* BranchAccessor */] = nodeAccessor;
|
1738
|
+
branch["^CatchContent" /* CatchContent */] = normalizeDynamicRenderer(input.catch);
|
1739
|
+
branch["%PlaceholderContent" /* PlaceholderContent */] = normalizeDynamicRenderer(
|
1740
|
+
input.placeholder
|
1741
|
+
);
|
1742
|
+
}
|
1743
|
+
};
|
1744
|
+
}
|
1735
1745
|
function conditional(nodeAccessor, ...branches) {
|
1736
|
-
const branchAccessor =
|
1746
|
+
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1737
1747
|
return (scope, newBranch) => {
|
1738
1748
|
if (newBranch !== scope[branchAccessor]) {
|
1739
1749
|
setConditionalRenderer(
|
@@ -1749,8 +1759,8 @@ function patchDynamicTag(fn) {
|
|
1749
1759
|
dynamicTag = fn(dynamicTag);
|
1750
1760
|
}
|
1751
1761
|
var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
1752
|
-
const childScopeAccessor =
|
1753
|
-
const rendererAccessor =
|
1762
|
+
const childScopeAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1763
|
+
const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1754
1764
|
return (scope, newRenderer, getInput) => {
|
1755
1765
|
const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1756
1766
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.___id || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
@@ -1776,7 +1786,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1776
1786
|
subscribeToScopeSet(
|
1777
1787
|
content.___owner,
|
1778
1788
|
content.___accessor,
|
1779
|
-
scope[childScopeAccessor][(true ? `#${normalizedRenderer}/0` : 0)
|
1789
|
+
scope[childScopeAccessor]["ConditionalScope:" /* ConditionalScope */ + (true ? `#${normalizedRenderer}/0` : 0)]
|
1780
1790
|
);
|
1781
1791
|
}
|
1782
1792
|
}
|
@@ -1818,9 +1828,9 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1818
1828
|
};
|
1819
1829
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1820
1830
|
const referenceNode = scope[nodeAccessor];
|
1821
|
-
const prevBranch = scope[
|
1831
|
+
const prevBranch = scope["ConditionalScope:" /* ConditionalScope */ + nodeAccessor];
|
1822
1832
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.___startNode || referenceNode).parentNode : referenceNode;
|
1823
|
-
const newBranch = scope[
|
1833
|
+
const newBranch = scope["ConditionalScope:" /* ConditionalScope */ + nodeAccessor] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
|
1824
1834
|
if (referenceNode === parentNode) {
|
1825
1835
|
if (prevBranch) {
|
1826
1836
|
destroyBranch(prevBranch);
|
@@ -1875,13 +1885,13 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1875
1885
|
const params = renderer.___params;
|
1876
1886
|
return (scope, value2) => {
|
1877
1887
|
const referenceNode = scope[nodeAccessor];
|
1878
|
-
const oldMap = scope[
|
1879
|
-
const oldArray = oldMap ? scope[
|
1888
|
+
const oldMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor];
|
1889
|
+
const oldArray = oldMap ? scope["LoopScopeArray:" /* LoopScopeArray */ + nodeAccessor] || [
|
1880
1890
|
...oldMap.values()
|
1881
1891
|
] : [];
|
1882
1892
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].___startNode.parentNode : referenceNode;
|
1883
|
-
const newMap = scope[
|
1884
|
-
const newArray = scope[
|
1893
|
+
const newMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map();
|
1894
|
+
const newArray = scope["LoopScopeArray:" /* LoopScopeArray */ + nodeAccessor] = [];
|
1885
1895
|
forEach(value2, (key, args) => {
|
1886
1896
|
const branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
|
1887
1897
|
params?.(branch, args);
|
@@ -1927,6 +1937,161 @@ function byFirstArg(name) {
|
|
1927
1937
|
return name;
|
1928
1938
|
}
|
1929
1939
|
|
1940
|
+
// src/dom/queue.ts
|
1941
|
+
var pendingRenders = [];
|
1942
|
+
var pendingRendersLookup = /* @__PURE__ */ new Map();
|
1943
|
+
var pendingEffects = [];
|
1944
|
+
var rendering = false;
|
1945
|
+
var scopeKeyOffset = 1e3;
|
1946
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
|
1947
|
+
const key = scopeKey * scopeKeyOffset + signalKey;
|
1948
|
+
const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1949
|
+
if (existingRender) {
|
1950
|
+
existingRender.___value = value2;
|
1951
|
+
} else {
|
1952
|
+
const render = {
|
1953
|
+
___key: key,
|
1954
|
+
___scope: scope,
|
1955
|
+
___signal: signal,
|
1956
|
+
___value: value2
|
1957
|
+
};
|
1958
|
+
let i = pendingRenders.push(render) - 1;
|
1959
|
+
while (i) {
|
1960
|
+
const parentIndex = i - 1 >> 1;
|
1961
|
+
const parent = pendingRenders[parentIndex];
|
1962
|
+
if (key - parent.___key >= 0) break;
|
1963
|
+
pendingRenders[i] = parent;
|
1964
|
+
i = parentIndex;
|
1965
|
+
}
|
1966
|
+
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
1967
|
+
pendingRenders[i] = render;
|
1968
|
+
}
|
1969
|
+
}
|
1970
|
+
function queueEffect(scope, fn) {
|
1971
|
+
pendingEffects.push(fn, scope);
|
1972
|
+
}
|
1973
|
+
function run() {
|
1974
|
+
const effects = pendingEffects;
|
1975
|
+
try {
|
1976
|
+
rendering = true;
|
1977
|
+
runRenders();
|
1978
|
+
} finally {
|
1979
|
+
pendingRenders = [];
|
1980
|
+
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1981
|
+
pendingEffects = [];
|
1982
|
+
rendering = false;
|
1983
|
+
}
|
1984
|
+
runEffects(effects);
|
1985
|
+
}
|
1986
|
+
function prepareEffects(fn) {
|
1987
|
+
const prevRenders = pendingRenders;
|
1988
|
+
const prevRendersLookup = pendingRendersLookup;
|
1989
|
+
const prevEffects = pendingEffects;
|
1990
|
+
const preparedEffects = pendingEffects = [];
|
1991
|
+
pendingRenders = [];
|
1992
|
+
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1993
|
+
try {
|
1994
|
+
rendering = true;
|
1995
|
+
fn();
|
1996
|
+
runRenders();
|
1997
|
+
} finally {
|
1998
|
+
rendering = false;
|
1999
|
+
pendingRenders = prevRenders;
|
2000
|
+
pendingRendersLookup = prevRendersLookup;
|
2001
|
+
pendingEffects = prevEffects;
|
2002
|
+
}
|
2003
|
+
return preparedEffects;
|
2004
|
+
}
|
2005
|
+
function runEffects(effects) {
|
2006
|
+
for (let i = 0, scope; i < effects.length; ) {
|
2007
|
+
effects[i++](
|
2008
|
+
scope = effects[i++],
|
2009
|
+
scope
|
2010
|
+
);
|
2011
|
+
}
|
2012
|
+
}
|
2013
|
+
function runRenders() {
|
2014
|
+
while (pendingRenders.length) {
|
2015
|
+
const render = pendingRenders[0];
|
2016
|
+
const item = pendingRenders.pop();
|
2017
|
+
if (render !== item) {
|
2018
|
+
let i = 0;
|
2019
|
+
const mid = pendingRenders.length >> 1;
|
2020
|
+
const key = (pendingRenders[0] = item).___key;
|
2021
|
+
while (i < mid) {
|
2022
|
+
let bestChild = (i << 1) + 1;
|
2023
|
+
const right = bestChild + 1;
|
2024
|
+
if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
|
2025
|
+
bestChild = right;
|
2026
|
+
}
|
2027
|
+
if (pendingRenders[bestChild].___key - key >= 0) {
|
2028
|
+
break;
|
2029
|
+
} else {
|
2030
|
+
pendingRenders[i] = pendingRenders[bestChild];
|
2031
|
+
i = bestChild;
|
2032
|
+
}
|
2033
|
+
}
|
2034
|
+
pendingRenders[i] = item;
|
2035
|
+
}
|
2036
|
+
if (!render.___scope.___closestBranch?.___destroyed) {
|
2037
|
+
runRender(render);
|
2038
|
+
}
|
2039
|
+
}
|
2040
|
+
finishPendingScopes();
|
2041
|
+
}
|
2042
|
+
var runRender = (render) => render.___signal(render.___scope, render.___value);
|
2043
|
+
var enableCatch = () => {
|
2044
|
+
enableCatch = () => {
|
2045
|
+
};
|
2046
|
+
runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
2047
|
+
try {
|
2048
|
+
runRender2(render);
|
2049
|
+
} catch (error) {
|
2050
|
+
let branch = render.___scope.___closestBranch;
|
2051
|
+
while (branch && !branch["^CatchContent" /* CatchContent */])
|
2052
|
+
branch = branch.___parentBranch;
|
2053
|
+
if (!branch) {
|
2054
|
+
throw error;
|
2055
|
+
} else {
|
2056
|
+
setConditionalRenderer(
|
2057
|
+
branch._,
|
2058
|
+
branch["*BranchAccessor" /* BranchAccessor */],
|
2059
|
+
branch["^CatchContent" /* CatchContent */],
|
2060
|
+
createAndSetupBranch
|
2061
|
+
);
|
2062
|
+
branch["^CatchContent" /* CatchContent */].___params?.(
|
2063
|
+
branch._["ConditionalScope:" /* ConditionalScope */ + branch["*BranchAccessor" /* BranchAccessor */]],
|
2064
|
+
[error]
|
2065
|
+
);
|
2066
|
+
}
|
2067
|
+
}
|
2068
|
+
})(runRender);
|
2069
|
+
};
|
2070
|
+
|
2071
|
+
// src/dom/abort-signal.ts
|
2072
|
+
function resetAbortSignal(scope, id) {
|
2073
|
+
const ctrl = scope.___abortControllers?.[id];
|
2074
|
+
if (ctrl) {
|
2075
|
+
queueEffect(ctrl, abort);
|
2076
|
+
scope.___abortControllers[id] = void 0;
|
2077
|
+
}
|
2078
|
+
}
|
2079
|
+
function getAbortSignal(scope, id) {
|
2080
|
+
if (scope.___closestBranch) {
|
2081
|
+
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
2082
|
+
}
|
2083
|
+
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
2084
|
+
}
|
2085
|
+
function abort(ctrl) {
|
2086
|
+
ctrl.abort();
|
2087
|
+
}
|
2088
|
+
|
2089
|
+
// src/common/compat-meta.ts
|
2090
|
+
var prefix = true ? "$compat_" : "$C_";
|
2091
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
2092
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
2093
|
+
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
2094
|
+
|
1930
2095
|
// src/dom/compat.ts
|
1931
2096
|
var classIdToBranch = /* @__PURE__ */ new Map();
|
1932
2097
|
var compat = {
|