@cloudbase/lowcode-builder 1.6.4-alpha.0 → 1.6.5

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.6.4-alpha.0",
3
+ "version": "1.6.5",
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",
@@ -38,8 +38,8 @@
38
38
  "url": "https://github.com/TencentCloudBase/cloudbase-framework/issues"
39
39
  },
40
40
  "dependencies": {
41
- "@cloudbase/cals": "workspace:^",
42
- "@cloudbase/lowcode-generator": "workspace:^",
41
+ "@cloudbase/cals": "^1.0.3",
42
+ "@cloudbase/lowcode-generator": "^1.6.5",
43
43
  "axios": "^0.21.0",
44
44
  "browserfs": "^1.4.3",
45
45
  "browserify-zlib": "^0.2.0",
@@ -81,4 +81,4 @@
81
81
  "webpack-dev-server": "^4.7.3",
82
82
  "worker-loader": "^3.0.8"
83
83
  }
84
- }
84
+ }
@@ -18,14 +18,35 @@
18
18
  />
19
19
  <% cssStyles.forEach(function(styleUrl){%>
20
20
  <link type="text/css" rel="stylesheet" href="<%=styleUrl %>" />
21
- <% })%>
22
-
21
+ <% })%> <% if(cdnEndpoints.aegis){ %>
22
+ <script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis-sdk/latest/aegis.min.js"></script>
23
+ <script>
24
+ <% if(!isAdminPortal){ %>
25
+ const _aegis = new Aegis({
26
+ id: 'lXHFsBpTjIzNADiczY', // 项目ID,即上报key
27
+ reportApiSpeed: true, // 接口测速
28
+ reportAssetSpeed: true, // 静态资源测速
29
+ spa: true,
30
+ ext1: '<%=appId%>',
31
+ });
32
+ <% } else {%>
33
+ const _aegis = new Aegis({
34
+ id: 'lXHFsBpTrKcnOMqTRQ', // 项目ID,即上报key
35
+ reportApiSpeed: false, // 接口测速
36
+ reportAssetSpeed: false, // 静态资源测速
37
+ spa: true,
38
+ ext1: '<%=appId%>',
39
+ });
40
+ <% }%>
41
+ window._aegis = _aegis;
42
+ window._aegis_inited = Date.now()
43
+ </script>
44
+ <% }%>
23
45
  <title><%= title %></title>
24
-
25
- <!-- <% if(mode !== 'production'){ %>
26
- <script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
27
- <script>new VConsole()</script>
28
- <% }%> -->
46
+ <% if(mode !== 'production'){ %>
47
+ <!-- <script src="https://cdn.bootcdn.net/ajax/libs/vConsole/3.3.4/vconsole.min.js"></script>
48
+ <script>new VConsole()</script> -->
49
+ <% }%>
29
50
 
30
51
  <!-- 重置浏览器样式 -->
31
52
  <style type="text/css">
@@ -434,39 +455,13 @@
434
455
  </div>
435
456
  <% }%>
436
457
  </div>
