rvlib-shipkit 2.22.1 → 2.24.0
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/CHANGELOG.md +44 -0
- package/package.json +1 -1
- package/src/agent-time/render.ts +28 -14
- package/src/agent-time/report.ts +46 -25
- package/src/agent-time/store.ts +30 -10
- package/src/agent-time/timeline.ts +43 -15
- package/src/annex/annex.ts +3 -0
- package/src/annex/born.ts +464 -0
- package/src/annex/flush.ts +46 -0
- package/src/annex/offload.ts +171 -38
- package/src/annex/snapshots.ts +53 -0
- package/src/annex/tidy.ts +368 -0
- package/src/asks/asks-queue.ts +32 -11
- package/src/checks/SK041-annex-links.check.ts +4 -2
- package/src/checks/SK043-scratch-on-the-mac.check.ts +45 -0
- package/src/checks/SK044-behind-upstream.check.ts +38 -0
- package/src/cli/cmd_Annex.ts +60 -9
- package/src/cli/cmd_Asks.ts +2 -0
- package/src/cli/cmd_Backup.ts +7 -5
- package/src/cli/cmd_Bump.ts +1 -0
- package/src/cli/cmd_Capacity.ts +26 -0
- package/src/cli/cmd_Check.ts +1 -0
- package/src/cli/cmd_Checks.ts +1 -0
- package/src/cli/cmd_Ci.ts +1 -0
- package/src/cli/cmd_Commands.ts +50 -14
- package/src/cli/cmd_Home.ts +0 -1
- package/src/cli/cmd_Hooks.ts +1 -0
- package/src/cli/cmd_Mv.ts +1 -0
- package/src/cli/cmd_Rec.ts +17 -7
- package/src/cli/cmd_Reflect.ts +1 -0
- package/src/cli/cmd_Releases.ts +1 -0
- package/src/cli/cmd_Review.ts +124 -17
- package/src/cli/cmd_Secret.ts +41 -2
- package/src/cli/cmd_Shot.ts +1 -0
- package/src/cli/cmd_Status.ts +1 -0
- package/src/cli/cmd_Time.ts +3 -1
- package/src/cli/cmd_Tmp.ts +82 -0
- package/src/cli/cmd_Wiki.ts +1 -0
- package/src/cli/registry.ts +13 -1
- package/src/collections/pings.ts +1 -1
- package/src/core/capacity.ts +71 -0
- package/src/core/check-runner.ts +86 -15
- package/src/core/machine-db.ts +8 -0
- package/src/core/motherhome.ts +67 -9
- package/src/core/slots.ts +49 -12
- package/src/core/trace-audit.ts +4 -1
- package/src/drill/run.ts +5 -2
- package/src/home/daemon-jobs.ts +10 -3
- package/src/home/global-units.ts +3 -0
- package/src/home/gui-app/ShipkitGui.swift +1 -0
- package/src/home/home-launchd.ts +11 -3
- package/src/home/home-routes.ts +11 -4
- package/src/home/machine-host.ts +65 -0
- package/src/home/machine-stores.ts +30 -4
- package/src/home/machine-temp.ts +493 -0
- package/src/home/other-macs.ts +74 -0
- package/src/home/pm.ts +4 -1
- package/src/home/run-daemon.ts +10 -2
- package/src/home/run-pm.ts +1 -0
- package/src/home/serve-web.ts +2 -2
- package/src/home/via-hub.ts +6 -1
- package/src/identities/identities.ts +92 -24
- package/src/init-repo.ts +7 -3
- package/src/ledger/ledger.ts +6 -0
- package/src/ledger/store.ts +6 -0
- package/src/media-store/backup/keys.ts +21 -6
- package/src/media-store/backup/manifest.ts +52 -11
- package/src/media-store/backup/restore.ts +17 -10
- package/src/media-store/backup/run.ts +5 -2
- package/src/media-store/backup/sources.ts +2 -1
- package/src/media-store/daemon.ts +2 -2
- package/src/media-store/purge.ts +4 -0
- package/src/mv/mv-md.ts +121 -42
- package/src/recordings/load.ts +3 -3
- package/src/recordings/model.ts +7 -0
- package/src/recordings/open.ts +12 -0
- package/src/recordings/presets.ts +12 -5
- package/src/recordings/recorder-app/Capture.swift +34 -5
- package/src/recordings/recorder-app/Clip.swift +126 -17
- package/src/recordings/recorder-app/Editor.swift +177 -7
- package/src/recordings/recorder-app/Hud.swift +189 -0
- package/src/recordings/recorder-app/Tray.swift +179 -36
- package/src/recordings/recorder-app/icon.svg +16 -0
- package/src/recordings/recorder-app/main.swift +349 -18
- package/src/recordings/recorder-app.ts +8 -4
- package/src/recordings/recorder.shipkit.ts +2 -1
- package/src/recordings/routes.ts +52 -6
- package/src/recordings/run-recorder.ts +2 -1
- package/src/recordings/share.ts +27 -0
- package/src/recordings/take.ts +36 -4
- package/src/recordings/view.ts +11 -0
- package/src/reflect/transcript.ts +56 -11
- package/src/releases/from-card.ts +45 -3
- package/src/releases/model.ts +6 -0
- package/src/releases/store.ts +8 -1
- package/src/repo-config.ts +14 -4
- package/src/review/cells.ts +24 -3
- package/src/review/format.ts +33 -9
- package/src/review/media-kind.ts +14 -11
- package/src/review/media-read.ts +6 -5
- package/src/review/model.ts +104 -7
- package/src/review/paste.ts +2 -1
- package/src/review/previews.ts +123 -36
- package/src/review/routes.ts +29 -18
- package/src/review/store.ts +74 -12
- package/src/review/threads.ts +7 -5
- package/src/secrets/copy.ts +110 -0
- package/src/secrets/list.ts +17 -7
- package/src/serve/hub-app/home-strip.css +5 -0
- package/src/serve/hub-app/home-strip.tsx +18 -0
- package/src/serve/hub-app/hub-app.tsx +2 -1
- package/src/serve/hub-app/hub.css +18 -0
- package/src/serve/hub-app/inbox.css +1 -0
- package/src/serve/hub-app/pull-refresh.tsx +88 -0
- package/src/serve/hub-app/recordings-st.ts +135 -24
- package/src/serve/hub-app/recordings-view.tsx +293 -54
- package/src/serve/hub-app/recordings.css +77 -24
- package/src/serve/hub-app/review/review-cells.tsx +52 -13
- package/src/serve/hub-app/review/review-list.tsx +6 -1
- package/src/serve/hub-app/review/review-st.ts +6 -5
- package/src/serve/hub-app/review/review-thread.tsx +3 -1
- package/src/serve/hub-app/review/review-views.tsx +18 -11
- package/src/serve/hub-app/review/thread-st.ts +82 -14
- package/src/serve/hub-app/review.css +15 -2
- package/src/serve/hub-runtime.ts +2 -1
- package/src/serve/run-serve.ts +4 -2
- package/src/serve/serve-hub.ts +9 -2
- package/src/shipkit-files.ts +5 -0
- package/src/social/drafts.ts +4 -3
- package/src/social/load.ts +7 -2
- package/src/social/publish/discord.ts +10 -3
- package/src/suite/child-tools.ts +45 -0
- package/src/suite/judge-suites.ts +10 -22
- package/src/suite/select.ts +83 -8
- package/src/suite/suite-cli.ts +38 -14
- package/src/suite/suite-cores.ts +68 -0
- package/src/suite/suite-reads-preload.ts +8 -6
- package/src/ts/config.ts +44 -0
- package/src/ts/rename.ts +11 -1
|
@@ -49,6 +49,8 @@ struct Preset: Decodable {
|
|
|
49
49
|
|
|
50
50
|
struct State: Decodable {
|
|
51
51
|
var presets: [Preset]
|
|
52
|
+
/** the hotkeys that show or hide the recent captures tray */
|
|
53
|
+
var trayKeys: [String]?
|
|
52
54
|
var problems: [String]
|
|
53
55
|
var repos: [String]
|
|
54
56
|
var repo: String
|
|
@@ -56,7 +58,7 @@ struct State: Decodable {
|
|
|
56
58
|
}
|
|
57
59
|
|
|
58
60
|
struct Imported: Decodable {
|
|
59
|
-
struct Rec: Decodable { var id: String; var name: String; var repo: String }
|
|
61
|
+
struct Rec: Decodable { var id: String; var name: String; var repo: String; var webp: String? }
|
|
60
62
|
var ok: Bool
|
|
61
63
|
var recording: Rec?
|
|
62
64
|
var said: [String]?
|
|
@@ -125,6 +127,7 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
125
127
|
var repo: String = ""
|
|
126
128
|
var hotkeys: [EventHotKeyRef] = []
|
|
127
129
|
var hotkeyPresets: [UInt32: Preset] = [:]
|
|
130
|
+
var trayHotkeys = Set<UInt32>()
|
|
128
131
|
var loadError: String?
|
|
129
132
|
|
|
130
133
|
var stream: SCStream?
|
|
@@ -141,10 +144,17 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
141
144
|
|
|
142
145
|
/** one capture in the editor window */
|
|
143
146
|
func edit(repo: String, id: String) {
|
|
144
|
-
guard let h = state?.home, let u = URL(string: "\(h)/recordings?solo=1#\(repo)/\(id)") else {
|
|
147
|
+
guard let h = state?.home, let u = URL(string: "\(h)/recordings?solo=1#\(repo)/\(id)") else {
|
|
148
|
+
editor.failed("no hub to open \(repo)/\(id) in: sk rec presets names no home")
|
|
149
|
+
return
|
|
150
|
+
}
|
|
151
|
+
tray.current = "\(repo)/\(id)"
|
|
145
152
|
editor.open(u)
|
|
146
153
|
}
|
|
147
154
|
var busy = false
|
|
155
|
+
/** a capture runs, from its press until its take is filed (choosing, shooting, filing): another press is ignored,
|
|
156
|
+
* so a hotkey pressed twice never stacks two overlays or two takes. A running video is `stream`, stopped by a press */
|
|
157
|
+
var shooting = false
|
|
148
158
|
var pickerAnswer: CheckedContinuation<SCContentFilter?, Never>?
|
|
149
159
|
|
|
150
160
|
// MARK: sk
|
|
@@ -185,11 +195,25 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
185
195
|
|
|
186
196
|
func applicationDidFinishLaunching(_ n: Notification) {
|
|
187
197
|
NSApp.setActivationPolicy(.accessory)
|
|
188
|
-
NSApp.mainMenu = keysMenu()
|
|
198
|
+
NSApp.mainMenu = Recorder.keysMenu()
|
|
189
199
|
UNUserNotificationCenter.current().delegate = self
|
|
190
200
|
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { _, _ in }
|
|
191
201
|
installHotkeyHandler()
|
|
192
202
|
hotkeyFired = { [weak self] id in Task { @MainActor in self?.hotkey(id) } }
|
|
203
|
+
ClipHud.shared.mirror = { [weak self] s in self?.editor.toast(s) }
|
|
204
|
+
// one window: while the editor is open the recent captures sit under it, and the app is one ⌘Tab reaches,
|
|
205
|
+
// with its Dock icon; closed, it is a menu bar app again and the captures are their own panel
|
|
206
|
+
// the page moved to another capture itself (a pick in its gallery): the band's ring follows
|
|
207
|
+
editor.onCapture = { [weak self] ref in self?.tray.current = ref }
|
|
208
|
+
tray.onGallery = { [weak self] in
|
|
209
|
+
guard let self, let h = state?.home, let u = URL(string: "\(h)/recordings?solo=1#gallery") else { return }
|
|
210
|
+
editor.open(u)
|
|
211
|
+
}
|
|
212
|
+
editor.onVisible = { [weak self] on in
|
|
213
|
+
guard let self else { return }
|
|
214
|
+
NSApp.setActivationPolicy(on ? .regular : .accessory)
|
|
215
|
+
tray.host = on ? { [weak self] v in self?.editor.setStrip(v) } : nil
|
|
216
|
+
}
|
|
193
217
|
idle()
|
|
194
218
|
if !CGPreflightScreenCaptureAccess() {
|
|
195
219
|
// the system's prompt, and the app listed in System Settings with its switch off
|
|
@@ -203,18 +227,19 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
203
227
|
tray.onEdit = { [weak self] repo, id in self?.edit(repo: repo, id: id) }
|
|
204
228
|
Task {
|
|
205
229
|
await reload()
|
|
206
|
-
|
|
230
|
+
await tray.refresh(show: false)
|
|
207
231
|
}
|
|
208
232
|
}
|
|
209
233
|
|
|
210
234
|
/** a menu bar app has no menu, and macOS gives a window ⌘W, ⌘C, ⌘V only through one: this one is never shown,
|
|
211
235
|
* it carries the keys. No Undo here: ⌘Z belongs to the editor page's own undo of its marks */
|
|
212
|
-
func keysMenu() -> NSMenu {
|
|
236
|
+
static func keysMenu() -> NSMenu {
|
|
213
237
|
let main = NSMenu()
|
|
214
238
|
let app = NSMenuItem()
|
|
215
239
|
main.addItem(app)
|
|
216
240
|
let am = NSMenu()
|
|
217
241
|
am.addItem(withTitle: "Close", action: #selector(NSWindow.performClose(_:)), keyEquivalent: "w")
|
|
242
|
+
am.addItem(withTitle: "Hide", action: #selector(NSApplication.hide(_:)), keyEquivalent: "h")
|
|
218
243
|
app.submenu = am
|
|
219
244
|
let edit = NSMenuItem()
|
|
220
245
|
main.addItem(edit)
|
|
@@ -240,12 +265,70 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
240
265
|
do { try await freezeShot(out) } catch { fail("freeze-shot: \(error.localizedDescription)") }
|
|
241
266
|
return
|
|
242
267
|
}
|
|
268
|
+
if u.host == "copy", let q = URLComponents(url: u, resolvingAgainstBaseURL: false)?.queryItems, let t = q.first(where: { $0.name == "text" })?.value {
|
|
269
|
+
// the editor's ⌘C of a link: `copy?text=<url>&label=<what>&detail=<line>`
|
|
270
|
+
Clip.copyText(t, label: q.first { $0.name == "label" }?.value ?? "Text", detail: q.first { $0.name == "detail" }?.value ?? "") { [weak self] in self?.fail($0) }
|
|
271
|
+
return
|
|
272
|
+
}
|
|
273
|
+
if u.host == "copy", let q = URLComponents(url: u, resolvingAgainstBaseURL: false)?.queryItems, let f = q.first(where: { $0.name == "file" })?.value {
|
|
274
|
+
// the editor's ⌘C (sk's copy verb): `copy?file=<abs>&format=png|webp-hq|file`, through the one clipboard path
|
|
275
|
+
let file = URL(fileURLWithPath: f)
|
|
276
|
+
switch q.first(where: { $0.name == "format" })?.value {
|
|
277
|
+
case "png": Clip.copy(ClipJob(pngFile: file, format: .png)) { [weak self] in self?.fail($0) }
|
|
278
|
+
case "webp-hq": Clip.copy(ClipJob(pngFile: file, format: .webpHigh, keep: q.first(where: { $0.name == "keep" })?.value.map { URL(fileURLWithPath: $0) })) { [weak self] in self?.fail($0) }
|
|
279
|
+
default: Clip.copyFile(file) { [weak self] in self?.fail($0) }
|
|
280
|
+
}
|
|
281
|
+
return
|
|
282
|
+
}
|
|
283
|
+
if u.host == "refresh" {
|
|
284
|
+
// a capture changed outside the app (a save, a rename or a delete in the editor page): the recent captures read again
|
|
285
|
+
await tray.refresh(show: false)
|
|
286
|
+
return
|
|
287
|
+
}
|
|
288
|
+
if u.host == "hud-shot", let out = URLComponents(url: u, resolvingAgainstBaseURL: false)?.queryItems?.first(where: { $0.name == "out" })?.value {
|
|
289
|
+
// the indicator's proof: `open 'shipkit-recorder://hud-shot?out=<dir>'` draws each of its states to <dir>/hud-<state>.png,
|
|
290
|
+
// and hud-on-screen.png, the ready state shown for real and shot from the screen under the pointer
|
|
291
|
+
do {
|
|
292
|
+
let dir = URL(fileURLWithPath: out, isDirectory: true)
|
|
293
|
+
try ClipHud.shared.drawStates(to: dir)
|
|
294
|
+
let at = ClipHud.shared.demo(.checked(.ready(format: "WebP HQ", size: "41 KB")))
|
|
295
|
+
try await Task.sleep(nanoseconds: 400_000_000)
|
|
296
|
+
try write(try crop(try await frozenScreen(), at.insetBy(dx: -24, dy: -24)), dir.appendingPathComponent("hud-on-screen.png").path)
|
|
297
|
+
say("ok: the clipboard indicator drawn to \(out)")
|
|
298
|
+
} catch { fail("hud-shot: \(error.localizedDescription)") }
|
|
299
|
+
return
|
|
300
|
+
}
|
|
243
301
|
if u.host == "tray-shot", let out = URLComponents(url: u, resolvingAgainstBaseURL: false)?.queryItems?.first(where: { $0.name == "out" })?.value {
|
|
244
302
|
// the tray's proof: `open 'shipkit-recorder://tray-shot?out=<png>'` draws the open tray, its newest captures
|
|
303
|
+
// `&hover=<i>` shows cell i's ×, `&armed=1` as a first click leaves it
|
|
245
304
|
await tray.refresh(show: true)
|
|
305
|
+
let q = URLComponents(url: u, resolvingAgainstBaseURL: false)?.queryItems ?? []
|
|
306
|
+
if let h = q.first(where: { $0.name == "hover" })?.value.flatMap(Int.init) { tray.hover(h, armed: q.contains { $0.name == "armed" && $0.value == "1" }) }
|
|
246
307
|
do { try tray.snapshot(to: URL(fileURLWithPath: out)); say("ok: the tray drawn to \(out)") } catch { fail("tray-shot: \(error.localizedDescription)") }
|
|
247
308
|
return
|
|
248
309
|
}
|
|
310
|
+
if u.host == "editor-shot", let q = URLComponents(url: u, resolvingAgainstBaseURL: false)?.queryItems, let out = q.first(where: { $0.name == "out" })?.value {
|
|
311
|
+
// the window's proof, shot from the screen, then left as it was: `open 'shipkit-recorder://editor-shot?out=<png>'`
|
|
312
|
+
// opens it as a take's end does, its spinner on; `&open=<repo>/<id>` opens that capture for real, the
|
|
313
|
+
// recent captures under it; `&open=gallery` every capture as a grid
|
|
314
|
+
let was = editor.window?.isVisible == true
|
|
315
|
+
let open = q.first(where: { $0.name == "open" })?.value?.split(separator: "/").map(String.init)
|
|
316
|
+
if let open, open.count == 2 { edit(repo: open[0], id: open[1]) } else if open == ["gallery"] { tray.onGallery?() } else { editor.opening("Filing the video…") }
|
|
317
|
+
do {
|
|
318
|
+
if open != nil {
|
|
319
|
+
let end = Date().addingTimeInterval(8)
|
|
320
|
+
while editor.covering, Date() < end { try await Task.sleep(nanoseconds: 100_000_000) }
|
|
321
|
+
try await Task.sleep(nanoseconds: 2_000_000_000)
|
|
322
|
+
} else {
|
|
323
|
+
try await Task.sleep(nanoseconds: 500_000_000)
|
|
324
|
+
}
|
|
325
|
+
guard let w = editor.window else { throw Err("no editor window") }
|
|
326
|
+
try write(try crop(try await frozenScreen(), w.frame), out)
|
|
327
|
+
say("ok: the editor drawn to \(out)")
|
|
328
|
+
} catch { fail("editor-shot: \(error.localizedDescription)") }
|
|
329
|
+
if !was { editor.hide() } else if open == nil, let r = tray.items.first { edit(repo: r.repo, id: r.id) }
|
|
330
|
+
return
|
|
331
|
+
}
|
|
249
332
|
if stream != nil { await stop(); return }
|
|
250
333
|
let q = URLComponents(url: u, resolvingAgainstBaseURL: false)?.queryItems ?? []
|
|
251
334
|
let v = { (n: String) in q.first { $0.name == n }?.value }
|
|
@@ -285,7 +368,19 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
285
368
|
for h in hotkeys { UnregisterEventHotKey(h) }
|
|
286
369
|
hotkeys = []
|
|
287
370
|
hotkeyPresets = [:]
|
|
371
|
+
trayHotkeys = []
|
|
288
372
|
var n: UInt32 = 1
|
|
373
|
+
for k in state?.trayKeys ?? [] {
|
|
374
|
+
guard let parsed = parseKey(k) else { continue }
|
|
375
|
+
var ref: EventHotKeyRef?
|
|
376
|
+
if RegisterEventHotKey(parsed.code, parsed.mods, EventHotKeyID(signature: OSType(0x534B_5243), id: n), GetApplicationEventTarget(), 0, &ref) == noErr, let ref {
|
|
377
|
+
hotkeys.append(ref)
|
|
378
|
+
trayHotkeys.insert(n)
|
|
379
|
+
} else {
|
|
380
|
+
loadError = "\(k) is taken by another app: the tray has no hotkey \(k)"
|
|
381
|
+
}
|
|
382
|
+
n += 1
|
|
383
|
+
}
|
|
289
384
|
for p in state?.presets ?? [] {
|
|
290
385
|
for k in p.keys ?? [] {
|
|
291
386
|
guard let parsed = parseKey(k) else { continue }
|
|
@@ -303,6 +398,8 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
303
398
|
}
|
|
304
399
|
|
|
305
400
|
func hotkey(_ id: UInt32) {
|
|
401
|
+
// the tray's key shows or hides it at any time, a running video included, which it never stops
|
|
402
|
+
if trayHotkeys.contains(id) { trayClicked(); return }
|
|
306
403
|
if Chooser.key(id) { return }
|
|
307
404
|
if stream != nil { Task { await stop() }; return }
|
|
308
405
|
guard let p = hotkeyPresets[id] else { return }
|
|
@@ -354,7 +451,7 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
354
451
|
let ri = NSMenuItem(title: "Takes go to: \(repo)", action: nil, keyEquivalent: "")
|
|
355
452
|
ri.submenu = repos
|
|
356
453
|
m.addItem(ri)
|
|
357
|
-
let recent = NSMenuItem(title: tray.
|
|
454
|
+
let recent = NSMenuItem(title: tray.on ? "Hide recent captures" : "Show recent captures", action: #selector(trayClicked), keyEquivalent: "")
|
|
358
455
|
recent.target = self
|
|
359
456
|
m.addItem(recent)
|
|
360
457
|
let formats = NSMenu()
|
|
@@ -384,10 +481,10 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
384
481
|
Task { await record(Ask(preset: p, repo: repo, name: nil, replace: nil, fromUrl: false)) }
|
|
385
482
|
}
|
|
386
483
|
@objc func clipFormatClicked(_ i: NSMenuItem) {
|
|
387
|
-
if let r = i.representedObject as? String, let f = ClipFormat(rawValue: r) { ClipFormat.current = f;
|
|
484
|
+
if let r = i.representedObject as? String, let f = ClipFormat(rawValue: r) { ClipFormat.current = f; tray.render() }
|
|
388
485
|
}
|
|
389
486
|
@objc func repoClicked(_ i: NSMenuItem) { if let r = i.representedObject as? String { repo = r; buildMenu() } }
|
|
390
|
-
@objc func trayClicked() { if tray.
|
|
487
|
+
@objc func trayClicked() { if tray.on { tray.close() } else { Task { await tray.refresh(show: true) } } }
|
|
391
488
|
@objc func openClicked() { if let h = state?.home, let u = URL(string: "\(h)/recordings") { NSWorkspace.shared.open(u) } }
|
|
392
489
|
@objc func reloadClicked() { Task { await reload() } }
|
|
393
490
|
@objc func stopClicked() { Task { await stop() } }
|
|
@@ -439,7 +536,9 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
439
536
|
return Target(filter: f, w: even(f.contentRect.width * scale), h: even(f.contentRect.height * scale))
|
|
440
537
|
}
|
|
441
538
|
if p.shoot.mode == "select" || p.shoot.mode == "region" {
|
|
442
|
-
|
|
539
|
+
// a video's bar starts as it was left for this preset, the preset's own mic and sound until it is touched once
|
|
540
|
+
let keep = p.still == true ? nil : p.id
|
|
541
|
+
guard let c = await choose(video: p.still != true, windowsToo: p.shoot.mode == "select", mic: SoundChoice.get("mic", keep, else: p.mic == true), sound: SoundChoice.get("sound", keep, else: p.systemAudio == true), remember: keep) else { return nil }
|
|
443
542
|
let content = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: true)
|
|
444
543
|
let scale = c.screen.backingScaleFactor
|
|
445
544
|
if let w = c.window, let sw = content.windows.first(where: { $0.windowID == w.id }) {
|
|
@@ -555,7 +654,13 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
555
654
|
// MARK: record
|
|
556
655
|
|
|
557
656
|
func record(_ a: Ask) async {
|
|
558
|
-
if stream != nil
|
|
657
|
+
if stream != nil { return }
|
|
658
|
+
if shooting || busy {
|
|
659
|
+
say("ignored: a capture is already running (\(a.preset.label ?? a.preset.id))")
|
|
660
|
+
return
|
|
661
|
+
}
|
|
662
|
+
shooting = true
|
|
663
|
+
defer { shooting = false }
|
|
559
664
|
do {
|
|
560
665
|
if a.preset.shoot.mode == "freeze" {
|
|
561
666
|
try await freeze(a)
|
|
@@ -649,6 +754,8 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
649
754
|
ticker?.invalidate()
|
|
650
755
|
stopper?.invalidate()
|
|
651
756
|
stream = nil
|
|
757
|
+
// the editor up at the press, its spinner on while the file is finished and filed
|
|
758
|
+
if ask?.preset.after?.contains("open-editor") == true { editor.opening("Saving the video…") }
|
|
652
759
|
do {
|
|
653
760
|
try await s.stopCapture()
|
|
654
761
|
} catch {
|
|
@@ -758,14 +865,14 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
758
865
|
}
|
|
759
866
|
|
|
760
867
|
/** a still on the clipboard now, its data promised in the menu's format and made behind it; a WebP that fails
|
|
761
|
-
* leaves the PNG, said */
|
|
868
|
+
* leaves the PNG, said, and the indicator shows what the clipboard reads back */
|
|
762
869
|
func clip(_ img: CGImage) {
|
|
763
870
|
let job = ClipJob(image: img, format: ClipFormat.current)
|
|
764
|
-
|
|
765
|
-
job
|
|
766
|
-
if let failure { self?.fail(failure) } else { say("ok: \(said)") }
|
|
767
|
-
}
|
|
871
|
+
shotClip = job
|
|
872
|
+
Clip.copy(job) { [weak self] in self?.fail($0) }
|
|
768
873
|
}
|
|
874
|
+
/** the clipboard job of the still being filed: its WebP, made at the shot, is kept with the capture once filed */
|
|
875
|
+
var shotClip: ClipJob?
|
|
769
876
|
|
|
770
877
|
/** the take handed to sk: filed under its repo, its after steps run; `clipped`: the app put it on the clipboard */
|
|
771
878
|
func file(_ url: URL, _ a: Ask, clipped: Bool = false) async {
|
|
@@ -777,6 +884,7 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
777
884
|
// disk), then the ones that wait on the network behind it. open-editor is this app's own step, its window
|
|
778
885
|
let after = a.preset.after ?? []
|
|
779
886
|
let opensEditor = after.contains("open-editor")
|
|
887
|
+
if opensEditor { editor.opening(a.preset.still == true ? "Filing the screenshot…" : "Filing the video…") }
|
|
780
888
|
let local = after.filter { $0 == "reveal" || ($0 == "copy-file" && !clipped) }
|
|
781
889
|
let remote = after.filter { !["open-editor", "copy-file", "reveal"].contains($0) }
|
|
782
890
|
args += ["--after", local.joined(separator: ",")]
|
|
@@ -787,13 +895,20 @@ final class Recorder: NSObject, NSApplicationDelegate, SCStreamDelegate, SCRecor
|
|
|
787
895
|
idle()
|
|
788
896
|
let line = r.out.split(separator: "\n").last.map(String.init) ?? ""
|
|
789
897
|
guard let j = try? JSONDecoder().decode(Imported.self, from: Data(line.utf8)) else {
|
|
790
|
-
|
|
898
|
+
let why = r.err.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty ? "sk rec import said nothing; the take is at \(url.path)" : r.err
|
|
899
|
+
if opensEditor { editor.failed(why) }
|
|
900
|
+
fail(why)
|
|
791
901
|
return
|
|
792
902
|
}
|
|
903
|
+
if opensEditor, j.recording == nil { editor.failed(j.error ?? "the take did not file") }
|
|
904
|
+
// the WebP the shot already made is the capture's own: kept beside it, so it reads as ready and the next copy encodes nothing
|
|
905
|
+
if clipped, let keep = j.recording?.webp { shotClip?.keepWebp(at: URL(fileURLWithPath: keep)) }
|
|
906
|
+
shotClip = nil
|
|
793
907
|
let editor = j.recording.flatMap { rec in state?.home.map { "\($0)/recordings#\(rec.repo)/\(rec.id)" } }
|
|
794
908
|
if let rec = j.recording, !remote.isEmpty { tray.pending.insert(rec.id) }
|
|
795
|
-
|
|
909
|
+
// the editor first: the tray's refresh is another sk run, and the window already waits on this take
|
|
796
910
|
if opensEditor, let rec = j.recording { edit(repo: rec.repo, id: rec.id) }
|
|
911
|
+
if j.recording != nil { await tray.refresh(show: true) }
|
|
797
912
|
if let rec = j.recording, !remote.isEmpty {
|
|
798
913
|
// the network's part, behind the take: the tray spins on it until it is done
|
|
799
914
|
let cli = self.cli
|
|
@@ -848,12 +963,228 @@ if let i = CommandLine.arguments.firstIndex(of: "--clip-test"), CommandLine.argu
|
|
|
848
963
|
let job = ClipJob(pngFile: png, format: format)
|
|
849
964
|
do { try Clip.put(job) } catch { print("FAIL: \(error.localizedDescription)"); exit(1) }
|
|
850
965
|
print("ok: on the clipboard, promised")
|
|
851
|
-
job.whenReady {
|
|
966
|
+
job.whenReady { r in print(r.line) }
|
|
852
967
|
}
|
|
853
968
|
DispatchQueue.main.asyncAfter(deadline: .now() + 5) { exit(0) }
|
|
854
969
|
RunLoop.main.run()
|
|
855
970
|
}
|
|
856
971
|
|
|
972
|
+
if CommandLine.arguments.contains("--editor-cover-test") {
|
|
973
|
+
// the editor's cover lifts on every open: a first capture, then another, which only changes the url's fragment, so
|
|
974
|
+
// WebKit moves within the same document. Exits 1 when the cover stays
|
|
975
|
+
MainActor.assumeIsolated {
|
|
976
|
+
_ = NSApplication.shared
|
|
977
|
+
NSApp.setActivationPolicy(.accessory)
|
|
978
|
+
let html = FileManager.default.temporaryDirectory.appendingPathComponent("editor-cover-test.html")
|
|
979
|
+
try! "<html><body>capture</body></html>".write(to: html, atomically: true, encoding: .utf8)
|
|
980
|
+
let e = EditorWindow()
|
|
981
|
+
func lifts(_ what: String, within: Double, then: @escaping @MainActor () -> Void) {
|
|
982
|
+
let end = Date().addingTimeInterval(within)
|
|
983
|
+
Timer.scheduledTimer(withTimeInterval: 0.05, repeats: true) { t in
|
|
984
|
+
MainActor.assumeIsolated {
|
|
985
|
+
if !e.covering { t.invalidate(); print("ok: the cover lifts after \(what)"); then() }
|
|
986
|
+
else if Date() > end { print("FAIL: the cover stays after \(what)"); exit(1) }
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
e.open(URL(string: html.absoluteString + "#first")!)
|
|
991
|
+
lifts("a first capture", within: 5) {
|
|
992
|
+
e.open(URL(string: html.absoluteString + "#second")!)
|
|
993
|
+
lifts("another capture, the same page at another fragment", within: 3) { exit(0) }
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
RunLoop.main.run()
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
if CommandLine.arguments.contains("--bar-choice-test") {
|
|
1000
|
+
// the bar's mic and system sound are kept per preset: a bar never touched starts as its preset says, a switch
|
|
1001
|
+
// flipped is how the next bar of that preset starts, and another preset is untouched. Exits 1 otherwise
|
|
1002
|
+
MainActor.assumeIsolated {
|
|
1003
|
+
_ = NSApplication.shared
|
|
1004
|
+
let (a, b) = ("bar-choice-test-a-\(ProcessInfo.processInfo.processIdentifier)", "bar-choice-test-b-\(ProcessInfo.processInfo.processIdentifier)")
|
|
1005
|
+
var bad: [String] = []
|
|
1006
|
+
func expect(_ what: String, _ ok: Bool) { if !ok { bad.append(what) } }
|
|
1007
|
+
let start = { (id: String) in (SoundChoice.get("mic", id, else: true), SoundChoice.get("sound", id, else: false)) }
|
|
1008
|
+
expect("a bar never touched starts as its preset says", start(a) == (true, false))
|
|
1009
|
+
let c = Chooser(video: true, windowsToo: false, mic: start(a).0, sound: start(a).1, remember: a)
|
|
1010
|
+
let off = NSButton(), on = NSButton()
|
|
1011
|
+
off.state = .off
|
|
1012
|
+
on.state = .on
|
|
1013
|
+
c.micClicked(off)
|
|
1014
|
+
c.soundClicked(on)
|
|
1015
|
+
expect("the next bar of that preset starts as this one was left", start(a) == (false, true))
|
|
1016
|
+
expect("another preset keeps its own", start(b) == (true, false))
|
|
1017
|
+
SoundChoice.forget(a)
|
|
1018
|
+
expect("forgotten, the preset's values are back", start(a) == (true, false))
|
|
1019
|
+
for x in bad { print("FAIL: not so: \(x)") }
|
|
1020
|
+
if bad.isEmpty { print("ok: the bar's mic and sound are kept per preset") }
|
|
1021
|
+
exit(bad.isEmpty ? 0 : 1)
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
if CommandLine.arguments.contains("--dock-test") {
|
|
1026
|
+
// one window at a time: the recent captures are their own panel while the editor is closed, sit under it while it
|
|
1027
|
+
// is open (the app then in ⌘Tab), leave it when switched off, and are a panel again once it closes. Exits 1 on
|
|
1028
|
+
// any other state
|
|
1029
|
+
MainActor.assumeIsolated {
|
|
1030
|
+
_ = NSApplication.shared
|
|
1031
|
+
NSApp.setActivationPolicy(.accessory)
|
|
1032
|
+
let was = UserDefaults.standard.bool(forKey: RecentTray.SHOWN)
|
|
1033
|
+
let wasOff = UserDefaults.standard.bool(forKey: RecentTray.DOCK_OFF)
|
|
1034
|
+
UserDefaults.standard.set(false, forKey: RecentTray.DOCK_OFF)
|
|
1035
|
+
let t = RecentTray()
|
|
1036
|
+
t.items = [RecentItem(id: "20260101-000000", name: "a-capture", repo: "demo", still: true, seconds: 0, dir: "/nowhere")]
|
|
1037
|
+
let e = EditorWindow()
|
|
1038
|
+
e.onVisible = { on in
|
|
1039
|
+
NSApp.setActivationPolicy(on ? .regular : .accessory)
|
|
1040
|
+
t.host = on ? { e.setStrip($0) } : nil
|
|
1041
|
+
}
|
|
1042
|
+
var bad: [String] = []
|
|
1043
|
+
func expect(_ what: String, _ ok: Bool) { if !ok { bad.append(what) } }
|
|
1044
|
+
let panel = { t.panel?.isVisible == true }
|
|
1045
|
+
t.open()
|
|
1046
|
+
expect("the captures are a panel while the editor is closed", panel())
|
|
1047
|
+
e.opening("a capture")
|
|
1048
|
+
expect("the panel leaves when the editor opens", !panel())
|
|
1049
|
+
expect("the captures sit under the editor", e.stripShown)
|
|
1050
|
+
expect("the app is one ⌘Tab reaches while the editor is open", NSApp.activationPolicy() == .regular)
|
|
1051
|
+
t.close()
|
|
1052
|
+
expect("switched off, the editor keeps the whole window", !e.stripShown && e.window?.isVisible == true && !panel())
|
|
1053
|
+
t.open()
|
|
1054
|
+
expect("switched on again, they are back under the editor", e.stripShown && !panel())
|
|
1055
|
+
e.window?.close()
|
|
1056
|
+
expect("the editor closed, the panel is back", panel() && e.window?.isVisible != true)
|
|
1057
|
+
expect("a menu bar app again once the editor is closed", NSApp.activationPolicy() == .accessory)
|
|
1058
|
+
t.close()
|
|
1059
|
+
UserDefaults.standard.set(was, forKey: RecentTray.SHOWN)
|
|
1060
|
+
UserDefaults.standard.set(wasOff, forKey: RecentTray.DOCK_OFF)
|
|
1061
|
+
for b in bad { print("FAIL: not so: \(b)") }
|
|
1062
|
+
if bad.isEmpty { print("ok: one window at a time, the recent captures under the editor while it is open") }
|
|
1063
|
+
exit(bad.isEmpty ? 0 : 1)
|
|
1064
|
+
}
|
|
1065
|
+
}
|
|
1066
|
+
|
|
1067
|
+
if CommandLine.arguments.contains("--hud-file-test") {
|
|
1068
|
+
// a file copied (a video, the editor's ⌘C) shows on the indicator: written on a private pasteboard, then read
|
|
1069
|
+
// back, and the indicator must say so. Exits 1 when it stays silent
|
|
1070
|
+
MainActor.assumeIsolated {
|
|
1071
|
+
_ = NSApplication.shared
|
|
1072
|
+
NSApp.setActivationPolicy(.accessory)
|
|
1073
|
+
let f = FileManager.default.temporaryDirectory.appendingPathComponent("hud-file-test.mp4")
|
|
1074
|
+
try! Data(repeating: 7, count: 2048).write(to: f)
|
|
1075
|
+
let e = EditorWindow()
|
|
1076
|
+
ClipHud.shared.mirror = { e.toast($0) }
|
|
1077
|
+
e.opening("a capture")
|
|
1078
|
+
Clip.copyFile(f, on: NSPasteboard(name: NSPasteboard.Name("dev.shipkit.recorder.hud-test"))) { print("FAIL: \($0)"); exit(1) }
|
|
1079
|
+
let t = ClipHud.shared.shownTitle, w = e.toastTitle
|
|
1080
|
+
let ok = t == "MP4 file on the clipboard" && w == t
|
|
1081
|
+
print(ok ? "ok: the corner and the editor window say \(t!)" : "FAIL: the corner says \(t ?? "nothing"), the editor window \(w ?? "nothing")")
|
|
1082
|
+
exit(ok ? 0 : 1)
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1086
|
+
if CommandLine.arguments.contains("--editor-key-test") {
|
|
1087
|
+
// ⌘C reaches the editor's page: the app's Edit menu binds ⌘C to Copy, and the page must still see the key first
|
|
1088
|
+
// to copy the capture. A page that takes ⌘C sets its title; exits 1 when the key never reached it
|
|
1089
|
+
MainActor.assumeIsolated {
|
|
1090
|
+
_ = NSApplication.shared
|
|
1091
|
+
NSApp.setActivationPolicy(.accessory)
|
|
1092
|
+
NSApp.mainMenu = Recorder.keysMenu()
|
|
1093
|
+
let html = FileManager.default.temporaryDirectory.appendingPathComponent("editor-key-test.html")
|
|
1094
|
+
try! "<html><body>capture<script>addEventListener('keydown',e=>{if(e.metaKey&&(e.key==='c'||e.key==='s')){e.preventDefault();document.title+=e.key}})</script></body></html>".write(to: html, atomically: true, encoding: .utf8)
|
|
1095
|
+
let e = EditorWindow()
|
|
1096
|
+
e.open(html)
|
|
1097
|
+
let end = Date().addingTimeInterval(5)
|
|
1098
|
+
var sent = false
|
|
1099
|
+
Timer.scheduledTimer(withTimeInterval: 0.1, repeats: true) { t in
|
|
1100
|
+
MainActor.assumeIsolated {
|
|
1101
|
+
guard let w = e.window, let web = e.web else { return }
|
|
1102
|
+
if !sent && !e.covering {
|
|
1103
|
+
sent = true
|
|
1104
|
+
w.makeKeyAndOrderFront(nil)
|
|
1105
|
+
w.makeFirstResponder(web)
|
|
1106
|
+
// ⌘C (the Edit menu binds it to Copy) and ⌘S (no menu item): what AppKit does with a ⌘ key in the key
|
|
1107
|
+
// window, before the menu. This process is never active, so its window is never key and
|
|
1108
|
+
// NSApp.sendEvent would skip the window
|
|
1109
|
+
for (ch, code) in [("c", UInt16(8)), ("s", UInt16(1))] {
|
|
1110
|
+
let ev = NSEvent.keyEvent(with: .keyDown, location: .zero, modifierFlags: .command, timestamp: 0, windowNumber: w.windowNumber, context: nil, characters: ch, charactersIgnoringModifiers: ch, isARepeat: false, keyCode: code)!
|
|
1111
|
+
_ = w.performKeyEquivalent(with: ev)
|
|
1112
|
+
}
|
|
1113
|
+
}
|
|
1114
|
+
if web.title == "cs" { t.invalidate(); print("ok: ⌘C and ⌘S reached the page"); exit(0) }
|
|
1115
|
+
if Date() > end { print("FAIL: the page got \(web.title ?? "nothing") of ⌘C and ⌘S"); exit(1) }
|
|
1116
|
+
}
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
RunLoop.main.run()
|
|
1120
|
+
}
|
|
1121
|
+
|
|
1122
|
+
if let i = CommandLine.arguments.firstIndex(of: "--clip-keep-test"), CommandLine.arguments.count > i + 1 {
|
|
1123
|
+
// a still's WebP is made once and kept, on a private pasteboard: `--clip-keep-test <png>`. The first copy encodes it
|
|
1124
|
+
// and writes it where it is kept; the next copy serves that file's bytes, encoding nothing. Exits 1 otherwise
|
|
1125
|
+
let png = URL(fileURLWithPath: CommandLine.arguments[i + 1])
|
|
1126
|
+
MainActor.assumeIsolated {
|
|
1127
|
+
let pb = NSPasteboard(name: NSPasteboard.Name("dev.shipkit.recorder.keep-test"))
|
|
1128
|
+
let keep = FileManager.default.temporaryDirectory.appendingPathComponent("clip-keep-test-\(ProcessInfo.processInfo.processIdentifier).webp")
|
|
1129
|
+
let a = ClipJob(pngFile: png, format: .webpHigh, keep: keep)
|
|
1130
|
+
do { try Clip.put(a, on: pb) } catch { print("FAIL: \(error.localizedDescription)"); exit(1) }
|
|
1131
|
+
a.whenReady { r in
|
|
1132
|
+
guard case .ready = r, let made = try? Data(contentsOf: keep), made == pb.data(forType: Clip.WEBP_TYPE) else { print("FAIL: the first copy kept no WebP: \(r.line)"); exit(1) }
|
|
1133
|
+
// other bytes under the kept name: the next copy serving them proves it reads the file
|
|
1134
|
+
let mark = Data("kept".utf8)
|
|
1135
|
+
try! mark.write(to: keep)
|
|
1136
|
+
let b = ClipJob(pngFile: png, format: .webpHigh, keep: keep)
|
|
1137
|
+
do { try Clip.put(b, on: pb) } catch { print("FAIL: \(error.localizedDescription)"); exit(1) }
|
|
1138
|
+
b.whenReady { _ in
|
|
1139
|
+
let ok = pb.data(forType: Clip.WEBP_TYPE) == mark
|
|
1140
|
+
try? FileManager.default.removeItem(at: keep)
|
|
1141
|
+
guard ok else { print("FAIL: the next copy encoded again instead of reading the kept WebP"); exit(1) }
|
|
1142
|
+
// a shot's job is given its place only once its take is filed: its WebP lands there then
|
|
1143
|
+
b.keepWebp(at: keep)
|
|
1144
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
|
|
1145
|
+
let late = (try? Data(contentsOf: keep)) == mark
|
|
1146
|
+
try? FileManager.default.removeItem(at: keep)
|
|
1147
|
+
print(late ? "ok: the WebP is made once (\(made.count) bytes), kept, read back by the next copy, and a shot's is kept once filed" : "FAIL: a job told where to keep its WebP after it was made wrote nothing")
|
|
1148
|
+
exit(late ? 0 : 1)
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
}
|
|
1153
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 10) { print("FAIL: no answer in 10 s"); exit(1) }
|
|
1154
|
+
RunLoop.main.run()
|
|
1155
|
+
}
|
|
1156
|
+
|
|
1157
|
+
if let i = CommandLine.arguments.firstIndex(of: "--clip-race-test"), CommandLine.arguments.count > i + 1 {
|
|
1158
|
+
// the clipboard's races, on a private pasteboard (the owner's own clipboard untouched): `--clip-race-test <png>`.
|
|
1159
|
+
// Two stills shot back to back: the first reads back replaced, only the second ready. A still whose clipboard
|
|
1160
|
+
// another app takes while its WebP encodes: replaced. Exits 1 on any other answer
|
|
1161
|
+
let png = URL(fileURLWithPath: CommandLine.arguments[i + 1])
|
|
1162
|
+
MainActor.assumeIsolated {
|
|
1163
|
+
let pb = NSPasteboard(name: NSPasteboard.Name("dev.shipkit.recorder.race-test"))
|
|
1164
|
+
let a = ClipJob(pngFile: png, format: .webpHigh), b = ClipJob(pngFile: png, format: .webpHigh), c = ClipJob(pngFile: png, format: .webpHigh)
|
|
1165
|
+
do { try Clip.put(a, on: pb); try Clip.put(b, on: pb) } catch { print("FAIL: \(error.localizedDescription)"); exit(1) }
|
|
1166
|
+
var got: [String: ClipCheck] = [:]
|
|
1167
|
+
let end = {
|
|
1168
|
+
guard got.count == 3 else { return }
|
|
1169
|
+
let ok = got["first"] == .replaced && got["taken"] == .replaced && { if case .ready = got["second"] { true } else { false } }()
|
|
1170
|
+
for k in ["first", "second", "taken"] { print("\(k): \(got[k]!.line)") }
|
|
1171
|
+
print(ok ? "ok: every race reads back as it happened" : "FAIL: a race read back wrong")
|
|
1172
|
+
exit(ok ? 0 : 1)
|
|
1173
|
+
}
|
|
1174
|
+
a.whenReady { got["first"] = $0; end() }
|
|
1175
|
+
b.whenReady { r in
|
|
1176
|
+
got["second"] = r
|
|
1177
|
+
do { try Clip.put(c, on: pb) } catch { print("FAIL: \(error.localizedDescription)"); exit(1) }
|
|
1178
|
+
pb.clearContents()
|
|
1179
|
+
pb.setString("another app's copy", forType: .string)
|
|
1180
|
+
c.whenReady { got["taken"] = $0; end() }
|
|
1181
|
+
end()
|
|
1182
|
+
}
|
|
1183
|
+
}
|
|
1184
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 10) { print("FAIL: no answer in 10 s"); exit(1) }
|
|
1185
|
+
RunLoop.main.run()
|
|
1186
|
+
}
|
|
1187
|
+
|
|
857
1188
|
MainActor.assumeIsolated {
|
|
858
1189
|
let app = NSApplication.shared
|
|
859
1190
|
let delegate = Recorder()
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// sk. Rebuilt only when the source or the sk it runs changed: a rebuilt binary may ask for Screen Recording again
|
|
4
4
|
import { join } from 'node:path'
|
|
5
5
|
import { LIB_VERSION } from '../core/lib-version.ts'
|
|
6
|
-
import {
|
|
6
|
+
import { identityOfRoot } from '../core/app-icon.ts'
|
|
7
7
|
import { identityOfName } from '../core/identity-color.ts'
|
|
8
8
|
import { houseRoot } from '../home/home-start.ts'
|
|
9
9
|
import { ensureApp, type AppSpec } from '../home/gui-app.ts'
|
|
@@ -13,7 +13,7 @@ import { RECORDER_SCHEME } from './open.ts'
|
|
|
13
13
|
export const RECORDER_BUNDLE_ID = 'dev.shipkit.recorder'
|
|
14
14
|
/** the app's Swift module: main.swift (the menu, the hotkeys, the takes), Capture.swift (the overlay), Tray.swift (the
|
|
15
15
|
* recent captures), Editor.swift (the editor window) */
|
|
16
|
-
export const RECORDER_SOURCES = ['main.swift', 'Capture.swift', 'Tray.swift', 'Editor.swift', 'Clip.swift'].map((f) => join(import.meta.dir, 'recorder-app', f))
|
|
16
|
+
export const RECORDER_SOURCES = ['main.swift', 'Capture.swift', 'Tray.swift', 'Editor.swift', 'Clip.swift', 'Hud.swift'].map((f) => join(import.meta.dir, 'recorder-app', f))
|
|
17
17
|
export const recorderAppPath = (): string => process.env.SHIPKIT_RECORDER_APP ?? join(appsDir(), 'Shipkit Recorder.app')
|
|
18
18
|
|
|
19
19
|
const xml = (s: string): string => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>')
|
|
@@ -21,7 +21,11 @@ const xml = (s: string): string => s.replace(/&/g, '&').replace(/</g, '<'
|
|
|
21
21
|
/** the argv that runs this sk: the bun running now and the cli source beside this file */
|
|
22
22
|
export const skArgv = (): string[] => [process.execPath, join(import.meta.dir, '..', 'cli.ts')]
|
|
23
23
|
|
|
24
|
-
/** the
|
|
24
|
+
/** the recorder's own mark: a viewfinder and a record dot on red, a whole tile, so it never reads as the shipkit app
|
|
25
|
+
* beside it in ⌘Tab and the Dock */
|
|
26
|
+
export const RECORDER_ICON = join(import.meta.dir, 'recorder-app', 'icon.svg')
|
|
27
|
+
|
|
28
|
+
/** the spec of the bundle: its own icon, source and scheme */
|
|
25
29
|
export function recorderSpec(o: { app?: string; cli?: string[]; root?: string | null } = {}): AppSpec {
|
|
26
30
|
const cli = o.cli ?? skArgv()
|
|
27
31
|
const root = o.root === undefined ? houseRoot(process.cwd()) : o.root
|
|
@@ -29,7 +33,7 @@ export function recorderSpec(o: { app?: string; cli?: string[]; root?: string |
|
|
|
29
33
|
name: 'Shipkit Recorder',
|
|
30
34
|
bundleId: RECORDER_BUNDLE_ID,
|
|
31
35
|
url: null,
|
|
32
|
-
icon:
|
|
36
|
+
icon: RECORDER_ICON,
|
|
33
37
|
identity: root == null ? identityOfName('shipkit') : identityOfRoot(root),
|
|
34
38
|
app: o.app ?? recorderAppPath(),
|
|
35
39
|
version: LIB_VERSION,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the menu bar recorder as a machine process: pm keeps it running, so its hotkeys answer from any app
|
|
1
|
+
// the menu bar recorder as a machine process: pm starts it at login and keeps it running, so its hotkeys answer from any app
|
|
2
2
|
import { join } from 'node:path'
|
|
3
3
|
import { globalProcess } from '../shipkit-files.ts'
|
|
4
4
|
|
|
@@ -8,4 +8,5 @@ export default globalProcess({
|
|
|
8
8
|
description: 'menu bar screen recorder: a hotkey per preset, takes filed under a repo, up in the Space (sk rec presets)',
|
|
9
9
|
cmd: ['bun', join(import.meta.dir, 'run-recorder.ts')],
|
|
10
10
|
icon: '⏺️',
|
|
11
|
+
atLogin: true,
|
|
11
12
|
})
|