marko 6.0.0-next.3.34 → 6.0.0-next.3.36
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 +0 -1
- package/dist/debug/dom.mjs +0 -1
- package/dist/dom/template.d.ts +1 -1
- package/dist/dom.d.ts +0 -2
- package/dist/dom.js +0 -1
- package/dist/dom.mjs +0 -1
- package/dist/translator/index.js +67 -41
- package/dist/translator/visitors/tag/custom-tag.d.ts +2 -0
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
@@ -44,7 +44,6 @@ __export(dom_exports, {
|
|
44
44
|
controllable_textarea_value_effect: () => controllable_input_value_effect,
|
45
45
|
createRenderer: () => createRenderer,
|
46
46
|
createRendererWithOwner: () => createRendererWithOwner,
|
47
|
-
createScope: () => createScope,
|
48
47
|
createTemplate: () => createTemplate,
|
49
48
|
data: () => data,
|
50
49
|
dynamicClosure: () => dynamicClosure,
|
package/dist/debug/dom.mjs
CHANGED
package/dist/dom/template.d.ts
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
import type { Template } from "../common/types";
|
2
2
|
import { createRenderer } from "./renderer";
|
3
|
-
export declare const createTemplate: (templateId: string, template: string, walks?: string | undefined, setup?: ((scope: import("../
|
3
|
+
export declare const createTemplate: (templateId: string, template: string, walks?: string | undefined, setup?: ((scope: import("../common/types").Scope) => void) | undefined, getArgs?: (() => import("./signals").Signal<unknown>) | undefined) => Template;
|
package/dist/dom.d.ts
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
export { attrTag, attrTags } from "./common/attr-tag";
|
2
2
|
export { forIn, forOf, forTo } from "./common/for";
|
3
|
-
export type { Scope } from "./common/types";
|
4
3
|
export { getAbortSignal, resetAbortSignal } from "./dom/abort-signal";
|
5
4
|
export { compat } from "./dom/compat";
|
6
5
|
export { conditional, conditionalOnlyChild, loopIn, loopOf, loopTo, } from "./dom/control-flow";
|
@@ -10,6 +9,5 @@ export { on } from "./dom/event";
|
|
10
9
|
export { run } from "./dom/queue";
|
11
10
|
export { createRenderer, createRendererWithOwner, dynamicTagAttrs, } from "./dom/renderer";
|
12
11
|
export { init, nodeRef, register, registerBoundSignal, registerSubscriber, } from "./dom/resume";
|
13
|
-
export { createScope } from "./dom/scope";
|
14
12
|
export { conditionalClosure, dynamicClosure, effect, inChild, intersection, intersections, loopClosure, nextTagId, setTagVar, setTagVarChange, state, tagVarSignal, tagVarSignalChange, value, } from "./dom/signals";
|
15
13
|
export { createTemplate } from "./dom/template";
|
package/dist/dom.js
CHANGED
@@ -41,7 +41,6 @@ __export(dom_exports, {
|
|
41
41
|
controllable_textarea_value_effect: () => controllable_input_value_effect,
|
42
42
|
createRenderer: () => createRenderer,
|
43
43
|
createRendererWithOwner: () => createRendererWithOwner,
|
44
|
-
createScope: () => createScope,
|
45
44
|
createTemplate: () => createTemplate,
|
46
45
|
data: () => data,
|
47
46
|
dynamicClosure: () => dynamicClosure,
|
package/dist/dom.mjs
CHANGED
package/dist/translator/index.js
CHANGED
@@ -626,19 +626,22 @@ function toMemberExpression(object, key, optional) {
|
|
626
626
|
|
627
627
|
// src/translator/util/runtime.ts
|
628
628
|
var pureFunctions = [
|
629
|
-
"
|
629
|
+
"conditional",
|
630
|
+
"conditionalClosure",
|
631
|
+
"conditionalOnlyChild",
|
630
632
|
"createRenderer",
|
631
633
|
"createRendererWithOwner",
|
632
|
-
"
|
633
|
-
"
|
634
|
+
"createTemplate",
|
635
|
+
"dynamicClosure",
|
636
|
+
"dynamicTagAttrs",
|
637
|
+
"inChild",
|
634
638
|
"intersection",
|
635
639
|
"loopClosure",
|
636
|
-
"conditionalClosure",
|
637
|
-
"dynamicClosure",
|
638
|
-
"loopOf",
|
639
640
|
"loopIn",
|
641
|
+
"loopOf",
|
640
642
|
"loopTo",
|
641
|
-
"
|
643
|
+
"state",
|
644
|
+
"value"
|
642
645
|
];
|
643
646
|
function importRuntime(name2) {
|
644
647
|
const { output } = getMarkoOpts();
|
@@ -3114,7 +3117,9 @@ var program_default = {
|
|
3114
3117
|
currentProgramPath = program;
|
3115
3118
|
startSection(program);
|
3116
3119
|
trackParamsReferences(program, 2 /* input */);
|
3117
|
-
program.node.params[0]
|
3120
|
+
if (program.node.params[0]?.extra?.binding) {
|
3121
|
+
program.node.params[0].extra.binding.nullable = false;
|
3122
|
+
}
|
3118
3123
|
const { scope } = program;
|
3119
3124
|
(program.node.extra ??= {}).domExports = {
|
3120
3125
|
template: scope.generateUid("template_"),
|
@@ -4569,6 +4574,7 @@ var native_tag_default = {
|
|
4569
4574
|
);
|
4570
4575
|
}
|
4571
4576
|
}
|
4577
|
+
setForceResumeScope(section);
|
4572
4578
|
translateVar(
|
4573
4579
|
tag,
|
4574
4580
|
callRuntime(
|
@@ -8008,14 +8014,14 @@ var function_default = {
|
|
8008
8014
|
if (markoRoot && (markoRoot.isMarkoPlaceholder() || markoRoot.isMarkoScriptlet() && markoRoot.node.target === "server")) {
|
8009
8015
|
return;
|
8010
8016
|
}
|
8017
|
+
if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils37.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
|
8018
|
+
return;
|
8019
|
+
}
|
8011
8020
|
const { node } = fn;
|
8012
8021
|
const extra = node.extra ??= {};
|
8013
8022
|
const name2 = extra.name = fn.node.id?.name || (isMarkoAttribute(markoRoot) ? markoRoot.node.default ? import_compiler47.types.toIdentifier(
|
8014
8023
|
markoRoot.parentPath.has("var") ? markoRoot.parentPath.get("var") : markoRoot.parentPath.get("name")
|
8015
8024
|
) : markoRoot.node.name : import_compiler47.types.isVariableDeclarator(fn.parent) && import_compiler47.types.isIdentifier(fn.parent.id) ? fn.parent.id.name : import_compiler47.types.isObjectMethod(node) && import_compiler47.types.isIdentifier(node.key) ? node.key.name : "anonymous");
|
8016
|
-
if (isMarkoAttribute(markoRoot) && ((0, import_babel_utils37.isNativeTag)(markoRoot.parentPath) && /^on[A-Z-]/.test(markoRoot.node.name) || isCoreTagName(markoRoot.parentPath, "script") || isCoreTagName(markoRoot.parentPath, "lifecycle") || isCoreTagName(markoRoot.parentPath, "for"))) {
|
8017
|
-
return;
|
8018
|
-
}
|
8019
8025
|
const {
|
8020
8026
|
markoOpts,
|
8021
8027
|
opts: { filename }
|
@@ -8370,6 +8376,7 @@ var import_compiler51 = require("@marko/compiler");
|
|
8370
8376
|
var import_babel_utils40 = require("@marko/compiler/babel-utils");
|
8371
8377
|
var import_path4 = __toESM(require("path"));
|
8372
8378
|
var kChildScopeBinding = Symbol("custom tag child scope");
|
8379
|
+
var kChildAttrExprs = Symbol("custom tag child attribute expressions");
|
8373
8380
|
var custom_tag_default = {
|
8374
8381
|
analyze: {
|
8375
8382
|
enter(tag) {
|
@@ -8398,12 +8405,14 @@ var custom_tag_default = {
|
|
8398
8405
|
void 0,
|
8399
8406
|
tagExtra
|
8400
8407
|
);
|
8408
|
+
tagExtra[kChildAttrExprs] = /* @__PURE__ */ new Set([tagExtra]);
|
8401
8409
|
const childFile = (0, import_babel_utils40.loadFileForTag)(tag);
|
8402
8410
|
if (childFile.opts.filename === tag.hub.file.opts.filename) {
|
8403
8411
|
mergeReferences(section, tag.node, getAllTagReferenceNodes(tag.node));
|
8404
8412
|
} else {
|
8405
8413
|
const childProgramExtra = childFile.ast.program.extra;
|
8406
8414
|
analyzeAttrs(
|
8415
|
+
tagExtra,
|
8407
8416
|
section,
|
8408
8417
|
tag,
|
8409
8418
|
childProgramExtra?.domExports.params?.props?.[0]
|
@@ -8442,40 +8451,51 @@ function translateHTML(tag) {
|
|
8442
8451
|
}
|
8443
8452
|
const tagVar = node.var;
|
8444
8453
|
const section = getSection(tag);
|
8445
|
-
const childScopeBinding = node.extra[kChildScopeBinding];
|
8446
|
-
const peekScopeId = tag.scope.generateUidIdentifier(childScopeBinding?.name);
|
8447
|
-
tag.insertBefore(
|
8448
|
-
import_compiler51.types.variableDeclaration("const", [
|
8449
|
-
import_compiler51.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
|
8450
|
-
])
|
8451
|
-
);
|
8452
|
-
getSerializedScopeProperties(section).set(
|
8453
|
-
getScopeAccessorLiteral(childScopeBinding),
|
8454
|
-
callRuntime("writeExistingScope", peekScopeId)
|
8455
|
-
);
|
8456
8454
|
const inputExport = (0, import_babel_utils40.loadFileForTag)(tag)?.ast.program.extra?.domExports?.params?.props?.[0];
|
8457
8455
|
const { properties, statements } = inputExport ? translateAttrs(tag, inputExport.props) : {
|
8458
8456
|
properties: [],
|
8459
8457
|
statements: []
|
8460
8458
|
};
|
8461
|
-
|
8462
|
-
|
8463
|
-
|
8464
|
-
|
8465
|
-
|
8466
|
-
|
8467
|
-
|
8468
|
-
|
8469
|
-
|
8470
|
-
|
8471
|
-
|
8472
|
-
|
8473
|
-
|
8459
|
+
let providesStatefulAttrs = false;
|
8460
|
+
for (const expr of tag.node.extra[kChildAttrExprs]) {
|
8461
|
+
if (isReferencedExtra(expr) && isStatefulReferences(expr.referencedBindings)) {
|
8462
|
+
providesStatefulAttrs = true;
|
8463
|
+
break;
|
8464
|
+
}
|
8465
|
+
}
|
8466
|
+
if (providesStatefulAttrs || tagVar) {
|
8467
|
+
const childScopeBinding = node.extra[kChildScopeBinding];
|
8468
|
+
const peekScopeId = tag.scope.generateUidIdentifier(
|
8469
|
+
childScopeBinding?.name
|
8470
|
+
);
|
8471
|
+
tag.insertBefore(
|
8472
|
+
import_compiler51.types.variableDeclaration("const", [
|
8473
|
+
import_compiler51.types.variableDeclarator(peekScopeId, callRuntime("peekNextScope"))
|
8474
|
+
])
|
8475
|
+
);
|
8476
|
+
getSerializedScopeProperties(section).set(
|
8477
|
+
getScopeAccessorLiteral(childScopeBinding),
|
8478
|
+
callRuntime("writeExistingScope", peekScopeId)
|
8479
|
+
);
|
8480
|
+
if (tagVar) {
|
8481
|
+
statements.push(
|
8482
|
+
import_compiler51.types.expressionStatement(
|
8483
|
+
callRuntime(
|
8484
|
+
"setTagVar",
|
8485
|
+
getScopeIdIdentifier(section),
|
8486
|
+
peekScopeId,
|
8487
|
+
import_compiler51.types.stringLiteral(
|
8488
|
+
getResumeRegisterId(
|
8489
|
+
section,
|
8490
|
+
node.var.extra?.binding,
|
8491
|
+
// TODO: node.var is not always an identifier.
|
8492
|
+
"var"
|
8493
|
+
)
|
8474
8494
|
)
|
8475
8495
|
)
|
8476
8496
|
)
|
8477
|
-
)
|
8478
|
-
|
8497
|
+
);
|
8498
|
+
}
|
8479
8499
|
}
|
8480
8500
|
if (node.extra.tagNameNullable) {
|
8481
8501
|
const contentProp = getTranslatedBodyContentProperty(properties);
|
@@ -8617,7 +8637,7 @@ function getTagRelativePath(tag) {
|
|
8617
8637
|
}
|
8618
8638
|
return relativePath;
|
8619
8639
|
}
|
8620
|
-
function analyzeAttrs(section, tag, templateExport) {
|
8640
|
+
function analyzeAttrs(rootTagExtra, section, tag, templateExport) {
|
8621
8641
|
if (!templateExport) {
|
8622
8642
|
dropReferences(getAllTagReferenceNodes(tag.node));
|
8623
8643
|
return;
|
@@ -8653,7 +8673,7 @@ function analyzeAttrs(section, tag, templateExport) {
|
|
8653
8673
|
const childAttrExports = templateExport.props[attrTagMeta.name];
|
8654
8674
|
if (childAttrExports) {
|
8655
8675
|
if (childAttrExports.props && !attrTagMeta.dynamic) {
|
8656
|
-
analyzeAttrs(section, child, childAttrExports);
|
8676
|
+
analyzeAttrs(rootTagExtra, section, child, childAttrExports);
|
8657
8677
|
} else {
|
8658
8678
|
analyzeDynamicChildGroup(attrTagMeta.group, child);
|
8659
8679
|
}
|
@@ -8677,8 +8697,12 @@ function analyzeAttrs(section, tag, templateExport) {
|
|
8677
8697
|
}
|
8678
8698
|
}
|
8679
8699
|
}
|
8680
|
-
for (const {
|
8681
|
-
|
8700
|
+
for (const {
|
8701
|
+
firstTag: { node },
|
8702
|
+
referenceNodes
|
8703
|
+
} of nodeReferencesByGroup.values()) {
|
8704
|
+
mergeReferences(section, node, referenceNodes);
|
8705
|
+
rootTagExtra[kChildAttrExprs].add(node.extra);
|
8682
8706
|
}
|
8683
8707
|
}
|
8684
8708
|
const { attributes } = tag.node;
|
@@ -8696,6 +8720,8 @@ function analyzeAttrs(section, tag, templateExport) {
|
|
8696
8720
|
spreadReferenceNodes.push(attr2.value);
|
8697
8721
|
} else if (import_compiler51.types.isMarkoSpreadAttribute(attr2)) {
|
8698
8722
|
spreadReferenceNodes = [attr2.value];
|
8723
|
+
} else {
|
8724
|
+
rootTagExtra[kChildAttrExprs].add(attr2.value.extra ??= {});
|
8699
8725
|
}
|
8700
8726
|
}
|
8701
8727
|
if (spreadReferenceNodes) {
|
@@ -1,9 +1,11 @@
|
|
1
1
|
import { types as t } from "@marko/compiler";
|
2
2
|
import { type Binding } from "../../util/references";
|
3
3
|
declare const kChildScopeBinding: unique symbol;
|
4
|
+
declare const kChildAttrExprs: unique symbol;
|
4
5
|
declare module "@marko/compiler/dist/types" {
|
5
6
|
interface MarkoTagExtra {
|
6
7
|
[kChildScopeBinding]?: Binding;
|
8
|
+
[kChildAttrExprs]?: Set<t.NodeExtra>;
|
7
9
|
}
|
8
10
|
}
|
9
11
|
declare const _default: {
|