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.mjs
CHANGED
@@ -234,7 +234,7 @@ function init(runtimeId = DEFAULT_RUNTIME_ID) {
|
|
234
234
|
const token = commentText[commentPrefixLen];
|
235
235
|
if (token === "*" /* Node */) {
|
236
236
|
const node = scope[data2] = visit.previousSibling;
|
237
|
-
scope[
|
237
|
+
scope["Getter:" /* Getter */ + data2] = () => node;
|
238
238
|
} else if (token === "$" /* ClosestBranch */) {
|
239
239
|
closestBranchMarkers.set(scopeId, visit);
|
240
240
|
} else if (token === "[" /* BranchStart */) {
|
@@ -379,7 +379,7 @@ function controllable_input_checked(scope, nodeAccessor, checked, checkedChange)
|
|
379
379
|
function controllable_input_checked_effect(scope, nodeAccessor) {
|
380
380
|
const el = scope[nodeAccessor];
|
381
381
|
syncControllable(el, "input", hasCheckboxChanged, () => {
|
382
|
-
const checkedChange = scope[
|
382
|
+
const checkedChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
383
383
|
if (checkedChange) {
|
384
384
|
const newValue = el.checked;
|
385
385
|
el.checked = !newValue;
|
@@ -389,7 +389,7 @@ function controllable_input_checked_effect(scope, nodeAccessor) {
|
|
389
389
|
});
|
390
390
|
}
|
391
391
|
function controllable_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value2) {
|
392
|
-
scope[
|
392
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = checkedValue;
|
393
393
|
attr(scope[nodeAccessor], "value", value2);
|
394
394
|
setCheckboxValue(
|
395
395
|
scope,
|
@@ -402,9 +402,9 @@ function controllable_input_checkedValue(scope, nodeAccessor, checkedValue, chec
|
|
402
402
|
function controllable_input_checkedValue_effect(scope, nodeAccessor) {
|
403
403
|
const el = scope[nodeAccessor];
|
404
404
|
syncControllable(el, "input", hasCheckboxChanged, () => {
|
405
|
-
const checkedValueChange = scope[
|
405
|
+
const checkedValueChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
406
406
|
if (checkedValueChange) {
|
407
|
-
const oldValue = scope[
|
407
|
+
const oldValue = scope["ControlledValue:" /* ControlledValue */ + nodeAccessor];
|
408
408
|
const newValue = Array.isArray(oldValue) ? updateList(oldValue, el.value, el.checked) : el.checked ? el.value : void 0;
|
409
409
|
if (el.name && el.type[0] === "r") {
|
410
410
|
for (const radio of el.getRootNode().querySelectorAll(
|
@@ -425,33 +425,33 @@ function controllable_input_checkedValue_effect(scope, nodeAccessor) {
|
|
425
425
|
function controllable_input_value(scope, nodeAccessor, value2, valueChange) {
|
426
426
|
const el = scope[nodeAccessor];
|
427
427
|
const normalizedValue = normalizeStrProp(value2);
|
428
|
-
scope[
|
428
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = valueChange;
|
429
429
|
if (valueChange) {
|
430
|
-
scope[
|
431
|
-
scope[
|
430
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 0 /* InputChecked */;
|
431
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = value2;
|
432
432
|
if (el.isConnected) {
|
433
433
|
setValueAndUpdateSelection(el, normalizedValue);
|
434
434
|
} else {
|
435
435
|
el.defaultValue = normalizedValue;
|
436
436
|
}
|
437
437
|
} else {
|
438
|
-
scope[
|
438
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
439
439
|
el.defaultValue = normalizedValue;
|
440
440
|
}
|
441
441
|
}
|
442
442
|
function controllable_input_value_effect(scope, nodeAccessor) {
|
443
443
|
const el = scope[nodeAccessor];
|
444
444
|
if (isResuming) {
|
445
|
-
scope[
|
445
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = el.defaultValue;
|
446
446
|
}
|
447
447
|
syncControllable(el, "input", hasValueChanged, (ev) => {
|
448
|
-
const valueChange = scope[
|
448
|
+
const valueChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
449
449
|
if (valueChange) {
|
450
450
|
const newValue = el.value;
|
451
451
|
inputType = ev?.inputType;
|
452
452
|
setValueAndUpdateSelection(
|
453
453
|
el,
|
454
|
-
scope[
|
454
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor]
|
455
455
|
);
|
456
456
|
valueChange(newValue);
|
457
457
|
run();
|
@@ -460,12 +460,12 @@ function controllable_input_value_effect(scope, nodeAccessor) {
|
|
460
460
|
});
|
461
461
|
}
|
462
462
|
function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
463
|
-
scope[
|
463
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = valueChange;
|
464
464
|
if (valueChange) {
|
465
|
-
scope[
|
466
|
-
scope[
|
465
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 3 /* SelectValue */;
|
466
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = value2;
|
467
467
|
} else {
|
468
|
-
scope[
|
468
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
469
469
|
}
|
470
470
|
pendingEffects.unshift(
|
471
471
|
() => setSelectOptions(
|
@@ -479,14 +479,14 @@ function controllable_select_value(scope, nodeAccessor, value2, valueChange) {
|
|
479
479
|
function controllable_select_value_effect(scope, nodeAccessor) {
|
480
480
|
const el = scope[nodeAccessor];
|
481
481
|
const onChange = () => {
|
482
|
-
const valueChange = scope[
|
482
|
+
const valueChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
483
483
|
if (valueChange) {
|
484
484
|
const newValue = Array.isArray(
|
485
|
-
scope[
|
485
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor]
|
486
486
|
) ? Array.from(el.selectedOptions, toValueProp) : el.value;
|
487
487
|
setSelectOptions(
|
488
488
|
el,
|
489
|
-
scope[
|
489
|
+
scope["ControlledValue:" /* ControlledValue */ + nodeAccessor],
|
490
490
|
valueChange
|
491
491
|
);
|
492
492
|
valueChange(newValue);
|
@@ -495,7 +495,7 @@ function controllable_select_value_effect(scope, nodeAccessor) {
|
|
495
495
|
};
|
496
496
|
if (!el._) {
|
497
497
|
new MutationObserver(() => {
|
498
|
-
const value2 = scope[
|
498
|
+
const value2 = scope["ControlledValue:" /* ControlledValue */ + nodeAccessor];
|
499
499
|
if (Array.isArray(value2) ? value2.length !== el.selectedOptions.length || value2.some((value3, i) => value3 != el.selectedOptions[i].value) : el.value != value2) {
|
500
500
|
onChange();
|
501
501
|
}
|
@@ -528,23 +528,23 @@ function setSelectOptions(el, value2, valueChange) {
|
|
528
528
|
}
|
529
529
|
}
|
530
530
|
function controllable_detailsOrDialog_open(scope, nodeAccessor, open, openChange) {
|
531
|
-
scope[
|
531
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = openChange;
|
532
532
|
if (openChange) {
|
533
|
-
scope[
|
533
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 4 /* DetailsOrDialogOpen */;
|
534
534
|
} else {
|
535
|
-
scope[
|
535
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
536
536
|
}
|
537
|
-
scope[nodeAccessor].open = scope[
|
537
|
+
scope[nodeAccessor].open = scope["ControlledValue:" /* ControlledValue */ + nodeAccessor] = normalizeBoolProp(open);
|
538
538
|
}
|
539
539
|
function controllable_detailsOrDialog_open_effect(scope, nodeAccessor) {
|
540
540
|
const el = scope[nodeAccessor];
|
541
|
-
const hasChanged = () => el.open !== scope[
|
541
|
+
const hasChanged = () => el.open !== scope["ControlledValue:" /* ControlledValue */ + nodeAccessor];
|
542
542
|
syncControllable(
|
543
543
|
el,
|
544
544
|
el.tagName === "DIALOG" ? "close" : "toggle",
|
545
545
|
hasChanged,
|
546
546
|
() => {
|
547
|
-
const openChange = scope[
|
547
|
+
const openChange = scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor];
|
548
548
|
if (openChange && hasChanged()) {
|
549
549
|
const newValue = el.open;
|
550
550
|
el.open = !newValue;
|
@@ -569,12 +569,12 @@ function setValueAndUpdateSelection(el, value2) {
|
|
569
569
|
}
|
570
570
|
}
|
571
571
|
function setCheckboxValue(scope, nodeAccessor, type, checked, checkedChange) {
|
572
|
-
scope[
|
572
|
+
scope["ControlledHandler:" /* ControlledHandler */ + nodeAccessor] = checkedChange;
|
573
573
|
if (checkedChange) {
|
574
|
-
scope[
|
574
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = type;
|
575
575
|
scope[nodeAccessor].checked = checked;
|
576
576
|
} else {
|
577
|
-
scope[
|
577
|
+
scope["ControlledType:" /* ControlledType */ + nodeAccessor] = 5 /* None */;
|
578
578
|
scope[nodeAccessor].defaultChecked = checked;
|
579
579
|
}
|
580
580
|
}
|
@@ -786,7 +786,7 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
786
786
|
break;
|
787
787
|
default: {
|
788
788
|
if (isEventHandler(name)) {
|
789
|
-
(events ||= scope[
|
789
|
+
(events ||= scope["EventAttributes:" /* EventAttributes */ + nodeAccessor] = {})[getEventHandlerName(name)] = value2;
|
790
790
|
} else if (!skip?.test(name)) {
|
791
791
|
attr(el, name, value2);
|
792
792
|
}
|
@@ -796,8 +796,8 @@ function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
796
796
|
}
|
797
797
|
function attrsEvents(scope, nodeAccessor) {
|
798
798
|
const el = scope[nodeAccessor];
|
799
|
-
const events = scope[
|
800
|
-
switch (scope[
|
799
|
+
const events = scope["EventAttributes:" /* EventAttributes */ + nodeAccessor];
|
800
|
+
switch (scope["ControlledType:" /* ControlledType */ + nodeAccessor]) {
|
801
801
|
case 0 /* InputChecked */:
|
802
802
|
controllable_input_checked_effect(scope, nodeAccessor);
|
803
803
|
break;
|
@@ -821,7 +821,7 @@ function attrsEvents(scope, nodeAccessor) {
|
|
821
821
|
function html(scope, value2, accessor) {
|
822
822
|
const firstChild = scope[accessor];
|
823
823
|
const parentNode = firstChild.parentNode;
|
824
|
-
const lastChild = scope[
|
824
|
+
const lastChild = scope["DynamicPlaceholderLastChild:" /* DynamicPlaceholderLastChild */ + accessor] || firstChild;
|
825
825
|
const newContent = parseHTML(
|
826
826
|
value2 || value2 === 0 ? value2 + "" : "",
|
827
827
|
parentNode.namespaceURI
|
@@ -830,7 +830,7 @@ function html(scope, value2, accessor) {
|
|
830
830
|
parentNode,
|
831
831
|
firstChild,
|
832
832
|
scope[accessor] = newContent.firstChild || newContent.appendChild(new Text()),
|
833
|
-
scope[
|
833
|
+
scope["DynamicPlaceholderLastChild:" /* DynamicPlaceholderLastChild */ + accessor] = newContent.lastChild
|
834
834
|
);
|
835
835
|
removeChildNodes(firstChild, lastChild);
|
836
836
|
}
|
@@ -868,7 +868,7 @@ function lifecycle(scope, index, thisObj) {
|
|
868
868
|
thisObj.onMount?.();
|
869
869
|
getAbortSignal(
|
870
870
|
scope,
|
871
|
-
"
|
871
|
+
"LifecycleAbortController:" /* LifecycleAbortController */ + index
|
872
872
|
).onabort = () => thisObj.onDestroy?.();
|
873
873
|
}
|
874
874
|
}
|
@@ -943,134 +943,15 @@ function insertBranchBefore(branch, parentNode, nextSibling) {
|
|
943
943
|
branch.___endNode
|
944
944
|
);
|
945
945
|
}
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
|
954
|
-
const key = scopeKey * scopeKeyOffset + signalKey;
|
955
|
-
const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
956
|
-
if (existingRender) {
|
957
|
-
existingRender.___value = value2;
|
958
|
-
} else {
|
959
|
-
const render = {
|
960
|
-
___key: key,
|
961
|
-
___scope: scope,
|
962
|
-
___signal: signal,
|
963
|
-
___value: value2
|
964
|
-
};
|
965
|
-
let i = pendingRenders.push(render) - 1;
|
966
|
-
while (i) {
|
967
|
-
const parentIndex = i - 1 >> 1;
|
968
|
-
const parent = pendingRenders[parentIndex];
|
969
|
-
if (key - parent.___key >= 0) break;
|
970
|
-
pendingRenders[i] = parent;
|
971
|
-
i = parentIndex;
|
972
|
-
}
|
973
|
-
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
974
|
-
pendingRenders[i] = render;
|
975
|
-
}
|
976
|
-
}
|
977
|
-
function queueEffect(scope, fn) {
|
978
|
-
pendingEffects.push(fn, scope);
|
979
|
-
}
|
980
|
-
function run() {
|
981
|
-
const effects = pendingEffects;
|
982
|
-
try {
|
983
|
-
rendering = true;
|
984
|
-
runRenders();
|
985
|
-
} finally {
|
986
|
-
pendingRenders = [];
|
987
|
-
pendingRendersLookup = /* @__PURE__ */ new Map();
|
988
|
-
pendingEffects = [];
|
989
|
-
rendering = false;
|
990
|
-
}
|
991
|
-
runEffects(effects);
|
992
|
-
}
|
993
|
-
function prepareEffects(fn) {
|
994
|
-
const prevRenders = pendingRenders;
|
995
|
-
const prevRendersLookup = pendingRendersLookup;
|
996
|
-
const prevEffects = pendingEffects;
|
997
|
-
const preparedEffects = pendingEffects = [];
|
998
|
-
pendingRenders = [];
|
999
|
-
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1000
|
-
try {
|
1001
|
-
rendering = true;
|
1002
|
-
fn();
|
1003
|
-
runRenders();
|
1004
|
-
} finally {
|
1005
|
-
rendering = false;
|
1006
|
-
pendingRenders = prevRenders;
|
1007
|
-
pendingRendersLookup = prevRendersLookup;
|
1008
|
-
pendingEffects = prevEffects;
|
1009
|
-
}
|
1010
|
-
return preparedEffects;
|
1011
|
-
}
|
1012
|
-
function runEffects(effects) {
|
1013
|
-
for (let i = 0, scope; i < effects.length; ) {
|
1014
|
-
effects[i++](
|
1015
|
-
scope = effects[i++],
|
1016
|
-
scope
|
1017
|
-
);
|
1018
|
-
}
|
1019
|
-
}
|
1020
|
-
function runRenders() {
|
1021
|
-
while (pendingRenders.length) {
|
1022
|
-
const render = pendingRenders[0];
|
1023
|
-
const item = pendingRenders.pop();
|
1024
|
-
if (render !== item) {
|
1025
|
-
let i = 0;
|
1026
|
-
const mid = pendingRenders.length >> 1;
|
1027
|
-
const key = (pendingRenders[0] = item).___key;
|
1028
|
-
while (i < mid) {
|
1029
|
-
let bestChild = (i << 1) + 1;
|
1030
|
-
const right = bestChild + 1;
|
1031
|
-
if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
|
1032
|
-
bestChild = right;
|
1033
|
-
}
|
1034
|
-
if (pendingRenders[bestChild].___key - key >= 0) {
|
1035
|
-
break;
|
1036
|
-
} else {
|
1037
|
-
pendingRenders[i] = pendingRenders[bestChild];
|
1038
|
-
i = bestChild;
|
1039
|
-
}
|
1040
|
-
}
|
1041
|
-
pendingRenders[i] = item;
|
1042
|
-
}
|
1043
|
-
if (!render.___scope.___closestBranch?.___destroyed) {
|
1044
|
-
render.___signal(render.___scope, render.___value);
|
1045
|
-
}
|
1046
|
-
}
|
1047
|
-
finishPendingScopes();
|
1048
|
-
}
|
1049
|
-
|
1050
|
-
// src/dom/abort-signal.ts
|
1051
|
-
function resetAbortSignal(scope, id) {
|
1052
|
-
const ctrl = scope.___abortControllers?.[id];
|
1053
|
-
if (ctrl) {
|
1054
|
-
queueEffect(ctrl, abort);
|
1055
|
-
scope.___abortControllers[id] = void 0;
|
1056
|
-
}
|
1057
|
-
}
|
1058
|
-
function getAbortSignal(scope, id) {
|
1059
|
-
if (scope.___closestBranch) {
|
1060
|
-
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1061
|
-
}
|
1062
|
-
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1063
|
-
}
|
1064
|
-
function abort(ctrl) {
|
1065
|
-
ctrl.abort();
|
946
|
+
function tempDetatchBranch(branch) {
|
947
|
+
insertChildNodes(
|
948
|
+
new DocumentFragment(),
|
949
|
+
null,
|
950
|
+
branch.___startNode,
|
951
|
+
branch.___endNode
|
952
|
+
);
|
1066
953
|
}
|
1067
954
|
|
1068
|
-
// src/common/compat-meta.ts
|
1069
|
-
var prefix = true ? "$compat_" : "$C_";
|
1070
|
-
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
1071
|
-
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
1072
|
-
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
1073
|
-
|
1074
955
|
// src/dom/reconcile.ts
|
1075
956
|
var WRONG_POS = 2147483647;
|
1076
957
|
function reconcile(parent, oldBranches, newBranches, afterReference) {
|
@@ -1255,7 +1136,7 @@ function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
1255
1136
|
if (value2 === 32 /* Get */) {
|
1256
1137
|
const node = walker.currentNode;
|
1257
1138
|
scope[true ? getDebugKey(currentScopeIndex, walker.currentNode) : currentScopeIndex] = node;
|
1258
|
-
scope[(true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++)
|
1139
|
+
scope["Getter:" /* Getter */ + (true ? getDebugKey(currentScopeIndex++, walker.currentNode) : currentScopeIndex++)] = () => node;
|
1259
1140
|
} else if (value2 === 37 /* Replace */ || value2 === 49 /* DynamicTagWithVar */) {
|
1260
1141
|
walker.currentNode.replaceWith(
|
1261
1142
|
walker.currentNode = scope[true ? getDebugKey(currentScopeIndex++, "#text") : currentScopeIndex++] = new Text()
|
@@ -1468,7 +1349,7 @@ function state(valueAccessor, fn) {
|
|
1468
1349
|
valueAccessor.lastIndexOf("/")
|
1469
1350
|
);
|
1470
1351
|
}
|
1471
|
-
const valueChangeAccessor =
|
1352
|
+
const valueChangeAccessor = "@TagVariableChange" /* TagVariableChange */ + valueAccessor;
|
1472
1353
|
const update = (scope, value2) => {
|
1473
1354
|
if (scope[valueAccessor] !== value2) {
|
1474
1355
|
scope[valueAccessor] = value2;
|
@@ -1519,8 +1400,8 @@ function intersection(id, fn, defaultPending = 1, scopeIdAccessor = /* @__KEY__
|
|
1519
1400
|
}
|
1520
1401
|
function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
1521
1402
|
const childSignal = closure(valueAccessor, fn);
|
1522
|
-
const loopScopeAccessor =
|
1523
|
-
const loopScopeMapAccessor =
|
1403
|
+
const loopScopeAccessor = "LoopScopeArray:" /* LoopScopeArray */ + ownerLoopNodeAccessor;
|
1404
|
+
const loopScopeMapAccessor = "LoopScopeMap:" /* LoopScopeMap */ + ownerLoopNodeAccessor;
|
1524
1405
|
const ownerSignal = (ownerScope) => {
|
1525
1406
|
const scopes = ownerScope[loopScopeAccessor] || ownerScope[loopScopeMapAccessor]?.values() || [];
|
1526
1407
|
const [firstScope] = scopes;
|
@@ -1545,8 +1426,8 @@ function loopClosure(valueAccessor, ownerLoopNodeAccessor, fn) {
|
|
1545
1426
|
}
|
1546
1427
|
function conditionalClosure(valueAccessor, ownerConditionalNodeAccessor, branch, fn) {
|
1547
1428
|
const childSignal = closure(valueAccessor, fn);
|
1548
|
-
const scopeAccessor =
|
1549
|
-
const branchAccessor =
|
1429
|
+
const scopeAccessor = "ConditionalScope:" /* ConditionalScope */ + ownerConditionalNodeAccessor;
|
1430
|
+
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + ownerConditionalNodeAccessor;
|
1550
1431
|
const ownerSignal = (scope) => {
|
1551
1432
|
const ifScope = scope[scopeAccessor];
|
1552
1433
|
if (ifScope && !ifScope.___pending && scope[branchAccessor] === branch) {
|
@@ -1596,8 +1477,8 @@ function dynamicClosureRead(valueAccessor, fn, getOwnerScope) {
|
|
1596
1477
|
scope
|
1597
1478
|
);
|
1598
1479
|
};
|
1599
|
-
closureSignal.___scopeInstancesAccessor =
|
1600
|
-
closureSignal.___signalIndexAccessor =
|
1480
|
+
closureSignal.___scopeInstancesAccessor = "ClosureScopes:" /* ClosureScopes */ + valueAccessor;
|
1481
|
+
closureSignal.___signalIndexAccessor = "ClosureSignalIndex:" /* ClosureSignalIndex */ + valueAccessor;
|
1601
1482
|
return closureSignal;
|
1602
1483
|
}
|
1603
1484
|
function closure(valueAccessor, fn, getOwnerScope) {
|
@@ -1606,13 +1487,13 @@ function closure(valueAccessor, fn, getOwnerScope) {
|
|
1606
1487
|
};
|
1607
1488
|
}
|
1608
1489
|
function setTagVar(scope, childAccessor, tagVarSignal2) {
|
1609
|
-
scope[childAccessor]["/" /* TagVariable */] = (value2) => tagVarSignal2(scope, value2);
|
1490
|
+
scope[childAccessor]["/TagVariable" /* TagVariable */] = (value2) => tagVarSignal2(scope, value2);
|
1610
1491
|
}
|
1611
|
-
var tagVarSignal = (scope, value2) => scope["/" /* TagVariable */]?.(value2);
|
1492
|
+
var tagVarSignal = (scope, value2) => scope["/TagVariable" /* TagVariable */]?.(value2);
|
1612
1493
|
function setTagVarChange(scope, changeHandler) {
|
1613
|
-
scope["@" /* TagVariableChange */] = changeHandler;
|
1494
|
+
scope["@TagVariableChange" /* TagVariableChange */] = changeHandler;
|
1614
1495
|
}
|
1615
|
-
var tagVarSignalChange = (scope, value2) => scope["@" /* TagVariableChange */]?.(value2);
|
1496
|
+
var tagVarSignalChange = (scope, value2) => scope["@TagVariableChange" /* TagVariableChange */]?.(value2);
|
1616
1497
|
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1617
1498
|
function nextTagId({ $global }) {
|
1618
1499
|
const id = tagIdsByGlobal.get($global) || 0;
|
@@ -1647,8 +1528,134 @@ function hoist(...path) {
|
|
1647
1528
|
}
|
1648
1529
|
|
1649
1530
|
// src/dom/control-flow.ts
|
1531
|
+
function awaitTag(nodeAccessor, renderer) {
|
1532
|
+
const promiseAccessor = "Promise:" /* Promise */ + nodeAccessor;
|
1533
|
+
const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1534
|
+
return (scope, promise) => {
|
1535
|
+
let tryBranch = scope.___closestBranch;
|
1536
|
+
let awaitBranch = scope[branchAccessor];
|
1537
|
+
const referenceNode = scope[nodeAccessor];
|
1538
|
+
const namespaceNode = (awaitBranch?.___startNode ?? referenceNode).parentNode;
|
1539
|
+
while (tryBranch && !tryBranch["%PlaceholderContent" /* PlaceholderContent */]) {
|
1540
|
+
tryBranch = tryBranch.___parentBranch;
|
1541
|
+
}
|
1542
|
+
const thisPromise = scope[promiseAccessor] = promise.then((data2) => {
|
1543
|
+
if (scope.___closestBranch?.___destroyed || scope[promiseAccessor] !== thisPromise) {
|
1544
|
+
return;
|
1545
|
+
}
|
1546
|
+
scope[promiseAccessor] = void 0;
|
1547
|
+
const effects = prepareEffects(() => {
|
1548
|
+
if (!awaitBranch || !tryBranch) {
|
1549
|
+
insertBranchBefore(
|
1550
|
+
awaitBranch ??= scope[branchAccessor] = createAndSetupBranch(
|
1551
|
+
scope.$global,
|
1552
|
+
renderer,
|
1553
|
+
scope,
|
1554
|
+
namespaceNode
|
1555
|
+
),
|
1556
|
+
referenceNode.parentNode,
|
1557
|
+
referenceNode
|
1558
|
+
);
|
1559
|
+
referenceNode.remove();
|
1560
|
+
}
|
1561
|
+
renderer.___params?.(awaitBranch, [data2]);
|
1562
|
+
});
|
1563
|
+
if (tryBranch) {
|
1564
|
+
if (!--tryBranch.___pendingAsyncCount) {
|
1565
|
+
const placeholderBranch = tryBranch["#PlaceholderBranch" /* PlaceholderBranch */];
|
1566
|
+
if (placeholderBranch) {
|
1567
|
+
insertBranchBefore(
|
1568
|
+
tryBranch,
|
1569
|
+
placeholderBranch.___startNode.parentNode,
|
1570
|
+
placeholderBranch.___startNode
|
1571
|
+
);
|
1572
|
+
removeAndDestroyBranch(placeholderBranch);
|
1573
|
+
} else {
|
1574
|
+
insertBranchBefore(
|
1575
|
+
tryBranch,
|
1576
|
+
referenceNode.parentNode,
|
1577
|
+
referenceNode
|
1578
|
+
);
|
1579
|
+
}
|
1580
|
+
}
|
1581
|
+
} else {
|
1582
|
+
runEffects(effects);
|
1583
|
+
}
|
1584
|
+
}).catch((error) => {
|
1585
|
+
let tryBranch2 = scope.___closestBranch;
|
1586
|
+
while (tryBranch2 && !tryBranch2["^CatchContent" /* CatchContent */]) {
|
1587
|
+
tryBranch2 = tryBranch2.___parentBranch;
|
1588
|
+
}
|
1589
|
+
if (!tryBranch2) {
|
1590
|
+
setTimeout(() => {
|
1591
|
+
throw error;
|
1592
|
+
});
|
1593
|
+
} else {
|
1594
|
+
setConditionalRenderer(
|
1595
|
+
tryBranch2._,
|
1596
|
+
tryBranch2["*BranchAccessor" /* BranchAccessor */],
|
1597
|
+
tryBranch2["^CatchContent" /* CatchContent */],
|
1598
|
+
createAndSetupBranch
|
1599
|
+
);
|
1600
|
+
tryBranch2["^CatchContent" /* CatchContent */].___params?.(
|
1601
|
+
tryBranch2._["ConditionalScope:" /* ConditionalScope */ + tryBranch2["*BranchAccessor" /* BranchAccessor */]],
|
1602
|
+
[error]
|
1603
|
+
);
|
1604
|
+
}
|
1605
|
+
});
|
1606
|
+
if (tryBranch) {
|
1607
|
+
if (!tryBranch.___pendingAsyncCount) {
|
1608
|
+
tryBranch.___pendingAsyncCount = 0;
|
1609
|
+
requestAnimationFrame(() => {
|
1610
|
+
if (tryBranch.___pendingAsyncCount && !tryBranch.___destroyed) {
|
1611
|
+
const placeholderBranch = tryBranch["#PlaceholderBranch" /* PlaceholderBranch */] = createAndSetupBranch(
|
1612
|
+
scope.$global,
|
1613
|
+
tryBranch["%PlaceholderContent" /* PlaceholderContent */],
|
1614
|
+
tryBranch._,
|
1615
|
+
tryBranch.___startNode.parentNode
|
1616
|
+
);
|
1617
|
+
insertBranchBefore(
|
1618
|
+
placeholderBranch,
|
1619
|
+
tryBranch.___startNode.parentNode,
|
1620
|
+
tryBranch.___startNode
|
1621
|
+
);
|
1622
|
+
tempDetatchBranch(tryBranch);
|
1623
|
+
}
|
1624
|
+
});
|
1625
|
+
}
|
1626
|
+
tryBranch.___pendingAsyncCount++;
|
1627
|
+
} else if (awaitBranch) {
|
1628
|
+
awaitBranch.___startNode.parentNode.insertBefore(
|
1629
|
+
referenceNode,
|
1630
|
+
awaitBranch.___startNode
|
1631
|
+
);
|
1632
|
+
tempDetatchBranch(awaitBranch);
|
1633
|
+
}
|
1634
|
+
};
|
1635
|
+
}
|
1636
|
+
function createTry(nodeAccessor, tryContent) {
|
1637
|
+
const branchAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1638
|
+
return (scope, input) => {
|
1639
|
+
if (!scope[branchAccessor]) {
|
1640
|
+
setConditionalRenderer(
|
1641
|
+
scope,
|
1642
|
+
nodeAccessor,
|
1643
|
+
tryContent,
|
1644
|
+
createAndSetupBranch
|
1645
|
+
);
|
1646
|
+
}
|
1647
|
+
const branch = scope[branchAccessor];
|
1648
|
+
if (branch) {
|
1649
|
+
branch["*BranchAccessor" /* BranchAccessor */] = nodeAccessor;
|
1650
|
+
branch["^CatchContent" /* CatchContent */] = normalizeDynamicRenderer(input.catch);
|
1651
|
+
branch["%PlaceholderContent" /* PlaceholderContent */] = normalizeDynamicRenderer(
|
1652
|
+
input.placeholder
|
1653
|
+
);
|
1654
|
+
}
|
1655
|
+
};
|
1656
|
+
}
|
1650
1657
|
function conditional(nodeAccessor, ...branches) {
|
1651
|
-
const branchAccessor =
|
1658
|
+
const branchAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1652
1659
|
return (scope, newBranch) => {
|
1653
1660
|
if (newBranch !== scope[branchAccessor]) {
|
1654
1661
|
setConditionalRenderer(
|
@@ -1664,8 +1671,8 @@ function patchDynamicTag(fn) {
|
|
1664
1671
|
dynamicTag = fn(dynamicTag);
|
1665
1672
|
}
|
1666
1673
|
var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, inputIsArgs) {
|
1667
|
-
const childScopeAccessor =
|
1668
|
-
const rendererAccessor =
|
1674
|
+
const childScopeAccessor = "ConditionalScope:" /* ConditionalScope */ + nodeAccessor;
|
1675
|
+
const rendererAccessor = "ConditionalRenderer:" /* ConditionalRenderer */ + nodeAccessor;
|
1669
1676
|
return (scope, newRenderer, getInput) => {
|
1670
1677
|
const normalizedRenderer = normalizeDynamicRenderer(newRenderer);
|
1671
1678
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = normalizedRenderer?.___id || normalizedRenderer) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
@@ -1691,7 +1698,7 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1691
1698
|
subscribeToScopeSet(
|
1692
1699
|
content.___owner,
|
1693
1700
|
content.___accessor,
|
1694
|
-
scope[childScopeAccessor][(true ? `#${normalizedRenderer}/0` : 0)
|
1701
|
+
scope[childScopeAccessor]["ConditionalScope:" /* ConditionalScope */ + (true ? `#${normalizedRenderer}/0` : 0)]
|
1695
1702
|
);
|
1696
1703
|
}
|
1697
1704
|
}
|
@@ -1733,9 +1740,9 @@ var dynamicTag = function dynamicTag2(nodeAccessor, getContent, getTagVar, input
|
|
1733
1740
|
};
|
1734
1741
|
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1735
1742
|
const referenceNode = scope[nodeAccessor];
|
1736
|
-
const prevBranch = scope[
|
1743
|
+
const prevBranch = scope["ConditionalScope:" /* ConditionalScope */ + nodeAccessor];
|
1737
1744
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? (prevBranch?.___startNode || referenceNode).parentNode : referenceNode;
|
1738
|
-
const newBranch = scope[
|
1745
|
+
const newBranch = scope["ConditionalScope:" /* ConditionalScope */ + nodeAccessor] = newRenderer && createBranch2(scope.$global, newRenderer, scope, parentNode);
|
1739
1746
|
if (referenceNode === parentNode) {
|
1740
1747
|
if (prevBranch) {
|
1741
1748
|
destroyBranch(prevBranch);
|
@@ -1790,13 +1797,13 @@ function loop(nodeAccessor, renderer, forEach) {
|
|
1790
1797
|
const params = renderer.___params;
|
1791
1798
|
return (scope, value2) => {
|
1792
1799
|
const referenceNode = scope[nodeAccessor];
|
1793
|
-
const oldMap = scope[
|
1794
|
-
const oldArray = oldMap ? scope[
|
1800
|
+
const oldMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor];
|
1801
|
+
const oldArray = oldMap ? scope["LoopScopeArray:" /* LoopScopeArray */ + nodeAccessor] || [
|
1795
1802
|
...oldMap.values()
|
1796
1803
|
] : [];
|
1797
1804
|
const parentNode = referenceNode.nodeType > 1 /* Element */ ? referenceNode.parentNode || oldArray[0].___startNode.parentNode : referenceNode;
|
1798
|
-
const newMap = scope[
|
1799
|
-
const newArray = scope[
|
1805
|
+
const newMap = scope["LoopScopeMap:" /* LoopScopeMap */ + nodeAccessor] = /* @__PURE__ */ new Map();
|
1806
|
+
const newArray = scope["LoopScopeArray:" /* LoopScopeArray */ + nodeAccessor] = [];
|
1800
1807
|
forEach(value2, (key, args) => {
|
1801
1808
|
const branch = oldMap?.get(key) || createAndSetupBranch(scope.$global, renderer, scope, parentNode);
|
1802
1809
|
params?.(branch, args);
|
@@ -1842,6 +1849,161 @@ function byFirstArg(name) {
|
|
1842
1849
|
return name;
|
1843
1850
|
}
|
1844
1851
|
|
1852
|
+
// src/dom/queue.ts
|
1853
|
+
var pendingRenders = [];
|
1854
|
+
var pendingRendersLookup = /* @__PURE__ */ new Map();
|
1855
|
+
var pendingEffects = [];
|
1856
|
+
var rendering = false;
|
1857
|
+
var scopeKeyOffset = 1e3;
|
1858
|
+
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.___id) {
|
1859
|
+
const key = scopeKey * scopeKeyOffset + signalKey;
|
1860
|
+
const existingRender = signalKey >= 0 && pendingRendersLookup.get(key);
|
1861
|
+
if (existingRender) {
|
1862
|
+
existingRender.___value = value2;
|
1863
|
+
} else {
|
1864
|
+
const render = {
|
1865
|
+
___key: key,
|
1866
|
+
___scope: scope,
|
1867
|
+
___signal: signal,
|
1868
|
+
___value: value2
|
1869
|
+
};
|
1870
|
+
let i = pendingRenders.push(render) - 1;
|
1871
|
+
while (i) {
|
1872
|
+
const parentIndex = i - 1 >> 1;
|
1873
|
+
const parent = pendingRenders[parentIndex];
|
1874
|
+
if (key - parent.___key >= 0) break;
|
1875
|
+
pendingRenders[i] = parent;
|
1876
|
+
i = parentIndex;
|
1877
|
+
}
|
1878
|
+
signalKey >= 0 && pendingRendersLookup.set(key, render);
|
1879
|
+
pendingRenders[i] = render;
|
1880
|
+
}
|
1881
|
+
}
|
1882
|
+
function queueEffect(scope, fn) {
|
1883
|
+
pendingEffects.push(fn, scope);
|
1884
|
+
}
|
1885
|
+
function run() {
|
1886
|
+
const effects = pendingEffects;
|
1887
|
+
try {
|
1888
|
+
rendering = true;
|
1889
|
+
runRenders();
|
1890
|
+
} finally {
|
1891
|
+
pendingRenders = [];
|
1892
|
+
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1893
|
+
pendingEffects = [];
|
1894
|
+
rendering = false;
|
1895
|
+
}
|
1896
|
+
runEffects(effects);
|
1897
|
+
}
|
1898
|
+
function prepareEffects(fn) {
|
1899
|
+
const prevRenders = pendingRenders;
|
1900
|
+
const prevRendersLookup = pendingRendersLookup;
|
1901
|
+
const prevEffects = pendingEffects;
|
1902
|
+
const preparedEffects = pendingEffects = [];
|
1903
|
+
pendingRenders = [];
|
1904
|
+
pendingRendersLookup = /* @__PURE__ */ new Map();
|
1905
|
+
try {
|
1906
|
+
rendering = true;
|
1907
|
+
fn();
|
1908
|
+
runRenders();
|
1909
|
+
} finally {
|
1910
|
+
rendering = false;
|
1911
|
+
pendingRenders = prevRenders;
|
1912
|
+
pendingRendersLookup = prevRendersLookup;
|
1913
|
+
pendingEffects = prevEffects;
|
1914
|
+
}
|
1915
|
+
return preparedEffects;
|
1916
|
+
}
|
1917
|
+
function runEffects(effects) {
|
1918
|
+
for (let i = 0, scope; i < effects.length; ) {
|
1919
|
+
effects[i++](
|
1920
|
+
scope = effects[i++],
|
1921
|
+
scope
|
1922
|
+
);
|
1923
|
+
}
|
1924
|
+
}
|
1925
|
+
function runRenders() {
|
1926
|
+
while (pendingRenders.length) {
|
1927
|
+
const render = pendingRenders[0];
|
1928
|
+
const item = pendingRenders.pop();
|
1929
|
+
if (render !== item) {
|
1930
|
+
let i = 0;
|
1931
|
+
const mid = pendingRenders.length >> 1;
|
1932
|
+
const key = (pendingRenders[0] = item).___key;
|
1933
|
+
while (i < mid) {
|
1934
|
+
let bestChild = (i << 1) + 1;
|
1935
|
+
const right = bestChild + 1;
|
1936
|
+
if (right < pendingRenders.length && pendingRenders[right].___key - pendingRenders[bestChild].___key < 0) {
|
1937
|
+
bestChild = right;
|
1938
|
+
}
|
1939
|
+
if (pendingRenders[bestChild].___key - key >= 0) {
|
1940
|
+
break;
|
1941
|
+
} else {
|
1942
|
+
pendingRenders[i] = pendingRenders[bestChild];
|
1943
|
+
i = bestChild;
|
1944
|
+
}
|
1945
|
+
}
|
1946
|
+
pendingRenders[i] = item;
|
1947
|
+
}
|
1948
|
+
if (!render.___scope.___closestBranch?.___destroyed) {
|
1949
|
+
runRender(render);
|
1950
|
+
}
|
1951
|
+
}
|
1952
|
+
finishPendingScopes();
|
1953
|
+
}
|
1954
|
+
var runRender = (render) => render.___signal(render.___scope, render.___value);
|
1955
|
+
var enableCatch = () => {
|
1956
|
+
enableCatch = () => {
|
1957
|
+
};
|
1958
|
+
runRender = /* @__PURE__ */ ((runRender2) => (render) => {
|
1959
|
+
try {
|
1960
|
+
runRender2(render);
|
1961
|
+
} catch (error) {
|
1962
|
+
let branch = render.___scope.___closestBranch;
|
1963
|
+
while (branch && !branch["^CatchContent" /* CatchContent */])
|
1964
|
+
branch = branch.___parentBranch;
|
1965
|
+
if (!branch) {
|
1966
|
+
throw error;
|
1967
|
+
} else {
|
1968
|
+
setConditionalRenderer(
|
1969
|
+
branch._,
|
1970
|
+
branch["*BranchAccessor" /* BranchAccessor */],
|
1971
|
+
branch["^CatchContent" /* CatchContent */],
|
1972
|
+
createAndSetupBranch
|
1973
|
+
);
|
1974
|
+
branch["^CatchContent" /* CatchContent */].___params?.(
|
1975
|
+
branch._["ConditionalScope:" /* ConditionalScope */ + branch["*BranchAccessor" /* BranchAccessor */]],
|
1976
|
+
[error]
|
1977
|
+
);
|
1978
|
+
}
|
1979
|
+
}
|
1980
|
+
})(runRender);
|
1981
|
+
};
|
1982
|
+
|
1983
|
+
// src/dom/abort-signal.ts
|
1984
|
+
function resetAbortSignal(scope, id) {
|
1985
|
+
const ctrl = scope.___abortControllers?.[id];
|
1986
|
+
if (ctrl) {
|
1987
|
+
queueEffect(ctrl, abort);
|
1988
|
+
scope.___abortControllers[id] = void 0;
|
1989
|
+
}
|
1990
|
+
}
|
1991
|
+
function getAbortSignal(scope, id) {
|
1992
|
+
if (scope.___closestBranch) {
|
1993
|
+
(scope.___closestBranch.___abortScopes ||= /* @__PURE__ */ new Set()).add(scope);
|
1994
|
+
}
|
1995
|
+
return ((scope.___abortControllers ||= {})[id] ||= new AbortController()).signal;
|
1996
|
+
}
|
1997
|
+
function abort(ctrl) {
|
1998
|
+
ctrl.abort();
|
1999
|
+
}
|
2000
|
+
|
2001
|
+
// src/common/compat-meta.ts
|
2002
|
+
var prefix = true ? "$compat_" : "$C_";
|
2003
|
+
var RENDERER_REGISTER_ID = prefix + (true ? "renderer" : "r");
|
2004
|
+
var SET_SCOPE_REGISTER_ID = prefix + (true ? "setScope" : "s");
|
2005
|
+
var RENDER_BODY_ID = prefix + (true ? "renderBody" : "b");
|
2006
|
+
|
1845
2007
|
// src/dom/compat.ts
|
1846
2008
|
var classIdToBranch = /* @__PURE__ */ new Map();
|
1847
2009
|
var compat = {
|
@@ -2024,6 +2186,7 @@ export {
|
|
2024
2186
|
attrTags,
|
2025
2187
|
attrs,
|
2026
2188
|
attrsEvents,
|
2189
|
+
awaitTag,
|
2027
2190
|
classAttr,
|
2028
2191
|
compat,
|
2029
2192
|
conditional,
|
@@ -2043,11 +2206,13 @@ export {
|
|
2043
2206
|
createContent,
|
2044
2207
|
createRenderer,
|
2045
2208
|
createTemplate,
|
2209
|
+
createTry,
|
2046
2210
|
data,
|
2047
2211
|
dynamicClosure,
|
2048
2212
|
dynamicClosureRead,
|
2049
2213
|
dynamicTag,
|
2050
2214
|
effect,
|
2215
|
+
enableCatch,
|
2051
2216
|
forIn,
|
2052
2217
|
forOf,
|
2053
2218
|
forTo,
|