@wujingze-self/arkwebrouter 1.0.0 → 1.0.1
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 +63 -0
- package/index.d.ts +2 -0
- package/index.d.ts.map +1 -1
- package/index.js +5 -1
- package/index.js.map +1 -1
- package/index.ts +3 -1
- package/package.json +1 -1
- package/src/annotation/WebApiController.d.ts +5 -0
- package/src/annotation/WebApiController.d.ts.map +1 -0
- package/src/annotation/WebApiController.js +7 -0
- package/src/annotation/WebApiController.js.map +1 -0
- package/src/annotation/WebApiController.ts +7 -0
- package/src/annotation/WebApiMethod.d.ts +6 -0
- package/src/annotation/WebApiMethod.d.ts.map +1 -0
- package/src/annotation/WebApiMethod.js +7 -0
- package/src/annotation/WebApiMethod.js.map +1 -0
- package/src/annotation/WebApiMethod.ts +8 -0
package/README.md
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# 基于typescript项目开发Hvigor插件
|
|
2
|
+
|
|
3
|
+
## 初始化typescript项目
|
|
4
|
+
|
|
5
|
+
1. 创建一个空目录
|
|
6
|
+
2. 安装typescript模块
|
|
7
|
+
```shell
|
|
8
|
+
// 全局安装TypeScript
|
|
9
|
+
|
|
10
|
+
npm install typescript -g
|
|
11
|
+
```
|
|
12
|
+
3. 初始化npm项目。执行如下命令,根据命令行指示配置项目。初始化完成后会生成package.json文件。
|
|
13
|
+
```shell
|
|
14
|
+
// 初始化一个npm项目
|
|
15
|
+
npm init
|
|
16
|
+
```
|
|
17
|
+
4. 生成typescript配置文件。执行如下命令生成tsconfig.json文件。
|
|
18
|
+
```shell
|
|
19
|
+
// 初始化typeScript配置文件
|
|
20
|
+
tsc --init
|
|
21
|
+
```
|
|
22
|
+
5. 删除verbatimModuleSyntax字段。检查tsconfig.json文件是否存在verbatimModuleSyntax字段,如果存在且配置为true,会导致无法使用ESM语法,编译时会报错,因此需要删除该字段。
|
|
23
|
+
|
|
24
|
+
## 开发插件
|
|
25
|
+
|
|
26
|
+
1. 配置npm镜像仓库地址,用于安装@ohos/hvigor插件。
|
|
27
|
+
在工程目录下创建.npmrc文件,配置如下信息:
|
|
28
|
+
```
|
|
29
|
+
registry=https://repo.huaweicloud.com/repository/npm/
|
|
30
|
+
@ohos:registry=https://repo.harmonyos.com/npm/
|
|
31
|
+
```
|
|
32
|
+
2. 添加依赖声明。
|
|
33
|
+
打开package.json添加devDependencies配置。
|
|
34
|
+
```json
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@ohos/hvigor": "^5.8.9"
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
3. 安装依赖 `npm install`
|
|
40
|
+
4. 编写插件代码。[custom-wjz-plugin.ts](src/plugin/custom-wjz-plugin.ts)
|
|
41
|
+
5. 导出插件。[index.ts](index.ts)
|
|
42
|
+
|
|
43
|
+
## 发布插件
|
|
44
|
+
|
|
45
|
+
1. 配置registry。 打开工程目录下的[.npmrc](.npmrc)文件,配置您需要发布的镜像仓库。
|
|
46
|
+
2. 去(https://www.npmjs.com/settings/wujingze/tokens)获取token信息
|
|
47
|
+
- 先创建组织 Organizations + (注意[package.json](package.json)的name前缀需要是@组织名称)
|
|
48
|
+
- 再创建 Access Tokens (需要点击 Bypass two-factor authentication (2FA) 跳过2FA验证)
|
|
49
|
+
- 将TOKEN放入[.npmrc](.npmrc) `//registry.npmjs.org/:_authToken=TOKEN`
|
|
50
|
+
3. `npm login` 登录
|
|
51
|
+
4. `tsc` 编译npm包
|
|
52
|
+
5. 发布npm包,因为我们使用的是免费的,所以只能发布公共包 `npm publish --access public`
|
|
53
|
+
|
|
54
|
+
## 使用插件
|
|
55
|
+
|
|
56
|
+
1. 在鸿蒙工程下`hvigor/hvigor-config.json5`中添加自定义插件依赖,依赖项支持离线插件配置。Sync Now
|
|
57
|
+
```json5
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"@wujingze-self/arkwebrouter": "1.0.0" // 使用我们自定义的插件
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
2. 导入插件,在 hvigorfile 里导入插件并使用
|
|
63
|
+
|
package/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
export { NativeMethodPlugin } from './src/plugin/native-method-plugin';
|
|
2
2
|
export { customWjzPlugin } from './src/plugin/custom-wjz-plugin';
|
|
3
|
+
export { WebApiController } from './src/annotation/WebApiController';
|
|
4
|
+
export { WebApiMethod } from './src/annotation/WebApiMethod';
|
|
3
5
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,kBAAkB,EAAC,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAC,eAAe,EAAC,MAAM,gCAAgC,CAAC;AAC/D,OAAO,EAAC,gBAAgB,EAAC,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAC,YAAY,EAAC,MAAM,+BAA+B,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.customWjzPlugin = exports.NativeMethodPlugin = void 0;
|
|
3
|
+
exports.WebApiMethod = exports.WebApiController = exports.customWjzPlugin = exports.NativeMethodPlugin = void 0;
|
|
4
4
|
var native_method_plugin_1 = require("./src/plugin/native-method-plugin");
|
|
5
5
|
Object.defineProperty(exports, "NativeMethodPlugin", { enumerable: true, get: function () { return native_method_plugin_1.NativeMethodPlugin; } });
|
|
6
6
|
var custom_wjz_plugin_1 = require("./src/plugin/custom-wjz-plugin");
|
|
7
7
|
Object.defineProperty(exports, "customWjzPlugin", { enumerable: true, get: function () { return custom_wjz_plugin_1.customWjzPlugin; } });
|
|
8
|
+
var WebApiController_1 = require("./src/annotation/WebApiController");
|
|
9
|
+
Object.defineProperty(exports, "WebApiController", { enumerable: true, get: function () { return WebApiController_1.WebApiController; } });
|
|
10
|
+
var WebApiMethod_1 = require("./src/annotation/WebApiMethod");
|
|
11
|
+
Object.defineProperty(exports, "WebApiMethod", { enumerable: true, get: function () { return WebApiMethod_1.WebApiMethod; } });
|
|
8
12
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,0EAAqE;AAA7D,0HAAA,kBAAkB,OAAA;AAC1B,oEAA+D;AAAvD,oHAAA,eAAe,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;AAAA,0EAAqE;AAA7D,0HAAA,kBAAkB,OAAA;AAC1B,oEAA+D;AAAvD,oHAAA,eAAe,OAAA;AACvB,sEAAmE;AAA3D,oHAAA,gBAAgB,OAAA;AACxB,8DAA2D;AAAnD,4GAAA,YAAY,OAAA"}
|
package/index.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
1
|
export {NativeMethodPlugin} from './src/plugin/native-method-plugin';
|
|
2
|
-
export {customWjzPlugin} from './src/plugin/custom-wjz-plugin';
|
|
2
|
+
export {customWjzPlugin} from './src/plugin/custom-wjz-plugin';
|
|
3
|
+
export {WebApiController} from './src/annotation/WebApiController';
|
|
4
|
+
export {WebApiMethod} from './src/annotation/WebApiMethod';
|
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebApiController.d.ts","sourceRoot":"","sources":["WebApiController.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,sBAAsB,qBAE7D;AAED,MAAM,WAAW,sBAAsB;IACnC,IAAI,EAAE,MAAM,CAAC;CAChB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebApiController.js","sourceRoot":"","sources":["WebApiController.ts"],"names":[],"mappings":";;AAAA,4CAEC;AAFD,SAAgB,gBAAgB,CAAC,KAA6B;IAC1D,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebApiMethod.d.ts","sourceRoot":"","sources":["WebApiMethod.ts"],"names":[],"mappings":"AAAA,wBAAgB,YAAY,sBAE3B;AAED,MAAM,WAAW,kBAAkB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,QAAQ,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"WebApiMethod.js","sourceRoot":"","sources":["WebApiMethod.ts"],"names":[],"mappings":";;AAAA,oCAEC;AAFD,SAAgB,YAAY;IACxB,OAAO,MAAM,CAAC;AAClB,CAAC"}
|