@cloudbase/framework-plugin-low-code 1.0.3-beta.11 → 1.0.3-beta.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.
Files changed (80) hide show
  1. package/lib/builder/config/common.js +5 -1
  2. package/lib/builder/config/index.js +5 -1
  3. package/lib/builder/config/mp.js +5 -1
  4. package/lib/builder/core/copy.js +5 -1
  5. package/lib/builder/core/material.js +5 -1
  6. package/lib/builder/core/prepare.js +5 -1
  7. package/lib/builder/mp/index.js +5 -1
  8. package/lib/builder/mp/materials.js +5 -1
  9. package/lib/builder/mp/mixMode.js +5 -1
  10. package/lib/builder/mp/mp_config.js +7 -3
  11. package/lib/builder/service/builder/copy.js +5 -1
  12. package/lib/builder/service/builder/generate.js +8 -8
  13. package/lib/builder/service/builder/plugin.js +5 -1
  14. package/lib/builder/util/console.js +5 -1
  15. package/lib/builder/util/generateFiles.js +5 -1
  16. package/lib/builder/util/index.js +5 -1
  17. package/lib/builder/util/mp.js +5 -1
  18. package/lib/builder/util/net.js +5 -1
  19. package/lib/builder/util/process.d.ts +1 -0
  20. package/lib/builder/util/process.d.ts.map +1 -1
  21. package/lib/builder/util/style.js +5 -1
  22. package/lib/builder/util/weapp.js +5 -1
  23. package/lib/generator/config/index.js +5 -1
  24. package/lib/generator/core/generate.js +10 -10
  25. package/lib/generator/core/material.js +5 -1
  26. package/lib/generator/util/index.js +5 -1
  27. package/lib/weapps-core/config/index.js +5 -1
  28. package/lib/weapps-core/index.js +5 -1
  29. package/lib/weapps-core/types/index.js +5 -1
  30. package/lib/weapps-core/utils/file.d.ts +1 -1
  31. package/lib/weapps-core/utils/index.js +5 -1
  32. package/package.json +3 -3
  33. package/template/src/app/common.js +0 -13
  34. package/template/src/app/global-api.js +0 -132
  35. package/template/src/app/handlers.js +0 -13
  36. package/template/src/app/material-actions.js +0 -16
  37. package/template/src/app/mountAppApis.js +0 -25
  38. package/template/src/app/mountMpApis.js +0 -4
  39. package/template/src/datasources/config.js.tpl +0 -27
  40. package/template/src/datasources/dataset-profiles.js.tpl +0 -5
  41. package/template/src/datasources/datasource-profiles.js.tpl +0 -4
  42. package/template/src/datasources/index.js.tpl +0 -27
  43. package/template/src/handlers/FieldMiddleware/renderer.jsx +0 -536
  44. package/template/src/handlers/HotAreas.js +0 -36
  45. package/template/src/handlers/PositionHandler.jsx +0 -8
  46. package/template/src/handlers/actionHandler/utils.js +0 -154
  47. package/template/src/handlers/componentEventActionEmitter.js +0 -29
  48. package/template/src/handlers/componentNodeMap.js +0 -24
  49. package/template/src/handlers/controller.js +0 -5
  50. package/template/src/handlers/emitComponentEvent.js +0 -8
  51. package/template/src/handlers/eventListener/componentEventListener.js +0 -15
  52. package/template/src/handlers/eventListener/hotAreaEventListener.js +0 -32
  53. package/template/src/handlers/eventListener/index.js +0 -29
  54. package/template/src/handlers/eventListener/pageEventListener.js +0 -11
  55. package/template/src/handlers/eventListener/types.js +0 -32
  56. package/template/src/handlers/hooks/index.js +0 -15
  57. package/template/src/handlers/initWebEnv.js +0 -4
  58. package/template/src/handlers/injectStyle.js +0 -14
  59. package/template/src/handlers/instanceMap.js +0 -39
  60. package/template/src/handlers/lifecycle.js +0 -222
  61. package/template/src/handlers/render.jsx +0 -170
  62. package/template/src/handlers/utils/common.js +0 -298
  63. package/template/src/handlers/utils/eventProxy.js +0 -64
  64. package/template/src/handlers/utils/events.js +0 -8
  65. package/template/src/handlers/utils/index.js +0 -4
  66. package/template/src/handlers/utils/widgets.js +0 -307
  67. package/template/src/index.jsx +0 -185
  68. package/template/src/index.less +0 -119
  69. package/template/src/libraries/default-lib/wx_yypt_report_v2.js +0 -441
  70. package/template/src/pages/app.tpl +0 -200
  71. package/template/src/pages/composite.tpl +0 -171
  72. package/template/src/router/index.tpl +0 -29
  73. package/template/src/store/computed.js +0 -11
  74. package/template/src/store/index.js +0 -40
  75. package/template/src/utils/formatEnum.js +0 -42
  76. package/template/src/utils/history.js +0 -66
  77. package/template/src/utils/index.js +0 -82
  78. package/template/src/utils/kbone.js +0 -18
  79. package/template/src/utils/monitor-jssdk.min.js +0 -763
  80. package/template/src/utils/request.js +0 -5
