marko 6.0.60 → 6.0.61
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 +278 -296
- package/dist/debug/dom.mjs +278 -296
- package/dist/debug/html.js +219 -219
- package/dist/debug/html.mjs +169 -169
- package/dist/dom/abort-signal.d.ts +2 -2
- package/dist/dom/control-flow.d.ts +8 -8
- package/dist/dom/controllable.d.ts +11 -11
- package/dist/dom/dom.d.ts +17 -18
- package/dist/dom/event.d.ts +1 -1
- package/dist/dom/queue.d.ts +1 -1
- package/dist/dom/renderer.d.ts +4 -4
- package/dist/dom/resume.d.ts +3 -3
- package/dist/dom/signals.d.ts +14 -14
- package/dist/dom/template.d.ts +1 -1
- package/dist/dom.d.ts +10 -10
- package/dist/dom.js +254 -265
- package/dist/dom.mjs +254 -265
- package/dist/html/attrs.d.ts +14 -14
- package/dist/html/compat.d.ts +5 -5
- package/dist/html/content.d.ts +4 -4
- package/dist/html/dynamic-tag.d.ts +3 -3
- package/dist/html/template.d.ts +1 -1
- package/dist/html/writer.d.ts +26 -26
- package/dist/html.d.ts +5 -5
- package/dist/html.js +210 -210
- package/dist/html.mjs +160 -160
- package/dist/translator/index.js +500 -482
- package/dist/translator/util/runtime.d.ts +8 -8
- package/dist/translator/util/signals.d.ts +1 -1
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -54,10 +54,10 @@ var import_babel_utils = require("@marko/compiler/babel-utils");
|
|
54
54
|
|
55
55
|
// src/translator/util/assert.ts
|
56
56
|
function assertNoSpreadAttrs(tag) {
|
57
|
-
for (const
|
58
|
-
if (
|
57
|
+
for (const attr of tag.get("attributes")) {
|
58
|
+
if (attr.isMarkoSpreadAttribute()) {
|
59
59
|
const tagName = tag.get("name").node.value;
|
60
|
-
throw
|
60
|
+
throw attr.buildCodeFrameError(
|
61
61
|
`The [\`<${tagName}>\`](https://next.markojs.com/docs/reference/core-tag#${tagName}) tag does not support \`...spread\` attributes.`
|
62
62
|
);
|
63
63
|
}
|
@@ -2181,13 +2181,13 @@ var entry_builder_default = {
|
|
2181
2181
|
|
2182
2182
|
// src/translator/util/get-known-attr-values.ts
|
2183
2183
|
function getKnownAttrValues(tag) {
|
2184
|
-
const
|
2185
|
-
for (const
|
2186
|
-
if (
|
2187
|
-
|
2184
|
+
const attrs = {};
|
2185
|
+
for (const attr of tag.attributes) {
|
2186
|
+
if (attr.type === "MarkoAttribute") {
|
2187
|
+
attrs[attr.name] = attr.value;
|
2188
2188
|
}
|
2189
2189
|
}
|
2190
|
-
return
|
2190
|
+
return attrs;
|
2191
2191
|
}
|
2192
2192
|
|
2193
2193
|
// src/translator/util/runtime.ts
|
@@ -2248,23 +2248,23 @@ function isVoid(value) {
|
|
2248
2248
|
}
|
2249
2249
|
|
2250
2250
|
// src/html/content.ts
|
2251
|
-
function
|
2251
|
+
function _unescaped(val) {
|
2252
2252
|
return val ? val + "" : val === 0 ? "0" : "";
|
2253
2253
|
}
|
2254
2254
|
var unsafeXMLReg = /[<&]/g;
|
2255
2255
|
var replaceUnsafeXML = (c) => c === "&" ? "&" : "<";
|
2256
2256
|
var escapeXMLStr = (str) => unsafeXMLReg.test(str) ? str.replace(unsafeXMLReg, replaceUnsafeXML) : str;
|
2257
|
-
function
|
2257
|
+
function _escape(val) {
|
2258
2258
|
return val ? escapeXMLStr(val + "") : val === 0 ? "0" : "‍";
|
2259
2259
|
}
|
2260
2260
|
var unsafeScriptReg = /<\/script/g;
|
2261
2261
|
var escapeScriptStr = (str) => unsafeScriptReg.test(str) ? str.replace(unsafeScriptReg, "\\x3C/script") : str;
|
2262
|
-
function
|
2262
|
+
function _escape_script(val) {
|
2263
2263
|
return val ? escapeScriptStr(val + "") : val === 0 ? "0" : "";
|
2264
2264
|
}
|
2265
2265
|
var unsafeStyleReg = /<\/style/g;
|
2266
2266
|
var escapeStyleStr = (str) => unsafeStyleReg.test(str) ? str.replace(unsafeStyleReg, "\\3C/style") : str;
|
2267
|
-
function
|
2267
|
+
function _escape_style(val) {
|
2268
2268
|
return val ? escapeStyleStr(val + "") : val === 0 ? "0" : "";
|
2269
2269
|
}
|
2270
2270
|
|
@@ -2284,14 +2284,14 @@ if (false) {
|
|
2284
2284
|
var tick = globalThis.setImmediate || globalThis.setTimeout || globalThis.queueMicrotask || ((cb) => Promise.resolve().then(cb));
|
2285
2285
|
|
2286
2286
|
// src/html/attrs.ts
|
2287
|
-
function
|
2287
|
+
function _attr_class(value) {
|
2288
2288
|
return stringAttr("class", classValue(value));
|
2289
2289
|
}
|
2290
|
-
function
|
2290
|
+
function _attr_style(value) {
|
2291
2291
|
return stringAttr("style", styleValue(value));
|
2292
2292
|
}
|
2293
2293
|
var kSelectedValue = Symbol("selectedValue");
|
2294
|
-
function
|
2294
|
+
function _attr(name2, value) {
|
2295
2295
|
return isVoid(value) ? "" : nonVoidAttr(name2, value);
|
2296
2296
|
}
|
2297
2297
|
function stringAttr(name2, value) {
|
@@ -2371,28 +2371,28 @@ function toMemberExpression(object, key, optional) {
|
|
2371
2371
|
|
2372
2372
|
// src/translator/util/runtime.ts
|
2373
2373
|
var pureDOMFunctions = /* @__PURE__ */ new Set([
|
2374
|
-
"
|
2375
|
-
"
|
2376
|
-
"
|
2377
|
-
"
|
2378
|
-
"
|
2379
|
-
"
|
2380
|
-
"
|
2381
|
-
"
|
2382
|
-
"
|
2383
|
-
"
|
2384
|
-
"
|
2385
|
-
"
|
2386
|
-
"
|
2387
|
-
"
|
2388
|
-
"
|
2389
|
-
"
|
2390
|
-
"
|
2374
|
+
"_await",
|
2375
|
+
"_if",
|
2376
|
+
"_if_closure",
|
2377
|
+
"_try",
|
2378
|
+
"_dynamic_tag",
|
2379
|
+
"_content_branch",
|
2380
|
+
"_content",
|
2381
|
+
"_template",
|
2382
|
+
"_closure",
|
2383
|
+
"_closure_get",
|
2384
|
+
"_or",
|
2385
|
+
"_for_closure",
|
2386
|
+
"_for_in",
|
2387
|
+
"_for_of",
|
2388
|
+
"_for_to",
|
2389
|
+
"_let",
|
2390
|
+
"_const"
|
2391
2391
|
]);
|
2392
2392
|
function importRuntime(name2) {
|
2393
2393
|
const { output } = getMarkoOpts();
|
2394
2394
|
return toMemberExpression(
|
2395
|
-
(0, import_babel_utils13.importStar)((0, import_babel_utils13.getFile)(), getRuntimePath(output), "
|
2395
|
+
(0, import_babel_utils13.importStar)((0, import_babel_utils13.getFile)(), getRuntimePath(output), "_"),
|
2396
2396
|
name2
|
2397
2397
|
);
|
2398
2398
|
}
|
@@ -2413,13 +2413,13 @@ function callRuntime(name2, ...args) {
|
|
2413
2413
|
}
|
2414
2414
|
function getHTMLRuntime() {
|
2415
2415
|
return {
|
2416
|
-
|
2417
|
-
|
2418
|
-
|
2419
|
-
|
2420
|
-
|
2421
|
-
|
2422
|
-
|
2416
|
+
_escape,
|
2417
|
+
_unescaped,
|
2418
|
+
_attr,
|
2419
|
+
_attr_class,
|
2420
|
+
_attr_style,
|
2421
|
+
_escape_script,
|
2422
|
+
_escape_style
|
2423
2423
|
};
|
2424
2424
|
}
|
2425
2425
|
function getRuntimePath(output) {
|
@@ -2629,7 +2629,7 @@ function getExprIfSerialized(reason, expr) {
|
|
2629
2629
|
return reason ? reason === true || reason.state ? expr : import_compiler14.types.logicalExpression(
|
2630
2630
|
"&&",
|
2631
2631
|
callRuntime(
|
2632
|
-
"
|
2632
|
+
"_serialize_if",
|
2633
2633
|
import_compiler14.types.identifier(getSharedUid("serialize")),
|
2634
2634
|
withLeadingComment(
|
2635
2635
|
import_compiler14.types.numericLiteral(
|
@@ -2646,7 +2646,7 @@ function getExprIfSerialized(reason, expr) {
|
|
2646
2646
|
}
|
2647
2647
|
function getInputSerializeReasonGuard(reason) {
|
2648
2648
|
return callRuntime(
|
2649
|
-
"
|
2649
|
+
"_serialize_guard",
|
2650
2650
|
import_compiler14.types.identifier(getSharedUid("serialize")),
|
2651
2651
|
withLeadingComment(
|
2652
2652
|
import_compiler14.types.numericLiteral(
|
@@ -2686,7 +2686,7 @@ var html_default = {
|
|
2686
2686
|
);
|
2687
2687
|
const exportDefault = import_compiler14.types.exportDefaultDeclaration(
|
2688
2688
|
callRuntime(
|
2689
|
-
"
|
2689
|
+
"_template",
|
2690
2690
|
import_compiler14.types.stringLiteral(program.hub.file.metadata.marko.id),
|
2691
2691
|
contentId ? import_compiler14.types.identifier(contentId) : contentFn
|
2692
2692
|
)
|
@@ -2768,11 +2768,7 @@ function addRegisteredDeclarations(body) {
|
|
2768
2768
|
for (const { id, registerId } of registeredFnDeclarations) {
|
2769
2769
|
body.push(
|
2770
2770
|
import_compiler14.types.expressionStatement(
|
2771
|
-
callRuntime(
|
2772
|
-
"register",
|
2773
|
-
import_compiler14.types.identifier(id),
|
2774
|
-
import_compiler14.types.stringLiteral(registerId)
|
2775
|
-
)
|
2771
|
+
callRuntime("_resume", import_compiler14.types.identifier(id), import_compiler14.types.stringLiteral(registerId))
|
2776
2772
|
)
|
2777
2773
|
);
|
2778
2774
|
}
|
@@ -2782,7 +2778,7 @@ function getRegisteredFnExpression(node) {
|
|
2782
2778
|
const { extra } = node;
|
2783
2779
|
if (isRegisteredFnExtra(extra)) {
|
2784
2780
|
return callRuntime(
|
2785
|
-
"
|
2781
|
+
"_resume",
|
2786
2782
|
simplifyFunction(node),
|
2787
2783
|
import_compiler14.types.stringLiteral(extra.registerId),
|
2788
2784
|
(extra.referencedBindingsInFunction || extra.referencesScope) && getScopeIdIdentifier(extra.section)
|
@@ -3034,14 +3030,14 @@ function consumeHTML(path5) {
|
|
3034
3030
|
if (writeResult && trailerResult) {
|
3035
3031
|
return import_compiler17.types.expressionStatement(
|
3036
3032
|
import_compiler17.types.sequenceExpression([
|
3037
|
-
callRuntime("
|
3038
|
-
callRuntime("
|
3033
|
+
callRuntime("_html", writeResult),
|
3034
|
+
callRuntime("_trailers", trailerResult)
|
3039
3035
|
])
|
3040
3036
|
);
|
3041
3037
|
} else if (writeResult) {
|
3042
|
-
return import_compiler17.types.expressionStatement(callRuntime("
|
3038
|
+
return import_compiler17.types.expressionStatement(callRuntime("_html", writeResult));
|
3043
3039
|
} else if (trailerResult) {
|
3044
|
-
return import_compiler17.types.expressionStatement(callRuntime("
|
3040
|
+
return import_compiler17.types.expressionStatement(callRuntime("_trailers", trailerResult));
|
3045
3041
|
}
|
3046
3042
|
}
|
3047
3043
|
function flushBefore(path5) {
|
@@ -3077,7 +3073,7 @@ function markNode(path5, nodeBinding, reason) {
|
|
3077
3073
|
if (reason) {
|
3078
3074
|
const section = getSection(path5);
|
3079
3075
|
writeTo(path5)`${callRuntime(
|
3080
|
-
"
|
3076
|
+
"_el_resume",
|
3081
3077
|
getScopeIdIdentifier(section),
|
3082
3078
|
getScopeAccessorLiteral(nodeBinding),
|
3083
3079
|
getSerializeGuard(reason, true)
|
@@ -3115,14 +3111,14 @@ var return_default = {
|
|
3115
3111
|
} else {
|
3116
3112
|
tagsWithReturn.add(tag.parentPath);
|
3117
3113
|
}
|
3118
|
-
const
|
3119
|
-
if (!
|
3114
|
+
const attrs = getKnownAttrValues(tag.node);
|
3115
|
+
if (!attrs.value) {
|
3120
3116
|
throw tag.get("name").buildCodeFrameError(
|
3121
3117
|
"The [`<return>` tag](https://next.markojs.com/docs/reference/core-tag#return) requires a [`value=` attribute](https://next.markojs.com/docs/reference/language#shorthand-value)."
|
3122
3118
|
);
|
3123
3119
|
}
|
3124
|
-
if (
|
3125
|
-
(
|
3120
|
+
if (attrs.valueChange) {
|
3121
|
+
(attrs.valueChange.extra ??= {}).isEffect = true;
|
3126
3122
|
forceSectionSerialize(
|
3127
3123
|
getOrCreateSection(tag),
|
3128
3124
|
getAccessorProp().TagVariableChange
|
@@ -3133,21 +3129,21 @@ var return_default = {
|
|
3133
3129
|
html: {
|
3134
3130
|
exit(tag) {
|
3135
3131
|
const section = getSection(tag);
|
3136
|
-
const
|
3132
|
+
const attrs = getKnownAttrValues(tag.node);
|
3137
3133
|
flushBefore(tag);
|
3138
|
-
if (
|
3134
|
+
if (attrs.valueChange) {
|
3139
3135
|
setSectionSerializedValue(
|
3140
3136
|
section,
|
3141
3137
|
getAccessorProp().TagVariableChange,
|
3142
|
-
|
3138
|
+
attrs.valueChange
|
3143
3139
|
);
|
3144
3140
|
}
|
3145
|
-
if (
|
3141
|
+
if (attrs.value) {
|
3146
3142
|
const returnId = generateUidIdentifier("return");
|
3147
3143
|
setReturnValueIdentifier(section, returnId);
|
3148
3144
|
tag.replaceWith(
|
3149
3145
|
import_compiler18.types.variableDeclaration("const", [
|
3150
|
-
import_compiler18.types.variableDeclarator(returnId,
|
3146
|
+
import_compiler18.types.variableDeclarator(returnId, attrs.value)
|
3151
3147
|
])
|
3152
3148
|
)[0].skip();
|
3153
3149
|
}
|
@@ -3156,28 +3152,24 @@ var return_default = {
|
|
3156
3152
|
dom: {
|
3157
3153
|
exit(tag) {
|
3158
3154
|
const section = getSection(tag);
|
3159
|
-
const
|
3160
|
-
if (
|
3155
|
+
const attrs = getKnownAttrValues(tag.node);
|
3156
|
+
if (attrs.value) {
|
3161
3157
|
addStatement(
|
3162
3158
|
"render",
|
3163
3159
|
section,
|
3164
|
-
|
3160
|
+
attrs.value.extra?.referencedBindings,
|
3165
3161
|
import_compiler18.types.expressionStatement(
|
3166
|
-
callRuntime("
|
3162
|
+
callRuntime("_return", scopeIdentifier, attrs.value)
|
3167
3163
|
)
|
3168
3164
|
);
|
3169
3165
|
}
|
3170
|
-
if (
|
3166
|
+
if (attrs.valueChange) {
|
3171
3167
|
addStatement(
|
3172
3168
|
"render",
|
3173
3169
|
section,
|
3174
|
-
|
3170
|
+
attrs.valueChange.extra?.referencedBindings,
|
3175
3171
|
import_compiler18.types.expressionStatement(
|
3176
|
-
callRuntime(
|
3177
|
-
"setTagVarChange",
|
3178
|
-
scopeIdentifier,
|
3179
|
-
attrs2.valueChange
|
3180
|
-
)
|
3172
|
+
callRuntime("_return_change", scopeIdentifier, attrs.valueChange)
|
3181
3173
|
)
|
3182
3174
|
);
|
3183
3175
|
}
|
@@ -3305,7 +3297,9 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
3305
3297
|
signals.set(
|
3306
3298
|
referencedBindings,
|
3307
3299
|
signal = {
|
3308
|
-
identifier: exportName ? import_compiler21.types.identifier(exportName) : generateUidIdentifier(
|
3300
|
+
identifier: exportName ? import_compiler21.types.identifier(exportName) : generateUidIdentifier(
|
3301
|
+
section.name ? `${section.name}__${name2}` : name2
|
3302
|
+
),
|
3309
3303
|
referencedBindings,
|
3310
3304
|
section,
|
3311
3305
|
values: [],
|
@@ -3328,7 +3322,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
3328
3322
|
signal.build = () => {
|
3329
3323
|
const { id, scopeOffset } = intersectionMeta.get(referencedBindings);
|
3330
3324
|
return callRuntime(
|
3331
|
-
"
|
3325
|
+
"_or",
|
3332
3326
|
import_compiler21.types.numericLiteral(id),
|
3333
3327
|
getSignalFn(signal),
|
3334
3328
|
scopeOffset || referencedBindings.length > 2 ? import_compiler21.types.numericLiteral(referencedBindings.length - 1) : void 0,
|
@@ -3341,7 +3335,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
3341
3335
|
const render = getSignalFn(signal);
|
3342
3336
|
const closureSignalBuilder = getClosureSignalBuilder(section);
|
3343
3337
|
return !closureSignalBuilder || isDynamicClosure(section, canonicalClosure) ? callRuntime(
|
3344
|
-
"
|
3338
|
+
"_closure_get",
|
3345
3339
|
getScopeAccessorLiteral(canonicalClosure),
|
3346
3340
|
render,
|
3347
3341
|
isImmediateOwner(section, canonicalClosure) ? void 0 : import_compiler21.types.arrowFunctionExpression(
|
@@ -3354,7 +3348,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
3354
3348
|
}
|
3355
3349
|
return signal;
|
3356
3350
|
}
|
3357
|
-
function initValue(binding,
|
3351
|
+
function initValue(binding, isLet = false) {
|
3358
3352
|
const section = binding.section;
|
3359
3353
|
const signal = getSignal(section, binding);
|
3360
3354
|
signal.build = () => {
|
@@ -3366,8 +3360,8 @@ function initValue(binding, runtimeHelper = "value") {
|
|
3366
3360
|
const needsMarks = isParamBinding || signal.intersection;
|
3367
3361
|
if (needsCache || needsMarks || binding.hoists.size) {
|
3368
3362
|
return callRuntime(
|
3369
|
-
|
3370
|
-
getScopeAccessorLiteral(binding,
|
3363
|
+
isLet ? "_let" : "_const",
|
3364
|
+
getScopeAccessorLiteral(binding, isLet),
|
3371
3365
|
fn
|
3372
3366
|
);
|
3373
3367
|
} else {
|
@@ -3496,7 +3490,7 @@ function getSignalFn(signal) {
|
|
3496
3490
|
if (!dynamicClosureArgs) {
|
3497
3491
|
dynamicClosureArgs = [];
|
3498
3492
|
dynamicClosureSignalIdentifier = generateUidIdentifier(
|
3499
|
-
signal.identifier.name + "
|
3493
|
+
signal.identifier.name + "__closure"
|
3500
3494
|
);
|
3501
3495
|
signal.render.push(
|
3502
3496
|
import_compiler21.types.expressionStatement(
|
@@ -3524,7 +3518,7 @@ function getSignalFn(signal) {
|
|
3524
3518
|
import_compiler21.types.variableDeclaration("const", [
|
3525
3519
|
import_compiler21.types.variableDeclarator(
|
3526
3520
|
dynamicClosureSignalIdentifier,
|
3527
|
-
callRuntime("
|
3521
|
+
callRuntime("_closure", ...dynamicClosureArgs)
|
3528
3522
|
)
|
3529
3523
|
])
|
3530
3524
|
);
|
@@ -3532,7 +3526,7 @@ function getSignalFn(signal) {
|
|
3532
3526
|
}
|
3533
3527
|
}
|
3534
3528
|
if (signal.effect.length) {
|
3535
|
-
const effectIdentifier = import_compiler21.types.identifier(`${signal.identifier.name}
|
3529
|
+
const effectIdentifier = import_compiler21.types.identifier(`${signal.identifier.name}__script`);
|
3536
3530
|
signal.render.push(
|
3537
3531
|
import_compiler21.types.expressionStatement(
|
3538
3532
|
import_compiler21.types.callExpression(effectIdentifier, [scopeIdentifier])
|
@@ -3604,9 +3598,13 @@ function generateSignalName(referencedBindings) {
|
|
3604
3598
|
let name2;
|
3605
3599
|
if (referencedBindings) {
|
3606
3600
|
if (Array.isArray(referencedBindings)) {
|
3607
|
-
name2 = "
|
3601
|
+
name2 = "";
|
3608
3602
|
for (const ref of referencedBindings) {
|
3609
|
-
name2
|
3603
|
+
if (name2) {
|
3604
|
+
name2 += `__OR__${ref.name.replace(/^\$/, "")}`;
|
3605
|
+
} else {
|
3606
|
+
name2 = ref.name;
|
3607
|
+
}
|
3610
3608
|
}
|
3611
3609
|
} else {
|
3612
3610
|
name2 = referencedBindings.name;
|
@@ -3747,7 +3745,9 @@ function writeSignals(section) {
|
|
3747
3745
|
let effectDeclarator;
|
3748
3746
|
if (signal.effect.length) {
|
3749
3747
|
traverseReplace(signal, "effect", replaceEffectNode);
|
3750
|
-
const effectIdentifier = import_compiler21.types.identifier(
|
3748
|
+
const effectIdentifier = import_compiler21.types.identifier(
|
3749
|
+
`${signal.identifier.name}__script`
|
3750
|
+
);
|
3751
3751
|
const referencedBindings = signal.effectReferencedBindings;
|
3752
3752
|
const referencesScope = traverseContains(
|
3753
3753
|
signal.effect,
|
@@ -3756,7 +3756,7 @@ function writeSignals(section) {
|
|
3756
3756
|
effectDeclarator = import_compiler21.types.variableDeclarator(
|
3757
3757
|
effectIdentifier,
|
3758
3758
|
callRuntime(
|
3759
|
-
"
|
3759
|
+
"_script",
|
3760
3760
|
import_compiler21.types.stringLiteral(
|
3761
3761
|
getResumeRegisterId(section, signal.referencedBindings)
|
3762
3762
|
),
|
@@ -3784,7 +3784,7 @@ function writeSignals(section) {
|
|
3784
3784
|
}
|
3785
3785
|
if (signal.register) {
|
3786
3786
|
value = callRuntime(
|
3787
|
-
"
|
3787
|
+
"_var_resume",
|
3788
3788
|
import_compiler21.types.stringLiteral(
|
3789
3789
|
getResumeRegisterId(section, signal.referencedBindings, "var")
|
3790
3790
|
),
|
@@ -3830,7 +3830,8 @@ function writeHoists(section) {
|
|
3830
3830
|
import_compiler21.types.variableDeclarator(
|
3831
3831
|
hoistIdentifier,
|
3832
3832
|
hoistedBinding.downstreamExpressions.size ? callRuntime(
|
3833
|
-
"
|
3833
|
+
"_resume",
|
3834
|
+
// TODO: add _hoist_resume runtime
|
3834
3835
|
import_compiler21.types.stringLiteral(
|
3835
3836
|
getResumeRegisterId(
|
3836
3837
|
hoistedBinding.section,
|
@@ -3838,8 +3839,8 @@ function writeHoists(section) {
|
|
3838
3839
|
"hoist"
|
3839
3840
|
)
|
3840
3841
|
),
|
3841
|
-
callRuntime("
|
3842
|
-
) : callRuntime("
|
3842
|
+
callRuntime("_hoist", ...accessors)
|
3843
|
+
) : callRuntime("_hoist", ...accessors)
|
3843
3844
|
)
|
3844
3845
|
])
|
3845
3846
|
);
|
@@ -3898,7 +3899,7 @@ function writeRegisteredFns() {
|
|
3898
3899
|
statements.push(
|
3899
3900
|
import_compiler21.types.expressionStatement(
|
3900
3901
|
callRuntime(
|
3901
|
-
"
|
3902
|
+
"_resume",
|
3902
3903
|
import_compiler21.types.stringLiteral(registeredFn.registerId),
|
3903
3904
|
import_compiler21.types.identifier(registeredFn.id)
|
3904
3905
|
)
|
@@ -3930,7 +3931,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3930
3931
|
htmlDynamicClosureInstancesIdentifier.set(
|
3931
3932
|
closureSignal,
|
3932
3933
|
identifier = generateUidIdentifier(
|
3933
|
-
closureSignal.identifier.name + "
|
3934
|
+
closureSignal.identifier.name + "__closures"
|
3934
3935
|
)
|
3935
3936
|
);
|
3936
3937
|
getHTMLSectionStatements(closure.section).push(
|
@@ -3956,7 +3957,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3956
3957
|
);
|
3957
3958
|
addWriteScopeBuilder(
|
3958
3959
|
section,
|
3959
|
-
(expr) => callRuntime("
|
3960
|
+
(expr) => callRuntime("_subscribe", identifier, expr)
|
3960
3961
|
);
|
3961
3962
|
}
|
3962
3963
|
}
|
@@ -3970,7 +3971,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3970
3971
|
import_compiler21.types.variableDeclarator(
|
3971
3972
|
import_compiler21.types.identifier(hoistedBinding.name),
|
3972
3973
|
callRuntime(
|
3973
|
-
"
|
3974
|
+
"_hoist",
|
3974
3975
|
getScopeIdIdentifier(hoistedBinding.section),
|
3975
3976
|
import_compiler21.types.stringLiteral(
|
3976
3977
|
getResumeRegisterId(
|
@@ -3989,7 +3990,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3989
3990
|
const parentSection = currentSection.parent;
|
3990
3991
|
if (!currentSection.sectionAccessor && !sectionDynamicSubscribers.has(currentSection)) {
|
3991
3992
|
const subscribersIdentifier = generateUidIdentifier(
|
3992
|
-
`${currentSection.name}
|
3993
|
+
`${currentSection.name}__subscribers`
|
3993
3994
|
);
|
3994
3995
|
sectionDynamicSubscribers.add(currentSection);
|
3995
3996
|
getHTMLSectionStatements(parentSection).push(
|
@@ -4002,7 +4003,7 @@ function writeHTMLResumeStatements(path5) {
|
|
4002
4003
|
);
|
4003
4004
|
addWriteScopeBuilder(
|
4004
4005
|
currentSection,
|
4005
|
-
(expr) => callRuntime("
|
4006
|
+
(expr) => callRuntime("_subscribe", subscribersIdentifier, expr)
|
4006
4007
|
);
|
4007
4008
|
setSerializedValue(
|
4008
4009
|
parentSection,
|
@@ -4027,7 +4028,7 @@ function writeHTMLResumeStatements(path5) {
|
|
4027
4028
|
body.push(
|
4028
4029
|
import_compiler21.types.expressionStatement(
|
4029
4030
|
callRuntime(
|
4030
|
-
"
|
4031
|
+
"_script",
|
4031
4032
|
scopeIdIdentifier,
|
4032
4033
|
import_compiler21.types.stringLiteral(getResumeRegisterId(section, signalRefs))
|
4033
4034
|
)
|
@@ -4076,7 +4077,7 @@ function writeHTMLResumeStatements(path5) {
|
|
4076
4077
|
const ownerReason = getSectionSerializeReason(section, ownerAccessor);
|
4077
4078
|
if (ownerReason) {
|
4078
4079
|
const getOwnerExpr = callRuntime(
|
4079
|
-
"
|
4080
|
+
"_scope_with_id",
|
4080
4081
|
getScopeIdIdentifier(section.parent)
|
4081
4082
|
);
|
4082
4083
|
serializedLookup.delete(ownerAccessor);
|
@@ -4114,7 +4115,7 @@ function writeHTMLResumeStatements(path5) {
|
|
4114
4115
|
writeScopeArgs.push(import_compiler21.types.objectExpression(debugVars));
|
4115
4116
|
}
|
4116
4117
|
}
|
4117
|
-
let writeScopeCall = writeScopeBuilder ? writeScopeBuilder(callRuntime("
|
4118
|
+
let writeScopeCall = writeScopeBuilder ? writeScopeBuilder(callRuntime("_scope", ...writeScopeArgs)) : callRuntime("_scope", ...writeScopeArgs);
|
4118
4119
|
if (sectionSerializeReason !== true && !sectionSerializeReason.state) {
|
4119
4120
|
writeScopeCall = import_compiler21.types.logicalExpression(
|
4120
4121
|
"&&",
|
@@ -4124,19 +4125,17 @@ function writeHTMLResumeStatements(path5) {
|
|
4124
4125
|
}
|
4125
4126
|
body.push(import_compiler21.types.expressionStatement(writeScopeCall));
|
4126
4127
|
}
|
4127
|
-
const
|
4128
|
-
if (
|
4128
|
+
const resumeClosestBranch = !section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || !!find(section.bindings, (binding) => binding.type === 1 /* let */));
|
4129
|
+
if (resumeClosestBranch) {
|
4129
4130
|
body.push(
|
4130
|
-
import_compiler21.types.expressionStatement(
|
4131
|
-
callRuntime("resumeClosestBranch", scopeIdIdentifier)
|
4132
|
-
)
|
4131
|
+
import_compiler21.types.expressionStatement(callRuntime("_resume_branch", scopeIdIdentifier))
|
4133
4132
|
);
|
4134
4133
|
}
|
4135
4134
|
const additionalStatements = getHTMLSectionStatements(section);
|
4136
4135
|
if (body.length || additionalStatements.length) {
|
4137
4136
|
body.unshift(
|
4138
4137
|
import_compiler21.types.variableDeclaration("const", [
|
4139
|
-
import_compiler21.types.variableDeclarator(scopeIdIdentifier, callRuntime("
|
4138
|
+
import_compiler21.types.variableDeclarator(scopeIdIdentifier, callRuntime("_scope_id"))
|
4140
4139
|
]),
|
4141
4140
|
...additionalStatements
|
4142
4141
|
);
|
@@ -4374,7 +4373,7 @@ var dom_default = {
|
|
4374
4373
|
const { walks: walks2, writes: writes2, setup: setup2 } = getSectionMeta(childSection);
|
4375
4374
|
const identifier = import_compiler22.types.identifier(childSection.name);
|
4376
4375
|
let renderer = getSectionParentIsOwner(childSection) ? callRuntime(
|
4377
|
-
"
|
4376
|
+
"_content_branch",
|
4378
4377
|
...replaceNullishAndEmptyFunctionsWith0([
|
4379
4378
|
writes2,
|
4380
4379
|
walks2,
|
@@ -4382,8 +4381,8 @@ var dom_default = {
|
|
4382
4381
|
tagParamsSignal?.identifier
|
4383
4382
|
])
|
4384
4383
|
) : callRuntime(
|
4385
|
-
isSerializedSection(childSection) ? "
|
4386
|
-
import_compiler22.types.stringLiteral(getResumeRegisterId(childSection, "
|
4384
|
+
isSerializedSection(childSection) ? "_content_resume" : "_content",
|
4385
|
+
import_compiler22.types.stringLiteral(getResumeRegisterId(childSection, "content")),
|
4387
4386
|
...replaceNullishAndEmptyFunctionsWith0([
|
4388
4387
|
writes2,
|
4389
4388
|
walks2,
|
@@ -4394,7 +4393,7 @@ var dom_default = {
|
|
4394
4393
|
);
|
4395
4394
|
if (childSection.referencedLocalClosures) {
|
4396
4395
|
renderer = callRuntime(
|
4397
|
-
"
|
4396
|
+
"_content_closures",
|
4398
4397
|
renderer,
|
4399
4398
|
import_compiler22.types.objectExpression(
|
4400
4399
|
toArray(childSection.referencedLocalClosures, (closure) => {
|
@@ -4453,7 +4452,7 @@ var dom_default = {
|
|
4453
4452
|
program.node.body.push(
|
4454
4453
|
import_compiler22.types.exportDefaultDeclaration(
|
4455
4454
|
callRuntime(
|
4456
|
-
"
|
4455
|
+
"_template",
|
4457
4456
|
import_compiler22.types.stringLiteral(program.hub.file.metadata.marko.id),
|
4458
4457
|
templateIdentifier,
|
4459
4458
|
walksIdentifier,
|
@@ -5412,16 +5411,19 @@ function getMaxOwnSourceOffset(intersection, section) {
|
|
5412
5411
|
}
|
5413
5412
|
var intersectionMeta = /* @__PURE__ */ new WeakMap();
|
5414
5413
|
function setBindingDownstream(binding, expr) {
|
5415
|
-
|
5414
|
+
getBindingValueExprs().set(binding, expr || false);
|
5416
5415
|
if (expr && expr !== true) {
|
5417
5416
|
forEach(expr, (expr2) => {
|
5418
5417
|
expr2.downstream = bindingUtil.add(expr2.downstream, binding);
|
5419
5418
|
});
|
5420
5419
|
}
|
5421
5420
|
}
|
5422
|
-
var
|
5423
|
-
var
|
5421
|
+
var [getResolvedSources] = createProgramState(() => /* @__PURE__ */ new Set());
|
5422
|
+
var [getBindingValueExprs] = createProgramState(
|
5423
|
+
() => /* @__PURE__ */ new Map()
|
5424
|
+
);
|
5424
5425
|
function resolveBindingSources(binding) {
|
5426
|
+
const resolvedSources = getResolvedSources();
|
5425
5427
|
if (resolvedSources.has(binding)) return;
|
5426
5428
|
resolvedSources.add(binding);
|
5427
5429
|
switch (binding.type) {
|
@@ -5448,6 +5450,7 @@ function resolveBindingSources(binding) {
|
|
5448
5450
|
}
|
5449
5451
|
}
|
5450
5452
|
function resolveDerivedSources(binding) {
|
5453
|
+
const bindingValueExprs = getBindingValueExprs();
|
5451
5454
|
const exprs = bindingValueExprs.get(binding);
|
5452
5455
|
bindingValueExprs.delete(binding);
|
5453
5456
|
if (exprs === void 0 || exprs === true) {
|
@@ -5554,8 +5557,8 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
|
|
5554
5557
|
referenceNodes.push(arg);
|
5555
5558
|
}
|
5556
5559
|
}
|
5557
|
-
for (const
|
5558
|
-
referenceNodes.push(
|
5560
|
+
for (const attr of tag.attributes) {
|
5561
|
+
referenceNodes.push(attr.value);
|
5559
5562
|
}
|
5560
5563
|
for (const child of tag.body.attributeTags ? tag.body.body : tag.attributeTags) {
|
5561
5564
|
switch (child.type) {
|
@@ -5898,7 +5901,7 @@ var await_default = {
|
|
5898
5901
|
const { node } = tag;
|
5899
5902
|
const [valueAttr] = node.attributes;
|
5900
5903
|
const tagExtra = node.extra;
|
5901
|
-
const
|
5904
|
+
const nodeRef = tagExtra[kDOMBinding];
|
5902
5905
|
const tagBody = tag.get("body");
|
5903
5906
|
const section = getSection(tag);
|
5904
5907
|
const bodySection = getSectionForBody(tagBody);
|
@@ -5907,9 +5910,9 @@ var await_default = {
|
|
5907
5910
|
tag.replaceWith(
|
5908
5911
|
import_compiler26.types.expressionStatement(
|
5909
5912
|
callRuntime(
|
5910
|
-
"
|
5913
|
+
"_await",
|
5911
5914
|
getScopeIdIdentifier(section),
|
5912
|
-
getScopeAccessorLiteral(
|
5915
|
+
getScopeAccessorLiteral(nodeRef),
|
5913
5916
|
valueAttr.value,
|
5914
5917
|
import_compiler26.types.arrowFunctionExpression(
|
5915
5918
|
node.body.params,
|
@@ -5939,14 +5942,14 @@ var await_default = {
|
|
5939
5942
|
exit(tag) {
|
5940
5943
|
const { node } = tag;
|
5941
5944
|
const tagExtra = node.extra;
|
5942
|
-
const
|
5945
|
+
const nodeRef = tagExtra[kDOMBinding];
|
5943
5946
|
const section = getSection(tag);
|
5944
5947
|
const bodySection = getSectionForBody(tag.get("body"));
|
5945
|
-
const signal = getSignal(section,
|
5948
|
+
const signal = getSignal(section, nodeRef, "await");
|
5946
5949
|
signal.build = () => {
|
5947
5950
|
return callRuntime(
|
5948
|
-
"
|
5949
|
-
getScopeAccessorLiteral(
|
5951
|
+
"_await",
|
5952
|
+
getScopeAccessorLiteral(nodeRef),
|
5950
5953
|
import_compiler26.types.identifier(bodySection.name)
|
5951
5954
|
);
|
5952
5955
|
};
|
@@ -6075,6 +6078,14 @@ var const_default = {
|
|
6075
6078
|
}
|
6076
6079
|
const binding = trackVarReferences(tag, 5 /* derived */, upstreamAlias);
|
6077
6080
|
if (binding) {
|
6081
|
+
if (node.var.type === "Identifier") {
|
6082
|
+
const assignment = tag.scope.getBinding(node.var.name)?.constantViolations?.[0];
|
6083
|
+
if (assignment) {
|
6084
|
+
throw assignment.buildCodeFrameError(
|
6085
|
+
`${node.var.name} is readonly and cannot be mutated.`
|
6086
|
+
);
|
6087
|
+
}
|
6088
|
+
}
|
6078
6089
|
if (!valueExtra.nullable) binding.nullable = false;
|
6079
6090
|
setBindingDownstream(binding, valueExtra);
|
6080
6091
|
}
|
@@ -6346,29 +6357,29 @@ var native_tag_default = {
|
|
6346
6357
|
let spreadReferenceNodes;
|
6347
6358
|
let attrExprExtras;
|
6348
6359
|
for (let i = attributes.length; i--; ) {
|
6349
|
-
const
|
6350
|
-
const valueExtra =
|
6351
|
-
if (import_compiler32.types.isMarkoAttribute(
|
6352
|
-
if (seen[
|
6353
|
-
dropReferences(
|
6360
|
+
const attr = attributes[i];
|
6361
|
+
const valueExtra = attr.value.extra ??= {};
|
6362
|
+
if (import_compiler32.types.isMarkoAttribute(attr)) {
|
6363
|
+
if (seen[attr.name]) {
|
6364
|
+
dropReferences(attr.value);
|
6354
6365
|
continue;
|
6355
6366
|
}
|
6356
|
-
seen[
|
6357
|
-
if (isEventHandler(
|
6367
|
+
seen[attr.name] = attr;
|
6368
|
+
if (isEventHandler(attr.name) || isChangeHandler(attr.name)) {
|
6358
6369
|
valueExtra.isEffect = true;
|
6359
6370
|
hasEventHandlers = true;
|
6360
|
-
} else if (!evaluate(
|
6371
|
+
} else if (!evaluate(attr.value).confident) {
|
6361
6372
|
hasDynamicAttributes = true;
|
6362
6373
|
}
|
6363
|
-
} else if (import_compiler32.types.isMarkoSpreadAttribute(
|
6374
|
+
} else if (import_compiler32.types.isMarkoSpreadAttribute(attr)) {
|
6364
6375
|
valueExtra.isEffect = true;
|
6365
6376
|
hasEventHandlers = true;
|
6366
6377
|
hasDynamicAttributes = true;
|
6367
6378
|
}
|
6368
6379
|
if (spreadReferenceNodes) {
|
6369
|
-
spreadReferenceNodes.push(
|
6370
|
-
} else if (import_compiler32.types.isMarkoSpreadAttribute(
|
6371
|
-
spreadReferenceNodes = [
|
6380
|
+
spreadReferenceNodes.push(attr.value);
|
6381
|
+
} else if (import_compiler32.types.isMarkoSpreadAttribute(attr)) {
|
6382
|
+
spreadReferenceNodes = [attr.value];
|
6372
6383
|
relatedControllable = getRelatedControllable(tagName, seen);
|
6373
6384
|
} else {
|
6374
6385
|
attrExprExtras = push(attrExprExtras, valueExtra);
|
@@ -6386,9 +6397,9 @@ var native_tag_default = {
|
|
6386
6397
|
(0, import_babel_utils25.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
|
6387
6398
|
if (spreadReferenceNodes) {
|
6388
6399
|
if (relatedControllable && !relatedControllable.attrs.every(Boolean)) {
|
6389
|
-
for (const
|
6390
|
-
if (
|
6391
|
-
spreadReferenceNodes.push(
|
6400
|
+
for (const attr of relatedControllable.attrs) {
|
6401
|
+
if (attr) {
|
6402
|
+
spreadReferenceNodes.push(attr.value);
|
6392
6403
|
}
|
6393
6404
|
}
|
6394
6405
|
relatedControllable = void 0;
|
@@ -6447,7 +6458,7 @@ var native_tag_default = {
|
|
6447
6458
|
const tagExtra = tag.node.extra;
|
6448
6459
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
6449
6460
|
const tagDef = (0, import_babel_utils25.getTagDef)(tag);
|
6450
|
-
const
|
6461
|
+
const write = writeTo(tag);
|
6451
6462
|
const tagSection = getSection(tag);
|
6452
6463
|
if (tagExtra.tagNameNullable) {
|
6453
6464
|
flushBefore(tag);
|
@@ -6457,22 +6468,22 @@ var native_tag_default = {
|
|
6457
6468
|
translateVar(
|
6458
6469
|
tag,
|
6459
6470
|
callRuntime(
|
6460
|
-
"
|
6471
|
+
"_el",
|
6461
6472
|
getterId && getScopeIdIdentifier(tagSection),
|
6462
6473
|
getterId && import_compiler32.types.stringLiteral(getterId)
|
6463
6474
|
)
|
6464
6475
|
);
|
6465
6476
|
}
|
6466
6477
|
const visitAccessor = nodeBinding && getScopeAccessorLiteral(nodeBinding);
|
6467
|
-
|
6478
|
+
write`<${tag.node.name}`;
|
6468
6479
|
const usedAttrs = getUsedAttrs(tagName, tag.node);
|
6469
6480
|
const { staticAttrs, staticControllable, skipExpression } = usedAttrs;
|
6470
6481
|
let { spreadExpression } = usedAttrs;
|
6471
6482
|
if (staticControllable) {
|
6472
|
-
const { helper, attrs
|
6483
|
+
const { helper, attrs } = staticControllable;
|
6473
6484
|
if (tagName !== "select" && tagName !== "textarea") {
|
6474
|
-
const values =
|
6475
|
-
|
6485
|
+
const values = attrs.map((attr) => attr?.value);
|
6486
|
+
write`${callRuntime(helper, getScopeIdIdentifier(tagSection), visitAccessor, ...values)}`;
|
6476
6487
|
}
|
6477
6488
|
addHTMLEffectCall(tagSection, void 0);
|
6478
6489
|
}
|
@@ -6524,7 +6535,7 @@ var native_tag_default = {
|
|
6524
6535
|
}
|
6525
6536
|
if (value || valueChange) {
|
6526
6537
|
writeAtStartOfBody = callRuntime(
|
6527
|
-
"
|
6538
|
+
"_attr_textarea_value",
|
6528
6539
|
getScopeIdIdentifier(getSection(tag)),
|
6529
6540
|
getScopeAccessorLiteral(nodeBinding),
|
6530
6541
|
value,
|
@@ -6532,32 +6543,32 @@ var native_tag_default = {
|
|
6532
6543
|
);
|
6533
6544
|
}
|
6534
6545
|
}
|
6535
|
-
for (const
|
6536
|
-
const { name: name2, value } =
|
6546
|
+
for (const attr of staticAttrs) {
|
6547
|
+
const { name: name2, value } = attr;
|
6537
6548
|
const { confident, computed } = value.extra || {};
|
6538
6549
|
const valueReferences = value.extra?.referencedBindings;
|
6539
6550
|
if (tagName === "option" && name2 === "value") {
|
6540
|
-
|
6551
|
+
write`${callRuntime("_attr_option_value", value)}`;
|
6541
6552
|
continue;
|
6542
6553
|
}
|
6543
6554
|
switch (name2) {
|
6544
6555
|
case "class":
|
6545
6556
|
case "style": {
|
6546
|
-
const helper =
|
6557
|
+
const helper = `_attr_${name2}`;
|
6547
6558
|
if (confident) {
|
6548
|
-
|
6559
|
+
write`${getHTMLRuntime()[helper](computed)}`;
|
6549
6560
|
} else {
|
6550
|
-
|
6561
|
+
write`${callRuntime(helper, value)}`;
|
6551
6562
|
}
|
6552
6563
|
break;
|
6553
6564
|
}
|
6554
6565
|
default:
|
6555
6566
|
if (confident) {
|
6556
|
-
|
6567
|
+
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
6557
6568
|
} else if (isEventHandler(name2)) {
|
6558
6569
|
addHTMLEffectCall(tagSection, valueReferences);
|
6559
6570
|
} else {
|
6560
|
-
|
6571
|
+
write`${callRuntime("_attr", import_compiler32.types.stringLiteral(name2), value)}`;
|
6561
6572
|
}
|
6562
6573
|
break;
|
6563
6574
|
}
|
@@ -6568,9 +6579,9 @@ var native_tag_default = {
|
|
6568
6579
|
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
6569
6580
|
if (isOpenOnly || hasChildren || usedAttrs.staticContentAttr) {
|
6570
6581
|
if (skipExpression) {
|
6571
|
-
|
6582
|
+
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), tag.node.name)}`;
|
6572
6583
|
} else {
|
6573
|
-
|
6584
|
+
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), tag.node.name)}`;
|
6574
6585
|
}
|
6575
6586
|
}
|
6576
6587
|
}
|
@@ -6578,20 +6589,20 @@ var native_tag_default = {
|
|
6578
6589
|
switch (tagDef.htmlType) {
|
6579
6590
|
case "svg":
|
6580
6591
|
case "math":
|
6581
|
-
|
6592
|
+
write`/>`;
|
6582
6593
|
break;
|
6583
6594
|
default:
|
6584
|
-
|
6595
|
+
write`>`;
|
6585
6596
|
break;
|
6586
6597
|
}
|
6587
6598
|
} else {
|
6588
6599
|
if (usedAttrs.staticContentAttr) {
|
6589
|
-
|
6600
|
+
write`>`;
|
6590
6601
|
tagExtra[kTagContentAttr] = true;
|
6591
6602
|
tag.node.body.body = [
|
6592
6603
|
import_compiler32.types.expressionStatement(
|
6593
6604
|
callRuntime(
|
6594
|
-
"
|
6605
|
+
"_attr_content",
|
6595
6606
|
visitAccessor,
|
6596
6607
|
getScopeIdIdentifier(tagSection),
|
6597
6608
|
usedAttrs.staticContentAttr.value,
|
@@ -6611,7 +6622,7 @@ var native_tag_default = {
|
|
6611
6622
|
tag.node.body.body = [
|
6612
6623
|
skipExpression ? import_compiler32.types.expressionStatement(
|
6613
6624
|
callRuntime(
|
6614
|
-
"
|
6625
|
+
"_attrs_partial_content",
|
6615
6626
|
spreadExpression,
|
6616
6627
|
skipExpression,
|
6617
6628
|
visitAccessor,
|
@@ -6621,7 +6632,7 @@ var native_tag_default = {
|
|
6621
6632
|
)
|
6622
6633
|
) : import_compiler32.types.expressionStatement(
|
6623
6634
|
callRuntime(
|
6624
|
-
"
|
6635
|
+
"_attrs_content",
|
6625
6636
|
spreadExpression,
|
6626
6637
|
visitAccessor,
|
6627
6638
|
getScopeIdIdentifier(tagSection),
|
@@ -6631,7 +6642,7 @@ var native_tag_default = {
|
|
6631
6642
|
)
|
6632
6643
|
];
|
6633
6644
|
} else {
|
6634
|
-
|
6645
|
+
write`>`;
|
6635
6646
|
}
|
6636
6647
|
}
|
6637
6648
|
if (tagExtra.tagNameNullable) {
|
@@ -6640,7 +6651,7 @@ var native_tag_default = {
|
|
6640
6651
|
)[0].skip();
|
6641
6652
|
}
|
6642
6653
|
if (writeAtStartOfBody) {
|
6643
|
-
|
6654
|
+
write`${writeAtStartOfBody}`;
|
6644
6655
|
}
|
6645
6656
|
},
|
6646
6657
|
exit(tag) {
|
@@ -6664,7 +6675,7 @@ var native_tag_default = {
|
|
6664
6675
|
tag.insertBefore(
|
6665
6676
|
import_compiler32.types.expressionStatement(
|
6666
6677
|
callRuntime(
|
6667
|
-
"
|
6678
|
+
"_attr_select_value",
|
6668
6679
|
getScopeIdIdentifier(getSection(tag)),
|
6669
6680
|
getScopeAccessorLiteral(nodeBinding),
|
6670
6681
|
selectArgs.value,
|
@@ -6703,7 +6714,7 @@ var native_tag_default = {
|
|
6703
6714
|
const tagExtra = tag.node.extra;
|
6704
6715
|
const nodeBinding = tagExtra[kNativeTagBinding];
|
6705
6716
|
const tagDef = (0, import_babel_utils25.getTagDef)(tag);
|
6706
|
-
const
|
6717
|
+
const write = writeTo(tag);
|
6707
6718
|
const tagSection = getSection(tag);
|
6708
6719
|
if (tag.node.var) {
|
6709
6720
|
const varName = tag.node.var.name;
|
@@ -6717,7 +6728,7 @@ var native_tag_default = {
|
|
6717
6728
|
import_compiler32.types.variableDeclarator(
|
6718
6729
|
getterFnIdentifier,
|
6719
6730
|
callRuntime(
|
6720
|
-
"
|
6731
|
+
"_el",
|
6721
6732
|
import_compiler32.types.stringLiteral(getterId),
|
6722
6733
|
import_compiler32.types.stringLiteral(
|
6723
6734
|
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeBinding).value
|
@@ -6762,17 +6773,17 @@ var native_tag_default = {
|
|
6762
6773
|
if (visitAccessor) {
|
6763
6774
|
visit(tag, 32 /* Get */);
|
6764
6775
|
}
|
6765
|
-
|
6776
|
+
write`<${tag.node.name}`;
|
6766
6777
|
const usedAttrs = getUsedAttrs(tagName, tag.node);
|
6767
6778
|
const { staticAttrs, staticControllable, skipExpression } = usedAttrs;
|
6768
6779
|
const { spreadExpression } = usedAttrs;
|
6769
6780
|
const isOpenOnly = !!(tagDef && tagDef.parseOptions?.openTagOnly);
|
6770
6781
|
const hasChildren = !!tag.node.body.body.length;
|
6771
6782
|
if (staticControllable) {
|
6772
|
-
const { helper, attrs
|
6773
|
-
const firstAttr =
|
6783
|
+
const { helper, attrs } = staticControllable;
|
6784
|
+
const firstAttr = attrs.find(Boolean);
|
6774
6785
|
const referencedBindings = firstAttr.value.extra?.referencedBindings;
|
6775
|
-
const values =
|
6786
|
+
const values = attrs.map((attr) => attr?.value);
|
6776
6787
|
addStatement(
|
6777
6788
|
"render",
|
6778
6789
|
tagSection,
|
@@ -6786,20 +6797,20 @@ var native_tag_default = {
|
|
6786
6797
|
tagSection,
|
6787
6798
|
void 0,
|
6788
6799
|
import_compiler32.types.expressionStatement(
|
6789
|
-
callRuntime(`${helper}
|
6800
|
+
callRuntime(`${helper}_script`, scopeIdentifier, visitAccessor)
|
6790
6801
|
)
|
6791
6802
|
);
|
6792
6803
|
}
|
6793
|
-
for (const
|
6794
|
-
const { name: name2, value } =
|
6804
|
+
for (const attr of staticAttrs) {
|
6805
|
+
const { name: name2, value } = attr;
|
6795
6806
|
const { confident, computed } = value.extra || {};
|
6796
6807
|
const valueReferences = value.extra?.referencedBindings;
|
6797
6808
|
switch (name2) {
|
6798
6809
|
case "class":
|
6799
6810
|
case "style": {
|
6800
|
-
const helper =
|
6811
|
+
const helper = `_attr_${name2}`;
|
6801
6812
|
if (confident) {
|
6802
|
-
|
6813
|
+
write`${getHTMLRuntime()[helper](computed)}`;
|
6803
6814
|
} else {
|
6804
6815
|
const nodeExpr = import_compiler32.types.memberExpression(
|
6805
6816
|
scopeIdentifier,
|
@@ -6819,7 +6830,7 @@ var native_tag_default = {
|
|
6819
6830
|
);
|
6820
6831
|
} else {
|
6821
6832
|
if (meta.staticItems) {
|
6822
|
-
|
6833
|
+
write`${getHTMLRuntime()[helper](meta.staticItems)}`;
|
6823
6834
|
}
|
6824
6835
|
if (meta.dynamicValues) {
|
6825
6836
|
const keys = Object.keys(meta.dynamicValues);
|
@@ -6828,7 +6839,7 @@ var native_tag_default = {
|
|
6828
6839
|
const value2 = meta.dynamicValues[key];
|
6829
6840
|
stmt = import_compiler32.types.expressionStatement(
|
6830
6841
|
callRuntime(
|
6831
|
-
|
6842
|
+
`_attr_${name2}_item`,
|
6832
6843
|
nodeExpr,
|
6833
6844
|
import_compiler32.types.stringLiteral(key),
|
6834
6845
|
value2
|
@@ -6844,7 +6855,7 @@ var native_tag_default = {
|
|
6844
6855
|
}
|
6845
6856
|
stmt = import_compiler32.types.expressionStatement(
|
6846
6857
|
callRuntime(
|
6847
|
-
|
6858
|
+
`_attr_${name2}_items`,
|
6848
6859
|
nodeExpr,
|
6849
6860
|
import_compiler32.types.objectExpression(props)
|
6850
6861
|
)
|
@@ -6860,7 +6871,7 @@ var native_tag_default = {
|
|
6860
6871
|
}
|
6861
6872
|
default:
|
6862
6873
|
if (confident) {
|
6863
|
-
|
6874
|
+
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
6864
6875
|
} else if (isEventHandler(name2)) {
|
6865
6876
|
addStatement(
|
6866
6877
|
"effect",
|
@@ -6868,7 +6879,7 @@ var native_tag_default = {
|
|
6868
6879
|
valueReferences,
|
6869
6880
|
import_compiler32.types.expressionStatement(
|
6870
6881
|
callRuntime(
|
6871
|
-
"
|
6882
|
+
"_on",
|
6872
6883
|
import_compiler32.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6873
6884
|
import_compiler32.types.stringLiteral(getEventHandlerName(name2)),
|
6874
6885
|
value
|
@@ -6882,7 +6893,7 @@ var native_tag_default = {
|
|
6882
6893
|
valueReferences,
|
6883
6894
|
import_compiler32.types.expressionStatement(
|
6884
6895
|
callRuntime(
|
6885
|
-
"
|
6896
|
+
"_attr",
|
6886
6897
|
import_compiler32.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6887
6898
|
import_compiler32.types.stringLiteral(name2),
|
6888
6899
|
value
|
@@ -6902,7 +6913,7 @@ var native_tag_default = {
|
|
6902
6913
|
tagExtra.referencedBindings,
|
6903
6914
|
import_compiler32.types.expressionStatement(
|
6904
6915
|
callRuntime(
|
6905
|
-
canHaveAttrContent ? "
|
6916
|
+
canHaveAttrContent ? "_attrs_partial_content" : "_attrs_partial",
|
6906
6917
|
scopeIdentifier,
|
6907
6918
|
visitAccessor,
|
6908
6919
|
spreadExpression,
|
@@ -6917,7 +6928,7 @@ var native_tag_default = {
|
|
6917
6928
|
tagExtra.referencedBindings,
|
6918
6929
|
import_compiler32.types.expressionStatement(
|
6919
6930
|
callRuntime(
|
6920
|
-
canHaveAttrContent ? "
|
6931
|
+
canHaveAttrContent ? "_attrs_content" : "_attrs",
|
6921
6932
|
scopeIdentifier,
|
6922
6933
|
visitAccessor,
|
6923
6934
|
spreadExpression
|
@@ -6930,7 +6941,7 @@ var native_tag_default = {
|
|
6930
6941
|
tagSection,
|
6931
6942
|
tagExtra.referencedBindings,
|
6932
6943
|
import_compiler32.types.expressionStatement(
|
6933
|
-
callRuntime("
|
6944
|
+
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
6934
6945
|
),
|
6935
6946
|
false
|
6936
6947
|
);
|
@@ -6943,7 +6954,7 @@ var native_tag_default = {
|
|
6943
6954
|
contentAttrValue.extra?.referencedBindings,
|
6944
6955
|
import_compiler32.types.expressionStatement(
|
6945
6956
|
callRuntime(
|
6946
|
-
"
|
6957
|
+
"_attr_content",
|
6947
6958
|
scopeIdentifier,
|
6948
6959
|
visitAccessor,
|
6949
6960
|
contentAttrValue
|
@@ -6955,14 +6966,14 @@ var native_tag_default = {
|
|
6955
6966
|
switch (tagDef.htmlType) {
|
6956
6967
|
case "svg":
|
6957
6968
|
case "math":
|
6958
|
-
|
6969
|
+
write`/>`;
|
6959
6970
|
break;
|
6960
6971
|
default:
|
6961
|
-
|
6972
|
+
write`>`;
|
6962
6973
|
break;
|
6963
6974
|
}
|
6964
6975
|
} else {
|
6965
|
-
|
6976
|
+
write`>`;
|
6966
6977
|
}
|
6967
6978
|
enter2(tag);
|
6968
6979
|
},
|
@@ -6978,69 +6989,69 @@ var native_tag_default = {
|
|
6978
6989
|
}
|
6979
6990
|
})
|
6980
6991
|
};
|
6981
|
-
function assertExclusiveControllableGroups(tag,
|
6992
|
+
function assertExclusiveControllableGroups(tag, attrs) {
|
6982
6993
|
const exclusiveGroups = [
|
6983
|
-
|
6984
|
-
|
6985
|
-
|
6986
|
-
|
6994
|
+
attrs.open || attrs.openChange,
|
6995
|
+
attrs.checked || attrs.checkedChange,
|
6996
|
+
attrs.checkedValue || attrs.checkedValueChange,
|
6997
|
+
attrs.valueChange
|
6987
6998
|
].filter(Boolean);
|
6988
6999
|
if (exclusiveGroups.length > 1) {
|
6989
7000
|
throw tag.get("name").buildCodeFrameError(
|
6990
|
-
`The attributes ${exclusiveGroups.map((
|
7001
|
+
`The attributes ${exclusiveGroups.map((attr) => `"${attr.name}"`).join(", ")} are mutually exclusive.`
|
6991
7002
|
);
|
6992
7003
|
}
|
6993
7004
|
}
|
6994
|
-
function getRelatedControllable(tagName,
|
7005
|
+
function getRelatedControllable(tagName, attrs) {
|
6995
7006
|
switch (tagName) {
|
6996
7007
|
case "input":
|
6997
|
-
if (
|
7008
|
+
if (attrs.checked || attrs.checkedChange) {
|
6998
7009
|
return {
|
6999
7010
|
special: false,
|
7000
|
-
helper: "
|
7001
|
-
attrs: [
|
7011
|
+
helper: "_attr_input_checked",
|
7012
|
+
attrs: [attrs.checked, attrs.checkedChange]
|
7002
7013
|
};
|
7003
7014
|
}
|
7004
|
-
if (
|
7015
|
+
if (attrs.checkedValue || attrs.checkedValueChange) {
|
7005
7016
|
return {
|
7006
7017
|
special: true,
|
7007
|
-
helper: "
|
7008
|
-
attrs: [
|
7018
|
+
helper: "_attr_input_checkedValue",
|
7019
|
+
attrs: [attrs.checkedValue, attrs.checkedValueChange, attrs.value]
|
7009
7020
|
};
|
7010
7021
|
}
|
7011
|
-
if (
|
7022
|
+
if (attrs.value || attrs.valueChange) {
|
7012
7023
|
return {
|
7013
7024
|
special: false,
|
7014
|
-
helper: "
|
7015
|
-
attrs: [
|
7025
|
+
helper: "_attr_input_value",
|
7026
|
+
attrs: [attrs.value, attrs.valueChange]
|
7016
7027
|
};
|
7017
7028
|
}
|
7018
7029
|
break;
|
7019
7030
|
case "select":
|
7020
|
-
if (
|
7031
|
+
if (attrs.value || attrs.valueChange) {
|
7021
7032
|
return {
|
7022
7033
|
special: true,
|
7023
|
-
helper: "
|
7024
|
-
attrs: [
|
7034
|
+
helper: "_attr_select_value",
|
7035
|
+
attrs: [attrs.value, attrs.valueChange]
|
7025
7036
|
};
|
7026
7037
|
}
|
7027
7038
|
break;
|
7028
7039
|
case "textarea":
|
7029
|
-
if (
|
7040
|
+
if (attrs.value || attrs.valueChange) {
|
7030
7041
|
return {
|
7031
7042
|
special: true,
|
7032
|
-
helper: "
|
7033
|
-
attrs: [
|
7043
|
+
helper: "_attr_textarea_value",
|
7044
|
+
attrs: [attrs.value, attrs.valueChange]
|
7034
7045
|
};
|
7035
7046
|
}
|
7036
7047
|
break;
|
7037
7048
|
case "details":
|
7038
7049
|
case "dialog":
|
7039
|
-
if (
|
7050
|
+
if (attrs.open || attrs.openChange) {
|
7040
7051
|
return {
|
7041
7052
|
special: false,
|
7042
|
-
helper:
|
7043
|
-
attrs: [
|
7053
|
+
helper: `_attr_${tagName}_open`,
|
7054
|
+
attrs: [attrs.open, attrs.openChange]
|
7044
7055
|
};
|
7045
7056
|
}
|
7046
7057
|
break;
|
@@ -7057,31 +7068,31 @@ function getUsedAttrs(tagName, tag) {
|
|
7057
7068
|
let staticControllable;
|
7058
7069
|
let staticContentAttr;
|
7059
7070
|
for (let i = attributes.length; i--; ) {
|
7060
|
-
const
|
7061
|
-
const { value } =
|
7062
|
-
if (import_compiler32.types.isMarkoSpreadAttribute(
|
7071
|
+
const attr = attributes[i];
|
7072
|
+
const { value } = attr;
|
7073
|
+
if (import_compiler32.types.isMarkoSpreadAttribute(attr)) {
|
7063
7074
|
if (!spreadProps) {
|
7064
7075
|
spreadProps = [];
|
7065
7076
|
staticControllable = getRelatedControllable(tagName, seen);
|
7066
7077
|
if (staticControllable && !staticControllable.attrs.every(Boolean)) {
|
7067
|
-
for (const
|
7068
|
-
if (
|
7069
|
-
spreadProps.push(toObjectProperty(
|
7070
|
-
maybeStaticAttrs.delete(
|
7078
|
+
for (const attr2 of staticControllable.attrs) {
|
7079
|
+
if (attr2) {
|
7080
|
+
spreadProps.push(toObjectProperty(attr2.name, attr2.value));
|
7081
|
+
maybeStaticAttrs.delete(attr2);
|
7071
7082
|
}
|
7072
7083
|
}
|
7073
7084
|
staticControllable = void 0;
|
7074
7085
|
}
|
7075
7086
|
}
|
7076
7087
|
spreadProps.push(import_compiler32.types.spreadElement(value));
|
7077
|
-
} else if (!seen[
|
7078
|
-
seen[
|
7088
|
+
} else if (!seen[attr.name] || !(attr.name === "content" && tag.body.body.length)) {
|
7089
|
+
seen[attr.name] = attr;
|
7079
7090
|
if (spreadProps) {
|
7080
|
-
spreadProps.push(toObjectProperty(
|
7081
|
-
} else if (
|
7082
|
-
staticContentAttr =
|
7091
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
7092
|
+
} else if (attr.name === "content" && tagName !== "meta") {
|
7093
|
+
staticContentAttr = attr;
|
7083
7094
|
} else {
|
7084
|
-
maybeStaticAttrs.add(
|
7095
|
+
maybeStaticAttrs.add(attr);
|
7085
7096
|
}
|
7086
7097
|
}
|
7087
7098
|
}
|
@@ -7092,9 +7103,9 @@ function getUsedAttrs(tagName, tag) {
|
|
7092
7103
|
}
|
7093
7104
|
}
|
7094
7105
|
if (staticControllable) {
|
7095
|
-
for (const
|
7096
|
-
if (
|
7097
|
-
maybeStaticAttrs.delete(
|
7106
|
+
for (const attr of staticControllable.attrs) {
|
7107
|
+
if (attr) {
|
7108
|
+
maybeStaticAttrs.delete(attr);
|
7098
7109
|
}
|
7099
7110
|
}
|
7100
7111
|
}
|
@@ -7102,10 +7113,10 @@ function getUsedAttrs(tagName, tag) {
|
|
7102
7113
|
if (spreadProps) {
|
7103
7114
|
spreadProps.reverse();
|
7104
7115
|
if (staticControllable) {
|
7105
|
-
for (const
|
7106
|
-
if (
|
7116
|
+
for (const attr of staticControllable.attrs) {
|
7117
|
+
if (attr) {
|
7107
7118
|
(skipProps ||= []).push(
|
7108
|
-
toObjectProperty(
|
7119
|
+
toObjectProperty(attr.name, import_compiler32.types.numericLiteral(1))
|
7109
7120
|
);
|
7110
7121
|
}
|
7111
7122
|
}
|
@@ -7398,21 +7409,21 @@ var for_default = {
|
|
7398
7409
|
const { node } = tag;
|
7399
7410
|
const tagExtra = node.extra;
|
7400
7411
|
const { referencedBindings } = tagExtra;
|
7401
|
-
const
|
7412
|
+
const nodeRef = getOptimizedOnlyChildNodeBinding(tag, tagSection);
|
7402
7413
|
setClosureSignalBuilder(tag, (closure, render) => {
|
7403
7414
|
return callRuntime(
|
7404
|
-
"
|
7415
|
+
"_for_closure",
|
7405
7416
|
getScopeAccessorLiteral(closure),
|
7406
|
-
getScopeAccessorLiteral(
|
7417
|
+
getScopeAccessorLiteral(nodeRef),
|
7407
7418
|
render
|
7408
7419
|
);
|
7409
7420
|
});
|
7410
7421
|
const forType = getForType(node);
|
7411
|
-
const signal = getSignal(tagSection,
|
7422
|
+
const signal = getSignal(tagSection, nodeRef, "for");
|
7412
7423
|
signal.build = () => {
|
7413
7424
|
return callRuntime(
|
7414
7425
|
forTypeToDOMRuntime(forType),
|
7415
|
-
getScopeAccessorLiteral(
|
7426
|
+
getScopeAccessorLiteral(nodeRef),
|
7416
7427
|
import_compiler34.types.identifier(bodySection.name)
|
7417
7428
|
);
|
7418
7429
|
};
|
@@ -7490,23 +7501,23 @@ var for_default = {
|
|
7490
7501
|
}
|
7491
7502
|
]
|
7492
7503
|
};
|
7493
|
-
function buildForRuntimeCall(type,
|
7504
|
+
function buildForRuntimeCall(type, attrs, params, statements) {
|
7494
7505
|
return import_compiler34.types.expressionStatement(
|
7495
7506
|
callRuntime(
|
7496
7507
|
forTypeToRuntime(type),
|
7497
|
-
...getBaseArgsInForTag(type,
|
7508
|
+
...getBaseArgsInForTag(type, attrs),
|
7498
7509
|
import_compiler34.types.arrowFunctionExpression(params, import_compiler34.types.blockStatement(statements))
|
7499
7510
|
)
|
7500
7511
|
);
|
7501
7512
|
}
|
7502
7513
|
function getForType(tag) {
|
7503
|
-
for (const
|
7504
|
-
if (
|
7505
|
-
switch (
|
7514
|
+
for (const attr of tag.attributes) {
|
7515
|
+
if (attr.type === "MarkoAttribute") {
|
7516
|
+
switch (attr.name) {
|
7506
7517
|
case "of":
|
7507
7518
|
case "in":
|
7508
7519
|
case "to":
|
7509
|
-
return
|
7520
|
+
return attr.name;
|
7510
7521
|
}
|
7511
7522
|
}
|
7512
7523
|
}
|
@@ -7524,34 +7535,34 @@ function forTypeToRuntime(type) {
|
|
7524
7535
|
function forTypeToHTMLResumeRuntime(type) {
|
7525
7536
|
switch (type) {
|
7526
7537
|
case "of":
|
7527
|
-
return "
|
7538
|
+
return "_for_of";
|
7528
7539
|
case "in":
|
7529
|
-
return "
|
7540
|
+
return "_for_in";
|
7530
7541
|
case "to":
|
7531
|
-
return "
|
7542
|
+
return "_for_to";
|
7532
7543
|
}
|
7533
7544
|
}
|
7534
7545
|
function forTypeToDOMRuntime(type) {
|
7535
7546
|
switch (type) {
|
7536
7547
|
case "of":
|
7537
|
-
return "
|
7548
|
+
return "_for_of";
|
7538
7549
|
case "in":
|
7539
|
-
return "
|
7550
|
+
return "_for_in";
|
7540
7551
|
case "to":
|
7541
|
-
return "
|
7552
|
+
return "_for_to";
|
7542
7553
|
}
|
7543
7554
|
}
|
7544
|
-
function getBaseArgsInForTag(type,
|
7555
|
+
function getBaseArgsInForTag(type, attrs) {
|
7545
7556
|
switch (type) {
|
7546
7557
|
case "in":
|
7547
|
-
return [
|
7558
|
+
return [attrs.in];
|
7548
7559
|
case "of":
|
7549
|
-
return [
|
7560
|
+
return [attrs.of];
|
7550
7561
|
case "to":
|
7551
7562
|
return [
|
7552
|
-
|
7553
|
-
|
7554
|
-
|
7563
|
+
attrs.to,
|
7564
|
+
attrs.from || import_compiler34.types.numericLiteral(0),
|
7565
|
+
attrs.step || import_compiler34.types.numericLiteral(1)
|
7555
7566
|
];
|
7556
7567
|
}
|
7557
7568
|
}
|
@@ -7662,13 +7673,13 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
7662
7673
|
}
|
7663
7674
|
const { attributes } = tag.node;
|
7664
7675
|
for (let i = attributes.length; i--; ) {
|
7665
|
-
const
|
7666
|
-
const { value } =
|
7667
|
-
if (import_compiler35.types.isMarkoSpreadAttribute(
|
7676
|
+
const attr = attributes[i];
|
7677
|
+
const { value } = attr;
|
7678
|
+
if (import_compiler35.types.isMarkoSpreadAttribute(attr)) {
|
7668
7679
|
properties.push(import_compiler35.types.spreadElement(value));
|
7669
|
-
} else if (!seen.has(
|
7670
|
-
seen.add(
|
7671
|
-
properties.push(toObjectProperty(
|
7680
|
+
} else if (!seen.has(attr.name) && usesExport(templateExports, attr.name)) {
|
7681
|
+
seen.add(attr.name);
|
7682
|
+
properties.push(toObjectProperty(attr.name, value));
|
7672
7683
|
}
|
7673
7684
|
}
|
7674
7685
|
properties.reverse();
|
@@ -7866,8 +7877,8 @@ function buildContent(body) {
|
|
7866
7877
|
if (isOutputHTML()) {
|
7867
7878
|
const serialized = isSerializedSection(bodySection);
|
7868
7879
|
return callRuntime(
|
7869
|
-
serialized ? "
|
7870
|
-
import_compiler35.types.stringLiteral(getResumeRegisterId(bodySection, "
|
7880
|
+
serialized ? "_content_resume" : "_content",
|
7881
|
+
import_compiler35.types.stringLiteral(getResumeRegisterId(bodySection, "content")),
|
7871
7882
|
import_compiler35.types.arrowFunctionExpression(
|
7872
7883
|
body.node.params,
|
7873
7884
|
import_compiler35.types.blockStatement(body.node.body)
|
@@ -8099,7 +8110,7 @@ var html_comment_default = {
|
|
8099
8110
|
translateVar(
|
8100
8111
|
tag,
|
8101
8112
|
callRuntime(
|
8102
|
-
"
|
8113
|
+
"_el",
|
8103
8114
|
getterId && getScopeIdIdentifier(getSection(tag)),
|
8104
8115
|
getterId && import_compiler38.types.stringLiteral(getterId)
|
8105
8116
|
)
|
@@ -8115,7 +8126,7 @@ var html_comment_default = {
|
|
8115
8126
|
import_compiler38.types.variableDeclarator(
|
8116
8127
|
getterFnIdentifier,
|
8117
8128
|
callRuntime(
|
8118
|
-
"
|
8129
|
+
"_el",
|
8119
8130
|
import_compiler38.types.stringLiteral(getterId),
|
8120
8131
|
getScopeAccessorLiteral(nodeBinding)
|
8121
8132
|
)
|
@@ -8151,13 +8162,13 @@ var html_comment_default = {
|
|
8151
8162
|
const tagSection = getSection(tag);
|
8152
8163
|
const tagExtra = tag.node.extra;
|
8153
8164
|
const nodeBinding = tagExtra[kNodeBinding];
|
8154
|
-
const
|
8165
|
+
const write = writeTo(tag);
|
8155
8166
|
if (isOutputHTML()) {
|
8156
8167
|
for (const child of tag.node.body.body) {
|
8157
8168
|
if (import_compiler38.types.isMarkoText(child)) {
|
8158
|
-
|
8169
|
+
write`${child.value}`;
|
8159
8170
|
} else if (import_compiler38.types.isMarkoPlaceholder(child)) {
|
8160
|
-
|
8171
|
+
write`${callRuntime("_escape", child.value)}`;
|
8161
8172
|
}
|
8162
8173
|
}
|
8163
8174
|
} else {
|
@@ -8174,7 +8185,7 @@ var html_comment_default = {
|
|
8174
8185
|
}
|
8175
8186
|
}
|
8176
8187
|
if (templateExpressions.length === 0) {
|
8177
|
-
|
8188
|
+
write`${currentQuasi}`;
|
8178
8189
|
} else {
|
8179
8190
|
templateQuasis.push(import_compiler38.types.templateElement({ raw: currentQuasi }));
|
8180
8191
|
addStatement(
|
@@ -8183,7 +8194,7 @@ var html_comment_default = {
|
|
8183
8194
|
tagExtra.referencedBindings,
|
8184
8195
|
import_compiler38.types.expressionStatement(
|
8185
8196
|
callRuntime(
|
8186
|
-
"
|
8197
|
+
"_text",
|
8187
8198
|
import_compiler38.types.memberExpression(
|
8188
8199
|
scopeIdentifier,
|
8189
8200
|
getScopeAccessorLiteral(nodeBinding),
|
@@ -8196,7 +8207,7 @@ var html_comment_default = {
|
|
8196
8207
|
}
|
8197
8208
|
}
|
8198
8209
|
exit2(tag);
|
8199
|
-
|
8210
|
+
write`-->`;
|
8200
8211
|
if (nodeBinding) {
|
8201
8212
|
markNode(
|
8202
8213
|
tag,
|
@@ -8241,29 +8252,29 @@ var html_script_default = {
|
|
8241
8252
|
let hasEventHandlers = false;
|
8242
8253
|
let hasDynamicAttributes = false;
|
8243
8254
|
for (let i = attributes.length; i--; ) {
|
8244
|
-
const
|
8245
|
-
const valueExtra =
|
8246
|
-
if (import_compiler39.types.isMarkoAttribute(
|
8247
|
-
if (seen[
|
8248
|
-
dropReferences(
|
8255
|
+
const attr = attributes[i];
|
8256
|
+
const valueExtra = attr.value.extra ??= {};
|
8257
|
+
if (import_compiler39.types.isMarkoAttribute(attr)) {
|
8258
|
+
if (seen[attr.name]) {
|
8259
|
+
dropReferences(attr.value);
|
8249
8260
|
continue;
|
8250
8261
|
}
|
8251
|
-
seen[
|
8252
|
-
if (isEventHandler(
|
8262
|
+
seen[attr.name] = attr;
|
8263
|
+
if (isEventHandler(attr.name)) {
|
8253
8264
|
valueExtra.isEffect = true;
|
8254
8265
|
hasEventHandlers = true;
|
8255
|
-
} else if (!evaluate(
|
8266
|
+
} else if (!evaluate(attr.value).confident) {
|
8256
8267
|
hasDynamicAttributes = true;
|
8257
8268
|
}
|
8258
|
-
} else if (import_compiler39.types.isMarkoSpreadAttribute(
|
8269
|
+
} else if (import_compiler39.types.isMarkoSpreadAttribute(attr)) {
|
8259
8270
|
valueExtra.isEffect = true;
|
8260
8271
|
hasEventHandlers = true;
|
8261
8272
|
hasDynamicAttributes = true;
|
8262
8273
|
}
|
8263
8274
|
if (spreadReferenceNodes) {
|
8264
|
-
spreadReferenceNodes.push(
|
8265
|
-
} else if (import_compiler39.types.isMarkoSpreadAttribute(
|
8266
|
-
spreadReferenceNodes = [
|
8275
|
+
spreadReferenceNodes.push(attr.value);
|
8276
|
+
} else if (import_compiler39.types.isMarkoSpreadAttribute(attr)) {
|
8277
|
+
spreadReferenceNodes = [attr.value];
|
8267
8278
|
} else {
|
8268
8279
|
exprExtras = push(exprExtras, valueExtra);
|
8269
8280
|
}
|
@@ -8337,7 +8348,7 @@ var html_script_default = {
|
|
8337
8348
|
const tagExtra = tag.node.extra;
|
8338
8349
|
const nodeBinding = tagExtra[kNodeBinding2];
|
8339
8350
|
const isHTML = isOutputHTML();
|
8340
|
-
const
|
8351
|
+
const write = writeTo(tag);
|
8341
8352
|
const tagSection = getSection(tag);
|
8342
8353
|
const hasVar = !!tag.node.var;
|
8343
8354
|
if (hasVar) {
|
@@ -8346,7 +8357,7 @@ var html_script_default = {
|
|
8346
8357
|
translateVar(
|
8347
8358
|
tag,
|
8348
8359
|
callRuntime(
|
8349
|
-
"
|
8360
|
+
"_el",
|
8350
8361
|
getterId && getScopeIdIdentifier(tagSection),
|
8351
8362
|
getterId && import_compiler39.types.stringLiteral(getterId)
|
8352
8363
|
)
|
@@ -8362,7 +8373,7 @@ var html_script_default = {
|
|
8362
8373
|
import_compiler39.types.variableDeclarator(
|
8363
8374
|
getterFnIdentifier,
|
8364
8375
|
callRuntime(
|
8365
|
-
"
|
8376
|
+
"_el",
|
8366
8377
|
import_compiler39.types.stringLiteral(getterId),
|
8367
8378
|
getScopeAccessorLiteral(nodeBinding)
|
8368
8379
|
)
|
@@ -8392,21 +8403,21 @@ var html_script_default = {
|
|
8392
8403
|
if (visitAccessor) {
|
8393
8404
|
visit(tag, 32 /* Get */);
|
8394
8405
|
}
|
8395
|
-
|
8406
|
+
write`<script`;
|
8396
8407
|
const usedAttrs = getUsedAttrs2(tag.node);
|
8397
8408
|
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
8398
|
-
for (const
|
8399
|
-
const { name: name2, value } =
|
8409
|
+
for (const attr of staticAttrs) {
|
8410
|
+
const { name: name2, value } = attr;
|
8400
8411
|
const { confident, computed } = value.extra || {};
|
8401
8412
|
const valueReferences = value.extra?.referencedBindings;
|
8402
8413
|
switch (name2) {
|
8403
8414
|
case "class":
|
8404
8415
|
case "style": {
|
8405
|
-
const helper =
|
8416
|
+
const helper = `_attr_${name2}`;
|
8406
8417
|
if (confident) {
|
8407
|
-
|
8418
|
+
write`${getHTMLRuntime()[helper](computed)}`;
|
8408
8419
|
} else if (isHTML) {
|
8409
|
-
|
8420
|
+
write`${callRuntime(helper, value)}`;
|
8410
8421
|
} else {
|
8411
8422
|
addStatement(
|
8412
8423
|
"render",
|
@@ -8425,12 +8436,12 @@ var html_script_default = {
|
|
8425
8436
|
}
|
8426
8437
|
default:
|
8427
8438
|
if (confident) {
|
8428
|
-
|
8439
|
+
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
8429
8440
|
} else if (isHTML) {
|
8430
8441
|
if (isEventHandler(name2)) {
|
8431
8442
|
addHTMLEffectCall(tagSection, valueReferences);
|
8432
8443
|
} else {
|
8433
|
-
|
8444
|
+
write`${callRuntime("_attr", import_compiler39.types.stringLiteral(name2), value)}`;
|
8434
8445
|
}
|
8435
8446
|
} else if (isEventHandler(name2)) {
|
8436
8447
|
addStatement(
|
@@ -8439,7 +8450,7 @@ var html_script_default = {
|
|
8439
8450
|
valueReferences,
|
8440
8451
|
import_compiler39.types.expressionStatement(
|
8441
8452
|
callRuntime(
|
8442
|
-
"
|
8453
|
+
"_on",
|
8443
8454
|
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
8444
8455
|
import_compiler39.types.stringLiteral(getEventHandlerName(name2)),
|
8445
8456
|
value
|
@@ -8453,7 +8464,7 @@ var html_script_default = {
|
|
8453
8464
|
valueReferences,
|
8454
8465
|
import_compiler39.types.expressionStatement(
|
8455
8466
|
callRuntime(
|
8456
|
-
"
|
8467
|
+
"_attr",
|
8457
8468
|
import_compiler39.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
8458
8469
|
import_compiler39.types.stringLiteral(name2),
|
8459
8470
|
value
|
@@ -8468,9 +8479,9 @@ var html_script_default = {
|
|
8468
8479
|
if (isHTML) {
|
8469
8480
|
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
8470
8481
|
if (skipExpression) {
|
8471
|
-
|
8482
|
+
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler39.types.stringLiteral("script"))}`;
|
8472
8483
|
} else {
|
8473
|
-
|
8484
|
+
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler39.types.stringLiteral("script"))}`;
|
8474
8485
|
}
|
8475
8486
|
} else {
|
8476
8487
|
if (skipExpression) {
|
@@ -8480,7 +8491,7 @@ var html_script_default = {
|
|
8480
8491
|
tagExtra.referencedBindings,
|
8481
8492
|
import_compiler39.types.expressionStatement(
|
8482
8493
|
callRuntime(
|
8483
|
-
"
|
8494
|
+
"_attrs_partial",
|
8484
8495
|
scopeIdentifier,
|
8485
8496
|
visitAccessor,
|
8486
8497
|
spreadExpression,
|
@@ -8495,7 +8506,7 @@ var html_script_default = {
|
|
8495
8506
|
tagExtra.referencedBindings,
|
8496
8507
|
import_compiler39.types.expressionStatement(
|
8497
8508
|
callRuntime(
|
8498
|
-
"
|
8509
|
+
"_attrs",
|
8499
8510
|
scopeIdentifier,
|
8500
8511
|
visitAccessor,
|
8501
8512
|
spreadExpression
|
@@ -8508,26 +8519,26 @@ var html_script_default = {
|
|
8508
8519
|
tagSection,
|
8509
8520
|
tagExtra.referencedBindings,
|
8510
8521
|
import_compiler39.types.expressionStatement(
|
8511
|
-
callRuntime("
|
8522
|
+
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
8512
8523
|
),
|
8513
8524
|
false
|
8514
8525
|
);
|
8515
8526
|
}
|
8516
8527
|
}
|
8517
|
-
|
8528
|
+
write`>`;
|
8518
8529
|
enter2(tag);
|
8519
8530
|
},
|
8520
8531
|
exit(tag) {
|
8521
8532
|
const tagSection = getSection(tag);
|
8522
8533
|
const tagExtra = tag.node.extra;
|
8523
8534
|
const nodeBinding = tagExtra[kNodeBinding2];
|
8524
|
-
const
|
8535
|
+
const write = writeTo(tag);
|
8525
8536
|
if (isOutputHTML()) {
|
8526
8537
|
for (const child of tag.node.body.body) {
|
8527
8538
|
if (import_compiler39.types.isMarkoText(child)) {
|
8528
|
-
|
8539
|
+
write`${child.value}`;
|
8529
8540
|
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
8530
|
-
|
8541
|
+
write`${callRuntime("_escape_script", child.value)}`;
|
8531
8542
|
}
|
8532
8543
|
}
|
8533
8544
|
} else {
|
@@ -8546,7 +8557,7 @@ var html_script_default = {
|
|
8546
8557
|
}
|
8547
8558
|
}
|
8548
8559
|
if (!referencePlaceholder) {
|
8549
|
-
|
8560
|
+
write`${currentQuasi}`;
|
8550
8561
|
} else {
|
8551
8562
|
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
8552
8563
|
addStatement(
|
@@ -8555,7 +8566,7 @@ var html_script_default = {
|
|
8555
8566
|
referencePlaceholder.value.extra?.referencedBindings,
|
8556
8567
|
import_compiler39.types.expressionStatement(
|
8557
8568
|
callRuntime(
|
8558
|
-
"
|
8569
|
+
"_text_content",
|
8559
8570
|
import_compiler39.types.memberExpression(
|
8560
8571
|
scopeIdentifier,
|
8561
8572
|
getScopeAccessorLiteral(nodeBinding),
|
@@ -8567,7 +8578,7 @@ var html_script_default = {
|
|
8567
8578
|
);
|
8568
8579
|
}
|
8569
8580
|
}
|
8570
|
-
|
8581
|
+
write`</script>`;
|
8571
8582
|
if (nodeBinding) {
|
8572
8583
|
markNode(
|
8573
8584
|
tag,
|
@@ -8609,19 +8620,19 @@ function getUsedAttrs2(tag) {
|
|
8609
8620
|
let spreadProps;
|
8610
8621
|
let skipProps;
|
8611
8622
|
for (let i = attributes.length; i--; ) {
|
8612
|
-
const
|
8613
|
-
const { value } =
|
8614
|
-
if (import_compiler39.types.isMarkoSpreadAttribute(
|
8623
|
+
const attr = attributes[i];
|
8624
|
+
const { value } = attr;
|
8625
|
+
if (import_compiler39.types.isMarkoSpreadAttribute(attr)) {
|
8615
8626
|
if (!spreadProps) {
|
8616
8627
|
spreadProps = [];
|
8617
8628
|
}
|
8618
8629
|
spreadProps.push(import_compiler39.types.spreadElement(value));
|
8619
|
-
} else if (!seen[
|
8620
|
-
seen[
|
8630
|
+
} else if (!seen[attr.name]) {
|
8631
|
+
seen[attr.name] = attr;
|
8621
8632
|
if (spreadProps) {
|
8622
|
-
spreadProps.push(toObjectProperty(
|
8633
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
8623
8634
|
} else {
|
8624
|
-
maybeStaticAttrs.add(
|
8635
|
+
maybeStaticAttrs.add(attr);
|
8625
8636
|
}
|
8626
8637
|
}
|
8627
8638
|
}
|
@@ -8665,29 +8676,29 @@ var html_style_default = {
|
|
8665
8676
|
let hasEventHandlers = false;
|
8666
8677
|
let hasDynamicAttributes = false;
|
8667
8678
|
for (let i = attributes.length; i--; ) {
|
8668
|
-
const
|
8669
|
-
const valueExtra =
|
8670
|
-
if (import_compiler40.types.isMarkoAttribute(
|
8671
|
-
if (seen[
|
8672
|
-
dropReferences(
|
8679
|
+
const attr = attributes[i];
|
8680
|
+
const valueExtra = attr.value.extra ??= {};
|
8681
|
+
if (import_compiler40.types.isMarkoAttribute(attr)) {
|
8682
|
+
if (seen[attr.name]) {
|
8683
|
+
dropReferences(attr.value);
|
8673
8684
|
continue;
|
8674
8685
|
}
|
8675
|
-
seen[
|
8676
|
-
if (isEventHandler(
|
8686
|
+
seen[attr.name] = attr;
|
8687
|
+
if (isEventHandler(attr.name)) {
|
8677
8688
|
valueExtra.isEffect = true;
|
8678
8689
|
hasEventHandlers = true;
|
8679
|
-
} else if (!evaluate(
|
8690
|
+
} else if (!evaluate(attr.value).confident) {
|
8680
8691
|
hasDynamicAttributes = true;
|
8681
8692
|
}
|
8682
|
-
} else if (import_compiler40.types.isMarkoSpreadAttribute(
|
8693
|
+
} else if (import_compiler40.types.isMarkoSpreadAttribute(attr)) {
|
8683
8694
|
valueExtra.isEffect = true;
|
8684
8695
|
hasEventHandlers = true;
|
8685
8696
|
hasDynamicAttributes = true;
|
8686
8697
|
}
|
8687
8698
|
if (spreadReferenceNodes) {
|
8688
|
-
spreadReferenceNodes.push(
|
8689
|
-
} else if (import_compiler40.types.isMarkoSpreadAttribute(
|
8690
|
-
spreadReferenceNodes = [
|
8699
|
+
spreadReferenceNodes.push(attr.value);
|
8700
|
+
} else if (import_compiler40.types.isMarkoSpreadAttribute(attr)) {
|
8701
|
+
spreadReferenceNodes = [attr.value];
|
8691
8702
|
} else {
|
8692
8703
|
exprExtras = push(exprExtras, valueExtra);
|
8693
8704
|
}
|
@@ -8761,7 +8772,7 @@ var html_style_default = {
|
|
8761
8772
|
const tagExtra = tag.node.extra;
|
8762
8773
|
const nodeBinding = tagExtra[kNodeBinding3];
|
8763
8774
|
const isHTML = isOutputHTML();
|
8764
|
-
const
|
8775
|
+
const write = writeTo(tag);
|
8765
8776
|
const tagSection = getSection(tag);
|
8766
8777
|
const hasVar = !!tag.node.var;
|
8767
8778
|
if (hasVar) {
|
@@ -8770,7 +8781,7 @@ var html_style_default = {
|
|
8770
8781
|
translateVar(
|
8771
8782
|
tag,
|
8772
8783
|
callRuntime(
|
8773
|
-
"
|
8784
|
+
"_el",
|
8774
8785
|
getterId && getScopeIdIdentifier(tagSection),
|
8775
8786
|
getterId && import_compiler40.types.stringLiteral(getterId)
|
8776
8787
|
)
|
@@ -8786,7 +8797,7 @@ var html_style_default = {
|
|
8786
8797
|
import_compiler40.types.variableDeclarator(
|
8787
8798
|
getterFnIdentifier,
|
8788
8799
|
callRuntime(
|
8789
|
-
"
|
8800
|
+
"_el",
|
8790
8801
|
import_compiler40.types.stringLiteral(getterId),
|
8791
8802
|
getScopeAccessorLiteral(nodeBinding)
|
8792
8803
|
)
|
@@ -8816,21 +8827,21 @@ var html_style_default = {
|
|
8816
8827
|
if (visitAccessor) {
|
8817
8828
|
visit(tag, 32 /* Get */);
|
8818
8829
|
}
|
8819
|
-
|
8830
|
+
write`<style`;
|
8820
8831
|
const usedAttrs = getUsedAttrs3(tag.node);
|
8821
8832
|
const { staticAttrs, skipExpression, spreadExpression } = usedAttrs;
|
8822
|
-
for (const
|
8823
|
-
const { name: name2, value } =
|
8833
|
+
for (const attr of staticAttrs) {
|
8834
|
+
const { name: name2, value } = attr;
|
8824
8835
|
const { confident, computed } = value.extra || {};
|
8825
8836
|
const valueReferences = value.extra?.referencedBindings;
|
8826
8837
|
switch (name2) {
|
8827
8838
|
case "class":
|
8828
8839
|
case "style": {
|
8829
|
-
const helper =
|
8840
|
+
const helper = `_attr_${name2}`;
|
8830
8841
|
if (confident) {
|
8831
|
-
|
8842
|
+
write`${getHTMLRuntime()[helper](computed)}`;
|
8832
8843
|
} else if (isHTML) {
|
8833
|
-
|
8844
|
+
write`${callRuntime(helper, value)}`;
|
8834
8845
|
} else {
|
8835
8846
|
addStatement(
|
8836
8847
|
"render",
|
@@ -8849,12 +8860,12 @@ var html_style_default = {
|
|
8849
8860
|
}
|
8850
8861
|
default:
|
8851
8862
|
if (confident) {
|
8852
|
-
|
8863
|
+
write`${getHTMLRuntime()._attr(name2, computed)}`;
|
8853
8864
|
} else if (isHTML) {
|
8854
8865
|
if (isEventHandler(name2)) {
|
8855
8866
|
addHTMLEffectCall(tagSection, valueReferences);
|
8856
8867
|
} else {
|
8857
|
-
|
8868
|
+
write`${callRuntime("_attr", import_compiler40.types.stringLiteral(name2), value)}`;
|
8858
8869
|
}
|
8859
8870
|
} else if (isEventHandler(name2)) {
|
8860
8871
|
addStatement(
|
@@ -8863,7 +8874,7 @@ var html_style_default = {
|
|
8863
8874
|
valueReferences,
|
8864
8875
|
import_compiler40.types.expressionStatement(
|
8865
8876
|
callRuntime(
|
8866
|
-
"
|
8877
|
+
"_on",
|
8867
8878
|
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
8868
8879
|
import_compiler40.types.stringLiteral(getEventHandlerName(name2)),
|
8869
8880
|
value
|
@@ -8877,7 +8888,7 @@ var html_style_default = {
|
|
8877
8888
|
valueReferences,
|
8878
8889
|
import_compiler40.types.expressionStatement(
|
8879
8890
|
callRuntime(
|
8880
|
-
"
|
8891
|
+
"_attr",
|
8881
8892
|
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
8882
8893
|
import_compiler40.types.stringLiteral(name2),
|
8883
8894
|
value
|
@@ -8892,9 +8903,9 @@ var html_style_default = {
|
|
8892
8903
|
if (isHTML) {
|
8893
8904
|
addHTMLEffectCall(tagSection, tagExtra.referencedBindings);
|
8894
8905
|
if (skipExpression) {
|
8895
|
-
|
8906
|
+
write`${callRuntime("_attrs_partial", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler40.types.stringLiteral("style"))}`;
|
8896
8907
|
} else {
|
8897
|
-
|
8908
|
+
write`${callRuntime("_attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(tagSection), import_compiler40.types.stringLiteral("style"))}`;
|
8898
8909
|
}
|
8899
8910
|
} else {
|
8900
8911
|
if (skipExpression) {
|
@@ -8904,7 +8915,7 @@ var html_style_default = {
|
|
8904
8915
|
tagExtra.referencedBindings,
|
8905
8916
|
import_compiler40.types.expressionStatement(
|
8906
8917
|
callRuntime(
|
8907
|
-
"
|
8918
|
+
"_attrs_partial",
|
8908
8919
|
scopeIdentifier,
|
8909
8920
|
visitAccessor,
|
8910
8921
|
spreadExpression,
|
@@ -8919,7 +8930,7 @@ var html_style_default = {
|
|
8919
8930
|
tagExtra.referencedBindings,
|
8920
8931
|
import_compiler40.types.expressionStatement(
|
8921
8932
|
callRuntime(
|
8922
|
-
"
|
8933
|
+
"_attrs",
|
8923
8934
|
scopeIdentifier,
|
8924
8935
|
visitAccessor,
|
8925
8936
|
spreadExpression
|
@@ -8932,26 +8943,26 @@ var html_style_default = {
|
|
8932
8943
|
tagSection,
|
8933
8944
|
tagExtra.referencedBindings,
|
8934
8945
|
import_compiler40.types.expressionStatement(
|
8935
|
-
callRuntime("
|
8946
|
+
callRuntime("_attrs_script", scopeIdentifier, visitAccessor)
|
8936
8947
|
),
|
8937
8948
|
false
|
8938
8949
|
);
|
8939
8950
|
}
|
8940
8951
|
}
|
8941
|
-
|
8952
|
+
write`>`;
|
8942
8953
|
enter2(tag);
|
8943
8954
|
},
|
8944
8955
|
exit(tag) {
|
8945
8956
|
const tagSection = getSection(tag);
|
8946
8957
|
const tagExtra = tag.node.extra;
|
8947
8958
|
const nodeBinding = tagExtra[kNodeBinding3];
|
8948
|
-
const
|
8959
|
+
const write = writeTo(tag);
|
8949
8960
|
if (isOutputHTML()) {
|
8950
8961
|
for (const child of tag.node.body.body) {
|
8951
8962
|
if (import_compiler40.types.isMarkoText(child)) {
|
8952
|
-
|
8963
|
+
write`${child.value}`;
|
8953
8964
|
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
8954
|
-
|
8965
|
+
write`${callRuntime("_escape_style", child.value)}`;
|
8955
8966
|
}
|
8956
8967
|
}
|
8957
8968
|
} else {
|
@@ -8970,7 +8981,7 @@ var html_style_default = {
|
|
8970
8981
|
}
|
8971
8982
|
}
|
8972
8983
|
if (!referencePlaceholder) {
|
8973
|
-
|
8984
|
+
write`${currentQuasi}`;
|
8974
8985
|
} else {
|
8975
8986
|
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
8976
8987
|
addStatement(
|
@@ -8979,7 +8990,7 @@ var html_style_default = {
|
|
8979
8990
|
referencePlaceholder.value.extra?.referencedBindings,
|
8980
8991
|
import_compiler40.types.expressionStatement(
|
8981
8992
|
callRuntime(
|
8982
|
-
"
|
8993
|
+
"_text_content",
|
8983
8994
|
import_compiler40.types.memberExpression(
|
8984
8995
|
scopeIdentifier,
|
8985
8996
|
getScopeAccessorLiteral(nodeBinding),
|
@@ -8991,7 +9002,7 @@ var html_style_default = {
|
|
8991
9002
|
);
|
8992
9003
|
}
|
8993
9004
|
}
|
8994
|
-
|
9005
|
+
write`</style>`;
|
8995
9006
|
if (nodeBinding) {
|
8996
9007
|
markNode(
|
8997
9008
|
tag,
|
@@ -9028,19 +9039,19 @@ function getUsedAttrs3(tag) {
|
|
9028
9039
|
let spreadProps;
|
9029
9040
|
let skipProps;
|
9030
9041
|
for (let i = attributes.length; i--; ) {
|
9031
|
-
const
|
9032
|
-
const { value } =
|
9033
|
-
if (import_compiler40.types.isMarkoSpreadAttribute(
|
9042
|
+
const attr = attributes[i];
|
9043
|
+
const { value } = attr;
|
9044
|
+
if (import_compiler40.types.isMarkoSpreadAttribute(attr)) {
|
9034
9045
|
if (!spreadProps) {
|
9035
9046
|
spreadProps = [];
|
9036
9047
|
}
|
9037
9048
|
spreadProps.push(import_compiler40.types.spreadElement(value));
|
9038
|
-
} else if (!seen[
|
9039
|
-
seen[
|
9049
|
+
} else if (!seen[attr.name]) {
|
9050
|
+
seen[attr.name] = attr;
|
9040
9051
|
if (spreadProps) {
|
9041
|
-
spreadProps.push(toObjectProperty(
|
9052
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
9042
9053
|
} else {
|
9043
|
-
maybeStaticAttrs.add(
|
9054
|
+
maybeStaticAttrs.add(attr);
|
9044
9055
|
}
|
9045
9056
|
}
|
9046
9057
|
}
|
@@ -9096,7 +9107,7 @@ var id_default = {
|
|
9096
9107
|
translate: {
|
9097
9108
|
exit(tag) {
|
9098
9109
|
const { node } = tag;
|
9099
|
-
const id = isOutputHTML() ? callRuntime("
|
9110
|
+
const id = isOutputHTML() ? callRuntime("_id") : callRuntime("_id", scopeIdentifier);
|
9100
9111
|
const [valueAttr] = tag.node.attributes;
|
9101
9112
|
if (isOutputHTML()) {
|
9102
9113
|
tag.replaceWith(
|
@@ -9289,7 +9300,7 @@ var IfTag = {
|
|
9289
9300
|
);
|
9290
9301
|
statement = import_compiler43.types.expressionStatement(
|
9291
9302
|
callRuntime(
|
9292
|
-
"
|
9303
|
+
"_if",
|
9293
9304
|
cbNode,
|
9294
9305
|
getScopeIdIdentifier(ifTagSection),
|
9295
9306
|
getScopeAccessorLiteral(nodeBinding),
|
@@ -9327,7 +9338,7 @@ var IfTag = {
|
|
9327
9338
|
const [ifTag] = branches[0];
|
9328
9339
|
const ifTagSection = getSection(ifTag);
|
9329
9340
|
const ifTagExtra = branches[0][0].node.extra;
|
9330
|
-
const
|
9341
|
+
const nodeRef = getOptimizedOnlyChildNodeBinding(ifTag, ifTagSection);
|
9331
9342
|
const rendererIdentifiers = [];
|
9332
9343
|
let expr = import_compiler43.types.numericLiteral(branches.length);
|
9333
9344
|
for (let i = branches.length; i--; ) {
|
@@ -9338,9 +9349,9 @@ var IfTag = {
|
|
9338
9349
|
rendererIdentifiers.push(import_compiler43.types.identifier(branchBodySection.name));
|
9339
9350
|
setClosureSignalBuilder(branchTag, (closure, render) => {
|
9340
9351
|
return callRuntime(
|
9341
|
-
"
|
9352
|
+
"_if_closure",
|
9342
9353
|
getScopeAccessorLiteral(closure),
|
9343
|
-
getScopeAccessorLiteral(
|
9354
|
+
getScopeAccessorLiteral(nodeRef),
|
9344
9355
|
import_compiler43.types.numericLiteral(i),
|
9345
9356
|
render
|
9346
9357
|
);
|
@@ -9349,11 +9360,11 @@ var IfTag = {
|
|
9349
9360
|
branchTag.remove();
|
9350
9361
|
expr = testAttr ? import_compiler43.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
|
9351
9362
|
}
|
9352
|
-
const signal = getSignal(ifTagSection,
|
9363
|
+
const signal = getSignal(ifTagSection, nodeRef, "if");
|
9353
9364
|
signal.build = () => {
|
9354
9365
|
return callRuntime(
|
9355
|
-
"
|
9356
|
-
getScopeAccessorLiteral(
|
9366
|
+
"_if",
|
9367
|
+
getScopeAccessorLiteral(nodeRef),
|
9357
9368
|
...rendererIdentifiers.reverse()
|
9358
9369
|
);
|
9359
9370
|
};
|
@@ -9523,15 +9534,15 @@ var let_default = {
|
|
9523
9534
|
const tagVar = node.var;
|
9524
9535
|
let valueAttr;
|
9525
9536
|
let valueChangeAttr;
|
9526
|
-
for (const
|
9527
|
-
if (import_compiler44.types.isMarkoAttribute(
|
9528
|
-
if (
|
9529
|
-
valueAttr =
|
9530
|
-
} else if (
|
9531
|
-
valueChangeAttr =
|
9537
|
+
for (const attr of node.attributes) {
|
9538
|
+
if (import_compiler44.types.isMarkoAttribute(attr)) {
|
9539
|
+
if (attr.name === "value") {
|
9540
|
+
valueAttr = attr;
|
9541
|
+
} else if (attr.name === "valueChange") {
|
9542
|
+
valueChangeAttr = attr;
|
9532
9543
|
} else {
|
9533
|
-
const start =
|
9534
|
-
const end =
|
9544
|
+
const start = attr.loc?.start;
|
9545
|
+
const end = attr.loc?.end;
|
9535
9546
|
const msg = "The [`<let>` tag](https://next.markojs.com/docs/reference/core-tag#let) only supports the [`value=` attribute](https://next.markojs.com/docs/reference/language#shorthand-value) and its change handler.";
|
9536
9547
|
if (start == null || end == null) {
|
9537
9548
|
throw tag.get("name").buildCodeFrameError(msg);
|
@@ -9560,7 +9571,7 @@ var let_default = {
|
|
9560
9571
|
);
|
9561
9572
|
}
|
9562
9573
|
if (valueChangeAttr && (0, import_babel_utils38.computeNode)(valueChangeAttr.value)) {
|
9563
|
-
throw tag.get("attributes").find((
|
9574
|
+
throw tag.get("attributes").find((attr) => attr.node === valueChangeAttr).get("value").buildCodeFrameError(
|
9564
9575
|
"The [`<let>` tag](https://next.markojs.com/docs/reference/core-tag#let) [`valueChange=` attribute](https://next.markojs.com/docs/reference/core-tag#controllable-let) must be a function."
|
9565
9576
|
);
|
9566
9577
|
}
|
@@ -9586,15 +9597,15 @@ var let_default = {
|
|
9586
9597
|
const { node } = tag;
|
9587
9598
|
const tagVar = node.var;
|
9588
9599
|
const valueAttr = node.attributes.find(
|
9589
|
-
(
|
9600
|
+
(attr) => import_compiler44.types.isMarkoAttribute(attr) && (attr.default || attr.name === "value")
|
9590
9601
|
) ?? import_compiler44.types.markoAttribute("value", import_compiler44.types.identifier("undefined"));
|
9591
9602
|
const valueChangeAttr = node.attributes.find(
|
9592
|
-
(
|
9603
|
+
(attr) => import_compiler44.types.isMarkoAttribute(attr) && attr.name === "valueChange"
|
9593
9604
|
);
|
9594
9605
|
const section = getSection(tag);
|
9595
9606
|
const binding = tagVar.extra.binding;
|
9596
9607
|
if (isOutputDOM()) {
|
9597
|
-
const signal = initValue(binding,
|
9608
|
+
const signal = initValue(binding, true);
|
9598
9609
|
const referencedBindings = tag.node.extra.referencedBindings;
|
9599
9610
|
addValue(section, referencedBindings, signal, valueAttr.value);
|
9600
9611
|
if (valueChangeAttr) {
|
@@ -9659,13 +9670,13 @@ var lifecycle_default = {
|
|
9659
9670
|
"The [`<lifecycle>` tag](https://next.markojs.com/docs/reference/core-tag#lifecycle) requires at least one attribute."
|
9660
9671
|
);
|
9661
9672
|
}
|
9662
|
-
for (const
|
9663
|
-
if (import_compiler45.types.isMarkoSpreadAttribute(
|
9673
|
+
for (const attr of node.attributes) {
|
9674
|
+
if (import_compiler45.types.isMarkoSpreadAttribute(attr)) {
|
9664
9675
|
throw tag.get("name").buildCodeFrameError(
|
9665
9676
|
"The [`<lifecycle>` tag](https://next.markojs.com/docs/reference/core-tag#lifecycle) does not support [`...spread` attributes](https://next.markojs.com/docs/reference/language#spread-attributes)."
|
9666
9677
|
);
|
9667
9678
|
}
|
9668
|
-
(
|
9679
|
+
(attr.value.extra ??= {}).isEffect = true;
|
9669
9680
|
}
|
9670
9681
|
((0, import_babel_utils39.getProgram)().node.extra ??= {}).isInteractive = true;
|
9671
9682
|
},
|
@@ -9681,7 +9692,7 @@ var lifecycle_default = {
|
|
9681
9692
|
translatedAttrs.statements.push(
|
9682
9693
|
import_compiler45.types.expressionStatement(
|
9683
9694
|
callRuntime(
|
9684
|
-
"
|
9695
|
+
"_lifecycle",
|
9685
9696
|
scopeIdentifier,
|
9686
9697
|
getScopeAccessorLiteral(lifecycleAttrsRef),
|
9687
9698
|
propsToExpression(translatedAttrs.properties)
|
@@ -9812,17 +9823,17 @@ var script_default = {
|
|
9812
9823
|
);
|
9813
9824
|
}
|
9814
9825
|
let seenValueAttr = false;
|
9815
|
-
for (const
|
9816
|
-
if (
|
9826
|
+
for (const attr of node.attributes) {
|
9827
|
+
if (attr.type === "MarkoAttribute" && attr.name === "value") {
|
9817
9828
|
if (seenValueAttr) {
|
9818
|
-
throw tag.hub.buildError(
|
9829
|
+
throw tag.hub.buildError(attr, "Invalid duplicate value attribute.");
|
9819
9830
|
}
|
9820
9831
|
seenValueAttr = true;
|
9821
|
-
(
|
9832
|
+
(attr.value.extra ??= {}).isEffect = true;
|
9822
9833
|
((0, import_babel_utils41.getProgram)().node.extra ??= {}).isInteractive = true;
|
9823
9834
|
} else {
|
9824
9835
|
throw tag.hub.buildError(
|
9825
|
-
|
9836
|
+
attr,
|
9826
9837
|
"The [`<script>` tag](https://next.markojs.com/docs/reference/core-tag#script) does not support html attributes." + htmlScriptTagAlternateMsg
|
9827
9838
|
);
|
9828
9839
|
}
|
@@ -9981,12 +9992,12 @@ var style_default = {
|
|
9981
9992
|
(0, import_babel_utils44.assertNoAttributeTags)(tag);
|
9982
9993
|
const { node } = tag;
|
9983
9994
|
const ext = STYLE_EXT_REG.exec(node.rawValue || "")?.[1]?.slice(1);
|
9984
|
-
for (const
|
9985
|
-
if (
|
9995
|
+
for (const attr of node.attributes) {
|
9996
|
+
if (attr.start == null && attr.type === "MarkoAttribute" && attr.name === "class" && attr.value.type === "StringLiteral" && attr.value.value === ext) {
|
9986
9997
|
continue;
|
9987
9998
|
}
|
9988
9999
|
throw tag.hub.buildError(
|
9989
|
-
|
10000
|
+
attr.value,
|
9990
10001
|
"The `style` does not support html attributes." + htmlStyleTagAlternateMsg
|
9991
10002
|
);
|
9992
10003
|
}
|
@@ -10120,7 +10131,7 @@ var try_default = {
|
|
10120
10131
|
const tagExtra = node.extra;
|
10121
10132
|
const tagBody = tag.get("body");
|
10122
10133
|
const translatedAttrs = translateAttrs(tag);
|
10123
|
-
const
|
10134
|
+
const nodeRef = tagExtra[kDOMBinding2];
|
10124
10135
|
const contentProp = getTranslatedBodyContentProperty(
|
10125
10136
|
translatedAttrs.properties
|
10126
10137
|
);
|
@@ -10136,9 +10147,9 @@ var try_default = {
|
|
10136
10147
|
tag.replaceWith(
|
10137
10148
|
import_compiler51.types.expressionStatement(
|
10138
10149
|
callRuntime(
|
10139
|
-
"
|
10150
|
+
"_try",
|
10140
10151
|
getScopeIdIdentifier(section),
|
10141
|
-
getScopeAccessorLiteral(
|
10152
|
+
getScopeAccessorLiteral(nodeRef),
|
10142
10153
|
contentProp?.value,
|
10143
10154
|
propsToExpression(translatedAttrs.properties)
|
10144
10155
|
)
|
@@ -10157,7 +10168,7 @@ var try_default = {
|
|
10157
10168
|
exit(tag) {
|
10158
10169
|
const { node } = tag;
|
10159
10170
|
const tagExtra = node.extra;
|
10160
|
-
const
|
10171
|
+
const nodeRef = tagExtra[kDOMBinding2];
|
10161
10172
|
const referencedBindings = tagExtra.referencedBindings;
|
10162
10173
|
const translatedAttrs = translateAttrs(tag);
|
10163
10174
|
const contentProp = getTranslatedBodyContentProperty(
|
@@ -10171,11 +10182,11 @@ var try_default = {
|
|
10171
10182
|
}
|
10172
10183
|
const section = getSection(tag);
|
10173
10184
|
const bodySection = getSectionForBody(tag.get("body"));
|
10174
|
-
const signal = getSignal(section,
|
10185
|
+
const signal = getSignal(section, nodeRef, "try");
|
10175
10186
|
signal.build = () => {
|
10176
10187
|
return callRuntime(
|
10177
|
-
"
|
10178
|
-
getScopeAccessorLiteral(
|
10188
|
+
"_try",
|
10189
|
+
getScopeAccessorLiteral(nodeRef),
|
10179
10190
|
import_compiler51.types.identifier(bodySection.name)
|
10180
10191
|
);
|
10181
10192
|
};
|
@@ -10188,7 +10199,7 @@ var try_default = {
|
|
10188
10199
|
);
|
10189
10200
|
}
|
10190
10201
|
(0, import_babel_utils45.getProgram)().node.body.push(
|
10191
|
-
import_compiler51.types.expressionStatement(callRuntime("
|
10202
|
+
import_compiler51.types.expressionStatement(callRuntime("_enable_catch"))
|
10192
10203
|
);
|
10193
10204
|
addValue(
|
10194
10205
|
section,
|
@@ -10345,7 +10356,7 @@ var placeholder_default = {
|
|
10345
10356
|
const { confident, computed } = valueExtra;
|
10346
10357
|
if (confident && isVoid2(computed)) return;
|
10347
10358
|
if (isStaticText(node)) {
|
10348
|
-
if (isStaticText(getPrev(placeholder))) {
|
10359
|
+
if (isStaticText(getPrev(placeholder)) || isStaticText(getNext(placeholder))) {
|
10349
10360
|
(node.extra ??= {})[kSharedText] = true;
|
10350
10361
|
}
|
10351
10362
|
} else {
|
@@ -10371,13 +10382,13 @@ var placeholder_default = {
|
|
10371
10382
|
return;
|
10372
10383
|
}
|
10373
10384
|
const isHTML = isOutputHTML();
|
10374
|
-
const
|
10385
|
+
const write = writeTo(placeholder);
|
10375
10386
|
const extra = node.extra || {};
|
10376
10387
|
const nodeBinding = extra[kNodeBinding4];
|
10377
10388
|
const canWriteHTML = isHTML || confident && node.escape;
|
10378
|
-
const method = canWriteHTML ? node.escape ? "
|
10389
|
+
const method = canWriteHTML ? node.escape ? "_escape" : "_unescaped" : node.escape ? "_text" : "_html";
|
10379
10390
|
if (confident && canWriteHTML) {
|
10380
|
-
|
10391
|
+
write`${getHTMLRuntime()[method](computed)}`;
|
10381
10392
|
} else {
|
10382
10393
|
const section = getSection(placeholder);
|
10383
10394
|
const siblingText = extra[kSiblingText];
|
@@ -10385,20 +10396,20 @@ var placeholder_default = {
|
|
10385
10396
|
if (siblingText === 1 /* Before */) {
|
10386
10397
|
if (isHTML && markerSerializeReason) {
|
10387
10398
|
if (markerSerializeReason === true || markerSerializeReason.state) {
|
10388
|
-
|
10399
|
+
write`<!>`;
|
10389
10400
|
} else {
|
10390
|
-
|
10401
|
+
write`${callRuntime("_sep", getSerializeGuard(markerSerializeReason, true))}`;
|
10391
10402
|
}
|
10392
10403
|
}
|
10393
10404
|
visit(placeholder, 37 /* Replace */);
|
10394
10405
|
} else if (siblingText === 2 /* After */) {
|
10395
10406
|
visit(placeholder, 37 /* Replace */);
|
10396
10407
|
} else {
|
10397
|
-
if (!isHTML)
|
10408
|
+
if (!isHTML) write` `;
|
10398
10409
|
visit(placeholder, 32 /* Get */);
|
10399
10410
|
}
|
10400
10411
|
if (isHTML) {
|
10401
|
-
|
10412
|
+
write`${callRuntime(method, value)}`;
|
10402
10413
|
if (nodeBinding) {
|
10403
10414
|
markNode(placeholder, nodeBinding, markerSerializeReason);
|
10404
10415
|
}
|
@@ -10408,8 +10419,8 @@ var placeholder_default = {
|
|
10408
10419
|
getSection(placeholder),
|
10409
10420
|
valueExtra.referencedBindings,
|
10410
10421
|
import_compiler53.types.expressionStatement(
|
10411
|
-
method === "
|
10412
|
-
"
|
10422
|
+
method === "_text" ? callRuntime(
|
10423
|
+
"_text",
|
10413
10424
|
import_compiler53.types.memberExpression(
|
10414
10425
|
scopeIdentifier,
|
10415
10426
|
getScopeAccessorLiteral(nodeBinding),
|
@@ -10417,7 +10428,7 @@ var placeholder_default = {
|
|
10417
10428
|
),
|
10418
10429
|
value
|
10419
10430
|
) : callRuntime(
|
10420
|
-
"
|
10431
|
+
"_html",
|
10421
10432
|
scopeIdentifier,
|
10422
10433
|
value,
|
10423
10434
|
getScopeAccessorLiteral(nodeBinding)
|
@@ -10495,6 +10506,13 @@ function getPrev(path5) {
|
|
10495
10506
|
}
|
10496
10507
|
return prev.node;
|
10497
10508
|
}
|
10509
|
+
function getNext(path5) {
|
10510
|
+
let next = path5.getNextSibling();
|
10511
|
+
while (next.node && (next.isMarkoComment() || next.isMarkoPlaceholder() && isEmptyPlaceholder(next.node))) {
|
10512
|
+
next = next.getNextSibling();
|
10513
|
+
}
|
10514
|
+
return next.node;
|
10515
|
+
}
|
10498
10516
|
function isEmptyPlaceholder(placeholder) {
|
10499
10517
|
const { confident, computed } = evaluate(placeholder.value);
|
10500
10518
|
return confident && isVoid2(computed);
|
@@ -10581,7 +10599,7 @@ var referenced_identifier_default = {
|
|
10581
10599
|
section,
|
10582
10600
|
exprRoot.node.extra?.referencedBindings,
|
10583
10601
|
import_compiler54.types.expressionStatement(
|
10584
|
-
import_compiler54.types.callExpression(importRuntime("
|
10602
|
+
import_compiler54.types.callExpression(importRuntime("$signalReset"), [
|
10585
10603
|
scopeIdentifier,
|
10586
10604
|
import_compiler54.types.numericLiteral(exprId)
|
10587
10605
|
])
|
@@ -10590,7 +10608,7 @@ var referenced_identifier_default = {
|
|
10590
10608
|
);
|
10591
10609
|
}
|
10592
10610
|
identifier.replaceWith(
|
10593
|
-
import_compiler54.types.callExpression(importRuntime("
|
10611
|
+
import_compiler54.types.callExpression(importRuntime("$signal"), [
|
10594
10612
|
scopeIdentifier,
|
10595
10613
|
import_compiler54.types.numericLiteral(exprId)
|
10596
10614
|
])
|
@@ -10863,19 +10881,19 @@ function translateHTML(tag) {
|
|
10863
10881
|
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
10864
10882
|
tag.insertBefore(
|
10865
10883
|
import_compiler56.types.variableDeclaration("const", [
|
10866
|
-
import_compiler56.types.variableDeclarator(peekScopeId, callRuntime("
|
10884
|
+
import_compiler56.types.variableDeclarator(peekScopeId, callRuntime("_peek_scope_id"))
|
10867
10885
|
])
|
10868
10886
|
);
|
10869
10887
|
setBindingSerializedValue(
|
10870
10888
|
section,
|
10871
10889
|
childScopeBinding,
|
10872
|
-
callRuntime("
|
10890
|
+
callRuntime("_existing_scope", peekScopeId)
|
10873
10891
|
);
|
10874
10892
|
if (tagVar) {
|
10875
10893
|
statements.push(
|
10876
10894
|
import_compiler56.types.expressionStatement(
|
10877
10895
|
callRuntime(
|
10878
|
-
"
|
10896
|
+
"_var",
|
10879
10897
|
getScopeIdIdentifier(section),
|
10880
10898
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
10881
10899
|
peekScopeId,
|
@@ -10953,7 +10971,7 @@ function translateDOM(tag) {
|
|
10953
10971
|
const { node } = tag;
|
10954
10972
|
const extra = node.extra;
|
10955
10973
|
const childScopeBinding = extra[kChildScopeBinding];
|
10956
|
-
const
|
10974
|
+
const write = writeTo(tag);
|
10957
10975
|
const { file } = tag.hub;
|
10958
10976
|
const tagName = import_compiler56.types.isIdentifier(node.name) ? node.name.name : import_compiler56.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
10959
10977
|
const relativePath = getTagRelativePath(tag);
|
@@ -10973,7 +10991,7 @@ function translateDOM(tag) {
|
|
10973
10991
|
);
|
10974
10992
|
source.register = true;
|
10975
10993
|
source.buildAssignment = (valueSection, value) => {
|
10976
|
-
return import_compiler56.types.callExpression(importRuntime("
|
10994
|
+
return import_compiler56.types.callExpression(importRuntime("_var_change"), [
|
10977
10995
|
createScopeReadExpression(valueSection, childScopeBinding),
|
10978
10996
|
value
|
10979
10997
|
]);
|
@@ -10984,7 +11002,7 @@ function translateDOM(tag) {
|
|
10984
11002
|
void 0,
|
10985
11003
|
import_compiler56.types.expressionStatement(
|
10986
11004
|
callRuntime(
|
10987
|
-
"
|
11005
|
+
"_var",
|
10988
11006
|
scopeIdentifier,
|
10989
11007
|
getScopeAccessorLiteral(childScopeBinding),
|
10990
11008
|
source.identifier
|
@@ -11011,7 +11029,7 @@ function translateDOM(tag) {
|
|
11011
11029
|
attrTagCallsByTag: void 0
|
11012
11030
|
});
|
11013
11031
|
}
|
11014
|
-
|
11032
|
+
write`${(0, import_babel_utils49.importNamed)(file, relativePath, childExports.template, `${tagName}_template`)}`;
|
11015
11033
|
injectWalks(
|
11016
11034
|
tag,
|
11017
11035
|
(0, import_babel_utils49.importNamed)(file, relativePath, childExports.walks, `${tagName}_walks`)
|
@@ -11157,26 +11175,26 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport, rootAttrExprs,
|
|
11157
11175
|
const { attributes } = tag.node;
|
11158
11176
|
let spreadReferenceNodes;
|
11159
11177
|
for (let i = attributes.length; i--; ) {
|
11160
|
-
const
|
11161
|
-
if (import_compiler56.types.isMarkoAttribute(
|
11162
|
-
const templateExportAttr = templateExport.props[
|
11163
|
-
if (!templateExportAttr || seen.has(
|
11164
|
-
dropReferences(
|
11178
|
+
const attr = attributes[i];
|
11179
|
+
if (import_compiler56.types.isMarkoAttribute(attr)) {
|
11180
|
+
const templateExportAttr = templateExport.props[attr.name];
|
11181
|
+
if (!templateExportAttr || seen.has(attr.name)) {
|
11182
|
+
dropReferences(attr.value);
|
11165
11183
|
continue;
|
11166
11184
|
}
|
11167
|
-
seen.add(
|
11185
|
+
seen.add(attr.name);
|
11168
11186
|
setBindingDownstream(
|
11169
11187
|
templateExportAttr.binding,
|
11170
|
-
|
11188
|
+
attr.value.extra ??= {}
|
11171
11189
|
);
|
11172
11190
|
}
|
11173
11191
|
if (spreadReferenceNodes) {
|
11174
|
-
spreadReferenceNodes.push(
|
11175
|
-
} else if (import_compiler56.types.isMarkoSpreadAttribute(
|
11176
|
-
spreadReferenceNodes = [
|
11192
|
+
spreadReferenceNodes.push(attr.value);
|
11193
|
+
} else if (import_compiler56.types.isMarkoSpreadAttribute(attr)) {
|
11194
|
+
spreadReferenceNodes = [attr.value];
|
11177
11195
|
} else {
|
11178
|
-
const attrValueExtra =
|
11179
|
-
known[
|
11196
|
+
const attrValueExtra = attr.value.extra ??= {};
|
11197
|
+
known[attr.name] = { value: attrValueExtra };
|
11180
11198
|
rootAttrExprs.add(attrValueExtra);
|
11181
11199
|
}
|
11182
11200
|
}
|
@@ -11408,38 +11426,38 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
11408
11426
|
const staticAttrs = [];
|
11409
11427
|
let spreadProps;
|
11410
11428
|
for (let i = attributes.length; i--; ) {
|
11411
|
-
const
|
11412
|
-
if (import_compiler56.types.isMarkoAttribute(
|
11413
|
-
const childAttrExports = templateExport.props[
|
11414
|
-
if (!childAttrExports || seen.has(
|
11415
|
-
seen.add(
|
11429
|
+
const attr = attributes[i];
|
11430
|
+
if (import_compiler56.types.isMarkoAttribute(attr)) {
|
11431
|
+
const childAttrExports = templateExport.props[attr.name];
|
11432
|
+
if (!childAttrExports || seen.has(attr.name)) continue;
|
11433
|
+
seen.add(attr.name);
|
11416
11434
|
if (spreadProps) {
|
11417
|
-
spreadProps.push(toObjectProperty(
|
11435
|
+
spreadProps.push(toObjectProperty(attr.name, attr.value));
|
11418
11436
|
continue;
|
11419
11437
|
}
|
11420
|
-
staticAttrs.push(
|
11438
|
+
staticAttrs.push(attr);
|
11421
11439
|
} else if (spreadProps) {
|
11422
|
-
spreadProps.push(import_compiler56.types.spreadElement(
|
11440
|
+
spreadProps.push(import_compiler56.types.spreadElement(attr.value));
|
11423
11441
|
} else {
|
11424
|
-
spreadProps = [import_compiler56.types.spreadElement(
|
11442
|
+
spreadProps = [import_compiler56.types.spreadElement(attr.value)];
|
11425
11443
|
}
|
11426
11444
|
}
|
11427
|
-
for (const
|
11428
|
-
const childAttrExports = templateExport.props[
|
11445
|
+
for (const attr of staticAttrs.reverse()) {
|
11446
|
+
const childAttrExports = templateExport.props[attr.name];
|
11429
11447
|
const attrExportIdentifier = importOrSelfReferenceName(
|
11430
11448
|
tag.hub.file,
|
11431
11449
|
info.relativePath,
|
11432
11450
|
childAttrExports.id,
|
11433
|
-
`${importAlias}_${
|
11451
|
+
`${importAlias}_${attr.name}`
|
11434
11452
|
);
|
11435
11453
|
addStatement(
|
11436
11454
|
"render",
|
11437
11455
|
info.tagSection,
|
11438
|
-
|
11456
|
+
attr.value.extra?.referencedBindings,
|
11439
11457
|
import_compiler56.types.expressionStatement(
|
11440
11458
|
import_compiler56.types.callExpression(attrExportIdentifier, [
|
11441
11459
|
createScopeReadExpression(info.tagSection, info.childScopeBinding),
|
11442
|
-
|
11460
|
+
attr.value
|
11443
11461
|
])
|
11444
11462
|
)
|
11445
11463
|
);
|
@@ -11555,7 +11573,7 @@ var dynamic_tag_default = {
|
|
11555
11573
|
tagSection
|
11556
11574
|
);
|
11557
11575
|
(0, import_babel_utils50.getProgram)().node.extra.isInteractive ||= hasVar || tag.node.attributes.some(
|
11558
|
-
(
|
11576
|
+
(attr) => import_compiler57.types.isMarkoSpreadAttribute(attr) || isEventHandler(attr.name)
|
11559
11577
|
);
|
11560
11578
|
if (hasVar) {
|
11561
11579
|
trackVarReferences(tag, 5 /* derived */);
|
@@ -11617,7 +11635,7 @@ var dynamic_tag_default = {
|
|
11617
11635
|
(0, import_babel_utils50.getProgram)().node.body.push(
|
11618
11636
|
import_compiler57.types.expressionStatement(
|
11619
11637
|
callRuntime(
|
11620
|
-
"
|
11638
|
+
"_resume",
|
11621
11639
|
import_compiler57.types.stringLiteral((0, import_babel_utils50.loadFileForTag)(tag).metadata.marko.id),
|
11622
11640
|
import_compiler57.types.identifier(tagExpression.name)
|
11623
11641
|
)
|
@@ -11656,7 +11674,7 @@ var dynamic_tag_default = {
|
|
11656
11674
|
true
|
11657
11675
|
);
|
11658
11676
|
const dynamicTagExpr = hasTagArgs ? callRuntime(
|
11659
|
-
"
|
11677
|
+
"_dynamic_tag",
|
11660
11678
|
getScopeIdIdentifier(tagSection),
|
11661
11679
|
getScopeAccessorLiteral(nodeBinding),
|
11662
11680
|
tagExpression,
|
@@ -11665,7 +11683,7 @@ var dynamic_tag_default = {
|
|
11665
11683
|
import_compiler57.types.numericLiteral(1),
|
11666
11684
|
serializeArg
|
11667
11685
|
) : callRuntime(
|
11668
|
-
"
|
11686
|
+
"_dynamic_tag",
|
11669
11687
|
getScopeIdIdentifier(tagSection),
|
11670
11688
|
getScopeAccessorLiteral(nodeBinding),
|
11671
11689
|
tagExpression,
|
@@ -11682,7 +11700,7 @@ var dynamic_tag_default = {
|
|
11682
11700
|
import_compiler57.types.variableDeclaration("const", [
|
11683
11701
|
import_compiler57.types.variableDeclarator(
|
11684
11702
|
dynamicScopeIdentifier,
|
11685
|
-
callRuntime("
|
11703
|
+
callRuntime("_peek_scope_id")
|
11686
11704
|
)
|
11687
11705
|
])
|
11688
11706
|
);
|
@@ -11692,7 +11710,7 @@ var dynamic_tag_default = {
|
|
11692
11710
|
]),
|
11693
11711
|
import_compiler57.types.expressionStatement(
|
11694
11712
|
callRuntime(
|
11695
|
-
"
|
11713
|
+
"_var",
|
11696
11714
|
getScopeIdIdentifier(tagSection),
|
11697
11715
|
getScopeAccessorLiteral(
|
11698
11716
|
tag.node.extra[kChildOffsetScopeBinding2]
|
@@ -11727,7 +11745,7 @@ var dynamic_tag_default = {
|
|
11727
11745
|
);
|
11728
11746
|
tagVarSignal.register = true;
|
11729
11747
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
11730
|
-
return import_compiler57.types.callExpression(importRuntime("
|
11748
|
+
return import_compiler57.types.callExpression(importRuntime("_var_change"), [
|
11731
11749
|
import_compiler57.types.memberExpression(
|
11732
11750
|
getScopeExpression(tagVarSignal.section, valueSection),
|
11733
11751
|
import_compiler57.types.stringLiteral(
|
@@ -11741,7 +11759,7 @@ var dynamic_tag_default = {
|
|
11741
11759
|
}
|
11742
11760
|
signal.build = () => {
|
11743
11761
|
return callRuntime(
|
11744
|
-
"
|
11762
|
+
"_dynamic_tag",
|
11745
11763
|
getScopeAccessorLiteral(nodeBinding),
|
11746
11764
|
bodySection && import_compiler57.types.identifier(bodySection.name),
|
11747
11765
|
tagVarSignal ? import_compiler57.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
@@ -11785,10 +11803,10 @@ var tag_default = {
|
|
11785
11803
|
}
|
11786
11804
|
}
|
11787
11805
|
for (let i = 0; i < attributes.length; i++) {
|
11788
|
-
const
|
11789
|
-
if (import_compiler58.types.isMarkoAttribute(
|
11790
|
-
|
11791
|
-
attributes.splice(++i, 0, getChangeHandler(tag,
|
11806
|
+
const attr = attributes[i];
|
11807
|
+
if (import_compiler58.types.isMarkoAttribute(attr) && attr.bound) {
|
11808
|
+
attr.bound = false;
|
11809
|
+
attributes.splice(++i, 0, getChangeHandler(tag, attr));
|
11792
11810
|
crawl = true;
|
11793
11811
|
}
|
11794
11812
|
}
|
@@ -11841,19 +11859,19 @@ var tag_default = {
|
|
11841
11859
|
enter(tagDef.translator.hook, tag);
|
11842
11860
|
return;
|
11843
11861
|
}
|
11844
|
-
for (const
|
11845
|
-
if (
|
11846
|
-
if (
|
11847
|
-
throw
|
11848
|
-
`Unsupported arguments on the \`${
|
11862
|
+
for (const attr of tag.get("attributes")) {
|
11863
|
+
if (attr.isMarkoAttribute()) {
|
11864
|
+
if (attr.node.arguments) {
|
11865
|
+
throw attr.buildCodeFrameError(
|
11866
|
+
`Unsupported arguments on the \`${attr.node.name}\` attribute.`
|
11849
11867
|
);
|
11850
11868
|
}
|
11851
|
-
if (
|
11852
|
-
if ((0, import_babel_utils51.isNativeTag)(
|
11853
|
-
|
11869
|
+
if (attr.node.modifier) {
|
11870
|
+
if ((0, import_babel_utils51.isNativeTag)(attr.parentPath)) {
|
11871
|
+
attr.node.name += `:${attr.node.modifier}`;
|
11854
11872
|
} else {
|
11855
|
-
throw
|
11856
|
-
`Unsupported modifier \`${
|
11873
|
+
throw attr.buildCodeFrameError(
|
11874
|
+
`Unsupported modifier \`${attr.node.modifier}\`.`
|
11857
11875
|
);
|
11858
11876
|
}
|
11859
11877
|
}
|
@@ -11907,24 +11925,24 @@ var tag_default = {
|
|
11907
11925
|
}
|
11908
11926
|
}
|
11909
11927
|
};
|
11910
|
-
function getChangeHandler(tag,
|
11911
|
-
const attrName =
|
11928
|
+
function getChangeHandler(tag, attr) {
|
11929
|
+
const attrName = attr.name;
|
11912
11930
|
const changeAttrName = attrName + "Change";
|
11913
|
-
if (import_compiler58.types.isIdentifier(
|
11914
|
-
const binding = tag.scope.getBinding(
|
11931
|
+
if (import_compiler58.types.isIdentifier(attr.value)) {
|
11932
|
+
const binding = tag.scope.getBinding(attr.value.name);
|
11915
11933
|
if (!binding)
|
11916
11934
|
return import_compiler58.types.markoAttribute(
|
11917
11935
|
changeAttrName,
|
11918
|
-
buildChangeHandlerFunction(
|
11936
|
+
buildChangeHandlerFunction(attr.value)
|
11919
11937
|
);
|
11920
11938
|
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
11921
11939
|
if (!existingChangedAttr) {
|
11922
11940
|
const bindingIdentifierPath = binding.path.getOuterBindingIdentifierPaths()[binding.identifier.name];
|
11923
|
-
const changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(
|
11941
|
+
const changeAttrExpr = bindingIdentifierPath ? bindingIdentifierPath.parentPath === binding.path ? buildChangeHandlerFunction(attr.value) : bindingIdentifierPath.parentPath.isObjectProperty() ? getChangeHandlerFromObjectPattern(
|
11924
11942
|
bindingIdentifierPath.parentPath
|
11925
11943
|
) : void 0 : void 0;
|
11926
11944
|
if (!changeAttrExpr) {
|
11927
|
-
throw tag.hub.buildError(
|
11945
|
+
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
11928
11946
|
}
|
11929
11947
|
const changeHandlerAttr = import_compiler58.types.markoAttribute(
|
11930
11948
|
changeAttrName,
|
@@ -11938,13 +11956,13 @@ function getChangeHandler(tag, attr2) {
|
|
11938
11956
|
changeAttrName,
|
11939
11957
|
withPreviousLocation(
|
11940
11958
|
import_compiler58.types.identifier(existingChangedAttr.name),
|
11941
|
-
|
11959
|
+
attr.value
|
11942
11960
|
)
|
11943
11961
|
);
|
11944
11962
|
}
|
11945
11963
|
const markoRoot = isMarko(binding.path) ? binding.path : getMarkoRoot(binding.path);
|
11946
11964
|
if (!(markoRoot?.isMarkoTag() || markoRoot?.isMarkoTagBody())) {
|
11947
|
-
throw tag.hub.buildError(
|
11965
|
+
throw tag.hub.buildError(attr.value, "Unable to bind to value.");
|
11948
11966
|
}
|
11949
11967
|
const changeHandlerId = generateUid(changeAttrName);
|
11950
11968
|
const changeHandlerConst = import_compiler58.types.markoTag(
|
@@ -11965,15 +11983,15 @@ function getChangeHandler(tag, attr2) {
|
|
11965
11983
|
}
|
11966
11984
|
return import_compiler58.types.markoAttribute(
|
11967
11985
|
changeAttrName,
|
11968
|
-
withPreviousLocation(import_compiler58.types.identifier(changeHandlerId),
|
11986
|
+
withPreviousLocation(import_compiler58.types.identifier(changeHandlerId), attr.value)
|
11969
11987
|
);
|
11970
|
-
} else if (import_compiler58.types.isMemberExpression(
|
11971
|
-
const prop =
|
11972
|
-
if (!import_compiler58.types.isPrivateName(
|
11988
|
+
} else if (import_compiler58.types.isMemberExpression(attr.value)) {
|
11989
|
+
const prop = attr.value.property;
|
11990
|
+
if (!import_compiler58.types.isPrivateName(attr.value.property)) {
|
11973
11991
|
return import_compiler58.types.markoAttribute(
|
11974
11992
|
changeAttrName,
|
11975
11993
|
import_compiler58.types.memberExpression(
|
11976
|
-
import_compiler58.types.cloneNode(
|
11994
|
+
import_compiler58.types.cloneNode(attr.value.object),
|
11977
11995
|
prop.type === "Identifier" ? withPreviousLocation(import_compiler58.types.identifier(prop.name + "Change"), prop) : import_compiler58.types.binaryExpression(
|
11978
11996
|
"+",
|
11979
11997
|
import_compiler58.types.cloneNode(prop),
|
@@ -11985,7 +12003,7 @@ function getChangeHandler(tag, attr2) {
|
|
11985
12003
|
}
|
11986
12004
|
}
|
11987
12005
|
throw tag.hub.buildError(
|
11988
|
-
|
12006
|
+
attr.value,
|
11989
12007
|
"Attributes may only be bound to identifiers or member expressions"
|
11990
12008
|
);
|
11991
12009
|
}
|