@cloudbase/lowcode-builder 1.8.58 → 1.8.60

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.
@@ -0,0 +1 @@
1
+ export declare function mergeCssVarConfig(cssVarConfig?: {}, platform?: any): Record<string, string>;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.mergeCssVarConfig = void 0;
4
+ function mergeCssVarConfig(cssVarConfig = {}, platform = 'PCWEB') {
5
+ let merged = { ...cssVarConfig === null || cssVarConfig === void 0 ? void 0 : cssVarConfig._ };
6
+ let list = [platform];
7
+ switch (platform) {
8
+ case 'PCWEB': {
9
+ list = ['WEB', 'PCWEB'];
10
+ break;
11
+ }
12
+ case 'MOBILEWEB': {
13
+ list = ['WEB', 'MOBILE', 'MOBILEWEB'];
14
+ break;
15
+ }
16
+ case 'MP': {
17
+ list = ['MOBILE', 'MP'];
18
+ break;
19
+ }
20
+ case 'WEB':
21
+ case 'MOBILE': {
22
+ list = [platform];
23
+ }
24
+ }
25
+ for (let key of list) {
26
+ if (cssVarConfig[key]) {
27
+ merged = {
28
+ ...merged,
29
+ ...cssVarConfig[key],
30
+ };
31
+ }
32
+ }
33
+ return merged;
34
+ }
35
+ exports.mergeCssVarConfig = mergeCssVarConfig;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.8.58",
3
+ "version": "1.8.60",
4
4
  "description": "云开发 Tencent CloudBase Framework Low Code Plugin,将低码配置生成完整项目并一键部署云开发资源。",
5
5
  "author": "yhsunshining@gmail.com",
6
6
  "homepage": "https://github.com/TencentCloudBase/cloudbase-framework#readme",
@@ -43,8 +43,10 @@
43
43
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
44
44
  },
