Repository navigation
feat(napi): Win32 calls, native callbacks and message windows - #50
Merged
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the
|
triniwiz
force-pushed
the
feat/napi-win32
branch
from
November 9, 2026 02:51
5f98dc0 to
f595064
Compare
Adds NSWinRT.win32 to the napi engines (windows-napi and the standalone runtimes), on the classic engine's libffi Win32 core: - call/bind/define/import; pointer arguments also take buffers, pointer objects and BigInts, and 64-bit results beyond 2^53 are BigInts. - callback(retType, argTypes, fn): a native function pointer calling fn. - messageWindow(listener): a hidden window whose messages go to listener(msg, wParam, lParam), for tray icons, hotkeys and menus. An open window keeps a standalone runtime's event loop running.
triniwiz
force-pushed
the
feat/napi-win32
branch
from
November 9, 2026 03:10
d31bd01 to
b9954a7
Compare
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.
The napi engines (
@nativescript/windows-napiand the standalone engine runtimes) only reached WinRT. This addsNSWinRT.win32to them (exported aswin32fromwindows-napi), built on the classic engine's libffi Win32 core inruntime/src/win32.rs, which now compiles for both engines.Calls —
call,bind,defineandimport, as in the classic runtime:pointerarguments also take anArrayBuffer, typed array orDataView(its memory, for structs and out-parameters), a pointer object, or aBigInt.nullfor awstr/strparameter is a null pointer.BigInt;definealso accepts{ args, ret }per function.Callbacks —
win32.callback(retType, argTypes, fn)returns{ pointer, release() }: a libffi closure that callsfnsynchronously on the JS thread (calls from another thread are run there and waited on, as for WinRT delegates). For APIs that take a function pointer:EnumWindows, aWNDPROC, hooks.Window messages —
win32.messageWindow(listener)returns{ hwnd, close() }, a hidden top-level window whose messages are delivered tolistener(msg, wParam, lParam)through the UI dispatcher, so JS never runs inside the window procedure. It is the window for a tray icon's callback message,RegisterHotKey(WM_HOTKEY) and popup menus (WM_COMMAND). Being top-level rather than message-only, it also receives broadcasts such asTaskbarCreated. While open, it keeps a standalone runtime's event loop running.The README has a tray icon + global hotkey example;
test/win32-test.jscovers calls, buffers, BigInt, null strings, callbacks (including a throwing one) and message delivery.