Repository navigation
feat(napi): XamlWindow (XAML Islands) and agile JS delegates - #38
Merged
Merged
Conversation
Event sources that only accept agile handlers, such as DispatcherQueueTimer.Tick, rejected JS functions with "The object must support the IAgileObject interface". Both delegate implementations already run off-thread invokes on the owner JS thread, so they now say so in QueryInterface (classic and napi). The IAgileObject IID moves to value.rs and is shared.
Adds XAML Islands hosting to @nativescript/windows-napi:
- xaml_host.rs: a host window ('dialog' or borderless 'popup'),
DesktopWindowXamlSource attach, PreTranslateMessage from a
WH_GETMESSAGE hook so Tab and access keys work whoever owns the
message loop, DPI-aware placement, and activate / deactivate /
close / closed events queued on the dispatcher so JS never runs
inside the window procedure.
- Helpers: foregroundWindow, activateWindow, enableWindow,
windowProcessId. Window handles are accepted as numbers, bigints or
Buffers (as returned by getNativeWindowHandle()).
- nswinrt.js: XamlWindow class (theme detection, events, a clear error
when the host manifest lacks maxversiontested).
- test/xaml-host-test.js; README section.
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
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.
Summary
DispatcherQueueTimer.Tick, rejected JS functions with "The object must support the IAgileObject interface". Both delegate implementations (classic and napi) already run off-thread invokes on the owner JS thread, soQueryInterfacenow answersIAgileObject.XamlWindowin@nativescript/windows-napi. HostsWindows.UI.Xamlcontent (XAML Islands) in a Win32 window:style: 'dialog'(title bar, close box, optional owner) or'popup'(borderless, not in the taskbar or Alt+Tab), plustopmostandtheme.PreTranslateMessageruns from aWH_GETMESSAGEhook, so Tab and access keys work no matter who owns the message loop.place(): centers over a window, or on the pointer's monitor.activate/deactivate/close/closedevents are queued on the dispatcher, so JS never runs inside the window procedure.foregroundWindow,activateWindow,enableWindow,windowProcessId. Window handles come in as numbers, bigints or Buffers. They are window handles, not memory pointers: user32 validates them.maxversiontested10.0.18362 or later in the host executable's manifest.electron.exehas it;node.exedoesn't, soXamlWindowthrows a clear error there.Testing
npm testinwindows-napi: 442 passed, 0 failed across 23 suites, including the newxaml-host-test.js. Under node.exe the new suite only checks the error path.ELECTRON_RUN_AS_NODE=1 electron.exe test/xaml-host-test.js(Electron 45.2.3): 14 passed. This covers create, content, place, show/hide, events and close.cargo check -p runtime(classic) passes.