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.
Arc parity: AppleScript, with Arc's dictionary (JavaScript off by default)
Victorde695e2a7c2b
diff --git a/Packages/CraCore/Sources/CraCore/SidebarModel.swift b/Packages/CraCore/Sources/CraCore/SidebarModel.swiftindex e43e03a..5b05a9f 100644--- a/Packages/CraCore/Sources/CraCore/SidebarModel.swift+++ b/Packages/CraCore/Sources/CraCore/SidebarModel.swift@@ -525,6 +525,8 @@ public struct AppSettings: Codable, Equatable {public var shareThemeWithWebsites: Bool = true/// Arc's Settings ▸ General "Block Cookie Banners" (CookieBanners), off by default as in Arc.public var blockCookieBanners: Bool = false+ /// Arc's View ▸ Developer ▸ "Allow JavaScript from Apple Events": AppleScript's `execute`, off by default.+ public var allowAppleEventsJavaScript: Bool = false/// Arc's searchSuggestEnabled: the command bar asks the search engine for suggestions/// as you type and fills its rows with them.public var searchSuggestions: Bool = true@@ -736,6 +738,7 @@ extension AppSettings {restoreWindows = try c.decodeIfPresent(Bool.self, forKey: .restoreWindows) ?? trueshareThemeWithWebsites = try c.decodeIfPresent(Bool.self, forKey: .shareThemeWithWebsites) ?? trueblockCookieBanners = try c.decodeIfPresent(Bool.self, forKey: .blockCookieBanners) ?? false+ allowAppleEventsJavaScript = try c.decodeIfPresent(Bool.self, forKey: .allowAppleEventsJavaScript) ?? falsesearchSuggestions = try c.decodeIfPresent(Bool.self, forKey: .searchSuggestions) ?? trueshowSpaceHeaderOnSingleSpace = try c.decodeIfPresent(Bool.self, forKey: .showSpaceHeaderOnSingleSpace) ?? truesharedFavorites = try c.decodeIfPresent(Bool.self, forKey: .sharedFavorites) ?? falsediff --git a/Packages/CraCore/Tests/CraCoreTests/WebsiteAppearanceTests.swift b/Packages/CraCore/Tests/CraCoreTests/WebsiteAppearanceTests.swiftindex 1c884ac..483d51c 100644--- a/Packages/CraCore/Tests/CraCoreTests/WebsiteAppearanceTests.swift+++ b/Packages/CraCore/Tests/CraCoreTests/WebsiteAppearanceTests.swift@@ -11,6 +11,7 @@ struct WebsiteAppearanceTests {#expect(s.websiteAppearance == .automatic)#expect(s.soundEffects)#expect(s.restoreWindows, "Arc restores windows unless told not to")+ #expect(!s.allowAppleEventsJavaScript, "AppleScript runs no JavaScript until it is turned on, as in Arc")}@Test func aChoiceSurvivesASave() throws {diff --git a/Sources/Cra/App/AppDelegate.swift b/Sources/Cra/App/AppDelegate.swiftindex 205b7ac..40a59e8 100644--- a/Sources/Cra/App/AppDelegate.swift+++ b/Sources/Cra/App/AppDelegate.swift@@ -763,6 +763,18 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {// tidy: the divider's Tidy on the window's space, without hovering it; undoTidy: ⌘Z's.if dict["tidy"] != nil { TidyTabsService.shared.tidy(store.focusedSpace(window: main.windowID).id, store: store); return }if dict["undoTidy"] != nil { _ = store.undoTidy(); return }+ // applescript=<source>: an AppleScript run inside Cra (raw «class …» codes address its own+ // dictionary), its result or error logged; no other app, so no Automation prompt.+ // Off the main thread, as a script from another app would be: commands that wait for a+ // page (execute javascript) answer on the main thread.+ if let source = dict["applescript"] {+ Thread.detachNewThread {+ var error: NSDictionary?+ let result = NSAppleScript(source: source)?.executeAndReturnError(&error)+ NSLog("Cra applescript → %@", result?.stringValue ?? result.map { "\($0)" } ?? "error \(error?[NSAppleScript.errorNumber] ?? "") \(error?[NSAppleScript.errorMessage] ?? "")")+ }+ return+ }// captureToEasel=1: the page's screenshot, then the capture menu's New Easel.if let how = dict["captureToEasel"] { main.debugCaptureToEasel(send: how == "send"); return }// settingsPane=max: Settings opened on that pane.@@ -1099,6 +1111,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {item.title = store.isPinnedCollapsed(main.focusedSpaceID) ? "Expand Pinned Tabs" : "Collapse Pinned Tabs"return !main.isStandalonecase "stayOnTop": item.state = main.staysOnTop ? .on : .off+ case "allowAppleEventsJavaScript": item.state = store.settings.allowAppleEventsJavaScript ? .on : .offcase "appearanceAutomatic", "appearanceLight", "appearanceDark":item.state = "appearance" + store.settings.websiteAppearance.title == item.representedObject as? String ? .on : .offcase "copyURLQuote", "savePageAs", "captureFullPage", "capturePortrait", "revealTab": return store.selectedTabID != nil@@ -1311,6 +1324,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {case "showArchive": main.showLibrary(.archive)case "clearArchive": store.clearArchive()case "stayOnTop": main.toggleStayOnTop()+ case "allowAppleEventsJavaScript": store.settings.allowAppleEventsJavaScript.toggle()case "appearanceAutomatic": store.settings.websiteAppearance = .automaticcase "appearanceLight": store.settings.websiteAppearance = .lightcase "appearanceDark": store.settings.websiteAppearance = .dark@@ -1567,6 +1581,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSMenuItemValidation {view.addItem(.separator())let dev = NSMenu(title: "Developer")for id in ["viewSource", "devTools", "inspectElement", "jsConsole"] { dev.addItem(item(id)) }+ dev.addItem(item("allowAppleEventsJavaScript"))dev.addItem(.separator())dev.addItem(item("toggleDeveloperMode"))view.addItem(submenu: dev, title: "Developer")diff --git a/Sources/Cra/App/AppleScripting.swift b/Sources/Cra/App/AppleScripting.swiftnew file mode 100644index 0000000..44cc9a8--- /dev/null+++ b/Sources/Cra/App/AppleScripting.swift@@ -0,0 +1,223 @@+import AppKit+import CraCEF++/// Arc's AppleScript dictionary (Arc 1.172.1's Arc.sdef, the same terms and four-letter codes in+/// resources/Cra.sdef, so scripts and launcher extensions written for Arc work against Cra):+/// windows, their tabs and spaces; make new tab, select, go back/forward, reload, stop, close,+/// focus a space. `execute javascript` runs only while View ▸ Developer ▸ Allow JavaScript from+/// Apple Events is on (off by default, as in Arc). macOS asks before any app may script Cra.++extension AppDelegate {+ @objc func application(_ sender: NSApplication, delegateHandlesKey key: String) -> Bool {+ ["appleScriptWindows", "appleScriptTabs"].contains(key)+ }++ /// The browser windows, front to back.+ @objc var appleScriptWindows: [AppleScriptWindowWrapper] {+ let order = NSApp.orderedWindows+ return mainWindows+ .filter { $0.window?.isVisible == true || $0.window?.isMiniaturized == true }+ .sorted { a, b in (order.firstIndex { $0 === a.window } ?? .max) < (order.firstIndex { $0 === b.window } ?? .max) }+ .map(AppleScriptWindowWrapper.init)+ }++ /// Arc: a write-only collection that makes a Little Arc; here a Little Window.+ @objc var appleScriptTabs: [AppleScriptTabWrapper] { [] }++ @objc func insertInAppleScriptTabs(_ tab: AppleScriptTabWrapper) {+ _ = openLittleWindow(url: tab.pendingURL ?? "")+ }+}++@MainActor+@objc(AppleScriptWindowWrapper)+final class AppleScriptWindowWrapper: NSObject {+ let controller: MainWindowController+ init(_ controller: MainWindowController) { self.controller = controller }+ private var app: AppDelegate? { NSApp.delegate as? AppDelegate }+ private var store: SidebarStore { controller.store }++ @objc var id: String { controller.windowID.uuidString }+ @objc var title: String { controller.window?.title ?? "" }+ @objc var orderedIndex: Int { (app?.appleScriptWindows.firstIndex { $0.controller === controller } ?? 0) + 1 }+ @objc var hasCloseBox: Bool { true }+ @objc var isMiniaturizable: Bool { true }+ @objc var isMiniaturized: Bool {+ get { controller.window?.isMiniaturized ?? false }+ set { newValue ? controller.window?.miniaturize(nil) : controller.window?.deminiaturize(nil) }+ }+ @objc var isResizable: Bool { true }+ @objc var isVisible: Bool {+ get { controller.window?.isVisible ?? false }+ set { newValue ? controller.showWindow(nil) : controller.window?.orderOut(nil) }+ }+ @objc var isZoomable: Bool { true }+ @objc var isZoomed: Bool {+ get { controller.window?.isZoomed ?? false }+ set { if newValue != isZoomed { controller.window?.zoom(nil) } }+ }+ @objc var isIncognito: Bool { controller.isIncognito }+ @objc var mode: String { controller.isIncognito ? "incognito" : "normal" }++ @objc var activeTab: AppleScriptTabWrapper? { controller.selectedTabID.map { AppleScriptTabWrapper(tab: $0, window: self) } }+ @objc var activeSpace: AppleScriptSpaceWrapper? { AppleScriptSpaceWrapper(space: controller.focusedSpaceID, window: self) }++ /// The window's space's tabs, as its sidebar lists them: favorites, pinned, then Today.+ @objc var appleScriptTabs: [AppleScriptTabWrapper] {+ tabIDs(in: controller.focusedSpaceID).map { AppleScriptTabWrapper(tab: $0, window: self) }+ }++ @objc var appleScriptSpaces: [AppleScriptSpaceWrapper] {+ guard !controller.isStandalone else { return [AppleScriptSpaceWrapper(space: controller.focusedSpaceID, window: self)] }+ return store.orderedSpaces.filter { !store.isStandalone(space: $0.id) }.map { AppleScriptSpaceWrapper(space: $0.id, window: self) }+ }++ func tabIDs(in spaceID: UUID) -> [UUID] {+ guard let space = store.space(spaceID) else { return [] }+ return (store.tabs(under: space.favoritesContainerID) + store.tabs(under: space.pinnedContainerID)+ + store.tabs(under: space.todayContainerID)).map(\.id)+ }++ /// make new tab at end of tabs of window 1 with properties {URL:"…"}: a Today tab, opened.+ @objc func insertInAppleScriptTabs(_ tab: AppleScriptTabWrapper) {+ let url = tab.pendingURL ?? ""+ if url.isEmpty { controller.openCommandBar(.newTab); return }+ let item = store.createTab(url: url, in: controller.focusedSpaceID, select: true, window: controller.windowID)+ tab.attach(item.id, window: self)+ }++ @objc func close(_ command: NSScriptCommand) -> Any? {+ controller.window?.performClose(nil)+ return nil+ }++ override var objectSpecifier: NSScriptObjectSpecifier? {+ guard let appDescription = NSApp.classDescription as? NSScriptClassDescription else { return nil }+ return NSUniqueIDSpecifier(containerClassDescription: appDescription, containerSpecifier: nil,+ key: "appleScriptWindows", uniqueID: id)+ }+}++@MainActor+@objc(AppleScriptSpaceWrapper)+final class AppleScriptSpaceWrapper: NSObject {+ let spaceID: UUID+ let window: AppleScriptWindowWrapper+ init(space: UUID, window: AppleScriptWindowWrapper) { (spaceID, self.window) = (space, window) }++ @objc var id: String { spaceID.uuidString }+ @objc var title: String {+ let space = window.controller.store.space(spaceID)+ return window.controller.isBlank ? "This Window" : space?.title ?? ""+ }+ @objc var appleScriptTabs: [AppleScriptTabWrapper] {+ window.tabIDs(in: spaceID).map { AppleScriptTabWrapper(tab: $0, window: window) }+ }++ @objc func focus(_ command: NSScriptCommand) -> Any? {+ window.controller.store.focusSpace(spaceID, window: window.controller.windowID)+ return nil+ }++ override var objectSpecifier: NSScriptObjectSpecifier? {+ guard let container = window.objectSpecifier, let desc = container.keyClassDescription else { return nil }+ return NSUniqueIDSpecifier(containerClassDescription: desc, containerSpecifier: container, key: "appleScriptSpaces", uniqueID: id)+ }+}++@MainActor+@objc(AppleScriptTabWrapper)+final class AppleScriptTabWrapper: NSObject {+ private(set) var tabID: UUID?+ private(set) weak var window: AppleScriptWindowWrapper?+ private var windowRef: AppleScriptWindowWrapper?+ /// What `make new tab with properties {URL:…}` set before the tab exists.+ var pendingURL: String?++ /// Cocoa scripting makes a new one with init() for `make new tab`.+ override init() { super.init() }+ init(tab: UUID, window: AppleScriptWindowWrapper) {+ tabID = tab+ windowRef = window+ super.init()+ self.window = window+ }++ func attach(_ tab: UUID, window: AppleScriptWindowWrapper) {+ tabID = tab+ windowRef = window+ self.window = window+ }++ private var controller: MainWindowController? { window?.controller }+ private var store: SidebarStore? { controller?.store }+ private var item: SidebarItem? { tabID.flatMap { store?.item($0) } }+ private var browser: CraBrowser? { tabID.flatMap { (NSApp.delegate as? AppDelegate)?.runtime(for: $0)?.browser } }++ @objc var id: String { tabID?.uuidString ?? "" }+ @objc var title: String { item?.displayTitle ?? "" }+ @objc var URL: String {+ get { item?.tab?.url ?? pendingURL ?? "" }+ set {+ guard let tabID, let controller else { pendingURL = newValue; return }+ controller.store.updateTab(tabID, url: newValue)+ browser?.loadURL(newValue)+ }+ }+ @objc var loading: Bool { browser?.isLoading ?? false }+ @objc var location: String {+ guard let tabID, let store else { return "unpinned" }+ if store.isFavorite(tabID) { return "topApp" }+ return store.isPinned(tabID) ? "pinned" : "unpinned"+ }++ @objc func select(_ command: NSScriptCommand) -> Any? {+ guard let tabID, let controller else { return nil }+ controller.store.selectTab(tabID, window: controller.windowID)+ controller.showWindow(nil)+ return nil+ }+ @objc func goBack(_ command: NSScriptCommand) -> Any? { browser?.goBack(); return nil }+ @objc func goForward(_ command: NSScriptCommand) -> Any? { browser?.goForward(); return nil }+ @objc func reload(_ command: NSScriptCommand) -> Any? { browser?.reload(); return nil }+ @objc func stopLoading(_ command: NSScriptCommand) -> Any? { browser?.stopLoading(); return nil }+ @objc func close(_ command: NSScriptCommand) -> Any? {+ if let tabID { controller?.closeTab(tabID) }+ return nil+ }++ /// Arc's `execute … javascript "…"`: the result as text. Refused while the Developer menu's+ /// Allow JavaScript from Apple Events is off, and for a tab whose page isn't loaded.+ @objc func executeJavascript(_ command: NSScriptCommand) -> Any? {+ guard store?.settings.allowAppleEventsJavaScript == true else {+ command.scriptErrorNumber = -1723 // errAEAccessorNotFound's neighbour: "access not allowed"+ command.scriptErrorString = "Executing JavaScript through AppleScript is turned off. To turn it on, choose View ▸ Developer ▸ Allow JavaScript from Apple Events in Cra."+ return nil+ }+ guard let js = command.evaluatedArguments?["javascript"] as? String, let browser else {+ command.scriptErrorNumber = -1728+ command.scriptErrorString = "The tab has no page loaded."+ return nil+ }+ guard let params = try? JSONSerialization.data(withJSONObject: ["expression": js, "returnByValue": true, "awaitPromise": true]),+ let json = String(data: params, encoding: .utf8) else { return nil }+ command.suspendExecution()+ browser.sendDevToolsMethod("Runtime.evaluate", params: json) { result, error in+ let o = result.flatMap { try? JSONSerialization.jsonObject(with: Data($0.utf8)) as? [String: Any] }+ let value = (o?["result"] as? [String: Any])?["value"]+ let text: String+ switch value {+ case let s as String: text = s+ case nil: text = error ?? ""+ case let v?: text = (try? JSONSerialization.data(withJSONObject: v, options: [.fragmentsAllowed])).flatMap { String(data: $0, encoding: .utf8) } ?? "\(v)"+ }+ command.resumeExecution(withResult: text)+ }+ return nil+ }++ override var objectSpecifier: NSScriptObjectSpecifier? {+ guard let window, let container = window.objectSpecifier, let desc = container.keyClassDescription else { return nil }+ return NSUniqueIDSpecifier(containerClassDescription: desc, containerSpecifier: container, key: "appleScriptTabs", uniqueID: id)+ }+}diff --git a/Sources/Cra/App/KeyBindings.swift b/Sources/Cra/App/KeyBindings.swiftindex 103af57..50d105d 100644--- a/Sources/Cra/App/KeyBindings.swift+++ b/Sources/Cra/App/KeyBindings.swift@@ -181,6 +181,9 @@ final class KeyBindingRegistry {KeyAction(id: "resetZoom", name: "Zoom to Actual Size", section: .view, shortcuts: [Shortcut("0", cmd)], triggers: ["reset zoom"]),KeyAction(id: "zoomIn", name: "Zoom In", section: .view, shortcuts: [Shortcut("=", cmd), Shortcut("=", cmdShift)]),KeyAction(id: "zoomOut", name: "Zoom Out", section: .view, shortcuts: [Shortcut("-", cmd)]),+ // Arc: View ▸ Developer ▸ Allow JavaScript from Apple Events (AppleScript's `execute`).+ KeyAction(id: "allowAppleEventsJavaScript", name: "Allow JavaScript from Apple Events", section: .none, shortcuts: [],+ triggers: ["applescript", "apple events"], inCommandBar: false),KeyAction(id: "viewSource", name: "View Source", section: .view, shortcuts: [Shortcut("u", cmdOpt)]),KeyAction(id: "devTools", name: "Developer Tools", section: .view, shortcuts: [Shortcut("i", cmdOpt), Shortcut(Shortcut.f12, [])], triggers: ["devtools", "inspect", "console"]),KeyAction(id: "inspectElement", name: "Inspect Elements", section: .view, shortcuts: [Shortcut("c", cmdOpt)], inCommandBar: false),diff --git a/Tests/Scenarios/applescript.scenario b/Tests/Scenarios/applescript.scenarionew file mode 100644index 0000000..024ce09--- /dev/null+++ b/Tests/Scenarios/applescript.scenario@@ -0,0 +1,16 @@+# Arc's AppleScript dictionary (Arc 1.172.1's Arc.sdef, same codes in resources/Cra.sdef): a window's+# active tab is readable, `execute javascript` is refused until View ▸ Developer ▸ Allow JavaScript from+# Apple Events is on (off by default, as in Arc), then runs in the tab. Scripts use raw codes, run inside Cra.+budget rss=700 stalls50=10+cra://open?url=${PAGE}?n=scripted+expect-log loaded 127\.0\.0\.1 \(HTTP 200\)+wait 1+cra://debug?applescript=tell%20current%20application%20to%20get%20%C2%ABclass%20URL%20%C2%BB%20of%20%C2%ABclass%20acTa%C2%BB%20of%20%C2%ABclass%20WiND%C2%BB%201+expect-log Cra applescript → http://127\.0\.0\.1:[0-9]+/page\.html\?n=scripted+cra://debug?applescript=tell%20current%20application%20to%20count%20%C2%ABclass%20tAbB%C2%BB%20of%20%C2%ABclass%20WiND%C2%BB%201+expect-log Cra applescript → .*1+cra://debug?applescript=tell%20current%20application%20to%20%C2%ABevent%20CrSuExJa%C2%BB%20%C2%ABclass%20acTa%C2%BB%20of%20%C2%ABclass%20WiND%C2%BB%201%20given%20%C2%ABclass%20JvSc%C2%BB%3A%226%2A7%22+expect-log Cra applescript → error .*Allow JavaScript from Apple Events+cra://action/allowAppleEventsJavaScript+cra://debug?applescript=tell%20current%20application%20to%20%C2%ABevent%20CrSuExJa%C2%BB%20%C2%ABclass%20acTa%C2%BB%20of%20%C2%ABclass%20WiND%C2%BB%201%20given%20%C2%ABclass%20JvSc%C2%BB%3A%226%2A7%22+expect-log Cra applescript → 42diff --git a/docs/arc-parity.md b/docs/arc-parity.mdindex 773fe51..518b38c 100644--- a/docs/arc-parity.md+++ b/docs/arc-parity.md@@ -25,7 +25,7 @@ or Arc-only service), per CONTRIBUTING.md.| Capture Full Page / Portrait Mode | File, URL-bar menu | done | Portrait: 390 × 844 pt at 3x. || Copy URL without trackers | Copy URL ⇧⌘C ("Copy the current tab's URL without trackers") | done | utm_* and click ids dropped (CleanURL). || Copy URL as Quote | Edit ▸ ⌃⇧⌘C, "Enable Shared Quotes when highlighting text" | done | Arc links to arc.net (cloud); Cra copies a text-fragment link. |-| AppleScript dictionary | Arc.sdef, View ▸ Developer ▸ Allow JavaScript from Apple Events | missing | Raycast and other launchers script Arc through it. |+| AppleScript dictionary | Arc.sdef, View ▸ Developer ▸ Allow JavaScript from Apple Events | done | Arc's terms and codes (resources/Cra.sdef); `execute javascript` only after View ▸ Developer ▸ Allow JavaScript from Apple Events (off by default, as in Arc). || Cast | View ▸ Cast | done | Chrome's Cast bubble (IDC_ROUTE_MEDIA). || Find and Replace, Use Selection to Find, Jump to Selection | Edit ▸ Find | partial | Use Selection to Find and Jump to Selection (⌘J) done; Find and Replace is for Arc's Notes/Easels text, which Cra doesn't have. || Sound effects | Settings ▸ Advanced "Play Arc sound effects" | done | Settings ▸ Advanced ▸ Play Cra sound effects gates the capture shutter. |@@ -126,6 +126,7 @@ in this sweep (Essential Shortcuts window, Library pages).measured live in Arc (names, #RRGGBBAA format, no trace in the page's markup) and fitted to thesemantic palette Arc stores per space.- Edit ▸ Find ▸ Use Selection to Find and Jump to Selection (⌘J).+- AppleScript, Arc's dictionary (Victor's choice, 7 Nov: like Arc, JavaScript off by default).- Settings ▸ Privacy ▸ Block cookie banners (Arc's "Block Cookie Banners", off by default).- Easels, first version: File ▸ New Easel (⌃⇧E) opens a canvas in the tab (EaselBrowser, a pageengine of its own like WebKitBrowser, so sidebar.json is unchanged: the tab's address is@@ -149,6 +150,5 @@ in this sweep (Essential Shortcuts window, Library pages).- Boosts: the offline Arc has no network and a local server is blocked in this session, so its Boosteditor couldn't be put on screen to copy. Needs a site in Arc (Victor's OK to run the real Arc, ora localhost server).-- AppleScript dictionary (a new way for other apps to drive Cra; worth a decision on what it may do,- as for cra:// URLs), window dragging from the top of pages (measured, above), Previews and+- Window dragging from the top of pages (measured, above), Previews andJoin Meeting: not started.diff --git a/resources/Cra.sdef b/resources/Cra.sdefnew file mode 100644index 0000000..eb8e971--- /dev/null+++ b/resources/Cra.sdef@@ -0,0 +1,197 @@+<?xml version="1.0" encoding="UTF-8"?>+<!DOCTYPE dictionary SYSTEM "file://localhost/System/Library/DTDs/sdef.dtd">+<dictionary title="Cra Terminology">+ <!--+ STANDARD SUITE+ -->+ <suite name="Standard Suite" code="core" description="Common classes and commands for all applications.">++ <command name="make" code="corecrel" description="Make a new object.">+ <cocoa class="NSCreateCommand"/>+ <access-group identifier="*"/>+ <parameter name="new" code="kocl" description="The class of the new object." type="type">+ <cocoa key="ObjectClass"/>+ </parameter>+ <parameter name="with properties" code="prdt" type="record" optional="yes" description="The initial values for properties of the object.">+ <cocoa key="KeyDictionary"/>+ </parameter>+ <result description="to the new object" type="specifier"/>+ </command>++ <command name="count" code="corecnte" description="Return the number of elements of a particular class within an object.">+ <cocoa class="NSCountCommand"/>+ <access-group identifier="*"/>+ <direct-parameter description="the object whose elements are to be counted" type="specifier"/>+ <parameter name="each" code="kocl" description="The class of objects to be counted." type="type" optional="yes">+ <cocoa key="ObjectClass"/>+ </parameter>+ <result description="the number of elements" type="integer"/>+ </command>++ <class name="application" code="capp" description="The application's top-level scripting object.">+ <cocoa class="NSApplication"/>+ <element description="The windows contained within this application, ordered front to back." type="window">+ <cocoa key="appleScriptWindows"/>+ </element>+ <property name="name" code="pnam" description="The name of the application." type="text" access="r"/>+ <property name="frontmost" code="pisf" description="Is this the frontmost (active) application?" type="boolean" access="r">+ <cocoa key="isActive"/>+ </property>+ <property name="version" code="vers" description="The version of the application." type="text" access="r"/>+ <responds-to command="quit">+ <cocoa method="handleQuitScriptCommand:"/>+ </responds-to>+ <element description="The tabs associated with this window. This is a write-only collection that allows you to create new Little Window tabs." type="tab" access="w">+ <cocoa key="appleScriptTabs"/>+ </element>+ </class>++ <command name="close" code="coreclos" description="Close">+ <direct-parameter description="The object to execute the command on." type="specifier"/>+ </command>++ <class name="window" code="WiND" description="An application's window" plural="windows">+ <cocoa class="AppleScriptWindowWrapper"/>+ <element description="The tabs contained within this window." type="tab" access="rw">+ <cocoa key="appleScriptTabs"/>+ </element>+ <element description="The spaces accessible within this window." type="space">+ <cocoa key="appleScriptSpaces"/>+ </element>+ <property name="id" code="ID " type="text" access="r"+ description="The unique identifier of the window.">+ <cocoa key="id"/>+ </property>+ <property name="name" code="pnam" type="text" access="r"+ description="The full title of the window.">+ <cocoa key="title"/>+ </property>+ <property name="index" code="pidx" type="integer"+ description="The index of the window, ordered front to back.">+ <cocoa key="orderedIndex"/>+ </property>+ <property name="closeable" code="hclb" description="Whether the window has a close box." type="boolean" access="r">+ <cocoa key="hasCloseBox"/>+ </property>+ <property name="minimizable" code="ismn" description="Whether the window can be minimized." type="boolean" access="r">+ <cocoa key="isMiniaturizable"/>+ </property>+ <property name="minimized" code="pmnd" description="Whether the window is currently minimized." type="boolean">+ <cocoa key="isMiniaturized"/>+ </property>+ <property name="resizable" code="prsz" description="Whether the window can be resized." type="boolean" access="r">+ <cocoa key="isResizable"/>+ </property>+ <property name="visible" code="pvis" description="Whether the window is currently visible." type="boolean">+ <cocoa key="isVisible"/>+ </property>+ <property name="zoomable" code="iszm" description="Whether the window can be zoomed." type="boolean" access="r">+ <cocoa key="isZoomable"/>+ </property>+ <property name="zoomed" code="pzum" description="Whether the window is currently zoomed." type="boolean">+ <cocoa key="isZoomed"/>+ </property>+ <property name="active tab" code="acTa" description="Returns the currently selected tab" type="tab" access="r">+ <cocoa key="activeTab"/>+ </property>+ <property name="active space" code="acSp" description="Returns the currently active space" type="space" access="r">+ <cocoa key="activeSpace"/>+ </property>+ <property name="incognito" code="inco" description="Whether the window is an incognito window." type="boolean">+ <cocoa key="isIncognito"/>+ </property>+ <property name="mode" code="mode" description="Represents the mode of the window which can be 'normal' or 'incognito', can be set only once during creation of the window." type="text">+ <cocoa key="mode"/>+ </property>+ <responds-to command="close">+ <cocoa method="close:"/>+ </responds-to>+ </class>++ <command name="select" code="CrSelect" description="Select the tab.">+ <direct-parameter description="The tab to execute the command in." type="specifier"/>+ </command>++ <command name="go back" code="CrSuBack" description="Go Back (If Possible).">+ <direct-parameter description="The tab to execute the command in." type="specifier"/>+ </command>++ <command name="go forward" code="CrSuFwd " description="Go Forward (If Possible).">+ <direct-parameter description="The tab to execute the command in." type="specifier"/>+ </command>++ <command name="reload" code="CrSuRlod" description="Reload a tab.">+ <direct-parameter description="The tab to execute the command in." type="specifier"/>+ </command>++ <command name="stop" code="CrSustop" description="Stop the current tab from loading.">+ <direct-parameter description="The tab to execute the command in." type="specifier"/>+ </command>++ <command name="execute" code="CrSuExJa" description="Execute a piece of JavaScript in the tab. Off until View ▸ Developer ▸ Allow JavaScript from Apple Events is on.">+ <direct-parameter description="The tab to execute the command in." type="specifier"/>+ <parameter name="javascript" code="JvSc" description="The javascript code to execute." type="text">+ <cocoa key="javascript"/>+ </parameter>+ <result type="text"/>+ </command>++ <class name="tab" code="tAbB" description="A window's tab" plural="tabs">+ <cocoa class="AppleScriptTabWrapper"/>+ <property name="id" code="ID " type="text" access="r" description="The unique identifier of the tab.">+ <cocoa key="id"/>+ </property>+ <property name="title" code="pnam" type="text" access="r" description="The full title of the tab.">+ <cocoa key="title"/>+ </property>+ <property name="URL" code="URL " description="The url of the tab." type="text" access="rw">+ <cocoa key="URL"/>+ </property>+ <property name="loading" code="ldng" description="Is loading?" type="boolean" access="r"/>+ <property name="location" code="loca" description="Represents the location of the tab in the sidebar. Can be 'topApp' (a favorite), 'pinned' or 'unpinned'." type="text">+ <cocoa key="location"/>+ </property>+ <responds-to command="select">+ <cocoa method="select:"/>+ </responds-to>+ <responds-to command="go back">+ <cocoa method="goBack:"/>+ </responds-to>+ <responds-to command="go forward">+ <cocoa method="goForward:"/>+ </responds-to>+ <responds-to command="reload">+ <cocoa method="reload:"/>+ </responds-to>+ <responds-to command="stop">+ <cocoa method="stopLoading:"/>+ </responds-to>+ <responds-to command="execute">+ <cocoa method="executeJavascript:"/>+ </responds-to>+ <responds-to command="close">+ <cocoa method="close:"/>+ </responds-to>+ </class>++ <command name="focus" code="SpaFocus" description="Focus on a space.">+ <direct-parameter description="The space to focus." type="specifier"/>+ </command>++ <class name="space" code="sPaC" description="A space" plural="spaces">+ <cocoa class="AppleScriptSpaceWrapper"/>+ <property name="id" code="ID " type="text" access="r" description="The unique identifier of the space.">+ <cocoa key="id"/>+ </property>+ <property name="title" code="pnam" type="text" access="r" description="The full title of the space.">+ <cocoa key="title"/>+ </property>+ <element description="The tabs contained within this window." type="tab" access="rw">+ <cocoa key="appleScriptTabs"/>+ </element>+ <responds-to command="focus">+ <cocoa method="focus:"/>+ </responds-to>+ </class>+ </suite>+</dictionary>diff --git a/resources/Info.plist b/resources/Info.plistindex 9e27480..e0998c5 100644--- a/resources/Info.plist+++ b/resources/Info.plist@@ -36,6 +36,10 @@<string>14.0</string><key>LSApplicationCategoryType</key><string>public.app-category.productivity</string>+ <key>NSAppleScriptEnabled</key>+ <true/>+ <key>OSAScriptingDefinition</key>+ <string>Cra.sdef</string><key>NSPrincipalClass</key><string>CraApplication</string><key>NSHighResolutionCapable</key>diff --git a/scripts/build.sh b/scripts/build.shindex 27fe058..e58c938 100755--- a/scripts/build.sh+++ b/scripts/build.sh@@ -39,6 +39,8 @@ sed -e "s/__VERSION__/$VERSION/" -e "s/__BUILD__/$BUILD_NUMBER/" resources/Info.[ -n "${CRA_GOOGLE_API_KEY:-}" ] && /usr/libexec/PlistBuddy -c "Add :CraGoogleAPIKey string $CRA_GOOGLE_API_KEY" "$APP/Contents/Info.plist"echo -n "APPL????" > "$APP/Contents/PkgInfo"[ -f resources/AppIcon.icns ] && cp resources/AppIcon.icns "$APP/Contents/Resources/AppIcon.icns"+# The AppleScript dictionary (Arc's, same terms and codes: Info.plist OSAScriptingDefinition).+cp resources/Cra.sdef "$APP/Contents/Resources/Cra.sdef"[ -d resources/web ] && cp -R resources/web "$APP/Contents/Resources/web"[ -d resources/brand ] && cp -R resources/brand "$APP/Contents/Resources/brand"[ -d resources/blocklist ] && cp -R resources/blocklist "$APP/Contents/Resources/blocklist"