@cloudbase/cals 1.0.49 → 1.0.50
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/template.js +3 -3
- package/package.json +3 -3
- package/lib/parser/cals/utils/block/index.js +0 -151
- package/lib/parser/cals/utils/code/index.js +0 -393
- package/lib/parser/cals/utils/common.js +0 -268
- package/lib/parser/cals/utils/getUsedResources.d.ts +0 -10
- package/lib/parser/cals/utils/getUsedResources.d.ts.map +0 -1
- package/lib/parser/cals/utils/getUsedResources.js +0 -128
- package/lib/parser/cals/utils/runtime.js +0 -268
- package/lib/parser/cals/utils/style.js +0 -472
- package/lib/parser/cals/utils/version/common.js +0 -385
- package/lib/parser/cals/utils/version/config.d.ts +0 -16
- package/lib/parser/cals/utils/version/config.d.ts.map +0 -1
- package/lib/parser/cals/utils/version/config.js +0 -244
- package/lib/parser/cals/utils/version/index.js +0 -96
- package/lib/parser/cals/utils/version/parses.js +0 -581
- package/lib/parser/cals/utils/version/utils.d.ts +0 -14
- package/lib/parser/cals/utils/version/utils.d.ts.map +0 -1
- package/lib/parser/cals/utils/version/utils.js +0 -148
- package/lib/parser/expression/index.d.ts +0 -123
- package/lib/parser/expression/index.d.ts.map +0 -1
- package/lib/parser/expression/index.js +0 -301
- package/lib/parser/plugins/postcss-rpx2clac.d.ts +0 -18
- package/lib/parser/plugins/postcss-rpx2clac.d.ts.map +0 -1
- package/lib/parser/plugins/postcss-rpx2clac.js +0 -68
- package/lib/types/basic/app.d.ts +0 -73
- package/lib/types/basic/app.d.ts.map +0 -1
- package/lib/types/basic/app.js +0 -2
- package/lib/types/basic/common.d.ts +0 -93
- package/lib/types/basic/common.d.ts.map +0 -1
- package/lib/types/basic/common.js +0 -2
- package/lib/types/basic/component.d.ts +0 -211
- package/lib/types/basic/component.d.ts.map +0 -1
- package/lib/types/basic/component.js +0 -2
- package/lib/types/basic/datasource.d.ts +0 -50
- package/lib/types/basic/datasource.d.ts.map +0 -1
- package/lib/types/basic/datasource.js +0 -2
- package/lib/types/index.js +0 -42
- package/lib/types/lcds.js +0 -25
- package/lib/types/platform/app.js +0 -11
- package/lib/types/platform/common.d.ts +0 -181
- package/lib/types/platform/common.d.ts.map +0 -1
- package/lib/types/platform/common.js +0 -87
- package/lib/types/platform/component.d.ts +0 -139
- package/lib/types/platform/component.d.ts.map +0 -1
- package/lib/types/platform/component.js +0 -11
- package/lib/types/platform/datasource.d.ts +0 -467
- package/lib/types/platform/datasource.d.ts.map +0 -1
- package/lib/types/platform/datasource.js +0 -2
- package/lib/types/platform/eventFlow.d.ts +0 -20
- package/lib/types/platform/eventFlow.d.ts.map +0 -1
- package/lib/types/platform/eventFlow.js +0 -2
- package/lib/types/platform/query.d.ts +0 -67
- package/lib/types/platform/query.d.ts.map +0 -1
- package/lib/types/platform/query.js +0 -2
- package/lib/types/platform/theme.js +0 -2
- 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/CSSProperty.d.ts +0 -64
- package/lib/utils/CSSProperty.d.ts.map +0 -1
- package/lib/utils/CSSProperty.js +0 -89
- 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/dts/auto-generated.d.ts +0 -2
- package/lib/utils/dts/auto-generated.d.ts.map +0 -1
- package/lib/utils/dts/auto-generated.js +0 -1796
- package/lib/utils/dts/build.d.ts +0 -2
- package/lib/utils/dts/build.d.ts.map +0 -1
- package/lib/utils/dts/build.js +0 -136
- package/lib/utils/dts/index.js +0 -1008
- package/lib/utils/index.js +0 -27
- package/lib/utils/version/common.d.ts +0 -3
- package/lib/utils/version/common.d.ts.map +0 -1
- package/lib/utils/version/common.js +0 -27
- package/lib/utils/version/featureChecker.js +0 -35
- package/lib/utils/version/migrations/version4.js +0 -199
- 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
|
@@ -1,148 +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.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;
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
import { Node, Options } from 'acorn';
|
|
2
|
-
export declare const PARSE_CONFIG: Options;
|
|
3
|
-
export declare const AST_TYPE: {
|
|
4
|
-
Literal: string;
|
|
5
|
-
ExpressionStatement: string;
|
|
6
|
-
LogicalExpression: string;
|
|
7
|
-
BinaryExpression: string;
|
|
8
|
-
UnaryExpression: string;
|
|
9
|
-
MemberExpression: string;
|
|
10
|
-
Identifier: string;
|
|
11
|
-
ArrayExpression: string;
|
|
12
|
-
CallExpression: string;
|
|
13
|
-
TemplateLiteral: string;
|
|
14
|
-
TemplateElement: string;
|
|
15
|
-
ConditionalExpression: string;
|
|
16
|
-
SequenceExpression: string;
|
|
17
|
-
};
|
|
18
|
-
export declare enum PropBindType {
|
|
19
|
-
static = "static",
|
|
20
|
-
state = "rematch",
|
|
21
|
-
computed = "computed",
|
|
22
|
-
forItem = "for-item",
|
|
23
|
-
expression = "expression",
|
|
24
|
-
prop = "prop",
|
|
25
|
-
slot = "slot",
|
|
26
|
-
dataVar = "dataVar",
|
|
27
|
-
stateData = "state",
|
|
28
|
-
/**
|
|
29
|
-
* @deprecated
|
|
30
|
-
*/
|
|
31
|
-
paramData = "params",
|
|
32
|
-
params = "params",
|
|
33
|
-
scope = "scope"
|
|
34
|
-
}
|
|
35
|
-
export declare enum ActionType {
|
|
36
|
-
Rematch = "rematch",
|
|
37
|
-
Material = "material",
|
|
38
|
-
GeneralFunc = "general-func",
|
|
39
|
-
LifeCycle = "lifecycle",
|
|
40
|
-
PropEvent = "prop-event",
|
|
41
|
-
HandlerFn = "handler-fn",
|
|
42
|
-
Inline = "inline",
|
|
43
|
-
Platform = "platform",
|
|
44
|
-
DataSource = "dataSource"
|
|
45
|
-
}
|
|
46
|
-
export interface IDynamicValue {
|
|
47
|
-
type: PropBindType;
|
|
48
|
-
value: any;
|
|
49
|
-
extra?: any;
|
|
50
|
-
}
|
|
51
|
-
export interface IDataBind {
|
|
52
|
-
propertyPath: string;
|
|
53
|
-
bindDataPath: string;
|
|
54
|
-
type?: PropBindType;
|
|
55
|
-
extra?: any;
|
|
56
|
-
}
|
|
57
|
-
interface NodeEx extends Node {
|
|
58
|
-
$parent: NodeEx;
|
|
59
|
-
$path: any[];
|
|
60
|
-
expressions: NodeEx[];
|
|
61
|
-
/**
|
|
62
|
-
* LogicalExpression
|
|
63
|
-
*/
|
|
64
|
-
left: NodeEx;
|
|
65
|
-
right: NodeEx;
|
|
66
|
-
/**
|
|
67
|
-
* UnaryExpression
|
|
68
|
-
*/
|
|
69
|
-
operator: string;
|
|
70
|
-
prefix: boolean;
|
|
71
|
-
/**
|
|
72
|
-
* MemberExpression
|
|
73
|
-
*/
|
|
74
|
-
property: NodeEx;
|
|
75
|
-
object: NodeEx;
|
|
76
|
-
computed: boolean;
|
|
77
|
-
/**
|
|
78
|
-
* Literal
|
|
79
|
-
*/
|
|
80
|
-
name: string;
|
|
81
|
-
value: any;
|
|
82
|
-
regex: any;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* 检查全局变量静态访问是否符合要求
|
|
86
|
-
* @export
|
|
87
|
-
* @param {*} expression
|
|
88
|
-
*/
|
|
89
|
-
export declare function parseMemberProperty(expression: NodeEx, checkMemberProperty?: (path: any[]) => void): (string | number)[];
|
|
90
|
-
interface IDynamicValueParserOptions {
|
|
91
|
-
type: PropBindType;
|
|
92
|
-
value?: string;
|
|
93
|
-
expression?: any;
|
|
94
|
-
pageId?: string;
|
|
95
|
-
}
|
|
96
|
-
export declare class DynamicValueParser {
|
|
97
|
-
expression: NodeEx;
|
|
98
|
-
expressionString: string;
|
|
99
|
-
options: IDynamicValueParserOptions;
|
|
100
|
-
constructor(expressionString: string, options?: Partial<IDynamicValueParserOptions>);
|
|
101
|
-
/**
|
|
102
|
-
* parser
|
|
103
|
-
*/
|
|
104
|
-
parse(): IDynamicValueParserOptions;
|
|
105
|
-
linkBinaryExpression(expression: NodeEx): void;
|
|
106
|
-
parseBinaryExpression(expression: NodeEx, options: this['options']): IDynamicValueParserOptions;
|
|
107
|
-
parseSimpleExpression(expression: NodeEx, options: this['options']): IDynamicValueParserOptions;
|
|
108
|
-
parseItemAliseExpression(expression: NodeEx, options: this['options']): this["options"];
|
|
109
|
-
_generatePrefix(memberProperty: (number | string)[], index: number): string;
|
|
110
|
-
_replaceExpression(meta: {
|
|
111
|
-
memberProperty: (number | string)[];
|
|
112
|
-
index: number;
|
|
113
|
-
replacer: string;
|
|
114
|
-
expressionString?: string;
|
|
115
|
-
}): string;
|
|
116
|
-
parseDataset(expression: NodeEx, meta: {
|
|
117
|
-
memberProperty: (number | string)[];
|
|
118
|
-
index: number;
|
|
119
|
-
replacer: string;
|
|
120
|
-
}, options: this['options']): IDynamicValueParserOptions;
|
|
121
|
-
}
|
|
122
|
-
export {};
|
|
123
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parser/expression/index.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DynamicValueParser = exports.parseMemberProperty = exports.ActionType = exports.PropBindType = exports.AST_TYPE = exports.PARSE_CONFIG = void 0;
|
|
4
|
-
const acorn_1 = require("acorn");
|
|
5
|
-
exports.PARSE_CONFIG = {
|
|
6
|
-
ecmaVersion: 6,
|
|
7
|
-
sourceType: 'script',
|
|
8
|
-
allowReturnOutsideFunction: false,
|
|
9
|
-
allowImportExportEverywhere: false,
|
|
10
|
-
allowAwaitOutsideFunction: false,
|
|
11
|
-
allowHashBang: false,
|
|
12
|
-
};
|
|
13
|
-
exports.AST_TYPE = {
|
|
14
|
-
Literal: 'Literal',
|
|
15
|
-
ExpressionStatement: 'ExpressionStatement',
|
|
16
|
-
LogicalExpression: 'LogicalExpression',
|
|
17
|
-
BinaryExpression: 'BinaryExpression',
|
|
18
|
-
UnaryExpression: 'UnaryExpression',
|
|
19
|
-
MemberExpression: 'MemberExpression',
|
|
20
|
-
Identifier: 'Identifier',
|
|
21
|
-
ArrayExpression: 'ArrayExpression',
|
|
22
|
-
CallExpression: 'CallExpression',
|
|
23
|
-
TemplateLiteral: 'TemplateLiteral',
|
|
24
|
-
TemplateElement: 'TemplateElement',
|
|
25
|
-
ConditionalExpression: 'ConditionalExpression',
|
|
26
|
-
SequenceExpression: 'SequenceExpression',
|
|
27
|
-
};
|
|
28
|
-
var PropBindType;
|
|
29
|
-
(function (PropBindType) {
|
|
30
|
-
PropBindType["static"] = "static";
|
|
31
|
-
PropBindType["state"] = "rematch";
|
|
32
|
-
PropBindType["computed"] = "computed";
|
|
33
|
-
PropBindType["forItem"] = "for-item";
|
|
34
|
-
PropBindType["expression"] = "expression";
|
|
35
|
-
PropBindType["prop"] = "prop";
|
|
36
|
-
PropBindType["slot"] = "slot";
|
|
37
|
-
PropBindType["dataVar"] = "dataVar";
|
|
38
|
-
PropBindType["stateData"] = "state";
|
|
39
|
-
/**
|
|
40
|
-
* @deprecated
|
|
41
|
-
*/
|
|
42
|
-
PropBindType["paramData"] = "params";
|
|
43
|
-
PropBindType["params"] = "params";
|
|
44
|
-
PropBindType["scope"] = "scope";
|
|
45
|
-
})(PropBindType = exports.PropBindType || (exports.PropBindType = {}));
|
|
46
|
-
var ActionType;
|
|
47
|
-
(function (ActionType) {
|
|
48
|
-
ActionType["Rematch"] = "rematch";
|
|
49
|
-
ActionType["Material"] = "material";
|
|
50
|
-
ActionType["GeneralFunc"] = "general-func";
|
|
51
|
-
ActionType["LifeCycle"] = "lifecycle";
|
|
52
|
-
ActionType["PropEvent"] = "prop-event";
|
|
53
|
-
ActionType["HandlerFn"] = "handler-fn";
|
|
54
|
-
ActionType["Inline"] = "inline";
|
|
55
|
-
ActionType["Platform"] = "platform";
|
|
56
|
-
ActionType["DataSource"] = "dataSource";
|
|
57
|
-
})(ActionType = exports.ActionType || (exports.ActionType = {}));
|
|
58
|
-
class ParseError extends Error {
|
|
59
|
-
constructor(error) {
|
|
60
|
-
super(error.message);
|
|
61
|
-
if (error.code) {
|
|
62
|
-
this.code = error.code || 'PARSE_DYNAMIC_EXPRESSION_ERROR';
|
|
63
|
-
}
|
|
64
|
-
if (error.expression) {
|
|
65
|
-
this.expression = error.expression;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* 检查全局变量静态访问是否符合要求
|
|
71
|
-
* @export
|
|
72
|
-
* @param {*} expression
|
|
73
|
-
*/
|
|
74
|
-
function parseMemberProperty(expression, checkMemberProperty) {
|
|
75
|
-
let exp = expression;
|
|
76
|
-
let memberPathArr = [];
|
|
77
|
-
if (exp.type == exports.AST_TYPE.MemberExpression) {
|
|
78
|
-
// 算过了就不再算了, 赋值是校验,此处不校验,减少比较
|
|
79
|
-
if (expression.$path) {
|
|
80
|
-
return [...expression.$path];
|
|
81
|
-
}
|
|
82
|
-
let object = exp.object;
|
|
83
|
-
switch (object.type) {
|
|
84
|
-
case exports.AST_TYPE.MemberExpression:
|
|
85
|
-
memberPathArr = parseMemberProperty(object, checkMemberProperty);
|
|
86
|
-
break;
|
|
87
|
-
case exports.AST_TYPE.Identifier:
|
|
88
|
-
memberPathArr = [object.name];
|
|
89
|
-
break;
|
|
90
|
-
default:
|
|
91
|
-
throw new ParseError({
|
|
92
|
-
expression,
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
let property = exp.property;
|
|
96
|
-
if (exp.computed) {
|
|
97
|
-
if (property.type === exports.AST_TYPE.Literal && !property.regex) {
|
|
98
|
-
memberPathArr.push(property.value);
|
|
99
|
-
}
|
|
100
|
-
else {
|
|
101
|
-
throw new ParseError({
|
|
102
|
-
expression,
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
memberPathArr.push(property.name);
|
|
108
|
-
}
|
|
109
|
-
if (checkMemberProperty) {
|
|
110
|
-
checkMemberProperty(memberPathArr);
|
|
111
|
-
}
|
|
112
|
-
expression.$path = memberPathArr;
|
|
113
|
-
}
|
|
114
|
-
return [...memberPathArr];
|
|
115
|
-
}
|
|
116
|
-
exports.parseMemberProperty = parseMemberProperty;
|
|
117
|
-
class DynamicValueParser {
|
|
118
|
-
constructor(expressionString, options) {
|
|
119
|
-
this.expressionString = expressionString;
|
|
120
|
-
this.options = Object.assign(Object.assign({}, options), { type: PropBindType.expression, value: this.expressionString });
|
|
121
|
-
let ast = (0, acorn_1.parse)(this.expressionString, exports.PARSE_CONFIG);
|
|
122
|
-
let { expression } = ast.body[0];
|
|
123
|
-
this.expression = expression;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* parser
|
|
127
|
-
*/
|
|
128
|
-
parse() {
|
|
129
|
-
switch (this.expression.type) {
|
|
130
|
-
case exports.AST_TYPE.BinaryExpression:
|
|
131
|
-
return this.parseBinaryExpression(this.expression, this.options);
|
|
132
|
-
case exports.AST_TYPE.MemberExpression:
|
|
133
|
-
return this.parseSimpleExpression(this.expression, this.options);
|
|
134
|
-
case exports.AST_TYPE.Identifier: {
|
|
135
|
-
if (this.expression.name == '$slot') {
|
|
136
|
-
this.options.type = PropBindType.slot;
|
|
137
|
-
this.options.value = '';
|
|
138
|
-
return this.options;
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
throw new ParseError({
|
|
142
|
-
expression: this.expression,
|
|
143
|
-
});
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
default:
|
|
147
|
-
throw new ParseError({
|
|
148
|
-
expression: this.expression,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
linkBinaryExpression(expression) {
|
|
153
|
-
expression.left.$parent = expression;
|
|
154
|
-
expression.right.$parent = expression;
|
|
155
|
-
}
|
|
156
|
-
parseBinaryExpression(expression, options) {
|
|
157
|
-
this.linkBinaryExpression(expression);
|
|
158
|
-
let { operator, left, right, start } = expression;
|
|
159
|
-
if (operator != 'in') {
|
|
160
|
-
throw new ParseError({
|
|
161
|
-
expression,
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
this.parseItemAliseExpression(left, options);
|
|
165
|
-
return this.parseSimpleExpression(right, options);
|
|
166
|
-
}
|
|
167
|
-
parseSimpleExpression(expression, options) {
|
|
168
|
-
switch (expression.type) {
|
|
169
|
-
case exports.AST_TYPE.MemberExpression: {
|
|
170
|
-
let memberProperty = parseMemberProperty(expression);
|
|
171
|
-
let hasCallExpression = memberProperty.find((exp) => typeof exp === 'object');
|
|
172
|
-
const meta = {
|
|
173
|
-
memberProperty,
|
|
174
|
-
index: 0,
|
|
175
|
-
replacer: '',
|
|
176
|
-
expressionString: this.expressionString.slice(expression.start, expression.end),
|
|
177
|
-
};
|
|
178
|
-
switch (memberProperty[0]) {
|
|
179
|
-
case '$page': {
|
|
180
|
-
if (hasCallExpression || !this.options.pageId) {
|
|
181
|
-
throw new ParseError({ expression });
|
|
182
|
-
}
|
|
183
|
-
meta.index = 1;
|
|
184
|
-
meta.replacer = this.options.pageId;
|
|
185
|
-
switch (memberProperty[1]) {
|
|
186
|
-
case 'dataset': {
|
|
187
|
-
return this.parseDataset(expression, meta, options);
|
|
188
|
-
}
|
|
189
|
-
case 'state':
|
|
190
|
-
case 'computed':
|
|
191
|
-
case 'dataVar': {
|
|
192
|
-
// 老格式全部都转为 expression 格式
|
|
193
|
-
throw new ParseError({ expression });
|
|
194
|
-
}
|
|
195
|
-
default: {
|
|
196
|
-
throw new ParseError({ expression });
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
case '$app': {
|
|
201
|
-
meta.index = 1;
|
|
202
|
-
meta.replacer = 'global';
|
|
203
|
-
switch (memberProperty[1]) {
|
|
204
|
-
case 'dataset': {
|
|
205
|
-
return this.parseDataset(expression, meta, options);
|
|
206
|
-
}
|
|
207
|
-
case 'state':
|
|
208
|
-
case 'computed':
|
|
209
|
-
case 'dataVar': {
|
|
210
|
-
// 老格式全部都转为 expression 格式
|
|
211
|
-
throw new ParseError({ expression });
|
|
212
|
-
}
|
|
213
|
-
default: {
|
|
214
|
-
throw new ParseError({ expression });
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
case '$for':
|
|
219
|
-
options.type = PropBindType.forItem;
|
|
220
|
-
options.value = this.expressionString.slice(expression.start, expression.end).replace(/^\$for\./, '');
|
|
221
|
-
break;
|
|
222
|
-
default: {
|
|
223
|
-
throw new ParseError({
|
|
224
|
-
expression,
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
options.expression = expression;
|
|
229
|
-
break;
|
|
230
|
-
}
|
|
231
|
-
default: {
|
|
232
|
-
throw new ParseError({
|
|
233
|
-
expression,
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return options;
|
|
238
|
-
}
|
|
239
|
-
parseItemAliseExpression(expression, options) {
|
|
240
|
-
switch (expression.type) {
|
|
241
|
-
case exports.AST_TYPE.Identifier:
|
|
242
|
-
return options;
|
|
243
|
-
case exports.AST_TYPE.SequenceExpression: {
|
|
244
|
-
let { expressions } = expression;
|
|
245
|
-
console.log(expressions);
|
|
246
|
-
if (expressions.length > 2 || expressions.length < 1) {
|
|
247
|
-
throw new ParseError({
|
|
248
|
-
expression,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
for (let exp of expressions) {
|
|
252
|
-
if (exp.type !== exports.AST_TYPE.Identifier) {
|
|
253
|
-
throw new ParseError({
|
|
254
|
-
expression,
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
return options;
|
|
259
|
-
}
|
|
260
|
-
default:
|
|
261
|
-
throw new ParseError({
|
|
262
|
-
expression,
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
_generatePrefix(memberProperty, index) {
|
|
267
|
-
let prefix = '';
|
|
268
|
-
for (let i = 0; i <= index; i++) {
|
|
269
|
-
if (i != 0) {
|
|
270
|
-
prefix += '.';
|
|
271
|
-
}
|
|
272
|
-
prefix += memberProperty[i];
|
|
273
|
-
}
|
|
274
|
-
return prefix;
|
|
275
|
-
}
|
|
276
|
-
_replaceExpression(meta) {
|
|
277
|
-
let { memberProperty, index, replacer, expressionString = this.expressionString } = meta;
|
|
278
|
-
let prefix = this._generatePrefix(memberProperty, index);
|
|
279
|
-
return expressionString.replace(new RegExp(escapeRegExp(prefix)), replacer);
|
|
280
|
-
}
|
|
281
|
-
parseDataset(expression, meta, options) {
|
|
282
|
-
let { memberProperty, index } = meta;
|
|
283
|
-
switch (memberProperty[index + 1]) {
|
|
284
|
-
case 'state':
|
|
285
|
-
options.type = PropBindType.stateData;
|
|
286
|
-
options.value = this._replaceExpression(Object.assign(Object.assign({}, meta), { index: meta.index + 1 }));
|
|
287
|
-
break;
|
|
288
|
-
case 'params':
|
|
289
|
-
options.type = PropBindType.params;
|
|
290
|
-
options.value = this._replaceExpression(Object.assign(Object.assign({}, meta), { index: meta.index + 1 }));
|
|
291
|
-
break;
|
|
292
|
-
default:
|
|
293
|
-
throw new ParseError({ expression });
|
|
294
|
-
}
|
|
295
|
-
return this.options;
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
|
-
exports.DynamicValueParser = DynamicValueParser;
|
|
299
|
-
function escapeRegExp(string) {
|
|
300
|
-
return string.replace(/[.*+\-?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
|
301
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
declare function Plugin(opt?: {
|
|
2
|
-
root?: string;
|
|
3
|
-
zoom?: number;
|
|
4
|
-
precision?: number;
|
|
5
|
-
outUnit?: string;
|
|
6
|
-
exclude?: string;
|
|
7
|
-
}): {
|
|
8
|
-
postcssPlugin: string;
|
|
9
|
-
Once(root: any, { result }: {
|
|
10
|
-
result: any;
|
|
11
|
-
}): void;
|
|
12
|
-
};
|
|
13
|
-
declare namespace Plugin {
|
|
14
|
-
var postcss: boolean;
|
|
15
|
-
var CALC_RPX_ROOT_VAL_NAME: string;
|
|
16
|
-
}
|
|
17
|
-
export default Plugin;
|
|
18
|
-
//# sourceMappingURL=postcss-rpx2clac.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postcss-rpx2clac.d.ts","sourceRoot":"","sources":["../../../src/parser/plugins/postcss-rpx2clac.ts"],"names":[],"mappings":"AA+BA,iBAAS,MAAM,CAAC,GAAG,CAAC,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE;;;;;EAqC7G;kBArCQ,MAAM;;;;AA0Cf,eAAe,MAAM,CAAC"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const DEFAULT_CONFIG = {
|
|
4
|
-
root: '2',
|
|
5
|
-
/**
|
|
6
|
-
* 缩放比例
|
|
7
|
-
*/
|
|
8
|
-
zoom: 1,
|
|
9
|
-
/**
|
|
10
|
-
* 配置精度
|
|
11
|
-
*/
|
|
12
|
-
precision: 5,
|
|
13
|
-
/**
|
|
14
|
-
* 输出单位
|
|
15
|
-
*/
|
|
16
|
-
outUnit: 'px',
|
|
17
|
-
/**
|
|
18
|
-
* 配置忽略文件,正则匹配
|
|
19
|
-
*/
|
|
20
|
-
exclude: '',
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* https://github.com/cuth/postcss-pxtorem/blob/122649015322214f8e9d1ac852eb11c0791b634b/index.js#L56
|
|
24
|
-
*/
|
|
25
|
-
function toFixed(number, precision) {
|
|
26
|
-
const multiplier = Math.pow(10, precision + 1), wholeNumber = Math.floor(number * multiplier);
|
|
27
|
-
return (Math.round(wholeNumber / 10) * 10) / multiplier;
|
|
28
|
-
}
|
|
29
|
-
function Plugin(opt) {
|
|
30
|
-
opt = Object.assign(Object.assign({}, DEFAULT_CONFIG), (opt || {}));
|
|
31
|
-
const { root: rootValue, zoom, precision, outUnit, exclude } = opt;
|
|
32
|
-
return {
|
|
33
|
-
postcssPlugin: 'postcss-rpx2calc',
|
|
34
|
-
Once(root, { result }) {
|
|
35
|
-
if (exclude && root.source.input.file.match(exclude) !== null) {
|
|
36
|
-
result.root = root;
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
root.walkRules(function (rule) {
|
|
40
|
-
rule.walkDecls(function (decl) {
|
|
41
|
-
if (decl.value.includes('rpx')) {
|
|
42
|
-
/**
|
|
43
|
-
* copy form
|
|
44
|
-
* https://github.com/cuth/postcss-pxtorem/blob/122649015322214f8e9d1ac852eb11c0791b634b/lib/pixel-unit-regex.js#L9
|
|
45
|
-
* 不处理 var()rpx 的情况
|
|
46
|
-
*/
|
|
47
|
-
const r2 = /"[^"]+"|'[^']+'|url\([^)]+\)|var\([^)]+\)|(\d*\.?\d+)rpx/g;
|
|
48
|
-
decl.value = decl.value.replace(r2, (str, num1) => {
|
|
49
|
-
if (num1 == undefined)
|
|
50
|
-
return str;
|
|
51
|
-
if (num1 == '0')
|
|
52
|
-
return '0';
|
|
53
|
-
const v = +num1 / (zoom || 1);
|
|
54
|
-
if (isNaN(v)) {
|
|
55
|
-
return str;
|
|
56
|
-
}
|
|
57
|
-
const value = Number.isInteger(v) ? v.toString() : toFixed(v, precision || 0);
|
|
58
|
-
return `calc(${value}${outUnit}/${rootValue})`;
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
},
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
Plugin.postcss = true;
|
|
67
|
-
Plugin.CALC_RPX_ROOT_VAL_NAME = '--wd-rpx-radio';
|
|
68
|
-
exports.default = Plugin;
|