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,5 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
// src/common/constants/accessor-prefix.debug.ts
|
|
3
3
|
const BranchScopes$1 = "BranchScopes:";
|
|
4
4
|
const ClosureScopes = "ClosureScopes:";
|
|
5
5
|
const ClosureSignalIndex = "ClosureSignalIndex:";
|
|
@@ -16,8 +16,7 @@ const Lifecycle = "Lifecycle:";
|
|
|
16
16
|
const Promise$1 = "Promise:";
|
|
17
17
|
const TagVariableChange$1 = "TagVariableChange:";
|
|
18
18
|
const TryBranch$1 = "TryBranch:";
|
|
19
|
-
|
|
20
|
-
//#region src/common/constants/accessor-prop.debug.ts
|
|
19
|
+
// src/common/constants/accessor-prop.debug.ts
|
|
21
20
|
const Global = "$global";
|
|
22
21
|
const AbortControllers = "#AbortControllers";
|
|
23
22
|
const AbortScopes = "#AbortScopes";
|
|
@@ -47,17 +46,12 @@ const Subscriptions = "#Subscriptions";
|
|
|
47
46
|
const TagVariable = "#TagVariable";
|
|
48
47
|
const TagVariableChange = "#TagVariableChange";
|
|
49
48
|
const TryBranch = "#TryBranch";
|
|
50
|
-
|
|
51
|
-
//#region src/common/constants/closure-scopes-prop.debug.ts
|
|
49
|
+
// src/common/constants/closure-scopes-prop.debug.ts
|
|
52
50
|
const Changed = "Changed";
|
|
53
|
-
|
|
54
|
-
//#region src/common/constants/closure-signal-prop.debug.ts
|
|
51
|
+
// src/common/constants/closure-signal-prop.debug.ts
|
|
55
52
|
const ScopesAccessor = "scopesAccessor";
|
|
56
53
|
const SignalIndexAccessor = "signalIndexAccessor";
|
|
57
54
|
const Index = "index";
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region src/common/constants/keyed-scopes-prop.debug.ts
|
|
60
|
-
const PreviousKey = "PreviousKey:";
|
|
61
55
|
const Scope = "scope";
|
|
62
56
|
const Signal = "signal";
|
|
63
57
|
const Value = "value";
|
|
@@ -70,8 +64,7 @@ const Accessor = "accessor";
|
|
|
70
64
|
const LocalClosures = "localClosures";
|
|
71
65
|
const Returns = "returns";
|
|
72
66
|
const Lazy = "lazy";
|
|
73
|
-
|
|
74
|
-
//#region src/common/helpers.ts
|
|
67
|
+
// src/common/helpers.ts
|
|
75
68
|
const invalidNativeAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
76
69
|
const knownWrongAttrs = {
|
|
77
70
|
className: "class",
|
|
@@ -139,7 +132,7 @@ function escapeStyleValue(str) {
|
|
|
139
132
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
140
133
|
return result + closers;
|
|
141
134
|
}
|
|
142
|
-
|
|
135
|
+
function toDelimitedString(val, delimiter, stringify) {
|
|
143
136
|
let str = "";
|
|
144
137
|
let sep = "";
|
|
145
138
|
let part;
|
|
@@ -161,7 +154,7 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
161
154
|
}
|
|
162
155
|
}
|
|
163
156
|
return str;
|
|
164
|
-
}
|
|
157
|
+
}
|
|
165
158
|
function isEventHandler(name) {
|
|
166
159
|
return /^on[A-Z-]/.test(name);
|
|
167
160
|
}
|
|
@@ -195,8 +188,7 @@ function withDynamicHtml(runtime) {
|
|
|
195
188
|
dynamicHtmlEnabled = 1;
|
|
196
189
|
return runtime;
|
|
197
190
|
}
|
|
198
|
-
|
|
199
|
-
//#region src/common/errors.ts
|
|
191
|
+
// src/common/errors.ts
|
|
200
192
|
const lowercaseOnAttrReg = /^on[a-z]/;
|
|
201
193
|
function assertValidAttrValue(name, value) {
|
|
202
194
|
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.`);
|
|
@@ -311,8 +303,7 @@ function joinWithAnd(a) {
|
|
|
311
303
|
default: return `${a.slice(0, -1).join(", ")}, and ${a[a.length - 1]}`;
|
|
312
304
|
}
|
|
313
305
|
}
|
|
314
|
-
|
|
315
|
-
//#region src/common/for.ts
|
|
306
|
+
// src/common/for.ts
|
|
316
307
|
function forIn(obj, cb) {
|
|
317
308
|
for (const key in obj) cb(key, obj[key]);
|
|
318
309
|
}
|
|
@@ -339,8 +330,7 @@ function forUntil(until, from, step, cb) {
|
|
|
339
330
|
const delta = step || 1;
|
|
340
331
|
for (let steps = (until - start) / delta, i = 0; i < steps; i++) cb(start + i * delta);
|
|
341
332
|
}
|
|
342
|
-
|
|
343
|
-
//#region src/dom/queue.ts
|
|
333
|
+
// src/dom/queue.ts
|
|
344
334
|
let rendering;
|
|
345
335
|
let runId = 2;
|
|
346
336
|
let pendingEffects = [];
|
|
@@ -443,9 +433,9 @@ function prepareEffects(fn) {
|
|
|
443
433
|
}
|
|
444
434
|
return preparedEffects;
|
|
445
435
|
}
|
|
446
|
-
let runEffects = (
|
|
436
|
+
let runEffects = (effects) => {
|
|
447
437
|
for (let i = 0; i < effects.length;) effects[i++](effects[i++]);
|
|
448
|
-
}
|
|
438
|
+
};
|
|
449
439
|
let runRender = (render) => {
|
|
450
440
|
if (!branchesEnabled || render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) render[Signal](render[Scope], render[Value]);
|
|
451
441
|
};
|
|
@@ -480,8 +470,7 @@ function runRenders(renders = pendingRenders) {
|
|
|
480
470
|
runRender(render);
|
|
481
471
|
}
|
|
482
472
|
}
|
|
483
|
-
|
|
484
|
-
//#region src/dom/abort-signal.ts
|
|
473
|
+
// src/dom/abort-signal.ts
|
|
485
474
|
function $signalReset(scope, id) {
|
|
486
475
|
const ctrl = scope[AbortControllers]?.[id];
|
|
487
476
|
if (ctrl) {
|
|
@@ -496,7 +485,7 @@ function $signal(scope, id) {
|
|
|
496
485
|
return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
|
|
497
486
|
}
|
|
498
487
|
/** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
|
|
499
|
-
function
|
|
488
|
+
function onAbort(scope, id, abort) {
|
|
500
489
|
abortsEnabled = 1;
|
|
501
490
|
trackCleanup(scope);
|
|
502
491
|
(scope[AbortControllers] ||= {})[id] = { abort };
|
|
@@ -515,8 +504,7 @@ let subscriptionsEnabled;
|
|
|
515
504
|
function abort(ctrl) {
|
|
516
505
|
ctrl.abort();
|
|
517
506
|
}
|
|
518
|
-
|
|
519
|
-
//#region src/common/opt.ts
|
|
507
|
+
// src/common/opt.ts
|
|
520
508
|
function toArray(opt) {
|
|
521
509
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
522
510
|
}
|
|
@@ -529,8 +517,7 @@ function forEach(opt, cb) {
|
|
|
529
517
|
function push(opt, item) {
|
|
530
518
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
531
519
|
}
|
|
532
|
-
|
|
533
|
-
//#region src/dom/event.ts
|
|
520
|
+
// src/dom/event.ts
|
|
534
521
|
function _on(element, type, handler) {
|
|
535
522
|
assertHandlerIsFunction("on" + type[0].toUpperCase() + type.slice(1), handler);
|
|
536
523
|
delegate(type, handleDelegated);
|
|
@@ -552,21 +539,18 @@ function handleDelegated(ev) {
|
|
|
552
539
|
}
|
|
553
540
|
delete ev.currentTarget;
|
|
554
541
|
}
|
|
555
|
-
|
|
556
|
-
//#region src/dom/parse-html.ts
|
|
542
|
+
// src/dom/parse-html.ts
|
|
557
543
|
const parsers = {};
|
|
558
544
|
function parseHTML(html, ns) {
|
|
559
545
|
const parser = parsers[ns] ||= document.createElementNS(ns, "template");
|
|
560
546
|
parser.innerHTML = html;
|
|
561
547
|
return parser.content || parser;
|
|
562
548
|
}
|
|
563
|
-
|
|
564
|
-
//#region src/common/meta.ts
|
|
549
|
+
// src/common/meta.ts
|
|
565
550
|
const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
566
551
|
const DYNAMIC_TAG_VAR_REGISTER_ID = "_dynamicTagVar";
|
|
567
552
|
const PLACEHOLDER_DISMISS_REGISTER_ID = "_placeholderDismiss";
|
|
568
|
-
|
|
569
|
-
//#region src/dom/scope.ts
|
|
553
|
+
// src/dom/scope.ts
|
|
570
554
|
let nextScopeId = 1e6;
|
|
571
555
|
let collectingScopes;
|
|
572
556
|
function createScope($global, closestBranch) {
|
|
@@ -600,7 +584,7 @@ function skipScope() {
|
|
|
600
584
|
return nextScopeId++;
|
|
601
585
|
}
|
|
602
586
|
function destroyBranch(branch) {
|
|
603
|
-
branch[ParentBranch]?.[BranchScopes]
|
|
587
|
+
branch[ParentBranch]?.[BranchScopes].delete(branch);
|
|
604
588
|
destroyNestedScopes(branch);
|
|
605
589
|
}
|
|
606
590
|
function destroyScope(scope) {
|
|
@@ -609,11 +593,11 @@ function destroyScope(scope) {
|
|
|
609
593
|
cleanupScope(scope);
|
|
610
594
|
}
|
|
611
595
|
}
|
|
612
|
-
|
|
596
|
+
function destroyNestedScopes(scope) {
|
|
613
597
|
scope[Gen$1] = 0;
|
|
614
598
|
scope[BranchScopes]?.forEach(destroyNestedScopes);
|
|
615
599
|
scope[AbortScopes]?.forEach(cleanupScope);
|
|
616
|
-
}
|
|
600
|
+
}
|
|
617
601
|
function cleanupScope(scope) {
|
|
618
602
|
if (subscriptionsEnabled) scope[Subscriptions]?.forEach(unsubscribe, scope);
|
|
619
603
|
if (abortsEnabled) for (const id in scope[AbortControllers]) $signalReset(scope, id);
|
|
@@ -633,8 +617,7 @@ function detachBranch(branch) {
|
|
|
633
617
|
fragment.namespaceURI = branch[StartNode].parentNode.namespaceURI;
|
|
634
618
|
insertChildNodes(fragment, null, branch[StartNode], branch[EndNode]);
|
|
635
619
|
}
|
|
636
|
-
|
|
637
|
-
//#region src/dom/schedule.ts
|
|
620
|
+
// src/dom/schedule.ts
|
|
638
621
|
let runTask;
|
|
639
622
|
let isScheduled;
|
|
640
623
|
let channel;
|
|
@@ -666,8 +649,7 @@ function triggerMacroTask() {
|
|
|
666
649
|
}
|
|
667
650
|
channel.port2.postMessage(0);
|
|
668
651
|
}
|
|
669
|
-
|
|
670
|
-
//#region src/dom/signals.ts
|
|
652
|
+
// src/dom/signals.ts
|
|
671
653
|
function _let(id, fn) {
|
|
672
654
|
const valueAccessor = id.slice(0, id.lastIndexOf("/"));
|
|
673
655
|
id = +id.slice(id.lastIndexOf("/") + 1);
|
|
@@ -707,7 +689,8 @@ function _const(valueAccessor, fn) {
|
|
|
707
689
|
}
|
|
708
690
|
});
|
|
709
691
|
}
|
|
710
|
-
function _or(id, fn, defaultPending = 1, scopeIdAccessor
|
|
692
|
+
function _or(id, fn, defaultPending = 1, scopeIdAccessor) {
|
|
693
|
+
scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
|
|
711
694
|
return (scope) => {
|
|
712
695
|
if (scope["#Gen"] === runId) {
|
|
713
696
|
if (~id in scope) {
|
|
@@ -716,36 +699,33 @@ function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
|
716
699
|
} else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
717
700
|
};
|
|
718
701
|
}
|
|
719
|
-
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
702
|
+
function _for_closure(ownerLoopNodeAccessor, fn, id, scopeIdAccessor) {
|
|
703
|
+
scopeIdAccessor = scopeIdAccessor ? scopeIdAccessor : "#Id";
|
|
720
704
|
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
721
|
-
const
|
|
722
|
-
const
|
|
723
|
-
queueRender(ownerScope, (_) => {
|
|
724
|
-
for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
|
|
725
|
-
}, -1);
|
|
705
|
+
const render = (ownerScope) => {
|
|
706
|
+
for (const scope of toArray(ownerScope[scopeAccessor])) if (scope["#Gen"] < runId) fn(scope);
|
|
726
707
|
};
|
|
708
|
+
const ownerSignal = (ownerScope) => queueRender(ownerScope, render, id, 0, ownerScope[scopeIdAccessor]);
|
|
727
709
|
ownerSignal._ = (scope) => queueRender(scope, fn, -1);
|
|
728
710
|
return ownerSignal;
|
|
729
711
|
}
|
|
730
|
-
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn) {
|
|
712
|
+
function _for_selector(ownerLoopNodeAccessor, ownerValueAccessor, fn, getValueScope) {
|
|
731
713
|
const scopeAccessor = BranchScopes$1 + ownerLoopNodeAccessor;
|
|
732
714
|
const mapAccessor = KeyedScopes + ownerLoopNodeAccessor;
|
|
733
|
-
const
|
|
715
|
+
const prevKey = Symbol(ownerValueAccessor);
|
|
734
716
|
const ownerSignal = (ownerScope) => {
|
|
735
717
|
if (ownerScope["#Gen"] < runId) {
|
|
736
|
-
const nextKey = ownerScope[ownerValueAccessor];
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
if (map) map[prevKeyProp] = nextKey;
|
|
748
|
-
}, -1);
|
|
718
|
+
const nextKey = (getValueScope ? getValueScope(ownerScope) : ownerScope)[ownerValueAccessor];
|
|
719
|
+
const map = keyedScopes(ownerScope, scopeAccessor, mapAccessor);
|
|
720
|
+
if (map && prevKey in ownerScope) {
|
|
721
|
+
const prevScope = map.get(ownerScope[prevKey]);
|
|
722
|
+
const nextScope = map.get(nextKey);
|
|
723
|
+
if (prevScope !== nextScope) {
|
|
724
|
+
queueLiveBranch(prevScope, fn);
|
|
725
|
+
queueLiveBranch(nextScope, fn);
|
|
726
|
+
}
|
|
727
|
+
} else for (const scope of toArray(ownerScope[scopeAccessor])) queueLiveBranch(scope, fn);
|
|
728
|
+
ownerScope[prevKey] = nextKey;
|
|
749
729
|
}
|
|
750
730
|
};
|
|
751
731
|
ownerSignal._ = (scope) => queueRender(scope, fn, -1);
|
|
@@ -760,8 +740,8 @@ function keyedScopes(ownerScope, scopeAccessor, mapAccessor) {
|
|
|
760
740
|
}
|
|
761
741
|
return map;
|
|
762
742
|
}
|
|
763
|
-
function
|
|
764
|
-
if (scope
|
|
743
|
+
function queueLiveBranch(scope, fn) {
|
|
744
|
+
if (scope?.["#Gen"] < runId) queueRender(scope, fn, -1);
|
|
765
745
|
}
|
|
766
746
|
function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
767
747
|
const scopeAccessor = BranchScopes$1 + ownerConditionalNodeAccessor;
|
|
@@ -830,9 +810,7 @@ function _id(scope, accessor) {
|
|
|
830
810
|
}
|
|
831
811
|
function _script(id, fn) {
|
|
832
812
|
_resumed[id] = fn;
|
|
833
|
-
return (scope) =>
|
|
834
|
-
queueEffect(scope, fn);
|
|
835
|
-
};
|
|
813
|
+
return (scope) => queueEffect(scope, fn);
|
|
836
814
|
}
|
|
837
815
|
function _global_read($global, key) {
|
|
838
816
|
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.`);
|
|
@@ -865,15 +843,14 @@ function _hoist(...path) {
|
|
|
865
843
|
function _hoist_resume(id, ...path) {
|
|
866
844
|
return _resumed[id] = _hoist(...path);
|
|
867
845
|
}
|
|
868
|
-
|
|
869
|
-
//#region src/dom/walker.ts
|
|
846
|
+
// src/dom/walker.ts
|
|
870
847
|
/** Cloned templates are small, where a TreeWalker's per-step cost dominates. */
|
|
871
848
|
let currentNode;
|
|
872
849
|
function walk(startNode, walkCodes, branch) {
|
|
873
850
|
currentNode = startNode;
|
|
874
851
|
walkInternal(0, walkCodes, branch);
|
|
875
852
|
}
|
|
876
|
-
|
|
853
|
+
function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
877
854
|
let value;
|
|
878
855
|
let currentMultiplier;
|
|
879
856
|
let storedMultiplier = 0;
|
|
@@ -909,7 +886,7 @@ const walkInternal = function walkInternal(currentWalkIndex, walkCodes, scope) {
|
|
|
909
886
|
storedMultiplier = currentMultiplier * 10 + value - 117;
|
|
910
887
|
}
|
|
911
888
|
}
|
|
912
|
-
}
|
|
889
|
+
}
|
|
913
890
|
function getDebugKey(index, node) {
|
|
914
891
|
if (typeof node === "string") return `${node}/${index}`;
|
|
915
892
|
else if (node.nodeType === 3) return `#text/${index}`;
|
|
@@ -918,8 +895,7 @@ function getDebugKey(index, node) {
|
|
|
918
895
|
return index;
|
|
919
896
|
}
|
|
920
897
|
const walkNextSibling = (_) => currentNode = currentNode.nextSibling || currentNode;
|
|
921
|
-
|
|
922
|
-
//#region src/dom/resume.ts
|
|
898
|
+
// src/dom/resume.ts
|
|
923
899
|
const _resumed = {};
|
|
924
900
|
let curRenders;
|
|
925
901
|
let embedRenders;
|
|
@@ -962,168 +938,166 @@ function init(runtimeId = "M") {
|
|
|
962
938
|
}
|
|
963
939
|
const renders = self[runtimeId];
|
|
964
940
|
const defineRuntime = (desc) => Object.defineProperty(self, runtimeId, desc);
|
|
965
|
-
const initRuntime = (renders) => {
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
scopeId++;
|
|
991
|
-
}
|
|
941
|
+
const initRuntime = (renders) => defineRuntime({ value: curRenders = ((renderId) => {
|
|
942
|
+
const render = curRenders[renderId] = renders[renderId] || renders(renderId);
|
|
943
|
+
const walk = render.w;
|
|
944
|
+
const scopeLookup = {};
|
|
945
|
+
const pending = [];
|
|
946
|
+
const getScope = (id) => scopeLookup[id] || (+id ? initScope(scopeLookup[id] = { ["#Id"]: +id }) : initGlobal());
|
|
947
|
+
const initGlobal = (_) => scopeLookup[0] ||= {
|
|
948
|
+
runtimeId,
|
|
949
|
+
renderId
|
|
950
|
+
};
|
|
951
|
+
const initScope = (scope) => {
|
|
952
|
+
scope[Gen$1] ??= 1;
|
|
953
|
+
scope[Global] = initGlobal();
|
|
954
|
+
if (branchesEnabled && scope["#ClosestBranchId"]) scope[ClosestBranch] = getScope(scope[ClosestBranchId]);
|
|
955
|
+
return scope;
|
|
956
|
+
};
|
|
957
|
+
const applyScopes = (partials) => {
|
|
958
|
+
let scopeId = partials[0];
|
|
959
|
+
for (let i = 1; i < partials.length; i++) {
|
|
960
|
+
const partial = partials[i];
|
|
961
|
+
if (typeof partial === "number") scopeId += partial;
|
|
962
|
+
else {
|
|
963
|
+
if (scopeId) initScope(Object.assign(scopeLookup[scopeId] ||= (partial["#Id"] = scopeId, partial), partial));
|
|
964
|
+
else Object.assign(initGlobal(), partial);
|
|
965
|
+
scopeId++;
|
|
992
966
|
}
|
|
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
|
-
|
|
1025
|
-
startVisit = branchStarts.pop();
|
|
1026
|
-
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
1027
|
-
branch[StartNode] = startVisit;
|
|
1028
|
-
branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
967
|
+
}
|
|
968
|
+
};
|
|
969
|
+
const serializeContext = ((data, registryId) => typeof data === "number" ? registryId ? _resumed[registryId](getScope(data)) : getScope(data) : applyScopes(data));
|
|
970
|
+
const createVisitBranches = (branchScopesStack = [], branchStarts = [], curBranchScopes, reorderBranch, reorderDepth = 0, adopt = (scope, branch) => scope["#ClosestBranch"] === scope ? scope !== branch && setParentBranch(scope, branch) : scope[ClosestBranch] = branch) => {
|
|
971
|
+
return (branchId, branch, endedBranches, accessor, nodeAccessor, singleNode, parent = visit.parentNode, startVisit = visit) => {
|
|
972
|
+
if (visitType === "*") {
|
|
973
|
+
while (reorderBranch && pending.length >= reorderDepth) adopt(pending.pop(), reorderBranch);
|
|
974
|
+
if (reorderBranch = +lastToken && visitScope) reorderDepth = pending.push(reorderBranch);
|
|
975
|
+
return;
|
|
976
|
+
}
|
|
977
|
+
if (visitType !== "[") {
|
|
978
|
+
visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit;
|
|
979
|
+
accessor = BranchScopes$1 + (nodeAccessor = lastToken);
|
|
980
|
+
singleNode = visitType !== "]" && visitType !== ")";
|
|
981
|
+
nextToken();
|
|
982
|
+
}
|
|
983
|
+
while (branchId = +lastToken) {
|
|
984
|
+
(endedBranches ||= []).push(branch = getScope(branchId));
|
|
985
|
+
setParentBranch(branch, branch[ClosestBranch]);
|
|
986
|
+
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
|
|
987
|
+
if (singleNode) {
|
|
988
|
+
while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
|
|
989
|
+
branch["_"] ??= visitScope;
|
|
990
|
+
branch[EndNode] = branch[StartNode] = startVisit;
|
|
991
|
+
if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
992
|
+
} else {
|
|
993
|
+
branch[BranchAccessor] = nodeAccessor;
|
|
994
|
+
curBranchScopes = push(curBranchScopes, branch);
|
|
995
|
+
if (accessor) {
|
|
996
|
+
visitScope[accessor] = curBranchScopes;
|
|
997
|
+
forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
|
|
998
|
+
curBranchScopes = branchScopesStack.pop();
|
|
1029
999
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1000
|
+
startVisit = branchStarts.pop();
|
|
1001
|
+
if (parent !== startVisit.parentNode) parent.prepend(startVisit);
|
|
1002
|
+
branch[StartNode] = startVisit;
|
|
1003
|
+
branch[EndNode] = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
1032
1004
|
}
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1005
|
+
while (pending.at(-1)?.["#Id"] >= branchId) adopt(pending.pop(), branch);
|
|
1006
|
+
nextToken();
|
|
1007
|
+
}
|
|
1008
|
+
if (endedBranches) {
|
|
1009
|
+
for (const ended of endedBranches) pending.push(ended);
|
|
1010
|
+
if (singleNode) visitScope[accessor] = endedBranches.length > 1 ? endedBranches.reverse() : endedBranches[0];
|
|
1011
|
+
}
|
|
1012
|
+
if (visitType === "[") {
|
|
1013
|
+
if (!endedBranches) {
|
|
1014
|
+
branchScopesStack.push(curBranchScopes);
|
|
1015
|
+
curBranchScopes = void 0;
|
|
1036
1016
|
}
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
branchScopesStack.push(curBranchScopes);
|
|
1040
|
-
curBranchScopes = void 0;
|
|
1041
|
-
}
|
|
1042
|
-
branchStarts.push(visit);
|
|
1043
|
-
} else pending.push(visitScope);
|
|
1044
|
-
};
|
|
1017
|
+
branchStarts.push(visit);
|
|
1018
|
+
} else pending.push(visitScope);
|
|
1045
1019
|
};
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1020
|
+
};
|
|
1021
|
+
const nextToken = (_) => lastToken = visitText.slice(lastTokenIndex, (lastTokenIndex = visitText.indexOf(" ", lastTokenIndex) + 1 || visitText.length + 1) - 1);
|
|
1022
|
+
const processResumes = (resumes = [], effects) => {
|
|
1023
|
+
let i = 0;
|
|
1024
|
+
for (; i < resumes.length; i++) {
|
|
1025
|
+
const serialized = resumes[i];
|
|
1026
|
+
if (typeof serialized === "string") {
|
|
1027
|
+
lastTokenIndex = 0;
|
|
1028
|
+
visitText = serialized;
|
|
1029
|
+
while (nextToken()) if (/\D/.test(lastToken)) lastEffect = _resumed[lastToken];
|
|
1030
|
+
else effects.push(lastEffect, getScope(lastToken));
|
|
1031
|
+
} else if (Array.isArray(serialized)) {
|
|
1032
|
+
if (!(readyIds && serialized.every((dep) => readyIds.has(dep) && !render.b[dep].length))) break;
|
|
1033
|
+
} else if (readyIds && typeof serialized === "number") break;
|
|
1034
|
+
else {
|
|
1035
|
+
const scopes = serialized(serializeContext);
|
|
1036
|
+
if (Array.isArray(scopes)) applyScopes(scopes);
|
|
1063
1037
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1038
|
+
}
|
|
1039
|
+
resumes.splice(0, i);
|
|
1040
|
+
return i;
|
|
1041
|
+
};
|
|
1042
|
+
let lastEffect;
|
|
1043
|
+
let visits;
|
|
1044
|
+
let visit;
|
|
1045
|
+
let visitText;
|
|
1046
|
+
let visitType;
|
|
1047
|
+
let visitScope;
|
|
1048
|
+
let lastToken;
|
|
1049
|
+
let lastTokenIndex;
|
|
1050
|
+
let visitBranches;
|
|
1051
|
+
let htmlStart;
|
|
1052
|
+
let embedAnchor;
|
|
1053
|
+
serializeContext._ = _resumed;
|
|
1054
|
+
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.`);
|
|
1055
|
+
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.`);
|
|
1056
|
+
render.m = (effects) => {
|
|
1057
|
+
processResumes(render.r, effects);
|
|
1058
|
+
if (readyIds && render.b) for (let progress = 1; progress;) {
|
|
1059
|
+
progress = 0;
|
|
1060
|
+
for (const readyId of readyIds) {
|
|
1061
|
+
const resumes = render.b[readyId];
|
|
1062
|
+
if (resumes && processResumes(resumes, effects)) progress = 1;
|
|
1089
1063
|
}
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
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.");
|
|
1100
|
-
visitScope[nextToken()] = htmlStart;
|
|
1101
|
-
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1102
|
-
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1103
|
-
}
|
|
1104
|
-
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1105
|
-
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1064
|
+
}
|
|
1065
|
+
let retained = 0;
|
|
1066
|
+
for (visit of visits = render.v) {
|
|
1067
|
+
lastTokenIndex = render.i.length;
|
|
1068
|
+
visitText = visit.data;
|
|
1069
|
+
visitType = visitText[lastTokenIndex++];
|
|
1070
|
+
visitScope = getScope(nextToken());
|
|
1071
|
+
if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
|
|
1072
|
+
if (visitType === "&") htmlStart = visit;
|
|
1106
1073
|
else {
|
|
1107
|
-
|
|
1074
|
+
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.");
|
|
1075
|
+
visitScope[nextToken()] = htmlStart;
|
|
1076
|
+
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1108
1077
|
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1109
1078
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
visitBranches();
|
|
1079
|
+
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1080
|
+
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1081
|
+
else {
|
|
1082
|
+
visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
|
|
1083
|
+
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1116
1084
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1085
|
+
if (embedRenders && !embedAnchor && visit.parentNode) embedRenders.set(embedAnchor = visit.parentNode.insertBefore(new Text(), visit), [renderId, scopeLookup]);
|
|
1086
|
+
}
|
|
1087
|
+
if (branchesEnabled && visitBranches) {
|
|
1088
|
+
visitType = "*";
|
|
1089
|
+
lastToken = "";
|
|
1090
|
+
visitBranches();
|
|
1091
|
+
}
|
|
1092
|
+
visits.length = retained;
|
|
1093
|
+
return effects;
|
|
1094
|
+
};
|
|
1095
|
+
render.w = (_) => {
|
|
1096
|
+
walk();
|
|
1097
|
+
runResumeEffects(render);
|
|
1098
|
+
};
|
|
1099
|
+
return render;
|
|
1100
|
+
}) });
|
|
1127
1101
|
if (renders) {
|
|
1128
1102
|
initRuntime(renders);
|
|
1129
1103
|
for (const renderId in renders) runResumeEffects(curRenders(renderId));
|
|
@@ -1154,11 +1128,10 @@ function _el(id, accessor) {
|
|
|
1154
1128
|
function _dynamic_tag_var_resume(accessor) {
|
|
1155
1129
|
_resumed[DYNAMIC_TAG_VAR_REGISTER_ID + accessor] = (scope) => (_) => {
|
|
1156
1130
|
const node = scope[accessor];
|
|
1157
|
-
return _el_read(node.nodeType
|
|
1131
|
+
return _el_read(node.nodeType > 1 ? node.previousSibling : node);
|
|
1158
1132
|
};
|
|
1159
1133
|
}
|
|
1160
|
-
|
|
1161
|
-
//#region src/dom/renderer.ts
|
|
1134
|
+
// src/dom/renderer.ts
|
|
1162
1135
|
function createBranch($global, renderer, parentScope, parentNode) {
|
|
1163
1136
|
const branch = createScope($global);
|
|
1164
1137
|
branch["_"] = renderer["owner"] || parentScope;
|
|
@@ -1189,11 +1162,8 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
1189
1162
|
walks = walks ? walks.replace(/[^\0-1]+$/, "") : "";
|
|
1190
1163
|
setup = setup ? setup._ || setup : void 0;
|
|
1191
1164
|
params ||= void 0;
|
|
1192
|
-
const
|
|
1193
|
-
|
|
1194
|
-
} : (branch) => {
|
|
1195
|
-
walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
1196
|
-
};
|
|
1165
|
+
const cloneables = {};
|
|
1166
|
+
const clone = template ? (branch, ns) => (cloneables[ns] ||= createCloneableHTML(template, walks, ns))(branch) : (branch) => walk(branch[StartNode] = branch[EndNode] = new Text(), walks, branch);
|
|
1197
1167
|
return _resumed[id] = (owner) => {
|
|
1198
1168
|
return {
|
|
1199
1169
|
["id"]: id,
|
|
@@ -1233,14 +1203,11 @@ function _content_closures(renderer, closureFns) {
|
|
|
1233
1203
|
return instance;
|
|
1234
1204
|
};
|
|
1235
1205
|
}
|
|
1236
|
-
|
|
1237
|
-
function createCloneableHTML(html, ns) {
|
|
1206
|
+
function createCloneableHTML(html, walks, ns) {
|
|
1238
1207
|
const { firstChild, lastChild } = parseHTML(html, ns);
|
|
1239
1208
|
const parent = new DocumentFragment();
|
|
1240
1209
|
insertChildNodes(parent, null, firstChild, lastChild);
|
|
1241
|
-
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch, walks) => {
|
|
1242
|
-
walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch);
|
|
1243
|
-
} : (branch, walks) => {
|
|
1210
|
+
return firstChild === lastChild && firstChild.nodeType < 8 ? (branch) => walk(branch[StartNode] = branch[EndNode] = firstChild.cloneNode(true), walks, branch) : (branch) => {
|
|
1244
1211
|
const clone = parent.cloneNode(true);
|
|
1245
1212
|
clone.namespaceURI = ns;
|
|
1246
1213
|
walk(clone.firstChild, walks, branch);
|
|
@@ -1248,8 +1215,7 @@ function createCloneableHTML(html, ns) {
|
|
|
1248
1215
|
branch[EndNode] = clone.lastChild;
|
|
1249
1216
|
};
|
|
1250
1217
|
}
|
|
1251
|
-
|
|
1252
|
-
//#region src/dom/dom.ts
|
|
1218
|
+
// src/dom/dom.ts
|
|
1253
1219
|
function _to_text(value) {
|
|
1254
1220
|
assertValidTextValue(value);
|
|
1255
1221
|
return value || value === 0 ? value + "" : "";
|
|
@@ -1379,7 +1345,12 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
|
1379
1345
|
}
|
|
1380
1346
|
}
|
|
1381
1347
|
function _attr_content(scope, nodeAccessor, value) {
|
|
1382
|
-
const
|
|
1348
|
+
const renderer = normalizeDynamicRenderer(value);
|
|
1349
|
+
let content;
|
|
1350
|
+
if (renderer) {
|
|
1351
|
+
if (renderer["id"]) content = renderer;
|
|
1352
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1353
|
+
}
|
|
1383
1354
|
if (scope["ConditionalRenderer:" + nodeAccessor] !== (scope["ConditionalRenderer:" + nodeAccessor] = rendererKey(content))) {
|
|
1384
1355
|
setBranch(scope, nodeAccessor, content, createAndSetupBranch);
|
|
1385
1356
|
if (content?.["accessor"]) subscribeToScopeSet(content[Owner], content[Accessor], scope[BranchScopes$1 + nodeAccessor]);
|
|
@@ -1414,13 +1385,6 @@ const _html = /*@__PURE__*/ withDynamicHtml(function _html(scope, value, accesso
|
|
|
1414
1385
|
removeChildNodes(firstChild, lastChild);
|
|
1415
1386
|
}
|
|
1416
1387
|
});
|
|
1417
|
-
function normalizeClientRender(value) {
|
|
1418
|
-
const renderer = normalizeDynamicRenderer(value);
|
|
1419
|
-
if (renderer) {
|
|
1420
|
-
if (renderer["id"]) return renderer;
|
|
1421
|
-
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1422
|
-
}
|
|
1423
|
-
}
|
|
1424
1388
|
function normalizeAttrValue(value) {
|
|
1425
1389
|
if (isNotNullishOrFalse(value)) return value === true ? "" : value + "";
|
|
1426
1390
|
}
|
|
@@ -1437,7 +1401,7 @@ function _lifecycle(scope, thisObj, index = 0) {
|
|
|
1437
1401
|
Object.assign(thisObj, thisObj.onMount?.());
|
|
1438
1402
|
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1439
1403
|
}
|
|
1440
|
-
|
|
1404
|
+
onAbort(scope, accessor, (_) => thisObj.onDestroy?.());
|
|
1441
1405
|
}
|
|
1442
1406
|
}
|
|
1443
1407
|
function removeChildNodes(startNode, endNode) {
|
|
@@ -1456,8 +1420,7 @@ function insertChildNodes(parentNode, referenceNode, startNode, endNode) {
|
|
|
1456
1420
|
startNode = next;
|
|
1457
1421
|
}
|
|
1458
1422
|
}
|
|
1459
|
-
|
|
1460
|
-
//#region src/dom/resolve-cursor-position.ts
|
|
1423
|
+
// src/dom/resolve-cursor-position.ts
|
|
1461
1424
|
const R = /[\p{L}\p{N}]/gu;
|
|
1462
1425
|
function resolveCursorPosition(inputType, initialPosition, initialValue, updatedValue) {
|
|
1463
1426
|
if ((initialPosition || initialPosition === 0) && (initialPosition !== initialValue.length || /kw/.test(inputType))) {
|
|
@@ -1471,8 +1434,7 @@ function resolveCursorPosition(inputType, initialPosition, initialValue, updated
|
|
|
1471
1434
|
}
|
|
1472
1435
|
return -1;
|
|
1473
1436
|
}
|
|
1474
|
-
|
|
1475
|
-
//#region src/dom/controllable.ts
|
|
1437
|
+
// src/dom/controllable.ts
|
|
1476
1438
|
let inputType = "";
|
|
1477
1439
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
1478
1440
|
const el = scope[nodeAccessor];
|
|
@@ -1767,8 +1729,7 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
|
|
|
1767
1729
|
return /^open(?:Change)?$/;
|
|
1768
1730
|
}
|
|
1769
1731
|
}
|
|
1770
|
-
|
|
1771
|
-
//#region src/dom/control-flow.ts
|
|
1732
|
+
// src/dom/control-flow.ts
|
|
1772
1733
|
function _await_promise(nodeAccessor, params) {
|
|
1773
1734
|
const promiseAccessor = Promise$1 + nodeAccessor;
|
|
1774
1735
|
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
@@ -1802,7 +1763,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1802
1763
|
let awaitCounter = tryBranch[AwaitCounter];
|
|
1803
1764
|
if (!scope[tryAccessor]) {
|
|
1804
1765
|
scope[tryAccessor] = tryBranch;
|
|
1805
|
-
|
|
1766
|
+
onAbort(scope, promiseAccessor, (_) => {
|
|
1806
1767
|
scope[promiseAccessor] = 0;
|
|
1807
1768
|
if (scope[tryAccessor]) queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
|
|
1808
1769
|
});
|
|
@@ -1980,7 +1941,7 @@ const _show = /*@__PURE__*/ withBranches((nodeAccessor, startNodeAccessor) => {
|
|
|
1980
1941
|
const rangeAccessor = BranchScopes$1 + nodeAccessor;
|
|
1981
1942
|
return (scope, display) => {
|
|
1982
1943
|
const referenceNode = scope[nodeAccessor];
|
|
1983
|
-
const onlyChild = referenceNode.nodeType
|
|
1944
|
+
const onlyChild = referenceNode.nodeType < 3;
|
|
1984
1945
|
const parentNode = onlyChild ? referenceNode : referenceNode.parentNode;
|
|
1985
1946
|
let range = scope[rangeAccessor];
|
|
1986
1947
|
if (!range) {
|
|
@@ -2118,7 +2079,7 @@ const loop = /*@__PURE__*/ withBranches((forEach, reorder) => (nodeAccessor, tem
|
|
|
2118
2079
|
const oldScope = oldScopes[i];
|
|
2119
2080
|
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));
|
|
2120
2081
|
if (branch) {
|
|
2121
|
-
hasPotentialMoves =
|
|
2082
|
+
hasPotentialMoves = 1;
|
|
2122
2083
|
oldScopesByKey?.delete(key);
|
|
2123
2084
|
branch[LoopKey] = key;
|
|
2124
2085
|
} else {
|
|
@@ -2234,7 +2195,6 @@ function bySecondArg(_item, index) {
|
|
|
2234
2195
|
function byFirstArg(name) {
|
|
2235
2196
|
return name;
|
|
2236
2197
|
}
|
|
2237
|
-
//#endregion
|
|
2238
2198
|
Object.defineProperty(exports, "$signal", {
|
|
2239
2199
|
enumerable: true,
|
|
2240
2200
|
get: function() {
|
|
@@ -3045,6 +3005,12 @@ Object.defineProperty(exports, "installDynamicTagVar", {
|
|
|
3045
3005
|
return installDynamicTagVar;
|
|
3046
3006
|
}
|
|
3047
3007
|
});
|
|
3008
|
+
Object.defineProperty(exports, "onAbort", {
|
|
3009
|
+
enumerable: true,
|
|
3010
|
+
get: function() {
|
|
3011
|
+
return onAbort;
|
|
3012
|
+
}
|
|
3013
|
+
});
|
|
3048
3014
|
Object.defineProperty(exports, "patchDynamicTag", {
|
|
3049
3015
|
enumerable: true,
|
|
3050
3016
|
get: function() {
|