aiot-toolkit 2.0.5-widget-provider-beta.1 → 2.0.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.
package/README.md CHANGED
@@ -1,94 +1,94 @@
1
- <!-- 此文档由 tools/createFile.ts 生成, 请勿手动修改 -->
2
- <!--
3
-
4
- 生成方法
5
- 1. 修改 tools/README.template.md
6
- 2. 修改 tools/VelaBuilderParam.json
7
- 3. 执行 tools/createFile.ts
8
- -->
9
-
10
- # 项目介绍
11
-
12
- aiot-toolkit 2.0 是将 **源码项目** 转换为 **目标代码项目** 并生成 **目标代码应用** 的命令行工具,同时配备了 **模拟器** 相关功能供开发者使用。
13
-
14
- aiot-toolkit2.0目前支持的打包格式如下:
15
-
16
- - ux:vela 平台下的应用,目前大量使用于小米手表、音箱等智能穿戴及物联网设备
17
-
18
- ## 安装使用
19
-
20
- - 全局安装
21
-
22
- `npm i aiot-toolkit -g`
23
-
24
- `npm i create-aiot -g`
25
-
26
- - 创建项目
27
-
28
- 1. `create-aiot ux`
29
- 2. 在项目根目录执行:`npm i`
30
-
31
- - 本机运行项目
32
-
33
- 在项目根目录执行 `aiot start`,此会启动模拟器,并运行项目
34
-
35
- * 打包项目
36
-
37
- 在项目根目录执行 `aiot release`
38
-
39
- ## 常用命令
40
-
41
- | 命令 | 说明 |
42
- | ------------------------ | ---------------------------------------------- |
43
- | npm create aiot | 创建并手动选择项目 |
44
- | npm create aiot ux | 创建ux项目 |
45
- | aiot build | 构建项目 |
46
- | aiot release | 构建项目-release模式 |
47
- | aiot start | 构建项目并运行到模拟器 |
48
- | aiot getConnectedDevices | 获取已连接设备列表 |
49
- | aiot getPlatforms | 获取设置平台 |
50
- | aiot installDbgAndMkp | 在真机上安装快应用调试器 |
51
- | aiot createVVD | 创建 vela 模拟器 |
52
- | aiot deleteVVD | 删除 vela 模拟器 |
53
- | aiot resign | build目录重新生成rpk, 详情: [resign](#resign) |
54
-
55
- ## build 参数
56
-
57
-
58
- | 参数 | 类型 | 描述 | 默认值 | 参考 |
59
- | --- | --- | --- | --- | --- |
60
- | *devtool* | string | source map 配置 | | https://www.webpackjs.com/configuration/devtool/#devtool |
61
- | *enable-jsc* | confirm | 是否启用 jsc bundle | `false` | |
62
- | *enable-protobuf* | confirm | 是否启用 `protobuf` | `false` | |
63
- | *enable-e2e* | confirm | 是否为当前项目注入测试套件 | `false` | https://doc.quickapp.cn/tutorial/others/testing.html |
64
- | *enable-stats* | confirm | 分析 webpack 输出文件的大小 | `false` | |
65
- | *optimize-css-attr* | confirm | 优化压缩css名称 | `false` | |
66
- | *complete-feature* | confirm | 自动将代码中使用的功能,补全到 manifest.json 的 features 字段中 | `false` | |
67
- | *start-page* | string | 启动页面,示例:`--start-page 'pages/index?a=1&b=2'` | | |
68
- | *e2e-config-path* | string | e2e 配置文件的路径, 示例:--e2e-config-path ./test2/autoTestConfig.json | | |
69
- | *enable-image-png8* | confirm | 压缩png文件为png8 | | |
70
- | *drop-console* | string | 删除 console. <br/>+ `true`: 全部删除 <br/>+ `false`: 不删除. <br/>+ string: 自定义. <br/>示例:`--drop-console=warn,error` ,`--drop-console=true` | `false` | |
71
- | *~~enable-custom-component~~* | confirm | **已废弃** | | |
72
- | *~~stats~~* | confirm | **已废弃** | | |
73
-
74
- ## resign
75
-
76
- build目录重新生成rpk
77
-
78
- 步骤
79
-
80
- 1. 创建任意名称的空目录, 例如 `folder`
81
- 2. 将 `build` 复制到 `folder`
82
- 3. (可跳过)如需自定义证书,将证书复制到 `folder/sign`
83
- 4. 进入 `folder` 目录,执行 `aiot resign`,会在`foler/dist`中生成rpk
84
- 5. 目录结构如下
85
-
86
- ```sh
87
- folder
88
- build // 用户复制
89
- sign // 用户复制,可选
90
- certificate.pem
91
- private.pem
92
- dist // 生成
93
- ***.rpk
94
- ```
1
+ <!-- 此文档由 tools/createFile.ts 生成, 请勿手动修改 -->
2
+ <!--
3
+
4
+ 生成方法
5
+ 1. 修改 tools/README.template.md
6
+ 2. 修改 tools/VelaBuilderParam.json
7
+ 3. 执行 tools/createFile.ts
8
+ -->
9
+
10
+ # 项目介绍
11
+
12
+ aiot-toolkit 2.0 是将 **源码项目** 转换为 **目标代码项目** 并生成 **目标代码应用** 的命令行工具,同时配备了 **模拟器** 相关功能供开发者使用。
13
+
14
+ aiot-toolkit2.0目前支持的打包格式如下:
15
+
16
+ - ux:vela 平台下的应用,目前大量使用于小米手表、音箱等智能穿戴及物联网设备
17
+
18
+ ## 安装使用
19
+
20
+ - 全局安装
21
+
22
+ `npm i aiot-toolkit -g`
23
+
24
+ `npm i create-aiot -g`
25
+
26
+ - 创建项目
27
+
28
+ 1. `create-aiot ux`
29
+ 2. 在项目根目录执行:`npm i`
30
+
31
+ - 本机运行项目
32
+
33
+ 在项目根目录执行 `aiot start`,此会启动模拟器,并运行项目
34
+
35
+ * 打包项目
36
+
37
+ 在项目根目录执行 `aiot release`
38
+
39
+ ## 常用命令
40
+
41
+ | 命令 | 说明 |
42
+ | ------------------------ | ---------------------------------------------- |
43
+ | npm create aiot | 创建并手动选择项目 |
44
+ | npm create aiot ux | 创建ux项目 |
45
+ | aiot build | 构建项目 |
46
+ | aiot release | 构建项目-release模式 |
47
+ | aiot start | 构建项目并运行到模拟器 |
48
+ | aiot getConnectedDevices | 获取已连接设备列表 |
49
+ | aiot getPlatforms | 获取设置平台 |
50
+ | aiot installDbgAndMkp | 在真机上安装快应用调试器 |
51
+ | aiot createVVD | 创建 vela 模拟器 |
52
+ | aiot deleteVVD | 删除 vela 模拟器 |
53
+ | aiot resign | build目录重新生成rpk, 详情: [resign](#resign) |
54
+
55
+ ## build 参数
56
+
57
+
58
+ | 参数 | 类型 | 描述 | 默认值 | 参考 |
59
+ | --- | --- | --- | --- | --- |
60
+ | *devtool* | string | source map 配置 | | https://www.webpackjs.com/configuration/devtool/#devtool |
61
+ | *enable-jsc* | confirm | 是否启用 jsc bundle | `false` | |
62
+ | *enable-protobuf* | confirm | 是否启用 `protobuf` | `false` | |
63
+ | *enable-e2e* | confirm | 是否为当前项目注入测试套件 | `false` | https://doc.quickapp.cn/tutorial/others/testing.html |
64
+ | *enable-stats* | confirm | 分析 webpack 输出文件的大小 | `false` | |
65
+ | *optimize-css-attr* | confirm | 优化压缩css名称 | `false` | |
66
+ | *complete-feature* | confirm | 自动将代码中使用的功能,补全到 manifest.json 的 features 字段中 | `false` | |
67
+ | *start-page* | string | 启动页面,示例:`--start-page 'pages/index?a=1&b=2'` | | |
68
+ | *e2e-config-path* | string | e2e 配置文件的路径, 示例:--e2e-config-path ./test2/autoTestConfig.json | | |
69
+ | *enable-image-png8* | confirm | 压缩png文件为png8 | | |
70
+ | *drop-console* | string | 删除 console. <br/>+ `true`: 全部删除 <br/>+ `false`: 不删除. <br/>+ string: 自定义. <br/>示例:`--drop-console=warn,error` ,`--drop-console=true` | `false` | |
71
+ | *~~enable-custom-component~~* | confirm | **已废弃** | | |
72
+ | *~~stats~~* | confirm | **已废弃** | | |
73
+
74
+ ## resign
75
+
76
+ build目录重新生成rpk
77
+
78
+ 步骤
79
+
80
+ 1. 创建任意名称的空目录, 例如 `folder`
81
+ 2. 将 `build` 复制到 `folder`
82
+ 3. (可跳过)如需自定义证书,将证书复制到 `folder/sign`
83
+ 4. 进入 `folder` 目录,执行 `aiot resign`,会在`foler/dist`中生成rpk
84
+ 5. 目录结构如下
85
+
86
+ ```sh
87
+ folder
88
+ build // 用户复制
89
+ sign // 用户复制,可选
90
+ certificate.pem
91
+ private.pem
92
+ dist // 生成
93
+ ***.rpk
94
+ ```
@@ -7,8 +7,8 @@ exports.default = void 0;
7
7
  var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
8
  var _UxBuilderBase = _interopRequireDefault(require("./UxBuilderBase"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
10
- /**
11
- * AndroidUxBuilder
10
+ /**
11
+ * AndroidUxBuilder
12
12
  */
13
13
  class AndroidUxBuilder extends _UxBuilderBase.default {
14
14
  params = [{
@@ -26,12 +26,12 @@ var _IFileLaneEvents = _interopRequireWildcard(require("file-lane/lib/interface/
26
26
  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); }
27
27
  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; }
28
28
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
29
- /**
30
- * UxBuilderBase
29
+ /**
30
+ * UxBuilderBase
31
31
  */
32
32
  class UxBuilderBase {
33
- /**
34
- * 配置文件
33
+ /**
34
+ * 配置文件
35
35
  */
36
36
  QUICKAPP_CONFIG = 'quickapp.config.js';
37
37
  constructor() {
@@ -39,11 +39,11 @@ class UxBuilderBase {
39
39
  this.events = events;
40
40
  }
41
41
 
42
- /**
43
- * ux项目的build函数
44
- * @param projectPath 项目路径
45
- * @param options 命令参数
46
- * @param watch 是否开启监听
42
+ /**
43
+ * ux项目的build函数
44
+ * @param projectPath 项目路径
45
+ * @param options 命令参数
46
+ * @param watch 是否开启监听
47
47
  */
48
48
  async build(projectPath, options) {
49
49
  if (this.fileLane) {
@@ -101,10 +101,10 @@ class UxBuilderBase {
101
101
  this.fileLane = undefined;
102
102
  }
103
103
 
104
- /**
105
- * 获取build的编译配置
106
- * @param projectPath 项目路径
107
- * @param options 命令参数
104
+ /**
105
+ * 获取build的编译配置
106
+ * @param projectPath 项目路径
107
+ * @param options 命令参数
108
108
  */
109
109
  getCompilerOption(projectPath, options) {
110
110
  // 读取项目中文件的配置
@@ -8,8 +8,8 @@ var _sharedUtils = require("@aiot-toolkit/shared-utils");
8
8
  var _UxBuilderBase = _interopRequireDefault(require("./UxBuilderBase"));
9
9
  var _IVelaUxBuilderOption = require("../interface/IVelaUxBuilderOption");
10
10
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
- /**
12
- * VelaUxBuilder
11
+ /**
12
+ * VelaUxBuilder
13
13
  */
14
14
  class VelaUxBuilder extends _UxBuilderBase.default {
15
15
  params = (() => _IVelaUxBuilderOption.velaUxBuilderParams)();
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.velaUxBuilderParams = void 0;
7
- /*****
8
- * 由 tools/createFile.ts 生成, 请勿手动修改
9
- *
10
- * 生成方法
11
- * 1. 修改 tools/VelaBuilderParam.json
12
- * 2. 执行 tools/createFile.ts
7
+ /*****
8
+ * 由 tools/createFile.ts 生成, 请勿手动修改
9
+ *
10
+ * 生成方法
11
+ * 1. 修改 tools/VelaBuilderParam.json
12
+ * 2. 执行 tools/createFile.ts
13
13
  */
14
14
 
15
15
  const velaUxBuilderParams = exports.velaUxBuilderParams = [{
@@ -14,11 +14,11 @@ var _AndroidUxBuilder = _interopRequireDefault(require("../builder/AndroidUxBuil
14
14
  var _IStarter = _interopRequireDefault(require("./IStarter"));
15
15
  var _PackageRouter = _interopRequireDefault(require("./androidRouter/PackageRouter"));
16
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
17
- /**
18
- * AndroidUxStart
19
- *
20
- * 1. 启动本机开发者http服务器,并提供二维码,以下载 rpk
21
- * 2. 打包 rpk,并监听文件变化,重新打包
17
+ /**
18
+ * AndroidUxStart
19
+ *
20
+ * 1. 启动本机开发者http服务器,并提供二维码,以下载 rpk
21
+ * 2. 打包 rpk,并监听文件变化,重新打包
22
22
  */
23
23
  class AndroidUxStart extends _IStarter.default {
24
24
  builder = (() => new _AndroidUxBuilder.default())();
@@ -44,10 +44,10 @@ class AndroidUxStart extends _IStarter.default {
44
44
  });
45
45
  }
46
46
 
47
- /**
48
- * 启动
49
- * 1. build 项目
50
- * 2. build 成功,则创建http服务器
47
+ /**
48
+ * 启动
49
+ * 1. build 项目
50
+ * 2. build 成功,则创建http服务器
51
51
  */
52
52
  async start(projectPath, options) {
53
53
  this.projectPath = projectPath;
@@ -59,12 +59,12 @@ class AndroidUxStart extends _IStarter.default {
59
59
  await this.createServer(buildOption);
60
60
  }
61
61
 
62
- /**
63
- * 创建服务器
64
- *
65
- * 1. 使用 koa 创建服务器
66
- * 2. 显示服务器地址和二维码
67
- * @returns
62
+ /**
63
+ * 创建服务器
64
+ *
65
+ * 1. 使用 koa 创建服务器
66
+ * 2. 显示服务器地址和二维码
67
+ * @returns
68
68
  */
69
69
  async createServer(options) {
70
70
  return new Promise(async resolve => {
@@ -118,10 +118,10 @@ class AndroidUxStart extends _IStarter.default {
118
118
  this.server?.close();
119
119
  }
120
120
 
121
- /**
122
- * 通知已知的设备,应用有更新
123
- * @param projectPath
124
- * @param options
121
+ /**
122
+ * 通知已知的设备,应用有更新
123
+ * @param projectPath
124
+ * @param options
125
125
  */
126
126
  noticeDeviceListUpdate(projectPath, options) {
127
127
  const {
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- /**
8
- * IStarter
7
+ /**
8
+ * IStarter
9
9
  */
10
10
  class IStarter {
11
- /**
12
- * start 的参数列表
11
+ /**
12
+ * start 的参数列表
13
13
  */
14
14
  params = [];
15
15
  constructor(name, description) {
@@ -20,8 +20,8 @@ class IStarter {
20
20
  return;
21
21
  }
22
22
 
23
- /**
24
- * start 的命令
23
+ /**
24
+ * start 的命令
25
25
  */
26
26
  getCommond() {
27
27
  return {
@@ -36,10 +36,10 @@ class IStarter {
36
36
  };
37
37
  }
38
38
 
39
- /**
40
- * 运行项目
41
- * @param projectPath 项目路径
42
- * @param options 命令参数
39
+ /**
40
+ * 运行项目
41
+ * @param projectPath 项目路径
42
+ * @param options 命令参数
43
43
  */
44
44
  }
45
45
  exports.default = IStarter;
@@ -19,9 +19,9 @@ var _events = _interopRequireDefault(require("events"));
19
19
  var _FileLaneTriggerType = _interopRequireDefault(require("file-lane/lib/enum/FileLaneTriggerType"));
20
20
  var _IVelaUxBuilderOption = require("../interface/IVelaUxBuilderOption");
21
21
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
22
- /**
23
- * VelaUxStarter
24
- * ux快应用启动器
22
+ /**
23
+ * VelaUxStarter
24
+ * ux快应用启动器
25
25
  */
26
26
  class VelaUxStarter extends _IStarter.default {
27
27
  constructor(name, description) {
@@ -128,7 +128,9 @@ class VelaUxStarter extends _IStarter.default {
128
128
  const projectInfo = _aiotpack.UxFileUtils.getManifestInfo(projectPath, compilerOption.sourceRoot);
129
129
  if (this.lastRpk && _fsExtra.default.existsSync(this.lastRpk)) {
130
130
  const targetPath = await this.emulatorInstance?.pushRpk(this.lastRpk, projectInfo.package);
131
- await this.emulatorInstance?.install(targetPath, projectInfo.package);
131
+ await this.emulatorInstance?.install(targetPath, {
132
+ packageName: projectInfo.package
133
+ });
132
134
  await this.emulatorInstance?.startApp(projectInfo.package, options.devtool);
133
135
  }
134
136
  this.event.on('buildSuccess', async data => {
@@ -139,17 +141,19 @@ class VelaUxStarter extends _IStarter.default {
139
141
  await this.emulatorInstance?.reloadApp(projectInfo.package);
140
142
  } else if (data.info?.trigger === _FileLaneTriggerType.default.START && data.info.rpk) {
141
143
  const targetPath = await this.emulatorInstance?.pushRpk(data.info.rpk, projectInfo.package);
142
- await this.emulatorInstance?.install(targetPath, projectInfo.package);
144
+ await this.emulatorInstance?.install(targetPath, {
145
+ packageName: projectInfo.package
146
+ });
143
147
  await this.emulatorInstance?.startApp(projectInfo.package, options.devtool);
144
148
  }
145
149
  });
146
150
  }
147
151
 
148
- /**
149
- * 检查选择的模拟器在当前环境下是否可以使用
150
- * 下面的几种情况会导致模拟器不可用:1. 模拟器绑定的Vela镜像不存在;2. Vela4.0缺少coredump.core或者vela_data.bin文件
151
- * @param avdName 模拟器名称
152
- * @returns {boolean}
152
+ /**
153
+ * 检查选择的模拟器在当前环境下是否可以使用
154
+ * 下面的几种情况会导致模拟器不可用:1. 模拟器绑定的Vela镜像不存在;2. Vela4.0缺少coredump.core或者vela_data.bin文件
155
+ * @param avdName 模拟器名称
156
+ * @returns {boolean}
153
157
  */
154
158
  isAvailableEmulator(avdName) {
155
159
  const {
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
- /**
8
- * 连接类型
7
+ /**
8
+ * 连接类型
9
9
  */
10
10
  var LinkMode = /*#__PURE__*/function (LinkMode) {
11
11
  LinkMode[LinkMode["NULL"] = 0] = "NULL";
@@ -11,9 +11,9 @@ var _qrImage = _interopRequireDefault(require("qr-image"));
11
11
  var _LinkMode = _interopRequireDefault(require("./LinkMode"));
12
12
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
13
  const CLIENT_PORT = 39517;
14
- /**
15
- * 打包相关的路由配置
16
- * 用于开发机的httpServer
14
+ /**
15
+ * 打包相关的路由配置
16
+ * 用于开发机的httpServer
17
17
  */
18
18
  class PackageRouter {
19
19
  constructor(param) {
@@ -34,10 +34,10 @@ class PackageRouter {
34
34
  }
35
35
  }];
36
36
 
37
- /**
38
- * 下载 rpk 包
39
- * @param ctx
40
- * @param next
37
+ /**
38
+ * 下载 rpk 包
39
+ * @param ctx
40
+ * @param next
41
41
  */
42
42
  handlerDownLoadRpk = (ctx, next) => {
43
43
  const {
@@ -60,26 +60,26 @@ class PackageRouter {
60
60
  return next();
61
61
  };
62
62
 
63
- /**
64
- * 记录设备信息
65
- *
66
- * 获取请求的 ip 和端口,记录到本机中,最多记录5个
67
- *
68
- * 文件内容的格式为:
69
- * ```
70
- * records: {
71
- * "快应用项目路径":[
72
- * {ip:"", port:""},
73
- * {ip:"", port:""},
74
- * {ip:"", port:""}
75
- * ]
76
- * }
77
- * ```
78
- *
79
- *
80
- * 此记录的作用是:当重新打包后,获取已连接的设备列表
81
- * @param ctx
82
- * @param next
63
+ /**
64
+ * 记录设备信息
65
+ *
66
+ * 获取请求的 ip 和端口,记录到本机中,最多记录5个
67
+ *
68
+ * 文件内容的格式为:
69
+ * ```
70
+ * records: {
71
+ * "快应用项目路径":[
72
+ * {ip:"", port:""},
73
+ * {ip:"", port:""},
74
+ * {ip:"", port:""}
75
+ * ]
76
+ * }
77
+ * ```
78
+ *
79
+ *
80
+ * 此记录的作用是:当重新打包后,获取已连接的设备列表
81
+ * @param ctx
82
+ * @param next
83
83
  */
84
84
  recordDevice = async ctx => {
85
85
  const clientInfo = this.getClientFromRequest(ctx);
@@ -134,13 +134,13 @@ class PackageRouter {
134
134
  };
135
135
  }
136
136
 
137
- /**
138
- * http 请求中,用于返回下载文件
139
- *
140
- * 调用此方法后,仍需调用 next()
141
- *
142
- * @param filePath 文件绝对路径
143
- * @param ctx 请求上下文
137
+ /**
138
+ * http 请求中,用于返回下载文件
139
+ *
140
+ * 调用此方法后,仍需调用 next()
141
+ *
142
+ * @param filePath 文件绝对路径
143
+ * @param ctx 请求上下文
144
144
  */
145
145
  download(filePath, ctx) {
146
146
  if (filePath && _fsExtra.default.existsSync(filePath)) {