@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,123 @@
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/parser/expression/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,301 @@
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,10 +1,11 @@
1
1
  export * from './cals/index';
2
2
  export { upgrageToVersion2 } from './cals/utils/version';
3
3
  export { processComponentModule } from './cals/utils/spinoff';
4
- export { calsToCode, codeToCals, type ICodeItem, checkForConflicts, autoResolveConflicts, findAllConflicts } from './cals/utils/code';
4
+ export { calsToCode, codeToCals, type ICodeItem, checkForConflicts, autoResolveConflicts, findAllConflicts, } from './cals/utils/code';
5
5
  export { parseComponentCals } from './cals/utils/block';
6
6
  export { ActionType, type IDataBind, PropBindType } from './expression/index';
7
7
  export { processCommonStyle2CSSProperties, processCSSProperties2Rem, processCSSPropertiesUnit, } from './cals/utils/style';
8
8
  export { getUsedResources, getNavUsedStaticResource, _simpleGetUsedResourceOfComponent, } from './cals/utils/getUsedResources';
9
9
  export { default as PostcssRpx2Calc } from './plugins/postcss-rpx2clac';
10
+ export { Dependencies } from './dependiencies';
10
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,iBAAiB,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACtI,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,gCAAgC,EAChC,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/parser/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAC9D,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,SAAS,EACd,iBAAiB,EACjB,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,KAAK,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC9E,OAAO,EACL,gCAAgC,EAChC,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,gBAAgB,EAChB,wBAAwB,EACxB,iCAAiC,GAClC,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC"}
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
17
17
  return (mod && mod.__esModule) ? mod : { "default": mod };
18
18
  };
19
19
  Object.defineProperty(exports, "__esModule", { value: true });
20
- exports.PostcssRpx2Calc = exports._simpleGetUsedResourceOfComponent = exports.getNavUsedStaticResource = exports.getUsedResources = exports.processCSSPropertiesUnit = exports.processCSSProperties2Rem = exports.processCommonStyle2CSSProperties = exports.PropBindType = exports.ActionType = exports.parseComponentCals = exports.findAllConflicts = exports.autoResolveConflicts = exports.checkForConflicts = exports.codeToCals = exports.calsToCode = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
20
+ exports.Dependencies = exports.PostcssRpx2Calc = exports._simpleGetUsedResourceOfComponent = exports.getNavUsedStaticResource = exports.getUsedResources = exports.processCSSPropertiesUnit = exports.processCSSProperties2Rem = exports.processCommonStyle2CSSProperties = exports.PropBindType = exports.ActionType = exports.parseComponentCals = exports.findAllConflicts = exports.autoResolveConflicts = exports.checkForConflicts = exports.codeToCals = exports.calsToCode = exports.processComponentModule = exports.upgrageToVersion2 = void 0;
21
21
  __exportStar(require("./cals/index"), exports);
22
22
  var version_1 = require("./cals/utils/version");
23
23
  Object.defineProperty(exports, "upgrageToVersion2", { enumerable: true, get: function () { return version_1.upgrageToVersion2; } });
@@ -44,3 +44,5 @@ Object.defineProperty(exports, "getNavUsedStaticResource", { enumerable: true, g
44
44
  Object.defineProperty(exports, "_simpleGetUsedResourceOfComponent", { enumerable: true, get: function () { return getUsedResources_1._simpleGetUsedResourceOfComponent; } });
45
45
  var postcss_rpx2clac_1 = require("./plugins/postcss-rpx2clac");
46
46
  Object.defineProperty(exports, "PostcssRpx2Calc", { enumerable: true, get: function () { return __importDefault(postcss_rpx2clac_1).default; } });
47
+ var dependiencies_1 = require("./dependiencies");
48
+ Object.defineProperty(exports, "Dependencies", { enumerable: true, get: function () { return dependiencies_1.Dependencies; } });
@@ -0,0 +1,18 @@
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
@@ -0,0 +1 @@
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"}
@@ -0,0 +1,68 @@
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;
@@ -0,0 +1,73 @@
1
+ import { IListener, IResource } from './common';
2
+ import { IDataSource } from './datasource';
3
+ import { IComponent } from './component';
4
+ export interface IApp {
5
+ /**
6
+ * 必填, 应用名称, 标识
7
+ * @maxLength 214
8
+ * @minLength 1
9
+ * @pattern ^(?:\x40[a-z0-9-*~][a-z0-9-*._~]*\x47)?[a-z0-9-~][a-z0-9-._~]*$
10
+ */
11
+ name?: string;
12
+ /**
13
+ * 选填, 应用别名
14
+ */
15
+ label?: string;
16
+ /**
17
+ * 选填, 应用版本
18
+ * version 值应该能够被 node-semver 解析
19
+ *
20
+ * @default 0.1.0
21
+ */
22
+ version?: string;
23
+ /**
24
+ * 协议版本 semer version
25
+ * x.x.x | latest
26
+ */
27
+ schemaVersion?: string;
28
+ /**
29
+ * 选填, 应用简介
30
+ */
31
+ description?: string;
32
+ /**
33
+ * 选填, 应用的入口组件
34
+ *
35
+ * @default home
36
+ */
37
+ main?: string;
38
+ /**
39
+ * 选填, 应用的作者
40
+ */
41
+ author?: string;
42
+ /**
43
+ * 可选, 应用的控制属性
44
+ */
45
+ attributes?: Record<string, any>;
46
+ /**
47
+ * 可选, 应用事件信息
48
+ */
49
+ events?: any;
50
+ /**
51
+ * 必填, 应用的组件集合
52
+ */
53
+ items: IComponent[];
54
+ /**
55
+ * 可选, 数据源集合
56
+ */
57
+ dataSources?: IDataSource[];
58
+ /**
59
+ * 可选, 应用的资源集合
60
+ *
61
+ * 例如, 代码片段、组件库、静态资源
62
+ */
63
+ resources?: IResource[];
64
+ /**
65
+ * 可选, 应用绑定的监听器
66
+ */
67
+ listeners?: IListener[];
68
+ /**
69
+ * 可选, 扩展字段, 尽量避免用
70
+ */
71
+ extra?: any;
72
+ }
73
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/types/basic/app.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,MAAM,WAAW,IAAI;IACnB;;;;;OAKG;IAEH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf;;;;;OAKG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IAErB;;;;OAIG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEjC;;OAEG;IACH,MAAM,CAAC,EAAE,GAAG,CAAC;IAEb;;OAEG;IACH,KAAK,EAAE,UAAU,EAAE,CAAC;IAEpB;;OAEG;IACH,WAAW,CAAC,EAAE,WAAW,EAAE,CAAC;IAE5B;;;;OAIG;IACH,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IAExB;;OAEG;IACH,SAAS,CAAC,EAAE,SAAS,EAAE,CAAC;IAExB;;OAEG;IACH,KAAK,CAAC,EAAE,GAAG,CAAC;CACb"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });