marko 6.3.16 → 6.3.18
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/LICENSE +21 -0
- package/dist/common/accessor.d.ts +1 -0
- package/dist/common/accessor.debug.d.ts +1 -0
- package/dist/common/types.d.ts +0 -1
- package/dist/debug/dom.js +30 -17
- package/dist/debug/dom.mjs +30 -17
- package/dist/debug/html.js +58 -21
- package/dist/debug/html.mjs +58 -22
- package/dist/dom.js +19 -17
- package/dist/dom.mjs +19 -17
- package/dist/html/attrs.d.ts +1 -0
- package/dist/html.d.ts +1 -1
- package/dist/html.js +44 -14
- package/dist/html.mjs +44 -14
- package/dist/translator/index.js +76 -38
- package/dist/translator/util/body-to-text-literal.d.ts +2 -2
- package/dist/translator/util/references.d.ts +1 -0
- package/dist/translator/util/to-first-expression-or-block.d.ts +1 -2
- package/dist/translator/util/walks.d.ts +1 -1
- package/dist/translator/util/writer.d.ts +1 -1
- package/package.json +11 -7
package/dist/translator/index.js
CHANGED
|
@@ -127,6 +127,7 @@ let AccessorProp$1 = /* @__PURE__ */ function(AccessorProp) {
|
|
|
127
127
|
AccessorProp["Id"] = "#Id";
|
|
128
128
|
AccessorProp["Load"] = "#Load";
|
|
129
129
|
AccessorProp["LoopKey"] = "#LoopKey";
|
|
130
|
+
AccessorProp["LoopIndex"] = "#LoopIndex";
|
|
130
131
|
AccessorProp["ParentBranch"] = "#ParentBranch";
|
|
131
132
|
AccessorProp["PendingEffects"] = "#PendingEffects";
|
|
132
133
|
AccessorProp["PendingRenders"] = "#PendingRenders";
|
|
@@ -252,7 +253,12 @@ function stringifyClassObject(name, value) {
|
|
|
252
253
|
return value ? name : "";
|
|
253
254
|
}
|
|
254
255
|
function stringifyStyleObject(name, value) {
|
|
255
|
-
return value || value === 0 ? name + ":" + value : "";
|
|
256
|
+
return value || value === 0 ? escapeStyleAttr(name) + ":" + escapeStyleAttr(value + "") : "";
|
|
257
|
+
}
|
|
258
|
+
const unsafeStyleAttrReg = /[\\;]/g;
|
|
259
|
+
const replaceUnsafeStyleAttr = (c) => c === ";" ? "\\3B " : "\\\\";
|
|
260
|
+
function escapeStyleAttr(str) {
|
|
261
|
+
return unsafeStyleAttrReg.test(str) ? str.replace(unsafeStyleAttrReg, replaceUnsafeStyleAttr) : str;
|
|
256
262
|
}
|
|
257
263
|
const toDelimitedString = function toDelimitedString(val, delimiter, stringify) {
|
|
258
264
|
let str = "";
|
|
@@ -878,6 +884,7 @@ let AccessorProp = /* @__PURE__ */ function(AccessorProp) {
|
|
|
878
884
|
AccessorProp["Id"] = "L";
|
|
879
885
|
AccessorProp["Load"] = "X";
|
|
880
886
|
AccessorProp["LoopKey"] = "M";
|
|
887
|
+
AccessorProp["LoopIndex"] = "I";
|
|
881
888
|
AccessorProp["ParentBranch"] = "N";
|
|
882
889
|
AccessorProp["PendingEffects"] = "J";
|
|
883
890
|
AccessorProp["PendingRenders"] = "W";
|
|
@@ -1741,8 +1748,8 @@ const escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeS
|
|
|
1741
1748
|
function _escape_script(val) {
|
|
1742
1749
|
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
|
1743
1750
|
}
|
|
1744
|
-
const unsafeStyleReg =
|
|
1745
|
-
const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C
|
|
1751
|
+
const unsafeStyleReg = /<(\/style)/gi;
|
|
1752
|
+
const escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C$1") : str;
|
|
1746
1753
|
function _escape_style(val) {
|
|
1747
1754
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
|
1748
1755
|
}
|
|
@@ -1838,11 +1845,14 @@ function _attr_option_value(value) {
|
|
|
1838
1845
|
const kSelectedValue = Symbol("selectedValue");
|
|
1839
1846
|
function _attr_select_value(scopeId, nodeAccessor, value, valueChange, content, serializeType) {
|
|
1840
1847
|
if (valueChange) writeControlledScope(3, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
1841
|
-
if (content) withContext(kSelectedValue, value, content);
|
|
1848
|
+
if (content) withContext(kSelectedValue, value ?? "", content);
|
|
1842
1849
|
}
|
|
1843
1850
|
function _attr_textarea_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1844
1851
|
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
1845
|
-
return
|
|
1852
|
+
return _textarea_value(value);
|
|
1853
|
+
}
|
|
1854
|
+
function _textarea_value(value) {
|
|
1855
|
+
return _escape(normalizeStrAttrValue(value));
|
|
1846
1856
|
}
|
|
1847
1857
|
function _attr_input_value(scopeId, nodeAccessor, value, valueChange, serializeType) {
|
|
1848
1858
|
if (valueChange) writeControlledScope(2, scopeId, nodeAccessor, void 0, valueChange, serializeType);
|
|
@@ -2385,7 +2395,6 @@ const [getSteps] = createSectionState("steps", (section) => {
|
|
|
2385
2395
|
});
|
|
2386
2396
|
const walkCodeToName = {
|
|
2387
2397
|
[32]: "get",
|
|
2388
|
-
[36]: "inside",
|
|
2389
2398
|
[37]: "replace",
|
|
2390
2399
|
[38]: "endChild",
|
|
2391
2400
|
[47]: "beginChild",
|
|
@@ -2563,12 +2572,12 @@ function getSectionMetaIdentifiers(section) {
|
|
|
2563
2572
|
}
|
|
2564
2573
|
return meta;
|
|
2565
2574
|
}
|
|
2566
|
-
function markNode(path, nodeBinding, reason) {
|
|
2575
|
+
function markNode(path, nodeBinding, reason, deferred) {
|
|
2567
2576
|
if (nodeBinding.type !== 0) throw path.buildCodeFrameError("POTENTIAL MARKO BUG: Tried to mark a node that was not determined to need a mark during analyze.");
|
|
2568
2577
|
if (isOutputHTML()) {
|
|
2569
2578
|
if (reason) {
|
|
2570
2579
|
const section = getSection(path);
|
|
2571
|
-
writeTo(path)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
|
|
2580
|
+
writeTo(path, deferred)`${callRuntime("_el_resume", getScopeIdIdentifier(section), getScopeAccessorLiteral(nodeBinding), getSerializeGuard(section, reason, true))}`;
|
|
2572
2581
|
}
|
|
2573
2582
|
}
|
|
2574
2583
|
}
|
|
@@ -2707,6 +2716,7 @@ function detectForSelector(bodySection, keyBinding) {
|
|
|
2707
2716
|
}
|
|
2708
2717
|
function onlyComparesKey(closure, canonical, bodySection, keyBinding) {
|
|
2709
2718
|
let found = false;
|
|
2719
|
+
const keyReads = /* @__PURE__ */ new Map();
|
|
2710
2720
|
for (let chain = closure; chain; chain = chain.upstreamAlias) for (const expr of chain.reads) {
|
|
2711
2721
|
if (expr.section !== bodySection) continue;
|
|
2712
2722
|
let other = false;
|
|
@@ -2714,13 +2724,23 @@ function onlyComparesKey(closure, canonical, bodySection, keyBinding) {
|
|
|
2714
2724
|
const resolved = read.extra.read;
|
|
2715
2725
|
const at = resolved && resolvesTo(resolved, canonical);
|
|
2716
2726
|
if (!at) return;
|
|
2717
|
-
|
|
2718
|
-
|
|
2727
|
+
const keyRead = read.comparedTo?.extra?.read;
|
|
2728
|
+
if (at === 2 || resolved.getter || !readsKey(keyRead, keyBinding)) other = true;
|
|
2729
|
+
else {
|
|
2730
|
+
found = true;
|
|
2731
|
+
if (keyRead && !keyRead.props && getCanonicalBinding(keyRead.binding) === getCanonicalBinding(keyBinding)) keyReads.set(expr, bindingUtil.add(keyReads.get(expr), keyRead.binding));
|
|
2732
|
+
}
|
|
2719
2733
|
});
|
|
2720
2734
|
if (other) return false;
|
|
2721
2735
|
}
|
|
2736
|
+
if (found) for (const [expr, dropped] of keyReads) dropKeyReferences(expr, dropped);
|
|
2722
2737
|
return found;
|
|
2723
2738
|
}
|
|
2739
|
+
function dropKeyReferences(expr, dropped) {
|
|
2740
|
+
if (dropReferencedBindings(expr, dropped)) forEach(dropped, (binding) => {
|
|
2741
|
+
binding.forcePersist = true;
|
|
2742
|
+
});
|
|
2743
|
+
}
|
|
2724
2744
|
function resolvesTo(read, canonical) {
|
|
2725
2745
|
let binding = read.binding;
|
|
2726
2746
|
let through = 0;
|
|
@@ -2810,16 +2830,9 @@ function simplifyFunction(fn) {
|
|
|
2810
2830
|
//#endregion
|
|
2811
2831
|
//#region src/translator/util/to-first-expression-or-block.ts
|
|
2812
2832
|
function toFirstExpressionOrBlock(stmts) {
|
|
2813
|
-
if (stmts.length === 1 && _marko_compiler.types.isExpressionStatement(stmts[0])) return
|
|
2833
|
+
if (stmts.length === 1 && _marko_compiler.types.isExpressionStatement(stmts[0])) return stmts[0].expression;
|
|
2814
2834
|
return _marko_compiler.types.blockStatement(stmts);
|
|
2815
2835
|
}
|
|
2816
|
-
function toParenthesizedExpressionIfNeeded(expr) {
|
|
2817
|
-
switch (expr.type) {
|
|
2818
|
-
case "ObjectExpression":
|
|
2819
|
-
case "AssignmentExpression": return _marko_compiler.types.parenthesizedExpression(expr);
|
|
2820
|
-
default: return expr;
|
|
2821
|
-
}
|
|
2822
|
-
}
|
|
2823
2836
|
//#endregion
|
|
2824
2837
|
//#region src/translator/util/signals.ts
|
|
2825
2838
|
const [getSignals] = createSectionState("signals", () => /* @__PURE__ */ new Map());
|
|
@@ -2925,7 +2938,7 @@ function getSignal(section, referencedBindings, name) {
|
|
|
2925
2938
|
const render = getSignalFn(signal);
|
|
2926
2939
|
const closureSignalBuilder = getClosureSignalBuilder(section);
|
|
2927
2940
|
if (closureSignalBuilder && !isDynamicClosure(section, closure)) return closureSignalBuilder(closure, render);
|
|
2928
|
-
return callRuntime("_closure_get", isOptimize() ? _marko_compiler.types.numericLiteral(getClosureAccessorId(closure)) : getScopeAccessorLiteral(closure, true), render, isImmediateOwner(section, closure) ? void 0 : _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], getScopeExpression(section, closure.section)),
|
|
2941
|
+
return callRuntime("_closure_get", isOptimize() ? _marko_compiler.types.numericLiteral(getClosureAccessorId(closure)) : getScopeAccessorLiteral(closure, true), render, isImmediateOwner(section, closure) ? void 0 : _marko_compiler.types.arrowFunctionExpression([scopeIdentifier], getScopeExpression(section, closure.section)), underTryPlaceholder(section) ? _marko_compiler.types.stringLiteral(getResumeRegisterId(section, closure, "pending")) : void 0);
|
|
2929
2942
|
};
|
|
2930
2943
|
}
|
|
2931
2944
|
return signal;
|
|
@@ -3123,7 +3136,7 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
|
|
|
3123
3136
|
args[i] = _marko_compiler.types.numericLiteral(0);
|
|
3124
3137
|
continue;
|
|
3125
3138
|
}
|
|
3126
|
-
if (body.length === 1 && _marko_compiler.types.isExpressionStatement(body[0])) arg.body =
|
|
3139
|
+
if (body.length === 1 && _marko_compiler.types.isExpressionStatement(body[0])) arg.body = body[0].expression;
|
|
3127
3140
|
}
|
|
3128
3141
|
if (finalLen === void 0) finalLen = i + 1;
|
|
3129
3142
|
}
|
|
@@ -3695,7 +3708,7 @@ function getRegisteredFnExpression(node) {
|
|
|
3695
3708
|
//#region src/translator/util/body-to-text-literal.ts
|
|
3696
3709
|
const kRawText = Symbol("raw text placeholder");
|
|
3697
3710
|
function bodyToTextLiteral(body) {
|
|
3698
|
-
return buildTextLiteral(body, toText,
|
|
3711
|
+
return buildTextLiteral(body, toText, true);
|
|
3699
3712
|
}
|
|
3700
3713
|
function bodyToRawTextLiteral(body) {
|
|
3701
3714
|
return buildTextLiteral(body, (value) => value, true);
|
|
@@ -3719,15 +3732,17 @@ function buildTextLiteral(body, coerce, bareSingle) {
|
|
|
3719
3732
|
const templateExpressions = [];
|
|
3720
3733
|
let currentQuasi = "";
|
|
3721
3734
|
let placeholderExtra;
|
|
3735
|
+
let singleValue;
|
|
3722
3736
|
for (const child of body.body) if (_marko_compiler.types.isMarkoText(child)) currentQuasi += child.value;
|
|
3723
3737
|
else if (_marko_compiler.types.isMarkoPlaceholder(child)) {
|
|
3724
3738
|
placeholderExtra ||= child.value.extra;
|
|
3725
3739
|
templateQuasis.push(templateElement(currentQuasi, false));
|
|
3726
3740
|
templateExpressions.push(coerce(child.value));
|
|
3741
|
+
singleValue = child.value;
|
|
3727
3742
|
currentQuasi = "";
|
|
3728
3743
|
}
|
|
3729
3744
|
if (templateExpressions.length) {
|
|
3730
|
-
if (bareSingle && templateExpressions.length === 1 && !currentQuasi && !templateQuasis[0].value.cooked) return
|
|
3745
|
+
if (bareSingle && templateExpressions.length === 1 && !currentQuasi && !templateQuasis[0].value.cooked && !_marko_compiler.types.isStringLiteral(singleValue)) return singleValue;
|
|
3731
3746
|
templateQuasis.push(templateElement(currentQuasi, true));
|
|
3732
3747
|
const literal = _marko_compiler.types.templateLiteral(templateQuasis, templateExpressions);
|
|
3733
3748
|
literal.extra = placeholderExtra;
|
|
@@ -4350,6 +4365,10 @@ var native_tag_default = {
|
|
|
4350
4365
|
let exprExtras;
|
|
4351
4366
|
for (let i = attributes.length; i--;) {
|
|
4352
4367
|
const attr = attributes[i];
|
|
4368
|
+
if (_marko_compiler.types.isMarkoAttribute(attr) && attr.name === "content" && tag.node.body.body.length) {
|
|
4369
|
+
dropNodes(attr.value);
|
|
4370
|
+
continue;
|
|
4371
|
+
}
|
|
4353
4372
|
const valueExtra = attr.value.extra ??= {};
|
|
4354
4373
|
if (_marko_compiler.types.isMarkoAttribute(attr)) {
|
|
4355
4374
|
if (seen[attr.name]) {
|
|
@@ -4489,7 +4508,7 @@ var native_tag_default = {
|
|
|
4489
4508
|
spreadExpression = spreadIdentifier;
|
|
4490
4509
|
}
|
|
4491
4510
|
if (valueChange) writeAtStartOfBody = callRuntime("_attr_textarea_value", getScopeIdIdentifier(tagSection), visitAccessor, value, valueChange, staticControllable ? void 0 : _marko_compiler.types.numericLiteral(1));
|
|
4492
|
-
else if (value) writeAtStartOfBody = callRuntime("
|
|
4511
|
+
else if (value) writeAtStartOfBody = callRuntime("_textarea_value", value);
|
|
4493
4512
|
}
|
|
4494
4513
|
for (const attr of staticAttrs) {
|
|
4495
4514
|
const { name, value } = attr;
|
|
@@ -4549,7 +4568,7 @@ var native_tag_default = {
|
|
|
4549
4568
|
const tagName = getCanonicalTagName(tag);
|
|
4550
4569
|
const tagSection = getSection(tag);
|
|
4551
4570
|
const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getSerializeReason(tagSection, nodeBinding);
|
|
4552
|
-
const write = writeTo(tag,
|
|
4571
|
+
const write = writeTo(tag, tagName === "html" || !markerSerializeReason && tagName === "body");
|
|
4553
4572
|
if (tagExtra[kTagContentAttr]) flushBefore(tag);
|
|
4554
4573
|
if (selectArgs) {
|
|
4555
4574
|
if (!tagExtra[kSkipEndTag]) write`</${tagName}>`;
|
|
@@ -4563,7 +4582,7 @@ var native_tag_default = {
|
|
|
4563
4582
|
if (tagName === "head" && getMarkoOpts().linkAssets) write`${callRuntime("_flush_head")}`;
|
|
4564
4583
|
write`</${tagName}>`;
|
|
4565
4584
|
}
|
|
4566
|
-
if (markerSerializeReason) markNode(tag, nodeBinding, markerSerializeReason);
|
|
4585
|
+
if (markerSerializeReason) markNode(tag, nodeBinding, markerSerializeReason, tagName === "html");
|
|
4567
4586
|
tag.remove();
|
|
4568
4587
|
}
|
|
4569
4588
|
},
|
|
@@ -5257,7 +5276,7 @@ function flattenTextOnlyConditional(rootTag) {
|
|
|
5257
5276
|
if (node.body.attributeTags || !body.length) return;
|
|
5258
5277
|
const [attr] = node.attributes;
|
|
5259
5278
|
if (isCoreTagName(tag, "else")) {
|
|
5260
|
-
if (node.attributes.length) return;
|
|
5279
|
+
if (node.attributes.length > 1 || attr && (!_marko_compiler.types.isMarkoAttribute(attr) || attr.name !== "if")) return;
|
|
5261
5280
|
} else if (node.attributes.length !== 1 || !_marko_compiler.types.isMarkoAttribute(attr) || !attr.default) return;
|
|
5262
5281
|
for (const child of body) if (_marko_compiler.types.isMarkoText(child)) {
|
|
5263
5282
|
if (_escape(child.value) !== child.value) return;
|
|
@@ -5274,7 +5293,8 @@ function flattenTextOnlyConditional(rootTag) {
|
|
|
5274
5293
|
const branchTag = branches[i];
|
|
5275
5294
|
const text = bodyToRawTextLiteral(branchTag.node.body);
|
|
5276
5295
|
rawText ||= _marko_compiler.types.isTemplateLiteral(text);
|
|
5277
|
-
|
|
5296
|
+
const [conditionAttr] = branchTag.node.attributes;
|
|
5297
|
+
expr = conditionAttr ? _marko_compiler.types.conditionalExpression(conditionAttr.value, text, expr) : text;
|
|
5278
5298
|
}
|
|
5279
5299
|
for (let i = branches.length; i-- > 1;) branches[i].remove();
|
|
5280
5300
|
const placeholder = _marko_compiler.types.markoPlaceholder(expr, true);
|
|
@@ -5499,7 +5519,7 @@ function getChangeHandler(tag, attr) {
|
|
|
5499
5519
|
if (!existingChangedAttr) {
|
|
5500
5520
|
const bindingIdentifierPath = binding.path.getOuterBindingIdentifierPaths()[binding.identifier.name];
|
|
5501
5521
|
let changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value, modifier) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(bindingIdentifierPath.parentPath) : void 0 : void 0;
|
|
5502
|
-
if (!changeAttrExpr) throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
5522
|
+
if (!changeAttrExpr) throw tag.hub.buildError(attr.value, bindingIdentifierPath?.parentPath?.isArrayPattern() ? `Cannot two-way bind to \`${attr.value.name}\` because it comes from array destructuring, which has no change handler. Use object destructuring or pass an explicit \`${changeAttrName}\` attribute.` : "Unable to bind to value.");
|
|
5503
5523
|
if (modifier && _marko_compiler.types.isIdentifier(changeAttrExpr)) changeAttrExpr = _marko_compiler.types.logicalExpression("&&", changeAttrExpr, buildModifierForwarder(_marko_compiler.types.cloneNode(changeAttrExpr), modifier));
|
|
5504
5524
|
const changeHandlerAttr = _marko_compiler.types.markoAttribute(changeAttrName, changeAttrExpr);
|
|
5505
5525
|
BINDING_CHANGE_HANDLER.set(binding.identifier, changeHandlerAttr);
|
|
@@ -6918,6 +6938,15 @@ function finalizeReferences() {
|
|
|
6918
6938
|
readsByExpression.clear();
|
|
6919
6939
|
fnReadsByExpression.clear();
|
|
6920
6940
|
}
|
|
6941
|
+
function dropReferencedBindings(expr, drop) {
|
|
6942
|
+
let kept;
|
|
6943
|
+
forEach(expr.referencedBindings, (binding) => {
|
|
6944
|
+
if (!bindingUtil.has(drop, binding)) kept = bindingUtil.add(kept, binding);
|
|
6945
|
+
});
|
|
6946
|
+
if (Array.isArray(kept)) return false;
|
|
6947
|
+
expr.referencedBindings = kept;
|
|
6948
|
+
return true;
|
|
6949
|
+
}
|
|
6921
6950
|
function getMaxOwnSourceOffset(intersection, section) {
|
|
6922
6951
|
let scopeOffset;
|
|
6923
6952
|
const trackScopeOffset = (source) => {
|
|
@@ -9492,6 +9521,14 @@ function optionalValueToNode(value) {
|
|
|
9492
9521
|
const kDOMBinding = Symbol("dynamic tag dom binding");
|
|
9493
9522
|
const kChildOffsetScopeBinding = Symbol("custom tag scope offset");
|
|
9494
9523
|
const importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
9524
|
+
const [getCompatRegistrations] = createProgramState(() => /* @__PURE__ */ new Set());
|
|
9525
|
+
function pushCompatRegistration(key, statement) {
|
|
9526
|
+
const keys = getCompatRegistrations();
|
|
9527
|
+
if (!keys.has(key)) {
|
|
9528
|
+
keys.add(key);
|
|
9529
|
+
(0, _marko_compiler_babel_utils.getProgram)().node.body.push(statement);
|
|
9530
|
+
}
|
|
9531
|
+
}
|
|
9495
9532
|
var dynamic_tag_default = {
|
|
9496
9533
|
analyze: { enter(tag) {
|
|
9497
9534
|
(0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
|
|
@@ -9572,32 +9609,33 @@ var dynamic_tag_default = {
|
|
|
9572
9609
|
if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
|
|
9573
9610
|
if (classTagTemplate) {
|
|
9574
9611
|
const preserveBoundary = !tagsSerializeReason && (classHydration === "descendant" || classHydration === "self" && !!classFile?.metadata.marko.hasComponentBrowser);
|
|
9575
|
-
if (isOutputHTML() ? serializeReason || classHydration : serializeReason) (
|
|
9612
|
+
if (isOutputHTML() ? serializeReason || classHydration : serializeReason) pushCompatRegistration(classFile.metadata.marko.id, isOutputHTML() ? _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.callExpression((0, _marko_compiler_babel_utils.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"), [
|
|
9576
9613
|
_marko_compiler.types.stringLiteral(classFile.metadata.marko.id),
|
|
9577
9614
|
_marko_compiler.types.identifier(tagExpression.name),
|
|
9578
9615
|
...preserveBoundary ? [_marko_compiler.types.stringLiteral("preserve")] : []
|
|
9579
9616
|
]))], true) : _marko_compiler.types.expressionStatement(callRuntime("_resume", _marko_compiler.types.stringLiteral(classFile.metadata.marko.id), _marko_compiler.types.identifier(tagExpression.name))));
|
|
9580
|
-
} else
|
|
9617
|
+
} else {
|
|
9618
|
+
const rendererName = tagExpression.name;
|
|
9619
|
+
pushCompatRegistration(rendererName, _marko_compiler.types.markoScriptlet([_marko_compiler.types.expressionStatement(_marko_compiler.types.assignmentExpression("??=", _marko_compiler.types.memberExpression(_marko_compiler.types.identifier(rendererName), _marko_compiler.types.identifier("_")), _marko_compiler.types.identifier(rendererName)))], true));
|
|
9620
|
+
}
|
|
9581
9621
|
} else if (_marko_compiler.types.isStringLiteral(tagExpression)) tagExpression = (0, _marko_compiler_babel_utils.importDefault)(tag.hub.file, getTagRelativePath(tag), tagExpression.value);
|
|
9582
9622
|
const { properties, statements } = translateAttrs(tag, void 0, void 0, void 0, isClassAPI ? "renderBody" : "content");
|
|
9583
9623
|
const args = [];
|
|
9624
|
+
const contentProp = getTranslatedBodyContentProperty(properties);
|
|
9584
9625
|
let hasTagArgs = false;
|
|
9585
9626
|
if (node.arguments) {
|
|
9586
9627
|
hasTagArgs = true;
|
|
9587
9628
|
args.push(...node.arguments);
|
|
9588
9629
|
if (properties.length) args.push(propsToExpression(properties));
|
|
9589
|
-
} else {
|
|
9590
|
-
|
|
9591
|
-
|
|
9592
|
-
|
|
9593
|
-
args.push(propsToExpression(properties), contentProp.value);
|
|
9594
|
-
} else args.push(propsToExpression(properties));
|
|
9595
|
-
}
|
|
9630
|
+
} else if (contentProp) {
|
|
9631
|
+
properties.splice(properties.indexOf(contentProp), 1);
|
|
9632
|
+
args.push(propsToExpression(properties), contentProp.value);
|
|
9633
|
+
} else args.push(propsToExpression(properties));
|
|
9596
9634
|
if (isOutputHTML()) {
|
|
9597
9635
|
flushInto(tag);
|
|
9598
9636
|
writeHTMLResumeStatements(tag.get("body"));
|
|
9599
9637
|
const serializeArg = getSerializeGuard(tagSection, serializeReason, true);
|
|
9600
|
-
const dynamicTagExpr = hasTagArgs ? callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, _marko_compiler.types.arrayExpression(args), _marko_compiler.types.numericLiteral(0), _marko_compiler.types.numericLiteral(1), serializeArg) : callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, args[0], args[1] || (serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0), serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0, serializeArg);
|
|
9638
|
+
const dynamicTagExpr = hasTagArgs ? callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, _marko_compiler.types.arrayExpression(args), contentProp ? contentProp.value : _marko_compiler.types.numericLiteral(0), _marko_compiler.types.numericLiteral(1), serializeArg) : callRuntime("_dynamic_tag", getScopeIdIdentifier(tagSection), getScopeAccessorLiteral(nodeBinding), tagExpression, args[0], args[1] || (serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0), serializeArg ? _marko_compiler.types.numericLiteral(0) : void 0, serializeArg);
|
|
9601
9639
|
if (node.var) {
|
|
9602
9640
|
const dynamicScopeIdentifier = generateUidIdentifier(tag.get("name").toString() + "_scope");
|
|
9603
9641
|
const mutatesTagVar = !!(tag.node.var.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
|
@@ -5,6 +5,6 @@ declare module "@marko/compiler/dist/types" {
|
|
|
5
5
|
[kRawText]?: true;
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
-
export declare function bodyToTextLiteral(body: t.MarkoTagBody): t.
|
|
9
|
-
export declare function bodyToRawTextLiteral(body: t.MarkoTagBody): t.
|
|
8
|
+
export declare function bodyToTextLiteral(body: t.MarkoTagBody): t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.ObjectExpression | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression | t.MarkoParseError;
|
|
9
|
+
export declare function bodyToRawTextLiteral(body: t.MarkoTagBody): t.ArrayExpression | t.ArrowFunctionExpression | t.AssignmentExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.ObjectExpression | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression | t.MarkoParseError;
|
|
10
10
|
export declare function injectTextCoercion(expr: t.Expression): void;
|
|
@@ -125,6 +125,7 @@ export declare function setReferencesScope(path: t.NodePath<any>): void;
|
|
|
125
125
|
export declare function mergeReferences<T extends t.Node>(section: Section, target: T, nodes: (t.Node | undefined)[]): NonNullable<T["extra"]> & ReferencedExtra;
|
|
126
126
|
export declare function compareReferences(a: ReferencedBindings, b: ReferencedBindings): number;
|
|
127
127
|
export declare function finalizeReferences(): void;
|
|
128
|
+
export declare function dropReferencedBindings(expr: ReferencedExtra, drop: ReferencedBindings): boolean;
|
|
128
129
|
export declare const intersectionMeta: WeakMap<Intersection, {
|
|
129
130
|
id: number;
|
|
130
131
|
scopeOffset: Binding | undefined;
|
|
@@ -1,3 +1,2 @@
|
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
|
2
|
-
export declare function toFirstExpressionOrBlock(stmts: t.Statement[]): t.
|
|
3
|
-
export declare function toParenthesizedExpressionIfNeeded(expr: t.Expression): t.ArrayExpression | t.ArrowFunctionExpression | t.AwaitExpression | t.BigIntLiteral | t.BinaryExpression | t.BindExpression | t.BooleanLiteral | t.CallExpression | t.ClassExpression | t.ConditionalExpression | t.DecimalLiteral | t.DoExpression | t.FunctionExpression | t.Identifier | t.Import | t.ImportExpression | t.JSXElement | t.JSXFragment | t.LogicalExpression | t.MemberExpression | t.MetaProperty | t.ModuleExpression | t.NewExpression | t.NullLiteral | t.NumericLiteral | t.OptionalCallExpression | t.OptionalMemberExpression | t.ParenthesizedExpression | t.PipelineBareFunction | t.PipelinePrimaryTopicReference | t.PipelineTopicExpression | t.RecordExpression | t.RegExpLiteral | t.SequenceExpression | t.StringLiteral | t.Super | t.TSAsExpression | t.TSInstantiationExpression | t.TSNonNullExpression | t.TSSatisfiesExpression | t.TSTypeAssertion | t.TaggedTemplateExpression | t.TemplateLiteral | t.ThisExpression | t.TopicReference | t.TupleExpression | t.TypeCastExpression | t.UnaryExpression | t.UpdateExpression | t.YieldExpression | t.MarkoParseError;
|
|
2
|
+
export declare function toFirstExpressionOrBlock(stmts: t.Statement[]): t.BlockStatement | t.Expression;
|
|
@@ -6,7 +6,7 @@ export declare enum Step {
|
|
|
6
6
|
Enter = 0,
|
|
7
7
|
Exit = 1
|
|
8
8
|
}
|
|
9
|
-
type VisitCodes = WalkCode.Get | WalkCode.
|
|
9
|
+
type VisitCodes = WalkCode.Get | WalkCode.Replace | WalkCode.DynamicTagWithVar;
|
|
10
10
|
export declare function enter(path: t.NodePath<any>): void;
|
|
11
11
|
export declare function exit(path: t.NodePath<any>): void;
|
|
12
12
|
export declare function enterShallow(path: t.NodePath<any>): void;
|
|
@@ -14,5 +14,5 @@ interface SectionMeta {
|
|
|
14
14
|
}
|
|
15
15
|
export declare const getSectionMeta: (section: Section) => SectionMeta;
|
|
16
16
|
export declare function getSectionMetaIdentifiers(section: Section): SectionMeta;
|
|
17
|
-
export declare function markNode(path: t.NodePath<t.MarkoTag | t.MarkoPlaceholder>, nodeBinding: Binding, reason: undefined | false | SerializeReason): void;
|
|
17
|
+
export declare function markNode(path: t.NodePath<t.MarkoTag | t.MarkoPlaceholder>, nodeBinding: Binding, reason: undefined | false | SerializeReason, deferred?: boolean): void;
|
|
18
18
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.18",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -47,15 +47,16 @@
|
|
|
47
47
|
"!**/*.tsbuildinfo",
|
|
48
48
|
"cheatsheet.md"
|
|
49
49
|
],
|
|
50
|
-
"scripts": {
|
|
51
|
-
"build": "node -r ~ts ./scripts/bundle.mts"
|
|
52
|
-
},
|
|
53
50
|
"dependencies": {
|
|
54
|
-
"@marko/compiler": "^5.41.
|
|
51
|
+
"@marko/compiler": "^5.41.4",
|
|
55
52
|
"csstype": "^3.2.3",
|
|
56
53
|
"fastest-levenshtein": "^1.0.16",
|
|
57
54
|
"magic-string": "^0.30.21"
|
|
58
55
|
},
|
|
56
|
+
"devDependencies": {
|
|
57
|
+
"@marko/runtime-tags": "npm:marko@6.3.18",
|
|
58
|
+
"marko": "5.39.26"
|
|
59
|
+
},
|
|
59
60
|
"engines": {
|
|
60
61
|
"node": ">=22"
|
|
61
62
|
},
|
|
@@ -69,5 +70,8 @@
|
|
|
69
70
|
"./debug/*": "./src/*.ts",
|
|
70
71
|
"./*": "./src/*.ts"
|
|
71
72
|
},
|
|
72
|
-
"private": false
|
|
73
|
-
|
|
73
|
+
"private": false,
|
|
74
|
+
"scripts": {
|
|
75
|
+
"build": "node -r ~ts ./scripts/bundle.mts"
|
|
76
|
+
}
|
|
77
|
+
}
|