@vue-jsx-vapor/compiler 2.5.1 → 2.5.3
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/index.cjs +22 -68
- package/dist/index.d.cts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +24 -70
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
@@ -144,18 +144,7 @@ function getLiteralExpressionValue(exp) {
|
|
144
144
|
const isConstant = (node) => {
|
145
145
|
if (!node) return false;
|
146
146
|
if (node.type === "Identifier") return node.name === "undefined" || (0, __vue_shared.isGloballyAllowed)(node.name);
|
147
|
-
|
148
|
-
"JSXElement",
|
149
|
-
"JSXFragment",
|
150
|
-
"NullLiteral"
|
151
|
-
].includes(node.type)) return true;
|
152
|
-
if (node.type === "ArrayExpression") {
|
153
|
-
const { elements } = node;
|
154
|
-
return elements.every((element) => element && isConstant(element));
|
155
|
-
}
|
156
|
-
if (node.type === "ObjectExpression") return node.properties.every((property) => isConstant(property.value));
|
157
|
-
if (node.type === "TemplateLiteral" ? !node.expressions.length : (0, __babel_types.isLiteral)(node)) return true;
|
158
|
-
return false;
|
147
|
+
return (0, __vue_compiler_dom.isConstantNode)(node, {});
|
159
148
|
};
|
160
149
|
const EMPTY_TEXT_REGEX = /^[\t\v\f \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*[\n\r]\s*$/;
|
161
150
|
const START_EMPTY_TEXT_REGEX = /^\s*[\n\r]/;
|
@@ -756,21 +745,10 @@ function genCreateComponent(operation, context) {
|
|
756
745
|
const { helper } = context;
|
757
746
|
const tag = genTag();
|
758
747
|
const { root, props, slots, once } = operation;
|
748
|
+
const rawProps = genRawProps(props, context);
|
759
749
|
const rawSlots = genRawSlots(slots, context);
|
760
|
-
const [ids, handlers] = processInlineHandlers(props, context);
|
761
|
-
const rawProps = context.withId(() => genRawProps(props, context), ids);
|
762
|
-
const inlineHandlers = handlers.reduce((acc, { name, value }) => {
|
763
|
-
const handler = genEventHandler(context, value, void 0, false);
|
764
|
-
return [
|
765
|
-
...acc,
|
766
|
-
`const ${name} = `,
|
767
|
-
...handler,
|
768
|
-
NEWLINE
|
769
|
-
];
|
770
|
-
}, []);
|
771
750
|
return [
|
772
751
|
NEWLINE,
|
773
|
-
...inlineHandlers,
|
774
752
|
`const n${operation.id} = `,
|
775
753
|
...genCall(operation.dynamic && !operation.dynamic.isStatic ? helper("createDynamicComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, root ? "true" : false, once && "true"),
|
776
754
|
...genDirectivesForElement(operation.id, context)
|
@@ -786,33 +764,6 @@ function genCreateComponent(operation, context) {
|
|
786
764
|
else return genExpression((0, __vue_shared.extend)((0, __vue_compiler_dom.createSimpleExpression)(operation.tag, false), { ast: null }), context);
|
787
765
|
}
|
788
766
|
}
|
789
|
-
function getUniqueHandlerName(context, name) {
|
790
|
-
const { seenInlineHandlerNames } = context;
|
791
|
-
const count = seenInlineHandlerNames[name] || 0;
|
792
|
-
seenInlineHandlerNames[name] = count + 1;
|
793
|
-
return count === 0 ? name : `${name}${count}`;
|
794
|
-
}
|
795
|
-
function processInlineHandlers(props, context) {
|
796
|
-
const ids = Object.create(null);
|
797
|
-
const handlers = [];
|
798
|
-
const staticProps = props[0];
|
799
|
-
if ((0, __vue_shared.isArray)(staticProps)) for (const prop of staticProps) {
|
800
|
-
if (!prop.handler) continue;
|
801
|
-
prop.values.forEach((value, i) => {
|
802
|
-
const isMemberExp = (0, __vue_compiler_dom.isMemberExpression)(value, context.options);
|
803
|
-
if (!isMemberExp) {
|
804
|
-
const name = getUniqueHandlerName(context, `_on_${prop.key.content.replace(":", "_")}`);
|
805
|
-
handlers.push({
|
806
|
-
name,
|
807
|
-
value
|
808
|
-
});
|
809
|
-
ids[name] = null;
|
810
|
-
prop.values[i] = (0, __vue_shared.extend)({ ast: null }, (0, __vue_compiler_dom.createSimpleExpression)(name));
|
811
|
-
}
|
812
|
-
});
|
813
|
-
}
|
814
|
-
return [ids, handlers];
|
815
|
-
}
|
816
767
|
function genRawProps(props, context) {
|
817
768
|
const staticProps = props[0];
|
818
769
|
if ((0, __vue_shared.isArray)(staticProps)) {
|
@@ -1069,23 +1020,27 @@ function genFor(oper, context) {
|
|
1069
1020
|
idMap[indexVar] = null;
|
1070
1021
|
}
|
1071
1022
|
const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
|
1072
|
-
const
|
1023
|
+
const selectorDeclarations = [];
|
1024
|
+
const selectorSetup = [];
|
1073
1025
|
for (const [i, { selector }] of selectorPatterns.entries()) {
|
1074
1026
|
const selectorName = `_selector${id}_${i}`;
|
1075
|
-
|
1027
|
+
selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
|
1028
|
+
if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
|
1029
|
+
selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
|
1030
|
+
if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
|
1076
1031
|
}
|
1077
1032
|
const blockFn = context.withId(() => {
|
1078
1033
|
const frag = [];
|
1079
1034
|
frag.push("(", ...args, ") => {", INDENT_START);
|
1080
1035
|
if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(...genBlockContent(render, context, false, () => {
|
1081
|
-
const patternFrag
|
1036
|
+
const patternFrag = [];
|
1082
1037
|
for (const [i, { effect }] of selectorPatterns.entries()) {
|
1083
|
-
patternFrag
|
1084
|
-
for (const oper$1 of effect.operations) patternFrag
|
1085
|
-
patternFrag
|
1038
|
+
patternFrag.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
|
1039
|
+
for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
|
1040
|
+
patternFrag.push(INDENT_END, NEWLINE, `})`);
|
1086
1041
|
}
|
1087
|
-
for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag
|
1088
|
-
return patternFrag
|
1042
|
+
for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
|
1043
|
+
return patternFrag;
|
1089
1044
|
}));
|
1090
1045
|
else frag.push(...genBlockContent(render, context));
|
1091
1046
|
frag.push(INDENT_END, NEWLINE, "}");
|
@@ -1098,9 +1053,9 @@ function genFor(oper, context) {
|
|
1098
1053
|
if (once) flags |= VaporVForFlags.ONCE;
|
1099
1054
|
return [
|
1100
1055
|
NEWLINE,
|
1056
|
+
...selectorDeclarations,
|
1101
1057
|
`const n${id} = `,
|
1102
|
-
...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0)
|
1103
|
-
...patternFrag
|
1058
|
+
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0, selectorSetup.length ? selectorSetup : void 0)
|
1104
1059
|
];
|
1105
1060
|
function parseValueDestructure() {
|
1106
1061
|
const map = /* @__PURE__ */ new Map();
|
@@ -1248,7 +1203,7 @@ function matchSelectorPattern(effect, keyAst, idMap) {
|
|
1248
1203
|
}
|
1249
1204
|
}
|
1250
1205
|
const content = effect.expressions[0].content;
|
1251
|
-
if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" && (
|
1206
|
+
if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" && isConstant(ast.consequent) && isConstant(ast.alternate)) {
|
1252
1207
|
const left = ast.test.left;
|
1253
1208
|
const right = ast.test.right;
|
1254
1209
|
for (const [a, b] of [[left, right], [right, left]]) {
|
@@ -1553,7 +1508,6 @@ var CodegenContext = class {
|
|
1553
1508
|
};
|
1554
1509
|
delegates = /* @__PURE__ */ new Set();
|
1555
1510
|
identifiers = Object.create(null);
|
1556
|
-
seenInlineHandlerNames = Object.create(null);
|
1557
1511
|
block;
|
1558
1512
|
withId(fn, map) {
|
1559
1513
|
const { identifiers } = this;
|
@@ -1703,7 +1657,7 @@ var TransformContext = class TransformContext {
|
|
1703
1657
|
registerEffect(expressions, operation, getEffectIndex = () => this.block.effect.length, getOperationIndex = () => this.block.operation.length) {
|
1704
1658
|
const operations = [operation].flat();
|
1705
1659
|
expressions = expressions.filter((exp) => !isConstantExpression(exp));
|
1706
|
-
if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast && (
|
1660
|
+
if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast && isConstant(e.ast))) return this.registerOperation(operations, getOperationIndex);
|
1707
1661
|
this.block.effect.splice(getEffectIndex(), 0, {
|
1708
1662
|
expressions,
|
1709
1663
|
operations
|
@@ -2052,7 +2006,7 @@ function processConditionalExpression(node, context) {
|
|
2052
2006
|
id,
|
2053
2007
|
condition,
|
2054
2008
|
positive: branch,
|
2055
|
-
once: context.inVOnce || (
|
2009
|
+
once: context.inVOnce || isConstant(test)
|
2056
2010
|
};
|
2057
2011
|
return [() => {
|
2058
2012
|
onExit();
|
@@ -2220,7 +2174,7 @@ function processFor(node, dir, context) {
|
|
2220
2174
|
return () => {
|
2221
2175
|
exitBlock();
|
2222
2176
|
const { parent } = context;
|
2223
|
-
const isOnlyChild = parent && parent.block.node !== parent.node && parent.node.children.length === 1;
|
2177
|
+
const isOnlyChild = parent && parent.block.node !== parent.node && parent.node.children.filter((child) => !isEmptyText(child)).length === 1;
|
2224
2178
|
context.dynamic.operation = {
|
2225
2179
|
type: IRNodeTypes.FOR,
|
2226
2180
|
id,
|
@@ -2230,7 +2184,7 @@ function processFor(node, dir, context) {
|
|
2230
2184
|
index,
|
2231
2185
|
keyProp: keyProperty,
|
2232
2186
|
render,
|
2233
|
-
once: context.inVOnce || !!(source.ast && (
|
2187
|
+
once: context.inVOnce || !!(source.ast && isConstant(source.ast)),
|
2234
2188
|
component: isComponent,
|
2235
2189
|
onlyChild: !!isOnlyChild
|
2236
2190
|
};
|
@@ -2305,7 +2259,7 @@ function processIf(node, attribute, context) {
|
|
2305
2259
|
id,
|
2306
2260
|
condition: dir.exp,
|
2307
2261
|
positive: branch,
|
2308
|
-
once: context.inVOnce || (
|
2262
|
+
once: context.inVOnce || isConstant(attribute.value)
|
2309
2263
|
};
|
2310
2264
|
};
|
2311
2265
|
} else {
|
package/dist/index.d.cts
CHANGED
@@ -353,7 +353,6 @@ declare class CodegenContext {
|
|
353
353
|
helper: (name: string) => string;
|
354
354
|
delegates: Set<string>;
|
355
355
|
identifiers: Record<string, (string | SimpleExpressionNode)[]>;
|
356
|
-
seenInlineHandlerNames: Record<string, number>;
|
357
356
|
block: BlockIRNode;
|
358
357
|
withId<T>(fn: () => T, map: Record<string, string | SimpleExpressionNode | null>): T;
|
359
358
|
enterBlock(block: BlockIRNode): () => BlockIRNode;
|
package/dist/index.d.ts
CHANGED
@@ -353,7 +353,6 @@ declare class CodegenContext {
|
|
353
353
|
helper: (name: string) => string;
|
354
354
|
delegates: Set<string>;
|
355
355
|
identifiers: Record<string, (string | SimpleExpressionNode)[]>;
|
356
|
-
seenInlineHandlerNames: Record<string, number>;
|
357
356
|
block: BlockIRNode;
|
358
357
|
withId<T>(fn: () => T, map: Record<string, string | SimpleExpressionNode | null>): T;
|
359
358
|
enterBlock(block: BlockIRNode): () => BlockIRNode;
|
package/dist/index.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { parse, parseExpression } from "@babel/parser";
|
2
2
|
import { NOOP, camelize, canSetValueDirectly, capitalize, extend, isArray, isBuiltInDirective, isGloballyAllowed, isHTMLTag, isSVGTag, isString, isVoidTag, makeMap, remove, shouldSetAsAttr, toHandlerKey } from "@vue/shared";
|
3
|
-
import { DOMErrorCodes, ErrorCodes, NewlineType, NodeTypes, TS_NODE_TYPES, advancePositionWithClone, advancePositionWithMutation, createCompilerError, createDOMCompilerError, createSimpleExpression, defaultOnError, defaultOnWarn, isConstantNode, isFnExpression, isLiteralWhitelisted, isMemberExpression, isSimpleIdentifier,
|
3
|
+
import { DOMErrorCodes, ErrorCodes, NewlineType, NodeTypes, TS_NODE_TYPES, advancePositionWithClone, advancePositionWithMutation, createCompilerError, createDOMCompilerError, createSimpleExpression, defaultOnError, defaultOnWarn, isConstantNode, isFnExpression, isLiteralWhitelisted, isMemberExpression, isSimpleIdentifier, isStaticProperty, isValidHTMLNesting, locStub, resolveModifiers, toValidAssetId, unwrapTSNode, walkIdentifiers } from "@vue/compiler-dom";
|
4
4
|
import { walkAST, walkIdentifiers as walkIdentifiers$1 } from "ast-kit";
|
5
|
-
import {
|
5
|
+
import { isNodesEquivalent, jsxClosingFragment, jsxExpressionContainer, jsxFragment, jsxOpeningFragment } from "@babel/types";
|
6
6
|
import { SourceMapGenerator } from "source-map-js";
|
7
7
|
|
8
8
|
//#region src/ir/component.ts
|
@@ -121,18 +121,7 @@ function getLiteralExpressionValue(exp) {
|
|
121
121
|
const isConstant = (node) => {
|
122
122
|
if (!node) return false;
|
123
123
|
if (node.type === "Identifier") return node.name === "undefined" || isGloballyAllowed(node.name);
|
124
|
-
|
125
|
-
"JSXElement",
|
126
|
-
"JSXFragment",
|
127
|
-
"NullLiteral"
|
128
|
-
].includes(node.type)) return true;
|
129
|
-
if (node.type === "ArrayExpression") {
|
130
|
-
const { elements } = node;
|
131
|
-
return elements.every((element) => element && isConstant(element));
|
132
|
-
}
|
133
|
-
if (node.type === "ObjectExpression") return node.properties.every((property) => isConstant(property.value));
|
134
|
-
if (node.type === "TemplateLiteral" ? !node.expressions.length : isLiteral(node)) return true;
|
135
|
-
return false;
|
124
|
+
return isConstantNode(node, {});
|
136
125
|
};
|
137
126
|
const EMPTY_TEXT_REGEX = /^[\t\v\f \u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*[\n\r]\s*$/;
|
138
127
|
const START_EMPTY_TEXT_REGEX = /^\s*[\n\r]/;
|
@@ -733,21 +722,10 @@ function genCreateComponent(operation, context) {
|
|
733
722
|
const { helper } = context;
|
734
723
|
const tag = genTag();
|
735
724
|
const { root, props, slots, once } = operation;
|
725
|
+
const rawProps = genRawProps(props, context);
|
736
726
|
const rawSlots = genRawSlots(slots, context);
|
737
|
-
const [ids, handlers] = processInlineHandlers(props, context);
|
738
|
-
const rawProps = context.withId(() => genRawProps(props, context), ids);
|
739
|
-
const inlineHandlers = handlers.reduce((acc, { name, value }) => {
|
740
|
-
const handler = genEventHandler(context, value, void 0, false);
|
741
|
-
return [
|
742
|
-
...acc,
|
743
|
-
`const ${name} = `,
|
744
|
-
...handler,
|
745
|
-
NEWLINE
|
746
|
-
];
|
747
|
-
}, []);
|
748
727
|
return [
|
749
728
|
NEWLINE,
|
750
|
-
...inlineHandlers,
|
751
729
|
`const n${operation.id} = `,
|
752
730
|
...genCall(operation.dynamic && !operation.dynamic.isStatic ? helper("createDynamicComponent") : operation.asset ? helper("createComponentWithFallback") : helper("createComponent"), tag, rawProps, rawSlots, root ? "true" : false, once && "true"),
|
753
731
|
...genDirectivesForElement(operation.id, context)
|
@@ -763,33 +741,6 @@ function genCreateComponent(operation, context) {
|
|
763
741
|
else return genExpression(extend(createSimpleExpression(operation.tag, false), { ast: null }), context);
|
764
742
|
}
|
765
743
|
}
|
766
|
-
function getUniqueHandlerName(context, name) {
|
767
|
-
const { seenInlineHandlerNames } = context;
|
768
|
-
const count = seenInlineHandlerNames[name] || 0;
|
769
|
-
seenInlineHandlerNames[name] = count + 1;
|
770
|
-
return count === 0 ? name : `${name}${count}`;
|
771
|
-
}
|
772
|
-
function processInlineHandlers(props, context) {
|
773
|
-
const ids = Object.create(null);
|
774
|
-
const handlers = [];
|
775
|
-
const staticProps = props[0];
|
776
|
-
if (isArray(staticProps)) for (const prop of staticProps) {
|
777
|
-
if (!prop.handler) continue;
|
778
|
-
prop.values.forEach((value, i) => {
|
779
|
-
const isMemberExp = isMemberExpression(value, context.options);
|
780
|
-
if (!isMemberExp) {
|
781
|
-
const name = getUniqueHandlerName(context, `_on_${prop.key.content.replace(":", "_")}`);
|
782
|
-
handlers.push({
|
783
|
-
name,
|
784
|
-
value
|
785
|
-
});
|
786
|
-
ids[name] = null;
|
787
|
-
prop.values[i] = extend({ ast: null }, createSimpleExpression(name));
|
788
|
-
}
|
789
|
-
});
|
790
|
-
}
|
791
|
-
return [ids, handlers];
|
792
|
-
}
|
793
744
|
function genRawProps(props, context) {
|
794
745
|
const staticProps = props[0];
|
795
746
|
if (isArray(staticProps)) {
|
@@ -1046,23 +997,27 @@ function genFor(oper, context) {
|
|
1046
997
|
idMap[indexVar] = null;
|
1047
998
|
}
|
1048
999
|
const { selectorPatterns, keyOnlyBindingPatterns } = matchPatterns(render, keyProp, idMap);
|
1049
|
-
const
|
1000
|
+
const selectorDeclarations = [];
|
1001
|
+
const selectorSetup = [];
|
1050
1002
|
for (const [i, { selector }] of selectorPatterns.entries()) {
|
1051
1003
|
const selectorName = `_selector${id}_${i}`;
|
1052
|
-
|
1004
|
+
selectorDeclarations.push(`let ${selectorName}`, NEWLINE);
|
1005
|
+
if (i === 0) selectorSetup.push(`({ createSelector }) => {`, INDENT_START);
|
1006
|
+
selectorSetup.push(NEWLINE, `${selectorName} = `, ...genCall(`createSelector`, [`() => `, ...genExpression(selector, context)]));
|
1007
|
+
if (i === selectorPatterns.length - 1) selectorSetup.push(INDENT_END, NEWLINE, "}");
|
1053
1008
|
}
|
1054
1009
|
const blockFn = context.withId(() => {
|
1055
1010
|
const frag = [];
|
1056
1011
|
frag.push("(", ...args, ") => {", INDENT_START);
|
1057
1012
|
if (selectorPatterns.length || keyOnlyBindingPatterns.length) frag.push(...genBlockContent(render, context, false, () => {
|
1058
|
-
const patternFrag
|
1013
|
+
const patternFrag = [];
|
1059
1014
|
for (const [i, { effect }] of selectorPatterns.entries()) {
|
1060
|
-
patternFrag
|
1061
|
-
for (const oper$1 of effect.operations) patternFrag
|
1062
|
-
patternFrag
|
1015
|
+
patternFrag.push(NEWLINE, `_selector${id}_${i}(() => {`, INDENT_START);
|
1016
|
+
for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
|
1017
|
+
patternFrag.push(INDENT_END, NEWLINE, `})`);
|
1063
1018
|
}
|
1064
|
-
for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag
|
1065
|
-
return patternFrag
|
1019
|
+
for (const { effect } of keyOnlyBindingPatterns) for (const oper$1 of effect.operations) patternFrag.push(...genOperation(oper$1, context));
|
1020
|
+
return patternFrag;
|
1066
1021
|
}));
|
1067
1022
|
else frag.push(...genBlockContent(render, context));
|
1068
1023
|
frag.push(INDENT_END, NEWLINE, "}");
|
@@ -1075,9 +1030,9 @@ function genFor(oper, context) {
|
|
1075
1030
|
if (once) flags |= VaporVForFlags.ONCE;
|
1076
1031
|
return [
|
1077
1032
|
NEWLINE,
|
1033
|
+
...selectorDeclarations,
|
1078
1034
|
`const n${id} = `,
|
1079
|
-
...genCall(helper("createFor"), sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0)
|
1080
|
-
...patternFrag
|
1035
|
+
...genCall([helper("createFor"), "undefined"], sourceExpr, blockFn, genCallback(keyProp), flags ? String(flags) : void 0, selectorSetup.length ? selectorSetup : void 0)
|
1081
1036
|
];
|
1082
1037
|
function parseValueDestructure() {
|
1083
1038
|
const map = /* @__PURE__ */ new Map();
|
@@ -1225,7 +1180,7 @@ function matchSelectorPattern(effect, keyAst, idMap) {
|
|
1225
1180
|
}
|
1226
1181
|
}
|
1227
1182
|
const content = effect.expressions[0].content;
|
1228
|
-
if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" &&
|
1183
|
+
if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" && isConstant(ast.consequent) && isConstant(ast.alternate)) {
|
1229
1184
|
const left = ast.test.left;
|
1230
1185
|
const right = ast.test.right;
|
1231
1186
|
for (const [a, b] of [[left, right], [right, left]]) {
|
@@ -1530,7 +1485,6 @@ var CodegenContext = class {
|
|
1530
1485
|
};
|
1531
1486
|
delegates = /* @__PURE__ */ new Set();
|
1532
1487
|
identifiers = Object.create(null);
|
1533
|
-
seenInlineHandlerNames = Object.create(null);
|
1534
1488
|
block;
|
1535
1489
|
withId(fn, map) {
|
1536
1490
|
const { identifiers } = this;
|
@@ -1680,7 +1634,7 @@ var TransformContext = class TransformContext {
|
|
1680
1634
|
registerEffect(expressions, operation, getEffectIndex = () => this.block.effect.length, getOperationIndex = () => this.block.operation.length) {
|
1681
1635
|
const operations = [operation].flat();
|
1682
1636
|
expressions = expressions.filter((exp) => !isConstantExpression(exp));
|
1683
|
-
if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast &&
|
1637
|
+
if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast && isConstant(e.ast))) return this.registerOperation(operations, getOperationIndex);
|
1684
1638
|
this.block.effect.splice(getEffectIndex(), 0, {
|
1685
1639
|
expressions,
|
1686
1640
|
operations
|
@@ -2029,7 +1983,7 @@ function processConditionalExpression(node, context) {
|
|
2029
1983
|
id,
|
2030
1984
|
condition,
|
2031
1985
|
positive: branch,
|
2032
|
-
once: context.inVOnce ||
|
1986
|
+
once: context.inVOnce || isConstant(test)
|
2033
1987
|
};
|
2034
1988
|
return [() => {
|
2035
1989
|
onExit();
|
@@ -2197,7 +2151,7 @@ function processFor(node, dir, context) {
|
|
2197
2151
|
return () => {
|
2198
2152
|
exitBlock();
|
2199
2153
|
const { parent } = context;
|
2200
|
-
const isOnlyChild = parent && parent.block.node !== parent.node && parent.node.children.length === 1;
|
2154
|
+
const isOnlyChild = parent && parent.block.node !== parent.node && parent.node.children.filter((child) => !isEmptyText(child)).length === 1;
|
2201
2155
|
context.dynamic.operation = {
|
2202
2156
|
type: IRNodeTypes.FOR,
|
2203
2157
|
id,
|
@@ -2207,7 +2161,7 @@ function processFor(node, dir, context) {
|
|
2207
2161
|
index,
|
2208
2162
|
keyProp: keyProperty,
|
2209
2163
|
render,
|
2210
|
-
once: context.inVOnce || !!(source.ast &&
|
2164
|
+
once: context.inVOnce || !!(source.ast && isConstant(source.ast)),
|
2211
2165
|
component: isComponent,
|
2212
2166
|
onlyChild: !!isOnlyChild
|
2213
2167
|
};
|
@@ -2282,7 +2236,7 @@ function processIf(node, attribute, context) {
|
|
2282
2236
|
id,
|
2283
2237
|
condition: dir.exp,
|
2284
2238
|
positive: branch,
|
2285
|
-
once: context.inVOnce ||
|
2239
|
+
once: context.inVOnce || isConstant(attribute.value)
|
2286
2240
|
};
|
2287
2241
|
};
|
2288
2242
|
} else {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vue-jsx-vapor/compiler",
|
3
|
-
"version": "2.5.
|
3
|
+
"version": "2.5.3",
|
4
4
|
"description": "Vue JSX Vapor Compiler",
|
5
5
|
"type": "module",
|
6
6
|
"keywords": [
|
@@ -36,8 +36,8 @@
|
|
36
36
|
"dependencies": {
|
37
37
|
"@babel/parser": "^7.28.0",
|
38
38
|
"@babel/types": "^7.28.0",
|
39
|
-
"@vue/compiler-dom": "
|
40
|
-
"@vue/shared": "
|
39
|
+
"@vue/compiler-dom": "3.6.0-alpha.2",
|
40
|
+
"@vue/shared": "3.6.0-alpha.2",
|
41
41
|
"ast-kit": "^2.1.1",
|
42
42
|
"source-map-js": "^1.2.1"
|
43
43
|
},
|