@windowkit/appkit 0.30.2 → 0.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +159 -1
- package/binding.gyp +7 -2
- package/index.js +5 -2
- package/package.json +2 -2
- package/prebuilds/darwin-arm64/calayers.node +0 -0
- package/prebuilds/darwin-x64/calayers.node +0 -0
- package/src/addon.mm +6 -0
- package/src/backend.mm +16 -0
- package/src/capture.mm +1944 -0
- package/src/permissions.mm +64 -3
- package/src/systemaudio.mm +876 -0
package/README.md
CHANGED
|
@@ -705,6 +705,162 @@ height, duration }` once the item is ready, and again if either moves (`duration
|
|
|
705
705
|
tagged BT.709 — on a layer and copied into a surface beside it, and holds the two to
|
|
706
706
|
the same colour on screen: 211, 127, 67 and 211, 127, 68 on an M1 Pro.
|
|
707
707
|
|
|
708
|
+
## Capture: cameras, microphones, the audio out, the screen
|
|
709
|
+
|
|
710
|
+
The devices a renderer's media capture lists and opens (react-x11's
|
|
711
|
+
`getUserMedia`, `<video srcObject>`, `createAudioFrames`, `captureScreenshot`).
|
|
712
|
+
Listing asks for nothing and raises no prompt; opening a camera or a microphone
|
|
713
|
+
needs the grant `authorizationStatus` reads, and a renderer asks for it first
|
|
714
|
+
(`requestAuthorization`) so the open never has to.
|
|
715
|
+
|
|
716
|
+
**Devices.**
|
|
717
|
+
|
|
718
|
+
- **`native.captureDevices()`** → `[{ id, kind, name, isDefault, groupId?,
|
|
719
|
+
position?, formats? }]`, or **`native.captureDevices(cb)`**, which lists on a
|
|
720
|
+
queue of its own: the first listing in a process loads AVFoundation's camera
|
|
721
|
+
plug-ins, 100 ms to over a second that a UI thread should not wait out. `kind`
|
|
722
|
+
is `'camera'`, `'microphone'` or `'speaker'`; `id` is stable across launches
|
|
723
|
+
(a microphone's is its CoreAudio UID); a camera's `formats` are `[{ width,
|
|
724
|
+
height, minFrameRate, maxFrameRate }]` and its `position` `'front'`,
|
|
725
|
+
`'back'`, `'external'` or `'unspecified'`; `groupId` is set where a camera and
|
|
726
|
+
a microphone share a model. The private aggregate devices an audio engine
|
|
727
|
+
makes for itself are left out.
|
|
728
|
+
- Event **`capture-devices`** whenever a device comes or goes or the default
|
|
729
|
+
input or output moves — from the first listing on, and only when what a
|
|
730
|
+
listing shows changed.
|
|
731
|
+
|
|
732
|
+
**A camera.**
|
|
733
|
+
|
|
734
|
+
- **`native.openCamera(deviceId | null, { width, height, frameRate })`** →
|
|
735
|
+
`{ id, layer, width, height, frameRate, format, range, colorSpace }`: the
|
|
736
|
+
device's format nearest the size asked (a 4:2:0 YCbCr one where it has one —
|
|
737
|
+
every Mac camera seen so far has only those — so nothing is converted on the
|
|
738
|
+
way) at the rate asked, clamped to it; nothing asked is the largest within
|
|
739
|
+
1280x720. The rate is set from the format's own frame rate ranges, so the
|
|
740
|
+
fastest a format lists is asked for exactly. The session starts on a queue of
|
|
741
|
+
its own, and `camera-started { id, frameRate }` or `camera-error { id, name,
|
|
742
|
+
message }` follows — `name` is Media Capture's: `NotFoundError`,
|
|
743
|
+
`NotAllowedError`, `NotReadableError`, the last also for a configuration
|
|
744
|
+
AVFoundation would not take. `layer` is an
|
|
745
|
+
`AVCaptureVideoPreviewLayer`, a handle every layer verb takes, filling its
|
|
746
|
+
bounds and never mirrored; the renderer fits and flips.
|
|
747
|
+
- **`native.cameraFrames(id, on)`** — while on, `camera-frame { id, width,
|
|
748
|
+
height, format, range, colorSpace, planes, strides, time }`: the frame's own
|
|
749
|
+
planes (NV12: Y, then CbCr) as `Buffer` copies, `time` in seconds on the
|
|
750
|
+
capture clock. The newest frame only: one that arrives while the last is
|
|
751
|
+
still on its way replaces it, in pump mode and through the channel alike.
|
|
752
|
+
Off by default, so a preview on the layer costs nothing in JS.
|
|
753
|
+
- **`native.cameraCopyFrame(id, surface)`** — `playerCopyFrame`'s contract:
|
|
754
|
+
the newest frame into a 2D surface of its size, in the layer's colours, or
|
|
755
|
+
`null` when none is newer than the last one copied.
|
|
756
|
+
- Events `camera-muted { id, muted }` (the session interrupted — another app
|
|
757
|
+
took the camera — and resumed) and `camera-ended { id }` (unplugged, or a
|
|
758
|
+
runtime error). **`native.closeCamera(id)`**.
|
|
759
|
+
|
|
760
|
+
**The audio.** One `AVAudioEngine` for every microphone and every output: an
|
|
761
|
+
echo canceller needs the far-end signal, so while an echo-cancelled microphone
|
|
762
|
+
is open voice processing is on for the engine's input and output both, and
|
|
763
|
+
every output plays through it.
|
|
764
|
+
|
|
765
|
+
- **`native.openMicrophone(deviceId | null, { sampleRate, channels,
|
|
766
|
+
echoCancellation, noiseSuppression, autoGainControl })`** → `{ id,
|
|
767
|
+
sampleRate, channels, echoCancellation, noiseSuppression, autoGainControl }`,
|
|
768
|
+
what was asked. The audio is resampled and mixed down here, so `{ sampleRate:
|
|
769
|
+
16000, channels: 1 }` arrives as asked. `microphone-started { id,
|
|
770
|
+
echoCancellation, noiseSuppression, autoGainControl, sampleRate, channels,
|
|
771
|
+
latency }` says what the engine did — voice processing engaged or not — and
|
|
772
|
+
`microphone-error { id, name, message }` what went wrong; then `audio-input
|
|
773
|
+
{ id, sampleRate, channels, frames, time, dropped? }` every 10 ms, a
|
|
774
|
+
`Float32Array` a channel. Nothing is dropped short of two seconds of chunks
|
|
775
|
+
waiting; past that, `dropped` counts them. One input device at a time.
|
|
776
|
+
**`native.closeMicrophone(id)`**.
|
|
777
|
+
|
|
778
|
+
Where voice processing will not start on an input — some Bluetooth headsets'
|
|
779
|
+
microphones — or keeps reconfiguring the device (three configuration
|
|
780
|
+
changes in five seconds), the microphone runs without it and
|
|
781
|
+
`microphone-started` says `echoCancellation: false`, until every microphone
|
|
782
|
+
closes. A microphone that was live and whose engine cannot come back after a
|
|
783
|
+
configuration change ends: `microphone-ended { id }`.
|
|
784
|
+
- **`native.openAudioOutput({ sampleRate, channels, deviceId })`** → `{ id,
|
|
785
|
+
sampleRate, channels }`; **`native.audioOutputWrite(id, [Float32Array, …])`**
|
|
786
|
+
→ frames now queued (ten seconds at most); **`native.audioOutputState(id)`**
|
|
787
|
+
→ `{ currentTime, queued, latency }`, `currentTime` the seconds the device has
|
|
788
|
+
played since the first write, silence where the queue ran dry included;
|
|
789
|
+
**`native.closeAudioOutput(id)`**. One output device for the engine: the
|
|
790
|
+
first output's `deviceId` picks it.
|
|
791
|
+
|
|
792
|
+
`APPKIT_DEBUG_AUDIO=1` writes what the engine does to stderr: each rebuild and
|
|
793
|
+
why, whether voice processing engaged, the input's format, each start and its
|
|
794
|
+
error, configuration changes, and once a second the frames the input gave and
|
|
795
|
+
the chunks that went to JS.
|
|
796
|
+
|
|
797
|
+
**The screen.**
|
|
798
|
+
|
|
799
|
+
- **`native.captureScreenshot({ display, window, rect, cursor }, cb)`** — one
|
|
800
|
+
picture through ScreenCaptureKit (macOS 14): `cb({ width, height, scale,
|
|
801
|
+
data })` with `data` straight RGBA in sRGB, or `cb({ error, name })` —
|
|
802
|
+
`NotAllowedError` without the Screen Recording grant, `NotFoundError` for a
|
|
803
|
+
display or window that is not there, `NotSupportedError` before macOS 14.
|
|
804
|
+
`display` is a `screenCaptureDisplays` id (the main display without one),
|
|
805
|
+
`window` a window number, `rect` points within the display.
|
|
806
|
+
- **`native.screenCaptureDisplays()`** → `[{ id, name, x, y, width, height,
|
|
807
|
+
scale }]`, points from the top left of the main display; through a callback
|
|
808
|
+
off the main thread.
|
|
809
|
+
- **`native.setWindowSharing(win, 'none' | 'readOnly')`** — `NSWindow.sharingType`:
|
|
810
|
+
`'none'` keeps the window out of every screenshot and recording, this app's
|
|
811
|
+
own included. On macOS 15 such a window comes back with every pixel clear.
|
|
812
|
+
|
|
813
|
+
**Other applications' sound** — CoreAudio's process taps, macOS 14.2 (these
|
|
814
|
+
three verbs are not exported before it, which is how a renderer tells). A tap
|
|
815
|
+
is private to this process, sits in an aggregate device of its own with
|
|
816
|
+
nothing else in it — no output device beside it, whose input streams would be
|
|
817
|
+
opened too: a headset's microphone, a Bluetooth headset switched into its call
|
|
818
|
+
profile by that — and leaves what it taps audible.
|
|
819
|
+
|
|
820
|
+
- **`native.audioProcesses()`** → `[{ pid, bundleId, name, playing, app? }]`,
|
|
821
|
+
or **`native.audioProcesses(cb)`** from a queue of its own: every process
|
|
822
|
+
connected to the audio server, not only the ones playing. `playing` is
|
|
823
|
+
whether it has output running now. `app` is the outermost application bundle
|
|
824
|
+
its executable sits in, `{ bundleId, name, regular }` (`regular`: it has a
|
|
825
|
+
Dock icon) — a browser's renderers and an Electron app's helpers play under
|
|
826
|
+
helper bundle ids of their own, `com.google.Chrome.helper`, and `app` is
|
|
827
|
+
what a person would call them. A tool in no bundle (`afplay`) has an empty
|
|
828
|
+
`bundleId` and no `app`.
|
|
829
|
+
- Event **`audio-processes`** whenever a process connects or goes, or starts or
|
|
830
|
+
stops playing — from the first listing on.
|
|
831
|
+
- **`native.openSystemAudio({ pid?, bundleId?, exclude?, sampleRate, channels
|
|
832
|
+
})`** → `{ id, sampleRate, channels }`. With neither `pid` nor `bundleId`, every
|
|
833
|
+
process but this one and the pids in `exclude`; with `pid`, that process;
|
|
834
|
+
with `bundleId`, every process whose own bundle id or `app` is that one. A
|
|
835
|
+
bundle id's tap follows the application — a helper that starts later joins
|
|
836
|
+
it, an application that is not running is silence until it is — and the tap
|
|
837
|
+
of everything leaves this process out once it has connected.
|
|
838
|
+
`system-audio-started { id, sampleRate, channels, latency }` or
|
|
839
|
+
`system-audio-error { id, name, message }` answers it: `NotFoundError` for a
|
|
840
|
+
pid with no audio (said before anything is asked of the user),
|
|
841
|
+
`NotAllowedError`, `NotReadableError` for CoreAudio saying no. Then
|
|
842
|
+
`audio-input` every 10 ms, a microphone's event exactly — resampled and
|
|
843
|
+
mixed to what was asked, silence included while nothing plays, nothing
|
|
844
|
+
dropped short of two seconds waiting — and `system-audio-ended { id }` when
|
|
845
|
+
the one process tapped has gone. **`native.closeSystemAudio(id)`**.
|
|
846
|
+
|
|
847
|
+
The grant is System Audio Recording (`authorizationStatus('system-audio-recording')`,
|
|
848
|
+
below), and a tap without it is no error: it delivers silence. So an open reads
|
|
849
|
+
the status first, refuses a denial by name and asks where nobody has been
|
|
850
|
+
asked, before the tap is made.
|
|
851
|
+
|
|
852
|
+
`test/capture.js` lists the devices both ways, opens a camera and a microphone
|
|
853
|
+
that are not there (refused by name, nothing prompted), plays 0.2 s through an
|
|
854
|
+
output on the device's clock, and — where Screen Recording is allowed — reads a
|
|
855
|
+
red window back as red and an excluded one as clear. A camera and a microphone
|
|
856
|
+
that this process may use are opened and read from; where it may not they are
|
|
857
|
+
skipped, never prompted. `test/capture-threaded.js` does the same from a
|
|
858
|
+
worker. `test/system-audio.js` lists the processes both ways, plays a file of
|
|
859
|
+
silence through `afplay` and sees it announced coming and going, refuses a
|
|
860
|
+
process with no audio, and — only where System Audio Recording is allowed —
|
|
861
|
+
taps everything and one process; `test/system-audio-threaded.js` lists and
|
|
862
|
+
refuses from a worker.
|
|
863
|
+
|
|
708
864
|
## Text: at a display's scale
|
|
709
865
|
|
|
710
866
|
A text verb's size is the caller's pixels, and a renderer that draws in device pixels hands
|
|
@@ -1164,6 +1320,7 @@ native.openPrivacySettings(kind?); // no kind: th
|
|
|
1164
1320
|
| ------------------------ | ---------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1165
1321
|
| `camera`, `microphone` | `AVCaptureDevice authorizationStatusForMediaType:` | `requestAccessForMediaType:` | all four statuses; the prompt is in-process and the answer arrives when the user clicks |
|
|
1166
1322
|
| `screen-recording` | `CGPreflightScreenCaptureAccess` | `CGRequestScreenCaptureAccess` | a bool, so never `notDetermined`; the "prompt" is the system's go-to-Settings dialog (shown once) and the request resolves at once. A new grant needs a process restart |
|
|
1323
|
+
| `system-audio-recording` | `TCCAccessPreflight` for `kTCCServiceAudioCapture` | `TCCAccessRequest` | macOS 14.2, for `openSystemAudio`. There is no public call to read or ask for this one, so TCC's own pair is found at run time; where it is not there — and before 14.2 — the status is `unknown` and a tap's first read is the prompt. A refusal is not an error from a tap but silence, which is why the status is worth reading. The bundle's key is `NSAudioCaptureUsageDescription`; Settings › Privacy & Security › Screen & System Audio Recording holds the switch (`Privacy_AudioCapture`) |
|
|
1167
1324
|
| `accessibility` | `AXIsProcessTrusted` | `AXIsProcessTrustedWithOptions` + prompt | a bool, so never `notDetermined`; go-to-Settings dialog, resolves at once, the grant applies live |
|
|
1168
1325
|
| `input-monitoring` | `IOHIDCheckAccess` (listen) | `IOHIDRequestAccess` | granted / denied / unknown → `notDetermined`; the request posts the prompt and resolves at once, `notDetermined` while it is still up |
|
|
1169
1326
|
| `automation` | `AEDeterminePermissionToAutomateTarget` | the same, asking | needs `{ target: bundleId }` of a **running** app, otherwise throws — TCC only answers for a running target. Asking blocks until answered, so it runs off the main thread |
|
|
@@ -1176,7 +1333,8 @@ native.openPrivacySettings(kind?); // no kind: th
|
|
|
1176
1333
|
process* (Terminal, an IDE) or to `node` itself, and prompts with no
|
|
1177
1334
|
usage-description strings. A bundled app must carry the keys
|
|
1178
1335
|
(`NSCameraUsageDescription`, `NSMicrophoneUsageDescription`,
|
|
1179
|
-
`
|
|
1336
|
+
`NSAudioCaptureUsageDescription`, `NSLocationUsageDescription`,
|
|
1337
|
+
`NSAppleEventsUsageDescription`; for
|
|
1180
1338
|
EventKit on macOS 14+ `NSCalendarsFullAccessUsageDescription`,
|
|
1181
1339
|
`NSCalendarsWriteOnlyAccessUsageDescription` and
|
|
1182
1340
|
`NSRemindersFullAccessUsageDescription`, and before 14
|
package/binding.gyp
CHANGED
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"src/screencolor.mm",
|
|
12
12
|
"src/threaded.mm",
|
|
13
13
|
"src/video.mm",
|
|
14
|
-
"src/player.mm"
|
|
14
|
+
"src/player.mm",
|
|
15
|
+
"src/capture.mm",
|
|
16
|
+
"src/systemaudio.mm"
|
|
15
17
|
],
|
|
16
18
|
"include_dirs": [
|
|
17
19
|
"<!@(node -p \"require('node-addon-api').include\")"
|
|
@@ -39,7 +41,10 @@
|
|
|
39
41
|
"-framework IOKit",
|
|
40
42
|
"-framework ApplicationServices",
|
|
41
43
|
"-framework UserNotifications",
|
|
42
|
-
"-framework EventKit"
|
|
44
|
+
"-framework EventKit",
|
|
45
|
+
"-framework CoreAudio",
|
|
46
|
+
"-framework AudioToolbox",
|
|
47
|
+
"-weak_framework ScreenCaptureKit"
|
|
43
48
|
]
|
|
44
49
|
}
|
|
45
50
|
}
|
package/index.js
CHANGED
|
@@ -188,7 +188,8 @@ const controls = {
|
|
|
188
188
|
};
|
|
189
189
|
|
|
190
190
|
// Privacy (TCC) authorizations. kind: 'camera' | 'microphone' |
|
|
191
|
-
// 'screen-recording' | '
|
|
191
|
+
// 'screen-recording' | 'system-audio-recording' | 'accessibility' |
|
|
192
|
+
// 'input-monitoring' | 'location' |
|
|
192
193
|
// 'automation' (with { target: bundleId }) | 'calendars' | 'reminders'
|
|
193
194
|
// (EventKit; calendars takes { access: 'full' | 'write-only' }, full by
|
|
194
195
|
// default). Status and request never touch policy: the renderer decides when
|
|
@@ -197,7 +198,9 @@ const permissions = {
|
|
|
197
198
|
// -> 'authorized' | 'denied' | 'restricted' | 'notDetermined', or
|
|
198
199
|
// 'writeOnly' for calendars and reminders on macOS 14+: the app may save
|
|
199
200
|
// items it cannot read, which is granted to a writer and denied to a reader
|
|
200
|
-
// — the word crosses as it is so the caller can decide
|
|
201
|
+
// — the word crosses as it is so the caller can decide; and 'unknown' for
|
|
202
|
+
// system-audio-recording where nothing can read it (before macOS 14.2, or a
|
|
203
|
+
// TCC without the calls). Never prompts.
|
|
201
204
|
status: (kind, opts) => native.authorizationStatus(kind, opts),
|
|
202
205
|
// Raises the system prompt where macOS has one; resolves to granted — the
|
|
203
206
|
// level asked for is held afterwards (for calendars with
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@windowkit/appkit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.32.0",
|
|
4
4
|
"description": "Retained-mode AppKit backend for Node.js: Core Animation (CALayer) layer trees, CoreText layout and drawing, IOSurface presentation, NSMenu, and native control bezels — the macOS half of react-x11.",
|
|
5
5
|
"author": "Andrey Sidorov <andrey.sidorov@gmail.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
"install": "node scripts/install.js",
|
|
44
44
|
"build": "node-gyp rebuild",
|
|
45
45
|
"demo": "node demo/demo.js",
|
|
46
|
-
"test": "node test/app-lifecycle.js && node test/animation.js && node test/layer-transform.js && node test/contents-gravity.js && node test/contents-center.js && node test/accessibility-display.js && node test/ignores-mouse-events.js && node test/popup-menu.js && node test/pasteboard-write.js && node test/surface-blit.js && node test/surface-faded.js && node test/image-smoothing.js && node test/surface-colorspace.js && node test/video-surface.js && node test/player.js && node test/player-vp9.js && node test/round-rect-xy.js && node test/clip-rule.js && node test/radial-gradient.js && node test/control-bezels.js && node test/text-features.js && node test/font-from-data.js && node test/text-coverage.js && node test/text-typesetter.js && node test/text-line-height.js && node test/text-line-width.js && node test/text-justify.js && node test/text-scale.js && node test/symbols.js && node test/eventkit-permissions.js && node test/calendars.js && node test/calendar-writes.js && node test/screencolor.js && node test/notifications.js && node test/threaded.js && node test/threaded-verbs.js && node test/threaded-frames.js && node test/threaded-resize.js && node test/ending-worker.js && node test/live-resize.js && node test/window-states.js && node test/threaded-window-states.js && node test/activation-policy.js && node test/last-input.js"
|
|
46
|
+
"test": "node test/app-lifecycle.js && node test/animation.js && node test/layer-transform.js && node test/contents-gravity.js && node test/contents-center.js && node test/accessibility-display.js && node test/ignores-mouse-events.js && node test/popup-menu.js && node test/pasteboard-write.js && node test/surface-blit.js && node test/surface-faded.js && node test/image-smoothing.js && node test/surface-colorspace.js && node test/video-surface.js && node test/player.js && node test/player-vp9.js && node test/capture.js && node test/capture-threaded.js && node test/system-audio.js && node test/system-audio-threaded.js && node test/round-rect-xy.js && node test/clip-rule.js && node test/radial-gradient.js && node test/control-bezels.js && node test/text-features.js && node test/font-from-data.js && node test/text-coverage.js && node test/text-typesetter.js && node test/text-line-height.js && node test/text-line-width.js && node test/text-justify.js && node test/text-scale.js && node test/symbols.js && node test/eventkit-permissions.js && node test/calendars.js && node test/calendar-writes.js && node test/screencolor.js && node test/notifications.js && node test/threaded.js && node test/threaded-verbs.js && node test/threaded-frames.js && node test/threaded-resize.js && node test/ending-worker.js && node test/live-resize.js && node test/window-states.js && node test/threaded-window-states.js && node test/activation-policy.js && node test/last-input.js"
|
|
47
47
|
},
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"node-addon-api": "^8.3.0"
|
|
Binary file
|
|
Binary file
|
package/src/addon.mm
CHANGED
|
@@ -1868,6 +1868,10 @@ void InitVideo(Napi::Env env, Napi::Object exports);
|
|
|
1868
1868
|
// src/player.mm — a file or URL played by AVFoundation: an AVPlayer, its
|
|
1869
1869
|
// AVPlayerLayer as a layer handle, and the frame showing copied into a surface.
|
|
1870
1870
|
void InitPlayer(Napi::Env env, Napi::Object exports);
|
|
1871
|
+
// src/capture.mm — cameras, microphones, speakers and an audio out on one
|
|
1872
|
+
// voice-processing engine, and ScreenCaptureKit's screenshots.
|
|
1873
|
+
void InitCapture(Napi::Env env, Napi::Object exports);
|
|
1874
|
+
void InitSystemAudio(Napi::Env env, Napi::Object exports);
|
|
1871
1875
|
|
|
1872
1876
|
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
1873
1877
|
#define FN(js, fn) exports.Set(js, Napi::Function::New(env, fn))
|
|
@@ -1916,6 +1920,8 @@ static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
|
1916
1920
|
InitThreaded(env, exports);
|
|
1917
1921
|
InitVideo(env, exports);
|
|
1918
1922
|
InitPlayer(env, exports);
|
|
1923
|
+
InitCapture(env, exports);
|
|
1924
|
+
InitSystemAudio(env, exports);
|
|
1919
1925
|
return exports;
|
|
1920
1926
|
}
|
|
1921
1927
|
|
package/src/backend.mm
CHANGED
|
@@ -1197,6 +1197,21 @@ static Napi::Value SetWindowIgnoresMouseEvents(const Napi::CallbackInfo& info) {
|
|
|
1197
1197
|
return info.Env().Undefined();
|
|
1198
1198
|
}
|
|
1199
1199
|
|
|
1200
|
+
// setWindowSharing(win, 'none' | 'readOnly') — NSWindow.sharingType: 'none'
|
|
1201
|
+
// keeps the window out of every screenshot and screen recording, this app's
|
|
1202
|
+
// own included; 'readOnly' is the default.
|
|
1203
|
+
static Napi::Value SetWindowSharing(const Napi::CallbackInfo& info) {
|
|
1204
|
+
std::string mode = info.Length() > 1 && info[1].IsString() ? info[1].As<Napi::String>().Utf8Value() : "";
|
|
1205
|
+
if (mode != "none" && mode != "readOnly") {
|
|
1206
|
+
Napi::TypeError::New(info.Env(), "setWindowSharing(win, mode): mode is 'none' or 'readOnly'")
|
|
1207
|
+
.ThrowAsJavaScriptException();
|
|
1208
|
+
return info.Env().Undefined();
|
|
1209
|
+
}
|
|
1210
|
+
NSWindowSharingType type = mode == "none" ? NSWindowSharingNone : NSWindowSharingReadOnly;
|
|
1211
|
+
OnWindow(info[0], ^(NSWindow* win) { win.sharingType = type; });
|
|
1212
|
+
return info.Env().Undefined();
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1200
1215
|
// setWindowFrame(win, x, y, w, h) — any argument may be null to keep it.
|
|
1201
1216
|
// x/y are the content's top-left in global top-left coordinates, points.
|
|
1202
1217
|
static Napi::Value SetWindowFrame(const Napi::CallbackInfo& info) {
|
|
@@ -8143,6 +8158,7 @@ void InitBackend(Napi::Env env, Napi::Object exports) {
|
|
|
8143
8158
|
BFN("showWindow", ShowWindowFn);
|
|
8144
8159
|
BFN("hideWindow", HideWindowFn);
|
|
8145
8160
|
BFN("setWindowTitle", SetWindowTitle);
|
|
8161
|
+
BFN("setWindowSharing", SetWindowSharing);
|
|
8146
8162
|
BFN("setWindowIgnoresMouseEvents", SetWindowIgnoresMouseEvents);
|
|
8147
8163
|
BFN("windowNumberAtPoint", WindowNumberAtPoint);
|
|
8148
8164
|
BFN("setWindowFrame", SetWindowFrame);
|