@aiot-toolkit/aiotpack 2.0.6-beta.17 → 2.0.6-beta.19

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.
@@ -114,11 +114,10 @@ class UxCompileUtil {
114
114
  if (Array.isArray(services)) {
115
115
  services.forEach(item => {
116
116
  const {
117
- name,
118
117
  path
119
118
  } = item;
120
- if (name && path) {
121
- result['services/' + name] = './src/' + path + `?uxType=${_EntryType.default.APP}`;
119
+ if (path) {
120
+ result[path] = './src/' + path + `?uxType=${_EntryType.default.APP}`;
122
121
  }
123
122
  });
124
123
  }
@@ -5,6 +5,7 @@ import PngLoader from '../loader/ux/PngLoader';
5
5
  import AppUxLoader from '../loader/ux/vela/AppUxLoader';
6
6
  import HmlLoader from '../loader/ux/vela/HmlLoader';
7
7
  import UxLoader from '../loader/ux/vela/UxLoader';
8
+ import AndroidUxLoader from '../loader/ux/android/UxLoader';
8
9
  import UxBeforeWorks from '../beforeWorks/ux/UxBeforeWorks';
9
10
  import UxAfterWorks from '../afterWorks/ux/UxAfterWorks';
10
11
  import { IChangedFile } from 'file-lane/lib/interface/IChangedFile';
@@ -46,11 +47,7 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
46
47
  } | {
47
48
  test: RegExp[];
48
49
  exclude: RegExp[];
49
- loader: (typeof UxLoader)[];
50
- } | {
51
- test: RegExp[];
52
50
  loader: (typeof HmlLoader | typeof UxLoader)[];
53
- exclude?: undefined;
54
51
  } | {
55
52
  test: RegExp[];
56
53
  loader: (typeof JsLoader)[];
@@ -60,6 +57,14 @@ declare class UxConfig implements IFileLaneConfig<IJavascriptCompileOption> {
60
57
  loader: (typeof PngLoader)[];
61
58
  exclude?: undefined;
62
59
  })[];
60
+ } | {
61
+ rules: ({
62
+ test: RegExp[];
63
+ loader: (typeof AndroidUxLoader)[];
64
+ } | {
65
+ test: RegExp[];
66
+ loader: (typeof PngLoader)[];
67
+ })[];
63
68
  };
64
69
  /**
65
70
  * 判断项目类型
@@ -123,11 +123,8 @@ class UxConfig {
123
123
  test: ['app.ux'],
124
124
  loader: [_AppUxLoader.default]
125
125
  }, {
126
- test: [/.+\.ux$/],
126
+ test: [/.+\.(ux|hml)$/],
127
127
  exclude: [/app\.ux/],
128
- loader: [_UxLoader.default]
129
- }, {
130
- test: [/.+\.hml$/],
131
128
  loader: [_HmlLoader.default, _UxLoader.default]
132
129
  }, {
133
130
  test: [/.+\.js$/],
@@ -1,5 +1,6 @@
1
1
  import { IFileLaneContext, IFileParam, ILoader } from 'file-lane';
2
2
  import IJavascriptCompileOption from '../../compiler/javascript/interface/IJavascriptCompileOption';
3
+ import { ILog } from '@aiot-toolkit/shared-utils';
3
4
  import FileLaneCompilation from 'file-lane/lib/FileLaneCompilation';
4
5
  /**
5
6
  * JsLoader
@@ -8,6 +9,7 @@ declare class JsLoader implements ILoader {
8
9
  context: IFileLaneContext;
9
10
  compilerOption: IJavascriptCompileOption;
10
11
  compilation: FileLaneCompilation;
12
+ logs: ILog[];
11
13
  parser(files: IFileParam<any>[]): Promise<IFileParam<any>[]>;
12
14
  }
13
15
  export default JsLoader;
@@ -12,8 +12,8 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
12
12
  * JsLoader
13
13
  */
