@vue-jsx-vapor/compiler 2.5.2 → 2.5.4-beta.1

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 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
- if ([
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]/;
@@ -1214,7 +1203,7 @@ function matchSelectorPattern(effect, keyAst, idMap) {
1214
1203
  }
1215
1204
  }
1216
1205
  const content = effect.expressions[0].content;
1217
- if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" && (0, __vue_compiler_dom.isStaticNode)(ast.consequent) && (0, __vue_compiler_dom.isStaticNode)(ast.alternate)) {
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)) {
1218
1207
  const left = ast.test.left;
1219
1208
  const right = ast.test.right;
1220
1209
  for (const [a, b] of [[left, right], [right, left]]) {
@@ -1668,7 +1657,7 @@ var TransformContext = class TransformContext {
1668
1657
  registerEffect(expressions, operation, getEffectIndex = () => this.block.effect.length, getOperationIndex = () => this.block.operation.length) {
1669
1658
  const operations = [operation].flat();
1670
1659
  expressions = expressions.filter((exp) => !isConstantExpression(exp));
1671
- if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast && (0, __vue_compiler_dom.isConstantNode)(e.ast, {}))) return this.registerOperation(operations, getOperationIndex);
1660
+ if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast && isConstant(e.ast))) return this.registerOperation(operations, getOperationIndex);
1672
1661
  this.block.effect.splice(getEffectIndex(), 0, {
1673
1662
  expressions,
1674
1663
  operations
@@ -2017,7 +2006,7 @@ function processConditionalExpression(node, context) {
2017
2006
  id,
2018
2007
  condition,
2019
2008
  positive: branch,
2020
- once: context.inVOnce || (0, __vue_compiler_dom.isStaticNode)(test)
2009
+ once: context.inVOnce || isConstant(test)
2021
2010
  };
2022
2011
  return [() => {
2023
2012
  onExit();
@@ -2185,7 +2174,7 @@ function processFor(node, dir, context) {
2185
2174
  return () => {
2186
2175
  exitBlock();
2187
2176
  const { parent } = context;
2188
- 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;
2189
2178
  context.dynamic.operation = {
2190
2179
  type: IRNodeTypes.FOR,
2191
2180
  id,
@@ -2195,7 +2184,7 @@ function processFor(node, dir, context) {
2195
2184
  index,
2196
2185
  keyProp: keyProperty,
2197
2186
  render,
2198
- once: context.inVOnce || !!(source.ast && (0, __vue_compiler_dom.isConstantNode)(source.ast, {})),
2187
+ once: context.inVOnce || !!(source.ast && isConstant(source.ast)),
2199
2188
  component: isComponent,
2200
2189
  onlyChild: !!isOnlyChild
2201
2190
  };
@@ -2270,7 +2259,7 @@ function processIf(node, attribute, context) {
2270
2259
  id,
2271
2260
  condition: dir.exp,
2272
2261
  positive: branch,
2273
- once: context.inVOnce || (0, __vue_compiler_dom.isConstantNode)(attribute.value, {})
2262
+ once: context.inVOnce || isConstant(attribute.value)
2274
2263
  };
2275
2264
  };
2276
2265
  } else {
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, isStaticNode, isStaticProperty, isValidHTMLNesting, locStub, resolveModifiers, toValidAssetId, unwrapTSNode, walkIdentifiers } from "@vue/compiler-dom";
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 { isLiteral, isNodesEquivalent, jsxClosingFragment, jsxExpressionContainer, jsxFragment, jsxOpeningFragment } from "@babel/types";
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
- if ([
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]/;
@@ -1191,7 +1180,7 @@ function matchSelectorPattern(effect, keyAst, idMap) {
1191
1180
  }
1192
1181
  }
1193
1182
  const content = effect.expressions[0].content;
1194
- if (typeof ast === "object" && ast && ast.type === "ConditionalExpression" && ast.test.type === "BinaryExpression" && ast.test.operator === "===" && ast.test.left.type !== "PrivateName" && isStaticNode(ast.consequent) && isStaticNode(ast.alternate)) {
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)) {
1195
1184
  const left = ast.test.left;
1196
1185
  const right = ast.test.right;
1197
1186
  for (const [a, b] of [[left, right], [right, left]]) {
@@ -1645,7 +1634,7 @@ var TransformContext = class TransformContext {
1645
1634
  registerEffect(expressions, operation, getEffectIndex = () => this.block.effect.length, getOperationIndex = () => this.block.operation.length) {
1646
1635
  const operations = [operation].flat();
1647
1636
  expressions = expressions.filter((exp) => !isConstantExpression(exp));
1648
- if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast && isConstantNode(e.ast, {}))) return this.registerOperation(operations, getOperationIndex);
1637
+ if (this.inVOnce || expressions.length === 0 || expressions.every((e) => e.ast && isConstant(e.ast))) return this.registerOperation(operations, getOperationIndex);
1649
1638
  this.block.effect.splice(getEffectIndex(), 0, {
1650
1639
  expressions,
1651
1640
  operations
@@ -1994,7 +1983,7 @@ function processConditionalExpression(node, context) {
1994
1983
  id,
1995
1984
  condition,
1996
1985
  positive: branch,
1997
- once: context.inVOnce || isStaticNode(test)
1986
+ once: context.inVOnce || isConstant(test)
1998
1987
  };
1999
1988
  return [() => {
2000
1989
  onExit();
@@ -2162,7 +2151,7 @@ function processFor(node, dir, context) {
2162
2151
  return () => {
2163
2152
  exitBlock();
2164
2153
  const { parent } = context;
2165
- 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;
2166
2155
  context.dynamic.operation = {
2167
2156
  type: IRNodeTypes.FOR,
2168
2157
  id,
@@ -2172,7 +2161,7 @@ function processFor(node, dir, context) {
2172
2161
  index,
2173
2162
  keyProp: keyProperty,
2174
2163
  render,
2175
- once: context.inVOnce || !!(source.ast && isConstantNode(source.ast, {})),
2164
+ once: context.inVOnce || !!(source.ast && isConstant(source.ast)),
2176
2165
  component: isComponent,
2177
2166
  onlyChild: !!isOnlyChild
2178
2167
  };
@@ -2247,7 +2236,7 @@ function processIf(node, attribute, context) {
2247
2236
  id,
2248
2237
  condition: dir.exp,
2249
2238
  positive: branch,
2250
- once: context.inVOnce || isConstantNode(attribute.value, {})
2239
+ once: context.inVOnce || isConstant(attribute.value)
2251
2240
  };
2252
2241
  };
2253
2242
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vue-jsx-vapor/compiler",
3
- "version": "2.5.2",
3
+ "version": "2.5.4-beta.1",
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": "https://pkg.pr.new/@vue/compiler-dom@5771104",
40
- "@vue/shared": "https://pkg.pr.new/@vue/shared@5771104",
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
  },