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
|
@@ -8,11 +8,13 @@ const ControlledHandler = "ControlledHandler:";
|
|
|
8
8
|
const ControlledType = "ControlledType:";
|
|
9
9
|
const ControlledValue = "ControlledValue:";
|
|
10
10
|
const DynamicHTMLLastChild = "DynamicHTMLLastChild:";
|
|
11
|
+
const DynamicHTMLValue = "DynamicHTMLValue:";
|
|
11
12
|
const EventAttributes = "EventAttributes:";
|
|
12
13
|
const KeyedScopes = "KeyedScopes:";
|
|
13
14
|
const Lifecycle = "Lifecycle:";
|
|
14
15
|
const Promise$1 = "Promise:";
|
|
15
16
|
const TagVariableChange$1 = "TagVariableChange:";
|
|
17
|
+
const TryBranch$1 = "TryBranch:";
|
|
16
18
|
//#endregion
|
|
17
19
|
//#region src/common/constants/accessor-prop.debug.ts
|
|
18
20
|
const Global = "$global";
|
|
@@ -31,15 +33,18 @@ const Load = "#Load";
|
|
|
31
33
|
const LoopKey = "#LoopKey";
|
|
32
34
|
const ParentBranch = "#ParentBranch";
|
|
33
35
|
const PendingEffects = "#PendingEffects";
|
|
36
|
+
const PendingEffectScopes = "#PendingEffectScopes";
|
|
34
37
|
const PendingRenders = "#PendingRenders";
|
|
35
38
|
const PendingScopes = "#PendingScopes";
|
|
36
39
|
const PlaceholderBranch = "#PlaceholderBranch";
|
|
37
40
|
const PlaceholderContent = "#PlaceholderContent";
|
|
38
41
|
const Renderer = "#Renderer";
|
|
42
|
+
const ReturnValue = "#ReturnValue";
|
|
39
43
|
const StartNode = "#StartNode";
|
|
40
44
|
const Subscriptions = "#Subscriptions";
|
|
41
45
|
const TagVariable = "#TagVariable";
|
|
42
46
|
const TagVariableChange = "#TagVariableChange";
|
|
47
|
+
const TryBranch = "#TryBranch";
|
|
43
48
|
//#endregion
|
|
44
49
|
//#region src/common/constants/closure-scopes-prop.debug.ts
|
|
45
50
|
const Changed = "Changed";
|
|
@@ -134,19 +139,21 @@ const toDelimitedString = function toDelimitedString(val, delimiter, stringify)
|
|
|
134
139
|
let str = "";
|
|
135
140
|
let sep = "";
|
|
136
141
|
let part;
|
|
137
|
-
if (val)
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
142
|
+
if (val) {
|
|
143
|
+
if (typeof val !== "object") str += val;
|
|
144
|
+
else if (Array.isArray(val)) for (const v of val) {
|
|
145
|
+
part = toDelimitedString(v, delimiter, stringify);
|
|
146
|
+
if (part) {
|
|
147
|
+
str += sep + part;
|
|
148
|
+
sep = delimiter;
|
|
149
|
+
}
|
|
143
150
|
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
151
|
+
else for (const name in val) {
|
|
152
|
+
part = stringify(name, val[name]);
|
|
153
|
+
if (part) {
|
|
154
|
+
str += sep + part;
|
|
155
|
+
sep = delimiter;
|
|
156
|
+
}
|
|
150
157
|
}
|
|
151
158
|
}
|
|
152
159
|
return str;
|
|
@@ -249,18 +256,18 @@ function _hoist_read_error() {
|
|
|
249
256
|
function _assert_hoist(value) {
|
|
250
257
|
if (value !== void 0 && typeof value !== "function") throw new Error(`Hoisted values must be functions, received type "${typeof value}".`);
|
|
251
258
|
}
|
|
252
|
-
function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
259
|
+
function assertExclusiveAttrs(attrs, onError = throwErr, isSet = isTruthy) {
|
|
253
260
|
if (attrs) {
|
|
254
261
|
let exclusiveAttrs;
|
|
255
|
-
if (attrs.checkedChange) (exclusiveAttrs ||= []).push("checkedChange");
|
|
262
|
+
if (isSet(attrs.checkedChange)) (exclusiveAttrs ||= []).push("checkedChange");
|
|
256
263
|
if ("checkedValue" in attrs) {
|
|
257
264
|
(exclusiveAttrs ||= []).push("checkedValue");
|
|
258
265
|
if ("checked" in attrs) exclusiveAttrs.push("checked");
|
|
259
|
-
} else if (attrs.checkedValueChange) {
|
|
266
|
+
} else if (isSet(attrs.checkedValueChange)) {
|
|
260
267
|
(exclusiveAttrs ||= []).push("checkedValueChange");
|
|
261
268
|
if ("checked" in attrs) exclusiveAttrs.push("checked");
|
|
262
269
|
}
|
|
263
|
-
if (attrs.valueChange) {
|
|
270
|
+
if (isSet(attrs.valueChange)) {
|
|
264
271
|
(exclusiveAttrs ||= []).push("valueChange");
|
|
265
272
|
if ("checked" in attrs && !exclusiveAttrs.includes("checked")) exclusiveAttrs.push("checked");
|
|
266
273
|
}
|
|
@@ -276,6 +283,9 @@ function assertHandlerIsFunction(name, value) {
|
|
|
276
283
|
function assertValidTagName(tagName) {
|
|
277
284
|
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.`);
|
|
278
285
|
}
|
|
286
|
+
function isTruthy(value) {
|
|
287
|
+
return value;
|
|
288
|
+
}
|
|
279
289
|
function throwErr(msg) {
|
|
280
290
|
throw new Error(msg);
|
|
281
291
|
}
|
|
@@ -319,8 +329,6 @@ function forUntil(until, from, step, cb) {
|
|
|
319
329
|
//#region src/dom/queue.ts
|
|
320
330
|
let rendering;
|
|
321
331
|
let runId = 2;
|
|
322
|
-
const caughtError = /* @__PURE__ */ new WeakSet();
|
|
323
|
-
const placeholderShown = /* @__PURE__ */ new WeakSet();
|
|
324
332
|
let pendingEffects = [];
|
|
325
333
|
let pendingRenders = [];
|
|
326
334
|
const scopeKeyOffset = 1e6;
|
|
@@ -397,10 +405,10 @@ let runRender = (render) => {
|
|
|
397
405
|
if (!branchesEnabled || render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) render[Signal](render[Scope], render[Value]);
|
|
398
406
|
};
|
|
399
407
|
let catchEnabled;
|
|
400
|
-
function installCatch(
|
|
408
|
+
function installCatch(catchEffects, wrapRender) {
|
|
401
409
|
catchEnabled = 1;
|
|
402
410
|
withBranches();
|
|
403
|
-
runEffects =
|
|
411
|
+
runEffects = catchEffects;
|
|
404
412
|
runRender = wrapRender(runRender);
|
|
405
413
|
}
|
|
406
414
|
function runRenders() {
|
|
@@ -441,6 +449,12 @@ function $signal(scope, id) {
|
|
|
441
449
|
trackCleanup(scope);
|
|
442
450
|
return ((scope[AbortControllers] ||= {})[id] ||= new AbortController()).signal;
|
|
443
451
|
}
|
|
452
|
+
/** Runs `abort` as a destroyed scope's `$signal` would fire, without creating one. */
|
|
453
|
+
function trackAbort(scope, id, abort) {
|
|
454
|
+
abortsEnabled = 1;
|
|
455
|
+
trackCleanup(scope);
|
|
456
|
+
(scope[AbortControllers] ||= {})[id] = { abort };
|
|
457
|
+
}
|
|
444
458
|
/** Enrols `scope` with its branch so destroying the branch cleans it up. */
|
|
445
459
|
function trackCleanup(scope, subscribers) {
|
|
446
460
|
const branch = scope[ClosestBranch];
|
|
@@ -461,8 +475,10 @@ function toArray(opt) {
|
|
|
461
475
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
462
476
|
}
|
|
463
477
|
function forEach(opt, cb) {
|
|
464
|
-
if (opt)
|
|
465
|
-
|
|
478
|
+
if (opt) {
|
|
479
|
+
if (Array.isArray(opt)) for (const item of opt) cb(item);
|
|
480
|
+
else cb(opt);
|
|
481
|
+
}
|
|
466
482
|
}
|
|
467
483
|
function push(opt, item) {
|
|
468
484
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
@@ -537,11 +553,6 @@ function collectScopes(fn) {
|
|
|
537
553
|
function skipScope() {
|
|
538
554
|
return nextScopeId++;
|
|
539
555
|
}
|
|
540
|
-
function findBranchWithKey(scope, key) {
|
|
541
|
-
let branch = scope[ClosestBranch];
|
|
542
|
-
while (branch && branch[key] == null) branch = branch[ParentBranch];
|
|
543
|
-
return branch;
|
|
544
|
-
}
|
|
545
556
|
function destroyBranch(branch) {
|
|
546
557
|
branch[ParentBranch]?.[BranchScopes]?.delete(branch);
|
|
547
558
|
destroyNestedScopes(branch);
|
|
@@ -632,11 +643,12 @@ function _let_change(id, fn) {
|
|
|
632
643
|
const valueChangeAccessor = TagVariableChange$1 + valueAccessor;
|
|
633
644
|
const base = _let(id, fn);
|
|
634
645
|
return (scope, value, valueChange) => {
|
|
635
|
-
if (rendering)
|
|
636
|
-
scope[
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
646
|
+
if (rendering) {
|
|
647
|
+
if ((scope[valueChangeAccessor] = valueChange) && (scope[valueAccessor] !== value || !(valueAccessor in scope))) {
|
|
648
|
+
scope[valueAccessor] = value;
|
|
649
|
+
fn?.(scope);
|
|
650
|
+
} else base(scope, value);
|
|
651
|
+
} else if (scope[valueChangeAccessor]) scope[valueChangeAccessor](value);
|
|
640
652
|
else base(scope, value);
|
|
641
653
|
return value;
|
|
642
654
|
};
|
|
@@ -651,10 +663,11 @@ function _const(valueAccessor, fn) {
|
|
|
651
663
|
}
|
|
652
664
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
653
665
|
return (scope) => {
|
|
654
|
-
if (scope["#Gen"] === runId)
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
|
|
666
|
+
if (scope["#Gen"] === runId) {
|
|
667
|
+
if (~id in scope) {
|
|
668
|
+
if (!--scope[~id]) fn(scope);
|
|
669
|
+
} else scope[~id] = defaultPending;
|
|
670
|
+
} else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
658
671
|
};
|
|
659
672
|
}
|
|
660
673
|
function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
@@ -737,7 +750,8 @@ function _closure_get(valueAccessor, fn, getOwnerScope, resumeId) {
|
|
|
737
750
|
const closureSignal = ((scope, resumed) => {
|
|
738
751
|
const ownerScope = getOwnerScope ? getOwnerScope(scope) : scope["_"];
|
|
739
752
|
scope[closureSignal[SignalIndexAccessor]] = closureSignal[Index];
|
|
740
|
-
if (!resumed
|
|
753
|
+
if (!resumed) fn(scope);
|
|
754
|
+
else if (ownerScope[closureSignal["scopeInstancesAccessor"]]["Changed"]) queueAsyncRender(scope, closureSignal);
|
|
741
755
|
subscribeToScopeSet(ownerScope, closureSignal[ScopeInstancesAccessor], scope);
|
|
742
756
|
});
|
|
743
757
|
closureSignal[ScopeInstancesAccessor] = ClosureScopes + valueAccessor;
|
|
@@ -753,9 +767,11 @@ function _child_setup(setup) {
|
|
|
753
767
|
return setup;
|
|
754
768
|
}
|
|
755
769
|
function _var(scope, childAccessor, signal) {
|
|
756
|
-
scope[childAccessor]
|
|
770
|
+
const childScope = scope[childAccessor];
|
|
771
|
+
childScope[TagVariable] = (value) => signal(scope, value);
|
|
772
|
+
if ("#ReturnValue" in childScope) signal(scope, childScope[ReturnValue]);
|
|
757
773
|
}
|
|
758
|
-
const _return = (scope, value) => scope[TagVariable]
|
|
774
|
+
const _return = (scope, value) => scope["#TagVariable"] ? scope[TagVariable](value) : scope[ReturnValue] = value;
|
|
759
775
|
function _return_change(scope, changeHandler) {
|
|
760
776
|
scope[TagVariableChange] = changeHandler || void 0;
|
|
761
777
|
}
|
|
@@ -782,7 +798,7 @@ function _script(id, fn) {
|
|
|
782
798
|
};
|
|
783
799
|
}
|
|
784
800
|
function _global_read($global, key) {
|
|
785
|
-
if (!(key in $global)) console.error(`\`$global.${key}\` is not serialized to the client, so this read is \`undefined\`.
|
|
801
|
+
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.`);
|
|
786
802
|
return $global[key];
|
|
787
803
|
}
|
|
788
804
|
function _el_read(value) {
|
|
@@ -791,12 +807,15 @@ function _el_read(value) {
|
|
|
791
807
|
}
|
|
792
808
|
function* traverse(scope, path, args, i = path.length - 1) {
|
|
793
809
|
if (rendering) _hoist_read_error();
|
|
794
|
-
if (scope)
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
810
|
+
if (scope) {
|
|
811
|
+
if (Symbol.iterator in scope) {
|
|
812
|
+
for (const childScope of scope.values()) if (childScope["#Gen"] !== 0) yield* traverse(childScope, path, args, i);
|
|
813
|
+
} else {
|
|
814
|
+
const step = path[i];
|
|
815
|
+
const item = Array.isArray(step) ? (scope[step[1]] || 0) === step[2] && scope[step[0]] : scope[step];
|
|
816
|
+
if (i) yield* traverse(item, path, args, i - 1);
|
|
817
|
+
else yield typeof item === "function" ? item(...args) : item;
|
|
818
|
+
}
|
|
800
819
|
}
|
|
801
820
|
}
|
|
802
821
|
function _hoist(...path) {
|
|
@@ -880,9 +899,8 @@ function readyFailed(readyId) {
|
|
|
880
899
|
(failedIds ||= /* @__PURE__ */ new Set()).add(readyId);
|
|
881
900
|
console.error(`The lazy module for "${readyId}" failed to load; its server-rendered content cannot become interactive.`);
|
|
882
901
|
}
|
|
883
|
-
function withLazy(
|
|
902
|
+
function withLazy() {
|
|
884
903
|
lazyEnabled = 1;
|
|
885
|
-
return runtime;
|
|
886
904
|
}
|
|
887
905
|
function initEmbedded(readyId, runtimeId) {
|
|
888
906
|
if (!embedRenders) {
|
|
@@ -956,7 +974,7 @@ function init(runtimeId = "M") {
|
|
|
956
974
|
setParentBranch(branch, branch[ClosestBranch]);
|
|
957
975
|
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch[AwaitCounter].m = render.m;
|
|
958
976
|
if (singleNode) {
|
|
959
|
-
while (startVisit.previousSibling &&
|
|
977
|
+
while (startVisit.previousSibling && (startVisit = startVisit.previousSibling).nodeType > 1);
|
|
960
978
|
branch["_"] ??= visitScope;
|
|
961
979
|
branch[EndNode] = branch[StartNode] = startVisit;
|
|
962
980
|
if (visitType === "(") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
@@ -1023,6 +1041,7 @@ function init(runtimeId = "M") {
|
|
|
1023
1041
|
let embedAnchor;
|
|
1024
1042
|
serializeContext._ = _resumed;
|
|
1025
1043
|
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.`);
|
|
1044
|
+
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.`);
|
|
1026
1045
|
render.m = (effects) => {
|
|
1027
1046
|
processResumes(render.r, effects);
|
|
1028
1047
|
if (readyIds && render.b) for (let progress = 1; progress;) {
|
|
@@ -1038,13 +1057,15 @@ function init(runtimeId = "M") {
|
|
|
1038
1057
|
visitText = visit.data;
|
|
1039
1058
|
visitType = visitText[lastTokenIndex++];
|
|
1040
1059
|
visitScope = getScope(nextToken());
|
|
1041
|
-
if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'")
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1060
|
+
if (dynamicHtmlEnabled && visitType > "%" && visitType <= "'") {
|
|
1061
|
+
if (visitType === "&") htmlStart = visit;
|
|
1062
|
+
else {
|
|
1063
|
+
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.");
|
|
1064
|
+
visitScope[nextToken()] = htmlStart;
|
|
1065
|
+
visitScope[DynamicHTMLLastChild + lastToken] = visit;
|
|
1066
|
+
if ((branchesEnabled || lazyEnabled) && pending[pending.length - 1] !== visitScope) pending.push(visitScope);
|
|
1067
|
+
}
|
|
1068
|
+
} else if (branchesEnabled && visitType > "'") (visitBranches ||= createVisitBranches())();
|
|
1048
1069
|
else if (lazyEnabled && render.b && visitType > "%") visits[retained++] = visit;
|
|
1049
1070
|
else {
|
|
1050
1071
|
visitScope[nextToken()] = visitType === "%" ? visit.parentNode.insertBefore(new Text(), visit) : visit.previousSibling;
|
|
@@ -1079,7 +1100,7 @@ let isResuming;
|
|
|
1079
1100
|
function runResumeEffects(render) {
|
|
1080
1101
|
try {
|
|
1081
1102
|
isResuming = 1;
|
|
1082
|
-
runEffects(render.m([])
|
|
1103
|
+
runEffects(render.m([]));
|
|
1083
1104
|
} finally {
|
|
1084
1105
|
isResuming = 0;
|
|
1085
1106
|
}
|
|
@@ -1147,6 +1168,7 @@ function _content(id, template, walks, setup, params, dynamicScopesAccessor) {
|
|
|
1147
1168
|
function _content_resume(renderer, hasLocalValues = 0) {
|
|
1148
1169
|
return _resumed[renderer()["id"]] = (owner, ...values) => {
|
|
1149
1170
|
for (let i = values.length, scope = owner; i > hasLocalValues;) {
|
|
1171
|
+
if (!scope) throw new Error("Unable to resume registered content: its payload does not link the owner of every closure level.");
|
|
1150
1172
|
const closures = values[--i];
|
|
1151
1173
|
for (const key in closures) if (!(key in scope)) scope[key] = closures[key];
|
|
1152
1174
|
scope = scope["_"];
|
|
@@ -1195,8 +1217,10 @@ function _attr(element, name, value) {
|
|
|
1195
1217
|
setAttribute(element, name, normalizeAttrValue(value));
|
|
1196
1218
|
}
|
|
1197
1219
|
function setAttribute(element, name, value) {
|
|
1198
|
-
if (element.getAttribute(name) != value)
|
|
1199
|
-
|
|
1220
|
+
if (element.getAttribute(name) != value) {
|
|
1221
|
+
if (value === void 0) element.removeAttribute(name);
|
|
1222
|
+
else element.setAttribute(name, value);
|
|
1223
|
+
}
|
|
1200
1224
|
}
|
|
1201
1225
|
function _attr_class(element, value) {
|
|
1202
1226
|
setAttribute(element, "class", toDelimitedString(value, " ", stringifyClassObject) || void 0);
|
|
@@ -1301,7 +1325,6 @@ function attrsInternal(scope, nodeAccessor, nextAttrs, controllable) {
|
|
|
1301
1325
|
assertValidAttrName(name);
|
|
1302
1326
|
if (isEventHandler(name)) (events ||= scope[EventAttributes + nodeAccessor] = {})[getEventHandlerName(name)] = value;
|
|
1303
1327
|
else if (!(skip?.test(name) || name === "content" && el.tagName !== "META")) _attr(el, name, value);
|
|
1304
|
-
break;
|
|
1305
1328
|
}
|
|
1306
1329
|
}
|
|
1307
1330
|
}
|
|
@@ -1320,22 +1343,33 @@ function _attrs_script(scope, nodeAccessor) {
|
|
|
1320
1343
|
for (const name in events) _on(el, name, events[name]);
|
|
1321
1344
|
}
|
|
1322
1345
|
const _html = /*@__PURE__*/ withDynamicHtml(function _html(scope, value, accessor) {
|
|
1323
|
-
const
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1346
|
+
const prevValue = scope[DynamicHTMLValue + accessor];
|
|
1347
|
+
if (prevValue !== (scope["DynamicHTMLValue:" + accessor] = _to_text(value))) {
|
|
1348
|
+
const firstChild = scope[accessor];
|
|
1349
|
+
const parentNode = firstChild.parentNode;
|
|
1350
|
+
const lastChild = scope["DynamicHTMLLastChild:" + accessor] || firstChild;
|
|
1351
|
+
const newContent = parseHTML(scope[DynamicHTMLValue + accessor], parentNode.namespaceURI);
|
|
1352
|
+
if (prevValue === void 0 && lastChild !== firstChild) {
|
|
1353
|
+
let node = firstChild;
|
|
1354
|
+
let newNode = newContent.firstChild;
|
|
1355
|
+
while ((node = node.nextSibling) !== lastChild && node.isEqualNode(newNode)) newNode = newNode.nextSibling;
|
|
1356
|
+
if (node === lastChild && !newNode) return;
|
|
1357
|
+
}
|
|
1358
|
+
const newFirstChild = scope[accessor] = newContent.firstChild || newContent.appendChild(new Text());
|
|
1359
|
+
const newLastChild = scope[DynamicHTMLLastChild + accessor] = newContent.lastChild;
|
|
1360
|
+
const branch = scope[ClosestBranch];
|
|
1361
|
+
if (branch?.["#StartNode"] === firstChild) branch[StartNode] = newFirstChild;
|
|
1362
|
+
if (branch?.["#EndNode"] === lastChild) branch[EndNode] = newLastChild;
|
|
1363
|
+
insertChildNodes(parentNode, firstChild, newFirstChild, newLastChild);
|
|
1364
|
+
removeChildNodes(firstChild, lastChild);
|
|
1365
|
+
}
|
|
1334
1366
|
});
|
|
1335
1367
|
function normalizeClientRender(value) {
|
|
1336
1368
|
const renderer = normalizeDynamicRenderer(value);
|
|
1337
|
-
if (renderer)
|
|
1338
|
-
|
|
1369
|
+
if (renderer) {
|
|
1370
|
+
if (renderer["id"]) return renderer;
|
|
1371
|
+
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1372
|
+
}
|
|
1339
1373
|
}
|
|
1340
1374
|
function normalizeAttrValue(value) {
|
|
1341
1375
|
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
@@ -1353,7 +1387,7 @@ function _lifecycle(scope, thisObj, index = 0) {
|
|
|
1353
1387
|
Object.assign(thisObj, thisObj.onMount?.());
|
|
1354
1388
|
for (const prop in snapshot) if (!Object.is(snapshot[prop], thisObj[prop])) throw new Error(`Tried to overwrite existing property "${prop}" in <lifecycle> onMount.`);
|
|
1355
1389
|
}
|
|
1356
|
-
|
|
1390
|
+
trackAbort(scope, accessor, () => thisObj.onDestroy?.());
|
|
1357
1391
|
}
|
|
1358
1392
|
}
|
|
1359
1393
|
function removeChildNodes(startNode, endNode) {
|
|
@@ -1455,8 +1489,10 @@ function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValu
|
|
|
1455
1489
|
}
|
|
1456
1490
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
1457
1491
|
const el = scope[nodeAccessor];
|
|
1458
|
-
if (isResuming && el.defaultChecked)
|
|
1459
|
-
|
|
1492
|
+
if (isResuming && el.defaultChecked) {
|
|
1493
|
+
if (scope["ControlledValue:" + nodeAccessor]) scope[ControlledValue + nodeAccessor].push(el.value);
|
|
1494
|
+
else scope[ControlledValue + nodeAccessor] = el.value;
|
|
1495
|
+
}
|
|
1460
1496
|
syncControllableFormInput(el, hasCheckboxChanged, () => {
|
|
1461
1497
|
const checkedValueChange = scope[ControlledHandler + nodeAccessor];
|
|
1462
1498
|
if (checkedValueChange) {
|
|
@@ -1565,14 +1601,16 @@ function _attr_select_value_script(scope, nodeAccessor) {
|
|
|
1565
1601
|
run();
|
|
1566
1602
|
}
|
|
1567
1603
|
};
|
|
1568
|
-
if (isResuming)
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1604
|
+
if (isResuming) {
|
|
1605
|
+
if (el.multiple) {
|
|
1606
|
+
scope[ControlledValue + nodeAccessor] = [];
|
|
1607
|
+
for (const opt of el.options) if (opt.defaultSelected) scope[ControlledValue + nodeAccessor].push(opt.value);
|
|
1608
|
+
} else {
|
|
1609
|
+
scope[ControlledValue + nodeAccessor] = "";
|
|
1610
|
+
for (const opt of el.options) if (opt.defaultSelected) {
|
|
1611
|
+
scope[ControlledValue + nodeAccessor] = opt.value;
|
|
1612
|
+
break;
|
|
1613
|
+
}
|
|
1576
1614
|
}
|
|
1577
1615
|
}
|
|
1578
1616
|
syncControllableFormInput(el, hasSelectChanged, onChange);
|
|
@@ -1694,6 +1732,7 @@ function _controllable_open(scope, nodeAccessor, nextAttrs) {
|
|
|
1694
1732
|
function _await_promise(nodeAccessor, params) {
|
|
1695
1733
|
const promiseAccessor = Promise$1 + nodeAccessor;
|
|
1696
1734
|
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
1735
|
+
const tryAccessor = TryBranch$1 + nodeAccessor;
|
|
1697
1736
|
const resolveAwait = (scope, referenceNode, value) => {
|
|
1698
1737
|
const awaitBranch = scope[branchAccessor];
|
|
1699
1738
|
if (awaitBranch["#DetachedAwait"]) {
|
|
@@ -1709,80 +1748,73 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1709
1748
|
const awaitPromise = (scope, promise) => {
|
|
1710
1749
|
if (!isPromise(scope[promiseAccessor])) scope[promiseAccessor] = 0;
|
|
1711
1750
|
let awaitBranch = scope[branchAccessor];
|
|
1712
|
-
const
|
|
1713
|
-
const tryBranch = tryPlaceholder || awaitBranch;
|
|
1751
|
+
const tryBranch = scope[tryAccessor] || isPromise(promise) && findTryWithPlaceholder(scope) || awaitBranch;
|
|
1714
1752
|
if (!tryBranch) {
|
|
1715
1753
|
const deferred = scope[promiseAccessor] = () => deferred === scope[promiseAccessor] && awaitPromise(scope, promise);
|
|
1716
|
-
const awaitCounter =
|
|
1754
|
+
const awaitCounter = findTryWithPlaceholder(scope)?.[AwaitCounter];
|
|
1717
1755
|
if (awaitCounter?.i) {
|
|
1718
1756
|
const complete = awaitCounter.c;
|
|
1719
1757
|
awaitCounter.c = () => complete() || queueAsyncRender(scope, deferred);
|
|
1720
1758
|
}
|
|
1721
1759
|
return;
|
|
1722
1760
|
}
|
|
1723
|
-
if (!isPromise(promise)) return scope[
|
|
1761
|
+
if (!isPromise(promise)) return scope[tryAccessor] ? awaitPromise(scope, Promise.resolve(promise)) : resolveAwait(scope, scope[nodeAccessor], promise);
|
|
1724
1762
|
let awaitCounter = tryBranch[AwaitCounter];
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
if (
|
|
1730
|
-
const detachedParent = scope[branchAccessor][StartNode].parentNode;
|
|
1731
|
-
if (detachedParent === anchor.parentNode) anchor.remove();
|
|
1732
|
-
else anchor.replaceWith(detachedParent);
|
|
1733
|
-
}
|
|
1734
|
-
}
|
|
1735
|
-
});
|
|
1736
|
-
if (!scope[promiseAccessor]) {
|
|
1737
|
-
if (awaitBranch) awaitBranch[PendingRenders] ||= [];
|
|
1738
|
-
if (tryPlaceholder) awaitCounter = addAwaitCounter(scope, tryPlaceholder);
|
|
1739
|
-
else scheduleAwaitFrame(awaitCounter, scope, () => {
|
|
1740
|
-
if (!awaitBranch["#DetachedAwait"]) {
|
|
1741
|
-
awaitBranch[StartNode].parentNode.insertBefore(scope[nodeAccessor], awaitBranch[StartNode]);
|
|
1742
|
-
tempDetachBranch(tryBranch);
|
|
1743
|
-
}
|
|
1763
|
+
if (!scope[tryAccessor]) {
|
|
1764
|
+
scope[tryAccessor] = tryBranch;
|
|
1765
|
+
trackAbort(scope, promiseAccessor, () => {
|
|
1766
|
+
scope[promiseAccessor] = 0;
|
|
1767
|
+
if (scope[tryAccessor]) queueAsyncRender(scope[tryAccessor], completeAwaitCounter, awaitCounter);
|
|
1744
1768
|
});
|
|
1769
|
+
if (awaitBranch) awaitBranch[PendingRenders] ||= [];
|
|
1770
|
+
if (tryBranch !== awaitBranch) awaitCounter = addAwaitCounter(scope, tryBranch);
|
|
1771
|
+
else {
|
|
1772
|
+
if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => {
|
|
1773
|
+
if (tryBranch === scope[branchAccessor]) {
|
|
1774
|
+
const anchor = scope[nodeAccessor];
|
|
1775
|
+
if (anchor.parentNode) {
|
|
1776
|
+
const detachedParent = scope[branchAccessor][StartNode].parentNode;
|
|
1777
|
+
if (detachedParent === anchor.parentNode) anchor.remove();
|
|
1778
|
+
else anchor.replaceWith(detachedParent);
|
|
1779
|
+
}
|
|
1780
|
+
}
|
|
1781
|
+
});
|
|
1782
|
+
scheduleAwaitFrame(awaitCounter, scope, () => {
|
|
1783
|
+
if (!awaitBranch["#DetachedAwait"]) {
|
|
1784
|
+
awaitBranch[StartNode].parentNode.insertBefore(scope[nodeAccessor], awaitBranch[StartNode]);
|
|
1785
|
+
tempDetachBranch(tryBranch);
|
|
1786
|
+
}
|
|
1787
|
+
});
|
|
1788
|
+
}
|
|
1745
1789
|
}
|
|
1746
1790
|
const thisPromise = scope[promiseAccessor] = promise.then((data) => {
|
|
1747
1791
|
if (thisPromise === scope[promiseAccessor]) {
|
|
1748
1792
|
const referenceNode = scope[nodeAccessor];
|
|
1749
1793
|
scope[promiseAccessor] = 0;
|
|
1750
|
-
if (!scope[branchAccessor]
|
|
1751
|
-
|
|
1794
|
+
if (!scope[branchAccessor]) {
|
|
1795
|
+
scope[tryAccessor] = 0;
|
|
1796
|
+
awaitPromise(scope, data);
|
|
1752
1797
|
awaitCounter.c();
|
|
1753
1798
|
run();
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
awaitCounter.c();
|
|
1763
|
-
if (awaitCounter.m) {
|
|
1764
|
-
const fnScopes = /* @__PURE__ */ new Map();
|
|
1765
|
-
const effects = awaitCounter.m([]);
|
|
1766
|
-
for (let i = 0; i < pendingEffects.length;) {
|
|
1767
|
-
const fn = pendingEffects[i++];
|
|
1768
|
-
let scopes = fnScopes.get(fn);
|
|
1769
|
-
if (!scopes) fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
|
|
1770
|
-
scopes.add(pendingEffects[i++]);
|
|
1771
|
-
}
|
|
1772
|
-
for (let i = 0; i < effects.length;) {
|
|
1773
|
-
const fn = effects[i++];
|
|
1774
|
-
const scope = effects[i++];
|
|
1775
|
-
if (!fnScopes.get(fn)?.has(scope)) queueEffect(scope, fn);
|
|
1776
|
-
}
|
|
1799
|
+
} else queueAsyncRender(scope, () => {
|
|
1800
|
+
if (!scope[promiseAccessor]) {
|
|
1801
|
+
awaitBranch = resolveAwait(scope, referenceNode, data);
|
|
1802
|
+
const pendingRenders = awaitBranch[PendingRenders];
|
|
1803
|
+
awaitBranch[PendingRenders] = 0;
|
|
1804
|
+
pendingRenders?.forEach(queuePendingRender);
|
|
1805
|
+
scope[tryAccessor] = 0;
|
|
1806
|
+
queueCompleteAwaitCounter(tryBranch, awaitCounter);
|
|
1777
1807
|
}
|
|
1778
1808
|
});
|
|
1779
1809
|
}
|
|
1780
1810
|
}, (error) => {
|
|
1781
1811
|
if (thisPromise === scope[promiseAccessor]) {
|
|
1782
|
-
scope[promiseAccessor] = 0;
|
|
1783
|
-
if (tryPlaceholder && !awaitCounter.m) awaitCounter.c();
|
|
1784
|
-
else awaitCounter.i = 0;
|
|
1812
|
+
scope[promiseAccessor] = scope[tryAccessor] = 0;
|
|
1785
1813
|
queueAsyncRender(scope, renderCatch, error);
|
|
1814
|
+
if (tryBranch !== awaitBranch && !awaitCounter.m) {
|
|
1815
|
+
if (findTryWithCatch(scope)) queueCompleteAwaitCounter(tryBranch, awaitCounter);
|
|
1816
|
+
else awaitCounter.c();
|
|
1817
|
+
} else awaitCounter.i = 0;
|
|
1786
1818
|
}
|
|
1787
1819
|
});
|
|
1788
1820
|
};
|
|
@@ -1798,13 +1830,13 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
1798
1830
|
if (typeof scope[promiseAccessor] === "function") scope[promiseAccessor]();
|
|
1799
1831
|
};
|
|
1800
1832
|
}
|
|
1801
|
-
function addAwaitCounter(scope, tryBranch =
|
|
1833
|
+
function addAwaitCounter(scope, tryBranch = findTryWithPlaceholder(scope)) {
|
|
1802
1834
|
if (!tryBranch) return;
|
|
1803
1835
|
let awaitCounter = tryBranch[AwaitCounter];
|
|
1804
1836
|
if (!awaitCounter?.i) awaitCounter = createAwaitCounter(tryBranch, () => dismissPlaceholder(tryBranch));
|
|
1805
|
-
placeholderShown.add(pendingEffects);
|
|
1806
1837
|
scheduleAwaitFrame(awaitCounter, tryBranch, () => {
|
|
1807
|
-
|
|
1838
|
+
(tryBranch[PlaceholderBranch] = createAndSetupBranch(tryBranch[Global], tryBranch[PlaceholderContent](), tryBranch["_"], tryBranch[StartNode].parentNode))[TryBranch] = tryBranch;
|
|
1839
|
+
insertBranchBefore(tryBranch[PlaceholderBranch], tryBranch[StartNode].parentNode, tryBranch[StartNode]);
|
|
1808
1840
|
tempDetachBranch(tryBranch);
|
|
1809
1841
|
});
|
|
1810
1842
|
return awaitCounter;
|
|
@@ -1812,10 +1844,32 @@ function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, Placeholder
|
|
|
1812
1844
|
function scheduleAwaitFrame(awaitCounter, scope, render) {
|
|
1813
1845
|
if (!awaitCounter.i++) requestAnimationFrame(() => awaitCounter.i && runEffects(prepareEffects(() => queueRender(scope, render, -1))));
|
|
1814
1846
|
}
|
|
1847
|
+
function queueCompleteAwaitCounter(tryBranch, awaitCounter) {
|
|
1848
|
+
queueRender(tryBranch, completeAwaitCounter, -1, awaitCounter, tryBranch["#Id"] + 1e9);
|
|
1849
|
+
}
|
|
1850
|
+
function completeAwaitCounter(_scope, awaitCounter) {
|
|
1851
|
+
awaitCounter.c();
|
|
1852
|
+
if (awaitCounter.m) {
|
|
1853
|
+
const fnScopes = /* @__PURE__ */ new Map();
|
|
1854
|
+
const effects = awaitCounter.m([]);
|
|
1855
|
+
for (let i = 0; i < pendingEffects.length;) {
|
|
1856
|
+
const fn = pendingEffects[i++];
|
|
1857
|
+
let scopes = fnScopes.get(fn);
|
|
1858
|
+
if (!scopes) fnScopes.set(fn, scopes = /* @__PURE__ */ new Set());
|
|
1859
|
+
scopes.add(pendingEffects[i++]);
|
|
1860
|
+
}
|
|
1861
|
+
for (let i = 0; i < effects.length;) {
|
|
1862
|
+
const fn = effects[i++];
|
|
1863
|
+
const scope = effects[i++];
|
|
1864
|
+
if (!fnScopes.get(fn)?.has(scope)) queueEffect(scope, fn);
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1815
1868
|
function createAwaitCounter(tryBranch, done) {
|
|
1816
1869
|
const awaitCounter = tryBranch[AwaitCounter] = {
|
|
1817
1870
|
i: 0,
|
|
1818
1871
|
c() {
|
|
1872
|
+
if (awaitCounter.i < 1) throw new Error("An await counter completed more counts than it took.");
|
|
1819
1873
|
if (--awaitCounter.i) return 1;
|
|
1820
1874
|
done();
|
|
1821
1875
|
queueEffect(tryBranch, runPendingEffects);
|
|
@@ -1823,12 +1877,8 @@ function createAwaitCounter(tryBranch, done) {
|
|
|
1823
1877
|
};
|
|
1824
1878
|
return awaitCounter;
|
|
1825
1879
|
}
|
|
1826
|
-
function runPendingEffects(
|
|
1827
|
-
|
|
1828
|
-
if (effects) {
|
|
1829
|
-
scope[PendingEffects] = [];
|
|
1830
|
-
runEffects(effects, 1);
|
|
1831
|
-
}
|
|
1880
|
+
function runPendingEffects(tryBranch) {
|
|
1881
|
+
tryBranch[PendingEffectScopes]?.forEach((scope) => scope[PendingEffects].forEach((fn) => runEffects([fn, scope]), scope[PendingEffects] = null), tryBranch[PendingEffectScopes] = null);
|
|
1832
1882
|
}
|
|
1833
1883
|
function dismissPlaceholder(tryBranch) {
|
|
1834
1884
|
const placeholderBranch = tryBranch[PlaceholderBranch];
|
|
@@ -1838,21 +1888,19 @@ function dismissPlaceholder(tryBranch) {
|
|
|
1838
1888
|
removeAndDestroyBranch(placeholderBranch);
|
|
1839
1889
|
}
|
|
1840
1890
|
}
|
|
1841
|
-
function _try(nodeAccessor, template, walks, setup) {
|
|
1891
|
+
function _try(nodeAccessor, template, walks, setup, placeholderContent, catchContent) {
|
|
1842
1892
|
const branchAccessor = BranchScopes$1 + nodeAccessor;
|
|
1843
1893
|
const renderer = _content("", template, walks, setup)();
|
|
1844
|
-
return (scope
|
|
1845
|
-
|
|
1894
|
+
return (scope) => {
|
|
1895
|
+
setConditionalRenderer(scope, nodeAccessor, renderer, createAndSetupBranch);
|
|
1846
1896
|
const branch = scope[branchAccessor];
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
branch[PlaceholderContent] = normalizeDynamicRenderer(input.placeholder);
|
|
1851
|
-
}
|
|
1897
|
+
branch[BranchAccessor] = nodeAccessor;
|
|
1898
|
+
branch[CatchContent] = catchContent;
|
|
1899
|
+
branch[PlaceholderContent] = placeholderContent || void 0;
|
|
1852
1900
|
};
|
|
1853
1901
|
}
|
|
1854
1902
|
function renderCatch(scope, error) {
|
|
1855
|
-
const tryWithCatch =
|
|
1903
|
+
const tryWithCatch = findTryWithCatch(scope);
|
|
1856
1904
|
if (!tryWithCatch) throw error;
|
|
1857
1905
|
else {
|
|
1858
1906
|
const owner = tryWithCatch["_"];
|
|
@@ -1862,11 +1910,21 @@ function renderCatch(scope, error) {
|
|
|
1862
1910
|
owner[BranchScopes$1 + tryWithCatch[BranchAccessor]] = placeholderBranch;
|
|
1863
1911
|
destroyBranch(tryWithCatch);
|
|
1864
1912
|
}
|
|
1865
|
-
|
|
1866
|
-
setConditionalRenderer(owner, tryWithCatch[BranchAccessor],
|
|
1867
|
-
|
|
1913
|
+
const catchContent = tryWithCatch[CatchContent]();
|
|
1914
|
+
setConditionalRenderer(owner, tryWithCatch[BranchAccessor], catchContent, createAndSetupBranch);
|
|
1915
|
+
catchContent[Params]?.(owner[BranchScopes$1 + tryWithCatch[BranchAccessor]], [error]);
|
|
1868
1916
|
}
|
|
1869
1917
|
}
|
|
1918
|
+
function findTryWithPlaceholder(scope) {
|
|
1919
|
+
let branch = scope[ClosestBranch];
|
|
1920
|
+
while (branch && !branch["#PlaceholderContent"]) branch = branch[ParentBranch];
|
|
1921
|
+
return branch;
|
|
1922
|
+
}
|
|
1923
|
+
function findTryWithCatch(scope) {
|
|
1924
|
+
let branch = scope[ClosestBranch];
|
|
1925
|
+
while (branch && !branch["#CatchContent"]) branch = branch["#TryBranch"] || branch["#ParentBranch"];
|
|
1926
|
+
return branch;
|
|
1927
|
+
}
|
|
1870
1928
|
const _if = /*@__PURE__*/ withBranches((nodeAccessor, ...branchesArgs) => {
|
|
1871
1929
|
const branchAccessor = ConditionalRenderer + nodeAccessor;
|
|
1872
1930
|
const branches = [];
|
|
@@ -1923,10 +1981,12 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
|
|
|
1923
1981
|
if (scope[rendererAccessor] !== (scope[rendererAccessor] = rendererKey(normalizedRenderer)) || getContent && !(normalizedRenderer || scope[childScopeAccessor])) {
|
|
1924
1982
|
const renderer = normalizedRenderer || (getContent ? getContent(scope) : void 0);
|
|
1925
1983
|
setConditionalRenderer(scope, nodeAccessor, renderer, createBranchWithTagNameOrRenderer);
|
|
1926
|
-
if (getTagVar)
|
|
1927
|
-
scope[childScopeAccessor]
|
|
1928
|
-
|
|
1929
|
-
|
|
1984
|
+
if (getTagVar) {
|
|
1985
|
+
if (scope[childScopeAccessor]) {
|
|
1986
|
+
scope[childScopeAccessor][TagVariable] = (value) => getTagVar()(scope, value);
|
|
1987
|
+
if (typeof normalizedRenderer === "string") bindNativeTagVar?.(scope[childScopeAccessor]);
|
|
1988
|
+
} else getTagVar()(scope, void 0);
|
|
1989
|
+
}
|
|
1930
1990
|
if (typeof renderer === "string") {
|
|
1931
1991
|
if (getContent) {
|
|
1932
1992
|
const content = getContent(scope);
|
|
@@ -1944,13 +2004,15 @@ let _dynamic_tag = /*@__PURE__*/ withBranches((nodeAccessor, getContent, getTagV
|
|
|
1944
2004
|
if (childScope["EventAttributes:" + nodeAccessor] || childScope["ControlledHandler:" + nodeAccessor]) queueEffect(childScope, dynamicTagScript);
|
|
1945
2005
|
} else {
|
|
1946
2006
|
normalizedRenderer[LocalClosures]?.(childScope);
|
|
1947
|
-
if (normalizedRenderer["params"])
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
2007
|
+
if (normalizedRenderer["params"]) {
|
|
2008
|
+
if (inputIsArgs) normalizedRenderer[Params](childScope, normalizedRenderer._ ? args[0] : args);
|
|
2009
|
+
else {
|
|
2010
|
+
const inputWithContent = getContent ? {
|
|
2011
|
+
...args,
|
|
2012
|
+
content: getContent(scope)
|
|
2013
|
+
} : args || {};
|
|
2014
|
+
normalizedRenderer[Params](childScope, normalizedRenderer._ ? inputWithContent : [inputWithContent]);
|
|
2015
|
+
}
|
|
1954
2016
|
}
|
|
1955
2017
|
}
|
|
1956
2018
|
}
|
|
@@ -2088,20 +2150,22 @@ function reorderKeyed(newScopes, start, newEnd, parentNode, afterReference) {
|
|
|
2088
2150
|
let hi;
|
|
2089
2151
|
let mid;
|
|
2090
2152
|
for (let i = diffLen; i--;) sources[i] = newScopes[start + i]["#LoopIndex"] ?? -1;
|
|
2091
|
-
for (let i = 0; i < diffLen; i++) if (~sources[i])
|
|
2092
|
-
if (
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
if (
|
|
2104
|
-
|
|
2153
|
+
for (let i = 0; i < diffLen; i++) if (~sources[i]) {
|
|
2154
|
+
if (tail < 0 || sources[tails[tail]] < sources[i]) {
|
|
2155
|
+
if (~tail) pred[i] = tails[tail];
|
|
2156
|
+
tails[++tail] = i;
|
|
2157
|
+
} else {
|
|
2158
|
+
lo = 0;
|
|
2159
|
+
hi = tail;
|
|
2160
|
+
while (lo < hi) {
|
|
2161
|
+
mid = (lo + hi) / 2 | 0;
|
|
2162
|
+
if (sources[tails[mid]] < sources[i]) lo = mid + 1;
|
|
2163
|
+
else hi = mid;
|
|
2164
|
+
}
|
|
2165
|
+
if (sources[i] < sources[tails[lo]]) {
|
|
2166
|
+
if (lo > 0) pred[i] = tails[lo - 1];
|
|
2167
|
+
tails[lo] = i;
|
|
2168
|
+
}
|
|
2105
2169
|
}
|
|
2106
2170
|
}
|
|
2107
2171
|
hi = tails[tail];
|
|
@@ -2130,4 +2194,4 @@ function byFirstArg(name) {
|
|
|
2130
2194
|
return name;
|
|
2131
2195
|
}
|
|
2132
2196
|
//#endregion
|
|
2133
|
-
export {
|
|
2197
|
+
export { _attrs as $, syncGen as $t, _attr_input_value as A, EndNode as An, _closure as At, _controllable_select as B, TagVariable as Bn, _if_closure as Bt, _attr_details_or_dialog_open_script as C, Owner as Cn, getRegisteredWithScope as Ct, _attr_input_checkedValue_script as D, Scope as Dn, readyFailed as Dt, _attr_input_checkedValue_default as E, Pending as En, ready as Et, _attr_select_value as F, PendingEffectScopes as Fn, _for_selector as Ft, _attr_class as G, _return_change as Gt, controllableRenders as H, _let_change as Ht, _attr_select_value_default as I, PendingEffects as In, _global_read as It, _attr_content as J, _var_change as Jt, _attr_class_item as K, _script as Kt, _attr_select_value_script as L, PendingRenders as Ln, _hoist as Lt, _attr_input_value_default as M, Global as Mn, _const as Mt, _attr_input_value_dynamic_default as N, Load as Nn, _el_read as Nt, _attr_input_checked_default as O, AwaitCounter as On, withLazy as Ot, _attr_input_value_script as P, ParentBranch as Pn, _for_closure as Pt, _attr_style_items as Q, removeAndDestroyBranch as Qt, _controllable_input as R, PlaceholderBranch as Rn, _hoist_resume as Rt, _attr_details_or_dialog_open_default as S, Clone as Sn, _var_resume as St, _attr_input_checkedValue as T, Setup as Tn, initEmbedded as Tt, controllableScripts as U, _or as Ut, _controllable_textarea as V, _let as Vt, _attr as W, _return as Wt, _attr_style as X, destroyBranch as Xt, _attr_nonce as Y, _assert_init as Yt, _attr_style_item as Z, insertBranchBefore as Zt, installDynamicTagVar as _, forUntil as _n, createBranch as _t, _for_in as a, installCatch as an, _lifecycle as at, runPendingEffects as b, _call as bn, _el as bt, _for_to as c, queueEffect as cn, _text as ct, _for_until_unkeyed as d, run as dn, insertChildNodes as dt, DYNAMIC_TAG_SCRIPT_REGISTER_ID as en, _attrs_content as et, _if as f, runEffects as fn, toInsertNode as ft, dynamicTagScript as g, forTo as gn, createAndSetupBranch as gt, addAwaitCounter as h, forOf as hn, _content_resume as ht, _dynamic_tag_content as i, $signalReset as in, _html as it, _attr_input_value_attribute_default as j, Gen$1 as jn, _closure_get as jt, _attr_input_checked_script as k, ClosestBranch as kn, _child_setup as kt, _for_to_unkeyed as l, queueRender as ln, _text_content as lt, _try as m, forIn as mn, _content_closures as mt, _await_promise as n, _on as nn, _attrs_partial_content as nt, _for_of as o, prepareEffects as on, _style_rule_item as ot, _show as p, runId as pn, _content as pt, _attr_class_items as q, _var as qt, _dynamic_tag as r, $signal as rn, _attrs_script as rt, _for_of_unkeyed as s, queueAsyncRender as sn, _style_shell as st, _await_content as t, PLACEHOLDER_DISMISS_REGISTER_ID as tn, _attrs_partial as tt, _for_until as u, rendering as un, _to_text as ut, patchDynamicTag as v, _assert_hoist as vn, setupBranch as vt, _attr_input_checked as w, Params as wn, init as wt, _attr_details_or_dialog_open as x, withBranches as xn, _resumed as xt, renderCatch as y, _hoist_read_error as yn, _dynamic_tag_var_resume as yt, _controllable_open as z, StartNode as zn, _id as zt };
|