@cloudbase/framework-plugin-low-code 0.6.29 → 0.6.32

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/framework-plugin-low-code",
3
- "version": "0.6.29",
3
+ "version": "0.6.32",
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",
@@ -24,7 +24,9 @@ const evtListeners = {<% Object.entries(eventHandlers).map(([handlerName, listen
24
24
  key: '<%= l.key %>',
25
25
  handler: <% if (l.type == 'rematch') {%> _handler<%= l.handler %> <%} else {%> <%= l.handler %> <%} %>,
26
26
  data: <%= stringifyObj(l.data, {depth: null}) %>,
27
- boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for=forItems; return <%= expr %>},
27
+ boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for=forItems; return (
28
+ <%= expr %>
29
+ )},
28
30
  <%}) %>}
29
31
  },<%})%>
30
32
  ],<%})%>
@@ -52,7 +54,9 @@ const handler = {<% handlers.forEach(h => {%>
52
54
 
53
55
  const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
54
56
  <%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
55
- <%= prop %>: function (lists, forItems, event, $context) {const $for=forItems; return <%= expr %>; },<% }) %>
57
+ <%= prop %>: function (lists, forItems, event, $context) {const $for=forItems; return (
58
+ <%= expr %>
59
+ ); },<% }) %>
56
60
  },<%}) %>
57
61
  }
58
62
 
@@ -19,14 +19,18 @@ const evtListeners = {<% Object.entries(eventHanlders).map(([handlerName, listen
19
19
  key: '<%= l.key %>',
20
20
  handler: <% if (l.type === 'rematch') {%> handlers.<%= l.handler %> <%} else if (l.type == 'material') {%> function(...args) { return require('../../materials/<%= l.handlerModule %>/actions/<%= l.handler %>/index').default(...args) } <%} else {%> <%= l.handler %> <%} %>,
21
21
  data: <%= stringifyObj(l.data, {depth: null}) %>,
22
- boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for = forItems; return <%= expr %>},
22
+ boundData: {<% Object.entries(l.boundData).map(([prop, expr])=>{%>'<%= prop %>':(lists, forItems, event, $context) => {const $for = forItems; return (
23
+ <%= expr %>
24
+ )},
23
25
  <%}) %>}
24
26
  },<%})%>
25
27
  ],<%})%>
26
28
  }
27
29
  const dataBinds = {<% Object.entries(dataBinds).map(([id, widgetBinds])=>{%>
28
30
  <%= id %>: { <% Object.entries(widgetBinds).map(([prop, expr]) => { %>
29
- <%= prop %>: function (lists, forItems, event, $context) {const $for = forItems; return <%= expr %>; },<% }) %>
31
+ <%= prop %>: function (lists, forItems, event, $context) {const $for = forItems; return (
32
+ <%= expr %>
33
+ ); },<% }) %>
30
34
  },<%}) %>
31
35
  }
32
36
 
