@cloudbase/lowcode-builder 1.8.10 → 1.8.12

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.
@@ -118,13 +118,13 @@ async function generateWxMp({ buildContext, weapps, plugins, deployOptions, opti
118
118
  debug: buildContext.debugMode,
119
119
  },
120
120
  'common/data-patch.js': {},
121
- 'common/event-emitter.ts': {},
121
+ 'common/event-emitter.js': {},
122
122
  'common/watch.js': {},
123
123
  'common/constant.js': {
124
124
  REPEATER: JSON.stringify(config_1.REPEATER, undefined, 2),
125
125
  },
126
- 'common/query.ts': {},
127
- 'common/flow.ts': {},
126
+ 'common/query.js': {},
127
+ 'common/flow.js': {},
128
128
  'common/loading': {},
129
129
  /**
130
130
  * 调试用
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/lowcode-builder",
3
- "version": "1.8.10",
3
+ "version": "1.8.12",
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",
@@ -39,7 +39,7 @@
39
39
  },
40
40
  "dependencies": {
41
41
  "@cloudbase/cals": "^1.0.9",
42
- "@cloudbase/lowcode-generator": "^1.8.1",
42
+ "@cloudbase/lowcode-generator": "^1.8.5",
43
43
  "axios": "^0.21.0",
44
44
  "browserfs": "^1.4.3",
45
45
  "browserify-zlib": "^0.2.0",
@@ -30,7 +30,7 @@
30
30
  reportAssetSpeed: true, // 静态资源测速
31
31
  spa: true,
32
32
  ext1: '<%=appId%>',
33
- version: '0.0.1',
33
+ version: '0.0.2',
34
34
  });
35
35
  <% } else {%>
36
36
  const _aegis = new Aegis({
@@ -39,7 +39,7 @@
39
39
  reportAssetSpeed: false, // 静态资源测速
40
40
  spa: true,
41
41
  ext1: '<%=appId%>',
42
- version: '0.0.1',
42
+ version: '0.0.2',
43
43
  });
44
44
  <% }%>
45
45
  window._aegis = _aegis;
@@ -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.3df3008899037155a92c.bundle.js"
554
+ %>/lcap/lcap-resource-cdngo/-/0.1.4/_files/static/weda-render/main.4e08e64803c057479d66.bundle.js"
555
555
  ></script>
556
556
  </body>
557
557
  </html>
@@ -43,37 +43,41 @@ export default class EventEmitter {
43
43
  }
44
44
  }
45
45
 
46
+ // interface IEventProps {
47
+ // type: string;
48
+ // currentTarget: any;
49
+ // target?: any;
50
+ // detail?: any;
51
+ // _isCapturePhase?: boolean;
52
+ // origin?: Event;
53
+ // }
54
+
46
55
  export class Event {
47
- type: string;
48
- detail: any;
56
+ type /* : string*/;
57
+ detail /* : any*/;
49
58
  /**
50
59
  * 类别应当为 typeof UserWidget
51
60
  * 当前类别为 typeof $page.widgets.xxxx
52
61
  * 添加上报确定用量
53
62
  */
54
- currentTarget: any /* typeof UserWidget */;
55
- target?: any /* typeof UserWidget */;
63
+ currentTarget /* : any */ /* typeof UserWidget */;
64
+ target /* ?: any */ /* typeof UserWidget */;
56
65
  /**
57
66
  * 内部实现
58
67
  * 外部不应该进行访问
59
68
  */
60
- _isCapturePhase: boolean;
61
- origin: Event;
62
- constructor({
63
- type = '',
64
- detail = undefined,
65
- currentTarget = undefined,
66
- target = undefined,
67
- _isCapturePhase = false,
68
- origin,
69
- }: {
70
- type: string;
71
- currentTarget: any;
72
- target?: any;
73
- detail?: any;
74
- _isCapturePhase?: boolean;
75
- origin?: Event;
76
- }) {
69
+ _isCapturePhase; /* : boolean; */
70
+ origin /* : Event */;
71
+ constructor(
72
+ {
73
+ type = '',
74
+ detail = undefined,
75
+ currentTarget = undefined,
76
+ target = undefined,
77
+ _isCapturePhase = false,
78
+ origin,
79
+ } /* : IEventProps*/,
80
+ ) {
77
81
  function proxyWrapper(target, key) {
78
82
  try {
79
83
  return new Proxy(target, {
@@ -1,50 +1,19 @@
1
1
  import { createEventHandlers, getMpEventHandlerName } from './util';
2
2
  import { Event } from './event-emitter';
3
- type IGenerateContext = any;
4
-
5
- export interface IEventFlowContext extends IGenerateContext {
6
- $page?: any;
7
- $app?: any;
8
- target?: any; // widget
9
- }
10
-
11
- interface IMPEventFlowGenerateOptions {
12
- looseError?: boolean;
13
- isComposite?: boolean;
14
- }
15
-
16
3
  export class EventFlow {
17
- id: string;
18
- description: string;
19
- private _eventHandlerMap: Record<string, Function> = {};
20
- private _context: IEventFlowContext;
21
-
22
- constructor({
23
- schema,
24
- context,
25
- options,
26
- }: {
27
- schema: {
28
- id?: string;
29
- description?: string;
30
- /**
31
- * 预处理后 event handler listeners
32
- */
33
- eventHandlers?: Record<string, any>;
34
- };
35
- context: IEventFlowContext;
36
- options?: IMPEventFlowGenerateOptions;
37
- }) {
4
+ constructor({ schema, context, options }) {
5
+ this._eventHandlerMap = {};
38
6
  this._context = context;
39
7
  const { id, description, eventHandlers = {} } = schema || {};
40
8
  this.id = id || '';
41
9
  this.description = description || '';
42
-
43
- this._eventHandlerMap = Object.entries(createEventHandlers(eventHandlers, {
44
- looseError: true,
45
- isComposite: options?.isComposite || false,
46
- syncCall: true
47
- })).reduce(
10
+ this._eventHandlerMap = Object.entries(
11
+ createEventHandlers(eventHandlers, {
12
+ looseError: true,
13
+ isComposite: options?.isComposite || false,
14
+ syncCall: true,
15
+ }),
16
+ ).reduce(
48
17
  (map, [key, fn]) => {
49
18
  map[key] = fn;
50
19
  return map;
@@ -53,11 +22,9 @@ export class EventFlow {
53
22
  _getInstance: () => this._context.$page || this._context.$app,
54
23
  },
55
24
  );
56
-
57
25
  return this;
58
26
  }
59
-
60
- trigger(additionalScope, options: Partial<IEventFlowContext> = {}) {
27
+ trigger(additionalScope, options = {}) {
61
28
  const mergedContext = {
62
29
  ...this._context,
63
30
  ...options,
@@ -87,14 +54,8 @@ export class EventFlow {
87
54
  // return emit(`${this.id}.start`, additionalScope);
88
55
  }
89
56
  }
90
-
91
- export function generateEventFlows(
92
- flows: { id: string }[] = [],
93
- context: IEventFlowContext,
94
- options?: IMPEventFlowGenerateOptions,
95
- ) {
57
+ export function generateEventFlows(flows = [], context, options) {
96
58
  const result = {};
97
-
98
59
  for (let flow of flows) {
99
60
  result[flow.id] = new EventFlow({ schema: flow, context, options });
100
61
  }
@@ -1,59 +1,20 @@
1
- import { observable, IReactionDisposer, autorun, toJS } from 'mobx';
1
+ import { observable, autorun, toJS } from 'mobx';
2
2
  import { createEventHandlers, getMpEventHandlerName, mergeDynamic2StaticData } from './util';
3
3
  import { Event } from './event-emitter';
4
4
 
5
- interface IMPDataSourceQuery {
6
- id: string;
7
- label?: string;
8
- description?: string;
9
- trigger: 'auto' | 'manual';
10
- type: 'model' | 'apis' | 'sql';
11
- dataSourceName: string;
12
- methodName: string;
13
- data: object;
14
- dataBinds: Record<string, Function>;
15
- /**
16
- * 预处理后 event handler listeners
17
- */
18
- eventHandlers?: Record<string, any>;
19
- }
20
- interface IQueryContext {
21
- $w: any,
22
- $app?: any,
23
- $page?: any
24
- };
25
- type IDataBind = any;
26
- interface IGenerateOptions {
27
- looseError: boolean
28
- };
29
-
30
5
  export class Query {
31
- private _schema: IMPDataSourceQuery;
32
- private _context: IQueryContext;
33
- private _disposes: IReactionDisposer[] = [];
34
- private _dataBinds: Record<string, IDataBind> = {};
35
- private _triggered = false;
36
- private _action: any;
37
- private _paramsRef: { current: any } = observable({ current: null });
38
- private _currentRequestKey: any = null;
39
- private _observableValue: { data: any; error: Error | null } = observable({ data: null, error: null });
40
- private _eventHandlerMap: Record<string, Function> = {};
41
- private _timer: any;
42
-
43
- constructor({
44
- schema,
45
- context,
46
- options = {},
47
- }: {
48
- schema: IMPDataSourceQuery;
49
- context: IQueryContext;
50
- options?: IGenerateOptions;
51
- }) {
6
+ 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 = {};
52
14
  const { looseError = false } = options;
53
15
  const { $w } = context;
54
16
  this._schema = schema;
55
17
  this._context = context;
56
-
57
18
  if (this._schema?.trigger === 'auto') {
58
19
  this._disposes.push(
59
20
  autorun(
@@ -71,38 +32,29 @@ export class Query {
71
32
  ),
72
33
  );
73
34
  }
74
-
75
- const baseParam: {
76
- dataSourceName: string;
77
- sqlTemplateId?: string;
78
- methodName?: string;
79
- } = {
35
+ const baseParam = {
80
36
  dataSourceName: this._schema.dataSourceName,
81
37
  };
82
-
83
38
  if (this._schema?.type === 'sql') {
84
39
  baseParam.sqlTemplateId = this._schema.methodName;
85
40
  } else {
86
41
  baseParam.methodName = this._schema.methodName;
87
42
  }
88
-
89
43
  this._paramsRef.current = this._schema.data;
90
44
  this._dataBinds = this._schema.dataBinds;
91
-
92
45
  this._action = async (data) => {
93
46
  return $w.cloud.callDataSource({
94
47
  ...baseParam,
95
48
  params: data,
96
49
  });
97
50
  };
98
-
99
51
  this._eventHandlerMap = Object.entries(
100
52
  createEventHandlers(this._schema.eventHandlers || {}, {
101
53
  looseError: looseError,
102
54
  isComposite: false,
103
55
  }),
104
56
  ).reduce(
105
- (map, [key, fn]: [string, any]) => {
57
+ (map, [key, fn]) => {
106
58
  // map[key] = fn.bind(this);
107
59
  map[key] = fn;
108
60
  return map;
@@ -111,7 +63,6 @@ export class Query {
111
63
  _getInstance: () => this._context.$page || this._context.$app,
112
64
  },
113
65
  );
114
-
115
66
  // this._emit = async (trigger, eventData, originalEvent?) =>
116
67
  // generateEmit($w)(
117
68
  // trigger,
@@ -131,41 +82,32 @@ export class Query {
131
82
  // $w.page.id,
132
83
  // true,
133
84
  // );
134
-
135
85
  return this;
136
86
  }
137
-
138
- get id(): string {
87
+ get id() {
139
88
  return this._schema?.id || '';
140
89
  }
141
-
142
- get label(): string {
90
+ get label() {
143
91
  return this._schema?.label || '';
144
92
  }
145
-
146
- get description(): string {
93
+ get description() {
147
94
  return this._schema?.description || '';
148
95
  }
149
-
150
96
  get data() {
151
97
  return this._observableValue.data;
152
98
  }
153
-
154
99
  get error() {
155
100
  return this._observableValue.error;
156
101
  }
157
-
158
- async trigger(additionalScope?, options = {}) {
102
+ async trigger(additionalScope, options = {}) {
159
103
  this._triggered = true;
160
104
  return this._innerTrigger(this._resolveParams(), additionalScope, options);
161
105
  }
162
-
163
106
  reset() {
164
107
  this._observableValue.data = null;
165
108
  this._observableValue.error = null;
166
109
  }
167
-
168
- async _innerTrigger(data, additionalScope?, options = {}) {
110
+ async _innerTrigger(data, additionalScope, options = {}) {
169
111
  this._currentRequestKey = Date.now();
170
112
  const key = this._currentRequestKey;
171
113
  try {
@@ -179,14 +121,13 @@ export class Query {
179
121
  } catch (e) {
180
122
  if (key === this._currentRequestKey) {
181
123
  this._observableValue.data = null;
182
- this._observableValue.error = e as any;
124
+ this._observableValue.error = e;
183
125
  this._emit(`fail`, e);
184
126
  }
185
127
  throw e;
186
128
  }
187
129
  }
188
-
189
- private _debounceTrigger(...args) {
130
+ _debounceTrigger(...args) {
190
131
  if (this._timer) {
191
132
  clearTimeout(this._timer);
192
133
  }
@@ -194,12 +135,10 @@ export class Query {
194
135
  this._innerTrigger(...args);
195
136
  }, 300);
196
137
  }
197
-
198
138
  destroy() {
199
139
  this._disposes.forEach((dispose) => dispose());
200
140
  }
201
-
202
- private _resolveParams() {
141
+ _resolveParams() {
203
142
  /**
204
143
  * 这里万一其中某个字段计算失败
205
144
  * 好像会阻塞其他字段的计算
@@ -216,8 +155,7 @@ export class Query {
216
155
  // may be additional scope
217
156
  })?.params;
218
157
  }
219
-
220
- private async _emit(eventName: string, data?: any) {
158
+ async _emit(eventName, data) {
221
159
  return this._eventHandlerMap[getMpEventHandlerName(this.id, eventName)]?.(
222
160
  new Event({
223
161
  type: eventName,
@@ -228,10 +166,8 @@ export class Query {
228
166
  );
229
167
  }
230
168
  }
231
-
232
- export function generateDatasetQuery(schema, context: IQueryContext, options: IGenerateOptions) {
169
+ export function generateDatasetQuery(schema, context, options) {
233
170
  const result = {};
234
-
235
171
  for (const key in schema) {
236
172
  result[key] = new Query({ schema: schema[key], context, options });
237
173
  }
@@ -6,7 +6,6 @@ import { getAccessToken, loginScope } from '../datasources/index';
6
6
  import { app } from '../app/weapps-api';
7
7
  export { generateDatasetQuery } from './query';
8
8
  export { generateEventFlows } from './flow';
9
- import { Event } from './event-emitter';
10
9
 
11
10
  /**
12
11
  * Convert abcWordSnd -> abc-word-snd