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.
A test layer that runs in CI: CraCore, scripts/test.sh, a launch smoke test (#44) (#62)
Victor Kildahl3074bf07ac9b
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex fff69ea..59bd8f1 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -10,6 +10,16 @@ concurrency:cancel-in-progress: truejobs:+ test:+ name: Tests+ # No Chromium download: Packages/CraCore and the harnesses compile only the files they test.+ runs-on: macos-26+ steps:+ - uses: actions/checkout@v7++ - name: CraCore and harnesses+ run: scripts/test.sh+build:name: Build Cra.app# Same runner as release.yml, so CI builds what ships.@@ -34,3 +44,10 @@ jobs:run: |codesign --verify --deep --strict --verbose=2 build/Cra.app/usr/libexec/PlistBuddy -c 'Print :CFBundleShortVersionString' build/Cra.app/Contents/Info.plist++ # Launches the app three times and quits it; fails on a crash, hang or crash report.+ # Not blocking until it has proved steady on the hosted runners.+ - name: Smoke test+ continue-on-error: true+ timeout-minutes: 5+ run: Tests/smoke-launch.sh build/Cra.appdiff --git a/CONTRIBUTING.md b/CONTRIBUTING.mdindex 9dea58f..8661a5f 100644--- a/CONTRIBUTING.md+++ b/CONTRIBUTING.md@@ -33,8 +33,10 @@ hooks and how to run a test instance next to your daily Cra.1. Fork, branch from `main`, keep the change to one thing.2. Match the code around you: naming, comments and structure. Doc comments say *why*,not what.-3. Run it. CI only checks that Cra builds and signs, so say in the PR how you tested- it, and add a screenshot or a short clip for anything visible.+3. Run it, and `scripts/test.sh`. CI builds and signs Cra, runs those tests and launches the+ app, but none of that sees the screen: say in the PR how you tested it, and add a+ screenshot or a short clip for anything visible. A fix for a bug that a test could+ have caught comes with that test ([docs/development.md](docs/development.md#tests)).4. Don't touch the release pipeline, signing or the CEF pin unless that's the point ofthe PR. Releases are cut by the maintainer.diff --git a/Package.swift b/Package.swiftindex bef8d4f..1a12d69 100644--- a/Package.swift+++ b/Package.swift@@ -33,6 +33,8 @@ let package = Package(// Cra.app/Contents/PlugIns/CraDockTile.docktileplugin..library(name: "CraDockTile", type: .dynamic, targets: ["CraDockTile"]),],+ // Models and decisions that need no AppKit or CEF, with tests that run without vendor/cef.+ dependencies: [.package(path: "Packages/CraCore")],targets: [// Objective-C++ bridge between Swift and CEF..target(@@ -69,7 +71,7 @@ let package = Package(// The browser itself: AppKit window, SwiftUI sidebar and command bar..executableTarget(name: "Cra",- dependencies: ["CraCEF"],+ dependencies: ["CraCEF", .product(name: "CraCore", package: "CraCore")],path: "Sources/Cra",swiftSettings: [.unsafeFlags(["-F", sparkleRoot]), .unsafeFlags(["-Onone"], .when(configuration: .debug))],linkerSettings: [.unsafeFlags(["-F", sparkleRoot, "-framework", "Sparkle",diff --git a/Packages/CraCore/Package.swift b/Packages/CraCore/Package.swiftnew file mode 100644index 0000000..f67a918--- /dev/null+++ b/Packages/CraCore/Package.swift@@ -0,0 +1,18 @@+// swift-tools-version:5.10+import PackageDescription++// Cra's decisions that need no window and no Chromium: models, Arc import mapping, layout+// arithmetic. A package of its own so `swift test --package-path Packages/CraCore` builds+// and runs without vendor/cef (a target in the root package would build CEF first).+let package = Package(+ name: "CraCore",+ platforms: [.macOS(.v14)],+ products: [+ .library(name: "CraCore", targets: ["CraCore"]),+ ],+ targets: [+ .target(name: "CraCore"),+ .testTarget(name: "CraCoreTests", dependencies: ["CraCore"], resources: [.copy("Fixtures")]),+ ],+ swiftLanguageVersions: [.v5]+)diff --git a/Packages/CraCore/Sources/CraCore/ArcThemeImport.swift b/Packages/CraCore/Sources/CraCore/ArcThemeImport.swiftnew file mode 100644index 0000000..bbda8a1--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/ArcThemeImport.swift@@ -0,0 +1,98 @@+import Foundation++/// An Arc space's `customInfo.windowTheme` (StorableSidebar.json) as a Cra theme.+public enum ArcThemeImport {+ /// Arc's blendedGradient → SpaceTheme. Prefers the dark variant when one exists.+ public static func theme(from space: [String: Any]) -> SpaceTheme? {+ guard let info = space["customInfo"] as? [String: Any], let wt = info["windowTheme"] as? [String: Any],+ let bg = wt["background"] as? [String: Any] else { return nil }+ var variant: [String: Any]?+ var appearance = "auto"+ if let ab = bg["appearanceBased"] as? [String: Any] {+ variant = (ab["dark"] as? [String: Any]) ?? (ab["light"] as? [String: Any])+ appearance = ab["dark"] != nil ? "dark" : "light"+ } else if let single = bg["single"] as? [String: Any] {+ variant = single["_0"] as? [String: Any]+ }+ guard let v = variant else { return nil }+ if let a = v["contentOverBackgroundAppearance"] as? String { appearance = a }+ let vibrant = v["isVibrant"] as? Bool ?? false+ func comp(_ c: [String: Any], _ k: String) -> Double { max(0, min(1, c[k] as? Double ?? 0)) }+ func hexOf(_ c: [String: Any]) -> String {+ String(format: "#%02X%02X%02X", Int((comp(c, "red") * 255).rounded()),+ Int((comp(c, "green") * 255).rounded()), Int((comp(c, "blue") * 255).rounded()))+ }+ let c0 = ((v["style"] as? [String: Any])?["color"] as? [String: Any])?["_0"] as? [String: Any]+ // A solid colour (Arc's colour picker with one dot) is `blendedSingleColor`. Themes+ // Cra can't read still carry Arc's derived palette, whose mid tone keeps the hue.+ if let s = (c0?["blendedSingleColor"] as? [String: Any])?["_0"] as? [String: Any], let c = s["color"] as? [String: Any] {+ let mods = s["modifiers"] as? [String: Any]+ return solidTheme(hexOf(c), intensity: mods?["intensityFactor"] as? Double ?? 1,+ noise: mods?["noiseFactor"] as? Double ?? 0, appearance: appearance)+ }+ guard let bg2 = c0?["blendedGradient"] as? [String: Any], let g = bg2["_0"] as? [String: Any],+ let base = g["baseColors"] as? [[String: Any]], !base.isEmpty else {+ guard let mid = (wt["primaryColorPalette"] as? [String: Any])?["midTone"] as? [String: Any] else { return nil }+ return solidTheme(hexOf(mid), intensity: 1, noise: 0, appearance: appearance)+ }+ let overlays = g["overlayColors"] as? [[String: Any]] ?? []+ // Arc blends an overlay gradient onto the base gradient and the wheel+ // mixes the two base colours; bake both into our two stops (fitted to+ // Arc's rendering: top stop leans toward the second base colour).+ func hex(_ i: Int) -> String {+ let b = base[min(i, base.count - 1)]+ let other = base[min(i == 0 ? 1 : 0, base.count - 1)]+ var r = comp(b, "red"), gg = comp(b, "green"), bl = comp(b, "blue")+ if i == 0 {+ r += (comp(other, "red") - r) * 0.1; gg += (comp(other, "green") - gg) * 0.1; bl += (comp(other, "blue") - bl) * 0.1+ }+ if i < overlays.count {+ let o = overlays[i]+ let a = comp(o, "alpha") * 0.85+ r += (comp(o, "red") - r) * a; gg += (comp(o, "green") - gg) * a; bl += (comp(o, "blue") - bl) * a+ }+ return String(format: "#%02X%02X%02X", Int((r * 255).rounded()), Int((gg * 255).rounded()), Int((bl * 255).rounded()))+ }+ var colors = [hex(0), hex(1)]+ let mods = g["modifiers"] as? [String: Any]+ var intensity = mods?["intensityFactor"] as? Double ?? 0.5+ if vibrant && appearance != "dark" {+ // Fitted to Arc over white and black backdrops: the top stop is the+ // first base colour nudged toward the second and 30% toward white;+ // the bottom stop is the base colour pulled 30% toward the overlay's+ // end colour (or the second base colour) and 20% toward white.+ // Opacity ramps 0.45 → 0.59 (see SpacePalette).+ func rgb(_ c: [String: Any]) -> (Double, Double, Double) { (comp(c, "red"), comp(c, "green"), comp(c, "blue")) }+ func mix(_ a: (Double, Double, Double), _ b: (Double, Double, Double), _ t: Double) -> (Double, Double, Double) {+ (a.0 + (b.0 - a.0) * t, a.1 + (b.1 - a.1) * t, a.2 + (b.2 - a.2) * t)+ }+ func hexOf(_ c: (Double, Double, Double)) -> String {+ String(format: "#%02X%02X%02X", Int((c.0 * 255).rounded()), Int((c.1 * 255).rounded()), Int((c.2 * 255).rounded()))+ }+ let b0 = rgb(base[0]), b1 = rgb(base[min(1, base.count - 1)])+ let end = overlays.last(where: { comp($0, "alpha") > 0 }).map(rgb) ?? b1+ let white = (1.0, 1.0, 1.0)+ colors = [hexOf(mix(mix(b0, b1, 0.15), white, 0.30)), hexOf(mix(mix(b0, end, 0.30), white, 0.20))]+ }+ let accent = String(format: "#%02X%02X%02X", Int((comp(base[0], "red") * 255).rounded()),+ Int((comp(base[0], "green") * 255).rounded()), Int((comp(base[0], "blue") * 255).rounded()))+ if appearance == "dark" && !vibrant {+ // Measured from Arc: dark themes show ~27% of the colour over a+ // slightly purple dark grey (#2B2632).+ colors = colors.map { c in+ let k = HexColor.components(c) ?? (0, 0, 0)+ func ch(_ v: Double, _ base: Double) -> Int { Int((v * 255 * 0.27 + base).rounded()) }+ return String(format: "#%02X%02X%02X", ch(k.r, 43), ch(k.g, 38), ch(k.b, 50))+ }+ intensity = 1+ }+ return SpaceTheme(colors: colors, intensity: intensity,+ noise: mods?["noiseFactor"] as? Double ?? 0.15, appearance: appearance, vibrant: vibrant, accent: accent)+ }++ /// One flat colour (SpaceTheme.solid). Arc draws it the same whether or not it is+ /// marked vibrant, so only the colour, intensity and text appearance carry over.+ private static func solidTheme(_ hex: String, intensity: Double, noise: Double, appearance: String) -> SpaceTheme {+ SpaceTheme(colors: [hex, hex], intensity: intensity, noise: noise, appearance: appearance, accent: hex, solid: true)+ }+}diff --git a/Packages/CraCore/Sources/CraCore/FavoritesLayout.swift b/Packages/CraCore/Sources/CraCore/FavoritesLayout.swiftnew file mode 100644index 0000000..0091d32--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/FavoritesLayout.swift@@ -0,0 +1,44 @@+import CoreGraphics++/// Where a space's favorite tiles go in a grid `width` points wide (the sidebar less 8 pt each side).+///+/// Arc 1.171 (AX frames, 1–9 favorites at sidebar widths 100–347, 31 Oct): at most as many+/// columns (up to four) as keep a tile at least as wide as it is tall (47 pt), then the fewest+/// that need no more rows: one favorite fills the row, five go 3 + 2, nine 3 × 3, four at+/// 200 pt 2 × 2 (#29). A short last row keeps the tile width, from the left.+public struct FavoritesLayout: Equatable {+ public static let tileHeight: CGFloat = 47+ public static let gap: CGFloat = 8++ public let count: Int+ public let width: CGFloat++ public init(count: Int, width: CGFloat) {+ self.count = count+ self.width = width+ }++ public var columns: Int {+ let widest = (1...4).last { (width - CGFloat($0 - 1) * Self.gap) / CGFloat($0) >= Self.tileHeight } ?? 1+ guard count > 0 else { return widest }+ let rows = (count + widest - 1) / widest+ return (count + rows - 1) / rows+ }++ public var rows: Int { (count + columns - 1) / columns }++ public var tileWidth: CGFloat { (width - CGFloat(columns - 1) * Self.gap) / CGFloat(columns) }++ /// The tiles' height, 0 with no favorites.+ public var gridHeight: CGFloat {+ rows == 0 ? 0 : CGFloat(rows) * Self.tileHeight + CGFloat(rows - 1) * Self.gap+ }++ public func frame(at index: Int) -> CGRect {+ let n = columns, cw = tileWidth+ let r = index / n, c = index % n+ // Arc puts each tile on a half point (84.75 → 85 at 347 pt).+ let x = (CGFloat(c) * (cw + Self.gap) * 2).rounded() / 2+ return CGRect(x: x, y: CGFloat(r) * (Self.tileHeight + Self.gap), width: cw, height: Self.tileHeight)+ }+}diff --git a/Packages/CraCore/Sources/CraCore/ObserveChanges.swift b/Packages/CraCore/Sources/CraCore/ObserveChanges.swiftnew file mode 100644index 0000000..3390815--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/ObserveChanges.swift@@ -0,0 +1,22 @@+import Observation++/// Calls `apply` with what `read` returns now, then again whenever that value changes, for as+/// long as the app runs. Observation reports a change on every write to a stored property, and+/// SidebarStore.settings is one struct: an observer of `settings.httpsOnly` fires on any settings+/// write. Unchanged values stop here, so a side effect (a Chromium preference) runs only for a+/// real change, not on every write during onboarding or at quit (#36).+@MainActor+public func observeChanges<Value: Equatable>(of read: @escaping @MainActor () -> Value,+ apply: @escaping @MainActor (Value) -> Void) {+ var last: Value?+ func track() {+ let value = withObservationTracking(read) {+ Task { @MainActor in track() }+ }+ if value != last {+ last = value+ apply(value)+ }+ }+ track()+}diff --git a/Packages/CraCore/Sources/CraCore/SpaceTheme.swift b/Packages/CraCore/Sources/CraCore/SpaceTheme.swiftnew file mode 100644index 0000000..db4f5a4--- /dev/null+++ b/Packages/CraCore/Sources/CraCore/SpaceTheme.swift@@ -0,0 +1,82 @@+import Foundation++public struct SpaceTheme: Codable, Equatable {+ /// One or two hex colors blended into a gradient (Arc: blendedGradient.baseColors).+ public var colors: [String]+ /// 0...1, how saturated the gradient is rendered (Arc: intensityFactor).+ public var intensity: Double+ /// 0...1 grain overlay (Arc: noiseFactor).+ public var noise: Double+ /// "auto" | "light" | "dark" (Arc: contentOverBackgroundAppearance).+ public var appearance: String+ /// Arc's isVibrant: the gradient is laid over the blurred desktop at+ /// `intensity` opacity instead of being painted opaque.+ public var vibrant: Bool = false+ /// The theme's raw first colour (Arc's base colour); drives the toolbar band.+ public var accent: String? = nil+ /// Arc's one-colour theme (blendedSingleColor): a flat fill laid over a dark, slightly+ /// see-through material, at `intensity` (SpacePalette.solidAlpha), not a gradient.+ public var solid: Bool = false++ public init(colors: [String], intensity: Double, noise: Double, appearance: String, vibrant: Bool = false, accent: String? = nil,+ solid: Bool = false) {+ self.colors = colors+ self.intensity = intensity+ self.noise = noise+ self.appearance = appearance+ self.vibrant = vibrant+ self.accent = accent+ self.solid = solid+ }++ public init(from decoder: Decoder) throws {+ let c = try decoder.container(keyedBy: CodingKeys.self)+ colors = try c.decodeIfPresent([String].self, forKey: .colors) ?? ["#1C242B", "#3A3660"]+ intensity = try c.decodeIfPresent(Double.self, forKey: .intensity) ?? 0.8+ noise = try c.decodeIfPresent(Double.self, forKey: .noise) ?? 0.15+ appearance = try c.decodeIfPresent(String.self, forKey: .appearance) ?? "auto"+ vibrant = try c.decodeIfPresent(Bool.self, forKey: .vibrant) ?? false+ accent = try c.decodeIfPresent(String.self, forKey: .accent)+ solid = try c.decodeIfPresent(Bool.self, forKey: .solid) ?? false+ }++ /// Dark first: colors borrowed from Victor's other projects (GhostWriter+ /// ink + brand purple, Spook's "wall" browns, Phantom's greys, moss, gold,+ /// ember), then a few lighter Arc-style gradients.+ public static let presets: [SpaceTheme] = [+ SpaceTheme(colors: ["#1C242B", "#3A3660"], intensity: 0.85, noise: 0.18, appearance: "dark"), // Ink+ SpaceTheme(colors: ["#1C1712", "#2E2620"], intensity: 0.9, noise: 0.22, appearance: "dark"), // Wall+ SpaceTheme(colors: ["#181818", "#262626"], intensity: 0.9, noise: 0.12, appearance: "dark"), // Phantom+ SpaceTheme(colors: ["#0F2420", "#2F6F5E"], intensity: 0.75, noise: 0.18, appearance: "dark"), // Moss+ SpaceTheme(colors: ["#2A1A14", "#A2481D"], intensity: 0.7, noise: 0.2, appearance: "dark"), // Ember+ SpaceTheme(colors: ["#2A2310", "#7A5C0F"], intensity: 0.75, noise: 0.2, appearance: "dark"), // Gold+ SpaceTheme(colors: ["#241C3A", "#6944AE"], intensity: 0.75, noise: 0.18, appearance: "dark"), // Brand+ SpaceTheme(colors: ["#F8D558", "#A4F554"], intensity: 0.45, noise: 0.25, appearance: "light"),+ SpaceTheme(colors: ["#C7CAFF", "#FFE5E5"], intensity: 0.5, noise: 0.1, appearance: "light"),+ SpaceTheme(colors: ["#F4F1EA", "#E6DCC8"], intensity: 0.6, noise: 0.15, appearance: "light"), // Parchment+ ]++ /// Incognito windows: near-black with a cool violet cast, so they never pass for a space.+ public static let incognito = SpaceTheme(colors: ["#141318", "#2B2638"], intensity: 0.9, noise: 0.14, appearance: "dark")++ public var isDark: Bool {+ if appearance == "dark" { return true }+ if appearance == "light" { return false }+ // auto: judge by the first color's luminance+ return (colors.first.flatMap(HexColor.luminance) ?? 1) < 0.45+ }+}++public enum HexColor {+ public static func components(_ hex: String) -> (r: Double, g: Double, b: Double)? {+ var s = hex.trimmingCharacters(in: .whitespaces)+ if s.hasPrefix("#") { s.removeFirst() }+ guard s.count == 6, let v = UInt32(s, radix: 16) else { return nil }+ return (Double((v >> 16) & 0xff) / 255, Double((v >> 8) & 0xff) / 255, Double(v & 0xff) / 255)+ }+ public static func luminance(_ hex: String) -> Double? {+ guard let c = components(hex) else { return nil }+ return 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b+ }+}+diff --git a/Packages/CraCore/Tests/CraCoreTests/ArcThemeImportTests.swift b/Packages/CraCore/Tests/CraCoreTests/ArcThemeImportTests.swiftnew file mode 100644index 0000000..21de28f--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ArcThemeImportTests.swift@@ -0,0 +1,81 @@+import CraCore+import Foundation+import Testing++/// Fixtures/arc-window-themes.json holds `customInfo.windowTheme` as Arc writes it (background and+/// primaryColorPalette only). The solid ones are the 22 test spaces Arc was measured with for #30;+/// the gradients come from a real Arc profile.+struct ArcThemeImportTests {+ static let spaces: [String: [String: Any]] = {+ let url = Bundle.module.url(forResource: "arc-window-themes", withExtension: "json", subdirectory: "Fixtures")!+ let data = try! Data(contentsOf: url)+ return try! JSONSerialization.jsonObject(with: data) as! [String: [String: Any]]+ }()++ static func theme(_ name: String) -> SpaceTheme? {+ ArcThemeImport.theme(from: spaces[name]!)+ }++ /// A one-colour Arc theme (blendedSingleColor) stays that colour, flat, whatever its vibrancy+ /// and text appearance (0.1.22 imported it as a gradient of another colour, #30).+ @Test(arguments: [+ ("solidRedDark", "#E63333", 1.0, "dark"),+ ("solidWhiteDark", "#FFFFFF", 1.0, "dark"),+ ("solidWhiteLight", "#FFFFFF", 1.0, "light"),+ ("solidBlueDark", "#2861B3", 1.0, "dark"),+ ("solidBlueHalfIntensity", "#2861B3", 0.5, "dark"),+ ("solidBlueZeroIntensity", "#2861B3", 0.0, "dark"),+ ("solidBlueVibrantLight", "#2861B3", 1.0, "light"),+ ])+ func solidThemeKeepsItsColour(name: String, hex: String, intensity: Double, appearance: String) throws {+ let theme = try #require(Self.theme(name))+ #expect(theme.solid)+ #expect(theme.colors == [hex, hex])+ #expect(theme.accent == hex)+ #expect(theme.intensity == intensity)+ #expect(theme.appearance == appearance)+ #expect(!theme.vibrant, "Arc draws a solid colour the same with or without vibrancy")+ }++ /// Fitted to Arc's rendering in 0.1.23; a change here changes how imported spaces look.+ @Test func vibrantLightGradient() throws {+ let theme = try #require(Self.theme("gradientVibrantLight"))+ #expect(theme == SpaceTheme(colors: ["#F1E58A", "#FBC67D"], intensity: 0.25217215013901756, noise: 0.35,+ appearance: "light", vibrant: true, accent: "#F8D558"))+ }++ @Test func darkVariantOfAnAppearanceBasedGradient() throws {+ let theme = try #require(Self.theme("gradientAppearanceBasedDark"))+ #expect(theme == SpaceTheme(colors: ["#2C273B", "#32263A"], intensity: 1, noise: 0,+ appearance: "dark", accent: "#010220"))+ }++ /// A style Cra can't read falls back to the mid tone of Arc's derived palette, which keeps the hue.+ @Test func unknownStyleFallsBackToThePalettesMidTone() throws {+ let theme = try #require(Self.theme("unknownStyleWithPalette"))+ #expect(theme.solid && theme.colors == ["#8389FF", "#8389FF"])+ }++ @Test func spaceWithoutAThemeImportsNone() {+ #expect(Self.theme("noWindowTheme") == nil)+ }+}++struct SpaceThemeTests {+ /// sidebar.json written by older versions lacks the newer keys.+ @Test func decodingFillsMissingKeys() throws {+ let theme = try JSONDecoder().decode(SpaceTheme.self, from: Data(##"{"colors":["#112233","#445566"]}"##.utf8))+ #expect(theme == SpaceTheme(colors: ["#112233", "#445566"], intensity: 0.8, noise: 0.15, appearance: "auto"))+ }++ @Test func roundTrips() throws {+ let theme = SpaceTheme(colors: ["#2861B3", "#2861B3"], intensity: 0.5, noise: 0, appearance: "light",+ vibrant: true, accent: "#2861B3", solid: true)+ #expect(try JSONDecoder().decode(SpaceTheme.self, from: JSONEncoder().encode(theme)) == theme)+ }++ @Test(arguments: [("#000000", true), ("#FFFFFF", false), ("#2861B3", true), ("#F8D558", false)])+ func autoAppearanceFollowsTheFirstColour(hex: String, dark: Bool) {+ #expect(SpaceTheme(colors: [hex, hex], intensity: 1, noise: 0, appearance: "auto").isDark == dark)+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/FavoritesLayoutTests.swift b/Packages/CraCore/Tests/CraCoreTests/FavoritesLayoutTests.swiftnew file mode 100644index 0000000..4230ac4--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/FavoritesLayoutTests.swift@@ -0,0 +1,60 @@+import CoreGraphics+import CraCore+import Testing++/// Arc's favorites grid as measured (docs/arc-reverse-engineering.md, "Favorites grid columns+/// and Peek"). Arc's widths are the sidebar's; the grid is 16 pt narrower (8 pt each side).+struct FavoritesLayoutTests {+ /// Arc 1.170, 29 Oct: four favorites, sidebar width → columns and the tile width Arc's AX+ /// frames report (whole points; nil where it wasn't written down).+ @Test(arguments: [+ (347, 4, 76), (300, 4, nil), (260, 4, 55), (230, 4, 47),+ (227, 2, 101), (225, 2, 100), (220, 2, 98), (212, 2, 94), (205, 2, 90), (200, 2, 88),+ (170, 2, 73), (140, 2, 58), (100, 1, 84),+ ] as [(Int, Int, Int?)])+ func fourFavoritesMatchArc(sidebarWidth: Int, columns: Int, tileWidth: Int?) {+ let grid = FavoritesLayout(count: 4, width: CGFloat(sidebarWidth - 16))+ #expect(grid.columns == columns)+ if let tileWidth { #expect(Int(grid.tileWidth) == tileWidth) }+ }++ /// Arc 1.171, 31 Oct: 1–9 favorites at five sidebar widths. The widest grid keeps tiles at+ /// least 47 pt (4 at 347 and 230, 3 at 200, 2 at 140, 1 at 100), then takes the fewest+ /// columns that need no more rows: 5 → 3 + 2, 6 → 3 × 2, 7 → 4 + 3, 9 → 3 × 3, 4 at 200 → 2 × 2.+ @Test(arguments: [+ (347, [1, 2, 3, 4, 3, 3, 4, 4, 3]),+ (230, [1, 2, 3, 4, 3, 3, 4, 4, 3]),+ (200, [1, 2, 3, 2, 3, 3, 3, 3, 3]),+ (140, [1, 2, 2, 2, 2, 2, 2, 2, 2]),+ (100, [1, 1, 1, 1, 1, 1, 1, 1, 1]),+ ])+ func columnsByCountMatchArc(sidebarWidth: Int, columnsByCount: [Int]) {+ for (i, expected) in columnsByCount.enumerated() {+ let grid = FavoritesLayout(count: i + 1, width: CGFloat(sidebarWidth - 16))+ #expect(grid.columns == expected, "\(i + 1) favorites at \(sidebarWidth) pt")+ }+ }++ @Test func tilesSitOnHalfPoints() {+ // Arc at 347 pt: 84.75 → 85, 254.25 → 254.5. Widths are not rounded.+ let grid = FavoritesLayout(count: 4, width: 331)+ #expect(grid.frame(at: 1).minX == 85)+ #expect(grid.frame(at: 3).minX == 254.5)+ #expect(grid.frame(at: 3).width == 76.75)+ }++ @Test func shortLastRowKeepsTileWidthFromTheLeft() {+ let grid = FavoritesLayout(count: 5, width: 331)+ #expect(grid.columns == 3 && grid.rows == 2)+ #expect(grid.frame(at: 3).minX == 0 && grid.frame(at: 3).minY == 55)+ #expect(grid.frame(at: 4).minX == grid.frame(at: 1).minX)+ #expect(grid.frame(at: 4).width == grid.frame(at: 0).width)+ }++ @Test func heightCountsRowsAndGaps() {+ #expect(FavoritesLayout(count: 0, width: 331).gridHeight == 0)+ #expect(FavoritesLayout(count: 0, width: 331).rows == 0)+ #expect(FavoritesLayout(count: 4, width: 331).gridHeight == 47)+ #expect(FavoritesLayout(count: 9, width: 331).gridHeight == 157, "3 rows of 47 and 2 gaps of 8")+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/Fixtures/arc-window-themes.json b/Packages/CraCore/Tests/CraCoreTests/Fixtures/arc-window-themes.jsonnew file mode 100644index 0000000..5e8dd4a--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/Fixtures/arc-window-themes.json@@ -0,0 +1,759 @@+{+ "gradientAppearanceBasedDark": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "appearanceBased": {+ "dark": {+ "contentOverBackgroundAppearance": "dark",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedGradient": {+ "_0": {+ "baseColors": [+ {+ "alpha": 1,+ "blue": 0.12423918396234512,+ "colorSpace": "extendedSRGB",+ "green": 0.00801163725554943,+ "red": 0.0030348505824804306+ },+ {+ "alpha": 1,+ "blue": 0.12350984662771225,+ "colorSpace": "extendedSRGB",+ "green": -0.0005694620776921511,+ "red": 0.10257645696401596+ }+ ],+ "modifiers": {+ "intensityFactor": 0.8,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "overlayColors": [],+ "translucencyStyle": "dark",+ "wheel": {+ "complimentary": {}+ }+ }+ }+ }+ }+ }+ },+ "light": {+ "contentOverBackgroundAppearance": "light",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedGradient": {+ "_0": {+ "baseColors": [+ {+ "alpha": 1,+ "blue": 1.0133761167526245,+ "colorSpace": "extendedSRGB",+ "green": 0.7924899458885193,+ "red": 0.7825282216072083+ },+ {+ "alpha": 1,+ "blue": 0.8998938202857971,+ "colorSpace": "extendedSRGB",+ "green": 0.8975197672843933,+ "red": 1.0203664302825928+ }+ ],+ "modifiers": {+ "intensityFactor": 0.5,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "overlayColors": [],+ "translucencyStyle": "light",+ "wheel": {+ "complimentary": {}+ }+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": 1.0143413391776335,+ "colorSpace": "extendedSRGB",+ "green": 0.5381175653059538,+ "red": 0.5139257535271398+ },+ "shaded": {+ "alpha": 1,+ "blue": 1.0240697860717773,+ "colorSpace": "extendedSRGB",+ "green": 0.22479963302612305,+ "red": 0.1841973066329956+ },+ "shadedDark": {+ "alpha": 1,+ "blue": 1.0258938698644293,+ "colorSpace": "extendedSRGB",+ "green": 0.16605252072365362,+ "red": 0.12237322284034358+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 1.0021807805599507,+ "colorSpace": "extendedSRGB",+ "green": 0.9297649806557461,+ "red": 0.9260863121448228+ }+ }+ }+ }+ },+ "gradientVibrantLight": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "light",+ "isVibrant": true,+ "style": {+ "color": {+ "_0": {+ "blendedGradient": {+ "_0": {+ "baseColors": [+ {+ "alpha": 1,+ "blue": 0.3457501530647278,+ "colorSpace": "extendedSRGB",+ "green": 0.8349388241767883,+ "red": 0.9725341200828552+ },+ {+ "alpha": 1,+ "blue": 0.33059829473495483,+ "colorSpace": "extendedSRGB",+ "green": 0.9583556056022644,+ "red": 0.6419472098350525+ }+ ],+ "modifiers": {+ "intensityFactor": 0.25217215013901756,+ "noiseFactor": 0.35,+ "overlay": "grain"+ },+ "overlayColors": [+ {+ "alpha": 0,+ "blue": 0,+ "colorSpace": "extendedSRGB",+ "green": 0,+ "red": 0+ },+ {+ "alpha": 1,+ "blue": 0.40259188413619995,+ "colorSpace": "extendedSRGB",+ "green": 0.45889586210250854,+ "red": 1.0189919471740723+ }+ ],+ "translucencyStyle": "light",+ "wheel": {+ "analogous": {}+ }+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "noWindowTheme": {+ "customInfo": {+ "iconType": {+ "emoji_v2": "🌿"+ }+ }+ },+ "solidBlueDark": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "dark",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedSingleColor": {+ "_0": {+ "color": {+ "alpha": 1,+ "blue": 0.701,+ "colorSpace": "extendedSRGB",+ "green": 0.381,+ "red": 0.158+ },+ "modifiers": {+ "intensityFactor": 1,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "translucencyStyle": "light"+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "solidBlueHalfIntensity": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "dark",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedSingleColor": {+ "_0": {+ "color": {+ "alpha": 1,+ "blue": 0.701,+ "colorSpace": "extendedSRGB",+ "green": 0.381,+ "red": 0.158+ },+ "modifiers": {+ "intensityFactor": 0.5,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "translucencyStyle": "light"+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "solidBlueVibrantLight": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "light",+ "isVibrant": true,+ "style": {+ "color": {+ "_0": {+ "blendedSingleColor": {+ "_0": {+ "color": {+ "alpha": 1,+ "blue": 0.701,+ "colorSpace": "extendedSRGB",+ "green": 0.381,+ "red": 0.158+ },+ "modifiers": {+ "intensityFactor": 1,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "translucencyStyle": "light"+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "solidBlueZeroIntensity": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "dark",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedSingleColor": {+ "_0": {+ "color": {+ "alpha": 1,+ "blue": 0.701,+ "colorSpace": "extendedSRGB",+ "green": 0.381,+ "red": 0.158+ },+ "modifiers": {+ "intensityFactor": 0.0,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "translucencyStyle": "light"+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "solidRedDark": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "dark",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedSingleColor": {+ "_0": {+ "color": {+ "alpha": 1,+ "blue": 0.2,+ "colorSpace": "extendedSRGB",+ "green": 0.2,+ "red": 0.9+ },+ "modifiers": {+ "intensityFactor": 1,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "translucencyStyle": "light"+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "solidWhiteDark": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "dark",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedSingleColor": {+ "_0": {+ "color": {+ "alpha": 1,+ "blue": 1,+ "colorSpace": "extendedSRGB",+ "green": 1,+ "red": 1+ },+ "modifiers": {+ "intensityFactor": 1,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "translucencyStyle": "light"+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "solidWhiteLight": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "single": {+ "_0": {+ "contentOverBackgroundAppearance": "light",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "blendedSingleColor": {+ "_0": {+ "color": {+ "alpha": 1,+ "blue": 1,+ "colorSpace": "extendedSRGB",+ "green": 1,+ "red": 1+ },+ "modifiers": {+ "intensityFactor": 1,+ "noiseFactor": 0,+ "overlay": "grain"+ },+ "translucencyStyle": "light"+ }+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shaded": {+ "alpha": 1,+ "blue": -0.2314479947090149,+ "colorSpace": "extendedSRGB",+ "green": 0.7032328248023987,+ "red": 0.913607656955719+ },+ "shadedDark": {+ "alpha": 1,+ "blue": -0.08024805039167404,+ "colorSpace": "extendedSRGB",+ "green": 0.33624404668807983,+ "red": 0.4369257688522339+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 0.7377796769142151,+ "colorSpace": "extendedSRGB",+ "green": 0.9305835962295532,+ "red": 0.9889748692512512+ }+ }+ }+ }+ },+ "unknownStyleWithPalette": {+ "customInfo": {+ "windowTheme": {+ "background": {+ "appearanceBased": {+ "dark": {+ "contentOverBackgroundAppearance": "dark",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "someFutureStyle": {+ "_0": {}+ }+ }+ }+ }+ },+ "light": {+ "contentOverBackgroundAppearance": "light",+ "isVibrant": false,+ "style": {+ "color": {+ "_0": {+ "someFutureStyle": {+ "_0": {}+ }+ }+ }+ }+ }+ }+ },+ "primaryColorPalette": {+ "midTone": {+ "alpha": 1,+ "blue": 1.0143413391776335,+ "colorSpace": "extendedSRGB",+ "green": 0.5381175653059538,+ "red": 0.5139257535271398+ },+ "shaded": {+ "alpha": 1,+ "blue": 1.0240697860717773,+ "colorSpace": "extendedSRGB",+ "green": 0.22479963302612305,+ "red": 0.1841973066329956+ },+ "shadedDark": {+ "alpha": 1,+ "blue": 1.0258938698644293,+ "colorSpace": "extendedSRGB",+ "green": 0.16605252072365362,+ "red": 0.12237322284034358+ },+ "tintedLight": {+ "alpha": 1,+ "blue": 1.0021807805599507,+ "colorSpace": "extendedSRGB",+ "green": 0.9297649806557461,+ "red": 0.9260863121448228+ }+ }+ }+ }+ }+}diff --git a/Packages/CraCore/Tests/CraCoreTests/ObserveChangesTests.swift b/Packages/CraCore/Tests/CraCoreTests/ObserveChangesTests.swiftnew file mode 100644index 0000000..6383f90--- /dev/null+++ b/Packages/CraCore/Tests/CraCoreTests/ObserveChangesTests.swift@@ -0,0 +1,57 @@+import CraCore+import Observation+import Testing++/// SidebarStore in miniature: one @Observable stored property holding a settings struct.+@Observable @MainActor+private final class Store {+ var settings = Settings()+}++private struct Settings {+ var httpsOnly = false+ var sidebarWidth = 240+}++/// Lets the main-actor tasks Observation's onChange queued run.+@MainActor+private func settle() async {+ for _ in 0..<10 { await Task.yield() }+}++@MainActor+struct ObserveChangesTests {+ /// Why observeChanges exists: watching one field of the struct fires on any settings write.+ /// The HTTPS-only observer re-applied Chromium's preference on every write, including the+ /// ones during CefShutdown (#36).+ @Test func plainTrackingFiresOnAnUnrelatedSettingsWrite() {+ final class Fired: @unchecked Sendable { var value = false }+ let store = Store(), fired = Fired()+ _ = withObservationTracking { store.settings.httpsOnly } onChange: { fired.value = true }+ store.settings.sidebarWidth = 300+ #expect(fired.value)+ }++ @Test func appliesOnceThenOnlyRealChanges() async {+ let store = Store()+ var applied: [Bool] = []+ observeChanges(of: { store.settings.httpsOnly }, apply: { applied.append($0) })+ #expect(applied == [false])++ store.settings.sidebarWidth = 300+ await settle()+ store.settings.httpsOnly = false+ await settle()+ #expect(applied == [false], "unrelated and same-value writes apply nothing")++ store.settings.httpsOnly = true+ await settle()+ #expect(applied == [false, true])++ store.settings.sidebarWidth = 200+ await settle()+ store.settings.httpsOnly = false+ await settle()+ #expect(applied == [false, true, false], "it keeps watching after each change")+ }+}diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex 716648b..a589a01 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -172,21 +172,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {/// Settings > Privacy > "Always use secure connections", live like content blocking.private func observeHttpsOnly() {- let enabled = withObservationTracking {- store.settings.httpsOnly- } onChange: { [weak self] in- Task { @MainActor in self?.observeHttpsOnly() }- }- CraCEFRuntime.setHttpsOnlyModeEnabled(enabled)+ observeChanges(of: { [store] in store.settings.httpsOnly }, apply: CraCEFRuntime.setHttpsOnlyModeEnabled)}private func observeContentBlocking() {- let enabled = withObservationTracking {- store.settings.blockAdsAndTrackers- } onChange: { [weak self] in- Task { @MainActor in self?.observeContentBlocking() }- }- CraCEFRuntime.setContentBlockingEnabled(enabled)+ observeChanges(of: { [store] in store.settings.blockAdsAndTrackers }, apply: CraCEFRuntime.setContentBlockingEnabled)}private func installURLEventHandler() {diff --git a/Sources/Cra/App/CraCoreExports.swift b/Sources/Cra/App/CraCoreExports.swiftnew file mode 100644index 0000000..6aa3aff--- /dev/null+++ b/Sources/Cra/App/CraCoreExports.swift@@ -0,0 +1,3 @@+// Packages/CraCore (models and decisions with no AppKit or Chromium, tested by+// scripts/test.sh) is visible in every Cra file, as if its types lived here.+@_exported import CraCorediff --git a/Sources/Cra/Model/SidebarModel.swift b/Sources/Cra/Model/SidebarModel.swiftindex a00db57..6ff1be5 100644--- a/Sources/Cra/Model/SidebarModel.swift+++ b/Sources/Cra/Model/SidebarModel.swift@@ -191,86 +191,6 @@ struct SidebarItem: Identifiable, Codable, Equatable {}}-struct SpaceTheme: Codable, Equatable {- /// One or two hex colors blended into a gradient (Arc: blendedGradient.baseColors).- var colors: [String]- /// 0...1, how saturated the gradient is rendered (Arc: intensityFactor).- var intensity: Double- /// 0...1 grain overlay (Arc: noiseFactor).- var noise: Double- /// "auto" | "light" | "dark" (Arc: contentOverBackgroundAppearance).- var appearance: String- /// Arc's isVibrant: the gradient is laid over the blurred desktop at- /// `intensity` opacity instead of being painted opaque.- var vibrant: Bool = false- /// The theme's raw first colour (Arc's base colour); drives the toolbar band.- var accent: String? = nil- /// Arc's one-colour theme (blendedSingleColor): a flat fill laid over a dark, slightly- /// see-through material, at `intensity` (SpacePalette.solidAlpha), not a gradient.- var solid: Bool = false-- init(colors: [String], intensity: Double, noise: Double, appearance: String, vibrant: Bool = false, accent: String? = nil,- solid: Bool = false) {- self.colors = colors- self.intensity = intensity- self.noise = noise- self.appearance = appearance- self.vibrant = vibrant- self.accent = accent- self.solid = solid- }-- init(from decoder: Decoder) throws {- let c = try decoder.container(keyedBy: CodingKeys.self)- colors = try c.decodeIfPresent([String].self, forKey: .colors) ?? ["#1C242B", "#3A3660"]- intensity = try c.decodeIfPresent(Double.self, forKey: .intensity) ?? 0.8- noise = try c.decodeIfPresent(Double.self, forKey: .noise) ?? 0.15- appearance = try c.decodeIfPresent(String.self, forKey: .appearance) ?? "auto"- vibrant = try c.decodeIfPresent(Bool.self, forKey: .vibrant) ?? false- accent = try c.decodeIfPresent(String.self, forKey: .accent)- solid = try c.decodeIfPresent(Bool.self, forKey: .solid) ?? false- }-- /// Dark first: colors borrowed from Victor's other projects (GhostWriter- /// ink + brand purple, Spook's "wall" browns, Phantom's greys, moss, gold,- /// ember), then a few lighter Arc-style gradients.- static let presets: [SpaceTheme] = [- SpaceTheme(colors: ["#1C242B", "#3A3660"], intensity: 0.85, noise: 0.18, appearance: "dark"), // Ink- SpaceTheme(colors: ["#1C1712", "#2E2620"], intensity: 0.9, noise: 0.22, appearance: "dark"), // Wall- SpaceTheme(colors: ["#181818", "#262626"], intensity: 0.9, noise: 0.12, appearance: "dark"), // Phantom- SpaceTheme(colors: ["#0F2420", "#2F6F5E"], intensity: 0.75, noise: 0.18, appearance: "dark"), // Moss- SpaceTheme(colors: ["#2A1A14", "#A2481D"], intensity: 0.7, noise: 0.2, appearance: "dark"), // Ember- SpaceTheme(colors: ["#2A2310", "#7A5C0F"], intensity: 0.75, noise: 0.2, appearance: "dark"), // Gold- SpaceTheme(colors: ["#241C3A", "#6944AE"], intensity: 0.75, noise: 0.18, appearance: "dark"), // Brand- SpaceTheme(colors: ["#F8D558", "#A4F554"], intensity: 0.45, noise: 0.25, appearance: "light"),- SpaceTheme(colors: ["#C7CAFF", "#FFE5E5"], intensity: 0.5, noise: 0.1, appearance: "light"),- SpaceTheme(colors: ["#F4F1EA", "#E6DCC8"], intensity: 0.6, noise: 0.15, appearance: "light"), // Parchment- ]-- /// Incognito windows: near-black with a cool violet cast, so they never pass for a space.- static let incognito = SpaceTheme(colors: ["#141318", "#2B2638"], intensity: 0.9, noise: 0.14, appearance: "dark")-- var isDark: Bool {- if appearance == "dark" { return true }- if appearance == "light" { return false }- // auto: judge by the first color's luminance- return (colors.first.flatMap(HexColor.luminance) ?? 1) < 0.45- }-}--enum HexColor {- static func components(_ hex: String) -> (r: Double, g: Double, b: Double)? {- var s = hex.trimmingCharacters(in: .whitespaces)- if s.hasPrefix("#") { s.removeFirst() }- guard s.count == 6, let v = UInt32(s, radix: 16) else { return nil }- return (Double((v >> 16) & 0xff) / 255, Double((v >> 8) & 0xff) / 255, Double(v & 0xff) / 255)- }- static func luminance(_ hex: String) -> Double? {- guard let c = components(hex) else { return nil }- return 0.2126 * c.r + 0.7152 * c.g + 0.0722 * c.b- }-}-struct Space: Identifiable, Codable, Equatable {var id: UUIDvar title: Stringdiff --git a/Sources/Cra/Services/Import/Importers.swift b/Sources/Cra/Services/Import/Importers.swiftindex 124d978..bd059ea 100644--- a/Sources/Cra/Services/Import/Importers.swift+++ b/Sources/Cra/Services/Import/Importers.swift@@ -183,7 +183,7 @@ enum ArcImporter {}// A space without a theme is Arc's default dark purple, close to Ink. Not the next// preset: that shifted every later space onto another colour (issue #30).- var sp = ImportedSpace(title: title, emoji: emoji, theme: theme(from: space) ?? SpaceTheme.presets[0])+ var sp = ImportedSpace(title: title, emoji: emoji, theme: ArcThemeImport.theme(from: space) ?? SpaceTheme.presets[0])let profile = space["profile"] as? NSDictionarysp.favorites = favoritesByProfile.first { $0.profile.isEqual(profile) }?.items ?? allFavoritesif let p = pinnedID, let c = items[p] { sp.pinned = (c["childrenIds"] as? [String] ?? []).compactMap(convert) }@@ -259,100 +259,6 @@ enum ArcImporter {let path = supportDir.appendingPathComponent("SidebarItemsFaviconCache/\(digest)").pathreturn FileManager.default.fileExists(atPath: path) ? path : nil}-- /// Arc's blendedGradient → SpaceTheme. Prefers the dark variant when one exists.- private static func theme(from space: [String: Any]) -> SpaceTheme? {- guard let info = space["customInfo"] as? [String: Any], let wt = info["windowTheme"] as? [String: Any],- let bg = wt["background"] as? [String: Any] else { return nil }- var variant: [String: Any]?- var appearance = "auto"- if let ab = bg["appearanceBased"] as? [String: Any] {- variant = (ab["dark"] as? [String: Any]) ?? (ab["light"] as? [String: Any])- appearance = ab["dark"] != nil ? "dark" : "light"- } else if let single = bg["single"] as? [String: Any] {- variant = single["_0"] as? [String: Any]- }- guard let v = variant else { return nil }- if let a = v["contentOverBackgroundAppearance"] as? String { appearance = a }- let vibrant = v["isVibrant"] as? Bool ?? false- func comp(_ c: [String: Any], _ k: String) -> Double { max(0, min(1, c[k] as? Double ?? 0)) }- func hexOf(_ c: [String: Any]) -> String {- String(format: "#%02X%02X%02X", Int((comp(c, "red") * 255).rounded()),- Int((comp(c, "green") * 255).rounded()), Int((comp(c, "blue") * 255).rounded()))- }- let c0 = ((v["style"] as? [String: Any])?["color"] as? [String: Any])?["_0"] as? [String: Any]- // A solid colour (Arc's colour picker with one dot) is `blendedSingleColor`. Themes- // Cra can't read still carry Arc's derived palette, whose mid tone keeps the hue.- if let s = (c0?["blendedSingleColor"] as? [String: Any])?["_0"] as? [String: Any], let c = s["color"] as? [String: Any] {- let mods = s["modifiers"] as? [String: Any]- return solidTheme(hexOf(c), intensity: mods?["intensityFactor"] as? Double ?? 1,- noise: mods?["noiseFactor"] as? Double ?? 0, appearance: appearance)- }- guard let bg2 = c0?["blendedGradient"] as? [String: Any], let g = bg2["_0"] as? [String: Any],- let base = g["baseColors"] as? [[String: Any]], !base.isEmpty else {- guard let mid = (wt["primaryColorPalette"] as? [String: Any])?["midTone"] as? [String: Any] else { return nil }- return solidTheme(hexOf(mid), intensity: 1, noise: 0, appearance: appearance)- }- let overlays = g["overlayColors"] as? [[String: Any]] ?? []- // Arc blends an overlay gradient onto the base gradient and the wheel- // mixes the two base colours; bake both into our two stops (fitted to- // Arc's rendering: top stop leans toward the second base colour).- func hex(_ i: Int) -> String {- let b = base[min(i, base.count - 1)]- let other = base[min(i == 0 ? 1 : 0, base.count - 1)]- var r = comp(b, "red"), gg = comp(b, "green"), bl = comp(b, "blue")- if i == 0 {- r += (comp(other, "red") - r) * 0.1; gg += (comp(other, "green") - gg) * 0.1; bl += (comp(other, "blue") - bl) * 0.1- }- if i < overlays.count {- let o = overlays[i]- let a = comp(o, "alpha") * 0.85- r += (comp(o, "red") - r) * a; gg += (comp(o, "green") - gg) * a; bl += (comp(o, "blue") - bl) * a- }- return String(format: "#%02X%02X%02X", Int((r * 255).rounded()), Int((gg * 255).rounded()), Int((bl * 255).rounded()))- }- var colors = [hex(0), hex(1)]- let mods = g["modifiers"] as? [String: Any]- var intensity = mods?["intensityFactor"] as? Double ?? 0.5- if vibrant && appearance != "dark" {- // Fitted to Arc over white and black backdrops: the top stop is the- // first base colour nudged toward the second and 30% toward white;- // the bottom stop is the base colour pulled 30% toward the overlay's- // end colour (or the second base colour) and 20% toward white.- // Opacity ramps 0.45 → 0.59 (see SpacePalette).- func rgb(_ c: [String: Any]) -> (Double, Double, Double) { (comp(c, "red"), comp(c, "green"), comp(c, "blue")) }- func mix(_ a: (Double, Double, Double), _ b: (Double, Double, Double), _ t: Double) -> (Double, Double, Double) {- (a.0 + (b.0 - a.0) * t, a.1 + (b.1 - a.1) * t, a.2 + (b.2 - a.2) * t)- }- func hexOf(_ c: (Double, Double, Double)) -> String {- String(format: "#%02X%02X%02X", Int((c.0 * 255).rounded()), Int((c.1 * 255).rounded()), Int((c.2 * 255).rounded()))- }- let b0 = rgb(base[0]), b1 = rgb(base[min(1, base.count - 1)])- let end = overlays.last(where: { comp($0, "alpha") > 0 }).map(rgb) ?? b1- let white = (1.0, 1.0, 1.0)- colors = [hexOf(mix(mix(b0, b1, 0.15), white, 0.30)), hexOf(mix(mix(b0, end, 0.30), white, 0.20))]- }- let accent = String(format: "#%02X%02X%02X", Int((comp(base[0], "red") * 255).rounded()),- Int((comp(base[0], "green") * 255).rounded()), Int((comp(base[0], "blue") * 255).rounded()))- if appearance == "dark" && !vibrant {- // Measured from Arc: dark themes show ~27% of the colour over a- // slightly purple dark grey (#2B2632).- colors = colors.map { c in- let k = HexColor.components(c) ?? (0, 0, 0)- func ch(_ v: Double, _ base: Double) -> Int { Int((v * 255 * 0.27 + base).rounded()) }- return String(format: "#%02X%02X%02X", ch(k.r, 43), ch(k.g, 38), ch(k.b, 50))- }- intensity = 1- }- return SpaceTheme(colors: colors, intensity: intensity,- noise: mods?["noiseFactor"] as? Double ?? 0.15, appearance: appearance, vibrant: vibrant, accent: accent)- }-- /// One flat colour (SpaceTheme.solid). Arc draws it the same whether or not it is- /// marked vibrant, so only the colour, intensity and text appearance carry over.- private static func solidTheme(_ hex: String, intensity: Double, noise: Double, appearance: String) -> SpaceTheme {- SpaceTheme(colors: [hex, hex], intensity: intensity, noise: noise, appearance: appearance, accent: hex, solid: true)- }}// MARK: - Diadiff --git a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swiftindex 76b325e..311f09f 100644--- a/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift+++ b/Sources/Cra/UI/Sidebar/List/SpaceColumnView.swift@@ -493,34 +493,18 @@ final class FavoritesGridView: NSView {if countChanged { onHeightChange(false) }}- /// Arc 1.171 (AX frames, 1–9 favorites at sidebar widths 100–347, 31 Oct): at most as many- /// columns (up to four) as keep a tile at least as wide as it is tall (47 pt), then the fewest- /// that need no more rows: one favorite fills the row, five go 3 + 2, nine 3 × 3, four at- /// 200 pt 2 × 2 (#29). A short last row keeps the tile width, from the left.- private func columns(forWidth w: CGFloat) -> Int {- let widest = (1...4).last { (w - CGFloat($0 - 1) * 8) / CGFloat($0) >= 47 } ?? 1- guard !order.isEmpty else { return widest }- let rows = (order.count + widest - 1) / widest- return (order.count + rows - 1) / rows- }-- private func rows(forWidth w: CGFloat) -> Int {- let c = columns(forWidth: w)- return (order.count + c - 1) / c- }+ /// Arc's columns and tile frames (FavoritesLayout, #29).+ private func grid(forWidth w: CGFloat) -> FavoritesLayout { FavoritesLayout(count: order.count, width: w) }func height(forWidth w: CGFloat) -> CGFloat {- let rows = rows(forWidth: w)- let grid = rows == 0 ? 0 : CGFloat(rows) * 47 + CGFloat(rows - 1) * 8- return grid + (order.isEmpty ? 0 : 4) + strip.height+ grid(forWidth: w).gridHeight + (order.isEmpty ? 0 : 4) + strip.height}/// Where the header and list are placed from: the tiles' bottom, the open "Add to Favorites"/// strip's while a tab is dragged over it, nil with no favorites.func tilesBottom(forWidth w: CGFloat) -> CGFloat? {if strip.targeted { return height(forWidth: w) }- let rows = rows(forWidth: w)- return rows == 0 ? nil : CGFloat(rows) * 47 + CGFloat(rows - 1) * 8+ return order.isEmpty ? nil : grid(forWidth: w).gridHeight}/// The resting strip only takes drops (AppKit finds drop targets apart from hitTest). With@@ -533,17 +517,9 @@ final class FavoritesGridView: NSView {override func layout() {super.layout()let w = bounds.width- let n = columns(forWidth: w)- let cw = (w - CGFloat(n - 1) * 8) / CGFloat(n)- for (i, id) in order.enumerated() {- let r = i / n, c = i % n- // Arc puts each tile on a half point (84.75 → 85 at 347 pt).- let x = (CGFloat(c) * (cw + 8) * 2).rounded() / 2- tiles[id]?.frame = NSRect(x: x, y: CGFloat(r) * (47 + 8), width: cw, height: 47)- }- let rows = rows(forWidth: w)- let grid = rows == 0 ? 0 : CGFloat(rows) * 47 + CGFloat(rows - 1) * 8- strip.frame = NSRect(x: 0, y: grid + (order.isEmpty ? 0 : 4), width: w, height: strip.height)+ let grid = grid(forWidth: w)+ for (i, id) in order.enumerated() { tiles[id]?.frame = grid.frame(at: i) }+ strip.frame = NSRect(x: 0, y: grid.gridHeight + (order.isEmpty ? 0 : 4), width: w, height: strip.height)}func moveFavorite(_ dragged: UUID, before target: UUID, after: Bool) {diff --git a/Tests/BrowserManagerSupport/AppServices.swift b/Tests/BrowserManagerSupport/AppServices.swiftindex 51129ff..4554800 100644--- a/Tests/BrowserManagerSupport/AppServices.swift+++ b/Tests/BrowserManagerSupport/AppServices.swift@@ -1,4 +1,5 @@import AppKit+import CraCEF// Unrelated shell services required to typecheck the complete production manager.// The tab store deliberately remains observable so stale callbacks can be asserted.@@ -42,6 +43,14 @@ final class FaviconCache {}enum TabSwitcherMetrics { static let thumbnail = NSSize(width: 320, height: 200) }enum HitchMonitor { static func mark(_ event: String) {} }+enum CraLog {+ static func note(_ message: String) {}+ static func host(_ url: String) -> String { URL(string: url)?.host ?? "?" }+}+enum PageProbe {+ static func run(_ browser: CraBrowser, completion: @escaping (String) -> Void) {}+ static func viewState(_ runtime: TabRuntime) -> String { "" }+}enum EmbeddedPages {static var viewsByHost: [ObjectIdentifier: [NSView]] = [:]static func isHost(_ window: NSWindow) -> Bool { viewsByHost[ObjectIdentifier(window)] != nil }diff --git a/Tests/smoke-launch.sh b/Tests/smoke-launch.shnew file mode 100755index 0000000..4f2c8ba--- /dev/null+++ b/Tests/smoke-launch.sh@@ -0,0 +1,83 @@+#!/bin/bash+# Launch the built app three times on a throwaway data folder (no pages, a page opened, the page+# restored) and quit it each time like ⌘Q, just after a settings write. Fails if it dies, hangs,+# exits with an error or leaves a crash report: the only check that sees a CHECK inside Chromium.+# Tests/smoke-launch.sh [path/to/Cra.app] (default build/Cra.app)+set -euo pipefail+cd "$(dirname "$0")/.."+APP="${1:-build/Cra.app}"+EXE="$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$APP/Contents/Info.plist")"+TEST_DIR="$(mktemp -d /tmp/cra-smoke.XXXXXX)"+DATA="$TEST_DIR/data"+REPORTS="$HOME/Library/Logs/DiagnosticReports"+mkdir -p "$DATA"+touch "$TEST_DIR/started"+PID=""+cleanup() {+ [ -n "$PID" ] && kill -9 "$PID" 2>/dev/null || true+ rm -rf "$TEST_DIR"+}+trap cleanup EXIT++fail() {+ echo "Smoke: FAIL: $*"+ echo "--- last lines of the app's output"+ tail -40 "$TEST_DIR/run-"*.log 2>/dev/null || true+ exit 1+}++# Quits like ⌘Q: an Apple event to this pid only, never to the installed Cra.+cat > "$TEST_DIR/quit.swift" <<'EOF'+import AppKit+let pid = pid_t(CommandLine.arguments[1])!+exit(NSRunningApplication(processIdentifier: pid)?.terminate() == true ? 0 : 1)+EOF+xcrun swiftc "$TEST_DIR/quit.swift" -o "$TEST_DIR/quit"++# Past onboarding, no quit warning, and not reading Arc's preferences on this machine.+cat > "$DATA/settings.json" <<'EOF'+{"hasSeenImportPrompt": true, "warnBeforeQuitting": false, "toolbarDefaultMigrated": true, "showToolbar": false}+EOF+cat > "$TEST_DIR/page.html" <<'EOF'+<!doctype html><title>Smoke</title><p>Cra smoke test</p>+EOF++run() {+ local n="$1" what="$2"+ CRA_DATA_DIR="$DATA" CRA_COMMAND_FILE="$TEST_DIR/commands" CRA_TEST_BACKGROUND=1 \+ "$APP/Contents/MacOS/$EXE" > "$TEST_DIR/run-$n.log" 2>&1 &+ PID=$!+ # The command file appears once the app has finished launching.+ for _ in $(seq 120); do+ [ -e "$TEST_DIR/commands" ] && break+ kill -0 "$PID" 2>/dev/null || fail "launch $n ($what): the app exited while starting"+ sleep 0.5+ done+ [ -e "$TEST_DIR/commands" ] || fail "launch $n ($what): not ready after 60 s"+ [ "$what" = "opens a page" ] && echo "cra://open?url=file://$TEST_DIR/page.html" >> "$TEST_DIR/commands"+ sleep 8+ kill -0 "$PID" 2>/dev/null || fail "launch $n ($what): the app died before quitting"+ # A settings write just before quitting (#36 crashed on one at quit).+ echo "cra://action/toggleToolbar" >> "$TEST_DIR/commands"+ sleep 0.3+ "$TEST_DIR/quit" "$PID" || fail "launch $n ($what): the app did not take the quit event"+ for _ in $(seq 60); do+ kill -0 "$PID" 2>/dev/null || break+ sleep 0.5+ done+ kill -0 "$PID" 2>/dev/null && fail "launch $n ($what): still running 30 s after quitting"+ local status=0+ wait "$PID" || status=$?+ PID=""+ rm -f "$TEST_DIR/commands"+ [ "$status" = 0 ] || fail "launch $n ($what): exited with status $status"+ echo "Smoke: launch $n $what and quits cleanly"+}++run 1 "starts with no pages"+run 2 "opens a page"+run 3 "restores the page"+sleep 3 # ReportCrash writes a moment after the process is gone+CRASHES="$(find "$REPORTS" -maxdepth 1 -name "$EXE*.ips" -newer "$TEST_DIR/started" 2>/dev/null || true)"+[ -z "$CRASHES" ] || fail "crash reports were written:"$'\n'"$CRASHES"+echo "Smoke: passed"diff --git a/Tests/test-browser-manager.sh b/Tests/test-browser-manager.shold mode 100644new mode 100755diff --git a/docs/development.md b/docs/development.mdindex 1346749..06dee24 100644--- a/docs/development.md+++ b/docs/development.md@@ -27,6 +27,9 @@ issue when a newer stable CEF is out; `scripts/update-cef.sh` moves the pin.bar, split view, windows, settings, onboarding)- `Sources/CraCEF` — Objective-C++ bridge between Swift and CEF- `Sources/CraHelper` — Chromium subprocess executable+- `Packages/CraCore` — models and decisions with no AppKit or Chromium (space themes, Arc+ theme import, the favorites grid), visible in every `Sources/Cra` file+- `Tests/` — the harnesses that compile production files against fakes, and the smoke test- `resources/` — app icon, brand PNGs, the ad and tracker blocklist with its licence notices- `scripts/` — build, release, CEF and test tooling; `scripts/clips` records release clips- `docs/arc-reverse-engineering.md` — what was learned from Arc and how@@ -47,6 +50,33 @@ the on-screen pages' state, settings, extensions and the last week's crash reporaddresses cut to their host; `cra://debug?exportDiagnostics=<path>` does the same withoutthe save panel.+## Tests++ scripts/test.sh # everything below except the smoke test, in seconds+ scripts/test.sh core # only Packages/CraCore+ Tests/smoke-launch.sh # launches build/Cra.app three times, about 30 s++CI runs `scripts/test.sh` on every pull request (no CEF download) and the smoke test on the+app it builds.++- `Packages/CraCore` (`swift test --package-path Packages/CraCore`): a package of its own, so+ its tests build without `vendor/cef`. Code that decides something without a window or a+ page belongs here, with a test: a layout rule, a mapping from Arc's or Chromium's files,+ a policy. Expected values for anything copied from Arc come from Arc's measurements in+ `docs/arc-reverse-engineering.md`; fixtures hold Arc's own JSON, trimmed to what is read.+- `Tests/test-browser-manager.sh`, `scripts/test-floating-sidebar.sh`,+ `scripts/test-extension-popup-candidate.sh`, `scripts/test-extension-state.sh`: compile a+ few production files with `swiftc` against fakes (`Tests/BrowserManagerSupport` stands in+ for CraCEF and the rest of the app). When the manager calls something new from the app, add+ a stub to `AppServices.swift`.+- `Tests/smoke-launch.sh [app]`: starts the app on a throwaway data folder with no pages,+ with a page opened, then with it restored, and quits it like ⌘Q after a settings write.+ It fails on a crash, a hang, an error exit or a new crash report, which is how a `CHECK`+ inside Chromium shows up. Its own data folder lets it run next to your daily Cra.++What none of these see: compositing (the sidebar blur), fullscreen spaces, and how real sites+behave. Check those by hand, and say how in the PR.+## Running a test instance`scripts/dev.sh` builds a separate `CraDev.app`, including Sparkle, without a productiondiff --git a/scripts/test.sh b/scripts/test.shnew file mode 100755index 0000000..a90dac0--- /dev/null+++ b/scripts/test.sh@@ -0,0 +1,29 @@+#!/bin/bash+# Every test that runs without Chromium, a window server session or a profile: what CI runs+# on each pull request. Seconds, and no vendor/cef needed.+# scripts/test.sh all of them+# scripts/test.sh core only Packages/CraCore (swift test)+# A new harness is one more `suite` line below.+set -uo pipefail+cd "$(dirname "$0")/.."++failed=()+suite() {+ local name="$1"; shift+ echo "==> $name"+ if ! "$@"; then failed+=("$name"); fi+}++suite "CraCore" swift test --package-path Packages/CraCore+if [ "${1:-}" != core ]; then+ suite "Browser manager" Tests/test-browser-manager.sh+ suite "Floating sidebar" scripts/test-floating-sidebar.sh+ suite "Extension popup candidate" scripts/test-extension-popup-candidate.sh+ suite "Extension state" scripts/test-extension-state.sh+fi++if [ ${#failed[@]} -gt 0 ]; then+ printf 'Failed: %s\n' "${failed[@]}"+ exit 1+fi+echo "All tests passed."