diff --git a/ArkUIKit/NativeNodeNapiSample/.gitignore b/ArkUIKit/NativeNodeNapiSample/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/AppScope/app.json5 b/ArkUIKit/NativeNodeNapiSample/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..97377064ec3a689f01fa3657a7a4656a1cb3c5fb --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.nativenodenapisample", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/element/string.json b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..16cc64a2ea47d408bd320091fb2f1045cfdae3b9 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "NativeNodeNapiSample" + } + ] +} diff --git a/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/background.png b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/background.png differ diff --git a/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/foreground.png b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/foreground.png differ diff --git a/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/layered_image.json b/ArkUIKit/NativeNodeNapiSample/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/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/ArkUIKit/NativeNodeNapiSample/build-profile.json5 b/ArkUIKit/NativeNodeNapiSample/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..69d9537d0f9770e05937c401f9c12afcf54eecf1 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/build-profile.json5 @@ -0,0 +1,44 @@ +{ + "app": { + "signingConfigs": [ + ], + "products": [ + { + "name": "default", + "signingConfig": "default", + "targetSdkVersion": 20, + "compileSdkVersion": 20, + "compatibleSdkVersion": 20, + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/code-linter.json5 b/ArkUIKit/NativeNodeNapiSample/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/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/ArkUIKit/NativeNodeNapiSample/entry/.gitignore b/ArkUIKit/NativeNodeNapiSample/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/build-profile.json5 b/ArkUIKit/NativeNodeNapiSample/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..068731d504c606b0e0080e03c2f3c8e6f13a743b --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/build-profile.json5 @@ -0,0 +1,40 @@ +{ + "apiType": "stageMode", + "buildOption": { + "externalNativeOptions": { + "path": "./src/main/cpp/CMakeLists.txt", + "arguments": "", + "cppFlags": "", + "abiFilters": ["arm64-v8a", "armeabi-v7a", "x86_64"] + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + "nativeLib": { + "debugSymbol": { + "strip": true, + "exclude": [] + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/hvigorfile.ts b/ArkUIKit/NativeNodeNapiSample/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..b0e3a1ab98a91bc918d6404b2413111a5011f14a --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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. */ +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/obfuscation-rules.txt b/ArkUIKit/NativeNodeNapiSample/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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/ArkUIKit/NativeNodeNapiSample/entry/oh-package-lock.json5 b/ArkUIKit/NativeNodeNapiSample/entry/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7c36300c3272430b97f5cda7cb1a835421298382 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/oh-package-lock.json5 @@ -0,0 +1,19 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry" + }, + "packages": { + "libentry.so@src/main/cpp/types/libentry": { + "name": "libentry.so", + "version": "1.0.0", + "resolved": "src/main/cpp/types/libentry", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/oh-package.json5 b/ArkUIKit/NativeNodeNapiSample/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..54cb066266f9993f5a023f2ac5a8dfc5d2574643 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": { + "libentry.so": "file:./src/main/cpp/types/libentry" + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/CMakeLists.txt b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..91d70df51e8bce6bbfbdbe25c11044b939a4953b --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/CMakeLists.txt @@ -0,0 +1,21 @@ +cmake_minimum_required(VERSION 3.5.0) +project(DrawableExample) + +set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +if(DEFINED PACKAGE_FIND_FILE) + include(${PACKAGE_FIND_FILE}) +endif() + +include_directories(${NATIVERENDER_ROOT_PATH} + ${NATIVERENDER_ROOT_PATH}/include) + +find_library( + libace-lib + ace_ndk.z +) +# 添加源文件 +add_library(entry SHARED napi_init.cpp) + +# 链接库 +target_link_libraries(entry PUBLIC ${libace-lib} libace_napi.z.so libnative_drawing.so hilog_ndk.z.so) \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/napi_init.cpp b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/napi_init.cpp new file mode 100644 index 0000000000000000000000000000000000000000..b3611b6154386b3c76ab7e4ca170edf3adefd12c --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/napi_init.cpp @@ -0,0 +1,88 @@ +#include +#include +#include +#include + +// Native方法:处理JS层传入的Drawable +static napi_value ProcessDrawable(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + // 获取JS层传入的参数 + napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (status != napi_ok || argc < 1) { + OH_LOG_ERROR(LOG_APP, "获取参数失败"); + return nullptr; + } + napi_value resourceValue = args[0]; // 这是ArkTS侧传入的Resource对象 + // 核心接口:将napi_value转换为DrawableDescriptor + ArkUI_DrawableDescriptor* drawable = nullptr; + int32_t res = OH_ArkUI_GetDrawableDescriptorFromNapiValue(env, resourceValue, &drawable); + // 3. 处理转换结果 + if (res != ArkUI_ErrorCode::ARKUI_ERROR_CODE_NO_ERROR) { + // 转换失败:根据错误码处理(参数无效等) + OH_LOG_ERROR(LOG_APP, "Failed to get drawable descriptor"); + napi_throw_error(env, nullptr, "Failed to get drawable descriptor"); + return nullptr; + } + // 4. 成功获取后,可使用drawableDesc进行后续操作 + // 返回处理结果给JS层 + napi_value result; + napi_create_int32(env, res, &result); + return result; +} + +// Native方法:处理JS层传入的Drawable +static napi_value ProcessDrawable2(napi_env env, napi_callback_info info) +{ + size_t argc = 1; + napi_value args[1] = {nullptr}; + // 获取JS层传入的参数 + napi_status status = napi_get_cb_info(env, info, &argc, args, nullptr, nullptr); + if (status != napi_ok || argc < 1) { + OH_LOG_ERROR(LOG_APP, "获取参数失败"); + return nullptr; + } + napi_value resourceValue = args[0]; // 这是ArkTS侧传入的Resource对象 + // 核心接口:将napi_value转换为DrawableDescriptor + ArkUI_DrawableDescriptor* drawable = nullptr; + int32_t res = OH_ArkUI_GetDrawableDescriptorFromResourceNapiValue (env, resourceValue, &drawable); + // 3. 处理转换结果 + if (res != ArkUI_ErrorCode::ARKUI_ERROR_CODE_NO_ERROR) { + // 转换失败:根据错误码处理(参数无效等) + napi_throw_error(env, nullptr, "Failed to get drawable descriptor"); + return nullptr; + } + // 4. 成功获取后,可使用drawableDesc进行后续操作 + // 返回处理结果给JS层 + napi_value result; + napi_create_int32(env, res, &result); + return result; +} + +EXTERN_C_START +static napi_value Init(napi_env env, napi_value exports) +{ + napi_property_descriptor desc[] = { + { "processDrawable", nullptr, ProcessDrawable, nullptr, nullptr, nullptr, napi_default, nullptr }, + { "processDrawable2", nullptr, ProcessDrawable2, nullptr, nullptr, nullptr, napi_default, nullptr } + }; + napi_define_properties(env, exports, sizeof(desc) / sizeof(desc[0]), desc); + return exports; +} +EXTERN_C_END + +static napi_module demoModule = { + .nm_version = 1, + .nm_flags = 0, + .nm_filename = nullptr, + .nm_register_func = Init, + .nm_modname = "entry", + .nm_priv = ((void*)0), + .reserved = { 0 }, +}; + +extern "C" __attribute__((constructor)) void RegisterEntryModule(void) +{ + napi_module_register(&demoModule); +} diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/Index.d.ts b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..16e407ebf821623b98e3505ad0e8cbf23d00baf1 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/Index.d.ts @@ -0,0 +1,5 @@ +import { DrawableDescriptor } from "@kit.ArkUI"; + +export const processDrawable: (a: DrawableDescriptor) => number; + +export const processDrawable2: (a: DrawableDescriptor) => number; \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/oh-package.json5 b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ea410725a8826704d061021d98cf02aa76cd8016 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/cpp/types/libentry/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entryability/EntryAbility.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..508880af8c33aa838016d1cd4b2c68be2f447540 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + 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/Index', (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'); + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/pages/Index.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..26267a93d6a55f736a1974883d043c67be99b3b1 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,36 @@ +import drawableProcessor from 'libentry.so'; // 导入Native模块 +import { DrawableDescriptor, LayeredDrawableDescriptor } from '@kit.ArkUI'; + +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + Text('Drawable处理示例') + .fontSize(20) + .margin(20) + + Button('GetDrawableDescriptorFromNapiValue接口测试') + .onClick(() => { + let resManager = this.getUIContext().getHostContext()?.resourceManager + let imageRes: DrawableDescriptor = (resManager?.getDrawableDescriptor($r('app.media.logo').id)) as DrawableDescriptor; + + const result = drawableProcessor.processDrawable(imageRes); + console.log('处理结果: ' + result); + }) + .margin({top:40,bottom:20}) + + Button('GetDrawableDescriptorFromResourceNapiValue接口测试') + .onClick(() => { + let resManager = this.getUIContext().getHostContext()?.resourceManager + let imageRes: DrawableDescriptor = (resManager?.getDrawableDescriptor($r('app.media.logo').id)) as DrawableDescriptor; + const result = drawableProcessor.processDrawable2(imageRes); + console.log('处理结果2: ' + result); + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/module.json5 b/ArkUIKit/NativeNodeNapiSample/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2cd3a6c601073f86f4789ab9db7529f84f705f3f --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/module.json5 @@ -0,0 +1,51 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "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" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/color.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/float.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/string.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/background.png b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/background.png differ diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/foreground.png b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/foreground.png differ diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/layered_image.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/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/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/logo.png b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..1d2d602999675ed16bf29903aaa7a0787be7f452 Binary files /dev/null and b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/logo.png differ diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/startIcon.png b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/backup_config.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/main_pages.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/dark/element/color.json b/ArkUIKit/NativeNodeNapiSample/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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/ArkUIKit/NativeNodeNapiSample/entry/src/mock/Libentry.mock.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/mock/Libentry.mock.ets new file mode 100644 index 0000000000000000000000000000000000000000..c2171716d040a605ef6af71e90b937a945f2677d --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/mock/Libentry.mock.ets @@ -0,0 +1,7 @@ +const NativeMock: Record = { + 'add': (a: number, b: number) => { + return a + b; + }, +}; + +export default NativeMock; \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/mock/mock-config.json5 b/ArkUIKit/NativeNodeNapiSample/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6540976c9acc8afbd45895db6404334cff195465 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/mock/mock-config.json5 @@ -0,0 +1,5 @@ +{ + "libentry.so": { + "source": "src/mock/Libentry.mock.ets" + } +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/Ability.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/List.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/module.json5 b/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..69026872775eebd0844900b225c411959ae5608b --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/src/ohosTest/module.json5 @@ -0,0 +1,12 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ArkUIKit/NativeNodeNapiSample/entry/src/test/List.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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/ArkUIKit/NativeNodeNapiSample/entry/src/test/LocalUnit.test.ets b/ArkUIKit/NativeNodeNapiSample/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/entry/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/ArkUIKit/NativeNodeNapiSample/hvigor/hvigor-config.json5 b/ArkUIKit/NativeNodeNapiSample/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..5bebc9755447385d82ce4138f54d991b1f85f348 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.5", + "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*/ + } +} diff --git a/ArkUIKit/NativeNodeNapiSample/hvigorfile.ts b/ArkUIKit/NativeNodeNapiSample/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..47113e2e36ecefde41c136272a0bd6ff745cffe4 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/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. */ +} \ No newline at end of file diff --git a/ArkUIKit/NativeNodeNapiSample/oh-package-lock.json5 b/ArkUIKit/NativeNodeNapiSample/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a3925056904d5e0d6791438feddebc0014a84db0 --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/oh-package-lock.json5 @@ -0,0 +1,28 @@ +{ + "meta": { + "stableOrder": true, + "enableUnifiedLockfile": false + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "@ohos/hamock@1.0.0": "@ohos/hamock@1.0.0", + "@ohos/hypium@1.0.21": "@ohos/hypium@1.0.21" + }, + "packages": { + "@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/ArkUIKit/NativeNodeNapiSample/oh-package.json5 b/ArkUIKit/NativeNodeNapiSample/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a8aff0c5aff22d78aa26fd19c3861f4320e951ff --- /dev/null +++ b/ArkUIKit/NativeNodeNapiSample/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "modelVersion": "5.0.5", + "description": "Please describe the basic information.", + "dependencies": { + }, + "devDependencies": { + "@ohos/hypium": "1.0.21", + "@ohos/hamock": "1.0.0" + } +}