diff --git a/.hvigor/cache/meta.json b/.hvigor/cache/meta.json new file mode 100644 index 0000000..18f86af --- /dev/null +++ b/.hvigor/cache/meta.json @@ -0,0 +1 @@ +{"compileSdkVersion":"5.0.4(16)","hvigorVersion":"5.16.2","toolChainsVersion":"5.0.4.150"} diff --git a/.hvigor/dependencyMap/Home/oh-package.json5 b/.hvigor/dependencyMap/Home/oh-package.json5 new file mode 100644 index 0000000..7ba66c1 --- /dev/null +++ b/.hvigor/dependencyMap/Home/oh-package.json5 @@ -0,0 +1 @@ +{"name":"home","version":"1.0.0","description":"Please describe the basic information.","main":"Index.ets","author":"","license":"Apache-2.0","dependencies":{"@itcast/basic":"file:../../commons/basic"}} \ No newline at end of file diff --git a/.hvigor/dependencyMap/basic/oh-package.json5 b/.hvigor/dependencyMap/basic/oh-package.json5 new file mode 100644 index 0000000..ef35fcd --- /dev/null +++ b/.hvigor/dependencyMap/basic/oh-package.json5 @@ -0,0 +1 @@ +{"name":"@itcast/basic","version":"1.0.0","description":"Please describe the basic information.","main":"Index.ets","author":"","license":"Apache-2.0","dependencies":{}} \ No newline at end of file diff --git a/.hvigor/dependencyMap/default/oh-package.json5 b/.hvigor/dependencyMap/default/oh-package.json5 new file mode 100644 index 0000000..c84fedc --- /dev/null +++ b/.hvigor/dependencyMap/default/oh-package.json5 @@ -0,0 +1 @@ +{"name":"expert","version":"1.0.0","description":"Please describe the basic information.","main":"","author":"","license":"","dependencies":{"@itcast/basic":"file:../../commons/basic","utils":"file:../../commons/utils","mypage":"file:../../features/mypage","home":"file:../../features/Home","register":"file:../../features/register"}} \ No newline at end of file diff --git a/.hvigor/dependencyMap/dependencyMap.json5 b/.hvigor/dependencyMap/dependencyMap.json5 new file mode 100644 index 0000000..cfca4a6 --- /dev/null +++ b/.hvigor/dependencyMap/dependencyMap.json5 @@ -0,0 +1 @@ +{"basePath":"/Users/gandanxiangzhao/Downloads/Expert/harmony/.hvigor/dependencyMap/dependencyMap.json5","rootDependency":"./oh-package.json5","dependencyMap":{"default":"./default/oh-package.json5","uicomponents":"./uicomponents/oh-package.json5","utils":"./utils/oh-package.json5","mypage":"./mypage/oh-package.json5","basic":"./basic/oh-package.json5","Home":"./Home/oh-package.json5","register":"./register/oh-package.json5"},"modules":[{"name":"default","srcPath":"../../../products/expert"},{"name":"uicomponents","srcPath":"../../../commons/uicomponents"},{"name":"utils","srcPath":"../../../commons/utils"},{"name":"mypage","srcPath":"../../../features/mypage"},{"name":"basic","srcPath":"../../../commons/basic"},{"name":"Home","srcPath":"../../../features/Home"},{"name":"register","srcPath":"../../../features/register"}]} \ No newline at end of file diff --git a/.hvigor/dependencyMap/mypage/oh-package.json5 b/.hvigor/dependencyMap/mypage/oh-package.json5 new file mode 100644 index 0000000..414776f --- /dev/null +++ b/.hvigor/dependencyMap/mypage/oh-package.json5 @@ -0,0 +1 @@ +{"name":"mypage","version":"1.0.0","description":"Please describe the basic information.","main":"Index.ets","author":"","license":"Apache-2.0","dependencies":{"@itcast/basic":"file:../../commons/basic"}} \ No newline at end of file diff --git a/.hvigor/dependencyMap/oh-package.json5 b/.hvigor/dependencyMap/oh-package.json5 new file mode 100644 index 0000000..83f3326 --- /dev/null +++ b/.hvigor/dependencyMap/oh-package.json5 @@ -0,0 +1 @@ +{"modelVersion":"5.0.2","description":"Please describe the basic information.","dependencies":{"@ohos/crypto-js":"^2.0.4"},"devDependencies":{"@ohos/hypium":"1.0.21","@ohos/hamock":"1.0.0"},"dynamicDependencies":{}} \ No newline at end of file diff --git a/.hvigor/dependencyMap/register/oh-package.json5 b/.hvigor/dependencyMap/register/oh-package.json5 new file mode 100644 index 0000000..dfad1c0 --- /dev/null +++ b/.hvigor/dependencyMap/register/oh-package.json5 @@ -0,0 +1 @@ +{"name":"register","version":"1.0.0","description":"Please describe the basic information.","main":"Index.ets","author":"","license":"Apache-2.0","dependencies":{"@itcast/basic":"file:../../commons/basic"}} \ No newline at end of file diff --git a/.hvigor/dependencyMap/uicomponents/oh-package.json5 b/.hvigor/dependencyMap/uicomponents/oh-package.json5 new file mode 100644 index 0000000..cbdab54 --- /dev/null +++ b/.hvigor/dependencyMap/uicomponents/oh-package.json5 @@ -0,0 +1 @@ +{"name":"uicomponents","version":"1.0.0","description":"Please describe the basic information.","main":"Index.ets","author":"","license":"Apache-2.0","dependencies":{}} \ No newline at end of file diff --git a/.hvigor/dependencyMap/utils/oh-package.json5 b/.hvigor/dependencyMap/utils/oh-package.json5 new file mode 100644 index 0000000..e256db3 --- /dev/null +++ b/.hvigor/dependencyMap/utils/oh-package.json5 @@ -0,0 +1 @@ +{"name":"utils","version":"1.0.0","description":"Please describe the basic information.","main":"Index.ets","author":"","license":"Apache-2.0","dependencies":{"@ohos/crypto-js":"^2.0.4"},"devDependencies":{},"dynamicDependencies":{}} \ No newline at end of file diff --git a/.hvigor/outputs/build-logs/build.log b/.hvigor/outputs/build-logs/build.log new file mode 100644 index 0000000..514a609 --- /dev/null +++ b/.hvigor/outputs/build-logs/build.log @@ -0,0 +1,506 @@ +[2025-05-09T15:47:09.084] [DEBUG] debug-file - env: nodejsVersion=v18.20.1 +[2025-05-09T15:47:09.301] [DEBUG] debug-file - Hvigor init with startParameters:{ + hvigorfileTypeCheck: false, + parallelExecution: true, + incrementalExecution: true, + printStackTrace: true, + daemon: false, + analyze: 0, + logLevel: Level { level: 20000, levelStr: 'INFO', colour: 'green' } +} +[2025-05-09T15:47:09.311] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/hvigorfile.ts +[2025-05-09T15:47:09.974] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: appTasks], plugins: [] } } +[2025-05-09T15:47:10.071] [DEBUG] debug-file - Start initialize project's product build option map with build mode debug. +[2025-05-09T15:47:10.073] [DEBUG] debug-file - Product 'default' using build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } +} in this build. +[2025-05-09T15:47:10.084] [DEBUG] debug-file - Local scan or download HarmonyOS sdk components toolchains,ets,js,native,previewer +[2025-05-09T15:47:10.087] [DEBUG] debug-file - Local scan or download hmscore sdk components toolchains,ets,native +[2025-05-09T15:47:10.089] [DEBUG] debug-file - Start recording SDK configuration permission data. +[2025-05-09T15:47:10.102] [DEBUG] debug-file - Sdk init in 19 ms +[2025-05-09T15:47:10.109] [DEBUG] debug-file - Project task initialization takes 7 ms +[2025-05-09T15:47:10.112] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/hvigorfile.ts +[2025-05-09T15:47:10.120] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=default, buildMode=debug +[2025-05-09T15:47:10.123] [DEBUG] debug-file - Module default task initialization takes 2 ms +[2025-05-09T15:47:10.126] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/hvigorfile.ts +[2025-05-09T15:47:10.147] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=uicomponents, buildMode=debug +[2025-05-09T15:47:10.148] [DEBUG] debug-file - Module uicomponents task initialization takes 1 ms +[2025-05-09T15:47:10.151] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/hvigorfile.ts +[2025-05-09T15:47:10.156] [DEBUG] debug-file - Module utils task initialization takes 1 ms +[2025-05-09T15:47:10.155] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=utils, buildMode=debug +[2025-05-09T15:47:10.158] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/hvigorfile.ts +[2025-05-09T15:47:10.164] [DEBUG] debug-file - Module mypage task initialization takes 1 ms +[2025-05-09T15:47:10.168] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/hvigorfile.ts +[2025-05-09T15:47:10.163] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=mypage, buildMode=debug +[2025-05-09T15:47:10.172] [DEBUG] debug-file - Module basic task initialization takes 1 ms +[2025-05-09T15:47:10.171] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=basic, buildMode=debug +[2025-05-09T15:47:10.175] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/hvigorfile.ts +[2025-05-09T15:47:10.179] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=Home, buildMode=debug +[2025-05-09T15:47:10.180] [DEBUG] debug-file - Module Home task initialization takes 1 ms +[2025-05-09T15:47:10.182] [DEBUG] debug-file - hvigorfile, resolving /Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/hvigorfile.ts +[2025-05-09T15:47:10.185] [DEBUG] debug-file - Start initialize module-target build option map, moduleName=register, buildMode=debug +[2025-05-09T15:47:10.186] [DEBUG] debug-file - Module register task initialization takes 1 ms +[2025-05-09T15:47:10.187] [DEBUG] debug-file - project has submodules:default,uicomponents,utils,mypage,basic,Home,register +[2025-05-09T15:47:10.205] [DEBUG] debug-file - Configuration task cost before running: 919 ms +[2025-05-09T15:47:10.230] [DEBUG] debug-file - default : clean cost memory -8.51708984375 +[2025-05-09T15:47:10.206] [DEBUG] debug-file - Executing task :default:clean +[2025-05-09T15:47:10.232] [DEBUG] debug-file - Executing task :uicomponents:clean +[2025-05-09T15:47:10.233] [DEBUG] debug-file - Executing task :utils:clean +[2025-05-09T15:47:10.232] [DEBUG] debug-file - uicomponents : clean cost memory 0.20479583740234375 +[2025-05-09T15:47:10.235] [DEBUG] debug-file - utils : clean cost memory 0.2655181884765625 +[2025-05-09T15:47:10.237] [DEBUG] debug-file - mypage : clean cost memory 0.26578521728515625 +[2025-05-09T15:47:10.238] [DEBUG] debug-file - Executing task :basic:clean +[2025-05-09T15:47:10.236] [DEBUG] debug-file - Executing task :mypage:clean +[2025-05-09T15:47:10.240] [DEBUG] debug-file - basic : clean cost memory 0.2654876708984375 +[2025-05-09T15:47:10.240] [DEBUG] debug-file - Executing task :Home:clean +[2025-05-09T15:47:10.243] [DEBUG] debug-file - Executing task :register:clean +[2025-05-09T15:47:10.243] [DEBUG] debug-file - Home : clean cost memory 0.26555633544921875 +[2025-05-09T15:47:10.249] [DEBUG] debug-file - Module 'default' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.245] [DEBUG] debug-file - register : clean cost memory 0.265716552734375 +[2025-05-09T15:47:09.086] [DEBUG] debug-file - env: hvigor-config.json5 content = { + modelVersion: '5.0.2', + dependencies: {}, + execution: {}, + logging: {}, + debugging: { stacktrace: true }, + nodeOptions: {} +} +[2025-05-09T15:47:09.302] [DEBUG] debug-file - Since current hvigor version 5.16.2 differs from last hvigor version + undefined, delete file-cache.json and task-cache.json. +[2025-05-09T15:47:09.975] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: appTasks] +[2025-05-09T15:47:10.072] [DEBUG] debug-file - Picking option from product 'default' with build mode 'debug'. +[2025-05-09T15:47:10.082] [DEBUG] debug-file - No signingConfig found, initRemoteHspCache failed. +[2025-05-09T15:47:10.109] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.115] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: hapTasks], plugins: [] } } +[2025-05-09T15:47:10.120] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-09T15:47:10.123] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.128] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: harTasks], plugins: [] } } +[2025-05-09T15:47:10.147] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-09T15:47:10.148] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.153] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: harTasks], plugins: [] } } +[2025-05-09T15:47:10.267] [DEBUG] debug-file - Create resident worker with id: 0. +[2025-05-09T15:47:10.156] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.155] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-09T15:47:10.161] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: harTasks], plugins: [] } } +[2025-05-09T15:47:10.165] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.169] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: harTasks], plugins: [] } } +[2025-05-09T15:47:10.163] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-09T15:47:10.173] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.171] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-09T15:47:10.177] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: harTasks], plugins: [] } } +[2025-05-09T15:47:10.179] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-09T15:47:10.180] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.183] [DEBUG] debug-file - hvigorfile, require result: { default: { system: [Function: harTasks], plugins: [] } } +[2025-05-09T15:47:10.185] [DEBUG] debug-file - Target 'default' config: {} +[2025-05-09T15:47:10.186] [DEBUG] debug-file - hvigorfile, binding custom plugins [] +[2025-05-09T15:47:10.187] [DEBUG] debug-file - module:uicomponents no need to execute packageHap +[2025-05-09T15:47:10.230] [DEBUG] debug-file - runTaskFromQueue task cost before running: 944 ms +[2025-05-09T15:47:10.206] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.232] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.233] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.233] [DEBUG] debug-file - runTaskFromQueue task cost before running: 946 ms +[2025-05-09T15:47:10.235] [DEBUG] debug-file - runTaskFromQueue task cost before running: 948 ms +[2025-05-09T15:47:10.237] [DEBUG] debug-file - runTaskFromQueue task cost before running: 951 ms +[2025-05-09T15:47:10.238] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.236] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.240] [DEBUG] debug-file - runTaskFromQueue task cost before running: 953 ms +[2025-05-09T15:47:10.240] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.243] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.243] [DEBUG] debug-file - runTaskFromQueue task cost before running: 956 ms +[2025-05-09T15:47:10.250] [DEBUG] debug-file - Module 'default' target 'ohosTest' using build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} in this build. +[2025-05-09T15:47:10.245] [DEBUG] debug-file - runTaskFromQueue task cost before running: 958 ms +[2025-05-09T15:47:09.086] [DEBUG] debug-file - env: daemon=false +[2025-05-09T15:47:09.302] [DEBUG] debug-file - Cache service initialization finished in 1 ms +[2025-05-09T15:47:10.072] [DEBUG] debug-file - Product 'default' build option: {} +[2025-05-09T15:47:10.109] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/hvigorfile.ts +[2025-05-09T15:47:10.115] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: hapTasks] +[2025-05-09T15:47:10.120] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-09T15:47:10.123] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/hvigorfile.ts +[2025-05-09T15:47:10.128] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: harTasks] +[2025-05-09T15:47:10.147] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-09T15:47:10.148] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/hvigorfile.ts +[2025-05-09T15:47:10.153] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: harTasks] +[2025-05-09T15:47:10.268] [DEBUG] debug-file - Create resident worker with id: 1. +[2025-05-09T15:47:10.156] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/hvigorfile.ts +[2025-05-09T15:47:10.155] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-09T15:47:10.161] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: harTasks] +[2025-05-09T15:47:10.165] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/hvigorfile.ts +[2025-05-09T15:47:10.169] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: harTasks] +[2025-05-09T15:47:10.163] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-09T15:47:10.173] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/hvigorfile.ts +[2025-05-09T15:47:10.172] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-09T15:47:10.177] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: harTasks] +[2025-05-09T15:47:10.179] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-09T15:47:10.180] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/hvigorfile.ts +[2025-05-09T15:47:10.183] [DEBUG] debug-file - hvigorfile, binding system plugins [Function: harTasks] +[2025-05-09T15:47:10.185] [DEBUG] debug-file - Target 'ohosTest' config: {} +[2025-05-09T15:47:10.186] [DEBUG] debug-file - hvigorfile, no custom plugins were found in /Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/hvigorfile.ts +[2025-05-09T15:47:10.187] [DEBUG] debug-file - module:utils no need to execute packageHap +[2025-05-09T15:47:10.231] [INFO] debug-file - Finished :default:clean... after 25 ms +[2025-05-09T15:47:10.233] [INFO] debug-file - Finished :uicomponents:clean... after 1 ms +[2025-05-09T15:47:10.235] [INFO] debug-file - Finished :utils:clean... after 2 ms +[2025-05-09T15:47:10.237] [INFO] debug-file - Finished :mypage:clean... after 2 ms +[2025-05-09T15:47:10.240] [INFO] debug-file - Finished :basic:clean... after 2 ms +[2025-05-09T15:47:10.243] [INFO] debug-file - Finished :Home:clean... after 3 ms +[2025-05-09T15:47:10.252] [DEBUG] debug-file - Module 'uicomponents' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.245] [INFO] debug-file - Finished :register:clean... after 2 ms +[2025-05-09T15:47:09.086] [DEBUG] debug-file - no-daemon, use the parent process.execArgv --max-old-space-size=8192,--expose-gc +[2025-05-09T15:47:10.072] [DEBUG] debug-file - End initialize project's product build option map with build mode 'debug'. +[2025-05-09T15:47:10.109] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/hvigorfile.ts +[2025-05-09T15:47:10.120] [DEBUG] debug-file - Module 'default' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-09T15:47:10.123] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/hvigorfile.ts +[2025-05-09T15:47:10.147] [DEBUG] debug-file - Module 'uicomponents' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-09T15:47:10.148] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/hvigorfile.ts +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Current worker pool is stopped or closed. +[2025-05-09T15:47:10.156] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/hvigorfile.ts +[2025-05-09T15:47:10.155] [DEBUG] debug-file - Module 'utils' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-09T15:47:10.165] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/hvigorfile.ts +[2025-05-09T15:47:10.163] [DEBUG] debug-file - Module 'mypage' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-09T15:47:10.173] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/hvigorfile.ts +[2025-05-09T15:47:10.172] [DEBUG] debug-file - Module 'basic' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-09T15:47:10.179] [DEBUG] debug-file - Module 'Home' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-09T15:47:10.180] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/hvigorfile.ts +[2025-05-09T15:47:10.185] [DEBUG] debug-file - Module 'register' target 'default' build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} +[2025-05-09T15:47:10.186] [DEBUG] debug-file - hvigorfile, resolve finished /Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/hvigorfile.ts +[2025-05-09T15:47:10.187] [DEBUG] debug-file - module:mypage no need to execute packageHap +[2025-05-09T15:47:10.253] [DEBUG] debug-file - Module 'utils' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.245] [DEBUG] debug-file - Executing task ::clean +[2025-05-09T15:47:10.120] [DEBUG] debug-file - Module 'default' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-09T15:47:10.147] [DEBUG] debug-file - Module 'uicomponents' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Clear worker 0. +[2025-05-09T15:47:10.155] [DEBUG] debug-file - Module 'utils' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-09T15:47:10.163] [DEBUG] debug-file - Module 'mypage' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-09T15:47:10.172] [DEBUG] debug-file - Module 'basic' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-09T15:47:10.179] [DEBUG] debug-file - Module 'Home' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-09T15:47:10.185] [DEBUG] debug-file - Module 'register' target 'ohosTest' build option: { + "debuggable": true, + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "default" +} +[2025-05-09T15:47:10.187] [DEBUG] debug-file - module:basic no need to execute packageHap +[2025-05-09T15:47:10.255] [DEBUG] debug-file - Module 'mypage' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.245] [DEBUG] debug-file - clean: Worker pool is inactive. +[2025-05-09T15:47:10.120] [DEBUG] debug-file - End initialize module-target build option map, moduleName=default +[2025-05-09T15:47:10.147] [DEBUG] debug-file - End initialize module-target build option map, moduleName=uicomponents +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Worker 0 has been cleared. +[2025-05-09T15:47:10.155] [DEBUG] debug-file - End initialize module-target build option map, moduleName=utils +[2025-05-09T15:47:10.163] [DEBUG] debug-file - End initialize module-target build option map, moduleName=mypage +[2025-05-09T15:47:10.172] [DEBUG] debug-file - End initialize module-target build option map, moduleName=basic +[2025-05-09T15:47:10.179] [DEBUG] debug-file - End initialize module-target build option map, moduleName=Home +[2025-05-09T15:47:10.185] [DEBUG] debug-file - End initialize module-target build option map, moduleName=register +[2025-05-09T15:47:10.187] [DEBUG] debug-file - module:Home no need to execute packageHap +[2025-05-09T15:47:10.257] [DEBUG] debug-file - Module 'basic' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.245] [DEBUG] debug-file - harmony : clean cost memory 0.027099609375 +[2025-05-09T15:47:10.120] [DEBUG] debug-file - Module 'default' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.147] [DEBUG] debug-file - Module 'uicomponents' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Current idle worker size: 1. +[2025-05-09T15:47:10.155] [DEBUG] debug-file - Module 'utils' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.163] [DEBUG] debug-file - Module 'mypage' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.172] [DEBUG] debug-file - Module 'basic' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.179] [DEBUG] debug-file - Module 'Home' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.185] [DEBUG] debug-file - Module 'register' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.187] [DEBUG] debug-file - module:register no need to execute packageHap +[2025-05-09T15:47:10.258] [DEBUG] debug-file - Module 'Home' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.245] [DEBUG] debug-file - runTaskFromQueue task cost before running: 959 ms +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Current busy worker size: 0. +[2025-05-09T15:47:10.187] [DEBUG] debug-file - start to load updatedOhPackageInfo to the disk +[2025-05-09T15:47:10.260] [DEBUG] debug-file - Module 'register' target 'default' using build option: { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" +} in this build. +[2025-05-09T15:47:10.245] [INFO] debug-file - Finished ::clean... after 1 ms +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Clear worker 1. +[2025-05-09T15:47:10.189] [DEBUG] debug-file - load to the disk finished +[2025-05-09T15:47:10.266] [DEBUG] debug-file - Since there is no instance or instance is terminated, create a new worker pool. +[2025-05-09T15:47:10.245] [DEBUG] debug-file - Executing task :default:init +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Worker 1 has been cleared. +[2025-05-09T15:47:10.190] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.266] [DEBUG] debug-file - Worker pool is initialized with config: { + minPoolNum: 2, + maxPoolNum: undefined, + maxCoreSize: undefined, + cacheCapacity: undefined, + cacheTtl: undefined +} +[2025-05-09T15:47:10.245] [DEBUG] debug-file - default : init cost memory 0.010162353515625 +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Current idle worker size: 0. +[2025-05-09T15:47:10.193] [DEBUG] debug-file - Module harmony Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.245] [DEBUG] debug-file - runTaskFromQueue task cost before running: 959 ms +[2025-05-09T15:47:10.269] [DEBUG] debug-file - Current busy worker size: 0. +[2025-05-09T15:47:10.193] [DEBUG] debug-file - Module harmony's total dependency: 1 +[2025-05-09T15:47:10.245] [INFO] debug-file - Finished :default:init... after 1 ms +[2025-05-09T15:47:10.269] [DEBUG] debug-file - hvigor build process will be closed. +[2025-05-09T15:47:10.193] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Executing task :uicomponents:init +[2025-05-09T15:47:10.273] [DEBUG] debug-file - worker[0] exits with exit code 0. +[2025-05-09T15:47:10.195] [DEBUG] debug-file - Module default Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic,/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils,/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage,/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home,/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register,/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.246] [DEBUG] debug-file - uicomponents : init cost memory 0.0080413818359375 +[2025-05-09T15:47:10.273] [DEBUG] debug-file - worker[1] exits with exit code 0. +[2025-05-09T15:47:10.195] [DEBUG] debug-file - Module default's total dependency: 6 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - runTaskFromQueue task cost before running: 959 ms +[2025-05-09T15:47:10.273] [DEBUG] debug-file - Current worker pool is terminated. +[2025-05-09T15:47:10.197] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.246] [INFO] debug-file - Finished :uicomponents:init... after 1 ms +[2025-05-09T15:47:10.198] [DEBUG] debug-file - Module uicomponents Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Executing task :utils:init +[2025-05-09T15:47:10.198] [DEBUG] debug-file - Module uicomponents's total dependency: 1 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - utils : init cost memory 0.00803375244140625 +[2025-05-09T15:47:10.198] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.246] [DEBUG] debug-file - runTaskFromQueue task cost before running: 959 ms +[2025-05-09T15:47:10.199] [DEBUG] debug-file - Module utils Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.246] [INFO] debug-file - Finished :utils:init... after 1 ms +[2025-05-09T15:47:10.199] [DEBUG] debug-file - Module utils's total dependency: 1 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Executing task :mypage:init +[2025-05-09T15:47:10.199] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.246] [DEBUG] debug-file - mypage : init cost memory 0.00803375244140625 +[2025-05-09T15:47:10.200] [DEBUG] debug-file - Module mypage Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic,/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.246] [DEBUG] debug-file - runTaskFromQueue task cost before running: 959 ms +[2025-05-09T15:47:10.200] [DEBUG] debug-file - Module mypage's total dependency: 2 +[2025-05-09T15:47:10.246] [INFO] debug-file - Finished :mypage:init... after 1 ms +[2025-05-09T15:47:10.200] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Executing task :basic:init +[2025-05-09T15:47:10.200] [DEBUG] debug-file - Module basic Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.246] [DEBUG] debug-file - basic : init cost memory 0.00803375244140625 +[2025-05-09T15:47:10.200] [DEBUG] debug-file - Module basic's total dependency: 1 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - runTaskFromQueue task cost before running: 959 ms +[2025-05-09T15:47:10.201] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.246] [INFO] debug-file - Finished :basic:init... after 1 ms +[2025-05-09T15:47:10.201] [DEBUG] debug-file - Module Home Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic,/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Executing task :Home:init +[2025-05-09T15:47:10.201] [DEBUG] debug-file - Module Home's total dependency: 2 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Home : init cost memory 0.00803375244140625 +[2025-05-09T15:47:10.201] [DEBUG] debug-file - Start to initialize dependency information. +[2025-05-09T15:47:10.246] [DEBUG] debug-file - runTaskFromQueue task cost before running: 960 ms +[2025-05-09T15:47:10.202] [DEBUG] debug-file - Module register Collected Dependency: /Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic,/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js +[2025-05-09T15:47:10.246] [INFO] debug-file - Finished :Home:init... after 1 ms +[2025-05-09T15:47:10.202] [DEBUG] debug-file - Module register's total dependency: 2 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Executing task :register:init +[2025-05-09T15:47:10.202] [DEBUG] debug-file - Configuration phase cost:896 ms +[2025-05-09T15:47:10.246] [DEBUG] debug-file - register : init cost memory 0.00803375244140625 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - runTaskFromQueue task cost before running: 960 ms +[2025-05-09T15:47:10.246] [INFO] debug-file - Finished :register:init... after 1 ms +[2025-05-09T15:47:10.246] [DEBUG] debug-file - Executing task ::init +[2025-05-09T15:47:10.246] [DEBUG] debug-file - harmony : init cost memory 0.00946044921875 +[2025-05-09T15:47:10.246] [DEBUG] debug-file - runTaskFromQueue task cost before running: 960 ms +[2025-05-09T15:47:10.246] [INFO] debug-file - Finished ::init... after 1 ms diff --git a/.hvigor/outputs/sync/fileCache.json b/.hvigor/outputs/sync/fileCache.json new file mode 100644 index 0000000..9193318 --- /dev/null +++ b/.hvigor/outputs/sync/fileCache.json @@ -0,0 +1 @@ +{"CACHE_SYNC_FILE_HASH":{"/Users/gandanxiangzhao/Downloads/Expert/harmony/hvigor/hvigor-config.json5":"20319a4ef107cc47d2bf9a1ac691d6c733fd711688e908e288fb7925f48930b1","/Users/gandanxiangzhao/Downloads/Expert/harmony/build-profile.json5":"4f159b63fd533768ffc0f154aab15dbece8a78dee82421b19c7ccc2259583fb3","/Users/gandanxiangzhao/Downloads/Expert/harmony/hvigorfile.ts":"4b8b0f7c80f5ab496f613571147388f5fa2db267caf23c0c395e235f684243da","/Users/gandanxiangzhao/Downloads/Expert/harmony/oh-package.json5":"068f92ff2d99e7ba31124a3f88c32815b3c0220d46317ef5e63d4e5507dec3c5","/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build-profile.json5":"b05f2e93717d5619d015242ddf5c0b16878efafb308ea35409fe4aaf5261fdb3","/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/hvigorfile.ts":"4b8b0f7c80f5ab496f613571147388f5fa2db267caf23c0c395e235f684243da","/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/oh-package.json5":"4a8598ab9bf6607c1ab389b74dd4753a36a31df93879c9ab6aed959cb36b9dce","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build-profile.json5":"b703fbdf4e8f4a927137bccc699dfccc8e9a989c10f883710f4c5e9f7e58f84a","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/hvigorfile.ts":"e27f4d8160361104348dff98f8f86381a7444a112f8b6bdb1945fce3cab2dfb6","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/oh-package.json5":"d88b8312eae1ab7dc655d34e352876a1eb87ab0fe512aff1a04498acb1ab051d","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build-profile.json5":"9ce5eceb1bc7d4b80401ecab45117eb2a82eb7231e27e60d1080d0bfe5755524","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/hvigorfile.ts":"8a05edf077b615a93dd193b8b219a9d81fd802c57234a16b8a2acd6b942a018e","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/oh-package.json5":"6b911a31909105546015d359633369267c125b97a5d0f3b0dc3bcab12a08c9e9","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build-profile.json5":"9b89183c24483338b38d9b2fb345a66c75e97fbd32e2f9ee70f1f25edb3269c8","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/hvigorfile.ts":"999b9b9a715325665778aae13050f00201629564c8f760fe11116a4b678e02da","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/oh-package.json5":"b8057721cf5c5fe8da4dab5d2d5e06d33b00d067411be974917ac552d2c0589c","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build-profile.json5":"7477805ff4b896e8475f6cfa1509715e6e8c7694fe643c0a1b76185626c5d2f8","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/hvigorfile.ts":"fd8160090e16e49c719256141a1407758987c28d92f10db27e1bf1d6f38f2d3a","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/oh-package.json5":"88f9db9e1bf86367a620c95d302ded2bedc172a78ba9ebea6b09353a8ccde631","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build-profile.json5":"abf2da0306988ce6712bae36a070c0a13f764d5936124218c21e368db81052f7","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/hvigorfile.ts":"c91ffa76d2a6eb8d2f7f83a6ce26354851f3bafb02bbf4de8706741b3378e443","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/oh-package.json5":"bc1845dce5016980622f462664e167e3789359f8bafff276e6c3297fb23723e9","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build-profile.json5":"a82329b08da958ff28f376e8c7b454aa462ad933c3554ce1598cf67dfc1d71dd","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/hvigorfile.ts":"c8227f76f37b0315187105ccc7f5e8ece7fb3163b39202df7c9614310d99c0e0","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/oh-package.json5":"4673942b26a12891f0adc0c1d565477298a3989a4cc0a43ff6cbaa2950d453f2","/Users/gandanxiangzhao/Downloads/Expert/harmony/.hvigor/outputs/sync/output.json":"d0e04b0e623a90277051245e14b691bba3384d846c2519a3f272b3303ae9731a","SDK_LOCATION":"/Applications/DevEco-Studio.app/Contents/sdk"},"OHPM_INSTALL_FILE_HASH":{"/Users/gandanxiangzhao/Downloads/Expert/harmony/oh-package.json5":"068f92ff2d99e7ba31124a3f88c32815b3c0220d46317ef5e63d4e5507dec3c5","/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/lock.json5":"85fa316843d5998b214e6d903078467ef165c071f85e41c5c770f8bffad92522","/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/oh-package.json5":"4a8598ab9bf6607c1ab389b74dd4753a36a31df93879c9ab6aed959cb36b9dce","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/oh-package.json5":"d88b8312eae1ab7dc655d34e352876a1eb87ab0fe512aff1a04498acb1ab051d","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/oh-package.json5":"6b911a31909105546015d359633369267c125b97a5d0f3b0dc3bcab12a08c9e9","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/oh-package.json5":"b8057721cf5c5fe8da4dab5d2d5e06d33b00d067411be974917ac552d2c0589c","/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/oh-package.json5":"88f9db9e1bf86367a620c95d302ded2bedc172a78ba9ebea6b09353a8ccde631","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/oh-package.json5":"bc1845dce5016980622f462664e167e3789359f8bafff276e6c3297fb23723e9","/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/oh-package.json5":"4673942b26a12891f0adc0c1d565477298a3989a4cc0a43ff6cbaa2950d453f2","/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules":true,"/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/oh_modules":true,"/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/oh_modules":false,"/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/oh_modules":true,"/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/oh_modules":true,"/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/oh_modules":false,"/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/oh_modules":true,"/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/oh_modules":true}} \ No newline at end of file diff --git a/.hvigor/outputs/sync/output.json b/.hvigor/outputs/sync/output.json new file mode 100644 index 0000000..e855842 --- /dev/null +++ b/.hvigor/outputs/sync/output.json @@ -0,0 +1,718 @@ +{ + "ohos-module-default": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build", + "DEPENDENCY_INFO": { + "@itcast/basic": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic", + "utils": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils", + "mypage": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage", + "home": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home", + "register": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register", + "@ohos/crypto-js": "/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js" + }, + "TARGETS": { + "default": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/src/main", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/src/main/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/outputs/default", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/loader_out/default", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/loader_out_lite/default", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/res/default", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/res/default/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/cache/default/default@CompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/cache/default/default@CompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/loader/default/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/manifest/default", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/hap_metadata/default/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/source_map/default" + }, + "BUILD_OPTION": { + "debuggable": true + } + }, + "ohosTest": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/src/ohosTest", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/src/ohosTest/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/outputs/ohosTest", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/loader_out/ohosTest", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/loader_out_lite/ohosTest", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/res/ohosTest", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/res/ohosTest/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/cache/ohosTest/ohosTest@OhosTestCompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/cache/ohosTest/ohosTest@OhosTestCompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/loader/ohosTest/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/manifest/ohosTest", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/hap_metadata/ohosTest/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert/build/default/intermediates/source_map/ohosTest" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-module-uicomponents": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build", + "DEPENDENCY_INFO": { + "@ohos/crypto-js": "/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js" + }, + "TARGETS": { + "default": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/src/main", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/src/main/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/outputs/default", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/loader_out/default", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/loader_out_lite/default", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/res/default", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/res/default/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/cache/default/default@HarCompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/cache/default/default@HarCompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/loader/default/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/manifest/default", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/hap_metadata/default/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents/build/default/intermediates/source_map/default" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-module-utils": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build", + "DEPENDENCY_INFO": { + "@ohos/crypto-js": "/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js" + }, + "TARGETS": { + "default": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/src/main", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/src/main/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/outputs/default", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/loader_out/default", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/loader_out_lite/default", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/res/default", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/res/default/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/cache/default/default@HarCompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/cache/default/default@HarCompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/loader/default/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/manifest/default", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/hap_metadata/default/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils/build/default/intermediates/source_map/default" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-module-mypage": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build", + "DEPENDENCY_INFO": { + "@itcast/basic": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic", + "@ohos/crypto-js": "/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js" + }, + "TARGETS": { + "default": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/src/main", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/src/main/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/outputs/default", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/loader_out/default", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/loader_out_lite/default", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/res/default", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/res/default/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/cache/default/default@HarCompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/cache/default/default@HarCompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/loader/default/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/manifest/default", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/hap_metadata/default/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage/build/default/intermediates/source_map/default" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-module-basic": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build", + "DEPENDENCY_INFO": { + "@ohos/crypto-js": "/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js" + }, + "TARGETS": { + "default": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/src/main", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/src/main/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/outputs/default", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/loader_out/default", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/loader_out_lite/default", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/res/default", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/res/default/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/cache/default/default@HarCompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/cache/default/default@HarCompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/loader/default/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/manifest/default", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/hap_metadata/default/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic/build/default/intermediates/source_map/default" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-module-Home": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build", + "DEPENDENCY_INFO": { + "@itcast/basic": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic", + "@ohos/crypto-js": "/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js" + }, + "TARGETS": { + "default": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/src/main", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/src/main/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/outputs/default", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/loader_out/default", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/loader_out_lite/default", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/res/default", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/res/default/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/cache/default/default@HarCompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/cache/default/default@HarCompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/loader/default/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/manifest/default", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/hap_metadata/default/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home/build/default/intermediates/source_map/default" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-module-register": { + "SELECT_TARGET": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build", + "DEPENDENCY_INFO": { + "@itcast/basic": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic", + "@ohos/crypto-js": "/Users/gandanxiangzhao/Downloads/Expert/harmony/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js" + }, + "TARGETS": { + "default": { + "SOURCE_ROOT": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/src/main", + "RESOURCES_PATH": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/src/main/resources" + ], + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/outputs/default", + "INTERMEDIA_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates", + "JS_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/loader_out/default", + "JS_LITE_ASSETS_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/loader_out_lite/default", + "RES_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/res/default", + "RES_PROFILE_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/res/default/resources/base/profile", + "ETS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/cache/default/default@HarCompileArkTS/esmodule", + "JS_SUPER_VISUAL_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/cache/default/default@HarCompileJS/jsbundle", + "WORKER_LOADER": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/loader/default/loader.json", + "MANIFEST_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/manifest/default", + "OUTPUT_METADATA_JSON": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/hap_metadata/default/output_metadata.json", + "SOURCE_MAP_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register/build/default/intermediates/source_map/default" + }, + "BUILD_OPTION": { + "debuggable": true + } + } + }, + "BUILD_OPTION": { + "default-default": { + "debuggable": true, + "copyFrom": "default", + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + }, + "name": "debug" + } + }, + "BUILD_PROFILE_OPT": { + "apiType": "stageMode", + "buildOption": {}, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + } + }, + { + "name": "default" + }, + { + "name": "debug" + } + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] + }, + "BUILD_CACHE_DIR": "" + }, + "ohos-project": { + "SELECT_PRODUCT_NAME": "default", + "MODULE_BUILD_DIR": "/Users/gandanxiangzhao/Downloads/Expert/harmony/build", + "BUNDLE_NAME": "com.example.expert", + "BUILD_PATH": { + "OUTPUT_PATH": "/Users/gandanxiangzhao/Downloads/Expert/harmony/build/outputs/default" + }, + "MODULES": [ + { + "name": "default", + "srcPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony/products/expert", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ], + "belongProjectPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony" + }, + { + "name": "uicomponents", + "srcPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/uicomponents", + "belongProjectPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony" + }, + { + "name": "utils", + "srcPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/utils", + "belongProjectPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony" + }, + { + "name": "mypage", + "srcPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/mypage", + "belongProjectPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony" + }, + { + "name": "basic", + "srcPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony/commons/basic", + "belongProjectPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony" + }, + { + "name": "Home", + "srcPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/Home", + "belongProjectPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony" + }, + { + "name": "register", + "srcPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony/features/register", + "belongProjectPath": "/Users/gandanxiangzhao/Downloads/Expert/harmony" + } + ], + "PROFILE_OPT": { + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.2(14)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug" + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "default", + "srcPath": "./products/expert", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "uicomponents", + "srcPath": "./commons/uicomponents" + }, + { + "name": "utils", + "srcPath": "./commons/utils" + }, + { + "name": "mypage", + "srcPath": "./features/mypage" + }, + { + "name": "basic", + "srcPath": "./commons/basic" + }, + { + "name": "Home", + "srcPath": "./features/Home" + }, + { + "name": "register", + "srcPath": "./features/register" + } + ] + }, + "CONFIG_PROPERTIES": { + "enableSignTask": true, + "skipNativeIncremental": false, + "hvigor.keepDependency": true + }, + "OVERALL_PROJECT_PATHS": [ + "/Users/gandanxiangzhao/Downloads/Expert/harmony" + ], + "BUILD_CACHE_DIR": "" + }, + "version": 1 +} \ No newline at end of file diff --git a/AppScope/app.json5 b/AppScope/app.json5 new file mode 100644 index 0000000..0a93d67 --- /dev/null +++ b/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.expert", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/AppScope/resources/base/element/string.json b/AppScope/resources/base/element/string.json new file mode 100644 index 0000000..44bdc2c --- /dev/null +++ b/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "Expert" + } + ] +} diff --git a/AppScope/resources/base/media/background.png b/AppScope/resources/base/media/background.png new file mode 100644 index 0000000..923f2b3 Binary files /dev/null and b/AppScope/resources/base/media/background.png differ diff --git a/AppScope/resources/base/media/foreground.png b/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000..97014d3 Binary files /dev/null and b/AppScope/resources/base/media/foreground.png differ diff --git a/AppScope/resources/base/media/layered_image.json b/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000..fb49920 --- /dev/null +++ b/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/build-profile.json5 b/build-profile.json5 new file mode 100644 index 0000000..23febd7 --- /dev/null +++ b/build-profile.json5 @@ -0,0 +1,65 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.2(14)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "default", + "srcPath": "./products/expert", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "uicomponents", + "srcPath": "./commons/uicomponents", + }, + { + "name": "utils", + "srcPath": "./commons/utils", + }, + { + "name": "mypage", + "srcPath": "./features/mypage" + }, + { + "name": "basic", + "srcPath": "./commons/basic", + }, + { + "name": "Home", + "srcPath": "./features/Home", + }, + { + "name": "register", + "srcPath": "./features/register", + } + ] +} \ No newline at end of file diff --git a/code-linter.json5 b/code-linter.json5 new file mode 100644 index 0000000..073990f --- /dev/null +++ b/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/commons/basic/.gitignore b/commons/basic/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/commons/basic/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/commons/basic/BuildProfile.ets b/commons/basic/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/commons/basic/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/commons/basic/Index.ets b/commons/basic/Index.ets new file mode 100644 index 0000000..b68d661 --- /dev/null +++ b/commons/basic/Index.ets @@ -0,0 +1,27 @@ +export { hdHttp, HdResponse } from './src/main/ets/utils/request' + +export { authStore, HdUser, AUTH_STORE_KEY } from './src/main/ets/utils/auth' + +export { logger } from './src/main/ets/utils/logger' + +export { getTimeText, getPercentText } from './src/main/ets/utils/base' + +export { themeManager } from './src/main/ets/utils/themeManager' + +export { Base64Util } from './src/main/ets/utils/Base64Util' + +export { ChangeUtil } from './src/main/ets/utils/ChangeUtil' + +export { HdNav } from './src/main/ets/components/HdNav' + +export { BasicConstant } from './src/main/ets/constants/BasicConstant' + +export { preferenceStore } from './src/main/ets/utils/PreferenceStore' + +export { LoginInfo,Data } from './src/main/ets/models/LoginInfoModel' + +export { DataWebModel } from './src/main/ets/models/DataWebModel' + +export { PromptActionClass } from './src/main/ets/components/PromptActionClass' + +export { RequestDefaultModel } from './src/main/ets/models/RequestDefaultModel' diff --git a/commons/basic/build-profile.json5 b/commons/basic/build-profile.json5 new file mode 100644 index 0000000..e6773f9 --- /dev/null +++ b/commons/basic/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/commons/basic/consumer-rules.txt b/commons/basic/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/commons/basic/hvigorfile.ts b/commons/basic/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/commons/basic/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/commons/basic/obfuscation-rules.txt b/commons/basic/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/commons/basic/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/commons/basic/oh-package.json5 b/commons/basic/oh-package.json5 new file mode 100644 index 0000000..f15dd9f --- /dev/null +++ b/commons/basic/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "@itcast/basic", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/commons/basic/src/main/ets/components/HdNav.ets b/commons/basic/src/main/ets/components/HdNav.ets new file mode 100644 index 0000000..7984385 --- /dev/null +++ b/commons/basic/src/main/ets/components/HdNav.ets @@ -0,0 +1,90 @@ +import { router } from '@kit.ArkUI' + +@Builder +function defaultBuilder(): void { + +} + +@Component +export struct HdNav { + @StorageProp('topHeight') + topHeight: number = 0 + @Prop + title: string = '' + @Prop + textColor: ResourceStr = $r('app.color.top_title') + @Prop + bgColor: ResourceStr = $r('app.color.top_bg') + @Prop + hasBorder: boolean = false + @Prop + leftIcon: ResourceStr = $r('app.media.top_back') + @Prop + rightIcon: ResourceStr = $r('sys.media.ohos_ic_public_more') + @Prop + showRightIcon: boolean = true + @Prop + showLeftIcon: boolean = true + @Prop + showRightText: boolean = false + @Prop + rightText: string = '' + @BuilderParam + titleBuilder: () => void = defaultBuilder + @BuilderParam + menuBuilder: () => void = defaultBuilder + + build() { + Row({ space: 16 }) { + if (this.showLeftIcon) { + Image(this.leftIcon) + .size({ width: 24, height: 24 }) + .margin({left:-5}) + .onClick(() => router.back()) + .fillColor($r('app.color.black')) + } + else { + Blank() + .width(24) + } + Row() { + if (this.title) { + Text(this.title) + .fontWeight(600) + .layoutWeight(1) + .textAlign(TextAlign.Center) + .fontSize(20) + .fontColor(this.textColor) + .maxLines(1) + .textOverflow({ overflow: TextOverflow.Ellipsis }) + } else if (this.titleBuilder) { + this.titleBuilder() + } + } + .height(56) + .layoutWeight(1) + + if (this.showRightIcon) { + Image(this.rightIcon) + .size({ width: 24, height: 24 }) + .objectFit(ImageFit.Contain) + .bindMenu(this.menuBuilder) + } else if (this.showRightText) + { + Text(this.rightText) + .fontSize(16) + .fontColor(this.textColor) + .margin({right:10}) + } + else { + Blank() + .width(24) + } + } + .padding({ left: 16, right: 16, top: this.topHeight }) + .height(56 + this.topHeight) + .width('100%') + .backgroundColor(this.bgColor) + + } +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/components/HdWeb.ets b/commons/basic/src/main/ets/components/HdWeb.ets new file mode 100644 index 0000000..c3ac490 --- /dev/null +++ b/commons/basic/src/main/ets/components/HdWeb.ets @@ -0,0 +1,24 @@ +import { webview } from '@kit.ArkWeb' +import { logger } from '../utils/logger' + +@Component +export struct HdWeb { + layoutMode: WebLayoutMode = WebLayoutMode.NONE + src: ResourceStr = $rawfile('detail.html') + onLoad: () => void = () => { + } + controller: webview.WebviewController = new webview.WebviewController() + + build() { + Web({ src: this.src, controller: this.controller }) + .javaScriptAccess(true) + .onPageEnd(() => { + this.onLoad() + }) + .onErrorReceive(event => { + logger.error(event!.error.getErrorInfo()) + }) + .layoutMode(this.layoutMode) + .layoutWeight(1) + } +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/components/PromptActionClass.ets b/commons/basic/src/main/ets/components/PromptActionClass.ets new file mode 100644 index 0000000..6ec850e --- /dev/null +++ b/commons/basic/src/main/ets/components/PromptActionClass.ets @@ -0,0 +1,62 @@ +import { BusinessError } from '@kit.BasicServicesKit'; +import { ComponentContent, promptAction, UIContext } from '@kit.ArkUI'; + +export class PromptActionClass { + static ctx: UIContext; + static contentNode: ComponentContent; + static options: promptAction.BaseDialogOptions; + + static setContext(context: UIContext) { + PromptActionClass.ctx = context; + } + + static setContentNode(node: ComponentContent) { + PromptActionClass.contentNode = node; + } + + static setOptions(options: promptAction.BaseDialogOptions) { + PromptActionClass.options = options; + } + + static openDialog() { + if (PromptActionClass.contentNode !== null) { + PromptActionClass.ctx.getPromptAction().openCustomDialog(PromptActionClass.contentNode, PromptActionClass.options) + .then(() => { + console.info('OpenCustomDialog complete.') + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`OpenCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } + + static closeDialog() { + if (PromptActionClass.contentNode !== null) { + PromptActionClass.ctx.getPromptAction().closeCustomDialog(PromptActionClass.contentNode) + .then(() => { + console.info('CloseCustomDialog complete.') + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`CloseCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } + + static updateDialog(options: promptAction.BaseDialogOptions) { + if (PromptActionClass.contentNode !== null) { + PromptActionClass.ctx.getPromptAction().updateCustomDialog(PromptActionClass.contentNode, options) + .then(() => { + console.info('UpdateCustomDialog complete.') + }) + .catch((error: BusinessError) => { + let message = (error as BusinessError).message; + let code = (error as BusinessError).code; + console.error(`UpdateCustomDialog args error code is ${code}, message is ${message}`); + }) + } + } +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/constants/BasicConstant.ets b/commons/basic/src/main/ets/constants/BasicConstant.ets new file mode 100644 index 0000000..ce5c5b8 --- /dev/null +++ b/commons/basic/src/main/ets/constants/BasicConstant.ets @@ -0,0 +1,18 @@ +export class BasicConstant { + static readonly SPACE_SM = 4 + static readonly SPACE_MD = 10 + static readonly SPACE_LG = 16 + static readonly getyyzc="https://doc.igandan.com/app/integral/permission_expert.html";//隐私政策 + static readonly getzcxy = "http://app.igandan.com/expert_zcxy.jsp";// 注册协议正式地址 + + //测试环境 + static readonly urlimage = "https://dev-app.igandan.com/app/"; + static readonly urlmyLan = "https://dev-app.igandan.com/app/expertAPI/"; + static readonly urlapp = "https://dev-app.igandan.com//app/expertApp/" + static readonly urlHtml = "http://dev-doc.igandan.com/app/" + static readonly imageHeader = "http://doc.igandan.com/app/" + static readonly urlExpert = "https://dev-app.igandan.com/app/expert/" + + + static readonly getStartpage=BasicConstant.urlapp + "startpage"; +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/models/DataWebModel.ets b/commons/basic/src/main/ets/models/DataWebModel.ets new file mode 100644 index 0000000..b001793 --- /dev/null +++ b/commons/basic/src/main/ets/models/DataWebModel.ets @@ -0,0 +1,4 @@ +export class DataWebModel { + url: string = ''; + title: string = ''; +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/models/LoginInfoModel.ets b/commons/basic/src/main/ets/models/LoginInfoModel.ets new file mode 100644 index 0000000..6689fae --- /dev/null +++ b/commons/basic/src/main/ets/models/LoginInfoModel.ets @@ -0,0 +1,55 @@ +import { List } from '@kit.ArkTS'; +export interface LoginInfo{ + special: List ; + YX_accid:string ; + code:string; + data:Data; + YX_token:string; + nginxPath:string; + message:string; +} + +interface SpecialDisease{ + diseaseName:string; + diseaseUuid:string; +} + +export interface Data{ + isEnable:number; + isVisit:number; + modifyDate:string; + currentSpec:string; + deviceType:number; + currentType:number; + deviceSpec:string; + positionName:string; + userName:string; + createDate:string; + password:string; + officeName:string; + certificateImg:string; + birthDate:string; + isStar:number; + countyId:number; + cityId:number; + email:string; + photo:string; + qrcode:string; + mobile:string; + hospitalName:string; + officeUuid:string; + checkInfo:string; + hospitalUuid:string; + officePhone:string; + positionUuid:string; + nation:number; + wechat_qrcode:string; + sex:number; + provId:number; + uuid:string; + intro:string; + certificate:string; + state:number; + realName:string; + specialy:Array; +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/models/RequestDefaultModel.ets b/commons/basic/src/main/ets/models/RequestDefaultModel.ets new file mode 100644 index 0000000..3db3e28 --- /dev/null +++ b/commons/basic/src/main/ets/models/RequestDefaultModel.ets @@ -0,0 +1,13 @@ + +export interface RequestDefaultModel{ + code:string; + data:DefaulyData[]; + message:string; +} + +export interface DefaulyData { + 'officeName':string; + 'officeUuid':string; + 'name':string; + 'uuid':string; +} diff --git a/commons/basic/src/main/ets/utils/Base64Util.ets b/commons/basic/src/main/ets/utils/Base64Util.ets new file mode 100644 index 0000000..e0fb889 --- /dev/null +++ b/commons/basic/src/main/ets/utils/Base64Util.ets @@ -0,0 +1,84 @@ +import util from '@ohos.util'; + +import { buffer } from '@kit.ArkTS'; + +/** + * Base64 工具类 + * author: 鸿蒙布道师 + * since: 2025/03/31 + */ +export class Base64Util { + /** + * 创建 Base64Helper 实例 + * @returns Base64Helper 实例 + */ + private static createBase64Helper(): util.Base64Helper { + return new util.Base64Helper(); + } + + /** + * 编码为 Uint8Array(异步) + * @param array 输入的 Uint8Array 数据 + * @returns 编码后的 Uint8Array 对象 + */ + static encode(array: Uint8Array): Promise { + const base64 = Base64Util.createBase64Helper(); + return base64.encode(array); + } + + /** + * 编码为 Uint8Array(同步) + * @param array 输入的 Uint8Array 数据 + * @returns 编码后的 Uint8Array 对象 + */ + static encodeSync(array: Uint8Array): Uint8Array { + const base64 = Base64Util.createBase64Helper(); + return base64.encodeSync(array); + } + + /** + * 编码为字符串(异步) + * @param array 输入的 Uint8Array 数据 + * @param options 可选参数 + * @returns 编码后的字符串 + */ + static encodeToStr(array: Uint8Array, options?: util.Type): Promise { + const base64 = Base64Util.createBase64Helper(); + return base64.encodeToString(array, options); + } + + /** + * 编码为字符串(同步) + * @param array 输入的 Uint8Array 数据 + * @param options 可选参数 + * @returns 编码后的字符串 + */ + static encodeToStrSync(keyValueStr:string): string { + let array: Uint8Array=new Uint8Array(buffer.from(keyValueStr, 'utf-8').buffer) + const base64 = Base64Util.createBase64Helper(); + + return base64.encodeToStringSync(array, util.Type.BASIC).replaceAll("=", ""); + } + + /** + * 解码为 Uint8Array(异步) + * @param input 输入的 Uint8Array 或字符串 + * @param options 可选参数 + * @returns 解码后的 Uint8Array 对象 + */ + static decode(input: Uint8Array | string, options?: util.Type): Promise { + const base64 = Base64Util.createBase64Helper(); + return base64.decode(input, options); + } + + /** + * 解码为 Uint8Array(同步) + * @param input 输入的 Uint8Array 或字符串 + * @param options 可选参数 + * @returns 解码后的 Uint8Array 对象 + */ + static decodeSync(input: Uint8Array | string, options?: util.Type): Uint8Array { + const base64 = Base64Util.createBase64Helper(); + return base64.decodeSync(input, options); + } +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/utils/ChangeUtil.ets b/commons/basic/src/main/ets/utils/ChangeUtil.ets new file mode 100644 index 0000000..4909a56 --- /dev/null +++ b/commons/basic/src/main/ets/utils/ChangeUtil.ets @@ -0,0 +1,58 @@ +import HashMap from '@ohos.util.HashMap'; +import { Base64Util } from './Base64Util'; +import { CryptoJS } from '@ohos/crypto-js'; + + +export class ChangeUtil { + /** + * 将HashMap转成JsonString + * @param map + * @returns + */ + static map2Json(map:HashMap): string { + let jsonObject: Record = {}; + map.forEach((value, key) => { + if(key != undefined && value != undefined){ + jsonObject[key] = value; + } + }) + return JSON.stringify(jsonObject); + } + + static getSign(extraDatas1: HashMap, secret: string): string { + if(secret!=null) { + let keyValueStr: string = ""; + let entriesArray: Array = Array.from(extraDatas1.keys()); + entriesArray.sort(); + + let sortedMap:HashMap = new HashMap(); + entriesArray.forEach((value: string, index: number) => { + sortedMap.set(value,extraDatas1.get(value)); + keyValueStr +=value+extraDatas1.get(value) + }); + keyValueStr = keyValueStr.replace(" ", ""); + keyValueStr = keyValueStr + CryptoJS.MD5(secret).toString(); + let Md5keyValueStr: string = CryptoJS.MD5(keyValueStr).toString(); + let base64Str:string=Base64Util.encodeToStrSync(Md5keyValueStr); + return base64Str; + } + else + { + return ''; + } + } + + + static isMobileNum(mobiles:string): boolean { + const reg2: RegExp = new RegExp('^(1[3-9])[0-9]{9}$') + + return reg2.test(mobiles); +} + static isPassword(password:string): boolean { + const reg2: RegExp = new RegExp('^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$') + + return reg2.test(password); + } + + +} \ No newline at end of file diff --git a/commons/basic/src/main/ets/utils/PreferenceStore.ets b/commons/basic/src/main/ets/utils/PreferenceStore.ets new file mode 100644 index 0000000..e1ace27 --- /dev/null +++ b/commons/basic/src/main/ets/utils/PreferenceStore.ets @@ -0,0 +1,44 @@ +import { preferences } from '@kit.ArkData' + +class PreferenceStore { + KEY = 'gdxz_config' + store: preferences.Preferences | null = null + + getStore() { + if (!this.store) { + this.store = preferences.getPreferencesSync(getContext(), { name: this.KEY }) + } + return this.store + } + setItemString(keyword: string,value:string) { + this.getStore().putSync(keyword, value) + this.getStore().flush() + } + setItemBoolean(keyword: string,value:boolean) { + this.getStore().putSync(keyword, value) + this.getStore().flush() + } + delItem(keyword: string) { + this.getStore().deleteSync(keyword) + this.getStore().flush() + } + getItemString(keyword: string) { + return this.getStore().getSync(keyword,'') + } + getItemBooleanT(keyword: string):boolean { + return this.getStore().getSync(keyword,true) as boolean + } + getItemBooleanF(keyword: string):boolean { + return this.getStore().getSync(keyword,false) as boolean + } + clear() { + this.getStore().clearSync() + } + + getAll() { + const obj = this.getStore().getAllSync() + return Object.keys(obj) + } +} + +export const preferenceStore = new PreferenceStore() \ No newline at end of file diff --git a/commons/basic/src/main/ets/utils/auth.ets b/commons/basic/src/main/ets/utils/auth.ets new file mode 100644 index 0000000..f9a0410 --- /dev/null +++ b/commons/basic/src/main/ets/utils/auth.ets @@ -0,0 +1,73 @@ +import { preferences } from '@kit.ArkData' +import { router } from '@kit.ArkUI' +import { Data } from '../models/LoginInfoModel' + +export interface HdUser { + id: string + username: string + avatar: string + token: string + refreshToken: string + nickName?: string + totalTime?: number + clockinNumbers?: number +} + +export const AUTH_STORE_KEY = 'authStore' + +class AuthStore { + store: preferences.Preferences | null = null + + getStore() { + if (!this.store) { + this.store = preferences.getPreferencesSync(getContext(), { name: AUTH_STORE_KEY }) + } + return this.store + } + + async setUser(user: Data) { + AppStorage.setOrCreate('user', user) + await this.getStore().put(AUTH_STORE_KEY, JSON.stringify(user)) + await this.getStore().flush() + } + + async delUser() { + AppStorage.setOrCreate('user', {}) + await this.getStore().put(AUTH_STORE_KEY, '{}') + await this.getStore().flush() + } + + initUser() { + const json = this.getStore().getSync(AUTH_STORE_KEY, '{}') as string + AppStorage.setOrCreate('user', JSON.parse(json)) + } + + getUser() { + return AppStorage.get('user') || {} as Data + } + + checkAuth(options: router.RouterOptions | Function) { + // if (this.getUser().token) { + // if (typeof options === 'function') { + // options() + // } else { + // router.pushUrl(options) + // } + // } else { + // if (typeof options === 'function') { + // router.pushUrl({ + // url: 'pages/LoginPage', + // }) + // } else { + // const params = options.params as Record || {} + // params.return_path = options.url + // router.pushUrl({ + // url: 'pages/LoginPage', + // params: params + // }) + // } + // } + } +} + +export const authStore = new AuthStore() \ No newline at end of file diff --git a/commons/basic/src/main/ets/utils/base.ets b/commons/basic/src/main/ets/utils/base.ets new file mode 100644 index 0000000..1c77d77 --- /dev/null +++ b/commons/basic/src/main/ets/utils/base.ets @@ -0,0 +1,10 @@ +export const getTimeText = (time: number = 0, hasUnit = true) => { + if (time < 3600) { + return String(Math.floor(time / 60)) + (hasUnit ? ' 分钟' : '') + } else { + return String(Math.round(time / 3600 * 10) / 10) + (hasUnit ? ' 小时' : '') + } +} + +export const getPercentText = + (value: number, total: number) => Math.round(value / total * 100) + '%' diff --git a/commons/basic/src/main/ets/utils/expert_request.ets b/commons/basic/src/main/ets/utils/expert_request.ets new file mode 100644 index 0000000..8b11911 --- /dev/null +++ b/commons/basic/src/main/ets/utils/expert_request.ets @@ -0,0 +1,289 @@ +import { http } from '@kit.NetworkKit'; +import { authStore } from './auth'; +import { promptAction, router } from '@kit.ArkUI'; +import { BusinessError } from '@ohos.base'; +import { logger } from './logger'; +import { HashMap } from '@kit.ArkTS'; +import { CryptoJS } from '@ohos/crypto-js' +import { Base64Util } from './Base64Util'; +import { ChangeUtil } from './ChangeUtil' + +interface HdRequestOptions { + baseURL?: string +} + +type HdParams = Record + +export interface HdResponse { + code: number + message: string + data: T +} +export interface TimestampBean { + timestamp:string + + +} +class HdHttp { + baseURL: string + + constructor(options: HdRequestOptions) { + this.baseURL = options.baseURL || '' + } + + private request1(path: string, method: http.RequestMethod = http.RequestMethod.GET, extraDatas:HashMap) { + const httpInstance = http.createHttp() + let fullUrl = this.baseURL + path + let promise = httpInstance.request( + // 请求url地址 + fullUrl, + { + // 请求方式 + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json', + 'sign':this.getSign(extraDatas) + }, + extraData:ChangeUtil.map2Json(extraDatas) + }); + logger.info('Response JSON.stringify(extraDatas)' + ChangeUtil.map2Json(extraDatas)) + return promise.then((data) => { + logger.info('Response request:' + data.result); + if (data.result) { + const result = data.result as HdResponse + logger.info('Response result:' + result); + return result + + } + return Promise.reject(data.result) + // if (data.responseCode === http.ResponseCode.OK) { + // console.info('Response request:' + data.result); + // + // } + // else + // { + // + // } + // return Promise.reject(data.result) + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq request:' + JSON.stringify(err)); + return Promise.reject(err) + + }).finally(() => { + httpInstance.destroy() + }) + + } + private request(path: string, method: http.RequestMethod = http.RequestMethod.POST, extraDatas :HashMap) { + const httpInstance = http.createHttp() + + const options: http.HttpRequestOptions = { + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json', + 'sign':this.getSign(extraDatas) + }, + extraData:ChangeUtil.map2Json(extraDatas) + } + + let fullUrl = this.baseURL + path + + + return httpInstance.request(fullUrl, options).then((res) => { + logger.info('Response fullUrl:' +fullUrl+ res.result); + const result = res.result as HdResponse + return result + }).catch((err: BusinessError) => { + logger.info(fullUrl+`Response succeeded: ${err}`); + promptAction.showToast({ message: err.message || '网络错误' }) + return Promise.reject(err) + }).finally(() => { + httpInstance.destroy() + }) + } + + + private requestafter(path: string, method: http.RequestMethod = http.RequestMethod.GET, extraData?: Object) { + const httpInstance = http.createHttp() + + const options: http.HttpRequestOptions = { + method: http.RequestMethod.GET, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + } + + let fullUrl = this.baseURL + path + if (method === http.RequestMethod.GET && extraData) { + const strArr = Object.keys(extraData) + .filter(key => (extraData as HdParams)[key] !== undefined) + .map(key => `${key}=${(extraData as HdParams)[key]}`) + fullUrl += `?${strArr.join('&')}` + } else { + options.extraData = extraData + } + + return httpInstance.request(fullUrl, options).then((res) => { + return Promise.reject(res.result) + }).catch((err: BusinessError) => { + logger.error(fullUrl+`Response succeeded: ${err}+${err.name}+${err.message}+${err.data}+${err.stack}`); + // logger.error(fullUrl, err.code?.toString(), err.message) + promptAction.showToast({ message: err.message || '网络错误' }) + return Promise.reject(err) + }).finally(() => { + httpInstance.destroy() + }) + } + + + get(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.GET, data) + } + + post(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.POST, data) + } + + put(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.PUT, data) + } + + delete(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.DELETE, data) + } + posts(url: string, data: HashMap): Promise> { + return this.request(url, http.RequestMethod.POST, data) + } + httpReq(url: string, datas: HashMap): Promise> { + + // 创建httpRequest对象。 + let httpRequest = http.createHttp(); + let url1 = "https://dev-app.igandan.com/app/manager/getSystemTimeStamp"; + let promise = httpRequest.request( + // 请求url地址 + url1, + { + // 请求方式 + method: http.RequestMethod.GET, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + }); + // 处理响应结果。 + return promise.then((data) => { + if (data.responseCode === http.ResponseCode.OK) { + logger.info('Response httpReq:' + data.result); + let json:TimestampBean = JSON.parse(data.result.toString()) as TimestampBean; + let tp = json.timestamp; + datas.set("user_uuid", ''); + datas.set("client_type", 'A'); + datas.set("version",'4.0.0' ); + datas.set('timestamp',tp+''); + + return this.posts(url, datas); + } + else + { + return this.posts(url, datas); + } + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq error:' + JSON.stringify(err)); + return Promise.reject(err); + + }).finally(() => { + httpRequest.destroy() + }) + + } + httpReqSimply(url: string) { + + // 创建httpRequest对象。 + let httpRequest = http.createHttp(); + + let promise = httpRequest.request( + // 请求url地址 + url, + { + // 请求方式 + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + }); + // 处理响应结果。 + return promise.then((data) => { + logger.info('Response httpReqSimply:' + JSON.stringify(data)); + const result = data.result as HdResponse + return result + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq error:' + JSON.stringify(err)); + return Promise.reject(err); + + }).finally(() => { + httpRequest.destroy() + }) + + } + getSign(extraDatas1:HashMap): string { + let secret= extraDatas1.get("timestamp") + if(secret!=null) { + let keyValueStr: string = ""; + let entriesArray: Array = Array.from(extraDatas1.keys()); + entriesArray.sort(); + + let sortedMap:HashMap = new HashMap(); + entriesArray.forEach((value: string, index: number) => { + sortedMap.set(value,extraDatas1.get(value)); + keyValueStr +=value+extraDatas1.get(value) + }); + keyValueStr = keyValueStr.replace(" ", ""); + keyValueStr = keyValueStr + CryptoJS.MD5(secret).toString(); + let Md5keyValueStr: string = CryptoJS.MD5(keyValueStr).toString(); + let base64Str:string=Base64Util.encodeToStrSync(Md5keyValueStr); + return base64Str; + } + else + { + return ''; + } + + +} +} + +export const hdHttp = new HdHttp({ baseURL: '' }) + + + + diff --git a/commons/basic/src/main/ets/utils/logger.ets b/commons/basic/src/main/ets/utils/logger.ets new file mode 100644 index 0000000..7881389 --- /dev/null +++ b/commons/basic/src/main/ets/utils/logger.ets @@ -0,0 +1,33 @@ +import hilog from '@ohos.hilog' + +const DOMAIN = 0xFF09 +const PREFIX = 'PASS_INTERVIEW_LOGGER' +const FORMAT = '%{public}s, %{public}s' + +class Logger { + debug(...args: string[]) { + hilog.debug(DOMAIN, PREFIX, FORMAT, args) + } + + info(...args: string[]) { + hilog.info(DOMAIN, PREFIX, FORMAT, args) + } + + warn(...args: string[]) { + hilog.warn(DOMAIN, PREFIX, FORMAT, args) + } + + error(...args: string[]) { + hilog.error(DOMAIN, PREFIX, FORMAT, args) + } + + fatal(...args: string[]) { + hilog.fatal(DOMAIN, PREFIX, FORMAT, args) + } + + isLoggable(level: hilog.LogLevel) { + hilog.isLoggable(DOMAIN, PREFIX, level) + } +} + +export const logger = new Logger() \ No newline at end of file diff --git a/commons/basic/src/main/ets/utils/request.ets b/commons/basic/src/main/ets/utils/request.ets new file mode 100644 index 0000000..3aab179 --- /dev/null +++ b/commons/basic/src/main/ets/utils/request.ets @@ -0,0 +1,290 @@ +import { http } from '@kit.NetworkKit'; +import { authStore } from './auth'; +import { promptAction, router } from '@kit.ArkUI'; +import { BusinessError } from '@ohos.base'; +import { logger } from './logger'; +import { HashMap } from '@kit.ArkTS'; +import { CryptoJS } from '@ohos/crypto-js' +import { Base64Util } from './Base64Util'; +import { ChangeUtil } from './ChangeUtil' +import { BasicConstant } from '../constants/BasicConstant' + +interface HdRequestOptions { + baseURL?: string +} + +type HdParams = Record + +export interface HdResponse { + code: number + message: string + data: T +} +export interface TimestampBean { + timestamp:string + + +} +class HdHttp { + baseURL: string + + constructor(options: HdRequestOptions) { + this.baseURL = options.baseURL || '' + } + + private request1(path: string, method: http.RequestMethod = http.RequestMethod.GET, extraDatas:HashMap) { + const httpInstance = http.createHttp() + let fullUrl = this.baseURL + path + let promise = httpInstance.request( + // 请求url地址 + fullUrl, + { + // 请求方式 + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json', + 'sign':this.getSign(extraDatas) + }, + extraData:ChangeUtil.map2Json(extraDatas) + }); + logger.info('Response JSON.stringify(extraDatas)' + ChangeUtil.map2Json(extraDatas)) + return promise.then((data) => { + logger.info('Response request:' + data.result); + if (data.result) { + const result = data.result as HdResponse + logger.info('Response result:' + result); + return result + + } + return Promise.reject(data.result) + // if (data.responseCode === http.ResponseCode.OK) { + // console.info('Response request:' + data.result); + // + // } + // else + // { + // + // } + // return Promise.reject(data.result) + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq request:' + JSON.stringify(err)); + return Promise.reject(err) + + }).finally(() => { + httpInstance.destroy() + }) + + } + private request(path: string, method: http.RequestMethod = http.RequestMethod.POST, extraDatas :HashMap) { + const httpInstance = http.createHttp() + + const options: http.HttpRequestOptions = { + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json', + 'sign':this.getSign(extraDatas) + }, + extraData:ChangeUtil.map2Json(extraDatas) + } + + let fullUrl = this.baseURL + path + + + return httpInstance.request(fullUrl, options).then((res) => { + logger.info('Response fullUrl:' +fullUrl+ res.result); + const result = res.result as HdResponse + return result + }).catch((err: BusinessError) => { + logger.info(fullUrl+`Response succeeded: ${err}`); + promptAction.showToast({ message: err.message || '网络错误' }) + return Promise.reject(err) + }).finally(() => { + httpInstance.destroy() + }) + } + + + private requestafter(path: string, method: http.RequestMethod = http.RequestMethod.GET, extraData?: Object) { + const httpInstance = http.createHttp() + + const options: http.HttpRequestOptions = { + method: http.RequestMethod.GET, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + } + + let fullUrl = this.baseURL + path + if (method === http.RequestMethod.GET && extraData) { + const strArr = Object.keys(extraData) + .filter(key => (extraData as HdParams)[key] !== undefined) + .map(key => `${key}=${(extraData as HdParams)[key]}`) + fullUrl += `?${strArr.join('&')}` + } else { + options.extraData = extraData + } + + return httpInstance.request(fullUrl, options).then((res) => { + return Promise.reject(res.result) + }).catch((err: BusinessError) => { + logger.error(fullUrl+`Response succeeded: ${err}+${err.name}+${err.message}+${err.data}+${err.stack}`); + // logger.error(fullUrl, err.code?.toString(), err.message) + promptAction.showToast({ message: err.message || '网络错误' }) + return Promise.reject(err) + }).finally(() => { + httpInstance.destroy() + }) + } + + + get(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.GET, data) + } + + post(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.POST, data) + } + + put(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.PUT, data) + } + + delete(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.DELETE, data) + } + posts(url: string, data: HashMap): Promise> { + return this.request(url, http.RequestMethod.POST, data) + } + httpReq(url: string, datas: HashMap): Promise> { + + // 创建httpRequest对象。 + let httpRequest = http.createHttp(); + let url1 = "https://dev-app.igandan.com/app/manager/getSystemTimeStamp"; + let promise = httpRequest.request( + // 请求url地址 + url1, + { + // 请求方式 + method: http.RequestMethod.GET, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + }); + // 处理响应结果。 + return promise.then((data) => { + if (data.responseCode === http.ResponseCode.OK) { + logger.info('Response httpReq:' + data.result); + let json:TimestampBean = JSON.parse(data.result.toString()) as TimestampBean; + let tp = json.timestamp; + datas.set("user_uuid", authStore.getUser().uuid?authStore.getUser().uuid:''); + datas.set("client_type", 'A'); + datas.set("version",'4.0.0' ); + datas.set('timestamp',tp+''); + + return this.posts(url, datas); + } + else + { + return this.posts(url, datas); + } + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq error:' + JSON.stringify(err)); + return Promise.reject(err); + + }).finally(() => { + httpRequest.destroy() + }) + + } + httpReqSimply(url: string) { + + // 创建httpRequest对象。 + let httpRequest = http.createHttp(); + + let promise = httpRequest.request( + // 请求url地址 + url, + { + // 请求方式 + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + }); + // 处理响应结果。 + return promise.then((data) => { + logger.info('Response httpReqSimply:' + JSON.stringify(data)); + const result = data.result as HdResponse + return result + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq error:' + JSON.stringify(err)); + return Promise.reject(err); + + }).finally(() => { + httpRequest.destroy() + }) + + } + getSign(extraDatas1:HashMap): string { + let secret= extraDatas1.get("timestamp") + if(secret!=null) { + let keyValueStr: string = ""; + let entriesArray: Array = Array.from(extraDatas1.keys()); + entriesArray.sort(); + + let sortedMap:HashMap = new HashMap(); + entriesArray.forEach((value: string, index: number) => { + sortedMap.set(value,extraDatas1.get(value)); + keyValueStr +=value+extraDatas1.get(value) + }); + keyValueStr = keyValueStr.replace(" ", ""); + keyValueStr = keyValueStr + CryptoJS.MD5(secret).toString(); + let Md5keyValueStr: string = CryptoJS.MD5(keyValueStr).toString(); + let base64Str:string=Base64Util.encodeToStrSync(Md5keyValueStr); + return base64Str; + } + else + { + return ''; + } + + + } +} + +export const hdHttp = new HdHttp({ baseURL: '' }) + + + + diff --git a/commons/basic/src/main/ets/utils/themeManager.ets b/commons/basic/src/main/ets/utils/themeManager.ets new file mode 100644 index 0000000..e151cf2 --- /dev/null +++ b/commons/basic/src/main/ets/utils/themeManager.ets @@ -0,0 +1,83 @@ +/** + * 1. 主题设置 + * 2. 沉浸式设置 + * 3. 通知栏设置 + */ +import { ConfigurationConstant } from '@kit.AbilityKit' +import { window } from '@kit.ArkUI' +import { logger } from './logger' + +class ThemeManager { + windowStage: window.Window | null = null + + async getWindowStage() { + if (this.windowStage) { + return this.windowStage + } else { + return await window.getLastWindow(getContext()) + } + } + + initThemeSetting() { + const app = getContext().getApplicationContext() + app.on('environment', { + onConfigurationUpdated: (config) => { + logger.info('===', JSON.stringify(config)) + if (config.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT) { + this.settingStatusBarBlack() + } + if (config.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_DARK) { + this.settingStatusBarWhite() + } + if (config.colorMode === ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET) { + // TODO + } + }, + onMemoryLevel: (_level) => { + // TODO + } + }) + // 获取应用当前主题 + PersistentStorage.persistProp('appColorMode', + ConfigurationConstant.ColorMode.COLOR_MODE_LIGHT) + const appColorMode = AppStorage.get('appColorMode') + app.setColorMode(appColorMode) + } + + settingStatusBarWhite() { + this.settingStatusBar({ statusBarContentColor: '#FFFFFF' }) + } + + settingStatusBarBlack() { + this.settingStatusBar({ statusBarContentColor: '#000000' }) + } + + settingStatusBar(config: window.SystemBarProperties) { + this.getWindowStage() + .then((windowStage: window.Window) => { + windowStage.setWindowSystemBarProperties(config) + }) + } + + enableFullScreen() { + this.getWindowStage() + .then((windowStage: window.Window) => { + windowStage.setWindowLayoutFullScreen(true) + const topArea = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_SYSTEM) + AppStorage.setOrCreate('topHeight', px2vp(topArea.topRect.height)) + const bottomArea = windowStage.getWindowAvoidArea(window.AvoidAreaType.TYPE_NAVIGATION_INDICATOR) + AppStorage.setOrCreate('bottomHeight', px2vp(bottomArea.bottomRect.height)) + }) + } + + disableFullScreen() { + this.getWindowStage() + .then((windowStage: window.Window) => { + windowStage.setWindowLayoutFullScreen(false) + AppStorage.setOrCreate('topHeight', 0) + AppStorage.setOrCreate('bottomHeight', 0) + }) + } +} + +export const themeManager = new ThemeManager() \ No newline at end of file diff --git a/commons/basic/src/main/module.json5 b/commons/basic/src/main/module.json5 new file mode 100644 index 0000000..bbca727 --- /dev/null +++ b/commons/basic/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "basic", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/commons/basic/src/main/resources/base/element/color.json b/commons/basic/src/main/resources/base/element/color.json new file mode 100644 index 0000000..cc5ce7c --- /dev/null +++ b/commons/basic/src/main/resources/base/element/color.json @@ -0,0 +1,64 @@ +{ + "color": [ + { + "name": "common_gray_01", + "value": "#222222" + }, + { + "name": "common_gray_02", + "value": "#ffbebbb4" + }, + { + "name": "common_gray_03", + "value": "#666666" + }, + { + "name": "common_gray_bg", + "value": "#f3f4f5" + }, + { + "name": "common_gray_border", + "value": "#e8e7ee" + }, + { + "name": "common_main_color", + "value": "#FA6D1D" + }, + { + "name": "common_green", + "value": "#41B883" + }, + { + "name": "common_blue", + "value": "#3266EE" + }, + { + "name": "common_blue_bg", + "value": "#EDF2FF" + }, + { + "name": "black", + "value": "#131313" + }, + { + "name": "white", + "value": "#ffffff" + }, + { + "name": "home_gray", + "value": "#EDECF2" + }, + { + "name": "top_title", + "value": "#8D2316" + }, + { + "name": "top_bg", + "value": "#FFEFEFEF" + }, + { + "name": "main_color", + "value": "#923C35" + } + ] +} \ No newline at end of file diff --git a/commons/basic/src/main/resources/base/element/float.json b/commons/basic/src/main/resources/base/element/float.json new file mode 100644 index 0000000..0bafc42 --- /dev/null +++ b/commons/basic/src/main/resources/base/element/float.json @@ -0,0 +1,100 @@ +{ + "float": [ + { + "name": "common_border_width", + "value": "0.5vp" + }, + { + "name": "common_gutter", + "value": "16vp" + }, + { + "name": "navigation_title_font20", + "value": "20fp" + }, + { + "name": "common_font14", + "value": "14fp" + }, + { + "name": "common_font12", + "value": "12fp" + }, + { + "name": "common_font10", + "value": "10fp" + }, + { + "name": "common_font8", + "value": "8fp" + }, + { + "name": "common_space4", + "value": "4vp" + }, + { + "name": "common_space10", + "value": "10vp" + }, + { + "name": "common_space16", + "value": "16vp" + }, + { + "name": "hd_search_icon_size", + "value": "14vp" + }, + { + "name": "hd_search_height", + "value": "32vp" + }, + { + "name": "hd_search_radius", + "value": "16vp" + }, + { + "name": "hd_clock_font", + "value": "18fp" + }, + { + "name": "hd_clock_text_width", + "value": "50vp" + }, + { + "name": "hd_clock_width", + "value": "74vp" + }, + { + "name": "hd_clock_height", + "value": "28vp" + }, + { + "name": "hd_tag_width", + "value": "34vp" + }, + { + "name": "hd_tag_height", + "value": "18vp" + }, + { + "name": "hd_tag_radius", + "value": "2vp" + }, + { + "name": "hd_list_load_height", + "value": "80vp" + }, + { + "name": "hd_list_load_font", + "value": "14fp" + }, + { + "name": "hd_list_load_icon", + "value": "24vp" + }, + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} \ No newline at end of file diff --git a/commons/basic/src/main/resources/base/element/string.json b/commons/basic/src/main/resources/base/element/string.json new file mode 100644 index 0000000..2f0fc0a --- /dev/null +++ b/commons/basic/src/main/resources/base/element/string.json @@ -0,0 +1,40 @@ +{ + "string": [ + { + "name": "hd_search_placeholder", + "value": "搜索题目" + }, + { + "name": "hd_clock_continue", + "value": "已连续打卡" + }, + { + "name": "hd_clock_day", + "value": " 天" + }, + { + "name": "hd_tag_simple", + "value": "简单" + }, + { + "name": "hd_tag_general", + "value": "一般" + }, + { + "name": "hd_tag_difficult", + "value": "困难" + }, + { + "name": "hd_list_loading", + "value": "加载中..." + }, + { + "name": "hd_list_finished", + "value": "没有更多了~" + }, + { + "name": "hd_clock_in", + "value": "打卡" + } + ] +} diff --git a/commons/basic/src/main/resources/base/media/ic_common_back.svg b/commons/basic/src/main/resources/base/media/ic_common_back.svg new file mode 100644 index 0000000..454d0aa --- /dev/null +++ b/commons/basic/src/main/resources/base/media/ic_common_back.svg @@ -0,0 +1,13 @@ + + + Public/ic_public_back + + + + + + + + + + \ No newline at end of file diff --git a/commons/basic/src/main/resources/base/media/top_back.png b/commons/basic/src/main/resources/base/media/top_back.png new file mode 100644 index 0000000..fa7c276 Binary files /dev/null and b/commons/basic/src/main/resources/base/media/top_back.png differ diff --git a/commons/basic/src/ohosTest/ets/test/Ability.test.ets b/commons/basic/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/commons/basic/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/commons/basic/src/ohosTest/ets/test/List.test.ets b/commons/basic/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..794c7dc --- /dev/null +++ b/commons/basic/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/commons/basic/src/ohosTest/module.json5 b/commons/basic/src/ohosTest/module.json5 new file mode 100644 index 0000000..eeb0a60 --- /dev/null +++ b/commons/basic/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "basic_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/commons/basic/src/test/List.test.ets b/commons/basic/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/commons/basic/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/commons/basic/src/test/LocalUnit.test.ets b/commons/basic/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/commons/basic/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/commons/uicomponents/.gitignore b/commons/uicomponents/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/commons/uicomponents/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/commons/uicomponents/Index.ets b/commons/uicomponents/Index.ets new file mode 100644 index 0000000..42bf416 --- /dev/null +++ b/commons/uicomponents/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/commons/uicomponents/build-profile.json5 b/commons/uicomponents/build-profile.json5 new file mode 100644 index 0000000..e6773f9 --- /dev/null +++ b/commons/uicomponents/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/commons/uicomponents/consumer-rules.txt b/commons/uicomponents/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/commons/uicomponents/hvigorfile.ts b/commons/uicomponents/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/commons/uicomponents/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/commons/uicomponents/obfuscation-rules.txt b/commons/uicomponents/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/commons/uicomponents/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/commons/uicomponents/oh-package.json5 b/commons/uicomponents/oh-package.json5 new file mode 100644 index 0000000..ba99f3b --- /dev/null +++ b/commons/uicomponents/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "uicomponents", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/commons/uicomponents/src/main/ets/components/MainPage.ets b/commons/uicomponents/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000..9de5eb3 --- /dev/null +++ b/commons/uicomponents/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/commons/uicomponents/src/main/module.json5 b/commons/uicomponents/src/main/module.json5 new file mode 100644 index 0000000..7a1010d --- /dev/null +++ b/commons/uicomponents/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "uicomponents", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/commons/uicomponents/src/main/resources/base/element/float.json b/commons/uicomponents/src/main/resources/base/element/float.json new file mode 100644 index 0000000..33ea223 --- /dev/null +++ b/commons/uicomponents/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/commons/uicomponents/src/main/resources/base/element/string.json b/commons/uicomponents/src/main/resources/base/element/string.json new file mode 100644 index 0000000..f51a9c8 --- /dev/null +++ b/commons/uicomponents/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/commons/uicomponents/src/ohosTest/ets/test/Ability.test.ets b/commons/uicomponents/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/commons/uicomponents/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/commons/uicomponents/src/ohosTest/ets/test/List.test.ets b/commons/uicomponents/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..794c7dc --- /dev/null +++ b/commons/uicomponents/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/commons/uicomponents/src/ohosTest/module.json5 b/commons/uicomponents/src/ohosTest/module.json5 new file mode 100644 index 0000000..0e061dc --- /dev/null +++ b/commons/uicomponents/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "uicomponents_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/commons/uicomponents/src/test/List.test.ets b/commons/uicomponents/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/commons/uicomponents/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/commons/uicomponents/src/test/LocalUnit.test.ets b/commons/uicomponents/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/commons/uicomponents/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/commons/utils/.gitignore b/commons/utils/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/commons/utils/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/commons/utils/BuildProfile.ets b/commons/utils/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/commons/utils/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/commons/utils/Index.ets b/commons/utils/Index.ets new file mode 100644 index 0000000..e2e89d9 --- /dev/null +++ b/commons/utils/Index.ets @@ -0,0 +1,4 @@ +export { logger } from './src/main/ets/request/logger' +export { Base64Util } from './src/main/ets/request/Base64Util' +export { HdResponse } from './src/main/ets/request/request' +export { ChangeUtil } from './src/main/ets/request/ChangeUtil' diff --git a/commons/utils/build-profile.json5 b/commons/utils/build-profile.json5 new file mode 100644 index 0000000..e6773f9 --- /dev/null +++ b/commons/utils/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/commons/utils/consumer-rules.txt b/commons/utils/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/commons/utils/hvigorfile.ts b/commons/utils/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/commons/utils/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/commons/utils/obfuscation-rules.txt b/commons/utils/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/commons/utils/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/commons/utils/oh-package-lock.json5 b/commons/utils/oh-package-lock.json5 new file mode 100644 index 0000000..47887dd --- /dev/null +++ b/commons/utils/oh-package-lock.json5 @@ -0,0 +1,19 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/crypto-js@^2.0.4": "@ohos/crypto-js@2.0.4" + }, + "packages": { + "@ohos/crypto-js@2.0.4": { + "name": "@ohos/crypto-js", + "version": "2.0.4", + "integrity": "sha512-589ur6oqU1UNibqefMly2cwEeEhkSoCAA3uc+oNUwRnYYtevn/kQnO+Coi36N+VJSeeg/uFzZk1K/wUMdovpOA==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/crypto-js/-/crypto-js-2.0.4.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/commons/utils/oh-package.json5 b/commons/utils/oh-package.json5 new file mode 100644 index 0000000..38e98ed --- /dev/null +++ b/commons/utils/oh-package.json5 @@ -0,0 +1,13 @@ +{ + "name": "utils", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@ohos/crypto-js": "^2.0.4" + }, + "devDependencies": {}, + "dynamicDependencies": {} +} \ No newline at end of file diff --git a/commons/utils/src/main/ets/request/Base64Util.ets b/commons/utils/src/main/ets/request/Base64Util.ets new file mode 100644 index 0000000..e0fb889 --- /dev/null +++ b/commons/utils/src/main/ets/request/Base64Util.ets @@ -0,0 +1,84 @@ +import util from '@ohos.util'; + +import { buffer } from '@kit.ArkTS'; + +/** + * Base64 工具类 + * author: 鸿蒙布道师 + * since: 2025/03/31 + */ +export class Base64Util { + /** + * 创建 Base64Helper 实例 + * @returns Base64Helper 实例 + */ + private static createBase64Helper(): util.Base64Helper { + return new util.Base64Helper(); + } + + /** + * 编码为 Uint8Array(异步) + * @param array 输入的 Uint8Array 数据 + * @returns 编码后的 Uint8Array 对象 + */ + static encode(array: Uint8Array): Promise { + const base64 = Base64Util.createBase64Helper(); + return base64.encode(array); + } + + /** + * 编码为 Uint8Array(同步) + * @param array 输入的 Uint8Array 数据 + * @returns 编码后的 Uint8Array 对象 + */ + static encodeSync(array: Uint8Array): Uint8Array { + const base64 = Base64Util.createBase64Helper(); + return base64.encodeSync(array); + } + + /** + * 编码为字符串(异步) + * @param array 输入的 Uint8Array 数据 + * @param options 可选参数 + * @returns 编码后的字符串 + */ + static encodeToStr(array: Uint8Array, options?: util.Type): Promise { + const base64 = Base64Util.createBase64Helper(); + return base64.encodeToString(array, options); + } + + /** + * 编码为字符串(同步) + * @param array 输入的 Uint8Array 数据 + * @param options 可选参数 + * @returns 编码后的字符串 + */ + static encodeToStrSync(keyValueStr:string): string { + let array: Uint8Array=new Uint8Array(buffer.from(keyValueStr, 'utf-8').buffer) + const base64 = Base64Util.createBase64Helper(); + + return base64.encodeToStringSync(array, util.Type.BASIC).replaceAll("=", ""); + } + + /** + * 解码为 Uint8Array(异步) + * @param input 输入的 Uint8Array 或字符串 + * @param options 可选参数 + * @returns 解码后的 Uint8Array 对象 + */ + static decode(input: Uint8Array | string, options?: util.Type): Promise { + const base64 = Base64Util.createBase64Helper(); + return base64.decode(input, options); + } + + /** + * 解码为 Uint8Array(同步) + * @param input 输入的 Uint8Array 或字符串 + * @param options 可选参数 + * @returns 解码后的 Uint8Array 对象 + */ + static decodeSync(input: Uint8Array | string, options?: util.Type): Uint8Array { + const base64 = Base64Util.createBase64Helper(); + return base64.decodeSync(input, options); + } +} \ No newline at end of file diff --git a/commons/utils/src/main/ets/request/ChangeUtil.ets b/commons/utils/src/main/ets/request/ChangeUtil.ets new file mode 100644 index 0000000..f75b932 --- /dev/null +++ b/commons/utils/src/main/ets/request/ChangeUtil.ets @@ -0,0 +1,61 @@ + +import HashMap from '@ohos.util.HashMap'; +import { Base64Util } from './Base64Util'; + + +export class ChangeUtil { + /** + * 将HashMap转成JsonString + * @param map + * @returns + */ + static map2Json(map:HashMap): string { + let jsonObject: Record = {}; + map.forEach((value, key) => { + if(key != undefined && value != undefined){ + jsonObject[key] = value; + } + }) + return JSON.stringify(jsonObject); + } + + static getSign(extraDatas1:HashMap): string { + let secret= extraDatas1.get("timestamp") + if(secret!=null) { + let keyValueStr: string = ""; + let entriesArray: Array = Array.from(extraDatas1.keys()); + entriesArray.sort(); + + let sortedMap:HashMap = new HashMap(); + entriesArray.forEach((value: string, index: number) => { + sortedMap.set(value,extraDatas1.get(value)); + keyValueStr +=value+extraDatas1.get(value) + }); + keyValueStr = keyValueStr.replace(" ", ""); + keyValueStr = keyValueStr + CryptoJS.MD5(secret).toString(); + let Md5keyValueStr: string = CryptoJS.MD5(keyValueStr).toString(); + let base64Str:string=Base64Util.encodeToStrSync(Md5keyValueStr); + return base64Str; + } + else + { + return ''; + } + + + } + + + static isMobileNum(mobiles:string): boolean { + const reg2: RegExp = new RegExp('^(1[3-9])[0-9]{9}$') + + return reg2.test(mobiles); +} + static isPassword(password:string): boolean { + const reg2: RegExp = new RegExp('^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{6,16}$') + + return reg2.test(password); + } + + +} \ No newline at end of file diff --git a/commons/utils/src/main/ets/request/logger.ets b/commons/utils/src/main/ets/request/logger.ets new file mode 100644 index 0000000..7881389 --- /dev/null +++ b/commons/utils/src/main/ets/request/logger.ets @@ -0,0 +1,33 @@ +import hilog from '@ohos.hilog' + +const DOMAIN = 0xFF09 +const PREFIX = 'PASS_INTERVIEW_LOGGER' +const FORMAT = '%{public}s, %{public}s' + +class Logger { + debug(...args: string[]) { + hilog.debug(DOMAIN, PREFIX, FORMAT, args) + } + + info(...args: string[]) { + hilog.info(DOMAIN, PREFIX, FORMAT, args) + } + + warn(...args: string[]) { + hilog.warn(DOMAIN, PREFIX, FORMAT, args) + } + + error(...args: string[]) { + hilog.error(DOMAIN, PREFIX, FORMAT, args) + } + + fatal(...args: string[]) { + hilog.fatal(DOMAIN, PREFIX, FORMAT, args) + } + + isLoggable(level: hilog.LogLevel) { + hilog.isLoggable(DOMAIN, PREFIX, level) + } +} + +export const logger = new Logger() \ No newline at end of file diff --git a/commons/utils/src/main/ets/request/request.ets b/commons/utils/src/main/ets/request/request.ets new file mode 100644 index 0000000..ff0970a --- /dev/null +++ b/commons/utils/src/main/ets/request/request.ets @@ -0,0 +1,288 @@ +import { http } from '@kit.NetworkKit'; +import { promptAction, router } from '@kit.ArkUI'; +import { BusinessError } from '@ohos.base'; +import { HashMap } from '@kit.ArkTS'; +import { CryptoJS } from '@ohos/crypto-js' +import { Base64Util } from './Base64Util'; +import { ChangeUtil } from './ChangeUtil' +import { logger } from './logger' + +interface HdRequestOptions { + baseURL?: string +} + +type HdParams = Record + +export interface HdResponse { + code: number + message: string + data: T +} +export interface TimestampBean { + timestamp:string + + +} +class HdHttp { + baseURL: string + + constructor(options: HdRequestOptions) { + this.baseURL = options.baseURL || '' + } + + private request1(path: string, method: http.RequestMethod = http.RequestMethod.GET, extraDatas:HashMap) { + const httpInstance = http.createHttp() + let fullUrl = this.baseURL + path + let promise = httpInstance.request( + // 请求url地址 + fullUrl, + { + // 请求方式 + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json', + 'sign':this.getSign(extraDatas) + }, + extraData:ChangeUtil.map2Json(extraDatas) + }); + logger.info('Response JSON.stringify(extraDatas)' + ChangeUtil.map2Json(extraDatas)) + return promise.then((data) => { + logger.info('Response request:' + data.result); + if (data.result) { + const result = data.result as HdResponse + logger.info('Response result:' + result); + return result + + } + return Promise.reject(data.result) + // if (data.responseCode === http.ResponseCode.OK) { + // console.info('Response request:' + data.result); + // + // } + // else + // { + // + // } + // return Promise.reject(data.result) + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq request:' + JSON.stringify(err)); + return Promise.reject(err) + + }).finally(() => { + httpInstance.destroy() + }) + + } + private request(path: string, method: http.RequestMethod = http.RequestMethod.POST, extraDatas :HashMap) { + const httpInstance = http.createHttp() + + const options: http.HttpRequestOptions = { + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json', + 'sign':this.getSign(extraDatas) + }, + extraData:ChangeUtil.map2Json(extraDatas) + } + + let fullUrl = this.baseURL + path + + + return httpInstance.request(fullUrl, options).then((res) => { + logger.info('Response fullUrl:' +fullUrl+ res.result); + const result = res.result as HdResponse + return result + }).catch((err: BusinessError) => { + logger.info(fullUrl+`Response succeeded: ${err}`); + promptAction.showToast({ message: err.message || '网络错误' }) + return Promise.reject(err) + }).finally(() => { + httpInstance.destroy() + }) + } + + + private requestafter(path: string, method: http.RequestMethod = http.RequestMethod.GET, extraData?: Object) { + const httpInstance = http.createHttp() + + const options: http.HttpRequestOptions = { + method: http.RequestMethod.GET, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + } + + let fullUrl = this.baseURL + path + if (method === http.RequestMethod.GET && extraData) { + const strArr = Object.keys(extraData) + .filter(key => (extraData as HdParams)[key] !== undefined) + .map(key => `${key}=${(extraData as HdParams)[key]}`) + fullUrl += `?${strArr.join('&')}` + } else { + options.extraData = extraData + } + + return httpInstance.request(fullUrl, options).then((res) => { + return Promise.reject(res.result) + }).catch((err: BusinessError) => { + logger.error(fullUrl+`Response succeeded: ${err}+${err.name}+${err.message}+${err.data}+${err.stack}`); + // logger.error(fullUrl, err.code?.toString(), err.message) + promptAction.showToast({ message: err.message || '网络错误' }) + return Promise.reject(err) + }).finally(() => { + httpInstance.destroy() + }) + } + + + get(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.GET, data) + } + + post(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.POST, data) + } + + put(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.PUT, data) + } + + delete(url: string, data?: Object): Promise> { + return this.requestafter(url, http.RequestMethod.DELETE, data) + } + posts(url: string, data: HashMap): Promise> { + return this.request(url, http.RequestMethod.POST, data) + } + httpReq(url: string, datas: HashMap): Promise> { + + // 创建httpRequest对象。 + let httpRequest = http.createHttp(); + let url1 = "https://dev-app.igandan.com/app/manager/getSystemTimeStamp"; + let promise = httpRequest.request( + // 请求url地址 + url1, + { + // 请求方式 + method: http.RequestMethod.GET, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + }); + // 处理响应结果。 + return promise.then((data) => { + if (data.responseCode === http.ResponseCode.OK) { + logger.info('Response httpReq:' + data.result); + let json:TimestampBean = JSON.parse(data.result.toString()) as TimestampBean; + let tp = json.timestamp; + datas.set("user_uuid", ''); + datas.set("client_type", 'A'); + datas.set("version",'4.0.0' ); + datas.set('timestamp',tp+''); + + return this.posts(url, datas); + } + else + { + return this.posts(url, datas); + } + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq error:' + JSON.stringify(err)); + return Promise.reject(err); + + }).finally(() => { + httpRequest.destroy() + }) + + } + httpReqSimply(url: string) { + + // 创建httpRequest对象。 + let httpRequest = http.createHttp(); + + let promise = httpRequest.request( + // 请求url地址 + url, + { + // 请求方式 + method: http.RequestMethod.POST, + // 可选,默认为60s + connectTimeout: 60000, + // 可选,默认为60s + readTimeout: 60000, + // 开发者根据自身业务需要添加header字段 + header: { + 'Content-Type': 'application/json' + } + }); + // 处理响应结果。 + return promise.then((data) => { + logger.info('Response httpReqSimply:' + JSON.stringify(data)); + const result = data.result as HdResponse + return result + } + + ).catch((err:BusinessError) => { + logger.info('Response httpReq error:' + JSON.stringify(err)); + return Promise.reject(err); + + }).finally(() => { + httpRequest.destroy() + }) + + } + getSign(extraDatas1:HashMap): string { + let secret= extraDatas1.get("timestamp") + if(secret!=null) { + let keyValueStr: string = ""; + let entriesArray: Array = Array.from(extraDatas1.keys()); + entriesArray.sort(); + + let sortedMap:HashMap = new HashMap(); + entriesArray.forEach((value: string, index: number) => { + sortedMap.set(value,extraDatas1.get(value)); + keyValueStr +=value+extraDatas1.get(value) + }); + keyValueStr = keyValueStr.replace(" ", ""); + keyValueStr = keyValueStr + CryptoJS.MD5(secret).toString(); + let Md5keyValueStr: string = CryptoJS.MD5(keyValueStr).toString(); + let base64Str:string=Base64Util.encodeToStrSync(Md5keyValueStr); + return base64Str; + } + else + { + return ''; + } + + +} +} + +export const hdHttp = new HdHttp({ baseURL: '' }) + + + + diff --git a/commons/utils/src/main/module.json5 b/commons/utils/src/main/module.json5 new file mode 100644 index 0000000..2355b2e --- /dev/null +++ b/commons/utils/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "utils", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/commons/utils/src/main/resources/base/element/float.json b/commons/utils/src/main/resources/base/element/float.json new file mode 100644 index 0000000..33ea223 --- /dev/null +++ b/commons/utils/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/commons/utils/src/main/resources/base/element/string.json b/commons/utils/src/main/resources/base/element/string.json new file mode 100644 index 0000000..f51a9c8 --- /dev/null +++ b/commons/utils/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/commons/utils/src/ohosTest/ets/test/Ability.test.ets b/commons/utils/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/commons/utils/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/commons/utils/src/ohosTest/ets/test/List.test.ets b/commons/utils/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..794c7dc --- /dev/null +++ b/commons/utils/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/commons/utils/src/ohosTest/module.json5 b/commons/utils/src/ohosTest/module.json5 new file mode 100644 index 0000000..5a67a48 --- /dev/null +++ b/commons/utils/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "utils_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/commons/utils/src/test/List.test.ets b/commons/utils/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/commons/utils/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/commons/utils/src/test/LocalUnit.test.ets b/commons/utils/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/commons/utils/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/features/Home/.gitignore b/features/Home/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/features/Home/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/features/Home/BuildProfile.ets b/features/Home/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/features/Home/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/Home/Index.ets b/features/Home/Index.ets new file mode 100644 index 0000000..b60e348 --- /dev/null +++ b/features/Home/Index.ets @@ -0,0 +1,3 @@ +export { HomePage } from './src/main/ets/pages/HomePage'; + +export { VideoPage } from './src/main/ets/pages/VideoPage'; diff --git a/features/Home/build-profile.json5 b/features/Home/build-profile.json5 new file mode 100644 index 0000000..e6773f9 --- /dev/null +++ b/features/Home/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/features/Home/consumer-rules.txt b/features/Home/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/features/Home/hvigorfile.ts b/features/Home/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/features/Home/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/features/Home/obfuscation-rules.txt b/features/Home/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/features/Home/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/features/Home/oh-package-lock.json5 b/features/Home/oh-package-lock.json5 new file mode 100644 index 0000000..cc3bce5 --- /dev/null +++ b/features/Home/oh-package-lock.json5 @@ -0,0 +1,18 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@itcast/basic@../../commons/basic": "@itcast/basic@../../commons/basic" + }, + "packages": { + "@itcast/basic@../../commons/basic": { + "name": "@itcast/basic", + "version": "1.0.0", + "resolved": "../../commons/basic", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/features/Home/oh-package.json5 b/features/Home/oh-package.json5 new file mode 100644 index 0000000..44c28bc --- /dev/null +++ b/features/Home/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "home", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@itcast/basic": "file:../../commons/basic" + } +} diff --git a/features/Home/src/main/ets/pages/HomePage.ets b/features/Home/src/main/ets/pages/HomePage.ets new file mode 100644 index 0000000..2ca217e --- /dev/null +++ b/features/Home/src/main/ets/pages/HomePage.ets @@ -0,0 +1,19 @@ +@Component +export struct HomePage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/features/Home/src/main/ets/pages/VideoPage.ets b/features/Home/src/main/ets/pages/VideoPage.ets new file mode 100644 index 0000000..760d015 --- /dev/null +++ b/features/Home/src/main/ets/pages/VideoPage.ets @@ -0,0 +1,29 @@ + +@Entry +@Component +export struct VideoPage { + @State message: string = 'Hello World'; + + onPageShow(): void { + console.log('VideoPage onPageShow!'); + } + + onPageHide(): void { + console.log('VideoPage onPageHide!'); + } + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/features/Home/src/main/module.json5 b/features/Home/src/main/module.json5 new file mode 100644 index 0000000..206f390 --- /dev/null +++ b/features/Home/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "Home", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/features/Home/src/main/resources/base/element/float.json b/features/Home/src/main/resources/base/element/float.json new file mode 100644 index 0000000..33ea223 --- /dev/null +++ b/features/Home/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/features/Home/src/main/resources/base/element/string.json b/features/Home/src/main/resources/base/element/string.json new file mode 100644 index 0000000..f51a9c8 --- /dev/null +++ b/features/Home/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/features/Home/src/ohosTest/ets/test/Ability.test.ets b/features/Home/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/features/Home/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/features/Home/src/ohosTest/ets/test/List.test.ets b/features/Home/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..794c7dc --- /dev/null +++ b/features/Home/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/features/Home/src/ohosTest/module.json5 b/features/Home/src/ohosTest/module.json5 new file mode 100644 index 0000000..68dda68 --- /dev/null +++ b/features/Home/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "Home_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/features/Home/src/test/List.test.ets b/features/Home/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/features/Home/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/features/Home/src/test/LocalUnit.test.ets b/features/Home/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/features/Home/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/features/mypage/.gitignore b/features/mypage/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/features/mypage/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/features/mypage/BuildProfile.ets b/features/mypage/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/features/mypage/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/mypage/Index.ets b/features/mypage/Index.ets new file mode 100644 index 0000000..c0b523b --- /dev/null +++ b/features/mypage/Index.ets @@ -0,0 +1,13 @@ +export { MyHomePage } from './src/main/ets/pages/MyHomePage' + +export { ChangePasswordComp } from './src/main/ets/view/ChangePasswordComp' + +export { ForgetPasswordComp } from './src/main/ets/view/ForgetPasswordComp' + +export { ChangePhoneComp } from './src/main/ets/view/ChangePhoneComp' + +export { ChooseEmailComp } from './src/main/ets/view/ChooseEmailComp' + +export { ChooseOfficePhoneComp } from './src/main/ets/view/ChooseOfficePhoneComp' + +export { EditUserDataComp } from './src/main/ets/view/EditUserDataComp' \ No newline at end of file diff --git a/features/mypage/build-profile.json5 b/features/mypage/build-profile.json5 new file mode 100644 index 0000000..e6773f9 --- /dev/null +++ b/features/mypage/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/features/mypage/consumer-rules.txt b/features/mypage/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/features/mypage/hvigorfile.ts b/features/mypage/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/features/mypage/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/features/mypage/obfuscation-rules.txt b/features/mypage/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/features/mypage/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/features/mypage/oh-package-lock.json5 b/features/mypage/oh-package-lock.json5 new file mode 100644 index 0000000..cc3bce5 --- /dev/null +++ b/features/mypage/oh-package-lock.json5 @@ -0,0 +1,18 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@itcast/basic@../../commons/basic": "@itcast/basic@../../commons/basic" + }, + "packages": { + "@itcast/basic@../../commons/basic": { + "name": "@itcast/basic", + "version": "1.0.0", + "resolved": "../../commons/basic", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/features/mypage/oh-package.json5 b/features/mypage/oh-package.json5 new file mode 100644 index 0000000..e15b9d4 --- /dev/null +++ b/features/mypage/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "mypage", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@itcast/basic": "file:../../commons/basic" + } +} \ No newline at end of file diff --git a/features/mypage/src/main/ets/model/MyPageSectionClass.ets b/features/mypage/src/main/ets/model/MyPageSectionClass.ets new file mode 100644 index 0000000..daf0b21 --- /dev/null +++ b/features/mypage/src/main/ets/model/MyPageSectionClass.ets @@ -0,0 +1,14 @@ + +export class MyPageSectionClass { + id:string = ''; + imageSrc:ResourceStr = ''; + title:string = ''; + path:string = ''; + + constructor(id:string,imageSrc:ResourceStr,title:string,path:string) { + this.id = id; + this.imageSrc = imageSrc; + this.title = title; + this.path = path; + } +} diff --git a/features/mypage/src/main/ets/pages/MyHomePage.ets b/features/mypage/src/main/ets/pages/MyHomePage.ets new file mode 100644 index 0000000..1f22076 --- /dev/null +++ b/features/mypage/src/main/ets/pages/MyHomePage.ets @@ -0,0 +1,42 @@ +import { HeaderView } from '../view/HeaderView' +import { HdNav, getTimeText, hdHttp, HdUser } from '@itcast/basic' +import { OneSection } from '../view/OneSection' +import { TwoSection } from '../view/TwoSection' +import { ThreeSection } from '../view/ThreeSection' +import { FourSection } from '../view/FourSection' +import { OtherList } from '../view/OtherList' +import { emitter } from '@kit.BasicServicesKit' + +@Component +export struct MyHomePage { + @State title: string = '我的'; + @StorageProp('topHeight') + topHeight: number = 0 + + scroller = new Scroller() + + build() { + Column() { + HdNav({ title: '我的', showLeftIcon:false , showRightIcon: false, hasBorder: true }) + + Scroll(this.scroller) { + Column() { + HeaderView() + // OneSection() + // TwoSection() + // ThreeSection() + FourSection() + OtherList() + } + } + .width('100%') + .height('100%') + .layoutWeight(1) + .scrollBar(BarState.Off) + .align(Alignment.TopStart) + } + .width('100%') + .height('100%') + .backgroundColor('#F1F3F5') + } +} diff --git a/features/mypage/src/main/ets/util/DateUtils.ets b/features/mypage/src/main/ets/util/DateUtils.ets new file mode 100644 index 0000000..fdee613 --- /dev/null +++ b/features/mypage/src/main/ets/util/DateUtils.ets @@ -0,0 +1,25 @@ +type DateFormat = 'YYYY-MM-DD' | 'MM/DD/YYYY' | 'DD-MMM-YYYY' | 'YYYY年MM月DD日' | 'YYYYMMDD'; + +export function formatDate(date: Date,pattern:DateFormat = 'YYYY-MM-DD'): string { + const padZero = (num: number): string => num.toString().padStart(2, '0'); + const year = date.getFullYear(); + const month = padZero(date.getMonth() + 1); // 月份修正[7,8](@ref) + const day = padZero(date.getDate()); + + // 模式映射逻辑(核心补全部分) + switch (pattern) { + case 'YYYY-MM-DD': + return `${year}-${month}-${day}`; + case 'MM/DD/YYYY': + return `${month}/${day}/${year}`; + case 'DD-MMM-YYYY': + const months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; + return `${day}-${months[date.getMonth()]}-${year}`; // 月份缩写处理[4](@ref) + case 'YYYY年MM月DD日': + return `${year}年${month}月${day}日`; // 中文格式[5](@ref) + case 'YYYYMMDD': + return `${year}${month}${day}`; // 紧凑格式 + default: + throw new Error(`Unsupported format pattern: ${pattern}`); + } +} diff --git a/features/mypage/src/main/ets/view/ChangePasswordComp.ets b/features/mypage/src/main/ets/view/ChangePasswordComp.ets new file mode 100644 index 0000000..06c683a --- /dev/null +++ b/features/mypage/src/main/ets/view/ChangePasswordComp.ets @@ -0,0 +1,101 @@ +import promptAction from '@ohos.promptAction'; +import { router } from '@kit.ArkUI' + +@Preview +@Component +export struct ChangePasswordComp { + @State oldPassword: string = '' + @State newPassword: string = '' + @State confirmPassword: string = '' + + build() { + Column() { + // 原密码输入框 + TextInput({ placeholder: '请输入原密码' }) + .width('95%') + .height(40) + .margin({ top: 10 }) + .borderWidth(1) + .borderRadius(8) + .borderColor('#cccccc') + .type(InputType.Password) + .onChange((value: string) => { + this.oldPassword = value + }) + + // 新密码输入框 + TextInput({ placeholder: '新密码(6~16位数字字母组合)' }) + .width('95%') + .height(40) + .margin({ top: 10 }) + .borderWidth(1) + .borderRadius(8) + .borderColor('#cccccc') + .type(InputType.Password) + .onChange((value: string) => { + this.newPassword = value + }) + + // 确认新密码输入框 + TextInput({ placeholder: '确认新密码' }) + .width('95%') + .height(40) + .margin({ top: 10 }) + .borderWidth(1) + .borderRadius(8) + .borderColor('#cccccc') + .type(InputType.Password) + .onChange((value: string) => { + this.confirmPassword = value + }) + + // 忘记密码链接 + Text('忘记密码?') + .fontSize(14) + .fontColor('#666666') + .margin({ top: 12 }) + .onClick(() => { + // 处理忘记密码逻辑 + router.pushUrl({url:'pages/MinePage/ForgetPassword'}) + }) + + // 确定按钮 + Button({ type: ButtonType.Normal }){ + Text('确 定') + } + .width('90%') + .height(40) + .position({x:'5%',y:'80%'}) + .backgroundColor('#ffffff') + .borderColor($r('app.color.main_color')) + .borderRadius(8) + .borderWidth(1) + .fontColor($r('app.color.main_color')) + .onClick(() => { + // 处理密码修改提交逻辑 + this.handleSubmit() + }) + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + } + + // 提交处理函数 + private handleSubmit() { + // 这里添加密码验证和提交逻辑 + // 验证规则示例: + if (this.newPassword !== this.confirmPassword) { + promptAction.showToast({message:'两次输入的新密码不一致'}) + return + } + + const passwordRegex = /^(?=.*[a-zA-Z])(?=.*\d)[a-zA-Z\d]{6,16}$/ + if (!passwordRegex.test(this.newPassword)) { + promptAction.showToast({message:'密码必须为6-16位数字字母组合'}) + return + } + + // 调用修改密码接口... + } +} diff --git a/features/mypage/src/main/ets/view/ChangePhoneComp.ets b/features/mypage/src/main/ets/view/ChangePhoneComp.ets new file mode 100644 index 0000000..1a96e93 --- /dev/null +++ b/features/mypage/src/main/ets/view/ChangePhoneComp.ets @@ -0,0 +1,121 @@ +import promptAction from '@ohos.promptAction'; + +@Preview +@Component +export struct ChangePhoneComp { + @State phoneNumber: string = '' + @State smsCode: string = '' + @State countdown: number = 0 + + // 验证码倒计时 + private startCountdown() { + this.countdown = 60 + const timer = setInterval(() => { + if (this.countdown > 0) { + this.countdown-- + } else { + clearInterval(timer) + } + }, 1000) + } + + build() { + Column() { + // 手机号输入框 + Row() { + Image($r('app.media.icon_phone')) + .width(18) + .height(18) + .objectFit(ImageFit.Contain) + .margin({left:10}) + + TextInput({ placeholder: '请输入手机号码' }) + .fontSize(16) + .backgroundColor(Color.White) + .onChange((value: string) => { + this.phoneNumber = value + }) + } + .margin({ top: 10 }) + .width('95%') + .height(48) + .borderRadius(4) + .borderWidth(1) + .borderColor('#CCCCCC') + + // 验证码输入区域 + Row() { + Row() { + Image($r('app.media.icon_verification_code')) + .width(18) + .height(18) + .objectFit(ImageFit.Contain) + .margin({left:10}) + TextInput({ placeholder: '请输入验证码' }) + .fontSize(16) + .backgroundColor(Color.White) + } + .margin({ top: 10 }) + .width('60%') + .height(48) + .borderRadius(4) + .borderWidth(1) + .borderColor('#CCCCCC') + + Button({type:ButtonType.Normal}){ + Text(this.countdown ? `${this.countdown}s` : '获取验证码') + } + .width('37%') + .height(32) + .borderRadius(5) + .borderColor('#8B2316') + .borderWidth(1) + .backgroundColor(Color.White) + .fontColor('#8B2316') + .fontSize(12) + .margin({ top: 10 }) + .enabled(this.countdown === 0) + .onClick(() => { + if (this.phoneNumber.length >= 11) { + this.startCountdown() + } else { + promptAction.showToast({message:'请输入手机号'}) + } + }) + } + .width('95%') + .justifyContent(FlexAlign.SpaceBetween) + + // 登录按钮 + Button({type:ButtonType.Normal}){ + Text('登 录') + } + .width('90%') + .height(48) + .borderRadius(8) + .borderWidth(1) + .borderColor('#8B2316') + .backgroundColor(Color.White) + .fontColor('#8B2316') + .fontSize(18) + .position({x:'5%',y:'80%'}) + .onClick(() => { + // 处理登录逻辑 + if (!/^1[3-9]\d{9}$/.test(this.phoneNumber)) { + promptAction.showToast({message:'请输入有效手机号'}) + return + } + + if (!this.smsCode) { + promptAction.showToast({message:'请输入验证码'}) + return + } + + // 执行登录操作... + }) + } + .width('100%') + .height('100%') + .backgroundColor('#FFFFFF') + } +} diff --git a/features/mypage/src/main/ets/view/ChooseEmailComp.ets b/features/mypage/src/main/ets/view/ChooseEmailComp.ets new file mode 100644 index 0000000..e975252 --- /dev/null +++ b/features/mypage/src/main/ets/view/ChooseEmailComp.ets @@ -0,0 +1,78 @@ +import promptAction from '@ohos.promptAction'; +import { authStore } from '@itcast/basic'; + +@Preview +@Component +export struct ChooseEmailComp { + @State phoneNumber: string = '' + @State countdown: number = 0 + + // 验证码倒计时 + private startCountdown() { + this.countdown = 60 + const timer = setInterval(() => { + if (this.countdown > 0) { + this.countdown-- + } else { + clearInterval(timer) + } + }, 1000) + } + + build() { + Column() { + // 手机号输入框 + Row() { + TextInput({ placeholder: authStore.getUser().email.length>0?authStore.getUser().email:'请输入您的邮箱' }) + .fontSize(16) + .backgroundColor(Color.White) + .onChange((value: string) => { + this.phoneNumber = value + }) + } + .margin({ top: 10 }) + .width('95%') + .height(48) + .borderRadius(4) + .borderWidth(1) + .borderColor('#CCCCCC') + + // 验证码输入区域 + Row() { + Text('请填写您的真实邮箱,以便联系上您') + .fontSize(15) + .fontColor('#333333') + .width('95%') + } + .margin({top:15}) + .width('95%') + .justifyContent(FlexAlign.SpaceBetween) + + // 登录按钮 + Button({type:ButtonType.Normal}){ + Text('保 存') + } + .width('90%') + .height(48) + .borderRadius(8) + .borderWidth(1) + .borderColor('#8B2316') + .backgroundColor(Color.White) + .fontColor('#8B2316') + .fontSize(18) + .position({x:'5%',y:'80%'}) + .onClick(() => { + // 处理登录逻辑 + if (!/^1[3-9]\d{9}$/.test(this.phoneNumber)) { + promptAction.showToast({message:'请输入有效手机号'}) + return + } + + // 执行登录操作... + }) + } + .width('100%') + .height('100%') + .backgroundColor('#FFFFFF') + } +} diff --git a/features/mypage/src/main/ets/view/ChooseOfficePhoneComp.ets b/features/mypage/src/main/ets/view/ChooseOfficePhoneComp.ets new file mode 100644 index 0000000..9dc5291 --- /dev/null +++ b/features/mypage/src/main/ets/view/ChooseOfficePhoneComp.ets @@ -0,0 +1,84 @@ +import promptAction from '@ohos.promptAction'; +import { authStore } from '@itcast/basic'; + +@Preview +@Component +export struct ChooseOfficePhoneComp { + @State phoneNumber: string = '' + @State smsCode: string = '' + @State countdown: number = 0 + + // 验证码倒计时 + private startCountdown() { + this.countdown = 60 + const timer = setInterval(() => { + if (this.countdown > 0) { + this.countdown-- + } else { + clearInterval(timer) + } + }, 1000) + } + + build() { + Column() { + // 手机号输入框 + Row() { + TextInput({ placeholder: authStore.getUser().officePhone.length>0?authStore.getUser().officePhone:'请输入科室号码' }) + .fontSize(16) + .backgroundColor(Color.White) + .onChange((value: string) => { + this.phoneNumber = value + }) + } + .margin({ top: 10 }) + .width('95%') + .height(48) + .borderRadius(4) + .borderWidth(1) + .borderColor('#CCCCCC') + + // 验证码输入区域 + Row() { + Text('请填写您的真实科室电话,以便联系上您') + .fontSize(15) + .fontColor('#333333') + .width('95%') + } + .margin({top:15}) + .width('95%') + .justifyContent(FlexAlign.SpaceBetween) + + // 登录按钮 + Button({type:ButtonType.Normal}){ + Text('保 存') + } + .width('90%') + .height(48) + .borderRadius(8) + .borderWidth(1) + .borderColor('#8B2316') + .backgroundColor(Color.White) + .fontColor('#8B2316') + .fontSize(18) + .position({x:'5%',y:'80%'}) + .onClick(() => { + // 处理登录逻辑 + if (!/^1[3-9]\d{9}$/.test(this.phoneNumber)) { + promptAction.showToast({message:'请输入有效手机号'}) + return + } + + if (!this.smsCode) { + promptAction.showToast({message:'请输入验证码'}) + return + } + + // 执行登录操作... + }) + } + .width('100%') + .height('100%') + .backgroundColor('#FFFFFF') + } +} diff --git a/features/mypage/src/main/ets/view/DatePickerDialog.ets b/features/mypage/src/main/ets/view/DatePickerDialog.ets new file mode 100644 index 0000000..39b2e7c --- /dev/null +++ b/features/mypage/src/main/ets/view/DatePickerDialog.ets @@ -0,0 +1,71 @@ +import { formatDate } from '../util/DateUtils' + +@CustomDialog +export struct DatePickerDialog { + @Prop selectedDateString:string = formatDate(new Date(),'YYYY-MM-DD'); + controller: CustomDialogController; + + // 添加回调函数属性 + private dateSelected: (date: string) => void = () => {}; + + // 修改构造函数 + constructor(controller: CustomDialogController, dateSelected: (date: string) => void) { + super(); + this.controller = controller; + this.dateSelected = dateSelected; + } + + // 初始化日期范围(示例为1930-至今) + private dateOptions: DatePickerOptions = { + start: new Date('1930-01-01'), + end: new Date(this.selectedDateString) + } + + build() { + Column() { + // 操作按钮区域 + Row({space:70}) { + Button('取消') + .layoutWeight(1) + .backgroundColor(Color.Transparent) + .fontColor($r('app.color.main_color')) + .backgroundColor(Color.White) + .width(80) + .onClick(() => { + this.controller.close() + }) + + Text('请选择出生日期') + .fontSize(15) + .fontColor('#666666') + + Button('确定') + .layoutWeight(1) + .backgroundColor(Color.Transparent) + .fontColor($r('app.color.main_color')) + .backgroundColor(Color.White) + .width(80) + .onClick(() => { + this.controller.close() + this.dateSelected(this.selectedDateString) + }) + } + .height(40) + + // 日期选择器主体 + DatePicker(this.dateOptions) + .lunar(false) // 禁用农历显示[1](@ref) + .selectedTextStyle({ + color: '#007AFF', + font: { size: 20, weight: FontWeight.Medium } + }) + .onDateChange((selected:Date)=>{ + this.selectedDateString = formatDate(selected,'YYYY-MM-DD'); + console.info('select current date is: ' + formatDate(selected,'YYYY-MM-DD')); + }) + } + .width('100%') + .height(240) + .backgroundColor(Color.White) + } +} diff --git a/features/mypage/src/main/ets/view/EditUserDataComp.ets b/features/mypage/src/main/ets/view/EditUserDataComp.ets new file mode 100644 index 0000000..9f8d4c7 --- /dev/null +++ b/features/mypage/src/main/ets/view/EditUserDataComp.ets @@ -0,0 +1,275 @@ +import { hdHttp, HdResponse,BasicConstant, logger,LoginInfo, authStore } from '@itcast/basic' +import HashMap from '@ohos.util.HashMap' +import { BusinessError } from '@kit.BasicServicesKit'; +import { promptAction, router } from '@kit.ArkUI' +import { EditUserDataItem } from './EditUserDataItem' +import { PhotoActionSheet } from './PhotoActionSheet' +import { DatePickerDialog } from './DatePickerDialog' +import { OfficeSelectedSheet } from './OfficeSelectedSheet' +import { PositionSelectedSheet } from './PositionSelectedSheet' +import { http } from '@kit.NetworkKit'; + +interface LoginParams { + uuid: string +} + +@Component +export struct EditUserDataComp { + @State photoPath:string = BasicConstant.imageHeader+authStore.getUser().photo; + @State name:string = authStore.getUser().realName; + @State sex:string = authStore.getUser().sex == 0 ? '男' : '女'; + @State birthday:string = authStore.getUser().birthDate; + @State phone:string = authStore.getUser().mobile; + @State email:string = authStore.getUser().email; + + @State hospatilName:string = authStore.getUser().hospitalName; + @State officeName:string = authStore.getUser().officeName; + @State officePhone:string = authStore.getUser().officePhone; + @State positionName:string = authStore.getUser().positionName; + @State certificate:string = authStore.getUser().certificate; + @State certificatePhoto:string = BasicConstant.imageHeader+authStore.getUser().certificateImg; + @State diseaseName:string = ''; + @State intro:string = authStore.getUser().intro; + + private photoSheetDialog!: CustomDialogController; + private datePickerDialog!: CustomDialogController; + private officePickerDialog!: CustomDialogController; + private positionPickerDialog!: CustomDialogController; + private certificatePhotoSheetDialog!: CustomDialogController; + + aboutToAppear() { + this.initPhotoDialog(); + this.initDatePickerDialog(); + this.initOfficePickerDialog(); + this.initPositionPickerDialog(); + this.initCerficatePhotoDialog(); + + this.uploadUserDataAction(); + console.log('用户资料:'+authStore.getUser().specialy); + } + + uploadUserDataAction() { + const hashMap: HashMap = new HashMap(); + const userDataUrl:string = BasicConstant.urlExpert+'getExpertByUuid'; + hashMap.set('uuid',authStore.getUser().uuid) + hdHttp.post(userDataUrl, { + uuid: authStore.getUser().uuid, + } as LoginParams).then(async (res: HdResponse) => { + logger.info('Response login111'+res); + console.info(`Response login succeeded333: ${res}`); + }).catch((err: BusinessError) => { + console.info(`Response login fail222222222222222: ${err}`); + }) + + + // hdHttp.oldPost(userDataUrl,hashMap).then(async (res: HdResponse) => { + // console.info(`Response officelist succeeded: ${res}`); + // let json:LoginInfo = JSON.parse(res+'') as LoginInfo; + // if(json.code=='1') { + // authStore.setUser(json.data) + // console.log('用户信息成功:', json); + // } else { + // console.error('用户信息失败:'+json.message) + // promptAction.showToast({ message: json.message, duration: 1000 }) + // } + // }).catch((err: BusinessError) => { + // console.error(`Response login fail: ${err}`); + // }) + // hdHttp.httpReq(userDataUrl,hashMap).then(async (res: HdResponse) => { + // logger.info('Response officelist success'+res); + // console.info(`Response officelist succeeded: ${res}`); + // let json:LoginInfo = JSON.parse(res+'') as LoginInfo; + // if(json.code=='1') { + // authStore.setUser(json.data) + // console.log('用户信息成功:', json); + // } else { + // console.error('用户信息失败:'+json.message) + // promptAction.showToast({ message: json.message, duration: 1000 }) + // } + // }).catch((err: BusinessError) => { + // console.info(`Response login fail: ${err}`); + // }) + } + + arrToStringSpecialy(specialy: Array) { + // 声明类型化数组 + let zhuangArr: string[] = []; + // 获取响应数据中的specialy数组(需根据实际API调整类型) + const array = specialy['specialy'] as Array>; + // 遍历提取diseaseName + if (specialy) { + zhuangArr = array + .filter(item => item['diseaseName']) // 过滤空值[8](@ref) + .map(item => item['diseaseName'] ?? ''); // 安全转换[9](@ref) + } + // 拼接为逗号分隔字符串 + const DiseaseName = zhuangArr.join(','); // 等效componentsJoinedByString[8](@ref) + return DiseaseName; + } + + private initPhotoDialog() { + this.photoSheetDialog = new CustomDialogController({ + builder: PhotoActionSheet({ + controller: this.photoSheetDialog, + onPhotoSelected: (uri: string) => { + this.photoPath = uri; + console.log('Selected image URI:', uri); + } + }), + alignment: DialogAlignment.Bottom, + customStyle: true, + autoCancel: false, + backgroundColor: ('rgba(0,0,0,0.5)'), + height: '100%' + }); + } + + private initOfficePickerDialog() { + this.officePickerDialog = new CustomDialogController({ + builder:OfficeSelectedSheet({ + controller:this.officePickerDialog, + officeSelected: (name:string , uuid:string) => { + this.officeName = name; + } + }), + alignment: DialogAlignment.Bottom, + customStyle: true, + autoCancel: false, + backgroundColor: ('rgba(0,0,0,0.5)'), + height: '100%' + }) + } + + private initPositionPickerDialog() { + this.positionPickerDialog = new CustomDialogController({ + builder:PositionSelectedSheet({ + controller:this.officePickerDialog, + officeSelected: (name:string , uuid:string) => { + this.positionName = name; + } + }), + alignment: DialogAlignment.Bottom, + customStyle: true, + autoCancel: false, + backgroundColor: ('rgba(0,0,0,0.5)'), + height: '100%' + }) + } + + private initDatePickerDialog() { + this.datePickerDialog = new CustomDialogController({ + builder: DatePickerDialog({ + controller:this.datePickerDialog, + dateSelected:(date:string) => { + this.birthday = date; + } + }), + alignment: DialogAlignment.Bottom, + customStyle: true, + autoCancel: false, + backgroundColor: ('rgba(0,0,0,0.5)'), + height: '100%' + }); + } + + private initCerficatePhotoDialog() { + this.certificatePhotoSheetDialog = new CustomDialogController({ + builder: PhotoActionSheet({ + controller: this.certificatePhotoSheetDialog, + onPhotoSelected: (uri: string) => { + this.certificatePhoto = uri; + console.log('Selected image URI:', uri); + } + }), + alignment: DialogAlignment.Bottom, + customStyle: true, + autoCancel: false, + backgroundColor: ('rgba(0,0,0,0.5)'), + height: '100%' + }); + } + + build() { + Scroll() { + Column() { + // 第一部分:基本资料 + Column() { + Column(){ + Text('基本资料') + .fontSize(16) + .margin({left:15}) + .fontColor($r('app.color.main_color')) + } + .width('100%') + .height(17) + .backgroundColor(Color.Gray) + .alignItems(HorizontalAlign.Start) + // 基本信息字段 + EditUserDataItem({ label: '头像', required: true, content: this.photoPath, hasArrow: true }) + .onClick(()=>this.photoSheetDialog.open()) + EditUserDataItem({ label: '姓名', required: true, content: this.name }) + EditUserDataItem({ label: '性别', required: true, content: this.sex }) + EditUserDataItem({ label: '出生日期', content: this.birthday , hasArrow: true}) + .onClick(()=>this.datePickerDialog.open()) + EditUserDataItem({ label: '手机号码', required: true, content: this.phone , hasArrow: true}) + .onClick(()=>{ + router.pushUrl({ + url:'pages/MinePage/ChangePhonePage' + }) + }) + EditUserDataItem({ label: '邮箱', content: this.email , hasArrow: true}) + .onClick(()=>{ + router.pushUrl({ + url:'pages/MinePage/ChooseEmail' + }) + }) + } + .height('auto') + + // 第二部分:专业资料 + Column() { + Column(){ + Text('专业资料') + .fontSize(16) + .margin({left:15}) + .fontColor($r('app.color.main_color')) + } + .width('100%') + .height(17) + .backgroundColor(Color.Gray) + .alignItems(HorizontalAlign.Start) + + EditUserDataItem({ label: '医院', required: true, content: this.hospatilName }) + EditUserDataItem({ label: '科室', required: true, content: this.officeName, hasArrow: true }) + .onClick(()=>this.officePickerDialog.open()) + EditUserDataItem({ label: '科室电话', required: true, content: this.officePhone, hasArrow: true }) + .onClick(()=>{ + router.pushUrl({ + url:'pages/MinePage/ChooseOfficePhone' + }) + }) + EditUserDataItem({ label: '职称', required: true, content: this.positionName, hasArrow: true }) + .onClick(()=>this.positionPickerDialog.open()) + EditUserDataItem({ label: '执业医师证编号', required: true, content: this.certificate }) + EditUserDataItem({ label: '执业医师证图片或胸牌', required: true, content: this.certificatePhoto }) + .onClick(()=>this.certificatePhotoSheetDialog.open()) + EditUserDataItem({ label: '专长', required: true, content: this.diseaseName , hasArrow: true}) + EditUserDataItem({ label: '个人简介', content: this.intro, hasArrow: true }) + .onClick(()=>{ + router.pushUrl({ + url:'pages/MinePage/EditIntroductionPage' + }) + }) + } + .height('auto') + } + .width('100%') + .height('100%') + .layoutWeight(1)// 占据剩余空间 + } + .height('auto') + .scrollBar(BarState.Off) + .scrollable(ScrollDirection.Vertical) + .backgroundColor('#ffffff') + } +} diff --git a/features/mypage/src/main/ets/view/EditUserDataItem.ets b/features/mypage/src/main/ets/view/EditUserDataItem.ets new file mode 100644 index 0000000..bb21ccc --- /dev/null +++ b/features/mypage/src/main/ets/view/EditUserDataItem.ets @@ -0,0 +1,68 @@ +@Component +export struct EditUserDataItem { + private label: string = '' + private required: boolean = false + @Prop content: string = '' + private hasArrow: boolean = false + + build() { + Column() { + Row() { + Row() { + Text(this.label) + .fontSize(16) + .fontColor('#333333') + .margin({ left: 15 }) + if (this.required) { + Text('*') + .margin({ left: 0 }) + .fontSize(16) + .fontColor($r('app.color.main_color')) + } + } + .layoutWeight(1)//权重自定义 + .justifyContent(FlexAlign.Start) + + Row({space:5}) { + if (this.label == '头像') { + Image(this.content) + .alt($r('app.media.userPhoto_default')) + .onComplete(() => console.log('图片加载完成')) + .onError(() => console.error('图片加载失败'+this.content)) + .width(40) + .height(40) + .margin({ right: this.hasArrow?0:10 }) + .borderRadius(8) + } else if (this.label == '执业医师证图片或胸牌') { + Image(this.content) + .onComplete(() => console.log('图片加载完成')) + .onError(() => console.error('图片加载失败'+this.content)) + .width(60) + .height(40) + .margin({ right: this.hasArrow?0:10 }) + } else { + Text(this.content) + .fontSize(16) + .fontColor('#333333') + .margin({ right: this.hasArrow?0:10 }) + } + if (this.hasArrow) { + Image($r('sys.media.ohos_ic_public_arrow_right')) + .width(15) + .height(15) + .margin({ right: 10 }) + } + } + .justifyContent(FlexAlign.End) + } + .height(50) + .alignItems(VerticalAlign.Center) + + Divider() + .color('#F4F4F4') + .strokeWidth(1) + .height(1) + .margin({ left: 10, top: 0 }) + } + } +} diff --git a/features/mypage/src/main/ets/view/ForgetPasswordComp.ets b/features/mypage/src/main/ets/view/ForgetPasswordComp.ets new file mode 100644 index 0000000..72c0aa4 --- /dev/null +++ b/features/mypage/src/main/ets/view/ForgetPasswordComp.ets @@ -0,0 +1,149 @@ +import promptAction from '@ohos.promptAction'; +import { router } from '@kit.ArkUI'; + +@Preview +@Component +export struct ForgetPasswordComp { + @State phoneNumber: string = '' + @State smsCode: string = '' + @State password: string = '' + @State showPassword: boolean = false + @State countdown: number = 0 + @State passWordSrc1: Resource = $r('app.media.icon_forgetpassword_show'); + @State passWordSrc2: Resource = $r('app.media.icon_forgetpassword'); + + // 验证码倒计时 + private startCountdown() { + this.countdown = 60 + const timer = setInterval(() => { + if (this.countdown > 0) { + this.countdown-- + } else { + clearInterval(timer) + } + }, 1000) + } + + build() { + Column() { + Row() { + Image($r('app.media.icon_phone')) + .width(18) + .height(18) + .objectFit(ImageFit.Contain) + .margin({left:10}) + // 手机号输入框 + TextInput({ placeholder: '请输入手机号码' }) + .fontSize(16) + .backgroundColor(Color.White) + .onChange((value: string) => { + this.phoneNumber = value + }) + } + .margin({ top: 10 }) + .width('95%') + .height(48) + .borderRadius(4) + .borderWidth(1) + .borderColor('#CCCCCC') + + // 验证码输入区域 + Row() { + Row() { + Image($r('app.media.icon_verification_code')) + .width(18) + .height(18) + .objectFit(ImageFit.Contain) + .margin({left:10}) + TextInput({ placeholder: '请输入验证码' }) + .fontSize(16) + .backgroundColor(Color.White) + } + .margin({ top: 10 }) + .width('60%') + .height(48) + .borderRadius(4) + .borderWidth(1) + .borderColor('#CCCCCC') + + Button({type:ButtonType.Normal}){ + Text(this.countdown ? `${this.countdown}s` : '获取验证码') + } + .width('37%') + .height(32) + .borderRadius(5) + .borderColor($r('app.color.main_color')) + .borderWidth(1) + .backgroundColor(Color.White) + .fontColor($r('app.color.main_color')) + .fontSize(12) + .margin({ top: 10 }) + .enabled(this.countdown === 0) + .onClick(() => { + if (this.phoneNumber.length >= 11) { + this.startCountdown() + } else { + promptAction.showToast({message:'请输入手机号'}) + } + }) + } + .width('95%') + .justifyContent(FlexAlign.SpaceBetween) + + Row() { + Image($r('app.media.icon_forgetpassword_show')) + .width(18) + .height(18) + .objectFit(ImageFit.Contain) + .margin({left:10}) + // 密码输入框 + TextInput({ placeholder: '6~16位数字字母组合' }) + .fontSize(16) + .width('95%') + .backgroundColor(Color.White) + .type(this.showPassword ? InputType.Normal : InputType.Password) + .passwordIcon({ onIconSrc: this.passWordSrc1, offIconSrc: this.passWordSrc2 }) + } + .margin({ top: 10 }) + .width('95%') + .height(48) + .borderRadius(4) + .borderWidth(1) + .borderColor('#CCCCCC') + + // 登录按钮 + Button({type:ButtonType.Normal}){ + Text('登 录') + } + .width('90%') + .height(48) + .margin({ top: 40 }) + .borderRadius(8) + .backgroundColor($r('app.color.main_color')) + .fontColor('#FFFFFF') + .fontSize(18) + .onClick(() => { + // 处理登录逻辑 + if (!/^1[3-9]\d{9}$/.test(this.phoneNumber)) { + promptAction.showToast({message:'请输入有效手机号'}) + return + } + + if (!this.smsCode) { + promptAction.showToast({message:'请输入验证码'}) + return + } + + if (!/^(?=.*[a-zA-Z])(?=.*\d)[\w]{6,16}$/.test(this.password)) { + promptAction.showToast({message:'密码格式不正确'}) + return + } + + // 执行登录操作... + }) + } + .width('100%') + .height('100%') + .backgroundColor('#FFFFFF') + } +} diff --git a/features/mypage/src/main/ets/view/FourSection.ets b/features/mypage/src/main/ets/view/FourSection.ets new file mode 100644 index 0000000..b4ca7c7 --- /dev/null +++ b/features/mypage/src/main/ets/view/FourSection.ets @@ -0,0 +1,152 @@ +import { it } from "@ohos/hypium"; +import { MyPageSectionClass } from "../model/MyPageSectionClass"; +import { MyPageSectionItem } from '../view/MyPageSectionItem' +import { common, Want } from '@kit.AbilityKit'; +import notificationManager from '@ohos.notificationManager'; +import { Theme } from "@ohos.arkui.theme"; +import { BusinessError } from "@kit.BasicServicesKit"; +import emitter from '@ohos.events.emitter'; + +@Component +export struct FourSection { + @State sectionTitle: string = "常规操作"; + @State currentIndex: number = 0; + @State pushStatus: string = '通知已开'; + @State refreshFlag: boolean = false; + + @State fourSectionList:Array = [ + new MyPageSectionClass('oneItem',$r('app.media.app_icon'),'微信绑定','/pages/MyHomePage'), + new MyPageSectionClass('twoItem',$r('app.media.app_icon'),'更换手机号','/pages/MyHomePage'), + new MyPageSectionClass('threeItem',$r('app.media.app_icon'),this.pushStatus,'/pages/MyHomePage'), + new MyPageSectionClass('fourItem',$r('app.media.app_icon'),'发现新版本','/pages/MyHomePage') + ]; + + aboutToAppear() { + console.log('FourSection aboutToAppear!'); + this.checkNotificationStatus(); + + // 监听通知状态变化事件 + emitter.on('notification_status_changed', this.onNotificationChanged); + } + + aboutToDisappear() { + // 取消事件监听 + emitter.off('notification_status_changed', this.onNotificationChanged); + } + + private onNotificationChanged = () => { + console.log('收到通知状态变化事件'); + this.checkNotificationStatus(); + } + + private getPagedItems(): Array> { + const pages: Array> = []; + const itemsPerPage = 4; + for (let i = 0; i < this.fourSectionList.length; i += itemsPerPage) { + pages.push(this.fourSectionList.slice(i, i + itemsPerPage)); + } + return pages; + } + + async checkNotificationStatus() { + try { + let isEnabled = await notificationManager.isNotificationEnabledSync(); + console.log('当前通知状态:', isEnabled); + this.pushStatus = isEnabled ? '通知已开' : '通知已关'; + // 更新数组中的标题 + this.fourSectionList = this.fourSectionList.map((item, index) => { + if (index === 2) { + return new MyPageSectionClass(item.id, item.imageSrc, this.pushStatus, item.path); + } + return item; + }); + } catch (error) { + console.error('Failed to check notification status:', error); + } + } + + private handleNotificationClick() { + let want: Want = { + bundleName: 'com.huawei.hmos.settings', + abilityName: 'com.huawei.hmos.settings.MainAbility', + uri: 'application_info_entry', + parameters: { + pushParams: 'com.example.expert' + } + }; + const context = getContext(this) as common.UIAbilityContext; + // 发送全局事件 + emitter.emit('notification_status_changed'); + context.startAbility(want).catch((err:BusinessError) => { + console.error('Failed to start ability:', err); + }); + } + + build() { + Column() { + // 标题 + Text(this.sectionTitle) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, left: 13 }) + .height(42) + + Column() { + Stack({ alignContent: Alignment.Bottom }) { + Swiper() { + ForEach(this.getPagedItems(), (pageItems: Array, index?: number) => { + Grid() { + ForEach(pageItems, (item: MyPageSectionClass) => { + GridItem() { + MyPageSectionItem({ sectionItem: item }) + } + .onClick(()=>{ + if (item.title.includes('通知')) { + this.handleNotificationClick(); + } + }) + }, (item: MyPageSectionClass) => item.id) + } + .columnsTemplate('1fr 1fr 1fr 1fr') + .columnsGap(8) + .rowsGap(8) + .height('100%') + .width('100%') + }) + } + .index(this.currentIndex) + .onChange((index: number) => { + this.currentIndex = index; + }) + .height(78) + .indicator(false) + + if (this.fourSectionList.length > 4) { + Row() { + ForEach(new Array(Math.ceil(this.fourSectionList.length / 4)).fill(0), (item: number, idx: number) => { + Row() + .width('50%') + .height(6) + .borderRadius(3) + .backgroundColor(this.currentIndex === idx ? '#8B2316' : + '#D8D8D8')// .margin({ right: idx !== Math.ceil(this.oneSectionList.length / 4) - 1 ? 0 : 0 }) + .margin({ right: 0 }) + }, (item: number, index: number) => index.toString()) + } + .justifyContent(FlexAlign.Center) + .backgroundColor('#D8D8D8') + .height(6) + .width(23) + .borderRadius(3) + .margin({ bottom: 8 }) + } + } + } + .padding({ left: 20, right: 20 }) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) + .borderRadius(5) + .margin({ top: 10, left: 10, right: 10 }) + } +} \ No newline at end of file diff --git a/features/mypage/src/main/ets/view/HeaderView.ets b/features/mypage/src/main/ets/view/HeaderView.ets new file mode 100644 index 0000000..22af948 --- /dev/null +++ b/features/mypage/src/main/ets/view/HeaderView.ets @@ -0,0 +1,81 @@ +import { HeroPopWindow } from '../view/HeroPopWindow' +import { router } from '@kit.ArkUI' + +@Preview +@Component +export struct HeaderView { + @State heroIndex: number = 0 // 当前页索引 + private scrollerForList: Scroller = new Scroller() + private heroList: string[] = ['2020年英雄榜','2021年英雄榜','2022年英雄榜','2023年英雄榜','2024年英雄榜'] + + dialogController: CustomDialogController = new CustomDialogController({ + builder: HeroPopWindow(), + alignment: DialogAlignment.Center, + customStyle: true + }) + + handleAvatarClick() { + router.pushUrl({url:'pages/MinePage/EditUserDataPage'}) + } + + build() { + // Row() { + Column({space:5}) { + Row({space:10}) { + Image($r('app.media.app_icon')) + .margin({left:15}) + .width(60) + .height(60) + .borderRadius(30) + .objectFit(ImageFit.Fill) + .onClick(()=>this.handleAvatarClick()) + Column({space:5}) { + Text('段钟平专家工作室') + .fontSize(18) + .fontColor('#333') + .onClick(()=>this.handleAvatarClick()) + List({space:5,initialIndex:this.heroIndex,scroller:this.scrollerForList}) { + ForEach(this.heroList, (item: string,index:number) => { + ListItem() { + Row() { + Image($r('app.media.app_icon')) + .width(13) + .height(13) + .margin({left:7}) + Text(item) + .fontColor(Color.White) + .fontSize(11) + .margin({left:4,right:10}) + } + .height(18) + // .width('autp') + .margin({right:5}) + .borderRadius(9) + .borderWidth(1) + .borderColor(Color.White) + .onClick(() => { + console.log('Show HeroPopWindow'); + }) + .onClick(()=>this.dialogController.open()) + } + }) + } + .listDirection(Axis.Horizontal) + .scrollBar(BarState.Off) + .width('100%') + .height(18) + } + .alignItems(HorizontalAlign.Start) + .height(60) + .width('70%') + .margin({top:22}) + } + .width('100%') + .height(97) + } + .width('100%') + .height(97) + .backgroundColor(Color.Green) + } + // } +} diff --git a/features/mypage/src/main/ets/view/HeroPopWindow.ets b/features/mypage/src/main/ets/view/HeroPopWindow.ets new file mode 100644 index 0000000..622f2c0 --- /dev/null +++ b/features/mypage/src/main/ets/view/HeroPopWindow.ets @@ -0,0 +1,83 @@ +import { it } from "@ohos/hypium"; + +@CustomDialog +export struct HeroPopWindow { + private years: string[] = ['2019年英雄榜','2018年英雄榜','2017年英雄榜','2016年英雄榜','2015年英雄榜']; + controller: CustomDialogController; + build() { + Stack() { + //半透明黑色背景 + Column().width('100%').height('100%').backgroundColor('#50000000') + + //弹窗主体 + Column() { + //头部图标 + Image($r('app.media.heroPop_headericon')) + .width(80) + .height(80) + .margin({top:-25}) + .zIndex(2) + //标题和正文范围 + Column() { + Text('肝胆英雄榜') + .fontSize(20) + .fontColor('#673986') + .margin({top:20}) + Grid() { + ForEach(this.years,(item:string)=>{ + GridItem({style:GridItemStyle.PLAIN}) { + Text(item) + .fontSize(10) + .fontColor(Color.Black) + .backgroundColor(Color.White) // 添加背景色确保可见 + .textAlign(TextAlign.Center) + .width('100%') // 确保文本容器宽度 + } + .height(20) + .width('48%') + .padding(5) + .borderRadius(10) + .borderWidth(1) + .borderColor(Color.Red) + }) + } + .columnsGap(10) + .rowsGap(10) + .padding(10) + .width('100%') + .height('auto') + Text('感谢有您,一路相伴。"肝胆英雄榜"是由国内最具影响力的肝胆病互联网线上服务平台-\n' + + '肝胆相照依据肝胆病医生在各自领域年度所做工作,综合评选出来的最认可的"肝胆好医生",授予证书并赠送精美感恩好礼。\n' + + '目前"肝胆英雄榜"荣誉包括:"护肝大使"护肝新量""公益之星""科普达入"、"视频之星"、"人气科室"及"宣传之星"等。') + .fontSize(12) + .fontColor('#666666') + .textAlign(TextAlign.Start) + .lineHeight(20) + .width('90%') + .margin({bottom:10}) + } + .zIndex(1) + .margin({top:-10,bottom:10}) + .justifyContent(FlexAlign.Center) + .backgroundColor(Color.White) + .borderRadius(16) + .height('auto') + .width('90%') + + //删除按钮 + Button() { + Image($r('app.media.heropop_delete')) + .width(30) + .height(30) + } + .zIndex(3) + .position({ x: '88%', y: 10 }) + .onClick(() => this.controller.close()) + } + .width('90%') + .backgroundImage($r('app.media.heroPop_bg')) + .backgroundImageSize(ImageSize.Cover) + .borderRadius(16) + } + } +} \ No newline at end of file diff --git a/features/mypage/src/main/ets/view/MyPageSectionItem.ets b/features/mypage/src/main/ets/view/MyPageSectionItem.ets new file mode 100644 index 0000000..a711602 --- /dev/null +++ b/features/mypage/src/main/ets/view/MyPageSectionItem.ets @@ -0,0 +1,19 @@ +import { MyPageSectionClass } from "../model/MyPageSectionClass" + +@Component +export struct MyPageSectionItem { + @Prop sectionItem: MyPageSectionClass; + + build() { + Column(){ + Image(this.sectionItem.imageSrc) + .backgroundColor(Color.Gray) + .width(35).height(35) + .borderRadius(17.5) + Text(this.sectionItem.title) + .fontSize(12) + .fontColor(Color.Black) + .margin({top:6}) + } + } +} diff --git a/features/mypage/src/main/ets/view/OfficeSelectedSheet.ets b/features/mypage/src/main/ets/view/OfficeSelectedSheet.ets new file mode 100644 index 0000000..36651b8 --- /dev/null +++ b/features/mypage/src/main/ets/view/OfficeSelectedSheet.ets @@ -0,0 +1,103 @@ +import { hdHttp, HdResponse,BasicConstant, logger,RequestDefaultModel, Data } from '@itcast/basic' +import { promptAction } from '@kit.ArkUI' +import HashMap from '@ohos.util.HashMap'; +import { BusinessError } from '@kit.BasicServicesKit'; + +interface DefaultData { + 'officeName':string; + 'officeUuid':string; +} + +@CustomDialog +export struct OfficeSelectedSheet { + controller: CustomDialogController; + @State officeNameArr:Array = []; + private officeArr:Array = []; + @Prop selectedOffice:object = new Object; + @State selectedModel:DefaultData = { officeName: '', officeUuid: '' }; + + // 添加回调函数属性 + private officeSelected: (name:string , uuid:string) => void = () => {}; + + // 修改构造函数 + constructor(controller: CustomDialogController, officeSelected: (name: string,uuid:string) => void) { + super(); + this.controller = controller; + this.officeSelected = officeSelected; + } + + officeRequestUrl:string = BasicConstant.urlExpert+'officeList' + hashMap: HashMap = new HashMap(); + + aboutToAppear(): void { + this.uploadOffice(); + } + + uploadOffice() { + hdHttp.httpReq(this.officeRequestUrl,this.hashMap).then(async (res: HdResponse) => { + logger.info('Response officelist success'+res); + console.info(`Response officelist succeeded: ${res}`); + let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel; + if(json.code=='1') { + this.officeArr = json.data as DefaultData[]; + this.officeNameArr = json.data.map(item => item.officeName); + console.log('科室名称数组:', this.officeNameArr); + } else { + console.error('科室数据失败:'+json.message) + promptAction.showToast({ message: json.message, duration: 1000 }) + } + }).catch((err: BusinessError) => { + console.info(`Response login fail: ${err}`); + }) + } + + build() { + Column() { + // 操作按钮区域 + Row({space:70}) { + Button('取消') + .layoutWeight(1) + .backgroundColor(Color.Transparent) + .fontColor($r('app.color.main_color')) + .backgroundColor(Color.White) + .width(80) + .onClick(() => { + this.controller.close() + }) + + Text('请选择科室') + .fontSize(15) + .fontColor('#666666') + + Button('确定') + .layoutWeight(1) + .backgroundColor(Color.Transparent) + .fontColor($r('app.color.main_color')) + .backgroundColor(Color.White) + .width(80) + .onClick(() => { + this.controller.close() + this.officeSelected(this.selectedModel.officeName, this.selectedModel.officeUuid); + }) + } + .height(40) + + TextPicker({ + range:this.officeNameArr + }) + .selectedTextStyle({ + color: '#007AFF', + font: { size: 20, weight: FontWeight.Medium } + }) + .onChange((name: string | string[], index: number | number[]) => { + // 处理单列选择场景 + if (typeof index === "number" && this.officeArr[index]) { + this.selectedModel = this.officeArr[index]; + } + }) + } + .width('100%') + .height(240) + .backgroundColor(Color.White) + } +} diff --git a/features/mypage/src/main/ets/view/OneSection.ets b/features/mypage/src/main/ets/view/OneSection.ets new file mode 100644 index 0000000..25766f0 --- /dev/null +++ b/features/mypage/src/main/ets/view/OneSection.ets @@ -0,0 +1,88 @@ +import { it } from "@ohos/hypium"; +import { MyPageSectionClass } from "../model/MyPageSectionClass"; +import { MyPageSectionItem } from '../view/MyPageSectionItem' + +@Preview +@Component +export struct OneSection { + @State sectionTitle: string = "随访服务"; + @State currentIndex: number = 0; + + @State oneSectionList: Array = [ + new MyPageSectionClass('oneItem', $r('app.media.app_icon'), '患者审核', '/pages/MyHomePage'), + new MyPageSectionClass('twoItem', $r('app.media.app_icon'), '患者分组', '/pages/MyHomePage'), + new MyPageSectionClass('threeItem', $r('app.media.app_icon'), '群发消息', '/pages/MyHomePage'), + new MyPageSectionClass('fourItem', $r('app.media.app_icon'), '随访二维码', '/pages/MyHomePage'), + new MyPageSectionClass('fiveItem', $r('app.media.app_icon'), '出诊计划', '/pages/MyHomePage') + ]; + + private getPagedItems(): Array> { + const pages: Array> = []; + const itemsPerPage = 4; + for (let i = 0; i < this.oneSectionList.length; i += itemsPerPage) { + pages.push(this.oneSectionList.slice(i, i + itemsPerPage)); + } + return pages; + } + + build() { + Column() { + // 标题 + Text(this.sectionTitle) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, left: 13 }) + .height(42) + + Column() { + Stack({ alignContent: Alignment.Bottom }) { + Swiper() { + ForEach(this.getPagedItems(), (pageItems: Array, index?: number) => { + Grid() { + ForEach(pageItems, (item: MyPageSectionClass) => { + GridItem() { + MyPageSectionItem({ sectionItem: item }) + } + }, (item: MyPageSectionClass) => item.id) + } + .columnsTemplate('1fr 1fr 1fr 1fr') + .columnsGap(8) + .rowsGap(8) + .height('100%') + .width('100%') + }) + } + .index(this.currentIndex) + .onChange((index: number) => { + this.currentIndex = index; + }) + .height(78) + .indicator(false) + + Row() { + ForEach(new Array(Math.ceil(this.oneSectionList.length / 4)).fill(0), (item: number, idx: number) => { + Row() + .width('50%') + .height(6) + .borderRadius(3) + .backgroundColor(this.currentIndex === idx ? '#8B2316' : '#D8D8D8') + // .margin({ right: idx !== Math.ceil(this.oneSectionList.length / 4) - 1 ? 0 : 0 }) + .margin({ right:0 }) + }, (item: number, index: number) => index.toString()) + } + .justifyContent(FlexAlign.Center) + .backgroundColor('#D8D8D8') + .height(6) + .width(23) + .borderRadius(3) + .margin({ bottom: 8 }) + } + } + .padding({ left: 20, right: 20 }) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) + .borderRadius(5) + .margin({ top: 10, left: 10, right: 10 }) + } +} \ No newline at end of file diff --git a/features/mypage/src/main/ets/view/OtherList.ets b/features/mypage/src/main/ets/view/OtherList.ets new file mode 100644 index 0000000..7a80b1f --- /dev/null +++ b/features/mypage/src/main/ets/view/OtherList.ets @@ -0,0 +1,70 @@ +import { router } from '@kit.ArkUI' + +class ListClass { + id: number = 0; + imageSrc: ResourceStr = ''; + content: string = '' + + constructor(id: number, imageSrc: ResourceStr, content: string) { + this.id = id + this.imageSrc = imageSrc; + this.content = content; + } +} + +@Preview +@Component +export struct OtherList { + @State otherList:Array=[ + // new ListClass(1,$r('app.media.app_icon'),'福利卡兑换'), + // new ListClass(2,$r('app.media.app_icon'),'发票管理'), + // new ListClass(3,$r('app.media.app_icon'),'常用银行卡'), + new ListClass(4,$r('app.media.app_icon'),'设置与帮助') + ] + + build() { + Row() { + List() { + ForEach(this.otherList,(model:ListClass)=>{ + ListItem(){ + Column(){ + Row() { + Image(model.imageSrc) + .width(22) + .height(22) + .margin({left:15}) + Text(model.content) + .fontSize(12) + .margin({left:10}) + Blank() + Image($r('sys.media.ohos_ic_public_arrow_right')) + .width(15) + .height(15) + .margin({right:10}) + } + .width('100%') + .height(52) + .justifyContent(FlexAlign.SpaceBetween) + .onClick(()=>{ + router.pushUrl({url:'pages/MinePage/SettingPage'}) + }) + + if (model.id <= 3) { + Divider() + .color('#F4F4F4') + .strokeWidth(1) + .height(1) + .margin({left:10,top:0}) + } + } + .justifyContent(FlexAlign.Start) + } + .height(53) + }) + } + .backgroundColor(Color.White) + .borderRadius(5) + .margin({top:10,left:10,right:10}) + } + } +} diff --git a/features/mypage/src/main/ets/view/PhotoActionSheet.ets b/features/mypage/src/main/ets/view/PhotoActionSheet.ets new file mode 100644 index 0000000..284539b --- /dev/null +++ b/features/mypage/src/main/ets/view/PhotoActionSheet.ets @@ -0,0 +1,145 @@ +import picker from '@ohos.file.picker'; +import { BusinessError } from '@ohos.base'; +import photoAccessHelper from '@ohos.file.photoAccessHelper'; +import common from '@ohos.app.ability.common'; +import { cameraPicker, camera } from '@kit.CameraKit' +import { abilityAccessCtrl } from '@kit.AbilityKit'; + +@CustomDialog +export struct PhotoActionSheet { + controller: CustomDialogController; + + // 添加回调函数属性 + private onPhotoSelected: (uri: string) => void = () => {}; + + // 修改构造函数 + constructor(controller: CustomDialogController, onPhotoSelected: (uri: string) => void) { + super(); + this.controller = controller; + this.onPhotoSelected = onPhotoSelected; + } + + async checkCameraPermission(): Promise { + const atManager = abilityAccessCtrl.createAtManager(); + const grantStatus = await atManager.checkAccessToken( + globalThis.abilityContext.applicationInfo.accessTokenId, + 'ohos.permission.CAMERA' + ); + return grantStatus === abilityAccessCtrl.GrantStatus.PERMISSION_GRANTED; + } + + build() { + Column() { + // 操作按钮区域 + Column() { + Row() { + // 拍摄照片按钮 + Column() { + Image($r('app.media.icon_camera')) + .width(40) + .height(40) + Text('拍摄照片') + .fontSize(15) + .margin({top:10}) + .fontColor($r('app.color.main_color')) + } + .width('50%') + .height(80) + .onClick(() => { + const context = getContext() as common.UIAbilityContext; + const cameras = camera.getCameraManager(context).getSupportedCameras(); + cameras.forEach(device => { + console.log('Camera type:', device.cameraPosition); + }); + this.openSystemCamera(); + this.animateHide(); + }) + .padding(20) + + // 相册照片按钮 + Column() { + Image($r('app.media.ixon_album')) + .width(40) + .height(40) + Text('相册照片') + .fontSize(15) + .margin({top:10}) + .fontColor($r('app.color.main_color')) + } + .width('50%') + .height(80) + .onClick(() => { + this.selectPhoto(); + this.animateHide() + }) + .padding(20) + } + } + .backgroundColor(Color.White) + + Divider() + .color('#999999') + .strokeWidth(5) + .height(5) + .margin({top:20}) + + // 取消按钮 + Button('取消') + .width('100%') + .height(50) + .fontColor('#999999') + .backgroundColor(Color.White) + .onClick(() => this.animateHide()) + } + .width('100%') + .height(150) + .backgroundColor(Color.White) + } + + animateHide() { + this.controller.close(); + } + + // 打开相机 + private async openSystemCamera() { + try { + const pickerProfile: cameraPicker.PickerProfile = { + cameraPosition: camera.CameraPosition.CAMERA_POSITION_BACK, + videoDuration: 15 // 录像时设置最大时长(秒) + }; + + const result = await cameraPicker.pick( + getContext(), + [cameraPicker.PickerMediaType.PHOTO], // 可替换为VIDEO + pickerProfile + ); + + if (result.resultCode === 0) { + console.log('Photo URI:', result.resultUri); + // 处理拍摄结果 + } + } catch (error) { + console.error('Camera error:', error.code); + } + } + + // 资源被选中回调,返回资源的信息,以及选中方式 + private selectPhoto() { + let photoSelectOptions = new picker.PhotoSelectOptions(); + photoSelectOptions.MIMEType = picker.PhotoViewMIMETypes.IMAGE_TYPE; + photoSelectOptions.maxSelectNumber = 1; + + let photoViewPicker = new picker.PhotoViewPicker(); + photoViewPicker.select(photoSelectOptions) + .then((photoSelectResult) => { + console.info('PhotoViewPicker.select successfully, photoSelectResult uri: ' + + JSON.stringify(photoSelectResult)); + if (photoSelectResult.photoUris && photoSelectResult.photoUris.length > 0) { + this.onPhotoSelected(photoSelectResult.photoUris[0]); + } + }) + .catch((err: BusinessError) => { + console.error('PhotoViewPicker.select failed with err: ' + err); + }); + } +} diff --git a/features/mypage/src/main/ets/view/PositionSelectedSheet.ets b/features/mypage/src/main/ets/view/PositionSelectedSheet.ets new file mode 100644 index 0000000..e4f6ea3 --- /dev/null +++ b/features/mypage/src/main/ets/view/PositionSelectedSheet.ets @@ -0,0 +1,103 @@ +import { hdHttp, HdResponse,BasicConstant, logger,RequestDefaultModel, Data } from '@itcast/basic' +import { promptAction } from '@kit.ArkUI' +import HashMap from '@ohos.util.HashMap'; +import { BusinessError } from '@kit.BasicServicesKit'; + +interface DefaultData { + 'name':string; + 'uuid':string; +} + +@CustomDialog +export struct PositionSelectedSheet { + controller: CustomDialogController; + @State officeNameArr:Array = []; + private officeArr:Array = []; + @Prop selectedOffice:object = new Object; + @State selectedModel:DefaultData = { name: '', uuid: '' }; + + // 添加回调函数属性 + private officeSelected: (name:string , uuid:string) => void = () => {}; + + // 修改构造函数 + constructor(controller: CustomDialogController, officeSelected: (name: string,uuid:string) => void) { + super(); + this.controller = controller; + this.officeSelected = officeSelected; + } + + officeRequestUrl:string = BasicConstant.urlExpert+'positionList' + hashMap: HashMap = new HashMap(); + + aboutToAppear(): void { + this.uploadOffice(); + } + + uploadOffice() { + hdHttp.httpReq(this.officeRequestUrl,this.hashMap).then(async (res: HdResponse) => { + logger.info('Response officelist success'+res); + console.info(`Response officelist succeeded: ${res}`); + let json:RequestDefaultModel = JSON.parse(res+'') as RequestDefaultModel; + if(json.code=='1') { + this.officeArr = json.data as DefaultData[]; + this.officeNameArr = json.data.map(item => item.name); + console.log('职称名称数组:', this.officeNameArr); + } else { + console.error('职称数据失败:'+json.message) + promptAction.showToast({ message: json.message, duration: 1000 }) + } + }).catch((err: BusinessError) => { + console.info(`Response login fail: ${err}`); + }) + } + + build() { + Column() { + // 操作按钮区域 + Row({space:70}) { + Button('取消') + .layoutWeight(1) + .backgroundColor(Color.Transparent) + .fontColor($r('app.color.main_color')) + .backgroundColor(Color.White) + .width(80) + .onClick(() => { + this.controller.close() + }) + + Text('请选择职称') + .fontSize(15) + .fontColor('#666666') + + Button('确定') + .layoutWeight(1) + .backgroundColor(Color.Transparent) + .fontColor($r('app.color.main_color')) + .backgroundColor(Color.White) + .width(80) + .onClick(() => { + this.controller.close() + this.officeSelected(this.selectedModel.name, this.selectedModel.uuid); + }) + } + .height(40) + + TextPicker({ + range:this.officeNameArr + }) + .selectedTextStyle({ + color: '#007AFF', + font: { size: 20, weight: FontWeight.Medium } + }) + .onChange((name: string | string[], index: number | number[]) => { + // 处理单列选择场景 + if (typeof index === "number" && this.officeArr[index]) { + this.selectedModel = this.officeArr[index]; + } + }) + } + .width('100%') + .height(240) + .backgroundColor(Color.White) + } +} diff --git a/features/mypage/src/main/ets/view/ThreeSection.ets b/features/mypage/src/main/ets/view/ThreeSection.ets new file mode 100644 index 0000000..db0d862 --- /dev/null +++ b/features/mypage/src/main/ets/view/ThreeSection.ets @@ -0,0 +1,91 @@ +import { it } from "@ohos/hypium"; +import { MyPageSectionClass } from "../model/MyPageSectionClass"; +import { MyPageSectionItem } from '../view/MyPageSectionItem' + +@Preview +@Component +export struct ThreeSection { + @State sectionTitle:string="账户明细"; + @State currentIndex: number = 0; + + @State threeSectionList:Array = [ + new MyPageSectionClass('oneItem',$r('app.media.app_icon'),'我的账户','/pages/MyHomePage'), + new MyPageSectionClass('twoItem',$r('app.media.app_icon'),'我的积分','/pages/MyHomePage'), + new MyPageSectionClass('threeItem',$r('app.media.app_icon'),'我的福利','/pages/MyHomePage'), + new MyPageSectionClass('fourItem',$r('app.media.app_icon'),'我的鲜花','/pages/MyHomePage'), + new MyPageSectionClass('fiveItem',$r('app.media.app_icon'),'课件明细','/pages/MyHomePage'), + new MyPageSectionClass('fiveItem',$r('app.media.app_icon'),'课程明细','/pages/MyHomePage') + ]; + + private getPagedItems(): Array> { + const pages: Array> = []; + const itemsPerPage = 4; + for (let i = 0; i < this.threeSectionList.length; i += itemsPerPage) { + pages.push(this.threeSectionList.slice(i, i + itemsPerPage)); + } + return pages; + } + + build() { + Column() { + // 标题 + Text(this.sectionTitle) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, left: 13 }) + .height(42) + + Column() { + Stack({ alignContent: Alignment.Bottom }) { + Swiper() { + ForEach(this.getPagedItems(), (pageItems: Array, index?: number) => { + Grid() { + ForEach(pageItems, (item: MyPageSectionClass) => { + GridItem() { + MyPageSectionItem({ sectionItem: item }) + } + }, (item: MyPageSectionClass) => item.id) + } + .columnsTemplate('1fr 1fr 1fr 1fr') + .columnsGap(8) + .rowsGap(8) + .height('100%') + .width('100%') + }) + } + .index(this.currentIndex) + .onChange((index: number) => { + this.currentIndex = index; + }) + .height(78) + .indicator(false) + + if (this.threeSectionList.length > 4) { + Row() { + ForEach(new Array(Math.ceil(this.threeSectionList.length / 4)).fill(0), (item: number, idx: number) => { + Row() + .width('50%') + .height(6) + .borderRadius(3) + .backgroundColor(this.currentIndex === idx ? '#8B2316' : + '#D8D8D8')// .margin({ right: idx !== Math.ceil(this.oneSectionList.length / 4) - 1 ? 0 : 0 }) + .margin({ right: 0 }) + }, (item: number, index: number) => index.toString()) + } + .justifyContent(FlexAlign.Center) + .backgroundColor('#D8D8D8') + .height(6) + .width(23) + .borderRadius(3) + .margin({ bottom: 8 }) + } + } + } + .padding({ left: 20, right: 20 }) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) + .borderRadius(5) + .margin({ top: 10, left: 10, right: 10 }) + } +} \ No newline at end of file diff --git a/features/mypage/src/main/ets/view/TwoSection.ets b/features/mypage/src/main/ets/view/TwoSection.ets new file mode 100644 index 0000000..dd301a0 --- /dev/null +++ b/features/mypage/src/main/ets/view/TwoSection.ets @@ -0,0 +1,89 @@ +import { it } from "@ohos/hypium"; +import { MyPageSectionClass } from "../model/MyPageSectionClass"; +import { MyPageSectionItem } from '../view/MyPageSectionItem' + +@Preview +@Component +export struct TwoSection { + @State sectionTitle:string="学习进步"; + @State currentIndex: number = 0; + + @State twoSectionList:Array = [ + new MyPageSectionClass('oneItem',$r('app.media.app_icon'),'我的视频','/pages/MyHomePage'), + new MyPageSectionClass('twoItem',$r('app.media.app_icon'),'我的课程','/pages/MyHomePage'), + new MyPageSectionClass('threeItem',$r('app.media.app_icon'),'我的下载','/pages/MyHomePage'), + new MyPageSectionClass('fourItem',$r('app.media.app_icon'),'我的收藏','/pages/MyHomePage') + ]; + + private getPagedItems(): Array> { + const pages: Array> = []; + const itemsPerPage = 4; + for (let i = 0; i < this.twoSectionList.length; i += itemsPerPage) { + pages.push(this.twoSectionList.slice(i, i + itemsPerPage)); + } + return pages; + } + + build() { + Column() { + // 标题 + Text(this.sectionTitle) + .fontSize(17) + .fontWeight(FontWeight.Bold) + .margin({ top: 10, left: 13 }) + .height(42) + + Column() { + Stack({ alignContent: Alignment.Bottom }) { + Swiper() { + ForEach(this.getPagedItems(), (pageItems: Array, index?: number) => { + Grid() { + ForEach(pageItems, (item: MyPageSectionClass) => { + GridItem() { + MyPageSectionItem({ sectionItem: item }) + } + }, (item: MyPageSectionClass) => item.id) + } + .columnsTemplate('1fr 1fr 1fr 1fr') + .columnsGap(8) + .rowsGap(8) + .height('100%') + .width('100%') + }) + } + .index(this.currentIndex) + .onChange((index: number) => { + this.currentIndex = index; + }) + .height(78) + .indicator(false) + + if (this.twoSectionList.length > 4) { + Row() { + ForEach(new Array(Math.ceil(this.twoSectionList.length / 4)).fill(0), (item: number, idx: number) => { + Row() + .width('50%') + .height(6) + .borderRadius(3) + .backgroundColor(this.currentIndex === idx ? '#8B2316' : + '#D8D8D8')// .margin({ right: idx !== Math.ceil(this.oneSectionList.length / 4) - 1 ? 0 : 0 }) + .margin({ right: 0 }) + }, (item: number, index: number) => index.toString()) + } + .justifyContent(FlexAlign.Center) + .backgroundColor('#D8D8D8') + .height(6) + .width(23) + .borderRadius(3) + .margin({ bottom: 8 }) + } + } + } + .padding({ left: 20, right: 20 }) + } + .alignItems(HorizontalAlign.Start) + .backgroundColor(Color.White) + .borderRadius(5) + .margin({ top: 10, left: 10, right: 10 }) + } +} \ No newline at end of file diff --git a/features/mypage/src/main/module.json5 b/features/mypage/src/main/module.json5 new file mode 100644 index 0000000..a719f9b --- /dev/null +++ b/features/mypage/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "mypage", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} \ No newline at end of file diff --git a/features/mypage/src/main/resources/base/element/float.json b/features/mypage/src/main/resources/base/element/float.json new file mode 100644 index 0000000..a0a93dd --- /dev/null +++ b/features/mypage/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} \ No newline at end of file diff --git a/features/mypage/src/main/resources/base/element/string.json b/features/mypage/src/main/resources/base/element/string.json new file mode 100644 index 0000000..f51a9c8 --- /dev/null +++ b/features/mypage/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/features/mypage/src/main/resources/base/media/app_icon.png b/features/mypage/src/main/resources/base/media/app_icon.png new file mode 100644 index 0000000..9dad311 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/app_icon.png differ diff --git a/features/mypage/src/main/resources/base/media/heroPop_bg.png b/features/mypage/src/main/resources/base/media/heroPop_bg.png new file mode 100644 index 0000000..0122f8b Binary files /dev/null and b/features/mypage/src/main/resources/base/media/heroPop_bg.png differ diff --git a/features/mypage/src/main/resources/base/media/heroPop_headericon.png b/features/mypage/src/main/resources/base/media/heroPop_headericon.png new file mode 100644 index 0000000..49f0d66 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/heroPop_headericon.png differ diff --git a/features/mypage/src/main/resources/base/media/heropop_delete.png b/features/mypage/src/main/resources/base/media/heropop_delete.png new file mode 100644 index 0000000..d5e7362 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/heropop_delete.png differ diff --git a/features/mypage/src/main/resources/base/media/icon_camera.png b/features/mypage/src/main/resources/base/media/icon_camera.png new file mode 100644 index 0000000..1734a60 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/icon_camera.png differ diff --git a/features/mypage/src/main/resources/base/media/icon_forgetpassword.png b/features/mypage/src/main/resources/base/media/icon_forgetpassword.png new file mode 100644 index 0000000..883b2c7 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/icon_forgetpassword.png differ diff --git a/features/mypage/src/main/resources/base/media/icon_forgetpassword_show.png b/features/mypage/src/main/resources/base/media/icon_forgetpassword_show.png new file mode 100644 index 0000000..727e683 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/icon_forgetpassword_show.png differ diff --git a/features/mypage/src/main/resources/base/media/icon_phone.png b/features/mypage/src/main/resources/base/media/icon_phone.png new file mode 100644 index 0000000..67be629 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/icon_phone.png differ diff --git a/features/mypage/src/main/resources/base/media/icon_verification_code.png b/features/mypage/src/main/resources/base/media/icon_verification_code.png new file mode 100644 index 0000000..4397073 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/icon_verification_code.png differ diff --git a/features/mypage/src/main/resources/base/media/ixon_album.png b/features/mypage/src/main/resources/base/media/ixon_album.png new file mode 100644 index 0000000..92f723d Binary files /dev/null and b/features/mypage/src/main/resources/base/media/ixon_album.png differ diff --git a/features/mypage/src/main/resources/base/media/userPhoto_default.png b/features/mypage/src/main/resources/base/media/userPhoto_default.png new file mode 100644 index 0000000..6cbc7e8 Binary files /dev/null and b/features/mypage/src/main/resources/base/media/userPhoto_default.png differ diff --git a/features/mypage/src/ohosTest/ets/test/Ability.test.ets b/features/mypage/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/features/mypage/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/features/mypage/src/ohosTest/ets/test/List.test.ets b/features/mypage/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..794c7dc --- /dev/null +++ b/features/mypage/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/features/mypage/src/ohosTest/module.json5 b/features/mypage/src/ohosTest/module.json5 new file mode 100644 index 0000000..de30661 --- /dev/null +++ b/features/mypage/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "mypage_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/features/mypage/src/test/List.test.ets b/features/mypage/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/features/mypage/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/features/mypage/src/test/LocalUnit.test.ets b/features/mypage/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/features/mypage/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/features/register/.gitignore b/features/register/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/features/register/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/features/register/BuildProfile.ets b/features/register/BuildProfile.ets new file mode 100644 index 0000000..3a501e5 --- /dev/null +++ b/features/register/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/features/register/Index.ets b/features/register/Index.ets new file mode 100644 index 0000000..e6d77b0 --- /dev/null +++ b/features/register/Index.ets @@ -0,0 +1,7 @@ +export { MainPage } from './src/main/ets/components/MainPage'; +export { GuidePage } from './src/main/ets/view/GuidePage' +export { LoginComp } from './src/main/ets/view/LoginComp' + +export { WebHeightPage } from './src/main/ets/view/WebHeightPage' + +export { LoginSetInfo } from './src/main/ets/view/LoginSetInfo' diff --git a/features/register/build-profile.json5 b/features/register/build-profile.json5 new file mode 100644 index 0000000..514585d --- /dev/null +++ b/features/register/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/features/register/consumer-rules.txt b/features/register/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/features/register/hvigorfile.ts b/features/register/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/features/register/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/features/register/obfuscation-rules.txt b/features/register/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/features/register/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/features/register/oh-package-lock.json5 b/features/register/oh-package-lock.json5 new file mode 100644 index 0000000..cc3bce5 --- /dev/null +++ b/features/register/oh-package-lock.json5 @@ -0,0 +1,18 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@itcast/basic@../../commons/basic": "@itcast/basic@../../commons/basic" + }, + "packages": { + "@itcast/basic@../../commons/basic": { + "name": "@itcast/basic", + "version": "1.0.0", + "resolved": "../../commons/basic", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/features/register/oh-package.json5 b/features/register/oh-package.json5 new file mode 100644 index 0000000..8a8ca3f --- /dev/null +++ b/features/register/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "register", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": { + "@itcast/basic": "file:../../commons/basic" + } +} diff --git a/features/register/src/main/ets/components/MainPage.ets b/features/register/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000..f12e5af --- /dev/null +++ b/features/register/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/features/register/src/main/ets/view/GuidePage.ets b/features/register/src/main/ets/view/GuidePage.ets new file mode 100644 index 0000000..0281eed --- /dev/null +++ b/features/register/src/main/ets/view/GuidePage.ets @@ -0,0 +1,46 @@ +import router from '@ohos.router' +@Entry +@Component +export struct GuidePage { + @State currentIndex: number = 0 // 当前页索引 + private swiperRef: SwiperController = new SwiperController() // Swiper控制器 + + // 图片资源路径数组 + private imageList: Resource[] = [ + $r('app.media.guide1'), // 路径对应resources/base/media目录 + $r('app.media.guide2'), + $r('app.media.guide3') + ] + + build() { + Stack({alignContent:Alignment.Bottom}) { // 使用堆叠布局实现按钮覆盖 + Swiper(this.swiperRef) { + ForEach(this.imageList, (item: Resource) => { + Image(item) + .objectFit(ImageFit.Cover) // 图片填充模式 + .width('100%') + .height('100%') + }, (item: Resource) => JSON.stringify(item)) + } + .indicator(false) // 隐藏默认指示器 + .loop(false) // 禁用循环滑动 + .onChange((index: number) => { + this.currentIndex = index + }) + // 只在最后一页显示按钮 + if (this.currentIndex === 2) { + Button('立即体验', { type: ButtonType.Capsule }) + .width(160) + .height(40) + .backgroundColor('#FFFFFF') + .fontColor('#8B2316') + .onClick(() => { + router.replaceUrl({ url: 'pages/LoginPage/LoginPage' }) + }) + .margin({bottom:30}) + } + } + .width('100%') + .height('100%') + } +} diff --git a/features/register/src/main/ets/view/LoginComp.ets b/features/register/src/main/ets/view/LoginComp.ets new file mode 100644 index 0000000..f78b0ca --- /dev/null +++ b/features/register/src/main/ets/view/LoginComp.ets @@ -0,0 +1,337 @@ +import { authStore, hdHttp, HdResponse,HdNav,BasicConstant, logger,LoginInfo,ChangeUtil } from '@itcast/basic' +import { promptAction, router } from '@kit.ArkUI' +import { BusinessError } from '@kit.BasicServicesKit'; +import HashMap from '@ohos.util.HashMap'; +import { DataWebModel,preferenceStore } from '@itcast/basic' +@Preview +@Component +export struct LoginComp { + @State + mobile: string = '13419527489' + @State + code: string = '123456a' + @State + current_code: string = '123456a' + @State + isAgree: boolean = false + @State + loading: boolean = false + @StorageProp('topHeight') + topHeight: number = 0 + @State + isPassLogin:boolean=false + + istime:boolean=false + time: number = 60 + timer: number | null = null + @State + timeText:string ='获取验证码' + @State + type:string ='账号密码登录' + + loginUrl:string=BasicConstant.urlmyLan+'umSmsLogin' + + hashMap: HashMap = new HashMap(); + + login() { + if (this.loading) return; + if (!this.mobile) { + return promptAction.showToast({ message: '手机号码不为空' }) + } + if (!ChangeUtil.isMobileNum(this.mobile)) { + return promptAction.showToast({ message: "手机号码不正确" }) + } + if(this.isPassLogin) + { + + if (!this.code) { + return promptAction.showToast({ message: '密码不为空' }) + } + if (!ChangeUtil.isPassword(this.code)) { + return promptAction.showToast({ message: "请输入6-16位字母、数字组合密码" }) + } + } + else + { + if (!this.current_code) { + return promptAction.showToast({ message: '请输入验证码' }) + } + } + + if (!this.isAgree) { + return promptAction.showToast({ message: '请勾选已阅读并同意' }) + } + this.loading = true + this.hashMap.clear(); + this.hashMap.set('mobile',this.mobile) + if(this.isPassLogin) + { + this.hashMap.set('password',this.code) + this.loginUrl=BasicConstant.urlmyLan+'login' + } + else + { + this.hashMap.set('sms',this.current_code) + this.loginUrl=BasicConstant.urlmyLan+'umSmsLogin' + } + this.hashMap.set('current_spec','hongmeng') + hdHttp.httpReq(this.loginUrl,this.hashMap).then(async (res: HdResponse) => { + this.loading = false + logger.info('Response login'+res); + console.info(`Response login succeeded: ${res}`); + let json:LoginInfo = JSON.parse(res+'') as LoginInfo; + + if(json.code=='1') + { + this.getSaveUserInfor(1,json) + } + else + { + promptAction.showToast({ message: json.message, duration: 1000 }) + } + + }).catch((err: BusinessError) => { + this.loading = false + console.info(`Response login fail: ${err}`); + }) + + } + getSaveUserInfor(type:number,objs:LoginInfo) + { + authStore.setUser(objs.data) + promptAction.showToast({ message: '登录成功', duration: 1000 }) + // emitter.emit({ eventId: 100401 }) + let state:number=objs.data.state + logger.info('Response state'+state); + if(state!=6) + { + router.pushUrl({ + url: 'pages/LoginPage/LoginSetInfoPage', // 目标url + }) + } + else + { + preferenceStore.setItemBoolean('isLogin',true) + router.replaceUrl({ + url: 'pages/Home', // 目标url + }) + } + + } + getMessage() + { + if (!this.mobile) { + return promptAction.showToast({ message: '手机号码不为空' }) + } + this.hashMap.clear(); + this.hashMap.set('mobile',this.mobile) + this.hashMap.set('type','7') + hdHttp.httpReq(BasicConstant.urlmyLan+'smsSend',this.hashMap).then(async (res: HdResponse) => { + }).catch((err: BusinessError) => { + this.loading = false + console.info(`Response login succeeded: ${err}`); + }) + } + build() { + Column() { + HdNav({ title: '登录', showRightIcon: false,showLeftIcon:false }) + + Image($r('app.media.icon_logo')) + .width(64) + .margin({top:45}) + .aspectRatio(1) + Text('专家版') + .fontSize(16) + .margin({ bottom: 15,top:10 }) + .fontColor($r('app.color.main_color')) + Column({ space: 15 }) { + Column() + { + Row() + { + Image($r('app.media.icon_mobile')) + .width(18) + .margin(5) + TextInput({ placeholder: '请输入手机号码', text: $$this.mobile }) + .customStyle() + } + Text().width('100%').height(0.8).backgroundColor('#CCCCCC') + if(this.isPassLogin) + { + Row() { + Image($r('app.media.icon_password')) + .width(18) + .margin(5) + TextInput({ placeholder: '请输入密码', text: $$this.code }) + .type(InputType.Password) + .passwordIcon({ onIconSrc:$r('app.media.icon_show_password'), offIconSrc: $r('app.media.icon_hidden_password') }) + .customStyle() + } + } + else + { + Row() { + Image($r('app.media.send_message')) + .width(18) + .margin(5) + TextInput({ placeholder: '请输入验证码', text: $$this.current_code }) + .customStyle() + .width(150) + Blank() + Text(this.timeText) + .width(100) + .height(27) + .borderRadius(12) + .textAlign(TextAlign.Center) + .fontSize(14) + .fontColor($r('app.color.top_title')) + .borderRadius(30) + .margin({right:15}) + .border({ width: 1, color: $r('app.color.top_title') }) + .onClick(() => { + + if(this.istime) + { + } + else + { + this.getMessage() + this.istime=true + this.startTime() + } + + }) + }.width('100%') + } + } + .borderRadius(5) + .border({ width: 1, color: '#CCCCCC' }) + Button({ type: ButtonType.Normal }) { + Row() { + if (this.loading) { + LoadingProgress() + .color($r('app.color.white')) + .width(24) + .height(24) + .margin({ right: 10 }) + } + Text('登录').fontColor($r('app.color.white')) + } + } + .width('100%') + .backgroundColor($r('app.color.top_title')) + .borderRadius(4) + .height(44) + .stateEffect(false) + .onClick(() => { + this.login() + }) + Text(this.type) + .fontSize(14) + .fontColor($r('app.color.top_title')) + .alignSelf(ItemAlign.Start) + .onClick(() => { + if(this.isPassLogin) + { + this.isPassLogin=false + this.type='账号密码登录' + } + else + { + this.isPassLogin=true + this.type='短信验证码登录' + } + + }) + Row() { + Checkbox() + .shape(CheckBoxShape.CIRCLE) + .selectedColor($r('app.color.top_title')) + .size({ width: 22, height: 22 }) + .select(this.isAgree) + .alignSelf((ItemAlign.Start)) + .onChange((val) => { + this.isAgree = val + }) + if(this.isPassLogin) + { + Text() { + Span('登录即代表同意').fontColor($r('app.color.common_gray_03')) + Span('《肝胆相照隐私政策》').fontColor($r('app.color.top_title')).onClick(() => { + this.ToWeb(BasicConstant.getyyzc,'《肝胆相照隐私政策》') + }) + Span('和').fontColor($r('app.color.common_gray_03')) + Span('《肝胆相照用户服务协议》').fontColor($r('app.color.top_title')) + .onClick(() => { + this.ToWeb(BasicConstant.getzcxy,'《肝胆相照用户服务协议》') + }) + + } + .fontSize(14) + .padding({ left: 4 ,right:20}) + } + else + { + + Text() { + Span('未注册的手机号验证登录后将自动创建肝胆相照账号,登录即代表同意').fontColor($r('app.color.common_gray_03')) + Span('《肝胆相照隐私政策》').fontColor($r('app.color.top_title')).onClick(() => { + this.ToWeb(BasicConstant.getyyzc,'《肝胆相照隐私政策》') + }) + Span('和').fontColor($r('app.color.common_gray_03')) + Span('《肝胆相照用户服务协议》').fontColor($r('app.color.top_title')) + .onClick(() => { + this.ToWeb(BasicConstant.getzcxy,'《肝胆相照用户服务协议》') + }) + + } + .fontSize(14) + .padding({ left: 4 ,right:20}) + + } + + + }.padding({bottom:20}).alignSelf(ItemAlign.End) + } + .height("100%") + .padding({ left: 20, right: 20, top: 30 }) + + } + } + startTime() { + this.time=60 + this.timer = setInterval(() => { + this.timeText=this.time+'s' + if (this.time <= 0) { + clearInterval(this.timer) + this.timeText='获取验证码' + this.istime=false + } + this.time-- + + }, 1000) + } + ToWeb(u:string,t:string) + { + let paramsInfo: DataWebModel = { + url:u , + title:t + + }; + router.pushUrl({ + url: 'pages/WebView/WebPage', // 目标url + params: paramsInfo // 添加params属性,传递自定义参数 + }) + } +} +@Extend(TextInput) +function customStyle() { + .placeholderColor('#C3C3C5') + .caretColor('#fa711d') + .height(45) + .borderRadius(0) + .backgroundColor($r('app.color.white')) + .margin({right:30}) +} + + diff --git a/features/register/src/main/ets/view/LoginSetInfo.ets b/features/register/src/main/ets/view/LoginSetInfo.ets new file mode 100644 index 0000000..2bd6da2 --- /dev/null +++ b/features/register/src/main/ets/view/LoginSetInfo.ets @@ -0,0 +1,179 @@ +import { HdNav,PromptActionClass } from '@itcast/basic' +import { ComponentContent } from '@kit.ArkUI'; +@Entry +@Preview +@Component +export struct LoginSetInfo{ + scroller: Scroller = new Scroller(); + @State + realName:string='' + @State + officePhone:string='' + @State + certificate:string='111111111' + @State titleName: string = "" + private ctx: UIContext = this.getUIContext(); + private contentNode: ComponentContent = + new ComponentContent(this.ctx, wrapBuilder(buildText),this.titleName); + aboutToAppear(): void { + PromptActionClass.setContext(this.ctx); + PromptActionClass.setContentNode(this.contentNode); + PromptActionClass.setOptions({ alignment: DialogAlignment.Bottom, offset: { dx: 0, dy: 0 } }); + } + build() { + Column() { + HdNav({ title: '完善个人资料', showRightIcon: false, showLeftIcon: true,showRightText:true,rightText:'保存' }) + Scroll(this.scroller) { + Column(){ + Row() + { + Text('头像').customStyle() + Blank() + Image($r('app.media.icon_touxiang_persion_ws')) + .width(45) + .height(45) + .borderRadius(6) + .margin({right:10}) + Image($r('app.media.arrow_right')).customStyleI() + }.customStyleR() + Row() + { + Text('姓名').customStyle() + Blank() + Text(){ + if(this.realName=='') + { + Span('请输入姓名').fontColor($r('app.color.common_gray_02')) + } + Span(this.realName).fontColor($r('app.color.common_gray_01')) + } + .customStyleT() + .onClick(() => { + PromptActionClass.openDialog() + this.titleName='请输入姓名' + this.contentNode.update({ title: this.titleName, field: this.currentField, currentValue: this.realName }) + }) + Image($r('app.media.arrow_right')).customStyleI() + }.customStyleR().margin({top:8}) + Row() + { + Text('科室电话').customStyle() + Blank() + Text(){ + if(this.officePhone=='') + { + Span('请输入所在科室的电话').fontColor($r('app.color.common_gray_02')) + + } + Span(this.officePhone).fontColor($r('app.color.common_gray_01')) + } + .customStyleT() + .onClick(() => { + PromptActionClass.openDialog() + this.titleName='请输入科室电话' + this.contentNode.update(this.titleName) + }) + Image($r('app.media.arrow_right')).customStyleI() + }.customStyleR().margin({top:8}) + Row() + { + Text('执业医师证编号').customStyle() + Blank() + Text(){ + if(this.certificate=='') + { + Span('请输入执业医师证编号').fontColor($r('app.color.common_gray_02')) + + } + Span(this.certificate).fontColor($r('app.color.common_gray_01')) + } + .customStyleT() + .onClick(() => { + PromptActionClass.openDialog() + this.titleName='请输入执业医师资格证号码' + this.contentNode.update(this.titleName) + }) + Image($r('app.media.arrow_right')).customStyleI() + }.customStyleR().margin({top:8}) + } + .width('100%') + .height('100%') + .backgroundImage($r('app.media.bg_reg')) + .backgroundImageSize(ImageSize.FILL) + } + .scrollable(ScrollDirection.Vertical) // 滚动方向为垂直方向 + .scrollBar(BarState.Off) // 滚动条常驻显示 + + + } + } + @State currentField: string = ''; // 记录当前编辑的字段 + +} +@Extend(Text) +function customStyle() { + .fontColor($r('app.color.common_gray_01')) + .height(48) + .fontSize(16) + .padding({left:15,top:10,bottom:10}) +} +@Extend(Text) +function customStyleT() { + .fontSize(13) + .margin({right:10}) + +} +@Extend(Image) +function customStyleI() { + .width(8) + .height(13) + .margin({right:15}) + +} +@Extend(Row) +function customStyleR() { + .width('100%') + .backgroundColor($r('app.color.white')) + +} + +@Builder +function buildText( title: string ) { + + Column() { + Row(){ + Text('取消') + .fontSize(14) + .fontColor($r('app.color.top_title')) + .margin({left:10}) + .onClick(() => { + // this.currentField='' + PromptActionClass.closeDialog() + }) + Blank() + Text(title) + .fontSize(16) + .fontColor($r('app.color.common_gray_01')) + Blank() + Text('确定') + .fontSize(14) + .fontColor($r('app.color.top_title')) + .margin({right:10}) + .onClick(() => { + PromptActionClass.closeDialog() + switch (title) + { + case '': + break + } + + }) + } .width('100%') + .padding(10) + .backgroundColor($r('app.color.top_bg')) + TextInput({ placeholder: '请输入', text: '' }) + .padding(10) + .backgroundColor($r('app.color.white')) + .borderRadius(0) + }.backgroundColor('#FFF0F0F0') +} diff --git a/features/register/src/main/ets/view/WebHeightPage.ets b/features/register/src/main/ets/view/WebHeightPage.ets new file mode 100644 index 0000000..4f4b1a9 --- /dev/null +++ b/features/register/src/main/ets/view/WebHeightPage.ets @@ -0,0 +1,49 @@ +import { webview } from '@kit.ArkWeb'; +import { HdNav } from '@itcast/basic' +import { router } from '@kit.ArkUI'; +import { DataWebModel } from '@itcast/basic' +@Entry +@Component +export struct WebHeightPage { + private webviewController: WebviewController = new webview.WebviewController() + private scroller: Scroller = new Scroller() + params: DataWebModel = router.getParams() as DataWebModel; // 获取传递过来的参数对象 + url: string = this.params.url // 获取id属性的值 + title: string = this.params.title // 获取age属性的值 + + // 三方应用相关信息标识 + customUserAgent: string = 'gdxz-expert'; + + build() { + Column() { + HdNav({ title: this.title, showRightIcon: false,showLeftIcon:true }) + // Scroll(this.scroller) { + Column() { + Web({ + src: this.url, + controller: this.webviewController, + renderMode: RenderMode.SYNC_RENDER // 设置为同步渲染模式 + }) + .mixedMode(MixedMode.All) + // .layoutMode(WebLayoutMode.FIT_CONTENT) // 设置为Web组件大小自适应页面内容 + // .overScrollMode(OverScrollMode.NEVER) // 设置过滚动模式为关闭状态 + .domStorageAccess(true) + .onControllerAttached(() => { + + let userAgent = this.webviewController.getUserAgent() + this.customUserAgent; + this.webviewController.setCustomUserAgent(userAgent); + }) + // Text("") + // .fontSize(28) + // .fontColor("#FFFFFF") + // .height(100) + // .width("100%") + // .backgroundColor("#FFFFFF") + + } + } + + } + + // } +} \ No newline at end of file diff --git a/features/register/src/main/module.json5 b/features/register/src/main/module.json5 new file mode 100644 index 0000000..32516e7 --- /dev/null +++ b/features/register/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "register", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/features/register/src/main/resources/base/element/float.json b/features/register/src/main/resources/base/element/float.json new file mode 100644 index 0000000..33ea223 --- /dev/null +++ b/features/register/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/features/register/src/main/resources/base/element/string.json b/features/register/src/main/resources/base/element/string.json new file mode 100644 index 0000000..f51a9c8 --- /dev/null +++ b/features/register/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/features/register/src/main/resources/base/media/arrow_right.png b/features/register/src/main/resources/base/media/arrow_right.png new file mode 100644 index 0000000..2251fc2 Binary files /dev/null and b/features/register/src/main/resources/base/media/arrow_right.png differ diff --git a/features/register/src/main/resources/base/media/bg_reg.png b/features/register/src/main/resources/base/media/bg_reg.png new file mode 100644 index 0000000..47311b4 Binary files /dev/null and b/features/register/src/main/resources/base/media/bg_reg.png differ diff --git a/features/register/src/main/resources/base/media/clocked_bg.png b/features/register/src/main/resources/base/media/clocked_bg.png new file mode 100644 index 0000000..1897d5b Binary files /dev/null and b/features/register/src/main/resources/base/media/clocked_bg.png differ diff --git a/features/register/src/main/resources/base/media/guide1.jpg b/features/register/src/main/resources/base/media/guide1.jpg new file mode 100644 index 0000000..40333c2 Binary files /dev/null and b/features/register/src/main/resources/base/media/guide1.jpg differ diff --git a/features/register/src/main/resources/base/media/guide2.jpg b/features/register/src/main/resources/base/media/guide2.jpg new file mode 100644 index 0000000..ec080d2 Binary files /dev/null and b/features/register/src/main/resources/base/media/guide2.jpg differ diff --git a/features/register/src/main/resources/base/media/guide3.jpg b/features/register/src/main/resources/base/media/guide3.jpg new file mode 100644 index 0000000..08819b7 Binary files /dev/null and b/features/register/src/main/resources/base/media/guide3.jpg differ diff --git a/features/register/src/main/resources/base/media/icon_hidden_password.png b/features/register/src/main/resources/base/media/icon_hidden_password.png new file mode 100644 index 0000000..3e9ac96 Binary files /dev/null and b/features/register/src/main/resources/base/media/icon_hidden_password.png differ diff --git a/features/register/src/main/resources/base/media/icon_logo.png b/features/register/src/main/resources/base/media/icon_logo.png new file mode 100644 index 0000000..0f5f466 Binary files /dev/null and b/features/register/src/main/resources/base/media/icon_logo.png differ diff --git a/features/register/src/main/resources/base/media/icon_mobile.png b/features/register/src/main/resources/base/media/icon_mobile.png new file mode 100644 index 0000000..50fcaab Binary files /dev/null and b/features/register/src/main/resources/base/media/icon_mobile.png differ diff --git a/features/register/src/main/resources/base/media/icon_password.png b/features/register/src/main/resources/base/media/icon_password.png new file mode 100644 index 0000000..f1367c1 Binary files /dev/null and b/features/register/src/main/resources/base/media/icon_password.png differ diff --git a/features/register/src/main/resources/base/media/icon_show_password.png b/features/register/src/main/resources/base/media/icon_show_password.png new file mode 100644 index 0000000..ae5aa59 Binary files /dev/null and b/features/register/src/main/resources/base/media/icon_show_password.png differ diff --git a/features/register/src/main/resources/base/media/icon_touxiang_persion_ws.png b/features/register/src/main/resources/base/media/icon_touxiang_persion_ws.png new file mode 100644 index 0000000..3f955be Binary files /dev/null and b/features/register/src/main/resources/base/media/icon_touxiang_persion_ws.png differ diff --git a/features/register/src/main/resources/base/media/send_message.png b/features/register/src/main/resources/base/media/send_message.png new file mode 100644 index 0000000..2c68be1 Binary files /dev/null and b/features/register/src/main/resources/base/media/send_message.png differ diff --git a/features/register/src/ohosTest/ets/test/Ability.test.ets b/features/register/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/features/register/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/features/register/src/ohosTest/ets/test/List.test.ets b/features/register/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..794c7dc --- /dev/null +++ b/features/register/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/features/register/src/ohosTest/module.json5 b/features/register/src/ohosTest/module.json5 new file mode 100644 index 0000000..68629ee --- /dev/null +++ b/features/register/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "register_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/features/register/src/test/List.test.ets b/features/register/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/features/register/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/features/register/src/test/LocalUnit.test.ets b/features/register/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/features/register/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 new file mode 100644 index 0000000..c7c1843 --- /dev/null +++ b/hvigor/hvigor-config.json5 @@ -0,0 +1,25 @@ +{ + "modelVersion": "5.0.2", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + }, + "debugging": { + "stacktrace": true /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + } +} diff --git a/hvigorfile.ts b/hvigorfile.ts new file mode 100644 index 0000000..f3cb9f1 --- /dev/null +++ b/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/local.properties b/local.properties new file mode 100644 index 0000000..20f6086 --- /dev/null +++ b/local.properties @@ -0,0 +1,9 @@ +# This file is automatically generated by DevEco Studio. +# Do not modify this file -- YOUR CHANGES WILL BE ERASED! +# +# This file should *NOT* be checked into Version Control Systems, +# as it contains information specific to your local configuration. +# +# For customization when using a Version Control System, please read the header note. + + diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 new file mode 100644 index 0000000..f18e42c --- /dev/null +++ b/oh-package-lock.json5 @@ -0,0 +1,35 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/crypto-js@^2.0.4": "@ohos/crypto-js@2.0.4", + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@ohos/crypto-js@2.0.4": { + "name": "@ohos/crypto-js", + "version": "2.0.4", + "integrity": "sha512-589ur6oqU1UNibqefMly2cwEeEhkSoCAA3uc+oNUwRnYYtevn/kQnO+Coi36N+VJSeeg/uFzZk1K/wUMdovpOA==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/crypto-js/-/crypto-js-2.0.4.har", + "registryType": "ohpm" + }, + "@ohos/hamock@1.0.0": { + "name": "@ohos/hamock", + "version": "1.0.0", + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hamock/-/hamock-1.0.0.har", + "registryType": "ohpm" + }, + "@ohos/hypium@1.0.21": { + "name": "@ohos/hypium", + "version": "1.0.21", + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.21.har", + "registryType": "ohpm" + } + } +} \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 new file mode 100644 index 0000000..36b2fe4 --- /dev/null +++ b/oh-package.json5 @@ -0,0 +1,12 @@ +{ + "modelVersion": "5.0.2", + "description": "Please describe the basic information.", + "dependencies": { + "@ohos/crypto-js": "^2.0.4" + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + }, + "dynamicDependencies": {} +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/CHANGELOG.md b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/CHANGELOG.md new file mode 100644 index 0000000..43a1f49 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/CHANGELOG.md @@ -0,0 +1,108 @@ +## v2.0.4 +- 添加index.d.ts声明文件 +- 优化_doCryptBlock方法,还原为源库的二阶数组写法 +- 在DevEco Studio: NEXT Beta1-5.0.3.806, SDK:API12 Release(5.0.0.66)上验证通过 + +## v2.0.4-rc.1 +- 添加index.d.ts声明文件 + +## v2.0.4-rc.0 +- 优化_doCryptBlock方法,还原为源库的二阶数组写法 + +## v2.0.3 +- 适配源库4.2.0版本,更改PBKDF2的默认哈希算法和迭代,以通过使用默认配置来防止弱安全性。 +- 支持blowfish加密 +- 修复不兼容API9问题 +- 优化hasOwn方法 + +## v2.0.3-rc.1 +- 适配源库4.2.0版本,更改PBKDF2的默认哈希算法和迭代,以通过使用默认配置来防止弱安全性。 +- 支持blowfish加密 + +## v2.0.3-rc.0 +- 修复不兼容API9问题 + +## v2.0.2 +- ArkTs语法规则整改 + +## v2.0.1 +- 支持export default和export两种引入方式 +- 适配DevEco Studio: 4.0 Canary1(4.0.3.212) +- 适配SDK: API 10 Release(4.0.8.3) + +## v2.0.0 +- 包管理工具由npm切换为ohpm +- 适配DevEco Studio: 3.1 Beta2(3.1.0.400) +- 适配SDK: API9 Release(3.2.11.9) + +## v1.0.6 + +1. 完善DevEco Studio 3.1 Beta1及以上版本适配 +2. 去掉polyfill接口,采用原生sdk接口 + +## v1.0.5 + +1. 适配DevEco Studio 3.1 Beta1及以上版本 + +## v1.0.4 + +1. 修复加解密不可逆的问题 + +## v1.0.3 + +1. 修复加密算法中特殊字符以及中文字符加密错误的问题 + +## v1.0.2 + +1. 适配API9 + +2. 直接引用源库使用,删除本库的绝大部分逻辑,仅将客制化的部分抽出作为lib + +## v1.0.1 + +- 已实现功能 + 1. sha224 + 2. sha384 + 3. sha3 + 4. hmac-sha224 + 5. hmac-sha384 + 6. hmac-sha3 + 7. pbkdf2 + 8. aes + 9. tripledes + 10. rc4 + 11. rabbit + 12. rabbit-legacy + 13. evpkdf + 14. format-openssl + 15. format-hex + 16. enc-latin1 + 17. enc-utf8 + 18. enc-hex + 19. enc-utf16 + 20. enc-base64 + 21. mode-cfb + 22. mode-ctr + 23. mode-ctr-gladman + 24. mode-ofb + 25. mode-ecb + 26. pad-pkcs7 + 27. pad-ansix923 + 28. pad-iso10126 + 29. pad-iso97971 + 30. pad-zeropadding + 31. pad-nopadding + +## v1.0.0 + +- 已实现功能 + 1. md5 + 2. sha1 + 3. sha256 + 4. sha512 + 5. ripemd160 + 6. hmac-md5 + 7. hmac-sha1 + 8. hmac-sha256 + 9. hmac-sha512 + 10. hmac-ripemd160 \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/LICENSE b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/LICENSE new file mode 100644 index 0000000..396257f --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/LICENSE @@ -0,0 +1,24 @@ +# License + +[The MIT License (MIT)](http://opensource.org/licenses/MIT) + +Copyright (c) 2009-2013 Jeff Mott +Copyright (c) 2013-2016 Evan Vosberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/NOTICE b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/NOTICE new file mode 100644 index 0000000..995eff5 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/NOTICE @@ -0,0 +1,35 @@ +OPEN SOURCE SOFTWARE NOTICE + +Please note we provide an open source software notice for the third party open source software along with this software and/or this software component (in the following just “this SOFTWARE”). The open source software licenses are granted by the respective right holders. + +Warranty Disclaimer +THE OPEN SOURCE SOFTWARE IN THIS PRODUCT IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE APPLICABLE LICENSES FOR MORE DETAILS. + +Copyright Notice and License Texts + +---------------------------------------------------------------------- +Software: crypto-js 4.1.1 + +Copyright notice: +[The MIT License (MIT)](http://opensource.org/licenses/MIT) + +Copyright (c) 2009-2013 Jeff Mott +Copyright (c) 2013-2016 Evan Vosberg + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/README.OpenSource b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/README.OpenSource new file mode 100644 index 0000000..ba39e1c --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/README.OpenSource @@ -0,0 +1,21 @@ +[ + { + "Name": "crypto-js", + "License": "MIT", + "License File": " LICENSE ", + "Version Number": "4.1.1", + "Owner" : "xiafeng@huawei.com", + "Upstream URL": "https://github.com/brix/crypto-js", + "Description": "JavaScript library of crypto standards" + }, + + { + "Name": "DefinitelyTyped", + "License": "MIT", + "License File": " LICENSE ", + "Version Number": "4.2.2", + "Owner" : "xiafeng@huawei.com", + "Upstream URL": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/crypto-js", + "Description": "The repository for high quality TypeScript type definitions." + }, +] \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/README.md b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/README.md new file mode 100644 index 0000000..4f53641 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/README.md @@ -0,0 +1,153 @@ +# crypto-js + +## 简介 + 本软件是移植开源软件 [crypto-js](https://github.com/brix/crypto-js) 源码在OpenHarmony上进行功能适配,在OpenHarmony上已支持原库crypto-js的功能,目前crypto-js已支持的算法有:MD5、SHA-1、SHA-256、HMAC、HMAC-MD5、HMAC-SHA1、HMAC-SHA256、PBKDF2、AES、RC4、DES等。 + +![preview.gif](preview/preview.gif) + +## 下载安装 +```shell +ohpm install @ohos/crypto-js +``` +OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmony ohpm 包](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md) +## 使用说明 +1. 引入依赖 + ``` +最新版本支持 + import { CryptoJS } from '@ohos/crypto-js' 或者 + import CryptoJS from '@ohos/crypto-js' + ``` +2. md5算法使用 + + md5信息摘要算法(英语:md5 Message-Digest Algorithm),一种被广泛使用的密码散列函数,可以产生出一个128位(16字节)的散列值(hash value),用于确保信息传输完整一致。 + + md5特点: + 1. 不可逆性 --- 根据 MD5 值计算不出原始数据 + 2. 唯一性 --- 不同原始数据会有不同的 MD5 值 + + md5算法在本库的使用: + ``` + //第一步在需要使用到的页面,导入CryptoJS + import { CryptoJS } from '@ohos/crypto-js' + //第二步在需要使用到md5的业务逻辑,调用md5算法 + var hash = CryptoJS.MD5("123456") //传参是需要加密的内容,返回值是加密后的数据 + ``` +3. aes算法使用 + + AES算法全称Advanced Encryption Standard,又称Rijndael加密法,是美国联邦政府采用的一种区块加密标准。 + + AES是对称加密,所以加密解密都需要用到同一个秘钥。 + + AES算法在本库的使用: + ``` + //第一步在需要使用到的页面,导入CryptoJS + import { CryptoJS } from '@ohos/crypto-js' + //第二步定义加密解密需要用到的key + var key = 'secret key 1234' + //第三步在需要使用AES加密的业务逻辑,调用AES加密 + var encrypted = CryptoJS.AES.encrypt('hello world', key).toString() //传参为加密内容及秘钥 + //第四步在需要把上面的加密块解密的业务逻辑,调用AES解密,注意key必须相同 + var decrypted = CryptoJS.AES.decrypt(encrypted, key) //传参为加密后的内容及秘钥 + ``` +其他加密算法使用方式,如sha1、sha256、sha224、sha512、sha384、sha3、ripemd160、hmac-md5、hmac-sha1、hmac-sha256、hmac-sha224、hmac-sha512、hmac-sha384、hmac-sha3、hmac-ripemd160 +、pbkdf2、aes、tripledes、rc4、rabbit、rabbit-legacy、evpkdf、des、triple-des、format-openssl、format-hex、enc-latin1、enc-utf8、enc-hex、enc-utf16、enc-base64、 +mode-cfb、mode-ctr、mode-ctr-gladman、mode-ofb、mode-ecb、pad-pkcs7、pad-ansix923、pad-iso10126、pad-iso97971、pad-zeropadding、pad-nopadding。 + +更多使用方法请参照 [demo](https://gitee.com/openharmony-sig/crypto-js/blob/master/entry/src/main/ets/pages/Index.ets) 和 [XTS](https://gitee.com/openharmony-sig/crypto-js/tree/master/entry/src/ohosTest/ets/test) 及 [参考原库使用文档](https://cryptojs.gitbook.io/docs/) + + +## 接口列表 + +- `crypto-js/md5` +- `crypto-js/sha1` +- `crypto-js/sha256` +- `crypto-js/sha224` +- `crypto-js/sha512` +- `crypto-js/sha384` +- `crypto-js/sha3` +- `crypto-js/ripemd160` +------ + +- `crypto-js/hmac-md5` +- `crypto-js/hmac-sha1` +- `crypto-js/hmac-sha256` +- `crypto-js/hmac-sha224` +- `crypto-js/hmac-sha512` +- `crypto-js/hmac-sha384` +- `crypto-js/hmac-sha3` +- `crypto-js/hmac-ripemd160` + +------ + +- `crypto-js/pbkdf2` + +------ + +- `crypto-js/aes` +- `crypto-js/tripledes` +- `crypto-js/rc4` +- `crypto-js/rabbit` +- `crypto-js/rabbit-legacy` +- `crypto-js/evpkdf` +- `crypto-js/des` +- `crypto-js/triple-des` + +------ + +- `crypto-js/format-openssl` +- `crypto-js/format-hex` + +------ + +- `crypto-js/enc-latin1` +- `crypto-js/enc-utf8` +- `crypto-js/enc-hex` +- `crypto-js/enc-utf16` +- `crypto-js/enc-base64` + +------ + +- `crypto-js/mode-cfb` +- `crypto-js/mode-ctr` +- `crypto-js/mode-ctr-gladman` +- `crypto-js/mode-ofb` +- `crypto-js/mode-ecb` + +------ + +- `crypto-js/pad-pkcs7` +- `crypto-js/pad-ansix923` +- `crypto-js/pad-iso10126` +- `crypto-js/pad-iso97971` +- `crypto-js/pad-zeropadding` +- `crypto-js/pad-nopadding` + +## 约束与限制 + +在下述版本验证通过: +- DevEco Studio: NEXT Beta1-5.0.3.806, SDK:API12 Release(5.0.0.66) +- DevEco Studio : 5.0.3.122, SDK: API12 (5.0.0.17) +- DevEco Studio : 4.1.3.600, SDK: API11 (4.1.0.67) + +## 目录结构 +```` +|---- crypto-js +| |---- entry # 示例代码文件夹 +| |---- crypto # crypto-js库文件夹 +| |---- index.ts # 对外接口 +| |---- src +| |---- main +| |---- ets +| |---- components +| |---- crypto.ts # 加密封装类 +| |---- README.md # 安装使用方法 +```` + +## 贡献代码 +使用过程中发现任何问题都可以提 [Issue](https://gitee.com/openharmony-sig/crypto-js/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://gitee.com/openharmony-sig/crypto-js/pulls) 。 + +## 开源协议 +本项目基于 [MIT License](https://gitee.com/openharmony-sig/crypto-js/blob/master/LICENSE) ,请自由地享受和参与开源。 + +## 遗留问题 +- pbkdf2算法性能问题 \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/ResourceTable.txt b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/ResourceTable.txt new file mode 100644 index 0000000..d159750 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/ResourceTable.txt @@ -0,0 +1 @@ +string page_show 0x02000000 \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/build-profile.json5 b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/build-profile.json5 new file mode 100644 index 0000000..fb1e371 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/build-profile.json5 @@ -0,0 +1,10 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/hvigorfile.ts b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/hvigorfile.ts new file mode 100644 index 0000000..ec0ed33 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/hvigorfile.ts @@ -0,0 +1,2 @@ +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/index.d.ts b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/index.d.ts new file mode 100644 index 0000000..3e8fe5f --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/index.d.ts @@ -0,0 +1,1802 @@ +export default CryptoJS; + +export { CryptoJS }; + +type WordArray = CryptoJS.lib.WordArray; +type CipherParams = CryptoJS.lib.CipherParams; +type X64Word = CryptoJS.x64.Word; + +declare global { + namespace CryptoJS { + /** + * Library namespace. + */ + export namespace lib { + /** + * Base object for prototypal inheritance. + */ + const Base: { + /** + * Creates a new object that inherits from this object. + * + * @param overrides Properties to copy into the new object. + * + * @return The new object. + * + * @example + * + * var MyType = CryptoJS.lib.Base.extend({ + * field: 'value', + * + * method: function () { + * } + * }); + */ + extend(overrides: object): any; + + /** + * Extends this object and runs the init method. + * Arguments to create() will be passed to init(). + * + * @return The new object. + * + * @example + * + * var instance = MyType.create(); + */ + create(...args: any[]): any; + + /** + * Copies properties into this object. + * + * @param properties The properties to mix in. + * + * @example + * + * MyType.mixIn({ + * field: 'value' + * }); + */ + mixIn(properties: object): any; + }; + + /** + * An array of 32-bit words. + */ + interface WordArray { + /** + * The array of 32-bit words. + */ + words: number[]; + /** + * The number of significant bytes in this word array. + */ + sigBytes: number; + /** + * Converts this word array to a string. + * + * @param encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex + * + * @return The stringified word array. + * + * @example + * + * var string = wordArray + ''; + * var string = wordArray.toString(); + * var string = wordArray.toString(CryptoJS.enc.Utf8); + */ + toString(encoder?: Encoder): string; + + /** + * Concatenates a word array to this word array. + * + * @param wordArray The word array to append. + * + * @return This word array. + * + * @example + * + * wordArray1.concat(wordArray2); + */ + concat(wordArray: WordArray): this; + + /** + * Removes insignificant bits. + * + * @example + * + * wordArray.clamp(); + */ + clamp(): void; + + /** + * Creates a copy of this word array. + * + * @return The clone. + * + * @example + * + * var clone = wordArray.clone(); + */ + clone(): WordArray; + } + const WordArray: { + /** + * Initializes a newly created word array. + * + * @param words (Optional) An array of 32-bit words. + * @param sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.create(); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); + */ + create( + words?: + | number[] + | ArrayBuffer + | Uint8Array + | Int8Array + | Uint8ClampedArray + | Int16Array + | Uint16Array + | Int32Array + | Uint32Array + | Float32Array + | Float64Array + | object[], + sigBytes?: number, + ): WordArray; + /** + * Creates a word array filled with random bytes. + * + * @param nBytes The number of random bytes to generate. + * + * @return The random word array. + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.random(16); + */ + random(nBytes: number): WordArray; + }; + + const BufferedBlockAlgorithm: any; + + const Hasher: { + /** + * Creates a shortcut function to a hasher's object interface. + * + * @param hasher The hasher to create a helper for. + * + * @return The shortcut function. + * + * @example + * + * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + */ + _createHelper(hasher: HasherStatic): HasherHelper; + /** + * Creates a shortcut function to the HMAC's object interface. + * + * @param hasher The hasher to use in this HMAC helper. + * + * @return The shortcut function. + * + * @example + * + * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + */ + _createHmacHelper(hasher: HasherStatic): HmacHasherHelper; + }; + + const Cipher: { + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param cipher The cipher to create a helper for. + * + * @return An object with encrypt and decrypt shortcut functions. + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper(cipher: Cipher): CipherHelper; + }; + + /** + * A collection of cipher parameters. + */ + interface CipherParams { + /** + * The raw ciphertext. + */ + ciphertext: WordArray; + /** + * The key to this ciphertext. + */ + key: WordArray; + /** + * The IV used in the ciphering operation. + */ + iv: WordArray; + /** + * The salt used with a key derivation function. + */ + salt: WordArray; + /** + * The cipher algorithm. + */ + algorithm: CipherStatic; + /** + * The block mode used in the ciphering operation. + */ + mode: Mode; + /** + * The padding scheme used in the ciphering operation. + */ + padding: Padding; + /** + * The block size of the cipher. + */ + blockSize: number; + /** + * The default formatting strategy to convert this cipher params object to a string. + */ + formatter: Format; + /** + * Converts this cipher params object to a string. + * + * @param formatter (Optional) The formatting strategy to use. + * + * @return The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString(formatter?: Format): string; + } + const CipherParams: { + /** + * Initializes a newly created cipher params object. + * + * @param cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + create(cipherParams: Partial | object): CipherParams; + }; + + /** + * Abstract base stream cipher template. + */ + interface StreamCipher extends Cipher { + /** + * The number of 32-bit words this cipher operates on. Default: 1 (32 bits) + */ + blockSize: number; + } + + /** + * Abstract base block cipher mode template. + */ + const BlockCipherMode: any; + + /** + * A cipher wrapper that returns ciphertext as a serializable cipher params object. + */ + const SerializableCipher: { + /** + * Encrypts a message. + * + * @param cipher The cipher algorithm to use. + * @param message The message to encrypt. + * @param key The key. + * @param cfg (Optional) The configuration options to use for this operation. + * + * @return A cipher params object. + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt( + cipher: CipherStatic, + message: WordArray | string, + key: WordArray, + cfg?: CipherOption, + ): CipherParams; + + /** + * Decrypts serialized ciphertext. + * + * @param cipher The cipher algorithm to use. + * @param ciphertext The ciphertext to decrypt. + * @param key The key. + * @param cfg (Optional) The configuration options to use for this operation. + * + * @return The plaintext. + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt( + cipher: CipherStatic, + ciphertext: WordArray | string, + key: WordArray, + cfg?: CipherOption, + ): CipherParams; + + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param ciphertext The ciphertext. + * @param format The formatting strategy to use to parse serialized ciphertext. + * + * @return The unserialized ciphertext. + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); + */ + _parse(ciphertext: CipherParams | string, format: Format): CipherParams; + }; + + /** + * A serializable cipher wrapper that derives the key from a password, + * and returns ciphertext as a serializable cipher params object. + */ + const PasswordBasedCipher: { + /** + * Encrypts a message using a password. + * + * @param cipher The cipher algorithm to use. + * @param message The message to encrypt. + * @param password The password. + * @param cfg (Optional) The configuration options to use for this operation. + * + * @return A cipher params object. + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + encrypt( + cipher: CipherStatic, + message: WordArray | string, + password: string, + cfg?: CipherOption, + ): CipherParams; + + /** + * Decrypts serialized ciphertext using a password. + * + * @param cipher The cipher algorithm to use. + * @param ciphertext The ciphertext to decrypt. + * @param password The password. + * @param cfg (Optional) The configuration options to use for this operation. + * + * @return The plaintext. + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); + */ + decrypt( + cipher: CipherStatic, + ciphertext: CipherParams | string, + password: string, + cfg?: CipherOption, + ): WordArray; + }; + } + /** + * Padding namespace. + */ + export namespace pad { + /** + * PKCS #5/7 padding strategy. + */ + const Pkcs7: Padding; + + /** + * ANSI X.923 padding strategy. + */ + const AnsiX923: Padding; + + /** + * ISO 10126 padding strategy. + */ + const Iso10126: Padding; + + /** + * ISO/IEC 9797-1 Padding Method 2. + */ + const Iso97971: Padding; + + /** + * Zero padding strategy. + */ + const ZeroPadding: Padding; + + /** + * A noop padding strategy. + */ + const NoPadding: Padding; + } + + /** + * Key derivation function namespace. + */ + export namespace kdf { + /** + * OpenSSL key derivation function. + */ + const OpenSSL: { + /** + * Derives a key and IV from a password. + * + * @param password The password to derive from. + * @param keySize The size in words of the key to generate. + * @param ivSize The size in words of the IV to generate. + * @param salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return A cipher params object with the key, IV, and salt. + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute( + password: string, + keySize: number, + ivSize: number, + salt?: WordArray | string, + hasher?: Hasher, + ): CipherParams; + }; + } + + /** + * Mode namespace. + */ + export namespace mode { + /** + * Cipher Block Chaining mode. + */ + const CBC: BlockCipherMode; + + /** + * Cipher Feedback block mode. + */ + const CFB: BlockCipherMode; + /** + * Counter block mode. + */ + const CTR: BlockCipherMode; + /** + * @preserve + * Counter block mode compatible with Dr Brian Gladman fileenc.c + * derived from CryptoJS.mode.CTR + * Jan Hruby jhruby.web@gmail.com + */ + const CTRGladman: BlockCipherMode; + /** + * Output Feedback block mode. + */ + const OFB: BlockCipherMode; + + /** + * Electronic Codebook block mode. + */ + const ECB: BlockCipherMode; + } + + /** + * Format namespace. + */ + export namespace format { + /** + * OpenSSL formatting strategy. + */ + const OpenSSL: Format; + const Hex: Format; + } + + /** + * Encoder namespace. + */ + export namespace enc { + /** + * Hex encoding strategy. + */ + const Hex: Encoder; + /** + * Latin1 encoding strategy. + */ + const Latin1: Encoder; + /** + * UTF-8 encoding strategy. + */ + const Utf8: Encoder; + /** + * UTF-16 BE encoding strategy. + */ + const Utf16: Encoder; + const Utf16BE: Encoder; + + /** + * UTF-16 LE encoding strategy. + */ + const Utf16LE: Encoder; + /** + * Base64 encoding strategy. + */ + const Base64: Encoder; + /** + * Base64url encoding strategy. + */ + const Base64url: Encoder; + } + + /** + * Algorithm namespace. + */ + export namespace algo { + /** + * MD5 hash algorithm. + */ + const MD5: HasherStatic; + + /** + * SHA-1 hash algorithm. + */ + const SHA1: HasherStatic; + + /** + * SHA-256 hash algorithm. + */ + const SHA256: HasherStatic; + /** + * SHA-224 hash algorithm. + */ + const SHA224: HasherStatic; + /** + * SHA-512 hash algorithm. + */ + const SHA512: HasherStatic; + + /** + * SHA-384 hash algorithm. + */ + const SHA384: HasherStatic; + /** + * SHA-3 hash algorithm. + */ + const SHA3: HasherStatic; + /** + * RIPEMD160 hash algorithm. + */ + const RIPEMD160: HasherStatic; + /** + * HMAC algorithm. + */ + abstract class HMAC { + /** + * Initializes a newly created HMAC. + * + * @param hasher The hash algorithm to use. + * @param key The secret key. + * + * @example + * + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + */ + static create(hasher: HasherStatic, key: WordArray | string): HMAC; + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset(): void; + + /** + * Updates this HMAC with a message. + * + * @param messageUpdate The message to append. + * + * @return This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update(messageUpdate: WordArray | string): this; + + /** + * Finalizes the HMAC computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param messageUpdate (Optional) A final message update. + * + * @return The HMAC. + * + * @example + * + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); + */ + finalize(messageUpdate?: WordArray | string): WordArray; + } + /** + * Password-Based Key Derivation Function 2 algorithm. + */ + abstract class PBKDF2 { + /** + * Initializes a newly created key derivation function. + * + * @param cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.PBKDF2.create(); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 }); + */ + static create(cfg?: KDFOption): PBKDF2; + + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param password The password. + * @param salt A salt. + * + * @return The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute(password: WordArray | string, salt: WordArray|string): WordArray; + } + /** + * This key derivation function is meant to conform with EVP_BytesToKey. + * www.openssl.org/docs/crypto/EVP_BytesToKey.html + */ + abstract class EvpKDF { + /** + * Initializes a newly created key derivation function. + * + * @param cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.EvpKDF.create(); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + */ + static create(cfg?: { keySize: number; hasher?: HasherStatic | undefined; iterations?: number }): EvpKDF; + + /** + * Derives a key from a password. + * + * @param password The password. + * @param salt A salt. + * + * @return The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute(password: WordArray | string, salt: WordArray|string): WordArray; + } + + /** + * AES block cipher algorithm. + */ + const AES: CipherStatic; + + /** + * DES block cipher algorithm. + */ + const DES: CipherStatic; + + /** + * Triple-DES block cipher algorithm. + */ + const TripleDES: CipherStatic; + + /** + * RC4 stream cipher algorithm. + */ + const RC4: CipherStatic; + + /** + * Modified RC4 stream cipher algorithm. + */ + const RC4Drop: CipherStatic; + + /** + * Rabbit stream cipher algorithm + */ + const Rabbit: CipherStatic; + + /** + * Rabbit stream cipher algorithm. + * + * This is a legacy version that neglected to convert the key to little-endian. + * This error doesn't affect the cipher's security, + * but it does affect its compatibility with other implementations. + */ + const RabbitLegacy: CipherStatic; + } + + /** + * x64 namespace. + */ + export namespace x64 { + /** + * A 64-bit word. + */ + interface Word { + /** + * Bitwise NOTs this word. + * + * @return A new x64-Word object after negating. + * + * @example + * + * var negated = x64Word.not(); + */ + not(): X64Word; + /** + * Bitwise ANDs this word with the passed word. + * + * @param word The x64-Word to AND with this word. + * + * @return A new x64-Word object after ANDing. + * + * @example + * + * var anded = x64Word.and(anotherX64Word); + */ + and(word: X64Word): X64Word; + + /** + * Bitwise ORs this word with the passed word. + * + * @param word The x64-Word to OR with this word. + * + * @return A new x64-Word object after ORing. + * + * @example + * + * var ored = x64Word.or(anotherX64Word); + */ + or(word: X64Word): X64Word; + + /** + * Bitwise XORs this word with the passed word. + * + * @param word The x64-Word to XOR with this word. + * + * @return A new x64-Word object after XORing. + * + * @example + * + * var xored = x64Word.xor(anotherX64Word); + */ + xor(word: X64Word): X64Word; + /** + * Shifts this word n bits to the left. + * + * @param n The number of bits to shift. + * + * @return A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftL(25); + */ + shiftL(n: number): X64Word; + /** + * Shifts this word n bits to the right. + * + * @param n The number of bits to shift. + * + * @return A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftR(7); + */ + shiftR(n: number): X64Word; + /** + * Rotates this word n bits to the left. + * + * @param n The number of bits to rotate. + * + * @return A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotL(25); + */ + rotL(n: number): X64Word; + + /** + * Rotates this word n bits to the right. + * + * @param n The number of bits to rotate. + * + * @return A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotR(7); + */ + rotR(n: number): X64Word; + /** + * Adds this word with the passed word. + * + * @param word The x64-Word to add with this word. + * + * @return A new x64-Word object after adding. + * + * @example + * + * var added = x64Word.add(anotherX64Word); + */ + add(word: X64Word): X64Word; + /** + * Initializes a newly created 64-bit word. + * + * @param {number} high The high 32 bits. + * + */ + high?:number + /** + * Initializes a newly created 64-bit word. + * + * @param {number} low The low 32 bits. + * + */ + low?:number + } + + const Word: { + /** + * Initializes a newly created 64-bit word. + * + * @param high The high 32 bits. + * @param low The low 32 bits. + * + * @example + * + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + */ + create(high: number, low: number): X64Word ; + }; + + /** + * Initializes a newly created word array. + * + * @param words (Optional) An array of CryptoJS.x64.Word objects. + * @param sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.x64.WordArray.create(); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ]); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ], 10); + */ + const WordArray: { + create(words?: X64WordArray[] |X64Word[], sigBytes?: number): X64WordArray; + }; + } + + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.MD5('message'); + * var hash = CryptoJS.MD5(wordArray); + */ + export const MD5: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMA'C. + * + * @example + * + * var hmac = CryptoJS.HmacMD5(message, key); + */ + export const HmacMD5: HmacHasherHelper; + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.SHA1('message'); + * var hash = CryptoJS.SHA1(wordArray); + */ + export const SHA1: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMAC. + * + * @example + * + * var hmac = CryptoJS.HmacSHA1(message, key); + */ + export const HmacSHA1: HmacHasherHelper; + + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.SHA256('message'); + * var hash = CryptoJS.SHA256(wordArray); + */ + export const SHA256: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMAC. + * + * @example + * + * var hmac = CryptoJS.HmacSHA256(message, key); + */ + export const HmacSHA256: HmacHasherHelper; + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.SHA224('message'); + * var hash = CryptoJS.SHA224(wordArray); + */ + export const SHA224: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMAC. + * + * @example + * + * var hmac = CryptoJS.HmacSHA224(message, key); + */ + export const HmacSHA224: HmacHasherHelper; + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.SHA512('message'); + * var hash = CryptoJS.SHA512(wordArray); + */ + export const SHA512: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMAC. + * + * @example + * + * var hmac = CryptoJS.HmacSHA512(message, key); + */ + export const HmacSHA512: HmacHasherHelper; + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.SHA384('message'); + * var hash = CryptoJS.SHA384(wordArray); + */ + export const SHA384: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMAC. + * + * @example + * + * var hmac = CryptoJS.HmacSHA384(message, key); + */ + export const HmacSHA384: HmacHasherHelper; + + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.SHA3('message'); + * var hash = CryptoJS.SHA3(wordArray); + */ + export const SHA3: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMAC. + * + * @example + * + * var hmac = CryptoJS.HmacSHA3(message, key); + */ + export const HmacSHA3: HmacHasherHelper; + + /** + * Shortcut function to the hasher's object interface. + * + * @param message The message to hash. + * + * @return The hash. + * + * @example + * + * var hash = CryptoJS.RIPEMD160('message'); + * var hash = CryptoJS.RIPEMD160(wordArray); + */ + export const RIPEMD160: HasherHelper; + /** + * Shortcut function to the HMAC's object interface. + * + * @param message The message to hash. + * @param key The secret key. + * + * @return The HMAC. + * + * @example + * + * var hmac = CryptoJS.HmacRIPEMD160(message, key); + */ + export const HmacRIPEMD160: HmacHasherHelper; + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param password The password. + * @param salt A salt. + * @param cfg (Optional) The configuration options to use for this computation. + * + * @return The derived key. + * + * @example + * + * var key = CryptoJS.PBKDF2(password, salt); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 }); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 }); + */ + export function PBKDF2(password: WordArray | string, salt: WordArray | string, cfg?: KDFOption): WordArray; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); + */ + export const AES: CipherHelper; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); + */ + export const DES: CipherHelper; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); + */ + export const TripleDES: CipherHelper; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg); + */ + export const RC4: CipherHelper; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg); + */ + export const RC4Drop: CipherHelper; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg); + * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg); + */ + export const Rabbit: CipherHelper; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg); + */ + export const RabbitLegacy: CipherHelper; + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.Blowfish.encrypt(message, key, cfg); + * var plaintext = CryptoJS.Blowfish.decrypt(ciphertext, key, cfg); + */ + export const Blowfish: CipherHelper; + + /** + * Derives a key from a password. + * + * @param password The password. + * @param salt A salt. + * @param cfg (Optional) The configuration options to use for this computation. + * + * @return The derived key. + * + * @example + * + * var key = CryptoJS.EvpKDF(password, salt); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); + */ + export function EvpKDF( + password: WordArray | string, + salt: WordArray | string, + cfg?: { + keySize: number; + hasher?: HasherStatic | undefined; + iterations?: number; + }, + ): WordArray; + + /** + * Encoding strategy. + */ + interface Encoder { + /** + * Converts a word array to a hex string. + * + * @param wordArray The word array. + * + * @return The hex string. + * + * @example + * + * var hexString = CryptoJS.enc.Hex.stringify(wordArray); + */ + stringify(wordArray: WordArray | object): string; + /** + * Converts a hex string to a word array. + * + * @param hexStr The hex string. + * + * @return The word array. + * + * @example + * + * var wordArray = CryptoJS.enc.Hex.parse(hexString); + */ + parse(str: string): WordArray; + } + + /** + * Abstract buffered block algorithm template. + * + * The property blockSize must be implemented in a concrete subtype. + */ + interface BufferedBlockAlgorithm { + /** + * The number of blocks that should be kept unprocessed in the buffer. Default: 0 + */ + _minBufferSize: number; + /** + * Resets this block algorithm's data buffer to its initial state. + * + * @example + * + * bufferedBlockAlgorithm.reset(); + */ + reset(): void; + /** + * Adds new data to this block algorithm's buffer. + * + * @param data The data to append. Strings are converted to a WordArray using UTF-8. + * + * @example + * + * bufferedBlockAlgorithm._append('data'); + * bufferedBlockAlgorithm._append(wordArray); + */ + _append(data: WordArray | string): void; + /** + * Processes available data blocks. + * + * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. + * + * @param doFlush Whether all blocks and partial blocks should be processed. + * + * @return The processed data. + * + * @example + * + * var processedData = bufferedBlockAlgorithm._process(); + * var processedData = bufferedBlockAlgorithm._process(!!'flush'); + */ + _process(doFlush?: boolean): WordArray; + /** + * Creates a copy of this object. + * + * @return The clone. + * + * @example + * + * var clone = bufferedBlockAlgorithm.clone(); + */ + clone(): BufferedBlockAlgorithm; + } + + /** + * Abstract hasher template. + */ + interface Hasher { + /** + * Creates a copy of this object. + * + * @return The clone. + */ + clone(): this; + /** + * The number of 32-bit words this hasher operates on. Default: 16 (512 bits) + */ + blockSize: number; + /** + * Resets this hasher to its initial state. + * + * @example + * + * hasher.reset(); + */ + reset(): void; + /** + * Updates this hasher with a message. + * + * @param messageUpdate The message to append. + * + * @return This hasher. + * + * @example + * + * hasher.update('message'); + * hasher.update(wordArray); + */ + update(messageUpdate: WordArray | string): this; + /** + * Finalizes the hash computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param messageUpdate (Optional) A final message update. + * + * @return The hash. + * + * @example + * + * var hash = hasher.finalize(); + * var hash = hasher.finalize('message'); + * var hash = hasher.finalize(wordArray); + */ + finalize(messageUpdate?: WordArray | string): WordArray; + } + + interface HasherStatic { + /** + * Initializes a newly created hasher. + * + * @param cfg (Optional) The configuration options to use for this hash computation. + * + * @example + * + * var hasher = CryptoJS.algo.SHA256.create(); + */ + create(cfg?: object): Hasher; + } + + export interface HasherHelper { + (message: WordArray | string, cfg?: object): WordArray; + } + + interface HmacHasherHelper { + (message: WordArray | string, key: WordArray | string): WordArray; + } + + /** + * Abstract base cipher template. + */ + interface Cipher { + /** + * This cipher's key size. Default: 4 (128 bits) + */ + keySize: number; + /** + * This cipher's IV size. Default: 4 (128 bits) + */ + ivSize: number; + /** + * The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + blockSize?: number; + /** + * Configuration options. + */ + cfg:BlockCipherOption + /** + * A constant representing encryption mode. + */ + readonly _ENC_XFORM_MODE: number; + /** + * A constant representing decryption mode. + */ + readonly _DEV_XFORM_MODE: number; + + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset(): void; + + /** + * Adds data to be encrypted or decrypted. + * + * @param dataUpdate The data to encrypt or decrypt. + * + * @return The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process(dataUpdate: WordArray | string): WordArray; + + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param dataUpdate The final data to encrypt or decrypt. + * + * @return The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize(dataUpdate?: WordArray | string): WordArray; + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + */ + encryptBlock(words:Array, offset:number):void + } + + export interface CipherStatic { + /** + * Creates this cipher in encryption mode. + * + * @param key The key. + * @param cfg (Optional) The configuration options to use for this operation. + * + * @return A cipher instance. + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor(key: WordArray | object, cfg?: CipherOption | object): Cipher; + + /** + * Creates this cipher in decryption mode. + * + * @param key The key. + * @param cfg (Optional) The configuration options to use for this operation. + * + * @return A cipher instance. + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor(key: WordArray, cfg?: CipherOption): Cipher; + + /** + * Initializes a newly created cipher. + * + * @param xformMode Either the encryption or decryption transormation mode constant. + * @param key The key. + * @param cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + create(xformMode: number, key: WordArray, cfg?: CipherOption): Cipher; + /** + * The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + blockSize?: number; + } + + interface CipherHelper { + encrypt(message: WordArray | string, key: WordArray | string, cfg?: CipherOption): CipherParams; + decrypt(ciphertext: CipherParams | string, key: WordArray | string, cfg?: CipherOption): WordArray; + } + + /** + * Configuration options. + */ + interface CipherOption { + /** + * The IV to use for this operation. + */ + iv?: WordArray | undefined; + format?: Format | undefined; + [key: string]: any; + } + + interface Mode { + /** + * Processes the data block at offset. + * + * @param words The data words to operate on. + * @param offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock(words: number[], offset: number): void; + } + + interface ModeStatic { + /** + * Initializes a newly created mode. + * + * @param cipher A block cipher instance. + * @param iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + create(cipher: Cipher, iv: number[]): Mode; + } + + /** + * Abstract base block cipher mode template. + */ + interface BlockCipherMode { + Encryptor: ModeStatic; + Decryptor: ModeStatic; + /** + * Creates this mode for encryption. + * + * @param cipher A block cipher instance. + * @param iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor(cipher: Cipher, iv: number[]): Mode; + + /** + * Creates this mode for decryption. + * + * @param cipher A block cipher instance. + * @param iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor(cipher: Cipher, iv: number[]): Mode; + } + + /** + * Abstract base block cipher mode template. + */ + interface BlockCipherMode { + /** + * Creates this mode for encryption. + * + * @param cipher A block cipher instance. + * @param iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor(cipher: Cipher): Mode; + } + + /** + * Padding strategy. + */ + interface Padding { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param data The data to pad. + * @param blockSize The multiple that the data should be padded to. + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad(data: WordArray, blockSize: number): void; + + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param data The data to unpad. + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad(data: WordArray): void; + } + + /** + * Abstract base block cipher template. + */ + interface BlockCipher { + /** + * The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + blockSize: number; + } + + /** + * Configuration options. + */ + interface BlockCipherOption { + /** + * The block mode to use. Default: CBC + */ + mode: Mode; + /** + * The padding strategy to use. Default: Pkcs7 + */ + padding: Padding; + } + /** + * Formatting strategy. + */ + interface Format { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param cipherParams The cipher params object. + * + * @return The OpenSSL-compatible string. + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify(cipherParams: CipherParams): string; + + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param openSSLStr The OpenSSL-compatible string. + * + * @return The cipher params object. + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse(str: string): CipherParams; + } + + /** + * An array of 64-bit words. + */ + interface X64WordArray { + /** + * The array of CryptoJS.x64.Word objects. + */ + words: number[] ; + /** + * The number of significant bytes in this word array. + */ + sigBytes: number; + + /** + * Converts this 64-bit word array to a 32-bit word array. + * + * @return This word array's data as a 32-bit word array. + * + * @example + * + * var x32WordArray = x64WordArray.toX32(); + */ + toX32(): WordArray; + + /** + * Creates a copy of this word array. + * + * @return The clone. + * + * @example + * + * var clone = x64WordArray.clone(); + */ + clone(): X64WordArray; + } + + /** + * Base object for prototypal inheritance. + */ + interface Base { + /** + * Creates a copy of this object. + * + * @return The clone. + * + * @example + * + * var clone = instance.clone(); + */ + clone(): this; + } + + /** + * Configuration options. + */ + interface KDFOption { + /** + * The key size in words to generate. + */ + keySize?: number | undefined; + /** + * The hasher to use. + */ + hasher?: HasherStatic | undefined; + /** + * The number of iterations to perform. + */ + iterations?: number | undefined; + } + } +} diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/index.ts b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/index.ts new file mode 100644 index 0000000..6009fc9 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/index.ts @@ -0,0 +1,20 @@ +/* + * Copyright (C) 2022 Huawei Device Co., Ltd. + * Licensed under the MIT License, (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://opensource.org/licenses/MIT + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// import CryptoJS from './src/main/js/core'; +import CryptoJS from "./src/main/js/crypto-js" + +export default CryptoJS; + +export { CryptoJS }; diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/oh-package.json5 b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/oh-package.json5 new file mode 100644 index 0000000..87a1702 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/oh-package.json5 @@ -0,0 +1 @@ +{"types":"index.d.ts","keywords":["crypto-js","OpenHarmony","HarmonyOS"],"author":"hihope","description":"The encryption algorithm class library can be very convenient to perform the encryption and decryption operations it supports in the front end. Currently, the algorithms supported by crypto-js are: MD5, SHA-1, SHA-256, HMAC, HMAC-MD5, HMAC-SHA1, HMAC-SHA256, PBKDF2, etc.","ohos":{"org":"opensource"},"main":"index.ts","repository":"https://gitee.com/openharmony-sig/crypto-js","type":"module","version":"2.0.4","dependencies":{},"tags":["Tools","Security"],"license":"MIT","devDependencies":{},"name":"@ohos/crypto-js","metadata":{"sourceRoots":["./src/main"]},"compatibleSdkVersion":9,"compatibleSdkType":"OpenHarmony","obfuscated":false} diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/js/crypto-js.js b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/js/crypto-js.js new file mode 100644 index 0000000..dec45a9 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/js/crypto-js.js @@ -0,0 +1,8025 @@ +import require$$0 from '@ohos.buffer'; +import { hasOwn } from './utils' +var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : { + }; + +var srcExports = {}; +var src$1 = { + get exports() { + return srcExports; + }, + set exports(v) { + srcExports = v; + }, +}; + +function commonjsRequire(path) { + throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.'); +} + +var coreExports = {}; +var core = { + get exports() { + return coreExports; + }, + set exports(v) { + coreExports = v; + }, +}; + +var hasRequiredCore; + +function requireCore() { + if (hasRequiredCore) return coreExports; + hasRequiredCore = 1; + (function(module, exports){ + const buffer = require$$0; + const unhexTable = new Int8Array([ + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 0 - 15 + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 16 - 31 + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 32 - 47 + +0, + +1, + +2, + +3, + +4, + +5, + +6, + +7, + +8, + +9, + -1, + -1, + -1, + -1, + -1, + -1, // 48 - 63 + -1, + 10, + 11, + 12, + 13, + 14, + 15, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 64 - 79 + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 80 - 95 + -1, + 10, + 11, + 12, + 13, + 14, + 15, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 96 - 111 + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 112 - 127 + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // 128 ... + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, + -1, // ... 255 + ]); + + (function (root, factory) { + { + // CommonJS + module.exports = factory(); + } + })(commonjsGlobal, function () { + + function unescapeBuffer(s, decodeSpaces) { + const out = buffer.alloc(s.length); + let index = 0; + let outIndex = 0; + let currentChar; + let nextChar; + let hexHigh; + let hexLow; + const maxLength = s.length - 2; + // Flag to know if some hex chars have been decoded + let hasHex = false; + while (index < s.length) { + currentChar = s.charCodeAt(index); + if (currentChar === 43 /* '+' */ + && decodeSpaces) { + out[outIndex++] = 32; // ' ' + index++; + continue; + } + if (currentChar === 37 /* '%' */ + && index < maxLength) { + currentChar = s.charCodeAt(++index); + hexHigh = unhexTable[currentChar]; + if (!(hexHigh >= 0)) { + out[outIndex++] = 37; // '%' + continue; + } else { + nextChar = s.charCodeAt(++index); + hexLow = unhexTable[nextChar]; + if (!(hexLow >= 0)) { + out[outIndex++] = 37; // '%' + index--; + } else { + hasHex = true; + currentChar = hexHigh * 16 + hexLow; + } + } + } + out[outIndex++] = currentChar; + index++; + } + return hasHex ? out.subarray(0, outIndex) : out; + } + + /*globals window, global, require*/ + + /** + * CryptoJS core components. + */ + var CryptoJS = + CryptoJS || + (function (Math, undefined$1) { + var crypto; + + // Native crypto from window (Browser) + if (typeof window !== "undefined" && window.crypto) { + crypto = window.crypto; + } + + // Native crypto in web worker (Browser) + if (typeof self !== "undefined" && self.crypto) { + crypto = self.crypto; + } + + // Native crypto from worker + if (typeof globalThis !== "undefined" && globalThis.crypto) { + crypto = globalThis.crypto; + } + + // Native (experimental IE 11) crypto from window (Browser) + if (!crypto && typeof window !== "undefined" && window.msCrypto) { + crypto = window.msCrypto; + } + + // Native crypto from global (NodeJS) + if (!crypto && typeof commonjsGlobal !== "undefined" && commonjsGlobal.crypto) { + crypto = commonjsGlobal.crypto; + } + + // Native crypto import via require (NodeJS) + if (!crypto && typeof commonjsRequire === "function") { + try { + crypto = require("crypto"); + } catch (err) { + } + } + + /* + * Local polyfill of Object.create + + */ + var create = + Object.create || + (function () { + + function F() { + } + + return function (obj) { + var subtype; + + F.prototype = obj; + + subtype = new F(); + + F.prototype = null; + + return subtype; + }; + })(); + + /** + * CryptoJS namespace. + */ + var C = {}; + + /** + * Library namespace. + */ + var C_lib = (C.lib = {}); + + /** + * Base object for prototypal inheritance. + */ + var Base = (C_lib.Base = (function () { + return { + /** + * Creates a new object that inherits from this object. + * + * @param {Object} overrides Properties to copy into the new object. + * + * @return {Object} The new object. + * + * @static + * + * @example + * + * var MyType = CryptoJS.lib.Base.extend({ + * field: 'value', + * + * method: function () { + * } + * }); + */ + extend: function (overrides) { + // Spawn + var subtype = create(this); + + // Augment + if (overrides) { + subtype.mixIn(overrides); + } + + // Create default initializer + if (!hasOwn(subtype,"init") || this.init === subtype.init) { + subtype.init = function () { + subtype.$super.init.apply(this, arguments); + }; + } + + // Initializer's prototype is the subtype object + subtype.init.prototype = subtype; + + // Reference supertype + subtype.$super = this; + + return subtype; + }, + + /** + * Extends this object and runs the init method. + * Arguments to create() will be passed to init(). + * + * @return {Object} The new object. + * + * @static + * + * @example + * + * var instance = MyType.create(); + */ + create: function () { + var instance = this.extend(); + instance.init.apply(instance, arguments); + + return instance; + }, + + /** + * Initializes a newly created object. + * Override this method to add some logic when your objects are created. + * + * @example + * + * var MyType = CryptoJS.lib.Base.extend({ + * init: function () { + * // ... + * } + * }); + */ + init: function () { + }, + + /** + * Copies properties into this object. + * + * @param {Object} properties The properties to mix in. + * + * @example + * + * MyType.mixIn({ + * field: 'value' + * }); + */ + mixIn: function (properties) { + for (var propertyName in properties) { + if (hasOwn(properties,propertyName)) { + this[propertyName] = properties[propertyName]; + } + } + + // IE won't copy toString using the loop above + if (hasOwn(properties,"toString")) { + this.toString = properties.toString; + } + }, + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = instance.clone(); + */ + clone: function () { + return this.init.prototype.extend(this); + }, + }; + })()); + + /** + * An array of 32-bit words. + * + * @property {Array} words The array of 32-bit words. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + var WordArray = (C_lib.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of 32-bit words. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.create(); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607]); + * var wordArray = CryptoJS.lib.WordArray.create([0x00010203, 0x04050607], 6); + */ + init: function (words, sigBytes) { + words = this.words = words || []; + + if (sigBytes != undefined$1) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 4; + } + }, + + /** + * Converts this word array to a string. + * + * @param {Encoder} encoder (Optional) The encoding strategy to use. Default: CryptoJS.enc.Hex + * + * @return {string} The stringified word array. + * + * @example + * + * var string = wordArray + ''; + * var string = wordArray.toString(); + * var string = wordArray.toString(CryptoJS.enc.Utf8); + */ + toString: function (encoder) { + return (encoder || Hex).stringify(this); + }, + + /** + * Concatenates a word array to this word array. + * + * @param {WordArray} wordArray The word array to append. + * + * @return {WordArray} This word array. + * + * @example + * + * wordArray1.concat(wordArray2); + */ + concat: function (wordArray) { + // Shortcuts + var thisWords = this.words; + var thatWords = wordArray.words; + var thisSigBytes = this.sigBytes; + var thatSigBytes = wordArray.sigBytes; + + // Clamp excess bits + this.clamp(); + + // Concat + if (thisSigBytes % 4) { + // Copy one byte at a time + for (var i = 0; i < thatSigBytes; i++) { + var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + thisWords[(thisSigBytes + i) >>> 2] |= + thatByte << (24 - ((thisSigBytes + i) % 4) * 8); + } + } else { + // Copy one word at a time + for (var j = 0; j < thatSigBytes; j += 4) { + thisWords[(thisSigBytes + j) >>> 2] = thatWords[j >>> 2]; + } + } + this.sigBytes += thatSigBytes; + + // Chainable + return this; + }, + + /** + * Removes insignificant bits. + * + * @example + * + * wordArray.clamp(); + */ + clamp: function () { + // Shortcuts + var words = this.words; + var sigBytes = this.sigBytes; + + // Clamp + words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8); + words.length = Math.ceil(sigBytes / 4); + }, + + /** + * Creates a copy of this word array. + * + * @return {WordArray} The clone. + * + * @example + * + * var clone = wordArray.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + clone.words = this.words.slice(0); + + return clone; + }, + + /** + * Creates a word array filled with random bytes. + * + * @param {number} nBytes The number of random bytes to generate. + * + * @return {WordArray} The random word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.lib.WordArray.random(16); + */ + random: function (nBytes) { + // var words = []; + + // for (var i = 0; i < nBytes; i += 4) { + // words.push(cryptoSecureRandomInt()); + // } + + // return new WordArray.init(words, nBytes); + var words = []; + var r = function (m_w) { + var m_z = 0x3ade68b1; + var mask = 0xffffffff; + + return function () { + m_z = (0x9069 * (m_z & 0xffff) + (m_z >> 0x10)) & mask; + m_w = (0x4650 * (m_w & 0xffff) + (m_w >> 0x10)) & mask; + var result = ((m_z << 0x10) + m_w) & mask; + result /= 0x100000000; + result += 0.5; + return result * (Math.random() > 0.5 ? 1 : -1); + }; + }; + + for (var i = 0, rcache; i < nBytes; i += 4) { + var _r = r((rcache || Math.random()) * 0x100000000); + + rcache = _r() * 0x3ade67b7; + words.push((_r() * 0x100000000) | 0); + } + return CryptoJS.lib.WordArray.create(words, nBytes); + }, + })); + + /** + * Encoder namespace. + */ + var C_enc = (C.enc = {}); + + /** + * Hex encoding strategy. + */ + var Hex = (C_enc.Hex = { + /** + * Converts a word array to a hex string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The hex string. + * + * @static + * + * @example + * + * var hexString = CryptoJS.enc.Hex.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var hexChars = []; + for (var i = 0; i < sigBytes; i++) { + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + hexChars.push((bite >>> 4).toString(16)); + hexChars.push((bite & 0x0f).toString(16)); + } + + return hexChars.join(""); + }, + + /** + * Converts a hex string to a word array. + * + * @param {string} hexStr The hex string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Hex.parse(hexString); + */ + parse: function (hexStr) { + // Shortcut + var hexStrLength = hexStr.length; + + // Convert + var words = []; + for (var i = 0; i < hexStrLength; i += 2) { + words[i >>> 3] |= + parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4); + } + + return new WordArray.init(words, hexStrLength / 2); + }, + }); + + /** + * Latin1 encoding strategy. + */ + (C_enc.Latin1 = { + /** + * Converts a word array to a Latin1 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Latin1 string. + * + * @static + * + * @example + * + * var latin1String = CryptoJS.enc.Latin1.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var latin1Chars = []; + for (var i = 0; i < sigBytes; i++) { + var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + latin1Chars.push(String.fromCharCode(bite)); + } + + return latin1Chars.join(""); + }, + + /** + * Converts a Latin1 string to a word array. + * + * @param {string} latin1Str The Latin1 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Latin1.parse(latin1String); + */ + parse: function (latin1Str) { + // Shortcut + var latin1StrLength = latin1Str.length; + + // Convert + var words = []; + for (var i = 0; i < latin1StrLength; i++) { + words[i >>> 2] |= + (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8); + } + + return new WordArray.init(words, latin1StrLength); + }, + }); + + /** + * UTF-8 encoding strategy. + */ + var Utf8 = (C_enc.Utf8 = { + /** + * Converts a word array to a UTF-8 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-8 string. + * + * @static + * + * @example + * + * var utf8String = CryptoJS.enc.Utf8.stringify(wordArray); + */ + stringify: function (wordArray) { + try { + return buffer + .from(CryptoJS.enc.Latin1.stringify(wordArray), "latin1") + .toString("utf-8"); + // return decodeURIComponent(escape(Latin1.stringify(wordArray))); + } catch (e) { + throw new Error("Malformed UTF-8 data"); + } + }, + + /** + * Converts a UTF-8 string to a word array. + * + * @param {string} utf8Str The UTF-8 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf8.parse(utf8String); + */ + parse: function (utf8Str) { + return CryptoJS.enc.Latin1.parse( + unescapeBuffer(encodeURIComponent(utf8Str), false).toString( + "binary" + ) + ); + // return Latin1.parse(unescape(encodeURIComponent(utf8Str))); + }, + }); + + /** + * Abstract buffered block algorithm template. + * + * The property blockSize must be implemented in a concrete subtype. + * + * @property {number} _minBufferSize The number of blocks that should be kept unprocessed in the buffer. Default: 0 + */ + var BufferedBlockAlgorithm = (C_lib.BufferedBlockAlgorithm = Base.extend({ + /** + * Resets this block algorithm's data buffer to its initial state. + * + * @example + * + * bufferedBlockAlgorithm.reset(); + */ + reset: function () { + // Initial values + this._data = new WordArray.init(); + this._nDataBytes = 0; + }, + + /** + * Adds new data to this block algorithm's buffer. + * + * @param {WordArray|string} data The data to append. Strings are converted to a WordArray using UTF-8. + * + * @example + * + * bufferedBlockAlgorithm._append('data'); + * bufferedBlockAlgorithm._append(wordArray); + */ + _append: function (data) { + // Convert string to WordArray, else assume WordArray already + if (typeof data == "string") { + data = Utf8.parse(data); + } + + // Append + this._data.concat(data); + this._nDataBytes += data.sigBytes; + }, + + /** + * Processes available data blocks. + * + * This method invokes _doProcessBlock(offset), which must be implemented by a concrete subtype. + * + * @param {boolean} doFlush Whether all blocks and partial blocks should be processed. + * + * @return {WordArray} The processed data. + * + * @example + * + * var processedData = bufferedBlockAlgorithm._process(); + * var processedData = bufferedBlockAlgorithm._process(!!'flush'); + */ + _process: function (doFlush) { + var processedWords; + + // Shortcuts + var data = this._data; + var dataWords = data.words; + var dataSigBytes = data.sigBytes; + var blockSize = this.blockSize; + var blockSizeBytes = blockSize * 4; + + // Count blocks ready + var nBlocksReady = dataSigBytes / blockSizeBytes; + if (doFlush) { + // Round up to include partial blocks + nBlocksReady = Math.ceil(nBlocksReady); + } else { + // Round down to include only full blocks, + // less the number of blocks that must remain in the buffer + nBlocksReady = Math.max( + (nBlocksReady | 0) - this._minBufferSize, + 0 + ); + } + + // Count words ready + var nWordsReady = nBlocksReady * blockSize; + + // Count bytes ready + var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes); + + // Process blocks + if (nWordsReady) { + for (var offset = 0; offset < nWordsReady; offset += blockSize) { + // Perform concrete-algorithm logic + this._doProcessBlock(dataWords, offset); + } + + // Remove processed words + processedWords = dataWords.splice(0, nWordsReady); + data.sigBytes -= nBytesReady; + } + + // Return processed words + return new WordArray.init(processedWords, nBytesReady); + }, + + /** + * Creates a copy of this object. + * + * @return {Object} The clone. + * + * @example + * + * var clone = bufferedBlockAlgorithm.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + clone._data = this._data.clone(); + + return clone; + }, + + _minBufferSize: 0, + })); + + /** + * Abstract hasher template. + * + * @property {number} blockSize The number of 32-bit words this hasher operates on. Default: 16 (512 bits) + */ + (C_lib.Hasher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + */ + cfg: Base.extend(), + + /** + * Initializes a newly created hasher. + * + * @param {Object} cfg (Optional) The configuration options to use for this hash computation. + * + * @example + * + * var hasher = CryptoJS.algo.SHA256.create(); + */ + init: function (cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); + + // Set initial values + this.reset(); + }, + + /** + * Resets this hasher to its initial state. + * + * @example + * + * hasher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); + + // Perform concrete-hasher logic + this._doReset(); + }, + + /** + * Updates this hasher with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {Hasher} This hasher. + * + * @example + * + * hasher.update('message'); + * hasher.update(wordArray); + */ + update: function (messageUpdate) { + // Append + this._append(messageUpdate); + + // Update the hash + this._process(); + + // Chainable + return this; + }, + + /** + * Finalizes the hash computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The hash. + * + * @example + * + * var hash = hasher.finalize(); + * var hash = hasher.finalize('message'); + * var hash = hasher.finalize(wordArray); + */ + finalize: function (messageUpdate) { + // Final message update + if (messageUpdate) { + this._append(messageUpdate); + } + + // Perform concrete-hasher logic + var hash = this._doFinalize(); + + return hash; + }, + + blockSize: 512 / 32, + + /** + * Creates a shortcut function to a hasher's object interface. + * + * @param {Hasher} hasher The hasher to create a helper for. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var SHA256 = CryptoJS.lib.Hasher._createHelper(CryptoJS.algo.SHA256); + */ + _createHelper: function (hasher) { + return function (message, cfg) { + return new hasher.init(cfg).finalize(message); + }; + }, + + /** + * Creates a shortcut function to the HMAC's object interface. + * + * @param {Hasher} hasher The hasher to use in this HMAC helper. + * + * @return {Function} The shortcut function. + * + * @static + * + * @example + * + * var HmacSHA256 = CryptoJS.lib.Hasher._createHmacHelper(CryptoJS.algo.SHA256); + */ + _createHmacHelper: function (hasher) { + return function (message, key) { + return new C_algo.HMAC.init(hasher, key).finalize(message); + }; + }, + })); + + /** + * Algorithm namespace. + */ + var C_algo = (C.algo = {}); + + return C; + })(Math); + + return CryptoJS; + }); + }(core)); + return coreExports; +} + +var x64CoreExports = {}; +var x64Core = { + get exports() { + return x64CoreExports; + }, + set exports(v) { + x64CoreExports = v; + }, +}; + +var hasRequiredX64Core; + +function requireX64Core() { + if (hasRequiredX64Core) return x64CoreExports; + hasRequiredX64Core = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(undefined$1){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var X32WordArray = C_lib.WordArray; + + /** + * x64 namespace. + */ + var C_x64 = C.x64 = {}; + + /** + * A 64-bit word. + */ + C_x64.Word = Base.extend({ + /** + * Initializes a newly created 64-bit word. + * + * @param {number} high The high 32 bits. + * @param {number} low The low 32 bits. + * + * @example + * + * var x64Word = CryptoJS.x64.Word.create(0x00010203, 0x04050607); + */ + init: function (high, low) { + this.high = high; + this.low = low; + } + + /** + * Bitwise NOTs this word. + * + * @return {X64Word} A new x64-Word object after negating. + * + * @example + * + * var negated = x64Word.not(); + */ + // not: function () { + // var high = ~this.high; + // var low = ~this.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ANDs this word with the passed word. + * + * @param {X64Word} word The x64-Word to AND with this word. + * + * @return {X64Word} A new x64-Word object after ANDing. + * + * @example + * + * var anded = x64Word.and(anotherX64Word); + */ + // and: function (word) { + // var high = this.high & word.high; + // var low = this.low & word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise ORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to OR with this word. + * + * @return {X64Word} A new x64-Word object after ORing. + * + * @example + * + * var ored = x64Word.or(anotherX64Word); + */ + // or: function (word) { + // var high = this.high | word.high; + // var low = this.low | word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Bitwise XORs this word with the passed word. + * + * @param {X64Word} word The x64-Word to XOR with this word. + * + * @return {X64Word} A new x64-Word object after XORing. + * + * @example + * + * var xored = x64Word.xor(anotherX64Word); + */ + // xor: function (word) { + // var high = this.high ^ word.high; + // var low = this.low ^ word.low; + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the left. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftL(25); + */ + // shiftL: function (n) { + // if (n < 32) { + // var high = (this.high << n) | (this.low >>> (32 - n)); + // var low = this.low << n; + // } else { + // var high = this.low << (n - 32); + // var low = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Shifts this word n bits to the right. + * + * @param {number} n The number of bits to shift. + * + * @return {X64Word} A new x64-Word object after shifting. + * + * @example + * + * var shifted = x64Word.shiftR(7); + */ + // shiftR: function (n) { + // if (n < 32) { + // var low = (this.low >>> n) | (this.high << (32 - n)); + // var high = this.high >>> n; + // } else { + // var low = this.high >>> (n - 32); + // var high = 0; + // } + + // return X64Word.create(high, low); + // }, + + /** + * Rotates this word n bits to the left. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotL(25); + */ + // rotL: function (n) { + // return this.shiftL(n).or(this.shiftR(64 - n)); + // }, + + /** + * Rotates this word n bits to the right. + * + * @param {number} n The number of bits to rotate. + * + * @return {X64Word} A new x64-Word object after rotating. + * + * @example + * + * var rotated = x64Word.rotR(7); + */ + // rotR: function (n) { + // return this.shiftR(n).or(this.shiftL(64 - n)); + // }, + + /** + * Adds this word with the passed word. + * + * @param {X64Word} word The x64-Word to add with this word. + * + * @return {X64Word} A new x64-Word object after adding. + * + * @example + * + * var added = x64Word.add(anotherX64Word); + */ + // add: function (word) { + // var low = (this.low + word.low) | 0; + // var carry = (low >>> 0) < (this.low >>> 0) ? 1 : 0; + // var high = (this.high + word.high + carry) | 0; + + // return X64Word.create(high, low); + // } + }); + + /** + * An array of 64-bit words. + * + * @property {Array} words The array of CryptoJS.x64.Word objects. + * @property {number} sigBytes The number of significant bytes in this word array. + */ + C_x64.WordArray = Base.extend({ + /** + * Initializes a newly created word array. + * + * @param {Array} words (Optional) An array of CryptoJS.x64.Word objects. + * @param {number} sigBytes (Optional) The number of significant bytes in the words. + * + * @example + * + * var wordArray = CryptoJS.x64.WordArray.create(); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ]); + * + * var wordArray = CryptoJS.x64.WordArray.create([ + * CryptoJS.x64.Word.create(0x00010203, 0x04050607), + * CryptoJS.x64.Word.create(0x18191a1b, 0x1c1d1e1f) + * ], 10); + */ + init: function (words, sigBytes) { + words = this.words = words || []; + + if (sigBytes != undefined$1) { + this.sigBytes = sigBytes; + } else { + this.sigBytes = words.length * 8; + } + }, + + /** + * Converts this 64-bit word array to a 32-bit word array. + * + * @return {CryptoJS.lib.WordArray} This word array's data as a 32-bit word array. + * + * @example + * + * var x32WordArray = x64WordArray.toX32(); + */ + toX32: function () { + // Shortcuts + var x64Words = this.words; + var x64WordsLength = x64Words.length; + + // Convert + var x32Words = []; + for (var i = 0; i < x64WordsLength; i++) { + var x64Word = x64Words[i]; + x32Words.push(x64Word.high); + x32Words.push(x64Word.low); + } + + return X32WordArray.create(x32Words, this.sigBytes); + }, + + /** + * Creates a copy of this word array. + * + * @return {X64WordArray} The clone. + * + * @example + * + * var clone = x64WordArray.clone(); + */ + clone: function () { + var clone = Base.clone.call(this); + + // Clone "words" array + var words = clone.words = this.words.slice(0); + + // Clone each X64Word object + var wordsLength = words.length; + for (var i = 0; i < wordsLength; i++) { + words[i] = words[i].clone(); + } + + return clone; + } + }); + }()); + + + return CryptoJS; + + })); + }(x64Core)); + return x64CoreExports; +} + +var libTypedarraysExports = {}; +var libTypedarrays = { + get exports() { + return libTypedarraysExports; + }, + set exports(v) { + libTypedarraysExports = v; + }, +}; + +var hasRequiredLibTypedarrays; + +function requireLibTypedarrays() { + if (hasRequiredLibTypedarrays) return libTypedarraysExports; + hasRequiredLibTypedarrays = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Check if typed arrays are supported + if (typeof ArrayBuffer != 'function') { + return; + } + + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + + // Reference original init + var superInit = WordArray.init; + + // Augment WordArray.init to handle typed arrays + var subInit = WordArray.init = function (typedArray) { + // Convert buffers to uint8 + if (typedArray instanceof ArrayBuffer) { + typedArray = new Uint8Array(typedArray); + } + + // Convert other array views to uint8 + if ( + typedArray instanceof Int8Array || + (typeof Uint8ClampedArray !== "undefined" && typedArray instanceof Uint8ClampedArray) || + typedArray instanceof Int16Array || + typedArray instanceof Uint16Array || + typedArray instanceof Int32Array || + typedArray instanceof Uint32Array || + typedArray instanceof Float32Array || + typedArray instanceof Float64Array + ) { + typedArray = new Uint8Array(typedArray.buffer, typedArray.byteOffset, typedArray.byteLength); + } + + // Handle Uint8Array + if (typedArray instanceof Uint8Array) { + // Shortcut + var typedArrayByteLength = typedArray.byteLength; + + // Extract bytes + var words = []; + for (var i = 0; i < typedArrayByteLength; i++) { + words[i >>> 2] |= typedArray[i] << (24 - (i % 4) * 8); + } + + // Initialize this word array + superInit.call(this, words, typedArrayByteLength); + } else { + // Else call normal init + superInit.apply(this, arguments); + } + }; + + subInit.prototype = WordArray; + }()); + + + return CryptoJS.lib.WordArray; + + })); + }(libTypedarrays)); + return libTypedarraysExports; +} + +var encUtf16Exports = {}; +var encUtf16 = { + get exports() { + return encUtf16Exports; + }, + set exports(v) { + encUtf16Exports = v; + }, +}; + +var hasRequiredEncUtf16; + +function requireEncUtf16() { + if (hasRequiredEncUtf16) return encUtf16Exports; + hasRequiredEncUtf16 = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * UTF-16 BE encoding strategy. + */ + C_enc.Utf16 = C_enc.Utf16BE = { + /** + * Converts a word array to a UTF-16 BE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 BE string. + * + * @static + * + * @example + * + * var utf16String = CryptoJS.enc.Utf16.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var utf16Chars = []; + for (var i = 0; i < sigBytes; i += 2) { + var codePoint = (words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff; + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); + }, + + /** + * Converts a UTF-16 BE string to a word array. + * + * @param {string} utf16Str The UTF-16 BE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf16.parse(utf16String); + */ + parse: function (utf16Str) { + // Shortcut + var utf16StrLength = utf16Str.length; + + // Convert + var words = []; + for (var i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= utf16Str.charCodeAt(i) << (16 - (i % 2) * 16); + } + + return WordArray.create(words, utf16StrLength * 2); + } + }; + + /** + * UTF-16 LE encoding strategy. + */ + C_enc.Utf16LE = { + /** + * Converts a word array to a UTF-16 LE string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The UTF-16 LE string. + * + * @static + * + * @example + * + * var utf16Str = CryptoJS.enc.Utf16LE.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + + // Convert + var utf16Chars = []; + for (var i = 0; i < sigBytes; i += 2) { + var codePoint = swapEndian((words[i >>> 2] >>> (16 - (i % 4) * 8)) & 0xffff); + utf16Chars.push(String.fromCharCode(codePoint)); + } + + return utf16Chars.join(''); + }, + + /** + * Converts a UTF-16 LE string to a word array. + * + * @param {string} utf16Str The UTF-16 LE string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Utf16LE.parse(utf16Str); + */ + parse: function (utf16Str) { + // Shortcut + var utf16StrLength = utf16Str.length; + + // Convert + var words = []; + for (var i = 0; i < utf16StrLength; i++) { + words[i >>> 1] |= swapEndian(utf16Str.charCodeAt(i) << (16 - (i % 2) * 16)); + } + + return WordArray.create(words, utf16StrLength * 2); + } + }; + + function swapEndian(word) { + return ((word << 8) & 0xff00ff00) | ((word >>> 8) & 0x00ff00ff); + } + }()); + + + return CryptoJS.enc.Utf16; + + })); + }(encUtf16)); + return encUtf16Exports; +} + +var encBase64Exports = {}; +var encBase64 = { + get exports() { + return encBase64Exports; + }, + set exports(v) { + encBase64Exports = v; + }, +}; + +var hasRequiredEncBase64; + +function requireEncBase64() { + if (hasRequiredEncBase64) return encBase64Exports; + hasRequiredEncBase64 = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * Base64 encoding strategy. + */ + C_enc.Base64 = { + /** + * Converts a word array to a Base64 string. + * + * @param {WordArray} wordArray The word array. + * + * @return {string} The Base64 string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64.stringify(wordArray); + */ + stringify: function (wordArray) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = this._map; + + // Clamp excess bits + wordArray.clamp(); + + // Convert + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; + + var triplet = (byte1 << 16) | (byte2 << 8) | byte3; + + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); + } + } + + // Add padding + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + + return base64Chars.join(''); + }, + + /** + * Converts a Base64 string to a word array. + * + * @param {string} base64Str The Base64 string. + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64.parse(base64String); + */ + parse: function (base64Str) { + // Shortcuts + var base64StrLength = base64Str.length; + var map = this._map; + var reverseMap = this._reverseMap; + + if (!reverseMap) { + reverseMap = this._reverseMap = []; + for (var j = 0; j < map.length; j++) { + reverseMap[map.charCodeAt(j)] = j; + } + } + + // Ignore padding + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; + } + } + + // Convert + return parseLoop(base64Str, base64StrLength, reverseMap); + + }, + + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=' + }; + + function parseLoop(base64Str, base64StrLength, reverseMap) { + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); + var bitsCombined = bits1 | bits2; + words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8); + nBytes++; + } + } + return WordArray.create(words, nBytes); + } + }()); + + + return CryptoJS.enc.Base64; + + })); + }(encBase64)); + return encBase64Exports; +} + +var encBase64urlExports = {}; +var encBase64url = { + get exports() { + return encBase64urlExports; + }, + set exports(v) { + encBase64urlExports = v; + }, +}; + +var hasRequiredEncBase64url; + +function requireEncBase64url() { + if (hasRequiredEncBase64url) return encBase64urlExports; + hasRequiredEncBase64url = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_enc = C.enc; + + /** + * Base64url encoding strategy. + */ + C_enc.Base64url = { + /** + * Converts a word array to a Base64url string. + * + * @param {WordArray} wordArray The word array. + * + * @param {boolean} urlSafe Whether to use url safe + * + * @return {string} The Base64url string. + * + * @static + * + * @example + * + * var base64String = CryptoJS.enc.Base64url.stringify(wordArray); + */ + stringify: function (wordArray, urlSafe = true) { + // Shortcuts + var words = wordArray.words; + var sigBytes = wordArray.sigBytes; + var map = urlSafe ? this._safe_map : this._map; + + // Clamp excess bits + wordArray.clamp(); + + // Convert + var base64Chars = []; + for (var i = 0; i < sigBytes; i += 3) { + var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff; + var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff; + var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff; + + var triplet = (byte1 << 16) | (byte2 << 8) | byte3; + + for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) { + base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f)); + } + } + + // Add padding + var paddingChar = map.charAt(64); + if (paddingChar) { + while (base64Chars.length % 4) { + base64Chars.push(paddingChar); + } + } + + return base64Chars.join(''); + }, + + /** + * Converts a Base64url string to a word array. + * + * @param {string} base64Str The Base64url string. + * + * @param {boolean} urlSafe Whether to use url safe + * + * @return {WordArray} The word array. + * + * @static + * + * @example + * + * var wordArray = CryptoJS.enc.Base64url.parse(base64String); + */ + parse: function (base64Str, urlSafe = true) { + // Shortcuts + var base64StrLength = base64Str.length; + var map = urlSafe ? this._safe_map : this._map; + var reverseMap = this._reverseMap; + + if (!reverseMap) { + reverseMap = this._reverseMap = []; + for (var j = 0; j < map.length; j++) { + reverseMap[map.charCodeAt(j)] = j; + } + } + + // Ignore padding + var paddingChar = map.charAt(64); + if (paddingChar) { + var paddingIndex = base64Str.indexOf(paddingChar); + if (paddingIndex !== -1) { + base64StrLength = paddingIndex; + } + } + + // Convert + return parseLoop(base64Str, base64StrLength, reverseMap); + + }, + + _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=', + _safe_map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_', + }; + + function parseLoop(base64Str, base64StrLength, reverseMap) { + var words = []; + var nBytes = 0; + for (var i = 0; i < base64StrLength; i++) { + if (i % 4) { + var bits1 = reverseMap[base64Str.charCodeAt(i - 1)] << ((i % 4) * 2); + var bits2 = reverseMap[base64Str.charCodeAt(i)] >>> (6 - (i % 4) * 2); + var bitsCombined = bits1 | bits2; + words[nBytes >>> 2] |= bitsCombined << (24 - (nBytes % 4) * 8); + nBytes++; + } + } + return WordArray.create(words, nBytes); + } + }()); + + return CryptoJS.enc.Base64url; + + })); + }(encBase64url)); + return encBase64urlExports; +} + +var md5Exports = {}; +var md5 = { + get exports() { + return md5Exports; + }, + set exports(v) { + md5Exports = v; + }, +}; + +var hasRequiredMd5; + +function requireMd5() { + if (hasRequiredMd5) return md5Exports; + hasRequiredMd5 = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(Math){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Constants table + var T = []; + + // Compute constants + (function(){ + for (var i = 0; i < 64; i++) { + T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0; + } + }()); + + /** + * MD5 hash algorithm. + */ + var MD5 = C_algo.MD5 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0x67452301, 0xefcdab89, + 0x98badcfe, 0x10325476 + ]); + }, + + _doProcessBlock: function (M, offset) { + // Swap endian + for (var i = 0; i < 16; i++) { + // Shortcuts + var offset_i = offset + i; + var M_offset_i = M[offset_i]; + + M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } + + // Shortcuts + var H = this._hash.words; + + var M_offset_0 = M[offset + 0]; + var M_offset_1 = M[offset + 1]; + var M_offset_2 = M[offset + 2]; + var M_offset_3 = M[offset + 3]; + var M_offset_4 = M[offset + 4]; + var M_offset_5 = M[offset + 5]; + var M_offset_6 = M[offset + 6]; + var M_offset_7 = M[offset + 7]; + var M_offset_8 = M[offset + 8]; + var M_offset_9 = M[offset + 9]; + var M_offset_10 = M[offset + 10]; + var M_offset_11 = M[offset + 11]; + var M_offset_12 = M[offset + 12]; + var M_offset_13 = M[offset + 13]; + var M_offset_14 = M[offset + 14]; + var M_offset_15 = M[offset + 15]; + + // Working varialbes + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + + // Computation + a = FF(a, b, c, d, M_offset_0, 7, T[0]); + d = FF(d, a, b, c, M_offset_1, 12, T[1]); + c = FF(c, d, a, b, M_offset_2, 17, T[2]); + b = FF(b, c, d, a, M_offset_3, 22, T[3]); + a = FF(a, b, c, d, M_offset_4, 7, T[4]); + d = FF(d, a, b, c, M_offset_5, 12, T[5]); + c = FF(c, d, a, b, M_offset_6, 17, T[6]); + b = FF(b, c, d, a, M_offset_7, 22, T[7]); + a = FF(a, b, c, d, M_offset_8, 7, T[8]); + d = FF(d, a, b, c, M_offset_9, 12, T[9]); + c = FF(c, d, a, b, M_offset_10, 17, T[10]); + b = FF(b, c, d, a, M_offset_11, 22, T[11]); + a = FF(a, b, c, d, M_offset_12, 7, T[12]); + d = FF(d, a, b, c, M_offset_13, 12, T[13]); + c = FF(c, d, a, b, M_offset_14, 17, T[14]); + b = FF(b, c, d, a, M_offset_15, 22, T[15]); + + a = GG(a, b, c, d, M_offset_1, 5, T[16]); + d = GG(d, a, b, c, M_offset_6, 9, T[17]); + c = GG(c, d, a, b, M_offset_11, 14, T[18]); + b = GG(b, c, d, a, M_offset_0, 20, T[19]); + a = GG(a, b, c, d, M_offset_5, 5, T[20]); + d = GG(d, a, b, c, M_offset_10, 9, T[21]); + c = GG(c, d, a, b, M_offset_15, 14, T[22]); + b = GG(b, c, d, a, M_offset_4, 20, T[23]); + a = GG(a, b, c, d, M_offset_9, 5, T[24]); + d = GG(d, a, b, c, M_offset_14, 9, T[25]); + c = GG(c, d, a, b, M_offset_3, 14, T[26]); + b = GG(b, c, d, a, M_offset_8, 20, T[27]); + a = GG(a, b, c, d, M_offset_13, 5, T[28]); + d = GG(d, a, b, c, M_offset_2, 9, T[29]); + c = GG(c, d, a, b, M_offset_7, 14, T[30]); + b = GG(b, c, d, a, M_offset_12, 20, T[31]); + + a = HH(a, b, c, d, M_offset_5, 4, T[32]); + d = HH(d, a, b, c, M_offset_8, 11, T[33]); + c = HH(c, d, a, b, M_offset_11, 16, T[34]); + b = HH(b, c, d, a, M_offset_14, 23, T[35]); + a = HH(a, b, c, d, M_offset_1, 4, T[36]); + d = HH(d, a, b, c, M_offset_4, 11, T[37]); + c = HH(c, d, a, b, M_offset_7, 16, T[38]); + b = HH(b, c, d, a, M_offset_10, 23, T[39]); + a = HH(a, b, c, d, M_offset_13, 4, T[40]); + d = HH(d, a, b, c, M_offset_0, 11, T[41]); + c = HH(c, d, a, b, M_offset_3, 16, T[42]); + b = HH(b, c, d, a, M_offset_6, 23, T[43]); + a = HH(a, b, c, d, M_offset_9, 4, T[44]); + d = HH(d, a, b, c, M_offset_12, 11, T[45]); + c = HH(c, d, a, b, M_offset_15, 16, T[46]); + b = HH(b, c, d, a, M_offset_2, 23, T[47]); + + a = II(a, b, c, d, M_offset_0, 6, T[48]); + d = II(d, a, b, c, M_offset_7, 10, T[49]); + c = II(c, d, a, b, M_offset_14, 15, T[50]); + b = II(b, c, d, a, M_offset_5, 21, T[51]); + a = II(a, b, c, d, M_offset_12, 6, T[52]); + d = II(d, a, b, c, M_offset_3, 10, T[53]); + c = II(c, d, a, b, M_offset_10, 15, T[54]); + b = II(b, c, d, a, M_offset_1, 21, T[55]); + a = II(a, b, c, d, M_offset_8, 6, T[56]); + d = II(d, a, b, c, M_offset_15, 10, T[57]); + c = II(c, d, a, b, M_offset_6, 15, T[58]); + b = II(b, c, d, a, M_offset_13, 21, T[59]); + a = II(a, b, c, d, M_offset_4, 6, T[60]); + d = II(d, a, b, c, M_offset_11, 10, T[61]); + c = II(c, d, a, b, M_offset_2, 15, T[62]); + b = II(b, c, d, a, M_offset_9, 21, T[63]); + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + + var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000); + var nBitsTotalL = nBitsTotal; + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = ( + (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) | + (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00) + ); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) | + (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00) + ); + + data.sigBytes = (dataWords.length + 1) * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + var hash = this._hash; + var H = hash.words; + + // Swap endian + for (var i = 0; i < 4; i++) { + // Shortcut + var H_i = H[i]; + + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } + + // Return final computed hash + return hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + function FF(a, b, c, d, x, s, t) { + var n = a + ((b & c) | (~b & d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + function GG(a, b, c, d, x, s, t) { + var n = a + ((b & d) | (c & ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + function HH(a, b, c, d, x, s, t) { + var n = a + (b ^ c ^ d) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + function II(a, b, c, d, x, s, t) { + var n = a + (c ^ (b | ~d)) + x + t; + return ((n << s) | (n >>> (32 - s))) + b; + } + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.MD5('message'); + * var hash = CryptoJS.MD5(wordArray); + */ + C.MD5 = Hasher._createHelper(MD5); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacMD5(message, key); + */ + C.HmacMD5 = Hasher._createHmacHelper(MD5); + }(Math)); + + + return CryptoJS.MD5; + + })); + }(md5)); + return md5Exports; +} + +var sha1Exports = {}; +var sha1 = { + get exports() { + return sha1Exports; + }, + set exports(v) { + sha1Exports = v; + }, +}; + +var hasRequiredSha1; + +function requireSha1() { + if (hasRequiredSha1) return sha1Exports; + hasRequiredSha1 = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Reusable object + var W = []; + + /** + * SHA-1 hash algorithm. + */ + var SHA1 = C_algo.SHA1 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0x67452301, 0xefcdab89, + 0x98badcfe, 0x10325476, + 0xc3d2e1f0 + ]); + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var H = this._hash.words; + + // Working variables + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + + // Computation + for (var i = 0; i < 80; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var n = W[i - 3] ^ W[i - 8] ^ W[i - 14] ^ W[i - 16]; + W[i] = (n << 1) | (n >>> 31); + } + + var t = ((a << 5) | (a >>> 27)) + e + W[i]; + if (i < 20) { + t += ((b & c) | (~b & d)) + 0x5a827999; + } else if (i < 40) { + t += (b ^ c ^ d) + 0x6ed9eba1; + } else if (i < 60) { + t += ((b & c) | (b & d) | (c & d)) - 0x70e44324; + } else /* if (i < 80) */ + { + t += (b ^ c ^ d) - 0x359d3e2a; + } + + e = d; + d = c; + c = (b << 30) | (b >>> 2); + b = a; + a = t; + } + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Return final computed hash + return this._hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA1('message'); + * var hash = CryptoJS.SHA1(wordArray); + */ + C.SHA1 = Hasher._createHelper(SHA1); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA1(message, key); + */ + C.HmacSHA1 = Hasher._createHmacHelper(SHA1); + }()); + + + return CryptoJS.SHA1; + + })); + }(sha1)); + return sha1Exports; +} + +var sha256Exports = {}; +var sha256 = { + get exports() { + return sha256Exports; + }, + set exports(v) { + sha256Exports = v; + }, +}; + +var hasRequiredSha256; + +function requireSha256() { + if (hasRequiredSha256) return sha256Exports; + hasRequiredSha256 = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(Math){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Initialization and round constants tables + var H = []; + var K = []; + + // Compute constants + (function(){ + + function isPrime(n) { + var sqrtN = Math.sqrt(n); + for (var factor = 2; factor <= sqrtN; factor++) { + if (!(n % factor)) { + return false; + } + } + + return true; + } + + function getFractionalBits(n) { + return ((n - (n | 0)) * 0x100000000) | 0; + } + + var n = 2; + var nPrime = 0; + while (nPrime < 64) { + if (isPrime(n)) { + if (nPrime < 8) { + H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2)); + } + K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3)); + + nPrime++; + } + + n++; + } + }()); + + // Reusable object + var W = []; + + /** + * SHA-256 hash algorithm. + */ + var SHA256 = C_algo.SHA256 = Hasher.extend({ + _doReset: function () { + this._hash = new WordArray.init(H.slice(0)); + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var H = this._hash.words; + + // Working variables + var a = H[0]; + var b = H[1]; + var c = H[2]; + var d = H[3]; + var e = H[4]; + var f = H[5]; + var g = H[6]; + var h = H[7]; + + // Computation + for (var i = 0; i < 64; i++) { + if (i < 16) { + W[i] = M[offset + i] | 0; + } else { + var gamma0x = W[i - 15]; + var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^ + ((gamma0x << 14) | (gamma0x >>> 18)) ^ + (gamma0x >>> 3); + + var gamma1x = W[i - 2]; + var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^ + ((gamma1x << 13) | (gamma1x >>> 19)) ^ + (gamma1x >>> 10); + + W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16]; + } + + var ch = (e & f) ^ (~e & g); + var maj = (a & b) ^ (a & c) ^ (b & c); + + var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22)); + var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25)); + + var t1 = h + sigma1 + ch + K[i] + W[i]; + var t2 = sigma0 + maj; + + h = g; + g = f; + f = e; + e = (d + t1) | 0; + d = c; + c = b; + b = a; + a = (t1 + t2) | 0; + } + + // Intermediate hash value + H[0] = (H[0] + a) | 0; + H[1] = (H[1] + b) | 0; + H[2] = (H[2] + c) | 0; + H[3] = (H[3] + d) | 0; + H[4] = (H[4] + e) | 0; + H[5] = (H[5] + f) | 0; + H[6] = (H[6] + g) | 0; + H[7] = (H[7] + h) | 0; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Return final computed hash + return this._hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA256('message'); + * var hash = CryptoJS.SHA256(wordArray); + */ + C.SHA256 = Hasher._createHelper(SHA256); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA256(message, key); + */ + C.HmacSHA256 = Hasher._createHmacHelper(SHA256); + }(Math)); + + + return CryptoJS.SHA256; + + })); + }(sha256)); + return sha256Exports; +} + +var sha224Exports = {}; +var sha224 = { + get exports() { + return sha224Exports; + }, + set exports(v) { + sha224Exports = v; + }, +}; + +var hasRequiredSha224; + +function requireSha224() { + if (hasRequiredSha224) return sha224Exports; + hasRequiredSha224 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireSha256()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var SHA256 = C_algo.SHA256; + + /** + * SHA-224 hash algorithm. + */ + var SHA224 = C_algo.SHA224 = SHA256.extend({ + _doReset: function () { + this._hash = new WordArray.init([ + 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939, + 0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 + ]); + }, + + _doFinalize: function () { + var hash = SHA256._doFinalize.call(this); + + hash.sigBytes -= 4; + + return hash; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA224('message'); + * var hash = CryptoJS.SHA224(wordArray); + */ + C.SHA224 = SHA256._createHelper(SHA224); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA224(message, key); + */ + C.HmacSHA224 = SHA256._createHmacHelper(SHA224); + }()); + + + return CryptoJS.SHA224; + + })); + }(sha224)); + return sha224Exports; +} + +var sha512Exports = {}; +var sha512 = { + get exports() { + return sha512Exports; + }, + set exports(v) { + sha512Exports = v; + }, +}; + +var hasRequiredSha512; + +function requireSha512() { + if (hasRequiredSha512) return sha512Exports; + hasRequiredSha512 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireX64Core()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Hasher = C_lib.Hasher; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var X64WordArray = C_x64.WordArray; + var C_algo = C.algo; + + function X64Word_create() { + return X64Word.create.apply(X64Word, arguments); + } + + // Constants + var K = [ + X64Word_create(0x428a2f98, 0xd728ae22), X64Word_create(0x71374491, 0x23ef65cd), + X64Word_create(0xb5c0fbcf, 0xec4d3b2f), X64Word_create(0xe9b5dba5, 0x8189dbbc), + X64Word_create(0x3956c25b, 0xf348b538), X64Word_create(0x59f111f1, 0xb605d019), + X64Word_create(0x923f82a4, 0xaf194f9b), X64Word_create(0xab1c5ed5, 0xda6d8118), + X64Word_create(0xd807aa98, 0xa3030242), X64Word_create(0x12835b01, 0x45706fbe), + X64Word_create(0x243185be, 0x4ee4b28c), X64Word_create(0x550c7dc3, 0xd5ffb4e2), + X64Word_create(0x72be5d74, 0xf27b896f), X64Word_create(0x80deb1fe, 0x3b1696b1), + X64Word_create(0x9bdc06a7, 0x25c71235), X64Word_create(0xc19bf174, 0xcf692694), + X64Word_create(0xe49b69c1, 0x9ef14ad2), X64Word_create(0xefbe4786, 0x384f25e3), + X64Word_create(0x0fc19dc6, 0x8b8cd5b5), X64Word_create(0x240ca1cc, 0x77ac9c65), + X64Word_create(0x2de92c6f, 0x592b0275), X64Word_create(0x4a7484aa, 0x6ea6e483), + X64Word_create(0x5cb0a9dc, 0xbd41fbd4), X64Word_create(0x76f988da, 0x831153b5), + X64Word_create(0x983e5152, 0xee66dfab), X64Word_create(0xa831c66d, 0x2db43210), + X64Word_create(0xb00327c8, 0x98fb213f), X64Word_create(0xbf597fc7, 0xbeef0ee4), + X64Word_create(0xc6e00bf3, 0x3da88fc2), X64Word_create(0xd5a79147, 0x930aa725), + X64Word_create(0x06ca6351, 0xe003826f), X64Word_create(0x14292967, 0x0a0e6e70), + X64Word_create(0x27b70a85, 0x46d22ffc), X64Word_create(0x2e1b2138, 0x5c26c926), + X64Word_create(0x4d2c6dfc, 0x5ac42aed), X64Word_create(0x53380d13, 0x9d95b3df), + X64Word_create(0x650a7354, 0x8baf63de), X64Word_create(0x766a0abb, 0x3c77b2a8), + X64Word_create(0x81c2c92e, 0x47edaee6), X64Word_create(0x92722c85, 0x1482353b), + X64Word_create(0xa2bfe8a1, 0x4cf10364), X64Word_create(0xa81a664b, 0xbc423001), + X64Word_create(0xc24b8b70, 0xd0f89791), X64Word_create(0xc76c51a3, 0x0654be30), + X64Word_create(0xd192e819, 0xd6ef5218), X64Word_create(0xd6990624, 0x5565a910), + X64Word_create(0xf40e3585, 0x5771202a), X64Word_create(0x106aa070, 0x32bbd1b8), + X64Word_create(0x19a4c116, 0xb8d2d0c8), X64Word_create(0x1e376c08, 0x5141ab53), + X64Word_create(0x2748774c, 0xdf8eeb99), X64Word_create(0x34b0bcb5, 0xe19b48a8), + X64Word_create(0x391c0cb3, 0xc5c95a63), X64Word_create(0x4ed8aa4a, 0xe3418acb), + X64Word_create(0x5b9cca4f, 0x7763e373), X64Word_create(0x682e6ff3, 0xd6b2b8a3), + X64Word_create(0x748f82ee, 0x5defb2fc), X64Word_create(0x78a5636f, 0x43172f60), + X64Word_create(0x84c87814, 0xa1f0ab72), X64Word_create(0x8cc70208, 0x1a6439ec), + X64Word_create(0x90befffa, 0x23631e28), X64Word_create(0xa4506ceb, 0xde82bde9), + X64Word_create(0xbef9a3f7, 0xb2c67915), X64Word_create(0xc67178f2, 0xe372532b), + X64Word_create(0xca273ece, 0xea26619c), X64Word_create(0xd186b8c7, 0x21c0c207), + X64Word_create(0xeada7dd6, 0xcde0eb1e), X64Word_create(0xf57d4f7f, 0xee6ed178), + X64Word_create(0x06f067aa, 0x72176fba), X64Word_create(0x0a637dc5, 0xa2c898a6), + X64Word_create(0x113f9804, 0xbef90dae), X64Word_create(0x1b710b35, 0x131c471b), + X64Word_create(0x28db77f5, 0x23047d84), X64Word_create(0x32caab7b, 0x40c72493), + X64Word_create(0x3c9ebe0a, 0x15c9bebc), X64Word_create(0x431d67c4, 0x9c100d4c), + X64Word_create(0x4cc5d4be, 0xcb3e42b6), X64Word_create(0x597f299c, 0xfc657e2a), + X64Word_create(0x5fcb6fab, 0x3ad6faec), X64Word_create(0x6c44198c, 0x4a475817) + ]; + + // Reusable objects + var W = []; + (function(){ + for (var i = 0; i < 80; i++) { + W[i] = X64Word_create(); + } + }()); + + /** + * SHA-512 hash algorithm. + */ + var SHA512 = C_algo.SHA512 = Hasher.extend({ + _doReset: function () { + this._hash = new X64WordArray.init([ + new X64Word.init(0x6a09e667, 0xf3bcc908), new X64Word.init(0xbb67ae85, 0x84caa73b), + new X64Word.init(0x3c6ef372, 0xfe94f82b), new X64Word.init(0xa54ff53a, 0x5f1d36f1), + new X64Word.init(0x510e527f, 0xade682d1), new X64Word.init(0x9b05688c, 0x2b3e6c1f), + new X64Word.init(0x1f83d9ab, 0xfb41bd6b), new X64Word.init(0x5be0cd19, 0x137e2179) + ]); + }, + + _doProcessBlock: function (M, offset) { + // Shortcuts + var H = this._hash.words; + + var H0 = H[0]; + var H1 = H[1]; + var H2 = H[2]; + var H3 = H[3]; + var H4 = H[4]; + var H5 = H[5]; + var H6 = H[6]; + var H7 = H[7]; + + var H0h = H0.high; + var H0l = H0.low; + var H1h = H1.high; + var H1l = H1.low; + var H2h = H2.high; + var H2l = H2.low; + var H3h = H3.high; + var H3l = H3.low; + var H4h = H4.high; + var H4l = H4.low; + var H5h = H5.high; + var H5l = H5.low; + var H6h = H6.high; + var H6l = H6.low; + var H7h = H7.high; + var H7l = H7.low; + + // Working variables + var ah = H0h; + var al = H0l; + var bh = H1h; + var bl = H1l; + var ch = H2h; + var cl = H2l; + var dh = H3h; + var dl = H3l; + var eh = H4h; + var el = H4l; + var fh = H5h; + var fl = H5l; + var gh = H6h; + var gl = H6l; + var hh = H7h; + var hl = H7l; + + // Rounds + for (var i = 0; i < 80; i++) { + var Wil; + var Wih; + + // Shortcut + var Wi = W[i]; + + // Extend message + if (i < 16) { + Wih = Wi.high = M[offset + i * 2] | 0; + Wil = Wi.low = M[offset + i * 2 + 1] | 0; + } else { + // Gamma0 + var gamma0x = W[i - 15]; + var gamma0xh = gamma0x.high; + var gamma0xl = gamma0x.low; + var gamma0h = ((gamma0xh >>> 1) | (gamma0xl << 31)) ^ ((gamma0xh >>> 8) | (gamma0xl << 24)) ^ (gamma0xh >>> 7); + var gamma0l = ((gamma0xl >>> 1) | (gamma0xh << 31)) ^ ((gamma0xl >>> 8) | (gamma0xh << 24)) ^ ((gamma0xl >>> 7) | (gamma0xh << 25)); + + // Gamma1 + var gamma1x = W[i - 2]; + var gamma1xh = gamma1x.high; + var gamma1xl = gamma1x.low; + var gamma1h = ((gamma1xh >>> 19) | (gamma1xl << 13)) ^ ((gamma1xh << 3) | (gamma1xl >>> 29)) ^ (gamma1xh >>> 6); + var gamma1l = ((gamma1xl >>> 19) | (gamma1xh << 13)) ^ ((gamma1xl << 3) | (gamma1xh >>> 29)) ^ ((gamma1xl >>> 6) | (gamma1xh << 26)); + + // W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16] + var Wi7 = W[i - 7]; + var Wi7h = Wi7.high; + var Wi7l = Wi7.low; + + var Wi16 = W[i - 16]; + var Wi16h = Wi16.high; + var Wi16l = Wi16.low; + + Wil = gamma0l + Wi7l; + Wih = gamma0h + Wi7h + ((Wil >>> 0) < (gamma0l >>> 0) ? 1 : 0); + Wil = Wil + gamma1l; + Wih = Wih + gamma1h + ((Wil >>> 0) < (gamma1l >>> 0) ? 1 : 0); + Wil = Wil + Wi16l; + Wih = Wih + Wi16h + ((Wil >>> 0) < (Wi16l >>> 0) ? 1 : 0); + + Wi.high = Wih; + Wi.low = Wil; + } + + var chh = (eh & fh) ^ (~eh & gh); + var chl = (el & fl) ^ (~el & gl); + var majh = (ah & bh) ^ (ah & ch) ^ (bh & ch); + var majl = (al & bl) ^ (al & cl) ^ (bl & cl); + + var sigma0h = ((ah >>> 28) | (al << 4)) ^ ((ah << 30) | (al >>> 2)) ^ ((ah << 25) | (al >>> 7)); + var sigma0l = ((al >>> 28) | (ah << 4)) ^ ((al << 30) | (ah >>> 2)) ^ ((al << 25) | (ah >>> 7)); + var sigma1h = ((eh >>> 14) | (el << 18)) ^ ((eh >>> 18) | (el << 14)) ^ ((eh << 23) | (el >>> 9)); + var sigma1l = ((el >>> 14) | (eh << 18)) ^ ((el >>> 18) | (eh << 14)) ^ ((el << 23) | (eh >>> 9)); + + // t1 = h + sigma1 + ch + K[i] + W[i] + var Ki = K[i]; + var Kih = Ki.high; + var Kil = Ki.low; + + var t1l = hl + sigma1l; + var t1h = hh + sigma1h + ((t1l >>> 0) < (hl >>> 0) ? 1 : 0); + var t1l = t1l + chl; + var t1h = t1h + chh + ((t1l >>> 0) < (chl >>> 0) ? 1 : 0); + var t1l = t1l + Kil; + var t1h = t1h + Kih + ((t1l >>> 0) < (Kil >>> 0) ? 1 : 0); + var t1l = t1l + Wil; + var t1h = t1h + Wih + ((t1l >>> 0) < (Wil >>> 0) ? 1 : 0); + + // t2 = sigma0 + maj + var t2l = sigma0l + majl; + var t2h = sigma0h + majh + ((t2l >>> 0) < (sigma0l >>> 0) ? 1 : 0); + + // Update working variables + hh = gh; + hl = gl; + gh = fh; + gl = fl; + fh = eh; + fl = el; + el = (dl + t1l) | 0; + eh = (dh + t1h + ((el >>> 0) < (dl >>> 0) ? 1 : 0)) | 0; + dh = ch; + dl = cl; + ch = bh; + cl = bl; + bh = ah; + bl = al; + al = (t1l + t2l) | 0; + ah = (t1h + t2h + ((al >>> 0) < (t1l >>> 0) ? 1 : 0)) | 0; + } + + // Intermediate hash value + H0l = H0.low = (H0l + al); + H0.high = (H0h + ah + ((H0l >>> 0) < (al >>> 0) ? 1 : 0)); + H1l = H1.low = (H1l + bl); + H1.high = (H1h + bh + ((H1l >>> 0) < (bl >>> 0) ? 1 : 0)); + H2l = H2.low = (H2l + cl); + H2.high = (H2h + ch + ((H2l >>> 0) < (cl >>> 0) ? 1 : 0)); + H3l = H3.low = (H3l + dl); + H3.high = (H3h + dh + ((H3l >>> 0) < (dl >>> 0) ? 1 : 0)); + H4l = H4.low = (H4l + el); + H4.high = (H4h + eh + ((H4l >>> 0) < (el >>> 0) ? 1 : 0)); + H5l = H5.low = (H5l + fl); + H5.high = (H5h + fh + ((H5l >>> 0) < (fl >>> 0) ? 1 : 0)); + H6l = H6.low = (H6l + gl); + H6.high = (H6h + gh + ((H6l >>> 0) < (gl >>> 0) ? 1 : 0)); + H7l = H7.low = (H7l + hl); + H7.high = (H7h + hh + ((H7l >>> 0) < (hl >>> 0) ? 1 : 0)); + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 30] = Math.floor(nBitsTotal / 0x100000000); + dataWords[(((nBitsLeft + 128) >>> 10) << 5) + 31] = nBitsTotal; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Convert hash to 32-bit word array before returning + var hash = this._hash.toX32(); + + // Return final computed hash + return hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + }, + + blockSize: 1024 / 32 + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA512('message'); + * var hash = CryptoJS.SHA512(wordArray); + */ + C.SHA512 = Hasher._createHelper(SHA512); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA512(message, key); + */ + C.HmacSHA512 = Hasher._createHmacHelper(SHA512); + }()); + + + return CryptoJS.SHA512; + + })); + }(sha512)); + return sha512Exports; +} + +var sha384Exports = {}; +var sha384 = { + get exports() { + return sha384Exports; + }, + set exports(v) { + sha384Exports = v; + }, +}; + +var hasRequiredSha384; + +function requireSha384() { + if (hasRequiredSha384) return sha384Exports; + hasRequiredSha384 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireX64Core(), requireSha512()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var X64WordArray = C_x64.WordArray; + var C_algo = C.algo; + var SHA512 = C_algo.SHA512; + + /** + * SHA-384 hash algorithm. + */ + var SHA384 = C_algo.SHA384 = SHA512.extend({ + _doReset: function () { + this._hash = new X64WordArray.init([ + new X64Word.init(0xcbbb9d5d, 0xc1059ed8), new X64Word.init(0x629a292a, 0x367cd507), + new X64Word.init(0x9159015a, 0x3070dd17), new X64Word.init(0x152fecd8, 0xf70e5939), + new X64Word.init(0x67332667, 0xffc00b31), new X64Word.init(0x8eb44a87, 0x68581511), + new X64Word.init(0xdb0c2e0d, 0x64f98fa7), new X64Word.init(0x47b5481d, 0xbefa4fa4) + ]); + }, + + _doFinalize: function () { + var hash = SHA512._doFinalize.call(this); + + hash.sigBytes -= 16; + + return hash; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA384('message'); + * var hash = CryptoJS.SHA384(wordArray); + */ + C.SHA384 = SHA512._createHelper(SHA384); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA384(message, key); + */ + C.HmacSHA384 = SHA512._createHmacHelper(SHA384); + }()); + + + return CryptoJS.SHA384; + + })); + }(sha384)); + return sha384Exports; +} + +var sha3Exports = {}; +var sha3 = { + get exports() { + return sha3Exports; + }, + set exports(v) { + sha3Exports = v; + }, +}; + +var hasRequiredSha3; + +function requireSha3() { + if (hasRequiredSha3) return sha3Exports; + hasRequiredSha3 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireX64Core()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(Math){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_x64 = C.x64; + var X64Word = C_x64.Word; + var C_algo = C.algo; + + // Constants tables + var RHO_OFFSETS = []; + var PI_INDEXES = []; + var ROUND_CONSTANTS = []; + + // Compute Constants + (function(){ + // Compute rho offset constants + var x = 1, y = 0; + for (var t = 0; t < 24; t++) { + RHO_OFFSETS[x + 5 * y] = ((t + 1) * (t + 2) / 2) % 64; + + var newX = y % 5; + var newY = (2 * x + 3 * y) % 5; + x = newX; + y = newY; + } + + // Compute pi index constants + for (var x = 0; x < 5; x++) { + for (var y = 0; y < 5; y++) { + PI_INDEXES[x + 5 * y] = y + ((2 * x + 3 * y) % 5) * 5; + } + } + + // Compute round constants + var LFSR = 0x01; + for (var i = 0; i < 24; i++) { + var roundConstantMsw = 0; + var roundConstantLsw = 0; + + for (var j = 0; j < 7; j++) { + if (LFSR & 0x01) { + var bitPosition = (1 << j) - 1; + if (bitPosition < 32) { + roundConstantLsw ^= 1 << bitPosition; + } else /* if (bitPosition >= 32) */ + { + roundConstantMsw ^= 1 << (bitPosition - 32); + } + } + + // Compute next LFSR + if (LFSR & 0x80) { + // Primitive polynomial over GF(2): x^8 + x^6 + x^5 + x^4 + 1 + LFSR = (LFSR << 1) ^ 0x71; + } else { + LFSR <<= 1; + } + } + + ROUND_CONSTANTS[i] = X64Word.create(roundConstantMsw, roundConstantLsw); + } + }()); + + // Reusable objects for temporary values + var T = []; + (function(){ + for (var i = 0; i < 25; i++) { + T[i] = X64Word.create(); + } + }()); + + /** + * SHA-3 hash algorithm. + */ + var SHA3 = C_algo.SHA3 = Hasher.extend({ + /** + * Configuration options. + * + * @property {number} outputLength + * The desired number of bits in the output hash. + * Only values permitted are: 224, 256, 384, 512. + * Default: 512 + */ + cfg: Hasher.cfg.extend({ + outputLength: 512 + }), + + _doReset: function () { + var state = this._state = []; + for (var i = 0; i < 25; i++) { + state[i] = new X64Word.init(); + } + + this.blockSize = (1600 - 2 * this.cfg.outputLength) / 32; + }, + + _doProcessBlock: function (M, offset) { + // Shortcuts + var state = this._state; + var nBlockSizeLanes = this.blockSize / 2; + + // Absorb + for (var i = 0; i < nBlockSizeLanes; i++) { + // Shortcuts + var M2i = M[offset + 2 * i]; + var M2i1 = M[offset + 2 * i + 1]; + + // Swap endian + M2i = ( + (((M2i << 8) | (M2i >>> 24)) & 0x00ff00ff) | + (((M2i << 24) | (M2i >>> 8)) & 0xff00ff00) + ); + M2i1 = ( + (((M2i1 << 8) | (M2i1 >>> 24)) & 0x00ff00ff) | + (((M2i1 << 24) | (M2i1 >>> 8)) & 0xff00ff00) + ); + + // Absorb message into state + var lane = state[i]; + lane.high ^= M2i1; + lane.low ^= M2i; + } + + // Rounds + for (var round = 0; round < 24; round++) { + // Theta + for (var x = 0; x < 5; x++) { + // Mix column lanes + var tMsw = 0, tLsw = 0; + for (var y = 0; y < 5; y++) { + var lane = state[x + 5 * y]; + tMsw ^= lane.high; + tLsw ^= lane.low; + } + + // Temporary values + var Tx = T[x]; + Tx.high = tMsw; + Tx.low = tLsw; + } + for (var x = 0; x < 5; x++) { + // Shortcuts + var Tx4 = T[(x + 4) % 5]; + var Tx1 = T[(x + 1) % 5]; + var Tx1Msw = Tx1.high; + var Tx1Lsw = Tx1.low; + + // Mix surrounding columns + var tMsw = Tx4.high ^ ((Tx1Msw << 1) | (Tx1Lsw >>> 31)); + var tLsw = Tx4.low ^ ((Tx1Lsw << 1) | (Tx1Msw >>> 31)); + for (var y = 0; y < 5; y++) { + var lane = state[x + 5 * y]; + lane.high ^= tMsw; + lane.low ^= tLsw; + } + } + + // Rho Pi + for (var laneIndex = 1; laneIndex < 25; laneIndex++) { + var tMsw; + var tLsw; + + // Shortcuts + var lane = state[laneIndex]; + var laneMsw = lane.high; + var laneLsw = lane.low; + var rhoOffset = RHO_OFFSETS[laneIndex]; + + // Rotate lanes + if (rhoOffset < 32) { + tMsw = (laneMsw << rhoOffset) | (laneLsw >>> (32 - rhoOffset)); + tLsw = (laneLsw << rhoOffset) | (laneMsw >>> (32 - rhoOffset)); + } else /* if (rhoOffset >= 32) */ + { + tMsw = (laneLsw << (rhoOffset - 32)) | (laneMsw >>> (64 - rhoOffset)); + tLsw = (laneMsw << (rhoOffset - 32)) | (laneLsw >>> (64 - rhoOffset)); + } + + // Transpose lanes + var TPiLane = T[PI_INDEXES[laneIndex]]; + TPiLane.high = tMsw; + TPiLane.low = tLsw; + } + + // Rho pi at x = y = 0 + var T0 = T[0]; + var state0 = state[0]; + T0.high = state0.high; + T0.low = state0.low; + + // Chi + for (var x = 0; x < 5; x++) { + for (var y = 0; y < 5; y++) { + // Shortcuts + var laneIndex = x + 5 * y; + var lane = state[laneIndex]; + var TLane = T[laneIndex]; + var Tx1Lane = T[((x + 1) % 5) + 5 * y]; + var Tx2Lane = T[((x + 2) % 5) + 5 * y]; + + // Mix rows + lane.high = TLane.high ^ (~Tx1Lane.high & Tx2Lane.high); + lane.low = TLane.low ^ (~Tx1Lane.low & Tx2Lane.low); + } + } + + // Iota + var lane = state[0]; + var roundConstant = ROUND_CONSTANTS[round]; + lane.high ^= roundConstant.high; + lane.low ^= roundConstant.low; + } + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + var blockSizeBits = this.blockSize * 32; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x1 << (24 - nBitsLeft % 32); + dataWords[((Math.ceil((nBitsLeft + 1) / blockSizeBits) * blockSizeBits) >>> 5) - 1] |= 0x80; + data.sigBytes = dataWords.length * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + var state = this._state; + var outputLengthBytes = this.cfg.outputLength / 8; + var outputLengthLanes = outputLengthBytes / 8; + + // Squeeze + var hashWords = []; + for (var i = 0; i < outputLengthLanes; i++) { + // Shortcuts + var lane = state[i]; + var laneMsw = lane.high; + var laneLsw = lane.low; + + // Swap endian + laneMsw = ( + (((laneMsw << 8) | (laneMsw >>> 24)) & 0x00ff00ff) | + (((laneMsw << 24) | (laneMsw >>> 8)) & 0xff00ff00) + ); + laneLsw = ( + (((laneLsw << 8) | (laneLsw >>> 24)) & 0x00ff00ff) | + (((laneLsw << 24) | (laneLsw >>> 8)) & 0xff00ff00) + ); + + // Squeeze state to retrieve hash + hashWords.push(laneLsw); + hashWords.push(laneMsw); + } + + // Return final computed hash + return new WordArray.init(hashWords, outputLengthBytes); + }, + + clone: function () { + var clone = Hasher.clone.call(this); + + var state = clone._state = this._state.slice(0); + for (var i = 0; i < 25; i++) { + state[i] = state[i].clone(); + } + + return clone; + } + }); + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.SHA3('message'); + * var hash = CryptoJS.SHA3(wordArray); + */ + C.SHA3 = Hasher._createHelper(SHA3); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacSHA3(message, key); + */ + C.HmacSHA3 = Hasher._createHmacHelper(SHA3); + }(Math)); + + + return CryptoJS.SHA3; + + })); + }(sha3)); + return sha3Exports; +} + +var ripemd160Exports = {}; +var ripemd160 = { + get exports() { + return ripemd160Exports; + }, + set exports(v) { + ripemd160Exports = v; + }, +}; + +var hasRequiredRipemd160; + +function requireRipemd160() { + if (hasRequiredRipemd160) return ripemd160Exports; + hasRequiredRipemd160 = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** @preserve + (c) 2012 by Cédric Mesnil. All rights reserved. + + Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: + + - Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. + - Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + + (function(Math){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var Hasher = C_lib.Hasher; + var C_algo = C.algo; + + // Constants table + var _zl = WordArray.create([ + 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, + 7, 4, 13, 1, 10, 6, 15, 3, 12, 0, 9, 5, 2, 14, 11, 8, + 3, 10, 14, 4, 9, 15, 8, 1, 2, 7, 0, 6, 13, 11, 5, 12, + 1, 9, 11, 10, 0, 8, 12, 4, 13, 3, 7, 15, 14, 5, 6, 2, + 4, 0, 5, 9, 7, 12, 2, 10, 14, 1, 3, 8, 11, 6, 15, 13]); + var _zr = WordArray.create([ + 5, 14, 7, 0, 9, 2, 11, 4, 13, 6, 15, 8, 1, 10, 3, 12, + 6, 11, 3, 7, 0, 13, 5, 10, 14, 15, 8, 12, 4, 9, 1, 2, + 15, 5, 1, 3, 7, 14, 6, 9, 11, 8, 12, 2, 10, 0, 4, 13, + 8, 6, 4, 1, 3, 11, 15, 0, 5, 12, 2, 13, 9, 7, 10, 14, + 12, 15, 10, 4, 1, 5, 8, 7, 6, 2, 13, 14, 0, 3, 9, 11]); + var _sl = WordArray.create([ + 11, 14, 15, 12, 5, 8, 7, 9, 11, 13, 14, 15, 6, 7, 9, 8, + 7, 6, 8, 13, 11, 9, 7, 15, 7, 12, 15, 9, 11, 7, 13, 12, + 11, 13, 6, 7, 14, 9, 13, 15, 14, 8, 13, 6, 5, 12, 7, 5, + 11, 12, 14, 15, 14, 15, 9, 8, 9, 14, 5, 6, 8, 6, 5, 12, + 9, 15, 5, 11, 6, 8, 13, 12, 5, 12, 13, 14, 11, 8, 5, 6]); + var _sr = WordArray.create([ + 8, 9, 9, 11, 13, 15, 15, 5, 7, 7, 8, 11, 14, 14, 12, 6, + 9, 13, 15, 7, 12, 8, 9, 11, 7, 7, 12, 7, 6, 15, 13, 11, + 9, 7, 15, 11, 8, 6, 6, 14, 12, 13, 5, 14, 13, 13, 7, 5, + 15, 5, 8, 11, 14, 14, 6, 14, 6, 9, 12, 9, 12, 5, 15, 8, + 8, 5, 12, 9, 12, 5, 14, 6, 8, 13, 6, 5, 15, 13, 11, 11]); + + var _hl = WordArray.create([0x00000000, 0x5A827999, 0x6ED9EBA1, 0x8F1BBCDC, 0xA953FD4E]); + var _hr = WordArray.create([0x50A28BE6, 0x5C4DD124, 0x6D703EF3, 0x7A6D76E9, 0x00000000]); + + /** + * RIPEMD160 hash algorithm. + */ + var RIPEMD160 = C_algo.RIPEMD160 = Hasher.extend({ + _doReset: function () { + this._hash = WordArray.create([0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0]); + }, + + _doProcessBlock: function (M, offset) { + + // Swap endian + for (var i = 0; i < 16; i++) { + // Shortcuts + var offset_i = offset + i; + var M_offset_i = M[offset_i]; + + // Swap + M[offset_i] = ( + (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) | + (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00) + ); + } + // Shortcut + var H = this._hash.words; + var hl = _hl.words; + var hr = _hr.words; + var zl = _zl.words; + var zr = _zr.words; + var sl = _sl.words; + var sr = _sr.words; + + // Working variables + var al, bl, cl, dl, el; + var ar, br, cr, dr, er; + + ar = al = H[0]; + br = bl = H[1]; + cr = cl = H[2]; + dr = dl = H[3]; + er = el = H[4]; + // Computation + var t; + for (var i = 0; i < 80; i += 1) { + t = (al + M[offset+zl[i]]) | 0; + if (i < 16) { + t += f1(bl, cl, dl) + hl[0]; + } else if (i < 32) { + t += f2(bl, cl, dl) + hl[1]; + } else if (i < 48) { + t += f3(bl, cl, dl) + hl[2]; + } else if (i < 64) { + t += f4(bl, cl, dl) + hl[3]; + } else { // if (i<80) { + t += f5(bl, cl, dl) + hl[4]; + } + t = t | 0; + t = rotl(t, sl[i]); + t = (t + el) | 0; + al = el; + el = dl; + dl = rotl(cl, 10); + cl = bl; + bl = t; + + t = (ar + M[offset+zr[i]]) | 0; + if (i < 16) { + t += f5(br, cr, dr) + hr[0]; + } else if (i < 32) { + t += f4(br, cr, dr) + hr[1]; + } else if (i < 48) { + t += f3(br, cr, dr) + hr[2]; + } else if (i < 64) { + t += f2(br, cr, dr) + hr[3]; + } else { // if (i<80) { + t += f1(br, cr, dr) + hr[4]; + } + t = t | 0; + t = rotl(t, sr[i]); + t = (t + er) | 0; + ar = er; + er = dr; + dr = rotl(cr, 10); + cr = br; + br = t; + } + // Intermediate hash value + t = (H[1] + cl + dr) | 0; + H[1] = (H[2] + dl + er) | 0; + H[2] = (H[3] + el + ar) | 0; + H[3] = (H[4] + al + br) | 0; + H[4] = (H[0] + bl + cr) | 0; + H[0] = t; + }, + + _doFinalize: function () { + // Shortcuts + var data = this._data; + var dataWords = data.words; + + var nBitsTotal = this._nDataBytes * 8; + var nBitsLeft = data.sigBytes * 8; + + // Add padding + dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32); + dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = ( + (((nBitsTotal << 8) | (nBitsTotal >>> 24)) & 0x00ff00ff) | + (((nBitsTotal << 24) | (nBitsTotal >>> 8)) & 0xff00ff00) + ); + data.sigBytes = (dataWords.length + 1) * 4; + + // Hash final blocks + this._process(); + + // Shortcuts + var hash = this._hash; + var H = hash.words; + + // Swap endian + for (var i = 0; i < 5; i++) { + // Shortcut + var H_i = H[i]; + + // Swap + H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) | + (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00); + } + + // Return final computed hash + return hash; + }, + + clone: function () { + var clone = Hasher.clone.call(this); + clone._hash = this._hash.clone(); + + return clone; + } + }); + + + function f1(x, y, z) { + return ((x) ^ (y) ^ (z)); + + } + + function f2(x, y, z) { + return (((x) & (y)) | ((~x) & (z))); + } + + function f3(x, y, z) { + return (((x) | (~(y))) ^ (z)); + } + + function f4(x, y, z) { + return (((x) & (z)) | ((y) & (~(z)))); + } + + function f5(x, y, z) { + return ((x) ^ ((y) | (~(z)))); + + } + + function rotl(x, n) { + return (x << n) | (x >>> (32 - n)); + } + + + /** + * Shortcut function to the hasher's object interface. + * + * @param {WordArray|string} message The message to hash. + * + * @return {WordArray} The hash. + * + * @static + * + * @example + * + * var hash = CryptoJS.RIPEMD160('message'); + * var hash = CryptoJS.RIPEMD160(wordArray); + */ + C.RIPEMD160 = Hasher._createHelper(RIPEMD160); + + /** + * Shortcut function to the HMAC's object interface. + * + * @param {WordArray|string} message The message to hash. + * @param {WordArray|string} key The secret key. + * + * @return {WordArray} The HMAC. + * + * @static + * + * @example + * + * var hmac = CryptoJS.HmacRIPEMD160(message, key); + */ + C.HmacRIPEMD160 = Hasher._createHmacHelper(RIPEMD160); + }()); + + + return CryptoJS.RIPEMD160; + + })); + }(ripemd160)); + return ripemd160Exports; +} + +var hmacExports = {}; +var hmac = { + get exports() { + return hmacExports; + }, + set exports(v) { + hmacExports = v; + }, +}; + +var hasRequiredHmac; + +function requireHmac() { + if (hasRequiredHmac) return hmacExports; + hasRequiredHmac = 1; + (function(module, exports){ + (function(root, factory){ + { + // CommonJS + module.exports = factory(requireCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var C_enc = C.enc; + var Utf8 = C_enc.Utf8; + var C_algo = C.algo; + + /** + * HMAC algorithm. + */ + C_algo.HMAC = Base.extend({ + /** + * Initializes a newly created HMAC. + * + * @param {Hasher} hasher The hash algorithm to use. + * @param {WordArray|string} key The secret key. + * + * @example + * + * var hmacHasher = CryptoJS.algo.HMAC.create(CryptoJS.algo.SHA256, key); + */ + init: function (hasher, key) { + // Init hasher + hasher = this._hasher = new hasher.init(); + + // Convert string to WordArray, else assume WordArray already + if (typeof key == 'string') { + key = Utf8.parse(key); + } + + // Shortcuts + var hasherBlockSize = hasher.blockSize; + var hasherBlockSizeBytes = hasherBlockSize * 4; + + // Allow arbitrary length keys + if (key.sigBytes > hasherBlockSizeBytes) { + key = hasher.finalize(key); + } + + // Clamp excess bits + key.clamp(); + + // Clone key for inner and outer pads + var oKey = this._oKey = key.clone(); + var iKey = this._iKey = key.clone(); + + // Shortcuts + var oKeyWords = oKey.words; + var iKeyWords = iKey.words; + + // XOR keys with pad constants + for (var i = 0; i < hasherBlockSize; i++) { + oKeyWords[i] ^= 0x5c5c5c5c; + iKeyWords[i] ^= 0x36363636; + } + oKey.sigBytes = iKey.sigBytes = hasherBlockSizeBytes; + + // Set initial values + this.reset(); + }, + + /** + * Resets this HMAC to its initial state. + * + * @example + * + * hmacHasher.reset(); + */ + reset: function () { + // Shortcut + var hasher = this._hasher; + + // Reset + hasher.reset(); + hasher.update(this._iKey); + }, + + /** + * Updates this HMAC with a message. + * + * @param {WordArray|string} messageUpdate The message to append. + * + * @return {HMAC} This HMAC instance. + * + * @example + * + * hmacHasher.update('message'); + * hmacHasher.update(wordArray); + */ + update: function (messageUpdate) { + this._hasher.update(messageUpdate); + + // Chainable + return this; + }, + + /** + * Finalizes the HMAC computation. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} messageUpdate (Optional) A final message update. + * + * @return {WordArray} The HMAC. + * + * @example + * + * var hmac = hmacHasher.finalize(); + * var hmac = hmacHasher.finalize('message'); + * var hmac = hmacHasher.finalize(wordArray); + */ + finalize: function (messageUpdate) { + // Shortcut + var hasher = this._hasher; + + // Compute HMAC + var innerHash = hasher.finalize(messageUpdate); + hasher.reset(); + var hmac = hasher.finalize(this._oKey.clone().concat(innerHash)); + + return hmac; + } + }); + }()); + + + })); + }(hmac)); + return hmacExports; +} + +var pbkdf2Exports = {}; +var pbkdf2 = { + get exports() { + return pbkdf2Exports; + }, + set exports(v) { + pbkdf2Exports = v; + }, +}; + +var hasRequiredPbkdf2; + +function requirePbkdf2() { + if (hasRequiredPbkdf2) return pbkdf2Exports; + hasRequiredPbkdf2 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireSha1(), requireHmac()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var SHA256 = C_algo.SHA256; + var HMAC = C_algo.HMAC; + + /** + * Password-Based Key Derivation Function 2 algorithm. + */ + var PBKDF2 = C_algo.PBKDF2 = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hasher to use. Default: SHA256 + * @property {number} iterations The number of iterations to perform. Default: 250000 + */ + cfg: Base.extend({ + keySize: 128 / 32, + hasher: SHA256, + iterations: 250000 + }), + + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.PBKDF2.create(); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.PBKDF2.create({ keySize: 8, iterations: 1000 }); + */ + init: function (cfg) { + this.cfg = this.cfg.extend(cfg); + }, + + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function (password, salt) { + // Shortcut + var cfg = this.cfg; + + // Init HMAC + var hmac = HMAC.create(cfg.hasher, password); + + // Initial values + var derivedKey = WordArray.create(); + var blockIndex = WordArray.create([0x00000001]); + + // Shortcuts + var derivedKeyWords = derivedKey.words; + var blockIndexWords = blockIndex.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; + + // Generate key + while (derivedKeyWords.length < keySize) { + var block = hmac.update(salt).finalize(blockIndex); + hmac.reset(); + + // Shortcuts + var blockWords = block.words; + var blockWordsLength = blockWords.length; + + // Iterations + var intermediate = block; + for (var i = 1; i < iterations; i++) { + intermediate = hmac.finalize(intermediate); + hmac.reset(); + + // Shortcut + var intermediateWords = intermediate.words; + + // XOR intermediate with block + for (var j = 0; j < blockWordsLength; j++) { + blockWords[j] ^= intermediateWords[j]; + } + } + + derivedKey.concat(block); + blockIndexWords[0]++; + } + derivedKey.sigBytes = keySize * 4; + + return derivedKey; + } + }); + + /** + * Computes the Password-Based Key Derivation Function 2. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.PBKDF2(password, salt); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8 }); + * var key = CryptoJS.PBKDF2(password, salt, { keySize: 8, iterations: 1000 }); + */ + C.PBKDF2 = function (password, salt, cfg) { + return PBKDF2.create(cfg).compute(password, salt); + }; + }()); + + + return CryptoJS.PBKDF2; + + })); + }(pbkdf2)); + return pbkdf2Exports; +} + +var evpkdfExports = {}; +var evpkdf = { + get exports() { + return evpkdfExports; + }, + set exports(v) { + evpkdfExports = v; + }, +}; + +var hasRequiredEvpkdf; + +function requireEvpkdf() { + if (hasRequiredEvpkdf) return evpkdfExports; + hasRequiredEvpkdf = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireSha1(), requireHmac()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var C_algo = C.algo; + var MD5 = C_algo.MD5; + + /** + * This key derivation function is meant to conform with EVP_BytesToKey. + * www.openssl.org/docs/crypto/EVP_BytesToKey.html + */ + var EvpKDF = C_algo.EvpKDF = Base.extend({ + /** + * Configuration options. + * + * @property {number} keySize The key size in words to generate. Default: 4 (128 bits) + * @property {Hasher} hasher The hash algorithm to use. Default: MD5 + * @property {number} iterations The number of iterations to perform. Default: 1 + */ + cfg: Base.extend({ + keySize: 128 / 32, + hasher: MD5, + iterations: 1 + }), + + /** + * Initializes a newly created key derivation function. + * + * @param {Object} cfg (Optional) The configuration options to use for the derivation. + * + * @example + * + * var kdf = CryptoJS.algo.EvpKDF.create(); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 }); + * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 }); + */ + init: function (cfg) { + this.cfg = this.cfg.extend(cfg); + }, + + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * + * @return {WordArray} The derived key. + * + * @example + * + * var key = kdf.compute(password, salt); + */ + compute: function (password, salt) { + var block; + + // Shortcut + var cfg = this.cfg; + + // Init hasher + var hasher = cfg.hasher.create(); + + // Initial values + var derivedKey = WordArray.create(); + + // Shortcuts + var derivedKeyWords = derivedKey.words; + var keySize = cfg.keySize; + var iterations = cfg.iterations; + + // Generate key + while (derivedKeyWords.length < keySize) { + if (block) { + hasher.update(block); + } + block = hasher.update(password).finalize(salt); + hasher.reset(); + + // Iterations + for (var i = 1; i < iterations; i++) { + block = hasher.finalize(block); + hasher.reset(); + } + + derivedKey.concat(block); + } + derivedKey.sigBytes = keySize * 4; + + return derivedKey; + } + }); + + /** + * Derives a key from a password. + * + * @param {WordArray|string} password The password. + * @param {WordArray|string} salt A salt. + * @param {Object} cfg (Optional) The configuration options to use for this computation. + * + * @return {WordArray} The derived key. + * + * @static + * + * @example + * + * var key = CryptoJS.EvpKDF(password, salt); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 }); + * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 }); + */ + C.EvpKDF = function (password, salt, cfg) { + return EvpKDF.create(cfg).compute(password, salt); + }; + }()); + + + return CryptoJS.EvpKDF; + + })); + }(evpkdf)); + return evpkdfExports; +} + +var cipherCoreExports = {}; +var cipherCore = { + get exports() { + return cipherCoreExports; + }, + set exports(v) { + cipherCoreExports = v; + }, +}; + +var hasRequiredCipherCore; + +function requireCipherCore() { + if (hasRequiredCipherCore) return cipherCoreExports; + hasRequiredCipherCore = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireEvpkdf()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * Cipher core components. + */ + CryptoJS.lib.Cipher || (function(undefined$1){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var Base = C_lib.Base; + var WordArray = C_lib.WordArray; + var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm; + var C_enc = C.enc; + C_enc.Utf8; + var Base64 = C_enc.Base64; + var C_algo = C.algo; + var EvpKDF = C_algo.EvpKDF; + + /** + * Abstract base cipher template. + * + * @property {number} keySize This cipher's key size. Default: 4 (128 bits) + * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits) + * @property {number} _ENC_XFORM_MODE A constant representing encryption mode. + * @property {number} _DEC_XFORM_MODE A constant representing decryption mode. + */ + var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({ + /** + * Configuration options. + * + * @property {WordArray} iv The IV to use for this operation. + */ + cfg: Base.extend(), + + /** + * Creates this cipher in encryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray }); + */ + createEncryptor: function (key, cfg) { + return this.create(this._ENC_XFORM_MODE, key, cfg); + }, + + /** + * Creates this cipher in decryption mode. + * + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {Cipher} A cipher instance. + * + * @static + * + * @example + * + * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray }); + */ + createDecryptor: function (key, cfg) { + return this.create(this._DEC_XFORM_MODE, key, cfg); + }, + + /** + * Initializes a newly created cipher. + * + * @param {number} xformMode Either the encryption or decryption transormation mode constant. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @example + * + * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray }); + */ + init: function (xformMode, key, cfg) { + // Apply config defaults + this.cfg = this.cfg.extend(cfg); + + // Store transform mode and key + this._xformMode = xformMode; + this._key = key; + + // Set initial values + this.reset(); + }, + + /** + * Resets this cipher to its initial state. + * + * @example + * + * cipher.reset(); + */ + reset: function () { + // Reset data buffer + BufferedBlockAlgorithm.reset.call(this); + + // Perform concrete-cipher logic + this._doReset(); + }, + + /** + * Adds data to be encrypted or decrypted. + * + * @param {WordArray|string} dataUpdate The data to encrypt or decrypt. + * + * @return {WordArray} The data after processing. + * + * @example + * + * var encrypted = cipher.process('data'); + * var encrypted = cipher.process(wordArray); + */ + process: function (dataUpdate) { + // Append + this._append(dataUpdate); + + // Process available blocks + return this._process(); + }, + + /** + * Finalizes the encryption or decryption process. + * Note that the finalize operation is effectively a destructive, read-once operation. + * + * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt. + * + * @return {WordArray} The data after final processing. + * + * @example + * + * var encrypted = cipher.finalize(); + * var encrypted = cipher.finalize('data'); + * var encrypted = cipher.finalize(wordArray); + */ + finalize: function (dataUpdate) { + // Final data update + if (dataUpdate) { + this._append(dataUpdate); + } + + // Perform concrete-cipher logic + var finalProcessedData = this._doFinalize(); + + return finalProcessedData; + }, + + keySize: 128 / 32, + + ivSize: 128 / 32, + + _ENC_XFORM_MODE: 1, + + _DEC_XFORM_MODE: 2, + + /** + * Creates shortcut functions to a cipher's object interface. + * + * @param {Cipher} cipher The cipher to create a helper for. + * + * @return {Object} An object with encrypt and decrypt shortcut functions. + * + * @static + * + * @example + * + * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES); + */ + _createHelper: (function(){ + + function selectCipherStrategy(key) { + if (typeof key == 'string') { + return PasswordBasedCipher; + } else { + return SerializableCipher; + } + } + + return function (cipher) { + return { + encrypt: function (message, key, cfg) { + return selectCipherStrategy(key).encrypt(cipher, message, key, cfg); + }, + + decrypt: function (ciphertext, key, cfg) { + return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg); + } + }; + }; + }()) + }); + + /** + * Abstract base stream cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits) + */ + C_lib.StreamCipher = Cipher.extend({ + _doFinalize: function () { + // Process partial blocks + var finalProcessedBlocks = this._process(!!'flush'); + + return finalProcessedBlocks; + }, + + blockSize: 1 + }); + + /** + * Mode namespace. + */ + var C_mode = C.mode = {}; + + /** + * Abstract base block cipher mode template. + */ + var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({ + /** + * Creates this mode for encryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words); + */ + createEncryptor: function (cipher, iv) { + return this.Encryptor.create(cipher, iv); + }, + + /** + * Creates this mode for decryption. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @static + * + * @example + * + * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words); + */ + createDecryptor: function (cipher, iv) { + return this.Decryptor.create(cipher, iv); + }, + + /** + * Initializes a newly created mode. + * + * @param {Cipher} cipher A block cipher instance. + * @param {Array} iv The IV words. + * + * @example + * + * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words); + */ + init: function (cipher, iv) { + this._cipher = cipher; + this._iv = iv; + } + }); + + /** + * Cipher Block Chaining mode. + */ + var CBC = C_mode.CBC = (function(){ + /** + * Abstract base CBC mode. + */ + var CBC = BlockCipherMode.extend(); + + /** + * CBC encryptor. + */ + CBC.Encryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // XOR and encrypt + xorBlock.call(this, words, offset, blockSize); + cipher.encryptBlock(words, offset); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + + /** + * CBC decryptor. + */ + CBC.Decryptor = CBC.extend({ + /** + * Processes the data block at offset. + * + * @param {Array} words The data words to operate on. + * @param {number} offset The offset where the block starts. + * + * @example + * + * mode.processBlock(data.words, offset); + */ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); + + // Decrypt and XOR + cipher.decryptBlock(words, offset); + xorBlock.call(this, words, offset, blockSize); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } + }); + + function xorBlock(words, offset, blockSize) { + var block; + + // Shortcut + var iv = this._iv; + + // Choose mixing block + if (iv) { + block = iv; + + // Remove IV for subsequent blocks + this._iv = undefined$1; + } else { + block = this._prevBlock; + } + + // XOR blocks + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= block[i]; + } + } + + return CBC; + }()); + + /** + * Padding namespace. + */ + var C_pad = C.pad = {}; + + /** + * PKCS #5/7 padding strategy. + */ + var Pkcs7 = C_pad.Pkcs7 = { + /** + * Pads data using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to pad. + * @param {number} blockSize The multiple that the data should be padded to. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.pad(wordArray, 4); + */ + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + + // Create padding word + var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes; + + // Create padding + var paddingWords = []; + for (var i = 0; i < nPaddingBytes; i += 4) { + paddingWords.push(paddingWord); + } + var padding = WordArray.create(paddingWords, nPaddingBytes); + + // Add padding + data.concat(padding); + }, + + /** + * Unpads data that had been padded using the algorithm defined in PKCS #5/7. + * + * @param {WordArray} data The data to unpad. + * + * @static + * + * @example + * + * CryptoJS.pad.Pkcs7.unpad(wordArray); + */ + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + /** + * Abstract base block cipher template. + * + * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits) + */ + C_lib.BlockCipher = Cipher.extend({ + /** + * Configuration options. + * + * @property {Mode} mode The block mode to use. Default: CBC + * @property {Padding} padding The padding strategy to use. Default: Pkcs7 + */ + cfg: Cipher.cfg.extend({ + mode: CBC, + padding: Pkcs7 + }), + + reset: function () { + var modeCreator; + + // Reset cipher + Cipher.reset.call(this); + + // Shortcuts + var cfg = this.cfg; + var iv = cfg.iv; + var mode = cfg.mode; + + // Reset block mode + if (this._xformMode == this._ENC_XFORM_MODE) { + modeCreator = mode.createEncryptor; + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ + { + modeCreator = mode.createDecryptor; + // Keep at least one block in the buffer for unpadding + this._minBufferSize = 1; + } + + if (this._mode && this._mode.__creator == modeCreator) { + this._mode.init(this, iv && iv.words); + } else { + this._mode = modeCreator.call(mode, this, iv && iv.words); + this._mode.__creator = modeCreator; + } + }, + + _doProcessBlock: function (words, offset) { + this._mode.processBlock(words, offset); + }, + + _doFinalize: function () { + var finalProcessedBlocks; + + // Shortcut + var padding = this.cfg.padding; + + // Finalize + if (this._xformMode == this._ENC_XFORM_MODE) { + // Pad data + padding.pad(this._data, this.blockSize); + + // Process final blocks + finalProcessedBlocks = this._process(!!'flush'); + } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ + { + // Process final blocks + finalProcessedBlocks = this._process(!!'flush'); + + // Unpad data + padding.unpad(finalProcessedBlocks); + } + + return finalProcessedBlocks; + }, + + blockSize: 128 / 32 + }); + + /** + * A collection of cipher parameters. + * + * @property {WordArray} ciphertext The raw ciphertext. + * @property {WordArray} key The key to this ciphertext. + * @property {WordArray} iv The IV used in the ciphering operation. + * @property {WordArray} salt The salt used with a key derivation function. + * @property {Cipher} algorithm The cipher algorithm. + * @property {Mode} mode The block mode used in the ciphering operation. + * @property {Padding} padding The padding scheme used in the ciphering operation. + * @property {number} blockSize The block size of the cipher. + * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string. + */ + var CipherParams = C_lib.CipherParams = Base.extend({ + /** + * Initializes a newly created cipher params object. + * + * @param {Object} cipherParams An object with any of the possible cipher parameters. + * + * @example + * + * var cipherParams = CryptoJS.lib.CipherParams.create({ + * ciphertext: ciphertextWordArray, + * key: keyWordArray, + * iv: ivWordArray, + * salt: saltWordArray, + * algorithm: CryptoJS.algo.AES, + * mode: CryptoJS.mode.CBC, + * padding: CryptoJS.pad.PKCS7, + * blockSize: 4, + * formatter: CryptoJS.format.OpenSSL + * }); + */ + init: function (cipherParams) { + this.mixIn(cipherParams); + }, + + /** + * Converts this cipher params object to a string. + * + * @param {Format} formatter (Optional) The formatting strategy to use. + * + * @return {string} The stringified cipher params. + * + * @throws Error If neither the formatter nor the default formatter is set. + * + * @example + * + * var string = cipherParams + ''; + * var string = cipherParams.toString(); + * var string = cipherParams.toString(CryptoJS.format.OpenSSL); + */ + toString: function (formatter) { + return (formatter || this.formatter).stringify(this); + } + }); + + /** + * Format namespace. + */ + var C_format = C.format = {}; + + /** + * OpenSSL formatting strategy. + */ + var OpenSSLFormatter = C_format.OpenSSL = { + /** + * Converts a cipher params object to an OpenSSL-compatible string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The OpenSSL-compatible string. + * + * @static + * + * @example + * + * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams); + */ + stringify: function (cipherParams) { + var wordArray; + + // Shortcuts + var ciphertext = cipherParams.ciphertext; + var salt = cipherParams.salt; + + // Format + if (salt) { + wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext); + } else { + wordArray = ciphertext; + } + + return wordArray.toString(Base64); + }, + + /** + * Converts an OpenSSL-compatible string to a cipher params object. + * + * @param {string} openSSLStr The OpenSSL-compatible string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString); + */ + parse: function (openSSLStr) { + var salt; + + // Parse base64 + var ciphertext = Base64.parse(openSSLStr); + + // Shortcut + var ciphertextWords = ciphertext.words; + + // Test for salt + if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) { + // Extract salt + salt = WordArray.create(ciphertextWords.slice(2, 4)); + + // Remove salt from ciphertext + ciphertextWords.splice(0, 4); + ciphertext.sigBytes -= 16; + } + + return CipherParams.create({ ciphertext: ciphertext, salt: salt }); + } + }; + + /** + * A cipher wrapper that returns ciphertext as a serializable cipher params object. + */ + var SerializableCipher = C_lib.SerializableCipher = Base.extend({ + /** + * Configuration options. + * + * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL + */ + cfg: Base.extend({ + format: OpenSSLFormatter + }), + + /** + * Encrypts a message. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv }); + * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Encrypt + var encryptor = cipher.createEncryptor(key, cfg); + var ciphertext = encryptor.finalize(message); + + // Shortcut + var cipherCfg = encryptor.cfg; + + // Create and return serializable cipher params + return CipherParams.create({ + ciphertext: ciphertext, + key: key, + iv: cipherCfg.iv, + algorithm: cipher, + mode: cipherCfg.mode, + padding: cipherCfg.padding, + blockSize: cipher.blockSize, + formatter: cfg.format + }); + }, + + /** + * Decrypts serialized ciphertext. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {WordArray} key The key. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, key, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); + + // Decrypt + var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext); + + return plaintext; + }, + + /** + * Converts serialized ciphertext to CipherParams, + * else assumed CipherParams already and returns ciphertext unchanged. + * + * @param {CipherParams|string} ciphertext The ciphertext. + * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext. + * + * @return {CipherParams} The unserialized ciphertext. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format); + */ + _parse: function (ciphertext, format) { + if (typeof ciphertext == 'string') { + return format.parse(ciphertext, this); + } else { + return ciphertext; + } + } + }); + + /** + * Key derivation function namespace. + */ + var C_kdf = C.kdf = {}; + + /** + * OpenSSL key derivation function. + */ + var OpenSSLKdf = C_kdf.OpenSSL = { + /** + * Derives a key and IV from a password. + * + * @param {string} password The password to derive from. + * @param {number} keySize The size in words of the key to generate. + * @param {number} ivSize The size in words of the IV to generate. + * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly. + * + * @return {CipherParams} A cipher params object with the key, IV, and salt. + * + * @static + * + * @example + * + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32); + * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt'); + */ + execute: function (password, keySize, ivSize, salt, hasher) { + // Generate random salt + if (!salt) { + salt = WordArray.random(64 / 8); + } + + // Derive key and IV + var key = ""; + if (!hasher) { + key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt); + } else { + key = EvpKDF.create({ keySize: keySize + ivSize, hasher: hasher, }).compute(password, salt); + } + + // Separate key and IV + var iv = WordArray.create(key.words.slice(keySize), ivSize * 4); + key.sigBytes = keySize * 4; + + // Return params + return CipherParams.create({ key: key, iv: iv, salt: salt }); + } + }; + + /** + * A serializable cipher wrapper that derives the key from a password, + * and returns ciphertext as a serializable cipher params object. + */ + var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({ + /** + * Configuration options. + * + * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL + */ + cfg: SerializableCipher.cfg.extend({ + kdf: OpenSSLKdf + }), + + /** + * Encrypts a message using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {WordArray|string} message The message to encrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {CipherParams} A cipher params object. + * + * @static + * + * @example + * + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password'); + * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL }); + */ + encrypt: function (cipher, message, password, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Derive key and other params + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, cfg.salt, cfg.hasher); + + // Add IV to config + cfg.iv = derivedParams.iv; + + // Encrypt + var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg); + + // Mix in derived params + ciphertext.mixIn(derivedParams); + + return ciphertext; + }, + + /** + * Decrypts serialized ciphertext using a password. + * + * @param {Cipher} cipher The cipher algorithm to use. + * @param {CipherParams|string} ciphertext The ciphertext to decrypt. + * @param {string} password The password. + * @param {Object} cfg (Optional) The configuration options to use for this operation. + * + * @return {WordArray} The plaintext. + * + * @static + * + * @example + * + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL }); + * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL }); + */ + decrypt: function (cipher, ciphertext, password, cfg) { + // Apply config defaults + cfg = this.cfg.extend(cfg); + + // Convert string to CipherParams + ciphertext = this._parse(ciphertext, cfg.format); + + // Derive key and other params + var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt, cfg.hasher); + + // Add IV to config + cfg.iv = derivedParams.iv; + + // Decrypt + var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg); + + return plaintext; + } + }); + }()); + + + })); + }(cipherCore)); + return cipherCoreExports; +} + +var modeCfbExports = {}; +var modeCfb = { + get exports() { + return modeCfbExports; + }, + set exports(v) { + modeCfbExports = v; + }, +}; + +var hasRequiredModeCfb; + +function requireModeCfb() { + if (hasRequiredModeCfb) return modeCfbExports; + hasRequiredModeCfb = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * Cipher Feedback block mode. + */ + CryptoJS.mode.CFB = (function(){ + var CFB = CryptoJS.lib.BlockCipherMode.extend(); + + CFB.Encryptor = CFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + + // Remember this block to use with next block + this._prevBlock = words.slice(offset, offset + blockSize); + } + }); + + CFB.Decryptor = CFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + + // Remember this block to use with next block + var thisBlock = words.slice(offset, offset + blockSize); + + generateKeystreamAndEncrypt.call(this, words, offset, blockSize, cipher); + + // This block becomes the previous block + this._prevBlock = thisBlock; + } + }); + + function generateKeystreamAndEncrypt(words, offset, blockSize, cipher) { + var keystream; + + // Shortcut + var iv = this._iv; + + // Generate keystream + if (iv) { + keystream = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } else { + keystream = this._prevBlock; + } + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + + return CFB; + }()); + + + return CryptoJS.mode.CFB; + + })); + }(modeCfb)); + return modeCfbExports; +} + +var modeCtrExports = {}; +var modeCtr = { + get exports() { + return modeCtrExports; + }, + set exports(v) { + modeCtrExports = v; + }, +}; + +var hasRequiredModeCtr; + +function requireModeCtr() { + if (hasRequiredModeCtr) return modeCtrExports; + hasRequiredModeCtr = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * Counter block mode. + */ + CryptoJS.mode.CTR = (function(){ + var CTR = CryptoJS.lib.BlockCipherMode.extend(); + + var Encryptor = CTR.Encryptor = CTR.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + var iv = this._iv; + var counter = this._counter; + + // Generate keystream + if (iv) { + counter = this._counter = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } + var keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); + + // Increment counter + counter[blockSize - 1] = (counter[blockSize - 1] + 1) | 0; + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); + + CTR.Decryptor = Encryptor; + + return CTR; + }()); + + + return CryptoJS.mode.CTR; + + })); + }(modeCtr)); + return modeCtrExports; +} + +var modeCtrGladmanExports = {}; +var modeCtrGladman = { + get exports() { + return modeCtrGladmanExports; + }, + set exports(v) { + modeCtrGladmanExports = v; + }, +}; + +var hasRequiredModeCtrGladman; + +function requireModeCtrGladman() { + if (hasRequiredModeCtrGladman) return modeCtrGladmanExports; + hasRequiredModeCtrGladman = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** @preserve + * Counter block mode compatible with Dr Brian Gladman fileenc.c + * derived from CryptoJS.mode.CTR + * Jan Hruby jhruby.web@gmail.com + */ + CryptoJS.mode.CTRGladman = (function(){ + var CTRGladman = CryptoJS.lib.BlockCipherMode.extend(); + + function incWord(word) { + if (((word >> 24) & 0xff) === 0xff) { //overflow + var b1 = (word >> 16) & 0xff; + var b2 = (word >> 8) & 0xff; + var b3 = word & 0xff; + + if (b1 === 0xff) // overflow b1 + { + b1 = 0; + if (b2 === 0xff) { + b2 = 0; + if (b3 === 0xff) { + b3 = 0; + } + else { + ++b3; + } + } + else { + ++b2; + } + } + else { + ++b1; + } + + word = 0; + word += (b1 << 16); + word += (b2 << 8); + word += b3; + } + else { + word += (0x01 << 24); + } + return word; + } + + function incCounter(counter) { + if ((counter[0] = incWord(counter[0])) === 0) { + // encr_data in fileenc.c from Dr Brian Gladman's counts only with DWORD j < 8 + counter[1] = incWord(counter[1]); + } + return counter; + } + + var Encryptor = CTRGladman.Encryptor = CTRGladman.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + var iv = this._iv; + var counter = this._counter; + + // Generate keystream + if (iv) { + counter = this._counter = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } + + incCounter(counter); + + var keystream = counter.slice(0); + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); + + CTRGladman.Decryptor = Encryptor; + + return CTRGladman; + }()); + + + return CryptoJS.mode.CTRGladman; + + })); + }(modeCtrGladman)); + return modeCtrGladmanExports; +} + +var modeOfbExports = {}; +var modeOfb = { + get exports() { + return modeOfbExports; + }, + set exports(v) { + modeOfbExports = v; + }, +}; + +var hasRequiredModeOfb; + +function requireModeOfb() { + if (hasRequiredModeOfb) return modeOfbExports; + hasRequiredModeOfb = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * Output Feedback block mode. + */ + CryptoJS.mode.OFB = (function(){ + var OFB = CryptoJS.lib.BlockCipherMode.extend(); + + var Encryptor = OFB.Encryptor = OFB.extend({ + processBlock: function (words, offset) { + // Shortcuts + var cipher = this._cipher; + var blockSize = cipher.blockSize; + var iv = this._iv; + var keystream = this._keystream; + + // Generate keystream + if (iv) { + keystream = this._keystream = iv.slice(0); + + // Remove IV for subsequent blocks + this._iv = undefined; + } + cipher.encryptBlock(keystream, 0); + + // Encrypt + for (var i = 0; i < blockSize; i++) { + words[offset + i] ^= keystream[i]; + } + } + }); + + OFB.Decryptor = Encryptor; + + return OFB; + }()); + + + return CryptoJS.mode.OFB; + + })); + }(modeOfb)); + return modeOfbExports; +} + +var modeEcbExports = {}; +var modeEcb = { + get exports() { + return modeEcbExports; + }, + set exports(v) { + modeEcbExports = v; + }, +}; + +var hasRequiredModeEcb; + +function requireModeEcb() { + if (hasRequiredModeEcb) return modeEcbExports; + hasRequiredModeEcb = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * Electronic Codebook block mode. + */ + CryptoJS.mode.ECB = (function(){ + var ECB = CryptoJS.lib.BlockCipherMode.extend(); + + ECB.Encryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.encryptBlock(words, offset); + } + }); + + ECB.Decryptor = ECB.extend({ + processBlock: function (words, offset) { + this._cipher.decryptBlock(words, offset); + } + }); + + return ECB; + }()); + + + return CryptoJS.mode.ECB; + + })); + }(modeEcb)); + return modeEcbExports; +} + +var padAnsix923Exports = {}; +var padAnsix923 = { + get exports() { + return padAnsix923Exports; + }, + set exports(v) { + padAnsix923Exports = v; + }, +}; + +var hasRequiredPadAnsix923; + +function requirePadAnsix923() { + if (hasRequiredPadAnsix923) return padAnsix923Exports; + hasRequiredPadAnsix923 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * ANSI X.923 padding strategy. + */ + CryptoJS.pad.AnsiX923 = { + pad: function (data, blockSize) { + // Shortcuts + var dataSigBytes = data.sigBytes; + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - dataSigBytes % blockSizeBytes; + + // Compute last byte position + var lastBytePos = dataSigBytes + nPaddingBytes - 1; + + // Pad + data.clamp(); + data.words[lastBytePos >>> 2] |= nPaddingBytes << (24 - (lastBytePos % 4) * 8); + data.sigBytes += nPaddingBytes; + }, + + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + + return CryptoJS.pad.Ansix923; + + })); + }(padAnsix923)); + return padAnsix923Exports; +} + +var padIso10126Exports = {}; +var padIso10126 = { + get exports() { + return padIso10126Exports; + }, + set exports(v) { + padIso10126Exports = v; + }, +}; + +var hasRequiredPadIso10126; + +function requirePadIso10126() { + if (hasRequiredPadIso10126) return padIso10126Exports; + hasRequiredPadIso10126 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * ISO 10126 padding strategy. + */ + CryptoJS.pad.Iso10126 = { + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Count padding bytes + var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes; + + // Pad + data.concat(CryptoJS.lib.WordArray.random(nPaddingBytes - 1)).concat(CryptoJS.lib.WordArray.create([nPaddingBytes << 24], 1)); + }, + + unpad: function (data) { + // Get number of padding bytes from last byte + var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff; + + // Remove padding + data.sigBytes -= nPaddingBytes; + } + }; + + + return CryptoJS.pad.Iso10126; + + })); + }(padIso10126)); + return padIso10126Exports; +} + +var padIso97971Exports = {}; +var padIso97971 = { + get exports() { + return padIso97971Exports; + }, + set exports(v) { + padIso97971Exports = v; + }, +}; + +var hasRequiredPadIso97971; + +function requirePadIso97971() { + if (hasRequiredPadIso97971) return padIso97971Exports; + hasRequiredPadIso97971 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * ISO/IEC 9797-1 Padding Method 2. + */ + CryptoJS.pad.Iso97971 = { + pad: function (data, blockSize) { + // Add 0x80 byte + data.concat(CryptoJS.lib.WordArray.create([0x80000000], 1)); + + // Zero pad the rest + CryptoJS.pad.ZeroPadding.pad(data, blockSize); + }, + + unpad: function (data) { + // Remove zero padding + CryptoJS.pad.ZeroPadding.unpad(data); + + // Remove one more byte -- the 0x80 byte + data.sigBytes--; + } + }; + + + return CryptoJS.pad.Iso97971; + + })); + }(padIso97971)); + return padIso97971Exports; +} + +var padZeropaddingExports = {}; +var padZeropadding = { + get exports() { + return padZeropaddingExports; + }, + set exports(v) { + padZeropaddingExports = v; + }, +}; + +var hasRequiredPadZeropadding; + +function requirePadZeropadding() { + if (hasRequiredPadZeropadding) return padZeropaddingExports; + hasRequiredPadZeropadding = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * Zero padding strategy. + */ + CryptoJS.pad.ZeroPadding = { + pad: function (data, blockSize) { + // Shortcut + var blockSizeBytes = blockSize * 4; + + // Pad + data.clamp(); + data.sigBytes += blockSizeBytes - ((data.sigBytes % blockSizeBytes) || blockSizeBytes); + }, + + unpad: function (data) { + // Shortcut + var dataWords = data.words; + + // Unpad + var i = data.sigBytes - 1; + for (var i = data.sigBytes - 1; i >= 0; i--) { + if (((dataWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff)) { + data.sigBytes = i + 1; + break; + } + } + } + }; + + + return CryptoJS.pad.ZeroPadding; + + })); + }(padZeropadding)); + return padZeropaddingExports; +} + +var padNopaddingExports = {}; +var padNopadding = { + get exports() { + return padNopaddingExports; + }, + set exports(v) { + padNopaddingExports = v; + }, +}; + +var hasRequiredPadNopadding; + +function requirePadNopadding() { + if (hasRequiredPadNopadding) return padNopaddingExports; + hasRequiredPadNopadding = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + /** + * A noop padding strategy. + */ + CryptoJS.pad.NoPadding = { + pad: function () { + }, + + unpad: function () { + } + }; + + + return CryptoJS.pad.NoPadding; + + })); + }(padNopadding)); + return padNopaddingExports; +} + +var formatHexExports = {}; +var formatHex = { + get exports() { + return formatHexExports; + }, + set exports(v) { + formatHexExports = v; + }, +}; + +var hasRequiredFormatHex; + +function requireFormatHex() { + if (hasRequiredFormatHex) return formatHexExports; + hasRequiredFormatHex = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(undefined$1){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var CipherParams = C_lib.CipherParams; + var C_enc = C.enc; + var Hex = C_enc.Hex; + var C_format = C.format; + + C_format.Hex = { + /** + * Converts the ciphertext of a cipher params object to a hexadecimally encoded string. + * + * @param {CipherParams} cipherParams The cipher params object. + * + * @return {string} The hexadecimally encoded string. + * + * @static + * + * @example + * + * var hexString = CryptoJS.format.Hex.stringify(cipherParams); + */ + stringify: function (cipherParams) { + return cipherParams.ciphertext.toString(Hex); + }, + + /** + * Converts a hexadecimally encoded ciphertext string to a cipher params object. + * + * @param {string} input The hexadecimally encoded string. + * + * @return {CipherParams} The cipher params object. + * + * @static + * + * @example + * + * var cipherParams = CryptoJS.format.Hex.parse(hexString); + */ + parse: function (input) { + var ciphertext = Hex.parse(input); + return CipherParams.create({ ciphertext: ciphertext }); + } + }; + }()); + + + return CryptoJS.format.Hex; + + })); + }(formatHex)); + return formatHexExports; +} + +var aesExports = {}; +var aes = { + get exports() { + return aesExports; + }, + set exports(v) { + aesExports = v; + }, +}; + +var hasRequiredAes; + +function requireAes() { + if (hasRequiredAes) return aesExports; + hasRequiredAes = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireEncBase64(), requireMd5(), requireEvpkdf(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + // Lookup tables + var SBOX = []; + var INV_SBOX = []; + var SUB_MIX_0 = []; + var SUB_MIX_1 = []; + var SUB_MIX_2 = []; + var SUB_MIX_3 = []; + var INV_SUB_MIX_0 = []; + var INV_SUB_MIX_1 = []; + var INV_SUB_MIX_2 = []; + var INV_SUB_MIX_3 = []; + + // Compute lookup tables + (function(){ + // Compute double table + var d = []; + for (var i = 0; i < 256; i++) { + if (i < 128) { + d[i] = i << 1; + } else { + d[i] = (i << 1) ^ 0x11b; + } + } + + // Walk GF(2^8) + var x = 0; + var xi = 0; + for (var i = 0; i < 256; i++) { + // Compute sbox + var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4); + sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63; + SBOX[x] = sx; + INV_SBOX[sx] = x; + + // Compute multiplication + var x2 = d[x]; + var x4 = d[x2]; + var x8 = d[x4]; + + // Compute sub bytes, mix columns tables + var t = (d[sx] * 0x101) ^ (sx * 0x1010100); + SUB_MIX_0[x] = (t << 24) | (t >>> 8); + SUB_MIX_1[x] = (t << 16) | (t >>> 16); + SUB_MIX_2[x] = (t << 8) | (t >>> 24); + SUB_MIX_3[x] = t; + + // Compute inv sub bytes, inv mix columns tables + var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100); + INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8); + INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16); + INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24); + INV_SUB_MIX_3[sx] = t; + + // Compute next counter + if (!x) { + x = xi = 1; + } else { + x = x2 ^ d[d[d[x8 ^ x2]]]; + xi ^= d[d[xi]]; + } + } + }()); + + // Precomputed Rcon lookup + var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36]; + + /** + * AES block cipher algorithm. + */ + var AES = C_algo.AES = BlockCipher.extend({ + _doReset: function () { + var t; + + // Skip reset of nRounds has been set before and key did not change + if (this._nRounds && this._keyPriorReset === this._key) { + return; + } + + // Shortcuts + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + + // Compute number of rounds + var nRounds = this._nRounds = keySize + 6; + + // Compute number of key schedule rows + var ksRows = (nRounds + 1) * 4; + + // Compute key schedule + var keySchedule = this._keySchedule = []; + for (var ksRow = 0; ksRow < ksRows; ksRow++) { + if (ksRow < keySize) { + keySchedule[ksRow] = keyWords[ksRow]; + } else { + t = keySchedule[ksRow - 1]; + + if (!(ksRow % keySize)) { + // Rot word + t = (t << 8) | (t >>> 24); + + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + + // Mix Rcon + t ^= RCON[(ksRow / keySize) | 0] << 24; + } else if (keySize > 6 && ksRow % keySize == 4) { + // Sub word + t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff]; + } + + keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t; + } + } + + // Compute inv key schedule + var invKeySchedule = this._invKeySchedule = []; + for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) { + var ksRow = ksRows - invKsRow; + + if (invKsRow % 4) { + var t = keySchedule[ksRow]; + } else { + var t = keySchedule[ksRow - 4]; + } + + if (invKsRow < 4 || ksRow <= 4) { + invKeySchedule[invKsRow] = t; + } else { + invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^ + INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]]; + } + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX); + }, + + decryptBlock: function (M, offset) { + // Swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + + this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX); + + // Inv swap 2nd and 4th rows + var t = M[offset + 1]; + M[offset + 1] = M[offset + 3]; + M[offset + 3] = t; + }, + + _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) { + // Shortcut + var nRounds = this._nRounds; + + // Get input, add round key + var s0 = M[offset] ^ keySchedule[0]; + var s1 = M[offset + 1] ^ keySchedule[1]; + var s2 = M[offset + 2] ^ keySchedule[2]; + var s3 = M[offset + 3] ^ keySchedule[3]; + + // Key schedule row counter + var ksRow = 4; + + // Rounds + for (var round = 1; round < nRounds; round++) { + // Shift rows, sub bytes, mix columns, add round key + var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++]; + var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++]; + var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++]; + var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++]; + + // Update state + s0 = t0; + s1 = t1; + s2 = t2; + s3 = t3; + } + + // Shift rows, sub bytes, add round key + var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++]; + var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++]; + var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++]; + var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++]; + + // Set output + M[offset] = t0; + M[offset + 1] = t1; + M[offset + 2] = t2; + M[offset + 3] = t3; + }, + + keySize: 256 / 32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg); + */ + C.AES = BlockCipher._createHelper(AES); + }()); + + + return CryptoJS.AES; + + })); + }(aes)); + return aesExports; +} + +var tripledesExports = {}; +var tripledes = { + get exports() { + return tripledesExports; + }, + set exports(v) { + tripledesExports = v; + }, +}; + +var hasRequiredTripledes; + +function requireTripledes() { + if (hasRequiredTripledes) return tripledesExports; + hasRequiredTripledes = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireEncBase64(), requireMd5(), requireEvpkdf(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var WordArray = C_lib.WordArray; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + // Permuted Choice 1 constants + var PC1 = [ + 57, 49, 41, 33, 25, 17, 9, 1, + 58, 50, 42, 34, 26, 18, 10, 2, + 59, 51, 43, 35, 27, 19, 11, 3, + 60, 52, 44, 36, 63, 55, 47, 39, + 31, 23, 15, 7, 62, 54, 46, 38, + 30, 22, 14, 6, 61, 53, 45, 37, + 29, 21, 13, 5, 28, 20, 12, 4 + ]; + + // Permuted Choice 2 constants + var PC2 = [ + 14, 17, 11, 24, 1, 5, + 3, 28, 15, 6, 21, 10, + 23, 19, 12, 4, 26, 8, + 16, 7, 27, 20, 13, 2, + 41, 52, 31, 37, 47, 55, + 30, 40, 51, 45, 33, 48, + 44, 49, 39, 56, 34, 53, + 46, 42, 50, 36, 29, 32 + ]; + + // Cumulative bit shift constants + var BIT_SHIFTS = [1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28]; + + // SBOXes and round permutation constants + var SBOX_P = [ + { + 0x0: 0x808200, + 0x10000000: 0x8000, + 0x20000000: 0x808002, + 0x30000000: 0x2, + 0x40000000: 0x200, + 0x50000000: 0x808202, + 0x60000000: 0x800202, + 0x70000000: 0x800000, + 0x80000000: 0x202, + 0x90000000: 0x800200, + 0xa0000000: 0x8200, + 0xb0000000: 0x808000, + 0xc0000000: 0x8002, + 0xd0000000: 0x800002, + 0xe0000000: 0x0, + 0xf0000000: 0x8202, + 0x8000000: 0x0, + 0x18000000: 0x808202, + 0x28000000: 0x8202, + 0x38000000: 0x8000, + 0x48000000: 0x808200, + 0x58000000: 0x200, + 0x68000000: 0x808002, + 0x78000000: 0x2, + 0x88000000: 0x800200, + 0x98000000: 0x8200, + 0xa8000000: 0x808000, + 0xb8000000: 0x800202, + 0xc8000000: 0x800002, + 0xd8000000: 0x8002, + 0xe8000000: 0x202, + 0xf8000000: 0x800000, + 0x1: 0x8000, + 0x10000001: 0x2, + 0x20000001: 0x808200, + 0x30000001: 0x800000, + 0x40000001: 0x808002, + 0x50000001: 0x8200, + 0x60000001: 0x200, + 0x70000001: 0x800202, + 0x80000001: 0x808202, + 0x90000001: 0x808000, + 0xa0000001: 0x800002, + 0xb0000001: 0x8202, + 0xc0000001: 0x202, + 0xd0000001: 0x800200, + 0xe0000001: 0x8002, + 0xf0000001: 0x0, + 0x8000001: 0x808202, + 0x18000001: 0x808000, + 0x28000001: 0x800000, + 0x38000001: 0x200, + 0x48000001: 0x8000, + 0x58000001: 0x800002, + 0x68000001: 0x2, + 0x78000001: 0x8202, + 0x88000001: 0x8002, + 0x98000001: 0x800202, + 0xa8000001: 0x202, + 0xb8000001: 0x808200, + 0xc8000001: 0x800200, + 0xd8000001: 0x0, + 0xe8000001: 0x8200, + 0xf8000001: 0x808002 + }, + { + 0x0: 0x40084010, + 0x1000000: 0x4000, + 0x2000000: 0x80000, + 0x3000000: 0x40080010, + 0x4000000: 0x40000010, + 0x5000000: 0x40084000, + 0x6000000: 0x40004000, + 0x7000000: 0x10, + 0x8000000: 0x84000, + 0x9000000: 0x40004010, + 0xa000000: 0x40000000, + 0xb000000: 0x84010, + 0xc000000: 0x80010, + 0xd000000: 0x0, + 0xe000000: 0x4010, + 0xf000000: 0x40080000, + 0x800000: 0x40004000, + 0x1800000: 0x84010, + 0x2800000: 0x10, + 0x3800000: 0x40004010, + 0x4800000: 0x40084010, + 0x5800000: 0x40000000, + 0x6800000: 0x80000, + 0x7800000: 0x40080010, + 0x8800000: 0x80010, + 0x9800000: 0x0, + 0xa800000: 0x4000, + 0xb800000: 0x40080000, + 0xc800000: 0x40000010, + 0xd800000: 0x84000, + 0xe800000: 0x40084000, + 0xf800000: 0x4010, + 0x10000000: 0x0, + 0x11000000: 0x40080010, + 0x12000000: 0x40004010, + 0x13000000: 0x40084000, + 0x14000000: 0x40080000, + 0x15000000: 0x10, + 0x16000000: 0x84010, + 0x17000000: 0x4000, + 0x18000000: 0x4010, + 0x19000000: 0x80000, + 0x1a000000: 0x80010, + 0x1b000000: 0x40000010, + 0x1c000000: 0x84000, + 0x1d000000: 0x40004000, + 0x1e000000: 0x40000000, + 0x1f000000: 0x40084010, + 0x10800000: 0x84010, + 0x11800000: 0x80000, + 0x12800000: 0x40080000, + 0x13800000: 0x4000, + 0x14800000: 0x40004000, + 0x15800000: 0x40084010, + 0x16800000: 0x10, + 0x17800000: 0x40000000, + 0x18800000: 0x40084000, + 0x19800000: 0x40000010, + 0x1a800000: 0x40004010, + 0x1b800000: 0x80010, + 0x1c800000: 0x0, + 0x1d800000: 0x4010, + 0x1e800000: 0x40080010, + 0x1f800000: 0x84000 + }, + { + 0x0: 0x104, + 0x100000: 0x0, + 0x200000: 0x4000100, + 0x300000: 0x10104, + 0x400000: 0x10004, + 0x500000: 0x4000004, + 0x600000: 0x4010104, + 0x700000: 0x4010000, + 0x800000: 0x4000000, + 0x900000: 0x4010100, + 0xa00000: 0x10100, + 0xb00000: 0x4010004, + 0xc00000: 0x4000104, + 0xd00000: 0x10000, + 0xe00000: 0x4, + 0xf00000: 0x100, + 0x80000: 0x4010100, + 0x180000: 0x4010004, + 0x280000: 0x0, + 0x380000: 0x4000100, + 0x480000: 0x4000004, + 0x580000: 0x10000, + 0x680000: 0x10004, + 0x780000: 0x104, + 0x880000: 0x4, + 0x980000: 0x100, + 0xa80000: 0x4010000, + 0xb80000: 0x10104, + 0xc80000: 0x10100, + 0xd80000: 0x4000104, + 0xe80000: 0x4010104, + 0xf80000: 0x4000000, + 0x1000000: 0x4010100, + 0x1100000: 0x10004, + 0x1200000: 0x10000, + 0x1300000: 0x4000100, + 0x1400000: 0x100, + 0x1500000: 0x4010104, + 0x1600000: 0x4000004, + 0x1700000: 0x0, + 0x1800000: 0x4000104, + 0x1900000: 0x4000000, + 0x1a00000: 0x4, + 0x1b00000: 0x10100, + 0x1c00000: 0x4010000, + 0x1d00000: 0x104, + 0x1e00000: 0x10104, + 0x1f00000: 0x4010004, + 0x1080000: 0x4000000, + 0x1180000: 0x104, + 0x1280000: 0x4010100, + 0x1380000: 0x0, + 0x1480000: 0x10004, + 0x1580000: 0x4000100, + 0x1680000: 0x100, + 0x1780000: 0x4010004, + 0x1880000: 0x10000, + 0x1980000: 0x4010104, + 0x1a80000: 0x10104, + 0x1b80000: 0x4000004, + 0x1c80000: 0x4000104, + 0x1d80000: 0x4010000, + 0x1e80000: 0x4, + 0x1f80000: 0x10100 + }, + { + 0x0: 0x80401000, + 0x10000: 0x80001040, + 0x20000: 0x401040, + 0x30000: 0x80400000, + 0x40000: 0x0, + 0x50000: 0x401000, + 0x60000: 0x80000040, + 0x70000: 0x400040, + 0x80000: 0x80000000, + 0x90000: 0x400000, + 0xa0000: 0x40, + 0xb0000: 0x80001000, + 0xc0000: 0x80400040, + 0xd0000: 0x1040, + 0xe0000: 0x1000, + 0xf0000: 0x80401040, + 0x8000: 0x80001040, + 0x18000: 0x40, + 0x28000: 0x80400040, + 0x38000: 0x80001000, + 0x48000: 0x401000, + 0x58000: 0x80401040, + 0x68000: 0x0, + 0x78000: 0x80400000, + 0x88000: 0x1000, + 0x98000: 0x80401000, + 0xa8000: 0x400000, + 0xb8000: 0x1040, + 0xc8000: 0x80000000, + 0xd8000: 0x400040, + 0xe8000: 0x401040, + 0xf8000: 0x80000040, + 0x100000: 0x400040, + 0x110000: 0x401000, + 0x120000: 0x80000040, + 0x130000: 0x0, + 0x140000: 0x1040, + 0x150000: 0x80400040, + 0x160000: 0x80401000, + 0x170000: 0x80001040, + 0x180000: 0x80401040, + 0x190000: 0x80000000, + 0x1a0000: 0x80400000, + 0x1b0000: 0x401040, + 0x1c0000: 0x80001000, + 0x1d0000: 0x400000, + 0x1e0000: 0x40, + 0x1f0000: 0x1000, + 0x108000: 0x80400000, + 0x118000: 0x80401040, + 0x128000: 0x0, + 0x138000: 0x401000, + 0x148000: 0x400040, + 0x158000: 0x80000000, + 0x168000: 0x80001040, + 0x178000: 0x40, + 0x188000: 0x80000040, + 0x198000: 0x1000, + 0x1a8000: 0x80001000, + 0x1b8000: 0x80400040, + 0x1c8000: 0x1040, + 0x1d8000: 0x80401000, + 0x1e8000: 0x400000, + 0x1f8000: 0x401040 + }, + { + 0x0: 0x80, + 0x1000: 0x1040000, + 0x2000: 0x40000, + 0x3000: 0x20000000, + 0x4000: 0x20040080, + 0x5000: 0x1000080, + 0x6000: 0x21000080, + 0x7000: 0x40080, + 0x8000: 0x1000000, + 0x9000: 0x20040000, + 0xa000: 0x20000080, + 0xb000: 0x21040080, + 0xc000: 0x21040000, + 0xd000: 0x0, + 0xe000: 0x1040080, + 0xf000: 0x21000000, + 0x800: 0x1040080, + 0x1800: 0x21000080, + 0x2800: 0x80, + 0x3800: 0x1040000, + 0x4800: 0x40000, + 0x5800: 0x20040080, + 0x6800: 0x21040000, + 0x7800: 0x20000000, + 0x8800: 0x20040000, + 0x9800: 0x0, + 0xa800: 0x21040080, + 0xb800: 0x1000080, + 0xc800: 0x20000080, + 0xd800: 0x21000000, + 0xe800: 0x1000000, + 0xf800: 0x40080, + 0x10000: 0x40000, + 0x11000: 0x80, + 0x12000: 0x20000000, + 0x13000: 0x21000080, + 0x14000: 0x1000080, + 0x15000: 0x21040000, + 0x16000: 0x20040080, + 0x17000: 0x1000000, + 0x18000: 0x21040080, + 0x19000: 0x21000000, + 0x1a000: 0x1040000, + 0x1b000: 0x20040000, + 0x1c000: 0x40080, + 0x1d000: 0x20000080, + 0x1e000: 0x0, + 0x1f000: 0x1040080, + 0x10800: 0x21000080, + 0x11800: 0x1000000, + 0x12800: 0x1040000, + 0x13800: 0x20040080, + 0x14800: 0x20000000, + 0x15800: 0x1040080, + 0x16800: 0x80, + 0x17800: 0x21040000, + 0x18800: 0x40080, + 0x19800: 0x21040080, + 0x1a800: 0x0, + 0x1b800: 0x21000000, + 0x1c800: 0x1000080, + 0x1d800: 0x40000, + 0x1e800: 0x20040000, + 0x1f800: 0x20000080 + }, + { + 0x0: 0x10000008, + 0x100: 0x2000, + 0x200: 0x10200000, + 0x300: 0x10202008, + 0x400: 0x10002000, + 0x500: 0x200000, + 0x600: 0x200008, + 0x700: 0x10000000, + 0x800: 0x0, + 0x900: 0x10002008, + 0xa00: 0x202000, + 0xb00: 0x8, + 0xc00: 0x10200008, + 0xd00: 0x202008, + 0xe00: 0x2008, + 0xf00: 0x10202000, + 0x80: 0x10200000, + 0x180: 0x10202008, + 0x280: 0x8, + 0x380: 0x200000, + 0x480: 0x202008, + 0x580: 0x10000008, + 0x680: 0x10002000, + 0x780: 0x2008, + 0x880: 0x200008, + 0x980: 0x2000, + 0xa80: 0x10002008, + 0xb80: 0x10200008, + 0xc80: 0x0, + 0xd80: 0x10202000, + 0xe80: 0x202000, + 0xf80: 0x10000000, + 0x1000: 0x10002000, + 0x1100: 0x10200008, + 0x1200: 0x10202008, + 0x1300: 0x2008, + 0x1400: 0x200000, + 0x1500: 0x10000000, + 0x1600: 0x10000008, + 0x1700: 0x202000, + 0x1800: 0x202008, + 0x1900: 0x0, + 0x1a00: 0x8, + 0x1b00: 0x10200000, + 0x1c00: 0x2000, + 0x1d00: 0x10002008, + 0x1e00: 0x10202000, + 0x1f00: 0x200008, + 0x1080: 0x8, + 0x1180: 0x202000, + 0x1280: 0x200000, + 0x1380: 0x10000008, + 0x1480: 0x10002000, + 0x1580: 0x2008, + 0x1680: 0x10202008, + 0x1780: 0x10200000, + 0x1880: 0x10202000, + 0x1980: 0x10200008, + 0x1a80: 0x2000, + 0x1b80: 0x202008, + 0x1c80: 0x200008, + 0x1d80: 0x0, + 0x1e80: 0x10000000, + 0x1f80: 0x10002008 + }, + { + 0x0: 0x100000, + 0x10: 0x2000401, + 0x20: 0x400, + 0x30: 0x100401, + 0x40: 0x2100401, + 0x50: 0x0, + 0x60: 0x1, + 0x70: 0x2100001, + 0x80: 0x2000400, + 0x90: 0x100001, + 0xa0: 0x2000001, + 0xb0: 0x2100400, + 0xc0: 0x2100000, + 0xd0: 0x401, + 0xe0: 0x100400, + 0xf0: 0x2000000, + 0x8: 0x2100001, + 0x18: 0x0, + 0x28: 0x2000401, + 0x38: 0x2100400, + 0x48: 0x100000, + 0x58: 0x2000001, + 0x68: 0x2000000, + 0x78: 0x401, + 0x88: 0x100401, + 0x98: 0x2000400, + 0xa8: 0x2100000, + 0xb8: 0x100001, + 0xc8: 0x400, + 0xd8: 0x2100401, + 0xe8: 0x1, + 0xf8: 0x100400, + 0x100: 0x2000000, + 0x110: 0x100000, + 0x120: 0x2000401, + 0x130: 0x2100001, + 0x140: 0x100001, + 0x150: 0x2000400, + 0x160: 0x2100400, + 0x170: 0x100401, + 0x180: 0x401, + 0x190: 0x2100401, + 0x1a0: 0x100400, + 0x1b0: 0x1, + 0x1c0: 0x0, + 0x1d0: 0x2100000, + 0x1e0: 0x2000001, + 0x1f0: 0x400, + 0x108: 0x100400, + 0x118: 0x2000401, + 0x128: 0x2100001, + 0x138: 0x1, + 0x148: 0x2000000, + 0x158: 0x100000, + 0x168: 0x401, + 0x178: 0x2100400, + 0x188: 0x2000001, + 0x198: 0x2100000, + 0x1a8: 0x0, + 0x1b8: 0x2100401, + 0x1c8: 0x100401, + 0x1d8: 0x400, + 0x1e8: 0x2000400, + 0x1f8: 0x100001 + }, + { + 0x0: 0x8000820, + 0x1: 0x20000, + 0x2: 0x8000000, + 0x3: 0x20, + 0x4: 0x20020, + 0x5: 0x8020820, + 0x6: 0x8020800, + 0x7: 0x800, + 0x8: 0x8020000, + 0x9: 0x8000800, + 0xa: 0x20800, + 0xb: 0x8020020, + 0xc: 0x820, + 0xd: 0x0, + 0xe: 0x8000020, + 0xf: 0x20820, + 0x80000000: 0x800, + 0x80000001: 0x8020820, + 0x80000002: 0x8000820, + 0x80000003: 0x8000000, + 0x80000004: 0x8020000, + 0x80000005: 0x20800, + 0x80000006: 0x20820, + 0x80000007: 0x20, + 0x80000008: 0x8000020, + 0x80000009: 0x820, + 0x8000000a: 0x20020, + 0x8000000b: 0x8020800, + 0x8000000c: 0x0, + 0x8000000d: 0x8020020, + 0x8000000e: 0x8000800, + 0x8000000f: 0x20000, + 0x10: 0x20820, + 0x11: 0x8020800, + 0x12: 0x20, + 0x13: 0x800, + 0x14: 0x8000800, + 0x15: 0x8000020, + 0x16: 0x8020020, + 0x17: 0x20000, + 0x18: 0x0, + 0x19: 0x20020, + 0x1a: 0x8020000, + 0x1b: 0x8000820, + 0x1c: 0x8020820, + 0x1d: 0x20800, + 0x1e: 0x820, + 0x1f: 0x8000000, + 0x80000010: 0x20000, + 0x80000011: 0x800, + 0x80000012: 0x8020020, + 0x80000013: 0x20820, + 0x80000014: 0x20, + 0x80000015: 0x8020000, + 0x80000016: 0x8000000, + 0x80000017: 0x8000820, + 0x80000018: 0x8020820, + 0x80000019: 0x8000020, + 0x8000001a: 0x8000800, + 0x8000001b: 0x0, + 0x8000001c: 0x20800, + 0x8000001d: 0x820, + 0x8000001e: 0x20020, + 0x8000001f: 0x8020800 + } + ]; + + // Masks that select the SBOX input + var SBOX_MASK = [ + 0xf8000001, 0x1f800000, 0x01f80000, 0x001f8000, + 0x0001f800, 0x00001f80, 0x000001f8, 0x8000001f + ]; + + /** + * DES block cipher algorithm. + */ + var DES = C_algo.DES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + + // Select 56 bits according to PC1 + var keyBits = []; + for (var i = 0; i < 56; i++) { + var keyBitPos = PC1[i] - 1; + keyBits[i] = (keyWords[keyBitPos >>> 5] >>> (31 - keyBitPos % 32)) & 1; + } + + // Assemble 16 subkeys + var subKeys = this._subKeys = []; + for (var nSubKey = 0; nSubKey < 16; nSubKey++) { + // Create subkey + var subKey = subKeys[nSubKey] = []; + + // Shortcut + var bitShift = BIT_SHIFTS[nSubKey]; + + // Select 48 bits according to PC2 + for (var i = 0; i < 24; i++) { + // Select from the left 28 key bits + subKey[(i / 6) | 0] |= keyBits[((PC2[i] - 1) + bitShift) % 28] << (31 - i % 6); + + // Select from the right 28 key bits + subKey[4 + ((i / 6) | 0)] |= keyBits[28 + (((PC2[i + 24] - 1) + bitShift) % 28)] << (31 - i % 6); + } + + // Since each subkey is applied to an expanded 32-bit input, + // the subkey can be broken into 8 values scaled to 32-bits, + // which allows the key to be used without expansion + subKey[0] = (subKey[0] << 1) | (subKey[0] >>> 31); + for (var i = 1; i < 7; i++) { + subKey[i] = subKey[i] >>> ((i - 1) * 4 + 3); + } + subKey[7] = (subKey[7] << 5) | (subKey[7] >>> 27); + } + + // Compute inverse subkeys + var invSubKeys = this._invSubKeys = []; + for (var i = 0; i < 16; i++) { + invSubKeys[i] = subKeys[15 - i]; + } + }, + + encryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._subKeys); + }, + + decryptBlock: function (M, offset) { + this._doCryptBlock(M, offset, this._invSubKeys); + }, + + _doCryptBlock: function (M, offset, subKeys) { + // Get input + this._lBlock = M[offset]; + this._rBlock = M[offset + 1]; + + // Initial permutation + exchangeLR.call(this, 4, 0x0f0f0f0f); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeRL.call(this, 2, 0x33333333); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeLR.call(this, 1, 0x55555555); + + // Rounds + for (var round = 0; round < 16; round++) { + // Shortcuts + var subKey = subKeys[round]; + var lBlock = this._lBlock; + var rBlock = this._rBlock; + + // Feistel function + var f = 0; + for (var i = 0; i < 8; i++) { + f |= SBOX_P[i][((rBlock ^ subKey[i]) & SBOX_MASK[i]) >>> 0]; + } + this._lBlock = rBlock; + this._rBlock = lBlock ^ f; + } + + // Undo swap from last round + var t = this._lBlock; + this._lBlock = this._rBlock; + this._rBlock = t; + + // Final permutation + exchangeLR.call(this, 1, 0x55555555); + exchangeRL.call(this, 8, 0x00ff00ff); + exchangeRL.call(this, 2, 0x33333333); + exchangeLR.call(this, 16, 0x0000ffff); + exchangeLR.call(this, 4, 0x0f0f0f0f); + + // Set output + M[offset] = this._lBlock; + M[offset + 1] = this._rBlock; + }, + + keySize: 64 / 32, + + ivSize: 64 / 32, + + blockSize: 64 / 32 + }); + + // Swap bits across the left and right words + function exchangeLR(offset, mask) { + var t = ((this._lBlock >>> offset) ^ this._rBlock) & mask; + this._rBlock ^= t; + this._lBlock ^= t << offset; + } + + function exchangeRL(offset, mask) { + var t = ((this._rBlock >>> offset) ^ this._lBlock) & mask; + this._lBlock ^= t; + this._rBlock ^= t << offset; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.DES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.DES.decrypt(ciphertext, key, cfg); + */ + C.DES = BlockCipher._createHelper(DES); + + /** + * Triple-DES block cipher algorithm. + */ + var TripleDES = C_algo.TripleDES = BlockCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + // Make sure the key length is valid (64, 128 or >= 192 bit) + if (keyWords.length !== 2 && keyWords.length !== 4 && keyWords.length < 6) { + throw new Error('Invalid key length - 3DES requires the key length to be 64, 128, 192 or >192.'); + } + + // Extend the key according to the keying options defined in 3DES standard + var key1 = keyWords.slice(0, 2); + var key2 = keyWords.length < 4 ? keyWords.slice(0, 2) : keyWords.slice(2, 4); + var key3 = keyWords.length < 6 ? keyWords.slice(0, 2) : keyWords.slice(4, 6); + + // Create DES instances + this._des1 = DES.createEncryptor(WordArray.create(key1)); + this._des2 = DES.createEncryptor(WordArray.create(key2)); + this._des3 = DES.createEncryptor(WordArray.create(key3)); + }, + + encryptBlock: function (M, offset) { + this._des1.encryptBlock(M, offset); + this._des2.decryptBlock(M, offset); + this._des3.encryptBlock(M, offset); + }, + + decryptBlock: function (M, offset) { + this._des3.decryptBlock(M, offset); + this._des2.encryptBlock(M, offset); + this._des1.decryptBlock(M, offset); + }, + + keySize: 192 / 32, + + ivSize: 64 / 32, + + blockSize: 64 / 32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.TripleDES.encrypt(message, key, cfg); + * var plaintext = CryptoJS.TripleDES.decrypt(ciphertext, key, cfg); + */ + C.TripleDES = BlockCipher._createHelper(TripleDES); + }()); + + + return CryptoJS.TripleDES; + + })); + }(tripledes)); + return tripledesExports; +} + +var rc4Exports = {}; +var rc4 = { + get exports() { + return rc4Exports; + }, + set exports(v) { + rc4Exports = v; + }, +}; + +var hasRequiredRc4; + +function requireRc4() { + if (hasRequiredRc4) return rc4Exports; + hasRequiredRc4 = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireEncBase64(), requireMd5(), requireEvpkdf(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; + + /** + * RC4 stream cipher algorithm. + */ + var RC4 = C_algo.RC4 = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var key = this._key; + var keyWords = key.words; + var keySigBytes = key.sigBytes; + + // Init sbox + var S = this._S = []; + for (var i = 0; i < 256; i++) { + S[i] = i; + } + + // Key setup + for (var i = 0, j = 0; i < 256; i++) { + var keyByteIndex = i % keySigBytes; + var keyByte = (keyWords[keyByteIndex >>> 2] >>> (24 - (keyByteIndex % 4) * 8)) & 0xff; + + j = (j + S[i] + keyByte) % 256; + + // Swap + var t = S[i]; + S[i] = S[j]; + S[j] = t; + } + + // Counters + this._i = this._j = 0; + }, + + _doProcessBlock: function (M, offset) { + M[offset] ^= generateKeystreamWord.call(this); + }, + + keySize: 256 / 32, + + ivSize: 0 + }); + + function generateKeystreamWord() { + // Shortcuts + var S = this._S; + var i = this._i; + var j = this._j; + + // Generate keystream word + var keystreamWord = 0; + for (var n = 0; n < 4; n++) { + i = (i + 1) % 256; + j = (j + S[i]) % 256; + + // Swap + var t = S[i]; + S[i] = S[j]; + S[j] = t; + + keystreamWord |= S[(S[i] + S[j]) % 256] << (24 - n * 8); + } + + // Update counters + this._i = i; + this._j = j; + + return keystreamWord; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4.decrypt(ciphertext, key, cfg); + */ + C.RC4 = StreamCipher._createHelper(RC4); + + /** + * Modified RC4 stream cipher algorithm. + */ + var RC4Drop = C_algo.RC4Drop = RC4.extend({ + /** + * Configuration options. + * + * @property {number} drop The number of keystream words to drop. Default 192 + */ + cfg: RC4.cfg.extend({ + drop: 192 + }), + + _doReset: function () { + RC4._doReset.call(this); + + // Drop + for (var i = this.cfg.drop; i > 0; i--) { + generateKeystreamWord.call(this); + } + } + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RC4Drop.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RC4Drop.decrypt(ciphertext, key, cfg); + */ + C.RC4Drop = StreamCipher._createHelper(RC4Drop); + }()); + + + return CryptoJS.RC4; + + })); + }(rc4)); + return rc4Exports; +} + +var rabbitExports = {}; +var rabbit = { + get exports() { + return rabbitExports; + }, + set exports(v) { + rabbitExports = v; + }, +}; + +var hasRequiredRabbit; + +function requireRabbit() { + if (hasRequiredRabbit) return rabbitExports; + hasRequiredRabbit = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireEncBase64(), requireMd5(), requireEvpkdf(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; + + // Reusable objects + var S = []; + var C_ = []; + var G = []; + + /** + * Rabbit stream cipher algorithm + */ + var Rabbit = C_algo.Rabbit = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var K = this._key.words; + var iv = this.cfg.iv; + + // Swap endian + for (var i = 0; i < 4; i++) { + K[i] = (((K[i] << 8) | (K[i] >>> 24)) & 0x00ff00ff) | + (((K[i] << 24) | (K[i] >>> 8)) & 0xff00ff00); + } + + // Generate initial state values + var X = this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16) + ]; + + // Generate initial counter values + var C = this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) + ]; + + // Carry bit + this._b = 0; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + + // Modify the counters + for (var i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } + + // IV setup + if (iv) { + // Shortcuts + var IV = iv.words; + var IV_0 = IV[0]; + var IV_1 = IV[1]; + + // Generate four subvectors + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + var i1 = (i0 >>> 16) | (i2 & 0xffff0000); + var i3 = (i2 << 16) | (i0 & 0x0000ffff); + + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + } + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var X = this._X; + + // Iterate the system + nextState.call(this); + + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); + + for (var i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + + // Encrypt + M[offset + i] ^= S[i]; + } + }, + + blockSize: 128 / 32, + + ivSize: 64 / 32 + }); + + function nextState() { + // Shortcuts + var X = this._X; + var C = this._C; + + // Save old counter values + for (var i = 0; i < 8; i++) { + C_[i] = C[i]; + } + + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; + + // Calculate the g-values + for (var i = 0; i < 8; i++) { + var gx = X[i] + C[i]; + + // Construct high and low argument for squaring + var ga = gx & 0xffff; + var gb = gx >>> 16; + + // Calculate high and low result of squaring + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); + + // High XOR low + G[i] = gh ^ gl; + } + + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.Rabbit.encrypt(message, key, cfg); + * var plaintext = CryptoJS.Rabbit.decrypt(ciphertext, key, cfg); + */ + C.Rabbit = StreamCipher._createHelper(Rabbit); + }()); + + + return CryptoJS.Rabbit; + + })); + }(rabbit)); + return rabbitExports; +} + +var rabbitLegacyExports = {}; +var rabbitLegacy = { + get exports() { + return rabbitLegacyExports; + }, + set exports(v) { + rabbitLegacyExports = v; + }, +}; + +var hasRequiredRabbitLegacy; + +function requireRabbitLegacy() { + if (hasRequiredRabbitLegacy) return rabbitLegacyExports; + hasRequiredRabbitLegacy = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireEncBase64(), requireMd5(), requireEvpkdf(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function(){ + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var StreamCipher = C_lib.StreamCipher; + var C_algo = C.algo; + + // Reusable objects + var S = []; + var C_ = []; + var G = []; + + /** + * Rabbit stream cipher algorithm. + * + * This is a legacy version that neglected to convert the key to little-endian. + * This error doesn't affect the cipher's security, + * but it does affect its compatibility with other implementations. + */ + var RabbitLegacy = C_algo.RabbitLegacy = StreamCipher.extend({ + _doReset: function () { + // Shortcuts + var K = this._key.words; + var iv = this.cfg.iv; + + // Generate initial state values + var X = this._X = [ + K[0], (K[3] << 16) | (K[2] >>> 16), + K[1], (K[0] << 16) | (K[3] >>> 16), + K[2], (K[1] << 16) | (K[0] >>> 16), + K[3], (K[2] << 16) | (K[1] >>> 16) + ]; + + // Generate initial counter values + var C = this._C = [ + (K[2] << 16) | (K[2] >>> 16), (K[0] & 0xffff0000) | (K[1] & 0x0000ffff), + (K[3] << 16) | (K[3] >>> 16), (K[1] & 0xffff0000) | (K[2] & 0x0000ffff), + (K[0] << 16) | (K[0] >>> 16), (K[2] & 0xffff0000) | (K[3] & 0x0000ffff), + (K[1] << 16) | (K[1] >>> 16), (K[3] & 0xffff0000) | (K[0] & 0x0000ffff) + ]; + + // Carry bit + this._b = 0; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + + // Modify the counters + for (var i = 0; i < 8; i++) { + C[i] ^= X[(i + 4) & 7]; + } + + // IV setup + if (iv) { + // Shortcuts + var IV = iv.words; + var IV_0 = IV[0]; + var IV_1 = IV[1]; + + // Generate four subvectors + var i0 = (((IV_0 << 8) | (IV_0 >>> 24)) & 0x00ff00ff) | (((IV_0 << 24) | (IV_0 >>> 8)) & 0xff00ff00); + var i2 = (((IV_1 << 8) | (IV_1 >>> 24)) & 0x00ff00ff) | (((IV_1 << 24) | (IV_1 >>> 8)) & 0xff00ff00); + var i1 = (i0 >>> 16) | (i2 & 0xffff0000); + var i3 = (i2 << 16) | (i0 & 0x0000ffff); + + // Modify counter values + C[0] ^= i0; + C[1] ^= i1; + C[2] ^= i2; + C[3] ^= i3; + C[4] ^= i0; + C[5] ^= i1; + C[6] ^= i2; + C[7] ^= i3; + + // Iterate the system four times + for (var i = 0; i < 4; i++) { + nextState.call(this); + } + } + }, + + _doProcessBlock: function (M, offset) { + // Shortcut + var X = this._X; + + // Iterate the system + nextState.call(this); + + // Generate four keystream words + S[0] = X[0] ^ (X[5] >>> 16) ^ (X[3] << 16); + S[1] = X[2] ^ (X[7] >>> 16) ^ (X[5] << 16); + S[2] = X[4] ^ (X[1] >>> 16) ^ (X[7] << 16); + S[3] = X[6] ^ (X[3] >>> 16) ^ (X[1] << 16); + + for (var i = 0; i < 4; i++) { + // Swap endian + S[i] = (((S[i] << 8) | (S[i] >>> 24)) & 0x00ff00ff) | + (((S[i] << 24) | (S[i] >>> 8)) & 0xff00ff00); + + // Encrypt + M[offset + i] ^= S[i]; + } + }, + + blockSize: 128 / 32, + + ivSize: 64 / 32 + }); + + function nextState() { + // Shortcuts + var X = this._X; + var C = this._C; + + // Save old counter values + for (var i = 0; i < 8; i++) { + C_[i] = C[i]; + } + + // Calculate new counter values + C[0] = (C[0] + 0x4d34d34d + this._b) | 0; + C[1] = (C[1] + 0xd34d34d3 + ((C[0] >>> 0) < (C_[0] >>> 0) ? 1 : 0)) | 0; + C[2] = (C[2] + 0x34d34d34 + ((C[1] >>> 0) < (C_[1] >>> 0) ? 1 : 0)) | 0; + C[3] = (C[3] + 0x4d34d34d + ((C[2] >>> 0) < (C_[2] >>> 0) ? 1 : 0)) | 0; + C[4] = (C[4] + 0xd34d34d3 + ((C[3] >>> 0) < (C_[3] >>> 0) ? 1 : 0)) | 0; + C[5] = (C[5] + 0x34d34d34 + ((C[4] >>> 0) < (C_[4] >>> 0) ? 1 : 0)) | 0; + C[6] = (C[6] + 0x4d34d34d + ((C[5] >>> 0) < (C_[5] >>> 0) ? 1 : 0)) | 0; + C[7] = (C[7] + 0xd34d34d3 + ((C[6] >>> 0) < (C_[6] >>> 0) ? 1 : 0)) | 0; + this._b = (C[7] >>> 0) < (C_[7] >>> 0) ? 1 : 0; + + // Calculate the g-values + for (var i = 0; i < 8; i++) { + var gx = X[i] + C[i]; + + // Construct high and low argument for squaring + var ga = gx & 0xffff; + var gb = gx >>> 16; + + // Calculate high and low result of squaring + var gh = ((((ga * ga) >>> 17) + ga * gb) >>> 15) + gb * gb; + var gl = (((gx & 0xffff0000) * gx) | 0) + (((gx & 0x0000ffff) * gx) | 0); + + // High XOR low + G[i] = gh ^ gl; + } + + // Calculate new state values + X[0] = (G[0] + ((G[7] << 16) | (G[7] >>> 16)) + ((G[6] << 16) | (G[6] >>> 16))) | 0; + X[1] = (G[1] + ((G[0] << 8) | (G[0] >>> 24)) + G[7]) | 0; + X[2] = (G[2] + ((G[1] << 16) | (G[1] >>> 16)) + ((G[0] << 16) | (G[0] >>> 16))) | 0; + X[3] = (G[3] + ((G[2] << 8) | (G[2] >>> 24)) + G[1]) | 0; + X[4] = (G[4] + ((G[3] << 16) | (G[3] >>> 16)) + ((G[2] << 16) | (G[2] >>> 16))) | 0; + X[5] = (G[5] + ((G[4] << 8) | (G[4] >>> 24)) + G[3]) | 0; + X[6] = (G[6] + ((G[5] << 16) | (G[5] >>> 16)) + ((G[4] << 16) | (G[4] >>> 16))) | 0; + X[7] = (G[7] + ((G[6] << 8) | (G[6] >>> 24)) + G[5]) | 0; + } + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.RabbitLegacy.encrypt(message, key, cfg); + * var plaintext = CryptoJS.RabbitLegacy.decrypt(ciphertext, key, cfg); + */ + C.RabbitLegacy = StreamCipher._createHelper(RabbitLegacy); + }()); + + + return CryptoJS.RabbitLegacy; + + })); + }(rabbitLegacy)); + return rabbitLegacyExports; +} + +var blowFishExports = {}; +var blowFish = { + get exports() { + return blowFishExports; + }, + set exports(v) { + blowFishExports = v; + }, +}; + +var hasRequiredBlowFish; + +function requireBlowFish() { + if (hasRequiredBlowFish) return blowFishExports; + hasRequiredBlowFish = 1; + (function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireEncBase64(), requireMd5(), requireEvpkdf(), requireCipherCore()); + } + }(commonjsGlobal, function (CryptoJS) { + + (function () { + // Shortcuts + var C = CryptoJS; + var C_lib = C.lib; + var BlockCipher = C_lib.BlockCipher; + var C_algo = C.algo; + + const N = 16; + + //Origin pbox and sbox, derived from PI + const ORIG_P = [ + 0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344, + 0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89, + 0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C, + 0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917, + 0x9216D5D9, 0x8979FB1B + ]; + + const ORIG_S = [ + [ 0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7, + 0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99, + 0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16, + 0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E, + 0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE, + 0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013, + 0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF, + 0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E, + 0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60, + 0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440, + 0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE, + 0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A, + 0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E, + 0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677, + 0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193, + 0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032, + 0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88, + 0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239, + 0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E, + 0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0, + 0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3, + 0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98, + 0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88, + 0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE, + 0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6, + 0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D, + 0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B, + 0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7, + 0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA, + 0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463, + 0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F, + 0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09, + 0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3, + 0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB, + 0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279, + 0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8, + 0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB, + 0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82, + 0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB, + 0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573, + 0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0, + 0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B, + 0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790, + 0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8, + 0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4, + 0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0, + 0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7, + 0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C, + 0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD, + 0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1, + 0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299, + 0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9, + 0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477, + 0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF, + 0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49, + 0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF, + 0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA, + 0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5, + 0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41, + 0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915, + 0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400, + 0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915, + 0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664, + 0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A ], + [ 0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623, + 0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266, + 0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1, + 0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E, + 0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6, + 0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1, + 0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E, + 0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1, + 0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737, + 0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8, + 0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF, + 0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD, + 0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701, + 0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7, + 0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41, + 0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331, + 0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF, + 0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF, + 0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E, + 0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87, + 0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C, + 0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2, + 0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16, + 0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD, + 0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B, + 0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509, + 0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E, + 0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3, + 0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F, + 0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A, + 0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4, + 0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960, + 0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66, + 0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28, + 0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802, + 0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84, + 0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510, + 0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF, + 0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14, + 0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E, + 0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50, + 0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7, + 0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8, + 0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281, + 0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99, + 0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696, + 0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128, + 0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73, + 0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0, + 0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0, + 0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105, + 0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250, + 0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3, + 0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285, + 0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00, + 0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061, + 0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB, + 0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E, + 0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735, + 0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC, + 0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9, + 0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340, + 0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20, + 0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7 ], + [ 0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934, + 0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068, + 0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF, + 0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840, + 0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45, + 0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504, + 0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A, + 0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB, + 0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE, + 0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6, + 0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42, + 0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B, + 0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2, + 0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB, + 0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527, + 0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B, + 0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33, + 0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C, + 0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3, + 0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC, + 0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17, + 0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564, + 0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B, + 0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115, + 0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922, + 0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728, + 0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0, + 0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E, + 0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37, + 0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D, + 0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804, + 0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B, + 0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3, + 0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB, + 0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D, + 0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C, + 0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350, + 0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9, + 0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A, + 0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE, + 0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D, + 0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC, + 0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F, + 0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61, + 0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2, + 0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9, + 0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2, + 0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C, + 0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E, + 0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633, + 0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10, + 0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169, + 0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52, + 0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027, + 0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5, + 0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62, + 0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634, + 0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76, + 0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24, + 0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC, + 0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4, + 0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C, + 0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837, + 0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0 ], + [ 0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B, + 0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE, + 0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B, + 0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4, + 0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8, + 0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6, + 0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304, + 0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22, + 0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4, + 0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6, + 0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9, + 0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59, + 0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593, + 0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51, + 0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28, + 0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C, + 0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B, + 0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28, + 0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C, + 0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD, + 0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A, + 0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319, + 0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB, + 0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F, + 0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991, + 0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32, + 0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680, + 0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166, + 0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE, + 0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB, + 0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5, + 0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47, + 0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370, + 0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D, + 0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84, + 0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048, + 0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8, + 0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD, + 0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9, + 0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7, + 0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38, + 0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F, + 0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C, + 0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525, + 0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1, + 0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442, + 0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964, + 0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E, + 0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8, + 0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D, + 0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F, + 0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299, + 0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02, + 0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC, + 0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614, + 0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A, + 0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6, + 0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B, + 0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0, + 0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060, + 0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E, + 0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9, + 0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F, + 0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6 ] + ]; + + var BLOWFISH_CTX = { + pbox: [], + sbox: [] + } + + function F(ctx, x){ + let a = (x >> 24) & 0xFF; + let b = (x >> 16) & 0xFF; + let c = (x >> 8) & 0xFF; + let d = x & 0xFF; + + let y = ctx.sbox[0][a] + ctx.sbox[1][b]; + y = y ^ ctx.sbox[2][c]; + y = y + ctx.sbox[3][d]; + + return y; + } + + function BlowFish_Encrypt(ctx, left, right){ + let Xl = left; + let Xr = right; + let temp; + + for(let i = 0; i < N; ++i){ + Xl = Xl ^ ctx.pbox[i]; + Xr = F(ctx, Xl) ^ Xr; + + temp = Xl; + Xl = Xr; + Xr = temp; + } + + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ ctx.pbox[N]; + Xl = Xl ^ ctx.pbox[N + 1]; + + return {left: Xl, right: Xr}; + } + + function BlowFish_Decrypt(ctx, left, right){ + let Xl = left; + let Xr = right; + let temp; + + for(let i = N + 1; i > 1; --i){ + Xl = Xl ^ ctx.pbox[i]; + Xr = F(ctx, Xl) ^ Xr; + + temp = Xl; + Xl = Xr; + Xr = temp; + } + + temp = Xl; + Xl = Xr; + Xr = temp; + + Xr = Xr ^ ctx.pbox[1]; + Xl = Xl ^ ctx.pbox[0]; + + return {left: Xl, right: Xr}; + } + + /** + * Initialization ctx's pbox and sbox. + * + * @param {Object} ctx The object has pbox and sbox. + * @param {Array} key An array of 32-bit words. + * @param {int} keysize The length of the key. + * + * @example + * + * BlowFishInit(BLOWFISH_CTX, key, 128/32); + */ + function BlowFishInit(ctx, key, keysize) + { + for(let Row = 0; Row < 4; Row++) + { + ctx.sbox[Row] = []; + for(let Col = 0; Col < 256; Col++) + { + ctx.sbox[Row][Col] = ORIG_S[Row][Col]; + } + } + + let keyIndex = 0; + for(let index = 0; index < N + 2; index++) + { + ctx.pbox[index] = ORIG_P[index] ^ key[keyIndex]; + keyIndex++; + if(keyIndex >= keysize) + { + keyIndex = 0; + } + } + + let Data1 = 0; + let Data2 = 0; + let res = 0; + for(let i = 0; i < N + 2; i += 2) + { + res = BlowFish_Encrypt(ctx, Data1, Data2); + Data1 = res.left; + Data2 = res.right; + ctx.pbox[i] = Data1; + ctx.pbox[i + 1] = Data2; + } + + for(let i = 0; i < 4; i++) + { + for(let j = 0; j < 256; j += 2) + { + res = BlowFish_Encrypt(ctx, Data1, Data2); + Data1 = res.left; + Data2 = res.right; + ctx.sbox[i][j] = Data1; + ctx.sbox[i][j + 1] = Data2; + } + } + + return true; + } + + /** + * Blowfish block cipher algorithm. + */ + var Blowfish = C_algo.Blowfish = BlockCipher.extend({ + _doReset: function () { + // Skip reset of nRounds has been set before and key did not change + if (this._keyPriorReset === this._key) { + return; + } + + // Shortcuts + var key = this._keyPriorReset = this._key; + var keyWords = key.words; + var keySize = key.sigBytes / 4; + + //Initialization pbox and sbox + BlowFishInit(BLOWFISH_CTX, keyWords, keySize); + }, + + encryptBlock: function (M, offset) { + var res = BlowFish_Encrypt(BLOWFISH_CTX, M[offset], M[offset + 1]); + M[offset] = res.left; + M[offset + 1] = res.right; + }, + + decryptBlock: function (M, offset) { + var res = BlowFish_Decrypt(BLOWFISH_CTX, M[offset], M[offset + 1]); + M[offset] = res.left; + M[offset + 1] = res.right; + }, + + blockSize: 64/32, + + keySize: 128/32, + + ivSize: 64/32 + }); + + /** + * Shortcut functions to the cipher's object interface. + * + * @example + * + * var ciphertext = CryptoJS.Blowfish.encrypt(message, key, cfg); + * var plaintext = CryptoJS.Blowfish.decrypt(ciphertext, key, cfg); + */ + C.Blowfish = BlockCipher._createHelper(Blowfish); + }()); + + + return CryptoJS.BlowFish; + + })); + }(blowFish)); + return blowFishExports; +} + +(function(module, exports){ + (function(root, factory, undef){ + { + // CommonJS + module.exports = factory(requireCore(), requireX64Core(), requireLibTypedarrays(), requireEncUtf16(), requireEncBase64(), requireEncBase64url(), requireMd5(), requireSha1(), requireSha256(), requireSha224(), requireSha512(), requireSha384(), requireSha3(), requireRipemd160(), requireHmac(), requirePbkdf2(), requireEvpkdf(), requireCipherCore(), requireModeCfb(), requireModeCtr(), requireModeCtrGladman(), requireModeOfb(), requireModeEcb(), requirePadAnsix923(), requirePadIso10126(), requirePadIso97971(), requirePadZeropadding(), requirePadNopadding(), requireFormatHex(), requireAes(), requireTripledes(), requireRc4(), requireRabbit(), requireRabbitLegacy(), requireBlowFish()); + } + }(commonjsGlobal, function (CryptoJS) { + + return CryptoJS; + + })); +}(src$1)); + +var src = srcExports; + +export { src as default }; +//# sourceMappingURL=bundle.js.map diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/js/utils.js b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/js/utils.js new file mode 100644 index 0000000..44b9d4a --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/js/utils.js @@ -0,0 +1,22 @@ +/* + * Copyright (C) 2023 Huawei Device Co., Ltd. + * Licensed under the MIT License, (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://opensource.org/licenses/MIT + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export function hasOwn(obj,value){ + for (let key in obj) { + if (key === value) { + return true + } + } + return false +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/module.json b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/module.json new file mode 100644 index 0000000..3fb2ace --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/module.json @@ -0,0 +1,27 @@ +{ + "app": { + "bundleName": "cn.openharmony.crypto", + "versionCode": 1000002, + "versionName": "2.0.3", + "minAPIVersion": 9, + "targetAPIVersion": 10, + "apiReleaseType": "Release", + "compileSdkVersion": "4.0.10.16", + "compileSdkType": "OpenHarmony", + "appEnvironments": [], + "bundleType": "app" + }, + "module": { + "name": "library", + "type": "har", + "deviceTypes": [ + "default", + "tablet" + ], + "packageName": "@ohos/crypto-js", + "installationFree": false, + "virtualMachine": "ark9.0.0.0", + "compileMode": "esmodule", + "dependencies": [] + } +} diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/base/element/string.json b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/base/element/string.json new file mode 100644 index 0000000..78fe302 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/en_US/element/string.json b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/en_US/element/string.json new file mode 100644 index 0000000..78fe302 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/en_US/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/zh_CN/element/string.json b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/zh_CN/element/string.json new file mode 100644 index 0000000..78fe302 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js/src/main/resources/zh_CN/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from npm package" + } + ] +} diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/CHANGELOG.md b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/CHANGELOG.md new file mode 100644 index 0000000..f62e2be --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/CHANGELOG.md @@ -0,0 +1,4 @@ +## 1.0.0 +- 修复once断言问题 +## 1.0.0-rc +- 提供DevEco Studio预览器场景使能的MockSetup装饰器 \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/LICENSE b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/LICENSE new file mode 100644 index 0000000..4a45986 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/README.md b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/README.md new file mode 100644 index 0000000..ea667a1 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/README.md @@ -0,0 +1,82 @@ +# Hamock + +## 简介 + +Hamock 是 OpenHarmony 上的模拟框架,提供预览场景的模拟功能。 + +## 下载安装 + +```bash +ohpm install @ohos/hamock +``` + +OpenHarmony ohpm 环境配置等更多内容,请参考[如何安装 OpenHarmony ohpm 包](https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md) + +## 使用示例 + +Hamock 提供了 @MockSetup 用于修饰 Mock 方法,仅支持声明式范式的组件。当开发者预览该组件时,预览运行时将在组件初始化时执行被 @MockSetup 修饰的方法。因此,开发者可以在这个被修饰的方法内重定义组件的方法或重赋值组件的属性,其将在预览时生效。 + +> 说明: +> @MockSetup 修饰的方法仅在预览场景会自动触发,并先于组件的 aboutToAppear 执行。 + +### UI组件的方法 + +在 ArkTS 页面代码中引入 Hamock。在目标组件中定义一个方法,并用 @MockSetup 修饰该方法。在这个方法中,使用 MockKit 模拟目标方法。 + +```typescript +import { MockKit, when, MockSetup } from '@ohos/hamock'; + +@Entry +@Component +struct Index { + ... + @MockSetup + randomName() { + let mocker: MockKit = new MockKit(); + let mockfunc: Object = mocker.mockFunc(this, this.method1); + // mock 指定的方法在指定入参的返回值 + when(mockfunc)('test').afterReturn(1); + } + ... + // 业务场景调用方法 + const result: number = this.method1('test'); // in previewer, result = 1 +} +``` + +### UI组件的属性 + +在 ArkTS 页面代码中引入 Hamock。在目标组件中定义一个方法,并用 @MockSetup 修饰该方法。在这个方法中,对于需要 Mock 的属性,可以重新赋值。 + +```typescript +import { MockSetup } from '@ohos/hamock'; + +@Component +struct Person { + @Prop species: string; + ... + // 在 @MockSetup 片段中,定义对象属性 + @MockSetup + randomName() { + this.species = 'primates'; + } + ... + // 业务场景调用属性(如果从初始化到调用期间,该属性无变化) + const result: string = this.species; // in previewer, result = primates +} +``` + +## 约束与限制 + +在下述版本验证通过: + +DevEco Studio: 4.1 (4.1.3.400), SDK: API11 (4.1.0.36) + +MockSetup 仅在 API11 支持。 + +## 贡献代码 + +使用过程中发现任何问题都可以提[Issue](https://gitee.com/openharmony/testfwk_arkxtest/issues) 给我们,当然,我们也非常欢迎你给我们提[PR](https://gitee.com/openharmony/testfwk_arkxtest/pulls) 。 + +## 开源协议 + +本项目基于 [Apache License 2.0](https://gitee.com/openharmony/testfwk_arkxtest/blob/master/hamock/LICENSE) ,请自由地享受和参与开源。 \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/build-profile.json5 b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/build-profile.json5 new file mode 100644 index 0000000..cf61dec --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/build-profile.json5 @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + "apiType": "stageMode", + "buildOption": { + }, + "targets": [ + { + "name": "default" + } + ] +} diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/hvigorfile.js b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/hvigorfile.js new file mode 100644 index 0000000..76915cf --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/hvigorfile.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/hvigorfile.ts b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/hvigorfile.ts new file mode 100644 index 0000000..ba30640 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/hvigorfile.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. +export { harTasks } from '@ohos/hvigor-ohos-plugin'; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.d.ts b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.d.ts new file mode 100644 index 0000000..d6179ad --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.d.ts @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ArgumentMatchers { + static any; + static anyString; + static anyBoolean; + static anyNumber; + static anyObj; + static anyFunction; + static matchRegexs(Regex: RegExp): void +} + +declare interface when { + afterReturn(value: any): any + afterReturnNothing(): undefined + afterAction(action: any): any + afterThrow(e_msg: string): string + (argMatchers?: any): when; +} + +export const when: when; + +export interface VerificationMode { + times(count: Number): void + never(): void + once(): void + atLeast(count: Number): void + atMost(count: Number): void +} + +export class MockKit { + constructor() + mockFunc(obj: Object, func: Function): Function + mockObject(obj: Object): Object + verify(methodName: String, argsArray: Array): VerificationMode + ignoreMock(obj: Object, func: Function): void + clear(obj: Object): void + clearAll(): void +} + +export declare function MockSetup( + target: Object, + propertyName: string | Symbol, + descriptor: TypedPropertyDescriptor<() => void> +): void; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ets b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ets new file mode 100644 index 0000000..3e4ab4c --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ets @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { MockSetup, MockKit, when } from './src/main/mock/MockKit'; +export { ArgumentMatchers } from './src/main/mock/ArgumentMatchers'; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.js b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.js new file mode 100644 index 0000000..b3832e8 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.js @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export { MockSetup, MockKit, when } from './src/main/mock/MockKit.js'; +export { ArgumentMatchers } from './src/main/mock/ArgumentMatchers.js'; diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ts b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ts new file mode 100644 index 0000000..df0e313 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/index.ts @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2021-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export { MockSetup, MockKit, when } from './src/main/mock/MockKit.js'; +export { ArgumentMatchers } from './src/main/mock/ArgumentMatchers.js'; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/oh-package.json5 b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/oh-package.json5 new file mode 100644 index 0000000..49f3683 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/oh-package.json5 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +{ + name: '@ohos/hamock', + version: '1.0.0', + description: 'A mock framework for OpenHarmony application.', + main: 'index.ets', + author: 'huawei', + license: 'Apache-2.0', + dependencies: {}, + ohos: { + org: 'ohos', + }, + types: 'index.d.ts' +} diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ArgumentMatchers.js b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ArgumentMatchers.js new file mode 100644 index 0000000..610c540 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ArgumentMatchers.js @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +export class ArgumentMatchers { + constructor() { + this.ANY = ""; + this.ANY_STRING = ""; + this.ANY_BOOLEAN = ""; + this.ANY_NUMBER = ""; + this.ANY_OBJECT = ""; + this.ANY_FUNCTION = ""; + this.MATCH_REGEXS = ""; + } + static any() { + } + static anyString() { + } + static anyBoolean() { + } + static anyNumber() { + } + static anyObj() { + } + static anyFunction() { + } + static matchRegexs(regex) { + if (ArgumentMatchers.isRegExp(regex)) { + return regex; + } + throw Error("not a regex"); + } + static isRegExp(value) { + return Object.prototype.toString.call(value) === "[object RegExp]"; + } + matcheReturnKey(...args) { + let arg = args[0]; + let regex = args[1]; + let stubSetKey = args[2]; + if (stubSetKey && stubSetKey == this.ANY) { + return this.ANY; + } + if (typeof arg === "string" && !regex) { + return this.ANY_STRING; + } + if (typeof arg === "boolean" && !regex) { + return this.ANY_BOOLEAN; + } + if (typeof arg === "number" && !regex) { + return this.ANY_NUMBER; + } + if (typeof arg === "object" && !regex) { + return this.ANY_OBJECT; + } + if (typeof arg === "function" && !regex) { + return this.ANY_FUNCTION; + } + if (typeof arg === "string" && regex) { + return regex.test(arg); + } + return null; + } + matcheStubKey(key) { + if (key === ArgumentMatchers.any) { + return this.ANY; + } + if (key === ArgumentMatchers.anyString) { + return this.ANY_STRING; + } + if (key === ArgumentMatchers.anyBoolean) { + return this.ANY_BOOLEAN; + } + if (key === ArgumentMatchers.anyNumber) { + return this.ANY_NUMBER; + } + if (key === ArgumentMatchers.anyObj) { + return this.ANY_OBJECT; + } + if (key === ArgumentMatchers.anyFunction) { + return this.ANY_FUNCTION; + } + if (ArgumentMatchers.isRegExp(key)) { + return key; + } + return null; + } +} diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ArgumentMatchers.ts b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ArgumentMatchers.ts new file mode 100644 index 0000000..0e0e64c --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ArgumentMatchers.ts @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export class ArgumentMatchers { + ANY = ""; + ANY_STRING = ""; + ANY_BOOLEAN = ""; + ANY_NUMBER = ""; + ANY_OBJECT = ""; + ANY_FUNCTION = ""; + MATCH_REGEXS = ""; + + static any() { + } + + static anyString() { + } + + static anyBoolean() { + } + + static anyNumber() { + } + + static anyObj() { + } + + static anyFunction() { + } + + static matchRegexs(regex: any) { + if (ArgumentMatchers.isRegExp(regex)) { + return regex; + } + throw Error("not a regex"); + } + + static isRegExp(value: string) { + return Object.prototype.toString.call(value) === "[object RegExp]"; + } + + matcheReturnKey(...args: Array) { + let arg = args[0]; + let regex = args[1]; + let stubSetKey = args[2]; + + if (stubSetKey && stubSetKey == this.ANY) { + return this.ANY; + } + + if (typeof arg === "string" && !regex) { + return this.ANY_STRING; + } + + if (typeof arg === "boolean" && !regex) { + return this.ANY_BOOLEAN; + } + + if (typeof arg === "number" && !regex) { + return this.ANY_NUMBER; + } + + if (typeof arg === "object" && !regex) { + return this.ANY_OBJECT; + } + + if (typeof arg === "function" && !regex) { + return this.ANY_FUNCTION; + } + + if (typeof arg === "string" && regex) { + return regex.test(arg); + } + + return null; + } + + matcheStubKey(key: any) { + + if (key === ArgumentMatchers.any) { + return this.ANY; + } + + if (key === ArgumentMatchers.anyString) { + return this.ANY_STRING; + } + if (key === ArgumentMatchers.anyBoolean) { + return this.ANY_BOOLEAN; + } + if (key === ArgumentMatchers.anyNumber) { + return this.ANY_NUMBER; + } + if (key === ArgumentMatchers.anyObj) { + return this.ANY_OBJECT; + } + if (key === ArgumentMatchers.anyFunction) { + return this.ANY_FUNCTION; + } + + if (ArgumentMatchers.isRegExp(key)) { + return key; + } + + return null; + } +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ExtendInterface.js b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ExtendInterface.js new file mode 100644 index 0000000..325be96 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ExtendInterface.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class ExtendInterface { + constructor(mocker) { + this.mocker = mocker; + } + stub() { + this.params = arguments; + return this; + } + stubMockedCall(returnInfo) { + this.mocker.stubApply(this, this.params, returnInfo); + } + afterReturn(value) { + this.stubMockedCall(function () { + return value; + }); + } + afterReturnNothing() { + this.stubMockedCall(function () { + return undefined; + }); + } + afterAction(action) { + this.stubMockedCall(action); + } + afterThrow(msg) { + this.stubMockedCall(function () { + throw msg; + }); + } + clear(obj) { + this.mocker.clear(obj); + } +} +export default ExtendInterface; diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ExtendInterface.ts b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ExtendInterface.ts new file mode 100644 index 0000000..8e27e2e --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/ExtendInterface.ts @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { MockKit } from "./MockKit.js"; + +class ExtendInterface { + + private mocker: MockKit + private params: any + + constructor(mocker: MockKit) { + this.mocker = mocker; + } + + stub() { + this.params = arguments; + return this; + } + + stubMockedCall(returnInfo: any) { + this.mocker.stubApply(this, this.params, returnInfo); + } + + afterReturn(value: any) { + this.stubMockedCall(function () { + return value; + }); + } + + afterReturnNothing() { + this.stubMockedCall(function () { + return undefined; + }); + } + + afterAction(action: Function) { + this.stubMockedCall(action); + } + + afterThrow(msg: string) { + this.stubMockedCall(function () { + throw msg; + }); + } + + clear(obj?: any) { + this.mocker.clear(obj); + } +} + +export default ExtendInterface; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/MockKit.js b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/MockKit.js new file mode 100644 index 0000000..01a4bf3 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/MockKit.js @@ -0,0 +1,253 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import ExtendInterface from "./ExtendInterface.js"; +import VerificationMode from "./VerificationMode.js"; +import { ArgumentMatchers } from "./ArgumentMatchers.js"; +class MockKit { + constructor() { + this.mFunctions = []; + this.stubs = new Map(); + this.recordCalls = new Map(); + this.currentSetKey = new Map(); + this.mockObj = null; + this.recordMockedMethod = new Map(); + this.mFunctions = []; + this.stubs = new Map(); + this.recordCalls = new Map(); + this.currentSetKey = new Map(); + this.mockObj = null; + this.recordMockedMethod = new Map(); + } + init() { + this.reset(); + } + reset() { + this.mFunctions = []; + this.stubs = new Map(); + this.recordCalls = new Map(); + this.currentSetKey = new Map(); + this.mockObj = null; + this.recordMockedMethod = new Map(); + } + clearAll() { + this.reset(); + } + clear(obj) { + if (!obj) throw Error("Please enter an object to be cleaned"); + if (typeof (obj) !== 'object' && typeof (obj) !== 'function') throw new Error('Not a object or static class'); + this.recordMockedMethod.forEach(function (value, key, map) { + if (key) { + obj[key] = value; + } + }); + } + ignoreMock(obj, method) { + if (typeof (obj) !== 'object' && typeof (obj) !== 'function') throw new Error('Not a object or static class'); + if (typeof (method) !== 'function') throw new Error('Not a function'); + let og = this.recordMockedMethod.get(method.propName); + if (og) { + obj[method.propName] = og; + this.recordMockedMethod.set(method.propName, undefined); + } + } + extend(dest, source) { + dest["stub"] = source["stub"]; + dest["afterReturn"] = source["afterReturn"]; + dest["afterReturnNothing"] = source["afterReturnNothing"]; + dest["afterAction"] = source["afterAction"]; + dest["afterThrow"] = source["afterThrow"]; + dest["stubMockedCall"] = source["stubMockedCall"]; + dest["clear"] = source["clear"]; + return dest; + } + stubApply(f, params, returnInfo) { + let values = this.stubs.get(f); + if (!values) { + values = new Map(); + } + let key = params[0]; + if (typeof key === "undefined") { + key = "anonymous-mock-" + f.propName; + } + let matcher = new ArgumentMatchers(); + if (matcher.matcheStubKey(key)) { + key = matcher.matcheStubKey(key); + if (key) { + this.currentSetKey.set(f, key); + } + } + values.set(key, returnInfo); + this.stubs.set(f, values); + } + getReturnInfo(f, params) { + let values = this.stubs.get(f); + if (!values) { + return undefined; + } + let retrunKet = params[0]; + if (typeof retrunKet === "undefined") { + retrunKet = "anonymous-mock-" + f.propName; + } + let stubSetKey = this.currentSetKey.get(f); + + if (stubSetKey && (typeof (retrunKet) !== "undefined")) { + retrunKet = stubSetKey; + } + let matcher = new ArgumentMatchers(); + if (matcher.matcheReturnKey(params[0], undefined, stubSetKey) && matcher.matcheReturnKey(params[0], undefined, stubSetKey) !== stubSetKey) { + retrunKet = params[0]; + } + values.forEach(function (value, key, map) { + if (ArgumentMatchers.isRegExp(key) && matcher.matcheReturnKey(params[0], key)) { + retrunKet = key; + } + }); + return values.get(retrunKet); + } + findName(obj, value) { + let properties = this.findProperties(obj); + let name = ''; + properties.filter((item) => (item !== 'caller' && item !== 'arguments')).forEach(function (va1, idx, array) { + if (obj[va1] === value) { + name = va1; + } + }); + return name; + } + isFunctionFromPrototype(f, container, propName) { + if (container.constructor !== Object && container.constructor.prototype !== container) { + return container.constructor.prototype[propName] === f; + } + return false; + } + findProperties(obj, ...arg) { + function getProperty(new_obj) { + if (new_obj.__proto__ === null) { + return []; + } + let properties = Object.getOwnPropertyNames(new_obj); + return [...properties, ...getProperty(new_obj.__proto__)]; + } + return getProperty(obj); + } + recordMethodCall(originalMethod, args) { + originalMethod['getName'] = function () { + return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]; + }; + let name = originalMethod.getName(); + let arglistString = name + '(' + Array.from(args).toString() + ')'; + let records = this.recordCalls.get(arglistString); + if (!records) { + records = 0; + } + records++; + this.recordCalls.set(arglistString, records); + } + mockFunc(originalObject, originalMethod) { + let tmp = this; + this.originalMethod = originalMethod; + const _this = this; + let f = function () { + let args = arguments; + let action = tmp.getReturnInfo(f, args); + if (originalMethod) { + tmp.recordMethodCall(originalMethod, args); + } + if (action) { + return action.apply(_this, args); + } + }; + f.container = null || originalObject; + f.original = originalMethod || null; + if (originalObject && originalMethod) { + if (typeof (originalMethod) != 'function') + throw new Error('Not a function'); + var name = this.findName(originalObject, originalMethod); + originalObject[name] = f; + this.recordMockedMethod.set(name, originalMethod); + f.propName = name; + f.originalFromPrototype = this.isFunctionFromPrototype(f.original, originalObject, f.propName); + } + f.mocker = this; + this.mFunctions.push(f); + this.extend(f, new ExtendInterface(this)); + return f; + } + verify(methodName, argsArray) { + if (!methodName) { + throw Error("not a function name"); + } + let a = this.recordCalls.get(methodName + '(' + argsArray.toString() + ')'); + return new VerificationMode(a ? a : 0); + } + mockObject(object) { + if (!object || typeof object === "string") { + throw Error(`this ${object} cannot be mocked`); + } + const _this = this; + let mockedObject = {}; + let keys = Reflect.ownKeys(object); + keys.filter(key => (typeof Reflect.get(object, key)) === 'function') + .forEach((key) => { + mockedObject[key] = object[key]; + mockedObject[key] = _this.mockFunc(mockedObject, mockedObject[key]); + }); + return mockedObject; + } +} +function ifMockedFunction(f) { + if (Object.prototype.toString.call(f) != "[object Function]" && + Object.prototype.toString.call(f) != "[object AsyncFunction]") { + throw Error("not a function"); + } + if (!f.stub) { + throw Error("not a mock function"); + } + return true; +} +function when(f) { + if (ifMockedFunction(f)) { + return f.stub.bind(f); + } +} +function MockSetup(target, propertyName, descriptor) { + const aboutToAppearOrigin = target.aboutToAppear; + const setup = descriptor.value; + target.aboutToAppear = function (...args) { + if (target.__Param) { // copy attributes and params of the original context + try { + const map = target.__Param; + for (const [key, val] of map) { + this[key] = val; // 'this' refers to context of current function + } + } + catch (e) { + throw new Error(`Mock setup param error: ${e}`); + } + } + if (setup) { // apply the mock content + try { + setup.apply(this); + } + catch (e) { + throw new Error(`Mock setup apply error: ${e}`); + } + } + if (aboutToAppearOrigin) { // append to aboutToAppear function of the original context + aboutToAppearOrigin.apply(this, args); + } + }; +} +export { MockSetup, MockKit, when }; diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/MockKit.ts b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/MockKit.ts new file mode 100644 index 0000000..a9f965a --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/MockKit.ts @@ -0,0 +1,294 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ExtendInterface from "./ExtendInterface.js"; +import VerificationMode from "./VerificationMode.js"; +import { ArgumentMatchers } from "./ArgumentMatchers.js"; + +interface IFunction extends Function { + container: any; + original: any; + propName: string; + originalFromPrototype: boolean + mocker: MockKit +} + +class MockKit { + + private mFunctions:Array = []; + private stubs = new Map(); + private recordCalls = new Map(); + private currentSetKey = new Map(); + private mockObj = null; + private recordMockedMethod = new Map(); + private originalMethod: any; + + constructor() { + this.mFunctions = []; + this.stubs = new Map(); + this.recordCalls = new Map(); + this.currentSetKey = new Map(); + this.mockObj = null; + this.recordMockedMethod = new Map(); + } + + init() { + this.reset(); + } + + reset() { + this.mFunctions = []; + this.stubs = new Map() + this.recordCalls = new Map(); + this.currentSetKey = new Map(); + this.mockObj = null; + this.recordMockedMethod = new Map(); + } + + clearAll() { + this.reset(); + } + + clear(obj: any) { + if (!obj) throw Error("Please enter an object to be cleaned"); + if (typeof (obj) != 'object') throw new Error('Not a object'); + this.recordMockedMethod.forEach(function (value, key, map) { + if (key) { + obj[key] = value; + } + }); + } + + ignoreMock(obj:any, method: any) { + if (typeof (obj) != 'object') throw new Error('Not a object'); + if (typeof (method) != 'function') throw new Error('Not a function'); + let og = this.recordMockedMethod.get(method.propName); + if (og) { + obj[method.propName] = og; + this.recordMockedMethod.set(method.propName, undefined); + } + } + + extend(dest: any, source:any) { + dest["stub"] = source["stub"]; + dest["afterReturn"] = source["afterReturn"]; + dest["afterReturnNothing"] = source["afterReturnNothing"]; + dest["afterAction"] = source["afterAction"]; + dest["afterThrow"] = source["afterThrow"]; + dest["stubMockedCall"] = source["stubMockedCall"]; + dest["clear"] = source["clear"]; + return dest; + } + + stubApply(f: any, params:any, returnInfo:any) { + let values = this.stubs.get(f); + if (!values) { + values = new Map(); + } + let key = params[0]; + if (typeof key == "undefined") { + key = "anonymous-mock-" + f.propName; + } + let matcher = new ArgumentMatchers(); + if (matcher.matcheStubKey(key)) { + key = matcher.matcheStubKey(key); + if (key) { + this.currentSetKey.set(f, key); + } + } + values.set(key, returnInfo); + this.stubs.set(f, values); + } + + getReturnInfo(f: any, params:any) { + let values = this.stubs.get(f); + if (!values) { + return undefined; + } + let retrunKet = params[0]; + if (typeof retrunKet == "undefined") { + retrunKet = "anonymous-mock-" + f.propName; + } + let stubSetKey = this.currentSetKey.get(f); + + if (stubSetKey && (typeof (retrunKet) != "undefined")) { + retrunKet = stubSetKey; + } + let matcher = new ArgumentMatchers(); + if (matcher.matcheReturnKey(params[0], undefined, stubSetKey) && matcher.matcheReturnKey(params[0], undefined, stubSetKey) != stubSetKey) { + retrunKet = params[0]; + } + + values.forEach(function (value: any, key: any, map: any) { + if (ArgumentMatchers.isRegExp(key) && matcher.matcheReturnKey(params[0], key)) { + retrunKet = key; + } + }); + + return values.get(retrunKet); + } + + findName(obj: any, value: any) { + let properties = this.findProperties(obj); + let name = ''; + properties.filter((item:any) => (item !== 'caller' && item !== 'arguments')).forEach( + function (va1:any, idx:any, array:any) { + if (obj[va1] === value) { + name = va1; + } + } + ); + return name; + } + + isFunctionFromPrototype(f: Function, container:Function, propName: string) { + if (container.constructor != Object && container.constructor.prototype !== container) { + return container.constructor.prototype[propName] === f; + } + return false; + } + + findProperties(obj: any, ...arg: Array) { + function getProperty(new_obj:any): Array { + if (new_obj.__proto__ === null) { + return []; + } + let properties = Object.getOwnPropertyNames(new_obj); + return [...properties, ...getProperty(new_obj.__proto__)]; + } + return getProperty(obj); + } + + recordMethodCall(originalMethod: any, args: any) { + originalMethod['getName'] = function () { + return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]; + } + let name = originalMethod.getName(); + let arglistString = name + '(' + Array.from(args).toString() + ')'; + let records = this.recordCalls.get(arglistString); + if (!records) { + records = 0; + } + records++; + this.recordCalls.set(arglistString, records); + } + + mockFunc(originalObject:any, originalMethod:any) { + let tmp = this; + this.originalMethod = originalMethod; + const _this = this; + let f:any = function () { + let args = arguments; + let action = tmp.getReturnInfo(f, args); + if (originalMethod) { + tmp.recordMethodCall(originalMethod, args); + } + if (action) { + return action.apply(_this, args); + } + }; + + f.container = null || originalObject; + f.original = originalMethod || null; + + if (originalObject && originalMethod) { + if (typeof (originalMethod) != 'function') throw new Error('Not a function'); + var name = this.findName(originalObject, originalMethod); + originalObject[name] = f; + this.recordMockedMethod.set(name, originalMethod); + f.propName = name; + f.originalFromPrototype = this.isFunctionFromPrototype(f.original, originalObject, f.propName); + } + f.mocker = this; + this.mFunctions.push(f); + this.extend(f, new ExtendInterface(this)); + return f; + } + + verify(methodName:any, argsArray:any) { + if (!methodName) { + throw Error("not a function name"); + } + let a = this.recordCalls.get(methodName + '(' + argsArray.toString() + ')'); + return new VerificationMode(a ? a : 0); + } + + mockObject(object: any) { + if (!object || typeof object === "string") { + throw Error(`this ${object} cannot be mocked`); + } + const _this = this; + let mockedObject:any = {}; + let keys = Reflect.ownKeys(object); + keys.filter(key => (typeof Reflect.get(object, key)) === 'function') + .forEach((key:any) => { + mockedObject[key] = object[key]; + mockedObject[key] = _this.mockFunc(mockedObject, mockedObject[key]); + }); + return mockedObject; + } +} + +function ifMockedFunction(f: any) { + if (Object.prototype.toString.call(f) != "[object Function]" && + Object.prototype.toString.call(f) != "[object AsyncFunction]") { + throw Error("not a function"); + } + if (!f.stub) { + throw Error("not a mock function"); + } + return true; +} + +function when(f: any) { + if (ifMockedFunction(f)) { + return f.stub.bind(f); + } +} + +function MockSetup(target: Object, propertyName: string | Symbol, descriptor: TypedPropertyDescriptor<() => void>): void { + const aboutToAppearOrigin = target.aboutToAppear; + const setup = descriptor.value; + target.aboutToAppear = function (...args: any[]) { + if (target.__Param) { // copy attributes and params of the original context + try { + const map = target.__Param as Map; + for (const [key, val] of map) { + this[key] = val; // 'this' refers to context of current function + } + } catch (e) { + throw new Error(`Mock setup param error: ${e}`); + } + } + + if (setup) { // apply the mock content + try { + setup.apply(this); + } catch (e) { + throw new Error(`Mock setup apply error: ${e}`); + } + } + + if (aboutToAppearOrigin) { // append to aboutToAppear function of the original context + aboutToAppearOrigin.apply(this, args); + } + } +} + +export { + MockSetup, + MockKit, + when +}; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/VerificationMode.js b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/VerificationMode.js new file mode 100644 index 0000000..02fbf3b --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/VerificationMode.js @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +class VerificationMode { + constructor(times) { + this.doTimes = times; + } + times(count) { + if (count !== this.doTimes) { + throw Error(`expect ${count} actual ${this.doTimes}`); + } + } + never() { + if (this.doTimes !== 0) { + throw Error(`expect 0 actual ${this.doTimes}`); + } + } + once() { + if (this.doTimes !== 1) { + throw Error(`expect 1 actual ${this.doTimes}`); + } + } + atLeast(count) { + if (count > this.doTimes) { + throw Error('failed ' + count + ' greater than the actual execution times of method'); + } + } + atMost(count) { + if (count < this.doTimes) { + throw Error('failed ' + count + ' less than the actual execution times of method'); + } + } +} +export default VerificationMode; diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/VerificationMode.ts b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/VerificationMode.ts new file mode 100644 index 0000000..0748125 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/mock/VerificationMode.ts @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + + +class VerificationMode { + + private doTimes: number + + constructor(times: number) { + this.doTimes = times; + } + + times(count: number) { + if(count !== this.doTimes) { + throw Error(`expect ${count} actual ${this.doTimes}`); + } + } + + never() { + if (this.doTimes !== 0) { + throw Error(`expect 0 actual ${this.doTimes}`); + } + } + + once() { + if (this.doTimes !== 1) { + throw Error(`expect 1 actual ${this.doTimes}`); + } + } + + atLeast(count: number) { + if (count > this.doTimes) { + throw Error('failed ' + count + ' greater than the actual execution times of method'); + } + } + + atMost(count: number) { + if (count < this.doTimes) { + throw Error('failed ' + count + ' less than the actual execution times of method'); + } + } +} + +export default VerificationMode; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/module.json b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/module.json new file mode 100644 index 0000000..384ae72 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/main/module.json @@ -0,0 +1,22 @@ +{ + "app": { + "bundleName": "com.example.hamock", + "debug": true, + "versionCode": 1000000, + "versionName": "1.0.0", + "minAPIVersion": 9, + "targetAPIVersion": 9, + "apiReleaseType": "Release" + }, + "module": { + "name": "hamock", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "tv", + "wearable", + "car" + ] + } +} diff --git a/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/res/schemas/mock-config-json5-schema.json b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/res/schemas/mock-config-json5-schema.json new file mode 100644 index 0000000..b137b0a --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock/src/res/schemas/mock-config-json5-schema.json @@ -0,0 +1,25 @@ +{ + "$schema": "http://json-schema.org/draft-04/schema#", + "title": "JSON schema for mock-config.json5 file", + "definitions": { + "sourceRedirection": { + "description": "A source redirection for mocked module.", + "type": "object", + "required": [ + "source" + ], + "properties": { + "source": { + "type": "string", + "maxLength": 128, + "minLength": 1 + } + } + } + }, + "patternProperties": { + ".+": { + "$ref": "#/definitions/sourceRedirection" + } + } +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/BuildProfile.ets b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/BuildProfile.ets new file mode 100644 index 0000000..07a9435 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.21'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/CHANGELOG.md b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/CHANGELOG.md new file mode 100644 index 0000000..6b8c61a --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/CHANGELOG.md @@ -0,0 +1,27 @@ +## 1.0.21 +- mock支持多参数 +- describe中异步函数抛出日志信息 +- 修复多测试套时,执行单个测试套会打印其他测试套的日志信息 +## 1.0.14 +- 堆栈信息打印到cmd +## 1.0.15 +- 支持获取测试代码的失败堆栈信息 +- mock代码迁移至harmock包 +- 适配arkts语法 +- 修复覆盖率数据容易截断的bug +## 1.0.16 +- 修改覆盖率文件生成功能 +- 修改静态方法无法ignoreMock函数 +- ## 1.0.17 +- 修改not断言失败提示日志 +- 自定义错误message信息 +- 添加xdescribe, xit API功能 +- ## 1.0.18 +- 添加全局变量存储API get set +- 自定义断言功能 +## 1.0.18-rc.0 +添加框架worker执行能力 +## 1.0.19 +规范日志格式 +# 1.0.20 +代码告警整改 \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/LICENSE b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/LICENSE new file mode 100644 index 0000000..4947287 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/LICENSE @@ -0,0 +1,177 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/README.md b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/README.md new file mode 100644 index 0000000..93997dc --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/README.md @@ -0,0 +1,224 @@ +
Hypium
+
A unit test framework for OpenHarmonyOS application
+ +## Hypium是什么? +*** +- Hypium是OpenHarmony上的测试框架,提供测试用例编写、执行、结果显示能力,用于OpenHarmony系统应用接口以及应用界面测试。 +- Hypium结构化模型:hypium工程主要由List.test.js与TestCase.test.js组成。 +``` +rootProject // Hypium工程根目录 +├── moduleA +│   ├── src +│      ├── main // 被测试应用目录 +│      ├── ohosTest // 测试用例目录 +│         ├── js/ets +│            └── test +│               └── List.test.js // 测试用例加载脚本,ets目录下为.ets后缀 +│               └── TestCase.test.js // 测试用例脚本,ets目录下为.ets后缀 +└── moduleB + ... +│               └── List.test.js // 测试用例加载脚本,ets目录下为.ets后缀 +│               └── TestCase.test.js // 测试用例脚本,ets目录下为.ets后缀 +``` + +## 安装使用 + +```javascript +ohpm install @ohos/hypium +``` + +*** +- 在DevEco Studio内使用Hypium +- 工程级package.json内配置: +```json +"dependencies": { + "@ohos/hypium": "1.0.21" +} +``` +注: +hypium服务于OpenHarmonyOS应用对外接口测试、系统对外接口测试(SDK中接口),完成HAP自动化测试。详细指导: +[Deveco Studio](https://developer.harmonyos.com/cn/develop/deveco-studio) + +#### 通用语法 + +- 测试用例采用业内通用语法,describe代表一个测试套, it代表一条用例。 + +| No. | API | 功能说明 | +| --- | ---------- | ---------------------------------------------------------------------------------------------------------------------- | +| 1 | describe | 定义一个测试套,支持两个参数:测试套名称和测试套函数 | +| 2 | beforeAll | 在测试套内定义一个预置条件,在所有测试用例开始前执行且仅执行一次,支持一个参数:预置动作函数 | +| 3 | beforeEach | 在测试套内定义一个单元预置条件,在每条测试用例开始前执行,执行次数与it定义的测试用例数一致,支持一个参数:预置动作函数 | +| 4 | afterEach | 在测试套内定义一个单元清理条件,在每条测试用例结束后执行,执行次数与it定义的测试用例数一致,支持一个参数:清理动作函数 | +| 5 | afterAll | 在测试套内定义一个清理条件,在所有测试用例结束后执行且仅执行一次,支持一个参数:清理动作函数 | +| 6 | it | 定义一条测试用例,支持三个参数:用例名称,过滤参数和用例函数 | +| 7 | expect | 支持bool类型判断等多种断言方法 | + +#### 断言库 + +- 示例代码: + +```javascript + expect(${actualvalue}).assertX(${expectvalue}) +``` + +- 断言功能列表: + +| No. | API | 功能说明 | +| :--- | :------------------------------- | ---------------------------------------------------------------------------------------------- | +| 1 | assertClose | 检验actualvalue和expectvalue(0)的接近程度是否是expectValue(1) | +| 2 | assertContain | 检验actualvalue中是否包含expectvalue | +| 3 | assertDeepEquals | @since1.0.4 检验actualvalue和expectvalue(0)是否是同一个对象 | +| 4 | assertEqual | 检验actualvalue是否等于expectvalue[0] | +| 5 | assertFail | 抛出一个错误 | +| 6 | assertFalse | 检验actualvalue是否是false | +| 7 | assertTrue | 检验actualvalue是否是true | +| 8 | assertInstanceOf | 检验actualvalue是否是expectvalue类型 | +| 9 | assertLarger | 检验actualvalue是否大于expectvalue | +| 10 | assertLess | 检验actualvalue是否小于expectvalue | +| 11 | assertNaN | @since1.0.4 检验actualvalue是否是NaN | +| 12 | assertNegUnlimited | @since1.0.4 检验actualvalue是否等于Number.NEGATIVE_INFINITY | +| 13 | assertNull | 检验actualvalue是否是null | +| 14 | assertPosUnlimited | @since1.0.4 检验actualvalue是否等于Number.POSITIVE_INFINITY | +| 15 | assertPromiseIsPending | @since1.0.4 检验actualvalue是否处于Pending状态【actualvalue为promse对象】 | +| 16 | assertPromiseIsRejected | @since1.0.4 检验actualvalue是否处于Rejected状态【同15】 | +| 17 | assertPromiseIsRejectedWith | @since1.0.4 检验actualvalue是否处于Rejected状态,并且比较执行的结果值【同15】 | +| 18 | assertPromiseIsRejectedWithError | @since1.0.4 检验actualvalue是否处于Rejected状态并有异常,同时比较异常的类型和message值【同15】 | +| 19 | assertPromiseIsResolved | @since1.0.4 检验actualvalue是否处于Resolved状态【同15】 | +| 20 | assertPromiseIsResolvedWith | @since1.0.4 检验actualvalue是否处于Resolved状态,并且比较执行的结果值【同15】 | +| 21 | assertThrowError | 检验actualvalue抛出Error内容是否是expectValue | +| 22 | assertUndefined | 检验actualvalue是否是undefined | +| 23 | not | @since1.0.4 断言结果取反 | + + +示例代码: + +```javascript + import { describe, it, expect } from '@ohos/hypium'; + + export default async function assertCloseTest() { + describe('assertClose', function () { + it('assertClose_success', 0, function () { + let a = 100; + let b = 0.1; + expect(a).assertClose(99, b); + }) + }) + } +``` + +#### 公共系统能力 + +| No. | API | 功能描述 | +| ---- | ------------------------------------------------------- | ------------------------------------------------------------ | +| 1 | existKeyword(keyword: string, timeout: number): boolean | @since1.0.3 hilog日志中查找指定字段是否存在,keyword是待查找关键字,timeout为设置的查找时间 | +| 2 | actionStart(tag: string): void | @since1.0.3 cmd窗口输出开始tag | +| 3 | actionEnd(tag: string): void | @since1.0.3 cmd窗口输出结束tag | + +示例代码: + +```javascript +import { describe, it, expect, SysTestKit} from '@ohos/hypium'; + +export default function existKeywordTest() { + describe('existKeywordTest', function () { + it('existKeyword',DEFAULT, async function () { + console.info("HelloTest"); + let isExist = await SysTestKit.existKeyword('HelloTest'); + console.info('isExist ------>' + isExist); + }) + }) +} +``` +```javascript +import { describe, it, expect, SysTestKit} from '@ohos/hypium'; + +export default function actionTest() { + describe('actionTest', function () { + it('existKeyword',DEFAULT, async function () { + let tag = '[MyTest]'; + SysTestKit.actionStart(tag); + //do something + SysTestKit.actionEnd(tag); + }) + }) +} +``` + +#### 专项能力 + +- 测试用例属性筛选能力:hypium支持根据用例属性筛选执行指定测试用例,使用方式是先在测试用例上标记用例属性后,再在测试应用的启动shell命令后新增" -s ${Key} ${Value}"。 + +| Key | 含义说明 | Value取值范围 | +| -------- | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------ | +| level | 用例级别 | "0","1","2","3","4", 例如:-s level 1 | +| size | 用例粒度 | "small","medium","large", 例如:-s size small | +| testType | 用例测试类型 | "function","performance","power","reliability","security","global","compatibility","user","standard","safety","resilience", 例如:-s testType function | + +示例代码 + +```javascript +import { describe, it, expect, TestType, Size, Level } from '@ohos/hypium'; + +export default function attributeTest() { + describe('attributeTest', function () { + it("testAttributeIt", TestType.FUNCTION | Size.SMALLTEST | Level.LEVEL0, function () { + console.info('Hello Test'); + }) + }) +} +``` + +示例命令 +```shell +XX -s level 1 -s size small -s testType function +``` +该命令的作用是:筛选测试应用中同时满足a)用例级别是1 b)用例粒度是small c)用例测试类型是function 三个条件的用例执行。 + +- 测试套/测试用例名称筛选能力(测试套与用例名称用“#”号连接,多个用“,”英文逗号分隔) + +| Key | 含义说明 | Value取值范围 | +| -------- | ----------------------- | -------------------------------------------------------------------------------------------- | +| class | 指定要执行的测试套&用例 | ${describeName}#${itName},${describeName} , 例如:-s class attributeTest#testAttributeIt | +| notClass | 指定不执行的测试套&用例 | ${describeName}#${itName},${describeName} , 例如:-s notClass attributeTest#testAttributeIt | + +示例命令 +```shell +XX -s class attributeTest#testAttributeIt,abilityTest#testAbilityIt +``` +该命令的作用是:筛选测试应用中attributeTest测试套下的testAttributeIt测试用例,abilityTest测试套下的testAbilityIt测试用例,只执行这两条用例。 + +- 其他能力 + +| 能力项 | Key | 含义说明 | Value取值范围 | +| ------------ | ------- | ---------------------------- | ---------------------------------------------- | +| 随机执行能力 | random | 测试套&测试用例随机执行 | true, 不传参默认为false, 例如:-s random true | +| 空跑能力 | dryRun | 显示要执行的测试用例信息全集 | true , 不传参默认为false,例如:-s dryRun true | +| 异步超时能力 | timeout | 异步用例执行的超时时间 | 正整数 , 单位ms,例如:-s timeout 5000 | + +##### 约束限制 +随机执行能力和空跑能力从npm包1.0.3版本开始支持 + +#### Mock能力 + +##### 约束限制 + +单元测试框架Mock能力从npm包[1.0.1版本](https://repo.harmonyos.com/#/cn/application/atomService/@ohos%2Fhypium/v/1.0.1)开始支持 + +## 约束 + +*** + 本模块首批接口从OpenHarmony SDK API version 8开始支持。 + +## Hypium开放能力隐私声明 + +- 我们如何收集和使用您的个人信息 + 您在使用集成了Hypium开放能力的测试应用时,Hypium不会处理您的个人信息。 +- SDK处理的个人信息 + 不涉及。 +- SDK集成第三方服务声明 + 不涉及。 +- SDK数据安全保护 + 不涉及。 +- SDK版本更新声明 + 为了向您提供最新的服务,我们会不时更新Hypium版本。我们强烈建议开发者集成使用最新版本的Hypium。 + diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/ResourceTable.txt b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/ResourceTable.txt new file mode 100644 index 0000000..d159750 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/ResourceTable.txt @@ -0,0 +1 @@ +string page_show 0x02000000 \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/build-profile.json5 b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/build-profile.json5 new file mode 100644 index 0000000..16208e7 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + } + ] +} diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/consumer-rules.txt b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/consumer-rules.txt new file mode 100644 index 0000000..e69de29 diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/hvigorfile.ts b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/hvigorfile.ts new file mode 100644 index 0000000..4218707 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.d.ts b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.d.ts new file mode 100644 index 0000000..58e1066 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.d.ts @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +export const DEFAULT = 0B0000 + +export const when: when; + +export enum TestType { + FUNCTION = 0B1, + PERFORMANCE = 0B1 << 1, + POWER = 0B1 << 2, + RELIABILITY = 0B1 << 3, + SECURITY = 0B1 << 4, + GLOBAL = 0B1 << 5, + COMPATIBILITY = 0B1 << 6, + USER = 0B1 << 7, + STANDARD = 0B1 << 8, + SAFETY = 0B1 << 9, + RESILIENCE = 0B1 << 10 +} + +export enum Size { + SMALLTEST = 0B1 << 16, + MEDIUMTEST = 0B1 << 17, + LARGETEST = 0B1 << 18 +} + +export enum Level { + LEVEL0 = 0B1 << 24, + LEVEL1 = 0B1 << 25, + LEVEL2 = 0B1 << 26, + LEVEL3 = 0B1 << 27, + LEVEL4 = 0B1 << 28 +} +export { xdescribe, xit, describe, it } from './index'; + + + +export function beforeItSpecified(testCaseNames: Array | string, callback: Function): void + +export function afterItSpecified(testCaseNames: Array | string, callback: Function): void + +export function beforeEach(callback: Function): void + +export function afterEach(callback: Function): void + +export function beforeAll(callback: Function): void + +export function afterAll(callback: Function): void + + +export interface Assert { + assertClose(expectValue: number, precision: number): void + assertContain(expectValue: any): void + assertEqual(expectValue: any): void + assertFail(): void + assertFalse(): void + assertTrue(): void + assertInstanceOf(expectValue: string): void + assertLarger(expectValue: number): void + assertLess(expectValue: number): void + assertNull(): void + assertThrowError(expectValue: string | Function): void + assertUndefined(): void + assertLargerOrEqual(expectValue: number): void + assertLessOrEqual(expectValue: number): void + assertNaN(): void + assertNegUnlimited(): void + assertPosUnlimited(): void + not(): Assert; + assertDeepEquals(expectValue: any): void + assertPromiseIsPending(): Promise + assertPromiseIsRejected(): Promise + assertPromiseIsRejectedWith(expectValue?: any): Promise + assertPromiseIsRejectedWithError(...expectValue): Promise + assertPromiseIsResolved(): Promise + assertPromiseIsResolvedWith(expectValue?: any): Promise + message(msg: string): Assert +} + +export function expect(actualValue?: any): Assert + +export class ArgumentMatchers { + static any; + static anyString; + static anyBoolean; + static anyNumber; + static anyObj; + static anyFunction; + static matchRegexs(Regex: RegExp): void +} + +declare interface when { + afterReturn(value: any): any + afterReturnNothing(): undefined + afterAction(action: any): any + afterThrow(e_msg: string): string + (argMatchers?: any): when; +} + +export interface VerificationMode { + times(count: Number): void + never(): void + once(): void + atLeast(count: Number): void + atMost(count: Number): void +} + +export class MockKit { + constructor() + mockFunc(obj: Object, func: Function): Function + mockObject(obj: Object): Object + verify(methodName: String, argsArray: Array): VerificationMode + ignoreMock(obj: Object, func: Function): void + clear(obj: Object): void + clearAll(): void +} + +export class SysTestKit { + static getDescribeName(): string; + static getItName(): string; + static getItAttribute(): TestType | Size | Level + static actionStart(tag: string): void + static actionEnd(tag: string): void + static existKeyword(keyword: string, timeout?: number): boolean +} + +export class Hypium { + static setData(data: { [key: string]: any }): void + static setTimeConfig(systemTime: any) + static hypiumTest(abilityDelegator: any, abilityDelegatorArguments: any, testsuite: Function): void + static set(key: string, value: any): void + static get(key: string): any + static registerAssert(customAssertion: Function): void + static unregisterAssert(customAssertion: string | Function): void + static hypiumWorkerTest(abilityDelegator: Object, abilityDelegatorArguments: Object, testsuite: Function, workerPort: Object): void; + static hypiumInitWorkers(abilityDelegator: Object, scriptURL: string, workerNum: number, params: Object): void; +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ets b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ets new file mode 100644 index 0000000..996fc7d --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ets @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Core from './src/main/core'; +import {TestType, Size, Level, DEFAULT} from './src/main/Constant'; +import DataDriver from './src/main/module/config/DataDriver'; +import ExpectExtend from './src/main/module/assert/ExpectExtend'; +import OhReport from './src/main/module/report/OhReport'; +export { xdescribe, xit, describe, it } from './index.ts'; + +export declare class Hypium { + static setData(data: Object): void + static setTimeConfig(systemTime: Object): void + static hypiumTest(abilityDelegator: Object, abilityDelegatorArguments: Object, testsuite: Function): void + static set(key: string, value: Object): void + static get(key: string): Object + static registerAssert(customAssertion: Function): void + static unregisterAssert(customAssertion: string | Function): void + static hypiumWorkerTest(abilityDelegator: Object, abilityDelegatorArguments: Object, + testsuite: Function, workerPort: Object): void; + static hypiumInitWorkers(abilityDelegator: Object, scriptURL: string, workerNum: number, params: Object): void; +} + +export { + Core, + DataDriver, + ExpectExtend, + OhReport, + TestType, + Size, + Level, + DEFAULT +}; + +type allExpectType = Object | undefined | null + +export declare function beforeItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function afterItSpecified(testCaseNames: Array | string, callback: Function): void + +export declare function beforeEach(callback: Function): void + +export declare function afterEach(callback: Function): void + +export declare function beforeAll(callback: Function): void + +export declare function afterAll(callback: Function): void + +export declare interface Assert { + assertClose(expectValue: number, precision: number): void + assertContain(expectValue: allExpectType): void + assertEqual(expectValue: allExpectType): void + assertFail(): void + assertFalse(): void + assertTrue(): void + assertInstanceOf(expectValue: string): void + assertLarger(expectValue: number): void + assertLess(expectValue: number): void + assertNull(): void + assertThrowError(expectValue: string | Function): void + assertUndefined(): void + assertLargerOrEqual(expectValue: number):void + assertLessOrEqual(expectValue: number):void + assertNaN():void + assertNegUnlimited(): void + assertPosUnlimited(): void + not(): Assert; + assertDeepEquals(expectValue: allExpectType):void + assertPromiseIsPending(): Promise + assertPromiseIsRejected(): Promise + assertPromiseIsRejectedWith(expectValue?: allExpectType): Promise + assertPromiseIsRejectedWithError(...expectValue: allExpectType[]): Promise + assertPromiseIsResolved(): Promise + assertPromiseIsResolvedWith(expectValue?: allExpectType): Promise + message(msg: string): Assert +} + +export declare function expect(actualValue?: allExpectType): Assert + +export declare class ArgumentMatchers { + public static any: allExpectType; + public static anyString: string; + public static anyBoolean: Boolean; + public static anyNumber: Number; + public static anyObj: Object; + public static anyFunction: Function; + public static matchRegexs(regex: RegExp): void +} + +declare interface whenResult { + afterReturn: (value: allExpectType) => allExpectType + afterReturnNothing: () => undefined + afterAction: (action: allExpectType) => allExpectType + afterThrow: (e_msg: string) => string +} + +export declare function when(f:Function): (...args: (allExpectType | void)[]) => whenResult + +export declare interface VerificationMode { + times(count: Number): void + never(): void + once(): void + atLeast(count: Number): void + atMost(count: Number): void +} + +export declare class MockKit { + constructor() + mockFunc(obj: Object, func: Function): Function + mockObject(obj: Object): Object + verify(methodName: String, argsArray: Array): VerificationMode + ignoreMock(obj: Object, func: Function): void + clear(obj: Object): void + clearAll(): void +} + +export declare class SysTestKit { + static getDescribeName(): string; + static getItName(): string; + static getItAttribute(): TestType | Size | Level + static actionStart(tag: string): void + static actionEnd(tag: string): void + static existKeyword(keyword: string, timeout?: number): boolean +} + diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.js new file mode 100644 index 0000000..954f765 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.js @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License") + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Core from './src/main/core'; +import { DEFAULT, TestType, Size, Level, TAG, PrintTag } from './src/main/Constant'; +import DataDriver from './src/main/module/config/DataDriver'; +import ExpectExtend from './src/main/module/assert/ExpectExtend'; +import OhReport from './src/main/module/report/OhReport'; +import SysTestKit from './src/main/module/kit/SysTestKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, beforeItSpecified, afterItSpecified, xdescribe, xit } from './src/main/interface'; +import { MockKit, when } from './src/main/module/mock/MockKit'; +import ArgumentMatchers from './src/main/module/mock/ArgumentMatchers'; +import worker from '@ohos.worker'; + +class Hypium { + static context = new Map(); + static setData(data) { + const core = Core.getInstance(); + const dataDriver = new DataDriver({ data }); + core.addService('dataDriver', dataDriver); + } + + static setTimeConfig(systemTime) { + SysTestKit.systemTime = systemTime; + } + + static set(key, value) { + Hypium.context.set(key, value); + } + + static get(key) { + return Hypium.context.get(key); + } + + static hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) { + const core = Core.getInstance(); + const expectExtend = new ExpectExtend({ + 'id': 'extend' + }); + core.addService('expect', expectExtend); + const ohReport = new OhReport({ + 'delegator': abilityDelegator, + 'abilityDelegatorArguments': abilityDelegatorArguments + }); + SysTestKit.delegator = abilityDelegator; + core.addService('report', ohReport); + core.init(); + core.subscribeEvent('spec', ohReport); + core.subscribeEvent('suite', ohReport); + core.subscribeEvent('task', ohReport); + const configService = core.getDefaultService('config'); + if (abilityDelegatorArguments !== null) { + let testParameters = configService.translateParams(abilityDelegatorArguments.parameters); + console.info(`${TAG}parameters:${JSON.stringify(testParameters)}`); + configService.setConfig(testParameters); + } + testsuite(); + core.execute(abilityDelegator); + } + static async hypiumInitWorkers(abilityDelegator, scriptURL, workerNum = 8, params) { + console.info(`${TAG}, hypiumInitWorkers call,${scriptURL}`); + let workerPromiseArray = []; + + // 开始统计时间 + let startTime = await SysTestKit.getRealTime(); + for (let i = 0; i < workerNum; i++) { + // 创建worker线程 + const workerPromise = Hypium.createWorkerPromise(scriptURL, i, params); + workerPromiseArray.push(workerPromise); + } + const ret = {total: 0, failure: 0, error: 0, pass: 0, ignore: 0, duration: 0}; + Promise.all(workerPromiseArray).then(async (items) => { + console.info(`${TAG}, all result from workers, ${JSON.stringify(items)}`); + let allItemList = new Array(); + // 统计执行结果 + Hypium.handleWorkerTestResult(ret, allItemList, items); + console.info(`${TAG}, all it result, ${JSON.stringify(allItemList)}`); + // 统计用例执行结果 + const retResult = {total: 0, failure: 0, error: 0, pass: 0, ignore: 0, duration: 0}; + // 标记用例执行结果 + Hypium.configWorkerItTestResult(retResult, allItemList); + // 打印用例结果 + Hypium.printWorkerTestResult(abilityDelegator, allItemList); + // 用例执行完成统计时间 + let endTime = await SysTestKit.getRealTime(); + const taskConsuming = endTime - startTime; + const message = + `\n${PrintTag.OHOS_REPORT_ALL_RESULT}: stream=Test run: runTimes: ${ret.total},total: ${retResult.total}, Failure: ${retResult.failure}, Error: ${retResult.error}, Pass: ${retResult.pass}, Ignore: ${retResult.ignore}` + + `\n${PrintTag.OHOS_REPORT_ALL_CODE}: ${retResult.failure > 0 || retResult.error > 0 ? -1 : 0}` + + `\n${PrintTag.OHOS_REPORT_ALL_STATUS}: taskconsuming=${taskConsuming > 0 ? taskConsuming : ret.duration}`; + abilityDelegator.printSync(message); + console.info(`${TAG}, [end] you worker test`); + abilityDelegator.finishTest('you worker test finished!!!', 0, () => {}); + }).catch((e) => { + console.info(`${TAG}, [end] error you worker test, ${JSON.stringify(e)}`); + abilityDelegator.finishTest('you worker test error finished!!!', 0, () => {}); + }).finally(() => { + console.info(`${TAG}, all promise finally end`); + }); + } + // 创建worker线程 + static createWorkerPromise(scriptURL, i, params) { + console.info(`${TAG}, createWorkerPromiser, ${scriptURL}, ${i}`); + const workerPromise = new Promise((resolve, reject) => { + const workerInstance = new worker.ThreadWorker(scriptURL, {name: `worker_${i}`}); + console.info(`${TAG}, send data to worker`); + // 发送数据到worker线程中 + workerInstance.postMessage(params); + workerInstance.onmessage = function (e) { + let currentThreadName = e.data?.currentThreadName; + console.info(`${TAG}, receview data from ${currentThreadName}, ${JSON.stringify(e.data)}`); + // + resolve(e.data?.summary); + console.info(`${TAG}, ${currentThreadName} finish`); + workerInstance.terminate(); + }; + workerInstance.onerror = function (e) { + console.info(`${TAG}, worker error, ${JSON.stringify(e)}`); + reject(e); + workerInstance.terminate(); + }; + workerInstance.onmessageerror = function (e) { + console.info(`${TAG}, worker message error, ${JSON.stringify(e)}`); + reject(e); + workerInstance.terminate(); + }; + }); + return workerPromise; + } + static handleWorkerTestResult(ret, allItemList, items) { + console.info(`${TAG}, handleWorkerTestResult, ${JSON.stringify(items)}`); + for (const {total, failure, error, pass, ignore, duration, itItemList} of items) { + ret.total += total; + ret.failure += failure; + ret.error += error; + ret.pass += pass; + ret.ignore += ignore; + ret.duration += duration; + Hypium.handleItResult(allItemList, itItemList); + } + } + static handleItResult(allItemList, itItemList) { + // 遍历所有的用例结果统计最终结果 + for (const {currentThreadName, description, result} of itItemList) { + let item = allItemList.find((it) => it.description === description); + if (item) { + let itResult = item.result; + // 当在worker中出现一次failure就标记为failure, 出现一次error就标记为error, 所有线程都pass才标记为pass + if (itResult === 0) { + item.result = result; + item.currentThreadName = currentThreadName; + } + } else { + let it = { + description: description, + currentThreadName: currentThreadName, + result: result + }; + allItemList.push(it); + } + } + } + static configWorkerItTestResult(retResult, allItemList) { + console.info(`${TAG}, configWorkerItTestResult, ${JSON.stringify(allItemList)}`); + for (const {currentThreadName, description, result} of allItemList) { + console.info(`${TAG}, description, ${description}, result,${result}`); + retResult.total ++; + if (result === 0) { + retResult.pass ++; + } else if (result === -1) { + retResult.error ++; + } else if (result === -2) { + retResult.failure ++; + } else { + retResult.ignore ++; + } + } + } + static printWorkerTestResult(abilityDelegator, allItemList) { + console.info(`${TAG}, printWorkerTestResult, ${JSON.stringify(allItemList)}`); + let index = 1; + for (const {currentThreadName, description, result} of allItemList) { + console.info(`${TAG}, description print, ${description}, result,${result}`); + let itArray = description.split('#'); + let des; + let itName; + if (itArray.length > 1) { + des = itArray[0]; + itName = itArray[1]; + } else if (itArray.length > 1) { + des = itArray[0]; + itName = itArray[0]; + } else { + des = 'undefined'; + itName = 'undefined'; + } + + let msg = `\n${PrintTag.OHOS_REPORT_WORKER_STATUS}: class=${des}`; + msg += `\n${PrintTag.OHOS_REPORT_WORKER_STATUS}: test=${itName}`; + msg += `\n${PrintTag.OHOS_REPORT_WORKER_STATUS}: current=${index}`; + msg += `\n${PrintTag.OHOS_REPORT_WORKER_STATUS}: CODE=${result}`; + abilityDelegator.printSync(msg); + index ++; + } + } + static hypiumWorkerTest(abilityDelegator, abilityDelegatorArguments, testsuite, workerPort) { + console.info(`${TAG}, hypiumWorkerTest call`); + SysTestKit.workerPort = workerPort; + let currentWorkerName = workerPort.name; + console.info(`${TAG}, hypiumWorkerTest_currentWorkerName: ${currentWorkerName}`); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + + } + + static registerAssert(customAssertion) { + const core = Core.getInstance(); + const expectService = core.getDefaultService('expect'); + let matchers = {}; + matchers[customAssertion.name] = customAssertion; + expectService.addMatchers(matchers); + expectService.customMatchers.push(customAssertion.name); + console.info(`${TAG}success to register the ${customAssertion.name}`); + } + + static unregisterAssert(customAssertion) { + const core = Core.getInstance(); + const expectService = core.getDefaultService('expect'); + let customAssertionName = typeof customAssertion === 'function' ? customAssertion.name : customAssertion; + expectService.removeMatchers(customAssertionName); + console.info(`${TAG}success to unregister the ${customAssertionName}`); + } + +} + +export { + Hypium, + Core, + DEFAULT, + TestType, + Size, + Level, + DataDriver, + ExpectExtend, + OhReport, + SysTestKit, + describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, beforeItSpecified, afterItSpecified, xdescribe, xit, + MockKit, when, + ArgumentMatchers +}; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ts b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ts new file mode 100644 index 0000000..6e059e3 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/index.ts @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { TestType, Size, Level } from "./src/main/Constant"; + +export declare function xdescribe(testSuiteName: string, func: Function): void; + +export declare namespace xdescribe { + function reason(reason: string): any; +}; + +export declare function describe(testSuiteName: string, func: Function): void; + +export declare function xit(testCaseName: string, attribute: TestType | Size | Level, func: Function): void; + +export declare namespace xit { + function reason(reason: string): any; +}; + +export declare function it(testCaseName: string, attribute: TestType | Size | Level, func: Function): void; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/obfuscation-rules.txt b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/obfuscation-rules.txt new file mode 100644 index 0000000..985b2ae --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/obfuscation-rules.txt @@ -0,0 +1,18 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://gitee.com/openharmony/arkcompiler_ets_frontend/blob/master/arkguard/README.md + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/oh-package.json5 b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/oh-package.json5 new file mode 100644 index 0000000..3ef03ac --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/oh-package.json5 @@ -0,0 +1 @@ +{"name":"@ohos/hypium","version":"1.0.21","description":"A unit test framework for OpenHarmony application","main":"index.js","keywords":["测试框架","except","mock"],"author":"huawei","license":"Apache-2.0","repository":"https://gitee.com/openharmony/testfwk_arkxtest","homepage":"https://gitee.com/openharmony/testfwk_arkxtest","dependencies":{},"metadata":{"sourceRoots":["./src/main"],"debug":true},"compatibleSdkVersion":11,"compatibleSdkType":"OpenHarmony","obfuscated":false} diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/Constant.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/Constant.js new file mode 100644 index 0000000..2f6e8a1 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/Constant.js @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * define the testcase type : TestType, Size , Level + */ +export const TAG = '[Hypium]'; + +export const DEFAULT = 0B0000; + +export class PrintTag { + static OHOS_REPORT_WORKER_STATUS = 'OHOS_REPORT_WORKER_STATUS'; + static OHOS_REPORT_ALL_RESULT = 'OHOS_REPORT_ALL_RESULT'; + static OHOS_REPORT_ALL_CODE = 'OHOS_REPORT_ALL_CODE'; + static OHOS_REPORT_ALL_STATUS = 'OHOS_REPORT_ALL_STATUS'; + static OHOS_REPORT_RESULT = 'OHOS_REPORT_RESULT'; + static OHOS_REPORT_CODE = 'OHOS_REPORT_CODE'; + static OHOS_REPORT_STATUS = 'OHOS_REPORT_STATUS'; + static OHOS_REPORT_SUM = 'OHOS_REPORT_SUM'; + static OHOS_REPORT_STATUS_CODE = 'OHOS_REPORT_STATUS_CODE'; +}; + +export class TestType { + static FUNCTION = 0B1; + static PERFORMANCE = 0B1 << 1; + static POWER = 0B1 << 2; + static RELIABILITY = 0B1 << 3; + static SECURITY = 0B1 << 4; + static GLOBAL = 0B1 << 5; + static COMPATIBILITY = 0B1 << 6; + static USER = 0B1 << 7; + static STANDARD = 0B1 << 8; + static SAFETY = 0B1 << 9; + static RESILIENCE = 0B1 << 10; +}; + +export class Size { + static SMALLTEST = 0B1 << 16; + static MEDIUMTEST = 0B1 << 17; + static LARGETEST = 0B1 << 18; +}; + +export class Level { + static LEVEL0 = 0B1 << 24; + static LEVEL1 = 0B1 << 25; + static LEVEL2 = 0B1 << 26; + static LEVEL3 = 0B1 << 27; + static LEVEL4 = 0B1 << 28; +}; + +export const TESTTYPE = { + 'function': 1, + 'performance': 1 << 1, + 'power': 1 << 2, + 'reliability': 1 << 3, + 'security': 1 << 4, + 'global': 1 << 5, + 'compatibility': 1 << 6, + 'user': 1 << 7, + 'standard': 1 << 8, + 'safety': 1 << 9, + 'resilience': 1 << 10, +}; + +export const LEVEL = { + '0': 1 << 24, + '1': 1 << 25, + '2': 1 << 26, + '3': 1 << 27, + '4': 1 << 28, +}; + +export const SIZE = { + 'small': 1 << 16, + 'medium': 1 << 17, + 'large': 1 << 18, +}; + +export const KEYSET = [ + '-s class', '-s notClass', '-s suite', '-s itName', + '-s level', '-s testType', '-s size', '-s timeout', + '-s dryRun', '-s random', '-s breakOnError', '-s stress', + '-s coverage', '-s skipMessage', '-s runSkipped', + 'class', 'notClass', 'suite', 'itName', + 'level', 'testType', 'size', 'timeout', 'dryRun', 'random', + 'breakOnError', 'stress', 'coverage', 'skipMessage', 'runSkipped' +]; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/core.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/core.js new file mode 100644 index 0000000..1981a5a --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/core.js @@ -0,0 +1,159 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {SuiteService, SpecService, ExpectService, ReportService} from './service'; +import {ConfigService} from './module/config/configService'; +import {SpecEvent, TaskEvent, SuiteEvent} from './event'; + +/** + * core service for execute testcase. + */ +class Core { + static getInstance() { + if (!this.instance) { + this.instance = new Core(); + } + return this.instance; + } + + constructor() { + this.instance = null; + this.services = { + suite: {}, + spec: {}, + config: {}, + expect: {}, + log: {}, + report: {} + + }; + this.events = { + suite: {}, + spec: {}, + task: {} + }; + } + + addService(name, service) { + let serviceObj = {}; + if (!this.services[name]) { + this.services[name] = serviceObj; + } else { + serviceObj = this.services[name]; + } + serviceObj[service.id] = service; + } + + getDefaultService(name) { + return this.services[name].default; + } + + getServices(name) { + return this.services[name]; + } + + registerEvent(serviceName, event) { + let eventObj = {}; + if (!this.events[serviceName]) { + this.events[serviceName] = eventObj; + } else { + eventObj = this.events[serviceName]; + } + eventObj[event.id] = event; + } + + unRegisterEvent(serviceName, eventID) { + const eventObj = this.events[serviceName]; + if (eventObj) { + delete eventObj[eventID]; + } + } + + subscribeEvent(serviceName, serviceObj) { + const eventObj = this.events[serviceName]; + if (eventObj) { + for (const attr in eventObj) { + eventObj[attr]['subscribeEvent'](serviceObj); + } + } + } + + async fireEvents(serviceName, eventName) { + const eventObj = this.events[serviceName]; + if (!eventObj) { + return; + } + for (const attr in eventObj) { + await eventObj[attr][eventName](); + } + } + + addToGlobal(apis) { + if (typeof globalThis !== 'undefined') { + for (let api in apis) { + globalThis[api] = apis[api]; + } + } + for (const api in apis) { + this[api] = apis[api]; + } + } + + init() { + this.addService('suite', new SuiteService({id: 'default'})); + this.addService('spec', new SpecService({id: 'default'})); + this.addService('expect', new ExpectService({id: 'default'})); + this.addService('report', new ReportService({id: 'default'})); + this.addService('config', new ConfigService({id: 'default'})); + this.registerEvent('task', new TaskEvent({id: 'default', coreContext: this})); + this.registerEvent('suite', new SuiteEvent({id: 'default', coreContext: this})); + this.registerEvent('spec', new SpecEvent({id: 'default', coreContext: this})); + this.subscribeEvent('spec', this.getDefaultService('report')); + this.subscribeEvent('suite', this.getDefaultService('report')); + this.subscribeEvent('task', this.getDefaultService('report')); + const context = this; + for (const key in this.services) { + const serviceObj = this.services[key]; + for (const serviceID in serviceObj) { + const service = serviceObj[serviceID]; + service.init(context); + + if (typeof service.apis !== 'function') { + continue; + } + const apis = service.apis(); + if (apis) { + this.addToGlobal(apis); + } + } + } + } + + execute(abilityDelegator) { + const suiteService = this.getDefaultService('suite'); + const configService = this.getDefaultService('config'); + if (configService['dryRun'] === 'true') { + (async function () { + await suiteService.dryRun(abilityDelegator); + })(); + return; + } + setTimeout(() => { + suiteService.execute(); + }, 10); + } +} + +export default Core; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/event.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/event.js new file mode 100644 index 0000000..d465896 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/event.js @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class SpecEvent { + constructor(attr) { + this.id = attr.id; + this.coreContext = attr.context; + this.eventMonitors = []; + } + + subscribeEvent(service) { + this.eventMonitors.push(service); + } + + async specStart() { + for (const monitor of this.eventMonitors) { + await monitor['specStart'](); + } + } + + async specDone() { + for (const monitor of this.eventMonitors) { + await monitor['specDone'](); + } + } +} + +class SuiteEvent { + constructor(attr) { + this.id = attr.id; + this.suiteContext = attr.coreContext; + this.eventMonitors = []; + } + + subscribeEvent(service) { + this.eventMonitors.push(service); + } + + async suiteStart() { + for (const monitor of this.eventMonitors) { + await monitor['suiteStart'](); + } + } + + async suiteDone() { + for (const monitor of this.eventMonitors) { + await monitor['suiteDone'](); + } + } +} + +class TaskEvent { + constructor(attr) { + this.id = attr.id; + this.coreContext = attr.coreContext; + this.eventMonitors = []; + } + + subscribeEvent(service) { + this.eventMonitors.push(service); + } + + async taskStart() { + for (const monitor of this.eventMonitors) { + await monitor['taskStart'](); + } + } + + async taskDone() { + for (const monitor of this.eventMonitors) { + await monitor['taskDone'](); + } + } + + incorrectFormat() { + for (const monitor of this.eventMonitors) { + monitor['incorrectFormat'](); + } + } + + incorrectTestSuiteFormat() { + for (const monitor of this.eventMonitors) { + monitor.incorrectTestSuiteFormat(); + } + } +} + +export { SpecEvent, TaskEvent, SuiteEvent }; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/interface.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/interface.js new file mode 100644 index 0000000..e2530d2 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/interface.js @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import Core from './core'; + +const core = Core.getInstance(); + +const describe = function (desc, func) { + return Reflect.has(core, 'describe') ? core.describe(desc, func) : (desc, func) => { }; +}; +const it = function (desc, filter, func) { + return Reflect.has(core, 'it') ? core.it(desc, filter, func) : (desc, filter, func) => { }; +}; +const beforeItSpecified = function (itDescs, func) { + return Reflect.has(core, 'beforeItSpecified') ? core.beforeItSpecified(itDescs, func) : (itDescs, func) => { }; +}; + +const afterItSpecified = function (itDescs, func) { + return Reflect.has(core, 'afterItSpecified') ? core.afterItSpecified(itDescs, func) : (itDescs, func) => { }; +}; +const beforeEach = function (func) { + return Reflect.has(core, 'beforeEach') ? core.beforeEach(func) : (func) => { }; +}; +const afterEach = function (func) { + return Reflect.has(core, 'afterEach') ? core.afterEach(func) : (func) => { }; +}; +const beforeAll = function (func) { + return Reflect.has(core, 'beforeAll') ? core.beforeAll(func) : (func) => { }; +}; +const afterAll = function (func) { + return Reflect.has(core, 'afterAll') ? core.afterAll(func) : (func) => { }; +}; +const expect = function (actualValue) { + return Reflect.has(core, 'expect') ? core.expect(actualValue) : (actualValue) => { }; +}; + +const xdescribe = function (desc, func) { + return Reflect.has(core, 'xdescribe') ? core.xdescribe(desc, func, null) : (desc, func, reason) => { }; +}; +xdescribe.reason = (reason) => { + return (desc, func) => { + return Reflect.has(core, 'xdescribe') ? core.xdescribe(desc, func, reason) : (desc, func, reason) => { }; + }; +}; +const xit = function (desc, filter, func) { + return Reflect.has(core, 'xit') ? core.xit(desc, filter, func, null) : (desc, filter, func, reason) => { }; +}; +xit.reason = (reason) => { + return (desc, filter, func) => { + return Reflect.has(core, 'xit') ? core.xit(desc, filter, func, reason) : (desc, filter, func, reason) => { }; + }; +}; + +export { + describe, it, beforeAll, beforeEach, afterEach, afterAll, expect, beforeItSpecified, afterItSpecified, xdescribe, xit +}; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module.json b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module.json new file mode 100644 index 0000000..5f76af6 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module.json @@ -0,0 +1,31 @@ +{ + "app": { + "bundleName": "com.ohos.myapplication", + "debug": true, + "versionCode": 1000000, + "versionName": "1.0.0", + "minAPIVersion": 11, + "targetAPIVersion": 11, + "apiReleaseType": "Release", + "compileSdkVersion": "4.1.7.5", + "compileSdkType": "OpenHarmony", + "appEnvironments": [], + "bundleType": "app" + }, + "module": { + "name": "hypium", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "tv", + "wearable", + "car" + ], + "packageName": "@ohos/hypium", + "installationFree": false, + "virtualMachine": "ark11.0.2.0", + "compileMode": "esmodule", + "dependencies": [] + } +} diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/ExpectExtend.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/ExpectExtend.js new file mode 100644 index 0000000..6a3a01f --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/ExpectExtend.js @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import assertNull from './assertNull'; +import assertClose from './assertClose'; +import assertContain from './assertContain'; +import assertLess from './assertLess'; +import assertLarger from './assertLarger'; +import assertFail from './assertFail'; +import assertUndefined from './assertUndefined'; +import assertFalse from './assertFalse'; +import assertInstanceOf from './assertInstanceOf'; +import assertThrowError from './assertThrowError'; +import assertLargerOrEqual from './assertLargerOrEqual'; +import assertLessOrEqual from './assertLessOrEqual'; +import assertNaN from './assertNaN'; +import assertNegUnlimited from './assertNegUnlimited'; +import assertPosUnlimited from './assertPosUnlimited'; +import assertDeepEquals from './deepEquals/assertDeepEquals'; +import assertPromiseIsPending from './assertPromiseIsPending'; +import assertPromiseIsRejected from './assertPromiseIsRejected'; +import assertPromiseIsRejectedWith from './assertPromiseIsRejectedWith'; +import assertPromiseIsRejectedWithError from './assertPromiseIsRejectedWithError'; +import assertPromiseIsResolved from './assertPromiseIsResolved'; +import assertPromiseIsResolvedWith from './assertPromiseIsResolvedWith'; +class ExpectExtend { + constructor(attr) { + this.id = attr.id; + this.matchers = {}; + } + + extendsMatchers() { + this.matchers.assertNull = assertNull; + this.matchers.assertClose = assertClose; + this.matchers.assertContain = assertContain; + this.matchers.assertLess = assertLess; + this.matchers.assertLarger = assertLarger; + this.matchers.assertFail = assertFail; + this.matchers.assertUndefined = assertUndefined; + this.matchers.assertFalse = assertFalse; + this.matchers.assertInstanceOf = assertInstanceOf; + this.matchers.assertThrowError = assertThrowError; + this.matchers.assertLargerOrEqual = assertLargerOrEqual; + this.matchers.assertLessOrEqual = assertLessOrEqual; + this.matchers.assertNaN = assertNaN; + this.matchers.assertNegUnlimited = assertNegUnlimited; + this.matchers.assertPosUnlimited = assertPosUnlimited; + this.matchers.assertDeepEquals = assertDeepEquals; + this.matchers.assertPromiseIsPending = assertPromiseIsPending; + this.matchers.assertPromiseIsRejected = assertPromiseIsRejected; + this.matchers.assertPromiseIsRejectedWith = assertPromiseIsRejectedWith; + this.matchers.assertPromiseIsRejectedWithError = assertPromiseIsRejectedWithError; + this.matchers.assertPromiseIsResolved = assertPromiseIsResolved; + this.matchers.assertPromiseIsResolvedWith = assertPromiseIsResolvedWith; + } + + init(coreContext) { + this.coreContext = coreContext; + this.extendsMatchers(); + const expectService = this.coreContext.getDefaultService('expect'); + expectService.addMatchers(this.matchers); + } + + apis() { + return { + 'expect': function (actualValue) { + return this.coreContext.getDefaultService('expect').expect(actualValue); + } + }; + } +} + +export default ExpectExtend; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertClose.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertClose.js new file mode 100644 index 0000000..b4470fa --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertClose.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertClose(actualValue, expected) { + if (actualValue === null && expected[0] === null) { + throw new Error('actualValue and expected can not be both null!!!'); + } + let result; + let diff = Math.abs(expected[0] - actualValue); + let actualAbs = Math.abs(actualValue); + if ((actualAbs - 0) === 0) { + if ((diff - 0) === 0) { + result = true; + } else { + result = false; + } + } else if (diff / actualAbs < expected[1]) { + result = true; + } else { + result = false; + } + return { + pass: result, + message: '|' + actualValue + ' - ' + expected[0] + '|/' + actualValue + ' is not less than ' + expected[1] + }; +} + +export default assertClose; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertContain.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertContain.js new file mode 100644 index 0000000..ee896ab --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertContain.js @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertContain(actualValue, expect) { + let result = false; + if (Object.prototype.toString.call(actualValue).indexOf('Array')) { + for (let i in actualValue) { + if (actualValue[i] == expect[0]) { + result = true; + } + } + } + let type = Object.prototype.toString.call(actualValue); + if (type === '[object String]') { + result = actualValue.indexOf(expect[0]) >= 0; + } + return { + pass: result, + message: 'expect false, ' + actualValue + ' do not have ' + expect[0] + }; +} + +export default assertContain; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertFail.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertFail.js new file mode 100644 index 0000000..e06dcd4 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertFail.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertFail() { + return { + pass: false, + message: 'fail ' + }; +} + +export default assertFail; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertFalse.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertFalse.js new file mode 100644 index 0000000..299781f --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertFalse.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertFalse(actualValue) { + return { + pass: (actualValue) === false, + message: 'expect false, actualValue is ' + actualValue + }; +} + +export default assertFalse; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertInstanceOf.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertInstanceOf.js new file mode 100644 index 0000000..bc5e52c --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertInstanceOf.js @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertInstanceOf(actualValue, expected) { + if (Object.prototype.toString.call(actualValue) == '[object ' + expected[0] + ']') { + return { + pass: true + }; + } else { + return { + pass: false, + message: actualValue + ' is ' + Object.prototype.toString.call(actualValue) + 'not ' + expected[0] + }; + } +} + +export default assertInstanceOf; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLarger.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLarger.js new file mode 100644 index 0000000..a0fa15e --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLarger.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertLarger(actualValue, expected) { + return { + pass: (actualValue) > expected[0], + message: (actualValue) + ' is not larger than ' + expected[0] + }; +} + +export default assertLarger; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLargerOrEqual.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLargerOrEqual.js new file mode 100644 index 0000000..3416bd1 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLargerOrEqual.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertLargerOrEqual(actualValue, expected) { + return { + pass: (actualValue) >= expected[0], + message: (actualValue) + ' is not larger than ' + expected[0] + }; +} + +export default assertLargerOrEqual; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLess.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLess.js new file mode 100644 index 0000000..23a1d8c --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLess.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertLess(actualValue, expected) { + return { + pass: (actualValue) < expected[0], + message: (actualValue) + ' is not less than ' + expected[0] + }; +} + +export default assertLess; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLessOrEqual.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLessOrEqual.js new file mode 100644 index 0000000..4a2d05e --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertLessOrEqual.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertLessOrEqual(actualValue, expected) { + return { + pass: (actualValue) <= expected[0], + message: (actualValue) + ' is not less than ' + expected[0] + }; +} + +export default assertLessOrEqual; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNaN.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNaN.js new file mode 100644 index 0000000..fa06fe7 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNaN.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertNaN(actualValue) { + return { + pass: actualValue !== actualValue, + message: 'expect NaN, actualValue is ' + actualValue + }; +} + +export default assertNaN; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNegUnlimited.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNegUnlimited.js new file mode 100644 index 0000000..3573ee0 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNegUnlimited.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +function assertNegUnlimited(actualValue) { + return { + pass: actualValue === Number.NEGATIVE_INFINITY, + message: 'Expected actualValue not to be -Infinity. actualValue is,' + actualValue + }; +} + +export default assertNegUnlimited; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNull.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNull.js new file mode 100644 index 0000000..32523dd --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertNull.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertNull(actualValue) { + return { + pass: (actualValue) === null, + message: 'expect null, actualValue is ' + (actualValue) + }; +} + +export default assertNull; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPosUnlimited.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPosUnlimited.js new file mode 100644 index 0000000..43a5a0f --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPosUnlimited.js @@ -0,0 +1,23 @@ +/* +* Copyright (c) 2022 Huawei Device Co., Ltd. +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + +function assertPosUnlimited(actualValue) { + return { + pass: actualValue === Number.POSITIVE_INFINITY, + message: 'Expected actualValue is POSITIVE_INFINITY. actualValue is,' + actualValue + }; +} + +export default assertPosUnlimited; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsPending.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsPending.js new file mode 100644 index 0000000..5297cc2 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsPending.js @@ -0,0 +1,42 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import isPromiseLike from './isPromiseLike'; + +function assertPromiseIsPending(actualPromise) { + if (!isPromiseLike(actualPromise)) { + return Promise.reject().then(function () { + }, function () { + return {pass: false, message: 'Expected not be called on a promise.'}; + }); + } + const helper = {}; + return Promise.race([actualPromise, Promise.resolve(helper)]).then( + function (got) { + return helper === got ? {pass: true, message: 'actualValue is isPending'} + : { + pass: false, + message: 'expect isPending, actualValue is resolve' + }; + }, + function () { + return { + pass: false + , message: 'expect isPending, actualValue is reject' + }; + }); +} + +export default assertPromiseIsPending; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejected.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejected.js new file mode 100644 index 0000000..1bb43c5 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejected.js @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import isPromiseLike from './isPromiseLike'; + +function assertPromiseIsRejected(actualPromise) { + if (!isPromiseLike(actualPromise)) { + return Promise.reject().then(function () { + }, function () { + return {pass: false, message: 'Expected not be called on a promise.'}; + }); + } + return actualPromise.then( + function (got) { + return { + pass: false, + message: 'expect isRejected, but actualValue is resolve' + }; + }, + function () { + return {pass: true, message: 'actualValue is isRejected'}; + } + ); +} + +export default assertPromiseIsRejected; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWith.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWith.js new file mode 100644 index 0000000..d81f680 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWith.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import isPromiseLike from './isPromiseLike'; + +function assertPromiseIsRejectedWith(actualPromise, expectedValue) { + + if (!isPromiseLike(actualPromise)) { + return Promise.reject().then(function () { + }, function () { + return {pass: false, message: 'Expected not be called on a promise.'}; + }); + } + + function tips(passed) { + return ('Expected a promise ' + (passed ? 'not ' : '') + + 'to be rejected with ' + JSON.stringify(expectedValue[0])); + } + + return actualPromise.then( + function (got) { + return { + pass: false, + message: tips(false) + ' but actualValue is resolve' + }; + }, + function (actualValue) { + if (JSON.stringify(actualValue) == JSON.stringify(expectedValue[0])) { + return { + pass: true, + message: 'actualValue was rejected with ' + JSON.stringify(actualValue) + '.' + }; + } else { + return { + pass: false, + message: tips(false) + ' but it was rejected with ' + JSON.stringify(actualValue) + '.' + }; + } + } + ); +} + +export default assertPromiseIsRejectedWith; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWithError.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWithError.js new file mode 100644 index 0000000..b910148 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsRejectedWithError.js @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import isPromiseLike from './isPromiseLike'; + +function assertPromiseIsRejectedWithError(actualPromise, expectedValue) { + if (!isPromiseLike(actualPromise)) { + return Promise.reject().then(function () { + }, function () { + return {pass: false, message: 'Expected not be called on a promise.'}; + }); + } + return actualPromise.then( + function (got) { + return { + pass: false, + message: 'Expected a promise to be rejected but actualValue is resolve' + }; + }, + function (actualValue) { + return matchError(actualValue, expectedValue); + } + ); + +} + +function matchError(actualValue, expectedValue) { + if (expectedValue.length == 1 && typeof expectedValue[0] === 'function') { + if (expectedValue[0].name === actualValue.__proto__.name) { + return {pass: true, message: 'actual error type is ' + actualValue.name + '.'}; + } + return {pass: false, message: `except error type is ${expectedValue[0].name},but actual is ${actualValue.name}.`}; + } + + if (expectedValue.length == 1 && typeof expectedValue[0] === 'string') { + if (expectedValue[0] === actualValue.message) { + return {pass: true, message: `actual error message is ${actualValue.message}.`}; + } + return {pass: false, message: `except error message ${expectedValue[0]},but actual is ${actualValue.message}.`}; + } + + if (expectedValue.length == 1) { + return {pass: false, message: 'When only one parameter, it should be error type or error message.'}; + } + + if (expectedValue.length == 2 && typeof expectedValue[0] === 'function' && expectedValue[0].name === actualValue.name) { + if (typeof expectedValue[1] === 'string' && actualValue.message === expectedValue[1]) { + return {pass: true, message: 'actual error message is ' + actualValue.message + '.'}; + } + return {pass: false, message: `except error message is ${expectedValue[1]},but actual is ${actualValue.message}.`}; + } + + if (expectedValue.length == 2 && typeof expectedValue[0] === 'function' && expectedValue[0].name !== actualValue.name) { + if (typeof expectedValue[1] === 'string' && actualValue.message === expectedValue[1]) { + return {pass: false, message: `except error type is ${expectedValue[0].name},but actual is ${actualValue.name}.`}; + } + return {pass: false, message: 'except error type and message are incorrect.'}; + } + if (expectedValue.length > 2) { + return {pass: false, message: 'Up to two parameters are supported.'}; + } + return {pass: true, message: 'not equal type'}; +} + +export default assertPromiseIsRejectedWithError; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolved.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolved.js new file mode 100644 index 0000000..28cf278 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolved.js @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import isPromiseLike from './isPromiseLike'; + +function assertPromiseIsResolved(actualPromise) { + if (!isPromiseLike(actualPromise)) { + return Promise.reject().then(function () { + }, function () { + return {pass: false, message: 'Expected not be called on a promise.'}; + }); + } + + return actualPromise.then( + function (got) { + return {pass: true, message: 'actualValue is isResolved'}; + }, + function (rej) { + return { + pass: false, + message: 'Expected a promise to be resolved but it was ' + + 'rejected with ' + JSON.stringify(rej) + '.' + }; + } + ); +} + +export default assertPromiseIsResolved; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolvedWith.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolvedWith.js new file mode 100644 index 0000000..b20c3e5 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertPromiseIsResolvedWith.js @@ -0,0 +1,55 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import isPromiseLike from './isPromiseLike'; + +function assertPromiseIsResolvedWith(actualPromise, expectedValue) { + if (!isPromiseLike(actualPromise)) { + return Promise.reject().then(function () { + }, function () { + return {pass: false, message: 'Expected not be called on a promise.'}; + }); + } + + function tips(passed) { + return ( + 'Expected a promise ' + (passed ? 'not ' : '') + + 'to be resolved with ' + JSON.stringify(expectedValue[0])); + } + + return actualPromise.then( + function (got) { + if (JSON.stringify(got) == JSON.stringify(expectedValue[0])) { + return { + pass: true, + message: 'actualValue was resolved with ' + JSON.stringify(got) + '.' + }; + } + return { + pass: false, + message: tips(false) + ' but it was resolved with ' + + JSON.stringify(got) + '.' + }; + }, + function (rej) { + return { + pass: false, + message: tips(false) + ' but it was rejected with ' + JSON.stringify(rej) + '.' + }; + } + ); +} + +export default assertPromiseIsResolvedWith; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertThrowError.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertThrowError.js new file mode 100644 index 0000000..55a6f4a --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertThrowError.js @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertThrowError(actualValue, expected) { + let result = false; + let message = ''; + let err; + if (typeof actualValue !== 'function') { + throw new Error('actualValue is not a function'); + } + try { + actualValue(); + return { + pass: result, + message: ' An error is not thrown while it is expected!' + }; + } catch (e) { + err = e; + } + if (err instanceof Error) { + let type = typeof expected[0]; + if (type === 'function') { + result = err.constructor.name === expected[0].name; + message = 'expected throw failed , ' + err.constructor.name + ' is not ' + expected[0].name; + } else if (type === 'string') { + result = err.message.includes(expected[0]); + message = 'expected throw failed , ' + err.message + ' is not ' + expected[0]; + } + } + return { + pass: result, + message: message + }; +} + +export default assertThrowError; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertUndefined.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertUndefined.js new file mode 100644 index 0000000..0cd0570 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/assertUndefined.js @@ -0,0 +1,23 @@ +/* + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function assertUndefined(actualValue) { + return { + pass: undefined === (actualValue), + message: 'expect Undefined, actualValue is ' + (actualValue) + }; +} + +export default assertUndefined; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/deepEquals/DeepTypeUtils.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/deepEquals/DeepTypeUtils.js new file mode 100644 index 0000000..40dc13b --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/deepEquals/DeepTypeUtils.js @@ -0,0 +1,139 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class DeepTypeUtils { + static getType(value) { + return Object.prototype.toString.apply(value); + } + static isA(typeName, value) { + return this.getType(value) === '[object ' + typeName + ']'; + } + static isAsymmetricEqualityTester(obj) { + return obj ? this.isA('Function', obj.asymmetricMatch) : false; + } + + /** + * 是否是function + * @param value + */ + static isFunction(value) { + return this.isA('Function', value); + } + + /** + * 是否是undefined + * @param obj + */ + static isUndefined(obj) { + return obj === void 0; + } + + /** + * 是否是Node + * @param obj + */ + static isDomNode(obj) { + return obj !== null && + typeof obj === 'object' && + typeof obj.nodeType === 'number' && + typeof obj.nodeName === 'string'; + } + + /** + * 是否是promise对象 + * @param obj + */ + static isPromise(obj) { + return !!obj && obj.constructor === Promise; + }; + /** + * 是否是map对象 + * @param obj + */ + static isMap(obj) { + return ( + obj !== null && + typeof obj !== 'undefined' && + obj.constructor === Map + ); + } + + /** + * 是否是set对象 + * @param obj 对象 + */ + static isSet(obj) { + return ( + obj !== null && + typeof obj !== 'undefined' && + obj.constructor === Set + ); + } + + /** + * 对象是否有key属性 + * @param obj 对象 + * @param key 对象属性名称 + */ + static has(obj, key) { + return Object.prototype.hasOwnProperty.call(obj, key); + } + + /** + * 获取对象的自有属性 + * @param obj 对象 + * @param isArray 是否是数组,[object Array] + */ + static keys(obj, isArray) { + const extraKeys = []; + // 获取对象所有属性 + const allKeys = this.getAllKeys(obj); + if (!isArray) { + return allKeys; + } + if (allKeys.length === 0) { + return allKeys; + } + for (const k of allKeys) { + if (typeof k === 'symbol' || !/^[0-9]+$/.test(k)) { + extraKeys.push(k); + } + } + return extraKeys; + } + + /** + * 获取obj对象的所有属性 + * @param obj obj对象 + */ + static getAllKeys(obj) { + const keys = []; + for (let key in obj) { + if (this.has(obj, key)) { + keys.push(key); + } + } + const symbols = Object.getOwnPropertySymbols(obj); + for (const sym of symbols) { + // obj.propertyIsEnumerable(sym) + if (Object.prototype.propertyIsEnumerable.call(obj, sym)) { + keys.push(sym); + } + } + return keys; + } + +} +export default DeepTypeUtils; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/deepEquals/assertDeepEquals.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/deepEquals/assertDeepEquals.js new file mode 100644 index 0000000..0ad8ba7 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/deepEquals/assertDeepEquals.js @@ -0,0 +1,341 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import DeepTypeUtils from './DeepTypeUtils'; +function assertDeepEquals(actualValue, expected) { + let result = eq(actualValue, expected[0]); + let msg = logMsg(actualValue, expected[0]); + return { + pass: result, + message: msg + }; +} + +/** + * 获取失败显示日志 + * @param actualValue 实际对象 + * @param expected 期待比较对象 + */ +function logMsg(actualValue, expected) { + // 获取a的对象名称 + const aClassName = Object.prototype.toString.call(actualValue); + const bClassName = Object.prototype.toString.call(expected); + let actualMsg; + let expectMsg; + if (aClassName == '[object Function]') { + actualMsg = 'actualValue Function'; + } else if (aClassName == '[object Promise]') { + actualMsg = 'actualValue Promise'; + } else if (aClassName == '[object Set]' || aClassName == '[object Map]') { + actualMsg = JSON.stringify(Array.from(actualValue)); + } else if (aClassName == '[object RegExp]') { + actualMsg = JSON.stringify(actualValue.source.replace('\\', '')); + } else if (aClassName == '[object BigInt]') { + actualMsg = actualValue; + } else if (aClassName == '[object Error]') { + actualMsg = actualValue.message; + } else if (aClassName == '[object ArrayBuffer]') { + actualMsg = actualValue.byteLength; + } + else { + actualMsg = JSON.stringify(actualValue); + } + if (bClassName == '[object Function]') { + expectMsg = 'expected Function'; + } else if (bClassName == '[object Promise]') { + expectMsg = 'expected Promise'; + } else if (bClassName == '[object Set]' || bClassName == '[object Map]') { + expectMsg = JSON.stringify(Array.from(expected)); + } else if (bClassName == '[object RegExp]') { + expectMsg = JSON.stringify(expected.source.replace('\\', '')); + } else if (bClassName == '[object BigInt]') { + expectMsg = expected; + } else if (bClassName == '[object Error]') { + expectMsg = expected.message; + } else if (bClassName == '[object ArrayBuffer]') { + expectMsg = expected.byteLength; + } + else { + expectMsg = JSON.stringify(expected); + } + return actualMsg + ' is not deep equal ' + expectMsg; +} + +function eq(a, b) { + let result = true; + + if (a === b) { + result = a !== 0 || 1 / a === 1 / b; + return result; + } + + if (a === null || b === null) { + result = a === b; + return result; + } + // 获取a的对象名称 + const aClassName = Object.prototype.toString.call(a); + const bClassName = Object.prototype.toString.call(b); + // 不同类型不同对象 + if (aClassName !== bClassName) { + return false; + } + if (aClassName === '[object String]' || aClassName === '[object Number]' || aClassName === '[object Date]' || + aClassName === '[object Boolean]' || aClassName === '[object ArrayBuffer]' || + aClassName === '[object RegExp]' || aClassName === '[object Error]') { + result = isEqualSampleObj(a, b); + return result; + } + + if (typeof a !== 'object' || typeof b !== 'object') { + return false; + } + + if (DeepTypeUtils.isDomNode(a) || DeepTypeUtils.isPromise(a) || DeepTypeUtils.isFunction(a)) { + result = isEqualNodeOrPromiseOrFunction(a, b); + return result; + } + + if (aClassName === '[object Array]' || aClassName === '[object Map]' || aClassName === '[object Set]') { + result = isEqualCollection(a, b); + return result; + } + + result = isEqualObj(a, b); + return result; +} + +function isEqualNodeOrPromiseOrFunction(a, b) { + let equalNodeOrPromiseOrFunction = true; + if (DeepTypeUtils.isDomNode(a) && DeepTypeUtils.isDomNode(b)) { + const aIsDomNode = DeepTypeUtils.isDomNode(a); + const bIsDomNode = DeepTypeUtils.isDomNode(b); + if (aIsDomNode && bIsDomNode) { + // At first try to use DOM3 method isEqualNode + equalNodeOrPromiseOrFunction = a.isEqualNode(b); + return equalNodeOrPromiseOrFunction; + } + if (aIsDomNode || bIsDomNode) { + equalNodeOrPromiseOrFunction = false; + return false; + } + } + + if (DeepTypeUtils.isPromise(a) && DeepTypeUtils.isPromise(b)) { + const aIsPromise = DeepTypeUtils.isPromise(a); + const bIsPromise = DeepTypeUtils.isPromise(b); + // 俩个Promise对象 + if (aIsPromise && bIsPromise) { + equalNodeOrPromiseOrFunction = a === b; + return a === b; + } + } + if (DeepTypeUtils.isFunction(a) && DeepTypeUtils.isFunction(b)) { + // 俩个函数对象 + const aCtor = a.constructor, + bCtor = b.constructor; + if ( + aCtor !== bCtor && + DeepTypeUtils.isFunction(aCtor) && + DeepTypeUtils.isFunction(bCtor) && + a instanceof aCtor && + b instanceof bCtor && + !(aCtor instanceof aCtor && bCtor instanceof bCtor) + ) { + equalNodeOrPromiseOrFunction = false; + return false; + } + } + return equalNodeOrPromiseOrFunction; +} + +function isEqualCollection(a, b) { + let equalCollection = true; + // 获取a的对象名称 + const aClassName = Object.prototype.toString.call(a); + const bClassName = Object.prototype.toString.call(b); + // 都是数组 + if (aClassName === '[object Array]') { + equalCollection = isEqualArray(a, b); + return equalCollection; + } + + // 都是Map + if (DeepTypeUtils.isMap(a) && DeepTypeUtils.isMap(b)) { + equalCollection = isEqualMap(a, b); + return equalCollection; + } + + // 都是Set + if (DeepTypeUtils.isSet(a) && DeepTypeUtils.isSet(b)) { + equalCollection = isEqualSet(a, b); + return equalCollection; + } + + return true; +} + +function isEqualSampleObj(a, b) { + let equalSampleObj = true; + const aClassName = Object.prototype.toString.call(a); + const bClassName = Object.prototype.toString.call(b); + // 俩个string对象 + if (aClassName === '[object String]') { + equalSampleObj = a === String(b); + return equalSampleObj; + } + // 俩个Number对象 + if (aClassName === '[object Number]') { + equalSampleObj = a !== +a ? b !== +b : a === 0 && b === 0 ? 1 / a === 1 / b : a === +b; + return equalSampleObj; + } + + // 俩个Date对象/ boolean对象 + if (aClassName === '[object Date]' || aClassName === '[object Boolean]') { + equalSampleObj = +a === +b; + return equalSampleObj; + } + + // 俩个ArrayBuffer + if (aClassName === '[object ArrayBuffer]') { + equalSampleObj = eq(new Uint8Array(a), new Uint8Array(b)); + return equalSampleObj; + } + + // 正则表达式 + if (aClassName === '[object RegExp]') { + return ( + a.source === b.source && + a.global === b.global && + a.multiline === b.multiline && + a.ignoreCase === b.ignoreCase + ); + } + + if (a instanceof Error && b instanceof Error) { + equalSampleObj = a.message === b.message; + return equalSampleObj; + } + + return equalSampleObj; +} + +function isEqualObj(a, b) { + let equalObj = true; + const aClassName = Object.prototype.toString.call(a); + const bClassName = Object.prototype.toString.call(b); + const aKeys = DeepTypeUtils.keys(a, aClassName === '[object Array]'); + let size = aKeys.length; + + // 俩个对象属性长度不一致, 俩对象不相同 + if (DeepTypeUtils.keys(b, bClassName === '[object Array]').length !== size) { + return false; + } + + // 俩对象属性数量相同, 递归比较每个属性值得值 + for (const key of aKeys) { + // b 没有 key 属性 + if (!DeepTypeUtils.has(b, key)) { + equalObj = false; + continue; + } + if (!eq(a[key], b[key])) { + equalObj = false; + } + } + return equalObj; +} + +function isEqualArray(a, b) { + let equalArray = true; + const aLength = a.length; + const bLength = b.length; + if (aLength !== bLength) { + // 数组长度不同,不是同一个对象 + return false; + } + for (let i = 0; i < aLength || i < bLength; i++) { + // 递归每一个元素是否相同 + equalArray = eq(i < aLength ? a[i] : void 0, i < bLength ? b[i] : void 0) && equalArray; + } + return equalArray; +} + +function isEqualMap(a, b) { + let equalMap = true; + if (a.size !== b.size) { + return false; + } + const keysA = []; + const keysB = []; + a.forEach(function(valueA, keyA) { + keysA.push(keyA); + }); + b.forEach(function(valueB, keyB) { + keysB.push(keyB); + }); + const mapKeys = [keysA, keysB]; + const cmpKeys = [keysB, keysA]; + for (let i = 0; equalMap && i < mapKeys.length; i++) { + const mapIter = mapKeys[i]; + const cmpIter = cmpKeys[i]; + + for (let j = 0; equalMap && j < mapIter.length; j++) { + const mapKey = mapIter[j]; + const cmpKey = cmpIter[j]; + const mapValueA = a.get(mapKey); + let mapValueB; + if (eq(mapKey, cmpKey)) { + mapValueB = b.get(cmpKey); + } else { + mapValueB = b.get(mapKey); + } + equalMap = eq(mapValueA, mapValueB); + } + } + return equalMap; +} + +function isEqualSet(a, b) { + let equalSet = true; + if (a.size !== b.size) { + return false; + } + const valuesA = []; + a.forEach(function(valueA) { + valuesA.push(valueA); + }); + const valuesB = []; + b.forEach(function(valueB) { + valuesB.push(valueB); + }); + const setPairs = [[valuesA, valuesB], [valuesB, valuesA]]; + for (let i = 0; equalSet && i < setPairs.length; i++) { + const baseValues = setPairs[i][0]; + const otherValues = setPairs[i][1]; + for (const baseValue of baseValues) { + let found = false; + for (let j = 0; !found && j < otherValues.length; j++) { + const otherValue = otherValues[j]; + // 深度比较对象 + found = eq(baseValue, otherValue); + } + equalSet = equalSet && found; + } + } + return equalSet; +} + +export default assertDeepEquals; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/isPromiseLike.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/isPromiseLike.js new file mode 100644 index 0000000..1604237 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/assert/isPromiseLike.js @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function isPromiseLike(obj) { + return !!obj && isFunction(obj.then); +} + +function isFunction(value) { + return isA('Function', value); +} + +function isA(typeName, value) { + return getType(value) === '[object ' + typeName + ']'; +} + +function getType(value) { + return Object.prototype.toString.apply(value); +} + +export default isPromiseLike; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/DataDriver.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/DataDriver.js new file mode 100644 index 0000000..0d9f9e1 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/DataDriver.js @@ -0,0 +1,135 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +const SUITES_KEY = 'suites'; +const SPECS_KEY = 'items'; +const DESCRIBE_KEY = 'describe'; +const IT_KEY = 'it'; +const PARAMS_KEY = 'params'; +const STRESS_KEY = 'stress'; + +class ObjectUtils { + static get(object, name, defaultValue) { + let result = defaultValue; + for (const key in object) { + if (key === name) { + return object[key]; + } + } + return result; + } + + static has(object, key) { + return Object.prototype.hasOwnProperty.call(object, key); + } +} + +class DataDriver { + constructor(attr) { + this.id = 'dataDriver'; + this.data = attr.data || {}; + } + + init(coreContext) { + this.coreContext = coreContext; + this.suiteService = this.coreContext.getDefaultService('suite'); + this.specService = this.coreContext.getDefaultService('spec'); + } + + getSpecParamsValue(specs) { + let specParams = []; + let specDesc = this.specService.getCurrentRunningSpec().description; + if (specs === null || specs === undefined) { + return specParams; + } + for (const specItem of specs) { + if (ObjectUtils.has(specItem, IT_KEY) && ObjectUtils.get(specItem, IT_KEY) === specDesc) { + return ObjectUtils.get(specItem, PARAMS_KEY, specParams); + } + } + return specParams; + } + + getSpecParams() { + let specParams = []; + let suiteDesc = this.suiteService.getCurrentRunningSuite().description; + let specDesc = this.specService.getCurrentRunningSpec().description; + let suites = ObjectUtils.get(this.data, SUITES_KEY, []); + for (const suiteItem of suites) { + let describeValue = ObjectUtils.get(suiteItem, DESCRIBE_KEY, ''); + if (ObjectUtils.has(suiteItem, DESCRIBE_KEY) && (typeof describeValue === 'object') && describeValue.constructor === Array && describeValue.includes(suiteDesc)) { + let specs = ObjectUtils.get(suiteItem, SPECS_KEY, []); + return this.getSpecParamsValue(specs); + } + } + return specParams; + } + + getSuiteParams() { + let suiteParams = {}; + let suiteDesc = this.suiteService.getCurrentRunningSuite().description; + let suites = ObjectUtils.get(this.data, SUITES_KEY, []); + for (const suiteItem of suites) { + let describeValue = ObjectUtils.get(suiteItem, DESCRIBE_KEY, []); + if (ObjectUtils.has(suiteItem, DESCRIBE_KEY) && (typeof describeValue === 'object') && describeValue.constructor === Array && describeValue.includes(suiteDesc)) { + suiteParams = Object.assign({}, suiteParams, ObjectUtils.get(suiteItem, PARAMS_KEY, suiteParams)); + } + } + return suiteParams; + } + + getStressNum(specs, specDesc) { + let stress = 1; + if (specs === null || specs === undefined) { + return stress; + } + for (const specItem of specs) { + if (ObjectUtils.has(specItem, IT_KEY) && ObjectUtils.get(specItem, IT_KEY) === specDesc) { + let tempStress = ObjectUtils.get(specItem, STRESS_KEY, stress); + return (Number.isInteger(tempStress) && tempStress >= 1) ? tempStress : stress; + } + } + return stress; + } + + getSpecStress(specDesc) { + let stress = 1; + let suiteDesc = this.suiteService.getCurrentRunningSuite().description; + let suites = ObjectUtils.get(this.data, SUITES_KEY, []); + for (const suiteItem of suites) { + let describeValue = ObjectUtils.get(suiteItem, DESCRIBE_KEY, ''); + if (ObjectUtils.has(suiteItem, DESCRIBE_KEY) && (typeof describeValue === 'object') && describeValue.constructor === Array && describeValue.includes(suiteDesc)) { + let specs = ObjectUtils.get(suiteItem, SPECS_KEY, []); + return this.getStressNum(specs, specDesc); + } + } + return stress; + } + + getSuiteStress(suiteDesc) { + let stress = 1; + let suites = ObjectUtils.get(this.data, SUITES_KEY, []); + for (const suiteItem of suites) { + let describeValue = ObjectUtils.get(suiteItem, DESCRIBE_KEY, []); + if (ObjectUtils.has(suiteItem, DESCRIBE_KEY) && (typeof describeValue === 'object') && describeValue.constructor === Array && describeValue.includes(suiteDesc)) { + let tempStress = ObjectUtils.get(suiteItem, STRESS_KEY, stress); + return (Number.isInteger(tempStress) && tempStress >= 1) ? tempStress : stress; + } + } + return stress; + } +} + +export default DataDriver; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/Filter.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/Filter.js new file mode 100644 index 0000000..136e6f8 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/Filter.js @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { LEVEL, SIZE, TESTTYPE } from '../../Constant'; + +class ClassFilter { + constructor(suiteName, itName, params) { + this.suiteName = suiteName; + this.itName = itName; + this.params = params; + } + + filterSuite() { + return !this.params.split(',').map(item => item.split('#')[0]).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); + } + + filterIt() { + let classArray = this.params.split(',') || []; + let suiteFilterResult = classArray.filter(item => !item.includes('#')).map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); + let itFilterResult = classArray.filter(item => item.includes('#')).map(item => item == (this.suiteName + '#' + this.itName)).reduce((pre, cur) => pre || cur, false); + return !(suiteFilterResult || itFilterResult); + } +} + +class NotClassFilter { + constructor(suiteName, itName, params) { + this.suiteName = suiteName; + this.itName = itName; + this.params = params; + } + + filterSuite() { + return this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); + } + + filterIt() { + return this.params.split(',').some(item => item == (this.suiteName + '#' + this.itName)); + } +} + +class SuiteAndItNameFilter { + constructor(suiteName, itName, params) { + this.suiteName = suiteName; + this.itName = itName; + this.params = params; + } + + filterSuite() { + return !this.params.split(',').map(item => item == this.suiteName).reduce((pre, cur) => pre || cur, false); + } + + filterIt() { + return !this.params.split(',').map(item => item == this.itName).reduce((pre, cur) => pre || cur, false); + } +} + + +class TestTypesFilter { + constructor(suiteName, itName, fi, params) { + this.suiteName = suiteName; + this.itName = itName; + this.params = params; + this.fi = fi; + } + + filterIt() { + return !((this.params === (this.fi & this.params)) || this.fi === 0); + } +} + +class NestFilter { + filterNestName(targetSuiteArray, targetSpecArray, suiteStack, desc) { + let targetSuiteName = ''; + for (let key in suiteStack) { + targetSuiteName = targetSuiteName + '.' + suiteStack[key].description; + } + targetSuiteName = targetSuiteName.substring(2); + const targetSpecName = targetSuiteName + '#' + desc; + let isFilter = true; + if (targetSpecArray.includes(targetSpecName)) { + return false; + } + for (let index in targetSuiteArray) { + if (targetSuiteName.startsWith(targetSuiteArray[index])) { + return false; + } + } + return isFilter; + } + + filterNotClass(notClass, suiteStack, desc) { + let filterNotClass = false; + if (notClass != null) { + let notClassArray = notClass.split(','); + let targetSuiteName = ''; + for (let key in suiteStack) { + targetSuiteName = targetSuiteName + '.' + suiteStack[key].description; + } + targetSuiteName = targetSuiteName.substring(2); + const targetSpecName = targetSuiteName + '#' + desc; + if (notClassArray.includes(targetSpecName) || notClassArray.some(key => targetSpecName.startsWith(key))) { + filterNotClass = true; + } + } + return filterNotClass; + } + + filterLevelOrSizeOrTestType(level, size, testType, filter) { + let result = false; + if (filter === 0 || filter === '0') { + return result; + } + if (level == null && size == null && testType == null) { + return result; + } + if (level != null) { + let levelFilter = LEVEL[`${level}`]; + result = result || filter === levelFilter; + } + if (size != null) { + let sizeFilter = SIZE[`${size}`]; + result = result || filter === sizeFilter; + } + if (testType != null) { + let testTypeFilter = TESTTYPE[`${testType}`]; + result = result || filter === testTypeFilter; + } + return !result; + } +} +export { ClassFilter, NotClassFilter, SuiteAndItNameFilter, TestTypesFilter, NestFilter }; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/configService.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/configService.js new file mode 100644 index 0000000..296745d --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/config/configService.js @@ -0,0 +1,299 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ClassFilter, NotClassFilter, SuiteAndItNameFilter, TestTypesFilter, NestFilter } from './Filter'; +import { TAG, TESTTYPE, LEVEL, SIZE, KEYSET } from '../../Constant'; +const STRESS_RULE = /^[1-9]\d*$/; + +class ConfigService { + constructor(attr) { + this.id = attr.id; + this.supportAsync = true; // 默认异步处理测试用例 + this.random = false; + this.filterValid = []; + this.filter = 0; + this.flag = false; + this.suite = null; + this.itName = null; + this.testType = null; + this.level = null; + this.size = null; + this.class = null; + this.notClass = null; + this.timeout = null; + // 遇错即停模式配置 + this.breakOnError = false; + // 压力测试配置 + this.stress = null; + this.skipMessage = false; + this.runSkipped = ''; + this.filterXdescribe = []; + } + + init(coreContext) { + this.coreContext = coreContext; + } + + isNormalInteger(str) { + const n = Math.floor(Number(str)); + return n !== Infinity && String(n) === String(str) && n >= 0; + } + + + getStress() { + if (this.stress === undefined || this.stress === '' || this.stress === null) { + return 1; + } + return !this.stress.match(STRESS_RULE) ? 1 : Number.parseInt(this.stress); + } + + basicParamValidCheck(params) { + let size = params.size; + if (size !== undefined && size !== '' && size !== null) { + let sizeArray = ['small', 'medium', 'large']; + if (sizeArray.indexOf(size) === -1) { + this.filterValid.push('size:' + size); + } + } + let level = params.level; + if (level !== undefined && level !== '' && level !== null) { + let levelArray = ['0', '1', '2', '3', '4']; + if (levelArray.indexOf(level) === -1) { + this.filterValid.push('level:' + level); + } + } + let testType = params.testType; + if (testType !== undefined && testType !== '' && testType !== null) { + let testTypeArray = ['function', 'performance', 'power', 'reliability', 'security', + 'global', 'compatibility', 'user', 'standard', 'safety', 'resilience']; + if (testTypeArray.indexOf(testType) === -1) { + this.filterValid.push('testType:' + testType); + } + } + } + + filterParamValidCheck(params) { + let timeout = params.timeout; + if (timeout !== undefined && timeout !== '' && timeout !== null) { + if (!this.isNormalInteger(timeout)) { + this.filterValid.push('timeout:' + timeout); + } + } + + let paramKeys = ['dryRun', 'random', 'breakOnError', 'coverage', 'skipMessage']; + for (const key of paramKeys) { + if (params[key] !== undefined && params[key] !== 'true' && params[key] !== 'false') { + this.filterValid.push(`${key}:${params[key]}`); + } + } + + // 压力测试参数验证,正整数 + if (params.stress !== undefined && params.stress !== '' && params.stress !== null) { + if (!params.stress.match(STRESS_RULE)) { + this.filterValid.push('stress:' + params.stress); + } + } + + let nameRule = /^[A-Za-z]{1}[\w#,.]*$/; + let paramClassKeys = ['class', 'notClass']; + for (const key of paramClassKeys) { + if (params[key] !== undefined && params[key] !== '' && params[key] !== null) { + let classArray = params[key].split(','); + classArray.forEach(item => !item.match(nameRule) ? this.filterValid.push(`${key}:${params[key]}`) : null); + } + } + } + + setConfig(params) { + this.basicParamValidCheck(params); + this.filterParamValidCheck(params); + try { + this.class = params.class; + this.notClass = params.notClass; + this.flag = params.flag || { flag: false }; + this.suite = params.suite; + this.itName = params.itName; + this.filter = params.filter; + this.testType = params.testType; + this.level = params.level; + this.size = params.size; + this.timeout = params.timeout; + this.dryRun = params.dryRun; + this.breakOnError = params.breakOnError; + this.random = params.random === 'true' ? true : false; + this.stress = params.stress; + this.coverage = params.coverage; + this.skipMessage = params.skipMessage; + this.runSkipped = params.runSkipped; + this.filterParam = { + testType: TESTTYPE, + level: LEVEL, + size: SIZE + }; + this.parseParams(); + } catch (err) { + console.info(`${TAG}setConfig error: ${err.message}`); + } + } + + parseParams() { + if (this.filter != null) { + return; + } + let testTypeFilter = 0; + let sizeFilter = 0; + let levelFilter = 0; + if (this.testType != null) { + testTypeFilter = this.testType.split(',') + .map(item => this.filterParam.testType[item] || 0) + .reduce((pre, cur) => pre | cur, 0); + } + if (this.level != null) { + levelFilter = this.level.split(',') + .map(item => this.filterParam.level[item] || 0) + .reduce((pre, cur) => pre | cur, 0); + } + if (this.size != null) { + sizeFilter = this.size.split(',') + .map(item => this.filterParam.size[item] || 0) + .reduce((pre, cur) => pre | cur, 0); + } + this.filter = testTypeFilter | sizeFilter | levelFilter; + console.info(`${TAG}filter params:${this.filter}`); + } + + isCurrentSuite(description) { + if (this.suite !== undefined && this.suite !== '' && this.suite !== null) { + let suiteArray = this.suite.split(','); + return suiteArray.indexOf(description) !== -1; + } + return false; + } + + filterSuite(currentSuiteName) { + let filterArray = []; + if (this.suite !== undefined && this.suite !== '' && this.suite !== null) { + filterArray.push(new SuiteAndItNameFilter(currentSuiteName, '', this.suite)); + } + if (this.class !== undefined && this.class !== '' && this.class !== null) { + filterArray.push(new ClassFilter(currentSuiteName, '', this.class)); + } + if (this.notClass !== undefined && this.notClass !== '' && this.notClass !== null) { + filterArray.push(new NotClassFilter(currentSuiteName, '', this.notClass)); + } + + let result = filterArray.map(item => item.filterSuite()).reduce((pre, cur) => pre || cur, false); + return result; + } + + filterDesc(currentSuiteName, desc, fi, coreContext) { + let filterArray = []; + if (this.itName !== undefined && this.itName !== '' && this.itName !== null) { + filterArray.push(new SuiteAndItNameFilter(currentSuiteName, desc, this.itName)); + } + if (this.class !== undefined && this.class !== '' && this.class !== null) { + filterArray.push(new ClassFilter(currentSuiteName, desc, this.class)); + } + if (this.notClass !== undefined && this.notClass !== '' && this.notClass !== null) { + filterArray.push(new NotClassFilter(currentSuiteName, desc, this.notClass)); + } + if (typeof (this.filter) !== 'undefined' && this.filter !== 0 && fi !== 0) { + filterArray.push(new TestTypesFilter('', '', fi, this.filter)); + } + let result = filterArray.map(item => item.filterIt()).reduce((pre, cur) => pre || cur, false); + return result; + } + + filterWithNest(desc, filter) { + let filterArray = []; + const nestFilter = new NestFilter(); + const targetSuiteArray = this.coreContext.getDefaultService('suite').targetSuiteArray; + const targetSpecArray = this.coreContext.getDefaultService('suite').targetSpecArray; + const suiteStack = this.coreContext.getDefaultService('suite').suitesStack; + let isFilter = nestFilter.filterNestName(targetSuiteArray, targetSpecArray, suiteStack, desc); + const isFullRun = this.coreContext.getDefaultService('suite').fullRun; + if (typeof (this.filter) !== 'undefined' && this.filter !== 0 && filter !== 0) { + filterArray.push(new TestTypesFilter('', '', filter, this.filter)); + return filterArray.map(item => item.filterIt()).reduce((pre, cur) => pre || cur, false); + } + if (isFilter && !isFullRun) { + return true; + } + return nestFilter.filterNotClass(this.notClass, suiteStack, desc); + + } + + isRandom() { + return this.random || false; + } + + isBreakOnError() { + return this.breakOnError !== 'true' ? false : true; + } + + setSupportAsync(value) { + this.supportAsync = value; + } + + isSupportAsync() { + return this.supportAsync; + } + + translateParams(parameters) { + const keySet = new Set(KEYSET); + let targetParams = {}; + for (const key in parameters) { + if (keySet.has(key)) { + var newKey = key.replace('-s ', ''); + targetParams[newKey] = parameters[key]; + } + } + return targetParams; + } + translateParamsToString(parameters) { + const keySet = new Set(KEYSET); + let targetParams = ''; + for (const key in parameters) { + if (keySet.has(key)) { + targetParams += ' ' + key + ' ' + parameters[key]; + } + } + return targetParams.trim(); + } + + execute() { + } + + checkIfSuiteInSkipRun(desc) { + return this.runSkipped.split(',').some(item => { + return item === desc || item.startsWith(desc + '.') || item.startsWith(desc + '#') || desc.startsWith(item + '.') || this.runSkipped === 'skipped'; + }); + } + + checkIfSpecInSkipRun(desc) { + return this.runSkipped.split(',').some(item => { + if (item.includes('#')) { + return item === desc; + } else { + return desc.startsWith(item + '.') || desc.startsWith(item + '#') || this.runSkipped === 'skipped'; + } + } + ); + } +} + +export { + ConfigService +}; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/coverage/coverageCollect.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/coverage/coverageCollect.js new file mode 100644 index 0000000..be5a7a8 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/coverage/coverageCollect.js @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import SysTestKit from '../kit/SysTestKit'; +import fs from '@ohos.file.fs'; +import {TAG} from '../../Constant'; + +const jsCoverageFileName = 'js_coverage.json'; + +export async function collectCoverageData() { + if (globalThis.__coverage__ === undefined) { + console.info(`${TAG} globalThis not have coverage`); + return; + } + const strJson = JSON.stringify(globalThis.__coverage__); + let testMode = globalThis.__testMode__; + console.info(`${TAG} coverage data testMode: ${testMode}`); + let savePath = globalThis.__savePath__; + console.info(`${TAG} write coverage data to: ${savePath}`); + let readPath = globalThis.__readPath__; + console.info(`${TAG} read coverage data in: ${readPath}`); + + // run callback mode if local test or (save path and read path ) is not defined + if (!testMode || !isCoveragePathValid(savePath)) { + console.info(`${TAG} run coverage data in call back mode`); + const strLen = strJson.length; + const maxLen = 500; + const maxCount = Math.floor(strLen / maxLen); + const OHOS_REPORT_COVERAGE_DATA = 'OHOS_REPORT_COVERAGE_DATA:'; + for (let count = 0; count <= maxCount; count++) { + console.info(`${OHOS_REPORT_COVERAGE_DATA} ${strJson.substring(count * maxLen, (count + 1) * maxLen)}`); + await SysTestKit.print(`${OHOS_REPORT_COVERAGE_DATA} ${strJson.substring(count * maxLen, (count + 1) * maxLen)}`); + } + return; + } + console.info(`${TAG} run coverage data in save file mode`); + if (fs.accessSync(savePath)) { + fs.unlinkSync(savePath); + } + + let inputPathDir = savePath.substring(0, savePath.length - jsCoverageFileName.length); + if (!fs.accessSync(inputPathDir)) { + console.info(`${TAG} coverage data create dir: ${inputPathDir}`); + fs.mkdirSync(inputPathDir); + } + + let file = fs.openSync(savePath, fs.OpenMode.READ_WRITE | fs.OpenMode.CREATE); + let writeLen = fs.writeSync(file.fd, strJson, {encoding:'utf-8'}); + console.info(`${TAG} write coverage data success: ${writeLen}`); + fs.closeSync(file); + const OHOS_REPORT_COVERAGE_PATH = 'OHOS_REPORT_COVERAGE_PATH:'; + await SysTestKit.print(`${OHOS_REPORT_COVERAGE_PATH} ${readPath}`); + console.info(`${OHOS_REPORT_COVERAGE_PATH} ${readPath}`); +} + +function isCoveragePathValid(inputPath) { + if (!inputPath) { + return false; + } + if (inputPath.indexOf(jsCoverageFileName) === -1) { + return false; + } + return true; +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/kit/SysTestKit.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/kit/SysTestKit.js new file mode 100644 index 0000000..3bc622d --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/kit/SysTestKit.js @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {TAG} from '../../Constant'; +import Core from '../../core.js'; + +export default class SysTestKit { + + static delegator = null; + static systemTime = null; + static workerPort = null; + + constructor() { + this.id = 'sysTestKit'; + this.index = 0; + } + + static getDescribeName() { + return Core.getInstance().getDefaultService('suite').getCurrentRunningSuite().description; + } + + static getItName() { + return Core.getInstance().getDefaultService('spec').getCurrentRunningSpec().description; + } + + static getItAttribute() { + return Core.getInstance().getDefaultService('spec').getCurrentRunningSpec().fi; + } + + static actionStart(tag) { + console.info(`${TAG}${JSON.stringify(tag)}`); + var message = '\n' + 'OHOS_REPORT_ACTIONSTART: ' + JSON.stringify(tag) + '\n'; + SysTestKit.print(message); + console.info(`${TAG}${JSON.stringify(tag)} actionStart print success`); + } + + static actionEnd(tag) { + console.info(`${TAG}${JSON.stringify(tag)}`); + var message = '\n' + 'OHOS_REPORT_ACTIONEND: ' + JSON.stringify(tag) + '\n'; + SysTestKit.print(message); + console.info(`${TAG}${JSON.stringify(tag)} actionEnd print success`); + } + + static async existKeyword(keyword, timeout) { + let reg = new RegExp(/^[a-zA-Z0-9]{1,}$/); + if (!reg.test(keyword)) { + throw new Error('keyword must contain more than one string, and only letters and numbers are supported.'); + } + timeout = timeout || 4; + + let searchResult = false; + let cmd = 'hilog -x | grep -i \'' + keyword + '\' | wc -l'; + await executePromise(cmd, timeout).then((data) => { + searchResult = data; + }); + return searchResult; + } + static async print(message) { + if ('printSync' in SysTestKit.delegator) { + console.info(`${TAG}printSync called ...`); + SysTestKit.delegator.printSync(message); + } else { + await SysTestKit.delegator.print(message); + } + } + + static async getRealTime() { + let currentTime = new Date().getTime(); + if (SysTestKit.systemTime !== null && SysTestKit.systemTime !== undefined) { + await SysTestKit.systemTime.getRealTime().then((time) => { + console.info(`${TAG}systemTime.getRealTime success data: ${JSON.stringify(time)}`); + currentTime = time; + }).catch((error) => { + console.error(`${TAG}failed to systemTime.getRealTime because ${JSON.stringify(error)}`); + }); + } + return currentTime; + } +} + +function executePromise(cmd, timeout) { + return new Promise((resolve, reject) => { + SysTestKit.delegator.executeShellCommand(cmd, timeout, + (error, data) => { + console.info(`${TAG}existKeyword CallBack: err : ${JSON.stringify(error)}`); + console.info(`${TAG}existKeyword CallBack: data : ${JSON.stringify(data)}`); + resolve(parseInt(data.stdResult) > 3 ? true : false); + }); + }); +} \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/ArgumentMatchers.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/ArgumentMatchers.js new file mode 100644 index 0000000..b3fa101 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/ArgumentMatchers.js @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class ArgumentMatchers { + ANY = ''; + ANY_STRING = ''; + ANY_BOOLEAN = ''; + ANY_NUMBER = ''; + ANY_OBJECT = ''; + ANY_FUNCTION = ''; + MATCH_REGEXS = ''; + + static any() { + } + + static anyString() { + } + + static anyBoolean() { + } + + static anyNumber() { + } + + static anyObj() { + } + + static anyFunction() { + } + + static matchRegexs() { + let regex = arguments[0]; + if (ArgumentMatchers.isRegExp(regex)) { + return regex; + } + throw Error('not a regex'); + } + + static isRegExp(value) { + return Object.prototype.toString.call(value) === '[object RegExp]'; + } + + matcheReturnKey() { + let arg = arguments[0]; + let regex = arguments[1]; + let stubSetKey = arguments[2]; + + if (stubSetKey && stubSetKey == this.ANY) { + return this.ANY; + } + + if (typeof arg === 'string' && !regex) { + return this.ANY_STRING; + } + + if (typeof arg === 'boolean' && !regex) { + return this.ANY_BOOLEAN; + } + + if (typeof arg === 'number' && !regex) { + return this.ANY_NUMBER; + } + + if (typeof arg === 'object' && !regex) { + return this.ANY_OBJECT; + } + + if (typeof arg === 'function' && !regex) { + return this.ANY_FUNCTION; + } + + if (typeof arg === 'string' && regex) { + return regex.test(arg); + } + + return null; + } + + matcheStubKey() { + let key = arguments[0]; + + if (key === ArgumentMatchers.any) { + return this.ANY; + } + + if (key === ArgumentMatchers.anyString) { + return this.ANY_STRING; + } + if (key === ArgumentMatchers.anyBoolean) { + return this.ANY_BOOLEAN; + } + if (key === ArgumentMatchers.anyNumber) { + return this.ANY_NUMBER; + } + if (key === ArgumentMatchers.anyObj) { + return this.ANY_OBJECT; + } + if (key === ArgumentMatchers.anyFunction) { + return this.ANY_FUNCTION; + } + + if (ArgumentMatchers.isRegExp(key)) { + return key; + } + + return null; + } +} + +export default ArgumentMatchers; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/ExtendInterface.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/ExtendInterface.js new file mode 100644 index 0000000..2ffc667 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/ExtendInterface.js @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class ExtendInterface { + constructor(mocker) { + this.mocker = mocker; + } + + stub() { + this.params = arguments; + return this; + } + + stubMockedCall(returnInfo) { + this.mocker.stubApply(this, this.params, returnInfo); + } + + afterReturn(value) { + this.stubMockedCall(function () { + return value; + }); + } + + afterReturnNothing() { + this.stubMockedCall(function () { + return undefined; + }); + } + + afterAction(action) { + this.stubMockedCall(action); + } + + afterThrow(msg) { + this.stubMockedCall(function () { + throw msg; + }); + } + + clear() { + this.mocker.clear(); + } +} + +export default ExtendInterface; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/MockKit.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/MockKit.js new file mode 100644 index 0000000..a702dc6 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/MockKit.js @@ -0,0 +1,347 @@ +/* + * Copyright (c) 2022-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import ExtendInterface from './ExtendInterface'; +import VerificationMode from './VerificationMode'; +import ArgumentMatchers from './ArgumentMatchers'; + +class MockKit { + constructor() { + this.mFunctions = []; + this.stubs = new Map(); + this.recordCalls = new Map(); + this.currentSetKey = new Map(); + this.mockObj = null; + this.recordMockedMethod = new Map(); + } + + init() { + this.reset(); + } + + reset() { + this.mFunctions = []; + this.stubs = {}; + this.recordCalls = {}; + this.currentSetKey = new Map(); + this.mockObj = null; + this.recordMockedMethod = new Map(); + } + + clearAll() { + this.reset(); + var props = Object.keys(this); + for (var i = 0; i < props.length; i++) { + delete this[props[i]]; + } + + var props = Object.getOwnPropertyNames(this); + for (var i = 0; i < props.length; i++) { + delete this[props[i]]; + } + for (var key in this) { + delete this[key]; + } + } + + clear(obj) { + if (!obj) { + throw Error('Please enter an object to be cleaned'); + } + if (typeof obj !== 'object' && typeof obj !== 'function') { + throw new Error('Not a object or static class'); + } + this.recordMockedMethod.forEach(function (value, key, map) { + if (key) { + obj[key] = value; + } + }); + } + + ignoreMock(obj, method) { + if (typeof obj !== 'object' && typeof obj !== 'function') { + throw new Error('Not a object or static class'); + } + if (typeof method !== 'function') { + throw new Error('Not a function'); + } + let og = this.recordMockedMethod.get(method.propName); + if (og) { + obj[method.propName] = og; + this.recordMockedMethod.set(method.propName, undefined); + } + } + + extend(dest, source) { + dest['stub'] = source['stub']; + dest['afterReturn'] = source['afterReturn']; + dest['afterReturnNothing'] = source['afterReturnNothing']; + dest['afterAction'] = source['afterAction']; + dest['afterThrow'] = source['afterThrow']; + dest['stubMockedCall'] = source['stubMockedCall']; + dest['clear'] = source['clear']; + return dest; + } + + stubApply(f, params, returnInfo) { + let values = this.stubs.get(f); + if (!values) { + values = new Map(); + } + let key = params[0]; + if (typeof key === 'undefined') { + key = 'anonymous-mock-' + f.propName; + } else { + key = []; + const matcher = new ArgumentMatchers(); + for (let i = 0; i < params.length; i++) { + const param = params[i]; + const matchKey = matcher.matcheStubKey(param); + if (matchKey) { + key.push(matchKey); + } else { + key.push(param); + } + } + } + values.set(key, returnInfo); + this.stubs.set(f, values); + } + + getReturnInfo(f, params) { + let values = this.stubs.get(f); + if (!values) { + return undefined; + } + let returnKet = params[0]; + const anonymousName = 'anonymous-mock-' + f.propName; + if (typeof returnKet === 'undefined') { + returnKet = anonymousName; + } else { + returnKet = this.getReturnKet(values, params, returnKet, anonymousName); + } + + return values.get(returnKet); + } + + getReturnKet(values, params, defaultValue, anonymousName) { + let flag = true; + let returnKet = defaultValue; + values.forEach((value, paramsKey, map) => { + if ( + flag && + paramsKey !== anonymousName && + paramsKey.length === params.length && + this.checkIsRightValue(paramsKey, params) + ) { + returnKet = paramsKey; + flag = false; + } + }); + return returnKet; + } + + checkIsRightValue(paramsKey, params) { + const matcher = new ArgumentMatchers(); + return paramsKey.every((key, j) => { + if (ArgumentMatchers.isRegExp(key) && typeof params[j] === 'string') { + return key.test(params[j]); + } + const matchKey = matcher.matcheReturnKey(params[j], undefined, key); + if (matchKey && matchKey === key) { + return true; + } else if (this.checkIsEqual(params[j], key)) { + return true; + } + return false; + }); + } + + checkIsEqual(value1, value2) { + if (value1 === value2) { + return true; + } + if (typeof value1 !== typeof value2) { + return false; + } + if (Array.isArray(value1) && Array.isArray(value2)) { + if (value1.length !== value2.length) { + return false; + } + for (let i = 0; i < value1.length; i++) { + if (!this.checkIsEqual(value1[i], value2[i])) { + return false; + } + } + return true; + } + if (Object.prototype.toString.call(value1) === '[object Object]' && + Object.prototype.toString.call(value2) === '[object Object]') { + const keys1 = Object.keys(value1); + const keys2 = Object.keys(value2); + if (keys1.length !== keys2.length) { + return false; + } + for (let key of keys1) { + if (!keys2.includes(key) || !this.checkIsEqual(value1[key], value2[key])) { + return false; + } + } + return true; + } + if (Object.prototype.toString.call(value1) === '[object Date]' && + Object.prototype.toString.call(value2) === '[object Date]' && + value1.getTime() === value2.getTime()) { + return true; + } + if (Object.prototype.toString.call(value1) === '[object RegExp]' && + Object.prototype.toString.call(value2) === '[object RegExp]' && + value1.toString() === value2.toString()) { + return true; + } + return false; + } + + findName(obj, value) { + let properties = this.findProperties(obj); + let name = null; + properties + .filter((item) => item !== 'caller' && item !== 'arguments') + .forEach(function (va1, idx, array) { + if (obj[va1] === value) { + name = va1; + } + }); + return name; + } + + isFunctionFromPrototype(f, container, propName) { + if ( + container.constructor !== Object && + container.constructor.prototype !== container + ) { + return container.constructor.prototype[propName] === f; + } + return false; + } + + findProperties(obj, ...arg) { + function getProperty(newObj) { + if (newObj.__proto__ === null) { + return []; + } + let properties = Object.getOwnPropertyNames(newObj); + return [...properties, ...getProperty(newObj.__proto__)]; + } + return getProperty(obj); + } + + recordMethodCall(originalMethod, args) { + Function.prototype.getName = function () { + return this.name || this.toString().match(/function\s*([^(]*)\(/)[1]; + }; + let name = originalMethod.getName(); + let arglistString = name + '(' + Array.from(args).toString() + ')'; + let records = this.recordCalls.get(arglistString); + if (!records) { + records = 0; + } + records++; + this.recordCalls.set(arglistString, records); + } + + mockFunc(originalObject, originalMethod) { + let tmp = this; + this.originalMethod = originalMethod; + let f = function () { + let args = arguments; + let action = tmp.getReturnInfo(f, args); + if (originalMethod) { + tmp.recordMethodCall(originalMethod, args); + } + if (action) { + return action.apply(this, args); + } + }; + + f.container = null || originalObject; + f.original = originalMethod || null; + + if (originalObject && originalMethod) { + if (typeof originalMethod !== 'function') { + throw new Error('Not a function'); + } + var name = this.findName(originalObject, originalMethod); + originalObject[name] = f; + this.recordMockedMethod.set(name, originalMethod); + f.propName = name; + f.originalFromPrototype = this.isFunctionFromPrototype( + f.original, + originalObject, + f.propName + ); + } + f.mocker = this; + this.mFunctions.push(f); + this.extend(f, new ExtendInterface(this)); + return f; + } + + verify(methodName, argsArray) { + if (!methodName) { + throw Error('not a function name'); + } + let a = this.recordCalls.get(methodName + '(' + argsArray.toString() + ')'); + return new VerificationMode(a ? a : 0); + } + + mockObject(object) { + if (!object || typeof object === 'string') { + throw Error(`this ${object} cannot be mocked`); + } + const _this = this; + let mockedObject = {}; + let keys = Reflect.ownKeys(object); + keys + .filter((key) => typeof Reflect.get(object, key) === 'function') + .forEach((key) => { + mockedObject[key] = object[key]; + mockedObject[key] = _this.mockFunc(mockedObject, mockedObject[key]); + }); + return mockedObject; + } +} + +function ifMockedFunction(f) { + if ( + Object.prototype.toString.call(f) !== '[object Function]' && + Object.prototype.toString.call(f) !== '[object AsyncFunction]' + ) { + throw Error('not a function'); + } + if (!f.stub) { + throw Error('not a mock function'); + } + return true; +} + +function when(f) { + if (!ifMockedFunction(f)) { + throw Error('not a mock function'); + } + return f.stub.bind(f); +} + +export { MockKit, when }; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/VerificationMode.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/VerificationMode.js new file mode 100644 index 0000000..d0d9b88 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/mock/VerificationMode.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2022-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import {expect} from '../../interface'; + +class VerificationMode { + constructor(times) { + this.doTimes = times; + } + + times(count) { + expect(count).assertEqual(this.doTimes); + } + + never() { + console.info(this.doTimes); + expect(0).assertEqual(this.doTimes); + } + + once() { + expect(1).assertEqual(this.doTimes); + } + + atLeast(count) { + if (count > this.doTimes) { + throw Error('failed ' + count + ' greater than the actual execution times of method'); + } + } + + atMost(count) { + if (count < this.doTimes) { + throw Error('failed ' + count + ' less than the actual execution times of method'); + } + } +} + +export default VerificationMode; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/LogExpectError.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/LogExpectError.js new file mode 100644 index 0000000..86974b9 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/LogExpectError.js @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class LogExpectError { + static getErrorMsg(matcherName, actualValue, expect, originMsg) { + if (matcherName === 'assertNull') { + return 'expect not null, actualValue is ' + (actualValue); + } + if (matcherName === 'assertTrue') { + return 'expect not true, actualValue is ' + (actualValue); + } + if (matcherName === 'assertFalse') { + return 'expect not false, actualValue is ' + (actualValue); + } + if (matcherName === 'assertEqual') { + return 'expect not Equal, actualValue is ' + actualValue + ' equals ' + expect; + } + if (matcherName === 'assertContain') { + return 'expect not have, ' + actualValue + ' have ' + expect; + } + if (matcherName === 'assertInstanceOf') { + return 'expect not InstanceOf, ' + actualValue + ' is ' + + Object.prototype.toString.call(actualValue) + expect; + } + if (matcherName === 'assertLarger') { + return 'expect not Larger, ' + + (actualValue) + ' is larger than ' + expect; + } + if (matcherName === 'assertLargerOrEqual') { + return 'expect not LargerOrEqual, ' + (actualValue) + ' larger than ' + expect; + } + if (matcherName === 'assertLess') { + return 'expect not Less, ' + (actualValue) + ' less than ' + expect; + } + if (matcherName === 'assertLessOrEqual') { + return 'expect not LessOrEqual, ' + (actualValue) + ' is less than ' + expect; + } + if (matcherName === 'assertNaN') { + return 'expect not NaN, actualValue is ' + (actualValue); + } + if (matcherName === 'assertNegUnlimited') { + return 'expect not NegUnlimited, actualValue is ' + (actualValue); + } + if (matcherName === 'assertPosUnlimited') { + return 'expect not PosUnlimited, actualValue is ' + (actualValue); + } + if (matcherName === 'assertUndefined') { + return 'expect not Undefined, actualValue is ' + (actualValue); + } + return originMsg; + } +} +export default LogExpectError; \ No newline at end of file diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/OhReport.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/OhReport.js new file mode 100644 index 0000000..65f25eb --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/OhReport.js @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import SysTestKit from '../kit/SysTestKit'; +import { collectCoverageData } from '../coverage/coverageCollect'; +import { TAG, PrintTag } from '../../Constant'; + +class OhReport { + constructor(attr) { + this.delegator = attr.delegator; + this.abilityDelegatorArguments = attr.abilityDelegatorArguments; + this.id = 'report'; + this.index = 0; + this.duration = 0; + this.currentThreadName = 'mainThread'; + } + + init(coreContext) { + this.coreContext = coreContext; + this.suiteService = this.coreContext.getDefaultService('suite'); + this.specService = this.coreContext.getDefaultService('spec'); + if (SysTestKit.workerPort !== null) { + this.currentThreadName = SysTestKit.workerPort.name; + } + } + + taskStart() { + } + + async taskDone() { + let summary = this.suiteService.getSummary(); + if (this.abilityDelegatorArguments !== null) { + this.taskDoneTime = new Date().getTime(); + const configService = this.coreContext.getDefaultService('config'); + const suiteService = this.coreContext.getDefaultService('suite'); + const specService = this.coreContext.getDefaultService('spec'); + if (configService['coverage'] === 'true') { + await collectCoverageData(); + } + let message = '\n' + `${PrintTag.OHOS_REPORT_RESULT}: stream=Tests run: ` + summary.total + ', Failure: ' + summary.failure; + message += ', Error: ' + summary.error; + message += ', Pass: ' + summary.pass; + message += ', Ignore: ' + summary.ignore; + if (specService.skipSpecNum > 0) { + message += ', SkipSpec: ' + specService.skipSpecNum; + } + message += '\n' + `${PrintTag.OHOS_REPORT_CODE}: ` + (summary.failure > 0 ? -1 : 0) + '\n'; + let isHasError = summary.failure > 0 || summary.error > 0; + let config = this.coreContext.getDefaultService('config'); + if (config.isBreakOnError() && isHasError) { + // 未执行全部说明 + message += '\n' + `${PrintTag.OHOS_REPORT_RESULT}: breakOnError model, Stopping whole test suite if one specific test case failed or error` + '\n'; + } + message += `${PrintTag.OHOS_REPORT_STATUS}: taskconsuming=` + summary.duration + '\n'; + console.info(`${message}`); + await SysTestKit.print(message); + } + if (SysTestKit.workerPort === null || SysTestKit.workerPort === undefined) { + // 主线程执行完成 结束任务。 + console.info(`${TAG}report print success`); + this.delegator.finishTest('your test finished!!!', 0, () => { }); + } else { + // worker线程执行完成将数据发送到主线程中。 + let sendData = { + currentThreadName: this.currentThreadName, + summary: summary + }; + console.info(`${TAG}, send data to mainThread, ${this.currentThreadName}, ${JSON.stringify(sendData)}`); + SysTestKit.workerPort.postMessage(sendData); + } + } + + incorrectFormat() { + if (this.coreContext.getDefaultService('config').filterValid.length !== 0) { + var value = this.coreContext.getDefaultService('config').filterValid; + var message = 'this param ' + value.join(',') + ' is invalid' + '\n'; + this.delegator.finishTest(message, 0, () => { + }); + } + } + + incorrectTestSuiteFormat() { + if (this.coreContext.getDefaultService('config').filterXdescribe.length !== 0) { + let value = this.coreContext.getDefaultService('config').filterXdescribe; + let message = 'xdescribe ' + value.join(',') + ' should not contain it' + '\n'; + this.delegator.finishTest(message, 0, () => { + }); + } + } + async suiteStart() { + if (this.abilityDelegatorArguments !== null) { + let specArr = []; + this.suiteService.getAllChildSuiteNum(this.suiteService.getCurrentRunningSuite(), specArr); + let message = '\n' + `${PrintTag.OHOS_REPORT_SUM}: ` + specArr.length; + this.suiteService.setCurrentRunningSuiteDesc(this.suiteService.getRootSuite(), this.suiteService.getCurrentRunningSuite(), ''); + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: class=` + this.suiteService.getCurrentRunningSuiteDesc() + '\n'; + if (this.suiteService.currentRunningSuite.isSkip) { + message += `${PrintTag.OHOS_REPORT_STATUS}: skipReason=` + this.suiteService.currentRunningSuite.skipReason + '\n'; + } + if (SysTestKit.workerPort !== null) { + message += `${PrintTag.OHOS_REPORT_STATUS}: currentWorkerName=` + this.currentThreadName; + } + console.info(`${message}`); + await SysTestKit.print(message); + console.info(`${TAG}${this.suiteService.getCurrentRunningSuite().description} suiteStart print success`); + } + } + + async suiteDone() { + if (this.abilityDelegatorArguments !== null) { + const currentRunningSuite = this.suiteService.getCurrentRunningSuite(); + this.suiteService.setCurrentRunningSuiteDesc(this.suiteService.getRootSuite(), currentRunningSuite, ''); + let message = '\n' + `${PrintTag.OHOS_REPORT_STATUS}: class=` + this.suiteService.getCurrentRunningSuiteDesc(); + if (this.suiteService.currentRunningSuite.isSkip && this.suiteService.currentRunningSuite.skipReason !== '') { + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: skipReason=` + this.suiteService.currentRunningSuite.skipReason; + } + const isPromiseError = currentRunningSuite.isPromiseError; + if (isPromiseError) { + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: shortMsg=Promise(async, await) in describe is not allowed!`; + } + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: suiteconsuming=` + currentRunningSuite.duration; + if (currentRunningSuite.hookError) { + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: ${currentRunningSuite.hookError.message}`; + } + message += '\n'; + if (SysTestKit.workerPort !== null) { + message += `${PrintTag.OHOS_REPORT_STATUS}: currentWorkerName=` + this.currentThreadName; + } + console.info(`${message}`); + await SysTestKit.print(message); + console.info(`${TAG}${currentRunningSuite.description} suiteDone print success`); + } + } + + async specStart() { + if (this.abilityDelegatorArguments !== null) { + let message = '\n' + `${PrintTag.OHOS_REPORT_STATUS}: class=` + this.suiteService.getCurrentRunningSuiteDesc(); + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: current=` + (++this.index); + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: id=JS`; + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: numtests=` + this.specService.getTestTotal(); + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: stream=`; + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: test=` + this.specService.currentRunningSpec.description; + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS_CODE}: 1` + '\n'; + if (this.specService.currentRunningSpec.isSkip) { + message += `${PrintTag.OHOS_REPORT_STATUS}: skipReason=` + this.specService.currentRunningSpec.skipReason + '\n'; + } + if (SysTestKit.workerPort !== null) { + message += `${PrintTag.OHOS_REPORT_STATUS}: currentWorkerName=` + this.currentThreadName; + } + console.info(`${message}`); + await SysTestKit.print(message); + console.info(`${TAG}${this.specService.currentRunningSpec.description} specStart start print success`); + } + } + + async specDone() { + if (this.abilityDelegatorArguments !== null) { + let message = '\n' + `${PrintTag.OHOS_REPORT_STATUS}: class=` + this.suiteService.getCurrentRunningSuiteDesc(); + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: current=` + (this.index); + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: id=JS`; + message += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: numtests=` + this.specService.getTestTotal(); + let messageStack = ''; + let messageCode = ''; + if (this.specService.currentRunningSpec.error) { + messageStack = `${PrintTag.OHOS_REPORT_STATUS}: stack=` + this.specService.currentRunningSpec.error?.stack?.slice(0, -1); + messageCode += `${PrintTag.OHOS_REPORT_STATUS}: stream=`; + messageCode += this.specService.currentRunningSpec.expectMsg !== '' ? + `message: ${this.specService.currentRunningSpec.expectMsg}, Error in ${this.specService.currentRunningSpec.description}, ${this.specService.currentRunningSpec.error?.message}` : + `Error in ${this.specService.currentRunningSpec.description}, ${this.specService.currentRunningSpec.error?.message}`; + messageCode += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: test=` + this.specService.currentRunningSpec.description; + messageCode += '\n' + `${PrintTag.OHOS_REPORT_STATUS_CODE}: -1` + '\n'; + } else if (this.specService.currentRunningSpec) { + if (this.specService.currentRunningSpec.fail) { + messageStack += `${PrintTag.OHOS_REPORT_STATUS}: stack=` + this.specService.currentRunningSpec.fail?.stack?.slice(0, -1); + messageCode += `${PrintTag.OHOS_REPORT_STATUS}: stream=`; + messageCode += this.specService.currentRunningSpec.expectMsg !== '' ? + `message: ${this.specService.currentRunningSpec.expectMsg}, Error in ${this.specService.currentRunningSpec.description}, ${this.specService.currentRunningSpec.fail?.message}` : + `Error in ${this.specService.currentRunningSpec.description}, ${this.specService.currentRunningSpec.fail?.message}`; + messageCode += '\n' + `${PrintTag.OHOS_REPORT_STATUS}: test=` + this.specService.currentRunningSpec.description; + messageCode += '\n' + `${PrintTag.OHOS_REPORT_STATUS_CODE}: -2` + '\n'; + } else { + messageStack += `${PrintTag.OHOS_REPORT_STATUS}: stream=`; + messageCode += `${PrintTag.OHOS_REPORT_STATUS}: test=` + this.specService.currentRunningSpec.description; + messageCode += '\n' + `${PrintTag.OHOS_REPORT_STATUS_CODE}: 0` + '\n'; + messageCode += this.specService.currentRunningSpec.isSkip ? (`${PrintTag.OHOS_REPORT_STATUS}: skipReason=` + this.specService.currentRunningSpec.skipReason + '\n') : ''; + } + } else { + messageCode += '\n'; + } + messageCode += `${PrintTag.OHOS_REPORT_STATUS}: consuming=` + this.specService.currentRunningSpec.duration + '\n'; + if (SysTestKit.workerPort !== null) { + messageCode += `${PrintTag.OHOS_REPORT_STATUS}: currentWorkerName=` + this.currentThreadName; + } + console.info(`${message}`); + console.info(`\n${messageStack}`); + console.info(`\n${messageCode}`); + await SysTestKit.print(message); + await SysTestKit.print(messageStack); + await SysTestKit.print(messageCode); + console.info(`${TAG}${this.specService.currentRunningSpec.description} specDone end print success`); + } + } +} + +export default OhReport; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/ReportExtend.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/ReportExtend.js new file mode 100644 index 0000000..e973388 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/module/report/ReportExtend.js @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +class ReportExtend { + constructor(fileModule) { + this.id = 'extend'; + this.fileModule = fileModule; + } + + init(coreContext) { + this.coreContext = coreContext; + this.suiteService = this.coreContext.getDefaultService('suite'); + } + + taskStart() { + + } + + handleSpecs(specs, report, suiteReport, testsuite) { + for (let testcase of specs) { + report.tests++; + suiteReport.tests++; + let caseReport = { + tag: 'testcase', + name: testcase.description, + status: 'run', + time: '0.0', + classname: testsuite.description + }; + if (testcase.error) { + caseReport.result = false; + caseReport.children = [{ + tag: 'error', + type: '', + message: testcase.error.message + }]; + report.errors++; + suiteReport.errors++; + } else if (testcase.result.failExpects.length > 0) { + caseReport.result = false; + let message = ''; + testcase.result.failExpects.forEach(failExpect => { + message += failExpect.message || ('expect ' + failExpect.actualValue + ' ' + failExpect.checkFunc + ' ' + (failExpect.expectValue || '')) + ';'; + }); + caseReport.children = [{ + tag: 'failure', + type: '', + message: message + }]; + report.failures++; + suiteReport.failures++; + } else { + caseReport.result = true; + } + suiteReport.children.push(caseReport); + } + } + + taskDone() { + const report = { + tag: 'testsuites', + name: 'summary_report', + timestamp: new Date().toDateString(), + time: '1', + errors: 0, + failures: 0, + tests: 0, + children: [] + }; + const rootSuite = this.suiteService.rootSuite; + if (rootSuite && rootSuite.childSuites) { + for (let testsuite of rootSuite.childSuites) { + let suiteReport = { + tag: 'testsuite', + name: testsuite['description'], + errors: 0, + tests: 0, + failures: 0, + time: '0.1', + children: [] + }; + let specs = testsuite['specs']; + this.handleSpecs(specs, report, suiteReport, testsuite); + report.children.push(suiteReport); + } + } + + writeXmlReport(report); + } +} + +function writeXmlReport(report) { + let reportXml = '\n' + json2xml(report); + this.fileModule.writeText({ + uri: 'internal://app/report.xml', + text: reportXml, + success: function () { + console.info('call success callback success'); + }, + fail: function (data, code) { + console.info('call fail callback success:'); + }, + complete: function () { + console.info('call complete callback success'); + } + }); +} + +function handleChild(json, key, hasChildren, childrenStr) { + if (json[key].length > 0) { + hasChildren = true; + for (let child of json[key]) { + childrenStr += json2xml(child); + } + } +} + +function json2xml(json) { + let tagName; + let hasChildren = false; + let childrenStr = ''; + let attrStr = ''; + for (let key in json) { + if (key === 'tag') { + tagName = json[key]; + } else if (key === 'children') { + handleChild(json, key, hasChildren, childrenStr); + } else { + attrStr += ` ${key}="${json[key]}"`; + } + } + let xml = `<${tagName}${attrStr}`; + xml += hasChildren ? `>${childrenStr}` : '/>'; + return xml; +} + +export default ReportExtend; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/service.js b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/service.js new file mode 100644 index 0000000..9b711aa --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/service.js @@ -0,0 +1,1265 @@ +/* + * Copyright (c) 2021-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import SysTestKit from './module/kit/SysTestKit'; +import { TAG } from './Constant'; +import LogExpectError from './module/report/LogExpectError'; +import { NestFilter } from './module/config/Filter'; + +function assertTrueFun(actualValue) { + let result = { + pass: (actualValue) === true, + message: 'expect true, actualValue is ' + actualValue + }; + return result; +} + +function assertEqualFun(actualValue, args) { + let msg = 'expect ' + actualValue + ' equals ' + args[0]; + if (actualValue === args[0]) { // 数值相同,提示数据类型 + const aClassName = Object.prototype.toString.call(actualValue); + const bClassName = Object.prototype.toString.call(args[0]); + msg = 'expect ' + actualValue + aClassName + ' equals ' + args[0] + bClassName + 'strict mode inspect type'; + } + let result = { + pass: (actualValue) === args[0], + expectValue: args[0], + message: msg + }; + return result; +} + +function assertThrowFun(actual, args) { + const result = { + pass: false + }; + if (typeof actual !== 'function') { + result.message = 'toThrow\'s Actual should be a Function'; + } else { + let hasThrow = false; + let throwError; + try { + actual(); + } catch (e) { + hasThrow = true; + throwError = e; + } + if (!hasThrow) { + result.message = 'function did not throw an exception'; + } else if (throwError && throwError.message === args[0]) { + result.pass = true; + } else { + result.message = `expect to throw ${args[0]} , actual throw ${throwError.message}`; + } + } + return result; +} + +class AssertException extends Error { + constructor(message) { + super(); + this.name = 'AssertException'; + this.message = message; + } +} + +function getFuncWithArgsZero(func, timeout, isStressTest) { + return new Promise(async (resolve, reject) => { + let timer = null; + if (!isStressTest) { + timer = setTimeout(() => { + reject(new Error('execute timeout ' + timeout + 'ms')); + }, timeout); + } + try { + await func(); + } catch (err) { + reject(err); + } + timer !== null ? clearTimeout(timer) : null; + resolve(); + }); +} + +function getFuncWithArgsOne(func, timeout, isStressTest) { + return new Promise(async (resolve, reject) => { + let timer = null; + if (!isStressTest) { + timer = setTimeout(() => { + reject(new Error('execute timeout ' + timeout + 'ms')); + }, timeout); + } + + function done() { + timer !== null ? clearTimeout(timer) : null; + resolve(); + } + + try { + await func(done); + } catch (err) { + timer !== null ? clearTimeout(timer) : null; + reject(err); + } + }); +} + +function getFuncWithArgsTwo(func, timeout, paramItem, isStressTest) { + return new Promise(async (resolve, reject) => { + let timer = null; + if (!isStressTest) { + timer = setTimeout(() => { + reject(new Error('execute timeout ' + timeout + 'ms')); + }, timeout); + } + + function done() { + timer !== null ? clearTimeout(timer) : null; + resolve(); + } + + try { + await func(done, paramItem); + } catch (err) { + timer !== null ? clearTimeout(timer) : null; + reject(err); + } + }); +} + +function processFunc(coreContext, func) { + let argNames = ((func || '').toString() + .replace(/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg, '') + .match(/^(function)?\s*[^\(]*\(\s*([^\)]*)\)/m) || ['', '', ''])[2] + .split(',') // split parameters + .map(item => item.replace(/^\s*(_?)(.+?)\1\s*$/, name => name.split('=')[0].trim())) + .filter(String); + let funcLen = func.length; + let processedFunc; + const config = coreContext.getDefaultService('config'); + config.setSupportAsync(true); + const timeout = + (config.timeout === undefined ? 5000 : config.timeout); + const isStressTest = (coreContext.getServices('dataDriver') !== undefined || config.getStress() > 1); + switch (funcLen) { + case 0: { + processedFunc = function () { + return getFuncWithArgsZero(func, timeout, isStressTest); + }; + break; + } + case 1: { + processedFunc = function () { + return getFuncWithArgsOne(func, timeout, isStressTest); + }; + break; + } + default: { + processedFunc = function (paramItem) { + return getFuncWithArgsTwo(func, timeout, paramItem, isStressTest); + }; + break; + } + } + return processedFunc; +} + +function secureRandomNumber() { + return crypto.randomBytes(8).readUInt32LE() / 0xffffffff; +} + + + +class SuiteService { + constructor(attr) { + this.id = attr.id; + this.rootSuite = new SuiteService.Suite({}); + this.currentRunningSuite = this.rootSuite; + this.suitesStack = [this.rootSuite]; + this.targetSuiteArray = []; + this.targetSpecArray = []; + this.currentRunningSuiteDesc = null; + this.fullRun = false; + this.isSkipSuite = false; + this.suiteSkipReason = null; + } + + describe(desc, func) { + const configService = this.coreContext.getDefaultService('config'); + if (this.suitesStack.some(suite => { return suite.description === desc })) { + console.error(`${TAG} Loop nesting occurs : ${desc}`); + this.suiteSkipReason = ''; + this.isSkipSuite = false; + return; + } + let isFilter = this.analyzeConfigServiceClass(configService.class, desc); + if (configService.filterSuite(desc) && isFilter) { + if (this.currentRunningSuite.description === '' || this.currentRunningSuite.description == null) { + console.info(`${TAG}filter suite : ${desc}`); + this.suiteSkipReason = ''; + this.isSkipSuite = false; + return; + } + } + const suite = new SuiteService.Suite({ description: desc }); + if (this.isSkipSuite) { + suite.isSkip = true; + suite.skipReason = this.suiteSkipReason; + } + this.suiteSkipReason = ''; + this.isSkipSuite = false; + if (typeof this.coreContext.getServices('dataDriver') !== 'undefined' && configService['dryRun'] !== 'true') { + let suiteStress = this.coreContext.getServices('dataDriver').dataDriver.getSuiteStress(desc); + for (let i = 1; i < suiteStress; i++) { + this.currentRunningSuite.childSuites.push(suite); + } + } + this.currentRunningSuite.childSuites.push(suite); + this.currentRunningSuite = suite; + this.suitesStack.push(suite); + const res = func.call(); + if (Object.prototype.toString.call(res) === '[object Promise]') { + suite.isPromiseError = true; + } + this.suitesStack.pop(); + this.currentRunningSuite = this.suitesStack.pop(); + this.suitesStack.push(this.currentRunningSuite); + } + xdescribe(desc, func, reason) { + const configService = this.coreContext.getDefaultService('config'); + if (!configService.skipMessage && configService.runSkipped !== 'all') { + if (configService.runSkipped != null && configService.runSkipped !== '') { + let finalDesc = ''; + this.suitesStack.map(suite => { + finalDesc = finalDesc + '.' + suite.description; + }); + finalDesc = (finalDesc + '.' + desc).substring(2); + console.info(`${TAG} finalDesc ${finalDesc}`); + if (configService.checkIfSuiteInSkipRun(finalDesc)) { + console.info(`${TAG} runSkipped suite: ${desc}`); + } else { + console.info(reason == null ? `${TAG} skip suite: ${desc}` : `${TAG} skip suite: ${desc}, and the reason is ${reason}`); + return; + } + } else { + console.info(reason == null ? `${TAG} skip suite: ${desc}` : `${TAG} skip suite: ${desc}, and the reason is ${reason}`); + return; + } + } + this.isSkipSuite = true; + this.suiteSkipReason = reason; + this.describe(desc, func); + } + + beforeAll(func) { + this.currentRunningSuite.beforeAll.push(processFunc(this.coreContext, func)); + } + + beforeEach(func) { + this.currentRunningSuite.beforeEach.push(processFunc(this.coreContext, func)); + } + + beforeItSpecified(itDescs, func) { + this.currentRunningSuite.beforeItSpecified.set(itDescs, processFunc(this.coreContext, func)); + } + + afterItSpecified(itDescs, func) { + this.currentRunningSuite.afterItSpecified.set(itDescs, processFunc(this.coreContext, func)); + } + + afterAll(func) { + this.currentRunningSuite.afterAll.push(processFunc(this.coreContext, func)); + } + + afterEach(func) { + this.currentRunningSuite.afterEach.push(processFunc(this.coreContext, func)); + } + + getCurrentRunningSuite() { + return this.currentRunningSuite; + } + + setCurrentRunningSuite(suite) { + this.currentRunningSuite = suite; + } + + getRootSuite() { + return this.rootSuite; + } + + getCurrentRunningSuiteDesc() { + return this.currentRunningSuiteDesc; + } + + + setCurrentRunningSuiteDesc(suite, currentSuite, prefix) { + if (suite != null && suite === currentSuite) { + this.currentRunningSuiteDesc = prefix; + } else if (suite != null && suite !== currentSuite) { + suite.childSuites.forEach(it => { + let temp = prefix; + if (it.description != null || it.description !== '') { + temp = prefix === '' ? it.description : prefix + '.' + it.description; + } + this.setCurrentRunningSuiteDesc(it, currentSuite, temp); + } + ); + } + } + analyzeConfigServiceClass(configServiceClass, desc) { + if (configServiceClass == null || configServiceClass === '') { + this.fullRun = true; + return false; + } + const targetArray = configServiceClass.split(',').map(item => item.trim()).filter(item => item !== ''); + if (this.targetSuiteArray.length === 0) { + for (let index in targetArray) { + if (targetArray[index].includes('#')) { + this.targetSpecArray.push(targetArray[index]); + } else { + this.targetSuiteArray.push(targetArray[index]); + } + } + + } + return targetArray.indexOf(desc) === -1; + + } + traversalResults(suite, obj, breakOnError) { + if (suite.childSuites.length === 0 && suite.specs.length === 0) { + return; + } + if (suite.specs.length > 0) { + for (const itItem of suite.specs) { + obj.total++; + let itInfo = { + currentThreadName: 'mainThread', + description: suite.description + '#' + itItem.description, + result: -3 + }; + if (SysTestKit.workerPort !== null) { + itInfo.currentThreadName = SysTestKit.workerPort.name; + } + obj.itItemList.push(itInfo); + if (breakOnError && (obj.error > 0 || obj.failure > 0)) { // breakOnError模式 + continue; + } + if (itItem.error) { + obj.error++; + itInfo.result = -1; + } else if (itItem.fail) { + obj.failure++; + itInfo.result = -2; + } else if (itItem.pass === true) { + obj.pass++; + itInfo.result = 0; + } + } + } + + obj.duration += suite.duration; + + if (suite.childSuites.length > 0) { + for (const suiteItem of suite.childSuites) { + this.traversalResults(suiteItem, obj, breakOnError); + } + } + + } + + async setSuiteResults(suite, error, coreContext) { + if (suite.childSuites.length === 0 && suite.specs.length === 0) { + return; + } + if (suite.specs.length > 0) { + const specService = coreContext.getDefaultService('spec'); + for (const specItem of suite.specs) { + specService.setCurrentRunningSpec(specItem); + if (error instanceof AssertException) { + specItem.fail = error; + } else { + specItem.error = error; + } + await coreContext.fireEvents('spec', 'specStart', specItem); + await coreContext.fireEvents('spec', 'specDone', specItem); + } + } + if (suite.childSuites.length > 0) { + for (const suiteItem of suite.childSuites) { + await this.setSuiteResults(suiteItem, error, coreContext); + } + } + } + + getSummary() { + let suiteService = this.coreContext.getDefaultService('suite'); + let rootSuite = suiteService.rootSuite; + const specService = this.coreContext.getDefaultService('spec'); + const configService = this.coreContext.getDefaultService('config'); + let breakOnError = configService.isBreakOnError(); + let isError = specService.getStatus(); + let isBreaKOnError = breakOnError && isError; + // itItemList 保存当前用例执行情况, 发送到主线程用例计算最终结果 + let obj = { total: 0, failure: 0, error: 0, pass: 0, ignore: 0, duration: 0, itItemList: []}; + for (const suiteItem of rootSuite.childSuites) { + this.traversalResults(suiteItem, obj, isBreaKOnError); + } + obj.ignore = obj.total - obj.pass - obj.failure - obj.error; + return obj; + } + + init(coreContext) { + this.coreContext = coreContext; + } + + traversalSuites(suite, obj, configService) { + if (suite.childSuites.length === 0 && suite.specs.length === 0) { + return []; + } + if (suite.specs.length > 0) { + let itArray = []; + for (const itItem of suite['specs']) { + if (!configService.filterDesc(suite.description, itItem.description, itItem.fi, null)) { + itArray.push({ 'itName': itItem.description }); + } + } + obj[suite.description] = itArray; + } + if (suite.childSuites.length > 0) { + let suiteArray = []; + for (const suiteItem of suite.childSuites) { + let suiteObj = {}; + this.traversalSuites(suiteItem, suiteObj, configService); + if (!configService.filterSuite(suiteItem.description)) { + suiteArray.push(suiteObj); + } + } + obj.suites = suiteArray; + } + } + + async dryRun(abilityDelegator) { + console.info(`${TAG} rootSuite : ` + JSON.stringify(this.rootSuite)); + let obj = this.rootSuite; + let prefixStack = []; + let suiteArray = []; + let skipSuiteArray = []; + this.analyzeSuitesArray(prefixStack, suiteArray, skipSuiteArray, obj); + const configService = this.coreContext.getDefaultService('config'); + let result; + if (configService.skipMessage) { + result = { 'suites': suiteArray, 'skipSuites': skipSuiteArray }; + } else { + result = { 'suites': suiteArray }; + } + let strJson = JSON.stringify(result); + let strLen = strJson.length; + let maxLen = 500; + let maxCount = Math.floor(strLen / maxLen); + for (let count = 0; count <= maxCount; count++) { + await SysTestKit.print(strJson.substring(count * maxLen, (count + 1) * maxLen)); + } + console.info(`${TAG}dryRun print success`); + abilityDelegator.finishTest('dry run finished!!!', 0, () => { }); + } + + //将suitesArray的嵌套结构展开成三层结构 + analyzeSuitesArray(prefixStack, suiteArray, skipSuiteArray, obj) { + obj.childSuites.map(suite => { + if (suite.description != null && suite.description !== '') { + let prefix = ''; + if (prefixStack.length > 0) { + prefix = prefixStack.join('.') + '.' + suite.description; + } else { + prefix = suite.description; + } + prefixStack.push(suite.description); + let temp = {}; + temp[prefix] = []; + let skipTemp = {}; + skipTemp[prefix] = []; + suite.specs.map(spec => { + let it = { 'itName': spec.description }; + spec.isSkip ? skipTemp[prefix].push(it) : temp[prefix].push(it); + }); + suiteArray.push(temp); + skipSuiteArray.push(skipTemp); + } + this.analyzeSuitesArray(prefixStack, suiteArray, skipSuiteArray, suite); + prefixStack.pop(); + }); + } + //获取当前测试套下的所有测试用例数量 + getAllChildSuiteNum(suite, specArray) { + if (suite.specs != null) { + suite.specs.forEach(spec => specArray.push(spec)); + } + if (suite.childSuites != null) { + suite.childSuites.forEach(it => this.getAllChildSuiteNum(it, specArray)); + } + } + + execute() { + const configService = this.coreContext.getDefaultService('config'); + if (configService.filterValid.length !== 0) { + this.coreContext.fireEvents('task', 'incorrectFormat'); + return; + } + if (configService.filterXdescribe.length !== 0) { + this.coreContext.fireEvents('task', 'incorrectTestSuiteFormat'); + return; + } + if (configService.isRandom() && this.rootSuite.childSuites.length > 0) { + this.rootSuite.childSuites.sort(function () { + return +('0.' + (+ new Date() + '').split('').reverse().join('')) > 0.5 ? -1 : 1; + }); + this.currentRunningSuite = this.rootSuite.childSuites[0]; + } + if (configService.isSupportAsync()) { + console.info(`${TAG} rootSuite:` + JSON.stringify(this.rootSuite)); + let asyncExecute = async () => { + await this.coreContext.fireEvents('task', 'taskStart'); + await this.rootSuite.asyncRun(this.coreContext); + }; + asyncExecute().then(async () => { + await this.coreContext.fireEvents('task', 'taskDone'); + }); + } else { + console.info('${TAG} rootSuite:' + JSON.stringify(this.rootSuite)); + this.coreContext.fireEvents('task', 'taskStart'); + this.rootSuite.run(this.coreContext); + this.coreContext.fireEvents('task', 'taskDone'); + } + } + + apis() { + const _this = this; + return { + describe: function (desc, func) { + return _this.describe(desc, func); + }, + xdescribe: function (desc, func, reason) { + return _this.xdescribe(desc, func, reason); + }, + beforeItSpecified: function (itDescs, func) { + return _this.beforeItSpecified(itDescs, func); + }, + afterItSpecified: function (itDescs, func) { + return _this.afterItSpecified(itDescs, func); + }, + beforeAll: function (func) { + return _this.beforeAll(func); + }, + beforeEach: function (func) { + return _this.beforeEach(func); + }, + afterAll: function (func) { + return _this.afterAll(func); + }, + afterEach: function (func) { + return _this.afterEach(func); + } + }; + } +} + +SuiteService.Suite = class { + constructor(attrs) { + this.description = attrs.description || ''; + this.childSuites = []; + this.specs = []; + this.beforeAll = []; + this.afterAll = []; + this.beforeItSpecified = new Map(); + this.afterItSpecified = new Map(); + this.beforeEach = []; + this.afterEach = []; + this.duration = 0; + this.hookError = null; + this.isSkip = false; + this.skipReason = ''; + } + + pushSpec(spec) { + this.specs.push(spec); + } + + removeSpec(desc) { + this.specs = this.specs.filter((item, index) => { + return item.description !== desc; + }); + } + + getSpecsNum() { + return this.specs.length; + } + + isRun(coreContext) { + const configService = coreContext.getDefaultService('config'); + const suiteService = coreContext.getDefaultService('suite'); + const specService = coreContext.getDefaultService('spec'); + let breakOnError = configService.isBreakOnError(); + let isError = specService.getStatus(); + return breakOnError && isError; + } + + run(coreContext) { + const suiteService = coreContext.getDefaultService('suite'); + suiteService.setCurrentRunningSuite(this); + if (this.description !== '') { + coreContext.fireEvents('suite', 'suiteStart', this); + } + this.runHookFunc('beforeAll'); + if (this.specs.length > 0) { + const configService = coreContext.getDefaultService('config'); + if (configService.isRandom()) { + this.specs.sort(function () { + return +('0.' + (+ new Date() + '').split('').reverse().join('')) > 0.5 ? -1 : 1; + }); + } + for (let spec in this.specs) { + let isBreakOnError = this.isRun(coreContext); + if (isBreakOnError) { + break; + } + this.runHookFunc('beforeEach'); + spec.run(coreContext); + this.runHookFunc('afterEach'); + } + } + if (this.childSuites.length > 0) { + for (let suite in this.childSuites) { + let isBreakOnError = this.isRun(coreContext); + if (isBreakOnError) { + break; + } + suite.run(coreContext); + suiteService.setCurrentRunningSuite(suite); + } + } + this.runHookFunc('afterAll'); + if (this.description !== '') { + coreContext.fireEvents('suite', 'suiteDone'); + } + } + + async runBeforeItSpecified(beforeItSpecified, specItem) { + for (const [itNames, hookFunc] of beforeItSpecified) { + if ((Object.prototype.toString.call(itNames) === '[object Array]' && itNames.includes(specItem.description)) || + (Object.prototype.toString.call(itNames) === '[object String]' && itNames === specItem.description)) { + await Reflect.apply(hookFunc, null, []); + } + break; + } + } + + async runAfterItSpecified(beforeItSpecified, specItem) { + for (const [itNames, hookFunc] of beforeItSpecified) { + if ((Object.prototype.toString.call(itNames) === '[object Array]' && itNames.includes(specItem.description)) || + (Object.prototype.toString.call(itNames) === '[object String]' && itNames === specItem.description)) { + await Reflect.apply(hookFunc, null, []); + } + break; + } + } + + async asyncRunSpecs(coreContext) { + const configService = coreContext.getDefaultService('config'); + if (configService.isRandom()) { + this.specs.sort(function () { + return +('0.' + (+ new Date() + '').split('').reverse().join('')) > 0.5 ? -1 : 1; + }); + } + const specService = coreContext.getDefaultService('spec'); + for (let specItem of this.specs) { + specService.setCurrentRunningSpec(specItem); + // 遇错即停模式,发现用例有问题,直接返回,不在执行后面的it + let isBreakOnError = this.isRun(coreContext); + if (isBreakOnError) { + console.info('break description :' + this.description); + break; + } + await coreContext.fireEvents('spec', 'specStart', specItem); + try { + await this.runBeforeItSpecified(this.beforeItSpecified, specItem); + await this.runAsyncHookFunc('beforeEach'); + await specItem.asyncRun(coreContext); + await this.runAfterItSpecified(this.afterItSpecified, specItem); + await this.runAsyncHookFunc('afterEach'); + } catch (e) { + console.error(`${TAG}stack:${e?.stack}`); + console.error(`${TAG}stack end`); + if (e instanceof AssertException) { + specItem.fail = e; + } else { + specItem.error = e; + } + specService.setStatus(true); + } + specItem.setResult(); + await coreContext.fireEvents('spec', 'specDone', specItem); + specService.setCurrentRunningSpec(null); + } + } + + async asyncRunChildSuites(coreContext) { + for (let i = 0; i < this.childSuites.length; i++) { + // 遇错即停模式, 发现用例有问题,直接返回,不在执行后面的description + let isBreakOnError = this.isRun(coreContext); + if (isBreakOnError) { + console.info(`${TAG}break description : ${this.description}`); + break; + } + await this.childSuites[i].asyncRun(coreContext); + } + } + + async asyncRun(coreContext) { + const suiteService = coreContext.getDefaultService('suite'); + const specService = coreContext.getDefaultService('spec'); + + suiteService.setCurrentRunningSuite(this); + suiteService.suitesStack.push(this); + if (this.description !== '') { + await coreContext.fireEvents('suite', 'suiteStart', this); + } + + try { + await this.runAsyncHookFunc('beforeAll'); + } catch (error) { + console.error(`${TAG}${error?.stack}`); + this.hookError = error; + } + + if (this.hookError !== null) { + specService.setStatus(true); + await suiteService.setSuiteResults(this, this.hookError, coreContext); + } + + if (this.specs.length > 0 && this.hookError === null) { + await this.asyncRunSpecs(coreContext); + } + + if (this.childSuites.length > 0 && this.hookError === null) { + await this.asyncRunChildSuites(coreContext); + } + + try { + await this.runAsyncHookFunc('afterAll'); + } catch (error) { + console.error(`${TAG}${error?.stack}`); + this.hookError = error; + specService.setStatus(true); + } + + if (this.description !== '') { + await coreContext.fireEvents('suite', 'suiteDone'); + let childSuite = suiteService.suitesStack.pop(); + let currentRunningSuite = suiteService.suitesStack.pop(); + suiteService.setCurrentRunningSuite(currentRunningSuite); + suiteService.suitesStack.push(currentRunningSuite); + } + } + + runHookFunc(hookName) { + if (this[hookName] && this[hookName].length > 0) { + this[hookName].forEach(func => { + try { + func(); + } catch (e) { + console.error(`${TAG}${e.stack}`); + } + }); + } + } + + async runAsyncHookFunc(hookName) { + for (const hookItem of this[hookName]) { + try { + await hookItem(); + } catch (error) { + error['message'] += `, error in ${hookName} function`; + throw error; + } + + } + } +}; + +class SpecService { + constructor(attr) { + this.id = attr.id; + this.totalTest = 0; + this.hasError = false; + this.skipSpecNum = 0; + this.isSkipSpec = false; + this.specSkipReason = ''; + } + + init(coreContext) { + this.coreContext = coreContext; + } + + setCurrentRunningSpec(spec) { + this.currentRunningSpec = spec; + } + + setStatus(obj) { + this.hasError = obj; + } + + getStatus() { + return this.hasError; + } + + getTestTotal() { + return this.totalTest; + } + + getCurrentRunningSpec() { + return this.currentRunningSpec; + } + + + getSkipSpecNum() { + return this.skipSpecNum; + } + + initSpecService() { + this.isSkipSpec = false; + this.specSkipReason = ''; + } + + it(desc, filter, func) { + const suiteService = this.coreContext.getDefaultService('suite'); + const configService = this.coreContext.getDefaultService('config'); + let isFilter = new NestFilter().filterNestName(suiteService.targetSuiteArray, suiteService.targetSpecArray, suiteService.suitesStack, desc); + if (configService.filterWithNest(desc, filter)) { + console.info(`${TAG}filter it :${desc}`); + this.initSpecService(); + return; + } + if (configService.filterDesc(suiteService.currentRunningSuite.description, desc, filter, this.coreContext) && isFilter && !suiteService.fullRun) { + console.info(`${TAG}filter it :${desc}`); + this.initSpecService(); + } else { + let processedFunc = processFunc(this.coreContext, func); + const spec = new SpecService.Spec({ description: desc, fi: filter, fn: processedFunc }); + if (this.isSkipSpec) { + spec.isSkip = true; + spec.skipReason = this.specSkipReason; + } + this.initSpecService(); + if (configService.runSkipped === 'skipped' && !spec.isSkip) { + console.info(`${TAG} runSkipped is skipped , just run xit, don't run it: ${spec.description}`); + return; + } + if (suiteService.getCurrentRunningSuite().isSkip && !spec.isSkip) { + configService.filterXdescribe.push(suiteService.getCurrentRunningSuite().description); + } + if (typeof this.coreContext.getServices('dataDriver') !== 'undefined' && configService['dryRun'] !== 'true') { + let specStress = this.coreContext.getServices('dataDriver').dataDriver.getSpecStress(desc); + for (let i = 1; i < specStress; i++) { + this.totalTest++; + suiteService.getCurrentRunningSuite().pushSpec(spec); + } + } + // dryRun 状态下不统计压力测试重复数据 + if (configService['dryRun'] !== 'true') { + let stress = configService.getStress(); // 命令配置压力测试 + console.info(`${TAG}stress length : ${stress}`); + for (let i = 1; i < stress; i++) { + this.totalTest++; + suiteService.getCurrentRunningSuite().pushSpec(spec); + } + } + this.totalTest++; + suiteService.getCurrentRunningSuite().pushSpec(spec); + } + } + + xit(desc, filter, func, reason) { + const configService = this.coreContext.getDefaultService('config'); + const suiteService = this.coreContext.getDefaultService('suite'); + if (!configService.skipMessage && configService.runSkipped !== 'all') { + if (configService.runSkipped != null && configService.runSkipped !== '') { + let finalDesc = ''; + suiteService.suitesStack.map(suite => { + finalDesc = finalDesc + '.' + suite.description; + }); + finalDesc = (finalDesc + '#' + desc).substring(2); + if (configService.checkIfSpecInSkipRun(finalDesc)) { + console.info(`${TAG} runSkipped spec: ${desc}`); + } else { + console.info(reason == null ? `${TAG} skip spec: ${desc}` : `${TAG} skip spec: ${desc}, and the reason is ${reason}`); + return; + } + } else { + console.info(reason == null ? `${TAG} skip spec: ${desc}` : `${TAG} skip spec: ${desc}, and the reason is ${reason}`); + return; + } + } + this.skipSpecNum++; + this.isSkipSpec = true; + this.specSkipReason = reason; + this.it(desc, filter, func); + } + + apis() { + const _this = this; + return { + it: function (desc, filter, func) { + return _this.it(desc, filter, func); + }, + xit: function (desc, filter, func, reason) { + return _this.xit(desc, filter, func, reason); + } + }; + } +} + +SpecService.Spec = class { + constructor(attrs) { + this.description = attrs.description || ''; + this.fi = attrs.fi; + this.fn = attrs.fn || function () { + }; + this.fail = undefined; + this.error = undefined; + this.duration = 0; + this.startTime = 0; + this.isExecuted = false; // 当前用例是否执行 + this.isSkip = false; + this.skipReason = ''; + this.expectMsg = ''; + } + + setResult() { + if (this.fail) { + this.pass = false; + } else { + this.pass = true; + } + } + + run(coreContext) { + const specService = coreContext.getDefaultService('spec'); + specService.setCurrentRunningSpec(this); + coreContext.fireEvents('spec', 'specStart', this); + this.isExecuted = true; + try { + let dataDriver = coreContext.getServices('dataDriver'); + if (typeof dataDriver === 'undefined') { + this.fn(); + } else { + let suiteParams = dataDriver.dataDriver.getSuiteParams(); + let specParams = dataDriver.dataDriver.getSpecParams(); + console.info(`${TAG}[suite params] ${JSON.stringify(suiteParams)}`); + console.info(`${TAG}[spec params] ${JSON.stringify(specParams)}`); + if (this.fn.length === 0) { + this.fn(); + } else if (specParams.length === 0) { + this.fn(suiteParams); + } else { + specParams.forEach(paramItem => this.fn(Object.assign({}, paramItem, suiteParams))); + } + } + this.setResult(); + } catch (e) { + this.error = e; + specService.setStatus(true); + } + coreContext.fireEvents('spec', 'specDone', this); + } + + async asyncRun(coreContext) { + const dataDriver = coreContext.getServices('dataDriver'); + if (typeof dataDriver === 'undefined') { + await this.fn(); + } else { + const suiteParams = dataDriver.dataDriver.getSuiteParams(); + const specParams = dataDriver.dataDriver.getSpecParams(); + console.info(`[suite params] ${JSON.stringify(suiteParams)}`); + console.info(`[spec params] ${JSON.stringify(specParams)}`); + if (this.fn.length === 0) { + await this.fn(); + } else if (specParams.length === 0) { + await this.fn(suiteParams); + } else { + for (const paramItem of specParams) { + await this.fn(Object.assign({}, paramItem, suiteParams)); + } + } + } + + this.isExecuted = true; + } + + filterCheck(coreContext) { + const specService = coreContext.getDefaultService('spec'); + specService.setCurrentRunningSpec(this); + return true; + } +}; + +class ExpectService { + constructor(attr) { + this.id = attr.id; + this.matchers = {}; + this.customMatchers = []; + } + + expect(actualValue) { + return this.wrapMatchers(actualValue); + } + + init(coreContext) { + this.coreContext = coreContext; + this.addMatchers(this.basicMatchers()); + } + + addMatchers(matchers) { + for (const matcherName in matchers) { + if (Object.prototype.hasOwnProperty.call(matchers, matcherName)) { + this.matchers[matcherName] = matchers[matcherName]; + } + } + } + + removeMatchers(customAssertionName) { + if (customAssertionName === 'all') { + for (const matcherName in this.matchers) { + this.matchers[matcherName] = this.customMatchers.includes(matcherName) + ? (() => {throw new Error(`${matcherName} is unregistered`)}) : undefined; + } + } else { + this.matchers[customAssertionName] = () => { + throw new Error(`${customAssertionName} is unregistered`); + }; + } + } + + basicMatchers() { + return { + assertTrue: assertTrueFun, + assertEqual: assertEqualFun, + assertThrow: assertThrowFun + }; + } + + initWrapMatchers(currentRunningSpec) { + return { + // 翻转标识 + isNot: false, + // 翻转方法 + not: function () { + this.isNot = true; + return this; + }, + message: function (msg) { + currentRunningSpec.expectMsg = msg; + console.info(`${TAG} msg: ${msg}`); + return this; + } + }; + + } + + handleWithAssertPromise(_this, wrappedMatchers, matcherName, actualValue, currentRunningSpec, currentRunningSuite) { + wrappedMatchers[matcherName] = async function (...args) { + await _this.matchers[matcherName](actualValue, args).then(function (result) { + if (wrappedMatchers.isNot) { + result.pass = !result.pass; + } + result.actualValue = actualValue; + result.checkFunc = matcherName; + if (!result.pass) { + const assertError = new AssertException(result.message); + currentRunningSpec ? currentRunningSpec.fail = assertError : currentRunningSuite.hookError = assertError; + throw assertError; + } + }); + }; + } + + handleWithoutAssertPromise(_this, wrappedMatchers, matcherName, actualValue, currentRunningSpec, currentRunningSuite) { + wrappedMatchers[matcherName] = function (...args) { + const result = _this.customMatchers.includes(matcherName) + ? _this.matchers[matcherName](actualValue, args[0]) : _this.matchers[matcherName](actualValue, args); + if (wrappedMatchers.isNot) { + result.pass = !result.pass; + result.message = LogExpectError.getErrorMsg(matcherName, actualValue, args[0], result.message); + } + result.actualValue = actualValue; + result.checkFunc = matcherName; + if (!result.pass) { + const assertError = new AssertException(result.message); + currentRunningSpec ? currentRunningSpec.fail = assertError : currentRunningSuite.hookError = assertError; + throw assertError; + } + }; + } + + addAssert(wrappedMatchers, matcherName, actualValue) { + const _this = this; + const specService = _this.coreContext.getDefaultService('spec'); + const currentRunningSpec = specService.getCurrentRunningSpec(); + const currentRunningSuite = _this.coreContext.getDefaultService('suite').getCurrentRunningSuite(); + if (matcherName.search('assertPromise') === 0) { + this.handleWithAssertPromise(_this, wrappedMatchers, matcherName, actualValue, currentRunningSpec, currentRunningSuite); + } else { + this.handleWithoutAssertPromise(_this, wrappedMatchers, matcherName, actualValue, currentRunningSpec, currentRunningSuite); + } + } + + wrapMatchers(actualValue) { + const _this = this; + const specService = _this.coreContext.getDefaultService('spec'); + const currentRunningSpec = specService.getCurrentRunningSpec(); + const wrappedMatchers = this.initWrapMatchers(currentRunningSpec); + const currentRunningSuite = _this.coreContext.getDefaultService('suite').getCurrentRunningSuite(); + for (const matcherName in this.matchers) { + let result = Object.prototype.hasOwnProperty.call(this.matchers, matcherName); + if (!result) { + continue; + } + this.addAssert(wrappedMatchers, matcherName, actualValue); + } + return wrappedMatchers; + } + + apis() { + const _this = this; + return { + expect: function (actualValue) { + return _this.expect(actualValue); + } + }; + } +} + +class ReportService { + constructor(attr) { + this.id = attr.id; + } + + init(coreContext) { + this.coreContext = coreContext; + this.specService = this.coreContext.getDefaultService('spec'); + this.suiteService = this.coreContext.getDefaultService('suite'); + this.duration = 0; + } + + taskStart() { + console.info(`${TAG}[start] start run suites`); + } + + async suiteStart() { + console.info(`${TAG}[suite start]${this.suiteService.getCurrentRunningSuite().description}`); + } + + async specStart() { + console.info(`${TAG}start running case '${this.specService.currentRunningSpec.description}'`); + this.index = this.index + 1; + let spec = this.specService.currentRunningSpec; + spec.startTime = await SysTestKit.getRealTime(); + } + + async specDone() { + let msg = ''; + let spec = this.specService.currentRunningSpec; + let suite = this.suiteService.currentRunningSuite; + spec.duration = await SysTestKit.getRealTime() - spec.startTime; + suite.duration += spec.duration; + if (spec.error) { + this.formatPrint('error', spec.description + ' ; consuming ' + spec.duration + 'ms'); + this.formatPrint('errorDetail', spec.error); + } else if (spec.fail) { + this.formatPrint('fail', spec.description + ' ; consuming ' + spec.duration + 'ms'); + this.formatPrint('failDetail', spec.fail?.message); + } else { + this.formatPrint('pass', spec.description + ' ; consuming ' + spec.duration + 'ms'); + } + this.formatPrint(this.specService.currentRunningSpec.error, msg); + } + + suiteDone() { + let suite = this.suiteService.currentRunningSuite; + let message = suite.hookError ? `, ${suite.hookError?.message}` : ''; + console.info(`[suite end] ${suite.description} consuming ${suite.duration} ms${message}`); + } + + taskDone() { + let msg = ''; + let summary = this.suiteService.getSummary(); + msg = 'total cases:' + summary.total + ';failure ' + summary.failure + ',' + 'error ' + summary.error; + msg += ',pass ' + summary.pass + '; consuming ' + summary.duration + 'ms'; + console.info(`${TAG}${msg}`); + console.info(`${TAG}[end] run suites end`); + } + + incorrectFormat() { + if (this.coreContext.getDefaultService('config').filterValid.length !== 0) { + this.coreContext.getDefaultService('config').filterValid.forEach(function (item) { + console.info(`${TAG}this param ${item} is invalid`); + }); + } + } + + incorrectTestSuiteFormat() { + if (this.coreContext.getDefaultService('config').filterXdescribe.length !== 0) { + this.coreContext.getDefaultService('config').filterXdescribe.forEach(function (item) { + console.info(`${TAG}xdescribe: ${item} should not contain it`); + }); + } + } + + formatPrint(type, msg) { + switch (type) { + case 'pass': + console.info(`${TAG}[pass]${msg}`); + break; + case 'fail': + console.info(`${TAG}[fail]${msg}`); + break; + case 'failDetail': + console.info(`${TAG}[failDetail]${msg}`); + break; + case 'error': + console.info(`${TAG}[error]${msg}`); + break; + case 'errorDetail': + console.info(`${TAG}[errorDetail]${msg}`); + break; + } + } + + sleep(numberMillis) { + var now = new Date(); + var exitTime = now.getTime() + numberMillis; + while (true) { + now = new Date(); + if (now.getTime() > exitTime) { + return; + } + } + } +} + +export { + SuiteService, + SpecService, + ExpectService, + ReportService +}; diff --git a/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/testrunner/OpenHarmonyTestRunner.ts b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/testrunner/OpenHarmonyTestRunner.ts new file mode 100644 index 0000000..a2fe902 --- /dev/null +++ b/oh_modules/.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium/src/main/testrunner/OpenHarmonyTestRunner.ts @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2023-2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { abilityDelegatorRegistry, TestRunner } from '@kit.TestKit'; +import { BusinessError } from '@kit.BasicServicesKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { resourceManager } from '@kit.LocalizationKit'; +import { util } from '@kit.ArkTS'; +import { Hypium } from '@ohos/hypium'; +import testsuite from '../test/List.test'; + +let abilityDelegator: abilityDelegatorRegistry.AbilityDelegator; +let abilityDelegatorArguments: abilityDelegatorRegistry.AbilityDelegatorArgs; +let jsonPath: string = 'mock/mock-config.json'; +let domain: number = 0x0000; //日志标识,0x0000作为测试框架的业务标识 +let tag: string = 'testTag'; //日志标识字符串,作为tag标识当前runner类下的测试行为 + +export default class OpenHarmonyTestRunner implements TestRunner { + constructor() { + } + + onPrepare() { + hilog.info(domain, tag, '%{public}s', 'OpenHarmonyTestRunner OnPrepare'); + } + + async onRun() { + hilog.info(domain, tag, '%{public}s', 'OpenHarmonyTestRunner onRun run'); + abilityDelegatorArguments = abilityDelegatorRegistry.getArguments(); + abilityDelegator = abilityDelegatorRegistry.getAbilityDelegator(); + let moduleName = abilityDelegatorArguments.parameters['-m']; + let context = abilityDelegator.getAppContext().getApplicationContext().createModuleContext(moduleName); + let mResourceManager = context.resourceManager; + await checkMock(abilityDelegator, mResourceManager); + hilog.info(domain, tag, '%{public}s', 'start run testcase!!!'); + Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite); + hilog.info(domain, tag, '%{public}s', 'OpenHarmonyTestRunner onRun end'); + } +} + +async function checkMock(abilityDelegator: abilityDelegatorRegistry.AbilityDelegator, resourceManager: resourceManager.ResourceManager) { + let rawFile: Uint8Array; + try { + rawFile = resourceManager.getRawFileContentSync(jsonPath); + hilog.info(domain, tag, 'MockList file exists'); + let mockStr: string = util.TextDecoder.create("utf-8", { ignoreBOM: true }).decodeWithStream(rawFile); + let mockMap: Record = getMockList(mockStr); + try { + abilityDelegator.setMockList(mockMap); + } catch (error) { + let code = (error as BusinessError).code; + let message = (error as BusinessError).message; + hilog.error(domain, tag, `abilityDelegator.setMockList failed, error code: ${code}, message: ${message}.`); + } + } catch (error) { + let code = (error as BusinessError).code; + let message = (error as BusinessError).message; + hilog.error(domain, tag, `ResourceManager:callback getRawFileContent failed, error code: ${code}, message: ${message}.`); + } +} + +function getMockList(jsonStr: string) { + let jsonObj: Record = JSON.parse(jsonStr); + let map: Map = new Map(Object.entries(jsonObj)); + let mockList: Record = {}; + map.forEach((value: object, key: string) => { + let realValue: string = value['source'].toString(); + mockList[key] = realValue; + }); + hilog.info(domain, tag, '%{public}s', 'mock-json value:' + JSON.stringify(mockList) ?? ''); + return mockList; +} \ No newline at end of file diff --git a/oh_modules/.ohpm/lock.json5 b/oh_modules/.ohpm/lock.json5 new file mode 100644 index 0000000..3956b39 --- /dev/null +++ b/oh_modules/.ohpm/lock.json5 @@ -0,0 +1,200 @@ +{ + "lockVersion": "1.0", + "settings": { + "resolveConflict": true, + "resolveConflictStrict": false, + "installAll": true + }, + "overrides": {}, + "overrideDependencyMap": {}, + "modules": { + ".": { + "name": "", + "dependencies": { + "@ohos/crypto-js": { + "specifier": "^2.0.4", + "version": "2.0.4" + } + }, + "devDependencies": { + "@ohos/hypium": { + "specifier": "1.0.21", + "version": "1.0.21" + }, + "@ohos/hamock": { + "specifier": "1.0.0", + "version": "1.0.0" + } + }, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + }, + "commons/basic": { + "name": "basic", + "dependencies": {}, + "devDependencies": {}, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + }, + "commons/uicomponents": { + "name": "uicomponents", + "dependencies": {}, + "devDependencies": {}, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + }, + "commons/utils": { + "name": "utils", + "dependencies": { + "@ohos/crypto-js": { + "specifier": "^2.0.4", + "version": "2.0.4" + } + }, + "devDependencies": {}, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + }, + "features/Home": { + "name": "Home", + "dependencies": { + "@itcast/basic": { + "specifier": "file:commons/basic", + "version": "file:commons/basic" + } + }, + "devDependencies": {}, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + }, + "features/mypage": { + "name": "mypage", + "dependencies": { + "@itcast/basic": { + "specifier": "file:commons/basic", + "version": "file:commons/basic" + } + }, + "devDependencies": {}, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + }, + "features/register": { + "name": "register", + "dependencies": { + "@itcast/basic": { + "specifier": "file:commons/basic", + "version": "file:commons/basic" + } + }, + "devDependencies": {}, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + }, + "products/expert": { + "name": "default", + "dependencies": { + "@itcast/basic": { + "specifier": "file:commons/basic", + "version": "file:commons/basic" + }, + "utils": { + "specifier": "file:commons/utils", + "version": "file:commons/utils" + }, + "mypage": { + "specifier": "file:features/mypage", + "version": "file:features/mypage" + }, + "home": { + "specifier": "file:features/Home", + "version": "file:features/Home" + }, + "register": { + "specifier": "file:features/register", + "version": "file:features/register" + } + }, + "devDependencies": {}, + "dynamicDependencies": {}, + "maskedByOverrideDependencyMap": false + } + }, + "packages": { + "@ohos/crypto-js@2.0.4": { + "integrity": "sha512-589ur6oqU1UNibqefMly2cwEeEhkSoCAA3uc+oNUwRnYYtevn/kQnO+Coi36N+VJSeeg/uFzZk1K/wUMdovpOA==", + "storePath": "oh_modules/.ohpm/@ohos+crypto-js@2.0.4", + "dependencies": {}, + "dynamicDependencies": {}, + "dev": false, + "dynamic": false, + "maskedByOverrideDependencyMap": false + }, + "@ohos/hypium@1.0.21": { + "integrity": "sha512-iyKGMXxE+9PpCkqEwu0VykN/7hNpb+QOeIuHwkmZnxOpI+dFZt6yhPB7k89EgV1MiSK/ieV/hMjr5Z2mWwRfMQ==", + "storePath": "oh_modules/.ohpm/@ohos+hypium@1.0.21", + "dependencies": {}, + "dynamicDependencies": {}, + "dev": true, + "dynamic": false, + "maskedByOverrideDependencyMap": false + }, + "@ohos/hamock@1.0.0": { + "integrity": "sha512-K6lDPYc6VkKe6ZBNQa9aoG+ZZMiwqfcR/7yAVFSUGIuOAhPvCJAo9+t1fZnpe0dBRBPxj2bxPPbKh69VuyAtDg==", + "storePath": "oh_modules/.ohpm/@ohos+hamock@1.0.0", + "dependencies": {}, + "dynamicDependencies": {}, + "dev": true, + "dynamic": false, + "maskedByOverrideDependencyMap": false + }, + "@itcast/basic@file:commons/basic": { + "storePath": "commons/basic", + "dependencies": {}, + "dynamicDependencies": {}, + "dev": false, + "dynamic": false, + "maskedByOverrideDependencyMap": false + }, + "utils@file:commons/utils": { + "storePath": "commons/utils", + "dependencies": { + "@ohos/crypto-js": "2.0.4" + }, + "dynamicDependencies": {}, + "dev": false, + "dynamic": false, + "maskedByOverrideDependencyMap": false + }, + "mypage@file:features/mypage": { + "storePath": "features/mypage", + "dependencies": { + "@itcast/basic": "commons/basic" + }, + "dynamicDependencies": {}, + "dev": false, + "dynamic": false, + "maskedByOverrideDependencyMap": false + }, + "home@file:features/Home": { + "storePath": "features/Home", + "dependencies": { + "@itcast/basic": "commons/basic" + }, + "dynamicDependencies": {}, + "dev": false, + "dynamic": false, + "maskedByOverrideDependencyMap": false + }, + "register@file:features/register": { + "storePath": "features/register", + "dependencies": { + "@itcast/basic": "commons/basic" + }, + "dynamicDependencies": {}, + "dev": false, + "dynamic": false, + "maskedByOverrideDependencyMap": false + } + } +} \ No newline at end of file diff --git a/oh_modules/.ohpm/oh_modules/@ohos/crypto-js b/oh_modules/.ohpm/oh_modules/@ohos/crypto-js new file mode 120000 index 0000000..728d5f7 --- /dev/null +++ b/oh_modules/.ohpm/oh_modules/@ohos/crypto-js @@ -0,0 +1 @@ +../../@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js \ No newline at end of file diff --git a/oh_modules/.ohpm/oh_modules/@ohos/hamock b/oh_modules/.ohpm/oh_modules/@ohos/hamock new file mode 120000 index 0000000..b4b328a --- /dev/null +++ b/oh_modules/.ohpm/oh_modules/@ohos/hamock @@ -0,0 +1 @@ +../../@ohos+hamock@1.0.0/oh_modules/@ohos/hamock \ No newline at end of file diff --git a/oh_modules/.ohpm/oh_modules/@ohos/hypium b/oh_modules/.ohpm/oh_modules/@ohos/hypium new file mode 120000 index 0000000..1996076 --- /dev/null +++ b/oh_modules/.ohpm/oh_modules/@ohos/hypium @@ -0,0 +1 @@ +../../@ohos+hypium@1.0.21/oh_modules/@ohos/hypium \ No newline at end of file diff --git a/oh_modules/@ohos/crypto-js b/oh_modules/@ohos/crypto-js new file mode 120000 index 0000000..996b8e5 --- /dev/null +++ b/oh_modules/@ohos/crypto-js @@ -0,0 +1 @@ +../.ohpm/@ohos+crypto-js@2.0.4/oh_modules/@ohos/crypto-js \ No newline at end of file diff --git a/oh_modules/@ohos/hamock b/oh_modules/@ohos/hamock new file mode 120000 index 0000000..56a64d0 --- /dev/null +++ b/oh_modules/@ohos/hamock @@ -0,0 +1 @@ +../.ohpm/@ohos+hamock@1.0.0/oh_modules/@ohos/hamock \ No newline at end of file diff --git a/oh_modules/@ohos/hypium b/oh_modules/@ohos/hypium new file mode 120000 index 0000000..eed5762 --- /dev/null +++ b/oh_modules/@ohos/hypium @@ -0,0 +1 @@ +../.ohpm/@ohos+hypium@1.0.21/oh_modules/@ohos/hypium \ No newline at end of file diff --git a/products/expert/.gitignore b/products/expert/.gitignore new file mode 100644 index 0000000..e2713a2 --- /dev/null +++ b/products/expert/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/products/expert/build-profile.json5 b/products/expert/build-profile.json5 new file mode 100644 index 0000000..4d61187 --- /dev/null +++ b/products/expert/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/products/expert/hvigorfile.ts b/products/expert/hvigorfile.ts new file mode 100644 index 0000000..c6edcd9 --- /dev/null +++ b/products/expert/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/products/expert/obfuscation-rules.txt b/products/expert/obfuscation-rules.txt new file mode 100644 index 0000000..272efb6 --- /dev/null +++ b/products/expert/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/products/expert/oh-package-lock.json5 b/products/expert/oh-package-lock.json5 new file mode 100644 index 0000000..31a3a06 --- /dev/null +++ b/products/expert/oh-package-lock.json5 @@ -0,0 +1,66 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@itcast/basic@../../commons/basic": "@itcast/basic@../../commons/basic", + "@ohos/crypto-js@^2.0.4": "@ohos/crypto-js@2.0.4", + "home@../../features/Home": "home@../../features/Home", + "mypage@../../features/mypage": "mypage@../../features/mypage", + "register@../../features/register": "register@../../features/register", + "utils@../../commons/utils": "utils@../../commons/utils" + }, + "packages": { + "@itcast/basic@../../commons/basic": { + "name": "@itcast/basic", + "version": "1.0.0", + "resolved": "../../commons/basic", + "registryType": "local" + }, + "@ohos/crypto-js@2.0.4": { + "name": "@ohos/crypto-js", + "version": "2.0.4", + "integrity": "sha512-589ur6oqU1UNibqefMly2cwEeEhkSoCAA3uc+oNUwRnYYtevn/kQnO+Coi36N+VJSeeg/uFzZk1K/wUMdovpOA==", + "resolved": "https://repo.harmonyos.com/ohpm/@ohos/crypto-js/-/crypto-js-2.0.4.har", + "registryType": "ohpm" + }, + "home@../../features/Home": { + "name": "home", + "version": "1.0.0", + "resolved": "../../features/Home", + "registryType": "local", + "dependencies": { + "@itcast/basic": "file:../../commons/basic" + } + }, + "mypage@../../features/mypage": { + "name": "mypage", + "version": "1.0.0", + "resolved": "../../features/mypage", + "registryType": "local", + "dependencies": { + "@itcast/basic": "file:../../commons/basic" + } + }, + "register@../../features/register": { + "name": "register", + "version": "1.0.0", + "resolved": "../../features/register", + "registryType": "local", + "dependencies": { + "@itcast/basic": "file:../../commons/basic" + } + }, + "utils@../../commons/utils": { + "name": "utils", + "version": "1.0.0", + "resolved": "../../commons/utils", + "registryType": "local", + "dependencies": { + "@ohos/crypto-js": "^2.0.4" + } + } + } +} \ No newline at end of file diff --git a/products/expert/oh-package.json5 b/products/expert/oh-package.json5 new file mode 100644 index 0000000..d7e038f --- /dev/null +++ b/products/expert/oh-package.json5 @@ -0,0 +1,15 @@ +{ + "name": "expert", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "@itcast/basic": "file:../../commons/basic", + "utils": "file:../../commons/utils", + "mypage":"file:../../features/mypage", + "home": 'file:../../features/Home', + "register": 'file:../../features/register' + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/contants/TabBarItems.ets b/products/expert/src/main/ets/contants/TabBarItems.ets new file mode 100644 index 0000000..541f0ef --- /dev/null +++ b/products/expert/src/main/ets/contants/TabBarItems.ets @@ -0,0 +1,15 @@ + +import { TabBarCompModel } from '../models/TabBarCompModel' + +export const TabBarItems: TabBarCompModel[] = [ + { + defaultIcon: $r('app.media.video_tabbar_icon'), + activeIcon: $r('app.media.video_tabbar_selected_icon'), + label: '视频' + }, + { + defaultIcon: $r('app.media.my_tabbar_icon'), + activeIcon: $r('app.media.my_tabbar_selected_icon'), + label: '我的' + } +] \ No newline at end of file diff --git a/products/expert/src/main/ets/entryability/EntryAbility.ets b/products/expert/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000..966c723 --- /dev/null +++ b/products/expert/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,61 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; +import notificationManager from '@ohos.notificationManager'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + AppStorage.Set('notificationEnabled', false); // 假设默认关闭 + this.checkNotificationStatus(); // 首次检查 + + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/BootPage', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } + + // 检查系统通知状态并更新 AppStorage 的方法 + async checkNotificationStatus() { + try { + let isEnabled = await notificationManager.isNotificationEnabled(); + console.info(`Notification enabled status: ${isEnabled}`); + // 更新 AppStorage 中的通知状态 + AppStorage.Set('notificationEnabled', isEnabled); + } catch (err) { + console.error(`Failed to check notification status: ${JSON.stringify(err)}`); + // 错误处理,例如保持当前状态或设置为默认值 + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/entrybackupability/EntryBackupAbility.ets b/products/expert/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000..8e4de99 --- /dev/null +++ b/products/expert/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/models/StartModel.ets b/products/expert/src/main/ets/models/StartModel.ets new file mode 100644 index 0000000..47d67e5 --- /dev/null +++ b/products/expert/src/main/ets/models/StartModel.ets @@ -0,0 +1,14 @@ +export interface StartBean{ + code:string; + data:Start; + message:string; +} + +export interface Start { + uuid:string + status:string + note:string + type:string + path:string + url:string +} \ No newline at end of file diff --git a/products/expert/src/main/ets/models/TabBarCompModel.ets b/products/expert/src/main/ets/models/TabBarCompModel.ets new file mode 100644 index 0000000..85770da --- /dev/null +++ b/products/expert/src/main/ets/models/TabBarCompModel.ets @@ -0,0 +1,6 @@ + +export class TabBarCompModel { + defaultIcon: ResourceStr = '' + activeIcon: ResourceStr = '' + label: string = '' +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/BootPage.ets b/products/expert/src/main/ets/pages/BootPage.ets new file mode 100644 index 0000000..5cbcd30 --- /dev/null +++ b/products/expert/src/main/ets/pages/BootPage.ets @@ -0,0 +1,242 @@ +import { authStore, themeManager,hdHttp } from '@itcast/basic' +import { router } from '@kit.ArkUI' +import { preferenceStore,DataWebModel, logger,HdResponse } from '@itcast/basic' +import { BasicConstant } from '@itcast/basic' +import { BusinessError } from '@kit.BasicServicesKit'; +import { StartBean } from '../models/StartModel' +@Entry +@Component +struct BootPage { + @StorageProp('topHeight') + topHeight: number = 0 + @State + time: number = 3 + timer: number | null = null + @State + isFirstRun:boolean=preferenceStore.getItemBooleanT('isFirstRun') + @State + isLogin:boolean=preferenceStore.getItemBooleanF('isLogin') + @State + photoUrl:ResourceStr=$r('app.media.startIcon') + @State + newUrl:string=''; + aboutToAppear(): void { + themeManager.initThemeSetting() + themeManager.enableFullScreen() + authStore.initUser() + + getContext().getApplicationContext().getRunningProcessInformation() + if(this.isFirstRun) + { + } + else if(this.isLogin) + { + this.getPhoto() + } + } + + dialog = new CustomDialogController({ + builder: PrivacyDialog(), + cornerRadius: 4, + }) + + startTick() + { + this.timer = setInterval(() => { + this.time-- + if (this.time <= 0) { + + this.goNextPage(); + } + }, 1000) + } + goNextPage() + { + clearInterval(this.timer) + router.replaceUrl({ url: 'pages/Home' }) + + } + + onPageShow(): void { + + if(this.isFirstRun) + { + this.dialog.open() + } + else if(this.isLogin) + { + this.startTick() + } + else + { + router.replaceUrl({ url: 'pages/LoginPage/LoginPage' }) + } + } + onPageHide(): void { + + if(this.isFirstRun) + { + this.dialog.close() + } + } + + aboutToDisappear(): void { + clearInterval(this.timer) + } + + build() { + RelativeContainer() { + if(this.isFirstRun) + { + + } + else + { + if(this.newUrl!='') + { + Text( this.time + 's' + ' | 跳过') + .width(70) + .height(30) + .borderRadius(15) + .textAlign(TextAlign.Center) + .fontSize(14) + .backgroundColor('#33000000') + .fontColor($r('app.color.white')) + .alignRules({ + right: { anchor: "__container__", align: HorizontalAlign.End } + }) + .margin({ right: 20, top: this.topHeight + 20 }) + .onClick(()=>{ + this.goNextPage() + + + }) + Row() + { + Text('点击跳转至详情页') + .height(70) + .textAlign(TextAlign.Center) + .fontSize(21) + .fontColor($r('app.color.white')) + Image($r('app.media.gohere')) + .width(22) + .margin({left:2}) + } + .backgroundColor('#80000000') + .borderRadius(39) + .border({ + width: 3, + color: $r('app.color.white') + }) + .alignRules({ + bottom: { anchor: "__container__", align: VerticalAlign.Bottom }, + middle: { anchor: "__container__", align:HorizontalAlign.Center } + }) + .margin({bottom:200}) + .padding({right:55,left:55}) + .height(70) + .onClick(()=>{ + clearInterval(this.timer) + this.goNextPage() + try { + router.pushUrl({ + url: 'pages/WebView/WebPage', + params: { url: this.newUrl ,title:'肝胆相照'} + }, router.RouterMode.Standard); + } catch (err) { + console.error(`跳转失败: ${err.code}, ${err.message}`); + } + }) + } + + } + + } + .width('100%') + .height('100%') + .backgroundImage(this.photoUrl) + .backgroundImageSize(ImageSize.FILL) + .geometryTransition("boot") + .transition(TransitionEffect.OPACITY) + } + + getPhoto() + { + hdHttp.httpReqSimply(BasicConstant.getStartpage).then(async (res: HdResponse) => { + + logger.info('Response StartBean'+res); + let json:StartBean = JSON.parse(res+'') as StartBean; + // + if(json.code=='1') + { + this.photoUrl=BasicConstant.urlHtml+json.data.path + this.newUrl=json.data.url + logger.info('Response photoUrl'+this.photoUrl); + + } + + + }).catch((err: BusinessError) => { + + console.info(`Response login succeeded: ${err}`); + + }) + } + +} + +@CustomDialog +struct PrivacyDialog { + + controller: CustomDialogController + + build() { + Column({ space: 10 }) { + Text('温馨提示') + .fontSize(18) + Text() { + Span('欢迎使用肝胆相照,在使用本软件前,请认真阅读').fontColor($r('app.color.common_gray_03')) + Span('《隐私政策》').fontColor('#ff0000').onClick(() => { + this.controller.close() + ToWeb(BasicConstant.getyyzc,'《隐私政策》') + }) + Span(',您同意并接受全部条款后方可使用肝胆相照App。').fontColor($r('app.color.common_gray_03')) + } + .fontSize(16) + Flex({ justifyContent: FlexAlign.SpaceAround }) { + Button("不同意并退出") + .onClick(() => { + if (this.controller != undefined) { + this.controller.close() + router.back() + } + }).backgroundColor(0xffffff).fontColor($r('app.color.top_title')) + Button("同意") + .onClick(() => { + preferenceStore.setItemBoolean('isFirstRun',false) + if (this.controller != undefined ) { + this.controller.close() + router.replaceUrl({ url: 'pages/Index' }) + } + + }).backgroundColor(0xffffff).fontColor(Color.Black) + }.margin({ bottom: 10 }) + } + .justifyContent(FlexAlign.Center) + .backgroundColor($r('app.color.white')) + .padding(20) + } +} + +function ToWeb(u:string,t:string) +{ + let paramsInfo: DataWebModel = { + url:u , + title:t + + }; + router.pushUrl({ + url: 'pages/WebView/WebPage', // 目标url + params: paramsInfo // 添加params属性,传递自定义参数 + }) +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/Home.ets b/products/expert/src/main/ets/pages/Home.ets new file mode 100644 index 0000000..db2eee0 --- /dev/null +++ b/products/expert/src/main/ets/pages/Home.ets @@ -0,0 +1,62 @@ +import { TabBarComp } from '../pages/Tabbar/TabBarComp'; +import { themeManager } from '@itcast/basic'; +import { emitter } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; +import { promptAction } from '@kit.ArkUI'; + +@Entry +@Component +struct Home { + @State + @Watch('onChangeIndex') + activeIndex: number = 0 + + aboutToAppear(): void { + emitter.on({ eventId: 10000 }, (e) => { + if (e.data && e.data.activeIndex) { + this.activeIndex = e.data.activeIndex + } + }) + } + + onChangeIndex() { + if (this.activeIndex === 3) themeManager.settingStatusBarWhite() + else themeManager.settingStatusBarBlack() + } + + onPageShow(): void { + console.log('--onPageShow--'); + emitter.emit('notification_status_changed') + this.onChangeIndex() + } + + onPageHide(): void { + console.log('onPageHide'); + this.onChangeIndex() + themeManager.settingStatusBarBlack() + this.backTimes = 0 + } + + backTimes: number = 0 + + onBackPress(): boolean | void { + this.backTimes++ + if (this.backTimes <= 1) { + promptAction.showToast({ message: '再按一次将退出应用' }) + } + if (this.backTimes >= 2) { + const ctx = getContext() as common.UIAbilityContext + ctx.terminateSelf() + } + + + return true + } + + build() { + Flex() { + TabBarComp({ activeIndex: this.activeIndex }) + } + .backgroundColor($r('app.color.white')) + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/Index.ets b/products/expert/src/main/ets/pages/Index.ets new file mode 100644 index 0000000..d2110e6 --- /dev/null +++ b/products/expert/src/main/ets/pages/Index.ets @@ -0,0 +1,11 @@ +import { GuidePage } from 'register' + +@Entry +@Component +struct Index { + build() { + Column() { + GuidePage() + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets b/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets new file mode 100644 index 0000000..b05288e --- /dev/null +++ b/products/expert/src/main/ets/pages/LoginPage/LoginPage.ets @@ -0,0 +1,11 @@ +import { LoginComp } from 'register' + +@Entry +@Component +struct LoginPage { + build() { + Column() { + LoginComp() + } + } +} diff --git a/products/expert/src/main/ets/pages/LoginPage/LoginSetInfoPage.ets b/products/expert/src/main/ets/pages/LoginPage/LoginSetInfoPage.ets new file mode 100644 index 0000000..d874021 --- /dev/null +++ b/products/expert/src/main/ets/pages/LoginPage/LoginSetInfoPage.ets @@ -0,0 +1,11 @@ +import { LoginSetInfo } from 'register' + +@Entry +@Component +struct LoginSetInfoPage { + build() { + Column() { + LoginSetInfo() + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/CancelAccount.ets b/products/expert/src/main/ets/pages/MinePage/CancelAccount.ets new file mode 100644 index 0000000..e3b58ab --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/CancelAccount.ets @@ -0,0 +1,82 @@ +import { HdNav } from '@itcast/basic'; +import { promptAction } from '@kit.ArkUI' + +@Entry +@Component +struct CancelAccount { + @State feedbackText: string = + ' 账户注销后不可恢复,您将永久放弃此账户现有权益\n' + + ' 1.您将不能再使用此账户随访患者,不能接收随访患者发送的信息\n' + + ' 2.您所有的咨询、订单、下载记录将被清除且不能找回\n' + + ' 3.肝胆相照平台提供的文献、视频等服务将结束\n' + + ' 4.申请注销账户前,请确保账户相关权益已结清\n' + + ' 收到您的注销申请后,我们将在10个工作日内帮您完成注销及数据清除工作' + controller:TextAreaController = new TextAreaController(); + + build() { + Column() { + HdNav({ title: '注销账户', showRightIcon: false, hasBorder: true }) + + Row() { + Text(this.feedbackText) + .fontSize(13) + .margin(8) + } + .width('100%') + .height('auto') + .margin(0) + .backgroundColor(Color.White) + .borderRadius(5) + .border({ + width:1, + color:$r('app.color.main_color') + }) + + // 提交按钮 + Button('我已确认风险,提交注销申请', { + type: ButtonType.Normal, + stateEffect: true + }) + .fontSize(13) + .fontColor(Color.White) + .width('90%') + .height(45) + .backgroundColor('#8B2316') + .borderRadius(3) + .margin(20) + .border({ + width:1, + color:'#8B2316' + }) + .onClick(() => this.submitFeedback()) + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + } + // 提交反馈处理 + private submitFeedback(): void { + // 提交逻辑实现 + promptAction.showDialog({ + title:'注销账户', + message:'确定要注销肝胆相照平台账号吗?\n注销后您的所有数据将无法恢复', + alignment:DialogAlignment.Center, + buttons:[ + { + text:'取消', + color:'#333333' + }, + { + text:'确定', + color:'#999999' + } + ] + }) + .then(data=>{ + console.info('showDialog success, click button: '+data.index) + }) + .catch((error:Error)=>{ + console.info('showDialog error:'+error) + }) + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/ChangePassword.ets b/products/expert/src/main/ets/pages/MinePage/ChangePassword.ets new file mode 100644 index 0000000..4002691 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/ChangePassword.ets @@ -0,0 +1,13 @@ +import { ChangePasswordComp } from 'mypage' +import { HdNav } from '@itcast/basic'; + +@Entry +@Component +struct ChangePassword { + build() { + Column(){ + HdNav({ title: '修改登录密码', showRightIcon: false, hasBorder: true }) + ChangePasswordComp(); + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/ChangePhonePage.ets b/products/expert/src/main/ets/pages/MinePage/ChangePhonePage.ets new file mode 100644 index 0000000..e80db37 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/ChangePhonePage.ets @@ -0,0 +1,13 @@ +import { ChangePhoneComp, ForgetPasswordComp } from 'mypage' +import { HdNav } from '@itcast/basic'; + +@Entry +@Component +struct ChangePhonePage { + build() { + Column(){ + HdNav({ title: '更换手机号', showRightIcon: false, hasBorder: true }) + ChangePhoneComp(); + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/ChooseEmail.ets b/products/expert/src/main/ets/pages/MinePage/ChooseEmail.ets new file mode 100644 index 0000000..f2c2a77 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/ChooseEmail.ets @@ -0,0 +1,13 @@ +import { ChooseEmailComp } from 'mypage' +import { HdNav } from '@itcast/basic'; + +@Entry +@Component +struct ChooseEmail { + build() { + Column() { + HdNav({ title: '修改邮箱', showRightIcon: false, hasBorder: true }) + ChooseEmailComp(); + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/ChooseOfficePhone.ets b/products/expert/src/main/ets/pages/MinePage/ChooseOfficePhone.ets new file mode 100644 index 0000000..e95e6b5 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/ChooseOfficePhone.ets @@ -0,0 +1,13 @@ +import { ChooseOfficePhoneComp } from 'mypage' +import { HdNav } from '@itcast/basic'; + +@Entry +@Component +struct ChooseOfficePhone { + build() { + Column() { + HdNav({ title: '修改科室电话', showRightIcon: false, hasBorder: true }) + ChooseOfficePhoneComp(); + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/EditIntroductionPage.ets b/products/expert/src/main/ets/pages/MinePage/EditIntroductionPage.ets new file mode 100644 index 0000000..7821123 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/EditIntroductionPage.ets @@ -0,0 +1,69 @@ +import promptAction from '@ohos.promptAction'; +import { authStore } from '@itcast/basic'; +import { HdNav } from '@itcast/basic'; + +@Entry +@Component +struct EditIntroductionPage { + controller : TextAreaController = new TextAreaController() + @State inputValue: string = authStore.getUser().intro; + + build() { + Column() { + HdNav({ title: '修改个人简介', showRightIcon: false, hasBorder: true }) + + // 手机号输入框 + Row() { + TextArea({controller:this.controller,text:this.inputValue,placeholder:'请编辑您的个人简介(500字以内)'}) + .fontSize(16) + .borderRadius(5) + .borderWidth(1) + .borderColor('#999999') + .backgroundColor(Color.White) + .height(150) + .onChange((value:string)=>{ + this.inputValue = value; + }) + } + .margin({ top: 10 }) + .width('95%') + + // 验证码输入区域 + Row() { + Text('请填写您的个人简介,让更多的人了解您') + .fontSize(15) + .fontColor('#333333') + .width('95%') + } + .margin({top:15}) + .width('95%') + .justifyContent(FlexAlign.SpaceBetween) + + // 登录按钮 + Button({type:ButtonType.Normal}){ + Text('保 存') + } + .width('90%') + .height(48) + .borderRadius(8) + .borderWidth(1) + .borderColor('#8B2316') + .backgroundColor(Color.White) + .fontColor('#8B2316') + .fontSize(18) + .position({x:'5%',y:'80%'}) + .onClick(() => { + // 处理登录逻辑 + if (this.inputValue.length > 0) { + promptAction.showToast({message:'请输入简介'}) + return + } + + // 执行登录操作... + }) + } + .width('100%') + .height('100%') + .backgroundColor('#FFFFFF') + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/EditUserDataPage.ets b/products/expert/src/main/ets/pages/MinePage/EditUserDataPage.ets new file mode 100644 index 0000000..c2fd0e7 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/EditUserDataPage.ets @@ -0,0 +1,13 @@ +import { authStore, HdNav } from '@itcast/basic'; +import { EditUserDataComp } from 'mypage' + +@Entry +@Component +struct EditUserDataPage { + build() { + Column(){ + HdNav({ title: '个人资料', showRightIcon: false, hasBorder: true }); + EditUserDataComp(); + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/FeedbackPage.ets b/products/expert/src/main/ets/pages/MinePage/FeedbackPage.ets new file mode 100644 index 0000000..977cf4f --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/FeedbackPage.ets @@ -0,0 +1,56 @@ +import { HdNav } from '@itcast/basic'; + +@Entry +@Component +struct FeedbackPage { + @State feedbackText: string = '' + controller:TextAreaController = new TextAreaController(); + + build() { + Column() { + HdNav({ title: '意见反馈', showRightIcon: false, hasBorder: true }) + // 输入框区域 + TextArea({ + text:this.feedbackText, + placeholder:'欢迎对我们的软件提供建议,帮助我们更快更好地改进"肝胆相照"APP(200字以内)', + controller:this.controller + }) + .placeholderFont({size:16}) + .placeholderColor('#999999') + .width('95%') + .height(230) + .margin(10) + .fontSize(16) + .backgroundColor(Color.White) + .borderRadius(5) + .border({ + width:1, + color:'#999999' + }) + + // 提交按钮 + Button('提交', { + type: ButtonType.Normal, + stateEffect: true + }) + .width('90%') + .height(45) + .backgroundColor(Color.White) + .borderRadius(5) + .fontColor('#8B2316') + .position({x:'5%',y:'90%'}) + .border({ + width:1, + color:'#8B2316' + }) + .onClick(() => this.submitFeedback()) + } + .width('100%') + .height('100%') + .backgroundColor(Color.White) + } + // 提交反馈处理 + private submitFeedback(): void { + // 提交逻辑实现 + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/ForgetPassword.ets b/products/expert/src/main/ets/pages/MinePage/ForgetPassword.ets new file mode 100644 index 0000000..a6e35e8 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/ForgetPassword.ets @@ -0,0 +1,13 @@ +import { ForgetPasswordComp } from 'mypage' +import { HdNav } from '@itcast/basic'; + +@Entry +@Component +struct ForgetPassword { + build() { + Column(){ + HdNav({ title: '忘记密码', showRightIcon: false, hasBorder: true }) + ForgetPasswordComp(); + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/MinePage/MyPage.ets b/products/expert/src/main/ets/pages/MinePage/MyPage.ets new file mode 100644 index 0000000..6f051cd --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/MyPage.ets @@ -0,0 +1,15 @@ +import { MyHomePage } from 'mypage' +import { emitter } from '@kit.BasicServicesKit'; + +@Entry +@Component +export struct MyPage { + build() { + Column(){ + MyHomePage() + } + .width('100%') + .height('100%') + .backgroundColor('#F3F3F3') + } +} diff --git a/products/expert/src/main/ets/pages/MinePage/SettingPage.ets b/products/expert/src/main/ets/pages/MinePage/SettingPage.ets new file mode 100644 index 0000000..e576538 --- /dev/null +++ b/products/expert/src/main/ets/pages/MinePage/SettingPage.ets @@ -0,0 +1,210 @@ +import { authStore, HdNav , preferenceStore} from '@itcast/basic'; +import { bundleManager, common, ConfigurationConstant, Want } from '@kit.AbilityKit'; +import { fileIo, storageStatistics } from '@kit.CoreFileKit'; +import { promptAction, router } from '@kit.ArkUI'; +import call from '@ohos.telephony.call'; + +@Entry +@Preview +@Component +struct SettingPage { + @State version: string = '' + @State cache: string = '' + @State settingList : Array = [ + '修改登录密码', + '更换手机号', + '版本', + '关于肝胆相照', + // '分享肝胆相照APP', + '肝胆相照直播群', + '清除缓存', + '意见反馈', + '注销账户', + '注册协议', + '隐私政策', + '项目办公室电话' + ]; + + aboutToAppear(): void { + this.getVersion() + this.calcCache() + } + + getVersion() { + bundleManager.getBundleInfoForSelf( + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_APPLICATION | + bundleManager.BundleFlag.GET_BUNDLE_INFO_WITH_METADATA + ) + .then((res) => { + this.version = 'v' + res.versionName + }) + } + + calcCache() { + storageStatistics.getCurrentBundleStats() + .then(res => { + this.cache = (res.cacheSize / (1000 * 1000)).toFixed(2) + 'MB' + }) + } + + clearCache() { + const ctx = getContext() + const ctxCacheDir = ctx.cacheDir + const ctxExist = fileIo.accessSync(ctxCacheDir) + if (ctxExist) { + fileIo.rmdirSync(ctxCacheDir) + } + const app = ctx.getApplicationContext() + const appCacheDir = app.cacheDir + const appExist = fileIo.accessSync(appCacheDir) + if (appExist) { + fileIo.rmdirSync(appCacheDir) + } + promptAction.showToast({ message: '清理完毕' }) + this.calcCache() + } + + build() { + Column(){ + HdNav({ title: '设置与帮助', showRightIcon: false, hasBorder: true }) + + Blank() + + List(){ + ForEach(this.settingList,(item:string,index:number)=>{ + ListItem() { + Column() { + Row() { + Text(item) + .fontSize(16) + .fontColor('#333333') + .margin({ left: 10 }) + Blank() + if (item=='版本') { + Text(this.version) + .fontSize(16) + .fontColor($r('app.color.main_color')) + .margin({ right: 10 }) + } else if (item == '清除缓存') { + Text(this.cache) + .fontSize(16) + .fontColor($r('app.color.main_color')) + .margin({ right: 10 }) + Image($r('sys.media.ohos_ic_public_arrow_right')) + .width(15) + .height(15) + .margin({ right: 10 }) + } else if (item == '项目办公室电话') { + Text('010-87573022') + .fontSize(16) + .fontColor($r('app.color.main_color')) + .margin({ right: 10 }) + } else { + Image($r('sys.media.ohos_ic_public_arrow_right')) + .width(15) + .height(15) + .margin({ right: 10 }) + } + } + .width('100%') + .height(52) + .justifyContent(FlexAlign.SpaceBetween) + Divider() + .color('#F4F4F4') + .strokeWidth(1) + .height(1) + .margin({left:10,top:0}) + } + .justifyContent(FlexAlign.Start) + } + .height(53) + .onClick(()=>{ + if (index == 0) { + router.pushUrl({url:'pages/MinePage/ChangePassword'}) + } else if (index == 1) { + router.pushUrl({url:'pages/MinePage/ChangePhonePage'}) + } else if (index == 2) { + console.info('当前版本:',this.settingList[index]); + } else if (index == 3) { + try { + router.pushUrl({ + url: 'pages/WebView/WebPage', + params: { url: 'http://doc.igandan.com/app/html/about/2017/about2.html' ,title:'关于肝胆相照'} + }, router.RouterMode.Standard); + } catch (err) { + console.error(`跳转失败: ${err.code}, ${err.message}`); + } + } else if (index == 4) { + try { + router.pushUrl({ + url: 'pages/WebView/WebPage', + params: { url: 'http://wx.igandan.com/qun/gdxzqun' ,title:'肝胆相照直播群'} + }, router.RouterMode.Standard); + } catch (err) { + console.error(`跳转失败: ${err.code}, ${err.message}`); + } + } else if (index == 5) { + this.clearCache(); + } else if (index == 6) { + router.pushUrl({url:'pages/MinePage/FeedbackPage'}) + } else if (index == 7) { + router.pushUrl({url:'pages/MinePage/CancelAccount'}) + } else if (index == 8) { + try { + router.pushUrl({ + url: 'pages/WebView/WebPage', + params: { url: 'http://app.igandan.com/expert_zcxy.jsp' ,title:'注册协议'} + }, router.RouterMode.Standard); + } catch (err) { + console.error(`跳转失败: ${err.code}, ${err.message}`); + } + } else if (index == 9) { + try { + router.pushUrl({ + url: 'pages/WebView/WebPage', + params: { url: 'https://doc.igandan.com/app/integral/permission_expert.html' ,title:'隐私政策'} + }, router.RouterMode.Standard); + } catch (err) { + console.error(`跳转失败: ${err.code}, ${err.message}`); + } + } else { + if (call.hasVoiceCapability()) { + call.makeCall('010-87573022',(err)=>{ + if (err) { + promptAction.showToast({message:'拨号失败'}) + } else { + promptAction.showToast({message:'拨号成功'}) + } + }) + } else { + promptAction.showToast({message:'不支持通话'}) + } + } + }) + }) + } + .height('auto') + + Button({ type: ButtonType.Normal }){ + Text('退出登录') + } + .width('90%') + .height(53) + .fontSize(16) + .borderWidth(1) + .borderRadius(8) + .fontColor($r('app.color.main_color')) + .borderColor($r('app.color.main_color')) + .backgroundColor(Color.White) + .margin({top:10,left:10,right:10}) + .onClick(()=>{ + authStore.delUser(); + preferenceStore.setItemBoolean('isLogin',false) + router.back() + router.replaceUrl({ + url: 'pages/LoginPage/LoginPage', // 目标url + },router.RouterMode.Single) + }) + } + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/Tabbar/IndexCopy.ets b/products/expert/src/main/ets/pages/Tabbar/IndexCopy.ets new file mode 100644 index 0000000..6b5a95f --- /dev/null +++ b/products/expert/src/main/ets/pages/Tabbar/IndexCopy.ets @@ -0,0 +1,61 @@ +import { TabBarComp } from '../Tabbar/TabBarComp'; +import { themeManager } from '@itcast/basic'; +import { emitter } from '@kit.BasicServicesKit'; +import { common } from '@kit.AbilityKit'; +import { promptAction } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + @State + @Watch('onChangeIndex') + activeIndex: number = 0 + + aboutToAppear(): void { + emitter.on({ eventId: 10000 }, (e) => { + if (e.data && e.data.activeIndex) { + this.activeIndex = e.data.activeIndex + } + }) + } + + onChangeIndex() { + if (this.activeIndex === 3) themeManager.settingStatusBarWhite() + else themeManager.settingStatusBarBlack() + } + + onPageShow(): void { + console.log('--onPageShow--'); + this.onChangeIndex() + } + + onPageHide(): void { + console.log('onPageHide'); + this.onChangeIndex() + themeManager.settingStatusBarBlack() + this.backTimes = 0 + } + + backTimes: number = 0 + + onBackPress(): boolean | void { + this.backTimes++ + if (this.backTimes <= 1) { + promptAction.showToast({ message: '再按一次将退出应用' }) + } + if (this.backTimes >= 2) { + const ctx = getContext() as common.UIAbilityContext + ctx.terminateSelf() + } + + + return true + } + + build() { + Flex() { + TabBarComp({ activeIndex: this.activeIndex }) + } + .backgroundColor($r('app.color.white')) + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/Tabbar/TabBarComp.ets b/products/expert/src/main/ets/pages/Tabbar/TabBarComp.ets new file mode 100644 index 0000000..9111c74 --- /dev/null +++ b/products/expert/src/main/ets/pages/Tabbar/TabBarComp.ets @@ -0,0 +1,61 @@ +import { VideoPage } from 'home' +import { MyHomePage } from 'mypage' +import { TabBarCompModel } from '../../models/TabBarCompModel' +import { TabBarItems } from '../../contants/TabBarItems' +import { BasicConstant } from '@itcast/basic' +import mediaquery from '@ohos.mediaquery'; + +@Component +export struct TabBarComp { + @StorageProp('bottomHeight') + bottomHeight: number = 0 + @Link + activeIndex: number + @State + isLandscape: boolean = false + listenerScreen = mediaquery.matchMediaSync('(orientation: landscape) and (device-type: tablet)') + + aboutToAppear() { + this.listenerScreen.on('change', (mediaQueryResult) => { + this.isLandscape = mediaQueryResult.matches + }) + } + + @Builder + TabBarBuilder(item: TabBarCompModel, index: number) { + Column({ space: BasicConstant.SPACE_SM }) { + Image(this.activeIndex === index ? item.activeIcon : item.defaultIcon) + .width($r('app.float.tab_bar_item_icon_size')) + Text(item.label) + .fontSize($r('app.float.tab_bar_item_font_size')) + .fontColor(this.activeIndex === index ? $r('app.color.black') : $r('app.color.common_gray_01')) + .animation({ duration: 300 }) + } + } + + build() { + Tabs({ + index: this.activeIndex + }) { + ForEach(TabBarItems, (item: TabBarCompModel, index: number) => { + TabContent() { + if (index === 0) VideoPage() + // else if (index === 1) ProjectComp() + // else if (index === 2) InterviewComp() + else MyHomePage() + } + .tabBar(this.TabBarBuilder(item, index)) + .expandSafeArea([SafeAreaType.SYSTEM], [SafeAreaEdge.BOTTOM]) + }) + } + .divider({ strokeWidth: $r('app.float.common_border_width'), color: $r('app.color.common_gray_border') }) + .vertical(this.isLandscape) + .barPosition(this.isLandscape ? BarPosition.Start : BarPosition.End) + .onTabBarClick((index) => { + this.activeIndex = index + }) + .barHeight(this.isLandscape ? $r('app.float.tab_bar_item_height_lg') : $r('app.float.tab_bar_item_height_sm')) + .scrollable(false) + .margin({ bottom: this.bottomHeight }) + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/VideoPage/ScienceVideoPage.ets b/products/expert/src/main/ets/pages/VideoPage/ScienceVideoPage.ets new file mode 100644 index 0000000..3ec2601 --- /dev/null +++ b/products/expert/src/main/ets/pages/VideoPage/ScienceVideoPage.ets @@ -0,0 +1,31 @@ +@Entry +@Component +export struct ScienceVideoPage { + @State message: string = 'Hello World'; + + onPageShow(): void { + console.log('ScienceVideoPage onPageShow!'); + } + + onPageHide(): void { + console.log('ScienceVideoPage onPageShow!'); + } + + build() { + RelativeContainer() { + Text(this.message) + .id('ScienceVideoPageHelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/products/expert/src/main/ets/pages/WebView/WebPage.ets b/products/expert/src/main/ets/pages/WebView/WebPage.ets new file mode 100644 index 0000000..9bb3736 --- /dev/null +++ b/products/expert/src/main/ets/pages/WebView/WebPage.ets @@ -0,0 +1,39 @@ +import webview from '@ohos.web.webview'; +import { HdNav } from '@itcast/basic'; +import router from '@ohos.router'; + +@Entry +@Component +struct WebPage { + private controller: webview.WebviewController = new webview.WebviewController(); + @State params:RouteParams = router.getParams() as RouteParams; + + @State url: string = this.params.url; + @State title: string = this.params.title; + customUserAgent: string = 'gdxz-expert'; + + build() { + Column() { + HdNav({ title: this.title, showRightIcon: false, hasBorder: true }) + Web({ + src: this.url, + controller: this.controller + }) + .mixedMode(MixedMode.All) + .domStorageAccess(true) + .onControllerAttached(() => { + let userAgent = this.controller.getUserAgent() + this.customUserAgent; + this.controller.setCustomUserAgent(userAgent); + }) + .width('100%') + .layoutWeight(1)// 占据剩余空间 + .height('100%') + } + .height('100%')// 关键:约束父容器高度 + } +} + +interface RouteParams { + url:string; + title:string; +} \ No newline at end of file diff --git a/products/expert/src/main/module.json5 b/products/expert/src/main/module.json5 new file mode 100644 index 0000000..e83c406 --- /dev/null +++ b/products/expert/src/main/module.json5 @@ -0,0 +1,69 @@ +{ + "module": { + "name": "default", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:app_icon", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ] + } + ], + "requestPermissions": [ + { + "name": "ohos.permission.INTERNET", + "reason": "$string:load_picture", + "usedScene": {"abilities": ["EntryAbility"],"when": "always"} + }, + { + "name": "ohos.permission.CAMERA", + "reason": "$string:camera_reason", + "usedScene": {} + }, + { + "name": "ohos.permission.READ_MEDIA", + "reason": "$string:media_reason", + "usedScene": {} + } + ] + } +} \ No newline at end of file diff --git a/products/expert/src/main/resources/base/element/color.json b/products/expert/src/main/resources/base/element/color.json new file mode 100644 index 0000000..6075344 --- /dev/null +++ b/products/expert/src/main/resources/base/element/color.json @@ -0,0 +1,12 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + }, + { + "name": "item_title_font", + "value": "#E6000000" + } + ] +} \ No newline at end of file diff --git a/products/expert/src/main/resources/base/element/float.json b/products/expert/src/main/resources/base/element/float.json new file mode 100644 index 0000000..05a7d90 --- /dev/null +++ b/products/expert/src/main/resources/base/element/float.json @@ -0,0 +1,28 @@ +{ + "float": [ + { + "name": "tab_bar_item_font_size", + "value": "10fp" + }, + { + "name": "tab_bar_item_icon_size", + "value": "22vp" + }, + { + "name": "tab_bar_item_height_sm", + "value": "50vp" + }, + { + "name": "tab_bar_item_height_lg", + "value": "400vp" + }, + { + "name": "font_size", + "value": "14fp" + }, + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} \ No newline at end of file diff --git a/products/expert/src/main/resources/base/element/string.json b/products/expert/src/main/resources/base/element/string.json new file mode 100644 index 0000000..16c12d0 --- /dev/null +++ b/products/expert/src/main/resources/base/element/string.json @@ -0,0 +1,28 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "肝胆相照专家端" + }, + { + "name": "camera_reason", + "value": "用于拍摄照片" + }, + { + "name": "media_reason", + "value": "用于选取相册照片" + }, + { + "name": "load_picture", + "value": "加载网络图片" + } + ] +} \ No newline at end of file diff --git a/products/expert/src/main/resources/base/media/app_icon.png b/products/expert/src/main/resources/base/media/app_icon.png new file mode 100644 index 0000000..9dad311 Binary files /dev/null and b/products/expert/src/main/resources/base/media/app_icon.png differ diff --git a/products/expert/src/main/resources/base/media/gohere.png b/products/expert/src/main/resources/base/media/gohere.png new file mode 100644 index 0000000..86f5c13 Binary files /dev/null and b/products/expert/src/main/resources/base/media/gohere.png differ diff --git a/products/expert/src/main/resources/base/media/login_password.png b/products/expert/src/main/resources/base/media/login_password.png new file mode 100644 index 0000000..766f800 Binary files /dev/null and b/products/expert/src/main/resources/base/media/login_password.png differ diff --git a/products/expert/src/main/resources/base/media/login_phone.png b/products/expert/src/main/resources/base/media/login_phone.png new file mode 100644 index 0000000..a7af28b Binary files /dev/null and b/products/expert/src/main/resources/base/media/login_phone.png differ diff --git a/products/expert/src/main/resources/base/media/my_tabbar_icon.png b/products/expert/src/main/resources/base/media/my_tabbar_icon.png new file mode 100644 index 0000000..ad156b0 Binary files /dev/null and b/products/expert/src/main/resources/base/media/my_tabbar_icon.png differ diff --git a/products/expert/src/main/resources/base/media/my_tabbar_selected_icon.png b/products/expert/src/main/resources/base/media/my_tabbar_selected_icon.png new file mode 100644 index 0000000..e67ec7f Binary files /dev/null and b/products/expert/src/main/resources/base/media/my_tabbar_selected_icon.png differ diff --git a/products/expert/src/main/resources/base/media/startIcon.png b/products/expert/src/main/resources/base/media/startIcon.png new file mode 100755 index 0000000..85ea770 Binary files /dev/null and b/products/expert/src/main/resources/base/media/startIcon.png differ diff --git a/products/expert/src/main/resources/base/media/video_tabbar_icon.png b/products/expert/src/main/resources/base/media/video_tabbar_icon.png new file mode 100644 index 0000000..78d9598 Binary files /dev/null and b/products/expert/src/main/resources/base/media/video_tabbar_icon.png differ diff --git a/products/expert/src/main/resources/base/media/video_tabbar_selected_icon.png b/products/expert/src/main/resources/base/media/video_tabbar_selected_icon.png new file mode 100644 index 0000000..44d197b Binary files /dev/null and b/products/expert/src/main/resources/base/media/video_tabbar_selected_icon.png differ diff --git a/products/expert/src/main/resources/base/profile/backup_config.json b/products/expert/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000..78f40ae --- /dev/null +++ b/products/expert/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/products/expert/src/main/resources/base/profile/main_pages.json b/products/expert/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000..47bf555 --- /dev/null +++ b/products/expert/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,22 @@ +{ + "src": [ + "pages/Index", + "pages/BootPage", + "pages/Home", + "pages/LoginPage/LoginPage", + "pages/LoginPage/LoginSetInfoPage", + "pages/MinePage/MyPage", + "pages/VideoPage/ScienceVideoPage", + "pages/MinePage/SettingPage", + "pages/MinePage/ChangePassword", + "pages/MinePage/ForgetPassword", + "pages/MinePage/ChangePhonePage", + "pages/WebView/WebPage", + "pages/MinePage/FeedbackPage", + "pages/MinePage/CancelAccount", + "pages/MinePage/EditUserDataPage", + "pages/MinePage/ChooseEmail", + "pages/MinePage/ChooseOfficePhone", + "pages/MinePage/EditIntroductionPage" + ] +} \ No newline at end of file diff --git a/products/expert/src/main/resources/dark/element/color.json b/products/expert/src/main/resources/dark/element/color.json new file mode 100644 index 0000000..79b11c2 --- /dev/null +++ b/products/expert/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/products/expert/src/mock/mock-config.json5 b/products/expert/src/mock/mock-config.json5 new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/products/expert/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/products/expert/src/ohosTest/ets/test/Ability.test.ets b/products/expert/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000..85c78f6 --- /dev/null +++ b/products/expert/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/products/expert/src/ohosTest/ets/test/List.test.ets b/products/expert/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000..794c7dc --- /dev/null +++ b/products/expert/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/products/expert/src/ohosTest/module.json5 b/products/expert/src/ohosTest/module.json5 new file mode 100644 index 0000000..5087c45 --- /dev/null +++ b/products/expert/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "default_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/products/expert/src/test/List.test.ets b/products/expert/src/test/List.test.ets new file mode 100644 index 0000000..bb5b5c3 --- /dev/null +++ b/products/expert/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/products/expert/src/test/LocalUnit.test.ets b/products/expert/src/test/LocalUnit.test.ets new file mode 100644 index 0000000..165fc16 --- /dev/null +++ b/products/expert/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }); + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }); + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }); + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }); + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }); + }); +} \ No newline at end of file