marko 6.0.0-next.3.75 → 6.0.0-next.3.77
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 +2 -1
- package/dist/debug/dom.mjs +2 -1
- package/dist/dom.js +2 -2
- package/dist/dom.mjs +2 -2
- package/dist/translator/index.js +864 -785
- package/dist/translator/util/dynamic-sources.d.ts +1 -2
- package/dist/translator/util/evaluate.d.ts +1 -1
- package/dist/translator/util/generate-uid.d.ts +3 -0
- package/dist/translator/util/traverse.d.ts +1 -0
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -109,7 +109,7 @@ var attrs_default = {
|
|
109
109
|
};
|
110
110
|
|
111
111
|
// src/translator/core/await.ts
|
112
|
-
var
|
112
|
+
var import_compiler27 = require("@marko/compiler");
|
113
113
|
var import_babel_utils12 = require("@marko/compiler/babel-utils");
|
114
114
|
|
115
115
|
// src/common/accessor.debug.ts
|
@@ -163,15 +163,133 @@ function evaluate(value) {
|
|
163
163
|
}
|
164
164
|
|
165
165
|
// src/translator/util/references.ts
|
166
|
-
var
|
166
|
+
var import_compiler26 = require("@marko/compiler");
|
167
167
|
|
168
168
|
// src/translator/util/dynamic-sources.ts
|
169
|
-
var
|
169
|
+
var import_compiler7 = require("@marko/compiler");
|
170
170
|
|
171
171
|
// src/translator/util/sections.ts
|
172
|
-
var
|
172
|
+
var import_compiler6 = require("@marko/compiler");
|
173
173
|
var import_babel_utils5 = require("@marko/compiler/babel-utils");
|
174
174
|
|
175
|
+
// src/translator/util/generate-uid.ts
|
176
|
+
var import_compiler3 = require("@marko/compiler");
|
177
|
+
|
178
|
+
// src/translator/util/traverse.ts
|
179
|
+
var import_compiler2 = require("@marko/compiler");
|
180
|
+
var skip = Symbol("skip");
|
181
|
+
function traverseReplace(container, key, enter3) {
|
182
|
+
const node = container[key];
|
183
|
+
if (node) {
|
184
|
+
if (Array.isArray(node)) {
|
185
|
+
for (let i = node.length; i--; ) {
|
186
|
+
traverseReplace(node, i, enter3);
|
187
|
+
}
|
188
|
+
} else {
|
189
|
+
const keys = import_compiler2.types.VISITOR_KEYS[node.type];
|
190
|
+
for (let i = keys.length; i--; ) {
|
191
|
+
traverseReplace(node, keys[i], enter3);
|
192
|
+
}
|
193
|
+
const replacement = enter3(node, container, key);
|
194
|
+
if (replacement) container[key] = replacement;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
function traverseContains(node, check) {
|
199
|
+
if (node) {
|
200
|
+
if (Array.isArray(node)) {
|
201
|
+
for (const item of node) {
|
202
|
+
if (traverseContains(item, check)) {
|
203
|
+
return true;
|
204
|
+
}
|
205
|
+
}
|
206
|
+
} else {
|
207
|
+
switch (check(node)) {
|
208
|
+
case true:
|
209
|
+
return true;
|
210
|
+
case skip:
|
211
|
+
return false;
|
212
|
+
}
|
213
|
+
for (const key of import_compiler2.types.VISITOR_KEYS[node.type]) {
|
214
|
+
if (traverseContains(node[key], check)) {
|
215
|
+
return true;
|
216
|
+
}
|
217
|
+
}
|
218
|
+
}
|
219
|
+
}
|
220
|
+
return false;
|
221
|
+
}
|
222
|
+
function traverse(visit2, node, parent, grandParent) {
|
223
|
+
if (node) {
|
224
|
+
if (Array.isArray(node)) {
|
225
|
+
for (const item of node) {
|
226
|
+
traverse(visit2, item, parent, grandParent);
|
227
|
+
}
|
228
|
+
} else if (visit2(node, parent, grandParent) !== skip) {
|
229
|
+
for (const key of import_compiler2.types.VISITOR_KEYS[node.type]) {
|
230
|
+
traverse(visit2, node[key], node, parent);
|
231
|
+
}
|
232
|
+
}
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
// src/translator/util/generate-uid.ts
|
237
|
+
var countsForFile = /* @__PURE__ */ new WeakMap();
|
238
|
+
function generateUid(name2 = "") {
|
239
|
+
const file = (0, import_compiler3.getFile)();
|
240
|
+
let counts = countsForFile.get(file);
|
241
|
+
if (!counts) {
|
242
|
+
const { cache } = file.markoOpts;
|
243
|
+
const { filename } = file.opts;
|
244
|
+
const cacheKey = `uid-counts:${filename}`;
|
245
|
+
counts = cache.get(cacheKey);
|
246
|
+
if (counts) {
|
247
|
+
if (isTranslate(file)) {
|
248
|
+
counts = new Map(counts);
|
249
|
+
}
|
250
|
+
} else {
|
251
|
+
counts = getInitialCounts(file);
|
252
|
+
if (!isTranslate(file)) {
|
253
|
+
cache.set(cacheKey, counts);
|
254
|
+
}
|
255
|
+
}
|
256
|
+
countsForFile.set(file, counts);
|
257
|
+
}
|
258
|
+
name2 = name2.replace(/^[^a-z$_]|[^a-z$_0-9]/gi, "") || "temp";
|
259
|
+
name2 = /^_?(.*?)\d*$/.exec(name2)?.[1] || name2;
|
260
|
+
const i = (counts.get(name2) || 0) + 1;
|
261
|
+
const uniqueName = `_${i > 1 ? name2 + i : name2}`;
|
262
|
+
counts.set(name2, i);
|
263
|
+
return uniqueName;
|
264
|
+
}
|
265
|
+
function generateUidIdentifier(name2) {
|
266
|
+
return import_compiler3.types.identifier(generateUid(name2));
|
267
|
+
}
|
268
|
+
function getInitialCounts(file) {
|
269
|
+
const counts = /* @__PURE__ */ new Map();
|
270
|
+
const program = file.path;
|
271
|
+
const countName = (name2) => {
|
272
|
+
const match = /^_(.*?)([1-9]\d*)?$/.exec(name2);
|
273
|
+
if (match) {
|
274
|
+
const name3 = match[1];
|
275
|
+
const count = match[2] ? +match[2] + 1 : 1;
|
276
|
+
counts.set(name3, Math.max(counts.get(name3) || 0, count));
|
277
|
+
}
|
278
|
+
};
|
279
|
+
for (const name2 in program.scope.globals) {
|
280
|
+
countName(name2);
|
281
|
+
}
|
282
|
+
traverse((node, parent, grandParent) => {
|
283
|
+
if (node.type === "Identifier" && import_compiler3.types.isBinding(node, parent, grandParent)) {
|
284
|
+
countName(node.name);
|
285
|
+
}
|
286
|
+
}, program.node);
|
287
|
+
return counts;
|
288
|
+
}
|
289
|
+
function isTranslate(file) {
|
290
|
+
return file.___compileStage === "translate";
|
291
|
+
}
|
292
|
+
|
175
293
|
// src/translator/util/is-core-tag.ts
|
176
294
|
var import_babel_utils3 = require("@marko/compiler/babel-utils");
|
177
295
|
|
@@ -473,38 +591,38 @@ function joinRepeatable(compare, a, b) {
|
|
473
591
|
}
|
474
592
|
|
475
593
|
// src/translator/util/state.ts
|
476
|
-
var
|
594
|
+
var import_compiler4 = require("@marko/compiler");
|
477
595
|
var createProgramState = (init) => {
|
478
596
|
const map2 = /* @__PURE__ */ new WeakMap();
|
479
597
|
return [
|
480
598
|
() => {
|
481
|
-
let state = map2.get((0,
|
599
|
+
let state = map2.get((0, import_compiler4.getProgram)());
|
482
600
|
if (!state) {
|
483
|
-
map2.set((0,
|
601
|
+
map2.set((0, import_compiler4.getProgram)(), state = init());
|
484
602
|
}
|
485
603
|
return state;
|
486
604
|
},
|
487
605
|
(value) => {
|
488
|
-
map2.set((0,
|
606
|
+
map2.set((0, import_compiler4.getProgram)(), value);
|
489
607
|
}
|
490
608
|
];
|
491
609
|
};
|
492
610
|
function createSectionState(key, init) {
|
493
611
|
return [
|
494
612
|
(section) => {
|
495
|
-
const arrayOfSectionData = (0,
|
613
|
+
const arrayOfSectionData = (0, import_compiler4.getProgram)().state[key] ??= {};
|
496
614
|
const sectionData = arrayOfSectionData[section.id] ??= init && init(section);
|
497
615
|
return sectionData;
|
498
616
|
},
|
499
617
|
(section, value) => {
|
500
|
-
const arrayOfSectionData = (0,
|
618
|
+
const arrayOfSectionData = (0, import_compiler4.getProgram)().state[key] ??= {};
|
501
619
|
arrayOfSectionData[section.id] = value;
|
502
620
|
}
|
503
621
|
];
|
504
622
|
}
|
505
623
|
|
506
624
|
// src/translator/util/tag-name-type.ts
|
507
|
-
var
|
625
|
+
var import_compiler5 = require("@marko/compiler");
|
508
626
|
var import_babel_utils4 = require("@marko/compiler/babel-utils");
|
509
627
|
var MARKO_FILE_REG = /^<.*>$|\.marko$/;
|
510
628
|
function analyzeTagNameType(tag) {
|
@@ -534,7 +652,7 @@ function analyzeTagNameType(tag) {
|
|
534
652
|
} else if (childFile.ast.program.extra.featureType === "class") {
|
535
653
|
extra.tagNameType = 2 /* DynamicTag */;
|
536
654
|
extra.featureType = "class";
|
537
|
-
((0,
|
655
|
+
((0, import_compiler5.getProgram)().node.extra ??= {}).needsCompat = true;
|
538
656
|
}
|
539
657
|
}
|
540
658
|
}
|
@@ -579,7 +697,7 @@ function analyzeExpressionTagName(name2, extra) {
|
|
579
697
|
}
|
580
698
|
if (binding.kind === "module") {
|
581
699
|
const decl = binding.path.parent;
|
582
|
-
if (MARKO_FILE_REG.test(decl.source.value) && decl.specifiers.some((it) =>
|
700
|
+
if (MARKO_FILE_REG.test(decl.source.value) && decl.specifiers.some((it) => import_compiler5.types.isImportDefaultSpecifier(it))) {
|
583
701
|
const resolvedImport = (0, import_babel_utils4.resolveTagImport)(name2, decl.source.value) || decl.source.value;
|
584
702
|
if (type === 0 /* NativeTag */ || tagNameImported && tagNameImported !== resolvedImport) {
|
585
703
|
type = 2 /* DynamicTag */;
|
@@ -633,7 +751,7 @@ function startSection(path5) {
|
|
633
751
|
const sectionNamePath = path5.parentPath?.get(
|
634
752
|
"name"
|
635
753
|
);
|
636
|
-
const sectionName = path5.isProgram() ? "" :
|
754
|
+
const sectionName = path5.isProgram() ? "" : generateUid(sectionNamePath.toString() + "_content");
|
637
755
|
const programExtra = path5.hub.file.path.node.extra ??= {};
|
638
756
|
const sections = programExtra.sections ??= [];
|
639
757
|
section = extra.section = {
|
@@ -682,19 +800,19 @@ function getSection(path5) {
|
|
682
800
|
}
|
683
801
|
var [getScopeIdIdentifier] = createSectionState(
|
684
802
|
"scopeIdIdentifier",
|
685
|
-
(section) =>
|
803
|
+
(section) => generateUidIdentifier(`scope${section.id}_id`)
|
686
804
|
);
|
687
805
|
var [getSectionParentIsOwner, setSectionParentIsOwner] = createSectionState("parentIsOwner", () => false);
|
688
806
|
var [_getScopeIdentifier] = createSectionState(
|
689
807
|
"scopeIdentifier",
|
690
|
-
() =>
|
808
|
+
() => import_compiler6.types.identifier("undefined")
|
691
809
|
);
|
692
810
|
function forEachSection(fn) {
|
693
|
-
const { sections } = (0,
|
811
|
+
const { sections } = (0, import_compiler6.getProgram)().node.extra;
|
694
812
|
sections?.forEach(fn);
|
695
813
|
}
|
696
814
|
function forEachSectionReverse(fn) {
|
697
|
-
const { sections } = (0,
|
815
|
+
const { sections } = (0, import_compiler6.getProgram)().node.extra;
|
698
816
|
for (let i = sections.length; i--; ) {
|
699
817
|
fn(sections[i]);
|
700
818
|
}
|
@@ -757,7 +875,7 @@ function getNodeContentType(path5, extraMember, contentInfo) {
|
|
757
875
|
return 3 /* Tag */;
|
758
876
|
} else if ((0, import_babel_utils5.isAttributeTag)(tag)) {
|
759
877
|
return null;
|
760
|
-
} else if (
|
878
|
+
} else if (import_compiler6.types.isStringLiteral(tag.node.name)) {
|
761
879
|
const tagSection = (0, import_babel_utils5.loadFileForTag)(tag)?.ast.program.extra.section;
|
762
880
|
if (tagSection) {
|
763
881
|
if (tagSection.content) {
|
@@ -849,21 +967,6 @@ function getDynamicSourcesForBinding(binding) {
|
|
849
967
|
return true;
|
850
968
|
}
|
851
969
|
}
|
852
|
-
function getDynamicSourcesForReferences(referencedBindings) {
|
853
|
-
if (referencedBindings) {
|
854
|
-
let dynamicSources;
|
855
|
-
if (Array.isArray(referencedBindings)) {
|
856
|
-
for (const binding of referencedBindings) {
|
857
|
-
const newDynamicSources = getDynamicSourcesForBinding(binding);
|
858
|
-
if (newDynamicSources === true) return true;
|
859
|
-
dynamicSources = bindingUtil.union(dynamicSources, newDynamicSources);
|
860
|
-
}
|
861
|
-
return dynamicSources;
|
862
|
-
} else {
|
863
|
-
return getDynamicSourcesForBinding(referencedBindings);
|
864
|
-
}
|
865
|
-
}
|
866
|
-
}
|
867
970
|
function getDynamicSourcesForExtra(extra) {
|
868
971
|
if (isReferencedExtra(extra)) {
|
869
972
|
return getDynamicSourcesForReferences(extra.referencedBindings);
|
@@ -920,6 +1023,21 @@ function getDynamicSourcesForSections(sections) {
|
|
920
1023
|
}
|
921
1024
|
return merged || first;
|
922
1025
|
}
|
1026
|
+
function getDynamicSourcesForReferences(referencedBindings) {
|
1027
|
+
if (referencedBindings) {
|
1028
|
+
let dynamicSources;
|
1029
|
+
if (Array.isArray(referencedBindings)) {
|
1030
|
+
for (const binding of referencedBindings) {
|
1031
|
+
const newDynamicSources = getDynamicSourcesForBinding(binding);
|
1032
|
+
if (newDynamicSources === true) return true;
|
1033
|
+
dynamicSources = bindingUtil.union(dynamicSources, newDynamicSources);
|
1034
|
+
}
|
1035
|
+
return dynamicSources;
|
1036
|
+
} else {
|
1037
|
+
return getDynamicSourcesForBinding(referencedBindings);
|
1038
|
+
}
|
1039
|
+
}
|
1040
|
+
}
|
923
1041
|
function mergeDynamicSources(a, b) {
|
924
1042
|
if (a === true || b === true) return true;
|
925
1043
|
return bindingUtil.union(a, b);
|
@@ -1001,7 +1119,7 @@ var AccessorProp2 = /* @__PURE__ */ ((AccessorProp3) => {
|
|
1001
1119
|
})(AccessorProp2 || {});
|
1002
1120
|
|
1003
1121
|
// src/translator/util/marko-config.ts
|
1004
|
-
var
|
1122
|
+
var import_compiler8 = require("@marko/compiler");
|
1005
1123
|
function isOutputHTML() {
|
1006
1124
|
return getMarkoOpts().output === "html";
|
1007
1125
|
}
|
@@ -1009,7 +1127,7 @@ function isOutputDOM() {
|
|
1009
1127
|
return !isOutputHTML();
|
1010
1128
|
}
|
1011
1129
|
function getMarkoOpts() {
|
1012
|
-
return (0,
|
1130
|
+
return (0, import_compiler8.getFile)().markoOpts;
|
1013
1131
|
}
|
1014
1132
|
function isOptimize() {
|
1015
1133
|
return getMarkoOpts().optimize;
|
@@ -1084,7 +1202,7 @@ function isFunction(path5) {
|
|
1084
1202
|
}
|
1085
1203
|
|
1086
1204
|
// src/translator/util/is-invoked-function.ts
|
1087
|
-
var
|
1205
|
+
var import_compiler9 = require("@marko/compiler");
|
1088
1206
|
function isInvokedFunction(expr) {
|
1089
1207
|
let curPath = expr;
|
1090
1208
|
while (curPath) {
|
@@ -1103,10 +1221,10 @@ function isInvokedFunction(expr) {
|
|
1103
1221
|
}
|
1104
1222
|
|
1105
1223
|
// src/translator/util/scope-read.ts
|
1106
|
-
var
|
1224
|
+
var import_compiler25 = require("@marko/compiler");
|
1107
1225
|
|
1108
1226
|
// src/translator/visitors/program/index.ts
|
1109
|
-
var
|
1227
|
+
var import_compiler24 = require("@marko/compiler");
|
1110
1228
|
var import_babel_utils11 = require("@marko/compiler/babel-utils");
|
1111
1229
|
var import_path2 = __toESM(require("path"));
|
1112
1230
|
|
@@ -1123,7 +1241,7 @@ function bindingHasDownstreamExpressions(binding) {
|
|
1123
1241
|
}
|
1124
1242
|
|
1125
1243
|
// src/translator/util/entry-builder.ts
|
1126
|
-
var
|
1244
|
+
var import_compiler10 = require("@marko/compiler");
|
1127
1245
|
var import_babel_utils6 = require("@marko/compiler/babel-utils");
|
1128
1246
|
var kState = Symbol();
|
1129
1247
|
var entry_builder_default = {
|
@@ -1135,19 +1253,19 @@ var entry_builder_default = {
|
|
1135
1253
|
);
|
1136
1254
|
}
|
1137
1255
|
const body = state.imports.map(
|
1138
|
-
(it) =>
|
1256
|
+
(it) => import_compiler10.types.importDeclaration([], import_compiler10.types.stringLiteral(it))
|
1139
1257
|
);
|
1140
1258
|
if (state.init) {
|
1141
1259
|
body.unshift(
|
1142
|
-
|
1143
|
-
[
|
1144
|
-
|
1260
|
+
import_compiler10.types.importDeclaration(
|
1261
|
+
[import_compiler10.types.importSpecifier(import_compiler10.types.identifier("init"), import_compiler10.types.identifier("init"))],
|
1262
|
+
import_compiler10.types.stringLiteral(
|
1145
1263
|
`${runtime_info_default.name}/${entryFile.markoOpts.optimize ? "" : "debug/"}dom`
|
1146
1264
|
)
|
1147
1265
|
)
|
1148
1266
|
);
|
1149
1267
|
body.push(
|
1150
|
-
|
1268
|
+
import_compiler10.types.expressionStatement(import_compiler10.types.callExpression(import_compiler10.types.identifier("init"), []))
|
1151
1269
|
);
|
1152
1270
|
}
|
1153
1271
|
return body;
|
@@ -1169,7 +1287,7 @@ var entry_builder_default = {
|
|
1169
1287
|
};
|
1170
1288
|
|
1171
1289
|
// src/translator/util/runtime.ts
|
1172
|
-
var
|
1290
|
+
var import_compiler12 = require("@marko/compiler");
|
1173
1291
|
var import_babel_utils7 = require("@marko/compiler/babel-utils");
|
1174
1292
|
|
1175
1293
|
// src/common/attr-tag.ts
|
@@ -1592,25 +1710,25 @@ var RENDER_BODY_ID = prefix + (false ? "renderBody" : "b");
|
|
1592
1710
|
var K_TAGS_API_STATE = Symbol();
|
1593
1711
|
|
1594
1712
|
// src/translator/util/to-property-name.ts
|
1595
|
-
var
|
1713
|
+
var import_compiler11 = require("@marko/compiler");
|
1596
1714
|
function isValidPropertyIdentifier(name2) {
|
1597
1715
|
return /^[a-z_$][a-z0-9_$]*$/i.test(name2);
|
1598
1716
|
}
|
1599
1717
|
function toPropertyName(name2) {
|
1600
1718
|
if (isValidPropertyIdentifier(name2)) {
|
1601
|
-
return
|
1719
|
+
return import_compiler11.types.identifier(name2);
|
1602
1720
|
} else if (/^(?:0|[1-9][0-9]*)$/.test(name2)) {
|
1603
|
-
return
|
1721
|
+
return import_compiler11.types.numericLiteral(parseInt(name2, 10));
|
1604
1722
|
}
|
1605
|
-
return
|
1723
|
+
return import_compiler11.types.stringLiteral(name2);
|
1606
1724
|
}
|
1607
1725
|
function toObjectProperty(name2, value) {
|
1608
|
-
return
|
1726
|
+
return import_compiler11.types.objectProperty(toPropertyName(name2), value);
|
1609
1727
|
}
|
1610
1728
|
function toMemberExpression(object, key, optional) {
|
1611
1729
|
const prop = toPropertyName(key);
|
1612
1730
|
const computed = prop.type !== "Identifier";
|
1613
|
-
return optional ?
|
1731
|
+
return optional ? import_compiler11.types.optionalMemberExpression(object, prop, computed, true) : import_compiler11.types.memberExpression(object, prop, computed);
|
1614
1732
|
}
|
1615
1733
|
|
1616
1734
|
// src/translator/util/runtime.ts
|
@@ -1636,12 +1754,12 @@ var pureDOMFunctions = /* @__PURE__ */ new Set([
|
|
1636
1754
|
function importRuntime(name2) {
|
1637
1755
|
const { output } = getMarkoOpts();
|
1638
1756
|
return toMemberExpression(
|
1639
|
-
(0, import_babel_utils7.importStar)((0,
|
1757
|
+
(0, import_babel_utils7.importStar)((0, import_compiler12.getFile)(), getRuntimePath(output), "$"),
|
1640
1758
|
name2
|
1641
1759
|
);
|
1642
1760
|
}
|
1643
1761
|
function callRuntime(name2, ...args) {
|
1644
|
-
const callExpression2 =
|
1762
|
+
const callExpression2 = import_compiler12.types.callExpression(
|
1645
1763
|
importRuntime(name2),
|
1646
1764
|
filterArguments(args)
|
1647
1765
|
);
|
@@ -1675,7 +1793,7 @@ function filterArguments(args) {
|
|
1675
1793
|
for (let i = args.length; i--; ) {
|
1676
1794
|
const arg = args[i];
|
1677
1795
|
if (arg || filteredArgs.length) {
|
1678
|
-
filteredArgs[i] = arg ||
|
1796
|
+
filteredArgs[i] = arg || import_compiler12.types.unaryExpression("void", import_compiler12.types.numericLiteral(0));
|
1679
1797
|
}
|
1680
1798
|
}
|
1681
1799
|
return filteredArgs;
|
@@ -1686,7 +1804,7 @@ function getCompatRuntimeFile() {
|
|
1686
1804
|
}
|
1687
1805
|
|
1688
1806
|
// src/translator/visitors/program/dom.ts
|
1689
|
-
var
|
1807
|
+
var import_compiler22 = require("@marko/compiler");
|
1690
1808
|
var import_babel_utils10 = require("@marko/compiler/babel-utils");
|
1691
1809
|
|
1692
1810
|
// src/translator/util/get-style-file.ts
|
@@ -1726,11 +1844,11 @@ function escapeRegExp(str) {
|
|
1726
1844
|
}
|
1727
1845
|
|
1728
1846
|
// src/translator/util/signals.ts
|
1729
|
-
var
|
1847
|
+
var import_compiler21 = require("@marko/compiler");
|
1730
1848
|
var import_babel_utils9 = require("@marko/compiler/babel-utils");
|
1731
1849
|
|
1732
1850
|
// src/translator/core/return.ts
|
1733
|
-
var
|
1851
|
+
var import_compiler17 = require("@marko/compiler");
|
1734
1852
|
var import_babel_utils8 = require("@marko/compiler/babel-utils");
|
1735
1853
|
|
1736
1854
|
// src/translator/util/get-known-attr-values.ts
|
@@ -1753,7 +1871,7 @@ function getParentTag(tag) {
|
|
1753
1871
|
}
|
1754
1872
|
|
1755
1873
|
// src/translator/util/plugin-hooks.ts
|
1756
|
-
var
|
1874
|
+
var import_compiler13 = require("@marko/compiler");
|
1757
1875
|
function enter(modulePlugin, path5) {
|
1758
1876
|
if (!modulePlugin) {
|
1759
1877
|
return false;
|
@@ -1761,9 +1879,9 @@ function enter(modulePlugin, path5) {
|
|
1761
1879
|
const { node } = path5;
|
1762
1880
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
1763
1881
|
if (isFunctionPlugin(plugin)) {
|
1764
|
-
plugin(path5,
|
1882
|
+
plugin(path5, import_compiler13.types);
|
1765
1883
|
} else if (plugin.enter) {
|
1766
|
-
plugin.enter(path5,
|
1884
|
+
plugin.enter(path5, import_compiler13.types);
|
1767
1885
|
}
|
1768
1886
|
return node !== path5.node;
|
1769
1887
|
}
|
@@ -1774,7 +1892,7 @@ function exit(modulePlugin, path5) {
|
|
1774
1892
|
const { node } = path5;
|
1775
1893
|
const plugin = isModulePlugin(modulePlugin) ? modulePlugin.default : modulePlugin;
|
1776
1894
|
if (!isFunctionPlugin(plugin) && plugin.exit) {
|
1777
|
-
plugin.exit(path5,
|
1895
|
+
plugin.exit(path5, import_compiler13.types);
|
1778
1896
|
}
|
1779
1897
|
return node !== path5.node;
|
1780
1898
|
}
|
@@ -1818,10 +1936,10 @@ function translateByTarget({
|
|
1818
1936
|
}
|
1819
1937
|
|
1820
1938
|
// src/translator/util/writer.ts
|
1821
|
-
var
|
1939
|
+
var import_compiler16 = require("@marko/compiler");
|
1822
1940
|
|
1823
1941
|
// src/translator/util/normalize-string-expression.ts
|
1824
|
-
var
|
1942
|
+
var import_compiler14 = require("@marko/compiler");
|
1825
1943
|
function normalizeStringExpression(parts) {
|
1826
1944
|
const strs = [];
|
1827
1945
|
const exprs = [];
|
@@ -1829,9 +1947,9 @@ function normalizeStringExpression(parts) {
|
|
1829
1947
|
for (let i = 1; i < parts.length; i++) {
|
1830
1948
|
let content = parts[i];
|
1831
1949
|
if (typeof content === "object") {
|
1832
|
-
if (
|
1950
|
+
if (import_compiler14.types.isStringLiteral(content)) {
|
1833
1951
|
content = content.value;
|
1834
|
-
} else if (
|
1952
|
+
} else if (import_compiler14.types.isTemplateLiteral(content)) {
|
1835
1953
|
let nextIndex = i + 1;
|
1836
1954
|
const exprLen = content.expressions.length;
|
1837
1955
|
shiftItems(parts, nextIndex, content.quasis.length + exprLen);
|
@@ -1855,12 +1973,12 @@ function normalizeStringExpression(parts) {
|
|
1855
1973
|
return exprs[0];
|
1856
1974
|
}
|
1857
1975
|
strs.push(curStr);
|
1858
|
-
return
|
1859
|
-
strs.map((raw) =>
|
1976
|
+
return import_compiler14.types.templateLiteral(
|
1977
|
+
strs.map((raw) => import_compiler14.types.templateElement({ raw })),
|
1860
1978
|
exprs
|
1861
1979
|
);
|
1862
1980
|
} else if (curStr) {
|
1863
|
-
return
|
1981
|
+
return import_compiler14.types.stringLiteral(curStr);
|
1864
1982
|
}
|
1865
1983
|
}
|
1866
1984
|
function appendLiteral(arr, str) {
|
@@ -1873,7 +1991,7 @@ function shiftItems(list, start, offset) {
|
|
1873
1991
|
}
|
1874
1992
|
|
1875
1993
|
// src/translator/util/walks.ts
|
1876
|
-
var
|
1994
|
+
var import_compiler15 = require("@marko/compiler");
|
1877
1995
|
var [getWalks] = createSectionState(
|
1878
1996
|
"walks",
|
1879
1997
|
() => [""]
|
@@ -2052,16 +2170,16 @@ function consumeHTML(path5) {
|
|
2052
2170
|
trailers.length = 0;
|
2053
2171
|
trailers[0] = "";
|
2054
2172
|
if (writeResult && trailerResult) {
|
2055
|
-
return
|
2056
|
-
|
2173
|
+
return import_compiler16.types.expressionStatement(
|
2174
|
+
import_compiler16.types.sequenceExpression([
|
2057
2175
|
callRuntime("write", writeResult),
|
2058
2176
|
callRuntime("writeTrailers", trailerResult)
|
2059
2177
|
])
|
2060
2178
|
);
|
2061
2179
|
} else if (writeResult) {
|
2062
|
-
return
|
2180
|
+
return import_compiler16.types.expressionStatement(callRuntime("write", writeResult));
|
2063
2181
|
} else if (trailerResult) {
|
2064
|
-
return
|
2182
|
+
return import_compiler16.types.expressionStatement(callRuntime("writeTrailers", trailerResult));
|
2065
2183
|
}
|
2066
2184
|
}
|
2067
2185
|
function flushBefore(path5) {
|
@@ -2152,11 +2270,11 @@ var return_default = {
|
|
2152
2270
|
);
|
2153
2271
|
}
|
2154
2272
|
if (attrs2.value) {
|
2155
|
-
const returnId =
|
2273
|
+
const returnId = generateUidIdentifier("return");
|
2156
2274
|
setReturnValueIdentifier(section, returnId);
|
2157
2275
|
tag.replaceWith(
|
2158
|
-
|
2159
|
-
|
2276
|
+
import_compiler17.types.variableDeclaration("const", [
|
2277
|
+
import_compiler17.types.variableDeclarator(returnId, attrs2.value)
|
2160
2278
|
])
|
2161
2279
|
)[0].skip();
|
2162
2280
|
}
|
@@ -2206,10 +2324,10 @@ var return_default = {
|
|
2206
2324
|
};
|
2207
2325
|
|
2208
2326
|
// src/translator/util/get-defined-binding-expression.ts
|
2209
|
-
var
|
2327
|
+
var import_compiler18 = require("@marko/compiler");
|
2210
2328
|
function getDeclaredBindingExpression(binding) {
|
2211
2329
|
if (binding.declared || !binding.upstreamAlias) {
|
2212
|
-
return
|
2330
|
+
return import_compiler18.types.identifier(binding.name);
|
2213
2331
|
} else if (binding.property !== void 0) {
|
2214
2332
|
return toMemberExpression(
|
2215
2333
|
getDeclaredBindingExpression(binding.upstreamAlias),
|
@@ -2222,7 +2340,7 @@ function getDeclaredBindingExpression(binding) {
|
|
2222
2340
|
}
|
2223
2341
|
|
2224
2342
|
// src/translator/util/simplify-fn.ts
|
2225
|
-
var
|
2343
|
+
var import_compiler19 = require("@marko/compiler");
|
2226
2344
|
function simplifyFunction(fn) {
|
2227
2345
|
switch (fn.type) {
|
2228
2346
|
case "FunctionDeclaration":
|
@@ -2230,7 +2348,7 @@ function simplifyFunction(fn) {
|
|
2230
2348
|
case "ArrowFunctionExpression":
|
2231
2349
|
return fn;
|
2232
2350
|
default:
|
2233
|
-
return
|
2351
|
+
return import_compiler19.types.functionExpression(
|
2234
2352
|
null,
|
2235
2353
|
fn.params,
|
2236
2354
|
fn.body,
|
@@ -2241,9 +2359,9 @@ function simplifyFunction(fn) {
|
|
2241
2359
|
}
|
2242
2360
|
|
2243
2361
|
// src/translator/util/to-first-expression-or-block.ts
|
2244
|
-
var
|
2362
|
+
var import_compiler20 = require("@marko/compiler");
|
2245
2363
|
function toFirstExpressionOrBlock(stmts) {
|
2246
|
-
if (stmts.length === 1 &&
|
2364
|
+
if (stmts.length === 1 && import_compiler20.types.isExpressionStatement(stmts[0])) {
|
2247
2365
|
const { expression } = stmts[0];
|
2248
2366
|
switch (expression.type) {
|
2249
2367
|
case "ObjectExpression":
|
@@ -2253,63 +2371,18 @@ function toFirstExpressionOrBlock(stmts) {
|
|
2253
2371
|
return expression;
|
2254
2372
|
}
|
2255
2373
|
}
|
2256
|
-
return
|
2374
|
+
return import_compiler20.types.blockStatement(stmts);
|
2257
2375
|
}
|
2258
2376
|
function toParenthesizedExpressionIfNeeded(expr) {
|
2259
2377
|
switch (expr.type) {
|
2260
2378
|
case "ObjectExpression":
|
2261
2379
|
case "AssignmentExpression":
|
2262
|
-
return
|
2380
|
+
return import_compiler20.types.parenthesizedExpression(expr);
|
2263
2381
|
default:
|
2264
2382
|
return expr;
|
2265
2383
|
}
|
2266
2384
|
}
|
2267
2385
|
|
2268
|
-
// src/translator/util/traverse.ts
|
2269
|
-
var import_compiler19 = require("@marko/compiler");
|
2270
|
-
var skip = Symbol("skip");
|
2271
|
-
function traverseReplace(container, key, enter3) {
|
2272
|
-
const node = container[key];
|
2273
|
-
if (node) {
|
2274
|
-
if (Array.isArray(node)) {
|
2275
|
-
for (let i = node.length; i--; ) {
|
2276
|
-
traverseReplace(node, i, enter3);
|
2277
|
-
}
|
2278
|
-
} else {
|
2279
|
-
const keys = import_compiler19.types.VISITOR_KEYS[node.type];
|
2280
|
-
for (let i = keys.length; i--; ) {
|
2281
|
-
traverseReplace(node, keys[i], enter3);
|
2282
|
-
}
|
2283
|
-
const replacement = enter3(node, container, key);
|
2284
|
-
if (replacement) container[key] = replacement;
|
2285
|
-
}
|
2286
|
-
}
|
2287
|
-
}
|
2288
|
-
function traverseContains(node, check) {
|
2289
|
-
if (node) {
|
2290
|
-
if (Array.isArray(node)) {
|
2291
|
-
for (const item of node) {
|
2292
|
-
if (traverseContains(item, check)) {
|
2293
|
-
return true;
|
2294
|
-
}
|
2295
|
-
}
|
2296
|
-
} else {
|
2297
|
-
switch (check(node)) {
|
2298
|
-
case true:
|
2299
|
-
return true;
|
2300
|
-
case skip:
|
2301
|
-
return false;
|
2302
|
-
}
|
2303
|
-
for (const key of import_compiler19.types.VISITOR_KEYS[node.type]) {
|
2304
|
-
if (traverseContains(node[key], check)) {
|
2305
|
-
return true;
|
2306
|
-
}
|
2307
|
-
}
|
2308
|
-
}
|
2309
|
-
}
|
2310
|
-
return false;
|
2311
|
-
}
|
2312
|
-
|
2313
2386
|
// src/translator/util/signals.ts
|
2314
2387
|
var [getSignals] = createSectionState(
|
2315
2388
|
"signals",
|
@@ -2362,27 +2435,23 @@ function getHoistFunctionIdentifier(hoistedBinding) {
|
|
2362
2435
|
if (!identifier) {
|
2363
2436
|
idsMap.set(
|
2364
2437
|
hoistedBinding,
|
2365
|
-
identifier = (
|
2366
|
-
`get${hoistedBinding.name}`
|
2367
|
-
)
|
2438
|
+
identifier = generateUidIdentifier(`get${hoistedBinding.name}`)
|
2368
2439
|
);
|
2369
2440
|
}
|
2370
2441
|
return identifier;
|
2371
2442
|
}
|
2372
2443
|
var unimplementedBuild = () => {
|
2373
|
-
return
|
2444
|
+
return import_compiler21.types.stringLiteral("SIGNAL NOT INITIALIZED");
|
2374
2445
|
};
|
2375
2446
|
function getSignal(section, referencedBindings, name2 = generateSignalName(referencedBindings)) {
|
2376
2447
|
const signals = getSignals(section);
|
2377
2448
|
let signal = signals.get(referencedBindings);
|
2378
2449
|
if (!signal) {
|
2379
|
-
const exportName = referencedBindings ? !Array.isArray(referencedBindings) && referencedBindings.section === section && referencedBindings.export : !section.parent && (0,
|
2450
|
+
const exportName = referencedBindings ? !Array.isArray(referencedBindings) && referencedBindings.section === section && referencedBindings.export : !section.parent && (0, import_compiler21.getProgram)().node.extra.domExports?.setup;
|
2380
2451
|
signals.set(
|
2381
2452
|
referencedBindings,
|
2382
2453
|
signal = {
|
2383
|
-
identifier: exportName ?
|
2384
|
-
name2 + section.name.replace("_", "$")
|
2385
|
-
),
|
2454
|
+
identifier: exportName ? import_compiler21.types.identifier(exportName) : generateUidIdentifier(name2 + section.name.replace("_", "$")),
|
2386
2455
|
referencedBindings,
|
2387
2456
|
section,
|
2388
2457
|
values: [],
|
@@ -2437,9 +2506,9 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
2437
2506
|
const { id, scopeOffset } = intersectionMeta.get(referencedBindings);
|
2438
2507
|
return callRuntime(
|
2439
2508
|
"intersection",
|
2440
|
-
|
2509
|
+
import_compiler21.types.numericLiteral(id),
|
2441
2510
|
getSignalFn(signal),
|
2442
|
-
scopeOffset || referencedBindings.length > 2 ?
|
2511
|
+
scopeOffset || referencedBindings.length > 2 ? import_compiler21.types.numericLiteral(referencedBindings.length - 1) : void 0,
|
2443
2512
|
scopeOffset && getScopeAccessorLiteral(scopeOffset)
|
2444
2513
|
);
|
2445
2514
|
};
|
@@ -2451,7 +2520,7 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
2451
2520
|
"dynamicClosureRead",
|
2452
2521
|
getScopeAccessorLiteral(referencedBindings),
|
2453
2522
|
render,
|
2454
|
-
isImmediateOwner(section, referencedBindings) ? void 0 :
|
2523
|
+
isImmediateOwner(section, referencedBindings) ? void 0 : import_compiler21.types.arrowFunctionExpression(
|
2455
2524
|
[scopeIdentifier],
|
2456
2525
|
getScopeExpression(section, referencedBindings.section)
|
2457
2526
|
)
|
@@ -2468,7 +2537,7 @@ function initValue(binding, runtimeHelper = "value") {
|
|
2468
2537
|
const fn = getSignalFn(signal);
|
2469
2538
|
const isParamBinding = !binding.upstreamAlias && (binding.type === 3 /* param */ || binding.type === 2 /* input */);
|
2470
2539
|
const isNakedAlias = binding.upstreamAlias && !binding.property;
|
2471
|
-
const needsGuard = !isNakedAlias && (binding.downstreamExpressions.size || fn.body.body.length > 0);
|
2540
|
+
const needsGuard = !isNakedAlias && (binding.downstreamExpressions.size || fn.type === "ArrowFunctionExpression" && fn.body.body.length > 0);
|
2472
2541
|
const needsCache = needsGuard || signal.intersection;
|
2473
2542
|
const needsMarks = isParamBinding || signal.intersection;
|
2474
2543
|
if (needsCache || needsMarks || binding.hoists.size) {
|
@@ -2497,8 +2566,9 @@ function getSignalFn(signal) {
|
|
2497
2566
|
const isIntersection = Array.isArray(binding);
|
2498
2567
|
const isBinding = binding && !isIntersection;
|
2499
2568
|
const isValue = isBinding && binding.section === section;
|
2569
|
+
let canUseCalleeDirectly = !signal.render.length;
|
2500
2570
|
if (isBinding && (signal.renderReferencedBindings || binding.aliases.size || binding.propertyAliases.size)) {
|
2501
|
-
const valueParam =
|
2571
|
+
const valueParam = import_compiler21.types.identifier(binding.name);
|
2502
2572
|
if (binding.loc) {
|
2503
2573
|
valueParam.loc = binding.loc;
|
2504
2574
|
valueParam.start = binding.loc.start.index;
|
@@ -2510,10 +2580,10 @@ function getSignalFn(signal) {
|
|
2510
2580
|
for (const alias of binding.aliases) {
|
2511
2581
|
const aliasSignal = getSignal(alias.section, alias);
|
2512
2582
|
signal.render.push(
|
2513
|
-
|
2514
|
-
|
2583
|
+
import_compiler21.types.expressionStatement(
|
2584
|
+
import_compiler21.types.callExpression(aliasSignal.identifier, [
|
2515
2585
|
scopeIdentifier,
|
2516
|
-
|
2586
|
+
import_compiler21.types.identifier(binding.name),
|
2517
2587
|
...getTranslatedExtraArgs(aliasSignal)
|
2518
2588
|
])
|
2519
2589
|
)
|
@@ -2522,11 +2592,11 @@ function getSignalFn(signal) {
|
|
2522
2592
|
for (const [key, alias] of binding.propertyAliases) {
|
2523
2593
|
const aliasSignal = getSignal(alias.section, alias);
|
2524
2594
|
signal.render.push(
|
2525
|
-
|
2526
|
-
|
2595
|
+
import_compiler21.types.expressionStatement(
|
2596
|
+
import_compiler21.types.callExpression(aliasSignal.identifier, [
|
2527
2597
|
scopeIdentifier,
|
2528
2598
|
toMemberExpression(
|
2529
|
-
|
2599
|
+
import_compiler21.types.identifier(binding.name),
|
2530
2600
|
key,
|
2531
2601
|
binding.nullable
|
2532
2602
|
),
|
@@ -2538,8 +2608,8 @@ function getSignalFn(signal) {
|
|
2538
2608
|
}
|
2539
2609
|
for (const value of signal.values) {
|
2540
2610
|
signal.render.push(
|
2541
|
-
|
2542
|
-
|
2611
|
+
import_compiler21.types.expressionStatement(
|
2612
|
+
import_compiler21.types.callExpression(value.signal.identifier, [
|
2543
2613
|
value.scope,
|
2544
2614
|
value.value,
|
2545
2615
|
...getTranslatedExtraArgs(value.signal)
|
@@ -2549,7 +2619,7 @@ function getSignalFn(signal) {
|
|
2549
2619
|
}
|
2550
2620
|
forEach(signal.intersection, (intersection) => {
|
2551
2621
|
signal.render.push(
|
2552
|
-
|
2622
|
+
import_compiler21.types.expressionStatement(import_compiler21.types.callExpression(intersection, [scopeIdentifier]))
|
2553
2623
|
);
|
2554
2624
|
});
|
2555
2625
|
if (isValue) {
|
@@ -2560,12 +2630,12 @@ function getSignalFn(signal) {
|
|
2560
2630
|
if (isDynamicClosure(closureSection, binding)) {
|
2561
2631
|
if (!dynamicClosureArgs) {
|
2562
2632
|
dynamicClosureArgs = [];
|
2563
|
-
dynamicClosureSignalIdentifier =
|
2633
|
+
dynamicClosureSignalIdentifier = generateUidIdentifier(
|
2564
2634
|
signal.identifier.name + "_closure"
|
2565
2635
|
);
|
2566
2636
|
signal.render.push(
|
2567
|
-
|
2568
|
-
|
2637
|
+
import_compiler21.types.expressionStatement(
|
2638
|
+
import_compiler21.types.callExpression(dynamicClosureSignalIdentifier, [
|
2569
2639
|
scopeIdentifier
|
2570
2640
|
])
|
2571
2641
|
)
|
@@ -2576,8 +2646,8 @@ function getSignalFn(signal) {
|
|
2576
2646
|
);
|
2577
2647
|
} else {
|
2578
2648
|
signal.render.push(
|
2579
|
-
|
2580
|
-
|
2649
|
+
import_compiler21.types.expressionStatement(
|
2650
|
+
import_compiler21.types.callExpression(getSignal(closureSection, binding).identifier, [
|
2581
2651
|
scopeIdentifier
|
2582
2652
|
])
|
2583
2653
|
)
|
@@ -2587,8 +2657,8 @@ function getSignalFn(signal) {
|
|
2587
2657
|
});
|
2588
2658
|
if (dynamicClosureSignalIdentifier) {
|
2589
2659
|
(signal.prependStatements ||= []).push(
|
2590
|
-
|
2591
|
-
|
2660
|
+
import_compiler21.types.variableDeclaration("const", [
|
2661
|
+
import_compiler21.types.variableDeclarator(
|
2592
2662
|
dynamicClosureSignalIdentifier,
|
2593
2663
|
callRuntime("dynamicClosure", ...dynamicClosureArgs)
|
2594
2664
|
)
|
@@ -2597,24 +2667,46 @@ function getSignalFn(signal) {
|
|
2597
2667
|
}
|
2598
2668
|
}
|
2599
2669
|
if (signal.effect.length) {
|
2600
|
-
const effectIdentifier =
|
2670
|
+
const effectIdentifier = import_compiler21.types.identifier(`${signal.identifier.name}_effect`);
|
2601
2671
|
signal.render.push(
|
2602
|
-
|
2603
|
-
|
2672
|
+
import_compiler21.types.expressionStatement(
|
2673
|
+
import_compiler21.types.callExpression(effectIdentifier, [scopeIdentifier])
|
2604
2674
|
)
|
2605
2675
|
);
|
2606
2676
|
}
|
2607
2677
|
if (isIntersection && signal.renderReferencedBindings) {
|
2608
2678
|
signal.render.unshift(
|
2609
|
-
|
2610
|
-
|
2679
|
+
import_compiler21.types.variableDeclaration("const", [
|
2680
|
+
import_compiler21.types.variableDeclarator(
|
2611
2681
|
createScopeReadPattern(section, signal.renderReferencedBindings),
|
2612
2682
|
scopeIdentifier
|
2613
2683
|
)
|
2614
2684
|
])
|
2615
2685
|
);
|
2616
2686
|
}
|
2617
|
-
|
2687
|
+
if (canUseCalleeDirectly && signal.render.length === 1) {
|
2688
|
+
const render = signal.render[0];
|
2689
|
+
if (render.type === "ExpressionStatement") {
|
2690
|
+
const { expression } = render;
|
2691
|
+
if (expression.type === "CallExpression") {
|
2692
|
+
const args = expression.arguments;
|
2693
|
+
if (params.length >= args.length) {
|
2694
|
+
for (let i = args.length; i--; ) {
|
2695
|
+
const param = params[i];
|
2696
|
+
const arg = args[i];
|
2697
|
+
if (arg.type !== "Identifier" || param.name !== arg.name) {
|
2698
|
+
canUseCalleeDirectly = false;
|
2699
|
+
break;
|
2700
|
+
}
|
2701
|
+
}
|
2702
|
+
if (canUseCalleeDirectly) {
|
2703
|
+
return expression.callee;
|
2704
|
+
}
|
2705
|
+
}
|
2706
|
+
}
|
2707
|
+
}
|
2708
|
+
}
|
2709
|
+
return import_compiler21.types.arrowFunctionExpression(params, import_compiler21.types.blockStatement(signal.render));
|
2618
2710
|
}
|
2619
2711
|
var hasTranslatedExtraArgs = /* @__PURE__ */ new WeakSet();
|
2620
2712
|
var emptyExtraArgs = [];
|
@@ -2659,19 +2751,19 @@ function replaceNullishAndEmptyFunctionsWith0(args) {
|
|
2659
2751
|
for (let i = args.length; i--; ) {
|
2660
2752
|
const arg = args[i];
|
2661
2753
|
if (!arg) {
|
2662
|
-
args[i] =
|
2663
|
-
} else if (
|
2754
|
+
args[i] = import_compiler21.types.numericLiteral(0);
|
2755
|
+
} else if (import_compiler21.types.isArrowFunctionExpression(arg) && import_compiler21.types.isBlockStatement(arg.body)) {
|
2664
2756
|
const body = arg.body.body;
|
2665
2757
|
if (body.length === 0) {
|
2666
|
-
args[i] =
|
2667
|
-
} else if (body.length === 1 &&
|
2758
|
+
args[i] = import_compiler21.types.numericLiteral(0);
|
2759
|
+
} else if (body.length === 1 && import_compiler21.types.isExpressionStatement(body[0])) {
|
2668
2760
|
arg.body = toParenthesizedExpressionIfNeeded(body[0].expression);
|
2669
2761
|
}
|
2670
|
-
} else if (
|
2671
|
-
args[i] =
|
2762
|
+
} else if (import_compiler21.types.isNullLiteral(arg) || import_compiler21.types.isUnaryExpression(arg) && arg.operator === "void") {
|
2763
|
+
args[i] = import_compiler21.types.numericLiteral(0);
|
2672
2764
|
}
|
2673
2765
|
}
|
2674
|
-
for (let i = args.length - 1;
|
2766
|
+
for (let i = args.length - 1; import_compiler21.types.isNumericLiteral(args[i]) && args[i].value === 0; ) {
|
2675
2767
|
args.length = i--;
|
2676
2768
|
}
|
2677
2769
|
return args;
|
@@ -2720,7 +2812,7 @@ function getResumeRegisterId(section, referencedBindings, type) {
|
|
2720
2812
|
const {
|
2721
2813
|
markoOpts,
|
2722
2814
|
opts: { filename }
|
2723
|
-
} = (0,
|
2815
|
+
} = (0, import_compiler21.getFile)();
|
2724
2816
|
let name2 = "";
|
2725
2817
|
if (referencedBindings) {
|
2726
2818
|
if (typeof referencedBindings === "string") {
|
@@ -2744,7 +2836,7 @@ function getRegisterUID(section, name2) {
|
|
2744
2836
|
const {
|
2745
2837
|
markoOpts,
|
2746
2838
|
opts: { filename }
|
2747
|
-
} = (0,
|
2839
|
+
} = (0, import_compiler21.getFile)();
|
2748
2840
|
let used = usedRegisterIdsBySection.get(section);
|
2749
2841
|
if (!used) usedRegisterIdsBySection.set(section, used = /* @__PURE__ */ new Set());
|
2750
2842
|
const baseId = (0, import_babel_utils9.getTemplateId)(
|
@@ -2764,7 +2856,7 @@ function writeSignals(section) {
|
|
2764
2856
|
forEach(section.hoisted, (binding) => {
|
2765
2857
|
for (const hoistedBinding of binding.hoists.values()) {
|
2766
2858
|
const accessors = [
|
2767
|
-
binding.type === 0 /* dom */ ?
|
2859
|
+
binding.type === 0 /* dom */ ? import_compiler21.types.stringLiteral(
|
2768
2860
|
getAccessorPrefix().Getter + getScopeAccessor(binding)
|
2769
2861
|
) : getScopeAccessorLiteral(binding)
|
2770
2862
|
];
|
@@ -2777,13 +2869,13 @@ function writeSignals(section) {
|
|
2777
2869
|
currentSection = parentSection;
|
2778
2870
|
}
|
2779
2871
|
const hoistIdentifier = getHoistFunctionIdentifier(hoistedBinding);
|
2780
|
-
(0,
|
2781
|
-
|
2782
|
-
|
2872
|
+
(0, import_compiler21.getProgram)().node.body.push(
|
2873
|
+
import_compiler21.types.variableDeclaration("const", [
|
2874
|
+
import_compiler21.types.variableDeclarator(
|
2783
2875
|
hoistIdentifier,
|
2784
2876
|
hoistedBinding.downstreamExpressions.size ? callRuntime(
|
2785
2877
|
"register",
|
2786
|
-
|
2878
|
+
import_compiler21.types.stringLiteral(
|
2787
2879
|
getResumeRegisterId(
|
2788
2880
|
hoistedBinding.section,
|
2789
2881
|
hoistedBinding,
|
@@ -2800,7 +2892,7 @@ function writeSignals(section) {
|
|
2800
2892
|
hoistedBinding.section,
|
2801
2893
|
void 0,
|
2802
2894
|
initValue(hoistedBinding),
|
2803
|
-
|
2895
|
+
import_compiler21.types.callExpression(hoistIdentifier, [scopeIdentifier])
|
2804
2896
|
);
|
2805
2897
|
}
|
2806
2898
|
}
|
@@ -2814,20 +2906,20 @@ function writeSignals(section) {
|
|
2814
2906
|
let effectDeclarator;
|
2815
2907
|
if (signal.effect.length) {
|
2816
2908
|
traverseReplace(signal, "effect", replaceEffectNode);
|
2817
|
-
const effectIdentifier =
|
2909
|
+
const effectIdentifier = import_compiler21.types.identifier(`${signal.identifier.name}_effect`);
|
2818
2910
|
const referencedBindings = signal.effectReferencedBindings;
|
2819
2911
|
const referencesScope = traverseContains(
|
2820
2912
|
signal.effect,
|
2821
2913
|
isScopeIdentifier
|
2822
2914
|
);
|
2823
|
-
effectDeclarator =
|
2915
|
+
effectDeclarator = import_compiler21.types.variableDeclarator(
|
2824
2916
|
effectIdentifier,
|
2825
2917
|
callRuntime(
|
2826
2918
|
"effect",
|
2827
|
-
|
2919
|
+
import_compiler21.types.stringLiteral(
|
2828
2920
|
getResumeRegisterId(section, signal.referencedBindings)
|
2829
2921
|
),
|
2830
|
-
|
2922
|
+
import_compiler21.types.arrowFunctionExpression(
|
2831
2923
|
referencedBindings ? referencesScope ? [
|
2832
2924
|
scopeIdentifier,
|
2833
2925
|
createScopeReadPattern(section, referencedBindings)
|
@@ -2838,44 +2930,44 @@ function writeSignals(section) {
|
|
2838
2930
|
);
|
2839
2931
|
}
|
2840
2932
|
let value = signal.build();
|
2841
|
-
if (
|
2933
|
+
if (import_compiler21.types.isCallExpression(value)) {
|
2842
2934
|
replaceNullishAndEmptyFunctionsWith0(value.arguments);
|
2843
2935
|
}
|
2844
2936
|
if (signal.register) {
|
2845
2937
|
value = callRuntime(
|
2846
2938
|
"registerBoundSignal",
|
2847
|
-
|
2939
|
+
import_compiler21.types.stringLiteral(
|
2848
2940
|
getResumeRegisterId(section, signal.referencedBindings, "var")
|
2849
2941
|
),
|
2850
2942
|
value
|
2851
2943
|
);
|
2852
2944
|
}
|
2853
|
-
const signalDeclarator =
|
2854
|
-
let signalDeclaration = !section.parent && !signal.referencedBindings && (
|
2945
|
+
const signalDeclarator = import_compiler21.types.variableDeclarator(signal.identifier, value);
|
2946
|
+
let signalDeclaration = !section.parent && !signal.referencedBindings && (import_compiler21.types.isFunctionExpression(value) || import_compiler21.types.isArrowFunctionExpression(value)) ? import_compiler21.types.functionDeclaration(
|
2855
2947
|
signal.identifier,
|
2856
2948
|
value.params,
|
2857
|
-
|
2858
|
-
) :
|
2949
|
+
import_compiler21.types.isExpression(value.body) ? import_compiler21.types.blockStatement([import_compiler21.types.expressionStatement(value.body)]) : value.body
|
2950
|
+
) : import_compiler21.types.variableDeclaration("const", [signalDeclarator]);
|
2859
2951
|
if (signal.export) {
|
2860
|
-
signalDeclaration =
|
2952
|
+
signalDeclaration = import_compiler21.types.exportNamedDeclaration(signalDeclaration);
|
2861
2953
|
}
|
2862
2954
|
const signalStatements = signal.prependStatements || [];
|
2863
2955
|
if (effectDeclarator) {
|
2864
|
-
signalStatements.push(
|
2956
|
+
signalStatements.push(import_compiler21.types.variableDeclaration("const", [effectDeclarator]));
|
2865
2957
|
}
|
2866
2958
|
signalStatements.push(signalDeclaration);
|
2867
|
-
(0,
|
2959
|
+
(0, import_compiler21.getProgram)().node.body.push(...signalStatements);
|
2868
2960
|
}
|
2869
2961
|
}
|
2870
2962
|
function writeRegisteredFns() {
|
2871
|
-
const registeredFns = registeredFnsForProgram.get((0,
|
2963
|
+
const registeredFns = registeredFnsForProgram.get((0, import_compiler21.getProgram)().node);
|
2872
2964
|
const statements = [];
|
2873
2965
|
if (registeredFns) {
|
2874
2966
|
for (const registeredFn of registeredFns) {
|
2875
2967
|
let fn;
|
2876
2968
|
const params = registeredFn.referencedBindings ? registeredFn.referencesScope ? [
|
2877
2969
|
scopeIdentifier,
|
2878
|
-
|
2970
|
+
import_compiler21.types.assignmentPattern(
|
2879
2971
|
createScopeReadPattern(
|
2880
2972
|
registeredFn.section,
|
2881
2973
|
registeredFn.referencedBindings
|
@@ -2889,18 +2981,18 @@ function writeRegisteredFns() {
|
|
2889
2981
|
)
|
2890
2982
|
] : registeredFn.referencesScope ? [scopeIdentifier] : void 0;
|
2891
2983
|
if (params) {
|
2892
|
-
fn =
|
2893
|
-
|
2984
|
+
fn = import_compiler21.types.functionDeclaration(
|
2985
|
+
import_compiler21.types.identifier(registeredFn.id),
|
2894
2986
|
params,
|
2895
|
-
|
2987
|
+
import_compiler21.types.blockStatement(toReturnedFunction(registeredFn.node))
|
2896
2988
|
);
|
2897
2989
|
} else if (registeredFn.node.type === "FunctionDeclaration" && registeredFn.node.id?.name === registeredFn.id) {
|
2898
2990
|
fn = registeredFn.node;
|
2899
2991
|
} else {
|
2900
|
-
fn =
|
2901
|
-
|
2992
|
+
fn = import_compiler21.types.functionDeclaration(
|
2993
|
+
import_compiler21.types.identifier(registeredFn.id),
|
2902
2994
|
registeredFn.node.params,
|
2903
|
-
registeredFn.node.body.type === "BlockStatement" ? registeredFn.node.body :
|
2995
|
+
registeredFn.node.body.type === "BlockStatement" ? registeredFn.node.body : import_compiler21.types.blockStatement([import_compiler21.types.returnStatement(registeredFn.node.body)]),
|
2904
2996
|
registeredFn.node.generator,
|
2905
2997
|
registeredFn.node.async
|
2906
2998
|
);
|
@@ -2909,21 +3001,21 @@ function writeRegisteredFns() {
|
|
2909
3001
|
}
|
2910
3002
|
for (const registeredFn of registeredFns) {
|
2911
3003
|
statements.push(
|
2912
|
-
|
3004
|
+
import_compiler21.types.expressionStatement(
|
2913
3005
|
callRuntime(
|
2914
3006
|
"register",
|
2915
|
-
|
2916
|
-
|
3007
|
+
import_compiler21.types.stringLiteral(registeredFn.registerId),
|
3008
|
+
import_compiler21.types.identifier(registeredFn.id)
|
2917
3009
|
)
|
2918
3010
|
)
|
2919
3011
|
);
|
2920
3012
|
}
|
2921
|
-
(0,
|
3013
|
+
(0, import_compiler21.getProgram)().node.body.push(...statements);
|
2922
3014
|
}
|
2923
3015
|
}
|
2924
3016
|
function toReturnedFunction(rawFn) {
|
2925
3017
|
const fn = simplifyFunction(rawFn);
|
2926
|
-
return fn.type === "FunctionDeclaration" ? [fn,
|
3018
|
+
return fn.type === "FunctionDeclaration" ? [fn, import_compiler21.types.returnStatement(fn.id)] : [import_compiler21.types.returnStatement(fn)];
|
2927
3019
|
}
|
2928
3020
|
function sortSignals(a, b) {
|
2929
3021
|
const aReferencedBindings = getReferencedBindings(a);
|
@@ -2969,15 +3061,15 @@ function writeHTMLResumeStatements(path5) {
|
|
2969
3061
|
if (!identifier) {
|
2970
3062
|
htmlDynamicClosureInstancesIdentifier.set(
|
2971
3063
|
closureSignal,
|
2972
|
-
identifier =
|
3064
|
+
identifier = generateUidIdentifier(
|
2973
3065
|
closureSignal.identifier.name + "_closures"
|
2974
3066
|
)
|
2975
3067
|
);
|
2976
3068
|
getHTMLSectionStatements(closure.section).push(
|
2977
|
-
|
2978
|
-
|
3069
|
+
import_compiler21.types.variableDeclaration("const", [
|
3070
|
+
import_compiler21.types.variableDeclarator(
|
2979
3071
|
identifier,
|
2980
|
-
|
3072
|
+
import_compiler21.types.newExpression(import_compiler21.types.identifier("Set"), [])
|
2981
3073
|
)
|
2982
3074
|
])
|
2983
3075
|
);
|
@@ -2991,7 +3083,7 @@ function writeHTMLResumeStatements(path5) {
|
|
2991
3083
|
setSerializedProperty(
|
2992
3084
|
section,
|
2993
3085
|
getAccessorPrefix().ClosureSignalIndex + getScopeAccessor(closure),
|
2994
|
-
|
3086
|
+
import_compiler21.types.numericLiteral(getDynamicClosureIndex(closure, section)),
|
2995
3087
|
serializeReason
|
2996
3088
|
);
|
2997
3089
|
addWriteScopeBuilder(
|
@@ -3006,13 +3098,13 @@ function writeHTMLResumeStatements(path5) {
|
|
3006
3098
|
for (const hoistedBinding of binding.hoists.values()) {
|
3007
3099
|
if (hoistedBinding.downstreamExpressions.size) {
|
3008
3100
|
getHTMLSectionStatements(hoistedBinding.section).push(
|
3009
|
-
|
3010
|
-
|
3011
|
-
|
3101
|
+
import_compiler21.types.variableDeclaration("const", [
|
3102
|
+
import_compiler21.types.variableDeclarator(
|
3103
|
+
import_compiler21.types.identifier(hoistedBinding.name),
|
3012
3104
|
callRuntime(
|
3013
3105
|
"hoist",
|
3014
3106
|
getScopeIdIdentifier(hoistedBinding.section),
|
3015
|
-
|
3107
|
+
import_compiler21.types.stringLiteral(
|
3016
3108
|
getResumeRegisterId(
|
3017
3109
|
hoistedBinding.section,
|
3018
3110
|
hoistedBinding,
|
@@ -3028,15 +3120,15 @@ function writeHTMLResumeStatements(path5) {
|
|
3028
3120
|
while (currentSection && currentSection !== hoistedBinding.section) {
|
3029
3121
|
const parentSection = currentSection.parent;
|
3030
3122
|
if (!currentSection.sectionAccessor && !sectionDynamicSubscribers.has(currentSection)) {
|
3031
|
-
const subscribersIdentifier =
|
3123
|
+
const subscribersIdentifier = generateUidIdentifier(
|
3032
3124
|
`${currentSection.name}_subscribers`
|
3033
3125
|
);
|
3034
3126
|
sectionDynamicSubscribers.add(currentSection);
|
3035
3127
|
getHTMLSectionStatements(parentSection).push(
|
3036
|
-
|
3037
|
-
|
3128
|
+
import_compiler21.types.variableDeclaration("const", [
|
3129
|
+
import_compiler21.types.variableDeclarator(
|
3038
3130
|
subscribersIdentifier,
|
3039
|
-
|
3131
|
+
import_compiler21.types.newExpression(import_compiler21.types.identifier("Set"), [])
|
3040
3132
|
)
|
3041
3133
|
])
|
3042
3134
|
);
|
@@ -3067,11 +3159,11 @@ function writeHTMLResumeStatements(path5) {
|
|
3067
3159
|
if (allSignals[i].effect.length) {
|
3068
3160
|
const signalRefs = allSignals[i].referencedBindings;
|
3069
3161
|
body.push(
|
3070
|
-
|
3162
|
+
import_compiler21.types.expressionStatement(
|
3071
3163
|
callRuntime(
|
3072
3164
|
"writeEffect",
|
3073
3165
|
scopeIdIdentifier,
|
3074
|
-
|
3166
|
+
import_compiler21.types.stringLiteral(getResumeRegisterId(section, signalRefs))
|
3075
3167
|
)
|
3076
3168
|
)
|
3077
3169
|
);
|
@@ -3101,7 +3193,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3101
3193
|
}
|
3102
3194
|
const writeScopeArgs = [
|
3103
3195
|
scopeIdIdentifier,
|
3104
|
-
|
3196
|
+
import_compiler21.types.objectExpression(serializedProperties)
|
3105
3197
|
];
|
3106
3198
|
if (!isOptimize()) {
|
3107
3199
|
let debugVars;
|
@@ -3115,30 +3207,30 @@ function writeHTMLResumeStatements(path5) {
|
|
3115
3207
|
}
|
3116
3208
|
root = root.upstreamAlias;
|
3117
3209
|
}
|
3118
|
-
const locExpr = root.loc &&
|
3210
|
+
const locExpr = root.loc && import_compiler21.types.stringLiteral(
|
3119
3211
|
`${root.loc.start.line}:${root.loc.start.column + 1}`
|
3120
3212
|
);
|
3121
3213
|
(debugVars ||= []).push(
|
3122
3214
|
toObjectProperty(
|
3123
3215
|
getScopeAccessor(binding),
|
3124
|
-
root !== binding ?
|
3125
|
-
locExpr ? [
|
3126
|
-
) : locExpr ||
|
3216
|
+
root !== binding ? import_compiler21.types.arrayExpression(
|
3217
|
+
locExpr ? [import_compiler21.types.stringLiteral(root.name + access), locExpr] : [import_compiler21.types.stringLiteral(root.name + access)]
|
3218
|
+
) : locExpr || import_compiler21.types.numericLiteral(0)
|
3127
3219
|
)
|
3128
3220
|
);
|
3129
3221
|
});
|
3130
3222
|
writeScopeArgs.push(
|
3131
|
-
|
3132
|
-
section.loc && section.loc.start.line != null ?
|
3223
|
+
import_compiler21.types.stringLiteral(path5.hub.file.opts.filenameRelative),
|
3224
|
+
section.loc && section.loc.start.line != null ? import_compiler21.types.stringLiteral(
|
3133
3225
|
`${section.loc.start.line}:${section.loc.start.column + 1}`
|
3134
|
-
) :
|
3226
|
+
) : import_compiler21.types.numericLiteral(0)
|
3135
3227
|
);
|
3136
3228
|
if (debugVars) {
|
3137
|
-
writeScopeArgs.push(
|
3229
|
+
writeScopeArgs.push(import_compiler21.types.objectExpression(debugVars));
|
3138
3230
|
}
|
3139
3231
|
}
|
3140
3232
|
body.push(
|
3141
|
-
|
3233
|
+
import_compiler21.types.expressionStatement(
|
3142
3234
|
writeScopeBuilder ? writeScopeBuilder(callRuntime("writeScope", ...writeScopeArgs)) : callRuntime("writeScope", ...writeScopeArgs)
|
3143
3235
|
)
|
3144
3236
|
);
|
@@ -3146,7 +3238,7 @@ function writeHTMLResumeStatements(path5) {
|
|
3146
3238
|
const resumeClosestBranch2 = !section.isBranch && (section.hasAbortSignal || !!section.referencedClosures || !!find(section.bindings, (binding) => binding.type === 1 /* let */));
|
3147
3239
|
if (resumeClosestBranch2) {
|
3148
3240
|
body.push(
|
3149
|
-
|
3241
|
+
import_compiler21.types.expressionStatement(
|
3150
3242
|
callRuntime("resumeClosestBranch", scopeIdIdentifier)
|
3151
3243
|
)
|
3152
3244
|
);
|
@@ -3154,15 +3246,15 @@ function writeHTMLResumeStatements(path5) {
|
|
3154
3246
|
const additionalStatements = getHTMLSectionStatements(section);
|
3155
3247
|
if (body.length || additionalStatements.length) {
|
3156
3248
|
body.unshift(
|
3157
|
-
|
3158
|
-
|
3249
|
+
import_compiler21.types.variableDeclaration("const", [
|
3250
|
+
import_compiler21.types.variableDeclarator(scopeIdIdentifier, callRuntime("nextScopeId"))
|
3159
3251
|
]),
|
3160
3252
|
...additionalStatements
|
3161
3253
|
);
|
3162
3254
|
}
|
3163
3255
|
const returnIdentifier = getSectionReturnValueIdentifier(section);
|
3164
3256
|
if (returnIdentifier !== void 0) {
|
3165
|
-
body.push(
|
3257
|
+
body.push(import_compiler21.types.returnStatement(returnIdentifier));
|
3166
3258
|
}
|
3167
3259
|
}
|
3168
3260
|
function serializeOwners(from, to) {
|
@@ -3209,14 +3301,14 @@ function replaceAssignedNode(node) {
|
|
3209
3301
|
if (buildAssignment) {
|
3210
3302
|
const replacement = buildAssignment(
|
3211
3303
|
extra.section,
|
3212
|
-
|
3304
|
+
import_compiler21.types.binaryExpression(
|
3213
3305
|
node.operator === "++" ? "+" : "-",
|
3214
3306
|
node.argument,
|
3215
|
-
|
3307
|
+
import_compiler21.types.numericLiteral(1)
|
3216
3308
|
)
|
3217
3309
|
);
|
3218
3310
|
if (!node.prefix) {
|
3219
|
-
return
|
3311
|
+
return import_compiler21.types.sequenceExpression([replacement, node.argument]);
|
3220
3312
|
}
|
3221
3313
|
return replacement;
|
3222
3314
|
}
|
@@ -3235,7 +3327,7 @@ function replaceAssignedNode(node) {
|
|
3235
3327
|
if (buildAssignment) {
|
3236
3328
|
return buildAssignment(
|
3237
3329
|
extra.section,
|
3238
|
-
node.operator === "=" ? node.right :
|
3330
|
+
node.operator === "=" ? node.right : import_compiler21.types.binaryExpression(
|
3239
3331
|
node.operator.slice(
|
3240
3332
|
0,
|
3241
3333
|
-1
|
@@ -3260,27 +3352,27 @@ function replaceAssignedNode(node) {
|
|
3260
3352
|
extra.assignment
|
3261
3353
|
);
|
3262
3354
|
if (signal?.buildAssignment) {
|
3263
|
-
id.name =
|
3264
|
-
(params ||= []).push(
|
3355
|
+
id.name = generateUid(id.name);
|
3356
|
+
(params ||= []).push(import_compiler21.types.identifier(id.name));
|
3265
3357
|
(assignments ||= []).push(
|
3266
|
-
signal.buildAssignment(extra.section,
|
3358
|
+
signal.buildAssignment(extra.section, import_compiler21.types.identifier(id.name))
|
3267
3359
|
);
|
3268
3360
|
}
|
3269
3361
|
}
|
3270
3362
|
});
|
3271
3363
|
if (params && assignments) {
|
3272
|
-
const resultId =
|
3273
|
-
return
|
3274
|
-
|
3275
|
-
[
|
3276
|
-
|
3277
|
-
|
3364
|
+
const resultId = generateUid("result");
|
3365
|
+
return import_compiler21.types.callExpression(
|
3366
|
+
import_compiler21.types.arrowFunctionExpression(
|
3367
|
+
[import_compiler21.types.identifier(resultId), ...params],
|
3368
|
+
import_compiler21.types.sequenceExpression([
|
3369
|
+
import_compiler21.types.assignmentExpression(
|
3278
3370
|
"=",
|
3279
3371
|
node.left,
|
3280
|
-
|
3372
|
+
import_compiler21.types.identifier(resultId)
|
3281
3373
|
),
|
3282
3374
|
...assignments,
|
3283
|
-
|
3375
|
+
import_compiler21.types.identifier(resultId)
|
3284
3376
|
])
|
3285
3377
|
),
|
3286
3378
|
[node.right]
|
@@ -3297,15 +3389,15 @@ function replaceRegisteredFunctionNode(node) {
|
|
3297
3389
|
switch (node.type) {
|
3298
3390
|
case "ClassMethod": {
|
3299
3391
|
const replacement = getRegisteredFnExpression(node);
|
3300
|
-
return replacement &&
|
3392
|
+
return replacement && import_compiler21.types.classProperty(node.key, replacement);
|
3301
3393
|
}
|
3302
3394
|
case "ClassPrivateMethod": {
|
3303
3395
|
const replacement = getRegisteredFnExpression(node);
|
3304
|
-
return replacement &&
|
3396
|
+
return replacement && import_compiler21.types.classPrivateProperty(node.key, replacement);
|
3305
3397
|
}
|
3306
3398
|
case "ObjectMethod": {
|
3307
3399
|
const replacement = getRegisteredFnExpression(node);
|
3308
|
-
return replacement &&
|
3400
|
+
return replacement && import_compiler21.types.objectProperty(node.key, replacement);
|
3309
3401
|
}
|
3310
3402
|
case "ArrowFunctionExpression":
|
3311
3403
|
case "FunctionExpression": {
|
@@ -3314,8 +3406,8 @@ function replaceRegisteredFunctionNode(node) {
|
|
3314
3406
|
case "FunctionDeclaration": {
|
3315
3407
|
const replacement = getRegisteredFnExpression(node);
|
3316
3408
|
if (replacement) {
|
3317
|
-
return
|
3318
|
-
|
3409
|
+
return import_compiler21.types.variableDeclaration("const", [
|
3410
|
+
import_compiler21.types.variableDeclarator(node.id, replacement)
|
3319
3411
|
]);
|
3320
3412
|
}
|
3321
3413
|
break;
|
@@ -3325,12 +3417,12 @@ function replaceRegisteredFunctionNode(node) {
|
|
3325
3417
|
function getRegisteredFnExpression(node) {
|
3326
3418
|
const { extra } = node;
|
3327
3419
|
if (isRegisteredFnExtra(extra)) {
|
3328
|
-
const id =
|
3420
|
+
const id = generateUid(extra.name);
|
3329
3421
|
const referencesScope = extra.referencesScope;
|
3330
3422
|
const referencedBindings = extra.referencedBindingsInFunction;
|
3331
|
-
let registedFns = registeredFnsForProgram.get((0,
|
3423
|
+
let registedFns = registeredFnsForProgram.get((0, import_compiler21.getProgram)().node);
|
3332
3424
|
if (!registedFns) {
|
3333
|
-
registeredFnsForProgram.set((0,
|
3425
|
+
registeredFnsForProgram.set((0, import_compiler21.getProgram)().node, registedFns = []);
|
3334
3426
|
}
|
3335
3427
|
registedFns.push({
|
3336
3428
|
id,
|
@@ -3341,9 +3433,9 @@ function getRegisteredFnExpression(node) {
|
|
3341
3433
|
referencedBindings
|
3342
3434
|
});
|
3343
3435
|
if (referencesScope || referencedBindings) {
|
3344
|
-
return
|
3436
|
+
return import_compiler21.types.callExpression(import_compiler21.types.identifier(id), [scopeIdentifier]);
|
3345
3437
|
} else {
|
3346
|
-
return
|
3438
|
+
return import_compiler21.types.identifier(id);
|
3347
3439
|
}
|
3348
3440
|
}
|
3349
3441
|
}
|
@@ -3367,9 +3459,9 @@ var dom_default = {
|
|
3367
3459
|
const section = getSectionForBody(program);
|
3368
3460
|
const { walks, writes, setup } = getSectionMeta(section);
|
3369
3461
|
const domExports = program.node.extra.domExports;
|
3370
|
-
const templateIdentifier =
|
3371
|
-
const walksIdentifier =
|
3372
|
-
const setupIdentifier =
|
3462
|
+
const templateIdentifier = import_compiler22.types.identifier(domExports.template);
|
3463
|
+
const walksIdentifier = import_compiler22.types.identifier(domExports.walks);
|
3464
|
+
const setupIdentifier = import_compiler22.types.identifier(domExports.setup);
|
3373
3465
|
const inputBinding = program.node.params[0].extra?.binding;
|
3374
3466
|
const programInputSignal = inputBinding && bindingHasDownstreamExpressions(inputBinding) ? initValue(inputBinding) : void 0;
|
3375
3467
|
const styleFile = getStyleFile(program.hub.file);
|
@@ -3380,17 +3472,17 @@ var dom_default = {
|
|
3380
3472
|
if (childSection !== section) {
|
3381
3473
|
const tagParamsSignal = childSection.params && initValue(childSection.params);
|
3382
3474
|
const { walks: walks2, writes: writes2, setup: setup2 } = getSectionMeta(childSection);
|
3383
|
-
const identifier =
|
3384
|
-
const referencedClosures = childSection.referencedClosures ?
|
3475
|
+
const identifier = import_compiler22.types.identifier(childSection.name);
|
3476
|
+
const referencedClosures = childSection.referencedClosures ? import_compiler22.types.arrowFunctionExpression(
|
3385
3477
|
[scopeIdentifier],
|
3386
3478
|
toFirstExpressionOrBlock(
|
3387
3479
|
map(childSection.referencedClosures, (closure) => {
|
3388
3480
|
const closureSignal = getSignal(childSection, closure);
|
3389
|
-
return
|
3390
|
-
|
3391
|
-
isDynamicClosure(childSection, closure) ? closureSignal.identifier :
|
3481
|
+
return import_compiler22.types.expressionStatement(
|
3482
|
+
import_compiler22.types.callExpression(
|
3483
|
+
isDynamicClosure(childSection, closure) ? closureSignal.identifier : import_compiler22.types.memberExpression(
|
3392
3484
|
closureSignal.identifier,
|
3393
|
-
|
3485
|
+
import_compiler22.types.identifier("_")
|
3394
3486
|
),
|
3395
3487
|
[scopeIdentifier]
|
3396
3488
|
)
|
@@ -3409,7 +3501,7 @@ var dom_default = {
|
|
3409
3501
|
])
|
3410
3502
|
) : callRuntime(
|
3411
3503
|
isSerializedSection(childSection) ? "registerContent" : "createContent",
|
3412
|
-
|
3504
|
+
import_compiler22.types.stringLiteral(getResumeRegisterId(childSection, "renderer")),
|
3413
3505
|
...replaceNullishAndEmptyFunctionsWith0([
|
3414
3506
|
writes2,
|
3415
3507
|
walks2,
|
@@ -3421,8 +3513,8 @@ var dom_default = {
|
|
3421
3513
|
);
|
3422
3514
|
writeSignals(childSection);
|
3423
3515
|
program.node.body.push(
|
3424
|
-
|
3425
|
-
|
3516
|
+
import_compiler22.types.variableDeclaration("const", [
|
3517
|
+
import_compiler22.types.variableDeclarator(identifier, renderer)
|
3426
3518
|
])
|
3427
3519
|
);
|
3428
3520
|
}
|
@@ -3431,36 +3523,36 @@ var dom_default = {
|
|
3431
3523
|
writeRegisteredFns();
|
3432
3524
|
if (!setup) {
|
3433
3525
|
program.node.body.unshift(
|
3434
|
-
|
3435
|
-
|
3436
|
-
|
3526
|
+
import_compiler22.types.exportNamedDeclaration(
|
3527
|
+
import_compiler22.types.variableDeclaration("const", [
|
3528
|
+
import_compiler22.types.variableDeclarator(
|
3437
3529
|
setupIdentifier,
|
3438
|
-
|
3530
|
+
import_compiler22.types.arrowFunctionExpression([], import_compiler22.types.blockStatement([]))
|
3439
3531
|
)
|
3440
3532
|
])
|
3441
3533
|
)
|
3442
3534
|
);
|
3443
3535
|
}
|
3444
3536
|
program.node.body.unshift(
|
3445
|
-
|
3446
|
-
|
3447
|
-
|
3537
|
+
import_compiler22.types.exportNamedDeclaration(
|
3538
|
+
import_compiler22.types.variableDeclaration("const", [
|
3539
|
+
import_compiler22.types.variableDeclarator(
|
3448
3540
|
templateIdentifier,
|
3449
|
-
writes ||
|
3541
|
+
writes || import_compiler22.types.stringLiteral("")
|
3450
3542
|
)
|
3451
3543
|
])
|
3452
3544
|
),
|
3453
|
-
|
3454
|
-
|
3455
|
-
|
3545
|
+
import_compiler22.types.exportNamedDeclaration(
|
3546
|
+
import_compiler22.types.variableDeclaration("const", [
|
3547
|
+
import_compiler22.types.variableDeclarator(walksIdentifier, walks || import_compiler22.types.stringLiteral(""))
|
3456
3548
|
])
|
3457
3549
|
)
|
3458
3550
|
);
|
3459
3551
|
program.node.body.push(
|
3460
|
-
|
3552
|
+
import_compiler22.types.exportDefaultDeclaration(
|
3461
3553
|
callRuntime(
|
3462
3554
|
"createTemplate",
|
3463
|
-
|
3555
|
+
import_compiler22.types.stringLiteral(program.hub.file.metadata.marko.id),
|
3464
3556
|
templateIdentifier,
|
3465
3557
|
walksIdentifier,
|
3466
3558
|
setupIdentifier,
|
@@ -3473,7 +3565,7 @@ var dom_default = {
|
|
3473
3565
|
};
|
3474
3566
|
|
3475
3567
|
// src/translator/visitors/program/html.ts
|
3476
|
-
var
|
3568
|
+
var import_compiler23 = require("@marko/compiler");
|
3477
3569
|
|
3478
3570
|
// src/translator/util/is-static.ts
|
3479
3571
|
function isStatic(path5) {
|
@@ -3483,11 +3575,11 @@ function isStatic(path5) {
|
|
3483
3575
|
// src/translator/visitors/program/html.ts
|
3484
3576
|
var templateContentIdentifierForProgram = /* @__PURE__ */ new WeakMap();
|
3485
3577
|
function getTemplateContentName() {
|
3486
|
-
let name2 = templateContentIdentifierForProgram.get((0,
|
3578
|
+
let name2 = templateContentIdentifierForProgram.get((0, import_compiler23.getProgram)());
|
3487
3579
|
if (!name2) {
|
3488
3580
|
templateContentIdentifierForProgram.set(
|
3489
|
-
(0,
|
3490
|
-
name2 =
|
3581
|
+
(0, import_compiler23.getProgram)(),
|
3582
|
+
name2 = generateUid("content")
|
3491
3583
|
);
|
3492
3584
|
}
|
3493
3585
|
return name2;
|
@@ -3512,21 +3604,21 @@ var html_default = {
|
|
3512
3604
|
}
|
3513
3605
|
}
|
3514
3606
|
const contentId = templateContentIdentifierForProgram.get(program);
|
3515
|
-
const contentFn =
|
3516
|
-
[
|
3517
|
-
|
3607
|
+
const contentFn = import_compiler23.types.arrowFunctionExpression(
|
3608
|
+
[import_compiler23.types.identifier("input")],
|
3609
|
+
import_compiler23.types.blockStatement(renderContent)
|
3518
3610
|
);
|
3519
|
-
const exportDefault =
|
3611
|
+
const exportDefault = import_compiler23.types.exportDefaultDeclaration(
|
3520
3612
|
callRuntime(
|
3521
3613
|
"createTemplate",
|
3522
|
-
|
3523
|
-
contentId ?
|
3614
|
+
import_compiler23.types.stringLiteral(program.hub.file.metadata.marko.id),
|
3615
|
+
contentId ? import_compiler23.types.identifier(contentId) : contentFn
|
3524
3616
|
)
|
3525
3617
|
);
|
3526
3618
|
if (contentId) {
|
3527
3619
|
program.node.body.push(
|
3528
|
-
|
3529
|
-
|
3620
|
+
import_compiler23.types.variableDeclaration("const", [
|
3621
|
+
import_compiler23.types.variableDeclarator(import_compiler23.types.identifier(contentId), contentFn)
|
3530
3622
|
]),
|
3531
3623
|
exportDefault
|
3532
3624
|
);
|
@@ -3554,15 +3646,15 @@ function replaceRegisteredFunctionNode2(node, container) {
|
|
3554
3646
|
switch (node.type) {
|
3555
3647
|
case "ClassMethod": {
|
3556
3648
|
const replacement = getRegisteredFnExpression2(node);
|
3557
|
-
return replacement &&
|
3649
|
+
return replacement && import_compiler23.types.classProperty(node.key, replacement);
|
3558
3650
|
}
|
3559
3651
|
case "ClassPrivateMethod": {
|
3560
3652
|
const replacement = getRegisteredFnExpression2(node);
|
3561
|
-
return replacement &&
|
3653
|
+
return replacement && import_compiler23.types.classPrivateProperty(node.key, replacement);
|
3562
3654
|
}
|
3563
3655
|
case "ObjectMethod": {
|
3564
3656
|
const replacement = getRegisteredFnExpression2(node);
|
3565
|
-
return replacement &&
|
3657
|
+
return replacement && import_compiler23.types.objectProperty(node.key, replacement);
|
3566
3658
|
}
|
3567
3659
|
case "FunctionDeclaration": {
|
3568
3660
|
const { extra } = node;
|
@@ -3599,11 +3691,11 @@ function addRegisteredDeclarations(body) {
|
|
3599
3691
|
if (registeredFnDeclarations) {
|
3600
3692
|
for (const { id, registerId } of registeredFnDeclarations) {
|
3601
3693
|
body.push(
|
3602
|
-
|
3694
|
+
import_compiler23.types.expressionStatement(
|
3603
3695
|
callRuntime(
|
3604
3696
|
"register",
|
3605
|
-
|
3606
|
-
|
3697
|
+
import_compiler23.types.identifier(id),
|
3698
|
+
import_compiler23.types.stringLiteral(registerId)
|
3607
3699
|
)
|
3608
3700
|
)
|
3609
3701
|
);
|
@@ -3616,7 +3708,7 @@ function getRegisteredFnExpression2(node) {
|
|
3616
3708
|
return callRuntime(
|
3617
3709
|
"register",
|
3618
3710
|
simplifyFunction(node),
|
3619
|
-
|
3711
|
+
import_compiler23.types.stringLiteral(extra.registerId),
|
3620
3712
|
(extra.referencedBindingsInFunction || extra.referencesScope) && getScopeIdIdentifier(extra.section)
|
3621
3713
|
);
|
3622
3714
|
}
|
@@ -3631,7 +3723,7 @@ function isScopeIdentifier(node) {
|
|
3631
3723
|
var program_default = {
|
3632
3724
|
migrate: {
|
3633
3725
|
enter(program) {
|
3634
|
-
program.node.params = [
|
3726
|
+
program.node.params = [import_compiler24.types.identifier("input")];
|
3635
3727
|
},
|
3636
3728
|
exit(program) {
|
3637
3729
|
program.scope.crawl();
|
@@ -3645,14 +3737,13 @@ var program_default = {
|
|
3645
3737
|
if (inputBinding) {
|
3646
3738
|
inputBinding.nullable = false;
|
3647
3739
|
}
|
3648
|
-
const { scope } = program;
|
3649
3740
|
(program.node.extra ??= {}).domExports = {
|
3650
|
-
template:
|
3651
|
-
walks:
|
3652
|
-
setup:
|
3741
|
+
template: generateUid("template"),
|
3742
|
+
walks: generateUid("walks"),
|
3743
|
+
setup: generateUid("setup"),
|
3653
3744
|
input: void 0,
|
3654
3745
|
// TODO look into recursive components with fine grained params.
|
3655
|
-
closures:
|
3746
|
+
closures: generateUid("closures")
|
3656
3747
|
};
|
3657
3748
|
},
|
3658
3749
|
exit(program) {
|
@@ -3669,8 +3760,8 @@ var program_default = {
|
|
3669
3760
|
},
|
3670
3761
|
translate: {
|
3671
3762
|
enter(program) {
|
3672
|
-
scopeIdentifier = isOutputDOM() ?
|
3673
|
-
cleanIdentifier = isOutputDOM() ?
|
3763
|
+
scopeIdentifier = isOutputDOM() ? generateUidIdentifier("scope") : null;
|
3764
|
+
cleanIdentifier = isOutputDOM() ? generateUidIdentifier("clean") : null;
|
3674
3765
|
if (getMarkoOpts().output === "hydrate") {
|
3675
3766
|
const entryFile = program.hub.file;
|
3676
3767
|
const visitedFiles = /* @__PURE__ */ new Set([
|
@@ -3710,7 +3801,7 @@ var program_default = {
|
|
3710
3801
|
body.push(child);
|
3711
3802
|
}
|
3712
3803
|
}
|
3713
|
-
body[0] ??=
|
3804
|
+
body[0] ??= import_compiler24.types.importDeclaration([], import_compiler24.types.stringLiteral(compatFile));
|
3714
3805
|
program.node.body = body;
|
3715
3806
|
}
|
3716
3807
|
}
|
@@ -3724,7 +3815,7 @@ function resolveRelativeToEntry(entryFile, file, req) {
|
|
3724
3815
|
}
|
3725
3816
|
function buildTemplateExports(binding, program) {
|
3726
3817
|
const templateExport = {
|
3727
|
-
id: binding.export ??=
|
3818
|
+
id: binding.export ??= generateUid(binding.name),
|
3728
3819
|
binding,
|
3729
3820
|
props: void 0
|
3730
3821
|
};
|
@@ -3740,7 +3831,7 @@ function buildTemplateExports(binding, program) {
|
|
3740
3831
|
// src/translator/util/scope-read.ts
|
3741
3832
|
function createScopeReadPattern(section, referencedBindings) {
|
3742
3833
|
const rootDepth = section.depth;
|
3743
|
-
const rootPattern =
|
3834
|
+
const rootPattern = import_compiler25.types.objectPattern([]);
|
3744
3835
|
let nestedPatterns;
|
3745
3836
|
forEach(referencedBindings, (ref) => {
|
3746
3837
|
const propertyValue = ref.name;
|
@@ -3754,9 +3845,9 @@ function createScopeReadPattern(section, referencedBindings) {
|
|
3754
3845
|
let i = nestedPatterns.length;
|
3755
3846
|
let prev = nestedPatterns[i - 1];
|
3756
3847
|
for (; i <= relativeDepth; i++) {
|
3757
|
-
const nestedPattern =
|
3848
|
+
const nestedPattern = import_compiler25.types.objectPattern([]);
|
3758
3849
|
prev.properties.push(
|
3759
|
-
|
3850
|
+
import_compiler25.types.objectProperty(import_compiler25.types.identifier("_"), nestedPattern)
|
3760
3851
|
);
|
3761
3852
|
nestedPatterns.push(nestedPattern);
|
3762
3853
|
prev = nestedPattern;
|
@@ -3764,9 +3855,9 @@ function createScopeReadPattern(section, referencedBindings) {
|
|
3764
3855
|
pattern = nestedPatterns[relativeDepth];
|
3765
3856
|
}
|
3766
3857
|
pattern.properties.push(
|
3767
|
-
|
3858
|
+
import_compiler25.types.objectProperty(
|
3768
3859
|
toPropertyName(propertyKey),
|
3769
|
-
|
3860
|
+
import_compiler25.types.identifier(propertyValue),
|
3770
3861
|
false,
|
3771
3862
|
isShorthand
|
3772
3863
|
)
|
@@ -3775,10 +3866,10 @@ function createScopeReadPattern(section, referencedBindings) {
|
|
3775
3866
|
return rootPattern;
|
3776
3867
|
}
|
3777
3868
|
function getScopeExpression(section, targetSection) {
|
3778
|
-
let scope = scopeIdentifier ??
|
3869
|
+
let scope = scopeIdentifier ?? import_compiler25.types.identifier("undefined");
|
3779
3870
|
const diff = section.depth - targetSection.depth;
|
3780
3871
|
for (let i = 0; i < diff; i++) {
|
3781
|
-
scope =
|
3872
|
+
scope = import_compiler25.types.memberExpression(scope, import_compiler25.types.identifier("_"));
|
3782
3873
|
}
|
3783
3874
|
if (diff < 0) {
|
3784
3875
|
throw new Error("Unable to find scope for reference.");
|
@@ -3787,7 +3878,7 @@ function getScopeExpression(section, targetSection) {
|
|
3787
3878
|
}
|
3788
3879
|
function createScopeReadExpression(section, reference) {
|
3789
3880
|
const propName = toPropertyName(getScopeAccessor(reference));
|
3790
|
-
return
|
3881
|
+
return import_compiler25.types.memberExpression(
|
3791
3882
|
getScopeExpression(section, reference.section),
|
3792
3883
|
propName,
|
3793
3884
|
propName.type !== "Identifier"
|
@@ -3871,7 +3962,7 @@ function trackParamsReferences(body, type, upstreamAlias, upstreamExpression) {
|
|
3871
3962
|
const section = getOrCreateSection(body);
|
3872
3963
|
const canonicalUpstreamAlias = getCanonicalBinding(upstreamAlias);
|
3873
3964
|
const paramsBinding = canonicalUpstreamAlias || ((body.node.extra ??= {}).binding = createBinding(
|
3874
|
-
|
3965
|
+
generateUid("params"),
|
3875
3966
|
type,
|
3876
3967
|
section,
|
3877
3968
|
canonicalUpstreamAlias,
|
@@ -3902,7 +3993,7 @@ function trackHoistedReference(referencePath, binding) {
|
|
3902
3993
|
binding.hoists.set(
|
3903
3994
|
hoistSection,
|
3904
3995
|
hoistedBinding = createBinding(
|
3905
|
-
|
3996
|
+
generateUid("hoisted_" + referencePath.node.name),
|
3906
3997
|
5 /* hoist */,
|
3907
3998
|
hoistSection,
|
3908
3999
|
void 0,
|
@@ -3992,7 +4083,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
3992
4083
|
break;
|
3993
4084
|
case "ObjectPattern": {
|
3994
4085
|
const patternBinding = (property ? upstreamAlias.propertyAliases.get(property) : upstreamAlias) || ((lVal.extra ??= {}).binding = createBinding(
|
3995
|
-
(
|
4086
|
+
generateUid(property || "pattern"),
|
3996
4087
|
type,
|
3997
4088
|
section,
|
3998
4089
|
upstreamAlias,
|
@@ -4035,7 +4126,7 @@ function createBindingsAndTrackReferences(lVal, type, scope, section, upstreamAl
|
|
4035
4126
|
}
|
4036
4127
|
case "ArrayPattern": {
|
4037
4128
|
const patternBinding = (property ? upstreamAlias.propertyAliases.get(property) : upstreamAlias) || ((lVal.extra ??= {}).binding = createBinding(
|
4038
|
-
(
|
4129
|
+
generateUid(property || "pattern"),
|
4039
4130
|
type,
|
4040
4131
|
section,
|
4041
4132
|
upstreamAlias,
|
@@ -4091,7 +4182,7 @@ function trackReference(referencePath, binding) {
|
|
4091
4182
|
let propPath = binding.name;
|
4092
4183
|
while (true) {
|
4093
4184
|
const { parent } = root;
|
4094
|
-
if (!
|
4185
|
+
if (!import_compiler26.types.isMemberExpression(parent)) break;
|
4095
4186
|
const prop = getMemberExpressionPropString(parent);
|
4096
4187
|
if (prop === void 0) break;
|
4097
4188
|
if (reference.propertyAliases.has(prop)) {
|
@@ -4208,7 +4299,7 @@ function finalizeReferences() {
|
|
4208
4299
|
if (binding.type !== 0 /* dom */) {
|
4209
4300
|
resolveBindingSources(binding);
|
4210
4301
|
if (find(section.bindings, ({ name: name3 }) => name3 === binding.name)) {
|
4211
|
-
binding.name =
|
4302
|
+
binding.name = generateUid(name2);
|
4212
4303
|
}
|
4213
4304
|
}
|
4214
4305
|
section.bindings = bindingUtil.add(section.bindings, binding);
|
@@ -4258,9 +4349,7 @@ function finalizeReferences() {
|
|
4258
4349
|
let serialize = false;
|
4259
4350
|
const sourceSection = binding.section;
|
4260
4351
|
let currentSection = section;
|
4261
|
-
while (currentSection !== sourceSection && !(serialize = !currentSection.upstreamExpression || !!
|
4262
|
-
currentSection.upstreamExpression.referencedBindings
|
4263
|
-
))) {
|
4352
|
+
while (currentSection !== sourceSection && !(serialize = !currentSection.upstreamExpression || !!getDynamicSourcesForExtra(currentSection.upstreamExpression))) {
|
4264
4353
|
currentSection = currentSection.parent;
|
4265
4354
|
}
|
4266
4355
|
binding.serialize = serialize;
|
@@ -4391,9 +4480,9 @@ function getAllTagReferenceNodes(tag, referenceNodes = []) {
|
|
4391
4480
|
}
|
4392
4481
|
function getScopeAccessorLiteral(binding, includeId) {
|
4393
4482
|
if (isOptimize()) {
|
4394
|
-
return
|
4483
|
+
return import_compiler26.types.numericLiteral(binding.id);
|
4395
4484
|
}
|
4396
|
-
return
|
4485
|
+
return import_compiler26.types.stringLiteral(
|
4397
4486
|
binding.name + (includeId || binding.type === 0 /* dom */ ? `/${binding.id}` : "")
|
4398
4487
|
);
|
4399
4488
|
}
|
@@ -4408,7 +4497,7 @@ function getSectionInstancesAccessor(section) {
|
|
4408
4497
|
}
|
4409
4498
|
function getSectionInstancesAccessorLiteral(section) {
|
4410
4499
|
const accessor = getSectionInstancesAccessor(section);
|
4411
|
-
return accessor ? typeof accessor === "number" ?
|
4500
|
+
return accessor ? typeof accessor === "number" ? import_compiler26.types.numericLiteral(accessor) : import_compiler26.types.stringLiteral(accessor) : void 0;
|
4412
4501
|
}
|
4413
4502
|
function getReadReplacement(node) {
|
4414
4503
|
const { extra } = node;
|
@@ -4426,18 +4515,18 @@ function getReadReplacement(node) {
|
|
4426
4515
|
if (binding) {
|
4427
4516
|
if (node.type === "Identifier") {
|
4428
4517
|
if (binding.type === 5 /* hoist */) {
|
4429
|
-
replacement = node.extra?.[kIsInvoked] ?
|
4518
|
+
replacement = node.extra?.[kIsInvoked] ? import_compiler26.types.callExpression(getHoistFunctionIdentifier(binding), [
|
4430
4519
|
getScopeExpression(node.extra.section, binding.section)
|
4431
|
-
]) :
|
4520
|
+
]) : import_compiler26.types.identifier(getScopeAccessor(binding));
|
4432
4521
|
} else if (binding.name !== node.name) {
|
4433
4522
|
node.name = binding.name;
|
4434
4523
|
}
|
4435
4524
|
} else {
|
4436
|
-
replacement =
|
4525
|
+
replacement = import_compiler26.types.identifier(binding.name);
|
4437
4526
|
}
|
4438
4527
|
} else if (read) {
|
4439
4528
|
replacement = toMemberExpression(
|
4440
|
-
|
4529
|
+
import_compiler26.types.identifier(read.binding.name),
|
4441
4530
|
Array.isArray(read.props) ? read.props[0] : read.props
|
4442
4531
|
);
|
4443
4532
|
if (Array.isArray(read.props)) {
|
@@ -4576,7 +4665,7 @@ var await_default = {
|
|
4576
4665
|
if (!valueAttr) {
|
4577
4666
|
throw tag.get("name").buildCodeFrameError("The `await` tag requires a value.");
|
4578
4667
|
}
|
4579
|
-
if (node.attributes.length > 1 || !
|
4668
|
+
if (node.attributes.length > 1 || !import_compiler27.types.isMarkoAttribute(valueAttr) || valueAttr.name !== "value") {
|
4580
4669
|
throw tag.get("name").buildCodeFrameError(
|
4581
4670
|
"The `await` tag only supports the `value` attribute."
|
4582
4671
|
);
|
@@ -4584,7 +4673,7 @@ var await_default = {
|
|
4584
4673
|
if (!node.body.body.length) {
|
4585
4674
|
throw tag.get("name").buildCodeFrameError("The `await` tag requires body content.");
|
4586
4675
|
}
|
4587
|
-
if (node.body.params.length && (node.body.params.length > 1 ||
|
4676
|
+
if (node.body.params.length && (node.body.params.length > 1 || import_compiler27.types.isSpreadElement(node.body.params[0]))) {
|
4588
4677
|
throw tag.get("name").buildCodeFrameError(
|
4589
4678
|
"The `await` tag only supports a single parameter."
|
4590
4679
|
);
|
@@ -4621,13 +4710,13 @@ var await_default = {
|
|
4621
4710
|
flushInto(tag);
|
4622
4711
|
writeHTMLResumeStatements(tagBody);
|
4623
4712
|
tag.replaceWith(
|
4624
|
-
|
4713
|
+
import_compiler27.types.expressionStatement(
|
4625
4714
|
callRuntime(
|
4626
4715
|
"fork",
|
4627
4716
|
getScopeIdIdentifier(section),
|
4628
4717
|
getScopeAccessorLiteral(nodeRef2),
|
4629
4718
|
valueAttr.value,
|
4630
|
-
|
4719
|
+
import_compiler27.types.arrowFunctionExpression(
|
4631
4720
|
node.body.params,
|
4632
4721
|
toFirstExpressionOrBlock(node.body.body)
|
4633
4722
|
)
|
@@ -4659,7 +4748,7 @@ var await_default = {
|
|
4659
4748
|
return callRuntime(
|
4660
4749
|
"awaitTag",
|
4661
4750
|
getScopeAccessorLiteral(nodeRef2),
|
4662
|
-
|
4751
|
+
import_compiler27.types.identifier(bodySection.name)
|
4663
4752
|
);
|
4664
4753
|
};
|
4665
4754
|
addValue(
|
@@ -4683,7 +4772,7 @@ var await_default = {
|
|
4683
4772
|
};
|
4684
4773
|
|
4685
4774
|
// src/translator/core/client.ts
|
4686
|
-
var
|
4775
|
+
var import_compiler28 = require("@marko/compiler");
|
4687
4776
|
var import_babel_utils13 = require("@marko/compiler/babel-utils");
|
4688
4777
|
var client_default = {
|
4689
4778
|
parse(tag) {
|
@@ -4695,10 +4784,10 @@ var client_default = {
|
|
4695
4784
|
const code = rawValue.replace(/^client\s*/, "").trim();
|
4696
4785
|
const start = node.name.start + (rawValue.length - code.length);
|
4697
4786
|
let body = (0, import_babel_utils13.parseStatements)(file, code, start, start + code.length);
|
4698
|
-
if (body.length === 1 &&
|
4787
|
+
if (body.length === 1 && import_compiler28.types.isBlockStatement(body[0])) {
|
4699
4788
|
body = body[0].body;
|
4700
4789
|
}
|
4701
|
-
tag.replaceWith(
|
4790
|
+
tag.replaceWith(import_compiler28.types.markoScriptlet(body, true, "client"));
|
4702
4791
|
},
|
4703
4792
|
parseOptions: {
|
4704
4793
|
statement: true,
|
@@ -4714,11 +4803,11 @@ var client_default = {
|
|
4714
4803
|
};
|
4715
4804
|
|
4716
4805
|
// src/translator/core/const.ts
|
4717
|
-
var
|
4806
|
+
var import_compiler30 = require("@marko/compiler");
|
4718
4807
|
var import_babel_utils14 = require("@marko/compiler/babel-utils");
|
4719
4808
|
|
4720
4809
|
// src/translator/util/translate-var.ts
|
4721
|
-
var
|
4810
|
+
var import_compiler29 = require("@marko/compiler");
|
4722
4811
|
function translateVar(tag, initialValue, kind = "const") {
|
4723
4812
|
const {
|
4724
4813
|
node: { var: tagVar }
|
@@ -4727,7 +4816,7 @@ function translateVar(tag, initialValue, kind = "const") {
|
|
4727
4816
|
return;
|
4728
4817
|
}
|
4729
4818
|
tag.insertBefore(
|
4730
|
-
|
4819
|
+
import_compiler29.types.variableDeclaration(kind, [import_compiler29.types.variableDeclarator(tagVar, initialValue)])
|
4731
4820
|
);
|
4732
4821
|
}
|
4733
4822
|
|
@@ -4745,12 +4834,12 @@ var const_default = {
|
|
4745
4834
|
if (!valueAttr) {
|
4746
4835
|
throw tag.get("name").buildCodeFrameError("The `const` tag requires a value.");
|
4747
4836
|
}
|
4748
|
-
if (node.attributes.length > 1 || !
|
4837
|
+
if (node.attributes.length > 1 || !import_compiler30.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
4749
4838
|
throw tag.get("name").buildCodeFrameError(
|
4750
4839
|
"The `const` tag only supports the `value` attribute."
|
4751
4840
|
);
|
4752
4841
|
}
|
4753
|
-
const upstreamAlias =
|
4842
|
+
const upstreamAlias = import_compiler30.types.isIdentifier(valueAttr.value) ? tag.scope.getBinding(valueAttr.value.name)?.identifier.extra?.binding : void 0;
|
4754
4843
|
trackVarReferences(
|
4755
4844
|
tag,
|
4756
4845
|
4 /* derived */,
|
@@ -4791,7 +4880,7 @@ var const_default = {
|
|
4791
4880
|
};
|
4792
4881
|
|
4793
4882
|
// src/translator/core/debug.ts
|
4794
|
-
var
|
4883
|
+
var import_compiler31 = require("@marko/compiler");
|
4795
4884
|
var import_babel_utils15 = require("@marko/compiler/babel-utils");
|
4796
4885
|
var debug_default = {
|
4797
4886
|
analyze(tag) {
|
@@ -4800,7 +4889,7 @@ var debug_default = {
|
|
4800
4889
|
(0, import_babel_utils15.assertNoArgs)(tag);
|
4801
4890
|
(0, import_babel_utils15.assertNoParams)(tag);
|
4802
4891
|
assertNoBodyContent(tag);
|
4803
|
-
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!
|
4892
|
+
if (tag.node.attributes.length > 1 || tag.node.attributes.length === 1 && (!import_compiler31.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value")) {
|
4804
4893
|
throw tag.get("name").buildCodeFrameError(
|
4805
4894
|
"The `debug` tag only supports the `value` attribute."
|
4806
4895
|
);
|
@@ -4811,7 +4900,7 @@ var debug_default = {
|
|
4811
4900
|
const section = getSection(tag);
|
4812
4901
|
const [valueAttr] = tag.node.attributes;
|
4813
4902
|
const referencedBindings = valueAttr?.value.extra?.referencedBindings;
|
4814
|
-
const statement = withPreviousLocation(
|
4903
|
+
const statement = withPreviousLocation(import_compiler31.types.debuggerStatement(), tag.node);
|
4815
4904
|
if (isOutputHTML()) {
|
4816
4905
|
tag.insertBefore(statement);
|
4817
4906
|
} else {
|
@@ -4834,20 +4923,20 @@ var debug_default = {
|
|
4834
4923
|
};
|
4835
4924
|
|
4836
4925
|
// src/translator/core/define.ts
|
4837
|
-
var
|
4926
|
+
var import_compiler37 = require("@marko/compiler");
|
4838
4927
|
var import_babel_utils21 = require("@marko/compiler/babel-utils");
|
4839
4928
|
|
4840
4929
|
// src/translator/util/nested-attribute-tags.ts
|
4841
|
-
var
|
4930
|
+
var import_compiler32 = require("@marko/compiler");
|
4842
4931
|
var import_babel_utils16 = require("@marko/compiler/babel-utils");
|
4843
4932
|
var attrTagToIdentifierLookup = /* @__PURE__ */ new WeakMap();
|
4844
4933
|
function getAttrTagIdentifier(meta) {
|
4845
4934
|
let name2 = attrTagToIdentifierLookup.get(meta);
|
4846
4935
|
if (!name2) {
|
4847
|
-
name2 =
|
4936
|
+
name2 = generateUid(meta.name);
|
4848
4937
|
attrTagToIdentifierLookup.set(meta, name2);
|
4849
4938
|
}
|
4850
|
-
return
|
4939
|
+
return import_compiler32.types.identifier(name2);
|
4851
4940
|
}
|
4852
4941
|
function analyzeAttributeTags(tag) {
|
4853
4942
|
if (tag.node.extra?.attributeTags) return tag.node.extra.attributeTags;
|
@@ -4960,19 +5049,19 @@ function getConditionRoot(tag) {
|
|
4960
5049
|
}
|
4961
5050
|
|
4962
5051
|
// src/translator/util/translate-attrs.ts
|
4963
|
-
var
|
5052
|
+
var import_compiler36 = require("@marko/compiler");
|
4964
5053
|
var import_babel_utils20 = require("@marko/compiler/babel-utils");
|
4965
5054
|
|
4966
5055
|
// src/translator/core/for.ts
|
4967
|
-
var
|
5056
|
+
var import_compiler35 = require("@marko/compiler");
|
4968
5057
|
var import_babel_utils19 = require("@marko/compiler/babel-utils");
|
4969
5058
|
|
4970
5059
|
// src/translator/util/is-only-child-in-parent.ts
|
4971
|
-
var
|
5060
|
+
var import_compiler34 = require("@marko/compiler");
|
4972
5061
|
var import_babel_utils18 = require("@marko/compiler/babel-utils");
|
4973
5062
|
|
4974
5063
|
// src/translator/visitors/tag/native-tag.ts
|
4975
|
-
var
|
5064
|
+
var import_compiler33 = require("@marko/compiler");
|
4976
5065
|
var import_babel_utils17 = require("@marko/compiler/babel-utils");
|
4977
5066
|
var kNativeTagBinding = Symbol("native tag binding");
|
4978
5067
|
var kSerializeMarker = Symbol("serialize marker");
|
@@ -5064,7 +5153,7 @@ var native_tag_default = {
|
|
5064
5153
|
}
|
5065
5154
|
}
|
5066
5155
|
tag.node.attributes.push(
|
5067
|
-
|
5156
|
+
import_compiler33.types.markoAttribute(
|
5068
5157
|
"value",
|
5069
5158
|
normalizeStringExpression(parts) || buildUndefined()
|
5070
5159
|
)
|
@@ -5079,7 +5168,7 @@ var native_tag_default = {
|
|
5079
5168
|
(0, import_babel_utils17.assertNoParams)(tag);
|
5080
5169
|
(0, import_babel_utils17.assertNoAttributeTags)(tag);
|
5081
5170
|
const { node } = tag;
|
5082
|
-
if (node.var && !
|
5171
|
+
if (node.var && !import_compiler33.types.isIdentifier(node.var)) {
|
5083
5172
|
throw tag.get("var").buildCodeFrameError(
|
5084
5173
|
"Tag variables on native elements cannot be destructured."
|
5085
5174
|
);
|
@@ -5094,7 +5183,7 @@ var native_tag_default = {
|
|
5094
5183
|
let spreadReferenceNodes;
|
5095
5184
|
for (let i = attributes.length; i--; ) {
|
5096
5185
|
const attr2 = attributes[i];
|
5097
|
-
if (
|
5186
|
+
if (import_compiler33.types.isMarkoAttribute(attr2)) {
|
5098
5187
|
if (seen[attr2.name]) {
|
5099
5188
|
dropReferences(attr2.value);
|
5100
5189
|
continue;
|
@@ -5106,14 +5195,14 @@ var native_tag_default = {
|
|
5106
5195
|
} else if (!evaluate(attr2.value).confident) {
|
5107
5196
|
hasDynamicAttributes = true;
|
5108
5197
|
}
|
5109
|
-
} else if (
|
5198
|
+
} else if (import_compiler33.types.isMarkoSpreadAttribute(attr2)) {
|
5110
5199
|
hasEventHandlers = true;
|
5111
5200
|
hasDynamicAttributes = true;
|
5112
5201
|
(attr2.value.extra ??= {}).isEffect = true;
|
5113
5202
|
}
|
5114
5203
|
if (spreadReferenceNodes) {
|
5115
5204
|
spreadReferenceNodes.push(attr2.value);
|
5116
|
-
} else if (
|
5205
|
+
} else if (import_compiler33.types.isMarkoSpreadAttribute(attr2)) {
|
5117
5206
|
spreadReferenceNodes = [attr2.value];
|
5118
5207
|
relatedControllable = getRelatedControllable(tagName, seen);
|
5119
5208
|
}
|
@@ -5140,8 +5229,8 @@ var native_tag_default = {
|
|
5140
5229
|
);
|
5141
5230
|
}
|
5142
5231
|
if (node.var || hasEventHandlers || hasDynamicAttributes) {
|
5143
|
-
(0,
|
5144
|
-
const tagName2 = node.name.type === "StringLiteral" ? node.name.value :
|
5232
|
+
(0, import_compiler33.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
|
5233
|
+
const tagName2 = node.name.type === "StringLiteral" ? node.name.value : import_compiler33.types.toIdentifier(tag.get("name"));
|
5145
5234
|
const tagExtra = node.extra ??= {};
|
5146
5235
|
const bindingName = "#" + tagName2;
|
5147
5236
|
if (hasEventHandlers || node.var) {
|
@@ -5200,23 +5289,21 @@ var native_tag_default = {
|
|
5200
5289
|
callRuntime(
|
5201
5290
|
"nodeRef",
|
5202
5291
|
getterId && getScopeIdIdentifier(section),
|
5203
|
-
getterId &&
|
5292
|
+
getterId && import_compiler33.types.stringLiteral(getterId)
|
5204
5293
|
)
|
5205
5294
|
);
|
5206
5295
|
} else {
|
5207
5296
|
let getterFnIdentifier;
|
5208
5297
|
if (getterId) {
|
5209
|
-
getterFnIdentifier = (
|
5210
|
-
|
5211
|
-
|
5212
|
-
|
5213
|
-
import_compiler32.types.variableDeclaration("const", [
|
5214
|
-
import_compiler32.types.variableDeclarator(
|
5298
|
+
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
5299
|
+
(0, import_compiler33.getProgram)().node.body.push(
|
5300
|
+
import_compiler33.types.variableDeclaration("const", [
|
5301
|
+
import_compiler33.types.variableDeclarator(
|
5215
5302
|
getterFnIdentifier,
|
5216
5303
|
callRuntime(
|
5217
5304
|
"nodeRef",
|
5218
|
-
|
5219
|
-
|
5305
|
+
import_compiler33.types.stringLiteral(getterId),
|
5306
|
+
import_compiler33.types.stringLiteral(
|
5220
5307
|
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
|
5221
5308
|
)
|
5222
5309
|
)
|
@@ -5229,22 +5316,22 @@ var native_tag_default = {
|
|
5229
5316
|
const referenceSection = getSection(reference);
|
5230
5317
|
if (isInvokedFunction(reference)) {
|
5231
5318
|
reference.parentPath.replaceWith(
|
5232
|
-
|
5319
|
+
import_compiler33.types.expressionStatement(
|
5233
5320
|
createScopeReadExpression(referenceSection, nodeRef2)
|
5234
5321
|
)
|
5235
5322
|
);
|
5236
5323
|
} else if (getterFnIdentifier) {
|
5237
5324
|
reference.replaceWith(
|
5238
|
-
|
5325
|
+
import_compiler33.types.callExpression(getterFnIdentifier, [
|
5239
5326
|
getScopeExpression(referenceSection, getSection(tag))
|
5240
5327
|
])
|
5241
5328
|
);
|
5242
5329
|
} else {
|
5243
5330
|
reference.replaceWith(
|
5244
|
-
|
5245
|
-
|
5331
|
+
import_compiler33.types.expressionStatement(
|
5332
|
+
import_compiler33.types.memberExpression(
|
5246
5333
|
getScopeExpression(section, referenceSection),
|
5247
|
-
|
5334
|
+
import_compiler33.types.stringLiteral(
|
5248
5335
|
getAccessorPrefix().Getter + getScopeAccessorLiteral(nodeRef2).value
|
5249
5336
|
),
|
5250
5337
|
true
|
@@ -5280,7 +5367,7 @@ var native_tag_default = {
|
|
5280
5367
|
"render",
|
5281
5368
|
section,
|
5282
5369
|
referencedBindings,
|
5283
|
-
|
5370
|
+
import_compiler33.types.expressionStatement(
|
5284
5371
|
callRuntime(helper, scopeIdentifier, visitAccessor, ...values)
|
5285
5372
|
)
|
5286
5373
|
);
|
@@ -5288,7 +5375,7 @@ var native_tag_default = {
|
|
5288
5375
|
"effect",
|
5289
5376
|
section,
|
5290
5377
|
void 0,
|
5291
|
-
|
5378
|
+
import_compiler33.types.expressionStatement(
|
5292
5379
|
callRuntime(`${helper}_effect`, scopeIdentifier, visitAccessor)
|
5293
5380
|
)
|
5294
5381
|
);
|
@@ -5303,20 +5390,20 @@ var native_tag_default = {
|
|
5303
5390
|
valueChange: staticControllable.attrs[1]?.value || buildUndefined()
|
5304
5391
|
});
|
5305
5392
|
} else if (spreadExpression) {
|
5306
|
-
const spreadIdentifier =
|
5393
|
+
const spreadIdentifier = generateUidIdentifier("select_input");
|
5307
5394
|
tag.insertBefore(
|
5308
|
-
|
5309
|
-
|
5395
|
+
import_compiler33.types.variableDeclaration("const", [
|
5396
|
+
import_compiler33.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
5310
5397
|
])
|
5311
5398
|
);
|
5312
5399
|
htmlSelectArgs.set(tag.node, {
|
5313
|
-
value:
|
5400
|
+
value: import_compiler33.types.memberExpression(
|
5314
5401
|
spreadIdentifier,
|
5315
|
-
|
5402
|
+
import_compiler33.types.identifier("value")
|
5316
5403
|
),
|
5317
|
-
valueChange:
|
5404
|
+
valueChange: import_compiler33.types.memberExpression(
|
5318
5405
|
spreadIdentifier,
|
5319
|
-
|
5406
|
+
import_compiler33.types.identifier("valueChange")
|
5320
5407
|
)
|
5321
5408
|
});
|
5322
5409
|
spreadExpression = spreadIdentifier;
|
@@ -5328,16 +5415,16 @@ var native_tag_default = {
|
|
5328
5415
|
value = staticControllable.attrs[0]?.value;
|
5329
5416
|
valueChange = staticControllable.attrs[1]?.value;
|
5330
5417
|
} else if (spreadExpression) {
|
5331
|
-
const spreadIdentifier =
|
5418
|
+
const spreadIdentifier = generateUidIdentifier("textarea_input");
|
5332
5419
|
tag.insertBefore(
|
5333
|
-
|
5334
|
-
|
5420
|
+
import_compiler33.types.variableDeclaration("const", [
|
5421
|
+
import_compiler33.types.variableDeclarator(spreadIdentifier, spreadExpression)
|
5335
5422
|
])
|
5336
5423
|
);
|
5337
|
-
value =
|
5338
|
-
valueChange =
|
5424
|
+
value = import_compiler33.types.memberExpression(spreadIdentifier, import_compiler33.types.identifier("value"));
|
5425
|
+
valueChange = import_compiler33.types.memberExpression(
|
5339
5426
|
spreadIdentifier,
|
5340
|
-
|
5427
|
+
import_compiler33.types.identifier("valueChange")
|
5341
5428
|
);
|
5342
5429
|
spreadExpression = spreadIdentifier;
|
5343
5430
|
}
|
@@ -5373,10 +5460,10 @@ var native_tag_default = {
|
|
5373
5460
|
"render",
|
5374
5461
|
section,
|
5375
5462
|
valueReferences,
|
5376
|
-
|
5463
|
+
import_compiler33.types.expressionStatement(
|
5377
5464
|
callRuntime(
|
5378
5465
|
helper,
|
5379
|
-
|
5466
|
+
import_compiler33.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
5380
5467
|
value
|
5381
5468
|
)
|
5382
5469
|
)
|
@@ -5391,18 +5478,18 @@ var native_tag_default = {
|
|
5391
5478
|
if (isEventHandler(name3)) {
|
5392
5479
|
addHTMLEffectCall(section, valueReferences);
|
5393
5480
|
} else {
|
5394
|
-
write2`${callRuntime("attr",
|
5481
|
+
write2`${callRuntime("attr", import_compiler33.types.stringLiteral(name3), value)}`;
|
5395
5482
|
}
|
5396
5483
|
} else if (isEventHandler(name3)) {
|
5397
5484
|
addStatement(
|
5398
5485
|
"effect",
|
5399
5486
|
section,
|
5400
5487
|
valueReferences,
|
5401
|
-
|
5488
|
+
import_compiler33.types.expressionStatement(
|
5402
5489
|
callRuntime(
|
5403
5490
|
"on",
|
5404
|
-
|
5405
|
-
|
5491
|
+
import_compiler33.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
5492
|
+
import_compiler33.types.stringLiteral(getEventHandlerName(name3)),
|
5406
5493
|
value
|
5407
5494
|
)
|
5408
5495
|
)
|
@@ -5412,11 +5499,11 @@ var native_tag_default = {
|
|
5412
5499
|
"render",
|
5413
5500
|
section,
|
5414
5501
|
valueReferences,
|
5415
|
-
|
5502
|
+
import_compiler33.types.expressionStatement(
|
5416
5503
|
callRuntime(
|
5417
5504
|
"attr",
|
5418
|
-
|
5419
|
-
|
5505
|
+
import_compiler33.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
5506
|
+
import_compiler33.types.stringLiteral(name3),
|
5420
5507
|
value
|
5421
5508
|
)
|
5422
5509
|
)
|
@@ -5439,7 +5526,7 @@ var native_tag_default = {
|
|
5439
5526
|
"render",
|
5440
5527
|
section,
|
5441
5528
|
extra.referencedBindings,
|
5442
|
-
|
5529
|
+
import_compiler33.types.expressionStatement(
|
5443
5530
|
callRuntime(
|
5444
5531
|
"partialAttrs",
|
5445
5532
|
scopeIdentifier,
|
@@ -5454,7 +5541,7 @@ var native_tag_default = {
|
|
5454
5541
|
"render",
|
5455
5542
|
section,
|
5456
5543
|
extra.referencedBindings,
|
5457
|
-
|
5544
|
+
import_compiler33.types.expressionStatement(
|
5458
5545
|
callRuntime(
|
5459
5546
|
"attrs",
|
5460
5547
|
scopeIdentifier,
|
@@ -5468,7 +5555,7 @@ var native_tag_default = {
|
|
5468
5555
|
"effect",
|
5469
5556
|
section,
|
5470
5557
|
extra.referencedBindings,
|
5471
|
-
|
5558
|
+
import_compiler33.types.expressionStatement(
|
5472
5559
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
5473
5560
|
),
|
5474
5561
|
false
|
@@ -5489,7 +5576,7 @@ var native_tag_default = {
|
|
5489
5576
|
write2`>`;
|
5490
5577
|
}
|
5491
5578
|
if (isHTML && extra.tagNameNullable) {
|
5492
|
-
tag.insertBefore(
|
5579
|
+
tag.insertBefore(import_compiler33.types.ifStatement(name2.node, consumeHTML(tag)))[0].skip();
|
5493
5580
|
}
|
5494
5581
|
if (writeAtStartOfBody) {
|
5495
5582
|
write2`${writeAtStartOfBody}`;
|
@@ -5510,16 +5597,16 @@ var native_tag_default = {
|
|
5510
5597
|
writeTo(tag)`</${tag.node.name}>`;
|
5511
5598
|
flushInto(tag);
|
5512
5599
|
tag.insertBefore(
|
5513
|
-
|
5600
|
+
import_compiler33.types.expressionStatement(
|
5514
5601
|
callRuntime(
|
5515
5602
|
"controllable_select_value",
|
5516
5603
|
getScopeIdIdentifier(getSection(tag)),
|
5517
5604
|
getScopeAccessorLiteral(nodeRef2),
|
5518
5605
|
selectArgs.value,
|
5519
5606
|
selectArgs.valueChange,
|
5520
|
-
|
5607
|
+
import_compiler33.types.arrowFunctionExpression(
|
5521
5608
|
[],
|
5522
|
-
|
5609
|
+
import_compiler33.types.blockStatement(tag.node.body.body)
|
5523
5610
|
)
|
5524
5611
|
)
|
5525
5612
|
)
|
@@ -5543,7 +5630,7 @@ var native_tag_default = {
|
|
5543
5630
|
}
|
5544
5631
|
if (isHTML && extra.tagNameNullable) {
|
5545
5632
|
tag.insertBefore(
|
5546
|
-
|
5633
|
+
import_compiler33.types.ifStatement(tag.node.name, consumeHTML(tag))
|
5547
5634
|
)[0].skip();
|
5548
5635
|
}
|
5549
5636
|
if (shouldMark) {
|
@@ -5566,7 +5653,7 @@ function getUsedAttrs(tagName, tag) {
|
|
5566
5653
|
for (let i = attributes.length; i--; ) {
|
5567
5654
|
const attr2 = attributes[i];
|
5568
5655
|
const { value } = attr2;
|
5569
|
-
if (
|
5656
|
+
if (import_compiler33.types.isMarkoSpreadAttribute(attr2)) {
|
5570
5657
|
if (!spreadProps) {
|
5571
5658
|
spreadProps = [];
|
5572
5659
|
staticControllable = getRelatedControllable(tagName, seen);
|
@@ -5580,7 +5667,7 @@ function getUsedAttrs(tagName, tag) {
|
|
5580
5667
|
staticControllable = void 0;
|
5581
5668
|
}
|
5582
5669
|
}
|
5583
|
-
spreadProps.push(
|
5670
|
+
spreadProps.push(import_compiler33.types.spreadElement(value));
|
5584
5671
|
} else if (!seen[attr2.name]) {
|
5585
5672
|
seen[attr2.name] = attr2;
|
5586
5673
|
if (spreadProps) {
|
@@ -5610,16 +5697,16 @@ function getUsedAttrs(tagName, tag) {
|
|
5610
5697
|
for (const attr2 of staticControllable.attrs) {
|
5611
5698
|
if (attr2) {
|
5612
5699
|
(skipProps ||= []).push(
|
5613
|
-
toObjectProperty(attr2.name,
|
5700
|
+
toObjectProperty(attr2.name, import_compiler33.types.numericLiteral(1))
|
5614
5701
|
);
|
5615
5702
|
}
|
5616
5703
|
}
|
5617
5704
|
}
|
5618
5705
|
for (const { name: name2 } of staticAttrs) {
|
5619
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
5706
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler33.types.numericLiteral(1)));
|
5620
5707
|
}
|
5621
5708
|
if (skipProps) {
|
5622
|
-
skipExpression =
|
5709
|
+
skipExpression = import_compiler33.types.objectExpression(skipProps);
|
5623
5710
|
}
|
5624
5711
|
spreadExpression = propsToExpression(spreadProps);
|
5625
5712
|
}
|
@@ -5634,7 +5721,7 @@ function isChangeHandler(propName) {
|
|
5634
5721
|
return /^(?:value|checked(?:Value)?|open)Change/.test(propName);
|
5635
5722
|
}
|
5636
5723
|
function buildUndefined() {
|
5637
|
-
return
|
5724
|
+
return import_compiler33.types.unaryExpression("void", import_compiler33.types.numericLiteral(0));
|
5638
5725
|
}
|
5639
5726
|
|
5640
5727
|
// src/translator/util/is-only-child-in-parent.ts
|
@@ -5756,20 +5843,20 @@ var for_default = {
|
|
5756
5843
|
const forTagArgs = getBaseArgsInForTag(forType, forAttrs);
|
5757
5844
|
const forTagHTMLRuntime = serializeReason ? forTypeToHTMLResumeRuntime(forType, singleNodeOptimization) : forTypeToRuntime(forType);
|
5758
5845
|
forTagArgs.push(
|
5759
|
-
|
5846
|
+
import_compiler35.types.arrowFunctionExpression(params, import_compiler35.types.blockStatement(bodyStatements))
|
5760
5847
|
);
|
5761
5848
|
if (serializeReason) {
|
5762
5849
|
forTagArgs.push(
|
5763
|
-
forAttrs.by ||
|
5850
|
+
forAttrs.by || import_compiler35.types.numericLiteral(0),
|
5764
5851
|
getScopeIdIdentifier(tagSection),
|
5765
5852
|
getScopeAccessorLiteral(nodeRef2)
|
5766
5853
|
);
|
5767
5854
|
if (onlyChildInParentOptimization) {
|
5768
|
-
forTagArgs.push(
|
5855
|
+
forTagArgs.push(import_compiler35.types.numericLiteral(1));
|
5769
5856
|
}
|
5770
5857
|
}
|
5771
5858
|
statements.push(
|
5772
|
-
|
5859
|
+
import_compiler35.types.expressionStatement(callRuntime(forTagHTMLRuntime, ...forTagArgs))
|
5773
5860
|
);
|
5774
5861
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
5775
5862
|
replacement.skip();
|
@@ -5814,7 +5901,7 @@ var for_default = {
|
|
5814
5901
|
return callRuntime(
|
5815
5902
|
forTypeToDOMRuntime(forType),
|
5816
5903
|
getScopeAccessorLiteral(nodeRef2),
|
5817
|
-
|
5904
|
+
import_compiler35.types.identifier(bodySection.name)
|
5818
5905
|
);
|
5819
5906
|
};
|
5820
5907
|
const params = node.body.params;
|
@@ -5845,7 +5932,7 @@ var for_default = {
|
|
5845
5932
|
tagSection,
|
5846
5933
|
referencedBindings,
|
5847
5934
|
signal,
|
5848
|
-
|
5935
|
+
import_compiler35.types.arrayExpression(loopArgs)
|
5849
5936
|
);
|
5850
5937
|
tag.remove();
|
5851
5938
|
}
|
@@ -5911,11 +5998,11 @@ var for_default = {
|
|
5911
5998
|
]
|
5912
5999
|
};
|
5913
6000
|
function buildForRuntimeCall(type, attrs2, params, statements) {
|
5914
|
-
return
|
6001
|
+
return import_compiler35.types.expressionStatement(
|
5915
6002
|
callRuntime(
|
5916
6003
|
forTypeToRuntime(type),
|
5917
6004
|
...getBaseArgsInForTag(type, attrs2),
|
5918
|
-
|
6005
|
+
import_compiler35.types.arrowFunctionExpression(params, import_compiler35.types.blockStatement(statements))
|
5919
6006
|
)
|
5920
6007
|
);
|
5921
6008
|
}
|
@@ -5981,8 +6068,8 @@ function getBaseArgsInForTag(type, attrs2) {
|
|
5981
6068
|
case "to":
|
5982
6069
|
return [
|
5983
6070
|
attrs2.to,
|
5984
|
-
attrs2.from ||
|
5985
|
-
attrs2.step ||
|
6071
|
+
attrs2.from || import_compiler35.types.numericLiteral(0),
|
6072
|
+
attrs2.step || import_compiler35.types.numericLiteral(1)
|
5986
6073
|
];
|
5987
6074
|
}
|
5988
6075
|
}
|
@@ -6000,8 +6087,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
6000
6087
|
seen.add(attrTagMeta.name);
|
6001
6088
|
if (attrTagMeta.dynamic) {
|
6002
6089
|
statements.push(
|
6003
|
-
|
6004
|
-
|
6090
|
+
import_compiler36.types.variableDeclaration("let", [
|
6091
|
+
import_compiler36.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta))
|
6005
6092
|
])
|
6006
6093
|
);
|
6007
6094
|
properties.push(
|
@@ -6083,8 +6170,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
6083
6170
|
seen.add(contentKey);
|
6084
6171
|
const contentExpression = buildContent(tag.get("body"));
|
6085
6172
|
if (contentExpression) {
|
6086
|
-
const contentProp =
|
6087
|
-
|
6173
|
+
const contentProp = import_compiler36.types.objectProperty(
|
6174
|
+
import_compiler36.types.identifier(contentKey),
|
6088
6175
|
contentExpression
|
6089
6176
|
);
|
6090
6177
|
contentProps.add(contentProp);
|
@@ -6095,8 +6182,8 @@ function translateAttrs(tag, templateExports, statements = [], contentKey = "con
|
|
6095
6182
|
for (let i = attributes.length; i--; ) {
|
6096
6183
|
const attr2 = attributes[i];
|
6097
6184
|
const { value } = attr2;
|
6098
|
-
if (
|
6099
|
-
properties.push(
|
6185
|
+
if (import_compiler36.types.isMarkoSpreadAttribute(attr2)) {
|
6186
|
+
properties.push(import_compiler36.types.spreadElement(value));
|
6100
6187
|
} else if (!seen.has(attr2.name) && usesExport(templateExports, attr2.name)) {
|
6101
6188
|
seen.add(attr2.name);
|
6102
6189
|
properties.push(toObjectProperty(attr2.name, value));
|
@@ -6126,8 +6213,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
6126
6213
|
);
|
6127
6214
|
if (attrTagMeta.repeated) {
|
6128
6215
|
statements.push(
|
6129
|
-
|
6130
|
-
|
6216
|
+
import_compiler36.types.expressionStatement(
|
6217
|
+
import_compiler36.types.assignmentExpression(
|
6131
6218
|
"=",
|
6132
6219
|
getAttrTagIdentifier(attrTagMeta),
|
6133
6220
|
callRuntime(
|
@@ -6140,8 +6227,8 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
6140
6227
|
);
|
6141
6228
|
} else {
|
6142
6229
|
statements.push(
|
6143
|
-
|
6144
|
-
|
6230
|
+
import_compiler36.types.expressionStatement(
|
6231
|
+
import_compiler36.types.assignmentExpression(
|
6145
6232
|
"=",
|
6146
6233
|
getAttrTagIdentifier(attrTagMeta),
|
6147
6234
|
callRuntime(
|
@@ -6180,7 +6267,7 @@ function addDynamicAttrTagStatements(attrTags2, index, attrTagLookup, statements
|
|
6180
6267
|
return index;
|
6181
6268
|
}
|
6182
6269
|
function propsToExpression(props) {
|
6183
|
-
return props.length === 1 &&
|
6270
|
+
return props.length === 1 && import_compiler36.types.isSpreadElement(props[0]) ? props[0].argument : import_compiler36.types.objectExpression(props);
|
6184
6271
|
}
|
6185
6272
|
function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
6186
6273
|
const forTag = attrTags2[index];
|
@@ -6205,9 +6292,9 @@ function translateForAttrTag(attrTags2, index, attrTagLookup, statements, templa
|
|
6205
6292
|
function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templateExports, contentKey) {
|
6206
6293
|
const ifTag = attrTags2[index];
|
6207
6294
|
const consequentStatements = [];
|
6208
|
-
let ifStatement =
|
6295
|
+
let ifStatement = import_compiler36.types.ifStatement(
|
6209
6296
|
getConditionTestValue(ifTag),
|
6210
|
-
|
6297
|
+
import_compiler36.types.blockStatement(consequentStatements)
|
6211
6298
|
);
|
6212
6299
|
statements.push(ifStatement);
|
6213
6300
|
addAllAttrTagsAsDynamic(
|
@@ -6234,14 +6321,14 @@ function translateIfAttrTag(attrTags2, index, attrTagLookup, statements, templat
|
|
6234
6321
|
contentKey
|
6235
6322
|
);
|
6236
6323
|
if (testValue) {
|
6237
|
-
ifStatement.alternate = ifStatement =
|
6324
|
+
ifStatement.alternate = ifStatement = import_compiler36.types.ifStatement(
|
6238
6325
|
testValue,
|
6239
|
-
|
6326
|
+
import_compiler36.types.blockStatement(alternateStatements)
|
6240
6327
|
);
|
6241
6328
|
nextIndex++;
|
6242
6329
|
continue;
|
6243
6330
|
} else {
|
6244
|
-
ifStatement.alternate =
|
6331
|
+
ifStatement.alternate = import_compiler36.types.blockStatement(alternateStatements);
|
6245
6332
|
break;
|
6246
6333
|
}
|
6247
6334
|
}
|
@@ -6298,10 +6385,10 @@ function buildContent(body) {
|
|
6298
6385
|
const serialized = isSerializedSection(bodySection);
|
6299
6386
|
return callRuntime(
|
6300
6387
|
serialized ? "registerContent" : "createContent",
|
6301
|
-
|
6302
|
-
|
6388
|
+
import_compiler36.types.stringLiteral(getResumeRegisterId(bodySection, "renderer")),
|
6389
|
+
import_compiler36.types.arrowFunctionExpression(
|
6303
6390
|
body.node.params,
|
6304
|
-
|
6391
|
+
import_compiler36.types.blockStatement(body.node.body)
|
6305
6392
|
),
|
6306
6393
|
serialized ? getScopeIdIdentifier(
|
6307
6394
|
getSection(
|
@@ -6312,7 +6399,7 @@ function buildContent(body) {
|
|
6312
6399
|
) : void 0
|
6313
6400
|
);
|
6314
6401
|
} else {
|
6315
|
-
return
|
6402
|
+
return import_compiler36.types.callExpression(import_compiler36.types.identifier(bodySection.name), [
|
6316
6403
|
scopeIdentifier
|
6317
6404
|
]);
|
6318
6405
|
}
|
@@ -6397,7 +6484,7 @@ var define_default = {
|
|
6397
6484
|
};
|
6398
6485
|
|
6399
6486
|
// src/translator/core/effect.ts
|
6400
|
-
var
|
6487
|
+
var import_compiler38 = require("@marko/compiler");
|
6401
6488
|
var import_babel_utils22 = require("@marko/compiler/babel-utils");
|
6402
6489
|
var effect_default = {
|
6403
6490
|
migrate: [
|
@@ -6413,8 +6500,8 @@ var effect_default = {
|
|
6413
6500
|
fix() {
|
6414
6501
|
const { node } = tag;
|
6415
6502
|
tag.replaceWith(
|
6416
|
-
|
6417
|
-
withPreviousLocation(
|
6503
|
+
import_compiler38.types.markoTag(
|
6504
|
+
withPreviousLocation(import_compiler38.types.stringLiteral("script"), node.name),
|
6418
6505
|
node.attributes,
|
6419
6506
|
node.body,
|
6420
6507
|
node.arguments,
|
@@ -6451,7 +6538,7 @@ var export_default = {
|
|
6451
6538
|
};
|
6452
6539
|
|
6453
6540
|
// src/translator/core/html-comment.ts
|
6454
|
-
var
|
6541
|
+
var import_compiler39 = require("@marko/compiler");
|
6455
6542
|
var import_babel_utils24 = require("@marko/compiler/babel-utils");
|
6456
6543
|
var kCommentTagBinding = Symbol("comment tag binding");
|
6457
6544
|
var kGetterId2 = Symbol("node getter id");
|
@@ -6464,7 +6551,7 @@ var html_comment_default = {
|
|
6464
6551
|
let needsBinding = false;
|
6465
6552
|
let needsGetter = false;
|
6466
6553
|
if (tagVar) {
|
6467
|
-
if (!
|
6554
|
+
if (!import_compiler39.types.isIdentifier(tagVar)) {
|
6468
6555
|
throw tag.get("var").buildCodeFrameError(
|
6469
6556
|
"The `html-comment` tag variable cannot be destructured."
|
6470
6557
|
);
|
@@ -6516,7 +6603,7 @@ var html_comment_default = {
|
|
6516
6603
|
callRuntime(
|
6517
6604
|
"nodeRef",
|
6518
6605
|
getterId && getScopeIdIdentifier(getSection(tag)),
|
6519
|
-
getterId &&
|
6606
|
+
getterId && import_compiler39.types.stringLiteral(getterId)
|
6520
6607
|
)
|
6521
6608
|
);
|
6522
6609
|
} else {
|
@@ -6524,16 +6611,14 @@ var html_comment_default = {
|
|
6524
6611
|
const references = tag.scope.getBinding(varName).referencePaths;
|
6525
6612
|
let getterFnIdentifier;
|
6526
6613
|
if (getterId) {
|
6527
|
-
getterFnIdentifier = (
|
6528
|
-
|
6529
|
-
|
6530
|
-
|
6531
|
-
import_compiler38.types.variableDeclaration("const", [
|
6532
|
-
import_compiler38.types.variableDeclarator(
|
6614
|
+
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
6615
|
+
(0, import_compiler39.getProgram)().node.body.push(
|
6616
|
+
import_compiler39.types.variableDeclaration("const", [
|
6617
|
+
import_compiler39.types.variableDeclarator(
|
6533
6618
|
getterFnIdentifier,
|
6534
6619
|
callRuntime(
|
6535
6620
|
"nodeRef",
|
6536
|
-
|
6621
|
+
import_compiler39.types.stringLiteral(getterId),
|
6537
6622
|
getScopeAccessorLiteral(commentBinding)
|
6538
6623
|
)
|
6539
6624
|
)
|
@@ -6544,13 +6629,13 @@ var html_comment_default = {
|
|
6544
6629
|
const referenceSection = getSection(reference);
|
6545
6630
|
if (isInvokedFunction(reference)) {
|
6546
6631
|
reference.parentPath.replaceWith(
|
6547
|
-
|
6632
|
+
import_compiler39.types.expressionStatement(
|
6548
6633
|
createScopeReadExpression(referenceSection, commentBinding)
|
6549
6634
|
)
|
6550
6635
|
);
|
6551
6636
|
} else if (getterFnIdentifier) {
|
6552
6637
|
reference.replaceWith(
|
6553
|
-
|
6638
|
+
import_compiler39.types.callExpression(getterFnIdentifier, [
|
6554
6639
|
getScopeExpression(referenceSection, getSection(tag))
|
6555
6640
|
])
|
6556
6641
|
);
|
@@ -6570,9 +6655,9 @@ var html_comment_default = {
|
|
6570
6655
|
const write2 = writeTo(tag);
|
6571
6656
|
if (isOutputHTML()) {
|
6572
6657
|
for (const child of tag.node.body.body) {
|
6573
|
-
if (
|
6658
|
+
if (import_compiler39.types.isMarkoText(child)) {
|
6574
6659
|
write2`${child.value}`;
|
6575
|
-
} else if (
|
6660
|
+
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6576
6661
|
write2`${callRuntime("escapeXML", child.value)}`;
|
6577
6662
|
}
|
6578
6663
|
}
|
@@ -6581,10 +6666,10 @@ var html_comment_default = {
|
|
6581
6666
|
const templateExpressions = [];
|
6582
6667
|
let currentQuasi = "";
|
6583
6668
|
for (const child of tag.node.body.body) {
|
6584
|
-
if (
|
6669
|
+
if (import_compiler39.types.isMarkoText(child)) {
|
6585
6670
|
currentQuasi += child.value;
|
6586
|
-
} else if (
|
6587
|
-
templateQuasis.push(
|
6671
|
+
} else if (import_compiler39.types.isMarkoPlaceholder(child)) {
|
6672
|
+
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6588
6673
|
templateExpressions.push(child.value);
|
6589
6674
|
currentQuasi = "";
|
6590
6675
|
}
|
@@ -6592,20 +6677,20 @@ var html_comment_default = {
|
|
6592
6677
|
if (templateExpressions.length === 0) {
|
6593
6678
|
write2`${currentQuasi}`;
|
6594
6679
|
} else {
|
6595
|
-
templateQuasis.push(
|
6680
|
+
templateQuasis.push(import_compiler39.types.templateElement({ raw: currentQuasi }));
|
6596
6681
|
addStatement(
|
6597
6682
|
"render",
|
6598
6683
|
getSection(tag),
|
6599
6684
|
tagExtra.referencedBindings,
|
6600
|
-
|
6685
|
+
import_compiler39.types.expressionStatement(
|
6601
6686
|
callRuntime(
|
6602
6687
|
"data",
|
6603
|
-
|
6688
|
+
import_compiler39.types.memberExpression(
|
6604
6689
|
scopeIdentifier,
|
6605
6690
|
getScopeAccessorLiteral(commentBinding),
|
6606
6691
|
true
|
6607
6692
|
),
|
6608
|
-
|
6693
|
+
import_compiler39.types.templateLiteral(templateQuasis, templateExpressions)
|
6609
6694
|
)
|
6610
6695
|
)
|
6611
6696
|
);
|
@@ -6632,7 +6717,7 @@ var html_comment_default = {
|
|
6632
6717
|
};
|
6633
6718
|
|
6634
6719
|
// src/translator/core/html-script.ts
|
6635
|
-
var
|
6720
|
+
var import_compiler40 = require("@marko/compiler");
|
6636
6721
|
var import_babel_utils25 = require("@marko/compiler/babel-utils");
|
6637
6722
|
var kGetterId3 = Symbol("node getter id");
|
6638
6723
|
var html_script_default = {
|
@@ -6640,7 +6725,7 @@ var html_script_default = {
|
|
6640
6725
|
(0, import_babel_utils25.assertNoArgs)(tag);
|
6641
6726
|
(0, import_babel_utils25.assertNoParams)(tag);
|
6642
6727
|
const { node } = tag;
|
6643
|
-
if (node.var && !
|
6728
|
+
if (node.var && !import_compiler40.types.isIdentifier(node.var)) {
|
6644
6729
|
throw tag.get("var").buildCodeFrameError(
|
6645
6730
|
"Tag variables on native elements cannot be destructured."
|
6646
6731
|
);
|
@@ -6653,7 +6738,7 @@ var html_script_default = {
|
|
6653
6738
|
let spreadReferenceNodes;
|
6654
6739
|
for (let i = attributes.length; i--; ) {
|
6655
6740
|
const attr2 = attributes[i];
|
6656
|
-
if (
|
6741
|
+
if (import_compiler40.types.isMarkoAttribute(attr2)) {
|
6657
6742
|
if (seen[attr2.name]) {
|
6658
6743
|
dropReferences(attr2.value);
|
6659
6744
|
continue;
|
@@ -6665,14 +6750,14 @@ var html_script_default = {
|
|
6665
6750
|
} else if (!evaluate(attr2.value).confident) {
|
6666
6751
|
hasDynamicAttributes = true;
|
6667
6752
|
}
|
6668
|
-
} else if (
|
6753
|
+
} else if (import_compiler40.types.isMarkoSpreadAttribute(attr2)) {
|
6669
6754
|
hasEventHandlers = true;
|
6670
6755
|
hasDynamicAttributes = true;
|
6671
6756
|
(attr2.value.extra ??= {}).isEffect = true;
|
6672
6757
|
}
|
6673
6758
|
if (spreadReferenceNodes) {
|
6674
6759
|
spreadReferenceNodes.push(attr2.value);
|
6675
|
-
} else if (
|
6760
|
+
} else if (import_compiler40.types.isMarkoSpreadAttribute(attr2)) {
|
6676
6761
|
spreadReferenceNodes = [attr2.value];
|
6677
6762
|
}
|
6678
6763
|
}
|
@@ -6682,10 +6767,10 @@ var html_script_default = {
|
|
6682
6767
|
const bodyPlaceholderNodes = [];
|
6683
6768
|
let hasBodyPlaceholders = false;
|
6684
6769
|
for (const child of tag.node.body.body) {
|
6685
|
-
if (
|
6770
|
+
if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
6686
6771
|
bodyPlaceholderNodes.push(child.value);
|
6687
6772
|
hasBodyPlaceholders = true;
|
6688
|
-
} else if (!
|
6773
|
+
} else if (!import_compiler40.types.isMarkoText(child)) {
|
6689
6774
|
throw tag.hub.buildError(
|
6690
6775
|
child,
|
6691
6776
|
"Invalid child. Only text is allowed inside an html-script."
|
@@ -6700,7 +6785,7 @@ var html_script_default = {
|
|
6700
6785
|
);
|
6701
6786
|
}
|
6702
6787
|
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
6703
|
-
(0,
|
6788
|
+
(0, import_compiler40.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
|
6704
6789
|
const tagExtra = node.extra ??= {};
|
6705
6790
|
const bindingName = "#script";
|
6706
6791
|
tagExtra[kSerializeMarker] = hasEventHandlers || !!node.var;
|
@@ -6740,7 +6825,7 @@ var html_script_default = {
|
|
6740
6825
|
callRuntime(
|
6741
6826
|
"nodeRef",
|
6742
6827
|
getterId && getScopeIdIdentifier(section),
|
6743
|
-
getterId &&
|
6828
|
+
getterId && import_compiler40.types.stringLiteral(getterId)
|
6744
6829
|
)
|
6745
6830
|
);
|
6746
6831
|
} else {
|
@@ -6748,16 +6833,14 @@ var html_script_default = {
|
|
6748
6833
|
const references = tag.scope.getBinding(varName).referencePaths;
|
6749
6834
|
let getterFnIdentifier;
|
6750
6835
|
if (getterId) {
|
6751
|
-
getterFnIdentifier = (
|
6752
|
-
|
6753
|
-
|
6754
|
-
|
6755
|
-
import_compiler39.types.variableDeclaration("const", [
|
6756
|
-
import_compiler39.types.variableDeclarator(
|
6836
|
+
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
6837
|
+
(0, import_compiler40.getProgram)().node.body.push(
|
6838
|
+
import_compiler40.types.variableDeclaration("const", [
|
6839
|
+
import_compiler40.types.variableDeclarator(
|
6757
6840
|
getterFnIdentifier,
|
6758
6841
|
callRuntime(
|
6759
6842
|
"nodeRef",
|
6760
|
-
|
6843
|
+
import_compiler40.types.stringLiteral(getterId),
|
6761
6844
|
getScopeAccessorLiteral(nodeRef2)
|
6762
6845
|
)
|
6763
6846
|
)
|
@@ -6768,13 +6851,13 @@ var html_script_default = {
|
|
6768
6851
|
const referenceSection = getSection(reference);
|
6769
6852
|
if (isInvokedFunction(reference)) {
|
6770
6853
|
reference.parentPath.replaceWith(
|
6771
|
-
|
6854
|
+
import_compiler40.types.expressionStatement(
|
6772
6855
|
createScopeReadExpression(referenceSection, nodeRef2)
|
6773
6856
|
)
|
6774
6857
|
);
|
6775
6858
|
} else if (getterFnIdentifier) {
|
6776
6859
|
reference.replaceWith(
|
6777
|
-
|
6860
|
+
import_compiler40.types.callExpression(getterFnIdentifier, [
|
6778
6861
|
getScopeExpression(referenceSection, getSection(tag))
|
6779
6862
|
])
|
6780
6863
|
);
|
@@ -6807,10 +6890,10 @@ var html_script_default = {
|
|
6807
6890
|
"render",
|
6808
6891
|
section,
|
6809
6892
|
valueReferences,
|
6810
|
-
|
6893
|
+
import_compiler40.types.expressionStatement(
|
6811
6894
|
callRuntime(
|
6812
6895
|
helper,
|
6813
|
-
|
6896
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6814
6897
|
value
|
6815
6898
|
)
|
6816
6899
|
)
|
@@ -6825,18 +6908,18 @@ var html_script_default = {
|
|
6825
6908
|
if (isEventHandler(name2)) {
|
6826
6909
|
addHTMLEffectCall(section, valueReferences);
|
6827
6910
|
} else {
|
6828
|
-
write2`${callRuntime("attr",
|
6911
|
+
write2`${callRuntime("attr", import_compiler40.types.stringLiteral(name2), value)}`;
|
6829
6912
|
}
|
6830
6913
|
} else if (isEventHandler(name2)) {
|
6831
6914
|
addStatement(
|
6832
6915
|
"effect",
|
6833
6916
|
section,
|
6834
6917
|
valueReferences,
|
6835
|
-
|
6918
|
+
import_compiler40.types.expressionStatement(
|
6836
6919
|
callRuntime(
|
6837
6920
|
"on",
|
6838
|
-
|
6839
|
-
|
6921
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6922
|
+
import_compiler40.types.stringLiteral(getEventHandlerName(name2)),
|
6840
6923
|
value
|
6841
6924
|
)
|
6842
6925
|
)
|
@@ -6846,11 +6929,11 @@ var html_script_default = {
|
|
6846
6929
|
"render",
|
6847
6930
|
section,
|
6848
6931
|
valueReferences,
|
6849
|
-
|
6932
|
+
import_compiler40.types.expressionStatement(
|
6850
6933
|
callRuntime(
|
6851
6934
|
"attr",
|
6852
|
-
|
6853
|
-
|
6935
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
6936
|
+
import_compiler40.types.stringLiteral(name2),
|
6854
6937
|
value
|
6855
6938
|
)
|
6856
6939
|
)
|
@@ -6863,9 +6946,9 @@ var html_script_default = {
|
|
6863
6946
|
if (isHTML) {
|
6864
6947
|
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
6865
6948
|
if (skipExpression) {
|
6866
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section),
|
6949
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("script"))}`;
|
6867
6950
|
} else {
|
6868
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section),
|
6951
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler40.types.stringLiteral("script"))}`;
|
6869
6952
|
}
|
6870
6953
|
} else {
|
6871
6954
|
if (skipExpression) {
|
@@ -6873,7 +6956,7 @@ var html_script_default = {
|
|
6873
6956
|
"render",
|
6874
6957
|
section,
|
6875
6958
|
tagExtra.referencedBindings,
|
6876
|
-
|
6959
|
+
import_compiler40.types.expressionStatement(
|
6877
6960
|
callRuntime(
|
6878
6961
|
"partialAttrs",
|
6879
6962
|
scopeIdentifier,
|
@@ -6888,7 +6971,7 @@ var html_script_default = {
|
|
6888
6971
|
"render",
|
6889
6972
|
section,
|
6890
6973
|
tagExtra.referencedBindings,
|
6891
|
-
|
6974
|
+
import_compiler40.types.expressionStatement(
|
6892
6975
|
callRuntime(
|
6893
6976
|
"attrs",
|
6894
6977
|
scopeIdentifier,
|
@@ -6902,7 +6985,7 @@ var html_script_default = {
|
|
6902
6985
|
"effect",
|
6903
6986
|
section,
|
6904
6987
|
tagExtra.referencedBindings,
|
6905
|
-
|
6988
|
+
import_compiler40.types.expressionStatement(
|
6906
6989
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
6907
6990
|
),
|
6908
6991
|
false
|
@@ -6919,9 +7002,9 @@ var html_script_default = {
|
|
6919
7002
|
const visitAccessor = nodeRef2 && getScopeAccessorLiteral(nodeRef2);
|
6920
7003
|
if (isOutputHTML()) {
|
6921
7004
|
for (const child of tag.node.body.body) {
|
6922
|
-
if (
|
7005
|
+
if (import_compiler40.types.isMarkoText(child)) {
|
6923
7006
|
write2`${child.value}`;
|
6924
|
-
} else if (
|
7007
|
+
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
6925
7008
|
write2`${callRuntime("escapeScript", child.value)}`;
|
6926
7009
|
}
|
6927
7010
|
}
|
@@ -6931,11 +7014,11 @@ var html_script_default = {
|
|
6931
7014
|
let currentQuasi = "";
|
6932
7015
|
let referencePlaceholder;
|
6933
7016
|
for (const child of tag.node.body.body) {
|
6934
|
-
if (
|
7017
|
+
if (import_compiler40.types.isMarkoText(child)) {
|
6935
7018
|
currentQuasi += child.value;
|
6936
|
-
} else if (
|
7019
|
+
} else if (import_compiler40.types.isMarkoPlaceholder(child)) {
|
6937
7020
|
referencePlaceholder ||= child;
|
6938
|
-
templateQuasis.push(
|
7021
|
+
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
6939
7022
|
templateExpressions.push(child.value);
|
6940
7023
|
currentQuasi = "";
|
6941
7024
|
}
|
@@ -6943,16 +7026,16 @@ var html_script_default = {
|
|
6943
7026
|
if (!referencePlaceholder) {
|
6944
7027
|
write2`${currentQuasi}`;
|
6945
7028
|
} else {
|
6946
|
-
templateQuasis.push(
|
7029
|
+
templateQuasis.push(import_compiler40.types.templateElement({ raw: currentQuasi }));
|
6947
7030
|
addStatement(
|
6948
7031
|
"render",
|
6949
7032
|
getSection(tag),
|
6950
7033
|
referencePlaceholder.value.extra?.referencedBindings,
|
6951
|
-
|
7034
|
+
import_compiler40.types.expressionStatement(
|
6952
7035
|
callRuntime(
|
6953
7036
|
"textContent",
|
6954
|
-
|
6955
|
-
|
7037
|
+
import_compiler40.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7038
|
+
import_compiler40.types.templateLiteral(templateQuasis, templateExpressions)
|
6956
7039
|
)
|
6957
7040
|
)
|
6958
7041
|
);
|
@@ -6992,11 +7075,11 @@ function getUsedAttrs2(tag) {
|
|
6992
7075
|
for (let i = attributes.length; i--; ) {
|
6993
7076
|
const attr2 = attributes[i];
|
6994
7077
|
const { value } = attr2;
|
6995
|
-
if (
|
7078
|
+
if (import_compiler40.types.isMarkoSpreadAttribute(attr2)) {
|
6996
7079
|
if (!spreadProps) {
|
6997
7080
|
spreadProps = [];
|
6998
7081
|
}
|
6999
|
-
spreadProps.push(
|
7082
|
+
spreadProps.push(import_compiler40.types.spreadElement(value));
|
7000
7083
|
} else if (!seen[attr2.name]) {
|
7001
7084
|
seen[attr2.name] = attr2;
|
7002
7085
|
if (spreadProps) {
|
@@ -7010,10 +7093,10 @@ function getUsedAttrs2(tag) {
|
|
7010
7093
|
if (spreadProps) {
|
7011
7094
|
spreadProps.reverse();
|
7012
7095
|
for (const { name: name2 } of staticAttrs) {
|
7013
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
7096
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler40.types.numericLiteral(1)));
|
7014
7097
|
}
|
7015
7098
|
if (skipProps) {
|
7016
|
-
skipExpression =
|
7099
|
+
skipExpression = import_compiler40.types.objectExpression(skipProps);
|
7017
7100
|
}
|
7018
7101
|
spreadExpression = propsToExpression(spreadProps);
|
7019
7102
|
}
|
@@ -7025,7 +7108,7 @@ function getUsedAttrs2(tag) {
|
|
7025
7108
|
}
|
7026
7109
|
|
7027
7110
|
// src/translator/core/html-style.ts
|
7028
|
-
var
|
7111
|
+
var import_compiler41 = require("@marko/compiler");
|
7029
7112
|
var import_babel_utils26 = require("@marko/compiler/babel-utils");
|
7030
7113
|
var kGetterId4 = Symbol("node getter id");
|
7031
7114
|
var html_style_default = {
|
@@ -7033,7 +7116,7 @@ var html_style_default = {
|
|
7033
7116
|
(0, import_babel_utils26.assertNoArgs)(tag);
|
7034
7117
|
(0, import_babel_utils26.assertNoParams)(tag);
|
7035
7118
|
const { node } = tag;
|
7036
|
-
if (node.var && !
|
7119
|
+
if (node.var && !import_compiler41.types.isIdentifier(node.var)) {
|
7037
7120
|
throw tag.get("var").buildCodeFrameError(
|
7038
7121
|
"Tag variables on native elements cannot be destructured."
|
7039
7122
|
);
|
@@ -7046,7 +7129,7 @@ var html_style_default = {
|
|
7046
7129
|
let spreadReferenceNodes;
|
7047
7130
|
for (let i = attributes.length; i--; ) {
|
7048
7131
|
const attr2 = attributes[i];
|
7049
|
-
if (
|
7132
|
+
if (import_compiler41.types.isMarkoAttribute(attr2)) {
|
7050
7133
|
if (seen[attr2.name]) {
|
7051
7134
|
dropReferences(attr2.value);
|
7052
7135
|
continue;
|
@@ -7058,14 +7141,14 @@ var html_style_default = {
|
|
7058
7141
|
} else if (!evaluate(attr2.value).confident) {
|
7059
7142
|
hasDynamicAttributes = true;
|
7060
7143
|
}
|
7061
|
-
} else if (
|
7144
|
+
} else if (import_compiler41.types.isMarkoSpreadAttribute(attr2)) {
|
7062
7145
|
hasEventHandlers = true;
|
7063
7146
|
hasDynamicAttributes = true;
|
7064
7147
|
(attr2.value.extra ??= {}).isEffect = true;
|
7065
7148
|
}
|
7066
7149
|
if (spreadReferenceNodes) {
|
7067
7150
|
spreadReferenceNodes.push(attr2.value);
|
7068
|
-
} else if (
|
7151
|
+
} else if (import_compiler41.types.isMarkoSpreadAttribute(attr2)) {
|
7069
7152
|
spreadReferenceNodes = [attr2.value];
|
7070
7153
|
}
|
7071
7154
|
}
|
@@ -7075,10 +7158,10 @@ var html_style_default = {
|
|
7075
7158
|
const bodyPlaceholderNodes = [];
|
7076
7159
|
let hasBodyPlaceholders = false;
|
7077
7160
|
for (const child of tag.node.body.body) {
|
7078
|
-
if (
|
7161
|
+
if (import_compiler41.types.isMarkoPlaceholder(child)) {
|
7079
7162
|
bodyPlaceholderNodes.push(child.value);
|
7080
7163
|
hasBodyPlaceholders = true;
|
7081
|
-
} else if (!
|
7164
|
+
} else if (!import_compiler41.types.isMarkoText(child)) {
|
7082
7165
|
throw tag.hub.buildError(
|
7083
7166
|
child,
|
7084
7167
|
"Invalid child. Only text is allowed inside an html-style."
|
@@ -7093,7 +7176,7 @@ var html_style_default = {
|
|
7093
7176
|
);
|
7094
7177
|
}
|
7095
7178
|
if (node.var || hasEventHandlers || hasDynamicAttributes || hasBodyPlaceholders) {
|
7096
|
-
(0,
|
7179
|
+
(0, import_compiler41.getProgram)().node.extra.isInteractive ||= hasEventHandlers;
|
7097
7180
|
const tagExtra = node.extra ??= {};
|
7098
7181
|
const bindingName = "#style";
|
7099
7182
|
tagExtra[kSerializeMarker] = hasEventHandlers || !!node.var;
|
@@ -7133,7 +7216,7 @@ var html_style_default = {
|
|
7133
7216
|
callRuntime(
|
7134
7217
|
"nodeRef",
|
7135
7218
|
getterId && getScopeIdIdentifier(section),
|
7136
|
-
getterId &&
|
7219
|
+
getterId && import_compiler41.types.stringLiteral(getterId)
|
7137
7220
|
)
|
7138
7221
|
);
|
7139
7222
|
} else {
|
@@ -7141,16 +7224,14 @@ var html_style_default = {
|
|
7141
7224
|
const references = tag.scope.getBinding(varName).referencePaths;
|
7142
7225
|
let getterFnIdentifier;
|
7143
7226
|
if (getterId) {
|
7144
|
-
getterFnIdentifier = (
|
7145
|
-
|
7146
|
-
|
7147
|
-
|
7148
|
-
import_compiler40.types.variableDeclaration("const", [
|
7149
|
-
import_compiler40.types.variableDeclarator(
|
7227
|
+
getterFnIdentifier = generateUidIdentifier(`get_${varName}`);
|
7228
|
+
(0, import_compiler41.getProgram)().node.body.push(
|
7229
|
+
import_compiler41.types.variableDeclaration("const", [
|
7230
|
+
import_compiler41.types.variableDeclarator(
|
7150
7231
|
getterFnIdentifier,
|
7151
7232
|
callRuntime(
|
7152
7233
|
"nodeRef",
|
7153
|
-
|
7234
|
+
import_compiler41.types.stringLiteral(getterId),
|
7154
7235
|
getScopeAccessorLiteral(nodeRef2)
|
7155
7236
|
)
|
7156
7237
|
)
|
@@ -7161,13 +7242,13 @@ var html_style_default = {
|
|
7161
7242
|
const referenceSection = getSection(reference);
|
7162
7243
|
if (isInvokedFunction(reference)) {
|
7163
7244
|
reference.parentPath.replaceWith(
|
7164
|
-
|
7245
|
+
import_compiler41.types.expressionStatement(
|
7165
7246
|
createScopeReadExpression(referenceSection, nodeRef2)
|
7166
7247
|
)
|
7167
7248
|
);
|
7168
7249
|
} else if (getterFnIdentifier) {
|
7169
7250
|
reference.replaceWith(
|
7170
|
-
|
7251
|
+
import_compiler41.types.callExpression(getterFnIdentifier, [
|
7171
7252
|
getScopeExpression(referenceSection, getSection(tag))
|
7172
7253
|
])
|
7173
7254
|
);
|
@@ -7200,10 +7281,10 @@ var html_style_default = {
|
|
7200
7281
|
"render",
|
7201
7282
|
section,
|
7202
7283
|
valueReferences,
|
7203
|
-
|
7284
|
+
import_compiler41.types.expressionStatement(
|
7204
7285
|
callRuntime(
|
7205
7286
|
helper,
|
7206
|
-
|
7287
|
+
import_compiler41.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7207
7288
|
value
|
7208
7289
|
)
|
7209
7290
|
)
|
@@ -7218,18 +7299,18 @@ var html_style_default = {
|
|
7218
7299
|
if (isEventHandler(name2)) {
|
7219
7300
|
addHTMLEffectCall(section, valueReferences);
|
7220
7301
|
} else {
|
7221
|
-
write2`${callRuntime("attr",
|
7302
|
+
write2`${callRuntime("attr", import_compiler41.types.stringLiteral(name2), value)}`;
|
7222
7303
|
}
|
7223
7304
|
} else if (isEventHandler(name2)) {
|
7224
7305
|
addStatement(
|
7225
7306
|
"effect",
|
7226
7307
|
section,
|
7227
7308
|
valueReferences,
|
7228
|
-
|
7309
|
+
import_compiler41.types.expressionStatement(
|
7229
7310
|
callRuntime(
|
7230
7311
|
"on",
|
7231
|
-
|
7232
|
-
|
7312
|
+
import_compiler41.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7313
|
+
import_compiler41.types.stringLiteral(getEventHandlerName(name2)),
|
7233
7314
|
value
|
7234
7315
|
)
|
7235
7316
|
)
|
@@ -7239,11 +7320,11 @@ var html_style_default = {
|
|
7239
7320
|
"render",
|
7240
7321
|
section,
|
7241
7322
|
valueReferences,
|
7242
|
-
|
7323
|
+
import_compiler41.types.expressionStatement(
|
7243
7324
|
callRuntime(
|
7244
7325
|
"attr",
|
7245
|
-
|
7246
|
-
|
7326
|
+
import_compiler41.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7327
|
+
import_compiler41.types.stringLiteral(name2),
|
7247
7328
|
value
|
7248
7329
|
)
|
7249
7330
|
)
|
@@ -7256,9 +7337,9 @@ var html_style_default = {
|
|
7256
7337
|
if (isHTML) {
|
7257
7338
|
addHTMLEffectCall(section, tagExtra.referencedBindings);
|
7258
7339
|
if (skipExpression) {
|
7259
|
-
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section),
|
7340
|
+
write2`${callRuntime("partialAttrs", spreadExpression, skipExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler41.types.stringLiteral("style"))}`;
|
7260
7341
|
} else {
|
7261
|
-
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section),
|
7342
|
+
write2`${callRuntime("attrs", spreadExpression, visitAccessor, getScopeIdIdentifier(section), import_compiler41.types.stringLiteral("style"))}`;
|
7262
7343
|
}
|
7263
7344
|
} else {
|
7264
7345
|
if (skipExpression) {
|
@@ -7266,7 +7347,7 @@ var html_style_default = {
|
|
7266
7347
|
"render",
|
7267
7348
|
section,
|
7268
7349
|
tagExtra.referencedBindings,
|
7269
|
-
|
7350
|
+
import_compiler41.types.expressionStatement(
|
7270
7351
|
callRuntime(
|
7271
7352
|
"partialAttrs",
|
7272
7353
|
scopeIdentifier,
|
@@ -7281,7 +7362,7 @@ var html_style_default = {
|
|
7281
7362
|
"render",
|
7282
7363
|
section,
|
7283
7364
|
tagExtra.referencedBindings,
|
7284
|
-
|
7365
|
+
import_compiler41.types.expressionStatement(
|
7285
7366
|
callRuntime(
|
7286
7367
|
"attrs",
|
7287
7368
|
scopeIdentifier,
|
@@ -7295,7 +7376,7 @@ var html_style_default = {
|
|
7295
7376
|
"effect",
|
7296
7377
|
section,
|
7297
7378
|
tagExtra.referencedBindings,
|
7298
|
-
|
7379
|
+
import_compiler41.types.expressionStatement(
|
7299
7380
|
callRuntime("attrsEvents", scopeIdentifier, visitAccessor)
|
7300
7381
|
),
|
7301
7382
|
false
|
@@ -7312,9 +7393,9 @@ var html_style_default = {
|
|
7312
7393
|
enter2(tag);
|
7313
7394
|
if (isOutputHTML()) {
|
7314
7395
|
for (const child of tag.node.body.body) {
|
7315
|
-
if (
|
7396
|
+
if (import_compiler41.types.isMarkoText(child)) {
|
7316
7397
|
write2`${child.value}`;
|
7317
|
-
} else if (
|
7398
|
+
} else if (import_compiler41.types.isMarkoPlaceholder(child)) {
|
7318
7399
|
write2`${callRuntime("escapeStyle", child.value)}`;
|
7319
7400
|
}
|
7320
7401
|
}
|
@@ -7324,11 +7405,11 @@ var html_style_default = {
|
|
7324
7405
|
let currentQuasi = "";
|
7325
7406
|
let referencePlaceholder;
|
7326
7407
|
for (const child of tag.node.body.body) {
|
7327
|
-
if (
|
7408
|
+
if (import_compiler41.types.isMarkoText(child)) {
|
7328
7409
|
currentQuasi += child.value;
|
7329
|
-
} else if (
|
7410
|
+
} else if (import_compiler41.types.isMarkoPlaceholder(child)) {
|
7330
7411
|
referencePlaceholder ||= child;
|
7331
|
-
templateQuasis.push(
|
7412
|
+
templateQuasis.push(import_compiler41.types.templateElement({ raw: currentQuasi }));
|
7332
7413
|
templateExpressions.push(child.value);
|
7333
7414
|
currentQuasi = "";
|
7334
7415
|
}
|
@@ -7336,16 +7417,16 @@ var html_style_default = {
|
|
7336
7417
|
if (!referencePlaceholder) {
|
7337
7418
|
write2`${currentQuasi}`;
|
7338
7419
|
} else {
|
7339
|
-
templateQuasis.push(
|
7420
|
+
templateQuasis.push(import_compiler41.types.templateElement({ raw: currentQuasi }));
|
7340
7421
|
addStatement(
|
7341
7422
|
"render",
|
7342
7423
|
getSection(tag),
|
7343
7424
|
referencePlaceholder.value.extra?.referencedBindings,
|
7344
|
-
|
7425
|
+
import_compiler41.types.expressionStatement(
|
7345
7426
|
callRuntime(
|
7346
7427
|
"textContent",
|
7347
|
-
|
7348
|
-
|
7428
|
+
import_compiler41.types.memberExpression(scopeIdentifier, visitAccessor, true),
|
7429
|
+
import_compiler41.types.templateLiteral(templateQuasis, templateExpressions)
|
7349
7430
|
)
|
7350
7431
|
)
|
7351
7432
|
);
|
@@ -7380,11 +7461,11 @@ function getUsedAttrs3(tag) {
|
|
7380
7461
|
for (let i = attributes.length; i--; ) {
|
7381
7462
|
const attr2 = attributes[i];
|
7382
7463
|
const { value } = attr2;
|
7383
|
-
if (
|
7464
|
+
if (import_compiler41.types.isMarkoSpreadAttribute(attr2)) {
|
7384
7465
|
if (!spreadProps) {
|
7385
7466
|
spreadProps = [];
|
7386
7467
|
}
|
7387
|
-
spreadProps.push(
|
7468
|
+
spreadProps.push(import_compiler41.types.spreadElement(value));
|
7388
7469
|
} else if (!seen[attr2.name]) {
|
7389
7470
|
seen[attr2.name] = attr2;
|
7390
7471
|
if (spreadProps) {
|
@@ -7398,10 +7479,10 @@ function getUsedAttrs3(tag) {
|
|
7398
7479
|
if (spreadProps) {
|
7399
7480
|
spreadProps.reverse();
|
7400
7481
|
for (const { name: name2 } of staticAttrs) {
|
7401
|
-
(skipProps ||= []).push(toObjectProperty(name2,
|
7482
|
+
(skipProps ||= []).push(toObjectProperty(name2, import_compiler41.types.numericLiteral(1)));
|
7402
7483
|
}
|
7403
7484
|
if (skipProps) {
|
7404
|
-
skipExpression =
|
7485
|
+
skipExpression = import_compiler41.types.objectExpression(skipProps);
|
7405
7486
|
}
|
7406
7487
|
spreadExpression = propsToExpression(spreadProps);
|
7407
7488
|
}
|
@@ -7413,7 +7494,7 @@ function getUsedAttrs3(tag) {
|
|
7413
7494
|
}
|
7414
7495
|
|
7415
7496
|
// src/translator/core/id.ts
|
7416
|
-
var
|
7497
|
+
var import_compiler42 = require("@marko/compiler");
|
7417
7498
|
var import_babel_utils27 = require("@marko/compiler/babel-utils");
|
7418
7499
|
var id_default = {
|
7419
7500
|
analyze(tag) {
|
@@ -7426,7 +7507,7 @@ var id_default = {
|
|
7426
7507
|
if (!node.var) {
|
7427
7508
|
throw tag.get("name").buildCodeFrameError("The `id` tag requires a tag variable.");
|
7428
7509
|
}
|
7429
|
-
if (!
|
7510
|
+
if (!import_compiler42.types.isIdentifier(node.var)) {
|
7430
7511
|
throw tag.get("var").buildCodeFrameError("The `id` tag cannot be destructured");
|
7431
7512
|
}
|
7432
7513
|
trackVarReferences(tag, 4 /* derived */);
|
@@ -7437,7 +7518,7 @@ var id_default = {
|
|
7437
7518
|
const id = isOutputHTML() ? callRuntime("nextTagId") : callRuntime("nextTagId", scopeIdentifier);
|
7438
7519
|
if (isOutputHTML()) {
|
7439
7520
|
tag.replaceWith(
|
7440
|
-
|
7521
|
+
import_compiler42.types.variableDeclaration("const", [import_compiler42.types.variableDeclarator(node.var, id)])
|
7441
7522
|
);
|
7442
7523
|
} else {
|
7443
7524
|
const source = initValue(node.var.extra.binding);
|
@@ -7462,17 +7543,17 @@ var id_default = {
|
|
7462
7543
|
};
|
7463
7544
|
|
7464
7545
|
// src/translator/core/if.ts
|
7465
|
-
var
|
7546
|
+
var import_compiler44 = require("@marko/compiler");
|
7466
7547
|
var import_babel_utils28 = require("@marko/compiler/babel-utils");
|
7467
7548
|
|
7468
7549
|
// src/translator/util/to-first-statement-or-block.ts
|
7469
|
-
var
|
7550
|
+
var import_compiler43 = require("@marko/compiler");
|
7470
7551
|
function toFirstStatementOrBlock(body) {
|
7471
7552
|
if (Array.isArray(body)) {
|
7472
7553
|
if (body.length === 1) {
|
7473
7554
|
return body[0];
|
7474
7555
|
}
|
7475
|
-
return
|
7556
|
+
return import_compiler43.types.blockStatement(body);
|
7476
7557
|
}
|
7477
7558
|
return body;
|
7478
7559
|
}
|
@@ -7559,13 +7640,13 @@ var IfTag = {
|
|
7559
7640
|
const bodyStatements = branchTag.node.body.body;
|
7560
7641
|
if (serializeReason) {
|
7561
7642
|
bodyStatements.push(
|
7562
|
-
|
7643
|
+
import_compiler44.types.returnStatement(import_compiler44.types.numericLiteral(i))
|
7563
7644
|
);
|
7564
7645
|
}
|
7565
7646
|
const [testAttr] = branchTag.node.attributes;
|
7566
7647
|
const curStatement = toFirstStatementOrBlock(bodyStatements);
|
7567
7648
|
if (testAttr) {
|
7568
|
-
statement =
|
7649
|
+
statement = import_compiler44.types.ifStatement(
|
7569
7650
|
testAttr.value,
|
7570
7651
|
curStatement,
|
7571
7652
|
statement
|
@@ -7577,24 +7658,24 @@ var IfTag = {
|
|
7577
7658
|
}
|
7578
7659
|
if (serializeReason) {
|
7579
7660
|
const conditionSerializeReason = branchSources?.referenced;
|
7580
|
-
const cbNode =
|
7661
|
+
const cbNode = import_compiler44.types.arrowFunctionExpression(
|
7581
7662
|
[],
|
7582
|
-
|
7663
|
+
import_compiler44.types.blockStatement([statement])
|
7583
7664
|
);
|
7584
|
-
statement =
|
7665
|
+
statement = import_compiler44.types.expressionStatement(
|
7585
7666
|
singleNodeOptimization ? callRuntime(
|
7586
7667
|
"resumeSingleNodeConditional",
|
7587
7668
|
cbNode,
|
7588
7669
|
getScopeIdIdentifier(section),
|
7589
7670
|
getScopeAccessorLiteral(nodeRef2),
|
7590
|
-
conditionSerializeReason ?
|
7591
|
-
onlyChildInParentOptimization &&
|
7671
|
+
conditionSerializeReason ? import_compiler44.types.numericLiteral(1) : onlyChildInParentOptimization ? import_compiler44.types.numericLiteral(0) : void 0,
|
7672
|
+
onlyChildInParentOptimization && import_compiler44.types.numericLiteral(1)
|
7592
7673
|
) : callRuntime(
|
7593
7674
|
"resumeConditional",
|
7594
7675
|
cbNode,
|
7595
7676
|
getScopeIdIdentifier(section),
|
7596
7677
|
getScopeAccessorLiteral(nodeRef2),
|
7597
|
-
conditionSerializeReason ?
|
7678
|
+
conditionSerializeReason ? import_compiler44.types.numericLiteral(1) : void 0
|
7598
7679
|
)
|
7599
7680
|
);
|
7600
7681
|
}
|
@@ -7627,25 +7708,25 @@ var IfTag = {
|
|
7627
7708
|
const rootExtra = branches[0][0].node.extra;
|
7628
7709
|
const nodeRef2 = getOptimizedOnlyChildNodeRef(rootTag, section);
|
7629
7710
|
const rendererIdentifiers = [];
|
7630
|
-
let expr =
|
7711
|
+
let expr = import_compiler44.types.numericLiteral(branches.length);
|
7631
7712
|
for (let i = branches.length; i--; ) {
|
7632
7713
|
const [branchTag, branchBodySection] = branches[i];
|
7633
7714
|
const [testAttr] = branchTag.node.attributes;
|
7634
|
-
const consequent =
|
7715
|
+
const consequent = import_compiler44.types.numericLiteral(branchBodySection ? i : -1);
|
7635
7716
|
if (branchBodySection) {
|
7636
|
-
rendererIdentifiers.push(
|
7717
|
+
rendererIdentifiers.push(import_compiler44.types.identifier(branchBodySection.name));
|
7637
7718
|
setClosureSignalBuilder(branchTag, (closure, render) => {
|
7638
7719
|
return callRuntime(
|
7639
7720
|
"conditionalClosure",
|
7640
7721
|
getScopeAccessorLiteral(closure),
|
7641
7722
|
getScopeAccessorLiteral(nodeRef2),
|
7642
|
-
|
7723
|
+
import_compiler44.types.numericLiteral(i),
|
7643
7724
|
render
|
7644
7725
|
);
|
7645
7726
|
});
|
7646
7727
|
}
|
7647
7728
|
branchTag.remove();
|
7648
|
-
expr = testAttr ?
|
7729
|
+
expr = testAttr ? import_compiler44.types.conditionalExpression(testAttr.value, consequent, expr) : consequent;
|
7649
7730
|
}
|
7650
7731
|
const signal = getSignal(section, nodeRef2, "if");
|
7651
7732
|
signal.build = () => {
|
@@ -7727,7 +7808,7 @@ function assertHasBody(tag) {
|
|
7727
7808
|
function assertHasValueAttribute(tag) {
|
7728
7809
|
const { node } = tag;
|
7729
7810
|
const [valueAttr] = node.attributes;
|
7730
|
-
if (!
|
7811
|
+
if (!import_compiler44.types.isMarkoAttribute(valueAttr) || !valueAttr.default) {
|
7731
7812
|
throw tag.get("name").buildCodeFrameError(`The \`${getTagName(tag)}\` tag requires a value.`);
|
7732
7813
|
}
|
7733
7814
|
if (node.attributes.length > 1) {
|
@@ -7817,7 +7898,7 @@ var import_default = {
|
|
7817
7898
|
};
|
7818
7899
|
|
7819
7900
|
// src/translator/core/let.ts
|
7820
|
-
var
|
7901
|
+
var import_compiler45 = require("@marko/compiler");
|
7821
7902
|
var import_babel_utils30 = require("@marko/compiler/babel-utils");
|
7822
7903
|
var let_default = {
|
7823
7904
|
analyze(tag) {
|
@@ -7826,7 +7907,7 @@ var let_default = {
|
|
7826
7907
|
let valueAttr;
|
7827
7908
|
let valueChangeAttr;
|
7828
7909
|
for (const attr2 of node.attributes) {
|
7829
|
-
if (
|
7910
|
+
if (import_compiler45.types.isMarkoAttribute(attr2)) {
|
7830
7911
|
if (attr2.name === "value") {
|
7831
7912
|
valueAttr = attr2;
|
7832
7913
|
} else if (attr2.name === "valueChange") {
|
@@ -7854,7 +7935,7 @@ var let_default = {
|
|
7854
7935
|
if (!tagVar) {
|
7855
7936
|
throw tag.get("name").buildCodeFrameError("The `let` tag requires a tag variable.");
|
7856
7937
|
}
|
7857
|
-
if (!
|
7938
|
+
if (!import_compiler45.types.isIdentifier(tagVar)) {
|
7858
7939
|
throw tag.get("var").buildCodeFrameError("The `let` tag variable cannot be destructured.");
|
7859
7940
|
}
|
7860
7941
|
if (valueChangeAttr && (0, import_babel_utils30.computeNode)(valueChangeAttr.value)) {
|
@@ -7873,10 +7954,10 @@ var let_default = {
|
|
7873
7954
|
const { node } = tag;
|
7874
7955
|
const tagVar = node.var;
|
7875
7956
|
const valueAttr = node.attributes.find(
|
7876
|
-
(attr2) =>
|
7877
|
-
) ??
|
7957
|
+
(attr2) => import_compiler45.types.isMarkoAttribute(attr2) && (attr2.default || attr2.name === "value")
|
7958
|
+
) ?? import_compiler45.types.markoAttribute("value", import_compiler45.types.identifier("undefined"));
|
7878
7959
|
const valueChangeAttr = node.attributes.find(
|
7879
|
-
(attr2) =>
|
7960
|
+
(attr2) => import_compiler45.types.isMarkoAttribute(attr2) && attr2.name === "valueChange"
|
7880
7961
|
);
|
7881
7962
|
const section = getSection(tag);
|
7882
7963
|
const binding = tagVar.extra.binding;
|
@@ -7889,7 +7970,7 @@ var let_default = {
|
|
7889
7970
|
}
|
7890
7971
|
signal.buildAssignment = (valueSection, value) => {
|
7891
7972
|
const scope = getScopeExpression(valueSection, signal.section);
|
7892
|
-
return
|
7973
|
+
return import_compiler45.types.callExpression(signal.identifier, [scope, value]);
|
7893
7974
|
};
|
7894
7975
|
} else {
|
7895
7976
|
translateVar(tag, valueAttr.value, "let");
|
@@ -7920,7 +8001,7 @@ var let_default = {
|
|
7920
8001
|
};
|
7921
8002
|
|
7922
8003
|
// src/translator/core/lifecycle.ts
|
7923
|
-
var
|
8004
|
+
var import_compiler46 = require("@marko/compiler");
|
7924
8005
|
var import_babel_utils31 = require("@marko/compiler/babel-utils");
|
7925
8006
|
var kRef = Symbol("lifecycle attrs reference");
|
7926
8007
|
var lifecycle_default = {
|
@@ -7933,7 +8014,7 @@ var lifecycle_default = {
|
|
7933
8014
|
const tagExtra = node.extra ??= {};
|
7934
8015
|
const section = getOrCreateSection(tag);
|
7935
8016
|
tagExtra[kRef] = createBinding(
|
7936
|
-
|
8017
|
+
generateUid("lifecycle"),
|
7937
8018
|
4 /* derived */,
|
7938
8019
|
section,
|
7939
8020
|
void 0,
|
@@ -7945,14 +8026,14 @@ var lifecycle_default = {
|
|
7945
8026
|
);
|
7946
8027
|
}
|
7947
8028
|
for (const attr2 of node.attributes) {
|
7948
|
-
if (
|
8029
|
+
if (import_compiler46.types.isMarkoSpreadAttribute(attr2)) {
|
7949
8030
|
throw tag.get("name").buildCodeFrameError(
|
7950
8031
|
"The `lifecycle` tag does not support `...spread` attributes."
|
7951
8032
|
);
|
7952
8033
|
}
|
7953
8034
|
(attr2.value.extra ??= {}).isEffect = true;
|
7954
8035
|
}
|
7955
|
-
((0,
|
8036
|
+
((0, import_compiler46.getProgram)().node.extra ??= {}).isInteractive = true;
|
7956
8037
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
7957
8038
|
},
|
7958
8039
|
translate: {
|
@@ -7965,7 +8046,7 @@ var lifecycle_default = {
|
|
7965
8046
|
if (isOutputDOM()) {
|
7966
8047
|
const translatedAttrs = translateAttrs(tag);
|
7967
8048
|
translatedAttrs.statements.push(
|
7968
|
-
|
8049
|
+
import_compiler46.types.expressionStatement(
|
7969
8050
|
callRuntime(
|
7970
8051
|
"lifecycle",
|
7971
8052
|
scopeIdentifier,
|
@@ -8000,7 +8081,7 @@ var lifecycle_default = {
|
|
8000
8081
|
};
|
8001
8082
|
|
8002
8083
|
// src/translator/core/log.ts
|
8003
|
-
var
|
8084
|
+
var import_compiler47 = require("@marko/compiler");
|
8004
8085
|
var import_babel_utils32 = require("@marko/compiler/babel-utils");
|
8005
8086
|
var log_default = {
|
8006
8087
|
analyze(tag) {
|
@@ -8012,7 +8093,7 @@ var log_default = {
|
|
8012
8093
|
if (!valueAttr) {
|
8013
8094
|
throw tag.get("name").buildCodeFrameError("The `log` tag requires a value.");
|
8014
8095
|
}
|
8015
|
-
if (tag.node.attributes.length > 1 || !
|
8096
|
+
if (tag.node.attributes.length > 1 || !import_compiler47.types.isMarkoAttribute(valueAttr) || !valueAttr.default && valueAttr.name !== "value") {
|
8016
8097
|
throw tag.get("name").buildCodeFrameError(
|
8017
8098
|
"The `log` tag only supports the `value` attribute."
|
8018
8099
|
);
|
@@ -8024,9 +8105,9 @@ var log_default = {
|
|
8024
8105
|
const [valueAttr] = tag.node.attributes;
|
8025
8106
|
const { value } = valueAttr;
|
8026
8107
|
const referencedBindings = value.extra?.referencedBindings;
|
8027
|
-
const statement =
|
8028
|
-
|
8029
|
-
|
8108
|
+
const statement = import_compiler47.types.expressionStatement(
|
8109
|
+
import_compiler47.types.callExpression(
|
8110
|
+
import_compiler47.types.memberExpression(import_compiler47.types.identifier("console"), import_compiler47.types.identifier("log")),
|
8030
8111
|
[value]
|
8031
8112
|
)
|
8032
8113
|
);
|
@@ -8052,7 +8133,7 @@ var log_default = {
|
|
8052
8133
|
};
|
8053
8134
|
|
8054
8135
|
// src/translator/core/script.ts
|
8055
|
-
var
|
8136
|
+
var import_compiler48 = require("@marko/compiler");
|
8056
8137
|
var import_babel_utils33 = require("@marko/compiler/babel-utils");
|
8057
8138
|
var htmlScriptTagAlternateMsg = " For a native html `script` tag use the `html-script` core tag instead.";
|
8058
8139
|
var script_default = {
|
@@ -8074,12 +8155,12 @@ var script_default = {
|
|
8074
8155
|
const start = body[0]?.start;
|
8075
8156
|
const end = body[body.length - 1]?.end;
|
8076
8157
|
const bodyStatements = (0, import_babel_utils33.parseStatements)(tag.hub.file, code, start, end);
|
8077
|
-
const valueFn =
|
8158
|
+
const valueFn = import_compiler48.types.arrowFunctionExpression(
|
8078
8159
|
[],
|
8079
|
-
|
8160
|
+
import_compiler48.types.blockStatement(bodyStatements),
|
8080
8161
|
traverseContains(bodyStatements, isAwaitExpression)
|
8081
8162
|
);
|
8082
|
-
node.attributes.push(
|
8163
|
+
node.attributes.push(import_compiler48.types.markoAttribute("value", valueFn));
|
8083
8164
|
node.body.body = [];
|
8084
8165
|
}
|
8085
8166
|
},
|
@@ -8103,7 +8184,7 @@ var script_default = {
|
|
8103
8184
|
}
|
8104
8185
|
seenValueAttr = true;
|
8105
8186
|
(attr2.value.extra ??= {}).isEffect = true;
|
8106
|
-
((0,
|
8187
|
+
((0, import_compiler48.getProgram)().node.extra ??= {}).isInteractive = true;
|
8107
8188
|
} else {
|
8108
8189
|
throw tag.hub.buildError(
|
8109
8190
|
attr2,
|
@@ -8128,28 +8209,28 @@ var script_default = {
|
|
8128
8209
|
const referencedBindings = value.extra?.referencedBindings;
|
8129
8210
|
if (isOutputDOM()) {
|
8130
8211
|
const { value: value2 } = valueAttr;
|
8131
|
-
const isFunction2 =
|
8212
|
+
const isFunction2 = import_compiler48.types.isFunctionExpression(value2) || import_compiler48.types.isArrowFunctionExpression(value2);
|
8132
8213
|
let inlineBody = null;
|
8133
8214
|
if (isFunction2 && !(value2.async || value2.generator)) {
|
8134
|
-
if (
|
8215
|
+
if (import_compiler48.types.isBlockStatement(value2.body)) {
|
8135
8216
|
let hasDeclaration = false;
|
8136
8217
|
for (const child of value2.body.body) {
|
8137
|
-
if (
|
8218
|
+
if (import_compiler48.types.isDeclaration(child)) {
|
8138
8219
|
hasDeclaration = true;
|
8139
8220
|
break;
|
8140
8221
|
}
|
8141
8222
|
}
|
8142
8223
|
inlineBody = hasDeclaration ? value2.body : value2.body.body;
|
8143
8224
|
} else {
|
8144
|
-
inlineBody =
|
8225
|
+
inlineBody = import_compiler48.types.expressionStatement(value2.body);
|
8145
8226
|
}
|
8146
8227
|
}
|
8147
8228
|
addStatement(
|
8148
8229
|
"effect",
|
8149
8230
|
section,
|
8150
8231
|
referencedBindings,
|
8151
|
-
inlineBody ||
|
8152
|
-
|
8232
|
+
inlineBody || import_compiler48.types.expressionStatement(
|
8233
|
+
import_compiler48.types.callExpression(value2, isFunction2 ? [] : [scopeIdentifier])
|
8153
8234
|
)
|
8154
8235
|
);
|
8155
8236
|
} else {
|
@@ -8191,7 +8272,7 @@ function isAwaitExpression(node) {
|
|
8191
8272
|
}
|
8192
8273
|
|
8193
8274
|
// src/translator/core/server.ts
|
8194
|
-
var
|
8275
|
+
var import_compiler49 = require("@marko/compiler");
|
8195
8276
|
var import_babel_utils34 = require("@marko/compiler/babel-utils");
|
8196
8277
|
var server_default = {
|
8197
8278
|
parse(tag) {
|
@@ -8203,10 +8284,10 @@ var server_default = {
|
|
8203
8284
|
const code = rawValue.replace(/^server\s*/, "").trim();
|
8204
8285
|
const start = node.name.start + (rawValue.length - code.length);
|
8205
8286
|
let body = (0, import_babel_utils34.parseStatements)(file, code, start, start + code.length);
|
8206
|
-
if (body.length === 1 &&
|
8287
|
+
if (body.length === 1 && import_compiler49.types.isBlockStatement(body[0])) {
|
8207
8288
|
body = body[0].body;
|
8208
8289
|
}
|
8209
|
-
tag.replaceWith(
|
8290
|
+
tag.replaceWith(import_compiler49.types.markoScriptlet(body, true, "server"));
|
8210
8291
|
},
|
8211
8292
|
parseOptions: {
|
8212
8293
|
statement: true,
|
@@ -8222,7 +8303,7 @@ var server_default = {
|
|
8222
8303
|
};
|
8223
8304
|
|
8224
8305
|
// src/translator/core/static.ts
|
8225
|
-
var
|
8306
|
+
var import_compiler50 = require("@marko/compiler");
|
8226
8307
|
var import_babel_utils35 = require("@marko/compiler/babel-utils");
|
8227
8308
|
var static_default = {
|
8228
8309
|
parse(tag) {
|
@@ -8234,10 +8315,10 @@ var static_default = {
|
|
8234
8315
|
const code = rawValue.replace(/^static\s*/, "").trim();
|
8235
8316
|
const start = node.name.start + (rawValue.length - code.length);
|
8236
8317
|
let body = (0, import_babel_utils35.parseStatements)(file, code, start, start + code.length);
|
8237
|
-
if (body.length === 1 &&
|
8318
|
+
if (body.length === 1 && import_compiler50.types.isBlockStatement(body[0])) {
|
8238
8319
|
body = body[0].body;
|
8239
8320
|
}
|
8240
|
-
tag.replaceWith(
|
8321
|
+
tag.replaceWith(import_compiler50.types.markoScriptlet(body, true));
|
8241
8322
|
},
|
8242
8323
|
parseOptions: {
|
8243
8324
|
statement: true,
|
@@ -8253,7 +8334,7 @@ var static_default = {
|
|
8253
8334
|
};
|
8254
8335
|
|
8255
8336
|
// src/translator/core/style.ts
|
8256
|
-
var
|
8337
|
+
var import_compiler51 = require("@marko/compiler");
|
8257
8338
|
var import_babel_utils36 = require("@marko/compiler/babel-utils");
|
8258
8339
|
var import_magic_string = __toESM(require("magic-string"));
|
8259
8340
|
var import_path3 = __toESM(require("path"));
|
@@ -8329,20 +8410,20 @@ var style_default = {
|
|
8329
8410
|
});
|
8330
8411
|
if (importPath) {
|
8331
8412
|
if (!node.var) {
|
8332
|
-
(0,
|
8333
|
-
|
8413
|
+
(0, import_compiler51.getProgram)().node.body.push(
|
8414
|
+
import_compiler51.types.importDeclaration([], import_compiler51.types.stringLiteral(importPath))
|
8334
8415
|
);
|
8335
|
-
} else if (
|
8336
|
-
(0,
|
8337
|
-
|
8338
|
-
[
|
8339
|
-
|
8416
|
+
} else if (import_compiler51.types.isIdentifier(node.var)) {
|
8417
|
+
(0, import_compiler51.getProgram)().node.body.push(
|
8418
|
+
import_compiler51.types.importDeclaration(
|
8419
|
+
[import_compiler51.types.importDefaultSpecifier(node.var)],
|
8420
|
+
import_compiler51.types.stringLiteral(importPath)
|
8340
8421
|
)
|
8341
8422
|
);
|
8342
8423
|
} else {
|
8343
|
-
(0,
|
8344
|
-
|
8345
|
-
|
8424
|
+
(0, import_compiler51.getProgram)().node.body.push(
|
8425
|
+
import_compiler51.types.variableDeclaration("const", [
|
8426
|
+
import_compiler51.types.variableDeclarator(
|
8346
8427
|
node.var,
|
8347
8428
|
(0, import_babel_utils36.importDefault)(file, importPath, "style")
|
8348
8429
|
)
|
@@ -8362,7 +8443,7 @@ var style_default = {
|
|
8362
8443
|
};
|
8363
8444
|
|
8364
8445
|
// src/translator/core/try.ts
|
8365
|
-
var
|
8446
|
+
var import_compiler52 = require("@marko/compiler");
|
8366
8447
|
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
8367
8448
|
var kDOMBinding2 = Symbol("try tag dom binding");
|
8368
8449
|
var try_default = {
|
@@ -8422,7 +8503,7 @@ var try_default = {
|
|
8422
8503
|
writeHTMLResumeStatements(tagBody);
|
8423
8504
|
tag.insertBefore(translatedAttrs.statements);
|
8424
8505
|
tag.replaceWith(
|
8425
|
-
|
8506
|
+
import_compiler52.types.expressionStatement(
|
8426
8507
|
callRuntime(
|
8427
8508
|
"tryContent",
|
8428
8509
|
getScopeIdIdentifier(section),
|
@@ -8464,7 +8545,7 @@ var try_default = {
|
|
8464
8545
|
return callRuntime(
|
8465
8546
|
"createTry",
|
8466
8547
|
getScopeAccessorLiteral(nodeRef2),
|
8467
|
-
|
8548
|
+
import_compiler52.types.identifier(bodySection.name)
|
8468
8549
|
);
|
8469
8550
|
};
|
8470
8551
|
if (translatedAttrs.statements.length) {
|
@@ -8475,8 +8556,8 @@ var try_default = {
|
|
8475
8556
|
translatedAttrs.statements
|
8476
8557
|
);
|
8477
8558
|
}
|
8478
|
-
(0,
|
8479
|
-
|
8559
|
+
(0, import_compiler52.getProgram)().node.body.push(
|
8560
|
+
import_compiler52.types.expressionStatement(callRuntime("enableCatch"))
|
8480
8561
|
);
|
8481
8562
|
addValue(
|
8482
8563
|
section,
|
@@ -8574,7 +8655,7 @@ var document_type_default = {
|
|
8574
8655
|
};
|
8575
8656
|
|
8576
8657
|
// src/translator/visitors/function.ts
|
8577
|
-
var
|
8658
|
+
var import_compiler53 = require("@marko/compiler");
|
8578
8659
|
var import_babel_utils38 = require("@marko/compiler/babel-utils");
|
8579
8660
|
var functionIdsBySection = /* @__PURE__ */ new WeakMap();
|
8580
8661
|
var function_default = {
|
@@ -8591,13 +8672,13 @@ var function_default = {
|
|
8591
8672
|
}
|
8592
8673
|
const { node } = fn;
|
8593
8674
|
const extra = node.extra ??= {};
|
8594
|
-
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ?
|
8675
|
+
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler53.types.toIdentifier(
|
8595
8676
|
markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
|
8596
|
-
) : markoRoot.node.name :
|
8677
|
+
) : markoRoot.node.name : import_compiler53.types.isVariableDeclarator(fn.parent) && import_compiler53.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler53.types.isObjectMethod(node) && import_compiler53.types.isIdentifier(node.key) ? node.key.name : "anonymous");
|
8597
8678
|
const {
|
8598
8679
|
markoOpts,
|
8599
8680
|
opts: { filename }
|
8600
|
-
} = (0,
|
8681
|
+
} = (0, import_compiler53.getFile)();
|
8601
8682
|
const section = getSection(fn);
|
8602
8683
|
let functionNameCounts = functionIdsBySection.get(section);
|
8603
8684
|
if (!functionNameCounts) {
|
@@ -8654,10 +8735,10 @@ var import_declaration_default = {
|
|
8654
8735
|
};
|
8655
8736
|
|
8656
8737
|
// src/translator/visitors/placeholder.ts
|
8657
|
-
var
|
8738
|
+
var import_compiler55 = require("@marko/compiler");
|
8658
8739
|
|
8659
8740
|
// src/translator/util/is-non-html-text.ts
|
8660
|
-
var
|
8741
|
+
var import_compiler54 = require("@marko/compiler");
|
8661
8742
|
function isNonHTMLText(placeholder) {
|
8662
8743
|
const parentTag = placeholder.parentPath.isMarkoTagBody() && placeholder.parentPath.parentPath;
|
8663
8744
|
if (parentTag && isCoreTag(parentTag)) {
|
@@ -8695,7 +8776,8 @@ var placeholder_default = {
|
|
8695
8776
|
if (isNonHTMLText(placeholder)) return;
|
8696
8777
|
const { node } = placeholder;
|
8697
8778
|
const { value } = node;
|
8698
|
-
const
|
8779
|
+
const valueExtra = evaluate(value);
|
8780
|
+
const { confident, computed } = valueExtra;
|
8699
8781
|
if (confident && isVoid2(computed)) {
|
8700
8782
|
placeholder.remove();
|
8701
8783
|
return;
|
@@ -8706,7 +8788,7 @@ var placeholder_default = {
|
|
8706
8788
|
const nodeBinding = extra[kBinding];
|
8707
8789
|
const canWriteHTML = isHTML || confident && node.escape;
|
8708
8790
|
const method = canWriteHTML ? node.escape ? "escapeXML" : "toString" : node.escape ? "data" : "html";
|
8709
|
-
const serializeReason =
|
8791
|
+
const serializeReason = getDynamicSourcesForExtra(valueExtra);
|
8710
8792
|
const siblingText = extra[kSiblingText];
|
8711
8793
|
if (confident && canWriteHTML) {
|
8712
8794
|
write2`${getHTMLRuntime()[method](computed)}`;
|
@@ -8731,11 +8813,11 @@ var placeholder_default = {
|
|
8731
8813
|
addStatement(
|
8732
8814
|
"render",
|
8733
8815
|
getSection(placeholder),
|
8734
|
-
|
8735
|
-
|
8816
|
+
valueExtra.referencedBindings,
|
8817
|
+
import_compiler55.types.expressionStatement(
|
8736
8818
|
method === "data" ? callRuntime(
|
8737
8819
|
"data",
|
8738
|
-
|
8820
|
+
import_compiler55.types.memberExpression(
|
8739
8821
|
scopeIdentifier,
|
8740
8822
|
getScopeAccessorLiteral(nodeBinding),
|
8741
8823
|
true
|
@@ -8772,7 +8854,7 @@ function analyzeSiblingText(placeholder) {
|
|
8772
8854
|
break;
|
8773
8855
|
}
|
8774
8856
|
}
|
8775
|
-
if (!prev.node &&
|
8857
|
+
if (!prev.node && import_compiler55.types.isProgram(placeholder.parentPath)) {
|
8776
8858
|
return placeholderExtra[kSiblingText] = 1 /* Before */;
|
8777
8859
|
}
|
8778
8860
|
let next = placeholder.getNextSibling();
|
@@ -8789,7 +8871,7 @@ function analyzeSiblingText(placeholder) {
|
|
8789
8871
|
break;
|
8790
8872
|
}
|
8791
8873
|
}
|
8792
|
-
if (!next.node &&
|
8874
|
+
if (!next.node && import_compiler55.types.isProgram(placeholder.parentPath)) {
|
8793
8875
|
return placeholderExtra[kSiblingText] = 2 /* After */;
|
8794
8876
|
}
|
8795
8877
|
return placeholderExtra[kSiblingText] = 0 /* None */;
|
@@ -8799,7 +8881,7 @@ function isVoid2(value) {
|
|
8799
8881
|
}
|
8800
8882
|
|
8801
8883
|
// src/translator/visitors/referenced-identifier.ts
|
8802
|
-
var
|
8884
|
+
var import_compiler56 = require("@marko/compiler");
|
8803
8885
|
var abortIdsByExpressionForSection = /* @__PURE__ */ new WeakMap();
|
8804
8886
|
var referenced_identifier_default = {
|
8805
8887
|
migrate(identifier) {
|
@@ -8807,8 +8889,8 @@ var referenced_identifier_default = {
|
|
8807
8889
|
if (identifier.scope.hasBinding(name2)) return;
|
8808
8890
|
switch (name2) {
|
8809
8891
|
case "out":
|
8810
|
-
if (
|
8811
|
-
identifier.parentPath.replaceWith(
|
8892
|
+
if (import_compiler56.types.isMemberExpression(identifier.parent) && import_compiler56.types.isIdentifier(identifier.parent.property) && identifier.parent.property.name === "global") {
|
8893
|
+
identifier.parentPath.replaceWith(import_compiler56.types.identifier("$global"));
|
8812
8894
|
} else {
|
8813
8895
|
throw identifier.buildCodeFrameError(
|
8814
8896
|
"Only `out.global` is supported for compatibility."
|
@@ -8835,24 +8917,24 @@ var referenced_identifier_default = {
|
|
8835
8917
|
case "$global":
|
8836
8918
|
if (isOutputHTML()) {
|
8837
8919
|
identifier.replaceWith(
|
8838
|
-
|
8920
|
+
import_compiler56.types.callExpression(importRuntime("$global"), [])
|
8839
8921
|
);
|
8840
8922
|
} else {
|
8841
8923
|
identifier.replaceWith(
|
8842
|
-
|
8924
|
+
import_compiler56.types.memberExpression(scopeIdentifier, import_compiler56.types.identifier("$global"))
|
8843
8925
|
);
|
8844
8926
|
}
|
8845
8927
|
break;
|
8846
8928
|
case "$signal":
|
8847
8929
|
if (isOutputHTML()) {
|
8848
8930
|
identifier.replaceWith(
|
8849
|
-
|
8850
|
-
|
8931
|
+
import_compiler56.types.callExpression(
|
8932
|
+
import_compiler56.types.arrowFunctionExpression(
|
8851
8933
|
[],
|
8852
|
-
|
8853
|
-
|
8854
|
-
|
8855
|
-
|
8934
|
+
import_compiler56.types.blockStatement([
|
8935
|
+
import_compiler56.types.throwStatement(
|
8936
|
+
import_compiler56.types.newExpression(import_compiler56.types.identifier("Error"), [
|
8937
|
+
import_compiler56.types.stringLiteral("Cannot use $signal in a server render.")
|
8856
8938
|
])
|
8857
8939
|
)
|
8858
8940
|
])
|
@@ -8878,19 +8960,19 @@ var referenced_identifier_default = {
|
|
8878
8960
|
"render",
|
8879
8961
|
section,
|
8880
8962
|
exprRoot.node.extra?.referencedBindings,
|
8881
|
-
|
8882
|
-
|
8963
|
+
import_compiler56.types.expressionStatement(
|
8964
|
+
import_compiler56.types.callExpression(importRuntime("resetAbortSignal"), [
|
8883
8965
|
scopeIdentifier,
|
8884
|
-
|
8966
|
+
import_compiler56.types.numericLiteral(exprId)
|
8885
8967
|
])
|
8886
8968
|
),
|
8887
8969
|
false
|
8888
8970
|
);
|
8889
8971
|
}
|
8890
8972
|
identifier.replaceWith(
|
8891
|
-
|
8973
|
+
import_compiler56.types.callExpression(importRuntime("getAbortSignal"), [
|
8892
8974
|
scopeIdentifier,
|
8893
|
-
|
8975
|
+
import_compiler56.types.numericLiteral(exprId)
|
8894
8976
|
])
|
8895
8977
|
);
|
8896
8978
|
}
|
@@ -8930,11 +9012,11 @@ var scriptlet_default = {
|
|
8930
9012
|
};
|
8931
9013
|
|
8932
9014
|
// src/translator/visitors/tag/index.ts
|
8933
|
-
var
|
9015
|
+
var import_compiler60 = require("@marko/compiler");
|
8934
9016
|
var import_babel_utils43 = require("@marko/compiler/babel-utils");
|
8935
9017
|
|
8936
9018
|
// src/translator/visitors/tag/attribute-tag.ts
|
8937
|
-
var
|
9019
|
+
var import_compiler57 = require("@marko/compiler");
|
8938
9020
|
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
8939
9021
|
var attribute_tag_default = {
|
8940
9022
|
analyze: {
|
@@ -8965,7 +9047,7 @@ var attribute_tag_default = {
|
|
8965
9047
|
};
|
8966
9048
|
|
8967
9049
|
// src/translator/visitors/tag/custom-tag.ts
|
8968
|
-
var
|
9050
|
+
var import_compiler58 = require("@marko/compiler");
|
8969
9051
|
var import_babel_utils41 = require("@marko/compiler/babel-utils");
|
8970
9052
|
var import_path4 = __toESM(require("path"));
|
8971
9053
|
var kChildScopeBinding = Symbol("custom tag child scope");
|
@@ -9020,7 +9102,7 @@ var custom_tag_default = {
|
|
9020
9102
|
tag,
|
9021
9103
|
childProgramExtra?.domExports.input
|
9022
9104
|
);
|
9023
|
-
(0,
|
9105
|
+
(0, import_compiler58.getProgram)().node.extra.hasInteractiveChild = childProgramExtra?.isInteractive || childProgramExtra?.hasInteractiveChild || false;
|
9024
9106
|
}
|
9025
9107
|
}
|
9026
9108
|
},
|
@@ -9047,9 +9129,9 @@ function translateHTML(tag) {
|
|
9047
9129
|
let tagIdentifier;
|
9048
9130
|
flushInto(tag);
|
9049
9131
|
writeHTMLResumeStatements(tagBody);
|
9050
|
-
if (
|
9132
|
+
if (import_compiler58.types.isStringLiteral(node.name)) {
|
9051
9133
|
const relativePath = getTagRelativePath(tag);
|
9052
|
-
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ?
|
9134
|
+
tagIdentifier = isCircularRequest(tag.hub.file, relativePath) ? import_compiler58.types.identifier(getTemplateContentName()) : (0, import_babel_utils41.importDefault)(tag.hub.file, relativePath, getTagName(tag));
|
9053
9135
|
} else {
|
9054
9136
|
tagIdentifier = node.name;
|
9055
9137
|
}
|
@@ -9063,12 +9145,10 @@ function translateHTML(tag) {
|
|
9063
9145
|
const serializeReason = !!tagVar || getDynamicSourcesForExtras(tagExtra[kChildAttrExprs]);
|
9064
9146
|
if (serializeReason) {
|
9065
9147
|
const childScopeBinding = tagExtra[kChildScopeBinding];
|
9066
|
-
const peekScopeId =
|
9067
|
-
childScopeBinding?.name
|
9068
|
-
);
|
9148
|
+
const peekScopeId = generateUidIdentifier(childScopeBinding?.name);
|
9069
9149
|
tag.insertBefore(
|
9070
|
-
|
9071
|
-
|
9150
|
+
import_compiler58.types.variableDeclaration("const", [
|
9151
|
+
import_compiler58.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
|
9072
9152
|
])
|
9073
9153
|
);
|
9074
9154
|
setSerializedProperty(
|
@@ -9079,13 +9159,13 @@ function translateHTML(tag) {
|
|
9079
9159
|
);
|
9080
9160
|
if (tagVar) {
|
9081
9161
|
statements.push(
|
9082
|
-
|
9162
|
+
import_compiler58.types.expressionStatement(
|
9083
9163
|
callRuntime(
|
9084
9164
|
"setTagVar",
|
9085
9165
|
getScopeIdIdentifier(section),
|
9086
9166
|
getScopeAccessorLiteral(tag.node.extra[kChildOffsetScopeBinding]),
|
9087
9167
|
peekScopeId,
|
9088
|
-
|
9168
|
+
import_compiler58.types.stringLiteral(
|
9089
9169
|
getResumeRegisterId(
|
9090
9170
|
section,
|
9091
9171
|
node.var.extra?.binding,
|
@@ -9103,10 +9183,10 @@ function translateHTML(tag) {
|
|
9103
9183
|
let contentId = void 0;
|
9104
9184
|
if (contentProp) {
|
9105
9185
|
const contentExpression = contentProp.value;
|
9106
|
-
contentProp.value = contentId =
|
9186
|
+
contentProp.value = contentId = generateUidIdentifier("content");
|
9107
9187
|
const [contentPath] = tag.insertBefore(
|
9108
|
-
|
9109
|
-
|
9188
|
+
import_compiler58.types.variableDeclaration("const", [
|
9189
|
+
import_compiler58.types.variableDeclarator(
|
9110
9190
|
contentId,
|
9111
9191
|
// TODO: only register if needed (child template analysis)
|
9112
9192
|
contentExpression
|
@@ -9120,13 +9200,13 @@ function translateHTML(tag) {
|
|
9120
9200
|
propsToExpression(properties)
|
9121
9201
|
);
|
9122
9202
|
if (tagVar) {
|
9123
|
-
translateVar(tag,
|
9124
|
-
renderTagExpr =
|
9203
|
+
translateVar(tag, import_compiler58.types.unaryExpression("void", import_compiler58.types.numericLiteral(0)), "let");
|
9204
|
+
renderTagExpr = import_compiler58.types.assignmentExpression("=", tagVar, renderTagExpr);
|
9125
9205
|
}
|
9126
9206
|
statements.push(
|
9127
|
-
|
9207
|
+
import_compiler58.types.ifStatement(
|
9128
9208
|
tagIdentifier,
|
9129
|
-
|
9209
|
+
import_compiler58.types.expressionStatement(renderTagExpr),
|
9130
9210
|
contentId && callStatement(contentId)
|
9131
9211
|
)
|
9132
9212
|
);
|
@@ -9152,7 +9232,7 @@ function translateDOM(tag) {
|
|
9152
9232
|
const childScopeBinding = extra[kChildScopeBinding];
|
9153
9233
|
const write2 = writeTo(tag);
|
9154
9234
|
const { file } = tag.hub;
|
9155
|
-
const tagName =
|
9235
|
+
const tagName = import_compiler58.types.isIdentifier(node.name) ? node.name.name : import_compiler58.types.isStringLiteral(node.name) ? node.name.value : "tag";
|
9156
9236
|
const relativePath = getTagRelativePath(tag);
|
9157
9237
|
const childFile = (0, import_babel_utils41.loadFileForTag)(tag);
|
9158
9238
|
const childExports = childFile.ast.program.extra.domExports;
|
@@ -9184,7 +9264,7 @@ function translateDOM(tag) {
|
|
9184
9264
|
);
|
9185
9265
|
source.register = true;
|
9186
9266
|
source.buildAssignment = (valueSection, value) => {
|
9187
|
-
return
|
9267
|
+
return import_compiler58.types.callExpression(importRuntime("tagVarSignalChange"), [
|
9188
9268
|
createScopeReadExpression(valueSection, childScopeBinding),
|
9189
9269
|
value
|
9190
9270
|
]);
|
@@ -9193,7 +9273,7 @@ function translateDOM(tag) {
|
|
9193
9273
|
"render",
|
9194
9274
|
tagSection,
|
9195
9275
|
void 0,
|
9196
|
-
|
9276
|
+
import_compiler58.types.expressionStatement(
|
9197
9277
|
callRuntime(
|
9198
9278
|
"setTagVar",
|
9199
9279
|
scopeIdentifier,
|
@@ -9207,8 +9287,8 @@ function translateDOM(tag) {
|
|
9207
9287
|
"render",
|
9208
9288
|
tagSection,
|
9209
9289
|
void 0,
|
9210
|
-
|
9211
|
-
|
9290
|
+
import_compiler58.types.expressionStatement(
|
9291
|
+
import_compiler58.types.callExpression(tagIdentifier, [
|
9212
9292
|
createScopeReadExpression(tagSection, childScopeBinding)
|
9213
9293
|
])
|
9214
9294
|
)
|
@@ -9221,7 +9301,7 @@ function getTagRelativePath(tag) {
|
|
9221
9301
|
hub: { file }
|
9222
9302
|
} = tag;
|
9223
9303
|
let relativePath;
|
9224
|
-
if (
|
9304
|
+
if (import_compiler58.types.isStringLiteral(node.name)) {
|
9225
9305
|
const template = (0, import_babel_utils41.getTagTemplate)(tag);
|
9226
9306
|
relativePath = template && (0, import_babel_utils41.resolveRelativePath)(file, template);
|
9227
9307
|
} else if (node.extra?.tagNameImported) {
|
@@ -9314,7 +9394,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
9314
9394
|
let spreadReferenceNodes;
|
9315
9395
|
for (let i = attributes.length; i--; ) {
|
9316
9396
|
const attr2 = attributes[i];
|
9317
|
-
if (
|
9397
|
+
if (import_compiler58.types.isMarkoAttribute(attr2)) {
|
9318
9398
|
if (seen.has(attr2.name) || !templateExport.props[attr2.name]) {
|
9319
9399
|
dropReferences(attr2.value);
|
9320
9400
|
continue;
|
@@ -9323,7 +9403,7 @@ function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
|
9323
9403
|
}
|
9324
9404
|
if (spreadReferenceNodes) {
|
9325
9405
|
spreadReferenceNodes.push(attr2.value);
|
9326
|
-
} else if (
|
9406
|
+
} else if (import_compiler58.types.isMarkoSpreadAttribute(attr2)) {
|
9327
9407
|
spreadReferenceNodes = [attr2.value];
|
9328
9408
|
} else {
|
9329
9409
|
rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
|
@@ -9348,7 +9428,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9348
9428
|
// but we should probably ensure all other references are dropped in this case before we do that.
|
9349
9429
|
tag.node.extra?.referencedBindings,
|
9350
9430
|
identifierToSignal(tagInputIdentifier),
|
9351
|
-
|
9431
|
+
import_compiler58.types.isSpreadElement(arg) ? import_compiler58.types.memberExpression(arg.argument, import_compiler58.types.numericLiteral(0), true) : arg,
|
9352
9432
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
9353
9433
|
);
|
9354
9434
|
return;
|
@@ -9396,7 +9476,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9396
9476
|
} else {
|
9397
9477
|
attrTagCallsForTag.set(
|
9398
9478
|
attrTagName,
|
9399
|
-
translatedProps =
|
9479
|
+
translatedProps = import_compiler58.types.parenthesizedExpression(
|
9400
9480
|
callRuntime("attrTag", translatedProps)
|
9401
9481
|
)
|
9402
9482
|
);
|
@@ -9481,7 +9561,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9481
9561
|
childAttrExports.id,
|
9482
9562
|
`${importAlias}_${attrTagMeta.name}`
|
9483
9563
|
);
|
9484
|
-
decls.push(
|
9564
|
+
decls.push(import_compiler58.types.variableDeclarator(getAttrTagIdentifier(attrTagMeta)));
|
9485
9565
|
addValue(
|
9486
9566
|
info.tagSection,
|
9487
9567
|
referencedBindings,
|
@@ -9491,7 +9571,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9491
9571
|
);
|
9492
9572
|
}
|
9493
9573
|
addStatement("render", info.tagSection, referencedBindings, [
|
9494
|
-
|
9574
|
+
import_compiler58.types.variableDeclaration("let", decls),
|
9495
9575
|
...statements
|
9496
9576
|
]);
|
9497
9577
|
}
|
@@ -9511,7 +9591,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9511
9591
|
void 0,
|
9512
9592
|
// TODO: pretty sure content needs to have the reference group of it's param defaults.
|
9513
9593
|
identifierToSignal(contentExportIdentifier),
|
9514
|
-
|
9594
|
+
import_compiler58.types.callExpression(import_compiler58.types.identifier(bodySection.name), [scopeIdentifier]),
|
9515
9595
|
createScopeReadExpression(info.tagSection, info.childScopeBinding)
|
9516
9596
|
);
|
9517
9597
|
}
|
@@ -9521,7 +9601,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9521
9601
|
let spreadProps;
|
9522
9602
|
for (let i = attributes.length; i--; ) {
|
9523
9603
|
const attr2 = attributes[i];
|
9524
|
-
if (
|
9604
|
+
if (import_compiler58.types.isMarkoAttribute(attr2)) {
|
9525
9605
|
const childAttrExports = templateExport.props[attr2.name];
|
9526
9606
|
if (!childAttrExports || seen.has(attr2.name)) continue;
|
9527
9607
|
seen.add(attr2.name);
|
@@ -9531,9 +9611,9 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9531
9611
|
}
|
9532
9612
|
staticAttrs.push(attr2);
|
9533
9613
|
} else if (spreadProps) {
|
9534
|
-
spreadProps.push(
|
9614
|
+
spreadProps.push(import_compiler58.types.spreadElement(attr2.value));
|
9535
9615
|
} else {
|
9536
|
-
spreadProps = [
|
9616
|
+
spreadProps = [import_compiler58.types.spreadElement(attr2.value)];
|
9537
9617
|
}
|
9538
9618
|
}
|
9539
9619
|
for (const attr2 of staticAttrs.reverse()) {
|
@@ -9558,12 +9638,12 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9558
9638
|
const referencedBindings = tag.node.extra?.referencedBindings;
|
9559
9639
|
let getMissingPropValue = buildUndefined2;
|
9560
9640
|
if (spreadProps) {
|
9561
|
-
const spreadId =
|
9641
|
+
const spreadId = generateUidIdentifier(`${importAlias}_spread`);
|
9562
9642
|
spreadProps.reverse();
|
9563
9643
|
getMissingPropValue = (name2) => toMemberExpression(spreadId, name2);
|
9564
9644
|
addStatement("render", info.tagSection, referencedBindings, [
|
9565
|
-
|
9566
|
-
|
9645
|
+
import_compiler58.types.variableDeclaration("const", [
|
9646
|
+
import_compiler58.types.variableDeclarator(spreadId, propsToExpression(spreadProps))
|
9567
9647
|
])
|
9568
9648
|
]);
|
9569
9649
|
}
|
@@ -9587,7 +9667,7 @@ function writeAttrsToExports(tag, templateExport, importAlias, info) {
|
|
9587
9667
|
}
|
9588
9668
|
function importOrSelfReferenceName(file, request, name2, nameHint) {
|
9589
9669
|
if (isCircularRequest(file, request)) {
|
9590
|
-
return
|
9670
|
+
return import_compiler58.types.identifier(name2);
|
9591
9671
|
}
|
9592
9672
|
return (0, import_babel_utils41.importNamed)(file, request, name2, nameHint);
|
9593
9673
|
}
|
@@ -9596,10 +9676,10 @@ function isCircularRequest(file, request) {
|
|
9596
9676
|
return request === filename || request[0] === "." && import_path4.default.resolve(filename, "..", request) === filename;
|
9597
9677
|
}
|
9598
9678
|
function callStatement(id, ...args) {
|
9599
|
-
return
|
9679
|
+
return import_compiler58.types.expressionStatement(callExpression(id, ...args));
|
9600
9680
|
}
|
9601
9681
|
function callExpression(id, ...args) {
|
9602
|
-
return
|
9682
|
+
return import_compiler58.types.callExpression(id, args.filter(Boolean));
|
9603
9683
|
}
|
9604
9684
|
function identifierToSignal(identifier) {
|
9605
9685
|
return {
|
@@ -9608,14 +9688,14 @@ function identifierToSignal(identifier) {
|
|
9608
9688
|
};
|
9609
9689
|
}
|
9610
9690
|
function buildUndefined2() {
|
9611
|
-
return
|
9691
|
+
return import_compiler58.types.unaryExpression("void", import_compiler58.types.numericLiteral(0));
|
9612
9692
|
}
|
9613
9693
|
function always() {
|
9614
9694
|
return true;
|
9615
9695
|
}
|
9616
9696
|
|
9617
9697
|
// src/translator/visitors/tag/dynamic-tag.ts
|
9618
|
-
var
|
9698
|
+
var import_compiler59 = require("@marko/compiler");
|
9619
9699
|
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
9620
9700
|
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
9621
9701
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
@@ -9669,9 +9749,8 @@ var dynamic_tag_default = {
|
|
9669
9749
|
const nodeRef2 = tagExtra[kDOMBinding3];
|
9670
9750
|
const section = getSection(tag);
|
9671
9751
|
const isClassAPI = tagExtra.featureType === "class";
|
9672
|
-
const referencedBindings = tagExtra.referencedBindings;
|
9673
9752
|
let tagExpression = node.name;
|
9674
|
-
if (
|
9753
|
+
if (import_compiler59.types.isStringLiteral(tagExpression)) {
|
9675
9754
|
tagExpression = (0, import_babel_utils42.importDefault)(
|
9676
9755
|
tag.hub.file,
|
9677
9756
|
getTagRelativePath(tag),
|
@@ -9680,15 +9759,15 @@ var dynamic_tag_default = {
|
|
9680
9759
|
}
|
9681
9760
|
if (isClassAPI) {
|
9682
9761
|
if (isOutputHTML()) {
|
9683
|
-
(0,
|
9684
|
-
|
9762
|
+
(0, import_compiler59.getProgram)().node.body.push(
|
9763
|
+
import_compiler59.types.markoScriptlet(
|
9685
9764
|
[
|
9686
|
-
|
9687
|
-
|
9765
|
+
import_compiler59.types.expressionStatement(
|
9766
|
+
import_compiler59.types.callExpression(
|
9688
9767
|
(0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
9689
9768
|
[
|
9690
|
-
|
9691
|
-
|
9769
|
+
import_compiler59.types.identifier(tagExpression.name),
|
9770
|
+
import_compiler59.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
|
9692
9771
|
]
|
9693
9772
|
)
|
9694
9773
|
)
|
@@ -9697,12 +9776,12 @@ var dynamic_tag_default = {
|
|
9697
9776
|
)
|
9698
9777
|
);
|
9699
9778
|
} else {
|
9700
|
-
(0,
|
9701
|
-
|
9779
|
+
(0, import_compiler59.getProgram)().node.body.push(
|
9780
|
+
import_compiler59.types.expressionStatement(
|
9702
9781
|
callRuntime(
|
9703
9782
|
"register",
|
9704
|
-
|
9705
|
-
|
9783
|
+
import_compiler59.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id),
|
9784
|
+
import_compiler59.types.identifier(tagExpression.name)
|
9706
9785
|
)
|
9707
9786
|
)
|
9708
9787
|
);
|
@@ -9722,7 +9801,7 @@ var dynamic_tag_default = {
|
|
9722
9801
|
hasMultipleArgs = true;
|
9723
9802
|
args.push(propsToExpression(properties));
|
9724
9803
|
} else {
|
9725
|
-
hasMultipleArgs = node.arguments.length > 1 ||
|
9804
|
+
hasMultipleArgs = node.arguments.length > 1 || import_compiler59.types.isSpreadElement(node.arguments[0]);
|
9726
9805
|
}
|
9727
9806
|
} else {
|
9728
9807
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
@@ -9736,41 +9815,41 @@ var dynamic_tag_default = {
|
|
9736
9815
|
if (isOutputHTML()) {
|
9737
9816
|
flushInto(tag);
|
9738
9817
|
writeHTMLResumeStatements(tag.get("body"));
|
9739
|
-
const serializeReason = isClassAPI || !!node.var ||
|
9818
|
+
const serializeReason = isClassAPI || !!node.var || getDynamicSourcesForExtra(tagExtra);
|
9740
9819
|
const dynamicTagExpr = hasMultipleArgs ? callRuntime(
|
9741
9820
|
"dynamicTag",
|
9742
9821
|
getScopeIdIdentifier(section),
|
9743
9822
|
getScopeAccessorLiteral(nodeRef2),
|
9744
9823
|
tagExpression,
|
9745
|
-
|
9746
|
-
|
9747
|
-
|
9748
|
-
serializeReason ?
|
9824
|
+
import_compiler59.types.arrayExpression(args),
|
9825
|
+
import_compiler59.types.numericLiteral(0),
|
9826
|
+
import_compiler59.types.numericLiteral(1),
|
9827
|
+
serializeReason ? import_compiler59.types.numericLiteral(1) : void 0
|
9749
9828
|
) : callRuntime(
|
9750
9829
|
"dynamicTag",
|
9751
9830
|
getScopeIdIdentifier(section),
|
9752
9831
|
getScopeAccessorLiteral(nodeRef2),
|
9753
9832
|
tagExpression,
|
9754
9833
|
args[0],
|
9755
|
-
args[1] || (serializeReason ?
|
9756
|
-
serializeReason ?
|
9757
|
-
serializeReason ?
|
9834
|
+
args[1] || (serializeReason ? import_compiler59.types.numericLiteral(0) : void 0),
|
9835
|
+
serializeReason ? import_compiler59.types.numericLiteral(0) : void 0,
|
9836
|
+
serializeReason ? import_compiler59.types.numericLiteral(1) : void 0
|
9758
9837
|
);
|
9759
9838
|
if (node.var) {
|
9760
|
-
const dynamicScopeIdentifier =
|
9839
|
+
const dynamicScopeIdentifier = generateUidIdentifier("dynamicScope");
|
9761
9840
|
statements.push(
|
9762
|
-
|
9763
|
-
|
9841
|
+
import_compiler59.types.variableDeclaration("const", [
|
9842
|
+
import_compiler59.types.variableDeclarator(
|
9764
9843
|
dynamicScopeIdentifier,
|
9765
9844
|
callRuntime("peekNextScope")
|
9766
9845
|
)
|
9767
9846
|
])
|
9768
9847
|
);
|
9769
9848
|
statements.push(
|
9770
|
-
|
9771
|
-
|
9849
|
+
import_compiler59.types.variableDeclaration("const", [
|
9850
|
+
import_compiler59.types.variableDeclarator(node.var, dynamicTagExpr)
|
9772
9851
|
]),
|
9773
|
-
|
9852
|
+
import_compiler59.types.expressionStatement(
|
9774
9853
|
callRuntime(
|
9775
9854
|
"setTagVar",
|
9776
9855
|
getScopeIdIdentifier(section),
|
@@ -9778,7 +9857,7 @@ var dynamic_tag_default = {
|
|
9778
9857
|
tag.node.extra[kChildOffsetScopeBinding2]
|
9779
9858
|
),
|
9780
9859
|
dynamicScopeIdentifier,
|
9781
|
-
|
9860
|
+
import_compiler59.types.stringLiteral(
|
9782
9861
|
getResumeRegisterId(
|
9783
9862
|
section,
|
9784
9863
|
node.var.extra?.binding,
|
@@ -9790,7 +9869,7 @@ var dynamic_tag_default = {
|
|
9790
9869
|
)
|
9791
9870
|
);
|
9792
9871
|
} else {
|
9793
|
-
statements.push(
|
9872
|
+
statements.push(import_compiler59.types.expressionStatement(dynamicTagExpr));
|
9794
9873
|
}
|
9795
9874
|
for (const replacement of tag.replaceWithMultiple(statements)) {
|
9796
9875
|
replacement.skip();
|
@@ -9807,10 +9886,10 @@ var dynamic_tag_default = {
|
|
9807
9886
|
);
|
9808
9887
|
tagVarSignal.register = true;
|
9809
9888
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
9810
|
-
return
|
9811
|
-
|
9889
|
+
return import_compiler59.types.callExpression(importRuntime("tagVarSignalChange"), [
|
9890
|
+
import_compiler59.types.memberExpression(
|
9812
9891
|
getScopeExpression(tagVarSignal.section, valueSection),
|
9813
|
-
|
9892
|
+
import_compiler59.types.stringLiteral(
|
9814
9893
|
getAccessorPrefix().ConditionalScope + getScopeAccessor(nodeRef2)
|
9815
9894
|
),
|
9816
9895
|
true
|
@@ -9823,26 +9902,26 @@ var dynamic_tag_default = {
|
|
9823
9902
|
return callRuntime(
|
9824
9903
|
"dynamicTag",
|
9825
9904
|
getScopeAccessorLiteral(nodeRef2),
|
9826
|
-
bodySection &&
|
9827
|
-
tagVarSignal ?
|
9828
|
-
hasMultipleArgs &&
|
9905
|
+
bodySection && import_compiler59.types.identifier(bodySection.name),
|
9906
|
+
tagVarSignal ? import_compiler59.types.arrowFunctionExpression([], tagVarSignal.identifier) : void 0,
|
9907
|
+
hasMultipleArgs && import_compiler59.types.numericLiteral(1)
|
9829
9908
|
);
|
9830
9909
|
};
|
9831
9910
|
if (args.length) {
|
9832
|
-
const argsOrInput = hasMultipleArgs ?
|
9833
|
-
if (!
|
9911
|
+
const argsOrInput = hasMultipleArgs ? import_compiler59.types.arrayExpression(args) : args[0];
|
9912
|
+
if (!import_compiler59.types.isObjectExpression(argsOrInput) || argsOrInput.properties.length) {
|
9834
9913
|
signal.extraArgs = [
|
9835
|
-
|
9914
|
+
import_compiler59.types.arrowFunctionExpression(
|
9836
9915
|
[],
|
9837
|
-
statements.length ?
|
9838
|
-
statements.concat(
|
9916
|
+
statements.length ? import_compiler59.types.blockStatement(
|
9917
|
+
statements.concat(import_compiler59.types.returnStatement(argsOrInput))
|
9839
9918
|
) : argsOrInput
|
9840
9919
|
)
|
9841
9920
|
];
|
9842
9921
|
}
|
9843
9922
|
}
|
9844
9923
|
signal.hasDownstreamIntersections = () => true;
|
9845
|
-
addValue(section2, referencedBindings, signal, tagExpression);
|
9924
|
+
addValue(section2, tagExtra.referencedBindings, signal, tagExpression);
|
9846
9925
|
tag.remove();
|
9847
9926
|
}
|
9848
9927
|
}
|
@@ -9858,16 +9937,16 @@ var tag_default = {
|
|
9858
9937
|
const { node } = tag;
|
9859
9938
|
const { name: name2, attributes } = tag.node;
|
9860
9939
|
let crawl = false;
|
9861
|
-
if (
|
9940
|
+
if (import_compiler60.types.isStringLiteral(name2)) {
|
9862
9941
|
const tagName = name2.value;
|
9863
9942
|
if (tag.scope.getBinding(tagName) && TAG_NAME_IDENTIFIER_REG.test(tagName)) {
|
9864
|
-
node.name = withPreviousLocation(
|
9943
|
+
node.name = withPreviousLocation(import_compiler60.types.identifier(tagName), name2);
|
9865
9944
|
crawl = true;
|
9866
9945
|
}
|
9867
9946
|
}
|
9868
9947
|
for (let i = 0; i < attributes.length; i++) {
|
9869
9948
|
const attr2 = attributes[i];
|
9870
|
-
if (
|
9949
|
+
if (import_compiler60.types.isMarkoAttribute(attr2) && attr2.bound) {
|
9871
9950
|
attr2.bound = false;
|
9872
9951
|
attributes.splice(++i, 0, getChangeHandler(tag, attr2));
|
9873
9952
|
crawl = true;
|
@@ -9941,10 +10020,10 @@ var tag_default = {
|
|
9941
10020
|
}
|
9942
10021
|
}
|
9943
10022
|
if (extra.tagNameDynamic && extra.tagNameNullable && !tag.get("name").isIdentifier() && isOutputHTML()) {
|
9944
|
-
const tagNameId =
|
10023
|
+
const tagNameId = generateUidIdentifier("tagName");
|
9945
10024
|
const [tagNameVarPath] = tag.insertBefore(
|
9946
|
-
|
9947
|
-
|
10025
|
+
import_compiler60.types.variableDeclaration("const", [
|
10026
|
+
import_compiler60.types.variableDeclarator(tagNameId, tag.node.name)
|
9948
10027
|
])
|
9949
10028
|
);
|
9950
10029
|
tagNameVarPath.skip();
|
@@ -9991,16 +10070,16 @@ var tag_default = {
|
|
9991
10070
|
function getChangeHandler(tag, attr2) {
|
9992
10071
|
const attrName = attr2.name;
|
9993
10072
|
const changeAttrName = attrName + "Change";
|
9994
|
-
if (
|
10073
|
+
if (import_compiler60.types.isIdentifier(attr2.value)) {
|
9995
10074
|
const binding = tag.scope.getBinding(attr2.value.name);
|
9996
10075
|
if (!binding)
|
9997
|
-
return
|
10076
|
+
return import_compiler60.types.markoAttribute(
|
9998
10077
|
changeAttrName,
|
9999
10078
|
buildChangeHandlerFunction(attr2.value)
|
10000
10079
|
);
|
10001
10080
|
const existingChangedAttr = BINDING_CHANGE_HANDLER.get(binding.identifier);
|
10002
10081
|
if (!existingChangedAttr) {
|
10003
|
-
const changeHandlerAttr =
|
10082
|
+
const changeHandlerAttr = import_compiler60.types.markoAttribute(
|
10004
10083
|
changeAttrName,
|
10005
10084
|
buildChangeHandlerFunction(attr2.value)
|
10006
10085
|
);
|
@@ -10008,10 +10087,10 @@ function getChangeHandler(tag, attr2) {
|
|
10008
10087
|
return changeHandlerAttr;
|
10009
10088
|
}
|
10010
10089
|
if (existingChangedAttr.type === "Identifier") {
|
10011
|
-
return
|
10090
|
+
return import_compiler60.types.markoAttribute(
|
10012
10091
|
changeAttrName,
|
10013
10092
|
withPreviousLocation(
|
10014
|
-
|
10093
|
+
import_compiler60.types.identifier(existingChangedAttr.name),
|
10015
10094
|
attr2.value
|
10016
10095
|
)
|
10017
10096
|
);
|
@@ -10020,38 +10099,38 @@ function getChangeHandler(tag, attr2) {
|
|
10020
10099
|
if (!(markoRoot?.isMarkoTag() || markoRoot?.isMarkoTagBody())) {
|
10021
10100
|
throw tag.hub.buildError(attr2.value, "Unable to bind to value.");
|
10022
10101
|
}
|
10023
|
-
const changeHandlerId =
|
10024
|
-
const changeHandlerConst =
|
10025
|
-
|
10026
|
-
[
|
10027
|
-
|
10102
|
+
const changeHandlerId = generateUid(changeAttrName);
|
10103
|
+
const changeHandlerConst = import_compiler60.types.markoTag(
|
10104
|
+
import_compiler60.types.stringLiteral("const"),
|
10105
|
+
[import_compiler60.types.markoAttribute("value", existingChangedAttr.value, null, null, true)],
|
10106
|
+
import_compiler60.types.markoTagBody([]),
|
10028
10107
|
null,
|
10029
|
-
|
10108
|
+
import_compiler60.types.identifier(changeHandlerId)
|
10030
10109
|
);
|
10031
10110
|
BINDING_CHANGE_HANDLER.set(
|
10032
10111
|
binding.identifier,
|
10033
|
-
existingChangedAttr.value =
|
10112
|
+
existingChangedAttr.value = import_compiler60.types.identifier(changeHandlerId)
|
10034
10113
|
);
|
10035
10114
|
if (markoRoot.isMarkoTag()) {
|
10036
10115
|
markoRoot.insertAfter(changeHandlerConst);
|
10037
10116
|
} else {
|
10038
10117
|
markoRoot.unshiftContainer("body", changeHandlerConst);
|
10039
10118
|
}
|
10040
|
-
return
|
10119
|
+
return import_compiler60.types.markoAttribute(
|
10041
10120
|
changeAttrName,
|
10042
|
-
withPreviousLocation(
|
10121
|
+
withPreviousLocation(import_compiler60.types.identifier(changeHandlerId), attr2.value)
|
10043
10122
|
);
|
10044
|
-
} else if (
|
10123
|
+
} else if (import_compiler60.types.isMemberExpression(attr2.value)) {
|
10045
10124
|
const prop = attr2.value.property;
|
10046
|
-
if (!
|
10047
|
-
return
|
10125
|
+
if (!import_compiler60.types.isPrivateName(attr2.value.property)) {
|
10126
|
+
return import_compiler60.types.markoAttribute(
|
10048
10127
|
changeAttrName,
|
10049
|
-
|
10050
|
-
|
10051
|
-
prop.type === "Identifier" ? withPreviousLocation(
|
10128
|
+
import_compiler60.types.memberExpression(
|
10129
|
+
import_compiler60.types.cloneNode(attr2.value.object),
|
10130
|
+
prop.type === "Identifier" ? withPreviousLocation(import_compiler60.types.identifier(prop.name + "Change"), prop) : import_compiler60.types.binaryExpression(
|
10052
10131
|
"+",
|
10053
|
-
|
10054
|
-
|
10132
|
+
import_compiler60.types.cloneNode(prop),
|
10133
|
+
import_compiler60.types.stringLiteral("Change")
|
10055
10134
|
),
|
10056
10135
|
prop.type !== "Identifier"
|
10057
10136
|
)
|
@@ -10065,14 +10144,14 @@ function getChangeHandler(tag, attr2) {
|
|
10065
10144
|
}
|
10066
10145
|
function buildChangeHandlerFunction(id) {
|
10067
10146
|
const newId = "_new_" + id.name;
|
10068
|
-
return
|
10069
|
-
[withPreviousLocation(
|
10070
|
-
|
10071
|
-
|
10072
|
-
|
10147
|
+
return import_compiler60.types.arrowFunctionExpression(
|
10148
|
+
[withPreviousLocation(import_compiler60.types.identifier(newId), id)],
|
10149
|
+
import_compiler60.types.blockStatement([
|
10150
|
+
import_compiler60.types.expressionStatement(
|
10151
|
+
import_compiler60.types.assignmentExpression(
|
10073
10152
|
"=",
|
10074
|
-
withPreviousLocation(
|
10075
|
-
withPreviousLocation(
|
10153
|
+
withPreviousLocation(import_compiler60.types.identifier(id.name), id),
|
10154
|
+
withPreviousLocation(import_compiler60.types.identifier(newId), id)
|
10076
10155
|
)
|
10077
10156
|
)
|
10078
10157
|
])
|
@@ -10080,7 +10159,7 @@ function buildChangeHandlerFunction(id) {
|
|
10080
10159
|
}
|
10081
10160
|
|
10082
10161
|
// src/translator/visitors/text.ts
|
10083
|
-
var
|
10162
|
+
var import_compiler61 = require("@marko/compiler");
|
10084
10163
|
var text_default = {
|
10085
10164
|
translate: {
|
10086
10165
|
exit(text) {
|