ReviewOS

also looking at this

craft-native/craft

fix(bridge): stop discarding the fields the page actually sends

#82
Merged glennmichael123 wants to merge fix/bridge-field-names into main
7 files +375 -34
packages/zig/src/bridge_app.zigmodified+20-5
Changes to packages/zig/src/bridge_app.zig
@@ -64,7 +64,7 @@ pub const AppBridge = struct {
6464 } else if (std.mem.eql(u8, action, A.set_badge)) {
6565 try self.setBadge(data);
6666 } else if (std.mem.eql(u8, action, A.bounce)) {
67 try self.bounce();
67 try self.bounce(data);
6868 } else {
6969 if (comptime builtin.mode == .debug)
7070 std.debug.print("[AppBridge] Unknown action: {s}\n", .{action});
@@ -244,17 +244,32 @@ pub const AppBridge = struct {
244244 }
245245 }
246246
247 fn bounce(self: *Self) !void {
247 /// `craft.app.bounce(type)` — 'critical' or 'informational'.
248 ///
249 /// This took no payload at all and always requested an informational
250 /// bounce, so `bounce('critical')` hopped the Dock icon once instead of
251 /// bouncing until the user activates the app — which is the entire
252 /// difference between the two, and the only reason to pass an argument.
253 fn bounce(self: *Self, data: ?[]const u8) !void {
248254 _ = self;
249255 if (builtin.os.tag == .macos) {
250256 const macos = ;
251257 const NSApplication = macos.getClass("NSApplication");
252258 const app = macos.msgSend0(NSApplication, "sharedApplication");
253259
254 // NSApplicationActivateIgnoringOtherApps + request user attention
255 // NSInformationalRequest = 10
260 // `NSRequestUserAttentionType`: critical bounces until the app is
261 // activated, informational bounces once.
262 const NSCriticalRequest: c_long = 0;
256263 const NSInformationalRequest: c_long = 10;
257 _ = macos.msgSend1(app, "requestUserAttention:", NSInformationalRequest);
264
265 const request = if (data) |json_data| blk: {
266 break :blk if (std.mem.indexOf(u8, json_data, "critical") != null)
267 NSCriticalRequest
268 else
269 NSInformationalRequest;
270 } else NSInformationalRequest;
271
272 _ = macos.msgSend1(app, "requestUserAttention:", request);
258273 }
259274 }
260275