@@ -63,7 +63,7 @@ export const CompRenderer = observer(function (props) {
63
63
 
64
64
  // 组件最终用于执行的事件函数
65
65
  const emit = useCallback(
66
- (trigger, event, forItems, scopeContext) => {
66
+ (trigger, eventDetail, forItems, scopeContext) => {
67
67
  const listeners = listenerInstances || [];
68
68
 
69
69
  // 如果是数据容器,则将传过来的data,赋值给容器上下文context
@@ -83,7 +83,7 @@ export const CompRenderer = observer(function (props) {
83
83
  });
84
84
  }
85
85
 
86
- event = { detail: event, name: trigger };
86
+ let event = { detail: eventDetail, name: trigger };
87
87
  forItems = {
88
88
  ...forItems,
89
89
  forIndexes: getForIndexes(forItems, widgetsData),
@@ -105,14 +105,14 @@ export const CompRenderer = observer(function (props) {
105
105
 
106
106
  // 选区最终用于执行的事件函数
107
107
  const emitSB = useCallback(
108
- (trigger, event, forItems, scopeContext, fieldData) => {
108
+ (trigger, eventDetail, forItems, scopeContext, fieldData) => {
109
109
  const listeners =
110
110
  indexRef?.current !== undefined &&
111
111
  typeRef?.current &&
112
112
  fieldData?.[typeRef.current]?.[indexRef.current]?.selectableBlock?.[
113
113
  'x-props'
114
114
  ]?.listenerInstances;
115
- event = { detail: event, name: trigger };
115
+ let event = { detail: eventDetail, name: trigger };
116
116
  forItems = {
117
117
  ...forItems,
118
118
  forIndexes: getForIndexes(forItems, widgetsData),
@@ -164,7 +164,9 @@ export const CompRenderer = observer(function (props) {
164
164
  try {
165
165
  // 绑定了 for 变量,但计算值错误时,应当空数组兜底
166
166
  forList =
167
- dataBinds && dataBinds._waFor && (dataBinds._waFor(parentForItems, undefined, context) || []);
167
+ dataBinds &&
168
+ dataBinds._waFor &&
169
+ (dataBinds._waFor(parentForItems, undefined, context) || []);
168
170
  } catch (e) {
169
171
  // 计算值出错则使用空数组兜底
170
172
  forList = [];
@@ -305,7 +307,10 @@ export const CompRenderer = observer(function (props) {
305
307
 
306
308
  return (
307
309
  <Field
308
- data={{ ...fieldData, _selectableBlockEvents: _selectableBlockEventsWithItem }}
310
+ data={{
311
+ ...fieldData,
312
+ _selectableBlockEvents: _selectableBlockEventsWithItem,
313
+ }}
309
314
  id={compId}
310
315
  {...componentProps}
311
316
  emit={emitWithForItems}
@@ -11,31 +11,44 @@ export function getMetaInfoBySourceKey(sourceKey) {
11
11
  };
12
12
  }
13
13
 
14
- export function emitEvent(trigger, listeners = [], args, scopeContext = {}, context) {
14
+ export function emitEvent(
15
+ trigger,
16
+ listeners = [],
17
+ args,
18
+ scopeContext = {},
19
+ context
20
+ ) {
15
21
  const targetListeners = listeners.filter((l) => l.trigger === trigger);
16
22
  targetListeners.forEach(async (listener) => {
17
23
  // 当前非捕获Event,再判断冒泡行为
18
- if (
19
- !args?.customEventData?.detail?.isCapturePhase &&
20
- listener.noPropagation
21
- ) {
22
- args?.customEventData?.detail?.stopPropagation();
24
+ if (!args?.event?.isCapturePhase && listener.noPropagation) {
25
+ args?.customEventData?.stopPropagation();
23
26
  }
24
27
 
25
28
  // 判断捕获的执行,只有执行的捕获与配置的捕获一致时。才会执行。
26
29
  if (
27
30
  (listener?.isCapturePhase || false) ===
28
- (args?.customEventData?.detail?.isCapturePhase || false)
31
+ (args?.customEventData?.isCapturePhase || false)
29
32
  ) {
30
33
  try {
31
34
  const res = await invokeListener(listener, args, scopeContext, context);
32
35
  const eventName = `${listener.key}.success`;
33
36
  const event = {
34
- detail: {
35
- value: res,
36
- origin: args.event,
37
- isCapturePhase: !!args.event?.isCapturePhase,
38
- },
37
+ detail:
38
+ typeof res === 'object' && res !== null && !Array.isArray(res)
39
+ ? {
40
+ ...res,
41
+ /**
42
+ * @deprecated 历史bug
43
+ * value,origin,isCapturePhase
44
+ */
45
+ value: res,
46
+ origin: args.event,
47
+ isCapturePhase: !!args.event?.isCapturePhase,
48
+ }
49
+ : res,
50
+ origin: args.event,
51
+ isCapturePhase: !!args.event?.isCapturePhase,
39
52
  name: eventName,
40
53
  };
41
54
  emitEvent(
@@ -49,14 +62,22 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}, cont
49
62
  scopeContext,
50
63
  context
51
64
  );
65
+ if (res) {
66
+ console.warn(
67
+ `@deprecated 事件编排中后续事件(${eventName}) event.detail.value.xxx 已废弃,建议使用 event.detail 直接访问前一动作返回值`
68
+ );
69
+ }
52
70
  } catch (e) {
53
71
  const eventName = `${listener.key}.fail`;
72
+ try {
73
+ e.value = e;
74
+ e.origin = args.event;
75
+ e.isCapturePhase = !!args.event?.isCapturePhase;
76
+ } catch (e) {}
54
77
  const event = {
55
- detail: {
56
- value: e,
57
- origin: args.event,
58
- isCapturePhase: !!args.event?.isCapturePhase,
59
- },
78
+ detail: e,
79
+ origin: args.event,
80
+ isCapturePhase: !!args.event?.isCapturePhase,
60
81
  name: eventName,
61
82
  };
62
83
  emitEvent(
@@ -70,6 +91,9 @@ export function emitEvent(trigger, listeners = [], args, scopeContext = {}, cont
70
91
  scopeContext,
71
92
  context
72
93
  );
94
+ console.warn(
95
+ `@deprecated 事件编排中后续事件(${eventName}) event.detail.value.xxx 已废弃,建议使用 event.detail 直接访问前一动作返回值`
96
+ );
73
97
  // 之前 invoke 内部catch 了错误,不会抛错
74
98
  // throw e
75
99
  }
@@ -92,22 +92,16 @@ module.exports = function (options) {
92
92
  threadMode: true,
93
93
  loaders: {
94
94
  js: [babelLoader],
95
- ts: [
96
- babelLoader,
97
- typescriptLoader,
98
- ],
99
- }
100
- }
95
+ ts: [babelLoader, typescriptLoader],
96
+ },
97
+ },
101
98
  },
102
99
  ],
103
- threadPool: happyThreadPool
100
+ threadPool: happyThreadPool,
104
101
  }),
105
102
  new HappyPack({
106
103
  id: TS_LOADER_ID,
107
- loaders: [
108
- babelLoader,
109
- typescriptLoader,
110
- ],
104
+ loaders: [babelLoader, typescriptLoader],
111
105
  threadPool: happyThreadPool,
112
106
  }),
113
107
  new HappyPack({
@@ -125,13 +119,15 @@ module.exports = function (options) {
125
119
  filename: '[name].[contenthash].css',
126
120
  chunkFilename: '[id].[contenthash].css',
127
121
  }),
128
- new webpack.DefinePlugin(Object.assign(
129
- {
130
- 'process.env.isMiniprogram': false, // 注入环境变量,用于业务代码判断
131
- 'process.env.SSR': false,
132
- },
133
- definePlugin,
134
- )),
122
+ new webpack.DefinePlugin(
123
+ Object.assign(
124
+ {
125
+ 'process.env.isMiniprogram': false, // 注入环境变量,用于业务代码判断
126
+ 'process.env.SSR': false,
127
+ },
128
+ definePlugin
129
+ )
130
+ ),
135
131
  new CopyWebpackPlugin({
136
132
  patterns: [
137
133
  {
@@ -157,6 +153,36 @@ module.exports = function (options) {
157
153
  }),
158
154
  ]);
159
155
  }
156
+
157
+ const cssLoaders = [
158
+ MiniCssExtractPlugin.loader,
159
+ {
160
+ loader: 'css-loader',
161
+ options: {
162
+ modules: false,
163
+ importLoaders: 2,
164
+ },
165
+ },
166
+ {
167
+ loader: 'postcss-loader',
168
+ options: {
169
+ postcssOptions: {
170
+ plugins: [
171
+ [
172
+ 'postcss-pxtorem',
173
+ {
174
+ rootValue: 14,
175
+ propList: ['*'],
176
+ // todo
177
+ selectorBlackList: ['.weui-picker__indicator'],
178
+ },
179
+ ],
180
+ ],
181
+ },
182
+ },
183
+ },
184
+ ];
185
+
160
186
  return {
161
187
  context,
162
188
  entry,
@@ -184,7 +210,7 @@ module.exports = function (options) {
184
210
  rules: [
185
211
  {
186
212
  test: /\.vue$/,
187
- loader: 'happypack/loader?id=vue'
213
+ loader: 'happypack/loader?id=vue',
188
214
  },
189
215
  {
190
216
  test: /\.tsx?$/,
@@ -199,32 +225,7 @@ module.exports = function (options) {
199
225
  {
200
226
  test: /\.(scss|sass)$/,
201
227
  use: [
202
- MiniCssExtractPlugin.loader,
203
- {
204
- loader: 'css-loader',
205
- options: {
206
- modules: false,
207
- importLoaders: 2,
208
- },
209
- },
210
- {
211
- loader: 'postcss-loader',
212
- options: {
213
- postcssOptions: {
214
- plugins: [
215
- [
216
- 'postcss-pxtorem',
217
- {
218
- rootValue: 14,
219
- propList: ['*'],
220
- // todo
221
- selectorBlackList: ['.weui-picker__indicator'],
222
- },
223
- ],
224
- ],
225
- },
226
- },
227
- },
228
+ ...cssLoaders,
228
229
  {
229
230
  loader: 'sass-loader',
230
231
  options: {
@@ -234,34 +235,13 @@ module.exports = function (options) {
234
235
  ],
235
236
  },
236
237
  {
237
- test: /\.(css|less)$/,
238
+ test: /\.css$/,
239
+ use: [...cssLoaders],
240
+ },
241
+ {
242
+ test: /\.less$/,
238
243
  use: [
239
- MiniCssExtractPlugin.loader,
240
- {
241
- loader: 'css-loader',
242
- options: {
243
- modules: false,
244
- importLoaders: 2,
245
- },
246
- },
247
- {
248
- loader: 'postcss-loader',
249
- options: {
250
- postcssOptions: {
251
- plugins: [
252
- [
253
- 'postcss-pxtorem',
254
- {
255
- rootValue: 14,
256
- propList: ['*'],
257
- // todo
258
- selectorBlackList: ['.weui-picker__indicator'],
259
- },
260
- ],
261
- ],
262
- },
263
- },
264
- },
244
+ ...cssLoaders,
265
245
  {
266
246
  loader: 'less-loader',
267
247
  options: {
@@ -310,20 +290,20 @@ module.exports = function (options) {
310
290
  },
311
291
  ...(isDevelopment
312
292
  ? {
313
- minimize: false,
314
- removeAvailableModules: false,
315
- removeEmptyChunks: true,
316
- }
293
+ minimize: false,
294
+ removeAvailableModules: false,
295
+ removeEmptyChunks: true,
296
+ }
317
297
  : {
318
- minimizer: [
319
- new TerserPlugin({
320
- test: /\.js(\?.*)?$/i,
321
- cache: false,
322
- parallel: true,
323
- sourceMap: false,
324
- }),
325
- ],
326
- }),
298
+ minimizer: [
299
+ new TerserPlugin({
300
+ test: /\.js(\?.*)?$/i,
301
+ cache: false,
302
+ parallel: true,
303
+ sourceMap: false,
304
+ }),
305
+ ],
306
+ }),
327
307
  },
328
308
  };
329
309
  };