marko 6.0.117 → 6.0.118
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 +4 -0
- package/dist/debug/dom.mjs +4 -0
- package/dist/debug/html.js +4 -4
- package/dist/debug/html.mjs +3 -3
- package/dist/dom/dom.d.ts +1 -0
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +4 -0
- package/dist/dom.mjs +4 -0
- package/dist/html/content.d.ts +1 -1
- package/dist/html.d.ts +1 -1
- package/dist/html.js +4 -4
- package/dist/html.mjs +3 -3
- package/dist/translator/core/html-script.d.ts +1 -8
- package/dist/translator/core/html-style.d.ts +1 -8
- package/dist/translator/core/index.d.ts +0 -2
- package/dist/translator/core/textarea.d.ts +2 -3
- package/dist/translator/index.d.ts +0 -2
- package/dist/translator/index.js +834 -1755
- package/dist/translator/util/is-non-html-text.d.ts +1 -0
- package/dist/translator/util/runtime.d.ts +4 -2
- package/package.json +2 -2
- package/tags/html-comment.d.marko +1 -0
- package/tags/html-script.d.marko +1 -0
- package/tags/html-style.d.marko +1 -0
- package/dist/translator/core/title.d.ts +0 -10
package/dist/translator/index.js
CHANGED
|
@@ -112,8 +112,8 @@ var attrs_default = {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
// src/translator/core/await.ts
|
|
115
|
-
var
|
|
116
|
-
var
|
|
115
|
+
var import_compiler39 = require("@marko/compiler");
|
|
116
|
+
var import_babel_utils27 = require("@marko/compiler/babel-utils");
|
|
117
117
|
|
|
118
118
|
// src/common/accessor.debug.ts
|
|
119
119
|
var AccessorPrefix = /* @__PURE__ */ ((AccessorPrefix4) => {
|
|
@@ -248,8 +248,8 @@ function isNullableExpr(expr) {
|
|
|
248
248
|
}
|
|
249
249
|
|
|
250
250
|
// src/translator/util/references.ts
|
|
251
|
-
var
|
|
252
|
-
var
|
|
251
|
+
var import_compiler38 = require("@marko/compiler");
|
|
252
|
+
var import_babel_utils26 = require("@marko/compiler/babel-utils");
|
|
253
253
|
|
|
254
254
|
// src/common/helpers.ts
|
|
255
255
|
function classValue(classValue2) {
|
|
@@ -856,7 +856,16 @@ var import_babel_utils6 = require("@marko/compiler/babel-utils");
|
|
|
856
856
|
|
|
857
857
|
// src/translator/util/get-tag-name.ts
|
|
858
858
|
function getTagName(tag) {
|
|
859
|
-
|
|
859
|
+
switch (tag.node.name.type) {
|
|
860
|
+
case "StringLiteral":
|
|
861
|
+
return tag.node.name.value;
|
|
862
|
+
case "TemplateLiteral":
|
|
863
|
+
if (tag.node.name.quasis.length === 1) {
|
|
864
|
+
return tag.node.name.quasis[0].value.raw;
|
|
865
|
+
}
|
|
866
|
+
break;
|
|
867
|
+
}
|
|
868
|
+
return void 0;
|
|
860
869
|
}
|
|
861
870
|
|
|
862
871
|
// src/translator/util/is-core-tag.ts
|
|
@@ -869,13 +878,7 @@ function isCoreTag(tag) {
|
|
|
869
878
|
if (tagDef) {
|
|
870
879
|
switch (tagDef.taglibId) {
|
|
871
880
|
case taglibId:
|
|
872
|
-
return true;
|
|
873
881
|
case interopTaglibId:
|
|
874
|
-
switch (tagDef.name) {
|
|
875
|
-
// The body tag is registered in the v5 translator, without this it'd be seen as a core tag.
|
|
876
|
-
case "body":
|
|
877
|
-
return false;
|
|
878
|
-
}
|
|
879
882
|
return true;
|
|
880
883
|
case htmlTaglibId:
|
|
881
884
|
switch (tagDef.name) {
|
|
@@ -1598,7 +1601,7 @@ function analyzeTagNameType(tag, allowDynamic) {
|
|
|
1598
1601
|
if (name2.isStringLiteral()) {
|
|
1599
1602
|
extra.tagNameType = name2.node.value[0] === "@" ? 3 /* AttributeTag */ : (0, import_babel_utils9.isNativeTag)(tag) ? 0 /* NativeTag */ : 1 /* CustomTag */;
|
|
1600
1603
|
extra.tagNameNullable = extra.tagNameDynamic = false;
|
|
1601
|
-
} else if (name2.isTemplateLiteral() &&
|
|
1604
|
+
} else if (name2.isTemplateLiteral() && name2.node.quasis.length === 1) {
|
|
1602
1605
|
extra.tagNameType = 0 /* NativeTag */;
|
|
1603
1606
|
extra.tagNameNullable = extra.tagNameDynamic = false;
|
|
1604
1607
|
} else if (name2.isIdentifier()) {
|
|
@@ -1839,7 +1842,6 @@ function getNodeContentType(path5, extraMember, contentInfo) {
|
|
|
1839
1842
|
return 0 /* Comment */;
|
|
1840
1843
|
case "html-script":
|
|
1841
1844
|
case "html-style":
|
|
1842
|
-
case "title":
|
|
1843
1845
|
return 3 /* Tag */;
|
|
1844
1846
|
case "for":
|
|
1845
1847
|
case "if":
|
|
@@ -1993,7 +1995,6 @@ function isNativeNode(tag) {
|
|
|
1993
1995
|
case "html-comment":
|
|
1994
1996
|
case "html-script":
|
|
1995
1997
|
case "html-style":
|
|
1996
|
-
case "title":
|
|
1997
1998
|
return true;
|
|
1998
1999
|
default:
|
|
1999
2000
|
return false;
|
|
@@ -2217,11 +2218,11 @@ function isEventOrChangeHandler(prop) {
|
|
|
2217
2218
|
}
|
|
2218
2219
|
|
|
2219
2220
|
// src/translator/util/known-tag.ts
|
|
2220
|
-
var
|
|
2221
|
-
var
|
|
2221
|
+
var import_compiler37 = require("@marko/compiler");
|
|
2222
|
+
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
|
2222
2223
|
|
|
2223
2224
|
// src/translator/visitors/program/index.ts
|
|
2224
|
-
var
|
|
2225
|
+
var import_compiler27 = require("@marko/compiler");
|
|
2225
2226
|
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
|
2226
2227
|
var import_path2 = __toESM(require("path"));
|
|
2227
2228
|
|
|
@@ -4783,7 +4784,31 @@ function getRegisteredFnExpression2(node) {
|
|
|
4783
4784
|
}
|
|
4784
4785
|
|
|
4785
4786
|
// src/translator/visitors/program/pre-analyze.ts
|
|
4787
|
+
var import_compiler26 = require("@marko/compiler");
|
|
4788
|
+
|
|
4789
|
+
// src/translator/core/textarea.ts
|
|
4786
4790
|
var import_compiler25 = require("@marko/compiler");
|
|
4791
|
+
function preAnalyze(tag) {
|
|
4792
|
+
if (tag.node.body.body.length) {
|
|
4793
|
+
const parts = [];
|
|
4794
|
+
for (const child of tag.node.body.body) {
|
|
4795
|
+
if (child.type === "MarkoText" || child.type === "MarkoPlaceholder" && child.escape) {
|
|
4796
|
+
parts.push(child.value);
|
|
4797
|
+
} else {
|
|
4798
|
+
throw tag.hub.file.hub.buildError(
|
|
4799
|
+
child,
|
|
4800
|
+
"Unexpected content in textarea, only text and placeholders are supported.",
|
|
4801
|
+
SyntaxError
|
|
4802
|
+
);
|
|
4803
|
+
}
|
|
4804
|
+
}
|
|
4805
|
+
const textValue = normalizeStringExpression(parts);
|
|
4806
|
+
if (textValue) {
|
|
4807
|
+
tag.node.attributes.push(import_compiler25.types.markoAttribute("value", textValue));
|
|
4808
|
+
}
|
|
4809
|
+
tag.node.body.body = [];
|
|
4810
|
+
}
|
|
4811
|
+
}
|
|
4787
4812
|
|
|
4788
4813
|
// src/translator/util/with-previous-location.ts
|
|
4789
4814
|
function withPreviousLocation(newNode, originalNode) {
|
|
@@ -4796,7 +4821,7 @@ function withPreviousLocation(newNode, originalNode) {
|
|
|
4796
4821
|
// src/translator/visitors/program/pre-analyze.ts
|
|
4797
4822
|
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
|
4798
4823
|
var BINDING_CHANGE_HANDLER = /* @__PURE__ */ new WeakMap();
|
|
4799
|
-
function
|
|
4824
|
+
function preAnalyze2(program) {
|
|
4800
4825
|
const state = { crawl: false };
|
|
4801
4826
|
normalizeBody(state, program.get("body"));
|
|
4802
4827
|
if (state.crawl) {
|
|
@@ -4838,12 +4863,18 @@ function normalizeTag(state, tag) {
|
|
|
4838
4863
|
const tagName = name2.value;
|
|
4839
4864
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
|
4840
4865
|
state.crawl = true;
|
|
4841
|
-
node.name = withPreviousLocation(
|
|
4866
|
+
node.name = withPreviousLocation(import_compiler26.types.identifier(tagName), name2);
|
|
4867
|
+
} else {
|
|
4868
|
+
switch (tagName) {
|
|
4869
|
+
case "textarea":
|
|
4870
|
+
preAnalyze(tag);
|
|
4871
|
+
break;
|
|
4872
|
+
}
|
|
4842
4873
|
}
|
|
4843
4874
|
}
|
|
4844
4875
|
for (let i = 0; i < attributes.length; i++) {
|
|
4845
4876
|
const attr = attributes[i];
|
|
4846
|
-
if (
|
|
4877
|
+
if (import_compiler26.types.isMarkoAttribute(attr) && attr.bound) {
|
|
4847
4878
|
state.crawl = true;
|
|
4848
4879
|
attr.bound = false;
|
|
4849
4880
|
attributes.splice(++i, 0, getChangeHandler(tag, attr));
|
|
@@ -4853,10 +4884,10 @@ function normalizeTag(state, tag) {
|
|
|
4853
4884
|
function getChangeHandler(tag, attr) {
|
|
4854
4885
|
const attrName = attr.name;
|
|
4855
4886
|
const changeAttrName = attrName + "Change";
|
|
4856
|
-
if (
|
|
4887
|
+
if (import_compiler26.types.isIdentifier(attr.value)) {
|
|
4857
4888
|
const binding = tag.scope.getBinding(attr.value.name);
|
|
4858
4889
|
if (!binding)
|
|
4859
|
-
return
|
|
4890
|
+
return import_compiler26.types.markoAttribute(
|
|
4860
4891
|
changeAttrName,
|
|
4861
4892
|
buildChangeHandlerFunction(attr.value)
|
|
4862
4893
|
);
|
|
@@ -4869,7 +4900,7 @@ function getChangeHandler(tag, attr) {
|
|
|
4869
4900
|
if (!changeAttrExpr) {
|
|
4870
4901
|
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
4871
4902
|
}
|
|
4872
|
-
const changeHandlerAttr =
|
|
4903
|
+
const changeHandlerAttr = import_compiler26.types.markoAttribute(
|
|
4873
4904
|
changeAttrName,
|
|
4874
4905
|
changeAttrExpr
|
|
4875
4906
|
);
|
|
@@ -4877,10 +4908,10 @@ function getChangeHandler(tag, attr) {
|
|
|
4877
4908
|
return changeHandlerAttr;
|
|
4878
4909
|
}
|
|
4879
4910
|
if (existingChangedAttr.type === "Identifier") {
|
|
4880
|
-
return
|
|
4911
|
+
return import_compiler26.types.markoAttribute(
|
|
4881
4912
|
changeAttrName,
|
|
4882
4913
|
withPreviousLocation(
|
|
4883
|
-
|
|
4914
|
+
import_compiler26.types.identifier(existingChangedAttr.name),
|
|
4884
4915
|
attr.value
|
|
4885
4916
|
)
|
|
4886
4917
|
);
|
|
@@ -4890,16 +4921,16 @@ function getChangeHandler(tag, attr) {
|
|
|
4890
4921
|
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
4891
4922
|
}
|
|
4892
4923
|
const changeHandlerId = generateUid(changeAttrName);
|
|
4893
|
-
const changeHandlerConst =
|
|
4894
|
-
|
|
4895
|
-
[
|
|
4896
|
-
|
|
4924
|
+
const changeHandlerConst = import_compiler26.types.markoTag(
|
|
4925
|
+
import_compiler26.types.stringLiteral("const"),
|
|
4926
|
+
[import_compiler26.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
|
4927
|
+
import_compiler26.types.markoTagBody([]),
|
|
4897
4928
|
null,
|
|
4898
|
-
|
|
4929
|
+
import_compiler26.types.identifier(changeHandlerId)
|
|
4899
4930
|
);
|
|
4900
4931
|
BINDING_CHANGE_HANDLER.set(
|
|
4901
4932
|
binding.identifier,
|
|
4902
|
-
existingChangedAttr.value =
|
|
4933
|
+
existingChangedAttr.value = import_compiler26.types.identifier(changeHandlerId)
|
|
4903
4934
|
);
|
|
4904
4935
|
if (markoRoot.isMarkoTag()) {
|
|
4905
4936
|
markoRoot.insertAfter(changeHandlerConst);
|
|
@@ -4907,23 +4938,23 @@ function getChangeHandler(tag, attr) {
|
|
|
4907
4938
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
|
4908
4939
|
}
|
|
4909
4940
|
markoRoot.scope.crawl();
|
|
4910
|
-
return
|
|
4941
|
+
return import_compiler26.types.markoAttribute(
|
|
4911
4942
|
changeAttrName,
|
|
4912
|
-
withPreviousLocation(
|
|
4943
|
+
withPreviousLocation(import_compiler26.types.identifier(changeHandlerId), attr.value)
|
|
4913
4944
|
);
|
|
4914
|
-
} else if (
|
|
4945
|
+
} else if (import_compiler26.types.isMemberExpression(attr.value) || import_compiler26.types.isOptionalMemberExpression(attr.value)) {
|
|
4915
4946
|
const prop = attr.value.property;
|
|
4916
|
-
if (!
|
|
4917
|
-
const memberObj =
|
|
4918
|
-
const memberProp = prop.type === "Identifier" ? withPreviousLocation(
|
|
4947
|
+
if (!import_compiler26.types.isPrivateName(attr.value.property)) {
|
|
4948
|
+
const memberObj = import_compiler26.types.cloneNode(attr.value.object);
|
|
4949
|
+
const memberProp = prop.type === "Identifier" ? withPreviousLocation(import_compiler26.types.identifier(prop.name + "Change"), prop) : import_compiler26.types.binaryExpression(
|
|
4919
4950
|
"+",
|
|
4920
|
-
|
|
4921
|
-
|
|
4951
|
+
import_compiler26.types.cloneNode(prop),
|
|
4952
|
+
import_compiler26.types.stringLiteral("Change")
|
|
4922
4953
|
);
|
|
4923
4954
|
const computed = memberProp.type !== "Identifier";
|
|
4924
|
-
return
|
|
4955
|
+
return import_compiler26.types.markoAttribute(
|
|
4925
4956
|
changeAttrName,
|
|
4926
|
-
attr.value.optional ?
|
|
4957
|
+
attr.value.optional ? import_compiler26.types.optionalMemberExpression(memberObj, memberProp, computed, true) : import_compiler26.types.memberExpression(memberObj, memberProp, computed)
|
|
4927
4958
|
);
|
|
4928
4959
|
}
|
|
4929
4960
|
}
|
|
@@ -4934,14 +4965,14 @@ function getChangeHandler(tag, attr) {
|
|
|
4934
4965
|
}
|
|
4935
4966
|
function buildChangeHandlerFunction(id) {
|
|
4936
4967
|
const newId = "_new_" + id.name;
|
|
4937
|
-
return
|
|
4938
|
-
[withPreviousLocation(
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4968
|
+
return import_compiler26.types.arrowFunctionExpression(
|
|
4969
|
+
[withPreviousLocation(import_compiler26.types.identifier(newId), id)],
|
|
4970
|
+
import_compiler26.types.blockStatement([
|
|
4971
|
+
import_compiler26.types.expressionStatement(
|
|
4972
|
+
import_compiler26.types.assignmentExpression(
|
|
4942
4973
|
"=",
|
|
4943
|
-
withPreviousLocation(
|
|
4944
|
-
withPreviousLocation(
|
|
4974
|
+
withPreviousLocation(import_compiler26.types.identifier(id.name), id),
|
|
4975
|
+
withPreviousLocation(import_compiler26.types.identifier(newId), id)
|
|
4945
4976
|
)
|
|
4946
4977
|
)
|
|
4947
4978
|
])
|
|
@@ -4954,11 +4985,11 @@ function getChangeHandlerFromObjectPattern(parent) {
|
|
|
4954
4985
|
changeKey = generateUidIdentifier("dynamicChange");
|
|
4955
4986
|
pattern.pushContainer(
|
|
4956
4987
|
"properties",
|
|
4957
|
-
|
|
4958
|
-
|
|
4988
|
+
import_compiler26.types.objectProperty(
|
|
4989
|
+
import_compiler26.types.binaryExpression(
|
|
4959
4990
|
"+",
|
|
4960
4991
|
parent.get("key").node,
|
|
4961
|
-
|
|
4992
|
+
import_compiler26.types.stringLiteral("Change")
|
|
4962
4993
|
),
|
|
4963
4994
|
changeKey,
|
|
4964
4995
|
true
|
|
@@ -4980,8 +5011,8 @@ function getChangeHandlerFromObjectPattern(parent) {
|
|
|
4980
5011
|
if (!changeKey) {
|
|
4981
5012
|
pattern.unshiftContainer(
|
|
4982
5013
|
"properties",
|
|
4983
|
-
|
|
4984
|
-
|
|
5014
|
+
import_compiler26.types.objectProperty(
|
|
5015
|
+
import_compiler26.types.stringLiteral(searchKey),
|
|
4985
5016
|
changeKey = generateUidIdentifier(searchKey)
|
|
4986
5017
|
)
|
|
4987
5018
|
);
|
|
@@ -5011,7 +5042,7 @@ function getAssignmentInsertions(node, insertions) {
|
|
|
5011
5042
|
getLiteralName(left) || getLiteralName(prop.key) || "pattern"
|
|
5012
5043
|
);
|
|
5013
5044
|
prop.shorthand = false;
|
|
5014
|
-
prop.value =
|
|
5045
|
+
prop.value = import_compiler26.types.identifier(sourceName);
|
|
5015
5046
|
(insertions ||= []).push(
|
|
5016
5047
|
toConstTag(left, toFallbackExpr(sourceName, right))
|
|
5017
5048
|
);
|
|
@@ -5029,7 +5060,7 @@ function getAssignmentInsertions(node, insertions) {
|
|
|
5029
5060
|
if (el.type === "AssignmentPattern") {
|
|
5030
5061
|
const { left, right } = el;
|
|
5031
5062
|
const sourceName = generateUid(getLiteralName(left) || "pattern");
|
|
5032
|
-
node.elements[i] =
|
|
5063
|
+
node.elements[i] = import_compiler26.types.identifier(sourceName);
|
|
5033
5064
|
(insertions ||= []).push(
|
|
5034
5065
|
toConstTag(left, toFallbackExpr(sourceName, right))
|
|
5035
5066
|
);
|
|
@@ -5044,23 +5075,23 @@ function getAssignmentInsertions(node, insertions) {
|
|
|
5044
5075
|
return insertions;
|
|
5045
5076
|
}
|
|
5046
5077
|
function toFallbackExpr(id, fallback) {
|
|
5047
|
-
return
|
|
5048
|
-
|
|
5049
|
-
|
|
5078
|
+
return import_compiler26.types.conditionalExpression(
|
|
5079
|
+
import_compiler26.types.binaryExpression("!==", buildUndefined(), import_compiler26.types.identifier(id)),
|
|
5080
|
+
import_compiler26.types.identifier(id),
|
|
5050
5081
|
fallback
|
|
5051
5082
|
);
|
|
5052
5083
|
}
|
|
5053
5084
|
function toConstTag(id, expr) {
|
|
5054
|
-
return
|
|
5055
|
-
|
|
5056
|
-
[
|
|
5057
|
-
|
|
5085
|
+
return import_compiler26.types.markoTag(
|
|
5086
|
+
import_compiler26.types.stringLiteral("const"),
|
|
5087
|
+
[import_compiler26.types.markoAttribute("value", expr, null, null, true)],
|
|
5088
|
+
import_compiler26.types.markoTagBody(),
|
|
5058
5089
|
null,
|
|
5059
5090
|
id
|
|
5060
5091
|
);
|
|
5061
5092
|
}
|
|
5062
5093
|
function buildUndefined() {
|
|
5063
|
-
return
|
|
5094
|
+
return import_compiler26.types.unaryExpression("void", import_compiler26.types.numericLiteral(0));
|
|
5064
5095
|
}
|
|
5065
5096
|
|
|
5066
5097
|
// src/translator/visitors/program/index.ts
|
|
@@ -5072,14 +5103,14 @@ function isScopeIdentifier(node) {
|
|
|
5072
5103
|
var program_default = {
|
|
5073
5104
|
migrate: {
|
|
5074
5105
|
enter(program) {
|
|
5075
|
-
program.node.params = [
|
|
5106
|
+
program.node.params = [import_compiler27.types.identifier("input")];
|
|
5076
5107
|
},
|
|
5077
5108
|
exit(program) {
|
|
5078
5109
|
program.scope.crawl();
|
|
5079
5110
|
}
|
|
5080
5111
|
},
|
|
5081
5112
|
transform: {
|
|
5082
|
-
exit:
|
|
5113
|
+
exit: preAnalyze2
|
|
5083
5114
|
},
|
|
5084
5115
|
analyze: {
|
|
5085
5116
|
enter(program) {
|
|
@@ -5161,7 +5192,7 @@ var program_default = {
|
|
|
5161
5192
|
body.push(child);
|
|
5162
5193
|
}
|
|
5163
5194
|
}
|
|
5164
|
-
body[0] ??=
|
|
5195
|
+
body[0] ??= import_compiler27.types.importDeclaration([], import_compiler27.types.stringLiteral(compatFile));
|
|
5165
5196
|
program.node.body = body;
|
|
5166
5197
|
}
|
|
5167
5198
|
}
|
|
@@ -5175,7 +5206,7 @@ function resolveRelativeToEntry(entryFile, file, req) {
|
|
|
5175
5206
|
}
|
|
5176
5207
|
|
|
5177
5208
|
// src/translator/util/nested-attribute-tags.ts
|
|
5178
|
-
var
|
|
5209
|
+
var import_compiler28 = require("@marko/compiler");
|
|
5179
5210
|
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
|
5180
5211
|
var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
|
|
5181
5212
|
function getAttrTagIdentifier(meta) {
|
|
@@ -5184,7 +5215,7 @@ function getAttrTagIdentifier(meta) {
|
|
|
5184
5215
|
name2 = generateUid(meta.name);
|
|
5185
5216
|
attrTagToIdentifierLookup.set(meta, name2);
|
|
5186
5217
|
}
|
|
5187
|
-
return
|
|
5218
|
+
return import_compiler28.types.identifier(name2);
|
|
5188
5219
|
}
|
|
5189
5220
|
function analyzeAttributeTags(tag) {
|
|
5190
5221
|
if (tag.node.extra?.attributeTags) return tag.node.extra.attributeTags;
|
|
@@ -5297,7 +5328,7 @@ function getConditionRoot(tag) {
|
|
|
5297
5328
|
}
|
|
5298
5329
|
|
|
5299
5330
|
// src/translator/util/set-tag-sections-downstream.ts
|
|
5300
|
-
var
|
|
5331
|
+
var import_compiler29 = require("@marko/compiler");
|
|
5301
5332
|
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
|
5302
5333
|
var [getTagDownstreams] = createSectionState(
|
|
5303
5334
|
"tag-downstreams",
|
|
@@ -5344,23 +5375,82 @@ function crawlSectionsAndSetBinding(tag, binding, tree, skip2) {
|
|
|
5344
5375
|
}
|
|
5345
5376
|
|
|
5346
5377
|
// src/translator/util/translate-attrs.ts
|
|
5347
|
-
var
|
|
5348
|
-
var
|
|
5378
|
+
var import_compiler36 = require("@marko/compiler");
|
|
5379
|
+
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
|
5349
5380
|
|
|
5350
5381
|
// src/translator/core/for.ts
|
|
5351
|
-
var
|
|
5352
|
-
var
|
|
5382
|
+
var import_compiler35 = require("@marko/compiler");
|
|
5383
|
+
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
|
5353
5384
|
|
|
5354
5385
|
// src/translator/util/is-only-child-in-parent.ts
|
|
5355
|
-
var
|
|
5356
|
-
var
|
|
5386
|
+
var import_compiler34 = require("@marko/compiler");
|
|
5387
|
+
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
|
5357
5388
|
|
|
5358
5389
|
// src/translator/visitors/tag/native-tag.ts
|
|
5390
|
+
var import_compiler33 = require("@marko/compiler");
|
|
5391
|
+
var import_babel_utils21 = require("@marko/compiler/babel-utils");
|
|
5392
|
+
|
|
5393
|
+
// src/translator/util/body-to-text-literal.ts
|
|
5359
5394
|
var import_compiler30 = require("@marko/compiler");
|
|
5395
|
+
function bodyToTextLiteral(body) {
|
|
5396
|
+
const templateQuasis = [];
|
|
5397
|
+
const templateExpressions = [];
|
|
5398
|
+
let currentQuasi = "";
|
|
5399
|
+
let placeholderExtra;
|
|
5400
|
+
for (const child of body.body) {
|
|
5401
|
+
if (import_compiler30.types.isMarkoText(child)) {
|
|
5402
|
+
currentQuasi += child.value;
|
|
5403
|
+
} else if (import_compiler30.types.isMarkoPlaceholder(child)) {
|
|
5404
|
+
placeholderExtra ||= child.value.extra;
|
|
5405
|
+
templateQuasis.push(templateElement(currentQuasi, false));
|
|
5406
|
+
templateExpressions.push(callRuntime("_to_text", child.value));
|
|
5407
|
+
currentQuasi = "";
|
|
5408
|
+
}
|
|
5409
|
+
}
|
|
5410
|
+
if (templateExpressions.length) {
|
|
5411
|
+
templateQuasis.push(templateElement(currentQuasi, true));
|
|
5412
|
+
const literal = import_compiler30.types.templateLiteral(templateQuasis, templateExpressions);
|
|
5413
|
+
literal.extra = placeholderExtra;
|
|
5414
|
+
return literal;
|
|
5415
|
+
}
|
|
5416
|
+
return import_compiler30.types.stringLiteral(currentQuasi);
|
|
5417
|
+
}
|
|
5418
|
+
function templateElement(value, tail) {
|
|
5419
|
+
return import_compiler30.types.templateElement(
|
|
5420
|
+
{
|
|
5421
|
+
raw: value.replace(/`/g, "\\`"),
|
|
5422
|
+
cooked: value
|
|
5423
|
+
},
|
|
5424
|
+
tail
|
|
5425
|
+
);
|
|
5426
|
+
}
|
|
5427
|
+
|
|
5428
|
+
// src/translator/util/is-non-html-text.ts
|
|
5429
|
+
var import_compiler31 = require("@marko/compiler");
|
|
5360
5430
|
var import_babel_utils20 = require("@marko/compiler/babel-utils");
|
|
5431
|
+
function isNonHTMLText(placeholder) {
|
|
5432
|
+
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
5433
|
+
if (parentTag) {
|
|
5434
|
+
if (isCoreTag(parentTag)) {
|
|
5435
|
+
switch (parentTag.node.name.value) {
|
|
5436
|
+
case "html-comment":
|
|
5437
|
+
case "html-script":
|
|
5438
|
+
case "html-style":
|
|
5439
|
+
return true;
|
|
5440
|
+
}
|
|
5441
|
+
} else if (isTextOnlyNativeTag(parentTag)) {
|
|
5442
|
+
return true;
|
|
5443
|
+
}
|
|
5444
|
+
}
|
|
5445
|
+
return false;
|
|
5446
|
+
}
|
|
5447
|
+
function isTextOnlyNativeTag(tag) {
|
|
5448
|
+
const def = (0, import_babel_utils20.getTagDef)(tag);
|
|
5449
|
+
return !!(def && def.html && (def.name === "title" || def.parseOptions?.text));
|
|
5450
|
+
}
|
|
5361
5451
|
|
|
5362
5452
|
// src/translator/util/translate-var.ts
|
|
5363
|
-
var
|
|
5453
|
+
var import_compiler32 = require("@marko/compiler");
|
|
5364
5454
|
function translateVar(tag, initialValue, kind = "const") {
|
|
5365
5455
|
const {
|
|
5366
5456
|
node: { var: tagVar }
|
|
@@ -5378,15 +5468,15 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
|
5378
5468
|
if (changeBinding && changeName !== changeBinding.name) {
|
|
5379
5469
|
getDestructurePattern(id)?.pushContainer(
|
|
5380
5470
|
"properties",
|
|
5381
|
-
|
|
5382
|
-
|
|
5383
|
-
|
|
5471
|
+
import_compiler32.types.objectProperty(
|
|
5472
|
+
import_compiler32.types.identifier(changeName),
|
|
5473
|
+
import_compiler32.types.identifier(changeBinding.name)
|
|
5384
5474
|
)
|
|
5385
5475
|
);
|
|
5386
5476
|
}
|
|
5387
5477
|
});
|
|
5388
5478
|
tag.insertBefore(
|
|
5389
|
-
|
|
5479
|
+
import_compiler32.types.variableDeclaration(kind, [import_compiler32.types.variableDeclarator(tagVar, initialValue)])
|
|
5390
5480
|
);
|
|
5391
5481
|
}
|
|
5392
5482
|
function translateDomVar(tag, binding) {
|
|
@@ -5396,13 +5486,13 @@ function translateDomVar(tag, binding) {
|
|
|
5396
5486
|
if (registerId) {
|
|
5397
5487
|
tag.parentPath.unshiftContainer(
|
|
5398
5488
|
"body",
|
|
5399
|
-
|
|
5400
|
-
|
|
5489
|
+
import_compiler32.types.variableDeclaration("const", [
|
|
5490
|
+
import_compiler32.types.variableDeclarator(
|
|
5401
5491
|
tag.node.var,
|
|
5402
5492
|
callRuntime(
|
|
5403
5493
|
"_el",
|
|
5404
5494
|
getScopeIdIdentifier(tagSection),
|
|
5405
|
-
|
|
5495
|
+
import_compiler32.types.stringLiteral(registerId)
|
|
5406
5496
|
)
|
|
5407
5497
|
)
|
|
5408
5498
|
])
|
|
@@ -5428,65 +5518,83 @@ var htmlSelectArgs = /* @__PURE__ */ new WeakMap();
|
|
|
5428
5518
|
var native_tag_default = {
|
|
5429
5519
|
analyze: {
|
|
5430
5520
|
enter(tag) {
|
|
5431
|
-
(0,
|
|
5432
|
-
(0,
|
|
5433
|
-
(0,
|
|
5521
|
+
(0, import_babel_utils21.assertNoArgs)(tag);
|
|
5522
|
+
(0, import_babel_utils21.assertNoParams)(tag);
|
|
5523
|
+
(0, import_babel_utils21.assertNoAttributeTags)(tag);
|
|
5434
5524
|
const { node } = tag;
|
|
5435
|
-
if (node.var && !
|
|
5525
|
+
if (node.var && !import_compiler33.types.isIdentifier(node.var)) {
|
|
5436
5526
|
throw tag.get("var").buildCodeFrameError(
|
|
5437
5527
|
"Tag variables on [native tags](https://markojs.com/docs/reference/native-tag) cannot be destructured."
|
|
5438
5528
|
);
|
|
5439
5529
|
}
|
|
5440
|
-
const tagName =
|
|
5530
|
+
const tagName = getCanonicalTagName(tag);
|
|
5531
|
+
const textOnly = isTextOnlyNativeTag(tag);
|
|
5441
5532
|
const seen = {};
|
|
5442
5533
|
const { attributes } = tag.node;
|
|
5534
|
+
let injectNonce = isInjectNonceTag(tagName);
|
|
5443
5535
|
let hasDynamicAttributes = false;
|
|
5444
5536
|
let hasEventHandlers = false;
|
|
5445
5537
|
let relatedControllable;
|
|
5446
5538
|
let spreadReferenceNodes;
|
|
5447
|
-
let
|
|
5539
|
+
let exprExtras;
|
|
5448
5540
|
for (let i = attributes.length; i--; ) {
|
|
5449
5541
|
const attr = attributes[i];
|
|
5450
5542
|
const valueExtra = attr.value.extra ??= {};
|
|
5451
|
-
if (
|
|
5543
|
+
if (import_compiler33.types.isMarkoAttribute(attr)) {
|
|
5452
5544
|
if (seen[attr.name]) {
|
|
5453
5545
|
dropReferences(attr.value);
|
|
5454
5546
|
continue;
|
|
5455
5547
|
}
|
|
5456
5548
|
seen[attr.name] = attr;
|
|
5549
|
+
if (injectNonce && attr.name === "nonce") {
|
|
5550
|
+
injectNonce = false;
|
|
5551
|
+
}
|
|
5457
5552
|
if (isEventHandler(attr.name) || isNativeTagChangeHandler(attr.name)) {
|
|
5458
5553
|
valueExtra.isEffect = true;
|
|
5459
5554
|
hasEventHandlers = true;
|
|
5460
5555
|
} else if (!evaluate(attr.value).confident) {
|
|
5461
5556
|
hasDynamicAttributes = true;
|
|
5462
5557
|
}
|
|
5463
|
-
} else if (
|
|
5558
|
+
} else if (import_compiler33.types.isMarkoSpreadAttribute(attr)) {
|
|
5464
5559
|
valueExtra.isEffect = true;
|
|
5465
5560
|
hasEventHandlers = true;
|
|
5466
5561
|
hasDynamicAttributes = true;
|
|
5467
5562
|
}
|
|
5468
5563
|
if (spreadReferenceNodes) {
|
|
5469
5564
|
spreadReferenceNodes.push(attr.value);
|
|
5470
|
-
} else if (
|
|
5565
|
+
} else if (import_compiler33.types.isMarkoSpreadAttribute(attr)) {
|
|
5471
5566
|
spreadReferenceNodes = [attr.value];
|
|
5472
5567
|
relatedControllable = getRelatedControllable(tagName, seen);
|
|
5473
5568
|
} else {
|
|
5474
|
-
|
|
5569
|
+
exprExtras = push(exprExtras, valueExtra);
|
|
5475
5570
|
}
|
|
5476
5571
|
}
|
|
5477
5572
|
assertExclusiveAttrs(seen, (msg) => {
|
|
5478
5573
|
throw tag.get("name").buildCodeFrameError(msg);
|
|
5479
5574
|
});
|
|
5480
|
-
|
|
5575
|
+
let textPlaceholders;
|
|
5576
|
+
if (textOnly) {
|
|
5577
|
+
for (const child of tag.node.body.body) {
|
|
5578
|
+
if (import_compiler33.types.isMarkoPlaceholder(child)) {
|
|
5579
|
+
(textPlaceholders ||= []).push(child.value);
|
|
5580
|
+
} else if (!import_compiler33.types.isMarkoText(child)) {
|
|
5581
|
+
throw tag.hub.buildError(
|
|
5582
|
+
child,
|
|
5583
|
+
`Only text is allowed inside a \`<${tagName}>\`.`
|
|
5584
|
+
);
|
|
5585
|
+
}
|
|
5586
|
+
}
|
|
5587
|
+
}
|
|
5588
|
+
if (node.var || hasDynamicAttributes || hasEventHandlers || textPlaceholders || injectNonce || getRelatedControllable(tagName, seen)?.special) {
|
|
5481
5589
|
const tagExtra = node.extra ??= {};
|
|
5482
5590
|
const tagSection = getOrCreateSection(tag);
|
|
5483
5591
|
const nodeBinding = tagExtra[kNativeTagBinding] = createBinding(
|
|
5484
|
-
"#" + (
|
|
5592
|
+
"#" + getCanonicalTagName(tag),
|
|
5485
5593
|
0 /* dom */,
|
|
5486
5594
|
tagSection
|
|
5487
5595
|
);
|
|
5488
5596
|
if (hasEventHandlers) {
|
|
5489
|
-
(0,
|
|
5597
|
+
(0, import_babel_utils21.getProgram)().node.extra.isInteractive = true;
|
|
5490
5598
|
}
|
|
5491
5599
|
if (spreadReferenceNodes) {
|
|
5492
5600
|
if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
|
|
@@ -5508,38 +5616,50 @@ var native_tag_default = {
|
|
|
5508
5616
|
relatedControllable.attrs.map((it) => it?.value)
|
|
5509
5617
|
);
|
|
5510
5618
|
}
|
|
5619
|
+
if (textPlaceholders) {
|
|
5620
|
+
exprExtras = push(
|
|
5621
|
+
exprExtras,
|
|
5622
|
+
textPlaceholders.length === 1 ? textPlaceholders[0].extra ??= {} : mergeReferences(
|
|
5623
|
+
tagSection,
|
|
5624
|
+
textPlaceholders[0],
|
|
5625
|
+
textPlaceholders.slice(1)
|
|
5626
|
+
)
|
|
5627
|
+
);
|
|
5628
|
+
}
|
|
5511
5629
|
addSerializeExpr(
|
|
5512
5630
|
tagSection,
|
|
5513
5631
|
!!(node.var || hasEventHandlers),
|
|
5514
5632
|
nodeBinding
|
|
5515
5633
|
);
|
|
5516
5634
|
trackDomVarReferences(tag, nodeBinding);
|
|
5517
|
-
addSerializeExpr(
|
|
5518
|
-
tagSection,
|
|
5519
|
-
push(attrExprExtras, tagExtra),
|
|
5520
|
-
nodeBinding
|
|
5521
|
-
);
|
|
5635
|
+
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
5522
5636
|
}
|
|
5523
5637
|
}
|
|
5524
5638
|
},
|
|
5525
5639
|
translate: translateByTarget({
|
|
5526
5640
|
html: {
|
|
5527
5641
|
enter(tag) {
|
|
5528
|
-
const tagName =
|
|
5642
|
+
const tagName = getCanonicalTagName(tag);
|
|
5529
5643
|
const tagExtra = tag.node.extra;
|
|
5530
5644
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5531
|
-
const tagDef = (0,
|
|
5645
|
+
const tagDef = (0, import_babel_utils21.getTagDef)(tag);
|
|
5532
5646
|
const write = writeTo(tag);
|
|
5533
5647
|
const tagSection = getSection(tag);
|
|
5534
|
-
if (tagExtra.tagNameNullable) {
|
|
5535
|
-
flushBefore(tag);
|
|
5536
|
-
}
|
|
5537
5648
|
translateDomVar(tag, nodeBinding);
|
|
5538
5649
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
5539
|
-
write`<${
|
|
5650
|
+
write`<${tagName}`;
|
|
5540
5651
|
const usedAttrs = getUsedAttrs(tagName, tag.node);
|
|
5541
|
-
const {
|
|
5652
|
+
const {
|
|
5653
|
+
staticAttrs,
|
|
5654
|
+
staticControllable,
|
|
5655
|
+
staticContentAttr,
|
|
5656
|
+
skipExpression,
|
|
5657
|
+
injectNonce
|
|
5658
|
+
} = usedAttrs;
|
|
5542
5659
|
let { spreadExpression } = usedAttrs;
|
|
5660
|
+
if (injectNonce) {
|
|
5661
|
+
write`${callRuntime("_attr_nonce")}`;
|
|
5662
|
+
}
|
|
5543
5663
|
if (staticControllable) {
|
|
5544
5664
|
if (tagName !== "select" && tagName !== "textarea") {
|
|
5545
5665
|
write`${callRuntime(
|
|
@@ -5563,18 +5683,18 @@ var native_tag_default = {
|
|
|
5563
5683
|
} else if (spreadExpression) {
|
|
5564
5684
|
const spreadIdentifier = generateUidIdentifier("select_input");
|
|
5565
5685
|
tag.insertBefore(
|
|
5566
|
-
|
|
5567
|
-
|
|
5686
|
+
import_compiler33.types.variableDeclaration("const", [
|
|
5687
|
+
import_compiler33.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5568
5688
|
])
|
|
5569
5689
|
);
|
|
5570
5690
|
htmlSelectArgs.set(tag.node, {
|
|
5571
|
-
value:
|
|
5691
|
+
value: import_compiler33.types.memberExpression(
|
|
5572
5692
|
spreadIdentifier,
|
|
5573
|
-
|
|
5693
|
+
import_compiler33.types.identifier("value")
|
|
5574
5694
|
),
|
|
5575
|
-
valueChange:
|
|
5695
|
+
valueChange: import_compiler33.types.memberExpression(
|
|
5576
5696
|
spreadIdentifier,
|
|
5577
|
-
|
|
5697
|
+
import_compiler33.types.identifier("valueChange")
|
|
5578
5698
|
)
|
|
5579
5699
|
});
|
|
5580
5700
|
spreadExpression = spreadIdentifier;
|
|
@@ -5588,14 +5708,14 @@ var native_tag_default = {
|
|
|
5588
5708
|
} else if (spreadExpression) {
|
|
5589
5709
|
const spreadIdentifier = generateUidIdentifier("textarea_input");
|
|
5590
5710
|
tag.insertBefore(
|
|
5591
|
-
|
|
5592
|
-
|
|
5711
|
+
import_compiler33.types.variableDeclaration("const", [
|
|
5712
|
+
import_compiler33.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5593
5713
|
])
|
|
5594
5714
|
);
|
|
5595
|
-
value =
|
|
5596
|
-
valueChange =
|
|
5715
|
+
value = import_compiler33.types.memberExpression(spreadIdentifier, import_compiler33.types.identifier("value"));
|
|
5716
|
+
valueChange = import_compiler33.types.memberExpression(
|
|
5597
5717
|
spreadIdentifier,
|
|
5598
|
-
|
|
5718
|
+
import_compiler33.types.identifier("valueChange")
|
|
5599
5719
|
);
|
|
5600
5720
|
spreadExpression = spreadIdentifier;
|
|
5601
5721
|
}
|
|
@@ -5608,7 +5728,7 @@ var native_tag_default = {
|
|
|
5608
5728
|
valueChange
|
|
5609
5729
|
);
|
|
5610
5730
|
} else if (value) {
|
|
5611
|
-
writeAtStartOfBody = callRuntime("
|
|
5731
|
+
writeAtStartOfBody = callRuntime("_escape_text", value);
|
|
5612
5732
|
}
|
|
5613
5733
|
}
|
|
5614
5734
|
for (const attr of staticAttrs) {
|
|
@@ -5636,7 +5756,7 @@ var native_tag_default = {
|
|
|
5636
5756
|
} else if (isEventHandler(name2)) {
|
|
5637
5757
|
addHTMLEffectCall(tagSection, valueReferences);
|
|
5638
5758
|
} else {
|
|
5639
|
-
write`${callRuntime("_attr",
|
|
5759
|
+
write`${callRuntime("_attr", import_compiler33.types.stringLiteral(name2), value)}`;
|
|
5640
5760
|
}
|
|
5641
5761
|
break;
|
|
5642
5762
|
}
|
|
@@ -5645,11 +5765,24 @@ var native_tag_default = {
|
|
|
5645
5765
|
const hasChildren = !!tag.node.body.body.length;
|
|
5646
5766
|
if (spreadExpression) {
|
|
5647
5767
|
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
5648
|
-
if (isOpenOnly || hasChildren ||
|
|
5768
|
+
if (isOpenOnly || hasChildren || staticContentAttr) {
|
|
5649
5769
|
if (skipExpression) {
|
|
5650
|
-
write`${callRuntime(
|
|
5770
|
+
write`${callRuntime(
|
|
5771
|
+
"_attrs_partial",
|
|
5772
|
+
spreadExpression,
|
|
5773
|
+
skipExpression,
|
|
5774
|
+
visitAccessor,
|
|
5775
|
+
getScopeIdIdentifier(tagSection),
|
|
5776
|
+
import_compiler33.types.stringLiteral(tagName)
|
|
5777
|
+
)}`;
|
|
5651
5778
|
} else {
|
|
5652
|
-
write`${callRuntime(
|
|
5779
|
+
write`${callRuntime(
|
|
5780
|
+
"_attrs",
|
|
5781
|
+
spreadExpression,
|
|
5782
|
+
visitAccessor,
|
|
5783
|
+
getScopeIdIdentifier(tagSection),
|
|
5784
|
+
import_compiler33.types.stringLiteral(tagName)
|
|
5785
|
+
)}`;
|
|
5653
5786
|
}
|
|
5654
5787
|
}
|
|
5655
5788
|
}
|
|
@@ -5664,16 +5797,16 @@ var native_tag_default = {
|
|
|
5664
5797
|
break;
|
|
5665
5798
|
}
|
|
5666
5799
|
} else {
|
|
5667
|
-
if (
|
|
5800
|
+
if (staticContentAttr) {
|
|
5668
5801
|
write`>`;
|
|
5669
5802
|
tagExtra[kTagContentAttr] = true;
|
|
5670
5803
|
tag.node.body.body = [
|
|
5671
|
-
|
|
5804
|
+
import_compiler33.types.expressionStatement(
|
|
5672
5805
|
callRuntime(
|
|
5673
5806
|
"_attr_content",
|
|
5674
5807
|
visitAccessor,
|
|
5675
5808
|
getScopeIdIdentifier(tagSection),
|
|
5676
|
-
|
|
5809
|
+
staticContentAttr.value,
|
|
5677
5810
|
getSerializeGuard(
|
|
5678
5811
|
tagSection,
|
|
5679
5812
|
nodeBinding && getSerializeReason(tagSection, nodeBinding),
|
|
@@ -5690,23 +5823,23 @@ var native_tag_default = {
|
|
|
5690
5823
|
);
|
|
5691
5824
|
tagExtra[kTagContentAttr] = true;
|
|
5692
5825
|
tag.node.body.body = [
|
|
5693
|
-
skipExpression ?
|
|
5826
|
+
skipExpression ? import_compiler33.types.expressionStatement(
|
|
5694
5827
|
callRuntime(
|
|
5695
5828
|
"_attrs_partial_content",
|
|
5696
5829
|
spreadExpression,
|
|
5697
5830
|
skipExpression,
|
|
5698
5831
|
visitAccessor,
|
|
5699
5832
|
getScopeIdIdentifier(tagSection),
|
|
5700
|
-
|
|
5833
|
+
import_compiler33.types.stringLiteral(tagName),
|
|
5701
5834
|
serializeReason
|
|
5702
5835
|
)
|
|
5703
|
-
) :
|
|
5836
|
+
) : import_compiler33.types.expressionStatement(
|
|
5704
5837
|
callRuntime(
|
|
5705
5838
|
"_attrs_content",
|
|
5706
5839
|
spreadExpression,
|
|
5707
5840
|
visitAccessor,
|
|
5708
5841
|
getScopeIdIdentifier(tagSection),
|
|
5709
|
-
|
|
5842
|
+
import_compiler33.types.stringLiteral(tagName),
|
|
5710
5843
|
serializeReason
|
|
5711
5844
|
)
|
|
5712
5845
|
)
|
|
@@ -5715,11 +5848,6 @@ var native_tag_default = {
|
|
|
5715
5848
|
write`>`;
|
|
5716
5849
|
}
|
|
5717
5850
|
}
|
|
5718
|
-
if (tagExtra.tagNameNullable) {
|
|
5719
|
-
tag.insertBefore(
|
|
5720
|
-
import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
|
|
5721
|
-
)[0].skip();
|
|
5722
|
-
}
|
|
5723
5851
|
if (writeAtStartOfBody) {
|
|
5724
5852
|
write`${writeAtStartOfBody}`;
|
|
5725
5853
|
}
|
|
@@ -5727,50 +5855,52 @@ var native_tag_default = {
|
|
|
5727
5855
|
exit(tag) {
|
|
5728
5856
|
const tagExtra = tag.node.extra;
|
|
5729
5857
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5730
|
-
const openTagOnly = (0,
|
|
5858
|
+
const openTagOnly = (0, import_babel_utils21.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
|
5859
|
+
const textOnly = isTextOnlyNativeTag(tag);
|
|
5731
5860
|
const selectArgs = htmlSelectArgs.get(tag.node);
|
|
5732
|
-
const tagName =
|
|
5861
|
+
const tagName = getCanonicalTagName(tag);
|
|
5733
5862
|
const tagSection = getSection(tag);
|
|
5863
|
+
const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getSerializeReason(tagSection, nodeBinding);
|
|
5864
|
+
const write = writeTo(
|
|
5865
|
+
tag,
|
|
5866
|
+
!markerSerializeReason && (tagName === "html" || tagName === "body")
|
|
5867
|
+
);
|
|
5734
5868
|
if (tagExtra[kTagContentAttr]) {
|
|
5735
5869
|
flushBefore(tag);
|
|
5736
5870
|
}
|
|
5737
|
-
if (tagExtra.tagNameNullable) {
|
|
5738
|
-
flushInto(tag);
|
|
5739
|
-
}
|
|
5740
5871
|
if (selectArgs) {
|
|
5741
5872
|
if (!tagExtra[kSkipEndTag]) {
|
|
5742
|
-
|
|
5873
|
+
write`</${tagName}>`;
|
|
5743
5874
|
}
|
|
5744
5875
|
flushInto(tag);
|
|
5745
5876
|
tag.insertBefore(
|
|
5746
|
-
|
|
5877
|
+
import_compiler33.types.expressionStatement(
|
|
5747
5878
|
callRuntime(
|
|
5748
5879
|
"_attr_select_value",
|
|
5749
5880
|
getScopeIdIdentifier(getSection(tag)),
|
|
5750
5881
|
nodeBinding && getScopeAccessorLiteral(nodeBinding),
|
|
5751
5882
|
selectArgs.value,
|
|
5752
5883
|
selectArgs.valueChange,
|
|
5753
|
-
|
|
5884
|
+
import_compiler33.types.arrowFunctionExpression(
|
|
5754
5885
|
[],
|
|
5755
|
-
|
|
5886
|
+
import_compiler33.types.blockStatement(tag.node.body.body)
|
|
5756
5887
|
)
|
|
5757
5888
|
)
|
|
5758
5889
|
)
|
|
5759
5890
|
);
|
|
5891
|
+
} else if (textOnly) {
|
|
5892
|
+
for (const child of tag.node.body.body) {
|
|
5893
|
+
if (import_compiler33.types.isMarkoText(child)) {
|
|
5894
|
+
write`${child.value}`;
|
|
5895
|
+
} else if (import_compiler33.types.isMarkoPlaceholder(child)) {
|
|
5896
|
+
write`${callRuntime(getTextOnlyEscapeHelper(tagName), child.value)}`;
|
|
5897
|
+
}
|
|
5898
|
+
}
|
|
5760
5899
|
} else {
|
|
5761
5900
|
tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
|
|
5762
5901
|
}
|
|
5763
|
-
const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getSerializeReason(tagSection, nodeBinding);
|
|
5764
5902
|
if (!tagExtra[kSkipEndTag] && !openTagOnly && !selectArgs) {
|
|
5765
|
-
|
|
5766
|
-
tag,
|
|
5767
|
-
!markerSerializeReason && (tagName === "html" || tagName === "body")
|
|
5768
|
-
)`</${tag.node.name}>`;
|
|
5769
|
-
}
|
|
5770
|
-
if (tagExtra.tagNameNullable) {
|
|
5771
|
-
tag.insertBefore(
|
|
5772
|
-
import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
|
|
5773
|
-
)[0].skip();
|
|
5903
|
+
write`</${tagName}>`;
|
|
5774
5904
|
}
|
|
5775
5905
|
if (markerSerializeReason) {
|
|
5776
5906
|
markNode(tag, nodeBinding, markerSerializeReason);
|
|
@@ -5780,22 +5910,41 @@ var native_tag_default = {
|
|
|
5780
5910
|
},
|
|
5781
5911
|
dom: {
|
|
5782
5912
|
enter(tag) {
|
|
5783
|
-
const tagName =
|
|
5913
|
+
const tagName = getCanonicalTagName(tag);
|
|
5784
5914
|
const tagExtra = tag.node.extra;
|
|
5785
5915
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5786
|
-
const tagDef = (0,
|
|
5916
|
+
const tagDef = (0, import_babel_utils21.getTagDef)(tag);
|
|
5787
5917
|
const write = writeTo(tag);
|
|
5788
5918
|
const tagSection = getSection(tag);
|
|
5789
5919
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
5790
5920
|
if (nodeBinding) {
|
|
5791
5921
|
visit(tag, 32 /* Get */);
|
|
5792
5922
|
}
|
|
5793
|
-
write`<${
|
|
5794
|
-
const
|
|
5795
|
-
|
|
5796
|
-
|
|
5923
|
+
write`<${tagName}`;
|
|
5924
|
+
const {
|
|
5925
|
+
staticAttrs,
|
|
5926
|
+
staticControllable,
|
|
5927
|
+
staticContentAttr,
|
|
5928
|
+
skipExpression,
|
|
5929
|
+
spreadExpression,
|
|
5930
|
+
injectNonce
|
|
5931
|
+
} = getUsedAttrs(tagName, tag.node);
|
|
5797
5932
|
const isOpenOnly = !!(tagDef && tagDef.parseOptions?.openTagOnly);
|
|
5798
5933
|
const hasChildren = !!tag.node.body.body.length;
|
|
5934
|
+
if (injectNonce) {
|
|
5935
|
+
addStatement(
|
|
5936
|
+
"render",
|
|
5937
|
+
tagSection,
|
|
5938
|
+
void 0,
|
|
5939
|
+
import_compiler33.types.expressionStatement(
|
|
5940
|
+
callRuntime(
|
|
5941
|
+
"_attr_nonce",
|
|
5942
|
+
scopeIdentifier,
|
|
5943
|
+
getScopeAccessorLiteral(nodeBinding)
|
|
5944
|
+
)
|
|
5945
|
+
)
|
|
5946
|
+
);
|
|
5947
|
+
}
|
|
5799
5948
|
if (staticControllable) {
|
|
5800
5949
|
const { helper, attrs } = staticControllable;
|
|
5801
5950
|
const firstAttr = attrs.find(Boolean);
|
|
@@ -5805,7 +5954,7 @@ var native_tag_default = {
|
|
|
5805
5954
|
"render",
|
|
5806
5955
|
tagSection,
|
|
5807
5956
|
referencedBindings,
|
|
5808
|
-
|
|
5957
|
+
import_compiler33.types.expressionStatement(
|
|
5809
5958
|
callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
|
|
5810
5959
|
)
|
|
5811
5960
|
);
|
|
@@ -5814,7 +5963,7 @@ var native_tag_default = {
|
|
|
5814
5963
|
"effect",
|
|
5815
5964
|
tagSection,
|
|
5816
5965
|
void 0,
|
|
5817
|
-
|
|
5966
|
+
import_compiler33.types.expressionStatement(
|
|
5818
5967
|
callRuntime(`${helper}_script`, scopeIdentifier, visitAccessor)
|
|
5819
5968
|
)
|
|
5820
5969
|
);
|
|
@@ -5840,7 +5989,7 @@ var native_tag_default = {
|
|
|
5840
5989
|
let stmt;
|
|
5841
5990
|
trackDelimitedAttrValue(value, meta);
|
|
5842
5991
|
if (meta.dynamicItems) {
|
|
5843
|
-
stmt =
|
|
5992
|
+
stmt = import_compiler33.types.expressionStatement(
|
|
5844
5993
|
callRuntime(helper, nodeExpr, value)
|
|
5845
5994
|
);
|
|
5846
5995
|
} else {
|
|
@@ -5852,11 +6001,11 @@ var native_tag_default = {
|
|
|
5852
6001
|
if (keys.length === 1) {
|
|
5853
6002
|
const [key] = keys;
|
|
5854
6003
|
const value2 = meta.dynamicValues[key];
|
|
5855
|
-
stmt =
|
|
6004
|
+
stmt = import_compiler33.types.expressionStatement(
|
|
5856
6005
|
callRuntime(
|
|
5857
6006
|
`_attr_${name2}_item`,
|
|
5858
6007
|
nodeExpr,
|
|
5859
|
-
|
|
6008
|
+
import_compiler33.types.stringLiteral(key),
|
|
5860
6009
|
value2
|
|
5861
6010
|
)
|
|
5862
6011
|
);
|
|
@@ -5865,14 +6014,14 @@ var native_tag_default = {
|
|
|
5865
6014
|
for (const key of keys) {
|
|
5866
6015
|
const value2 = meta.dynamicValues[key];
|
|
5867
6016
|
props.push(
|
|
5868
|
-
|
|
6017
|
+
import_compiler33.types.objectProperty(toPropertyName(key), value2)
|
|
5869
6018
|
);
|
|
5870
6019
|
}
|
|
5871
|
-
stmt =
|
|
6020
|
+
stmt = import_compiler33.types.expressionStatement(
|
|
5872
6021
|
callRuntime(
|
|
5873
6022
|
`_attr_${name2}_items`,
|
|
5874
6023
|
nodeExpr,
|
|
5875
|
-
|
|
6024
|
+
import_compiler33.types.objectExpression(props)
|
|
5876
6025
|
)
|
|
5877
6026
|
);
|
|
5878
6027
|
}
|
|
@@ -5892,11 +6041,11 @@ var native_tag_default = {
|
|
|
5892
6041
|
"effect",
|
|
5893
6042
|
tagSection,
|
|
5894
6043
|
valueReferences,
|
|
5895
|
-
|
|
6044
|
+
import_compiler33.types.expressionStatement(
|
|
5896
6045
|
callRuntime(
|
|
5897
6046
|
"_on",
|
|
5898
6047
|
createScopeReadExpression(nodeBinding),
|
|
5899
|
-
|
|
6048
|
+
import_compiler33.types.stringLiteral(getEventHandlerName(name2)),
|
|
5900
6049
|
value
|
|
5901
6050
|
)
|
|
5902
6051
|
)
|
|
@@ -5906,11 +6055,11 @@ var native_tag_default = {
|
|
|
5906
6055
|
"render",
|
|
5907
6056
|
tagSection,
|
|
5908
6057
|
valueReferences,
|
|
5909
|
-
|
|
6058
|
+
import_compiler33.types.expressionStatement(
|
|
5910
6059
|
callRuntime(
|
|
5911
6060
|
"_attr",
|
|
5912
6061
|
createScopeReadExpression(nodeBinding),
|
|
5913
|
-
|
|
6062
|
+
import_compiler33.types.stringLiteral(name2),
|
|
5914
6063
|
value
|
|
5915
6064
|
)
|
|
5916
6065
|
)
|
|
@@ -5920,13 +6069,13 @@ var native_tag_default = {
|
|
|
5920
6069
|
}
|
|
5921
6070
|
}
|
|
5922
6071
|
if (spreadExpression) {
|
|
5923
|
-
const canHaveAttrContent = !(isOpenOnly || hasChildren ||
|
|
6072
|
+
const canHaveAttrContent = !(isOpenOnly || hasChildren || staticContentAttr);
|
|
5924
6073
|
if (skipExpression) {
|
|
5925
6074
|
addStatement(
|
|
5926
6075
|
"render",
|
|
5927
6076
|
tagSection,
|
|
5928
6077
|
tagExtra.referencedBindings,
|
|
5929
|
-
|
|
6078
|
+
import_compiler33.types.expressionStatement(
|
|
5930
6079
|
callRuntime(
|
|
5931
6080
|
canHaveAttrContent ? "_attrs_partial_content" : "_attrs_partial",
|
|
5932
6081
|
scopeIdentifier,
|
|
@@ -5941,7 +6090,7 @@ var native_tag_default = {
|
|
|
5941
6090
|
"render",
|
|
5942
6091
|
tagSection,
|
|
5943
6092
|
tagExtra.referencedBindings,
|
|
5944
|
-
|
|
6093
|
+
import_compiler33.types.expressionStatement(
|
|
5945
6094
|
callRuntime(
|
|
5946
6095
|
canHaveAttrContent ? "_attrs_content" : "_attrs",
|
|
5947
6096
|
scopeIdentifier,
|
|
@@ -5955,24 +6104,23 @@ var native_tag_default = {
|
|
|
5955
6104
|
"effect",
|
|
5956
6105
|
tagSection,
|
|
5957
6106
|
tagExtra.referencedBindings,
|
|
5958
|
-
|
|
6107
|
+
import_compiler33.types.expressionStatement(
|
|
5959
6108
|
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
5960
6109
|
),
|
|
5961
6110
|
false
|
|
5962
6111
|
);
|
|
5963
6112
|
}
|
|
5964
|
-
if (
|
|
5965
|
-
const contentAttrValue = usedAttrs.staticContentAttr.value;
|
|
6113
|
+
if (staticContentAttr) {
|
|
5966
6114
|
addStatement(
|
|
5967
6115
|
"render",
|
|
5968
6116
|
tagSection,
|
|
5969
|
-
|
|
5970
|
-
|
|
6117
|
+
staticContentAttr.value.extra?.referencedBindings,
|
|
6118
|
+
import_compiler33.types.expressionStatement(
|
|
5971
6119
|
callRuntime(
|
|
5972
6120
|
"_attr_content",
|
|
5973
6121
|
scopeIdentifier,
|
|
5974
6122
|
visitAccessor,
|
|
5975
|
-
|
|
6123
|
+
staticContentAttr.value
|
|
5976
6124
|
)
|
|
5977
6125
|
)
|
|
5978
6126
|
);
|
|
@@ -5993,10 +6141,33 @@ var native_tag_default = {
|
|
|
5993
6141
|
enter2(tag);
|
|
5994
6142
|
},
|
|
5995
6143
|
exit(tag) {
|
|
5996
|
-
const
|
|
5997
|
-
|
|
6144
|
+
const tagExtra = tag.node.extra;
|
|
6145
|
+
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
6146
|
+
const openTagOnly = (0, import_babel_utils21.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
|
6147
|
+
const textOnly = isTextOnlyNativeTag(tag);
|
|
5998
6148
|
if (!openTagOnly) {
|
|
5999
|
-
|
|
6149
|
+
if (textOnly) {
|
|
6150
|
+
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
6151
|
+
if (import_compiler33.types.isStringLiteral(textLiteral)) {
|
|
6152
|
+
writeTo(tag)`${textLiteral}`;
|
|
6153
|
+
} else {
|
|
6154
|
+
addStatement(
|
|
6155
|
+
"render",
|
|
6156
|
+
getSection(tag),
|
|
6157
|
+
textLiteral.extra?.referencedBindings,
|
|
6158
|
+
import_compiler33.types.expressionStatement(
|
|
6159
|
+
callRuntime(
|
|
6160
|
+
"_text_content",
|
|
6161
|
+
createScopeReadExpression(nodeBinding),
|
|
6162
|
+
textLiteral
|
|
6163
|
+
)
|
|
6164
|
+
)
|
|
6165
|
+
);
|
|
6166
|
+
}
|
|
6167
|
+
} else {
|
|
6168
|
+
tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
|
|
6169
|
+
}
|
|
6170
|
+
writeTo(tag)`</${getCanonicalTagName(tag)}>`;
|
|
6000
6171
|
}
|
|
6001
6172
|
exit2(tag);
|
|
6002
6173
|
tag.remove();
|
|
@@ -6069,10 +6240,11 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6069
6240
|
let skipProps;
|
|
6070
6241
|
let staticControllable;
|
|
6071
6242
|
let staticContentAttr;
|
|
6243
|
+
let injectNonce = isInjectNonceTag(tagName);
|
|
6072
6244
|
for (let i = attributes.length; i--; ) {
|
|
6073
6245
|
const attr = attributes[i];
|
|
6074
6246
|
const { value } = attr;
|
|
6075
|
-
if (
|
|
6247
|
+
if (import_compiler33.types.isMarkoSpreadAttribute(attr)) {
|
|
6076
6248
|
if (!spreadProps) {
|
|
6077
6249
|
spreadProps = [];
|
|
6078
6250
|
staticControllable = getRelatedControllable(tagName, seen);
|
|
@@ -6086,9 +6258,12 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6086
6258
|
staticControllable = void 0;
|
|
6087
6259
|
}
|
|
6088
6260
|
}
|
|
6089
|
-
spreadProps.push(
|
|
6261
|
+
spreadProps.push(import_compiler33.types.spreadElement(value));
|
|
6090
6262
|
} else if (!(seen[attr.name] || attr.name === "content" && tag.body.body.length)) {
|
|
6091
6263
|
seen[attr.name] = attr;
|
|
6264
|
+
if (injectNonce && attr.name === "nonce") {
|
|
6265
|
+
injectNonce = false;
|
|
6266
|
+
}
|
|
6092
6267
|
if (spreadProps) {
|
|
6093
6268
|
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
6094
6269
|
} else if (attr.name === "content" && tagName !== "meta") {
|
|
@@ -6113,25 +6288,37 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6113
6288
|
}
|
|
6114
6289
|
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
6115
6290
|
if (spreadProps) {
|
|
6116
|
-
spreadProps.reverse();
|
|
6117
6291
|
if (staticControllable) {
|
|
6118
6292
|
for (const attr of staticControllable.attrs) {
|
|
6119
6293
|
if (attr) {
|
|
6120
6294
|
(skipProps ||= []).push(
|
|
6121
|
-
toObjectProperty(attr.name,
|
|
6295
|
+
toObjectProperty(attr.name, import_compiler33.types.numericLiteral(1))
|
|
6122
6296
|
);
|
|
6123
6297
|
}
|
|
6124
6298
|
}
|
|
6125
6299
|
}
|
|
6126
6300
|
for (const { name: name2 } of staticAttrs) {
|
|
6127
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
|
6301
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler33.types.numericLiteral(1)));
|
|
6302
|
+
}
|
|
6303
|
+
if (injectNonce) {
|
|
6304
|
+
injectNonce = false;
|
|
6305
|
+
spreadProps.push(
|
|
6306
|
+
import_compiler33.types.objectProperty(
|
|
6307
|
+
import_compiler33.types.identifier("nonce"),
|
|
6308
|
+
import_compiler33.types.memberExpression(
|
|
6309
|
+
isOutputHTML() ? callRuntime("$global") : toMemberExpression(scopeIdentifier, getAccessorProp().Global),
|
|
6310
|
+
import_compiler33.types.identifier("cspNonce")
|
|
6311
|
+
)
|
|
6312
|
+
)
|
|
6313
|
+
);
|
|
6128
6314
|
}
|
|
6129
|
-
spreadExpression = propsToExpression(spreadProps);
|
|
6315
|
+
spreadExpression = propsToExpression(spreadProps.reverse());
|
|
6130
6316
|
}
|
|
6131
6317
|
if (skipProps) {
|
|
6132
|
-
skipExpression =
|
|
6318
|
+
skipExpression = import_compiler33.types.objectExpression(skipProps);
|
|
6133
6319
|
}
|
|
6134
6320
|
return {
|
|
6321
|
+
injectNonce,
|
|
6135
6322
|
staticAttrs,
|
|
6136
6323
|
staticContentAttr,
|
|
6137
6324
|
staticControllable,
|
|
@@ -6139,6 +6326,36 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6139
6326
|
skipExpression
|
|
6140
6327
|
};
|
|
6141
6328
|
}
|
|
6329
|
+
function isInjectNonceTag(tagName) {
|
|
6330
|
+
switch (tagName) {
|
|
6331
|
+
case "script":
|
|
6332
|
+
case "style":
|
|
6333
|
+
return true;
|
|
6334
|
+
default:
|
|
6335
|
+
return false;
|
|
6336
|
+
}
|
|
6337
|
+
}
|
|
6338
|
+
function getCanonicalTagName(tag) {
|
|
6339
|
+
const tagName = getTagName(tag);
|
|
6340
|
+
switch (tagName) {
|
|
6341
|
+
case "html-script":
|
|
6342
|
+
return "script";
|
|
6343
|
+
case "html-style":
|
|
6344
|
+
return "style";
|
|
6345
|
+
default:
|
|
6346
|
+
return tagName;
|
|
6347
|
+
}
|
|
6348
|
+
}
|
|
6349
|
+
function getTextOnlyEscapeHelper(tagName) {
|
|
6350
|
+
switch (tagName) {
|
|
6351
|
+
case "script":
|
|
6352
|
+
return "_escape_script";
|
|
6353
|
+
case "style":
|
|
6354
|
+
return "_escape_style";
|
|
6355
|
+
default:
|
|
6356
|
+
return "_escape_text";
|
|
6357
|
+
}
|
|
6358
|
+
}
|
|
6142
6359
|
function trackDelimitedAttrValue(expr, meta) {
|
|
6143
6360
|
switch (expr.type) {
|
|
6144
6361
|
case "ObjectExpression":
|
|
@@ -6216,14 +6433,14 @@ function trackDelimitedAttrObjectProperties(obj, meta) {
|
|
|
6216
6433
|
(meta.staticItems ||= []).push(staticProps);
|
|
6217
6434
|
}
|
|
6218
6435
|
if (dynamicProps) {
|
|
6219
|
-
(meta.dynamicItems ||= []).push(
|
|
6436
|
+
(meta.dynamicItems ||= []).push(import_compiler33.types.objectExpression(dynamicProps));
|
|
6220
6437
|
}
|
|
6221
6438
|
}
|
|
6222
6439
|
function isNativeTagChangeHandler(propName) {
|
|
6223
6440
|
return /^(?:value|checked(?:Value)?|open)Change$/.test(propName);
|
|
6224
6441
|
}
|
|
6225
6442
|
function buildUndefined2() {
|
|
6226
|
-
return
|
|
6443
|
+
return import_compiler33.types.unaryExpression("void", import_compiler33.types.numericLiteral(0));
|
|
6227
6444
|
}
|
|
6228
6445
|
|
|
6229
6446
|
// src/translator/util/is-only-child-in-parent.ts
|
|
@@ -6235,7 +6452,7 @@ function getOnlyChildParentTagName(tag, branchSize = 1) {
|
|
|
6235
6452
|
return extra[kOnlyChildInParent];
|
|
6236
6453
|
}
|
|
6237
6454
|
const parentTag = getParentTag(tag);
|
|
6238
|
-
return extra[kOnlyChildInParent] = parentTag && (0,
|
|
6455
|
+
return extra[kOnlyChildInParent] = parentTag && (0, import_babel_utils22.getTagDef)(parentTag)?.html && parentTag.node.name.type === "StringLiteral" && tag.parent.body.length === branchSize ? parentTag.node.name.value : false;
|
|
6239
6456
|
}
|
|
6240
6457
|
function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
|
|
6241
6458
|
if (getOnlyChildParentTagName(tag, branchSize)) {
|
|
@@ -6267,8 +6484,8 @@ var for_default = {
|
|
|
6267
6484
|
isAttrTag ? 4 /* local */ : 5 /* derived */
|
|
6268
6485
|
);
|
|
6269
6486
|
let allowAttrs;
|
|
6270
|
-
(0,
|
|
6271
|
-
(0,
|
|
6487
|
+
(0, import_babel_utils23.assertNoVar)(tag);
|
|
6488
|
+
(0, import_babel_utils23.assertNoArgs)(tag);
|
|
6272
6489
|
assertNoSpreadAttrs(tag);
|
|
6273
6490
|
switch (getForType(tag.node)) {
|
|
6274
6491
|
case "of":
|
|
@@ -6291,7 +6508,7 @@ var for_default = {
|
|
|
6291
6508
|
if (!isAttrTag) {
|
|
6292
6509
|
allowAttrs.push("by");
|
|
6293
6510
|
}
|
|
6294
|
-
(0,
|
|
6511
|
+
(0, import_babel_utils23.assertAllowedAttributes)(tag, allowAttrs);
|
|
6295
6512
|
if (isAttrTag) return;
|
|
6296
6513
|
const bodySection = startSection(tagBody);
|
|
6297
6514
|
if (!bodySection) {
|
|
@@ -6359,7 +6576,7 @@ var for_default = {
|
|
|
6359
6576
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
|
6360
6577
|
const forTagHTMLRuntime = branchSerializeReason ? forTypeToHTMLResumeRuntime(forType) : forTypeToRuntime(forType);
|
|
6361
6578
|
forTagArgs.push(
|
|
6362
|
-
|
|
6579
|
+
import_compiler35.types.arrowFunctionExpression(params, import_compiler35.types.blockStatement(bodyStatements))
|
|
6363
6580
|
);
|
|
6364
6581
|
if (branchSerializeReason) {
|
|
6365
6582
|
const skipParentEnd = onlyChildParentTagName && markerSerializeReason;
|
|
@@ -6374,7 +6591,7 @@ var for_default = {
|
|
|
6374
6591
|
!statefulSerializeArg
|
|
6375
6592
|
);
|
|
6376
6593
|
forTagArgs.push(
|
|
6377
|
-
forAttrs.by ||
|
|
6594
|
+
forAttrs.by || import_compiler35.types.numericLiteral(0),
|
|
6378
6595
|
getScopeIdIdentifier(tagSection),
|
|
6379
6596
|
getScopeAccessorLiteral(nodeBinding),
|
|
6380
6597
|
getSerializeGuard(
|
|
@@ -6387,17 +6604,17 @@ var for_default = {
|
|
|
6387
6604
|
);
|
|
6388
6605
|
if (skipParentEnd) {
|
|
6389
6606
|
getParentTag(tag).node.extra[kSkipEndTag] = true;
|
|
6390
|
-
forTagArgs.push(
|
|
6607
|
+
forTagArgs.push(import_compiler35.types.stringLiteral(`</${onlyChildParentTagName}>`));
|
|
6391
6608
|
}
|
|
6392
6609
|
if (singleChild) {
|
|
6393
6610
|
if (!skipParentEnd) {
|
|
6394
|
-
forTagArgs.push(
|
|
6611
|
+
forTagArgs.push(import_compiler35.types.numericLiteral(0));
|
|
6395
6612
|
}
|
|
6396
|
-
forTagArgs.push(
|
|
6613
|
+
forTagArgs.push(import_compiler35.types.numericLiteral(1));
|
|
6397
6614
|
}
|
|
6398
6615
|
}
|
|
6399
6616
|
statements.push(
|
|
6400
|
-
|
|
6617
|
+
import_compiler35.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
|
6401
6618
|
);
|
|
6402
6619
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
6403
6620
|
replacement.skip();
|
|
@@ -6455,7 +6672,7 @@ var for_default = {
|
|
|
6455
6672
|
tagSection,
|
|
6456
6673
|
referencedBindings,
|
|
6457
6674
|
signal,
|
|
6458
|
-
|
|
6675
|
+
import_compiler35.types.arrayExpression(loopArgs)
|
|
6459
6676
|
);
|
|
6460
6677
|
tag.remove();
|
|
6461
6678
|
}
|
|
@@ -6533,11 +6750,11 @@ var for_default = {
|
|
|
6533
6750
|
]
|
|
6534
6751
|
};
|
|
6535
6752
|
function buildForRuntimeCall(type, attrs, params, statements) {
|
|
6536
|
-
return
|
|
6753
|
+
return import_compiler35.types.expressionStatement(
|
|
6537
6754
|
callRuntime(
|
|
6538
6755
|
forTypeToRuntime(type),
|
|
6539
6756
|
...getBaseArgsInForTag(type, attrs),
|
|
6540
|
-
|
|
6757
|
+
import_compiler35.types.arrowFunctionExpression(params, import_compiler35.types.blockStatement(statements))
|
|
6541
6758
|
)
|
|
6542
6759
|
);
|
|
6543
6760
|
}
|
|
@@ -6599,14 +6816,14 @@ function getBaseArgsInForTag(type, attrs) {
|
|
|
6599
6816
|
case "to":
|
|
6600
6817
|
return [
|
|
6601
6818
|
attrs.to,
|
|
6602
|
-
attrs.from ||
|
|
6603
|
-
attrs.step ||
|
|
6819
|
+
attrs.from || import_compiler35.types.numericLiteral(0),
|
|
6820
|
+
attrs.step || import_compiler35.types.numericLiteral(1)
|
|
6604
6821
|
];
|
|
6605
6822
|
case "until":
|
|
6606
6823
|
return [
|
|
6607
6824
|
attrs.until,
|
|
6608
|
-
attrs.from ||
|
|
6609
|
-
attrs.step ||
|
|
6825
|
+
attrs.from || import_compiler35.types.numericLiteral(0),
|
|
6826
|
+
attrs.step || import_compiler35.types.numericLiteral(1)
|
|
6610
6827
|
];
|
|
6611
6828
|
}
|
|
6612
6829
|
}
|
|
@@ -6625,8 +6842,8 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6625
6842
|
seen.add(attrTagMeta.name);
|
|
6626
6843
|
if (attrTagMeta.dynamic) {
|
|
6627
6844
|
statements.push(
|
|
6628
|
-
|
|
6629
|
-
|
|
6845
|
+
import_compiler36.types.variableDeclaration("let", [
|
|
6846
|
+
import_compiler36.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
|
|
6630
6847
|
])
|
|
6631
6848
|
);
|
|
6632
6849
|
properties.push(
|
|
@@ -6642,7 +6859,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6642
6859
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
6643
6860
|
const child = attrTags2[i];
|
|
6644
6861
|
if (child.isMarkoTag()) {
|
|
6645
|
-
if ((0,
|
|
6862
|
+
if ((0, import_babel_utils24.isAttributeTag)(child)) {
|
|
6646
6863
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
6647
6864
|
if (attrTagMeta.dynamic) {
|
|
6648
6865
|
i = addDynamicAttrTagStatements(
|
|
@@ -6708,8 +6925,8 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6708
6925
|
if (!seen.has(contentKey) && usesExport(templateExports, contentKey)) {
|
|
6709
6926
|
const contentExpression = buildContent(tag.get("body"));
|
|
6710
6927
|
if (contentExpression) {
|
|
6711
|
-
const contentProp =
|
|
6712
|
-
|
|
6928
|
+
const contentProp = import_compiler36.types.objectProperty(
|
|
6929
|
+
import_compiler36.types.identifier(contentKey),
|
|
6713
6930
|
contentExpression
|
|
6714
6931
|
);
|
|
6715
6932
|
seen.add(contentKey);
|
|
@@ -6721,8 +6938,8 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6721
6938
|
for (let i = attributes.length; i--; ) {
|
|
6722
6939
|
const attr = attributes[i];
|
|
6723
6940
|
const { value } = attr;
|
|
6724
|
-
if (
|
|
6725
|
-
properties.push(
|
|
6941
|
+
if (import_compiler36.types.isMarkoSpreadAttribute(attr)) {
|
|
6942
|
+
properties.push(import_compiler36.types.spreadElement(value));
|
|
6726
6943
|
} else if (!seen.has(attr.name) && usesExport(templateExports, attr.name)) {
|
|
6727
6944
|
seen.add(attr.name);
|
|
6728
6945
|
properties.push(toObjectProperty(attr.name, value));
|
|
@@ -6741,7 +6958,7 @@ function getTranslatedBodyContentProperty(props) {
|
|
|
6741
6958
|
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, templateExports, contentKey = "content") {
|
|
6742
6959
|
const tag = attrTags2[index];
|
|
6743
6960
|
if (tag.isMarkoTag()) {
|
|
6744
|
-
if ((0,
|
|
6961
|
+
if ((0, import_babel_utils24.isAttributeTag)(tag)) {
|
|
6745
6962
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
|
6746
6963
|
if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
|
|
6747
6964
|
const translatedAttrTag = translateAttrs(
|
|
@@ -6753,8 +6970,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6753
6970
|
);
|
|
6754
6971
|
if (attrTagMeta.repeated) {
|
|
6755
6972
|
statements.push(
|
|
6756
|
-
|
|
6757
|
-
|
|
6973
|
+
import_compiler36.types.expressionStatement(
|
|
6974
|
+
import_compiler36.types.assignmentExpression(
|
|
6758
6975
|
"=",
|
|
6759
6976
|
getAttrTagIdentifier(attrTagMeta),
|
|
6760
6977
|
callRuntime(
|
|
@@ -6767,8 +6984,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6767
6984
|
);
|
|
6768
6985
|
} else {
|
|
6769
6986
|
statements.push(
|
|
6770
|
-
|
|
6771
|
-
|
|
6987
|
+
import_compiler36.types.expressionStatement(
|
|
6988
|
+
import_compiler36.types.assignmentExpression(
|
|
6772
6989
|
"=",
|
|
6773
6990
|
getAttrTagIdentifier(attrTagMeta),
|
|
6774
6991
|
callRuntime(
|
|
@@ -6807,7 +7024,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6807
7024
|
return index;
|
|
6808
7025
|
}
|
|
6809
7026
|
function propsToExpression(props) {
|
|
6810
|
-
return props.length === 1 &&
|
|
7027
|
+
return props.length === 1 && import_compiler36.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler36.types.objectExpression(props);
|
|
6811
7028
|
}
|
|
6812
7029
|
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6813
7030
|
const forTag = attrTags2[index];
|
|
@@ -6832,9 +7049,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
|
6832
7049
|
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6833
7050
|
const ifTag = attrTags2[index];
|
|
6834
7051
|
const consequentStatements = [];
|
|
6835
|
-
let ifStatement =
|
|
7052
|
+
let ifStatement = import_compiler36.types.ifStatement(
|
|
6836
7053
|
getConditionTestValue(ifTag),
|
|
6837
|
-
|
|
7054
|
+
import_compiler36.types.blockStatement(consequentStatements)
|
|
6838
7055
|
);
|
|
6839
7056
|
statements.push(ifStatement);
|
|
6840
7057
|
addAllAttrTagsAsDynamic(
|
|
@@ -6861,14 +7078,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
6861
7078
|
contentKey
|
|
6862
7079
|
);
|
|
6863
7080
|
if (testValue) {
|
|
6864
|
-
ifStatement.alternate = ifStatement =
|
|
7081
|
+
ifStatement.alternate = ifStatement = import_compiler36.types.ifStatement(
|
|
6865
7082
|
testValue,
|
|
6866
|
-
|
|
7083
|
+
import_compiler36.types.blockStatement(alternateStatements)
|
|
6867
7084
|
);
|
|
6868
7085
|
nextIndex++;
|
|
6869
7086
|
continue;
|
|
6870
7087
|
} else {
|
|
6871
|
-
ifStatement.alternate =
|
|
7088
|
+
ifStatement.alternate = import_compiler36.types.blockStatement(alternateStatements);
|
|
6872
7089
|
break;
|
|
6873
7090
|
}
|
|
6874
7091
|
}
|
|
@@ -6934,9 +7151,9 @@ function buildContent(body) {
|
|
|
6934
7151
|
}
|
|
6935
7152
|
if (dynamicSerializeReason) {
|
|
6936
7153
|
body.node.body.unshift(
|
|
6937
|
-
|
|
6938
|
-
|
|
6939
|
-
|
|
7154
|
+
import_compiler36.types.variableDeclaration("const", [
|
|
7155
|
+
import_compiler36.types.variableDeclarator(
|
|
7156
|
+
import_compiler36.types.identifier(
|
|
6940
7157
|
getSharedUid(`scope${bodySection.id}_reason`, bodySection)
|
|
6941
7158
|
),
|
|
6942
7159
|
callRuntime("_scope_reason")
|
|
@@ -6946,10 +7163,10 @@ function buildContent(body) {
|
|
|
6946
7163
|
}
|
|
6947
7164
|
return callRuntime(
|
|
6948
7165
|
serialized ? "_content_resume" : "_content",
|
|
6949
|
-
|
|
6950
|
-
|
|
7166
|
+
import_compiler36.types.stringLiteral(getResumeRegisterId(bodySection, "content")),
|
|
7167
|
+
import_compiler36.types.arrowFunctionExpression(
|
|
6951
7168
|
body.node.params,
|
|
6952
|
-
|
|
7169
|
+
import_compiler36.types.blockStatement(body.node.body)
|
|
6953
7170
|
),
|
|
6954
7171
|
serialized ? getScopeIdIdentifier(
|
|
6955
7172
|
getSection(
|
|
@@ -6960,17 +7177,17 @@ function buildContent(body) {
|
|
|
6960
7177
|
) : void 0
|
|
6961
7178
|
);
|
|
6962
7179
|
} else {
|
|
6963
|
-
return
|
|
6964
|
-
|
|
7180
|
+
return import_compiler36.types.callExpression(
|
|
7181
|
+
import_compiler36.types.identifier(bodySection.name),
|
|
6965
7182
|
bodySection.referencedLocalClosures ? [
|
|
6966
7183
|
scopeIdentifier,
|
|
6967
|
-
|
|
7184
|
+
import_compiler36.types.objectExpression(
|
|
6968
7185
|
toArray(bodySection.referencedLocalClosures, (ref) => {
|
|
6969
7186
|
const accessor = getScopeAccessor(ref, true);
|
|
6970
7187
|
const isShorthand = accessor === ref.name;
|
|
6971
|
-
return
|
|
7188
|
+
return import_compiler36.types.objectProperty(
|
|
6972
7189
|
toPropertyName(accessor),
|
|
6973
|
-
|
|
7190
|
+
import_compiler36.types.identifier(ref.name),
|
|
6974
7191
|
false,
|
|
6975
7192
|
isShorthand
|
|
6976
7193
|
);
|
|
@@ -7055,8 +7272,8 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7055
7272
|
if (childScopeSerializeReason) {
|
|
7056
7273
|
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
|
7057
7274
|
tag.insertBefore(
|
|
7058
|
-
|
|
7059
|
-
|
|
7275
|
+
import_compiler37.types.variableDeclaration("const", [
|
|
7276
|
+
import_compiler37.types.variableDeclarator(peekScopeId, callRuntime("_peek_scope_id"))
|
|
7060
7277
|
])
|
|
7061
7278
|
);
|
|
7062
7279
|
setBindingSerializedValue(
|
|
@@ -7066,13 +7283,13 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7066
7283
|
);
|
|
7067
7284
|
if (tagVar) {
|
|
7068
7285
|
statements.push(
|
|
7069
|
-
|
|
7286
|
+
import_compiler37.types.expressionStatement(
|
|
7070
7287
|
callRuntime(
|
|
7071
7288
|
"_var",
|
|
7072
7289
|
getScopeIdIdentifier(section),
|
|
7073
7290
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
|
7074
7291
|
peekScopeId,
|
|
7075
|
-
|
|
7292
|
+
import_compiler37.types.stringLiteral(
|
|
7076
7293
|
getResumeRegisterId(
|
|
7077
7294
|
section,
|
|
7078
7295
|
node.var.extra?.binding,
|
|
@@ -7101,9 +7318,9 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7101
7318
|
if (reason) {
|
|
7102
7319
|
hasDynamicReasons ||= reason !== true && !reason.state;
|
|
7103
7320
|
props.push(
|
|
7104
|
-
|
|
7321
|
+
import_compiler37.types.objectProperty(
|
|
7105
7322
|
withLeadingComment(
|
|
7106
|
-
|
|
7323
|
+
import_compiler37.types.numericLiteral(i),
|
|
7107
7324
|
getDebugNames(group.reason)
|
|
7108
7325
|
),
|
|
7109
7326
|
getSerializeGuard(section, reason, false)
|
|
@@ -7114,12 +7331,12 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7114
7331
|
}
|
|
7115
7332
|
}
|
|
7116
7333
|
if (props.length) {
|
|
7117
|
-
childSerializeReasonExpr = hasDynamicReasons || hasSkippedReasons ?
|
|
7334
|
+
childSerializeReasonExpr = hasDynamicReasons || hasSkippedReasons ? import_compiler37.types.objectExpression(props) : import_compiler37.types.numericLiteral(1);
|
|
7118
7335
|
}
|
|
7119
7336
|
}
|
|
7120
7337
|
if (childSerializeReasonExpr) {
|
|
7121
7338
|
tag.insertBefore(
|
|
7122
|
-
|
|
7339
|
+
import_compiler37.types.expressionStatement(
|
|
7123
7340
|
callRuntime("_set_serialize_reason", childSerializeReasonExpr)
|
|
7124
7341
|
)
|
|
7125
7342
|
);
|
|
@@ -7135,39 +7352,7 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7135
7352
|
}
|
|
7136
7353
|
return renderArgs;
|
|
7137
7354
|
};
|
|
7138
|
-
if (
|
|
7139
|
-
const contentProp = getTranslatedBodyContentProperty(properties);
|
|
7140
|
-
let contentId = void 0;
|
|
7141
|
-
if (contentProp) {
|
|
7142
|
-
const contentExpression = contentProp.value;
|
|
7143
|
-
contentProp.value = contentId = generateUidIdentifier("content");
|
|
7144
|
-
const [contentPath] = tag.insertBefore(
|
|
7145
|
-
import_compiler34.types.variableDeclaration("const", [
|
|
7146
|
-
import_compiler34.types.variableDeclarator(
|
|
7147
|
-
contentId,
|
|
7148
|
-
// TODO: only register if needed (child template analysis)
|
|
7149
|
-
contentExpression
|
|
7150
|
-
)
|
|
7151
|
-
])
|
|
7152
|
-
);
|
|
7153
|
-
contentPath.skip();
|
|
7154
|
-
}
|
|
7155
|
-
let renderTagExpr = callExpression(
|
|
7156
|
-
tagIdentifier,
|
|
7157
|
-
...getArgs()
|
|
7158
|
-
);
|
|
7159
|
-
if (tagVar) {
|
|
7160
|
-
translateVar(tag, import_compiler34.types.unaryExpression("void", import_compiler34.types.numericLiteral(0)), "let");
|
|
7161
|
-
renderTagExpr = import_compiler34.types.assignmentExpression("=", tagVar, renderTagExpr);
|
|
7162
|
-
}
|
|
7163
|
-
statements.push(
|
|
7164
|
-
import_compiler34.types.ifStatement(
|
|
7165
|
-
tagIdentifier,
|
|
7166
|
-
import_compiler34.types.expressionStatement(renderTagExpr),
|
|
7167
|
-
contentId && callStatement(contentId)
|
|
7168
|
-
)
|
|
7169
|
-
);
|
|
7170
|
-
} else if (tagVar) {
|
|
7355
|
+
if (tagVar) {
|
|
7171
7356
|
translateVar(tag, callExpression(tagIdentifier, ...getArgs()), "let");
|
|
7172
7357
|
} else {
|
|
7173
7358
|
statements.push(callStatement(tagIdentifier, ...getArgs()));
|
|
@@ -7194,15 +7379,15 @@ function knownTagTranslateDOM(tag, propTree, getBindingIdentifier, callSetup) {
|
|
|
7194
7379
|
value
|
|
7195
7380
|
];
|
|
7196
7381
|
if (!isOptimize()) {
|
|
7197
|
-
changeArgs.push(
|
|
7382
|
+
changeArgs.push(import_compiler37.types.stringLiteral(varBinding.name));
|
|
7198
7383
|
}
|
|
7199
|
-
return
|
|
7384
|
+
return import_compiler37.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
7200
7385
|
};
|
|
7201
7386
|
addStatement(
|
|
7202
7387
|
"render",
|
|
7203
7388
|
tagSection,
|
|
7204
7389
|
void 0,
|
|
7205
|
-
|
|
7390
|
+
import_compiler37.types.expressionStatement(
|
|
7206
7391
|
callRuntime(
|
|
7207
7392
|
"_var",
|
|
7208
7393
|
scopeIdentifier,
|
|
@@ -7247,7 +7432,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7247
7432
|
dropReferences(getAllTagReferenceNodes(tag.node));
|
|
7248
7433
|
return inputExpr;
|
|
7249
7434
|
}
|
|
7250
|
-
if (!propTree.props || tag.node.arguments?.some((node) =>
|
|
7435
|
+
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
7251
7436
|
const extra = inputExpr.value = mergeReferences(
|
|
7252
7437
|
section,
|
|
7253
7438
|
tag.node,
|
|
@@ -7322,7 +7507,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7322
7507
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
7323
7508
|
for (const child of attrTags2) {
|
|
7324
7509
|
if (child.isMarkoTag()) {
|
|
7325
|
-
if ((0,
|
|
7510
|
+
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
7326
7511
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7327
7512
|
const childAttrExports = propTree.props[attrTagMeta.name];
|
|
7328
7513
|
if (childAttrExports) {
|
|
@@ -7398,7 +7583,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7398
7583
|
let spreadReferenceNodes;
|
|
7399
7584
|
for (let i = attributes.length; i--; ) {
|
|
7400
7585
|
const attr = attributes[i];
|
|
7401
|
-
if (
|
|
7586
|
+
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
7402
7587
|
const templateExportAttr = propTree.props[attr.name];
|
|
7403
7588
|
if (!templateExportAttr || seen.has(attr.name)) {
|
|
7404
7589
|
unknownReferences.push(attr.value);
|
|
@@ -7412,7 +7597,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7412
7597
|
}
|
|
7413
7598
|
if (spreadReferenceNodes) {
|
|
7414
7599
|
spreadReferenceNodes.push(attr.value);
|
|
7415
|
-
} else if (
|
|
7600
|
+
} else if (import_compiler37.types.isMarkoSpreadAttribute(attr)) {
|
|
7416
7601
|
spreadReferenceNodes = [attr.value];
|
|
7417
7602
|
} else {
|
|
7418
7603
|
const attrValueExtra = attr.value.extra ??= {};
|
|
@@ -7454,7 +7639,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7454
7639
|
return inputExpr;
|
|
7455
7640
|
}
|
|
7456
7641
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
7457
|
-
if (!propTree.props || tag.node.arguments?.some((node) =>
|
|
7642
|
+
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
7458
7643
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7459
7644
|
const tagInputIdentifier = info.getBindingIdentifier(
|
|
7460
7645
|
propTree.binding,
|
|
@@ -7482,8 +7667,8 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7482
7667
|
"render",
|
|
7483
7668
|
info.tagSection,
|
|
7484
7669
|
referencedBindings,
|
|
7485
|
-
|
|
7486
|
-
|
|
7670
|
+
import_compiler37.types.expressionStatement(
|
|
7671
|
+
import_compiler37.types.callExpression(tagInputIdentifier, [import_compiler37.types.arrayExpression(renderArgs)])
|
|
7487
7672
|
)
|
|
7488
7673
|
);
|
|
7489
7674
|
return;
|
|
@@ -7502,8 +7687,8 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7502
7687
|
info.tagSection,
|
|
7503
7688
|
arg.extra?.referencedBindings,
|
|
7504
7689
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7505
|
-
|
|
7506
|
-
|
|
7690
|
+
import_compiler37.types.expressionStatement(
|
|
7691
|
+
import_compiler37.types.callExpression(argExportIdentifier, [
|
|
7507
7692
|
createScopeReadExpression(
|
|
7508
7693
|
info.childScopeBinding,
|
|
7509
7694
|
info.tagSection
|
|
@@ -7555,7 +7740,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7555
7740
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
7556
7741
|
const child = attrTags2[i];
|
|
7557
7742
|
if (child.isMarkoTag()) {
|
|
7558
|
-
if ((0,
|
|
7743
|
+
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
7559
7744
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7560
7745
|
const childAttrExport = propTree.props[attrTagMeta.name];
|
|
7561
7746
|
if (childAttrExport) {
|
|
@@ -7591,17 +7776,17 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7591
7776
|
childAttrExports.binding,
|
|
7592
7777
|
`${importAlias}_${attrTagMeta.name}`
|
|
7593
7778
|
);
|
|
7594
|
-
decls.push(
|
|
7779
|
+
decls.push(import_compiler37.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
7595
7780
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
7596
|
-
|
|
7781
|
+
import_compiler37.types.variableDeclaration("let", decls),
|
|
7597
7782
|
...statements
|
|
7598
7783
|
]);
|
|
7599
7784
|
addStatement(
|
|
7600
7785
|
"render",
|
|
7601
7786
|
info.tagSection,
|
|
7602
7787
|
referencedBindings,
|
|
7603
|
-
|
|
7604
|
-
|
|
7788
|
+
import_compiler37.types.expressionStatement(
|
|
7789
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
7605
7790
|
createScopeReadExpression(
|
|
7606
7791
|
info.childScopeBinding,
|
|
7607
7792
|
info.tagSection
|
|
@@ -7626,13 +7811,13 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7626
7811
|
info.tagSection,
|
|
7627
7812
|
void 0,
|
|
7628
7813
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7629
|
-
|
|
7630
|
-
|
|
7814
|
+
import_compiler37.types.expressionStatement(
|
|
7815
|
+
import_compiler37.types.callExpression(contentExportIdentifier, [
|
|
7631
7816
|
createScopeReadExpression(
|
|
7632
7817
|
info.childScopeBinding,
|
|
7633
7818
|
info.tagSection
|
|
7634
7819
|
),
|
|
7635
|
-
|
|
7820
|
+
import_compiler37.types.callExpression(import_compiler37.types.identifier(bodySection.name), [
|
|
7636
7821
|
scopeIdentifier
|
|
7637
7822
|
])
|
|
7638
7823
|
])
|
|
@@ -7645,7 +7830,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7645
7830
|
let spreadProps;
|
|
7646
7831
|
for (let i = attributes.length; i--; ) {
|
|
7647
7832
|
const attr = attributes[i];
|
|
7648
|
-
if (
|
|
7833
|
+
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
7649
7834
|
const childAttrExports = propTree.props[attr.name];
|
|
7650
7835
|
if (!childAttrExports || seen.has(attr.name)) continue;
|
|
7651
7836
|
if (spreadProps) {
|
|
@@ -7655,9 +7840,9 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7655
7840
|
seen.add(attr.name);
|
|
7656
7841
|
staticAttrs.push(attr);
|
|
7657
7842
|
} else if (spreadProps) {
|
|
7658
|
-
spreadProps.push(
|
|
7843
|
+
spreadProps.push(import_compiler37.types.spreadElement(attr.value));
|
|
7659
7844
|
} else {
|
|
7660
|
-
spreadProps = [
|
|
7845
|
+
spreadProps = [import_compiler37.types.spreadElement(attr.value)];
|
|
7661
7846
|
}
|
|
7662
7847
|
}
|
|
7663
7848
|
for (const attr of staticAttrs.reverse()) {
|
|
@@ -7670,8 +7855,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7670
7855
|
"render",
|
|
7671
7856
|
info.tagSection,
|
|
7672
7857
|
attr.value.extra?.referencedBindings,
|
|
7673
|
-
|
|
7674
|
-
|
|
7858
|
+
import_compiler37.types.expressionStatement(
|
|
7859
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
7675
7860
|
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7676
7861
|
attr.value
|
|
7677
7862
|
])
|
|
@@ -7691,11 +7876,11 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7691
7876
|
} else {
|
|
7692
7877
|
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
7693
7878
|
if (translatedAttrs) {
|
|
7694
|
-
translatedAttrs.properties = [
|
|
7879
|
+
translatedAttrs.properties = [import_compiler37.types.spreadElement(spreadId)];
|
|
7695
7880
|
}
|
|
7696
7881
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
7697
|
-
|
|
7698
|
-
|
|
7882
|
+
import_compiler37.types.variableDeclaration("const", [
|
|
7883
|
+
import_compiler37.types.variableDeclarator(spreadId, spreadExpr)
|
|
7699
7884
|
])
|
|
7700
7885
|
]);
|
|
7701
7886
|
}
|
|
@@ -7710,15 +7895,15 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7710
7895
|
"render",
|
|
7711
7896
|
info.tagSection,
|
|
7712
7897
|
referencedBindings,
|
|
7713
|
-
|
|
7714
|
-
|
|
7898
|
+
import_compiler37.types.expressionStatement(
|
|
7899
|
+
import_compiler37.types.callExpression(
|
|
7715
7900
|
attrExportIdentifier,
|
|
7716
7901
|
spreadId ? [
|
|
7717
7902
|
createScopeReadExpression(
|
|
7718
7903
|
info.childScopeBinding,
|
|
7719
7904
|
info.tagSection
|
|
7720
7905
|
),
|
|
7721
|
-
toMemberExpression(
|
|
7906
|
+
toMemberExpression(import_compiler37.types.cloneNode(spreadId, true), name2)
|
|
7722
7907
|
] : [
|
|
7723
7908
|
createScopeReadExpression(
|
|
7724
7909
|
info.childScopeBinding,
|
|
@@ -7758,12 +7943,12 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7758
7943
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7759
7944
|
if (propTree.rest && spreadId) {
|
|
7760
7945
|
const props = [];
|
|
7761
|
-
const restId =
|
|
7946
|
+
const restId = import_compiler37.types.identifier(propTree.rest.binding.name);
|
|
7762
7947
|
forEach(propTree.rest.binding.excludeProperties, (name2) => {
|
|
7763
7948
|
const propId = toPropertyName(name2);
|
|
7764
|
-
const shorthand = propId.type === "Identifier" &&
|
|
7949
|
+
const shorthand = propId.type === "Identifier" && import_compiler37.types.isValidIdentifier(name2);
|
|
7765
7950
|
props.push(
|
|
7766
|
-
|
|
7951
|
+
import_compiler37.types.objectProperty(
|
|
7767
7952
|
propId,
|
|
7768
7953
|
shorthand ? propId : generateUidIdentifier(name2),
|
|
7769
7954
|
false,
|
|
@@ -7771,13 +7956,13 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7771
7956
|
)
|
|
7772
7957
|
);
|
|
7773
7958
|
});
|
|
7774
|
-
props.push(
|
|
7775
|
-
translatedProps =
|
|
7776
|
-
|
|
7959
|
+
props.push(import_compiler37.types.restElement(restId));
|
|
7960
|
+
translatedProps = import_compiler37.types.callExpression(
|
|
7961
|
+
import_compiler37.types.arrowFunctionExpression([import_compiler37.types.objectPattern(props)], restId),
|
|
7777
7962
|
[spreadId]
|
|
7778
7963
|
);
|
|
7779
7964
|
}
|
|
7780
|
-
if ((0,
|
|
7965
|
+
if ((0, import_babel_utils25.isAttributeTag)(tag)) {
|
|
7781
7966
|
const attrTagName = getTagName(tag);
|
|
7782
7967
|
const parentTag = tag.parentPath;
|
|
7783
7968
|
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
|
@@ -7802,7 +7987,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7802
7987
|
} else {
|
|
7803
7988
|
attrTagCallsForTag.set(
|
|
7804
7989
|
attrTagName,
|
|
7805
|
-
translatedProps =
|
|
7990
|
+
translatedProps = import_compiler37.types.parenthesizedExpression(
|
|
7806
7991
|
callRuntime("attrTag", translatedProps)
|
|
7807
7992
|
)
|
|
7808
7993
|
);
|
|
@@ -7815,8 +8000,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7815
8000
|
"render",
|
|
7816
8001
|
info.tagSection,
|
|
7817
8002
|
referencedBindings,
|
|
7818
|
-
|
|
7819
|
-
|
|
8003
|
+
import_compiler37.types.expressionStatement(
|
|
8004
|
+
import_compiler37.types.callExpression(tagInputIdentifier, [
|
|
7820
8005
|
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7821
8006
|
translatedProps
|
|
7822
8007
|
])
|
|
@@ -7851,10 +8036,10 @@ function mapParamReasonToExpr(exprs, reason) {
|
|
|
7851
8036
|
}
|
|
7852
8037
|
}
|
|
7853
8038
|
function callStatement(id, ...args) {
|
|
7854
|
-
return
|
|
8039
|
+
return import_compiler37.types.expressionStatement(callExpression(id, ...args));
|
|
7855
8040
|
}
|
|
7856
8041
|
function callExpression(id, ...args) {
|
|
7857
|
-
return
|
|
8042
|
+
return import_compiler37.types.callExpression(id, args.filter(Boolean));
|
|
7858
8043
|
}
|
|
7859
8044
|
function isSimpleReference(expr) {
|
|
7860
8045
|
switch (expr.type) {
|
|
@@ -7917,7 +8102,7 @@ function trackDomVarReferences(tag, binding) {
|
|
|
7917
8102
|
if (!tagVar) {
|
|
7918
8103
|
return;
|
|
7919
8104
|
}
|
|
7920
|
-
if (!
|
|
8105
|
+
if (!import_compiler38.types.isIdentifier(tagVar)) {
|
|
7921
8106
|
throw tag.get("var").buildCodeFrameError(
|
|
7922
8107
|
"Tag variables on native elements cannot be destructured."
|
|
7923
8108
|
);
|
|
@@ -8017,7 +8202,7 @@ function trackParamsReferences(body, type, upstreamAlias) {
|
|
|
8017
8202
|
void 0,
|
|
8018
8203
|
i > 0 ? addNumericPropertiesUntil(void 0, i - 1) : void 0
|
|
8019
8204
|
);
|
|
8020
|
-
} else if (
|
|
8205
|
+
} else if (import_compiler38.types.isLVal(param)) {
|
|
8021
8206
|
createBindingsAndTrackReferences(
|
|
8022
8207
|
param,
|
|
8023
8208
|
type,
|
|
@@ -8222,7 +8407,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
8222
8407
|
if (hasRest) {
|
|
8223
8408
|
excludeProperties = propsUtil.add(excludeProperties, key);
|
|
8224
8409
|
}
|
|
8225
|
-
if (
|
|
8410
|
+
if (import_compiler38.types.isLVal(prop.value)) {
|
|
8226
8411
|
createBindingsAndTrackReferences(
|
|
8227
8412
|
prop.value,
|
|
8228
8413
|
type,
|
|
@@ -8262,7 +8447,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
8262
8447
|
property,
|
|
8263
8448
|
excludeProperties
|
|
8264
8449
|
);
|
|
8265
|
-
} else if (
|
|
8450
|
+
} else if (import_compiler38.types.isLVal(element)) {
|
|
8266
8451
|
createBindingsAndTrackReferences(
|
|
8267
8452
|
element,
|
|
8268
8453
|
type,
|
|
@@ -8285,7 +8470,7 @@ function trackReference(referencePath, binding) {
|
|
|
8285
8470
|
let propPath = binding.name;
|
|
8286
8471
|
while (true) {
|
|
8287
8472
|
const { parent } = root;
|
|
8288
|
-
if (!
|
|
8473
|
+
if (!import_compiler38.types.isMemberExpression(parent) && !import_compiler38.types.isOptionalMemberExpression(parent))
|
|
8289
8474
|
break;
|
|
8290
8475
|
const prop = getMemberExpressionPropString(parent);
|
|
8291
8476
|
if (prop === void 0) break;
|
|
@@ -8626,7 +8811,7 @@ function finalizeReferences() {
|
|
|
8626
8811
|
});
|
|
8627
8812
|
}
|
|
8628
8813
|
});
|
|
8629
|
-
const programExtra = (0,
|
|
8814
|
+
const programExtra = (0, import_babel_utils26.getProgram)().node.extra;
|
|
8630
8815
|
if (programExtra.returnValueExpr) {
|
|
8631
8816
|
programExtra.section.returnSerializeReason = getSerializeSourcesForExpr(
|
|
8632
8817
|
programExtra.returnValueExpr
|
|
@@ -8858,11 +9043,11 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
|
|
|
8858
9043
|
function getScopeAccessorLiteral(binding, encoded, includeId) {
|
|
8859
9044
|
const canonicalBinding = getCanonicalBinding(binding);
|
|
8860
9045
|
if (isOptimize()) {
|
|
8861
|
-
return encoded ?
|
|
9046
|
+
return encoded ? import_compiler38.types.numericLiteral(canonicalBinding.id) : import_compiler38.types.stringLiteral(decodeAccessor(canonicalBinding.id));
|
|
8862
9047
|
} else if (includeId || canonicalBinding.type === 0 /* dom */) {
|
|
8863
|
-
return
|
|
9048
|
+
return import_compiler38.types.stringLiteral(`${canonicalBinding.name}/${canonicalBinding.id}`);
|
|
8864
9049
|
}
|
|
8865
|
-
return
|
|
9050
|
+
return import_compiler38.types.stringLiteral(canonicalBinding.name);
|
|
8866
9051
|
}
|
|
8867
9052
|
function getScopeAccessor(binding, encoded, includeId) {
|
|
8868
9053
|
const canonicalBinding = getCanonicalBinding(binding);
|
|
@@ -8910,7 +9095,7 @@ function getSectionInstancesAccessor(section) {
|
|
|
8910
9095
|
}
|
|
8911
9096
|
function getSectionInstancesAccessorLiteral(section) {
|
|
8912
9097
|
const accessor = getSectionInstancesAccessor(section);
|
|
8913
|
-
return accessor ? typeof accessor === "number" ?
|
|
9098
|
+
return accessor ? typeof accessor === "number" ? import_compiler38.types.numericLiteral(accessor) : import_compiler38.types.stringLiteral(accessor) : void 0;
|
|
8914
9099
|
}
|
|
8915
9100
|
function getReadReplacement(node) {
|
|
8916
9101
|
const { extra } = node;
|
|
@@ -8923,13 +9108,13 @@ function getReadReplacement(node) {
|
|
|
8923
9108
|
if (isOutputDOM()) {
|
|
8924
9109
|
if (readBinding.type === 0 /* dom */) {
|
|
8925
9110
|
if (!extra[kIsInvoked] && readBinding.section.domGetterBindings.has(readBinding)) {
|
|
8926
|
-
replacement =
|
|
9111
|
+
replacement = import_compiler38.types.callExpression(
|
|
8927
9112
|
getBindingGetterIdentifier(readBinding),
|
|
8928
9113
|
[getScopeExpression(extra.section, readBinding.section)]
|
|
8929
9114
|
);
|
|
8930
9115
|
}
|
|
8931
9116
|
} else if (readBinding.type === 6 /* hoist */ && extra[kIsInvoked]) {
|
|
8932
|
-
replacement =
|
|
9117
|
+
replacement = import_compiler38.types.callExpression(
|
|
8933
9118
|
getBindingGetterIdentifier(readBinding),
|
|
8934
9119
|
[getScopeExpression(extra.section, readBinding.section)]
|
|
8935
9120
|
);
|
|
@@ -8938,7 +9123,7 @@ function getReadReplacement(node) {
|
|
|
8938
9123
|
}
|
|
8939
9124
|
} else {
|
|
8940
9125
|
if (node.type !== "Identifier") {
|
|
8941
|
-
replacement =
|
|
9126
|
+
replacement = import_compiler38.types.identifier(readBinding.name);
|
|
8942
9127
|
} else if (readBinding.name !== node.name && readBinding.type !== 0 /* dom */ && (readBinding.type !== 6 /* hoist */ || !extra[kIsInvoked])) {
|
|
8943
9128
|
node.name = readBinding.name;
|
|
8944
9129
|
}
|
|
@@ -8948,7 +9133,7 @@ function getReadReplacement(node) {
|
|
|
8948
9133
|
let curNode = node;
|
|
8949
9134
|
let curBinding = read.binding;
|
|
8950
9135
|
let replaceMember;
|
|
8951
|
-
replacement = isOutputDOM() ? createScopeReadExpression(read.binding, extra.section) :
|
|
9136
|
+
replacement = isOutputDOM() ? createScopeReadExpression(read.binding, extra.section) : import_compiler38.types.identifier(read.binding.name);
|
|
8952
9137
|
while (props.length && (curNode.type === "MemberExpression" || curNode.type === "OptionalMemberExpression")) {
|
|
8953
9138
|
const prop = props.pop();
|
|
8954
9139
|
const memberProp = getMemberExpressionPropString(curNode);
|
|
@@ -9164,7 +9349,7 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9164
9349
|
let reason = serializeReasonCache.get(extra);
|
|
9165
9350
|
if (reason === false) return;
|
|
9166
9351
|
if (reason === void 0) {
|
|
9167
|
-
if (extra === (0,
|
|
9352
|
+
if (extra === (0, import_babel_utils26.getProgram)().node.extra?.returnValueExpr) {
|
|
9168
9353
|
reason = true;
|
|
9169
9354
|
} else {
|
|
9170
9355
|
forEach(extra.downstream, (binding) => {
|
|
@@ -9226,10 +9411,10 @@ function addNumericPropertiesUntil(props, len) {
|
|
|
9226
9411
|
var kDOMBinding = Symbol("await tag dom binding");
|
|
9227
9412
|
var await_default = {
|
|
9228
9413
|
analyze(tag) {
|
|
9229
|
-
(0,
|
|
9230
|
-
(0,
|
|
9414
|
+
(0, import_babel_utils27.assertNoVar)(tag);
|
|
9415
|
+
(0, import_babel_utils27.assertNoArgs)(tag);
|
|
9231
9416
|
assertNoSpreadAttrs(tag);
|
|
9232
|
-
(0,
|
|
9417
|
+
(0, import_babel_utils27.assertNoAttributeTags)(tag);
|
|
9233
9418
|
const { node } = tag;
|
|
9234
9419
|
const tagBody = tag.get("body");
|
|
9235
9420
|
const section = getOrCreateSection(tag);
|
|
@@ -9241,7 +9426,7 @@ var await_default = {
|
|
|
9241
9426
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
9242
9427
|
);
|
|
9243
9428
|
}
|
|
9244
|
-
if (node.attributes.length > 1 || !
|
|
9429
|
+
if (node.attributes.length > 1 || !import_compiler39.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
|
|
9245
9430
|
throw tag.get("name").buildCodeFrameError(
|
|
9246
9431
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
9247
9432
|
);
|
|
@@ -9251,7 +9436,7 @@ var await_default = {
|
|
|
9251
9436
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires [content](https://markojs.com/docs/reference/language#tag-content)."
|
|
9252
9437
|
);
|
|
9253
9438
|
}
|
|
9254
|
-
if (node.body.params.length && (node.body.params.length > 1 ||
|
|
9439
|
+
if (node.body.params.length && (node.body.params.length > 1 || import_compiler39.types.isSpreadElement(node.body.params[0]))) {
|
|
9255
9440
|
throw tag.get("name").buildCodeFrameError(
|
|
9256
9441
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) only supports a single parameter."
|
|
9257
9442
|
);
|
|
@@ -9288,13 +9473,13 @@ var await_default = {
|
|
|
9288
9473
|
flushInto(tag);
|
|
9289
9474
|
writeHTMLResumeStatements(tagBody);
|
|
9290
9475
|
tag.replaceWith(
|
|
9291
|
-
|
|
9476
|
+
import_compiler39.types.expressionStatement(
|
|
9292
9477
|
callRuntime(
|
|
9293
9478
|
"_await",
|
|
9294
9479
|
getScopeIdIdentifier(section),
|
|
9295
9480
|
getScopeAccessorLiteral(nodeRef),
|
|
9296
9481
|
valueAttr.value,
|
|
9297
|
-
|
|
9482
|
+
import_compiler39.types.arrowFunctionExpression(
|
|
9298
9483
|
node.body.params,
|
|
9299
9484
|
toFirstExpressionOrBlock(node.body.body)
|
|
9300
9485
|
),
|
|
@@ -9328,9 +9513,9 @@ var await_default = {
|
|
|
9328
9513
|
const branchRenderArgs = getBranchRendererArgs(bodySection);
|
|
9329
9514
|
const branchParams = branchRenderArgs.pop();
|
|
9330
9515
|
(signal.prependStatements ||= []).push(
|
|
9331
|
-
|
|
9332
|
-
|
|
9333
|
-
|
|
9516
|
+
import_compiler39.types.variableDeclaration("const", [
|
|
9517
|
+
import_compiler39.types.variableDeclarator(
|
|
9518
|
+
import_compiler39.types.identifier(bodySection.name),
|
|
9334
9519
|
callRuntime(
|
|
9335
9520
|
"_await_content",
|
|
9336
9521
|
getScopeAccessorLiteral(nodeRef, true),
|
|
@@ -9349,8 +9534,8 @@ var await_default = {
|
|
|
9349
9534
|
"render",
|
|
9350
9535
|
section,
|
|
9351
9536
|
void 0,
|
|
9352
|
-
|
|
9353
|
-
|
|
9537
|
+
import_compiler39.types.expressionStatement(
|
|
9538
|
+
import_compiler39.types.callExpression(import_compiler39.types.identifier(bodySection.name), [scopeIdentifier])
|
|
9354
9539
|
)
|
|
9355
9540
|
);
|
|
9356
9541
|
addValue(
|
|
@@ -9374,8 +9559,8 @@ var await_default = {
|
|
|
9374
9559
|
};
|
|
9375
9560
|
|
|
9376
9561
|
// src/translator/core/client.ts
|
|
9377
|
-
var
|
|
9378
|
-
var
|
|
9562
|
+
var import_compiler40 = require("@marko/compiler");
|
|
9563
|
+
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
|
9379
9564
|
var client_default = {
|
|
9380
9565
|
parse(tag) {
|
|
9381
9566
|
const {
|
|
@@ -9385,11 +9570,11 @@ var client_default = {
|
|
|
9385
9570
|
const rawValue = node.rawValue;
|
|
9386
9571
|
const code = rawValue.replace(/^client\s*/, "");
|
|
9387
9572
|
const start = node.start + (rawValue.length - code.length);
|
|
9388
|
-
let body = (0,
|
|
9389
|
-
if (body.length === 1 &&
|
|
9573
|
+
let body = (0, import_babel_utils28.parseStatements)(file, code, start, start + code.length);
|
|
9574
|
+
if (body.length === 1 && import_compiler40.types.isBlockStatement(body[0])) {
|
|
9390
9575
|
body = body[0].body;
|
|
9391
9576
|
}
|
|
9392
|
-
tag.replaceWith(
|
|
9577
|
+
tag.replaceWith(import_compiler40.types.markoScriptlet(body, true, "client"));
|
|
9393
9578
|
},
|
|
9394
9579
|
parseOptions: {
|
|
9395
9580
|
statement: true,
|
|
@@ -9405,12 +9590,12 @@ var client_default = {
|
|
|
9405
9590
|
};
|
|
9406
9591
|
|
|
9407
9592
|
// src/translator/core/const.ts
|
|
9408
|
-
var
|
|
9409
|
-
var
|
|
9593
|
+
var import_compiler41 = require("@marko/compiler");
|
|
9594
|
+
var import_babel_utils29 = require("@marko/compiler/babel-utils");
|
|
9410
9595
|
var const_default = {
|
|
9411
9596
|
analyze(tag) {
|
|
9412
|
-
(0,
|
|
9413
|
-
(0,
|
|
9597
|
+
(0, import_babel_utils29.assertNoArgs)(tag);
|
|
9598
|
+
(0, import_babel_utils29.assertNoParams)(tag);
|
|
9414
9599
|
assertNoBodyContent(tag);
|
|
9415
9600
|
const { node } = tag;
|
|
9416
9601
|
const [valueAttr] = node.attributes;
|
|
@@ -9424,13 +9609,13 @@ var const_default = {
|
|
|
9424
9609
|
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
9425
9610
|
);
|
|
9426
9611
|
}
|
|
9427
|
-
if (node.attributes.length > 1 || !
|
|
9612
|
+
if (node.attributes.length > 1 || !import_compiler41.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
|
9428
9613
|
throw tag.get("name").buildCodeFrameError(
|
|
9429
9614
|
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
9430
9615
|
);
|
|
9431
9616
|
}
|
|
9432
9617
|
const valueExtra = evaluate(valueAttr.value);
|
|
9433
|
-
const upstreamAlias =
|
|
9618
|
+
const upstreamAlias = import_compiler41.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
|
|
9434
9619
|
if (upstreamAlias) {
|
|
9435
9620
|
valueExtra.pruned = true;
|
|
9436
9621
|
}
|
|
@@ -9486,16 +9671,16 @@ var const_default = {
|
|
|
9486
9671
|
};
|
|
9487
9672
|
|
|
9488
9673
|
// src/translator/core/debug.ts
|
|
9489
|
-
var
|
|
9490
|
-
var
|
|
9674
|
+
var import_compiler42 = require("@marko/compiler");
|
|
9675
|
+
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
|
9491
9676
|
var debug_default = {
|
|
9492
9677
|
analyze(tag) {
|
|
9493
9678
|
const [valueAttr] = tag.node.attributes;
|
|
9494
|
-
(0,
|
|
9495
|
-
(0,
|
|
9496
|
-
(0,
|
|
9679
|
+
(0, import_babel_utils30.assertNoVar)(tag);
|
|
9680
|
+
(0, import_babel_utils30.assertNoArgs)(tag);
|
|
9681
|
+
(0, import_babel_utils30.assertNoParams)(tag);
|
|
9497
9682
|
assertNoBodyContent(tag);
|
|
9498
|
-
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!
|
|
9683
|
+
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler42.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
|
9499
9684
|
throw tag.get("name").buildCodeFrameError(
|
|
9500
9685
|
"The [`<debug>` tag](https://markojs.com/docs/reference/core-tag#debug) only supports the [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
9501
9686
|
);
|
|
@@ -9506,7 +9691,7 @@ var debug_default = {
|
|
|
9506
9691
|
const section = getSection(tag);
|
|
9507
9692
|
const [valueAttr] = tag.node.attributes;
|
|
9508
9693
|
const referencedBindings = valueAttr?.value.extra?.referencedBindings;
|
|
9509
|
-
const statement = withPreviousLocation(
|
|
9694
|
+
const statement = withPreviousLocation(import_compiler42.types.debuggerStatement(), tag.node);
|
|
9510
9695
|
if (isOutputHTML()) {
|
|
9511
9696
|
tag.insertBefore(statement);
|
|
9512
9697
|
} else {
|
|
@@ -9529,11 +9714,11 @@ var debug_default = {
|
|
|
9529
9714
|
};
|
|
9530
9715
|
|
|
9531
9716
|
// src/translator/core/define.ts
|
|
9532
|
-
var
|
|
9533
|
-
var
|
|
9717
|
+
var import_compiler43 = require("@marko/compiler");
|
|
9718
|
+
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
|
9534
9719
|
var define_default = {
|
|
9535
9720
|
analyze(tag) {
|
|
9536
|
-
(0,
|
|
9721
|
+
(0, import_babel_utils31.assertNoArgs)(tag);
|
|
9537
9722
|
if (!tag.node.var) {
|
|
9538
9723
|
throw tag.get("name").buildCodeFrameError(
|
|
9539
9724
|
"The [`<define>` tag](https://markojs.com/docs/reference/core-tag#define) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
|
@@ -9549,7 +9734,7 @@ var define_default = {
|
|
|
9549
9734
|
trackParamsReferences(tagBody, 3 /* param */);
|
|
9550
9735
|
setTagDownstream(tag, varBinding);
|
|
9551
9736
|
if (bodySection) {
|
|
9552
|
-
if (
|
|
9737
|
+
if (import_compiler43.types.isIdentifier(tag.node.var)) {
|
|
9553
9738
|
const babelBinding = tag.scope.getBinding(tag.node.var.name);
|
|
9554
9739
|
let allDirectReferences = true;
|
|
9555
9740
|
for (const ref of babelBinding.referencePaths) {
|
|
@@ -9598,7 +9783,7 @@ var define_default = {
|
|
|
9598
9783
|
tag.insertBefore(translatedAttrs.statements);
|
|
9599
9784
|
translateVar(tag, propsToExpression(translatedAttrs.properties));
|
|
9600
9785
|
} else {
|
|
9601
|
-
if (
|
|
9786
|
+
if (import_compiler43.types.isIdentifier(node.var)) {
|
|
9602
9787
|
const babelBinding = tag.scope.getBinding(node.var.name);
|
|
9603
9788
|
let hasDirectReferences = false;
|
|
9604
9789
|
let allDirectReferences = true;
|
|
@@ -9653,24 +9838,24 @@ var define_default = {
|
|
|
9653
9838
|
};
|
|
9654
9839
|
|
|
9655
9840
|
// src/translator/core/effect.ts
|
|
9656
|
-
var
|
|
9657
|
-
var
|
|
9841
|
+
var import_compiler44 = require("@marko/compiler");
|
|
9842
|
+
var import_babel_utils32 = require("@marko/compiler/babel-utils");
|
|
9658
9843
|
var effect_default = {
|
|
9659
9844
|
migrate: [
|
|
9660
9845
|
(tag) => {
|
|
9661
|
-
(0,
|
|
9662
|
-
(0,
|
|
9846
|
+
(0, import_babel_utils32.assertNoArgs)(tag);
|
|
9847
|
+
(0, import_babel_utils32.assertNoParams)(tag);
|
|
9663
9848
|
assertNoBodyContent(tag);
|
|
9664
|
-
(0,
|
|
9849
|
+
(0, import_babel_utils32.assertNoAttributeTags)(tag);
|
|
9665
9850
|
assertNoSpreadAttrs(tag);
|
|
9666
|
-
(0,
|
|
9667
|
-
(0,
|
|
9851
|
+
(0, import_babel_utils32.assertAllowedAttributes)(tag, ["value"]);
|
|
9852
|
+
(0, import_babel_utils32.diagnosticDeprecate)(tag, {
|
|
9668
9853
|
label: "The 'effect' tag has been replaced by the 'script' tag.",
|
|
9669
9854
|
fix() {
|
|
9670
9855
|
const { node } = tag;
|
|
9671
9856
|
tag.replaceWith(
|
|
9672
|
-
|
|
9673
|
-
withPreviousLocation(
|
|
9857
|
+
import_compiler44.types.markoTag(
|
|
9858
|
+
withPreviousLocation(import_compiler44.types.stringLiteral("script"), node.name),
|
|
9674
9859
|
node.attributes,
|
|
9675
9860
|
node.body,
|
|
9676
9861
|
node.arguments,
|
|
@@ -9687,12 +9872,12 @@ var effect_default = {
|
|
|
9687
9872
|
};
|
|
9688
9873
|
|
|
9689
9874
|
// src/translator/core/export.ts
|
|
9690
|
-
var
|
|
9875
|
+
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
|
9691
9876
|
var export_default = {
|
|
9692
9877
|
parse(tag) {
|
|
9693
9878
|
const { node } = tag;
|
|
9694
9879
|
tag.replaceWith(
|
|
9695
|
-
(0,
|
|
9880
|
+
(0, import_babel_utils33.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
9696
9881
|
);
|
|
9697
9882
|
},
|
|
9698
9883
|
parseOptions: {
|
|
@@ -9707,55 +9892,18 @@ var export_default = {
|
|
|
9707
9892
|
};
|
|
9708
9893
|
|
|
9709
9894
|
// src/translator/core/html-comment.ts
|
|
9710
|
-
var
|
|
9711
|
-
var
|
|
9712
|
-
|
|
9713
|
-
// src/translator/util/body-to-text-literal.ts
|
|
9714
|
-
var import_compiler42 = require("@marko/compiler");
|
|
9715
|
-
function bodyToTextLiteral(body) {
|
|
9716
|
-
const templateQuasis = [];
|
|
9717
|
-
const templateExpressions = [];
|
|
9718
|
-
let currentQuasi = "";
|
|
9719
|
-
let placeholderExtra;
|
|
9720
|
-
for (const child of body.body) {
|
|
9721
|
-
if (import_compiler42.types.isMarkoText(child)) {
|
|
9722
|
-
currentQuasi += child.value;
|
|
9723
|
-
} else if (import_compiler42.types.isMarkoPlaceholder(child)) {
|
|
9724
|
-
placeholderExtra ||= child.value.extra;
|
|
9725
|
-
templateQuasis.push(templateElement(currentQuasi, false));
|
|
9726
|
-
templateExpressions.push(callRuntime("_to_text", child.value));
|
|
9727
|
-
currentQuasi = "";
|
|
9728
|
-
}
|
|
9729
|
-
}
|
|
9730
|
-
if (templateExpressions.length) {
|
|
9731
|
-
templateQuasis.push(templateElement(currentQuasi, true));
|
|
9732
|
-
const literal = import_compiler42.types.templateLiteral(templateQuasis, templateExpressions);
|
|
9733
|
-
literal.extra = placeholderExtra;
|
|
9734
|
-
return literal;
|
|
9735
|
-
}
|
|
9736
|
-
return import_compiler42.types.stringLiteral(currentQuasi);
|
|
9737
|
-
}
|
|
9738
|
-
function templateElement(value, tail) {
|
|
9739
|
-
return import_compiler42.types.templateElement(
|
|
9740
|
-
{
|
|
9741
|
-
raw: value.replace(/`/g, "\\`"),
|
|
9742
|
-
cooked: value
|
|
9743
|
-
},
|
|
9744
|
-
tail
|
|
9745
|
-
);
|
|
9746
|
-
}
|
|
9747
|
-
|
|
9748
|
-
// src/translator/core/html-comment.ts
|
|
9895
|
+
var import_compiler45 = require("@marko/compiler");
|
|
9896
|
+
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
9749
9897
|
var kNodeBinding = Symbol("comment tag binding");
|
|
9750
9898
|
var html_comment_default = {
|
|
9751
9899
|
analyze(tag) {
|
|
9752
|
-
(0,
|
|
9753
|
-
(0,
|
|
9754
|
-
(0,
|
|
9900
|
+
(0, import_babel_utils34.assertNoArgs)(tag);
|
|
9901
|
+
(0, import_babel_utils34.assertNoParams)(tag);
|
|
9902
|
+
(0, import_babel_utils34.assertNoAttributes)(tag);
|
|
9755
9903
|
const tagVar = tag.node.var;
|
|
9756
9904
|
let needsBinding = false;
|
|
9757
9905
|
if (tagVar) {
|
|
9758
|
-
if (!
|
|
9906
|
+
if (!import_compiler45.types.isIdentifier(tagVar)) {
|
|
9759
9907
|
throw tag.get("var").buildCodeFrameError(
|
|
9760
9908
|
"The [`<html-comment>` tag](https://markojs.com/docs/reference/core-tag#html-comment) tag variable cannot be destructured."
|
|
9761
9909
|
);
|
|
@@ -9772,693 +9920,44 @@ var html_comment_default = {
|
|
|
9772
9920
|
"Invalid child. Only text is allowed inside an html comment."
|
|
9773
9921
|
);
|
|
9774
9922
|
}
|
|
9775
|
-
}
|
|
9776
|
-
if (needsBinding) {
|
|
9777
|
-
const tagSection = getOrCreateSection(tag);
|
|
9778
|
-
const tagExtra = mergeReferences(tagSection, tag.node, referenceNodes);
|
|
9779
|
-
const nodeBinding = tagExtra[kNodeBinding] = createBinding(
|
|
9780
|
-
"#comment",
|
|
9781
|
-
0 /* dom */,
|
|
9782
|
-
tagSection
|
|
9783
|
-
);
|
|
9784
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
9785
|
-
addSerializeExpr(tagSection, !!tagVar || tagExtra, nodeBinding);
|
|
9786
|
-
}
|
|
9787
|
-
tag.skip();
|
|
9788
|
-
},
|
|
9789
|
-
translate: {
|
|
9790
|
-
enter(tag) {
|
|
9791
|
-
const tagExtra = tag.node.extra;
|
|
9792
|
-
const nodeBinding = tagExtra[kNodeBinding];
|
|
9793
|
-
if (isOutputHTML()) {
|
|
9794
|
-
translateDomVar(tag, nodeBinding);
|
|
9795
|
-
}
|
|
9796
|
-
if (nodeBinding) {
|
|
9797
|
-
visit(tag, 32 /* Get */);
|
|
9798
|
-
}
|
|
9799
|
-
enter2(tag);
|
|
9800
|
-
writeTo(tag)`<!--`;
|
|
9801
|
-
},
|
|
9802
|
-
exit(tag) {
|
|
9803
|
-
const tagSection = getSection(tag);
|
|
9804
|
-
const tagExtra = tag.node.extra;
|
|
9805
|
-
const nodeBinding = tagExtra[kNodeBinding];
|
|
9806
|
-
const write = writeTo(tag);
|
|
9807
|
-
if (isOutputHTML()) {
|
|
9808
|
-
for (const child of tag.node.body.body) {
|
|
9809
|
-
if (import_compiler43.types.isMarkoText(child)) {
|
|
9810
|
-
write`${child.value}`;
|
|
9811
|
-
} else if (import_compiler43.types.isMarkoPlaceholder(child)) {
|
|
9812
|
-
write`${callRuntime("_to_text", child.value)}`;
|
|
9813
|
-
}
|
|
9814
|
-
}
|
|
9815
|
-
} else {
|
|
9816
|
-
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
9817
|
-
if (import_compiler43.types.isStringLiteral(textLiteral)) {
|
|
9818
|
-
write`${textLiteral}`;
|
|
9819
|
-
} else {
|
|
9820
|
-
addStatement(
|
|
9821
|
-
"render",
|
|
9822
|
-
getSection(tag),
|
|
9823
|
-
tagExtra.referencedBindings,
|
|
9824
|
-
import_compiler43.types.expressionStatement(
|
|
9825
|
-
callRuntime(
|
|
9826
|
-
"_text",
|
|
9827
|
-
createScopeReadExpression(nodeBinding),
|
|
9828
|
-
textLiteral
|
|
9829
|
-
)
|
|
9830
|
-
)
|
|
9831
|
-
);
|
|
9832
|
-
}
|
|
9833
|
-
}
|
|
9834
|
-
exit2(tag);
|
|
9835
|
-
write`-->`;
|
|
9836
|
-
if (nodeBinding) {
|
|
9837
|
-
markNode(
|
|
9838
|
-
tag,
|
|
9839
|
-
nodeBinding,
|
|
9840
|
-
getSerializeReason(tagSection, nodeBinding)
|
|
9841
|
-
);
|
|
9842
|
-
}
|
|
9843
|
-
tag.remove();
|
|
9844
|
-
}
|
|
9845
|
-
},
|
|
9846
|
-
parseOptions: {
|
|
9847
|
-
text: true
|
|
9848
|
-
},
|
|
9849
|
-
attributes: {},
|
|
9850
|
-
autocomplete: [
|
|
9851
|
-
{
|
|
9852
|
-
description: "Use to create an html comment that is not stripped from the output.",
|
|
9853
|
-
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-comment"
|
|
9854
|
-
}
|
|
9855
|
-
]
|
|
9856
|
-
};
|
|
9857
|
-
|
|
9858
|
-
// src/translator/core/html-script.ts
|
|
9859
|
-
var import_compiler44 = require("@marko/compiler");
|
|
9860
|
-
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
9861
|
-
var kNodeBinding2 = Symbol("script tag node binding");
|
|
9862
|
-
var html_script_default = {
|
|
9863
|
-
analyze(tag) {
|
|
9864
|
-
(0, import_babel_utils34.assertNoArgs)(tag);
|
|
9865
|
-
(0, import_babel_utils34.assertNoParams)(tag);
|
|
9866
|
-
const { node } = tag;
|
|
9867
|
-
if (node.var && !import_compiler44.types.isIdentifier(node.var)) {
|
|
9868
|
-
throw tag.get("var").buildCodeFrameError(
|
|
9869
|
-
"Tag variables on native elements cannot be destructured."
|
|
9870
|
-
);
|
|
9871
|
-
}
|
|
9872
|
-
const seen = {};
|
|
9873
|
-
const { attributes } = tag.node;
|
|
9874
|
-
let spreadReferenceNodes;
|
|
9875
|
-
let exprExtras;
|
|
9876
|
-
let hasEventHandlers = false;
|
|
9877
|
-
let hasDynamicAttributes = false;
|
|
9878
|
-
for (let i = attributes.length; i--; ) {
|
|
9879
|
-
const attr = attributes[i];
|
|
9880
|
-
const valueExtra = attr.value.extra ??= {};
|
|
9881
|
-
if (import_compiler44.types.isMarkoAttribute(attr)) {
|
|
9882
|
-
if (seen[attr.name]) {
|
|
9883
|
-
dropReferences(attr.value);
|
|
9884
|
-
continue;
|
|
9885
|
-
}
|
|
9886
|
-
seen[attr.name] = attr;
|
|
9887
|
-
if (isEventHandler(attr.name)) {
|
|
9888
|
-
valueExtra.isEffect = true;
|
|
9889
|
-
hasEventHandlers = true;
|
|
9890
|
-
} else if (!evaluate(attr.value).confident) {
|
|
9891
|
-
hasDynamicAttributes = true;
|
|
9892
|
-
}
|
|
9893
|
-
} else if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
9894
|
-
valueExtra.isEffect = true;
|
|
9895
|
-
hasEventHandlers = true;
|
|
9896
|
-
hasDynamicAttributes = true;
|
|
9897
|
-
}
|
|
9898
|
-
if (spreadReferenceNodes) {
|
|
9899
|
-
spreadReferenceNodes.push(attr.value);
|
|
9900
|
-
} else if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
9901
|
-
spreadReferenceNodes = [attr.value];
|
|
9902
|
-
} else {
|
|
9903
|
-
exprExtras = push(exprExtras, valueExtra);
|
|
9904
|
-
}
|
|
9905
|
-
}
|
|
9906
|
-
const bodyPlaceholderNodes = [];
|
|
9907
|
-
let hasBodyPlaceholders = false;
|
|
9908
|
-
for (const child of tag.node.body.body) {
|
|
9909
|
-
if (import_compiler44.types.isMarkoPlaceholder(child)) {
|
|
9910
|
-
bodyPlaceholderNodes.push(child.value);
|
|
9911
|
-
hasBodyPlaceholders = true;
|
|
9912
|
-
} else if (!import_compiler44.types.isMarkoText(child)) {
|
|
9913
|
-
throw tag.hub.buildError(
|
|
9914
|
-
child,
|
|
9915
|
-
"Invalid child. Only text is allowed inside an html-script."
|
|
9916
|
-
);
|
|
9917
|
-
}
|
|
9918
|
-
}
|
|
9919
|
-
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
9920
|
-
const tagExtra = node.extra ??= {};
|
|
9921
|
-
const tagSection = getOrCreateSection(tag);
|
|
9922
|
-
const nodeBinding = tagExtra[kNodeBinding2] = createBinding(
|
|
9923
|
-
"#script",
|
|
9924
|
-
0 /* dom */,
|
|
9925
|
-
tagSection
|
|
9926
|
-
);
|
|
9927
|
-
if (hasEventHandlers) {
|
|
9928
|
-
(0, import_babel_utils34.getProgram)().node.extra.isInteractive = true;
|
|
9929
|
-
}
|
|
9930
|
-
if (spreadReferenceNodes) {
|
|
9931
|
-
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
9932
|
-
}
|
|
9933
|
-
if (hasBodyPlaceholders) {
|
|
9934
|
-
exprExtras = push(
|
|
9935
|
-
exprExtras,
|
|
9936
|
-
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
9937
|
-
tagSection,
|
|
9938
|
-
bodyPlaceholderNodes[0],
|
|
9939
|
-
bodyPlaceholderNodes.slice(1)
|
|
9940
|
-
)
|
|
9941
|
-
);
|
|
9942
|
-
}
|
|
9943
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
9944
|
-
addSerializeExpr(
|
|
9945
|
-
tagSection,
|
|
9946
|
-
!!(node.var || hasEventHandlers),
|
|
9947
|
-
nodeBinding
|
|
9948
|
-
);
|
|
9949
|
-
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
9950
|
-
}
|
|
9951
|
-
},
|
|
9952
|
-
translate: {
|
|
9953
|
-
enter(tag) {
|
|
9954
|
-
const tagExtra = tag.node.extra;
|
|
9955
|
-
const nodeBinding = tagExtra[kNodeBinding2];
|
|
9956
|
-
const isHTML = isOutputHTML();
|
|
9957
|
-
const write = writeTo(tag);
|
|
9958
|
-
const tagSection = getSection(tag);
|
|
9959
|
-
if (isHTML) {
|
|
9960
|
-
translateDomVar(tag, nodeBinding);
|
|
9961
|
-
}
|
|
9962
|
-
if (nodeBinding) {
|
|
9963
|
-
visit(tag, 32 /* Get */);
|
|
9964
|
-
}
|
|
9965
|
-
write`<script`;
|
|
9966
|
-
const usedAttrs = getUsedAttrs2(tag.node, isHTML);
|
|
9967
|
-
const { hasNonce, staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
9968
|
-
if (isHTML && !hasNonce && !spreadExpression) {
|
|
9969
|
-
write`${callRuntime("_attr_nonce")}`;
|
|
9970
|
-
}
|
|
9971
|
-
for (const attr of staticAttrs) {
|
|
9972
|
-
const { name: name2, value } = attr;
|
|
9973
|
-
const { confident, computed } = value.extra || {};
|
|
9974
|
-
const valueReferences = value.extra?.referencedBindings;
|
|
9975
|
-
switch (name2) {
|
|
9976
|
-
case "class":
|
|
9977
|
-
case "style": {
|
|
9978
|
-
const helper = `_attr_${name2}`;
|
|
9979
|
-
if (confident) {
|
|
9980
|
-
write`${getHTMLRuntime()[helper](computed)}`;
|
|
9981
|
-
} else if (isHTML) {
|
|
9982
|
-
write`${callRuntime(helper, value)}`;
|
|
9983
|
-
} else {
|
|
9984
|
-
addStatement(
|
|
9985
|
-
"render",
|
|
9986
|
-
tagSection,
|
|
9987
|
-
valueReferences,
|
|
9988
|
-
import_compiler44.types.expressionStatement(
|
|
9989
|
-
callRuntime(
|
|
9990
|
-
helper,
|
|
9991
|
-
createScopeReadExpression(nodeBinding),
|
|
9992
|
-
value
|
|
9993
|
-
)
|
|
9994
|
-
)
|
|
9995
|
-
);
|
|
9996
|
-
}
|
|
9997
|
-
break;
|
|
9998
|
-
}
|
|
9999
|
-
default:
|
|
10000
|
-
if (confident) {
|
|
10001
|
-
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
10002
|
-
} else if (isHTML) {
|
|
10003
|
-
if (isEventHandler(name2)) {
|
|
10004
|
-
addHTMLEffectCall(tagSection, valueReferences);
|
|
10005
|
-
} else {
|
|
10006
|
-
write`${callRuntime("_attr", import_compiler44.types.stringLiteral(name2), value)}`;
|
|
10007
|
-
}
|
|
10008
|
-
} else if (isEventHandler(name2)) {
|
|
10009
|
-
addStatement(
|
|
10010
|
-
"effect",
|
|
10011
|
-
tagSection,
|
|
10012
|
-
valueReferences,
|
|
10013
|
-
import_compiler44.types.expressionStatement(
|
|
10014
|
-
callRuntime(
|
|
10015
|
-
"_on",
|
|
10016
|
-
createScopeReadExpression(nodeBinding),
|
|
10017
|
-
import_compiler44.types.stringLiteral(getEventHandlerName(name2)),
|
|
10018
|
-
value
|
|
10019
|
-
)
|
|
10020
|
-
)
|
|
10021
|
-
);
|
|
10022
|
-
} else {
|
|
10023
|
-
addStatement(
|
|
10024
|
-
"render",
|
|
10025
|
-
tagSection,
|
|
10026
|
-
valueReferences,
|
|
10027
|
-
import_compiler44.types.expressionStatement(
|
|
10028
|
-
callRuntime(
|
|
10029
|
-
"_attr",
|
|
10030
|
-
createScopeReadExpression(nodeBinding),
|
|
10031
|
-
import_compiler44.types.stringLiteral(name2),
|
|
10032
|
-
value
|
|
10033
|
-
)
|
|
10034
|
-
)
|
|
10035
|
-
);
|
|
10036
|
-
}
|
|
10037
|
-
break;
|
|
10038
|
-
}
|
|
10039
|
-
}
|
|
10040
|
-
if (spreadExpression) {
|
|
10041
|
-
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
|
10042
|
-
if (isHTML) {
|
|
10043
|
-
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
10044
|
-
if (skipExpression) {
|
|
10045
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler44.types.stringLiteral("script"))}`;
|
|
10046
|
-
} else {
|
|
10047
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler44.types.stringLiteral("script"))}`;
|
|
10048
|
-
}
|
|
10049
|
-
} else {
|
|
10050
|
-
if (skipExpression) {
|
|
10051
|
-
addStatement(
|
|
10052
|
-
"render",
|
|
10053
|
-
tagSection,
|
|
10054
|
-
tagExtra.referencedBindings,
|
|
10055
|
-
import_compiler44.types.expressionStatement(
|
|
10056
|
-
callRuntime(
|
|
10057
|
-
"_attrs_partial",
|
|
10058
|
-
scopeIdentifier,
|
|
10059
|
-
visitAccessor,
|
|
10060
|
-
spreadExpression,
|
|
10061
|
-
skipExpression
|
|
10062
|
-
)
|
|
10063
|
-
)
|
|
10064
|
-
);
|
|
10065
|
-
} else {
|
|
10066
|
-
addStatement(
|
|
10067
|
-
"render",
|
|
10068
|
-
tagSection,
|
|
10069
|
-
tagExtra.referencedBindings,
|
|
10070
|
-
import_compiler44.types.expressionStatement(
|
|
10071
|
-
callRuntime(
|
|
10072
|
-
"_attrs",
|
|
10073
|
-
scopeIdentifier,
|
|
10074
|
-
visitAccessor,
|
|
10075
|
-
spreadExpression
|
|
10076
|
-
)
|
|
10077
|
-
)
|
|
10078
|
-
);
|
|
10079
|
-
}
|
|
10080
|
-
addStatement(
|
|
10081
|
-
"effect",
|
|
10082
|
-
tagSection,
|
|
10083
|
-
tagExtra.referencedBindings,
|
|
10084
|
-
import_compiler44.types.expressionStatement(
|
|
10085
|
-
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
10086
|
-
),
|
|
10087
|
-
false
|
|
10088
|
-
);
|
|
10089
|
-
}
|
|
10090
|
-
}
|
|
10091
|
-
write`>`;
|
|
10092
|
-
enter2(tag);
|
|
10093
|
-
},
|
|
10094
|
-
exit(tag) {
|
|
10095
|
-
const tagSection = getSection(tag);
|
|
10096
|
-
const tagExtra = tag.node.extra;
|
|
10097
|
-
const nodeBinding = tagExtra[kNodeBinding2];
|
|
10098
|
-
const write = writeTo(tag);
|
|
10099
|
-
if (isOutputHTML()) {
|
|
10100
|
-
for (const child of tag.node.body.body) {
|
|
10101
|
-
if (import_compiler44.types.isMarkoText(child)) {
|
|
10102
|
-
write`${child.value}`;
|
|
10103
|
-
} else if (import_compiler44.types.isMarkoPlaceholder(child)) {
|
|
10104
|
-
write`${callRuntime("_escape_script", child.value)}`;
|
|
10105
|
-
}
|
|
10106
|
-
}
|
|
10107
|
-
} else {
|
|
10108
|
-
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
10109
|
-
if (import_compiler44.types.isStringLiteral(textLiteral)) {
|
|
10110
|
-
write`${textLiteral}`;
|
|
10111
|
-
} else {
|
|
10112
|
-
addStatement(
|
|
10113
|
-
"render",
|
|
10114
|
-
getSection(tag),
|
|
10115
|
-
textLiteral.extra?.referencedBindings,
|
|
10116
|
-
import_compiler44.types.expressionStatement(
|
|
10117
|
-
callRuntime(
|
|
10118
|
-
"_text_content",
|
|
10119
|
-
createScopeReadExpression(nodeBinding),
|
|
10120
|
-
textLiteral
|
|
10121
|
-
)
|
|
10122
|
-
)
|
|
10123
|
-
);
|
|
10124
|
-
}
|
|
10125
|
-
}
|
|
10126
|
-
write`</script>`;
|
|
10127
|
-
if (nodeBinding) {
|
|
10128
|
-
markNode(
|
|
10129
|
-
tag,
|
|
10130
|
-
nodeBinding,
|
|
10131
|
-
getSerializeReason(tagSection, nodeBinding)
|
|
10132
|
-
);
|
|
10133
|
-
}
|
|
10134
|
-
exit2(tag);
|
|
10135
|
-
tag.remove();
|
|
10136
|
-
}
|
|
10137
|
-
},
|
|
10138
|
-
"@async": "#html-async",
|
|
10139
|
-
"@crossorigin": "#html-crossorigin",
|
|
10140
|
-
"@defer": "#html-defer",
|
|
10141
|
-
"@integrity": "#html-integrity",
|
|
10142
|
-
"@nomodule": "#html-nomodule",
|
|
10143
|
-
"@nonce": "#html-nonce",
|
|
10144
|
-
"@referrerpolicy": "#html-referrerpolicy",
|
|
10145
|
-
"@src": "#html-src",
|
|
10146
|
-
"@type": "#html-type",
|
|
10147
|
-
"attribute-groups": ["html-attributes"],
|
|
10148
|
-
parseOptions: {
|
|
10149
|
-
text: true,
|
|
10150
|
-
preserveWhitespace: true
|
|
10151
|
-
},
|
|
10152
|
-
autocomplete: [
|
|
10153
|
-
{
|
|
10154
|
-
description: "Use instead of `<script>` to render a native tag directly, without processing by Marko.",
|
|
10155
|
-
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
|
|
10156
|
-
}
|
|
10157
|
-
]
|
|
10158
|
-
};
|
|
10159
|
-
function getUsedAttrs2(tag, injectNonce) {
|
|
10160
|
-
const seen = {};
|
|
10161
|
-
const { attributes } = tag;
|
|
10162
|
-
const maybeStaticAttrs = /* @__PURE__ */ new Set();
|
|
10163
|
-
let spreadExpression;
|
|
10164
|
-
let skipExpression;
|
|
10165
|
-
let spreadProps;
|
|
10166
|
-
let skipProps;
|
|
10167
|
-
let hasNonce = false;
|
|
10168
|
-
for (let i = attributes.length; i--; ) {
|
|
10169
|
-
const attr = attributes[i];
|
|
10170
|
-
const { value } = attr;
|
|
10171
|
-
if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
10172
|
-
if (!spreadProps) {
|
|
10173
|
-
spreadProps = [];
|
|
10174
|
-
}
|
|
10175
|
-
spreadProps.push(import_compiler44.types.spreadElement(value));
|
|
10176
|
-
} else if (!seen[attr.name]) {
|
|
10177
|
-
seen[attr.name] = attr;
|
|
10178
|
-
if (attr.name === "nonce") {
|
|
10179
|
-
hasNonce = true;
|
|
10180
|
-
}
|
|
10181
|
-
if (spreadProps) {
|
|
10182
|
-
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
10183
|
-
} else {
|
|
10184
|
-
maybeStaticAttrs.add(attr);
|
|
10185
|
-
}
|
|
10186
|
-
}
|
|
10187
|
-
}
|
|
10188
|
-
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
10189
|
-
if (spreadProps) {
|
|
10190
|
-
spreadProps.reverse();
|
|
10191
|
-
for (const { name: name2 } of staticAttrs) {
|
|
10192
|
-
(skipProps ||= []).push(toObjectProperty(name2, import_compiler44.types.numericLiteral(1)));
|
|
10193
|
-
}
|
|
10194
|
-
if (skipProps) {
|
|
10195
|
-
skipExpression = import_compiler44.types.objectExpression(skipProps);
|
|
10196
|
-
}
|
|
10197
|
-
if (injectNonce && !hasNonce) {
|
|
10198
|
-
spreadProps.unshift(
|
|
10199
|
-
import_compiler44.types.objectProperty(
|
|
10200
|
-
import_compiler44.types.identifier("nonce"),
|
|
10201
|
-
import_compiler44.types.memberExpression(callRuntime("$global"), import_compiler44.types.identifier("cspNonce"))
|
|
10202
|
-
)
|
|
10203
|
-
);
|
|
10204
|
-
}
|
|
10205
|
-
spreadExpression = propsToExpression(spreadProps);
|
|
10206
|
-
}
|
|
10207
|
-
return {
|
|
10208
|
-
hasNonce,
|
|
10209
|
-
staticAttrs,
|
|
10210
|
-
spreadExpression,
|
|
10211
|
-
skipExpression
|
|
10212
|
-
};
|
|
10213
|
-
}
|
|
10214
|
-
|
|
10215
|
-
// src/translator/core/html-style.ts
|
|
10216
|
-
var import_compiler45 = require("@marko/compiler");
|
|
10217
|
-
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
10218
|
-
var kNodeBinding3 = Symbol("style tag node binding");
|
|
10219
|
-
var html_style_default = {
|
|
10220
|
-
analyze(tag) {
|
|
10221
|
-
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
10222
|
-
(0, import_babel_utils35.assertNoParams)(tag);
|
|
10223
|
-
const { node } = tag;
|
|
10224
|
-
if (node.var && !import_compiler45.types.isIdentifier(node.var)) {
|
|
10225
|
-
throw tag.get("var").buildCodeFrameError(
|
|
10226
|
-
"Tag variables on native elements cannot be destructured."
|
|
10227
|
-
);
|
|
10228
|
-
}
|
|
10229
|
-
const seen = {};
|
|
10230
|
-
const { attributes } = tag.node;
|
|
10231
|
-
let spreadReferenceNodes;
|
|
10232
|
-
let exprExtras;
|
|
10233
|
-
let hasEventHandlers = false;
|
|
10234
|
-
let hasDynamicAttributes = false;
|
|
10235
|
-
for (let i = attributes.length; i--; ) {
|
|
10236
|
-
const attr = attributes[i];
|
|
10237
|
-
const valueExtra = attr.value.extra ??= {};
|
|
10238
|
-
if (import_compiler45.types.isMarkoAttribute(attr)) {
|
|
10239
|
-
if (seen[attr.name]) {
|
|
10240
|
-
dropReferences(attr.value);
|
|
10241
|
-
continue;
|
|
10242
|
-
}
|
|
10243
|
-
seen[attr.name] = attr;
|
|
10244
|
-
if (isEventHandler(attr.name)) {
|
|
10245
|
-
valueExtra.isEffect = true;
|
|
10246
|
-
hasEventHandlers = true;
|
|
10247
|
-
} else if (!evaluate(attr.value).confident) {
|
|
10248
|
-
hasDynamicAttributes = true;
|
|
10249
|
-
}
|
|
10250
|
-
} else if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
|
10251
|
-
valueExtra.isEffect = true;
|
|
10252
|
-
hasEventHandlers = true;
|
|
10253
|
-
hasDynamicAttributes = true;
|
|
10254
|
-
}
|
|
10255
|
-
if (spreadReferenceNodes) {
|
|
10256
|
-
spreadReferenceNodes.push(attr.value);
|
|
10257
|
-
} else if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
|
10258
|
-
spreadReferenceNodes = [attr.value];
|
|
10259
|
-
} else {
|
|
10260
|
-
exprExtras = push(exprExtras, valueExtra);
|
|
10261
|
-
}
|
|
10262
|
-
}
|
|
10263
|
-
const bodyPlaceholderNodes = [];
|
|
10264
|
-
let hasBodyPlaceholders = false;
|
|
10265
|
-
for (const child of tag.node.body.body) {
|
|
10266
|
-
if (import_compiler45.types.isMarkoPlaceholder(child)) {
|
|
10267
|
-
bodyPlaceholderNodes.push(child.value);
|
|
10268
|
-
hasBodyPlaceholders = true;
|
|
10269
|
-
} else if (!import_compiler45.types.isMarkoText(child)) {
|
|
10270
|
-
throw tag.hub.buildError(
|
|
10271
|
-
child,
|
|
10272
|
-
"Invalid child. Only text is allowed inside an html-style."
|
|
10273
|
-
);
|
|
10274
|
-
}
|
|
10275
|
-
}
|
|
10276
|
-
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
10277
|
-
const tagExtra = node.extra ??= {};
|
|
10278
|
-
const tagSection = getOrCreateSection(tag);
|
|
10279
|
-
const nodeBinding = tagExtra[kNodeBinding3] = createBinding(
|
|
10280
|
-
"#style",
|
|
10281
|
-
0 /* dom */,
|
|
10282
|
-
tagSection
|
|
10283
|
-
);
|
|
10284
|
-
if (hasEventHandlers) {
|
|
10285
|
-
(0, import_babel_utils35.getProgram)().node.extra.isInteractive = true;
|
|
10286
|
-
}
|
|
10287
|
-
if (spreadReferenceNodes) {
|
|
10288
|
-
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
10289
|
-
}
|
|
10290
|
-
if (hasBodyPlaceholders) {
|
|
10291
|
-
exprExtras = push(
|
|
10292
|
-
exprExtras,
|
|
10293
|
-
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
10294
|
-
tagSection,
|
|
10295
|
-
bodyPlaceholderNodes[0],
|
|
10296
|
-
bodyPlaceholderNodes.slice(1)
|
|
10297
|
-
)
|
|
10298
|
-
);
|
|
10299
|
-
}
|
|
10300
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
10301
|
-
addSerializeExpr(
|
|
10302
|
-
tagSection,
|
|
10303
|
-
!!(node.var || hasEventHandlers),
|
|
10304
|
-
nodeBinding
|
|
10305
|
-
);
|
|
10306
|
-
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
10307
|
-
}
|
|
10308
|
-
},
|
|
10309
|
-
translate: {
|
|
10310
|
-
enter(tag) {
|
|
10311
|
-
const tagExtra = tag.node.extra;
|
|
10312
|
-
const nodeBinding = tagExtra[kNodeBinding3];
|
|
10313
|
-
const isHTML = isOutputHTML();
|
|
10314
|
-
const write = writeTo(tag);
|
|
10315
|
-
const tagSection = getSection(tag);
|
|
10316
|
-
if (isHTML) {
|
|
10317
|
-
translateDomVar(tag, nodeBinding);
|
|
10318
|
-
}
|
|
10319
|
-
if (nodeBinding) {
|
|
10320
|
-
visit(tag, 32 /* Get */);
|
|
10321
|
-
}
|
|
10322
|
-
write`<style`;
|
|
10323
|
-
const usedAttrs = getUsedAttrs3(tag.node, isHTML);
|
|
10324
|
-
const { hasNonce, staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
10325
|
-
if (isHTML && !hasNonce && !spreadExpression) {
|
|
10326
|
-
write`${callRuntime("_attr_nonce")}`;
|
|
10327
|
-
}
|
|
10328
|
-
for (const attr of staticAttrs) {
|
|
10329
|
-
const { name: name2, value } = attr;
|
|
10330
|
-
const { confident, computed } = value.extra || {};
|
|
10331
|
-
const valueReferences = value.extra?.referencedBindings;
|
|
10332
|
-
switch (name2) {
|
|
10333
|
-
case "class":
|
|
10334
|
-
case "style": {
|
|
10335
|
-
const helper = `_attr_${name2}`;
|
|
10336
|
-
if (confident) {
|
|
10337
|
-
write`${getHTMLRuntime()[helper](computed)}`;
|
|
10338
|
-
} else if (isHTML) {
|
|
10339
|
-
write`${callRuntime(helper, value)}`;
|
|
10340
|
-
} else {
|
|
10341
|
-
addStatement(
|
|
10342
|
-
"render",
|
|
10343
|
-
tagSection,
|
|
10344
|
-
valueReferences,
|
|
10345
|
-
import_compiler45.types.expressionStatement(
|
|
10346
|
-
callRuntime(
|
|
10347
|
-
helper,
|
|
10348
|
-
createScopeReadExpression(nodeBinding),
|
|
10349
|
-
value
|
|
10350
|
-
)
|
|
10351
|
-
)
|
|
10352
|
-
);
|
|
10353
|
-
}
|
|
10354
|
-
break;
|
|
10355
|
-
}
|
|
10356
|
-
default:
|
|
10357
|
-
if (confident) {
|
|
10358
|
-
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
10359
|
-
} else if (isHTML) {
|
|
10360
|
-
if (isEventHandler(name2)) {
|
|
10361
|
-
addHTMLEffectCall(tagSection, valueReferences);
|
|
10362
|
-
} else {
|
|
10363
|
-
write`${callRuntime("_attr", import_compiler45.types.stringLiteral(name2), value)}`;
|
|
10364
|
-
}
|
|
10365
|
-
} else if (isEventHandler(name2)) {
|
|
10366
|
-
addStatement(
|
|
10367
|
-
"effect",
|
|
10368
|
-
tagSection,
|
|
10369
|
-
valueReferences,
|
|
10370
|
-
import_compiler45.types.expressionStatement(
|
|
10371
|
-
callRuntime(
|
|
10372
|
-
"_on",
|
|
10373
|
-
createScopeReadExpression(nodeBinding),
|
|
10374
|
-
import_compiler45.types.stringLiteral(getEventHandlerName(name2)),
|
|
10375
|
-
value
|
|
10376
|
-
)
|
|
10377
|
-
)
|
|
10378
|
-
);
|
|
10379
|
-
} else {
|
|
10380
|
-
addStatement(
|
|
10381
|
-
"render",
|
|
10382
|
-
tagSection,
|
|
10383
|
-
valueReferences,
|
|
10384
|
-
import_compiler45.types.expressionStatement(
|
|
10385
|
-
callRuntime(
|
|
10386
|
-
"_attr",
|
|
10387
|
-
createScopeReadExpression(nodeBinding),
|
|
10388
|
-
import_compiler45.types.stringLiteral(name2),
|
|
10389
|
-
value
|
|
10390
|
-
)
|
|
10391
|
-
)
|
|
10392
|
-
);
|
|
10393
|
-
}
|
|
10394
|
-
break;
|
|
10395
|
-
}
|
|
10396
|
-
}
|
|
10397
|
-
if (spreadExpression) {
|
|
10398
|
-
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
10399
|
-
if (isHTML) {
|
|
10400
|
-
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
10401
|
-
if (skipExpression) {
|
|
10402
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler45.types.stringLiteral("style"))}`;
|
|
10403
|
-
} else {
|
|
10404
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler45.types.stringLiteral("style"))}`;
|
|
10405
|
-
}
|
|
10406
|
-
} else {
|
|
10407
|
-
if (skipExpression) {
|
|
10408
|
-
addStatement(
|
|
10409
|
-
"render",
|
|
10410
|
-
tagSection,
|
|
10411
|
-
tagExtra.referencedBindings,
|
|
10412
|
-
import_compiler45.types.expressionStatement(
|
|
10413
|
-
callRuntime(
|
|
10414
|
-
"_attrs_partial",
|
|
10415
|
-
scopeIdentifier,
|
|
10416
|
-
visitAccessor,
|
|
10417
|
-
spreadExpression,
|
|
10418
|
-
skipExpression
|
|
10419
|
-
)
|
|
10420
|
-
)
|
|
10421
|
-
);
|
|
10422
|
-
} else {
|
|
10423
|
-
addStatement(
|
|
10424
|
-
"render",
|
|
10425
|
-
tagSection,
|
|
10426
|
-
tagExtra.referencedBindings,
|
|
10427
|
-
import_compiler45.types.expressionStatement(
|
|
10428
|
-
callRuntime(
|
|
10429
|
-
"_attrs",
|
|
10430
|
-
scopeIdentifier,
|
|
10431
|
-
visitAccessor,
|
|
10432
|
-
spreadExpression
|
|
10433
|
-
)
|
|
10434
|
-
)
|
|
10435
|
-
);
|
|
10436
|
-
}
|
|
10437
|
-
addStatement(
|
|
10438
|
-
"effect",
|
|
10439
|
-
tagSection,
|
|
10440
|
-
tagExtra.referencedBindings,
|
|
10441
|
-
import_compiler45.types.expressionStatement(
|
|
10442
|
-
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
10443
|
-
),
|
|
10444
|
-
false
|
|
10445
|
-
);
|
|
10446
|
-
}
|
|
9923
|
+
}
|
|
9924
|
+
if (needsBinding) {
|
|
9925
|
+
const tagSection = getOrCreateSection(tag);
|
|
9926
|
+
const tagExtra = mergeReferences(tagSection, tag.node, referenceNodes);
|
|
9927
|
+
const nodeBinding = tagExtra[kNodeBinding] = createBinding(
|
|
9928
|
+
"#comment",
|
|
9929
|
+
0 /* dom */,
|
|
9930
|
+
tagSection
|
|
9931
|
+
);
|
|
9932
|
+
trackDomVarReferences(tag, nodeBinding);
|
|
9933
|
+
addSerializeExpr(tagSection, !!tagVar || tagExtra, nodeBinding);
|
|
9934
|
+
}
|
|
9935
|
+
tag.skip();
|
|
9936
|
+
},
|
|
9937
|
+
translate: {
|
|
9938
|
+
enter(tag) {
|
|
9939
|
+
const tagExtra = tag.node.extra;
|
|
9940
|
+
const nodeBinding = tagExtra[kNodeBinding];
|
|
9941
|
+
if (isOutputHTML()) {
|
|
9942
|
+
translateDomVar(tag, nodeBinding);
|
|
9943
|
+
}
|
|
9944
|
+
if (nodeBinding) {
|
|
9945
|
+
visit(tag, 32 /* Get */);
|
|
10447
9946
|
}
|
|
10448
|
-
write`>`;
|
|
10449
9947
|
enter2(tag);
|
|
9948
|
+
writeTo(tag)`<!--`;
|
|
10450
9949
|
},
|
|
10451
9950
|
exit(tag) {
|
|
10452
9951
|
const tagSection = getSection(tag);
|
|
10453
9952
|
const tagExtra = tag.node.extra;
|
|
10454
|
-
const nodeBinding = tagExtra[
|
|
9953
|
+
const nodeBinding = tagExtra[kNodeBinding];
|
|
10455
9954
|
const write = writeTo(tag);
|
|
10456
9955
|
if (isOutputHTML()) {
|
|
10457
9956
|
for (const child of tag.node.body.body) {
|
|
10458
9957
|
if (import_compiler45.types.isMarkoText(child)) {
|
|
10459
9958
|
write`${child.value}`;
|
|
10460
9959
|
} else if (import_compiler45.types.isMarkoPlaceholder(child)) {
|
|
10461
|
-
write`${callRuntime("
|
|
9960
|
+
write`${callRuntime("_escape_text", child.value)}`;
|
|
10462
9961
|
}
|
|
10463
9962
|
}
|
|
10464
9963
|
} else {
|
|
@@ -10469,10 +9968,10 @@ var html_style_default = {
|
|
|
10469
9968
|
addStatement(
|
|
10470
9969
|
"render",
|
|
10471
9970
|
getSection(tag),
|
|
10472
|
-
|
|
9971
|
+
tagExtra.referencedBindings,
|
|
10473
9972
|
import_compiler45.types.expressionStatement(
|
|
10474
9973
|
callRuntime(
|
|
10475
|
-
"
|
|
9974
|
+
"_text",
|
|
10476
9975
|
createScopeReadExpression(nodeBinding),
|
|
10477
9976
|
textLiteral
|
|
10478
9977
|
)
|
|
@@ -10480,7 +9979,8 @@ var html_style_default = {
|
|
|
10480
9979
|
);
|
|
10481
9980
|
}
|
|
10482
9981
|
}
|
|
10483
|
-
|
|
9982
|
+
exit2(tag);
|
|
9983
|
+
write`-->`;
|
|
10484
9984
|
if (nodeBinding) {
|
|
10485
9985
|
markNode(
|
|
10486
9986
|
tag,
|
|
@@ -10488,91 +9988,62 @@ var html_style_default = {
|
|
|
10488
9988
|
getSerializeReason(tagSection, nodeBinding)
|
|
10489
9989
|
);
|
|
10490
9990
|
}
|
|
10491
|
-
exit2(tag);
|
|
10492
9991
|
tag.remove();
|
|
10493
9992
|
}
|
|
10494
9993
|
},
|
|
10495
|
-
|
|
10496
|
-
|
|
10497
|
-
|
|
10498
|
-
|
|
10499
|
-
|
|
9994
|
+
parseOptions: {
|
|
9995
|
+
text: true
|
|
9996
|
+
},
|
|
9997
|
+
types: runtime_info_default.name + "/tags/html-comment.d.marko",
|
|
9998
|
+
autocomplete: [
|
|
9999
|
+
{
|
|
10000
|
+
description: "Use to create an html comment that is not stripped from the output.",
|
|
10001
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-comment"
|
|
10002
|
+
}
|
|
10003
|
+
]
|
|
10004
|
+
};
|
|
10005
|
+
|
|
10006
|
+
// src/translator/core/html-script.ts
|
|
10007
|
+
var html_script_default = {
|
|
10008
|
+
types: runtime_info_default.name + "/tags/html-script.d.marko",
|
|
10009
|
+
html: true,
|
|
10500
10010
|
parseOptions: {
|
|
10501
10011
|
text: true,
|
|
10502
10012
|
preserveWhitespace: true
|
|
10503
10013
|
},
|
|
10504
10014
|
autocomplete: [
|
|
10505
10015
|
{
|
|
10506
|
-
description: "Use instead of `<
|
|
10016
|
+
description: "Use instead of `<script>` to render a native tag directly, without processing by Marko.",
|
|
10507
10017
|
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
|
|
10508
10018
|
}
|
|
10509
10019
|
]
|
|
10510
10020
|
};
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
|
|
10514
|
-
|
|
10515
|
-
|
|
10516
|
-
|
|
10517
|
-
|
|
10518
|
-
|
|
10519
|
-
|
|
10520
|
-
|
|
10521
|
-
|
|
10522
|
-
|
|
10523
|
-
|
|
10524
|
-
if (!spreadProps) {
|
|
10525
|
-
spreadProps = [];
|
|
10526
|
-
}
|
|
10527
|
-
spreadProps.push(import_compiler45.types.spreadElement(value));
|
|
10528
|
-
} else if (!seen[attr.name]) {
|
|
10529
|
-
seen[attr.name] = attr;
|
|
10530
|
-
if (attr.name === "nonce") {
|
|
10531
|
-
hasNonce = true;
|
|
10532
|
-
}
|
|
10533
|
-
if (spreadProps) {
|
|
10534
|
-
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
10535
|
-
} else {
|
|
10536
|
-
maybeStaticAttrs.add(attr);
|
|
10537
|
-
}
|
|
10538
|
-
}
|
|
10539
|
-
}
|
|
10540
|
-
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
10541
|
-
if (spreadProps) {
|
|
10542
|
-
spreadProps.reverse();
|
|
10543
|
-
for (const { name: name2 } of staticAttrs) {
|
|
10544
|
-
(skipProps ||= []).push(toObjectProperty(name2, import_compiler45.types.numericLiteral(1)));
|
|
10545
|
-
}
|
|
10546
|
-
if (skipProps) {
|
|
10547
|
-
skipExpression = import_compiler45.types.objectExpression(skipProps);
|
|
10548
|
-
}
|
|
10549
|
-
if (injectNonce && !hasNonce) {
|
|
10550
|
-
spreadProps.unshift(
|
|
10551
|
-
import_compiler45.types.objectProperty(
|
|
10552
|
-
import_compiler45.types.identifier("nonce"),
|
|
10553
|
-
import_compiler45.types.memberExpression(callRuntime("$global"), import_compiler45.types.identifier("cspNonce"))
|
|
10554
|
-
)
|
|
10555
|
-
);
|
|
10021
|
+
|
|
10022
|
+
// src/translator/core/html-style.ts
|
|
10023
|
+
var html_style_default = {
|
|
10024
|
+
types: runtime_info_default.name + "/tags/html-style.d.marko",
|
|
10025
|
+
html: true,
|
|
10026
|
+
parseOptions: {
|
|
10027
|
+
text: true,
|
|
10028
|
+
preserveWhitespace: true
|
|
10029
|
+
},
|
|
10030
|
+
autocomplete: [
|
|
10031
|
+
{
|
|
10032
|
+
description: "Use instead of `<style>` to render a native tag directly, without processing by Marko.",
|
|
10033
|
+
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
|
|
10556
10034
|
}
|
|
10557
|
-
|
|
10558
|
-
|
|
10559
|
-
return {
|
|
10560
|
-
hasNonce,
|
|
10561
|
-
staticAttrs,
|
|
10562
|
-
spreadExpression,
|
|
10563
|
-
skipExpression
|
|
10564
|
-
};
|
|
10565
|
-
}
|
|
10035
|
+
]
|
|
10036
|
+
};
|
|
10566
10037
|
|
|
10567
10038
|
// src/translator/core/id.ts
|
|
10568
10039
|
var import_compiler46 = require("@marko/compiler");
|
|
10569
|
-
var
|
|
10040
|
+
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
10570
10041
|
var id_default = {
|
|
10571
10042
|
analyze(tag) {
|
|
10572
|
-
(0,
|
|
10573
|
-
(0,
|
|
10043
|
+
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
10044
|
+
(0, import_babel_utils35.assertNoParams)(tag);
|
|
10574
10045
|
assertNoBodyContent(tag);
|
|
10575
|
-
(0,
|
|
10046
|
+
(0, import_babel_utils35.assertNoAttributeTags)(tag);
|
|
10576
10047
|
const { node } = tag;
|
|
10577
10048
|
const [valueAttr] = node.attributes;
|
|
10578
10049
|
if (!node.var) {
|
|
@@ -10644,7 +10115,7 @@ var id_default = {
|
|
|
10644
10115
|
|
|
10645
10116
|
// src/translator/core/if.ts
|
|
10646
10117
|
var import_compiler48 = require("@marko/compiler");
|
|
10647
|
-
var
|
|
10118
|
+
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
|
10648
10119
|
|
|
10649
10120
|
// src/translator/util/to-first-statement-or-block.ts
|
|
10650
10121
|
var import_compiler47 = require("@marko/compiler");
|
|
@@ -10912,9 +10383,9 @@ var ElseTag = {
|
|
|
10912
10383
|
]
|
|
10913
10384
|
};
|
|
10914
10385
|
function assertValidCondition(tag) {
|
|
10915
|
-
(0,
|
|
10916
|
-
(0,
|
|
10917
|
-
(0,
|
|
10386
|
+
(0, import_babel_utils36.assertNoVar)(tag);
|
|
10387
|
+
(0, import_babel_utils36.assertNoArgs)(tag);
|
|
10388
|
+
(0, import_babel_utils36.assertNoParams)(tag);
|
|
10918
10389
|
assertHasBody(tag);
|
|
10919
10390
|
assertNoSpreadAttrs(tag);
|
|
10920
10391
|
switch (getTagName(tag)) {
|
|
@@ -11013,12 +10484,12 @@ function isRoot(tag) {
|
|
|
11013
10484
|
}
|
|
11014
10485
|
|
|
11015
10486
|
// src/translator/core/import.ts
|
|
11016
|
-
var
|
|
10487
|
+
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
|
11017
10488
|
var import_default = {
|
|
11018
10489
|
parse(tag) {
|
|
11019
10490
|
const { node } = tag;
|
|
11020
10491
|
tag.replaceWith(
|
|
11021
|
-
(0,
|
|
10492
|
+
(0, import_babel_utils37.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
11022
10493
|
);
|
|
11023
10494
|
},
|
|
11024
10495
|
parseOptions: {
|
|
@@ -11037,7 +10508,7 @@ var import_default = {
|
|
|
11037
10508
|
|
|
11038
10509
|
// src/translator/core/let.ts
|
|
11039
10510
|
var import_compiler49 = require("@marko/compiler");
|
|
11040
|
-
var
|
|
10511
|
+
var import_babel_utils38 = require("@marko/compiler/babel-utils");
|
|
11041
10512
|
var let_default = {
|
|
11042
10513
|
analyze(tag) {
|
|
11043
10514
|
const { node } = tag;
|
|
@@ -11066,8 +10537,8 @@ var let_default = {
|
|
|
11066
10537
|
}
|
|
11067
10538
|
}
|
|
11068
10539
|
}
|
|
11069
|
-
(0,
|
|
11070
|
-
(0,
|
|
10540
|
+
(0, import_babel_utils38.assertNoArgs)(tag);
|
|
10541
|
+
(0, import_babel_utils38.assertNoParams)(tag);
|
|
11071
10542
|
assertNoBodyContent(tag);
|
|
11072
10543
|
assertNoSpreadAttrs(tag);
|
|
11073
10544
|
if (!tagVar) {
|
|
@@ -11080,7 +10551,7 @@ var let_default = {
|
|
|
11080
10551
|
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) variable cannot be destructured."
|
|
11081
10552
|
);
|
|
11082
10553
|
}
|
|
11083
|
-
if (valueChangeAttr && (0,
|
|
10554
|
+
if (valueChangeAttr && (0, import_babel_utils38.computeNode)(valueChangeAttr.value)?.value) {
|
|
11084
10555
|
throw tag.get("attributes").find((attr) => attr.node === valueChangeAttr).get("value").buildCodeFrameError(
|
|
11085
10556
|
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) [`valueChange=` attribute](https://markojs.com/docs/reference/core-tag#controllable-let) must be a function."
|
|
11086
10557
|
);
|
|
@@ -11163,13 +10634,13 @@ var let_default = {
|
|
|
11163
10634
|
|
|
11164
10635
|
// src/translator/core/lifecycle.ts
|
|
11165
10636
|
var import_compiler50 = require("@marko/compiler");
|
|
11166
|
-
var
|
|
10637
|
+
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
|
11167
10638
|
var kRef = Symbol("lifecycle attrs reference");
|
|
11168
10639
|
var lifecycle_default = {
|
|
11169
10640
|
analyze(tag) {
|
|
11170
|
-
(0,
|
|
11171
|
-
(0,
|
|
11172
|
-
(0,
|
|
10641
|
+
(0, import_babel_utils39.assertNoArgs)(tag);
|
|
10642
|
+
(0, import_babel_utils39.assertNoVar)(tag);
|
|
10643
|
+
(0, import_babel_utils39.assertNoParams)(tag);
|
|
11173
10644
|
assertNoBodyContent(tag);
|
|
11174
10645
|
const { node } = tag;
|
|
11175
10646
|
const section = getOrCreateSection(tag);
|
|
@@ -11197,7 +10668,7 @@ var lifecycle_default = {
|
|
|
11197
10668
|
}
|
|
11198
10669
|
(attr.value.extra ??= {}).isEffect = true;
|
|
11199
10670
|
}
|
|
11200
|
-
(0,
|
|
10671
|
+
(0, import_babel_utils39.getProgram)().node.extra.isInteractive = true;
|
|
11201
10672
|
},
|
|
11202
10673
|
translate: {
|
|
11203
10674
|
exit(tag) {
|
|
@@ -11245,13 +10716,13 @@ var lifecycle_default = {
|
|
|
11245
10716
|
|
|
11246
10717
|
// src/translator/core/log.ts
|
|
11247
10718
|
var import_compiler51 = require("@marko/compiler");
|
|
11248
|
-
var
|
|
10719
|
+
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
|
11249
10720
|
var log_default = {
|
|
11250
10721
|
analyze(tag) {
|
|
11251
10722
|
const [valueAttr] = tag.node.attributes;
|
|
11252
|
-
(0,
|
|
11253
|
-
(0,
|
|
11254
|
-
(0,
|
|
10723
|
+
(0, import_babel_utils40.assertNoArgs)(tag);
|
|
10724
|
+
(0, import_babel_utils40.assertNoVar)(tag);
|
|
10725
|
+
(0, import_babel_utils40.assertNoParams)(tag);
|
|
11255
10726
|
assertNoBodyContent(tag);
|
|
11256
10727
|
if (!valueAttr) {
|
|
11257
10728
|
throw tag.get("name").buildCodeFrameError(
|
|
@@ -11299,7 +10770,7 @@ var log_default = {
|
|
|
11299
10770
|
|
|
11300
10771
|
// src/translator/core/script.ts
|
|
11301
10772
|
var import_compiler52 = require("@marko/compiler");
|
|
11302
|
-
var
|
|
10773
|
+
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
|
11303
10774
|
var htmlScriptTagAlternateMsg = " For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.";
|
|
11304
10775
|
var script_default = {
|
|
11305
10776
|
parse(tag) {
|
|
@@ -11319,7 +10790,7 @@ var script_default = {
|
|
|
11319
10790
|
}
|
|
11320
10791
|
const start = body[0]?.start;
|
|
11321
10792
|
const end = body[body.length - 1]?.end;
|
|
11322
|
-
const bodyStatements = (0,
|
|
10793
|
+
const bodyStatements = (0, import_babel_utils41.parseStatements)(tag.hub.file, code, start, end);
|
|
11323
10794
|
if (bodyStatements.length) {
|
|
11324
10795
|
const valueFn = import_compiler52.types.arrowFunctionExpression(
|
|
11325
10796
|
[],
|
|
@@ -11333,10 +10804,10 @@ var script_default = {
|
|
|
11333
10804
|
},
|
|
11334
10805
|
analyze(tag) {
|
|
11335
10806
|
const { node } = tag;
|
|
11336
|
-
(0,
|
|
11337
|
-
(0,
|
|
10807
|
+
(0, import_babel_utils41.assertNoArgs)(tag);
|
|
10808
|
+
(0, import_babel_utils41.assertNoParams)(tag);
|
|
11338
10809
|
assertNoBodyContent(tag);
|
|
11339
|
-
(0,
|
|
10810
|
+
(0, import_babel_utils41.assertNoAttributeTags)(tag);
|
|
11340
10811
|
if (node.var) {
|
|
11341
10812
|
throw tag.hub.buildError(
|
|
11342
10813
|
node.var,
|
|
@@ -11351,7 +10822,7 @@ var script_default = {
|
|
|
11351
10822
|
}
|
|
11352
10823
|
seenValueAttr = true;
|
|
11353
10824
|
(attr.value.extra ??= {}).isEffect = true;
|
|
11354
|
-
(0,
|
|
10825
|
+
(0, import_babel_utils41.getProgram)().node.extra.isInteractive = true;
|
|
11355
10826
|
} else {
|
|
11356
10827
|
throw tag.hub.buildError(
|
|
11357
10828
|
attr,
|
|
@@ -11413,7 +10884,6 @@ var script_default = {
|
|
|
11413
10884
|
text: true,
|
|
11414
10885
|
preserveWhitespace: true
|
|
11415
10886
|
},
|
|
11416
|
-
attributes: {},
|
|
11417
10887
|
autocomplete: [
|
|
11418
10888
|
{
|
|
11419
10889
|
description: "Use to create a side effects.",
|
|
@@ -11442,7 +10912,7 @@ function isAwaitExpression(node) {
|
|
|
11442
10912
|
|
|
11443
10913
|
// src/translator/core/server.ts
|
|
11444
10914
|
var import_compiler53 = require("@marko/compiler");
|
|
11445
|
-
var
|
|
10915
|
+
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
|
11446
10916
|
var server_default = {
|
|
11447
10917
|
parse(tag) {
|
|
11448
10918
|
const {
|
|
@@ -11452,7 +10922,7 @@ var server_default = {
|
|
|
11452
10922
|
const rawValue = node.rawValue;
|
|
11453
10923
|
const code = rawValue.replace(/^server\s*/, "");
|
|
11454
10924
|
const start = node.start + (rawValue.length - code.length);
|
|
11455
|
-
let body = (0,
|
|
10925
|
+
let body = (0, import_babel_utils42.parseStatements)(file, code, start, start + code.length);
|
|
11456
10926
|
if (body.length === 1 && import_compiler53.types.isBlockStatement(body[0])) {
|
|
11457
10927
|
body = body[0].body;
|
|
11458
10928
|
}
|
|
@@ -11473,7 +10943,7 @@ var server_default = {
|
|
|
11473
10943
|
|
|
11474
10944
|
// src/translator/core/static.ts
|
|
11475
10945
|
var import_compiler54 = require("@marko/compiler");
|
|
11476
|
-
var
|
|
10946
|
+
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
|
11477
10947
|
var static_default = {
|
|
11478
10948
|
parse(tag) {
|
|
11479
10949
|
const {
|
|
@@ -11483,7 +10953,7 @@ var static_default = {
|
|
|
11483
10953
|
const rawValue = node.rawValue;
|
|
11484
10954
|
const code = rawValue.replace(/^static\s*/, "");
|
|
11485
10955
|
const start = node.start + (rawValue.length - code.length);
|
|
11486
|
-
let body = (0,
|
|
10956
|
+
let body = (0, import_babel_utils43.parseStatements)(file, code, start, start + code.length);
|
|
11487
10957
|
if (body.length === 1 && import_compiler54.types.isBlockStatement(body[0])) {
|
|
11488
10958
|
body = body[0].body;
|
|
11489
10959
|
}
|
|
@@ -11504,16 +10974,16 @@ var static_default = {
|
|
|
11504
10974
|
|
|
11505
10975
|
// src/translator/core/style.ts
|
|
11506
10976
|
var import_compiler55 = require("@marko/compiler");
|
|
11507
|
-
var
|
|
10977
|
+
var import_babel_utils44 = require("@marko/compiler/babel-utils");
|
|
11508
10978
|
var import_magic_string = __toESM(require("magic-string"));
|
|
11509
10979
|
var import_path3 = __toESM(require("path"));
|
|
11510
10980
|
var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
|
11511
10981
|
var htmlStyleTagAlternateMsg = " For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.";
|
|
11512
10982
|
var style_default = {
|
|
11513
10983
|
analyze(tag) {
|
|
11514
|
-
(0,
|
|
11515
|
-
(0,
|
|
11516
|
-
(0,
|
|
10984
|
+
(0, import_babel_utils44.assertNoArgs)(tag);
|
|
10985
|
+
(0, import_babel_utils44.assertNoParams)(tag);
|
|
10986
|
+
(0, import_babel_utils44.assertNoAttributeTags)(tag);
|
|
11517
10987
|
const { node } = tag;
|
|
11518
10988
|
const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
|
|
11519
10989
|
for (const attr of node.attributes) {
|
|
@@ -11552,8 +11022,8 @@ var style_default = {
|
|
|
11552
11022
|
}
|
|
11553
11023
|
const markoText = node.body.body[0];
|
|
11554
11024
|
const { resolveVirtualDependency } = getMarkoOpts();
|
|
11555
|
-
const start = (0,
|
|
11556
|
-
const end = (0,
|
|
11025
|
+
const start = (0, import_babel_utils44.getStart)(file, markoText);
|
|
11026
|
+
const end = (0, import_babel_utils44.getEnd)(file, markoText);
|
|
11557
11027
|
let code = markoText.value;
|
|
11558
11028
|
let map;
|
|
11559
11029
|
if (resolveVirtualDependency && sourceMaps && start !== null && end !== null) {
|
|
@@ -11563,422 +11033,63 @@ var style_default = {
|
|
|
11563
11033
|
map = magicString.generateMap({
|
|
11564
11034
|
source: filename,
|
|
11565
11035
|
includeContent: true
|
|
11566
|
-
});
|
|
11567
|
-
if (sourceMaps === "inline" || sourceMaps === "both") {
|
|
11568
|
-
code += `
|
|
11569
|
-
/*# sourceMappingURL=${map.toUrl()}*/`;
|
|
11570
|
-
if (sourceMaps === "inline") {
|
|
11571
|
-
map = void 0;
|
|
11572
|
-
}
|
|
11573
|
-
}
|
|
11574
|
-
}
|
|
11575
|
-
const importPath = resolveVirtualDependency?.(filename, {
|
|
11576
|
-
virtualPath: `./${import_path3.default.basename(filename) + ext}`,
|
|
11577
|
-
code,
|
|
11578
|
-
map
|
|
11579
|
-
});
|
|
11580
|
-
if (importPath) {
|
|
11581
|
-
if (!node.var) {
|
|
11582
|
-
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11583
|
-
import_compiler55.types.importDeclaration([], import_compiler55.types.stringLiteral(importPath))
|
|
11584
|
-
);
|
|
11585
|
-
} else if (import_compiler55.types.isIdentifier(node.var)) {
|
|
11586
|
-
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11587
|
-
import_compiler55.types.importDeclaration(
|
|
11588
|
-
[import_compiler55.types.importNamespaceSpecifier(node.var)],
|
|
11589
|
-
import_compiler55.types.stringLiteral(importPath)
|
|
11590
|
-
)
|
|
11591
|
-
);
|
|
11592
|
-
} else {
|
|
11593
|
-
const varDecl = import_compiler55.types.variableDeclaration("const", [
|
|
11594
|
-
import_compiler55.types.variableDeclarator(node.var, (0, import_babel_utils45.importStar)(file, importPath, "style"))
|
|
11595
|
-
]);
|
|
11596
|
-
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11597
|
-
isOutputDOM() ? varDecl : import_compiler55.types.markoScriptlet([varDecl], true)
|
|
11598
|
-
);
|
|
11599
|
-
}
|
|
11600
|
-
}
|
|
11601
|
-
tag.remove();
|
|
11602
|
-
},
|
|
11603
|
-
parseOptions: {
|
|
11604
|
-
html: false,
|
|
11605
|
-
text: true,
|
|
11606
|
-
rawOpenTag: true,
|
|
11607
|
-
preserveWhitespace: true
|
|
11608
|
-
},
|
|
11609
|
-
attributes: {}
|
|
11610
|
-
};
|
|
11611
|
-
|
|
11612
|
-
// src/translator/core/textarea.ts
|
|
11613
|
-
var import_compiler56 = require("@marko/compiler");
|
|
11614
|
-
var textarea_default = {
|
|
11615
|
-
parse(tag) {
|
|
11616
|
-
if (tag.node.body.body.length) {
|
|
11617
|
-
const parts = [];
|
|
11618
|
-
for (const child of tag.node.body.body) {
|
|
11619
|
-
if (child.type === "MarkoText" || child.type === "MarkoPlaceholder" && child.escape) {
|
|
11620
|
-
parts.push(child.value);
|
|
11621
|
-
} else {
|
|
11622
|
-
throw tag.hub.file.hub.buildError(
|
|
11623
|
-
child,
|
|
11624
|
-
"Unexpected content in textarea, only text and placeholders are supported.",
|
|
11625
|
-
SyntaxError
|
|
11626
|
-
);
|
|
11627
|
-
}
|
|
11628
|
-
}
|
|
11629
|
-
tag.node.attributes.push(
|
|
11630
|
-
import_compiler56.types.markoAttribute(
|
|
11631
|
-
"value",
|
|
11632
|
-
normalizeStringExpression(parts) || buildUndefined3()
|
|
11633
|
-
)
|
|
11634
|
-
);
|
|
11635
|
-
tag.node.body.body = [];
|
|
11636
|
-
}
|
|
11637
|
-
},
|
|
11638
|
-
parseOptions: {
|
|
11639
|
-
text: true,
|
|
11640
|
-
preserveWhitespace: true
|
|
11641
|
-
}
|
|
11642
|
-
};
|
|
11643
|
-
function buildUndefined3() {
|
|
11644
|
-
return import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0));
|
|
11645
|
-
}
|
|
11646
|
-
|
|
11647
|
-
// src/translator/core/title.ts
|
|
11648
|
-
var import_compiler57 = require("@marko/compiler");
|
|
11649
|
-
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
11650
|
-
var kNodeBinding4 = Symbol("title tag node binding");
|
|
11651
|
-
var title_default = {
|
|
11652
|
-
analyze(tag) {
|
|
11653
|
-
(0, import_babel_utils46.assertNoArgs)(tag);
|
|
11654
|
-
(0, import_babel_utils46.assertNoParams)(tag);
|
|
11655
|
-
const { node } = tag;
|
|
11656
|
-
if (node.var && !import_compiler57.types.isIdentifier(node.var)) {
|
|
11657
|
-
throw tag.get("var").buildCodeFrameError(
|
|
11658
|
-
"Tag variables on native elements cannot be destructured."
|
|
11659
|
-
);
|
|
11660
|
-
}
|
|
11661
|
-
const seen = {};
|
|
11662
|
-
const { attributes } = tag.node;
|
|
11663
|
-
let spreadReferenceNodes;
|
|
11664
|
-
let exprExtras;
|
|
11665
|
-
let hasEventHandlers = false;
|
|
11666
|
-
let hasDynamicAttributes = false;
|
|
11667
|
-
for (let i = attributes.length; i--; ) {
|
|
11668
|
-
const attr = attributes[i];
|
|
11669
|
-
const valueExtra = attr.value.extra ??= {};
|
|
11670
|
-
if (import_compiler57.types.isMarkoAttribute(attr)) {
|
|
11671
|
-
if (seen[attr.name]) {
|
|
11672
|
-
dropReferences(attr.value);
|
|
11673
|
-
continue;
|
|
11674
|
-
}
|
|
11675
|
-
seen[attr.name] = attr;
|
|
11676
|
-
if (isEventHandler(attr.name)) {
|
|
11677
|
-
valueExtra.isEffect = true;
|
|
11678
|
-
hasEventHandlers = true;
|
|
11679
|
-
} else if (!evaluate(attr.value).confident) {
|
|
11680
|
-
hasDynamicAttributes = true;
|
|
11036
|
+
});
|
|
11037
|
+
if (sourceMaps === "inline" || sourceMaps === "both") {
|
|
11038
|
+
code += `
|
|
11039
|
+
/*# sourceMappingURL=${map.toUrl()}*/`;
|
|
11040
|
+
if (sourceMaps === "inline") {
|
|
11041
|
+
map = void 0;
|
|
11681
11042
|
}
|
|
11682
|
-
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11683
|
-
valueExtra.isEffect = true;
|
|
11684
|
-
hasEventHandlers = true;
|
|
11685
|
-
hasDynamicAttributes = true;
|
|
11686
|
-
}
|
|
11687
|
-
if (spreadReferenceNodes) {
|
|
11688
|
-
spreadReferenceNodes.push(attr.value);
|
|
11689
|
-
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11690
|
-
spreadReferenceNodes = [attr.value];
|
|
11691
|
-
} else {
|
|
11692
|
-
exprExtras = push(exprExtras, valueExtra);
|
|
11693
11043
|
}
|
|
11694
11044
|
}
|
|
11695
|
-
const
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
|
|
11701
|
-
|
|
11702
|
-
|
|
11703
|
-
|
|
11704
|
-
"Invalid child. Only text is allowed inside a `<title>`."
|
|
11045
|
+
const importPath = resolveVirtualDependency?.(filename, {
|
|
11046
|
+
virtualPath: `./${import_path3.default.basename(filename) + ext}`,
|
|
11047
|
+
code,
|
|
11048
|
+
map
|
|
11049
|
+
});
|
|
11050
|
+
if (importPath) {
|
|
11051
|
+
if (!node.var) {
|
|
11052
|
+
(0, import_babel_utils44.getProgram)().node.body.push(
|
|
11053
|
+
import_compiler55.types.importDeclaration([], import_compiler55.types.stringLiteral(importPath))
|
|
11705
11054
|
);
|
|
11706
|
-
}
|
|
11707
|
-
|
|
11708
|
-
|
|
11709
|
-
|
|
11710
|
-
|
|
11711
|
-
const nodeBinding = tagExtra[kNodeBinding4] = createBinding(
|
|
11712
|
-
"#title",
|
|
11713
|
-
0 /* dom */,
|
|
11714
|
-
tagSection
|
|
11715
|
-
);
|
|
11716
|
-
if (hasEventHandlers) {
|
|
11717
|
-
(0, import_babel_utils46.getProgram)().node.extra.isInteractive = true;
|
|
11718
|
-
}
|
|
11719
|
-
if (spreadReferenceNodes) {
|
|
11720
|
-
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
11721
|
-
}
|
|
11722
|
-
if (hasBodyPlaceholders) {
|
|
11723
|
-
exprExtras = push(
|
|
11724
|
-
exprExtras,
|
|
11725
|
-
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
11726
|
-
tagSection,
|
|
11727
|
-
bodyPlaceholderNodes[0],
|
|
11728
|
-
bodyPlaceholderNodes.slice(1)
|
|
11055
|
+
} else if (import_compiler55.types.isIdentifier(node.var)) {
|
|
11056
|
+
(0, import_babel_utils44.getProgram)().node.body.push(
|
|
11057
|
+
import_compiler55.types.importDeclaration(
|
|
11058
|
+
[import_compiler55.types.importNamespaceSpecifier(node.var)],
|
|
11059
|
+
import_compiler55.types.stringLiteral(importPath)
|
|
11729
11060
|
)
|
|
11730
11061
|
);
|
|
11731
|
-
}
|
|
11732
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
11733
|
-
addSerializeExpr(
|
|
11734
|
-
tagSection,
|
|
11735
|
-
!!(node.var || hasEventHandlers),
|
|
11736
|
-
nodeBinding
|
|
11737
|
-
);
|
|
11738
|
-
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
11739
|
-
}
|
|
11740
|
-
},
|
|
11741
|
-
translate: {
|
|
11742
|
-
enter(tag) {
|
|
11743
|
-
const tagExtra = tag.node.extra;
|
|
11744
|
-
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11745
|
-
const isHTML = isOutputHTML();
|
|
11746
|
-
const write = writeTo(tag);
|
|
11747
|
-
const tagSection = getSection(tag);
|
|
11748
|
-
if (isHTML) {
|
|
11749
|
-
translateDomVar(tag, nodeBinding);
|
|
11750
|
-
}
|
|
11751
|
-
if (nodeBinding) {
|
|
11752
|
-
visit(tag, 32 /* Get */);
|
|
11753
|
-
}
|
|
11754
|
-
write`<title`;
|
|
11755
|
-
const usedAttrs = getUsedAttrs4(tag.node);
|
|
11756
|
-
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
11757
|
-
for (const attr of staticAttrs) {
|
|
11758
|
-
const { name: name2, value } = attr;
|
|
11759
|
-
const { confident, computed } = value.extra || {};
|
|
11760
|
-
const valueReferences = value.extra?.referencedBindings;
|
|
11761
|
-
switch (name2) {
|
|
11762
|
-
case "class":
|
|
11763
|
-
case "style": {
|
|
11764
|
-
const helper = `_attr_${name2}`;
|
|
11765
|
-
if (confident) {
|
|
11766
|
-
write`${getHTMLRuntime()[helper](computed)}`;
|
|
11767
|
-
} else if (isHTML) {
|
|
11768
|
-
write`${callRuntime(helper, value)}`;
|
|
11769
|
-
} else {
|
|
11770
|
-
addStatement(
|
|
11771
|
-
"render",
|
|
11772
|
-
tagSection,
|
|
11773
|
-
valueReferences,
|
|
11774
|
-
import_compiler57.types.expressionStatement(
|
|
11775
|
-
callRuntime(
|
|
11776
|
-
helper,
|
|
11777
|
-
createScopeReadExpression(nodeBinding),
|
|
11778
|
-
value
|
|
11779
|
-
)
|
|
11780
|
-
)
|
|
11781
|
-
);
|
|
11782
|
-
}
|
|
11783
|
-
break;
|
|
11784
|
-
}
|
|
11785
|
-
default:
|
|
11786
|
-
if (confident) {
|
|
11787
|
-
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
11788
|
-
} else if (isHTML) {
|
|
11789
|
-
if (isEventHandler(name2)) {
|
|
11790
|
-
addHTMLEffectCall(tagSection, valueReferences);
|
|
11791
|
-
} else {
|
|
11792
|
-
write`${callRuntime("_attr", import_compiler57.types.stringLiteral(name2), value)}`;
|
|
11793
|
-
}
|
|
11794
|
-
} else if (isEventHandler(name2)) {
|
|
11795
|
-
addStatement(
|
|
11796
|
-
"effect",
|
|
11797
|
-
tagSection,
|
|
11798
|
-
valueReferences,
|
|
11799
|
-
import_compiler57.types.expressionStatement(
|
|
11800
|
-
callRuntime(
|
|
11801
|
-
"_on",
|
|
11802
|
-
createScopeReadExpression(nodeBinding),
|
|
11803
|
-
import_compiler57.types.stringLiteral(getEventHandlerName(name2)),
|
|
11804
|
-
value
|
|
11805
|
-
)
|
|
11806
|
-
)
|
|
11807
|
-
);
|
|
11808
|
-
} else {
|
|
11809
|
-
addStatement(
|
|
11810
|
-
"render",
|
|
11811
|
-
tagSection,
|
|
11812
|
-
valueReferences,
|
|
11813
|
-
import_compiler57.types.expressionStatement(
|
|
11814
|
-
callRuntime(
|
|
11815
|
-
"_attr",
|
|
11816
|
-
createScopeReadExpression(nodeBinding),
|
|
11817
|
-
import_compiler57.types.stringLiteral(name2),
|
|
11818
|
-
value
|
|
11819
|
-
)
|
|
11820
|
-
)
|
|
11821
|
-
);
|
|
11822
|
-
}
|
|
11823
|
-
break;
|
|
11824
|
-
}
|
|
11825
|
-
}
|
|
11826
|
-
if (spreadExpression) {
|
|
11827
|
-
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
|
11828
|
-
if (isHTML) {
|
|
11829
|
-
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
11830
|
-
if (skipExpression) {
|
|
11831
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11832
|
-
} else {
|
|
11833
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11834
|
-
}
|
|
11835
|
-
} else {
|
|
11836
|
-
if (skipExpression) {
|
|
11837
|
-
addStatement(
|
|
11838
|
-
"render",
|
|
11839
|
-
tagSection,
|
|
11840
|
-
tagExtra.referencedBindings,
|
|
11841
|
-
import_compiler57.types.expressionStatement(
|
|
11842
|
-
callRuntime(
|
|
11843
|
-
"_attrs_partial",
|
|
11844
|
-
scopeIdentifier,
|
|
11845
|
-
visitAccessor,
|
|
11846
|
-
spreadExpression,
|
|
11847
|
-
skipExpression
|
|
11848
|
-
)
|
|
11849
|
-
)
|
|
11850
|
-
);
|
|
11851
|
-
} else {
|
|
11852
|
-
addStatement(
|
|
11853
|
-
"render",
|
|
11854
|
-
tagSection,
|
|
11855
|
-
tagExtra.referencedBindings,
|
|
11856
|
-
import_compiler57.types.expressionStatement(
|
|
11857
|
-
callRuntime(
|
|
11858
|
-
"_attrs",
|
|
11859
|
-
scopeIdentifier,
|
|
11860
|
-
visitAccessor,
|
|
11861
|
-
spreadExpression
|
|
11862
|
-
)
|
|
11863
|
-
)
|
|
11864
|
-
);
|
|
11865
|
-
}
|
|
11866
|
-
addStatement(
|
|
11867
|
-
"effect",
|
|
11868
|
-
tagSection,
|
|
11869
|
-
tagExtra.referencedBindings,
|
|
11870
|
-
import_compiler57.types.expressionStatement(
|
|
11871
|
-
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
11872
|
-
),
|
|
11873
|
-
false
|
|
11874
|
-
);
|
|
11875
|
-
}
|
|
11876
|
-
}
|
|
11877
|
-
write`>`;
|
|
11878
|
-
enter2(tag);
|
|
11879
|
-
},
|
|
11880
|
-
exit(tag) {
|
|
11881
|
-
const tagSection = getSection(tag);
|
|
11882
|
-
const tagExtra = tag.node.extra;
|
|
11883
|
-
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11884
|
-
const write = writeTo(tag);
|
|
11885
|
-
if (isOutputHTML()) {
|
|
11886
|
-
for (const child of tag.node.body.body) {
|
|
11887
|
-
if (import_compiler57.types.isMarkoText(child)) {
|
|
11888
|
-
write`${child.value}`;
|
|
11889
|
-
} else if (import_compiler57.types.isMarkoPlaceholder(child)) {
|
|
11890
|
-
write`${callRuntime("_to_text", child.value)}`;
|
|
11891
|
-
}
|
|
11892
|
-
}
|
|
11893
11062
|
} else {
|
|
11894
|
-
const
|
|
11895
|
-
|
|
11896
|
-
|
|
11897
|
-
|
|
11898
|
-
|
|
11899
|
-
"render",
|
|
11900
|
-
getSection(tag),
|
|
11901
|
-
textLiteral.extra?.referencedBindings,
|
|
11902
|
-
import_compiler57.types.expressionStatement(
|
|
11903
|
-
callRuntime(
|
|
11904
|
-
"_text_content",
|
|
11905
|
-
createScopeReadExpression(nodeBinding),
|
|
11906
|
-
textLiteral
|
|
11907
|
-
)
|
|
11908
|
-
)
|
|
11909
|
-
);
|
|
11910
|
-
}
|
|
11911
|
-
}
|
|
11912
|
-
write`</title>`;
|
|
11913
|
-
if (nodeBinding) {
|
|
11914
|
-
markNode(
|
|
11915
|
-
tag,
|
|
11916
|
-
nodeBinding,
|
|
11917
|
-
getSerializeReason(tagSection, nodeBinding)
|
|
11063
|
+
const varDecl = import_compiler55.types.variableDeclaration("const", [
|
|
11064
|
+
import_compiler55.types.variableDeclarator(node.var, (0, import_babel_utils44.importStar)(file, importPath, "style"))
|
|
11065
|
+
]);
|
|
11066
|
+
(0, import_babel_utils44.getProgram)().node.body.push(
|
|
11067
|
+
isOutputDOM() ? varDecl : import_compiler55.types.markoScriptlet([varDecl], true)
|
|
11918
11068
|
);
|
|
11919
11069
|
}
|
|
11920
|
-
exit2(tag);
|
|
11921
|
-
tag.remove();
|
|
11922
11070
|
}
|
|
11071
|
+
tag.remove();
|
|
11923
11072
|
},
|
|
11924
11073
|
parseOptions: {
|
|
11925
|
-
|
|
11926
|
-
|
|
11074
|
+
html: false,
|
|
11075
|
+
text: true,
|
|
11076
|
+
rawOpenTag: true,
|
|
11077
|
+
preserveWhitespace: true
|
|
11078
|
+
},
|
|
11079
|
+
attributes: {}
|
|
11927
11080
|
};
|
|
11928
|
-
function getUsedAttrs4(tag) {
|
|
11929
|
-
const seen = {};
|
|
11930
|
-
const { attributes } = tag;
|
|
11931
|
-
const maybeStaticAttrs = /* @__PURE__ */ new Set();
|
|
11932
|
-
let spreadExpression;
|
|
11933
|
-
let skipExpression;
|
|
11934
|
-
let spreadProps;
|
|
11935
|
-
let skipProps;
|
|
11936
|
-
for (let i = attributes.length; i--; ) {
|
|
11937
|
-
const attr = attributes[i];
|
|
11938
|
-
const { value } = attr;
|
|
11939
|
-
if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11940
|
-
if (!spreadProps) {
|
|
11941
|
-
spreadProps = [];
|
|
11942
|
-
}
|
|
11943
|
-
spreadProps.push(import_compiler57.types.spreadElement(value));
|
|
11944
|
-
} else if (!seen[attr.name]) {
|
|
11945
|
-
seen[attr.name] = attr;
|
|
11946
|
-
if (spreadProps) {
|
|
11947
|
-
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
11948
|
-
} else {
|
|
11949
|
-
maybeStaticAttrs.add(attr);
|
|
11950
|
-
}
|
|
11951
|
-
}
|
|
11952
|
-
}
|
|
11953
|
-
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
11954
|
-
if (spreadProps) {
|
|
11955
|
-
spreadProps.reverse();
|
|
11956
|
-
for (const { name: name2 } of staticAttrs) {
|
|
11957
|
-
(skipProps ||= []).push(toObjectProperty(name2, import_compiler57.types.numericLiteral(1)));
|
|
11958
|
-
}
|
|
11959
|
-
if (skipProps) {
|
|
11960
|
-
skipExpression = import_compiler57.types.objectExpression(skipProps);
|
|
11961
|
-
}
|
|
11962
|
-
spreadExpression = propsToExpression(spreadProps);
|
|
11963
|
-
}
|
|
11964
|
-
return {
|
|
11965
|
-
staticAttrs,
|
|
11966
|
-
spreadExpression,
|
|
11967
|
-
skipExpression
|
|
11968
|
-
};
|
|
11969
|
-
}
|
|
11970
11081
|
|
|
11971
11082
|
// src/translator/core/try.ts
|
|
11972
|
-
var
|
|
11973
|
-
var
|
|
11083
|
+
var import_compiler56 = require("@marko/compiler");
|
|
11084
|
+
var import_babel_utils45 = require("@marko/compiler/babel-utils");
|
|
11974
11085
|
var hasEnabledCatch = /* @__PURE__ */ new WeakSet();
|
|
11975
11086
|
var kDOMBinding2 = Symbol("try tag dom binding");
|
|
11976
11087
|
var try_default = {
|
|
11977
11088
|
analyze(tag) {
|
|
11978
|
-
(0,
|
|
11979
|
-
(0,
|
|
11980
|
-
(0,
|
|
11981
|
-
(0,
|
|
11089
|
+
(0, import_babel_utils45.assertNoVar)(tag);
|
|
11090
|
+
(0, import_babel_utils45.assertNoArgs)(tag);
|
|
11091
|
+
(0, import_babel_utils45.assertNoParams)(tag);
|
|
11092
|
+
(0, import_babel_utils45.assertNoAttributes)(tag);
|
|
11982
11093
|
assertNoSpreadAttrs(tag);
|
|
11983
11094
|
analyzeAttributeTags(tag);
|
|
11984
11095
|
const section = getOrCreateSection(tag);
|
|
@@ -12030,7 +11141,7 @@ var try_default = {
|
|
|
12030
11141
|
writeHTMLResumeStatements(tagBody);
|
|
12031
11142
|
tag.insertBefore(translatedAttrs.statements);
|
|
12032
11143
|
tag.replaceWith(
|
|
12033
|
-
|
|
11144
|
+
import_compiler56.types.expressionStatement(
|
|
12034
11145
|
callRuntime(
|
|
12035
11146
|
"_try",
|
|
12036
11147
|
getScopeIdIdentifier(section),
|
|
@@ -12085,11 +11196,11 @@ var try_default = {
|
|
|
12085
11196
|
translatedAttrs.statements
|
|
12086
11197
|
);
|
|
12087
11198
|
}
|
|
12088
|
-
const program = (0,
|
|
11199
|
+
const program = (0, import_babel_utils45.getProgram)().node;
|
|
12089
11200
|
if (!hasEnabledCatch.has(program)) {
|
|
12090
11201
|
hasEnabledCatch.add(program);
|
|
12091
11202
|
program.body.push(
|
|
12092
|
-
|
|
11203
|
+
import_compiler56.types.expressionStatement(callRuntime("_enable_catch"))
|
|
12093
11204
|
);
|
|
12094
11205
|
}
|
|
12095
11206
|
addValue(
|
|
@@ -12140,8 +11251,6 @@ var core_default = {
|
|
|
12140
11251
|
"<server>": server_default,
|
|
12141
11252
|
"<static>": static_default,
|
|
12142
11253
|
"<style>": style_default,
|
|
12143
|
-
"<textarea>": textarea_default,
|
|
12144
|
-
"<title>": title_default,
|
|
12145
11254
|
"<try>": try_default
|
|
12146
11255
|
};
|
|
12147
11256
|
|
|
@@ -12189,13 +11298,13 @@ var document_type_default = {
|
|
|
12189
11298
|
};
|
|
12190
11299
|
|
|
12191
11300
|
// src/translator/visitors/import-declaration.ts
|
|
12192
|
-
var
|
|
11301
|
+
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
12193
11302
|
var import_declaration_default = {
|
|
12194
11303
|
analyze(importDecl) {
|
|
12195
11304
|
const { node } = importDecl;
|
|
12196
11305
|
const { source } = node;
|
|
12197
11306
|
const { value } = source;
|
|
12198
|
-
const tagImport = (0,
|
|
11307
|
+
const tagImport = (0, import_babel_utils46.resolveTagImport)(importDecl, value);
|
|
12199
11308
|
if (tagImport) {
|
|
12200
11309
|
node.extra ??= {};
|
|
12201
11310
|
node.extra.tagImport = tagImport;
|
|
@@ -12218,26 +11327,8 @@ var import_declaration_default = {
|
|
|
12218
11327
|
};
|
|
12219
11328
|
|
|
12220
11329
|
// src/translator/visitors/placeholder.ts
|
|
12221
|
-
var
|
|
12222
|
-
|
|
12223
|
-
// src/translator/util/is-non-html-text.ts
|
|
12224
|
-
var import_compiler59 = require("@marko/compiler");
|
|
12225
|
-
function isNonHTMLText(placeholder) {
|
|
12226
|
-
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
12227
|
-
if (parentTag && isCoreTag(parentTag)) {
|
|
12228
|
-
switch (parentTag.node.name.value) {
|
|
12229
|
-
case "html-comment":
|
|
12230
|
-
case "html-script":
|
|
12231
|
-
case "html-style":
|
|
12232
|
-
case "title":
|
|
12233
|
-
return true;
|
|
12234
|
-
}
|
|
12235
|
-
}
|
|
12236
|
-
return false;
|
|
12237
|
-
}
|
|
12238
|
-
|
|
12239
|
-
// src/translator/visitors/placeholder.ts
|
|
12240
|
-
var kNodeBinding5 = Symbol("placeholder node binding");
|
|
11330
|
+
var import_compiler57 = require("@marko/compiler");
|
|
11331
|
+
var kNodeBinding2 = Symbol("placeholder node binding");
|
|
12241
11332
|
var kSiblingText = Symbol("placeholder has sibling text");
|
|
12242
11333
|
var kSharedText = Symbol(
|
|
12243
11334
|
"placeholder will merge its visitor with a another node"
|
|
@@ -12255,7 +11346,7 @@ var placeholder_default = {
|
|
|
12255
11346
|
}
|
|
12256
11347
|
} else {
|
|
12257
11348
|
const section = getOrCreateSection(placeholder);
|
|
12258
|
-
const nodeBinding = (node.extra ??= {})[
|
|
11349
|
+
const nodeBinding = (node.extra ??= {})[kNodeBinding2] = createBinding(
|
|
12259
11350
|
"#text",
|
|
12260
11351
|
0 /* dom */,
|
|
12261
11352
|
section
|
|
@@ -12278,7 +11369,7 @@ var placeholder_default = {
|
|
|
12278
11369
|
const isHTML = isOutputHTML();
|
|
12279
11370
|
const write = writeTo(placeholder);
|
|
12280
11371
|
const extra = node.extra || {};
|
|
12281
|
-
const nodeBinding = extra[
|
|
11372
|
+
const nodeBinding = extra[kNodeBinding2];
|
|
12282
11373
|
const canWriteHTML = isHTML || confident && node.escape;
|
|
12283
11374
|
const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
|
|
12284
11375
|
if (confident && canWriteHTML) {
|
|
@@ -12312,7 +11403,7 @@ var placeholder_default = {
|
|
|
12312
11403
|
"render",
|
|
12313
11404
|
getSection(placeholder),
|
|
12314
11405
|
valueExtra.referencedBindings,
|
|
12315
|
-
|
|
11406
|
+
import_compiler57.types.expressionStatement(
|
|
12316
11407
|
method === "_text" ? callRuntime(
|
|
12317
11408
|
"_text",
|
|
12318
11409
|
createScopeReadExpression(nodeBinding),
|
|
@@ -12350,7 +11441,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
12350
11441
|
break;
|
|
12351
11442
|
}
|
|
12352
11443
|
}
|
|
12353
|
-
if (!prev.node &&
|
|
11444
|
+
if (!prev.node && import_compiler57.types.isProgram(placeholder.parentPath)) {
|
|
12354
11445
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
|
12355
11446
|
}
|
|
12356
11447
|
let next = placeholder.getNextSibling();
|
|
@@ -12367,7 +11458,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
12367
11458
|
break;
|
|
12368
11459
|
}
|
|
12369
11460
|
}
|
|
12370
|
-
if (!next.node &&
|
|
11461
|
+
if (!next.node && import_compiler57.types.isProgram(placeholder.parentPath)) {
|
|
12371
11462
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
|
12372
11463
|
}
|
|
12373
11464
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
|
@@ -12409,7 +11500,7 @@ function isEmptyPlaceholder(placeholder) {
|
|
|
12409
11500
|
}
|
|
12410
11501
|
|
|
12411
11502
|
// src/translator/visitors/referenced-identifier.ts
|
|
12412
|
-
var
|
|
11503
|
+
var import_compiler58 = require("@marko/compiler");
|
|
12413
11504
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
|
12414
11505
|
var referenced_identifier_default = {
|
|
12415
11506
|
migrate(identifier) {
|
|
@@ -12417,8 +11508,8 @@ var referenced_identifier_default = {
|
|
|
12417
11508
|
if (identifier.scope.hasBinding(name2)) return;
|
|
12418
11509
|
switch (name2) {
|
|
12419
11510
|
case "out":
|
|
12420
|
-
if (
|
|
12421
|
-
identifier.parentPath.replaceWith(
|
|
11511
|
+
if (import_compiler58.types.isMemberExpression(identifier.parent) && import_compiler58.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
|
11512
|
+
identifier.parentPath.replaceWith(import_compiler58.types.identifier("$global"));
|
|
12422
11513
|
} else {
|
|
12423
11514
|
throw identifier.buildCodeFrameError(
|
|
12424
11515
|
"Only `out.global` is supported for compatibility."
|
|
@@ -12445,13 +11536,13 @@ var referenced_identifier_default = {
|
|
|
12445
11536
|
case "$global":
|
|
12446
11537
|
if (isOutputHTML()) {
|
|
12447
11538
|
identifier.replaceWith(
|
|
12448
|
-
|
|
11539
|
+
import_compiler58.types.callExpression(importRuntime("$global"), [])
|
|
12449
11540
|
);
|
|
12450
11541
|
} else {
|
|
12451
11542
|
identifier.replaceWith(
|
|
12452
|
-
|
|
11543
|
+
import_compiler58.types.memberExpression(
|
|
12453
11544
|
scopeIdentifier,
|
|
12454
|
-
|
|
11545
|
+
import_compiler58.types.identifier(getAccessorProp().Global)
|
|
12455
11546
|
)
|
|
12456
11547
|
);
|
|
12457
11548
|
}
|
|
@@ -12459,13 +11550,13 @@ var referenced_identifier_default = {
|
|
|
12459
11550
|
case "$signal":
|
|
12460
11551
|
if (isOutputHTML()) {
|
|
12461
11552
|
identifier.replaceWith(
|
|
12462
|
-
|
|
12463
|
-
|
|
11553
|
+
import_compiler58.types.callExpression(
|
|
11554
|
+
import_compiler58.types.arrowFunctionExpression(
|
|
12464
11555
|
[],
|
|
12465
|
-
|
|
12466
|
-
|
|
12467
|
-
|
|
12468
|
-
|
|
11556
|
+
import_compiler58.types.blockStatement([
|
|
11557
|
+
import_compiler58.types.throwStatement(
|
|
11558
|
+
import_compiler58.types.newExpression(import_compiler58.types.identifier("Error"), [
|
|
11559
|
+
import_compiler58.types.stringLiteral("Cannot use $signal in a server render.")
|
|
12469
11560
|
])
|
|
12470
11561
|
)
|
|
12471
11562
|
])
|
|
@@ -12491,19 +11582,19 @@ var referenced_identifier_default = {
|
|
|
12491
11582
|
"render",
|
|
12492
11583
|
section,
|
|
12493
11584
|
exprRoot.node.extra?.referencedBindings,
|
|
12494
|
-
|
|
12495
|
-
|
|
11585
|
+
import_compiler58.types.expressionStatement(
|
|
11586
|
+
import_compiler58.types.callExpression(importRuntime("$signalReset"), [
|
|
12496
11587
|
scopeIdentifier,
|
|
12497
|
-
|
|
11588
|
+
import_compiler58.types.numericLiteral(exprId)
|
|
12498
11589
|
])
|
|
12499
11590
|
),
|
|
12500
11591
|
false
|
|
12501
11592
|
);
|
|
12502
11593
|
}
|
|
12503
11594
|
identifier.replaceWith(
|
|
12504
|
-
|
|
11595
|
+
import_compiler58.types.callExpression(importRuntime("$signal"), [
|
|
12505
11596
|
scopeIdentifier,
|
|
12506
|
-
|
|
11597
|
+
import_compiler58.types.numericLiteral(exprId)
|
|
12507
11598
|
])
|
|
12508
11599
|
);
|
|
12509
11600
|
}
|
|
@@ -12512,7 +11603,7 @@ var referenced_identifier_default = {
|
|
|
12512
11603
|
};
|
|
12513
11604
|
|
|
12514
11605
|
// src/translator/visitors/scriptlet.ts
|
|
12515
|
-
var
|
|
11606
|
+
var import_babel_utils47 = require("@marko/compiler/babel-utils");
|
|
12516
11607
|
var scriptlet_default = {
|
|
12517
11608
|
analyze(scriptlet) {
|
|
12518
11609
|
if (!scriptlet.node.static) {
|
|
@@ -12526,7 +11617,7 @@ var scriptlet_default = {
|
|
|
12526
11617
|
scriptlet.node.body
|
|
12527
11618
|
);
|
|
12528
11619
|
if (scriptlet.node.target === "client") {
|
|
12529
|
-
(0,
|
|
11620
|
+
(0, import_babel_utils47.getProgram)().node.extra.isInteractive = true;
|
|
12530
11621
|
}
|
|
12531
11622
|
},
|
|
12532
11623
|
translate: {
|
|
@@ -12547,21 +11638,21 @@ var scriptlet_default = {
|
|
|
12547
11638
|
};
|
|
12548
11639
|
|
|
12549
11640
|
// src/translator/visitors/tag/index.ts
|
|
12550
|
-
var
|
|
12551
|
-
var
|
|
11641
|
+
var import_compiler62 = require("@marko/compiler");
|
|
11642
|
+
var import_babel_utils51 = require("@marko/compiler/babel-utils");
|
|
12552
11643
|
|
|
12553
11644
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
12554
|
-
var
|
|
12555
|
-
var
|
|
11645
|
+
var import_compiler59 = require("@marko/compiler");
|
|
11646
|
+
var import_babel_utils48 = require("@marko/compiler/babel-utils");
|
|
12556
11647
|
var attribute_tag_default = {
|
|
12557
11648
|
analyze: {
|
|
12558
11649
|
enter(tag) {
|
|
12559
|
-
(0,
|
|
12560
|
-
(0,
|
|
11650
|
+
(0, import_babel_utils48.assertNoVar)(tag);
|
|
11651
|
+
(0, import_babel_utils48.assertNoArgs)(tag);
|
|
12561
11652
|
const body = tag.get("body");
|
|
12562
11653
|
startSection(body);
|
|
12563
11654
|
trackParamsReferences(body, 3 /* param */);
|
|
12564
|
-
if (!(0,
|
|
11655
|
+
if (!(0, import_babel_utils48.findParentTag)(tag)) {
|
|
12565
11656
|
throw tag.get("name").buildCodeFrameError(
|
|
12566
11657
|
"[Attribute tags](https://markojs.com/docs/reference/language#attribute-tags) must be nested within another tag."
|
|
12567
11658
|
);
|
|
@@ -12584,13 +11675,13 @@ var attribute_tag_default = {
|
|
|
12584
11675
|
};
|
|
12585
11676
|
|
|
12586
11677
|
// src/translator/visitors/tag/custom-tag.ts
|
|
12587
|
-
var
|
|
12588
|
-
var
|
|
11678
|
+
var import_compiler60 = require("@marko/compiler");
|
|
11679
|
+
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
12589
11680
|
var import_path4 = __toESM(require("path"));
|
|
12590
11681
|
var custom_tag_default = {
|
|
12591
11682
|
analyze: {
|
|
12592
11683
|
enter(tag) {
|
|
12593
|
-
const templateFile = (0,
|
|
11684
|
+
const templateFile = (0, import_babel_utils49.getTagTemplate)(tag);
|
|
12594
11685
|
if (!templateFile) {
|
|
12595
11686
|
const tagName = getTagName(tag);
|
|
12596
11687
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
|
@@ -12602,12 +11693,12 @@ var custom_tag_default = {
|
|
|
12602
11693
|
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
|
12603
11694
|
);
|
|
12604
11695
|
}
|
|
12605
|
-
(0,
|
|
12606
|
-
const childFile = (0,
|
|
11696
|
+
(0, import_babel_utils49.assertAttributesOrSingleArg)(tag);
|
|
11697
|
+
const childFile = (0, import_babel_utils49.loadFileForTag)(tag);
|
|
12607
11698
|
if (!childFile) {
|
|
12608
11699
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
|
12609
11700
|
}
|
|
12610
|
-
const programSection = (0,
|
|
11701
|
+
const programSection = (0, import_babel_utils49.getProgram)().node.extra.section;
|
|
12611
11702
|
const childProgram = childFile.ast.program;
|
|
12612
11703
|
const childExtra = childProgram.extra;
|
|
12613
11704
|
const childSection = childExtra.section;
|
|
@@ -12635,12 +11726,12 @@ var custom_tag_default = {
|
|
|
12635
11726
|
};
|
|
12636
11727
|
function translateHTML(tag) {
|
|
12637
11728
|
const { node } = tag;
|
|
12638
|
-
const childProgram = (0,
|
|
11729
|
+
const childProgram = (0, import_babel_utils49.loadFileForTag)(tag).ast.program;
|
|
12639
11730
|
const childExtra = childProgram.extra;
|
|
12640
11731
|
let tagIdentifier;
|
|
12641
|
-
if (
|
|
11732
|
+
if (import_compiler60.types.isStringLiteral(node.name)) {
|
|
12642
11733
|
const relativePath = getTagRelativePath(tag);
|
|
12643
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
|
11734
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler60.types.identifier(getTemplateContentName()) : (0, import_babel_utils49.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
|
12644
11735
|
} else {
|
|
12645
11736
|
tagIdentifier = node.name;
|
|
12646
11737
|
}
|
|
@@ -12656,12 +11747,12 @@ function translateDOM(tag) {
|
|
|
12656
11747
|
const { file } = tag.hub;
|
|
12657
11748
|
const write = writeTo(tag);
|
|
12658
11749
|
const relativePath = getTagRelativePath(tag);
|
|
12659
|
-
const programSection = (0,
|
|
12660
|
-
const childFile = (0,
|
|
11750
|
+
const programSection = (0, import_babel_utils49.getProgram)().node.extra.section;
|
|
11751
|
+
const childFile = (0, import_babel_utils49.loadFileForTag)(tag);
|
|
12661
11752
|
const childExtra = childFile.ast.program.extra;
|
|
12662
11753
|
const childExports = childExtra.domExports;
|
|
12663
11754
|
const childSection = childExtra.section;
|
|
12664
|
-
const tagName =
|
|
11755
|
+
const tagName = import_compiler60.types.isIdentifier(node.name) ? node.name.name : import_compiler60.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
12665
11756
|
if (programSection === childSection) {
|
|
12666
11757
|
knownTagTranslateDOM(
|
|
12667
11758
|
tag,
|
|
@@ -12672,16 +11763,16 @@ function translateDOM(tag) {
|
|
|
12672
11763
|
"render",
|
|
12673
11764
|
section,
|
|
12674
11765
|
void 0,
|
|
12675
|
-
|
|
12676
|
-
|
|
11766
|
+
import_compiler60.types.expressionStatement(
|
|
11767
|
+
import_compiler60.types.callExpression(import_compiler60.types.identifier(childExports.setup), [
|
|
12677
11768
|
createScopeReadExpression(childBinding, section)
|
|
12678
11769
|
])
|
|
12679
11770
|
)
|
|
12680
11771
|
);
|
|
12681
11772
|
}
|
|
12682
11773
|
);
|
|
12683
|
-
write`${
|
|
12684
|
-
injectWalks(tag, tagName,
|
|
11774
|
+
write`${import_compiler60.types.identifier(childExports.template)}`;
|
|
11775
|
+
injectWalks(tag, tagName, import_compiler60.types.identifier(childExports.walks));
|
|
12685
11776
|
} else {
|
|
12686
11777
|
knownTagTranslateDOM(
|
|
12687
11778
|
tag,
|
|
@@ -12697,8 +11788,8 @@ function translateDOM(tag) {
|
|
|
12697
11788
|
"render",
|
|
12698
11789
|
section,
|
|
12699
11790
|
void 0,
|
|
12700
|
-
|
|
12701
|
-
|
|
11791
|
+
import_compiler60.types.expressionStatement(
|
|
11792
|
+
import_compiler60.types.callExpression(
|
|
12702
11793
|
importOrSelfReferenceName(
|
|
12703
11794
|
file,
|
|
12704
11795
|
relativePath,
|
|
@@ -12711,11 +11802,11 @@ function translateDOM(tag) {
|
|
|
12711
11802
|
);
|
|
12712
11803
|
}
|
|
12713
11804
|
);
|
|
12714
|
-
write`${(0,
|
|
11805
|
+
write`${(0, import_babel_utils49.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
12715
11806
|
injectWalks(
|
|
12716
11807
|
tag,
|
|
12717
11808
|
tagName,
|
|
12718
|
-
(0,
|
|
11809
|
+
(0, import_babel_utils49.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
|
12719
11810
|
);
|
|
12720
11811
|
}
|
|
12721
11812
|
tag.remove();
|
|
@@ -12726,9 +11817,9 @@ function getTagRelativePath(tag) {
|
|
|
12726
11817
|
hub: { file }
|
|
12727
11818
|
} = tag;
|
|
12728
11819
|
let relativePath;
|
|
12729
|
-
if (
|
|
12730
|
-
const template = (0,
|
|
12731
|
-
relativePath = template && (0,
|
|
11820
|
+
if (import_compiler60.types.isStringLiteral(node.name)) {
|
|
11821
|
+
const template = (0, import_babel_utils49.getTagTemplate)(tag);
|
|
11822
|
+
relativePath = template && (0, import_babel_utils49.resolveRelativePath)(file, template);
|
|
12732
11823
|
} else if (node.extra?.tagNameImported) {
|
|
12733
11824
|
relativePath = node.extra.tagNameImported;
|
|
12734
11825
|
}
|
|
@@ -12747,9 +11838,9 @@ function getTagRelativePath(tag) {
|
|
|
12747
11838
|
}
|
|
12748
11839
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
12749
11840
|
if (isCircularRequest(file, request)) {
|
|
12750
|
-
return
|
|
11841
|
+
return import_compiler60.types.identifier(name2);
|
|
12751
11842
|
}
|
|
12752
|
-
return (0,
|
|
11843
|
+
return (0, import_babel_utils49.importNamed)(file, request, name2, nameHint);
|
|
12753
11844
|
}
|
|
12754
11845
|
function isCircularRequest(file, request) {
|
|
12755
11846
|
const { filename } = file.opts;
|
|
@@ -12757,15 +11848,15 @@ function isCircularRequest(file, request) {
|
|
|
12757
11848
|
}
|
|
12758
11849
|
|
|
12759
11850
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
12760
|
-
var
|
|
12761
|
-
var
|
|
11851
|
+
var import_compiler61 = require("@marko/compiler");
|
|
11852
|
+
var import_babel_utils50 = require("@marko/compiler/babel-utils");
|
|
12762
11853
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
|
12763
11854
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
|
12764
11855
|
var importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
12765
11856
|
var dynamic_tag_default = {
|
|
12766
11857
|
analyze: {
|
|
12767
11858
|
enter(tag) {
|
|
12768
|
-
(0,
|
|
11859
|
+
(0, import_babel_utils50.assertAttributesOrArgs)(tag);
|
|
12769
11860
|
const { node } = tag;
|
|
12770
11861
|
const definedBodySection = node.extra?.defineBodySection;
|
|
12771
11862
|
if (definedBodySection) {
|
|
@@ -12790,9 +11881,9 @@ var dynamic_tag_default = {
|
|
|
12790
11881
|
tagSection
|
|
12791
11882
|
);
|
|
12792
11883
|
if (hasVar || tag.node.attributes.some(
|
|
12793
|
-
(attr) =>
|
|
11884
|
+
(attr) => import_compiler61.types.isMarkoSpreadAttribute(attr) || isEventOrChangeHandler(attr.name)
|
|
12794
11885
|
)) {
|
|
12795
|
-
(0,
|
|
11886
|
+
(0, import_babel_utils50.getProgram)().node.extra.isInteractive = true;
|
|
12796
11887
|
}
|
|
12797
11888
|
if (hasVar) {
|
|
12798
11889
|
trackVarReferences(tag, 5 /* derived */);
|
|
@@ -12830,7 +11921,7 @@ var dynamic_tag_default = {
|
|
|
12830
11921
|
if (isOutputHTML()) {
|
|
12831
11922
|
knownTagTranslateHTML(
|
|
12832
11923
|
tag,
|
|
12833
|
-
|
|
11924
|
+
import_compiler61.types.memberExpression(tag.node.name, import_compiler61.types.identifier("content")),
|
|
12834
11925
|
definedBodySection,
|
|
12835
11926
|
propTree
|
|
12836
11927
|
);
|
|
@@ -12847,9 +11938,9 @@ var dynamic_tag_default = {
|
|
|
12847
11938
|
"render",
|
|
12848
11939
|
section,
|
|
12849
11940
|
void 0,
|
|
12850
|
-
|
|
12851
|
-
|
|
12852
|
-
|
|
11941
|
+
import_compiler61.types.expressionStatement(
|
|
11942
|
+
import_compiler61.types.callExpression(
|
|
11943
|
+
import_compiler61.types.memberExpression(signal.identifier, import_compiler61.types.identifier("_")),
|
|
12853
11944
|
[
|
|
12854
11945
|
createScopeReadExpression(childBinding, section),
|
|
12855
11946
|
getScopeExpression(section, definedBodySection.parent)
|
|
@@ -12874,8 +11965,8 @@ var dynamic_tag_default = {
|
|
|
12874
11965
|
const nodeBinding = tagExtra[kDOMBinding3];
|
|
12875
11966
|
const isClassAPI = tagExtra.featureType === "class";
|
|
12876
11967
|
let tagExpression = node.name;
|
|
12877
|
-
if (
|
|
12878
|
-
tagExpression = (0,
|
|
11968
|
+
if (import_compiler61.types.isStringLiteral(tagExpression)) {
|
|
11969
|
+
tagExpression = (0, import_babel_utils50.importDefault)(
|
|
12879
11970
|
tag.hub.file,
|
|
12880
11971
|
getTagRelativePath(tag),
|
|
12881
11972
|
tagExpression.value
|
|
@@ -12883,15 +11974,15 @@ var dynamic_tag_default = {
|
|
|
12883
11974
|
}
|
|
12884
11975
|
if (isClassAPI) {
|
|
12885
11976
|
if (isOutputHTML()) {
|
|
12886
|
-
(0,
|
|
12887
|
-
|
|
11977
|
+
(0, import_babel_utils50.getProgram)().node.body.push(
|
|
11978
|
+
import_compiler61.types.markoScriptlet(
|
|
12888
11979
|
[
|
|
12889
|
-
|
|
12890
|
-
|
|
12891
|
-
(0,
|
|
11980
|
+
import_compiler61.types.expressionStatement(
|
|
11981
|
+
import_compiler61.types.callExpression(
|
|
11982
|
+
(0, import_babel_utils50.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
12892
11983
|
[
|
|
12893
|
-
|
|
12894
|
-
|
|
11984
|
+
import_compiler61.types.identifier(tagExpression.name),
|
|
11985
|
+
import_compiler61.types.stringLiteral((0, import_babel_utils50.loadFileForTag)(tag).metadata.marko.id)
|
|
12895
11986
|
]
|
|
12896
11987
|
)
|
|
12897
11988
|
)
|
|
@@ -12900,12 +11991,12 @@ var dynamic_tag_default = {
|
|
|
12900
11991
|
)
|
|
12901
11992
|
);
|
|
12902
11993
|
} else {
|
|
12903
|
-
(0,
|
|
12904
|
-
|
|
11994
|
+
(0, import_babel_utils50.getProgram)().node.body.push(
|
|
11995
|
+
import_compiler61.types.expressionStatement(
|
|
12905
11996
|
callRuntime(
|
|
12906
11997
|
"_resume",
|
|
12907
|
-
|
|
12908
|
-
|
|
11998
|
+
import_compiler61.types.stringLiteral((0, import_babel_utils50.loadFileForTag)(tag).metadata.marko.id),
|
|
11999
|
+
import_compiler61.types.identifier(tagExpression.name)
|
|
12909
12000
|
)
|
|
12910
12001
|
)
|
|
12911
12002
|
);
|
|
@@ -12948,9 +12039,9 @@ var dynamic_tag_default = {
|
|
|
12948
12039
|
getScopeIdIdentifier(tagSection),
|
|
12949
12040
|
getScopeAccessorLiteral(nodeBinding),
|
|
12950
12041
|
tagExpression,
|
|
12951
|
-
|
|
12952
|
-
|
|
12953
|
-
|
|
12042
|
+
import_compiler61.types.arrayExpression(args),
|
|
12043
|
+
import_compiler61.types.numericLiteral(0),
|
|
12044
|
+
import_compiler61.types.numericLiteral(1),
|
|
12954
12045
|
serializeArg
|
|
12955
12046
|
) : callRuntime(
|
|
12956
12047
|
"_dynamic_tag",
|
|
@@ -12958,8 +12049,8 @@ var dynamic_tag_default = {
|
|
|
12958
12049
|
getScopeAccessorLiteral(nodeBinding),
|
|
12959
12050
|
tagExpression,
|
|
12960
12051
|
args[0],
|
|
12961
|
-
args[1] || (serializeArg ?
|
|
12962
|
-
serializeArg ?
|
|
12052
|
+
args[1] || (serializeArg ? import_compiler61.types.numericLiteral(0) : void 0),
|
|
12053
|
+
serializeArg ? import_compiler61.types.numericLiteral(0) : void 0,
|
|
12963
12054
|
serializeArg
|
|
12964
12055
|
);
|
|
12965
12056
|
if (node.var) {
|
|
@@ -12967,18 +12058,18 @@ var dynamic_tag_default = {
|
|
|
12967
12058
|
tag.get("name").toString() + "_scope"
|
|
12968
12059
|
);
|
|
12969
12060
|
statements.push(
|
|
12970
|
-
|
|
12971
|
-
|
|
12061
|
+
import_compiler61.types.variableDeclaration("const", [
|
|
12062
|
+
import_compiler61.types.variableDeclarator(
|
|
12972
12063
|
dynamicScopeIdentifier,
|
|
12973
12064
|
callRuntime("_peek_scope_id")
|
|
12974
12065
|
)
|
|
12975
12066
|
])
|
|
12976
12067
|
);
|
|
12977
12068
|
statements.push(
|
|
12978
|
-
|
|
12979
|
-
|
|
12069
|
+
import_compiler61.types.variableDeclaration("let", [
|
|
12070
|
+
import_compiler61.types.variableDeclarator(node.var, dynamicTagExpr)
|
|
12980
12071
|
]),
|
|
12981
|
-
|
|
12072
|
+
import_compiler61.types.expressionStatement(
|
|
12982
12073
|
callRuntime(
|
|
12983
12074
|
"_var",
|
|
12984
12075
|
getScopeIdIdentifier(tagSection),
|
|
@@ -12986,7 +12077,7 @@ var dynamic_tag_default = {
|
|
|
12986
12077
|
tag.node.extra[kChildOffsetScopeBinding2]
|
|
12987
12078
|
),
|
|
12988
12079
|
dynamicScopeIdentifier,
|
|
12989
|
-
|
|
12080
|
+
import_compiler61.types.stringLiteral(
|
|
12990
12081
|
getResumeRegisterId(
|
|
12991
12082
|
tagSection,
|
|
12992
12083
|
node.var.extra?.binding,
|
|
@@ -12998,7 +12089,7 @@ var dynamic_tag_default = {
|
|
|
12998
12089
|
)
|
|
12999
12090
|
);
|
|
13000
12091
|
} else {
|
|
13001
|
-
statements.push(
|
|
12092
|
+
statements.push(import_compiler61.types.expressionStatement(dynamicTagExpr));
|
|
13002
12093
|
}
|
|
13003
12094
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
13004
12095
|
replacement.skip();
|
|
@@ -13017,9 +12108,9 @@ var dynamic_tag_default = {
|
|
|
13017
12108
|
tagVarSignal.register = true;
|
|
13018
12109
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
|
13019
12110
|
const changeArgs = [
|
|
13020
|
-
|
|
12111
|
+
import_compiler61.types.memberExpression(
|
|
13021
12112
|
getScopeExpression(tagVarSignal.section, valueSection),
|
|
13022
|
-
|
|
12113
|
+
import_compiler61.types.stringLiteral(
|
|
13023
12114
|
getAccessorPrefix().BranchScopes + getScopeAccessor(nodeBinding)
|
|
13024
12115
|
),
|
|
13025
12116
|
true
|
|
@@ -13027,28 +12118,28 @@ var dynamic_tag_default = {
|
|
|
13027
12118
|
value
|
|
13028
12119
|
];
|
|
13029
12120
|
if (!isOptimize()) {
|
|
13030
|
-
changeArgs.push(
|
|
12121
|
+
changeArgs.push(import_compiler61.types.stringLiteral(varBinding.name));
|
|
13031
12122
|
}
|
|
13032
|
-
return
|
|
12123
|
+
return import_compiler61.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
13033
12124
|
};
|
|
13034
12125
|
}
|
|
13035
12126
|
signal.build = () => {
|
|
13036
12127
|
return callRuntime(
|
|
13037
12128
|
"_dynamic_tag",
|
|
13038
12129
|
getScopeAccessorLiteral(nodeBinding, true),
|
|
13039
|
-
bodySection &&
|
|
13040
|
-
tagVarSignal ?
|
|
13041
|
-
hasTagArgs &&
|
|
12130
|
+
bodySection && import_compiler61.types.identifier(bodySection.name),
|
|
12131
|
+
tagVarSignal ? import_compiler61.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
|
12132
|
+
hasTagArgs && import_compiler61.types.numericLiteral(1)
|
|
13042
12133
|
);
|
|
13043
12134
|
};
|
|
13044
12135
|
if (args.length) {
|
|
13045
|
-
const argsOrInput = hasTagArgs ?
|
|
13046
|
-
if (!
|
|
12136
|
+
const argsOrInput = hasTagArgs ? import_compiler61.types.arrayExpression(args) : args[0];
|
|
12137
|
+
if (!import_compiler61.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
|
13047
12138
|
signal.extraArgs = [
|
|
13048
|
-
|
|
12139
|
+
import_compiler61.types.arrowFunctionExpression(
|
|
13049
12140
|
[],
|
|
13050
|
-
statements.length ?
|
|
13051
|
-
statements.concat(
|
|
12141
|
+
statements.length ? import_compiler61.types.blockStatement(
|
|
12142
|
+
statements.concat(import_compiler61.types.returnStatement(argsOrInput))
|
|
13052
12143
|
) : argsOrInput
|
|
13053
12144
|
)
|
|
13054
12145
|
];
|
|
@@ -13062,13 +12153,13 @@ var dynamic_tag_default = {
|
|
|
13062
12153
|
}
|
|
13063
12154
|
};
|
|
13064
12155
|
function enableDynamicTagResume(tag) {
|
|
13065
|
-
const program = (0,
|
|
12156
|
+
const program = (0, import_babel_utils50.getProgram)().node;
|
|
13066
12157
|
if (!importedDynamicTagResume.has(program) && analyzeTagNameType(tag, true) !== 1 /* CustomTag */) {
|
|
13067
12158
|
for (const attr of tag.node.attributes) {
|
|
13068
12159
|
if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && isEventOrChangeHandler(attr.name)) {
|
|
13069
12160
|
importedDynamicTagResume.add(program);
|
|
13070
12161
|
program.body.push(
|
|
13071
|
-
|
|
12162
|
+
import_compiler61.types.expressionStatement(callRuntime("_resume_dynamic_tag"))
|
|
13072
12163
|
);
|
|
13073
12164
|
return;
|
|
13074
12165
|
}
|
|
@@ -13080,7 +12171,7 @@ function enableDynamicTagResume(tag) {
|
|
|
13080
12171
|
var tag_default = {
|
|
13081
12172
|
analyze: {
|
|
13082
12173
|
enter(tag) {
|
|
13083
|
-
const tagDef = (0,
|
|
12174
|
+
const tagDef = (0, import_babel_utils51.getTagDef)(tag);
|
|
13084
12175
|
const type = analyzeTagNameType(tag);
|
|
13085
12176
|
const hook = tagDef?.analyzer?.hook;
|
|
13086
12177
|
if (hook) {
|
|
@@ -13104,7 +12195,7 @@ var tag_default = {
|
|
|
13104
12195
|
}
|
|
13105
12196
|
},
|
|
13106
12197
|
exit(tag) {
|
|
13107
|
-
const hook = (0,
|
|
12198
|
+
const hook = (0, import_babel_utils51.getTagDef)(tag)?.analyzer?.hook;
|
|
13108
12199
|
if (hook) {
|
|
13109
12200
|
exit(hook, tag);
|
|
13110
12201
|
return;
|
|
@@ -13113,8 +12204,7 @@ var tag_default = {
|
|
|
13113
12204
|
},
|
|
13114
12205
|
translate: {
|
|
13115
12206
|
enter(tag) {
|
|
13116
|
-
const tagDef = (0,
|
|
13117
|
-
const extra = tag.node.extra;
|
|
12207
|
+
const tagDef = (0, import_babel_utils51.getTagDef)(tag);
|
|
13118
12208
|
if (tagDef?.translator) {
|
|
13119
12209
|
if (tagDef.translator.path) {
|
|
13120
12210
|
tag.hub.file.metadata.marko.watchFiles.push(tagDef.translator.path);
|
|
@@ -13130,7 +12220,7 @@ var tag_default = {
|
|
|
13130
12220
|
);
|
|
13131
12221
|
}
|
|
13132
12222
|
if (attr.node.modifier) {
|
|
13133
|
-
if ((0,
|
|
12223
|
+
if ((0, import_babel_utils51.isNativeTag)(attr.parentPath)) {
|
|
13134
12224
|
attr.node.name += `:${attr.node.modifier}`;
|
|
13135
12225
|
} else {
|
|
13136
12226
|
throw attr.buildCodeFrameError(
|
|
@@ -13140,18 +12230,7 @@ var tag_default = {
|
|
|
13140
12230
|
}
|
|
13141
12231
|
}
|
|
13142
12232
|
}
|
|
13143
|
-
|
|
13144
|
-
if (extra.tagNameDynamic && extra.tagNameNullable && type === 0 /* NativeTag */ && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
|
13145
|
-
const tagNameId = generateUidIdentifier("tagName");
|
|
13146
|
-
const [tagNameVarPath] = tag.insertBefore(
|
|
13147
|
-
import_compiler65.types.variableDeclaration("const", [
|
|
13148
|
-
import_compiler65.types.variableDeclarator(tagNameId, tag.node.name)
|
|
13149
|
-
])
|
|
13150
|
-
);
|
|
13151
|
-
tagNameVarPath.skip();
|
|
13152
|
-
tag.set("name", tagNameId);
|
|
13153
|
-
}
|
|
13154
|
-
switch (type) {
|
|
12233
|
+
switch (analyzeTagNameType(tag)) {
|
|
13155
12234
|
case 0 /* NativeTag */:
|
|
13156
12235
|
native_tag_default.translate.enter(tag);
|
|
13157
12236
|
break;
|
|
@@ -13167,7 +12246,7 @@ var tag_default = {
|
|
|
13167
12246
|
}
|
|
13168
12247
|
},
|
|
13169
12248
|
exit(tag) {
|
|
13170
|
-
const translator = (0,
|
|
12249
|
+
const translator = (0, import_babel_utils51.getTagDef)(tag)?.translator;
|
|
13171
12250
|
if (translator) {
|
|
13172
12251
|
exit(translator.hook, tag);
|
|
13173
12252
|
return;
|
|
@@ -13191,7 +12270,7 @@ var tag_default = {
|
|
|
13191
12270
|
};
|
|
13192
12271
|
|
|
13193
12272
|
// src/translator/visitors/text.ts
|
|
13194
|
-
var
|
|
12273
|
+
var import_compiler63 = require("@marko/compiler");
|
|
13195
12274
|
var text_default = {
|
|
13196
12275
|
translate: {
|
|
13197
12276
|
exit(text) {
|
|
@@ -13223,7 +12302,7 @@ var preferAPI = "tags";
|
|
|
13223
12302
|
var { transform, analyze, translate } = visitors;
|
|
13224
12303
|
var taglibs = [
|
|
13225
12304
|
[
|
|
13226
|
-
|
|
12305
|
+
core_default.taglibId,
|
|
13227
12306
|
{
|
|
13228
12307
|
...core_default,
|
|
13229
12308
|
migrate: visitors.migrate
|