@windowkit/appkit 0.4.0 → 0.5.1

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/index.js CHANGED
@@ -74,13 +74,21 @@ class Layer {
74
74
  }
75
75
  }
76
76
 
77
- // Explicit CABasicAnimation on any animatable keyPath, e.g.
78
- // 'transform.rotation.z', 'position', 'opacity', 'strokeEnd', 'backgroundColor'.
77
+ // Explicit animation on any animatable keyPath, e.g. 'transform.rotation.z',
78
+ // 'position', 'opacity', 'strokeEnd', 'backgroundColor': a CABasicAnimation
79
+ // ({ from, to }), a CAKeyframeAnimation ({ values }) or a CASpringAnimation
80
+ // ({ spring }) — README "Animations" lists the options. Returns the layer;
81
+ // native.addAnimation returns the duration the animation will take (a
82
+ // spring's settling time).
79
83
  animate(keyPath, opts = {}, key = keyPath) {
80
84
  native.addAnimation(this._h, keyPath, opts, key);
81
85
  return this;
82
86
  }
83
87
 
88
+ // The value the render server is showing for a key path right now,
89
+ // animations applied — null before the layer's first commit.
90
+ presentationValue(keyPath) { return native.presentationValue(this._h, keyPath); }
91
+
84
92
  removeAnimation(key) { native.removeAnimation(this._h, key); }
85
93
  removeAllAnimations() { native.removeAllAnimations(this._h); }
86
94
 
@@ -130,7 +138,8 @@ class Window {
130
138
  snapshot(file) { return native.snapshotWindow(this._h, file); } // renderInContext -> PNG
131
139
  }
132
140
 
133
- // Group property changes into one CATransaction (shared animation duration/timing).
141
+ // Group property changes into one CATransaction (shared animation duration and
142
+ // timing — a curve name or cubic-bezier control points [x1, y1, x2, y2]).
134
143
  function transaction(fn, opts = {}) {
135
144
  native.txBegin(opts);
136
145
  try { fn(); } finally { native.txCommit(); }
@@ -178,7 +187,73 @@ const controls = {
178
187
  isDark: () => native.appearanceIsDark(),
179
188
  };
180
189
 
190
+ // Privacy (TCC) authorizations. kind: 'camera' | 'microphone' |
191
+ // 'screen-recording' | 'accessibility' | 'input-monitoring' | 'location' |
192
+ // 'automation' (with { target: bundleId }). Status and request never touch
193
+ // policy: the renderer decides when to ask and what to do with a refusal.
194
+ const permissions = {
195
+ // -> 'authorized' | 'denied' | 'restricted' | 'notDetermined'; never prompts
196
+ status: (kind, opts) => native.authorizationStatus(kind, opts),
197
+ // Raises the system prompt where macOS has one; resolves to granted. Screen
198
+ // recording and accessibility can only be granted in Settings, so their
199
+ // prompt is the system's go-to-Settings dialog and this resolves at once.
200
+ request: (kind, opts) =>
201
+ new Promise((resolve) => native.requestAuthorization(kind, opts, resolve)),
202
+ // Best-effort deep link to the Privacy pane (or its top level with no kind);
203
+ // also takes 'files-and-folders' and 'full-disk-access'.
204
+ openSettings: (kind) => native.openPrivacySettings(kind),
205
+ };
206
+
207
+ // Desktop notifications through UNUserNotificationCenter — the macOS
208
+ // counterpart of org.freedesktop.Notifications. Mechanism only: what to say,
209
+ // when to ask and what to do with a refusal stay in the renderer. Banners
210
+ // are attributed to an app bundle, so a bare `node` process can post none:
211
+ // read settings().available first (it carries the reason when false) and
212
+ // fall to another rung; every other call throws in that state rather than
213
+ // dropping silently. Responses arrive as backend events, through
214
+ // native.setBackendEventCallback: 'notification-action' { identifier,
215
+ // actionId ('default' for a click on the banner itself), categoryId,
216
+ // userInfo } and 'notification-dismissed' { identifier, reason, ... }.
217
+ const notifications = {
218
+ // -> { available: false, bundleIdentifier, reason } | { available: true,
219
+ // bundleIdentifier, authorizationStatus: 'notDetermined' | 'denied' |
220
+ // 'authorized' | 'provisional', alert, sound, badge, ... }
221
+ settings: () => new Promise((resolve) => native.notificationSettings(resolve)),
222
+ // The system prompt, once per app; resolves to granted (boolean).
223
+ requestAuthorization: (options = ['alert', 'sound', 'badge']) =>
224
+ new Promise((resolve, reject) =>
225
+ native.requestNotificationAuthorization(options, (granted, err) =>
226
+ err ? reject(err) : resolve(granted))),
227
+ // [{ id, actions: [{ id, title, destructive?, foreground? }] }] — the action
228
+ // sets a notification's categoryId can name; replaces the whole set.
229
+ setCategories: (categories) => native.setNotificationCategories(categories),
230
+ // { identifier?, title, subtitle?, body?, sound?: 'default' | null,
231
+ // categoryId?, userInfo?, threadId?, badge? } -> identifier, once the
232
+ // system has accepted it (rejects while the app is not authorized).
233
+ post: (props) =>
234
+ new Promise((resolve, reject) => {
235
+ const id = native.postNotification(props, (err) => (err ? reject(err) : resolve(id)));
236
+ }),
237
+ // The same identifier again replaces the banner in place.
238
+ update: (identifier, props) =>
239
+ new Promise((resolve, reject) => {
240
+ native.updateNotification(identifier, props, (err) => (err ? reject(err) : resolve(identifier)));
241
+ }),
242
+ remove: (identifiers) => native.removeNotification(identifiers),
243
+ // readback: what is in Notification Center for this app, and the categories
244
+ delivered: () => new Promise((resolve) => native.deliveredNotifications(resolve)),
245
+ categories: () => new Promise((resolve) => native.notificationCategories(resolve)),
246
+ };
247
+
248
+ const accessibility = {
249
+ // System Settings › Accessibility › Display, as NSWorkspace reports it:
250
+ // { reduceMotion, reduceTransparency, increaseContrast, differentiateWithoutColor, invertColors }.
251
+ // A change arrives as an 'accessibility-display-changed' backend event with the same fields;
252
+ // install the callback first, then read this (README "Accessibility display options").
253
+ displayOptions: () => native.accessibilityDisplayOptions(),
254
+ };
255
+
181
256
  module.exports = {
182
257
  app, Window, Layer, TextLayer, GradientLayer, ShapeLayer,
183
- transaction, withoutAnimations, text, controls, native,
258
+ transaction, withoutAnimations, text, controls, permissions, notifications, accessibility, native,
184
259
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windowkit/appkit",
3
- "version": "0.4.0",
3
+ "version": "0.5.1",
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",
@@ -42,7 +42,8 @@
42
42
  "scripts": {
43
43
  "install": "node scripts/install.js",
44
44
  "build": "node-gyp rebuild",
45
- "demo": "node demo/demo.js"
45
+ "demo": "node demo/demo.js",
46
+ "test": "node test/app-lifecycle.js && node test/animation.js && node test/accessibility-display.js"
46
47
  },
47
48
  "dependencies": {
48
49
  "node-addon-api": "^8.3.0"
Binary file