craft-native 0.0.413 → 0.0.415
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.
|
|
3050
|
+
var version = "0.0.415";
|
|
3051
3051
|
|
|
3052
3052
|
// bin/cli.ts
|
|
3053
3053
|
var spawnedFrom = process6.env[CRAFT_CLI_SPAWN_MARKER];
|
package/dist/index.cjs
CHANGED
package/dist/index.js
CHANGED
|
@@ -639,12 +639,26 @@ final class DriverTests: XCTestCase {
|
|
|
639
639
|
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
|
|
640
640
|
let candidates = [app.buttons[label], springboard.buttons[label]]
|
|
641
641
|
let end = Date().addingTimeInterval(6)
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
642
|
+
// A tap is not a dismissal. iOS 26 draws "Save Password?" as a
|
|
643
|
+
// sheet that is in the tree, and hittable, while it still slides
|
|
644
|
+
// in, and a tap then is dropped: the driver said "tapped" and
|
|
645
|
+
// the sheet stayed over the app, so every later step looked at a
|
|
646
|
+
// screen it could not reach. Done means the button has gone; until
|
|
647
|
+
// then it is tapped again.
|
|
648
|
+
var tapped = false
|
|
649
|
+
var gone = false
|
|
650
|
+
while !gone && Date() < end {
|
|
651
|
+
guard let button = candidates.first(where: { $0.exists && $0.isHittable }) else {
|
|
652
|
+
if tapped { gone = true } else { Thread.sleep(forTimeInterval: 0.5) }
|
|
653
|
+
continue
|
|
654
|
+
}
|
|
655
|
+
button.tap()
|
|
656
|
+
tapped = true
|
|
657
|
+
let settle = Date().addingTimeInterval(1.5)
|
|
658
|
+
while button.exists && Date() < settle { Thread.sleep(forTimeInterval: 0.25) }
|
|
659
|
+
gone = !button.exists
|
|
646
660
|
}
|
|
647
|
-
note("dismiss \(label): \(
|
|
661
|
+
note("dismiss \(label): \(gone ? "tapped" : tapped ? "STILL SHOWN" : "none shown")")
|
|
648
662
|
case "log": note(arg)
|
|
649
663
|
default: XCTFail("Unknown command \(command)"); note("FAIL unknown command \(command)")
|
|
650
664
|
}
|
|
@@ -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
|
-
|
|
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 {
|
|
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] }
|