marko 6.2.0 → 6.2.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/dist/debug/dom.js +11 -9
- package/dist/debug/dom.mjs +11 -9
- package/dist/debug/html.js +6 -5
- package/dist/debug/html.mjs +6 -5
- package/dist/dom.js +9 -10
- package/dist/dom.mjs +9 -10
- package/dist/html/writer.d.ts +6 -5
- package/dist/html.js +5 -5
- package/dist/html.mjs +5 -5
- package/dist/translator/index.js +204 -37
- package/dist/translator/util/known-tag.d.ts +1 -1
- package/dist/translator/util/references.d.ts +5 -0
- package/dist/translator/util/serialize-reasons.d.ts +2 -0
- package/dist/translator/util/setup-statements.d.ts +5 -0
- package/dist/translator/util/signals.d.ts +1 -0
- package/dist/translator/visitors/program/index.d.ts +1 -0
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
|
@@ -73,7 +73,7 @@ function stringifyStyleObject(name, value) {
|
|
|
73
73
|
}
|
|
74
74
|
function escapeStyleValue(str) {
|
|
75
75
|
let closers = "";
|
|
76
|
-
const result = str.replace(/[\\"'{}
|
|
76
|
+
const result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
77
77
|
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
78
78
|
else if (c === "[") closers = "]" + closers;
|
|
79
79
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
@@ -233,6 +233,10 @@ const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
|
233
233
|
function toArray(opt) {
|
|
234
234
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
235
235
|
}
|
|
236
|
+
function forEach(opt, cb) {
|
|
237
|
+
if (opt) if (Array.isArray(opt)) for (const item of opt) cb(item);
|
|
238
|
+
else cb(opt);
|
|
239
|
+
}
|
|
236
240
|
function push(opt, item) {
|
|
237
241
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
238
242
|
}
|
|
@@ -778,12 +782,14 @@ function init(runtimeId = "M") {
|
|
|
778
782
|
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch["#AwaitCounter"].m = render.m;
|
|
779
783
|
if (singleNode) {
|
|
780
784
|
while (startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling));
|
|
785
|
+
branch["_"] ??= visitScope;
|
|
781
786
|
branch["#EndNode"] = branch["#StartNode"] = startVisit;
|
|
782
787
|
if (visitType === "'") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
783
788
|
} else {
|
|
784
789
|
curBranchScopes = push(curBranchScopes, branch);
|
|
785
790
|
if (accessor) {
|
|
786
791
|
visitScope[accessor] = curBranchScopes;
|
|
792
|
+
forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
|
|
787
793
|
curBranchScopes = branchScopesStack.pop();
|
|
788
794
|
}
|
|
789
795
|
startVisit = branchStarts.pop();
|
|
@@ -1186,20 +1192,16 @@ function _attr_style_item(element, name, value) {
|
|
|
1186
1192
|
function _style_shell(scope, nodeAccessor) {
|
|
1187
1193
|
const element = scope[nodeAccessor];
|
|
1188
1194
|
const id = _id(scope);
|
|
1195
|
+
_attr_nonce(scope, nodeAccessor);
|
|
1189
1196
|
element.className = id;
|
|
1190
|
-
_text_content(element, "." + id + "
|
|
1197
|
+
_text_content(element, "." + id + "~*{}");
|
|
1191
1198
|
}
|
|
1192
1199
|
function _style_rule_item(element, name, value) {
|
|
1193
1200
|
const text = element.textContent;
|
|
1194
1201
|
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1195
1202
|
let start = text.indexOf("{" + name + ":");
|
|
1196
|
-
if (start
|
|
1197
|
-
|
|
1198
|
-
else {
|
|
1199
|
-
let end = ++start;
|
|
1200
|
-
for (let c; (c = text[end]) && c !== ";"; end++) if (c === "\\") end++;
|
|
1201
|
-
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
1202
|
-
}
|
|
1203
|
+
if (!~start) start = text.indexOf(";" + name + ":");
|
|
1204
|
+
_text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
1203
1205
|
}
|
|
1204
1206
|
function _attr_nonce(scope, nodeAccessor) {
|
|
1205
1207
|
_attr(scope[nodeAccessor], "nonce", scope["$global"].cspNonce);
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -71,7 +71,7 @@ function stringifyStyleObject(name, value) {
|
|
|
71
71
|
}
|
|
72
72
|
function escapeStyleValue(str) {
|
|
73
73
|
let closers = "";
|
|
74
|
-
const result = str.replace(/[\\"'{}
|
|
74
|
+
const result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
75
75
|
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
76
76
|
else if (c === "[") closers = "]" + closers;
|
|
77
77
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
@@ -231,6 +231,10 @@ const DYNAMIC_TAG_SCRIPT_REGISTER_ID = "_dynamicTagScript";
|
|
|
231
231
|
function toArray(opt) {
|
|
232
232
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
233
233
|
}
|
|
234
|
+
function forEach(opt, cb) {
|
|
235
|
+
if (opt) if (Array.isArray(opt)) for (const item of opt) cb(item);
|
|
236
|
+
else cb(opt);
|
|
237
|
+
}
|
|
234
238
|
function push(opt, item) {
|
|
235
239
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
236
240
|
}
|
|
@@ -776,12 +780,14 @@ function init(runtimeId = "M") {
|
|
|
776
780
|
if (branch["#AwaitCounter"] = render.p?.[branchId]) branch["#AwaitCounter"].m = render.m;
|
|
777
781
|
if (singleNode) {
|
|
778
782
|
while (startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling));
|
|
783
|
+
branch["_"] ??= visitScope;
|
|
779
784
|
branch["#EndNode"] = branch["#StartNode"] = startVisit;
|
|
780
785
|
if (visitType === "'") branch[getDebugKey(0, startVisit)] = startVisit;
|
|
781
786
|
} else {
|
|
782
787
|
curBranchScopes = push(curBranchScopes, branch);
|
|
783
788
|
if (accessor) {
|
|
784
789
|
visitScope[accessor] = curBranchScopes;
|
|
790
|
+
forEach(curBranchScopes, (scope) => scope["_"] ??= visitScope);
|
|
785
791
|
curBranchScopes = branchScopesStack.pop();
|
|
786
792
|
}
|
|
787
793
|
startVisit = branchStarts.pop();
|
|
@@ -1184,20 +1190,16 @@ function _attr_style_item(element, name, value) {
|
|
|
1184
1190
|
function _style_shell(scope, nodeAccessor) {
|
|
1185
1191
|
const element = scope[nodeAccessor];
|
|
1186
1192
|
const id = _id(scope);
|
|
1193
|
+
_attr_nonce(scope, nodeAccessor);
|
|
1187
1194
|
element.className = id;
|
|
1188
|
-
_text_content(element, "." + id + "
|
|
1195
|
+
_text_content(element, "." + id + "~*{}");
|
|
1189
1196
|
}
|
|
1190
1197
|
function _style_rule_item(element, name, value) {
|
|
1191
1198
|
const text = element.textContent;
|
|
1192
1199
|
const decl = name + ":" + escapeStyleValue(_to_text(value)) + ";";
|
|
1193
1200
|
let start = text.indexOf("{" + name + ":");
|
|
1194
|
-
if (start
|
|
1195
|
-
|
|
1196
|
-
else {
|
|
1197
|
-
let end = ++start;
|
|
1198
|
-
for (let c; (c = text[end]) && c !== ";"; end++) if (c === "\\") end++;
|
|
1199
|
-
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
1200
|
-
}
|
|
1201
|
+
if (!~start) start = text.indexOf(";" + name + ":");
|
|
1202
|
+
_text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
1201
1203
|
}
|
|
1202
1204
|
function _attr_nonce(scope, nodeAccessor) {
|
|
1203
1205
|
_attr(scope[nodeAccessor], "nonce", scope["$global"].cspNonce);
|
package/dist/debug/html.js
CHANGED
|
@@ -69,7 +69,7 @@ function stringifyStyleObject(name, value) {
|
|
|
69
69
|
}
|
|
70
70
|
function escapeStyleValue(str) {
|
|
71
71
|
let closers = "";
|
|
72
|
-
const result = str.replace(/[\\"'{}
|
|
72
|
+
const result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
73
73
|
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
74
74
|
else if (c === "[") closers = "]" + closers;
|
|
75
75
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
@@ -1723,7 +1723,7 @@ function _scope_reason() {
|
|
|
1723
1723
|
return reason;
|
|
1724
1724
|
}
|
|
1725
1725
|
function _serialize_if(condition, key) {
|
|
1726
|
-
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
|
1726
|
+
return condition && (condition === 1 || (typeof condition === "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1727
1727
|
}
|
|
1728
1728
|
function _serialize_guard(condition, key) {
|
|
1729
1729
|
return _serialize_if(condition, key) || 0;
|
|
@@ -2271,7 +2271,7 @@ var Chunk = class Chunk {
|
|
|
2271
2271
|
readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
2272
2272
|
}
|
|
2273
2273
|
if (readyResumeScripts) needsWalk = true;
|
|
2274
|
-
const
|
|
2274
|
+
const effects = this.async ? "" : this.effects;
|
|
2275
2275
|
let { html, scripts } = this;
|
|
2276
2276
|
if (state.needsMainRuntime && !state.hasMainRuntime) {
|
|
2277
2277
|
state.hasMainRuntime = true;
|
|
@@ -2334,7 +2334,8 @@ var Chunk = class Chunk {
|
|
|
2334
2334
|
if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
|
|
2335
2335
|
this.html = html;
|
|
2336
2336
|
this.scripts = scripts;
|
|
2337
|
-
this.effects = this.lastEffect =
|
|
2337
|
+
if (!this.async) this.effects = this.lastEffect = "";
|
|
2338
|
+
state.resumes = "";
|
|
2338
2339
|
return this;
|
|
2339
2340
|
}
|
|
2340
2341
|
flushHTML() {
|
|
@@ -2544,7 +2545,7 @@ function _attr_nonce() {
|
|
|
2544
2545
|
}
|
|
2545
2546
|
function _style_html(decls) {
|
|
2546
2547
|
const id = _id();
|
|
2547
|
-
return `<style${_attr_nonce()} class=${id}>.${id}
|
|
2548
|
+
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
2548
2549
|
}
|
|
2549
2550
|
function _attr(name, value) {
|
|
2550
2551
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
package/dist/debug/html.mjs
CHANGED
|
@@ -67,7 +67,7 @@ function stringifyStyleObject(name, value) {
|
|
|
67
67
|
}
|
|
68
68
|
function escapeStyleValue(str) {
|
|
69
69
|
let closers = "";
|
|
70
|
-
const result = str.replace(/[\\"'{}
|
|
70
|
+
const result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
71
71
|
for (const c of result) if (c === "(") closers = ")" + closers;
|
|
72
72
|
else if (c === "[") closers = "]" + closers;
|
|
73
73
|
else if (c === closers[0]) closers = closers.slice(1);
|
|
@@ -1721,7 +1721,7 @@ function _scope_reason() {
|
|
|
1721
1721
|
return reason;
|
|
1722
1722
|
}
|
|
1723
1723
|
function _serialize_if(condition, key) {
|
|
1724
|
-
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
|
1724
|
+
return condition && (condition === 1 || (typeof condition === "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1725
1725
|
}
|
|
1726
1726
|
function _serialize_guard(condition, key) {
|
|
1727
1727
|
return _serialize_if(condition, key) || 0;
|
|
@@ -2269,7 +2269,7 @@ var Chunk = class Chunk {
|
|
|
2269
2269
|
readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
2270
2270
|
}
|
|
2271
2271
|
if (readyResumeScripts) needsWalk = true;
|
|
2272
|
-
const
|
|
2272
|
+
const effects = this.async ? "" : this.effects;
|
|
2273
2273
|
let { html, scripts } = this;
|
|
2274
2274
|
if (state.needsMainRuntime && !state.hasMainRuntime) {
|
|
2275
2275
|
state.hasMainRuntime = true;
|
|
@@ -2332,7 +2332,8 @@ var Chunk = class Chunk {
|
|
|
2332
2332
|
if (needsWalk) scripts = concatScripts(scripts, runtimePrefix + ".w()");
|
|
2333
2333
|
this.html = html;
|
|
2334
2334
|
this.scripts = scripts;
|
|
2335
|
-
this.effects = this.lastEffect =
|
|
2335
|
+
if (!this.async) this.effects = this.lastEffect = "";
|
|
2336
|
+
state.resumes = "";
|
|
2336
2337
|
return this;
|
|
2337
2338
|
}
|
|
2338
2339
|
flushHTML() {
|
|
@@ -2542,7 +2543,7 @@ function _attr_nonce() {
|
|
|
2542
2543
|
}
|
|
2543
2544
|
function _style_html(decls) {
|
|
2544
2545
|
const id = _id();
|
|
2545
|
-
return `<style${_attr_nonce()} class=${id}>.${id}
|
|
2546
|
+
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
2546
2547
|
}
|
|
2547
2548
|
function _attr(name, value) {
|
|
2548
2549
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
package/dist/dom.js
CHANGED
|
@@ -133,7 +133,7 @@ function stringifyStyleObject(name, value) {
|
|
|
133
133
|
return value || value === 0 ? name + ":" + value : "";
|
|
134
134
|
}
|
|
135
135
|
function escapeStyleValue(str) {
|
|
136
|
-
let closers = "", result = str.replace(/[\\"'{}
|
|
136
|
+
let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
137
137
|
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
138
138
|
return result + closers;
|
|
139
139
|
}
|
|
@@ -181,6 +181,10 @@ function forUntil(until, from, step, cb) {
|
|
|
181
181
|
function toArray(opt) {
|
|
182
182
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
183
183
|
}
|
|
184
|
+
function forEach(opt, cb) {
|
|
185
|
+
if (opt) if (Array.isArray(opt)) for (let item of opt) cb(item);
|
|
186
|
+
else cb(opt);
|
|
187
|
+
}
|
|
184
188
|
function push(opt, item) {
|
|
185
189
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
186
190
|
}
|
|
@@ -496,8 +500,8 @@ function init(runtimeId = "M") {
|
|
|
496
500
|
for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
|
|
497
501
|
if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
|
|
498
502
|
for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
|
|
499
|
-
branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
500
|
-
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
503
|
+
branch._ ??= visitScope, branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
504
|
+
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, forEach(curBranchScopes, (scope) => scope._ ??= visitScope), curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
501
505
|
for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
|
|
502
506
|
for (; j && deferredOwners[--j].L > branchId;) {
|
|
503
507
|
let owner = deferredOwners.pop();
|
|
@@ -769,16 +773,11 @@ function _attr_style_item(element, name, value) {
|
|
|
769
773
|
}
|
|
770
774
|
function _style_shell(scope, nodeAccessor) {
|
|
771
775
|
let element = scope[nodeAccessor], id = _id(scope);
|
|
772
|
-
element.className = id, _text_content(element, "." + id + "
|
|
776
|
+
_attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
|
|
773
777
|
}
|
|
774
778
|
function _style_rule_item(element, name, value) {
|
|
775
779
|
let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
|
|
776
|
-
|
|
777
|
-
else {
|
|
778
|
-
let end = ++start;
|
|
779
|
-
for (let c; (c = text[end]) && c !== ";"; end++) c === "\\" && end++;
|
|
780
|
-
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
781
|
-
}
|
|
780
|
+
~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
782
781
|
}
|
|
783
782
|
function _attr_nonce(scope, nodeAccessor) {
|
|
784
783
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
package/dist/dom.mjs
CHANGED
|
@@ -132,7 +132,7 @@ function stringifyStyleObject(name, value) {
|
|
|
132
132
|
return value || value === 0 ? name + ":" + value : "";
|
|
133
133
|
}
|
|
134
134
|
function escapeStyleValue(str) {
|
|
135
|
-
let closers = "", result = str.replace(/[\\"'{}
|
|
135
|
+
let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
136
136
|
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
137
137
|
return result + closers;
|
|
138
138
|
}
|
|
@@ -180,6 +180,10 @@ function forUntil(until, from, step, cb) {
|
|
|
180
180
|
function toArray(opt) {
|
|
181
181
|
return opt ? Array.isArray(opt) ? opt : [opt] : [];
|
|
182
182
|
}
|
|
183
|
+
function forEach(opt, cb) {
|
|
184
|
+
if (opt) if (Array.isArray(opt)) for (let item of opt) cb(item);
|
|
185
|
+
else cb(opt);
|
|
186
|
+
}
|
|
183
187
|
function push(opt, item) {
|
|
184
188
|
return opt ? Array.isArray(opt) ? (opt.push(item), opt) : [opt, item] : item;
|
|
185
189
|
}
|
|
@@ -495,8 +499,8 @@ function init(runtimeId = "M") {
|
|
|
495
499
|
for (visitType !== "[" && (visitScope[nextToken()] = visitType === ")" || visitType === "}" ? parent : visit, accessor = "A" + lastToken, singleNode = visitType !== "]" && visitType !== ")", nextToken()); branchId = +lastToken;) {
|
|
496
500
|
if ((endedBranches ||= []).push(branch = getScope(branchId)), setParentBranch(branch, branch.F), (branch.O = render.p?.[branchId]) && (branch.O.m = render.m), singleNode) {
|
|
497
501
|
for (; startVisit.previousSibling && ~visits.indexOf(startVisit = startVisit.previousSibling););
|
|
498
|
-
branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
499
|
-
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
502
|
+
branch._ ??= visitScope, branch.K = branch.S = startVisit, visitType === "'" && (branch.a = startVisit);
|
|
503
|
+
} else curBranchScopes = push(curBranchScopes, branch), accessor && (visitScope[accessor] = curBranchScopes, forEach(curBranchScopes, (scope) => scope._ ??= visitScope), curBranchScopes = branchScopesStack.pop()), startVisit = branchStarts.pop(), parent !== startVisit.parentNode && parent.prepend(startVisit), branch.S = startVisit, branch.K = visit.previousSibling === startVisit ? startVisit : parent.insertBefore(new Text(), visit);
|
|
500
504
|
for (; i && orphanBranches[--i].L > branchId;) setParentBranch(orphanBranches.pop(), branch);
|
|
501
505
|
for (; j && deferredOwners[--j].L > branchId;) {
|
|
502
506
|
let owner = deferredOwners.pop();
|
|
@@ -768,16 +772,11 @@ function _attr_style_item(element, name, value) {
|
|
|
768
772
|
}
|
|
769
773
|
function _style_shell(scope, nodeAccessor) {
|
|
770
774
|
let element = scope[nodeAccessor], id = _id(scope);
|
|
771
|
-
element.className = id, _text_content(element, "." + id + "
|
|
775
|
+
_attr_nonce(scope, nodeAccessor), element.className = id, _text_content(element, "." + id + "~*{}");
|
|
772
776
|
}
|
|
773
777
|
function _style_rule_item(element, name, value) {
|
|
774
778
|
let text = element.textContent, decl = name + ":" + escapeStyleValue(_to_text(value)) + ";", start = text.indexOf("{" + name + ":");
|
|
775
|
-
|
|
776
|
-
else {
|
|
777
|
-
let end = ++start;
|
|
778
|
-
for (let c; (c = text[end]) && c !== ";"; end++) c === "\\" && end++;
|
|
779
|
-
element.textContent = text.slice(0, start) + decl + text.slice(end + 1);
|
|
780
|
-
}
|
|
779
|
+
~start || (start = text.indexOf(";" + name + ":")), _text_content(element, ~start ? text.slice(0, ++start) + decl + text.slice(text.indexOf(";", start) + 1) : text.slice(0, -1) + decl + "}");
|
|
781
780
|
}
|
|
782
781
|
function _attr_nonce(scope, nodeAccessor) {
|
|
783
782
|
_attr(scope[nodeAccessor], "nonce", scope.$.cspNonce);
|
package/dist/html/writer.d.ts
CHANGED
|
@@ -37,10 +37,11 @@ export declare function _id(): string;
|
|
|
37
37
|
export declare function _scope_id(): number;
|
|
38
38
|
export declare function _peek_scope_id(): number;
|
|
39
39
|
export declare function getScopeById(scopeId: number | undefined): ScopeInternals | undefined;
|
|
40
|
-
export
|
|
41
|
-
export declare function
|
|
42
|
-
export declare function
|
|
43
|
-
export declare function
|
|
40
|
+
export type SerializeReasonValue = undefined | number | Partial<Record<string, 0 | 1>>;
|
|
41
|
+
export declare function _set_serialize_reason(reason: SerializeReasonValue): void;
|
|
42
|
+
export declare function _scope_reason(): SerializeReasonValue;
|
|
43
|
+
export declare function _serialize_if(condition: SerializeReasonValue, key: number): 1 | undefined;
|
|
44
|
+
export declare function _serialize_guard(condition: SerializeReasonValue, key: number): 0 | 1;
|
|
44
45
|
export declare function _el_resume(scopeId: number, accessor: Accessor, shouldResume?: 0 | 1): string;
|
|
45
46
|
export declare function _sep(shouldResume: 0 | 1): "" | "<!>";
|
|
46
47
|
export declare function _el(scopeId: number, id: string): () => void;
|
|
@@ -100,7 +101,7 @@ export declare class State implements SerializeState {
|
|
|
100
101
|
flushScopes: boolean;
|
|
101
102
|
writeScopes: Record<number, PartialScope>;
|
|
102
103
|
readyIds: Set<string> | null;
|
|
103
|
-
serializeReason:
|
|
104
|
+
serializeReason: SerializeReasonValue;
|
|
104
105
|
constructor($global: $Global & {
|
|
105
106
|
renderId: string;
|
|
106
107
|
runtimeId: string;
|
package/dist/html.js
CHANGED
|
@@ -376,7 +376,7 @@ function stringifyStyleObject(name, value) {
|
|
|
376
376
|
return value || value === 0 ? name + ":" + value : "";
|
|
377
377
|
}
|
|
378
378
|
function escapeStyleValue(str) {
|
|
379
|
-
let closers = "", result = str.replace(/[\\"'{}
|
|
379
|
+
let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
380
380
|
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
381
381
|
return result + closers;
|
|
382
382
|
}
|
|
@@ -1145,7 +1145,7 @@ function _scope_reason() {
|
|
|
1145
1145
|
return $chunk.boundary.state.serializeReason = void 0, reason;
|
|
1146
1146
|
}
|
|
1147
1147
|
function _serialize_if(condition, key) {
|
|
1148
|
-
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
|
1148
|
+
return condition && (condition === 1 || (typeof condition == "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1149
1149
|
}
|
|
1150
1150
|
function _serialize_guard(condition, key) {
|
|
1151
1151
|
return _serialize_if(condition, key) || 0;
|
|
@@ -1503,7 +1503,7 @@ var State = class {
|
|
|
1503
1503
|
state.needsMainRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
1504
1504
|
}
|
|
1505
1505
|
readyResumeScripts && (needsWalk = !0);
|
|
1506
|
-
let
|
|
1506
|
+
let effects = this.async ? "" : this.effects, { html, scripts } = this;
|
|
1507
1507
|
if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
|
|
1508
1508
|
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
|
|
1509
1509
|
for (let reorderedChunk of state.writeReorders) {
|
|
@@ -1520,7 +1520,7 @@ var State = class {
|
|
|
1520
1520
|
}
|
|
1521
1521
|
state.writeReorders = null;
|
|
1522
1522
|
}
|
|
1523
|
-
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
|
|
1523
|
+
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
|
|
1524
1524
|
}
|
|
1525
1525
|
flushHTML() {
|
|
1526
1526
|
let { boundary } = this, { state } = boundary;
|
|
@@ -1661,7 +1661,7 @@ function _attr_nonce() {
|
|
|
1661
1661
|
}
|
|
1662
1662
|
function _style_html(decls) {
|
|
1663
1663
|
let id = _id();
|
|
1664
|
-
return `<style${_attr_nonce()} class=${id}>.${id}
|
|
1664
|
+
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
1665
1665
|
}
|
|
1666
1666
|
function _attr(name, value) {
|
|
1667
1667
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
package/dist/html.mjs
CHANGED
|
@@ -375,7 +375,7 @@ function stringifyStyleObject(name, value) {
|
|
|
375
375
|
return value || value === 0 ? name + ":" + value : "";
|
|
376
376
|
}
|
|
377
377
|
function escapeStyleValue(str) {
|
|
378
|
-
let closers = "", result = str.replace(/[\\"'{}
|
|
378
|
+
let closers = "", result = str.replace(/[\\"'{};<>]|\/(?=\*)/g, (c) => c === "<" ? "\\3C " : c === ";" ? "\\3B " : c === "{" ? "\\7B " : "\\" + c);
|
|
379
379
|
for (let c of result) c === "(" ? closers = ")" + closers : c === "[" ? closers = "]" + closers : c === closers[0] && (closers = closers.slice(1));
|
|
380
380
|
return result + closers;
|
|
381
381
|
}
|
|
@@ -1144,7 +1144,7 @@ function _scope_reason() {
|
|
|
1144
1144
|
return $chunk.boundary.state.serializeReason = void 0, reason;
|
|
1145
1145
|
}
|
|
1146
1146
|
function _serialize_if(condition, key) {
|
|
1147
|
-
return condition && (condition === 1 || condition[key]) ? 1 : void 0;
|
|
1147
|
+
return condition && (condition === 1 || (typeof condition == "number" ? condition >>> key + 1 & 1 : condition[key])) ? 1 : void 0;
|
|
1148
1148
|
}
|
|
1149
1149
|
function _serialize_guard(condition, key) {
|
|
1150
1150
|
return _serialize_if(condition, key) || 0;
|
|
@@ -1502,7 +1502,7 @@ var State = class {
|
|
|
1502
1502
|
state.needsMainRuntime = !0, readyResumeScripts = concatScripts(readyResumeScripts, state.writeReady(channel.readyId, concatSequence(depsMarker(deps), resumes)));
|
|
1503
1503
|
}
|
|
1504
1504
|
readyResumeScripts && (needsWalk = !0);
|
|
1505
|
-
let
|
|
1505
|
+
let effects = this.async ? "" : this.effects, { html, scripts } = this;
|
|
1506
1506
|
if (state.needsMainRuntime && !state.hasMainRuntime && (state.hasMainRuntime = !0, scripts = concatScripts(scripts, "(e=>(self[e]||=(l,f=e+l,s=f.length,a={},d=[],t=document,n=t.createTreeWalker(t,129))=>t=self[e][l]={i:f,d:t,l:a,v:d,x(){},w(e,l,r){for(;e=n.nextNode();)t.x(l=(l=e.data)&&!l.indexOf(f)&&(a[r=l.slice(s+1)]=e,l[s]),r,e),l>\"#\"&&d.push(e)}},self[e]))(\"" + $global.runtimeId + "\")(\"" + $global.renderId + "\")")), scripts = concatScripts(scripts, readyResumeScripts), effects && (needsWalk = !0, state.resumes = state.resumes ? state.resumes + ",\"" + effects + "\"" : "\"" + effects + "\""), state.resumes && (state.hasWrittenResume ? scripts = concatScripts(scripts, runtimePrefix + ".r.push(" + state.resumes + ")") : (state.hasWrittenResume = !0, scripts = concatScripts(scripts, runtimePrefix + ".r=[" + state.resumes + "]"))), state.writeReorders) {
|
|
1507
1507
|
needsWalk = !0, state.hasReorderRuntime || (state.hasReorderRuntime = !0, scripts = concatScripts(scripts, "(e=>{if(e.j)return;let i,l,r,t=e.p={},c=(i,l)=>e.l[i].replaceWith(...l.childNodes);e.j={},e.x=(n,a,d,o,g)=>{d==r&&i(),\"#\"==n?(t[a]=l).i++:\"!\"==n?e.l[a]&&t[a]&&(r=d.nextSibling,i=()=>t[a].c()):\"T\"==d.tagName&&(a=d.getAttribute(e.i))&&(r=d.nextSibling,i=()=>{d.remove(),o||c(a,d),l.c()},l=t[a]||(o=t[a]={i:e.l[a]?1:2,c(i=e.l[\"^\"+a]){if(--o.i)return 1;for(;(r=e.l[a].previousSibling||i).remove(),i!=r;);c(a,d)}}),(n=e.j[a])&&(g=l.c,l.c=()=>g()||n(e.r)))}})(" + runtimePrefix + ")"));
|
|
1508
1508
|
for (let reorderedChunk of state.writeReorders) {
|
|
@@ -1519,7 +1519,7 @@ var State = class {
|
|
|
1519
1519
|
}
|
|
1520
1520
|
state.writeReorders = null;
|
|
1521
1521
|
}
|
|
1522
|
-
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.effects = this.lastEffect = state.resumes = "", this;
|
|
1522
|
+
return needsWalk && (scripts = concatScripts(scripts, runtimePrefix + ".w()")), this.html = html, this.scripts = scripts, this.async || (this.effects = this.lastEffect = ""), state.resumes = "", this;
|
|
1523
1523
|
}
|
|
1524
1524
|
flushHTML() {
|
|
1525
1525
|
let { boundary } = this, { state } = boundary;
|
|
@@ -1660,7 +1660,7 @@ function _attr_nonce() {
|
|
|
1660
1660
|
}
|
|
1661
1661
|
function _style_html(decls) {
|
|
1662
1662
|
let id = _id();
|
|
1663
|
-
return `<style${_attr_nonce()} class=${id}>.${id}
|
|
1663
|
+
return `<style${_attr_nonce()} class=${id}>.${id}~*{${decls}}</style>`;
|
|
1664
1664
|
}
|
|
1665
1665
|
function _attr(name, value) {
|
|
1666
1666
|
return isVoid(value) ? "" : nonVoidAttr(name, value);
|
package/dist/translator/index.js
CHANGED
|
@@ -1201,6 +1201,12 @@ function addOwnerSerializeReason(from, to, reason) {
|
|
|
1201
1201
|
function isReasonDynamic(reason) {
|
|
1202
1202
|
return !!reason && reason !== true && !reason.state;
|
|
1203
1203
|
}
|
|
1204
|
+
function isStaticSerializeReason(reason) {
|
|
1205
|
+
return !!reason && !isReasonDynamic(reason);
|
|
1206
|
+
}
|
|
1207
|
+
function isStateSerializeReason(reason) {
|
|
1208
|
+
return !!reason && reason !== true && !!reason.state;
|
|
1209
|
+
}
|
|
1204
1210
|
function getSerializeReason(section, prop, prefix) {
|
|
1205
1211
|
if (prop) return section.serializeReasons.get(getPropKey(section, prop, prefix));
|
|
1206
1212
|
else return section.serializeReason;
|
|
@@ -2263,6 +2269,7 @@ const pureDOMFunctions = new Set([
|
|
|
2263
2269
|
"_for_of",
|
|
2264
2270
|
"_for_to",
|
|
2265
2271
|
"_for_until",
|
|
2272
|
+
"_hoist",
|
|
2266
2273
|
"_let",
|
|
2267
2274
|
"_let_change",
|
|
2268
2275
|
"_const",
|
|
@@ -2313,6 +2320,40 @@ function getCompatRuntimeFile() {
|
|
|
2313
2320
|
return `marko/${markoOpts.optimize ? "dist" : "src"}/runtime/helpers/tags-compat/${isOutputHTML() ? "html" : "dom"}${markoOpts.optimize ? "" : "-debug"}.${markoOpts.modules === "esm" ? "mjs" : "js"}`;
|
|
2314
2321
|
}
|
|
2315
2322
|
//#endregion
|
|
2323
|
+
//#region src/translator/util/setup-statements.ts
|
|
2324
|
+
/**
|
|
2325
|
+
* Tracks, during analyze, whether translate will add statements to a
|
|
2326
|
+
* section's setup signal (the signal keyed by no referenced bindings).
|
|
2327
|
+
* Sites that key statements by an expression's resolved references register
|
|
2328
|
+
* the expression with `addSetupExpr`; sites that always target the setup
|
|
2329
|
+
* signal call `addSetupStatement`. Expressions that resolve references
|
|
2330
|
+
* through `mergeReferences` are covered centrally by `finalizeReferences`.
|
|
2331
|
+
*
|
|
2332
|
+
* This lets a template's analyze phase prove its setup export is a noop so
|
|
2333
|
+
* parent templates can skip importing and calling it. The proof is checked
|
|
2334
|
+
* when the template itself is translated (see `visitors/program/dom.ts`).
|
|
2335
|
+
*/
|
|
2336
|
+
const [getSetupInfo] = createSectionState("setupStatements", () => ({
|
|
2337
|
+
forced: false,
|
|
2338
|
+
exprs: /* @__PURE__ */ new Set()
|
|
2339
|
+
}));
|
|
2340
|
+
function addSetupStatement(section) {
|
|
2341
|
+
getSetupInfo(section).forced = true;
|
|
2342
|
+
}
|
|
2343
|
+
function addSetupExpr(section, node) {
|
|
2344
|
+
if (node) getSetupInfo(section).exprs.add(node.extra ??= {});
|
|
2345
|
+
else getSetupInfo(section).forced = true;
|
|
2346
|
+
}
|
|
2347
|
+
function sectionHasSetupStatements(section) {
|
|
2348
|
+
const info = getSetupInfo(section);
|
|
2349
|
+
if (info.forced) return true;
|
|
2350
|
+
for (let extra of info.exprs) {
|
|
2351
|
+
while (extra.merged) extra = extra.merged;
|
|
2352
|
+
if (!extra.pruned && !extra.referencedBindings) return true;
|
|
2353
|
+
}
|
|
2354
|
+
return false;
|
|
2355
|
+
}
|
|
2356
|
+
//#endregion
|
|
2316
2357
|
//#region src/translator/util/binding-has-prop.ts
|
|
2317
2358
|
function bindingHasProperty(binding, properties) {
|
|
2318
2359
|
if (binding.pruned) return false;
|
|
@@ -2753,8 +2794,10 @@ var return_default = {
|
|
|
2753
2794
|
if (!attrs.value) throw tag.get("name").buildCodeFrameError("The [`<return>` tag](https://markojs.com/docs/reference/core-tag#return) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value).");
|
|
2754
2795
|
if (attrs.valueChange) {
|
|
2755
2796
|
(attrs.valueChange.extra ??= {}).isEffect = true;
|
|
2797
|
+
addSetupExpr(section, attrs.valueChange);
|
|
2756
2798
|
addSerializeReason(section, true, getAccessorProp().TagVariableChange);
|
|
2757
2799
|
}
|
|
2800
|
+
addSetupExpr(section, attrs.value);
|
|
2758
2801
|
section.returnValueExpr = attrs.value.extra ??= {};
|
|
2759
2802
|
},
|
|
2760
2803
|
translate: translateByTarget({
|
|
@@ -2990,6 +3033,10 @@ function setClosureSignalBuilder(tag, builder) {
|
|
|
2990
3033
|
_setClosureSignalBuilder(getSectionForBody(tag.get("body")), builder);
|
|
2991
3034
|
}
|
|
2992
3035
|
const [getTryHasPlaceholder, setTryHasPlaceholder] = createSectionState("tryWithPlaceholder");
|
|
3036
|
+
const [getOwnerResumedByMarker, setOwnerResumedByMarker] = createSectionState("ownerResumedByMarker");
|
|
3037
|
+
function setSectionOwnerResumedByMarker(section) {
|
|
3038
|
+
setOwnerResumedByMarker(section, true);
|
|
3039
|
+
}
|
|
2993
3040
|
const [getSerializedAccessors] = createSectionState("serializedScopeProperties", () => /* @__PURE__ */ new Map());
|
|
2994
3041
|
function setSectionSerializedValue(section, prop, expression) {
|
|
2995
3042
|
const reason = getSerializeReason(section, prop);
|
|
@@ -3100,6 +3147,7 @@ function underTryPlaceholder(section) {
|
|
|
3100
3147
|
function initValue(binding, isLet = false) {
|
|
3101
3148
|
const section = binding.section;
|
|
3102
3149
|
const signal = getSignal(section, binding);
|
|
3150
|
+
if (binding.forcePersist) signal.forcePersist = true;
|
|
3103
3151
|
signal.build = () => {
|
|
3104
3152
|
if (isPureMemberForwarder(binding)) return;
|
|
3105
3153
|
const fn = getSignalFn(signal);
|
|
@@ -3472,7 +3520,7 @@ function writeHTMLResumeStatements(path) {
|
|
|
3472
3520
|
const ownerReason = getSerializeReason(section, ownerAccessor);
|
|
3473
3521
|
if (ownerReason) {
|
|
3474
3522
|
serializedLookup.delete(ownerAccessor);
|
|
3475
|
-
serializedProperties.push(toObjectProperty(ownerAccessor, ifSerialized(ownerReason, callRuntime("_scope_with_id", getScopeIdIdentifier(section.parent)))));
|
|
3523
|
+
if (!getOwnerResumedByMarker(section)) serializedProperties.push(toObjectProperty(ownerAccessor, ifSerialized(ownerReason, callRuntime("_scope_with_id", getScopeIdIdentifier(section.parent)))));
|
|
3476
3524
|
}
|
|
3477
3525
|
}
|
|
3478
3526
|
for (const [key, { expression, reason }] of serializedLookup) serializedProperties.push(toObjectProperty(key, ifSerialized(reason, expression)));
|
|
@@ -3717,9 +3765,11 @@ var dom_default = { translate: {
|
|
|
3717
3765
|
if (decls) extraDecls = extraDecls ? [...decls, ...extraDecls] : decls;
|
|
3718
3766
|
}
|
|
3719
3767
|
});
|
|
3720
|
-
writeSignals(section);
|
|
3768
|
+
const written = writeSignals(section);
|
|
3721
3769
|
writeRegisteredFns();
|
|
3722
|
-
|
|
3770
|
+
const setup = getSetup(section);
|
|
3771
|
+
if (domExports.setupEmpty && setup && written.has(setup)) throw program.buildCodeFrameError("Marko internal error: analysis marked this template's setup export as empty but translation produced statements for it. Please open an issue with a reproduction.");
|
|
3772
|
+
if (!setup) program.node.body.unshift(_marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(setupIdentifier, _marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([])))])));
|
|
3723
3773
|
program.node.body.unshift(_marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(templateIdentifier, writes || _marko_compiler.types.stringLiteral(""))])), _marko_compiler.types.exportNamedDeclaration(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(walksIdentifier, walks || _marko_compiler.types.stringLiteral(""))])));
|
|
3724
3774
|
if (extraDecls) program.node.body.unshift(_marko_compiler.types.variableDeclaration("const", extraDecls));
|
|
3725
3775
|
program.node.body.push(_marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(program.hub.file.metadata.marko.id), templateIdentifier, walksIdentifier, setupIdentifier, programInputSignal?.identifier)));
|
|
@@ -3992,6 +4042,7 @@ var for_default = {
|
|
|
3992
4042
|
const singleChild = bodySection.content?.singleChild && bodySection.content.startType !== 4;
|
|
3993
4043
|
const branchSerializeReason = getSerializeReason(bodySection, kBranchSerializeReason);
|
|
3994
4044
|
const markerSerializeReason = getSerializeReason(tagSection, nodeBinding);
|
|
4045
|
+
if (isStateSerializeReason(getSerializeReason(tagSection, kStatefulReason$2)) && isStaticSerializeReason(branchSerializeReason) && isStaticSerializeReason(markerSerializeReason)) setSectionOwnerResumedByMarker(bodySection);
|
|
3995
4046
|
flushInto(tag);
|
|
3996
4047
|
writeHTMLResumeStatements(tagBody);
|
|
3997
4048
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
|
@@ -4484,6 +4535,7 @@ var native_tag_default = {
|
|
|
4484
4535
|
if (isEventOrChangeHandler(attr.name)) assertNativeHandlerAttr(tag, attr);
|
|
4485
4536
|
if (isEventHandler(attr.name)) {
|
|
4486
4537
|
valueExtra.isEffect = true;
|
|
4538
|
+
valueExtra.invokeOnly = true;
|
|
4487
4539
|
hasEventHandlers = true;
|
|
4488
4540
|
} else {
|
|
4489
4541
|
assertValidNativeEventHandlerAttr(tag, attr);
|
|
@@ -4523,6 +4575,7 @@ var native_tag_default = {
|
|
|
4523
4575
|
}
|
|
4524
4576
|
const spreadExtra = mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
4525
4577
|
spreadExtra.nativeTagSpread = true;
|
|
4578
|
+
spreadExtra.invokeOnly = true;
|
|
4526
4579
|
if (isMergedSpread) spreadExtra.nativeTagSpreadMerged = true;
|
|
4527
4580
|
let carveProperties = getSpreadControllableValueProps(tagName);
|
|
4528
4581
|
if (!tag.node.body.body.length && !isTextOnly && !(0, _marko_compiler_babel_utils.getTagDef)(tag)?.parseOptions?.openTagOnly && !seen.content) if (carveProperties) carveProperties.push("content");
|
|
@@ -4538,7 +4591,16 @@ var native_tag_default = {
|
|
|
4538
4591
|
}
|
|
4539
4592
|
} else relatedControllable = getRelatedControllable(tagName, seen);
|
|
4540
4593
|
if (relatedControllable) mergeReferences(tagSection, relatedControllable.attrs.find(Boolean).value, relatedControllable.attrs.map((it) => it?.value));
|
|
4541
|
-
if (textPlaceholders)
|
|
4594
|
+
if (textPlaceholders) {
|
|
4595
|
+
exprExtras = push(exprExtras, textPlaceholders.length === 1 ? textPlaceholders[0].extra ??= {} : mergeReferences(tagSection, textPlaceholders[0], textPlaceholders.slice(1)));
|
|
4596
|
+
addSetupExpr(tagSection, textPlaceholders[0]);
|
|
4597
|
+
}
|
|
4598
|
+
if (injectNonce) addSetupStatement(tagSection);
|
|
4599
|
+
if (relatedControllable?.attrs[1]) addSetupStatement(tagSection);
|
|
4600
|
+
for (const name in seen) {
|
|
4601
|
+
const attr = seen[name];
|
|
4602
|
+
if (isEventHandler(name) || name === "content" || !evaluate(attr.value).confident) addSetupExpr(tagSection, attr.value);
|
|
4603
|
+
}
|
|
4542
4604
|
addSerializeExpr(tagSection, !!(node.var || hasEventHandlers), nodeBinding);
|
|
4543
4605
|
trackDomVarReferences(tag, nodeBinding);
|
|
4544
4606
|
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
@@ -5167,7 +5229,11 @@ const IfTag = {
|
|
|
5167
5229
|
exit(tag) {
|
|
5168
5230
|
if (tag.node.body.attributeTags) return;
|
|
5169
5231
|
const tagBody = tag.get("body");
|
|
5170
|
-
|
|
5232
|
+
const bodySection = getSectionForBody(tagBody);
|
|
5233
|
+
if (bodySection) {
|
|
5234
|
+
const [[ifTag]] = getBranches(tag);
|
|
5235
|
+
const ifTagSection = getSection(ifTag);
|
|
5236
|
+
if (isStateSerializeReason(getSerializeReason(ifTagSection, kStatefulReason$1)) && isStaticSerializeReason(getSerializeReason(bodySection, kBranchSerializeReason)) && isStaticSerializeReason(getSerializeReason(ifTagSection, getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection)))) setSectionOwnerResumedByMarker(bodySection);
|
|
5171
5237
|
flushInto(tag);
|
|
5172
5238
|
writeHTMLResumeStatements(tagBody);
|
|
5173
5239
|
}
|
|
@@ -5669,6 +5735,8 @@ var program_default = {
|
|
|
5669
5735
|
const programExtra = program.node.extra;
|
|
5670
5736
|
const paramsBinding = programExtra.binding;
|
|
5671
5737
|
if (paramsBinding && !paramsBinding.pruned) programExtra.domExports.params = getBindingPropTree(paramsBinding);
|
|
5738
|
+
const section = programExtra.section;
|
|
5739
|
+
if (!section.hoistedTo && !sectionHasSetupStatements(section)) programExtra.domExports.setupEmpty = true;
|
|
5672
5740
|
}
|
|
5673
5741
|
},
|
|
5674
5742
|
translate: {
|
|
@@ -5843,6 +5911,7 @@ function knownTagAnalyze(tag, contentSection, propTree) {
|
|
|
5843
5911
|
const varBinding = trackVarReferences(tag, 5);
|
|
5844
5912
|
const exprs = tagExtra[kKnownExprs] = analyzeParams(tagExtra, section, tag, propTree, attrExprs);
|
|
5845
5913
|
if (varBinding) {
|
|
5914
|
+
addSetupStatement(section);
|
|
5846
5915
|
const mutatesTagVar = !!(tag.node.var.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
|
5847
5916
|
const varExpr = tagExtra.defineBodySection ? contentSection.returnValueExpr : mapParamReasonToExpr(exprs, contentSection.returnSerializeReason && (contentSection.returnSerializeReason === true || !!contentSection.returnSerializeReason.state || contentSection.returnSerializeReason.param));
|
|
5848
5917
|
varBinding.scopeOffset = tagExtra[kChildOffsetScopeBinding$1] = createBinding("#scopeOffset", 0, section);
|
|
@@ -5879,6 +5948,8 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
5879
5948
|
childSerializeReasonExpr = reason && getSerializeGuard(section, reason, false);
|
|
5880
5949
|
} else {
|
|
5881
5950
|
const props = [];
|
|
5951
|
+
let bitmask = 0;
|
|
5952
|
+
let bitmaskNames = "";
|
|
5882
5953
|
let hasDynamicReasons = false;
|
|
5883
5954
|
let hasSkippedReasons = false;
|
|
5884
5955
|
for (let i = 0; i < contentSection.paramReasonGroups.length; i++) {
|
|
@@ -5886,10 +5957,16 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
5886
5957
|
const reason = getSerializeReason(section, childScopeBinding, group.id);
|
|
5887
5958
|
if (reason) {
|
|
5888
5959
|
hasDynamicReasons ||= reason !== true && !reason.state;
|
|
5889
|
-
|
|
5960
|
+
const guard = getSerializeGuard(section, reason, false);
|
|
5961
|
+
if (bitmask >= 0) if (guard.type === "NumericLiteral" && guard.value === 1 && i < 30) {
|
|
5962
|
+
bitmask |= 1 << i + 1;
|
|
5963
|
+
const names = getDebugNames(group.reason);
|
|
5964
|
+
if (names) bitmaskNames += bitmaskNames ? ` | ${names}` : names;
|
|
5965
|
+
} else bitmask = -1;
|
|
5966
|
+
props.push(_marko_compiler.types.objectProperty(withLeadingComment(_marko_compiler.types.numericLiteral(i), getDebugNames(group.reason)), guard));
|
|
5890
5967
|
} else hasSkippedReasons = true;
|
|
5891
5968
|
}
|
|
5892
|
-
if (props.length) childSerializeReasonExpr = hasDynamicReasons || hasSkippedReasons ? _marko_compiler.types.
|
|
5969
|
+
if (props.length) childSerializeReasonExpr = !(hasDynamicReasons || hasSkippedReasons) ? _marko_compiler.types.numericLiteral(1) : bitmask > 0 ? withLeadingComment(_marko_compiler.types.numericLiteral(bitmask), bitmaskNames) : _marko_compiler.types.objectExpression(props);
|
|
5893
5970
|
}
|
|
5894
5971
|
if (childSerializeReasonExpr) tag.insertBefore(_marko_compiler.types.expressionStatement(callRuntime("_set_serialize_reason", childSerializeReasonExpr)));
|
|
5895
5972
|
}
|
|
@@ -5918,7 +5995,7 @@ function knownTagTranslateDOM(tag, propTree, getBindingIdentifier, callSetup) {
|
|
|
5918
5995
|
};
|
|
5919
5996
|
addStatement("render", tagSection, void 0, _marko_compiler.types.expressionStatement(callRuntime("_var", scopeIdentifier, getScopeAccessorLiteral(childScopeBinding, true), source.identifier)));
|
|
5920
5997
|
}
|
|
5921
|
-
callSetup(tagSection, childScopeBinding);
|
|
5998
|
+
callSetup?.(tagSection, childScopeBinding);
|
|
5922
5999
|
if (propTree) writeParamsToSignals(tag, propTree, getTagName(tag) || "tag", {
|
|
5923
6000
|
tagSection,
|
|
5924
6001
|
getBindingIdentifier,
|
|
@@ -5955,6 +6032,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
5955
6032
|
const argValueExtra = arg.extra ??= {};
|
|
5956
6033
|
known[i++] = { value: argValueExtra };
|
|
5957
6034
|
rootAttrExprs.add(argValueExtra);
|
|
6035
|
+
addSetupExpr(section, arg);
|
|
5958
6036
|
}
|
|
5959
6037
|
const attrPropsTree = propTree.props[i];
|
|
5960
6038
|
if (attrPropsTree) known[i] = analyzeAttrs(rootTagExtra, section, tag, attrPropsTree, rootAttrExprs);
|
|
@@ -6055,6 +6133,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6055
6133
|
else {
|
|
6056
6134
|
remaining.delete("content");
|
|
6057
6135
|
known.content = { value: void 0 };
|
|
6136
|
+
addSetupStatement(section);
|
|
6058
6137
|
}
|
|
6059
6138
|
}
|
|
6060
6139
|
}
|
|
@@ -6079,7 +6158,9 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6079
6158
|
remaining.delete(attr.name);
|
|
6080
6159
|
known[attr.name] = { value: attrExtra };
|
|
6081
6160
|
rootAttrExprs.add(attrExtra);
|
|
6161
|
+
addSetupExpr(section, attr.value);
|
|
6082
6162
|
setBindingDownstream(templateExportAttr.binding, attrExtra);
|
|
6163
|
+
if (getRootSection(templateExportAttr.binding.section) !== (0, _marko_compiler_babel_utils.getProgram)().node.extra.section && isInvokeOnlyBinding(templateExportAttr.binding)) attrExtra.invokeOnly = true;
|
|
6083
6164
|
if (knownSpread && !includes(knownSpread.binding.excludeProperties, attr.name)) addRead(attrExtra, {}, getOrCreatePropertyAlias(knownSpread.binding, attr.name), section, void 0);
|
|
6084
6165
|
}
|
|
6085
6166
|
} else if (spreadReferenceNodes) spreadReferenceNodes.push(attr.value);
|
|
@@ -6102,9 +6183,13 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
6102
6183
|
inputExpr.value = mergeReferences(section, tag.node, spreadReferenceNodes);
|
|
6103
6184
|
setBindingDownstream(propTree.rest?.binding || propTree.binding, inputExpr.value);
|
|
6104
6185
|
} else dropNodes(spreadReferenceNodes);
|
|
6105
|
-
else
|
|
6106
|
-
|
|
6107
|
-
|
|
6186
|
+
else {
|
|
6187
|
+
if (restReferenceNodes) {
|
|
6188
|
+
inputExpr.value = mergeReferences(section, tag.node, restReferenceNodes);
|
|
6189
|
+
setBindingDownstream(propTree.rest.binding, inputExpr.value);
|
|
6190
|
+
}
|
|
6191
|
+
if (remaining.size) addSetupStatement(section);
|
|
6192
|
+
if (propTree.rest && !propTree.rest.props) addSetupExpr(section, tag.node);
|
|
6108
6193
|
}
|
|
6109
6194
|
dropNodes(dropReferenceNodes);
|
|
6110
6195
|
return inputExpr;
|
|
@@ -6387,6 +6472,10 @@ function isSimpleReference(expr) {
|
|
|
6387
6472
|
default: return false;
|
|
6388
6473
|
}
|
|
6389
6474
|
}
|
|
6475
|
+
function getRootSection(section) {
|
|
6476
|
+
while (section.parent) section = section.parent;
|
|
6477
|
+
return section;
|
|
6478
|
+
}
|
|
6390
6479
|
//#endregion
|
|
6391
6480
|
//#region src/translator/util/references.ts
|
|
6392
6481
|
const kBranchSerializeReason = Symbol("branch serialize reason");
|
|
@@ -6425,7 +6514,8 @@ function createBinding(name, type, refSection, upstreamAlias, property, excludeP
|
|
|
6425
6514
|
directContentExport: void 0,
|
|
6426
6515
|
nullable: !sameSection || excludeProperties === void 0,
|
|
6427
6516
|
pruned: void 0,
|
|
6428
|
-
exposed: false
|
|
6517
|
+
exposed: false,
|
|
6518
|
+
forcePersist: false
|
|
6429
6519
|
};
|
|
6430
6520
|
if (property) {
|
|
6431
6521
|
if (declared) upstreamAlias.nullable = false;
|
|
@@ -6654,6 +6744,7 @@ function mergeReferences(section, target, nodes) {
|
|
|
6654
6744
|
for (const node of nodes) {
|
|
6655
6745
|
if (!node) continue;
|
|
6656
6746
|
const extra = node.extra ??= {};
|
|
6747
|
+
if (extra === targetExtra) continue;
|
|
6657
6748
|
extra.merged = targetExtra;
|
|
6658
6749
|
if (isReferencedExtra(extra)) {
|
|
6659
6750
|
const additionalReads = readsByExpression.get(extra);
|
|
@@ -6701,6 +6792,11 @@ function finalizeReferences() {
|
|
|
6701
6792
|
for (const [expr, reads] of readsByExpression) if (isReferencedExtra(expr)) {
|
|
6702
6793
|
const exprBindings = resolveReferencedBindings(expr, reads, intersectionsBySection);
|
|
6703
6794
|
expr.referencedBindings = exprBindings.referencedBindings;
|
|
6795
|
+
expr.lazyBindings = exprBindings.lazyBindings;
|
|
6796
|
+
if (!exprBindings.referencedBindings) addSetupStatement(expr.section);
|
|
6797
|
+
forEach(exprBindings.lazyBindings, (binding) => {
|
|
6798
|
+
binding.forcePersist = true;
|
|
6799
|
+
});
|
|
6704
6800
|
if (exprBindings.hoistedBindings) expr.section.referencedHoists = bindingUtil.union(expr.section.referencedHoists, exprBindings.hoistedBindings);
|
|
6705
6801
|
if (expr.isEffect) {
|
|
6706
6802
|
forEach(exprBindings.referencedBindings, (binding) => {
|
|
@@ -6709,12 +6805,15 @@ function finalizeReferences() {
|
|
|
6709
6805
|
forEach(exprBindings.constantBindings, (binding) => {
|
|
6710
6806
|
addSerializeReason(binding.section, true, binding);
|
|
6711
6807
|
});
|
|
6808
|
+
forEach(exprBindings.lazyBindings, (binding) => {
|
|
6809
|
+
addSerializeReason(binding.section, true, binding);
|
|
6810
|
+
});
|
|
6712
6811
|
}
|
|
6713
6812
|
if (exprBindings.allBindings) {
|
|
6714
6813
|
const exprFnReads = fnReadsByExpression.get(expr);
|
|
6715
6814
|
if (exprFnReads) for (const [fn, fnReads] of exprFnReads) {
|
|
6716
6815
|
const fnBindings = fn === expr ? exprBindings : resolveReferencedBindingsInFunction(exprBindings.allBindings, fnReads);
|
|
6717
|
-
fn.referencedBindingsInFunction = fnBindings.referencedBindings;
|
|
6816
|
+
fn.referencedBindingsInFunction = fn === expr ? bindingUtil.union(fnBindings.referencedBindings, exprBindings.lazyBindings) : fnBindings.referencedBindings;
|
|
6718
6817
|
fn.constantBindingsInFunction = fnBindings.constantBindings;
|
|
6719
6818
|
}
|
|
6720
6819
|
}
|
|
@@ -6762,14 +6861,19 @@ function finalizeReferences() {
|
|
|
6762
6861
|
}
|
|
6763
6862
|
}
|
|
6764
6863
|
section.bindings = bindingUtil.add(section.bindings, getCanonicalBinding(binding));
|
|
6765
|
-
for (const
|
|
6766
|
-
|
|
6767
|
-
|
|
6768
|
-
|
|
6769
|
-
|
|
6770
|
-
|
|
6771
|
-
|
|
6772
|
-
|
|
6864
|
+
for (const exprExtra of binding.reads) {
|
|
6865
|
+
const { isEffect, section } = exprExtra;
|
|
6866
|
+
if (section.depth > binding.section.depth) {
|
|
6867
|
+
if (binding.type === 4) section.referencedLocalClosures = bindingUtil.add(section.referencedLocalClosures, binding);
|
|
6868
|
+
else if (binding.type !== 0) {
|
|
6869
|
+
const canonicalUpstreamAlias = getCanonicalBinding(binding);
|
|
6870
|
+
if (!bindingUtil.has(exprExtra.lazyBindings, binding)) {
|
|
6871
|
+
canonicalUpstreamAlias.closureSections = sectionUtil.add(canonicalUpstreamAlias.closureSections, section);
|
|
6872
|
+
section.referencedClosures = bindingUtil.add(section.referencedClosures, canonicalUpstreamAlias);
|
|
6873
|
+
}
|
|
6874
|
+
setReadsOwner(section, canonicalUpstreamAlias.section);
|
|
6875
|
+
addOwnerSerializeReason(section, canonicalUpstreamAlias.section, !!isEffect || canonicalUpstreamAlias.sources);
|
|
6876
|
+
}
|
|
6773
6877
|
}
|
|
6774
6878
|
}
|
|
6775
6879
|
}
|
|
@@ -7048,7 +7152,8 @@ function addRead(exprExtra, extra, binding, section, getter) {
|
|
|
7048
7152
|
extra,
|
|
7049
7153
|
getter,
|
|
7050
7154
|
ownVar: false,
|
|
7051
|
-
comparedTo: void 0
|
|
7155
|
+
comparedTo: void 0,
|
|
7156
|
+
deferred: false
|
|
7052
7157
|
};
|
|
7053
7158
|
binding.reads.add(exprExtra);
|
|
7054
7159
|
exprExtra.section = section;
|
|
@@ -7086,6 +7191,7 @@ function addReadToExpression(root, binding, getter) {
|
|
|
7086
7191
|
}
|
|
7087
7192
|
if (root.parent.type === "MarkoSpreadAttribute") exprExtra.spreadFrom = binding;
|
|
7088
7193
|
if (fnRoot) {
|
|
7194
|
+
read.deferred = fnRoot.node.type !== "ObjectMethod" || fnRoot.node.kind === "method";
|
|
7089
7195
|
const fnReadsByExpr = getFunctionReadsByExpression();
|
|
7090
7196
|
let exprFnReads = fnReadsByExpr.get(exprExtra);
|
|
7091
7197
|
if (!exprFnReads) fnReadsByExpr.set(exprExtra, exprFnReads = /* @__PURE__ */ new Map());
|
|
@@ -7230,6 +7336,12 @@ function getReadReplacement(node, signal) {
|
|
|
7230
7336
|
return replacement && withPreviousLocation(replacement, node);
|
|
7231
7337
|
} else if (binding && node.type == "Identifier" && node.name !== binding.name) node.name = binding.name;
|
|
7232
7338
|
}
|
|
7339
|
+
function isInvokeOnlyBinding(binding) {
|
|
7340
|
+
if (binding.assignmentSections || binding.hoists || binding.getters.size || binding.propertyAliases.size || binding.excludeProperties) return false;
|
|
7341
|
+
for (const expr of binding.reads) if (!expr.invokeOnly) return false;
|
|
7342
|
+
for (const alias of binding.aliases) if (!isInvokeOnlyBinding(alias)) return false;
|
|
7343
|
+
return true;
|
|
7344
|
+
}
|
|
7233
7345
|
function hasNonConstantPropertyAlias(ref) {
|
|
7234
7346
|
for (const alias of ref.propertyAliases.values()) if (alias.type !== 6) return true;
|
|
7235
7347
|
return false;
|
|
@@ -7307,11 +7419,15 @@ function addBindingGetter(binding, { invoked, hoisted }) {
|
|
|
7307
7419
|
if (hoisted || !binding.getters.has(binding.section)) binding.getters.set(hoisted, !invoked);
|
|
7308
7420
|
}
|
|
7309
7421
|
}
|
|
7422
|
+
function isLazyRead(expr, read, binding, isChangeHandlerRead) {
|
|
7423
|
+
return !!(expr.invokeOnly && read.deferred && !isChangeHandlerRead && !binding.upstreamAlias && binding.type !== 0 && binding.type !== 6 && (binding.type !== 4 || binding.section === expr.section));
|
|
7424
|
+
}
|
|
7310
7425
|
function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
7311
7426
|
let referencedBindings;
|
|
7312
7427
|
let constantBindings;
|
|
7313
7428
|
let hoistedBindings;
|
|
7314
7429
|
let allBindings;
|
|
7430
|
+
let lazyBindings;
|
|
7315
7431
|
if (Array.isArray(reads)) {
|
|
7316
7432
|
const rootBindings = getRootBindings(reads);
|
|
7317
7433
|
for (const read of reads) {
|
|
@@ -7326,14 +7442,16 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
|
7326
7442
|
hoistedBindings = bindingUtil.add(hoistedBindings, binding);
|
|
7327
7443
|
}
|
|
7328
7444
|
} else {
|
|
7329
|
-
|
|
7445
|
+
const isChangeHandlerRead = extra.assignmentTo === binding;
|
|
7446
|
+
if (isChangeHandlerRead) {
|
|
7330
7447
|
const upstreamRoot = binding.upstreamAlias && findClosestReference(binding.upstreamAlias, rootBindings);
|
|
7331
7448
|
if (upstreamRoot) binding = upstreamRoot;
|
|
7332
7449
|
} else {
|
|
7333
7450
|
extra.section = expr.section;
|
|
7334
7451
|
({binding} = extra.read ??= resolveExpressionReference(rootBindings, binding));
|
|
7335
7452
|
}
|
|
7336
|
-
if (binding
|
|
7453
|
+
if (isLazyRead(expr, read, binding, isChangeHandlerRead)) lazyBindings = bindingUtil.add(lazyBindings, binding);
|
|
7454
|
+
else if (binding.type === 6) constantBindings = bindingUtil.add(constantBindings, binding);
|
|
7337
7455
|
else if (binding.type !== 0) referencedBindings = bindingUtil.add(referencedBindings, binding);
|
|
7338
7456
|
}
|
|
7339
7457
|
allBindings = bindingUtil.add(allBindings, binding);
|
|
@@ -7349,12 +7467,20 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
|
7349
7467
|
}
|
|
7350
7468
|
} else {
|
|
7351
7469
|
extra.read = createRead(binding, void 0, ownVar);
|
|
7352
|
-
if (binding.
|
|
7470
|
+
if (isLazyRead(expr, reads, binding, extra.assignmentTo === binding)) lazyBindings = binding;
|
|
7471
|
+
else if (binding.type === 6) constantBindings = binding;
|
|
7353
7472
|
else if (binding.type !== 0) referencedBindings = binding;
|
|
7354
7473
|
}
|
|
7355
7474
|
extra.section = expr.section;
|
|
7356
7475
|
allBindings = binding;
|
|
7357
7476
|
}
|
|
7477
|
+
if (lazyBindings) {
|
|
7478
|
+
let onlyLazy;
|
|
7479
|
+
forEach(lazyBindings, (binding) => {
|
|
7480
|
+
if (!bindingUtil.has(referencedBindings, binding)) onlyLazy = bindingUtil.add(onlyLazy, binding);
|
|
7481
|
+
});
|
|
7482
|
+
lazyBindings = onlyLazy;
|
|
7483
|
+
}
|
|
7358
7484
|
if (Array.isArray(referencedBindings)) {
|
|
7359
7485
|
const intersections = intersectionsBySection.get(expr.section) || [];
|
|
7360
7486
|
const intersection = findSorted(compareIntersections, intersections, referencedBindings);
|
|
@@ -7370,7 +7496,8 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
|
7370
7496
|
referencedBindings,
|
|
7371
7497
|
constantBindings,
|
|
7372
7498
|
hoistedBindings,
|
|
7373
|
-
allBindings
|
|
7499
|
+
allBindings,
|
|
7500
|
+
lazyBindings
|
|
7374
7501
|
};
|
|
7375
7502
|
}
|
|
7376
7503
|
function resolveExpressionReference(rootBindings, readBinding) {
|
|
@@ -7535,6 +7662,7 @@ var await_default = {
|
|
|
7535
7662
|
const paramsBinding = trackParamsReferences(tagBody, 5);
|
|
7536
7663
|
if (paramsBinding) setBindingDownstream(paramsBinding, valueExtra);
|
|
7537
7664
|
bodySection.upstreamExpression = valueAttr.value.extra;
|
|
7665
|
+
addSetupStatement(section);
|
|
7538
7666
|
},
|
|
7539
7667
|
translate: translateByTarget({
|
|
7540
7668
|
html: {
|
|
@@ -7642,7 +7770,10 @@ var const_default = {
|
|
|
7642
7770
|
}
|
|
7643
7771
|
}
|
|
7644
7772
|
if (!valueExtra.nullable) binding.nullable = false;
|
|
7645
|
-
if (!upstreamAlias)
|
|
7773
|
+
if (!upstreamAlias) {
|
|
7774
|
+
setBindingDownstream(binding, valueExtra);
|
|
7775
|
+
addSetupExpr(getOrCreateSection(tag), valueAttr.value);
|
|
7776
|
+
}
|
|
7646
7777
|
}
|
|
7647
7778
|
},
|
|
7648
7779
|
translate: { exit(tag) {
|
|
@@ -7677,6 +7808,7 @@ var debug_default = {
|
|
|
7677
7808
|
(0, _marko_compiler_babel_utils.assertNoParams)(tag);
|
|
7678
7809
|
assertNoBodyContent(tag);
|
|
7679
7810
|
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!_marko_compiler.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) throw tag.get("name").buildCodeFrameError("The [`<debug>` tag](https://markojs.com/docs/reference/core-tag#debug) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value).");
|
|
7811
|
+
addSetupExpr(getOrCreateSection(tag), valueAttr?.value);
|
|
7680
7812
|
},
|
|
7681
7813
|
translate: { exit(tag) {
|
|
7682
7814
|
const section = getSection(tag);
|
|
@@ -7926,6 +8058,7 @@ var id_default = {
|
|
|
7926
8058
|
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!_marko_compiler.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) throw tag.get("name").buildCodeFrameError("The [`<id>` tag](https://markojs.com/docs/reference/core-tag#id) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value).");
|
|
7927
8059
|
const binding = trackVarReferences(tag, 5);
|
|
7928
8060
|
if (binding) setBindingDownstream(binding, !!valueAttr && evaluate(valueAttr.value));
|
|
8061
|
+
addSetupExpr(getOrCreateSection(tag), valueAttr?.value);
|
|
7929
8062
|
},
|
|
7930
8063
|
translate: { exit(tag) {
|
|
7931
8064
|
const { node } = tag;
|
|
@@ -8002,7 +8135,7 @@ var let_default = {
|
|
|
8002
8135
|
const tagExtra = mergeReferences(tagSection, tag.node, [valueAttr?.value, valueChangeAttr?.value]);
|
|
8003
8136
|
if (valueChangeAttr) {
|
|
8004
8137
|
setBindingDownstream(binding, tagExtra);
|
|
8005
|
-
addSerializeReason(tagSection, true, binding, getAccessorPrefix().TagVariableChange);
|
|
8138
|
+
if (binding.assignmentSections) addSerializeReason(tagSection, true, binding, getAccessorPrefix().TagVariableChange);
|
|
8006
8139
|
} else setBindingDownstream(binding, false);
|
|
8007
8140
|
},
|
|
8008
8141
|
translate: { exit(tag) {
|
|
@@ -8084,6 +8217,7 @@ var log_default = {
|
|
|
8084
8217
|
assertNoBodyContent(tag);
|
|
8085
8218
|
if (!valueAttr) throw tag.get("name").buildCodeFrameError("The [`<log>` tag](https://markojs.com/docs/reference/core-tag#log) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value).");
|
|
8086
8219
|
if (tag.node.attributes.length > 1 || !_marko_compiler.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") throw tag.get("name").buildCodeFrameError("The [`<log>` tag](https://markojs.com/docs/reference/core-tag#log) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value).");
|
|
8220
|
+
addSetupExpr(getOrCreateSection(tag), valueAttr.value);
|
|
8087
8221
|
},
|
|
8088
8222
|
translate: { exit(tag) {
|
|
8089
8223
|
const section = getSection(tag);
|
|
@@ -8138,6 +8272,7 @@ var script_default = {
|
|
|
8138
8272
|
if (seenValueAttr) throw tag.hub.buildError(attr, "Invalid duplicate value attribute.");
|
|
8139
8273
|
seenValueAttr = true;
|
|
8140
8274
|
(attr.value.extra ??= {}).isEffect = true;
|
|
8275
|
+
addSetupExpr(getOrCreateSection(tag), attr.value);
|
|
8141
8276
|
(0, _marko_compiler_babel_utils.getProgram)().node.extra.isInteractive = true;
|
|
8142
8277
|
} else throw tag.hub.buildError(attr, "The [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) does not support html attributes." + htmlScriptTagAlternateMsg);
|
|
8143
8278
|
if (!seenValueAttr) dropNodes(getAllTagReferenceNodes(node));
|
|
@@ -8238,7 +8373,7 @@ var show_default = {
|
|
|
8238
8373
|
if (tagExtra[kStaticDisplay] === void 0) {
|
|
8239
8374
|
mergeReferences(tagSection, tag.node, [display]);
|
|
8240
8375
|
addSerializeExpr(tagSection, tagExtra, kStatefulReason);
|
|
8241
|
-
}
|
|
8376
|
+
} else addSetupStatement(tagSection);
|
|
8242
8377
|
},
|
|
8243
8378
|
exit(tag) {
|
|
8244
8379
|
const tagExtra = tag.node.extra;
|
|
@@ -8492,7 +8627,10 @@ var style_default = {
|
|
|
8492
8627
|
const importPath = getStyleImportPath(file, node, names);
|
|
8493
8628
|
(node.extra ??= {}).styleImportPath = importPath;
|
|
8494
8629
|
if (importPath) addAssetImport(file, importPath);
|
|
8495
|
-
if (names)
|
|
8630
|
+
if (names) {
|
|
8631
|
+
analyzeDynamicStyle(tag, names);
|
|
8632
|
+
addSetupStatement(getOrCreateSection(tag));
|
|
8633
|
+
}
|
|
8496
8634
|
},
|
|
8497
8635
|
translate: translateByTarget({
|
|
8498
8636
|
html: { exit: translateHTML$1 },
|
|
@@ -8585,7 +8723,7 @@ function translateDOM$1(tag) {
|
|
|
8585
8723
|
const readEl = () => createScopeReadExpression(binding);
|
|
8586
8724
|
visit(tag, 32);
|
|
8587
8725
|
write`<style>`;
|
|
8588
|
-
addStatement("render", section, void 0,
|
|
8726
|
+
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(callRuntime("_style_shell", scopeIdentifier, getScopeAccessorLiteral(binding))), void 0, true);
|
|
8589
8727
|
dynamicStyleValues(node).forEach((value, i) => {
|
|
8590
8728
|
const valueRef = value.extra?.referencedBindings;
|
|
8591
8729
|
addStatement("render", section, valueRef, _marko_compiler.types.expressionStatement(callRuntime("_style_rule_item", readEl(), _marko_compiler.types.stringLiteral(names[i]), value)), void 0, !valueRef);
|
|
@@ -8949,6 +9087,7 @@ var placeholder_default = {
|
|
|
8949
9087
|
const section = getOrCreateSection(placeholder);
|
|
8950
9088
|
const nodeBinding = (node.extra ??= {})[kNodeBinding] = createBinding("#text", 0, section);
|
|
8951
9089
|
analyzeSiblingText(placeholder);
|
|
9090
|
+
addSetupExpr(section, node.value);
|
|
8952
9091
|
addSerializeExpr(section, valueExtra, nodeBinding);
|
|
8953
9092
|
}
|
|
8954
9093
|
},
|
|
@@ -9014,23 +9153,49 @@ function buildEscapedTextExpression(value) {
|
|
|
9014
9153
|
function analyzeSiblingText(placeholder) {
|
|
9015
9154
|
const placeholderExtra = placeholder.node.extra;
|
|
9016
9155
|
let prev = placeholder.getPrevSibling();
|
|
9017
|
-
|
|
9156
|
+
let prevParent = placeholder.parentPath;
|
|
9157
|
+
for (;;) {
|
|
9158
|
+
if (!prev.node) {
|
|
9159
|
+
const showTag = getInlinedBodyTag(prevParent);
|
|
9160
|
+
if (showTag) {
|
|
9161
|
+
prev = showTag.getPrevSibling();
|
|
9162
|
+
prevParent = showTag.parentPath;
|
|
9163
|
+
continue;
|
|
9164
|
+
}
|
|
9165
|
+
break;
|
|
9166
|
+
}
|
|
9018
9167
|
const contentType = getNodeContentType(prev, "endType");
|
|
9019
9168
|
if (contentType === null) prev = prev.getPrevSibling();
|
|
9020
9169
|
else if (contentType === 4 || contentType === 1 || contentType === 2) return placeholderExtra[kSiblingText] = 1;
|
|
9021
9170
|
else break;
|
|
9022
9171
|
}
|
|
9023
|
-
if (!prev.node &&
|
|
9172
|
+
if (!prev.node && prevParent.isProgram()) return placeholderExtra[kSiblingText] = 1;
|
|
9024
9173
|
let next = placeholder.getNextSibling();
|
|
9025
|
-
|
|
9174
|
+
let nextParent = placeholder.parentPath;
|
|
9175
|
+
for (;;) {
|
|
9176
|
+
if (!next.node) {
|
|
9177
|
+
const showTag = getInlinedBodyTag(nextParent);
|
|
9178
|
+
if (showTag) {
|
|
9179
|
+
next = showTag.getNextSibling();
|
|
9180
|
+
nextParent = showTag.parentPath;
|
|
9181
|
+
continue;
|
|
9182
|
+
}
|
|
9183
|
+
break;
|
|
9184
|
+
}
|
|
9026
9185
|
const contentType = getNodeContentType(next, "startType");
|
|
9027
9186
|
if (contentType === null) next = next.getNextSibling();
|
|
9028
9187
|
else if (contentType === 4 || contentType === 1 || contentType === 2) return placeholderExtra[kSiblingText] = 2;
|
|
9029
9188
|
else break;
|
|
9030
9189
|
}
|
|
9031
|
-
if (!next.node &&
|
|
9190
|
+
if (!next.node && nextParent.isProgram()) return placeholderExtra[kSiblingText] = 2;
|
|
9032
9191
|
return placeholderExtra[kSiblingText] = 0;
|
|
9033
9192
|
}
|
|
9193
|
+
function getInlinedBodyTag(parent) {
|
|
9194
|
+
if (parent.isMarkoTagBody()) {
|
|
9195
|
+
const tag = parent.parentPath;
|
|
9196
|
+
if (tag.isMarkoTag() && isCoreTagName(tag, "show")) return tag;
|
|
9197
|
+
}
|
|
9198
|
+
}
|
|
9034
9199
|
function isStaticText(node) {
|
|
9035
9200
|
switch (node?.type) {
|
|
9036
9201
|
case "MarkoText": return true;
|
|
@@ -9177,6 +9342,7 @@ var custom_tag_default = {
|
|
|
9177
9342
|
const childSection = childExtra.section;
|
|
9178
9343
|
if (childExtra.page) programExtra.page ??= true;
|
|
9179
9344
|
if (tagExtra.tagNameLoad) tagExtra[kLoadTagBinding] = createBinding("#text", 0, getOrCreateSection(tag));
|
|
9345
|
+
if (tagExtra.tagNameLoad || !childExtra.domExports?.setupEmpty) addSetupStatement(getOrCreateSection(tag));
|
|
9180
9346
|
knownTagAnalyze(tag, childSection, programSection === childSection ? programSection.params && getBindingPropTree(programSection.params) : childExtra.domExports?.params);
|
|
9181
9347
|
} },
|
|
9182
9348
|
translate: {
|
|
@@ -9245,13 +9411,13 @@ function translateDOM(tag) {
|
|
|
9245
9411
|
injectWalks(tag, tagName);
|
|
9246
9412
|
enterShallow(tag);
|
|
9247
9413
|
} else if (programSection === childSection) {
|
|
9248
|
-
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName) => getSignal(programSection, binding, preferredName).identifier, (section, childBinding) => {
|
|
9414
|
+
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName) => getSignal(programSection, binding, preferredName).identifier, childExports.setupEmpty ? void 0 : (section, childBinding) => {
|
|
9249
9415
|
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(_marko_compiler.types.identifier(childExports.setup), [createScopeReadExpression(childBinding, section)])));
|
|
9250
9416
|
});
|
|
9251
9417
|
write`${_marko_compiler.types.identifier(childExports.template)}`;
|
|
9252
9418
|
injectWalks(tag, tagName, _marko_compiler.types.identifier(childExports.walks));
|
|
9253
9419
|
} else {
|
|
9254
|
-
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName, directContent) => importOrSelfReferenceName(tag.hub.file, relativePath, directContent && binding.directContentExport || binding.export, preferredName), (section, childBinding) => {
|
|
9420
|
+
knownTagTranslateDOM(tag, childExports.params, (binding, preferredName, directContent) => importOrSelfReferenceName(tag.hub.file, relativePath, directContent && binding.directContentExport || binding.export, preferredName), childExports.setupEmpty ? void 0 : (section, childBinding) => {
|
|
9255
9421
|
addStatement("render", section, void 0, _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(importOrSelfReferenceName(file, relativePath, childExports.setup, tagName), [createScopeReadExpression(childBinding, section)])));
|
|
9256
9422
|
});
|
|
9257
9423
|
write`${(0, _marko_compiler_babel_utils.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
@@ -9325,6 +9491,7 @@ var dynamic_tag_default = {
|
|
|
9325
9491
|
analyze: { enter(tag) {
|
|
9326
9492
|
(0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
|
|
9327
9493
|
const { node } = tag;
|
|
9494
|
+
addSetupStatement(getOrCreateSection(tag));
|
|
9328
9495
|
const definedBodySection = node.extra?.defineBodySection;
|
|
9329
9496
|
if (definedBodySection) {
|
|
9330
9497
|
knownTagAnalyze(tag, definedBodySection, definedBodySection.params && getBindingPropTree(definedBodySection.params));
|
|
@@ -20,6 +20,6 @@ declare module "@marko/compiler/dist/types" {
|
|
|
20
20
|
}
|
|
21
21
|
export declare function knownTagAnalyze(tag: t.NodePath<t.MarkoTag>, contentSection: Section, propTree: BindingPropTree | undefined): void;
|
|
22
22
|
export declare function knownTagTranslateHTML(tag: t.NodePath<t.MarkoTag>, tagIdentifier: t.Expression, contentSection: Section, propTree: BindingPropTree | undefined): void;
|
|
23
|
-
export declare function knownTagTranslateDOM(tag: t.NodePath<t.MarkoTag>, propTree: BindingPropTree | undefined, getBindingIdentifier: (binding: Binding, preferredName?: string, directContent?: boolean) => t.Identifier, callSetup: (section: Section, childBinding: Binding) => void): void;
|
|
23
|
+
export declare function knownTagTranslateDOM(tag: t.NodePath<t.MarkoTag>, propTree: BindingPropTree | undefined, getBindingIdentifier: (binding: Binding, preferredName?: string, directContent?: boolean) => t.Identifier, callSetup: ((section: Section, childBinding: Binding) => void) | undefined): void;
|
|
24
24
|
export declare function finalizeKnownTags(section: Section): void;
|
|
25
25
|
export {};
|
|
@@ -49,6 +49,7 @@ export interface Binding {
|
|
|
49
49
|
nullable: boolean;
|
|
50
50
|
pruned: boolean | undefined;
|
|
51
51
|
exposed: boolean;
|
|
52
|
+
forcePersist: boolean;
|
|
52
53
|
}
|
|
53
54
|
export interface InputBinding extends Binding {
|
|
54
55
|
type: BindingType.input;
|
|
@@ -70,6 +71,7 @@ interface Read {
|
|
|
70
71
|
ownVar: boolean;
|
|
71
72
|
getter: Getter | undefined;
|
|
72
73
|
comparedTo: t.Node | undefined;
|
|
74
|
+
deferred: boolean;
|
|
73
75
|
}
|
|
74
76
|
interface ExtraRead {
|
|
75
77
|
binding: Binding;
|
|
@@ -88,6 +90,8 @@ declare module "@marko/compiler/dist/types" {
|
|
|
88
90
|
read?: ExtraRead;
|
|
89
91
|
pruned?: true;
|
|
90
92
|
isEffect?: true;
|
|
93
|
+
invokeOnly?: true;
|
|
94
|
+
lazyBindings?: ReferencedBindings;
|
|
91
95
|
spreadFrom?: Binding;
|
|
92
96
|
nativeTagSpread?: true;
|
|
93
97
|
nativeTagSpreadMerged?: true;
|
|
@@ -148,6 +152,7 @@ export declare function getDebugNamesAsIdentifier(refs: ReferencedBindings): str
|
|
|
148
152
|
export declare function getSectionInstancesAccessor(section: Section): string;
|
|
149
153
|
export declare function getSectionInstancesAccessorLiteral(section: Section): t.NumericLiteral | t.StringLiteral | undefined;
|
|
150
154
|
export declare function getReadReplacement(node: t.Identifier | t.MemberExpression | t.OptionalMemberExpression, signal?: Signal): t.Expression | undefined;
|
|
155
|
+
export declare function isInvokeOnlyBinding(binding: Binding): boolean;
|
|
151
156
|
export declare function hasNonConstantPropertyAlias(ref: Binding): boolean;
|
|
152
157
|
export declare function pruneBinding(binding: Binding): boolean;
|
|
153
158
|
export declare function createRead(binding: Binding, props: Opt<string>, ownVar?: boolean): ExtraRead;
|
|
@@ -14,6 +14,8 @@ export declare function isReasonDynamic(reason: undefined | SerializeReason): re
|
|
|
14
14
|
state: undefined;
|
|
15
15
|
param: OneMany<InputBinding | ParamBinding>;
|
|
16
16
|
};
|
|
17
|
+
export declare function isStaticSerializeReason(reason: undefined | SerializeReason): reason is SerializeReason;
|
|
18
|
+
export declare function isStateSerializeReason(reason: undefined | SerializeReason): reason is Sources;
|
|
17
19
|
export declare function getSerializeReason(section: Section, prop?: Binding | AccessorProp | symbol, prefix?: AccessorPrefix | symbol): SerializeReason | undefined;
|
|
18
20
|
export declare function getSerializeSourcesForExpr(expr: t.NodeExtra): Sources | undefined;
|
|
19
21
|
export declare function getSerializeSourcesForExprs(exprs: Opt<t.NodeExtra> | boolean): true | Sources | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { types as t } from "@marko/compiler";
|
|
2
|
+
import type { Section } from "./sections";
|
|
3
|
+
export declare function addSetupStatement(section: Section): void;
|
|
4
|
+
export declare function addSetupExpr(section: Section, node: t.Node | undefined): void;
|
|
5
|
+
export declare function sectionHasSetupStatements(section: Section): boolean;
|
|
@@ -33,6 +33,7 @@ type closureSignalBuilder = (closure: Binding, render: t.Expression) => t.Expres
|
|
|
33
33
|
export declare const getSignals: (section: Section) => Map<unknown, Signal>;
|
|
34
34
|
export declare function setClosureSignalBuilder(tag: t.NodePath<t.MarkoTag>, builder: closureSignalBuilder): void;
|
|
35
35
|
export declare const getTryHasPlaceholder: (section: Section) => true | undefined, setTryHasPlaceholder: (section: Section, value: true | undefined) => void;
|
|
36
|
+
export declare function setSectionOwnerResumedByMarker(section: Section): void;
|
|
36
37
|
export declare function setSectionSerializedValue(section: Section, prop: AccessorProp, expression: t.Expression): void;
|
|
37
38
|
export declare function setBindingSerializedValue(section: Section, binding: Binding, expression: t.Expression, prefix?: AccessorPrefix): void;
|
|
38
39
|
export declare function setSerializedValue(section: Section, key: string, expression: t.Expression): void;
|