diff --git a/.gitignore b/.gitignore index 2727df6..c09d674 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /target +/.cache .DS_Store .vscode @@ -6,4 +7,4 @@ *.har package/src/main/ets package/libs -/dist \ No newline at end of file +dist diff --git a/Cargo.lock b/Cargo.lock index a194fad..a7cc73f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,30 +4,30 @@ version = 4 [[package]] name = "aho-corasick" -version = "1.1.3" +version = "1.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "ddd31a130427c27518df266943a5308ed92d4b226cc639f5a8f1002816174301" dependencies = [ "memchr", ] [[package]] name = "bitflags" -version = "2.9.0" +version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c8214115b7bf84099f1309324e63141d4c5d7cc26862f97a0a857dbefe165bd" +checksum = "843867be96c8daad0d758b57df9392b6d8d271134fce549de6ce169ff98a92af" [[package]] name = "bytes" -version = "1.10.1" +version = "1.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" +checksum = "1e748733b7cbc798e1434b6ac524f0c1ff2ab456fe201501e6497c8417a4fc33" [[package]] name = "cfg-if" -version = "1.0.0" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801" [[package]] name = "convert_case" @@ -40,18 +40,18 @@ dependencies = [ [[package]] name = "convert_case" -version = "0.8.0" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baaaa0ecca5b51987b9423ccdc971514dd8b0bb7b4060b983d3664dad3f1f89f" +checksum = "633458d4ef8c78b72454de2d54fd6ab2e60f9e02be22f3c6104cdc8a4e0fceb9" dependencies = [ "unicode-segmentation", ] [[package]] name = "ctor" -version = "0.6.1" +version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ffc71fcdcdb40d6f087edddf7f8f1f8f79e6cf922f555a9ee8779752d4819bd" +checksum = "424e0138278faeb2b401f174ad17e715c829512d74f3d1e81eb43365c2e0590e" dependencies = [ "ctor-proc-macro", "dtor", @@ -63,6 +63,19 @@ version = "0.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "52560adf09603e58c9a7ee1fe1dcb95a16927b17c127f0ac02d6e768a0e25bc1" +[[package]] +name = "demo_native" +version = "0.1.0" +dependencies = [ + "futures-executor", + "napi-build-ohos", + "napi-derive-ohos", + "napi-ohos", + "ohos-hilog-binding", + "openharmony-ability", + "openharmony-ability-derive", +] + [[package]] name = "dtor" version = "0.1.1" @@ -79,10 +92,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f678cf4a922c215c63e0de95eb1ff08a958a81d47e485cf9da1e27bf6305cfa5" [[package]] -name = "fnv" -version = "1.0.7" +name = "futures" +version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +checksum = "8b147ee9d1f6d097cef9ce628cd2ee62288d963e16fb287bd9286455b241382d" +dependencies = [ + "futures-channel", + "futures-core", + "futures-executor", + "futures-io", + "futures-sink", + "futures-task", + "futures-util", +] [[package]] name = "futures-channel" @@ -91,6 +113,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" dependencies = [ "futures-core", + "futures-sink", ] [[package]] @@ -110,6 +133,29 @@ dependencies = [ "futures-util", ] +[[package]] +name = "futures-io" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" + +[[package]] +name = "futures-macro" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "futures-sink" +version = "0.3.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c39754e157331b013978ec91992bde1ac089843443c49cbc7f46150b0fad0893" + [[package]] name = "futures-task" version = "0.3.32" @@ -122,58 +168,62 @@ version = "0.3.32" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" dependencies = [ + "futures-channel", "futures-core", + "futures-io", + "futures-macro", + "futures-sink", "futures-task", + "memchr", "pin-project-lite", "slab", ] [[package]] name = "http" -version = "1.3.1" +version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f4a85d31aea989eead29a3aaf9e1115a180df8282431156e533de47660892565" +checksum = "e3ba2a386d7f85a81f119ad7498ebe444d2e22c2af0b86b069416ace48b3311a" dependencies = [ "bytes", - "fnv", "itoa", ] [[package]] name = "itoa" -version = "1.0.15" +version = "1.0.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" +checksum = "92ecc6618181def0457392ccd0ee51198e065e016d1d527a7ac1b6dc7c1f09d2" [[package]] name = "libloading" -version = "0.8.6" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fc2f4eb4bc735547cfed7c0a4922cbd04a4655978c09b54f1f7b228750664c34" +checksum = "754ca22de805bb5744484a5b151a9e1a8e837d5dc232c2d7d8c2e3492edc8b60" dependencies = [ "cfg-if", - "windows-targets", + "windows-link", ] [[package]] name = "memchr" -version = "2.7.4" +version = "2.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79" [[package]] name = "napi-build-ohos" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c26abeb82d299258244202546ce4b8098e9991b0a8d5514abe5f56d4fb1d48c" +checksum = "bcd28e4f8ae2bebf45f0a051bc2396259cb7b7b27d3f4c8c5058c9ee2942d9bf" [[package]] name = "napi-derive-backend-ohos" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d86f96f92eb3dba447ebc023ac5e16b0a92406d6df938bf3be566b604ea6646a" +checksum = "2cea8c5fcecd200491cb05ec15c205e5b408d6ce51ccd6e80c098022b87c2eed" dependencies = [ - "convert_case 0.8.0", + "convert_case 0.10.0", "proc-macro2", "quote", "semver", @@ -182,11 +232,11 @@ dependencies = [ [[package]] name = "napi-derive-ohos" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b2ebc6e95ff9cb26e669693315116913fcfdbd1cf4dd50463f046ef8c440937" +checksum = "c62e951b5919c4e8572e78d0e101c461ea445c777637cde66b0c273cf9f5d7f3" dependencies = [ - "convert_case 0.8.0", + "convert_case 0.10.0", "ctor", "napi-derive-backend-ohos", "proc-macro2", @@ -196,12 +246,13 @@ dependencies = [ [[package]] name = "napi-ohos" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c507895644c3334483daeb9612cfe3fd2d433408edcb9f3449bccd7c3e357db0" +checksum = "300401a6c16e3a166bfb43d196e3bafe98362332e918377e18c8443bd7318e40" dependencies = [ "bitflags", "ctor", + "futures", "napi-build-ohos", "napi-sys-ohos", "nohash-hasher", @@ -211,9 +262,9 @@ dependencies = [ [[package]] name = "napi-sys-ohos" -version = "1.1.4" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b96d2ad26866a761c5cf9432200bb3e5190e222a12c2e4494a0c23f7c45c6964" +checksum = "c26511521495f458de78601477e42455e3d5553e96163be6f8725882497aa383" dependencies = [ "libloading", ] @@ -266,9 +317,9 @@ checksum = "fe9e1bba4d94159d0a65f1b4e748c148d4bce7930912c424522693f1837dad77" [[package]] name = "ohos-hilog-binding" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f360d22e965a34286283d36e8864fdfb04f443697641e8f6cbd64e670c3a3d5" +checksum = "860d1e3c2c5e3217d819a16c815d2d4dcbc7610285d2612d08745a29c353a503" dependencies = [ "ohos-hilogs-sys", ] @@ -400,24 +451,24 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.16" +version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" +checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd" [[package]] name = "proc-macro2" -version = "1.0.95" +version = "1.0.106" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "02b3e5e68a3a1a02aad3ec490a98007cbc13c37cbe84a3cd7b8e406d76e7f778" +checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.40" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1885c039570dc00dcb4ff087a89e185fd56bae234ddc7f056a945bf36467248d" +checksum = "41f2619966050689382d2b44f664f4bc593e129785a36d6ee376ddf37259b924" dependencies = [ "proc-macro2", ] @@ -430,9 +481,9 @@ checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" [[package]] name = "regex" -version = "1.11.1" +version = "1.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191" +checksum = "e10754a14b9137dd7b1e3e5b0493cc9171fdd105e0ab477f51b72e7f3ac0e276" dependencies = [ "aho-corasick", "memchr", @@ -442,9 +493,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.9" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908" +checksum = "6e1dd4122fc1595e8162618945476892eefca7b88c52820e74af6262213cae8f" dependencies = [ "aho-corasick", "memchr", @@ -453,9 +504,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.5" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +checksum = "dc897dd8d9e8bd1ed8cdad82b5966c3e0ecae09fb1907d58efaa013543185d0a" [[package]] name = "rustc-hash" @@ -465,9 +516,9 @@ checksum = "357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d" [[package]] name = "semver" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "56e6fa9c48d24d85fb3de5ad847117517440f6beceb7798af16b4a87d616b8d0" +checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" [[package]] name = "slab" @@ -477,9 +528,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "syn" -version = "2.0.101" +version = "2.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ce2b7fc941b3a24138a0a7cf8e858bfc6a992e7978a068a5c760deb0ed43caf" +checksum = "e665b8803e7b1d2a727f4023456bbbbe74da67099c585258af0ad9c5013b9b99" dependencies = [ "proc-macro2", "quote", @@ -488,18 +539,18 @@ dependencies = [ [[package]] name = "tokio" -version = "1.49.0" +version = "1.50.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72a2903cd7736441aac9df9d7688bd0ce48edccaadf181c3b90be801e81d3d86" +checksum = "27ad5e34374e03cfffefc301becb44e9dc3c17584f414349ebe29ed26661822d" dependencies = [ "pin-project-lite", ] [[package]] name = "unicode-ident" -version = "1.0.18" +version = "1.0.24" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a5f39404a5da50712a4c1eecf25e90dd62b613502b7e925fd4e4d19b5c96512" +checksum = "e6e4313cd5fcd3dad5cafa179702e2b244f760991f45397d14d4ebf38247da75" [[package]] name = "unicode-segmentation" @@ -508,90 +559,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f6ccf251212114b54433ec949fd6a7841275f9ada20dddd2f29e9ceea4501493" [[package]] -name = "webview_example" -version = "0.1.0" -dependencies = [ - "napi-build-ohos", - "napi-derive-ohos", - "napi-ohos", - "ohos-hilog-binding", - "openharmony-ability", - "openharmony-ability-derive", -] - -[[package]] -name = "windows-targets" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" -dependencies = [ - "windows_aarch64_gnullvm", - "windows_aarch64_msvc", - "windows_i686_gnu", - "windows_i686_gnullvm", - "windows_i686_msvc", - "windows_x86_64_gnu", - "windows_x86_64_gnullvm", - "windows_x86_64_msvc", -] - -[[package]] -name = "windows_aarch64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" - -[[package]] -name = "windows_aarch64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" - -[[package]] -name = "windows_i686_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" - -[[package]] -name = "windows_i686_gnullvm" -version = "0.52.6" +name = "windows-link" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" - -[[package]] -name = "windows_i686_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" - -[[package]] -name = "windows_x86_64_gnu" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" - -[[package]] -name = "windows_x86_64_gnullvm" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" - -[[package]] -name = "windows_x86_64_msvc" -version = "0.52.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" - -[[package]] -name = "xcomponent_example" -version = "0.1.0" -dependencies = [ - "futures-executor", - "napi-build-ohos", - "napi-derive-ohos", - "napi-ohos", - "ohos-hilog-binding", - "openharmony-ability", - "openharmony-ability-derive", -] +checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" diff --git a/Cargo.toml b/Cargo.toml index 214b1c0..fba457f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,4 +21,4 @@ ohos-ime-binding = { version = "0.1" } ohos-web-binding = { version = "0.1" } ohos-display-binding = { version = "0.0.1" } -http = { version = "1.1" } +http = { version = "1.1" } \ No newline at end of file diff --git a/README.md b/README.md index 140e7bf..caf1336 100644 --- a/README.md +++ b/README.md @@ -2,105 +2,84 @@ > This project is in progress, and the API is not stable. -`openharmony-ability` is a crate to manage OpenHarmony application's activity with rust, be similar to [android-activity](https://github.com/rust-mobile/android-activity). +`openharmony-ability` provides Rust-side lifecycle management and ArkTS-side entry helpers for OpenHarmony applications, similar in spirit to `android-activity`. ## Architecture -The architecture of OpenHarmony is similar to Node.js, where we need to manage the application's lifecycle via callbacks. Hence, there are a few key points to keep in mind. +OpenHarmony applications are driven by callbacks, so there are two important constraints: -1. Don't block the main thread as it can lead to application freezing and crashing. -2. openharmony-ability's run_loop doesn't retain the resource and ownership, so if you create a new resource, you should leak it to prevent NULL pointer. +1. Do not block the main thread. +2. `run_loop` does not retain user resources for you, so resources that must outlive setup need stable ownership. ![Architecture](/fixtures/openharmony-ability.png) -We provide some packages or crates to help you develop OpenHarmony application with Rust. +## Repository Layout -### ArkTS - -We need a entry-point to start the application, and we use ArkTS to manage the application's lifecycle. - -- [@ohos-rs/ability](./package/README.md) - All of ability need to extend `RustAbility` and all lifecycle need to call `super.xx` to make sure the ability can work normally. - -### Rust - -- [openharmony-ability](./crates/ability/README.md) - Basic crate to manage the application's lifecycle. - -- [openharmony-ability-derive](./crates/derive/README.md) - Macro to generate the ability's implementation. +- `crates/ability` — Rust lifecycle/runtime support +- `crates/derive` — `#[ability]` macro +- `ability_rust` — ArkTS package source for `@ohos-rs/ability` +- `package` — packaged ohpm artifact source +- `demo` — unified Harmony demo project +- `rust_example/demo_native` — unified native demo implementation ## Usage -1. use `ohrs` to init project and add `openharmony-ability` dependencies. - - ```bash - ohrs init hello - - cargo add openharmony-ability - cargo add openharmony-ability-derive - ``` - - If you already have a rust project, you can add the dependencies into your project. And you need to add the following dependencies into your project which is used to generate some codes to bridge ArkTS. - - ```bash - cargo add napi-ohos - cargo add napi-derive-ohos - cargo add napi-build-ohos - ``` - -2. Add the follow code to `lib.rs`. - - ```rust - use ohos_hilog_binding::hilog_info; - use openharmony_ability::App; - use openharmony_ability_derive::ability; - - #[ability] - fn openharmony_app(app: App) { - app.run_loop(|types| { - hilog_info!(format!("ohos-rs macro: {:?}", types.as_str()).as_str()); - }); - } - ``` - - > Note: `ohos_hilog_binding` is a optional dependency and you can add or remove it. - -3. Add `@ohos-rs/ability` to your `OpenHarmony/HarmonyNext` project. - - ```bash - ohpm install @ohos-rs/ability - ``` - -4. change the `EntryAbility.ets` file to the follow code: - - ```ts - import { RustAbility } from "@ohos-rs/ability"; - import Want from "@ohos.app.ability.Want"; - import { AbilityConstant } from "@kit.AbilityKit"; - - export default class EntryAbility extends RustAbility { - public moduleName: string = "example"; - - async onCreate( - want: Want, - launchParam: AbilityConstant.LaunchParam - ): Promise { - // Note: you should call super.onCreate to make sure the ability can work normally. - super.onCreate(want, launchParam); - } - } - ``` - -5. Set `moduleName` to the bare module name, for example `hello`. The framework will load `libhello.so` internally. You can also pass `string[]` when one ability needs to initialize multiple native modules. - -6. Build your rust project and copy the dynamic library to (Open-)Harmony(Next) project. - -7. Now, you can enjoy it. - -## Example - -See example with [example](./example/src/lib.rs) +1. Add Rust dependencies: + +```bash +cargo add openharmony-ability +cargo add openharmony-ability-derive +cargo add napi-ohos +cargo add napi-derive-ohos +cargo add napi-build-ohos +``` + +2. Implement your native entry: + +```rust +use ohos_hilog_binding::hilog_info; +use openharmony_ability::OpenHarmonyApp; +use openharmony_ability_derive::ability; + +#[ability] +fn openharmony_app(app: OpenHarmonyApp) { + app.run_loop(|event| { + hilog_info!(format!("event: {:?}", event.as_str()).as_str()); + }); +} +``` + +3. Use `RustAbility` in ArkTS: + +```ts +import { RustAbility } from "@ohos-rs/ability"; +import Want from "@ohos.app.ability.Want"; +import { AbilityConstant } from "@kit.AbilityKit"; + +export default class EntryAbility extends RustAbility { + public moduleName: string = "demo_native"; + + async onCreate( + want: Want, + launchParam: AbilityConstant.LaunchParam + ): Promise { + super.onCreate(want, launchParam); + } +} +``` + +4. Build the native module: + +```bash +cd rust_example/demo_native +ohrs build --arch arm64 +``` + +## Demo + +- Harmony demo project: `demo` +- Native demo module: `rust_example/demo_native/src/lib.rs` +- ArkTS package source: `ability_rust` ## License diff --git a/rust_ability/ability_rust/.gitignore b/ability_rust/.gitignore similarity index 100% rename from rust_ability/ability_rust/.gitignore rename to ability_rust/.gitignore diff --git a/rust_ability/ability_rust/BuildProfile.ets b/ability_rust/BuildProfile.ets similarity index 100% rename from rust_ability/ability_rust/BuildProfile.ets rename to ability_rust/BuildProfile.ets diff --git a/rust_ability/ability_rust/LICENSE b/ability_rust/LICENSE similarity index 100% rename from rust_ability/ability_rust/LICENSE rename to ability_rust/LICENSE diff --git a/rust_ability/ability_rust/README.md b/ability_rust/README.md similarity index 92% rename from rust_ability/ability_rust/README.md rename to ability_rust/README.md index a189ace..69108a9 100644 --- a/rust_ability/ability_rust/README.md +++ b/ability_rust/README.md @@ -19,15 +19,15 @@ We provide some packages or crates to help you develop OpenHarmony application w We need a entry-point to start the application, and we use ArkTS to manage the application's lifecycle. -- [@ohos-rs/ability](./package/README.md) +- [@ohos-rs/ability](../package/README.md) All of ability need to extend `RustAbility` and all lifecycle need to call `super.xx` to make sure the ability can work normally. ### Rust -- [openharmony-ability](./crates/ability/README.md) +- [openharmony-ability](../crates/ability/README.md) Basic crate to manage the application's lifecycle. -- [openharmony-ability-derive](./crates/derive/README.md) +- [openharmony-ability-derive](../crates/derive/README.md) Macro to generate the ability's implementation. ## Usage @@ -92,4 +92,4 @@ We need a entry-point to start the application, and we use ArkTS to manage the a ## Example -See example with [example](./example/src/lib.rs) +- Unified native example: `../rust_example/demo_native/src/lib.rs` diff --git a/rust_ability/ability_rust/build-profile.json5 b/ability_rust/build-profile.json5 similarity index 100% rename from rust_ability/ability_rust/build-profile.json5 rename to ability_rust/build-profile.json5 diff --git a/rust_ability/ability_rust/consumer-rules.txt b/ability_rust/consumer-rules.txt similarity index 100% rename from rust_ability/ability_rust/consumer-rules.txt rename to ability_rust/consumer-rules.txt diff --git a/rust_ability/ability_rust/hvigorfile.ts b/ability_rust/hvigorfile.ts similarity index 100% rename from rust_ability/ability_rust/hvigorfile.ts rename to ability_rust/hvigorfile.ts diff --git a/rust_ability/ability_rust/index.ets b/ability_rust/index.ets similarity index 100% rename from rust_ability/ability_rust/index.ets rename to ability_rust/index.ets diff --git a/rust_ability/ability_rust/obfuscation-rules.txt b/ability_rust/obfuscation-rules.txt similarity index 100% rename from rust_ability/ability_rust/obfuscation-rules.txt rename to ability_rust/obfuscation-rules.txt diff --git a/rust_ability/ability_rust/oh-package-lock.json5 b/ability_rust/oh-package-lock.json5 similarity index 100% rename from rust_ability/ability_rust/oh-package-lock.json5 rename to ability_rust/oh-package-lock.json5 diff --git a/rust_ability/ability_rust/oh-package.json5 b/ability_rust/oh-package.json5 similarity index 100% rename from rust_ability/ability_rust/oh-package.json5 rename to ability_rust/oh-package.json5 diff --git a/rust_ability/ability_rust/src/main/cpp/CMakeLists.txt b/ability_rust/src/main/cpp/CMakeLists.txt similarity index 100% rename from rust_ability/ability_rust/src/main/cpp/CMakeLists.txt rename to ability_rust/src/main/cpp/CMakeLists.txt diff --git a/rust_ability/ability_rust/src/main/cpp/napi_init.cpp b/ability_rust/src/main/cpp/napi_init.cpp similarity index 100% rename from rust_ability/ability_rust/src/main/cpp/napi_init.cpp rename to ability_rust/src/main/cpp/napi_init.cpp diff --git a/rust_ability/ability_rust/src/main/cpp/types/libability_rust/Index.d.ts b/ability_rust/src/main/cpp/types/libability_rust/Index.d.ts similarity index 100% rename from rust_ability/ability_rust/src/main/cpp/types/libability_rust/Index.d.ts rename to ability_rust/src/main/cpp/types/libability_rust/Index.d.ts diff --git a/rust_ability/ability_rust/src/main/cpp/types/libability_rust/oh-package.json5 b/ability_rust/src/main/cpp/types/libability_rust/oh-package.json5 similarity index 100% rename from rust_ability/ability_rust/src/main/cpp/types/libability_rust/oh-package.json5 rename to ability_rust/src/main/cpp/types/libability_rust/oh-package.json5 diff --git a/rust_ability/ability_rust/src/main/ets/ability/RustAbility.ets b/ability_rust/src/main/ets/ability/RustAbility.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/ability/RustAbility.ets rename to ability_rust/src/main/ets/ability/RustAbility.ets diff --git a/rust_ability/ability_rust/src/main/ets/ability/type.ets b/ability_rust/src/main/ets/ability/type.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/ability/type.ets rename to ability_rust/src/main/ets/ability/type.ets diff --git a/rust_ability/ability_rust/src/main/ets/components/DefaultXComponent.ets b/ability_rust/src/main/ets/components/DefaultXComponent.ets similarity index 99% rename from rust_ability/ability_rust/src/main/ets/components/DefaultXComponent.ets rename to ability_rust/src/main/ets/components/DefaultXComponent.ets index 29b8a06..03949de 100644 --- a/rust_ability/ability_rust/src/main/ets/components/DefaultXComponent.ets +++ b/ability_rust/src/main/ets/components/DefaultXComponent.ets @@ -16,7 +16,6 @@ import { } from "../webview/DefaultWebview"; export const RouteName = "RustAbility"; - @Component export struct DefaultXComponent { moduleName: string = ""; diff --git a/rust_ability/ability_rust/src/main/ets/components/MainPage.ets b/ability_rust/src/main/ets/components/MainPage.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/components/MainPage.ets rename to ability_rust/src/main/ets/components/MainPage.ets diff --git a/rust_ability/ability_rust/src/main/ets/helper/index.ets b/ability_rust/src/main/ets/helper/index.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/helper/index.ets rename to ability_rust/src/main/ets/helper/index.ets diff --git a/rust_ability/ability_rust/src/main/ets/helper/loadable.ets b/ability_rust/src/main/ets/helper/loadable.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/helper/loadable.ets rename to ability_rust/src/main/ets/helper/loadable.ets diff --git a/rust_ability/ability_rust/src/main/ets/helper/object.ts b/ability_rust/src/main/ets/helper/object.ts similarity index 100% rename from rust_ability/ability_rust/src/main/ets/helper/object.ts rename to ability_rust/src/main/ets/helper/object.ts diff --git a/rust_ability/ability_rust/src/main/ets/helper/os.ets b/ability_rust/src/main/ets/helper/os.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/helper/os.ets rename to ability_rust/src/main/ets/helper/os.ets diff --git a/rust_ability/ability_rust/src/main/ets/helper/permission.ets b/ability_rust/src/main/ets/helper/permission.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/helper/permission.ets rename to ability_rust/src/main/ets/helper/permission.ets diff --git a/rust_ability/ability_rust/src/main/ets/helper/random.ets b/ability_rust/src/main/ets/helper/random.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/helper/random.ets rename to ability_rust/src/main/ets/helper/random.ets diff --git a/rust_ability/ability_rust/src/main/ets/webview/DefaultWebview.ets b/ability_rust/src/main/ets/webview/DefaultWebview.ets similarity index 97% rename from rust_ability/ability_rust/src/main/ets/webview/DefaultWebview.ets rename to ability_rust/src/main/ets/webview/DefaultWebview.ets index 40f9030..a931413 100644 --- a/rust_ability/ability_rust/src/main/ets/webview/DefaultWebview.ets +++ b/ability_rust/src/main/ets/webview/DefaultWebview.ets @@ -109,15 +109,12 @@ export class RustWebviewNodeController extends NodeController { return getCookies(url) as string; }; const loadUrl = (url: string, header?: Record) => { - const headers = Object.keys((header || {}) as Record).reduce( - (t, i) => { - if (!!header![i]) { - t.push({ headerKey: i, headerValue: header![i] }); - } - return t; - }, - [] as Array, - ); + const headers = Object.keys((header || {}) as Record).reduce((t, i) => { + if (!!header![i]) { + t.push({ headerKey: i, headerValue: header![i] }); + } + return t; + }, [] as Array); controller.loadUrl(url, headers); }; diff --git a/rust_ability/ability_rust/src/main/ets/webview/Utils.ets b/ability_rust/src/main/ets/webview/Utils.ets similarity index 100% rename from rust_ability/ability_rust/src/main/ets/webview/Utils.ets rename to ability_rust/src/main/ets/webview/Utils.ets diff --git a/rust_ability/ability_rust/src/main/module.json5 b/ability_rust/src/main/module.json5 similarity index 100% rename from rust_ability/ability_rust/src/main/module.json5 rename to ability_rust/src/main/module.json5 diff --git a/rust_ability/ability_rust/src/main/resources/base/element/string.json b/ability_rust/src/main/resources/base/element/string.json similarity index 100% rename from rust_ability/ability_rust/src/main/resources/base/element/string.json rename to ability_rust/src/main/resources/base/element/string.json diff --git a/rust_ability/ability_rust/src/main/resources/en_US/element/string.json b/ability_rust/src/main/resources/en_US/element/string.json similarity index 100% rename from rust_ability/ability_rust/src/main/resources/en_US/element/string.json rename to ability_rust/src/main/resources/en_US/element/string.json diff --git a/rust_ability/ability_rust/src/main/resources/zh_CN/element/string.json b/ability_rust/src/main/resources/zh_CN/element/string.json similarity index 100% rename from rust_ability/ability_rust/src/main/resources/zh_CN/element/string.json rename to ability_rust/src/main/resources/zh_CN/element/string.json diff --git a/rust_ability/ability_rust/src/ohosTest/ets/test/Ability.test.ets b/ability_rust/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from rust_ability/ability_rust/src/ohosTest/ets/test/Ability.test.ets rename to ability_rust/src/ohosTest/ets/test/Ability.test.ets diff --git a/rust_ability/ability_rust/src/ohosTest/ets/test/List.test.ets b/ability_rust/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from rust_ability/ability_rust/src/ohosTest/ets/test/List.test.ets rename to ability_rust/src/ohosTest/ets/test/List.test.ets diff --git a/rust_ability/ability_rust/src/ohosTest/module.json5 b/ability_rust/src/ohosTest/module.json5 similarity index 100% rename from rust_ability/ability_rust/src/ohosTest/module.json5 rename to ability_rust/src/ohosTest/module.json5 diff --git a/rust_ability/ability_rust/src/test/List.test.ets b/ability_rust/src/test/List.test.ets similarity index 100% rename from rust_ability/ability_rust/src/test/List.test.ets rename to ability_rust/src/test/List.test.ets diff --git a/rust_ability/ability_rust/src/test/LocalUnit.test.ets b/ability_rust/src/test/LocalUnit.test.ets similarity index 100% rename from rust_ability/ability_rust/src/test/LocalUnit.test.ets rename to ability_rust/src/test/LocalUnit.test.ets diff --git a/crates/ability/Cargo.toml b/crates/ability/Cargo.toml index fe99fac..b12db9f 100644 --- a/crates/ability/Cargo.toml +++ b/crates/ability/Cargo.toml @@ -15,7 +15,7 @@ webview = ["dep:ohos-web-binding", "dep:http"] futures-channel = "0.3" # for napi binding -napi-ohos = { workspace = true, default-features = false, features = ["napi8"] } +napi-ohos = { workspace = true, features = ["napi8"] } napi-derive-ohos = { workspace = true } # for xcomponent native render diff --git a/xcomponent_example/.gitignore b/demo/.gitignore similarity index 100% rename from xcomponent_example/.gitignore rename to demo/.gitignore diff --git a/xcomponent_example/AppScope/app.json5 b/demo/AppScope/app.json5 similarity index 77% rename from xcomponent_example/AppScope/app.json5 rename to demo/AppScope/app.json5 index b80212c..45efd8b 100644 --- a/xcomponent_example/AppScope/app.json5 +++ b/demo/AppScope/app.json5 @@ -1,6 +1,6 @@ { "app": { - "bundleName": "com.ohos.activity_example", + "bundleName": "com.ohos.ability_demo", "vendor": "example", "versionCode": 1000000, "versionName": "1.0.0", diff --git a/xcomponent_example/AppScope/resources/base/element/string.json b/demo/AppScope/resources/base/element/string.json similarity index 64% rename from xcomponent_example/AppScope/resources/base/element/string.json rename to demo/AppScope/resources/base/element/string.json index c0fcd47..e58ffe2 100644 --- a/xcomponent_example/AppScope/resources/base/element/string.json +++ b/demo/AppScope/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "app_name", - "value": "example" + "value": "ability_demo" } ] -} \ No newline at end of file +} diff --git a/xcomponent_example/AppScope/resources/base/media/app_icon.png b/demo/AppScope/resources/base/media/app_icon.png similarity index 100% rename from xcomponent_example/AppScope/resources/base/media/app_icon.png rename to demo/AppScope/resources/base/media/app_icon.png diff --git a/xcomponent_example/build-profile.json5 b/demo/build-profile.json5 similarity index 94% rename from xcomponent_example/build-profile.json5 rename to demo/build-profile.json5 index 1d16024..2bc8723 100644 --- a/xcomponent_example/build-profile.json5 +++ b/demo/build-profile.json5 @@ -39,7 +39,7 @@ }, { "name": "ability_rust", - "srcPath": "../rust_ability/ability_rust" + "srcPath": "../ability_rust" } ] } diff --git a/xcomponent_example/code-linter.json5 b/demo/code-linter.json5 similarity index 100% rename from xcomponent_example/code-linter.json5 rename to demo/code-linter.json5 diff --git a/rust_ability/entry/.gitignore b/demo/entry/.gitignore similarity index 100% rename from rust_ability/entry/.gitignore rename to demo/entry/.gitignore diff --git a/rust_ability/entry/build-profile.json5 b/demo/entry/build-profile.json5 similarity index 100% rename from rust_ability/entry/build-profile.json5 rename to demo/entry/build-profile.json5 diff --git a/rust_ability/entry/hvigorfile.ts b/demo/entry/hvigorfile.ts similarity index 100% rename from rust_ability/entry/hvigorfile.ts rename to demo/entry/hvigorfile.ts diff --git a/xcomponent_example/entry/libs/arm64-v8a/.gitkeep b/demo/entry/libs/arm64-v8a/.gitkeep similarity index 100% rename from xcomponent_example/entry/libs/arm64-v8a/.gitkeep rename to demo/entry/libs/arm64-v8a/.gitkeep diff --git a/rust_ability/entry/obfuscation-rules.txt b/demo/entry/obfuscation-rules.txt similarity index 100% rename from rust_ability/entry/obfuscation-rules.txt rename to demo/entry/obfuscation-rules.txt diff --git a/webview_example/entry/oh-package-lock.json5 b/demo/entry/oh-package-lock.json5 similarity index 61% rename from webview_example/entry/oh-package-lock.json5 rename to demo/entry/oh-package-lock.json5 index f8a54f4..6901d4a 100644 --- a/webview_example/entry/oh-package-lock.json5 +++ b/demo/entry/oh-package-lock.json5 @@ -6,14 +6,14 @@ "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { - "@ohos-rs/ability@../../rust_ability/ability_rust": "@ohos-rs/ability@../../rust_ability/ability_rust", - "libability_rust.so@../../rust_ability/ability_rust/src/main/cpp/types/libability_rust": "libability_rust.so@../../rust_ability/ability_rust/src/main/cpp/types/libability_rust", - "libark_web.so@src/main/cpp/types/libark_web": "libark_web.so@src/main/cpp/types/libark_web", + "@ohos-rs/ability@../../ability_rust": "@ohos-rs/ability@../../ability_rust", + "libability_rust.so@../../ability_rust/src/main/cpp/types/libability_rust": "libability_rust.so@../../ability_rust/src/main/cpp/types/libability_rust", "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry", - "libwebview_example.so@src/main/cpp/types/libwebview_example": "libwebview_example.so@src/main/cpp/types/libwebview_example" + "libdemo_native.so@src/main/cpp/types/libdemo_native": "libdemo_native.so@src/main/cpp/types/libdemo_native", + "libark_web.so@src/main/cpp/types/libark_web": "libark_web.so@src/main/cpp/types/libark_web" }, "packages": { - "@ohos-rs/ability@../../rust_ability/ability_rust": { + "@ohos-rs/ability@../../ability_rust": { "name": "@ohos-rs/ability", "version": "0.0.1", "resolved": "", @@ -22,29 +22,29 @@ "libability_rust.so": "file:./src/main/cpp/types/libability_rust" } }, - "libability_rust.so@../../rust_ability/ability_rust/src/main/cpp/types/libability_rust": { + "libability_rust.so@../../ability_rust/src/main/cpp/types/libability_rust": { "name": "libability_rust.so", "version": "1.0.0", "resolved": "", "registryType": "local" }, - "libark_web.so@src/main/cpp/types/libark_web": { - "name": "libark_web.so", + "libentry.so@src/main/cpp/types/libentry": { + "name": "libentry.so", "version": "1.0.0", "resolved": "", "registryType": "local" }, - "libentry.so@src/main/cpp/types/libentry": { - "name": "libentry.so", + "libdemo_native.so@src/main/cpp/types/libdemo_native": { + "name": "libdemo_native.so", "version": "1.0.0", "resolved": "", "registryType": "local" }, - "libwebview_example.so@src/main/cpp/types/libwebview_example": { - "name": "libwebview_example.so", + "libark_web.so@src/main/cpp/types/libark_web": { + "name": "libark_web.so", "version": "1.0.0", "resolved": "", "registryType": "local" } } -} \ No newline at end of file +} diff --git a/webview_example/entry/oh-package.json5 b/demo/entry/oh-package.json5 similarity index 67% rename from webview_example/entry/oh-package.json5 rename to demo/entry/oh-package.json5 index 6b0e59f..c40f82e 100644 --- a/webview_example/entry/oh-package.json5 +++ b/demo/entry/oh-package.json5 @@ -7,8 +7,8 @@ "license": "", "dependencies": { "libentry.so": "file:./src/main/cpp/types/libentry", - "@ohos-rs/ability": "file:../../rust_ability/ability_rust", + "libdemo_native.so": "file:./src/main/cpp/types/libdemo_native", "libark_web.so": "file:./src/main/cpp/types/libark_web", - "libwebview_example.so": "file:./src/main/cpp/types/libwebview_example" + "@ohos-rs/ability": "file:../../ability_rust" } } diff --git a/xcomponent_example/entry/src/main/cpp/CMakeLists.txt b/demo/entry/src/main/cpp/CMakeLists.txt similarity index 100% rename from xcomponent_example/entry/src/main/cpp/CMakeLists.txt rename to demo/entry/src/main/cpp/CMakeLists.txt diff --git a/rust_ability/entry/src/main/cpp/napi_init.cpp b/demo/entry/src/main/cpp/napi_init.cpp similarity index 100% rename from rust_ability/entry/src/main/cpp/napi_init.cpp rename to demo/entry/src/main/cpp/napi_init.cpp diff --git a/webview_example/entry/src/main/cpp/types/libark_web/Index.d.ts b/demo/entry/src/main/cpp/types/libark_web/Index.d.ts similarity index 100% rename from webview_example/entry/src/main/cpp/types/libark_web/Index.d.ts rename to demo/entry/src/main/cpp/types/libark_web/Index.d.ts diff --git a/webview_example/entry/src/main/cpp/types/libark_web/oh-package.json5 b/demo/entry/src/main/cpp/types/libark_web/oh-package.json5 similarity index 100% rename from webview_example/entry/src/main/cpp/types/libark_web/oh-package.json5 rename to demo/entry/src/main/cpp/types/libark_web/oh-package.json5 diff --git a/demo/entry/src/main/cpp/types/libdemo_native/Index.d.ts b/demo/entry/src/main/cpp/types/libdemo_native/Index.d.ts new file mode 100644 index 0000000..1105ef3 --- /dev/null +++ b/demo/entry/src/main/cpp/types/libdemo_native/Index.d.ts @@ -0,0 +1,20 @@ +/* auto-generated by OHOS-RS */ +/* eslint-disable */ + +export declare function demoRequestPermissionFromMainThread(): Promise>; + +export declare function handleChange(): void; + +export declare function init(context?: AbilityInitContext | undefined | null): ApplicationLifecycle; + +export declare function onBackPressIntercept(): boolean; + +export declare function registerCustomProtocol(): void; + +export declare function render(helper: object, slot: NodeContent): void; + +export declare function setBackgroundColor(color: string): void; + +export declare function setVisible(visible: boolean): void; + +export declare function toggleBackPressIntercept(): boolean; diff --git a/xcomponent_example/entry/src/main/cpp/types/libexample/oh-package.json5 b/demo/entry/src/main/cpp/types/libdemo_native/oh-package.json5 similarity index 78% rename from xcomponent_example/entry/src/main/cpp/types/libexample/oh-package.json5 rename to demo/entry/src/main/cpp/types/libdemo_native/oh-package.json5 index 0d52799..9b90341 100644 --- a/xcomponent_example/entry/src/main/cpp/types/libexample/oh-package.json5 +++ b/demo/entry/src/main/cpp/types/libdemo_native/oh-package.json5 @@ -1,5 +1,5 @@ { - "name": "libexample.so", + "name": "libdemo_native.so", "types": "./Index.d.ts", "version": "1.0.0", "description": "Please describe the basic information." diff --git a/rust_ability/entry/src/main/cpp/types/libentry/Index.d.ts b/demo/entry/src/main/cpp/types/libentry/Index.d.ts similarity index 100% rename from rust_ability/entry/src/main/cpp/types/libentry/Index.d.ts rename to demo/entry/src/main/cpp/types/libentry/Index.d.ts diff --git a/rust_ability/entry/src/main/cpp/types/libentry/oh-package.json5 b/demo/entry/src/main/cpp/types/libentry/oh-package.json5 similarity index 100% rename from rust_ability/entry/src/main/cpp/types/libentry/oh-package.json5 rename to demo/entry/src/main/cpp/types/libentry/oh-package.json5 diff --git a/webview_example/entry/src/main/ets/entryability/EntryAbility.ets b/demo/entry/src/main/ets/entryability/EntryAbility.ets similarity index 93% rename from webview_example/entry/src/main/ets/entryability/EntryAbility.ets rename to demo/entry/src/main/ets/entryability/EntryAbility.ets index bfb1dab..9d2ad75 100644 --- a/webview_example/entry/src/main/ets/entryability/EntryAbility.ets +++ b/demo/entry/src/main/ets/entryability/EntryAbility.ets @@ -4,7 +4,7 @@ import { AbilityConstant } from "@kit.AbilityKit"; import window from "@ohos.window"; export default class EntryAbility extends RustAbility { - public moduleName: string = "webview_example"; + public moduleName: string = "demo_native"; public defaultPage: boolean = false; async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): Promise { diff --git a/xcomponent_example/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/demo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets similarity index 100% rename from xcomponent_example/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets rename to demo/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets diff --git a/demo/entry/src/main/ets/pages/Index.ets b/demo/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000..c771270 --- /dev/null +++ b/demo/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,96 @@ +import { DefaultXComponent } from "@ohos-rs/ability"; +import { + demoRequestPermissionFromMainThread, + handleChange, + setBackgroundColor, + setVisible, + toggleBackPressIntercept, +} from "libdemo_native.so"; + +const MODULE_NAME = "demo_native"; + +@Entry +@Component +struct Index { + @State currentDemo: number = 0; + @State interceptEnabled: boolean = true; + @State webviewVisible: boolean = true; + + async handlePermissionDemo() { + const result: number[] = await demoRequestPermissionFromMainThread(); + console.log(`permission result: ${result}`); + } + + handleToggleBackIntercept() { + this.interceptEnabled = toggleBackPressIntercept(); + console.log(`backPressIntercept=${this.interceptEnabled}`); + } + + handleToggleWebviewVisible() { + const nextVisible = !this.webviewVisible; + setVisible(nextVisible); + this.webviewVisible = nextVisible; + } + + @Builder + DemoSwitcher(label: string, index: number) { + Button(label) + .type(this.currentDemo === index ? ButtonType.Capsule : ButtonType.Normal) + .onClick(() => { + this.currentDemo = index; + }); + } + + @Builder + XComponentDemo() { + Column({ space: 12 }) { + Button("request permission demo") + .onClick(() => this.handlePermissionDemo()) + Button(this.interceptEnabled ? "back intercept: ON" : "back intercept: OFF") + .onClick(() => this.handleToggleBackIntercept()) + Text("Swipe back to test intercept behavior.") + DefaultXComponent({ moduleName: MODULE_NAME }) + } + .width("100%") + .height("100%"); + } + + @Builder + WebviewDemo() { + Column({ space: 12 }) { + Row({ space: 12 }) { + Button("create webview") + .onClick(() => { + handleChange(); + }) + Button("background red") + .onClick(() => { + setBackgroundColor("red"); + }) + Button(this.webviewVisible ? "hide webview" : "show webview") + .onClick(() => this.handleToggleWebviewVisible()) + } + DefaultXComponent({ moduleName: MODULE_NAME }) + } + .width("100%") + .height("100%"); + } + + build() { + Column({ space: 16 }) { + Row({ space: 12 }) { + this.DemoSwitcher("XComponent demo", 0) + this.DemoSwitcher("WebView demo", 1) + }.width("100%") + if (this.currentDemo === 0) { + this.XComponentDemo(); + } + if (this.currentDemo !== 0) { + this.WebviewDemo(); + } + } + .width("100%") + .height("100%") + .padding(16); + } +} diff --git a/xcomponent_example/entry/src/main/module.json5 b/demo/entry/src/main/module.json5 similarity index 93% rename from xcomponent_example/entry/src/main/module.json5 rename to demo/entry/src/main/module.json5 index 9578c76..7e2ae27 100644 --- a/xcomponent_example/entry/src/main/module.json5 +++ b/demo/entry/src/main/module.json5 @@ -56,8 +56,11 @@ }, { "name": "ohos.permission.MICROPHONE", - "reason": "$string:page_show", + "reason": "$string:module_desc", "usedScene": {} + }, + { + "name": "ohos.permission.INTERNET" } ] } diff --git a/rust_ability/entry/src/main/resources/base/element/color.json b/demo/entry/src/main/resources/base/element/color.json similarity index 100% rename from rust_ability/entry/src/main/resources/base/element/color.json rename to demo/entry/src/main/resources/base/element/color.json diff --git a/xcomponent_example/entry/src/main/resources/en_US/element/string.json b/demo/entry/src/main/resources/base/element/string.json similarity index 60% rename from xcomponent_example/entry/src/main/resources/en_US/element/string.json rename to demo/entry/src/main/resources/base/element/string.json index f945955..f8238a8 100644 --- a/xcomponent_example/entry/src/main/resources/en_US/element/string.json +++ b/demo/entry/src/main/resources/base/element/string.json @@ -2,15 +2,15 @@ "string": [ { "name": "module_desc", - "value": "module description" + "value": "Rust ability demo entry" }, { "name": "EntryAbility_desc", - "value": "description" + "value": "Unified native demo" }, { "name": "EntryAbility_label", - "value": "label" + "value": "demo" } ] -} \ No newline at end of file +} diff --git a/xcomponent_example/entry/src/main/resources/base/media/background.png b/demo/entry/src/main/resources/base/media/background.png similarity index 100% rename from xcomponent_example/entry/src/main/resources/base/media/background.png rename to demo/entry/src/main/resources/base/media/background.png diff --git a/xcomponent_example/entry/src/main/resources/base/media/foreground.png b/demo/entry/src/main/resources/base/media/foreground.png similarity index 100% rename from xcomponent_example/entry/src/main/resources/base/media/foreground.png rename to demo/entry/src/main/resources/base/media/foreground.png diff --git a/rust_ability/AppScope/resources/base/media/layered_image.json b/demo/entry/src/main/resources/base/media/layered_image.json similarity index 100% rename from rust_ability/AppScope/resources/base/media/layered_image.json rename to demo/entry/src/main/resources/base/media/layered_image.json diff --git a/rust_ability/entry/src/main/resources/base/media/startIcon.png b/demo/entry/src/main/resources/base/media/startIcon.png similarity index 100% rename from rust_ability/entry/src/main/resources/base/media/startIcon.png rename to demo/entry/src/main/resources/base/media/startIcon.png diff --git a/rust_ability/entry/src/main/resources/base/profile/backup_config.json b/demo/entry/src/main/resources/base/profile/backup_config.json similarity index 100% rename from rust_ability/entry/src/main/resources/base/profile/backup_config.json rename to demo/entry/src/main/resources/base/profile/backup_config.json diff --git a/rust_ability/entry/src/main/resources/base/profile/main_pages.json b/demo/entry/src/main/resources/base/profile/main_pages.json similarity index 100% rename from rust_ability/entry/src/main/resources/base/profile/main_pages.json rename to demo/entry/src/main/resources/base/profile/main_pages.json diff --git a/webview_example/entry/src/main/resources/base/element/string.json b/demo/entry/src/main/resources/en_US/element/string.json similarity index 60% rename from webview_example/entry/src/main/resources/base/element/string.json rename to demo/entry/src/main/resources/en_US/element/string.json index f945955..f8238a8 100644 --- a/webview_example/entry/src/main/resources/base/element/string.json +++ b/demo/entry/src/main/resources/en_US/element/string.json @@ -2,15 +2,15 @@ "string": [ { "name": "module_desc", - "value": "module description" + "value": "Rust ability demo entry" }, { "name": "EntryAbility_desc", - "value": "description" + "value": "Unified native demo" }, { "name": "EntryAbility_label", - "value": "label" + "value": "demo" } ] -} \ No newline at end of file +} diff --git a/rust_ability/entry/src/main/resources/base/element/string.json b/demo/entry/src/main/resources/zh_CN/element/string.json similarity index 59% rename from rust_ability/entry/src/main/resources/base/element/string.json rename to demo/entry/src/main/resources/zh_CN/element/string.json index f945955..c10d87d 100644 --- a/rust_ability/entry/src/main/resources/base/element/string.json +++ b/demo/entry/src/main/resources/zh_CN/element/string.json @@ -2,15 +2,15 @@ "string": [ { "name": "module_desc", - "value": "module description" + "value": "Rust Ability Demo 入口" }, { "name": "EntryAbility_desc", - "value": "description" + "value": "收敛后的 Native Demo" }, { "name": "EntryAbility_label", - "value": "label" + "value": "demo" } ] -} \ No newline at end of file +} diff --git a/rust_ability/entry/src/mock/Libentry.mock.ets b/demo/entry/src/mock/Libentry.mock.ets similarity index 100% rename from rust_ability/entry/src/mock/Libentry.mock.ets rename to demo/entry/src/mock/Libentry.mock.ets diff --git a/rust_ability/entry/src/mock/mock-config.json5 b/demo/entry/src/mock/mock-config.json5 similarity index 100% rename from rust_ability/entry/src/mock/mock-config.json5 rename to demo/entry/src/mock/mock-config.json5 diff --git a/rust_ability/entry/src/ohosTest/ets/test/Ability.test.ets b/demo/entry/src/ohosTest/ets/test/Ability.test.ets similarity index 100% rename from rust_ability/entry/src/ohosTest/ets/test/Ability.test.ets rename to demo/entry/src/ohosTest/ets/test/Ability.test.ets diff --git a/rust_ability/entry/src/ohosTest/ets/test/List.test.ets b/demo/entry/src/ohosTest/ets/test/List.test.ets similarity index 100% rename from rust_ability/entry/src/ohosTest/ets/test/List.test.ets rename to demo/entry/src/ohosTest/ets/test/List.test.ets diff --git a/rust_ability/entry/src/ohosTest/module.json5 b/demo/entry/src/ohosTest/module.json5 similarity index 100% rename from rust_ability/entry/src/ohosTest/module.json5 rename to demo/entry/src/ohosTest/module.json5 diff --git a/rust_ability/entry/src/test/List.test.ets b/demo/entry/src/test/List.test.ets similarity index 100% rename from rust_ability/entry/src/test/List.test.ets rename to demo/entry/src/test/List.test.ets diff --git a/rust_ability/entry/src/test/LocalUnit.test.ets b/demo/entry/src/test/LocalUnit.test.ets similarity index 100% rename from rust_ability/entry/src/test/LocalUnit.test.ets rename to demo/entry/src/test/LocalUnit.test.ets diff --git a/rust_ability/hvigor/hvigor-config.json5 b/demo/hvigor/hvigor-config.json5 similarity index 100% rename from rust_ability/hvigor/hvigor-config.json5 rename to demo/hvigor/hvigor-config.json5 diff --git a/rust_ability/hvigorfile.ts b/demo/hvigorfile.ts similarity index 100% rename from rust_ability/hvigorfile.ts rename to demo/hvigorfile.ts diff --git a/xcomponent_example/oh-package-lock.json5 b/demo/oh-package-lock.json5 similarity index 100% rename from xcomponent_example/oh-package-lock.json5 rename to demo/oh-package-lock.json5 diff --git a/xcomponent_example/oh-package.json5 b/demo/oh-package.json5 similarity index 100% rename from xcomponent_example/oh-package.json5 rename to demo/oh-package.json5 diff --git a/package/README.md b/package/README.md index 8f4d7cb..ff31cc5 100644 --- a/package/README.md +++ b/package/README.md @@ -1,29 +1,24 @@ # @ohos-rs/ability -This package provides a set of components and APIs for building OpenHarmony activities and it helps us create a application entry for rust application. - -For OpenHarmony/HarmonyNext development, our application entry must be a ArkTS file and we need to forward some lifecycle event to rust code. +`@ohos-rs/ability` provides ArkTS-side helpers for loading Rust native modules and forwarding OpenHarmony lifecycle events into Rust. ## Install -``` +```bash ohpm install @ohos-rs/ability ``` -## API and Components - -### RustAbility +## API -The Activity component is a wrapper of the OpenHarmony Activity class. It will load the native code and forward the lifecycle event to rust code by default. +### `RustAbility` -If you want to use rust development OpenHarmony/HarmonyNext application, you must use this component to create your application entry. +`RustAbility` wraps `UIAbility` and initializes one or more Rust native modules. ```ts -// ets/entryability/EntryAbility.ets import { RustAbility } from "@ohos-rs/ability"; -export default class MyAbility extends RustAbility { - public moduleName: string = "hello"; +export default class EntryAbility extends RustAbility { + public moduleName: string = "demo_native"; onCreate() { super.onCreate(); @@ -31,54 +26,53 @@ export default class MyAbility extends RustAbility { } ``` -Here are some notes and tips: - -1. For every lifecycle callback, you must call the super method to forward the event to rust code as first and then write your own logic. +Notes: -2. `moduleName` is the bare native module name, such as `hello`. The framework resolves it to `libhello.so` internally. You must define it in your project. +1. Every lifecycle override should call the `super` implementation first. +2. `moduleName` is the bare module name; the runtime resolves it to `lib.so`. +3. `moduleName` can also be `string[]` when one ability needs multiple native modules. -### loadMode +### `loadMode` -Allow to define that how to load dynamic library in runtime. +Controls how the native module is loaded. -- async - In `async` mode, we will use `await import(${lib})` to load library. And this is default behavior. -- sync - In `sync` mode, we will use `loadNativeModule` to load library. If you define it, you must add some configuration into your `build-profile.json5`. +- `async` — uses dynamic import and is the default +- `sync` — uses `loadNativeModule` - ```json - { - "buildOption": { - "arkOptions": { - "runtimeOnly": { - "packages": ["libentry.so"] - } - } - } - } - ``` +When using `sync`, add the corresponding library to `build-profile.json5` runtime packages. - See more with [loadNativeModule](https://developer.huawei.com/consumer/cn/doc/harmonyos-references/js-apis-common-load-native-module#loadnativemodule). +### `DefaultXComponent` -### DefaultXComponent +`DefaultXComponent` loads the native module and binds the default Rust rendering surface. -When using rust to develop OpenHarmony/HarmonyNext application, we use `XComponent` to render the UI by default. And `DefaultXComponent` loads the native module and forward the lifecycle event to rust code by default. +```ts +import { DefaultXComponent } from "@ohos-rs/ability"; -This component is a optional component, you may don't need it. If you don't need to use it, `RustAbility` will use it by default. +@Entry +@Component +struct Index { + build() { + Row() { + Column() { + DefaultXComponent({ moduleName: "demo_native" }) + } + .width("100%") + } + .height("100%") + } +} +``` -And if you want to add some custom logic, you can use it with the following code: +### Custom Page Example ```ts -// ets/entryability/EntryAbility.ets import { RustAbility } from "@ohos-rs/ability"; import Want from "@ohos.app.ability.Want"; import { AbilityConstant } from "@kit.AbilityKit"; import window from "@ohos.window"; export default class EntryAbility extends RustAbility { - public moduleName: string = "example"; - - // Must mark it as false to prevent the default page from loading + public moduleName: string = "demo_native"; public defaultPage: boolean = false; async onCreate( @@ -89,49 +83,8 @@ export default class EntryAbility extends RustAbility { } async onWindowStageCreate(windowStage: window.WindowStage): Promise { - // Must call super method to forward the event to rust code super.onWindowStageCreate(windowStage); - // Jump to your custom page await windowStage.loadContent("pages/Index"); } } ``` - -```ts -// ets/pages/Index.ets -import { DefaultXComponent } from '@ohos-rs/ability' -import { ItemRestriction, SegmentButton, SegmentButtonOptions, SegmentButtonTextItem } from '@kit.ArkUI'; -import { changeRender } from "libwgpu_in_app.so" - -@Entry -@Component -struct Index { - // Add some custom logic - @State tabOptions: SegmentButtonOptions = SegmentButtonOptions.capsule({ - buttons: [{ text: 'boids' }, - { text: 'MSAA line' }, - { text: 'cube' }, - { text: "water" }, - { text: "shadow" }] as ItemRestriction, - backgroundBlurStyle: BlurStyle.BACKGROUND_THICK, - }) - @State @Watch("handleChange") tabSelectedIndexes: number[] = [0] - - handleChange() { - console.log(`changeIndex: ${this.tabSelectedIndexes}`) - changeRender(this.tabSelectedIndexes[0]) - } - - build() { - Row() { - Column() { - SegmentButton({ options: this.tabOptions, selectedIndexes: $tabSelectedIndexes }) - // Must use the default component to render the UI - DefaultXComponent({ moduleName: "example" }) - } - .width('100%') - } - .height('100%') - } -} -``` diff --git a/rust_ability/.gitignore b/rust_ability/.gitignore deleted file mode 100644 index d2ff201..0000000 --- a/rust_ability/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/rust_ability/AppScope/app.json5 b/rust_ability/AppScope/app.json5 deleted file mode 100644 index 53c3d28..0000000 --- a/rust_ability/AppScope/app.json5 +++ /dev/null @@ -1,10 +0,0 @@ -{ - "app": { - "bundleName": "com.example.rust_ability", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:layered_image", - "label": "$string:app_name" - } -} diff --git a/rust_ability/AppScope/resources/base/element/string.json b/rust_ability/AppScope/resources/base/element/string.json deleted file mode 100644 index c5fb461..0000000 --- a/rust_ability/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "rust_ability" - } - ] -} \ No newline at end of file diff --git a/rust_ability/AppScope/resources/base/media/background.png b/rust_ability/AppScope/resources/base/media/background.png deleted file mode 100644 index 923f2b3..0000000 Binary files a/rust_ability/AppScope/resources/base/media/background.png and /dev/null differ diff --git a/rust_ability/AppScope/resources/base/media/foreground.png b/rust_ability/AppScope/resources/base/media/foreground.png deleted file mode 100644 index 97014d3..0000000 Binary files a/rust_ability/AppScope/resources/base/media/foreground.png and /dev/null differ diff --git a/rust_ability/build-profile.json5 b/rust_ability/build-profile.json5 deleted file mode 100644 index 9831d55..0000000 --- a/rust_ability/build-profile.json5 +++ /dev/null @@ -1,45 +0,0 @@ -{ - "app": { - "signingConfigs": [], - "products": [ - { - "name": "default", - "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug" - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "ability_rust", - "srcPath": "./ability_rust" - } - ] -} diff --git a/rust_ability/code-linter.json5 b/rust_ability/code-linter.json5 deleted file mode 100644 index 719b1b9..0000000 --- a/rust_ability/code-linter.json5 +++ /dev/null @@ -1,32 +0,0 @@ -{ - "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" - } -} diff --git a/rust_ability/entry/oh-package-lock.json5 b/rust_ability/entry/oh-package-lock.json5 deleted file mode 100644 index 05149e9..0000000 --- a/rust_ability/entry/oh-package-lock.json5 +++ /dev/null @@ -1,19 +0,0 @@ -{ - "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": "", - "registryType": "local" - } - } -} \ No newline at end of file diff --git a/rust_ability/entry/oh-package.json5 b/rust_ability/entry/oh-package.json5 deleted file mode 100644 index d11bb96..0000000 --- a/rust_ability/entry/oh-package.json5 +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry" - } -} diff --git a/rust_ability/entry/src/main/cpp/CMakeLists.txt b/rust_ability/entry/src/main/cpp/CMakeLists.txt deleted file mode 100644 index 0fcd7a1..0000000 --- a/rust_ability/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(rust_ability) - -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) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/rust_ability/entry/src/main/ets/entryability/EntryAbility.ets b/rust_ability/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100644 index 649cc7d..0000000 --- a/rust_ability/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,51 +0,0 @@ -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"); - } -} diff --git a/rust_ability/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/rust_ability/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100644 index 541c4a9..0000000 --- a/rust_ability/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,16 +0,0 @@ -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(); - } -} diff --git a/rust_ability/entry/src/main/ets/pages/Index.ets b/rust_ability/entry/src/main/ets/pages/Index.ets deleted file mode 100644 index 17d790c..0000000 --- a/rust_ability/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,24 +0,0 @@ -import { hilog } from "@kit.PerformanceAnalysisKit"; -import testNapi from "libentry.so"; - -const DOMAIN = 0x0000; - -@Entry -@Component -struct Index { - @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"; - hilog.info(DOMAIN, "testTag", "Test NAPI 2 + 3 = %{public}d", testNapi.add(2, 3)); - }) - }.width("100%") - }.height("100%"); - } -} diff --git a/rust_ability/entry/src/main/module.json5 b/rust_ability/entry/src/main/module.json5 deleted file mode 100644 index 83ca116..0000000 --- a/rust_ability/entry/src/main/module.json5 +++ /dev/null @@ -1,52 +0,0 @@ -{ - "module": { - "name": "entry", - "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: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" - } - ] - } - ] - } -} diff --git a/rust_ability/entry/src/main/resources/base/element/float.json b/rust_ability/entry/src/main/resources/base/element/float.json deleted file mode 100644 index a0a93dd..0000000 --- a/rust_ability/entry/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} \ No newline at end of file diff --git a/rust_ability/entry/src/main/resources/base/media/background.png b/rust_ability/entry/src/main/resources/base/media/background.png deleted file mode 100644 index 923f2b3..0000000 Binary files a/rust_ability/entry/src/main/resources/base/media/background.png and /dev/null differ diff --git a/rust_ability/entry/src/main/resources/base/media/foreground.png b/rust_ability/entry/src/main/resources/base/media/foreground.png deleted file mode 100644 index 97014d3..0000000 Binary files a/rust_ability/entry/src/main/resources/base/media/foreground.png and /dev/null differ diff --git a/rust_ability/entry/src/main/resources/base/media/layered_image.json b/rust_ability/entry/src/main/resources/base/media/layered_image.json deleted file mode 100644 index 4f9ad63..0000000 --- a/rust_ability/entry/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "layered-image": { - "background": "$media:background", - "foreground": "$media:foreground" - } -} \ No newline at end of file diff --git a/rust_ability/entry/src/main/resources/dark/element/color.json b/rust_ability/entry/src/main/resources/dark/element/color.json deleted file mode 100644 index 79b11c2..0000000 --- a/rust_ability/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/rust_ability/oh-package-lock.json5 b/rust_ability/oh-package-lock.json5 deleted file mode 100644 index 19f267c..0000000 --- a/rust_ability/oh-package-lock.json5 +++ /dev/null @@ -1,28 +0,0 @@ -{ - "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": "", - "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": "", - "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/rust_ability/oh-package.json5 b/rust_ability/oh-package.json5 deleted file mode 100644 index 9dac712..0000000 --- a/rust_ability/oh-package.json5 +++ /dev/null @@ -1,9 +0,0 @@ -{ - "modelVersion": "5.0.0", - "description": "Please describe the basic information.", - "dependencies": {}, - "devDependencies": { - "@ohos/hypium": "1.0.21", - "@ohos/hamock": "1.0.0" - } -} diff --git a/rust_example/webview_example/.gitignore b/rust_example/demo_native/.gitignore similarity index 100% rename from rust_example/webview_example/.gitignore rename to rust_example/demo_native/.gitignore diff --git a/rust_example/webview_example/Cargo.toml b/rust_example/demo_native/Cargo.toml similarity index 66% rename from rust_example/webview_example/Cargo.toml rename to rust_example/demo_native/Cargo.toml index d9eaded..6feb89c 100755 --- a/rust_example/webview_example/Cargo.toml +++ b/rust_example/demo_native/Cargo.toml @@ -1,24 +1,20 @@ [package] -name = "webview_example" +name = "demo_native" version = "0.1.0" edition = "2021" publish = false -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - [lib] crate-type = ["cdylib"] [dependencies] -napi-ohos = { workspace = true} +napi-ohos = { workspace = true, features = ["tokio_rt"] } napi-derive-ohos = { workspace = true } openharmony-ability = { workspace = true, features = ["webview"] } openharmony-ability-derive = { workspace = true } ohos-hilog-binding = { version = "*" } +futures-executor = "0.3" [build-dependencies] napi-build-ohos = { workspace = true } - -[profile.release] -lto = true diff --git a/rust_example/webview_example/build.rs b/rust_example/demo_native/build.rs similarity index 100% rename from rust_example/webview_example/build.rs rename to rust_example/demo_native/build.rs diff --git a/rust_example/webview_example/src/index.html b/rust_example/demo_native/src/index.html similarity index 100% rename from rust_example/webview_example/src/index.html rename to rust_example/demo_native/src/index.html diff --git a/rust_example/xcomponent_example/src/lib.rs b/rust_example/demo_native/src/lib.rs similarity index 52% rename from rust_example/xcomponent_example/src/lib.rs rename to rust_example/demo_native/src/lib.rs index ae04ede..1f039f7 100755 --- a/rust_example/xcomponent_example/src/lib.rs +++ b/rust_example/demo_native/src/lib.rs @@ -1,13 +1,22 @@ #![allow(dead_code)] -use std::sync::{ - atomic::{AtomicBool, Ordering}, - LazyLock, RwLock, +use std::{ + cell::RefCell, + sync::{ + atomic::{AtomicBool, Ordering}, + LazyLock, RwLock, + }, }; -use napi_ohos::{Error, Result}; +use napi_derive_ohos::napi; +use napi_ohos::{ + bindgen_prelude::{Function, JsObjectValue, Object}, + Env, Error, Result, +}; use ohos_hilog_binding::hilog_info; -use openharmony_ability::{Event, InputEvent, OpenHarmonyApp}; +use openharmony_ability::{ + native_web::WebProxyBuilder, Event, InputEvent, OpenHarmonyApp, WebViewBuilder, +}; use openharmony_ability_derive::ability; static INNER_APP: LazyLock>> = LazyLock::new(|| RwLock::new(None)); @@ -15,7 +24,15 @@ static PERMISSION_REQUESTED: AtomicBool = AtomicBool::new(false); static MAIN_THREAD_DEMO_REQUESTED: AtomicBool = AtomicBool::new(false); static BACK_PRESS_INTERCEPT_ENABLED: AtomicBool = AtomicBool::new(true); -#[napi_derive_ohos::napi] +thread_local! { + #[allow(clippy::missing_const_for_thread_local)] + static WEBVIEW_ID: RefCell>> = RefCell::new(None); +} + +const WEB_TAG: &str = "demo_webview"; +const INDEX: &str = include_str!("index.html"); + +#[napi] pub async fn demo_request_permission_from_main_thread() -> Result> { if MAIN_THREAD_DEMO_REQUESTED.swap(true, Ordering::SeqCst) { hilog_info!("main-thread demo request already triggered"); @@ -43,7 +60,7 @@ pub async fn demo_request_permission_from_main_thread() -> Result> { Ok(codes) } -#[napi_derive_ohos::napi] +#[napi] pub fn toggle_back_press_intercept() -> bool { let current = BACK_PRESS_INTERCEPT_ENABLED.load(Ordering::SeqCst); let next = !current; @@ -52,7 +69,79 @@ pub fn toggle_back_press_intercept() -> bool { next } -#[ability] +#[napi] +pub fn handle_change(env: &Env) -> napi_ohos::Result<()> { + let web_tag = String::from(WEB_TAG); + + let webview = WebViewBuilder::new() + .id(web_tag.clone()) + .html(INDEX) + .build()?; + + webview + .custom_protocol("wry", |url, req, is_main_frame| { + hilog_info!(format!("ohos-rs macro custom_protocol: {:?}", url).as_str()); + hilog_info!(format!("ohos-rs macro custom_protocol: {:?}", req).as_str()); + hilog_info!(format!("ohos-rs macro custom_protocol: {:?}", is_main_frame).as_str()); + None + }) + .map_err(|_| napi_ohos::Error::from_reason("custom_protocol error".to_string()))?; + + let _ = webview.on_controller_attach(move || { + hilog_info!("ohos-rs macro on_controller_attach"); + let _ = WebProxyBuilder::new(web_tag.clone(), "test".to_string()) + .add_method("test", |_web_tag: String, args: Vec| { + hilog_info!(format!("ohos-rs macro test: {:?}", args).as_str()); + }) + .build() + .unwrap(); + }); + + let _ = webview.on_page_begin(|| { + hilog_info!("ohos-rs macro on_page_begin"); + }); + + let _ = webview.on_page_end(|| { + hilog_info!("ohos-rs macro on_page_end"); + }); + + let ret: Object<'static> = unsafe { + std::mem::transmute::, Object<'static>>(webview.inner().get_value(env)?) + }; + WEBVIEW_ID.with(|w| { + w.replace(Some(ret)); + }); + + Ok(()) +} + +#[napi] +pub fn set_background_color(_env: &Env, color: String) -> napi_ohos::Result<()> { + WEBVIEW_ID.with(|w| { + if let Some(webview) = w.borrow().as_ref() { + let set_background_color_js_function = webview + .get_named_property::>("setBackgroundColor") + .unwrap(); + set_background_color_js_function.call(color).unwrap(); + } + }); + Ok(()) +} + +#[napi] +pub fn set_visible(_env: &Env, visible: bool) -> napi_ohos::Result<()> { + WEBVIEW_ID.with(|w| { + if let Some(webview) = w.borrow().as_ref() { + let set_visible_js_function = webview + .get_named_property::>("setVisible") + .unwrap(); + set_visible_js_function.call(visible).unwrap(); + } + }); + Ok(()) +} + +#[ability(webview, protocol = "wry,custom,other")] fn openharmony_app(app: OpenHarmonyApp) { INNER_APP.write().unwrap().replace(app.clone()); hilog_info!(format!( @@ -71,7 +160,7 @@ fn openharmony_app(app: OpenHarmonyApp) { intercept }); - app.run_loop(move |types| match types { + app.run_loop(move |event| match event { Event::SurfaceCreate => { hilog_info!("ohos-rs macro surface_create"); if !PERMISSION_REQUESTED.swap(true, Ordering::SeqCst) { @@ -98,9 +187,9 @@ fn openharmony_app(app: OpenHarmonyApp) { }); } } - Event::Input(k) => match k { - InputEvent::ImeEvent(s) => { - hilog_info!(format!("ohos-rs macro input_text: {:?}", s).as_str()); + Event::Input(input) => match input { + InputEvent::ImeEvent(text) => { + hilog_info!(format!("ohos-rs macro input_text: {:?}", text).as_str()); } _ => { hilog_info!("ohos-rs macro input:"); @@ -110,7 +199,7 @@ fn openharmony_app(app: OpenHarmonyApp) { hilog_info!("ohos-rs macro window_redraw"); } _ => { - hilog_info!(format!("ohos-rs macro: {:?}", types.as_str()).as_str()); + hilog_info!(format!("ohos-rs macro: {:?}", event.as_str()).as_str()); } }); } diff --git a/rust_example/webview_example/scripts/devtools.sh b/rust_example/webview_example/scripts/devtools.sh deleted file mode 100644 index d85d510..0000000 --- a/rust_example/webview_example/scripts/devtools.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -# Get current fport rule list -CURRENT_FPORT_LIST=$(hdc fport ls) - -# Delete the existing fport rule one by one -while IFS= read -r line; do - # Extract the taskline - IFS=' ' read -ra parts <<< "$line" - taskline="${parts[1]} ${parts[2]}" - - # Delete the corresponding fport rule - echo "Removing forward rule for $taskline" - hdc fport rm $taskline - result=$? - - if [ $result -eq 0 ]; then - echo "Remove forward rule success, taskline:$taskline" - else - echo "Failed to remove forward rule, taskline:$taskline" - fi - -done <<< "$CURRENT_FPORT_LIST" - -# Initial port number -INITIAL_PORT=9222 - -# Get the current port number, use initial port number if not set previously -CURRENT_PORT=${PORT:-$INITIAL_PORT} - -# Get the list of all PIDs that match the condition -PID_LIST=$(hdc shell cat /proc/net/unix | grep webview_devtools_remote_ | awk -F '_' '{print $NF}') - -if [ -z "$PID_LIST" ]; then - echo "Failed to retrieve PID from the device" - exit 1 -fi - -# Increment the port number -PORT=$CURRENT_PORT - -# Forward ports for each application one by one -for PID in $PID_LIST; do - # Increment the port number - PORT=$((PORT + 1)) - - # Execute the hdc fport command - hdc fport tcp:$PORT localabstract:webview_devtools_remote_$PID - - # Check if the command executed successfully - if [ $? -ne 0 ]; then - echo "Failed to execute hdc fport command" - exit 1 - fi -done - -# List all forwarded ports -hdc fport ls \ No newline at end of file diff --git a/rust_example/webview_example/src/lib.rs b/rust_example/webview_example/src/lib.rs deleted file mode 100755 index a1bf230..0000000 --- a/rust_example/webview_example/src/lib.rs +++ /dev/null @@ -1,116 +0,0 @@ -use std::cell::RefCell; - -use napi_derive_ohos::napi; -use napi_ohos::{ - bindgen_prelude::{Function, JsObjectValue, Object}, - Env, -}; -use ohos_hilog_binding::hilog_info; -use openharmony_ability::{ - native_web::WebProxyBuilder, Event, InputEvent, OpenHarmonyApp, WebViewBuilder, -}; -use openharmony_ability_derive::ability; - -thread_local! { - static WEBVIEW_ID: RefCell>> = RefCell::new(None); -} - -const INDEX: &str = include_str!("index.html"); - -#[napi] -pub fn handle_change(env: &Env) -> napi_ohos::Result<()> { - let web_tag = String::from("webview_example"); - - let webview = WebViewBuilder::new() - .id(web_tag.clone()) - .html(INDEX) - .build()?; - - webview - .custom_protocol("wry", |url, req, is_main_frame| { - hilog_info!(format!("ohos-rs macro custom_protocol: {:?}", url).as_str()); - hilog_info!(format!("ohos-rs macro custom_protocol: {:?}", req).as_str()); - hilog_info!(format!("ohos-rs macro custom_protocol: {:?}", is_main_frame).as_str()); - None - }) - .map_err(|_| napi_ohos::Error::from_reason("custom_protocol error".to_string()))?; - - let _ = webview.on_controller_attach(move || { - hilog_info!("ohos-rs macro on_controller_attach"); - let _ = WebProxyBuilder::new(web_tag.clone(), "test".to_string()) - .add_method("test", |_web_tag: String, args: Vec| { - hilog_info!(format!("ohos-rs macro test: {:?}", args).as_str()); - }) - .build() - .unwrap(); - }); - - let _ = webview.on_page_begin(|| { - hilog_info!("ohos-rs macro on_page_begin"); - }); - - let _ = webview.on_page_end(|| { - hilog_info!("ohos-rs macro on_page_end"); - }); - - let ret = unsafe { std::mem::transmute(webview.inner().get_value(env)?) }; - - WEBVIEW_ID.with(|w| { - w.replace(Some(ret)); - }); - - Ok(()) -} - -#[napi] -pub fn set_background_color(env: &Env, color: String) -> napi_ohos::Result<()> { - WEBVIEW_ID.with(|w| { - if let Some(webview) = w.borrow().as_ref() { - let set_background_color_js_function = webview - .get_named_property::>("setBackgroundColor") - .unwrap(); - set_background_color_js_function.call(color).unwrap(); - } - }); - Ok(()) -} - -#[napi] -pub fn set_visible(env: &Env, visible: bool) -> napi_ohos::Result<()> { - WEBVIEW_ID.with(|w| { - if let Some(webview) = w.borrow().as_ref() { - let set_visible_js_function = webview - .get_named_property::>("setVisible") - .unwrap(); - set_visible_js_function.call(visible).unwrap(); - } - }); - Ok(()) -} - -#[ability(webview, protocol = "wry,custom,other")] -fn openharmony_app(app: OpenHarmonyApp) { - hilog_info!(format!( - "init context => module={:?}, base={:?}, pref={:?}, locales={:?}", - app.module_name(), - app.base_path(), - app.pref_path(), - app.preferred_locales() - ) - .as_str()); - - app.run_loop(|types| match types { - Event::Input(k) => match k { - InputEvent::ImeEvent(s) => { - hilog_info!(format!("ohos-rs macro input_text: {:?}", s).as_str()); - } - _ => { - hilog_info!("ohos-rs macro input:"); - } - }, - Event::WindowRedraw(_) => {} - _ => { - hilog_info!(format!("ohos-rs macro: {:?}", types.as_str()).as_str()); - } - }); -} diff --git a/rust_example/xcomponent_example/.gitignore b/rust_example/xcomponent_example/.gitignore deleted file mode 100755 index d578fcc..0000000 --- a/rust_example/xcomponent_example/.gitignore +++ /dev/null @@ -1,9 +0,0 @@ -dist/ -target/ -.DS_Store -.idea/ -package/libs - -*.har - -Cargo.lock diff --git a/rust_example/xcomponent_example/Cargo.toml b/rust_example/xcomponent_example/Cargo.toml deleted file mode 100755 index 9d40576..0000000 --- a/rust_example/xcomponent_example/Cargo.toml +++ /dev/null @@ -1,25 +0,0 @@ -[package] -name = "xcomponent_example" -version = "0.1.0" -edition = "2021" -publish = false - -# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html - -[lib] -crate-type = ["cdylib"] - -[dependencies] -napi-ohos = { workspace = true, features = ["tokio_rt"] } -napi-derive-ohos = { workspace = true } - -openharmony-ability = { workspace = true } -openharmony-ability-derive = { workspace = true } -ohos-hilog-binding = { version = "*" } -futures-executor = "0.3" - -[build-dependencies] -napi-build-ohos = { workspace = true } - -[profile.release] -lto = true diff --git a/rust_example/xcomponent_example/build.rs b/rust_example/xcomponent_example/build.rs deleted file mode 100755 index a6e4623..0000000 --- a/rust_example/xcomponent_example/build.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - napi_build_ohos::setup(); -} diff --git a/scripts/pack.sh b/scripts/pack.sh index daf76dc..fabc106 100644 --- a/scripts/pack.sh +++ b/scripts/pack.sh @@ -5,6 +5,6 @@ SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd) rm -rf $SCRIPT_DIR/../package/src/main/ets rm -rf $SCRIPT_DIR/../dist -cp -rf $SCRIPT_DIR/../rust_ability/ability_rust/src/main/ets/ $SCRIPT_DIR/../package/src/main/ets +cp -rf $SCRIPT_DIR/../ability_rust/src/main/ets/ $SCRIPT_DIR/../package/src/main/ets pushd $SCRIPT_DIR/../ && ohrs artifact --skip-libs \ No newline at end of file diff --git a/webview_example/.gitignore b/webview_example/.gitignore deleted file mode 100644 index d2ff201..0000000 --- a/webview_example/.gitignore +++ /dev/null @@ -1,12 +0,0 @@ -/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/webview_example/AppScope/app.json5 b/webview_example/AppScope/app.json5 deleted file mode 100644 index 56758ae..0000000 --- a/webview_example/AppScope/app.json5 +++ /dev/null @@ -1,10 +0,0 @@ -{ - "app": { - "bundleName": "com.example.webview_example", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:layered_image", - "label": "$string:app_name" - } -} diff --git a/webview_example/AppScope/resources/base/element/string.json b/webview_example/AppScope/resources/base/element/string.json deleted file mode 100644 index 1e855cb..0000000 --- a/webview_example/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "webview_example" - } - ] -} \ No newline at end of file diff --git a/webview_example/AppScope/resources/base/media/background.png b/webview_example/AppScope/resources/base/media/background.png deleted file mode 100644 index 923f2b3..0000000 Binary files a/webview_example/AppScope/resources/base/media/background.png and /dev/null differ diff --git a/webview_example/AppScope/resources/base/media/foreground.png b/webview_example/AppScope/resources/base/media/foreground.png deleted file mode 100644 index 97014d3..0000000 Binary files a/webview_example/AppScope/resources/base/media/foreground.png and /dev/null differ diff --git a/webview_example/AppScope/resources/base/media/layered_image.json b/webview_example/AppScope/resources/base/media/layered_image.json deleted file mode 100644 index 4f9ad63..0000000 --- a/webview_example/AppScope/resources/base/media/layered_image.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "layered-image": { - "background": "$media:background", - "foreground": "$media:foreground" - } -} \ No newline at end of file diff --git a/webview_example/build-profile.json5 b/webview_example/build-profile.json5 deleted file mode 100644 index 282bcd3..0000000 --- a/webview_example/build-profile.json5 +++ /dev/null @@ -1,45 +0,0 @@ -{ - "app": { - "signingConfigs": [], - "products": [ - { - "name": "default", - "signingConfig": "default", - "compatibleSdkVersion": "5.0.0(12)", - "runtimeOS": "HarmonyOS", - "buildOption": { - "strictMode": { - "caseSensitiveCheck": true, - "useNormalizedOHMUrl": true - } - } - } - ], - "buildModeSet": [ - { - "name": "debug" - }, - { - "name": "release" - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, - { - "name": "ability_rust", - "srcPath": "../rust_ability/ability_rust" - } - ] -} diff --git a/webview_example/code-linter.json5 b/webview_example/code-linter.json5 deleted file mode 100644 index 719b1b9..0000000 --- a/webview_example/code-linter.json5 +++ /dev/null @@ -1,32 +0,0 @@ -{ - "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" - } -} diff --git a/webview_example/entry/.gitignore b/webview_example/entry/.gitignore deleted file mode 100644 index e2713a2..0000000 --- a/webview_example/entry/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/webview_example/entry/build-profile.json5 b/webview_example/entry/build-profile.json5 deleted file mode 100644 index ead913d..0000000 --- a/webview_example/entry/build-profile.json5 +++ /dev/null @@ -1,39 +0,0 @@ -{ - "apiType": "stageMode", - "buildOption": { - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "" - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - } - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/webview_example/entry/hvigorfile.ts b/webview_example/entry/hvigorfile.ts deleted file mode 100644 index 1e21331..0000000 --- a/webview_example/entry/hvigorfile.ts +++ /dev/null @@ -1,6 +0,0 @@ -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/webview_example/entry/obfuscation-rules.txt b/webview_example/entry/obfuscation-rules.txt deleted file mode 100644 index 272efb6..0000000 --- a/webview_example/entry/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/webview_example/entry/src/main/cpp/CMakeLists.txt b/webview_example/entry/src/main/cpp/CMakeLists.txt deleted file mode 100644 index 0026865..0000000 --- a/webview_example/entry/src/main/cpp/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -# the minimum version of CMake. -cmake_minimum_required(VERSION 3.5.0) -project(webview_example) - -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) - -add_library(entry SHARED napi_init.cpp) -target_link_libraries(entry PUBLIC libace_napi.z.so) \ No newline at end of file diff --git a/webview_example/entry/src/main/cpp/napi_init.cpp b/webview_example/entry/src/main/cpp/napi_init.cpp deleted file mode 100644 index 85330e3..0000000 --- a/webview_example/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "napi/native_api.h" - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; - -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "add", nullptr, Add, 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/webview_example/entry/src/main/cpp/types/libentry/Index.d.ts b/webview_example/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100644 index 4b23059..0000000 --- a/webview_example/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export const add: (a: number, b: number) => number; diff --git a/webview_example/entry/src/main/cpp/types/libentry/oh-package.json5 b/webview_example/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100644 index d0d6112..0000000 --- a/webview_example/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "libentry.so", - "types": "./Index.d.ts", - "version": "1.0.0", - "description": "Please describe the basic information." -} diff --git a/webview_example/entry/src/main/cpp/types/libwebview_example/Index.d.ts b/webview_example/entry/src/main/cpp/types/libwebview_example/Index.d.ts deleted file mode 100644 index 82094cb..0000000 --- a/webview_example/entry/src/main/cpp/types/libwebview_example/Index.d.ts +++ /dev/null @@ -1,60 +0,0 @@ -/* auto-generated by OHOS-RS */ -/* eslint-disable */ - -export interface ApplicationLifecycle { - environmentCallback: EnvironmentCallback; - windowStageEventCallback: WindowStageEventCallback; -} - -export interface AbilityInitContext { - basePath?: string; - prefPath?: string; - preferredLocales?: string; - moduleName?: string; -} - -export interface ArkTSHelper { - exit: (arg: number) => void; - createWebview: (arg: WebViewInitData) => Object; -} - -export interface EnvironmentCallback { - onConfigurationUpdated: () => void; - onMemoryLevel: (arg: number) => void; -} - -export interface WebViewComponentEventCallback { - onComponentCreated: () => void; - onComponentDestroyed: () => void; -} - -export interface WebViewInitData { - url?: string; - id?: string; - style?: WebViewStyle; -} - -export interface WebViewStyle { - x?: number | string; - y?: number | string; -} - -export interface WindowStageEventCallback { - onWindowStageCreate: () => void; - onWindowStageDestroy: () => void; - onAbilityCreate: () => void; - onAbilityDestroy: () => void; - onAbilitySaveState: () => void; - onAbilityRestoreState: () => void; - onWindowStageEvent: (arg: number) => void; - onWindowSizeChange: (arg: object) => void; - onWindowRectChange: (arg: object) => void; -} - -export declare function handleChange(): void; - -export declare function init(context?: AbilityInitContext): ApplicationLifecycle; - -export declare function webviewRender(helper: ArkTSHelper): WebViewComponentEventCallback; -export declare function setBackgroundColor(color: string): void; -export declare function setVisible(visible: boolean): void; diff --git a/webview_example/entry/src/main/cpp/types/libwebview_example/oh-package.json5 b/webview_example/entry/src/main/cpp/types/libwebview_example/oh-package.json5 deleted file mode 100644 index e46ec77..0000000 --- a/webview_example/entry/src/main/cpp/types/libwebview_example/oh-package.json5 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "libwebview_example.so", - "types": "./Index.d.ts", - "version": "1.0.0", - "description": "Please describe the basic information." -} diff --git a/webview_example/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/webview_example/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets deleted file mode 100644 index 541c4a9..0000000 --- a/webview_example/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets +++ /dev/null @@ -1,16 +0,0 @@ -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(); - } -} diff --git a/webview_example/entry/src/main/ets/pages/Index.ets b/webview_example/entry/src/main/ets/pages/Index.ets deleted file mode 100644 index 5407f91..0000000 --- a/webview_example/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,34 +0,0 @@ -import { DefaultXComponent } from "@ohos-rs/ability"; -import { handleChange, setBackgroundColor, setVisible } from "libwebview_example.so"; - -const MODULE_NAME = "webview_example"; - -@Entry -@Component -struct Index { - @State message: string = "Hello World"; - @State visible: boolean = true; - - build() { - Row() { - Column() { - Row() { - Button("add baidu webview") - .onClick(() => { - handleChange(); - }) - Button("changeData") - .onClick(() => { - setBackgroundColor("red"); - }) - Button("changeVisible") - .onClick(() => { - setVisible(!this.visible); - this.visible = !this.visible; - }) - } - DefaultXComponent({ moduleName: MODULE_NAME }) - }.width("100%") - }.height("100%"); - } -} diff --git a/webview_example/entry/src/main/module.json5 b/webview_example/entry/src/main/module.json5 deleted file mode 100644 index 2792e83..0000000 --- a/webview_example/entry/src/main/module.json5 +++ /dev/null @@ -1,57 +0,0 @@ -{ - "module": { - "name": "entry", - "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: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" - } - ] - } - ], - "requestPermissions": [ - { - "name": "ohos.permission.INTERNET" - } - ] - } -} diff --git a/webview_example/entry/src/main/resources/base/element/color.json b/webview_example/entry/src/main/resources/base/element/color.json deleted file mode 100644 index 3c71296..0000000 --- a/webview_example/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/webview_example/entry/src/main/resources/base/element/float.json b/webview_example/entry/src/main/resources/base/element/float.json deleted file mode 100644 index a0a93dd..0000000 --- a/webview_example/entry/src/main/resources/base/element/float.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "float": [ - { - "name": "page_text_font_size", - "value": "50fp" - } - ] -} \ No newline at end of file diff --git a/webview_example/entry/src/main/resources/base/media/background.png b/webview_example/entry/src/main/resources/base/media/background.png deleted file mode 100644 index 923f2b3..0000000 Binary files a/webview_example/entry/src/main/resources/base/media/background.png and /dev/null differ diff --git a/webview_example/entry/src/main/resources/base/media/foreground.png b/webview_example/entry/src/main/resources/base/media/foreground.png deleted file mode 100644 index 97014d3..0000000 Binary files a/webview_example/entry/src/main/resources/base/media/foreground.png and /dev/null differ diff --git a/webview_example/entry/src/main/resources/base/media/layered_image.json b/webview_example/entry/src/main/resources/base/media/layered_image.json deleted file mode 100644 index 4f9ad63..0000000 --- a/webview_example/entry/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "layered-image": { - "background": "$media:background", - "foreground": "$media:foreground" - } -} \ No newline at end of file diff --git a/webview_example/entry/src/main/resources/base/media/startIcon.png b/webview_example/entry/src/main/resources/base/media/startIcon.png deleted file mode 100644 index 205ad8b..0000000 Binary files a/webview_example/entry/src/main/resources/base/media/startIcon.png and /dev/null differ diff --git a/webview_example/entry/src/main/resources/base/profile/backup_config.json b/webview_example/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100644 index 78f40ae..0000000 --- a/webview_example/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/webview_example/entry/src/main/resources/base/profile/main_pages.json b/webview_example/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index 55c3f00..0000000 --- a/webview_example/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} \ No newline at end of file diff --git a/webview_example/entry/src/main/resources/dark/element/color.json b/webview_example/entry/src/main/resources/dark/element/color.json deleted file mode 100644 index 79b11c2..0000000 --- a/webview_example/entry/src/main/resources/dark/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#000000" - } - ] -} \ No newline at end of file diff --git a/webview_example/entry/src/mock/Libentry.mock.ets b/webview_example/entry/src/mock/Libentry.mock.ets deleted file mode 100644 index 9d582b5..0000000 --- a/webview_example/entry/src/mock/Libentry.mock.ets +++ /dev/null @@ -1,7 +0,0 @@ -const NativeMock: Record = { - add: (a: number, b: number) => { - return a + b; - }, -}; - -export default NativeMock; diff --git a/webview_example/entry/src/mock/mock-config.json5 b/webview_example/entry/src/mock/mock-config.json5 deleted file mode 100644 index 8f9b5a0..0000000 --- a/webview_example/entry/src/mock/mock-config.json5 +++ /dev/null @@ -1,5 +0,0 @@ -{ - "libentry.so": { - "source": "src/mock/Libentry.mock.ets" - } -} diff --git a/webview_example/entry/src/ohosTest/ets/test/Ability.test.ets b/webview_example/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index bd7e94d..0000000 --- a/webview_example/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -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); - }); - }); -} diff --git a/webview_example/entry/src/ohosTest/ets/test/List.test.ets b/webview_example/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 64971a8..0000000 --- a/webview_example/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from "./Ability.test"; - -export default function testsuite() { - abilityTest(); -} diff --git a/webview_example/entry/src/ohosTest/module.json5 b/webview_example/entry/src/ohosTest/module.json5 deleted file mode 100644 index 55725a9..0000000 --- a/webview_example/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/webview_example/entry/src/test/List.test.ets b/webview_example/entry/src/test/List.test.ets deleted file mode 100644 index 37ddf3e..0000000 --- a/webview_example/entry/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from "./LocalUnit.test"; - -export default function testsuite() { - localUnitTest(); -} diff --git a/webview_example/entry/src/test/LocalUnit.test.ets b/webview_example/entry/src/test/LocalUnit.test.ets deleted file mode 100644 index a8e45e0..0000000 --- a/webview_example/entry/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -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); - }); - }); -} diff --git a/webview_example/hvigor/hvigor-config.json5 b/webview_example/hvigor/hvigor-config.json5 deleted file mode 100644 index da31855..0000000 --- a/webview_example/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,21 +0,0 @@ -{ - "modelVersion": "5.0.0", - "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/webview_example/hvigorfile.ts b/webview_example/hvigorfile.ts deleted file mode 100644 index 9d563d9..0000000 --- a/webview_example/hvigorfile.ts +++ /dev/null @@ -1,6 +0,0 @@ -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/webview_example/oh-package-lock.json5 b/webview_example/oh-package-lock.json5 deleted file mode 100644 index 19f267c..0000000 --- a/webview_example/oh-package-lock.json5 +++ /dev/null @@ -1,28 +0,0 @@ -{ - "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": "", - "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": "", - "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/webview_example/oh-package.json5 b/webview_example/oh-package.json5 deleted file mode 100644 index 9dac712..0000000 --- a/webview_example/oh-package.json5 +++ /dev/null @@ -1,9 +0,0 @@ -{ - "modelVersion": "5.0.0", - "description": "Please describe the basic information.", - "dependencies": {}, - "devDependencies": { - "@ohos/hypium": "1.0.21", - "@ohos/hamock": "1.0.0" - } -} diff --git a/xcomponent_example/entry/.gitignore b/xcomponent_example/entry/.gitignore deleted file mode 100644 index e2713a2..0000000 --- a/xcomponent_example/entry/.gitignore +++ /dev/null @@ -1,6 +0,0 @@ -/node_modules -/oh_modules -/.preview -/build -/.cxx -/.test \ No newline at end of file diff --git a/xcomponent_example/entry/build-profile.json5 b/xcomponent_example/entry/build-profile.json5 deleted file mode 100644 index 35f98c1..0000000 --- a/xcomponent_example/entry/build-profile.json5 +++ /dev/null @@ -1,46 +0,0 @@ -{ - "apiType": "stageMode", - "buildOption": { - "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", - "arguments": "", - "cppFlags": "" - }, - "arkOptions": { - "runtimeOnly": { - "packages": [ - "libexample.so" - ] - } - } - }, - "buildOptionSet": [ - { - "name": "release", - "arkOptions": { - "obfuscation": { - "ruleOptions": { - "enable": false, - "files": [ - "./obfuscation-rules.txt" - ] - } - } - }, - "nativeLib": { - "debugSymbol": { - "strip": true, - "exclude": [] - } - } - } - ], - "targets": [ - { - "name": "default" - }, - { - "name": "ohosTest" - } - ] -} diff --git a/xcomponent_example/entry/hvigorfile.ts b/xcomponent_example/entry/hvigorfile.ts deleted file mode 100644 index 1e21331..0000000 --- a/xcomponent_example/entry/hvigorfile.ts +++ /dev/null @@ -1,6 +0,0 @@ -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/xcomponent_example/entry/obfuscation-rules.txt b/xcomponent_example/entry/obfuscation-rules.txt deleted file mode 100644 index 272efb6..0000000 --- a/xcomponent_example/entry/obfuscation-rules.txt +++ /dev/null @@ -1,23 +0,0 @@ -# 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/xcomponent_example/entry/oh-package-lock.json5 b/xcomponent_example/entry/oh-package-lock.json5 deleted file mode 100644 index d4c5e90..0000000 --- a/xcomponent_example/entry/oh-package-lock.json5 +++ /dev/null @@ -1,50 +0,0 @@ -{ - "meta": { - "stableOrder": true, - "enableUnifiedLockfile": false - }, - "lockfileVersion": 3, - "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", - "specifiers": { - "@ohos-rs/ability@../../rust_ability/ability_rust": "@ohos-rs/ability@../../rust_ability/ability_rust", - "libability_rust.so@../../rust_ability/ability_rust/src/main/cpp/types/libability_rust": "libability_rust.so@../../rust_ability/ability_rust/src/main/cpp/types/libability_rust", - "libentry.so@src/main/cpp/types/libentry": "libentry.so@src/main/cpp/types/libentry", - "libexample.so@src/main/cpp/types/libexample": "libexample.so@src/main/cpp/types/libexample", - "libwgpu_in_app.so@src/main/cpp/types/libwgpu_in_app": "libwgpu_in_app.so@src/main/cpp/types/libwgpu_in_app" - }, - "packages": { - "@ohos-rs/ability@../../rust_ability/ability_rust": { - "name": "@ohos-rs/ability", - "version": "0.0.1", - "resolved": "", - "registryType": "local", - "dependencies": { - "libability_rust.so": "file:./src/main/cpp/types/libability_rust" - } - }, - "libability_rust.so@../../rust_ability/ability_rust/src/main/cpp/types/libability_rust": { - "name": "libability_rust.so", - "version": "1.0.0", - "resolved": "", - "registryType": "local" - }, - "libentry.so@src/main/cpp/types/libentry": { - "name": "libentry.so", - "version": "1.0.0", - "resolved": "", - "registryType": "local" - }, - "libexample.so@src/main/cpp/types/libexample": { - "name": "libexample.so", - "version": "1.0.0", - "resolved": "", - "registryType": "local" - }, - "libwgpu_in_app.so@src/main/cpp/types/libwgpu_in_app": { - "name": "libwgpu_in_app.so", - "version": "1.0.0", - "resolved": "", - "registryType": "local" - } - } -} \ No newline at end of file diff --git a/xcomponent_example/entry/oh-package.json5 b/xcomponent_example/entry/oh-package.json5 deleted file mode 100644 index 227378e..0000000 --- a/xcomponent_example/entry/oh-package.json5 +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "entry", - "version": "1.0.0", - "description": "Please describe the basic information.", - "main": "", - "author": "", - "license": "", - "dependencies": { - "libentry.so": "file:./src/main/cpp/types/libentry", - "libexample.so": "file:./src/main/cpp/types/libexample", - "libwgpu_in_app.so": "file:./src/main/cpp/types/libwgpu_in_app", - "@ohos-rs/ability": "file:../../rust_ability/ability_rust" - } -} diff --git a/xcomponent_example/entry/src/main/cpp/napi_init.cpp b/xcomponent_example/entry/src/main/cpp/napi_init.cpp deleted file mode 100644 index 85330e3..0000000 --- a/xcomponent_example/entry/src/main/cpp/napi_init.cpp +++ /dev/null @@ -1,53 +0,0 @@ -#include "napi/native_api.h" - -static napi_value Add(napi_env env, napi_callback_info info) -{ - size_t argc = 2; - napi_value args[2] = {nullptr}; - - napi_get_cb_info(env, info, &argc, args , nullptr, nullptr); - - napi_valuetype valuetype0; - napi_typeof(env, args[0], &valuetype0); - - napi_valuetype valuetype1; - napi_typeof(env, args[1], &valuetype1); - - double value0; - napi_get_value_double(env, args[0], &value0); - - double value1; - napi_get_value_double(env, args[1], &value1); - - napi_value sum; - napi_create_double(env, value0 + value1, &sum); - - return sum; - -} - -EXTERN_C_START -static napi_value Init(napi_env env, napi_value exports) -{ - napi_property_descriptor desc[] = { - { "add", nullptr, Add, 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/xcomponent_example/entry/src/main/cpp/types/libentry/Index.d.ts b/xcomponent_example/entry/src/main/cpp/types/libentry/Index.d.ts deleted file mode 100644 index 4b23059..0000000 --- a/xcomponent_example/entry/src/main/cpp/types/libentry/Index.d.ts +++ /dev/null @@ -1 +0,0 @@ -export const add: (a: number, b: number) => number; diff --git a/xcomponent_example/entry/src/main/cpp/types/libentry/oh-package.json5 b/xcomponent_example/entry/src/main/cpp/types/libentry/oh-package.json5 deleted file mode 100644 index d0d6112..0000000 --- a/xcomponent_example/entry/src/main/cpp/types/libentry/oh-package.json5 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "libentry.so", - "types": "./Index.d.ts", - "version": "1.0.0", - "description": "Please describe the basic information." -} diff --git a/xcomponent_example/entry/src/main/cpp/types/libexample/Index.d.ts b/xcomponent_example/entry/src/main/cpp/types/libexample/Index.d.ts deleted file mode 100644 index ed23a0e..0000000 --- a/xcomponent_example/entry/src/main/cpp/types/libexample/Index.d.ts +++ /dev/null @@ -1,31 +0,0 @@ -/* auto-generated by OHOS-RS */ -/* eslint-disable */ -import { NodeContent } from "@kit.ArkUI"; - -export interface ApplicationLifecycle { - environmentCallback: EnvironmentCallback; - windowStageEventCallback: WindowStageEventCallback; -} - -export interface AbilityInitContext { - basePath?: string; - prefPath?: string; - preferredLocales?: string; - moduleName?: string; -} - -export interface EnvironmentCallback { - onConfigurationUpdated: () => void; - onMemoryLevel: () => void; -} - -export interface WindowStageEventCallback { - onWindowStageCreate: () => void; - onWindowStageDestroy: () => void; - onAbilityCreate: () => void; - onAbilityDestroy: () => void; - onAbilitySaveState: () => void; -} - -export declare function init(context?: AbilityInitContext): ApplicationLifecycle; -export declare function render(slot: NodeContent): void; diff --git a/xcomponent_example/entry/src/main/cpp/types/libwgpu_in_app/Index.d.ts b/xcomponent_example/entry/src/main/cpp/types/libwgpu_in_app/Index.d.ts deleted file mode 100644 index dd5de09..0000000 --- a/xcomponent_example/entry/src/main/cpp/types/libwgpu_in_app/Index.d.ts +++ /dev/null @@ -1,32 +0,0 @@ -/* auto-generated by OHOS-RS */ -/* eslint-disable */ -import { NodeContent } from "@kit.ArkUI"; - -export interface ApplicationLifecycle { - environmentCallback: EnvironmentCallback; - windowStageEventCallback: WindowStageEventCallback; -} - -export interface AbilityInitContext { - basePath?: string; - prefPath?: string; - preferredLocales?: string; - moduleName?: string; -} - -export interface EnvironmentCallback { - onConfigurationUpdated: () => void; - onMemoryLevel: () => void; -} - -export interface WindowStageEventCallback { - onWindowStageCreate: () => void; - onWindowStageDestroy: () => void; - onAbilityCreate: () => void; - onAbilityDestroy: () => void; - onAbilitySaveState: () => void; -} - -export declare function init(context?: AbilityInitContext): ApplicationLifecycle; - -export declare function changeRender(index: number): void; diff --git a/xcomponent_example/entry/src/main/cpp/types/libwgpu_in_app/oh-package.json5 b/xcomponent_example/entry/src/main/cpp/types/libwgpu_in_app/oh-package.json5 deleted file mode 100644 index 66c0898..0000000 --- a/xcomponent_example/entry/src/main/cpp/types/libwgpu_in_app/oh-package.json5 +++ /dev/null @@ -1,6 +0,0 @@ -{ - "name": "libwgpu_in_app.so", - "types": "./Index.d.ts", - "version": "1.0.0", - "description": "Please describe the basic information." -} diff --git a/xcomponent_example/entry/src/main/ets/entryability/EntryAbility.ets b/xcomponent_example/entry/src/main/ets/entryability/EntryAbility.ets deleted file mode 100644 index 09b710c..0000000 --- a/xcomponent_example/entry/src/main/ets/entryability/EntryAbility.ets +++ /dev/null @@ -1,21 +0,0 @@ -import { RustAbility } from "@ohos-rs/ability"; -import Want from "@ohos.app.ability.Want"; -import { AbilityConstant } from "@kit.AbilityKit"; -import window from "@ohos.window"; - -export default class EntryAbility extends RustAbility { - public moduleName: string = "xcomponent_example"; - public defaultPage: boolean = false; - - async onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): Promise { - super.onCreate(want, launchParam); - } - - async onWindowStageCreate(windowStage: window.WindowStage): Promise { - const window = windowStage.getMainWindowSync(); - await window.setWindowLayoutFullScreen(false); - super.onWindowStageCreate(windowStage); - - await windowStage.loadContent("pages/Index"); - } -} diff --git a/xcomponent_example/entry/src/main/ets/pages/Index.ets b/xcomponent_example/entry/src/main/ets/pages/Index.ets deleted file mode 100644 index 7aba8a8..0000000 --- a/xcomponent_example/entry/src/main/ets/pages/Index.ets +++ /dev/null @@ -1,36 +0,0 @@ -import { DefaultXComponent } from "@ohos-rs/ability"; -import { - demoRequestPermissionFromMainThread, - toggleBackPressIntercept, -} from "libxcomponent_example.so"; - -const MODULE_NAME = "xcomponent_example"; - -@Entry -@Component -struct Index { - @State interceptEnabled: boolean = true; - - async handleClick() { - const re: number[] = await demoRequestPermissionFromMainThread(); - console.log(`${re}`); - } - - handleToggleBackIntercept() { - this.interceptEnabled = toggleBackPressIntercept(); - console.log(`backPressIntercept=${this.interceptEnabled}`); - } - - build() { - Row() { - Column() { - Button("request permission demo") - .onClick(() => this.handleClick()) - Button(this.interceptEnabled ? "back intercept: ON" : "back intercept: OFF") - .onClick(() => this.handleToggleBackIntercept()) - Text("Swipe back to test intercept behavior.") - DefaultXComponent({ moduleName: MODULE_NAME }) - }.width("100%") - }.height("100%"); - } -} diff --git a/xcomponent_example/entry/src/main/resources/base/element/color.json b/xcomponent_example/entry/src/main/resources/base/element/color.json deleted file mode 100644 index 3c71296..0000000 --- a/xcomponent_example/entry/src/main/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "start_window_background", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/xcomponent_example/entry/src/main/resources/base/element/string.json b/xcomponent_example/entry/src/main/resources/base/element/string.json deleted file mode 100644 index f945955..0000000 --- a/xcomponent_example/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "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/xcomponent_example/entry/src/main/resources/base/media/layered_image.json b/xcomponent_example/entry/src/main/resources/base/media/layered_image.json deleted file mode 100644 index 4f9ad63..0000000 --- a/xcomponent_example/entry/src/main/resources/base/media/layered_image.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "layered-image": { - "background": "$media:background", - "foreground": "$media:foreground" - } -} \ No newline at end of file diff --git a/xcomponent_example/entry/src/main/resources/base/media/startIcon.png b/xcomponent_example/entry/src/main/resources/base/media/startIcon.png deleted file mode 100644 index 205ad8b..0000000 Binary files a/xcomponent_example/entry/src/main/resources/base/media/startIcon.png and /dev/null differ diff --git a/xcomponent_example/entry/src/main/resources/base/profile/backup_config.json b/xcomponent_example/entry/src/main/resources/base/profile/backup_config.json deleted file mode 100644 index 78f40ae..0000000 --- a/xcomponent_example/entry/src/main/resources/base/profile/backup_config.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "allowToBackupRestore": true -} \ No newline at end of file diff --git a/xcomponent_example/entry/src/main/resources/base/profile/main_pages.json b/xcomponent_example/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index 55c3f00..0000000 --- a/xcomponent_example/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/Index" - ] -} \ No newline at end of file diff --git a/xcomponent_example/entry/src/main/resources/zh_CN/element/string.json b/xcomponent_example/entry/src/main/resources/zh_CN/element/string.json deleted file mode 100644 index 597ecf9..0000000 --- a/xcomponent_example/entry/src/main/resources/zh_CN/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_desc", - "value": "模块描述" - }, - { - "name": "EntryAbility_desc", - "value": "description" - }, - { - "name": "EntryAbility_label", - "value": "label" - } - ] -} \ No newline at end of file diff --git a/xcomponent_example/entry/src/mock/Libentry.mock.ets b/xcomponent_example/entry/src/mock/Libentry.mock.ets deleted file mode 100644 index 9d582b5..0000000 --- a/xcomponent_example/entry/src/mock/Libentry.mock.ets +++ /dev/null @@ -1,7 +0,0 @@ -const NativeMock: Record = { - add: (a: number, b: number) => { - return a + b; - }, -}; - -export default NativeMock; diff --git a/xcomponent_example/entry/src/mock/mock-config.json5 b/xcomponent_example/entry/src/mock/mock-config.json5 deleted file mode 100644 index 8f9b5a0..0000000 --- a/xcomponent_example/entry/src/mock/mock-config.json5 +++ /dev/null @@ -1,5 +0,0 @@ -{ - "libentry.so": { - "source": "src/mock/Libentry.mock.ets" - } -} diff --git a/xcomponent_example/entry/src/ohosTest/ets/test/Ability.test.ets b/xcomponent_example/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index bd7e94d..0000000 --- a/xcomponent_example/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -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); - }); - }); -} diff --git a/xcomponent_example/entry/src/ohosTest/ets/test/List.test.ets b/xcomponent_example/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 64971a8..0000000 --- a/xcomponent_example/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from "./Ability.test"; - -export default function testsuite() { - abilityTest(); -} diff --git a/xcomponent_example/entry/src/ohosTest/module.json5 b/xcomponent_example/entry/src/ohosTest/module.json5 deleted file mode 100644 index 55725a9..0000000 --- a/xcomponent_example/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/xcomponent_example/entry/src/test/List.test.ets b/xcomponent_example/entry/src/test/List.test.ets deleted file mode 100644 index 37ddf3e..0000000 --- a/xcomponent_example/entry/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from "./LocalUnit.test"; - -export default function testsuite() { - localUnitTest(); -} diff --git a/xcomponent_example/entry/src/test/LocalUnit.test.ets b/xcomponent_example/entry/src/test/LocalUnit.test.ets deleted file mode 100644 index a8e45e0..0000000 --- a/xcomponent_example/entry/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -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); - }); - }); -} diff --git a/xcomponent_example/hvigor/hvigor-config.json5 b/xcomponent_example/hvigor/hvigor-config.json5 deleted file mode 100644 index da31855..0000000 --- a/xcomponent_example/hvigor/hvigor-config.json5 +++ /dev/null @@ -1,21 +0,0 @@ -{ - "modelVersion": "5.0.0", - "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/xcomponent_example/hvigorfile.ts b/xcomponent_example/hvigorfile.ts deleted file mode 100644 index 9d563d9..0000000 --- a/xcomponent_example/hvigorfile.ts +++ /dev/null @@ -1,6 +0,0 @@ -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. */, -};