marko 6.3.42 → 6.3.44
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/cheatsheet.md +5 -4
- package/dist/debug/dom/catch.feat.js +1 -1
- package/dist/debug/dom/catch.feat.mjs +1 -1
- package/dist/debug/dom/controllable-input.feat.js +1 -1
- package/dist/debug/dom/controllable-input.feat.mjs +1 -1
- package/dist/debug/dom/controllable-open.feat.js +1 -1
- package/dist/debug/dom/controllable-open.feat.mjs +1 -1
- package/dist/debug/dom/controllable-select.feat.js +1 -1
- package/dist/debug/dom/controllable-select.feat.mjs +1 -1
- package/dist/debug/dom/controllable-textarea.feat.js +1 -1
- package/dist/debug/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/debug/dom/controllable.feat.js +1 -1
- package/dist/debug/dom/controllable.feat.mjs +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.js +1 -1
- package/dist/debug/dom/dynamic-tag-var.feat.mjs +1 -1
- package/dist/debug/dom/placeholder.feat.js +1 -1
- package/dist/debug/dom/placeholder.feat.mjs +1 -1
- package/dist/debug/{dom-BbtmY5_5.js → dom-DBuLwSOh.js} +10 -0
- package/dist/debug/{dom-DYV177a1.mjs → dom-ky42a_qY.mjs} +5 -1
- package/dist/debug/dom.js +2 -1
- package/dist/debug/dom.mjs +2 -2
- package/dist/dom/catch.feat.js +3 -3
- package/dist/dom/catch.feat.mjs +1 -1
- package/dist/dom/controllable-input.feat.js +1 -1
- package/dist/dom/controllable-input.feat.mjs +1 -1
- package/dist/dom/controllable-open.feat.js +1 -1
- package/dist/dom/controllable-open.feat.mjs +1 -1
- package/dist/dom/controllable-select.feat.js +1 -1
- package/dist/dom/controllable-select.feat.mjs +1 -1
- package/dist/dom/controllable-textarea.feat.js +1 -1
- package/dist/dom/controllable-textarea.feat.mjs +1 -1
- package/dist/dom/controllable.feat.js +1 -1
- package/dist/dom/controllable.feat.mjs +1 -1
- package/dist/dom/dynamic-tag-var.feat.js +2 -2
- package/dist/dom/dynamic-tag-var.feat.mjs +2 -2
- package/dist/dom/placeholder.feat.js +3 -3
- package/dist/dom/placeholder.feat.mjs +2 -2
- package/dist/dom/signals.d.ts +1 -0
- package/dist/{dom-BVNolGe1.mjs → dom-BSAs0ur8.mjs} +5 -2
- package/dist/{dom-BfloYt04.js → dom-DHJCbngT.js} +46 -38
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +21 -21
- package/dist/dom.mjs +2 -2
- package/dist/html.js +3 -3
- package/dist/html.mjs +3 -3
- package/dist/translator/index.js +59 -12
- package/dist/translator/util/constants/structure-kind.d.ts +1 -0
- package/dist/translator/util/sections.d.ts +5 -1
- package/dist/translator/util/structure.d.ts +1 -0
- package/dist/translator/util/tag-name-type.d.ts +1 -0
- package/dist/translator/visitors/tag/custom-tag.d.ts +1 -0
- package/package.json +4 -4
package/dist/translator/index.js
CHANGED
|
@@ -784,6 +784,7 @@ function isInvokedFunction(expr) {
|
|
|
784
784
|
//#endregion
|
|
785
785
|
//#region src/translator/util/constants/structure-kind.ts
|
|
786
786
|
const Visit = "visit";
|
|
787
|
+
const Text = "text";
|
|
787
788
|
const Child = "child";
|
|
788
789
|
const SectionRef = "sectionRef";
|
|
789
790
|
const ExportRef = "exportRef";
|
|
@@ -1322,6 +1323,7 @@ function createSectionState(key, init) {
|
|
|
1322
1323
|
//#endregion
|
|
1323
1324
|
//#region src/translator/util/tag-name-type.ts
|
|
1324
1325
|
const MARKO_FILE_REG = /^<.*>$|\.marko$/;
|
|
1326
|
+
const TAG_NAME_IDENTIFIER_REG$1 = /^[A-Z][a-zA-Z0-9_$]*$/;
|
|
1325
1327
|
function analyzeTagNameType(tag, allowDynamic) {
|
|
1326
1328
|
const extra = tag.node.extra ??= {};
|
|
1327
1329
|
if (extra.tagNameType === void 0) {
|
|
@@ -1348,6 +1350,8 @@ function analyzeTagNameType(tag, allowDynamic) {
|
|
|
1348
1350
|
} else if (!childFile) {
|
|
1349
1351
|
extra.tagNameType = 2;
|
|
1350
1352
|
extra.tagNameDynamic = true;
|
|
1353
|
+
const tagName = name.node.value;
|
|
1354
|
+
extra.tagNameUnresolved = !(TAG_NAME_IDENTIFIER_REG$1.test(tagName) && tag.scope.hasBinding(tagName));
|
|
1351
1355
|
}
|
|
1352
1356
|
}
|
|
1353
1357
|
}
|
|
@@ -2373,11 +2377,11 @@ let _dynamic_tag = (scopeId, accessor, tag, inputOrArgs, content, inputIsArgs, s
|
|
|
2373
2377
|
}
|
|
2374
2378
|
const childScope = getScopeById(branchId);
|
|
2375
2379
|
const needsScript = childScope && (childScope["EventAttributes:a"] || childScope["ControlledHandler:a"]);
|
|
2376
|
-
if (needsScript) _script(branchId, "
|
|
2380
|
+
if (needsScript) _script(branchId, "_d");
|
|
2377
2381
|
if (shouldResume || needsScript) _html(state.mark("'", scopeId + " " + accessor + " " + branchId));
|
|
2378
2382
|
};
|
|
2379
2383
|
renderNative();
|
|
2380
|
-
result = _el(branchId, "
|
|
2384
|
+
result = _el(branchId, "_e");
|
|
2381
2385
|
} else {
|
|
2382
2386
|
const chunk = void 0;
|
|
2383
2387
|
const beforeBranch = shouldResume ? deferBranchStart(chunk) : void 0;
|
|
@@ -3898,6 +3902,12 @@ function writeTo(path) {
|
|
|
3898
3902
|
}
|
|
3899
3903
|
};
|
|
3900
3904
|
}
|
|
3905
|
+
function writeTextTo(path, value) {
|
|
3906
|
+
if (value) getSection(path).structure?.push({
|
|
3907
|
+
kind: Text,
|
|
3908
|
+
value
|
|
3909
|
+
});
|
|
3910
|
+
}
|
|
3901
3911
|
function pushMarkup(structure, str) {
|
|
3902
3912
|
if (!str) return;
|
|
3903
3913
|
const last = structure.length - 1;
|
|
@@ -3923,17 +3933,31 @@ function resolveStructure(section) {
|
|
|
3923
3933
|
walkComment: [],
|
|
3924
3934
|
steps: startDynamic ? [0, 1] : []
|
|
3925
3935
|
};
|
|
3926
|
-
|
|
3927
|
-
|
|
3936
|
+
let textEdge;
|
|
3937
|
+
for (const op of section.structure) if (typeof op === "string") {
|
|
3938
|
+
appendLiteral(resolved.writes, op);
|
|
3939
|
+
textEdge = void 0;
|
|
3940
|
+
} else if (typeof op === "number") resolved.steps.push(op);
|
|
3928
3941
|
else switch (op.kind) {
|
|
3942
|
+
case Text:
|
|
3943
|
+
if (textEdge === "child") separate(resolved);
|
|
3944
|
+
appendLiteral(resolved.writes, op.value);
|
|
3945
|
+
textEdge = "own";
|
|
3946
|
+
break;
|
|
3929
3947
|
case Visit:
|
|
3930
3948
|
if (!op.claimed) continue;
|
|
3931
3949
|
flushSteps(resolved);
|
|
3932
3950
|
resolved.walkComment.push(walkCodeToName[op.code]);
|
|
3933
3951
|
appendLiteral(resolved.walks, String.fromCharCode(op.code));
|
|
3934
|
-
if (op.code !== 32)
|
|
3952
|
+
if (op.code !== 32) {
|
|
3953
|
+
appendLiteral(resolved.writes, "<!>");
|
|
3954
|
+
textEdge = void 0;
|
|
3955
|
+
}
|
|
3935
3956
|
break;
|
|
3936
3957
|
case Child: {
|
|
3958
|
+
const content = refContent(op.renderer);
|
|
3959
|
+
if (textEdge && content?.startType === 4) separate(resolved);
|
|
3960
|
+
textEdge = content?.endType === 4 ? "child" : void 0;
|
|
3937
3961
|
flushSteps(resolved);
|
|
3938
3962
|
const template = op.renderer && resolveRef(op.renderer, "template");
|
|
3939
3963
|
if (template) resolved.writes.push(template, "");
|
|
@@ -3952,6 +3976,13 @@ function resolveStructure(section) {
|
|
|
3952
3976
|
flushSteps(resolved);
|
|
3953
3977
|
return resolved;
|
|
3954
3978
|
}
|
|
3979
|
+
function separate(resolved) {
|
|
3980
|
+
appendLiteral(resolved.writes, "<!>");
|
|
3981
|
+
resolved.steps.push(0, 1);
|
|
3982
|
+
}
|
|
3983
|
+
function refContent(ref) {
|
|
3984
|
+
return (ref && (ref.kind === "sectionRef" ? ref.section : ref.program.section))?.content;
|
|
3985
|
+
}
|
|
3955
3986
|
function resolveRef(ref, part) {
|
|
3956
3987
|
if (ref.kind === "sectionRef") return getSectionMetaIdentifiers(ref.section)[part === "template" ? "writes" : "walks"];
|
|
3957
3988
|
const name = ref.program.domExports[part];
|
|
@@ -6057,7 +6088,8 @@ function preAnalyze$1(tag) {
|
|
|
6057
6088
|
const [firstChild] = tag.node.body.body;
|
|
6058
6089
|
if (firstChild.type === "MarkoText") firstChild.value = firstChild.value.replace(/^\r?\n/, "");
|
|
6059
6090
|
const parts = [];
|
|
6060
|
-
for (const child of tag.node.body.body) if (child.type === "MarkoText"
|
|
6091
|
+
for (const child of tag.node.body.body) if (child.type === "MarkoText") parts.push((0, _marko_compiler_babel_utils.decodeHTML)(child.value));
|
|
6092
|
+
else if (child.type === "MarkoPlaceholder" && child.escape) parts.push(child.value);
|
|
6061
6093
|
else throw tag.hub.file.hub.buildError(child, "Unexpected content in textarea, only text and placeholders are supported.", SyntaxError);
|
|
6062
6094
|
const textValue = normalizeStringExpression(parts);
|
|
6063
6095
|
if (textValue) {
|
|
@@ -9777,7 +9809,9 @@ var import_declaration_default = {
|
|
|
9777
9809
|
}
|
|
9778
9810
|
(node.extra ??= {}).loadImport = loadImport;
|
|
9779
9811
|
const { file } = importDecl.hub;
|
|
9780
|
-
|
|
9812
|
+
const loadFile = tagImport && (0, _marko_compiler_babel_utils.loadFileForImport)(file, value);
|
|
9813
|
+
if (!loadFile) throw importDecl.buildCodeFrameError("Unable to resolve marko file for load import.");
|
|
9814
|
+
if (loadFile.ast.program.extra?.featureType === "class") throw importDecl.buildCodeFrameError(`The [\`load\` import attribute](https://markojs.com/docs/reference/lazy-loading) is not supported for the Marko 5 (class API) tag \`${value}\`. Import it without \`load\`, or migrate the tag to the tags API.`);
|
|
9781
9815
|
}
|
|
9782
9816
|
},
|
|
9783
9817
|
translate: { exit(importDecl) {
|
|
@@ -9942,12 +9976,12 @@ var placeholder_default = {
|
|
|
9942
9976
|
const staticText = confident ? getHTMLRuntime()[node.escape ? "_escape" : "_unescaped"](computed) : void 0;
|
|
9943
9977
|
if (staticText === "") return;
|
|
9944
9978
|
const extra = node.extra || {};
|
|
9945
|
-
if (confident && node.escape)
|
|
9979
|
+
if (confident && node.escape) writeTextTo(placeholder, staticText);
|
|
9946
9980
|
else {
|
|
9947
9981
|
const siblingText = extra[kSiblingText];
|
|
9948
9982
|
if (siblingText === 1 || siblingText === 2) visit(placeholder, 37);
|
|
9949
9983
|
else {
|
|
9950
|
-
|
|
9984
|
+
writeTextTo(placeholder, " ");
|
|
9951
9985
|
visit(placeholder, 32);
|
|
9952
9986
|
}
|
|
9953
9987
|
}
|
|
@@ -10099,9 +10133,14 @@ var referenced_identifier_default = {
|
|
|
10099
10133
|
const { name } = identifier.node;
|
|
10100
10134
|
if (identifier.scope.hasBinding(name)) return;
|
|
10101
10135
|
switch (name) {
|
|
10102
|
-
case "$global":
|
|
10103
|
-
if (
|
|
10136
|
+
case "$global": {
|
|
10137
|
+
if (isOutputHTML()) break;
|
|
10138
|
+
const globalRead = _marko_compiler.types.memberExpression(scopeIdentifier, _marko_compiler.types.identifier(getAccessorProp().Global));
|
|
10139
|
+
const key = !isOptimize() && getSignalGlobalKey(identifier);
|
|
10140
|
+
if (key) identifier.parentPath.replaceWith(callRuntime("_global_read", globalRead, _marko_compiler.types.stringLiteral(key)));
|
|
10141
|
+
else identifier.replaceWith(globalRead);
|
|
10104
10142
|
break;
|
|
10143
|
+
}
|
|
10105
10144
|
case "$signal": if (isOutputHTML()) identifier.replaceWith(_marko_compiler.types.callExpression(_marko_compiler.types.arrowFunctionExpression([], _marko_compiler.types.blockStatement([_marko_compiler.types.throwStatement(_marko_compiler.types.newExpression(_marko_compiler.types.identifier("Error"), [_marko_compiler.types.stringLiteral("Cannot use $signal in a server render.")]))])), []));
|
|
10106
10145
|
else {
|
|
10107
10146
|
const section = getSection(identifier);
|
|
@@ -10117,6 +10156,13 @@ var referenced_identifier_default = {
|
|
|
10117
10156
|
}
|
|
10118
10157
|
}
|
|
10119
10158
|
};
|
|
10159
|
+
function getSignalGlobalKey(identifier) {
|
|
10160
|
+
const { parent } = identifier;
|
|
10161
|
+
if (!_marko_compiler.types.isMemberExpression(parent) || parent.computed || !_marko_compiler.types.isIdentifier(parent.property) || parent.object !== identifier.node) return;
|
|
10162
|
+
const { name } = parent.property;
|
|
10163
|
+
if (name === "runtimeId" || name === "renderId") return;
|
|
10164
|
+
return getExprRoot(identifier).node.extra?.referencedBindings ? name : void 0;
|
|
10165
|
+
}
|
|
10120
10166
|
//#endregion
|
|
10121
10167
|
//#region src/translator/visitors/scriptlet.ts
|
|
10122
10168
|
var scriptlet_default = {
|
|
@@ -10375,6 +10421,7 @@ function pushCompatRegistration(key, statement) {
|
|
|
10375
10421
|
}
|
|
10376
10422
|
var dynamic_tag_default = {
|
|
10377
10423
|
analyze: { enter(tag) {
|
|
10424
|
+
if (tag.node.extra?.tagNameUnresolved) throw tagNotFoundError(tag);
|
|
10378
10425
|
(0, _marko_compiler_babel_utils.assertAttributesOrArgs)(tag);
|
|
10379
10426
|
const { node } = tag;
|
|
10380
10427
|
const definedBodySection = node.extra?.defineBodySection;
|
|
@@ -10659,7 +10706,7 @@ var tag_default = {
|
|
|
10659
10706
|
var text_default = {
|
|
10660
10707
|
analyze: { exit(text) {
|
|
10661
10708
|
if (isNonHTMLText(text)) return;
|
|
10662
|
-
|
|
10709
|
+
writeTextTo(text, text.node.value);
|
|
10663
10710
|
if (!isStaticText(getPrevStaticSibling(text))) enterShallow(text);
|
|
10664
10711
|
} },
|
|
10665
10712
|
translate: { exit(text) {
|
|
@@ -28,7 +28,11 @@ export interface StructureExportRef {
|
|
|
28
28
|
path: string;
|
|
29
29
|
hint: string;
|
|
30
30
|
}
|
|
31
|
-
export type StructureOp = string | Step.Value | StructureVisit | StructureChild;
|
|
31
|
+
export type StructureOp = string | Step.Value | StructureText | StructureVisit | StructureChild;
|
|
32
|
+
export interface StructureText {
|
|
33
|
+
kind: typeof StructureKind.Text;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
32
36
|
export interface StructureVisit {
|
|
33
37
|
kind: typeof StructureKind.Visit;
|
|
34
38
|
code: typeof WalkCode.Get | typeof WalkCode.Replace | typeof WalkCode.DynamicTagWithVar;
|
|
@@ -6,6 +6,7 @@ export declare function exit(path: t.NodePath<any>): void;
|
|
|
6
6
|
export declare function enterShallow(path: t.NodePath<any>): void;
|
|
7
7
|
export declare function child(tag: t.NodePath<t.MarkoTag>, name: string, renderer?: StructureRef): void;
|
|
8
8
|
export declare function writeTo(path: t.NodePath<any>): (strs: TemplateStringsArray, ...exprs: string[]) => void;
|
|
9
|
+
export declare function writeTextTo(path: t.NodePath<any>, value: string): void;
|
|
9
10
|
export declare function visit(path: t.NodePath<t.MarkoTag | t.MarkoPlaceholder | t.Program>, code: StructureVisit["code"], claimed?: boolean): StructureVisit | undefined;
|
|
10
11
|
type ResolvedPart = string | t.Expression;
|
|
11
12
|
interface ResolvedStructure {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "marko",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.44",
|
|
4
4
|
"description": "Optimized runtime for Marko templates.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"api",
|
|
@@ -51,14 +51,14 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"@marko/compiler": "^5.42.
|
|
54
|
+
"@marko/compiler": "^5.42.2",
|
|
55
55
|
"csstype": "^3.2.3",
|
|
56
56
|
"fastest-levenshtein": "^1.0.16",
|
|
57
57
|
"magic-string": "^0.30.21"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@marko/runtime-tags": "npm:marko@6.3.
|
|
61
|
-
"marko": "5.39.
|
|
60
|
+
"@marko/runtime-tags": "npm:marko@6.3.44",
|
|
61
|
+
"marko": "5.39.36"
|
|
62
62
|
},
|
|
63
63
|
"engines": {
|
|
64
64
|
"node": ">=22"
|