@wevu/compiler 6.16.25 → 6.16.27

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.
Files changed (2) hide show
  1. package/dist/index.mjs +26 -6
  2. package/package.json +6 -6
package/dist/index.mjs CHANGED
@@ -5743,6 +5743,9 @@ function buildCtxValueAccess(member) {
5743
5743
  function isValueMemberObject(node, parent) {
5744
5744
  return t.isMemberExpression(parent) && parent.object === node && t.isIdentifier(parent.property, { name: "value" }) && !parent.computed;
5745
5745
  }
5746
+ function isCallTarget(node, parent) {
5747
+ return (t.isCallExpression(parent) || t.isOptionalCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node;
5748
+ }
5746
5749
  function rewriteTopLevelRefLikeAccess(ast, context) {
5747
5750
  traverse(ast, {
5748
5751
  AssignmentExpression(path) {
@@ -5761,6 +5764,7 @@ function rewriteTopLevelRefLikeAccess(ast, context) {
5761
5764
  traverse(ast, { MemberExpression(path) {
5762
5765
  if (!isRefLikeCtxMember(path.node, context)) return;
5763
5766
  if (isValueMemberObject(path.node, path.parentPath?.node)) return;
5767
+ if (isCallTarget(path.node, path.parentPath?.node)) return;
5764
5768
  path.replaceWith(buildCtxValueAccess(path.node));
5765
5769
  path.skip();
5766
5770
  } });
@@ -7116,7 +7120,7 @@ function transformSlotElement(node, context, transformNode) {
7116
7120
  ];
7117
7121
  if (context.slotMultipleInstance) scopedAttrs.push(`${WEVU_SLOT_SCOPE_ATTR}="${renderMustache(WEVU_SLOT_SCOPE_KEY, context)}"`);
7118
7122
  const scopedTag = `<${genericKey}${scopedAttrs.length ? ` ${scopedAttrs.join(" ")}` : ""} />`;
7119
- const projectedContent = hasScopeBindings ? scopedTag : `${scopedTag}${context.platform.wrapElse(slotTag)}`;
7123
+ const projectedContent = hasScopeBindings ? `${slotTag}${scopedTag}` : `${scopedTag}${context.platform.wrapElse(slotTag)}`;
7120
7124
  if (fallbackContent && slotPresentExp) return `${context.platform.wrapIf(slotPresentExp, projectedContent, (exp) => renderMustache(exp, context))}${context.platform.wrapElse(fallbackContent)}`;
7121
7125
  return projectedContent;
7122
7126
  }
@@ -8731,7 +8735,15 @@ function resolveScriptSetupPropsDerivedKeys(bindings) {
8731
8735
  function collectScriptSetupReturnInfo(scriptCode) {
8732
8736
  const keys = /* @__PURE__ */ new Set();
8733
8737
  const propsObjectAliases = new Set(["__props"]);
8738
+ const propsRefsAliases = /* @__PURE__ */ new Set();
8734
8739
  const destructuredPropsKeys = /* @__PURE__ */ new Set();
8740
+ const addObjectPatternKeys = (pattern) => {
8741
+ for (const property of pattern.properties) {
8742
+ if (!t.isObjectProperty(property)) continue;
8743
+ if (t.isIdentifier(property.value)) destructuredPropsKeys.add(property.value.name);
8744
+ else if (t.isAssignmentPattern(property.value) && t.isIdentifier(property.value.left)) destructuredPropsKeys.add(property.value.left.name);
8745
+ }
8746
+ };
8735
8747
  try {
8736
8748
  traverse(parseJsLike(scriptCode), {
8737
8749
  VariableDeclarator(path) {
@@ -8740,12 +8752,20 @@ function collectScriptSetupReturnInfo(scriptCode) {
8740
8752
  propsObjectAliases.add(path.node.id.name);
8741
8753
  return;
8742
8754
  }
8743
- if (!t.isObjectPattern(path.node.id) || !t.isIdentifier(init) || !propsObjectAliases.has(init.name)) return;
8744
- for (const property of path.node.id.properties) {
8745
- if (!t.isObjectProperty(property)) continue;
8746
- if (t.isIdentifier(property.value)) destructuredPropsKeys.add(property.value.name);
8747
- else if (t.isAssignmentPattern(property.value) && t.isIdentifier(property.value.left)) destructuredPropsKeys.add(property.value.left.name);
8755
+ if (t.isIdentifier(path.node.id) && t.isCallExpression(init) && t.isIdentifier(init.callee, { name: "toRefs" }) && init.arguments.length === 1 && t.isIdentifier(init.arguments[0]) && propsObjectAliases.has(init.arguments[0].name)) {
8756
+ propsRefsAliases.add(path.node.id.name);
8757
+ return;
8758
+ }
8759
+ if (!t.isObjectPattern(path.node.id)) return;
8760
+ if (t.isIdentifier(init) && propsObjectAliases.has(init.name)) {
8761
+ addObjectPatternKeys(path.node.id);
8762
+ return;
8763
+ }
8764
+ if (t.isIdentifier(init) && propsRefsAliases.has(init.name)) {
8765
+ addObjectPatternKeys(path.node.id);
8766
+ return;
8748
8767
  }
8768
+ if (t.isCallExpression(init) && t.isIdentifier(init.callee, { name: "toRefs" }) && init.arguments.length === 1 && t.isIdentifier(init.arguments[0]) && propsObjectAliases.has(init.arguments[0].name)) addObjectPatternKeys(path.node.id);
8749
8769
  },
8750
8770
  ObjectProperty(path) {
8751
8771
  const objectPath = path.parentPath;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/compiler",
3
3
  "type": "module",
4
- "version": "6.16.25",
4
+ "version": "6.16.27",
5
5
  "description": "wevu 编译器基础包,面向小程序模板的编译与转换",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",
@@ -42,18 +42,18 @@
42
42
  ],
43
43
  "dependencies": {
44
44
  "@jridgewell/remapping": "^2.3.5",
45
- "@vue/compiler-core": "^3.5.34",
46
- "@vue/compiler-dom": "^3.5.34",
45
+ "@vue/compiler-core": "^3.5.35",
46
+ "@vue/compiler-dom": "^3.5.35",
47
47
  "comment-json": "^5.0.0",
48
48
  "lru-cache": "^11.5.0",
49
49
  "magic-string": "^0.30.21",
50
50
  "merge": "^2.1.1",
51
51
  "pathe": "^2.0.3",
52
- "vue": "^3.5.34",
52
+ "vue": "^3.5.35",
53
53
  "@weapp-core/constants": "0.1.10",
54
54
  "@weapp-core/shared": "3.0.4",
55
- "@weapp-vite/ast": "6.16.25",
56
- "rolldown-require": "2.0.17"
55
+ "@weapp-vite/ast": "6.16.27",
56
+ "rolldown-require": "2.0.18"
57
57
  },
58
58
  "publishConfig": {
59
59
  "access": "public",