marko 6.1.10 → 6.1.12
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 +0 -2
- package/dist/common/helpers.d.ts +1 -0
- package/dist/common/types.d.ts +2 -2
- package/dist/debug/dom.js +66 -59
- package/dist/debug/dom.mjs +66 -59
- package/dist/debug/html.js +9 -9
- package/dist/debug/html.mjs +9 -9
- 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 +59 -48
- package/dist/dom.mjs +59 -48
- package/dist/html/writer.d.ts +1 -1
- package/dist/html.js +9 -9
- package/dist/html.mjs +9 -9
- package/dist/translator/index.js +99 -22
- package/dist/translator/util/references.d.ts +4 -0
- package/dist/translator/util/sections.d.ts +1 -1
- 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) {
|
|
@@ -158,6 +155,9 @@ function isEventHandler(name) {
|
|
|
158
155
|
function getEventHandlerName(name) {
|
|
159
156
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
160
157
|
}
|
|
158
|
+
function isNotVoid(value) {
|
|
159
|
+
return value != null && value !== !1;
|
|
160
|
+
}
|
|
161
161
|
function normalizeDynamicRenderer(value) {
|
|
162
162
|
if (value) {
|
|
163
163
|
if (typeof value == "string") return value;
|
|
@@ -213,11 +213,26 @@ function parseHTML(html, ns) {
|
|
|
213
213
|
function createScope($global, closestBranch) {
|
|
214
214
|
let scope = {
|
|
215
215
|
L: nextScopeId++,
|
|
216
|
-
H:
|
|
216
|
+
H: runId,
|
|
217
217
|
F: closestBranch,
|
|
218
218
|
$: $global
|
|
219
219
|
};
|
|
220
|
-
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
|
+
}
|
|
221
236
|
}
|
|
222
237
|
function skipScope() {
|
|
223
238
|
return nextScopeId++;
|
|
@@ -231,7 +246,7 @@ function destroyBranch(branch) {
|
|
|
231
246
|
branch.N?.D?.delete(branch), destroyNestedScopes(branch);
|
|
232
247
|
}
|
|
233
248
|
function destroyScope(scope) {
|
|
234
|
-
scope.
|
|
249
|
+
scope.H && (destroyNestedScopes(scope), resetControllers(scope));
|
|
235
250
|
}
|
|
236
251
|
function resetControllers(scope) {
|
|
237
252
|
for (let id in scope.A) $signalReset(scope, id);
|
|
@@ -263,7 +278,7 @@ function triggerMacroTask() {
|
|
|
263
278
|
//#region src/dom/signals.ts
|
|
264
279
|
function _let(id, fn) {
|
|
265
280
|
let valueAccessor = decodeAccessor(id);
|
|
266
|
-
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);
|
|
267
282
|
}
|
|
268
283
|
function _let_change(id, fn) {
|
|
269
284
|
let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor, base = _let(id, fn);
|
|
@@ -276,7 +291,7 @@ function _const(valueAccessor, fn) {
|
|
|
276
291
|
}
|
|
277
292
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L") {
|
|
278
293
|
return scopeIdAccessor !== "L" && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
|
|
279
|
-
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]);
|
|
280
295
|
};
|
|
281
296
|
}
|
|
282
297
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
@@ -284,7 +299,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
284
299
|
let scopeAccessor = "A" + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
|
|
285
300
|
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
286
301
|
scopes.length && queueRender(ownerScope, () => {
|
|
287
|
-
for (let scope of scopes)
|
|
302
|
+
for (let scope of scopes) scope.H > 0 && scope.H < runId && fn(scope);
|
|
288
303
|
}, -1, 0, scopes[0].L);
|
|
289
304
|
};
|
|
290
305
|
return ownerSignal._ = fn, ownerSignal;
|
|
@@ -293,7 +308,7 @@ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
|
293
308
|
ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
|
|
294
309
|
let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
295
310
|
let ifScope = scope[scopeAccessor];
|
|
296
|
-
ifScope &&
|
|
311
|
+
ifScope && ifScope.H > 0 && ifScope.H < runId && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
|
|
297
312
|
};
|
|
298
313
|
return ownerSignal._ = fn, ownerSignal;
|
|
299
314
|
}
|
|
@@ -305,7 +320,7 @@ function _closure(...closureSignals) {
|
|
|
305
320
|
let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
|
|
306
321
|
for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
|
|
307
322
|
return (scope) => {
|
|
308
|
-
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);
|
|
309
324
|
};
|
|
310
325
|
}
|
|
311
326
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
@@ -437,7 +452,7 @@ function init(runtimeId = "M") {
|
|
|
437
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] ||= {
|
|
438
453
|
runtimeId,
|
|
439
454
|
renderId
|
|
440
|
-
}, 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) => {
|
|
441
456
|
let scopeId = partials[0];
|
|
442
457
|
for (let i = 1; i < partials.length; i++) {
|
|
443
458
|
let partial = partials[i];
|
|
@@ -522,15 +537,15 @@ function _el(id, accessor) {
|
|
|
522
537
|
//#endregion
|
|
523
538
|
//#region src/dom/controllable.ts
|
|
524
539
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
525
|
-
let el = scope[nodeAccessor], normalizedChecked =
|
|
540
|
+
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
526
541
|
if (el.defaultChecked !== normalizedChecked) {
|
|
527
|
-
let restoreValue = scope.H
|
|
542
|
+
let restoreValue = scope.H < runId ? el.checked : normalizedChecked;
|
|
528
543
|
el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
|
|
529
544
|
}
|
|
530
545
|
}
|
|
531
546
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
532
|
-
let el = scope[nodeAccessor], normalizedChecked =
|
|
533
|
-
scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange &&
|
|
547
|
+
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
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);
|
|
534
549
|
}
|
|
535
550
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
536
551
|
let el = scope[nodeAccessor];
|
|
@@ -544,11 +559,11 @@ function _attr_input_checked_script(scope, nodeAccessor) {
|
|
|
544
559
|
}
|
|
545
560
|
function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value) {
|
|
546
561
|
let multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
547
|
-
_attr(scope[nodeAccessor], "value",
|
|
562
|
+
_attr(scope[nodeAccessor], "value", value), _attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
|
|
548
563
|
}
|
|
549
564
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
550
|
-
let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue),
|
|
551
|
-
|
|
565
|
+
let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedCheckedValue = scope["G" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
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);
|
|
552
567
|
}
|
|
553
568
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
554
569
|
let el = scope[nodeAccessor];
|
|
@@ -563,15 +578,15 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
|
563
578
|
});
|
|
564
579
|
}
|
|
565
580
|
function _attr_input_value_default(scope, nodeAccessor, value) {
|
|
566
|
-
let el = scope[nodeAccessor], normalizedValue =
|
|
581
|
+
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
567
582
|
if (el.defaultValue !== normalizedValue) {
|
|
568
|
-
let restoreValue = scope.H
|
|
583
|
+
let restoreValue = scope.H < runId ? el.value : normalizedValue;
|
|
569
584
|
el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
|
|
570
585
|
}
|
|
571
586
|
}
|
|
572
587
|
function _attr_input_value(scope, nodeAccessor, value, valueChange) {
|
|
573
|
-
let el = scope[nodeAccessor], normalizedValue =
|
|
574
|
-
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange &&
|
|
588
|
+
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
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);
|
|
575
590
|
}
|
|
576
591
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
577
592
|
let el = scope[nodeAccessor];
|
|
@@ -587,17 +602,17 @@ function setInputValue(el, value) {
|
|
|
587
602
|
}
|
|
588
603
|
}
|
|
589
604
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
590
|
-
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);
|
|
591
606
|
pendingEffects.unshift(() => {
|
|
592
607
|
for (let opt of el.options) {
|
|
593
608
|
let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
|
|
594
|
-
opt.defaultSelected !== selected && (
|
|
609
|
+
opt.defaultSelected !== selected && (live && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
|
|
595
610
|
}
|
|
596
611
|
restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
|
|
597
612
|
}, scope);
|
|
598
613
|
}
|
|
599
614
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
600
|
-
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);
|
|
601
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);
|
|
602
617
|
}
|
|
603
618
|
function _attr_select_value_script(scope, nodeAccessor) {
|
|
@@ -634,11 +649,11 @@ function getSelectValue(el, multiple) {
|
|
|
634
649
|
return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
|
|
635
650
|
}
|
|
636
651
|
function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
637
|
-
scope.H && (scope[nodeAccessor].open =
|
|
652
|
+
scope.H === runId && (scope[nodeAccessor].open = isNotVoid(open));
|
|
638
653
|
}
|
|
639
654
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
640
|
-
let normalizedOpen = scope["G" + nodeAccessor] =
|
|
641
|
-
scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange &&
|
|
655
|
+
let normalizedOpen = scope["G" + nodeAccessor] = isNotVoid(open);
|
|
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);
|
|
642
657
|
}
|
|
643
658
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
644
659
|
let el = scope[nodeAccessor];
|
|
@@ -681,9 +696,6 @@ function hasFormElementChanged(el) {
|
|
|
681
696
|
function normalizeStrProp(value) {
|
|
682
697
|
return normalizeAttrValue(value) || "";
|
|
683
698
|
}
|
|
684
|
-
function normalizeBoolProp(value) {
|
|
685
|
-
return value != null && value !== !1;
|
|
686
|
-
}
|
|
687
699
|
function updateList(arr, val, push) {
|
|
688
700
|
let index = arr.indexOf(val);
|
|
689
701
|
return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
|
|
@@ -828,7 +840,7 @@ function normalizeClientRender(value) {
|
|
|
828
840
|
if (renderer && renderer.a) return renderer;
|
|
829
841
|
}
|
|
830
842
|
function normalizeAttrValue(value) {
|
|
831
|
-
if (value
|
|
843
|
+
if (isNotVoid(value)) return value === !0 ? "" : value + "";
|
|
832
844
|
}
|
|
833
845
|
function _lifecycle(scope, thisObj, index = 0) {
|
|
834
846
|
let accessor = "K" + index, instance = scope[accessor];
|
|
@@ -873,7 +885,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
873
885
|
if (thisPromise === scope[promiseAccessor]) {
|
|
874
886
|
let referenceNode = scope[nodeAccessor];
|
|
875
887
|
scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
|
|
876
|
-
(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]);
|
|
877
889
|
let pendingRenders = awaitBranch.W;
|
|
878
890
|
if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
|
|
879
891
|
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
|
|
@@ -897,7 +909,8 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
897
909
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
898
910
|
let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
899
911
|
return (scope) => {
|
|
900
|
-
(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;
|
|
901
914
|
};
|
|
902
915
|
}
|
|
903
916
|
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
|
|
@@ -1069,12 +1082,10 @@ function runRenders() {
|
|
|
1069
1082
|
}
|
|
1070
1083
|
runRender(render);
|
|
1071
1084
|
}
|
|
1072
|
-
for (let scope of pendingScopes) scope.H = 0;
|
|
1073
|
-
pendingScopes = [];
|
|
1074
1085
|
}
|
|
1075
1086
|
function skipDestroyedRenders() {
|
|
1076
1087
|
runRender = ((runRender) => (render) => {
|
|
1077
|
-
render.b.F?.
|
|
1088
|
+
render.b.F?.H !== 0 && runRender(render);
|
|
1078
1089
|
})(runRender);
|
|
1079
1090
|
}
|
|
1080
1091
|
function _enable_catch() {
|
|
@@ -1089,7 +1100,7 @@ function _enable_catch() {
|
|
|
1089
1100
|
runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
1090
1101
|
if (checkPending || caughtError.has(effects)) {
|
|
1091
1102
|
let i = 0, fn, scope, branch;
|
|
1092
|
-
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);
|
|
1093
1104
|
} else runEffects(effects);
|
|
1094
1105
|
})(runEffects), runRender = ((runRender) => (render) => {
|
|
1095
1106
|
try {
|
|
@@ -1193,8 +1204,8 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
1193
1204
|
}
|
|
1194
1205
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
1195
1206
|
let parent = marker.parentNode;
|
|
1196
|
-
branch
|
|
1197
|
-
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();
|
|
1198
1209
|
});
|
|
1199
1210
|
}
|
|
1200
1211
|
function loadFailed(scope, awaitCounter) {
|
|
@@ -1205,16 +1216,16 @@ function loadFailed(scope, awaitCounter) {
|
|
|
1205
1216
|
function applyLoad(scope, insert) {
|
|
1206
1217
|
let values = scope.X, remaining;
|
|
1207
1218
|
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
|
-
})
|
|
1219
|
+
entry.b = signal, --remaining || queueAsyncRender(scope, (scope) => {
|
|
1220
|
+
syncGen(scope), values.forEach((e) => e.b._(scope, e.a)), insert();
|
|
1221
|
+
});
|
|
1211
1222
|
}, () => 0);
|
|
1212
1223
|
else insert();
|
|
1213
1224
|
}
|
|
1214
1225
|
function _load_signal(load) {
|
|
1215
1226
|
let pending, signal;
|
|
1216
1227
|
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);
|
|
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);
|
|
1218
1229
|
};
|
|
1219
1230
|
}
|
|
1220
1231
|
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) {
|
|
@@ -157,6 +154,9 @@ function isEventHandler(name) {
|
|
|
157
154
|
function getEventHandlerName(name) {
|
|
158
155
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
159
156
|
}
|
|
157
|
+
function isNotVoid(value) {
|
|
158
|
+
return value != null && value !== !1;
|
|
159
|
+
}
|
|
160
160
|
function normalizeDynamicRenderer(value) {
|
|
161
161
|
if (value) {
|
|
162
162
|
if (typeof value == "string") return value;
|
|
@@ -212,11 +212,26 @@ function parseHTML(html, ns) {
|
|
|
212
212
|
function createScope($global, closestBranch) {
|
|
213
213
|
let scope = {
|
|
214
214
|
L: nextScopeId++,
|
|
215
|
-
H:
|
|
215
|
+
H: runId,
|
|
216
216
|
F: closestBranch,
|
|
217
217
|
$: $global
|
|
218
218
|
};
|
|
219
|
-
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
|
+
}
|
|
220
235
|
}
|
|
221
236
|
function skipScope() {
|
|
222
237
|
return nextScopeId++;
|
|
@@ -230,7 +245,7 @@ function destroyBranch(branch) {
|
|
|
230
245
|
branch.N?.D?.delete(branch), destroyNestedScopes(branch);
|
|
231
246
|
}
|
|
232
247
|
function destroyScope(scope) {
|
|
233
|
-
scope.
|
|
248
|
+
scope.H && (destroyNestedScopes(scope), resetControllers(scope));
|
|
234
249
|
}
|
|
235
250
|
function resetControllers(scope) {
|
|
236
251
|
for (let id in scope.A) $signalReset(scope, id);
|
|
@@ -262,7 +277,7 @@ function triggerMacroTask() {
|
|
|
262
277
|
//#region src/dom/signals.ts
|
|
263
278
|
function _let(id, fn) {
|
|
264
279
|
let valueAccessor = decodeAccessor(id);
|
|
265
|
-
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);
|
|
266
281
|
}
|
|
267
282
|
function _let_change(id, fn) {
|
|
268
283
|
let valueAccessor = decodeAccessor(id), valueChangeAccessor = "M" + valueAccessor, base = _let(id, fn);
|
|
@@ -275,7 +290,7 @@ function _const(valueAccessor, fn) {
|
|
|
275
290
|
}
|
|
276
291
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L") {
|
|
277
292
|
return scopeIdAccessor !== "L" && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
|
|
278
|
-
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]);
|
|
279
294
|
};
|
|
280
295
|
}
|
|
281
296
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
@@ -283,7 +298,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
283
298
|
let scopeAccessor = "A" + ownerLoopNodeAccessor, ownerSignal = (ownerScope) => {
|
|
284
299
|
let scopes = toArray(ownerScope[scopeAccessor]);
|
|
285
300
|
scopes.length && queueRender(ownerScope, () => {
|
|
286
|
-
for (let scope of scopes)
|
|
301
|
+
for (let scope of scopes) scope.H > 0 && scope.H < runId && fn(scope);
|
|
287
302
|
}, -1, 0, scopes[0].L);
|
|
288
303
|
};
|
|
289
304
|
return ownerSignal._ = fn, ownerSignal;
|
|
@@ -292,7 +307,7 @@ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
|
292
307
|
ownerConditionalNodeAccessor = decodeAccessor(ownerConditionalNodeAccessor);
|
|
293
308
|
let scopeAccessor = "A" + ownerConditionalNodeAccessor, branchAccessor = "D" + ownerConditionalNodeAccessor, ownerSignal = (scope) => {
|
|
294
309
|
let ifScope = scope[scopeAccessor];
|
|
295
|
-
ifScope &&
|
|
310
|
+
ifScope && ifScope.H > 0 && ifScope.H < runId && (scope[branchAccessor] || 0) === branch && queueRender(ifScope, fn, -1);
|
|
296
311
|
};
|
|
297
312
|
return ownerSignal._ = fn, ownerSignal;
|
|
298
313
|
}
|
|
@@ -304,7 +319,7 @@ function _closure(...closureSignals) {
|
|
|
304
319
|
let [firstSignal] = closureSignals, scopeInstances = firstSignal.a, signalIndex = firstSignal.b;
|
|
305
320
|
for (let i = closureSignals.length; i--;) closureSignals[i].c = i;
|
|
306
321
|
return (scope) => {
|
|
307
|
-
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);
|
|
308
323
|
};
|
|
309
324
|
}
|
|
310
325
|
function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
@@ -436,7 +451,7 @@ function init(runtimeId = "M") {
|
|
|
436
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] ||= {
|
|
437
452
|
runtimeId,
|
|
438
453
|
renderId
|
|
439
|
-
}, 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) => {
|
|
440
455
|
let scopeId = partials[0];
|
|
441
456
|
for (let i = 1; i < partials.length; i++) {
|
|
442
457
|
let partial = partials[i];
|
|
@@ -521,15 +536,15 @@ function _el(id, accessor) {
|
|
|
521
536
|
//#endregion
|
|
522
537
|
//#region src/dom/controllable.ts
|
|
523
538
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
524
|
-
let el = scope[nodeAccessor], normalizedChecked =
|
|
539
|
+
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
525
540
|
if (el.defaultChecked !== normalizedChecked) {
|
|
526
|
-
let restoreValue = scope.H
|
|
541
|
+
let restoreValue = scope.H < runId ? el.checked : normalizedChecked;
|
|
527
542
|
el.defaultChecked = normalizedChecked, restoreValue !== normalizedChecked && (el.checked = restoreValue);
|
|
528
543
|
}
|
|
529
544
|
}
|
|
530
545
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
531
|
-
let el = scope[nodeAccessor], normalizedChecked =
|
|
532
|
-
scope["E" + nodeAccessor] = checkedChange, scope["F" + nodeAccessor] = checkedChange ? 0 : 5, checkedChange &&
|
|
546
|
+
let el = scope[nodeAccessor], normalizedChecked = isNotVoid(checked);
|
|
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);
|
|
533
548
|
}
|
|
534
549
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
535
550
|
let el = scope[nodeAccessor];
|
|
@@ -543,11 +558,11 @@ function _attr_input_checked_script(scope, nodeAccessor) {
|
|
|
543
558
|
}
|
|
544
559
|
function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value) {
|
|
545
560
|
let multiple = Array.isArray(checkedValue), normalizedValue = normalizeStrProp(value), normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
546
|
-
_attr(scope[nodeAccessor], "value",
|
|
561
|
+
_attr(scope[nodeAccessor], "value", value), _attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
|
|
547
562
|
}
|
|
548
563
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
549
|
-
let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue),
|
|
550
|
-
|
|
564
|
+
let el = scope[nodeAccessor], multiple = Array.isArray(checkedValue), normalizedCheckedValue = scope["G" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
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);
|
|
551
566
|
}
|
|
552
567
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
553
568
|
let el = scope[nodeAccessor];
|
|
@@ -562,15 +577,15 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
|
562
577
|
});
|
|
563
578
|
}
|
|
564
579
|
function _attr_input_value_default(scope, nodeAccessor, value) {
|
|
565
|
-
let el = scope[nodeAccessor], normalizedValue =
|
|
580
|
+
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
566
581
|
if (el.defaultValue !== normalizedValue) {
|
|
567
|
-
let restoreValue = scope.H
|
|
582
|
+
let restoreValue = scope.H < runId ? el.value : normalizedValue;
|
|
568
583
|
el.defaultValue = normalizedValue, setInputValue(el, restoreValue);
|
|
569
584
|
}
|
|
570
585
|
}
|
|
571
586
|
function _attr_input_value(scope, nodeAccessor, value, valueChange) {
|
|
572
|
-
let el = scope[nodeAccessor], normalizedValue =
|
|
573
|
-
scope["E" + nodeAccessor] = valueChange, scope["G" + nodeAccessor] = normalizedValue, scope["F" + nodeAccessor] = valueChange ? 2 : 5, valueChange &&
|
|
587
|
+
let el = scope[nodeAccessor], normalizedValue = normalizeAttrValue(value) || "";
|
|
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);
|
|
574
589
|
}
|
|
575
590
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
576
591
|
let el = scope[nodeAccessor];
|
|
@@ -586,17 +601,17 @@ function setInputValue(el, value) {
|
|
|
586
601
|
}
|
|
587
602
|
}
|
|
588
603
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
589
|
-
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);
|
|
590
605
|
pendingEffects.unshift(() => {
|
|
591
606
|
for (let opt of el.options) {
|
|
592
607
|
let selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
|
|
593
|
-
opt.defaultSelected !== selected && (
|
|
608
|
+
opt.defaultSelected !== selected && (live && (restoreValue ??= getSelectValue(el, multiple)), opt.defaultSelected = selected);
|
|
594
609
|
}
|
|
595
610
|
restoreValue !== void 0 && setSelectValue(el, restoreValue, multiple);
|
|
596
611
|
}, scope);
|
|
597
612
|
}
|
|
598
613
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
599
|
-
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);
|
|
600
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);
|
|
601
616
|
}
|
|
602
617
|
function _attr_select_value_script(scope, nodeAccessor) {
|
|
@@ -633,11 +648,11 @@ function getSelectValue(el, multiple) {
|
|
|
633
648
|
return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
|
|
634
649
|
}
|
|
635
650
|
function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
636
|
-
scope.H && (scope[nodeAccessor].open =
|
|
651
|
+
scope.H === runId && (scope[nodeAccessor].open = isNotVoid(open));
|
|
637
652
|
}
|
|
638
653
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
639
|
-
let normalizedOpen = scope["G" + nodeAccessor] =
|
|
640
|
-
scope["E" + nodeAccessor] = openChange, scope["F" + nodeAccessor] = openChange ? 4 : 5, openChange &&
|
|
654
|
+
let normalizedOpen = scope["G" + nodeAccessor] = isNotVoid(open);
|
|
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);
|
|
641
656
|
}
|
|
642
657
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
643
658
|
let el = scope[nodeAccessor];
|
|
@@ -680,9 +695,6 @@ function hasFormElementChanged(el) {
|
|
|
680
695
|
function normalizeStrProp(value) {
|
|
681
696
|
return normalizeAttrValue(value) || "";
|
|
682
697
|
}
|
|
683
|
-
function normalizeBoolProp(value) {
|
|
684
|
-
return value != null && value !== !1;
|
|
685
|
-
}
|
|
686
698
|
function updateList(arr, val, push) {
|
|
687
699
|
let index = arr.indexOf(val);
|
|
688
700
|
return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
|
|
@@ -827,7 +839,7 @@ function normalizeClientRender(value) {
|
|
|
827
839
|
if (renderer && renderer.a) return renderer;
|
|
828
840
|
}
|
|
829
841
|
function normalizeAttrValue(value) {
|
|
830
|
-
if (value
|
|
842
|
+
if (isNotVoid(value)) return value === !0 ? "" : value + "";
|
|
831
843
|
}
|
|
832
844
|
function _lifecycle(scope, thisObj, index = 0) {
|
|
833
845
|
let accessor = "K" + index, instance = scope[accessor];
|
|
@@ -872,7 +884,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
872
884
|
if (thisPromise === scope[promiseAccessor]) {
|
|
873
885
|
let referenceNode = scope[nodeAccessor];
|
|
874
886
|
scope[promiseAccessor] = 0, queueAsyncRender(scope, () => {
|
|
875
|
-
(awaitBranch = scope[branchAccessor]).V && (
|
|
887
|
+
(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
888
|
let pendingRenders = awaitBranch.W;
|
|
877
889
|
if (awaitBranch.W = 0, pendingRenders?.forEach(queuePendingRender), placeholderShown.add(pendingEffects), awaitCounter.c(), awaitCounter.m) {
|
|
878
890
|
let fnScopes = /* @__PURE__ */ new Map(), effects = awaitCounter.m([]);
|
|
@@ -896,7 +908,8 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
896
908
|
nodeAccessor = decodeAccessor(nodeAccessor);
|
|
897
909
|
let branchAccessor = "A" + nodeAccessor, renderer = _content("", template, walks, setup)();
|
|
898
910
|
return (scope) => {
|
|
899
|
-
(scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer
|
|
911
|
+
let pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope.$, renderer, scope, scope[nodeAccessor].parentNode)).V = renderer);
|
|
912
|
+
scope[branchAccessor].Y = pendingScopes;
|
|
900
913
|
};
|
|
901
914
|
}
|
|
902
915
|
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "Q")) {
|
|
@@ -1068,12 +1081,10 @@ function runRenders() {
|
|
|
1068
1081
|
}
|
|
1069
1082
|
runRender(render);
|
|
1070
1083
|
}
|
|
1071
|
-
for (let scope of pendingScopes) scope.H = 0;
|
|
1072
|
-
pendingScopes = [];
|
|
1073
1084
|
}
|
|
1074
1085
|
function skipDestroyedRenders() {
|
|
1075
1086
|
runRender = ((runRender) => (render) => {
|
|
1076
|
-
render.b.F?.
|
|
1087
|
+
render.b.F?.H !== 0 && runRender(render);
|
|
1077
1088
|
})(runRender);
|
|
1078
1089
|
}
|
|
1079
1090
|
function _enable_catch() {
|
|
@@ -1088,7 +1099,7 @@ function _enable_catch() {
|
|
|
1088
1099
|
runEffects = ((runEffects) => (effects, checkPending = placeholderShown.has(effects)) => {
|
|
1089
1100
|
if (checkPending || caughtError.has(effects)) {
|
|
1090
1101
|
let i = 0, fn, scope, branch;
|
|
1091
|
-
for (; i < effects.length;) fn = effects[i++], scope = effects[i++], branch = scope.F
|
|
1102
|
+
for (; i < effects.length;) fn = effects[i++], scope = effects[i++], (branch = scope.F)?.H !== 0 && !(checkPending && handlePendingTry(fn, scope, branch)) && fn(scope);
|
|
1092
1103
|
} else runEffects(effects);
|
|
1093
1104
|
})(runEffects), runRender = ((runRender) => (render) => {
|
|
1094
1105
|
try {
|
|
@@ -1192,8 +1203,8 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
1192
1203
|
}
|
|
1193
1204
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
1194
1205
|
let parent = marker.parentNode;
|
|
1195
|
-
branch
|
|
1196
|
-
insertBranchBefore(branch, parent, marker), marker.remove(),
|
|
1206
|
+
syncGen(branch), renderer.b(branch, parent.namespaceURI), setupBranch(renderer, branch), applyLoad(branch, () => {
|
|
1207
|
+
insertBranchBefore(branch, parent, marker), marker.remove(), awaitCounter?.c();
|
|
1197
1208
|
});
|
|
1198
1209
|
}
|
|
1199
1210
|
function loadFailed(scope, awaitCounter) {
|
|
@@ -1204,16 +1215,16 @@ function loadFailed(scope, awaitCounter) {
|
|
|
1204
1215
|
function applyLoad(scope, insert) {
|
|
1205
1216
|
let values = scope.X, remaining;
|
|
1206
1217
|
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
|
-
})
|
|
1218
|
+
entry.b = signal, --remaining || queueAsyncRender(scope, (scope) => {
|
|
1219
|
+
syncGen(scope), values.forEach((e) => e.b._(scope, e.a)), insert();
|
|
1220
|
+
});
|
|
1210
1221
|
}, () => 0);
|
|
1211
1222
|
else insert();
|
|
1212
1223
|
}
|
|
1213
1224
|
function _load_signal(load) {
|
|
1214
1225
|
let pending, signal;
|
|
1215
1226
|
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);
|
|
1227
|
+
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
1228
|
};
|
|
1218
1229
|
}
|
|
1219
1230
|
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;
|