@windowkit/appkit 0.31.0 → 0.33.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 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 session starts on a queue of its own, and `camera-started { id }`
740
- or `camera-error { id, name, message }` follows — `name` is Media Capture's:
741
- `NotFoundError`, `NotAllowedError`, `NotReadableError`. `layer` is an
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
@@ -794,6 +809,83 @@ every output plays through it.
794
809
  - **`native.setWindowSharing(win, 'none' | 'readOnly')`** — `NSWindow.sharingType`:
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.
812
+ - **`native.screenCaptureWindows(cb)`** — the windows a person would share:
813
+ `cb([{ id, title, app: { name, bundleId, pid }, x, y, width, height, active
814
+ }])`, on screen at the normal level and at least 40 points a side,
815
+ frontmost first, points from the top left of the main display; `id` is the
816
+ window number `captureScreenshot` and `openDisplayStream` take. Or
817
+ `cb({ error, name })`, `NotAllowedError` without Screen Recording.
818
+
819
+ **A display or a window as a stream** — ScreenCaptureKit's `SCStream`, macOS
820
+ 14, what a camera is with the screen behind it: shown on a layer of its own,
821
+ its frames handed to JS only on request.
822
+
823
+ - **`native.openDisplayStream({ display?, window?, width?, height?, frameRate?,
824
+ cursor? })`** → `{ id, layer }`, answered at once: a display (the main one
825
+ without either) or one window. The stream starts on a queue of its own, and
826
+ `display-started { id, width, height, frameRate }` or `display-error { id,
827
+ name, message }` says how — `NotAllowedError` without Screen Recording,
828
+ `NotFoundError` for a display or window that is not there,
829
+ `NotSupportedError` before macOS 14. Frames are the source's pixels, fitted
830
+ into `width` x `height` with the aspect kept (a width or a height alone
831
+ sets the other), even numbers both; at `frameRate` at most (30 if not said)
832
+ and only when something changed. `layer` shows the newest, filling its
833
+ bounds; `cursor` defaults to true.
834
+ - **`native.displayStreamFrames(id, on)`** — while on, `display-frame { id,
835
+ width, height, format: 'BGRA', planes, strides, time }`, copies in sRGB, the
836
+ newest only.
837
+ - **`native.displayStreamCopyFrame(id, surface)`** → `{ width, height, time,
838
+ written } | null`: `cameraCopyFrame`'s contract.
839
+ - **`native.displayStreamConfigure(id, { width?, height?, frameRate? })`** —
840
+ another size or rate without stopping, answered by `display-configured {
841
+ id, width, height, frameRate }`, or `display-configured { id, error, name }`
842
+ with the stream running as it was.
843
+ - Events **`display-muted { id, muted }`** — the window minimized, hidden or on
844
+ another space, no frames until it is back — and **`display-ended { id,
845
+ name?, message? }`** — the window closed (said within a second; ScreenCaptureKit
846
+ suspends a closed window's stream as it does a minimized one's and says
847
+ nothing more, so the window is looked for), the display went, or the user
848
+ stopped the sharing from the menu bar (`NotAllowedError`).
849
+ **`native.closeDisplayStream(id)`**.
850
+
851
+ **Other applications' sound** — CoreAudio's process taps, macOS 14.2 (these
852
+ three verbs are not exported before it, which is how a renderer tells). A tap
853
+ is private to this process, sits in an aggregate device of its own with
854
+ nothing else in it — no output device beside it, whose input streams would be
855
+ opened too: a headset's microphone, a Bluetooth headset switched into its call
856
+ profile by that — and leaves what it taps audible.
857
+
858
+ - **`native.audioProcesses()`** → `[{ pid, bundleId, name, playing, app? }]`,
859
+ or **`native.audioProcesses(cb)`** from a queue of its own: every process
860
+ connected to the audio server, not only the ones playing. `playing` is
861
+ whether it has output running now. `app` is the outermost application bundle
862
+ its executable sits in, `{ bundleId, name, regular }` (`regular`: it has a
863
+ Dock icon) — a browser's renderers and an Electron app's helpers play under
864
+ helper bundle ids of their own, `com.google.Chrome.helper`, and `app` is
865
+ what a person would call them. A tool in no bundle (`afplay`) has an empty
866
+ `bundleId` and no `app`.
867
+ - Event **`audio-processes`** whenever a process connects or goes, or starts or
868
+ stops playing — from the first listing on.
869
+ - **`native.openSystemAudio({ pid?, bundleId?, exclude?, sampleRate, channels
870
+ })`** → `{ id, sampleRate, channels }`. With neither `pid` nor `bundleId`, every
871
+ process but this one and the pids in `exclude`; with `pid`, that process;
872
+ with `bundleId`, every process whose own bundle id or `app` is that one. A
873
+ bundle id's tap follows the application — a helper that starts later joins
874
+ it, an application that is not running is silence until it is — and the tap
875
+ of everything leaves this process out once it has connected.
876
+ `system-audio-started { id, sampleRate, channels, latency }` or
877
+ `system-audio-error { id, name, message }` answers it: `NotFoundError` for a
878
+ pid with no audio (said before anything is asked of the user),
879
+ `NotAllowedError`, `NotReadableError` for CoreAudio saying no. Then
880
+ `audio-input` every 10 ms, a microphone's event exactly — resampled and
881
+ mixed to what was asked, silence included while nothing plays, nothing
882
+ dropped short of two seconds waiting — and `system-audio-ended { id }` when
883
+ the one process tapped has gone. **`native.closeSystemAudio(id)`**.
884
+
885
+ The grant is System Audio Recording (`authorizationStatus('system-audio-recording')`,
886
+ below), and a tap without it is no error: it delivers silence. So an open reads
887
+ the status first, refuses a denial by name and asks where nobody has been
888
+ asked, before the tap is made.
797
889
 
