@cloudbase/framework-plugin-low-code 0.6.59-alpha.0 → 0.6.59

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.
@@ -1 +1 @@
1
- {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/builder/core/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAe5C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAkBnD,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,EAC3B,cAAc,kCAA2B,EACzC,YAAY,6BAAsB,EAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,SAAS,EAAE,EAC1B,UAAU,EAAE,WAAW,EACvB,OAAO,qBAAwB,EAC/B,aAAa,qBAAiB,EAC9B,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,MAAM,EAAE,MAAM,iBAsGf;AACD,wBAAsB,mBAAmB,CACvC,YAAY,oBAAa,EACzB,WAAW,EAAE,MAAM,EACnB,MAAM,KAAA,iBASP"}
1
+ {"version":3,"file":"generate.d.ts","sourceRoot":"","sources":["../../../src/builder/core/generate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAe5C,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAkBnD,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,OAAO,EAAE,kBAAkB,EAC3B,cAAc,kCAA2B,EACzC,YAAY,6BAAsB,EAClC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,aAAa,EAAE,SAAS,EAAE,EAC1B,UAAU,EAAE,WAAW,EACvB,OAAO,qBAAwB,EAC/B,aAAa,qBAAiB,EAC9B,SAAS;iBACM,OAAO;eACT,GAAG;aAIf,EACD,MAAM,EAAE,MAAM,iBAyGf;AACD,wBAAsB,mBAAmB,CACvC,YAAY,oBAAa,EACzB,WAAW,EAAE,MAAM,EACnB,MAAM,KAAA,iBASP"}
@@ -67,6 +67,8 @@ function runGenerateCore(appBuildDir, appData, subAppDataList = [], dependencies
67
67
  domain: domain,
68
68
  appConfig: util_1.JsonToStringWithVariableName({
69
69
  id: appKey,
70
+ staticResourceDomain: domain || '',
71
+ envVersion: deployMode === types_1.DEPLOY_MODE.UPLOAD ? 'production' : 'preview',
70
72
  pages: pageInstanceList
71
73
  .sort((item) => (item.isHome ? -1 : 1))
72
74
  .map((item) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/builder/mp/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,aAAa,EACb,UAAU,EAEV,OAAO,EAIR,MAAM,mBAAmB,CAAC;AAU3B,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAkB/C,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAEL,SAAS,EACT,YAAY,EACZ,UAAU,EACX,MAAM,iBAAiB,CAAC;AAUzB,wBAAsB,YAAY,CAAC,EACjC,MAAM,EACN,OAAO,EACP,KAAK,EACL,MAAM,EACN,SAAS,EACT,OAAO,EACP,YAAY,EACZ,UAAU,EACV,SAAS,EACT,SAAS,EACT,OAAO,EACP,aAAa,GACd,EAAE;IACD,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,EA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M,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,aAAa,EAAE,CAAC;IAC3B,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,YAAY,EAAE,OAAO,CAAC;IACtB,UAAU,EAAE,WAAW,CAAC;IACxB,SAAS,EAAE,GAAG,CAAC;IACf,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE;QACP,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;IACF,aAAa,EAAE,SAAS,EAAE,CAAC;CAC5B,GAAG,OAAO,CAAC;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC,CAuSvC;AA8KD,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,UAAU,EACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,aAAa,iBAgCnB;AAYD,wBAAgB,oBAAoB,CAAC,EACnC,YAAY,EACZ,MAAM,EACN,SAAS,GACV,EAAE;IACD,YAAY,EAAE,aAAa,CAAC;IAC5B,MAAM,EAAE,UAAU,EAAE,CAAC;IACrB,SAAS,EAAE,aAAa,EAAE,CAAC;CAC5B;;;EA0CA"}
@@ -328,6 +328,8 @@ function generateFramework(appData, outDir, ctx) {
328
328
  isBare: false,
329
329
  appConfig: util_3.JsonToStringWithVariableName({
330
330
  id: ctx.appId,
331
+ staticResourceDomain: ctx.domain || '',
332
+ envVersion: (ctx === null || ctx === void 0 ? void 0 : ctx.isProduction) ? 'production' : 'preview',
331
333
  pages: appData.pageInstanceList
332
334
  .sort((item) => (item.isHome ? -1 : 1))
333
335
  .map((item) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudbase/framework-plugin-low-code",
3
- "version": "0.6.59-alpha.0",
3
+ "version": "0.6.59",
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",
@@ -87,4 +87,4 @@
87
87
  "jest": "^26.0.1",
88
88
  "typescript": "^3.8.3"
89
89
  }
90
- }
90
+ }
@@ -1,10 +1,5 @@
1
1
  import * as React from 'react';
2
- import {
3
- useContext,
4
- useCallback,
5
- createContext,
6
- useRef
7
- } from 'react';
2
+ import { useContext, useCallback, createContext, useRef } from 'react';
8
3
  import { observer } from 'mobx-react-lite';
9
4
  import { emitEvent } from '../actionHandler/utils';
10
5
  import { translateStyleToRem } from '@tcwd/weapps-core';
@@ -12,15 +7,40 @@ import { get, set } from 'lodash';
12
7
  import { $page } from '../../app/global-api';
13
8
  import { getDom } from '../utils/widgets';
14
9
  import { checkVisible } from '../../utils/index';
10
+ import { generateSlotMetaMap } from '../render';
15
11
 
16
12
  export const ForContext = createContext({});
17
13
 
14
+ function generateSlotMap(slots, forContext = undefined) {
15
+ let map = {};
16
+ Object.keys(slots).forEach((slotProp) => {
17
+ let meta = slots[slotProp];
18
+ if (meta.type === 'HOC') {
19
+ set(map, slotProp, meta.node);
20
+ } else {
21
+ const Element = meta.node;
22
+ if (forContext) {
23
+ set(
24
+ map,
25
+ slotProp,
26
+ <ForContext.Provider value={forContext}>
27
+ <Element />
28
+ </ForContext.Provider>
29
+ );
30
+ } else {
31
+ set(map, slotProp, <Element />);
32
+ }
33
+ }
34
+ });
35
+ return map;
36
+ }
37
+
18
38
  export const CompRenderer = observer(function (props) {
19
39
  const {
20
40
  id: compId,
21
41
  xProps,
22
42
  virtualFields,
23
- slots = {},
43
+ renderSlot,
24
44
  codeContext,
25
45
  scopeContext,
26
46
  context = {},
@@ -56,6 +76,13 @@ export const CompRenderer = observer(function (props) {
56
76
  const Field = virtualFields[sourceKey];
57
77
  const parentForItems = useContext(ForContext);
58
78
 
79
+ const _context = {
80
+ scopeContext,
81
+ forContext: parentForItems,
82
+ codeContext,
83
+ dataContext: context,
84
+ };
85
+
59
86
  // 组件最终用于执行的事件函数
60
87
  const emit = useCallback(
61
88
  (trigger, eventDetail, forItems, scopeContext) => {
@@ -187,10 +214,22 @@ export const CompRenderer = observer(function (props) {
187
214
  if (!checkVisible(forItemData)) {
188
215
  return null;
189
216
  }
190
- // 多个组件的 slot 属性
191
- Object.keys(slots).forEach((slotProp) => {
192
- set(forItemData, slotProp, slots[slotProp]);
193
- });
217
+
218
+ const slotMap = generateSlotMap(
219
+ generateSlotMetaMap(
220
+ componentSchema,
221
+ {
222
+ ..._context,
223
+ forContext: forItems,
224
+ virtualFields,
225
+ updateContext,
226
+ },
227
+ {
228
+ renderSlot,
229
+ }
230
+ )
231
+ );
232
+
194
233
  const emitWithForItems = (trigger, evt) =>
195
234
  emit(trigger, evt, forItems, scopeContext);
196
235
 
@@ -230,6 +269,7 @@ export const CompRenderer = observer(function (props) {
230
269
  <Field
231
270
  data={{
232
271
  ...forItemData,
272
+ ...slotMap,
233
273
  _selectableBlockEvents: _selectableBlockEventsForItems,
234
274
  }}
235
275
  id={compId}
@@ -270,9 +310,19 @@ export const CompRenderer = observer(function (props) {
270
310
  }
271
311
 
272
312
  // 单个组件的 slot 属性
273
- Object.keys(slots).forEach((slotProp) => {
274
- set(fieldData, slotProp, slots[slotProp]);
275
- });
313
+ const slotMap = generateSlotMap(
314
+ generateSlotMetaMap(
315
+ componentSchema,
316
+ {
317
+ ...context,
318
+ virtualFields,
319
+ updateContext,
320
+ },
321
+ {
322
+ renderSlot,
323
+ }
324
+ )
325
+ );
276
326
 
277
327
  // 防止渲染时 data 的 style 与实际的 style 冲突
278
328
  delete fieldData.style;
@@ -304,6 +354,7 @@ export const CompRenderer = observer(function (props) {
304
354
  <Field
305
355
  data={{
306
356
  ...fieldData,
357
+ ...slotMap,
307
358
  _selectableBlockEvents: _selectableBlockEventsWithItem,
308
359
  }}
309
360
  id={compId}
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { useRef } from 'react';
3
3
  import * as _ from 'lodash';
4
- import { CompRenderer } from './FieldMiddleware/renderer';
4
+ import { CompRenderer, ForContext } from './FieldMiddleware/renderer';
5
5
  import { isScopeSlot } from '../utils/index';
6
6
 
7
7
  function getComponentChildren(component) {
@@ -14,6 +14,68 @@ function getComponentChildren(component) {
14
14
  );
15
15
  }
16
16
 
17
+ export function generateSlotMetaMap(componentSchema, context, options = {}) {
18
+ const slots = {};
19
+ const { properties = {} } = componentSchema;
20
+ const {
21
+ scopeContext,
22
+ codeContext,
23
+ virtualFields,
24
+ dataContext,
25
+ updateContext,
26
+ forContext,
27
+ } = context;
28
+ // eslint-disable-next-line guard-for-in
29
+ for (const key in properties) {
30
+ const child = properties[key];
31
+ if (!child['x-props'] && child.properties) {
32
+ const isHOC = isScopeSlot(componentSchema, key);
33
+
34
+ slots[key] = {
35
+ type: isHOC ? 'HOC' : 'ELEMENT',
36
+ node: isHOC
37
+ ? (props) => {
38
+ let clonedScopeContext = _.cloneDeep(scopeContext);
39
+ _.set(
40
+ clonedScopeContext,
41
+ `${componentSchema.key}.${child.key}`,
42
+ props
43
+ );
44
+ return (
45
+ <AppRender
46
+ key={child.key}
47
+ componentSchema={child}
48
+ renderSlot={options?.renderSlot}
49
+ virtualFields={virtualFields}
50
+ codeContext={codeContext}
51
+ scopeContext={clonedScopeContext}
52
+ context={dataContext}
53
+ updateContext={updateContext}
54
+ />
55
+ );
56
+ }
57
+ : () => {
58
+ return (
59
+ <ForContext.Provider value={forContext}>
60
+ <AppRender
61
+ key={child.key}
62
+ componentSchema={child}
63
+ renderSlot={options?.renderSlot}
64
+ virtualFields={virtualFields}
65
+ codeContext={codeContext}
66
+ scopeContext={scopeContext}
67
+ context={dataContext}
68
+ updateContext={updateContext}
69
+ />
70
+ </ForContext.Provider>
71
+ );
72
+ },
73
+ };
74
+ }
75
+ }
76
+ return slots;
77
+ }
78
+
17
79
  export function AppRender(props) {
18
80
  const {
19
81
  className,
@@ -70,46 +132,6 @@ export function AppRender(props) {
70
132
  }
71
133
 
72
134
  const children = getComponentChildren(componentSchema);
73
- const slots = {};
74
- // eslint-disable-next-line guard-for-in
75
- for (const key in properties) {
76
- const child = properties[key];
77
- if (!child['x-props'] && child.properties) {
78
- slots[key] = isScopeSlot(componentSchema, key) ? (
79
- (props) => {
80
- let clonedScopeContext = _.cloneDeep(scopeContext);
81
- _.set(
82
- clonedScopeContext,
83
- `${componentSchema.key}.${child.key}`,
84
- props
85
- );
86
- return (
87
- <AppRender
88
- key={child.key}
89
- componentSchema={child}
90
- renderSlot
91
- virtualFields={virtualFields}
92
- codeContext={codeContext}
93
- scopeContext={clonedScopeContext}
94
- context={context}
95
- updateContext={updateContext}
96
- />
97
- );
98
- }
99
- ) : (
100
- <AppRender
101
- key={child.key}
102
- componentSchema={child}
103
- renderSlot
104
- virtualFields={virtualFields}
105
- codeContext={codeContext}
106
- scopeContext={scopeContext}
107
- context={context}
108
- updateContext={updateContext}
109
- />
110
- );
111
- }
112
- }
113
135
 
114
136
  return (
115
137
  <CompRenderer
@@ -118,7 +140,7 @@ export function AppRender(props) {
118
140
  emitEvents={componentSchema.emitEvents || []}
119
141
  componentSchema={componentSchema}
120
142
  virtualFields={virtualFields}
121
- slots={slots}
143
+ renderSlot={renderSlot}
122
144
  codeContext={codeContext}
123
145
  scopeContext={scopeContext}
124
146
  context={context}