@wevu/compiler 6.6.8 → 6.6.9

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 +7 -1
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -4676,11 +4676,17 @@ function createIdentifierAccessWithPropsFallback(name) {
4676
4676
  const thisAccess = createThisMemberAccess(name);
4677
4677
  const propsAccess = createMemberAccess(createThisMemberAccess("__wevuProps"), name);
4678
4678
  const propsObject = createThisMemberAccess("__wevuProps");
4679
+ const stateObject = createThisMemberAccess("$state");
4679
4680
  const hasPropsObject = t.binaryExpression("!=", propsObject, t.nullLiteral());
4680
4681
  const hasDefinedPropsValue = t.binaryExpression("!==", propsAccess, t.identifier("undefined"));
4681
4682
  const hasPropsKey = createHasOwnPropertyCall(propsObject, name);
4682
4683
  const hasUsablePropsValue = t.logicalExpression("&&", hasPropsObject, t.logicalExpression("||", hasDefinedPropsValue, hasPropsKey));
4683
- return t.conditionalExpression(hasUsablePropsValue, propsAccess, thisAccess);
4684
+ const hasStateObject = t.binaryExpression("!=", stateObject, t.nullLiteral());
4685
+ const hasStateKey = createHasOwnPropertyCall(stateObject, name);
4686
+ const hasThisMember = t.binaryExpression("in", t.stringLiteral(name), t.thisExpression());
4687
+ const shouldUseStateAccess = t.logicalExpression("&&", hasStateObject, hasStateKey);
4688
+ const shouldUsePropsAccess = t.logicalExpression("&&", hasUsablePropsValue, t.unaryExpression("!", hasThisMember));
4689
+ return t.conditionalExpression(shouldUseStateAccess, thisAccess, t.conditionalExpression(shouldUsePropsAccess, propsAccess, thisAccess));
4684
4690
  }
4685
4691
  function normalizeJsExpressionWithContext(exp, context, options) {
4686
4692
  const trimmed = exp.trim();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@wevu/compiler",
3
3
  "type": "module",
4
- "version": "6.6.8",
4
+ "version": "6.6.9",
5
5
  "description": "wevu 编译器基础包,面向小程序模板的编译与转换",
6
6
  "author": "ice breaker <1324318532@qq.com>",
7
7
  "license": "MIT",