marko 6.4.9 → 6.4.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cheatsheet.md +1 -1
- package/dist/common/accessor.d.ts +0 -3
- package/dist/common/accessor.debug.d.ts +0 -3
- package/dist/common/helpers.d.ts +1 -1
- package/dist/common/types.d.ts +4 -3
- package/dist/debug/dom/catch.feat.js +2 -3
- package/dist/debug/dom/catch.feat.mjs +2 -3
- package/dist/debug/dom/controllable-input.feat.js +2 -3
- package/dist/debug/dom/controllable-input.feat.mjs +2 -3
- package/dist/debug/dom/controllable-open.feat.js +2 -3
- package/dist/debug/dom/controllable-open.feat.mjs +2 -3
- package/dist/debug/dom/controllable-select.feat.js +2 -3
- package/dist/debug/dom/controllable-select.feat.mjs +2 -3
- package/dist/debug/dom/controllable-textarea.feat.js +2 -3
- package/dist/debug/dom/controllable-textarea.feat.mjs +2 -3
- package/dist/debug/dom/controllable.feat.js +2 -3
- package/dist/debug/dom/controllable.feat.mjs +2 -3
- package/dist/debug/dom/dynamic-tag-script.feat.js +2 -3
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +2 -3
- package/dist/debug/dom/dynamic-tag-var.feat.js +2 -3
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +2 -3
- package/dist/debug/dom/lazy.feat.js +2 -3
- package/dist/debug/dom/lazy.feat.mjs +2 -3
- package/dist/debug/dom/placeholder.feat.js +2 -3
- package/dist/debug/dom/placeholder.feat.mjs +2 -3
- package/dist/debug/{dom-VKjkbuuo.mjs → dom-DjUZd-9y.mjs} +221 -261
- package/dist/debug/{dom-QkYva5Qx.js → dom-mQ5mPBTF.js} +226 -260
- package/dist/debug/dom.js +10 -18
- package/dist/debug/dom.mjs +10 -19
- package/dist/debug/html.js +87 -125
- package/dist/debug/html.mjs +87 -125
- package/dist/dom/abort-signal.d.ts +1 -1
- package/dist/dom/catch.feat.js +4 -5
- package/dist/dom/catch.feat.mjs +2 -3
- package/dist/dom/control-flow.d.ts +4 -4
- package/dist/dom/controllable-input.feat.js +1 -2
- package/dist/dom/controllable-input.feat.mjs +1 -2
- package/dist/dom/controllable-open.feat.js +2 -3
- package/dist/dom/controllable-open.feat.mjs +2 -3
- package/dist/dom/controllable-select.feat.js +2 -3
- package/dist/dom/controllable-select.feat.mjs +2 -3
- package/dist/dom/controllable-textarea.feat.js +2 -3
- package/dist/dom/controllable-textarea.feat.mjs +2 -3
- package/dist/dom/controllable.feat.js +1 -2
- package/dist/dom/controllable.feat.mjs +1 -2
- package/dist/dom/dynamic-tag-script.feat.js +3 -4
- package/dist/dom/dynamic-tag-script.feat.mjs +2 -3
- package/dist/dom/dynamic-tag-var.feat.js +3 -4
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -2
- package/dist/dom/lazy.feat.js +2 -3
- package/dist/dom/lazy.feat.mjs +2 -3
- package/dist/dom/load.d.ts +3 -4
- package/dist/dom/placeholder.feat.js +2 -3
- package/dist/dom/placeholder.feat.mjs +2 -3
- package/dist/dom/queue.d.ts +1 -2
- package/dist/dom/signals.d.ts +5 -7
- package/dist/{dom-IujlfJ6b.js → dom-B8j2453O.js} +158 -190
- package/dist/{dom-DtKQb840.mjs → dom-HEWdZCCb.mjs} +134 -172
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +22 -30
- package/dist/dom.mjs +10 -19
- package/dist/html/assets.d.ts +3 -4
- package/dist/html/for.d.ts +0 -1
- package/dist/html/writer.d.ts +2 -2
- package/dist/html.d.ts +1 -1
- package/dist/html.js +99 -131
- package/dist/html.mjs +99 -132
- package/dist/translator/index.d.ts +0 -1
- package/dist/translator/index.js +4771 -4760
- package/dist/translator/interop/out-global.d.ts +5 -0
- package/dist/translator/util/assert.d.ts +13 -2
- package/dist/translator/util/entry-builder.d.ts +1 -1
- package/dist/translator/util/finalize-references.d.ts +2 -1
- package/dist/translator/util/for-selector.d.ts +1 -1
- package/dist/translator/util/known-tag.d.ts +10 -1
- package/dist/translator/util/references.d.ts +11 -5
- package/dist/translator/util/runtime.d.ts +1 -0
- package/dist/translator/util/sections.d.ts +6 -1
- package/dist/translator/util/signals.d.ts +2 -1
- package/dist/translator/util/sources.d.ts +1 -1
- package/dist/translator/util/style-interpolation.d.ts +1 -1
- package/dist/translator/util/tag-name-type.d.ts +4 -0
- package/dist/translator/util/visitors.d.ts +1 -1
- package/dist/translator/util/write-guard.d.ts +2 -0
- package/dist/translator/visitors/program/index.d.ts +0 -4
- package/dist/translator/visitors/referenced-identifier.d.ts +3 -1
- package/package.json +6 -6
- package/tags/lifecycle.d.marko +2 -0
- package/dist/common/constants/keyed-scopes-prop.d.ts +0 -4
- package/dist/common/constants/keyed-scopes-prop.debug.d.ts +0 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/common/constants/accessor-prefix.debug.ts
|
|
2
2
|
const BranchScopes$1 = "BranchScopes:";
|
|
3
3
|
const ClosureScopes = "ClosureScopes:";
|
|
4
4
|
const ClosureSignalIndex = "ClosureSignalIndex:";
|
|
@@ -15,8 +15,7 @@ const Lifecycle = "Lifecycle:";
|
|
|
15
15
|
const Promise$1 = "Promise:";
|
|
16
16
|
const TagVariableChange$1 = "TagVariableChange:";
|
|
17
17
|
const TryBranch$1 = "TryBranch:";
|
|
18
|
-
|
|
19
|
-
//#region src/common/constants/accessor-prop.debug.ts
|
|
18
|
+
// src/common/constants/accessor-prop.debug.ts
|
|
20
19
|
const Global = "$global";
|
|
21
20
|
const AbortControllers = "#AbortControllers";
|
|
22
21
|
const AbortScopes = "#AbortScopes";
|
|
@@ -46,17 +45,12 @@ const Subscriptions = "#Subscriptions";
|
|
|
46
45
|
const TagVariable = "#TagVariable";
|
|
47
46
|
const TagVariableChange = "#TagVariableChange";
|
|
48
47
|
const TryBranch = "#TryBranch";
|
|
49
|
-
|
|
50
|
-
//#region src/common/constants/closure-scopes-prop.debug.ts
|
|
48
|
+
// src/common/constants/closure-scopes-prop.debug.ts
|
|
51
49
|
const Changed = "Changed";
|
|
52
|
-
|
|
53
|
-
//#region src/common/constants/closure-signal-prop.debug.ts
|
|
50
|
+
// src/common/constants/closure-signal-prop.debug.ts
|
|
54
51
|
const ScopesAccessor = "scopesAccessor";
|
|
55
52
|
const SignalIndexAccessor = "signalIndexAccessor";
|
|
56
53
|
const Index = "index";
|
|
57
|
-
//#endregion
|
|
58
|
-
//#region src/common/constants/keyed-scopes-prop.debug.ts
|
|
59
|
-
const PreviousKey = "PreviousKey:";
|
|
60
54
|
const Scope = "scope";
|
|
61
55
|
const Signal = "signal";
|
|
62
56
|
const Value = "value";
|
|
@@ -69,8 +63,7 @@ const Accessor = "accessor";
|
|
|
69
63
|
const LocalClosures = "localClosures";
|
|
70
64
|
const Returns = "returns";
|
|
71
65
|
const Lazy = "lazy";
|
|
72
|
-
|
|
73
|
-
//#region src/common/helpers.ts
|
|
66
|
+
// src/common/helpers.ts
|
|
74
67
|
const invalidNativeAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
75
68
|
const knownWrongAttrs = {
|
|
76
69
|
className: "class",
|
|
@@ -138,7 +131,7 @@ function escapeStyleValue(str) {
|
|
|
138
131
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
139
132
|
return result + closers;
|
|
140
133
|
}
|
|
141
|
-
|
|
134
|
+
function toDelimitedString(val, delimiter, stringify) {
|
|
142
135
|
let str = "";
|
|
143
136
|
let sep = "";
|
|
144
137
|
let part;
|
|
@@ -160,7 +153,7 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
160
153
|
}
|
|
161
154
|
}
|
|
162
155
|
return str;
|
|
163
|
-
}
|
|
156
|
+
}
|
|
164
157
|
function isEventHandler(name) {
|
|
165
158
|
return /^on[A-Z-]/.test(name);
|
|
166
159
|
}
|
|
@@ -194,8 +187,7 @@ function withDynamicHtml(runtime) {
|
|
|
194
187
|
dynamicHtmlEnabled = 1;
|
|
195
188
|
return runtime;
|
|
196
189
|
}
|
|
197
|
-
|
|
198
|
-
//#region src/common/errors.ts
|
|
190
|
+
// src/common/errors.ts
|
|
199
191
|
const lowercaseOnAttrReg = /^on[a-z]/;
|
|
200
192
|
function assertValidAttrValue(name, value) {
|
|
201
193
|
if (value && typeof value !== "string" && lowercaseOnAttrReg.test(name)) throw new Error(`The \`${name}\` attribute must be a string or a falsey value (\`null\`, \`undefined\`, \`false\`, \`0\`, …), but received type "${typeof value}". To attach an event listener, use the \`on${name[2].toUpperCase()}${name.slice(3)}\` event handler instead.`);
|
|
@@ -310,8 +302,7 @@ function joinWithAnd(a) {
|
|
|
310
302
|
default: return `${a.slice(0, -1).join(", ")}, and ${a[a.length - 1]}`;
|
|
311
303
|
}
|
|
312
304
|
}
|
|
313
|
-
|
|
314
|
-
//#region src/common/for.ts
|
|
305
|
+
// src/common/for.ts
|
|
315
306
|
function forIn(obj, cb) {
|
|
316
307
|
for (const key in obj) cb(key, obj[key]);
|
|
317
308
|
}
|
|
@@ -338,8 +329,7 @@ function forUntil(until, from, step, cb) {
|
|
|
338
329
|
const delta = step || 1;
|
|
339
330
|
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
340
331
|
}
|
|
341
|
-
|
|
342
|
-
//#region src/dom/queue.ts
|
|
332
|
+
// src/dom/queue.ts
|
|
343
333
|
let rendering;
|
|
344
334
|
let runId = 2;
|
|
345
335
|
let pendingEffects = [];
|
|
@@ -442,9 +432,9 @@ function prepareEffects(fn) {
|
|
|
442
432
|
}
|
|
443
433
|
return preparedEffects;
|
|
444
434
|
}
|
|
445
|
-
let runEffects = (
|
|
435
|
+
let runEffects = (effects) => {
|
|
446
436
|
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
447
|
-
}
|
|
437
|
+
};
|
|
448
438
|
let runRender = (render) => {
|
|
449
439
|
if (!branchesEnabled || render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) render[Signal](render[Scope], render[Value]);
|
|
450
440
|
};
|
|
@@ -479,8 +469,7 @@ function runRenders(renders = pendingRenders) {
|
|
|
479
469
|
runRender(render);
|
|
480
470
|
}
|
|
481
471
|
}
|
|
482
|
-
|
|
483
|
-
//#region src/dom/abort-signal.ts
|
|
472
|
+
// src/dom/abort-signal.ts
|
|
484
473
|
function $signalReset(scope, id) {
|
|
485
474
|
const ctrl = scope[AbortControllers]?.[id];
|
|
486
475
|
if (ctrl) {
|
|
@@ -495,7 +484,7 @@ function $signal(scope, id) {
|
|
|
495
484
|
return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
|
|
496
485
|
}
|
|
497
486
|
/** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
|
|
498
|
-
function
|
|
487
|
+
function onAbort(scope, id, abort) {
|
|
499
488
|
abortsEnabled = 1;
|
|
500
489
|
trackCleanup(scope);
|
|
501
490
|
(scope[AbortControllers] ||= {})[id] = { abort };
|
|
@@ -514,8 +503,7 @@ let subscriptionsEnabled;
|
|
|
514
503
|
function abort(ctrl) {
|
|
515
504
|
ctrl.abort();
|
|
516
505
|
}
|
|
517
|
-
|
|
518
|
-
//#region src/common/opt.ts
|
|
506
|
+
// src/common/opt.ts
|
|
519
507
|
function toArray(opt) {
|
|
520
508
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
521
509
|
}
|
|
@@ -528,8 +516,7 @@ function forEach(opt, cb) {
|
|
|
528
516
|
function push(opt, item) {
|
|
529
517
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
530
518
|
}
|
|
531
|
-
|
|
532
|
-
//#region src/dom/event.ts
|
|
519
|
+
// src/dom/event.ts
|
|
533
520
|
function _on(element, type, handler) {
|
|
534
521
|
assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
|
|
535
522
|
delegate(type, handleDelegated);
|
|
@@ -551,21 +538,18 @@ function handleDelegated(ev) {
|
|
|
551
538
|
}
|
|
552
539
|
delete ev.currentTarget;
|
|
553
540
|
}
|
|
554
|
-
|
|
555
|
-
//#region src/dom/parse-html.ts
|
|
541
|
+
// src/dom/parse-html.ts
|
|
556
542
|
const parsers = {};
|
|
557
543
|
function parseHTML(html, ns) {
|
|
558
544
|
const parser = parsers[ns] ||= document.createElementNS(ns, "template");
|
|
559
545
|
parser.innerHTML = html;
|
|
560
546
|
return parser.content || parser;
|
|
561
547
|
}
|
|
562
|
-
|
|
563
|
-
//#region src/common/meta.ts
|
|
548
|
+
// src/common/meta.ts
|
|
564
549
|
const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
565
550
|
const DYNAMIC_TAG_VAR_REGISTER_ID = "_dynamicTagVar";
|
|
566
551
|
const PLACEHOLDER_DISMISS_REGISTER_ID = "_placeholderDismiss";
|
|
567
|
-
|
|
568
|
-
//#region src/dom/scope.ts
|
|
552
|
+
// src/dom/scope.ts
|
|
569
553
|
let nextScopeId = 1e6;
|
|
570
554
|
let collectingScopes;
|
|
571
555
|
function createScope($global, closestBranch) {
|
|
@@ -599,7 +583,7 @@ function skipScope() {
|
|
|
599
583
|
return nextScopeId++;
|
|
600
584
|
}
|
|
601
585
|
function destroyBranch(branch) {
|
|
602
|
-
branch[ParentBranch]?.[BranchScopes]
|
|
586
|
+
branch[ParentBranch]?.[BranchScopes].delete(branch);
|
|
603
587
|
destroyNestedScopes(branch);
|
|
604
588
|
}
|
|
605
589
|
function destroyScope(scope) {
|
|
@@ -608,11 +592,11 @@ function destroyScope(scope) {
|
|
|
608
592
|
cleanupScope(scope);
|
|
609
593
|
}
|
|
610
594
|
}
|
|
611
|
-
|
|
595
|
+
function destroyNestedScopes(scope) {
|
|
612
596
|
scope[Gen$1] = 0;
|
|
613
597
|
scope[BranchScopes]?.forEach(destroyNestedScopes);
|
|
614
598
|
scope[AbortScopes]?.forEach(cleanupScope);
|
|
615
|
-
}
|
|
599
|
+
}
|
|
616
600
|
function cleanupScope(scope) {
|
|
617
601
|
if (subscriptionsEnabled) scope[Subscriptions]?.forEach(unsubscribe, scope);
|
|
618
602
|
if (abortsEnabled) for (const id in scope[AbortControllers]) $signalReset(scope, id);
|
|
@@ -632,8 +616,7 @@ function detachBranch(branch) {
|
|
|
632
616
|
fragment.namespaceURI = branch[StartNode].parentNode.namespaceURI;
|
|
633
617
|
insertChildNodes(fragment, null, branch[StartNode], branch[EndNode]);
|
|
634
618
|
}
|
|
635
|
-
|
|
636
|
-
//#region src/dom/schedule.ts
|
|
619
|
+
// src/dom/schedule.ts
|
|
637
620
|
let runTask;
|
|
638
621
|
let isScheduled;
|
|
639
622
|
let channel;
|
|
@@ -665,8 +648,7 @@ function triggerMacroTask() {
|
|
|
665
648
|
}
|
|
666
649
|
channel.port2.postMessage(0);
|
|
667
650
|
}
|
|
668
|
-
|
|
669
|
-
//#region src/dom/signals.ts
|
|
651
|
+
// src/dom/signals.ts
|
|
670
652
|
function _let(id, fn) {
|
|
671
653
|
const valueAccessor = id.slice(0, id.lastIndexOf("/"));
|
|
672
654
|
id = +id.slice(id.lastIndexOf("/") + 1);
|
|
@@ -706,7 +688,8 @@ function _const(valueAccessor, fn) {
|
|
|
706
688
|
}
|
|
707
689
|
});
|
|
708
690
|
}
|
|
709
|
-
function _or(id, fn, defaultPending = 1, scopeIdAccessor
|
|
691
|
+
function _or(id, fn, defaultPending = 1, scopeIdAccessor) {
|
|
692
|
+
scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
|
|
710
693
|
return (scope) => {
|
|
711
694
|
if (scope["#Gen"] === runId) {
|
|
712
695
|
if (~id in scope) {
|
|
@@ -715,36 +698,33 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
|
715
698
|
} else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
716
699
|
};
|
|
717
700
|
}
|
|
718
|
-
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
701
|
+
function _for_closure(ownerLoopNodeAccessor, fn, id, scopeIdAccessor) {
|
|
702
|
+
scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
|
|
719
703
|
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
720
|
-
const
|
|
721
|
-
const
|
|
722
|
-
queueRender(ownerScope, (_) => {
|
|
723
|
-
for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
|
|
724
|
-
}, -1);
|
|
704
|
+
const render = (ownerScope) => {
|
|
705
|
+
for (const scope of toArray(ownerScope[scopeAccessor])) if (scope["#Gen"] < runId) fn(scope);
|
|
725
706
|
};
|
|
707
|
+
const ownerSignal = (ownerScope) => queueRender(ownerScope, render, id, 0, ownerScope[scopeIdAccessor]);
|
|
726
708
|
ownerSignal._ = (scope) => queueRender(scope, fn, -1);
|
|
727
709
|
return ownerSignal;
|
|
728
710
|
}
|
|
729
|
-
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn) {
|
|
711
|
+
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn, getValueScope) {
|
|
730
712
|
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
731
713
|
const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
|
|
732
|
-
const
|
|
714
|
+
const prevKey = Symbol(ownerValueAccessor);
|
|
733
715
|
const ownerSignal = (ownerScope) => {
|
|
734
716
|
if (ownerScope["#Gen"] < runId) {
|
|
735
|
-
const nextKey = ownerScope[ownerValueAccessor];
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
if (map) map[prevKeyProp] = nextKey;
|
|
747
|
-
}, -1);
|
|
717
|
+
const nextKey = (getValueScope ? getValueScope(ownerScope) : ownerScope)[ownerValueAccessor];
|
|
718
|
+
const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor);
|
|
719
|
+
if (map && prevKey in ownerScope) {
|
|
720
|
+
const prevScope = map.get(ownerScope[prevKey]);
|
|
721
|
+
const nextScope = map.get(nextKey);
|
|
722
|
+
if (prevScope !== nextScope) {
|
|
723
|
+
queueLiveBranch(prevScope, fn);
|
|
724
|
+
queueLiveBranch(nextScope, fn);
|
|
725
|
+
}
|
|
726
|
+
} else for (const scope of toArray(ownerScope[scopeAccessor])) queueLiveBranch(scope, fn);
|
|
727
|
+
ownerScope[prevKey] = nextKey;
|
|
748
728
|
}
|
|
749
729
|
};
|
|
750
730
|
ownerSignal._ = (scope) => queueRender(scope, fn, -1);
|
|
@@ -759,8 +739,8 @@ function keyedScopes(ownerScope, scopeAccessor, mapAccessor) {
|
|
|
759
739
|
}
|
|
760
740
|
return map;
|
|
761
741
|
}
|
|
762
|
-
function
|
|
763
|
-
if (scope
|
|
742
|
+
function queueLiveBranch(scope, fn) {
|
|
743
|
+
if (scope?.["#Gen"] < runId) queueRender(scope, fn, -1);
|
|
764
744
|
}
|
|
765
745
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
766
746
|
const scopeAccessor = BranchScopes$1 + ownerConditionalNodeAccessor;
|
|
@@ -829,9 +809,7 @@ function _id(scope, accessor) {
|
|
|
829
809
|
}
|
|
830
810
|
function _script(id, fn) {
|
|
831
811
|
_resumed[id] = fn;
|
|
832
|
-
return (scope) =>
|
|
833
|
-
queueEffect(scope, fn);
|
|
834
|
-
};
|
|
812
|
+
return (scope) => queueEffect(scope, fn);
|
|
835
813
|
}
|
|
836
814
|
function _global_read($global, key) {
|
|
837
815
|
if (!(key in $global)) console.error(`\`$global.${key}\` is not serialized to the client, so this read is \`undefined\`. Serialized globals are embedded in the page: add \`${key}\` to \`serializedGlobals\` at the render call only if it holds no secrets; otherwise copy the field the client needs into its own \`$global\` key and serialize that.`);
|
|
@@ -864,15 +842,14 @@ function _hoist(...path) {
|
|
|
864
842
|
function _hoist_resume(id, ...path) {
|
|
865
843
|
return _resumed[id] = _hoist(...path);
|
|
866
844
|
}
|
|
867
|
-
|
|
868
|
-
//#region src/dom/walker.ts
|
|
845
|
+
// src/dom/walker.ts
|
|
869
846
|
/** Cloned templates are small, where a TreeWalker's per-step cost dominates. */
|
|
870
847
|
let currentNode;
|
|
871
848
|
function walk(startNode, walkCodes, branch) {
|
|
872
849
|
currentNode = startNode;
|
|
873
850
|
walkInternal(0, walkCodes, branch);
|
|
874
851
|
}
|
|
875
|
-
|
|
852
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
876
853
|
let value;
|
|
877
854
|
let currentMultiplier;
|
|
878
855
|
let storedMultiplier = 0;
|
|
@@ -908,7 +885,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
908
885
|
storedMultiplier = currentMultiplier * 10 + value - 117;
|
|
909
886
|
}
|
|
910
887
|
}
|
|
911
|
-
}
|
|
888
|
+
}
|
|
912
889
|
function getDebugKey(index, node) {
|
|
913
890
|
if (typeof node === "string") return `${node}/${index}`;
|
|
914
891
|
else if (node.nodeType === 3) return `#text/${index}`;
|
|
@@ -917,8 +894,7 @@ function getDebugKey(index, node) {
|
|
|
917
894
|
return index;
|
|
918
895
|
}
|
|
919
896
|
const walkNextSibling = (_) => currentNode = currentNode.nextSibling || currentNode;
|
|
920
|
-
|
|
921
|
-
//#region src/dom/resume.ts
|
|
897
|
+
// src/dom/resume.ts
|
|
922
898
|
const _resumed = {};
|
|
923
899
|
let curRenders;
|
|
924
900
|
let embedRenders;
|
|
@@ -961,168 +937,166 @@ function init(runtimeId = "M") {
|
|
|
961
937
|
}
|
|
962
938
|
const renders = self[runtimeId];
|
|
963
939
|
const defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc);
|
|
964
|
-
const initRuntime = (renders) => {
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
scopeId++;
|
|
990
|
-
}
|
|
940
|
+
const initRuntime = (renders) => defineRuntime({ value: curRenders = ((renderId) => {
|
|
941
|
+
const render = curRenders[renderId] = renders[renderId] || renders(renderId);
|
|
942
|
+
const walk = render.w;
|
|
943
|
+
const scopeLookup = {};
|
|
944
|
+
const pending = [];
|
|
945
|
+
const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
|
|
946
|
+
const initGlobal = (_) => scopeLookup[0] ||= {
|
|
947
|
+
runtimeId,
|
|
948
|
+
renderId
|
|
949
|
+
};
|
|
950
|
+
const initScope = (scope) => {
|
|
951
|
+
scope[Gen$1] ??= 1;
|
|
952
|
+
scope[Global] = initGlobal();
|
|
953
|
+
if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
|
|
954
|
+
return scope;
|
|
955
|
+
};
|
|
956
|
+
const applyScopes = (partials) => {
|
|
957
|
+
let scopeId = partials[0];
|
|
958
|
+
for (let i = 1; i < partials.length; i++) {
|
|
959
|
+
const partial = partials[i];
|
|
960
|
+
if (typeof partial === "number") scopeId += partial;
|
|
961
|
+
else {
|
|
962
|
+
if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
|
|
963
|
+
else Object.assign(initGlobal(), partial);
|
|
964
|
+
scopeId++;
|
|
991
965
|
}
|
|
992
|
-
}
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
startVisit = branchStarts.pop();
|
|
1025
|
-
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
1026
|
-
branch[StartNode] = startVisit;
|
|
1027
|
-
branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
966
|
+
}
|
|
967
|
+
};
|
|
968
|
+
const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? _resumed[registryId](getScope(data)) : getScope(data) : applyScopes(data));
|
|
969
|
+
const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
|
|
970
|
+
return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
|
|
971
|
+
if (visitType === "*") {
|
|
972
|
+
while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
|
|
973
|
+
if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
976
|
+
if (visitType !== "[") {
|
|
977
|
+
visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
|
|
978
|
+
accessor = BranchScopes$1 + (nodeAccessor = lastToken);
|
|
979
|
+
singleNode = visitType !== "]" && visitType !== ")";
|
|
980
|
+
nextToken();
|
|
981
|
+
}
|
|
982
|
+
while (branchId = +lastToken) {
|
|
983
|
+
(endedBranches ||= []).push(branch = getScope(branchId));
|
|
984
|
+
setParentBranch(branch, branch[ClosestBranch]);
|
|
985
|
+
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
|
|
986
|
+
if (singleNode) {
|
|
987
|
+
while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
|
|
988
|
+
branch["_"] ??= visitScope;
|
|
989
|
+
branch[EndNode] = branch[StartNode] = startVisit;
|
|
990
|
+
if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
991
|
+
} else {
|
|
992
|
+
branch[BranchAccessor] = nodeAccessor;
|
|
993
|
+
curBranchScopes = push(curBranchScopes, branch);
|
|
994
|
+
if (accessor) {
|
|
995
|
+
visitScope[accessor] = curBranchScopes;
|
|
996
|
+
forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
|
|
997
|
+
curBranchScopes = branchScopesStack.pop();
|
|
1028
998
|
}
|
|
1029
|
-
|
|
1030
|
-
|
|
999
|
+
startVisit = branchStarts.pop();
|
|
1000
|
+
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
1001
|
+
branch[StartNode] = startVisit;
|
|
1002
|
+
branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
1031
1003
|
}
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1004
|
+
while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
|
|
1005
|
+
nextToken();
|
|
1006
|
+
}
|
|
1007
|
+
if (endedBranches) {
|
|
1008
|
+
for (const ended of endedBranches) pending.push(ended);
|
|
1009
|
+
if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
|
|
1010
|
+
}
|
|
1011
|
+
if (visitType === "[") {
|
|
1012
|
+
if (!endedBranches) {
|
|
1013
|
+
branchScopesStack.push(curBranchScopes);
|
|
1014
|
+
curBranchScopes = void 0;
|
|
1035
1015
|
}
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
branchScopesStack.push(curBranchScopes);
|
|
1039
|
-
curBranchScopes = void 0;
|
|
1040
|
-
}
|
|
1041
|
-
branchStarts.push(visit);
|
|
1042
|
-
} else pending.push(visitScope);
|
|
1043
|
-
};
|
|
1016
|
+
branchStarts.push(visit);
|
|
1017
|
+
} else pending.push(visitScope);
|
|
1044
1018
|
};
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1019
|
+
};
|
|
1020
|
+
const nextToken = (_) => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
|
|
1021
|
+
const processResumes = (resumes = [], effects) => {
|
|
1022
|
+
let i = 0;
|
|
1023
|
+
for (; i < resumes.length; i++) {
|
|
1024
|
+
const serialized = resumes[i];
|
|
1025
|
+
if (typeof serialized === "string") {
|
|
1026
|
+
lastTokenIndex = 0;
|
|
1027
|
+
visitText = serialized;
|
|
1028
|
+
while (nextToken()) if (/\D/.test(lastToken)) lastEffect = _resumed[lastToken];
|
|
1029
|
+
else effects.push(lastEffect, getScope(lastToken));
|
|
1030
|
+
} else if (Array.isArray(serialized)) {
|
|
1031
|
+
if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
|
|
1032
|
+
} else if (readyIds && typeof serialized === "number") break;
|
|
1033
|
+
else {
|
|
1034
|
+
const scopes = serialized(serializeContext);
|
|
1035
|
+
if (Array.isArray(scopes)) applyScopes(scopes);
|
|
1062
1036
|
}
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1037
|
+
}
|
|
1038
|
+
resumes.splice(0, i);
|
|
1039
|
+
return i;
|
|
1040
|
+
};
|
|
1041
|
+
let lastEffect;
|
|
1042
|
+
let visits;
|
|
1043
|
+
let visit;
|
|
1044
|
+
let visitText;
|
|
1045
|
+
let visitType;
|
|
1046
|
+
let visitScope;
|
|
1047
|
+
let lastToken;
|
|
1048
|
+
let lastTokenIndex;
|
|
1049
|
+
let visitBranches;
|
|
1050
|
+
let htmlStart;
|
|
1051
|
+
let embedAnchor;
|
|
1052
|
+
serializeContext._ = _resumed;
|
|
1053
|
+
if (render.m) throw new Error(`Marko rendered multiple times with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as ${JSON.stringify(renderId)}. Ensure each render into a page has a unique $global.renderId.`);
|
|
1054
|
+
for (const otherId in curRenders) if (otherId !== renderId && (otherId.startsWith(renderId) || renderId.startsWith(otherId))) console.error(`Marko rendered with $global.runtimeId as ${JSON.stringify(runtimeId)} and $global.renderId as both ${JSON.stringify(otherId)} and ${JSON.stringify(renderId)}, so one render claims the other's resume comments. Ensure no $global.renderId in a page starts another.`);
|
|
1055
|
+
render.m = (effects) => {
|
|
1056
|
+
processResumes(render.r, effects);
|
|
1057
|
+
if (readyIds && render.b) for (let progress = 1; progress;) {
|
|
1058
|
+
progress = 0;
|
|
1059
|
+
for (const readyId of readyIds) {
|
|
1060
|
+
const resumes = render.b[readyId];
|
|
1061
|
+
if (resumes && processResumes(resumes, effects)) progress = 1;
|
|
1088
1062
|
}
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
if (visit.parentNode !== htmlStart.parentNode) console.error("An unescaped placeholder (`$!{}`) rendered HTML that does not parse as a balanced fragment where it is placed (an unclosed, stray or misnested tag), so updating it removes the wrong nodes.");
|
|
1099
|
-
visitScope[nextToken()] = htmlStart;
|
|
1100
|
-
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1101
|
-
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1102
|
-
}
|
|
1103
|
-
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1104
|
-
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1063
|
+
}
|
|
1064
|
+
let retained = 0;
|
|
1065
|
+
for (visit of visits = render.v) {
|
|
1066
|
+
lastTokenIndex = render.i.length;
|
|
1067
|
+
visitText = visit.data;
|
|
1068
|
+
visitType = visitText[lastTokenIndex++];
|
|
1069
|
+
visitScope = getScope(nextToken());
|
|
1070
|
+
if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
|
|
1071
|
+
if (visitType === "&") htmlStart = visit;
|
|
1105
1072
|
else {
|
|
1106
|
-
|
|
1073
|
+
if (visit.parentNode !== htmlStart.parentNode) console.error("An unescaped placeholder (`$!{}`) rendered HTML that does not parse as a balanced fragment where it is placed (an unclosed, stray or misnested tag), so updating it removes the wrong nodes.");
|
|
1074
|
+
visitScope[nextToken()] = htmlStart;
|
|
1075
|
+
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1107
1076
|
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1108
1077
|
}
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
visitBranches();
|
|
1078
|
+
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1079
|
+
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1080
|
+
else {
|
|
1081
|
+
visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
|
|
1082
|
+
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1115
1083
|
}
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1084
|
+
if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
|
|
1085
|
+
}
|
|
1086
|
+
if (branchesEnabled && visitBranches) {
|
|
1087
|
+
visitType = "*";
|
|
1088
|
+
lastToken = "";
|
|
1089
|
+
visitBranches();
|
|
1090
|
+
}
|
|
1091
|
+
visits.length = retained;
|
|
1092
|
+
return effects;
|
|
1093
|
+
};
|
|
1094
|
+
render.w = (_) => {
|
|
1095
|
+
walk();
|
|
1096
|
+
runResumeEffects(render);
|
|
1097
|
+
};
|
|
1098
|
+
return render;
|
|
1099
|
+
}) });
|
|
1126
1100
|
if (renders) {
|
|
1127
1101
|
initRuntime(renders);
|
|
1128
1102
|
for (const renderId in renders) runResumeEffects(curRenders(renderId));
|
|
@@ -1153,11 +1127,10 @@ function _el(id, accessor) {
|
|
|
1153
1127
|
function _dynamic_tag_var_resume(accessor) {
|
|
1154
1128
|
_resumed[DYNAMIC_TAG_VAR_REGISTER_ID + accessor] = (scope) => (_) => {
|
|
1155
1129
|
const node = scope[accessor];
|
|
1156
|
-
return _el_read(node.nodeType
|
|
1130
|
+
return _el_read(node.nodeType > 1 ? node.previousSibling : node);
|
|
1157
1131
|
};
|
|
1158
1132
|
}
|
|
1159
|
-
|
|
1160
|
-
//#region src/dom/renderer.ts
|
|
1133
|
+
// src/dom/renderer.ts
|
|
1161
1134
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
1162
1135
|
const branch = createScope($global);
|
|
1163
1136
|
branch["_"] = renderer["owner"] || parentScope;
|
|
@@ -1188,11 +1161,8 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
1188
1161
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
1189
1162
|
setup = setup ? setup._ || setup : void 0;
|
|
1190
1163
|
params ||= void 0;
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1193
|
-
} : (branch) => {
|
|
1194
|
-
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
1195
|
-
};
|
|
1164
|
+
const cloneables = {};
|
|
1165
|
+
const clone = template ? (branch, ns) => (cloneables[ns] ||= createCloneableHTML(template, walks, ns))(branch) : (branch) => walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
1196
1166
|
return _resumed[id] = (owner) => {
|
|
1197
1167
|
return {
|
|
1198
1168
|
["id"]: id,
|
|
@@ -1232,14 +1202,11 @@ function _content_closures(renderer, closureFns) {
|
|
|
1232
1202
|
return instance;
|
|
1233
1203
|
};
|
|
1234
1204
|
}
|
|
1235
|
-
|
|
1236
|
-
function createCloneableHTML(html, ns) {
|
|
1205
|
+
function createCloneableHTML(html, walks, ns) {
|
|
1237
1206
|
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
1238
1207
|
const parent = new DocumentFragment();
|
|
1239
1208
|
insertChildNodes(parent, null, firstChild, lastChild);
|
|
1240
|
-
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
1241
|
-
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
1242
|
-
} : (branch, walks) => {
|
|
1209
|
+
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch) => walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch) : (branch) => {
|
|
1243
1210
|
const clone = parent.cloneNode(true);
|
|
1244
1211
|
clone.namespaceURI = ns;
|
|
1245
1212
|
walk(clone.firstChild, walks, branch);
|
|
@@ -1247,8 +1214,7 @@ function createCloneableHTML(html, ns) {
|
|
|
1247
1214
|
branch[EndNode] = clone.lastChild;
|
|
1248
1215
|
};
|
|
1249
1216
|
}
|
|
1250
|
-
|
|
1251
|
-
//#region src/dom/dom.ts
|
|
1217
|
+
// src/dom/dom.ts
|
|
1252
1218
|
function _to_text(value) {
|
|
1253
1219
|
assertValidTextValue(value);
|
|
1254
1220
|
return value || value === 0 ? value + "" : "";
|
|
@@ -1378,7 +1344,12 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
|
1378
1344
|
}
|
|
1379
1345
|
}
|
|
1380
1346
|
function _attr_content(scope, nodeAccessor, value) {
|
|
1381
|
-
const
|
|
1347
|
+
const renderer = normalizeDynamicRenderer(value);
|
|
1348
|
+
let content;
|
|
1349
|
+
if (renderer) {
|
|
1350
|
+
if (renderer["id"]) content = renderer;
|
|
1351
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1352
|
+
}
|
|
1382
1353
|
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = rendererKey(content))) {
|
|
1383
1354
|
setBranch(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1384
1355
|
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
@@ -1413,13 +1384,6 @@ const _html = /*@__PURE__*/ withDynamicHtml(function _html(scope, value, accesso
|
|
|
1413
1384
|
removeChildNodes(firstChild, lastChild);
|
|
1414
1385
|
}
|
|
1415
1386
|
});
|
|
1416
|
-
function normalizeClientRender(value) {
|
|
1417
|
-
const renderer = normalizeDynamicRenderer(value);
|
|
1418
|
-
if (renderer) {
|
|
1419
|
-
if (renderer["id"]) return renderer;
|
|
1420
|
-
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1421
|
-
}
|
|
1422
|
-
}
|
|
1423
1387
|
function normalizeAttrValue(value) {
|
|
1424
1388
|
if (isNotNullishOrFalse(value)) return value === true ? "" : value + "";
|
|
1425
1389
|
}
|
|
@@ -1436,7 +1400,7 @@ function _lifecycle(scope, thisObj, index = 0) {
|
|
|
1436
1400
|
Object.assign(thisObj, thisObj.onMount?.());
|
|
1437
1401
|
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1438
1402
|
}
|
|
1439
|
-
|
|
1403
|
+
onAbort(scope, accessor, (_) => thisObj.onDestroy?.());
|
|
1440
1404
|
}
|
|
1441
1405
|
}
|
|
1442
1406
|
function removeChildNodes(startNode, endNode) {
|
|
@@ -1455,8 +1419,7 @@ function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
|
|
1455
1419
|
startNode = next;
|
|
1456
1420
|
}
|
|
1457
1421
|
}
|
|
1458
|
-
|
|
1459
|
-
//#region src/dom/resolve-cursor-position.ts
|
|
1422
|
+
// src/dom/resolve-cursor-position.ts
|
|
1460
1423
|
const R = /[\p{L}\p{N}]/gu;
|
|
1461
1424
|
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
1462
1425
|
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
@@ -1470,8 +1433,7 @@ function resolveCursorPosition(inputType, initialPosition, initialValue, updated
|
|
|
1470
1433
|
}
|
|
1471
1434
|
return -1;
|
|
1472
1435
|
}
|
|
1473
|
-
|
|
1474
|
-
//#region src/dom/controllable.ts
|
|
1436
|
+
// src/dom/controllable.ts
|
|
1475
1437
|
let inputType = "";
|
|
1476
1438
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
1477
1439
|
const el = scope[nodeAccessor];
|
|
@@ -1766,8 +1728,7 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
|
|
|
1766
1728
|
return /^open(?:Change)?$/;
|
|
1767
1729
|
}
|
|
1768
1730
|
}
|
|
1769
|
-
|
|
1770
|
-
//#region src/dom/control-flow.ts
|
|
1731
|
+
// src/dom/control-flow.ts
|
|
1771
1732
|
function _await_promise(nodeAccessor, params) {
|
|
1772
1733
|
const promiseAccessor = Promise$1 + nodeAccessor;
|
|
1773
1734
|
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
@@ -1801,7 +1762,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1801
1762
|
let awaitCounter = tryBranch[AwaitCounter];
|
|
1802
1763
|
if (!scope[tryAccessor]) {
|
|
1803
1764
|
scope[tryAccessor] = tryBranch;
|
|
1804
|
-
|
|
1765
|
+
onAbort(scope, promiseAccessor, (_) => {
|
|
1805
1766
|
scope[promiseAccessor] = 0;
|
|
1806
1767
|
if (scope[tryAccessor]) queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
|
|
1807
1768
|
});
|
|
@@ -1979,7 +1940,7 @@ const _show = /*@__PURE__*/ withBranches((nodeAccessor, startNodeAccessor) => {
|
|
|
1979
1940
|
const rangeAccessor = BranchScopes$1 + nodeAccessor;
|
|
1980
1941
|
return (scope, display) => {
|
|
1981
1942
|
const referenceNode = scope[nodeAccessor];
|
|
1982
|
-
const onlyChild = referenceNode.nodeType
|
|
1943
|
+
const onlyChild = referenceNode.nodeType < 3;
|
|
1983
1944
|
const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
|
|
1984
1945
|
let range = scope[rangeAccessor];
|
|
1985
1946
|
if (!range) {
|
|
@@ -2117,7 +2078,7 @@ const loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, tem
|
|
|
2117
2078
|
const oldScope = oldScopes[i];
|
|
2118
2079
|
let branch = oldLen && (oldScopesByKey || key !== (oldScope?.["#LoopKey"] ?? i) ? (oldScopesByKey ||= oldScopes.reduce((map, scope, j) => j < i ? map : (scope["#LoopIndex"] = j, map.set(scope["#LoopKey"] ?? j, scope)), /* @__PURE__ */ new Map())).get(key) : oldScope && (start++, oldScope));
|
|
2119
2080
|
if (branch) {
|
|
2120
|
-
hasPotentialMoves =
|
|
2081
|
+
hasPotentialMoves = 1;
|
|
2121
2082
|
oldScopesByKey?.delete(key);
|
|
2122
2083
|
branch[LoopKey] = key;
|
|
2123
2084
|
} else {
|
|
@@ -2233,5 +2194,4 @@ function bySecondArg(_item, index) {
|
|
|
2233
2194
|
function byFirstArg(name) {
|
|
2234
2195
|
return name;
|
|
2235
2196
|
}
|
|
2236
|
-
|
|
2237
|
-
export { _attr_style_items as $, DYNAMIC_TAG_SCRIPT_REGISTER_ID as $t, _attr_input_value as A, Setup as An, _closure_get as At, _controllable_select as B, ParentBranch as Bn, _let as Bt, _attr_details_or_dialog_open_script as C, withBranches as Cn, getRegisteredWithScope as Ct, _attr_input_checkedValue_script as D, Owner as Dn, readyFailed as Dt, _attr_input_checkedValue_default as E, LocalClosures as En, ready as Et, _attr_select_value as F, ClosestBranch as Fn, _global_read as Ft, _attr_class as G, StartNode as Gn, _script as Gt, controllableScripts as H, PendingEffects as Hn, _or as Ht, _attr_select_value_default as I, EndNode as In, _hoist as It, _attr_class_names as J, _assert_init as Jt, _attr_class_item as K, TagVariable as Kn, _var as Kt, _attr_select_value_script as L, Gen$1 as Ln, _hoist_resume as Lt, _attr_input_value_default as M, Scope as Mn, _el_read as Mt, _attr_input_value_dynamic_default as N, AwaitCounter as Nn, _for_closure as Nt, _attr_input_checked_default as O, Params as On, withLazy as Ot, _attr_input_value_script as P, BranchRenders as Pn, _for_selector as Pt, _attr_style_item as Q, syncGen as Qt, _controllable_input as R, Global as Rn, _id as Rt, _attr_details_or_dialog_open_default as S, _call as Sn, _var_resume as St, _attr_input_checkedValue as T, Lazy as Tn, initEmbedded as Tt, controllableSpreadHelpers as U, PendingRenders as Un, _return as Ut, _controllable_textarea as V, PendingEffectScopes as Vn, _let_change as Vt, _attr as W, PlaceholderBranch as Wn, _return_change as Wt, _attr_nonce as X, insertBranchBefore as Xt, _attr_content as Y, destroyBranch as Yt, _attr_style as Z, removeAndDestroyBranch as Zt, patchDynamicTag as _, forTo as _n, createBranch as _t, _for_in as a, installBranchRenders as an, _html as at, startAwait as b, _assert_hoist as bn, _el as bt, _for_to as c, queueAsyncRender as cn, _style_shell as ct, _for_until_unkeyed as d, rendering as dn, _to_text as dt, PLACEHOLDER_DISMISS_REGISTER_ID as en, _attrs as et, _if as f, run as fn, _content as ft, installDynamicTagVar as g, forOf as gn, createAndSetupBranch as gt, dynamicTagScript as h, forIn as hn, _return_setup as ht, _dynamic_tag_content as i, createBranchRenders as in, _attrs_script as it, _attr_input_value_attribute_default as j, Pending as jn, _const as jt, _attr_input_checked_script as k, Returns as kn, _closure as kt, _for_to_unkeyed as l, queueEffect as ln, _text as lt, _try as m, runId as mn, _content_resume as mt, _await_promise as n, $signal as nn, _attrs_partial as nt, _for_of as o, installCatch as on, _lifecycle as ot, _show as p, runEffects as pn, _content_closures as pt, _attr_class_items as q, _var_change as qt, _dynamic_tag as r, $signalReset as rn, _attrs_partial_content as rt, _for_of_unkeyed as s, prepareEffects as sn, _style_rule_item as st, _await_content as t, _on as tn, _attrs_content as tt, _for_until as u, queueRender as un, _text_content as ut, renderCatch as v, forUntil as vn, setupBranch as vt, _attr_input_checked as w, Clone as wn, init as wt, _attr_details_or_dialog_open as x, _hoist_read_error as xn, _resumed as xt, runPendingEffects as y, _assert_class_toggles as yn, _dynamic_tag_var_resume as yt, _controllable_open as z, Load as zn, _if_closure as zt };
|
|
2197
|
+
export { _attr_style_items as $, DYNAMIC_TAG_SCRIPT_REGISTER_ID as $t, _attr_input_value as A, Returns as An, _closure_get as At, _controllable_select as B, Load as Bn, _let as Bt, _attr_details_or_dialog_open_script as C, _call as Cn, getRegisteredWithScope as Ct, _attr_input_checkedValue_script as D, LocalClosures as Dn, readyFailed as Dt, _attr_input_checkedValue_default as E, Lazy as En, ready as Et, _attr_select_value as F, BranchRenders as Fn, _global_read as Ft, _attr_class as G, PlaceholderBranch as Gn, _script as Gt, controllableScripts as H, PendingEffectScopes as Hn, _or as Ht, _attr_select_value_default as I, ClosestBranch as In, _hoist as It, _attr_class_names as J, _assert_init as Jt, _attr_class_item as K, StartNode as Kn, _var as Kt, _attr_select_value_script as L, EndNode as Ln, _hoist_resume as Lt, _attr_input_value_default as M, Pending as Mn, _el_read as Mt, _attr_input_value_dynamic_default as N, Scope as Nn, _for_closure as Nt, _attr_input_checked_default as O, Owner as On, withLazy as Ot, _attr_input_value_script as P, AwaitCounter as Pn, _for_selector as Pt, _attr_style_item as Q, syncGen as Qt, _controllable_input as R, Gen$1 as Rn, _id as Rt, _attr_details_or_dialog_open_default as S, _hoist_read_error as Sn, _var_resume as St, _attr_input_checkedValue as T, Clone as Tn, initEmbedded as Tt, controllableSpreadHelpers as U, PendingEffects as Un, _return as Ut, _controllable_textarea as V, ParentBranch as Vn, _let_change as Vt, _attr as W, PendingRenders as Wn, _return_change as Wt, _attr_nonce as X, insertBranchBefore as Xt, _attr_content as Y, destroyBranch as Yt, _attr_style as Z, removeAndDestroyBranch as Zt, patchDynamicTag as _, forOf as _n, createBranch as _t, _for_in as a, createBranchRenders as an, _html as at, startAwait as b, _assert_class_toggles as bn, _el as bt, _for_to as c, prepareEffects as cn, _style_shell as ct, _for_until_unkeyed as d, queueRender as dn, _to_text as dt, PLACEHOLDER_DISMISS_REGISTER_ID as en, _attrs as et, _if as f, rendering as fn, _content as ft, installDynamicTagVar as g, forIn as gn, createAndSetupBranch as gt, dynamicTagScript as h, runId as hn, _return_setup as ht, _dynamic_tag_content as i, onAbort as in, _attrs_script as it, _attr_input_value_attribute_default as j, Setup as jn, _const as jt, _attr_input_checked_script as k, Params as kn, _closure as kt, _for_to_unkeyed as l, queueAsyncRender as ln, _text as lt, _try as m, runEffects as mn, _content_resume as mt, _await_promise as n, $signal as nn, _attrs_partial as nt, _for_of as o, installBranchRenders as on, _lifecycle as ot, _show as p, run as pn, _content_closures as pt, _attr_class_items as q, TagVariable as qn, _var_change as qt, _dynamic_tag as r, $signalReset as rn, _attrs_partial_content as rt, _for_of_unkeyed as s, installCatch as sn, _style_rule_item as st, _await_content as t, _on as tn, _attrs_content as tt, _for_until as u, queueEffect as un, _text_content as ut, renderCatch as v, forTo as vn, setupBranch as vt, _attr_input_checked as w, withBranches as wn, init as wt, _attr_details_or_dialog_open as x, _assert_hoist as xn, _resumed as xt, runPendingEffects as y, forUntil as yn, _dynamic_tag_var_resume as yt, _controllable_open as z, Global as zn, _if_closure as zt };
|