@windowkit/appkit 0.31.0 → 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 +65 -5
- package/binding.gyp +2 -1
- 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 +2 -0
- package/src/capture.mm +265 -53
- package/src/permissions.mm +64 -3
- package/src/systemaudio.mm +876 -0
package/README.md
CHANGED
|
@@ -736,9 +736,12 @@ needs the grant `authorizationStatus` reads, and a renderer asks for it first
|
|
|
736
736
|
device's format nearest the size asked (a 4:2:0 YCbCr one where it has one —
|
|
737
737
|
every Mac camera seen so far has only those — so nothing is converted on the
|
|
738
738
|
way) at the rate asked, clamped to it; nothing asked is the largest within
|
|
739
|
-
1280x720. The
|
|
740
|
-
|
|
741
|
-
|
|
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
|
|
742
745
|
`AVCaptureVideoPreviewLayer`, a handle every layer verb takes, filling its
|
|
743
746
|
bounds and never mirrored; the renderer fits and flips.
|
|
744
747
|
- **`native.cameraFrames(id, on)`** — while on, `camera-frame { id, width,
|
|
@@ -771,6 +774,13 @@ every output plays through it.
|
|
|
771
774
|
`Float32Array` a channel. Nothing is dropped short of two seconds of chunks
|
|
772
775
|
waiting; past that, `dropped` counts them. One input device at a time.
|
|
773
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 }`.
|
|
774
784
|
- **`native.openAudioOutput({ sampleRate, channels, deviceId })`** → `{ id,
|
|
775
785
|
sampleRate, channels }`; **`native.audioOutputWrite(id, [Float32Array, …])`**
|
|
776
786
|
→ frames now queued (ten seconds at most); **`native.audioOutputState(id)`**
|
|
@@ -779,6 +789,11 @@ every output plays through it.
|
|
|
779
789
|
**`native.closeAudioOutput(id)`**. One output device for the engine: the
|
|
780
790
|
first output's `deviceId` picks it.
|
|
781
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
|
+
|
|
782
797
|
**The screen.**
|
|
783
798
|
|
|
784
799
|
- **`native.captureScreenshot({ display, window, rect, cursor }, cb)`** — one
|
|
@@ -795,13 +810,56 @@ every output plays through it.
|
|
|
795
810
|
`'none'` keeps the window out of every screenshot and recording, this app's
|
|
796
811
|
own included. On macOS 15 such a window comes back with every pixel clear.
|
|
797
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
|
+
|
|
798
852
|
`test/capture.js` lists the devices both ways, opens a camera and a microphone
|
|
799
853
|
that are not there (refused by name, nothing prompted), plays 0.2 s through an
|
|
800
854
|
output on the device's clock, and — where Screen Recording is allowed — reads a
|
|
801
855
|
red window back as red and an excluded one as clear. A camera and a microphone
|
|
802
856
|
that this process may use are opened and read from; where it may not they are
|
|
803
857
|
skipped, never prompted. `test/capture-threaded.js` does the same from a
|
|
804
|
-
worker.
|
|
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.
|
|
805
863
|
|
|
806
864
|
## Text: at a display's scale
|
|
807
865
|
|
|
@@ -1262,6 +1320,7 @@ native.openPrivacySettings(kind?); // no kind: th
|
|
|
1262
1320
|
| ------------------------ | ---------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
1263
1321
|
| `camera`, `microphone` | `AVCaptureDevice authorizationStatusForMediaType:` | `requestAccessForMediaType:` | all four statuses; the prompt is in-process and the answer arrives when the user clicks |
|
|
1264
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`) |
|
|
1265
1324
|
| `accessibility` | `AXIsProcessTrusted` | `AXIsProcessTrustedWithOptions` + prompt | a bool, so never `notDetermined`; go-to-Settings dialog, resolves at once, the grant applies live |
|
|
1266
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 |
|
|
1267
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 |
|
|
@@ -1274,7 +1333,8 @@ native.openPrivacySettings(kind?); // no kind: th
|
|
|
1274
1333
|
process* (Terminal, an IDE) or to `node` itself, and prompts with no
|
|
1275
1334
|
usage-description strings. A bundled app must carry the keys
|
|
1276
1335
|
(`NSCameraUsageDescription`, `NSMicrophoneUsageDescription`,
|
|
1277
|
-
`
|
|
1336
|
+
`NSAudioCaptureUsageDescription`, `NSLocationUsageDescription`,
|
|
1337
|
+
`NSAppleEventsUsageDescription`; for
|
|
1278
1338
|
EventKit on macOS 14+ `NSCalendarsFullAccessUsageDescription`,
|
|
1279
1339
|
`NSCalendarsWriteOnlyAccessUsageDescription` and
|
|
1280
1340
|
`NSRemindersFullAccessUsageDescription`, and before 14
|
package/binding.gyp
CHANGED
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/capture.js && node test/capture-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"
|
|
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
|
@@ -1871,6 +1871,7 @@ void InitPlayer(Napi::Env env, Napi::Object exports);
|
|
|
1871
1871
|
// src/capture.mm — cameras, microphones, speakers and an audio out on one
|
|
1872
1872
|
// voice-processing engine, and ScreenCaptureKit's screenshots.
|
|
1873
1873
|
void InitCapture(Napi::Env env, Napi::Object exports);
|
|
1874
|
+
void InitSystemAudio(Napi::Env env, Napi::Object exports);
|
|
1874
1875
|
|
|
1875
1876
|
static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
1876
1877
|
#define FN(js, fn) exports.Set(js, Napi::Function::New(env, fn))
|
|
@@ -1920,6 +1921,7 @@ static Napi::Object Init(Napi::Env env, Napi::Object exports) {
|
|
|
1920
1921
|
InitVideo(env, exports);
|
|
1921
1922
|
InitPlayer(env, exports);
|
|
1922
1923
|
InitCapture(env, exports);
|
|
1924
|
+
InitSystemAudio(env, exports);
|
|
1923
1925
|
return exports;
|
|
1924
1926
|
}
|
|
1925
1927
|
|