@windowkit/appkit 0.30.0 → 0.30.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@windowkit/appkit",
3
- "version": "0.30.0",
3
+ "version": "0.30.2",
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/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/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
@@ -1581,6 +1581,35 @@ static Napi::Value SetContentsImage(const Napi::CallbackInfo& info) {
1581
1581
  // native controls: NSCell rendered offscreen (the WebKit/Firefox technique)
1582
1582
  // ---------------------------------------------------------------------------
1583
1583
 
1584
+ // A view control drawn into the current NSGraphicsContext, filling (0, 0, w,
1585
+ // h) points over pw x ph pixels. Through a bitmap rep rather than
1586
+ // displayRectIgnoringOpacity:inContext:, which under the macOS 26 design (a
1587
+ // process linked against the 26 SDK — Bun is) draws NSSlider and NSSwitch
1588
+ // through their layers and leaves a foreign context empty.
1589
+ // cacheDisplayInRect: renders the layer tree, and on the older design gives
1590
+ // the pixels displayRect did.
1591
+ static void DrawViewControl(NSControl* v, double w, double h, size_t pw, size_t ph) {
1592
+ NSBitmapImageRep* rep = [[NSBitmapImageRep alloc]
1593
+ initWithBitmapDataPlanes:NULL
1594
+ pixelsWide:(NSInteger)pw
1595
+ pixelsHigh:(NSInteger)ph
1596
+ bitsPerSample:8
1597
+ samplesPerPixel:4
1598
+ hasAlpha:YES
1599
+ isPlanar:NO
1600
+ colorSpaceName:NSDeviceRGBColorSpace
1601
+ bytesPerRow:0
1602
+ bitsPerPixel:0];
1603
+ rep.size = NSMakeSize(w, h);
1604
+ [v cacheDisplayInRect:v.bounds toBitmapImageRep:rep];
1605
+ [rep drawInRect:NSMakeRect(0, 0, w, h)
1606
+ fromRect:NSZeroRect
1607
+ operation:NSCompositingOperationSourceOver
1608
+ fraction:1
1609
+ respectFlipped:YES
1610
+ hints:nil];
1611
+ }
1612
+
1584
1613
  static NSView* DummyDrawView() {
1585
1614
  // Cells only use the view for flippedness/appearance queries; it never needs
1586
1615
  // to be in a window.
@@ -1631,7 +1660,7 @@ static Napi::Value DrawControl(const Napi::CallbackInfo& info) {
1631
1660
 
1632
1661
  // Controls whose cells no longer draw offscreen (NSSliderCell renders via
1633
1662
  // the view's layer machinery) or that have no cell at all (NSSwitch): use a
1634
- // real offscreen NSControl and displayRectIgnoringOpacity:inContext:.
1663
+ // real offscreen NSControl, captured with DrawViewControl.
1635
1664
  NSControl* viewControl = nil;
1636
1665
  if ([kind isEqualToString:@"slider"]) {
1637
1666
  NSSlider* s = [[NSSlider alloc] init];
@@ -1697,7 +1726,7 @@ static Napi::Value DrawControl(const Napi::CallbackInfo& info) {
1697
1726
  viewControl.frame = NSMakeRect(0, 0, w, h);
1698
1727
  viewControl.appearance = ap;
1699
1728
  [viewControl layoutSubtreeIfNeeded];
1700
- [viewControl displayRectIgnoringOpacity:viewControl.bounds inContext:g];
1729
+ DrawViewControl(viewControl, w, h, pw, ph);
1701
1730
  } else {
1702
1731
  [ap performAsCurrentDrawingAppearance:^{
1703
1732
  [cell drawWithFrame:NSMakeRect(0, 0, w, h) inView:DummyDrawView()];
package/src/backend.mm CHANGED
@@ -3911,10 +3911,39 @@ static NSView* BezelDrawView() {
3911
3911
  return v;
3912
3912
  }
3913
3913
 
3914
+ // A view control drawn into the current NSGraphicsContext, filling (0, 0, w,
3915
+ // h) points over pw x ph pixels. Through a bitmap rep rather than
3916
+ // displayRectIgnoringOpacity:inContext:, which under the macOS 26 design (a
3917
+ // process linked against the 26 SDK — Bun is) draws NSSlider and NSSwitch
3918
+ // through their layers and leaves a foreign context empty.
3919
+ // cacheDisplayInRect: renders the layer tree, and on the older design gives
3920
+ // the pixels displayRect did.
3921
+ static void BDrawViewControl(NSControl* v, double w, double h, size_t pw, size_t ph) {
3922
+ NSBitmapImageRep* rep = [[NSBitmapImageRep alloc]
3923
+ initWithBitmapDataPlanes:NULL
3924
+ pixelsWide:(NSInteger)pw
3925
+ pixelsHigh:(NSInteger)ph
3926
+ bitsPerSample:8
3927
+ samplesPerPixel:4
3928
+ hasAlpha:YES
3929
+ isPlanar:NO
3930
+ colorSpaceName:NSDeviceRGBColorSpace
3931
+ bytesPerRow:0
3932
+ bitsPerPixel:0];
3933
+ rep.size = NSMakeSize(w, h);
3934
+ [v cacheDisplayInRect:v.bounds toBitmapImageRep:rep];
3935
+ [rep drawInRect:NSMakeRect(0, 0, w, h)
3936
+ fromRect:NSZeroRect
3937
+ operation:NSCompositingOperationSourceOver
3938
+ fraction:1
3939
+ respectFlipped:YES
3940
+ hints:nil];
3941
+ }
3942
+
3914
3943
  // The two render paths AppKit leaves us: classic cells draw offscreen via
3915
3944
  // drawWithFrame:, while NSSlider's cell now renders through the view's layer
3916
3945
  // machinery and NSSwitch has no cell at all — those go through a real
3917
- // offscreen NSControl and displayRectIgnoringOpacity:inContext:.
3946
+ // offscreen NSControl, captured with BDrawViewControl.
3918
3947
  struct BezelControl {
3919
3948
  NSCell* cell = nil;
3920
3949
  NSControl* view = nil;
@@ -4100,7 +4129,7 @@ static Napi::Value DrawControlIntoSurface(const Napi::CallbackInfo& info) {
4100
4129
  c.view.frame = NSMakeRect(0, 0, w, h);
4101
4130
  c.view.appearance = ap;
4102
4131
  [c.view layoutSubtreeIfNeeded];
4103
- [c.view displayRectIgnoringOpacity:c.view.bounds inContext:g];
4132
+ BDrawViewControl(c.view, w, h, pw, ph);
4104
4133
  } else if (c.cell) {
4105
4134
  NSCell* cell = c.cell;
4106
4135
  [ap performAsCurrentDrawingAppearance:^{
package/src/player.mm CHANGED
@@ -31,6 +31,7 @@
31
31
 
32
32
  #include <napi.h>
33
33
  #import <AVFoundation/AVFoundation.h>
34
+ #import <VideoToolbox/VideoToolbox.h>
34
35
  #import <CoreMedia/CoreMedia.h>
35
36
  #import <CoreVideo/CoreVideo.h>
36
37
  #import <QuartzCore/QuartzCore.h>
@@ -259,8 +260,21 @@ static void Apply(CALPlayer* p, const PlayerSettings& s) {
259
260
  }
260
261
  }
261
262
 
263
+ // VP9 is one of VideoToolbox's supplemental decoders, which a process has to
264
+ // ask for before AVFoundation can use one. Without this a `vp09` track in an
265
+ // MP4 opens and comes ready, and reports a picture of no size and hands out
266
+ // no frames, with no error anywhere. Asked once, and of nothing on a Mac that
267
+ // has no such decoder: its VP9 then fails as any format it cannot play does.
268
+ static void RegisterSupplementalDecoders() {
269
+ static dispatch_once_t once;
270
+ dispatch_once(&once, ^{
271
+ VTRegisterSupplementalVideoDecoderIfAvailable(kCMVideoCodecType_VP9);
272
+ });
273
+ }
274
+
262
275
  static Napi::Value CreatePlayer(const Napi::CallbackInfo& info) {
263
276
  Napi::Env env = info.Env();
277
+ RegisterSupplementalDecoders();
264
278
  if (!info[0].IsString() || info[0].As<Napi::String>().Utf8Value().empty()) {
265
279
  Napi::TypeError::New(env, "createPlayer(url, options): url is a path or a URL string")
266
280
  .ThrowAsJavaScriptException();