marko 6.1.11 → 6.1.13
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 +2 -2
- package/dist/common/accessor.debug.d.ts +2 -2
- package/dist/common/errors.d.ts +2 -2
- package/dist/common/types.d.ts +2 -2
- package/dist/debug/dom.js +72 -49
- package/dist/debug/dom.mjs +72 -49
- package/dist/debug/html.js +22 -4
- package/dist/debug/html.mjs +22 -4
- package/dist/dom/queue.d.ts +2 -2
- package/dist/dom/scope.d.ts +3 -0
- package/dist/dom.d.ts +2 -1
- package/dist/dom.js +51 -39
- package/dist/dom.mjs +51 -39
- package/dist/html/writer.d.ts +1 -1
- package/dist/translator/index.js +30 -9
- package/package.json +1 -1
package/dist/dom.js
CHANGED
|
@@ -4,8 +4,8 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
4
4
|
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
5
|
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
6
|
return str;
|
|
7
|
-
}, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), defaultDelegator = /* @__PURE__ */ createDelegator(), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
8
|
-
scope.
|
|
7
|
+
}, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), defaultDelegator = /* @__PURE__ */ createDelegator(), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
8
|
+
scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
|
|
9
9
|
}, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), walker = /* @__PURE__ */ document.createTreeWalker(document), walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
10
10
|
let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
|
|
11
11
|
for (; currentWalkIndex < walkCodes.length;) if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32) {
|
|
@@ -49,7 +49,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
49
49
|
};
|
|
50
50
|
}, _for_of = /* @__PURE__ */ loop(([all, by = bySecondArg], cb) => {
|
|
51
51
|
typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
52
|
-
}), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))),
|
|
52
|
+
}), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))), rendering, runId = 2, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingRenders = [], scopeKeyOffset = 1e3, runEffects = ((effects) => {
|
|
53
53
|
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
54
54
|
}), runRender = (render) => render.c(render.b, render.d), catchEnabled, classIdToBranch = /* @__PURE__ */ new Map(), scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
|
|
55
55
|
let render = self[$global.runtimeId]?.[$global.renderId], scopes = render && scopesByRender.get(render);
|
|
@@ -119,9 +119,6 @@ function* attrTagIterator() {
|
|
|
119
119
|
yield this, yield* this[rest];
|
|
120
120
|
}
|
|
121
121
|
function _assert_hoist(value) {}
|
|
122
|
-
function _assert_init(scope, accessor) {
|
|
123
|
-
return scope[accessor];
|
|
124
|
-
}
|
|
125
122
|
//#endregion
|
|
126
123
|
//#region src/common/for.ts
|
|
127
124
|
function forIn(obj, cb) {
|
|
@@ -216,11 +213,26 @@ function parseHTML(html, ns) {
|
|
|
216
213
|
function createScope($global, closestBranch) {
|
|
217
214
|
let scope = {
|
|
218
215
|
L: nextScopeId++,
|
|
219
|
-
H:
|
|
216
|
+
H: runId,
|
|
220
217
|
F: closestBranch,
|
|
221
218
|
$: $global
|
|
222
219
|
};
|
|
223
|
-
return
|
|
220
|
+
return collectingScopes?.push(scope), scope;
|
|
221
|
+
}
|
|
222
|
+
function syncGen(scope) {
|
|
223
|
+
scope.H = runId;
|
|
224
|
+
}
|
|
225
|
+
function _assert_init(scope, accessor) {
|
|
226
|
+
return scope[accessor];
|
|
227
|
+
}
|
|
228
|
+
function collectScopes(fn) {
|
|
229
|
+
let prev = collectingScopes;
|
|
230
|
+
collectingScopes = [];
|
|
231
|
+
try {
|
|
232
|
+
return fn(), collectingScopes;
|
|
233
|
+
} finally {
|
|
234
|
+
collectingScopes = prev;
|
|
235
|
+
}
|
|
224
236
|
}
|
|
225
237
|
function skipScope() {
|
|
226
238
|
return nextScopeId++;
|
|
@@ -234,7 +246,7 @@ function destroyBranch(branch) {
|
|
|
234
246
|
branch.N?.D?.delete(branch), destroyNestedScopes(branch);
|
|
235
247
|
}
|
|
236
248
|
function destroyScope(scope) {
|
|
237
|
-
scope.
|
|
249
|
+
scope.H && (destroyNestedScopes(scope), resetControllers(scope));
|
|
238
250
|
}
|
|
239
251
|
function resetControllers(scope) {
|
|
240
252
|
for (let id in scope.A) $signalReset(scope, id);
|
|
@@ -266,7 +278,7 @@ function triggerMacroTask() {
|
|
|
266
278
|
//#region src/dom/signals.ts
|
|
267
279
|
function _let(id, fn) {
|
|
268
280
|
let valueAccessor = decodeAccessor(id);
|
|
269
|
-
return (scope, value) => (rendering ? scope.H && (scope[valueAccessor] = value, fn?.(scope)) : (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn) && (schedule(), queueRender(scope, fn, id)), value);
|
|
281
|
+
return (scope, value) => (rendering ? scope.H === runId && (scope[valueAccessor] = value, fn?.(scope)) : (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn) && (schedule(), queueRender(scope, fn, id)), value);
|
|
270
282
|
}
|
|
271
283
|
function _let_change(id, fn) {
|
|
272
284
|
let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor, base = _let(id, fn);
|
|
@@ -279,7 +291,7 @@ function _const(valueAccessor, fn) {
|
|
|
279
291
|
}
|
|
280
292
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L") {
|
|
281
293
|
return scopeIdAccessor !== "L" && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
|
|
282
|
-
scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
294
|
+
scope.H === runId ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
283
295
|
};
|
|
284
296
|
}
|
|
285
297
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
@@ -287,7 +299,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
287
299
|
let scopeAccessor = "A" + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
|
|
288
300
|
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
289
301
|
scopes.length && queueRender(ownerScope, () => {
|
|
290
|
-
for (let scope of scopes)
|
|
302
|
+
for (let scope of scopes) scope.H > 0 && scope.H < runId && fn(scope);
|
|
291
303
|
}, -1, 0, scopes[0].L);
|
|
292
304
|
};
|
|
293
305
|
return ownerSignal._ = fn, ownerSignal;
|
|
@@ -296,7 +308,7 @@ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
|
296
308
|
ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
|
|
297
309
|
let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
298
310
|
let ifScope = scope[scopeAccessor];
|
|
299
|
-
ifScope &&
|
|
311
|
+
ifScope && ifScope.H > 0 && ifScope.H < runId && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
|
|
300
312
|
};
|
|
301
313
|
return ownerSignal._ = fn, ownerSignal;
|
|
302
314
|
}
|
|
@@ -308,7 +320,7 @@ function _closure(...closureSignals) {
|
|
|
308
320
|
let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
|
|
309
321
|
for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
|
|
310
322
|
return (scope) => {
|
|
311
|
-
if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H
|
|
323
|
+
if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H > 0 && childScope.H < runId && queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
|
|
312
324
|
};
|
|
313
325
|
}
|
|
314
326
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
@@ -440,7 +452,7 @@ function init(runtimeId = "M") {
|
|
|
440
452
|
let render = curRenders[renderId] = renders[renderId] || renders(renderId), walk = render.w, scopeLookup = {}, getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { L: +id }) : initGlobal()), initGlobal = () => scopeLookup[0] ||= {
|
|
441
453
|
runtimeId,
|
|
442
454
|
renderId
|
|
443
|
-
}, initScope = (scope) => (scope.$ = initGlobal(), branchesEnabled && scope.G && (scope.F = getScope(scope.G)), scope), applyScopes = (partials) => {
|
|
455
|
+
}, initScope = (scope) => (scope.H = 1, scope.$ = initGlobal(), branchesEnabled && scope.G && (scope.F = getScope(scope.G)), scope), applyScopes = (partials) => {
|
|
444
456
|
let scopeId = partials[0];
|
|
445
457
|
for (let i = 1; i < partials.length; i++) {
|
|
446
458
|
let partial = partials[i];
|
|
@@ -527,13 +539,13 @@ function _el(id, accessor) {
|
|
|
527
539
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
528
540
|
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
529
541
|
if (el.defaultChecked !== normalizedChecked) {
|
|
530
|
-
let restoreValue = scope.H
|
|
542
|
+
let restoreValue = scope.H < runId ? el.checked : normalizedChecked;
|
|
531
543
|
el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
|
|
532
544
|
}
|
|
533
545
|
}
|
|
534
546
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
535
547
|
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
536
|
-
scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange &&
|
|
548
|
+
scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange && scope.H < runId ? el.checked = normalizedChecked : _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
|
|
537
549
|
}
|
|
538
550
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
539
551
|
let el = scope[nodeAccessor];
|
|
@@ -551,7 +563,7 @@ function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, val
|
|
|
551
563
|
}
|
|
552
564
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
553
565
|
let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedCheckedValue = scope["G" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
554
|
-
scope["E" + nodeAccessor] = checkedValueChange, scope["F" + nodeAccessor] = checkedValueChange ? 1 : 5, checkedValueChange &&
|
|
566
|
+
scope["E" + nodeAccessor] = checkedValueChange, scope["F" + nodeAccessor] = checkedValueChange ? 1 : 5, checkedValueChange && scope.H < runId ? (el.checked = multiple ? normalizedCheckedValue.includes(normalizeStrProp(value)) : normalizeStrProp(value) === normalizedCheckedValue, _attr(el, "value", value)) : _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value);
|
|
555
567
|
}
|
|
556
568
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
557
569
|
let el = scope[nodeAccessor];
|
|
@@ -568,13 +580,13 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
|
568
580
|
function _attr_input_value_default(scope, nodeAccessor, value) {
|
|
569
581
|
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
570
582
|
if (el.defaultValue !== normalizedValue) {
|
|
571
|
-
let restoreValue = scope.H
|
|
583
|
+
let restoreValue = scope.H < runId ? el.value : normalizedValue;
|
|
572
584
|
el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
|
|
573
585
|
}
|
|
574
586
|
}
|
|
575
587
|
function _attr_input_value(scope, nodeAccessor, value, valueChange) {
|
|
576
588
|
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
577
|
-
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange &&
|
|
589
|
+
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange && scope.H < runId ? setInputValue(el, normalizedValue) : _attr_input_value_default(scope, nodeAccessor, normalizedValue);
|
|
578
590
|
}
|
|
579
591
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
580
592
|
let el = scope[nodeAccessor];
|
|
@@ -590,17 +602,17 @@ function setInputValue(el, value) {
|
|
|
590
602
|
}
|
|
591
603
|
}
|
|
592
604
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
593
|
-
let restoreValue, el = scope[nodeAccessor],
|
|
605
|
+
let restoreValue, el = scope[nodeAccessor], live = scope.H < runId, multiple = Array.isArray(value), normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
594
606
|
pendingEffects.unshift(() => {
|
|
595
607
|
for (let opt of el.options) {
|
|
596
608
|
let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
|
|
597
|
-
opt.defaultSelected !== selected && (
|
|
609
|
+
opt.defaultSelected !== selected && (live && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
|
|
598
610
|
}
|
|
599
611
|
restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
|
|
600
612
|
}, scope);
|
|
601
613
|
}
|
|
602
614
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
603
|
-
let el = scope[nodeAccessor], existing =
|
|
615
|
+
let el = scope[nodeAccessor], existing = scope.H < runId, multiple = Array.isArray(value), normalizedValue = scope["G" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
604
616
|
scope["E" + nodeAccessor] = valueChange, scope["F" + nodeAccessor] = valueChange ? 3 : 5, valueChange && existing ? pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope) : _attr_select_value_default(scope, nodeAccessor, normalizedValue);
|
|
605
617
|
}
|
|
606
618
|
function _attr_select_value_script(scope, nodeAccessor) {
|
|
@@ -637,11 +649,11 @@ function getSelectValue(el, multiple) {
|
|
|
637
649
|
return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
|
|
638
650
|
}
|
|
639
651
|
function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
640
|
-
scope.H && (scope[nodeAccessor].open = isNotVoid(open));
|
|
652
|
+
scope.H === runId && (scope[nodeAccessor].open = isNotVoid(open));
|
|
641
653
|
}
|
|
642
654
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
643
655
|
let normalizedOpen = scope["G" + nodeAccessor] = isNotVoid(open);
|
|
644
|
-
scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange &&
|
|
656
|
+
scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange && scope.H < runId ? scope[nodeAccessor].open = normalizedOpen : _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
|
|
645
657
|
}
|
|
646
658
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
647
659
|
let el = scope[nodeAccessor];
|
|
@@ -758,7 +770,8 @@ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
758
770
|
_attrs_partial(scope, nodeAccessor, nextAttrs, skip), _attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
759
771
|
}
|
|
760
772
|
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
761
|
-
let el = scope[nodeAccessor], events, skip;
|
|
773
|
+
let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
|
|
774
|
+
for (let name in events) events[name] = 0;
|
|
762
775
|
switch (el.tagName) {
|
|
763
776
|
case "INPUT":
|
|
764
777
|
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
@@ -873,7 +886,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
873
886
|
if (thisPromise === scope[promiseAccessor]) {
|
|
874
887
|
let referenceNode = scope[nodeAccessor];
|
|
875
888
|
scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
|
|
876
|
-
(awaitBranch = scope[branchAccessor]).V && (
|
|
889
|
+
(awaitBranch = scope[branchAccessor]).V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [data]);
|
|
877
890
|
let pendingRenders = awaitBranch.W;
|
|
878
891
|
if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
|
|
879
892
|
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
|
|
@@ -897,7 +910,8 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
897
910
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
898
911
|
let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
899
912
|
return (scope) => {
|
|
900
|
-
(scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer
|
|
913
|
+
let pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer);
|
|
914
|
+
scope[branchAccessor].Y = pendingScopes;
|
|
901
915
|
};
|
|
902
916
|
}
|
|
903
917
|
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
|
|
@@ -942,7 +956,7 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
942
956
|
let branchAccessor = "D" + nodeAccessor, branches = [], i = 0;
|
|
943
957
|
for (; i < branchesArgs.length;) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
|
|
944
958
|
return enableBranches(), (scope, newBranch) => {
|
|
945
|
-
newBranch !== scope[branchAccessor] && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
959
|
+
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
946
960
|
};
|
|
947
961
|
}
|
|
948
962
|
function patchDynamicTag(fn) {
|
|
@@ -1069,12 +1083,10 @@ function runRenders() {
|
|
|
1069
1083
|
}
|
|
1070
1084
|
runRender(render);
|
|
1071
1085
|
}
|
|
1072
|
-
for (let scope of pendingScopes) scope.H = 0;
|
|
1073
|
-
pendingScopes = [];
|
|
1074
1086
|
}
|
|
1075
1087
|
function skipDestroyedRenders() {
|
|
1076
1088
|
runRender = ((runRender) => (render) => {
|
|
1077
|
-
render.b.F?.
|
|
1089
|
+
render.b.F?.H !== 0 && runRender(render);
|
|
1078
1090
|
})(runRender);
|
|
1079
1091
|
}
|
|
1080
1092
|
function _enable_catch() {
|
|
@@ -1089,7 +1101,7 @@ function _enable_catch() {
|
|
|
1089
1101
|
runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
1090
1102
|
if (checkPending || caughtError.has(effects)) {
|
|
1091
1103
|
let i = 0, fn, scope, branch;
|
|
1092
|
-
for (; i < effects.length;) fn = effects[i++], scope = effects[i++], branch = scope.F
|
|
1104
|
+
for (; i < effects.length;) fn = effects[i++], scope = effects[i++], (branch = scope.F)?.H !== 0 && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope);
|
|
1093
1105
|
} else runEffects(effects);
|
|
1094
1106
|
})(runEffects), runRender = ((runRender) => (render) => {
|
|
1095
1107
|
try {
|
|
@@ -1193,8 +1205,8 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
1193
1205
|
}
|
|
1194
1206
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
1195
1207
|
let parent = marker.parentNode;
|
|
1196
|
-
branch
|
|
1197
|
-
insertBranchBefore(branch, parent, marker), marker.remove(),
|
|
1208
|
+
syncGen(branch), renderer.b(branch, parent.namespaceURI), setupBranch(renderer, branch), applyLoad(branch, () => {
|
|
1209
|
+
insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c();
|
|
1198
1210
|
});
|
|
1199
1211
|
}
|
|
1200
1212
|
function loadFailed(scope, awaitCounter) {
|
|
@@ -1205,16 +1217,16 @@ function loadFailed(scope, awaitCounter) {
|
|
|
1205
1217
|
function applyLoad(scope, insert) {
|
|
1206
1218
|
let values = scope.X, remaining;
|
|
1207
1219
|
if (scope.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
|
|
1208
|
-
entry.b = signal, --remaining ||
|
|
1209
|
-
values.forEach((e) => e.b._(scope, e.a)), insert();
|
|
1210
|
-
})
|
|
1220
|
+
entry.b = signal, --remaining || queueAsyncRender(scope, (scope) => {
|
|
1221
|
+
syncGen(scope), values.forEach((e) => e.b._(scope, e.a)), insert();
|
|
1222
|
+
});
|
|
1211
1223
|
}, () => 0);
|
|
1212
1224
|
else insert();
|
|
1213
1225
|
}
|
|
1214
1226
|
function _load_signal(load) {
|
|
1215
1227
|
let pending, signal;
|
|
1216
1228
|
return (scope, value) => {
|
|
1217
|
-
pending ||= load(), scope.X || !("X" in scope) && scope.H ? (scope.X ||= /* @__PURE__ */ new Map()).set(pending, { a: value }) : signal ? signal(scope, value) : pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
|
|
1229
|
+
pending ||= load(), scope.X || !("X" in scope) && scope.H === runId ? (scope.X ||= /* @__PURE__ */ new Map()).set(pending, { a: value }) : signal ? signal(scope, value) : pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
|
|
1218
1230
|
};
|
|
1219
1231
|
}
|
|
1220
1232
|
function _load_visible_trigger(selector, options) {
|
package/dist/dom.mjs
CHANGED
|
@@ -4,8 +4,8 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
4
4
|
else if (Array.isArray(val)) for (let v of val) part = toDelimitedString(v, delimiter, stringify), part && (str += sep + part, sep = delimiter);
|
|
5
5
|
else for (let name in val) part = stringify(name, val[name]), part && (str += sep + part, sep = delimiter);
|
|
6
6
|
return str;
|
|
7
|
-
}, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), defaultDelegator = /* @__PURE__ */ createDelegator(), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
8
|
-
scope.
|
|
7
|
+
}, decodeAccessor = (num) => (num + (num < 26 ? 10 : num < 962 ? 334 : 11998)).toString(36), defaultDelegator = /* @__PURE__ */ createDelegator(), R = /[^\p{L}\p{N}]/gu, parsers = {}, nextScopeId = 1e6, collectingScopes, destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
8
|
+
scope.H = 0, scope.D?.forEach(destroyNestedScopes), scope.B?.forEach(resetControllers);
|
|
9
9
|
}, isScheduled, channel, _return = (scope, value) => scope.T?.(value), _var_change = (scope, value) => scope.U?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap(), walker = /* @__PURE__ */ document.createTreeWalker(document), walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
10
10
|
let value, currentMultiplier, storedMultiplier = 0, currentScopeIndex = 0;
|
|
11
11
|
for (; currentWalkIndex < walkCodes.length;) if (value = walkCodes.charCodeAt(currentWalkIndex++), currentMultiplier = storedMultiplier, storedMultiplier = 0, value === 32) {
|
|
@@ -49,7 +49,7 @@ let empty = [], rest = Symbol(), toDelimitedString = function toDelimitedString(
|
|
|
49
49
|
};
|
|
50
50
|
}, _for_of = /* @__PURE__ */ loop(([all, by = bySecondArg], cb) => {
|
|
51
51
|
typeof by == "string" ? forOf(all, (item, i) => cb(item[by], [item, i])) : forOf(all, (item, i) => cb(by(item, i), [item, i]));
|
|
52
|
-
}), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))),
|
|
52
|
+
}), _for_in = /* @__PURE__ */ loop(([obj, by = byFirstArg], cb) => forIn(obj, (key, value) => cb(by(key, value), [key, value]))), _for_to = /* @__PURE__ */ loop(([to, from, step, by = byFirstArg], cb) => forTo(to, from, step, (v) => cb(by(v), [v]))), _for_until = /* @__PURE__ */ loop(([until, from, step, by = byFirstArg], cb) => forUntil(until, from, step, (v) => cb(by(v), [v]))), rendering, runId = 2, caughtError = /* @__PURE__ */ new WeakSet(), placeholderShown = /* @__PURE__ */ new WeakSet(), pendingEffects = [], pendingRenders = [], scopeKeyOffset = 1e3, runEffects = ((effects) => {
|
|
53
53
|
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
54
54
|
}), runRender = (render) => render.c(render.b, render.d), catchEnabled, classIdToBranch = /* @__PURE__ */ new Map(), scopesByRender = /* @__PURE__ */ new WeakMap(), getRenderScopes = ($global) => {
|
|
55
55
|
let render = self[$global.runtimeId]?.[$global.renderId], scopes = render && scopesByRender.get(render);
|
|
@@ -118,9 +118,6 @@ function* attrTagIterator() {
|
|
|
118
118
|
yield this, yield* this[rest];
|
|
119
119
|
}
|
|
120
120
|
function _assert_hoist(value) {}
|
|
121
|
-
function _assert_init(scope, accessor) {
|
|
122
|
-
return scope[accessor];
|
|
123
|
-
}
|
|
124
121
|
//#endregion
|
|
125
122
|
//#region src/common/for.ts
|
|
126
123
|
function forIn(obj, cb) {
|
|
@@ -215,11 +212,26 @@ function parseHTML(html, ns) {
|
|
|
215
212
|
function createScope($global, closestBranch) {
|
|
216
213
|
let scope = {
|
|
217
214
|
L: nextScopeId++,
|
|
218
|
-
H:
|
|
215
|
+
H: runId,
|
|
219
216
|
F: closestBranch,
|
|
220
217
|
$: $global
|
|
221
218
|
};
|
|
222
|
-
return
|
|
219
|
+
return collectingScopes?.push(scope), scope;
|
|
220
|
+
}
|
|
221
|
+
function syncGen(scope) {
|
|
222
|
+
scope.H = runId;
|
|
223
|
+
}
|
|
224
|
+
function _assert_init(scope, accessor) {
|
|
225
|
+
return scope[accessor];
|
|
226
|
+
}
|
|
227
|
+
function collectScopes(fn) {
|
|
228
|
+
let prev = collectingScopes;
|
|
229
|
+
collectingScopes = [];
|
|
230
|
+
try {
|
|
231
|
+
return fn(), collectingScopes;
|
|
232
|
+
} finally {
|
|
233
|
+
collectingScopes = prev;
|
|
234
|
+
}
|
|
223
235
|
}
|
|
224
236
|
function skipScope() {
|
|
225
237
|
return nextScopeId++;
|
|
@@ -233,7 +245,7 @@ function destroyBranch(branch) {
|
|
|
233
245
|
branch.N?.D?.delete(branch), destroyNestedScopes(branch);
|
|
234
246
|
}
|
|
235
247
|
function destroyScope(scope) {
|
|
236
|
-
scope.
|
|
248
|
+
scope.H && (destroyNestedScopes(scope), resetControllers(scope));
|
|
237
249
|
}
|
|
238
250
|
function resetControllers(scope) {
|
|
239
251
|
for (let id in scope.A) $signalReset(scope, id);
|
|
@@ -265,7 +277,7 @@ function triggerMacroTask() {
|
|
|
265
277
|
//#region src/dom/signals.ts
|
|
266
278
|
function _let(id, fn) {
|
|
267
279
|
let valueAccessor = decodeAccessor(id);
|
|
268
|
-
return (scope, value) => (rendering ? scope.H && (scope[valueAccessor] = value, fn?.(scope)) : (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn) && (schedule(), queueRender(scope, fn, id)), value);
|
|
280
|
+
return (scope, value) => (rendering ? scope.H === runId && (scope[valueAccessor] = value, fn?.(scope)) : (scope[valueAccessor] !== value || !(valueAccessor in scope)) && (scope[valueAccessor] = value, fn) && (schedule(), queueRender(scope, fn, id)), value);
|
|
269
281
|
}
|
|
270
282
|
function _let_change(id, fn) {
|
|
271
283
|
let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor, base = _let(id, fn);
|
|
@@ -278,7 +290,7 @@ function _const(valueAccessor, fn) {
|
|
|
278
290
|
}
|
|
279
291
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L") {
|
|
280
292
|
return scopeIdAccessor !== "L" && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
|
|
281
|
-
scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
293
|
+
scope.H === runId ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
282
294
|
};
|
|
283
295
|
}
|
|
284
296
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
@@ -286,7 +298,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
286
298
|
let scopeAccessor = "A" + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
|
|
287
299
|
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
288
300
|
scopes.length && queueRender(ownerScope, () => {
|
|
289
|
-
for (let scope of scopes)
|
|
301
|
+
for (let scope of scopes) scope.H > 0 && scope.H < runId && fn(scope);
|
|
290
302
|
}, -1, 0, scopes[0].L);
|
|
291
303
|
};
|
|
292
304
|
return ownerSignal._ = fn, ownerSignal;
|
|
@@ -295,7 +307,7 @@ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
|
295
307
|
ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
|
|
296
308
|
let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
297
309
|
let ifScope = scope[scopeAccessor];
|
|
298
|
-
ifScope &&
|
|
310
|
+
ifScope && ifScope.H > 0 && ifScope.H < runId && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
|
|
299
311
|
};
|
|
300
312
|
return ownerSignal._ = fn, ownerSignal;
|
|
301
313
|
}
|
|
@@ -307,7 +319,7 @@ function _closure(...closureSignals) {
|
|
|
307
319
|
let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
|
|
308
320
|
for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
|
|
309
321
|
return (scope) => {
|
|
310
|
-
if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H
|
|
322
|
+
if (scope[scopeInstances]) for (let childScope of scope[scopeInstances]) childScope.H > 0 && childScope.H < runId && queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
|
|
311
323
|
};
|
|
312
324
|
}
|
|
313
325
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
@@ -439,7 +451,7 @@ function init(runtimeId = "M") {
|
|
|
439
451
|
let render = curRenders[renderId] = renders[renderId] || renders(renderId), walk = render.w, scopeLookup = {}, getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { L: +id }) : initGlobal()), initGlobal = () => scopeLookup[0] ||= {
|
|
440
452
|
runtimeId,
|
|
441
453
|
renderId
|
|
442
|
-
}, initScope = (scope) => (scope.$ = initGlobal(), branchesEnabled && scope.G && (scope.F = getScope(scope.G)), scope), applyScopes = (partials) => {
|
|
454
|
+
}, initScope = (scope) => (scope.H = 1, scope.$ = initGlobal(), branchesEnabled && scope.G && (scope.F = getScope(scope.G)), scope), applyScopes = (partials) => {
|
|
443
455
|
let scopeId = partials[0];
|
|
444
456
|
for (let i = 1; i < partials.length; i++) {
|
|
445
457
|
let partial = partials[i];
|
|
@@ -526,13 +538,13 @@ function _el(id, accessor) {
|
|
|
526
538
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
527
539
|
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
528
540
|
if (el.defaultChecked !== normalizedChecked) {
|
|
529
|
-
let restoreValue = scope.H
|
|
541
|
+
let restoreValue = scope.H < runId ? el.checked : normalizedChecked;
|
|
530
542
|
el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
|
|
531
543
|
}
|
|
532
544
|
}
|
|
533
545
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
534
546
|
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
535
|
-
scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange &&
|
|
547
|
+
scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange && scope.H < runId ? el.checked = normalizedChecked : _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
|
|
536
548
|
}
|
|
537
549
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
538
550
|
let el = scope[nodeAccessor];
|
|
@@ -550,7 +562,7 @@ function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, val
|
|
|
550
562
|
}
|
|
551
563
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
552
564
|
let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedCheckedValue = scope["G" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
553
|
-
scope["E" + nodeAccessor] = checkedValueChange, scope["F" + nodeAccessor] = checkedValueChange ? 1 : 5, checkedValueChange &&
|
|
565
|
+
scope["E" + nodeAccessor] = checkedValueChange, scope["F" + nodeAccessor] = checkedValueChange ? 1 : 5, checkedValueChange && scope.H < runId ? (el.checked = multiple ? normalizedCheckedValue.includes(normalizeStrProp(value)) : normalizeStrProp(value) === normalizedCheckedValue, _attr(el, "value", value)) : _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value);
|
|
554
566
|
}
|
|
555
567
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
556
568
|
let el = scope[nodeAccessor];
|
|
@@ -567,13 +579,13 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
|
567
579
|
function _attr_input_value_default(scope, nodeAccessor, value) {
|
|
568
580
|
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
569
581
|
if (el.defaultValue !== normalizedValue) {
|
|
570
|
-
let restoreValue = scope.H
|
|
582
|
+
let restoreValue = scope.H < runId ? el.value : normalizedValue;
|
|
571
583
|
el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
|
|
572
584
|
}
|
|
573
585
|
}
|
|
574
586
|
function _attr_input_value(scope, nodeAccessor, value, valueChange) {
|
|
575
587
|
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
576
|
-
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange &&
|
|
588
|
+
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange && scope.H < runId ? setInputValue(el, normalizedValue) : _attr_input_value_default(scope, nodeAccessor, normalizedValue);
|
|
577
589
|
}
|
|
578
590
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
579
591
|
let el = scope[nodeAccessor];
|
|
@@ -589,17 +601,17 @@ function setInputValue(el, value) {
|
|
|
589
601
|
}
|
|
590
602
|
}
|
|
591
603
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
592
|
-
let restoreValue, el = scope[nodeAccessor],
|
|
604
|
+
let restoreValue, el = scope[nodeAccessor], live = scope.H < runId, multiple = Array.isArray(value), normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
593
605
|
pendingEffects.unshift(() => {
|
|
594
606
|
for (let opt of el.options) {
|
|
595
607
|
let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
|
|
596
|
-
opt.defaultSelected !== selected && (
|
|
608
|
+
opt.defaultSelected !== selected && (live && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
|
|
597
609
|
}
|
|
598
610
|
restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
|
|
599
611
|
}, scope);
|
|
600
612
|
}
|
|
601
613
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
602
|
-
let el = scope[nodeAccessor], existing =
|
|
614
|
+
let el = scope[nodeAccessor], existing = scope.H < runId, multiple = Array.isArray(value), normalizedValue = scope["G" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
603
615
|
scope["E" + nodeAccessor] = valueChange, scope["F" + nodeAccessor] = valueChange ? 3 : 5, valueChange && existing ? pendingEffects.unshift(() => setSelectValue(el, normalizedValue, multiple), scope) : _attr_select_value_default(scope, nodeAccessor, normalizedValue);
|
|
604
616
|
}
|
|
605
617
|
function _attr_select_value_script(scope, nodeAccessor) {
|
|
@@ -636,11 +648,11 @@ function getSelectValue(el, multiple) {
|
|
|
636
648
|
return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
|
|
637
649
|
}
|
|
638
650
|
function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
639
|
-
scope.H && (scope[nodeAccessor].open = isNotVoid(open));
|
|
651
|
+
scope.H === runId && (scope[nodeAccessor].open = isNotVoid(open));
|
|
640
652
|
}
|
|
641
653
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
642
654
|
let normalizedOpen = scope["G" + nodeAccessor] = isNotVoid(open);
|
|
643
|
-
scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange &&
|
|
655
|
+
scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange && scope.H < runId ? scope[nodeAccessor].open = normalizedOpen : _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
|
|
644
656
|
}
|
|
645
657
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
646
658
|
let el = scope[nodeAccessor];
|
|
@@ -757,7 +769,8 @@ function _attrs_partial_content(scope, nodeAccessor, nextAttrs, skip) {
|
|
|
757
769
|
_attrs_partial(scope, nodeAccessor, nextAttrs, skip), _attr_content(scope, nodeAccessor, nextAttrs?.content);
|
|
758
770
|
}
|
|
759
771
|
function attrsInternal(scope, nodeAccessor, nextAttrs) {
|
|
760
|
-
let el = scope[nodeAccessor], events, skip;
|
|
772
|
+
let el = scope[nodeAccessor], events = scope["I" + nodeAccessor], skip;
|
|
773
|
+
for (let name in events) events[name] = 0;
|
|
761
774
|
switch (el.tagName) {
|
|
762
775
|
case "INPUT":
|
|
763
776
|
if ("checked" in nextAttrs || "checkedChange" in nextAttrs) _attr_input_checked(scope, nodeAccessor, nextAttrs.checked, nextAttrs.checkedChange);
|
|
@@ -872,7 +885,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
872
885
|
if (thisPromise === scope[promiseAccessor]) {
|
|
873
886
|
let referenceNode = scope[nodeAccessor];
|
|
874
887
|
scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
|
|
875
|
-
(awaitBranch = scope[branchAccessor]).V && (
|
|
888
|
+
(awaitBranch = scope[branchAccessor]).V && (awaitBranch.Y = awaitBranch.Y?.forEach(syncGen), setupBranch(awaitBranch.V, awaitBranch), awaitBranch.V = 0, insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]), referenceNode.remove()), params?.(awaitBranch, [data]);
|
|
876
889
|
let pendingRenders = awaitBranch.W;
|
|
877
890
|
if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
|
|
878
891
|
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
|
|
@@ -896,7 +909,8 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
896
909
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
897
910
|
let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
898
911
|
return (scope) => {
|
|
899
|
-
(scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer
|
|
912
|
+
let pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer);
|
|
913
|
+
scope[branchAccessor].Y = pendingScopes;
|
|
900
914
|
};
|
|
901
915
|
}
|
|
902
916
|
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
|
|
@@ -941,7 +955,7 @@ function _if(nodeAccessor, ...branchesArgs) {
|
|
|
941
955
|
let branchAccessor = "D" + nodeAccessor, branches = [], i = 0;
|
|
942
956
|
for (; i < branchesArgs.length;) branches.push(_content("", branchesArgs[i++], branchesArgs[i++], branchesArgs[i++])());
|
|
943
957
|
return enableBranches(), (scope, newBranch) => {
|
|
944
|
-
newBranch !== scope[branchAccessor] && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
958
|
+
newBranch !== (scope[branchAccessor] ?? (scope["A" + nodeAccessor] && 0)) && setConditionalRenderer(scope, nodeAccessor, branches[scope[branchAccessor] = newBranch], createAndSetupBranch);
|
|
945
959
|
};
|
|
946
960
|
}
|
|
947
961
|
function patchDynamicTag(fn) {
|
|
@@ -1068,12 +1082,10 @@ function runRenders() {
|
|
|
1068
1082
|
}
|
|
1069
1083
|
runRender(render);
|
|
1070
1084
|
}
|
|
1071
|
-
for (let scope of pendingScopes) scope.H = 0;
|
|
1072
|
-
pendingScopes = [];
|
|
1073
1085
|
}
|
|
1074
1086
|
function skipDestroyedRenders() {
|
|
1075
1087
|
runRender = ((runRender) => (render) => {
|
|
1076
|
-
render.b.F?.
|
|
1088
|
+
render.b.F?.H !== 0 && runRender(render);
|
|
1077
1089
|
})(runRender);
|
|
1078
1090
|
}
|
|
1079
1091
|
function _enable_catch() {
|
|
@@ -1088,7 +1100,7 @@ function _enable_catch() {
|
|
|
1088
1100
|
runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
1089
1101
|
if (checkPending || caughtError.has(effects)) {
|
|
1090
1102
|
let i = 0, fn, scope, branch;
|
|
1091
|
-
for (; i < effects.length;) fn = effects[i++], scope = effects[i++], branch = scope.F
|
|
1103
|
+
for (; i < effects.length;) fn = effects[i++], scope = effects[i++], (branch = scope.F)?.H !== 0 && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope);
|
|
1092
1104
|
} else runEffects(effects);
|
|
1093
1105
|
})(runEffects), runRender = ((runRender) => (render) => {
|
|
1094
1106
|
try {
|
|
@@ -1192,8 +1204,8 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
1192
1204
|
}
|
|
1193
1205
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
1194
1206
|
let parent = marker.parentNode;
|
|
1195
|
-
branch
|
|
1196
|
-
insertBranchBefore(branch, parent, marker), marker.remove(),
|
|
1207
|
+
syncGen(branch), renderer.b(branch, parent.namespaceURI), setupBranch(renderer, branch), applyLoad(branch, () => {
|
|
1208
|
+
insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c();
|
|
1197
1209
|
});
|
|
1198
1210
|
}
|
|
1199
1211
|
function loadFailed(scope, awaitCounter) {
|
|
@@ -1204,16 +1216,16 @@ function loadFailed(scope, awaitCounter) {
|
|
|
1204
1216
|
function applyLoad(scope, insert) {
|
|
1205
1217
|
let values = scope.X, remaining;
|
|
1206
1218
|
if (scope.X = 0, remaining = values?.size) for (let [promise, entry] of values) promise.then((signal) => {
|
|
1207
|
-
entry.b = signal, --remaining ||
|
|
1208
|
-
values.forEach((e) => e.b._(scope, e.a)), insert();
|
|
1209
|
-
})
|
|
1219
|
+
entry.b = signal, --remaining || queueAsyncRender(scope, (scope) => {
|
|
1220
|
+
syncGen(scope), values.forEach((e) => e.b._(scope, e.a)), insert();
|
|
1221
|
+
});
|
|
1210
1222
|
}, () => 0);
|
|
1211
1223
|
else insert();
|
|
1212
1224
|
}
|
|
1213
1225
|
function _load_signal(load) {
|
|
1214
1226
|
let pending, signal;
|
|
1215
1227
|
return (scope, value) => {
|
|
1216
|
-
pending ||= load(), scope.X || !("X" in scope) && scope.H ? (scope.X ||= /* @__PURE__ */ new Map()).set(pending, { a: value }) : signal ? signal(scope, value) : pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
|
|
1228
|
+
pending ||= load(), scope.X || !("X" in scope) && scope.H === runId ? (scope.X ||= /* @__PURE__ */ new Map()).set(pending, { a: value }) : signal ? signal(scope, value) : pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
|
|
1217
1229
|
};
|
|
1218
1230
|
}
|
|
1219
1231
|
function _load_visible_trigger(selector, options) {
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -40,7 +40,7 @@ export declare function getScopeById(scopeId: number | undefined): ScopeInternal
|
|
|
40
40
|
export declare function _set_serialize_reason(reason: undefined | 0 | 1): void;
|
|
41
41
|
export declare function _scope_reason(): 0 | 1 | undefined;
|
|
42
42
|
export declare function _serialize_if(condition: undefined | 1 | Record<string, 1>, key: string): 1 | undefined;
|
|
43
|
-
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string):
|
|
43
|
+
export declare function _serialize_guard(condition: undefined | 1 | Record<string, 1>, key: string): 1 | 0;
|
|
44
44
|
export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
|
|
45
45
|
export declare function _sep(shouldResume: 0 | 1): "" | "<!>";
|
|
46
46
|
export declare function _el(scopeId: number, id: string): () => void;
|