marko 6.3.56 → 6.4.1
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 +3 -3
- package/dist/common/constants/accessor-prefix.d.ts +2 -0
- package/dist/common/constants/accessor-prefix.debug.d.ts +2 -0
- package/dist/common/constants/accessor-prop.d.ts +3 -0
- package/dist/common/constants/accessor-prop.debug.d.ts +3 -0
- package/dist/common/constants/reserved-id.d.ts +5 -0
- package/dist/common/errors.d.ts +1 -1
- package/dist/common/types.d.ts +11 -2
- package/dist/debug/dom/catch.feat.js +12 -14
- package/dist/debug/dom/catch.feat.mjs +12 -14
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/lazy.feat.js +4 -0
- package/dist/debug/dom/lazy.feat.mjs +4 -0
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-DcwejnYg.js → dom-ClV4kVOO.js} +263 -193
- package/dist/debug/{dom-BeCNT5R5.mjs → dom-LFrKxOk5.mjs} +246 -182
- package/dist/debug/dom.js +14 -12
- package/dist/debug/dom.mjs +14 -12
- package/dist/debug/html.js +826 -685
- package/dist/debug/html.mjs +822 -683
- package/dist/dom/abort-signal.d.ts +2 -0
- package/dist/dom/catch.feat.js +6 -7
- package/dist/dom/catch.feat.mjs +5 -7
- package/dist/dom/control-flow.d.ts +3 -5
- package/dist/dom/controllable-input.feat.js +3 -2
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +3 -2
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +3 -2
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +3 -2
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +3 -2
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-script.feat.js +3 -2
- package/dist/dom/dynamic-tag-script.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +2 -1
- package/dist/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/dom/lazy.feat.d.ts +1 -0
- package/dist/dom/lazy.feat.js +4 -0
- package/dist/dom/lazy.feat.mjs +4 -0
- package/dist/dom/load.d.ts +3 -3
- package/dist/dom/placeholder.feat.js +4 -3
- package/dist/dom/placeholder.feat.mjs +1 -1
- package/dist/dom/queue.d.ts +2 -4
- package/dist/dom/resume.d.ts +1 -1
- package/dist/dom/scope.d.ts +0 -1
- package/dist/dom/signals.d.ts +3 -2
- package/dist/{dom-QEF0csuC.js → dom-CNglVi8P.js} +222 -185
- package/dist/{dom-BwNsIevR.mjs → dom-DfP3MCo0.mjs} +126 -90
- package/dist/dom.js +59 -56
- package/dist/dom.mjs +34 -32
- package/dist/html/attrs.d.ts +4 -2
- package/dist/html/dynamic-tag.d.ts +1 -1
- package/dist/html/inlined-runtimes.d.ts +1 -1
- package/dist/html/inlined-runtimes.debug.d.ts +1 -1
- package/dist/html/serializer.d.ts +1 -1
- package/dist/html/writer.d.ts +39 -33
- package/dist/html.d.ts +2 -2
- package/dist/html.js +526 -424
- package/dist/html.mjs +524 -423
- package/dist/translator/core/html-comment.d.ts +0 -7
- package/dist/translator/core/let.d.ts +0 -5
- package/dist/translator/core/show.d.ts +2 -5
- package/dist/translator/core/style.d.ts +6 -8
- package/dist/translator/index.d.ts +9 -0
- package/dist/translator/index.js +8195 -7939
- package/dist/translator/util/binding-has-prop.d.ts +3 -1
- package/dist/translator/util/binding-prop-tree.d.ts +4 -4
- package/dist/translator/util/bindings.d.ts +127 -0
- package/dist/translator/util/body-to-text-literal.d.ts +1 -2
- package/dist/translator/util/branch-tag.d.ts +7 -7
- package/dist/translator/util/constants/binding-type.d.ts +5 -6
- package/dist/translator/util/constants/slot-kind.d.ts +14 -0
- package/dist/translator/util/constants/structure-kind.d.ts +1 -1
- package/dist/translator/util/entry-builder.d.ts +2 -0
- package/dist/translator/util/evaluate.d.ts +11 -10
- package/dist/translator/util/finalize-references.d.ts +4 -0
- package/dist/translator/util/for-selector.d.ts +1 -1
- package/dist/translator/util/generate-uid.d.ts +7 -0
- package/dist/translator/util/get-declared-binding-expression.d.ts +2 -2
- package/dist/translator/util/is-core-tag.d.ts +0 -3
- package/dist/translator/util/is-only-child-in-parent.d.ts +2 -7
- package/dist/translator/util/known-tag.d.ts +8 -7
- package/dist/translator/util/read-replacement.d.ts +3 -0
- package/dist/translator/util/reasons.d.ts +32 -0
- package/dist/translator/util/references.d.ts +69 -167
- package/dist/translator/util/runtime.d.ts +3 -3
- package/dist/translator/util/scope-accessor.d.ts +14 -0
- package/dist/translator/util/scope-read.d.ts +1 -1
- package/dist/translator/util/sections.d.ts +56 -50
- package/dist/translator/util/set-tag-derived-from.d.ts +7 -0
- package/dist/translator/util/setup-work.d.ts +4 -0
- package/dist/translator/util/signals.d.ts +8 -12
- package/dist/translator/util/slots.d.ts +50 -0
- package/dist/translator/util/solve-reasons.d.ts +10 -0
- package/dist/translator/util/sources.d.ts +21 -0
- package/dist/translator/util/structure.d.ts +5 -2
- package/dist/translator/util/tag-facts.d.ts +21 -0
- package/dist/translator/util/tag-name-type.d.ts +4 -1
- package/dist/translator/util/translate-attrs.d.ts +2 -0
- package/dist/translator/util/translate-var.d.ts +3 -0
- package/dist/translator/util/write-guard.d.ts +12 -0
- package/dist/translator/util/writer.d.ts +3 -3
- package/dist/translator/visitors/export-declaration.d.ts +9 -0
- package/dist/translator/visitors/function.d.ts +5 -4
- package/dist/translator/visitors/import-declaration.d.ts +2 -2
- package/dist/translator/visitors/placeholder.d.ts +0 -3
- package/dist/translator/visitors/program/index.d.ts +13 -3
- package/dist/translator/visitors/referenced-identifier.d.ts +2 -1
- package/dist/translator/visitors/tag/custom-tag.d.ts +1 -1
- package/dist/translator/visitors/tag/dynamic-tag.d.ts +0 -3
- package/dist/translator/visitors/tag/index.d.ts +2 -1
- package/dist/translator/visitors/tag/native-tag.d.ts +26 -11
- package/package.json +3 -3
- package/dist/translator/util/insertion-context.d.ts +0 -1
- package/dist/translator/util/is-non-html-text.d.ts +0 -3
- package/dist/translator/util/serialize-guard.d.ts +0 -11
- package/dist/translator/util/serialize-reasons.d.ts +0 -37
- package/dist/translator/util/set-tag-sections-downstream.d.ts +0 -6
- package/dist/translator/util/setup-statements.d.ts +0 -5
|
@@ -9,11 +9,13 @@ const ControlledHandler = "ControlledHandler:";
|
|
|
9
9
|
const ControlledType = "ControlledType:";
|
|
10
10
|
const ControlledValue = "ControlledValue:";
|
|
11
11
|
const DynamicHTMLLastChild = "DynamicHTMLLastChild:";
|
|
12
|
+
const DynamicHTMLValue = "DynamicHTMLValue:";
|
|
12
13
|
const EventAttributes = "EventAttributes:";
|
|
13
14
|
const KeyedScopes = "KeyedScopes:";
|
|
14
15
|
const Lifecycle = "Lifecycle:";
|
|
15
16
|
const Promise$1 = "Promise:";
|
|
16
17
|
const TagVariableChange$1 = "TagVariableChange:";
|
|
18
|
+
const TryBranch$1 = "TryBranch:";
|
|
17
19
|
//#endregion
|
|
18
20
|
//#region src/common/constants/accessor-prop.debug.ts
|
|
19
21
|
const Global = "$global";
|
|
@@ -32,15 +34,18 @@ const Load = "#Load";
|
|
|
32
34
|
const LoopKey = "#LoopKey";
|
|
33
35
|
const ParentBranch = "#ParentBranch";
|
|
34
36
|
const PendingEffects = "#PendingEffects";
|
|
37
|
+
const PendingEffectScopes = "#PendingEffectScopes";
|
|
35
38
|
const PendingRenders = "#PendingRenders";
|
|
36
39
|
const PendingScopes = "#PendingScopes";
|
|
37
40
|
const PlaceholderBranch = "#PlaceholderBranch";
|
|
38
41
|
const PlaceholderContent = "#PlaceholderContent";
|
|
39
42
|
const Renderer = "#Renderer";
|
|
43
|
+
const ReturnValue = "#ReturnValue";
|
|
40
44
|
const StartNode = "#StartNode";
|
|
41
45
|
const Subscriptions = "#Subscriptions";
|
|
42
46
|
const TagVariable = "#TagVariable";
|
|
43
47
|
const TagVariableChange = "#TagVariableChange";
|
|
48
|
+
const TryBranch = "#TryBranch";
|
|
44
49
|
//#endregion
|
|
45
50
|
//#region src/common/constants/closure-scopes-prop.debug.ts
|
|
46
51
|
const Changed = "Changed";
|
|
@@ -135,19 +140,21 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
135
140
|
let str = "";
|
|
136
141
|
let sep = "";
|
|
137
142
|
let part;
|
|
138
|
-
if (val)
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
143
|
+
if (val) {
|
|
144
|
+
if (typeof val !== "object") str += val;
|
|
145
|
+
else if (Array.isArray(val)) for (const v of val) {
|
|
146
|
+
part = toDelimitedString(v, delimiter, stringify);
|
|
147
|
+
if (part) {
|
|
148
|
+
str += sep + part;
|
|
149
|
+
sep = delimiter;
|
|
150
|
+
}
|
|
144
151
|
}
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
152
|
+
else for (const name in val) {
|
|
153
|
+
part = stringify(name, val[name]);
|
|
154
|
+
if (part) {
|
|
155
|
+
str += sep + part;
|
|
156
|
+
sep = delimiter;
|
|
157
|
+
}
|
|
151
158
|
}
|
|
152
159
|
}
|
|
153
160
|
return str;
|
|
@@ -250,18 +257,18 @@ function _hoist_read_error() {
|
|
|
250
257
|
function _assert_hoist(value) {
|
|
251
258
|
if (value !== void 0 && typeof value !== "function") throw new Error(`Hoisted values must be functions, received type "${typeof value}".`);
|
|
252
259
|
}
|
|
253
|
-
function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
260
|
+
function assertExclusiveAttrs(attrs, onError = throwErr, isSet = isTruthy) {
|
|
254
261
|
if (attrs) {
|
|
255
262
|
let exclusiveAttrs;
|
|
256
|
-
if (attrs.checkedChange) (exclusiveAttrs ||= []).push("checkedChange");
|
|
263
|
+
if (isSet(attrs.checkedChange)) (exclusiveAttrs ||= []).push("checkedChange");
|
|
257
264
|
if ("checkedValue" in attrs) {
|
|
258
265
|
(exclusiveAttrs ||= []).push("checkedValue");
|
|
259
266
|
if ("checked" in attrs) exclusiveAttrs.push("checked");
|
|
260
|
-
} else if (attrs.checkedValueChange) {
|
|
267
|
+
} else if (isSet(attrs.checkedValueChange)) {
|
|
261
268
|
(exclusiveAttrs ||= []).push("checkedValueChange");
|
|
262
269
|
if ("checked" in attrs) exclusiveAttrs.push("checked");
|
|
263
270
|
}
|
|
264
|
-
if (attrs.valueChange) {
|
|
271
|
+
if (isSet(attrs.valueChange)) {
|
|
265
272
|
(exclusiveAttrs ||= []).push("valueChange");
|
|
266
273
|
if ("checked" in attrs && !exclusiveAttrs.includes("checked")) exclusiveAttrs.push("checked");
|
|
267
274
|
}
|
|
@@ -277,6 +284,9 @@ function assertHandlerIsFunction(name, value) {
|
|
|
277
284
|
function assertValidTagName(tagName) {
|
|
278
285
|
if (!/^[a-z][a-z0-9._-]*$/i.test(tagName)) throw new Error(`Invalid tag name: "${tagName}". Tag names must start with a letter and contain only letters, numbers, periods, hyphens, and underscores.`);
|
|
279
286
|
}
|
|
287
|
+
function isTruthy(value) {
|
|
288
|
+
return value;
|
|
289
|
+
}
|
|
280
290
|
function throwErr(msg) {
|
|
281
291
|
throw new Error(msg);
|
|
282
292
|
}
|
|
@@ -320,8 +330,6 @@ function forUntil(until, from, step, cb) {
|
|
|
320
330
|
//#region src/dom/queue.ts
|
|
321
331
|
let rendering;
|
|
322
332
|
let runId = 2;
|
|
323
|
-
const caughtError = /* @__PURE__ */ new WeakSet();
|
|
324
|
-
const placeholderShown = /* @__PURE__ */ new WeakSet();
|
|
325
333
|
let pendingEffects = [];
|
|
326
334
|
let pendingRenders = [];
|
|
327
335
|
const scopeKeyOffset = 1e6;
|
|
@@ -398,10 +406,10 @@ let runRender = (render) => {
|
|
|
398
406
|
if (!branchesEnabled || render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) render[Signal](render[Scope], render[Value]);
|
|
399
407
|
};
|
|
400
408
|
let catchEnabled;
|
|
401
|
-
function installCatch(
|
|
409
|
+
function installCatch(catchEffects, wrapRender) {
|
|
402
410
|
catchEnabled = 1;
|
|
403
411
|
withBranches();
|
|
404
|
-
runEffects =
|
|
412
|
+
runEffects = catchEffects;
|
|
405
413
|
runRender = wrapRender(runRender);
|
|
406
414
|
}
|
|
407
415
|
function runRenders() {
|
|
@@ -442,6 +450,12 @@ function $signal(scope, id) {
|
|
|
442
450
|
trackCleanup(scope);
|
|
443
451
|
return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
|
|
444
452
|
}
|
|
453
|
+
/** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
|
|
454
|
+
function trackAbort(scope, id, abort) {
|
|
455
|
+
abortsEnabled = 1;
|
|
456
|
+
trackCleanup(scope);
|
|
457
|
+
(scope[AbortControllers] ||= {})[id] = { abort };
|
|
458
|
+
}
|
|
445
459
|
/** Enrols `scope` with its branch so destroying the branch cleans it up. */
|
|
446
460
|
function trackCleanup(scope, subscribers) {
|
|
447
461
|
const branch = scope[ClosestBranch];
|
|
@@ -462,8 +476,10 @@ function toArray(opt) {
|
|
|
462
476
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
463
477
|
}
|
|
464
478
|
function forEach(opt, cb) {
|
|
465
|
-
if (opt)
|
|
466
|
-
|
|
479
|
+
if (opt) {
|
|
480
|
+
if (Array.isArray(opt)) for (const item of opt) cb(item);
|
|
481
|
+
else cb(opt);
|
|
482
|
+
}
|
|
467
483
|
}
|
|
468
484
|
function push(opt, item) {
|
|
469
485
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
@@ -538,11 +554,6 @@ function collectScopes(fn) {
|
|
|
538
554
|
function skipScope() {
|
|
539
555
|
return nextScopeId++;
|
|
540
556
|
}
|
|
541
|
-
function findBranchWithKey(scope, key) {
|
|
542
|
-
let branch = scope[ClosestBranch];
|
|
543
|
-
while (branch && branch[key] == null) branch = branch[ParentBranch];
|
|
544
|
-
return branch;
|
|
545
|
-
}
|
|
546
557
|
function destroyBranch(branch) {
|
|
547
558
|
branch[ParentBranch]?.[BranchScopes]?.delete(branch);
|
|
548
559
|
destroyNestedScopes(branch);
|
|
@@ -633,11 +644,12 @@ function _let_change(id, fn) {
|
|
|
633
644
|
const valueChangeAccessor = TagVariableChange$1 + valueAccessor;
|
|
634
645
|
const base = _let(id, fn);
|
|
635
646
|
return (scope, value, valueChange) => {
|
|
636
|
-
if (rendering)
|
|
637
|
-
scope[
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
647
|
+
if (rendering) {
|
|
648
|
+
if ((scope[valueChangeAccessor] = valueChange) && (scope[valueAccessor] !== value || !(valueAccessor in scope))) {
|
|
649
|
+
scope[valueAccessor] = value;
|
|
650
|
+
fn?.(scope);
|
|
651
|
+
} else base(scope, value);
|
|
652
|
+
} else if (scope[valueChangeAccessor]) scope[valueChangeAccessor](value);
|
|
641
653
|
else base(scope, value);
|
|
642
654
|
return value;
|
|
643
655
|
};
|
|
@@ -652,10 +664,11 @@ function _const(valueAccessor, fn) {
|
|
|
652
664
|
}
|
|
653
665
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
654
666
|
return (scope) => {
|
|
655
|
-
if (scope["#Gen"] === runId)
|
|
656
|
-
if (
|
|
657
|
-
|
|
658
|
-
|
|
667
|
+
if (scope["#Gen"] === runId) {
|
|
668
|
+
if (~id in scope) {
|
|
669
|
+
if (!--scope[~id]) fn(scope);
|
|
670
|
+
} else scope[~id] = defaultPending;
|
|
671
|
+
} else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
659
672
|
};
|
|
660
673
|
}
|
|
661
674
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
@@ -738,7 +751,8 @@ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
|
738
751
|
const closureSignal = ((scope, resumed) => {
|
|
739
752
|
const ownerScope = getOwnerScope ? getOwnerScope(scope) : scope["_"];
|
|
740
753
|
scope[closureSignal[SignalIndexAccessor]] = closureSignal[Index];
|
|
741
|
-
if (!resumed
|
|
754
|
+
if (!resumed) fn(scope);
|
|
755
|
+
else if (ownerScope[closureSignal["scopeInstancesAccessor"]]["Changed"]) queueAsyncRender(scope, closureSignal);
|
|
742
756
|
subscribeToScopeSet(ownerScope, closureSignal[ScopeInstancesAccessor], scope);
|
|
743
757
|
});
|
|
744
758
|
closureSignal[ScopeInstancesAccessor] = ClosureScopes + valueAccessor;
|
|
@@ -754,9 +768,11 @@ function _child_setup(setup) {
|
|
|
754
768
|
return setup;
|
|
755
769
|
}
|
|
756
770
|
function _var(scope, childAccessor, signal) {
|
|
757
|
-
scope[childAccessor]
|
|
771
|
+
const childScope = scope[childAccessor];
|
|
772
|
+
childScope[TagVariable] = (value) => signal(scope, value);
|
|
773
|
+
if ("#ReturnValue" in childScope) signal(scope, childScope[ReturnValue]);
|
|
758
774
|
}
|
|
759
|
-
const _return = (scope, value) => scope[TagVariable]
|
|
775
|
+
const _return = (scope, value) => scope["#TagVariable"] ? scope[TagVariable](value) : scope[ReturnValue] = value;
|
|
760
776
|
function _return_change(scope, changeHandler) {
|
|
761
777
|
scope[TagVariableChange] = changeHandler || void 0;
|
|
762
778
|
}
|
|
@@ -783,7 +799,7 @@ function _script(id, fn) {
|
|
|
783
799
|
};
|
|
784
800
|
}
|
|
785
801
|
function _global_read($global, key) {
|
|
786
|
-
if (!(key in $global)) console.error(`\`$global.${key}\` is not serialized to the client, so this read is \`undefined\`.
|
|
802
|
+
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.`);
|
|
787
803
|
return $global[key];
|
|
788
804
|
}
|
|
789
805
|
function _el_read(value) {
|
|
@@ -792,12 +808,15 @@ function _el_read(value) {
|
|
|
792
808
|
}
|
|
793
809
|
function* traverse(scope, path, args, i = path.length - 1) {
|
|
794
810
|
if (rendering) _hoist_read_error();
|
|
795
|
-
if (scope)
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
811
|
+
if (scope) {
|
|
812
|
+
if (Symbol.iterator in scope) {
|
|
813
|
+
for (const childScope of scope.values()) if (childScope["#Gen"] !== 0) yield* traverse(childScope, path, args, i);
|
|
814
|
+
} else {
|
|
815
|
+
const step = path[i];
|
|
816
|
+
const item = Array.isArray(step) ? (scope[step[1]] || 0) === step[2] && scope[step[0]] : scope[step];
|
|
817
|
+
if (i) yield* traverse(item, path, args, i - 1);
|
|
818
|
+
else yield typeof item === "function" ? item(...args) : item;
|
|
819
|
+
}
|
|
801
820
|
}
|
|
802
821
|
}
|
|
803
822
|
function _hoist(...path) {
|
|
@@ -881,9 +900,8 @@ function readyFailed(readyId) {
|
|
|
881
900
|
(failedIds ||= /* @__PURE__ */ new Set()).add(readyId);
|
|
882
901
|
console.error(`The lazy module for "${readyId}" failed to load; its server-rendered content cannot become interactive.`);
|
|
883
902
|
}
|
|
884
|
-
function withLazy(
|
|
903
|
+
function withLazy() {
|
|
885
904
|
lazyEnabled = 1;
|
|
886
|
-
return runtime;
|
|
887
905
|
}
|
|
888
906
|
function initEmbedded(readyId, runtimeId) {
|
|
889
907
|
if (!embedRenders) {
|
|
@@ -957,7 +975,7 @@ function init(runtimeId = "M") {
|
|
|
957
975
|
setParentBranch(branch, branch[ClosestBranch]);
|
|
958
976
|
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
|
|
959
977
|
if (singleNode) {
|
|
960
|
-
while (startVisit.previousSibling &&
|
|
978
|
+
while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
|
|
961
979
|
branch["_"] ??= visitScope;
|
|
962
980
|
branch[EndNode] = branch[StartNode] = startVisit;
|
|
963
981
|
if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
@@ -1024,6 +1042,7 @@ function init(runtimeId = "M") {
|
|
|
1024
1042
|
let embedAnchor;
|
|
1025
1043
|
serializeContext._ = _resumed;
|
|
1026
1044
|
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.`);
|
|
1045
|
+
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.`);
|
|
1027
1046
|
render.m = (effects) => {
|
|
1028
1047
|
processResumes(render.r, effects);
|
|
1029
1048
|
if (readyIds && render.b) for (let progress = 1; progress;) {
|
|
@@ -1039,13 +1058,15 @@ function init(runtimeId = "M") {
|
|
|
1039
1058
|
visitText = visit.data;
|
|
1040
1059
|
visitType = visitText[lastTokenIndex++];
|
|
1041
1060
|
visitScope = getScope(nextToken());
|
|
1042
|
-
if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'")
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1061
|
+
if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
|
|
1062
|
+
if (visitType === "&") htmlStart = visit;
|
|
1063
|
+
else {
|
|
1064
|
+
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.");
|
|
1065
|
+
visitScope[nextToken()] = htmlStart;
|
|
1066
|
+
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1067
|
+
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1068
|
+
}
|
|
1069
|
+
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1049
1070
|
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1050
1071
|
else {
|
|
1051
1072
|
visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
|
|
@@ -1080,7 +1101,7 @@ let isResuming;
|
|
|
1080
1101
|
function runResumeEffects(render) {
|
|
1081
1102
|
try {
|
|
1082
1103
|
isResuming = 1;
|
|
1083
|
-
runEffects(render.m([])
|
|
1104
|
+
runEffects(render.m([]));
|
|
1084
1105
|
} finally {
|
|
1085
1106
|
isResuming = 0;
|
|
1086
1107
|
}
|
|
@@ -1148,6 +1169,7 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
1148
1169
|
function _content_resume(renderer, hasLocalValues = 0) {
|
|
1149
1170
|
return _resumed[renderer()["id"]] = (owner, ...values) => {
|
|
1150
1171
|
for (let i = values.length, scope = owner; i > hasLocalValues;) {
|
|
1172
|
+
if (!scope) throw new Error("Unable to resume registered content: its payload does not link the owner of every closure level.");
|
|
1151
1173
|
const closures = values[--i];
|
|
1152
1174
|
for (const key in closures) if (!(key in scope)) scope[key] = closures[key];
|
|
1153
1175
|
scope = scope["_"];
|
|
@@ -1196,8 +1218,10 @@ function _attr(element, name, value) {
|
|
|
1196
1218
|
setAttribute(element, name, normalizeAttrValue(value));
|
|
1197
1219
|
}
|
|
1198
1220
|
function setAttribute(element, name, value) {
|
|
1199
|
-
if (element.getAttribute(name) != value)
|
|
1200
|
-
|
|
1221
|
+
if (element.getAttribute(name) != value) {
|
|
1222
|
+
if (value === void 0) element.removeAttribute(name);
|
|
1223
|
+
else element.setAttribute(name, value);
|
|
1224
|
+
}
|
|
1201
1225
|
}
|
|
1202
1226
|
function _attr_class(element, value) {
|
|
1203
1227
|
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
@@ -1302,7 +1326,6 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
|
1302
1326
|
assertValidAttrName(name);
|
|
1303
1327
|
if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1304
1328
|
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1305
|
-
break;
|
|
1306
1329
|
}
|
|
1307
1330
|
}
|
|
1308
1331
|
}
|
|
@@ -1321,22 +1344,33 @@ function _attrs_script(scope, nodeAccessor) {
|
|
|
1321
1344
|
for (const name in events) _on(el, name, events[name]);
|
|
1322
1345
|
}
|
|
1323
1346
|
const _html = /*@__PURE__*/ withDynamicHtml(function _html(scope, value, accessor) {
|
|
1324
|
-
const
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1347
|
+
const prevValue = scope[DynamicHTMLValue + accessor];
|
|
1348
|
+
if (prevValue !== (scope["DynamicHTMLValue:" + accessor] = _to_text(value))) {
|
|
1349
|
+
const firstChild = scope[accessor];
|
|
1350
|
+
const parentNode = firstChild.parentNode;
|
|
1351
|
+
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1352
|
+
const newContent = parseHTML(scope[DynamicHTMLValue + accessor], parentNode.namespaceURI);
|
|
1353
|
+
if (prevValue === void 0 && lastChild !== firstChild) {
|
|
1354
|
+
let node = firstChild;
|
|
1355
|
+
let newNode = newContent.firstChild;
|
|
1356
|
+
while ((node = node.nextSibling) !== lastChild && node.isEqualNode(newNode)) newNode = newNode.nextSibling;
|
|
1357
|
+
if (node === lastChild && !newNode) return;
|
|
1358
|
+
}
|
|
1359
|
+
const newFirstChild = scope[accessor] = newContent.firstChild || newContent.appendChild(new Text());
|
|
1360
|
+
const newLastChild = scope[DynamicHTMLLastChild + accessor] = newContent.lastChild;
|
|
1361
|
+
const branch = scope[ClosestBranch];
|
|
1362
|
+
if (branch?.["#StartNode"] === firstChild) branch[StartNode] = newFirstChild;
|
|
1363
|
+
if (branch?.["#EndNode"] === lastChild) branch[EndNode] = newLastChild;
|
|
1364
|
+
insertChildNodes(parentNode, firstChild, newFirstChild, newLastChild);
|
|
1365
|
+
removeChildNodes(firstChild, lastChild);
|
|
1366
|
+
}
|
|
1335
1367
|
});
|
|
1336
1368
|
function normalizeClientRender(value) {
|
|
1337
1369
|
const renderer = normalizeDynamicRenderer(value);
|
|
1338
|
-
if (renderer)
|
|
1339
|
-
|
|
1370
|
+
if (renderer) {
|
|
1371
|
+
if (renderer["id"]) return renderer;
|
|
1372
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1373
|
+
}
|
|
1340
1374
|
}
|
|
1341
1375
|
function normalizeAttrValue(value) {
|
|
1342
1376
|
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
@@ -1354,7 +1388,7 @@ function _lifecycle(scope, thisObj, index = 0) {
|
|
|
1354
1388
|
Object.assign(thisObj, thisObj.onMount?.());
|
|
1355
1389
|
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1356
1390
|
}
|
|
1357
|
-
|
|
1391
|
+
trackAbort(scope, accessor, () => thisObj.onDestroy?.());
|
|
1358
1392
|
}
|
|
1359
1393
|
}
|
|
1360
1394
|
function removeChildNodes(startNode, endNode) {
|
|
@@ -1456,8 +1490,10 @@ function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValu
|
|
|
1456
1490
|
}
|
|
1457
1491
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
1458
1492
|
const el = scope[nodeAccessor];
|
|
1459
|
-
if (isResuming && el.defaultChecked)
|
|
1460
|
-
|
|
1493
|
+
if (isResuming && el.defaultChecked) {
|
|
1494
|
+
if (scope["ControlledValue:" + nodeAccessor]) scope[ControlledValue + nodeAccessor].push(el.value);
|
|
1495
|
+
else scope[ControlledValue + nodeAccessor] = el.value;
|
|
1496
|
+
}
|
|
1461
1497
|
syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
1462
1498
|
const checkedValueChange = scope[ControlledHandler + nodeAccessor];
|
|
1463
1499
|
if (checkedValueChange) {
|
|
@@ -1566,14 +1602,16 @@ function _attr_select_value_script(scope, nodeAccessor) {
|
|
|
1566
1602
|
run();
|
|
1567
1603
|
}
|
|
1568
1604
|
};
|
|
1569
|
-
if (isResuming)
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1605
|
+
if (isResuming) {
|
|
1606
|
+
if (el.multiple) {
|
|
1607
|
+
scope[ControlledValue + nodeAccessor] = [];
|
|
1608
|
+
for (const opt of el.options) if (opt.defaultSelected) scope[ControlledValue + nodeAccessor].push(opt.value);
|
|
1609
|
+
} else {
|
|
1610
|
+
scope[ControlledValue + nodeAccessor] = "";
|
|
1611
|
+
for (const opt of el.options) if (opt.defaultSelected) {
|
|
1612
|
+
scope[ControlledValue + nodeAccessor] = opt.value;
|
|
1613
|
+
break;
|
|
1614
|
+
}
|
|
1577
1615
|
}
|
|
1578
1616
|
}
|
|
1579
1617
|
syncControllableFormInput(el, hasSelectChanged, onChange);
|
|
@@ -1695,6 +1733,7 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
|
|
|
1695
1733
|
function _await_promise(nodeAccessor, params) {
|
|
1696
1734
|
const promiseAccessor = Promise$1 + nodeAccessor;
|
|
1697
1735
|
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
1736
|
+
const tryAccessor = TryBranch$1 + nodeAccessor;
|
|
1698
1737
|
const resolveAwait = (scope, referenceNode, value) => {
|
|
1699
1738
|
const awaitBranch = scope[branchAccessor];
|
|
1700
1739
|
if (awaitBranch["#DetachedAwait"]) {
|
|
@@ -1710,80 +1749,73 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1710
1749
|
const awaitPromise = (scope, promise) => {
|
|
1711
1750
|
if (!isPromise(scope[promiseAccessor])) scope[promiseAccessor] = 0;
|
|
1712
1751
|
let awaitBranch = scope[branchAccessor];
|
|
1713
|
-
const
|
|
1714
|
-
const tryBranch = tryPlaceholder || awaitBranch;
|
|
1752
|
+
const tryBranch = scope[tryAccessor] || isPromise(promise) && findTryWithPlaceholder(scope) || awaitBranch;
|
|
1715
1753
|
if (!tryBranch) {
|
|
1716
1754
|
const deferred = scope[promiseAccessor] = () => deferred === scope[promiseAccessor] && awaitPromise(scope, promise);
|
|
1717
|
-
const awaitCounter =
|
|
1755
|
+
const awaitCounter = findTryWithPlaceholder(scope)?.[AwaitCounter];
|
|
1718
1756
|
if (awaitCounter?.i) {
|
|
1719
1757
|
const complete = awaitCounter.c;
|
|
1720
1758
|
awaitCounter.c = () => complete() || queueAsyncRender(scope, deferred);
|
|
1721
1759
|
}
|
|
1722
1760
|
return;
|
|
1723
1761
|
}
|
|
1724
|
-
if (!isPromise(promise)) return scope[
|
|
1762
|
+
if (!isPromise(promise)) return scope[tryAccessor] ? awaitPromise(scope, Promise.resolve(promise)) : resolveAwait(scope, scope[nodeAccessor], promise);
|
|
1725
1763
|
let awaitCounter = tryBranch[AwaitCounter];
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
if (
|
|
1731
|
-
const detachedParent = scope[branchAccessor][StartNode].parentNode;
|
|
1732
|
-
if (detachedParent === anchor.parentNode) anchor.remove();
|
|
1733
|
-
else anchor.replaceWith(detachedParent);
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
});
|
|
1737
|
-
if (!scope[promiseAccessor]) {
|
|
1738
|
-
if (awaitBranch) awaitBranch[PendingRenders] ||= [];
|
|
1739
|
-
if (tryPlaceholder) awaitCounter = addAwaitCounter(scope, tryPlaceholder);
|
|
1740
|
-
else scheduleAwaitFrame(awaitCounter, scope, () => {
|
|
1741
|
-
if (!awaitBranch["#DetachedAwait"]) {
|
|
1742
|
-
awaitBranch[StartNode].parentNode.insertBefore(scope[nodeAccessor], awaitBranch[StartNode]);
|
|
1743
|
-
tempDetachBranch(tryBranch);
|
|
1744
|
-
}
|
|
1764
|
+
if (!scope[tryAccessor]) {
|
|
1765
|
+
scope[tryAccessor] = tryBranch;
|
|
1766
|
+
trackAbort(scope, promiseAccessor, () => {
|
|
1767
|
+
scope[promiseAccessor] = 0;
|
|
1768
|
+
if (scope[tryAccessor]) queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
|
|
1745
1769
|
});
|
|
1770
|
+
if (awaitBranch) awaitBranch[PendingRenders] ||= [];
|
|
1771
|
+
if (tryBranch !== awaitBranch) awaitCounter = addAwaitCounter(scope, tryBranch);
|
|
1772
|
+
else {
|
|
1773
|
+
if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
|
|
1774
|
+
if (tryBranch === scope[branchAccessor]) {
|
|
1775
|
+
const anchor = scope[nodeAccessor];
|
|
1776
|
+
if (anchor.parentNode) {
|
|
1777
|
+
const detachedParent = scope[branchAccessor][StartNode].parentNode;
|
|
1778
|
+
if (detachedParent === anchor.parentNode) anchor.remove();
|
|
1779
|
+
else anchor.replaceWith(detachedParent);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
scheduleAwaitFrame(awaitCounter, scope, () => {
|
|
1784
|
+
if (!awaitBranch["#DetachedAwait"]) {
|
|
1785
|
+
awaitBranch[StartNode].parentNode.insertBefore(scope[nodeAccessor], awaitBranch[StartNode]);
|
|
1786
|
+
tempDetachBranch(tryBranch);
|
|
1787
|
+
}
|
|
1788
|
+
});
|
|
1789
|
+
}
|
|
1746
1790
|
}
|
|
1747
1791
|
const thisPromise = scope[promiseAccessor] = promise.then((data) => {
|
|
1748
1792
|
if (thisPromise === scope[promiseAccessor]) {
|
|
1749
1793
|
const referenceNode = scope[nodeAccessor];
|
|
1750
1794
|
scope[promiseAccessor] = 0;
|
|
1751
|
-
if (!scope[branchAccessor]
|
|
1752
|
-
|
|
1795
|
+
if (!scope[branchAccessor]) {
|
|
1796
|
+
scope[tryAccessor] = 0;
|
|
1797
|
+
awaitPromise(scope, data);
|
|
1753
1798
|
awaitCounter.c();
|
|
1754
1799
|
run();
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
awaitCounter.c();
|
|
1764
|
-
if (awaitCounter.m) {
|
|
1765
|
-
const fnScopes = /* @__PURE__ */ new Map();
|
|
1766
|
-
const effects = awaitCounter.m([]);
|
|
1767
|
-
for (let i = 0; i < pendingEffects.length;) {
|
|
1768
|
-
const fn = pendingEffects[i++];
|
|
1769
|
-
let scopes = fnScopes.get(fn);
|
|
1770
|
-
if (!scopes) fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
|
|
1771
|
-
scopes.add(pendingEffects[i++]);
|
|
1772
|
-
}
|
|
1773
|
-
for (let i = 0; i < effects.length;) {
|
|
1774
|
-
const fn = effects[i++];
|
|
1775
|
-
const scope = effects[i++];
|
|
1776
|
-
if (!fnScopes.get(fn)?.has(scope)) queueEffect(scope, fn);
|
|
1777
|
-
}
|
|
1800
|
+
} else queueAsyncRender(scope, () => {
|
|
1801
|
+
if (!scope[promiseAccessor]) {
|
|
1802
|
+
awaitBranch = resolveAwait(scope, referenceNode, data);
|
|
1803
|
+
const pendingRenders = awaitBranch[PendingRenders];
|
|
1804
|
+
awaitBranch[PendingRenders] = 0;
|
|
1805
|
+
pendingRenders?.forEach(queuePendingRender);
|
|
1806
|
+
scope[tryAccessor] = 0;
|
|
1807
|
+
queueCompleteAwaitCounter(tryBranch, awaitCounter);
|
|
1778
1808
|
}
|
|
1779
1809
|
});
|
|
1780
1810
|
}
|
|
1781
1811
|
}, (error) => {
|
|
1782
1812
|
if (thisPromise === scope[promiseAccessor]) {
|
|
1783
|
-
scope[promiseAccessor] = 0;
|
|
1784
|
-
if (tryPlaceholder && !awaitCounter.m) awaitCounter.c();
|
|
1785
|
-
else awaitCounter.i = 0;
|
|
1813
|
+
scope[promiseAccessor] = scope[tryAccessor] = 0;
|
|
1786
1814
|
queueAsyncRender(scope, renderCatch, error);
|
|
1815
|
+
if (tryBranch !== awaitBranch && !awaitCounter.m) {
|
|
1816
|
+
if (findTryWithCatch(scope)) queueCompleteAwaitCounter(tryBranch, awaitCounter);
|
|
1817
|
+
else awaitCounter.c();
|
|
1818
|
+
} else awaitCounter.i = 0;
|
|
1787
1819
|
}
|
|
1788
1820
|
});
|
|
1789
1821
|
};
|
|
@@ -1799,13 +1831,13 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
1799
1831
|
if (typeof scope[promiseAccessor] === "function") scope[promiseAccessor]();
|
|
1800
1832
|
};
|
|
1801
1833
|
}
|
|
1802
|
-
function addAwaitCounter(scope, tryBranch =
|
|
1834
|
+
function addAwaitCounter(scope, tryBranch = findTryWithPlaceholder(scope)) {
|
|
1803
1835
|
if (!tryBranch) return;
|
|
1804
1836
|
let awaitCounter = tryBranch[AwaitCounter];
|
|
1805
1837
|
if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch));
|
|
1806
|
-
placeholderShown.add(pendingEffects);
|
|
1807
1838
|
scheduleAwaitFrame(awaitCounter, tryBranch, () => {
|
|
1808
|
-
|
|
1839
|
+
(tryBranch[PlaceholderBranch] = createAndSetupBranch(tryBranch[Global], tryBranch[PlaceholderContent](), tryBranch["_"], tryBranch[StartNode].parentNode))[TryBranch] = tryBranch;
|
|
1840
|
+
insertBranchBefore(tryBranch[PlaceholderBranch], tryBranch[StartNode].parentNode, tryBranch[StartNode]);
|
|
1809
1841
|
tempDetachBranch(tryBranch);
|
|
1810
1842
|
});
|
|
1811
1843
|
return awaitCounter;
|
|
@@ -1813,10 +1845,32 @@ function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, Placeholder
|
|
|
1813
1845
|
function scheduleAwaitFrame(awaitCounter, scope, render) {
|
|
1814
1846
|
if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, render, -1))));
|
|
1815
1847
|
}
|
|
1848
|
+
function queueCompleteAwaitCounter(tryBranch, awaitCounter) {
|
|
1849
|
+
queueRender(tryBranch, completeAwaitCounter, -1, awaitCounter, tryBranch["#Id"] + 1e9);
|
|
1850
|
+
}
|
|
1851
|
+
function completeAwaitCounter(_scope, awaitCounter) {
|
|
1852
|
+
awaitCounter.c();
|
|
1853
|
+
if (awaitCounter.m) {
|
|
1854
|
+
const fnScopes = /* @__PURE__ */ new Map();
|
|
1855
|
+
const effects = awaitCounter.m([]);
|
|
1856
|
+
for (let i = 0; i < pendingEffects.length;) {
|
|
1857
|
+
const fn = pendingEffects[i++];
|
|
1858
|
+
let scopes = fnScopes.get(fn);
|
|
1859
|
+
if (!scopes) fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
|
|
1860
|
+
scopes.add(pendingEffects[i++]);
|
|
1861
|
+
}
|
|
1862
|
+
for (let i = 0; i < effects.length;) {
|
|
1863
|
+
const fn = effects[i++];
|
|
1864
|
+
const scope = effects[i++];
|
|
1865
|
+
if (!fnScopes.get(fn)?.has(scope)) queueEffect(scope, fn);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1816
1869
|
function createAwaitCounter(tryBranch, done) {
|
|
1817
1870
|
const awaitCounter = tryBranch[AwaitCounter] = {
|
|
1818
1871
|
i: 0,
|
|
1819
1872
|
c() {
|
|
1873
|
+
if (awaitCounter.i < 1) throw new Error("An await counter completed more counts than it took.");
|
|
1820
1874
|
if (--awaitCounter.i) return 1;
|
|
1821
1875
|
done();
|
|
1822
1876
|
queueEffect(tryBranch, runPendingEffects);
|
|
@@ -1824,12 +1878,8 @@ function createAwaitCounter(tryBranch, done) {
|
|
|
1824
1878
|
};
|
|
1825
1879
|
return awaitCounter;
|
|
1826
1880
|
}
|
|
1827
|
-
function runPendingEffects(
|
|
1828
|
-
|
|
1829
|
-
if (effects) {
|
|
1830
|
-
scope[PendingEffects] = [];
|
|
1831
|
-
runEffects(effects, 1);
|
|
1832
|
-
}
|
|
1881
|
+
function runPendingEffects(tryBranch) {
|
|
1882
|
+
tryBranch[PendingEffectScopes]?.forEach((scope) => scope[PendingEffects].forEach((fn) => runEffects([fn, scope]), scope[PendingEffects] = null), tryBranch[PendingEffectScopes] = null);
|
|
1833
1883
|
}
|
|
1834
1884
|
function dismissPlaceholder(tryBranch) {
|
|
1835
1885
|
const placeholderBranch = tryBranch[PlaceholderBranch];
|
|
@@ -1839,21 +1889,19 @@ function dismissPlaceholder(tryBranch) {
|
|
|
1839
1889
|
removeAndDestroyBranch(placeholderBranch);
|
|
1840
1890
|
}
|
|
1841
1891
|
}
|
|
1842
|
-
function _try(nodeAccessor, template, walks, setup) {
|
|
1892
|
+
function _try(nodeAccessor, template, walks, setup, placeholderContent, catchContent) {
|
|
1843
1893
|
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
1844
1894
|
const renderer = _content("", template, walks, setup)();
|
|
1845
|
-
return (scope
|
|
1846
|
-
|
|
1895
|
+
return (scope) => {
|
|
1896
|
+
setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
|
|
1847
1897
|
const branch = scope[branchAccessor];
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
branch[PlaceholderContent] = normalizeDynamicRenderer(input.placeholder);
|
|
1852
|
-
}
|
|
1898
|
+
branch[BranchAccessor] = nodeAccessor;
|
|
1899
|
+
branch[CatchContent] = catchContent;
|
|
1900
|
+
branch[PlaceholderContent] = placeholderContent || void 0;
|
|
1853
1901
|
};
|
|
1854
1902
|
}
|
|
1855
1903
|
function renderCatch(scope, error) {
|
|
1856
|
-
const tryWithCatch =
|
|
1904
|
+
const tryWithCatch = findTryWithCatch(scope);
|
|
1857
1905
|
if (!tryWithCatch) throw error;
|
|
1858
1906
|
else {
|
|
1859
1907
|
const owner = tryWithCatch["_"];
|
|
@@ -1863,11 +1911,21 @@ function renderCatch(scope, error) {
|
|
|
1863
1911
|
owner[BranchScopes$1 + tryWithCatch[BranchAccessor]] = placeholderBranch;
|
|
1864
1912
|
destroyBranch(tryWithCatch);
|
|
1865
1913
|
}
|
|
1866
|
-
|
|
1867
|
-
setConditionalRenderer(owner, tryWithCatch[BranchAccessor],
|
|
1868
|
-
|
|
1914
|
+
const catchContent = tryWithCatch[CatchContent]();
|
|
1915
|
+
setConditionalRenderer(owner, tryWithCatch[BranchAccessor], catchContent, createAndSetupBranch);
|
|
1916
|
+
catchContent[Params]?.(owner[BranchScopes$1 + tryWithCatch[BranchAccessor]], [error]);
|
|
1869
1917
|
}
|
|
1870
1918
|
}
|
|
1919
|
+
function findTryWithPlaceholder(scope) {
|
|
1920
|
+
let branch = scope[ClosestBranch];
|
|
1921
|
+
while (branch && !branch["#PlaceholderContent"]) branch = branch[ParentBranch];
|
|
1922
|
+
return branch;
|
|
1923
|
+
}
|
|
1924
|
+
function findTryWithCatch(scope) {
|
|
1925
|
+
let branch = scope[ClosestBranch];
|
|
1926
|
+
while (branch && !branch["#CatchContent"]) branch = branch["#TryBranch"] || branch["#ParentBranch"];
|
|
1927
|
+
return branch;
|
|
1928
|
+
}
|
|
1871
1929
|
const _if = /*@__PURE__*/ withBranches((nodeAccessor, ...branchesArgs) => {
|
|
1872
1930
|
const branchAccessor = ConditionalRenderer + nodeAccessor;
|
|
1873
1931
|
const branches = [];
|
|
@@ -1924,10 +1982,12 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
|
|
|
1924
1982
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
|
1925
1983
|
const renderer = normalizedRenderer || (getContent ? getContent(scope) : void 0);
|
|
1926
1984
|
setConditionalRenderer(scope, nodeAccessor, renderer, createBranchWithTagNameOrRenderer);
|
|
1927
|
-
if (getTagVar)
|
|
1928
|
-
scope[childScopeAccessor]
|
|
1929
|
-
|
|
1930
|
-
|
|
1985
|
+
if (getTagVar) {
|
|
1986
|
+
if (scope[childScopeAccessor]) {
|
|
1987
|
+
scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
|
|
1988
|
+
if (typeof normalizedRenderer === "string") bindNativeTagVar?.(scope[childScopeAccessor]);
|
|
1989
|
+
} else getTagVar()(scope, void 0);
|
|
1990
|
+
}
|
|
1931
1991
|
if (typeof renderer === "string") {
|
|
1932
1992
|
if (getContent) {
|
|
1933
1993
|
const content = getContent(scope);
|
|
@@ -1945,13 +2005,15 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
|
|
|
1945
2005
|
if (childScope["EventAttributes:" + nodeAccessor] || childScope["ControlledHandler:" + nodeAccessor]) queueEffect(childScope, dynamicTagScript);
|
|
1946
2006
|
} else {
|
|
1947
2007
|
normalizedRenderer[LocalClosures]?.(childScope);
|
|
1948
|
-
if (normalizedRenderer["params"])
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
2008
|
+
if (normalizedRenderer["params"]) {
|
|
2009
|
+
if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
|
|
2010
|
+
else {
|
|
2011
|
+
const inputWithContent = getContent ? {
|
|
2012
|
+
...args,
|
|
2013
|
+
content: getContent(scope)
|
|
2014
|
+
} : args || {};
|
|
2015
|
+
normalizedRenderer[Params](childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
|
|
2016
|
+
}
|
|
1955
2017
|
}
|
|
1956
2018
|
}
|
|
1957
2019
|
}
|
|
@@ -2089,20 +2151,22 @@ function reorderKeyed(newScopes, start, newEnd, parentNode, afterReference) {
|
|
|
2089
2151
|
let hi;
|
|
2090
2152
|
let mid;
|
|
2091
2153
|
for (let i = diffLen; i--;) sources[i] = newScopes[start + i]["#LoopIndex"] ?? -1;
|
|
2092
|
-
for (let i = 0; i < diffLen; i++) if (~sources[i])
|
|
2093
|
-
if (
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
if (
|
|
2105
|
-
|
|
2154
|
+
for (let i = 0; i < diffLen; i++) if (~sources[i]) {
|
|
2155
|
+
if (tail < 0 || sources[tails[tail]] < sources[i]) {
|
|
2156
|
+
if (~tail) pred[i] = tails[tail];
|
|
2157
|
+
tails[++tail] = i;
|
|
2158
|
+
} else {
|
|
2159
|
+
lo = 0;
|
|
2160
|
+
hi = tail;
|
|
2161
|
+
while (lo < hi) {
|
|
2162
|
+
mid = (lo + hi) / 2 | 0;
|
|
2163
|
+
if (sources[tails[mid]] < sources[i]) lo = mid + 1;
|
|
2164
|
+
else hi = mid;
|
|
2165
|
+
}
|
|
2166
|
+
if (sources[i] < sources[tails[lo]]) {
|
|
2167
|
+
if (lo > 0) pred[i] = tails[lo - 1];
|
|
2168
|
+
tails[lo] = i;
|
|
2169
|
+
}
|
|
2106
2170
|
}
|
|
2107
2171
|
}
|
|
2108
2172
|
hi = tails[tail];
|
|
@@ -2221,6 +2285,12 @@ Object.defineProperty(exports, "Pending", {
|
|
|
2221
2285
|
return Pending;
|
|
2222
2286
|
}
|
|
2223
2287
|
});
|
|
2288
|
+
Object.defineProperty(exports, "PendingEffectScopes", {
|
|
2289
|
+
enumerable: true,
|
|
2290
|
+
get: function() {
|
|
2291
|
+
return PendingEffectScopes;
|
|
2292
|
+
}
|
|
2293
|
+
});
|
|
2224
2294
|
Object.defineProperty(exports, "PendingEffects", {
|
|
2225
2295
|
enumerable: true,
|
|
2226
2296
|
get: function() {
|
|
@@ -2797,12 +2867,6 @@ Object.defineProperty(exports, "addAwaitCounter", {
|
|
|
2797
2867
|
return addAwaitCounter;
|
|
2798
2868
|
}
|
|
2799
2869
|
});
|
|
2800
|
-
Object.defineProperty(exports, "caughtError", {
|
|
2801
|
-
enumerable: true,
|
|
2802
|
-
get: function() {
|
|
2803
|
-
return caughtError;
|
|
2804
|
-
}
|
|
2805
|
-
});
|
|
2806
2870
|
Object.defineProperty(exports, "controllableRenders", {
|
|
2807
2871
|
enumerable: true,
|
|
2808
2872
|
get: function() {
|
|
@@ -2911,12 +2975,6 @@ Object.defineProperty(exports, "patchDynamicTag", {
|
|
|
2911
2975
|
return patchDynamicTag;
|
|
2912
2976
|
}
|
|
2913
2977
|
});
|
|
2914
|
-
Object.defineProperty(exports, "placeholderShown", {
|
|
2915
|
-
enumerable: true,
|
|
2916
|
-
get: function() {
|
|
2917
|
-
return placeholderShown;
|
|
2918
|
-
}
|
|
2919
|
-
});
|
|
2920
2978
|
Object.defineProperty(exports, "prepareEffects", {
|
|
2921
2979
|
enumerable: true,
|
|
2922
2980
|
get: function() {
|
|
@@ -2965,6 +3023,12 @@ Object.defineProperty(exports, "renderCatch", {
|
|
|
2965
3023
|
return renderCatch;
|
|
2966
3024
|
}
|
|
2967
3025
|
});
|
|
3026
|
+
Object.defineProperty(exports, "rendering", {
|
|
3027
|
+
enumerable: true,
|
|
3028
|
+
get: function() {
|
|
3029
|
+
return rendering;
|
|
3030
|
+
}
|
|
3031
|
+
});
|
|
2968
3032
|
Object.defineProperty(exports, "run", {
|
|
2969
3033
|
enumerable: true,
|
|
2970
3034
|
get: function() {
|
|
@@ -2983,6 +3047,12 @@ Object.defineProperty(exports, "runId", {
|
|
|
2983
3047
|
return runId;
|
|
2984
3048
|
}
|
|
2985
3049
|
});
|
|
3050
|
+
Object.defineProperty(exports, "runPendingEffects", {
|
|
3051
|
+
enumerable: true,
|
|
3052
|
+
get: function() {
|
|
3053
|
+
return runPendingEffects;
|
|
3054
|
+
}
|
|
3055
|
+
});
|
|
2986
3056
|
Object.defineProperty(exports, "setupBranch", {
|
|
2987
3057
|
enumerable: true,
|
|
2988
3058
|
get: function() {
|