@cloudbase/lowcode-builder 1.8.71 → 1.8.73

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.8.71",
3
+ "version": "1.8.73",
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",
@@ -44,7 +44,9 @@
44
44
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
45
45
  },
46
46
  "dependencies": {
47
- "@cloudbase/cals": "^1.0.57",
47
+ "@babel/core": "7.21.4",
48
+ "@babel/preset-env": "7.21.4",
49
+ "@cloudbase/cals": "^1.0.59",
48
50
  "@cloudbase/lowcode-generator": "^1.8.24",
49
51
  "axios": "^0.21.0",
50
52
  "browserfs": "^1.4.3",
@@ -78,7 +80,6 @@
78
80
  "@types/weixin-app": "^2.9.0",
79
81
  "cross-env": "^7.0.3",
80
82
  "csstype": "^2.6.10",
81
- "jest": "^27.5.1",
82
83
  "ts-loader": "^8.3.0",
83
84
  "ts-node": "^10.4.0",
84
85
  "tsc-watch": "^6.0.4",
@@ -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.5d28c337dc394d80cf5d.bundle.js"
546
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.72ae321d6810e4fa769a.bundle.js"
547
547
  ></script>
548
548
  </body>
549
549
  </html>
@@ -1,12 +1,11 @@
1
1
  import { observable } from 'mobx'
2
2
  import { createMpApp } from '@cloudbase/weda-client';
3
- import { createComputed, formatEnum, enumOptions } from '<%= subLevelPath %>../common/util'
3
+ import { createComputed, formatEnum, enumOptions, generateDatasetQuery } from '<%= subLevelPath %>../common/util'
4
4
  import appGlobal from '<%= subLevelPath %>../app/app-global'
5
5
  import { createDataset } from '<%= subLevelPath %>../datasources/index'
6
6
 
7
7
  import lodashGet from 'lodash.get';
8
8
  import config from '<%= subLevelPath %>../common/config';
9
- import { generateDatasetQuery } from '../common/util';
10
9
 
11
10
 
12
11
  <%= importor.state? `import state from '../lowcode/state'` : "const state = {}" %>
@@ -4,7 +4,7 @@ export function getDatapatch(base, pendingData) {
4
4
  for (const widgetId in pendingData) {
5
5
  const baseWidget = base[widgetId]
6
6
  const pendingWidget = pendingData[widgetId]
7
- if (!baseWidget) {
7
+ if (!baseWidget || typeof pendingWidget === 'string') {
8
8
  patch[widgetId] = pendingWidget
9
9
  } else {
10
10
  patchProp(baseWidget, pendingWidget, patch, widgetId)
@@ -17,17 +17,20 @@ function patchProp(baseWidget, pendingWidget, patch, prefixes) {
17
17
  if (Array.isArray(pendingWidget)) {
18
18
  /**
19
19
  * 数组长度发生变化,更新整个数组
20
+ * 当启用 _WaForKey,且可以取到key时,更新整个数组
20
21
  * 通过 array[0].xxx 进行更新,id 不会更新,疑似 mp 实现 bug
21
22
  */
22
23
  if (pendingWidget.length != baseWidget.length) {
23
24
  patch[prefixes] = pendingWidget
24
- return
25
- }
26
- for (let i = 0; i < pendingWidget.length; i++) {
27
- if (!baseWidget[i]) {
28
- patch[prefixes + '[' + i + ']'] = pendingWidget[i]
29
- } else {
30
- patchProp(baseWidget[i], pendingWidget[i], patch, prefixes + '[' + i + ']')
25
+ } else if (pendingWidget?.some(item=>item._waForKey) && pendingWidget[0]?._key) {
26
+ patch[prefixes] = pendingWidget
27
+ } else {
28
+ for (let i = 0; i < pendingWidget.length; i++) {
29
+ if (!baseWidget[i]) {
30
+ patch[prefixes + '[' + i + ']'] = pendingWidget[i]
31
+ } else {
32
+ patchProp(baseWidget[i], pendingWidget[i], patch, prefixes + '[' + i + ']')
33
+ }
31
34
  }
32
35
  }
33
36
  } else {
@@ -5,13 +5,9 @@ import { getDatapatch } from './data-patch'
5
5
 
6
6
  export default {
7
7
  // Attention, must be called at the end of attached or page load to make sure user init take effect
8
- initMergeRenderer(widgets) {
8
+ initMergeRenderer(widgets, dataFactory = {}) {
9
9
  this.flushPendingData = throttle(this.flushPendingData.bind(this), 18)
10
10
 
11
- const dataFactory = {
12
- // <%= dataPropNames.pageState %>: () => pageState,
13
- // <%= dataPropNames.pageComputed %>: () => pageComputed,
14
- }
15
11
  for (const id in widgets) {
16
12
  const props = widgets[id]
17
13
  dataFactory['<%= dataPropNames.widgetProp %>' + id] = () => resolveWidgetData(props, id)
@@ -5,7 +5,7 @@ import { toDash } from './util'
5
5
  export function styleToCss(style) {
6
6
  const styleDeclars = [] // ['color: red;', 'background-color: green']
7
7
  for (const key in style) {
8
- styleDeclars.push(toDash(key) + ':' + style[key] + ';')
8
+ styleDeclars.push(`${/^--/.test(key) ? key : toDash(key)}:${style[key]};`)
9
9
  }
10
10
  return styleDeclars.join('')
11
11
  }
@@ -201,7 +201,7 @@ export function createEventHandlers(
201
201
  if (!self[nextHandler.handlerName] && error) {
202
202
  const message = generateErrorDebugMessage(error) || error.errMsg || ''
203
203
  console.error(`Action error:`, message, error?.stack);
204
- if (!looseError) {
204
+ if (!looseError && !/scanCode:fail cancel/.test(message)) {
205
205
  if (app.__internal__?.env?.type !== 'production') {
206
206
  app.showModal({
207
207
  title: `事件响应失败`,
@@ -22,6 +22,7 @@ import { $w as baseAPI } from '../app/weapps-api';
22
22
  import { Event } from './event-emitter';
23
23
  import { generatePageUrl } from '@cloudbase/weda-client';
24
24
  import { mergeDynamic2StaticData, patchWdigetPropsWithEvtListeners } from './util';
25
+ import { styleToCss } from './style';
25
26
 
26
27
  export const PAGE_ROOT_SYMBOL = Symbol('@@page_route@@')
27
28
 
@@ -118,6 +119,7 @@ export function createPage({
118
119
 
119
120
  const evtHandlers = createEventHandlers(evtListeners);
120
121
  const {[PAGE_ROOT_SYMBOL]: pageRootDataBinds, ...componentDataBinds} = dataBinds
122
+ const staticPageStyle = <%= pageStyle || '{}' %>
121
123
 
122
124
  return Component({
123
125
  _componentType: 'page',
@@ -127,7 +129,7 @@ export function createPage({
127
129
  _expiredMessage: '',
128
130
  weDaHasLogin: null,
129
131
  loginError: null,
130
- pageStyle: `<%= pageStyle || '' %>`
132
+ pageStyle: styleToCss(staticPageStyle)
131
133
  },
132
134
  lifetimes: {
133
135
  attached() {
@@ -158,7 +160,33 @@ export function createPage({
158
160
  const widget = getWidget($page.widgets, e.target.id);
159
161
  widget._methods = {};
160
162
  };
161
- this._disposers.push(...this.initMergeRenderer($page.widgets));
163
+ this._disposers.push(...this.initMergeRenderer($page.widgets, {
164
+ pageStyle: () => {
165
+ let pageStyle = { ...staticPageStyle }
166
+ try {
167
+ if ( pageRootDataBinds.style ) {
168
+ const { style } = mergeDynamic2StaticData({}, {
169
+ style: pageRootDataBinds.style
170
+ }, {
171
+ codeContext: {
172
+ /**
173
+ * $page 或 $comp 实例
174
+ */
175
+ instance: $page,
176
+ },
177
+ $w: $page?.__internal__?.$w,
178
+ })
179
+ pageStyle = {
180
+ ...pageStyle,
181
+ ...style
182
+ }
183
+ }
184
+ } catch(e) {
185
+ console.warn('页面动态style绑定计算失败:', e)
186
+ }
187
+ return styleToCss(pageStyle)
188
+ }
189
+ }));
162
190
  getExpiredMessage(<%= expirationStartTimesnap %>).then(message => {
163
191
  if (message) {
164
192
  this.setData({
@@ -77,7 +77,7 @@ export function resolveWidgetData(props, widgetId) {
77
77
  if (!Array.isArray(props)) {
78
78
  return resolveWidgetProp(props, widgetId);
79
79
  }
80
- return props.map(prop => resolveWidgetData(prop, widgetId));
80
+ return props.map((prop) => resolveWidgetData(prop, widgetId));
81
81
  }
82
82
 
83
83
  export function createWidgets(widgetProps, dataBinds, ownerMpInst, widgetHolder) {
@@ -135,7 +135,8 @@ function createSubWidgetTree(
135
135
  (node, parentNode, cache) => {
136
136
  const parentForWidgetArr = ownerForWidgetHolder[node.id] || [];
137
137
  const { _waForKey } = node.value;
138
- const key = forContext.forItems?.[node.id]?.[_waForKey];
138
+
139
+ const key = forContext.forItems?.[node.id]?.[_waForKey] || currentIndex;
139
140
  let forExistingWidgetMap = {};
140
141
  let forExsitWidget;
141
142
 
@@ -280,8 +281,8 @@ function runFor(curForNode, dataBinds, ownerMpInst, forContext, ownerForWidgetHo
280
281
  // dispose widgets before reused instead
281
282
  // disposeWidgets(parentForWidgets[curForNode.id])
282
283
  const exsitMap = forList.reduce((map, item, index) => {
283
- const cache = item?.[_waForKey];
284
- if (map[cache] === undefined) {
284
+ const cache = item?.[_waForKey] || index;
285
+ if (cache !== undefined && map[cache] === undefined) {
285
286
  map[cache] = index;
286
287
  }
287
288
  return map;
@@ -291,17 +292,18 @@ function runFor(curForNode, dataBinds, ownerMpInst, forContext, ownerForWidgetHo
291
292
  const existingWidgetIndexMap = {};
292
293
  const extraWidgetsIndexMap = {};
293
294
  forWidgets.forEach((widget, index) => {
294
- if (exsitMap[widget._key] !== undefined) {
295
+ const cecheKey = widget._key || index;
296
+ if (exsitMap[cecheKey] !== undefined) {
295
297
  const nodeId = widget.id?.split(ID_SEPARATOR)[0];
296
- existingWidgetMap[widget._key] = { index: exsitMap[widget._key], widgets: { [nodeId]: widget } };
298
+ existingWidgetMap[cecheKey] = { index: exsitMap[cecheKey], widgets: { [nodeId]: widget } };
297
299
  /**
298
- * 此处依赖了 existingWidgetMap[widget._key].widgets 的引用,
300
+ * 此处依赖了 existingWidgetMap[cecheKey].widgets 的引用,
299
301
  * 为了直接可以通过 index 访问到 existingWidgetMap 里的值进行编辑
300
302
  * 但是依赖引用关系,存在维护风险
301
303
  */
302
- existingWidgetIndexMap[index] = existingWidgetMap[widget._key].widgets;
304
+ existingWidgetIndexMap[index] = existingWidgetMap[cecheKey].widgets;
303
305
  // need to use uqique key
304
- exsitMap[widget._key] = undefined;
306
+ exsitMap[cecheKey] = undefined;
305
307
  } else {
306
308
  extraWidgetsIndexMap[index] = widget;
307
309
  }