@@ -1,170 +0,0 @@
1
- import * as React from 'react';
2
- import { set, cloneDeep } from 'lodash';
3
- import { ForContext, getComponentRenderList } from './FieldMiddleware/renderer';
4
- import { isScopeSlot } from '../utils/index';
5
- import { observer } from 'mobx-react-lite';
6
-
7
- export function getComponentChildren(component, context = {}) {
8
- const { properties } = component;
9
- if (!properties) {
10
- return [];
11
- }
12
- const list = Object.values(properties).sort((a, b) => (a['x-index'] || 0) - (b['x-index'] || 0));
13
- const {
14
- virtualFields,
15
- codeContext,
16
- scopeContext,
17
- forContext,
18
- injectContext = {},
19
- dataContext,
20
- updateContext,
21
- } = context;
22
-
23
- return list.map((schema) => {
24
- return getRenderList({
25
- key: schema.key,
26
- componentSchema: schema,
27
- rootNode: false,
28
- renderSlot: false,
29
- virtualFields,
30
- codeContext,
31
- scopeContext,
32
- forContext,
33
- injectContext,
34
- context: dataContext,
35
- updateContext,
36
- });
37
- });
38
- }
39
-
40
- function getRenderList(props) {
41
- const {
42
- key = '',
43
- className,
44
- virtualFields,
45
- componentSchema,
46
- renderSlot,
47
- rootNode = true,
48
- codeContext,
49
- scopeContext = {},
50
- context = {},
51
- updateContext,
52
- forContext = {},
53
- } = props;
54
-
55
- const { 'x-props': xProps, properties = {} } = componentSchema;
56
-
57
- // 判断是否为 slot
58
- const isSlot = !xProps;
59
- if (isSlot && !(renderSlot || rootNode)) {
60
- return null;
61
- }
62
-
63
- // const preClassName = useRef();
64
-
65
- // wrapperClass
66
- const containerEl = Object.values(properties)[0];
67
- if (containerEl && containerEl['x-props'] && className) {
68
- let { classNameList = [] } = containerEl['x-props'];
69
-
70
- // 先替换掉先前计算出来的className部分
71
- // if (preClassName.current) {
72
- // if (preClassName.current !== className) {
73
- // classNameList = classNameList.filter(
74
- // (clsName) => clsName !== preClassName.current
75
- // );
76
- // preClassName.current = className;
77
- // }
78
- // } else {
79
- // preClassName.current = className;
80
- // }
81
-
82
- containerEl['x-props'].classNameList = Array.from(new Set([className, ...classNameList]));
83
- }
84
-
85
- if (xProps && xProps.sourceKey) {
86
- const { sourceKey } = xProps;
87
- const Field = virtualFields[sourceKey];
88
- if (!Field) {
89
- return (
90
- <div style={{ color: 'red' }}>
91
- 组件<em>{sourceKey}</em>未找到
92
- </div>
93
- );
94
- }
95
- }
96
-
97
- return getComponentRenderList({
98
- key,
99
- componentSchema,
100
- id: componentSchema.key,
101
- xProps,
102
- emitEvents: componentSchema.emitEvents || [],
103
- virtualFields,
104
- renderSlot,
105
- codeContext,
106
- scopeContext,
107
- forContext,
108
- context,
109
- updateContext,
110
- });
111
- }
112
-
113
- export function generateSlotMetaMap(componentSchema, context, options = {}) {
114
- const slots = {};
115
- const { properties = {} } = componentSchema;
116
- const { scopeContext, codeContext, virtualFields, dataContext, updateContext, forContext } = context;
117
- // eslint-disable-next-line guard-for-in
118
- for (const key in properties) {
119
- const child = properties[key];
120
- if (!child['x-props'] && child.properties) {
121
- const isHOC = isScopeSlot(componentSchema, key);
122
-
123
- slots[key] = {
124
- type: isHOC ? 'HOC' : 'ELEMENT',
125
- node: isHOC
126
- ? (props) => {
127
- let clonedScopeContext = cloneDeep(scopeContext);
128
- set(clonedScopeContext, `${componentSchema.key}.${key}`, props);
129
- return (
130
- <AppRender
131
- key={key}
132
- componentSchema={child}
133
- renderSlot={options?.renderSlot}
134
- virtualFields={virtualFields}
135
- codeContext={codeContext}
136
- scopeContext={clonedScopeContext}
137
- context={dataContext}
138
- updateContext={updateContext}
139
- />
140
- );
141
- }
142
- : () => {
143
- return (
144
- <ForContext.Provider value={forContext}>
145
- <AppRender
146
- key={key}
147
- componentSchema={child}
148
- renderSlot={options?.renderSlot}
149
- virtualFields={virtualFields}
150
- codeContext={codeContext}
151
- scopeContext={scopeContext}
152
- context={dataContext}
153
- updateContext={updateContext}
154
- />
155
- </ForContext.Provider>
156
- );
157
- },
158
- };
159
- }
160
- }
161
- return slots;
162
- }
163
-
164
- export const AppRender = observer(function (props) {
165
- return getRenderList({
166
- ...props,
167
- forContext: React.useContext(ForContext),
168
- injectContext: {},
169
- });
170
- });
@@ -1,298 +0,0 @@
1
- import config from '../../datasources/config'
2
- import { auth } from '@cloudbase/weda-client';
3
- const { loginScope, getAccessToken } = auth;
4
-
5
- export function getComponentId(key) {
6
- return `__weapps-component-wrapper-${key}`;
7
- }
8
-
9
- export const pathSpecialSymbol = '__$__';
10
-
11
- export function pathTransformDotToSymbol(str) {
12
- return str.replace(/\./g, pathSpecialSymbol);
13
- }
14
-
15
- export function pathTransformSymbolToDot(str) {
16
- return String(str).replace(new RegExp(`__\\$__`, 'g'), '.');
17
- }
18
-
19
- /**
20
- * All data bindings are generated as functions: (forItems, event?) => any
21
- * @param {*} dataBinds
22
- * @param {*} forItems
23
- */
24
- export function resolveDataBinds(
25
- dataBinds,
26
- forItems,
27
- codeContext,
28
- scopeContext,
29
- throwError,
30
- context
31
- ) {
32
- const resolvedProps = {};
33
- for (const prop in dataBinds) {
34
- let fn = dataBinds[prop];
35
- try {
36
- if (codeContext && codeContext.$WEAPPS_COMP) {
37
- fn = fn.bind(codeContext.$WEAPPS_COMP);
38
- }
39
- resolvedProps[prop] = fn(
40
- forItems,
41
- codeContext && codeContext.event,
42
- context
43
- );
44
- } catch (e) {
45
- console.error('Error resolving data binding', prop, dataBinds[prop], e);
46
- if (throwError) {
47
- throw e;
48
- }
49
- }
50
- }
51
- return resolvedProps;
52
- }
53
-
54
- const varSeparator = '.';
55
- export function getDeep(target, key) {
56
- if (key == null) {
57
- return target;
58
- }
59
- const keys = (key + '').split(varSeparator);
60
- let prop = target[keys[0]];
61
- for (let i = 1; i < keys.length; i++) {
62
- prop = prop[keys[i]];
63
- }
64
- return prop;
65
- }
66
-
67
- /**
68
- * 用于处理自定义组件props传参结构,对系统变量进行保留
69
- */
70
- export function resolveComponentProps(props, isPlainProps) {
71
- const { staticResourceAttribute } = props;
72
- staticResourceAttribute &&
73
- staticResourceAttribute.map((property) => {
74
- if (props.data && props.data[property]) {
75
- props.data[property] = getStaticResourceAttribute(props.data[property]);
76
- }
77
- });
78
- if (!isPlainProps) {
79
- return {
80
- ...props,
81
- };
82
- }
83
- const { data = {}, events = [], $node, ...restProps } = props;
84
- const customProps = { ...data };
85
- const builtinProps = [
86
- // react 保留字
87
- 'ref',
88
- 'key',
89
- 'dangerouslySetInnerHTML',
90
- 'className',
91
- 'htmlFor',
92
- 'style',
93
- 'contentEditable',
94
- // lowcode 保留字
95
- 'events',
96
- 'children',
97
- '_parentId',
98
- '_visible',
99
- 'classList',
100
- 'widgetType',
101
- 'getWidgetsByType',
102
- 'getDom',
103
- 'domRef',
104
- 'extends',
105
- // 小程序保留字
106
- 'id',
107
- 'class',
108
- 'hidden',
109
- 'slot',
110
- ];
111
- builtinProps.map((prop) => delete customProps[prop]);
112
- // 选区events处理
113
- const { _selectableBlockEvents, ...restData } = data;
114
- const { emit: _selectableBlockEmit } = _selectableBlockEvents;
115
- _selectableBlockEvents.events = new Proxy(
116
- _selectableBlockEvents.events.reduce((events, item) => {
117
- const propName = item;
118
- events[propName] = (e) => _selectableBlockEmit(propName, e);
119
- return events;
120
- }, {}),
121
- {
122
- get(obj, prop) {
123
- return prop in obj ? obj[prop] : (e) => _selectableBlockEmit(prop, e);
124
- },
125
- }
126
- );
127
- return {
128
- ...restData,
129
- ...restProps,
130
- _selectableBlockEvents,
131
- events: events.reduce((events, item) => {
132
- const propName = item;
133
- events[propName] = (e) => restProps.emit(propName, e);
134
- return events;
135
- }, {}),
136
- };
137
- }
138
-
139
- export function getStaticResourceAttribute(staticUrl) {
140
- const { __internal__ = {} } = window.app || {};
141
- return __internal__?.resolveStaticResourceUrl?.(staticUrl) || staticUrl
142
- }
143
-
144
- export function findLoginPage(app = window.app) {
145
- const { pages = [] } = app.__internal__.getConfig();
146
- return pages.find(item => item.type === 'login');
147
- }
148
-
149
- let _AUTH_CONFIG_CACHE = null;
150
- export async function getAuthConfig(app = window.app) {
151
- if (_AUTH_CONFIG_CACHE) {
152
- return _AUTH_CONFIG_CACHE;
153
- }
154
- try {
155
- const res = await app.cloud.callWedaApi({
156
- action: "DescribeRuntimeResourceStrategy",
157
- data: {
158
- ResourceType: `<%= isAdminPortal? 'modelApp' : 'app'%>`,
159
- ResourceId: app.id,
160
- },
161
- });
162
- const settingData = {};
163
- // 云api不支持map只能传字符串,需要转换
164
- res.forEach((item) => {
165
- settingData[item.Key] = ['AllowRegister', 'NeedLogin'].includes(item.Key) ? item.Value === '1' : item.Value;
166
- });
167
- _AUTH_CONFIG_CACHE = settingData;
168
- return _AUTH_CONFIG_CACHE;
169
- } catch (e) {
170
- return {
171
- NeedLogin: false,
172
- RejectStrategy: "show_warning",
173
- };
174
- }
175
- }
176
-
177
- let _AUTH_CACHE_MAP = {}
178
- async function getAccessPermission(app, appId, pageId) {
179
- const cacheKey = `${appId}-${pageId}`
180
- if (_AUTH_CACHE_MAP[cacheKey] !== undefined) {
181
- return _AUTH_CACHE_MAP[cacheKey];
182
- }
183
-
184
- let isAccess = false;
185
- try {
186
- const res = await app.cloud.callWedaApi({
187
- action: 'DescribeResourcesPermission',
188
- data: {
189
- ResourceType: `<%= isAdminPortal? 'modelApp' : 'app'%>`,
190
- ResourceIdList: [cacheKey],
191
- AppResourceId: appId,
192
- },
193
- });
194
- if (Array.isArray(res) && res.length > 0) {
195
- isAccess = !!res[0].IsAccess;
196
- }
197
- _AUTH_CACHE_MAP[cacheKey] = isAccess;
198
- } catch (e) {
199
- console.warn('getAccessPermission', e);
200
- }
201
- return isAccess
202
- }
203
-
204
- export async function checkAnonymous() {
205
- // 用户是否非匿名登录前端判断条件:有accessToken且scope不为anonymous
206
- // 此分支逻辑本不应该前端判断是否登录,历史原因后端短期内搞不定,后续后端优化后删除
207
- let isAnonymous = true;
208
- try {
209
- const [scope, { accessToken }] = await Promise.all([loginScope(), getAccessToken()]);
210
- if (accessToken && scope !== 'anonymous') {
211
- isAnonymous = false;
212
- }
213
- } catch (e) { }
214
- return isAnonymous;
215
- }
216
-
217
- /**
218
- * 检查页面权限
219
- **/
220
- export async function checkAuth(app, appId, $page) {
221
- return true
222
- <% if (isAdminPortal || isXPage) { %>return true;<% } %>
223
- app.showNavigationBarLoading();
224
- const { loginConfigVersion } = app.__internal__.getConfig();
225
- const requestList = [getAccessPermission(app, appId, $page.id)];
226
- // 有登录配置版本号时,才拉取自定义登录配置进行校验
227
- if (loginConfigVersion) {
228
- requestList.push(getAuthConfig(app));
229
- requestList.push(checkAnonymous());
230
- }
231
- const [isAccess, authConfig, isAnonymous] = await Promise.all(requestList);
232
- app.hideNavigationBarLoading();
233
-
234
- if (loginConfigVersion && isAnonymous) {
235
- if (authConfig.NeedLogin || (!isAccess && authConfig.RejectStrategy === 'to_login')) {
236
- redirectToLogin($page);
237
- return false;
238
- }
239
- }
240
-
241
- if (!isAccess) {
242
- app.showToast({
243
- title: '页面无访问权限',
244
- icon: 'error',
245
- });
246
- }
247
- return isAccess;
248
- }
249
-
250
- export async function redirectToLogin(currentPage) {
251
- // 去登录则清空权限缓存。
252
- _AUTH_CACHE_MAP = {};
253
- const app = window.app;
254
-
255
- const { envId, id, clientId, loginConfigVersion } = app.__internal__.getConfig();
256
- if (loginConfigVersion) {
257
- const url = `${location.origin}/__auth/?redirect_uri=${encodeURIComponent(
258
- location.href,
259
- )}&app_id=${id}&env_id=${envId}&client_id=${clientId}&config_version=${loginConfigVersion}`;
260
- app.redirectTo({
261
- mode: 'web',
262
- params: {},
263
- url,
264
- });
265
- } else {
266
- app.showToast({
267
- title: '用户未登录',
268
- icon: 'error',
269
- });
270
- }
271
- }
272
-
273
- const _REPORTED = {}
274
- export function reportTime(tag, time, only = false) {
275
- if (!window._aegis || !tag) {
276
- return;
277
- }
278
- if (window['_WedaHostConfig'] && !window['_WedaHostConfig']['_REPORTED']) {
279
- window['_WedaHostConfig']['_REPORTED'] = _REPORTED
280
- }
281
-
282
- const CACHE_MAP = window['_WedaHostConfig']?.['_REPORTED'] || _REPORTED
283
-
284
- if (only && CACHE_MAP[tag]) {
285
- return;
286
- }
287
- CACHE_MAP[tag] = true
288
- try {
289
- let t = time === undefined ? (performance?.now?.() || Date.now() - window['_aegis_inited']) : time;
290
- window._aegis.reportTime({
291
- name: tag,
292
- duration: t,
293
- ext2: config.isProd ? 'production' : 'preview',
294
- })
295
- } catch (e) {
296
- console.log(e)
297
- }
298
- }
@@ -1,64 +0,0 @@
1
- /**
2
- * @author elliothu@tencent.com
3
- * @date 2019-05-07
4
- * @desc 事件系统,用于全局通信
5
- */
6
-
7
- export class EventProxy {
8
- proxies = {};
9
-
10
- onceProxies = {};
11
-
12
- on = (eventName, handler) => {
13
- if (this.proxies[eventName]) {
14
- return this.proxies[eventName].push(handler);
15
- }
16
- this.proxies[eventName] = [handler];
17
- };
18
-
19
- only = (eventName, handler) => {
20
- this.proxies[eventName] = [handler];
21
- };
22
-
23
- once = (eventName, handler) => {
24
- if (this.onceProxies[eventName]) {
25
- return this.onceProxies[eventName].push(handler);
26
- }
27
- this.onceProxies[eventName] = [handler];
28
- };
29
-
30
- emit = (eventName, ...args) => {
31
- if (this.proxies[eventName]) {
32
- this.proxies[eventName].forEach(handler => handler(...args));
33
- }
34
- if (this.onceProxies[eventName]) {
35
- this.onceProxies[eventName].forEach(handler => handler(...args));
36
- this.onceProxies[eventName] = [];
37
- }
38
- };
39
-
40
- cancel = (eventName, handler) => {
41
- if (!this.proxies[eventName]) { return; }
42
- this.proxies[eventName] = this.proxies[eventName].filter(h => h !== handler);
43
- };
44
-
45
- cancelOnce = (eventName, handler) => {
46
- if (!this.onceProxies[eventName]) { return; }
47
- this.onceProxies[eventName] = this.onceProxies[eventName].filter(h => h !== handler);
48
- };
49
-
50
- cancelAll = eventName => {
51
- if (!this.proxies[eventName]) { return; }
52
- this.proxies[eventName] = [];
53
- };
54
-
55
- cancelAllOnce = eventName => {
56
- if (!this.onceProxies[eventName]) { return; }
57
- this.onceProxies[eventName] = [];
58
- };
59
-
60
- clear = () => {
61
- this.proxies = {};
62
- this.onceProxies = {};
63
- };
64
- }
@@ -1,8 +0,0 @@
1
- import { EventProxy } from './eventProxy';
2
-
3
- export const EventEmitTypes = {
4
- COMPONENT_INTERSECTING_CHANGE: 'component_intersecting_change',
5
- HOT_AREA_INTERSECTING_CHANGE: 'hot_area_intersecting_change',
6
- };
7
-
8
- export const events = new EventProxy();
@@ -1,4 +0,0 @@
1
- export * from './events'
2
- export * from './eventProxy'
3
- export * from './common'
4
- export * from './widgets'