marko 6.0.62 → 6.0.64
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 +9 -2
- package/dist/debug/dom.mjs +9 -2
- package/dist/dom/signals.d.ts +2 -2
- package/dist/dom.js +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/translator/index.js +38 -17
- package/package.json +1 -1
- package/tags/let.d.marko +1 -1
package/dist/debug/dom.js
CHANGED
@@ -1059,9 +1059,16 @@ function _var(scope, childAccessor, signal) {
|
|
1059
1059
|
}
|
1060
1060
|
var _return = (scope, value) => scope["#TagVariable" /* TagVariable */]?.(value);
|
1061
1061
|
function _return_change(scope, changeHandler) {
|
1062
|
-
|
1062
|
+
if (changeHandler) {
|
1063
|
+
scope["#TagVariableChange" /* TagVariableChange */] = changeHandler;
|
1064
|
+
}
|
1063
1065
|
}
|
1064
|
-
var _var_change = (scope, value
|
1066
|
+
var _var_change = true ? (scope, value, name = "This") => {
|
1067
|
+
if (typeof scope["#TagVariableChange" /* TagVariableChange */] !== "function") {
|
1068
|
+
throw new TypeError(`${name} is a readonly tag variable.`);
|
1069
|
+
}
|
1070
|
+
scope["#TagVariableChange" /* TagVariableChange */](value);
|
1071
|
+
} : (scope, value) => scope["#TagVariableChange" /* TagVariableChange */]?.(value);
|
1065
1072
|
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
1066
1073
|
function _id({ $global }) {
|
1067
1074
|
const id = tagIdsByGlobal.get($global) || 0;
|
package/dist/debug/dom.mjs
CHANGED
@@ -962,9 +962,16 @@ function _var(scope, childAccessor, signal) {
|
|
962
962
|
}
|
963
963
|
var _return = (scope, value) => scope["#TagVariable" /* TagVariable */]?.(value);
|
964
964
|
function _return_change(scope, changeHandler) {
|
965
|
-
|
965
|
+
if (changeHandler) {
|
966
|
+
scope["#TagVariableChange" /* TagVariableChange */] = changeHandler;
|
967
|
+
}
|
966
968
|
}
|
967
|
-
var _var_change = (scope, value
|
969
|
+
var _var_change = true ? (scope, value, name = "This") => {
|
970
|
+
if (typeof scope["#TagVariableChange" /* TagVariableChange */] !== "function") {
|
971
|
+
throw new TypeError(`${name} is a readonly tag variable.`);
|
972
|
+
}
|
973
|
+
scope["#TagVariableChange" /* TagVariableChange */](value);
|
974
|
+
} : (scope, value) => scope["#TagVariableChange" /* TagVariableChange */]?.(value);
|
968
975
|
var tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
969
976
|
function _id({ $global }) {
|
970
977
|
const id = tagIdsByGlobal.get($global) || 0;
|
package/dist/dom/signals.d.ts
CHANGED
@@ -17,8 +17,8 @@ export declare function _closure_get<T>(valueAccessor: Accessor, fn: Signal<T>,
|
|
17
17
|
};
|
18
18
|
export declare function _var(scope: Scope, childAccessor: Accessor, signal: Signal<unknown>): void;
|
19
19
|
export declare const _return: (scope: Scope, value: unknown) => any;
|
20
|
-
export declare function _return_change(scope: Scope, changeHandler
|
21
|
-
export declare const _var_change: (scope: Scope, value: unknown) =>
|
20
|
+
export declare function _return_change(scope: Scope, changeHandler?: ((value: unknown) => void) | null | false): void;
|
21
|
+
export declare const _var_change: (scope: Scope, value: unknown, name?: string) => void;
|
22
22
|
export declare function _id({ $global }: Scope): string;
|
23
23
|
export declare function _script(id: string, fn: (scope: Scope) => void): (scope: Scope) => void;
|
24
24
|
export declare function _hoist(...path: Accessor[]): (scope: Scope) => (...args: unknown[]) => any;
|
package/dist/dom.js
CHANGED
@@ -684,7 +684,7 @@ function _var(scope, childAccessor, signal) {
|
|
684
684
|
}
|
685
685
|
var _return = (scope, value) => scope.e?.(value);
|
686
686
|
function _return_change(scope, changeHandler) {
|
687
|
-
scope.f = changeHandler;
|
687
|
+
changeHandler && (scope.f = changeHandler);
|
688
688
|
}
|
689
689
|
var _var_change = (scope, value) => scope.f?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
690
690
|
function _id({ $global }) {
|
package/dist/dom.mjs
CHANGED
@@ -590,7 +590,7 @@ function _var(scope, childAccessor, signal) {
|
|
590
590
|
}
|
591
591
|
var _return = (scope, value) => scope.e?.(value);
|
592
592
|
function _return_change(scope, changeHandler) {
|
593
|
-
scope.f = changeHandler;
|
593
|
+
changeHandler && (scope.f = changeHandler);
|
594
594
|
}
|
595
595
|
var _var_change = (scope, value) => scope.f?.(value), tagIdsByGlobal = /* @__PURE__ */ new WeakMap();
|
596
596
|
function _id({ $global }) {
|
package/dist/translator/index.js
CHANGED
@@ -3135,7 +3135,11 @@ var return_default = {
|
|
3135
3135
|
setSectionSerializedValue(
|
3136
3136
|
section,
|
3137
3137
|
getAccessorProp().TagVariableChange,
|
3138
|
-
|
3138
|
+
import_compiler18.types.logicalExpression(
|
3139
|
+
"||",
|
3140
|
+
attrs.valueChange,
|
3141
|
+
import_compiler18.types.unaryExpression("void", import_compiler18.types.numericLiteral(0))
|
3142
|
+
)
|
3139
3143
|
);
|
3140
3144
|
}
|
3141
3145
|
if (attrs.value) {
|
@@ -9570,7 +9574,7 @@ var let_default = {
|
|
9570
9574
|
"The [`<let>` tag](https://next.markojs.com/docs/reference/core-tag#let) variable cannot be destructured."
|
9571
9575
|
);
|
9572
9576
|
}
|
9573
|
-
if (valueChangeAttr && (0, import_babel_utils38.computeNode)(valueChangeAttr.value)) {
|
9577
|
+
if (valueChangeAttr && (0, import_babel_utils38.computeNode)(valueChangeAttr.value)?.value) {
|
9574
9578
|
throw tag.get("attributes").find((attr) => attr.node === valueChangeAttr).get("value").buildCodeFrameError(
|
9575
9579
|
"The [`<let>` tag](https://next.markojs.com/docs/reference/core-tag#let) [`valueChange=` attribute](https://next.markojs.com/docs/reference/core-tag#controllable-let) must be a function."
|
9576
9580
|
);
|
@@ -9621,7 +9625,11 @@ var let_default = {
|
|
9621
9625
|
setBindingSerializedValue(
|
9622
9626
|
section,
|
9623
9627
|
binding,
|
9624
|
-
|
9628
|
+
import_compiler44.types.logicalExpression(
|
9629
|
+
"||",
|
9630
|
+
valueChangeAttr.value,
|
9631
|
+
import_compiler44.types.unaryExpression("void", import_compiler44.types.numericLiteral(0))
|
9632
|
+
),
|
9625
9633
|
getAccessorPrefix().TagVariableChange
|
9626
9634
|
);
|
9627
9635
|
}
|
@@ -9801,12 +9809,14 @@ var script_default = {
|
|
9801
9809
|
const start = body[0]?.start;
|
9802
9810
|
const end = body[body.length - 1]?.end;
|
9803
9811
|
const bodyStatements = (0, import_babel_utils41.parseStatements)(tag.hub.file, code, start, end);
|
9804
|
-
|
9805
|
-
|
9806
|
-
|
9807
|
-
|
9808
|
-
|
9809
|
-
|
9812
|
+
if (bodyStatements.length) {
|
9813
|
+
const valueFn = import_compiler47.types.arrowFunctionExpression(
|
9814
|
+
[],
|
9815
|
+
import_compiler47.types.blockStatement(bodyStatements),
|
9816
|
+
traverseContains(bodyStatements, isAwaitExpression)
|
9817
|
+
);
|
9818
|
+
node.attributes.push(import_compiler47.types.markoAttribute("value", valueFn));
|
9819
|
+
}
|
9810
9820
|
node.body.body = [];
|
9811
9821
|
}
|
9812
9822
|
},
|
@@ -10732,6 +10742,7 @@ var custom_tag_default = {
|
|
10732
10742
|
throw tag.get("name").buildCodeFrameError("Unable to resolve file for tag.");
|
10733
10743
|
}
|
10734
10744
|
const varBinding = trackVarReferences(tag, 5 /* derived */);
|
10745
|
+
const mutatesTagVar = !!(tag.node.var?.type === "Identifier" && tag.scope.getBinding(tag.node.var.name)?.constantViolations.length);
|
10735
10746
|
if (varBinding) {
|
10736
10747
|
varBinding.scopeOffset = tagExtra[kChildOffsetScopeBinding] = createBinding("#scopeOffset", 0 /* dom */, section);
|
10737
10748
|
}
|
@@ -10743,7 +10754,7 @@ var custom_tag_default = {
|
|
10743
10754
|
addBindingSerializeReasonExpr(
|
10744
10755
|
section,
|
10745
10756
|
childScopeBinding,
|
10746
|
-
varSerializeReason
|
10757
|
+
mutatesTagVar || varSerializeReason
|
10747
10758
|
);
|
10748
10759
|
}
|
10749
10760
|
} else {
|
@@ -10769,7 +10780,7 @@ var custom_tag_default = {
|
|
10769
10780
|
addBindingSerializeReasonExpr(
|
10770
10781
|
section,
|
10771
10782
|
childScopeBinding,
|
10772
|
-
varSerializeReason
|
10783
|
+
mutatesTagVar || varSerializeReason
|
10773
10784
|
);
|
10774
10785
|
}
|
10775
10786
|
if (childExtra.inputSerializeReasons) {
|
@@ -10985,16 +10996,21 @@ function translateDOM(tag) {
|
|
10985
10996
|
);
|
10986
10997
|
const inputExport = childExports.input;
|
10987
10998
|
if (node.var) {
|
10999
|
+
const varBinding = node.var.extra.binding;
|
10988
11000
|
const source = initValue(
|
10989
11001
|
// TODO: support destructuring
|
10990
|
-
|
11002
|
+
varBinding
|
10991
11003
|
);
|
10992
11004
|
source.register = true;
|
10993
11005
|
source.buildAssignment = (valueSection, value) => {
|
10994
|
-
|
11006
|
+
const changeArgs = [
|
10995
11007
|
createScopeReadExpression(valueSection, childScopeBinding),
|
10996
11008
|
value
|
10997
|
-
]
|
11009
|
+
];
|
11010
|
+
if (!isOptimize()) {
|
11011
|
+
changeArgs.push(import_compiler56.types.stringLiteral(varBinding.name));
|
11012
|
+
}
|
11013
|
+
return import_compiler56.types.callExpression(importRuntime("_var_change"), changeArgs);
|
10998
11014
|
};
|
10999
11015
|
addStatement(
|
11000
11016
|
"render",
|
@@ -11739,13 +11755,14 @@ var dynamic_tag_default = {
|
|
11739
11755
|
const signal = getSignal(section, nodeBinding, "dynamicTag");
|
11740
11756
|
let tagVarSignal;
|
11741
11757
|
if (tag.node.var) {
|
11758
|
+
const varBinding = tag.node.var.extra.binding;
|
11742
11759
|
tagVarSignal = initValue(
|
11743
11760
|
// TODO: support destructuring
|
11744
|
-
|
11761
|
+
varBinding
|
11745
11762
|
);
|
11746
11763
|
tagVarSignal.register = true;
|
11747
11764
|
tagVarSignal.buildAssignment = (valueSection, value) => {
|
11748
|
-
|
11765
|
+
const changeArgs = [
|
11749
11766
|
import_compiler57.types.memberExpression(
|
11750
11767
|
getScopeExpression(tagVarSignal.section, valueSection),
|
11751
11768
|
import_compiler57.types.stringLiteral(
|
@@ -11754,7 +11771,11 @@ var dynamic_tag_default = {
|
|
11754
11771
|
true
|
11755
11772
|
),
|
11756
11773
|
value
|
11757
|
-
]
|
11774
|
+
];
|
11775
|
+
if (!isOptimize()) {
|
11776
|
+
changeArgs.push(import_compiler57.types.stringLiteral(varBinding.name));
|
11777
|
+
}
|
11778
|
+
return import_compiler57.types.callExpression(importRuntime("_var_change"), changeArgs);
|
11758
11779
|
};
|
11759
11780
|
}
|
11760
11781
|
signal.build = () => {
|
package/package.json
CHANGED