14
14
  class JsLoader {
15
+ logs = [];
15
16
  async parser(files) {
16
- const onLog = () => {};
17
17
  const result = [];
18
18
  for (const item of files) {
19
19
  if (!item.content) {
@@ -27,7 +27,9 @@ class JsLoader {
27
27
  projectPath: this.context.projectPath,
28
28
  content: item.content.toString(),
29
29
  projectType: _sharedUtils.ProjectType.getProjectType(this.context.projectPath),
30
- onLog
30
+ onLog: log => {
31
+ this.logs.push(log);
32
+ }
31
33
  };
32
34
  const scriptTree = await new _parser.ScriptToTypescript(options, this.compilerOption, this.context).translate({
33
35
  content: new _parser.ScriptParser(options).parser(item.content.toString()).ast.content
@@ -9,13 +9,12 @@ declare class HmlLoader implements ILoader {
9
9
  /**
10
10
  * 包裹 hml 文件
11
11
  *
12
- * # 路径
13
- * 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
14
- *
15
12
  * # 内容
16
- * 1. 给hml的内容加上<template></template>
17
- * 2. 如果存在同路径同名的 script文件,则加到<script></script>中
18
- * 3. 如果存在同路径同名的 style文件,则加到<style></style>中
13
+ * 1. 如果存在template节点,则保留原内容不变
14
+ * 2. 如果不存在template节点,则进行如下包装
15
+ * 1. hml的内容加上<template></template>
16
+ * 2. 如果存在同路径同名的 script文件,则加到<script></script>中
17
+ * 3. 如果存在同路径同名的 style文件,则加到<style></style>中
19
18
  *
20
19
  * @param file
21
20
  */
@@ -7,6 +7,9 @@ exports.default = void 0;
7
7
  var _path = _interopRequireDefault(require("path"));
8
8
  var _fs = _interopRequireDefault(require("fs"));
9
9
  var _parser = require("@aiot-toolkit/parser");
10
+ var parse5 = _interopRequireWildcard(require("aiot-parse5"));
11
+ 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); }
12
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
10
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
14
  /**
12
15
  * HmlLoader
@@ -21,13 +24,12 @@ class HmlLoader {
21
24
  /**
22
25
  * 包裹 hml 文件
23
26
  *
24
- * # 路径
25
- * 如果存在同路径的 ux 后缀,报错;否则转换为同路径的 ux 后缀
26
- *
27
27
  * # 内容
28
- * 1. 给hml的内容加上<template></template>
29
- * 2. 如果存在同路径同名的 script文件,则加到<script></script>中
30
- * 3. 如果存在同路径同名的 style文件,则加到<style></style>中
28
+ * 1. 如果存在template节点,则保留原内容不变
29
+ * 2. 如果不存在template节点,则进行如下包装
30
+ * 1. hml的内容加上<template></template>
31
+ * 2. 如果存在同路径同名的 script文件,则加到<script></script>中
32
+ * 3. 如果存在同路径同名的 style文件,则加到<style></style>中
31
33
  *
32
34
  * @param file
33
35
  */
@@ -36,17 +38,22 @@ class HmlLoader {
36
38
  path,
37
39
  content
38
40
  } = file;
39
- const uxExt = _parser.ExtensionConfig.UX;
41
+ const uxAst = parse5.parseFragment(content?.toString() || '', {
42
+ scriptingEnabled: false,
43
+ sourceCodeLocationInfo: true
44
+ });
45
+ const hasTemplate = uxAst.childNodes.some(node => {
46
+ return node.nodeName === 'template';
47
+ });
48
+ if (hasTemplate) {
49
+ return file;
50
+ }
40
51
  const getFilePath = ext => {
41
52
  const pathParsed = _path.default.parse(path);
42
53
  pathParsed.ext = ext;
43
54
  pathParsed.base = pathParsed.name + ext;
44
55
  return _path.default.format(pathParsed);
45
56
  };
46
- const uxPath = getFilePath(uxExt);
47
- if (_fs.default.existsSync(uxPath)) {
48
- throw new Error(`${uxPath} already exists`);
49
- }
50
57
  const scriptExts = _parser.ExtensionConfig.SCRIPTS;
51
58
  const styleExts = _parser.ExtensionConfig.STYLES;
52
59
  const scriptPath = scriptExts.map(item => getFilePath(item)).find(item => _fs.default.existsSync(item));
@@ -56,7 +63,8 @@ class HmlLoader {
56
63
  uxContent += ['<script>', _fs.default.readFileSync(scriptPath, 'utf-8'), '</script>'].join('\n');
57
64
  }
58
65
  if (stylePath) {
59
- uxContent += ['<style>', _fs.default.readFileSync(stylePath, 'utf-8'), '</style>'].join('\n');
66
+ const styleExt = _path.default.extname(stylePath).toLowerCase();
67
+ uxContent += [`<style lang="${styleExt.slice(1)}">`, _fs.default.readFileSync(stylePath, 'utf-8'), '</style>'].join('\n');
60
68
  }
61
69
  return {
62
70
  path,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/aiotpack",
3
- "version": "2.0.6-beta.17",
3
+ "version": "2.0.6-beta.19",
4
4
  "description": "The process tool for packaging aiot projects.",
5
5
  "keywords": [
6
6
  "aiotpack"
@@ -19,14 +19,14 @@
19
19
  "test": "node ./__tests__/aiotpack.test.js"
20
20
  },
21
21
  "dependencies": {
22
- "@aiot-toolkit/generator": "2.0.6-beta.17",
23
- "@aiot-toolkit/parser": "2.0.6-beta.17",
24
- "@aiot-toolkit/shared-utils": "2.0.6-beta.17",
22
+ "@aiot-toolkit/generator": "2.0.6-beta.19",
23
+ "@aiot-toolkit/parser": "2.0.6-beta.19",
24
+ "@aiot-toolkit/shared-utils": "2.0.6-beta.19",
25
25
  "@hap-toolkit/aaptjs": "^2.0.0",
26
26
  "@rspack/core": "^1.3.9",
27
27
  "aiot-parse5": "^1.0.2",
28
28
  "babel-loader": "^9.1.3",
29
- "file-lane": "2.0.6-beta.17",
29
+ "file-lane": "2.0.6-beta.19",
30
30
  "file-loader": "^6.2.0",
31
31
  "fs-extra": "^11.2.0",
32
32
  "jsrsasign": "^11.1.0",
@@ -42,5 +42,5 @@
42
42
  "@types/jsrsasign": "^10.5.12",
43
43
  "@types/webpack-sources": "^3.2.3"
44
44
  },
45
- "gitHead": "d9d60157e951ebbc58f6a6f6fac63efd9d9d4fd5"
45
+ "gitHead": "29d48c29e9b35e01a722868daba622fd74baefc9"
46
46
  }