@aiot-toolkit/aiotpack 2.0.3-beta.9 → 2.0.3

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.
@@ -14,8 +14,8 @@ var _JavascriptDefaultCompileOption = _interopRequireDefault(require("../../comp
14
14
  var _Jsc = _interopRequireDefault(require("../../compiler/javascript/vela/utils/Jsc"));
15
15
  var _ZipUtil = _interopRequireDefault(require("../../compiler/javascript/vela/utils/ZipUtil"));
16
16
  var _UxFileUtils = _interopRequireDefault(require("../../utils/ux/UxFileUtils"));
17
- var _archiver = _interopRequireDefault(require("archiver"));
18
17
  var _FileLaneTriggerType = _interopRequireDefault(require("file-lane/lib/enum/FileLaneTriggerType"));
18
+ var _ZipFileUtil = _interopRequireDefault(require("@aiot-toolkit/shared-utils/lib/utils/ZipFileUtil"));
19
19
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
20
20
  const BinaryPlugin = require('@aiot-toolkit/parser/lib/ux/translate/vela/protobuf/BinaryPlugin');
21
21
 
@@ -250,22 +250,10 @@ class UxAfterCompile {
250
250
  const distFold = _path.default.join(compilerOption.projectPath, compilerOption.releasePath);
251
251
  const diffFileName = `.diff.rpk`;
252
252
  const diffPath = _path.default.join(distFold, diffFileName);
253
- const diffStream = _fsExtra.default.createWriteStream(diffPath);
254
- const archiver = (0, _archiver.default)('zip', {
255
- zlib: {
256
- level: 9
257
- }
258
- });
259
- archiver.pipe(diffStream);
260
- diffList.forEach(item => {
261
- const filePath = _path.default.join(buildFold, item);
262
- archiver.append(_fsExtra.default.createReadStream(filePath), {
263
- name: item
264
- });
265
- });
266
- await archiver.finalize();
267
- diffStream.close();
268
- diffStream.destroy();
253
+ await _ZipFileUtil.default.createZipFile(diffPath, diffList.map(item => ({
254
+ filePath: _path.default.join(buildFold, item),
255
+ zipFilePath: item
256
+ })));
269
257
  compalition.info.diffList = diffList;
270
258
  compalition.info.diffFile = _path.default.join(config.projectPath, compilerOption.releasePath, diffFileName);
271
259
  }
@@ -1,3 +1,4 @@
1
+ import { IStyleNode } from '@aiot-toolkit/parser';
1
2
  import { ILog } from '@aiot-toolkit/shared-utils';
2
3
  import { IFileLaneContext, IFileParam } from 'file-lane';
3
4
  import { SourceFile } from 'ts-morph';
@@ -54,7 +55,7 @@ declare class UxLoaderUtils {
54
55
  * @returns
55
56
  */
56
57
  static wrapTempalte(templateTree: SourceFile, file: IFileParam, compilerOption: IJavascriptCompileOption): string;
57
- static wrapStyle(code: string, file: IFileParam, compilerOption: IJavascriptCompileOption): string;
58
+ static wrapStyle(styleNodes: IStyleNode[], file: IFileParam, compilerOption: IJavascriptCompileOption): string;
58
59
  /**
59
60
  * 给script增加外层包裹内容
60
61
  * @param isPageUx
@@ -11,6 +11,7 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
11
11
  var parse5 = _interopRequireWildcard(require("aiot-parse5"));
12
12
  var _fsExtra = _interopRequireDefault(require("fs-extra"));
13
13
  var _path = _interopRequireDefault(require("path"));
14
+ var _QuickAppDocHelp = require("@aiot-toolkit/shared-utils/lib/utils/QuickAppDocHelp");
14
15
  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); }
15
16
  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; }
16
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -86,7 +87,8 @@ class UxLoaderUtils {
86
87
  content: content.toString(),
87
88
  onLog: log => {
88
89
  logs.push(log);
89
- }
90
+ },
91
+ docHelp: new _QuickAppDocHelp.VelaAppDocHelp()
90
92
  };
91
93
  // 收集图片资源
92
94
  const ImageResources = [];
@@ -114,8 +116,10 @@ class UxLoaderUtils {
114
116
  // app.ux解析结果中加上manifest.json的内容
115
117
  const manifestJson = `require('./manifest.json')`;
116
118
  const integrateFunction = (appImport, appStyleTree, appTemplateTree, appScriptTree) => {
119
+ const scriptCode = appScriptTree.getText();
120
+ const hasScript = Boolean(scriptCode) && scriptCode !== '""';
117
121
  // script代码放在第三个位置不能变化,影响更新source map
118
- return isAppUx ? [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(JSON.stringify(appStyleTree), file, compilerOption)}`, `var $app_script$ = ${UxLoaderUtils.wrapScript(false, appScriptTree)}`, `$app_script$({}, $app_exports$, $app_require$);`, `$app_exports$.default.style = $app_style$;`, `$app_exports$.default.manifest = ${manifestJson}`] : [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(JSON.stringify(appStyleTree), file, compilerOption)}`, `var $app_script$ = ${UxLoaderUtils.wrapScript(isPageUx, appScriptTree)}`, `var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree, file, compilerOption)}`, `${UxLoaderUtils.getReturnType(isPageUx)} function ($app_exports$) {`, `$app_script$({}, $app_exports$, $app_require$);`, `$app_exports$.default.template = $app_template$;`, `$app_exports$.default.style = $app_style$;`, `}`];
122
+ return isAppUx ? [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(false, appScriptTree)}` : '', hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.style = $app_style$;`, `$app_exports$.default.manifest = ${manifestJson}`] : [`${appImport.join('\n')}`, `var $app_style$ = ${UxLoaderUtils.wrapStyle(appStyleTree, file, compilerOption)}`, hasScript ? `var $app_script$ = ${UxLoaderUtils.wrapScript(isPageUx, appScriptTree)}` : '', `var $app_template$ = ${UxLoaderUtils.wrapTempalte(appTemplateTree, file, compilerOption)}`, `${UxLoaderUtils.getReturnType(isPageUx)} function ($app_exports$) {`, hasScript ? `$app_script$({}, $app_exports$, $app_require$);` : `$app_exports$.default = {}`, `$app_exports$.default.template = $app_template$;`, `$app_exports$.default.style = $app_style$;`, `}`];
119
123
  };
120
124
  const {
121
125
  targetTree,
@@ -302,10 +306,13 @@ class UxLoaderUtils {
302
306
  }
303
307
  return result;
304
308
  }
305
- static wrapStyle(code, file, compilerOption) {
309
+ static wrapStyle(styleNodes, file, compilerOption) {
310
+ const code = JSON.stringify(styleNodes);
306
311
  if (compilerOption.enableProtobuf) {
307
- const result = BinaryPlugin.addStyle(file.path, file.path, code);
308
- return `['${result.name}', ${result.index}]`;
312
+ if (styleNodes?.length) {
313
+ const result = BinaryPlugin.addStyle(file.path, file.path, code);
314
+ return `['${result.name}', ${result.index}]`;
315
+ }
309
316
  }
310
317
  return code;
311
318
  }
@@ -9,6 +9,7 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
9
9
  var _UxToTypescript = _interopRequireDefault(require("@aiot-toolkit/parser/lib/ux/translate/android/UxToTypescript"));
10
10
  var _generator = require("@aiot-toolkit/generator");
11
11
  var _path = _interopRequireDefault(require("path"));
12
+ var _QuickAppDocHelp = require("@aiot-toolkit/shared-utils/lib/utils/QuickAppDocHelp");
12
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
14
  /**
14
15
  * AndroidUx
@@ -58,7 +59,8 @@ class AndroidUx {
58
59
  onLog: function (log) {
59
60
  logs.push(log);
60
61
  },
61
- content: content.toString()
62
+ content: content.toString(),
63
+ docHelp: new _QuickAppDocHelp.QuickAppDocHelper()
62
64
  };
63
65
  const uxAst = await new _parser.UxParser(option, compilerOption, {}, path => path).parser();
64
66
  const tsAst = await new _UxToTypescript.default(option, compilerOption, context).translate(uxAst.ast, uxAst.offsetList || []);
@@ -75,7 +77,7 @@ class AndroidUx {
75
77
  content: code.code
76
78
  }, {
77
79
  path: `${filePathParse.dir}/${filePathParse.base}.map`,
78
- content: code.sourcemap
80
+ content: tsAst.sourceMap.toString()
79
81
  }
80
82
  // resource todo
81
83
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiot-toolkit/aiotpack",
3
- "version": "2.0.3-beta.9",
3
+ "version": "2.0.3",
4
4
  "description": "The process tool for packaging aiot projects.",
5
5
  "keywords": [
6
6
  "aiotpack"
@@ -19,16 +19,16 @@
19
19
  "test": "node ./__tests__/aiotpack.test.js"
20
20
  },
21
21
  "dependencies": {
22
- "@aiot-toolkit/generator": "2.0.3-beta.9",
23
- "@aiot-toolkit/parser": "2.0.3-beta.9",
24
- "@aiot-toolkit/shared-utils": "2.0.3-beta.9",
22
+ "@aiot-toolkit/generator": "2.0.3",
23
+ "@aiot-toolkit/parser": "2.0.3",
24
+ "@aiot-toolkit/shared-utils": "2.0.3",
25
25
  "@hap-toolkit/aaptjs": "^2.0.0",
26
26
  "@rspack/core": "^1.0.0",
27
27
  "aiot-parse5": "^1.0.0",
28
28
  "archiver": "^7.0.1",
29
29
  "babel-loader": "^9.1.3",
30
30
  "fast-glob": "^3.3.2",
31
- "file-lane": "2.0.3-beta.9",
31
+ "file-lane": "2.0.3",
32
32
  "file-loader": "^6.2.0",
33
33
  "fs-extra": "^11.2.0",
34
34
  "jsrsasign": "^11.1.0",
@@ -45,5 +45,5 @@
45
45
  "@types/jsrsasign": "^10.5.12",
46
46
  "@types/webpack-sources": "^3.2.3"
47
47
  },
48
- "gitHead": "d51c01beb50c17548d9ab5be522790d295b4c18d"
48
+ "gitHead": "e29e61eb89c2559eb9f3a18c51fd5ce4c4196cc2"
49
49
  }