craft-native 0.0.413 → 0.0.414

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/dist/cli.js CHANGED
@@ -3047,7 +3047,7 @@ function pinCraftNativeDependency(packagePath, craftVersion) {
3047
3047
  `);
3048
3048
  }
3049
3049
  // package.json
3050
- var version = "0.0.413";
3050
+ var version = "0.0.414";
3051
3051
 
3052
3052
  // bin/cli.ts
3053
3053
  var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
package/dist/index.cjs CHANGED
@@ -375,7 +375,7 @@ function craftBinaryNotFoundMessage(triedPath) {
375
375
  `);
376
376
  }
377
377
  // package.json
378
- var version = "0.0.413";
378
+ var version = "0.0.414";
379
379
 
380
380
  // src/sdk-version.ts
381
381
  var SDK_VERSION = version;
package/dist/index.js CHANGED
@@ -117,7 +117,7 @@ function craftBinaryNotFoundMessage(triedPath) {
117
117
  `);
118
118
  }
119
119
  // package.json
120
- var version = "0.0.413";
120
+ var version = "0.0.414";
121
121
 
122
122
  // src/sdk-version.ts
123
123
  var SDK_VERSION = version;
@@ -197,9 +197,13 @@ final class CraftMacApplication: NSObject, NSApplicationDelegate, UNUserNotifica
197
197
  if let scene = scenes[name] { scene.window.makeKeyAndOrderFront(nil); return }
198
198
  scenes[name] = CraftMacScene(name: name, route: route, options: options, application: self)
199
199
  }
200
+ /// A menu command goes to the window it was chosen in (the key window), else the main one: with
201
+ /// two windows of the same screen open, cmd-T opens one tab, not one in each.
200
202
  @objc func command(_ item: NSMenuItem) {
201
203
  guard let id = item.representedObject as? String else { return }
202
- broadcast(id)
204
+ let target = scenes.values.first { $0.window === NSApp.keyWindow } ?? scenes["main"]
205
+ guard let target else { broadcast(id); return }
206
+ target.runtime.send("CRAFT_EVENT", ["event": "craftDesktopCommand", "detail": ["id": id]])
203
207
  }
204
208
  func broadcast(_ id: String) { for scene in scenes.values { scene.runtime.send("CRAFT_EVENT", ["event": "craftDesktopCommand", "detail": ["id": id]]) } }
205
209
  func appearanceChanged() {
@@ -320,6 +324,11 @@ final class CraftMacApplication: NSObject, NSApplicationDelegate, UNUserNotifica
320
324
  let filter = CIFilter(name: "CIQRCodeGenerator")!; filter.setValue(Data(text.utf8), forKey: "inputMessage"); filter.setValue("M", forKey: "inputCorrectionLevel")
321
325
  guard let image = filter.outputImage?.transformed(by: CGAffineTransform(scaleX: 8, y: 8)), let cg = CIContext().createCGImage(image, from: image.extent), let data = NSBitmapImageRep(cgImage: cg).representation(using: .png, properties: [:]) else { reply(NSNull()); return }
322
326
  reply("data:image/png;base64," + data.base64EncodedString())
327
+ case "post":
328
+ // A message for the app's other windows (a tab handed from a small window to the main one).
329
+ let message = args.first ?? NSNull()
330
+ for other in scenes.values where other !== scene { other.runtime.send("CRAFT_EVENT", ["event": "craftDesktopMessage", "detail": ["from": scene?.name ?? "", "message": message]]) }
331
+ reply(true)
323
332
  case "takeOpenedURLs": reply(openedURLs); openedURLs.removeAll()
324
333
  case "isDefaultBrowser": reply(isDefaultBrowser)
325
334
  case "setDefaultBrowser":
@@ -401,7 +410,12 @@ final class CraftMacApplication: NSObject, NSApplicationDelegate, UNUserNotifica
401
410
  }
402
411
  private func testAction(_ action: [String: Any]) -> [String: Any] {
403
412
  let kind = action["action"] as? String ?? ""
404
- if kind == "command", let id = action["id"] as? String { broadcast(id); return ["ok": true] }
413
+ if kind == "command", let id = action["id"] as? String {
414
+ // Like a menu: to the named window, else the key one, else the main one.
415
+ let target = (action["window"] as? String).flatMap { scenes[$0] } ?? scenes.values.first { $0.window === NSApp.keyWindow } ?? scenes["main"]
416
+ target?.runtime.send("CRAFT_EVENT", ["event": "craftDesktopCommand", "detail": ["id": id]])
417
+ return ["ok": target != nil]
418
+ }
405
419
  // After this result is written, from the run loop rather than a main-queue block (see applicationShouldTerminate).
406
420
  if kind == "quit" { NSApp.perform(#selector(NSApplication.terminate(_:)), with: nil, afterDelay: 0); return ["ok": true] }
407
421
  if kind == "openURL", let url = (action["url"] as? String).flatMap(URL.init(string:)) { application(NSApp, open: [url]); return ["ok": true] }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "craft-native",
3
- "version": "0.0.413",
3
+ "version": "0.0.414",
4
4
  "type": "module",
5
5
  "description": "Build desktop apps with web languages - TypeScript SDK for Craft",
6
6
  "author": "Chris Breuer <chris@stacksjs.org>",