@cloudbase/cals 1.0.50 → 1.0.52-alpha.0

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 (93) hide show
  1. package/lib/parser/cals/index.d.ts.map +1 -1
  2. package/lib/parser/cals/index.js +8 -6
  3. package/lib/parser/cals/utils/block/index.js +151 -0
  4. package/lib/parser/cals/utils/code/index.js +393 -0
  5. package/lib/parser/cals/utils/common.js +268 -0
  6. package/lib/parser/cals/utils/getUsedResources.d.ts +10 -0
  7. package/lib/parser/cals/utils/getUsedResources.d.ts.map +1 -0
  8. package/lib/parser/cals/utils/getUsedResources.js +128 -0
  9. package/lib/parser/cals/utils/runtime.js +268 -0
  10. package/lib/parser/cals/utils/spinoff/index.d.ts.map +1 -1
  11. package/lib/parser/cals/utils/spinoff/index.js +5 -3
  12. package/lib/parser/cals/utils/style.js +472 -0
  13. package/lib/parser/cals/utils/version/common.js +385 -0
  14. package/lib/parser/cals/utils/version/config.d.ts +16 -0
  15. package/lib/parser/cals/utils/version/config.d.ts.map +1 -0
  16. package/lib/parser/cals/utils/version/config.js +244 -0
  17. package/lib/parser/cals/utils/version/index.js +96 -0
  18. package/lib/parser/cals/utils/version/parses.js +581 -0
  19. package/lib/parser/cals/utils/version/utils.d.ts +14 -0
  20. package/lib/parser/cals/utils/version/utils.d.ts.map +1 -0
  21. package/lib/parser/cals/utils/version/utils.js +148 -0
  22. package/lib/parser/dependiencies/index.d.ts +116 -0
  23. package/lib/parser/dependiencies/index.d.ts.map +1 -0
  24. package/lib/parser/dependiencies/index.js +674 -0
  25. package/lib/parser/expression/index.d.ts +123 -0
  26. package/lib/parser/expression/index.d.ts.map +1 -0
  27. package/lib/parser/expression/index.js +301 -0
  28. package/lib/parser/index.d.ts +2 -1
  29. package/lib/parser/index.d.ts.map +1 -1
  30. package/lib/parser/index.js +3 -1
  31. package/lib/parser/plugins/postcss-rpx2clac.d.ts +18 -0
  32. package/lib/parser/plugins/postcss-rpx2clac.d.ts.map +1 -0
  33. package/lib/parser/plugins/postcss-rpx2clac.js +68 -0
  34. package/lib/types/basic/app.d.ts +73 -0
  35. package/lib/types/basic/app.d.ts.map +1 -0
  36. package/lib/types/basic/app.js +2 -0
  37. package/lib/types/basic/common.d.ts +93 -0
  38. package/lib/types/basic/common.d.ts.map +1 -0
  39. package/lib/types/basic/common.js +2 -0
  40. package/lib/types/basic/component.d.ts +211 -0
  41. package/lib/types/basic/component.d.ts.map +1 -0
  42. package/lib/types/basic/component.js +2 -0
  43. package/lib/types/basic/datasource.d.ts +50 -0
  44. package/lib/types/basic/datasource.d.ts.map +1 -0
  45. package/lib/types/basic/datasource.js +2 -0
  46. package/lib/types/index.js +42 -0
  47. package/lib/types/lcds.js +25 -0
  48. package/lib/types/platform/app.js +11 -0
  49. package/lib/types/platform/common.d.ts +181 -0
  50. package/lib/types/platform/common.d.ts.map +1 -0
  51. package/lib/types/platform/common.js +87 -0
  52. package/lib/types/platform/component.d.ts +139 -0
  53. package/lib/types/platform/component.d.ts.map +1 -0
  54. package/lib/types/platform/component.js +11 -0
  55. package/lib/types/platform/datasource.d.ts +467 -0
  56. package/lib/types/platform/datasource.d.ts.map +1 -0
  57. package/lib/types/platform/datasource.js +2 -0
  58. package/lib/types/platform/eventFlow.d.ts +20 -0
  59. package/lib/types/platform/eventFlow.d.ts.map +1 -0
  60. package/lib/types/platform/eventFlow.js +2 -0
  61. package/lib/types/platform/query.d.ts +67 -0
  62. package/lib/types/platform/query.d.ts.map +1 -0
  63. package/lib/types/platform/query.js +2 -0
  64. package/lib/types/platform/theme.js +2 -0
  65. package/lib/types/platform/widget/form.d.ts +5 -0
  66. package/lib/types/platform/widget/form.d.ts.map +1 -0
  67. package/lib/types/platform/widget/form.js +5 -0
  68. package/lib/types/platform/widget/meta.d.ts +60 -0
  69. package/lib/types/platform/widget/meta.d.ts.map +1 -0
  70. package/lib/types/platform/widget/meta.js +6 -0
  71. package/lib/utils/CSSProperty.d.ts +64 -0
  72. package/lib/utils/CSSProperty.d.ts.map +1 -0
  73. package/lib/utils/CSSProperty.js +89 -0
  74. package/lib/utils/build.d.ts +2 -0
  75. package/lib/utils/build.d.ts.map +1 -0
  76. package/lib/utils/build.js +75 -0
  77. package/lib/utils/constant.d.ts +19 -0
  78. package/lib/utils/constant.d.ts.map +1 -1
  79. package/lib/utils/constant.js +24 -1
  80. package/lib/utils/dts/auto-generated.d.ts +2 -0
  81. package/lib/utils/dts/auto-generated.d.ts.map +1 -0
  82. package/lib/utils/dts/auto-generated.js +1796 -0
  83. package/lib/utils/dts/build.d.ts +2 -0
  84. package/lib/utils/dts/build.d.ts.map +1 -0
  85. package/lib/utils/dts/build.js +136 -0
  86. package/lib/utils/dts/index.js +1008 -0
  87. package/lib/utils/index.js +27 -0
  88. package/lib/utils/version/common.d.ts +3 -0
  89. package/lib/utils/version/common.d.ts.map +1 -0
  90. package/lib/utils/version/common.js +27 -0
  91. package/lib/utils/version/featureChecker.js +35 -0
  92. package/lib/utils/version/migrations/version4.js +199 -0
  93. package/package.json +4 -4
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.findComponentInTree = exports.checkIsNeedAddFormWrapper = exports.isPlainObject = exports.isEmptyObject = exports.isWeAppId = exports.getComponentChildren = exports.isComplexJSON = exports.addDefaultData = exports.addDefaultSlot = exports.isGsdH5ReactComponent = exports.isComplexComponent = exports.getId = exports.init = void 0;
7
+ const config_1 = require("./config");
8
+ const merge_1 = __importDefault(require("lodash/merge"));
9
+ const ids = [];
10
+ let maxId = 10000;
11
+ function init(json) {
12
+ const { pageInstanceList = [] } = json;
13
+ const comps = [];
14
+ pageInstanceList.forEach((instance, index) => {
15
+ const { componentInstances } = instance;
16
+ for (const i in componentInstances) {
17
+ ids.push(i);
18
+ const comp = componentInstances[i];
19
+ comps.push(comp);
20
+ }
21
+ });
22
+ while (true) {
23
+ const topComp = comps.pop();
24
+ if (!topComp) {
25
+ break;
26
+ }
27
+ const keys = Object.keys(topComp['properties'] || {});
28
+ if (keys.length > 0) {
29
+ keys.forEach((key) => {
30
+ ids.push(key);
31
+ const _comp = topComp['properties'][key];
32
+ comps.push(_comp);
33
+ });
34
+ }
35
+ }
36
+ const idNums = ids.map((id) => parseInt(id.replace('id', ''))).filter((item) => !isNaN(item));
37
+ maxId = Math.max(...idNums);
38
+ }
39
+ exports.init = init;
40
+ function getId() {
41
+ return `id${++maxId}`;
42
+ }
43
+ exports.getId = getId;
44
+ function isComplexComponent(name = '') {
45
+ const bigoName = config_1.COMPLEX_COMPONENT_KEYS.map((item) => {
46
+ return {
47
+ key: item.toLocaleLowerCase(),
48
+ compName: item,
49
+ };
50
+ }).find((item) => item.key === name.toLocaleLowerCase());
51
+ return bigoName === null || bigoName === void 0 ? void 0 : bigoName.compName;
52
+ }
53
+ exports.isComplexComponent = isComplexComponent;
54
+ function isGsdH5ReactComponent(name = '') {
55
+ const bigoName = config_1.GSD_H5_REACT_COMPONENT_KEYS.map((item) => {
56
+ return {
57
+ key: item.toLocaleLowerCase(),
58
+ compName: item,
59
+ };
60
+ }).find((item) => item.key === name.toLocaleLowerCase());
61
+ return bigoName === null || bigoName === void 0 ? void 0 : bigoName.compName;
62
+ }
63
+ exports.isGsdH5ReactComponent = isGsdH5ReactComponent;
64
+ function addDefaultSlot(slotKey = [], comp) {
65
+ comp.properties = comp.properties || {};
66
+ slotKey.map((key) => {
67
+ comp.properties[key] = comp.properties[key] || {
68
+ properties: {},
69
+ };
70
+ });
71
+ }
72
+ exports.addDefaultSlot = addDefaultSlot;
73
+ function addDefaultData(defaultData, comp) {
74
+ // @ts-ignore
75
+ comp.xProps = comp.xProps || {};
76
+ comp.xProps.data = comp.xProps.data || {};
77
+ comp.xProps.data = (0, merge_1.default)(defaultData, comp.xProps.data);
78
+ }
79
+ exports.addDefaultData = addDefaultData;
80
+ function isComplexJSON(json) {
81
+ // FIX: pure render 组件无法通过该方法判断
82
+ // 在 v2 导出时会有 isComposite 的标识字段可识别
83
+ return json.isComposite || Object.keys((json === null || json === void 0 ? void 0 : json.dataForm) || {}).length > 0;
84
+ }
85
+ exports.isComplexJSON = isComplexJSON;
86
+ function getComponentChildren(component) {
87
+ if (!component) {
88
+ return [];
89
+ }
90
+ const { properties } = component;
91
+ if (!properties) {
92
+ return [];
93
+ }
94
+ return Object.entries(properties).sort((a, b) => (a['x-index'] || 0) - (b['x-index'] || 0));
95
+ }
96
+ exports.getComponentChildren = getComponentChildren;
97
+ function isWeAppId(key = '') {
98
+ return key.match(/^id\d+$/);
99
+ }
100
+ exports.isWeAppId = isWeAppId;
101
+ function isEmptyObject(obj = {}) {
102
+ return Object.keys(obj).length === 0;
103
+ }
104
+ exports.isEmptyObject = isEmptyObject;
105
+ function isPlainObject(src) {
106
+ return Object.prototype.toString.call(src) === '[object Object]';
107
+ }
108
+ exports.isPlainObject = isPlainObject;
109
+ function checkIsNeedAddFormWrapper(tree) {
110
+ let isNeedAddFormWrapper = false;
111
+ findComponentInTree(tree, (comp) => {
112
+ const { xComponent } = comp;
113
+ if (xComponent && xComponent.name) {
114
+ const lowerCaseName = xComponent.name.toLocaleLowerCase();
115
+ // 存在 Form 组件时,不需要加最外层 Form
116
+ if (lowerCaseName === 'form') {
117
+ isNeedAddFormWrapper = false;
118
+ return true;
119
+ }
120
+ // 当存在 Input 类型组件,而没有 Form 组件时,需要加最外层 Form
121
+ isNeedAddFormWrapper = config_1.FORM_COMPONENT_KEYS.some((key) => key.toLocaleLowerCase() === lowerCaseName);
122
+ return isNeedAddFormWrapper;
123
+ }
124
+ });
125
+ return isNeedAddFormWrapper;
126
+ }
127
+ exports.checkIsNeedAddFormWrapper = checkIsNeedAddFormWrapper;
128
+ function findComponentInTree(tree, cb, path = '') {
129
+ // tree.path = path
130
+ const stop = cb(tree, path);
131
+ if (stop) {
132
+ return tree;
133
+ }
134
+ const { properties } = tree;
135
+ if (!properties) {
136
+ return;
137
+ }
138
+ // eslint-disable-next-line guard-for-in
139
+ for (const id in properties) {
140
+ const node = properties[id];
141
+ const compPath = path ? `${path}.${id}` : id;
142
+ const found = findComponentInTree(node, cb, compPath);
143
+ if (found) {
144
+ return found;
145
+ }
146
+ }
147
+ }
148
+ exports.findComponentInTree = findComponentInTree;
@@ -0,0 +1,116 @@
1
+ import { IPlatformApp, IDependencies } from '../../types';
2
+ export declare class Dependencies {
3
+ #private;
4
+ constructor({ request, cals, compositeGroupId, compositeComponentId, }: {
5
+ cals: {
6
+ id: Required<IPlatformApp>['id'];
7
+ dependencies: IPlatformApp['dependencies'];
8
+ };
9
+ compositeGroupId?: string;
10
+ compositeComponentId?: string;
11
+ request?: {
12
+ capiRequest?: any;
13
+ lowcodeRequest?: any;
14
+ };
15
+ }, options?: {});
16
+ static diffDependencies(source: any, target: any, whiteList?: string[]): {
17
+ diff: {};
18
+ rollbackDiff: {};
19
+ };
20
+ static normalizeDependencies(dependencies: IDependencies): IDependencies;
21
+ static loadProdMaterial({ name: materialName, title, controlJsPath, controlCssPath, components: materialComponents, isComposite, justRelyOn, }: {
22
+ name: string;
23
+ title: string;
24
+ controlJsPath: string;
25
+ controlCssPath: string;
26
+ components: any[];
27
+ isComposite?: boolean;
28
+ justRelyOn?: boolean;
29
+ }, options?: {
30
+ compositeComponentId: string;
31
+ }): Promise<{
32
+ lcds: any;
33
+ components: any;
34
+ plugins: any;
35
+ actions: any;
36
+ title: any;
37
+ name: any;
38
+ } | {
39
+ components: any[];
40
+ plugins: any[];
41
+ actions: any[];
42
+ name: string;
43
+ title: string;
44
+ } | {
45
+ materialName: string;
46
+ title: string;
47
+ error: any;
48
+ components: any[];
49
+ }>;
50
+ /**
51
+ * 处理 component schema
52
+ * 用于补充设计态相关字段
53
+ */
54
+ processCompnent(component: any): any;
55
+ useLatestDependiencies(latestCompositeGroupList: ICompositeGroupData[]): any;
56
+ onCalsDependenciesChange(dependencies: IDependencies): any;
57
+ /**
58
+ * 核心逻辑。获取组件物料,主要做了以下事情:
59
+ * 1、加载组件库最新列表
60
+ * 2、用户组件库立刻加载
61
+ * 2、官方组件库不加载
62
+ */
63
+ init(): Promise<{
64
+ lcds: any;
65
+ compLibs: any;
66
+ actions: any;
67
+ components: any;
68
+ plugins: any;
69
+ componentMethodList: Record<string, any>;
70
+ dependencies: any;
71
+ }>;
72
+ DescribeLatestCompositeGroupList({ WeAppId }: {
73
+ WeAppId: any;
74
+ }): Promise<{
75
+ Data: {
76
+ List: ICompositeGroupData[];
77
+ };
78
+ }>;
79
+ get schema(): any[];
80
+ _DescribeCompositeGroupList(data: {
81
+ WeAppId?: string;
82
+ GroupList?: {
83
+ Id: string;
84
+ GroupVersion: string;
85
+ }[];
86
+ }, opts?: any): Promise<{
87
+ Data: {
88
+ List?: ICompositeGroupData[];
89
+ };
90
+ }>;
91
+ _DescribeShareCompGroups(data: {
92
+ WeAppId?: string;
93
+ }): Promise<{
94
+ Data: {
95
+ List?: ICompositeGroupData[];
96
+ };
97
+ }>;
98
+ _DescribeCompositeContent(data: any): Promise<void>;
99
+ }
100
+ interface ICompositeGroupData {
101
+ Id: string;
102
+ GroupName: string;
103
+ Title?: string;
104
+ Describe?: string;
105
+ Version?: string;
106
+ Content: string;
107
+ PrivateCosPrefix: string;
108
+ PublicCosPrefix: string;
109
+ TinyPrimeVersion: string;
110
+ CreatedAt: string;
111
+ ModifyTime: string;
112
+ UpdatedAt: string;
113
+ IsShare?: boolean;
114
+ }
115
+ export {};
116
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parser/dependiencies/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAY1D,qBAAa,YAAY;;gBAerB,EACE,OAAY,EACZ,IAAI,EACJ,gBAAgB,EAChB,oBAAoB,GACrB,EAAE;QAC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