@cloudbase/lowcode-builder 1.8.28 → 1.8.29

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.
@@ -22,7 +22,6 @@ export declare function generateConfig(data: {
22
22
  isPrivateMode?: boolean;
23
23
  endpointType?: IBuildContext['endpointType'] | '';
24
24
  }, root: string): Promise<void>;
25
- export declare function normalizePageId(pageId: any): string;
26
25
  export declare function writeLowCodeFiles(ctx: IBuildContext, appData: IWeAppData, outDir: string): Promise<void>;
27
26
  /**
28
27
  * TODO: 与 cals 里的实现进行整合
@@ -26,7 +26,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
26
26
  return (mod && mod.__esModule) ? mod : { "default": mod };
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
- exports.handleUsedComponents = exports.writeLowCodeFiles = exports.normalizePageId = exports.generateConfig = exports.generateWxMp = void 0;
29
+ exports.handleUsedComponents = exports.writeLowCodeFiles = exports.generateConfig = exports.generateWxMp = void 0;
30
30
  const chalk_1 = __importDefault(require("chalk"));
31
31
  const path_1 = __importDefault(require("path"));
32
32
  const util_1 = require("util");
@@ -288,20 +288,6 @@ async function generateConfig(data, root) {
288
288
  }, templateDir, root);
289
289
  }
290
290
  exports.generateConfig = generateConfig;
291
- /**
292
- * pageId 名称管理器
293
- * 因为 pageId 命名为非法
294
- */
295
- const _MANAGER_PAGE_ID_LIST = [];
296
- const _MANAGER_PAGE_ID_MAP = {};
297
- function normalizePageId(pageId) {
298
- if (!_MANAGER_PAGE_ID_MAP[pageId]) {
299
- _MANAGER_PAGE_ID_MAP[pageId] = `$${_MANAGER_PAGE_ID_LIST.length}`;
300
- _MANAGER_PAGE_ID_LIST.push(pageId);
301
- }
302
- return _MANAGER_PAGE_ID_MAP[pageId];
303
- }
304
- exports.normalizePageId = normalizePageId;
305
291
  async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
306
292
  const wxmlDataPrefix = (0, mp_1.getWxmlDataPrefix)(!ctx.isProduction);
307
293
  console.log(`Generating ${em(weapp.rootPath ? 'subApp' : 'app')} to ${appRoot}`);
@@ -349,7 +335,7 @@ async function generatePkg(ctx, weapp, appRoot, pageConfigs) {
349
335
  stringifyObj: util_1.inspect,
350
336
  },