798
890
  `test/capture.js` lists the devices both ways, opens a camera and a microphone
799
891
  that are not there (refused by name, nothing prompted), plays 0.2 s through an
@@ -801,7 +893,11 @@ output on the device's clock, and — where Screen Recording is allowed — read
801
893
  red window back as red and an excluded one as clear. A camera and a microphone
802
894
  that this process may use are opened and read from; where it may not they are
803
895
  skipped, never prompted. `test/capture-threaded.js` does the same from a
804
- worker.
896
+ worker. `test/system-audio.js` lists the processes both ways, plays a file of
897
+ silence through `afplay` and sees it announced coming and going, refuses a
898
+ process with no audio, and — only where System Audio Recording is allowed —
899
+ taps everything and one process; `test/system-audio-threaded.js` lists and
900
+ refuses from a worker.
805
901
 
806
902
  ## Text: at a display's scale
807
903
 
@@ -1262,6 +1358,7 @@ native.openPrivacySettings(kind?); // no kind: th
1262
1358
  | ------------------------ | ---------------------------------------------- | ------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
1263
1359
  | `camera`, `microphone` | `AVCaptureDevice authorizationStatusForMediaType:` | `requestAccessForMediaType:` | all four statuses; the prompt is in-process and the answer arrives when the user clicks |
1264
1360
  | `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 |
1361
+ | `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
1362
  | `accessibility` | `AXIsProcessTrusted` | `AXIsProcessTrustedWithOptions` + prompt | a bool, so never `notDetermined`; go-to-Settings dialog, resolves at once, the grant applies live |
1266
1363
  | `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
1364
  | `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 +1371,8 @@ native.openPrivacySettings(kind?); // no kind: th
1274
1371
  process* (Terminal, an IDE) or to `node` itself, and prompts with no
1275
1372
  usage-description strings. A bundled app must carry the keys
1276
1373
  (`NSCameraUsageDescription`, `NSMicrophoneUsageDescription`,
1277
- `NSLocationUsageDescription`, `NSAppleEventsUsageDescription`; for
1374
+ `NSAudioCaptureUsageDescription`, `NSLocationUsageDescription`,
1375
+ `NSAppleEventsUsageDescription`; for
1278
1376
  EventKit on macOS 14+ `NSCalendarsFullAccessUsageDescription`,
1279
1377
  `NSCalendarsWriteOnlyAccessUsageDescription` and
1280
1378
  `NSRemindersFullAccessUsageDescription`, and before 14
package/binding.gyp CHANGED
@@ -12,7 +12,9 @@
12
12
  "src/threaded.mm",
13
13
  "src/video.mm",
14
14
  "src/player.mm",
15
- "src/capture.mm"
15
+ "src/capture.mm",
16
+ "src/systemaudio.mm",
17
+ "src/displaystream.mm"
16
18
  ],
17
19
  "include_dirs": [
18
20
  "<!@(node -p \"require('node-addon-api').include\")"
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' | 'accessibility' | 'input-monitoring' | 'location' |
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. Never prompts.
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.31.0",
3
+ "version": "0.33.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/display-stream.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
package/src/addon.mm CHANGED
@@ -1871,6 +1871,9 @@ 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);
1875
+ // src/displaystream.mm — a display or a window as ScreenCaptureKit's stream.
1876
+ void InitDisplayStream(Napi::Env env, Napi::Object exports);
1874
1877
 
1875
1878
  static Napi::Object Init(Napi::Env env, Napi::Object exports) {
1876
1879
  #define FN(js, fn) exports.Set(js, Napi::Function::New(env, fn))
@@ -1920,6 +1923,8 @@ static Napi::Object Init(Napi::Env env, Napi::Object exports) {
1920
1923
  InitVideo(env, exports);
1921
1924
  InitPlayer(env, exports);
1922
1925
  InitCapture(env, exports);
1926
+ InitSystemAudio(env, exports);
1927
+ InitDisplayStream(env, exports);
1923
1928
  return exports;
1924
1929
  }
1925
1930