437
- <% if(cdnEndpoints.aegis){ %>
438
- <script crossorigin="anonymous" src="<%= cdnEndpoints.aegis %>/aegis-sdk/latest/aegis.min.js"></script>
439
- <script>
440
- <% if(!isAdminPortal){ %>
441
- const _aegis = new Aegis({
442
- id: 'lXHFsBpTjIzNADiczY', // 项目ID,即上报key
443
- reportApiSpeed: true, // 接口测速
444
- reportAssetSpeed: true, // 静态资源测速
445
- spa: true,
446
- ext1: '<%=appId%>',
447
- });
448
- <% } else {%>
449
- const _aegis = new Aegis({
450
- id: 'lXHFsBpTrKcnOMqTRQ', // 项目ID,即上报key
451
- reportApiSpeed: false, // 接口测速
452
- reportAssetSpeed: false, // 静态资源测速
453
- spa: true,
454
- ext1: '<%=appId%>',
455
- });
456
- <% }%>
457
- window._aegis = _aegis;
458
- window._aegis_inited = Date.now()
459
- </script>
460
- <% }%> <% jsApis.forEach(function(jsApi){%>
458
+ <% jsApis.forEach(function(jsApi){%>
461
459
  <script src="<%=jsApi %>"></script>
462
460
  <% })%> <% if(canUseVite){ %>
463
461
  <script type="module" src="/src/index.jsx"></script>
464
462
  <% } %> <% if(!isAdminPortal){ %>
465
463
  <script src="/weda-config/weda-private.js"></script>
466
- <script src="<%= cdnEndpoints.cloudbase %>/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.js?v=1"></script>
467
- <script src="<%= cdnEndpoints.cloudbase %>/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.auth.js?v=1"></script>
468
- <script src="<%= cdnEndpoints.cloudbase %>/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.functions.js?v=1"></script>
469
- <script src="<%= cdnEndpoints.cloudbase %>/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.storage.js?v=1"></script>
464
+ <script src="<%= cdnEndpoints.cloudbase %>/cloudbase-js-sdk/2.4.7-beta.0/cloudbase.full.js?v=1"></script>
470
465
  <% }%>
471
466
  <script>
472
467
  if (window.cloudbase && window._aegis) {
@@ -514,17 +509,23 @@
514
509
  ></script>
515
510
  <script
516
511
  crossorigin
517
- src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/release/_npm/react-dom@16.14.0/umd/react-dom.production.min.js"
512
+ src="<%=
513
+ cdnEndpoints.cdngo
514
+ %>/lcap/lcap-resource-cdngo/-/release/_npm/react-dom@16.14.0/umd/react-dom.production.min.js"
518
515
  ></script>
519
516
  <script
520
- src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/602f2de5/_url/ajax/libs/mobx/5.15.7/mobx.umd.min.js"
517
+ src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/0.1.2/_url/ajax/libs/mobx/5.15.7/mobx.umd.js"
521
518
  crossorigin="anonymous"
522
519
  ></script>
523
520
  <script
524
521
  crossorigin="anonymous"
525
522
  src="<%=
526
523
  cdnEndpoints.cdngo
527
- %>/lcap/lcap-resource-cdngo/-/83ec8058/_npm/@cloudbase/weda-cloud-sdk@1.0.30-alpha.0/dist/h5.browser.js"
524
+ %>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.29/dist/h5.browser.js"
525
+ ></script>
526
+ <script
527
+ crossorigin
528
+ src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/release/_npm/acorn@8.0.4/dist/acorn.js"
528
529
  ></script>
529
530
  <script>
530
531
  // zxing polifill
@@ -532,23 +533,21 @@
532
533
  this.globalThis = this;
533
534
  }
534
535
  </script>
535
- <script>
536
- var script = document.createElement('script');
537
- script.type = 'text/javascript';
538
- script.crossorigin = 'anonymous';
539
- script.src =
540
- '<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js';
541
- setTimeout(function () {
542
- document.getElementsByTagName('body')[0].appendChild(script);
543
- }, 1000);
544
- </script>
536
+ <script
537
+ crossorigin="anonymous"
538
+ src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/0.1.2/_url/npm/@zxing/library@0.18.6/umd/index.min.js"
539
+ ></script>
545
540
  <script
546
541
  crossorigin
547
- src="<%= cdnEndpoints.cdngo %>/lcap/lcap-resource-cdngo/-/f8115605/_npm/@cloudbase/cals@1.0.3-alpha.8/lib/cloudbase.cals.umd.min.js"
542
+ src="<%=
543
+ cdnEndpoints.cdngo
544
+ %>/lcap/lcap-resource-cdngo/-/release/_url/qcloud/lowcode/static/ide/assets/js/babel.min.js"
548
545
  ></script>
549
546
  <script
550
547
  crossorigin
551
- src="<%= cdnEndpoints.cdngo %>lcap/lcap-resource-cdngo/-/189f87d7/_files/static/weda-render/main.da12d9cfd372eee26888.bundle.js"
548
+ src="<%=
549
+ cdnEndpoints.cdngo
550
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.b13197aa3e72385a9cc9.bundle.js"
552
551
  ></script>
553
552
  </body>
554
553
  </html>
@@ -68,8 +68,12 @@ setConfig({
68
68
  const loginPage = findLoginPage();
69
69
  if (loginPage) {
70
70
  const authConfig = await getAuthConfig();
71
- const isAnonymous = await checkAnonymous();
72
- if (isAnonymous && authConfig.RejectStrategy == 'to_login') {
71
+ if (authConfig.RejectStrategy == 'to_login') {
72
+ if (['InnerError.AuthFailure'].includes(res?.result?.code)) {
73
+ const isAnonymous = await checkAnonymous();
74
+ if (!isAnonymous) return;
75
+ // 匿名用户越权去登录
76
+ }
73
77
  redirectToLogin();
74
78
  } else if (authConfig.RejectStrategy == 'show_warning') {
75
79
  app.showToast({
@@ -1,3 +1,4 @@
1
+ /* eslint-disable no-restricted-syntax */
1
2
  'use strict';
2
3
  import { generateForContextOfWidget, generateWidgetAPIContext, getWidget } from './widget';
3
4
  import { observable, untracked } from 'mobx';
@@ -33,7 +34,7 @@ export function generateDataContext(widget) {
33
34
  while (widget?._scope) {
34
35
  const current = widget;
35
36
  // 此处采用代理的方式,是为了可以获取到最新的 _scope.dataContext 防止 dataContext 引用被重新赋值
36
- if(current?._scope?.id){
37
+ if (current?._scope?.id) {
37
38
  Object.defineProperty(dataContext, current._scope.id, {
38
39
  get() {
39
40
  return current?._scope?.dataContext;
@@ -53,9 +54,10 @@ export function createEventHandlers(
53
54
  evtListeners,
54
55
  options = {
55
56
  looseError: false,
57
+ isComposite: false,
56
58
  },
57
59
  ) {
58
- const { looseError = false } = options;
60
+ const { looseError = false, isComposite = false } = options;
59
61
  const evtHandlers = {};
60
62
  for (const name in evtListeners) {
61
63
  const listeners = evtListeners[name];
@@ -73,41 +75,103 @@ export function createEventHandlers(
73
75
  const dataContext = untracked(() => generateDataContext(currentTarget));
74
76
  const $w = untracked(() => generateWidgetAPIContext(owner?.__internal__?.$w, currentTarget, forContext));
75
77
 
76
- const currentPageId = app.__internal__?.activePage?.id
78
+ function checkPageActive(pageId, currentPageContext, listener) {
79
+ /**
80
+ * 复合组件自身不中断校验
81
+ */
82
+ if (isComposite) {
83
+ return true;
84
+ }
85
+ const { id, __internal__ } = currentPageContext || {};
86
+ if (pageId && id) {
87
+ if (pageId !== id || (__internal__ && !__internal__.active)) {
88
+ console.error(`Action error: [${listener.trigger}:${listener.key}] 页面生命周期结束,链式调用中断`);
89
+ return false;
90
+ }
91
+ }
92
+ return true;
93
+ }
94
+
77
95
  listeners.forEach(async (l) => {
78
- if(currentPageId && owner.id && currentPageId !== owner.id) {
79
- console.error(`Action error: [${trigger}:${l.key}] 页面生命周期结束,链式调用中断`);
80
- return ;
96
+ /**
97
+ * 调用前置校验
98
+ * 是否仍可调用方法
99
+ */
100
+ if (!checkPageActive(owner.id, app.__internal__?.activePage, l)) {
101
+ return;
81
102
  }
103
+
82
104
  let { data = {}, boundData = {} } = l;
83
105
  data = { ...data };
106
+ const nextEventHandles = [
107
+ {
108
+ handlerName: '',
109
+ event: {
110
+ ...event,
111
+ },
112
+ },
113
+ ];
114
+ let error = false;
115
+ const isIfAction = l.sourceKey === 'platform:utils.If';
116
+ const isShowModalAction = l.sourceKey === 'platform:showModal';
84
117
  try {
85
118
  for (const k in boundData) {
86
119
  set(data, k, boundData[k].call(owner, owner, lists, forItems, event, dataContext, $w));
87
120
  }
88
121
  let res = await l.handler.call(owner, { event, data });
89
- let eventName = prefix && l.key ? `${prefix}$${l.key}${(l.sourceKey !== 'platform:utils.If') ? '_success' : (res ? '_success' : '_fail')}` : '';
90
- self[eventName] &&
91
- self[eventName]({
92
- ...event,
93
- detail: l.sourceKey === 'platform:utils.If' ? event.detail : res,
94
- });
122
+ nextEventHandles[0].handlerName =
123
+ prefix && l.key ? `${prefix}$${l.key}${!isIfAction || res ? '_success' : '_fail'}` : '';
124
+ nextEventHandles[0].event.detail = isIfAction ? event.detail : res;
125
+ if (isShowModalAction) {
126
+ let handlerName = '';
127
+
128
+ if (res.cancel) {
129
+ handlerName = `${prefix}$${l.key}_cancel`;
130
+ } else if (res.confirm) {
131
+ handlerName = `${prefix}$${l.key}_confirm`;
132
+ }
133
+
134
+ if (handlerName) {
135
+ nextEventHandles.push({
136
+ handlerName,
137
+ event: {
138
+ ...event,
139
+ detail: res,
140
+ },
141
+ });
142
+ }
143
+ }
95
144
  } catch (e) {
96
- let eventName = l.key ? `${prefix}$${l.key}_fail` : '';
97
- if (self[eventName]) {
98
- await self[eventName]({
99
- ...event,
100
- detail: e,
101
- });
102
- } else {
103
- console.error(`Action error: [${trigger}:${l.key}]`, e);
145
+ nextEventHandles[0].handlerName = l.key ? `${prefix}$${l.key}_fail` : '';
146
+ nextEventHandles[0].event.detail = isIfAction ? event.detail : e;
147
+ error = e;
148
+ }
149
+
150
+ /**
151
+ * 调用后置校验
152
+ * 是否触发后置事件
153
+ */
154
+ if (checkPageActive(owner.id, app.__internal__?.activePage, l)) {
155
+ const nextHandler = nextEventHandles[0];
156
+
157
+ if (!self[nextHandler.handlerName] && error) {
158
+ console.error(`Action error: [${trigger}:${l.key}]`, error);
104
159
  if (!looseError) {
105
160
  app.showToast({
106
161
  icon: 'error',
107
162
  title: `事件响应失败`,
108
163
  });
109
164
  }
110
- throw e;
165
+ throw error;
166
+ } else {
167
+ await Promise.all(
168
+ nextEventHandles.map(async (nextHandler) => {
169
+ if (self[nextHandler.handlerName]) {
170
+ return self[nextHandler.handlerName](nextHandler.event);
171
+ }
172
+ return null;
173
+ }),
174
+ );
111
175
  }
112
176
  }
113
177
  });
@@ -313,7 +377,11 @@ async function getAccessPermission(app, appId, pageId) {
313
377
  const resourceInfo = res.find((i) => i.ResourceId === cacheKey);
314
378
  const isAccess = !!resourceInfo?.IsAccess;
315
379
  _AUTH_CACHE_MAP[cacheKey] = isAccess;
316
- return isAccess;
380
+
381
+ return {
382
+ isAccess,
383
+ roleId: resourceInfo?.RoleId,
384
+ };
317
385
  } else {
318
386
  throw new Error(`鉴权接口返回参数不正确 - ${JSON.stringify(res)}`);
319
387
  }
@@ -330,7 +398,7 @@ export async function checkAnonymous() {
330
398
  const scope = await loginScope();
331
399
  isAnonymous = scope === 'anonymous';
332
400
  }
333
- } catch (e) { }
401
+ } catch (e) {}
334
402
  return isAnonymous;
335
403
  }
336
404
 
@@ -359,17 +427,17 @@ export async function checkAuth(app, appId, $page) {
359
427
  requestList.push(getAuthConfig(app));
360
428
  }
361
429
  try {
362
- const [isAccess, authConfig] = await Promise.all(requestList);
430
+ const [accessData, authConfig] = await Promise.all(requestList);
363
431
  app.hideNavigationBarLoading();
364
432
 
365
433
  const isAnonymousUser = await checkAnonymous();
366
434
 
367
- if (!isAccess) {
435
+ if (!accessData?.isAccess) {
368
436
  if (isAnonymousUser && loginPage && (authConfig.NeedLogin || authConfig.RejectStrategy == 'to_login')) {
369
437
  redirectToLogin($page);
370
438
  } else {
371
439
  app.showToast({
372
- title: '页面无访问权限',
440
+ title: ['-2', '-4'].includes(accessData?.roleId) ? '默认访客无权限' : '页面无访问权限',
373
441
  icon: 'error',
374
442
  });
375
443
  }
@@ -378,14 +446,14 @@ export async function checkAuth(app, appId, $page) {
378
446
  try {
379
447
  if (isAnonymousUser) {
380
448
  redirectToLogin($page);
381
- return false
449
+ return false;
382
450
  }
383
451
  } catch (e) {
384
452
  redirectToLogin($page);
385
- return false
453
+ return false;
386
454
  }
387
455
  }
388
- return isAccess;
456
+ return accessData?.isAccess;
389
457
  } catch (e) {
390
458
  app.showModal({
391
459
  title: '页面鉴权失败',
@@ -471,8 +539,9 @@ async function getGeneralOptions(optionName) {
471
539
 
472
540
  export function getMpEventHandlerName(widgetId, evtName, modifier = {}) {
473
541
  // Only builtin events have will bubble
474
- return `on${widgetId}$${evtName.replace(/\./g, '_')}${modifier.isCapturePhase ? '$cap' : ''}${modifier.noPropagation ? '$cat' : ''
475
- }`;
542
+ return `on${widgetId}$${evtName.replace(/\./g, '_')}${modifier.isCapturePhase ? '$cap' : ''}${
543
+ modifier.noPropagation ? '$cat' : ''
544
+ }`;
476
545
  }
477
546
 
478
547
  function isPlainObject(src) {
@@ -56,6 +56,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
56
56
  attached() {
57
57
  const $comp = this._getInstance()
58
58
  if(!$comp) return
59
+ $comp.__internal__.active = this._pageActive
59
60
 
60
61
  $comp.props.events = createPropEvents(events, this)
61
62
  const { widgets, rootWidget: virtualRootWidget } = createWidgets(widgetProps, dataBinds, this, $comp.widgets)
@@ -92,6 +93,8 @@ export function createComponent(key, behaviors, properties, events, handler, dat
92
93
  detached() {
93
94
  const $comp = this._getInstance()
94
95
  if(!$comp) return
96
+ this._pageActive = false
97
+ $comp.__internal__.active = this._pageActive
95
98
 
96
99
  $comp.widgets = null
97
100
  $comp.node._eventListeners.clear();
@@ -123,7 +126,7 @@ export function createComponent(key, behaviors, properties, events, handler, dat
123
126
  },
124
127
 
125
128
  methods: {
126
- ...createEventHandlers(evtListeners, { looseError: true }),
129
+ ...createEventHandlers(evtListeners, { looseError: true, isComposite: true }),
127
130
  ...mergeRenderer,
128
131
  _getInstance() {
129
132
  if(!this.$WEAPPS_COMP){
@@ -112,6 +112,8 @@ export function createPage(
112
112
  detached() {
113
113
  const $page = this._getInstance();
114
114
  this._pageActive = false;
115
+ $page.__internal__.active = this._pageActive;
116
+
115
117
  disposeWidget($page._rootWidget);
116
118
  this._disposers.forEach((dispose) => dispose());
117
119
  },
@@ -152,8 +154,9 @@ export function createPage(
152
154
  async onLoad(options) {
153
155
  const $page = this._getInstance();
154
156
  setConfig({ currentPageId: $page.uuid });
155
- app.__internal__.activePage = $page;
156
157
  this._pageActive = true;
158
+ $page.__internal__.active = this._pageActive;
159
+ app.__internal__.activePage = $page;
157
160
 
158
161
  this._query = decodePageQuery(options || {});
159
162
 
@@ -184,8 +187,9 @@ export function createPage(
184
187
  async onShow() {
185
188
  const $page = this._getInstance();
186
189
  setConfig({ currentPageId: $page.uuid });
187
- app.__internal__.activePage = $page;
188
190
  this._pageActive = true;
191
+ $page.__internal__.active = this._pageActive;
192
+ app.__internal__.activePage = $page;
189
193
 
190
194
  await this.beforePageCustomLaunch?.(this._query)
191
195
 
@@ -198,6 +202,7 @@ export function createPage(
198
202
  const hook = lifecycle.onHide || lifecycle.onPageHide;
199
203
  hook?.call?.($page);
200
204
  this._pageActive = false;
205
+ $page.__internal__.active = this._pageActive;
201
206
 
202
207
  // 触发页面节点事件
203
208
  this.invokeEventHandler(id, 'hide');
@@ -1,7 +1,9 @@
1
1
  import { $w as baseAPI } from '<%= subLevelPath %>../../app/weapps-api'
2
2
 
3
3
  export const $page = {
4
- __internal__: {}
4
+ __internal__: {
5
+ active: false
6
+ }
5
7
  };
6
8
 
7
9
  export const $w = new Proxy(
@@ -180,7 +180,8 @@ module.exports = function (options) {
180
180
  },
181
181
  {
182
182
  test: /\.(js|jsx)$/,
183
- exclude: /node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core))|gsd-kbone-react/,
183
+ exclude:
184
+ /node_modules\/(?!(@cloudbase\/weda-ui)|(@tcwd\/vuera)|(@tcwd\/weapps-core)|(@react-spring))|gsd-kbone-react/,
184
185
  use: ['happypack/loader?id=babel'],
185
186
  },
186
187
  {