@cloudbase/lowcode-builder 1.2.4 → 1.3.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.
@@ -1,7 +1,7 @@
1
1
  import { observable } from 'mobx';
2
2
  import { createComponent } from '../../../common/weapp-component'
3
3
  import { concatClassList, px2rpx } from '../../../common/style'
4
- import { app } from '../../../app/weapps-api'
4
+ import { app, $app } from '../../../app/weapps-api'
5
5
  <%= importor.lifecycle? "import lifeCycle from './lowcode/lifecycle'" : "const lifeCycle = {}" %>
6
6
  <%= importor.state? "import stateFn from './lowcode/state'" : "const stateFn = {}" %>
7
7
  <%= importor.computed? "import computedFuncs from './lowcode/computed'" : "const computedFuncs = {}" %>
@@ -11,7 +11,6 @@ import * as constObj from '../libCommonRes/const'
11
11
  import * as toolsObj from '../libCommonRes/tools'
12
12
 
13
13
  const libCode = '<%= materialName %>'
14
- const $app = new Proxy({}, { get: function(obj, prop){ return app[prop] }});
15
14
 
16
15
  const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
17
16
 
@@ -19,9 +18,9 @@ const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listen
19
18
  <%= handlerName%>: [
20
19
  <%listeners.map(l=> { %>{
21
20
  key: '<%= l.key %>',
22
- handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else if (l.type === 'inline') {%> function({event, lists, forItems, $context}, $comp){ <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
21
+ handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else {%> <%= l.handler %> <%} %>,
23
22
  data: <%= stringifyObj(l.data, {depth: null}) %>,
24
- boundData: {<% Object.entries(l.boundData).map(([prop, bindMeta])=>{%>'<%= prop %>':($comp, lists, forItems, event, $context) => {<%= bindMeta.imports %> return (
23
+ boundData: {<% Object.entries(l.boundData).map(([prop, bindMeta])=>{%>'<%= prop %>':($comp, lists, forItems, event, $context, $w) => {<%= bindMeta.imports %> return (
25
24
  <%= bindMeta.expression === '' ? 'undefined': bindMeta.expression %>
26
25
  )},
27
26
  <%}) %>}
@@ -51,7 +50,7 @@ const handler = {<% handlers.forEach(h => {%>
51
50
 
52
51
  const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
53
52
  <%= id %>: { <% Object.entries(widgetBinds).map(([prop, bindMeta]) => { %>
54
- "<%= prop %>": function ($comp, lists, forItems, event, $context) {<%= bindMeta.imports %> return (
53
+ "<%= prop %>": function ($comp, lists, forItems, event, $context, $w) {<%= bindMeta.imports %> return (
55
54
  <%= bindMeta.expression === '' ? 'undefined': bindMeta.expression %>
56
55
  ); },<% }) %>
57
56
  },<%}) %>
@@ -5,7 +5,7 @@
5
5
  "dependencies": {<% if(importJSSDK) {%>
6
6
  "@cloudbase/js-sdk": "2.5.6-beta.1",<% } %>
7
7
  "@cloudbase/oauth": "0.1.1-alpha.5",
8
- "@cloudbase/weda-client": "0.2.36",
8
+ "@cloudbase/weda-client": "0.2.39",
9
9
  "@cloudbase/weda-cloud-sdk": "1.0.26",
10
10
  "mobx": "^5.15.4",
11
11
  "lodash.get": "^4.4.2",
@@ -1 +1,24 @@
1
- export const $page = {}
1
+ import { $w as baseAPI } from '<%= subLevelPath %>../../app/weapps-api'
2
+
3
+ export const $page = {
4
+ __internal__: {}
5
+ };
6
+
7
+ export const $w = new Proxy(
8
+ baseAPI,
9
+ {
10
+ get(target, prop) {
11
+ if(prop === '$page'){
12
+ return $page
13
+ }
14
+ // 尝试代理页面级别组件实例
15
+ const pageWidget = $page.widgets?.[prop];
16
+ if (pageWidget) {
17
+ return pageWidget._userWidget;
18
+ }
19
+ return target[prop]
20
+ },
21
+ },
22
+ );
23
+
24
+ $page.__internal__.$w = $w
@@ -1,24 +1,22 @@
1
1
  import { observable } from 'mobx';
2
2
  import { createPage } from '<%= subLevelPath %>../../common/weapp-page'
3
3
  import { concatClassList, px2rpx } from '<%= subLevelPath %>../../common/style'
4
- import { app } from '<%= subLevelPath %>../../app/weapps-api'
4
+ import { app, $app } from '<%= subLevelPath %>../../app/weapps-api'
5
5
  import { $$<%= pageName %> as handlers } from '../../app/handlers'
6
6
  <%= importor.lifecycle? `import lifecyle from '../../lowcode/${pageName}/lifecycle'` : "const lifecyle = {}" %>
7
7
  <%= importor.state? `import state from '../../lowcode/${pageName}/state'` : "const state = {}" %>
8
8
  <%= importor.computed? `import computed from '../../lowcode/${pageName}/computed'` : "const computed = {}" %>
9
9
  import { $page } from './api'
10
10
 
11
- const $app = new Proxy({}, { get: function(obj, prop){ return app[prop] }});
12
-
13
11
  const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
14
12
  /** widget event listeners **/
15
13
  const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listeners])=>{%>
16
14
  <%= handlerName%>: [
17
15
  <%listeners.map(l=> { %>{
18
16
  key: '<%= l.key %>',
19
- handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else if (l.type == 'inline') {%> function({event, lists, forItems, $context}){const $for = forItems; const $index=lists?.[0]?.currentIndex; return <%= l.handler %> } <%} else {%> <%= l.handler %> <%} %>,
17
+ handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else {%> <%= l.handler %> <%} %>,
20
18
  data: <%= stringifyObj(l.data, {depth: null}) %>,
21
- boundData: {<% Object.entries(l.boundData).map(([prop, bindMeta])=>{%>'<%= prop %>':($page, lists, forItems, event, $context) => {<%= bindMeta.imports %> return (
19
+ boundData: {<% Object.entries(l.boundData).map(([prop, bindMeta])=>{%>'<%= prop %>':($page, lists, forItems, event, $context, $w) => {<%= bindMeta.imports %> return (
22
20
  <%= bindMeta.expression === '' ? 'undefined': bindMeta.expression %>
23
21
  )},
24
22
  <%}) %>}
@@ -28,7 +26,7 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
28
26
 
29
27
  const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
30
28
  <%= id %>: { <% Object.entries(widgetBinds).map(([prop, bindMeta]) => { %>
31
- "<%= prop %>": function ($page, lists, forItems, event, $context) {<%= bindMeta.imports %> return (
29
+ "<%= prop %>": function ($page, lists, forItems, event, $context, $w) {<%= bindMeta.imports %> return (
32
30
  <%= bindMeta.expression === '' ? 'undefined': bindMeta.expression %>
33
31
  ); },<% }) %>
34
32
  },<%}) %>
@@ -1,3 +1,3 @@
1
1
  {
2
- "usingComponents": <%= JSON.stringify(usingComponents)%><%= extra %>
2
+ "usingComponents": <%= JSON.stringify(usingComponents, undefined, 2)%><%= extra %>
3
3
  }
@@ -1 +0,0 @@
1
- export default { env: { buildType: 'mp' } }