feat: pr63 pluginized - #68
Open
richerfu wants to merge 31 commits into
Open
Conversation
Split every capability of #63 into the pluginized bridge architecture (crates/plugin-* + plugins/* pairs with named N-API contracts, no JSON envelope): new plugins: - plugin-version (ohos.version): sdk/distribution API version, canIUse, is-desktop-device (sync/ability) - plugin-clipboard (ohos.clipboard): write RGBA image to system clipboard (async/ability) - plugin-updater (ohos.updater): AppGallery check + download-and-install (async/ability) - plugin-menu (ohos.menu): per-window menubar, context popup, visibility; menu-click via the scoped main-thread named N-API event port - plugin-statusbar (ohos.statusbar): tray add/remove/icon/menu/tips/ predefined-action; icon-click/menu-click scoped events extensions: - plugin-app-control: restart (appRecovery, 3s cooldown), set-color-mode - plugin-window: create-os-window, decorations, background color, blur, focus, focusable, move, resize, minimize/maximize/restore/recover/show, is-maximized/is-minimized - plugin-webview: windowId on create, style width/height, set-bounds, set-cookie, snapshot, create-pdf, set/is-debugging-access core: - AbilityInitContext carries sdkApiVersion/distributionOSApiVersion - core version module (init + thread-safe getters) used by #[ability] macro - NewWant event + want.parameters/uri storage (deep-link) - log feature for mouse event cfg demo & docs: - demo_native exercises every new plugin facade - demo EntryAbility registers all 9 builtin plugins - plugin-development-standard.md contract table + helper migration table - named-napi-contracts skill contract table synced
- adopt napi-ohos 1.2 and upgraded ohos bindings (arkui 0.2, xcomponent 0.3, ime 0.2, web 0.2, display 0.1, resource-manager 0.3, hilog 0.2) from main - keep all 9 plugin workspace deps + crossbeam-channel - prek.toml rustfmt hook from main (cargo fmt --check) - demo_native: main's MouseEvent-aware event match + all plugin facades - drop leftover ohos-arkui-sys / ohos-xcomponent-sys deps (mouse_event.rs was removed with the ohdev leftovers) - regenerate Cargo.lock
- adopt napi-ohos 1.2 and upgraded ohos bindings (arkui 0.2, xcomponent 0.3, ime 0.2, web 0.2, display 0.1, resource-manager 0.3, hilog 0.2) from main - keep the 4 plugin workspace deps of this branch - prek.toml rustfmt hook from main (cargo fmt --check) - demo_native: main's MouseEvent-aware event match - regenerate Cargo.lock
Split both capabilities of #65 into the pluginized bridge model on the pluginized-bridge base: - plugin-url (ohos.url / open-url): external link opening via context.openLink (async/ability), absolute-URL validation on the Rust facade - plugin-files (ohos.files / file-dialog): DocumentViewPicker open/save/folder dialogs (async/ability) File dialog parameters travel as a structured named N-API object (ohos.files.DialogOptions with structured DialogFilter { name, pattern }); no string-encoded filter grammar crosses the bridge - the picker-specific 'name|*.ext' choice strings and ';'-separated patterns are converted only inside the ArkTS plugin. demo & docs: - demo_native: demo_open_url, demo_file_dialog_open, demo_file_dialog_save - demo EntryAbility registers ohos.url and ohos.files - Index.ets: new 'Platform services demo' tab - plugin-development-standard.md + named-napi-contracts skill contract tables
Follow-up work on top of the PR #65 pluginization: - abstract plugin bases (PluginBase / AsyncPluginBase / SyncPluginBase): execution mode fixed by the base, identity declared once on the plugin, optional lifecycle hooks with default no-ops; exported from @ohos-rs/ability - registration: identity no longer repeated — BridgePluginFactory reduced to { modules?, create }, LazyPlugin wraps a per-session instance closure, and the context is lazy-injected via attachContext() after creation (before onInstall); factory/plugin consistency check removed (instance is the single source of truth) - hvigor ArkTS compiler fixes: restore literal annotations (ArkTS rejects as const), drop as unknown / indexed-access types, definite-assignment-safe init chain with failure logging in NativeAbility - demo.raw factory contract + DemoNodePlugin.requires mismatch fixed - demo buttons overflow fixed (Flex wrap + Scroll) - ignore build artifacts (oh_modules, build dirs)
Adopt the pluginized-bridge evolution (abstract plugin bases, LazyPlugin registration, context lazy-injection, hvigor ArkTS fixes) and migrate all PR #63 plugins to the new model: - 11 plugins registered via new LazyPlugin(() => new X()) in EntryAbility - PR #63 plugins (clipboard, menu, statusbar, updater, version) migrated: extends AsyncPluginBase/SyncPluginBase, identity once, static-free, attachContext for context-needing plugins (menu, statusbar, window) - app-control keeps restart/set-color-mode extensions on SyncPluginBase - window keeps multi-window actions (create-os-window, decorations, blur, focus, move/resize/min-max/restore/show, is-maximized/minimized) on the new model with attachContext - demo_native merges both demo facades (PR #63 menu/statusbar/version/ clipboard/updater/restart/color-mode + PR #65 url/files) - Cargo.toml: 11 plugin workspace deps; Cargo.lock regenerated
hvigor fails when a HAR referenced by oh-package.json5 is not listed in demo/build-profile.json5 modules. Add the 5 PR #63 plugin modules (plugin_clipboard, plugin_menu, plugin_statusbar, plugin_updater, plugin_version) alongside the existing ones (11 total).
Real hvigor compile (DevEco 6.1.1.280 SDK) surfaced ArkTS rule violations in the merged PR #63 plugins: - ESObject-typed consts need explicit annotations (arkts-no-any-unknown on inference): dynamicItem/icons/result/dynamic in statusbar, webview, window - clipboard: drop namespace cast (arkts-no-ns-as-obj) and call pasteboard.createData directly (ValueType supports PixelMap since API 9) - statusbar: restore accidentally removed @ohos-rs/ability import (caused cascading unknown errors), add requireContext, explicit payload interfaces instead of object-literal types, no delete operator, static @ohos.process import, common.UIAbilityContext for indexed-access type - menu: no object spread (arkts-no-spread), MenuBarRequest gains visible - updater: checkAppUpdate/showUpdateDialog take context (API 12 signature) - webview: getWebPageSnapshot + createPdf via ESObject dynamic dispatch (API 12 controller surface lacks them; createPdf is callback-style) BUILD SUCCESSFUL with DevEco 6.1.1.280 hvigorw.
…t onCreate - EagerPlugin: shares one caller-constructed BridgePlugin instance across native modules and Ability sessions, for plugins owning process-wide global state (e.g. ohos.resource); tolerates repeated attachContext - attachBridgeEventSink runs right after module.init in onCreate so ability-only plugins can emit ArkTS -> Rust inbound events on ability-create instead of waiting for ui-context-ready; the render-time attach in DefaultXComponent remains as an idempotent fallback
- new paired plugin: crates/plugin-resource (Rust facade, ResourceBridgePlugin) + plugins/resource (ArkTS wrapper, ResourcePlugin); inbound-only resource-manager-ready event pushes the platform resourceManager object into a native pointer inside the same N-API callback, then all reads go through ohos-resource-manager-binding C API - remove the built-in global resource manager from crates/ability (resource.rs, app.resource_manager(), derive init hook); use ResourceExt / openharmony_ability_plugin_resource::resource_manager() instead - demo: Resource demo page (installed check + raw dir count), EagerPlugin registration in EntryAbility, workspace/demo dependency wiring - docs: plugin-development-standard §3/§8 (inbound event timing, EagerPlugin shared instances), contract-table, crate READMEs
Project overview, build/lint/format commands, architecture map, plugin contract rules and the new-plugin checklist for agents working in this repository.
…bridge The fix targeted crates/ability/src/helper/webview.rs (Rc<ObjectRef> leak) which was deleted by the pluginized-bridge rearchitecture; Rust no longer holds an ObjectRef. Keep the current branch's code and record the reconciliation. Co-Authored-By: Claude <noreply@anthropic.com>
Reconcile the pluginized resource manager (ohos.resource) from feat/pluginized-bridge with the statusbar/updater/menu/version/clipboard plugins already on feat/pr63-pluginized: - workspace + lockfiles: union resource/statusbar/updater deps - derive macro: drop the deleted ResourceManager init, keep version init - demo & ArkTS entry: register both plugin sets - docs: merge both contract tables Also fix .gitignore which carried leftover conflict markers committed by an earlier merge (ee55373). Co-Authored-By: Claude <noreply@anthropic.com>
…pr63-pluginized - bridge: adopt main's call_sync_from_worker (worker -> main-thread sync via TSFN) plus tsfn_sync_bridge demo wiring - packages: rename all plugins to @ohos-rs/ability-plugin-* and bump to 1.0.0-beta.0 (author/keywords/repository metadata) matching main's published form; drop the libnative_ability.so dependency from native_ability and plugin lockfiles - keep PR #63 pluginization: clipboard/menu/statusbar/updater/version crates and HARs, evolved webview/window/app-control plugins, demo registrations - delete legacy package/ staging dir (main removed it; workspace excludes it) - docs: fold main's call_sync_from_worker guidance into AGENTS.md and plugin-development-standard.md Co-Authored-By: Claude <noreply@anthropic.com>
# Conflicts: # Cargo.lock # Cargo.toml # crates/ability/src/app.rs # crates/derive/src/lib.rs # crates/plugin-webview/src/lib.rs # demo/entry/src/main/ets/entryability/EntryAbility.ets # docs/plugin-development-standard.md # plugins/webview/src/main/ets/WebviewPlugin.ets # plugins/window/src/main/ets/WindowPlugin.ets # rust_example/demo_native/Cargo.toml # rust_example/demo_native/src/lib.rs
# Conflicts: # .agents/skills/named-napi-contracts/references/contract-table.md # demo/entry/src/main/ets/entryability/EntryAbility.ets
# Conflicts: # crates/plugin-window/README.md
# Conflicts: # AGENTS.md # docs/plugin-development-standard.md
ljy9812
pushed a commit
to ljy9812/openharmony-ability
that referenced
this pull request
Aug 20, 2026
…ore + PR harmony-contrib#68 plugins) Phase A0 of bridge migration: merge upstream pluginized bridge architecture into local ohdev branch with conflict resolution. Key changes: - Restored helper module from pre-merge (needed by legacy feature modules) - Preserved deleted files to _legacy/ directories - Merged type.ets: kept old ArkHelper/WebView types + new bridge types - Merged NativeAbility.ets: kept old ProcessInitializer lifecycle (bridge migration in A1+) - Merged DefaultXComponent.ets: upstream new bridge-based architecture - Merged MainPage.ets: kept old MenuBarComponent/WindowManager integration - Fixed xcomponent-sys version mismatch (0.0.2 -> 0.1) - Fixed axis event FFI (private in newer sys crate, re-declared locally) - Removed duplicate MouseEvent variant in input/mod.rs Compilation: 0 errors on both aarch64-unknown-linux-ohos and Windows. Rollback tag: pre-bridge-merge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.