marko 6.0.0-next.3.37 → 6.0.0-next.3.38
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/debug/dom.js +48 -54
- package/dist/debug/dom.mjs +48 -54
- package/dist/dom/compat.d.ts +2 -2
- package/dist/dom/control-flow.d.ts +4 -5
- package/dist/dom/signals.d.ts +1 -2
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +67 -67
- package/dist/dom.mjs +67 -67
- package/dist/translator/core/for.d.ts +0 -9
- package/dist/translator/core/if.d.ts +0 -8
- package/dist/translator/index.js +549 -549
- package/dist/translator/util/is-only-child-in-parent.d.ts +14 -0
- package/package.json +1 -1
package/dist/dom.js
CHANGED
@@ -26,7 +26,6 @@ __export(dom_exports, {
|
|
26
26
|
compat: () => compat,
|
27
27
|
conditional: () => conditional,
|
28
28
|
conditionalClosure: () => conditionalClosure,
|
29
|
-
conditionalOnlyChild: () => conditionalOnlyChild,
|
30
29
|
controllable_detailsOrDialog_open: () => controllable_detailsOrDialog_open,
|
31
30
|
controllable_detailsOrDialog_open_effect: () => controllable_detailsOrDialog_open_effect,
|
32
31
|
controllable_input_checked: () => controllable_input_checked,
|
@@ -44,6 +43,7 @@ __export(dom_exports, {
|
|
44
43
|
createTemplate: () => createTemplate,
|
45
44
|
data: () => data,
|
46
45
|
dynamicClosure: () => dynamicClosure,
|
46
|
+
dynamicTag: () => dynamicTag,
|
47
47
|
dynamicTagAttrs: () => dynamicTagAttrs,
|
48
48
|
effect: () => effect,
|
49
49
|
forIn: () => forIn,
|
@@ -224,19 +224,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
224
224
|
|
225
225
|
// src/dom/resume.ts
|
226
226
|
var registeredValues = {}, Render = class {
|
227
|
-
|
228
|
-
|
227
|
+
m = [];
|
228
|
+
n = {};
|
229
229
|
A = {
|
230
230
|
_: registeredValues
|
231
231
|
};
|
232
232
|
constructor(renders, runtimeId, renderId) {
|
233
|
-
this.B = renders, this.C = runtimeId, this.
|
233
|
+
this.B = renders, this.C = runtimeId, this.o = renderId, this.p = renders[renderId], this.q();
|
234
234
|
}
|
235
235
|
w() {
|
236
|
-
this.
|
236
|
+
this.p.w(), this.q();
|
237
237
|
}
|
238
|
-
|
239
|
-
let data2 = this.
|
238
|
+
q() {
|
239
|
+
let data2 = this.p, serializeContext = this.A, scopeLookup = this.n, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
240
240
|
if (visits.length) {
|
241
241
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
242
242
|
data2.v = [];
|
@@ -258,7 +258,7 @@ var registeredValues = {}, Render = class {
|
|
258
258
|
else if (token === "$" /* ClosestBranch */)
|
259
259
|
closestBranchMarkers.set(scopeId, visit);
|
260
260
|
else if (token === "[" /* BranchStart */)
|
261
|
-
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.
|
261
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.m.push(this.e)), this.e = scopeId, scope.a = visit;
|
262
262
|
else if (token === "]" /* BranchEnd */) {
|
263
263
|
scope[data3] = visit;
|
264
264
|
let curParent = visit.parentNode, startNode = branchEnd(
|
@@ -266,7 +266,7 @@ var registeredValues = {}, Render = class {
|
|
266
266
|
visit,
|
267
267
|
visit
|
268
268
|
).a;
|
269
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.
|
269
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.m.pop();
|
270
270
|
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
271
271
|
let next = data3.indexOf(" "), curNode = visit;
|
272
272
|
for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
@@ -287,7 +287,7 @@ var registeredValues = {}, Render = class {
|
|
287
287
|
let resumeData = resumes[i++];
|
288
288
|
if (typeof resumeData == "function") {
|
289
289
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
290
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.
|
290
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.o);
|
291
291
|
for (let scopeId in scopes)
|
292
292
|
if (scopeId !== "$") {
|
293
293
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -298,10 +298,10 @@ var registeredValues = {}, Render = class {
|
|
298
298
|
let parentBranchId = parentBranchIds.get(scopeId);
|
299
299
|
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
300
300
|
let branch = scope, parentBranch = branch.c;
|
301
|
-
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.
|
301
|
+
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
|
302
302
|
}
|
303
303
|
}
|
304
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.B[this.
|
304
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.B[this.o] : registeredValues[resumes[i++]](
|
305
305
|
scopeLookup[resumeData],
|
306
306
|
scopeLookup[resumeData]
|
307
307
|
);
|
@@ -740,10 +740,10 @@ function getEmptyBranch(marker) {
|
|
740
740
|
return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
|
741
741
|
}
|
742
742
|
function destroyBranch(branch) {
|
743
|
-
branch.
|
743
|
+
branch.s?.j?.delete(branch), destroyNestedBranches(branch);
|
744
744
|
}
|
745
745
|
function destroyNestedBranches(branch) {
|
746
|
-
branch.E = 1, branch.
|
746
|
+
branch.E = 1, branch.j?.forEach(destroyNestedBranches), branch.F?.forEach((scope) => {
|
747
747
|
for (let id in scope.h)
|
748
748
|
scope.h[id]?.abort();
|
749
749
|
});
|
@@ -882,7 +882,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
882
882
|
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
883
883
|
let branch = createBranch(
|
884
884
|
$global,
|
885
|
-
renderer.
|
885
|
+
renderer.t || parentScope,
|
886
886
|
parentScope
|
887
887
|
);
|
888
888
|
return initBranch(renderer, branch, parentNode), branch;
|
@@ -903,11 +903,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
903
903
|
}
|
904
904
|
function createBranch($global, ownerScope, parentScope) {
|
905
905
|
let branch = createScope($global), parentBranch = parentScope.c;
|
906
|
-
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.
|
906
|
+
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
|
907
907
|
}
|
908
908
|
function initBranch(renderer, branch, parentNode) {
|
909
|
-
let clone = renderer.
|
910
|
-
walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.
|
909
|
+
let clone = renderer.k(parentNode.namespaceURI), cloneParent = clone.parentNode;
|
910
|
+
walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.u && queueRender(branch, renderer.u);
|
911
911
|
}
|
912
912
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
913
913
|
return (scope, attrsOrOp) => {
|
@@ -919,7 +919,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
919
919
|
return renderer.d?.(childScope, attrsOrOp);
|
920
920
|
let content = getContent?.(scope);
|
921
921
|
if (typeof renderer == "string")
|
922
|
-
setConditionalRendererOnlyChild(
|
922
|
+
setConditionalRendererOnlyChild(
|
923
|
+
childScope,
|
924
|
+
0,
|
925
|
+
content,
|
926
|
+
createBranchScopeWithTagNameOrRenderer
|
927
|
+
), attrs(childScope, 0, attrsOrOp());
|
923
928
|
else if (renderer.d) {
|
924
929
|
let attributes = attrsOrOp();
|
925
930
|
renderer.d(
|
@@ -937,12 +942,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
937
942
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
938
943
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
939
944
|
return (owner) => ({
|
940
|
-
|
945
|
+
x: id,
|
941
946
|
y: template,
|
942
947
|
G: walks,
|
943
|
-
|
944
|
-
|
945
|
-
|
948
|
+
u: setup,
|
949
|
+
k: _clone,
|
950
|
+
t: owner,
|
946
951
|
get d() {
|
947
952
|
return args ||= getArgs?.();
|
948
953
|
}
|
@@ -964,57 +969,52 @@ function createCloneableHTML(html2, ns) {
|
|
964
969
|
}
|
965
970
|
|
966
971
|
// src/dom/control-flow.ts
|
967
|
-
function
|
968
|
-
|
972
|
+
function conditional(nodeAccessor, ...branches) {
|
973
|
+
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
974
|
+
return (scope, newBranchIndexOrOp) => {
|
975
|
+
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN && (scope[nodeAccessor].nodeType > 1 /* Element */ ? setConditionalRenderer : setConditionalRendererOnlyChild)(
|
976
|
+
scope,
|
977
|
+
nodeAccessor,
|
978
|
+
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
979
|
+
createBranchScopeWithRenderer
|
980
|
+
);
|
981
|
+
};
|
969
982
|
}
|
970
|
-
|
983
|
+
function patchDynamicTag(fn) {
|
984
|
+
dynamicTag = fn(dynamicTag);
|
985
|
+
}
|
986
|
+
var dynamicTag = function(nodeAccessor, fn, getIntersection) {
|
971
987
|
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
972
988
|
return (scope, newRendererOrOp) => {
|
973
989
|
if (newRendererOrOp === DIRTY) return;
|
974
990
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
975
991
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
976
992
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
977
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
993
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
994
|
+
scope,
|
995
|
+
nodeAccessor,
|
996
|
+
normalizedRenderer,
|
997
|
+
createBranchScopeWithTagNameOrRenderer
|
998
|
+
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
978
999
|
}
|
979
1000
|
intersection2?.(scope, op);
|
980
1001
|
};
|
981
1002
|
};
|
982
|
-
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
983
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ?
|
1003
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
1004
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranch2(
|
984
1005
|
newRenderer,
|
985
1006
|
scope.$global,
|
986
1007
|
scope,
|
987
1008
|
prevBranch.b.parentNode
|
988
1009
|
) : getEmptyBranch(scope[nodeAccessor]);
|
989
|
-
insertBranchBefore(
|
1010
|
+
prevBranch !== newBranch && (insertBranchBefore(
|
990
1011
|
newBranch,
|
991
1012
|
prevBranch.b.parentNode,
|
992
1013
|
prevBranch.b.nextSibling
|
993
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
1014
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch);
|
994
1015
|
}
|
995
|
-
|
996
|
-
let
|
997
|
-
return (scope, newRendererOrOp) => {
|
998
|
-
if (newRendererOrOp === DIRTY) return;
|
999
|
-
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
1000
|
-
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
1001
|
-
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
1002
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (currentRenderer = scope[rendererAccessor] = normalizedRenderer, setConditionalRendererOnlyChild(
|
1003
|
-
scope,
|
1004
|
-
nodeAccessor,
|
1005
|
-
normalizedRenderer
|
1006
|
-
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
1007
|
-
}
|
1008
|
-
intersection2?.(scope, op);
|
1009
|
-
};
|
1010
|
-
};
|
1011
|
-
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
1012
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranchScopeWithTagNameOrRenderer(
|
1013
|
-
newRenderer,
|
1014
|
-
scope.$global,
|
1015
|
-
scope,
|
1016
|
-
referenceNode
|
1017
|
-
);
|
1016
|
+
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer, createBranch2) {
|
1017
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranch2(newRenderer, scope.$global, scope, referenceNode);
|
1018
1018
|
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
1019
1019
|
}
|
1020
1020
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
@@ -1078,7 +1078,7 @@ function byFirstArg(name) {
|
|
1078
1078
|
return name;
|
1079
1079
|
}
|
1080
1080
|
function isDifferentRenderer(a, b) {
|
1081
|
-
return a !== b && (a?.
|
1081
|
+
return a !== b && (a?.x || 0) !== b?.x;
|
1082
1082
|
}
|
1083
1083
|
|
1084
1084
|
// src/dom/signals.ts
|
@@ -1123,10 +1123,10 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
|
1123
1123
|
};
|
1124
1124
|
return helperSignal._ = signal, helperSignal;
|
1125
1125
|
}
|
1126
|
-
function conditionalClosure(ownerConditionalNodeAccessor,
|
1127
|
-
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */,
|
1128
|
-
let
|
1129
|
-
|
1126
|
+
function conditionalClosure(ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1127
|
+
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1128
|
+
let ifScope = scope[scopeAccessor];
|
1129
|
+
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, signal, value2);
|
1130
1130
|
};
|
1131
1131
|
return helperSignal._ = signal, helperSignal;
|
1132
1132
|
}
|
@@ -1185,7 +1185,7 @@ function queueSource(scope, signal, value2) {
|
|
1185
1185
|
}
|
1186
1186
|
function queueRender(scope, signal, value2) {
|
1187
1187
|
let i = pendingRenders.length, render = {
|
1188
|
-
|
1188
|
+
l: scope,
|
1189
1189
|
H: signal,
|
1190
1190
|
I: value2,
|
1191
1191
|
z: i
|
@@ -1241,7 +1241,7 @@ function runRenders() {
|
|
1241
1241
|
}
|
1242
1242
|
pendingRenders[i] = item;
|
1243
1243
|
}
|
1244
|
-
render.
|
1244
|
+
render.l.c?.E || render.H(render.l, render.I);
|
1245
1245
|
}
|
1246
1246
|
finishPendingScopes();
|
1247
1247
|
}
|
@@ -1249,7 +1249,7 @@ function comparePendingRenders(a, b) {
|
|
1249
1249
|
return getBranchDepth(a) - getBranchDepth(b) || a.z - b.z;
|
1250
1250
|
}
|
1251
1251
|
function getBranchDepth(render) {
|
1252
|
-
return render.
|
1252
|
+
return render.l.c?.f || 0;
|
1253
1253
|
}
|
1254
1254
|
|
1255
1255
|
// src/dom/abort-signal.ts
|
@@ -1269,7 +1269,7 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
|
|
1269
1269
|
|
1270
1270
|
// src/dom/compat.ts
|
1271
1271
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1272
|
-
patchConditionals,
|
1272
|
+
patchConditionals: patchDynamicTag,
|
1273
1273
|
queueEffect,
|
1274
1274
|
init(warp10Noop) {
|
1275
1275
|
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
@@ -1283,7 +1283,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1283
1283
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1284
1284
|
},
|
1285
1285
|
isRenderer(renderer) {
|
1286
|
-
return renderer.
|
1286
|
+
return renderer.k;
|
1287
1287
|
},
|
1288
1288
|
getStartNode(branch) {
|
1289
1289
|
return branch.a;
|
@@ -1303,12 +1303,12 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1303
1303
|
}) {
|
1304
1304
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1305
1305
|
value2[0],
|
1306
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1306
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.n[value2[1]]
|
1307
1307
|
) : value2;
|
1308
1308
|
},
|
1309
1309
|
createRenderer(setup, clone, args) {
|
1310
1310
|
let renderer = createRenderer("", 0, setup, args && (() => args));
|
1311
|
-
return renderer.
|
1311
|
+
return renderer.k = clone, renderer;
|
1312
1312
|
},
|
1313
1313
|
render(out, component, renderer, args) {
|
1314
1314
|
let branch = component.scope;
|
@@ -1320,7 +1320,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1320
1320
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1321
1321
|
}
|
1322
1322
|
if (component.effects = prepareEffects(() => {
|
1323
|
-
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.
|
1323
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.t, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
|
1324
1324
|
}), !existing)
|
1325
1325
|
return toInsertNode(branch.a, branch.b);
|
1326
1326
|
}
|
package/dist/dom.mjs
CHANGED
@@ -141,19 +141,19 @@ var DEFAULT_RUNTIME_ID = "M", DEFAULT_RENDER_ID = "_";
|
|
141
141
|
|
142
142
|
// src/dom/resume.ts
|
143
143
|
var registeredValues = {}, Render = class {
|
144
|
-
|
145
|
-
|
144
|
+
m = [];
|
145
|
+
n = {};
|
146
146
|
A = {
|
147
147
|
_: registeredValues
|
148
148
|
};
|
149
149
|
constructor(renders, runtimeId, renderId) {
|
150
|
-
this.B = renders, this.C = runtimeId, this.
|
150
|
+
this.B = renders, this.C = runtimeId, this.o = renderId, this.p = renders[renderId], this.q();
|
151
151
|
}
|
152
152
|
w() {
|
153
|
-
this.
|
153
|
+
this.p.w(), this.q();
|
154
154
|
}
|
155
|
-
|
156
|
-
let data2 = this.
|
155
|
+
q() {
|
156
|
+
let data2 = this.p, serializeContext = this.A, scopeLookup = this.n, visits = data2.v, branchIds = /* @__PURE__ */ new Set(), parentBranchIds = /* @__PURE__ */ new Map();
|
157
157
|
if (visits.length) {
|
158
158
|
let commentPrefixLen = data2.i.length, closestBranchMarkers = /* @__PURE__ */ new Map(), visitNodes = new Set(visits), lastEndNode;
|
159
159
|
data2.v = [];
|
@@ -175,7 +175,7 @@ var registeredValues = {}, Render = class {
|
|
175
175
|
else if (token === "$" /* ClosestBranch */)
|
176
176
|
closestBranchMarkers.set(scopeId, visit);
|
177
177
|
else if (token === "[" /* BranchStart */)
|
178
|
-
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.
|
178
|
+
this.e && (dataIndex && branchEnd(this.e, visit, visit), this.m.push(this.e)), this.e = scopeId, scope.a = visit;
|
179
179
|
else if (token === "]" /* BranchEnd */) {
|
180
180
|
scope[data3] = visit;
|
181
181
|
let curParent = visit.parentNode, startNode = branchEnd(
|
@@ -183,7 +183,7 @@ var registeredValues = {}, Render = class {
|
|
183
183
|
visit,
|
184
184
|
visit
|
185
185
|
).a;
|
186
|
-
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.
|
186
|
+
curParent !== startNode.parentNode && curParent.prepend(startNode), this.e = this.m.pop();
|
187
187
|
} else if (token === "|" /* BranchSingleNode */ || token === "=" /* BranchSingleNodeOnlyChildInParent */) {
|
188
188
|
let next = data3.indexOf(" "), curNode = visit;
|
189
189
|
for (scope[~next ? data3.slice(0, next) : data3] = token === "=" /* BranchSingleNodeOnlyChildInParent */ ? visit.parentNode : visit; ~next; ) {
|
@@ -204,7 +204,7 @@ var registeredValues = {}, Render = class {
|
|
204
204
|
let resumeData = resumes[i++];
|
205
205
|
if (typeof resumeData == "function") {
|
206
206
|
let scopes = resumeData(serializeContext), { $global } = scopeLookup;
|
207
|
-
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.
|
207
|
+
$global || (scopeLookup.$global = $global = scopes.$ || {}, $global.runtimeId = this.C, $global.renderId = this.o);
|
208
208
|
for (let scopeId in scopes)
|
209
209
|
if (scopeId !== "$") {
|
210
210
|
let scope = scopes[scopeId], prevScope = scopeLookup[scopeId];
|
@@ -215,10 +215,10 @@ var registeredValues = {}, Render = class {
|
|
215
215
|
let parentBranchId = parentBranchIds.get(scopeId);
|
216
216
|
if (parentBranchId && (scope.c = scopes[parentBranchId]), branchIds.has(scopeId)) {
|
217
217
|
let branch = scope, parentBranch = branch.c;
|
218
|
-
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.
|
218
|
+
branch.f = +scopeId, scope.c = branch, parentBranch && (branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch));
|
219
219
|
}
|
220
220
|
}
|
221
|
-
} else i === len || typeof resumes[i] != "string" ? delete this.B[this.
|
221
|
+
} else i === len || typeof resumes[i] != "string" ? delete this.B[this.o] : registeredValues[resumes[i++]](
|
222
222
|
scopeLookup[resumeData],
|
223
223
|
scopeLookup[resumeData]
|
224
224
|
);
|
@@ -657,10 +657,10 @@ function getEmptyBranch(marker) {
|
|
657
657
|
return emptyBranch.a = emptyBranch.b = marker, emptyBranch;
|
658
658
|
}
|
659
659
|
function destroyBranch(branch) {
|
660
|
-
branch.
|
660
|
+
branch.s?.j?.delete(branch), destroyNestedBranches(branch);
|
661
661
|
}
|
662
662
|
function destroyNestedBranches(branch) {
|
663
|
-
branch.E = 1, branch.
|
663
|
+
branch.E = 1, branch.j?.forEach(destroyNestedBranches), branch.F?.forEach((scope) => {
|
664
664
|
for (let id in scope.h)
|
665
665
|
scope.h[id]?.abort();
|
666
666
|
});
|
@@ -799,7 +799,7 @@ function walkInternal(walkCodes, scope, currentWalkIndex) {
|
|
799
799
|
function createBranchScopeWithRenderer(renderer, $global, parentScope, parentNode) {
|
800
800
|
let branch = createBranch(
|
801
801
|
$global,
|
802
|
-
renderer.
|
802
|
+
renderer.t || parentScope,
|
803
803
|
parentScope
|
804
804
|
);
|
805
805
|
return initBranch(renderer, branch, parentNode), branch;
|
@@ -820,11 +820,11 @@ function createBranchScopeWithTagNameOrRenderer(tagNameOrRenderer, $global, pare
|
|
820
820
|
}
|
821
821
|
function createBranch($global, ownerScope, parentScope) {
|
822
822
|
let branch = createScope($global), parentBranch = parentScope.c;
|
823
|
-
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.
|
823
|
+
return branch._ = ownerScope, branch.c = branch, parentBranch ? (branch.f = parentBranch.f + 1, branch.s = parentBranch, (parentBranch.j ||= /* @__PURE__ */ new Set()).add(branch)) : branch.f = 1, branch;
|
824
824
|
}
|
825
825
|
function initBranch(renderer, branch, parentNode) {
|
826
|
-
let clone = renderer.
|
827
|
-
walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.
|
826
|
+
let clone = renderer.k(parentNode.namespaceURI), cloneParent = clone.parentNode;
|
827
|
+
walk(cloneParent?.firstChild || clone, renderer.G, branch), branch.a = cloneParent?.firstChild || clone, branch.b = cloneParent?.lastChild || clone, renderer.u && queueRender(branch, renderer.u);
|
828
828
|
}
|
829
829
|
function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
830
830
|
return (scope, attrsOrOp) => {
|
@@ -836,7 +836,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
836
836
|
return renderer.d?.(childScope, attrsOrOp);
|
837
837
|
let content = getContent?.(scope);
|
838
838
|
if (typeof renderer == "string")
|
839
|
-
setConditionalRendererOnlyChild(
|
839
|
+
setConditionalRendererOnlyChild(
|
840
|
+
childScope,
|
841
|
+
0,
|
842
|
+
content,
|
843
|
+
createBranchScopeWithTagNameOrRenderer
|
844
|
+
), attrs(childScope, 0, attrsOrOp());
|
840
845
|
else if (renderer.d) {
|
841
846
|
let attributes = attrsOrOp();
|
842
847
|
renderer.d(
|
@@ -854,12 +859,12 @@ function dynamicTagAttrs(nodeAccessor, getContent, inputIsArgs) {
|
|
854
859
|
function createRendererWithOwner(template, rawWalks, setup, getArgs) {
|
855
860
|
let args, id = {}, walks = rawWalks ? /* @__PURE__ */ trimWalkString(rawWalks) : " ";
|
856
861
|
return (owner) => ({
|
857
|
-
|
862
|
+
x: id,
|
858
863
|
y: template,
|
859
864
|
G: walks,
|
860
|
-
|
861
|
-
|
862
|
-
|
865
|
+
u: setup,
|
866
|
+
k: _clone,
|
867
|
+
t: owner,
|
863
868
|
get d() {
|
864
869
|
return args ||= getArgs?.();
|
865
870
|
}
|
@@ -881,57 +886,52 @@ function createCloneableHTML(html2, ns) {
|
|
881
886
|
}
|
882
887
|
|
883
888
|
// src/dom/control-flow.ts
|
884
|
-
function
|
885
|
-
|
889
|
+
function conditional(nodeAccessor, ...branches) {
|
890
|
+
let branchAccessor = nodeAccessor + "(" /* ConditionalRenderer */;
|
891
|
+
return (scope, newBranchIndexOrOp) => {
|
892
|
+
newBranchIndexOrOp !== scope[branchAccessor] && newBranchIndexOrOp !== DIRTY && newBranchIndexOrOp !== MARK && newBranchIndexOrOp !== CLEAN && (scope[nodeAccessor].nodeType > 1 /* Element */ ? setConditionalRenderer : setConditionalRendererOnlyChild)(
|
893
|
+
scope,
|
894
|
+
nodeAccessor,
|
895
|
+
branches[scope[branchAccessor] = newBranchIndexOrOp],
|
896
|
+
createBranchScopeWithRenderer
|
897
|
+
);
|
898
|
+
};
|
886
899
|
}
|
887
|
-
|
900
|
+
function patchDynamicTag(fn) {
|
901
|
+
dynamicTag = fn(dynamicTag);
|
902
|
+
}
|
903
|
+
var dynamicTag = function(nodeAccessor, fn, getIntersection) {
|
888
904
|
let rendererAccessor = nodeAccessor + "(" /* ConditionalRenderer */, intersection2 = getIntersection && ((scope, op) => (intersection2 = getIntersection())(scope, op));
|
889
905
|
return (scope, newRendererOrOp) => {
|
890
906
|
if (newRendererOrOp === DIRTY) return;
|
891
907
|
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
892
908
|
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
893
909
|
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
894
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
910
|
+
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (scope[rendererAccessor] = normalizedRenderer, setConditionalRenderer(
|
911
|
+
scope,
|
912
|
+
nodeAccessor,
|
913
|
+
normalizedRenderer,
|
914
|
+
createBranchScopeWithTagNameOrRenderer
|
915
|
+
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
895
916
|
}
|
896
917
|
intersection2?.(scope, op);
|
897
918
|
};
|
898
919
|
};
|
899
|
-
function setConditionalRenderer(scope, nodeAccessor, newRenderer) {
|
900
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ?
|
920
|
+
function setConditionalRenderer(scope, nodeAccessor, newRenderer, createBranch2) {
|
921
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */] || getEmptyBranch(scope[nodeAccessor]), newBranch = newRenderer ? createBranch2(
|
901
922
|
newRenderer,
|
902
923
|
scope.$global,
|
903
924
|
scope,
|
904
925
|
prevBranch.b.parentNode
|
905
926
|
) : getEmptyBranch(scope[nodeAccessor]);
|
906
|
-
insertBranchBefore(
|
927
|
+
prevBranch !== newBranch && (insertBranchBefore(
|
907
928
|
newBranch,
|
908
929
|
prevBranch.b.parentNode,
|
909
930
|
prevBranch.b.nextSibling
|
910
|
-
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch;
|
931
|
+
), removeAndDestroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newRenderer && newBranch);
|
911
932
|
}
|
912
|
-
|
913
|
-
let
|
914
|
-
return (scope, newRendererOrOp) => {
|
915
|
-
if (newRendererOrOp === DIRTY) return;
|
916
|
-
let currentRenderer = scope[rendererAccessor], op = newRendererOrOp;
|
917
|
-
if (newRendererOrOp !== MARK && newRendererOrOp !== CLEAN) {
|
918
|
-
let normalizedRenderer = normalizeDynamicRenderer(newRendererOrOp);
|
919
|
-
isDifferentRenderer(normalizedRenderer, currentRenderer) ? (currentRenderer = scope[rendererAccessor] = normalizedRenderer, setConditionalRendererOnlyChild(
|
920
|
-
scope,
|
921
|
-
nodeAccessor,
|
922
|
-
normalizedRenderer
|
923
|
-
), fn && fn(scope), op = DIRTY) : op = CLEAN;
|
924
|
-
}
|
925
|
-
intersection2?.(scope, op);
|
926
|
-
};
|
927
|
-
};
|
928
|
-
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer) {
|
929
|
-
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranchScopeWithTagNameOrRenderer(
|
930
|
-
newRenderer,
|
931
|
-
scope.$global,
|
932
|
-
scope,
|
933
|
-
referenceNode
|
934
|
-
);
|
933
|
+
function setConditionalRendererOnlyChild(scope, nodeAccessor, newRenderer, createBranch2) {
|
934
|
+
let prevBranch = scope[nodeAccessor + "!" /* ConditionalScope */], referenceNode = scope[nodeAccessor], newBranch = newRenderer && createBranch2(newRenderer, scope.$global, scope, referenceNode);
|
935
935
|
referenceNode.textContent = "", newBranch && insertBranchBefore(newBranch, referenceNode, null), prevBranch && destroyBranch(prevBranch), scope[nodeAccessor + "!" /* ConditionalScope */] = newBranch;
|
936
936
|
}
|
937
937
|
var emptyMarkerMap = /* @__PURE__ */ new Map([
|
@@ -995,7 +995,7 @@ function byFirstArg(name) {
|
|
995
995
|
return name;
|
996
996
|
}
|
997
997
|
function isDifferentRenderer(a, b) {
|
998
|
-
return a !== b && (a?.
|
998
|
+
return a !== b && (a?.x || 0) !== b?.x;
|
999
999
|
}
|
1000
1000
|
|
1001
1001
|
// src/dom/signals.ts
|
@@ -1040,10 +1040,10 @@ function loopClosure(ownerLoopNodeAccessor, fn, getIntersection) {
|
|
1040
1040
|
};
|
1041
1041
|
return helperSignal._ = signal, helperSignal;
|
1042
1042
|
}
|
1043
|
-
function conditionalClosure(ownerConditionalNodeAccessor,
|
1044
|
-
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */,
|
1045
|
-
let
|
1046
|
-
|
1043
|
+
function conditionalClosure(ownerConditionalNodeAccessor, branch, fn, getIntersection) {
|
1044
|
+
let signal = closure(fn, getIntersection), scopeAccessor = ownerConditionalNodeAccessor + "!" /* ConditionalScope */, branchAccessor = ownerConditionalNodeAccessor + "(" /* ConditionalRenderer */, helperSignal = (scope, value2) => {
|
1045
|
+
let ifScope = scope[scopeAccessor];
|
1046
|
+
ifScope && !ifScope.g && scope[branchAccessor] === branch && queueSource(ifScope, signal, value2);
|
1047
1047
|
};
|
1048
1048
|
return helperSignal._ = signal, helperSignal;
|
1049
1049
|
}
|
@@ -1102,7 +1102,7 @@ function queueSource(scope, signal, value2) {
|
|
1102
1102
|
}
|
1103
1103
|
function queueRender(scope, signal, value2) {
|
1104
1104
|
let i = pendingRenders.length, render = {
|
1105
|
-
|
1105
|
+
l: scope,
|
1106
1106
|
H: signal,
|
1107
1107
|
I: value2,
|
1108
1108
|
z: i
|
@@ -1158,7 +1158,7 @@ function runRenders() {
|
|
1158
1158
|
}
|
1159
1159
|
pendingRenders[i] = item;
|
1160
1160
|
}
|
1161
|
-
render.
|
1161
|
+
render.l.c?.E || render.H(render.l, render.I);
|
1162
1162
|
}
|
1163
1163
|
finishPendingScopes();
|
1164
1164
|
}
|
@@ -1166,7 +1166,7 @@ function comparePendingRenders(a, b) {
|
|
1166
1166
|
return getBranchDepth(a) - getBranchDepth(b) || a.z - b.z;
|
1167
1167
|
}
|
1168
1168
|
function getBranchDepth(render) {
|
1169
|
-
return render.
|
1169
|
+
return render.l.c?.f || 0;
|
1170
1170
|
}
|
1171
1171
|
|
1172
1172
|
// src/dom/abort-signal.ts
|
@@ -1186,7 +1186,7 @@ var prefix = "$C_", RENDERER_REGISTER_ID = prefix + "r", SET_SCOPE_REGISTER_ID =
|
|
1186
1186
|
|
1187
1187
|
// src/dom/compat.ts
|
1188
1188
|
var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
1189
|
-
patchConditionals,
|
1189
|
+
patchConditionals: patchDynamicTag,
|
1190
1190
|
queueEffect,
|
1191
1191
|
init(warp10Noop) {
|
1192
1192
|
register(SET_SCOPE_REGISTER_ID, (branch) => {
|
@@ -1200,7 +1200,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1200
1200
|
return value2 === MARK || value2 === CLEAN || value2 === DIRTY;
|
1201
1201
|
},
|
1202
1202
|
isRenderer(renderer) {
|
1203
|
-
return renderer.
|
1203
|
+
return renderer.k;
|
1204
1204
|
},
|
1205
1205
|
getStartNode(branch) {
|
1206
1206
|
return branch.a;
|
@@ -1220,12 +1220,12 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1220
1220
|
}) {
|
1221
1221
|
return Array.isArray(value2) && typeof value2[0] == "string" ? getRegisteredWithScope(
|
1222
1222
|
value2[0],
|
1223
|
-
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.
|
1223
|
+
value2.length === 2 && window[runtimeId]?.[componentIdPrefix === "s" ? "_" : componentIdPrefix]?.n[value2[1]]
|
1224
1224
|
) : value2;
|
1225
1225
|
},
|
1226
1226
|
createRenderer(setup, clone, args) {
|
1227
1227
|
let renderer = createRenderer("", 0, setup, args && (() => args));
|
1228
|
-
return renderer.
|
1228
|
+
return renderer.k = clone, renderer;
|
1229
1229
|
},
|
1230
1230
|
render(out, component, renderer, args) {
|
1231
1231
|
let branch = component.scope;
|
@@ -1237,7 +1237,7 @@ var classIdToBranch = /* @__PURE__ */ new Map(), compat = {
|
|
1237
1237
|
normalizedInput[key === "renderBody" ? "content" : key] = input[key];
|
1238
1238
|
}
|
1239
1239
|
if (component.effects = prepareEffects(() => {
|
1240
|
-
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.
|
1240
|
+
branch ? (applyArgs(branch, MARK), existing = !0) : (branch = component.scope = createScope(out.global), branch._ = renderer.t, initBranch(renderer, branch, document.body)), applyArgs(branch, args);
|
1241
1241
|
}), !existing)
|
1242
1242
|
return toInsertNode(branch.a, branch.b);
|
1243
1243
|
}
|
@@ -1301,7 +1301,6 @@ export {
|
|
1301
1301
|
compat,
|
1302
1302
|
conditional,
|
1303
1303
|
conditionalClosure,
|
1304
|
-
conditionalOnlyChild,
|
1305
1304
|
controllable_detailsOrDialog_open,
|
1306
1305
|
controllable_detailsOrDialog_open_effect,
|
1307
1306
|
controllable_input_checked,
|
@@ -1319,6 +1318,7 @@ export {
|
|
1319
1318
|
createTemplate,
|
1320
1319
|
data,
|
1321
1320
|
dynamicClosure,
|
1321
|
+
dynamicTag,
|
1322
1322
|
dynamicTagAttrs,
|
1323
1323
|
effect,
|
1324
1324
|
forIn,
|
@@ -1,14 +1,5 @@
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
2
|
-
import { type Binding } from "../util/references";
|
3
2
|
type ForType = "in" | "of" | "to";
|
4
|
-
declare const kForMarkerBinding: unique symbol;
|
5
|
-
declare const kOnlyChildInParent: unique symbol;
|
6
|
-
declare module "@marko/compiler/dist/types" {
|
7
|
-
interface NodeExtra {
|
8
|
-
[kForMarkerBinding]?: Binding;
|
9
|
-
[kOnlyChildInParent]?: boolean;
|
10
|
-
}
|
11
|
-
}
|
12
3
|
declare const _default: {
|
13
4
|
analyze(tag: t.NodePath<t.MarkoTag>): void;
|
14
5
|
translate: {
|