marko 6.0.116 → 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 +846 -1756
- package/dist/translator/util/is-non-html-text.d.ts +1 -0
- package/dist/translator/util/references.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
|
|
|
@@ -2252,7 +2253,7 @@ function getBindingPropTree(binding) {
|
|
|
2252
2253
|
}
|
|
2253
2254
|
} else if (binding.aliases.size === 1) {
|
|
2254
2255
|
const [restAlias] = binding.aliases;
|
|
2255
|
-
if (restAlias.excludeProperties
|
|
2256
|
+
if (hasSupersetExcludeProperties(binding, restAlias.excludeProperties)) {
|
|
2256
2257
|
props.rest = getBindingPropTree(restAlias);
|
|
2257
2258
|
props.props = {};
|
|
2258
2259
|
if (restAlias.type === 2 /* input */) {
|
|
@@ -2272,6 +2273,17 @@ function getBindingPropTree(binding) {
|
|
|
2272
2273
|
}
|
|
2273
2274
|
return props;
|
|
2274
2275
|
}
|
|
2276
|
+
function hasSupersetExcludeProperties(binding, excludeProperties) {
|
|
2277
|
+
if (excludeProperties === void 0) {
|
|
2278
|
+
return false;
|
|
2279
|
+
}
|
|
2280
|
+
for (const prop of binding.propertyAliases.keys()) {
|
|
2281
|
+
if (!propsUtil.has(excludeProperties, prop)) {
|
|
2282
|
+
return false;
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
return true;
|
|
2286
|
+
}
|
|
2275
2287
|
|
|
2276
2288
|
// src/translator/util/entry-builder.ts
|
|
2277
2289
|
var import_compiler9 = require("@marko/compiler");
|
|
@@ -4772,7 +4784,31 @@ function getRegisteredFnExpression2(node) {
|
|
|
4772
4784
|
}
|
|
4773
4785
|
|
|
4774
4786
|
// src/translator/visitors/program/pre-analyze.ts
|
|
4787
|
+
var import_compiler26 = require("@marko/compiler");
|
|
4788
|
+
|
|
4789
|
+
// src/translator/core/textarea.ts
|
|
4775
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
|
+
}
|
|
4776
4812
|
|
|
4777
4813
|
// src/translator/util/with-previous-location.ts
|
|
4778
4814
|
function withPreviousLocation(newNode, originalNode) {
|
|
@@ -4785,7 +4821,7 @@ function withPreviousLocation(newNode, originalNode) {
|
|
|
4785
4821
|
// src/translator/visitors/program/pre-analyze.ts
|
|
4786
4822
|
var TAG_NAME_IDENTIFIER_REG = /^[A-Z][a-zA-Z0-9_$]*$/;
|
|
4787
4823
|
var BINDING_CHANGE_HANDLER = /* @__PURE__ */ new WeakMap();
|
|
4788
|
-
function
|
|
4824
|
+
function preAnalyze2(program) {
|
|
4789
4825
|
const state = { crawl: false };
|
|
4790
4826
|
normalizeBody(state, program.get("body"));
|
|
4791
4827
|
if (state.crawl) {
|
|
@@ -4827,12 +4863,18 @@ function normalizeTag(state, tag) {
|
|
|
4827
4863
|
const tagName = name2.value;
|
|
4828
4864
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
|
4829
4865
|
state.crawl = true;
|
|
4830
|
-
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
|
+
}
|
|
4831
4873
|
}
|
|
4832
4874
|
}
|
|
4833
4875
|
for (let i = 0; i < attributes.length; i++) {
|
|
4834
4876
|
const attr = attributes[i];
|
|
4835
|
-
if (
|
|
4877
|
+
if (import_compiler26.types.isMarkoAttribute(attr) && attr.bound) {
|
|
4836
4878
|
state.crawl = true;
|
|
4837
4879
|
attr.bound = false;
|
|
4838
4880
|
attributes.splice(++i, 0, getChangeHandler(tag, attr));
|
|
@@ -4842,10 +4884,10 @@ function normalizeTag(state, tag) {
|
|
|
4842
4884
|
function getChangeHandler(tag, attr) {
|
|
4843
4885
|
const attrName = attr.name;
|
|
4844
4886
|
const changeAttrName = attrName + "Change";
|
|
4845
|
-
if (
|
|
4887
|
+
if (import_compiler26.types.isIdentifier(attr.value)) {
|
|
4846
4888
|
const binding = tag.scope.getBinding(attr.value.name);
|
|
4847
4889
|
if (!binding)
|
|
4848
|
-
return
|
|
4890
|
+
return import_compiler26.types.markoAttribute(
|
|
4849
4891
|
changeAttrName,
|
|
4850
4892
|
buildChangeHandlerFunction(attr.value)
|
|
4851
4893
|
);
|
|
@@ -4858,7 +4900,7 @@ function getChangeHandler(tag, attr) {
|
|
|
4858
4900
|
if (!changeAttrExpr) {
|
|
4859
4901
|
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
4860
4902
|
}
|
|
4861
|
-
const changeHandlerAttr =
|
|
4903
|
+
const changeHandlerAttr = import_compiler26.types.markoAttribute(
|
|
4862
4904
|
changeAttrName,
|
|
4863
4905
|
changeAttrExpr
|
|
4864
4906
|
);
|
|
@@ -4866,10 +4908,10 @@ function getChangeHandler(tag, attr) {
|
|
|
4866
4908
|
return changeHandlerAttr;
|
|
4867
4909
|
}
|
|
4868
4910
|
if (existingChangedAttr.type === "Identifier") {
|
|
4869
|
-
return
|
|
4911
|
+
return import_compiler26.types.markoAttribute(
|
|
4870
4912
|
changeAttrName,
|
|
4871
4913
|
withPreviousLocation(
|
|
4872
|
-
|
|
4914
|
+
import_compiler26.types.identifier(existingChangedAttr.name),
|
|
4873
4915
|
attr.value
|
|
4874
4916
|
)
|
|
4875
4917
|
);
|
|
@@ -4879,16 +4921,16 @@ function getChangeHandler(tag, attr) {
|
|
|
4879
4921
|
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
4880
4922
|
}
|
|
4881
4923
|
const changeHandlerId = generateUid(changeAttrName);
|
|
4882
|
-
const changeHandlerConst =
|
|
4883
|
-
|
|
4884
|
-
[
|
|
4885
|
-
|
|
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([]),
|
|
4886
4928
|
null,
|
|
4887
|
-
|
|
4929
|
+
import_compiler26.types.identifier(changeHandlerId)
|
|
4888
4930
|
);
|
|
4889
4931
|
BINDING_CHANGE_HANDLER.set(
|
|
4890
4932
|
binding.identifier,
|
|
4891
|
-
existingChangedAttr.value =
|
|
4933
|
+
existingChangedAttr.value = import_compiler26.types.identifier(changeHandlerId)
|
|
4892
4934
|
);
|
|
4893
4935
|
if (markoRoot.isMarkoTag()) {
|
|
4894
4936
|
markoRoot.insertAfter(changeHandlerConst);
|
|
@@ -4896,23 +4938,23 @@ function getChangeHandler(tag, attr) {
|
|
|
4896
4938
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
|
4897
4939
|
}
|
|
4898
4940
|
markoRoot.scope.crawl();
|
|
4899
|
-
return
|
|
4941
|
+
return import_compiler26.types.markoAttribute(
|
|
4900
4942
|
changeAttrName,
|
|
4901
|
-
withPreviousLocation(
|
|
4943
|
+
withPreviousLocation(import_compiler26.types.identifier(changeHandlerId), attr.value)
|
|
4902
4944
|
);
|
|
4903
|
-
} else if (
|
|
4945
|
+
} else if (import_compiler26.types.isMemberExpression(attr.value) || import_compiler26.types.isOptionalMemberExpression(attr.value)) {
|
|
4904
4946
|
const prop = attr.value.property;
|
|
4905
|
-
if (!
|
|
4906
|
-
const memberObj =
|
|
4907
|
-
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(
|
|
4908
4950
|
"+",
|
|
4909
|
-
|
|
4910
|
-
|
|
4951
|
+
import_compiler26.types.cloneNode(prop),
|
|
4952
|
+
import_compiler26.types.stringLiteral("Change")
|
|
4911
4953
|
);
|
|
4912
4954
|
const computed = memberProp.type !== "Identifier";
|
|
4913
|
-
return
|
|
4955
|
+
return import_compiler26.types.markoAttribute(
|
|
4914
4956
|
changeAttrName,
|
|
4915
|
-
attr.value.optional ?
|
|
4957
|
+
attr.value.optional ? import_compiler26.types.optionalMemberExpression(memberObj, memberProp, computed, true) : import_compiler26.types.memberExpression(memberObj, memberProp, computed)
|
|
4916
4958
|
);
|
|
4917
4959
|
}
|
|
4918
4960
|
}
|
|
@@ -4923,14 +4965,14 @@ function getChangeHandler(tag, attr) {
|
|
|
4923
4965
|
}
|
|
4924
4966
|
function buildChangeHandlerFunction(id) {
|
|
4925
4967
|
const newId = "_new_" + id.name;
|
|
4926
|
-
return
|
|
4927
|
-
[withPreviousLocation(
|
|
4928
|
-
|
|
4929
|
-
|
|
4930
|
-
|
|
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(
|
|
4931
4973
|
"=",
|
|
4932
|
-
withPreviousLocation(
|
|
4933
|
-
withPreviousLocation(
|
|
4974
|
+
withPreviousLocation(import_compiler26.types.identifier(id.name), id),
|
|
4975
|
+
withPreviousLocation(import_compiler26.types.identifier(newId), id)
|
|
4934
4976
|
)
|
|
4935
4977
|
)
|
|
4936
4978
|
])
|
|
@@ -4943,11 +4985,11 @@ function getChangeHandlerFromObjectPattern(parent) {
|
|
|
4943
4985
|
changeKey = generateUidIdentifier("dynamicChange");
|
|
4944
4986
|
pattern.pushContainer(
|
|
4945
4987
|
"properties",
|
|
4946
|
-
|
|
4947
|
-
|
|
4988
|
+
import_compiler26.types.objectProperty(
|
|
4989
|
+
import_compiler26.types.binaryExpression(
|
|
4948
4990
|
"+",
|
|
4949
4991
|
parent.get("key").node,
|
|
4950
|
-
|
|
4992
|
+
import_compiler26.types.stringLiteral("Change")
|
|
4951
4993
|
),
|
|
4952
4994
|
changeKey,
|
|
4953
4995
|
true
|
|
@@ -4969,8 +5011,8 @@ function getChangeHandlerFromObjectPattern(parent) {
|
|
|
4969
5011
|
if (!changeKey) {
|
|
4970
5012
|
pattern.unshiftContainer(
|
|
4971
5013
|
"properties",
|
|
4972
|
-
|
|
4973
|
-
|
|
5014
|
+
import_compiler26.types.objectProperty(
|
|
5015
|
+
import_compiler26.types.stringLiteral(searchKey),
|
|
4974
5016
|
changeKey = generateUidIdentifier(searchKey)
|
|
4975
5017
|
)
|
|
4976
5018
|
);
|
|
@@ -5000,7 +5042,7 @@ function getAssignmentInsertions(node, insertions) {
|
|
|
5000
5042
|
getLiteralName(left) || getLiteralName(prop.key) || "pattern"
|
|
5001
5043
|
);
|
|
5002
5044
|
prop.shorthand = false;
|
|
5003
|
-
prop.value =
|
|
5045
|
+
prop.value = import_compiler26.types.identifier(sourceName);
|
|
5004
5046
|
(insertions ||= []).push(
|
|
5005
5047
|
toConstTag(left, toFallbackExpr(sourceName, right))
|
|
5006
5048
|
);
|
|
@@ -5018,7 +5060,7 @@ function getAssignmentInsertions(node, insertions) {
|
|
|
5018
5060
|
if (el.type === "AssignmentPattern") {
|
|
5019
5061
|
const { left, right } = el;
|
|
5020
5062
|
const sourceName = generateUid(getLiteralName(left) || "pattern");
|
|
5021
|
-
node.elements[i] =
|
|
5063
|
+
node.elements[i] = import_compiler26.types.identifier(sourceName);
|
|
5022
5064
|
(insertions ||= []).push(
|
|
5023
5065
|
toConstTag(left, toFallbackExpr(sourceName, right))
|
|
5024
5066
|
);
|
|
@@ -5033,23 +5075,23 @@ function getAssignmentInsertions(node, insertions) {
|
|
|
5033
5075
|
return insertions;
|
|
5034
5076
|
}
|
|
5035
5077
|
function toFallbackExpr(id, fallback) {
|
|
5036
|
-
return
|
|
5037
|
-
|
|
5038
|
-
|
|
5078
|
+
return import_compiler26.types.conditionalExpression(
|
|
5079
|
+
import_compiler26.types.binaryExpression("!==", buildUndefined(), import_compiler26.types.identifier(id)),
|
|
5080
|
+
import_compiler26.types.identifier(id),
|
|
5039
5081
|
fallback
|
|
5040
5082
|
);
|
|
5041
5083
|
}
|
|
5042
5084
|
function toConstTag(id, expr) {
|
|
5043
|
-
return
|
|
5044
|
-
|
|
5045
|
-
[
|
|
5046
|
-
|
|
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(),
|
|
5047
5089
|
null,
|
|
5048
5090
|
id
|
|
5049
5091
|
);
|
|
5050
5092
|
}
|
|
5051
5093
|
function buildUndefined() {
|
|
5052
|
-
return
|
|
5094
|
+
return import_compiler26.types.unaryExpression("void", import_compiler26.types.numericLiteral(0));
|
|
5053
5095
|
}
|
|
5054
5096
|
|
|
5055
5097
|
// src/translator/visitors/program/index.ts
|
|
@@ -5061,14 +5103,14 @@ function isScopeIdentifier(node) {
|
|
|
5061
5103
|
var program_default = {
|
|
5062
5104
|
migrate: {
|
|
5063
5105
|
enter(program) {
|
|
5064
|
-
program.node.params = [
|
|
5106
|
+
program.node.params = [import_compiler27.types.identifier("input")];
|
|
5065
5107
|
},
|
|
5066
5108
|
exit(program) {
|
|
5067
5109
|
program.scope.crawl();
|
|
5068
5110
|
}
|
|
5069
5111
|
},
|
|
5070
5112
|
transform: {
|
|
5071
|
-
exit:
|
|
5113
|
+
exit: preAnalyze2
|
|
5072
5114
|
},
|
|
5073
5115
|
analyze: {
|
|
5074
5116
|
enter(program) {
|
|
@@ -5150,7 +5192,7 @@ var program_default = {
|
|
|
5150
5192
|
body.push(child);
|
|
5151
5193
|
}
|
|
5152
5194
|
}
|
|
5153
|
-
body[0] ??=
|
|
5195
|
+
body[0] ??= import_compiler27.types.importDeclaration([], import_compiler27.types.stringLiteral(compatFile));
|
|
5154
5196
|
program.node.body = body;
|
|
5155
5197
|
}
|
|
5156
5198
|
}
|
|
@@ -5164,7 +5206,7 @@ function resolveRelativeToEntry(entryFile, file, req) {
|
|
|
5164
5206
|
}
|
|
5165
5207
|
|
|
5166
5208
|
// src/translator/util/nested-attribute-tags.ts
|
|
5167
|
-
var
|
|
5209
|
+
var import_compiler28 = require("@marko/compiler");
|
|
5168
5210
|
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
|
5169
5211
|
var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
|
|
5170
5212
|
function getAttrTagIdentifier(meta) {
|
|
@@ -5173,7 +5215,7 @@ function getAttrTagIdentifier(meta) {
|
|
|
5173
5215
|
name2 = generateUid(meta.name);
|
|
5174
5216
|
attrTagToIdentifierLookup.set(meta, name2);
|
|
5175
5217
|
}
|
|
5176
|
-
return
|
|
5218
|
+
return import_compiler28.types.identifier(name2);
|
|
5177
5219
|
}
|
|
5178
5220
|
function analyzeAttributeTags(tag) {
|
|
5179
5221
|
if (tag.node.extra?.attributeTags) return tag.node.extra.attributeTags;
|
|
@@ -5286,7 +5328,7 @@ function getConditionRoot(tag) {
|
|
|
5286
5328
|
}
|
|
5287
5329
|
|
|
5288
5330
|
// src/translator/util/set-tag-sections-downstream.ts
|
|
5289
|
-
var
|
|
5331
|
+
var import_compiler29 = require("@marko/compiler");
|
|
5290
5332
|
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
|
5291
5333
|
var [getTagDownstreams] = createSectionState(
|
|
5292
5334
|
"tag-downstreams",
|
|
@@ -5333,23 +5375,82 @@ function crawlSectionsAndSetBinding(tag, binding, tree, skip2) {
|
|
|
5333
5375
|
}
|
|
5334
5376
|
|
|
5335
5377
|
// src/translator/util/translate-attrs.ts
|
|
5336
|
-
var
|
|
5337
|
-
var
|
|
5378
|
+
var import_compiler36 = require("@marko/compiler");
|
|
5379
|
+
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
|
5338
5380
|
|
|
5339
5381
|
// src/translator/core/for.ts
|
|
5340
|
-
var
|
|
5341
|
-
var
|
|
5382
|
+
var import_compiler35 = require("@marko/compiler");
|
|
5383
|
+
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
|
5342
5384
|
|
|
5343
5385
|
// src/translator/util/is-only-child-in-parent.ts
|
|
5344
|
-
var
|
|
5345
|
-
var
|
|
5386
|
+
var import_compiler34 = require("@marko/compiler");
|
|
5387
|
+
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
|
5346
5388
|
|
|
5347
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
|
|
5348
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");
|
|
5349
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
|
+
}
|
|
5350
5451
|
|
|
5351
5452
|
// src/translator/util/translate-var.ts
|
|
5352
|
-
var
|
|
5453
|
+
var import_compiler32 = require("@marko/compiler");
|
|
5353
5454
|
function translateVar(tag, initialValue, kind = "const") {
|
|
5354
5455
|
const {
|
|
5355
5456
|
node: { var: tagVar }
|
|
@@ -5367,15 +5468,15 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
|
5367
5468
|
if (changeBinding && changeName !== changeBinding.name) {
|
|
5368
5469
|
getDestructurePattern(id)?.pushContainer(
|
|
5369
5470
|
"properties",
|
|
5370
|
-
|
|
5371
|
-
|
|
5372
|
-
|
|
5471
|
+
import_compiler32.types.objectProperty(
|
|
5472
|
+
import_compiler32.types.identifier(changeName),
|
|
5473
|
+
import_compiler32.types.identifier(changeBinding.name)
|
|
5373
5474
|
)
|
|
5374
5475
|
);
|
|
5375
5476
|
}
|
|
5376
5477
|
});
|
|
5377
5478
|
tag.insertBefore(
|
|
5378
|
-
|
|
5479
|
+
import_compiler32.types.variableDeclaration(kind, [import_compiler32.types.variableDeclarator(tagVar, initialValue)])
|
|
5379
5480
|
);
|
|
5380
5481
|
}
|
|
5381
5482
|
function translateDomVar(tag, binding) {
|
|
@@ -5385,13 +5486,13 @@ function translateDomVar(tag, binding) {
|
|
|
5385
5486
|
if (registerId) {
|
|
5386
5487
|
tag.parentPath.unshiftContainer(
|
|
5387
5488
|
"body",
|
|
5388
|
-
|
|
5389
|
-
|
|
5489
|
+
import_compiler32.types.variableDeclaration("const", [
|
|
5490
|
+
import_compiler32.types.variableDeclarator(
|
|
5390
5491
|
tag.node.var,
|
|
5391
5492
|
callRuntime(
|
|
5392
5493
|
"_el",
|
|
5393
5494
|
getScopeIdIdentifier(tagSection),
|
|
5394
|
-
|
|
5495
|
+
import_compiler32.types.stringLiteral(registerId)
|
|
5395
5496
|
)
|
|
5396
5497
|
)
|
|
5397
5498
|
])
|
|
@@ -5417,65 +5518,83 @@ var htmlSelectArgs = /* @__PURE__ */ new WeakMap();
|
|
|
5417
5518
|
var native_tag_default = {
|
|
5418
5519
|
analyze: {
|
|
5419
5520
|
enter(tag) {
|
|
5420
|
-
(0,
|
|
5421
|
-
(0,
|
|
5422
|
-
(0,
|
|
5521
|
+
(0, import_babel_utils21.assertNoArgs)(tag);
|
|
5522
|
+
(0, import_babel_utils21.assertNoParams)(tag);
|
|
5523
|
+
(0, import_babel_utils21.assertNoAttributeTags)(tag);
|
|
5423
5524
|
const { node } = tag;
|
|
5424
|
-
if (node.var && !
|
|
5525
|
+
if (node.var && !import_compiler33.types.isIdentifier(node.var)) {
|
|
5425
5526
|
throw tag.get("var").buildCodeFrameError(
|
|
5426
5527
|
"Tag variables on [native tags](https://markojs.com/docs/reference/native-tag) cannot be destructured."
|
|
5427
5528
|
);
|
|
5428
5529
|
}
|
|
5429
|
-
const tagName =
|
|
5530
|
+
const tagName = getCanonicalTagName(tag);
|
|
5531
|
+
const textOnly = isTextOnlyNativeTag(tag);
|
|
5430
5532
|
const seen = {};
|
|
5431
5533
|
const { attributes } = tag.node;
|
|
5534
|
+
let injectNonce = isInjectNonceTag(tagName);
|
|
5432
5535
|
let hasDynamicAttributes = false;
|
|
5433
5536
|
let hasEventHandlers = false;
|
|
5434
5537
|
let relatedControllable;
|
|
5435
5538
|
let spreadReferenceNodes;
|
|
5436
|
-
let
|
|
5539
|
+
let exprExtras;
|
|
5437
5540
|
for (let i = attributes.length; i--; ) {
|
|
5438
5541
|
const attr = attributes[i];
|
|
5439
5542
|
const valueExtra = attr.value.extra ??= {};
|
|
5440
|
-
if (
|
|
5543
|
+
if (import_compiler33.types.isMarkoAttribute(attr)) {
|
|
5441
5544
|
if (seen[attr.name]) {
|
|
5442
5545
|
dropReferences(attr.value);
|
|
5443
5546
|
continue;
|
|
5444
5547
|
}
|
|
5445
5548
|
seen[attr.name] = attr;
|
|
5549
|
+
if (injectNonce && attr.name === "nonce") {
|
|
5550
|
+
injectNonce = false;
|
|
5551
|
+
}
|
|
5446
5552
|
if (isEventHandler(attr.name) || isNativeTagChangeHandler(attr.name)) {
|
|
5447
5553
|
valueExtra.isEffect = true;
|
|
5448
5554
|
hasEventHandlers = true;
|
|
5449
5555
|
} else if (!evaluate(attr.value).confident) {
|
|
5450
5556
|
hasDynamicAttributes = true;
|
|
5451
5557
|
}
|
|
5452
|
-
} else if (
|
|
5558
|
+
} else if (import_compiler33.types.isMarkoSpreadAttribute(attr)) {
|
|
5453
5559
|
valueExtra.isEffect = true;
|
|
5454
5560
|
hasEventHandlers = true;
|
|
5455
5561
|
hasDynamicAttributes = true;
|
|
5456
5562
|
}
|
|
5457
5563
|
if (spreadReferenceNodes) {
|
|
5458
5564
|
spreadReferenceNodes.push(attr.value);
|
|
5459
|
-
} else if (
|
|
5565
|
+
} else if (import_compiler33.types.isMarkoSpreadAttribute(attr)) {
|
|
5460
5566
|
spreadReferenceNodes = [attr.value];
|
|
5461
5567
|
relatedControllable = getRelatedControllable(tagName, seen);
|
|
5462
5568
|
} else {
|
|
5463
|
-
|
|
5569
|
+
exprExtras = push(exprExtras, valueExtra);
|
|
5464
5570
|
}
|
|
5465
5571
|
}
|
|
5466
5572
|
assertExclusiveAttrs(seen, (msg) => {
|
|
5467
5573
|
throw tag.get("name").buildCodeFrameError(msg);
|
|
5468
5574
|
});
|
|
5469
|
-
|
|
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) {
|
|
5470
5589
|
const tagExtra = node.extra ??= {};
|
|
5471
5590
|
const tagSection = getOrCreateSection(tag);
|
|
5472
5591
|
const nodeBinding = tagExtra[kNativeTagBinding] = createBinding(
|
|
5473
|
-
"#" + (
|
|
5592
|
+
"#" + getCanonicalTagName(tag),
|
|
5474
5593
|
0 /* dom */,
|
|
5475
5594
|
tagSection
|
|
5476
5595
|
);
|
|
5477
5596
|
if (hasEventHandlers) {
|
|
5478
|
-
(0,
|
|
5597
|
+
(0, import_babel_utils21.getProgram)().node.extra.isInteractive = true;
|
|
5479
5598
|
}
|
|
5480
5599
|
if (spreadReferenceNodes) {
|
|
5481
5600
|
if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
|
|
@@ -5497,38 +5616,50 @@ var native_tag_default = {
|
|
|
5497
5616
|
relatedControllable.attrs.map((it) => it?.value)
|
|
5498
5617
|
);
|
|
5499
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
|
+
}
|
|
5500
5629
|
addSerializeExpr(
|
|
5501
5630
|
tagSection,
|
|
5502
5631
|
!!(node.var || hasEventHandlers),
|
|
5503
5632
|
nodeBinding
|
|
5504
5633
|
);
|
|
5505
5634
|
trackDomVarReferences(tag, nodeBinding);
|
|
5506
|
-
addSerializeExpr(
|
|
5507
|
-
tagSection,
|
|
5508
|
-
push(attrExprExtras, tagExtra),
|
|
5509
|
-
nodeBinding
|
|
5510
|
-
);
|
|
5635
|
+
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
5511
5636
|
}
|
|
5512
5637
|
}
|
|
5513
5638
|
},
|
|
5514
5639
|
translate: translateByTarget({
|
|
5515
5640
|
html: {
|
|
5516
5641
|
enter(tag) {
|
|
5517
|
-
const tagName =
|
|
5642
|
+
const tagName = getCanonicalTagName(tag);
|
|
5518
5643
|
const tagExtra = tag.node.extra;
|
|
5519
5644
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5520
|
-
const tagDef = (0,
|
|
5645
|
+
const tagDef = (0, import_babel_utils21.getTagDef)(tag);
|
|
5521
5646
|
const write = writeTo(tag);
|
|
5522
5647
|
const tagSection = getSection(tag);
|
|
5523
|
-
if (tagExtra.tagNameNullable) {
|
|
5524
|
-
flushBefore(tag);
|
|
5525
|
-
}
|
|
5526
5648
|
translateDomVar(tag, nodeBinding);
|
|
5527
5649
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
5528
|
-
write`<${
|
|
5650
|
+
write`<${tagName}`;
|
|
5529
5651
|
const usedAttrs = getUsedAttrs(tagName, tag.node);
|
|
5530
|
-
const {
|
|
5652
|
+
const {
|
|
5653
|
+
staticAttrs,
|
|
5654
|
+
staticControllable,
|
|
5655
|
+
staticContentAttr,
|
|
5656
|
+
skipExpression,
|
|
5657
|
+
injectNonce
|
|
5658
|
+
} = usedAttrs;
|
|
5531
5659
|
let { spreadExpression } = usedAttrs;
|
|
5660
|
+
if (injectNonce) {
|
|
5661
|
+
write`${callRuntime("_attr_nonce")}`;
|
|
5662
|
+
}
|
|
5532
5663
|
if (staticControllable) {
|
|
5533
5664
|
if (tagName !== "select" && tagName !== "textarea") {
|
|
5534
5665
|
write`${callRuntime(
|
|
@@ -5552,18 +5683,18 @@ var native_tag_default = {
|
|
|
5552
5683
|
} else if (spreadExpression) {
|
|
5553
5684
|
const spreadIdentifier = generateUidIdentifier("select_input");
|
|
5554
5685
|
tag.insertBefore(
|
|
5555
|
-
|
|
5556
|
-
|
|
5686
|
+
import_compiler33.types.variableDeclaration("const", [
|
|
5687
|
+
import_compiler33.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5557
5688
|
])
|
|
5558
5689
|
);
|
|
5559
5690
|
htmlSelectArgs.set(tag.node, {
|
|
5560
|
-
value:
|
|
5691
|
+
value: import_compiler33.types.memberExpression(
|
|
5561
5692
|
spreadIdentifier,
|
|
5562
|
-
|
|
5693
|
+
import_compiler33.types.identifier("value")
|
|
5563
5694
|
),
|
|
5564
|
-
valueChange:
|
|
5695
|
+
valueChange: import_compiler33.types.memberExpression(
|
|
5565
5696
|
spreadIdentifier,
|
|
5566
|
-
|
|
5697
|
+
import_compiler33.types.identifier("valueChange")
|
|
5567
5698
|
)
|
|
5568
5699
|
});
|
|
5569
5700
|
spreadExpression = spreadIdentifier;
|
|
@@ -5577,14 +5708,14 @@ var native_tag_default = {
|
|
|
5577
5708
|
} else if (spreadExpression) {
|
|
5578
5709
|
const spreadIdentifier = generateUidIdentifier("textarea_input");
|
|
5579
5710
|
tag.insertBefore(
|
|
5580
|
-
|
|
5581
|
-
|
|
5711
|
+
import_compiler33.types.variableDeclaration("const", [
|
|
5712
|
+
import_compiler33.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
|
5582
5713
|
])
|
|
5583
5714
|
);
|
|
5584
|
-
value =
|
|
5585
|
-
valueChange =
|
|
5715
|
+
value = import_compiler33.types.memberExpression(spreadIdentifier, import_compiler33.types.identifier("value"));
|
|
5716
|
+
valueChange = import_compiler33.types.memberExpression(
|
|
5586
5717
|
spreadIdentifier,
|
|
5587
|
-
|
|
5718
|
+
import_compiler33.types.identifier("valueChange")
|
|
5588
5719
|
);
|
|
5589
5720
|
spreadExpression = spreadIdentifier;
|
|
5590
5721
|
}
|
|
@@ -5597,7 +5728,7 @@ var native_tag_default = {
|
|
|
5597
5728
|
valueChange
|
|
5598
5729
|
);
|
|
5599
5730
|
} else if (value) {
|
|
5600
|
-
writeAtStartOfBody = callRuntime("
|
|
5731
|
+
writeAtStartOfBody = callRuntime("_escape_text", value);
|
|
5601
5732
|
}
|
|
5602
5733
|
}
|
|
5603
5734
|
for (const attr of staticAttrs) {
|
|
@@ -5625,7 +5756,7 @@ var native_tag_default = {
|
|
|
5625
5756
|
} else if (isEventHandler(name2)) {
|
|
5626
5757
|
addHTMLEffectCall(tagSection, valueReferences);
|
|
5627
5758
|
} else {
|
|
5628
|
-
write`${callRuntime("_attr",
|
|
5759
|
+
write`${callRuntime("_attr", import_compiler33.types.stringLiteral(name2), value)}`;
|
|
5629
5760
|
}
|
|
5630
5761
|
break;
|
|
5631
5762
|
}
|
|
@@ -5634,11 +5765,24 @@ var native_tag_default = {
|
|
|
5634
5765
|
const hasChildren = !!tag.node.body.body.length;
|
|
5635
5766
|
if (spreadExpression) {
|
|
5636
5767
|
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
5637
|
-
if (isOpenOnly || hasChildren ||
|
|
5768
|
+
if (isOpenOnly || hasChildren || staticContentAttr) {
|
|
5638
5769
|
if (skipExpression) {
|
|
5639
|
-
write`${callRuntime(
|
|
5770
|
+
write`${callRuntime(
|
|
5771
|
+
"_attrs_partial",
|
|
5772
|
+
spreadExpression,
|
|
5773
|
+
skipExpression,
|
|
5774
|
+
visitAccessor,
|
|
5775
|
+
getScopeIdIdentifier(tagSection),
|
|
5776
|
+
import_compiler33.types.stringLiteral(tagName)
|
|
5777
|
+
)}`;
|
|
5640
5778
|
} else {
|
|
5641
|
-
write`${callRuntime(
|
|
5779
|
+
write`${callRuntime(
|
|
5780
|
+
"_attrs",
|
|
5781
|
+
spreadExpression,
|
|
5782
|
+
visitAccessor,
|
|
5783
|
+
getScopeIdIdentifier(tagSection),
|
|
5784
|
+
import_compiler33.types.stringLiteral(tagName)
|
|
5785
|
+
)}`;
|
|
5642
5786
|
}
|
|
5643
5787
|
}
|
|
5644
5788
|
}
|
|
@@ -5653,16 +5797,16 @@ var native_tag_default = {
|
|
|
5653
5797
|
break;
|
|
5654
5798
|
}
|
|
5655
5799
|
} else {
|
|
5656
|
-
if (
|
|
5800
|
+
if (staticContentAttr) {
|
|
5657
5801
|
write`>`;
|
|
5658
5802
|
tagExtra[kTagContentAttr] = true;
|
|
5659
5803
|
tag.node.body.body = [
|
|
5660
|
-
|
|
5804
|
+
import_compiler33.types.expressionStatement(
|
|
5661
5805
|
callRuntime(
|
|
5662
5806
|
"_attr_content",
|
|
5663
5807
|
visitAccessor,
|
|
5664
5808
|
getScopeIdIdentifier(tagSection),
|
|
5665
|
-
|
|
5809
|
+
staticContentAttr.value,
|
|
5666
5810
|
getSerializeGuard(
|
|
5667
5811
|
tagSection,
|
|
5668
5812
|
nodeBinding && getSerializeReason(tagSection, nodeBinding),
|
|
@@ -5679,23 +5823,23 @@ var native_tag_default = {
|
|
|
5679
5823
|
);
|
|
5680
5824
|
tagExtra[kTagContentAttr] = true;
|
|
5681
5825
|
tag.node.body.body = [
|
|
5682
|
-
skipExpression ?
|
|
5826
|
+
skipExpression ? import_compiler33.types.expressionStatement(
|
|
5683
5827
|
callRuntime(
|
|
5684
5828
|
"_attrs_partial_content",
|
|
5685
5829
|
spreadExpression,
|
|
5686
5830
|
skipExpression,
|
|
5687
5831
|
visitAccessor,
|
|
5688
5832
|
getScopeIdIdentifier(tagSection),
|
|
5689
|
-
|
|
5833
|
+
import_compiler33.types.stringLiteral(tagName),
|
|
5690
5834
|
serializeReason
|
|
5691
5835
|
)
|
|
5692
|
-
) :
|
|
5836
|
+
) : import_compiler33.types.expressionStatement(
|
|
5693
5837
|
callRuntime(
|
|
5694
5838
|
"_attrs_content",
|
|
5695
5839
|
spreadExpression,
|
|
5696
5840
|
visitAccessor,
|
|
5697
5841
|
getScopeIdIdentifier(tagSection),
|
|
5698
|
-
|
|
5842
|
+
import_compiler33.types.stringLiteral(tagName),
|
|
5699
5843
|
serializeReason
|
|
5700
5844
|
)
|
|
5701
5845
|
)
|
|
@@ -5704,11 +5848,6 @@ var native_tag_default = {
|
|
|
5704
5848
|
write`>`;
|
|
5705
5849
|
}
|
|
5706
5850
|
}
|
|
5707
|
-
if (tagExtra.tagNameNullable) {
|
|
5708
|
-
tag.insertBefore(
|
|
5709
|
-
import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
|
|
5710
|
-
)[0].skip();
|
|
5711
|
-
}
|
|
5712
5851
|
if (writeAtStartOfBody) {
|
|
5713
5852
|
write`${writeAtStartOfBody}`;
|
|
5714
5853
|
}
|
|
@@ -5716,50 +5855,52 @@ var native_tag_default = {
|
|
|
5716
5855
|
exit(tag) {
|
|
5717
5856
|
const tagExtra = tag.node.extra;
|
|
5718
5857
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5719
|
-
const openTagOnly = (0,
|
|
5858
|
+
const openTagOnly = (0, import_babel_utils21.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
|
5859
|
+
const textOnly = isTextOnlyNativeTag(tag);
|
|
5720
5860
|
const selectArgs = htmlSelectArgs.get(tag.node);
|
|
5721
|
-
const tagName =
|
|
5861
|
+
const tagName = getCanonicalTagName(tag);
|
|
5722
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
|
+
);
|
|
5723
5868
|
if (tagExtra[kTagContentAttr]) {
|
|
5724
5869
|
flushBefore(tag);
|
|
5725
5870
|
}
|
|
5726
|
-
if (tagExtra.tagNameNullable) {
|
|
5727
|
-
flushInto(tag);
|
|
5728
|
-
}
|
|
5729
5871
|
if (selectArgs) {
|
|
5730
5872
|
if (!tagExtra[kSkipEndTag]) {
|
|
5731
|
-
|
|
5873
|
+
write`</${tagName}>`;
|
|
5732
5874
|
}
|
|
5733
5875
|
flushInto(tag);
|
|
5734
5876
|
tag.insertBefore(
|
|
5735
|
-
|
|
5877
|
+
import_compiler33.types.expressionStatement(
|
|
5736
5878
|
callRuntime(
|
|
5737
5879
|
"_attr_select_value",
|
|
5738
5880
|
getScopeIdIdentifier(getSection(tag)),
|
|
5739
5881
|
nodeBinding && getScopeAccessorLiteral(nodeBinding),
|
|
5740
5882
|
selectArgs.value,
|
|
5741
5883
|
selectArgs.valueChange,
|
|
5742
|
-
|
|
5884
|
+
import_compiler33.types.arrowFunctionExpression(
|
|
5743
5885
|
[],
|
|
5744
|
-
|
|
5886
|
+
import_compiler33.types.blockStatement(tag.node.body.body)
|
|
5745
5887
|
)
|
|
5746
5888
|
)
|
|
5747
5889
|
)
|
|
5748
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
|
+
}
|
|
5749
5899
|
} else {
|
|
5750
5900
|
tag.insertBefore(tag.node.body.body).forEach((child) => child.skip());
|
|
5751
5901
|
}
|
|
5752
|
-
const markerSerializeReason = !tagExtra[kSkipEndTag] && nodeBinding && getSerializeReason(tagSection, nodeBinding);
|
|
5753
5902
|
if (!tagExtra[kSkipEndTag] && !openTagOnly && !selectArgs) {
|
|
5754
|
-
|
|
5755
|
-
tag,
|
|
5756
|
-
!markerSerializeReason && (tagName === "html" || tagName === "body")
|
|
5757
|
-
)`</${tag.node.name}>`;
|
|
5758
|
-
}
|
|
5759
|
-
if (tagExtra.tagNameNullable) {
|
|
5760
|
-
tag.insertBefore(
|
|
5761
|
-
import_compiler30.types.ifStatement(tag.node.name, consumeHTML(tag))
|
|
5762
|
-
)[0].skip();
|
|
5903
|
+
write`</${tagName}>`;
|
|
5763
5904
|
}
|
|
5764
5905
|
if (markerSerializeReason) {
|
|
5765
5906
|
markNode(tag, nodeBinding, markerSerializeReason);
|
|
@@ -5769,22 +5910,41 @@ var native_tag_default = {
|
|
|
5769
5910
|
},
|
|
5770
5911
|
dom: {
|
|
5771
5912
|
enter(tag) {
|
|
5772
|
-
const tagName =
|
|
5913
|
+
const tagName = getCanonicalTagName(tag);
|
|
5773
5914
|
const tagExtra = tag.node.extra;
|
|
5774
5915
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5775
|
-
const tagDef = (0,
|
|
5916
|
+
const tagDef = (0, import_babel_utils21.getTagDef)(tag);
|
|
5776
5917
|
const write = writeTo(tag);
|
|
5777
5918
|
const tagSection = getSection(tag);
|
|
5778
5919
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
5779
5920
|
if (nodeBinding) {
|
|
5780
5921
|
visit(tag, 32 /* Get */);
|
|
5781
5922
|
}
|
|
5782
|
-
write`<${
|
|
5783
|
-
const
|
|
5784
|
-
|
|
5785
|
-
|
|
5923
|
+
write`<${tagName}`;
|
|
5924
|
+
const {
|
|
5925
|
+
staticAttrs,
|
|
5926
|
+
staticControllable,
|
|
5927
|
+
staticContentAttr,
|
|
5928
|
+
skipExpression,
|
|
5929
|
+
spreadExpression,
|
|
5930
|
+
injectNonce
|
|
5931
|
+
} = getUsedAttrs(tagName, tag.node);
|
|
5786
5932
|
const isOpenOnly = !!(tagDef && tagDef.parseOptions?.openTagOnly);
|
|
5787
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
|
+
}
|
|
5788
5948
|
if (staticControllable) {
|
|
5789
5949
|
const { helper, attrs } = staticControllable;
|
|
5790
5950
|
const firstAttr = attrs.find(Boolean);
|
|
@@ -5794,7 +5954,7 @@ var native_tag_default = {
|
|
|
5794
5954
|
"render",
|
|
5795
5955
|
tagSection,
|
|
5796
5956
|
referencedBindings,
|
|
5797
|
-
|
|
5957
|
+
import_compiler33.types.expressionStatement(
|
|
5798
5958
|
callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
|
|
5799
5959
|
)
|
|
5800
5960
|
);
|
|
@@ -5803,7 +5963,7 @@ var native_tag_default = {
|
|
|
5803
5963
|
"effect",
|
|
5804
5964
|
tagSection,
|
|
5805
5965
|
void 0,
|
|
5806
|
-
|
|
5966
|
+
import_compiler33.types.expressionStatement(
|
|
5807
5967
|
callRuntime(`${helper}_script`, scopeIdentifier, visitAccessor)
|
|
5808
5968
|
)
|
|
5809
5969
|
);
|
|
@@ -5829,7 +5989,7 @@ var native_tag_default = {
|
|
|
5829
5989
|
let stmt;
|
|
5830
5990
|
trackDelimitedAttrValue(value, meta);
|
|
5831
5991
|
if (meta.dynamicItems) {
|
|
5832
|
-
stmt =
|
|
5992
|
+
stmt = import_compiler33.types.expressionStatement(
|
|
5833
5993
|
callRuntime(helper, nodeExpr, value)
|
|
5834
5994
|
);
|
|
5835
5995
|
} else {
|
|
@@ -5841,11 +6001,11 @@ var native_tag_default = {
|
|
|
5841
6001
|
if (keys.length === 1) {
|
|
5842
6002
|
const [key] = keys;
|
|
5843
6003
|
const value2 = meta.dynamicValues[key];
|
|
5844
|
-
stmt =
|
|
6004
|
+
stmt = import_compiler33.types.expressionStatement(
|
|
5845
6005
|
callRuntime(
|
|
5846
6006
|
`_attr_${name2}_item`,
|
|
5847
6007
|
nodeExpr,
|
|
5848
|
-
|
|
6008
|
+
import_compiler33.types.stringLiteral(key),
|
|
5849
6009
|
value2
|
|
5850
6010
|
)
|
|
5851
6011
|
);
|
|
@@ -5854,14 +6014,14 @@ var native_tag_default = {
|
|
|
5854
6014
|
for (const key of keys) {
|
|
5855
6015
|
const value2 = meta.dynamicValues[key];
|
|
5856
6016
|
props.push(
|
|
5857
|
-
|
|
6017
|
+
import_compiler33.types.objectProperty(toPropertyName(key), value2)
|
|
5858
6018
|
);
|
|
5859
6019
|
}
|
|
5860
|
-
stmt =
|
|
6020
|
+
stmt = import_compiler33.types.expressionStatement(
|
|
5861
6021
|
callRuntime(
|
|
5862
6022
|
`_attr_${name2}_items`,
|
|
5863
6023
|
nodeExpr,
|
|
5864
|
-
|
|
6024
|
+
import_compiler33.types.objectExpression(props)
|
|
5865
6025
|
)
|
|
5866
6026
|
);
|
|
5867
6027
|
}
|
|
@@ -5881,11 +6041,11 @@ var native_tag_default = {
|
|
|
5881
6041
|
"effect",
|
|
5882
6042
|
tagSection,
|
|
5883
6043
|
valueReferences,
|
|
5884
|
-
|
|
6044
|
+
import_compiler33.types.expressionStatement(
|
|
5885
6045
|
callRuntime(
|
|
5886
6046
|
"_on",
|
|
5887
6047
|
createScopeReadExpression(nodeBinding),
|
|
5888
|
-
|
|
6048
|
+
import_compiler33.types.stringLiteral(getEventHandlerName(name2)),
|
|
5889
6049
|
value
|
|
5890
6050
|
)
|
|
5891
6051
|
)
|
|
@@ -5895,11 +6055,11 @@ var native_tag_default = {
|
|
|
5895
6055
|
"render",
|
|
5896
6056
|
tagSection,
|
|
5897
6057
|
valueReferences,
|
|
5898
|
-
|
|
6058
|
+
import_compiler33.types.expressionStatement(
|
|
5899
6059
|
callRuntime(
|
|
5900
6060
|
"_attr",
|
|
5901
6061
|
createScopeReadExpression(nodeBinding),
|
|
5902
|
-
|
|
6062
|
+
import_compiler33.types.stringLiteral(name2),
|
|
5903
6063
|
value
|
|
5904
6064
|
)
|
|
5905
6065
|
)
|
|
@@ -5909,13 +6069,13 @@ var native_tag_default = {
|
|
|
5909
6069
|
}
|
|
5910
6070
|
}
|
|
5911
6071
|
if (spreadExpression) {
|
|
5912
|
-
const canHaveAttrContent = !(isOpenOnly || hasChildren ||
|
|
6072
|
+
const canHaveAttrContent = !(isOpenOnly || hasChildren || staticContentAttr);
|
|
5913
6073
|
if (skipExpression) {
|
|
5914
6074
|
addStatement(
|
|
5915
6075
|
"render",
|
|
5916
6076
|
tagSection,
|
|
5917
6077
|
tagExtra.referencedBindings,
|
|
5918
|
-
|
|
6078
|
+
import_compiler33.types.expressionStatement(
|
|
5919
6079
|
callRuntime(
|
|
5920
6080
|
canHaveAttrContent ? "_attrs_partial_content" : "_attrs_partial",
|
|
5921
6081
|
scopeIdentifier,
|
|
@@ -5930,7 +6090,7 @@ var native_tag_default = {
|
|
|
5930
6090
|
"render",
|
|
5931
6091
|
tagSection,
|
|
5932
6092
|
tagExtra.referencedBindings,
|
|
5933
|
-
|
|
6093
|
+
import_compiler33.types.expressionStatement(
|
|
5934
6094
|
callRuntime(
|
|
5935
6095
|
canHaveAttrContent ? "_attrs_content" : "_attrs",
|
|
5936
6096
|
scopeIdentifier,
|
|
@@ -5944,24 +6104,23 @@ var native_tag_default = {
|
|
|
5944
6104
|
"effect",
|
|
5945
6105
|
tagSection,
|
|
5946
6106
|
tagExtra.referencedBindings,
|
|
5947
|
-
|
|
6107
|
+
import_compiler33.types.expressionStatement(
|
|
5948
6108
|
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
5949
6109
|
),
|
|
5950
6110
|
false
|
|
5951
6111
|
);
|
|
5952
6112
|
}
|
|
5953
|
-
if (
|
|
5954
|
-
const contentAttrValue = usedAttrs.staticContentAttr.value;
|
|
6113
|
+
if (staticContentAttr) {
|
|
5955
6114
|
addStatement(
|
|
5956
6115
|
"render",
|
|
5957
6116
|
tagSection,
|
|
5958
|
-
|
|
5959
|
-
|
|
6117
|
+
staticContentAttr.value.extra?.referencedBindings,
|
|
6118
|
+
import_compiler33.types.expressionStatement(
|
|
5960
6119
|
callRuntime(
|
|
5961
6120
|
"_attr_content",
|
|
5962
6121
|
scopeIdentifier,
|
|
5963
6122
|
visitAccessor,
|
|
5964
|
-
|
|
6123
|
+
staticContentAttr.value
|
|
5965
6124
|
)
|
|
5966
6125
|
)
|
|
5967
6126
|
);
|
|
@@ -5982,10 +6141,33 @@ var native_tag_default = {
|
|
|
5982
6141
|
enter2(tag);
|
|
5983
6142
|
},
|
|
5984
6143
|
exit(tag) {
|
|
5985
|
-
const
|
|
5986
|
-
|
|
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);
|
|
5987
6148
|
if (!openTagOnly) {
|
|
5988
|
-
|
|
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)}>`;
|
|
5989
6171
|
}
|
|
5990
6172
|
exit2(tag);
|
|
5991
6173
|
tag.remove();
|
|
@@ -6058,10 +6240,11 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6058
6240
|
let skipProps;
|
|
6059
6241
|
let staticControllable;
|
|
6060
6242
|
let staticContentAttr;
|
|
6243
|
+
let injectNonce = isInjectNonceTag(tagName);
|
|
6061
6244
|
for (let i = attributes.length; i--; ) {
|
|
6062
6245
|
const attr = attributes[i];
|
|
6063
6246
|
const { value } = attr;
|
|
6064
|
-
if (
|
|
6247
|
+
if (import_compiler33.types.isMarkoSpreadAttribute(attr)) {
|
|
6065
6248
|
if (!spreadProps) {
|
|
6066
6249
|
spreadProps = [];
|
|
6067
6250
|
staticControllable = getRelatedControllable(tagName, seen);
|
|
@@ -6075,9 +6258,12 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6075
6258
|
staticControllable = void 0;
|
|
6076
6259
|
}
|
|
6077
6260
|
}
|
|
6078
|
-
spreadProps.push(
|
|
6261
|
+
spreadProps.push(import_compiler33.types.spreadElement(value));
|
|
6079
6262
|
} else if (!(seen[attr.name] || attr.name === "content" && tag.body.body.length)) {
|
|
6080
6263
|
seen[attr.name] = attr;
|
|
6264
|
+
if (injectNonce && attr.name === "nonce") {
|
|
6265
|
+
injectNonce = false;
|
|
6266
|
+
}
|
|
6081
6267
|
if (spreadProps) {
|
|
6082
6268
|
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
6083
6269
|
} else if (attr.name === "content" && tagName !== "meta") {
|
|
@@ -6102,25 +6288,37 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6102
6288
|
}
|
|
6103
6289
|
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
6104
6290
|
if (spreadProps) {
|
|
6105
|
-
spreadProps.reverse();
|
|
6106
6291
|
if (staticControllable) {
|
|
6107
6292
|
for (const attr of staticControllable.attrs) {
|
|
6108
6293
|
if (attr) {
|
|
6109
6294
|
(skipProps ||= []).push(
|
|
6110
|
-
toObjectProperty(attr.name,
|
|
6295
|
+
toObjectProperty(attr.name, import_compiler33.types.numericLiteral(1))
|
|
6111
6296
|
);
|
|
6112
6297
|
}
|
|
6113
6298
|
}
|
|
6114
6299
|
}
|
|
6115
6300
|
for (const { name: name2 } of staticAttrs) {
|
|
6116
|
-
(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
|
+
);
|
|
6117
6314
|
}
|
|
6118
|
-
spreadExpression = propsToExpression(spreadProps);
|
|
6315
|
+
spreadExpression = propsToExpression(spreadProps.reverse());
|
|
6119
6316
|
}
|
|
6120
6317
|
if (skipProps) {
|
|
6121
|
-
skipExpression =
|
|
6318
|
+
skipExpression = import_compiler33.types.objectExpression(skipProps);
|
|
6122
6319
|
}
|
|
6123
6320
|
return {
|
|
6321
|
+
injectNonce,
|
|
6124
6322
|
staticAttrs,
|
|
6125
6323
|
staticContentAttr,
|
|
6126
6324
|
staticControllable,
|
|
@@ -6128,6 +6326,36 @@ function getUsedAttrs(tagName, tag) {
|
|
|
6128
6326
|
skipExpression
|
|
6129
6327
|
};
|
|
6130
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
|
+
}
|
|
6131
6359
|
function trackDelimitedAttrValue(expr, meta) {
|
|
6132
6360
|
switch (expr.type) {
|
|
6133
6361
|
case "ObjectExpression":
|
|
@@ -6205,14 +6433,14 @@ function trackDelimitedAttrObjectProperties(obj, meta) {
|
|
|
6205
6433
|
(meta.staticItems ||= []).push(staticProps);
|
|
6206
6434
|
}
|
|
6207
6435
|
if (dynamicProps) {
|
|
6208
|
-
(meta.dynamicItems ||= []).push(
|
|
6436
|
+
(meta.dynamicItems ||= []).push(import_compiler33.types.objectExpression(dynamicProps));
|
|
6209
6437
|
}
|
|
6210
6438
|
}
|
|
6211
6439
|
function isNativeTagChangeHandler(propName) {
|
|
6212
6440
|
return /^(?:value|checked(?:Value)?|open)Change$/.test(propName);
|
|
6213
6441
|
}
|
|
6214
6442
|
function buildUndefined2() {
|
|
6215
|
-
return
|
|
6443
|
+
return import_compiler33.types.unaryExpression("void", import_compiler33.types.numericLiteral(0));
|
|
6216
6444
|
}
|
|
6217
6445
|
|
|
6218
6446
|
// src/translator/util/is-only-child-in-parent.ts
|
|
@@ -6224,7 +6452,7 @@ function getOnlyChildParentTagName(tag, branchSize = 1) {
|
|
|
6224
6452
|
return extra[kOnlyChildInParent];
|
|
6225
6453
|
}
|
|
6226
6454
|
const parentTag = getParentTag(tag);
|
|
6227
|
-
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;
|
|
6228
6456
|
}
|
|
6229
6457
|
function getOptimizedOnlyChildNodeBinding(tag, section, branchSize = 1) {
|
|
6230
6458
|
if (getOnlyChildParentTagName(tag, branchSize)) {
|
|
@@ -6256,8 +6484,8 @@ var for_default = {
|
|
|
6256
6484
|
isAttrTag ? 4 /* local */ : 5 /* derived */
|
|
6257
6485
|
);
|
|
6258
6486
|
let allowAttrs;
|
|
6259
|
-
(0,
|
|
6260
|
-
(0,
|
|
6487
|
+
(0, import_babel_utils23.assertNoVar)(tag);
|
|
6488
|
+
(0, import_babel_utils23.assertNoArgs)(tag);
|
|
6261
6489
|
assertNoSpreadAttrs(tag);
|
|
6262
6490
|
switch (getForType(tag.node)) {
|
|
6263
6491
|
case "of":
|
|
@@ -6280,7 +6508,7 @@ var for_default = {
|
|
|
6280
6508
|
if (!isAttrTag) {
|
|
6281
6509
|
allowAttrs.push("by");
|
|
6282
6510
|
}
|
|
6283
|
-
(0,
|
|
6511
|
+
(0, import_babel_utils23.assertAllowedAttributes)(tag, allowAttrs);
|
|
6284
6512
|
if (isAttrTag) return;
|
|
6285
6513
|
const bodySection = startSection(tagBody);
|
|
6286
6514
|
if (!bodySection) {
|
|
@@ -6348,7 +6576,7 @@ var for_default = {
|
|
|
6348
6576
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
|
6349
6577
|
const forTagHTMLRuntime = branchSerializeReason ? forTypeToHTMLResumeRuntime(forType) : forTypeToRuntime(forType);
|
|
6350
6578
|
forTagArgs.push(
|
|
6351
|
-
|
|
6579
|
+
import_compiler35.types.arrowFunctionExpression(params, import_compiler35.types.blockStatement(bodyStatements))
|
|
6352
6580
|
);
|
|
6353
6581
|
if (branchSerializeReason) {
|
|
6354
6582
|
const skipParentEnd = onlyChildParentTagName && markerSerializeReason;
|
|
@@ -6363,7 +6591,7 @@ var for_default = {
|
|
|
6363
6591
|
!statefulSerializeArg
|
|
6364
6592
|
);
|
|
6365
6593
|
forTagArgs.push(
|
|
6366
|
-
forAttrs.by ||
|
|
6594
|
+
forAttrs.by || import_compiler35.types.numericLiteral(0),
|
|
6367
6595
|
getScopeIdIdentifier(tagSection),
|
|
6368
6596
|
getScopeAccessorLiteral(nodeBinding),
|
|
6369
6597
|
getSerializeGuard(
|
|
@@ -6376,17 +6604,17 @@ var for_default = {
|
|
|
6376
6604
|
);
|
|
6377
6605
|
if (skipParentEnd) {
|
|
6378
6606
|
getParentTag(tag).node.extra[kSkipEndTag] = true;
|
|
6379
|
-
forTagArgs.push(
|
|
6607
|
+
forTagArgs.push(import_compiler35.types.stringLiteral(`</${onlyChildParentTagName}>`));
|
|
6380
6608
|
}
|
|
6381
6609
|
if (singleChild) {
|
|
6382
6610
|
if (!skipParentEnd) {
|
|
6383
|
-
forTagArgs.push(
|
|
6611
|
+
forTagArgs.push(import_compiler35.types.numericLiteral(0));
|
|
6384
6612
|
}
|
|
6385
|
-
forTagArgs.push(
|
|
6613
|
+
forTagArgs.push(import_compiler35.types.numericLiteral(1));
|
|
6386
6614
|
}
|
|
6387
6615
|
}
|
|
6388
6616
|
statements.push(
|
|
6389
|
-
|
|
6617
|
+
import_compiler35.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
|
6390
6618
|
);
|
|
6391
6619
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
6392
6620
|
replacement.skip();
|
|
@@ -6444,7 +6672,7 @@ var for_default = {
|
|
|
6444
6672
|
tagSection,
|
|
6445
6673
|
referencedBindings,
|
|
6446
6674
|
signal,
|
|
6447
|
-
|
|
6675
|
+
import_compiler35.types.arrayExpression(loopArgs)
|
|
6448
6676
|
);
|
|
6449
6677
|
tag.remove();
|
|
6450
6678
|
}
|
|
@@ -6522,11 +6750,11 @@ var for_default = {
|
|
|
6522
6750
|
]
|
|
6523
6751
|
};
|
|
6524
6752
|
function buildForRuntimeCall(type, attrs, params, statements) {
|
|
6525
|
-
return
|
|
6753
|
+
return import_compiler35.types.expressionStatement(
|
|
6526
6754
|
callRuntime(
|
|
6527
6755
|
forTypeToRuntime(type),
|
|
6528
6756
|
...getBaseArgsInForTag(type, attrs),
|
|
6529
|
-
|
|
6757
|
+
import_compiler35.types.arrowFunctionExpression(params, import_compiler35.types.blockStatement(statements))
|
|
6530
6758
|
)
|
|
6531
6759
|
);
|
|
6532
6760
|
}
|
|
@@ -6588,14 +6816,14 @@ function getBaseArgsInForTag(type, attrs) {
|
|
|
6588
6816
|
case "to":
|
|
6589
6817
|
return [
|
|
6590
6818
|
attrs.to,
|
|
6591
|
-
attrs.from ||
|
|
6592
|
-
attrs.step ||
|
|
6819
|
+
attrs.from || import_compiler35.types.numericLiteral(0),
|
|
6820
|
+
attrs.step || import_compiler35.types.numericLiteral(1)
|
|
6593
6821
|
];
|
|
6594
6822
|
case "until":
|
|
6595
6823
|
return [
|
|
6596
6824
|
attrs.until,
|
|
6597
|
-
attrs.from ||
|
|
6598
|
-
attrs.step ||
|
|
6825
|
+
attrs.from || import_compiler35.types.numericLiteral(0),
|
|
6826
|
+
attrs.step || import_compiler35.types.numericLiteral(1)
|
|
6599
6827
|
];
|
|
6600
6828
|
}
|
|
6601
6829
|
}
|
|
@@ -6614,8 +6842,8 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6614
6842
|
seen.add(attrTagMeta.name);
|
|
6615
6843
|
if (attrTagMeta.dynamic) {
|
|
6616
6844
|
statements.push(
|
|
6617
|
-
|
|
6618
|
-
|
|
6845
|
+
import_compiler36.types.variableDeclaration("let", [
|
|
6846
|
+
import_compiler36.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
|
|
6619
6847
|
])
|
|
6620
6848
|
);
|
|
6621
6849
|
properties.push(
|
|
@@ -6631,7 +6859,7 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6631
6859
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
6632
6860
|
const child = attrTags2[i];
|
|
6633
6861
|
if (child.isMarkoTag()) {
|
|
6634
|
-
if ((0,
|
|
6862
|
+
if ((0, import_babel_utils24.isAttributeTag)(child)) {
|
|
6635
6863
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
6636
6864
|
if (attrTagMeta.dynamic) {
|
|
6637
6865
|
i = addDynamicAttrTagStatements(
|
|
@@ -6697,8 +6925,8 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6697
6925
|
if (!seen.has(contentKey) && usesExport(templateExports, contentKey)) {
|
|
6698
6926
|
const contentExpression = buildContent(tag.get("body"));
|
|
6699
6927
|
if (contentExpression) {
|
|
6700
|
-
const contentProp =
|
|
6701
|
-
|
|
6928
|
+
const contentProp = import_compiler36.types.objectProperty(
|
|
6929
|
+
import_compiler36.types.identifier(contentKey),
|
|
6702
6930
|
contentExpression
|
|
6703
6931
|
);
|
|
6704
6932
|
seen.add(contentKey);
|
|
@@ -6710,8 +6938,8 @@ function translateAttrs(tag, propTree, skip2, statements = [], contentKey = "con
|
|
|
6710
6938
|
for (let i = attributes.length; i--; ) {
|
|
6711
6939
|
const attr = attributes[i];
|
|
6712
6940
|
const { value } = attr;
|
|
6713
|
-
if (
|
|
6714
|
-
properties.push(
|
|
6941
|
+
if (import_compiler36.types.isMarkoSpreadAttribute(attr)) {
|
|
6942
|
+
properties.push(import_compiler36.types.spreadElement(value));
|
|
6715
6943
|
} else if (!seen.has(attr.name) && usesExport(templateExports, attr.name)) {
|
|
6716
6944
|
seen.add(attr.name);
|
|
6717
6945
|
properties.push(toObjectProperty(attr.name, value));
|
|
@@ -6730,7 +6958,7 @@ function getTranslatedBodyContentProperty(props) {
|
|
|
6730
6958
|
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, templateExports, contentKey = "content") {
|
|
6731
6959
|
const tag = attrTags2[index];
|
|
6732
6960
|
if (tag.isMarkoTag()) {
|
|
6733
|
-
if ((0,
|
|
6961
|
+
if ((0, import_babel_utils24.isAttributeTag)(tag)) {
|
|
6734
6962
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
|
6735
6963
|
if (usesExport(templateExports, attrTagMeta.name) && attrTagMeta.dynamic) {
|
|
6736
6964
|
const translatedAttrTag = translateAttrs(
|
|
@@ -6742,8 +6970,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6742
6970
|
);
|
|
6743
6971
|
if (attrTagMeta.repeated) {
|
|
6744
6972
|
statements.push(
|
|
6745
|
-
|
|
6746
|
-
|
|
6973
|
+
import_compiler36.types.expressionStatement(
|
|
6974
|
+
import_compiler36.types.assignmentExpression(
|
|
6747
6975
|
"=",
|
|
6748
6976
|
getAttrTagIdentifier(attrTagMeta),
|
|
6749
6977
|
callRuntime(
|
|
@@ -6756,8 +6984,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6756
6984
|
);
|
|
6757
6985
|
} else {
|
|
6758
6986
|
statements.push(
|
|
6759
|
-
|
|
6760
|
-
|
|
6987
|
+
import_compiler36.types.expressionStatement(
|
|
6988
|
+
import_compiler36.types.assignmentExpression(
|
|
6761
6989
|
"=",
|
|
6762
6990
|
getAttrTagIdentifier(attrTagMeta),
|
|
6763
6991
|
callRuntime(
|
|
@@ -6796,7 +7024,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
|
6796
7024
|
return index;
|
|
6797
7025
|
}
|
|
6798
7026
|
function propsToExpression(props) {
|
|
6799
|
-
return props.length === 1 &&
|
|
7027
|
+
return props.length === 1 && import_compiler36.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler36.types.objectExpression(props);
|
|
6800
7028
|
}
|
|
6801
7029
|
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6802
7030
|
const forTag = attrTags2[index];
|
|
@@ -6821,9 +7049,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
|
6821
7049
|
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
|
6822
7050
|
const ifTag = attrTags2[index];
|
|
6823
7051
|
const consequentStatements = [];
|
|
6824
|
-
let ifStatement =
|
|
7052
|
+
let ifStatement = import_compiler36.types.ifStatement(
|
|
6825
7053
|
getConditionTestValue(ifTag),
|
|
6826
|
-
|
|
7054
|
+
import_compiler36.types.blockStatement(consequentStatements)
|
|
6827
7055
|
);
|
|
6828
7056
|
statements.push(ifStatement);
|
|
6829
7057
|
addAllAttrTagsAsDynamic(
|
|
@@ -6850,14 +7078,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
|
6850
7078
|
contentKey
|
|
6851
7079
|
);
|
|
6852
7080
|
if (testValue) {
|
|
6853
|
-
ifStatement.alternate = ifStatement =
|
|
7081
|
+
ifStatement.alternate = ifStatement = import_compiler36.types.ifStatement(
|
|
6854
7082
|
testValue,
|
|
6855
|
-
|
|
7083
|
+
import_compiler36.types.blockStatement(alternateStatements)
|
|
6856
7084
|
);
|
|
6857
7085
|
nextIndex++;
|
|
6858
7086
|
continue;
|
|
6859
7087
|
} else {
|
|
6860
|
-
ifStatement.alternate =
|
|
7088
|
+
ifStatement.alternate = import_compiler36.types.blockStatement(alternateStatements);
|
|
6861
7089
|
break;
|
|
6862
7090
|
}
|
|
6863
7091
|
}
|
|
@@ -6923,9 +7151,9 @@ function buildContent(body) {
|
|
|
6923
7151
|
}
|
|
6924
7152
|
if (dynamicSerializeReason) {
|
|
6925
7153
|
body.node.body.unshift(
|
|
6926
|
-
|
|
6927
|
-
|
|
6928
|
-
|
|
7154
|
+
import_compiler36.types.variableDeclaration("const", [
|
|
7155
|
+
import_compiler36.types.variableDeclarator(
|
|
7156
|
+
import_compiler36.types.identifier(
|
|
6929
7157
|
getSharedUid(`scope${bodySection.id}_reason`, bodySection)
|
|
6930
7158
|
),
|
|
6931
7159
|
callRuntime("_scope_reason")
|
|
@@ -6935,10 +7163,10 @@ function buildContent(body) {
|
|
|
6935
7163
|
}
|
|
6936
7164
|
return callRuntime(
|
|
6937
7165
|
serialized ? "_content_resume" : "_content",
|
|
6938
|
-
|
|
6939
|
-
|
|
7166
|
+
import_compiler36.types.stringLiteral(getResumeRegisterId(bodySection, "content")),
|
|
7167
|
+
import_compiler36.types.arrowFunctionExpression(
|
|
6940
7168
|
body.node.params,
|
|
6941
|
-
|
|
7169
|
+
import_compiler36.types.blockStatement(body.node.body)
|
|
6942
7170
|
),
|
|
6943
7171
|
serialized ? getScopeIdIdentifier(
|
|
6944
7172
|
getSection(
|
|
@@ -6949,17 +7177,17 @@ function buildContent(body) {
|
|
|
6949
7177
|
) : void 0
|
|
6950
7178
|
);
|
|
6951
7179
|
} else {
|
|
6952
|
-
return
|
|
6953
|
-
|
|
7180
|
+
return import_compiler36.types.callExpression(
|
|
7181
|
+
import_compiler36.types.identifier(bodySection.name),
|
|
6954
7182
|
bodySection.referencedLocalClosures ? [
|
|
6955
7183
|
scopeIdentifier,
|
|
6956
|
-
|
|
7184
|
+
import_compiler36.types.objectExpression(
|
|
6957
7185
|
toArray(bodySection.referencedLocalClosures, (ref) => {
|
|
6958
7186
|
const accessor = getScopeAccessor(ref, true);
|
|
6959
7187
|
const isShorthand = accessor === ref.name;
|
|
6960
|
-
return
|
|
7188
|
+
return import_compiler36.types.objectProperty(
|
|
6961
7189
|
toPropertyName(accessor),
|
|
6962
|
-
|
|
7190
|
+
import_compiler36.types.identifier(ref.name),
|
|
6963
7191
|
false,
|
|
6964
7192
|
isShorthand
|
|
6965
7193
|
);
|
|
@@ -7044,8 +7272,8 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7044
7272
|
if (childScopeSerializeReason) {
|
|
7045
7273
|
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
|
7046
7274
|
tag.insertBefore(
|
|
7047
|
-
|
|
7048
|
-
|
|
7275
|
+
import_compiler37.types.variableDeclaration("const", [
|
|
7276
|
+
import_compiler37.types.variableDeclarator(peekScopeId, callRuntime("_peek_scope_id"))
|
|
7049
7277
|
])
|
|
7050
7278
|
);
|
|
7051
7279
|
setBindingSerializedValue(
|
|
@@ -7055,13 +7283,13 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7055
7283
|
);
|
|
7056
7284
|
if (tagVar) {
|
|
7057
7285
|
statements.push(
|
|
7058
|
-
|
|
7286
|
+
import_compiler37.types.expressionStatement(
|
|
7059
7287
|
callRuntime(
|
|
7060
7288
|
"_var",
|
|
7061
7289
|
getScopeIdIdentifier(section),
|
|
7062
7290
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
|
7063
7291
|
peekScopeId,
|
|
7064
|
-
|
|
7292
|
+
import_compiler37.types.stringLiteral(
|
|
7065
7293
|
getResumeRegisterId(
|
|
7066
7294
|
section,
|
|
7067
7295
|
node.var.extra?.binding,
|
|
@@ -7090,9 +7318,9 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7090
7318
|
if (reason) {
|
|
7091
7319
|
hasDynamicReasons ||= reason !== true && !reason.state;
|
|
7092
7320
|
props.push(
|
|
7093
|
-
|
|
7321
|
+
import_compiler37.types.objectProperty(
|
|
7094
7322
|
withLeadingComment(
|
|
7095
|
-
|
|
7323
|
+
import_compiler37.types.numericLiteral(i),
|
|
7096
7324
|
getDebugNames(group.reason)
|
|
7097
7325
|
),
|
|
7098
7326
|
getSerializeGuard(section, reason, false)
|
|
@@ -7103,12 +7331,12 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7103
7331
|
}
|
|
7104
7332
|
}
|
|
7105
7333
|
if (props.length) {
|
|
7106
|
-
childSerializeReasonExpr = hasDynamicReasons || hasSkippedReasons ?
|
|
7334
|
+
childSerializeReasonExpr = hasDynamicReasons || hasSkippedReasons ? import_compiler37.types.objectExpression(props) : import_compiler37.types.numericLiteral(1);
|
|
7107
7335
|
}
|
|
7108
7336
|
}
|
|
7109
7337
|
if (childSerializeReasonExpr) {
|
|
7110
7338
|
tag.insertBefore(
|
|
7111
|
-
|
|
7339
|
+
import_compiler37.types.expressionStatement(
|
|
7112
7340
|
callRuntime("_set_serialize_reason", childSerializeReasonExpr)
|
|
7113
7341
|
)
|
|
7114
7342
|
);
|
|
@@ -7124,39 +7352,7 @@ function knownTagTranslateHTML(tag, tagIdentifier, contentSection, propTree) {
|
|
|
7124
7352
|
}
|
|
7125
7353
|
return renderArgs;
|
|
7126
7354
|
};
|
|
7127
|
-
if (
|
|
7128
|
-
const contentProp = getTranslatedBodyContentProperty(properties);
|
|
7129
|
-
let contentId = void 0;
|
|
7130
|
-
if (contentProp) {
|
|
7131
|
-
const contentExpression = contentProp.value;
|
|
7132
|
-
contentProp.value = contentId = generateUidIdentifier("content");
|
|
7133
|
-
const [contentPath] = tag.insertBefore(
|
|
7134
|
-
import_compiler34.types.variableDeclaration("const", [
|
|
7135
|
-
import_compiler34.types.variableDeclarator(
|
|
7136
|
-
contentId,
|
|
7137
|
-
// TODO: only register if needed (child template analysis)
|
|
7138
|
-
contentExpression
|
|
7139
|
-
)
|
|
7140
|
-
])
|
|
7141
|
-
);
|
|
7142
|
-
contentPath.skip();
|
|
7143
|
-
}
|
|
7144
|
-
let renderTagExpr = callExpression(
|
|
7145
|
-
tagIdentifier,
|
|
7146
|
-
...getArgs()
|
|
7147
|
-
);
|
|
7148
|
-
if (tagVar) {
|
|
7149
|
-
translateVar(tag, import_compiler34.types.unaryExpression("void", import_compiler34.types.numericLiteral(0)), "let");
|
|
7150
|
-
renderTagExpr = import_compiler34.types.assignmentExpression("=", tagVar, renderTagExpr);
|
|
7151
|
-
}
|
|
7152
|
-
statements.push(
|
|
7153
|
-
import_compiler34.types.ifStatement(
|
|
7154
|
-
tagIdentifier,
|
|
7155
|
-
import_compiler34.types.expressionStatement(renderTagExpr),
|
|
7156
|
-
contentId && callStatement(contentId)
|
|
7157
|
-
)
|
|
7158
|
-
);
|
|
7159
|
-
} else if (tagVar) {
|
|
7355
|
+
if (tagVar) {
|
|
7160
7356
|
translateVar(tag, callExpression(tagIdentifier, ...getArgs()), "let");
|
|
7161
7357
|
} else {
|
|
7162
7358
|
statements.push(callStatement(tagIdentifier, ...getArgs()));
|
|
@@ -7183,15 +7379,15 @@ function knownTagTranslateDOM(tag, propTree, getBindingIdentifier, callSetup) {
|
|
|
7183
7379
|
value
|
|
7184
7380
|
];
|
|
7185
7381
|
if (!isOptimize()) {
|
|
7186
|
-
changeArgs.push(
|
|
7382
|
+
changeArgs.push(import_compiler37.types.stringLiteral(varBinding.name));
|
|
7187
7383
|
}
|
|
7188
|
-
return
|
|
7384
|
+
return import_compiler37.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
7189
7385
|
};
|
|
7190
7386
|
addStatement(
|
|
7191
7387
|
"render",
|
|
7192
7388
|
tagSection,
|
|
7193
7389
|
void 0,
|
|
7194
|
-
|
|
7390
|
+
import_compiler37.types.expressionStatement(
|
|
7195
7391
|
callRuntime(
|
|
7196
7392
|
"_var",
|
|
7197
7393
|
scopeIdentifier,
|
|
@@ -7236,7 +7432,7 @@ function analyzeParams(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7236
7432
|
dropReferences(getAllTagReferenceNodes(tag.node));
|
|
7237
7433
|
return inputExpr;
|
|
7238
7434
|
}
|
|
7239
|
-
if (!propTree.props || tag.node.arguments?.some((node) =>
|
|
7435
|
+
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
7240
7436
|
const extra = inputExpr.value = mergeReferences(
|
|
7241
7437
|
section,
|
|
7242
7438
|
tag.node,
|
|
@@ -7311,7 +7507,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7311
7507
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
7312
7508
|
for (const child of attrTags2) {
|
|
7313
7509
|
if (child.isMarkoTag()) {
|
|
7314
|
-
if ((0,
|
|
7510
|
+
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
7315
7511
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7316
7512
|
const childAttrExports = propTree.props[attrTagMeta.name];
|
|
7317
7513
|
if (childAttrExports) {
|
|
@@ -7387,7 +7583,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7387
7583
|
let spreadReferenceNodes;
|
|
7388
7584
|
for (let i = attributes.length; i--; ) {
|
|
7389
7585
|
const attr = attributes[i];
|
|
7390
|
-
if (
|
|
7586
|
+
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
7391
7587
|
const templateExportAttr = propTree.props[attr.name];
|
|
7392
7588
|
if (!templateExportAttr || seen.has(attr.name)) {
|
|
7393
7589
|
unknownReferences.push(attr.value);
|
|
@@ -7401,7 +7597,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7401
7597
|
}
|
|
7402
7598
|
if (spreadReferenceNodes) {
|
|
7403
7599
|
spreadReferenceNodes.push(attr.value);
|
|
7404
|
-
} else if (
|
|
7600
|
+
} else if (import_compiler37.types.isMarkoSpreadAttribute(attr)) {
|
|
7405
7601
|
spreadReferenceNodes = [attr.value];
|
|
7406
7602
|
} else {
|
|
7407
7603
|
const attrValueExtra = attr.value.extra ??= {};
|
|
@@ -7443,7 +7639,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7443
7639
|
return inputExpr;
|
|
7444
7640
|
}
|
|
7445
7641
|
function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
7446
|
-
if (!propTree.props || tag.node.arguments?.some((node) =>
|
|
7642
|
+
if (!propTree.props || tag.node.arguments?.some((node) => import_compiler37.types.isSpreadElement(node))) {
|
|
7447
7643
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
|
7448
7644
|
const tagInputIdentifier = info.getBindingIdentifier(
|
|
7449
7645
|
propTree.binding,
|
|
@@ -7471,8 +7667,8 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7471
7667
|
"render",
|
|
7472
7668
|
info.tagSection,
|
|
7473
7669
|
referencedBindings,
|
|
7474
|
-
|
|
7475
|
-
|
|
7670
|
+
import_compiler37.types.expressionStatement(
|
|
7671
|
+
import_compiler37.types.callExpression(tagInputIdentifier, [import_compiler37.types.arrayExpression(renderArgs)])
|
|
7476
7672
|
)
|
|
7477
7673
|
);
|
|
7478
7674
|
return;
|
|
@@ -7491,8 +7687,8 @@ function writeParamsToSignals(tag, propTree, importAlias, info) {
|
|
|
7491
7687
|
info.tagSection,
|
|
7492
7688
|
arg.extra?.referencedBindings,
|
|
7493
7689
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7494
|
-
|
|
7495
|
-
|
|
7690
|
+
import_compiler37.types.expressionStatement(
|
|
7691
|
+
import_compiler37.types.callExpression(argExportIdentifier, [
|
|
7496
7692
|
createScopeReadExpression(
|
|
7497
7693
|
info.childScopeBinding,
|
|
7498
7694
|
info.tagSection
|
|
@@ -7544,7 +7740,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7544
7740
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
7545
7741
|
const child = attrTags2[i];
|
|
7546
7742
|
if (child.isMarkoTag()) {
|
|
7547
|
-
if ((0,
|
|
7743
|
+
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
7548
7744
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7549
7745
|
const childAttrExport = propTree.props[attrTagMeta.name];
|
|
7550
7746
|
if (childAttrExport) {
|
|
@@ -7580,17 +7776,17 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7580
7776
|
childAttrExports.binding,
|
|
7581
7777
|
`${importAlias}_${attrTagMeta.name}`
|
|
7582
7778
|
);
|
|
7583
|
-
decls.push(
|
|
7779
|
+
decls.push(import_compiler37.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
|
7584
7780
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
7585
|
-
|
|
7781
|
+
import_compiler37.types.variableDeclaration("let", decls),
|
|
7586
7782
|
...statements
|
|
7587
7783
|
]);
|
|
7588
7784
|
addStatement(
|
|
7589
7785
|
"render",
|
|
7590
7786
|
info.tagSection,
|
|
7591
7787
|
referencedBindings,
|
|
7592
|
-
|
|
7593
|
-
|
|
7788
|
+
import_compiler37.types.expressionStatement(
|
|
7789
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
7594
7790
|
createScopeReadExpression(
|
|
7595
7791
|
info.childScopeBinding,
|
|
7596
7792
|
info.tagSection
|
|
@@ -7615,13 +7811,13 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7615
7811
|
info.tagSection,
|
|
7616
7812
|
void 0,
|
|
7617
7813
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
|
7618
|
-
|
|
7619
|
-
|
|
7814
|
+
import_compiler37.types.expressionStatement(
|
|
7815
|
+
import_compiler37.types.callExpression(contentExportIdentifier, [
|
|
7620
7816
|
createScopeReadExpression(
|
|
7621
7817
|
info.childScopeBinding,
|
|
7622
7818
|
info.tagSection
|
|
7623
7819
|
),
|
|
7624
|
-
|
|
7820
|
+
import_compiler37.types.callExpression(import_compiler37.types.identifier(bodySection.name), [
|
|
7625
7821
|
scopeIdentifier
|
|
7626
7822
|
])
|
|
7627
7823
|
])
|
|
@@ -7634,7 +7830,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7634
7830
|
let spreadProps;
|
|
7635
7831
|
for (let i = attributes.length; i--; ) {
|
|
7636
7832
|
const attr = attributes[i];
|
|
7637
|
-
if (
|
|
7833
|
+
if (import_compiler37.types.isMarkoAttribute(attr)) {
|
|
7638
7834
|
const childAttrExports = propTree.props[attr.name];
|
|
7639
7835
|
if (!childAttrExports || seen.has(attr.name)) continue;
|
|
7640
7836
|
if (spreadProps) {
|
|
@@ -7644,9 +7840,9 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7644
7840
|
seen.add(attr.name);
|
|
7645
7841
|
staticAttrs.push(attr);
|
|
7646
7842
|
} else if (spreadProps) {
|
|
7647
|
-
spreadProps.push(
|
|
7843
|
+
spreadProps.push(import_compiler37.types.spreadElement(attr.value));
|
|
7648
7844
|
} else {
|
|
7649
|
-
spreadProps = [
|
|
7845
|
+
spreadProps = [import_compiler37.types.spreadElement(attr.value)];
|
|
7650
7846
|
}
|
|
7651
7847
|
}
|
|
7652
7848
|
for (const attr of staticAttrs.reverse()) {
|
|
@@ -7659,8 +7855,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7659
7855
|
"render",
|
|
7660
7856
|
info.tagSection,
|
|
7661
7857
|
attr.value.extra?.referencedBindings,
|
|
7662
|
-
|
|
7663
|
-
|
|
7858
|
+
import_compiler37.types.expressionStatement(
|
|
7859
|
+
import_compiler37.types.callExpression(attrExportIdentifier, [
|
|
7664
7860
|
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7665
7861
|
attr.value
|
|
7666
7862
|
])
|
|
@@ -7680,11 +7876,11 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7680
7876
|
} else {
|
|
7681
7877
|
spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
|
7682
7878
|
if (translatedAttrs) {
|
|
7683
|
-
translatedAttrs.properties = [
|
|
7879
|
+
translatedAttrs.properties = [import_compiler37.types.spreadElement(spreadId)];
|
|
7684
7880
|
}
|
|
7685
7881
|
addStatement("render", info.tagSection, referencedBindings, [
|
|
7686
|
-
|
|
7687
|
-
|
|
7882
|
+
import_compiler37.types.variableDeclaration("const", [
|
|
7883
|
+
import_compiler37.types.variableDeclarator(spreadId, spreadExpr)
|
|
7688
7884
|
])
|
|
7689
7885
|
]);
|
|
7690
7886
|
}
|
|
@@ -7699,15 +7895,15 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7699
7895
|
"render",
|
|
7700
7896
|
info.tagSection,
|
|
7701
7897
|
referencedBindings,
|
|
7702
|
-
|
|
7703
|
-
|
|
7898
|
+
import_compiler37.types.expressionStatement(
|
|
7899
|
+
import_compiler37.types.callExpression(
|
|
7704
7900
|
attrExportIdentifier,
|
|
7705
7901
|
spreadId ? [
|
|
7706
7902
|
createScopeReadExpression(
|
|
7707
7903
|
info.childScopeBinding,
|
|
7708
7904
|
info.tagSection
|
|
7709
7905
|
),
|
|
7710
|
-
toMemberExpression(
|
|
7906
|
+
toMemberExpression(import_compiler37.types.cloneNode(spreadId, true), name2)
|
|
7711
7907
|
] : [
|
|
7712
7908
|
createScopeReadExpression(
|
|
7713
7909
|
info.childScopeBinding,
|
|
@@ -7747,12 +7943,12 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7747
7943
|
let translatedProps = propsToExpression(translatedAttrs.properties);
|
|
7748
7944
|
if (propTree.rest && spreadId) {
|
|
7749
7945
|
const props = [];
|
|
7750
|
-
const restId =
|
|
7946
|
+
const restId = import_compiler37.types.identifier(propTree.rest.binding.name);
|
|
7751
7947
|
forEach(propTree.rest.binding.excludeProperties, (name2) => {
|
|
7752
7948
|
const propId = toPropertyName(name2);
|
|
7753
|
-
const shorthand = propId.type === "Identifier" &&
|
|
7949
|
+
const shorthand = propId.type === "Identifier" && import_compiler37.types.isValidIdentifier(name2);
|
|
7754
7950
|
props.push(
|
|
7755
|
-
|
|
7951
|
+
import_compiler37.types.objectProperty(
|
|
7756
7952
|
propId,
|
|
7757
7953
|
shorthand ? propId : generateUidIdentifier(name2),
|
|
7758
7954
|
false,
|
|
@@ -7760,13 +7956,13 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7760
7956
|
)
|
|
7761
7957
|
);
|
|
7762
7958
|
});
|
|
7763
|
-
props.push(
|
|
7764
|
-
translatedProps =
|
|
7765
|
-
|
|
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),
|
|
7766
7962
|
[spreadId]
|
|
7767
7963
|
);
|
|
7768
7964
|
}
|
|
7769
|
-
if ((0,
|
|
7965
|
+
if ((0, import_babel_utils25.isAttributeTag)(tag)) {
|
|
7770
7966
|
const attrTagName = getTagName(tag);
|
|
7771
7967
|
const parentTag = tag.parentPath;
|
|
7772
7968
|
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
|
@@ -7791,7 +7987,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7791
7987
|
} else {
|
|
7792
7988
|
attrTagCallsForTag.set(
|
|
7793
7989
|
attrTagName,
|
|
7794
|
-
translatedProps =
|
|
7990
|
+
translatedProps = import_compiler37.types.parenthesizedExpression(
|
|
7795
7991
|
callRuntime("attrTag", translatedProps)
|
|
7796
7992
|
)
|
|
7797
7993
|
);
|
|
@@ -7804,8 +8000,8 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
7804
8000
|
"render",
|
|
7805
8001
|
info.tagSection,
|
|
7806
8002
|
referencedBindings,
|
|
7807
|
-
|
|
7808
|
-
|
|
8003
|
+
import_compiler37.types.expressionStatement(
|
|
8004
|
+
import_compiler37.types.callExpression(tagInputIdentifier, [
|
|
7809
8005
|
createScopeReadExpression(info.childScopeBinding, info.tagSection),
|
|
7810
8006
|
translatedProps
|
|
7811
8007
|
])
|
|
@@ -7840,10 +8036,10 @@ function mapParamReasonToExpr(exprs, reason) {
|
|
|
7840
8036
|
}
|
|
7841
8037
|
}
|
|
7842
8038
|
function callStatement(id, ...args) {
|
|
7843
|
-
return
|
|
8039
|
+
return import_compiler37.types.expressionStatement(callExpression(id, ...args));
|
|
7844
8040
|
}
|
|
7845
8041
|
function callExpression(id, ...args) {
|
|
7846
|
-
return
|
|
8042
|
+
return import_compiler37.types.callExpression(id, args.filter(Boolean));
|
|
7847
8043
|
}
|
|
7848
8044
|
function isSimpleReference(expr) {
|
|
7849
8045
|
switch (expr.type) {
|
|
@@ -7906,7 +8102,7 @@ function trackDomVarReferences(tag, binding) {
|
|
|
7906
8102
|
if (!tagVar) {
|
|
7907
8103
|
return;
|
|
7908
8104
|
}
|
|
7909
|
-
if (!
|
|
8105
|
+
if (!import_compiler38.types.isIdentifier(tagVar)) {
|
|
7910
8106
|
throw tag.get("var").buildCodeFrameError(
|
|
7911
8107
|
"Tag variables on native elements cannot be destructured."
|
|
7912
8108
|
);
|
|
@@ -8006,7 +8202,7 @@ function trackParamsReferences(body, type, upstreamAlias) {
|
|
|
8006
8202
|
void 0,
|
|
8007
8203
|
i > 0 ? addNumericPropertiesUntil(void 0, i - 1) : void 0
|
|
8008
8204
|
);
|
|
8009
|
-
} else if (
|
|
8205
|
+
} else if (import_compiler38.types.isLVal(param)) {
|
|
8010
8206
|
createBindingsAndTrackReferences(
|
|
8011
8207
|
param,
|
|
8012
8208
|
type,
|
|
@@ -8211,7 +8407,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
8211
8407
|
if (hasRest) {
|
|
8212
8408
|
excludeProperties = propsUtil.add(excludeProperties, key);
|
|
8213
8409
|
}
|
|
8214
|
-
if (
|
|
8410
|
+
if (import_compiler38.types.isLVal(prop.value)) {
|
|
8215
8411
|
createBindingsAndTrackReferences(
|
|
8216
8412
|
prop.value,
|
|
8217
8413
|
type,
|
|
@@ -8251,7 +8447,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
|
8251
8447
|
property,
|
|
8252
8448
|
excludeProperties
|
|
8253
8449
|
);
|
|
8254
|
-
} else if (
|
|
8450
|
+
} else if (import_compiler38.types.isLVal(element)) {
|
|
8255
8451
|
createBindingsAndTrackReferences(
|
|
8256
8452
|
element,
|
|
8257
8453
|
type,
|
|
@@ -8274,7 +8470,7 @@ function trackReference(referencePath, binding) {
|
|
|
8274
8470
|
let propPath = binding.name;
|
|
8275
8471
|
while (true) {
|
|
8276
8472
|
const { parent } = root;
|
|
8277
|
-
if (!
|
|
8473
|
+
if (!import_compiler38.types.isMemberExpression(parent) && !import_compiler38.types.isOptionalMemberExpression(parent))
|
|
8278
8474
|
break;
|
|
8279
8475
|
const prop = getMemberExpressionPropString(parent);
|
|
8280
8476
|
if (prop === void 0) break;
|
|
@@ -8615,7 +8811,7 @@ function finalizeReferences() {
|
|
|
8615
8811
|
});
|
|
8616
8812
|
}
|
|
8617
8813
|
});
|
|
8618
|
-
const programExtra = (0,
|
|
8814
|
+
const programExtra = (0, import_babel_utils26.getProgram)().node.extra;
|
|
8619
8815
|
if (programExtra.returnValueExpr) {
|
|
8620
8816
|
programExtra.section.returnSerializeReason = getSerializeSourcesForExpr(
|
|
8621
8817
|
programExtra.returnValueExpr
|
|
@@ -8847,11 +9043,11 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
|
|
|
8847
9043
|
function getScopeAccessorLiteral(binding, encoded, includeId) {
|
|
8848
9044
|
const canonicalBinding = getCanonicalBinding(binding);
|
|
8849
9045
|
if (isOptimize()) {
|
|
8850
|
-
return encoded ?
|
|
9046
|
+
return encoded ? import_compiler38.types.numericLiteral(canonicalBinding.id) : import_compiler38.types.stringLiteral(decodeAccessor(canonicalBinding.id));
|
|
8851
9047
|
} else if (includeId || canonicalBinding.type === 0 /* dom */) {
|
|
8852
|
-
return
|
|
9048
|
+
return import_compiler38.types.stringLiteral(`${canonicalBinding.name}/${canonicalBinding.id}`);
|
|
8853
9049
|
}
|
|
8854
|
-
return
|
|
9050
|
+
return import_compiler38.types.stringLiteral(canonicalBinding.name);
|
|
8855
9051
|
}
|
|
8856
9052
|
function getScopeAccessor(binding, encoded, includeId) {
|
|
8857
9053
|
const canonicalBinding = getCanonicalBinding(binding);
|
|
@@ -8899,7 +9095,7 @@ function getSectionInstancesAccessor(section) {
|
|
|
8899
9095
|
}
|
|
8900
9096
|
function getSectionInstancesAccessorLiteral(section) {
|
|
8901
9097
|
const accessor = getSectionInstancesAccessor(section);
|
|
8902
|
-
return accessor ? typeof accessor === "number" ?
|
|
9098
|
+
return accessor ? typeof accessor === "number" ? import_compiler38.types.numericLiteral(accessor) : import_compiler38.types.stringLiteral(accessor) : void 0;
|
|
8903
9099
|
}
|
|
8904
9100
|
function getReadReplacement(node) {
|
|
8905
9101
|
const { extra } = node;
|
|
@@ -8912,13 +9108,13 @@ function getReadReplacement(node) {
|
|
|
8912
9108
|
if (isOutputDOM()) {
|
|
8913
9109
|
if (readBinding.type === 0 /* dom */) {
|
|
8914
9110
|
if (!extra[kIsInvoked] && readBinding.section.domGetterBindings.has(readBinding)) {
|
|
8915
|
-
replacement =
|
|
9111
|
+
replacement = import_compiler38.types.callExpression(
|
|
8916
9112
|
getBindingGetterIdentifier(readBinding),
|
|
8917
9113
|
[getScopeExpression(extra.section, readBinding.section)]
|
|
8918
9114
|
);
|
|
8919
9115
|
}
|
|
8920
9116
|
} else if (readBinding.type === 6 /* hoist */ && extra[kIsInvoked]) {
|
|
8921
|
-
replacement =
|
|
9117
|
+
replacement = import_compiler38.types.callExpression(
|
|
8922
9118
|
getBindingGetterIdentifier(readBinding),
|
|
8923
9119
|
[getScopeExpression(extra.section, readBinding.section)]
|
|
8924
9120
|
);
|
|
@@ -8927,7 +9123,7 @@ function getReadReplacement(node) {
|
|
|
8927
9123
|
}
|
|
8928
9124
|
} else {
|
|
8929
9125
|
if (node.type !== "Identifier") {
|
|
8930
|
-
replacement =
|
|
9126
|
+
replacement = import_compiler38.types.identifier(readBinding.name);
|
|
8931
9127
|
} else if (readBinding.name !== node.name && readBinding.type !== 0 /* dom */ && (readBinding.type !== 6 /* hoist */ || !extra[kIsInvoked])) {
|
|
8932
9128
|
node.name = readBinding.name;
|
|
8933
9129
|
}
|
|
@@ -8937,7 +9133,7 @@ function getReadReplacement(node) {
|
|
|
8937
9133
|
let curNode = node;
|
|
8938
9134
|
let curBinding = read.binding;
|
|
8939
9135
|
let replaceMember;
|
|
8940
|
-
replacement = isOutputDOM() ? createScopeReadExpression(read.binding, extra.section) :
|
|
9136
|
+
replacement = isOutputDOM() ? createScopeReadExpression(read.binding, extra.section) : import_compiler38.types.identifier(read.binding.name);
|
|
8941
9137
|
while (props.length && (curNode.type === "MemberExpression" || curNode.type === "OptionalMemberExpression")) {
|
|
8942
9138
|
const prop = props.pop();
|
|
8943
9139
|
const memberProp = getMemberExpressionPropString(curNode);
|
|
@@ -9153,7 +9349,7 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9153
9349
|
let reason = serializeReasonCache.get(extra);
|
|
9154
9350
|
if (reason === false) return;
|
|
9155
9351
|
if (reason === void 0) {
|
|
9156
|
-
if (extra === (0,
|
|
9352
|
+
if (extra === (0, import_babel_utils26.getProgram)().node.extra?.returnValueExpr) {
|
|
9157
9353
|
reason = true;
|
|
9158
9354
|
} else {
|
|
9159
9355
|
forEach(extra.downstream, (binding) => {
|
|
@@ -9215,10 +9411,10 @@ function addNumericPropertiesUntil(props, len) {
|
|
|
9215
9411
|
var kDOMBinding = Symbol("await tag dom binding");
|
|
9216
9412
|
var await_default = {
|
|
9217
9413
|
analyze(tag) {
|
|
9218
|
-
(0,
|
|
9219
|
-
(0,
|
|
9414
|
+
(0, import_babel_utils27.assertNoVar)(tag);
|
|
9415
|
+
(0, import_babel_utils27.assertNoArgs)(tag);
|
|
9220
9416
|
assertNoSpreadAttrs(tag);
|
|
9221
|
-
(0,
|
|
9417
|
+
(0, import_babel_utils27.assertNoAttributeTags)(tag);
|
|
9222
9418
|
const { node } = tag;
|
|
9223
9419
|
const tagBody = tag.get("body");
|
|
9224
9420
|
const section = getOrCreateSection(tag);
|
|
@@ -9230,7 +9426,7 @@ var await_default = {
|
|
|
9230
9426
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
9231
9427
|
);
|
|
9232
9428
|
}
|
|
9233
|
-
if (node.attributes.length > 1 || !
|
|
9429
|
+
if (node.attributes.length > 1 || !import_compiler39.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
|
|
9234
9430
|
throw tag.get("name").buildCodeFrameError(
|
|
9235
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)."
|
|
9236
9432
|
);
|
|
@@ -9240,7 +9436,7 @@ var await_default = {
|
|
|
9240
9436
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) requires [content](https://markojs.com/docs/reference/language#tag-content)."
|
|
9241
9437
|
);
|
|
9242
9438
|
}
|
|
9243
|
-
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]))) {
|
|
9244
9440
|
throw tag.get("name").buildCodeFrameError(
|
|
9245
9441
|
"The [`<await>` tag](https://markojs.com/docs/reference/core-tag#await) only supports a single parameter."
|
|
9246
9442
|
);
|
|
@@ -9277,13 +9473,13 @@ var await_default = {
|
|
|
9277
9473
|
flushInto(tag);
|
|
9278
9474
|
writeHTMLResumeStatements(tagBody);
|
|
9279
9475
|
tag.replaceWith(
|
|
9280
|
-
|
|
9476
|
+
import_compiler39.types.expressionStatement(
|
|
9281
9477
|
callRuntime(
|
|
9282
9478
|
"_await",
|
|
9283
9479
|
getScopeIdIdentifier(section),
|
|
9284
9480
|
getScopeAccessorLiteral(nodeRef),
|
|
9285
9481
|
valueAttr.value,
|
|
9286
|
-
|
|
9482
|
+
import_compiler39.types.arrowFunctionExpression(
|
|
9287
9483
|
node.body.params,
|
|
9288
9484
|
toFirstExpressionOrBlock(node.body.body)
|
|
9289
9485
|
),
|
|
@@ -9317,9 +9513,9 @@ var await_default = {
|
|
|
9317
9513
|
const branchRenderArgs = getBranchRendererArgs(bodySection);
|
|
9318
9514
|
const branchParams = branchRenderArgs.pop();
|
|
9319
9515
|
(signal.prependStatements ||= []).push(
|
|
9320
|
-
|
|
9321
|
-
|
|
9322
|
-
|
|
9516
|
+
import_compiler39.types.variableDeclaration("const", [
|
|
9517
|
+
import_compiler39.types.variableDeclarator(
|
|
9518
|
+
import_compiler39.types.identifier(bodySection.name),
|
|
9323
9519
|
callRuntime(
|
|
9324
9520
|
"_await_content",
|
|
9325
9521
|
getScopeAccessorLiteral(nodeRef, true),
|
|
@@ -9338,8 +9534,8 @@ var await_default = {
|
|
|
9338
9534
|
"render",
|
|
9339
9535
|
section,
|
|
9340
9536
|
void 0,
|
|
9341
|
-
|
|
9342
|
-
|
|
9537
|
+
import_compiler39.types.expressionStatement(
|
|
9538
|
+
import_compiler39.types.callExpression(import_compiler39.types.identifier(bodySection.name), [scopeIdentifier])
|
|
9343
9539
|
)
|
|
9344
9540
|
);
|
|
9345
9541
|
addValue(
|
|
@@ -9363,8 +9559,8 @@ var await_default = {
|
|
|
9363
9559
|
};
|
|
9364
9560
|
|
|
9365
9561
|
// src/translator/core/client.ts
|
|
9366
|
-
var
|
|
9367
|
-
var
|
|
9562
|
+
var import_compiler40 = require("@marko/compiler");
|
|
9563
|
+
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
|
9368
9564
|
var client_default = {
|
|
9369
9565
|
parse(tag) {
|
|
9370
9566
|
const {
|
|
@@ -9374,11 +9570,11 @@ var client_default = {
|
|
|
9374
9570
|
const rawValue = node.rawValue;
|
|
9375
9571
|
const code = rawValue.replace(/^client\s*/, "");
|
|
9376
9572
|
const start = node.start + (rawValue.length - code.length);
|
|
9377
|
-
let body = (0,
|
|
9378
|
-
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])) {
|
|
9379
9575
|
body = body[0].body;
|
|
9380
9576
|
}
|
|
9381
|
-
tag.replaceWith(
|
|
9577
|
+
tag.replaceWith(import_compiler40.types.markoScriptlet(body, true, "client"));
|
|
9382
9578
|
},
|
|
9383
9579
|
parseOptions: {
|
|
9384
9580
|
statement: true,
|
|
@@ -9394,12 +9590,12 @@ var client_default = {
|
|
|
9394
9590
|
};
|
|
9395
9591
|
|
|
9396
9592
|
// src/translator/core/const.ts
|
|
9397
|
-
var
|
|
9398
|
-
var
|
|
9593
|
+
var import_compiler41 = require("@marko/compiler");
|
|
9594
|
+
var import_babel_utils29 = require("@marko/compiler/babel-utils");
|
|
9399
9595
|
var const_default = {
|
|
9400
9596
|
analyze(tag) {
|
|
9401
|
-
(0,
|
|
9402
|
-
(0,
|
|
9597
|
+
(0, import_babel_utils29.assertNoArgs)(tag);
|
|
9598
|
+
(0, import_babel_utils29.assertNoParams)(tag);
|
|
9403
9599
|
assertNoBodyContent(tag);
|
|
9404
9600
|
const { node } = tag;
|
|
9405
9601
|
const [valueAttr] = node.attributes;
|
|
@@ -9413,13 +9609,13 @@ var const_default = {
|
|
|
9413
9609
|
"The [`<const>` tag](https://markojs.com/docs/reference/core-tag#const) requires a [`value=` attribute](https://markojs.com/docs/reference/language#shorthand-value)."
|
|
9414
9610
|
);
|
|
9415
9611
|
}
|
|
9416
|
-
if (node.attributes.length > 1 || !
|
|
9612
|
+
if (node.attributes.length > 1 || !import_compiler41.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
|
9417
9613
|
throw tag.get("name").buildCodeFrameError(
|
|
9418
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)."
|
|
9419
9615
|
);
|
|
9420
9616
|
}
|
|
9421
9617
|
const valueExtra = evaluate(valueAttr.value);
|
|
9422
|
-
const upstreamAlias =
|
|
9618
|
+
const upstreamAlias = import_compiler41.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
|
|
9423
9619
|
if (upstreamAlias) {
|
|
9424
9620
|
valueExtra.pruned = true;
|
|
9425
9621
|
}
|
|
@@ -9475,16 +9671,16 @@ var const_default = {
|
|
|
9475
9671
|
};
|
|
9476
9672
|
|
|
9477
9673
|
// src/translator/core/debug.ts
|
|
9478
|
-
var
|
|
9479
|
-
var
|
|
9674
|
+
var import_compiler42 = require("@marko/compiler");
|
|
9675
|
+
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
|
9480
9676
|
var debug_default = {
|
|
9481
9677
|
analyze(tag) {
|
|
9482
9678
|
const [valueAttr] = tag.node.attributes;
|
|
9483
|
-
(0,
|
|
9484
|
-
(0,
|
|
9485
|
-
(0,
|
|
9679
|
+
(0, import_babel_utils30.assertNoVar)(tag);
|
|
9680
|
+
(0, import_babel_utils30.assertNoArgs)(tag);
|
|
9681
|
+
(0, import_babel_utils30.assertNoParams)(tag);
|
|
9486
9682
|
assertNoBodyContent(tag);
|
|
9487
|
-
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")) {
|
|
9488
9684
|
throw tag.get("name").buildCodeFrameError(
|
|
9489
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)."
|
|
9490
9686
|
);
|
|
@@ -9495,7 +9691,7 @@ var debug_default = {
|
|
|
9495
9691
|
const section = getSection(tag);
|
|
9496
9692
|
const [valueAttr] = tag.node.attributes;
|
|
9497
9693
|
const referencedBindings = valueAttr?.value.extra?.referencedBindings;
|
|
9498
|
-
const statement = withPreviousLocation(
|
|
9694
|
+
const statement = withPreviousLocation(import_compiler42.types.debuggerStatement(), tag.node);
|
|
9499
9695
|
if (isOutputHTML()) {
|
|
9500
9696
|
tag.insertBefore(statement);
|
|
9501
9697
|
} else {
|
|
@@ -9518,11 +9714,11 @@ var debug_default = {
|
|
|
9518
9714
|
};
|
|
9519
9715
|
|
|
9520
9716
|
// src/translator/core/define.ts
|
|
9521
|
-
var
|
|
9522
|
-
var
|
|
9717
|
+
var import_compiler43 = require("@marko/compiler");
|
|
9718
|
+
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
|
9523
9719
|
var define_default = {
|
|
9524
9720
|
analyze(tag) {
|
|
9525
|
-
(0,
|
|
9721
|
+
(0, import_babel_utils31.assertNoArgs)(tag);
|
|
9526
9722
|
if (!tag.node.var) {
|
|
9527
9723
|
throw tag.get("name").buildCodeFrameError(
|
|
9528
9724
|
"The [`<define>` tag](https://markojs.com/docs/reference/core-tag#define) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
|
@@ -9538,7 +9734,7 @@ var define_default = {
|
|
|
9538
9734
|
trackParamsReferences(tagBody, 3 /* param */);
|
|
9539
9735
|
setTagDownstream(tag, varBinding);
|
|
9540
9736
|
if (bodySection) {
|
|
9541
|
-
if (
|
|
9737
|
+
if (import_compiler43.types.isIdentifier(tag.node.var)) {
|
|
9542
9738
|
const babelBinding = tag.scope.getBinding(tag.node.var.name);
|
|
9543
9739
|
let allDirectReferences = true;
|
|
9544
9740
|
for (const ref of babelBinding.referencePaths) {
|
|
@@ -9587,7 +9783,7 @@ var define_default = {
|
|
|
9587
9783
|
tag.insertBefore(translatedAttrs.statements);
|
|
9588
9784
|
translateVar(tag, propsToExpression(translatedAttrs.properties));
|
|
9589
9785
|
} else {
|
|
9590
|
-
if (
|
|
9786
|
+
if (import_compiler43.types.isIdentifier(node.var)) {
|
|
9591
9787
|
const babelBinding = tag.scope.getBinding(node.var.name);
|
|
9592
9788
|
let hasDirectReferences = false;
|
|
9593
9789
|
let allDirectReferences = true;
|
|
@@ -9642,24 +9838,24 @@ var define_default = {
|
|
|
9642
9838
|
};
|
|
9643
9839
|
|
|
9644
9840
|
// src/translator/core/effect.ts
|
|
9645
|
-
var
|
|
9646
|
-
var
|
|
9841
|
+
var import_compiler44 = require("@marko/compiler");
|
|
9842
|
+
var import_babel_utils32 = require("@marko/compiler/babel-utils");
|
|
9647
9843
|
var effect_default = {
|
|
9648
9844
|
migrate: [
|
|
9649
9845
|
(tag) => {
|
|
9650
|
-
(0,
|
|
9651
|
-
(0,
|
|
9846
|
+
(0, import_babel_utils32.assertNoArgs)(tag);
|
|
9847
|
+
(0, import_babel_utils32.assertNoParams)(tag);
|
|
9652
9848
|
assertNoBodyContent(tag);
|
|
9653
|
-
(0,
|
|
9849
|
+
(0, import_babel_utils32.assertNoAttributeTags)(tag);
|
|
9654
9850
|
assertNoSpreadAttrs(tag);
|
|
9655
|
-
(0,
|
|
9656
|
-
(0,
|
|
9851
|
+
(0, import_babel_utils32.assertAllowedAttributes)(tag, ["value"]);
|
|
9852
|
+
(0, import_babel_utils32.diagnosticDeprecate)(tag, {
|
|
9657
9853
|
label: "The 'effect' tag has been replaced by the 'script' tag.",
|
|
9658
9854
|
fix() {
|
|
9659
9855
|
const { node } = tag;
|
|
9660
9856
|
tag.replaceWith(
|
|
9661
|
-
|
|
9662
|
-
withPreviousLocation(
|
|
9857
|
+
import_compiler44.types.markoTag(
|
|
9858
|
+
withPreviousLocation(import_compiler44.types.stringLiteral("script"), node.name),
|
|
9663
9859
|
node.attributes,
|
|
9664
9860
|
node.body,
|
|
9665
9861
|
node.arguments,
|
|
@@ -9676,12 +9872,12 @@ var effect_default = {
|
|
|
9676
9872
|
};
|
|
9677
9873
|
|
|
9678
9874
|
// src/translator/core/export.ts
|
|
9679
|
-
var
|
|
9875
|
+
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
|
9680
9876
|
var export_default = {
|
|
9681
9877
|
parse(tag) {
|
|
9682
9878
|
const { node } = tag;
|
|
9683
9879
|
tag.replaceWith(
|
|
9684
|
-
(0,
|
|
9880
|
+
(0, import_babel_utils33.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
9685
9881
|
);
|
|
9686
9882
|
},
|
|
9687
9883
|
parseOptions: {
|
|
@@ -9696,55 +9892,18 @@ var export_default = {
|
|
|
9696
9892
|
};
|
|
9697
9893
|
|
|
9698
9894
|
// src/translator/core/html-comment.ts
|
|
9699
|
-
var
|
|
9700
|
-
var
|
|
9701
|
-
|
|
9702
|
-
// src/translator/util/body-to-text-literal.ts
|
|
9703
|
-
var import_compiler42 = require("@marko/compiler");
|
|
9704
|
-
function bodyToTextLiteral(body) {
|
|
9705
|
-
const templateQuasis = [];
|
|
9706
|
-
const templateExpressions = [];
|
|
9707
|
-
let currentQuasi = "";
|
|
9708
|
-
let placeholderExtra;
|
|
9709
|
-
for (const child of body.body) {
|
|
9710
|
-
if (import_compiler42.types.isMarkoText(child)) {
|
|
9711
|
-
currentQuasi += child.value;
|
|
9712
|
-
} else if (import_compiler42.types.isMarkoPlaceholder(child)) {
|
|
9713
|
-
placeholderExtra ||= child.value.extra;
|
|
9714
|
-
templateQuasis.push(templateElement(currentQuasi, false));
|
|
9715
|
-
templateExpressions.push(callRuntime("_to_text", child.value));
|
|
9716
|
-
currentQuasi = "";
|
|
9717
|
-
}
|
|
9718
|
-
}
|
|
9719
|
-
if (templateExpressions.length) {
|
|
9720
|
-
templateQuasis.push(templateElement(currentQuasi, true));
|
|
9721
|
-
const literal = import_compiler42.types.templateLiteral(templateQuasis, templateExpressions);
|
|
9722
|
-
literal.extra = placeholderExtra;
|
|
9723
|
-
return literal;
|
|
9724
|
-
}
|
|
9725
|
-
return import_compiler42.types.stringLiteral(currentQuasi);
|
|
9726
|
-
}
|
|
9727
|
-
function templateElement(value, tail) {
|
|
9728
|
-
return import_compiler42.types.templateElement(
|
|
9729
|
-
{
|
|
9730
|
-
raw: value.replace(/`/g, "\\`"),
|
|
9731
|
-
cooked: value
|
|
9732
|
-
},
|
|
9733
|
-
tail
|
|
9734
|
-
);
|
|
9735
|
-
}
|
|
9736
|
-
|
|
9737
|
-
// src/translator/core/html-comment.ts
|
|
9895
|
+
var import_compiler45 = require("@marko/compiler");
|
|
9896
|
+
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
9738
9897
|
var kNodeBinding = Symbol("comment tag binding");
|
|
9739
9898
|
var html_comment_default = {
|
|
9740
9899
|
analyze(tag) {
|
|
9741
|
-
(0,
|
|
9742
|
-
(0,
|
|
9743
|
-
(0,
|
|
9900
|
+
(0, import_babel_utils34.assertNoArgs)(tag);
|
|
9901
|
+
(0, import_babel_utils34.assertNoParams)(tag);
|
|
9902
|
+
(0, import_babel_utils34.assertNoAttributes)(tag);
|
|
9744
9903
|
const tagVar = tag.node.var;
|
|
9745
9904
|
let needsBinding = false;
|
|
9746
9905
|
if (tagVar) {
|
|
9747
|
-
if (!
|
|
9906
|
+
if (!import_compiler45.types.isIdentifier(tagVar)) {
|
|
9748
9907
|
throw tag.get("var").buildCodeFrameError(
|
|
9749
9908
|
"The [`<html-comment>` tag](https://markojs.com/docs/reference/core-tag#html-comment) tag variable cannot be destructured."
|
|
9750
9909
|
);
|
|
@@ -9761,693 +9920,44 @@ var html_comment_default = {
|
|
|
9761
9920
|
"Invalid child. Only text is allowed inside an html comment."
|
|
9762
9921
|
);
|
|
9763
9922
|
}
|
|
9764
|
-
}
|
|
9765
|
-
if (needsBinding) {
|
|
9766
|
-
const tagSection = getOrCreateSection(tag);
|
|
9767
|
-
const tagExtra = mergeReferences(tagSection, tag.node, referenceNodes);
|
|
9768
|
-
const nodeBinding = tagExtra[kNodeBinding] = createBinding(
|
|
9769
|
-
"#comment",
|
|
9770
|
-
0 /* dom */,
|
|
9771
|
-
tagSection
|
|
9772
|
-
);
|
|
9773
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
9774
|
-
addSerializeExpr(tagSection, !!tagVar || tagExtra, nodeBinding);
|
|
9775
|
-
}
|
|
9776
|
-
tag.skip();
|
|
9777
|
-
},
|
|
9778
|
-
translate: {
|
|
9779
|
-
enter(tag) {
|
|
9780
|
-
const tagExtra = tag.node.extra;
|
|
9781
|
-
const nodeBinding = tagExtra[kNodeBinding];
|
|
9782
|
-
if (isOutputHTML()) {
|
|
9783
|
-
translateDomVar(tag, nodeBinding);
|
|
9784
|
-
}
|
|
9785
|
-
if (nodeBinding) {
|
|
9786
|
-
visit(tag, 32 /* Get */);
|
|
9787
|
-
}
|
|
9788
|
-
enter2(tag);
|
|
9789
|
-
writeTo(tag)`<!--`;
|
|
9790
|
-
},
|
|
9791
|
-
exit(tag) {
|
|
9792
|
-
const tagSection = getSection(tag);
|
|
9793
|
-
const tagExtra = tag.node.extra;
|
|
9794
|
-
const nodeBinding = tagExtra[kNodeBinding];
|
|
9795
|
-
const write = writeTo(tag);
|
|
9796
|
-
if (isOutputHTML()) {
|
|
9797
|
-
for (const child of tag.node.body.body) {
|
|
9798
|
-
if (import_compiler43.types.isMarkoText(child)) {
|
|
9799
|
-
write`${child.value}`;
|
|
9800
|
-
} else if (import_compiler43.types.isMarkoPlaceholder(child)) {
|
|
9801
|
-
write`${callRuntime("_to_text", child.value)}`;
|
|
9802
|
-
}
|
|
9803
|
-
}
|
|
9804
|
-
} else {
|
|
9805
|
-
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
9806
|
-
if (import_compiler43.types.isStringLiteral(textLiteral)) {
|
|
9807
|
-
write`${textLiteral}`;
|
|
9808
|
-
} else {
|
|
9809
|
-
addStatement(
|
|
9810
|
-
"render",
|
|
9811
|
-
getSection(tag),
|
|
9812
|
-
tagExtra.referencedBindings,
|
|
9813
|
-
import_compiler43.types.expressionStatement(
|
|
9814
|
-
callRuntime(
|
|
9815
|
-
"_text",
|
|
9816
|
-
createScopeReadExpression(nodeBinding),
|
|
9817
|
-
textLiteral
|
|
9818
|
-
)
|
|
9819
|
-
)
|
|
9820
|
-
);
|
|
9821
|
-
}
|
|
9822
|
-
}
|
|
9823
|
-
exit2(tag);
|
|
9824
|
-
write`-->`;
|
|
9825
|
-
if (nodeBinding) {
|
|
9826
|
-
markNode(
|
|
9827
|
-
tag,
|
|
9828
|
-
nodeBinding,
|
|
9829
|
-
getSerializeReason(tagSection, nodeBinding)
|
|
9830
|
-
);
|
|
9831
|
-
}
|
|
9832
|
-
tag.remove();
|
|
9833
|
-
}
|
|
9834
|
-
},
|
|
9835
|
-
parseOptions: {
|
|
9836
|
-
text: true
|
|
9837
|
-
},
|
|
9838
|
-
attributes: {},
|
|
9839
|
-
autocomplete: [
|
|
9840
|
-
{
|
|
9841
|
-
description: "Use to create an html comment that is not stripped from the output.",
|
|
9842
|
-
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-comment"
|
|
9843
|
-
}
|
|
9844
|
-
]
|
|
9845
|
-
};
|
|
9846
|
-
|
|
9847
|
-
// src/translator/core/html-script.ts
|
|
9848
|
-
var import_compiler44 = require("@marko/compiler");
|
|
9849
|
-
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
9850
|
-
var kNodeBinding2 = Symbol("script tag node binding");
|
|
9851
|
-
var html_script_default = {
|
|
9852
|
-
analyze(tag) {
|
|
9853
|
-
(0, import_babel_utils34.assertNoArgs)(tag);
|
|
9854
|
-
(0, import_babel_utils34.assertNoParams)(tag);
|
|
9855
|
-
const { node } = tag;
|
|
9856
|
-
if (node.var && !import_compiler44.types.isIdentifier(node.var)) {
|
|
9857
|
-
throw tag.get("var").buildCodeFrameError(
|
|
9858
|
-
"Tag variables on native elements cannot be destructured."
|
|
9859
|
-
);
|
|
9860
|
-
}
|
|
9861
|
-
const seen = {};
|
|
9862
|
-
const { attributes } = tag.node;
|
|
9863
|
-
let spreadReferenceNodes;
|
|
9864
|
-
let exprExtras;
|
|
9865
|
-
let hasEventHandlers = false;
|
|
9866
|
-
let hasDynamicAttributes = false;
|
|
9867
|
-
for (let i = attributes.length; i--; ) {
|
|
9868
|
-
const attr = attributes[i];
|
|
9869
|
-
const valueExtra = attr.value.extra ??= {};
|
|
9870
|
-
if (import_compiler44.types.isMarkoAttribute(attr)) {
|
|
9871
|
-
if (seen[attr.name]) {
|
|
9872
|
-
dropReferences(attr.value);
|
|
9873
|
-
continue;
|
|
9874
|
-
}
|
|
9875
|
-
seen[attr.name] = attr;
|
|
9876
|
-
if (isEventHandler(attr.name)) {
|
|
9877
|
-
valueExtra.isEffect = true;
|
|
9878
|
-
hasEventHandlers = true;
|
|
9879
|
-
} else if (!evaluate(attr.value).confident) {
|
|
9880
|
-
hasDynamicAttributes = true;
|
|
9881
|
-
}
|
|
9882
|
-
} else if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
9883
|
-
valueExtra.isEffect = true;
|
|
9884
|
-
hasEventHandlers = true;
|
|
9885
|
-
hasDynamicAttributes = true;
|
|
9886
|
-
}
|
|
9887
|
-
if (spreadReferenceNodes) {
|
|
9888
|
-
spreadReferenceNodes.push(attr.value);
|
|
9889
|
-
} else if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
9890
|
-
spreadReferenceNodes = [attr.value];
|
|
9891
|
-
} else {
|
|
9892
|
-
exprExtras = push(exprExtras, valueExtra);
|
|
9893
|
-
}
|
|
9894
|
-
}
|
|
9895
|
-
const bodyPlaceholderNodes = [];
|
|
9896
|
-
let hasBodyPlaceholders = false;
|
|
9897
|
-
for (const child of tag.node.body.body) {
|
|
9898
|
-
if (import_compiler44.types.isMarkoPlaceholder(child)) {
|
|
9899
|
-
bodyPlaceholderNodes.push(child.value);
|
|
9900
|
-
hasBodyPlaceholders = true;
|
|
9901
|
-
} else if (!import_compiler44.types.isMarkoText(child)) {
|
|
9902
|
-
throw tag.hub.buildError(
|
|
9903
|
-
child,
|
|
9904
|
-
"Invalid child. Only text is allowed inside an html-script."
|
|
9905
|
-
);
|
|
9906
|
-
}
|
|
9907
|
-
}
|
|
9908
|
-
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
9909
|
-
const tagExtra = node.extra ??= {};
|
|
9910
|
-
const tagSection = getOrCreateSection(tag);
|
|
9911
|
-
const nodeBinding = tagExtra[kNodeBinding2] = createBinding(
|
|
9912
|
-
"#script",
|
|
9913
|
-
0 /* dom */,
|
|
9914
|
-
tagSection
|
|
9915
|
-
);
|
|
9916
|
-
if (hasEventHandlers) {
|
|
9917
|
-
(0, import_babel_utils34.getProgram)().node.extra.isInteractive = true;
|
|
9918
|
-
}
|
|
9919
|
-
if (spreadReferenceNodes) {
|
|
9920
|
-
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
9921
|
-
}
|
|
9922
|
-
if (hasBodyPlaceholders) {
|
|
9923
|
-
exprExtras = push(
|
|
9924
|
-
exprExtras,
|
|
9925
|
-
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
9926
|
-
tagSection,
|
|
9927
|
-
bodyPlaceholderNodes[0],
|
|
9928
|
-
bodyPlaceholderNodes.slice(1)
|
|
9929
|
-
)
|
|
9930
|
-
);
|
|
9931
|
-
}
|
|
9932
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
9933
|
-
addSerializeExpr(
|
|
9934
|
-
tagSection,
|
|
9935
|
-
!!(node.var || hasEventHandlers),
|
|
9936
|
-
nodeBinding
|
|
9937
|
-
);
|
|
9938
|
-
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
9939
|
-
}
|
|
9940
|
-
},
|
|
9941
|
-
translate: {
|
|
9942
|
-
enter(tag) {
|
|
9943
|
-
const tagExtra = tag.node.extra;
|
|
9944
|
-
const nodeBinding = tagExtra[kNodeBinding2];
|
|
9945
|
-
const isHTML = isOutputHTML();
|
|
9946
|
-
const write = writeTo(tag);
|
|
9947
|
-
const tagSection = getSection(tag);
|
|
9948
|
-
if (isHTML) {
|
|
9949
|
-
translateDomVar(tag, nodeBinding);
|
|
9950
|
-
}
|
|
9951
|
-
if (nodeBinding) {
|
|
9952
|
-
visit(tag, 32 /* Get */);
|
|
9953
|
-
}
|
|
9954
|
-
write`<script`;
|
|
9955
|
-
const usedAttrs = getUsedAttrs2(tag.node, isHTML);
|
|
9956
|
-
const { hasNonce, staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
9957
|
-
if (isHTML && !hasNonce && !spreadExpression) {
|
|
9958
|
-
write`${callRuntime("_attr_nonce")}`;
|
|
9959
|
-
}
|
|
9960
|
-
for (const attr of staticAttrs) {
|
|
9961
|
-
const { name: name2, value } = attr;
|
|
9962
|
-
const { confident, computed } = value.extra || {};
|
|
9963
|
-
const valueReferences = value.extra?.referencedBindings;
|
|
9964
|
-
switch (name2) {
|
|
9965
|
-
case "class":
|
|
9966
|
-
case "style": {
|
|
9967
|
-
const helper = `_attr_${name2}`;
|
|
9968
|
-
if (confident) {
|
|
9969
|
-
write`${getHTMLRuntime()[helper](computed)}`;
|
|
9970
|
-
} else if (isHTML) {
|
|
9971
|
-
write`${callRuntime(helper, value)}`;
|
|
9972
|
-
} else {
|
|
9973
|
-
addStatement(
|
|
9974
|
-
"render",
|
|
9975
|
-
tagSection,
|
|
9976
|
-
valueReferences,
|
|
9977
|
-
import_compiler44.types.expressionStatement(
|
|
9978
|
-
callRuntime(
|
|
9979
|
-
helper,
|
|
9980
|
-
createScopeReadExpression(nodeBinding),
|
|
9981
|
-
value
|
|
9982
|
-
)
|
|
9983
|
-
)
|
|
9984
|
-
);
|
|
9985
|
-
}
|
|
9986
|
-
break;
|
|
9987
|
-
}
|
|
9988
|
-
default:
|
|
9989
|
-
if (confident) {
|
|
9990
|
-
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
9991
|
-
} else if (isHTML) {
|
|
9992
|
-
if (isEventHandler(name2)) {
|
|
9993
|
-
addHTMLEffectCall(tagSection, valueReferences);
|
|
9994
|
-
} else {
|
|
9995
|
-
write`${callRuntime("_attr", import_compiler44.types.stringLiteral(name2), value)}`;
|
|
9996
|
-
}
|
|
9997
|
-
} else if (isEventHandler(name2)) {
|
|
9998
|
-
addStatement(
|
|
9999
|
-
"effect",
|
|
10000
|
-
tagSection,
|
|
10001
|
-
valueReferences,
|
|
10002
|
-
import_compiler44.types.expressionStatement(
|
|
10003
|
-
callRuntime(
|
|
10004
|
-
"_on",
|
|
10005
|
-
createScopeReadExpression(nodeBinding),
|
|
10006
|
-
import_compiler44.types.stringLiteral(getEventHandlerName(name2)),
|
|
10007
|
-
value
|
|
10008
|
-
)
|
|
10009
|
-
)
|
|
10010
|
-
);
|
|
10011
|
-
} else {
|
|
10012
|
-
addStatement(
|
|
10013
|
-
"render",
|
|
10014
|
-
tagSection,
|
|
10015
|
-
valueReferences,
|
|
10016
|
-
import_compiler44.types.expressionStatement(
|
|
10017
|
-
callRuntime(
|
|
10018
|
-
"_attr",
|
|
10019
|
-
createScopeReadExpression(nodeBinding),
|
|
10020
|
-
import_compiler44.types.stringLiteral(name2),
|
|
10021
|
-
value
|
|
10022
|
-
)
|
|
10023
|
-
)
|
|
10024
|
-
);
|
|
10025
|
-
}
|
|
10026
|
-
break;
|
|
10027
|
-
}
|
|
10028
|
-
}
|
|
10029
|
-
if (spreadExpression) {
|
|
10030
|
-
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
|
10031
|
-
if (isHTML) {
|
|
10032
|
-
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
10033
|
-
if (skipExpression) {
|
|
10034
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler44.types.stringLiteral("script"))}`;
|
|
10035
|
-
} else {
|
|
10036
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler44.types.stringLiteral("script"))}`;
|
|
10037
|
-
}
|
|
10038
|
-
} else {
|
|
10039
|
-
if (skipExpression) {
|
|
10040
|
-
addStatement(
|
|
10041
|
-
"render",
|
|
10042
|
-
tagSection,
|
|
10043
|
-
tagExtra.referencedBindings,
|
|
10044
|
-
import_compiler44.types.expressionStatement(
|
|
10045
|
-
callRuntime(
|
|
10046
|
-
"_attrs_partial",
|
|
10047
|
-
scopeIdentifier,
|
|
10048
|
-
visitAccessor,
|
|
10049
|
-
spreadExpression,
|
|
10050
|
-
skipExpression
|
|
10051
|
-
)
|
|
10052
|
-
)
|
|
10053
|
-
);
|
|
10054
|
-
} else {
|
|
10055
|
-
addStatement(
|
|
10056
|
-
"render",
|
|
10057
|
-
tagSection,
|
|
10058
|
-
tagExtra.referencedBindings,
|
|
10059
|
-
import_compiler44.types.expressionStatement(
|
|
10060
|
-
callRuntime(
|
|
10061
|
-
"_attrs",
|
|
10062
|
-
scopeIdentifier,
|
|
10063
|
-
visitAccessor,
|
|
10064
|
-
spreadExpression
|
|
10065
|
-
)
|
|
10066
|
-
)
|
|
10067
|
-
);
|
|
10068
|
-
}
|
|
10069
|
-
addStatement(
|
|
10070
|
-
"effect",
|
|
10071
|
-
tagSection,
|
|
10072
|
-
tagExtra.referencedBindings,
|
|
10073
|
-
import_compiler44.types.expressionStatement(
|
|
10074
|
-
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
10075
|
-
),
|
|
10076
|
-
false
|
|
10077
|
-
);
|
|
10078
|
-
}
|
|
10079
|
-
}
|
|
10080
|
-
write`>`;
|
|
10081
|
-
enter2(tag);
|
|
10082
|
-
},
|
|
10083
|
-
exit(tag) {
|
|
10084
|
-
const tagSection = getSection(tag);
|
|
10085
|
-
const tagExtra = tag.node.extra;
|
|
10086
|
-
const nodeBinding = tagExtra[kNodeBinding2];
|
|
10087
|
-
const write = writeTo(tag);
|
|
10088
|
-
if (isOutputHTML()) {
|
|
10089
|
-
for (const child of tag.node.body.body) {
|
|
10090
|
-
if (import_compiler44.types.isMarkoText(child)) {
|
|
10091
|
-
write`${child.value}`;
|
|
10092
|
-
} else if (import_compiler44.types.isMarkoPlaceholder(child)) {
|
|
10093
|
-
write`${callRuntime("_escape_script", child.value)}`;
|
|
10094
|
-
}
|
|
10095
|
-
}
|
|
10096
|
-
} else {
|
|
10097
|
-
const textLiteral = bodyToTextLiteral(tag.node.body);
|
|
10098
|
-
if (import_compiler44.types.isStringLiteral(textLiteral)) {
|
|
10099
|
-
write`${textLiteral}`;
|
|
10100
|
-
} else {
|
|
10101
|
-
addStatement(
|
|
10102
|
-
"render",
|
|
10103
|
-
getSection(tag),
|
|
10104
|
-
textLiteral.extra?.referencedBindings,
|
|
10105
|
-
import_compiler44.types.expressionStatement(
|
|
10106
|
-
callRuntime(
|
|
10107
|
-
"_text_content",
|
|
10108
|
-
createScopeReadExpression(nodeBinding),
|
|
10109
|
-
textLiteral
|
|
10110
|
-
)
|
|
10111
|
-
)
|
|
10112
|
-
);
|
|
10113
|
-
}
|
|
10114
|
-
}
|
|
10115
|
-
write`</script>`;
|
|
10116
|
-
if (nodeBinding) {
|
|
10117
|
-
markNode(
|
|
10118
|
-
tag,
|
|
10119
|
-
nodeBinding,
|
|
10120
|
-
getSerializeReason(tagSection, nodeBinding)
|
|
10121
|
-
);
|
|
10122
|
-
}
|
|
10123
|
-
exit2(tag);
|
|
10124
|
-
tag.remove();
|
|
10125
|
-
}
|
|
10126
|
-
},
|
|
10127
|
-
"@async": "#html-async",
|
|
10128
|
-
"@crossorigin": "#html-crossorigin",
|
|
10129
|
-
"@defer": "#html-defer",
|
|
10130
|
-
"@integrity": "#html-integrity",
|
|
10131
|
-
"@nomodule": "#html-nomodule",
|
|
10132
|
-
"@nonce": "#html-nonce",
|
|
10133
|
-
"@referrerpolicy": "#html-referrerpolicy",
|
|
10134
|
-
"@src": "#html-src",
|
|
10135
|
-
"@type": "#html-type",
|
|
10136
|
-
"attribute-groups": ["html-attributes"],
|
|
10137
|
-
parseOptions: {
|
|
10138
|
-
text: true,
|
|
10139
|
-
preserveWhitespace: true
|
|
10140
|
-
},
|
|
10141
|
-
autocomplete: [
|
|
10142
|
-
{
|
|
10143
|
-
description: "Use instead of `<script>` to render a native tag directly, without processing by Marko.",
|
|
10144
|
-
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
|
|
10145
|
-
}
|
|
10146
|
-
]
|
|
10147
|
-
};
|
|
10148
|
-
function getUsedAttrs2(tag, injectNonce) {
|
|
10149
|
-
const seen = {};
|
|
10150
|
-
const { attributes } = tag;
|
|
10151
|
-
const maybeStaticAttrs = /* @__PURE__ */ new Set();
|
|
10152
|
-
let spreadExpression;
|
|
10153
|
-
let skipExpression;
|
|
10154
|
-
let spreadProps;
|
|
10155
|
-
let skipProps;
|
|
10156
|
-
let hasNonce = false;
|
|
10157
|
-
for (let i = attributes.length; i--; ) {
|
|
10158
|
-
const attr = attributes[i];
|
|
10159
|
-
const { value } = attr;
|
|
10160
|
-
if (import_compiler44.types.isMarkoSpreadAttribute(attr)) {
|
|
10161
|
-
if (!spreadProps) {
|
|
10162
|
-
spreadProps = [];
|
|
10163
|
-
}
|
|
10164
|
-
spreadProps.push(import_compiler44.types.spreadElement(value));
|
|
10165
|
-
} else if (!seen[attr.name]) {
|
|
10166
|
-
seen[attr.name] = attr;
|
|
10167
|
-
if (attr.name === "nonce") {
|
|
10168
|
-
hasNonce = true;
|
|
10169
|
-
}
|
|
10170
|
-
if (spreadProps) {
|
|
10171
|
-
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
10172
|
-
} else {
|
|
10173
|
-
maybeStaticAttrs.add(attr);
|
|
10174
|
-
}
|
|
10175
|
-
}
|
|
10176
|
-
}
|
|
10177
|
-
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
10178
|
-
if (spreadProps) {
|
|
10179
|
-
spreadProps.reverse();
|
|
10180
|
-
for (const { name: name2 } of staticAttrs) {
|
|
10181
|
-
(skipProps ||= []).push(toObjectProperty(name2, import_compiler44.types.numericLiteral(1)));
|
|
10182
|
-
}
|
|
10183
|
-
if (skipProps) {
|
|
10184
|
-
skipExpression = import_compiler44.types.objectExpression(skipProps);
|
|
10185
|
-
}
|
|
10186
|
-
if (injectNonce && !hasNonce) {
|
|
10187
|
-
spreadProps.unshift(
|
|
10188
|
-
import_compiler44.types.objectProperty(
|
|
10189
|
-
import_compiler44.types.identifier("nonce"),
|
|
10190
|
-
import_compiler44.types.memberExpression(callRuntime("$global"), import_compiler44.types.identifier("cspNonce"))
|
|
10191
|
-
)
|
|
10192
|
-
);
|
|
10193
|
-
}
|
|
10194
|
-
spreadExpression = propsToExpression(spreadProps);
|
|
10195
|
-
}
|
|
10196
|
-
return {
|
|
10197
|
-
hasNonce,
|
|
10198
|
-
staticAttrs,
|
|
10199
|
-
spreadExpression,
|
|
10200
|
-
skipExpression
|
|
10201
|
-
};
|
|
10202
|
-
}
|
|
10203
|
-
|
|
10204
|
-
// src/translator/core/html-style.ts
|
|
10205
|
-
var import_compiler45 = require("@marko/compiler");
|
|
10206
|
-
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
10207
|
-
var kNodeBinding3 = Symbol("style tag node binding");
|
|
10208
|
-
var html_style_default = {
|
|
10209
|
-
analyze(tag) {
|
|
10210
|
-
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
10211
|
-
(0, import_babel_utils35.assertNoParams)(tag);
|
|
10212
|
-
const { node } = tag;
|
|
10213
|
-
if (node.var && !import_compiler45.types.isIdentifier(node.var)) {
|
|
10214
|
-
throw tag.get("var").buildCodeFrameError(
|
|
10215
|
-
"Tag variables on native elements cannot be destructured."
|
|
10216
|
-
);
|
|
10217
|
-
}
|
|
10218
|
-
const seen = {};
|
|
10219
|
-
const { attributes } = tag.node;
|
|
10220
|
-
let spreadReferenceNodes;
|
|
10221
|
-
let exprExtras;
|
|
10222
|
-
let hasEventHandlers = false;
|
|
10223
|
-
let hasDynamicAttributes = false;
|
|
10224
|
-
for (let i = attributes.length; i--; ) {
|
|
10225
|
-
const attr = attributes[i];
|
|
10226
|
-
const valueExtra = attr.value.extra ??= {};
|
|
10227
|
-
if (import_compiler45.types.isMarkoAttribute(attr)) {
|
|
10228
|
-
if (seen[attr.name]) {
|
|
10229
|
-
dropReferences(attr.value);
|
|
10230
|
-
continue;
|
|
10231
|
-
}
|
|
10232
|
-
seen[attr.name] = attr;
|
|
10233
|
-
if (isEventHandler(attr.name)) {
|
|
10234
|
-
valueExtra.isEffect = true;
|
|
10235
|
-
hasEventHandlers = true;
|
|
10236
|
-
} else if (!evaluate(attr.value).confident) {
|
|
10237
|
-
hasDynamicAttributes = true;
|
|
10238
|
-
}
|
|
10239
|
-
} else if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
|
10240
|
-
valueExtra.isEffect = true;
|
|
10241
|
-
hasEventHandlers = true;
|
|
10242
|
-
hasDynamicAttributes = true;
|
|
10243
|
-
}
|
|
10244
|
-
if (spreadReferenceNodes) {
|
|
10245
|
-
spreadReferenceNodes.push(attr.value);
|
|
10246
|
-
} else if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
|
10247
|
-
spreadReferenceNodes = [attr.value];
|
|
10248
|
-
} else {
|
|
10249
|
-
exprExtras = push(exprExtras, valueExtra);
|
|
10250
|
-
}
|
|
10251
|
-
}
|
|
10252
|
-
const bodyPlaceholderNodes = [];
|
|
10253
|
-
let hasBodyPlaceholders = false;
|
|
10254
|
-
for (const child of tag.node.body.body) {
|
|
10255
|
-
if (import_compiler45.types.isMarkoPlaceholder(child)) {
|
|
10256
|
-
bodyPlaceholderNodes.push(child.value);
|
|
10257
|
-
hasBodyPlaceholders = true;
|
|
10258
|
-
} else if (!import_compiler45.types.isMarkoText(child)) {
|
|
10259
|
-
throw tag.hub.buildError(
|
|
10260
|
-
child,
|
|
10261
|
-
"Invalid child. Only text is allowed inside an html-style."
|
|
10262
|
-
);
|
|
10263
|
-
}
|
|
10264
|
-
}
|
|
10265
|
-
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
|
10266
|
-
const tagExtra = node.extra ??= {};
|
|
10267
|
-
const tagSection = getOrCreateSection(tag);
|
|
10268
|
-
const nodeBinding = tagExtra[kNodeBinding3] = createBinding(
|
|
10269
|
-
"#style",
|
|
10270
|
-
0 /* dom */,
|
|
10271
|
-
tagSection
|
|
10272
|
-
);
|
|
10273
|
-
if (hasEventHandlers) {
|
|
10274
|
-
(0, import_babel_utils35.getProgram)().node.extra.isInteractive = true;
|
|
10275
|
-
}
|
|
10276
|
-
if (spreadReferenceNodes) {
|
|
10277
|
-
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
10278
|
-
}
|
|
10279
|
-
if (hasBodyPlaceholders) {
|
|
10280
|
-
exprExtras = push(
|
|
10281
|
-
exprExtras,
|
|
10282
|
-
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
10283
|
-
tagSection,
|
|
10284
|
-
bodyPlaceholderNodes[0],
|
|
10285
|
-
bodyPlaceholderNodes.slice(1)
|
|
10286
|
-
)
|
|
10287
|
-
);
|
|
10288
|
-
}
|
|
10289
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
10290
|
-
addSerializeExpr(
|
|
10291
|
-
tagSection,
|
|
10292
|
-
!!(node.var || hasEventHandlers),
|
|
10293
|
-
nodeBinding
|
|
10294
|
-
);
|
|
10295
|
-
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
10296
|
-
}
|
|
10297
|
-
},
|
|
10298
|
-
translate: {
|
|
10299
|
-
enter(tag) {
|
|
10300
|
-
const tagExtra = tag.node.extra;
|
|
10301
|
-
const nodeBinding = tagExtra[kNodeBinding3];
|
|
10302
|
-
const isHTML = isOutputHTML();
|
|
10303
|
-
const write = writeTo(tag);
|
|
10304
|
-
const tagSection = getSection(tag);
|
|
10305
|
-
if (isHTML) {
|
|
10306
|
-
translateDomVar(tag, nodeBinding);
|
|
10307
|
-
}
|
|
10308
|
-
if (nodeBinding) {
|
|
10309
|
-
visit(tag, 32 /* Get */);
|
|
10310
|
-
}
|
|
10311
|
-
write`<style`;
|
|
10312
|
-
const usedAttrs = getUsedAttrs3(tag.node, isHTML);
|
|
10313
|
-
const { hasNonce, staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
10314
|
-
if (isHTML && !hasNonce && !spreadExpression) {
|
|
10315
|
-
write`${callRuntime("_attr_nonce")}`;
|
|
10316
|
-
}
|
|
10317
|
-
for (const attr of staticAttrs) {
|
|
10318
|
-
const { name: name2, value } = attr;
|
|
10319
|
-
const { confident, computed } = value.extra || {};
|
|
10320
|
-
const valueReferences = value.extra?.referencedBindings;
|
|
10321
|
-
switch (name2) {
|
|
10322
|
-
case "class":
|
|
10323
|
-
case "style": {
|
|
10324
|
-
const helper = `_attr_${name2}`;
|
|
10325
|
-
if (confident) {
|
|
10326
|
-
write`${getHTMLRuntime()[helper](computed)}`;
|
|
10327
|
-
} else if (isHTML) {
|
|
10328
|
-
write`${callRuntime(helper, value)}`;
|
|
10329
|
-
} else {
|
|
10330
|
-
addStatement(
|
|
10331
|
-
"render",
|
|
10332
|
-
tagSection,
|
|
10333
|
-
valueReferences,
|
|
10334
|
-
import_compiler45.types.expressionStatement(
|
|
10335
|
-
callRuntime(
|
|
10336
|
-
helper,
|
|
10337
|
-
createScopeReadExpression(nodeBinding),
|
|
10338
|
-
value
|
|
10339
|
-
)
|
|
10340
|
-
)
|
|
10341
|
-
);
|
|
10342
|
-
}
|
|
10343
|
-
break;
|
|
10344
|
-
}
|
|
10345
|
-
default:
|
|
10346
|
-
if (confident) {
|
|
10347
|
-
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
10348
|
-
} else if (isHTML) {
|
|
10349
|
-
if (isEventHandler(name2)) {
|
|
10350
|
-
addHTMLEffectCall(tagSection, valueReferences);
|
|
10351
|
-
} else {
|
|
10352
|
-
write`${callRuntime("_attr", import_compiler45.types.stringLiteral(name2), value)}`;
|
|
10353
|
-
}
|
|
10354
|
-
} else if (isEventHandler(name2)) {
|
|
10355
|
-
addStatement(
|
|
10356
|
-
"effect",
|
|
10357
|
-
tagSection,
|
|
10358
|
-
valueReferences,
|
|
10359
|
-
import_compiler45.types.expressionStatement(
|
|
10360
|
-
callRuntime(
|
|
10361
|
-
"_on",
|
|
10362
|
-
createScopeReadExpression(nodeBinding),
|
|
10363
|
-
import_compiler45.types.stringLiteral(getEventHandlerName(name2)),
|
|
10364
|
-
value
|
|
10365
|
-
)
|
|
10366
|
-
)
|
|
10367
|
-
);
|
|
10368
|
-
} else {
|
|
10369
|
-
addStatement(
|
|
10370
|
-
"render",
|
|
10371
|
-
tagSection,
|
|
10372
|
-
valueReferences,
|
|
10373
|
-
import_compiler45.types.expressionStatement(
|
|
10374
|
-
callRuntime(
|
|
10375
|
-
"_attr",
|
|
10376
|
-
createScopeReadExpression(nodeBinding),
|
|
10377
|
-
import_compiler45.types.stringLiteral(name2),
|
|
10378
|
-
value
|
|
10379
|
-
)
|
|
10380
|
-
)
|
|
10381
|
-
);
|
|
10382
|
-
}
|
|
10383
|
-
break;
|
|
10384
|
-
}
|
|
10385
|
-
}
|
|
10386
|
-
if (spreadExpression) {
|
|
10387
|
-
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
10388
|
-
if (isHTML) {
|
|
10389
|
-
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
10390
|
-
if (skipExpression) {
|
|
10391
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler45.types.stringLiteral("style"))}`;
|
|
10392
|
-
} else {
|
|
10393
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler45.types.stringLiteral("style"))}`;
|
|
10394
|
-
}
|
|
10395
|
-
} else {
|
|
10396
|
-
if (skipExpression) {
|
|
10397
|
-
addStatement(
|
|
10398
|
-
"render",
|
|
10399
|
-
tagSection,
|
|
10400
|
-
tagExtra.referencedBindings,
|
|
10401
|
-
import_compiler45.types.expressionStatement(
|
|
10402
|
-
callRuntime(
|
|
10403
|
-
"_attrs_partial",
|
|
10404
|
-
scopeIdentifier,
|
|
10405
|
-
visitAccessor,
|
|
10406
|
-
spreadExpression,
|
|
10407
|
-
skipExpression
|
|
10408
|
-
)
|
|
10409
|
-
)
|
|
10410
|
-
);
|
|
10411
|
-
} else {
|
|
10412
|
-
addStatement(
|
|
10413
|
-
"render",
|
|
10414
|
-
tagSection,
|
|
10415
|
-
tagExtra.referencedBindings,
|
|
10416
|
-
import_compiler45.types.expressionStatement(
|
|
10417
|
-
callRuntime(
|
|
10418
|
-
"_attrs",
|
|
10419
|
-
scopeIdentifier,
|
|
10420
|
-
visitAccessor,
|
|
10421
|
-
spreadExpression
|
|
10422
|
-
)
|
|
10423
|
-
)
|
|
10424
|
-
);
|
|
10425
|
-
}
|
|
10426
|
-
addStatement(
|
|
10427
|
-
"effect",
|
|
10428
|
-
tagSection,
|
|
10429
|
-
tagExtra.referencedBindings,
|
|
10430
|
-
import_compiler45.types.expressionStatement(
|
|
10431
|
-
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
10432
|
-
),
|
|
10433
|
-
false
|
|
10434
|
-
);
|
|
10435
|
-
}
|
|
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 */);
|
|
10436
9946
|
}
|
|
10437
|
-
write`>`;
|
|
10438
9947
|
enter2(tag);
|
|
9948
|
+
writeTo(tag)`<!--`;
|
|
10439
9949
|
},
|
|
10440
9950
|
exit(tag) {
|
|
10441
9951
|
const tagSection = getSection(tag);
|
|
10442
9952
|
const tagExtra = tag.node.extra;
|
|
10443
|
-
const nodeBinding = tagExtra[
|
|
9953
|
+
const nodeBinding = tagExtra[kNodeBinding];
|
|
10444
9954
|
const write = writeTo(tag);
|
|
10445
9955
|
if (isOutputHTML()) {
|
|
10446
9956
|
for (const child of tag.node.body.body) {
|
|
10447
9957
|
if (import_compiler45.types.isMarkoText(child)) {
|
|
10448
9958
|
write`${child.value}`;
|
|
10449
9959
|
} else if (import_compiler45.types.isMarkoPlaceholder(child)) {
|
|
10450
|
-
write`${callRuntime("
|
|
9960
|
+
write`${callRuntime("_escape_text", child.value)}`;
|
|
10451
9961
|
}
|
|
10452
9962
|
}
|
|
10453
9963
|
} else {
|
|
@@ -10458,10 +9968,10 @@ var html_style_default = {
|
|
|
10458
9968
|
addStatement(
|
|
10459
9969
|
"render",
|
|
10460
9970
|
getSection(tag),
|
|
10461
|
-
|
|
9971
|
+
tagExtra.referencedBindings,
|
|
10462
9972
|
import_compiler45.types.expressionStatement(
|
|
10463
9973
|
callRuntime(
|
|
10464
|
-
"
|
|
9974
|
+
"_text",
|
|
10465
9975
|
createScopeReadExpression(nodeBinding),
|
|
10466
9976
|
textLiteral
|
|
10467
9977
|
)
|
|
@@ -10469,7 +9979,8 @@ var html_style_default = {
|
|
|
10469
9979
|
);
|
|
10470
9980
|
}
|
|
10471
9981
|
}
|
|
10472
|
-
|
|
9982
|
+
exit2(tag);
|
|
9983
|
+
write`-->`;
|
|
10473
9984
|
if (nodeBinding) {
|
|
10474
9985
|
markNode(
|
|
10475
9986
|
tag,
|
|
@@ -10477,91 +9988,62 @@ var html_style_default = {
|
|
|
10477
9988
|
getSerializeReason(tagSection, nodeBinding)
|
|
10478
9989
|
);
|
|
10479
9990
|
}
|
|
10480
|
-
exit2(tag);
|
|
10481
9991
|
tag.remove();
|
|
10482
9992
|
}
|
|
10483
9993
|
},
|
|
10484
|
-
|
|
10485
|
-
|
|
10486
|
-
|
|
10487
|
-
|
|
10488
|
-
|
|
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,
|
|
10489
10010
|
parseOptions: {
|
|
10490
10011
|
text: true,
|
|
10491
10012
|
preserveWhitespace: true
|
|
10492
10013
|
},
|
|
10493
10014
|
autocomplete: [
|
|
10494
10015
|
{
|
|
10495
|
-
description: "Use instead of `<
|
|
10016
|
+
description: "Use instead of `<script>` to render a native tag directly, without processing by Marko.",
|
|
10496
10017
|
descriptionMoreURL: "https://markojs.com/docs/reference/core-tag#html-script--html-style"
|
|
10497
10018
|
}
|
|
10498
10019
|
]
|
|
10499
10020
|
};
|
|
10500
|
-
|
|
10501
|
-
|
|
10502
|
-
|
|
10503
|
-
|
|
10504
|
-
|
|
10505
|
-
|
|
10506
|
-
|
|
10507
|
-
|
|
10508
|
-
|
|
10509
|
-
|
|
10510
|
-
|
|
10511
|
-
|
|
10512
|
-
|
|
10513
|
-
if (!spreadProps) {
|
|
10514
|
-
spreadProps = [];
|
|
10515
|
-
}
|
|
10516
|
-
spreadProps.push(import_compiler45.types.spreadElement(value));
|
|
10517
|
-
} else if (!seen[attr.name]) {
|
|
10518
|
-
seen[attr.name] = attr;
|
|
10519
|
-
if (attr.name === "nonce") {
|
|
10520
|
-
hasNonce = true;
|
|
10521
|
-
}
|
|
10522
|
-
if (spreadProps) {
|
|
10523
|
-
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
10524
|
-
} else {
|
|
10525
|
-
maybeStaticAttrs.add(attr);
|
|
10526
|
-
}
|
|
10527
|
-
}
|
|
10528
|
-
}
|
|
10529
|
-
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
10530
|
-
if (spreadProps) {
|
|
10531
|
-
spreadProps.reverse();
|
|
10532
|
-
for (const { name: name2 } of staticAttrs) {
|
|
10533
|
-
(skipProps ||= []).push(toObjectProperty(name2, import_compiler45.types.numericLiteral(1)));
|
|
10534
|
-
}
|
|
10535
|
-
if (skipProps) {
|
|
10536
|
-
skipExpression = import_compiler45.types.objectExpression(skipProps);
|
|
10537
|
-
}
|
|
10538
|
-
if (injectNonce && !hasNonce) {
|
|
10539
|
-
spreadProps.unshift(
|
|
10540
|
-
import_compiler45.types.objectProperty(
|
|
10541
|
-
import_compiler45.types.identifier("nonce"),
|
|
10542
|
-
import_compiler45.types.memberExpression(callRuntime("$global"), import_compiler45.types.identifier("cspNonce"))
|
|
10543
|
-
)
|
|
10544
|
-
);
|
|
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"
|
|
10545
10034
|
}
|
|
10546
|
-
|
|
10547
|
-
|
|
10548
|
-
return {
|
|
10549
|
-
hasNonce,
|
|
10550
|
-
staticAttrs,
|
|
10551
|
-
spreadExpression,
|
|
10552
|
-
skipExpression
|
|
10553
|
-
};
|
|
10554
|
-
}
|
|
10035
|
+
]
|
|
10036
|
+
};
|
|
10555
10037
|
|
|
10556
10038
|
// src/translator/core/id.ts
|
|
10557
10039
|
var import_compiler46 = require("@marko/compiler");
|
|
10558
|
-
var
|
|
10040
|
+
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
10559
10041
|
var id_default = {
|
|
10560
10042
|
analyze(tag) {
|
|
10561
|
-
(0,
|
|
10562
|
-
(0,
|
|
10043
|
+
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
10044
|
+
(0, import_babel_utils35.assertNoParams)(tag);
|
|
10563
10045
|
assertNoBodyContent(tag);
|
|
10564
|
-
(0,
|
|
10046
|
+
(0, import_babel_utils35.assertNoAttributeTags)(tag);
|
|
10565
10047
|
const { node } = tag;
|
|
10566
10048
|
const [valueAttr] = node.attributes;
|
|
10567
10049
|
if (!node.var) {
|
|
@@ -10633,7 +10115,7 @@ var id_default = {
|
|
|
10633
10115
|
|
|
10634
10116
|
// src/translator/core/if.ts
|
|
10635
10117
|
var import_compiler48 = require("@marko/compiler");
|
|
10636
|
-
var
|
|
10118
|
+
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
|
10637
10119
|
|
|
10638
10120
|
// src/translator/util/to-first-statement-or-block.ts
|
|
10639
10121
|
var import_compiler47 = require("@marko/compiler");
|
|
@@ -10901,9 +10383,9 @@ var ElseTag = {
|
|
|
10901
10383
|
]
|
|
10902
10384
|
};
|
|
10903
10385
|
function assertValidCondition(tag) {
|
|
10904
|
-
(0,
|
|
10905
|
-
(0,
|
|
10906
|
-
(0,
|
|
10386
|
+
(0, import_babel_utils36.assertNoVar)(tag);
|
|
10387
|
+
(0, import_babel_utils36.assertNoArgs)(tag);
|
|
10388
|
+
(0, import_babel_utils36.assertNoParams)(tag);
|
|
10907
10389
|
assertHasBody(tag);
|
|
10908
10390
|
assertNoSpreadAttrs(tag);
|
|
10909
10391
|
switch (getTagName(tag)) {
|
|
@@ -11002,12 +10484,12 @@ function isRoot(tag) {
|
|
|
11002
10484
|
}
|
|
11003
10485
|
|
|
11004
10486
|
// src/translator/core/import.ts
|
|
11005
|
-
var
|
|
10487
|
+
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
|
11006
10488
|
var import_default = {
|
|
11007
10489
|
parse(tag) {
|
|
11008
10490
|
const { node } = tag;
|
|
11009
10491
|
tag.replaceWith(
|
|
11010
|
-
(0,
|
|
10492
|
+
(0, import_babel_utils37.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
11011
10493
|
);
|
|
11012
10494
|
},
|
|
11013
10495
|
parseOptions: {
|
|
@@ -11026,7 +10508,7 @@ var import_default = {
|
|
|
11026
10508
|
|
|
11027
10509
|
// src/translator/core/let.ts
|
|
11028
10510
|
var import_compiler49 = require("@marko/compiler");
|
|
11029
|
-
var
|
|
10511
|
+
var import_babel_utils38 = require("@marko/compiler/babel-utils");
|
|
11030
10512
|
var let_default = {
|
|
11031
10513
|
analyze(tag) {
|
|
11032
10514
|
const { node } = tag;
|
|
@@ -11055,8 +10537,8 @@ var let_default = {
|
|
|
11055
10537
|
}
|
|
11056
10538
|
}
|
|
11057
10539
|
}
|
|
11058
|
-
(0,
|
|
11059
|
-
(0,
|
|
10540
|
+
(0, import_babel_utils38.assertNoArgs)(tag);
|
|
10541
|
+
(0, import_babel_utils38.assertNoParams)(tag);
|
|
11060
10542
|
assertNoBodyContent(tag);
|
|
11061
10543
|
assertNoSpreadAttrs(tag);
|
|
11062
10544
|
if (!tagVar) {
|
|
@@ -11069,7 +10551,7 @@ var let_default = {
|
|
|
11069
10551
|
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) variable cannot be destructured."
|
|
11070
10552
|
);
|
|
11071
10553
|
}
|
|
11072
|
-
if (valueChangeAttr && (0,
|
|
10554
|
+
if (valueChangeAttr && (0, import_babel_utils38.computeNode)(valueChangeAttr.value)?.value) {
|
|
11073
10555
|
throw tag.get("attributes").find((attr) => attr.node === valueChangeAttr).get("value").buildCodeFrameError(
|
|
11074
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."
|
|
11075
10557
|
);
|
|
@@ -11152,13 +10634,13 @@ var let_default = {
|
|
|
11152
10634
|
|
|
11153
10635
|
// src/translator/core/lifecycle.ts
|
|
11154
10636
|
var import_compiler50 = require("@marko/compiler");
|
|
11155
|
-
var
|
|
10637
|
+
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
|
11156
10638
|
var kRef = Symbol("lifecycle attrs reference");
|
|
11157
10639
|
var lifecycle_default = {
|
|
11158
10640
|
analyze(tag) {
|
|
11159
|
-
(0,
|
|
11160
|
-
(0,
|
|
11161
|
-
(0,
|
|
10641
|
+
(0, import_babel_utils39.assertNoArgs)(tag);
|
|
10642
|
+
(0, import_babel_utils39.assertNoVar)(tag);
|
|
10643
|
+
(0, import_babel_utils39.assertNoParams)(tag);
|
|
11162
10644
|
assertNoBodyContent(tag);
|
|
11163
10645
|
const { node } = tag;
|
|
11164
10646
|
const section = getOrCreateSection(tag);
|
|
@@ -11186,7 +10668,7 @@ var lifecycle_default = {
|
|
|
11186
10668
|
}
|
|
11187
10669
|
(attr.value.extra ??= {}).isEffect = true;
|
|
11188
10670
|
}
|
|
11189
|
-
(0,
|
|
10671
|
+
(0, import_babel_utils39.getProgram)().node.extra.isInteractive = true;
|
|
11190
10672
|
},
|
|
11191
10673
|
translate: {
|
|
11192
10674
|
exit(tag) {
|
|
@@ -11234,13 +10716,13 @@ var lifecycle_default = {
|
|
|
11234
10716
|
|
|
11235
10717
|
// src/translator/core/log.ts
|
|
11236
10718
|
var import_compiler51 = require("@marko/compiler");
|
|
11237
|
-
var
|
|
10719
|
+
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
|
11238
10720
|
var log_default = {
|
|
11239
10721
|
analyze(tag) {
|
|
11240
10722
|
const [valueAttr] = tag.node.attributes;
|
|
11241
|
-
(0,
|
|
11242
|
-
(0,
|
|
11243
|
-
(0,
|
|
10723
|
+
(0, import_babel_utils40.assertNoArgs)(tag);
|
|
10724
|
+
(0, import_babel_utils40.assertNoVar)(tag);
|
|
10725
|
+
(0, import_babel_utils40.assertNoParams)(tag);
|
|
11244
10726
|
assertNoBodyContent(tag);
|
|
11245
10727
|
if (!valueAttr) {
|
|
11246
10728
|
throw tag.get("name").buildCodeFrameError(
|
|
@@ -11288,7 +10770,7 @@ var log_default = {
|
|
|
11288
10770
|
|
|
11289
10771
|
// src/translator/core/script.ts
|
|
11290
10772
|
var import_compiler52 = require("@marko/compiler");
|
|
11291
|
-
var
|
|
10773
|
+
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
|
11292
10774
|
var htmlScriptTagAlternateMsg = " For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.";
|
|
11293
10775
|
var script_default = {
|
|
11294
10776
|
parse(tag) {
|
|
@@ -11308,7 +10790,7 @@ var script_default = {
|
|
|
11308
10790
|
}
|
|
11309
10791
|
const start = body[0]?.start;
|
|
11310
10792
|
const end = body[body.length - 1]?.end;
|
|
11311
|
-
const bodyStatements = (0,
|
|
10793
|
+
const bodyStatements = (0, import_babel_utils41.parseStatements)(tag.hub.file, code, start, end);
|
|
11312
10794
|
if (bodyStatements.length) {
|
|
11313
10795
|
const valueFn = import_compiler52.types.arrowFunctionExpression(
|
|
11314
10796
|
[],
|
|
@@ -11322,10 +10804,10 @@ var script_default = {
|
|
|
11322
10804
|
},
|
|
11323
10805
|
analyze(tag) {
|
|
11324
10806
|
const { node } = tag;
|
|
11325
|
-
(0,
|
|
11326
|
-
(0,
|
|
10807
|
+
(0, import_babel_utils41.assertNoArgs)(tag);
|
|
10808
|
+
(0, import_babel_utils41.assertNoParams)(tag);
|
|
11327
10809
|
assertNoBodyContent(tag);
|
|
11328
|
-
(0,
|
|
10810
|
+
(0, import_babel_utils41.assertNoAttributeTags)(tag);
|
|
11329
10811
|
if (node.var) {
|
|
11330
10812
|
throw tag.hub.buildError(
|
|
11331
10813
|
node.var,
|
|
@@ -11340,7 +10822,7 @@ var script_default = {
|
|
|
11340
10822
|
}
|
|
11341
10823
|
seenValueAttr = true;
|
|
11342
10824
|
(attr.value.extra ??= {}).isEffect = true;
|
|
11343
|
-
(0,
|
|
10825
|
+
(0, import_babel_utils41.getProgram)().node.extra.isInteractive = true;
|
|
11344
10826
|
} else {
|
|
11345
10827
|
throw tag.hub.buildError(
|
|
11346
10828
|
attr,
|
|
@@ -11402,7 +10884,6 @@ var script_default = {
|
|
|
11402
10884
|
text: true,
|
|
11403
10885
|
preserveWhitespace: true
|
|
11404
10886
|
},
|
|
11405
|
-
attributes: {},
|
|
11406
10887
|
autocomplete: [
|
|
11407
10888
|
{
|
|
11408
10889
|
description: "Use to create a side effects.",
|
|
@@ -11431,7 +10912,7 @@ function isAwaitExpression(node) {
|
|
|
11431
10912
|
|
|
11432
10913
|
// src/translator/core/server.ts
|
|
11433
10914
|
var import_compiler53 = require("@marko/compiler");
|
|
11434
|
-
var
|
|
10915
|
+
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
|
11435
10916
|
var server_default = {
|
|
11436
10917
|
parse(tag) {
|
|
11437
10918
|
const {
|
|
@@ -11441,7 +10922,7 @@ var server_default = {
|
|
|
11441
10922
|
const rawValue = node.rawValue;
|
|
11442
10923
|
const code = rawValue.replace(/^server\s*/, "");
|
|
11443
10924
|
const start = node.start + (rawValue.length - code.length);
|
|
11444
|
-
let body = (0,
|
|
10925
|
+
let body = (0, import_babel_utils42.parseStatements)(file, code, start, start + code.length);
|
|
11445
10926
|
if (body.length === 1 && import_compiler53.types.isBlockStatement(body[0])) {
|
|
11446
10927
|
body = body[0].body;
|
|
11447
10928
|
}
|
|
@@ -11462,7 +10943,7 @@ var server_default = {
|
|
|
11462
10943
|
|
|
11463
10944
|
// src/translator/core/static.ts
|
|
11464
10945
|
var import_compiler54 = require("@marko/compiler");
|
|
11465
|
-
var
|
|
10946
|
+
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
|
11466
10947
|
var static_default = {
|
|
11467
10948
|
parse(tag) {
|
|
11468
10949
|
const {
|
|
@@ -11472,7 +10953,7 @@ var static_default = {
|
|
|
11472
10953
|
const rawValue = node.rawValue;
|
|
11473
10954
|
const code = rawValue.replace(/^static\s*/, "");
|
|
11474
10955
|
const start = node.start + (rawValue.length - code.length);
|
|
11475
|
-
let body = (0,
|
|
10956
|
+
let body = (0, import_babel_utils43.parseStatements)(file, code, start, start + code.length);
|
|
11476
10957
|
if (body.length === 1 && import_compiler54.types.isBlockStatement(body[0])) {
|
|
11477
10958
|
body = body[0].body;
|
|
11478
10959
|
}
|
|
@@ -11493,16 +10974,16 @@ var static_default = {
|
|
|
11493
10974
|
|
|
11494
10975
|
// src/translator/core/style.ts
|
|
11495
10976
|
var import_compiler55 = require("@marko/compiler");
|
|
11496
|
-
var
|
|
10977
|
+
var import_babel_utils44 = require("@marko/compiler/babel-utils");
|
|
11497
10978
|
var import_magic_string = __toESM(require("magic-string"));
|
|
11498
10979
|
var import_path3 = __toESM(require("path"));
|
|
11499
10980
|
var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
|
11500
10981
|
var htmlStyleTagAlternateMsg = " For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.";
|
|
11501
10982
|
var style_default = {
|
|
11502
10983
|
analyze(tag) {
|
|
11503
|
-
(0,
|
|
11504
|
-
(0,
|
|
11505
|
-
(0,
|
|
10984
|
+
(0, import_babel_utils44.assertNoArgs)(tag);
|
|
10985
|
+
(0, import_babel_utils44.assertNoParams)(tag);
|
|
10986
|
+
(0, import_babel_utils44.assertNoAttributeTags)(tag);
|
|
11506
10987
|
const { node } = tag;
|
|
11507
10988
|
const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
|
|
11508
10989
|
for (const attr of node.attributes) {
|
|
@@ -11541,8 +11022,8 @@ var style_default = {
|
|
|
11541
11022
|
}
|
|
11542
11023
|
const markoText = node.body.body[0];
|
|
11543
11024
|
const { resolveVirtualDependency } = getMarkoOpts();
|
|
11544
|
-
const start = (0,
|
|
11545
|
-
const end = (0,
|
|
11025
|
+
const start = (0, import_babel_utils44.getStart)(file, markoText);
|
|
11026
|
+
const end = (0, import_babel_utils44.getEnd)(file, markoText);
|
|
11546
11027
|
let code = markoText.value;
|
|
11547
11028
|
let map;
|
|
11548
11029
|
if (resolveVirtualDependency && sourceMaps && start !== null && end !== null) {
|
|
@@ -11552,422 +11033,63 @@ var style_default = {
|
|
|
11552
11033
|
map = magicString.generateMap({
|
|
11553
11034
|
source: filename,
|
|
11554
11035
|
includeContent: true
|
|
11555
|
-
});
|
|
11556
|
-
if (sourceMaps === "inline" || sourceMaps === "both") {
|
|
11557
|
-
code += `
|
|
11558
|
-
/*# sourceMappingURL=${map.toUrl()}*/`;
|
|
11559
|
-
if (sourceMaps === "inline") {
|
|
11560
|
-
map = void 0;
|
|
11561
|
-
}
|
|
11562
|
-
}
|
|
11563
|
-
}
|
|
11564
|
-
const importPath = resolveVirtualDependency?.(filename, {
|
|
11565
|
-
virtualPath: `./${import_path3.default.basename(filename) + ext}`,
|
|
11566
|
-
code,
|
|
11567
|
-
map
|
|
11568
|
-
});
|
|
11569
|
-
if (importPath) {
|
|
11570
|
-
if (!node.var) {
|
|
11571
|
-
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11572
|
-
import_compiler55.types.importDeclaration([], import_compiler55.types.stringLiteral(importPath))
|
|
11573
|
-
);
|
|
11574
|
-
} else if (import_compiler55.types.isIdentifier(node.var)) {
|
|
11575
|
-
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11576
|
-
import_compiler55.types.importDeclaration(
|
|
11577
|
-
[import_compiler55.types.importNamespaceSpecifier(node.var)],
|
|
11578
|
-
import_compiler55.types.stringLiteral(importPath)
|
|
11579
|
-
)
|
|
11580
|
-
);
|
|
11581
|
-
} else {
|
|
11582
|
-
const varDecl = import_compiler55.types.variableDeclaration("const", [
|
|
11583
|
-
import_compiler55.types.variableDeclarator(node.var, (0, import_babel_utils45.importStar)(file, importPath, "style"))
|
|
11584
|
-
]);
|
|
11585
|
-
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11586
|
-
isOutputDOM() ? varDecl : import_compiler55.types.markoScriptlet([varDecl], true)
|
|
11587
|
-
);
|
|
11588
|
-
}
|
|
11589
|
-
}
|
|
11590
|
-
tag.remove();
|
|
11591
|
-
},
|
|
11592
|
-
parseOptions: {
|
|
11593
|
-
html: false,
|
|
11594
|
-
text: true,
|
|
11595
|
-
rawOpenTag: true,
|
|
11596
|
-
preserveWhitespace: true
|
|
11597
|
-
},
|
|
11598
|
-
attributes: {}
|
|
11599
|
-
};
|
|
11600
|
-
|
|
11601
|
-
// src/translator/core/textarea.ts
|
|
11602
|
-
var import_compiler56 = require("@marko/compiler");
|
|
11603
|
-
var textarea_default = {
|
|
11604
|
-
parse(tag) {
|
|
11605
|
-
if (tag.node.body.body.length) {
|
|
11606
|
-
const parts = [];
|
|
11607
|
-
for (const child of tag.node.body.body) {
|
|
11608
|
-
if (child.type === "MarkoText" || child.type === "MarkoPlaceholder" && child.escape) {
|
|
11609
|
-
parts.push(child.value);
|
|
11610
|
-
} else {
|
|
11611
|
-
throw tag.hub.file.hub.buildError(
|
|
11612
|
-
child,
|
|
11613
|
-
"Unexpected content in textarea, only text and placeholders are supported.",
|
|
11614
|
-
SyntaxError
|
|
11615
|
-
);
|
|
11616
|
-
}
|
|
11617
|
-
}
|
|
11618
|
-
tag.node.attributes.push(
|
|
11619
|
-
import_compiler56.types.markoAttribute(
|
|
11620
|
-
"value",
|
|
11621
|
-
normalizeStringExpression(parts) || buildUndefined3()
|
|
11622
|
-
)
|
|
11623
|
-
);
|
|
11624
|
-
tag.node.body.body = [];
|
|
11625
|
-
}
|
|
11626
|
-
},
|
|
11627
|
-
parseOptions: {
|
|
11628
|
-
text: true,
|
|
11629
|
-
preserveWhitespace: true
|
|
11630
|
-
}
|
|
11631
|
-
};
|
|
11632
|
-
function buildUndefined3() {
|
|
11633
|
-
return import_compiler56.types.unaryExpression("void", import_compiler56.types.numericLiteral(0));
|
|
11634
|
-
}
|
|
11635
|
-
|
|
11636
|
-
// src/translator/core/title.ts
|
|
11637
|
-
var import_compiler57 = require("@marko/compiler");
|
|
11638
|
-
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
11639
|
-
var kNodeBinding4 = Symbol("title tag node binding");
|
|
11640
|
-
var title_default = {
|
|
11641
|
-
analyze(tag) {
|
|
11642
|
-
(0, import_babel_utils46.assertNoArgs)(tag);
|
|
11643
|
-
(0, import_babel_utils46.assertNoParams)(tag);
|
|
11644
|
-
const { node } = tag;
|
|
11645
|
-
if (node.var && !import_compiler57.types.isIdentifier(node.var)) {
|
|
11646
|
-
throw tag.get("var").buildCodeFrameError(
|
|
11647
|
-
"Tag variables on native elements cannot be destructured."
|
|
11648
|
-
);
|
|
11649
|
-
}
|
|
11650
|
-
const seen = {};
|
|
11651
|
-
const { attributes } = tag.node;
|
|
11652
|
-
let spreadReferenceNodes;
|
|
11653
|
-
let exprExtras;
|
|
11654
|
-
let hasEventHandlers = false;
|
|
11655
|
-
let hasDynamicAttributes = false;
|
|
11656
|
-
for (let i = attributes.length; i--; ) {
|
|
11657
|
-
const attr = attributes[i];
|
|
11658
|
-
const valueExtra = attr.value.extra ??= {};
|
|
11659
|
-
if (import_compiler57.types.isMarkoAttribute(attr)) {
|
|
11660
|
-
if (seen[attr.name]) {
|
|
11661
|
-
dropReferences(attr.value);
|
|
11662
|
-
continue;
|
|
11663
|
-
}
|
|
11664
|
-
seen[attr.name] = attr;
|
|
11665
|
-
if (isEventHandler(attr.name)) {
|
|
11666
|
-
valueExtra.isEffect = true;
|
|
11667
|
-
hasEventHandlers = true;
|
|
11668
|
-
} else if (!evaluate(attr.value).confident) {
|
|
11669
|
-
hasDynamicAttributes = true;
|
|
11036
|
+
});
|
|
11037
|
+
if (sourceMaps === "inline" || sourceMaps === "both") {
|
|
11038
|
+
code += `
|
|
11039
|
+
/*# sourceMappingURL=${map.toUrl()}*/`;
|
|
11040
|
+
if (sourceMaps === "inline") {
|
|
11041
|
+
map = void 0;
|
|
11670
11042
|
}
|
|
11671
|
-
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11672
|
-
valueExtra.isEffect = true;
|
|
11673
|
-
hasEventHandlers = true;
|
|
11674
|
-
hasDynamicAttributes = true;
|
|
11675
|
-
}
|
|
11676
|
-
if (spreadReferenceNodes) {
|
|
11677
|
-
spreadReferenceNodes.push(attr.value);
|
|
11678
|
-
} else if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11679
|
-
spreadReferenceNodes = [attr.value];
|
|
11680
|
-
} else {
|
|
11681
|
-
exprExtras = push(exprExtras, valueExtra);
|
|
11682
11043
|
}
|
|
11683
11044
|
}
|
|
11684
|
-
const
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
|
|
11688
|
-
|
|
11689
|
-
|
|
11690
|
-
|
|
11691
|
-
|
|
11692
|
-
|
|
11693
|
-
"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))
|
|
11694
11054
|
);
|
|
11695
|
-
}
|
|
11696
|
-
|
|
11697
|
-
|
|
11698
|
-
|
|
11699
|
-
|
|
11700
|
-
const nodeBinding = tagExtra[kNodeBinding4] = createBinding(
|
|
11701
|
-
"#title",
|
|
11702
|
-
0 /* dom */,
|
|
11703
|
-
tagSection
|
|
11704
|
-
);
|
|
11705
|
-
if (hasEventHandlers) {
|
|
11706
|
-
(0, import_babel_utils46.getProgram)().node.extra.isInteractive = true;
|
|
11707
|
-
}
|
|
11708
|
-
if (spreadReferenceNodes) {
|
|
11709
|
-
mergeReferences(tagSection, tag.node, spreadReferenceNodes);
|
|
11710
|
-
}
|
|
11711
|
-
if (hasBodyPlaceholders) {
|
|
11712
|
-
exprExtras = push(
|
|
11713
|
-
exprExtras,
|
|
11714
|
-
bodyPlaceholderNodes.length === 1 ? bodyPlaceholderNodes[0].extra ??= {} : mergeReferences(
|
|
11715
|
-
tagSection,
|
|
11716
|
-
bodyPlaceholderNodes[0],
|
|
11717
|
-
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)
|
|
11718
11060
|
)
|
|
11719
11061
|
);
|
|
11720
|
-
}
|
|
11721
|
-
trackDomVarReferences(tag, nodeBinding);
|
|
11722
|
-
addSerializeExpr(
|
|
11723
|
-
tagSection,
|
|
11724
|
-
!!(node.var || hasEventHandlers),
|
|
11725
|
-
nodeBinding
|
|
11726
|
-
);
|
|
11727
|
-
addSerializeExpr(tagSection, push(exprExtras, tagExtra), nodeBinding);
|
|
11728
|
-
}
|
|
11729
|
-
},
|
|
11730
|
-
translate: {
|
|
11731
|
-
enter(tag) {
|
|
11732
|
-
const tagExtra = tag.node.extra;
|
|
11733
|
-
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11734
|
-
const isHTML = isOutputHTML();
|
|
11735
|
-
const write = writeTo(tag);
|
|
11736
|
-
const tagSection = getSection(tag);
|
|
11737
|
-
if (isHTML) {
|
|
11738
|
-
translateDomVar(tag, nodeBinding);
|
|
11739
|
-
}
|
|
11740
|
-
if (nodeBinding) {
|
|
11741
|
-
visit(tag, 32 /* Get */);
|
|
11742
|
-
}
|
|
11743
|
-
write`<title`;
|
|
11744
|
-
const usedAttrs = getUsedAttrs4(tag.node);
|
|
11745
|
-
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
|
11746
|
-
for (const attr of staticAttrs) {
|
|
11747
|
-
const { name: name2, value } = attr;
|
|
11748
|
-
const { confident, computed } = value.extra || {};
|
|
11749
|
-
const valueReferences = value.extra?.referencedBindings;
|
|
11750
|
-
switch (name2) {
|
|
11751
|
-
case "class":
|
|
11752
|
-
case "style": {
|
|
11753
|
-
const helper = `_attr_${name2}`;
|
|
11754
|
-
if (confident) {
|
|
11755
|
-
write`${getHTMLRuntime()[helper](computed)}`;
|
|
11756
|
-
} else if (isHTML) {
|
|
11757
|
-
write`${callRuntime(helper, value)}`;
|
|
11758
|
-
} else {
|
|
11759
|
-
addStatement(
|
|
11760
|
-
"render",
|
|
11761
|
-
tagSection,
|
|
11762
|
-
valueReferences,
|
|
11763
|
-
import_compiler57.types.expressionStatement(
|
|
11764
|
-
callRuntime(
|
|
11765
|
-
helper,
|
|
11766
|
-
createScopeReadExpression(nodeBinding),
|
|
11767
|
-
value
|
|
11768
|
-
)
|
|
11769
|
-
)
|
|
11770
|
-
);
|
|
11771
|
-
}
|
|
11772
|
-
break;
|
|
11773
|
-
}
|
|
11774
|
-
default:
|
|
11775
|
-
if (confident) {
|
|
11776
|
-
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
|
11777
|
-
} else if (isHTML) {
|
|
11778
|
-
if (isEventHandler(name2)) {
|
|
11779
|
-
addHTMLEffectCall(tagSection, valueReferences);
|
|
11780
|
-
} else {
|
|
11781
|
-
write`${callRuntime("_attr", import_compiler57.types.stringLiteral(name2), value)}`;
|
|
11782
|
-
}
|
|
11783
|
-
} else if (isEventHandler(name2)) {
|
|
11784
|
-
addStatement(
|
|
11785
|
-
"effect",
|
|
11786
|
-
tagSection,
|
|
11787
|
-
valueReferences,
|
|
11788
|
-
import_compiler57.types.expressionStatement(
|
|
11789
|
-
callRuntime(
|
|
11790
|
-
"_on",
|
|
11791
|
-
createScopeReadExpression(nodeBinding),
|
|
11792
|
-
import_compiler57.types.stringLiteral(getEventHandlerName(name2)),
|
|
11793
|
-
value
|
|
11794
|
-
)
|
|
11795
|
-
)
|
|
11796
|
-
);
|
|
11797
|
-
} else {
|
|
11798
|
-
addStatement(
|
|
11799
|
-
"render",
|
|
11800
|
-
tagSection,
|
|
11801
|
-
valueReferences,
|
|
11802
|
-
import_compiler57.types.expressionStatement(
|
|
11803
|
-
callRuntime(
|
|
11804
|
-
"_attr",
|
|
11805
|
-
createScopeReadExpression(nodeBinding),
|
|
11806
|
-
import_compiler57.types.stringLiteral(name2),
|
|
11807
|
-
value
|
|
11808
|
-
)
|
|
11809
|
-
)
|
|
11810
|
-
);
|
|
11811
|
-
}
|
|
11812
|
-
break;
|
|
11813
|
-
}
|
|
11814
|
-
}
|
|
11815
|
-
if (spreadExpression) {
|
|
11816
|
-
const visitAccessor = getScopeAccessorLiteral(nodeBinding);
|
|
11817
|
-
if (isHTML) {
|
|
11818
|
-
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
|
11819
|
-
if (skipExpression) {
|
|
11820
|
-
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11821
|
-
} else {
|
|
11822
|
-
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler57.types.stringLiteral("title"))}`;
|
|
11823
|
-
}
|
|
11824
|
-
} else {
|
|
11825
|
-
if (skipExpression) {
|
|
11826
|
-
addStatement(
|
|
11827
|
-
"render",
|
|
11828
|
-
tagSection,
|
|
11829
|
-
tagExtra.referencedBindings,
|
|
11830
|
-
import_compiler57.types.expressionStatement(
|
|
11831
|
-
callRuntime(
|
|
11832
|
-
"_attrs_partial",
|
|
11833
|
-
scopeIdentifier,
|
|
11834
|
-
visitAccessor,
|
|
11835
|
-
spreadExpression,
|
|
11836
|
-
skipExpression
|
|
11837
|
-
)
|
|
11838
|
-
)
|
|
11839
|
-
);
|
|
11840
|
-
} else {
|
|
11841
|
-
addStatement(
|
|
11842
|
-
"render",
|
|
11843
|
-
tagSection,
|
|
11844
|
-
tagExtra.referencedBindings,
|
|
11845
|
-
import_compiler57.types.expressionStatement(
|
|
11846
|
-
callRuntime(
|
|
11847
|
-
"_attrs",
|
|
11848
|
-
scopeIdentifier,
|
|
11849
|
-
visitAccessor,
|
|
11850
|
-
spreadExpression
|
|
11851
|
-
)
|
|
11852
|
-
)
|
|
11853
|
-
);
|
|
11854
|
-
}
|
|
11855
|
-
addStatement(
|
|
11856
|
-
"effect",
|
|
11857
|
-
tagSection,
|
|
11858
|
-
tagExtra.referencedBindings,
|
|
11859
|
-
import_compiler57.types.expressionStatement(
|
|
11860
|
-
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
|
11861
|
-
),
|
|
11862
|
-
false
|
|
11863
|
-
);
|
|
11864
|
-
}
|
|
11865
|
-
}
|
|
11866
|
-
write`>`;
|
|
11867
|
-
enter2(tag);
|
|
11868
|
-
},
|
|
11869
|
-
exit(tag) {
|
|
11870
|
-
const tagSection = getSection(tag);
|
|
11871
|
-
const tagExtra = tag.node.extra;
|
|
11872
|
-
const nodeBinding = tagExtra[kNodeBinding4];
|
|
11873
|
-
const write = writeTo(tag);
|
|
11874
|
-
if (isOutputHTML()) {
|
|
11875
|
-
for (const child of tag.node.body.body) {
|
|
11876
|
-
if (import_compiler57.types.isMarkoText(child)) {
|
|
11877
|
-
write`${child.value}`;
|
|
11878
|
-
} else if (import_compiler57.types.isMarkoPlaceholder(child)) {
|
|
11879
|
-
write`${callRuntime("_to_text", child.value)}`;
|
|
11880
|
-
}
|
|
11881
|
-
}
|
|
11882
11062
|
} else {
|
|
11883
|
-
const
|
|
11884
|
-
|
|
11885
|
-
|
|
11886
|
-
|
|
11887
|
-
|
|
11888
|
-
"render",
|
|
11889
|
-
getSection(tag),
|
|
11890
|
-
textLiteral.extra?.referencedBindings,
|
|
11891
|
-
import_compiler57.types.expressionStatement(
|
|
11892
|
-
callRuntime(
|
|
11893
|
-
"_text_content",
|
|
11894
|
-
createScopeReadExpression(nodeBinding),
|
|
11895
|
-
textLiteral
|
|
11896
|
-
)
|
|
11897
|
-
)
|
|
11898
|
-
);
|
|
11899
|
-
}
|
|
11900
|
-
}
|
|
11901
|
-
write`</title>`;
|
|
11902
|
-
if (nodeBinding) {
|
|
11903
|
-
markNode(
|
|
11904
|
-
tag,
|
|
11905
|
-
nodeBinding,
|
|
11906
|
-
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)
|
|
11907
11068
|
);
|
|
11908
11069
|
}
|
|
11909
|
-
exit2(tag);
|
|
11910
|
-
tag.remove();
|
|
11911
11070
|
}
|
|
11071
|
+
tag.remove();
|
|
11912
11072
|
},
|
|
11913
11073
|
parseOptions: {
|
|
11914
|
-
|
|
11915
|
-
|
|
11074
|
+
html: false,
|
|
11075
|
+
text: true,
|
|
11076
|
+
rawOpenTag: true,
|
|
11077
|
+
preserveWhitespace: true
|
|
11078
|
+
},
|
|
11079
|
+
attributes: {}
|
|
11916
11080
|
};
|
|
11917
|
-
function getUsedAttrs4(tag) {
|
|
11918
|
-
const seen = {};
|
|
11919
|
-
const { attributes } = tag;
|
|
11920
|
-
const maybeStaticAttrs = /* @__PURE__ */ new Set();
|
|
11921
|
-
let spreadExpression;
|
|
11922
|
-
let skipExpression;
|
|
11923
|
-
let spreadProps;
|
|
11924
|
-
let skipProps;
|
|
11925
|
-
for (let i = attributes.length; i--; ) {
|
|
11926
|
-
const attr = attributes[i];
|
|
11927
|
-
const { value } = attr;
|
|
11928
|
-
if (import_compiler57.types.isMarkoSpreadAttribute(attr)) {
|
|
11929
|
-
if (!spreadProps) {
|
|
11930
|
-
spreadProps = [];
|
|
11931
|
-
}
|
|
11932
|
-
spreadProps.push(import_compiler57.types.spreadElement(value));
|
|
11933
|
-
} else if (!seen[attr.name]) {
|
|
11934
|
-
seen[attr.name] = attr;
|
|
11935
|
-
if (spreadProps) {
|
|
11936
|
-
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
|
11937
|
-
} else {
|
|
11938
|
-
maybeStaticAttrs.add(attr);
|
|
11939
|
-
}
|
|
11940
|
-
}
|
|
11941
|
-
}
|
|
11942
|
-
const staticAttrs = [...maybeStaticAttrs].reverse();
|
|
11943
|
-
if (spreadProps) {
|
|
11944
|
-
spreadProps.reverse();
|
|
11945
|
-
for (const { name: name2 } of staticAttrs) {
|
|
11946
|
-
(skipProps ||= []).push(toObjectProperty(name2, import_compiler57.types.numericLiteral(1)));
|
|
11947
|
-
}
|
|
11948
|
-
if (skipProps) {
|
|
11949
|
-
skipExpression = import_compiler57.types.objectExpression(skipProps);
|
|
11950
|
-
}
|
|
11951
|
-
spreadExpression = propsToExpression(spreadProps);
|
|
11952
|
-
}
|
|
11953
|
-
return {
|
|
11954
|
-
staticAttrs,
|
|
11955
|
-
spreadExpression,
|
|
11956
|
-
skipExpression
|
|
11957
|
-
};
|
|
11958
|
-
}
|
|
11959
11081
|
|
|
11960
11082
|
// src/translator/core/try.ts
|
|
11961
|
-
var
|
|
11962
|
-
var
|
|
11083
|
+
var import_compiler56 = require("@marko/compiler");
|
|
11084
|
+
var import_babel_utils45 = require("@marko/compiler/babel-utils");
|
|
11963
11085
|
var hasEnabledCatch = /* @__PURE__ */ new WeakSet();
|
|
11964
11086
|
var kDOMBinding2 = Symbol("try tag dom binding");
|
|
11965
11087
|
var try_default = {
|
|
11966
11088
|
analyze(tag) {
|
|
11967
|
-
(0,
|
|
11968
|
-
(0,
|
|
11969
|
-
(0,
|
|
11970
|
-
(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);
|
|
11971
11093
|
assertNoSpreadAttrs(tag);
|
|
11972
11094
|
analyzeAttributeTags(tag);
|
|
11973
11095
|
const section = getOrCreateSection(tag);
|
|
@@ -12019,7 +11141,7 @@ var try_default = {
|
|
|
12019
11141
|
writeHTMLResumeStatements(tagBody);
|
|
12020
11142
|
tag.insertBefore(translatedAttrs.statements);
|
|
12021
11143
|
tag.replaceWith(
|
|
12022
|
-
|
|
11144
|
+
import_compiler56.types.expressionStatement(
|
|
12023
11145
|
callRuntime(
|
|
12024
11146
|
"_try",
|
|
12025
11147
|
getScopeIdIdentifier(section),
|
|
@@ -12074,11 +11196,11 @@ var try_default = {
|
|
|
12074
11196
|
translatedAttrs.statements
|
|
12075
11197
|
);
|
|
12076
11198
|
}
|
|
12077
|
-
const program = (0,
|
|
11199
|
+
const program = (0, import_babel_utils45.getProgram)().node;
|
|
12078
11200
|
if (!hasEnabledCatch.has(program)) {
|
|
12079
11201
|
hasEnabledCatch.add(program);
|
|
12080
11202
|
program.body.push(
|
|
12081
|
-
|
|
11203
|
+
import_compiler56.types.expressionStatement(callRuntime("_enable_catch"))
|
|
12082
11204
|
);
|
|
12083
11205
|
}
|
|
12084
11206
|
addValue(
|
|
@@ -12129,8 +11251,6 @@ var core_default = {
|
|
|
12129
11251
|
"<server>": server_default,
|
|
12130
11252
|
"<static>": static_default,
|
|
12131
11253
|
"<style>": style_default,
|
|
12132
|
-
"<textarea>": textarea_default,
|
|
12133
|
-
"<title>": title_default,
|
|
12134
11254
|
"<try>": try_default
|
|
12135
11255
|
};
|
|
12136
11256
|
|
|
@@ -12178,13 +11298,13 @@ var document_type_default = {
|
|
|
12178
11298
|
};
|
|
12179
11299
|
|
|
12180
11300
|
// src/translator/visitors/import-declaration.ts
|
|
12181
|
-
var
|
|
11301
|
+
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
12182
11302
|
var import_declaration_default = {
|
|
12183
11303
|
analyze(importDecl) {
|
|
12184
11304
|
const { node } = importDecl;
|
|
12185
11305
|
const { source } = node;
|
|
12186
11306
|
const { value } = source;
|
|
12187
|
-
const tagImport = (0,
|
|
11307
|
+
const tagImport = (0, import_babel_utils46.resolveTagImport)(importDecl, value);
|
|
12188
11308
|
if (tagImport) {
|
|
12189
11309
|
node.extra ??= {};
|
|
12190
11310
|
node.extra.tagImport = tagImport;
|
|
@@ -12207,26 +11327,8 @@ var import_declaration_default = {
|
|
|
12207
11327
|
};
|
|
12208
11328
|
|
|
12209
11329
|
// src/translator/visitors/placeholder.ts
|
|
12210
|
-
var
|
|
12211
|
-
|
|
12212
|
-
// src/translator/util/is-non-html-text.ts
|
|
12213
|
-
var import_compiler59 = require("@marko/compiler");
|
|
12214
|
-
function isNonHTMLText(placeholder) {
|
|
12215
|
-
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
12216
|
-
if (parentTag && isCoreTag(parentTag)) {
|
|
12217
|
-
switch (parentTag.node.name.value) {
|
|
12218
|
-
case "html-comment":
|
|
12219
|
-
case "html-script":
|
|
12220
|
-
case "html-style":
|
|
12221
|
-
case "title":
|
|
12222
|
-
return true;
|
|
12223
|
-
}
|
|
12224
|
-
}
|
|
12225
|
-
return false;
|
|
12226
|
-
}
|
|
12227
|
-
|
|
12228
|
-
// src/translator/visitors/placeholder.ts
|
|
12229
|
-
var kNodeBinding5 = Symbol("placeholder node binding");
|
|
11330
|
+
var import_compiler57 = require("@marko/compiler");
|
|
11331
|
+
var kNodeBinding2 = Symbol("placeholder node binding");
|
|
12230
11332
|
var kSiblingText = Symbol("placeholder has sibling text");
|
|
12231
11333
|
var kSharedText = Symbol(
|
|
12232
11334
|
"placeholder will merge its visitor with a another node"
|
|
@@ -12244,7 +11346,7 @@ var placeholder_default = {
|
|
|
12244
11346
|
}
|
|
12245
11347
|
} else {
|
|
12246
11348
|
const section = getOrCreateSection(placeholder);
|
|
12247
|
-
const nodeBinding = (node.extra ??= {})[
|
|
11349
|
+
const nodeBinding = (node.extra ??= {})[kNodeBinding2] = createBinding(
|
|
12248
11350
|
"#text",
|
|
12249
11351
|
0 /* dom */,
|
|
12250
11352
|
section
|
|
@@ -12267,7 +11369,7 @@ var placeholder_default = {
|
|
|
12267
11369
|
const isHTML = isOutputHTML();
|
|
12268
11370
|
const write = writeTo(placeholder);
|
|
12269
11371
|
const extra = node.extra || {};
|
|
12270
|
-
const nodeBinding = extra[
|
|
11372
|
+
const nodeBinding = extra[kNodeBinding2];
|
|
12271
11373
|
const canWriteHTML = isHTML || confident && node.escape;
|
|
12272
11374
|
const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
|
|
12273
11375
|
if (confident && canWriteHTML) {
|
|
@@ -12301,7 +11403,7 @@ var placeholder_default = {
|
|
|
12301
11403
|
"render",
|
|
12302
11404
|
getSection(placeholder),
|
|
12303
11405
|
valueExtra.referencedBindings,
|
|
12304
|
-
|
|
11406
|
+
import_compiler57.types.expressionStatement(
|
|
12305
11407
|
method === "_text" ? callRuntime(
|
|
12306
11408
|
"_text",
|
|
12307
11409
|
createScopeReadExpression(nodeBinding),
|
|
@@ -12339,7 +11441,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
12339
11441
|
break;
|
|
12340
11442
|
}
|
|
12341
11443
|
}
|
|
12342
|
-
if (!prev.node &&
|
|
11444
|
+
if (!prev.node && import_compiler57.types.isProgram(placeholder.parentPath)) {
|
|
12343
11445
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
|
12344
11446
|
}
|
|
12345
11447
|
let next = placeholder.getNextSibling();
|
|
@@ -12356,7 +11458,7 @@ function analyzeSiblingText(placeholder) {
|
|
|
12356
11458
|
break;
|
|
12357
11459
|
}
|
|
12358
11460
|
}
|
|
12359
|
-
if (!next.node &&
|
|
11461
|
+
if (!next.node && import_compiler57.types.isProgram(placeholder.parentPath)) {
|
|
12360
11462
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
|
12361
11463
|
}
|
|
12362
11464
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
|
@@ -12398,7 +11500,7 @@ function isEmptyPlaceholder(placeholder) {
|
|
|
12398
11500
|
}
|
|
12399
11501
|
|
|
12400
11502
|
// src/translator/visitors/referenced-identifier.ts
|
|
12401
|
-
var
|
|
11503
|
+
var import_compiler58 = require("@marko/compiler");
|
|
12402
11504
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
|
12403
11505
|
var referenced_identifier_default = {
|
|
12404
11506
|
migrate(identifier) {
|
|
@@ -12406,8 +11508,8 @@ var referenced_identifier_default = {
|
|
|
12406
11508
|
if (identifier.scope.hasBinding(name2)) return;
|
|
12407
11509
|
switch (name2) {
|
|
12408
11510
|
case "out":
|
|
12409
|
-
if (
|
|
12410
|
-
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"));
|
|
12411
11513
|
} else {
|
|
12412
11514
|
throw identifier.buildCodeFrameError(
|
|
12413
11515
|
"Only `out.global` is supported for compatibility."
|
|
@@ -12434,13 +11536,13 @@ var referenced_identifier_default = {
|
|
|
12434
11536
|
case "$global":
|
|
12435
11537
|
if (isOutputHTML()) {
|
|
12436
11538
|
identifier.replaceWith(
|
|
12437
|
-
|
|
11539
|
+
import_compiler58.types.callExpression(importRuntime("$global"), [])
|
|
12438
11540
|
);
|
|
12439
11541
|
} else {
|
|
12440
11542
|
identifier.replaceWith(
|
|
12441
|
-
|
|
11543
|
+
import_compiler58.types.memberExpression(
|
|
12442
11544
|
scopeIdentifier,
|
|
12443
|
-
|
|
11545
|
+
import_compiler58.types.identifier(getAccessorProp().Global)
|
|
12444
11546
|
)
|
|
12445
11547
|
);
|
|
12446
11548
|
}
|
|
@@ -12448,13 +11550,13 @@ var referenced_identifier_default = {
|
|
|
12448
11550
|
case "$signal":
|
|
12449
11551
|
if (isOutputHTML()) {
|
|
12450
11552
|
identifier.replaceWith(
|
|
12451
|
-
|
|
12452
|
-
|
|
11553
|
+
import_compiler58.types.callExpression(
|
|
11554
|
+
import_compiler58.types.arrowFunctionExpression(
|
|
12453
11555
|
[],
|
|
12454
|
-
|
|
12455
|
-
|
|
12456
|
-
|
|
12457
|
-
|
|
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.")
|
|
12458
11560
|
])
|
|
12459
11561
|
)
|
|
12460
11562
|
])
|
|
@@ -12480,19 +11582,19 @@ var referenced_identifier_default = {
|
|
|
12480
11582
|
"render",
|
|
12481
11583
|
section,
|
|
12482
11584
|
exprRoot.node.extra?.referencedBindings,
|
|
12483
|
-
|
|
12484
|
-
|
|
11585
|
+
import_compiler58.types.expressionStatement(
|
|
11586
|
+
import_compiler58.types.callExpression(importRuntime("$signalReset"), [
|
|
12485
11587
|
scopeIdentifier,
|
|
12486
|
-
|
|
11588
|
+
import_compiler58.types.numericLiteral(exprId)
|
|
12487
11589
|
])
|
|
12488
11590
|
),
|
|
12489
11591
|
false
|
|
12490
11592
|
);
|
|
12491
11593
|
}
|
|
12492
11594
|
identifier.replaceWith(
|
|
12493
|
-
|
|
11595
|
+
import_compiler58.types.callExpression(importRuntime("$signal"), [
|
|
12494
11596
|
scopeIdentifier,
|
|
12495
|
-
|
|
11597
|
+
import_compiler58.types.numericLiteral(exprId)
|
|
12496
11598
|
])
|
|
12497
11599
|
);
|
|
12498
11600
|
}
|
|
@@ -12501,7 +11603,7 @@ var referenced_identifier_default = {
|
|
|
12501
11603
|
};
|
|
12502
11604
|
|
|
12503
11605
|
// src/translator/visitors/scriptlet.ts
|
|
12504
|
-
var
|
|
11606
|
+
var import_babel_utils47 = require("@marko/compiler/babel-utils");
|
|
12505
11607
|
var scriptlet_default = {
|
|
12506
11608
|
analyze(scriptlet) {
|
|
12507
11609
|
if (!scriptlet.node.static) {
|
|
@@ -12515,7 +11617,7 @@ var scriptlet_default = {
|
|
|
12515
11617
|
scriptlet.node.body
|
|
12516
11618
|
);
|
|
12517
11619
|
if (scriptlet.node.target === "client") {
|
|
12518
|
-
(0,
|
|
11620
|
+
(0, import_babel_utils47.getProgram)().node.extra.isInteractive = true;
|
|
12519
11621
|
}
|
|
12520
11622
|
},
|
|
12521
11623
|
translate: {
|
|
@@ -12536,21 +11638,21 @@ var scriptlet_default = {
|
|
|
12536
11638
|
};
|
|
12537
11639
|
|
|
12538
11640
|
// src/translator/visitors/tag/index.ts
|
|
12539
|
-
var
|
|
12540
|
-
var
|
|
11641
|
+
var import_compiler62 = require("@marko/compiler");
|
|
11642
|
+
var import_babel_utils51 = require("@marko/compiler/babel-utils");
|
|
12541
11643
|
|
|
12542
11644
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
12543
|
-
var
|
|
12544
|
-
var
|
|
11645
|
+
var import_compiler59 = require("@marko/compiler");
|
|
11646
|
+
var import_babel_utils48 = require("@marko/compiler/babel-utils");
|
|
12545
11647
|
var attribute_tag_default = {
|
|
12546
11648
|
analyze: {
|
|
12547
11649
|
enter(tag) {
|
|
12548
|
-
(0,
|
|
12549
|
-
(0,
|
|
11650
|
+
(0, import_babel_utils48.assertNoVar)(tag);
|
|
11651
|
+
(0, import_babel_utils48.assertNoArgs)(tag);
|
|
12550
11652
|
const body = tag.get("body");
|
|
12551
11653
|
startSection(body);
|
|
12552
11654
|
trackParamsReferences(body, 3 /* param */);
|
|
12553
|
-
if (!(0,
|
|
11655
|
+
if (!(0, import_babel_utils48.findParentTag)(tag)) {
|
|
12554
11656
|
throw tag.get("name").buildCodeFrameError(
|
|
12555
11657
|
"[Attribute tags](https://markojs.com/docs/reference/language#attribute-tags) must be nested within another tag."
|
|
12556
11658
|
);
|
|
@@ -12573,13 +11675,13 @@ var attribute_tag_default = {
|
|
|
12573
11675
|
};
|
|
12574
11676
|
|
|
12575
11677
|
// src/translator/visitors/tag/custom-tag.ts
|
|
12576
|
-
var
|
|
12577
|
-
var
|
|
11678
|
+
var import_compiler60 = require("@marko/compiler");
|
|
11679
|
+
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
12578
11680
|
var import_path4 = __toESM(require("path"));
|
|
12579
11681
|
var custom_tag_default = {
|
|
12580
11682
|
analyze: {
|
|
12581
11683
|
enter(tag) {
|
|
12582
|
-
const templateFile = (0,
|
|
11684
|
+
const templateFile = (0, import_babel_utils49.getTagTemplate)(tag);
|
|
12583
11685
|
if (!templateFile) {
|
|
12584
11686
|
const tagName = getTagName(tag);
|
|
12585
11687
|
if (tagName && tag.scope.hasBinding(tagName)) {
|
|
@@ -12591,12 +11693,12 @@ var custom_tag_default = {
|
|
|
12591
11693
|
`Unable to find entry point for [custom tag](https://markojs.com/docs/reference/custom-tag#relative-custom-tags) \`<${tagName}>\`.`
|
|
12592
11694
|
);
|
|
12593
11695
|
}
|
|
12594
|
-
(0,
|
|
12595
|
-
const childFile = (0,
|
|
11696
|
+
(0, import_babel_utils49.assertAttributesOrSingleArg)(tag);
|
|
11697
|
+
const childFile = (0, import_babel_utils49.loadFileForTag)(tag);
|
|
12596
11698
|
if (!childFile) {
|
|
12597
11699
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
|
12598
11700
|
}
|
|
12599
|
-
const programSection = (0,
|
|
11701
|
+
const programSection = (0, import_babel_utils49.getProgram)().node.extra.section;
|
|
12600
11702
|
const childProgram = childFile.ast.program;
|
|
12601
11703
|
const childExtra = childProgram.extra;
|
|
12602
11704
|
const childSection = childExtra.section;
|
|
@@ -12624,12 +11726,12 @@ var custom_tag_default = {
|
|
|
12624
11726
|
};
|
|
12625
11727
|
function translateHTML(tag) {
|
|
12626
11728
|
const { node } = tag;
|
|
12627
|
-
const childProgram = (0,
|
|
11729
|
+
const childProgram = (0, import_babel_utils49.loadFileForTag)(tag).ast.program;
|
|
12628
11730
|
const childExtra = childProgram.extra;
|
|
12629
11731
|
let tagIdentifier;
|
|
12630
|
-
if (
|
|
11732
|
+
if (import_compiler60.types.isStringLiteral(node.name)) {
|
|
12631
11733
|
const relativePath = getTagRelativePath(tag);
|
|
12632
|
-
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));
|
|
12633
11735
|
} else {
|
|
12634
11736
|
tagIdentifier = node.name;
|
|
12635
11737
|
}
|
|
@@ -12645,12 +11747,12 @@ function translateDOM(tag) {
|
|
|
12645
11747
|
const { file } = tag.hub;
|
|
12646
11748
|
const write = writeTo(tag);
|
|
12647
11749
|
const relativePath = getTagRelativePath(tag);
|
|
12648
|
-
const programSection = (0,
|
|
12649
|
-
const childFile = (0,
|
|
11750
|
+
const programSection = (0, import_babel_utils49.getProgram)().node.extra.section;
|
|
11751
|
+
const childFile = (0, import_babel_utils49.loadFileForTag)(tag);
|
|
12650
11752
|
const childExtra = childFile.ast.program.extra;
|
|
12651
11753
|
const childExports = childExtra.domExports;
|
|
12652
11754
|
const childSection = childExtra.section;
|
|
12653
|
-
const tagName =
|
|
11755
|
+
const tagName = import_compiler60.types.isIdentifier(node.name) ? node.name.name : import_compiler60.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
|
12654
11756
|
if (programSection === childSection) {
|
|
12655
11757
|
knownTagTranslateDOM(
|
|
12656
11758
|
tag,
|
|
@@ -12661,16 +11763,16 @@ function translateDOM(tag) {
|
|
|
12661
11763
|
"render",
|
|
12662
11764
|
section,
|
|
12663
11765
|
void 0,
|
|
12664
|
-
|
|
12665
|
-
|
|
11766
|
+
import_compiler60.types.expressionStatement(
|
|
11767
|
+
import_compiler60.types.callExpression(import_compiler60.types.identifier(childExports.setup), [
|
|
12666
11768
|
createScopeReadExpression(childBinding, section)
|
|
12667
11769
|
])
|
|
12668
11770
|
)
|
|
12669
11771
|
);
|
|
12670
11772
|
}
|
|
12671
11773
|
);
|
|
12672
|
-
write`${
|
|
12673
|
-
injectWalks(tag, tagName,
|
|
11774
|
+
write`${import_compiler60.types.identifier(childExports.template)}`;
|
|
11775
|
+
injectWalks(tag, tagName, import_compiler60.types.identifier(childExports.walks));
|
|
12674
11776
|
} else {
|
|
12675
11777
|
knownTagTranslateDOM(
|
|
12676
11778
|
tag,
|
|
@@ -12686,8 +11788,8 @@ function translateDOM(tag) {
|
|
|
12686
11788
|
"render",
|
|
12687
11789
|
section,
|
|
12688
11790
|
void 0,
|
|
12689
|
-
|
|
12690
|
-
|
|
11791
|
+
import_compiler60.types.expressionStatement(
|
|
11792
|
+
import_compiler60.types.callExpression(
|
|
12691
11793
|
importOrSelfReferenceName(
|
|
12692
11794
|
file,
|
|
12693
11795
|
relativePath,
|
|
@@ -12700,11 +11802,11 @@ function translateDOM(tag) {
|
|
|
12700
11802
|
);
|
|
12701
11803
|
}
|
|
12702
11804
|
);
|
|
12703
|
-
write`${(0,
|
|
11805
|
+
write`${(0, import_babel_utils49.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
12704
11806
|
injectWalks(
|
|
12705
11807
|
tag,
|
|
12706
11808
|
tagName,
|
|
12707
|
-
(0,
|
|
11809
|
+
(0, import_babel_utils49.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
|
12708
11810
|
);
|
|
12709
11811
|
}
|
|
12710
11812
|
tag.remove();
|
|
@@ -12715,9 +11817,9 @@ function getTagRelativePath(tag) {
|
|
|
12715
11817
|
hub: { file }
|
|
12716
11818
|
} = tag;
|
|
12717
11819
|
let relativePath;
|
|
12718
|
-
if (
|
|
12719
|
-
const template = (0,
|
|
12720
|
-
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);
|
|
12721
11823
|
} else if (node.extra?.tagNameImported) {
|
|
12722
11824
|
relativePath = node.extra.tagNameImported;
|
|
12723
11825
|
}
|
|
@@ -12736,9 +11838,9 @@ function getTagRelativePath(tag) {
|
|
|
12736
11838
|
}
|
|
12737
11839
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
12738
11840
|
if (isCircularRequest(file, request)) {
|
|
12739
|
-
return
|
|
11841
|
+
return import_compiler60.types.identifier(name2);
|
|
12740
11842
|
}
|
|
12741
|
-
return (0,
|
|
11843
|
+
return (0, import_babel_utils49.importNamed)(file, request, name2, nameHint);
|
|
12742
11844
|
}
|
|
12743
11845
|
function isCircularRequest(file, request) {
|
|
12744
11846
|
const { filename } = file.opts;
|
|
@@ -12746,15 +11848,15 @@ function isCircularRequest(file, request) {
|
|
|
12746
11848
|
}
|
|
12747
11849
|
|
|
12748
11850
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
12749
|
-
var
|
|
12750
|
-
var
|
|
11851
|
+
var import_compiler61 = require("@marko/compiler");
|
|
11852
|
+
var import_babel_utils50 = require("@marko/compiler/babel-utils");
|
|
12751
11853
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
|
12752
11854
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
|
12753
11855
|
var importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
12754
11856
|
var dynamic_tag_default = {
|
|
12755
11857
|
analyze: {
|
|
12756
11858
|
enter(tag) {
|
|
12757
|
-
(0,
|
|
11859
|
+
(0, import_babel_utils50.assertAttributesOrArgs)(tag);
|
|
12758
11860
|
const { node } = tag;
|
|
12759
11861
|
const definedBodySection = node.extra?.defineBodySection;
|
|
12760
11862
|
if (definedBodySection) {
|
|
@@ -12779,9 +11881,9 @@ var dynamic_tag_default = {
|
|
|
12779
11881
|
tagSection
|
|
12780
11882
|
);
|
|
12781
11883
|
if (hasVar || tag.node.attributes.some(
|
|
12782
|
-
(attr) =>
|
|
11884
|
+
(attr) => import_compiler61.types.isMarkoSpreadAttribute(attr) || isEventOrChangeHandler(attr.name)
|
|
12783
11885
|
)) {
|
|
12784
|
-
(0,
|
|
11886
|
+
(0, import_babel_utils50.getProgram)().node.extra.isInteractive = true;
|
|
12785
11887
|
}
|
|
12786
11888
|
if (hasVar) {
|
|
12787
11889
|
trackVarReferences(tag, 5 /* derived */);
|
|
@@ -12819,7 +11921,7 @@ var dynamic_tag_default = {
|
|
|
12819
11921
|
if (isOutputHTML()) {
|
|
12820
11922
|
knownTagTranslateHTML(
|
|
12821
11923
|
tag,
|
|
12822
|
-
|
|
11924
|
+
import_compiler61.types.memberExpression(tag.node.name, import_compiler61.types.identifier("content")),
|
|
12823
11925
|
definedBodySection,
|
|
12824
11926
|
propTree
|
|
12825
11927
|
);
|
|
@@ -12836,9 +11938,9 @@ var dynamic_tag_default = {
|
|
|
12836
11938
|
"render",
|
|
12837
11939
|
section,
|
|
12838
11940
|
void 0,
|
|
12839
|
-
|
|
12840
|
-
|
|
12841
|
-
|
|
11941
|
+
import_compiler61.types.expressionStatement(
|
|
11942
|
+
import_compiler61.types.callExpression(
|
|
11943
|
+
import_compiler61.types.memberExpression(signal.identifier, import_compiler61.types.identifier("_")),
|
|
12842
11944
|
[
|
|
12843
11945
|
createScopeReadExpression(childBinding, section),
|
|
12844
11946
|
getScopeExpression(section, definedBodySection.parent)
|
|
@@ -12863,8 +11965,8 @@ var dynamic_tag_default = {
|
|
|
12863
11965
|
const nodeBinding = tagExtra[kDOMBinding3];
|
|
12864
11966
|
const isClassAPI = tagExtra.featureType === "class";
|
|
12865
11967
|
let tagExpression = node.name;
|
|
12866
|
-
if (
|
|
12867
|
-
tagExpression = (0,
|
|
11968
|
+
if (import_compiler61.types.isStringLiteral(tagExpression)) {
|
|
11969
|
+
tagExpression = (0, import_babel_utils50.importDefault)(
|
|
12868
11970
|
tag.hub.file,
|
|
12869
11971
|
getTagRelativePath(tag),
|
|
12870
11972
|
tagExpression.value
|
|
@@ -12872,15 +11974,15 @@ var dynamic_tag_default = {
|
|
|
12872
11974
|
}
|
|
12873
11975
|
if (isClassAPI) {
|
|
12874
11976
|
if (isOutputHTML()) {
|
|
12875
|
-
(0,
|
|
12876
|
-
|
|
11977
|
+
(0, import_babel_utils50.getProgram)().node.body.push(
|
|
11978
|
+
import_compiler61.types.markoScriptlet(
|
|
12877
11979
|
[
|
|
12878
|
-
|
|
12879
|
-
|
|
12880
|
-
(0,
|
|
11980
|
+
import_compiler61.types.expressionStatement(
|
|
11981
|
+
import_compiler61.types.callExpression(
|
|
11982
|
+
(0, import_babel_utils50.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
12881
11983
|
[
|
|
12882
|
-
|
|
12883
|
-
|
|
11984
|
+
import_compiler61.types.identifier(tagExpression.name),
|
|
11985
|
+
import_compiler61.types.stringLiteral((0, import_babel_utils50.loadFileForTag)(tag).metadata.marko.id)
|
|
12884
11986
|
]
|
|
12885
11987
|
)
|
|
12886
11988
|
)
|
|
@@ -12889,12 +11991,12 @@ var dynamic_tag_default = {
|
|
|
12889
11991
|
)
|
|
12890
11992
|
);
|
|
12891
11993
|
} else {
|
|
12892
|
-
(0,
|
|
12893
|
-
|
|
11994
|
+
(0, import_babel_utils50.getProgram)().node.body.push(
|
|
11995
|
+
import_compiler61.types.expressionStatement(
|
|
12894
11996
|
callRuntime(
|
|
12895
11997
|
"_resume",
|
|
12896
|
-
|
|
12897
|
-
|
|
11998
|
+
import_compiler61.types.stringLiteral((0, import_babel_utils50.loadFileForTag)(tag).metadata.marko.id),
|
|
11999
|
+
import_compiler61.types.identifier(tagExpression.name)
|
|
12898
12000
|
)
|
|
12899
12001
|
)
|
|
12900
12002
|
);
|
|
@@ -12937,9 +12039,9 @@ var dynamic_tag_default = {
|
|
|
12937
12039
|
getScopeIdIdentifier(tagSection),
|
|
12938
12040
|
getScopeAccessorLiteral(nodeBinding),
|
|
12939
12041
|
tagExpression,
|
|
12940
|
-
|
|
12941
|
-
|
|
12942
|
-
|
|
12042
|
+
import_compiler61.types.arrayExpression(args),
|
|
12043
|
+
import_compiler61.types.numericLiteral(0),
|
|
12044
|
+
import_compiler61.types.numericLiteral(1),
|
|
12943
12045
|
serializeArg
|
|
12944
12046
|
) : callRuntime(
|
|
12945
12047
|
"_dynamic_tag",
|
|
@@ -12947,8 +12049,8 @@ var dynamic_tag_default = {
|
|
|
12947
12049
|
getScopeAccessorLiteral(nodeBinding),
|
|
12948
12050
|
tagExpression,
|
|
12949
12051
|
args[0],
|
|
12950
|
-
args[1] || (serializeArg ?
|
|
12951
|
-
serializeArg ?
|
|
12052
|
+
args[1] || (serializeArg ? import_compiler61.types.numericLiteral(0) : void 0),
|
|
12053
|
+
serializeArg ? import_compiler61.types.numericLiteral(0) : void 0,
|
|
12952
12054
|
serializeArg
|
|
12953
12055
|
);
|
|
12954
12056
|
if (node.var) {
|
|
@@ -12956,18 +12058,18 @@ var dynamic_tag_default = {
|
|
|
12956
12058
|
tag.get("name").toString() + "_scope"
|
|
12957
12059
|
);
|
|
12958
12060
|
statements.push(
|
|
12959
|
-
|
|
12960
|
-
|
|
12061
|
+
import_compiler61.types.variableDeclaration("const", [
|
|
12062
|
+
import_compiler61.types.variableDeclarator(
|
|
12961
12063
|
dynamicScopeIdentifier,
|
|
12962
12064
|
callRuntime("_peek_scope_id")
|
|
12963
12065
|
)
|
|
12964
12066
|
])
|
|
12965
12067
|
);
|
|
12966
12068
|
statements.push(
|
|
12967
|
-
|
|
12968
|
-
|
|
12069
|
+
import_compiler61.types.variableDeclaration("let", [
|
|
12070
|
+
import_compiler61.types.variableDeclarator(node.var, dynamicTagExpr)
|
|
12969
12071
|
]),
|
|
12970
|
-
|
|
12072
|
+
import_compiler61.types.expressionStatement(
|
|
12971
12073
|
callRuntime(
|
|
12972
12074
|
"_var",
|
|
12973
12075
|
getScopeIdIdentifier(tagSection),
|
|
@@ -12975,7 +12077,7 @@ var dynamic_tag_default = {
|
|
|
12975
12077
|
tag.node.extra[kChildOffsetScopeBinding2]
|
|
12976
12078
|
),
|
|
12977
12079
|
dynamicScopeIdentifier,
|
|
12978
|
-
|
|
12080
|
+
import_compiler61.types.stringLiteral(
|
|
12979
12081
|
getResumeRegisterId(
|
|
12980
12082
|
tagSection,
|
|
12981
12083
|
node.var.extra?.binding,
|
|
@@ -12987,7 +12089,7 @@ var dynamic_tag_default = {
|
|
|
12987
12089
|
)
|
|
12988
12090
|
);
|
|
12989
12091
|
} else {
|
|
12990
|
-
statements.push(
|
|
12092
|
+
statements.push(import_compiler61.types.expressionStatement(dynamicTagExpr));
|
|
12991
12093
|
}
|
|
12992
12094
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
|
12993
12095
|
replacement.skip();
|
|
@@ -13006,9 +12108,9 @@ var dynamic_tag_default = {
|
|
|
13006
12108
|
tagVarSignal.register = true;
|
|
13007
12109
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
|
13008
12110
|
const changeArgs = [
|
|
13009
|
-
|
|
12111
|
+
import_compiler61.types.memberExpression(
|
|
13010
12112
|
getScopeExpression(tagVarSignal.section, valueSection),
|
|
13011
|
-
|
|
12113
|
+
import_compiler61.types.stringLiteral(
|
|
13012
12114
|
getAccessorPrefix().BranchScopes + getScopeAccessor(nodeBinding)
|
|
13013
12115
|
),
|
|
13014
12116
|
true
|
|
@@ -13016,28 +12118,28 @@ var dynamic_tag_default = {
|
|
|
13016
12118
|
value
|
|
13017
12119
|
];
|
|
13018
12120
|
if (!isOptimize()) {
|
|
13019
|
-
changeArgs.push(
|
|
12121
|
+
changeArgs.push(import_compiler61.types.stringLiteral(varBinding.name));
|
|
13020
12122
|
}
|
|
13021
|
-
return
|
|
12123
|
+
return import_compiler61.types.callExpression(importRuntime("_var_change"), changeArgs);
|
|
13022
12124
|
};
|
|
13023
12125
|
}
|
|
13024
12126
|
signal.build = () => {
|
|
13025
12127
|
return callRuntime(
|
|
13026
12128
|
"_dynamic_tag",
|
|
13027
12129
|
getScopeAccessorLiteral(nodeBinding, true),
|
|
13028
|
-
bodySection &&
|
|
13029
|
-
tagVarSignal ?
|
|
13030
|
-
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)
|
|
13031
12133
|
);
|
|
13032
12134
|
};
|
|
13033
12135
|
if (args.length) {
|
|
13034
|
-
const argsOrInput = hasTagArgs ?
|
|
13035
|
-
if (!
|
|
12136
|
+
const argsOrInput = hasTagArgs ? import_compiler61.types.arrayExpression(args) : args[0];
|
|
12137
|
+
if (!import_compiler61.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
|
13036
12138
|
signal.extraArgs = [
|
|
13037
|
-
|
|
12139
|
+
import_compiler61.types.arrowFunctionExpression(
|
|
13038
12140
|
[],
|
|
13039
|
-
statements.length ?
|
|
13040
|
-
statements.concat(
|
|
12141
|
+
statements.length ? import_compiler61.types.blockStatement(
|
|
12142
|
+
statements.concat(import_compiler61.types.returnStatement(argsOrInput))
|
|
13041
12143
|
) : argsOrInput
|
|
13042
12144
|
)
|
|
13043
12145
|
];
|
|
@@ -13051,13 +12153,13 @@ var dynamic_tag_default = {
|
|
|
13051
12153
|
}
|
|
13052
12154
|
};
|
|
13053
12155
|
function enableDynamicTagResume(tag) {
|
|
13054
|
-
const program = (0,
|
|
12156
|
+
const program = (0, import_babel_utils50.getProgram)().node;
|
|
13055
12157
|
if (!importedDynamicTagResume.has(program) && analyzeTagNameType(tag, true) !== 1 /* CustomTag */) {
|
|
13056
12158
|
for (const attr of tag.node.attributes) {
|
|
13057
12159
|
if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && isEventOrChangeHandler(attr.name)) {
|
|
13058
12160
|
importedDynamicTagResume.add(program);
|
|
13059
12161
|
program.body.push(
|
|
13060
|
-
|
|
12162
|
+
import_compiler61.types.expressionStatement(callRuntime("_resume_dynamic_tag"))
|
|
13061
12163
|
);
|
|
13062
12164
|
return;
|
|
13063
12165
|
}
|
|
@@ -13069,7 +12171,7 @@ function enableDynamicTagResume(tag) {
|
|
|
13069
12171
|
var tag_default = {
|
|
13070
12172
|
analyze: {
|
|
13071
12173
|
enter(tag) {
|
|
13072
|
-
const tagDef = (0,
|
|
12174
|
+
const tagDef = (0, import_babel_utils51.getTagDef)(tag);
|
|
13073
12175
|
const type = analyzeTagNameType(tag);
|
|
13074
12176
|
const hook = tagDef?.analyzer?.hook;
|
|
13075
12177
|
if (hook) {
|
|
@@ -13093,7 +12195,7 @@ var tag_default = {
|
|
|
13093
12195
|
}
|
|
13094
12196
|
},
|
|
13095
12197
|
exit(tag) {
|
|
13096
|
-
const hook = (0,
|
|
12198
|
+
const hook = (0, import_babel_utils51.getTagDef)(tag)?.analyzer?.hook;
|
|
13097
12199
|
if (hook) {
|
|
13098
12200
|
exit(hook, tag);
|
|
13099
12201
|
return;
|
|
@@ -13102,8 +12204,7 @@ var tag_default = {
|
|
|
13102
12204
|
},
|
|
13103
12205
|
translate: {
|
|
13104
12206
|
enter(tag) {
|
|
13105
|
-
const tagDef = (0,
|
|
13106
|
-
const extra = tag.node.extra;
|
|
12207
|
+
const tagDef = (0, import_babel_utils51.getTagDef)(tag);
|
|
13107
12208
|
if (tagDef?.translator) {
|
|
13108
12209
|
if (tagDef.translator.path) {
|
|
13109
12210
|
tag.hub.file.metadata.marko.watchFiles.push(tagDef.translator.path);
|
|
@@ -13119,7 +12220,7 @@ var tag_default = {
|
|
|
13119
12220
|
);
|
|
13120
12221
|
}
|
|
13121
12222
|
if (attr.node.modifier) {
|
|
13122
|
-
if ((0,
|
|
12223
|
+
if ((0, import_babel_utils51.isNativeTag)(attr.parentPath)) {
|
|
13123
12224
|
attr.node.name += `:${attr.node.modifier}`;
|
|
13124
12225
|
} else {
|
|
13125
12226
|
throw attr.buildCodeFrameError(
|
|
@@ -13129,18 +12230,7 @@ var tag_default = {
|
|
|
13129
12230
|
}
|
|
13130
12231
|
}
|
|
13131
12232
|
}
|
|
13132
|
-
|
|
13133
|
-
if (extra.tagNameDynamic && extra.tagNameNullable && type === 0 /* NativeTag */ && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
|
13134
|
-
const tagNameId = generateUidIdentifier("tagName");
|
|
13135
|
-
const [tagNameVarPath] = tag.insertBefore(
|
|
13136
|
-
import_compiler65.types.variableDeclaration("const", [
|
|
13137
|
-
import_compiler65.types.variableDeclarator(tagNameId, tag.node.name)
|
|
13138
|
-
])
|
|
13139
|
-
);
|
|
13140
|
-
tagNameVarPath.skip();
|
|
13141
|
-
tag.set("name", tagNameId);
|
|
13142
|
-
}
|
|
13143
|
-
switch (type) {
|
|
12233
|
+
switch (analyzeTagNameType(tag)) {
|
|
13144
12234
|
case 0 /* NativeTag */:
|
|
13145
12235
|
native_tag_default.translate.enter(tag);
|
|
13146
12236
|
break;
|
|
@@ -13156,7 +12246,7 @@ var tag_default = {
|
|
|
13156
12246
|
}
|
|
13157
12247
|
},
|
|
13158
12248
|
exit(tag) {
|
|
13159
|
-
const translator = (0,
|
|
12249
|
+
const translator = (0, import_babel_utils51.getTagDef)(tag)?.translator;
|
|
13160
12250
|
if (translator) {
|
|
13161
12251
|
exit(translator.hook, tag);
|
|
13162
12252
|
return;
|
|
@@ -13180,7 +12270,7 @@ var tag_default = {
|
|
|
13180
12270
|
};
|
|
13181
12271
|
|
|
13182
12272
|
// src/translator/visitors/text.ts
|
|
13183
|
-
var
|
|
12273
|
+
var import_compiler63 = require("@marko/compiler");
|
|
13184
12274
|
var text_default = {
|
|
13185
12275
|
translate: {
|
|
13186
12276
|
exit(text) {
|
|
@@ -13212,7 +12302,7 @@ var preferAPI = "tags";
|
|
|
13212
12302
|
var { transform, analyze, translate } = visitors;
|
|
13213
12303
|
var taglibs = [
|
|
13214
12304
|
[
|
|
13215
|
-
|
|
12305
|
+
core_default.taglibId,
|
|
13216
12306
|
{
|
|
13217
12307
|
...core_default,
|
|
13218
12308
|
migrate: visitors.migrate
|