@cloudbase/cals 1.0.81 → 1.1.0-beta.1
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/lib/parser/cals/utils/getUsedResources.d.ts.map +1 -1
- package/lib/parser/cals/utils/getUsedResources.js +19 -9
- package/lib/schema/basic_application.json +1 -0
- package/lib/schema/lcds_action.json +1 -0
- package/lib/schema/lcds_component.json +1 -0
- package/lib/schema/platform_application.json +1 -0
- package/lib/schema/platform_data_source.json +1 -0
- package/lib/schema/platform_template.json +1 -0
- package/lib/types/basic/app.d.ts +11 -8
- package/lib/types/basic/app.d.ts.map +1 -1
- package/lib/types/basic/common.d.ts +14 -4
- package/lib/types/basic/common.d.ts.map +1 -1
- package/lib/types/basic/component.d.ts +20 -19
- package/lib/types/basic/component.d.ts.map +1 -1
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/lcds.d.ts +113 -39
- package/lib/types/lcds.d.ts.map +1 -1
- package/lib/types/platform/app.d.ts +36 -31
- package/lib/types/platform/app.d.ts.map +1 -1
- package/lib/types/platform/common.d.ts +16 -7
- package/lib/types/platform/common.d.ts.map +1 -1
- package/lib/types/platform/common.js +1 -1
- package/lib/types/platform/component.d.ts +21 -19
- package/lib/types/platform/component.d.ts.map +1 -1
- package/lib/types/platform/datasource.d.ts +56 -37
- package/lib/types/platform/datasource.d.ts.map +1 -1
- package/lib/types/platform/eventFlow.d.ts +2 -2
- package/lib/types/platform/eventFlow.d.ts.map +1 -1
- package/lib/types/platform/query.d.ts +2 -2
- package/lib/types/platform/query.d.ts.map +1 -1
- package/lib/types/platform/theme.d.ts +3 -1
- package/lib/types/platform/theme.d.ts.map +1 -1
- package/package.json +8 -7
- package/lib/types/platform/widget/form.d.ts +0 -5
- package/lib/types/platform/widget/form.d.ts.map +0 -1
- package/lib/types/platform/widget/form.js +0 -5
- package/lib/types/platform/widget/meta.d.ts +0 -60
- package/lib/types/platform/widget/meta.d.ts.map +0 -1
- package/lib/types/platform/widget/meta.js +0 -6
- package/lib/utils/build.d.ts +0 -2
- package/lib/utils/build.d.ts.map +0 -1
- package/lib/utils/build.js +0 -75
- package/lib/utils/version-migrations/common.d.ts +0 -5
- package/lib/utils/version-migrations/common.d.ts.map +0 -1
- package/lib/utils/version-migrations/common.js +0 -29
- package/lib/utils/version-migrations/version4.d.ts +0 -3
- package/lib/utils/version-migrations/version4.d.ts.map +0 -1
- package/lib/utils/version-migrations/version4.js +0 -199
|
@@ -33,7 +33,9 @@ export interface ITheme {
|
|
|
33
33
|
*/
|
|
34
34
|
export declare type IThemePlatform = '_' | `${EPlatform.PCWEB}` | `${EPlatform.MOBILE}`;
|
|
35
35
|
/** 主题 CSS 变量信息 */
|
|
36
|
-
export declare type IThemeCssVars =
|
|
36
|
+
export declare type IThemeCssVars = {
|
|
37
|
+
[key: string]: IThemeCssVarValue;
|
|
38
|
+
};
|
|
37
39
|
/**
|
|
38
40
|
* 主题支持的 CSS 变量名称
|
|
39
41
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/types/platform/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,WAAW;AACX,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,IAAI,EAAE;QACJ,kBAAkB;QAClB,QAAQ,EAAE;YACR,cAAc;YACd,EAAE,EAAE,MAAM,CAAC;YAEX,kBAAkB;YAClB,IAAI,CAAC,EAAE,MAAM,CAAC;YAEd,cAAc;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QAEF,kBAAkB;QAClB,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QAEzC,oBAAoB;QACpB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IAEF;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;CAC9D;AAED;;;;GAIG;AACH,oBAAY,cAAc,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;AAEhF,kBAAkB;
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/types/platform/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,WAAW;AACX,MAAM,WAAW,MAAM;IACrB;;OAEG;IACH,IAAI,EAAE;QACJ,kBAAkB;QAClB,QAAQ,EAAE;YACR,cAAc;YACd,EAAE,EAAE,MAAM,CAAC;YAEX,kBAAkB;YAClB,IAAI,CAAC,EAAE,MAAM,CAAC;YAEd,cAAc;YACd,OAAO,CAAC,EAAE,MAAM,CAAC;SAClB,CAAC;QAEF,kBAAkB;QAClB,WAAW,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;QAEzC,oBAAoB;QACpB,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IAEF;;;;OAIG;IACH,YAAY,EAAE,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,aAAa,CAAC,CAAC,CAAC;CAC9D;AAED;;;;GAIG;AACH,oBAAY,cAAc,GAAG,GAAG,GAAG,GAAG,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC;AAEhF,kBAAkB;AAElB,oBAAY,aAAa,GAAG;IAG1B,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAAC;CAClC,CAAC;AAKF;;GAEG;AACH,oBAAY,gBAAgB,GAAG,QAAQ,MAAM,EAAE,CAAC;AAEhD;;GAEG;AACH,oBAAY,iBAAiB,GAAG,MAAM,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cloudbase/cals",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.1.0-beta.1",
|
|
4
4
|
"description": "Common application specifications",
|
|
5
5
|
"main": "lib/utils/index.js",
|
|
6
6
|
"source": "src/utils/index.ts",
|
|
@@ -12,8 +12,9 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
|
-
"build": "rm -rf tsconfig.tsbuildinfo && tsc",
|
|
16
|
-
"build:schema": "ts-node
|
|
15
|
+
"build": "rm -rf lib tsconfig.tsbuildinfo && tsc && npm run build:schema && npm run copy:schema",
|
|
16
|
+
"build:schema": "ts-node scripts/build-schema.ts",
|
|
17
|
+
"copy:schema": "node scripts/copy-schema.mjs",
|
|
17
18
|
"build:dts": "ts-node src/utils/dts/build.ts",
|
|
18
19
|
"build:dts:watch": "ts-node src/utils/dts/build.ts --watch",
|
|
19
20
|
"develop": "tsc --watch",
|
|
@@ -44,14 +45,14 @@
|
|
|
44
45
|
"tinycolor2": "^1.6.0"
|
|
45
46
|
},
|
|
46
47
|
"devDependencies": {
|
|
47
|
-
"@tcwd/dev-tools": "
|
|
48
|
+
"@tcwd/dev-tools": "^1.0.1",
|
|
48
49
|
"@types/acorn": "^4.0.5",
|
|
49
50
|
"@types/jest": "^27.4.0",
|
|
50
51
|
"@types/lodash": "^4.14.168",
|
|
51
52
|
"@types/node": "^14.14.6",
|
|
52
53
|
"@types/react": "^18.0.17",
|
|
53
54
|
"@types/web": "^0.0.78",
|
|
54
|
-
"ajv": "^8.
|
|
55
|
+
"ajv": "^8.13.0",
|
|
55
56
|
"jest-fetch-mock": "^3.0.3",
|
|
56
57
|
"jsdom-worker": "^0.3.0",
|
|
57
58
|
"json-schema-to-typescript-for-browser": "^11.0.3",
|
|
@@ -60,6 +61,6 @@
|
|
|
60
61
|
"ts-node": "^10.4.0",
|
|
61
62
|
"tsc-watch": "^6.0.4",
|
|
62
63
|
"typescript": "^4.7.4",
|
|
63
|
-
"typescript-json-schema": "
|
|
64
|
+
"typescript-json-schema": "0.63.0"
|
|
64
65
|
}
|
|
65
|
-
}
|
|
66
|
+
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"form.d.ts","sourceRoot":"","sources":["../../../../src/types/platform/widget/form.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC"}
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 组件元信息描述
|
|
3
|
-
* 描述组件基本信息: 名称、描述、格式、分类、缩略图、属性列表
|
|
4
|
-
*/
|
|
5
|
-
/**
|
|
6
|
-
* 组件元信息描述格式
|
|
7
|
-
*/
|
|
8
|
-
export interface IWidgetMeta {
|
|
9
|
-
/**
|
|
10
|
-
* 组件 name 的命名空间
|
|
11
|
-
* 用于隔离系统组件、供应商组件、用户自定义组件 或者不同的组件库
|
|
12
|
-
* ns 应当是组件上传后, 由低码平台自动添加
|
|
13
|
-
*/
|
|
14
|
-
/** 组件名, 唯一标识 */
|
|
15
|
-
name: string;
|
|
16
|
-
/** 组件中文名 */
|
|
17
|
-
title: string;
|
|
18
|
-
/** 组件描述 */
|
|
19
|
-
description?: string;
|
|
20
|
-
/** 组件自身语义化版本 */
|
|
21
|
-
schemaVersion: string;
|
|
22
|
-
/**
|
|
23
|
-
* 支持的平台
|
|
24
|
-
* h5, mp
|
|
25
|
-
*/
|
|
26
|
-
platform: string;
|
|
27
|
-
/**
|
|
28
|
-
* 组件分类
|
|
29
|
-
* 如 list, card, carousel, form, container, layout 等
|
|
30
|
-
*/
|
|
31
|
-
category: string;
|
|
32
|
-
/**
|
|
33
|
-
* 组件类型
|
|
34
|
-
* 如 text, email, multitext, date, list, color
|
|
35
|
-
*/
|
|
36
|
-
type: string;
|
|
37
|
-
/**
|
|
38
|
-
* 组件实现类型
|
|
39
|
-
* code 基础组件
|
|
40
|
-
* data 组合组件(即使用JSON描述的组件)
|
|
41
|
-
*
|
|
42
|
-
* 默认值为 code
|
|
43
|
-
*/
|
|
44
|
-
compose?: 'code' | 'data';
|
|
45
|
-
/**
|
|
46
|
-
* 组件呈现数据的基础类型, 表单类型的组件需要该字段
|
|
47
|
-
* 如 string, number, boolean, object, array
|
|
48
|
-
*/
|
|
49
|
-
dataType?: string;
|
|
50
|
-
/**
|
|
51
|
-
* 呈现对应的格式, 表单类型的组件需要该字段
|
|
52
|
-
* 如 email, url, markdown 等
|
|
53
|
-
*/
|
|
54
|
-
format?: string;
|
|
55
|
-
/**
|
|
56
|
-
* 组件 attr 配置项
|
|
57
|
-
*/
|
|
58
|
-
configs: any;
|
|
59
|
-
}
|
|
60
|
-
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../../src/types/platform/widget/meta.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;;OAIG;IAGH,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IAEb,YAAY;IACZ,KAAK,EAAE,MAAM,CAAC;IAEd,WAAW;IACX,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB,gBAAgB;IAChB,aAAa,EAAE,MAAM,CAAC;IAEtB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAC;IAEb;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAE1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,OAAO,EAAE,GAAG,CAAC;CACd"}
|
package/lib/utils/build.d.ts
DELETED
package/lib/utils/build.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"build.d.ts","sourceRoot":"","sources":["../../src/utils/build.ts"],"names":[],"mappings":""}
|
package/lib/utils/build.js
DELETED
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const path_1 = require("path");
|
|
30
|
-
const fs_1 = require("fs");
|
|
31
|
-
const TJS = __importStar(require("typescript-json-schema"));
|
|
32
|
-
const merge_1 = __importDefault(require("lodash/merge"));
|
|
33
|
-
// optionally pass argument to schema generator
|
|
34
|
-
const settings = {
|
|
35
|
-
required: true,
|
|
36
|
-
};
|
|
37
|
-
// optionally pass ts compiler options
|
|
38
|
-
const compilerOptions = {
|
|
39
|
-
strictNullChecks: true,
|
|
40
|
-
esModuleInterop: true,
|
|
41
|
-
};
|
|
42
|
-
// optionally pass a base path
|
|
43
|
-
const basePath = '.';
|
|
44
|
-
const calsProgram = TJS.getProgramFromFiles([(0, path_1.resolve)(process.cwd(), 'src/types/basic/app.ts')], compilerOptions, basePath);
|
|
45
|
-
const platformCalsProgram = TJS.getProgramFromFiles([(0, path_1.resolve)(process.cwd(), 'src/types/platform/app.ts')], compilerOptions, basePath);
|
|
46
|
-
const lcdsProgram = TJS.getProgramFromFiles([(0, path_1.resolve)(process.cwd(), 'src/types/lcds.ts')], compilerOptions, basePath);
|
|
47
|
-
// ... or a generator that lets us incrementally get more schemas
|
|
48
|
-
const calsGenerator = TJS.buildGenerator(calsProgram, settings);
|
|
49
|
-
const platformCalsGenerator = TJS.buildGenerator(platformCalsProgram, settings);
|
|
50
|
-
const lcdsGenerator = TJS.buildGenerator(lcdsProgram, settings);
|
|
51
|
-
const basicApp = calsGenerator === null || calsGenerator === void 0 ? void 0 : calsGenerator.getSchemaForSymbol('IApp');
|
|
52
|
-
const platformApp = platformCalsGenerator === null || platformCalsGenerator === void 0 ? void 0 : platformCalsGenerator.getSchemaForSymbol('IPlatformApp');
|
|
53
|
-
const lcdsComponent = lcdsGenerator === null || lcdsGenerator === void 0 ? void 0 : lcdsGenerator.getSchemaForSymbol('LCDS.IComponent');
|
|
54
|
-
const lcdsAction = lcdsGenerator === null || lcdsGenerator === void 0 ? void 0 : lcdsGenerator.getSchemaForSymbol('LCDS.IAction');
|
|
55
|
-
// rewrite lcds
|
|
56
|
-
const resolveLcdsComponent = (0, merge_1.default)({}, lcdsComponent, {
|
|
57
|
-
properties: {
|
|
58
|
-
data: {
|
|
59
|
-
$schema: 'https://comp-public-replace-1303824488-cos.weda.tencent.com/schema/schema#',
|
|
60
|
-
$ref: 'https://comp-public-replace-1303824488-cos.weda.tencent.com/schema/schema#',
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
const resolveLcdsAction = (0, merge_1.default)({}, lcdsAction, {
|
|
65
|
-
properties: {
|
|
66
|
-
data: {
|
|
67
|
-
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
68
|
-
$ref: 'http://json-schema.org/draft-07/schema#',
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(process.cwd(), 'schema/basic_application.json'), JSON.stringify(basicApp, null, 2));
|
|
73
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(process.cwd(), 'schema/platform_application.json'), JSON.stringify(platformApp, null, 2));
|
|
74
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(process.cwd(), 'schema/lcds_component.json'), JSON.stringify(resolveLcdsComponent, null, 2));
|
|
75
|
-
(0, fs_1.writeFileSync)((0, path_1.resolve)(process.cwd(), 'schema/lcds_action.json'), JSON.stringify(resolveLcdsAction, null, 2));
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export declare function semverComp(a: string, b: string): number;
|
|
2
|
-
export declare function toFixed(num: number, precision: number): number;
|
|
3
|
-
export declare const OFFICIAL_COMPONENT_LIB_NAME = "CLOUDBASE_STANDARD";
|
|
4
|
-
export declare const OFFICIAL_MATERIAL_LIB_NAME = "gsd-h5-react";
|
|
5
|
-
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/utils/version-migrations/common.ts"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAYvD;AAED,wBAAgB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAI9D;AAED,eAAO,MAAM,2BAA2B,uBAAuB,CAAC;AAChE,eAAO,MAAM,0BAA0B,iBAAiB,CAAC"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OFFICIAL_MATERIAL_LIB_NAME = exports.OFFICIAL_COMPONENT_LIB_NAME = exports.toFixed = exports.semverComp = void 0;
|
|
4
|
-
function semverComp(a, b) {
|
|
5
|
-
const pa = a.split('.');
|
|
6
|
-
const pb = b.split('.');
|
|
7
|
-
for (let i = 0; i < 3; i++) {
|
|
8
|
-
const na = Number(pa[i]);
|
|
9
|
-
const nb = Number(pb[i]);
|
|
10
|
-
if (na > nb)
|
|
11
|
-
return 1;
|
|
12
|
-
if (nb > na)
|
|
13
|
-
return -1;
|
|
14
|
-
if (!isNaN(na) && isNaN(nb))
|
|
15
|
-
return 1;
|
|
16
|
-
if (isNaN(na) && !isNaN(nb))
|
|
17
|
-
return -1;
|
|
18
|
-
}
|
|
19
|
-
return 0;
|
|
20
|
-
}
|
|
21
|
-
exports.semverComp = semverComp;
|
|
22
|
-
function toFixed(num, precision) {
|
|
23
|
-
const multiplier = Math.pow(10, (precision + 1));
|
|
24
|
-
const wholeNumber = Math.floor(num * multiplier);
|
|
25
|
-
return (Math.round(wholeNumber / 10) * 10) / multiplier;
|
|
26
|
-
}
|
|
27
|
-
exports.toFixed = toFixed;
|
|
28
|
-
exports.OFFICIAL_COMPONENT_LIB_NAME = 'CLOUDBASE_STANDARD';
|
|
29
|
-
exports.OFFICIAL_MATERIAL_LIB_NAME = 'gsd-h5-react';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version4.d.ts","sourceRoot":"","sources":["../../../src/utils/version-migrations/version4.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAkB,MAAM,aAAa,CAAC;AAGhE,wBAAgB,QAAQ,CACtB,IAAI,EAAE,YAAY,EAClB,SAAS,EAAE,OAAO,EAClB,wBAAwB,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,SAAS,KAAK,IAAI,GAC/D,YAAY,CAEd"}
|
|
@@ -1,199 +0,0 @@
|
|
|
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.version4 = void 0;
|
|
7
|
-
const postcss_1 = __importDefault(require("postcss"));
|
|
8
|
-
const postcss_less_1 = __importDefault(require("postcss-less"));
|
|
9
|
-
const __1 = require("..");
|
|
10
|
-
const common_1 = require("./common");
|
|
11
|
-
function version4(cals, isUpgrade, setSchemaVersionCallback) {
|
|
12
|
-
return transformPxLowcodeCompAndSourceComp(cals, isUpgrade, setSchemaVersionCallback);
|
|
13
|
-
}
|
|
14
|
-
exports.version4 = version4;
|
|
15
|
-
const transformPxLowcodeCompAndSourceComp = (cals, isUpgrade, setSchemaVersionCallback) => {
|
|
16
|
-
var _a, _b, _c, _d;
|
|
17
|
-
{
|
|
18
|
-
function transformCals(items, isUpgradeToPx) {
|
|
19
|
-
return items.map((item) => {
|
|
20
|
-
var _a;
|
|
21
|
-
// 对于表单操作区的按钮组件的父容器添加.wd-form__action, 兼容组件规范化按钮升级样式
|
|
22
|
-
if ((item === null || item === void 0 ? void 0 : item.module) === common_1.OFFICIAL_COMPONENT_LIB_NAME && (item === null || item === void 0 ? void 0 : item.component) === 'Form') {
|
|
23
|
-
item = addClassToButtonContainer(item);
|
|
24
|
-
}
|
|
25
|
-
if ((_a = item === null || item === void 0 ? void 0 : item.extra) === null || _a === void 0 ? void 0 : _a.commonStyle) {
|
|
26
|
-
item.extra.commonStyle = convertCommonStyle(item.extra.commonStyle, isUpgradeToPx);
|
|
27
|
-
if (item.extra.commonStyle.self) {
|
|
28
|
-
// 处理 margin padding shorthand 同步
|
|
29
|
-
const newSelf = (0, __1.processCommonStyle2CSSProperties)(item.extra.commonStyle, {
|
|
30
|
-
toRem: false,
|
|
31
|
-
ignoreSelf: true,
|
|
32
|
-
addPXUnit: true,
|
|
33
|
-
});
|
|
34
|
-
['margin', 'padding', 'border'].forEach((k) => {
|
|
35
|
-
if (item.extra.commonStyle.self[k]) {
|
|
36
|
-
item.extra.commonStyle.self[k] = newSelf[k];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
if (item === null || item === void 0 ? void 0 : item.resources) {
|
|
42
|
-
item.resources = item.resources.map((n) => {
|
|
43
|
-
if (n.codeType === 'style') {
|
|
44
|
-
n = convertLowCodesStyle(n, isUpgradeToPx);
|
|
45
|
-
return n;
|
|
46
|
-
}
|
|
47
|
-
return n;
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (item.items) {
|
|
51
|
-
item.items = transformCals(item.items, isUpgradeToPx);
|
|
52
|
-
}
|
|
53
|
-
return item;
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
let pages = cals['items'];
|
|
57
|
-
let isDivision;
|
|
58
|
-
if (isUpgrade && (0, common_1.semverComp)((_a = cals['schemaVersion']) !== null && _a !== void 0 ? _a : '3.0.0', '4.0.0') < 0) {
|
|
59
|
-
// 组件库版本高于目标版本,且schemaVersion小于4, 将应用 CALS 数据中的 CSS 和 style 中的无单位和有单位的小写 px统一改写为 1/2 px
|
|
60
|
-
isDivision = true;
|
|
61
|
-
pages = transformCals(pages, isDivision);
|
|
62
|
-
cals.resources = (_b = cals.resources) === null || _b === void 0 ? void 0 : _b.map((n) => {
|
|
63
|
-
if (n.codeType === 'style') {
|
|
64
|
-
n = convertLowCodesStyle(n, isDivision);
|
|
65
|
-
return n;
|
|
66
|
-
}
|
|
67
|
-
return n;
|
|
68
|
-
});
|
|
69
|
-
cals['schemaVersion'] = '4.0.0';
|
|
70
|
-
setSchemaVersionCallback === null || setSchemaVersionCallback === void 0 ? void 0 : setSchemaVersionCallback('4.0.0');
|
|
71
|
-
}
|
|
72
|
-
else if (!isUpgrade && (0, common_1.semverComp)((_c = cals['schemaVersion']) !== null && _c !== void 0 ? _c : '3.0.0', '4.0.0') >= 0) {
|
|
73
|
-
// 组件库低于目标版本,并且schemaVersion大于4 将应用 CALS 数据中的 CSS 和 style 中的无单位和有单位的小写 px统一改写为 2倍 px
|
|
74
|
-
isDivision = false;
|
|
75
|
-
pages = transformCals(pages, isDivision);
|
|
76
|
-
cals.resources = (_d = cals.resources) === null || _d === void 0 ? void 0 : _d.map((n) => {
|
|
77
|
-
if (n.codeType === 'style') {
|
|
78
|
-
n = convertLowCodesStyle(n, isDivision);
|
|
79
|
-
return n;
|
|
80
|
-
}
|
|
81
|
-
return n;
|
|
82
|
-
});
|
|
83
|
-
delete cals['schemaVersion'];
|
|
84
|
-
setSchemaVersionCallback === null || setSchemaVersionCallback === void 0 ? void 0 : setSchemaVersionCallback(undefined);
|
|
85
|
-
}
|
|
86
|
-
cals['items'] = pages;
|
|
87
|
-
return cals;
|
|
88
|
-
}
|
|
89
|
-
};
|
|
90
|
-
function hasSubmitButton(item) {
|
|
91
|
-
var _a;
|
|
92
|
-
if ((_a = item === null || item === void 0 ? void 0 : item.items) === null || _a === void 0 ? void 0 : _a.length) {
|
|
93
|
-
const children = item.items;
|
|
94
|
-
return children.some((i) => { var _a; return (i === null || i === void 0 ? void 0 : i.module) === common_1.OFFICIAL_COMPONENT_LIB_NAME && i.component === 'Button' && ((_a = i === null || i === void 0 ? void 0 : i.attributes) === null || _a === void 0 ? void 0 : _a.formType) === 'submit'; });
|
|
95
|
-
}
|
|
96
|
-
return false;
|
|
97
|
-
}
|
|
98
|
-
function addClassToButtonContainer(item) {
|
|
99
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
|
100
|
-
if ((item === null || item === void 0 ? void 0 : item.module) === common_1.OFFICIAL_MATERIAL_LIB_NAME && item.component === 'Container') {
|
|
101
|
-
if (hasSubmitButton(item)) {
|
|
102
|
-
if (((_a = item.attributes) === null || _a === void 0 ? void 0 : _a.class) && !((_b = item.attributes) === null || _b === void 0 ? void 0 : _b.class.includes('wd-form__action'))) {
|
|
103
|
-
if (typeof ((_c = item.attributes) === null || _c === void 0 ? void 0 : _c.class) === 'string') {
|
|
104
|
-
item.attributes = Object.assign(Object.assign({}, item.attributes), { class: `${(_d = item.attributes) === null || _d === void 0 ? void 0 : _d.class} wd-form__action` });
|
|
105
|
-
}
|
|
106
|
-
else if (Array.isArray((_e = item.attributes) === null || _e === void 0 ? void 0 : _e.class)) {
|
|
107
|
-
item.attributes = Object.assign(Object.assign({}, item.attributes), { class: [...(_f = item.attributes) === null || _f === void 0 ? void 0 : _f.class, 'wd-form__action'] });
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
else if (!((_g = item.attributes) === null || _g === void 0 ? void 0 : _g.class)) {
|
|
111
|
-
item.attributes = Object.assign(Object.assign({}, item.attributes), { class: 'wd-form__action' });
|
|
112
|
-
}
|
|
113
|
-
// 移除旧的padding配置
|
|
114
|
-
if ((_j = (_h = item === null || item === void 0 ? void 0 : item.extra) === null || _h === void 0 ? void 0 : _h.commonStyle) === null || _j === void 0 ? void 0 : _j.padding) {
|
|
115
|
-
delete item.extra.commonStyle.padding;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
if ((_k = item === null || item === void 0 ? void 0 : item.items) === null || _k === void 0 ? void 0 : _k.length) {
|
|
120
|
-
item.items = item.items.map((i) => addClassToButtonContainer(i));
|
|
121
|
-
}
|
|
122
|
-
return item;
|
|
123
|
-
}
|
|
124
|
-
function jsonTranverse(json, reviver) {
|
|
125
|
-
return JSON.parse(JSON.stringify(json, reviver, 2));
|
|
126
|
-
}
|
|
127
|
-
function convertCommonStyle(value, isUpgrade) {
|
|
128
|
-
return jsonTranverse(value, (key, value) => {
|
|
129
|
-
if (__1.isUnitlessNumber[key]) {
|
|
130
|
-
return value;
|
|
131
|
-
}
|
|
132
|
-
if (typeof value === 'number') {
|
|
133
|
-
if (isUpgrade) {
|
|
134
|
-
value = value / 2;
|
|
135
|
-
}
|
|
136
|
-
else {
|
|
137
|
-
value = value * 2;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
else if (/^((\d+\.)?\d+)(px)?$/.test(value)) {
|
|
141
|
-
value = !value ? value : value === null || value === void 0 ? void 0 : value.replace('px', '');
|
|
142
|
-
if (isUpgrade) {
|
|
143
|
-
// console.log(key, value, Number(value) / 2);
|
|
144
|
-
value = !value ? value : `${(0, common_1.toFixed)(Number(value) / 2, 3)}px`;
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
value = !value ? value : `${Number(value) * 2}px`;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
return value;
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
const rem2PxPlugin = (opts) => {
|
|
154
|
-
const rem2pxSym = Symbol('rem2pxSym');
|
|
155
|
-
const { isUpgrade } = opts;
|
|
156
|
-
return {
|
|
157
|
-
postcssPlugin: 'postcss-rem2px',
|
|
158
|
-
Declaration(decl, rule) {
|
|
159
|
-
// Modified From https://github.com/cuth/postcss-pxtorem/blob/122649015322214f8e9d1ac852eb11c0791b634b/lib/pixel-unit-regex.js#L9
|
|
160
|
-
// eslint-disable-next-line no-useless-escape
|
|
161
|
-
const pxRegex = /"[^"]+"|'[^']+'|(\d*\.?\d+)px/gm;
|
|
162
|
-
if (decl.value.indexOf('px') < 0) {
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (decl[rem2pxSym]) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
if (isUpgrade) {
|
|
169
|
-
const value = decl.value.replace(pxRegex, (match, p1) => {
|
|
170
|
-
if (p1 !== null && p1 !== undefined) {
|
|
171
|
-
const r = (0, common_1.toFixed)(Number(p1) / 2, 3);
|
|
172
|
-
const rs = r.toString();
|
|
173
|
-
return `${rs}px`;
|
|
174
|
-
}
|
|
175
|
-
return match;
|
|
176
|
-
});
|
|
177
|
-
decl.value = value;
|
|
178
|
-
}
|
|
179
|
-
else {
|
|
180
|
-
const value = decl.value.replace(pxRegex, (match, p1) => {
|
|
181
|
-
if (p1 !== null && p1 !== undefined) {
|
|
182
|
-
return `${Number(p1) * 2}px`;
|
|
183
|
-
}
|
|
184
|
-
return match;
|
|
185
|
-
});
|
|
186
|
-
decl.value = value;
|
|
187
|
-
}
|
|
188
|
-
decl[rem2pxSym] = true;
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
};
|
|
192
|
-
rem2PxPlugin.postcss = true;
|
|
193
|
-
function convertLowCodesStyle(value, isUpgrade) {
|
|
194
|
-
const result = (0, postcss_1.default)([rem2PxPlugin({ isUpgrade })]).process(value.code, {
|
|
195
|
-
syntax: postcss_less_1.default,
|
|
196
|
-
});
|
|
197
|
-
value.code = result.css;
|
|
198
|
-
return value;
|
|
199
|
-
}
|