@wujingze-self/arkwebrouter 1.0.0

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/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export { NativeMethodPlugin } from './src/plugin/native-method-plugin';
2
+ export { customWjzPlugin } from './src/plugin/custom-wjz-plugin';
3
+ //# sourceMappingURL=index.d.ts.map
package/index.d.ts.map ADDED
@@ -0,0 +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"}
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customWjzPlugin = exports.NativeMethodPlugin = void 0;
4
+ var native_method_plugin_1 = require("./src/plugin/native-method-plugin");
5
+ Object.defineProperty(exports, "NativeMethodPlugin", { enumerable: true, get: function () { return native_method_plugin_1.NativeMethodPlugin; } });
6
+ var custom_wjz_plugin_1 = require("./src/plugin/custom-wjz-plugin");
7
+ Object.defineProperty(exports, "customWjzPlugin", { enumerable: true, get: function () { return custom_wjz_plugin_1.customWjzPlugin; } });
8
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +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"}
package/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export {NativeMethodPlugin} from './src/plugin/native-method-plugin';
2
+ export {customWjzPlugin} from './src/plugin/custom-wjz-plugin';
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@wujingze-self/arkwebrouter",
3
+ "version": "1.0.0",
4
+ "description": "arkweb request router",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 1"
8
+ },
9
+ "author": "",
10
+ "license": "ISC",
11
+ "devDependencies": {
12
+ "@ohos/hvigor": "^5.8.9",
13
+ "@ohos/hvigor-ohos-plugin": "^5.8.9"
14
+ },
15
+ "dependencies": {}
16
+ }
@@ -0,0 +1,3 @@
1
+ import type { HvigorPlugin } from '@ohos/hvigor';
2
+ export declare function customWjzPlugin(): HvigorPlugin;
3
+ //# sourceMappingURL=custom-wjz-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-wjz-plugin.d.ts","sourceRoot":"","sources":["custom-wjz-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,cAAc,CAAC;AAE7D,wBAAgB,eAAe,IAAI,YAAY,CAO9C"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.customWjzPlugin = customWjzPlugin;
4
+ function customWjzPlugin() {
5
+ return {
6
+ pluginId: 'customWjzPlugin',
7
+ apply(node) {
8
+ console.log('hello customPlugin!');
9
+ }
10
+ };
11
+ }
12
+ //# sourceMappingURL=custom-wjz-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"custom-wjz-plugin.js","sourceRoot":"","sources":["custom-wjz-plugin.ts"],"names":[],"mappings":";;AAEA,0CAOC;AAPD,SAAgB,eAAe;IAC3B,OAAO;QACH,QAAQ,EAAE,iBAAiB;QAC3B,KAAK,CAAC,IAAgB;YAClB,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC;QACvC,CAAC;KACJ,CAAA;AACL,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { HvigorNode, HvigorPlugin } from '@ohos/hvigor';
2
+
3
+ export function customWjzPlugin(): HvigorPlugin {
4
+ return {
5
+ pluginId: 'customWjzPlugin',
6
+ apply(node: HvigorNode) {
7
+ console.log('hello customPlugin!');
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,3 @@
1
+ import { HvigorPlugin } from '@ohos/hvigor';
2
+ export declare function NativeMethodPlugin(): HvigorPlugin;
3
+ //# sourceMappingURL=native-method-plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-method-plugin.d.ts","sourceRoot":"","sources":["native-method-plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,YAAY,EAAE,MAAM,cAAc,CAAC;AAKxD,wBAAgB,kBAAkB,IAAI,YAAY,CAkCjD"}
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NativeMethodPlugin = NativeMethodPlugin;
4
+ function NativeMethodPlugin() {
5
+ return {
6
+ pluginId: 'native-method-plugin',
7
+ apply(node) {
8
+ console.log('[NativeMethodPlugin] 开始扫描@NativeMethod注解...');
9
+ // 在编译的合适阶段执行
10
+ /*node.afterTask('compileArkTS', async () => {
11
+ try {
12
+ // 1. 获取项目根目录和源码路径
13
+ const projectRoot = node.getNodePath();
14
+ const srcPath = path.join(projectRoot, 'src/main/ets');
15
+
16
+ console.log(`[NativeMethodPlugin] 扫描路径: ${srcPath}`);
17
+
18
+ // 2. 扫描所有ets文件,收集被注解的方法
19
+ const scanner = new MethodScanner(srcPath);
20
+ const methods = scanner.scan();
21
+
22
+ console.log(`[NativeMethodPlugin] 发现 ${methods.length} 个@NativeMethod方法`);
23
+
24
+ if (methods.length > 0) {
25
+ // 3. 生成注册代码
26
+ const generator = new CodeGenerator(projectRoot);
27
+ const outputFile = generator.generate(methods);
28
+
29
+ console.log(`[NativeMethodPlugin] 注册代码已生成: ${outputFile}`);
30
+ }
31
+ } catch (error) {
32
+ console.error('[NativeMethodPlugin] 执行失败:', error);
33
+ }
34
+ });*/
35
+ }
36
+ };
37
+ }
38
+ //# sourceMappingURL=native-method-plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"native-method-plugin.js","sourceRoot":"","sources":["native-method-plugin.ts"],"names":[],"mappings":";;AAKA,gDAkCC;AAlCD,SAAgB,kBAAkB;IAC9B,OAAO;QACH,QAAQ,EAAE,sBAAsB;QAChC,KAAK,CAAC,IAAgB;YAClB,OAAO,CAAC,GAAG,CAAC,6CAA6C,CAAC,CAAC;YAE3D,aAAa;YACb;;;;;;;;;;;;;;;;;;;;;;;;iBAwBK;QACT,CAAC;KACJ,CAAC;AACN,CAAC"}
@@ -0,0 +1,40 @@
1
+ import { HvigorNode, HvigorPlugin } from '@ohos/hvigor';
2
+
3
+ import * as fs from 'fs';
4
+ import * as path from 'path';
5
+
6
+ export function NativeMethodPlugin(): HvigorPlugin {
7
+ return {
8
+ pluginId: 'native-method-plugin',
9
+ apply(node: HvigorNode) {
10
+ console.log('[NativeMethodPlugin] 开始扫描@NativeMethod注解...');
11
+
12
+ // 在编译的合适阶段执行
13
+ /*node.afterTask('compileArkTS', async () => {
14
+ try {
15
+ // 1. 获取项目根目录和源码路径
16
+ const projectRoot = node.getNodePath();
17
+ const srcPath = path.join(projectRoot, 'src/main/ets');
18
+
19
+ console.log(`[NativeMethodPlugin] 扫描路径: ${srcPath}`);
20
+
21
+ // 2. 扫描所有ets文件,收集被注解的方法
22
+ const scanner = new MethodScanner(srcPath);
23
+ const methods = scanner.scan();
24
+
25
+ console.log(`[NativeMethodPlugin] 发现 ${methods.length} 个@NativeMethod方法`);
26
+
27
+ if (methods.length > 0) {
28
+ // 3. 生成注册代码
29
+ const generator = new CodeGenerator(projectRoot);
30
+ const outputFile = generator.generate(methods);
31
+
32
+ console.log(`[NativeMethodPlugin] 注册代码已生成: ${outputFile}`);
33
+ }
34
+ } catch (error) {
35
+ console.error('[NativeMethodPlugin] 执行失败:', error);
36
+ }
37
+ });*/
38
+ }
39
+ };
40
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ // Visit https://aka.ms/tsconfig to read more about this file
3
+ "compilerOptions": {
4
+ // File Layout
5
+ // "rootDir": "./src",
6
+ // "outDir": "./dist",
7
+
8
+ // Environment Settings
9
+ // See also https://aka.ms/tsconfig/module
10
+ "module": "nodenext",
11
+ "target": "esnext",
12
+ "types": [],
13
+ // For nodejs:
14
+ // "lib": ["esnext"],
15
+ // "types": ["node"],
16
+ // and npm install -D @types/node
17
+
18
+ // Other Outputs
19
+ "sourceMap": true,
20
+ "declaration": true,
21
+ "declarationMap": true,
22
+
23
+ // Stricter Typechecking Options
24
+ "noUncheckedIndexedAccess": true,
25
+ "exactOptionalPropertyTypes": true,
26
+
27
+ // Style Options
28
+ // "noImplicitReturns": true,
29
+ // "noImplicitOverride": true,
30
+ // "noUnusedLocals": true,
31
+ // "noUnusedParameters": true,
32
+ // "noFallthroughCasesInSwitch": true,
33
+ // "noPropertyAccessFromIndexSignature": true,
34
+
35
+ // Recommended Options
36
+ "strict": true,
37
+ "jsx": "react-jsx",
38
+ "isolatedModules": true,
39
+ "noUncheckedSideEffectImports": true,
40
+ "moduleDetection": "force",
41
+ "skipLibCheck": true,
42
+ }
43
+ }