351
337
  [`index.js|${pageFileName}.js`]: {
352
- pageNameVar: normalizePageId(page.id),
338
+ pageNameVar: (0, lowcode_generator_1.normalizePageId)(page.id),
353
339
  pageName: page.id,
354
340
  pageSource: page.data.src || '',
355
341
  eventHandlers: (0, util_2.createEventHandlers)(ctx, componentInstances, 'this', page),
@@ -419,7 +405,7 @@ async function generateFramework(ctx, appData, outDir, options) {
419
405
  (0, weapps_core_1.loopDealWithFn)(appData.pageInstanceList || [], (p) => {
420
406
  allCodeModules.push({
421
407
  id: p.id,
422
- pageNameVar: normalizePageId(p.id),
408
+ pageNameVar: (0, lowcode_generator_1.normalizePageId)(p.id),
423
409
  lowCodes: p.lowCodes || [],
424
410
  });
425
411
  });
@@ -271,6 +271,10 @@ function getListenersHandlers(listeners = [], id, componentApi) {
271
271
  handler = `function({data}){ return $w[data.id]?.[data.method](data.data)}`;
272
272
  break;
273
273
  }
274
+ case `${weapps_core_1.ActionType.Platform}:invoke`: {
275
+ handler = `function({data, $w}){ return $app.invoke({...data, component: $w[data?.component]?._widget});}`;
276
+ break;
277
+ }
274
278
  default: {
275
279
  handler = `function({data}){ return $app.${(_c = l.handler) === null || _c === void 0 ? void 0 : _c.name}(data)}`;
276
280
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.8.28",
3
+ "version": "1.8.29",
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",
@@ -41,8 +41,8 @@
41
41
  "dependencies": {
42
42
  "@babel/core": "7.12.3",
43
43
  "@babel/preset-env": "7.12.1",
44
- "@cloudbase/cals": "^1.0.18",
45
- "@cloudbase/lowcode-generator": "^1.8.10",
44
+ "@cloudbase/cals": "^1.0.20",
45
+ "@cloudbase/lowcode-generator": "^1.8.11",
46
46
  "axios": "^0.21.0",
47
47
  "browserfs": "^1.4.3",
48
48
  "browserify-zlib": "^0.2.0",
@@ -525,7 +525,7 @@
525
525
  crossorigin="anonymous"
526
526
  src="<%=
527
527
  cdnEndpoints.cdngo
528
- %>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.43/dist/h5.browser.js"
528
+ %>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.45/dist/h5.browser.js"
529
529
  ></script>
530
530
  <script
531
531
  crossorigin
@@ -551,7 +551,7 @@
551
551
  crossorigin
552
552
  src="<%=
553
553
  cdnEndpoints.cdngo
554
- %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.5ec891fedc6dc37d6d57.bundle.js"
554
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.70be648bc34aeb4c9760.bundle.js"
555
555
  ></script>
556
556
  </body>
557
557
  </html>
@@ -30,6 +30,7 @@ export default {
30
30
  // setData merging
31
31
  pendingData: null,
32
32
  _settingData: false, // flag to prevent multiple setData at the same time
33
+ _flushId: null,
33
34
  flushPendingData() {
34
35
  if (!this.pendingData || this._settingData) { return }
35
36
  const patch = getDatapatch(this.data, this.pendingData)
@@ -41,6 +42,17 @@ export default {
41
42
  }
42
43
  this._settingData = true
43
44
  const lastUpdateTime = Date.now()
45
+ this._flushId = lastUpdateTime;
46
+ /**
47
+ * 兜底逻辑,当长时间 setData 没有返回时
48
+ * 直接抛弃,扭转 pending 状态
49
+ */
50
+ setTimeout(()=>{
51
+ if(this._flushId === lastUpdateTime && this._settingData) {
52
+ this._settingData = false;
53
+ this.flushPendingData()
54
+ }
55
+ }, 100)
44
56
  this.setData(patch, () => {<% if(debug) {%>
45
57
  const elapsedTime = Date.now() - lastUpdateTime;
46
58
  if(elapsedTime > 16) {
@@ -136,7 +136,7 @@ export function createEventHandlers(
136
136
  },
137
137
  dataContext,
138
138
  });
139
- let res = await l.handler.call(owner, { event, data: resolvedData });
139
+ let res = await l.handler.call(owner, { event, data: resolvedData, $w });
140
140
  nextEventHandles[0].handlerName =
141
141
  prefix && l.key ? `${prefix}$${l.key}${!isIfAction || res ? '_success' : '_fail'}` : '';
142
142
  nextEventHandles[0].event.detail = isIfAction ? event.detail : res;
@@ -283,21 +283,30 @@ export function createPage({
283
283
  app.utils.set($page.dataset.state, keyPath, userSetState[keyPath]);
284
284
  });
285
285
  };
286
+ $page.setParams = (params) => {
287
+ Object.keys(params).forEach((keyPath) => {
288
+ app.utils.set($page.dataset?.params, keyPath, params[keyPath]);
289
+ });
290
+ }
286
291
 
287
292
  const { widgets, rootWidget } = createWidgets(widgetProps, dataBinds, this, $page.widgets);
288
293
  $page.widgets = widgets;
289
294
  $page._rootWidget = rootWidget;
290
295
 
291
296
  $page.invokeComponentMethod = ({ component, method, params }) => {
292
- const components = $page.widgets[component];
293
297
  let componentInstance = undefined;
294
- if (Array.isArray(components)) {
295
- if (components.length > 1) {
296
- throw new Error(`调用方法失败:id为${component}的组件拥有多个实例`);
298
+ if (typeof component === 'string') {
299
+ const components = $page.widgets[component];
300
+ if (Array.isArray(components)) {
301
+ if (components.length > 1) {
302
+ throw new Error(`调用方法失败:id为${component}的组件拥有多个实例`);
303
+ }
304
+ componentInstance = components[0];
305
+ } else {
306
+ componentInstance = components;
297
307
  }
298
- componentInstance = components[0];
299
308
  } else {
300
- componentInstance = components;
309
+ componentInstance = component
301
310
  }
302
311
 
303
312
  const currentInstanceRef = componentInstance?._getInstanceRef()?.current || {};
@@ -7,7 +7,7 @@
7
7
  } %>
8
8
  "@cloudbase/oauth": "0.1.1-alpha.5",
9
9
  "@cloudbase/weda-client": "1.0.6",
10
- "@cloudbase/weda-cloud-sdk": "1.0.43",
10
+ "@cloudbase/weda-cloud-sdk": "1.0.45",
11
11
  "mobx": "^5.15.4",
12
12
  "lodash.get": "^4.4.2",
13
13
  "lodash.set": "^4.3.2",