marko 6.3.14 → 6.3.15
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/html.js +162 -157
- package/dist/debug/html.mjs +162 -157
- package/dist/html/writer.d.ts +36 -36
- package/dist/html.js +117 -113
- package/dist/html.mjs +117 -113
- package/dist/translator/index.js +62 -50
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
|
@@ -1754,13 +1754,14 @@ function getContext(key) {
|
|
|
1754
1754
|
function getState() {
|
|
1755
1755
|
return $chunk.boundary.state;
|
|
1756
1756
|
}
|
|
1757
|
-
function
|
|
1758
|
-
$chunk.
|
|
1757
|
+
function getScopeById(scopeId) {
|
|
1758
|
+
if (scopeId !== void 0) return $chunk.boundary.state.scopes.get(scopeId);
|
|
1759
1759
|
}
|
|
1760
|
-
function
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1760
|
+
function _scope_id() {
|
|
1761
|
+
return $chunk.boundary.state.scopeId++;
|
|
1762
|
+
}
|
|
1763
|
+
function _peek_scope_id() {
|
|
1764
|
+
return $chunk.boundary.state.scopeId;
|
|
1764
1765
|
}
|
|
1765
1766
|
const kPendingContexts = Symbol("Pending Contexts");
|
|
1766
1767
|
function withContext(key, value, cb, cbValue) {
|
|
@@ -1775,27 +1776,23 @@ function withContext(key, value, cb, cbValue) {
|
|
|
1775
1776
|
ctx[key] = prev;
|
|
1776
1777
|
}
|
|
1777
1778
|
}
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
return $chunk.boundary.state.scopeId;
|
|
1779
|
+
const kBranchId = Symbol("Branch Id");
|
|
1780
|
+
const kIsAsync = Symbol("Is Async");
|
|
1781
|
+
function withBranchId(branchId, cb) {
|
|
1782
|
+
return withContext(kBranchId, branchId, cb);
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1785
|
-
|
|
1784
|
+
function _html(html) {
|
|
1785
|
+
$chunk.writeHTML(html);
|
|
1786
1786
|
}
|
|
1787
|
-
function
|
|
1788
|
-
$chunk.
|
|
1787
|
+
function _script(scopeId, registryId) {
|
|
1788
|
+
if ($chunk.serializeState.readyId || $chunk.context?.[kIsAsync]) _resume_branch(scopeId);
|
|
1789
|
+
$chunk.boundary.state.needsMainRuntime = true;
|
|
1790
|
+
$chunk.writeEffect(scopeId, registryId);
|
|
1789
1791
|
}
|
|
1790
1792
|
function _resume_branch(scopeId) {
|
|
1791
1793
|
const branchId = $chunk.context?.[kBranchId];
|
|
1792
1794
|
if (branchId !== void 0 && branchId !== scopeId) writeScope(scopeId, { ["#ClosestBranchId"]: branchId });
|
|
1793
1795
|
}
|
|
1794
|
-
const kBranchId = Symbol("Branch Id");
|
|
1795
|
-
const kIsAsync = Symbol("Is Async");
|
|
1796
|
-
function withBranchId(branchId, cb) {
|
|
1797
|
-
return withContext(kBranchId, branchId, cb);
|
|
1798
|
-
}
|
|
1799
1796
|
let writeScope = (scopeId, partialScope) => {
|
|
1800
1797
|
const { state } = $chunk.boundary;
|
|
1801
1798
|
const target = $chunk.serializeState;
|
|
@@ -1814,6 +1811,9 @@ function scopeWithId(state, scopeId) {
|
|
|
1814
1811
|
if (!scope) scopes.set(scopeId, scope = { [K_SCOPE_ID]: scopeId });
|
|
1815
1812
|
return scope;
|
|
1816
1813
|
}
|
|
1814
|
+
function _set_serialize_reason(reason) {
|
|
1815
|
+
$chunk.boundary.state.serializeReason = reason;
|
|
1816
|
+
}
|
|
1817
1817
|
globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask;
|
|
1818
1818
|
//#endregion
|
|
1819
1819
|
//#region src/html/attrs.ts
|
|
@@ -1989,25 +1989,28 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
1989
1989
|
if (typeof renderer === "string") {
|
|
1990
1990
|
const input = (inputIsArgs ? inputOrArgs[0] : inputOrArgs) || {};
|
|
1991
1991
|
rendered = true;
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
if (
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
1992
|
+
const renderNative = () => {
|
|
1993
|
+
_scope_id();
|
|
1994
|
+
_html(`<${renderer}${_attrs(input, "a", branchId, renderer)}>`);
|
|
1995
|
+
if (!voidElementsReg.test(renderer)) {
|
|
1996
|
+
const renderContent = content || normalizeDynamicRenderer(input.content);
|
|
1997
|
+
if (renderer === "textarea") _html(_attr_textarea_value(branchId, "a", input.value, input.valueChange, 1));
|
|
1998
|
+
else if (renderContent) {
|
|
1999
|
+
if (typeof renderContent !== "function") throw new Error(`Body content is not supported for the \`<${renderer}>\` tag.`);
|
|
2000
|
+
if (renderer === "select" && ("value" in input || "valueChange" in input)) _attr_select_value(branchId, "a", input.value, input.valueChange, renderContent, 1);
|
|
2001
|
+
else _dynamic_tag(branchId, "a", renderContent, void 0, 0, void 0, serializeReason);
|
|
2002
|
+
}
|
|
2003
|
+
_html(`</${renderer}>`);
|
|
2004
|
+
}
|
|
2005
|
+
const childScope = getScopeById(branchId);
|
|
2006
|
+
const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
|
|
2007
|
+
if (needsScript) {
|
|
2008
|
+
writeScope(branchId, { ["#Renderer"]: renderer });
|
|
2009
|
+
_script(branchId, "d");
|
|
2010
|
+
}
|
|
2011
|
+
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
2012
|
+
};
|
|
2013
|
+
renderNative();
|
|
2011
2014
|
} else {
|
|
2012
2015
|
if (shouldResume) _html(state.mark("[", ""));
|
|
2013
2016
|
const render = () => {
|
|
@@ -2298,7 +2301,10 @@ function getScopeReasonDeclaration(section) {
|
|
|
2298
2301
|
return _marko_compiler.types.variableDeclaration("const", getSectionReasonState(section).declarators);
|
|
2299
2302
|
}
|
|
2300
2303
|
function getSerializeGuard(section, reason, optional) {
|
|
2301
|
-
if (!isReasonDynamic(reason) || isCrossSection(section, reason))
|
|
2304
|
+
if (!isReasonDynamic(reason) || isCrossSection(section, reason)) {
|
|
2305
|
+
if (!reason) return _marko_compiler.types.numericLiteral(0);
|
|
2306
|
+
return optional ? void 0 : withLeadingComment(_marko_compiler.types.numericLiteral(1), getDebugNames(reason === true ? void 0 : reason.state));
|
|
2307
|
+
}
|
|
2302
2308
|
return getOrHoist(reason, true);
|
|
2303
2309
|
}
|
|
2304
2310
|
function getSerializeGuardForAny(section, reasons, optional) {
|
|
@@ -3013,12 +3019,14 @@ function getSignalFn(signal) {
|
|
|
3013
3019
|
}
|
|
3014
3020
|
for (const value of signal.values) {
|
|
3015
3021
|
if (value.signal.inline) continue;
|
|
3016
|
-
if (signalHasStatements(value.signal))
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
|
|
3020
|
-
|
|
3021
|
-
|
|
3022
|
+
if (signalHasStatements(value.signal)) {
|
|
3023
|
+
const invocation = _marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(value.signal.identifier, [
|
|
3024
|
+
scopeIdentifier,
|
|
3025
|
+
value.value,
|
|
3026
|
+
...getTranslatedExtraArgs(value.signal)
|
|
3027
|
+
]));
|
|
3028
|
+
signal.render.push(invocation);
|
|
3029
|
+
} else signal.render.push(_marko_compiler.types.expressionStatement(withLeadingComment(value.value, getDebugNames(value.signal.referencedBindings))));
|
|
3022
3030
|
}
|
|
3023
3031
|
forEach(signal.intersection, (intersection) => {
|
|
3024
3032
|
signal.render.push(_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression(intersection.identifier, [scopeIdentifier])));
|
|
@@ -3150,13 +3158,16 @@ function addValue(targetSection, referencedBindings, signal, value) {
|
|
|
3150
3158
|
});
|
|
3151
3159
|
if (value.extra?.referencedBindingsInFunction) parentSignal.hasSideEffect = true;
|
|
3152
3160
|
}
|
|
3153
|
-
function
|
|
3154
|
-
const { markoOpts, opts: { filename } } = (0, _marko_compiler_babel_utils.getFile)();
|
|
3161
|
+
function buildResumeRegisterKey(section, referencedBindings, type) {
|
|
3155
3162
|
let name = "";
|
|
3156
3163
|
if (referencedBindings) if (typeof referencedBindings === "string") name += `_${referencedBindings}`;
|
|
3157
3164
|
else if (Array.isArray(referencedBindings)) for (const ref of referencedBindings) name += `_${ref.name}`;
|
|
3158
3165
|
else name += `_${referencedBindings.name}`;
|
|
3159
|
-
return
|
|
3166
|
+
return `${section.id}${name}${type ? "/" + type : ""}`;
|
|
3167
|
+
}
|
|
3168
|
+
function getResumeRegisterId(section, referencedBindings, type) {
|
|
3169
|
+
const { markoOpts, opts: { filename } } = (0, _marko_compiler_babel_utils.getFile)();
|
|
3170
|
+
return (0, _marko_compiler_babel_utils.getTemplateId)(markoOpts, filename, buildResumeRegisterKey(section, referencedBindings, type));
|
|
3160
3171
|
}
|
|
3161
3172
|
function writeSignals(section) {
|
|
3162
3173
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -3175,7 +3186,8 @@ function writeSignals(section) {
|
|
|
3175
3186
|
if (signal.effect.length) {
|
|
3176
3187
|
traverseReplace(signal, "effect", replaceEffectNode);
|
|
3177
3188
|
const effectIdentifier = _marko_compiler.types.identifier(`${signal.identifier.name}__script`);
|
|
3178
|
-
|
|
3189
|
+
const effectFn = _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], toFirstExpressionOrBlock(signal.effect));
|
|
3190
|
+
effectDeclarator = _marko_compiler.types.variableDeclarator(effectIdentifier, callRuntime("_script", _marko_compiler.types.stringLiteral(getResumeRegisterId(section, signal.referencedBindings)), effectFn));
|
|
3179
3191
|
}
|
|
3180
3192
|
let signalDeclaration;
|
|
3181
3193
|
if (signal.build) {
|