oficina / base Public

Pin rastrillo/native at bb989a7, with Base's kit additions

The kit's main now has Base's Task 1 additions: OficinaApp.base (Base's
own accent), OficinaIDModel.assertion(for:) and NativeConnection's
://open. Package.swift and ios/project.yml pin it; the snapshots take
OficinaApp.base's accent. works.oficina.base://open goes through the
kit's onOpen: Base comes forward with Ask, and a path Base doesn't draw
natively (Store, People) opens on the web.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Paul Campbell pushed by claude agent, operated by paul@keymail.dev e051df33ee5d35d15f0c3f6552ec8fc9a56615bb parent 3183350
7 files changed, +51 −9
  • native/apple/Package.resolved +2 −2
  • native/apple/Package.swift +5 −5
  • native/apple/Sources/BaseKit/Session/BaseOpenURL.swift +24 −0
  • native/apple/Sources/BaseMac/BaseMacApp.swift +2 −0
  • native/apple/Tests/BaseKitTests/OpenerTests.swift +15 −0
  • native/apple/Tests/BaseSnapshots/LookSnapshots.swift +2 −1
  • native/ios/project.yml +1 −1
diff --git a/native/apple/Package.resolved b/native/apple/Package.resolved
index 726c27e..2d80e2c 100644
--- a/native/apple/Package.resolved
+++ b/native/apple/Package.resolved
@@ -1,5 +1,5 @@
{
- "originHash" : "55be33bf272bf9c9fe2194d79bfbf31b311f59b21e0fc400d3996d6b9e5504f4",
+ "originHash" : "b89733f6728080d7a31ff67ab1761ff7c1b4a71eb609dc96e40a318c497a8a91",
"pins" : [
{
"identity" : "keyboardshortcuts",
@@ -14,7 +14,7 @@
"kind" : "remoteSourceControl",
"location" : "https://amadan.net/rastrillo/native",
"state" : {
- "revision" : "0254817dc9dd118ab271f1120cd2b03c1270a1f9"
+ "revision" : "bb989a7cf3bdb152e1529f6e514d24f249f777ec"
}
},
{
diff --git a/native/apple/Package.swift b/native/apple/Package.swift
index 904f1d1..c594078 100644
--- a/native/apple/Package.swift
+++ b/native/apple/Package.swift
@@ -2,12 +2,12 @@
import PackageDescription
import Foundation
-// rastrillo/native at main (0254817). Task 1's additions (assertion(for:),
-// OficinaApp.base, the ://open handler) arrive with the next pin; nothing
-// here depends on them yet. OFICINA_NATIVE_PACKAGE_PATH points at a local
-// checkout instead, for work on the kit itself.
+// rastrillo/native at main bb989a7, with Base's additions (Task 1):
+// OficinaIDModel.assertion(for:), OficinaApp.base and NativeConnection's
+// ://open. OFICINA_NATIVE_PACKAGE_PATH points at a local checkout instead,
+// for work on the kit itself.
let sharedNative: Package.Dependency = ProcessInfo.processInfo.environment["OFICINA_NATIVE_PACKAGE_PATH"].map { .package(name: "native", path: $0) }
- ?? .package(url: "https://amadan.net/rastrillo/native", revision: "0254817dc9dd118ab271f1120cd2b03c1270a1f9")
+ ?? .package(url: "https://amadan.net/rastrillo/native", revision: "bb989a7cf3bdb152e1529f6e514d24f249f777ec")
let package = Package(
name: "BaseNative",
diff --git a/native/apple/Sources/BaseKit/Session/BaseOpenURL.swift b/native/apple/Sources/BaseKit/Session/BaseOpenURL.swift
new file mode 100644
index 0000000..0453d10
--- /dev/null
+++ b/native/apple/Sources/BaseKit/Session/BaseOpenURL.swift
@@ -0,0 +1,24 @@
+import RastrilloApple
+import SwiftUI
+
+/// Another app asking to open Base: `works.oficina.base://open`, or
+/// `…://open?path=/a/page`, handled by the kit's NativeConnection (its
+/// `onOpen`, Task 1), which holds the path to a page on Base's own origin.
+/// Base comes forward with Ask; a page Base doesn't draw natively (Store,
+/// People) opens on the web.
+@MainActor public final class BaseOpenURL {
+ public static let scheme = "works.oficina.base"
+ private let connection: NativeConnection
+
+ public init(defaults: UserDefaults = UserDefaults(suiteName: "works.oficina.base.open") ?? .standard,
+ showAsk: @escaping @MainActor () -> Void, openWeb: @escaping @MainActor (String) -> Void) {
+ connection = NativeConnection(defaultServer: "https://base.oficina.works", callbackScheme: Self.scheme, defaults: defaults)
+ connection.onOpen = { path in
+ guard let path, path != "/", path != "/ask" else { showAsk(); return }
+ openWeb(path)
+ }
+ }
+
+ /// Hand every URL the app is opened with here; anything else is ignored.
+ public func handle(_ url: URL) { connection.handleOpenURL(url) }
+}
diff --git a/native/apple/Sources/BaseMac/BaseMacApp.swift b/native/apple/Sources/BaseMac/BaseMacApp.swift
index 51e5159..830697a 100644
--- a/native/apple/Sources/BaseMac/BaseMacApp.swift
+++ b/native/apple/Sources/BaseMac/BaseMacApp.swift
@@ -37,6 +37,7 @@ extension KeyboardShortcuts.Name {
var body: some Scene {
Window(BaseText.text("native.sidebar.ask"), id: "main") {
MacRoot(session: session, actions: delegate.actions)
+ .onOpenURL { delegate.openURL.handle($0) }
#if canImport(RastrilloMacUpdates)
.safeAreaInset(edge: .bottom) {
if updater.canInstallPendingUpdate { NativeUpdateNotice(updater: updater).padding(.bottom, 12) }
@@ -86,6 +87,7 @@ struct ColophonCommand: View {
@MainActor final class BaseMacDelegate: NSObject, NSApplicationDelegate {
let session = BaseSession.live()
lazy var actions = MacActions.make(session: session)
+ lazy var openURL = BaseOpenURL(showAsk: MacActions.showMainWindow, openWeb: { [actions] in actions.openWeb($0) })
func applicationDidFinishLaunching(_ notification: Notification) {
KeyboardShortcuts.onKeyUp(for: .askBase) { MacActions.openPanel() }
diff --git a/native/apple/Tests/BaseKitTests/OpenerTests.swift b/native/apple/Tests/BaseKitTests/OpenerTests.swift
index 0b0efb9..b9f92dc 100644
--- a/native/apple/Tests/BaseKitTests/OpenerTests.swift
+++ b/native/apple/Tests/BaseKitTests/OpenerTests.swift
@@ -52,3 +52,18 @@ final class OpenerTests: XCTestCase {
for e in entries where e.id != "timeless-sans" { XCTAssertGreaterThan(e.licenceText.count, 200, e.id) }
}
}
+
+/// The kit's `://open` (Task 1), as Base handles it.
+@MainActor final class OpenURLTests: XCTestCase {
+ func testOpenBringsAskForwardAndAPageOpensOnTheWeb() {
+ var asked = 0
+ var pages: [String] = []
+ let handler = BaseOpenURL(defaults: UserDefaults(suiteName: "OpenURLTests.\(UUID())")!, showAsk: { asked += 1 }, openWeb: { pages.append($0) })
+ handler.handle(URL(string: "works.oficina.base://open")!)
+ handler.handle(URL(string: "works.oficina.base://open?path=/store")!)
+ handler.handle(URL(string: "works.oficina.base://open?path=//evil.example/")!)
+ handler.handle(URL(string: "works.oficina.docs://open")!)
+ XCTAssertEqual(asked, 1)
+ XCTAssertEqual(pages, ["/store"])
+ }
+}
diff --git a/native/apple/Tests/BaseSnapshots/LookSnapshots.swift b/native/apple/Tests/BaseSnapshots/LookSnapshots.swift
index f4299a5..0e184f6 100644
--- a/native/apple/Tests/BaseSnapshots/LookSnapshots.swift
+++ b/native/apple/Tests/BaseSnapshots/LookSnapshots.swift
@@ -1,4 +1,5 @@
import BaseKit
+import RastrilloApple
import Foundation
import RastrilloSnapshots
import SwiftUI
@@ -18,7 +19,7 @@ final class LookSnapshots: XCTestCase {
await assertSnapshots(of: Self.typeCatalog)
}
- static let tint = Color(red: 0x6E / 255, green: 0xE7 / 255, blue: 0xDC / 255)
+ static let tint = OficinaPalette.accent(.base)
@MainActor static var catalog: SnapshotCatalog {
// Nothing here holds text that grows: light and dark at the default
diff --git a/native/ios/project.yml b/native/ios/project.yml
index 697c775..a988e4c 100644
--- a/native/ios/project.yml
+++ b/native/ios/project.yml
@@ -8,7 +8,7 @@ packages:
path: ../apple
RastrilloNative:
url: https://amadan.net/rastrillo/native
- revision: 0254817dc9dd118ab271f1120cd2b03c1270a1f9
+ revision: bb989a7cf3bdb152e1529f6e514d24f249f777ec
settings:
base:
SWIFT_VERSION: '6.0'