@cloudbase/lowcode-builder 1.8.17 → 1.8.18

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.17",
3
+ "version": "1.8.18",
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": "^1.0.12",
42
- "@cloudbase/lowcode-generator": "^1.8.7",
41
+ "@cloudbase/cals": "^1.0.14",
42
+ "@cloudbase/lowcode-generator": "^1.8.8",
43
43
  "axios": "^0.21.0",
44
44
  "browserfs": "^1.4.3",
45
45
  "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.37/dist/h5.browser.js"
528
+ %>/lcap/lcap-resource-cdngo/-/release/_npm/@cloudbase/weda-cloud-sdk@1.0.39/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.f686224dbca5407ae4d2.bundle.js"
554
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.8bdf2bc04fec833b06b7.bundle.js"
555
555
  ></script>
556
556
  </body>
557
557
  </html>
@@ -99,7 +99,7 @@ App({
99
99
  this.globaldata._beforeCustomLaunchPromise = new Promise(async (resolve)=>{
100
100
  try {
101
101
  EXTRA_API.setParams('$global', query || {})
102
- await createStateDataSourceVar('$global', generateParamsParser({ app, $page: {} }));
102
+ await createStateDataSourceVar('$global', generateParamsParser({ app, $page: {}, $w: app.__internal__?.$w }));
103
103
  } catch (e) {
104
104
  throw e;
105
105
  } finally {
@@ -1,13 +1,15 @@
1
1
  import { createEventHandlers, getMpEventHandlerName } from './util';
2
2
  import { Event } from './event-emitter';
3
3
  export class EventFlow {
4
+ #eventHandlerMap = {};
5
+ #context = {}
4
6
  constructor({ schema, context, options }) {
5
- this._eventHandlerMap = {};
6
- this._context = context;
7
+ this.#eventHandlerMap = {};
8
+ this.#context = context;
7
9
  const { id, description, eventHandlers = {} } = schema || {};
8
10
  this.id = id || '';
9
11
  this.description = description || '';
10
- this._eventHandlerMap = Object.entries(
12
+ this.#eventHandlerMap = Object.entries(
11
13
  createEventHandlers(eventHandlers, {
12
14
  looseError: true,
13
15
  isComposite: options?.isComposite || false,
@@ -19,19 +21,19 @@ export class EventFlow {
19
21
  return map;
20
22
  },
21
23
  {
22
- _getInstance: () => this._context.$page || this._context.$app,
24
+ _getInstance: () => this.#context.$page || this.#context.$app,
23
25
  },
24
26
  );
25
27
  return this;
26
28
  }
27
29
  trigger(additionalScope, options = {}) {
28
30
  const mergedContext = {
29
- ...this._context,
31
+ ...this.#context,
30
32
  ...options,
31
33
  };
32
34
  const { target } = mergedContext;
33
35
  const eventName = `${this.id}.start`;
34
- return this._eventHandlerMap[getMpEventHandlerName(this.id, eventName)](
36
+ return this.#eventHandlerMap[getMpEventHandlerName(this.id, eventName)](
35
37
  new Event({
36
38
  type: eventName,
37
39
  detail: additionalScope,
@@ -3,25 +3,32 @@ import { createEventHandlers, getMpEventHandlerName, mergeDynamic2StaticData } f
3
3
  import { Event } from './event-emitter';
4
4
 
5
5
  export class Query {
6
+ _schema = {}
7
+ #schema
8
+ #context = {};
9
+ #disposes = [];
10
+ #dataBinds = {};
11
+ #triggered = false;
12
+ #paramsRef = observable({ current: null });
13
+ #currentRequestKey = null;
14
+ #observableValue = observable({ data: null, error: null });
15
+ #eventHandlerMap = {};
16
+ #action = () => {};
6
17
  constructor({ schema, context, options = {} }) {
7
- this._disposes = [];
8
- this._dataBinds = {};
9
- this._triggered = false;
10
- this._paramsRef = observable({ current: null });
11
- this._currentRequestKey = null;
12
- this._observableValue = observable({ data: null, error: null });
13
- this._eventHandlerMap = {};
14
18
  const { looseError = false } = options;
15
- this._schema = schema;
16
- this._context = context;
17
- if (this._schema?.trigger === 'auto') {
18
- this._disposes.push(
19
+ this.#schema = schema;
20
+ this._schema = {
21
+ trigger: schema.trigger
22
+ }
23
+ this.#context = context;
24
+ if (this.#schema?.trigger === 'auto') {
25
+ this.#disposes.push(
19
26
  autorun(
20
27
  (r) => {
21
28
  try {
22
- const data = this._resolveParams();
23
- if (this._triggered) {
24
- this._debounceTrigger(data);
29
+ const data = this.#resolveParams();
30
+ if (this.#triggered) {
31
+ this.#debounceTrigger(data);
25
32
  }
26
33
  } catch (e) {
27
34
  console.error(e);
@@ -31,18 +38,18 @@ export class Query {
31
38
  ),
32
39
  );
33
40
  }
34
- this._paramsRef.current = this._schema.data;
35
- this._dataBinds = Object.entries(this._schema.dataBinds || {}).reduce((map, [prop, fn]) => {
41
+ this.#paramsRef.current = this.#schema.data;
42
+ this.#dataBinds = Object.entries(this.#schema.dataBinds || {}).reduce((map, [prop, fn]) => {
36
43
  if (!/[\s+\-*/!&|%]*?SERVER\./.test(prop)) {
37
44
  map[prop] = fn;
38
45
  }
39
46
  return map;
40
47
  }, {});
41
48
 
42
- const { $w } = this._context;
49
+ const { $w } = this.#context;
43
50
 
44
- this._action =
45
- this._schema.type === 'sql'
51
+ this.#action =
52
+ this.#schema.type === 'sql'
46
53
  ? async function (data) {
47
54
  const Data = await $w.cloud.callWedaApi({
48
55
  action: 'RunPluginQuery',
@@ -96,9 +103,9 @@ export class Query {
96
103
  total: Total || ExecuteResultList.length,
97
104
  };
98
105
  }
99
- : this._schema.handler;
100
- this._eventHandlerMap = Object.entries(
101
- createEventHandlers(this._schema.eventHandlers || {}, {
106
+ : this.#schema.handler;
107
+ this.#eventHandlerMap = Object.entries(
108
+ createEventHandlers(this.#schema.eventHandlers || {}, {
102
109
  looseError: looseError,
103
110
  isComposite: false,
104
111
  }),
@@ -109,84 +116,94 @@ export class Query {
109
116
  return map;
110
117
  },
111
118
  {
112
- _getInstance: () => this._context.$page || this._context.$app,
119
+ _getInstance: () => this.#context.$page || this.#context.$app,
113
120
  },
114
121
  );
115
122
  return this;
116
123
  }
117
124
  get id() {
118
- return this._schema?.id || '';
125
+ return this.#schema?.id || '';
119
126
  }
120
127
  get label() {
121
- return this._schema?.label || '';
128
+ return this.#schema?.label || '';
122
129
  }
123
130
  get description() {
124
- return this._schema?.description || '';
131
+ return this.#schema?.description || '';
125
132
  }
126
133
  get data() {
127
- return this._observableValue.data;
134
+ return this.#observableValue.data;
128
135
  }
129
136
  get error() {
130
- return this._observableValue.error;
137
+ return this.#observableValue.error;
131
138
  }
132
139
  async trigger(additionalScope, options = {}) {
133
- this._triggered = true;
134
- return this._innerTrigger(this._resolveParams(), additionalScope, options);
140
+ this.#triggered = true;
141
+ return this.#innerTrigger(this.#resolveParams(), additionalScope, options);
135
142
  }
136
143
  reset() {
137
- this._observableValue.data = null;
138
- this._observableValue.error = null;
144
+ this.#observableValue.data = null;
145
+ this.#observableValue.error = null;
146
+ }
147
+ destroy() {
148
+ this.#disposes.forEach((dispose) => dispose());
149
+ }
150
+
151
+ /**
152
+ * 用于调试
153
+ */
154
+ _toSchema() {
155
+ console.warn('调试使用,结构可能发生更改,请不要用于生产环境');
156
+ return this.#schema;
139
157
  }
140
- async _innerTrigger(data, additionalScope, options = {}) {
141
- this._currentRequestKey = Date.now();
142
- const key = this._currentRequestKey;
158
+
159
+ async #innerTrigger(data, additionalScope, options = {}) {
160
+ this.#currentRequestKey = Date.now();
161
+ const key = this.#currentRequestKey;
143
162
  try {
144
- const res = await this._action(data);
145
- if (key === this._currentRequestKey) {
146
- this._observableValue.data = res;
147
- this._observableValue.error = null;
148
- this._emit(`success`, res);
163
+ const res = await this.#action(data);
164
+ if (key === this.#currentRequestKey) {
165
+ this.#observableValue.data = res;
166
+ this.#observableValue.error = null;
167
+ this.#emit(`success`, res);
149
168
  }
150
169
  return res;
151
170
  } catch (e) {
152
- if (key === this._currentRequestKey) {
153
- this._observableValue.data = null;
154
- this._observableValue.error = e;
155
- this._emit(`fail`, e);
171
+ if (key === this.#currentRequestKey) {
172
+ this.#observableValue.data = null;
173
+ this.#observableValue.error = e;
174
+ this.#emit(`fail`, e);
156
175
  }
157
176
  throw e;
158
177
  }
159
178
  }
160
- _debounceTrigger(...args) {
179
+ #debounceTrigger(...args) {
161
180
  if (this._timer) {
162
181
  clearTimeout(this._timer);
163
182
  }
164
183
  this._timer = setTimeout(() => {
165
- this._innerTrigger(...args);
184
+ this.#innerTrigger(...args);
166
185
  }, 300);
167
186
  }
168
- destroy() {
169
- this._disposes.forEach((dispose) => dispose());
170
- }
171
- _resolveParams() {
187
+
188
+ #resolveParams() {
172
189
  /**
173
190
  * 这里万一其中某个字段计算失败
174
191
  * 好像会阻塞其他字段的计算
175
192
  * 从而导致 autorun 没有添加依赖
176
193
  */
177
- return mergeDynamic2StaticData(toJS(this._paramsRef.current), this._dataBinds, {
194
+ return mergeDynamic2StaticData(toJS(this.#paramsRef.current), this.#dataBinds, {
178
195
  codeContext: {
179
196
  /**
180
197
  * $page 或 $comp 实例
181
198
  */
182
- instance: this._context.$page,
199
+ instance: this.#context.$page,
183
200
  },
184
- $w: this._context.$w,
201
+ $w: this.#context.$w,
185
202
  // may be additional scope
186
203
  });
187
204
  }
188
- async _emit(eventName, data) {
189
- return this._eventHandlerMap[getMpEventHandlerName(this.id, eventName)]?.(
205
+ async #emit(eventName, data) {
206
+ return this.#eventHandlerMap[getMpEventHandlerName(this.id, eventName)]?.(
190
207
  new Event({
191
208
  type: eventName,
192
209
  detail: data,
@@ -53,7 +53,7 @@ export function createPage({
53
53
  (params ? '?' + params.map((pair) => pair.key + '=' + pair.value).join('&') : '');
54
54
  return {
55
55
  path: realPath,
56
- imageUrl,
56
+ imageUrl: app?.__internal__?.resolveStaticResourceUrl?.(imageUrl) || imageUrl,
57
57
  title,
58
58
  };
59
59
  }
@@ -153,7 +153,7 @@ export function createPage({
153
153
  this.setData({
154
154
  weDaHasLogin: true,
155
155
  });
156
- createStateDataSourceVar($page.uuid, generateParamsParser({ app, $page }));
156
+ createStateDataSourceVar($page.uuid, generateParamsParser({ app, $page, $w: $page.__internal__?.$w }));
157
157
  }
158
158
  } finally {
159
159
  this.setData({ _isCheckingAtuh: false })
@@ -198,7 +198,7 @@ export function createPage({
198
198
  const hook = lifecycle.onReady || lifecycle.onPageReady;
199
199
  await hook?.call?.($page);
200
200
 
201
- this._invokeEventHandler(id, 'ready');
201
+ this._invokeEventHandler('ready');
202
202
  },
203
203
  onUnload() {
204
204
  const $page = this._getInstance();
@@ -253,7 +253,11 @@ export function createPage({
253
253
  $page = pageContext;
254
254
  this.$WEAPPS_PAGE = $page;
255
255
  $page.handler = Object.keys(handlers).reduce((result, key) => {
256
- result[key] = handlers[key].bind($page);
256
+ try {
257
+ result[key] = handlers[key].bind($page);
258
+ } catch(e) {
259
+ console.error('添加页面handler失败', e)
260
+ }
257
261
  return result;
258
262
  }, {});
259
263
  $page.computed = createComputed(computed, $page);
@@ -6,8 +6,8 @@
6
6
  "@cloudbase/js-sdk": "2.5.6-beta.1",<%
7
7
  } %>
8
8
  "@cloudbase/oauth": "0.1.1-alpha.5",
9
- "@cloudbase/weda-client": "1.0.4",
10
- "@cloudbase/weda-cloud-sdk": "1.0.37",
9
+ "@cloudbase/weda-client": "1.0.5",
10
+ "@cloudbase/weda-cloud-sdk": "1.0.40",
11
11
  "mobx": "^5.15.4",
12
12
  "lodash.get": "^4.4.2",
13
13
  "lodash.set": "^4.3.2",