marko 6.0.158 → 6.0.159
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 +3 -0
- package/dist/debug/dom.mjs +3 -0
- package/dist/dom/signals.d.ts +1 -1
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/translator/index.js +30 -46
- package/dist/translator/util/sections.d.ts +1 -0
- package/dist/translator/visitors/program/index.d.ts +0 -1
- package/package.json +1 -1
package/dist/debug/dom.js
CHANGED
|
@@ -549,6 +549,9 @@ function _const(valueAccessor, fn) {
|
|
|
549
549
|
};
|
|
550
550
|
}
|
|
551
551
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id" /* Id */) {
|
|
552
|
+
if (false) {
|
|
553
|
+
scopeIdAccessor = decodeAccessor(scopeIdAccessor);
|
|
554
|
+
}
|
|
552
555
|
return (scope) => {
|
|
553
556
|
if (scope["#Creating" /* Creating */]) {
|
|
554
557
|
if (id in scope) {
|
package/dist/debug/dom.mjs
CHANGED
|
@@ -433,6 +433,9 @@ function _const(valueAccessor, fn) {
|
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
435
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "#Id" /* Id */) {
|
|
436
|
+
if (false) {
|
|
437
|
+
scopeIdAccessor = decodeAccessor(scopeIdAccessor);
|
|
438
|
+
}
|
|
436
439
|
return (scope) => {
|
|
437
440
|
if (scope["#Creating" /* Creating */]) {
|
|
438
441
|
if (id in scope) {
|
package/dist/dom/signals.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export type Signal<T> = ((scope: Scope, value: T) => void) & {
|
|
|
5
5
|
};
|
|
6
6
|
export declare function _let<T>(id: EncodedAccessor, fn?: SignalFn): (scope: Scope, value: T, valueChange?: (v: T) => void) => T;
|
|
7
7
|
export declare function _const<T>(valueAccessor: EncodedAccessor, fn?: SignalFn): Signal<T>;
|
|
8
|
-
export declare function _or(id: number, fn: SignalFn, defaultPending?: number, scopeIdAccessor?:
|
|
8
|
+
export declare function _or(id: number, fn: SignalFn, defaultPending?: number, scopeIdAccessor?: EncodedAccessor): Signal<never>;
|
|
9
9
|
export declare function _for_closure(ownerLoopNodeAccessor: EncodedAccessor, fn: SignalFn): SignalFn;
|
|
10
10
|
export declare function _if_closure(ownerConditionalNodeAccessor: EncodedAccessor, branch: number, fn: SignalFn): SignalFn;
|
|
11
11
|
export declare function subscribeToScopeSet(ownerScope: Scope, accessor: Accessor, scope: Scope): void;
|
package/dist/dom.js
CHANGED
|
@@ -341,7 +341,7 @@ function _const(valueAccessor, fn) {
|
|
|
341
341
|
};
|
|
342
342
|
}
|
|
343
343
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
|
|
344
|
-
return (scope) => {
|
|
344
|
+
return scopeIdAccessor !== "L" /* Id */ && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
|
|
345
345
|
scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
346
346
|
};
|
|
347
347
|
}
|
package/dist/dom.mjs
CHANGED
|
@@ -228,7 +228,7 @@ function _const(valueAccessor, fn) {
|
|
|
228
228
|
};
|
|
229
229
|
}
|
|
230
230
|
function _or(id, fn, defaultPending = 1, scopeIdAccessor = "L" /* Id */) {
|
|
231
|
-
return (scope) => {
|
|
231
|
+
return scopeIdAccessor !== "L" /* Id */ && (scopeIdAccessor = decodeAccessor(scopeIdAccessor)), (scope) => {
|
|
232
232
|
scope.H ? id in scope ? --scope[id] || fn(scope) : scope[id] = defaultPending : queueRender(scope, fn, id, 0, scope[scopeIdAccessor]);
|
|
233
233
|
};
|
|
234
234
|
}
|
package/dist/translator/index.js
CHANGED
|
@@ -1760,6 +1760,7 @@ function startSection(path7) {
|
|
|
1760
1760
|
serializeReason: void 0,
|
|
1761
1761
|
serializeReasons: /* @__PURE__ */ new Map(),
|
|
1762
1762
|
paramReasonGroups: void 0,
|
|
1763
|
+
returnValueExpr: void 0,
|
|
1763
1764
|
returnSerializeReason: void 0,
|
|
1764
1765
|
content: getContentInfo(path7),
|
|
1765
1766
|
upstreamExpression: void 0,
|
|
@@ -2310,17 +2311,6 @@ var entry_builder_default = {
|
|
|
2310
2311
|
}
|
|
2311
2312
|
};
|
|
2312
2313
|
|
|
2313
|
-
// src/translator/util/get-known-attr-values.ts
|
|
2314
|
-
function getKnownAttrValues(tag) {
|
|
2315
|
-
const attrs = {};
|
|
2316
|
-
for (const attr of tag.attributes) {
|
|
2317
|
-
if (attr.type === "MarkoAttribute") {
|
|
2318
|
-
attrs[attr.name] = attr.value;
|
|
2319
|
-
}
|
|
2320
|
-
}
|
|
2321
|
-
return attrs;
|
|
2322
|
-
}
|
|
2323
|
-
|
|
2324
2314
|
// src/translator/util/runtime.ts
|
|
2325
2315
|
var import_compiler11 = require("@marko/compiler");
|
|
2326
2316
|
var import_babel_utils13 = require("@marko/compiler/babel-utils");
|
|
@@ -2637,6 +2627,17 @@ var import_babel_utils15 = require("@marko/compiler/babel-utils");
|
|
|
2637
2627
|
var import_compiler17 = require("@marko/compiler");
|
|
2638
2628
|
var import_babel_utils14 = require("@marko/compiler/babel-utils");
|
|
2639
2629
|
|
|
2630
|
+
// src/translator/util/get-known-attr-values.ts
|
|
2631
|
+
function getKnownAttrValues(tag) {
|
|
2632
|
+
const attrs = {};
|
|
2633
|
+
for (const attr of tag.attributes) {
|
|
2634
|
+
if (attr.type === "MarkoAttribute") {
|
|
2635
|
+
attrs[attr.name] = attr.value;
|
|
2636
|
+
}
|
|
2637
|
+
}
|
|
2638
|
+
return attrs;
|
|
2639
|
+
}
|
|
2640
|
+
|
|
2640
2641
|
// src/translator/util/plugin-hooks.ts
|
|
2641
2642
|
var import_compiler12 = require("@marko/compiler");
|
|
2642
2643
|
function enter(modulePlugin, path7) {
|
|
@@ -3115,7 +3116,6 @@ function unwrapWrite(write) {
|
|
|
3115
3116
|
}
|
|
3116
3117
|
|
|
3117
3118
|
// src/translator/core/return.ts
|
|
3118
|
-
var tagsWithReturn = /* @__PURE__ */ new WeakSet();
|
|
3119
3119
|
var [getSectionReturnValueIdentifier, setReturnValueIdentifier] = createSectionState("returnValue");
|
|
3120
3120
|
var return_default = {
|
|
3121
3121
|
analyze(tag) {
|
|
@@ -3136,12 +3136,11 @@ var return_default = {
|
|
|
3136
3136
|
);
|
|
3137
3137
|
}
|
|
3138
3138
|
}
|
|
3139
|
-
|
|
3139
|
+
const section = getOrCreateSection(tag);
|
|
3140
|
+
if (section.returnValueExpr) {
|
|
3140
3141
|
throw tag.get("name").buildCodeFrameError(
|
|
3141
3142
|
`Cannot have multiple [\`<return>\` tags](https://markojs.com/docs/reference/core-tag#return) ${tag.parent.type === "Program" ? "for the template" : "within a tag's body content"}.`
|
|
3142
3143
|
);
|
|
3143
|
-
} else {
|
|
3144
|
-
tagsWithReturn.add(tag.parentPath);
|
|
3145
3144
|
}
|
|
3146
3145
|
const attrs = getKnownAttrValues(tag.node);
|
|
3147
3146
|
if (!attrs.value) {
|
|
@@ -3151,12 +3150,9 @@ var return_default = {
|
|
|
3151
3150
|
}
|
|
3152
3151
|
if (attrs.valueChange) {
|
|
3153
3152
|
(attrs.valueChange.extra ??= {}).isEffect = true;
|
|
3154
|
-
addSerializeReason(
|
|
3155
|
-
getOrCreateSection(tag),
|
|
3156
|
-
true,
|
|
3157
|
-
getAccessorProp().TagVariableChange
|
|
3158
|
-
);
|
|
3153
|
+
addSerializeReason(section, true, getAccessorProp().TagVariableChange);
|
|
3159
3154
|
}
|
|
3155
|
+
section.returnValueExpr = attrs.value.extra ??= {};
|
|
3160
3156
|
},
|
|
3161
3157
|
translate: translateByTarget({
|
|
3162
3158
|
html: {
|
|
@@ -5311,15 +5307,6 @@ var program_default = {
|
|
|
5311
5307
|
setup: generateUid("setup"),
|
|
5312
5308
|
params: void 0
|
|
5313
5309
|
};
|
|
5314
|
-
for (const child of program.get("body")) {
|
|
5315
|
-
if (isCoreTagName(child, "return")) {
|
|
5316
|
-
const { value } = getKnownAttrValues(child.node);
|
|
5317
|
-
if (value) {
|
|
5318
|
-
programExtra.returnValueExpr = value.extra ??= {};
|
|
5319
|
-
}
|
|
5320
|
-
break;
|
|
5321
|
-
}
|
|
5322
|
-
}
|
|
5323
5310
|
},
|
|
5324
5311
|
exit(program) {
|
|
5325
5312
|
finalizeReferences();
|
|
@@ -7504,14 +7491,6 @@ function knownTagAnalyze(tag, contentSection, propTree) {
|
|
|
7504
7491
|
setTagDownstream(tag, propTree?.props?.[0]?.binding);
|
|
7505
7492
|
tagExtra[kContentSection] = contentSection;
|
|
7506
7493
|
const varBinding = trackVarReferences(tag, 5 /* derived */);
|
|
7507
|
-
const mutatesTagVar = !!(tag.node.var?.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
|
7508
|
-
if (varBinding) {
|
|
7509
|
-
varBinding.scopeOffset = tagExtra[kChildOffsetScopeBinding] = createBinding(
|
|
7510
|
-
"#scopeOffset",
|
|
7511
|
-
0 /* dom */,
|
|
7512
|
-
section
|
|
7513
|
-
);
|
|
7514
|
-
}
|
|
7515
7494
|
const exprs = tagExtra[kKnownExprs] = analyzeParams(
|
|
7516
7495
|
tagExtra,
|
|
7517
7496
|
section,
|
|
@@ -7520,10 +7499,15 @@ function knownTagAnalyze(tag, contentSection, propTree) {
|
|
|
7520
7499
|
attrExprs
|
|
7521
7500
|
);
|
|
7522
7501
|
if (varBinding) {
|
|
7523
|
-
const
|
|
7524
|
-
const varExpr = mapParamReasonToExpr(
|
|
7502
|
+
const mutatesTagVar = !!(tag.node.var.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
|
7503
|
+
const varExpr = tagExtra.defineBodySection ? contentSection.returnValueExpr : mapParamReasonToExpr(
|
|
7525
7504
|
exprs,
|
|
7526
|
-
returnSerializeReason && (returnSerializeReason === true || !!returnSerializeReason.state || returnSerializeReason.param)
|
|
7505
|
+
contentSection.returnSerializeReason && (contentSection.returnSerializeReason === true || !!contentSection.returnSerializeReason.state || contentSection.returnSerializeReason.param)
|
|
7506
|
+
);
|
|
7507
|
+
varBinding.scopeOffset = tagExtra[kChildOffsetScopeBinding] = createBinding(
|
|
7508
|
+
"#scopeOffset",
|
|
7509
|
+
0 /* dom */,
|
|
7510
|
+
section
|
|
7527
7511
|
);
|
|
7528
7512
|
setBindingDownstream(varBinding, varExpr);
|
|
7529
7513
|
addSerializeExpr(section, mutatesTagVar || varExpr, childScopeBinding);
|
|
@@ -7691,7 +7675,7 @@ function finalizeKnownTags(section) {
|
|
|
7691
7675
|
const scopeBinding = tagExtra[kChildScopeBinding];
|
|
7692
7676
|
const knownExprs = tagExtra[kKnownExprs];
|
|
7693
7677
|
const contentSection = tagExtra[kContentSection];
|
|
7694
|
-
if (knownExprs && scopeBinding && contentSection
|
|
7678
|
+
if (knownExprs && scopeBinding && contentSection.paramReasonGroups) {
|
|
7695
7679
|
for (const group of contentSection.paramReasonGroups) {
|
|
7696
7680
|
addSerializeReason(
|
|
7697
7681
|
section,
|
|
@@ -9382,10 +9366,10 @@ function finalizeReferences() {
|
|
|
9382
9366
|
});
|
|
9383
9367
|
}
|
|
9384
9368
|
});
|
|
9385
|
-
const
|
|
9386
|
-
if (
|
|
9387
|
-
|
|
9388
|
-
|
|
9369
|
+
const programSection = (0, import_babel_utils27.getProgram)().node.extra.section;
|
|
9370
|
+
if (programSection.returnValueExpr) {
|
|
9371
|
+
programSection.returnSerializeReason = getSerializeSourcesForExpr(
|
|
9372
|
+
programSection.returnValueExpr
|
|
9389
9373
|
);
|
|
9390
9374
|
}
|
|
9391
9375
|
readsByExpression.clear();
|
|
@@ -10095,7 +10079,7 @@ function getAllSerializeReasonsForExtra(extra) {
|
|
|
10095
10079
|
let reason = serializeReasonCache.get(extra);
|
|
10096
10080
|
if (reason === false) return;
|
|
10097
10081
|
if (reason === void 0) {
|
|
10098
|
-
if (extra === (0, import_babel_utils27.getProgram)().node.extra?.returnValueExpr) {
|
|
10082
|
+
if (extra === (0, import_babel_utils27.getProgram)().node.extra?.section.returnValueExpr) {
|
|
10099
10083
|
reason = true;
|
|
10100
10084
|
} else {
|
|
10101
10085
|
serializeReasonCache.set(extra, false);
|
|
@@ -38,6 +38,7 @@ export interface Section {
|
|
|
38
38
|
serializeReason: undefined | SerializeReason;
|
|
39
39
|
serializeReasons: Map<symbol, SerializeReason>;
|
|
40
40
|
paramReasonGroups: ParamSerializeReasonGroups | undefined;
|
|
41
|
+
returnValueExpr: t.NodeExtra | undefined;
|
|
41
42
|
returnSerializeReason: SerializeReason | undefined;
|
|
42
43
|
isHoistThrough: true | undefined;
|
|
43
44
|
upstreamExpression: t.NodeExtra | undefined;
|
|
@@ -16,7 +16,6 @@ export declare function isScopeIdentifier(node: t.Node): node is t.Identifier;
|
|
|
16
16
|
export type TemplateExports = BindingPropTree["props"];
|
|
17
17
|
declare module "@marko/compiler/dist/types" {
|
|
18
18
|
interface ProgramExtra {
|
|
19
|
-
returnValueExpr?: t.NodeExtra;
|
|
20
19
|
domExports?: {
|
|
21
20
|
template: string;
|
|
22
21
|
walks: string;
|