@marko/runtime-tags 6.2.1 → 6.2.3
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
CHANGED
|
@@ -1002,7 +1002,7 @@ function writeArrayBuffer(state, val) {
|
|
|
1002
1002
|
return true;
|
|
1003
1003
|
}
|
|
1004
1004
|
function writeTypedArray(state, val, ref) {
|
|
1005
|
-
if (val.byteOffset || state.refs.has(val.buffer)) {
|
|
1005
|
+
if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
|
|
1006
1006
|
const needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
1007
1007
|
state.buf.push("new " + val.constructor.name + "(");
|
|
1008
1008
|
writeProp(state, val.buffer, ref, "buffer");
|
package/dist/debug/html.mjs
CHANGED
|
@@ -1000,7 +1000,7 @@ function writeArrayBuffer(state, val) {
|
|
|
1000
1000
|
return true;
|
|
1001
1001
|
}
|
|
1002
1002
|
function writeTypedArray(state, val, ref) {
|
|
1003
|
-
if (val.byteOffset || state.refs.has(val.buffer)) {
|
|
1003
|
+
if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
|
|
1004
1004
|
const needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
1005
1005
|
state.buf.push("new " + val.constructor.name + "(");
|
|
1006
1006
|
writeProp(state, val.buffer, ref, "buffer");
|
package/dist/html.js
CHANGED
|
@@ -755,7 +755,7 @@ function writeArrayBuffer(state, val) {
|
|
|
755
755
|
return state.buf.push(result), !0;
|
|
756
756
|
}
|
|
757
757
|
function writeTypedArray(state, val, ref) {
|
|
758
|
-
if (val.byteOffset || state.refs.has(val.buffer)) {
|
|
758
|
+
if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
|
|
759
759
|
let needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
760
760
|
state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
|
|
761
761
|
} else state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null)), state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
|
package/dist/html.mjs
CHANGED
|
@@ -754,7 +754,7 @@ function writeArrayBuffer(state, val) {
|
|
|
754
754
|
return state.buf.push(result), !0;
|
|
755
755
|
}
|
|
756
756
|
function writeTypedArray(state, val, ref) {
|
|
757
|
-
if (val.byteOffset || state.refs.has(val.buffer)) {
|
|
757
|
+
if (val.byteOffset || val.byteLength < val.buffer.byteLength || state.refs.has(val.buffer)) {
|
|
758
758
|
let needsLength = val.byteOffset + val.byteLength < val.buffer.byteLength;
|
|
759
759
|
state.buf.push("new " + val.constructor.name + "("), writeProp(state, val.buffer, ref, "buffer"), state.buf.push((val.byteOffset || needsLength ? "," + val.byteOffset + (needsLength ? "," + val.length : "") : "") + ")");
|
|
760
760
|
} else state.refs.set(val.buffer, new Reference(ref, "buffer", state.flush, null)), state.buf.push("new " + val.constructor.name + (val.length === 0 ? "" : "(" + (hasOnlyZeros(val) ? val.length : typedArrayToInitString(val)) + ")"));
|
package/dist/translator/index.js
CHANGED
|
@@ -2443,10 +2443,10 @@ function normalizeStringExpression(parts, useIife) {
|
|
|
2443
2443
|
const exprLen = content.expressions.length;
|
|
2444
2444
|
shiftItems(parts, nextIndex, content.quasis.length + exprLen);
|
|
2445
2445
|
for (let j = 0; j < exprLen; j++) {
|
|
2446
|
-
parts[nextIndex++] = content.quasis[j].value.
|
|
2446
|
+
parts[nextIndex++] = content.quasis[j].value.cooked ?? "";
|
|
2447
2447
|
parts[nextIndex++] = content.expressions[j];
|
|
2448
2448
|
}
|
|
2449
|
-
parts[nextIndex] = content.quasis[exprLen].value.
|
|
2449
|
+
parts[nextIndex] = content.quasis[exprLen].value.cooked ?? "";
|
|
2450
2450
|
continue;
|
|
2451
2451
|
} else {
|
|
2452
2452
|
exprs.push(content);
|
|
@@ -3834,7 +3834,7 @@ var html_default = { translate: {
|
|
|
3834
3834
|
else child.replaceWithMultiple(child.node.body);
|
|
3835
3835
|
const contentId = usedSharedUid("content") && getTemplateContentName();
|
|
3836
3836
|
const contentFn = _marko_compiler.types.arrowFunctionExpression([_marko_compiler.types.identifier("input")], _marko_compiler.types.blockStatement(renderContent));
|
|
3837
|
-
const exportDefault = _marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(program.hub.file.metadata.marko.id), contentId ? _marko_compiler.types.identifier(contentId) : contentFn, program.node.extra.page ? _marko_compiler.types.numericLiteral(1) : void 0));
|
|
3837
|
+
const exportDefault = _marko_compiler.types.exportDefaultDeclaration(callRuntime("_template", _marko_compiler.types.stringLiteral(program.hub.file.metadata.marko.id), contentId ? _marko_compiler.types.identifier(contentId) : contentFn, program.node.extra.page || !getMarkoOpts().linkAssets ? _marko_compiler.types.numericLiteral(1) : void 0));
|
|
3838
3838
|
if (contentId) program.node.body.push(_marko_compiler.types.variableDeclaration("const", [_marko_compiler.types.variableDeclarator(_marko_compiler.types.identifier(contentId), contentFn)]), exportDefault);
|
|
3839
3839
|
else program.node.body.push(exportDefault);
|
|
3840
3840
|
}
|
|
@@ -3862,15 +3862,15 @@ function replaceRegisteredFunctionNode(node) {
|
|
|
3862
3862
|
switch (node.type) {
|
|
3863
3863
|
case "ClassMethod": {
|
|
3864
3864
|
const replacement = getRegisteredFnExpression(node);
|
|
3865
|
-
return replacement && _marko_compiler.types.classProperty(node.key, replacement);
|
|
3865
|
+
return replacement && _marko_compiler.types.classProperty(node.key, replacement, void 0, void 0, node.computed, node.static);
|
|
3866
3866
|
}
|
|
3867
3867
|
case "ClassPrivateMethod": {
|
|
3868
3868
|
const replacement = getRegisteredFnExpression(node);
|
|
3869
|
-
return replacement && _marko_compiler.types.classPrivateProperty(node.key, replacement);
|
|
3869
|
+
return replacement && _marko_compiler.types.classPrivateProperty(node.key, replacement, void 0, node.static);
|
|
3870
3870
|
}
|
|
3871
3871
|
case "ObjectMethod": {
|
|
3872
3872
|
const replacement = getRegisteredFnExpression(node);
|
|
3873
|
-
return replacement && _marko_compiler.types.objectProperty(node.key, replacement);
|
|
3873
|
+
return replacement && _marko_compiler.types.objectProperty(node.key, replacement, node.computed);
|
|
3874
3874
|
}
|
|
3875
3875
|
case "ArrowFunctionExpression":
|
|
3876
3876
|
case "FunctionExpression": return getRegisteredFnExpression(node);
|
|
@@ -3983,6 +3983,9 @@ var for_default = {
|
|
|
3983
3983
|
if (!isAttrTag) allowAttrs.push("by");
|
|
3984
3984
|
(0, _marko_compiler_babel_utils.assertAllowedAttributes)(tag, allowAttrs);
|
|
3985
3985
|
if (isAttrTag) return;
|
|
3986
|
+
if (forType !== "of") {
|
|
3987
|
+
if (getKnownAttrValues(tag.node).by?.type === "StringLiteral") throw (tag.get("attributes").find((attr) => attr.isMarkoAttribute() && attr.node.name === "by") || tag).buildCodeFrameError(`The [\`<for>\` tag](https://markojs.com/docs/reference/core-tag#for) only supports a string \`by\` key with \`of\`; use a \`by=(${forType === "in" ? "key, value" : "index"}) => ...\` function for \`<for ${forType}>\`.`);
|
|
3988
|
+
}
|
|
3986
3989
|
const bodySection = startSection(tagBody);
|
|
3987
3990
|
if (!bodySection) {
|
|
3988
3991
|
dropNodes(getAllTagReferenceNodes(tag.node));
|
|
@@ -6704,7 +6707,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
6704
6707
|
if (element) {
|
|
6705
6708
|
if (element.type === "RestElement") {
|
|
6706
6709
|
excludeProperties = i > 0 ? addNumericPropertiesUntil(excludeProperties, i) : void 0;
|
|
6707
|
-
createBindingsAndTrackReferences(element.argument, type, scope, section, patternBinding,
|
|
6710
|
+
createBindingsAndTrackReferences(element.argument, type, scope, section, patternBinding, void 0, excludeProperties, i);
|
|
6708
6711
|
} else if (_marko_compiler.types.isLVal(element)) createBindingsAndTrackReferences(element, type, scope, section, patternBinding, `${i}`, void 0);
|
|
6709
6712
|
}
|
|
6710
6713
|
}
|
|
@@ -9070,10 +9073,32 @@ function parseTriggerType(type) {
|
|
|
9070
9073
|
}
|
|
9071
9074
|
}
|
|
9072
9075
|
//#endregion
|
|
9076
|
+
//#region src/translator/util/static-text.ts
|
|
9077
|
+
function isStaticText(node) {
|
|
9078
|
+
switch (node?.type) {
|
|
9079
|
+
case "MarkoText": return true;
|
|
9080
|
+
case "MarkoPlaceholder":
|
|
9081
|
+
if (node.escape) {
|
|
9082
|
+
const { confident, computed } = evaluate(node.value);
|
|
9083
|
+
return confident && isNotVoid(computed);
|
|
9084
|
+
}
|
|
9085
|
+
return false;
|
|
9086
|
+
}
|
|
9087
|
+
}
|
|
9088
|
+
function getPrevStaticSibling(path) {
|
|
9089
|
+
let prev = path.getPrevSibling();
|
|
9090
|
+
while (prev.node && (prev.isMarkoComment() || prev.isMarkoPlaceholder() && isEmptyPlaceholder(prev.node))) prev = prev.getPrevSibling();
|
|
9091
|
+
return prev.node;
|
|
9092
|
+
}
|
|
9093
|
+
function isEmptyPlaceholder(placeholder) {
|
|
9094
|
+
const { confident, computed } = evaluate(placeholder.value);
|
|
9095
|
+
return confident && isVoid(computed);
|
|
9096
|
+
}
|
|
9097
|
+
//#endregion
|
|
9073
9098
|
//#region src/translator/visitors/placeholder.ts
|
|
9074
9099
|
const kNodeBinding = Symbol("placeholder node binding");
|
|
9075
9100
|
const kSiblingText = Symbol("placeholder has sibling text");
|
|
9076
|
-
const kSharedText = Symbol("placeholder will merge its visitor with a another node");
|
|
9101
|
+
const kSharedText$1 = Symbol("placeholder will merge its visitor with a another node");
|
|
9077
9102
|
var placeholder_default = {
|
|
9078
9103
|
analyze(placeholder) {
|
|
9079
9104
|
if (isNonHTMLText(placeholder)) return;
|
|
@@ -9082,7 +9107,7 @@ var placeholder_default = {
|
|
|
9082
9107
|
const { confident, computed } = valueExtra;
|
|
9083
9108
|
if (confident && isVoid(computed)) return;
|
|
9084
9109
|
if (isStaticText(node)) {
|
|
9085
|
-
if (isStaticText(
|
|
9110
|
+
if (isStaticText(getPrevStaticSibling(placeholder))) (node.extra ??= {})[kSharedText$1] = true;
|
|
9086
9111
|
} else {
|
|
9087
9112
|
const section = getOrCreateSection(placeholder);
|
|
9088
9113
|
const nodeBinding = (node.extra ??= {})[kNodeBinding] = createBinding("#text", 0, section);
|
|
@@ -9126,7 +9151,7 @@ var placeholder_default = {
|
|
|
9126
9151
|
if (nodeBinding) markNode(placeholder, nodeBinding, markerSerializeReason);
|
|
9127
9152
|
} else addStatement("render", section, valueExtra.referencedBindings, _marko_compiler.types.expressionStatement(method === "_text" ? callRuntime("_text", createScopeReadExpression(nodeBinding), value) : callRuntime("_html", scopeIdentifier, value, getScopeAccessorLiteral(nodeBinding))), void 0, true);
|
|
9128
9153
|
}
|
|
9129
|
-
if (!extra[kSharedText]) enterShallow(placeholder);
|
|
9154
|
+
if (!extra[kSharedText$1]) enterShallow(placeholder);
|
|
9130
9155
|
placeholder.remove();
|
|
9131
9156
|
} }
|
|
9132
9157
|
};
|
|
@@ -9196,29 +9221,6 @@ function getInlinedBodyTag(parent) {
|
|
|
9196
9221
|
if (tag.isMarkoTag() && isCoreTagName(tag, "show")) return tag;
|
|
9197
9222
|
}
|
|
9198
9223
|
}
|
|
9199
|
-
function isStaticText(node) {
|
|
9200
|
-
switch (node?.type) {
|
|
9201
|
-
case "MarkoText": return true;
|
|
9202
|
-
case "MarkoPlaceholder": if (node.escape) {
|
|
9203
|
-
const { confident, computed } = evaluate(node.value);
|
|
9204
|
-
return confident && isNotVoid(computed);
|
|
9205
|
-
} else return false;
|
|
9206
|
-
}
|
|
9207
|
-
}
|
|
9208
|
-
function getPrev(path) {
|
|
9209
|
-
let prev = path.getPrevSibling();
|
|
9210
|
-
while (prev.node && (prev.isMarkoComment() || prev.isMarkoPlaceholder() && isEmptyPlaceholder(prev.node))) prev = prev.getPrevSibling();
|
|
9211
|
-
return prev.node;
|
|
9212
|
-
}
|
|
9213
|
-
function getNext(path) {
|
|
9214
|
-
let next = path.getNextSibling();
|
|
9215
|
-
while (next.node && (next.isMarkoComment() || next.isMarkoPlaceholder() && isEmptyPlaceholder(next.node))) next = next.getNextSibling();
|
|
9216
|
-
return next.node;
|
|
9217
|
-
}
|
|
9218
|
-
function isEmptyPlaceholder(placeholder) {
|
|
9219
|
-
const { confident, computed } = evaluate(placeholder.value);
|
|
9220
|
-
return confident && isVoid(computed);
|
|
9221
|
-
}
|
|
9222
9224
|
//#endregion
|
|
9223
9225
|
//#region src/translator/visitors/referenced-identifier.ts
|
|
9224
9226
|
const abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
|
@@ -9728,12 +9730,19 @@ var tag_default = {
|
|
|
9728
9730
|
};
|
|
9729
9731
|
//#endregion
|
|
9730
9732
|
//#region src/translator/visitors/text.ts
|
|
9731
|
-
|
|
9732
|
-
|
|
9733
|
-
|
|
9734
|
-
|
|
9735
|
-
|
|
9736
|
-
}
|
|
9733
|
+
const kSharedText = Symbol("text merges its walk step with a sibling node");
|
|
9734
|
+
var text_default = {
|
|
9735
|
+
analyze(text) {
|
|
9736
|
+
if (isNonHTMLText(text)) return;
|
|
9737
|
+
if (isStaticText(getPrevStaticSibling(text))) (text.node.extra ??= {})[kSharedText] = true;
|
|
9738
|
+
},
|
|
9739
|
+
translate: { exit(text) {
|
|
9740
|
+
if (isNonHTMLText(text)) return;
|
|
9741
|
+
writeTo(text)`${text.node.value}`;
|
|
9742
|
+
if (!text.node.extra?.[kSharedText]) enterShallow(text);
|
|
9743
|
+
text.remove();
|
|
9744
|
+
} }
|
|
9745
|
+
};
|
|
9737
9746
|
//#endregion
|
|
9738
9747
|
//#region src/translator/interop/build-aggregate-error.ts
|
|
9739
9748
|
function buildAggregateError(file, rootMsg, ...paths) {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
|
2
|
+
declare const kSharedText: unique symbol;
|
|
3
|
+
declare module "@marko/compiler/dist/types" {
|
|
4
|
+
interface NodeExtra {
|
|
5
|
+
[kSharedText]?: true;
|
|
6
|
+
}
|
|
7
|
+
}
|
|
2
8
|
declare const _default: {
|
|
9
|
+
analyze(this: unknown, text: t.NodePath<t.MarkoText>): void;
|
|
3
10
|
translate: {
|
|
4
11
|
exit(this: unknown, text: t.NodePath<t.MarkoText>): void;
|
|
5
12
|
};
|