45
45
  "dependencies": {
46
- "@cloudbase/cals": "^1.0.40",
47
- "@cloudbase/lowcode-generator": "^1.8.15",
46
+ "@babel/core": "7.21.4",
47
+ "@babel/preset-env": "7.21.4",
48
+ "@cloudbase/cals": "^1.0.45",
49
+ "@cloudbase/lowcode-generator": "^1.8.16",
48
50
  "axios": "^0.21.0",
49
51
  "browserfs": "^1.4.3",
50
52
  "browserify-zlib": "^0.2.0",
@@ -543,7 +543,7 @@
543
543
  crossorigin
544
544
  src="<%=
545
545
  cdnEndpoints.cdngo
546
- %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.c2d4a32f196583b43edf.bundle.js"
546
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.71408c38a7d1415e60ff.bundle.js"
547
547
  ></script>
548
548
  </body>
549
549
  </html>
@@ -37,26 +37,12 @@ const mainAppKey = '__weappsMainApp'
37
37
  Object.entries(eventHandlers).map(([handlerName, listeners])=>{
38
38
  print(`"${handlerName}": [
39
39
  ${listeners.map(l=>{
40
- let handler = 'undefined'
41
- switch(l.type){
42
- case 'rematch': {
43
- handler = `handlers.${l.handler}`
44
- break;
45
- }
46
- case 'material': {
47
- handler = `function(...args) { return require('/materials/${l.handlerModule}/actions/${l.handler}/index').default(...args) }`
48
- break;
49
- }
50
- default: {
51
- handler = l.handler
52
- }
53
- }
54
40
  return `{
55
41
  key: '${l.key||''}',
56
42
  sourceKey: '${ l.sourceKey||"" }',
57
- handler: ${handler},
58
- data: ${stringifyObj(l.data||{}, {depth: null})},
59
- boundData: {${printBoundData(l.boundData)}}
43
+ handler: ${l.generateHandler(subLevelPath) || 'undefined'},
44
+ args: ${stringifyObj(l.args||{}, {depth: null})},
45
+ argsBinds: {${printBoundData(l.argsBinds)}}
60
46
  }`
61
47
  }).join(',')}
62
48
  ],`)
@@ -171,12 +171,12 @@ export class Query {
171
171
  return this.#schema;
172
172
  }
173
173
 
174
- async #innerTrigger(data, options = {}) {
174
+ async #innerTrigger(args, options = {}) {
175
175
  this.#currentRequestKey = Date.now();
176
176
  const key = this.#currentRequestKey;
177
177
  try {
178
178
  this.#observableValue.isFetching = true;
179
- const res = await this.#action(data);
179
+ const res = await this.#action(...args);
180
180
  if (key === this.#currentRequestKey) {
181
181
  this.#observableValue.isFetching = false;
182
182
  this.#observableValue.data = res;
@@ -209,16 +209,13 @@ export class Query {
209
209
  * 好像会阻塞其他字段的计算
210
210
  * 从而导致 autorun 没有添加依赖
211
211
  */
212
- return mergeDynamic2StaticData(toJS(this.#paramsRef.current), this.#dataBinds, {
213
- codeContext: {
214
- /**
215
- * $page 或 $comp 实例
216
- */
217
- instance: this.#context.$page,
218
- },
219
- $w: this.#context.$w,
220
- paramsContext: additionalScope,
221
- });
212
+ let { params = [] } =
213
+ mergeDynamic2StaticData(toJS(this.#paramsRef.current), this.#dataBinds, {
214
+ $w: this.#context.$w,
215
+ paramsContext: additionalScope,
216
+ }) || {};
217
+
218
+ return params;
222
219
  }
223
220
  async #emit(eventName, data) {
224
221
  return this.#eventHandlerMap[getMpEventHandlerName(this.id, eventName)]?.(
@@ -113,8 +113,8 @@ export function createEventHandlers(
113
113
  return;
114
114
  }
115
115
 
116
- let { data = {}, boundData = {} } = l;
117
- data = { ...data };
116
+ let { args = {}, argsBinds = {} } = l;
117
+ args = { ...args };
118
118
  const nextEventHandles = [
119
119
  {
120
120
  handlerName: '',
@@ -128,7 +128,7 @@ export function createEventHandlers(
128
128
  const isIfAction = l.sourceKey === 'platform:utils.If';
129
129
  const isShowModalAction = l.sourceKey === 'platform:showModal';
130
130
  try {
131
- const resolvedData = mergeDynamic2StaticData(data, boundData, {
131
+ const resolvedData = mergeDynamic2StaticData(args, argsBinds, {
132
132
  $w,
133
133
  forContext,
134
134
  codeContext: {
@@ -137,7 +137,7 @@ export function createEventHandlers(
137
137
  },
138
138
  dataContext,
139
139
  });
140
- let res = await l.handler.call(owner, { event, data: resolvedData, $w });
140
+ let res = await l.handler.call(owner, { event, data: resolvedData.params?.[0], args: resolvedData.params || [], $w });
141
141
  nextEventHandles[0].handlerName =
142
142
  prefix && l.key ? `${prefix}$${l.key}${!isIfAction || res ? '_success' : '_fail'}` : '';
143
143
  nextEventHandles[0].event.detail = isIfAction ? event.detail : res;
@@ -124,7 +124,8 @@ export function createPage({
124
124
  _isCheckingAtuh: false,
125
125
  _expiredMessage: '',
126
126
  weDaHasLogin: null,
127
- loginError: null
127
+ loginError: null,
128
+ pageStyle: `<%= pageStyle || '' %>`
128
129
  },
129
130
  lifetimes: {
130
131
  attached() {
@@ -6,25 +6,37 @@ import { app, $app } from '../../../app/weapps-api'
6
6
  <%= importor.state? "import stateFn from './lowcode/state'" : "const stateFn = {}" %>
7
7
  <%= importor.computed? "import computedFuncs from './lowcode/computed'" : "const computedFuncs = {}" %>
8
8
  <% handlers.forEach(h => {%>
9
- import _handler<%= h %> from './lowcode/handler/<%= h %>' <%}) %>
9
+ import _hanlder<%= h %> from './lowcode/handler/<%= h %>' <%}) %>
10
10
  import * as constObj from '../libCommonRes/const'
11
11
  import * as toolsObj from '../libCommonRes/tools'
12
12
 
13
+ const handlers = {<% handlers.forEach(h => {%>
14
+ <%= h %>: _hanlder<%= h %>, <%}) %>
15
+ }
16
+
13
17
  const libCode = '<%= materialName %>'
14
18
 
15
19
  const widgetProps = <%= stringifyObj(widgetProps, {depth: null}) %>
16
20
 
21
+ <% function printBoundData(boundData={}) {
22
+ const list = []
23
+ Object.entries(boundData).map(([prop, bindMeta])=>{
24
+ const str = `'${prop}': ($comp, lists, forItems, event, $context, $w) => {${bindMeta.imports} return(
25
+ ${bindMeta.expression === '' ? 'undefined': bindMeta.expression}
26
+ )}`
27
+ list.push(str)
28
+ })
29
+ return list.join(',')
30
+ }%>
31
+
17
32
  const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listeners])=>{%>
18
33
  <%= handlerName%>: [
19
34
  <%listeners.map(l=> { %>{
20
35
  key: '<%= l.key %>',
21
36
  sourceKey: '<%= l.sourceKey %>',
22
- handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else {%> <%= l.handler %> <%} %>,
23
- data: <%= stringifyObj(l.data, {depth: null}) %>,
24
- boundData: {<% Object.entries(l.boundData).map(([prop, bindMeta])=>{%>'<%= prop %>':($comp, lists, forItems, event, $context, $w) => {<%= bindMeta.imports %> return (
25
- <%= bindMeta.expression === '' ? 'undefined': bindMeta.expression %>
26
- )},
27
- <%}) %>}
37
+ handler: <%= l.generateHandler('../') %>,
38
+ args: <%= stringifyObj(l.args, {depth: null}) %>,
39
+ argsBinds: { <%= printBoundData(l.argsBinds) %>}
28
40
  },<%})%>
29
41
  ],<%})%>
30
42
  }
@@ -45,19 +57,14 @@ const events = [<% emitEvents.map(evtName => {%>
45
57
  {name: "<%= evtName %>", <% if(formEvents && formEvents[evtName]){%>getValueFromEvent: (event)=> <%= formEvents[evtName] %><%}%>},<%}) %>
46
58
  ]
47
59
 
48
- const handler = {<% handlers.forEach(h => {%>
49
- <%= h %>: _handler<%= h %>, <%}) %>
50
- }
60
+
51
61
 
52
62
  const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
53
- <%= id %>: { <% Object.entries(widgetBinds).map(([prop, bindMeta]) => { %>
54
- "<%= prop %>": function ($comp, lists, forItems, event, $context, $w) {<%= bindMeta.imports %> return (
55
- <%= bindMeta.expression === '' ? 'undefined': bindMeta.expression %>
56
- ); },<% }) %>
63
+ <%= id %>: { <%= printBoundData(widgetBinds) %>
57
64
  },<%}) %>
58
65
  }
59
66
 
60
67
  const config = <%= JSON.stringify(config || {})%>
61
68
 
62
- createComponent('<%= key %>', behaviors, properties, events, handler, dataBinds, evtListeners, widgetProps,
69
+ createComponent('<%= key %>', behaviors, properties, events, handlers, dataBinds, evtListeners, widgetProps,
63
70
  {}, lifeCycle, stateFn, computedFuncs, config, { const: constObj, tools: toolsObj }, libCode)
@@ -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": "1.0.14",
8
+ "@cloudbase/weda-client": "1.0.19",
9
9
  "@cloudbase/weda-cloud-sdk": "1.0.49",
10
10
  "mobx": "^5.15.4",
11
11
  "lodash.get": "^4.4.2",
@@ -24,26 +24,12 @@ import { widgetProps } from './data'
24
24
  Object.entries(eventHandlers).map(([handlerName, listeners])=>{
25
25
  print(`"${handlerName}": [
26
26
  ${listeners.map(l=>{
27
- let handler = 'undefined'
28
- switch(l.type){
29
- case 'rematch': {
30
- handler = `handlers.${l.handler}`
31
- break;
32
- }
33
- case 'material': {
34
- handler = `function(...args) { return require('../../materials/${l.handlerModule}/actions/${l.handler}/index').default(...args) }`
35
- break;
36
- }
37
- default: {
38
- handler = l.handler
39
- }
40
- }
41
27
  return `{
42
28
  key: '${l.key||''}',
43
29
  sourceKey: '${ l.sourceKey||"" }',
44
- handler: ${handler},
45
- data: ${stringifyObj(l.data||{}, {depth: null})},
46
- boundData: {${printBoundData(l.boundData)}}
30
+ handler: ${l.generateHandler(subLevelPath) || 'undefined'},
31
+ args: ${stringifyObj(l.args||{}, {depth: null})},
32
+ argsBinds: {${printBoundData(l.argsBinds)}}
47
33
  }`
48
34
  }).join(',')}
49
35
  ],`)