marko 6.0.156 → 6.0.158
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/common/errors.d.ts +2 -0
- package/dist/common/helpers.d.ts +2 -0
- package/dist/debug/dom.js +22 -15
- package/dist/debug/dom.mjs +22 -15
- package/dist/debug/html.js +12 -1
- package/dist/debug/html.mjs +12 -1
- package/dist/dom.d.ts +1 -1
- package/dist/dom.js +4 -0
- package/dist/dom.mjs +4 -0
- package/dist/html/writer.d.ts +1 -1
- package/dist/html.js +4 -1
- package/dist/html.mjs +4 -1
- package/dist/translator/index.js +444 -346
- package/dist/translator/util/known-tag.d.ts +1 -1
- package/dist/translator/util/references.d.ts +5 -1
- package/index.d.ts +1 -1
- package/package.json +2 -2
- package/tags-html.d.ts +1 -1
package/dist/translator/index.js
CHANGED
|
@@ -114,7 +114,7 @@ var attrs_default = {
|
|
|
114
114
|
|
|
115
115
|
// src/translator/core/await.ts
|
|
116
116
|
var import_compiler39 = require("@marko/compiler");
|
|
117
|
-
var
|
|
117
|
+
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
|
118
118
|
|
|
119
119
|
// src/common/accessor.debug.ts
|
|
120
120
|
var AccessorPrefix = /* @__PURE__ */ ((AccessorPrefix4) => {
|
|
@@ -133,33 +133,33 @@ var AccessorPrefix = /* @__PURE__ */ ((AccessorPrefix4) => {
|
|
|
133
133
|
AccessorPrefix4["TagVariableChange"] = "TagVariableChange:";
|
|
134
134
|
return AccessorPrefix4;
|
|
135
135
|
})(AccessorPrefix || {});
|
|
136
|
-
var AccessorProp = /* @__PURE__ */ ((
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return
|
|
136
|
+
var AccessorProp = /* @__PURE__ */ ((AccessorProp6) => {
|
|
137
|
+
AccessorProp6["Global"] = "$global";
|
|
138
|
+
AccessorProp6["Owner"] = "_";
|
|
139
|
+
AccessorProp6["AbortControllers"] = "#AbortControllers";
|
|
140
|
+
AccessorProp6["AbortScopes"] = "#AbortScopes";
|
|
141
|
+
AccessorProp6["AwaitCounter"] = "#AwaitCounter";
|
|
142
|
+
AccessorProp6["BranchAccessor"] = "#BranchAccessor";
|
|
143
|
+
AccessorProp6["BranchScopes"] = "#BranchScopes";
|
|
144
|
+
AccessorProp6["CatchContent"] = "#CatchContent";
|
|
145
|
+
AccessorProp6["ClosestBranch"] = "#ClosestBranch";
|
|
146
|
+
AccessorProp6["ClosestBranchId"] = "#ClosestBranchId";
|
|
147
|
+
AccessorProp6["Creating"] = "#Creating";
|
|
148
|
+
AccessorProp6["Destroyed"] = "#Destroyed";
|
|
149
|
+
AccessorProp6["DetachedAwait"] = "#DetachedAwait";
|
|
150
|
+
AccessorProp6["EndNode"] = "#EndNode";
|
|
151
|
+
AccessorProp6["Id"] = "#Id";
|
|
152
|
+
AccessorProp6["LoopKey"] = "#LoopKey";
|
|
153
|
+
AccessorProp6["ParentBranch"] = "#ParentBranch";
|
|
154
|
+
AccessorProp6["PendingEffects"] = "#PendingEffects";
|
|
155
|
+
AccessorProp6["PendingRenders"] = "#PendingRenders";
|
|
156
|
+
AccessorProp6["PlaceholderBranch"] = "#PlaceholderBranch";
|
|
157
|
+
AccessorProp6["PlaceholderContent"] = "#PlaceholderContent";
|
|
158
|
+
AccessorProp6["Renderer"] = "#Renderer";
|
|
159
|
+
AccessorProp6["StartNode"] = "#StartNode";
|
|
160
|
+
AccessorProp6["TagVariable"] = "#TagVariable";
|
|
161
|
+
AccessorProp6["TagVariableChange"] = "#TagVariableChange";
|
|
162
|
+
return AccessorProp6;
|
|
163
163
|
})(AccessorProp || {});
|
|
164
164
|
|
|
165
165
|
// src/translator/util/evaluate.ts
|
|
@@ -252,9 +252,12 @@ function isNullableExpr(expr) {
|
|
|
252
252
|
|
|
253
253
|
// src/translator/util/references.ts
|
|
254
254
|
var import_compiler38 = require("@marko/compiler");
|
|
255
|
-
var
|
|
255
|
+
var import_babel_utils27 = require("@marko/compiler/babel-utils");
|
|
256
|
+
var import_config = require("@marko/compiler/config");
|
|
256
257
|
|
|
257
258
|
// src/common/helpers.ts
|
|
259
|
+
var htmlAttrNameReg = /^[^a-z_]|[^a-z0-9._:-]/i;
|
|
260
|
+
var userAttrNameReg = /^[^a-z_$]|[^a-z0-9._:-]/i;
|
|
258
261
|
function classValue(classValue2) {
|
|
259
262
|
return toDelimitedString(classValue2, " ", stringifyClassObject);
|
|
260
263
|
}
|
|
@@ -1298,33 +1301,33 @@ var AccessorPrefix2 = /* @__PURE__ */ ((AccessorPrefix4) => {
|
|
|
1298
1301
|
AccessorPrefix4["TagVariableChange"] = "M";
|
|
1299
1302
|
return AccessorPrefix4;
|
|
1300
1303
|
})(AccessorPrefix2 || {});
|
|
1301
|
-
var AccessorProp2 = /* @__PURE__ */ ((
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
return
|
|
1304
|
+
var AccessorProp2 = /* @__PURE__ */ ((AccessorProp6) => {
|
|
1305
|
+
AccessorProp6["Global"] = "$";
|
|
1306
|
+
AccessorProp6["Owner"] = "_";
|
|
1307
|
+
AccessorProp6["AbortControllers"] = "A";
|
|
1308
|
+
AccessorProp6["AbortScopes"] = "B";
|
|
1309
|
+
AccessorProp6["AwaitCounter"] = "O";
|
|
1310
|
+
AccessorProp6["BranchAccessor"] = "C";
|
|
1311
|
+
AccessorProp6["BranchScopes"] = "D";
|
|
1312
|
+
AccessorProp6["CatchContent"] = "E";
|
|
1313
|
+
AccessorProp6["ClosestBranch"] = "F";
|
|
1314
|
+
AccessorProp6["ClosestBranchId"] = "G";
|
|
1315
|
+
AccessorProp6["Creating"] = "H";
|
|
1316
|
+
AccessorProp6["Destroyed"] = "I";
|
|
1317
|
+
AccessorProp6["DetachedAwait"] = "V";
|
|
1318
|
+
AccessorProp6["EndNode"] = "K";
|
|
1319
|
+
AccessorProp6["Id"] = "L";
|
|
1320
|
+
AccessorProp6["LoopKey"] = "M";
|
|
1321
|
+
AccessorProp6["ParentBranch"] = "N";
|
|
1322
|
+
AccessorProp6["PendingEffects"] = "J";
|
|
1323
|
+
AccessorProp6["PendingRenders"] = "W";
|
|
1324
|
+
AccessorProp6["PlaceholderBranch"] = "P";
|
|
1325
|
+
AccessorProp6["PlaceholderContent"] = "Q";
|
|
1326
|
+
AccessorProp6["Renderer"] = "R";
|
|
1327
|
+
AccessorProp6["StartNode"] = "S";
|
|
1328
|
+
AccessorProp6["TagVariable"] = "T";
|
|
1329
|
+
AccessorProp6["TagVariableChange"] = "U";
|
|
1330
|
+
return AccessorProp6;
|
|
1328
1331
|
})(AccessorProp2 || {});
|
|
1329
1332
|
|
|
1330
1333
|
// src/translator/util/marko-config.ts
|
|
@@ -2169,90 +2172,9 @@ function isStaticRoot(path7) {
|
|
|
2169
2172
|
}
|
|
2170
2173
|
}
|
|
2171
2174
|
|
|
2172
|
-
// src/translator/util/for-each-identifier.ts
|
|
2173
|
-
function forEachIdentifier(node, cb) {
|
|
2174
|
-
switch (node.type) {
|
|
2175
|
-
case "ObjectPattern":
|
|
2176
|
-
for (const prop of node.properties) {
|
|
2177
|
-
switch (prop.type) {
|
|
2178
|
-
case "ObjectProperty":
|
|
2179
|
-
if (prop.value.type === "AssignmentPattern") {
|
|
2180
|
-
forEachIdentifier(prop.value.left, cb);
|
|
2181
|
-
} else {
|
|
2182
|
-
forEachIdentifier(prop.value, cb);
|
|
2183
|
-
}
|
|
2184
|
-
break;
|
|
2185
|
-
case "RestElement":
|
|
2186
|
-
forEachIdentifier(prop.argument, cb);
|
|
2187
|
-
break;
|
|
2188
|
-
}
|
|
2189
|
-
}
|
|
2190
|
-
break;
|
|
2191
|
-
case "ArrayPattern":
|
|
2192
|
-
for (const el of node.elements) {
|
|
2193
|
-
if (el != null) {
|
|
2194
|
-
switch (el.type) {
|
|
2195
|
-
case "RestElement":
|
|
2196
|
-
forEachIdentifier(el.argument, cb);
|
|
2197
|
-
break;
|
|
2198
|
-
case "AssignmentPattern":
|
|
2199
|
-
forEachIdentifier(el.left, cb);
|
|
2200
|
-
break;
|
|
2201
|
-
default:
|
|
2202
|
-
forEachIdentifier(el, cb);
|
|
2203
|
-
break;
|
|
2204
|
-
}
|
|
2205
|
-
}
|
|
2206
|
-
}
|
|
2207
|
-
break;
|
|
2208
|
-
case "Identifier":
|
|
2209
|
-
cb(node);
|
|
2210
|
-
break;
|
|
2211
|
-
}
|
|
2212
|
-
}
|
|
2213
|
-
function forEachIdentifierPath(nodePath, cb) {
|
|
2214
|
-
if (nodePath.isIdentifier()) {
|
|
2215
|
-
cb(nodePath);
|
|
2216
|
-
} else if (nodePath.isObjectPattern()) {
|
|
2217
|
-
for (const prop of nodePath.get("properties")) {
|
|
2218
|
-
if (prop.isObjectProperty()) {
|
|
2219
|
-
const value = prop.get("value");
|
|
2220
|
-
if (value.isAssignmentPattern()) {
|
|
2221
|
-
forEachIdentifierPath(value.get("left"), cb);
|
|
2222
|
-
} else {
|
|
2223
|
-
forEachIdentifierPath(value, cb);
|
|
2224
|
-
}
|
|
2225
|
-
} else if (prop.isRestElement()) {
|
|
2226
|
-
forEachIdentifierPath(prop.get("argument"), cb);
|
|
2227
|
-
}
|
|
2228
|
-
}
|
|
2229
|
-
} else if (nodePath.isArrayPattern()) {
|
|
2230
|
-
for (const el of nodePath.get("elements")) {
|
|
2231
|
-
if (el) {
|
|
2232
|
-
if (el.isRestElement()) {
|
|
2233
|
-
forEachIdentifierPath(el.get("argument"), cb);
|
|
2234
|
-
} else if (el.isAssignmentPattern()) {
|
|
2235
|
-
forEachIdentifierPath(el.get("left"), cb);
|
|
2236
|
-
} else {
|
|
2237
|
-
forEachIdentifierPath(el, cb);
|
|
2238
|
-
}
|
|
2239
|
-
}
|
|
2240
|
-
}
|
|
2241
|
-
}
|
|
2242
|
-
}
|
|
2243
|
-
|
|
2244
|
-
// src/translator/util/is-event-or-change-handler.ts
|
|
2245
|
-
function isEventOrChangeHandler(prop) {
|
|
2246
|
-
return /^on[-A-Z][a-zA-Z0-9_$]|[a-zA-Z_$][a-zA-Z0-9_$]*Change$/.test(prop);
|
|
2247
|
-
}
|
|
2248
|
-
|
|
2249
|
-
// src/translator/util/known-tag.ts
|
|
2250
|
-
var import_compiler37 = require("@marko/compiler");
|
|
2251
|
-
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
|
2252
|
-
|
|
2253
2175
|
// src/translator/visitors/program/index.ts
|
|
2254
2176
|
var import_compiler27 = require("@marko/compiler");
|
|
2255
|
-
var
|
|
2177
|
+
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
|
2256
2178
|
var import_path2 = __toESM(require("path"));
|
|
2257
2179
|
|
|
2258
2180
|
// src/translator/util/binding-prop-tree.ts
|
|
@@ -2619,8 +2541,8 @@ function getHTMLRuntime() {
|
|
|
2619
2541
|
};
|
|
2620
2542
|
}
|
|
2621
2543
|
function getRuntimePath(output) {
|
|
2622
|
-
const { optimize } = getMarkoOpts();
|
|
2623
|
-
return `${runtime_info_default.name}/${
|
|
2544
|
+
const { optimize: optimize2 } = getMarkoOpts();
|
|
2545
|
+
return `${runtime_info_default.name}/${optimize2 ? "" : "debug/"}${output === "html" ? "html" : "dom"}`;
|
|
2624
2546
|
}
|
|
2625
2547
|
function filterArguments(args) {
|
|
2626
2548
|
const filteredArgs = [];
|
|
@@ -3305,6 +3227,78 @@ var return_default = {
|
|
|
3305
3227
|
]
|
|
3306
3228
|
};
|
|
3307
3229
|
|
|
3230
|
+
// src/translator/util/for-each-identifier.ts
|
|
3231
|
+
function forEachIdentifier(node, cb) {
|
|
3232
|
+
switch (node.type) {
|
|
3233
|
+
case "ObjectPattern":
|
|
3234
|
+
for (const prop of node.properties) {
|
|
3235
|
+
switch (prop.type) {
|
|
3236
|
+
case "ObjectProperty":
|
|
3237
|
+
if (prop.value.type === "AssignmentPattern") {
|
|
3238
|
+
forEachIdentifier(prop.value.left, cb);
|
|
3239
|
+
} else {
|
|
3240
|
+
forEachIdentifier(prop.value, cb);
|
|
3241
|
+
}
|
|
3242
|
+
break;
|
|
3243
|
+
case "RestElement":
|
|
3244
|
+
forEachIdentifier(prop.argument, cb);
|
|
3245
|
+
break;
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
break;
|
|
3249
|
+
case "ArrayPattern":
|
|
3250
|
+
for (const el of node.elements) {
|
|
3251
|
+
if (el != null) {
|
|
3252
|
+
switch (el.type) {
|
|
3253
|
+
case "RestElement":
|
|
3254
|
+
forEachIdentifier(el.argument, cb);
|
|
3255
|
+
break;
|
|
3256
|
+
case "AssignmentPattern":
|
|
3257
|
+
forEachIdentifier(el.left, cb);
|
|
3258
|
+
break;
|
|
3259
|
+
default:
|
|
3260
|
+
forEachIdentifier(el, cb);
|
|
3261
|
+
break;
|
|
3262
|
+
}
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
break;
|
|
3266
|
+
case "Identifier":
|
|
3267
|
+
cb(node);
|
|
3268
|
+
break;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
function forEachIdentifierPath(nodePath, cb) {
|
|
3272
|
+
if (nodePath.isIdentifier()) {
|
|
3273
|
+
cb(nodePath);
|
|
3274
|
+
} else if (nodePath.isObjectPattern()) {
|
|
3275
|
+
for (const prop of nodePath.get("properties")) {
|
|
3276
|
+
if (prop.isObjectProperty()) {
|
|
3277
|
+
const value = prop.get("value");
|
|
3278
|
+
if (value.isAssignmentPattern()) {
|
|
3279
|
+
forEachIdentifierPath(value.get("left"), cb);
|
|
3280
|
+
} else {
|
|
3281
|
+
forEachIdentifierPath(value, cb);
|
|
3282
|
+
}
|
|
3283
|
+
} else if (prop.isRestElement()) {
|
|
3284
|
+
forEachIdentifierPath(prop.get("argument"), cb);
|
|
3285
|
+
}
|
|
3286
|
+
}
|
|
3287
|
+
} else if (nodePath.isArrayPattern()) {
|
|
3288
|
+
for (const el of nodePath.get("elements")) {
|
|
3289
|
+
if (el) {
|
|
3290
|
+
if (el.isRestElement()) {
|
|
3291
|
+
forEachIdentifierPath(el.get("argument"), cb);
|
|
3292
|
+
} else if (el.isAssignmentPattern()) {
|
|
3293
|
+
forEachIdentifierPath(el.get("left"), cb);
|
|
3294
|
+
} else {
|
|
3295
|
+
forEachIdentifierPath(el, cb);
|
|
3296
|
+
}
|
|
3297
|
+
}
|
|
3298
|
+
}
|
|
3299
|
+
}
|
|
3300
|
+
}
|
|
3301
|
+
|
|
3308
3302
|
// src/translator/util/get-defined-binding-expression.ts
|
|
3309
3303
|
var import_compiler18 = require("@marko/compiler");
|
|
3310
3304
|
function getDeclaredBindingExpression(binding) {
|
|
@@ -3344,7 +3338,7 @@ function createScopeReadExpression(reference, section = reference.section) {
|
|
|
3344
3338
|
);
|
|
3345
3339
|
if (section === reference.section && reference.type !== 0 /* dom */) {
|
|
3346
3340
|
const exprExtra = expr.extra ??= {};
|
|
3347
|
-
exprExtra.read = createRead(reference, void 0
|
|
3341
|
+
exprExtra.read = createRead(reference, void 0);
|
|
3348
3342
|
exprExtra.section = section;
|
|
3349
3343
|
}
|
|
3350
3344
|
return expr;
|
|
@@ -4494,11 +4488,11 @@ function getRegisteredFnExpression(node) {
|
|
|
4494
4488
|
const id = extra.name;
|
|
4495
4489
|
const referencesScope = extra.referencesScope;
|
|
4496
4490
|
const referencedBindings = extra.referencedBindingsInFunction;
|
|
4497
|
-
let
|
|
4498
|
-
if (!
|
|
4499
|
-
registeredFnsForProgram.set((0, import_babel_utils15.getProgram)().node,
|
|
4491
|
+
let registeredFns = registeredFnsForProgram.get((0, import_babel_utils15.getProgram)().node);
|
|
4492
|
+
if (!registeredFns) {
|
|
4493
|
+
registeredFnsForProgram.set((0, import_babel_utils15.getProgram)().node, registeredFns = []);
|
|
4500
4494
|
}
|
|
4501
|
-
|
|
4495
|
+
registeredFns.push({
|
|
4502
4496
|
id,
|
|
4503
4497
|
node,
|
|
4504
4498
|
registerId: extra.registerId,
|
|
@@ -4915,6 +4909,7 @@ function getRegisteredFnExpression2(node) {
|
|
|
4915
4909
|
|
|
4916
4910
|
// src/translator/visitors/program/pre-analyze.ts
|
|
4917
4911
|
var import_compiler26 = require("@marko/compiler");
|
|
4912
|
+
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
|
4918
4913
|
|
|
4919
4914
|
// src/translator/core/textarea.ts
|
|
4920
4915
|
var import_compiler25 = require("@marko/compiler");
|
|
@@ -4966,6 +4961,7 @@ function normalizeBody(body) {
|
|
|
4966
4961
|
function normalizeTag(tag) {
|
|
4967
4962
|
const { node } = tag;
|
|
4968
4963
|
const { name: name2, attributes } = node;
|
|
4964
|
+
let attrNameReg = userAttrNameReg;
|
|
4969
4965
|
normalizeBody(tag.get("body").get("body"));
|
|
4970
4966
|
normalizeBody(tag.get("attributeTags"));
|
|
4971
4967
|
if (node.var) {
|
|
@@ -4987,7 +4983,8 @@ function normalizeTag(tag) {
|
|
|
4987
4983
|
const tagName = name2.value;
|
|
4988
4984
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
|
4989
4985
|
node.name = withPreviousLocation(import_compiler26.types.identifier(tagName), name2);
|
|
4990
|
-
} else {
|
|
4986
|
+
} else if ((0, import_babel_utils17.isNativeTag)(tag)) {
|
|
4987
|
+
attrNameReg = htmlAttrNameReg;
|
|
4991
4988
|
switch (tagName) {
|
|
4992
4989
|
case "textarea":
|
|
4993
4990
|
preAnalyze(tag);
|
|
@@ -4997,31 +4994,78 @@ function normalizeTag(tag) {
|
|
|
4997
4994
|
}
|
|
4998
4995
|
for (let i = 0; i < attributes.length; i++) {
|
|
4999
4996
|
const attr = attributes[i];
|
|
5000
|
-
if (import_compiler26.types.isMarkoAttribute(attr)
|
|
5001
|
-
attr.bound
|
|
5002
|
-
|
|
4997
|
+
if (import_compiler26.types.isMarkoAttribute(attr)) {
|
|
4998
|
+
if (attr.bound) {
|
|
4999
|
+
attributes.splice(++i, 0, getChangeHandler(tag, attr));
|
|
5000
|
+
attr.bound = false;
|
|
5001
|
+
} else if (attr.modifier != null) {
|
|
5002
|
+
attr.name += ":" + attr.modifier;
|
|
5003
|
+
}
|
|
5004
|
+
if (attrNameReg.test(attr.name)) {
|
|
5005
|
+
throw tag.hub.buildError(
|
|
5006
|
+
attr.loc?.end && {
|
|
5007
|
+
loc: {
|
|
5008
|
+
start: attr.loc.start,
|
|
5009
|
+
end: {
|
|
5010
|
+
line: attr.loc.start.line,
|
|
5011
|
+
column: attr.loc.start.column + attr.name.length
|
|
5012
|
+
}
|
|
5013
|
+
}
|
|
5014
|
+
},
|
|
5015
|
+
"Invalid attribute name."
|
|
5016
|
+
);
|
|
5017
|
+
}
|
|
5018
|
+
attr.modifier = null;
|
|
5003
5019
|
}
|
|
5004
5020
|
}
|
|
5005
5021
|
}
|
|
5006
5022
|
function getChangeHandler(tag, attr) {
|
|
5007
5023
|
const attrName = attr.name;
|
|
5008
5024
|
const changeAttrName = attrName + "Change";
|
|
5025
|
+
let modifier;
|
|
5026
|
+
if (attr.modifier != null) {
|
|
5027
|
+
if (!import_compiler26.types.isValidIdentifier(attr.modifier)) {
|
|
5028
|
+
throw tag.hub.buildError(
|
|
5029
|
+
attr.value.loc?.end && {
|
|
5030
|
+
loc: {
|
|
5031
|
+
start: {
|
|
5032
|
+
line: attr.value.loc.start.line,
|
|
5033
|
+
column: attr.value.loc.start.column - attr.modifier.length - 2
|
|
5034
|
+
},
|
|
5035
|
+
end: {
|
|
5036
|
+
line: attr.value.loc.start.line,
|
|
5037
|
+
column: attr.value.loc.start.column - 2
|
|
5038
|
+
}
|
|
5039
|
+
}
|
|
5040
|
+
},
|
|
5041
|
+
"Bound attribute refinement shorthand must be a valid JavaScript identifier."
|
|
5042
|
+
);
|
|
5043
|
+
}
|
|
5044
|
+
modifier = withPreviousLocation(import_compiler26.types.identifier(attr.modifier), attr);
|
|
5045
|
+
}
|
|
5009
5046
|
if (import_compiler26.types.isIdentifier(attr.value)) {
|
|
5010
5047
|
const binding = tag.scope.getBinding(attr.value.name);
|
|
5011
5048
|
if (!binding)
|
|
5012
5049
|
return import_compiler26.types.markoAttribute(
|
|
5013
5050
|
changeAttrName,
|
|
5014
|
-
buildChangeHandlerFunction(attr.value)
|
|
5051
|
+
buildChangeHandlerFunction(attr.value, modifier)
|
|
5015
5052
|
);
|
|
5016
5053
|
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
|
5017
5054
|
if (!existingChangedAttr) {
|
|
5018
5055
|
const bindingIdentifierPath = binding.path.getOuterBindingIdentifierPaths()[binding.identifier.name];
|
|
5019
|
-
|
|
5056
|
+
let changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value, modifier) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(
|
|
5020
5057
|
bindingIdentifierPath.parentPath
|
|
5021
5058
|
) : void 0 : void 0;
|
|
5022
5059
|
if (!changeAttrExpr) {
|
|
5023
5060
|
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
|
5024
5061
|
}
|
|
5062
|
+
if (modifier && import_compiler26.types.isIdentifier(changeAttrExpr)) {
|
|
5063
|
+
changeAttrExpr = import_compiler26.types.logicalExpression(
|
|
5064
|
+
"&&",
|
|
5065
|
+
changeAttrExpr,
|
|
5066
|
+
buildChangeHandlerFunction(attr.value, modifier)
|
|
5067
|
+
);
|
|
5068
|
+
}
|
|
5025
5069
|
const changeHandlerAttr = import_compiler26.types.markoAttribute(
|
|
5026
5070
|
changeAttrName,
|
|
5027
5071
|
changeAttrExpr
|
|
@@ -5073,10 +5117,26 @@ function getChangeHandler(tag, attr) {
|
|
|
5073
5117
|
import_compiler26.types.stringLiteral("Change")
|
|
5074
5118
|
);
|
|
5075
5119
|
const computed = memberProp.type !== "Identifier";
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
|
|
5120
|
+
let changeAttrExpr = attr.value.optional ? import_compiler26.types.optionalMemberExpression(memberObj, memberProp, computed, true) : import_compiler26.types.memberExpression(memberObj, memberProp, computed);
|
|
5121
|
+
if (modifier) {
|
|
5122
|
+
const newValueId = generateUid("next");
|
|
5123
|
+
changeAttrExpr = import_compiler26.types.logicalExpression(
|
|
5124
|
+
"&&",
|
|
5125
|
+
changeAttrExpr,
|
|
5126
|
+
import_compiler26.types.arrowFunctionExpression(
|
|
5127
|
+
[import_compiler26.types.identifier(newValueId)],
|
|
5128
|
+
import_compiler26.types.blockStatement([
|
|
5129
|
+
import_compiler26.types.expressionStatement(
|
|
5130
|
+
import_compiler26.types.callExpression(
|
|
5131
|
+
import_compiler26.types.memberExpression(memberObj, memberProp, computed),
|
|
5132
|
+
[import_compiler26.types.callExpression(modifier, [import_compiler26.types.identifier(newValueId)])]
|
|
5133
|
+
)
|
|
5134
|
+
)
|
|
5135
|
+
])
|
|
5136
|
+
)
|
|
5137
|
+
);
|
|
5138
|
+
}
|
|
5139
|
+
return import_compiler26.types.markoAttribute(changeAttrName, changeAttrExpr);
|
|
5080
5140
|
}
|
|
5081
5141
|
}
|
|
5082
5142
|
throw tag.hub.buildError(
|
|
@@ -5084,8 +5144,12 @@ function getChangeHandler(tag, attr) {
|
|
|
5084
5144
|
"Attributes may only be bound to identifiers or member expressions"
|
|
5085
5145
|
);
|
|
5086
5146
|
}
|
|
5087
|
-
function buildChangeHandlerFunction(id) {
|
|
5147
|
+
function buildChangeHandlerFunction(id, modifier) {
|
|
5088
5148
|
const newId = "_new_" + id.name;
|
|
5149
|
+
let newValue = withPreviousLocation(import_compiler26.types.identifier(newId), id);
|
|
5150
|
+
if (modifier) {
|
|
5151
|
+
newValue = import_compiler26.types.callExpression(modifier, [newValue]);
|
|
5152
|
+
}
|
|
5089
5153
|
return import_compiler26.types.arrowFunctionExpression(
|
|
5090
5154
|
[withPreviousLocation(import_compiler26.types.identifier(newId), id)],
|
|
5091
5155
|
import_compiler26.types.blockStatement([
|
|
@@ -5093,7 +5157,7 @@ function buildChangeHandlerFunction(id) {
|
|
|
5093
5157
|
import_compiler26.types.assignmentExpression(
|
|
5094
5158
|
"=",
|
|
5095
5159
|
withPreviousLocation(import_compiler26.types.identifier(id.name), id),
|
|
5096
|
-
|
|
5160
|
+
newValue
|
|
5097
5161
|
)
|
|
5098
5162
|
)
|
|
5099
5163
|
])
|
|
@@ -5272,12 +5336,12 @@ var program_default = {
|
|
|
5272
5336
|
if (getMarkoOpts().output === "hydrate") {
|
|
5273
5337
|
const entryFile = program.hub.file;
|
|
5274
5338
|
const visitedFiles = /* @__PURE__ */ new Set([
|
|
5275
|
-
(0,
|
|
5339
|
+
(0, import_babel_utils18.resolveRelativePath)(entryFile, entryFile.opts.filename)
|
|
5276
5340
|
]);
|
|
5277
5341
|
entry_builder_default.visit(entryFile, entryFile, function visitChild(resolved) {
|
|
5278
5342
|
if (!visitedFiles.has(resolved)) {
|
|
5279
5343
|
visitedFiles.add(resolved);
|
|
5280
|
-
const file = (0,
|
|
5344
|
+
const file = (0, import_babel_utils18.loadFileForImport)(entryFile, resolved);
|
|
5281
5345
|
if (file) {
|
|
5282
5346
|
entry_builder_default.visit(
|
|
5283
5347
|
file,
|
|
@@ -5320,15 +5384,24 @@ var program_default = {
|
|
|
5320
5384
|
}
|
|
5321
5385
|
};
|
|
5322
5386
|
function resolveRelativeToEntry(entryFile, file, req) {
|
|
5323
|
-
return file === entryFile ? (0,
|
|
5387
|
+
return file === entryFile ? (0, import_babel_utils18.resolveRelativePath)(file, req) : (0, import_babel_utils18.resolveRelativePath)(
|
|
5324
5388
|
entryFile,
|
|
5325
5389
|
req[0] === "." ? import_path2.default.join(file.opts.filename, "..", req) : req
|
|
5326
5390
|
);
|
|
5327
5391
|
}
|
|
5328
5392
|
|
|
5393
|
+
// src/translator/util/is-event-or-change-handler.ts
|
|
5394
|
+
function isEventOrChangeHandler(prop) {
|
|
5395
|
+
return /^on[-A-Z][a-zA-Z0-9_$]|[a-zA-Z_$][a-zA-Z0-9_$]*Change$/.test(prop);
|
|
5396
|
+
}
|
|
5397
|
+
|
|
5398
|
+
// src/translator/util/known-tag.ts
|
|
5399
|
+
var import_compiler37 = require("@marko/compiler");
|
|
5400
|
+
var import_babel_utils26 = require("@marko/compiler/babel-utils");
|
|
5401
|
+
|
|
5329
5402
|
// src/translator/util/nested-attribute-tags.ts
|
|
5330
5403
|
var import_compiler28 = require("@marko/compiler");
|
|
5331
|
-
var
|
|
5404
|
+
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
|
5332
5405
|
var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
|
|
5333
5406
|
function getAttrTagIdentifier(meta) {
|
|
5334
5407
|
let name2 = attrTagToIdentifierLookup.get(meta);
|
|
@@ -5348,13 +5421,13 @@ function analyzeAttributeTags(tag) {
|
|
|
5348
5421
|
const sampleAttrTagsForControlFlow = /* @__PURE__ */ new Map();
|
|
5349
5422
|
for (const child of attrTags2) {
|
|
5350
5423
|
if (child.isMarkoTag()) {
|
|
5351
|
-
if ((0,
|
|
5424
|
+
if ((0, import_babel_utils19.isAttributeTag)(child)) {
|
|
5352
5425
|
const name2 = getTagName(child);
|
|
5353
5426
|
lookup[name2] ||= createAttrTagMeta(name2, [name2]);
|
|
5354
5427
|
(attrTagNodesByName[name2] ||= []).push(child);
|
|
5355
5428
|
analyzeAttributeTags(child);
|
|
5356
5429
|
} else {
|
|
5357
|
-
const isRepeated = (0,
|
|
5430
|
+
const isRepeated = (0, import_babel_utils19.isLoopTag)(child);
|
|
5358
5431
|
let curGroup;
|
|
5359
5432
|
for (const name2 of crawlAttrTags(child, attrTagNodesByName)) {
|
|
5360
5433
|
const oldMeta = lookup[name2];
|
|
@@ -5409,7 +5482,7 @@ function crawlAttrTags(tag, attrTagNodesByName, attrTagNames = /* @__PURE__ */ n
|
|
|
5409
5482
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
5410
5483
|
for (const child of attrTags2) {
|
|
5411
5484
|
if (child.isMarkoTag()) {
|
|
5412
|
-
if ((0,
|
|
5485
|
+
if ((0, import_babel_utils19.isAttributeTag)(child)) {
|
|
5413
5486
|
const tagName = getTagName(child);
|
|
5414
5487
|
attrTagNames.add(tagName);
|
|
5415
5488
|
(attrTagNodesByName[tagName] ||= []).push(child);
|
|
@@ -5450,7 +5523,7 @@ function getConditionRoot(tag) {
|
|
|
5450
5523
|
|
|
5451
5524
|
// src/translator/util/set-tag-sections-downstream.ts
|
|
5452
5525
|
var import_compiler29 = require("@marko/compiler");
|
|
5453
|
-
var
|
|
5526
|
+
var import_babel_utils20 = require("@marko/compiler/babel-utils");
|
|
5454
5527
|
var [getTagDownstreams] = createSectionState(
|
|
5455
5528
|
"tag-downstreams",
|
|
5456
5529
|
() => /* @__PURE__ */ new Map()
|
|
@@ -5480,7 +5553,7 @@ function crawlSectionsAndSetBinding(tag, binding, properties, skip2) {
|
|
|
5480
5553
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
5481
5554
|
for (const child of attrTags2) {
|
|
5482
5555
|
if (child.isMarkoTag()) {
|
|
5483
|
-
if ((0,
|
|
5556
|
+
if ((0, import_babel_utils20.isAttributeTag)(child)) {
|
|
5484
5557
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
5485
5558
|
crawlSectionsAndSetBinding(
|
|
5486
5559
|
child,
|
|
@@ -5496,19 +5569,19 @@ function crawlSectionsAndSetBinding(tag, binding, properties, skip2) {
|
|
|
5496
5569
|
|
|
5497
5570
|
// src/translator/util/translate-attrs.ts
|
|
5498
5571
|
var import_compiler35 = require("@marko/compiler");
|
|
5499
|
-
var
|
|
5572
|
+
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
|
5500
5573
|
|
|
5501
5574
|
// src/translator/core/for.ts
|
|
5502
5575
|
var import_compiler34 = require("@marko/compiler");
|
|
5503
|
-
var
|
|
5576
|
+
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
|
5504
5577
|
|
|
5505
5578
|
// src/translator/util/is-only-child-in-parent.ts
|
|
5506
5579
|
var import_compiler33 = require("@marko/compiler");
|
|
5507
|
-
var
|
|
5580
|
+
var import_babel_utils23 = require("@marko/compiler/babel-utils");
|
|
5508
5581
|
|
|
5509
5582
|
// src/translator/visitors/tag/native-tag.ts
|
|
5510
5583
|
var import_compiler32 = require("@marko/compiler");
|
|
5511
|
-
var
|
|
5584
|
+
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
|
5512
5585
|
|
|
5513
5586
|
// src/translator/util/body-to-text-literal.ts
|
|
5514
5587
|
var import_compiler30 = require("@marko/compiler");
|
|
@@ -5547,7 +5620,7 @@ function templateElement(value, tail) {
|
|
|
5547
5620
|
|
|
5548
5621
|
// src/translator/util/is-non-html-text.ts
|
|
5549
5622
|
var import_compiler31 = require("@marko/compiler");
|
|
5550
|
-
var
|
|
5623
|
+
var import_babel_utils21 = require("@marko/compiler/babel-utils");
|
|
5551
5624
|
function isNonHTMLText(placeholder) {
|
|
5552
5625
|
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
|
5553
5626
|
if (parentTag) {
|
|
@@ -5565,7 +5638,7 @@ function isNonHTMLText(placeholder) {
|
|
|
5565
5638
|
return false;
|
|
5566
5639
|
}
|
|
5567
5640
|
function isTextOnlyNativeTag(tag) {
|
|
5568
|
-
const def = (0,
|
|
5641
|
+
const def = (0, import_babel_utils21.getTagDef)(tag);
|
|
5569
5642
|
return !!(def && def.html && (def.name === "title" || def.parseOptions?.text));
|
|
5570
5643
|
}
|
|
5571
5644
|
|
|
@@ -5577,9 +5650,9 @@ var htmlSelectArgs = /* @__PURE__ */ new WeakMap();
|
|
|
5577
5650
|
var native_tag_default = {
|
|
5578
5651
|
analyze: {
|
|
5579
5652
|
enter(tag) {
|
|
5580
|
-
(0,
|
|
5581
|
-
(0,
|
|
5582
|
-
(0,
|
|
5653
|
+
(0, import_babel_utils22.assertNoArgs)(tag);
|
|
5654
|
+
(0, import_babel_utils22.assertNoParams)(tag);
|
|
5655
|
+
(0, import_babel_utils22.assertNoAttributeTags)(tag);
|
|
5583
5656
|
const { node } = tag;
|
|
5584
5657
|
if (node.var && !import_compiler32.types.isIdentifier(node.var)) {
|
|
5585
5658
|
throw tag.get("var").buildCodeFrameError(
|
|
@@ -5591,7 +5664,7 @@ var native_tag_default = {
|
|
|
5591
5664
|
case "html":
|
|
5592
5665
|
case "body":
|
|
5593
5666
|
case "head":
|
|
5594
|
-
(0,
|
|
5667
|
+
(0, import_babel_utils22.getProgram)().node.extra.page ??= true;
|
|
5595
5668
|
break;
|
|
5596
5669
|
}
|
|
5597
5670
|
const isTextOnly = isTextOnlyNativeTag(tag);
|
|
@@ -5665,7 +5738,7 @@ var native_tag_default = {
|
|
|
5665
5738
|
!!node.var
|
|
5666
5739
|
);
|
|
5667
5740
|
if (hasEventHandlers) {
|
|
5668
|
-
(0,
|
|
5741
|
+
(0, import_babel_utils22.getProgram)().node.extra.isInteractive = true;
|
|
5669
5742
|
}
|
|
5670
5743
|
if (spreadReferenceNodes) {
|
|
5671
5744
|
if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
|
|
@@ -5713,7 +5786,7 @@ var native_tag_default = {
|
|
|
5713
5786
|
const tagName = getCanonicalTagName(tag);
|
|
5714
5787
|
const tagExtra = tag.node.extra;
|
|
5715
5788
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5716
|
-
const tagDef = (0,
|
|
5789
|
+
const tagDef = (0, import_babel_utils22.getTagDef)(tag);
|
|
5717
5790
|
const write = writeTo(tag);
|
|
5718
5791
|
const tagSection = getSection(tag);
|
|
5719
5792
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
@@ -5927,7 +6000,7 @@ var native_tag_default = {
|
|
|
5927
6000
|
exit(tag) {
|
|
5928
6001
|
const tagExtra = tag.node.extra;
|
|
5929
6002
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5930
|
-
const isOpenOnly = (0,
|
|
6003
|
+
const isOpenOnly = (0, import_babel_utils22.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
|
5931
6004
|
const isTextOnly = isTextOnlyNativeTag(tag);
|
|
5932
6005
|
const selectArgs = htmlSelectArgs.get(tag.node);
|
|
5933
6006
|
const tagName = getCanonicalTagName(tag);
|
|
@@ -5985,7 +6058,7 @@ var native_tag_default = {
|
|
|
5985
6058
|
const tagName = getCanonicalTagName(tag);
|
|
5986
6059
|
const tagExtra = tag.node.extra;
|
|
5987
6060
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
5988
|
-
const tagDef = (0,
|
|
6061
|
+
const tagDef = (0, import_babel_utils22.getTagDef)(tag);
|
|
5989
6062
|
const write = writeTo(tag);
|
|
5990
6063
|
const tagSection = getSection(tag);
|
|
5991
6064
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
|
@@ -6238,7 +6311,7 @@ var native_tag_default = {
|
|
|
6238
6311
|
exit(tag) {
|
|
6239
6312
|
const tagExtra = tag.node.extra;
|
|
6240
6313
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
|
6241
|
-
const openTagOnly = (0,
|
|
6314
|
+
const openTagOnly = (0, import_babel_utils22.getTagDef)(tag)?.parseOptions?.openTagOnly;
|
|
6242
6315
|
const tagName = getCanonicalTagName(tag);
|
|
6243
6316
|
if (!openTagOnly) {
|
|
6244
6317
|
const write = writeTo(tag);
|
|
@@ -6560,7 +6633,7 @@ function getOnlyChildParentTagName(tag, branchSize = 1) {
|
|
|
6560
6633
|
return extra[kOnlyChildInParent];
|
|
6561
6634
|
}
|
|
6562
6635
|
const parentTag = getParentTag(tag);
|
|
6563
|
-
return extra[kOnlyChildInParent] = parentTag && (0,
|
|
6636
|
+
return extra[kOnlyChildInParent] = parentTag && (0, import_babel_utils23.getTagDef)(parentTag)?.html && parentTag.node.name.type === "StringLiteral" && tag.parent.body.filter(
|
|
6564
6637
|
(node) => node.type !== "MarkoComment"
|
|
6565
6638
|
).length === branchSize ? parentTag.node.name.value : false;
|
|
6566
6639
|
}
|
|
@@ -6594,8 +6667,8 @@ var for_default = {
|
|
|
6594
6667
|
isAttrTag ? 4 /* local */ : 5 /* derived */
|
|
6595
6668
|
);
|
|
6596
6669
|
let allowAttrs;
|
|
6597
|
-
(0,
|
|
6598
|
-
(0,
|
|
6670
|
+
(0, import_babel_utils24.assertNoVar)(tag);
|
|
6671
|
+
(0, import_babel_utils24.assertNoArgs)(tag);
|
|
6599
6672
|
assertNoSpreadAttrs(tag);
|
|
6600
6673
|
const forType = getForType(tag.node);
|
|
6601
6674
|
switch (forType) {
|
|
@@ -6619,7 +6692,7 @@ var for_default = {
|
|
|
6619
6692
|
if (!isAttrTag) {
|
|
6620
6693
|
allowAttrs.push("by");
|
|
6621
6694
|
}
|
|
6622
|
-
(0,
|
|
6695
|
+
(0, import_babel_utils24.assertAllowedAttributes)(tag, allowAttrs);
|
|
6623
6696
|
if (isAttrTag) return;
|
|
6624
6697
|
const bodySection = startSection(tagBody);
|
|
6625
6698
|
if (!bodySection) {
|
|
@@ -6976,7 +7049,7 @@ function translateAttrs(tag, propTree = true, skip2, statements = [], contentKey
|
|
|
6976
7049
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
6977
7050
|
const child = attrTags2[i];
|
|
6978
7051
|
if (child.isMarkoTag()) {
|
|
6979
|
-
if ((0,
|
|
7052
|
+
if ((0, import_babel_utils25.isAttributeTag)(child)) {
|
|
6980
7053
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
6981
7054
|
if (skip2?.has(attrTagMeta.name)) continue;
|
|
6982
7055
|
if (attrTagMeta.dynamic) {
|
|
@@ -7076,7 +7149,7 @@ function getTranslatedBodyContentProperty(props) {
|
|
|
7076
7149
|
function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements, propTree, contentKey = "content") {
|
|
7077
7150
|
const tag = attrTags2[index];
|
|
7078
7151
|
if (tag.isMarkoTag()) {
|
|
7079
|
-
if ((0,
|
|
7152
|
+
if ((0, import_babel_utils25.isAttributeTag)(tag)) {
|
|
7080
7153
|
const attrTagMeta = attrTagLookup[getTagName(tag)];
|
|
7081
7154
|
const attrTagExport = getKnownFromPropTree(propTree, attrTagMeta.name);
|
|
7082
7155
|
if (attrTagExport && attrTagMeta.dynamic) {
|
|
@@ -7715,7 +7788,7 @@ function analyzeAttrs(rootTagExtra, section, tag, propTree, rootAttrExprs) {
|
|
|
7715
7788
|
const attrTags2 = tag.node.body.attributeTags ? tag.get("body").get("body") : tag.get("attributeTags");
|
|
7716
7789
|
for (const child of attrTags2) {
|
|
7717
7790
|
if (child.isMarkoTag()) {
|
|
7718
|
-
if ((0,
|
|
7791
|
+
if ((0, import_babel_utils26.isAttributeTag)(child)) {
|
|
7719
7792
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
7720
7793
|
const childAttrExport = getKnownFromPropTree(
|
|
7721
7794
|
propTree,
|
|
@@ -7993,7 +8066,7 @@ function applyAttrObject(tag, propTree, tagInputIdentifier, info) {
|
|
|
7993
8066
|
translatedAttrs.statements
|
|
7994
8067
|
);
|
|
7995
8068
|
}
|
|
7996
|
-
if ((0,
|
|
8069
|
+
if ((0, import_babel_utils26.isAttributeTag)(tag)) {
|
|
7997
8070
|
const attrTagName = getTagName(tag);
|
|
7998
8071
|
const parentTag = tag.parentPath;
|
|
7999
8072
|
const repeated = analyzeAttributeTags(parentTag)?.[attrTagName]?.repeated;
|
|
@@ -8113,7 +8186,7 @@ function writeAttrsToSignals(tag, propTree, importAlias, info) {
|
|
|
8113
8186
|
for (let i = 0; i < attrTags2.length; i++) {
|
|
8114
8187
|
const child = attrTags2[i];
|
|
8115
8188
|
if (child.isMarkoTag()) {
|
|
8116
|
-
if ((0,
|
|
8189
|
+
if ((0, import_babel_utils26.isAttributeTag)(child)) {
|
|
8117
8190
|
const attrTagMeta = attrTagLookup[getTagName(child)];
|
|
8118
8191
|
const childAttrExport = getKnownFromPropTree(
|
|
8119
8192
|
propTree,
|
|
@@ -8701,9 +8774,30 @@ function trackParamsReferences(body, type) {
|
|
|
8701
8774
|
return paramsBinding;
|
|
8702
8775
|
}
|
|
8703
8776
|
}
|
|
8777
|
+
function getMarkoRootAsTag(path7) {
|
|
8778
|
+
const tag = path7.isMarkoTag() ? path7 : getMarkoRoot(path7)?.parentPath;
|
|
8779
|
+
if (tag?.isMarkoTag()) {
|
|
8780
|
+
return tag;
|
|
8781
|
+
}
|
|
8782
|
+
}
|
|
8783
|
+
function isReferenceInOwnBody(bindingPath, reference) {
|
|
8784
|
+
const tag = getMarkoRootAsTag(bindingPath);
|
|
8785
|
+
if (!tag) {
|
|
8786
|
+
return false;
|
|
8787
|
+
}
|
|
8788
|
+
const body = tag.get("body");
|
|
8789
|
+
let cur = reference;
|
|
8790
|
+
while (cur) {
|
|
8791
|
+
if (cur === body) {
|
|
8792
|
+
return true;
|
|
8793
|
+
}
|
|
8794
|
+
cur = cur.parentPath;
|
|
8795
|
+
}
|
|
8796
|
+
return false;
|
|
8797
|
+
}
|
|
8704
8798
|
function isReferenceHoisted(bindingPath, reference) {
|
|
8705
|
-
const tag =
|
|
8706
|
-
if (!tag
|
|
8799
|
+
const tag = getMarkoRootAsTag(bindingPath);
|
|
8800
|
+
if (!tag) {
|
|
8707
8801
|
return false;
|
|
8708
8802
|
}
|
|
8709
8803
|
const body = tag.parentPath;
|
|
@@ -9288,7 +9382,7 @@ function finalizeReferences() {
|
|
|
9288
9382
|
});
|
|
9289
9383
|
}
|
|
9290
9384
|
});
|
|
9291
|
-
const programExtra = (0,
|
|
9385
|
+
const programExtra = (0, import_babel_utils27.getProgram)().node.extra;
|
|
9292
9386
|
if (programExtra.returnValueExpr) {
|
|
9293
9387
|
programExtra.section.returnSerializeReason = getSerializeSourcesForExpr(
|
|
9294
9388
|
programExtra.returnValueExpr
|
|
@@ -9456,7 +9550,7 @@ var [getFunctionReadsByExpression] = createProgramState(
|
|
|
9456
9550
|
);
|
|
9457
9551
|
function addRead(exprExtra, extra, binding, section, getter) {
|
|
9458
9552
|
const readsByExpression = getReadsByExpression();
|
|
9459
|
-
const read = { binding, extra, getter };
|
|
9553
|
+
const read = { binding, extra, getter, ownVar: false };
|
|
9460
9554
|
binding.reads.add(exprExtra);
|
|
9461
9555
|
exprExtra.section = section;
|
|
9462
9556
|
readsByExpression.set(
|
|
@@ -9501,6 +9595,10 @@ function addReadToExpression(root, binding, getter) {
|
|
|
9501
9595
|
section,
|
|
9502
9596
|
getter
|
|
9503
9597
|
);
|
|
9598
|
+
if (!getter && binding.type === 5 /* derived */) {
|
|
9599
|
+
const babelBinding = root.scope.getBinding(binding.name);
|
|
9600
|
+
read.ownVar = !!babelBinding && babelBinding.kind !== "param" && isReferenceInOwnBody(babelBinding.path, root);
|
|
9601
|
+
}
|
|
9504
9602
|
if (root.parent.type === "MarkoSpreadAttribute") {
|
|
9505
9603
|
exprExtra.spreadFrom = binding;
|
|
9506
9604
|
}
|
|
@@ -9636,6 +9734,12 @@ function getReadReplacement(node, signal) {
|
|
|
9636
9734
|
[getScopeExpression(extra.section, readBinding.section)]
|
|
9637
9735
|
);
|
|
9638
9736
|
}
|
|
9737
|
+
} else if (!import_config.optimize && read.ownVar) {
|
|
9738
|
+
replacement = callRuntime(
|
|
9739
|
+
"_assert_init",
|
|
9740
|
+
extra.section ? getScopeExpression(extra.section, readBinding.section) : scopeIdentifier,
|
|
9741
|
+
getScopeAccessorLiteral(readBinding)
|
|
9742
|
+
);
|
|
9639
9743
|
} else {
|
|
9640
9744
|
replacement = createScopeReadExpression(readBinding, extra.section);
|
|
9641
9745
|
}
|
|
@@ -9847,7 +9951,7 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
|
9847
9951
|
const { extra, getter } = read;
|
|
9848
9952
|
if (getter) {
|
|
9849
9953
|
extra.section = expr.section;
|
|
9850
|
-
extra.read =
|
|
9954
|
+
extra.read = createGetterRead(binding, void 0, getter);
|
|
9851
9955
|
addBindingGetter(binding, getter);
|
|
9852
9956
|
if (getter.hoisted) {
|
|
9853
9957
|
binding.hoists = sectionUtil.add(binding.hoists, getter.hoisted);
|
|
@@ -9870,20 +9974,23 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
|
9870
9974
|
allBindings = bindingUtil.add(allBindings, binding);
|
|
9871
9975
|
}
|
|
9872
9976
|
} else if (reads) {
|
|
9873
|
-
const { binding, extra, getter } = reads;
|
|
9977
|
+
const { binding, extra, getter, ownVar } = reads;
|
|
9874
9978
|
if (getter) {
|
|
9979
|
+
extra.read = createGetterRead(binding, void 0, getter);
|
|
9875
9980
|
addBindingGetter(binding, getter);
|
|
9876
9981
|
if (getter.hoisted) {
|
|
9877
9982
|
binding.hoists = sectionUtil.add(binding.hoists, getter.hoisted);
|
|
9878
9983
|
hoistedBindings = bindingUtil.add(hoistedBindings, binding);
|
|
9879
9984
|
}
|
|
9880
|
-
} else
|
|
9881
|
-
|
|
9882
|
-
|
|
9883
|
-
|
|
9985
|
+
} else {
|
|
9986
|
+
extra.read = createRead(binding, void 0, ownVar);
|
|
9987
|
+
if (binding.type === 6 /* constant */) {
|
|
9988
|
+
constantBindings = binding;
|
|
9989
|
+
} else if (binding.type !== 0 /* dom */) {
|
|
9990
|
+
referencedBindings = binding;
|
|
9991
|
+
}
|
|
9884
9992
|
}
|
|
9885
9993
|
extra.section = expr.section;
|
|
9886
|
-
extra.read = createRead(binding, void 0, getter);
|
|
9887
9994
|
allBindings = binding;
|
|
9888
9995
|
}
|
|
9889
9996
|
if (Array.isArray(referencedBindings)) {
|
|
@@ -9930,7 +10037,7 @@ function resolveReferencedBindings(expr, reads, intersectionsBySection) {
|
|
|
9930
10037
|
function resolveExpressionReference(rootBindings, readBinding) {
|
|
9931
10038
|
const upstreamRoot = readBinding.upstreamAlias && findClosestReference(readBinding.upstreamAlias, rootBindings);
|
|
9932
10039
|
if (!upstreamRoot) {
|
|
9933
|
-
return createRead(readBinding, void 0
|
|
10040
|
+
return createRead(readBinding, void 0);
|
|
9934
10041
|
}
|
|
9935
10042
|
let curBinding = readBinding;
|
|
9936
10043
|
let props;
|
|
@@ -9943,15 +10050,18 @@ function resolveExpressionReference(rootBindings, readBinding) {
|
|
|
9943
10050
|
if (Array.isArray(props)) {
|
|
9944
10051
|
props.reverse();
|
|
9945
10052
|
}
|
|
9946
|
-
return createRead(upstreamRoot, props
|
|
10053
|
+
return createRead(upstreamRoot, props);
|
|
9947
10054
|
}
|
|
9948
10055
|
function isSupersetSources(a, b) {
|
|
9949
10056
|
if (!b.sources) return true;
|
|
9950
10057
|
if (!a.sources) return false;
|
|
9951
10058
|
return bindingUtil.isSuperset(a.sources.state, b.sources.state) && bindingUtil.isSuperset(a.sources.param, b.sources.param);
|
|
9952
10059
|
}
|
|
9953
|
-
function createRead(binding, props,
|
|
9954
|
-
return { binding, props, getter };
|
|
10060
|
+
function createRead(binding, props, ownVar = false) {
|
|
10061
|
+
return { binding, props, ownVar, getter: void 0 };
|
|
10062
|
+
}
|
|
10063
|
+
function createGetterRead(binding, props, getter) {
|
|
10064
|
+
return { binding, props, ownVar: false, getter };
|
|
9955
10065
|
}
|
|
9956
10066
|
function getMemberExpressionPropString(expr) {
|
|
9957
10067
|
switch (expr.property.type) {
|
|
@@ -9985,7 +10095,7 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
9985
10095
|
let reason = serializeReasonCache.get(extra);
|
|
9986
10096
|
if (reason === false) return;
|
|
9987
10097
|
if (reason === void 0) {
|
|
9988
|
-
if (extra === (0,
|
|
10098
|
+
if (extra === (0, import_babel_utils27.getProgram)().node.extra?.returnValueExpr) {
|
|
9989
10099
|
reason = true;
|
|
9990
10100
|
} else {
|
|
9991
10101
|
serializeReasonCache.set(extra, false);
|
|
@@ -10109,10 +10219,10 @@ function setReadsOwner(from, to) {
|
|
|
10109
10219
|
var kDOMBinding = /* @__PURE__ */ Symbol("await tag dom binding");
|
|
10110
10220
|
var await_default = {
|
|
10111
10221
|
analyze(tag) {
|
|
10112
|
-
(0,
|
|
10113
|
-
(0,
|
|
10222
|
+
(0, import_babel_utils28.assertNoVar)(tag);
|
|
10223
|
+
(0, import_babel_utils28.assertNoArgs)(tag);
|
|
10114
10224
|
assertNoSpreadAttrs(tag);
|
|
10115
|
-
(0,
|
|
10225
|
+
(0, import_babel_utils28.assertNoAttributeTags)(tag);
|
|
10116
10226
|
const { node } = tag;
|
|
10117
10227
|
const tagBody = tag.get("body");
|
|
10118
10228
|
const section = getOrCreateSection(tag);
|
|
@@ -10258,7 +10368,7 @@ var await_default = {
|
|
|
10258
10368
|
|
|
10259
10369
|
// src/translator/core/client.ts
|
|
10260
10370
|
var import_compiler40 = require("@marko/compiler");
|
|
10261
|
-
var
|
|
10371
|
+
var import_babel_utils29 = require("@marko/compiler/babel-utils");
|
|
10262
10372
|
var client_default = {
|
|
10263
10373
|
parse(tag) {
|
|
10264
10374
|
const {
|
|
@@ -10268,7 +10378,7 @@ var client_default = {
|
|
|
10268
10378
|
const rawValue = node.rawValue;
|
|
10269
10379
|
const code = rawValue.replace(/^client\s*/, "");
|
|
10270
10380
|
const start = node.start + (rawValue.length - code.length);
|
|
10271
|
-
let body = (0,
|
|
10381
|
+
let body = (0, import_babel_utils29.parseStatements)(file, code, start, start + code.length);
|
|
10272
10382
|
if (body.length === 1 && import_compiler40.types.isBlockStatement(body[0])) {
|
|
10273
10383
|
body = body[0].body;
|
|
10274
10384
|
}
|
|
@@ -10289,11 +10399,11 @@ var client_default = {
|
|
|
10289
10399
|
|
|
10290
10400
|
// src/translator/core/const.ts
|
|
10291
10401
|
var import_compiler41 = require("@marko/compiler");
|
|
10292
|
-
var
|
|
10402
|
+
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
|
10293
10403
|
var const_default = {
|
|
10294
10404
|
analyze(tag) {
|
|
10295
|
-
(0,
|
|
10296
|
-
(0,
|
|
10405
|
+
(0, import_babel_utils30.assertNoArgs)(tag);
|
|
10406
|
+
(0, import_babel_utils30.assertNoParams)(tag);
|
|
10297
10407
|
assertNoBodyContent(tag);
|
|
10298
10408
|
const { node } = tag;
|
|
10299
10409
|
const [valueAttr] = node.attributes;
|
|
@@ -10370,13 +10480,13 @@ var const_default = {
|
|
|
10370
10480
|
|
|
10371
10481
|
// src/translator/core/debug.ts
|
|
10372
10482
|
var import_compiler42 = require("@marko/compiler");
|
|
10373
|
-
var
|
|
10483
|
+
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
|
10374
10484
|
var debug_default = {
|
|
10375
10485
|
analyze(tag) {
|
|
10376
10486
|
const [valueAttr] = tag.node.attributes;
|
|
10377
|
-
(0,
|
|
10378
|
-
(0,
|
|
10379
|
-
(0,
|
|
10487
|
+
(0, import_babel_utils31.assertNoVar)(tag);
|
|
10488
|
+
(0, import_babel_utils31.assertNoArgs)(tag);
|
|
10489
|
+
(0, import_babel_utils31.assertNoParams)(tag);
|
|
10380
10490
|
assertNoBodyContent(tag);
|
|
10381
10491
|
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler42.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
|
10382
10492
|
throw tag.get("name").buildCodeFrameError(
|
|
@@ -10413,10 +10523,10 @@ var debug_default = {
|
|
|
10413
10523
|
|
|
10414
10524
|
// src/translator/core/define.ts
|
|
10415
10525
|
var import_compiler43 = require("@marko/compiler");
|
|
10416
|
-
var
|
|
10526
|
+
var import_babel_utils32 = require("@marko/compiler/babel-utils");
|
|
10417
10527
|
var define_default = {
|
|
10418
10528
|
analyze(tag) {
|
|
10419
|
-
(0,
|
|
10529
|
+
(0, import_babel_utils32.assertNoArgs)(tag);
|
|
10420
10530
|
if (!tag.node.var) {
|
|
10421
10531
|
throw tag.get("name").buildCodeFrameError(
|
|
10422
10532
|
"The [`<define>` tag](https://markojs.com/docs/reference/core-tag#define) requires a [tag variable](https://markojs.com/docs/reference/language#tag-variables)."
|
|
@@ -10547,17 +10657,17 @@ var define_default = {
|
|
|
10547
10657
|
|
|
10548
10658
|
// src/translator/core/effect.ts
|
|
10549
10659
|
var import_compiler44 = require("@marko/compiler");
|
|
10550
|
-
var
|
|
10660
|
+
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
|
10551
10661
|
var effect_default = {
|
|
10552
10662
|
migrate: [
|
|
10553
10663
|
(tag) => {
|
|
10554
|
-
(0,
|
|
10555
|
-
(0,
|
|
10664
|
+
(0, import_babel_utils33.assertNoArgs)(tag);
|
|
10665
|
+
(0, import_babel_utils33.assertNoParams)(tag);
|
|
10556
10666
|
assertNoBodyContent(tag);
|
|
10557
|
-
(0,
|
|
10667
|
+
(0, import_babel_utils33.assertNoAttributeTags)(tag);
|
|
10558
10668
|
assertNoSpreadAttrs(tag);
|
|
10559
|
-
(0,
|
|
10560
|
-
(0,
|
|
10669
|
+
(0, import_babel_utils33.assertAllowedAttributes)(tag, ["value"]);
|
|
10670
|
+
(0, import_babel_utils33.diagnosticDeprecate)(tag, {
|
|
10561
10671
|
label: "The 'effect' tag has been replaced by the 'script' tag.",
|
|
10562
10672
|
fix() {
|
|
10563
10673
|
const { node } = tag;
|
|
@@ -10580,12 +10690,12 @@ var effect_default = {
|
|
|
10580
10690
|
};
|
|
10581
10691
|
|
|
10582
10692
|
// src/translator/core/export.ts
|
|
10583
|
-
var
|
|
10693
|
+
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
|
10584
10694
|
var export_default = {
|
|
10585
10695
|
parse(tag) {
|
|
10586
10696
|
const { node } = tag;
|
|
10587
10697
|
tag.replaceWith(
|
|
10588
|
-
(0,
|
|
10698
|
+
(0, import_babel_utils34.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
10589
10699
|
);
|
|
10590
10700
|
},
|
|
10591
10701
|
parseOptions: {
|
|
@@ -10601,13 +10711,13 @@ var export_default = {
|
|
|
10601
10711
|
|
|
10602
10712
|
// src/translator/core/html-comment.ts
|
|
10603
10713
|
var import_compiler45 = require("@marko/compiler");
|
|
10604
|
-
var
|
|
10714
|
+
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
|
10605
10715
|
var kNodeBinding = /* @__PURE__ */ Symbol("comment tag binding");
|
|
10606
10716
|
var html_comment_default = {
|
|
10607
10717
|
analyze(tag) {
|
|
10608
|
-
(0,
|
|
10609
|
-
(0,
|
|
10610
|
-
(0,
|
|
10718
|
+
(0, import_babel_utils35.assertNoArgs)(tag);
|
|
10719
|
+
(0, import_babel_utils35.assertNoParams)(tag);
|
|
10720
|
+
(0, import_babel_utils35.assertNoAttributes)(tag);
|
|
10611
10721
|
const tagVar = tag.node.var;
|
|
10612
10722
|
let needsBinding = false;
|
|
10613
10723
|
if (tagVar) {
|
|
@@ -10747,13 +10857,13 @@ var html_style_default = {
|
|
|
10747
10857
|
|
|
10748
10858
|
// src/translator/core/id.ts
|
|
10749
10859
|
var import_compiler46 = require("@marko/compiler");
|
|
10750
|
-
var
|
|
10860
|
+
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
|
10751
10861
|
var id_default = {
|
|
10752
10862
|
analyze(tag) {
|
|
10753
|
-
(0,
|
|
10754
|
-
(0,
|
|
10863
|
+
(0, import_babel_utils36.assertNoArgs)(tag);
|
|
10864
|
+
(0, import_babel_utils36.assertNoParams)(tag);
|
|
10755
10865
|
assertNoBodyContent(tag);
|
|
10756
|
-
(0,
|
|
10866
|
+
(0, import_babel_utils36.assertNoAttributeTags)(tag);
|
|
10757
10867
|
const { node } = tag;
|
|
10758
10868
|
const [valueAttr] = node.attributes;
|
|
10759
10869
|
if (!node.var) {
|
|
@@ -10825,7 +10935,7 @@ var id_default = {
|
|
|
10825
10935
|
|
|
10826
10936
|
// src/translator/core/if.ts
|
|
10827
10937
|
var import_compiler48 = require("@marko/compiler");
|
|
10828
|
-
var
|
|
10938
|
+
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
|
10829
10939
|
|
|
10830
10940
|
// src/translator/util/to-first-statement-or-block.ts
|
|
10831
10941
|
var import_compiler47 = require("@marko/compiler");
|
|
@@ -11093,9 +11203,9 @@ var ElseTag = {
|
|
|
11093
11203
|
]
|
|
11094
11204
|
};
|
|
11095
11205
|
function assertValidCondition(tag) {
|
|
11096
|
-
(0,
|
|
11097
|
-
(0,
|
|
11098
|
-
(0,
|
|
11206
|
+
(0, import_babel_utils37.assertNoVar)(tag);
|
|
11207
|
+
(0, import_babel_utils37.assertNoArgs)(tag);
|
|
11208
|
+
(0, import_babel_utils37.assertNoParams)(tag);
|
|
11099
11209
|
assertHasBody(tag);
|
|
11100
11210
|
assertNoSpreadAttrs(tag);
|
|
11101
11211
|
switch (getTagName(tag)) {
|
|
@@ -11194,12 +11304,12 @@ function isRoot(tag) {
|
|
|
11194
11304
|
}
|
|
11195
11305
|
|
|
11196
11306
|
// src/translator/core/import.ts
|
|
11197
|
-
var
|
|
11307
|
+
var import_babel_utils38 = require("@marko/compiler/babel-utils");
|
|
11198
11308
|
var import_default = {
|
|
11199
11309
|
parse(tag) {
|
|
11200
11310
|
const { node } = tag;
|
|
11201
11311
|
tag.replaceWith(
|
|
11202
|
-
(0,
|
|
11312
|
+
(0, import_babel_utils38.parseStatements)(tag.hub.file, node.rawValue, node.start, node.end)[0]
|
|
11203
11313
|
);
|
|
11204
11314
|
},
|
|
11205
11315
|
parseOptions: {
|
|
@@ -11218,7 +11328,7 @@ var import_default = {
|
|
|
11218
11328
|
|
|
11219
11329
|
// src/translator/core/let.ts
|
|
11220
11330
|
var import_compiler49 = require("@marko/compiler");
|
|
11221
|
-
var
|
|
11331
|
+
var import_babel_utils39 = require("@marko/compiler/babel-utils");
|
|
11222
11332
|
var let_default = {
|
|
11223
11333
|
analyze(tag) {
|
|
11224
11334
|
const { node } = tag;
|
|
@@ -11247,8 +11357,8 @@ var let_default = {
|
|
|
11247
11357
|
}
|
|
11248
11358
|
}
|
|
11249
11359
|
}
|
|
11250
|
-
(0,
|
|
11251
|
-
(0,
|
|
11360
|
+
(0, import_babel_utils39.assertNoArgs)(tag);
|
|
11361
|
+
(0, import_babel_utils39.assertNoParams)(tag);
|
|
11252
11362
|
assertNoBodyContent(tag);
|
|
11253
11363
|
assertNoSpreadAttrs(tag);
|
|
11254
11364
|
if (!tagVar) {
|
|
@@ -11261,7 +11371,7 @@ var let_default = {
|
|
|
11261
11371
|
"The [`<let>` tag](https://markojs.com/docs/reference/core-tag#let) variable cannot be destructured."
|
|
11262
11372
|
);
|
|
11263
11373
|
}
|
|
11264
|
-
if (valueChangeAttr && (0,
|
|
11374
|
+
if (valueChangeAttr && (0, import_babel_utils39.computeNode)(valueChangeAttr.value)?.value) {
|
|
11265
11375
|
throw tag.get("attributes").find((attr) => attr.node === valueChangeAttr).get("value").buildCodeFrameError(
|
|
11266
11376
|
"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."
|
|
11267
11377
|
);
|
|
@@ -11344,13 +11454,13 @@ var let_default = {
|
|
|
11344
11454
|
|
|
11345
11455
|
// src/translator/core/lifecycle.ts
|
|
11346
11456
|
var import_compiler50 = require("@marko/compiler");
|
|
11347
|
-
var
|
|
11457
|
+
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
|
11348
11458
|
var [getIndex, setIndex] = createSectionState("lifecycleIndex", () => 0);
|
|
11349
11459
|
var lifecycle_default = {
|
|
11350
11460
|
analyze(tag) {
|
|
11351
|
-
(0,
|
|
11352
|
-
(0,
|
|
11353
|
-
(0,
|
|
11461
|
+
(0, import_babel_utils40.assertNoArgs)(tag);
|
|
11462
|
+
(0, import_babel_utils40.assertNoVar)(tag);
|
|
11463
|
+
(0, import_babel_utils40.assertNoParams)(tag);
|
|
11354
11464
|
assertNoBodyContent(tag);
|
|
11355
11465
|
const { node } = tag;
|
|
11356
11466
|
const section = getOrCreateSection(tag);
|
|
@@ -11372,7 +11482,7 @@ var lifecycle_default = {
|
|
|
11372
11482
|
);
|
|
11373
11483
|
}
|
|
11374
11484
|
}
|
|
11375
|
-
(0,
|
|
11485
|
+
(0, import_babel_utils40.getProgram)().node.extra.isInteractive = true;
|
|
11376
11486
|
},
|
|
11377
11487
|
translate: {
|
|
11378
11488
|
exit(tag) {
|
|
@@ -11421,13 +11531,13 @@ var lifecycle_default = {
|
|
|
11421
11531
|
|
|
11422
11532
|
// src/translator/core/log.ts
|
|
11423
11533
|
var import_compiler51 = require("@marko/compiler");
|
|
11424
|
-
var
|
|
11534
|
+
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
|
11425
11535
|
var log_default = {
|
|
11426
11536
|
analyze(tag) {
|
|
11427
11537
|
const [valueAttr] = tag.node.attributes;
|
|
11428
|
-
(0,
|
|
11429
|
-
(0,
|
|
11430
|
-
(0,
|
|
11538
|
+
(0, import_babel_utils41.assertNoArgs)(tag);
|
|
11539
|
+
(0, import_babel_utils41.assertNoVar)(tag);
|
|
11540
|
+
(0, import_babel_utils41.assertNoParams)(tag);
|
|
11431
11541
|
assertNoBodyContent(tag);
|
|
11432
11542
|
if (!valueAttr) {
|
|
11433
11543
|
throw tag.get("name").buildCodeFrameError(
|
|
@@ -11475,7 +11585,7 @@ var log_default = {
|
|
|
11475
11585
|
|
|
11476
11586
|
// src/translator/core/script.ts
|
|
11477
11587
|
var import_compiler52 = require("@marko/compiler");
|
|
11478
|
-
var
|
|
11588
|
+
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
|
11479
11589
|
var htmlScriptTagAlternateMsg = " For a native html [`<script>` tag](https://markojs.com/docs/reference/core-tag#script) use the `html-script` core tag instead.";
|
|
11480
11590
|
var script_default = {
|
|
11481
11591
|
parse(tag) {
|
|
@@ -11495,7 +11605,7 @@ var script_default = {
|
|
|
11495
11605
|
}
|
|
11496
11606
|
const start = body[0]?.start;
|
|
11497
11607
|
const end = body[body.length - 1]?.end;
|
|
11498
|
-
const bodyStatements = (0,
|
|
11608
|
+
const bodyStatements = (0, import_babel_utils42.parseStatements)(tag.hub.file, code, start, end);
|
|
11499
11609
|
if (bodyStatements.length) {
|
|
11500
11610
|
const valueFn = import_compiler52.types.arrowFunctionExpression(
|
|
11501
11611
|
[],
|
|
@@ -11509,10 +11619,10 @@ var script_default = {
|
|
|
11509
11619
|
},
|
|
11510
11620
|
analyze(tag) {
|
|
11511
11621
|
const { node } = tag;
|
|
11512
|
-
(0,
|
|
11513
|
-
(0,
|
|
11622
|
+
(0, import_babel_utils42.assertNoArgs)(tag);
|
|
11623
|
+
(0, import_babel_utils42.assertNoParams)(tag);
|
|
11514
11624
|
assertNoBodyContent(tag);
|
|
11515
|
-
(0,
|
|
11625
|
+
(0, import_babel_utils42.assertNoAttributeTags)(tag);
|
|
11516
11626
|
if (node.var) {
|
|
11517
11627
|
throw tag.hub.buildError(
|
|
11518
11628
|
node.var,
|
|
@@ -11527,7 +11637,7 @@ var script_default = {
|
|
|
11527
11637
|
}
|
|
11528
11638
|
seenValueAttr = true;
|
|
11529
11639
|
(attr.value.extra ??= {}).isEffect = true;
|
|
11530
|
-
(0,
|
|
11640
|
+
(0, import_babel_utils42.getProgram)().node.extra.isInteractive = true;
|
|
11531
11641
|
} else {
|
|
11532
11642
|
throw tag.hub.buildError(
|
|
11533
11643
|
attr,
|
|
@@ -11617,7 +11727,7 @@ function isAwaitExpression(node) {
|
|
|
11617
11727
|
|
|
11618
11728
|
// src/translator/core/server.ts
|
|
11619
11729
|
var import_compiler53 = require("@marko/compiler");
|
|
11620
|
-
var
|
|
11730
|
+
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
|
11621
11731
|
var server_default = {
|
|
11622
11732
|
parse(tag) {
|
|
11623
11733
|
const {
|
|
@@ -11627,7 +11737,7 @@ var server_default = {
|
|
|
11627
11737
|
const rawValue = node.rawValue;
|
|
11628
11738
|
const code = rawValue.replace(/^server\s*/, "");
|
|
11629
11739
|
const start = node.start + (rawValue.length - code.length);
|
|
11630
|
-
let body = (0,
|
|
11740
|
+
let body = (0, import_babel_utils43.parseStatements)(file, code, start, start + code.length);
|
|
11631
11741
|
if (body.length === 1 && import_compiler53.types.isBlockStatement(body[0])) {
|
|
11632
11742
|
body = body[0].body;
|
|
11633
11743
|
}
|
|
@@ -11648,7 +11758,7 @@ var server_default = {
|
|
|
11648
11758
|
|
|
11649
11759
|
// src/translator/core/static.ts
|
|
11650
11760
|
var import_compiler54 = require("@marko/compiler");
|
|
11651
|
-
var
|
|
11761
|
+
var import_babel_utils44 = require("@marko/compiler/babel-utils");
|
|
11652
11762
|
var static_default = {
|
|
11653
11763
|
parse(tag) {
|
|
11654
11764
|
const {
|
|
@@ -11658,7 +11768,7 @@ var static_default = {
|
|
|
11658
11768
|
const rawValue = node.rawValue;
|
|
11659
11769
|
const code = rawValue.replace(/^static\s*/, "");
|
|
11660
11770
|
const start = node.start + (rawValue.length - code.length);
|
|
11661
|
-
let body = (0,
|
|
11771
|
+
let body = (0, import_babel_utils44.parseStatements)(file, code, start, start + code.length);
|
|
11662
11772
|
if (body.length === 1 && import_compiler54.types.isBlockStatement(body[0])) {
|
|
11663
11773
|
body = body[0].body;
|
|
11664
11774
|
}
|
|
@@ -11679,16 +11789,16 @@ var static_default = {
|
|
|
11679
11789
|
|
|
11680
11790
|
// src/translator/core/style.ts
|
|
11681
11791
|
var import_compiler55 = require("@marko/compiler");
|
|
11682
|
-
var
|
|
11792
|
+
var import_babel_utils45 = require("@marko/compiler/babel-utils");
|
|
11683
11793
|
var import_magic_string = __toESM(require("magic-string"));
|
|
11684
11794
|
var import_path3 = __toESM(require("path"));
|
|
11685
11795
|
var STYLE_EXT_REG = /^style((?:\.[a-zA-Z0-9$_-]+)+)?/;
|
|
11686
11796
|
var htmlStyleTagAlternateMsg = " For a native html [`<style>` tag](https://markojs.com/docs/reference/core-tag#style) use the `html-style` core tag instead.";
|
|
11687
11797
|
var style_default = {
|
|
11688
11798
|
analyze(tag) {
|
|
11689
|
-
(0,
|
|
11690
|
-
(0,
|
|
11691
|
-
(0,
|
|
11799
|
+
(0, import_babel_utils45.assertNoArgs)(tag);
|
|
11800
|
+
(0, import_babel_utils45.assertNoParams)(tag);
|
|
11801
|
+
(0, import_babel_utils45.assertNoAttributeTags)(tag);
|
|
11692
11802
|
const { node } = tag;
|
|
11693
11803
|
const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
|
|
11694
11804
|
for (const attr of node.attributes) {
|
|
@@ -11728,13 +11838,13 @@ var style_default = {
|
|
|
11728
11838
|
for (const child of node.body.body) {
|
|
11729
11839
|
code += child.value;
|
|
11730
11840
|
if (createMap) {
|
|
11731
|
-
const start = (0,
|
|
11841
|
+
const start = (0, import_babel_utils45.getStart)(file, child);
|
|
11732
11842
|
if (start !== null) {
|
|
11733
11843
|
magicString ||= new import_magic_string.default(file.code, { filename });
|
|
11734
11844
|
if (start > last) {
|
|
11735
11845
|
magicString.remove(last, start);
|
|
11736
11846
|
}
|
|
11737
|
-
last = (0,
|
|
11847
|
+
last = (0, import_babel_utils45.getEnd)(file, child);
|
|
11738
11848
|
}
|
|
11739
11849
|
}
|
|
11740
11850
|
}
|
|
@@ -11761,11 +11871,11 @@ var style_default = {
|
|
|
11761
11871
|
});
|
|
11762
11872
|
if (importPath) {
|
|
11763
11873
|
if (!node.var) {
|
|
11764
|
-
(0,
|
|
11874
|
+
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11765
11875
|
import_compiler55.types.importDeclaration([], import_compiler55.types.stringLiteral(importPath))
|
|
11766
11876
|
);
|
|
11767
11877
|
} else if (import_compiler55.types.isIdentifier(node.var)) {
|
|
11768
|
-
(0,
|
|
11878
|
+
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11769
11879
|
import_compiler55.types.importDeclaration(
|
|
11770
11880
|
[import_compiler55.types.importNamespaceSpecifier(node.var)],
|
|
11771
11881
|
import_compiler55.types.stringLiteral(importPath)
|
|
@@ -11773,9 +11883,9 @@ var style_default = {
|
|
|
11773
11883
|
);
|
|
11774
11884
|
} else {
|
|
11775
11885
|
const varDecl = import_compiler55.types.variableDeclaration("const", [
|
|
11776
|
-
import_compiler55.types.variableDeclarator(node.var, (0,
|
|
11886
|
+
import_compiler55.types.variableDeclarator(node.var, (0, import_babel_utils45.importStar)(file, importPath, "style"))
|
|
11777
11887
|
]);
|
|
11778
|
-
(0,
|
|
11888
|
+
(0, import_babel_utils45.getProgram)().node.body.push(
|
|
11779
11889
|
isOutputDOM() ? varDecl : import_compiler55.types.markoScriptlet([varDecl], true)
|
|
11780
11890
|
);
|
|
11781
11891
|
}
|
|
@@ -11793,15 +11903,15 @@ var style_default = {
|
|
|
11793
11903
|
|
|
11794
11904
|
// src/translator/core/try.ts
|
|
11795
11905
|
var import_compiler56 = require("@marko/compiler");
|
|
11796
|
-
var
|
|
11906
|
+
var import_babel_utils46 = require("@marko/compiler/babel-utils");
|
|
11797
11907
|
var hasEnabledCatch = /* @__PURE__ */ new WeakSet();
|
|
11798
11908
|
var kDOMBinding2 = /* @__PURE__ */ Symbol("try tag dom binding");
|
|
11799
11909
|
var try_default = {
|
|
11800
11910
|
analyze(tag) {
|
|
11801
|
-
(0,
|
|
11802
|
-
(0,
|
|
11803
|
-
(0,
|
|
11804
|
-
(0,
|
|
11911
|
+
(0, import_babel_utils46.assertNoVar)(tag);
|
|
11912
|
+
(0, import_babel_utils46.assertNoArgs)(tag);
|
|
11913
|
+
(0, import_babel_utils46.assertNoParams)(tag);
|
|
11914
|
+
(0, import_babel_utils46.assertNoAttributes)(tag);
|
|
11805
11915
|
assertNoSpreadAttrs(tag);
|
|
11806
11916
|
analyzeAttributeTags(tag);
|
|
11807
11917
|
const section = getOrCreateSection(tag);
|
|
@@ -11914,7 +12024,7 @@ var try_default = {
|
|
|
11914
12024
|
translatedAttrs.statements
|
|
11915
12025
|
);
|
|
11916
12026
|
}
|
|
11917
|
-
const program = (0,
|
|
12027
|
+
const program = (0, import_babel_utils46.getProgram)().node;
|
|
11918
12028
|
if (!hasEnabledCatch.has(program)) {
|
|
11919
12029
|
hasEnabledCatch.add(program);
|
|
11920
12030
|
program.body.push(
|
|
@@ -12016,13 +12126,13 @@ var document_type_default = {
|
|
|
12016
12126
|
};
|
|
12017
12127
|
|
|
12018
12128
|
// src/translator/visitors/import-declaration.ts
|
|
12019
|
-
var
|
|
12129
|
+
var import_babel_utils47 = require("@marko/compiler/babel-utils");
|
|
12020
12130
|
var import_declaration_default = {
|
|
12021
12131
|
analyze(importDecl) {
|
|
12022
12132
|
const { node } = importDecl;
|
|
12023
12133
|
const { source } = node;
|
|
12024
12134
|
const { value } = source;
|
|
12025
|
-
const tagImport = (0,
|
|
12135
|
+
const tagImport = (0, import_babel_utils47.resolveTagImport)(importDecl, value);
|
|
12026
12136
|
if (tagImport) {
|
|
12027
12137
|
node.extra ??= {};
|
|
12028
12138
|
node.extra.tagImport = tagImport;
|
|
@@ -12324,7 +12434,7 @@ var referenced_identifier_default = {
|
|
|
12324
12434
|
|
|
12325
12435
|
// src/translator/visitors/scriptlet.ts
|
|
12326
12436
|
var import_compiler59 = require("@marko/compiler");
|
|
12327
|
-
var
|
|
12437
|
+
var import_babel_utils48 = require("@marko/compiler/babel-utils");
|
|
12328
12438
|
var scriptlet_default = {
|
|
12329
12439
|
analyze(scriptlet) {
|
|
12330
12440
|
if (!scriptlet.node.static) {
|
|
@@ -12338,7 +12448,7 @@ var scriptlet_default = {
|
|
|
12338
12448
|
scriptlet.node.body
|
|
12339
12449
|
);
|
|
12340
12450
|
if (scriptlet.node.target === "client") {
|
|
12341
|
-
(0,
|
|
12451
|
+
(0, import_babel_utils48.getProgram)().node.extra.isInteractive = true;
|
|
12342
12452
|
}
|
|
12343
12453
|
},
|
|
12344
12454
|
translate: {
|
|
@@ -12374,20 +12484,20 @@ var scriptlet_default = {
|
|
|
12374
12484
|
|
|
12375
12485
|
// src/translator/visitors/tag/index.ts
|
|
12376
12486
|
var import_compiler63 = require("@marko/compiler");
|
|
12377
|
-
var
|
|
12487
|
+
var import_babel_utils52 = require("@marko/compiler/babel-utils");
|
|
12378
12488
|
|
|
12379
12489
|
// src/translator/visitors/tag/attribute-tag.ts
|
|
12380
12490
|
var import_compiler60 = require("@marko/compiler");
|
|
12381
|
-
var
|
|
12491
|
+
var import_babel_utils49 = require("@marko/compiler/babel-utils");
|
|
12382
12492
|
var attribute_tag_default = {
|
|
12383
12493
|
analyze: {
|
|
12384
12494
|
enter(tag) {
|
|
12385
|
-
(0,
|
|
12386
|
-
(0,
|
|
12495
|
+
(0, import_babel_utils49.assertNoVar)(tag);
|
|
12496
|
+
(0, import_babel_utils49.assertNoArgs)(tag);
|
|
12387
12497
|
const body = tag.get("body");
|
|
12388
12498
|
startSection(body);
|
|
12389
12499
|
trackParamsReferences(body, 3 /* param */);
|
|
12390
|
-
if (!(0,
|
|
12500
|
+
if (!(0, import_babel_utils49.findParentTag)(tag)) {
|
|
12391
12501
|
throw tag.get("name").buildCodeFrameError(
|
|
12392
12502
|
"[Attribute tags](https://markojs.com/docs/reference/language#attribute-tags) must be nested within another tag."
|
|
12393
12503
|
);
|
|
@@ -12411,20 +12521,20 @@ var attribute_tag_default = {
|
|
|
12411
12521
|
|
|
12412
12522
|
// src/translator/visitors/tag/custom-tag.ts
|
|
12413
12523
|
var import_compiler61 = require("@marko/compiler");
|
|
12414
|
-
var
|
|
12524
|
+
var import_babel_utils50 = require("@marko/compiler/babel-utils");
|
|
12415
12525
|
var import_fastest_levenshtein = require("fastest-levenshtein");
|
|
12416
12526
|
var import_path4 = __toESM(require("path"));
|
|
12417
12527
|
var custom_tag_default = {
|
|
12418
12528
|
analyze: {
|
|
12419
12529
|
enter(tag) {
|
|
12420
|
-
const templateFile = (0,
|
|
12530
|
+
const templateFile = (0, import_babel_utils50.getTagTemplate)(tag);
|
|
12421
12531
|
if (!templateFile) throw tagNotFoundError(tag);
|
|
12422
|
-
(0,
|
|
12423
|
-
const childFile = (0,
|
|
12532
|
+
(0, import_babel_utils50.assertAttributesOrSingleArg)(tag);
|
|
12533
|
+
const childFile = (0, import_babel_utils50.loadFileForTag)(tag);
|
|
12424
12534
|
if (!childFile) {
|
|
12425
12535
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
|
12426
12536
|
}
|
|
12427
|
-
const programExtra = (0,
|
|
12537
|
+
const programExtra = (0, import_babel_utils50.getProgram)().node.extra;
|
|
12428
12538
|
const programSection = programExtra.section;
|
|
12429
12539
|
const childProgram = childFile.ast.program;
|
|
12430
12540
|
const childExtra = childProgram.extra;
|
|
@@ -12456,12 +12566,12 @@ var custom_tag_default = {
|
|
|
12456
12566
|
};
|
|
12457
12567
|
function translateHTML(tag) {
|
|
12458
12568
|
const { node } = tag;
|
|
12459
|
-
const childProgram = (0,
|
|
12569
|
+
const childProgram = (0, import_babel_utils50.loadFileForTag)(tag).ast.program;
|
|
12460
12570
|
const childExtra = childProgram.extra;
|
|
12461
12571
|
let tagIdentifier;
|
|
12462
12572
|
if (import_compiler61.types.isStringLiteral(node.name)) {
|
|
12463
12573
|
const relativePath = getTagRelativePath(tag);
|
|
12464
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler61.types.identifier(getTemplateContentName()) : (0,
|
|
12574
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler61.types.identifier(getTemplateContentName()) : (0, import_babel_utils50.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
|
12465
12575
|
} else {
|
|
12466
12576
|
tagIdentifier = node.name;
|
|
12467
12577
|
}
|
|
@@ -12477,8 +12587,8 @@ function translateDOM(tag) {
|
|
|
12477
12587
|
const { file } = tag.hub;
|
|
12478
12588
|
const write = writeTo(tag);
|
|
12479
12589
|
const relativePath = getTagRelativePath(tag);
|
|
12480
|
-
const programSection = (0,
|
|
12481
|
-
const childFile = (0,
|
|
12590
|
+
const programSection = (0, import_babel_utils50.getProgram)().node.extra.section;
|
|
12591
|
+
const childFile = (0, import_babel_utils50.loadFileForTag)(tag);
|
|
12482
12592
|
const childExtra = childFile.ast.program.extra;
|
|
12483
12593
|
const childExports = childExtra.domExports;
|
|
12484
12594
|
const childSection = childExtra.section;
|
|
@@ -12487,7 +12597,7 @@ function translateDOM(tag) {
|
|
|
12487
12597
|
knownTagTranslateDOM(
|
|
12488
12598
|
tag,
|
|
12489
12599
|
childExports.params,
|
|
12490
|
-
(binding,
|
|
12600
|
+
(binding, preferredName) => getSignal(programSection, binding, preferredName).identifier,
|
|
12491
12601
|
(section, childBinding) => {
|
|
12492
12602
|
addStatement(
|
|
12493
12603
|
"render",
|
|
@@ -12507,11 +12617,11 @@ function translateDOM(tag) {
|
|
|
12507
12617
|
knownTagTranslateDOM(
|
|
12508
12618
|
tag,
|
|
12509
12619
|
childExports.params,
|
|
12510
|
-
(binding,
|
|
12620
|
+
(binding, preferredName) => importOrSelfReferenceName(
|
|
12511
12621
|
tag.hub.file,
|
|
12512
12622
|
relativePath,
|
|
12513
12623
|
binding.export,
|
|
12514
|
-
|
|
12624
|
+
preferredName
|
|
12515
12625
|
),
|
|
12516
12626
|
(section, childBinding) => {
|
|
12517
12627
|
addStatement(
|
|
@@ -12532,11 +12642,11 @@ function translateDOM(tag) {
|
|
|
12532
12642
|
);
|
|
12533
12643
|
}
|
|
12534
12644
|
);
|
|
12535
|
-
write`${(0,
|
|
12645
|
+
write`${(0, import_babel_utils50.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
|
12536
12646
|
injectWalks(
|
|
12537
12647
|
tag,
|
|
12538
12648
|
tagName,
|
|
12539
|
-
(0,
|
|
12649
|
+
(0, import_babel_utils50.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
|
12540
12650
|
);
|
|
12541
12651
|
}
|
|
12542
12652
|
tag.remove();
|
|
@@ -12548,8 +12658,8 @@ function getTagRelativePath(tag) {
|
|
|
12548
12658
|
} = tag;
|
|
12549
12659
|
let relativePath;
|
|
12550
12660
|
if (import_compiler61.types.isStringLiteral(node.name)) {
|
|
12551
|
-
const template = node.extra?.featureType === "class" && (0,
|
|
12552
|
-
relativePath = template && (0,
|
|
12661
|
+
const template = node.extra?.featureType === "class" && (0, import_babel_utils50.getTagDef)(tag)?.renderer || (0, import_babel_utils50.getTagTemplate)(tag);
|
|
12662
|
+
relativePath = template && (0, import_babel_utils50.resolveRelativePath)(file, template);
|
|
12553
12663
|
} else if (node.extra?.tagNameImported) {
|
|
12554
12664
|
relativePath = node.extra.tagNameImported;
|
|
12555
12665
|
}
|
|
@@ -12581,7 +12691,7 @@ function importOrSelfReferenceName(file, request, name2, nameHint) {
|
|
|
12581
12691
|
if (isCircularRequest(file, request)) {
|
|
12582
12692
|
return import_compiler61.types.identifier(name2);
|
|
12583
12693
|
}
|
|
12584
|
-
return (0,
|
|
12694
|
+
return (0, import_babel_utils50.importNamed)(file, request, name2, nameHint);
|
|
12585
12695
|
}
|
|
12586
12696
|
function isCircularRequest(file, request) {
|
|
12587
12697
|
const { filename } = file.opts;
|
|
@@ -12590,14 +12700,14 @@ function isCircularRequest(file, request) {
|
|
|
12590
12700
|
|
|
12591
12701
|
// src/translator/visitors/tag/dynamic-tag.ts
|
|
12592
12702
|
var import_compiler62 = require("@marko/compiler");
|
|
12593
|
-
var
|
|
12703
|
+
var import_babel_utils51 = require("@marko/compiler/babel-utils");
|
|
12594
12704
|
var kDOMBinding3 = /* @__PURE__ */ Symbol("dynamic tag dom binding");
|
|
12595
12705
|
var kChildOffsetScopeBinding2 = /* @__PURE__ */ Symbol("custom tag scope offset");
|
|
12596
12706
|
var importedDynamicTagResume = /* @__PURE__ */ new WeakSet();
|
|
12597
12707
|
var dynamic_tag_default = {
|
|
12598
12708
|
analyze: {
|
|
12599
12709
|
enter(tag) {
|
|
12600
|
-
(0,
|
|
12710
|
+
(0, import_babel_utils51.assertAttributesOrArgs)(tag);
|
|
12601
12711
|
const { node } = tag;
|
|
12602
12712
|
const definedBodySection = node.extra?.defineBodySection;
|
|
12603
12713
|
if (definedBodySection) {
|
|
@@ -12624,7 +12734,7 @@ var dynamic_tag_default = {
|
|
|
12624
12734
|
if (hasVar || tag.node.attributes.some(
|
|
12625
12735
|
(attr) => import_compiler62.types.isMarkoSpreadAttribute(attr) || isEventOrChangeHandler(attr.name)
|
|
12626
12736
|
)) {
|
|
12627
|
-
(0,
|
|
12737
|
+
(0, import_babel_utils51.getProgram)().node.extra.isInteractive = true;
|
|
12628
12738
|
}
|
|
12629
12739
|
if (hasVar) {
|
|
12630
12740
|
trackVarReferences(tag, 5 /* derived */);
|
|
@@ -12723,7 +12833,7 @@ var dynamic_tag_default = {
|
|
|
12723
12833
|
const isClassAPI = tagExtra.featureType === "class";
|
|
12724
12834
|
let tagExpression = node.name;
|
|
12725
12835
|
if (import_compiler62.types.isStringLiteral(tagExpression)) {
|
|
12726
|
-
tagExpression = (0,
|
|
12836
|
+
tagExpression = (0, import_babel_utils51.importDefault)(
|
|
12727
12837
|
tag.hub.file,
|
|
12728
12838
|
getTagRelativePath(tag),
|
|
12729
12839
|
tagExpression.value
|
|
@@ -12731,15 +12841,15 @@ var dynamic_tag_default = {
|
|
|
12731
12841
|
}
|
|
12732
12842
|
if (isClassAPI) {
|
|
12733
12843
|
if (isOutputHTML()) {
|
|
12734
|
-
(0,
|
|
12844
|
+
(0, import_babel_utils51.getProgram)().node.body.push(
|
|
12735
12845
|
import_compiler62.types.markoScriptlet(
|
|
12736
12846
|
[
|
|
12737
12847
|
import_compiler62.types.expressionStatement(
|
|
12738
12848
|
import_compiler62.types.callExpression(
|
|
12739
|
-
(0,
|
|
12849
|
+
(0, import_babel_utils51.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
|
12740
12850
|
[
|
|
12741
12851
|
import_compiler62.types.identifier(tagExpression.name),
|
|
12742
|
-
import_compiler62.types.stringLiteral((0,
|
|
12852
|
+
import_compiler62.types.stringLiteral((0, import_babel_utils51.loadFileForTag)(tag).metadata.marko.id)
|
|
12743
12853
|
]
|
|
12744
12854
|
)
|
|
12745
12855
|
)
|
|
@@ -12748,11 +12858,11 @@ var dynamic_tag_default = {
|
|
|
12748
12858
|
)
|
|
12749
12859
|
);
|
|
12750
12860
|
} else {
|
|
12751
|
-
(0,
|
|
12861
|
+
(0, import_babel_utils51.getProgram)().node.body.push(
|
|
12752
12862
|
import_compiler62.types.expressionStatement(
|
|
12753
12863
|
callRuntime(
|
|
12754
12864
|
"_resume",
|
|
12755
|
-
import_compiler62.types.stringLiteral((0,
|
|
12865
|
+
import_compiler62.types.stringLiteral((0, import_babel_utils51.loadFileForTag)(tag).metadata.marko.id),
|
|
12756
12866
|
import_compiler62.types.identifier(tagExpression.name)
|
|
12757
12867
|
)
|
|
12758
12868
|
)
|
|
@@ -12910,7 +13020,7 @@ var dynamic_tag_default = {
|
|
|
12910
13020
|
}
|
|
12911
13021
|
};
|
|
12912
13022
|
function enableDynamicTagResume(tag) {
|
|
12913
|
-
const program = (0,
|
|
13023
|
+
const program = (0, import_babel_utils51.getProgram)().node;
|
|
12914
13024
|
if (!importedDynamicTagResume.has(program) && analyzeTagNameType(tag, true) !== 1 /* CustomTag */) {
|
|
12915
13025
|
for (const attr of tag.node.attributes) {
|
|
12916
13026
|
if (attr.type === "MarkoSpreadAttribute" || attr.type === "MarkoAttribute" && isEventOrChangeHandler(attr.name)) {
|
|
@@ -12928,7 +13038,7 @@ function enableDynamicTagResume(tag) {
|
|
|
12928
13038
|
var tag_default = {
|
|
12929
13039
|
analyze: {
|
|
12930
13040
|
enter(tag) {
|
|
12931
|
-
const tagDef = (0,
|
|
13041
|
+
const tagDef = (0, import_babel_utils52.getTagDef)(tag);
|
|
12932
13042
|
const type = analyzeTagNameType(tag);
|
|
12933
13043
|
const hook = tagDef?.analyzer?.hook;
|
|
12934
13044
|
if (hook) {
|
|
@@ -12952,7 +13062,7 @@ var tag_default = {
|
|
|
12952
13062
|
}
|
|
12953
13063
|
},
|
|
12954
13064
|
exit(tag) {
|
|
12955
|
-
const hook = (0,
|
|
13065
|
+
const hook = (0, import_babel_utils52.getTagDef)(tag)?.analyzer?.hook;
|
|
12956
13066
|
if (hook) {
|
|
12957
13067
|
exit(hook, tag);
|
|
12958
13068
|
return;
|
|
@@ -12961,7 +13071,7 @@ var tag_default = {
|
|
|
12961
13071
|
},
|
|
12962
13072
|
translate: {
|
|
12963
13073
|
enter(tag) {
|
|
12964
|
-
const tagDef = (0,
|
|
13074
|
+
const tagDef = (0, import_babel_utils52.getTagDef)(tag);
|
|
12965
13075
|
if (tagDef?.translator) {
|
|
12966
13076
|
if (tagDef.translator.path) {
|
|
12967
13077
|
tag.hub.file.metadata.marko.watchFiles.push(tagDef.translator.path);
|
|
@@ -12976,15 +13086,6 @@ var tag_default = {
|
|
|
12976
13086
|
`Unsupported arguments on the \`${attr.node.name}\` attribute.`
|
|
12977
13087
|
);
|
|
12978
13088
|
}
|
|
12979
|
-
if (attr.node.modifier) {
|
|
12980
|
-
if ((0, import_babel_utils51.isNativeTag)(attr.parentPath)) {
|
|
12981
|
-
attr.node.name += `:${attr.node.modifier}`;
|
|
12982
|
-
} else {
|
|
12983
|
-
throw attr.buildCodeFrameError(
|
|
12984
|
-
`Unsupported modifier \`${attr.node.modifier}\`.`
|
|
12985
|
-
);
|
|
12986
|
-
}
|
|
12987
|
-
}
|
|
12988
13089
|
}
|
|
12989
13090
|
}
|
|
12990
13091
|
switch (analyzeTagNameType(tag)) {
|
|
@@ -13003,7 +13104,7 @@ var tag_default = {
|
|
|
13003
13104
|
}
|
|
13004
13105
|
},
|
|
13005
13106
|
exit(tag) {
|
|
13006
|
-
const translator = (0,
|
|
13107
|
+
const translator = (0, import_babel_utils52.getTagDef)(tag)?.translator;
|
|
13007
13108
|
if (translator) {
|
|
13008
13109
|
exit(translator.hook, tag);
|
|
13009
13110
|
return;
|
|
@@ -13041,12 +13142,12 @@ var text_default = {
|
|
|
13041
13142
|
|
|
13042
13143
|
// src/translator/interop/index.ts
|
|
13043
13144
|
var import_compiler65 = require("@marko/compiler");
|
|
13044
|
-
var
|
|
13145
|
+
var import_babel_utils54 = require("@marko/compiler/babel-utils");
|
|
13045
13146
|
var import_babel2 = require("@marko/compiler/internal/babel");
|
|
13046
13147
|
var import_path6 = __toESM(require("path"));
|
|
13047
13148
|
|
|
13048
13149
|
// src/translator/interop/feature-detection.ts
|
|
13049
|
-
var
|
|
13150
|
+
var import_babel_utils53 = require("@marko/compiler/babel-utils");
|
|
13050
13151
|
|
|
13051
13152
|
// src/translator/interop/build-aggregate-error.ts
|
|
13052
13153
|
var import_babel = require("@marko/compiler/internal/babel");
|
|
@@ -13103,12 +13204,12 @@ function getFileNameWithLoc(fileName, { node: { loc } }) {
|
|
|
13103
13204
|
}
|
|
13104
13205
|
|
|
13105
13206
|
// src/translator/interop/feature-detection.ts
|
|
13106
|
-
function isTagsAPI(file = (0,
|
|
13207
|
+
function isTagsAPI(file = (0, import_babel_utils53.getFile)()) {
|
|
13107
13208
|
const program = file.path;
|
|
13108
13209
|
const programExtra = program.node.extra ??= {};
|
|
13109
13210
|
let { featureType } = programExtra;
|
|
13110
13211
|
if (!featureType) {
|
|
13111
|
-
const lookup = (0,
|
|
13212
|
+
const lookup = (0, import_babel_utils53.getTaglibLookup)(file);
|
|
13112
13213
|
const tagsDir = getTagsDir(file.opts.filename);
|
|
13113
13214
|
const state = {};
|
|
13114
13215
|
if (tagsDir && !lookup.manualTagsDirs?.has(tagsDir)) {
|
|
@@ -13189,7 +13290,7 @@ function scanTag(state, tag) {
|
|
|
13189
13290
|
tag.get("var")
|
|
13190
13291
|
);
|
|
13191
13292
|
}
|
|
13192
|
-
const tagDef = (0,
|
|
13293
|
+
const tagDef = (0, import_babel_utils53.getTagDef)(tag);
|
|
13193
13294
|
if (tagDef) {
|
|
13194
13295
|
if (tagDef.name === "style") {
|
|
13195
13296
|
if (/^style(?:(?:\.[^.\s\\/:*?"<>|({]+)+)?\s*\{/.test(
|
|
@@ -13215,9 +13316,6 @@ function scanTag(state, tag) {
|
|
|
13215
13316
|
attr.get("arguments")[0]
|
|
13216
13317
|
);
|
|
13217
13318
|
break;
|
|
13218
|
-
} else if (attr.node.modifier) {
|
|
13219
|
-
addFeature(state, "class" /* Class */, "Attribute modifier", attr);
|
|
13220
|
-
break;
|
|
13221
13319
|
} else if (attr.node.bound) {
|
|
13222
13320
|
addFeature(state, "tags" /* Tags */, "Bound attribute", attr);
|
|
13223
13321
|
break;
|
|
@@ -13289,10 +13387,10 @@ function createInteropTranslator(translate5) {
|
|
|
13289
13387
|
import_compiler65.taglib.resolveOptionalTaglibs(translate5.optionalTaglibs).concat(translate5.taglibs),
|
|
13290
13388
|
taglibs
|
|
13291
13389
|
),
|
|
13292
|
-
getRuntimeEntryFiles(output,
|
|
13390
|
+
getRuntimeEntryFiles(output, optimize2) {
|
|
13293
13391
|
return [
|
|
13294
|
-
...translate5.getRuntimeEntryFiles(output,
|
|
13295
|
-
...getRuntimeEntryFiles(output,
|
|
13392
|
+
...translate5.getRuntimeEntryFiles(output, optimize2),
|
|
13393
|
+
...getRuntimeEntryFiles(output, optimize2)
|
|
13296
13394
|
];
|
|
13297
13395
|
}
|
|
13298
13396
|
};
|
|
@@ -13374,7 +13472,7 @@ function createInteropTranslator(translate5) {
|
|
|
13374
13472
|
return enterProgram?.call(this, program, state);
|
|
13375
13473
|
}
|
|
13376
13474
|
const visitedFiles = /* @__PURE__ */ new Set([
|
|
13377
|
-
(0,
|
|
13475
|
+
(0, import_babel_utils54.resolveRelativePath)(entryFile, entryFile.opts.filename)
|
|
13378
13476
|
]);
|
|
13379
13477
|
entryBuilder.visit(
|
|
13380
13478
|
entryFile,
|
|
@@ -13382,7 +13480,7 @@ function createInteropTranslator(translate5) {
|
|
|
13382
13480
|
function visitChild(resolved) {
|
|
13383
13481
|
if (!visitedFiles.has(resolved)) {
|
|
13384
13482
|
visitedFiles.add(resolved);
|
|
13385
|
-
const file = (0,
|
|
13483
|
+
const file = (0, import_babel_utils54.loadFileForImport)(entryFile, resolved);
|
|
13386
13484
|
if (file) {
|
|
13387
13485
|
entryBuilder.visit(
|
|
13388
13486
|
file,
|
|
@@ -13539,7 +13637,7 @@ function getVisitorExit(visit2) {
|
|
|
13539
13637
|
return typeof visit2 === "object" ? visit2?.exit : void 0;
|
|
13540
13638
|
}
|
|
13541
13639
|
function resolveRelativeToEntry2(entryFile, file, req) {
|
|
13542
|
-
return file === entryFile ? (0,
|
|
13640
|
+
return file === entryFile ? (0, import_babel_utils54.resolveRelativePath)(file, req) : (0, import_babel_utils54.resolveRelativePath)(
|
|
13543
13641
|
entryFile,
|
|
13544
13642
|
req[0] === "." ? import_path6.default.join(file.opts.filename, "..", req) : req
|
|
13545
13643
|
);
|
|
@@ -13572,9 +13670,9 @@ var taglibs = [
|
|
|
13572
13670
|
}
|
|
13573
13671
|
]
|
|
13574
13672
|
];
|
|
13575
|
-
function getRuntimeEntryFiles(output,
|
|
13673
|
+
function getRuntimeEntryFiles(output, optimize2) {
|
|
13576
13674
|
return [
|
|
13577
|
-
`${runtime_info_default.name}${
|
|
13675
|
+
`${runtime_info_default.name}${optimize2 ? "" : "/debug"}/${output === "html" ? "html" : "dom"}`
|
|
13578
13676
|
];
|
|
13579
13677
|
}
|
|
13580
13678
|
// Annotate the CommonJS export names for ESM import in node:
|