@aiot-toolkit/parser 2.0.6-beta.14 → 2.0.6-beta.15

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.
@@ -36,7 +36,7 @@ class ParserUtil {
36
36
  * @param offsetList
37
37
  */
38
38
  static getOffsetColumn(position, offsetList) {
39
- if (!offsetList?.length) {
39
+ if (!(offsetList !== null && offsetList !== void 0 && offsetList.length)) {
40
40
  return 0;
41
41
  }
42
42
  const {
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.STYLE_ATTRIBUTE_LIST = exports.STYLE_ATTRIBUTE_CONFIG = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var _ExtendedBoxStyle = _interopRequireDefault(require("../translate/vela/utils/ExtendedBoxStyle"));
9
10
  var _UxUtil = _interopRequireDefault(require("../utils/UxUtil"));
@@ -4,6 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
8
+ require("core-js/modules/web.url-search-params.delete.js");
9
+ require("core-js/modules/web.url-search-params.has.js");
10
+ require("core-js/modules/web.url-search-params.size.js");
7
11
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
12
  var _cssTree = _interopRequireWildcard(require("css-tree"));
9
13
  var _lodash = _interopRequireDefault(require("lodash"));
@@ -124,7 +128,8 @@ class StyleParser {
124
128
  * @returns
125
129
  */
126
130
  getAlias() {
127
- return _sharedUtils.CommonUtil.requireModule(_path.default.join(this.options.projectPath, this.QUICKAPP_CONFIG))?.webpack?.resolve?.alias || {};
131
+ var _CommonUtil$requireMo;
132
+ return ((_CommonUtil$requireMo = _sharedUtils.CommonUtil.requireModule(_path.default.join(this.options.projectPath, this.QUICKAPP_CONFIG))) === null || _CommonUtil$requireMo === void 0 || (_CommonUtil$requireMo = _CommonUtil$requireMo.webpack) === null || _CommonUtil$requireMo === void 0 || (_CommonUtil$requireMo = _CommonUtil$requireMo.resolve) === null || _CommonUtil$requireMo === void 0 ? void 0 : _CommonUtil$requireMo.alias) || {};
128
133
  }
129
134
  /**
130
135
  * 将Less样式转为CSS
@@ -161,8 +166,8 @@ class StyleParser {
161
166
  });
162
167
  reject(`### lessToCss ### ${error}`);
163
168
  } else {
164
- CSSCode = output?.css ? output.css : '';
165
- if (output?.map) {
169
+ CSSCode = output !== null && output !== void 0 && output.css ? output.css : '';
170
+ if (output !== null && output !== void 0 && output.map) {
166
171
  this.nodeMap = output.map;
167
172
  this.isCss && (this.isCss = false);
168
173
  }
@@ -269,7 +274,7 @@ class StyleParser {
269
274
  onLog({
270
275
  level: _sharedUtils.Loglevel.THROW,
271
276
  filePath,
272
- message: `### Css ### ${error?.toString() || 'unknown error'}`
277
+ message: `### Css ### ${(error === null || error === void 0 ? void 0 : error.toString()) || 'unknown error'}`
273
278
  });
274
279
  }
275
280
  }
@@ -413,8 +418,9 @@ class StyleParser {
413
418
  if (_StyleUtil.default.isSelectorList(sourceNode)) {
414
419
  sourceNode.children.toArray().forEach(node => {
415
420
  if ('children' in node) {
421
+ var _node$children;
416
422
  let childResult = [];
417
- node.children?.toArray().forEach(childNode => {
423
+ (_node$children = node.children) === null || _node$children === void 0 || _node$children.toArray().forEach(childNode => {
418
424
  childResult.push({
419
425
  type: childNode.type,
420
426
  name: _StyleUtil.default.generateNodename(childNode)
@@ -526,7 +532,7 @@ class StyleParser {
526
532
  // 警告:不能为空
527
533
  onLog({
528
534
  level: _sharedUtils.Loglevel.WARN,
529
- filePath: tempPosition?.source || filePath,
535
+ filePath: (tempPosition === null || tempPosition === void 0 ? void 0 : tempPosition.source) || filePath,
530
536
  position: tempPosition,
531
537
  message: ['The value in', {
532
538
  word: 'url'
@@ -594,8 +600,7 @@ class StyleParser {
594
600
  }
595
601
  return targetList;
596
602
  }
597
- printError(errorType) {
598
- let errors = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
603
+ printError(errorType, errors = []) {
599
604
  let isParserError = errorType === 'parserError';
600
605
  let sourceCodeStyle = _sharedUtils.Loglevel.WARN;
601
606
  if (isParserError) {
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = exports.TemplateValueType = void 0;
7
+ require("core-js/modules/es.error.cause.js");
8
+ require("core-js/modules/es.array.push.js");
7
9
  let TemplateValueType = exports.TemplateValueType = /*#__PURE__*/function (TemplateValueType) {
8
10
  TemplateValueType[TemplateValueType["CHAR"] = 1] = "CHAR";
9
11
  TemplateValueType[TemplateValueType["CODE"] = 2] = "CODE";
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var parse5 = _interopRequireWildcard(require("aiot-parse5"));
9
10
  var _path = _interopRequireDefault(require("path"));
@@ -25,6 +26,7 @@ class UxParser {
25
26
  this.collectImageResource = collectImageResource;
26
27
  }
27
28
  async parser() {
29
+ var _childNode$childNodes, _childNode$sourceCode;
28
30
  const content = this.options.content;
29
31
  const fileName = _path.default.basename(this.options.filePath);
30
32
  const ast = {
@@ -61,7 +63,7 @@ class UxParser {
61
63
  case 'script':
62
64
  // 存储script正文的偏移行数
63
65
  this.options.scriptOffsetLine = 0;
64
- if (childNode?.childNodes?.[0]?.sourceCodeLocation) {
66
+ if (childNode !== null && childNode !== void 0 && (_childNode$childNodes = childNode.childNodes) !== null && _childNode$childNodes !== void 0 && (_childNode$childNodes = _childNode$childNodes[0]) !== null && _childNode$childNodes !== void 0 && _childNode$childNodes.sourceCodeLocation) {
65
67
  this.options.scriptOffsetLine = childNode.childNodes[0].sourceCodeLocation.startLine || 0;
66
68
  }
67
69
  const scriptContent = parse5.serialize(childNode);
@@ -79,7 +81,7 @@ class UxParser {
79
81
  // 转换全局变量为符合lang类型的字符串
80
82
  const globalStyle = _UxUtil.default.convertGlobalJson(this.globalVar, langType);
81
83
  // 解析CSS 转为 js格式的内容
82
- const cssParserResult = await new _StyleParser.default(this.options, this.compilerOption, this.collectImageResource, childNode.sourceCodeLocation?.startLine || 0).parser(`${cssContent}\n${globalStyle}`, cssFileName);
84
+ const cssParserResult = await new _StyleParser.default(this.options, this.compilerOption, this.collectImageResource, ((_childNode$sourceCode = childNode.sourceCodeLocation) === null || _childNode$sourceCode === void 0 ? void 0 : _childNode$sourceCode.startLine) || 0).parser(`${cssContent}\n${globalStyle}`, cssFileName);
83
85
  // 多Style标签(TODO: 应该不支持多style标签)
84
86
  ast.style.styleContent.push(...cssParserResult.ast.styleContent);
85
87
  ast.style.content = parse5.serialize(childNode);
@@ -98,6 +100,7 @@ class UxParser {
98
100
  };
99
101
  }
100
102
  parserSyncWithoutStyle() {
103
+ var _childNode$childNodes2;
101
104
  const content = this.options.content;
102
105
  const fileName = _path.default.basename(this.options.filePath);
103
106
  const ast = {
@@ -137,7 +140,7 @@ class UxParser {
137
140
  case 'script':
138
141
  // 存储script正文的偏移行数
139
142
  this.options.scriptOffsetLine = 0;
140
- if (childNode?.childNodes?.[0]?.sourceCodeLocation) {
143
+ if (childNode !== null && childNode !== void 0 && (_childNode$childNodes2 = childNode.childNodes) !== null && _childNode$childNodes2 !== void 0 && (_childNode$childNodes2 = _childNode$childNodes2[0]) !== null && _childNode$childNodes2 !== void 0 && _childNode$childNodes2.sourceCodeLocation) {
141
144
  this.options.scriptOffsetLine = childNode.childNodes[0].sourceCodeLocation.startLine || 0;
142
145
  }
143
146
  const scriptContent = parse5.serialize(childNode);
@@ -233,10 +236,11 @@ class UxParser {
233
236
  const templateChildNodes = templateNode.content.childNodes;
234
237
  const elements = templateChildNodes.filter(node => _TemplateUtil.default.isElement(node));
235
238
  if (elements.length !== 1) {
239
+ var _templateNode$sourceC;
236
240
  onLog({
237
241
  level: _sharedUtils.Loglevel.THROW,
238
242
  filePath,
239
- position: _TemplateUtil.default.parse5LocationToPosition(templateNode.sourceCodeLocation?.startTag),
243
+ position: _TemplateUtil.default.parse5LocationToPosition((_templateNode$sourceC = templateNode.sourceCodeLocation) === null || _templateNode$sourceC === void 0 ? void 0 : _templateNode$sourceC.startTag),
240
244
  message: [{
241
245
  word: '<template>'
242
246
  }, `There are`, {
@@ -296,9 +300,10 @@ class UxParser {
296
300
  ...sourceNode
297
301
  });
298
302
  } else {
303
+ var _sourceNode$sourceCod;
299
304
  onLog({
300
305
  filePath: this.options.filePath,
301
- position: _TemplateUtil.default.parse5LocationToPosition(sourceNode.sourceCodeLocation?.startTag),
306
+ position: _TemplateUtil.default.parse5LocationToPosition((_sourceNode$sourceCod = sourceNode.sourceCodeLocation) === null || _sourceNode$sourceCod === void 0 ? void 0 : _sourceNode$sourceCod.startTag),
302
307
  level: _sharedUtils.Loglevel.ERROR,
303
308
  message: ['### uxParser ### import missing', {
304
309
  word: `name or src`
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var _lodash = _interopRequireDefault(require("lodash"));
9
10
  var _ParserUtil = _interopRequireDefault(require("../../../utils/ParserUtil"));
@@ -20,7 +21,7 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
20
21
  */
21
22
  class TemplateToTypescript {
22
23
  _mapList = [];
23
- elementUtil = (() => new _ElementConfigUtil.default(_ElementConfig.default))();
24
+ elementUtil = new _ElementConfigUtil.default(_ElementConfig.default);
24
25
  constructor(options, compilerOption, importList) {
25
26
  this.options = options;
26
27
  this.compilerOption = compilerOption;
@@ -100,7 +101,7 @@ class TemplateToTypescript {
100
101
  } = node;
101
102
  const translateList = [new _ForTranslate.default(this.options, this.compilerOption), new _IfTranslate.default(this.options, this.compilerOption)];
102
103
  const elementConfig = this.elementUtil.getElementConfig(tagName);
103
- const effectType = elementConfig?.aliasName || tagName;
104
+ const effectType = (elementConfig === null || elementConfig === void 0 ? void 0 : elementConfig.aliasName) || tagName;
104
105
  // 1.a
105
106
  const result = {
106
107
  type: `'${effectType}'`,
@@ -174,7 +175,8 @@ class TemplateToTypescript {
174
175
  if (effectChildNodes.length) {
175
176
  result.children = [];
176
177
  for (const item of effectChildNodes) {
177
- result.children?.push(await this.createTargetNode(item, existingIdentifiers));
178
+ var _result$children;
179
+ (_result$children = result.children) === null || _result$children === void 0 || _result$children.push(await this.createTargetNode(item, existingIdentifiers));
178
180
  }
179
181
  }
180
182
  return result;
@@ -239,9 +241,10 @@ class TemplateToTypescript {
239
241
  childNodes
240
242
  } = node;
241
243
  let result = attrs.map(item => {
244
+ var _node$sourceCodeLocat;
242
245
  return {
243
246
  ...item,
244
- nameLocation: _TemplateUtil.default.parse5LocationToPosition(node.sourceCodeLocation?.attrs?.[item.name])
247
+ nameLocation: _TemplateUtil.default.parse5LocationToPosition((_node$sourceCodeLocat = node.sourceCodeLocation) === null || _node$sourceCodeLocat === void 0 || (_node$sourceCodeLocat = _node$sourceCodeLocat.attrs) === null || _node$sourceCodeLocat === void 0 ? void 0 : _node$sourceCodeLocat[item.name])
245
248
  };
246
249
  });
247
250
 
@@ -139,7 +139,7 @@ class UxToTypescript {
139
139
  style
140
140
  } = data;
141
141
  const scriptValue = this.wrapScript(script);
142
- return [imports.join('\n'), [`const $style$ = ${JSON.stringify(style)}`, `const $template$ = ${template?.getFullText() || `''`}`].join('\n'), `const $script$=${scriptValue || 'null'}`, `module.exports = function ($app_require$, $app_exports$, $app_module$) {
142
+ return [imports.join('\n'), [`const $style$ = ${JSON.stringify(style)}`, `const $template$ = ${(template === null || template === void 0 ? void 0 : template.getFullText()) || `''`}`].join('\n'), `const $script$=${scriptValue || 'null'}`, `module.exports = function ($app_require$, $app_exports$, $app_module$) {
143
143
  ${this.ruleScript(Boolean(scriptValue))}
144
144
  $app_module$.exports.template = $template$
145
145
  $app_module$.exports.style = $style$;
@@ -170,7 +170,7 @@ class UxToTypescript {
170
170
  return '';
171
171
  }
172
172
  wrapScript(script) {
173
- const code = script?.getFullText();
173
+ const code = script === null || script === void 0 ? void 0 : script.getFullText();
174
174
  const {
175
175
  fileType
176
176
  } = this.options;
@@ -54,9 +54,10 @@ class ForTranslate {
54
54
  indexNode
55
55
  } = _CfTranslate.default.extractForNodes(forAttribute, this.options);
56
56
  if (!listNode) {
57
+ var _node$sourceCodeLocat;
57
58
  onLog({
58
59
  filePath,
59
- position: _TemplateUtil.default.parse5LocationToPosition(node.sourceCodeLocation?.attrs?.[this.KEY]),
60
+ position: _TemplateUtil.default.parse5LocationToPosition((_node$sourceCodeLocat = node.sourceCodeLocation) === null || _node$sourceCodeLocat === void 0 || (_node$sourceCodeLocat = _node$sourceCodeLocat.attrs) === null || _node$sourceCodeLocat === void 0 ? void 0 : _node$sourceCodeLocat[this.KEY]),
60
61
  level: _sharedUtils.Loglevel.THROW,
61
62
  message: [{
62
63
  word: 'list'
@@ -4,6 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
8
+ require("core-js/modules/es.set.difference.v2.js");
9
+ require("core-js/modules/es.set.intersection.v2.js");
10
+ require("core-js/modules/es.set.is-disjoint-from.v2.js");
11
+ require("core-js/modules/es.set.is-subset-of.v2.js");
12
+ require("core-js/modules/es.set.is-superset-of.v2.js");
13
+ require("core-js/modules/es.set.symmetric-difference.v2.js");
14
+ require("core-js/modules/es.set.union.v2.js");
7
15
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
16
  var babel = _interopRequireWildcard(require("@babel/core"));
9
17
  var _path = _interopRequireDefault(require("path"));
@@ -19,9 +27,8 @@ const BabelPreset = require('@babel/preset-env');
19
27
  * ScriptToTypescript
20
28
  */
21
29
  class ScriptToTypescript {
22
- _systemFeatures = (() => new Set())();
23
- constructor(options, compilerOption, context) {
24
- let disableCheckCode = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
30
+ _systemFeatures = new Set();
31
+ constructor(options, compilerOption, context, disableCheckCode = false) {
25
32
  this.options = options;
26
33
  this.compilerOption = compilerOption;
27
34
  this.context = context;
@@ -96,14 +103,15 @@ class ScriptToTypescript {
96
103
  }]],
97
104
  plugins
98
105
  });
99
- return babelResult?.code || '';
106
+ return (babelResult === null || babelResult === void 0 ? void 0 : babelResult.code) || '';
100
107
  } catch (error) {
101
108
  const loc = error.loc;
102
109
  const babelError = error;
103
110
  let position = undefined;
104
111
  let message = babelError.message;
105
112
  if (loc) {
106
- const offsetLine = (sourceTree.sourceCodeLocation?.startLine || 0) - 1;
113
+ var _sourceTree$sourceCod;
114
+ const offsetLine = (((_sourceTree$sourceCod = sourceTree.sourceCodeLocation) === null || _sourceTree$sourceCod === void 0 ? void 0 : _sourceTree$sourceCod.startLine) || 0) - 1;
107
115
  const startLine = loc.line + offsetLine;
108
116
  const startColumn = loc.column;
109
117
  // babel 错误信息中包含行列信息,需要替换
@@ -195,9 +203,10 @@ class ScriptToTypescript {
195
203
  }
196
204
  }
197
205
  }).lintText(code);
198
- if (lintResult?.length) {
206
+ if (lintResult !== null && lintResult !== void 0 && lintResult.length) {
207
+ var _sourceTree$sourceCod2;
199
208
  const result = [];
200
- const offsetLine = (sourceTree.sourceCodeLocation?.startLine || 0) - 1;
209
+ const offsetLine = (((_sourceTree$sourceCod2 = sourceTree.sourceCodeLocation) === null || _sourceTree$sourceCod2 === void 0 ? void 0 : _sourceTree$sourceCod2.startLine) || 0) - 1;
201
210
  lintResult.forEach(item => {
202
211
  item.messages.forEach(message => {
203
212
  result.push({
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var _StyleSelectorType = require("../../enum/StyleSelectorType");
9
10
  var _StyleUtil = _interopRequireDefault(require("../../utils/StyleUtil"));
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var _tsMorph = require("ts-morph");
9
10
  var _ElementConfig = _interopRequireDefault(require("../../config/vela/ElementConfig"));
@@ -21,14 +22,14 @@ const STATIC_NAME = 'static';
21
22
  * TemplateToTypescript
22
23
  */
23
24
  class TemplateToTypescript {
24
- project = (() => new _tsMorph.Project({
25
+ project = new _tsMorph.Project({
25
26
  useInMemoryFileSystem: true,
26
27
  manipulationSettings: {
27
28
  indentationText: _tsMorph.IndentationText.TwoSpaces
28
29
  }
29
- }))();
30
+ });
30
31
  _mapList = [];
31
- elementConfigUtil = (() => new _ElementConfigUtil.default(_ElementConfig.default))();
32
+ elementConfigUtil = new _ElementConfigUtil.default(_ElementConfig.default);
32
33
  /**
33
34
  *
34
35
  * @param importList 组件列表
@@ -115,9 +116,10 @@ class TemplateToTypescript {
115
116
  nodeName
116
117
  } = node;
117
118
  let result = attrs.map(item => {
119
+ var _node$sourceCodeLocat;
118
120
  return {
119
121
  ...item,
120
- nameLocation: _TemplateUtil.default.parse5LocationToPosition(node.sourceCodeLocation?.attrs?.[item.name])
122
+ nameLocation: _TemplateUtil.default.parse5LocationToPosition((_node$sourceCodeLocat = node.sourceCodeLocation) === null || _node$sourceCodeLocat === void 0 || (_node$sourceCodeLocat = _node$sourceCodeLocat.attrs) === null || _node$sourceCodeLocat === void 0 ? void 0 : _node$sourceCodeLocat[item.name])
121
123
  };
122
124
  });
123
125
  // 1.a
@@ -175,10 +177,10 @@ class TemplateToTypescript {
175
177
  item.name = attributeName;
176
178
 
177
179
  // 4.a
178
- const effectDecorator = hasStaticAttribute ? decorator?.filter(item => item !== STATIC_NAME) : decorator;
180
+ const effectDecorator = hasStaticAttribute ? decorator === null || decorator === void 0 ? void 0 : decorator.filter(item => item !== STATIC_NAME) : decorator;
179
181
 
180
182
  // 4.b
181
- if (effectDecorator?.length && !excludesAttributes.includes(attributeName)) {
183
+ if (effectDecorator !== null && effectDecorator !== void 0 && effectDecorator.length && !excludesAttributes.includes(attributeName)) {
182
184
  const modiferName = attributeName;
183
185
  modifiers[modiferName] = Object.fromEntries(effectDecorator.map(item => [item, true]));
184
186
  }
@@ -229,7 +231,7 @@ class TemplateToTypescript {
229
231
  callerName: '__ce__',
230
232
  tag: {
231
233
  name: 'span',
232
- location: _TemplateUtil.default.parse5LocationToPosition(sourceCodeLocation?.startTag)
234
+ location: _TemplateUtil.default.parse5LocationToPosition(sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag)
233
235
  },
234
236
  attributes: [{
235
237
  name: 'value',
@@ -252,7 +254,7 @@ class TemplateToTypescript {
252
254
  word: nodeName
253
255
  }, `unsupport text as child, replace as`, {
254
256
  word: `<text>${this.templateUtil.getTextContent(textChildren[0], this.elementConfigUtil)}</text>`
255
- }, docHelp?.createWidgetReferenceMessage({
257
+ }, docHelp === null || docHelp === void 0 ? void 0 : docHelp.createWidgetReferenceMessage({
256
258
  componentName: 'text'
257
259
  })],
258
260
  filePath: this.options.filePath,
@@ -264,7 +266,7 @@ class TemplateToTypescript {
264
266
  // 提取标识符,用于创建节点函数
265
267
  const currentIdentifiers = this.getIdentifiersFromNode(node);
266
268
  const allIdentifiers = [...(identifiers || []), ...currentIdentifiers];
267
- const hasElementChildren = childNodes?.some(item => _TemplateUtil.default.isElement(item));
269
+ const hasElementChildren = childNodes === null || childNodes === void 0 ? void 0 : childNodes.some(item => _TemplateUtil.default.isElement(item));
268
270
  let effectChildNodes = childNodes ? childNodes.filter(item => {
269
271
  // 当前元素
270
272
  // 1. “允许文本子节点,且有普通元素”,则分别处理普通子元素和文本子元素,例如: `<text>aaa<span>abc</span></text>`,需要分别处理 aaa和 <span>abc</span>
@@ -286,12 +288,13 @@ class TemplateToTypescript {
286
288
  callerName: name,
287
289
  tag: {
288
290
  name: nodeName,
289
- location: _TemplateUtil.default.parse5LocationToPosition(sourceCodeLocation?.startTag)
291
+ location: _TemplateUtil.default.parse5LocationToPosition(sourceCodeLocation === null || sourceCodeLocation === void 0 ? void 0 : sourceCodeLocation.startTag)
290
292
  },
291
293
  attributes: attributes.map(item => {
294
+ var _sourceCodeLocation$a;
292
295
  return {
293
296
  ...item,
294
- nameLocation: item.nameLocation || _TemplateUtil.default.parse5LocationToPosition(sourceCodeLocation?.attrs?.[item.name])
297
+ nameLocation: item.nameLocation || _TemplateUtil.default.parse5LocationToPosition(sourceCodeLocation === null || sourceCodeLocation === void 0 || (_sourceCodeLocation$a = sourceCodeLocation.attrs) === null || _sourceCodeLocation$a === void 0 ? void 0 : _sourceCodeLocation$a[item.name])
295
298
  };
296
299
  }),
297
300
  children,
@@ -369,7 +372,7 @@ class TemplateToTypescript {
369
372
  const {
370
373
  importList
371
374
  } = this;
372
- return importList?.map(item => item.toLowerCase()).includes(componentName.toLowerCase());
375
+ return importList === null || importList === void 0 ? void 0 : importList.map(item => item.toLowerCase()).includes(componentName.toLowerCase());
373
376
  }
374
377
 
375
378
  /**
@@ -381,12 +384,13 @@ class TemplateToTypescript {
381
384
  * @returns
382
385
  */
383
386
  async createElementWrap(node, elementExpression, infomation, identifiers) {
387
+ var _this$compilerOption;
384
388
  // 1
385
389
  if (_TemplateUtil.default.isText(node)) {
386
390
  return elementExpression;
387
391
  }
388
392
  const translateList = [new _CbTranslate.default(this.options, this.compilerOption, infomation), new _CfTranslate.default(this.options, this.compilerOption), new _CiTranslate.default(this.options, this.compilerOption)];
389
- const params = this.compilerOption?.enableProtobuf ? ['aiot'].join(',') : '';
393
+ const params = (_this$compilerOption = this.compilerOption) !== null && _this$compilerOption !== void 0 && _this$compilerOption.enableProtobuf ? ['aiot'].join(',') : '';
390
394
  let result = elementExpression;
391
395
  for (let item of translateList) {
392
396
  if (item.match(node)) {
@@ -436,7 +440,7 @@ class TemplateToTypescript {
436
440
  result.hasStaticAttribute = attributeName.toLowerCase() === STATIC_NAME;
437
441
  }
438
442
  if (!result.hasStaticDecorator) {
439
- result.hasStaticDecorator = attributeName !== STATIC_NAME && Boolean(decorator?.includes(STATIC_NAME));
443
+ result.hasStaticDecorator = attributeName !== STATIC_NAME && Boolean(decorator === null || decorator === void 0 ? void 0 : decorator.includes(STATIC_NAME));
440
444
  }
441
445
  if (!result.hasEvent) {
442
446
  result.hasEvent = _TemplateUtil.default.isEventAttribute(attributeName);
@@ -4,10 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.set.difference.v2.js");
8
+ require("core-js/modules/es.set.intersection.v2.js");
9
+ require("core-js/modules/es.set.is-disjoint-from.v2.js");
10
+ require("core-js/modules/es.set.is-subset-of.v2.js");
11
+ require("core-js/modules/es.set.is-superset-of.v2.js");
12
+ require("core-js/modules/es.set.symmetric-difference.v2.js");
13
+ require("core-js/modules/es.set.union.v2.js");
7
14
  /**
8
15
  * TranslateCache
9
16
  */
10
17
  class TranslateCache {
11
- featureCache = (() => new Set())();
18
+ featureCache = new Set();
12
19
  }
13
20
  var _default = exports.default = TranslateCache;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = e2e;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var t = _interopRequireWildcard(require("@babel/types"));
8
9
  var parser = _interopRequireWildcard(require("@babel/parser"));
9
10
  var _path = _interopRequireDefault(require("path"));
@@ -21,10 +22,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
21
22
  function e2e() {
22
23
  return {
23
24
  visitor: {
24
- ExportDefaultDeclaration(path, _ref) {
25
- let {
26
- opts
27
- } = _ref;
25
+ ExportDefaultDeclaration(path, {
26
+ opts
27
+ }) {
28
28
  const opts2 = opts;
29
29
  const options = opts2.options;
30
30
  switch (options.fileType) {
@@ -114,6 +114,7 @@ function addPageTestCode(path, opts) {
114
114
  }
115
115
  }
116
116
  function getTestcaseConfig(filePath, opts, e2eConfig) {
117
+ var _e2eConfig$testcases;
117
118
  const {
118
119
  projectPath
119
120
  } = opts.options;
@@ -122,7 +123,7 @@ function getTestcaseConfig(filePath, opts, e2eConfig) {
122
123
  } = opts.compilerOption;
123
124
  const relativeSrc = _path.default.relative(_path.default.join(projectPath, sourceRoot || ''), filePath);
124
125
  const pageName = _path.default.dirname(relativeSrc).replace(/\\/g, _path.default.posix.sep);
125
- return e2eConfig.testcases?.find(item => item.name === pageName);
126
+ return (_e2eConfig$testcases = e2eConfig.testcases) === null || _e2eConfig$testcases === void 0 ? void 0 : _e2eConfig$testcases.find(item => item.name === pageName);
126
127
  }
127
128
 
128
129
  /**
@@ -15,10 +15,9 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
15
15
  function translateRequire() {
16
16
  return {
17
17
  visitor: {
18
- CallExpression(path, _ref) {
19
- let {
20
- opts
21
- } = _ref;
18
+ CallExpression(path, {
19
+ opts
20
+ }) {
22
21
  const {
23
22
  node
24
23
  } = path;
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = startPage;
7
+ require("core-js/modules/web.url.parse.js");
7
8
  var _url = _interopRequireDefault(require("url"));
8
9
  var _BabelUtil = _interopRequireDefault(require("../../../utils/BabelUtil"));
9
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.eventAttributeTranslate = exports.defaultAttributeTranslate = exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var _tsMorph = require("ts-morph");
9
10
  var _ParserUtil = _interopRequireDefault(require("../../../../utils/ParserUtil"));
@@ -45,6 +46,7 @@ const ATTRIBUTE_CONFIG = {
45
46
  return global.$translateStyle$(${result})
46
47
  }`;
47
48
  } else {
49
+ var _styleResult$targetTr;
48
50
  const logs = [];
49
51
  const onLog = log => {
50
52
  logs.push(log);
@@ -74,7 +76,7 @@ const ATTRIBUTE_CONFIG = {
74
76
  option.onLog(log);
75
77
  });
76
78
  }
77
- const value = styleResult.targetTree?.[0]?.[1];
79
+ const value = (_styleResult$targetTr = styleResult.targetTree) === null || _styleResult$targetTr === void 0 || (_styleResult$targetTr = _styleResult$targetTr[0]) === null || _styleResult$targetTr === void 0 ? void 0 : _styleResult$targetTr[1];
78
80
  return JSON.stringify(value);
79
81
  }
80
82
  }
@@ -106,8 +108,7 @@ const ATTRIBUTE_CONFIG = {
106
108
  * @param disabledWrap 是否禁用函数包裹。因为普通属性不用函数无法动态响应,而 for 的 list 属性设置函数又报错;所以这里临时加一个参数,在生成__list__的地方手动设置为 true
107
109
  * @returns
108
110
  */
109
- const defaultAttributeTranslate = function (value) {
110
- let disabledWrap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
111
+ const defaultAttributeTranslate = (value, disabledWrap = false) => {
111
112
  if (disabledWrap) {
112
113
  return value;
113
114
  }
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var _generator = _interopRequireDefault(require("@babel/generator"));
9
10
  var traverse = _interopRequireWildcard(require("@babel/traverse"));
@@ -60,8 +61,8 @@ class TemplateUtil {
60
61
  return m.toUpperCase();
61
62
  });
62
63
  };
63
- const separateModelValue = params?.separateModelValue;
64
- const nameToCamel = params?.nameToCamel;
64
+ const separateModelValue = params === null || params === void 0 ? void 0 : params.separateModelValue;
65
+ const nameToCamel = params === null || params === void 0 ? void 0 : params.nameToCamel;
65
66
  const result = {};
66
67
  for (const item of attributes) {
67
68
  const {
@@ -109,7 +110,7 @@ class TemplateUtil {
109
110
  */
110
111
  translateAttributeName(name) {
111
112
  const config = _AttributeConfig.default[name];
112
- if (config?.aliasName) {
113
+ if (config !== null && config !== void 0 && config.aliasName) {
113
114
  return config.aliasName;
114
115
  }
115
116
  if (TemplateUtil.isEventAttribute(name)) {
@@ -129,8 +130,7 @@ class TemplateUtil {
129
130
  * @param attribute
130
131
  * @returns
131
132
  */
132
- async translateAttributeValue(attribute, identifiers) {
133
- let disabledWrap = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
133
+ async translateAttributeValue(attribute, identifiers, disabledWrap = false) {
134
134
  let {
135
135
  name,
136
136
  value,
@@ -196,7 +196,7 @@ class TemplateUtil {
196
196
  onLog,
197
197
  filePath
198
198
  } = this.option;
199
- const nameLocation = ownerNode?.nameLocation;
199
+ const nameLocation = ownerNode === null || ownerNode === void 0 ? void 0 : ownerNode.nameLocation;
200
200
 
201
201
  /**
202
202
  * 遍历标识符,如果满足以下条件,不加前缀
@@ -217,7 +217,7 @@ class TemplateUtil {
217
217
  return code;
218
218
  }
219
219
  const ast = types.file(types.program([types.expressionStatement(expression)]));
220
- const bodyNode = ast?.program.body[0];
220
+ const bodyNode = ast === null || ast === void 0 ? void 0 : ast.program.body[0];
221
221
  if (ast) {
222
222
  traverse.default(ast, {
223
223
  Identifier(path) {
@@ -366,7 +366,7 @@ class TemplateUtil {
366
366
  return `validateElement ${tag} error`;
367
367
  }
368
368
  const elementConfig = getElementConfig(tag.name);
369
- const effectTag = elementConfig?.aliasName || tag.name;
369
+ const effectTag = (elementConfig === null || elementConfig === void 0 ? void 0 : elementConfig.aliasName) || tag.name;
370
370
  const {
371
371
  globalInstance,
372
372
  dataInstance,
@@ -396,9 +396,10 @@ class TemplateUtil {
396
396
  } = node;
397
397
  const target = attrs.find(item => TemplateUtil.parseAttributeName(item.name).attributeName.toLowerCase() === name);
398
398
  if (target) {
399
+ var _node$sourceCodeLocat;
399
400
  return {
400
401
  ...target,
401
- nameLocation: TemplateUtil.parse5LocationToPosition(node.sourceCodeLocation?.attrs?.[target.name])
402
+ nameLocation: TemplateUtil.parse5LocationToPosition((_node$sourceCodeLocat = node.sourceCodeLocation) === null || _node$sourceCodeLocat === void 0 || (_node$sourceCodeLocat = _node$sourceCodeLocat.attrs) === null || _node$sourceCodeLocat === void 0 ? void 0 : _node$sourceCodeLocat[target.name])
402
403
  };
403
404
  }
404
405
  }
@@ -441,7 +442,8 @@ class TemplateUtil {
441
442
  const forceDynamicList = ['if', 'for'];
442
443
  let result = TemplateUtil.isEventAttribute(attributeName) || forceDynamicList.includes(attributeName.toLowerCase());
443
444
  if (!result) {
444
- const config = getElementConfig(nodeName)?.attributes?.[attributeName];
445
+ var _getElementConfig;
446
+ const config = (_getElementConfig = getElementConfig(nodeName)) === null || _getElementConfig === void 0 || (_getElementConfig = _getElementConfig.attributes) === null || _getElementConfig === void 0 ? void 0 : _getElementConfig[attributeName];
445
447
  if (config && config.forceDynamic) {
446
448
  result = true;
447
449
  }
@@ -569,7 +571,7 @@ class TemplateUtil {
569
571
  if (attribute) {
570
572
  const {
571
573
  decorator
572
- } = TemplateUtil.parseAttributeName(attribute?.name);
574
+ } = TemplateUtil.parseAttributeName(attribute === null || attribute === void 0 ? void 0 : attribute.name);
573
575
  if (decorator) {
574
576
  return {
575
577
  [decoratorName]: Object.fromEntries(decorator.map(item => [item, true]))
@@ -592,9 +594,9 @@ class TemplateUtil {
592
594
  preConditions,
593
595
  selfCondition
594
596
  } = condition;
595
- const result = (preConditions?.map(item => this.translateTemplateValue(TemplateUtil.toDynamicValue(item.value), identifiers, item).result).map(item => {
597
+ const result = ((preConditions === null || preConditions === void 0 ? void 0 : preConditions.map(item => this.translateTemplateValue(TemplateUtil.toDynamicValue(item.value), identifiers, item).result).map(item => {
596
598
  return `!(${item})`;
597
- }) || []).concat(selfCondition ? [this.translateTemplateValue(TemplateUtil.toDynamicValue(selfCondition.value), identifiers, selfCondition).result] : []).map(item => `(${item})`).join(' && ');
599
+ })) || []).concat(selfCondition ? [this.translateTemplateValue(TemplateUtil.toDynamicValue(selfCondition.value), identifiers, selfCondition).result] : []).map(item => `(${item})`).join(' && ');
598
600
  return result;
599
601
  }
600
602
 
@@ -664,9 +666,10 @@ class TemplateUtil {
664
666
  const itemElse = TemplateUtil.getAttribute(element, 'else');
665
667
  // 2
666
668
  if (!itemIf && !itemElIf) {
669
+ var _element$sourceCodeLo;
667
670
  onLog({
668
671
  filePath,
669
- position: TemplateUtil.parse5LocationToPosition(element.sourceCodeLocation?.startTag),
672
+ position: TemplateUtil.parse5LocationToPosition((_element$sourceCodeLo = element.sourceCodeLocation) === null || _element$sourceCodeLo === void 0 ? void 0 : _element$sourceCodeLo.startTag),
670
673
  level: _sharedUtils.Loglevel.THROW,
671
674
  message: [{
672
675
  word: element.nodeName
@@ -676,10 +679,11 @@ class TemplateUtil {
676
679
 
677
680
  // 3
678
681
  if (i === 0 && !itemIf) {
682
+ var _element$sourceCodeLo2;
679
683
  onLog({
680
684
  level: _sharedUtils.Loglevel.THROW,
681
685
  filePath,
682
- position: TemplateUtil.parse5LocationToPosition(element.sourceCodeLocation?.startTag),
686
+ position: TemplateUtil.parse5LocationToPosition((_element$sourceCodeLo2 = element.sourceCodeLocation) === null || _element$sourceCodeLo2 === void 0 ? void 0 : _element$sourceCodeLo2.startTag),
683
687
  message: [`the first element requires`, {
684
688
  word: 'if'
685
689
  }, `attribute`]
@@ -804,7 +808,7 @@ class TemplateUtil {
804
808
  const parsedValues = new _TemplateValueParser.default().parse(value);
805
809
  const firstParsedValue = parsedValues[0];
806
810
  // 2.1
807
- if (firstParsedValue?.type === _TemplateValueParser.TemplateValueType.CHAR) {
811
+ if ((firstParsedValue === null || firstParsedValue === void 0 ? void 0 : firstParsedValue.type) === _TemplateValueParser.TemplateValueType.CHAR) {
808
812
  const srcPath = _path.default.join(projectPath, sourceRoot);
809
813
  const resourcePath = _path.default.join(_path.default.dirname(filePath), firstParsedValue.value);
810
814
  if (!resourcePath.startsWith(srcPath)) {
@@ -33,18 +33,20 @@ class CfTranslate {
33
33
  const attribute = _TemplateUtil.default.getAttribute(node, this.KEY);
34
34
  const tid = _TemplateUtil.default.getAttribute(node, 'tid');
35
35
  if (attribute) {
36
+ var _node$sourceCodeLocat;
36
37
  const {
37
38
  itemNode,
38
39
  indexNode,
39
40
  listNode
40
41
  } = CfTranslate.extractForNodes({
41
42
  ...attribute,
42
- nameLocation: _TemplateUtil.default.parse5LocationToPosition(node.sourceCodeLocation?.attrs?.[this.KEY])
43
+ nameLocation: _TemplateUtil.default.parse5LocationToPosition((_node$sourceCodeLocat = node.sourceCodeLocation) === null || _node$sourceCodeLocat === void 0 || (_node$sourceCodeLocat = _node$sourceCodeLocat.attrs) === null || _node$sourceCodeLocat === void 0 ? void 0 : _node$sourceCodeLocat[this.KEY])
43
44
  }, this.options);
44
45
  if (!listNode) {
46
+ var _node$sourceCodeLocat2;
45
47
  onLog({
46
48
  filePath,
47
- position: _TemplateUtil.default.parse5LocationToPosition(node.sourceCodeLocation?.attrs?.[this.KEY]),
49
+ position: _TemplateUtil.default.parse5LocationToPosition((_node$sourceCodeLocat2 = node.sourceCodeLocation) === null || _node$sourceCodeLocat2 === void 0 || (_node$sourceCodeLocat2 = _node$sourceCodeLocat2.attrs) === null || _node$sourceCodeLocat2 === void 0 ? void 0 : _node$sourceCodeLocat2[this.KEY]),
48
50
  level: _sharedUtils.Loglevel.THROW,
49
51
  message: [{
50
52
  word: 'list'
@@ -57,7 +59,7 @@ class CfTranslate {
57
59
  const listName = listNode.getText();
58
60
  const modifiers = this.getModifiers(node);
59
61
  const opts = {
60
- exp: await this.genExp(listName, [...identifiers, itemName, indexName], tid?.value, attribute),
62
+ exp: await this.genExp(listName, [...identifiers, itemName, indexName], tid === null || tid === void 0 ? void 0 : tid.value, attribute),
61
63
  modifiers
62
64
  };
63
65
  if (indexNode) {
@@ -85,8 +87,8 @@ class CfTranslate {
85
87
  filePath
86
88
  } = this.options;
87
89
  const listCode = await this.templateUtil.translateAttributeValue({
88
- name: attribute?.name || '',
89
- nameLocation: attribute?.nameLocation,
90
+ name: (attribute === null || attribute === void 0 ? void 0 : attribute.name) || '',
91
+ nameLocation: attribute === null || attribute === void 0 ? void 0 : attribute.nameLocation,
90
92
  value: _TemplateUtil.default.toDynamicValue(listName)
91
93
  }, identifiers, Boolean(tid));
92
94
  if (!tid) {
@@ -99,15 +101,15 @@ class CfTranslate {
99
101
  message: [{
100
102
  word: tid
101
103
  }, `tid expecting a static string,actually a dynamic value`],
102
- position: attribute?.nameLocation
104
+ position: attribute === null || attribute === void 0 ? void 0 : attribute.nameLocation
103
105
  });
104
106
  }
105
107
  return `function() {
106
108
  return {
107
109
  __list__: ${listCode},
108
110
  __tid__: ${await this.templateUtil.translateAttributeValue({
109
- name: attribute?.name || '',
110
- nameLocation: attribute?.nameLocation,
111
+ name: (attribute === null || attribute === void 0 ? void 0 : attribute.name) || '',
112
+ nameLocation: attribute === null || attribute === void 0 ? void 0 : attribute.nameLocation,
111
113
  value: tid
112
114
  }, identifiers)}
113
115
  }
@@ -42,9 +42,10 @@ class CiTranslate {
42
42
  const name = '__ci__';
43
43
  const condition = this.templateUtil.getIfCoditionList(node);
44
44
  if (!condition) {
45
+ var _node$sourceCodeLocat;
45
46
  onLog({
46
47
  filePath,
47
- position: _TemplateUtil.default.parse5LocationToPosition(node.sourceCodeLocation?.startTag),
48
+ position: _TemplateUtil.default.parse5LocationToPosition((_node$sourceCodeLocat = node.sourceCodeLocation) === null || _node$sourceCodeLocat === void 0 ? void 0 : _node$sourceCodeLocat.startTag),
48
49
  level: _sharedUtils.Loglevel.THROW,
49
50
  message: [{
50
51
  word: 'if'
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var parser = _interopRequireWildcard(require("@babel/parser"));
8
9
  var t = _interopRequireWildcard(require("@babel/types"));
9
10
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
@@ -46,7 +46,7 @@ class ElementConfigUtil {
46
46
  docHelp
47
47
  } = options;
48
48
  // 1
49
- if (!importList?.includes(tagName)) {
49
+ if (!(importList !== null && importList !== void 0 && importList.includes(tagName))) {
50
50
  const config = this.getElementConfig(tagName);
51
51
  if (!config) {
52
52
  onLog({
@@ -69,7 +69,8 @@ class ElementConfigUtil {
69
69
  // 3
70
70
  if (config && config.attributes) {
71
71
  const requireList = Object.keys(config.attributes).filter(attributeName => {
72
- return config.attributes && config.attributes[attributeName]?.required;
72
+ var _config$attributes$at;
73
+ return config.attributes && ((_config$attributes$at = config.attributes[attributeName]) === null || _config$attributes$at === void 0 ? void 0 : _config$attributes$at.required);
73
74
  });
74
75
  const missingAttribute = requireList.filter(attributeName => attributes.findIndex(item => item.name === attributeName) < 0);
75
76
  if (missingAttribute.length) {
@@ -81,7 +82,7 @@ class ElementConfigUtil {
81
82
  word: `[${tagName}]`
82
83
  }, `missing attributes`, {
83
84
  word: missingAttribute.join('、')
84
- }, docHelp?.createWidgetReferenceMessage({
85
+ }, docHelp === null || docHelp === void 0 ? void 0 : docHelp.createWidgetReferenceMessage({
85
86
  componentName: tagName,
86
87
  chapter: _QuickAppDocHelp.QuickAppDocWidgetType.ATTRIBUTE
87
88
  })]
@@ -126,7 +127,7 @@ class ElementConfigUtil {
126
127
  const isEvent = _TemplateUtil.default.isEventAttribute(name);
127
128
  if (isEvent) {
128
129
  const eventName = _TemplateUtil.default.translateEventName(name);
129
- const eventList = [...(elementConfig?.events || []), ...this.config.commonEvents];
130
+ const eventList = [...((elementConfig === null || elementConfig === void 0 ? void 0 : elementConfig.events) || []), ...this.config.commonEvents];
130
131
  if (!eventList.includes(eventName)) {
131
132
  onLog({
132
133
  filePath,
@@ -134,7 +135,7 @@ class ElementConfigUtil {
134
135
  level: _sharedUtils.Loglevel.WARN,
135
136
  message: [{
136
137
  word: `[${name}]`
137
- }, `unsupport event`, docHelp?.createWidgetReferenceMessage({
138
+ }, `unsupport event`, docHelp === null || docHelp === void 0 ? void 0 : docHelp.createWidgetReferenceMessage({
138
139
  componentName: tagName,
139
140
  chapter: _QuickAppDocHelp.QuickAppDocWidgetType.EVENT
140
141
  })]
@@ -173,7 +174,7 @@ class ElementConfigUtil {
173
174
  level: _sharedUtils.Loglevel.WARN,
174
175
  message: [`unsupport attribute`, {
175
176
  word: `[${tagName}.${name}]`
176
- }, docHelp?.createWidgetReferenceMessage({
177
+ }, docHelp === null || docHelp === void 0 ? void 0 : docHelp.createWidgetReferenceMessage({
177
178
  componentName: tagName
178
179
  })]
179
180
  });
@@ -196,7 +197,7 @@ class ElementConfigUtil {
196
197
  word: value
197
198
  }, `, but the valid value is`, {
198
199
  word: enums.join('/')
199
- }, docHelp?.createWidgetReferenceMessage({
200
+ }, docHelp === null || docHelp === void 0 ? void 0 : docHelp.createWidgetReferenceMessage({
200
201
  componentName: tagName,
201
202
  chapter: _QuickAppDocHelp.QuickAppDocWidgetType.ATTRIBUTE
202
203
  })]
@@ -28,8 +28,8 @@ class StyleMapUtil {
28
28
  * @param useAbsolutePath 是否生成绝对路径
29
29
  * @returns
30
30
  */
31
- transfromLocToPosition(location) {
32
- let useAbsolutePath = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
31
+ transfromLocToPosition(location, useAbsolutePath = true) {
32
+ var _nodeStartPosition$so, _nodeEndPosition$sour;
33
33
  const {
34
34
  projectPath
35
35
  } = this.options;
@@ -42,10 +42,10 @@ class StyleMapUtil {
42
42
  column: location.end.column
43
43
  });
44
44
  let nodePath = '';
45
- if (nodeStartPosition.source?.endsWith('.ux') && nodeStartPosition.line) {
45
+ if ((_nodeStartPosition$so = nodeStartPosition.source) !== null && _nodeStartPosition$so !== void 0 && _nodeStartPosition$so.endsWith('.ux') && nodeStartPosition.line) {
46
46
  nodeStartPosition.line = nodeStartPosition.line - 1 + this.lineOffset;
47
47
  }
48
- if (nodeEndPosition.source?.endsWith('.ux') && nodeEndPosition.line) {
48
+ if ((_nodeEndPosition$sour = nodeEndPosition.source) !== null && _nodeEndPosition$sour !== void 0 && _nodeEndPosition$sour.endsWith('.ux') && nodeEndPosition.line) {
49
49
  nodeEndPosition.line = nodeEndPosition.line - 1 + this.lineOffset;
50
50
  }
51
51
  // nodeStartPosition.source在scss转css时会添加file://前缀,在这里需要去掉,以免影响路径的计算
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.array.push.js");
7
8
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
9
  var _cssTree = require("css-tree");
9
10
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
@@ -128,10 +129,11 @@ class StyleUtil {
128
129
  if ('children' in nodeC) {
129
130
  const nodeCChildrens = Array.isArray(nodeC.children) ? nodeC.children : nodeC.children.toArray();
130
131
  nodeCChildrens.forEach(childNode => {
132
+ var _childNode$value;
131
133
  // 处理 除法
132
134
  // example: {type: "MediaFeature", name: "min-width", value: {type: "Ratio", left: "30", right: "1"}}
133
135
  // generate结果:(min-width: 30/1)
134
- if (StyleUtil.isMediaFeature(childNode) && childNode.value?.type === 'Ratio') {
136
+ if (StyleUtil.isMediaFeature(childNode) && ((_childNode$value = childNode.value) === null || _childNode$value === void 0 ? void 0 : _childNode$value.type) === 'Ratio') {
135
137
  const value = eval((0, _cssTree.generate)(childNode.value));
136
138
  childNode.value = {
137
139
  type: 'Number',
@@ -253,7 +255,8 @@ class StyleUtil {
253
255
  const mediaLevel4OperatorList = ['>', '>=', '<', '<='];
254
256
  const mediaLevel4OperatorRegex = /[><]=?/;
255
257
  if (error.offset) {
256
- const errorWord = error.source?.[error.offset] || '';
258
+ var _source;
259
+ const errorWord = ((_source = error.source) === null || _source === void 0 ? void 0 : _source[error.offset]) || '';
257
260
  // 排除media中写level4运算符的报错问题
258
261
  if (mediaLevel4OperatorList.includes(errorWord) || mediaLevel4OperatorRegex.test(fallbackNode.value)) {
259
262
  return false;
@@ -271,6 +274,7 @@ class StyleUtil {
271
274
  static collectParserError(error, fallbackNode) {
272
275
  // 检查错误解析是否为需要输出
273
276
  if (StyleUtil.checkParserError(error, fallbackNode)) {
277
+ var _loc$start, _loc$start2, _loc$start3, _loc$start4, _loc$start5, _loc$end, _loc$start6, _loc$end2, _loc$start7, _loc$end3;
274
278
  let parserError;
275
279
  let {
276
280
  message,
@@ -284,12 +288,12 @@ class StyleUtil {
284
288
  word: name
285
289
  }],
286
290
  details: message,
287
- startLine: loc?.start?.line || loc?.start?.startLine || 0,
288
- startCol: loc?.start?.column || loc?.start?.startCol || 0,
289
- startOffset: loc?.start?.offset || 0,
290
- endLine: loc?.end?.line || loc?.start?.startLine || 0,
291
- endCol: loc?.end?.column || loc?.start?.startCol || 0,
292
- endOffset: loc?.end?.offset || 0,
291
+ startLine: (loc === null || loc === void 0 || (_loc$start = loc.start) === null || _loc$start === void 0 ? void 0 : _loc$start.line) || (loc === null || loc === void 0 || (_loc$start2 = loc.start) === null || _loc$start2 === void 0 ? void 0 : _loc$start2.startLine) || 0,
292
+ startCol: (loc === null || loc === void 0 || (_loc$start3 = loc.start) === null || _loc$start3 === void 0 ? void 0 : _loc$start3.column) || (loc === null || loc === void 0 || (_loc$start4 = loc.start) === null || _loc$start4 === void 0 ? void 0 : _loc$start4.startCol) || 0,
293
+ startOffset: (loc === null || loc === void 0 || (_loc$start5 = loc.start) === null || _loc$start5 === void 0 ? void 0 : _loc$start5.offset) || 0,
294
+ endLine: (loc === null || loc === void 0 || (_loc$end = loc.end) === null || _loc$end === void 0 ? void 0 : _loc$end.line) || (loc === null || loc === void 0 || (_loc$start6 = loc.start) === null || _loc$start6 === void 0 ? void 0 : _loc$start6.startLine) || 0,
295
+ endCol: (loc === null || loc === void 0 || (_loc$end2 = loc.end) === null || _loc$end2 === void 0 ? void 0 : _loc$end2.column) || (loc === null || loc === void 0 || (_loc$start7 = loc.start) === null || _loc$start7 === void 0 ? void 0 : _loc$start7.startCol) || 0,
296
+ endOffset: (loc === null || loc === void 0 || (_loc$end3 = loc.end) === null || _loc$end3 === void 0 ? void 0 : _loc$end3.offset) || 0,
293
297
  source: 'value' in fallbackNode ? fallbackNode.value : ''
294
298
  };
295
299
  return parserError;
@@ -333,19 +337,21 @@ class StyleUtil {
333
337
  }];
334
338
  }
335
339
  if (loc) {
340
+ var _loc$start8, _loc$start9, _loc$start10, _loc$start11, _loc$start12, _loc$end4;
336
341
  syntaxErrors.push({
337
342
  messages,
338
343
  details,
339
- startLine: loc?.start?.line || 0,
340
- startCol: loc?.start?.column || 1,
341
- startOffset: loc?.start?.offset || 0,
342
- endLine: loc?.start?.line || 0,
343
- endCol: loc?.start?.column || 1,
344
- endOffset: loc?.end?.offset || 0,
344
+ startLine: (loc === null || loc === void 0 || (_loc$start8 = loc.start) === null || _loc$start8 === void 0 ? void 0 : _loc$start8.line) || 0,
345
+ startCol: (loc === null || loc === void 0 || (_loc$start9 = loc.start) === null || _loc$start9 === void 0 ? void 0 : _loc$start9.column) || 1,
346
+ startOffset: (loc === null || loc === void 0 || (_loc$start10 = loc.start) === null || _loc$start10 === void 0 ? void 0 : _loc$start10.offset) || 0,
347
+ endLine: (loc === null || loc === void 0 || (_loc$start11 = loc.start) === null || _loc$start11 === void 0 ? void 0 : _loc$start11.line) || 0,
348
+ endCol: (loc === null || loc === void 0 || (_loc$start12 = loc.start) === null || _loc$start12 === void 0 ? void 0 : _loc$start12.column) || 1,
349
+ endOffset: (loc === null || loc === void 0 || (_loc$end4 = loc.end) === null || _loc$end4 === void 0 ? void 0 : _loc$end4.offset) || 0,
345
350
  source: css
346
351
  });
347
352
  } else {
348
- const propertyLength = error?.property?.length || 0;
353
+ var _error$property;
354
+ const propertyLength = (error === null || error === void 0 || (_error$property = error.property) === null || _error$property === void 0 ? void 0 : _error$property.length) || 0;
349
355
  syntaxErrors.push({
350
356
  messages,
351
357
  details,
@@ -631,7 +637,7 @@ class StyleUtil {
631
637
  } = sourceNode;
632
638
  // 属性校验
633
639
  const config = _StyleBaseConfig.STYLE_ATTRIBUTE_CONFIG[name];
634
- if (config?.validate) {
640
+ if (config !== null && config !== void 0 && config.validate) {
635
641
  const {
636
642
  message: validMessages,
637
643
  level: validInfoLevel
@@ -640,7 +646,7 @@ class StyleUtil {
640
646
  StyleUtil.handleStyleError(validInfoLevel, validMessages, options, sourceNode.position);
641
647
  }
642
648
  }
643
- if (config?.translate) {
649
+ if (config !== null && config !== void 0 && config.translate) {
644
650
  targetList = {
645
651
  ...targetList,
646
652
  ...config.translate(sourceNode)
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ require("core-js/modules/es.error.cause.js");
8
+ require("core-js/modules/es.array.push.js");
7
9
  var _path = _interopRequireDefault(require("path"));
8
10
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
9
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -30,7 +32,7 @@ class UxUtil {
30
32
  */
31
33
  static getLangType(node) {
32
34
  let langType = 'css';
33
- for (let attr of node?.attrs || []) {
35
+ for (let attr of (node === null || node === void 0 ? void 0 : node.attrs) || []) {
34
36
  if (attr.name === 'lang') {
35
37
  langType = attr.value;
36
38
  break;
@@ -60,8 +62,7 @@ class UxUtil {
60
62
  * @param langType
61
63
  * @returns
62
64
  */
63
- static convertGlobalJson(globalVar) {
64
- let langType = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'css';
65
+ static convertGlobalJson(globalVar, langType = 'css') {
65
66
  if (langType === 'css' && globalVar) {
66
67
  return '';
67
68
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/parser",
3
- "version": "2.0.6-beta.14",
3
+ "version": "2.0.6-beta.15",
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.14",
23
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.15",
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.14",
34
+ "file-lane": "2.0.6-beta.15",
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": "4346308137e9c0a89bc407e1ad3a8c37631affb4"
63
+ "gitHead": "8a927aec513af6d004f88e21d85bba0ef2dcac90"
64
64
  }