marko 6.0.0-next.3.58 → 6.0.0-next.3.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/common/types.d.ts +7 -1
- package/dist/debug/dom.js +472 -314
- package/dist/debug/dom.mjs +472 -314
- package/dist/debug/html.js +118 -42
- package/dist/debug/html.mjs +118 -42
- package/dist/dom/control-flow.d.ts +5 -0
- package/dist/dom/queue.d.ts +2 -1
- package/dist/dom/resume.d.ts +1 -1
- package/dist/dom/scope.d.ts +1 -0
- package/dist/dom.d.ts +2 -2
- package/dist/dom.js +352 -226
- package/dist/dom.mjs +352 -226
- package/dist/html/dynamic-tag.d.ts +3 -4
- package/dist/html/serializer.d.ts +2 -1
- package/dist/html/writer.d.ts +2 -3
- package/dist/html.js +104 -36
- package/dist/html.mjs +104 -36
- package/dist/translator/core/await.d.ts +7 -0
- package/dist/translator/core/try.d.ts +7 -0
- package/dist/translator/index.js +140 -27
- package/package.json +1 -1
package/dist/translator/index.js
CHANGED
@@ -649,8 +649,10 @@ function toMemberExpression(object, key, optional) {
|
|
649
649
|
|
650
650
|
// src/translator/util/runtime.ts
|
651
651
|
var pureFunctions = [
|
652
|
+
"awaitTag",
|
652
653
|
"conditional",
|
653
654
|
"conditionalClosure",
|
655
|
+
"createTry",
|
654
656
|
"dynamicTag",
|
655
657
|
"createRenderer",
|
656
658
|
"createContent",
|
@@ -1263,6 +1265,8 @@ function getNodeContentType(path5, extraMember, contentInfo) {
|
|
1263
1265
|
return 3 /* Tag */;
|
1264
1266
|
case "for":
|
1265
1267
|
case "if":
|
1268
|
+
case "await":
|
1269
|
+
case "try":
|
1266
1270
|
return 1 /* Dynamic */;
|
1267
1271
|
default:
|
1268
1272
|
return null;
|
@@ -2194,7 +2198,8 @@ function getSignal(section, referencedBindings, name2 = generateSignalName(refer
|
|
2194
2198
|
scopeIdentifier,
|
2195
2199
|
import_compiler17.types.identifier(referencedBindings.name)
|
2196
2200
|
]);
|
2197
|
-
|
2201
|
+
const closureSignalBuilder = getClosureSignalBuilder(section);
|
2202
|
+
return !closureSignalBuilder || isDynamicClosure(section, referencedBindings) ? callRuntime(
|
2198
2203
|
"dynamicClosureRead",
|
2199
2204
|
getScopeAccessorLiteral(referencedBindings),
|
2200
2205
|
render,
|
@@ -4349,6 +4354,7 @@ function isStatefulBinding(binding) {
|
|
4349
4354
|
}
|
4350
4355
|
|
4351
4356
|
// src/translator/core/await.ts
|
4357
|
+
var kDOMBinding = Symbol("await tag dom binding");
|
4352
4358
|
var await_default = {
|
4353
4359
|
analyze(tag) {
|
4354
4360
|
(0, import_babel_utils12.assertNoVar)(tag);
|
@@ -4356,7 +4362,17 @@ var await_default = {
|
|
4356
4362
|
assertNoSpreadAttrs(tag);
|
4357
4363
|
(0, import_babel_utils12.assertNoAttributeTags)(tag);
|
4358
4364
|
const { node } = tag;
|
4365
|
+
const tagBody = tag.get("body");
|
4366
|
+
const section = getOrCreateSection(tag);
|
4359
4367
|
const [valueAttr] = node.attributes;
|
4368
|
+
const tagExtra = tag.node.extra ??= {};
|
4369
|
+
tagExtra[kDOMBinding] = createBinding(
|
4370
|
+
"#text",
|
4371
|
+
0 /* dom */,
|
4372
|
+
section,
|
4373
|
+
void 0,
|
4374
|
+
tagExtra
|
4375
|
+
);
|
4360
4376
|
if (!valueAttr) {
|
4361
4377
|
throw tag.get("name").buildCodeFrameError("The `await` tag requires a value.");
|
4362
4378
|
}
|
@@ -4373,10 +4389,11 @@ var await_default = {
|
|
4373
4389
|
"The `await` tag only supports a single parameter."
|
4374
4390
|
);
|
4375
4391
|
}
|
4392
|
+
startSection(tagBody);
|
4376
4393
|
getOrCreateSection(tag);
|
4377
4394
|
trackParamsReferences(
|
4378
|
-
|
4379
|
-
|
4395
|
+
tagBody,
|
4396
|
+
3 /* param */,
|
4380
4397
|
void 0,
|
4381
4398
|
evaluate(valueAttr.value)
|
4382
4399
|
);
|
@@ -4396,7 +4413,10 @@ var await_default = {
|
|
4396
4413
|
exit(tag) {
|
4397
4414
|
const { node } = tag;
|
4398
4415
|
const [valueAttr] = node.attributes;
|
4416
|
+
const tagExtra = node.extra;
|
4417
|
+
const nodeRef2 = tagExtra[kDOMBinding];
|
4399
4418
|
const tagBody = tag.get("body");
|
4419
|
+
const section = getSection(tag);
|
4400
4420
|
const bodySection = getSectionForBody(tagBody);
|
4401
4421
|
if (isStatefulReferences(valueAttr.extra?.referencedBindings) || checkStatefulClosures(bodySection, true)) {
|
4402
4422
|
setForceResumeScope(bodySection);
|
@@ -4407,6 +4427,8 @@ var await_default = {
|
|
4407
4427
|
import_compiler23.types.expressionStatement(
|
4408
4428
|
callRuntime(
|
4409
4429
|
"fork",
|
4430
|
+
getScopeIdIdentifier(section),
|
4431
|
+
getScopeAccessorLiteral(nodeRef2),
|
4410
4432
|
valueAttr.value,
|
4411
4433
|
import_compiler23.types.arrowFunctionExpression(
|
4412
4434
|
node.body.params,
|
@@ -4426,8 +4448,29 @@ var await_default = {
|
|
4426
4448
|
return;
|
4427
4449
|
}
|
4428
4450
|
setSectionParentIsOwner(bodySection, true);
|
4451
|
+
visit(tag, 37 /* Replace */);
|
4452
|
+
enterShallow(tag);
|
4429
4453
|
},
|
4430
4454
|
exit(tag) {
|
4455
|
+
const { node } = tag;
|
4456
|
+
const tagExtra = node.extra;
|
4457
|
+
const nodeRef2 = tagExtra[kDOMBinding];
|
4458
|
+
const section = getSection(tag);
|
4459
|
+
const bodySection = getSectionForBody(tag.get("body"));
|
4460
|
+
const signal = getSignal(section, nodeRef2, "await");
|
4461
|
+
signal.build = () => {
|
4462
|
+
return callRuntime(
|
4463
|
+
"awaitTag",
|
4464
|
+
getScopeAccessorLiteral(nodeRef2),
|
4465
|
+
import_compiler23.types.identifier(bodySection.name)
|
4466
|
+
);
|
4467
|
+
};
|
4468
|
+
addValue(
|
4469
|
+
section,
|
4470
|
+
tag.node.attributes[0].value.extra?.referencedBindings,
|
4471
|
+
signal,
|
4472
|
+
tag.node.attributes[0].value
|
4473
|
+
);
|
4431
4474
|
tag.remove();
|
4432
4475
|
}
|
4433
4476
|
}
|
@@ -8231,6 +8274,7 @@ var style_default = {
|
|
8231
8274
|
// src/translator/core/try.ts
|
8232
8275
|
var import_compiler48 = require("@marko/compiler");
|
8233
8276
|
var import_babel_utils37 = require("@marko/compiler/babel-utils");
|
8277
|
+
var kDOMBinding2 = Symbol("try tag dom binding");
|
8234
8278
|
var try_default = {
|
8235
8279
|
analyze(tag) {
|
8236
8280
|
(0, import_babel_utils37.assertNoVar)(tag);
|
@@ -8241,9 +8285,19 @@ var try_default = {
|
|
8241
8285
|
analyzeAttributeTags(tag);
|
8242
8286
|
const { node } = tag;
|
8243
8287
|
const section = getOrCreateSection(tag);
|
8288
|
+
const tagExtra = tag.node.extra ??= {};
|
8289
|
+
const tagBody = tag.get("body");
|
8290
|
+
tagExtra[kDOMBinding2] = createBinding(
|
8291
|
+
"#text",
|
8292
|
+
0 /* dom */,
|
8293
|
+
section,
|
8294
|
+
void 0,
|
8295
|
+
tagExtra
|
8296
|
+
);
|
8244
8297
|
if (!node.body.body.length) {
|
8245
8298
|
throw tag.get("name").buildCodeFrameError("The `try` tag requires body content.");
|
8246
8299
|
}
|
8300
|
+
startSection(tagBody);
|
8247
8301
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
8248
8302
|
},
|
8249
8303
|
translate: translateByTarget({
|
@@ -8253,12 +8307,27 @@ var try_default = {
|
|
8253
8307
|
tag.remove();
|
8254
8308
|
return;
|
8255
8309
|
}
|
8256
|
-
|
8310
|
+
const tagBody = tag.get("body");
|
8311
|
+
const bodySection = getSectionForBody(tagBody);
|
8312
|
+
setSectionParentIsOwner(bodySection, true);
|
8257
8313
|
flushBefore(tag);
|
8258
8314
|
},
|
8259
8315
|
exit(tag) {
|
8316
|
+
const { node } = tag;
|
8317
|
+
const section = getSection(tag);
|
8318
|
+
const tagExtra = node.extra;
|
8260
8319
|
const tagBody = tag.get("body");
|
8261
8320
|
const translatedAttrs = translateAttrs(tag);
|
8321
|
+
const nodeRef2 = tagExtra[kDOMBinding2];
|
8322
|
+
const contentProp = getTranslatedBodyContentProperty(
|
8323
|
+
translatedAttrs.properties
|
8324
|
+
);
|
8325
|
+
if (contentProp) {
|
8326
|
+
translatedAttrs.properties.splice(
|
8327
|
+
translatedAttrs.properties.indexOf(contentProp),
|
8328
|
+
1
|
8329
|
+
);
|
8330
|
+
}
|
8262
8331
|
flushInto(tag);
|
8263
8332
|
writeHTMLResumeStatements(tagBody);
|
8264
8333
|
tag.insertBefore(translatedAttrs.statements);
|
@@ -8266,6 +8335,9 @@ var try_default = {
|
|
8266
8335
|
import_compiler48.types.expressionStatement(
|
8267
8336
|
callRuntime(
|
8268
8337
|
"tryContent",
|
8338
|
+
getScopeIdIdentifier(section),
|
8339
|
+
getScopeAccessorLiteral(nodeRef2),
|
8340
|
+
contentProp?.value,
|
8269
8341
|
propsToExpression(translatedAttrs.properties)
|
8270
8342
|
)
|
8271
8343
|
)
|
@@ -8274,9 +8346,56 @@ var try_default = {
|
|
8274
8346
|
},
|
8275
8347
|
dom: {
|
8276
8348
|
enter(tag) {
|
8277
|
-
|
8349
|
+
const tagBody = tag.get("body");
|
8350
|
+
const bodySection = getSectionForBody(tagBody);
|
8351
|
+
setSectionParentIsOwner(bodySection, true);
|
8352
|
+
visit(tag, 37 /* Replace */);
|
8353
|
+
enterShallow(tag);
|
8278
8354
|
},
|
8279
8355
|
exit(tag) {
|
8356
|
+
const { node } = tag;
|
8357
|
+
const tagExtra = node.extra;
|
8358
|
+
const nodeRef2 = tagExtra[kDOMBinding2];
|
8359
|
+
const referencedBindings = tagExtra.referencedBindings;
|
8360
|
+
const translatedAttrs = translateAttrs(tag);
|
8361
|
+
const contentProp = getTranslatedBodyContentProperty(
|
8362
|
+
translatedAttrs.properties
|
8363
|
+
);
|
8364
|
+
if (contentProp) {
|
8365
|
+
translatedAttrs.properties.splice(
|
8366
|
+
translatedAttrs.properties.indexOf(contentProp),
|
8367
|
+
1
|
8368
|
+
);
|
8369
|
+
}
|
8370
|
+
const section = getSection(tag);
|
8371
|
+
const bodySection = getSectionForBody(tag.get("body"));
|
8372
|
+
const signal = getSignal(section, nodeRef2, "try");
|
8373
|
+
signal.build = () => {
|
8374
|
+
return callRuntime(
|
8375
|
+
"createTry",
|
8376
|
+
getScopeAccessorLiteral(nodeRef2),
|
8377
|
+
import_compiler48.types.identifier(bodySection.name)
|
8378
|
+
);
|
8379
|
+
};
|
8380
|
+
if (translatedAttrs.statements.length) {
|
8381
|
+
addStatement(
|
8382
|
+
"render",
|
8383
|
+
section,
|
8384
|
+
referencedBindings,
|
8385
|
+
translatedAttrs.statements
|
8386
|
+
);
|
8387
|
+
}
|
8388
|
+
currentProgramPath.pushContainer(
|
8389
|
+
"body",
|
8390
|
+
import_compiler48.types.expressionStatement(callRuntime("enableCatch"))
|
8391
|
+
);
|
8392
|
+
addValue(
|
8393
|
+
section,
|
8394
|
+
referencedBindings,
|
8395
|
+
signal,
|
8396
|
+
propsToExpression(translatedAttrs.properties)
|
8397
|
+
);
|
8398
|
+
signal.hasDownstreamIntersections = () => true;
|
8280
8399
|
tag.remove();
|
8281
8400
|
}
|
8282
8401
|
}
|
@@ -8290,17 +8409,6 @@ var try_default = {
|
|
8290
8409
|
],
|
8291
8410
|
types: runtime_info_default.name + "/tag-types/try.d.marko"
|
8292
8411
|
};
|
8293
|
-
function setAllSectionsParentIsOwner(tag) {
|
8294
|
-
for (const attrTag2 of tag.get("attributeTags")) {
|
8295
|
-
if (attrTag2.isMarkoTag()) {
|
8296
|
-
setAllSectionsParentIsOwner(attrTag2);
|
8297
|
-
}
|
8298
|
-
}
|
8299
|
-
const bodySection = getSectionForBody(tag.get("body"));
|
8300
|
-
if (bodySection) {
|
8301
|
-
setSectionParentIsOwner(bodySection, true);
|
8302
|
-
}
|
8303
|
-
}
|
8304
8412
|
|
8305
8413
|
// src/translator/core/index.ts
|
8306
8414
|
var core_default = {
|
@@ -9418,7 +9526,7 @@ function always() {
|
|
9418
9526
|
// src/translator/visitors/tag/dynamic-tag.ts
|
9419
9527
|
var import_compiler54 = require("@marko/compiler");
|
9420
9528
|
var import_babel_utils42 = require("@marko/compiler/babel-utils");
|
9421
|
-
var
|
9529
|
+
var kDOMBinding3 = Symbol("dynamic tag dom binding");
|
9422
9530
|
var kChildOffsetScopeBinding2 = Symbol("custom tag scope offset");
|
9423
9531
|
var dynamic_tag_default = {
|
9424
9532
|
analyze: {
|
@@ -9428,7 +9536,7 @@ var dynamic_tag_default = {
|
|
9428
9536
|
const section = getOrCreateSection(tag);
|
9429
9537
|
const tagExtra = tag.node.extra ??= {};
|
9430
9538
|
const tagBody = tag.get("body");
|
9431
|
-
tagExtra[
|
9539
|
+
tagExtra[kDOMBinding3] = createBinding(
|
9432
9540
|
"#text",
|
9433
9541
|
0 /* dom */,
|
9434
9542
|
section,
|
@@ -9467,7 +9575,7 @@ var dynamic_tag_default = {
|
|
9467
9575
|
exit(tag) {
|
9468
9576
|
const { node } = tag;
|
9469
9577
|
const tagExtra = node.extra;
|
9470
|
-
const nodeRef2 = tagExtra[
|
9578
|
+
const nodeRef2 = tagExtra[kDOMBinding3];
|
9471
9579
|
const section = getSection(tag);
|
9472
9580
|
const isClassAPI = tagExtra.featureType === "class";
|
9473
9581
|
const referencedBindings = tagExtra.referencedBindings;
|
@@ -9483,14 +9591,19 @@ var dynamic_tag_default = {
|
|
9483
9591
|
if (isOutputHTML()) {
|
9484
9592
|
currentProgramPath.pushContainer(
|
9485
9593
|
"body",
|
9486
|
-
import_compiler54.types.
|
9487
|
-
|
9488
|
-
|
9489
|
-
|
9490
|
-
|
9491
|
-
|
9492
|
-
|
9493
|
-
|
9594
|
+
import_compiler54.types.markoScriptlet(
|
9595
|
+
[
|
9596
|
+
import_compiler54.types.expressionStatement(
|
9597
|
+
import_compiler54.types.callExpression(
|
9598
|
+
(0, import_babel_utils42.importNamed)(tag.hub.file, getCompatRuntimeFile(), "s"),
|
9599
|
+
[
|
9600
|
+
import_compiler54.types.identifier(tagExpression.name),
|
9601
|
+
import_compiler54.types.stringLiteral((0, import_babel_utils42.loadFileForTag)(tag).metadata.marko.id)
|
9602
|
+
]
|
9603
|
+
)
|
9604
|
+
)
|
9605
|
+
],
|
9606
|
+
true
|
9494
9607
|
)
|
9495
9608
|
);
|
9496
9609
|
} else {
|