@shijiu/jsview 1.9.921 → 1.9.943-next-vue.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.
- package/dom/bin/jsview-dom-browser.min.js +1 -1
- package/dom/bin/jsview-dom-native.min.js +1 -1
- package/dom/bin/jsview-engine-js-browser.min.js +1 -1
- package/dom/bin/jsview-forge-define.min.js +1 -1
- package/dom/index.mjs +2 -1
- package/dom/target_core_revision.mjs +4 -4
- package/loader/jsview-loader.js +1 -5
- package/package.json +1 -1
- package/patches/node_modules/@vitejs/plugin-vue/dist/index.mjs +2729 -0
- package/patches/node_modules/@vitejs/plugin-vue/package.json +51 -0
- package/patches/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js +3152 -0
- package/patches/node_modules/@vue/compiler-dom/package.json +43 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-css-to-js.js +90 -25
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-checker.js +189 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-formator.cjs.js +919 -0
- package/patches/node_modules/@vue/runtime-dom/dist/runtime-dom.esm-bundler.js +17 -0
- package/patches/node_modules/postcss-js/objectifier.js +1 -1
- package/patches/node_modules/vite/dist/node/jsview-vite-extension.js +2 -2
- package/tools/jsview-batch-upgrade.mjs +40 -5
- package/tools/jsview-post-install.mjs +2 -0
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-format.js +0 -201
- package/patches/node_modules/@vue/compiler-sfc/dist/jsview-style-types.js +0 -83
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@vue/compiler-dom",
|
|
3
|
+
"version": "3.2.45",
|
|
4
|
+
"description": "@vue/compiler-dom",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"module": "dist/compiler-dom.esm-bundler.js",
|
|
7
|
+
"types": "dist/compiler-dom.d.ts",
|
|
8
|
+
"unpkg": "dist/compiler-dom.global.js",
|
|
9
|
+
"jsdelivr": "dist/compiler-dom.global.js",
|
|
10
|
+
"files": [
|
|
11
|
+
"index.js",
|
|
12
|
+
"dist"
|
|
13
|
+
],
|
|
14
|
+
"sideEffects": false,
|
|
15
|
+
"buildOptions": {
|
|
16
|
+
"name": "VueCompilerDOM",
|
|
17
|
+
"compat": true,
|
|
18
|
+
"formats": [
|
|
19
|
+
"esm-bundler",
|
|
20
|
+
"esm-browser",
|
|
21
|
+
"cjs",
|
|
22
|
+
"global"
|
|
23
|
+
]
|
|
24
|
+
},
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "git+https://github.com/vuejs/core.git",
|
|
28
|
+
"directory": "packages/compiler-dom"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"vue"
|
|
32
|
+
],
|
|
33
|
+
"author": "Evan You",
|
|
34
|
+
"license": "MIT",
|
|
35
|
+
"bugs": {
|
|
36
|
+
"url": "https://github.com/vuejs/core/issues"
|
|
37
|
+
},
|
|
38
|
+
"homepage": "https://github.com/vuejs/core/tree/main/packages/compiler-dom#readme",
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"@vue/shared": "3.2.45",
|
|
41
|
+
"@vue/compiler-core": "3.2.45"
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -8,8 +8,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
8
8
|
const crypto = require('crypto');
|
|
9
9
|
const fs = require('fs');
|
|
10
10
|
const path = require('path');
|
|
11
|
+
const postCss = require('postcss');
|
|
11
12
|
const postCssJs = require('postcss-js');
|
|
12
|
-
const
|
|
13
|
+
const styleChecker = require("./jsview-style-checker");
|
|
13
14
|
|
|
14
15
|
const compilerSfc = require("./compiler-sfc.cjs");
|
|
15
16
|
const processorLangList = [
|
|
@@ -83,7 +84,7 @@ function compileCssToJsImpl(sfc, options) {
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
const {styleImports, styleSheets } = compileAndSaveImportedNode(rawResult.result.root.nodes);
|
|
86
|
-
cachedStyleImports = [...cachedStyleImports, styleImports];
|
|
87
|
+
cachedStyleImports = [...cachedStyleImports, ...styleImports];
|
|
87
88
|
cachedStyleSheets = { ...cachedStyleSheets, ...styleSheets };
|
|
88
89
|
}
|
|
89
90
|
|
|
@@ -172,14 +173,14 @@ function compileAndSaveImportedNode(styleNodes) {
|
|
|
172
173
|
let styleImports = [];
|
|
173
174
|
let styleSheets = {};
|
|
174
175
|
|
|
175
|
-
|
|
176
|
+
for(const node of styleNodes) {
|
|
176
177
|
if (node.type === "comment"
|
|
177
178
|
|| node.name === "-webkit-keyframes"
|
|
178
179
|
|| node.name === "charset") {
|
|
179
180
|
// DO NOTHING
|
|
180
181
|
} else if(node.name === "import") {
|
|
181
|
-
const importContent =
|
|
182
|
-
if (styleImports.includes(importContent) == false) {
|
|
182
|
+
const importContent = compileImportNodeRecursive(node);
|
|
183
|
+
if (importContent && styleImports.includes(importContent) == false) {
|
|
183
184
|
styleImports.push(importContent);
|
|
184
185
|
}
|
|
185
186
|
} else if(node.name === "keyframes") {
|
|
@@ -187,8 +188,8 @@ function compileAndSaveImportedNode(styleNodes) {
|
|
|
187
188
|
const styleSelectors = new Set([node.params]);
|
|
188
189
|
const checked = checkSelectors(node, styleFilePath, styleSelectors); // 检测selector是否已经处理过
|
|
189
190
|
if (checked == false) {
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
let errMsg = "JsView Warn: Multi defined CSS keyframes '" + node.params + "'.\n";
|
|
192
|
+
console.warn(errMsg);
|
|
192
193
|
}
|
|
193
194
|
|
|
194
195
|
const subStyleSheets = compileKeyframesNode(node);
|
|
@@ -200,8 +201,8 @@ function compileAndSaveImportedNode(styleNodes) {
|
|
|
200
201
|
const styleSelectors = new Set([node.selector]);
|
|
201
202
|
const checked = checkSelectors(node, styleFilePath, styleSelectors); // 检测selector是否已经处理过
|
|
202
203
|
if (checked == false) {
|
|
203
|
-
|
|
204
|
-
|
|
204
|
+
let errMsg = "JsView Warn: Multi defined CSS selector '" + node.selector + "'.\n";
|
|
205
|
+
console.warn(errMsg);
|
|
205
206
|
}
|
|
206
207
|
|
|
207
208
|
const subStyleSheets = compileSelectorNode(node);
|
|
@@ -223,7 +224,7 @@ function compileAndSaveImportedNode(styleNodes) {
|
|
|
223
224
|
console.log("Unsupported css node: ", node);
|
|
224
225
|
check(false, node.source.input.css, "JsView Error: Unsupported css node from import css file.");
|
|
225
226
|
}
|
|
226
|
-
}
|
|
227
|
+
}
|
|
227
228
|
|
|
228
229
|
// console.log('jsview-css-to-js.compileAndSaveImportedNode() styleSheets=', styleImports, styleSheets);
|
|
229
230
|
return {
|
|
@@ -233,19 +234,19 @@ function compileAndSaveImportedNode(styleNodes) {
|
|
|
233
234
|
}
|
|
234
235
|
|
|
235
236
|
function serializeStyleJsFile(styleImports, styleSheets) {
|
|
236
|
-
|
|
237
|
-
&& Object.keys(styleSheets).length === 0) {
|
|
238
|
-
return "";
|
|
239
|
-
}
|
|
237
|
+
let styleJsContent = "\n";
|
|
240
238
|
|
|
241
|
-
|
|
242
|
-
|
|
239
|
+
if (styleImports.length > 0) {
|
|
240
|
+
const styleImportsContent = styleImports.join('\n');
|
|
241
|
+
styleJsContent += styleImportsContent;
|
|
242
|
+
}
|
|
243
243
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
244
|
+
if (Object.keys(styleSheets).length > 0) {
|
|
245
|
+
const styleSheetsContent = JSON.stringify(styleSheets);
|
|
246
|
+
styleJsContent += "\nconst styleSheetsContent = ";
|
|
247
|
+
styleJsContent += styleSheetsContent;
|
|
248
|
+
styleJsContent += ";\nwindow.JsvCode.Dom.DeclareStyleSheets(styleSheetsContent);";
|
|
249
|
+
}
|
|
249
250
|
|
|
250
251
|
return styleJsContent;
|
|
251
252
|
}
|
|
@@ -291,12 +292,69 @@ function getStringOffset(source, line, column) {
|
|
|
291
292
|
return offset;
|
|
292
293
|
}
|
|
293
294
|
|
|
294
|
-
function
|
|
295
|
+
function compileImportNodeRecursive(node, parsedImports = []) {
|
|
296
|
+
const name = node.name;
|
|
297
|
+
check(name === "import", node.source.input.css, "JsView Error: @import name is not found!");
|
|
298
|
+
|
|
299
|
+
let cssFilePath = node.params.replaceAll('"', '');
|
|
300
|
+
cssFilePath = cssFilePath.replaceAll("'", '');
|
|
295
301
|
const baseDir = path.dirname(node.source.input.file);
|
|
296
|
-
const
|
|
297
|
-
const styleJsFilePath = getStyleJsFilePath(
|
|
302
|
+
const cssFileFullPath = path.resolve(baseDir, cssFilePath);
|
|
303
|
+
const styleJsFilePath = getStyleJsFilePath(cssFileFullPath);
|
|
304
|
+
|
|
305
|
+
// 解死循环
|
|
306
|
+
if (parsedImports.includes(cssFileFullPath)) {
|
|
307
|
+
console.log('JsView Info: Ignore to parse file in dead loop: ' + cssFileFullPath);
|
|
308
|
+
return null;
|
|
309
|
+
}
|
|
310
|
+
parsedImports.push(cssFileFullPath);
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
const content = fs.readFileSync(cssFileFullPath, "utf8");;
|
|
314
|
+
const options = {
|
|
315
|
+
from: cssFileFullPath
|
|
316
|
+
};
|
|
317
|
+
const parsedCss = postCss([]).process(content, options);
|
|
318
|
+
|
|
319
|
+
const styleNodes = parsedCss.result.root.nodes;
|
|
320
|
+
const styleImportNodes = [];
|
|
321
|
+
const importNodeIndexs = [];
|
|
322
|
+
for (let idx = 0; idx < styleNodes.length; idx++) {
|
|
323
|
+
const node = styleNodes[idx];
|
|
324
|
+
if (node.name !== "import") {
|
|
325
|
+
continue;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
importNodeIndexs.push(idx);
|
|
329
|
+
}
|
|
330
|
+
for (const idx of importNodeIndexs) {
|
|
331
|
+
const node = styleNodes[idx];
|
|
332
|
+
styleImportNodes.push(node);
|
|
333
|
+
styleNodes.splice(idx, 1);
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
const styleImports = [];
|
|
337
|
+
for (const node of styleImportNodes) {
|
|
338
|
+
const importContent = compileImportNodeRecursive(node, parsedImports);
|
|
339
|
+
if (styleImports.includes(importContent) == true) {
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
styleImports.push(importContent);
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
const { _, styleSheets } = compileAndSaveImportedNode(styleNodes);
|
|
347
|
+
const styleJsContents = serializeStyleJsFile(styleImports, styleSheets);
|
|
348
|
+
|
|
349
|
+
fs.writeFileSync(styleJsFilePath, styleJsContents, "utf8");;
|
|
350
|
+
} catch (e) {
|
|
351
|
+
console.log('JsView Error: Failed to compile css import node.', e);
|
|
352
|
+
throw e;
|
|
353
|
+
}
|
|
354
|
+
|
|
298
355
|
const styleImportContent = `\nimport "${styleJsFilePath}";`;
|
|
299
356
|
|
|
357
|
+
// console.log('jsview-css-to-js.compileImportNodeRecursive() return ', styleImportContent);
|
|
300
358
|
return styleImportContent;
|
|
301
359
|
}
|
|
302
360
|
|
|
@@ -320,6 +378,7 @@ function compileKeyframesNode(node) {
|
|
|
320
378
|
const kfName = node.params;
|
|
321
379
|
let kfValue = content.replace(/(\r|\n|\r\n)/g, " ");
|
|
322
380
|
kfValue = kfValue.replace(/@keyframes .*? {/g, "@keyframes " + kfName + " {");
|
|
381
|
+
kfValue = styleChecker.GetFormattedKeyframe(kfName, kfValue);
|
|
323
382
|
|
|
324
383
|
const scopedId = '0'; // CSS规范中,keyframes没有继承, 放在glabol中
|
|
325
384
|
const kfRule = { [kfName]: kfValue };
|
|
@@ -375,6 +434,12 @@ function parseUnscopedStyleSheets(node, selector, declarations, scopedId) {
|
|
|
375
434
|
let styleRules = {};
|
|
376
435
|
|
|
377
436
|
for (let [name, value] of Object.entries(declarations)) {
|
|
437
|
+
if (value instanceof Array) { // 同一个name定义了多次
|
|
438
|
+
let errMsg = "JsView Warn: Multi defined CSS name '" + name + "' from " + selector + ".\n";
|
|
439
|
+
console.warn(errMsg);
|
|
440
|
+
value = value[value.length - 1];
|
|
441
|
+
}
|
|
442
|
+
|
|
378
443
|
// 处理var变量中如果存在'a.b'的写法,被翻译成'a\.b'的问题。
|
|
379
444
|
if (typeof (value) == 'string' && value.startsWith('var(--')) {
|
|
380
445
|
value = value.replaceAll('\\', '');
|
|
@@ -392,7 +457,7 @@ function parseUnscopedStyleSheets(node, selector, declarations, scopedId) {
|
|
|
392
457
|
continue;
|
|
393
458
|
}
|
|
394
459
|
|
|
395
|
-
const formattedValue =
|
|
460
|
+
const formattedValue = styleChecker.GetFormattedValue(name, value);
|
|
396
461
|
declarations[name] = formattedValue;
|
|
397
462
|
}
|
|
398
463
|
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
const {
|
|
2
|
+
StyleFormator,
|
|
3
|
+
StyleName,
|
|
4
|
+
StyleValue,
|
|
5
|
+
StyleVariable
|
|
6
|
+
} = require("./jsview-style-formator.cjs");
|
|
7
|
+
|
|
8
|
+
// if (StyleVariable.IsVariable(value)) {
|
|
9
|
+
// return value;
|
|
10
|
+
// }
|
|
11
|
+
|
|
12
|
+
class StyleChecker {
|
|
13
|
+
static GetFormattedValue(propName, propValue) {
|
|
14
|
+
propValue = new StyleValue(propValue);
|
|
15
|
+
if (StyleVariable.IsVariable(propValue)) {
|
|
16
|
+
return propValue;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
let formattedValue = propValue.get();
|
|
20
|
+
switch (propName) {
|
|
21
|
+
case StyleName.Layout.Height:
|
|
22
|
+
case StyleName.Layout.Left:
|
|
23
|
+
case StyleName.Layout.Top:
|
|
24
|
+
case StyleName.Layout.Width:
|
|
25
|
+
formattedValue = StyleChecker.#GetLayoutValue(propName, propValue);
|
|
26
|
+
break;
|
|
27
|
+
case StyleName.Background.BackgroundColor:
|
|
28
|
+
case StyleName.Background.BackgroundImage:
|
|
29
|
+
case StyleName.Background.BorderRadius:
|
|
30
|
+
formattedValue = StyleChecker.#GetBackgroundValue(propName, propValue);
|
|
31
|
+
break;
|
|
32
|
+
case StyleName.Effect.BackfaceVisibility:
|
|
33
|
+
case StyleName.Effect.BorderImage:
|
|
34
|
+
case StyleName.Effect.BorderImageWidth:
|
|
35
|
+
case StyleName.Effect.BorderImageOutset:
|
|
36
|
+
case StyleName.Effect.ClipPath:
|
|
37
|
+
case StyleName.Effect.Display:
|
|
38
|
+
case StyleName.Effect.ObjectFit:
|
|
39
|
+
case StyleName.Effect.Opacity:
|
|
40
|
+
case StyleName.Effect.Overflow:
|
|
41
|
+
case StyleName.Effect.Perspective:
|
|
42
|
+
case StyleName.Effect.PerspectiveOrigin:
|
|
43
|
+
case StyleName.Effect.Visibility:
|
|
44
|
+
case StyleName.Effect.ZIndex:
|
|
45
|
+
formattedValue = StyleChecker.#GetEffectValue(propName, propValue);
|
|
46
|
+
break;
|
|
47
|
+
case StyleName.Text.Color:
|
|
48
|
+
case StyleName.Text.FontFamily:
|
|
49
|
+
case StyleName.Text.FontSize:
|
|
50
|
+
case StyleName.Text.FontStyle:
|
|
51
|
+
case StyleName.Text.FontWeight:
|
|
52
|
+
case StyleName.Text.LineHeight:
|
|
53
|
+
case StyleName.Text.TextAlign:
|
|
54
|
+
case StyleName.Text.TextShadow:
|
|
55
|
+
case StyleName.Text.TextOverflow:
|
|
56
|
+
case StyleName.Text.Transform:
|
|
57
|
+
case StyleName.Text.TransformOrigin:
|
|
58
|
+
case StyleName.Text.TransformStyle:
|
|
59
|
+
case StyleName.Text.WebkitTextStroke:
|
|
60
|
+
case StyleName.Text.WhiteSpace:
|
|
61
|
+
case StyleName.Text.WordWrap:
|
|
62
|
+
formattedValue = StyleChecker.#GetTextValue(propName, propValue);
|
|
63
|
+
break;
|
|
64
|
+
case StyleName.Motion.Animation:
|
|
65
|
+
case StyleName.Motion.Transition:
|
|
66
|
+
formattedValue = StyleChecker.#GetMotionValue(propName, propValue);
|
|
67
|
+
break;
|
|
68
|
+
default:
|
|
69
|
+
// 返回未处理的值
|
|
70
|
+
console.warn("JsView Warn: Unimplemented style property [" + propName + "]");
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return formattedValue;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static GetFormattedKeyframe(propName, propValue) {
|
|
78
|
+
let removedPxSuffix = false;
|
|
79
|
+
|
|
80
|
+
// 去掉translate3d中的px单位
|
|
81
|
+
const valueArray = propValue.split('translate3d');
|
|
82
|
+
for (let idx = 1; idx < valueArray.length; idx++) {
|
|
83
|
+
let useFormated = false;
|
|
84
|
+
let translate3dValue = valueArray[idx].replace(/\).*/, ''); // 只保留value
|
|
85
|
+
translate3dValue = translate3dValue.replace(/.*\(/, ''); // 只保留value
|
|
86
|
+
const translate3dCoord = translate3dValue.split(',');
|
|
87
|
+
for (let coordIdx = 0; coordIdx < translate3dCoord.length; coordIdx++) {
|
|
88
|
+
const coordValue = translate3dCoord[coordIdx].trim();
|
|
89
|
+
if (coordValue.includes('px')) {
|
|
90
|
+
translate3dCoord[coordIdx] = coordValue.replace('px', '');
|
|
91
|
+
useFormated = true;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (useFormated) { // 替换成去掉px的值
|
|
96
|
+
translate3dValue = translate3dCoord.join(',');
|
|
97
|
+
valueArray[idx] = valueArray[idx].replace(/\(.*?\)/, '(' + translate3dValue + ')');
|
|
98
|
+
removedPxSuffix = true;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (removedPxSuffix) {
|
|
103
|
+
const msg = `JsView Info:`
|
|
104
|
+
+ ` Auto optimize style keyframes ${propName},`
|
|
105
|
+
+ ` remove unnecessary 'px' suffix.`;
|
|
106
|
+
console.info(msg);
|
|
107
|
+
}
|
|
108
|
+
const value = valueArray.join('translate3d');
|
|
109
|
+
|
|
110
|
+
return value;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
static #GetLayoutValue(propName, propValue) {
|
|
114
|
+
const formattedValue = StyleChecker.#ConvertToInt32(propName, propValue);
|
|
115
|
+
|
|
116
|
+
return formattedValue;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
static #GetBackgroundValue(propName, propValue) {
|
|
120
|
+
let formattedValue = null;
|
|
121
|
+
switch (propName) {
|
|
122
|
+
case StyleName.Background.BorderRadius:
|
|
123
|
+
propValue = propValue.replace('px', ''); // 去掉px
|
|
124
|
+
formattedValue = StyleFormator.ConvertToString(propValue);
|
|
125
|
+
break;
|
|
126
|
+
default:
|
|
127
|
+
formattedValue = StyleFormator.ConvertToString(propValue);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return formattedValue;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
static #GetEffectValue(propName, propValue) {
|
|
135
|
+
let formattedValue = null;
|
|
136
|
+
switch (propName) {
|
|
137
|
+
case StyleName.Effect.Opacity:
|
|
138
|
+
formattedValue = StyleFormator.ConvertToFloat(propValue);
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
formattedValue = StyleFormator.ConvertToString(propValue);
|
|
142
|
+
break;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
return formattedValue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
static #GetTextValue(propName, propValue) {
|
|
149
|
+
let formattedValue = null;
|
|
150
|
+
switch (propName) {
|
|
151
|
+
case StyleName.Text.FontSize:
|
|
152
|
+
case StyleName.Text.LineHeight:
|
|
153
|
+
formattedValue = StyleChecker.#ConvertToInt32(propName, propValue);
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
formattedValue = StyleFormator.ConvertToString(propValue);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
return formattedValue;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
static #GetMotionValue(propName, propValue) {
|
|
164
|
+
// 需要留到执行时处理
|
|
165
|
+
const formattedValue = StyleFormator.ConvertToString(propValue);
|
|
166
|
+
|
|
167
|
+
return formattedValue;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
static #ConvertToInt32(propName, propValue) {
|
|
171
|
+
if (propValue.is(StyleValue.DataType.String)) {
|
|
172
|
+
const strValue = propValue.get();
|
|
173
|
+
StyleFormator.StringTrim(strValue);
|
|
174
|
+
if (StyleFormator.StringEndsWith(strValue, "px")) {
|
|
175
|
+
const fmtValue = StyleFormator.StringToInt32(strValue);
|
|
176
|
+
const msg = `JsView Info:`
|
|
177
|
+
+ ` Auto optimize style propery ${propName},`
|
|
178
|
+
+ ` convert value from string ${strValue} to number ${fmtValue}.`;
|
|
179
|
+
console.info(msg);
|
|
180
|
+
return fmtValue;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return StyleFormator.ConvertToInt32(propValue);
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
module.exports = StyleChecker;
|