@aiot-toolkit/parser 2.0.6-beta.4 → 2.0.6-beta.5
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.
|
@@ -598,17 +598,10 @@ class StyleParser {
|
|
|
598
598
|
let errors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
599
599
|
let isParserError = errorType === 'parserError';
|
|
600
600
|
let sourceCodeStyle = _sharedUtils.Loglevel.WARN;
|
|
601
|
-
const {
|
|
602
|
-
onLog,
|
|
603
|
-
filePath
|
|
604
|
-
} = this.options;
|
|
605
601
|
if (isParserError) {
|
|
606
602
|
sourceCodeStyle = _sharedUtils.Loglevel.ERROR;
|
|
607
603
|
}
|
|
608
604
|
errors.forEach(error => {
|
|
609
|
-
const sourceCode = error.source ? [`, source code:`, {
|
|
610
|
-
word: `${error.source}`
|
|
611
|
-
}] : [];
|
|
612
605
|
const position = this.styleMapUtil.transfromLocToPosition({
|
|
613
606
|
start: {
|
|
614
607
|
line: error.startLine,
|
|
@@ -624,12 +617,7 @@ class StyleParser {
|
|
|
624
617
|
});
|
|
625
618
|
position.startColumn++;
|
|
626
619
|
position.endColumn++;
|
|
627
|
-
|
|
628
|
-
level: sourceCodeStyle,
|
|
629
|
-
filePath,
|
|
630
|
-
position,
|
|
631
|
-
message: [...error.messages, ...sourceCode]
|
|
632
|
-
});
|
|
620
|
+
_StyleUtil.default.handleStyleError(sourceCodeStyle, error.messages, this.options, position);
|
|
633
621
|
});
|
|
634
622
|
return [];
|
|
635
623
|
}
|
|
@@ -137,10 +137,6 @@ class StyleToTypescript {
|
|
|
137
137
|
* @param name
|
|
138
138
|
*/
|
|
139
139
|
addThorwLog(type, name, position, info) {
|
|
140
|
-
const {
|
|
141
|
-
onLog,
|
|
142
|
-
filePath
|
|
143
|
-
} = this.options;
|
|
144
140
|
const logLevel = name === ' ' || name === '>' ? _sharedUtils.Loglevel.WARN : _sharedUtils.Loglevel.THROW;
|
|
145
141
|
const message = info ? [`### StyleToTypescript ### Selector type unsupport`, {
|
|
146
142
|
word: info
|
|
@@ -149,12 +145,7 @@ class StyleToTypescript {
|
|
|
149
145
|
}, ',name:', {
|
|
150
146
|
word: name
|
|
151
147
|
}];
|
|
152
|
-
|
|
153
|
-
filePath,
|
|
154
|
-
position,
|
|
155
|
-
level: logLevel,
|
|
156
|
-
message
|
|
157
|
-
});
|
|
148
|
+
_StyleUtil.default.handleStyleError(logLevel, message, this.options, position);
|
|
158
149
|
}
|
|
159
150
|
translateAtrule(sourceNode) {
|
|
160
151
|
let targetNodes = [];
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IPosition, Loglevel, StyleMessage } from '@aiot-toolkit/shared-utils';
|
|
1
2
|
import { AtrulePrelude, CssNode, Declaration, Identifier, MediaFeature, MediaQuery, MediaQueryList, SelectorList, SyntaxParseError } from 'css-tree';
|
|
2
3
|
import IOptions from '../config/IOptions';
|
|
3
4
|
import { IImageFunction } from '../interface/IImageResource';
|
|
@@ -226,6 +227,6 @@ declare class StyleUtil {
|
|
|
226
227
|
* @returns
|
|
227
228
|
*/
|
|
228
229
|
static translateToNormalValue(value: any): any;
|
|
229
|
-
|
|
230
|
+
static handleStyleError(errorLevel: Loglevel, messages: StyleMessage[], options: IOptions, position: IPosition | undefined): void;
|
|
230
231
|
}
|
|
231
232
|
export default StyleUtil;
|
|
@@ -181,8 +181,7 @@ class StyleUtil {
|
|
|
181
181
|
}
|
|
182
182
|
const {
|
|
183
183
|
projectPath,
|
|
184
|
-
filePath
|
|
185
|
-
onLog
|
|
184
|
+
filePath
|
|
186
185
|
} = options;
|
|
187
186
|
const rootDir = compilerOption.sourceRoot;
|
|
188
187
|
const targetPath = _path.default.resolve(projectPath, rootDir);
|
|
@@ -196,12 +195,7 @@ class StyleUtil {
|
|
|
196
195
|
};
|
|
197
196
|
if (!assetsPath) {
|
|
198
197
|
// 警告,路径值不存在
|
|
199
|
-
|
|
200
|
-
filePath,
|
|
201
|
-
level: _sharedUtils.Loglevel.WARN,
|
|
202
|
-
position,
|
|
203
|
-
message: 'url value is null'
|
|
204
|
-
});
|
|
198
|
+
StyleUtil.handleStyleError(_sharedUtils.Loglevel.WARN, ['url value is null'], options, position);
|
|
205
199
|
return '';
|
|
206
200
|
}
|
|
207
201
|
// 1.
|
|
@@ -210,16 +204,11 @@ class StyleUtil {
|
|
|
210
204
|
if (_fsExtra.default.existsSync(_path.default.join(targetPath, assetsPath))) {
|
|
211
205
|
return assetsPath;
|
|
212
206
|
} else {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
word: `(${assetsAbsolutePath})`
|
|
219
|
-
}, 'to the current value ', {
|
|
220
|
-
word: `(${assetsPath})`
|
|
221
|
-
}, 'does not exist']
|
|
222
|
-
});
|
|
207
|
+
StyleUtil.handleStyleError(_sharedUtils.Loglevel.ERROR, ['The absolute path ', {
|
|
208
|
+
word: `(${assetsAbsolutePath})`
|
|
209
|
+
}, 'to the current value ', {
|
|
210
|
+
word: `(${assetsPath})`
|
|
211
|
+
}, 'does not exist'], options, position);
|
|
223
212
|
return '';
|
|
224
213
|
}
|
|
225
214
|
}
|
|
@@ -607,7 +596,7 @@ class StyleUtil {
|
|
|
607
596
|
break;
|
|
608
597
|
default:
|
|
609
598
|
const errorMessage = [`${firstName} is not a valid time value`];
|
|
610
|
-
StyleUtil.
|
|
599
|
+
StyleUtil.handleStyleError(_sharedUtils.Loglevel.THROW, errorMessage, options, position);
|
|
611
600
|
break;
|
|
612
601
|
}
|
|
613
602
|
}
|
|
@@ -648,7 +637,7 @@ class StyleUtil {
|
|
|
648
637
|
level: validInfoLevel
|
|
649
638
|
} = config.validate(sourceNode);
|
|
650
639
|
if (validMessages.length > 0) {
|
|
651
|
-
StyleUtil.
|
|
640
|
+
StyleUtil.handleStyleError(validInfoLevel, validMessages, options, sourceNode.position);
|
|
652
641
|
}
|
|
653
642
|
}
|
|
654
643
|
if (config?.translate) {
|
|
@@ -772,7 +761,7 @@ class StyleUtil {
|
|
|
772
761
|
}
|
|
773
762
|
return value;
|
|
774
763
|
}
|
|
775
|
-
static
|
|
764
|
+
static handleStyleError(errorLevel, messages, options, position) {
|
|
776
765
|
const {
|
|
777
766
|
onLog,
|
|
778
767
|
filePath,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/parser",
|
|
3
|
-
"version": "2.0.6-beta.
|
|
3
|
+
"version": "2.0.6-beta.5",
|
|
4
4
|
"description": "Parse the source code of aiot and convert it to the AST (Abstract Syntax Tree) of the target code.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiot",
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"test": "node ./__tests__/parser.test.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@aiot-toolkit/shared-utils": "2.0.6-beta.
|
|
23
|
+
"@aiot-toolkit/shared-utils": "2.0.6-beta.5",
|
|
24
24
|
"@babel/core": "^7.23.6",
|
|
25
25
|
"@babel/generator": "^7.24.10",
|
|
26
26
|
"@babel/parser": "^7.24.8",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"css-tree": "npm:aiot-css-tree@^2.3.1",
|
|
32
32
|
"csstree-validator": "^3.0.0",
|
|
33
33
|
"eslint": "^8.46.0",
|
|
34
|
-
"file-lane": "2.0.6-beta.
|
|
34
|
+
"file-lane": "2.0.6-beta.5",
|
|
35
35
|
"fs-extra": "^11.2.0",
|
|
36
36
|
"google-protobuf": "^3.21.2",
|
|
37
37
|
"less": "^4.2.0",
|
|
@@ -60,5 +60,5 @@
|
|
|
60
60
|
"@types/tinycolor2": "^1.4.6",
|
|
61
61
|
"babel-plugin-tester": "^11.0.4"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "d40eba7eacc8334bce1e952c39365513a171719e"
|
|
64
64
|
}
|