@marko/runtime-tags 6.1.10 → 6.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/accessor.d.ts +2 -2
- package/dist/common/accessor.debug.d.ts +2 -2
- package/dist/common/errors.d.ts +0 -2
- package/dist/common/helpers.d.ts +1 -0
- package/dist/common/types.d.ts +2 -2
- package/dist/debug/dom.js +66 -59
- package/dist/debug/dom.mjs +66 -59
- package/dist/debug/html.js +9 -9
- package/dist/debug/html.mjs +9 -9
- package/dist/dom/queue.d.ts +2 -2
- package/dist/dom/scope.d.ts +3 -0
- package/dist/dom.d.ts +2 -1
- package/dist/dom.js +59 -48
- package/dist/dom.mjs +59 -48
- package/dist/html/writer.d.ts +1 -1
- package/dist/html.js +9 -9
- package/dist/html.mjs +9 -9
- package/dist/translator/index.js +99 -22
- package/dist/translator/util/references.d.ts +4 -0
- package/dist/translator/util/sections.d.ts +1 -1
- package/package.json +1 -1
|
@@ -24,8 +24,7 @@ export declare enum AccessorProp {
|
|
|
24
24
|
CatchContent = "E",
|
|
25
25
|
ClosestBranch = "F",
|
|
26
26
|
ClosestBranchId = "G",
|
|
27
|
-
|
|
28
|
-
Destroyed = "I",
|
|
27
|
+
Gen = "H",
|
|
29
28
|
DetachedAwait = "V",
|
|
30
29
|
EndNode = "K",
|
|
31
30
|
Id = "L",
|
|
@@ -34,6 +33,7 @@ export declare enum AccessorProp {
|
|
|
34
33
|
ParentBranch = "N",
|
|
35
34
|
PendingEffects = "J",
|
|
36
35
|
PendingRenders = "W",
|
|
36
|
+
PendingScopes = "Y",
|
|
37
37
|
PlaceholderBranch = "P",
|
|
38
38
|
PlaceholderContent = "Q",
|
|
39
39
|
Renderer = "R",
|
|
@@ -24,8 +24,7 @@ export declare enum AccessorProp {
|
|
|
24
24
|
CatchContent = "#CatchContent",
|
|
25
25
|
ClosestBranch = "#ClosestBranch",
|
|
26
26
|
ClosestBranchId = "#ClosestBranchId",
|
|
27
|
-
|
|
28
|
-
Destroyed = "#Destroyed",
|
|
27
|
+
Gen = "#Gen",
|
|
29
28
|
DetachedAwait = "#DetachedAwait",
|
|
30
29
|
EndNode = "#EndNode",
|
|
31
30
|
Id = "#Id",
|
|
@@ -34,6 +33,7 @@ export declare enum AccessorProp {
|
|
|
34
33
|
ParentBranch = "#ParentBranch",
|
|
35
34
|
PendingEffects = "#PendingEffects",
|
|
36
35
|
PendingRenders = "#PendingRenders",
|
|
36
|
+
PendingScopes = "#PendingScopes",
|
|
37
37
|
PlaceholderBranch = "#PlaceholderBranch",
|
|
38
38
|
PlaceholderContent = "#PlaceholderContent",
|
|
39
39
|
Renderer = "#Renderer",
|
package/dist/common/errors.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { type Scope } from "./types";
|
|
2
1
|
export declare function _el_read_error(): void;
|
|
3
2
|
export declare function _hoist_read_error(): void;
|
|
4
3
|
export declare function _assert_hoist(value: unknown): void;
|
|
5
|
-
export declare function _assert_init(scope: Scope, accessor: string): any;
|
|
6
4
|
export declare function assertExclusiveAttrs(attrs: Record<string, unknown> | undefined, onError?: typeof throwErr): void;
|
|
7
5
|
export declare function assertValidTagName(tagName: string): void;
|
|
8
6
|
declare function throwErr(msg: string): void;
|
package/dist/common/helpers.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export declare const toDelimitedString: (val: unknown, delimiter: string, string
|
|
|
7
7
|
export declare function isEventHandler(name: string): name is `on${string}`;
|
|
8
8
|
export declare function getEventHandlerName(name: `on${string}`): string;
|
|
9
9
|
export declare function isVoid(value: unknown): value is false | null | undefined;
|
|
10
|
+
export declare function isNotVoid(value: unknown): boolean;
|
|
10
11
|
export declare function normalizeDynamicRenderer<Renderer>(value: any): Renderer | string | undefined;
|
|
11
12
|
export declare const decodeAccessor: (num: number) => string;
|
package/dist/common/types.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export interface BranchScope extends Scope {
|
|
|
6
6
|
[AccessorProp.StartNode]: ChildNode;
|
|
7
7
|
[AccessorProp.EndNode]: ChildNode;
|
|
8
8
|
[AccessorProp.ParentBranch]: BranchScope | undefined;
|
|
9
|
-
[AccessorProp.Destroyed]: 1 | undefined;
|
|
10
9
|
[AccessorProp.AbortScopes]: Set<Scope> | undefined;
|
|
11
10
|
[AccessorProp.BranchScopes]: Set<BranchScope> | undefined;
|
|
12
11
|
[AccessorProp.Renderer]: ClientRenderer | string;
|
|
@@ -15,12 +14,13 @@ export interface BranchScope extends Scope {
|
|
|
15
14
|
[AccessorProp.PlaceholderBranch]: BranchScope | undefined | 0;
|
|
16
15
|
[AccessorProp.PendingRenders]: PendingRender[] | 0 | undefined;
|
|
17
16
|
[AccessorProp.DetachedAwait]: Renderer | 0 | undefined;
|
|
17
|
+
[AccessorProp.PendingScopes]: Scope[] | void;
|
|
18
18
|
}
|
|
19
19
|
export interface Scope {
|
|
20
20
|
[AccessorProp.Owner]: Scope | undefined;
|
|
21
21
|
[AccessorProp.Global]: Record<string, unknown>;
|
|
22
22
|
[AccessorProp.Id]: number;
|
|
23
|
-
[AccessorProp.
|
|
23
|
+
[AccessorProp.Gen]: number;
|
|
24
24
|
[AccessorProp.AbortControllers]: Record<string | number, AbortController | void> | undefined;
|
|
25
25
|
[AccessorProp.ClosestBranch]: BranchScope | undefined;
|
|
26
26
|
[AccessorProp.ClosestBranchId]: number | undefined;
|
package/dist/debug/dom.js
CHANGED
|
@@ -31,10 +31,6 @@ function _hoist_read_error() {
|
|
|
31
31
|
function _assert_hoist(value) {
|
|
32
32
|
if (typeof value !== "function") throw new Error(`Hoisted values must be functions, received type "${typeof value}".`);
|
|
33
33
|
}
|
|
34
|
-
function _assert_init(scope, accessor) {
|
|
35
|
-
if (scope["#Creating"] || !(accessor in scope)) throw new ReferenceError(`Cannot access '${accessor}' before initialization`);
|
|
36
|
-
return scope[accessor];
|
|
37
|
-
}
|
|
38
34
|
function assertExclusiveAttrs(attrs, onError = throwErr) {
|
|
39
35
|
if (attrs) {
|
|
40
36
|
let exclusiveAttrs;
|
|
@@ -125,6 +121,9 @@ function isEventHandler(name) {
|
|
|
125
121
|
function getEventHandlerName(name) {
|
|
126
122
|
return name[2] === "-" ? name.slice(3) : name.slice(2).toLowerCase();
|
|
127
123
|
}
|
|
124
|
+
function isNotVoid(value) {
|
|
125
|
+
return value != null && value !== false;
|
|
126
|
+
}
|
|
128
127
|
function normalizeDynamicRenderer(value) {
|
|
129
128
|
if (value) {
|
|
130
129
|
if (typeof value === "string") return value;
|
|
@@ -199,16 +198,34 @@ function parseHTML(html, ns) {
|
|
|
199
198
|
//#endregion
|
|
200
199
|
//#region src/dom/scope.ts
|
|
201
200
|
let nextScopeId = 1e6;
|
|
201
|
+
let collectingScopes;
|
|
202
202
|
function createScope($global, closestBranch) {
|
|
203
203
|
const scope = {
|
|
204
204
|
["#Id"]: nextScopeId++,
|
|
205
|
-
["#
|
|
205
|
+
["#Gen"]: runId,
|
|
206
206
|
["#ClosestBranch"]: closestBranch,
|
|
207
207
|
["$global"]: $global
|
|
208
208
|
};
|
|
209
|
-
|
|
209
|
+
collectingScopes?.push(scope);
|
|
210
210
|
return scope;
|
|
211
211
|
}
|
|
212
|
+
function syncGen(scope) {
|
|
213
|
+
scope["#Gen"] = runId;
|
|
214
|
+
}
|
|
215
|
+
function _assert_init(scope, accessor) {
|
|
216
|
+
if (scope["#Gen"] === runId || !(accessor in scope)) throw new ReferenceError(`Cannot access '${accessor}' before initialization`);
|
|
217
|
+
return scope[accessor];
|
|
218
|
+
}
|
|
219
|
+
function collectScopes(fn) {
|
|
220
|
+
const prev = collectingScopes;
|
|
221
|
+
collectingScopes = [];
|
|
222
|
+
try {
|
|
223
|
+
fn();
|
|
224
|
+
return collectingScopes;
|
|
225
|
+
} finally {
|
|
226
|
+
collectingScopes = prev;
|
|
227
|
+
}
|
|
228
|
+
}
|
|
212
229
|
function skipScope() {
|
|
213
230
|
return nextScopeId++;
|
|
214
231
|
}
|
|
@@ -222,13 +239,13 @@ function destroyBranch(branch) {
|
|
|
222
239
|
destroyNestedScopes(branch);
|
|
223
240
|
}
|
|
224
241
|
function destroyScope(scope) {
|
|
225
|
-
if (
|
|
242
|
+
if (scope["#Gen"]) {
|
|
226
243
|
destroyNestedScopes(scope);
|
|
227
244
|
resetControllers(scope);
|
|
228
245
|
}
|
|
229
246
|
}
|
|
230
247
|
const destroyNestedScopes = function destroyNestedScopes(scope) {
|
|
231
|
-
scope["#
|
|
248
|
+
scope["#Gen"] = 0;
|
|
232
249
|
scope["#BranchScopes"]?.forEach(destroyNestedScopes);
|
|
233
250
|
scope["#AbortScopes"]?.forEach(resetControllers);
|
|
234
251
|
};
|
|
@@ -287,7 +304,7 @@ function _let(id, fn) {
|
|
|
287
304
|
id = +id.slice(id.lastIndexOf("/") + 1);
|
|
288
305
|
return (scope, value) => {
|
|
289
306
|
if (rendering) {
|
|
290
|
-
if (scope["#
|
|
307
|
+
if (scope["#Gen"] === runId) {
|
|
291
308
|
scope[valueAccessor] = value;
|
|
292
309
|
fn?.(scope);
|
|
293
310
|
}
|
|
@@ -322,7 +339,7 @@ function _const(valueAccessor, fn) {
|
|
|
322
339
|
}
|
|
323
340
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id") {
|
|
324
341
|
return (scope) => {
|
|
325
|
-
if (scope["#
|
|
342
|
+
if (scope["#Gen"] === runId) if (id in scope) {
|
|
326
343
|
if (!--scope[id]) fn(scope);
|
|
327
344
|
} else scope[id] = defaultPending;
|
|
328
345
|
else queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
@@ -333,7 +350,7 @@ function _for_closure(ownerLoopNodeAccessor, fn) {
|
|
|
333
350
|
const ownerSignal = (ownerScope) => {
|
|
334
351
|
const scopes = toArray(ownerScope[scopeAccessor]);
|
|
335
352
|
if (scopes.length) queueRender(ownerScope, () => {
|
|
336
|
-
for (const scope of scopes) if (
|
|
353
|
+
for (const scope of scopes) if (scope["#Gen"] > 0 && scope["#Gen"] < runId) fn(scope);
|
|
337
354
|
}, -1, 0, scopes[0]["#Id"]);
|
|
338
355
|
};
|
|
339
356
|
ownerSignal._ = fn;
|
|
@@ -344,7 +361,7 @@ function _if_closure(ownerConditionalNodeAccessor, branch, fn) {
|
|
|
344
361
|
const branchAccessor = "ConditionalRenderer:" + ownerConditionalNodeAccessor;
|
|
345
362
|
const ownerSignal = (scope) => {
|
|
346
363
|
const ifScope = scope[scopeAccessor];
|
|
347
|
-
if (ifScope &&
|
|
364
|
+
if (ifScope && ifScope["#Gen"] > 0 && ifScope["#Gen"] < runId && (scope[branchAccessor] || 0) === branch) queueRender(ifScope, fn, -1);
|
|
348
365
|
};
|
|
349
366
|
ownerSignal._ = fn;
|
|
350
367
|
return ownerSignal;
|
|
@@ -363,7 +380,7 @@ function _closure(...closureSignals) {
|
|
|
363
380
|
for (let i = closureSignals.length; i--;) closureSignals[i]["index"] = i;
|
|
364
381
|
return (scope) => {
|
|
365
382
|
if (scope[scopeInstances]) {
|
|
366
|
-
for (const childScope of scope[scopeInstances]) if (
|
|
383
|
+
for (const childScope of scope[scopeInstances]) if (childScope["#Gen"] > 0 && childScope["#Gen"] < runId) queueRender(childScope, closureSignals[childScope[signalIndex] || 0], -1);
|
|
367
384
|
}
|
|
368
385
|
};
|
|
369
386
|
}
|
|
@@ -603,6 +620,7 @@ function init(runtimeId = "M") {
|
|
|
603
620
|
renderId
|
|
604
621
|
};
|
|
605
622
|
const initScope = (scope) => {
|
|
623
|
+
scope["#Gen"] = 1;
|
|
606
624
|
scope["$global"] = initGlobal();
|
|
607
625
|
if (branchesEnabled && scope["#ClosestBranchId"]) scope["#ClosestBranch"] = getScope(scope["#ClosestBranchId"]);
|
|
608
626
|
return scope;
|
|
@@ -765,19 +783,19 @@ let inputType = "";
|
|
|
765
783
|
const controllableDelegate = /* @__PURE__ */ createDelegator();
|
|
766
784
|
function _attr_input_checked_default(scope, nodeAccessor, checked) {
|
|
767
785
|
const el = scope[nodeAccessor];
|
|
768
|
-
const normalizedChecked =
|
|
786
|
+
const normalizedChecked = isNotVoid(checked);
|
|
769
787
|
if (el.defaultChecked !== normalizedChecked) {
|
|
770
|
-
const restoreValue = scope["#
|
|
788
|
+
const restoreValue = scope["#Gen"] < runId ? el.checked : normalizedChecked;
|
|
771
789
|
el.defaultChecked = normalizedChecked;
|
|
772
790
|
if (restoreValue !== normalizedChecked) el.checked = restoreValue;
|
|
773
791
|
}
|
|
774
792
|
}
|
|
775
793
|
function _attr_input_checked(scope, nodeAccessor, checked, checkedChange) {
|
|
776
794
|
const el = scope[nodeAccessor];
|
|
777
|
-
const normalizedChecked =
|
|
795
|
+
const normalizedChecked = isNotVoid(checked);
|
|
778
796
|
scope["ControlledHandler:" + nodeAccessor] = checkedChange;
|
|
779
797
|
scope["ControlledType:" + nodeAccessor] = checkedChange ? 0 : 5;
|
|
780
|
-
if (checkedChange &&
|
|
798
|
+
if (checkedChange && scope["#Gen"] < runId) el.checked = normalizedChecked;
|
|
781
799
|
else _attr_input_checked_default(scope, nodeAccessor, normalizedChecked);
|
|
782
800
|
}
|
|
783
801
|
function _attr_input_checked_script(scope, nodeAccessor) {
|
|
@@ -796,19 +814,19 @@ function _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, val
|
|
|
796
814
|
const multiple = Array.isArray(checkedValue);
|
|
797
815
|
const normalizedValue = normalizeStrProp(value);
|
|
798
816
|
const normalizedCheckedValue = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
799
|
-
_attr(scope[nodeAccessor], "value",
|
|
817
|
+
_attr(scope[nodeAccessor], "value", value);
|
|
800
818
|
_attr_input_checked_default(scope, nodeAccessor, multiple ? normalizedCheckedValue.includes(normalizedValue) : normalizedValue === normalizedCheckedValue);
|
|
801
819
|
}
|
|
802
820
|
function _attr_input_checkedValue(scope, nodeAccessor, checkedValue, checkedValueChange, value) {
|
|
803
821
|
const el = scope[nodeAccessor];
|
|
804
822
|
const multiple = Array.isArray(checkedValue);
|
|
805
|
-
const normalizedValue = normalizeStrProp(value);
|
|
806
823
|
const normalizedCheckedValue = scope["ControlledValue:" + nodeAccessor] = multiple ? checkedValue.map(normalizeStrProp) : normalizeStrProp(checkedValue);
|
|
807
|
-
_attr(el, "value", normalizedValue);
|
|
808
824
|
scope["ControlledHandler:" + nodeAccessor] = checkedValueChange;
|
|
809
825
|
scope["ControlledType:" + nodeAccessor] = checkedValueChange ? 1 : 5;
|
|
810
|
-
if (checkedValueChange &&
|
|
811
|
-
|
|
826
|
+
if (checkedValueChange && scope["#Gen"] < runId) {
|
|
827
|
+
el.checked = multiple ? normalizedCheckedValue.includes(normalizeStrProp(value)) : normalizeStrProp(value) === normalizedCheckedValue;
|
|
828
|
+
_attr(el, "value", value);
|
|
829
|
+
} else _attr_input_checkedValue_default(scope, nodeAccessor, checkedValue, value);
|
|
812
830
|
}
|
|
813
831
|
function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
814
832
|
const el = scope[nodeAccessor];
|
|
@@ -829,20 +847,20 @@ function _attr_input_checkedValue_script(scope, nodeAccessor) {
|
|
|
829
847
|
}
|
|
830
848
|
function _attr_input_value_default(scope, nodeAccessor, value) {
|
|
831
849
|
const el = scope[nodeAccessor];
|
|
832
|
-
const normalizedValue =
|
|
850
|
+
const normalizedValue = normalizeAttrValue(value) || "";
|
|
833
851
|
if (el.defaultValue !== normalizedValue) {
|
|
834
|
-
const restoreValue = scope["#
|
|
852
|
+
const restoreValue = scope["#Gen"] < runId ? el.value : normalizedValue;
|
|
835
853
|
el.defaultValue = normalizedValue;
|
|
836
854
|
setInputValue(el, restoreValue);
|
|
837
855
|
}
|
|
838
856
|
}
|
|
839
857
|
function _attr_input_value(scope, nodeAccessor, value, valueChange) {
|
|
840
858
|
const el = scope[nodeAccessor];
|
|
841
|
-
const normalizedValue =
|
|
859
|
+
const normalizedValue = normalizeAttrValue(value) || "";
|
|
842
860
|
scope["ControlledHandler:" + nodeAccessor] = valueChange;
|
|
843
861
|
scope["ControlledValue:" + nodeAccessor] = normalizedValue;
|
|
844
862
|
scope["ControlledType:" + nodeAccessor] = valueChange ? 2 : 5;
|
|
845
|
-
if (valueChange &&
|
|
863
|
+
if (valueChange && scope["#Gen"] < runId) setInputValue(el, normalizedValue);
|
|
846
864
|
else _attr_input_value_default(scope, nodeAccessor, normalizedValue);
|
|
847
865
|
}
|
|
848
866
|
function _attr_input_value_script(scope, nodeAccessor) {
|
|
@@ -868,14 +886,14 @@ function setInputValue(el, value) {
|
|
|
868
886
|
function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
869
887
|
let restoreValue;
|
|
870
888
|
const el = scope[nodeAccessor];
|
|
871
|
-
const
|
|
889
|
+
const live = scope["#Gen"] < runId;
|
|
872
890
|
const multiple = Array.isArray(value);
|
|
873
891
|
const normalizedValue = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
874
892
|
pendingEffects.unshift(() => {
|
|
875
893
|
for (const opt of el.options) {
|
|
876
894
|
const selected = multiple ? normalizedValue.includes(opt.value) : opt.value === normalizedValue;
|
|
877
895
|
if (opt.defaultSelected !== selected) {
|
|
878
|
-
if (
|
|
896
|
+
if (live) restoreValue ??= getSelectValue(el, multiple);
|
|
879
897
|
opt.defaultSelected = selected;
|
|
880
898
|
}
|
|
881
899
|
}
|
|
@@ -884,7 +902,7 @@ function _attr_select_value_default(scope, nodeAccessor, value) {
|
|
|
884
902
|
}
|
|
885
903
|
function _attr_select_value(scope, nodeAccessor, value, valueChange) {
|
|
886
904
|
const el = scope[nodeAccessor];
|
|
887
|
-
const existing =
|
|
905
|
+
const existing = scope["#Gen"] < runId;
|
|
888
906
|
const multiple = Array.isArray(value);
|
|
889
907
|
const normalizedValue = scope["ControlledValue:" + nodeAccessor] = multiple ? value.map(normalizeStrProp) : normalizeStrProp(value);
|
|
890
908
|
scope["ControlledHandler:" + nodeAccessor] = valueChange;
|
|
@@ -932,13 +950,13 @@ function getSelectValue(el, multiple) {
|
|
|
932
950
|
return multiple ? Array.from(el.selectedOptions, (opt) => opt.value) : el.value;
|
|
933
951
|
}
|
|
934
952
|
function _attr_details_or_dialog_open_default(scope, nodeAccessor, open) {
|
|
935
|
-
if (scope["#
|
|
953
|
+
if (scope["#Gen"] === runId) scope[nodeAccessor].open = isNotVoid(open);
|
|
936
954
|
}
|
|
937
955
|
function _attr_details_or_dialog_open(scope, nodeAccessor, open, openChange) {
|
|
938
|
-
const normalizedOpen = scope["ControlledValue:" + nodeAccessor] =
|
|
956
|
+
const normalizedOpen = scope["ControlledValue:" + nodeAccessor] = isNotVoid(open);
|
|
939
957
|
scope["ControlledHandler:" + nodeAccessor] = openChange;
|
|
940
958
|
scope["ControlledType:" + nodeAccessor] = openChange ? 4 : 5;
|
|
941
|
-
if (openChange &&
|
|
959
|
+
if (openChange && scope["#Gen"] < runId) scope[nodeAccessor].open = normalizedOpen;
|
|
942
960
|
else _attr_details_or_dialog_open_default(scope, nodeAccessor, normalizedOpen);
|
|
943
961
|
}
|
|
944
962
|
function _attr_details_or_dialog_open_script(scope, nodeAccessor) {
|
|
@@ -987,9 +1005,6 @@ function hasFormElementChanged(el) {
|
|
|
987
1005
|
function normalizeStrProp(value) {
|
|
988
1006
|
return normalizeAttrValue(value) || "";
|
|
989
1007
|
}
|
|
990
|
-
function normalizeBoolProp(value) {
|
|
991
|
-
return value != null && value !== false;
|
|
992
|
-
}
|
|
993
1008
|
function updateList(arr, val, push) {
|
|
994
1009
|
const index = arr.indexOf(val);
|
|
995
1010
|
return (push ? !~index && [...arr, val] : ~index && arr.slice(0, index).concat(arr.slice(index + 1))) || arr;
|
|
@@ -1165,7 +1180,7 @@ function normalizeClientRender(value) {
|
|
|
1165
1180
|
else throw new Error(`Invalid \`content\` attribute. Received ${typeof value}`);
|
|
1166
1181
|
}
|
|
1167
1182
|
function normalizeAttrValue(value) {
|
|
1168
|
-
if (value
|
|
1183
|
+
if (isNotVoid(value)) return value === true ? "" : value + "";
|
|
1169
1184
|
}
|
|
1170
1185
|
function _lifecycle(scope, thisObj, index = 0) {
|
|
1171
1186
|
const accessor = "Lifecycle:" + index;
|
|
@@ -1245,7 +1260,7 @@ function _await_promise(nodeAccessor, params) {
|
|
|
1245
1260
|
scope[promiseAccessor] = 0;
|
|
1246
1261
|
queueAsyncRender(scope, () => {
|
|
1247
1262
|
if ((awaitBranch = scope[branchAccessor])["#DetachedAwait"]) {
|
|
1248
|
-
|
|
1263
|
+
awaitBranch["#PendingScopes"] = awaitBranch["#PendingScopes"]?.forEach(syncGen);
|
|
1249
1264
|
setupBranch(awaitBranch["#DetachedAwait"], awaitBranch);
|
|
1250
1265
|
awaitBranch["#DetachedAwait"] = 0;
|
|
1251
1266
|
insertBranchBefore(awaitBranch, scope[nodeAccessor].parentNode, scope[nodeAccessor]);
|
|
@@ -1286,8 +1301,8 @@ function _await_content(nodeAccessor, template, walks, setup) {
|
|
|
1286
1301
|
const branchAccessor = "BranchScopes:" + nodeAccessor;
|
|
1287
1302
|
const renderer = _content("", template, walks, setup)();
|
|
1288
1303
|
return (scope) => {
|
|
1289
|
-
(scope[branchAccessor] = createBranch(scope["$global"], renderer, scope, scope[nodeAccessor].parentNode))["#DetachedAwait"] = renderer;
|
|
1290
|
-
pendingScopes
|
|
1304
|
+
const pendingScopes = collectScopes(() => (scope[branchAccessor] = createBranch(scope["$global"], renderer, scope, scope[nodeAccessor].parentNode))["#DetachedAwait"] = renderer);
|
|
1305
|
+
scope[branchAccessor]["#PendingScopes"] = pendingScopes;
|
|
1291
1306
|
};
|
|
1292
1307
|
}
|
|
1293
1308
|
function addAwaitCounter(scope, tryBranch = findBranchWithKey(scope, "#PlaceholderContent")) {
|
|
@@ -1550,13 +1565,12 @@ function byFirstArg(name) {
|
|
|
1550
1565
|
}
|
|
1551
1566
|
//#endregion
|
|
1552
1567
|
//#region src/dom/queue.ts
|
|
1553
|
-
let
|
|
1554
|
-
let
|
|
1568
|
+
let rendering;
|
|
1569
|
+
let runId = 2;
|
|
1555
1570
|
const caughtError = /* @__PURE__ */ new WeakSet();
|
|
1556
1571
|
const placeholderShown = /* @__PURE__ */ new WeakSet();
|
|
1557
1572
|
let pendingEffects = [];
|
|
1558
|
-
let
|
|
1559
|
-
let rendering;
|
|
1573
|
+
let pendingRenders = [];
|
|
1560
1574
|
const scopeKeyOffset = 1e3;
|
|
1561
1575
|
function queueRender(scope, signal, signalKey, value, scopeKey = scope["#Id"]) {
|
|
1562
1576
|
let render;
|
|
@@ -1649,13 +1663,11 @@ function runRenders() {
|
|
|
1649
1663
|
}
|
|
1650
1664
|
runRender(render);
|
|
1651
1665
|
}
|
|
1652
|
-
for (const scope of pendingScopes) scope["#Creating"] = 0;
|
|
1653
|
-
pendingScopes = [];
|
|
1654
1666
|
}
|
|
1655
1667
|
let runRender = (render) => render["signal"](render["scope"], render["value"]);
|
|
1656
1668
|
function skipDestroyedRenders() {
|
|
1657
1669
|
runRender = ((runRender) => (render) => {
|
|
1658
|
-
if (
|
|
1670
|
+
if (render["scope"]["#ClosestBranch"]?.["#Gen"] !== 0) runRender(render);
|
|
1659
1671
|
})(runRender);
|
|
1660
1672
|
}
|
|
1661
1673
|
let catchEnabled;
|
|
@@ -1678,8 +1690,7 @@ function _enable_catch() {
|
|
|
1678
1690
|
for (; i < effects.length;) {
|
|
1679
1691
|
fn = effects[i++];
|
|
1680
1692
|
scope = effects[i++];
|
|
1681
|
-
branch = scope["#ClosestBranch"];
|
|
1682
|
-
if (!branch?.["#Destroyed"] && !(checkPending && handlePendingTry(fn, scope, branch))) fn(scope);
|
|
1693
|
+
if ((branch = scope["#ClosestBranch"])?.["#Gen"] !== 0 && !(checkPending && handlePendingTry(fn, scope, branch))) fn(scope);
|
|
1683
1694
|
}
|
|
1684
1695
|
} else runEffects(effects);
|
|
1685
1696
|
})(runEffects);
|
|
@@ -1903,13 +1914,12 @@ function _load_setup(nodeAccessor, childScopeAccessor, load) {
|
|
|
1903
1914
|
}
|
|
1904
1915
|
function insertLoaded(renderer, branch, marker, awaitCounter) {
|
|
1905
1916
|
const parent = marker.parentNode;
|
|
1906
|
-
branch
|
|
1917
|
+
syncGen(branch);
|
|
1907
1918
|
renderer["clone"](branch, parent.namespaceURI);
|
|
1908
1919
|
setupBranch(renderer, branch);
|
|
1909
1920
|
applyLoad(branch, () => {
|
|
1910
1921
|
insertBranchBefore(branch, parent, marker);
|
|
1911
1922
|
marker.remove();
|
|
1912
|
-
pendingScopes.push(branch);
|
|
1913
1923
|
awaitCounter?.c();
|
|
1914
1924
|
});
|
|
1915
1925
|
}
|
|
@@ -1925,14 +1935,11 @@ function applyLoad(scope, insert) {
|
|
|
1925
1935
|
scope["#Load"] = 0;
|
|
1926
1936
|
if (remaining = values?.size) for (const [promise, entry] of values) promise.then((signal) => {
|
|
1927
1937
|
entry["signal"] = signal;
|
|
1928
|
-
if (!--remaining) {
|
|
1929
|
-
scope
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
insert();
|
|
1934
|
-
});
|
|
1935
|
-
}
|
|
1938
|
+
if (!--remaining) queueAsyncRender(scope, (scope) => {
|
|
1939
|
+
syncGen(scope);
|
|
1940
|
+
values.forEach((e) => e["signal"]._(scope, e["value"]));
|
|
1941
|
+
insert();
|
|
1942
|
+
});
|
|
1936
1943
|
}, () => 0);
|
|
1937
1944
|
else insert();
|
|
1938
1945
|
}
|
|
@@ -1941,7 +1948,7 @@ function _load_signal(load) {
|
|
|
1941
1948
|
let signal;
|
|
1942
1949
|
return (scope, value) => {
|
|
1943
1950
|
pending ||= load();
|
|
1944
|
-
if (scope["#Load"] || !("#Load" in scope) && scope["#
|
|
1951
|
+
if (scope["#Load"] || !("#Load" in scope) && scope["#Gen"] === runId) (scope["#Load"] ||= /* @__PURE__ */ new Map()).set(pending, { ["value"]: value });
|
|
1945
1952
|
else if (signal) signal(scope, value);
|
|
1946
1953
|
else pending.then((mod) => queueAsyncRender(scope, signal = mod._, value), () => 0);
|
|
1947
1954
|
};
|