rvlib-shipkit 2.21.0 → 2.22.1
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 +23 -0
- package/package.json +1 -1
- package/src/asks/asks-queue.ts +8 -7
- package/src/assets/kits/identity-kit.ts +158 -2
- package/src/cli/cmd_Bump.ts +3 -3
- package/src/cli/cmd_Rec.ts +349 -0
- package/src/cli/cmd_Releases.ts +4 -1
- package/src/cli/cmd_Secret.ts +10 -3
- package/src/cli/cmd_Sign.ts +24 -0
- package/src/cli/cmd_Social.ts +44 -1
- package/src/cli/family-pages.ts +1 -0
- package/src/cli/registry.ts +4 -0
- package/src/core/agent-spawn.ts +4 -17
- package/src/core/code-lines.ts +49 -0
- package/src/core/discover-checks.ts +27 -3
- package/src/core/hard-reset.ts +34 -0
- package/src/core/raw-access.ts +3 -13
- package/src/core/throwaway-worktree.ts +72 -0
- package/src/home/app-sign.ts +98 -0
- package/src/home/gui-app.ts +31 -12
- package/src/home/home-routes.ts +6 -0
- package/src/home/serve-web.ts +1 -1
- package/src/identities/identities.ts +6 -0
- package/src/media-kinds.ts +5 -3
- package/src/media-store/forget.ts +54 -0
- package/src/media-store/put.ts +4 -3
- package/src/media-store/space.ts +63 -24
- package/src/recordings/delete.ts +19 -0
- package/src/recordings/edit.ts +231 -0
- package/src/recordings/load.ts +37 -0
- package/src/recordings/marks-draw.ts +111 -0
- package/src/recordings/marks-png.ts +25 -0
- package/src/recordings/marks.ts +138 -0
- package/src/recordings/media-kind.ts +67 -0
- package/src/recordings/model.ts +170 -0
- package/src/recordings/open.ts +33 -0
- package/src/recordings/place.ts +89 -0
- package/src/recordings/presets.ts +99 -0
- package/src/recordings/recorder-app/Capture.swift +510 -0
- package/src/recordings/recorder-app/Clip.swift +162 -0
- package/src/recordings/recorder-app/Editor.swift +39 -0
- package/src/recordings/recorder-app/Tray.swift +298 -0
- package/src/recordings/recorder-app/main.swift +862 -0
- package/src/recordings/recorder-app.ts +46 -0
- package/src/recordings/recorder.shipkit.ts +11 -0
- package/src/recordings/routes.ts +140 -0
- package/src/recordings/run-recorder.ts +40 -0
- package/src/recordings/share.ts +107 -0
- package/src/recordings/take.ts +146 -0
- package/src/recordings/view.ts +40 -0
- package/src/release/gate-checkout.ts +74 -0
- package/src/release/release-scope.ts +35 -26
- package/src/release/run-bump.ts +79 -37
- package/src/release/run-release.ts +67 -53
- package/src/releases/add.ts +7 -2
- package/src/releases/from-card.ts +3 -3
- package/src/releases/model.ts +29 -7
- package/src/repo-config.ts +7 -3
- package/src/review/trailer-desk.ts +1 -0
- package/src/review/trailer-model.ts +2 -0
- package/src/secrets/manager.ts +18 -1
- package/src/serve/hub-app/home-st.ts +15 -5
- package/src/serve/hub-app/home.html +1 -0
- package/src/serve/hub-app/hub-app.tsx +6 -1
- package/src/serve/hub-app/icons.tsx +2 -0
- package/src/serve/hub-app/palette-st.ts +1 -0
- package/src/serve/hub-app/project-list.tsx +1 -0
- package/src/serve/hub-app/projects-svc.ts +1 -1
- package/src/serve/hub-app/recordings-st.ts +641 -0
- package/src/serve/hub-app/recordings-view.tsx +504 -0
- package/src/serve/hub-app/recordings.css +82 -0
- package/src/serve/hub-app/repo-st.ts +1 -1
- package/src/serve/hub-app/review/trailer-page.tsx +1 -0
- package/src/serve/hub-app/review/trailer-st.ts +16 -0
- package/src/serve/hub-app/review/trailer-timeline.tsx +3 -0
- package/src/serve/hub-app/review.css +2 -0
- package/src/serve/hub-app/social/post-card.tsx +31 -3
- package/src/serve/hub-app/social/social-model.ts +4 -0
- package/src/serve/hub-app/social/social-st.ts +12 -0
- package/src/serve/hub-app/social.css +4 -0
- package/src/shipkit.ts +2 -2
- package/src/shot/box.ts +23 -17
- package/src/shot/browser-slot.ts +13 -3
- package/src/shot/film-box.ts +193 -117
- package/src/shot/shooter.ts +5 -3
- package/src/smoke/run-smoke.ts +8 -6
- package/src/social/compose.ts +14 -0
- package/src/social/drafts.ts +1 -1
- package/src/social/load.ts +16 -2
- package/src/social/publish/index.ts +3 -1
- package/src/social/publish/secret.ts +12 -4
- package/src/social/release-card.ts +69 -0
- package/src/social/release-stage.ts +49 -10
- package/src/social/routes.ts +5 -0
- package/src/social/stage.ts +9 -5
- package/src/trailer/build.ts +24 -0
- package/src/trailer/ffmpeg.ts +8 -0
- package/src/trailer/grammar.ts +9 -2
- package/src/trailer/look.ts +7 -0
- package/src/veille/chrome.ts +6 -3
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// the recorder's editor window (wiki tools/shipkit/recordings.md, The recorder): the hub's editor alone for one capture
|
|
2
|
+
// (`/recordings?solo=1#<repo>/<id>`), in a window of its own, resizable, closable, where it was left: brought to the
|
|
3
|
+
// front when it opens, then a window like any other, behind what is picked next (only the tray floats). It opens after a take whose preset ends with open-editor (a screenshot, by default) and on a click of a
|
|
4
|
+
// capture in the tray, so a capture is annotated without leaving what was being done
|
|
5
|
+
import AppKit
|
|
6
|
+
import WebKit
|
|
7
|
+
|
|
8
|
+
@MainActor
|
|
9
|
+
final class EditorWindow: NSObject, NSWindowDelegate {
|
|
10
|
+
var window: NSWindow?
|
|
11
|
+
var web: WKWebView?
|
|
12
|
+
|
|
13
|
+
func open(_ url: URL) {
|
|
14
|
+
let w = window ?? make()
|
|
15
|
+
window = w
|
|
16
|
+
web?.load(URLRequest(url: url))
|
|
17
|
+
NSApp.activate()
|
|
18
|
+
w.makeKeyAndOrderFront(nil)
|
|
19
|
+
w.orderFrontRegardless()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private func make() -> NSWindow {
|
|
23
|
+
let config = WKWebViewConfiguration()
|
|
24
|
+
config.websiteDataStore = .default()
|
|
25
|
+
let v = WKWebView(frame: NSRect(x: 0, y: 0, width: 1100, height: 760), configuration: config)
|
|
26
|
+
v.setValue(false, forKey: "drawsBackground")
|
|
27
|
+
web = v
|
|
28
|
+
let w = NSWindow(contentRect: v.frame, styleMask: [.titled, .closable, .resizable, .miniaturizable], backing: .buffered, defer: false)
|
|
29
|
+
w.title = "Capture"
|
|
30
|
+
w.contentView = v
|
|
31
|
+
w.level = .normal
|
|
32
|
+
w.isReleasedWhenClosed = false
|
|
33
|
+
w.minSize = NSSize(width: 640, height: 420)
|
|
34
|
+
w.delegate = self
|
|
35
|
+
w.center()
|
|
36
|
+
w.setFrameAutosaveName("ShipkitCaptureEditor")
|
|
37
|
+
return w
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
// the recent captures tray (wiki tools/shipkit/recordings.md, The recorder): an easy place, always on after a capture,
|
|
2
|
+
// to see and reach the recent ones. A small floating panel, on every Space, draggable (it remembers where): the newest captures as thumbs, a click opens one in the
|
|
3
|
+
// hub's editor, a right click copies the file or a link or shows it in the Finder. It shows after each capture and
|
|
4
|
+
// stays until closed; the menu brings it back
|
|
5
|
+
import AppKit
|
|
6
|
+
|
|
7
|
+
struct RecentItem: Decodable {
|
|
8
|
+
var id: String
|
|
9
|
+
var name: String
|
|
10
|
+
var repo: String
|
|
11
|
+
var still: Bool
|
|
12
|
+
var seconds: Double
|
|
13
|
+
var dir: String
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@MainActor
|
|
17
|
+
final class RecentTray: NSObject {
|
|
18
|
+
static let SHOWN = "recentTrayShown"
|
|
19
|
+
static let MAX = 5
|
|
20
|
+
/** a cell's width: its poster, its name and its button bar */
|
|
21
|
+
static let W: CGFloat = 140
|
|
22
|
+
var panel: NSPanel?
|
|
23
|
+
var items: [RecentItem] = []
|
|
24
|
+
var home: String?
|
|
25
|
+
var sk: (([String]) async -> (out: String, err: String, code: Int32))?
|
|
26
|
+
var onChange: (() -> Void)?
|
|
27
|
+
/** the captures whose upload and links still run: their cell spins */
|
|
28
|
+
var pending = Set<String>()
|
|
29
|
+
/** a capture opened in the recorder's editor window */
|
|
30
|
+
var onEdit: ((String, String) -> Void)?
|
|
31
|
+
|
|
32
|
+
var shown: Bool { panel?.isVisible == true }
|
|
33
|
+
|
|
34
|
+
/** the newest captures read again; the tray shown when `show`, or kept as it was */
|
|
35
|
+
func refresh(show: Bool) async {
|
|
36
|
+
guard let sk else { return }
|
|
37
|
+
let r = await sk(["rec", "--json"])
|
|
38
|
+
items = r.out.split(separator: "\n").prefix(RecentTray.MAX).compactMap { try? JSONDecoder().decode(RecentItem.self, from: Data($0.utf8)) }
|
|
39
|
+
if show || shown { open() }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
func open() {
|
|
43
|
+
let p = panel ?? makePanel()
|
|
44
|
+
panel = p
|
|
45
|
+
p.contentView = content()
|
|
46
|
+
p.setContentSize(p.contentView!.fittingSize)
|
|
47
|
+
if !p.isVisible && p.frameAutosaveName.isEmpty == false && !p.setFrameUsingName(p.frameAutosaveName) { place(p) }
|
|
48
|
+
p.orderFrontRegardless()
|
|
49
|
+
UserDefaults.standard.set(true, forKey: RecentTray.SHOWN)
|
|
50
|
+
onChange?()
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** the open tray drawn to a png, title bar included, on its dark ground: a layout's proof, no screen grant needed */
|
|
54
|
+
func snapshot(to: URL) throws {
|
|
55
|
+
guard let p = panel, p.isVisible, let v = p.contentView?.superview ?? p.contentView else { throw Err("the tray is not open") }
|
|
56
|
+
guard let rep = v.bitmapImageRepForCachingDisplay(in: v.bounds) else { throw Err("the tray drew nothing") }
|
|
57
|
+
v.cacheDisplay(in: v.bounds, to: rep)
|
|
58
|
+
let img = NSImage(size: v.bounds.size)
|
|
59
|
+
img.lockFocus()
|
|
60
|
+
NSColor(white: 0.16, alpha: 1).setFill()
|
|
61
|
+
NSRect(origin: .zero, size: v.bounds.size).fill()
|
|
62
|
+
rep.draw(in: NSRect(origin: .zero, size: v.bounds.size))
|
|
63
|
+
img.unlockFocus()
|
|
64
|
+
guard let tiff = img.tiffRepresentation, let png = NSBitmapImageRep(data: tiff)?.representation(using: .png, properties: [:]) else { throw Err("the tray drew nothing") }
|
|
65
|
+
try png.write(to: to)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
func close() {
|
|
69
|
+
panel?.orderOut(nil)
|
|
70
|
+
UserDefaults.standard.set(false, forKey: RecentTray.SHOWN)
|
|
71
|
+
onChange?()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
private func place(_ p: NSPanel) {
|
|
75
|
+
let v = (NSScreen.main ?? NSScreen.screens[0]).visibleFrame
|
|
76
|
+
p.setFrameOrigin(NSPoint(x: v.maxX - p.frame.width - 16, y: v.minY + 16))
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private func makePanel() -> NSPanel {
|
|
80
|
+
let p = NSPanel(contentRect: NSRect(x: 0, y: 0, width: 300, height: 120), styleMask: [.nonactivatingPanel, .titled, .closable, .utilityWindow, .hudWindow], backing: .buffered, defer: false)
|
|
81
|
+
p.title = "Recent captures"
|
|
82
|
+
p.level = .floating
|
|
83
|
+
p.isFloatingPanel = true
|
|
84
|
+
p.hidesOnDeactivate = false
|
|
85
|
+
p.isMovableByWindowBackground = true
|
|
86
|
+
p.isReleasedWhenClosed = false
|
|
87
|
+
p.collectionBehavior = [.canJoinAllSpaces, .fullScreenAuxiliary]
|
|
88
|
+
p.setFrameAutosaveName("ShipkitRecentTray")
|
|
89
|
+
p.delegate = self
|
|
90
|
+
place(p)
|
|
91
|
+
return p
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
private func content() -> NSView {
|
|
95
|
+
let row = NSStackView()
|
|
96
|
+
row.orientation = .horizontal
|
|
97
|
+
row.spacing = 8
|
|
98
|
+
row.edgeInsets = NSEdgeInsets(top: 8, left: 8, bottom: 8, right: 8)
|
|
99
|
+
if items.isEmpty {
|
|
100
|
+
row.addArrangedSubview(NSTextField(labelWithString: "no capture yet: a hotkey of the menu takes one"))
|
|
101
|
+
}
|
|
102
|
+
for (i, it) in items.enumerated() { row.addArrangedSubview(cell(it, i)) }
|
|
103
|
+
let all = NSButton(title: "All…", target: self, action: #selector(RecentTray.openAll))
|
|
104
|
+
all.bezelStyle = .rounded
|
|
105
|
+
all.controlSize = .small
|
|
106
|
+
// what a new capture puts on the clipboard, changed here as in the menu
|
|
107
|
+
let pick = NSPopUpButton(frame: .zero, pullsDown: false)
|
|
108
|
+
pick.controlSize = .small
|
|
109
|
+
pick.font = NSFont.systemFont(ofSize: 11)
|
|
110
|
+
for f in ClipFormat.allCases {
|
|
111
|
+
pick.addItem(withTitle: f.label)
|
|
112
|
+
pick.lastItem?.representedObject = f.rawValue
|
|
113
|
+
}
|
|
114
|
+
pick.selectItem(at: ClipFormat.allCases.firstIndex(of: ClipFormat.current) ?? 0)
|
|
115
|
+
pick.target = self
|
|
116
|
+
pick.action = #selector(RecentTray.formatPicked(_:))
|
|
117
|
+
pick.toolTip = "A new screenshot goes on the clipboard as this"
|
|
118
|
+
let label = NSTextField(labelWithString: "New captures copy as")
|
|
119
|
+
label.font = NSFont.systemFont(ofSize: 10)
|
|
120
|
+
label.textColor = .secondaryLabelColor
|
|
121
|
+
let side = NSStackView(views: [label, pick, all])
|
|
122
|
+
side.orientation = .vertical
|
|
123
|
+
side.alignment = .centerX
|
|
124
|
+
side.spacing = 6
|
|
125
|
+
row.addArrangedSubview(side)
|
|
126
|
+
return row
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/** one capture: its poster (a click opens it), its name on one line, and under it Finder, copy file, copy link */
|
|
130
|
+
private func cell(_ it: RecentItem, _ i: Int) -> NSView {
|
|
131
|
+
let thumb = NSButton(frame: NSRect(x: 0, y: 0, width: RecentTray.W, height: RecentTray.W * 9 / 16))
|
|
132
|
+
thumb.isBordered = false
|
|
133
|
+
thumb.imagePosition = .imageOnly
|
|
134
|
+
thumb.imageScaling = .scaleProportionallyUpOrDown
|
|
135
|
+
thumb.image = NSImage(contentsOfFile: "\(it.dir)/poster.webp")
|
|
136
|
+
thumb.tag = i
|
|
137
|
+
thumb.target = self
|
|
138
|
+
thumb.action = #selector(RecentTray.openItem(_:))
|
|
139
|
+
thumb.toolTip = "\(it.repo)/\(it.name): click to edit"
|
|
140
|
+
thumb.widthAnchor.constraint(equalToConstant: RecentTray.W).isActive = true
|
|
141
|
+
thumb.heightAnchor.constraint(equalToConstant: RecentTray.W * 9 / 16).isActive = true
|
|
142
|
+
let menu = NSMenu()
|
|
143
|
+
let copies: [(String, Selector)] = it.still ? [("Copy as PNG", #selector(RecentTray.copyPng(_:))), ("Copy as WebP HQ", #selector(RecentTray.copyWebp(_:)))] : [("Copy the file", #selector(RecentTray.copyFile(_:)))]
|
|
144
|
+
for (title, sel) in [("Open in the editor", #selector(RecentTray.openItem(_:)))] + copies + [("Copy a link", #selector(RecentTray.copyLink(_:))), ("Show in Finder", #selector(RecentTray.reveal(_:)))] {
|
|
145
|
+
let mi = NSMenuItem(title: title, action: sel, keyEquivalent: "")
|
|
146
|
+
mi.target = self
|
|
147
|
+
mi.tag = i
|
|
148
|
+
menu.addItem(mi)
|
|
149
|
+
}
|
|
150
|
+
thumb.menu = menu
|
|
151
|
+
let len = it.still ? "still" : String(format: "%d:%02d", Int(it.seconds) / 60, Int(it.seconds) % 60)
|
|
152
|
+
let name = NSTextField(labelWithString: "\(it.name) · \(len)")
|
|
153
|
+
name.font = NSFont.systemFont(ofSize: 10)
|
|
154
|
+
name.textColor = .secondaryLabelColor
|
|
155
|
+
name.lineBreakMode = .byTruncatingMiddle
|
|
156
|
+
name.alignment = .center
|
|
157
|
+
name.widthAnchor.constraint(equalToConstant: RecentTray.W).isActive = true
|
|
158
|
+
// a still copies as either format, whatever the menu's choice for a new capture; a video copies its file
|
|
159
|
+
let copy: [NSButton] = it.still
|
|
160
|
+
? [labeled("PNG", "Copy as PNG: a paste attaches the file, or pastes the image", #selector(RecentTray.copyPng(_:)), i, .systemBlue),
|
|
161
|
+
labeled("WebP", "Copy as WebP HQ (high quality): about a tenth of the PNG", #selector(RecentTray.copyWebp(_:)), i, .systemGreen)]
|
|
162
|
+
: [action("doc.on.doc", "Copy the file: a paste attaches it", #selector(RecentTray.copyFile(_:)), i, .systemBlue)]
|
|
163
|
+
let acts = NSStackView(views: [action("folder", "Show in Finder", #selector(RecentTray.reveal(_:)), i, .systemGray)] + copy + [action("link", "Copy a link: it plays in a browser for 7 days", #selector(RecentTray.copyLink(_:)), i, .systemPurple)])
|
|
164
|
+
acts.spacing = 1
|
|
165
|
+
acts.distribution = .fill
|
|
166
|
+
var rows: [NSView] = [thumb, name, acts]
|
|
167
|
+
if pending.contains(it.id) {
|
|
168
|
+
let spin = NSProgressIndicator()
|
|
169
|
+
spin.style = .spinning
|
|
170
|
+
spin.controlSize = .small
|
|
171
|
+
spin.startAnimation(nil)
|
|
172
|
+
let up = NSTextField(labelWithString: "uploading…")
|
|
173
|
+
up.font = NSFont.systemFont(ofSize: 10)
|
|
174
|
+
up.textColor = .secondaryLabelColor
|
|
175
|
+
let row = NSStackView(views: [spin, up])
|
|
176
|
+
row.spacing = 4
|
|
177
|
+
rows.insert(row, at: 2)
|
|
178
|
+
}
|
|
179
|
+
let col = NSStackView(views: rows)
|
|
180
|
+
col.orientation = .vertical
|
|
181
|
+
col.spacing = 4
|
|
182
|
+
return col
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** one button of a cell's bar: small, its own colour, so the four read apart with no gap between them */
|
|
186
|
+
private func tinted(_ b: NSButton, _ color: NSColor, _ width: CGFloat, _ tip: String, _ i: Int) -> NSButton {
|
|
187
|
+
// drawn by its own layer: the panel never takes focus, and a bezel colour shows only in a focused window
|
|
188
|
+
b.isBordered = false
|
|
189
|
+
b.wantsLayer = true
|
|
190
|
+
b.layer?.backgroundColor = color.withAlphaComponent(0.85).cgColor
|
|
191
|
+
b.layer?.cornerRadius = 4
|
|
192
|
+
b.contentTintColor = .white
|
|
193
|
+
b.heightAnchor.constraint(equalToConstant: 18).isActive = true
|
|
194
|
+
b.tag = i
|
|
195
|
+
b.toolTip = tip
|
|
196
|
+
b.widthAnchor.constraint(equalToConstant: width).isActive = true
|
|
197
|
+
return b
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private func action(_ symbol: String, _ tip: String, _ sel: Selector, _ i: Int, _ color: NSColor) -> NSButton {
|
|
201
|
+
let img = NSImage(systemSymbolName: symbol, accessibilityDescription: tip)!.withSymbolConfiguration(.init(pointSize: 9, weight: .semibold))!
|
|
202
|
+
return tinted(NSButton(image: img, target: self, action: sel), color, 26, tip, i)
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private func labeled(_ title: String, _ tip: String, _ sel: Selector, _ i: Int, _ color: NSColor) -> NSButton {
|
|
206
|
+
let b = NSButton(title: title, target: self, action: sel)
|
|
207
|
+
b.font = NSFont.systemFont(ofSize: 9, weight: .semibold)
|
|
208
|
+
b.attributedTitle = NSAttributedString(string: title, attributes: [.foregroundColor: NSColor.white, .font: b.font!])
|
|
209
|
+
return tinted(b, color, 36, tip, i)
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
/** a button says it is done: a checkmark for a second, then its own picture again */
|
|
213
|
+
private func done(_ s: Any, ok: Bool) {
|
|
214
|
+
guard let b = s as? NSButton else { return }
|
|
215
|
+
let (was, title) = (b.image, b.attributedTitle)
|
|
216
|
+
if was == nil { b.title = "" }
|
|
217
|
+
b.image = NSImage(systemSymbolName: ok ? "checkmark" : "exclamationmark.triangle", accessibilityDescription: ok ? "done" : "failed")
|
|
218
|
+
b.contentTintColor = ok ? .white : .systemYellow
|
|
219
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 1.2) {
|
|
220
|
+
b.image = was
|
|
221
|
+
b.attributedTitle = title
|
|
222
|
+
b.contentTintColor = .white
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
private func item(_ s: Any) -> RecentItem? {
|
|
227
|
+
let tag = (s as? NSButton)?.tag ?? (s as? NSMenuItem)?.tag ?? -1
|
|
228
|
+
return items.indices.contains(tag) ? items[tag] : nil
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
private func ref(_ it: RecentItem) -> String { "\(it.repo)/\(it.id)" }
|
|
232
|
+
|
|
233
|
+
@objc func openItem(_ s: Any) {
|
|
234
|
+
guard let it = item(s) else { return }
|
|
235
|
+
onEdit?(it.repo, it.id)
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
@objc func formatPicked(_ p: NSPopUpButton) {
|
|
239
|
+
if let r = p.selectedItem?.representedObject as? String, let f = ClipFormat(rawValue: r) { ClipFormat.current = f }
|
|
240
|
+
onChange?()
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
@objc func openAll() {
|
|
244
|
+
guard let h = home, let u = URL(string: "\(h)/recordings") else { return }
|
|
245
|
+
NSWorkspace.shared.open(u)
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
@objc func copyPng(_ s: Any) { copyStill(s, .png) }
|
|
249
|
+
@objc func copyWebp(_ s: Any) { copyStill(s, .webpHigh) }
|
|
250
|
+
|
|
251
|
+
/** a still on the clipboard in `format`, as a capture puts it; one the disk no longer holds comes back through sk first */
|
|
252
|
+
private func copyStill(_ s: Any, _ format: ClipFormat) {
|
|
253
|
+
guard let it = item(s) else { return }
|
|
254
|
+
Task {
|
|
255
|
+
var f = ["out.png", "raw.png"].map { "\(it.dir)/\($0)" }.first { FileManager.default.fileExists(atPath: $0) }
|
|
256
|
+
if f == nil {
|
|
257
|
+
_ = await sk?(["rec", "copy", ref(it)])
|
|
258
|
+
f = ["out.png", "raw.png"].map { "\(it.dir)/\($0)" }.first { FileManager.default.fileExists(atPath: $0) }
|
|
259
|
+
}
|
|
260
|
+
guard let f else { done(s, ok: false); return }
|
|
261
|
+
let ok = (try? Clip.put(ClipJob(pngFile: URL(fileURLWithPath: f), format: format))) != nil
|
|
262
|
+
done(s, ok: ok)
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
@objc func copyFile(_ s: Any) {
|
|
267
|
+
guard let it = item(s) else { return }
|
|
268
|
+
Task {
|
|
269
|
+
let r = await sk?(["rec", "copy", ref(it)])
|
|
270
|
+
done(s, ok: r?.code == 0)
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
@objc func copyLink(_ s: Any) {
|
|
275
|
+
guard let it = item(s) else { return }
|
|
276
|
+
Task {
|
|
277
|
+
let r = await sk?(["rec", "link", ref(it), "--copy"])
|
|
278
|
+
done(s, ok: r?.code == 0)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
@objc func reveal(_ s: Any) {
|
|
283
|
+
guard let it = item(s) else { return }
|
|
284
|
+
// the file that plays, picked in its folder
|
|
285
|
+
let file = ["out.mp4", "out.png", "raw.mp4", "raw.png"].map { "\(it.dir)/\($0)" }.first { FileManager.default.fileExists(atPath: $0) }
|
|
286
|
+
NSWorkspace.shared.activateFileViewerSelecting([URL(fileURLWithPath: file ?? it.dir)])
|
|
287
|
+
done(s, ok: true)
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
extension RecentTray: NSWindowDelegate {
|
|
292
|
+
nonisolated func windowWillClose(_ notification: Notification) {
|
|
293
|
+
MainActor.assumeIsolated {
|
|
294
|
+
UserDefaults.standard.set(false, forKey: RecentTray.SHOWN)
|
|
295
|
+
onChange?()
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|