Skip to content

armgit / cra

Public Imported from GitHub
0

The open-source Arc replacement for macOS. Spaces, pinned tabs, split view, Little Windows and Arc's shortcuts on Chromium, with your Arc sidebar imported in one go.

Release clips: tools, skill and a tag-push check

Victor4444441afbf6
diff --git a/.claude/settings.json b/.claude/settings.json
new file mode 100644
index 0000000..a178ca6
--- /dev/null
+++ b/.claude/settings.json
@@ -0,0 +1,17 @@
+{
+ "hooks": {
+ "PreToolUse": [
+ {
+ "matcher": "Bash",
+ "hooks": [
+ {
+ "type": "command",
+ "command": "\"$CLAUDE_PROJECT_DIR\"/scripts/clips/check-release-media.sh",
+ "timeout": 30,
+ "statusMessage": "Checking the release notes have clips"
+ }
+ ]
+ }
+ ]
+ }
+}
diff --git a/.claude/skills/release-clips/SKILL.md b/.claude/skills/release-clips/SKILL.md
new file mode 100644
index 0000000..33ae4ae
--- /dev/null
+++ b/.claude/skills/release-clips/SKILL.md
@@ -0,0 +1,60 @@
+---
+name: release-clips
+description: Record and attach short clips (or stills) of Cra's UI to the release notes on crabrowser.app. Use whenever a release, or an entry in cra-website's releases.ts, includes a UI change, animation, hover effect or drag interaction, before tagging the release, or when the release-tag hook blocks a push for missing clips.
+---
+
+# Release clips
+
+Every release that changes something you can see gets a clip on its highlight in
+`../cra-website/src/content/releases.ts`, shown on crabrowser.app/release-notes. A PreToolUse
+hook (`scripts/clips/check-release-media.sh`) blocks pushing a `v*` tag when `Sources/Cra/UI`
+changed since the previous tag and the entry has no `media:`. If a UI change has nothing to
+film, put `// no clip: <reason>` in the entry instead.
+
+## Rules
+
+- Record the real app, never the website's mockups or the launch reels.
+- Use the demo profile (`scripts/clips/seed-demo.py`), never Victor's own tabs.
+- Record at 120 fps and encode with `FPS=120`. Move the pointer with `glide` (eased, 240 Hz),
+ never `cliclick m:`/`dm:`, which jump and look laggy. Victor wants clips as smooth as possible.
+- Recording takes over the real pointer and keyboard. Ask Victor before taking the screen, and
+ ask peer sessions (ListAgents + SendMessage) to pause their input; tell them when you're done.
+- Show Victor one clip before making a batch, and preview the page before pushing the website.
+
+## Steps
+
+1. Build the release first (the clip copy is made from `/Applications/Cra.app`, so install the
+ new release there, or delete `build/clips/CraClip.app` to rebuild it from a newer copy).
+2. Drive and record:
+
+ ```sh
+ source scripts/clips/clip.sh
+ reset # demo profile; WX WY = window origin (1100x700 pt)
+ guard && rec dock 6 && glide w:300 m:$((WX+113)),$((WY+676)),800 w:450 d w:350 \
+ m:$((WX+186)),$((WY+676)),1400 w:350 u; waitrec
+ clip_quit
+ ```
+
+ - `cmd "cra://action/<id>"` runs any action (ids in Sources/Cra/App/KeyBindings.swift).
+ - Plain keys: `key 36` (Return), `key 125`/`126` (arrows), `key 53` (Esc), typing with
+ `cliclick -w 200 t:w t:e t:b`. ⌘ shortcuts: `cliclick kd:cmd t:t ku:cmd`.
+ - Sidebar landmarks at the seeded size: space dock y = WY+676 (cells at WX+78/113/146/180),
+ Library button WX+25, Studio header (WX+62, WY+172), tab rows from WY+418 down.
+ - Check takes with `ffmpeg -i $R/x.mov -vf "fps=2,scale=440:-1,tile=5x4" -frames:v 1 t.png`.
+3. Encode from the website repo, then paste the printed `media` entry into the highlight and
+ write its `alt`:
+
+ ```sh
+ cd ../cra-website
+ FPS=120 scripts/release-clip.sh 0.1.14 reorder-spaces "$R/dock.mov" 0.9 5.9
+ # CROP=w:h:x:y crops (recording pixels); DENSITY=1.5 for small sidebar crops
+ ```
+4. Preview with `next dev` (`/release-notes`), check the clip plays, then commit the website.
+
+## Gotchas
+
+- A CGEvent key-up that carries ⌘ leaves ⌘ latched (letters turn into shortcuts; a ⌘P once
+ opened an invisible Print sheet that ate every key until relaunch). `waitrec` releases
+ all modifiers.
+- Reset before every take: a drag or a closed pane changes the profile.
+- Cra redraws some drags at ~15 fps; that's the app, not the recording.
diff --git a/docs/release.md b/docs/release.md
index 3dcc2f2..f858df1 100644
--- a/docs/release.md
+++ b/docs/release.md
@@ -59,6 +59,27 @@ git tag v0.1.0
git push origin v0.1.0
```
+### Clips in the release notes
+
+When a release changes something you can see (UI, animations, dragging), give its
+highlight a short clip. `scripts/clips/` records one from a test copy of Cra (CraClip, own
+data folder, the website's demo profile) at 120 fps with a pointer that glides like a hand;
+the `release-clips` skill in `.claude/skills/` has the steps. Then encode it from the
+website repo:
+
+```sh
+FPS=120 scripts/release-clip.sh 0.1.14 reorder-spaces ../cra/build/clips/rec/dock.mov 0.9 5.9
+```
+
+It writes `public/releases/<version>/<name>.mp4` (H.264, silent, ≤1520 px) and a poster
+`.jpg`, and prints a `media: {…}` entry to paste into that highlight in `releases.ts` (fill
+in `alt`). A `.png` works too, for still changes. The release notes page loops clips muted
+while they're on screen. Keep them under ~8 s and ~2 MB.
+
+A Claude Code hook (`.claude/settings.json` → `scripts/clips/check-release-media.sh`) blocks
+pushing a `v*` tag when `Sources/Cra/UI` changed since the previous tag and the release's
+entry has no `media`. If there is nothing to film, add `// no clip: <reason>` to the entry.
+
Artifacts land on the GitHub release: `Cra.dmg`, `Cra.zip`, `SHA256SUMS.txt`. The names
carry no version so `releases/latest/download/Cra.dmg` always resolves; the website's
download button and `scripts/install.sh` rely on that.
diff --git a/scripts/clips/check-release-media.sh b/scripts/clips/check-release-media.sh
new file mode 100755
index 0000000..c60802f
--- /dev/null
+++ b/scripts/clips/check-release-media.sh
@@ -0,0 +1,48 @@
+#!/usr/bin/env bash
+# Claude Code PreToolUse hook (Bash): before a release tag is pushed, checks that a release
+# which changes the UI shows it in the release notes. Blocks (exit 2) when Sources/Cra/UI
+# changed since the previous tag and the version's entry in cra-website's releases.ts has no
+# `media:` clip. A release whose UI changes have nothing to film opts out with a comment in
+# its entry: `// no clip: <reason>`.
+set -euo pipefail
+
+command="$(jq -r '.tool_input.command // empty')"
+# Only an actual `git push` (at the start of a command, maybe after VAR=… prefixes),
+# not text that mentions one.
+grep -qE '(^|[;&|(]|\$\()[[:space:]]*([A-Za-z_][A-Za-z0-9_]*=("[^"]*"|[^[:space:]]+)[[:space:]]+)*git[[:space:]]+push\b' <<<"$command" || exit 0
+version="$(grep -oE '\bv[0-9]+\.[0-9]+\.[0-9]+\b' <<<"$command" | head -1)" || exit 0
+[[ -n "$version" ]] || exit 0
+
+repo="$(cd "$(dirname "$0")/../.." && pwd)"
+releases="${CRA_WEBSITE:-$repo/../cra-website}/src/content/releases.ts"
+[[ -f "$releases" ]] || exit 0
+
+# The tag right below this version, and the tag itself if it exists yet (else HEAD).
+previous="$(git -C "$repo" tag -l 'v*' | { cat; echo "$version"; } | sort -uV | grep -B1 -x "$version" | head -1)"
+[[ -n "$previous" && "$previous" != "$version" ]] || exit 0
+target="$version"; git -C "$repo" rev-parse -q --verify "refs/tags/$version" >/dev/null || target=HEAD
+ui_changes="$(git -C "$repo" diff --name-only "$previous" "$target" -- Sources/Cra/UI)"
+[[ -n "$ui_changes" ]] || exit 0
+
+entry="$(awk -v v="${version#v}" '
+ /^ version: "/ { inside = index($0, "\"" v "\"") > 0 }
+ inside' "$releases")"
+
+if [[ -z "$entry" ]]; then
+ echo "Release $version has no entry in $releases yet. Add its release notes first (see docs/release.md)." >&2
+ exit 2
+fi
+if grep -qE 'media: \{|// no clip:' <<<"$entry"; then
+ exit 0
+fi
+
+cat >&2 <<EOF
+Release $version changes the UI since $previous but its release notes have no clip:
+$(sed 's/^/ /' <<<"$ui_changes" | head -15)
+
+Record the visible change and attach it as \`media\` on the highlight in
+$releases
+(skill: release-clips; tools in scripts/clips/, encoder in cra-website/scripts/release-clip.sh).
+If there is nothing to film, add \`// no clip: <reason>\` inside the $version entry.
+EOF
+exit 2
diff --git a/scripts/clips/clip.sh b/scripts/clips/clip.sh
new file mode 100644
index 0000000..98b1120
--- /dev/null
+++ b/scripts/clips/clip.sh
@@ -0,0 +1,82 @@
+# Helpers for recording release-note clips from a test copy of Cra. Source it:
+#
+# source scripts/clips/clip.sh # builds the tools and CraClip.app on first use
+# reset # fresh demo profile, relaunch CraClip, sets WX WY WW WH
+# guard && rec reorder 6 && glide w:300 m:$((WX+113)),$((WY+676)),800 d m:...,1400 u; waitrec
+#
+# Then encode with cra-website's scripts/release-clip.sh (FPS=120 for these recordings).
+# CraClip is a renamed copy of /Applications/Cra.app (bundle id dk.kildahl.cra.clip) with its
+# own CRA_DATA_DIR, so it never touches the real Cra; drive it with CRA_COMMAND_FILE lines
+# (`cmd`), plain keys (`key`), ⌘ shortcuts via cliclick, and the pointer via `glide`.
+# Everything here moves the real pointer and keyboard: only run it when Victor has handed
+# over the screen, and ask other sessions (ListAgents + SendMessage) to pause their input.
+
+CLIPS_SRC="$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" && pwd)"
+CLIPS="${CLIPS:-$CLIPS_SRC/../../build/clips}"
+mkdir -p "$CLIPS/bin" "$CLIPS/rec"
+R="$CLIPS/rec"
+
+for tool in record glide key keys-up; do
+ [[ "$CLIPS/bin/$tool" -nt "$CLIPS_SRC/$tool.swift" ]] || swiftc -O "$CLIPS_SRC/$tool.swift" -o "$CLIPS/bin/$tool" || return 1
+done
+
+APP="$CLIPS/CraClip.app"
+if [[ ! -d "$APP" ]]; then
+ ditto /Applications/Cra.app "$APP"
+ (
+ cd "$APP/Contents" && mv MacOS/Cra MacOS/CraClip
+ /usr/libexec/PlistBuddy -c "Set :CFBundleExecutable CraClip" -c "Set :CFBundleIdentifier dk.kildahl.cra.clip" -c "Set :CFBundleName CraClip" Info.plist
+ /usr/libexec/PlistBuddy -c "Delete :CFBundleURLTypes" Info.plist 2>/dev/null
+ cd Frameworks
+ for h in "Cra Helper"*.app; do
+ n="${h/Cra Helper/CraClip Helper}" && mv "$h" "$n"
+ mv "$n/Contents/MacOS/${h%.app}" "$n/Contents/MacOS/${n%.app}"
+ id=$(/usr/libexec/PlistBuddy -c "Print :CFBundleIdentifier" "$n/Contents/Info.plist")
+ /usr/libexec/PlistBuddy -c "Set :CFBundleExecutable ${n%.app}" -c "Set :CFBundleName ${n%.app}" \
+ -c "Set :CFBundleIdentifier ${id/dk.kildahl.cra/dk.kildahl.cra.clip}" "$n/Contents/Info.plist"
+ done
+ )
+ codesign --force --deep -s - "$APP" >/dev/null 2>&1
+ defaults write dk.kildahl.cra.clip SUEnableAutomaticChecks -bool NO
+fi
+
+nap() { perl -e "select(undef,undef,undef,$1)"; }
+cmd() { for c in "$@"; do echo "$c" >> "$CLIPS/commands.txt"; done; }
+glide() { "$CLIPS/bin/glide" "$@"; }
+key() { "$CLIPS/bin/key" "$@"; }
+keys_up() { "$CLIPS/bin/keys-up"; }
+clip_pid() { pgrep -f "CraClip.app/Contents/MacOS/CraClip$"; }
+idle() { ioreg -c IOHIDSystem | awk '/HIDIdleTime/ {print int($NF/1000000000); exit}'; }
+isfront() { [[ "$(osascript -e 'tell application "System Events" to unix id of first process whose frontmost is true')" == "$PID" ]]; }
+
+# Quits CraClip, writes a fresh demo profile and relaunches it; waits $1 s (default 3) for pages.
+reset() {
+ osascript -e 'tell application id "dk.kildahl.cra.clip" to quit' >/dev/null 2>&1
+ for _ in $(seq 1 15); do clip_pid >/dev/null || break; nap 0.5; done
+ rm -rf "$CLIPS/data"
+ python3 "$CLIPS_SRC/seed-demo.py" "$CLIPS/data" "{{540, 60}, {1100, 700}}" >/dev/null
+ : > "$CLIPS/commands.txt"
+ (CRA_DATA_DIR="$CLIPS/data" CRA_COMMAND_FILE="$CLIPS/commands.txt" "$APP/Contents/MacOS/CraClip" > "$CLIPS/craclip.log" 2>&1 &)
+ nap 5
+ PID=$(clip_pid)
+ read -r WX WY WW WH < <(osascript -e "tell application \"System Events\" to tell (first process whose unix id is $PID)
+ set {x, y} to position of window 1
+ set {w, h} to size of window 1
+ return (x as text) & \" \" & (y as text) & \" \" & (w as text) & \" \" & (h as text)
+ end tell")
+ nap "${1:-3}"
+}
+
+# Makes CraClip's main window key and checks it is frontmost before sending input.
+guard() { cmd "cra://action/stop"; nap 0.6; isfront || { echo "CraClip is not frontmost" >&2; return 1; }; }
+
+# rec <name> <seconds> [x,y,w,h]: records in the background; follow with waitrec.
+rec() {
+ "$CLIPS/bin/record" "$PID" "$2" "$R/$1.mov" ${3:-} > "$R/$1.log" 2>&1 & RECPID=$!
+ ( perl -e "sleep($2+6)"; kill $RECPID 2>/dev/null ) &
+ nap 0.8
+}
+waitrec() { wait $RECPID; keys_up; }
+
+# Quit CraClip when done; it can come to the front on Victor's screen.
+clip_quit() { osascript -e 'tell application id "dk.kildahl.cra.clip" to quit' >/dev/null 2>&1; }
diff --git a/scripts/clips/glide.swift b/scripts/clips/glide.swift
new file mode 100644
index 0000000..950efe3
--- /dev/null
+++ b/scripts/clips/glide.swift
@@ -0,0 +1,48 @@
+// glide <step> ...: hand-like pointer moves posted to the HID tap at 240 Hz.
+// m:x,y,ms glide to x,y over ms (eased; drags if the button is down)
+// j:x,y jump to x,y
+// d / u button down / up at the current point
+// w:ms wait
+import CoreGraphics
+import Foundation
+
+let src = CGEventSource(stateID: .hidSystemState)
+var pos = CGEvent(source: nil)!.location
+var down = false
+
+func post(_ type: CGEventType, _ p: CGPoint) {
+ let e = CGEvent(mouseEventSource: src, mouseType: type, mouseCursorPosition: p, mouseButton: .left)!
+ e.post(tap: .cghidEventTap)
+}
+func ease(_ t: Double) -> Double { t < 0.5 ? 4 * t * t * t : 1 - pow(-2 * t + 2, 3) / 2 }
+
+for arg in CommandLine.arguments.dropFirst() {
+ let parts = arg.split(separator: ":", maxSplits: 1).map(String.init)
+ let n = parts.count > 1 ? parts[1].split(separator: ",").map { Double($0)! } : []
+ switch parts[0] {
+ case "m":
+ let from = pos, to = CGPoint(x: n[0], y: n[1])
+ let steps = max(1, Int(n[2] / 1000 * 240))
+ // A slight arc, like a wrist, perpendicular to the path.
+ let dx = to.x - from.x, dy = to.y - from.y, len = max(1, hypot(dx, dy))
+ let bow = min(18, len * 0.06)
+ for i in 1...steps {
+ let t = ease(Double(i) / Double(steps))
+ let arc = sin(Double.pi * t) * bow
+ pos = CGPoint(x: from.x + dx * t - dy / len * arc, y: from.y + dy * t + dx / len * arc)
+ post(down ? .leftMouseDragged : .mouseMoved, pos)
+ usleep(useconds_t(1_000_000 / 240))
+ }
+ pos = to
+ case "j":
+ pos = CGPoint(x: n[0], y: n[1]); post(down ? .leftMouseDragged : .mouseMoved, pos)
+ case "d":
+ down = true; post(.leftMouseDown, pos)
+ case "u":
+ down = false; post(.leftMouseUp, pos)
+ case "w":
+ usleep(useconds_t(n[0] * 1000))
+ default:
+ FileHandle.standardError.write("bad step \(arg)\n".data(using: .utf8)!); exit(1)
+ }
+}
diff --git a/scripts/clips/key.swift b/scripts/clips/key.swift
new file mode 100644
index 0000000..17aec6d
--- /dev/null
+++ b/scripts/clips/key.swift
@@ -0,0 +1,15 @@
+// key <code> [ctrl ...]: posts one plain key press. Send ⌘ shortcuts with
+// `cliclick kd:cmd t:x ku:cmd` instead: a key-up carrying ⌘ leaves ⌘ latched.
+import CoreGraphics
+import Foundation
+let a = CommandLine.arguments
+let code = CGKeyCode(a[1])!
+var flags: CGEventFlags = (123...126).contains(Int(code)) ? [.maskNumericPad, .maskSecondaryFn] : []
+for m in a.dropFirst(2) { switch m { case "cmd": flags.insert(.maskCommand); case "ctrl": flags.insert(.maskControl); case "shift": flags.insert(.maskShift); case "opt": flags.insert(.maskAlternate); default: break } }
+let src = CGEventSource(stateID: .privateState)
+for down in [true, false] {
+ let e = CGEvent(keyboardEventSource: src, virtualKey: code, keyDown: down)!
+ e.flags = flags
+ e.post(tap: .cghidEventTap)
+ usleep(30000)
+}
diff --git a/scripts/clips/keys-up.swift b/scripts/clips/keys-up.swift
new file mode 100644
index 0000000..74c0212
--- /dev/null
+++ b/scripts/clips/keys-up.swift
@@ -0,0 +1,5 @@
+// keys-up: releases every modifier, in case a test left one held down.
+import CoreGraphics
+let src = CGEventSource(stateID: .hidSystemState)
+for k: CGKeyCode in [55, 54, 59, 62, 56, 60, 58, 61, 63] { let e = CGEvent(keyboardEventSource: src, virtualKey: k, keyDown: false)!; e.flags = []; e.post(tap: .cghidEventTap) }
+let f = CGEvent(source: src)!; f.type = .flagsChanged; f.flags = []; f.post(tap: .cghidEventTap)
diff --git a/scripts/clips/record.swift b/scripts/clips/record.swift
new file mode 100644
index 0000000..68a8b9b
--- /dev/null
+++ b/scripts/clips/record.swift
@@ -0,0 +1,58 @@
+// record <pid> <seconds> <out.mov> [x,y,w,h]: records only that app's windows (even when
+// covered) at 120 fps. The rect is in global points; default: the app's largest window.
+import AVFoundation
+import Foundation
+import ScreenCaptureKit
+
+let a = CommandLine.arguments
+let pid = pid_t(a[1])!
+let seconds = Double(a[2])!
+let out = URL(fileURLWithPath: a[3])
+try? FileManager.default.removeItem(at: out)
+
+final class Delegate: NSObject, SCRecordingOutputDelegate, SCStreamOutput {
+ func recordingOutputDidStartRecording(_ r: SCRecordingOutput) { FileHandle.standardError.write("started\n".data(using: .utf8)!) }
+ func recordingOutput(_ r: SCRecordingOutput, didFailWithError e: Error) { print("failed", e); exit(1) }
+ func stream(_ s: SCStream, didOutputSampleBuffer b: CMSampleBuffer, of t: SCStreamOutputType) {}
+}
+
+Task {
+ let content = try await SCShareableContent.excludingDesktopWindows(false, onScreenWindowsOnly: false)
+ guard let app = content.applications.first(where: { $0.processID == pid }) else { print("no app"); exit(1) }
+ var rect: CGRect
+ if a.count > 4 {
+ let n = a[4].split(separator: ",").map { Double($0)! }
+ rect = CGRect(x: n[0], y: n[1], width: n[2], height: n[3])
+ } else {
+ let wins = content.windows.filter { $0.owningApplication?.processID == pid && $0.windowLayer == 0 }
+ guard let w = wins.max(by: { $0.frame.width * $0.frame.height < $1.frame.width * $1.frame.height }) else { print("no window"); exit(1) }
+ rect = w.frame
+ }
+ guard let display = content.displays.first(where: { $0.frame.intersects(rect) }) else { print("no display"); exit(1) }
+ let filter = SCContentFilter(display: display, including: [app], exceptingWindows: [])
+ let cfg = SCStreamConfiguration()
+ let scale = CGFloat(filter.pointPixelScale)
+ cfg.sourceRect = rect.offsetBy(dx: -display.frame.minX, dy: -display.frame.minY)
+ cfg.width = Int(rect.width * scale)
+ cfg.height = Int(rect.height * scale)
+ cfg.minimumFrameInterval = CMTime(value: 1, timescale: 120)
+ cfg.showsCursor = true
+ cfg.backgroundColor = .white
+ cfg.queueDepth = 8
+ let d = Delegate()
+ let stream = SCStream(filter: filter, configuration: cfg, delegate: nil)
+ try stream.addStreamOutput(d, type: .screen, sampleHandlerQueue: .global())
+ let rc = SCRecordingOutputConfiguration()
+ rc.outputURL = out
+ rc.outputFileType = .mov
+ rc.videoCodecType = .hevc
+ let ro = SCRecordingOutput(configuration: rc, delegate: d)
+ try stream.addRecordingOutput(ro)
+ try await stream.startCapture()
+ try await Task.sleep(nanoseconds: UInt64(seconds * 1e9))
+ try await stream.stopCapture()
+ try await Task.sleep(nanoseconds: 300_000_000)
+ print(out.path, "\(Int(rect.minX)),\(Int(rect.minY)),\(Int(rect.width)),\(Int(rect.height))", "scale", scale)
+ exit(0)
+}
+RunLoop.main.run()
diff --git a/scripts/clips/seed-demo.py b/scripts/clips/seed-demo.py
new file mode 100644
index 0000000..24f9c1f
--- /dev/null
+++ b/scripts/clips/seed-demo.py
@@ -0,0 +1,87 @@
+"""seed-demo.py <data dir> [window frame]: writes the website's demo profile
+(cra-website src/components/mockups/demo.ts) into a fresh CRA_DATA_DIR."""
+import json, os, shutil, sys, uuid
+from datetime import datetime, timezone
+
+out = sys.argv[1]
+os.makedirs(out, exist_ok=True)
+now = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
+items, spaces, order = [], [], []
+
+def U(): return str(uuid.uuid4()).upper()
+
+def item(data, parent, title=None, children=None, iid=None):
+ it = {"id": iid or U(), "parentID": parent, "children": children or [], "isUnread": False, "createdAt": now, "data": data}
+ if title: it["title"] = title
+ items.append(it)
+ return it
+
+def tab(url, title, parent):
+ host = url.split("/")[2].removeprefix("www.")
+ t = item({"tab": {"_0": {"url": url, "savedURL": url, "savedTitle": title, "muted": False, "faviconKey": host, "timeLastActiveAt": now}}}, parent, title)
+ return t["id"]
+
+def folder(title, parent, entries):
+ f = item({"folder": {}}, parent, title)
+ f["children"] = [tab(u, t, f["id"]) for u, t in entries]
+ return f["id"]
+
+def split(parent, entries):
+ s = item({"split": {"_0": {"orientation": "horizontal", "timeLastActiveAt": now}}}, parent)
+ s["children"] = [tab(u, t, s["id"]) for u, t in entries]
+ return s["id"]
+
+def space(title, emoji, theme, favs, pinned, today):
+ sid = U()
+ conts = {}
+ for kind, entries in (("favorites", favs), ("pinned", pinned), ("today", today)):
+ c = item({"container": {"_0": {kind: {"spaceID": sid}}}}, None)
+ c["children"] = [e(c["id"]) if callable(e) else tab(e[0], e[1], c["id"]) for e in entries]
+ conts[kind] = c["id"]
+ spaces.append({"id": sid, "title": title, "emoji": emoji, "theme": theme, "createdAt": now,
+ "favoritesContainerID": conts["favorites"], "pinnedContainerID": conts["pinned"], "todayContainerID": conts["today"]})
+ order.append(sid)
+
+def theme(colors, intensity, noise, appearance): return {"colors": colors, "intensity": intensity, "noise": noise, "appearance": appearance, "vibrant": False}
+
+space("Studio", "🎨", theme(["#C7CAFF", "#FFE5E5"], 0.5, 0.1, "light"),
+ [("https://github.com/", "GitHub"), ("https://www.figma.com/", "Figma"), ("https://linear.app/", "Linear"), ("https://www.notion.com/", "Notion"),
+ ("https://vercel.com/", "Vercel"), ("https://open.spotify.com/", "Spotify"), ("https://en.wikipedia.org/wiki/Main_Page", "Wikipedia"), ("https://www.apple.com/", "Apple")],
+ [("https://crabrowser.app/", "Cra — A calmer way to browse"),
+ lambda p: folder("Launch", p, [("https://github.com/VictorKildahl/cra", "VictorKildahl/cra"),
+ ("https://developer.apple.com/documentation/swiftui", "SwiftUI | Apple Developer Documentation"),
+ ("https://crabrowser.app/roadmap", "Roadmap")]),
+ ("https://news.ycombinator.com/", "Hacker News"), ("https://www.are.na/", "Are.na"),
+ lambda p: folder("Reading list", p, [("https://en.wikipedia.org/wiki/Typography", "Typography"), ("https://en.wikipedia.org/wiki/Color_theory", "Color theory")])],
+ [lambda p: split(p, [("https://en.wikipedia.org/wiki/Web_browser", "Web browser"), ("https://linear.app/changelog", "Changelog – Linear")]),
+ ("https://fonts.google.com/specimen/Instrument+Serif", "Instrument Serif – Google Fonts"), ("https://oklch.com/", "OKLCH Color Picker & Converter")])
+space("Personal", "🌱", theme(["#1C242B", "#3A3660"], 0.85, 0.18, "dark"),
+ [("https://www.youtube.com/", "YouTube"), ("https://open.spotify.com/", "Spotify"), ("https://en.wikipedia.org/wiki/Main_Page", "Wikipedia"), ("https://www.apple.com/", "Apple")],
+ [("https://github.com/trending", "Trending repositories on GitHub"), ("https://news.ycombinator.com/", "Hacker News")],
+ [("https://en.wikipedia.org/wiki/Copenhagen", "Copenhagen"), ("https://www.yr.no/en", "Yr")])
+space("Weekend", "🏕️", theme(["#0F2420", "#2F6F5E"], 0.75, 0.18, "dark"),
+ [("https://en.wikipedia.org/wiki/Main_Page", "Wikipedia"), ("https://www.apple.com/", "Apple")],
+ [("https://en.wikipedia.org/wiki/Hiking", "Hiking")],
+ [("https://en.wikipedia.org/wiki/Faroe_Islands", "Faroe Islands")])
+space("Reading", "📚", theme(["#F4F1EA", "#E6DCC8"], 0.6, 0.15, "light"),
+ [("https://www.gutenberg.org/", "Project Gutenberg")],
+ [("https://en.wikipedia.org/wiki/Arc_(web_browser)", "Arc (web browser)")],
+ [("https://en.wikipedia.org/wiki/Hypertext", "Hypertext")])
+
+json.dump({"version": 1, "spaceOrder": order, "spaces": spaces, "items": items}, open(f"{out}/sidebar.json", "w"), indent=1)
+json.dump({"hasSeenImportPrompt": True, "warnBeforeQuitting": False, "blockAdsAndTrackers": True, "toolbarDefaultMigrated": True,
+ "showToolbar": True, "showStatusBar": True}, open(f"{out}/settings.json", "w"))
+frame = sys.argv[2] if len(sys.argv) > 2 else "{{0, 0}, {1280, 800}}"
+pick = lambda t: next(i["id"] for i in items if i.get("title") == t)
+sel = [x for sid, t in zip(order, ["Cra — A calmer way to browse", "Copenhagen", "Faroe Islands", "Arc (web browser)"]) for x in (sid, pick(t))]
+launch = next(i["id"] for i in items if i.get("title") == "Launch")
+first_tab = next(i["id"] for i in items if i.get("title") == "Cra — A calmer way to browse")
+json.dump({"littleWindowSize": "{780, 520}", "sidebarWidth": 260, "expandedFolders": [launch], "collapsedPinnedSpaces": [],
+ "windows": [{"id": U(), "focusedSpaceID": order[0], "selectedTabPerSpace": sel, "frame": frame,
+ "sidebarVisible": True, "isIncognito": False}]}, open(f"{out}/windows.json", "w"))
+fav = os.path.join(out, "Favicons"); os.makedirs(fav, exist_ok=True)
+src = os.environ.get("CRA_WEBSITE", os.path.join(os.path.dirname(__file__), "../../../cra-website")) + "/public/mockups/favicons"
+for name, host in {"github": "github.com", "figma": "figma.com", "linear": "linear.app", "notion": "notion.com", "vercel": "vercel.com",
+ "spotify": "open.spotify.com", "wikipedia": "en.wikipedia.org", "apple": "apple.com", "hackernews": "news.ycombinator.com", "arena": "are.na"}.items():
+ shutil.copy(f"{src}/{name}.png", f"{fav}/{host}.png")
+print(order[0])