Mac App Store build !402

merged merged by cmc on 2026-11-20 08:22 UTC · krz/orgstar:mas-build into main

131 files changed, +5465 −982

Layout: unified · split

CONTRIBUTING.org +100 −8
@@ -3,8 +3,9 @@
33* Status
44
55Design phases 1–7 are built. The Mac app is released as a notarized DMG and a Homebrew
6cask, with Sparkle updates. The iOS and watchOS apps build from the Xcode project for the
7Simulator and for a device signed with your own team, and go to TestFlight and the
6cask, with Sparkle updates; a second, sandboxed build for the Mac App Store is not yet
7released (see /Mac App Store build/). The iOS and watchOS apps build from the Xcode project
8for the Simulator and for a device signed with your own team, and go to TestFlight and the
89[[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][App Store]] with =scripts/release-ios.sh=. Owed: the M1 Air gate run (issue 2) and the VoiceOver
910passes on the Mac and iOS (issues 3 and 4).
1011
@@ -54,12 +55,18 @@ orgstar" action as on the Mac.
5455
5556** In-app purchases
5657
57=ios/Orgstar.storekit= is the StoreKit configuration the "Orgstar iOS" scheme runs with, so
58purchases work in Xcode without App Store Connect. It holds orgstar+
58=ios/Orgstar.storekit= is the StoreKit configuration the "Orgstar iOS" and "Orgstar macOS"
59schemes run with, so purchases work in Xcode without App Store Connect. It holds orgstar+
5960(=sh.krz.orgstar.pro.monthly=, =.yearly=, =.lifetime=) and the consumable tips
60(=sh.krz.orgstar.tip.small=, =.medium=, =.large=, at 0.99, 2.99 and 4.99). Tips are in
61Settings ▸ About orgstar ▸ Support Development, for everyone, and unlock nothing. The Mac app
62has no tips: it is sold outside the App Store and has no StoreKit.
61(=sh.krz.orgstar.tip.small=, =.medium=, =.large=, at 0.99, 2.99 and 4.99). Tips unlock
62nothing. On iOS they are in Settings ▸ About orgstar ▸ Support Development, and in the Mac App
63Store build in Settings ▸ orgstar+, below the plans. The Developer ID Mac app has no StoreKit
64and no tips; orgstar+ there comes with a license key (see /Mac licenses/).
65
66The Mac App Store build has the iOS app's bundle ID, =sh.krz.orgstar=, as a Universal
67Purchase, so it sells the same products at the same prices and a purchase on one platform
68unlocks the other. Nobody is grandfathered in the Mac App Store build: =ProStore.grandfathers=
69is true only on iOS.
6370
6471In App Store Connect, create each tip as a Consumable with the exact product ID, a display
6572name and description in every localization the app has (de, fr, ja, es-ES, pt-BR), a price
@@ -67,6 +74,59 @@ and availability, and a review screenshot of the About screen's Support Developm
6774Submit new in-app purchases with an app version. Changes take up to an hour to reach the
6875sandbox; test there with a Sandbox Apple Account (Settings ▸ Developer on the device).
6976
77* Mac App Store build
78
79The "Orgstar macOS" scheme in =ios/Orgstar.xcodeproj= builds the Mac app for the Mac App
80Store: the same =Sources/Orgstar= with the =APPSTORE= compilation condition, sandboxed, with
81the widgets, Quick Look and Spotlight extensions, and without Sparkle or the =OrgPrograms=
82target. =ios/OrgstarMac= has its =Info.plist=, entitlements and privacy manifest. Choose My Mac
83and Run; it signs with the team set in the project.
84
85=APPSTORE= is set only by the Xcode targets, so =swift build= and =scripts/build-app.sh= build
86the Developer ID app exactly as before. Within the shared packages, the sandbox is detected at
87run time (=Sandbox.isActive=). The manual's Install page lists what the App Store build does
88differently.
89
90The sandboxed app keeps its data in =~/Library/Containers/sh.krz.orgstar/=, and the widgets'
91data in =~/Library/Group Containers/group.sh.krz.orgstar/=. A development build and a Mac App
92Store install share them, as they share the bundle ID. Keep the Developer ID app out of the way
93while testing, since Finder, Quick Look, Spotlight and URL handlers bind to one copy.
94
95Not yet done before the first submission:
96- A smoke test of a signed, sandboxed build: Grant Access… for includes, setup files, tangle
97 and export targets, images, capture, archive and dailies outside the folders (including a
98 picked folder that doesn't contain the one asked for); Can't Open and regranting a folder;
99 files opened from Finder coming back after a relaunch and after a force quit; the
100 configuration folder after a relaunch; =:shebang= tangling setting the mode; Save Elsewhere…
101 for exports; the Import from Emacs pickers; the welcome sheet's iCloud Drive folder.
102- The Mac screenshots (below).
103- The TestFlight group for the Mac app, in App Store Connect.
104- Installing each Mac version over the other, with the results in the manual's Install page.
105
106** Mac screenshots
107
108App Store Connect takes Mac screenshots at 1280x800, 1440x900, 2560x1600 or 2880x1800 pixels.
109The set lives in =ios/AppStore/screenshots/mac/=; the =01-editor.png= there now is 2560x1720
110and is not accepted, so replace it. To take a 2880x1800 set on a Retina display:
111
1121. Run the "Orgstar macOS" scheme. Remove other folders from its sidebar and add
113 =ios/AppStore/demo= with File ▸ Add Folder….
1142. Size the main window to 1440 by 900 points (Terminal needs Accessibility access in System
115 Settings ▸ Privacy & Security):
116 #+BEGIN_SRC sh
117 osascript -e 'tell application "System Events" to tell process "orgstar" to set size of front window to {1440, 900}'
118 #+END_SRC
1193. Set up each shot, then run =screencapture -i -w -o ios/AppStore/screenshots/mac/NN-name.png=
120 and click the window. =-o= leaves out the shadow.
1214. Check the size with =sips -g pixelWidth -g pixelHeight ios/AppStore/screenshots/mac/*.png=.
122
123The demo's dates are around Friday 16 October 2026; in the agenda, Go to Date shows that week.
124Take five shots: =01-editor= (=work.org=, with the sidebar showing), =02-agenda= (the week),
125=03-board= (the agenda's board as kanban columns), =04-tables= (=home.org= and its table) and
126=05-capture= (the capture window with a template). Show nothing the App Store
127build leaves out: no code block results from languages other than Emacs Lisp, no Emacs exports,
128no license key form and no update settings.
129
70130* Mac licenses
71131
72132orgstar+ for Mac comes with GitHub Sponsors: $60 once for a key that doesn't expire, or $5 a
@@ -95,6 +155,18 @@ swift test # all tests
95155ORGSTAR_GATES=1 swift test -c release --filter GateTests # performance gates
96156#+END_SRC
97157
158=swift test= covers the Developer ID build. =APPSTORE= is set only in the Xcode targets, so
159also check that the App Store build and the iOS app compile:
160
161#+BEGIN_SRC sh
162xcodebuild -project ios/Orgstar.xcodeproj -scheme 'Orgstar macOS' -destination 'generic/platform=macOS' \
163 -derivedDataPath .build/xcode CODE_SIGNING_ALLOWED=NO build
164xcodebuild -project ios/Orgstar.xcodeproj -scheme 'Orgstar iOS' -destination 'generic/platform=iOS Simulator' \
165 -derivedDataPath .build/xcode build
166#+END_SRC
167
168There is no CI; run these before committing.
169
98170* Release
99171
100172=scripts/release-mac.sh <version>= builds a universal app, signs it with the
@@ -105,7 +177,17 @@ Set =ORGSTAR_NOTES= to an HTML file of release notes for the appcast, which Spar
105177update window shows, and =ORGSTAR_RELEASE_NOTES= to a Markdown file for the gitbay
106178release. Without them both get the one-line platform note.
107179
108=scripts/release-ios.sh= then archives the =Orgstar iOS= scheme, with its extensions and the
180Each release goes out on three channels, in this order, from the same commit:
181
1821. =scripts/release-mac.sh <version>=, the Developer ID app.
1832. =scripts/release-ios.sh=, the iOS app.
1843. =scripts/release-macos.sh=, the Mac App Store app.
185
186The App Store builds take their version from =MARKETING_VERSION= in =ios/Orgstar.xcodeproj=,
187which every target shares and appstore-kit requires to be the same across them. Set it to
188=<version>= before the release.
189
190=scripts/release-ios.sh= archives the =Orgstar iOS= scheme, with its extensions and the
109191watch app, and uploads it to App Store Connect for TestFlight. It signs automatically with the
110192team's distribution certificate through the Apple ID signed in to Xcode (Xcode ▸ Settings ▸
111193Accounts), so it needs no key of its own. The version is the project's =MARKETING_VERSION=;
@@ -114,6 +196,16 @@ the build number is the commit count, as the Mac's is, so each upload needs a ne
114196The script sources =release-ios.sh= from appstore-kit, checked out beside this repository or
115197at =$APPSTORE_KIT=.
116198
199=scripts/release-macos.sh= does the same for the =Orgstar macOS= scheme, with appstore-kit's
200=platform=macos=, and uploads a =.pkg=. Before archiving it checks that the scheme has
201=APPSTORE= and the bundle ID =sh.krz.orgstar= and that no entitlements file has a temporary
202exception. Before exporting it checks the archive: no Sparkle, no =SU*= keys in =Info.plist=, no
203=NSTask= or =posix_spawn= in any executable, no temporary-exception entitlements, and an
204=embedded.provisionprofile= in the app and each extension. =ORGSTAR_PUBLISH=0= exports the
205=.pkg= to =.build/macos-release= without uploading.
206
207The macOS listing, review notes and TestFlight information are in =ios/AppStore/metadata.md=.
208
117209* App Store header
118210
119211=ios/AppStore/header.conf= sets the product page header's background and screenshots;
Package.swift +5 −2
@@ -53,7 +53,7 @@ let package = Package(
5353 .target(name: "OrgCore"),
5454 .target(name: "OrgDocument", dependencies: ["OrgCore"]),
5555 .target(name: "OrgIndex", dependencies: ["OrgCore", .product(name: "GRDB", package: "GRDB.swift")]),
56 .target(name: "OrgWorkspace", dependencies: ["OrgIndex"]),
56 .target(name: "OrgWorkspace", dependencies: ["OrgCore", "OrgIndex"]),
5757 .target(name: "OrgPresentation", dependencies: ["OrgCore", .product(name: "SwiftMath", package: "SwiftMath")]),
5858 .target(name: "OrgEditorAppKit", dependencies: ["OrgDocument", "OrgPresentation"]),
5959 .target(name: "TreeSitterElisp", path: "Sources/TreeSitterElisp", sources: ["src/parser.c"], cSettings: [.headerSearchPath("src")]),
@@ -93,7 +93,9 @@ let package = Package(
9393 // The watch app and its complications, bundled by scripts/build-watch-app.sh.
9494 .executableTarget(name: "OrgstarWatch", dependencies: ["OrgWatchData"]),
9595 .executableTarget(name: "OrgstarWatchWidgets", dependencies: ["OrgWatchData"]),
96 .executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]),
96 // Babel, Emacs and gnuplot as processes; the Developer ID app alone links it.
97 .target(name: "OrgPrograms", dependencies: ["OrgApp"]),
98 .executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgPrograms", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]),
9799 // The iOS app, bundled by scripts/build-ios-app.sh.
98100 .executableTarget(name: "OrgstarMobile", dependencies: ["OrgApp", "OrgHighlight"]),
99101 // App extensions, bundled into orgstar.app by scripts/build-app.sh.
@@ -112,6 +114,7 @@ let package = Package(
112114 .testTarget(name: "OrgPresentationTests", dependencies: ["OrgPresentation"]),
113115 .testTarget(name: "OrgEditorAppKitTests", dependencies: ["OrgEditorAppKit", "OrgApp"]),
114116 .testTarget(name: "OrgAppTests", dependencies: ["OrgApp", "OrgDocument"]),
117 .testTarget(name: "OrgProgramsTests", dependencies: ["OrgPrograms", "OrgApp", "OrgDocument"]),
115118 .testTarget(name: "OrgHighlightTests", dependencies: ["OrgHighlight", "OrgCore", "OrgPresentation"])
116119 ]
117120)
README.org +29 −17
@@ -10,8 +10,8 @@ iPad. It reads and writes the same plain-text =.org= files Emacs does, and leave
1010byte you didn't change as it was, so Emacs, the Mac app, the iOS app and your sync tool
1111can all work on the same folder.
1212
13[[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][App Store (Mac, iPhone and iPad)]] ·
1314[[https://files.krz.sh/orgstar/][Download for Mac]] ·
14[[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][App Store (iPhone and iPad)]] ·
1515[[https://files.krz.sh/orgstar/][Manual]] ·
1616[[file:ios/AppStore/screenshots][Screenshots]]
1717
@@ -36,8 +36,8 @@ Emacs tomorrow and nothing has been reformatted.
3636- *Tables.* Aligned as you type, with =#+TBLFM= formulas.
3737- *Code blocks.* Run source blocks and tangle them into files, as =org-babel-tangle=
3838 does.
39- *Export.* HTML and Markdown built in; PDF, LaTeX, ODT and more through Emacs when
40 it is installed.
39- *Export.* HTML, Markdown, PDF, Word, RTF and iCalendar built in; PDF through LaTeX, ODT
40 and more through Emacs when it is installed (download version only).
4141- *Search.* Across file names, headings and text, plus Spotlight and Quick Look
4242 previews of =.org= files.
4343
@@ -48,16 +48,25 @@ folders, capture templates, key bindings and agenda views. Settings live in plai
4848under =~/.config/orgstar/=, so they can sit in your dotfiles next to your Emacs config.
4949
5050** Get it
51On the Mac (macOS 26 or later), with Homebrew:
51The Mac app (macOS 26 or later) comes in two versions:
5252
53#+begin_src sh
54brew tap krz/tap https://gitbay.org/krz/homebrew-tap.git
55brew install --cask orgstar
56#+end_src
53- From the [[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][Mac App Store]]. It runs in the App Sandbox and starts no other programs: Emacs
54 Lisp blocks run in orgstar's own interpreter, other languages don't run, and nothing is
55 handed to Emacs. Folders outside the ones you add need your permission once.
56- As a download, signed with a Developer ID and notarized. It runs code blocks in any
57 language installed on the Mac, recalculates the tables and makes the exports orgstar can't
58 do itself in Emacs, and updates itself. Install it with Homebrew:
5759
58or download the notarized DMG from the
59[[https://files.krz.sh/orgstar/][files.krz.sh/orgstar]]. The iPhone and iPad app (iOS 26
60or later), with its Apple Watch app, is on the [[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][App Store]].
60 #+begin_src sh
61 brew tap krz/tap https://gitbay.org/krz/homebrew-tap.git
62 brew install --cask orgstar
63 #+end_src
64
65 or download the DMG from [[https://files.krz.sh/orgstar/][files.krz.sh/orgstar]].
66
67Keep only one of them installed. The manual's Install page lists the differences and how to
68move settings between them. The iPhone and iPad app (iOS 26 or later), with its Apple Watch
69app, is on the [[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][App Store]].
6170
6271** orgstar+
6372Editing, the agenda, capture, clocking, tables, search, and HTML and Markdown export are
@@ -66,17 +75,20 @@ and publishing; encrypting entries (decrypting stays free); org-roam nodes, dail
6675backlinks; widgets, the Apple Watch app and the clock Live Activity; Calendar and Reminders in
6776the agenda; and Shortcuts actions.
6877
69- iPhone and iPad: in-app, $1.99 a month, $19.99 a year or $39.99 once.
70- Mac: by [[https://github.com/sponsors/krazywarez][sponsoring on GitHub]], $60 once for a license key that doesn't expire,
78- iPhone, iPad and the Mac App Store version: in-app, $1.99 a month, $19.99 a year or $39.99
79 once. One purchase covers all three with the same Apple Account.
80- Mac download: by [[https://github.com/sponsors/krazywarez][sponsoring on GitHub]], $60 once for a license key that doesn't expire,
7181 or $5 a month for a key orgstar renews while you sponsor. Sign in with GitHub at
7282 [[https://krz.sh/apps/orgstar/license][krz.sh/apps/orgstar/license]] for the key and enter it in Settings ▸ orgstar+.
7383
74Anyone who installed orgstar before orgstar+ keeps every feature without buying it.
84Anyone who installed the iOS app or the Mac download before orgstar+ keeps every feature
85without buying it.
7586
76On iPhone and iPad, anyone can also leave a one-time tip in Settings ▸ About orgstar. Tips
77unlock nothing.
87On iPhone and iPad, anyone can also leave a one-time tip in Settings ▸ About orgstar, and in
88the Mac App Store version in Settings ▸ orgstar+. Tips unlock nothing.
7889
79To build from source, contribute or release (the Mac app and the App Store), see
90To build from source, contribute or release (the Mac download, the Mac App Store and the iOS
91App Store), see
8092[[file:CONTRIBUTING.org]].
8193
8294Copyright © 2026 Christian Cleberg. All rights reserved; see [[file:LICENSE]].
Sources/OrgApp/AgendaFiles.swift +2 −1
@@ -1,4 +1,5 @@
11import Foundation
2import OrgCore
23
34/// `org-agenda-files` as the `(org-agenda-files)` function reads it: each entry a folder (its
45/// `.org` files not starting with a dot, in name order, not below it), an `.org` file, or a
@@ -9,7 +10,7 @@ public enum AgendaFiles {
910 var out: [String] = []
1011 var seen: Set<String> = []
1112 func expand(_ entry: String, from base: String?) -> String {
12 let path = (entry as NSString).expandingTildeInPath
13 let path = OrgPaths.expandingTilde(entry)
1314 if path.hasPrefix("/") || base == nil { return (path as NSString).standardizingPath }
1415 return ((base! as NSString).appendingPathComponent(path) as NSString).standardizingPath
1516 }
Sources/OrgApp/AgendaSnapshot.swift +12 −8
@@ -204,22 +204,26 @@ public struct AgendaSnapshot: Codable, Equatable, Sendable {
204204
205205 // MARK: - The file
206206
207 /// Use the app group's container on the Mac too. The App Store build sets it at launch, in
208 /// the app and in the widget extension, as both have a provisioning profile there.
209 nonisolated(unsafe) public static var useGroupContainer = false
210
207211 /// `Widgets/agenda.json` in the app group's container; nil without the group. On the Mac,
208 /// in `~/Library/Application Support/Orgstar/Widgets`, which the sandboxed widget extension
209 /// reads by a sandbox exception, as an app group there needs a provisioning profile.
210 public static func file(group: String = CaptureInbox.group) -> URL? {
212 /// unless `useGroupContainer`, in `~/Library/Application Support/Orgstar/Widgets`, which the
213 /// sandboxed widget extension reads by a sandbox exception, as an app group there needs a
214 /// provisioning profile.
215 public static func file(group: String = CaptureInbox.group, inGroup: Bool = useGroupContainer) -> URL? {
211216 #if os(macOS)
212 return macWidgetsFolder.appendingPathComponent("agenda.json")
213 #else
214 FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group)?
215 .appendingPathComponent("Widgets").appendingPathComponent("agenda.json")
217 guard inGroup else { return macWidgetsFolder.appendingPathComponent("agenda.json") }
216218 #endif
219 return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group)?
220 .appendingPathComponent("Widgets").appendingPathComponent("agenda.json")
217221 }
218222
219223 #if os(macOS)
220224 /// From the account's home folder, not a sandbox container's.
221225 static var macWidgetsFolder: URL {
222 let home = getpwuid(getuid())?.pointee.pw_dir.map { String(cString: $0) } ?? NSHomeDirectory()
226 let home = OrgPaths.home
223227 return URL(fileURLWithPath: home).appendingPathComponent("Library/Application Support/Orgstar/Widgets")
224228 }
225229 #endif
Sources/OrgApp/AppStoreCommands.swift added +15
@@ -0,0 +1,15 @@
1import Foundation
2
3/// The commands the Mac App Store build leaves out of the palette and menus: exports that run
4/// Emacs, and attaching by link, which the sandbox doesn't allow.
5public enum AppStoreCommands {
6 public static let hidden: Set<String> = [
7 "app.export.pdf", "app.export.odt", "app.export.latex", "app.export.text",
8 "app.attach.link", "app.attach.symlink",
9 ]
10
11 /// What a key bound to a hidden command runs instead; nil when nothing takes its place.
12 public static func replacement(for id: String) -> String? {
13 id == "app.export.pdf" ? "app.export.print-pdf" : nil
14 }
15}
Sources/OrgApp/CaptureModel.swift +3 −3
@@ -172,14 +172,14 @@ extension DocumentSession {
172172 /// A template's file: absolute, `~/…`, or relative to `root`.
173173 public static func resolve(_ file: String, root: String?) -> String {
174174 if file.hasPrefix("/") { return file }
175 if file.hasPrefix("~") { return (file as NSString).expandingTildeInPath }
176 return ((root ?? NSHomeDirectory()) as NSString).appendingPathComponent(file)
175 if file.hasPrefix("~") { return OrgPaths.expandingTilde(file) }
176 return ((root ?? OrgPaths.home) as NSString).appendingPathComponent(file)
177177 }
178178
179179 /// `%a`: a link to the heading at the caret, as `org-store-link` makes one.
180180 public func captureAnnotation() -> String {
181181 guard let path, self.document != nil else { return "" }
182 let abbreviated = path.hasPrefix(NSHomeDirectory()) ? "~" + path.dropFirst(NSHomeDirectory().count) : Substring(path)
182 let abbreviated = path.hasPrefix(OrgPaths.home) ? "~" + path.dropFirst(OrgPaths.home.count) : Substring(path)
183183 guard let entry = outline.last(where: { $0.start <= caret }) else { return "[[file:\(abbreviated)]]" }
184184 return "[[file:\(abbreviated)::*\(entry.title)][\(entry.title)]]"
185185 }
Sources/OrgApp/ConfigFolder.swift added +42
@@ -0,0 +1,42 @@
1import Foundation
2import OrgCore
3
4/// A configuration folder chosen in the app, kept as a bookmark: on iOS a synced copy of the
5/// Mac's `~/.config/orgstar`, in the Mac sandbox a folder outside the container. The bookmark
6/// is security-scoped in the Mac sandbox and plain elsewhere.
7public enum ConfigFolder {
8 public static let bookmarkKey = "configFolderBookmark"
9
10 /// The chosen folder with access to it started, or nil when none is chosen or its bookmark
11 /// no longer resolves. A stale bookmark is renewed.
12 public static func resolve(defaults: UserDefaults = .standard, sandboxed: Bool = Sandbox.isActive) -> URL? {
13 guard let data = defaults.data(forKey: bookmarkKey) else { return nil }
14 var stale = false
15 guard let url = try? URL(resolvingBookmarkData: data, options: Sandbox.bookmarkResolutionOptions(sandboxed: sandboxed), bookmarkDataIsStale: &stale) else { return nil }
16 _ = url.startAccessingSecurityScopedResource()
17 if stale, let fresh = try? Sandbox.bookmark(url, sandboxed: sandboxed) {
18 defaults.set(fresh, forKey: bookmarkKey)
19 }
20 return url
21 }
22
23 /// Keeps `url`, as from a folder picker, as the chosen folder and starts access to it. False
24 /// when its bookmark can't be made, so the choice isn't kept after the app quits.
25 @discardableResult
26 public static func set(_ url: URL, defaults: UserDefaults = .standard, sandboxed: Bool = Sandbox.isActive) -> Bool {
27 _ = url.startAccessingSecurityScopedResource()
28 guard let bookmark = try? Sandbox.bookmark(url, sandboxed: sandboxed) else { return false }
29 defaults.set(bookmark, forKey: bookmarkKey)
30 return true
31 }
32
33 /// Stops using a chosen folder.
34 public static func clear(defaults: UserDefaults = .standard) {
35 defaults.removeObject(forKey: bookmarkKey)
36 }
37
38 /// `~/.config/orgstar` in the real home folder, where a folder picker starts.
39 public static var suggested: URL {
40 URL(fileURLWithPath: OrgPaths.home).appendingPathComponent(".config/orgstar")
41 }
42}
Sources/OrgApp/ConfigSync.swift +22 −2
@@ -20,7 +20,7 @@ public final class ConfigSync {
2020 /// The last file of the configuration folder that changed, with a serial number.
2121 public private(set) var changedFile: (name: String, serial: Int)?
2222
23 private let url: URL
23 @ObservationIgnored private var url: URL
2424 private let defaults: UserDefaults
2525 @ObservationIgnored private var text: String?
2626 @ObservationIgnored private var configProblems: [String] = []
@@ -28,6 +28,7 @@ public final class ConfigSync {
2828 @ObservationIgnored private var watcher: FSEventsWatcher?
2929 @ObservationIgnored private var observer: NSObjectProtocol?
3030 @ObservationIgnored private var serial = 0
31 @ObservationIgnored private var watches = true
3132
3233 /// Where `url` leads: a symlinked config.toml is written through, not replaced by a file.
3334 private var target: URL { url.resolvingSymlinksInPath() }
@@ -39,6 +40,7 @@ public final class ConfigSync {
3940
4041 public func start(watch: Bool = true) {
4142 guard observer == nil else { return }
43 watches = watch
4244 try? FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
4345 let reference = url.deletingLastPathComponent().appendingPathComponent("default-theme.toml")
4446 if (try? String(contentsOf: reference, encoding: .utf8)) != ThemeSpec.defaultThemeFile() {
@@ -71,7 +73,7 @@ public final class ConfigSync {
7173 let watchesLinked = linked.path != directory.path
7274 // Files still read from where earlier versions kept them reload when edited there too.
7375 let legacy = UserConfig.legacyDirectory.resolvingSymlinksInPath()
74 let watchesLegacy = legacy.path != directory.path && FileManager.default.fileExists(atPath: legacy.path)
76 let watchesLegacy = UserConfig.directoryOverride == nil && legacy.path != directory.path && FileManager.default.fileExists(atPath: legacy.path)
7577 watcher = FSEventsWatcher(roots: [directory] + (watchesLinked ? [linked] : []) + (watchesLegacy ? [legacy] : [])) { [weak self] events in
7678 let changed = Set(events.compactMap { event -> URL? in
7779 if case .changed(let url) = event { return url }
@@ -93,6 +95,24 @@ public final class ConfigSync {
9395 watcher?.start()
9496 }
9597
98 /// Uses `url`, as in another configuration folder, from now on: its settings apply, and a
99 /// missing file is created with the current ones. Does nothing before `start`.
100 public func move(to url: URL) {
101 guard observer != nil, url != self.url else { return }
102 watcher?.stop()
103 watcher = nil
104 if let observer { NotificationCenter.default.removeObserver(observer) }
105 observer = nil
106 text = nil
107 configProblems = []
108 self.url = url
109 start(watch: watches)
110 readTheme()
111 // Windows read keymap.toml once, so they reload it from the new folder.
112 serial += 1
113 changedFile = ("keymap.toml", serial)
114 }
115
96116 /// Reads the file and applies it when it changed since the last read or write.
97117 public func reload() {
98118 guard let new = try? String(contentsOf: url, encoding: .utf8), new != text else { return }
Sources/OrgApp/Dailies.swift +1 −1
@@ -73,7 +73,7 @@ public struct Dailies: Sendable, Equatable {
7373 interval: OrgPreferences.denoteJournalInterval(defaults)))
7474 }
7575 let roam = OrgPreferences.roamDirectory(defaults)
76 guard let base = roam.isEmpty ? roots.first : OrgAttach.expand(roam, in: roots.first ?? NSHomeDirectory()) else { return nil }
76 guard let base = roam.isEmpty ? roots.first : OrgAttach.expand(roam, in: roots.first ?? OrgPaths.home) else { return nil }
7777 return Dailies(directory: OrgAttach.expand(OrgPreferences.dailiesDirectory(defaults), in: base),
7878 file: OrgPreferences.dailiesFile(defaults), head: OrgPreferences.dailiesHead(defaults), entry: OrgPreferences.dailiesEntry(defaults))
7979 }
Sources/OrgApp/DenoteNote.swift +2 −2
@@ -25,12 +25,12 @@ public enum DenoteNote {
2525
2626 static func paths(_ setting: String, roots: [String]) -> [String] {
2727 setting.split(separator: ":").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty }
28 .map { OrgAttach.expand($0, in: roots.first ?? NSHomeDirectory()) }
28 .map { OrgAttach.expand($0, in: roots.first ?? OrgPaths.home) }
2929 }
3030
3131 /// A folder as the folder prompts show it, under `~` when it's in the home folder.
3232 public static func abbreviated(_ path: String) -> String {
33 let home = NSHomeDirectory()
33 let home = OrgPaths.home
3434 return path == home || path.hasPrefix(home + "/") ? "~" + path.dropFirst(home.count) : path
3535 }
3636
Sources/OrgApp/DocumentSession.swift +36 −12
@@ -752,6 +752,12 @@ public final class DocumentSession {
752752 return (TextEdit(range: at..<at, replacement: insertion), newStart, level)
753753 }
754754
755 /// The file `archive(from:now:)` moves the entry to, or nil when it can't tell.
756 public func archiveFile(from: (path: String, offset: Int)? = nil, now: Date = Date()) -> String? {
757 guard let (path, context) = source(from, now: now), case .success(let destination) = Archive.destination(context, sourcePath: path) else { return nil }
758 return destination.path
759 }
760
755761 /// Archives the subtree at the caret, or at `from`, where `org-archive-subtree` would.
756762 /// Returns a message.
757763 @discardableResult
@@ -877,7 +883,13 @@ public final class DocumentSession {
877883 /// Recalculates a table in Emacs from a snapshot of the buffer, then replaces the table
878884 /// with Emacs's text if it hasn't changed meanwhile. Returns a message for the echo area.
879885 public func recalculateInEmacs(table: Range<Int>, point: Int, form: String) async -> String {
880 #if os(macOS)
886 guard let programs = Self.runner else {
887 #if os(macOS)
888 return "Tables that need Emacs aren't recalculated in this version of orgstar."
889 #else
890 return "Tables that need Emacs aren't recalculated on iOS."
891 #endif
892 }
881893 guard let entry = current else { return "No file is open." }
882894 let path = entry.path
883895 let snapshot = entry.buffer.document.text as NSString
@@ -885,7 +897,7 @@ public final class DocumentSession {
885897 let old = snapshot.substring(with: NSRange(table))
886898 let directory = URL(fileURLWithPath: path).deletingLastPathComponent()
887899 do {
888 let new = try await EmacsRunner.recalculateTable(text: snapshot as String, directory: directory, table: table, point: point, form: form)
900 let new = try await programs.recalculateTable(text: snapshot as String, directory: directory, table: table, point: point, form: form)
889901 guard entries.contains(where: { $0 === entry }) else { return "The file was closed before Emacs finished." }
890902 let current = entry.buffer
891903 let text = current.document.text as NSString
@@ -902,9 +914,6 @@ public final class DocumentSession {
902914 } catch {
903915 return "\(error)"
904916 }
905 #else
906 return "Tables that need Emacs aren't recalculated on iOS."
907 #endif
908917 }
909918
910919 /// Runs a src block and writes its result under it, unless the block changed while it
@@ -912,18 +921,22 @@ public final class DocumentSession {
912921 public func runBabel(_ job: BabelJob) async -> String {
913922 guard let entry = current else { return "No file is open." }
914923 let directory = URL(fileURLWithPath: entry.path).deletingLastPathComponent()
915 /// A program on the Mac; on iOS, Emacs Lisp in `Elisp`, and nothing else.
924 let programs = Self.runner
925 /// A program through `programs`; without it, Emacs Lisp in `Elisp`, and nothing else.
916926 func run(_ job: BabelJob) async throws -> BabelOutput {
917 #if os(macOS)
918 return try await BabelRunner.run(job, fileDirectory: directory)
919 #else
927 if let programs { return try await programs.runBabel(job, fileDirectory: directory) }
920928 guard let output = try Babel.evaluateNatively(job) else {
929 #if os(macOS)
930 throw Babel.Failure.message(job.lispForm == nil
931 ? "\(job.language) blocks don't run in this version of orgstar."
932 : "This block uses Emacs Lisp that runs only in Emacs.")
933 #else
921934 throw Babel.Failure.message(job.lispForm == nil
922935 ? "\(job.language) blocks need the Mac to run."
923936 : "This block uses Emacs Lisp that runs only in Emacs, on the Mac.")
937 #endif
924938 }
925939 return output
926 #endif
927940 }
928941 do {
929942 // Blocks the `:var`s refer to run first, one at a time.
@@ -953,8 +966,7 @@ public final class DocumentSession {
953966 let output = try await run(job)
954967 guard entries.contains(where: { $0 === entry }) else { return "The file was closed before the block finished." }
955968 if let file = Babel.fileResult(job, output: output) {
956 let runDirectory = job.directory.map { URL(fileURLWithPath: $0, relativeTo: directory).standardizedFileURL } ?? directory
957 let target = file.path.hasPrefix("/") ? URL(fileURLWithPath: file.path) : runDirectory.appendingPathComponent(file.path)
969 let target = Self.resultFile(file.path, job: job, directory: directory)
958970 do {
959971 try file.contents.write(to: target, atomically: true, encoding: .utf8)
960972 } catch {
@@ -983,6 +995,18 @@ public final class DocumentSession {
983995 }
984996 }
985997
998 /// Where a block's `:file` result goes: relative to `:dir`, itself relative to `directory`.
999 static func resultFile(_ name: String, job: BabelJob, directory: URL) -> URL {
1000 let runDirectory = job.directory.map { URL(fileURLWithPath: $0, relativeTo: directory).standardizedFileURL } ?? directory
1001 return name.hasPrefix("/") ? URL(fileURLWithPath: name) : runDirectory.appendingPathComponent(name)
1002 }
1003
1004 /// The `:file` the block writes its result to, for the open file; nil without one.
1005 public func resultFile(of job: BabelJob) -> String? {
1006 guard let path, let name = job.finish.file else { return nil }
1007 return Self.resultFile(name, job: job, directory: URL(fileURLWithPath: path).deletingLastPathComponent()).path
1008 }
1009
9861010 /// The block running now, to cancel.
9871011 @ObservationIgnored private var babelTask: Task<String, Never>?
9881012 public private(set) var isRunningBabel = false
Sources/OrgApp/EmacsImport.swift +57 −12
@@ -55,6 +55,8 @@ public struct EmacsImport: Sendable {
5555 /// Doom's own org defaults Orgstar has no use for, not listed one by one.
5656 public var doomDefaultsLeftOut = 0
5757 public var isDoom = false
58 /// Doom's own org defaults were found and read.
59 public var doomDefaultsRead = false
5860
5961 // MARK: - Finding the configuration
6062
@@ -71,7 +73,7 @@ public struct EmacsImport: Sendable {
7173
7274 /// Where an Emacs configuration usually is, first found first.
7375 public static func defaultLocations() -> [URL] {
74 let home = URL(fileURLWithPath: NSHomeDirectory())
76 let home = URL(fileURLWithPath: OrgPaths.home)
7577 let environment = ProcessInfo.processInfo.environment
7678 var candidates: [URL] = []
7779 if let doom = environment["DOOMDIR"] { candidates.append(URL(fileURLWithPath: doom)) }
@@ -80,6 +82,19 @@ public struct EmacsImport: Sendable {
8082 return candidates.filter { !files(in: $0).isEmpty && !isDoomInstall($0) }
8183 }
8284
85 /// Where an open panel for the configuration starts: the first configuration found, or the
86 /// home folder.
87 public static func pickerLocation() -> URL {
88 defaultLocations().first ?? URL(fileURLWithPath: OrgPaths.home)
89 }
90
91 /// Where Doom is usually installed, `EMACSDIR` first.
92 public static func doomInstallLocations() -> [URL] {
93 let home = URL(fileURLWithPath: OrgPaths.home)
94 return [ProcessInfo.processInfo.environment["EMACSDIR"]].compactMap { $0 }.map { URL(fileURLWithPath: $0) }
95 + [".config/emacs", ".emacs.d"].map { home.appendingPathComponent($0) }
96 }
97
8398 /// Doom's own source folder, which holds `lisp/doom.el`, isn't a user configuration.
8499 static func isDoomInstall(_ url: URL) -> Bool {
85100 FileManager.default.fileExists(atPath: url.appendingPathComponent("lisp/doom.el").path)
@@ -87,11 +102,13 @@ public struct EmacsImport: Sendable {
87102
88103 /// Doom's org module and core defaults, if Doom is installed.
89104 static func doomDefaultFiles() -> [URL] {
90 let home = URL(fileURLWithPath: NSHomeDirectory())
91 let environment = ProcessInfo.processInfo.environment
92 let installs = ([environment["EMACSDIR"]].compactMap { $0 }.map { URL(fileURLWithPath: $0) })
93 + [".config/emacs", ".emacs.d"].map { home.appendingPathComponent($0) }
94 guard let install = installs.first(where: isDoomInstall) else { return [] }
105 guard let install = doomInstallLocations().first(where: isDoomInstall) else { return [] }
106 return doomDefaultFiles(in: install)
107 }
108
109 /// Doom's org module and core defaults in `install`, Doom's own folder; empty when it isn't one.
110 public static func doomDefaultFiles(in install: URL) -> [URL] {
111 guard isDoomInstall(install) else { return [] }
95112 var files = [install.appendingPathComponent("lisp/doom-emacs.el")]
96113 var moduleRoots = [install.appendingPathComponent("modules")]
97114 if let sources = try? FileManager.default.contentsOfDirectory(at: install.appendingPathComponent("sources"), includingPropertiesForKeys: nil) {
@@ -119,7 +136,10 @@ public struct EmacsImport: Sendable {
119136 result.isDoom = sources.contains { $0.text.contains("(doom!") || $0.text.contains("(map! ") || $0.text.contains("(after! ") }
120137 if result.isDoom {
121138 for url in doomDefaults ?? doomDefaultFiles() {
122 if let text = try? String(contentsOf: url, encoding: .utf8) { sources.insert(("Doom", text, 0), at: 0) }
139 if let text = try? String(contentsOf: url, encoding: .utf8) {
140 sources.insert(("Doom", text, 0), at: 0)
141 result.doomDefaultsRead = true
142 }
123143 }
124144 }
125145 var scanner = Scanner()
@@ -469,7 +489,7 @@ public struct EmacsImport: Sendable {
469489 var folders: Set<String> = []
470490 items.removeAll { item in
471491 guard case .folder(let path) = item.change else { return false }
472 let key = (path as NSString).expandingTildeInPath.trimmingCharacters(in: CharacterSet(charactersIn: "/"))
492 let key = OrgPaths.expandingTilde(path).trimmingCharacters(in: CharacterSet(charactersIn: "/"))
473493 return !folders.insert(key).inserted
474494 }
475495 for binding in scanner.bindings {
@@ -1064,16 +1084,33 @@ public struct EmacsImport: Sendable {
10641084}
10651085
10661086extension EmacsImport {
1087 /// The paths of `items`' folders that aren't in the sidebar yet, as written.
1088 @MainActor
1089 public static func foldersToAdd(_ items: [Item], workspace: WorkspaceModel?) -> [String] {
1090 items.compactMap { item in
1091 guard case .folder(let path) = item.change else { return nil }
1092 let url = URL(fileURLWithPath: OrgPaths.expandingTilde(path)).standardizedFileURL
1093 if let workspace, isRoot(url, in: workspace) { return nil }
1094 return path
1095 }
1096 }
1097
1098 @MainActor
1099 static func isRoot(_ url: URL, in workspace: WorkspaceModel) -> Bool {
1100 workspace.roots.contains { URL(fileURLWithPath: $0.path).standardizedFileURL.path == url.path }
1101 }
1102
10671103 /// Applies `items`: settings to `defaults` (and so config.toml), folders to the workspace,
10681104 /// capture templates and key bindings appended to capture.toml and keymap.toml in
10691105 /// `directory`, leaving out templates whose key is there already and bindings that are
10701106 /// there already. Returns a summary.
10711107 @MainActor
10721108 /// With `writeConfig`, settings and structure templates are written into `config.toml` too,
1073 /// for where nothing syncs user defaults into it (iOS).
1109 /// for where nothing syncs user defaults into it (iOS). With `chosenFolders`, folders chosen in
1110 /// open panels by the path of their item, a folder item is added only as the folder chosen for it.
10741111 public static func apply(
10751112 _ items: [Item], defaults: UserDefaults = .standard, workspace: WorkspaceModel?, directory: URL = UserConfig.directory,
1076 writeConfig: Bool = false
1113 writeConfig: Bool = false, chosenFolders: [String: URL]? = nil
10771114 ) async -> String {
10781115 var stored: [UserConfig.Setting] = []
10791116 var settings = 0, folders = 0, templates = 0, bindings = 0, blocks = 0, views = 0, projects = 0
@@ -1090,12 +1127,20 @@ extension EmacsImport {
10901127 }
10911128 for item in items {
10921129 guard case .folder(let path) = item.change else { continue }
1093 let url = URL(fileURLWithPath: (path as NSString).expandingTildeInPath).standardizedFileURL
1130 var url = URL(fileURLWithPath: OrgPaths.expandingTilde(path)).standardizedFileURL
1131 if let chosenFolders {
1132 if let workspace, Self.isRoot(url, in: workspace) { continue }
1133 guard let chosen = chosenFolders[path] else {
1134 problems.append("\(path) wasn't added")
1135 continue
1136 }
1137 url = chosen.standardizedFileURL
1138 }
10941139 guard let workspace, FileManager.default.fileExists(atPath: url.path) else {
10951140 problems.append("\(path) doesn't exist")
10961141 continue
10971142 }
1098 if workspace.roots.contains(where: { URL(fileURLWithPath: $0.path).standardizedFileURL.path == url.path }) { continue }
1143 if Self.isRoot(url, in: workspace) { continue }
10991144 do {
11001145 try await workspace.addRoot(url)
11011146 folders += 1
Sources/OrgApp/FolderGrants.swift added +68
@@ -0,0 +1,68 @@
1import Foundation
2import OrgCore
3
4/// Bookmarks that give access back after relaunch: security-scoped in the Mac sandbox, plain
5/// elsewhere.
6public enum SecurityBookmark {
7 public static func make(_ url: URL, sandboxed: Bool = Sandbox.isActive) -> Data? {
8 try? Sandbox.bookmark(url, sandboxed: sandboxed)
9 }
10
11 /// The bookmarked URL with access to it started, and new data when the bookmark was stale.
12 public static func resolve(_ data: Data, sandboxed: Bool = Sandbox.isActive) -> (url: URL, renewed: Data?)? {
13 var stale = false
14 guard let url = try? URL(resolvingBookmarkData: data, options: Sandbox.bookmarkResolutionOptions(sandboxed: sandboxed), bookmarkDataIsStale: &stale) else { return nil }
15 _ = url.startAccessingSecurityScopedResource()
16 return (url, stale ? make(url, sandboxed: sandboxed) : nil)
17 }
18}
19
20/// Folders outside the sidebar's folders that the Mac sandbox let orgstar into through an open
21/// panel: setup files, includes, tangle and export targets and the like. Kept as bookmarks and
22/// started when the store is first used.
23@MainActor
24public final class FolderGrants {
25 public static let shared = FolderGrants()
26 static let key = "folderGrants"
27
28 private let defaults: UserDefaults
29 private let sandboxed: Bool
30 /// The granted folders, with access started.
31 public private(set) var folders: [URL] = []
32
33 init(defaults: UserDefaults = .standard, sandboxed: Bool = Sandbox.isActive) {
34 self.defaults = defaults
35 self.sandboxed = sandboxed
36 let saved = defaults.array(forKey: Self.key) as? [Data] ?? []
37 var kept: [Data] = []
38 for data in saved {
39 // One that doesn't resolve now (an unmounted volume) is kept for later.
40 guard let (url, renewed) = SecurityBookmark.resolve(data, sandboxed: sandboxed) else {
41 kept.append(data)
42 continue
43 }
44 folders.append(url)
45 kept.append(renewed ?? data)
46 }
47 if kept != saved { defaults.set(kept, forKey: Self.key) }
48 }
49
50 /// Keeps `url`, a folder from an open panel, and starts access to it. False when its
51 /// bookmark can't be made, so access lasts only until the app quits.
52 @discardableResult
53 public func add(_ url: URL) -> Bool {
54 _ = url.startAccessingSecurityScopedResource()
55 guard !folders.contains(where: { $0.standardizedFileURL == url.standardizedFileURL }) else { return true }
56 folders.append(url)
57 guard let data = SecurityBookmark.make(url, sandboxed: sandboxed) else { return false }
58 defaults.set((defaults.array(forKey: Self.key) as? [Data] ?? []) + [data], forKey: Self.key)
59 return true
60 }
61
62 /// Whether `granted` is `folder` or contains it.
63 public nonisolated static func covers(_ granted: URL, _ folder: URL) -> Bool {
64 let outer = granted.resolvingSymlinksInPath().standardizedFileURL.path
65 let inner = folder.resolvingSymlinksInPath().standardizedFileURL.path
66 return inner == outer || inner.hasPrefix(outer == "/" ? "/" : outer + "/")
67 }
68}
Sources/OrgApp/ImageYank.swift +2 −2
@@ -48,13 +48,13 @@ public enum ImageYank {
4848 /// file's folder, else absolute with `~` for the home folder.
4949 static func fileLink(_ path: String, from orgPath: String) -> String {
5050 let folder = (orgPath as NSString).deletingLastPathComponent + "/"
51 let target = path.hasPrefix(folder) ? String(path.dropFirst(folder.count)) : (path as NSString).abbreviatingWithTildeInPath
51 let target = path.hasPrefix(folder) ? String(path.dropFirst(folder.count)) : OrgPaths.abbreviatingWithTilde(path)
5252 return "[[file:\(target)]]"
5353 }
5454
5555 /// The folder a `directory` method names, made if missing.
5656 static func folder(_ dir: String, for entry: Attachments.Entry) throws -> String {
57 let folder = OrgAttach.expand((dir as NSString).expandingTildeInPath, in: (entry.path as NSString).deletingLastPathComponent)
57 let folder = OrgAttach.expand(OrgPaths.expandingTilde(dir), in: (entry.path as NSString).deletingLastPathComponent)
5858 try FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: true)
5959 return folder
6060 }
Sources/OrgApp/LinkFollow.swift +2 −2
@@ -83,9 +83,9 @@ extension DocumentSession {
8383
8484 /// A file link's path against the open file's folder, as Org resolves relative links.
8585 public static func resolve(_ path: String, from current: String?) -> String {
86 let expanded = (path as NSString).expandingTildeInPath
86 let expanded = OrgPaths.expandingTilde(path)
8787 if expanded.hasPrefix("/") { return (expanded as NSString).standardizingPath }
88 let folder = current.map { ($0 as NSString).deletingLastPathComponent } ?? NSHomeDirectory()
88 let folder = current.map { ($0 as NSString).deletingLastPathComponent } ?? OrgPaths.home
8989 return ((folder as NSString).appendingPathComponent(expanded) as NSString).standardizingPath
9090 }
9191
Sources/OrgApp/OrgPreferences.swift +1 −1
@@ -221,7 +221,7 @@ public enum OrgPreferences {
221221 }
222222 /// `org-icalendar-combined-agenda-file`, `~` expanded.
223223 public static func icalendarCombinedFile(_ defaults: UserDefaults = .standard) -> String {
224 (string("icalendarCombinedAgendaFile", defaults) as NSString).expandingTildeInPath
224 OrgPaths.expandingTilde(string("icalendarCombinedAgendaFile", defaults))
225225 }
226226 /// `org-stuck-projects`.
227227 public static func stuckProjects(_ defaults: UserDefaults = .standard) -> StuckProjects {
Sources/OrgApp/PDFExport.swift +55 −3
@@ -1,5 +1,7 @@
11import Foundation
2import OrgCore
23import PDFKit
4import UniformTypeIdentifiers
35import WebKit
46#if os(macOS)
57import AppKit
@@ -39,6 +41,53 @@ public enum PDFExport {
3941 return printCSS.replacingOccurrences(of: "</style>", with: "body { font-family: \"\(family)\", -apple-system, sans-serif; }\n</style>")
4042 }
4143
44 /// `html` with each `<img>` that names a local file given that file as a `data:` URI.
45 /// Relative paths are read from `directory`; files that can't be read keep their `src`.
46 nonisolated static func inliningImages(_ html: String, directory: URL?) -> String {
47 let pattern = /(<img\b[^>]*?\bsrc=")([^"]*)(")/
48 return html.replacing(pattern) { match in
49 let (_, before, src, after) = match.output
50 guard let uri = dataURI(String(src), directory: directory) else { return String(match.output.0) }
51 return before + uri + after
52 }
53 }
54
55 /// The local files the `<img>` tags of `html` name.
56 public nonisolated static func imageFiles(_ html: String, directory: URL?) -> [String] {
57 var paths: [String] = []
58 for match in html.matches(of: /<img\b[^>]*?\bsrc="([^"]*)"/) {
59 if let path = imageURL(String(match.output.1), directory: directory)?.path, !paths.contains(path) { paths.append(path) }
60 }
61 return paths
62 }
63
64 /// The file an `<img src>` names, as a `data:` URI; nil for remote or unreadable images.
65 nonisolated static func dataURI(_ src: String, directory: URL?) -> String? {
66 guard let url = imageURL(src, directory: directory), let data = try? Data(contentsOf: url) else { return nil }
67 let type = UTType(filenameExtension: url.pathExtension)?.preferredMIMEType ?? "application/octet-stream"
68 return "data:\(type);base64,\(data.base64EncodedString())"
69 }
70
71 /// The local file an `<img src>` names; nil for remote images.
72 nonisolated static func imageURL(_ src: String, directory: URL?) -> URL? {
73 let path = src.replacingOccurrences(of: "&quot;", with: "\"").replacingOccurrences(of: "&lt;", with: "<")
74 .replacingOccurrences(of: "&gt;", with: ">").replacingOccurrences(of: "&amp;", with: "&")
75 let url: URL
76 if path.hasPrefix("file://") {
77 guard let parsed = URL(string: path) else { return nil }
78 url = parsed
79 } else if path.hasPrefix("/") {
80 url = URL(fileURLWithPath: path)
81 } else if path.hasPrefix("~/") {
82 url = URL(fileURLWithPath: OrgPaths.expandingTilde(path))
83 } else if !path.contains(":"), let directory {
84 url = directory.appendingPathComponent(path)
85 } else {
86 return nil
87 }
88 return url
89 }
90
4291 /// Each page's number, centred in its bottom margin, as an annotation: drawing it into the
4392 /// page would mean drawing the page again and losing WebKit's links.
4493 static func numberPages(_ data: Data, margin: Int) -> Data {
@@ -85,14 +134,17 @@ public enum PDFExport {
85134 webView.navigationDelegate = loader
86135 #if os(macOS)
87136 webView.appearance = NSAppearance(named: .aqua)
88 // A file beside nothing the user owns, readable with the images it links to.
137 // A file beside nothing the user owns, readable with the images it links to. In the
138 // sandbox WebKit's own process can't read the user's folders, so the images go in the page.
139 let sandboxed = Sandbox.isActive
89140 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-pdf-\(UUID().uuidString)")
90141 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
91142 defer { try? FileManager.default.removeItem(at: folder) }
92143 let file = folder.appendingPathComponent("page.html")
93 let based = directory.map { page.replacingOccurrences(of: "<head>", with: "<head>\n<base href=\"\($0.absoluteString)\">") } ?? page
144 let source = sandboxed ? inliningImages(page, directory: directory) : page
145 let based = directory.map { source.replacingOccurrences(of: "<head>", with: "<head>\n<base href=\"\($0.absoluteString)\">") } ?? source
94146 try based.write(to: file, atomically: true, encoding: .utf8)
95 webView.loadFileURL(file, allowingReadAccessTo: URL(fileURLWithPath: "/"))
147 webView.loadFileURL(file, allowingReadAccessTo: sandboxed ? folder : URL(fileURLWithPath: "/"))
96148 #else
97149 webView.overrideUserInterfaceStyle = .light
98150 webView.loadHTMLString(page, baseURL: directory)
Sources/OrgApp/PlotChart.swift +4 −46
@@ -216,13 +216,15 @@ struct Wireframe: View {
216216public enum PlotOutput {
217217 public struct Failure: Error, CustomStringConvertible {
218218 public let description: String
219
220 public init(description: String) { self.description = description }
219221 }
220222
221223 /// `file:` relative to the Org file's folder.
222224 public static func file(_ plot: TablePlot.Plot, directory: URL?) -> URL? {
223225 guard let name = plot.options.file, !name.isEmpty else { return nil }
224 let expanded = (name as NSString).expandingTildeInPath
225 return expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : (directory ?? URL(fileURLWithPath: NSHomeDirectory())).appendingPathComponent(expanded)
226 let expanded = OrgPaths.expandingTilde(name)
227 return expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : (directory ?? URL(fileURLWithPath: OrgPaths.home)).appendingPathComponent(expanded)
226228 }
227229
228230 /// The chart as gnuplot's default 640×480, as PNG, JPEG or PDF by the file's extension.
@@ -254,48 +256,4 @@ public enum PlotOutput {
254256 throw Failure(description: "Without gnuplot, plots are written as .png, .jpg or .pdf, not .\(url.pathExtension)")
255257 }
256258 }
257
258 #if os(macOS)
259 /// gnuplot on the `PATH` Babel uses, when installed.
260 public static var gnuplot: URL? {
261 let path = BabelRunner.environment["PATH"] ?? "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
262 return path.split(separator: ":").map { URL(fileURLWithPath: String($0)).appendingPathComponent("gnuplot") }
263 .first { FileManager.default.isExecutableFile(atPath: $0.path) }
264 }
265
266 /// `org-plot/gnuplot` through gnuplot: the data file and script org-plot writes, run with
267 /// the output at `file:`, or a PNG for showing when there's none. Returns the image.
268 public static func runGnuplot(_ plot: TablePlot.Plot, directory: URL?, gnuplot: URL) async throws -> URL {
269 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-plot-\(UUID().uuidString)")
270 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
271 let dataFile = folder.appendingPathComponent("data.tsv")
272 var plot = plot
273 let output = file(plot, directory: directory) ?? folder.appendingPathComponent("plot.png")
274 if plot.options.file == nil { plot.options.values["file"] = .string(output.path) }
275 let (data, labels): (String, [(Int, String)]) = plot.options.type == "grid" ? TablePlot.gridData(plot) : (TablePlot.data(plot), [])
276 try data.write(to: dataFile, atomically: true, encoding: .utf8)
277 var script = TablePlot.script(plot, dataFile: dataFile.path, output: output.path, yLabels: labels)
278 if let custom = plot.options["script"]?.description {
279 let path = (custom as NSString).expandingTildeInPath
280 let url = path.hasPrefix("/") ? URL(fileURLWithPath: path) : (directory ?? folder).appendingPathComponent(path)
281 guard let text = try? String(contentsOf: url, encoding: .utf8) else { throw Failure(description: "Can't read \(custom)") }
282 script = TablePlot.script(plot, dataFile: dataFile.path, output: output.path, yLabels: labels, preface: true)
283 + "\n" + text.replacingOccurrences(of: "$datafile", with: dataFile.path)
284 }
285 let scriptFile = folder.appendingPathComponent("plot.gp")
286 try script.write(to: scriptFile, atomically: true, encoding: .utf8)
287 let process = Process()
288 process.executableURL = gnuplot
289 process.arguments = [scriptFile.path]
290 process.currentDirectoryURL = directory
291 let errors = Pipe()
292 process.standardError = errors
293 try process.run()
294 while process.isRunning { try await Task.sleep(for: .milliseconds(50)) }
295 guard process.terminationStatus == 0 else {
296 throw Failure(description: "gnuplot: " + String(decoding: errors.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines))
297 }
298 return output
299 }
300 #endif
301259}
Sources/OrgApp/ProStore.swift added +160
@@ -0,0 +1,160 @@
1#if canImport(StoreKit)
2import Foundation
3import Observation
4import StoreKit
5
6/// orgstar+ from the App Store: a monthly or yearly subscription, or a lifetime purchase. It
7/// keeps `ProAccess.shared` current; iOS installs from before Pro keep it without buying.
8@MainActor @Observable
9public final class ProStore {
10 public static let shared = ProStore()
11
12 public static let monthly = "sh.krz.orgstar.pro.monthly"
13 public static let yearly = "sh.krz.orgstar.pro.yearly"
14 public static let lifetime = "sh.krz.orgstar.pro.lifetime"
15 public static let productIDs = [monthly, yearly, lifetime]
16
17 /// Whether downloads from before Pro keep it free. Only on iOS; the Mac App Store app never
18 /// grandfathers.
19 public static let grandfathers: Bool = {
20 #if os(iOS)
21 true
22 #else
23 false
24 #endif
25 }()
26
27 /// How much a yearly price saves against twelve monthly ones, in whole percent, or nil when
28 /// it saves nothing.
29 public nonisolated static func yearlySavings(yearly: Decimal, monthly: Decimal) -> Int? {
30 guard monthly > 0 else { return nil }
31 let ratio = NSDecimalNumber(decimal: yearly / (monthly * 12)).doubleValue
32 let percent = Int((1 - ratio) * 100)
33 return percent > 0 ? percent : nil
34 }
35
36 public private(set) var products: [Product] = []
37 public private(set) var activeProductID: String?
38 public private(set) var busy = false
39 public private(set) var isLoading = false
40 public var message: String?
41
42 @ObservationIgnored private var updates: Task<Void, Never>?
43 @ObservationIgnored private var expiry: Task<Void, Never>?
44
45 private init() {}
46
47 /// Starts listening for transactions and checks what's owned. Call once at launch, and only
48 /// from App Store builds: it sets the grant from StoreKit alone, replacing a license grant.
49 public func start() {
50 guard updates == nil else { return }
51 updates = Task.detached(priority: .background) {
52 for await result in Transaction.updates {
53 guard case .verified(let transaction) = result else { continue }
54 await transaction.finish()
55 await ProStore.shared.refresh()
56 }
57 }
58 Task { await refresh() }
59 }
60
61 public func loadProducts() async {
62 guard products.count < Self.productIDs.count, !isLoading else { return }
63 isLoading = true
64 message = nil
65 defer { isLoading = false }
66 do {
67 let fetched = try await Product.products(for: Self.productIDs)
68 products = Self.productIDs.compactMap { id in fetched.first { $0.id == id } }
69 if products.count < Self.productIDs.count {
70 message = String(localized: "Some plans aren't available from the App Store right now.")
71 }
72 } catch {
73 message = String(localized: "The App Store can't be reached right now.")
74 }
75 }
76
77 /// Sets Pro from the current entitlements, or from the original download predating Pro.
78 public func refresh() async {
79 var active: String?
80 var expires: Date?
81 for await result in Transaction.currentEntitlements {
82 guard case .verified(let transaction) = result, Self.productIDs.contains(transaction.productID),
83 transaction.revocationDate == nil else { continue }
84 if active == nil || transaction.productID == Self.lifetime { active = transaction.productID }
85 if let date = transaction.expirationDate { expires = max(expires ?? date, date) }
86 }
87 activeProductID = active
88 #if os(macOS)
89 refresh(at: active == Self.lifetime ? nil : expires)
90 #endif
91 if active != nil {
92 ProAccess.shared.set(.purchase)
93 } else if await Self.predatesPro() {
94 ProAccess.shared.set(.grandfathered)
95 } else if ProAccess.shared.grant != .grandfathered {
96 // A cached grandfathered grant survives the App Store being unreachable.
97 ProAccess.shared.set(nil)
98 }
99 }
100
101 #if os(macOS)
102 /// Checks again when a subscription runs out, since StoreKit sends no update for a lapse and
103 /// the Mac app can stay open for weeks.
104 private func refresh(at date: Date?) {
105 expiry?.cancel()
106 expiry = nil
107 guard let date, date > .now else { return }
108 expiry = Task {
109 try? await Task.sleep(for: .seconds(date.timeIntervalSinceNow + 1))
110 guard !Task.isCancelled else { return }
111 // A new task, so cancelling this one can't cut the entitlement check short.
112 Task { await ProStore.shared.refresh() }
113 }
114 }
115 #endif
116
117 /// Whether this Apple Account first downloaded orgstar before Pro. Only the production App
118 /// Store reports real original versions; sandbox and Xcode always say "1.0".
119 private static func predatesPro() async -> Bool {
120 guard grandfathers, case .verified(let app) = try? await AppTransaction.shared, app.environment == .production else { return false }
121 return Grandfathering.predatesPro(originalBuild: app.originalAppVersion)
122 }
123
124 public func buy(_ product: Product) async {
125 busy = true
126 defer { busy = false }
127 message = nil
128 do {
129 switch try await product.purchase() {
130 case .success(.verified(let transaction)):
131 await transaction.finish()
132 await refresh()
133 case .success(.unverified):
134 message = "The App Store couldn't verify the purchase."
135 case .pending:
136 message = "The purchase is waiting for approval."
137 case .userCancelled:
138 break
139 @unknown default:
140 break
141 }
142 } catch {
143 message = "The purchase didn't go through. \(error.localizedDescription)"
144 }
145 }
146
147 public func restore() async {
148 busy = true
149 defer { busy = false }
150 message = nil
151 do {
152 try await AppStore.sync()
153 await refresh()
154 if !ProAccess.shared.isUnlocked { message = "No orgstar+ purchase was found for this Apple Account." }
155 } catch {
156 message = "Restore didn't finish. \(error.localizedDescription)"
157 }
158 }
159}
160#endif
Sources/OrgApp/ProgramRunning.swift added +21
@@ -0,0 +1,21 @@
1import Foundation
2import OrgCore
3
4/// Runs Babel jobs and Emacs as processes, for an app allowed to start them.
5public protocol ProgramRunning: Sendable {
6 /// Runs `job` in `fileDirectory`, or its `:dir`.
7 func runBabel(_ job: BabelJob, fileDirectory: URL) async throws -> BabelOutput
8 /// Runs `form` in Emacs on a copy of `text`; returns the table that starts at `table.lowerBound`.
9 func recalculateTable(text: String, directory: URL, table: Range<Int>, point: Int, form: String) async throws -> String
10}
11
12extension DocumentSession {
13 /// The runner for programs, set at launch by an app that may start them. Without one,
14 /// only what runs natively runs.
15 public static var programs: (any ProgramRunning)?
16
17 /// Overrides `programs` for the current task and the tasks it starts.
18 @TaskLocal public static var scopedPrograms: (any ProgramRunning)?
19
20 static var runner: (any ProgramRunning)? { scopedPrograms ?? programs }
21}
Sources/OrgApp/Publish.swift +2 −2
@@ -91,8 +91,8 @@ public enum Publish {
9191 /// Absolute, `~/…`, or relative to `root`.
9292 static func resolve(_ path: String, root: String?) -> String {
9393 if path.hasPrefix("/") { return path }
94 if path.hasPrefix("~") { return (path as NSString).expandingTildeInPath }
95 return ((root ?? NSHomeDirectory()) as NSString).appendingPathComponent(path)
94 if path.hasPrefix("~") { return OrgPaths.expandingTilde(path) }
95 return ((root ?? OrgPaths.home) as NSString).appendingPathComponent(path)
9696 }
9797
9898 public struct Failure: Error, Equatable, CustomStringConvertible {
Sources/OrgApp/RefileTargets.swift +1 −1
@@ -185,7 +185,7 @@ extension WorkspaceModel {
185185 case .paths(let list):
186186 let base = openPath.map { ($0 as NSString).deletingLastPathComponent } ?? rootPaths.first
187187 paths = list.map { entry in
188 let path = (entry as NSString).expandingTildeInPath
188 let path = OrgPaths.expandingTilde(entry)
189189 return ((path.hasPrefix("/") || base == nil ? path : (base! as NSString).appendingPathComponent(path)) as NSString).standardizingPath
190190 }
191191 }
Sources/OrgApp/RoamActions.swift +7
@@ -21,6 +21,9 @@ public struct RoamActions {
2121 public var insertLink: (_ link: String, _ title: String) -> Void
2222 /// The index reads new files.
2323 public var refresh: () -> Void
24 /// In the Mac sandbox, asks for access to folders outside the sidebar's that new notes go
25 /// in. False when one is still out of reach.
26 public var reachFolders: ([String]) -> Bool = { _ in true }
2427
2528 public init(
2629 session: DocumentSession, roots: @escaping () -> [String], nodes: @escaping () -> [IndexStore.Node], show: @escaping (String) -> Void,
@@ -126,6 +129,7 @@ public struct RoamActions {
126129 /// `org-roam-dailies-goto-*`: the day's file, made if missing.
127130 func goto(_ day: Date) {
128131 guard let dailies else { return show("No folder for daily notes") }
132 guard reachFolders([dailies.directory]) else { return }
129133 do {
130134 let (path, created) = try dailies.ensure(day)
131135 if created { refresh() }
@@ -139,6 +143,7 @@ public struct RoamActions {
139143 /// which opens with the caret at `%?`.
140144 func capture(_ day: Date) {
141145 guard let dailies else { return show("No folder for daily notes") }
146 guard reachFolders([dailies.directory]) else { return }
142147 let context = CaptureContext(now: day, file: session.path ?? "", userName: NSFullUserName())
143148 let questions = Capture.questions(dailies.entry, context: context)
144149 func ask(_ answers: [String]) {
@@ -193,6 +198,7 @@ public struct RoamActions {
193198 guard !title.isEmpty else { return }
194199 if denote || silo != nil { return createDenote(title, known: all, silo: silo, then) }
195200 guard let folder = RoamNode.directory(roots: roots()) else { return show("No folder for new nodes") }
201 guard reachFolders([folder]) else { return }
196202 do {
197203 let node = try RoamNode.create(title: title, in: folder)
198204 refresh()
@@ -240,6 +246,7 @@ public struct RoamActions {
240246 var answers = answers
241247 switch prompts.first {
242248 case nil:
249 guard reachFolders([answers.folder ?? root]) else { return }
243250 do {
244251 let note = try DenoteNote.create(title: title, keywords: answers.keywords, in: answers.folder ?? root, roots: roots,
245252 now: answers.date ?? Date(), signature: answers.signature, template: answers.template)
Sources/OrgApp/RoamNode.swift +1 −1
@@ -8,7 +8,7 @@ public enum RoamNode {
88 /// `org-roam-directory`: the setting, else the first folder.
99 public static func directory(roots: [String], defaults: UserDefaults = .standard) -> String? {
1010 let roam = OrgPreferences.roamDirectory(defaults)
11 return roam.isEmpty ? roots.first : OrgAttach.expand(roam, in: roots.first ?? NSHomeDirectory())
11 return roam.isEmpty ? roots.first : OrgAttach.expand(roam, in: roots.first ?? OrgPaths.home)
1212 }
1313
1414 /// `org-roam-node-slugify`: without the combining marks org-roam drops, everything but
Sources/OrgApp/TangleWriter.swift +16 −2
@@ -3,7 +3,7 @@ import OrgCore
33
44/// Writes what `Tangle.run` produced, as `org-babel-tangle` does: a file whose contents
55/// haven't changed is left alone, `:mkdirp` makes its folder, a read-only file is replaced,
6/// and the mode is set after writing.
6/// and the mode is set after writing. A mode that can't be set doesn't stop the others.
77public enum TangleWriter {
88 public struct Failure: Error, Equatable {
99 public let message: String
@@ -14,6 +14,7 @@ public enum TangleWriter {
1414 public static func write(_ output: Tangle.Output, source: String) throws(Failure) -> [String] {
1515 let manager = FileManager.default
1616 var paths: [String] = []
17 var modeFailure: Failure?
1718 for file in output.files {
1819 let url = URL(fileURLWithPath: file.path)
1920 let data = Data(file.contents.utf8)
@@ -37,12 +38,19 @@ public enum TangleWriter {
3738 }
3839 do {
3940 try data.write(to: url)
40 if let mode = file.mode { try manager.setAttributes([.posixPermissions: mode], ofItemAtPath: file.path) }
4141 } catch {
4242 throw Failure(message: "Can't write \(file.path): \(error.localizedDescription)")
4343 }
44 if let mode = file.mode {
45 do {
46 try manager.setAttributes([.posixPermissions: mode], ofItemAtPath: file.path)
47 } catch {
48 modeFailure = modeFailure ?? Failure(message: "\(message(output, source: source)), but can't set the mode of \(file.path): \(error.localizedDescription)")
49 }
50 }
4451 paths.append(file.path)
4552 }
53 if let modeFailure { throw modeFailure }
4654 return paths
4755 }
4856
@@ -53,6 +61,12 @@ public enum TangleWriter {
5361}
5462
5563extension DocumentSession {
64 /// The files `tangle` would write.
65 public func tangleFiles(_ scope: Tangle.Scope) -> [String] {
66 guard let path, let document, case .success(let output) = Tangle.run(text: document.text, path: path, scope: scope, tree: document.tree) else { return [] }
67 return output.files.map(\.path)
68 }
69
5670 /// Tangles the open file: its text as it is now, written beside it.
5771 public func tangle(_ scope: Tangle.Scope) -> String {
5872 guard let path, let document else { return "No file is open" }
Sources/OrgApp/TipStore.swift added +60
@@ -0,0 +1,60 @@
1#if canImport(StoreKit)
2import Foundation
3import Observation
4import StoreKit
5
6/// Tips from the App Store. `ProStore`'s transaction listener finishes any that arrive later.
7@MainActor @Observable
8public final class TipStore {
9 public private(set) var products: [Product] = []
10 public private(set) var isLoading = false
11 public private(set) var purchasingProductID: String?
12 /// A failure, or a tip waiting for approval, shown in the section.
13 public private(set) var message: String?
14 /// Set after a tip goes through; the thank-you alert clears it.
15 public var thanked = false
16
17 public init() {}
18
19 public func loadProducts() async {
20 guard !isLoading else { return }
21 isLoading = true
22 message = nil
23 defer { isLoading = false }
24 do {
25 let fetched = try await Product.products(for: Tip.productIDs)
26 products = Tip.productIDs.compactMap { id in fetched.first { $0.id == id } }
27 if products.count < Tip.productIDs.count {
28 message = String(localized: "Some tips aren't available from the App Store right now.")
29 }
30 } catch {
31 products = []
32 message = String(localized: "The App Store can't be reached right now.")
33 }
34 }
35
36 public func purchase(_ product: Product) async {
37 guard purchasingProductID == nil else { return }
38 purchasingProductID = product.id
39 message = nil
40 defer { purchasingProductID = nil }
41 do {
42 switch try await product.purchase() {
43 case .success(.verified(let transaction)):
44 await transaction.finish()
45 thanked = true
46 case .success(.unverified):
47 message = String(localized: "The App Store couldn't verify the purchase.")
48 case .pending:
49 message = String(localized: "The tip is waiting for approval.")
50 case .userCancelled:
51 break
52 @unknown default:
53 break
54 }
55 } catch {
56 message = String(localized: "The purchase didn't go through. \(error.localizedDescription)")
57 }
58 }
59}
60#endif
Sources/OrgApp/UserConfig.swift +14 −5
@@ -13,14 +13,23 @@ public enum UserConfig {
1313
1414 public static var directory: URL {
1515 if let directoryOverride { return directoryOverride }
16 let environment = ProcessInfo.processInfo.environment
17 if let override = environment["ORGSTAR_CONFIG_DIR"] { return URL(fileURLWithPath: override) }
16 return defaultDirectory(environment: ProcessInfo.processInfo.environment, home: NSHomeDirectory(), sandboxed: Sandbox.isActive)
17 }
18
19 /// The folder from the environment, else `~/.config/orgstar`. In the sandbox, `home` is the
20 /// container and folders from the environment outside it are ignored, since they can't be
21 /// reached without a grant.
22 public static func defaultDirectory(environment: [String: String], home: String, sandboxed: Bool) -> URL {
23 let usable: (String) -> Bool = { path in
24 !sandboxed || (path as NSString).standardizingPath.hasPrefix((home as NSString).standardizingPath + "/")
25 }
26 if let override = environment["ORGSTAR_CONFIG_DIR"], usable(override) { return URL(fileURLWithPath: override) }
1827 // Development runs keep everything in their data folder.
19 if let data = environment["ORGSTAR_DATA_DIR"] { return URL(fileURLWithPath: data) }
20 if let xdg = environment["XDG_CONFIG_HOME"], !xdg.isEmpty {
28 if let data = environment["ORGSTAR_DATA_DIR"], usable(data) { return URL(fileURLWithPath: data) }
29 if let xdg = environment["XDG_CONFIG_HOME"], !xdg.isEmpty, usable(xdg) {
2130 return URL(fileURLWithPath: xdg).appendingPathComponent("orgstar")
2231 }
23 return URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent(".config/orgstar")
32 return URL(fileURLWithPath: home).appendingPathComponent(".config/orgstar")
2433 }
2534
2635 /// The theme `config.toml` (`text`) sets: its `[theme]` tables' colors over those of
Sources/OrgApp/WorkspaceModel.swift +70
@@ -31,6 +31,9 @@ public final class WorkspaceModel {
3131 private let rootsFile: URL
3232 /// Resolved root folders, keyed by their resolved path, which is how the index stores them.
3333 private var resolvedRoots: [String: URL] = [:]
34 /// Roots whose bookmark doesn't resolve: a folder gone, on a volume not mounted, or out of
35 /// the sandbox's reach.
36 public private(set) var unresolvedRoots: [WorkspaceRoot] = []
3437 @ObservationIgnored private var watcher: AnyObject?
3538 /// Watchers of the roots where there are no FSEvents.
3639 @ObservationIgnored private var presenters: [FolderPresenter] = []
@@ -92,6 +95,17 @@ public final class WorkspaceModel {
9295 await refresh()
9396 }
9497
98 /// Replaces `root`, one that doesn't resolve, with `url`, chosen again in an open panel.
99 public func regrant(_ root: WorkspaceRoot, with url: URL) async throws {
100 let fresh = try WorkspaceRoot(url: url)
101 roots.removeAll { $0 == root }
102 if !roots.contains(where: { $0.path == fresh.path }), resolvedRoots[fresh.path] == nil { roots.append(fresh) }
103 try saveRoots()
104 resolveRoots()
105 rootsChanged()
106 await refresh()
107 }
108
95109 /// Removes a root by its resolved path, as `FileEntry.root` gives it.
96110 public func removeRoot(path: String) throws {
97111 let bookmarkPaths = roots.filter { (try? $0.resolve().url.path) == path || $0.path == path }.map(\.path)
@@ -116,10 +130,12 @@ public final class WorkspaceModel {
116130 /// Resolves bookmarks; refreshes stale ones; reports folders that can't be found.
117131 private func resolveRoots() {
118132 resolvedRoots = [:]
133 unresolvedRoots = []
119134 var refreshed = roots
120135 for (i, root) in roots.enumerated() {
121136 guard let (url, isStale) = try? root.resolve() else {
122137 lastError = "Can't find the folder \(root.path)."
138 unresolvedRoots.append(root)
123139 continue
124140 }
125141 if isStale, let fresh = try? WorkspaceRoot(url: url) { refreshed[i] = fresh }
@@ -136,6 +152,60 @@ public final class WorkspaceModel {
136152 /// Resolved root paths, sorted.
137153 public var rootPaths: [String] { resolvedRoots.keys.sorted() }
138154
155 /// Whether `url` is a root or a granted folder, or inside one.
156 public func contains(_ url: URL) -> Bool {
157 Self.isInside(url, roots: Array(resolvedRoots.values) + FolderGrants.shared.folders)
158 }
159
160 /// The folders to ask for so that `paths` can be read and written: in the Mac sandbox, for
161 /// each path outside the roots, the grants and the app's container, its nearest existing
162 /// folder. `directories` takes the paths as folders rather than files. Empty unsandboxed.
163 public func foldersToGrant(for paths: [String], directories: Bool = false) -> [URL] {
164 guard Sandbox.isActive else { return [] }
165 let reachable = Array(resolvedRoots.values) + FolderGrants.shared.folders + [URL(fileURLWithPath: NSHomeDirectory())]
166 + (UserConfig.directoryOverride.map { [$0] } ?? [])
167 return Self.foldersToGrant(for: paths, directories: directories, reachable: reachable)
168 }
169
170 /// Whether the file at `path` is there to be read, for all the read failed: missing files
171 /// aren't worth asking for access to.
172 public nonisolated static func isThere(_ path: String) -> Bool {
173 do {
174 _ = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
175 return true
176 } catch let error as NSError {
177 return !(error.domain == NSCocoaErrorDomain && error.code == NSFileReadNoSuchFileError)
178 }
179 }
180
181 nonisolated static func foldersToGrant(
182 for paths: [String], directories: Bool, reachable: [URL],
183 exists: (String) -> Bool = { FileManager.default.fileExists(atPath: $0) }
184 ) -> [URL] {
185 var folders: [URL] = []
186 for path in paths where !path.isEmpty {
187 let url = URL(fileURLWithPath: path).standardizedFileURL
188 guard !isInside(url, roots: reachable) else { continue }
189 var folder = directories ? url : url.deletingLastPathComponent()
190 while folder.pathComponents.count > 1, !exists(folder.path) { folder.deleteLastPathComponent() }
191 if !folders.contains(folder) { folders.append(folder) }
192 }
193 return folders
194 }
195
196 /// Whether `url` is one of `roots` or inside one, by whole path components, as written or
197 /// with symbolic links resolved.
198 nonisolated static func isInside(_ url: URL, roots: [URL]) -> Bool {
199 func forms(_ url: URL) -> [[String]] {
200 let standard = url.standardizedFileURL
201 return [standard.pathComponents, standard.resolvingSymlinksInPath().pathComponents]
202 }
203 let paths = forms(url)
204 return roots.flatMap(forms).contains { root in
205 paths.contains { $0.count >= root.count && Array($0.prefix(root.count)) == root }
206 }
207 }
208
139209 // MARK: - Indexing
140210
141211 /// Which files the folders show; a change rescans them.
Sources/OrgCore/Capture/Capture.swift +2 −2
@@ -171,7 +171,7 @@ public struct CaptureContext: Sendable {
171171 public var linkProperties: [String: String] = [:]
172172 /// `%[file]`: what relative paths are relative to, and the contents of a file by its
173173 /// absolute path, nil when it can't be read.
174 public var directory = NSHomeDirectory()
174 public var directory = OrgPaths.home
175175 public var readFile: @Sendable (String) -> String? = { _ in nil }
176176
177177 public init(
@@ -390,7 +390,7 @@ public enum Capture {
390390 buffer.release(end)
391391 }
392392 if unescape(buffer, at: start.position) { continue }
393 let expanded = name.hasPrefix("~") ? NSHomeDirectory() + name.dropFirst() : name
393 let expanded = name.hasPrefix("~") ? OrgPaths.home + name.dropFirst() : name
394394 let path = ((expanded as NSString).isAbsolutePath ? expanded : (context.directory as NSString).appendingPathComponent(expanded) as String)
395395 let file = (path as NSString).standardizingPath
396396 buffer.deleteRegion(start.position, end.position)
Sources/OrgCore/Commands/Archive.swift +3 −3
@@ -199,7 +199,7 @@ public enum Archive {
199199 if fileFormat.contains(where: { !$0.isWhitespace }) {
200200 let file = fileFormat.replacingOccurrences(of: "%s", with: name)
201201 let directory = (sourcePath as NSString).deletingLastPathComponent
202 path = ((file as NSString).isAbsolutePath ? file : (directory as NSString).appendingPathComponent(file)).replacingOccurrences(of: "~", with: NSHomeDirectory(), options: .anchored)
202 path = ((file as NSString).isAbsolutePath ? file : (directory as NSString).appendingPathComponent(file)).replacingOccurrences(of: "~", with: OrgPaths.home, options: .anchored)
203203 } else {
204204 path = sourcePath
205205 }
@@ -215,7 +215,7 @@ public enum Archive {
215215 guard fileFormat.contains(where: { !$0.isWhitespace }) else { return sourcePath }
216216 let file = fileFormat.replacingOccurrences(of: "%s", with: (sourcePath as NSString).lastPathComponent)
217217 let directory = (sourcePath as NSString).deletingLastPathComponent
218 let path = ((file as NSString).isAbsolutePath ? file : (directory as NSString).appendingPathComponent(file)).replacingOccurrences(of: "~", with: NSHomeDirectory(), options: .anchored)
218 let path = ((file as NSString).isAbsolutePath ? file : (directory as NSString).appendingPathComponent(file)).replacingOccurrences(of: "~", with: OrgPaths.home, options: .anchored)
219219 return (path as NSString).standardizingPath
220220 }
221221
@@ -258,7 +258,7 @@ public enum Archive {
258258
259259 /// `~/` for paths in the home folder, as `abbreviate-file-name`.
260260 static func abbreviate(_ path: String) -> String {
261 let home = NSHomeDirectory()
261 let home = OrgPaths.home
262262 return path.hasPrefix(home + "/") ? "~" + path.dropFirst(home.count) : path
263263 }
264264
Sources/OrgCore/Commands/Attach.swift +1 −1
@@ -17,7 +17,7 @@ public enum OrgAttach {
1717
1818 /// `expand-file-name` of `path` in `folder`: `.` and `..` resolved, symbolic links not.
1919 public static func expand(_ path: String, in folder: String) -> String {
20 let expanded = (path as NSString).expandingTildeInPath
20 let expanded = OrgPaths.expandingTilde(path)
2121 let absolute = expanded.hasPrefix("/") ? expanded : (folder as NSString).appendingPathComponent(expanded)
2222 return URL(fileURLWithPath: absolute).standardized.path
2323 }
Sources/OrgCore/Commands/ClockTable.swift +1 −1
@@ -435,7 +435,7 @@ extension EmacsBuffer {
435435 var expanded: [String] = []
436436 for item in list {
437437 guard let name = item.string else { throw UserError(message: "Unknown scope: \(scopeValue.description)") }
438 var file = (name as NSString).expandingTildeInPath
438 var file = OrgPaths.expandingTilde(name)
439439 if !file.hasPrefix("/"), let base { file = (base as NSString).appendingPathComponent(file) }
440440 file = (file as NSString).standardizingPath
441441 var isDirectory: ObjCBool = false
Sources/OrgCore/Commands/ColumnView.swift +1 −1
@@ -410,7 +410,7 @@ extension EmacsBuffer {
410410 case "local", "nil", "": break
411411 case let value where value.hasPrefix("file:"):
412412 // `file:PATH`: the whole file, read from disk; relative to this file's folder.
413 var path = (String(value.dropFirst(5)) as NSString).expandingTildeInPath
413 var path = OrgPaths.expandingTilde(String(value.dropFirst(5)))
414414 if !path.hasPrefix("/"), let file = options.filePath { path = ((file as NSString).deletingLastPathComponent as NSString).appendingPathComponent(path) }
415415 guard let text = path == options.filePath ? string : try? String(contentsOfFile: path, encoding: .utf8) else {
416416 throw UserError(message: "No such file: \"\(value)\"")
Sources/OrgCore/Compute/Babel.swift +1 −1
@@ -74,7 +74,7 @@ public struct BabelJob: Sendable, Equatable {
7474 /// An inline block: the result goes after it, in `{{{results(…)}}}`.
7575 var inline = false
7676 /// `:file` (under `:output-dir`) with `:results file`, and `:file-desc`.
77 var file: String?
77 public internal(set) var file: String?
7878 var fileDescription: String?
7979 /// The program writes `file` itself, as graphics languages do.
8080 var writesFile = false
Sources/OrgCore/Compute/BabelCache.swift +2 −1
@@ -45,7 +45,8 @@ extension Babel {
4545 /// sorted by key and printed with `%S`, then the expanded body.
4646 static func cacheInput(language: String, params: Params, tables: Tables, expanded: String, call: Bool) throws -> String {
4747 if let key = params.lisp.first(where: { params.evaluated[$0] == nil }) {
48 throw Failure.message(":cache with \(key) \(params.single[key] ?? "") needs Emacs to evaluate the Lisp; nothing was run.")
48 let setting = ":cache with \(key) \(params.single[key] ?? "")"
49 throw Failure.message(setting + EmacsFallback.wording(" needs Emacs to evaluate the Lisp; nothing was run.", " is Lisp that can't be evaluated here; nothing was run."))
4950 }
5051 let ignored: Set<String> = ["replace", "silent", "none", "discard", "append", "prepend"]
5152 let drawsFile = language == "dot" || language == "plantuml"
Sources/OrgCore/Compute/BabelExpand.swift +1 −1
@@ -518,7 +518,7 @@ extension Babel {
518518 run = "echo | clojure -M \(file)\n"
519519 programs = ["clojure"]
520520 case let backend?:
521 throw Failure.message("The \(backend) backend for clojure needs Emacs; orgstar runs babashka or clojure-cli.")
521 throw Failure.message("The \(backend) backend for clojure " + EmacsFallback.wording("needs Emacs", "isn't supported") + "; orgstar runs babashka or clojure-cli.")
522522 }
523523 return CompiledRun(source: expanded, script: start + "cat > \(file)\n" + run + end, programs: [programs])
524524 default:
Sources/OrgCore/Compute/TableFormulaCommands.swift +2 −2
@@ -9,7 +9,7 @@ public struct TableRecalculate: OrgCommand {
99 public var id: String { all ? "org.table.recalc-all" : "org.table.recalc" }
1010 public var title: String { all ? "Recalculate Table" : "Recalculate Table Row" }
1111
12 public static let emacsMessage = "needs Emacs: "
12 public static var emacsMessage: String { EmacsFallback.wording("needs Emacs: ", "can't be calculated here: ") }
1313
1414 public func applies(in context: EditContext) -> Bool {
1515 KeyContext.holds("table", in: context) || Self.tblfmLine(in: context) != nil
@@ -199,7 +199,7 @@ extension EmacsBuffer {
199199 do {
200200 try tableEvalFormula(formula, analysis: analysis, substituted: false)
201201 } catch let error as Calc.Unsupported {
202 message = "The formula was stored; recalculating it needs Emacs: " + error.reason
202 message = EmacsFallback.wording("The formula was stored; recalculating it needs Emacs: ", "The formula was stored; it can't be calculated here: ") + error.reason
203203 }
204204 tableAlign()
205205 }
Sources/OrgCore/Compute/Tangle.swift +2 −2
@@ -153,7 +153,7 @@ public enum Tangle {
153153 lisp.define("expand-file-name") { lisp, args in
154154 try Elisp.arity(args, 1...2, "expand-file-name")
155155 let base = args.count > 1 && !Elisp.isNil(args[1]) ? try string(args, 1) : (try Elisp.string(lisp.value("default-directory")))
156 return .string(expand(try string(args, 0), in: (base as NSString).expandingTildeInPath))
156 return .string(expand(try string(args, 0), in: OrgPaths.expandingTilde(base)))
157157 }
158158 lisp.define("file-name-directory") { _, args in
159159 try Elisp.arity(args, 1...1, "file-name-directory")
@@ -206,7 +206,7 @@ public enum Tangle {
206206
207207 /// `expand-file-name`.
208208 static func expand(_ name: String, in directory: String) -> String {
209 let expanded = (name as NSString).expandingTildeInPath
209 let expanded = OrgPaths.expandingTilde(name)
210210 let absolute = expanded.hasPrefix("/") ? expanded : (directory as NSString).appendingPathComponent(expanded)
211211 return (absolute as NSString).standardizingPath
212212 }
Sources/OrgCore/EmacsFallback.swift added +12
@@ -0,0 +1,12 @@
1import Foundation
2
3/// Whether messages may send the user to Emacs for what orgstar can't do itself. The Mac App
4/// Store build, which can't run Emacs, turns it off at launch.
5public enum EmacsFallback {
6 nonisolated(unsafe) public static var offered = true
7
8 /// `emacs` while Emacs is offered, else `other`.
9 public static func wording(_ emacs: String, _ other: String, offered: Bool = offered) -> String {
10 offered ? emacs : other
11 }
12}
Sources/OrgCore/Export/Citations.swift +1 −1
@@ -389,7 +389,7 @@ struct CiteProcessor {
389389 // Each `#+bibliography:` names one file.
390390 for m in text.matches(of: #/(?mi)^[ \t]*#\+bibliography:[ \t]*(.*?)[ \t]*$/#) {
391391 for name in [String(m.1)].map({ $0.count > 1 && $0.hasPrefix("\"") && $0.hasSuffix("\"") ? String($0.dropFirst().dropLast()) : $0 }) where !name.isEmpty {
392 let path = (name as NSString).expandingTildeInPath
392 let path = OrgPaths.expandingTilde(name)
393393 let url = path.hasPrefix("/") ? URL(fileURLWithPath: path) : (directory ?? URL(fileURLWithPath: "/")).appendingPathComponent(path)
394394 guard let data = try? Data(contentsOf: url) else { continue }
395395 let parsed = url.pathExtension.lowercased() == "json" ? Self.parseJSON(data) : Self.parseBibTeX(String(decoding: data, as: UTF8.self))
Sources/OrgCore/Export/ExportOptions.swift +27 −3
@@ -116,9 +116,7 @@ public enum ExportPreprocess {
116116 file = String(spec[..<r.lowerBound])
117117 target = String(spec[r.upperBound...])
118118 }
119 let url = (file as NSString).isAbsolutePath || directory == nil
120 ? URL(fileURLWithPath: (file as NSString).expandingTildeInPath)
121 : directory!.appendingPathComponent(file)
119 let url = includeURL(file, directory: directory)
122120 guard var included = try? String(contentsOf: url, encoding: .utf8) else {
123121 lines.append("")
124122 continue
@@ -152,6 +150,32 @@ public enum ExportPreprocess {
152150 return lines.joined(separator: "\n")
153151 }
154152
153 /// The files `#+INCLUDE` names in `text`, and in the files they include, that can't be read.
154 public static func unreadableIncludes(_ text: String, directory: URL?, depth: Int = 0) -> [String] {
155 guard depth < 8, text.containsIgnoringASCIICase("#+INCLUDE:") else { return [] }
156 var unreadable: [String] = []
157 for line in text.components(separatedBy: "\n") {
158 guard let m = line.firstMatch(of: #/(?i)^[ \t]*#\+INCLUDE:[ \t]+"([^"]+)"/#) else { continue }
159 let spec = String(m.1)
160 let url = includeURL(spec.range(of: "::").map { String(spec[..<$0.lowerBound]) } ?? spec, directory: directory)
161 guard let included = try? String(contentsOf: url, encoding: .utf8) else {
162 if !unreadable.contains(url.path) { unreadable.append(url.path) }
163 continue
164 }
165 for path in unreadableIncludes(included, directory: url.deletingLastPathComponent(), depth: depth + 1) where !unreadable.contains(path) {
166 unreadable.append(path)
167 }
168 }
169 return unreadable
170 }
171
172 /// An include's file, relative to `directory`.
173 static func includeURL(_ file: String, directory: URL?) -> URL {
174 (file as NSString).isAbsolutePath || directory == nil
175 ? URL(fileURLWithPath: OrgPaths.expandingTilde(file))
176 : directory!.appendingPathComponent(file)
177 }
178
155179 /// The subtree of `text` at `*Heading` or `#custom-id`.
156180 static func subtree(_ text: String, _ target: String) -> String? {
157181 let tree = OrgParser.parse(text)
Sources/OrgCore/Export/ExportScope.swift +1 −1
@@ -59,7 +59,7 @@ public enum ExportScope {
5959 /// expanded) with its extension replaced by `ext`, or the source's name with `ext`.
6060 public static func output(for source: URL, name: String?, extension ext: String) -> URL {
6161 guard let name, !name.isEmpty else { return source.deletingPathExtension().appendingPathExtension(ext) }
62 let expanded = (name as NSString).expandingTildeInPath
62 let expanded = OrgPaths.expandingTilde(name)
6363 let url = expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : source.deletingLastPathComponent().appendingPathComponent(expanded)
6464 return url.deletingPathExtension().appendingPathExtension(ext).standardizedFileURL
6565 }
Sources/OrgCore/Links/Backlinks.swift +1 −1
@@ -20,7 +20,7 @@ public enum Backlinks {
2020 }
2121
2222 /// Whether `link`, written in the file at `source`, leads to `target`.
23 public static func links(_ link: String, from source: String, to target: Target, home: String = NSHomeDirectory()) -> Bool {
23 public static func links(_ link: String, from source: String, to target: Target, home: String = OrgPaths.home) -> Bool {
2424 let link = Links.unescape(link)
2525 if link.lowercased().hasPrefix("id:") {
2626 let id = link.dropFirst(3).components(separatedBy: "::")[0]
Sources/OrgCore/Links/LinkStore.swift +1 −1
@@ -235,7 +235,7 @@ public struct InsertLink: OrgCommand {
235235 public let file: String?
236236 public let home: String
237237
238 public init(stored: [StoredLink] = [], file: String? = nil, home: String = NSHomeDirectory()) {
238 public init(stored: [StoredLink] = [], file: String? = nil, home: String = OrgPaths.home) {
239239 self.stored = stored
240240 self.file = file
241241 self.home = home
Sources/OrgCore/Parser/SetupFile.swift +1 −1
@@ -25,7 +25,7 @@ public enum SetupFile {
2525 var value = line[line.index(after: colon)...].trimmingCharacters(in: .whitespaces)
2626 if value.count >= 2, value.hasPrefix("\""), value.hasSuffix("\"") { value = String(value.dropFirst().dropLast()) }
2727 guard !value.isEmpty, value.range(of: "^[a-zA-Z][a-zA-Z0-9+.-]*://", options: .regularExpression) == nil else { continue }
28 let expanded = (value as NSString).expandingTildeInPath
28 let expanded = OrgPaths.expandingTilde(value)
2929 let path = ((expanded.hasPrefix("/") ? expanded : (directory as NSString).appendingPathComponent(expanded)) as NSString).standardizingPath
3030 guard !seen.contains(path), let contents = read(path) else { continue }
3131 out += lines(in: contents, directory: (path as NSString).deletingLastPathComponent, read: read, own: true, seen: seen.union([path]))
Sources/OrgCore/Paths.swift added +28
@@ -0,0 +1,28 @@
1import Foundation
2
3/// Paths as written in Org files and settings, where `~` is the home folder.
4public enum OrgPaths {
5 /// The account's home folder. On the Mac this is the real one even in the sandbox, where
6 /// `NSHomeDirectory()` and `expandingTildeInPath` give the app's container.
7 public static let home: String = {
8 #if os(macOS)
9 getpwuid(getuid())?.pointee.pw_dir.map { String(cString: $0) } ?? NSHomeDirectory()
10 #else
11 NSHomeDirectory()
12 #endif
13 }()
14
15 /// `path` with a leading `~` or `~/` taken from `home`; otherwise, `~user` included, as
16 /// `expandingTildeInPath` gives it.
17 public static func expandingTilde(_ path: String, home: String = home) -> String {
18 guard path == "~" || path.hasPrefix("~/") else { return (path as NSString).expandingTildeInPath }
19 return ((home + path.dropFirst()) as NSString).expandingTildeInPath
20 }
21
22 /// `path` with `home` at its start written as `~`, as `abbreviatingWithTildeInPath` does.
23 public static func abbreviatingWithTilde(_ path: String, home: String = home) -> String {
24 let normalized = path.hasPrefix("~") ? path : (path as NSString).expandingTildeInPath
25 if normalized == home { return "~" }
26 return normalized.hasPrefix(home + "/") ? "~" + normalized.dropFirst(home.count) : normalized
27 }
28}
Sources/OrgCore/Sandbox.swift added +44
@@ -0,0 +1,44 @@
1import Foundation
2
3/// Whether this process runs in the App Sandbox, as the Mac App Store build does, and the
4/// choices that follow from it.
5public enum Sandbox {
6 /// True for a sandboxed Mac process. Always false on iOS.
7 public static let isActive = isActive(environment: ProcessInfo.processInfo.environment)
8
9 /// The sandbox sets `APP_SANDBOX_CONTAINER_ID` for the processes it confines.
10 static func isActive(environment: [String: String]) -> Bool {
11 #if os(macOS)
12 environment["APP_SANDBOX_CONTAINER_ID"] != nil
13 #else
14 false
15 #endif
16 }
17
18 /// Options for a bookmark that should give access back after relaunch: security-scoped in
19 /// the Mac sandbox, plain elsewhere.
20 public static func bookmarkCreationOptions(sandboxed: Bool = isActive) -> URL.BookmarkCreationOptions {
21 #if os(macOS)
22 sandboxed ? .withSecurityScope : []
23 #else
24 []
25 #endif
26 }
27
28 /// A bookmark of `url` made with `bookmarkCreationOptions`. Access to the URL is started
29 /// first: a URL from SwiftUI's file importer is security-scoped, and the sandbox refuses a
30 /// bookmark of it until access starts. Access stays on for the session.
31 public static func bookmark(_ url: URL, sandboxed: Bool = isActive) throws -> Data {
32 _ = url.startAccessingSecurityScopedResource()
33 return try url.bookmarkData(options: bookmarkCreationOptions(sandboxed: sandboxed), includingResourceValuesForKeys: nil, relativeTo: nil)
34 }
35
36 /// The resolving side of `bookmarkCreationOptions`.
37 public static func bookmarkResolutionOptions(sandboxed: Bool = isActive) -> URL.BookmarkResolutionOptions {
38 #if os(macOS)
39 sandboxed ? .withSecurityScope : []
40 #else
41 []
42 #endif
43 }
44}
Sources/OrgDocument/FileStorage.swift +23 −2
@@ -1,10 +1,17 @@
11import CryptoKit
22import Foundation
3import OrgCore
34
45/// Reads and replaces files under `NSFileCoordinator`, so iCloud and other coordinating
56/// writers see a consistent file.
67public struct CoordinatedFileSystem: FileSystem {
7 public init() {}
8 /// Write in place when the folder refuses the temporary file, as the sandbox does for a
9 /// file it granted alone. Not atomic, so only where it is the one way to save.
10 public let writesInPlaceWhenDenied: Bool
11
12 public init(writesInPlaceWhenDenied: Bool = Sandbox.isActive) {
13 self.writesInPlaceWhenDenied = writesInPlaceWhenDenied
14 }
815
916 public func read(_ url: URL) throws -> [UInt8]? {
1017 try coordinate(reading: url) { url in
@@ -17,7 +24,13 @@ public struct CoordinatedFileSystem: FileSystem {
1724 let manager = FileManager.default
1825 let folder = url.deletingLastPathComponent()
1926 let temporary = folder.appendingPathComponent(".\(url.lastPathComponent).orgstar-\(UUID().uuidString)")
20 try Data(bytes).write(to: temporary)
27 do {
28 try Data(bytes).write(to: temporary)
29 } catch where writesInPlaceWhenDenied && Self.isPermissionDenied(error) {
30 let previous = manager.fileExists(atPath: url.path) ? [UInt8](try Data(contentsOf: url)) : nil
31 try Data(bytes).write(to: url)
32 return previous
33 }
2134 guard manager.fileExists(atPath: url.path) else {
2235 try manager.moveItem(at: temporary, to: url)
2336 return nil
@@ -32,6 +45,14 @@ public struct CoordinatedFileSystem: FileSystem {
3245 }
3346 }
3447
48 /// Whether `error` is the file system refusing access.
49 static func isPermissionDenied(_ error: Error) -> Bool {
50 let error = error as NSError
51 if error.domain == NSCocoaErrorDomain, error.code == CocoaError.fileWriteNoPermission.rawValue { return true }
52 if error.domain == NSPOSIXErrorDomain, [Int(EACCES), Int(EPERM)].contains(error.code) { return true }
53 return (error.userInfo[NSUnderlyingErrorKey] as? Error).map(isPermissionDenied) ?? false
54 }
55
3556 private func coordinate<T>(reading url: URL, _ body: (URL) throws -> T) throws -> T {
3657 var coordinationError: NSError?
3758 var result: Result<T, Error>?
Sources/OrgEditorAppKit/OrgEditor+Images.swift +1 −1
@@ -54,7 +54,7 @@ extension OrgEditor {
5454 }
5555 return data.flatMap(NSImage.init(data:))
5656 }
57 let expanded = (path as NSString).expandingTildeInPath
57 let expanded = OrgPaths.expandingTilde(path)
5858 let url = expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : (baseDirectory ?? URL(fileURLWithPath: FileManager.default.currentDirectoryPath)).appendingPathComponent(expanded)
5959 let modified = (try? url.resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate?.timeIntervalSince1970 ?? 0
6060 let key = "\(url.path)|\(modified)" as NSString
Sources/OrgEditorAppKit/OrgEditor.swift +1 −1
@@ -652,7 +652,7 @@ public final class OrgEditor: NSObject {
652652 case .failed(let message):
653653 onMessage?(message)
654654 case .external(let request):
655 if let onExternal { onExternal(request) } else { onMessage?("This needs Emacs, which isn't available here.") }
655 if let onExternal { onExternal(request) } else { onMessage?(EmacsFallback.wording("This needs Emacs, which isn't available here.", "This isn't available here.")) }
656656 case .prompt(let prompt):
657657 onPrompt?(prompt) { [weak self] answer in
658658 guard let self else { return }
Sources/OrgApp/BabelRunner.swift → Sources/OrgPrograms/BabelRunner.swift renamed
Sources/OrgApp/BabelSessions.swift → Sources/OrgPrograms/BabelSessions.swift renamed
Sources/OrgApp/EmacsRunner.swift → Sources/OrgPrograms/EmacsRunner.swift renamed
Sources/OrgPrograms/Gnuplot.swift added +49
@@ -0,0 +1,49 @@
1#if os(macOS)
2import Foundation
3import OrgApp
4import OrgCore
5
6extension PlotOutput {
7 /// gnuplot on the `PATH` Babel uses, when installed.
8 public static var gnuplot: URL? {
9 let path = BabelRunner.environment["PATH"] ?? "/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin"
10 return path.split(separator: ":").map { URL(fileURLWithPath: String($0)).appendingPathComponent("gnuplot") }
11 .first { FileManager.default.isExecutableFile(atPath: $0.path) }
12 }
13
14 /// `org-plot/gnuplot` through gnuplot: the data file and script org-plot writes, run with
15 /// the output at `file:`, or a PNG for showing when there's none. Returns the image.
16 public static func runGnuplot(_ plot: TablePlot.Plot, directory: URL?, gnuplot: URL) async throws -> URL {
17 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-plot-\(UUID().uuidString)")
18 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
19 let dataFile = folder.appendingPathComponent("data.tsv")
20 var plot = plot
21 let output = file(plot, directory: directory) ?? folder.appendingPathComponent("plot.png")
22 if plot.options.file == nil { plot.options.values["file"] = .string(output.path) }
23 let (data, labels): (String, [(Int, String)]) = plot.options.type == "grid" ? TablePlot.gridData(plot) : (TablePlot.data(plot), [])
24 try data.write(to: dataFile, atomically: true, encoding: .utf8)
25 var script = TablePlot.script(plot, dataFile: dataFile.path, output: output.path, yLabels: labels)
26 if let custom = plot.options["script"]?.description {
27 let path = OrgPaths.expandingTilde(custom)
28 let url = path.hasPrefix("/") ? URL(fileURLWithPath: path) : (directory ?? folder).appendingPathComponent(path)
29 guard let text = try? String(contentsOf: url, encoding: .utf8) else { throw Failure(description: "Can't read \(custom)") }
30 script = TablePlot.script(plot, dataFile: dataFile.path, output: output.path, yLabels: labels, preface: true)
31 + "\n" + text.replacingOccurrences(of: "$datafile", with: dataFile.path)
32 }
33 let scriptFile = folder.appendingPathComponent("plot.gp")
34 try script.write(to: scriptFile, atomically: true, encoding: .utf8)
35 let process = Process()
36 process.executableURL = gnuplot
37 process.arguments = [scriptFile.path]
38 process.currentDirectoryURL = directory
39 let errors = Pipe()
40 process.standardError = errors
41 try process.run()
42 while process.isRunning { try await Task.sleep(for: .milliseconds(50)) }
43 guard process.terminationStatus == 0 else {
44 throw Failure(description: "gnuplot: " + String(decoding: errors.fileHandleForReading.readDataToEndOfFile(), as: UTF8.self).trimmingCharacters(in: .whitespacesAndNewlines))
45 }
46 return output
47 }
48}
49#endif
Sources/OrgPrograms/Programs.swift added +18
@@ -0,0 +1,18 @@
1#if os(macOS)
2import Foundation
3import OrgApp
4import OrgCore
5
6/// Babel and Emacs as processes, for `DocumentSession.programs`.
7public struct Programs: ProgramRunning {
8 public init() {}
9
10 public func runBabel(_ job: BabelJob, fileDirectory: URL) async throws -> BabelOutput {
11 try await BabelRunner.run(job, fileDirectory: fileDirectory)
12 }
13
14 public func recalculateTable(text: String, directory: URL, table: Range<Int>, point: Int, form: String) async throws -> String {
15 try await EmacsRunner.recalculateTable(text: text, directory: directory, table: table, point: point, form: form)
16 }
17}
18#endif
Sources/OrgWorkspace/Discovery.swift +8 −5
@@ -1,21 +1,24 @@
11import Foundation
2import OrgCore
23import OrgIndex
34
4/// A folder the user added. Identified by its bookmark, so a moved folder is followed.
5/// A folder the user added. Identified by its bookmark, so a moved folder is followed. In the
6/// Mac sandbox the bookmark is security-scoped, so access comes back after relaunch.
57public struct WorkspaceRoot: Sendable, Equatable, Codable {
68 public let bookmark: Data
79 /// The path when the bookmark was made or last refreshed, for display.
810 public var path: String
911
10 public init(url: URL) throws {
11 bookmark = try url.bookmarkData(options: [], includingResourceValuesForKeys: nil, relativeTo: nil)
12 public init(url: URL, sandboxed: Bool = Sandbox.isActive) throws {
13 bookmark = try Sandbox.bookmark(url, sandboxed: sandboxed)
1214 path = url.standardizedFileURL.path
1315 }
1416
1517 /// The folder's current location. `isStale` means the bookmark should be made again.
16 public func resolve() throws -> (url: URL, isStale: Bool) {
18 public func resolve(sandboxed: Bool = Sandbox.isActive) throws -> (url: URL, isStale: Bool) {
1719 var isStale = false
18 let url = try URL(resolvingBookmarkData: bookmark, options: [], relativeTo: nil, bookmarkDataIsStale: &isStale)
20 let options = Sandbox.bookmarkResolutionOptions(sandboxed: sandboxed)
21 let url = try URL(resolvingBookmarkData: bookmark, options: options, relativeTo: nil, bookmarkDataIsStale: &isStale)
1922 _ = url.startAccessingSecurityScopedResource()
2023 return (url.standardizedFileURL, isStale)
2124 }
Sources/Orgstar/AgendaView+Actions.swift +3
@@ -146,6 +146,9 @@ extension AgendaView {
146146 message = "No entry selected"
147147 return
148148 }
149 #if APPSTORE
150 guard commands.reach(session.archiveFile(from: (entry.path, offset)).map { [$0] } ?? []) else { return }
151 #endif
149152 message = session.archive(from: (entry.path, offset))
150153 tick += 1
151154 }
Sources/Orgstar/CaptureView.swift +8 −2
@@ -164,7 +164,7 @@ struct CaptureView: View {
164164 keys = ""
165165 day = nil
166166 let clocked = clock.running
167 let clockFile = clocked.map { Links.abbreviate($0.path, home: NSHomeDirectory()) }
167 let clockFile = clocked.map { Links.abbreviate($0.path, home: OrgPaths.home) }
168168 context = CaptureContext(
169169 initial: commands.editor?.selectedText ?? "",
170170 annotation: session.captureAnnotation(),
@@ -270,7 +270,13 @@ struct CaptureView: View {
270270 }
271271 } else {
272272 placed = template.resolved(workspace: workspace, session: session, clock: clock).flatMap { resolved in
273 session.capture(text, template: resolved.template, root: workspace.rootPaths.first, file: resolved.file, now: captureDate(now))
273 #if APPSTORE
274 let path = resolved.file ?? DocumentSession.resolve(resolved.template.target.file, root: workspace.rootPaths.first)
275 guard commands.reach([path]) else {
276 return .failure(CaptureError(message: String(localized: "orgstar can't reach \(OrgPaths.abbreviatingWithTilde(path)).", comment: "Alert for a folder outside the sidebar's folders")))
277 }
278 #endif
279 return session.capture(text, template: resolved.template, root: workspace.rootPaths.first, file: resolved.file, now: captureDate(now))
274280 }
275281 }
276282 switch placed {
Sources/Orgstar/ContentView.swift +151 −13
@@ -5,6 +5,9 @@ import OrgEditorAppKit
55import OrgPresentation
66import OrgWorkspace
77import OrgIndex
8#if !APPSTORE
9import OrgPrograms
10#endif
811import SwiftUI
912import UniformTypeIdentifiers
1013import WidgetKit
@@ -180,15 +183,25 @@ struct ContentView: View {
180183 }
181184 } else {
182185 ContentUnavailableView {
183 Label(workspace.roots.isEmpty ? "Add a folder of org files" : "Choose a file", systemImage: "doc.text")
186 Label(noFolders ? "Add a folder of org files" : "Choose a file", systemImage: "doc.text")
184187 } description: {
185 Text(workspace.roots.isEmpty ? "File ▸ Add Folder… (⇧⌘O)" : "Or press ⌘P to open one by name.")
188 Text(noFolders ? "File ▸ Add Folder… (⇧⌘O)" : "Or press ⌘P to open one by name.")
186189 } actions: {
187 if workspace.roots.isEmpty { Button("Get Started…") { commands.showingWelcome = true } }
190 if noFolders { Button("Get Started…") { commands.showingWelcome = true } }
188191 }
189192 }
190193 }
191194
195 /// No folder to show: in the App Store build, also when none of them resolves, so the
196 /// welcome sheet can ask for them again.
197 private var noFolders: Bool {
198 #if APPSTORE
199 workspace.rootPaths.isEmpty
200 #else
201 workspace.roots.isEmpty
202 #endif
203 }
204
192205 @ToolbarContentBuilder
193206 private var toolbarItems: some ToolbarContent {
194207 ToolbarItem(placement: .navigation) {
@@ -286,13 +299,13 @@ struct ContentView: View {
286299 // Buffers switched by keys show in the sidebar too; a restored caret shows once.
287300 if let path = session.path, selectedFile != path { selectedFile = path }
288301 if let path = session.path, let caret = pendingCarets.removeValue(forKey: path) { session.reveal(caret) }
289 BufferRestore.save(session)
302 saveBuffers()
290303 // Syncthing's conflict copies of the file.
291304 let copies = session.syncConflictCopies().count
292305 if copies > 0 { commands.show("\(copies) sync conflict \(copies == 1 ? "copy" : "copies") of this file; Resolve Sync Conflicts compares them.") }
293306 }
294307 .onChange(of: session.openPaths) { _, paths in
295 BufferRestore.save(session)
308 saveBuffers()
296309 for path in commands.store.editors.keys where !paths.contains(path) { commands.store.releasePath(path) }
297310 }
298311 .onChange(of: editorSettings, initial: true) { _, settings in commands.editorSettings = settings }
@@ -300,6 +313,9 @@ struct ContentView: View {
300313 commands.externalHandler = runExternal
301314 commands.filesHandler = { attachActions.drop($0) }
302315 commands.imageHandler = { attachActions.yankImage($0, ext: $1) }
316 #if APPSTORE
317 commands.reach = { [workspace] in GrantAccess.reach($0, workspace: workspace) }
318 #endif
303319 // `org-clock-out-when-done`, and the notification when the Effort runs out.
304320 clock.notifications = SystemReminderCenter.isAvailable ? SystemReminderCenter() : nil
305321 session.textChanged = { [weak session, weak clock, weak commands] path in
@@ -309,7 +325,7 @@ struct ContentView: View {
309325 clock.remindAtEffort(session)
310326 commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] }
311327 commands.mainWindowOpen = true
312 if workspace.roots.isEmpty, !welcomeShown {
328 if noFolders, !welcomeShown {
313329 welcomeShown = true
314330 commands.showingWelcome = true
315331 }
@@ -343,7 +359,13 @@ struct ContentView: View {
343359 .onChange(of: preset, initial: true) { loadKeymap() }
344360 .sheet(isPresented: $showingImport) { EmacsImportView(workspace: workspace) }
345361 .sheet(item: $panel) { panel in panelView(panel) }
346 .sheet(item: Bindable(ProAccess.shared).paywall) { feature in ProPaywallSheet(feature: feature) }
362 .sheet(item: Bindable(ProAccess.shared).paywall) { feature in
363 #if APPSTORE
364 StorePaywallSheet(feature: feature)
365 #else
366 ProPaywallSheet(feature: feature)
367 #endif
368 }
347369 .sheet(item: $blockEdit) { request in
348370 BlockEditorView(edit: request.edit) { content in
349371 blockEdit = nil
@@ -487,12 +509,18 @@ struct ContentView: View {
487509 }
488510 }
489511 .task {
512 #if !APPSTORE
490513 DevelopmentHooks.scheduleSnapshot()
514 #endif
491515 pendingCarets = BufferRestore.restore(session)
492516 if let path = session.path, let caret = pendingCarets.removeValue(forKey: path) { session.reveal(caret) }
493517 // Files handed over at launch open after the restored buffers, and show.
494518 for path in AppDelegate.pendingOpens { session.open(path) }
495519 AppDelegate.pendingOpens = []
520 #if APPSTORE
521 for link in AppDelegate.pendingLinks { commands.handle(protocolURL: link) }
522 AppDelegate.pendingLinks = []
523 #else
496524 for link in AppDelegate.pendingLinks + [DevelopmentHooks.urlToOpen].compactMap({ $0 }) { commands.handle(protocolURL: link) }
497525 AppDelegate.pendingLinks = []
498526 if let path = DevelopmentHooks.fileToOpen { selectedFile = path }
@@ -509,6 +537,7 @@ struct ContentView: View {
509537 if let id = DevelopmentHooks.windowToOpen {
510538 if id == "settings" { openSettings() } else { openWindow(id: id) }
511539 }
540 #endif
512541 await workspace.refresh()
513542 workspace.startWatching()
514543 }
@@ -559,6 +588,7 @@ struct ContentView: View {
559588 commands.show("No file is open")
560589 return
561590 }
591 guard readsIncludes(text, path: path) else { return }
562592 let url = URL(fileURLWithPath: path)
563593 let base = url.deletingPathExtension()
564594 let defaults = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
@@ -571,6 +601,8 @@ struct ContentView: View {
571601 }
572602 switch format {
573603 case "icalendar":
604 let name = ExportScope.fileName(whole, subtreeAt: subtree ? caret : nil, settings: defaults)
605 guard let destination = destination ?? writable(ExportScope.output(for: url, name: name, extension: "ics")) else { return }
574606 do {
575607 let target = try ICalendarFiles.export(whole, path: path, settings: defaults, options: OrgPreferences.icalendarOptions(),
576608 subtree: subtree ? caret : nil, destination: destination)
@@ -581,7 +613,7 @@ struct ContentView: View {
581613 }
582614 case "html", "html-open", "markdown":
583615 let name = ExportScope.fileName(whole, subtreeAt: subtree ? caret : nil, settings: defaults)
584 let target = destination ?? ExportScope.output(for: url, name: name, extension: format == "markdown" ? "md" : "html")
616 guard let target = destination ?? writable(ExportScope.output(for: url, name: name, extension: format == "markdown" ? "md" : "html")) else { return }
585617 let content = format == "markdown"
586618 ? MarkdownExport.document(text, settings: defaults, path: path, bodyOnly: bodyOnly)
587619 : HTMLExport.page(
@@ -599,12 +631,14 @@ struct ContentView: View {
599631 case "print-pdf", "docx", "rtf", "plain-text":
600632 let ext = ["print-pdf": "pdf", "plain-text": "txt"][format] ?? format
601633 let name = ExportScope.fileName(whole, subtreeAt: subtree ? caret : nil, settings: defaults)
602 let target = destination ?? ExportScope.output(for: url, name: name, extension: ext)
634 guard let target = destination ?? writable(ExportScope.output(for: url, name: name, extension: ext)) else { return }
603635 let html = HTMLExport.page(
604636 text, fallbackTitle: base.lastPathComponent, settings: defaults, path: path,
605637 codeStyle: HTMLCodeStyle(highlighter: PaneView.highlighter, theme: theme), language: OrgPreferences.exportLanguage()
606638 )
607639 let directory = url.deletingLastPathComponent()
640 // Images that can't be read are left out, so offer access to them first.
641 _ = reach(PDFExport.imageFiles(html, directory: directory).filter(WorkspaceModel.isThere))
608642 if format == "print-pdf" { commands.show("Exporting to PDF…") }
609643 Task {
610644 do {
@@ -624,6 +658,7 @@ struct ContentView: View {
624658 }
625659 }
626660 default:
661 #if !APPSTORE
627662 let functions = ["pdf": "org-latex-export-to-pdf", "odt": "org-odt-export-to-odt", "latex": "org-latex-export-to-latex", "text": "org-ascii-export-to-ascii"]
628663 guard let function = functions[format] else { return }
629664 commands.show("Exporting with Emacs…")
@@ -647,12 +682,84 @@ struct ContentView: View {
647682 commands.show("\(error)")
648683 }
649684 }
685 #else
686 let title = EditorCommands.all.first { $0.id == "app.export." + format }?.title
687 commands.show(Self.unavailable(title ?? format))
688 #endif
689 }
690 }
691
692 /// `url`; in the App Store build, when the sandbox keeps orgstar out of its folder, `url` once
693 /// that folder is granted, or where a save panel puts it instead. Nil when canceled.
694 private func writable(_ url: URL) -> URL? {
695 #if APPSTORE
696 guard let folder = workspace.foldersToGrant(for: [url.path]).first else { return url }
697 let elsewhere = String(localized: "Save Elsewhere…", comment: "Button that asks where an export goes instead")
698 switch GrantAccess.ask(folder, workspace: workspace, alternative: elsewhere) {
699 case .granted: return url
700 case .canceled: return nil
701 case .alternative: break
650702 }
703 let panel = NSSavePanel()
704 panel.directoryURL = url.deletingLastPathComponent()
705 panel.nameFieldStringValue = url.lastPathComponent
706 panel.message = String(localized: "This file isn't in one of your folders. Choose where the export goes.", comment: "Save panel for an export outside the sidebar's folders")
707 return panel.runModal() == .OK ? panel.url : nil
708 #else
709 return url
710 #endif
711 }
712
713 private func saveBuffers() {
714 #if APPSTORE
715 BufferRestore.save(session, workspace: workspace)
716 #else
717 BufferRestore.save(session)
718 #endif
719 }
720
721 /// In the App Store build, asks for the folders outside the sidebar's folders that `paths`
722 /// need. False when one is still out of reach.
723 private func reach(_ paths: @autoclosure () -> [String], directories: Bool = false) -> Bool {
724 #if APPSTORE
725 GrantAccess.reach(paths(), directories: directories, workspace: workspace)
726 #else
727 true
728 #endif
729 }
730
731 /// In the App Store build, offers access to the setup files and includes of `text` that
732 /// can't be read. False, with a message, when an include still can't be read, rather than
733 /// exporting it as an empty line.
734 private func readsIncludes(_ text: String, path: String) -> Bool {
735 #if APPSTORE
736 let directory = URL(fileURLWithPath: path).deletingLastPathComponent()
737 var setupFiles: [String] = []
738 _ = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path) { file in
739 let contents = OrgSettings.readFile(file)
740 if contents == nil, WorkspaceModel.isThere(file) { setupFiles.append(file) }
741 return contents
742 }
743 let includes = ExportPreprocess.unreadableIncludes(text, directory: directory).filter(WorkspaceModel.isThere)
744 guard !(setupFiles + includes).isEmpty else { return true }
745 _ = reach(setupFiles + includes)
746 guard let unreadable = ExportPreprocess.unreadableIncludes(text, directory: directory).first else { return true }
747 commands.show(String(localized: "Can't include \(OrgPaths.abbreviatingWithTilde(unreadable)).", comment: "Export stopped by an #+INCLUDE file that can't be read"))
748 return false
749 #else
750 return true
751 #endif
752 }
753
754 /// Says a command doesn't run in this build.
755 static func unavailable(_ title: String) -> String {
756 String(localized: "\(CommandTitle.localized(title)) isn't available.", comment: "A command the Mac App Store build leaves out")
651757 }
652758
653759 /// `org-icalendar-export-agenda-files`, or with `combined`, `org-icalendar-combine-agenda-files`.
654760 private func exportAgendaCalendars(combined: Bool) {
655761 let paths = workspace.agendaFilePaths()
762 guard reach(paths + (combined ? [OrgPreferences.icalendarCombinedFile()] : [])) else { return }
656763 let read = { (path: String) -> (text: String, settings: OrgSettings)? in
657764 guard let text = session.openDocuments.first(where: { $0.path == path })?.document.text ?? (try? String(contentsOfFile: path, encoding: .utf8)) else { return nil }
658765 return (text, Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile))
@@ -696,7 +803,7 @@ struct ContentView: View {
696803
697804 /// org-roam's daily notes and nodes.
698805 private var roamActions: RoamActions {
699 RoamActions(
806 var actions = RoamActions(
700807 session: session, roots: { [workspace] in workspace.rootPaths },
701808 nodes: { [workspace, session] in workspace.nodes(overlay: workspace.overlay(session.openDocuments)) },
702809 show: { [commands] in commands.show($0) }, ask: { [commands] in commands.ask($0, reply: $1) },
@@ -711,6 +818,10 @@ struct ContentView: View {
711818 editor.perform(PrecomputedEdit(EditResult(baseRevision: context.revision, edits: [TextEdit(range: range, replacement: text)], selection: [end..<end])))
712819 },
713820 refresh: { [workspace] in Task { await workspace.refresh() } })
821 #if APPSTORE
822 actions.reachFolders = { [workspace] in GrantAccess.reach($0, directories: true, workspace: workspace) }
823 #endif
824 return actions
714825 }
715826
716827 /// org-attach's commands for the entry at the caret.
@@ -733,6 +844,13 @@ struct ContentView: View {
733844 panel.allowsMultipleSelection = true
734845 panel.message = "File to keep as an attachment"
735846 guard panel.runModal() == .OK else { return }
847 #if APPSTORE
848 // The sandbox can remove only files in the sidebar's folders, and links nothing.
849 if method == .mv, let outside = panel.urls.first(where: { !workspace.contains($0) }) {
850 return commands.show(String(localized: "\(outside.lastPathComponent) isn't in one of your folders, so it can't be moved. Attach a copy instead.", comment: "Attach by moving a file from outside the sidebar's folders"))
851 }
852 guard method == .cp || method == .mv else { return }
853 #endif
736854 attachActions.attach(panel.urls, method: method)
737855 })
738856 }
@@ -783,6 +901,7 @@ struct ContentView: View {
783901 let plot: TablePlot.Plot
784902 do { plot = try TablePlot.plot(context.text, at: context.caret) } catch { return commands.show("\(error)") }
785903 let directory = URL(fileURLWithPath: path).deletingLastPathComponent()
904 #if !APPSTORE
786905 if let gnuplot = PlotOutput.gnuplot {
787906 commands.show("Plotting with gnuplot…")
788907 Task {
@@ -793,7 +912,11 @@ struct ContentView: View {
793912 commands.show("\(error)")
794913 }
795914 }
796 } else if let url = PlotOutput.file(plot, directory: directory) {
915 return
916 }
917 #endif
918 if let url = PlotOutput.file(plot, directory: directory) {
919 guard reach([url.path]) else { return }
797920 do {
798921 try PlotOutput.write(plot, to: url)
799922 plotWritten(url, editor: editor)
@@ -823,6 +946,9 @@ struct ContentView: View {
823946 }
824947 let codeStyle = HTMLCodeStyle(highlighter: PaneView.highlighter, theme: theme)
825948 func run(_ chosen: [PublishProject], only: String? = nil) {
949 // The chosen projects and their components read and write these folders.
950 let involved = { loaded.projects.filter { project in chosen.contains { $0 == project || $0.components.contains(project.name) } } }
951 guard reach(involved().flatMap { [$0.baseDirectory, $0.publishingDirectory] }, directories: true) else { return }
826952 do {
827953 let report = try Publish.publish(chosen, all: loaded.projects, only: only, read: read) { function, text, path, bodyOnly in
828954 let settings = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
@@ -864,7 +990,7 @@ struct ContentView: View {
864990 DispatchQueue.main.async { commands.editor?.perform(SparseTreeCommand(), answers: ["sparse": "/", "regexp": regexp]) }
865991 }
866992 case .tangle(let scope):
867 guard ProAccess.shared.allows(.babel) else { return }
993 guard ProAccess.shared.allows(.babel), reach(session.tangleFiles(scope)) else { return }
868994 commands.show(session.tangle(scope))
869995 case .agenda(let start, let days):
870996 commands.agendaRequest = (start, days)
@@ -873,6 +999,10 @@ struct ContentView: View {
873999 blockEdit = BlockEditRequest(edit: edit)
8741000 case .columnView(let view):
8751001 panel = .columns(UUID(), view)
1002 #if APPSTORE
1003 case .emacsTable(_, _, _, let reason, _):
1004 commands.show(String(localized: "This table's formulas can't be calculated here: \(TableReason.localized(reason)).", comment: "Table formulas orgstar can't calculate"))
1005 #else
8761006 case .emacsTable(let table, let point, let form, let reason, let lisp):
8771007 let run = {
8781008 commands.show(String(localized: "Recalculating in Emacs (\(TableReason.localized(reason)))…", comment: "Table formulas sent to Emacs, and why"))
@@ -890,9 +1020,11 @@ struct ContentView: View {
8901020 default: commands.show("Not recalculated")
8911021 }
8921022 }
1023 #endif
8931024 case .babel(let job):
8941025 guard ProAccess.shared.allows(.babel) else { return }
8951026 let run = {
1027 guard reach(session.resultFile(of: job).map { [$0] } ?? []) else { return }
8961028 commands.show("Running \(job.language) block… (⌘. to cancel)")
8971029 session.startBabel(job) { commands.show($0) }
8981030 }
@@ -996,6 +1128,10 @@ struct ContentView: View {
9961128
9971129 /// Runs a command from a key, the palette or the Org menu.
9981130 private func perform(_ id: String) {
1131 if hiddenCommandIDs.contains(id) {
1132 if let replacement = AppStoreCommands.replacement(for: id) { return perform(replacement) }
1133 return commands.show(Self.unavailable(EditorCommands.all.first { $0.id == id }?.title ?? id))
1134 }
9991135 if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return }
10001136 let orgOnly = ["app.refile", "app.refile.copy", "app.archive", "app.clock.in", "app.clock.default", "app.copy-rich-text"].contains(id) || (id.hasPrefix("app.export.") && !id.hasPrefix("app.export.icalendar-")) || id.hasPrefix("org.")
10011137 if orgOnly, !session.isOrg {
@@ -1096,6 +1232,7 @@ struct ContentView: View {
10961232 commands.jump(path: target.path, offset: target.start ?? Int.max)
10971233 }
10981234 case "app.archive":
1235 guard reach(session.archiveFile().map { [$0] } ?? []) else { return }
10991236 if let message = session.archive() { commands.show(message) }
11001237 case "app.table-import":
11011238 // `org-table-import`: a TSV, CSV or space-separated file becomes a table at point.
@@ -1129,7 +1266,7 @@ struct ContentView: View {
11291266 guard let editor = commands.editor, let path = session.path else { return commands.show("No method for storing a link from this buffer") }
11301267 let context = editor.context()
11311268 let denote = OrgPreferences.usesDenote() ? Links.storeDenote(in: context, path: path) : nil
1132 commands.storeLink(denote ?? Links.store(in: context, path: Links.abbreviate(path, home: NSHomeDirectory())))
1269 commands.storeLink(denote ?? Links.store(in: context, path: Links.abbreviate(path, home: OrgPaths.home)))
11331270 case "org.id.store-link":
11341271 guard let editor = commands.editor, let path = session.path else { return }
11351272 if case .commit = editor.perform(CreateID()),
@@ -1196,6 +1333,7 @@ struct ContentView: View {
11961333 case let id where id.hasPrefix("app.crypt."):
11971334 crypt(id)
11981335 case let id where id.hasPrefix("app.attach."):
1336 guard reach(attachActions.entry().flatMap { Attachments.directory($0, noFSCheck: true) }.map { [$0] } ?? [], directories: true) else { return }
11991337 attachActions.run(id)
12001338 case let id where id.hasPrefix("app.dailies.") || id.hasPrefix("app.node."):
12011339 roamActions.run(id)
Sources/Orgstar/DevelopmentHooks.swift +2
@@ -1,3 +1,4 @@
1#if !APPSTORE
12import AppKit
23import OrgEditorAppKit
34
@@ -47,3 +48,4 @@ enum DevelopmentHooks {
4748 }
4849 }
4950}
51#endif
Sources/Orgstar/EmacsImportView.swift +76 −3
@@ -12,6 +12,8 @@ struct EmacsImportView: View {
1212 @State private var choosing = false
1313 @State private var summary: String?
1414 @State private var importing = false
15 /// Doom's own folder, chosen in the App Store build, where the sandbox can't find it.
16 @State private var doomInstall: URL?
1517
1618 var body: some View {
1719 VStack(alignment: .leading, spacing: 0) {
@@ -44,7 +46,12 @@ struct EmacsImportView: View {
4446 }
4547 .frame(width: 640, height: 560)
4648 .onAppear {
49 // The sandbox can't look in the home folder, so the App Store build starts with the picker.
50 #if APPSTORE
51 if location == nil { DispatchQueue.main.async { choose() } }
52 #else
4753 if location == nil, let first = EmacsImport.defaultLocations().first { read(first) }
54 #endif
4855 }
4956 .fileImporter(isPresented: $choosing, allowedContentTypes: [.folder, .item]) { chosen in
5057 if case .success(let url) = chosen { read(url) }
@@ -55,15 +62,69 @@ struct EmacsImportView: View {
5562 HStack {
5663 VStack(alignment: .leading, spacing: 2) {
5764 Text("Import from Emacs").font(.headline)
58 Text(location.map { "Reading \($0.path)" + ((result?.isDoom ?? false) ? ", with Doom's own org defaults" : "") } ?? "")
65 Text(location.map { "Reading \($0.path)" + (withDoomDefaults ? ", with Doom's own org defaults" : "") } ?? "")
5966 .font(.caption).foregroundStyle(.secondary).lineLimit(2)
6067 }
6168 Spacer()
62 Button("Choose…") { choosing = true }
69 #if APPSTORE
70 if let result, result.isDoom, !result.doomDefaultsRead {
71 Button("Choose Doom Folder…") { chooseDoom() }
72 .help("Doom's own org defaults are read from the folder Doom is installed in")
73 }
74 #endif
75 Button("Choose…") { choose() }
6376 }
6477 .padding(12)
6578 }
6679
80 private var withDoomDefaults: Bool {
81 #if APPSTORE
82 result?.doomDefaultsRead ?? false
83 #else
84 result?.isDoom ?? false
85 #endif
86 }
87
88 private func choose() {
89 #if APPSTORE
90 let message = String(localized: "Choose your init.el, or the folder holding it (~/.emacs.d, ~/.config/doom).",
91 comment: "Open panel for importing an Emacs configuration")
92 if let url = GrantAccess.choose(at: EmacsImport.pickerLocation(), message: message, prompt: String(localized: "Choose"), files: true, hidden: true) {
93 read(url)
94 }
95 #else
96 choosing = true
97 #endif
98 }
99
100 #if APPSTORE
101 /// Doom's install folder, for its org defaults; the sandbox keeps orgstar from finding it.
102 private func chooseDoom() {
103 let message = String(localized: "Choose the folder Doom is installed in (~/.config/emacs or ~/.emacs.d) to read Doom's own org defaults.",
104 comment: "Open panel for Doom's install folder when importing from Emacs")
105 guard let install = EmacsImport.doomInstallLocations().first,
106 let url = GrantAccess.choose(at: install, message: message, prompt: String(localized: "Choose"), hidden: true),
107 let location else { return }
108 doomInstall = url
109 read(location)
110 }
111
112 /// Asks for each folder the import adds, with an open panel at it, and adds the folders
113 /// chosen there: the sandbox lets orgstar into those alone.
114 private func chooseFolders(_ items: [EmacsImport.Item]) -> [String: URL] {
115 var chosen: [String: URL] = [:]
116 for path in EmacsImport.foldersToAdd(items, workspace: workspace) where chosen[path] == nil {
117 let name = OrgPaths.abbreviatingWithTilde(OrgPaths.expandingTilde(path))
118 let message = String(localized: "Choose \(name) to add it to the sidebar.", comment: "Open panel for a folder imported from Emacs")
119 if let url = GrantAccess.choose(at: URL(fileURLWithPath: OrgPaths.expandingTilde(path)), message: message,
120 prompt: String(localized: "Add Folder")) {
121 chosen[path] = url
122 }
123 }
124 return chosen
125 }
126 #endif
127
67128 private func list(_ result: EmacsImport) -> some View {
68129 List {
69130 EmacsImportSections(result: result, groups: result.groups(folders: true), selected: $selected,
@@ -74,6 +135,9 @@ struct EmacsImportView: View {
74135 private func footnote(_ result: EmacsImport) -> String {
75136 var parts = ["\(result.skipped) variables not about org left alone"]
76137 if result.doomDefaultsLeftOut > 0 { parts.append("\(result.doomDefaultsLeftOut) Doom defaults orgstar has no use for") }
138 #if APPSTORE
139 if result.isDoom, !result.doomDefaultsRead { parts.append("Doom's own org defaults skipped") }
140 #endif
77141 return parts.joined(separator: "; ")
78142 }
79143
@@ -81,7 +145,11 @@ struct EmacsImportView: View {
81145 let accessing = url.startAccessingSecurityScopedResource()
82146 defer { if accessing { url.stopAccessingSecurityScopedResource() } }
83147 location = url
148 #if APPSTORE
149 let scanned = EmacsImport.scan(EmacsImport.files(in: url), doomDefaults: doomInstall.map(EmacsImport.doomDefaultFiles(in:)))
150 #else
84151 let scanned = EmacsImport.scan(EmacsImport.files(in: url))
152 #endif
85153 result = scanned
86154 selected = Set(scanned.items.map(\.id))
87155 summary = nil
@@ -91,8 +159,13 @@ struct EmacsImportView: View {
91159 guard let result else { return }
92160 importing = true
93161 let chosen = result.items.filter { selected.contains($0.id) }
162 #if APPSTORE
163 let folders: [String: URL]? = chooseFolders(chosen)
164 #else
165 let folders: [String: URL]? = nil
166 #endif
94167 Task {
95 summary = await EmacsImport.apply(chosen, workspace: workspace)
168 summary = await EmacsImport.apply(chosen, workspace: workspace, chosenFolders: folders)
96169 importing = false
97170 }
98171 }
Sources/Orgstar/ExportSheet.swift +14 −1
@@ -8,7 +8,9 @@ struct ExportSheet: View {
88 let inSubtree: Bool
99 /// The default destination for an extension, with or without the subtree.
1010 let target: (_ ext: String, _ subtree: Bool) -> URL
11 let export: (_ format: String, _ destination: URL, _ open: Bool, _ subtree: Bool, _ bodyOnly: Bool) -> Void
11 /// Without a chosen destination, the App Store build passes nil, and the export asks where
12 /// to write when the default is outside the sandbox's reach.
13 let export: (_ format: String, _ destination: URL?, _ open: Bool, _ subtree: Bool, _ bodyOnly: Bool) -> Void
1214 @AppStorage("exportFormat") private var format = "html"
1315 @AppStorage("exportOpenAfter") private var openAfter = false
1416 @AppStorage("exportBodyOnly") private var bodyOnly = false
@@ -19,12 +21,19 @@ struct ExportSheet: View {
1921 @State private var destination: URL?
2022 @Environment(\.dismiss) private var dismiss
2123
24 #if APPSTORE
25 static let formats: [(id: String, title: String, ext: String)] = [
26 ("html", "HTML", "html"), ("markdown", "Markdown", "md"), ("print-pdf", "PDF", "pdf"), ("docx", "Word", "docx"),
27 ("rtf", "Rich Text (RTF)", "rtf"), ("plain-text", "Plain text", "txt"), ("icalendar", "iCalendar", "ics"),
28 ]
29 #else
2230 static let formats: [(id: String, title: String, ext: String)] = [
2331 ("html", "HTML", "html"), ("markdown", "Markdown", "md"), ("print-pdf", "PDF", "pdf"), ("docx", "Word", "docx"),
2432 ("rtf", "Rich Text (RTF)", "rtf"), ("plain-text", "Plain text", "txt"), ("pdf", "PDF via LaTeX (Emacs)", "pdf"),
2533 ("odt", "ODT (Emacs)", "odt"), ("latex", "LaTeX (Emacs)", "tex"), ("text", "Plain text, ASCII (Emacs)", "txt"),
2634 ("icalendar", "iCalendar", "ics"),
2735 ]
36 #endif
2837
2938 private var ext: String { Self.formats.first { $0.id == format }?.ext ?? "html" }
3039 private var chosen: URL { destination ?? target(ext, subtree) }
@@ -68,7 +77,11 @@ struct ExportSheet: View {
6877 Spacer()
6978 Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction)
7079 Button("Export") {
80 #if APPSTORE
81 export(format, destination, openAfter, subtree && inSubtree, bodyOnly && allowsBodyOnly)
82 #else
7183 export(format, chosen, openAfter, subtree && inSubtree, bodyOnly && allowsBodyOnly)
84 #endif
7285 dismiss()
7386 }
7487 .keyboardShortcut(.defaultAction)
Sources/Orgstar/GrantAccess.swift added +88
@@ -0,0 +1,88 @@
1#if APPSTORE
2import AppKit
3import OrgApp
4import OrgCore
5import OrgWorkspace
6
7/// Access to folders outside the sidebar's folders, which the sandbox keeps orgstar out of
8/// until they're chosen in an open panel.
9@MainActor
10enum GrantAccess {
11 enum Answer {
12 case granted, alternative, canceled
13 }
14
15 /// Says orgstar can't reach `folder` and offers an open panel at it, plus `alternative`
16 /// when given. A folder chosen in the panel is kept as a grant; `granted` once it covers
17 /// `folder`.
18 static func ask(_ folder: URL, workspace: WorkspaceModel, alternative: String? = nil) -> Answer {
19 let alert = NSAlert()
20 let name = OrgPaths.abbreviatingWithTilde(folder.path)
21 alert.messageText = String(localized: "orgstar can't reach \(name).", comment: "Alert for a folder outside the sidebar's folders")
22 alert.informativeText = String(localized: "It isn't in one of your folders. Grant access to it to continue.", comment: "Alert for a folder outside the sidebar's folders")
23 alert.addButton(withTitle: String(localized: "Grant Access…", comment: "Button that opens a panel to give orgstar access to a folder"))
24 if let alternative { alert.addButton(withTitle: alternative) }
25 alert.addButton(withTitle: String(localized: "Cancel"))
26 switch alert.runModal() {
27 case .alertFirstButtonReturn: break
28 case .alertSecondButtonReturn where alternative != nil: return .alternative
29 default: return .canceled
30 }
31 guard let url = choose(at: folder, message: String(localized: "Choose \(name) or a folder that contains it.", comment: "Open panel for giving orgstar access to a folder"),
32 prompt: String(localized: "Grant Access", comment: "Open panel button that gives orgstar access to a folder")) else { return .canceled }
33 guard FolderGrants.covers(url, folder) else {
34 tell(String(localized: "\(OrgPaths.abbreviatingWithTilde(url.path)) doesn't contain \(name).", comment: "Alert when the folder chosen to grant access doesn't contain the one needed"),
35 String(localized: "Choose \(name) or a folder that contains it.", comment: "Open panel for giving orgstar access to a folder"))
36 return .canceled
37 }
38 if !FolderGrants.shared.add(url) {
39 tell(String(localized: "orgstar can't keep access to \(name).", comment: "Alert when a folder grant can't be saved"),
40 String(localized: "Access lasts until orgstar quits.", comment: "Alert when a folder grant or the configuration folder can't be saved"))
41 }
42 return workspace.foldersToGrant(for: [folder.path], directories: true).isEmpty ? .granted : .canceled
43 }
44
45 static func tell(_ message: String, _ information: String) {
46 let alert = NSAlert()
47 alert.messageText = message
48 alert.informativeText = information
49 alert.runModal()
50 }
51
52 /// An open panel at `location`, for a folder, or a file too with `files`. Hidden files show
53 /// with `hidden`, for dot folders such as `~/.config`.
54 static func choose(at location: URL, message: String, prompt: String, files: Bool = false, hidden: Bool = false) -> URL? {
55 let panel = NSOpenPanel()
56 panel.canChooseDirectories = true
57 panel.canChooseFiles = files
58 panel.canCreateDirectories = true
59 panel.showsHiddenFiles = hidden
60 panel.directoryURL = location
61 panel.prompt = prompt
62 panel.message = message
63 return panel.runModal() == .OK ? panel.url : nil
64 }
65
66 /// Asks again for `root`, a sidebar folder that doesn't resolve, with an open panel at where
67 /// it was, and puts the folder chosen in its place.
68 static func regrant(_ root: WorkspaceRoot, workspace: WorkspaceModel) {
69 let name = OrgPaths.abbreviatingWithTilde(root.path)
70 guard let url = choose(at: URL(fileURLWithPath: root.path),
71 message: String(localized: "Choose \(name) to give orgstar access to it again.", comment: "Open panel for a sidebar folder orgstar can't open"),
72 prompt: String(localized: "Grant Access", comment: "Open panel button that gives orgstar access to a folder")) else { return }
73 Task {
74 do { try await workspace.regrant(root, with: url) } catch { workspace.lastError = error.localizedDescription }
75 }
76 }
77
78 /// Asks for each folder `paths` need, in turn. Whether all of them can now be reached.
79 static func reach(_ paths: [String], directories: Bool = false, workspace: WorkspaceModel) -> Bool {
80 for folder in workspace.foldersToGrant(for: paths, directories: directories) {
81 // An earlier grant may cover this one.
82 guard !workspace.foldersToGrant(for: [folder.path], directories: true).isEmpty else { continue }
83 guard ask(folder, workspace: workspace) == .granted else { return false }
84 }
85 return true
86 }
87}
88#endif
Sources/Orgstar/Keys.swift +8 −1
@@ -179,6 +179,13 @@ extension EchoArea {
179179 }
180180}
181181
182/// Commands this build leaves out of the palette and menus; their keys say so when pressed.
183#if APPSTORE
184let hiddenCommandIDs = AppStoreCommands.hidden
185#else
186let hiddenCommandIDs: Set<String> = []
187#endif
188
182189/// M-x and ⇧⌘P: every command by title, with its keys.
183190struct PaletteView: View {
184191 let commands: AppCommands
@@ -187,7 +194,7 @@ struct PaletteView: View {
187194 @Environment(\.dismiss) private var dismiss
188195
189196 private var matches: [EditorCommand] {
190 let scored: [(command: EditorCommand, score: Int)] = EditorCommands.all.filter(\.inPalette).compactMap { command in
197 let scored: [(command: EditorCommand, score: Int)] = EditorCommands.all.filter { $0.inPalette && !hiddenCommandIDs.contains($0.id) }.compactMap { command in
191198 guard let score = FuzzyMatch.score(query, command.localizedTitle) ?? FuzzyMatch.score(query, command.title) else { return nil }
192199 return (command, score)
193200 }
Sources/Orgstar/LinkOpener.swift +5
@@ -8,6 +8,11 @@ enum LinkOpener {
88 /// Returns a message when the link can't be followed.
99 /// `ask` picks among a query link's matches.
1010 static func open(_ link: OrgLink, session: DocumentSession, workspace: WorkspaceModel, ask: @escaping (Prompt, @escaping (String?) -> Void) -> Void) -> String? {
11 #if APPSTORE
12 // A file outside the sidebar's folders needs access to its folder first.
13 if link.type == "file", !link.path.isEmpty,
14 !GrantAccess.reach([DocumentSession.resolve(link.path, from: session.path)], workspace: workspace) { return nil }
15 #endif
1116 switch session.follow(link, workspace: workspace, isText: FileTypes.isText) {
1217 case .shown: return nil
1318 case .openExternally(let url):
Sources/Orgstar/OrgstarApp.swift +118 −6
@@ -3,6 +3,9 @@ import OrgApp
33import OrgCore
44import OrgEditorAppKit
55import OrgPresentation
6#if !APPSTORE
7import OrgPrograms
8#endif
69import SwiftUI
710import UserNotifications
811
@@ -36,6 +39,10 @@ final class AppCommands {
3639 /// Files and images pasted or dropped on an editor; the main window sets them.
3740 var filesHandler: (([URL]) -> Void)?
3841 var imageHandler: ((Data, String) -> Void)?
42 #if APPSTORE
43 /// Asks for the folders outside the sidebar's folders that paths need; the main window sets it.
44 var reach: ([String]) -> Bool = { _ in true }
45 #endif
3946 /// Tags used across the workspace, for tag completion; the main window sets it.
4047 var knownTags: () -> [String] = { [] }
4148 /// The pending key prefix, and what can follow it.
@@ -179,17 +186,32 @@ struct PromptRequest: Identifiable {
179186final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
180187 var session: DocumentSession?
181188 var commands: AppCommands?
189 #if APPSTORE
190 var workspace: WorkspaceModel?
191 #else
182192 let updates = Updates()
193 #endif
183194
184195 func applicationDidFinishLaunching(_ notification: Notification) {
185196 DockIcon.start()
186197 if SystemReminderCenter.isAvailable { UNUserNotificationCenter.current().delegate = self }
198 #if !APPSTORE
187199 updates.start()
200 #endif
201 }
202
203 #if APPSTORE
204 /// A subscription may have lapsed or renewed while the app was in the background.
205 func applicationDidBecomeActive(_ notification: Notification) {
206 Task { await ProStore.shared.refresh() }
188207 }
208 #endif
189209
190210 /// `:session` interpreters end with the app.
191211 func applicationWillTerminate(_ notification: Notification) {
212 #if !APPSTORE
192213 BabelSessions.shared.stopAll()
214 #endif
193215 }
194216
195217 /// Reminders show while Orgstar is in front too.
@@ -233,7 +255,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
233255
234256 func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
235257 guard let session else { return .terminateNow }
258 #if APPSTORE
259 BufferRestore.save(session, workspace: workspace)
260 #else
236261 BufferRestore.save(session)
262 #endif
237263 return UnsavedChanges.resolve(session, paths: session.openPaths) ? .terminateNow : .terminateCancel
238264 }
239265}
@@ -289,18 +315,42 @@ enum BufferRestore {
289315 var paths: [String]
290316 var current: String?
291317 var carets: [String: Int]
318 /// In the Mac App Store build, bookmarks of the files outside every folder, which the
319 /// sandbox would otherwise keep orgstar out of after relaunch.
320 var bookmarks: [String: Data]?
292321 }
293322
294 static func save(_ session: DocumentSession, defaults: UserDefaults = .standard) {
323 /// `bookmarking` says which paths get a bookmark. A path still open keeps the bookmark it
324 /// has when no new one is made.
325 static func save(_ session: DocumentSession, bookmarking: (String) -> Bool = { _ in false }, defaults: UserDefaults = .standard) {
295326 var carets: [String: Int] = [:]
296327 for path in session.openPaths { carets[path] = session.caret(of: path) }
297 let state = State(paths: session.openPaths, current: session.path, carets: carets)
328 let previous = defaults.data(forKey: key).flatMap { try? JSONDecoder().decode(State.self, from: $0) }?.bookmarks ?? [:]
329 var bookmarks: [String: Data] = [:]
330 for path in session.openPaths {
331 bookmarks[path] = (bookmarking(path) ? SecurityBookmark.make(URL(fileURLWithPath: path)) : nil) ?? previous[path]
332 }
333 let state = State(paths: session.openPaths, current: session.path, carets: carets, bookmarks: bookmarks.isEmpty ? nil : bookmarks)
298334 if let data = try? JSONEncoder().encode(state) { defaults.set(data, forKey: key) }
299335 }
300336
337 #if APPSTORE
338 /// Saves with bookmarks for the files outside `workspace`'s folders and grants.
339 static func save(_ session: DocumentSession, workspace: WorkspaceModel?) {
340 save(session, bookmarking: { workspace?.contains(URL(fileURLWithPath: $0)) != true })
341 }
342 #endif
343
301344 /// Opens the buffers that were open, in order, and returns the carets to show them at.
302345 static func restore(_ session: DocumentSession, defaults: UserDefaults = .standard) -> [String: Int] {
303 guard let data = defaults.data(forKey: key), let state = try? JSONDecoder().decode(State.self, from: data) else { return [:] }
346 guard let data = defaults.data(forKey: key), var state = try? JSONDecoder().decode(State.self, from: data) else { return [:] }
347 // A bookmarked file comes back with access, at the path it has now.
348 for (path, bookmark) in state.bookmarks ?? [:] {
349 guard let moved = SecurityBookmark.resolve(bookmark)?.url.path, moved != path else { continue }
350 state.paths = state.paths.map { $0 == path ? moved : $0 }
351 if state.current == path { state.current = moved }
352 state.carets[moved] = state.carets.removeValue(forKey: path)
353 }
304354 let existing = state.paths.filter { FileManager.default.fileExists(atPath: $0) }
305355 for path in existing { session.open(path) }
306356 if let current = state.current, existing.contains(current) { session.open(current) }
@@ -324,8 +374,16 @@ struct OrgstarApp: App {
324374 }()
325375
326376 init() {
377 #if APPSTORE
378 AgendaSnapshot.useGroupContainer = true
379 EmacsFallback.offered = false
380 _ = FolderGrants.shared
381 ProStore.shared.start()
382 #else
383 DocumentSession.programs = Programs()
327384 MacPro.resolve()
328385 MacPro.renewInBackground()
386 #endif
329387 // Debug builds, and runs with ORGSTAR_PERF set: main-thread stalls in the console.
330388 #if DEBUG
331389 Perf.watchMainThread()
@@ -344,6 +402,9 @@ struct OrgstarApp: App {
344402 .onAppear {
345403 delegate.session = session
346404 delegate.commands = commands
405 #if APPSTORE
406 delegate.workspace = model
407 #endif
347408 CaptureIntent.environment = (model, session, clock, commands)
348409 }
349410 case .failure(let error):
@@ -400,7 +461,7 @@ struct OrgstarApp: App {
400461 }
401462 CommandGroup(after: .saveItem) {
402463 Menu("Export") {
403 ForEach(EditorCommands.all.filter { $0.id.hasPrefix("app.export.") }, id: \.id) { command in
464 ForEach(EditorCommands.all.filter { $0.id.hasPrefix("app.export.") && !hiddenCommandIDs.contains($0.id) }, id: \.id) { command in
404465 Button(command.localizedTitle) { commands.run(command.id) }
405466 }
406467 }
@@ -503,12 +564,18 @@ struct OrgstarApp: App {
503564 Button("Edit Config File") { commands.jump(path: UserConfig.configFile.path, offset: 0) }
504565 .keyboardShortcut(",", modifiers: [.command, .option])
505566 }
567 #if !APPSTORE
506568 CommandGroup(after: .appInfo) {
507569 CheckForUpdatesItem(updates: delegate.updates)
508570 }
571 #endif
509572 }
510573 Settings {
574 #if APPSTORE
575 SettingsView(commands: commands, workspace: try? workspace.get())
576 #else
511577 SettingsView(commands: commands, workspace: try? workspace.get(), updates: delegate.updates)
578 #endif
512579 }
513580 }
514581}
@@ -587,8 +654,13 @@ struct AgendaMenuItem: View {
587654struct SettingsView: View {
588655 let commands: AppCommands
589656 let workspace: WorkspaceModel?
657 #if !APPSTORE
590658 let updates: Updates
659 #endif
591660 @State private var importing = false
661 #if APPSTORE
662 @State private var configFolder = UserConfig.directoryOverride
663 #endif
592664 @Environment(\.openWindow) private var openWindow
593665 @AppStorage("saveMode") private var saveMode = SaveMode.automatic
594666 @AppStorage("keymap") private var preset = KeymapPreset.emacs
@@ -651,7 +723,11 @@ struct SettingsView: View {
651723 Tab("Appearance", systemImage: "paintpalette", value: "appearance") { appearance }
652724 Tab("Agenda", systemImage: "calendar", value: "agenda") { agenda }
653725 Tab("Capture", systemImage: "tray.and.arrow.down", value: "capture") { capture }
726 #if APPSTORE
727 Tab("orgstar+", systemImage: "star", value: "pro") { StoreForm() }
728 #else
654729 Tab("orgstar+", systemImage: "star", value: "pro") { LicenseForm() }
730 #endif
655731 }
656732 .frame(width: 600)
657733 }
@@ -662,6 +738,32 @@ struct SettingsView: View {
662738 commands.jump(path: UserConfig.configFile.path, offset: 0)
663739 }
664740
741 #if APPSTORE
742 /// A folder outside the app's container, such as `~/.config/orgstar` kept with dotfiles.
743 private func chooseConfigFolder() {
744 let panel = NSOpenPanel()
745 panel.canChooseFiles = false
746 panel.canChooseDirectories = true
747 panel.canCreateDirectories = true
748 panel.directoryURL = configFolder ?? ConfigFolder.suggested
749 panel.message = String(localized: "Choose the folder for config.toml and orgstar's other configuration files.", comment: "Choose Configuration Folder panel")
750 guard panel.runModal() == .OK, let url = panel.url else { return }
751 if !ConfigFolder.set(url) {
752 GrantAccess.tell(String(localized: "orgstar can't keep \(OrgPaths.abbreviatingWithTilde(url.path)) as the configuration folder.", comment: "Alert when the chosen configuration folder can't be saved"),
753 String(localized: "Access lasts until orgstar quits.", comment: "Alert when a folder grant or the configuration folder can't be saved"))
754 }
755 useConfigFolder(url)
756 }
757
758 /// Reads and writes the configuration in `url`, or with nil in the default folder.
759 private func useConfigFolder(_ url: URL?) {
760 if url == nil { ConfigFolder.clear() }
761 UserConfig.directoryOverride = url
762 configFolder = url
763 ConfigSync.shared.move(to: UserConfig.configFile)
764 }
765 #endif
766
665767 private var general: some View {
666768 Form {
667769 Section {
@@ -672,6 +774,14 @@ struct SettingsView: View {
672774 Button("Show in Finder") { NSWorkspace.shared.activateFileViewerSelecting([UserConfig.configFile]) }
673775 }
674776 }
777 #if APPSTORE
778 LabeledContent("Folder") {
779 HStack {
780 Button("Choose Configuration Folder…") { chooseConfigFolder() }
781 if configFolder != nil { Button("Use Default Folder") { useConfigFolder(nil) } }
782 }
783 }
784 #endif
675785 LabeledContent("Emacs") {
676786 Button("Import from Emacs…") { importing = true }
677787 }
@@ -679,14 +789,16 @@ struct SettingsView: View {
679789 Text("Every setting here is also in \(UserConfig.configFile.path), which you can edit, share or keep with your dotfiles. Changes in either place show up in the other.")
680790 .settingsFooter()
681791 }
792 #if !APPSTORE
682793 if updates.canCheck {
683794 Section {
684 Toggle("Check for updates automatically", isOn: Binding(get: { updates.automatically }, set: { updates.automatically = $0 }))
795 Toggle(isOn: Binding(get: { updates.automatically }, set: { updates.automatically = $0 })) { Text("Check for updates automatically", tableName: "DeveloperID") }
685796 } footer: {
686 Text("Once a day, from the app's own feed. orgstar ▸ Check for Updates… checks now.")
797 Text("Once a day, from the app's own feed. orgstar ▸ Check for Updates… checks now.", tableName: "DeveloperID")
687798 .settingsFooter()
688799 }
689800 }
801 #endif
690802 Section {
691803 Picker("Save files", selection: $saveMode) {
692804 Text("Automatically, when typing stops").tag(SaveMode.automatic)
Sources/Orgstar/PaneView.swift +4 −1
@@ -109,9 +109,12 @@ struct PaneView: NSViewRepresentable {
109109 }
110110 editor.onAppCommand = onAppCommand
111111 editor.onOpenFile = { [weak session, weak commands] typed in
112 let expanded = (typed as NSString).expandingTildeInPath
112 let expanded = OrgPaths.expandingTilde(typed)
113113 let base = URL(fileURLWithPath: path).deletingLastPathComponent()
114114 let target = expanded.hasPrefix("/") ? expanded : base.appendingPathComponent(expanded).standardizedFileURL.path
115 #if APPSTORE
116 guard commands?.reach([target]) ?? false else { return }
117 #endif
115118 guard FileManager.default.fileExists(atPath: target) else {
116119 commands?.show("No file \(typed)")
117120 return
Sources/Orgstar/Preferences.swift +9
@@ -6,9 +6,18 @@ import OrgCore
66enum Preferences {
77 static let defaultTodoKeywords = OrgPreferences.defaultTodoKeywords
88
9 #if APPSTORE
10 /// The folder chosen with Choose Configuration Folder…, used before anything reads the
11 /// configuration.
12 private static let chosenConfigFolder: Void = { UserConfig.directoryOverride = ConfigFolder.resolve() }()
13 #endif
14
915 /// TODO keywords for files without `#+TODO`, read at launch.
1016 @MainActor
1117 static var orgSettings: OrgSettings {
18 #if APPSTORE
19 _ = chosenConfigFolder
20 #endif
1221 // config.toml applies before anything reads settings.
1322 ConfigSync.shared.start()
1423 return OrgPreferences.orgSettings()
Sources/Orgstar/ProLicense.swift +13 −8
@@ -1,6 +1,7 @@
11import OrgApp
22import SwiftUI
33
4#if !APPSTORE
45/// Pro on the Mac: a license key for sponsoring on GitHub, or an install that predates Pro.
56enum MacPro {
67 static let buyURL = URL(string: "https://krz.sh/apps/orgstar/buy")!
@@ -45,7 +46,7 @@ struct LicenseForm: View {
4546 LabeledContent("orgstar+", value: license.map { "Licensed to \($0.holder)" } ?? "Licensed")
4647 if let expires = license?.expires {
4748 let date = Date(timeIntervalSince1970: TimeInterval(expires)).formatted(date: .abbreviated, time: .omitted)
48 Text("Renews while you sponsor monthly. This key is valid until \(date).")
49 Text("Renews while you sponsor monthly. This key is valid until \(date).", tableName: "DeveloperID")
4950 .foregroundStyle(.secondary)
5051 }
5152 case .grandfathered:
@@ -56,26 +57,28 @@ struct LicenseForm: View {
5657 }
5758 if access.grant != .license {
5859 Section {
59 TextField("License key", text: $key, prompt: Text("ORGSTAR1-…"), axis: .vertical)
60 TextField(text: $key, prompt: Text("ORGSTAR1-…", tableName: "DeveloperID"), axis: .vertical) { Text("License key", tableName: "DeveloperID") }
6061 .lineLimit(2...4)
6162 .font(.body.monospaced())
6263 .onSubmit(activate)
6364 if let error { Text(error).foregroundStyle(.red) }
6465 HStack {
65 Link("Sponsor for orgstar+…", destination: MacPro.buyURL)
66 Link("Get Your Key…", destination: MacPro.keyURL)
66 Link(destination: MacPro.buyURL) { Text("Sponsor for orgstar+…", tableName: "DeveloperID") }
67 Link(destination: MacPro.keyURL) { Text("Get Your Key…", tableName: "DeveloperID") }
6768 Spacer()
68 Button("Activate", action: activate).disabled(key.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
69 Button(action: activate) { Text("Activate", tableName: "DeveloperID") }.disabled(key.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
6970 }
7071 } footer: {
71 Text("Sponsors get their key by signing in with GitHub. It is checked on this Mac; a monthly sponsor's key is renewed with krz.sh.")
72 Text("Sponsors get their key by signing in with GitHub. It is checked on this Mac; a monthly sponsor's key is renewed with krz.sh.", tableName: "DeveloperID")
7273 }
7374 } else {
7475 Section {
75 Button("Remove License from This Mac", role: .destructive) {
76 Button(role: .destructive) {
7677 LicenseStore.remove()
7778 license = nil
7879 MacPro.resolve()
80 } label: {
81 Text("Remove License from This Mac", tableName: "DeveloperID")
7982 }
8083 }
8184 }
@@ -113,7 +116,7 @@ struct ProPaywallSheet: View {
113116 VStack(alignment: .leading, spacing: 0) {
114117 VStack(alignment: .leading, spacing: 6) {
115118 Label("\(feature.title) needs orgstar+", systemImage: feature.systemImage).font(.headline)
116 Text("orgstar+ for Mac comes with sponsoring orgstar on GitHub: $60 once, or $5 a month. Editing, the agenda, capture, clocking and search stay free.")
119 Text("orgstar+ for Mac comes with sponsoring orgstar on GitHub: $60 once, or $5 a month. Editing, the agenda, capture, clocking and search stay free.", tableName: "DeveloperID")
117120 .foregroundStyle(.secondary)
118121 }
119122 .padding([.horizontal, .top], 20)
@@ -129,6 +132,8 @@ struct ProPaywallSheet: View {
129132 }
130133}
131134
135#endif
136
132137extension ProFeature {
133138 /// The Pro features the Mac app has.
134139 static let macFeatures: [ProFeature] = [.babel, .export, .encryption, .roam, .widgets, .calendar, .shortcuts]
Sources/Orgstar/Sidebar.swift +21
@@ -49,6 +49,27 @@ struct Sidebar: View {
4949 .contextMenu { folderMenu(root) }
5050 }
5151 }
52 #if APPSTORE
53 if !workspace.unresolvedRoots.isEmpty {
54 Section("Can't Open") {
55 ForEach(workspace.unresolvedRoots, id: \.path) { root in
56 HStack {
57 Label((root.path as NSString).lastPathComponent, systemImage: "exclamationmark.triangle")
58 .foregroundStyle(.secondary)
59 Spacer()
60 Button("Grant Access…") { GrantAccess.regrant(root, workspace: workspace) }
61 .buttonStyle(.borderless)
62 .controlSize(.small)
63 }
64 .help(root.path)
65 .contextMenu {
66 Button("Grant Access…") { GrantAccess.regrant(root, workspace: workspace) }
67 Button("Remove from Sidebar…") { removing = root.path }
68 }
69 }
70 }
71 }
72 #endif
5273 }
5374 .listStyle(.sidebar)
5475 .themedListBackground(theme.color("sidebar-background", in: colorScheme))
Sources/Orgstar/StoreViews.swift added +210
@@ -0,0 +1,210 @@
1#if APPSTORE
2import OrgApp
3import StoreKit
4import SwiftUI
5
6/// orgstar+ from the App Store: status, plans with their prices and renewal terms, restoring,
7/// managing a subscription, and tips.
8struct StoreForm: View {
9 /// The feature that led here, if any.
10 var feature: ProFeature?
11 /// Whether to show the tips section, which the paywall leaves out.
12 var showsTips = true
13 private var store: ProStore { .shared }
14 private var access: ProAccess { .shared }
15
16 static let termsURL = URL(string: "https://www.apple.com/legal/internet-services/itunes/dev/stdeula/")!
17 static let privacyURL = URL(string: "https://krz.sh/privacy/orgstar/")!
18 static let subscriptionsURL = URL(string: "https://apps.apple.com/account/subscriptions")!
19
20 var body: some View {
21 Form {
22 Section {
23 HStack(spacing: 12) {
24 Image(systemName: "star.fill")
25 .font(.title2)
26 .foregroundStyle(.white)
27 .frame(width: 40, height: 40)
28 .background(.orange.gradient, in: .rect(cornerRadius: 9))
29 .accessibilityHidden(true)
30 VStack(alignment: .leading, spacing: 2) {
31 if let feature, !access.isUnlocked {
32 Text("\(feature.storeTitle) needs orgstar+.").font(.headline)
33 } else {
34 Text(verbatim: "orgstar+").font(.headline)
35 }
36 Text(status).foregroundStyle(.secondary)
37 }
38 }
39 }
40 Section {
41 ForEach(ProFeature.macFeatures) { feature in
42 Label(feature.storeTitle, systemImage: feature.systemImage)
43 }
44 } header: {
45 Text("Included in orgstar+")
46 } footer: {
47 Text("Editing, the agenda, capture, clocking, tables and search stay free.").settingsFooter()
48 }
49 if store.activeProductID != ProStore.lifetime {
50 Section {
51 if store.isLoading && store.products.isEmpty {
52 ProgressView().frame(maxWidth: .infinity)
53 }
54 ForEach(store.products) { product in plan(product) }
55 if !store.isLoading && store.message != nil && store.products.count < ProStore.productIDs.count {
56 Button("Try Again") { Task { await store.loadProducts() } }
57 }
58 } header: {
59 Text("Choose a plan")
60 } footer: {
61 Text("Subscriptions renew automatically until cancelled in your Apple Account settings, at least 24 hours before the period ends.")
62 .settingsFooter()
63 }
64 }
65 Section {
66 HStack {
67 Button("Restore Purchases") { Task { await store.restore() } }.disabled(store.busy)
68 if store.activeProductID == ProStore.monthly || store.activeProductID == ProStore.yearly {
69 Link("Manage Subscription…", destination: Self.subscriptionsURL)
70 }
71 Spacer()
72 Link("Terms of Use", destination: Self.termsURL)
73 Link("Privacy Policy", destination: Self.privacyURL)
74 }
75 if let message = store.message {
76 Text(message).foregroundStyle(.secondary)
77 }
78 }
79 if showsTips {
80 StoreTipSection()
81 }
82 }
83 .formStyle(.grouped)
84 .task { await store.loadProducts() }
85 }
86
87 /// One plan: its name, an optional savings tag, what it bills, and a button with its price.
88 private func plan(_ product: Product) -> some View {
89 LabeledContent {
90 Button(price(product)) { Task { await store.buy(product) } }
91 .monospacedDigit()
92 .disabled(store.busy || product.id == store.activeProductID)
93 } label: {
94 HStack(spacing: 6) {
95 Text(product.displayName)
96 if let percent = savings(product) {
97 Text("Save \(percent)%")
98 .font(.caption.bold())
99 .foregroundStyle(.white)
100 .padding(.horizontal, 6)
101 .padding(.vertical, 1)
102 .background(.orange.gradient, in: .capsule)
103 }
104 }
105 Text(detail(product))
106 }
107 }
108
109 private func detail(_ product: Product) -> String {
110 if product.id == store.activeProductID { return String(localized: "Current plan") }
111 switch product.id {
112 case ProStore.monthly: return String(localized: "Billed monthly")
113 case ProStore.yearly:
114 let perMonth = (product.price / 12).formatted(product.priceFormatStyle)
115 return String(localized: "\(perMonth) a month, billed yearly")
116 default: return String(localized: "One payment, no subscription")
117 }
118 }
119
120 /// The price with its billing period.
121 private func price(_ product: Product) -> String {
122 switch product.subscription?.subscriptionPeriod.unit {
123 case .month: String(localized: "\(product.displayPrice) / month")
124 case .year: String(localized: "\(product.displayPrice) / year")
125 default: product.displayPrice
126 }
127 }
128
129 private func savings(_ product: Product) -> Int? {
130 guard product.id == ProStore.yearly,
131 let monthly = store.products.first(where: { $0.id == ProStore.monthly })
132 else { return nil }
133 return ProStore.yearlySavings(yearly: product.price, monthly: monthly.price)
134 }
135
136 private var status: String {
137 guard access.isUnlocked else { return String(localized: "Power features and Apple integrations, on top of everything that stays free.") }
138 return store.activeProductID == ProStore.lifetime
139 ? String(localized: "You own orgstar+. Thank you for supporting orgstar.")
140 : String(localized: "Your orgstar+ subscription is active. Thank you for supporting orgstar.")
141 }
142}
143
144/// Tips, for everyone, with or without orgstar+.
145struct StoreTipSection: View {
146 @State private var store = TipStore()
147
148 var body: some View {
149 Section {
150 if store.isLoading && store.products.isEmpty {
151 ProgressView().frame(maxWidth: .infinity)
152 }
153 ForEach(store.products) { product in
154 LabeledContent(product.displayName) {
155 if store.purchasingProductID == product.id {
156 ProgressView().controlSize(.small)
157 } else {
158 Button(product.displayPrice) { Task { await store.purchase(product) } }
159 .monospacedDigit()
160 .disabled(store.purchasingProductID != nil)
161 }
162 }
163 }
164 if let message = store.message {
165 Text(message).foregroundStyle(.secondary)
166 if store.products.count < Tip.productIDs.count {
167 Button("Try Again") { Task { await store.loadProducts() } }.disabled(store.isLoading)
168 }
169 }
170 } header: {
171 Text("Support Development")
172 } footer: {
173 Text("Tips are one-time purchases that help pay for orgstar's development. They don't unlock anything.")
174 .settingsFooter()
175 }
176 .task { await store.loadProducts() }
177 .alert("Thank You", isPresented: $store.thanked) {
178 Button("OK") {}
179 } message: {
180 Text("Your tip helps keep orgstar going.")
181 }
182 }
183}
184
185/// Shown when a Pro feature is used without Pro.
186struct StorePaywallSheet: View {
187 let feature: ProFeature
188 @Environment(\.dismiss) private var dismiss
189
190 var body: some View {
191 VStack(spacing: 0) {
192 StoreForm(feature: feature, showsTips: false)
193 HStack {
194 Spacer()
195 Button("Done") { dismiss() }.keyboardShortcut(.defaultAction)
196 }
197 .padding([.horizontal, .bottom], 20)
198 }
199 .frame(width: 520, height: 600)
200 .onChange(of: ProAccess.shared.isUnlocked) { _, unlocked in if unlocked { dismiss() } }
201 }
202}
203
204extension ProFeature {
205 /// The title in the App Store build, which runs Emacs Lisp blocks natively.
206 var storeTitle: String {
207 self == .babel ? String(localized: "Run Emacs Lisp blocks and tangle") : title
208 }
209}
210#endif
Sources/Orgstar/Updates.swift +3 −1
@@ -1,3 +1,4 @@
1#if !APPSTORE
12import Combine
23import Sparkle
34import SwiftUI
@@ -36,7 +37,8 @@ struct CheckForUpdatesItem: View {
3637 let updates: Updates
3738
3839 var body: some View {
39 Button("Check for Updates…") { updates.check() }
40 Button { updates.check() } label: { Text("Check for Updates…", tableName: "DeveloperID") }
4041 .disabled(!updates.canCheck)
4142 }
4243}
44#endif
Sources/Orgstar/WelcomeView.swift +32 −3
@@ -1,5 +1,6 @@
11import OrgApp
22import OrgCore
3import OrgWorkspace
34import SwiftUI
45
56/// The first launch, with no folder added: add a folder or start one, and pick the keys.
@@ -13,11 +14,12 @@ struct WelcomeView: View {
1314 @State private var error: String?
1415 @Environment(\.dismiss) private var dismiss
1516
17 /// iCloud Drive's folder in the real home folder.
18 static let iCloudDriveFolder = URL(fileURLWithPath: OrgPaths.home).appendingPathComponent("Library/Mobile Documents/com~apple~CloudDocs")
19
1620 /// iCloud Drive's folder, when iCloud Drive is on for this user.
1721 static var iCloudDrive: URL? {
18 let url = FileManager.default.homeDirectoryForCurrentUser
19 .appendingPathComponent("Library/Mobile Documents/com~apple~CloudDocs")
20 return FileManager.default.fileExists(atPath: url.path) ? url : nil
22 FileManager.default.fileExists(atPath: iCloudDriveFolder.path) ? iCloudDriveFolder : nil
2123 }
2224
2325 var body: some View {
@@ -28,14 +30,32 @@ struct WelcomeView: View {
2830 ForEach(KeymapPreset.allCases, id: \.self) { Text($0.title).tag($0) }
2931 }
3032 Text(presetNote).font(.callout).foregroundStyle(.secondary)
33 #if APPSTORE
34 Text("orgstar keeps its settings in a folder of its own. To use the ones in ~/.config/orgstar, choose that folder in Settings ▸ General ▸ Choose Configuration Folder….")
35 .font(.callout).foregroundStyle(.secondary)
36 ForEach(workspace.unresolvedRoots, id: \.path) { root in
37 HStack {
38 Label(OrgPaths.abbreviatingWithTilde(root.path), systemImage: "exclamationmark.triangle")
39 .help("orgstar can't open this folder")
40 Spacer()
41 Button("Grant Access…") { GrantAccess.regrant(root, workspace: workspace) }
42 }
43 }
44 #endif
3145 if let error { Text(error).foregroundStyle(.red) }
3246 HStack {
3347 Button("Not Now") { dismiss() }
3448 Spacer()
49 #if APPSTORE
50 // The sandbox reaches iCloud Drive only through a folder chosen there.
51 Button("New Folder in iCloud Drive…") { chooseInICloudDrive() }
52 .help("Makes notes.org in a folder you choose or make in iCloud Drive and adds the folder")
53 #else
3554 if let drive = Self.iCloudDrive {
3655 Button("New Folder in iCloud Drive") { start(in: drive.appendingPathComponent("org")) }
3756 .help("Makes org/notes.org in iCloud Drive and adds the folder")
3857 }
58 #endif
3959 Button("Choose Folder…") {
4060 dismiss()
4161 chooseFolder()
@@ -55,6 +75,15 @@ struct WelcomeView: View {
5575 }
5676 }
5777
78 #if APPSTORE
79 /// An open panel in iCloud Drive; the folder chosen or made there becomes the notes folder.
80 private func chooseInICloudDrive() {
81 let message = String(localized: "Choose or make the folder for your notes in iCloud Drive.", comment: "Open panel on the welcome sheet")
82 guard let folder = GrantAccess.choose(at: Self.iCloudDriveFolder, message: message, prompt: String(localized: "Use Folder", comment: "Open panel button on the welcome sheet")) else { return }
83 start(in: folder)
84 }
85 #endif
86
5887 /// Makes `folder` with a notes file in it, adds it, and opens the file.
5988 private func start(in folder: URL) {
6089 Task {
Sources/OrgstarMobile/EditorScreen.swift +1 −1
@@ -337,7 +337,7 @@ struct EditorScreen: View {
337337 case "org.link.store":
338338 let context = editor.editContext()
339339 let denote = OrgPreferences.usesDenote() ? Links.storeDenote(in: context, path: path) : nil
340 message = StoredLink.add(denote ?? Links.store(in: context, path: Links.abbreviate(path, home: NSHomeDirectory())), to: &model.storedLinks)
340 message = StoredLink.add(denote ?? Links.store(in: context, path: Links.abbreviate(path, home: OrgPaths.home)), to: &model.storedLinks)
341341 case "org.id.store-link":
342342 if case .commit = editor.perform(CreateID()),
343343 let link = Links.storeID(in: editor.editContext(), fileName: (path as NSString).lastPathComponent) {
Sources/OrgstarMobile/MobileEditor+Display.swift +1 −1
@@ -93,7 +93,7 @@ extension MobileEditor {
9393 guard let url = URL(string: path) else { return nil }
9494 return RemoteImages.shared.data(for: url, mode: remote, loaded: loaded).flatMap(UIImage.init(data:))
9595 }
96 let expanded = (path as NSString).expandingTildeInPath
96 let expanded = OrgPaths.expandingTilde(path)
9797 let url: URL
9898 if expanded.hasPrefix("/") {
9999 url = URL(fileURLWithPath: expanded)
Sources/OrgstarMobile/MobileModel.swift +3 −15
@@ -66,11 +66,9 @@ final class MobileModel {
6666 @ObservationIgnored private var presenter: FolderPresenter?
6767 @ObservationIgnored private var sizeObserver: NSObjectProtocol?
6868
69 private static let bookmarkKey = "configFolderBookmark"
70
7169 private init() {
7270 // Development: `ORGSTAR_CONFIG_DIR` stands in for a chosen folder.
73 let folder = Self.resolveBookmark() ?? ProcessInfo.processInfo.environment["ORGSTAR_CONFIG_DIR"].map { URL(fileURLWithPath: $0) }
71 let folder = ConfigFolder.resolve() ?? ProcessInfo.processInfo.environment["ORGSTAR_CONFIG_DIR"].map { URL(fileURLWithPath: $0) }
7472 UserConfig.directoryOverride = folder
7573 let (problems, colors) = Self.readConfig(folder)
7674 let settings = OrgPreferences.orgSettings()
@@ -109,11 +107,10 @@ final class MobileModel {
109107 /// Chooses the configuration folder, or with nil stops using one; its settings apply now.
110108 func setConfigFolder(_ url: URL?) {
111109 if let url {
112 _ = url.startAccessingSecurityScopedResource()
113 if let bookmark = try? url.bookmarkData() { UserDefaults.standard.set(bookmark, forKey: Self.bookmarkKey) }
110 ConfigFolder.set(url)
114111 Self.createConfig(in: url)
115112 } else {
116 UserDefaults.standard.removeObject(forKey: Self.bookmarkKey)
113 ConfigFolder.clear()
117114 // What the folder set no longer applies.
118115 for setting in UserConfig.settings { UserDefaults.standard.removeObject(forKey: setting.defaultsKey) }
119116 }
@@ -217,15 +214,6 @@ final class MobileModel {
217214 self.presenter = presenter
218215 }
219216
220 private static func resolveBookmark() -> URL? {
221 guard let data = UserDefaults.standard.data(forKey: bookmarkKey) else { return nil }
222 var stale = false
223 guard let url = try? URL(resolvingBookmarkData: data, bookmarkDataIsStale: &stale) else { return nil }
224 _ = url.startAccessingSecurityScopedResource()
225 if stale, let fresh = try? url.bookmarkData() { UserDefaults.standard.set(fresh, forKey: bookmarkKey) }
226 return url
227 }
228
229217 /// Applies the folder's `config.toml` to the settings; returns its problems and the theme's
230218 /// colors.
231219 /// Writes `config.toml` with every setting at its default when the folder has none.
Sources/OrgstarMobile/ProStore.swift → Sources/OrgstarMobile/ProScreen.swift renamed +2 −110
@@ -4,112 +4,6 @@ import StoreKit
44import SwiftUI
55import UIKit
66
7/// orgstar+ from the App Store: a monthly or yearly subscription, or a lifetime purchase. It
8/// keeps `ProAccess.shared` current; installs from before Pro keep it without buying.
9@MainActor @Observable
10final class ProStore {
11 static let shared = ProStore()
12
13 static let monthly = "sh.krz.orgstar.pro.monthly"
14 static let yearly = "sh.krz.orgstar.pro.yearly"
15 static let lifetime = "sh.krz.orgstar.pro.lifetime"
16 static let productIDs = [monthly, yearly, lifetime]
17
18 private(set) var products: [Product] = []
19 private(set) var activeProductID: String?
20 private(set) var busy = false
21 var message: String?
22
23 @ObservationIgnored private var updates: Task<Void, Never>?
24
25 private init() {}
26
27 /// Starts listening for transactions and checks what's owned. Call once at launch.
28 func start() {
29 guard updates == nil else { return }
30 updates = Task.detached(priority: .background) {
31 for await result in Transaction.updates {
32 guard case .verified(let transaction) = result else { continue }
33 await transaction.finish()
34 await ProStore.shared.refresh()
35 }
36 }
37 Task { await refresh() }
38 }
39
40 func loadProducts() async {
41 guard products.isEmpty else { return }
42 do {
43 let fetched = try await Product.products(for: Self.productIDs)
44 products = Self.productIDs.compactMap { id in fetched.first { $0.id == id } }
45 } catch {
46 message = "The App Store can't be reached right now."
47 }
48 }
49
50 /// Sets Pro from the current entitlements, or from the original download predating Pro.
51 func refresh() async {
52 var active: String?
53 for await result in Transaction.currentEntitlements {
54 guard case .verified(let transaction) = result, Self.productIDs.contains(transaction.productID),
55 transaction.revocationDate == nil else { continue }
56 if active == nil || transaction.productID == Self.lifetime { active = transaction.productID }
57 }
58 activeProductID = active
59 if active != nil {
60 ProAccess.shared.set(.purchase)
61 } else if await Self.predatesPro() {
62 ProAccess.shared.set(.grandfathered)
63 } else if ProAccess.shared.grant != .grandfathered {
64 // A cached grandfathered grant survives the App Store being unreachable.
65 ProAccess.shared.set(nil)
66 }
67 }
68
69 /// Whether this Apple Account first downloaded orgstar before Pro. Only the production App
70 /// Store reports real original versions; sandbox and Xcode always say "1.0".
71 private static func predatesPro() async -> Bool {
72 guard case .verified(let app) = try? await AppTransaction.shared, app.environment == .production else { return false }
73 return Grandfathering.predatesPro(originalBuild: app.originalAppVersion)
74 }
75
76 func buy(_ product: Product) async {
77 busy = true
78 defer { busy = false }
79 message = nil
80 do {
81 switch try await product.purchase() {
82 case .success(.verified(let transaction)):
83 await transaction.finish()
84 await refresh()
85 case .success(.unverified):
86 message = "The App Store couldn't verify the purchase."
87 case .pending:
88 message = "The purchase is waiting for approval."
89 case .userCancelled:
90 break
91 @unknown default:
92 break
93 }
94 } catch {
95 message = "The purchase didn't go through. \(error.localizedDescription)"
96 }
97 }
98
99 func restore() async {
100 busy = true
101 defer { busy = false }
102 message = nil
103 do {
104 try await AppStore.sync()
105 await refresh()
106 if !ProAccess.shared.isUnlocked { message = "No orgstar+ purchase was found for this Apple Account." }
107 } catch {
108 message = "Restore didn't finish. \(error.localizedDescription)"
109 }
110 }
111}
112
1137/// orgstar+'s gold, for its banner in Settings and its screen.
1148extension ShapeStyle where Self == LinearGradient {
1159 static var plusGold: LinearGradient {
@@ -246,11 +140,9 @@ struct ProScreen: View {
246140 /// How much the yearly plan saves against twelve months, in whole percent.
247141 private func savings(_ product: Product) -> Int? {
248142 guard product.id == ProStore.yearly,
249 let monthly = store.products.first(where: { $0.id == ProStore.monthly }), monthly.price > 0
143 let monthly = store.products.first(where: { $0.id == ProStore.monthly })
250144 else { return nil }
251 let ratio = NSDecimalNumber(decimal: product.price / (monthly.price * 12)).doubleValue
252 let percent = Int((1 - ratio) * 100)
253 return percent > 0 ? percent : nil
145 return ProStore.yearlySavings(yearly: product.price, monthly: monthly.price)
254146 }
255147
256148 private var status: LocalizedStringKey {
Sources/OrgstarMobile/TipSection.swift added +49
@@ -0,0 +1,49 @@
1#if os(iOS)
2import OrgApp
3import StoreKit
4import SwiftUI
5
6/// Tips in About, for everyone, with or without orgstar+.
7struct TipSection: View {
8 @State private var store = TipStore()
9
10 var body: some View {
11 Section {
12 if store.isLoading && store.products.isEmpty {
13 ProgressView().frame(maxWidth: .infinity)
14 }
15 ForEach(store.products) { product in
16 Button { Task { await store.purchase(product) } } label: {
17 HStack {
18 Text(product.displayName)
19 Spacer()
20 if store.purchasingProductID == product.id {
21 ProgressView().controlSize(.small)
22 } else {
23 Text(product.displayPrice).monospacedDigit().foregroundStyle(.secondary)
24 }
25 }
26 }
27 .tint(.primary)
28 .disabled(store.purchasingProductID != nil)
29 }
30 if let message = store.message {
31 Text(message).foregroundStyle(.secondary)
32 if store.products.count < Tip.productIDs.count {
33 Button("Try Again") { Task { await store.loadProducts() } }.disabled(store.isLoading)
34 }
35 }
36 } header: {
37 Text("Support Development")
38 } footer: {
39 Text("Tips are one-time purchases that help pay for orgstar's development. They don't unlock anything.")
40 }
41 .task { await store.loadProducts() }
42 .alert("Thank You", isPresented: $store.thanked) {
43 Button("OK") {}
44 } message: {
45 Text("Your tip helps keep orgstar going.")
46 }
47 }
48}
49#endif
Sources/OrgstarMobile/TipStore.swift deleted −102
@@ -1,102 +0,0 @@
1#if os(iOS)
2import OrgApp
3import StoreKit
4import SwiftUI
5
6/// Tips from the App Store. `ProStore`'s transaction listener finishes any that arrive later.
7@MainActor @Observable
8final class TipStore {
9 private(set) var products: [Product] = []
10 private(set) var isLoading = false
11 private(set) var purchasingProductID: String?
12 /// A failure, or a tip waiting for approval, shown in the section.
13 private(set) var message: String?
14 /// Set after a tip goes through; the thank-you alert clears it.
15 var thanked = false
16
17 func loadProducts() async {
18 guard !isLoading else { return }
19 isLoading = true
20 message = nil
21 defer { isLoading = false }
22 do {
23 let fetched = try await Product.products(for: Tip.productIDs)
24 products = Tip.productIDs.compactMap { id in fetched.first { $0.id == id } }
25 if products.count < Tip.productIDs.count {
26 message = String(localized: "Some tips aren't available from the App Store right now.")
27 }
28 } catch {
29 products = []
30 message = String(localized: "The App Store can't be reached right now.")
31 }
32 }
33
34 func purchase(_ product: Product) async {
35 guard purchasingProductID == nil else { return }
36 purchasingProductID = product.id
37 message = nil
38 defer { purchasingProductID = nil }
39 do {
40 switch try await product.purchase() {
41 case .success(.verified(let transaction)):
42 await transaction.finish()
43 thanked = true
44 case .success(.unverified):
45 message = String(localized: "The App Store couldn't verify the purchase.")
46 case .pending:
47 message = String(localized: "The tip is waiting for approval.")
48 case .userCancelled:
49 break
50 @unknown default:
51 break
52 }
53 } catch {
54 message = String(localized: "The purchase didn't go through. \(error.localizedDescription)")
55 }
56 }
57}
58
59/// Tips in About, for everyone, with or without orgstar+.
60struct TipSection: View {
61 @State private var store = TipStore()
62
63 var body: some View {
64 Section {
65 if store.isLoading && store.products.isEmpty {
66 ProgressView().frame(maxWidth: .infinity)
67 }
68 ForEach(store.products) { product in
69 Button { Task { await store.purchase(product) } } label: {
70 HStack {
71 Text(product.displayName)
72 Spacer()
73 if store.purchasingProductID == product.id {
74 ProgressView().controlSize(.small)
75 } else {
76 Text(product.displayPrice).monospacedDigit().foregroundStyle(.secondary)
77 }
78 }
79 }
80 .tint(.primary)
81 .disabled(store.purchasingProductID != nil)
82 }
83 if let message = store.message {
84 Text(message).foregroundStyle(.secondary)
85 if store.products.count < Tip.productIDs.count {
86 Button("Try Again") { Task { await store.loadProducts() } }.disabled(store.isLoading)
87 }
88 }
89 } header: {
90 Text("Support Development")
91 } footer: {
92 Text("Tips are one-time purchases that help pay for orgstar's development. They don't unlock anything.")
93 }
94 .task { await store.loadProducts() }
95 .alert("Thank You", isPresented: $store.thanked) {
96 Button("OK") {}
97 } message: {
98 Text("Your tip helps keep orgstar going.")
99 }
100 }
101}
102#endif
Sources/OrgstarWidgets/AgendaTimeline.swift +3 −3
@@ -2,10 +2,10 @@ import OrgApp
22import SwiftUI
33import WidgetKit
44
5/// Whether the app lacks Pro, which the widgets need. Only iOS shares the flag with the widgets;
6/// the Mac app stops writing their data instead.
5/// Whether the app lacks Pro, which the widgets need. iOS and the App Store Mac app share the flag
6/// with the widgets; the Developer ID Mac app stops writing their data instead.
77var widgetsLocked: Bool {
8 #if os(iOS)
8 #if os(iOS) || APPSTORE
99 !ProAccess.isUnlockedNow
1010 #else
1111 false
Sources/OrgstarWidgets/OrgstarWidgets.swift +7
@@ -8,6 +8,13 @@ import WidgetKit
88/// the desktop and in Notification Center.
99@main
1010struct OrgstarWidgets: WidgetBundle {
11 #if APPSTORE
12 /// The App Store app writes the widgets' data to the app group's container.
13 init() {
14 AgendaSnapshot.useGroupContainer = true
15 }
16 #endif
17
1118 var body: some Widget {
1219 TodayWidget()
1320 HabitsWidget()
Tests/OrgAppTests/AppTests.swift +45 −145
@@ -95,6 +95,37 @@ struct WorkspaceModelTests {
9595 #expect(reopened.roots.count == 1)
9696 }
9797
98 @Test func aFolderThatDoesntResolveCanBeChosenAgain() async throws {
99 let parent = try Folder()
100 let gone = parent.url.appendingPathComponent("gone")
101 try FileManager.default.createDirectory(at: gone, withIntermediateDirectories: true)
102 let data = parent.url.appendingPathComponent("data")
103 let model = try WorkspaceModel(directory: data)
104 try await model.addRoot(gone)
105 #expect(model.unresolvedRoots.isEmpty)
106 try FileManager.default.removeItem(at: gone)
107
108 let reopened = try WorkspaceModel(directory: data)
109 let root = try #require(reopened.unresolvedRoots.first)
110 #expect(reopened.rootPaths.isEmpty && root.path == gone.path)
111 let found = try parent.write("found/a.org", "* Plumber\n").deletingLastPathComponent()
112 try await reopened.regrant(root, with: found)
113 #expect(reopened.unresolvedRoots.isEmpty)
114 #expect(reopened.roots.map(\.path) == [found.path])
115 #expect(reopened.search("plumber").count == 1)
116 #expect(try WorkspaceModel(directory: data).roots.map(\.path) == [found.path])
117
118 // Chosen again as a folder already in the sidebar, the old one just goes.
119 let other = parent.url.appendingPathComponent("other")
120 try FileManager.default.createDirectory(at: other, withIntermediateDirectories: true)
121 try await reopened.addRoot(other)
122 try FileManager.default.removeItem(at: other)
123 let third = try WorkspaceModel(directory: data)
124 let stale = try #require(third.unresolvedRoots.first)
125 try await third.regrant(stale, with: found)
126 #expect(third.roots.map(\.path) == [found.path] && third.unresolvedRoots.isEmpty)
127 }
128
98129 @Test func listsDownloadsInTheTree() {
99130 let files = [FileEntry(path: "/r/a.org", root: "/r", kind: .org)]
100131 let tree = FileTreeNode.build(root: "/r", files: files, downloading: ["/r/b.org", "/r/sub/c.org"])
@@ -949,157 +980,26 @@ struct ReminderSchedulerTests {
949980 }
950981}
951982
983/// Without `DocumentSession.programs`, only Emacs Lisp runs, natively.
952984@MainActor
953struct EmacsFallbackTests {
954 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
955 func recalculatesTablesNativeCodeCannot() async throws {
956 let notes = try Folder()
957 let file = try notes.write("t.org", "* Prices\n| item | n | twice |\n|------+---+-------|\n| x | a | |\n| y | 2 | |\n#+TBLFM: $3=$2*2\n")
958 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
959 session.open(file.path)
960 let step = session.perform(TableRecalculate(all: true), path: file.path, at: 50, expect: nil)
961 guard case .external(.emacsTable(let table, let point, let form, let reason, let lisp)) = step else {
962 Issue.record("\(step)")
963 return
964 }
965 #expect(reason == "non-numeric field a")
966 #expect(!lisp)
967 let message = await session.recalculateInEmacs(table: table, point: point, form: form)
968 #expect(message == "Recalculated in Emacs")
969 #expect(session.document?.text == "* Prices\n| item | n | twice |\n|------+---+-------|\n| x | a | 2 a |\n| y | 2 | 4 |\n#+TBLFM: $3=$2*2\n")
970 }
971
972 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
973 func cancelingARecalculationLeavesTheTable() async throws {
974 let notes = try Folder()
975 let text = "| n | twice |\n|---+-------|\n| a | |\n#+TBLFM: $2=$1*2\n"
976 let file = try notes.write("t.org", text)
977 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
978 session.open(file.path)
979 let step = session.perform(TableRecalculate(all: true), path: file.path, at: 2, expect: nil)
980 guard case .external(.emacsTable(let table, let point, let form, _, _)) = step else {
981 Issue.record("\(step)")
982 return
983 }
984 let task = Task { await session.recalculateInEmacs(table: table, point: point, form: form) }
985 task.cancel()
986 #expect(await task.value == "Recalculation canceled")
987 #expect(session.document?.text == text)
988 }
989}
990
991@MainActor
992struct BabelSessionTests {
993 @Test func runsBlocksAndWritesResults() async throws {
985struct NativeProgramsTests {
986 @Test func runsOnlyNativeBlocksWithoutARunner() async throws {
987 #expect(DocumentSession.runner == nil)
994988 let notes = try Folder()
995 let file = try notes.write("b.org", "#+begin_src sh\necho answer\necho \"$((6 * 7))\"\n#+end_src\n")
989 let file = try notes.write("b.org", "#+begin_src sh\necho hi\n#+end_src\n\n#+begin_src emacs-lisp\n(+ 1 2)\n#+end_src\n")
996990 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
997991 session.open(file.path)
998 let step = session.perform(ExecuteSrcBlock(), path: file.path, at: 3, expect: nil)
999 guard case .external(.babel(let job)) = step else {
1000 Issue.record("\(step)")
992 guard case .external(.babel(let sh)) = session.perform(ExecuteSrcBlock(), path: file.path, at: 3, expect: nil),
993 case .external(.babel(let lisp)) = session.perform(ExecuteSrcBlock(), path: file.path, at: 40, expect: nil) else {
994 Issue.record("not planned")
1001995 return
1002996 }
1003 #expect(await session.runBabel(job) == "Code block evaluation complete.")
1004 // A column that is half numbers is right-aligned, as org-table-align does.
1005 #expect(session.document?.text == "#+begin_src sh\necho answer\necho \"$((6 * 7))\"\n#+end_src\n\n#+RESULTS:\n| answer |\n| 42 |\n")
1006 }
1007}
1008
1009@MainActor
1010struct BabelErrorTests {
1011 func job(_ session: DocumentSession, _ path: String) throws -> BabelJob {
1012 guard case .external(.babel(let job)) = session.perform(ExecuteSrcBlock(), path: path, at: 3, expect: nil) else {
1013 throw CancellationError()
1014 }
1015 return job
1016 }
1017
1018 /// Like `org-babel-eval`: the results go in, and the error output and status are shown.
1019 @Test func reportsErrorsAndStillInsertsResults() async throws {
1020 let notes = try Folder()
1021 let file = try notes.write("e.org", "#+begin_src sh\necho out\necho oops >&2\nexit 3\n#+end_src\n")
1022 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
1023 session.open(file.path)
1024 #expect(await session.runBabel(try job(session, file.path)) == "Exited with status 3: oops")
1025 #expect(session.document?.text.hasSuffix("#+RESULTS:\n: out\n") == true)
1026 }
1027
1028 @Test func cancelsARunningBlock() async throws {
1029 let notes = try Folder()
1030 let file = try notes.write("s.org", "#+begin_src sh\nsleep 20\necho late\n#+end_src\n")
1031 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
1032 session.open(file.path)
1033 let start = ContinuousClock.now
1034 var message: String?
1035 session.startBabel(try job(session, file.path)) { message = $0 }
1036 #expect(session.isRunningBabel)
1037 try await Task.sleep(for: .milliseconds(200))
1038 session.cancelBabel()
1039 while message == nil, ContinuousClock.now - start < .seconds(5) { try await Task.sleep(for: .milliseconds(20)) }
1040 #expect(message == "Code block canceled.")
1041 #expect(!session.isRunningBabel)
1042 #expect(ContinuousClock.now - start < .seconds(5))
1043 #expect(session.document?.text.contains("#+RESULTS:") == false)
1044 }
1045}
1046
1047struct EmacsExportTests {
1048 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
1049 func exportsBesideTheFile() async throws {
1050 let notes = try Folder()
1051 let file = try notes.write("doc.org", "#+TITLE: On disk\n")
1052 // The buffer's text is exported, not the file's.
1053 let written = try await EmacsRunner.export(text: "#+TITLE: In the buffer\n\n* Heading\nBody.\n", path: file.path, function: "org-ascii-export-to-ascii")
1054 #expect(URL(fileURLWithPath: written).lastPathComponent == "doc.txt")
1055 let text = try String(contentsOfFile: written, encoding: .utf8)
1056 #expect(text.uppercased().contains("IN THE BUFFER") && text.contains("Body."), "\(text)")
1057 #expect(try String(contentsOf: file, encoding: .utf8) == "#+TITLE: On disk\n")
1058 }
1059
1060 /// The dispatcher's `C-s` and `C-b`: the subtree at point alone, its EXPORT_FILE_NAME used.
1061 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
1062 func exportsTheSubtreeBodyOnly() async throws {
1063 let notes = try Folder()
1064 let file = try notes.write("doc.org", "")
1065 let text = "#+TITLE: Doc\n* Ünï\nFirst.\n* Second\n:PROPERTIES:\n:EXPORT_FILE_NAME: second\n:END:\nOnly this.\n"
1066 let point = (text as NSString).substring(to: (text as NSString).range(of: "Only").location).unicodeScalars.count + 1
1067 let written = try await EmacsRunner.export(text: text, path: file.path, function: "org-ascii-export-to-ascii", subtree: point, bodyOnly: true)
1068 #expect(URL(fileURLWithPath: written).lastPathComponent == "second.txt")
1069 let out = try String(contentsOfFile: written, encoding: .utf8)
1070 #expect(out.contains("Only this.") && !out.contains("First.") && !out.uppercased().contains("DOC"), "\(out)")
1071 }
1072
1073 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
1074 func exportUsesBabelPath() async throws {
1075 let notes = try Folder()
1076 let file = try notes.write("doc.org", "")
1077 let function = #"(lambda () (with-temp-file "path.txt" (insert (getenv "PATH"))) "path.txt")"#
1078 let written = try await EmacsRunner.export(text: "", path: file.path, function: function)
1079 #expect(try String(contentsOfFile: written, encoding: .utf8) == BabelRunner.environment["PATH"])
1080 }
1081
1082 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
1083 func cancellingStopsTheExport() async throws {
1084 let notes = try Folder()
1085 let file = try notes.write("doc.org", "")
1086 let pidFile = notes.url.appendingPathComponent("pid")
1087 let function = #"(lambda () (with-temp-file "pid" (insert (number-to-string (emacs-pid)))) (sleep-for 60) "x")"#
1088 let export = Task { try await EmacsRunner.export(text: "", path: file.path, function: function) }
1089 var pid: pid_t?
1090 for _ in 0..<200 where pid == nil {
1091 try await Task.sleep(for: .milliseconds(50))
1092 pid = (try? String(contentsOf: pidFile, encoding: .utf8)).flatMap { pid_t($0) }
1093 }
1094 let started = try #require(pid)
1095 export.cancel()
1096 await #expect(throws: CancellationError.self) { try await export.value }
1097 var alive = true
1098 for _ in 0..<100 where alive {
1099 alive = kill(started, 0) == 0
1100 if alive { try await Task.sleep(for: .milliseconds(50)) }
1101 }
1102 #expect(!alive)
997 #if os(macOS)
998 #expect(await session.runBabel(sh) == "sh blocks don't run in this version of orgstar.")
999 #expect(await session.recalculateInEmacs(table: 0..<1, point: 0, form: "") == "Tables that need Emacs aren't recalculated in this version of orgstar.")
1000 #endif
1001 #expect(await session.runBabel(lisp) == "Code block evaluation complete.")
1002 #expect(session.document?.text.hasSuffix("#+RESULTS:\n: 3\n") == true)
11031003 }
11041004}
11051005
Tests/OrgAppTests/ConfigFolderTests.swift added +99
@@ -0,0 +1,99 @@
1import Foundation
2import OrgCore
3import Testing
4@testable import OrgApp
5
6@MainActor
7struct ConfigFolderTests {
8 func defaults() -> UserDefaults {
9 let name = "orgstar-config-folder-\(UUID().uuidString)"
10 let defaults = UserDefaults(suiteName: name)!
11 defaults.removePersistentDomain(forName: name)
12 return defaults
13 }
14
15 func folder() throws -> URL {
16 let url = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-config-folder-\(UUID().uuidString)")
17 try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
18 return url
19 }
20
21 @Test func chosenFolderResolves() throws {
22 let store = defaults()
23 let url = try folder()
24 defer { try? FileManager.default.removeItem(at: url) }
25 #expect(ConfigFolder.resolve(defaults: store) == nil)
26 ConfigFolder.set(url, defaults: store)
27 #expect(store.data(forKey: ConfigFolder.bookmarkKey) != nil)
28 let resolved = try #require(ConfigFolder.resolve(defaults: store))
29 #expect(resolved.resolvingSymlinksInPath().path == url.resolvingSymlinksInPath().path)
30 ConfigFolder.clear(defaults: store)
31 #expect(ConfigFolder.resolve(defaults: store) == nil)
32 }
33
34 @Test func aFolderWithoutABookmarkIsNotKept() {
35 let store = defaults()
36 #expect(!ConfigFolder.set(URL(fileURLWithPath: "/nowhere-\(UUID().uuidString)"), defaults: store))
37 #expect(store.data(forKey: ConfigFolder.bookmarkKey) == nil)
38 }
39
40 /// iOS keeps its folder under the key it always used.
41 @Test func bookmarkKeyIsUnchanged() {
42 #expect(ConfigFolder.bookmarkKey == "configFolderBookmark")
43 }
44
45 @Test func suggestedIsInTheRealHome() {
46 #expect(ConfigFolder.suggested.path == OrgPaths.home + "/.config/orgstar")
47 }
48
49 @Test func movingAppliesTheNewFolder() throws {
50 let first = try folder()
51 let second = try folder()
52 defer {
53 try? FileManager.default.removeItem(at: first)
54 try? FileManager.default.removeItem(at: second)
55 }
56 try "fill-column = 64\n".write(to: first.appendingPathComponent("config.toml"), atomically: true, encoding: .utf8)
57 try "fill-column = 72\n".write(to: second.appendingPathComponent("config.toml"), atomically: true, encoding: .utf8)
58 let store = defaults()
59 let sync = ConfigSync(url: first.appendingPathComponent("config.toml"), defaults: store)
60 sync.start(watch: false)
61 #expect(store.integer(forKey: "fillColumn") == 64)
62 sync.move(to: second.appendingPathComponent("config.toml"))
63 #expect(store.integer(forKey: "fillColumn") == 72)
64 #expect(sync.changedFile?.name == "keymap.toml")
65 // Changes made in the app go into the new file only.
66 store.set(80, forKey: "fillColumn")
67 sync.writeBack()
68 #expect(try String(contentsOf: second.appendingPathComponent("config.toml"), encoding: .utf8).contains("fill-column = 80"))
69 let old = try String(contentsOf: first.appendingPathComponent("config.toml"), encoding: .utf8)
70 #expect(old.contains("fill-column = 64") && !old.contains("fill-column = 80"))
71 }
72
73 @Test func movingToAnEmptyFolderWritesTheCurrentSettings() throws {
74 let first = try folder()
75 let second = try folder()
76 defer {
77 try? FileManager.default.removeItem(at: first)
78 try? FileManager.default.removeItem(at: second)
79 }
80 try "fill-column = 64\n".write(to: first.appendingPathComponent("config.toml"), atomically: true, encoding: .utf8)
81 let store = defaults()
82 let sync = ConfigSync(url: first.appendingPathComponent("config.toml"), defaults: store)
83 sync.start(watch: false)
84 sync.move(to: second.appendingPathComponent("config.toml"))
85 #expect(try String(contentsOf: second.appendingPathComponent("config.toml"), encoding: .utf8).contains("fill-column = 64"))
86 }
87
88 @Test func movingBeforeStartDoesNothing() throws {
89 let first = try folder()
90 let second = try folder()
91 defer {
92 try? FileManager.default.removeItem(at: first)
93 try? FileManager.default.removeItem(at: second)
94 }
95 let sync = ConfigSync(url: first.appendingPathComponent("config.toml"), defaults: defaults())
96 sync.move(to: second.appendingPathComponent("config.toml"))
97 #expect(!FileManager.default.fileExists(atPath: second.appendingPathComponent("config.toml").path))
98 }
99}
Tests/OrgAppTests/EmacsImportFoldersTests.swift added +68
@@ -0,0 +1,68 @@
1import Foundation
2import OrgCore
3import Testing
4@testable import OrgApp
5
6@MainActor
7struct EmacsImportFoldersTests {
8 func items(_ paths: [String]) -> [EmacsImport.Item] {
9 paths.enumerated().map { EmacsImport.Item(id: $0.offset, name: "org-directory", summary: $0.element, source: "config.el:1", change: .folder($0.element)) }
10 }
11
12 func defaults() -> UserDefaults {
13 let name = "orgstar-import-folders-\(UUID().uuidString)"
14 let defaults = UserDefaults(suiteName: name)!
15 defaults.removePersistentDomain(forName: name)
16 return defaults
17 }
18
19 @Test func addsOnlyTheFoldersChosen() async throws {
20 let notes = try Folder()
21 let picked = try Folder()
22 let config = try Folder()
23 let model = try WorkspaceModel(directory: nil)
24 try await model.addRoot(notes.url)
25 let first = "~/nowhere-\(UUID().uuidString)", second = "~/also-nowhere-\(UUID().uuidString)"
26 let all = items([notes.url.path, first, second])
27 // The folder already in the sidebar isn't asked for.
28 #expect(EmacsImport.foldersToAdd(all, workspace: model) == [first, second])
29 let summary = await EmacsImport.apply(all, defaults: defaults(), workspace: model, directory: config.url, chosenFolders: [first: picked.url])
30 #expect(Set(model.roots.map(\.path)) == [notes.url.path, picked.url.path])
31 #expect(summary.contains("wasn't added"), "\(summary)")
32 #expect(!summary.contains(first), "\(summary)")
33 }
34
35 @Test func withoutChosenFoldersAddsWhatsWritten() async throws {
36 let notes = try Folder()
37 let config = try Folder()
38 let model = try WorkspaceModel(directory: nil)
39 let summary = await EmacsImport.apply(items([notes.url.path, "/nowhere-\(UUID().uuidString)"]), defaults: defaults(), workspace: model, directory: config.url)
40 #expect(model.roots.map(\.path) == [notes.url.path])
41 #expect(summary.contains("doesn't exist"), "\(summary)")
42 }
43
44 @Test func readsDoomDefaultsFromAChosenInstall() throws {
45 let install = try Folder()
46 let user = try Folder()
47 try user.write("init.el", "(doom! :lang (org +pretty))")
48 try user.write("config.el", "(setq org-directory \"~/notes/\")")
49 #expect(EmacsImport.doomDefaultFiles(in: install.url).isEmpty)
50 try install.write("lisp/doom.el", ";; doom")
51 try install.write("lisp/doom-emacs.el", "(setq fill-column 80)")
52 try install.write("modules/lang/org/config.el", "(after! org (setq org-log-done 'time))")
53 let files = EmacsImport.doomDefaultFiles(in: install.url)
54 #expect(files.map(\.lastPathComponent) == ["config.el", "doom-emacs.el"])
55
56 let without = EmacsImport.scan(EmacsImport.files(in: user.url), doomDefaults: [])
57 #expect(without.isDoom && !without.doomDefaultsRead)
58 let with = EmacsImport.scan(EmacsImport.files(in: user.url), doomDefaults: files)
59 #expect(with.isDoom && with.doomDefaultsRead)
60 #expect(with.items.contains { if case .setting(let key, _) = $0.change { key == "org-log-done" } else { false } })
61 }
62
63 @Test func doomInstallsStartWithTheHomeFolders() {
64 let home = URL(fileURLWithPath: OrgPaths.home)
65 #expect(EmacsImport.doomInstallLocations().suffix(2) == [".config/emacs", ".emacs.d"].map { home.appendingPathComponent($0) })
66 #expect(EmacsImport.pickerLocation() == EmacsImport.defaultLocations().first ?? home)
67 }
68}
Tests/OrgAppTests/FolderGrantsTests.swift added +81
@@ -0,0 +1,81 @@
1import Foundation
2import Testing
3@testable import OrgApp
4
5@MainActor
6struct FolderGrantsTests {
7 func defaults() -> UserDefaults {
8 let name = "orgstar-folder-grants-\(UUID().uuidString)"
9 let defaults = UserDefaults(suiteName: name)!
10 defaults.removePersistentDomain(forName: name)
11 return defaults
12 }
13
14 @Test func grantsComeBackAtLaunch() throws {
15 let store = defaults()
16 let folder = try Folder()
17 let grants = FolderGrants(defaults: store, sandboxed: false)
18 #expect(grants.folders.isEmpty)
19 grants.add(folder.url)
20 grants.add(folder.url)
21 #expect(grants.folders == [folder.url])
22 #expect((store.array(forKey: FolderGrants.key) as? [Data])?.count == 1)
23 let relaunched = FolderGrants(defaults: store, sandboxed: false)
24 #expect(relaunched.folders.map { $0.resolvingSymlinksInPath().path } == [folder.url.resolvingSymlinksInPath().path])
25 }
26
27 @Test func aGrantWithoutABookmarkLastsForTheSession() {
28 let store = defaults()
29 let grants = FolderGrants(defaults: store, sandboxed: false)
30 let missing = URL(fileURLWithPath: "/nowhere-\(UUID().uuidString)")
31 #expect(!grants.add(missing))
32 #expect(grants.folders == [missing])
33 #expect(store.array(forKey: FolderGrants.key) == nil)
34 }
35
36 @Test func coverage() {
37 #expect(FolderGrants.covers(URL(fileURLWithPath: "/a"), URL(fileURLWithPath: "/a/b")))
38 #expect(FolderGrants.covers(URL(fileURLWithPath: "/a/b"), URL(fileURLWithPath: "/a/b")))
39 #expect(FolderGrants.covers(URL(fileURLWithPath: "/"), URL(fileURLWithPath: "/a")))
40 #expect(!FolderGrants.covers(URL(fileURLWithPath: "/a/b"), URL(fileURLWithPath: "/a")))
41 #expect(!FolderGrants.covers(URL(fileURLWithPath: "/a/b"), URL(fileURLWithPath: "/a/bc")))
42 }
43
44 @Test func bookmarksThatDontResolveAreKept() {
45 let store = defaults()
46 store.set([Data("not a bookmark".utf8)], forKey: FolderGrants.key)
47 #expect(FolderGrants(defaults: store, sandboxed: false).folders.isEmpty)
48 #expect((store.array(forKey: FolderGrants.key) as? [Data])?.count == 1)
49 }
50
51 @Test func fileBookmarkRoundTrip() throws {
52 let folder = try Folder()
53 let file = try folder.write("a.org", "* a\n")
54 let data = try #require(SecurityBookmark.make(file, sandboxed: false))
55 let resolved = try #require(SecurityBookmark.resolve(data, sandboxed: false))
56 #expect(resolved.url.resolvingSymlinksInPath().path == file.resolvingSymlinksInPath().path)
57 }
58
59 @Test func foldersToGrantSkipReachablePaths() {
60 let reachable = [URL(fileURLWithPath: "/notes"), URL(fileURLWithPath: "/container")]
61 let existing: Set<String> = ["/", "/notes", "/container", "/other", "/other/site"]
62 let folders = WorkspaceModel.foldersToGrant(
63 for: ["/notes/a.org", "/container/x", "/other/setup.org", "/other/inc.org", "", "/other/site/new/out.html"],
64 directories: false, reachable: reachable, exists: existing.contains)
65 #expect(folders.map(\.path) == ["/other", "/other/site"])
66 }
67
68 @Test func onlyFilesThatAreThereAreAskedFor() throws {
69 let folder = try Folder()
70 let file = try folder.write("setup.org", "#+TODO: A\n")
71 #expect(WorkspaceModel.isThere(file.path))
72 #expect(!WorkspaceModel.isThere(folder.url.appendingPathComponent("missing.org").path))
73 }
74
75 @Test func foldersToGrantForFolders() {
76 let folders = WorkspaceModel.foldersToGrant(
77 for: ["/out/public", "/out/missing/deep"], directories: true, reachable: [],
78 exists: ["/", "/out", "/out/public"].contains)
79 #expect(folders.map(\.path) == ["/out/public", "/out"])
80 }
81}
Tests/OrgAppTests/PDFExportTests.swift +23
@@ -31,4 +31,27 @@ struct PDFExportTests {
3131 #expect(css.contains("font-family: \"Georgia\""))
3232 #expect(!PDFExport.css(PDFExport.Options()).contains("font-family"))
3333 }
34
35 /// In the sandbox WebKit can't read the user's folders, so local images go in the page.
36 @Test func inlinesLocalImages() throws {
37 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-\(UUID().uuidString)")
38 try FileManager.default.createDirectory(at: folder.appendingPathComponent("img"), withIntermediateDirectories: true)
39 defer { try? FileManager.default.removeItem(at: folder) }
40 try Data([1, 2, 3]).write(to: folder.appendingPathComponent("img/a b.png"))
41 try Data([4]).write(to: folder.appendingPathComponent("c.svg"))
42 let absolute = folder.appendingPathComponent("c.svg").path
43 let html = #"<p><img src="img/a b.png" alt="a"> <img alt="c" src="\#(absolute)"> <img src="https://x.org/r.png"> <img src="gone.png"></p>"#
44 let inlined = PDFExport.inliningImages(html, directory: folder)
45 #expect(inlined.contains(#"<img src="data:image/png;base64,AQID" alt="a">"#))
46 #expect(inlined.contains(#"<img alt="c" src="data:image/svg+xml;base64,BA==">"#))
47 #expect(inlined.contains(#"<img src="https://x.org/r.png">"#))
48 #expect(inlined.contains(#"<img src="gone.png">"#))
49 #expect(PDFExport.inliningImages(#"<img src="img/a b.png">"#, directory: nil) == #"<img src="img/a b.png">"#)
50 }
51
52 /// The images to ask for access to before exporting.
53 @Test func localImageFiles() {
54 let html = #"<img src="img/a.png"> <img alt="c" src="/abs/c.svg"> <img src="https://x.org/r.png"> <img src="img/a.png">"#
55 #expect(PDFExport.imageFiles(html, directory: URL(fileURLWithPath: "/notes")) == ["/notes/img/a.png", "/abs/c.svg"])
56 }
3457}
Tests/OrgAppTests/ProgramRunningTests.swift added +39
@@ -0,0 +1,39 @@
1import Foundation
2import OrgCore
3import OrgDocument
4import Testing
5@testable import OrgApp
6
7/// Answers every block with a fixed output and every table with fixed text.
8private struct StubPrograms: ProgramRunning {
9 func runBabel(_ job: BabelJob, fileDirectory: URL) async throws -> BabelOutput {
10 BabelOutput(stdout: "stub")
11 }
12
13 func recalculateTable(text: String, directory: URL, table: Range<Int>, point: Int, form: String) async throws -> String {
14 "| 1 |\n"
15 }
16}
17
18/// The app creates its session before it sets `DocumentSession.programs`, so the runner is
19/// read when a block or table runs, not when the session is made.
20@MainActor
21struct ProgramRunningTests {
22 @Test func aRunnerSetAfterTheSessionOpensIsUsed() async throws {
23 #expect(DocumentSession.runner == nil)
24 let notes = try Folder()
25 let file = try notes.write("b.org", "#+begin_src sh\necho hi\n#+end_src\n\n| 2 |\n")
26 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
27 session.open(file.path)
28 guard case .external(.babel(let job)) = session.perform(ExecuteSrcBlock(), path: file.path, at: 3, expect: nil) else {
29 Issue.record("not planned")
30 return
31 }
32 let table = ("#+begin_src sh\necho hi\n#+end_src\n\n" as NSString).length
33 await DocumentSession.$scopedPrograms.withValue(StubPrograms()) {
34 #expect(await session.recalculateInEmacs(table: table..<(table + 6), point: table, form: "") == "Recalculated in Emacs")
35 #expect(await session.runBabel(job) == "Code block evaluation complete.")
36 }
37 #expect(session.document?.text == "#+begin_src sh\necho hi\n#+end_src\n\n#+RESULTS:\n: stub\n\n| 1 |\n")
38 }
39}
Tests/OrgAppTests/TangleWriterTests.swift +20 −1
@@ -1,7 +1,7 @@
11import Foundation
2import OrgCore
32import Testing
43@testable import OrgApp
4@testable import OrgCore
55
66struct TangleWriterTests {
77 @Test func writesMakesFoldersAndSetsModes() throws {
@@ -42,4 +42,23 @@ struct TangleWriterTests {
4242 try TangleWriter.write(own, source: source.path)
4343 }
4444 }
45
46 @Test func aModeThatCantBeSetIsReportedAfterWriting() throws {
47 let folder = try Folder()
48 let script = folder.url.appendingPathComponent("run.sh").path
49 // Anyone can write /dev/null, but only its owner can change its mode.
50 let output = Tangle.Output(files: [
51 Tangle.File(path: "/dev/null", contents: "x\n", mode: 0o755, makeDirectories: false),
52 Tangle.File(path: script, contents: "#!/bin/sh\n", mode: 0o755, makeDirectories: false),
53 ], blocks: 2)
54 let source = folder.url.appendingPathComponent("notes.org").path
55 do {
56 try TangleWriter.write(output, source: source)
57 Issue.record("The mode of /dev/null was set")
58 } catch {
59 #expect(error.message.hasPrefix("Tangled 2 code blocks from notes.org, but can't set the mode of /dev/null"))
60 }
61 #expect(try String(contentsOfFile: script, encoding: .utf8) == "#!/bin/sh\n")
62 #expect(try FileManager.default.attributesOfItem(atPath: script)[.posixPermissions] as? Int == 0o755)
63 }
4564}
Tests/OrgAppTests/TipTests.swift +30
@@ -1,3 +1,4 @@
1import Foundation
12import Testing
23@testable import OrgApp
34
@@ -15,3 +16,32 @@ struct TipTests {
1516 #expect(Tip.productIDs.allSatisfy { !$0.hasPrefix("sh.krz.orgstar.pro.") })
1617 }
1718}
19
20#if canImport(StoreKit)
21@MainActor
22struct ProStoreTests {
23 @Test func productIDsAreOrgstarPlusAndNotTips() {
24 #expect(ProStore.productIDs == [
25 "sh.krz.orgstar.pro.monthly",
26 "sh.krz.orgstar.pro.yearly",
27 "sh.krz.orgstar.pro.lifetime",
28 ])
29 #expect(Set(ProStore.productIDs).isDisjoint(with: Tip.productIDs))
30 }
31
32 @Test func grandfathersOnlyOnIOS() {
33 #if os(iOS)
34 #expect(ProStore.grandfathers)
35 #else
36 #expect(!ProStore.grandfathers)
37 #endif
38 }
39
40 @Test func yearlySavingsAreWholePercentAgainstTwelveMonths() {
41 #expect(ProStore.yearlySavings(yearly: Decimal(string: "39.99")!, monthly: Decimal(string: "4.99")!) == 33)
42 #expect(ProStore.yearlySavings(yearly: 60, monthly: 5) == nil)
43 #expect(ProStore.yearlySavings(yearly: 70, monthly: 5) == nil)
44 #expect(ProStore.yearlySavings(yearly: 10, monthly: 0) == nil)
45 }
46}
47#endif
Tests/OrgAppTests/UserConfigTests.swift +10
@@ -310,4 +310,14 @@ struct ThemeReadingTests {
310310 #expect(try String(contentsOf: folder.appendingPathComponent("config.toml"), encoding: .utf8).contains("dark-theme = \"nord\""))
311311 #expect(sync.theme.dark["background"] == ThemeSpec.palette("nord", .dark)?.colors["background"])
312312 }
313
314 @Test func sandboxIgnoresEnvironmentFoldersOutsideTheContainer() {
315 let home = "/Users/me/Library/Containers/sh.krz.orgstar/Data"
316 let outside = ["XDG_CONFIG_HOME": "/Users/me/.config", "ORGSTAR_CONFIG_DIR": "/Users/me/orgstar"]
317 #expect(UserConfig.defaultDirectory(environment: outside, home: home, sandboxed: true).path == home + "/.config/orgstar")
318 #expect(UserConfig.defaultDirectory(environment: outside, home: home, sandboxed: false).path == "/Users/me/orgstar")
319 #expect(UserConfig.defaultDirectory(environment: ["XDG_CONFIG_HOME": "/Users/me/.config"], home: home, sandboxed: false).path == "/Users/me/.config/orgstar")
320 let inside = ["XDG_CONFIG_HOME": home + "/xdg"]
321 #expect(UserConfig.defaultDirectory(environment: inside, home: home, sandboxed: true).path == home + "/xdg/orgstar")
322 }
313323}
Tests/OrgAppTests/WidgetDataTests.swift +8
@@ -101,5 +101,13 @@ struct MacWidgetFolderTests {
101101 #expect(!agenda.path.contains("/Containers/"))
102102 #expect(HabitSnapshot.file()?.deletingLastPathComponent() == agenda.deletingLastPathComponent())
103103 }
104
105 /// The App Store build reads and writes the app group's container, as iOS does.
106 @Test func groupContainerWhenSwitchedOn() {
107 #expect(!AgendaSnapshot.useGroupContainer)
108 let agenda = AgendaSnapshot.file(inGroup: true)
109 #expect(agenda.map { !$0.path.contains("/Application Support/Orgstar/") } ?? true)
110 #expect(agenda.map { $0.path.hasSuffix("/\(CaptureInbox.group)/Widgets/agenda.json") } ?? true)
111 }
104112}
105113#endif
Tests/OrgAppTests/WorkspaceContainsTests.swift added +27
@@ -0,0 +1,27 @@
1import Foundation
2import Testing
3@testable import OrgApp
4
5struct WorkspaceContainsTests {
6 @Test func insideByWholeComponents() {
7 let root = URL(fileURLWithPath: "/tmp/notes")
8 #expect(WorkspaceModel.isInside(URL(fileURLWithPath: "/tmp/notes"), roots: [root]))
9 #expect(WorkspaceModel.isInside(URL(fileURLWithPath: "/tmp/notes/a/b.html"), roots: [root]))
10 #expect(WorkspaceModel.isInside(URL(fileURLWithPath: "/tmp/notes/../notes/b.html"), roots: [root]))
11 #expect(!WorkspaceModel.isInside(URL(fileURLWithPath: "/tmp/notes2/b.html"), roots: [root]))
12 #expect(!WorkspaceModel.isInside(URL(fileURLWithPath: "/tmp/b.html"), roots: [root]))
13 #expect(!WorkspaceModel.isInside(URL(fileURLWithPath: "/tmp/notes/b.html"), roots: []))
14 }
15
16 @Test func insideThroughSymbolicLinks() throws {
17 let base = FileManager.default.temporaryDirectory.appendingPathComponent(UUID().uuidString)
18 defer { try? FileManager.default.removeItem(at: base) }
19 let real = base.appendingPathComponent("real")
20 try FileManager.default.createDirectory(at: real, withIntermediateDirectories: true)
21 let link = base.appendingPathComponent("link")
22 try FileManager.default.createSymbolicLink(at: link, withDestinationURL: real)
23 try Data().write(to: real.appendingPathComponent("a.org"))
24 #expect(WorkspaceModel.isInside(link.appendingPathComponent("a.org"), roots: [real]))
25 #expect(WorkspaceModel.isInside(real.appendingPathComponent("a.org"), roots: [link]))
26 }
27}
Tests/OrgCoreTests/EmacsFallbackTests.swift added +12
@@ -0,0 +1,12 @@
1import Testing
2@testable import OrgCore
3
4struct EmacsFallbackWordingTests {
5 /// The Developer ID and iOS apps keep pointing at Emacs; the App Store app doesn't.
6 @Test func wording() {
7 #expect(EmacsFallback.offered)
8 #expect(EmacsFallback.wording("needs Emacs", "isn't supported") == "needs Emacs")
9 #expect(EmacsFallback.wording("needs Emacs", "isn't supported", offered: false) == "isn't supported")
10 #expect(TableRecalculate.emacsMessage == "needs Emacs: ")
11 }
12}
Tests/OrgCoreTests/ExportOptionsTests.swift +16
@@ -104,4 +104,20 @@ struct ExportOptionsTests {
104104 let ours = ExportPreprocess.macros(ExportPreprocess.includes(text, directory: folder), path: path)
105105 #expect(ours == emacs.first, "ours:\n\(ours)\nemacs:\n\(emacs.first ?? "")")
106106 }
107
108 @Test func unreadableIncludesAreListed() throws {
109 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-includes-\(UUID().uuidString)")
110 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
111 defer { try? FileManager.default.removeItem(at: folder) }
112 try "#+INCLUDE: \"gone.org\"\ntext\n".write(to: folder.appendingPathComponent("part.org"), atomically: true, encoding: .utf8)
113 let text = """
114 #+INCLUDE: "part.org::*Sub" :minlevel 1
115 #+INCLUDE: "missing.org" src sh
116 #+INCLUDE: "missing.org"
117 """
118 #expect(ExportPreprocess.unreadableIncludes(text, directory: folder) == [
119 folder.appendingPathComponent("gone.org").path, folder.appendingPathComponent("missing.org").path,
120 ])
121 #expect(ExportPreprocess.unreadableIncludes("no includes", directory: folder).isEmpty)
122 }
107123}
Tests/OrgCoreTests/PathsTests.swift added +41
@@ -0,0 +1,41 @@
1import Foundation
2import Testing
3@testable import OrgCore
4
5struct PathsTests {
6 /// Unsandboxed, the real home folder is the one Foundation gives.
7 @Test func homeIsFoundationsOutsideTheSandbox() {
8 #expect(OrgPaths.home == NSHomeDirectory())
9 #expect(OrgPaths.expandingTilde("~/org/a.org") == ("~/org/a.org" as NSString).expandingTildeInPath)
10 }
11
12 @Test func tildeExpandsToTheGivenHome() {
13 let home = "/Users/someone"
14 #expect(OrgPaths.expandingTilde("~", home: home) == home)
15 #expect(OrgPaths.expandingTilde("~/", home: home) == home)
16 #expect(OrgPaths.expandingTilde("~/org//notes/", home: home) == "/Users/someone/org/notes")
17 #expect(OrgPaths.expandingTilde("/srv/org/", home: home) == "/srv/org")
18 #expect(OrgPaths.expandingTilde("org/a.org", home: home) == "org/a.org")
19 #expect(OrgPaths.expandingTilde("~~", home: home) == "~~")
20 #expect(OrgPaths.expandingTilde("", home: home) == "")
21 }
22
23 @Test func otherUsersHomesAreFoundations() {
24 #expect(OrgPaths.expandingTilde("~root/x", home: "/Users/someone") == ("~root/x" as NSString).expandingTildeInPath)
25 }
26
27 @Test func abbreviatesTheGivenHome() {
28 let home = "/Users/someone"
29 #expect(OrgPaths.abbreviatingWithTilde("/Users/someone", home: home) == "~")
30 #expect(OrgPaths.abbreviatingWithTilde("/Users/someone/", home: home) == "~")
31 #expect(OrgPaths.abbreviatingWithTilde("/Users/someone/org//a.org", home: home) == "~/org/a.org")
32 #expect(OrgPaths.abbreviatingWithTilde("/Users/someoneelse/a.org", home: home) == "/Users/someoneelse/a.org")
33 #expect(OrgPaths.abbreviatingWithTilde("~/a.org", home: home) == "~/a.org")
34 }
35
36 @Test func abbreviatingMatchesFoundationOutsideTheSandbox() {
37 for path in [NSHomeDirectory(), NSHomeDirectory() + "/org//a.org/", "/tmp/a.org", "relative/a"] {
38 #expect(OrgPaths.abbreviatingWithTilde(path) == (path as NSString).abbreviatingWithTildeInPath)
39 }
40 }
41}
Tests/OrgCoreTests/SandboxTests.swift added +33
@@ -0,0 +1,33 @@
1import Foundation
2import Testing
3@testable import OrgCore
4
5struct SandboxTests {
6 /// Tests run unsandboxed, so every switch keeps the Developer ID build's behaviour.
7 @Test func inactiveInTests() {
8 #expect(!Sandbox.isActive)
9 #expect(Sandbox.bookmarkCreationOptions() == [])
10 #expect(Sandbox.bookmarkResolutionOptions() == [])
11 }
12
13 @Test func detectedFromTheContainerVariable() {
14 #expect(!Sandbox.isActive(environment: [:]))
15 #if os(macOS)
16 #expect(Sandbox.isActive(environment: ["APP_SANDBOX_CONTAINER_ID": "sh.krz.orgstar"]))
17 #else
18 #expect(!Sandbox.isActive(environment: ["APP_SANDBOX_CONTAINER_ID": "sh.krz.orgstar"]))
19 #endif
20 }
21
22 @Test func bookmarksAreSecurityScopedInTheMacSandbox() {
23 #if os(macOS)
24 #expect(Sandbox.bookmarkCreationOptions(sandboxed: true) == .withSecurityScope)
25 #expect(Sandbox.bookmarkResolutionOptions(sandboxed: true) == .withSecurityScope)
26 #else
27 #expect(Sandbox.bookmarkCreationOptions(sandboxed: true) == [])
28 #expect(Sandbox.bookmarkResolutionOptions(sandboxed: true) == [])
29 #endif
30 #expect(Sandbox.bookmarkCreationOptions(sandboxed: false) == [])
31 #expect(Sandbox.bookmarkResolutionOptions(sandboxed: false) == [])
32 }
33}
Tests/OrgDocumentTests/SaveTests.swift +26
@@ -181,6 +181,32 @@ struct FileStorageTests {
181181 #expect(try FileManager.default.contentsOfDirectory(atPath: folder.path) == ["a.org"])
182182 }
183183
184 /// A file the sandbox granted alone: its folder takes no temporary file, so the save writes
185 /// in place and the previous bytes still come back for recovery.
186 @Test func writesInPlaceWhenTheFolderRefusesTheTemporaryFile() throws {
187 let folder = try temporaryFolder()
188 let manager = FileManager.default
189 let file = folder.appendingPathComponent("a.org")
190 try Data("one\n".utf8).write(to: file)
191 try manager.setAttributes([.posixPermissions: 0o555], ofItemAtPath: folder.path)
192 defer {
193 try? manager.setAttributes([.posixPermissions: 0o755], ofItemAtPath: folder.path)
194 try? manager.removeItem(at: folder)
195 }
196 #expect(throws: (any Error).self) { try CoordinatedFileSystem(writesInPlaceWhenDenied: false).replace(file, with: Array("two\n".utf8)) }
197 let files = CoordinatedFileSystem(writesInPlaceWhenDenied: true)
198 #expect(try files.replace(file, with: Array("two\n".utf8)) == Array("one\n".utf8))
199 #expect(try files.read(file) == Array("two\n".utf8))
200 #expect(try manager.contentsOfDirectory(atPath: folder.path) == ["a.org"])
201 }
202
203 @Test func outsideTheSandboxSavesReplaceTheFile() {
204 #expect(!CoordinatedFileSystem().writesInPlaceWhenDenied)
205 #expect(CoordinatedFileSystem.isPermissionDenied(CocoaError(.fileWriteNoPermission)))
206 #expect(CoordinatedFileSystem.isPermissionDenied(NSError(domain: NSPOSIXErrorDomain, code: Int(EACCES))))
207 #expect(!CoordinatedFileSystem.isPermissionDenied(CocoaError(.fileWriteOutOfSpace)))
208 }
209
184210 @Test func savesThroughTheRealFileSystem() throws {
185211 let folder = try temporaryFolder()
186212 defer { try? FileManager.default.removeItem(at: folder) }
Tests/OrgEditorAppKitTests/AppStoreCommandsTests.swift added +20
@@ -0,0 +1,20 @@
1import Foundation
2import OrgEditorAppKit
3import Testing
4import OrgApp
5
6struct AppStoreCommandsTests {
7 @Test func hiddenCommandsExist() {
8 let ids = Set(EditorCommands.all.map(\.id))
9 #expect(AppStoreCommands.hidden.isSubset(of: ids))
10 }
11
12 @Test func pdfKeysExportThroughWebKit() throws {
13 let replacement = try #require(AppStoreCommands.replacement(for: "app.export.pdf"))
14 #expect(replacement == "app.export.print-pdf")
15 #expect(!AppStoreCommands.hidden.contains(replacement))
16 for id in AppStoreCommands.hidden where id != "app.export.pdf" {
17 #expect(AppStoreCommands.replacement(for: id) == nil)
18 }
19 }
20}
Tests/OrgAppTests/BabelSessionTests.swift → Tests/OrgProgramsTests/BabelSessionTests.swift renamed +1
@@ -2,6 +2,7 @@ import Foundation
22import Testing
33import OrgCore
44@testable import OrgApp
5@testable import OrgPrograms
56
67/// Serial: the sessions are shared, and each test stops them all when it ends.
78@Suite(.serialized)
Tests/OrgProgramsTests/Folder.swift added +23
@@ -0,0 +1,23 @@
1import Foundation
2
3/// A temporary folder that removes itself.
4final class Folder {
5 let url: URL
6
7 init() throws {
8 url = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-\(UUID().uuidString)").standardizedFileURL
9 try FileManager.default.createDirectory(at: url, withIntermediateDirectories: true)
10 }
11
12 deinit {
13 try? FileManager.default.removeItem(at: url)
14 }
15
16 @discardableResult
17 func write(_ path: String, _ text: String) throws -> URL {
18 let file = url.appendingPathComponent(path)
19 try FileManager.default.createDirectory(at: file.deletingLastPathComponent(), withIntermediateDirectories: true)
20 try Data(text.utf8).write(to: file)
21 return file.standardizedFileURL
22 }
23}
Tests/OrgProgramsTests/ProgramsTests.swift added +175
@@ -0,0 +1,175 @@
1import Foundation
2import OrgCore
3import OrgDocument
4import Testing
5@testable import OrgApp
6@testable import OrgPrograms
7
8/// Runs each test with `Programs` as the session's runner, scoped to the test's task so
9/// suites without one are unaffected.
10struct WithPrograms: SuiteTrait, TestTrait, TestScoping {
11 func provideScope(for test: Test, testCase: Test.Case?, performing function: @Sendable () async throws -> Void) async throws {
12 try await DocumentSession.$scopedPrograms.withValue(Programs()) { try await function() }
13 }
14}
15
16extension Trait where Self == WithPrograms {
17 static var programs: Self { WithPrograms() }
18}
19
20@MainActor
21@Suite(.programs)
22struct EmacsFallbackTests {
23 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
24 func recalculatesTablesNativeCodeCannot() async throws {
25 let notes = try Folder()
26 let file = try notes.write("t.org", "* Prices\n| item | n | twice |\n|------+---+-------|\n| x | a | |\n| y | 2 | |\n#+TBLFM: $3=$2*2\n")
27 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
28 session.open(file.path)
29 let step = session.perform(TableRecalculate(all: true), path: file.path, at: 50, expect: nil)
30 guard case .external(.emacsTable(let table, let point, let form, let reason, let lisp)) = step else {
31 Issue.record("\(step)")
32 return
33 }
34 #expect(reason == "non-numeric field a")
35 #expect(!lisp)
36 let message = await session.recalculateInEmacs(table: table, point: point, form: form)
37 #expect(message == "Recalculated in Emacs")
38 #expect(session.document?.text == "* Prices\n| item | n | twice |\n|------+---+-------|\n| x | a | 2 a |\n| y | 2 | 4 |\n#+TBLFM: $3=$2*2\n")
39 }
40
41 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
42 func cancelingARecalculationLeavesTheTable() async throws {
43 let notes = try Folder()
44 let text = "| n | twice |\n|---+-------|\n| a | |\n#+TBLFM: $2=$1*2\n"
45 let file = try notes.write("t.org", text)
46 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
47 session.open(file.path)
48 let step = session.perform(TableRecalculate(all: true), path: file.path, at: 2, expect: nil)
49 guard case .external(.emacsTable(let table, let point, let form, _, _)) = step else {
50 Issue.record("\(step)")
51 return
52 }
53 let task = Task { await session.recalculateInEmacs(table: table, point: point, form: form) }
54 task.cancel()
55 #expect(await task.value == "Recalculation canceled")
56 #expect(session.document?.text == text)
57 }
58}
59
60@MainActor
61@Suite(.programs)
62struct BabelSessionTests {
63 @Test func runsBlocksAndWritesResults() async throws {
64 let notes = try Folder()
65 let file = try notes.write("b.org", "#+begin_src sh\necho answer\necho \"$((6 * 7))\"\n#+end_src\n")
66 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
67 session.open(file.path)
68 let step = session.perform(ExecuteSrcBlock(), path: file.path, at: 3, expect: nil)
69 guard case .external(.babel(let job)) = step else {
70 Issue.record("\(step)")
71 return
72 }
73 #expect(await session.runBabel(job) == "Code block evaluation complete.")
74 // A column that is half numbers is right-aligned, as org-table-align does.
75 #expect(session.document?.text == "#+begin_src sh\necho answer\necho \"$((6 * 7))\"\n#+end_src\n\n#+RESULTS:\n| answer |\n| 42 |\n")
76 }
77}
78
79@MainActor
80@Suite(.programs)
81struct BabelErrorTests {
82 func job(_ session: DocumentSession, _ path: String) throws -> BabelJob {
83 guard case .external(.babel(let job)) = session.perform(ExecuteSrcBlock(), path: path, at: 3, expect: nil) else {
84 throw CancellationError()
85 }
86 return job
87 }
88
89 /// Like `org-babel-eval`: the results go in, and the error output and status are shown.
90 @Test func reportsErrorsAndStillInsertsResults() async throws {
91 let notes = try Folder()
92 let file = try notes.write("e.org", "#+begin_src sh\necho out\necho oops >&2\nexit 3\n#+end_src\n")
93 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
94 session.open(file.path)
95 #expect(await session.runBabel(try job(session, file.path)) == "Exited with status 3: oops")
96 #expect(session.document?.text.hasSuffix("#+RESULTS:\n: out\n") == true)
97 }
98
99 @Test func cancelsARunningBlock() async throws {
100 let notes = try Folder()
101 let file = try notes.write("s.org", "#+begin_src sh\nsleep 20\necho late\n#+end_src\n")
102 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
103 session.open(file.path)
104 let start = ContinuousClock.now
105 var message: String?
106 session.startBabel(try job(session, file.path)) { message = $0 }
107 #expect(session.isRunningBabel)
108 try await Task.sleep(for: .milliseconds(200))
109 session.cancelBabel()
110 while message == nil, ContinuousClock.now - start < .seconds(5) { try await Task.sleep(for: .milliseconds(20)) }
111 #expect(message == "Code block canceled.")
112 #expect(!session.isRunningBabel)
113 #expect(ContinuousClock.now - start < .seconds(5))
114 #expect(session.document?.text.contains("#+RESULTS:") == false)
115 }
116}
117
118struct EmacsExportTests {
119 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
120 func exportsBesideTheFile() async throws {
121 let notes = try Folder()
122 let file = try notes.write("doc.org", "#+TITLE: On disk\n")
123 // The buffer's text is exported, not the file's.
124 let written = try await EmacsRunner.export(text: "#+TITLE: In the buffer\n\n* Heading\nBody.\n", path: file.path, function: "org-ascii-export-to-ascii")
125 #expect(URL(fileURLWithPath: written).lastPathComponent == "doc.txt")
126 let text = try String(contentsOfFile: written, encoding: .utf8)
127 #expect(text.uppercased().contains("IN THE BUFFER") && text.contains("Body."), "\(text)")
128 #expect(try String(contentsOf: file, encoding: .utf8) == "#+TITLE: On disk\n")
129 }
130
131 /// The dispatcher's `C-s` and `C-b`: the subtree at point alone, its EXPORT_FILE_NAME used.
132 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
133 func exportsTheSubtreeBodyOnly() async throws {
134 let notes = try Folder()
135 let file = try notes.write("doc.org", "")
136 let text = "#+TITLE: Doc\n* Ünï\nFirst.\n* Second\n:PROPERTIES:\n:EXPORT_FILE_NAME: second\n:END:\nOnly this.\n"
137 let point = (text as NSString).substring(to: (text as NSString).range(of: "Only").location).unicodeScalars.count + 1
138 let written = try await EmacsRunner.export(text: text, path: file.path, function: "org-ascii-export-to-ascii", subtree: point, bodyOnly: true)
139 #expect(URL(fileURLWithPath: written).lastPathComponent == "second.txt")
140 let out = try String(contentsOfFile: written, encoding: .utf8)
141 #expect(out.contains("Only this.") && !out.contains("First.") && !out.uppercased().contains("DOC"), "\(out)")
142 }
143
144 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
145 func exportUsesBabelPath() async throws {
146 let notes = try Folder()
147 let file = try notes.write("doc.org", "")
148 let function = #"(lambda () (with-temp-file "path.txt" (insert (getenv "PATH"))) "path.txt")"#
149 let written = try await EmacsRunner.export(text: "", path: file.path, function: function)
150 #expect(try String(contentsOfFile: written, encoding: .utf8) == BabelRunner.environment["PATH"])
151 }
152
153 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil))
154 func cancellingStopsTheExport() async throws {
155 let notes = try Folder()
156 let file = try notes.write("doc.org", "")
157 let pidFile = notes.url.appendingPathComponent("pid")
158 let function = #"(lambda () (with-temp-file "pid" (insert (number-to-string (emacs-pid)))) (sleep-for 60) "x")"#
159 let export = Task { try await EmacsRunner.export(text: "", path: file.path, function: function) }
160 var pid: pid_t?
161 for _ in 0..<200 where pid == nil {
162 try await Task.sleep(for: .milliseconds(50))
163 pid = (try? String(contentsOf: pidFile, encoding: .utf8)).flatMap { pid_t($0) }
164 }
165 let started = try #require(pid)
166 export.cancel()
167 await #expect(throws: CancellationError.self) { try await export.value }
168 var alive = true
169 for _ in 0..<100 where alive {
170 alive = kill(started, 0) == 0
171 if alive { try await Task.sleep(for: .milliseconds(50)) }
172 }
173 #expect(!alive)
174 }
175}
Tests/OrgWorkspaceTests/WorkspaceRootTests.swift added +33
@@ -0,0 +1,33 @@
1import Foundation
2import OrgCore
3import Testing
4@testable import OrgWorkspace
5
6struct WorkspaceRootTests {
7 @Test func plainBookmarkResolves() throws {
8 let folder = try Folder()
9 let root = try WorkspaceRoot(url: folder.url)
10 let resolved = try root.resolve()
11 #expect(resolved.url.resolvingSymlinksInPath() == folder.url.resolvingSymlinksInPath())
12 #expect(root.path == folder.url.path)
13 }
14
15 /// Tests run unsandboxed, so roots keep the Developer ID build's plain bookmarks.
16 @Test func unsandboxedByDefault() throws {
17 #expect(!Sandbox.isActive)
18 let folder = try Folder()
19 let root = try WorkspaceRoot(url: folder.url)
20 #expect(try root.resolve(sandboxed: false).url.resolvingSymlinksInPath() == folder.url.resolvingSymlinksInPath())
21 #expect(root.bookmark == (try WorkspaceRoot(url: folder.url, sandboxed: false)).bookmark)
22 }
23
24 #if os(macOS)
25 /// The sandboxed build's bookmarks carry their scope, and resolve with it.
26 @Test func securityScopedBookmarkResolves() throws {
27 let folder = try Folder()
28 let root = try WorkspaceRoot(url: folder.url, sandboxed: true)
29 #expect(try root.resolve(sandboxed: true).url.resolvingSymlinksInPath() == folder.url.resolvingSymlinksInPath())
30 #expect(root.bookmark != (try WorkspaceRoot(url: folder.url, sandboxed: false)).bookmark)
31 }
32 #endif
33}
docs/manual/guide/10-tables.org +7
@@ -538,6 +538,10 @@ Edit ▸ Cancel Running Task (=⌘.=) stops the recalculation; the echo area sho
538538=Recalculation canceled= and the table is unchanged. Starting another recalculation or
539539export in Emacs cancels the one that is running.
540540
541The [[file:../install.org][Mac App Store version]] doesn't run Emacs, so it recalculates
542only the tables orgstar computes itself. For any other table the echo area shows =This
543table's formulas can't be calculated here: (reason).=, and the table is unchanged.
544
541545If the table's formulas contain Lisp, orgstar asks first:
542546=This table's formulas run Lisp. Run them? (yes, no, always)=. =always= trusts this
543547table's text in this file, so the question isn't asked again until the text changes.
@@ -624,6 +628,9 @@ new plot.
624628
625629=type:radar= needs gnuplot; orgstar reports it.
626630
631The [[file:../install.org][Mac App Store version]] doesn't use gnuplot: it always draws
632the plot with Swift Charts, and reports =type:radar= in the same way.
633
627634* On iOS
628635
629636The iOS app evaluates formulas natively with the same engine. Tables that need Emacs
docs/manual/guide/11-code-blocks.org +12
@@ -103,6 +103,8 @@ Any other language is refused with "No way to run /language/ blocks yet."
103103
104104A run that takes longer than five minutes is stopped. Runs in a =:session= have no time limit.
105105
106The [[file:../install.org][Mac App Store version]] starts no programs, so only Emacs Lisp blocks run there; see /In the Mac App Store version/ below.
107
106108** Compiled languages
107109
108110On the Mac, =C=, =C++=, =cpp=, =D=, =java=, =fortran= and =clojure= blocks run as Org's =ob-C=, =ob-java=, =ob-fortran= and =ob-clojure= run them. orgstar writes the body, expanded as tangling writes it (see Tangling below), to a source file in a temporary folder, compiles it and runs the program in the file's folder or =:dir=, with a newline on standard input. What the compiler prints is dropped.
@@ -600,6 +602,8 @@ On the Mac, an =emacs-lisp= or =elisp= block runs in a new =emacs -Q --batch= fo
600602
601603On iOS, Emacs Lisp blocks run in orgstar's own Emacs Lisp interpreter. It covers ordinary list, string, number and control forms, =princ= and =message=. A block that uses something the interpreter does not have fails with "This block uses Emacs Lisp that runs only in Emacs, on the Mac." A Lisp error fails the run, as it does in Emacs.
602604
605In the [[file:../install.org][Mac App Store version]], Emacs Lisp blocks run in the same interpreter as on iOS. A block that uses something it does not have fails with "This block uses Emacs Lisp that runs only in Emacs."
606
603607Variables are bound with =let= around the body. =:results output= collects what the block prints with =princ=, =prin1=, =print= and =terpri=.
604608
605609* Graphics
@@ -708,6 +712,7 @@ Comments need the language's comment syntax. orgstar knows it for: =emacs-lisp=,
708712- A file whose contents would not change is left alone, so its modification time stays the same.
709713- A read-only file is replaced.
710714- Tangling into the Org file itself is refused: "Not allowed to tangle into the same file as self".
715- When a file's mode, from =:shebang= or =:tangle-mode=, can't be set, the other files are still written and their modes set, and the message area says "Tangled /N/ code blocks from /file/, but can't set the mode of /path/: /reason/".
711716
712717** What tangling refuses
713718
@@ -731,3 +736,10 @@ Tangling stops, writes nothing and says why when:
731736- Edit Block opens a plain text sheet without highlighting.
732737
733738See [[file:14-ios.org][iOS]] for the rest of the iOS app.
739
740* In the Mac App Store version
741
742- Only Emacs Lisp blocks run, in the same interpreter as on iOS. Any other language, compiled languages included, fails with "/language/ blocks don't run in this version of orgstar."
743- There are no sessions and no graphics.
744- The trust prompt works the same way.
745- Tangling works as in the download version, =:shebang= included. A target outside your folders needs access to its folder first: orgstar asks with Grant Access…, as described in [[file:../install.org][Install]]. So does a =:file= result outside them.
docs/manual/guide/12-export.org +4
@@ -29,6 +29,8 @@ The keys follow Emacs's export dispatcher (=org-export-dispatch=). =C-c C-e= on
2929
3030All fourteen commands are in File ▸ Export and in the command palette. They write the export beside the Org file, with the same name and the format's extension: =.html=, =.md=, =.pdf=, =.docx=, =.rtf=, =.tex=, =.odt=, =.txt= or =.ics=. The two agenda-file commands are the exceptions; see [[*iCalendar export][iCalendar export]]. =#+EXPORT_FILE_NAME:= names it instead, as in Org: relative to the Org file's folder (or absolute, or starting with =~=), with its extension replaced by the format's, so =#+EXPORT_FILE_NAME: out/report= writes =out/report.html=. A file already there is replaced. The message area shows "Exported to /name/".
3131
32The [[file:../install.org][Mac App Store version]] has the ten commands that don't need Emacs; File ▸ Export, the export dialog and the command palette leave out the other four, and a key bound to Export to PDF with Emacs runs Export to PDF. When the export file, or an =#+INCLUDE:= or =#+SETUPFILE:=, is outside your folders, orgstar first asks for access to its folder; for the export file, Save Elsewhere… instead picks another place. See [[file:../install.org][Install]].
33
3234** The export dialog
3335
3436*Export…* in the command palette, or =⇧⌘E= in the Mac preset, opens a dialog. The Emacs and Doom presets have no key for it; bind =app.export-dialog= in =keymap.toml= if you want one (see [[file:03-keys.org][Keys and commands]]). The dialog has:
@@ -338,6 +340,8 @@ On the Mac, PDF, LaTeX, ODT and plain text exports are done by Emacs, with the =
338340| ODT | =org-odt-export-to-odt= |
339341| Plain text | =org-ascii-export-to-ascii= |
340342
343The [[file:../install.org][Mac App Store version]] doesn't run Emacs and has none of these exports.
344
341345orgstar runs =emacs -Q --batch= in the Org file's folder. It opens the file, replaces its contents with the editor's current text without saving, and calls the function. Emacs writes the result beside the file, as it would itself; with a destination chosen in the export dialog, orgstar then moves it there. The message area shows "Exporting with Emacs…" and then "Exported to /name/".
342346
343347What you need:
docs/manual/guide/13-configuration.org +6
@@ -11,6 +11,8 @@ orgstar keeps its settings in a configuration folder:
1111
1212The environment variable =ORGSTAR_CONFIG_DIR= overrides both. If a file is missing from the configuration folder but exists in =~/Library/Application Support/Orgstar= (where earlier versions kept it), orgstar reads it from there, and reloads it when you edit it there.
1313
14The [[file:../install.org][Mac App Store version]] keeps the configuration folder in its container, =~/Library/Containers/sh.krz.orgstar/Data/.config/orgstar=. Settings ▸ General ▸ Choose Configuration Folder… makes it use another folder, such as =~/.config/orgstar= shared with the download version or kept with your dotfiles; Use Default Folder goes back to the container.
15
1416The folder holds these files:
1517
1618| File | What it holds | Written by orgstar |
@@ -54,6 +56,8 @@ Open it with orgstar ▸ Settings (=⌘,=). It has five panes. Each control writ
5456| config.toml: Edit in orgstar | Opens the file in the main window | | |
5557| config.toml: Open with Default App | Opens the file in the app macOS uses for =.toml= | | |
5658| config.toml: Show in Finder | Selects the file in Finder | | |
59| Folder: Choose Configuration Folder… | Mac App Store version: reads and writes the configuration in a folder you choose | | |
60| Folder: Use Default Folder | Mac App Store version: goes back to the folder in the app's container | | |
5761| Emacs: Import from Emacs… | Opens the import sheet; see Import from Emacs below| | |
5862| Save files | Automatically, when typing stops; Only with File ▸ Save (=⌘S=) | Automatically | =save= |
5963| Keys | Emacs; Mac; Doom (Vim keys) | Emacs | =keymap= |
@@ -569,6 +573,8 @@ A literate configuration (=config.org=) is read as =org-babel-load-file= and Doo
569573
570574On iOS, Settings ▸ Import from Emacs reads a configuration folder you choose; see [[file:14-ios.org][iOS]].
571575
576In the [[file:../install.org][Mac App Store version]], Import from Emacs first opens a picker at the configuration it finds, since the app can read only what you choose. For a Doom configuration, Choose Doom Folder… picks Doom's installation folder, so its org defaults are read; without it the footer says Doom's own org defaults were skipped. On Import, each folder to add opens a picker at that folder, and only the folders you choose there are added.
577
572578** Doom Emacs
573579
574580A configuration counts as Doom when it contains =(doom!=, =(map! = or =(after! =. orgstar then also reads Doom's own org defaults, from the Doom installation in =$EMACSDIR=, =~/.config/emacs= or =~/.emacs.d=: =modules/lang/org/config.el= and =lisp/doom-emacs.el=. Your configuration overrides them. Doom defaults orgstar has no use for are counted in the footer rather than listed.
docs/manual/guide/15-alongside-emacs.org +2 −1
@@ -97,6 +97,7 @@ When scanning folders, orgstar skips Emacs lock files (=.#name=), backups (=name
9797Every version a save, a merge or a conflict resolution displaces is kept in the recovery folder, and so is a snapshot of the file before a save, at most once an hour:
9898
9999- on the Mac, =~/Library/Application Support/Orgstar/Recovery= (or =$ORGSTAR_DATA_DIR/Recovery=),
100- in the Mac App Store version, =~/Library/Containers/sh.krz.orgstar/Data/Library/Application Support/Orgstar/Recovery=,
100101- on iOS, the app's own Application Support folder.
101102
102103Each file has a subfolder named from a hash of its path, holding its last 20 replaced versions and, apart from them, its last 10 snapshots. A version's file name has a timestamp, a label and the file's name. The labels are:
@@ -112,7 +113,7 @@ File ▸ Recovery Versions… (More ▸ Recovered Versions on iOS) lists the ope
112113
113114* Features that use Emacs on the Mac
114115
115Some features run Emacs in batch mode on the Mac. Everything else works without Emacs installed.
116Some features run Emacs in batch mode on the Mac. Everything else works without Emacs installed. The [[file:../install.org][Mac App Store version]] never runs Emacs and does without these features.
116117
117118| Feature | What runs |
118119|----------------------------------------------------------------+-----------------------------------------------------------------------------------------------|
docs/manual/index.org +1 −1
@@ -15,7 +15,7 @@ reminders, export and tangling.
1515
1616* Start here
1717
18- [[file:install.org][Install]]: the Mac app with Homebrew or a download, the iOS app from the App Store, or either from source.
18- [[file:install.org][Install]]: the Mac app from the Mac App Store, with Homebrew or as a download, the iOS app from the App Store, or either from source.
1919- [[file:quickstart.org][Quick start]]: add a folder, open a file, and the first keys to learn.
2020- The manual, below: every feature, chapter by chapter.
2121
docs/manual/install.org +111 −5
@@ -1,17 +1,35 @@
11#+TITLE: Install
2#+DESCRIPTION: Installing orgstar on the Mac with Homebrew or a download, and on iPhone and iPad from the App Store.
3#+LEDE: The Mac app comes as a notarized download and a Homebrew cask; the iOS app is on the App Store.
2#+DESCRIPTION: Installing orgstar on the Mac from the Mac App Store, with Homebrew or a download, and on iPhone and iPad from the App Store.
3#+LEDE: The Mac app comes from the Mac App Store, or as a notarized download and a Homebrew cask; the iOS app is on the App Store.
44
55* Requirements
66
77- macOS 26 or later.
8- Optional: GNU Emacs, for the features that hand work to it on the Mac
8- Optional, for the download version: GNU Emacs, for the features that hand work to it
99 (Emacs Lisp code blocks that need full Emacs, Lisp table formulas the built-in
1010 interpreter can't run, and export to PDF, LaTeX, ODT and other formats). See
1111 [[file:guide/15-alongside-emacs.org][Working alongside Emacs and other tools]].
1212
1313* The Mac app
1414
15There are two versions of the Mac app. Both edit the same files in the same way; they
16differ in where they come from, how orgstar+ is bought, and what they can run.
17
18- The Mac App Store version runs in the App Sandbox and starts no other programs. Emacs
19 Lisp blocks run in orgstar's own interpreter, as on iOS; other languages, Emacs and
20 gnuplot are not used. orgstar+ is an in-app purchase shared with the iPhone and iPad app.
21- The download version, from Homebrew or files.krz.sh, is signed with a Developer ID and
22 notarized. It runs code blocks with the programs installed on the Mac, hands some tables and
23 exports to Emacs, and updates itself.
24
25** From the Mac App Store
26
27Get orgstar from the [[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][Mac App Store]]. The Mac App Store keeps it up to date.
28
29Settings ▸ orgstar+ has the monthly, yearly and lifetime plans and Restore Purchases. A
30purchase made with the same Apple Account on iPhone or iPad unlocks orgstar+ on the Mac too,
31and the other way round. The same tab has tips, which unlock nothing.
32
1533** With Homebrew
1634
1735#+BEGIN_SRC sh
@@ -26,7 +44,89 @@ orgstar to Applications. The app is universal (Apple silicon and Intel), signed
2644Developer ID and notarized by Apple, so it opens without warnings.
2745
2846Once the app has been launched, Finder opens =.org= files with it, Quick Look shows
29them formatted, and Spotlight indexes their headings and text.
47them formatted, and Spotlight indexes their headings and text. The same is true of the Mac
48App Store version.
49
50* The Mac App Store version
51
52** What it does differently
53
54| Feature | Mac App Store version | Download version |
55|----------------------------+-------------------------------------------------------------------+--------------------------------------------------------|
56| Code blocks | Emacs Lisp, in orgstar's own interpreter | Every language installed; Emacs Lisp in Emacs |
57| Sessions, graphics | No | Yes |
58| Tangling | Yes | Yes |
59| Table formulas | Those orgstar computes itself | The rest in Emacs as well |
60| Plots | Drawn with Swift Charts | gnuplot when installed, else Swift Charts |
61| Export | HTML, Markdown, PDF, Word, RTF, plain text, iCalendar; publishing | Also PDF through LaTeX, LaTeX, ODT and ASCII, in Emacs |
62| Settings | In the app's container, or a folder you choose | =~/.config/orgstar= |
63| Files outside your folders | After you grant access to their folder | Directly |
64| Attachments | Copied, or moved from inside your folders | Copied, moved, linked or symlinked |
65| Updates | The Mac App Store | Built in, or Homebrew |
66| orgstar+ | In-app purchase, shared with iPhone and iPad | License key |
67
68A block in another language reports "/language/ blocks don't run in this version of
69orgstar." An Emacs Lisp block that uses more than the interpreter has reports "This block uses
70Emacs Lisp that runs only in Emacs." A table whose formulas need Emacs reports "This table's
71formulas can't be calculated here", with the reason, and isn't changed. The Emacs exports are
72not in the File ▸ Export menu, the export dialog or the command palette; a key bound to
73Export to PDF with Emacs exports to PDF without LaTeX.
74
75** Folders and files
76
77The App Store version can open only the folders and files you give it:
78
79- Folders you add (File ▸ Add Folder…, or the welcome sheet) and files you open from Finder.
80 orgstar remembers them across launches.
81- When something needs a file outside them, such as an =#+INCLUDE:= or =#+SETUPFILE:=, a
82 tangle target, an export file, an image in a PDF, Word or RTF export, a =file:= link, a
83 =:file= result, a publishing folder, a capture target, an archive file, or the folder for
84 org-roam nodes, daily notes or Denote notes, orgstar asks once. Grant Access… opens a folder picker at that folder; choose it, and orgstar
85 uses that folder and everything in it from then on. An export also offers Save Elsewhere….
86- A folder that can no longer be opened, for example one on a disk that isn't connected, is
87 listed under Can't Open in the sidebar, with Grant Access… to choose it again.
88- =~= in paths and settings means your home folder, as in the download version.
89- Import from Emacs opens a picker at the configuration it finds and asks for each folder it
90 adds to the sidebar. For a Doom configuration, Choose Doom Folder… reads Doom's own org
91 defaults from its installation folder.
92
93** Settings
94
95The App Store version keeps its settings in its container,
96=~/Library/Containers/sh.krz.orgstar/Data/.config/orgstar/=. To keep them in
97=~/.config/orgstar/= instead, for example to share them with the download version, the iOS app
98or your dotfiles, click Settings ▸ General ▸ Choose Configuration Folder… and choose that
99folder. If it has no =config.toml=, orgstar writes one with the current settings. Use Default
100Folder goes back to the container.
101
102* Switching between the two Mac versions
103
104Both versions are called orgstar and have the same bundle identifier. Keep only one of them:
105quit orgstar and delete =orgstar.app= from Applications, or run =brew uninstall --cask
106orgstar=, before installing the other. With both on the Mac, Finder, Quick Look, Spotlight,
107widgets and =org-protocol://= links each use one of them, as macOS picks.
108
109The two don't share their sidebar folders, open files, recovery versions or orgstar+:
110
111- After switching, add your folders again with File ▸ Add Folder….
112- The App Store version's purchase doesn't unlock the download version, and a license key
113 doesn't unlock the App Store version.
114- Recovery versions stay with the version that made them. The App Store version keeps them in
115 =~/Library/Containers/sh.krz.orgstar/Data/Library/Application Support/Orgstar/Recovery/=.
116
117Settings move this way:
118
119- From the download version to the App Store version: your settings stay in
120 =~/.config/orgstar/=. Choose that folder with Choose Configuration Folder… (see /Settings/
121 above).
122- From the App Store version to the download version: if you chose =~/.config/orgstar/=, there
123 is nothing to move. Otherwise copy the files out of the container; =cp -i= asks before
124 replacing a file that is already there:
125
126#+BEGIN_SRC sh
127mkdir -p ~/.config/orgstar
128cp -i ~/Library/Containers/sh.krz.orgstar/Data/.config/orgstar/*.toml ~/.config/orgstar/
129#+END_SRC
30130
31131* The iOS app
32132
@@ -37,6 +137,9 @@ See [[file:guide/14-ios.org][iPhone and iPad]] for what it does.
37137
38138* Updating
39139
140The Mac App Store updates the App Store version. The rest of this section is about the download
141version.
142
40143orgstar checks for a new release once a day, after asking on its second launch whether it
41144may; orgstar ▸ Check for Updates… checks now, and Settings ▸ General has the switch. An update
42145downloads, is checked against the key the releases are signed with, and installs when you
@@ -53,5 +156,8 @@ Your settings live in =~/.config/orgstar/= and survive rebuilds.
53156* Uninstalling
54157
55158Delete =orgstar.app=, or run =brew uninstall --cask orgstar=. To remove your settings as
56well, delete =~/.config/orgstar/= (=brew uninstall --zap --cask orgstar= does both).
159well, delete =~/.config/orgstar/= (=brew uninstall --zap --cask orgstar= does both). The App
160Store version keeps its settings, index and recovery versions in
161=~/Library/Containers/sh.krz.orgstar/=, and the widgets' data in
162=~/Library/Group Containers/group.sh.krz.orgstar/=.
57163Your org files are never stored inside the app.
ios/AppStore/metadata.md +77
@@ -61,3 +61,80 @@ org-mode,emacs,outline,todo,agenda,plain text,notes,tasks,gtd,planner,journal,or
6161## Privacy policy URL
6262
6363https://krz.sh/privacy/orgstar/
64
65## macOS
66
67The Mac App Store app shares the iOS app's record and bundle ID (Universal Purchase). Subtitle, copyright and privacy policy URL above apply to both; the sections below are the macOS version's own.
68
69### Description
70
71orgstar is an editor for Org mode files on the Mac. It reads and writes the same plain-text .org files Emacs does and leaves every byte you didn't change as it was, so your folder stays in step with Emacs, the iPhone and iPad app and whatever sync tool you use.
72
73Work on folders you choose, in iCloud Drive, a Syncthing folder or anywhere else. There is no database of your notes: orgstar keeps an index for search and the agenda, rebuilt from the files whenever they change.
74
75EDITOR
76- Headings, TODO keywords, priorities, tags, timestamps, links, lists, tables and source blocks, styled as you type
77- Folding and structure editing, with Emacs, Mac or Doom (Vim) keys
78- Several files side by side in panes and tabs
79- Changes made by other apps merged into your edits, with a sheet to resolve overlapping changes
80
81AGENDA
82- Scheduled items, deadlines and timestamps from all your files, by day
83- A board that shows entries as a table or as kanban columns
84- Habits with their consistency graph
85- Events from the Calendar app alongside your entries
86
87CAPTURE
88- Capture templates with questions, as in Org
89- Capture from a global keyboard shortcut, from Shortcuts, or from org-protocol links, so browser bookmarklets work unchanged
90
91CLOCKING
92- Clock in and out of entries, with the running clock in the menu bar
93- Clock reports
94
95AND MORE
96- Search across file names, headings and text
97- Table formulas and plots
98- Emacs Lisp source blocks, run by orgstar's own interpreter, and tangling source blocks into files
99- Export to HTML, Markdown, PDF, Word, RTF, plain text and iCalendar, and publishing projects
100- Desktop and Notification Center widgets: Today, Up Next and Habits
101- Spotlight search and Quick Look previews of .org files
102- Import from Emacs: reads your Emacs or Doom configuration and carries over org settings, folders, capture templates, key bindings and agenda views
103- Settings in plain text files you can keep with your dotfiles
104
105ORGSTAR+
106Editing, the agenda, capture, clocking, tables, search, and HTML and Markdown export are free. orgstar+, monthly, yearly or as a one-time lifetime purchase, adds:
107- Running Emacs Lisp blocks and tangling
108- PDF, Word and rich text export, and publishing
109- Encrypted entries
110- Org-roam nodes, daily notes and backlinks
111- Widgets
112- Calendar events and reminders in the agenda
113- Shortcuts actions
114orgstar+ bought on iPhone or iPad unlocks the Mac too, and the other way round.
115
116### Keywords
117
118org-mode,emacs,outline,todo,agenda,plain text,notes,tasks,gtd,planner,kanban,org file,clock,markdown
119
120### What's New
121
122orgstar is now on the Mac App Store. orgstar+ bought in the iPhone and iPad app unlocks it here too.
123
124### App Review notes
125
126- The app runs in the App Sandbox and starts no other programs. It reads and writes only folders and files the user chooses in an open panel or opens from Finder, and keeps security-scoped bookmarks to them.
127- Code (guideline 2.5.2): source blocks the user writes in their own documents can be run, and only Emacs Lisp blocks run. They are evaluated by an interpreter inside the app; no code is downloaded, and nothing changes the app's features. Before a block runs, the app asks whether to run it; the user can let it remember a block they trust.
128- com.apple.security.network.client: remote images in documents, attaching a file from a URL, MathJax in HTML and PDF export, and the App Store.
129- com.apple.security.files.user-selected.executable: tangling writes source blocks to files in folders the user chose. A block with a :shebang header, such as a shell script, gets the executable bit (mode 0755), as Org mode sets it. The app never runs these files.
130- com.apple.security.personal-information.calendars: Calendar events and reminders in the agenda, after the system asks.
131- com.apple.security.application-groups: the widgets read the agenda from the app group.
132- To try it: on the first launch, click Choose Folder… and pick any folder, or New Folder in iCloud Drive… to make one with a notes file. orgstar+ is in Settings (Command-comma) ▸ orgstar+, with Restore Purchases and the tips.
133
134### TestFlight
135
136Beta App Description: orgstar for the Mac, from the Mac App Store. An editor for Org mode files that reads and writes plain-text .org files in folders you choose.
137
138What to Test: Add a folder, edit files, check the agenda, capture and clocking. Run an Emacs Lisp block and tangle a file. Try orgstar+ with a purchase or Restore Purchases, and the widgets.
139
140Feedback email: help@krz.sh
ios/Orgstar.xcodeproj/project.pbxproj +434
@@ -21,6 +21,19 @@
2121 0A61626884F48A1B4963D767 /* OrgWatchData in Frameworks */ = {isa = PBXBuildFile; productRef = 925F6F580D155C1597A5F07B /* OrgWatchData */; };
2222 C6824548013D3A2076EAF9C7 /* OrgWatchData in Frameworks */ = {isa = PBXBuildFile; productRef = 2EFA0D9CD8BD435F6283F3AA /* OrgWatchData */; };
2323 625E39E946591E6D43200C02 /* OrgstarWatch/Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C908C5209CABA6130FD12641 /* OrgstarWatch/Assets.xcassets */; };
24 34F40D483630871B50619E6F /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = B1EC171400CB989363332D07 /* OrgApp */; };
25 4392873ADA2B1FC8930BE6C9 /* OrgEditorAppKit in Frameworks */ = {isa = PBXBuildFile; productRef = 0E5F6DB1CD783274FB49FD5E /* OrgEditorAppKit */; };
26 CA594F2E6DAFED2D16900872 /* OrgHighlight in Frameworks */ = {isa = PBXBuildFile; productRef = 88F9A423F8C1EBE523B6438B /* OrgHighlight */; };
27 D94278A370A1FB41D7A518DA /* AppIcons.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = B977A6852EA92ABDAA7C98AA /* AppIcons.xcassets */; };
28 8626AEED3928BE739C1DF301 /* IconPreviews in Resources */ = {isa = PBXBuildFile; fileRef = 9B39CA5A070717D948728096 /* IconPreviews */; };
29 BA4DCBEF0B0F66E84D66137B /* OrgstarMac/PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = AD93BA820CE0A7E09BB5CB1C /* OrgstarMac/PrivacyInfo.xcprivacy */; };
30 C1D3CBF59C494CF9A95F1B28 /* OrgstarQuickLook.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = 54F0339BC26341A6010C1386 /* OrgstarQuickLook.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
31 5A205B2638DB5D65DC83501B /* OrgstarWidgets.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = B54C32C5D364C02EE21DB092 /* OrgstarWidgets.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
32 15F20FD7060931A9FA7D5B5A /* OrgstarSpotlight.appex in Embed Foundation Extensions */ = {isa = PBXBuildFile; fileRef = AC88ABFF2E0DEC4AD6935E44 /* OrgstarSpotlight.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
33 C4B7AD977A87099C72B5E114 /* OrgCore in Frameworks */ = {isa = PBXBuildFile; productRef = 43689CAB6915EAB97D264A39 /* OrgCore */; };
34 B59088D6FF3E6C60DF909823 /* OrgstarSpotlight/PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 20B42E017B9B06BDBBF0CCDD /* OrgstarSpotlight/PrivacyInfo.xcprivacy */; };
35 9B607A4A9227D06D4F53091C /* OrgstarQuickLook/PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 7B319D00B61E5D44B6F8660B /* OrgstarQuickLook/PrivacyInfo.xcprivacy */; platformFilters = (macos, ); };
36 3AA1AFEEC1E57E8A3A1AF804 /* OrgstarWidgets/PrivacyInfo.xcprivacy in Resources */ = {isa = PBXBuildFile; fileRef = 83EDEDFCE07E278A9F985A17 /* OrgstarWidgets/PrivacyInfo.xcprivacy */; platformFilters = (macos, ); };
2437/* End PBXBuildFile section */
2538
2639/* Begin PBXContainerItemProxy section */
@@ -59,6 +72,27 @@
5972 remoteGlobalIDString = 9571051E69F5D60E9CDFD246;
6073 remoteInfo = OrgstarWatch;
6174 };
75 77FCBFF918E6E58AE9698F1B /* PBXContainerItemProxy */ = {
76 isa = PBXContainerItemProxy;
77 containerPortal = 46F86FAA6BBF9AC94A7E4595 /* Project object */;
78 proxyType = 1;
79 remoteGlobalIDString = BBA37636EB6BBA564493899D;
80 remoteInfo = OrgstarQuickLook;
81 };
82 A211EBFC69B345042D422426 /* PBXContainerItemProxy */ = {
83 isa = PBXContainerItemProxy;
84 containerPortal = 46F86FAA6BBF9AC94A7E4595 /* Project object */;
85 proxyType = 1;
86 remoteGlobalIDString = E87BE20AFDC99FD25E1A163F;
87 remoteInfo = OrgstarWidgets;
88 };
89 7C6ACD0E0D599F98671D5D8D /* PBXContainerItemProxy */ = {
90 isa = PBXContainerItemProxy;
91 containerPortal = 46F86FAA6BBF9AC94A7E4595 /* Project object */;
92 proxyType = 1;
93 remoteGlobalIDString = 983BBE813E871966964F6876;
94 remoteInfo = OrgstarSpotlight;
95 };
6296/* End PBXContainerItemProxy section */
6397
6498/* Begin PBXCopyFilesBuildPhase section */
@@ -97,6 +131,19 @@
97131 name = "Embed Watch Content";
98132 runOnlyForDeploymentPostprocessing = 0;
99133 };
134 50EAF92A2ABF4715F69C1B26 /* Embed Foundation Extensions */ = {
135 isa = PBXCopyFilesBuildPhase;
136 buildActionMask = 2147483647;
137 dstPath = "";
138 dstSubfolderSpec = 13;
139 files = (
140 C1D3CBF59C494CF9A95F1B28 /* OrgstarQuickLook.appex in Embed Foundation Extensions */,
141 15F20FD7060931A9FA7D5B5A /* OrgstarSpotlight.appex in Embed Foundation Extensions */,
142 5A205B2638DB5D65DC83501B /* OrgstarWidgets.appex in Embed Foundation Extensions */,
143 );
144 name = "Embed Foundation Extensions";
145 runOnlyForDeploymentPostprocessing = 0;
146 };
100147/* End PBXCopyFilesBuildPhase section */
101148
102149/* Begin PBXFileReference section */
@@ -120,6 +167,20 @@
120167 512F8C0EB67DE2C4AB5051D4 /* OrgstarWatchWidgets/Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = OrgstarWatchWidgets/Info.plist; sourceTree = "<group>"; };
121168 970E22E052046C63CA01A88F /* OrgstarWatch/OrgstarWatch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarWatch/OrgstarWatch.entitlements; sourceTree = "<group>"; };
122169 F75B5AA8EBA6F457B6D124AC /* OrgstarWatchWidgets/OrgstarWatchWidgets.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarWatchWidgets/OrgstarWatchWidgets.entitlements; sourceTree = "<group>"; };
170 C51149D0B6EA8A5C84383462 /* orgstar.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = orgstar.app; sourceTree = BUILT_PRODUCTS_DIR; };
171 AC88ABFF2E0DEC4AD6935E44 /* OrgstarSpotlight.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = OrgstarSpotlight.appex; sourceTree = BUILT_PRODUCTS_DIR; };
172 5CAA663B7191AA35B15DE681 /* OrgstarMac/Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = OrgstarMac/Info.plist; sourceTree = "<group>"; };
173 465A4F530E1EB892DCA2659D /* OrgstarMac/Orgstar.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarMac/Orgstar.entitlements; sourceTree = "<group>"; };
174 AD93BA820CE0A7E09BB5CB1C /* OrgstarMac/PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = OrgstarMac/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
175 B977A6852EA92ABDAA7C98AA /* AppIcons.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = AppIcons.xcassets; path = ../packaging/AppIcons.xcassets; sourceTree = "<group>"; };
176 9B39CA5A070717D948728096 /* IconPreviews */ = {isa = PBXFileReference; lastKnownFileType = folder; name = IconPreviews; path = ../packaging/IconPreviews; sourceTree = "<group>"; };
177 7B28B0DBC8FEDCBB28FF11E9 /* OrgstarSpotlight/Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = OrgstarSpotlight/Info.plist; sourceTree = "<group>"; };
178 108CFDFF570EDFC4035D4DF7 /* OrgstarSpotlight/OrgstarSpotlight.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarSpotlight/OrgstarSpotlight.entitlements; sourceTree = "<group>"; };
179 20B42E017B9B06BDBBF0CCDD /* OrgstarSpotlight/PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = OrgstarSpotlight/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
180 D27AFAB2F0523C96E1F9CC93 /* OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements; sourceTree = "<group>"; };
181 7B319D00B61E5D44B6F8660B /* OrgstarQuickLook/PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = OrgstarQuickLook/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
182 6857BB16511F98A95242D558 /* OrgstarWidgets/OrgstarWidgets-macOS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarWidgets/OrgstarWidgets-macOS.entitlements; sourceTree = "<group>"; };
183 83EDEDFCE07E278A9F985A17 /* OrgstarWidgets/PrivacyInfo.xcprivacy */ = {isa = PBXFileReference; lastKnownFileType = text.xml; path = OrgstarWidgets/PrivacyInfo.xcprivacy; sourceTree = "<group>"; };
123184/* End PBXFileReference section */
124185
125186/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
@@ -137,6 +198,13 @@
137198 );
138199 target = 92364A1473ECC9B162FEAE51 /* OrgstarShare */;
139200 };
201 4B121E9E27D011F773E768FF /* Exceptions for "../Sources/OrgstarSpotlight" folder in "OrgstarSpotlight" target */ = {
202 isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
203 membershipExceptions = (
204 main.swift,
205 );
206 target = 983BBE813E871966964F6876 /* OrgstarSpotlight */;
207 };
140208/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
141209
142210/* Begin PBXFileSystemSynchronizedRootGroup section */
@@ -176,6 +244,19 @@
176244 path = ../Sources/OrgstarWatchWidgets;
177245 sourceTree = "<group>";
178246 };
247 5492CCAC81DA9B3B7C8E53D9 /* ../Sources/Orgstar */ = {
248 isa = PBXFileSystemSynchronizedRootGroup;
249 path = ../Sources/Orgstar;
250 sourceTree = "<group>";
251 };
252 DCA0D699899E2CA4B0F5956F /* ../Sources/OrgstarSpotlight */ = {
253 isa = PBXFileSystemSynchronizedRootGroup;
254 exceptions = (
255 4B121E9E27D011F773E768FF /* Exceptions for "../Sources/OrgstarSpotlight" folder in "OrgstarSpotlight" target */,
256 );
257 path = ../Sources/OrgstarSpotlight;
258 sourceTree = "<group>";
259 };
179260/* End PBXFileSystemSynchronizedRootGroup section */
180261
181262/* Begin PBXFrameworksBuildPhase section */
@@ -228,6 +309,24 @@
228309 );
229310 runOnlyForDeploymentPostprocessing = 0;
230311 };
312 39CC8FCF3B50EC810191AF52 /* Frameworks */ = {
313 isa = PBXFrameworksBuildPhase;
314 buildActionMask = 2147483647;
315 files = (
316 34F40D483630871B50619E6F /* OrgApp in Frameworks */,
317 4392873ADA2B1FC8930BE6C9 /* OrgEditorAppKit in Frameworks */,
318 CA594F2E6DAFED2D16900872 /* OrgHighlight in Frameworks */,
319 );
320 runOnlyForDeploymentPostprocessing = 0;
321 };
322 E2B8E1256CB480BB98CECFCA /* Frameworks */ = {
323 isa = PBXFrameworksBuildPhase;
324 buildActionMask = 2147483647;
325 files = (
326 C4B7AD977A87099C72B5E114 /* OrgCore in Frameworks */,
327 );
328 runOnlyForDeploymentPostprocessing = 0;
329 };
231330/* End PBXFrameworksBuildPhase section */
232331
233332/* Begin PBXGroup section */
@@ -240,6 +339,8 @@
240339 B54C32C5D364C02EE21DB092 /* OrgstarWidgets.appex */,
241340 8A7A8B14798B54AA57D91D55 /* OrgstarWatch.app */,
242341 03F7E491D72C8915E6CB2542 /* OrgstarWatchWidgets.appex */,
342 C51149D0B6EA8A5C84383462 /* orgstar.app */,
343 AC88ABFF2E0DEC4AD6935E44 /* OrgstarSpotlight.appex */,
243344 );
244345 name = Products;
245346 sourceTree = "<group>";
@@ -250,6 +351,8 @@
250351 6425CB8F177EDFF8EE2BD447 /* ../Sources/OrgstarShare */,
251352 2412EC8ED6427B76498FCD18 /* ../Sources/OrgstarQuickLook */,
252353 7E85FA5E5BA11D0F6891693E /* ../Sources/OrgstarMobile */,
354 5492CCAC81DA9B3B7C8E53D9 /* ../Sources/Orgstar */,
355 DCA0D699899E2CA4B0F5956F /* ../Sources/OrgstarSpotlight */,
253356 DE99BDA1BB90EEDFA8FF4CC2 /* ../Sources/OrgstarWidgets */,
254357 0D702B6721D2BC88F89E3883 /* ../Sources/OrgstarWatch */,
255358 C2450FF4F75DA4598ABE47D6 /* ../Sources/OrgstarWatchWidgets */,
@@ -275,6 +378,18 @@
275378 970E22E052046C63CA01A88F /* OrgstarWatch/OrgstarWatch.entitlements */,
276379 512F8C0EB67DE2C4AB5051D4 /* OrgstarWatchWidgets/Info.plist */,
277380 F75B5AA8EBA6F457B6D124AC /* OrgstarWatchWidgets/OrgstarWatchWidgets.entitlements */,
381 5CAA663B7191AA35B15DE681 /* OrgstarMac/Info.plist */,
382 465A4F530E1EB892DCA2659D /* OrgstarMac/Orgstar.entitlements */,
383 AD93BA820CE0A7E09BB5CB1C /* OrgstarMac/PrivacyInfo.xcprivacy */,
384 B977A6852EA92ABDAA7C98AA /* AppIcons.xcassets */,
385 9B39CA5A070717D948728096 /* IconPreviews */,
386 D27AFAB2F0523C96E1F9CC93 /* OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements */,
387 7B319D00B61E5D44B6F8660B /* OrgstarQuickLook/PrivacyInfo.xcprivacy */,
388 6857BB16511F98A95242D558 /* OrgstarWidgets/OrgstarWidgets-macOS.entitlements */,
389 83EDEDFCE07E278A9F985A17 /* OrgstarWidgets/PrivacyInfo.xcprivacy */,
390 7B28B0DBC8FEDCBB28FF11E9 /* OrgstarSpotlight/Info.plist */,
391 108CFDFF570EDFC4035D4DF7 /* OrgstarSpotlight/OrgstarSpotlight.entitlements */,
392 20B42E017B9B06BDBBF0CCDD /* OrgstarSpotlight/PrivacyInfo.xcprivacy */,
278393 );
279394 name = Support;
280395 sourceTree = "<group>";
@@ -434,6 +549,59 @@
434549 productReference = 03F7E491D72C8915E6CB2542 /* OrgstarWatchWidgets.appex */;
435550 productType = "com.apple.product-type.app-extension";
436551 };
552 B4840CC47B21EF2ECB49A2B1 /* Orgstar macOS */ = {
553 isa = PBXNativeTarget;
554 buildConfigurationList = F9E8A973377C36C09C37D74B /* Build configuration list for PBXNativeTarget "Orgstar macOS" */;
555 buildPhases = (
556 8FB5AC5ACF7BCCCB4CB0CA6A /* Compile string catalog */,
557 0EFD7F2537761E968D3FE030 /* Sources */,
558 39CC8FCF3B50EC810191AF52 /* Frameworks */,
559 EDF6CA650FB1A0A57A682074 /* Resources */,
560 50EAF92A2ABF4715F69C1B26 /* Embed Foundation Extensions */,
561 );
562 buildRules = (
563 );
564 dependencies = (
565 C826A938ED8C4860D583408F /* PBXTargetDependency */,
566 12D858EB45921C42A853582E /* PBXTargetDependency */,
567 B8558921DD478BF0929CD181 /* PBXTargetDependency */,
568 );
569 fileSystemSynchronizedGroups = (
570 5492CCAC81DA9B3B7C8E53D9 /* ../Sources/Orgstar */,
571 );
572 name = "Orgstar macOS";
573 packageProductDependencies = (
574 B1EC171400CB989363332D07 /* OrgApp */,
575 0E5F6DB1CD783274FB49FD5E /* OrgEditorAppKit */,
576 88F9A423F8C1EBE523B6438B /* OrgHighlight */,
577 );
578 productName = Orgstar;
579 productReference = C51149D0B6EA8A5C84383462 /* orgstar.app */;
580 productType = "com.apple.product-type.application";
581 };
582 983BBE813E871966964F6876 /* OrgstarSpotlight */ = {
583 isa = PBXNativeTarget;
584 buildConfigurationList = 7B19660ED1008ECEF3FBC821 /* Build configuration list for PBXNativeTarget "OrgstarSpotlight" */;
585 buildPhases = (
586 84D0DC560E0227549E1F5F7E /* Sources */,
587 E2B8E1256CB480BB98CECFCA /* Frameworks */,
588 E0CA3F1B80A8855DAA3B427A /* Resources */,
589 );
590 buildRules = (
591 );
592 dependencies = (
593 );
594 fileSystemSynchronizedGroups = (
595 DCA0D699899E2CA4B0F5956F /* ../Sources/OrgstarSpotlight */,
596 );
597 name = OrgstarSpotlight;
598 packageProductDependencies = (
599 43689CAB6915EAB97D264A39 /* OrgCore */,
600 );
601 productName = OrgstarSpotlight;
602 productReference = AC88ABFF2E0DEC4AD6935E44 /* OrgstarSpotlight.appex */;
603 productType = "com.apple.product-type.app-extension";
604 };
437605/* End PBXNativeTarget section */
438606
439607/* Begin PBXProject section */
@@ -472,6 +640,8 @@
472640 E87BE20AFDC99FD25E1A163F /* OrgstarWidgets */,
473641 9571051E69F5D60E9CDFD246 /* OrgstarWatch */,
474642 A7FEE6F7EC27BB417D26E08E /* OrgstarWatchWidgets */,
643 B4840CC47B21EF2ECB49A2B1 /* Orgstar macOS */,
644 983BBE813E871966964F6876 /* OrgstarSpotlight */,
475645 );
476646 };
477647/* End PBXProject section */
@@ -496,6 +666,7 @@
496666 isa = PBXResourcesBuildPhase;
497667 buildActionMask = 2147483647;
498668 files = (
669 9B607A4A9227D06D4F53091C /* OrgstarQuickLook/PrivacyInfo.xcprivacy in Resources */,
499670 );
500671 runOnlyForDeploymentPostprocessing = 0;
501672 };
@@ -503,6 +674,7 @@
503674 isa = PBXResourcesBuildPhase;
504675 buildActionMask = 2147483647;
505676 files = (
677 3AA1AFEEC1E57E8A3A1AF804 /* OrgstarWidgets/PrivacyInfo.xcprivacy in Resources */,
506678 );
507679 runOnlyForDeploymentPostprocessing = 0;
508680 };
@@ -521,6 +693,24 @@
521693 );
522694 runOnlyForDeploymentPostprocessing = 0;
523695 };
696 EDF6CA650FB1A0A57A682074 /* Resources */ = {
697 isa = PBXResourcesBuildPhase;
698 buildActionMask = 2147483647;
699 files = (
700 D94278A370A1FB41D7A518DA /* AppIcons.xcassets in Resources */,
701 8626AEED3928BE739C1DF301 /* IconPreviews in Resources */,
702 BA4DCBEF0B0F66E84D66137B /* OrgstarMac/PrivacyInfo.xcprivacy in Resources */,
703 );
704 runOnlyForDeploymentPostprocessing = 0;
705 };
706 E0CA3F1B80A8855DAA3B427A /* Resources */ = {
707 isa = PBXResourcesBuildPhase;
708 buildActionMask = 2147483647;
709 files = (
710 B59088D6FF3E6C60DF909823 /* OrgstarSpotlight/PrivacyInfo.xcprivacy in Resources */,
711 );
712 runOnlyForDeploymentPostprocessing = 0;
713 };
524714/* End PBXResourcesBuildPhase section */
525715
526716/* Begin PBXShellScriptBuildPhase section */
@@ -679,6 +869,37 @@
679869 shellPath = /bin/sh;
680870 shellScript = "# The catalog is compiled here rather than as a resource, so that Xcode doesn't sync it\n# from this target's sources; scripts/sync-strings.sh keeps it.\nxcrun xcstringstool compile \"$SCRIPT_INPUT_FILE_0\" --output-directory \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\"\n";
681871 };
872 8FB5AC5ACF7BCCCB4CB0CA6A /* Compile string catalog */ = {
873 isa = PBXShellScriptBuildPhase;
874 buildActionMask = 2147483647;
875 files = (
876 );
877 inputFileListPaths = (
878 );
879 inputPaths = (
880 "$(SRCROOT)/../l10n/Localizable.xcstrings",
881 );
882 name = "Compile string catalog";
883 outputFileListPaths = (
884 );
885 outputPaths = (
886 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/en.lproj/Localizable.strings",
887 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/en.lproj/Localizable.stringsdict",
888 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/de.lproj/Localizable.strings",
889 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/de.lproj/Localizable.stringsdict",
890 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/fr.lproj/Localizable.strings",
891 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/fr.lproj/Localizable.stringsdict",
892 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/ja.lproj/Localizable.strings",
893 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/ja.lproj/Localizable.stringsdict",
894 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/es.lproj/Localizable.strings",
895 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/es.lproj/Localizable.stringsdict",
896 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/pt-BR.lproj/Localizable.strings",
897 "$(TARGET_BUILD_DIR)/$(UNLOCALIZED_RESOURCES_FOLDER_PATH)/pt-BR.lproj/Localizable.stringsdict",
898 );
899 runOnlyForDeploymentPostprocessing = 0;
900 shellPath = /bin/sh;
901 shellScript = "# The catalog is compiled here rather than as a resource, so that Xcode doesn't sync it\n# from this target's sources; scripts/sync-strings.sh keeps it.\nxcrun xcstringstool compile \"$SCRIPT_INPUT_FILE_0\" --output-directory \"$TARGET_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH\"\n";
902 };
682903/* End PBXShellScriptBuildPhase section */
683904
684905/* Begin PBXSourcesBuildPhase section */
@@ -724,6 +945,20 @@
724945 );
725946 runOnlyForDeploymentPostprocessing = 0;
726947 };
948 0EFD7F2537761E968D3FE030 /* Sources */ = {
949 isa = PBXSourcesBuildPhase;
950 buildActionMask = 2147483647;
951 files = (
952 );
953 runOnlyForDeploymentPostprocessing = 0;
954 };
955 84D0DC560E0227549E1F5F7E /* Sources */ = {
956 isa = PBXSourcesBuildPhase;
957 buildActionMask = 2147483647;
958 files = (
959 );
960 runOnlyForDeploymentPostprocessing = 0;
961 };
727962/* End PBXSourcesBuildPhase section */
728963
729964/* Begin PBXTargetDependency section */
@@ -752,12 +987,28 @@
752987 target = 9571051E69F5D60E9CDFD246 /* OrgstarWatch */;
753988 targetProxy = 3CD251D01E4C9C2DC6EA4271 /* PBXContainerItemProxy */;
754989 };
990 C826A938ED8C4860D583408F /* PBXTargetDependency */ = {
991 isa = PBXTargetDependency;
992 target = BBA37636EB6BBA564493899D /* OrgstarQuickLook */;
993 targetProxy = 77FCBFF918E6E58AE9698F1B /* PBXContainerItemProxy */;
994 };
995 B8558921DD478BF0929CD181 /* PBXTargetDependency */ = {
996 isa = PBXTargetDependency;
997 target = E87BE20AFDC99FD25E1A163F /* OrgstarWidgets */;
998 targetProxy = A211EBFC69B345042D422426 /* PBXContainerItemProxy */;
999 };
1000 12D858EB45921C42A853582E /* PBXTargetDependency */ = {
1001 isa = PBXTargetDependency;
1002 target = 983BBE813E871966964F6876 /* OrgstarSpotlight */;
1003 targetProxy = 7C6ACD0E0D599F98671D5D8D /* PBXContainerItemProxy */;
1004 };
7551005/* End PBXTargetDependency section */
7561006
7571007/* Begin XCBuildConfiguration section */
7581008 0BF40655E429259B35B06BEC /* Release */ = {
7591009 isa = XCBuildConfiguration;
7601010 buildSettings = {
1011 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements;
7611012 CODE_SIGN_STYLE = Automatic;
7621013 CURRENT_PROJECT_VERSION = 17;
7631014 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -768,10 +1019,20 @@
7681019 "@executable_path/Frameworks",
7691020 "@executable_path/../../Frameworks",
7701021 );
1022 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1023 "$(inherited)",
1024 "@executable_path/../Frameworks",
1025 "@executable_path/../../../../Frameworks",
1026 );
1027 MACOSX_DEPLOYMENT_TARGET = 26.0;
7711028 MARKETING_VERSION = 1.1.0;
7721029 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.quicklook;
7731030 PRODUCT_NAME = "$(TARGET_NAME)";
1031 SDKROOT = auto;
7741032 SKIP_INSTALL = YES;
1033 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1034 SUPPORTS_MACCATALYST = NO;
1035 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
7751036 TARGETED_DEVICE_FAMILY = "1,2";
7761037 };
7771038 name = Release;
@@ -849,6 +1110,7 @@
8491110 isa = XCBuildConfiguration;
8501111 buildSettings = {
8511112 CODE_SIGN_ENTITLEMENTS = OrgstarWidgets/OrgstarWidgets.entitlements;
1113 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarWidgets/OrgstarWidgets-macOS.entitlements;
8521114 CODE_SIGN_STYLE = Automatic;
8531115 CURRENT_PROJECT_VERSION = 17;
8541116 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -860,10 +1122,20 @@
8601122 "@executable_path/Frameworks",
8611123 "@executable_path/../../Frameworks",
8621124 );
1125 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1126 "$(inherited)",
1127 "@executable_path/../Frameworks",
1128 "@executable_path/../../../../Frameworks",
1129 );
1130 MACOSX_DEPLOYMENT_TARGET = 26.0;
8631131 MARKETING_VERSION = 1.1.0;
8641132 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.widgets;
8651133 PRODUCT_NAME = "$(TARGET_NAME)";
1134 SDKROOT = auto;
8661135 SKIP_INSTALL = YES;
1136 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1137 SUPPORTS_MACCATALYST = NO;
1138 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
8671139 TARGETED_DEVICE_FAMILY = "1,2";
8681140 };
8691141 name = Debug;
@@ -871,6 +1143,7 @@
8711143 942C95A5D90B164020736D83 /* Debug */ = {
8721144 isa = XCBuildConfiguration;
8731145 buildSettings = {
1146 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements;
8741147 CODE_SIGN_STYLE = Automatic;
8751148 CURRENT_PROJECT_VERSION = 17;
8761149 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -881,10 +1154,20 @@
8811154 "@executable_path/Frameworks",
8821155 "@executable_path/../../Frameworks",
8831156 );
1157 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1158 "$(inherited)",
1159 "@executable_path/../Frameworks",
1160 "@executable_path/../../../../Frameworks",
1161 );
1162 MACOSX_DEPLOYMENT_TARGET = 26.0;
8841163 MARKETING_VERSION = 1.1.0;
8851164 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.quicklook;
8861165 PRODUCT_NAME = "$(TARGET_NAME)";
1166 SDKROOT = auto;
8871167 SKIP_INSTALL = YES;
1168 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1169 SUPPORTS_MACCATALYST = NO;
1170 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
8881171 TARGETED_DEVICE_FAMILY = "1,2";
8891172 };
8901173 name = Debug;
@@ -935,6 +1218,7 @@
9351218 isa = XCBuildConfiguration;
9361219 buildSettings = {
9371220 CODE_SIGN_ENTITLEMENTS = OrgstarWidgets/OrgstarWidgets.entitlements;
1221 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarWidgets/OrgstarWidgets-macOS.entitlements;
9381222 CODE_SIGN_STYLE = Automatic;
9391223 CURRENT_PROJECT_VERSION = 17;
9401224 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -946,10 +1230,20 @@
9461230 "@executable_path/Frameworks",
9471231 "@executable_path/../../Frameworks",
9481232 );
1233 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1234 "$(inherited)",
1235 "@executable_path/../Frameworks",
1236 "@executable_path/../../../../Frameworks",
1237 );
1238 MACOSX_DEPLOYMENT_TARGET = 26.0;
9491239 MARKETING_VERSION = 1.1.0;
9501240 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.widgets;
9511241 PRODUCT_NAME = "$(TARGET_NAME)";
1242 SDKROOT = auto;
9521243 SKIP_INSTALL = YES;
1244 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1245 SUPPORTS_MACCATALYST = NO;
1246 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
9531247 TARGETED_DEVICE_FAMILY = "1,2";
9541248 };
9551249 name = Release;
@@ -1074,6 +1368,108 @@
10741368 };
10751369 name = Release;
10761370 };
1371 054B9495D84C3E79F2234534 /* Debug */ = {
1372 isa = XCBuildConfiguration;
1373 buildSettings = {
1374 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
1375 CODE_SIGN_ENTITLEMENTS = OrgstarMac/Orgstar.entitlements;
1376 CODE_SIGN_STYLE = Automatic;
1377 COMBINE_HIDPI_IMAGES = YES;
1378 CURRENT_PROJECT_VERSION = 17;
1379 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1380 GENERATE_INFOPLIST_FILE = NO;
1381 INFOPLIST_FILE = OrgstarMac/Info.plist;
1382 LD_RUNPATH_SEARCH_PATHS = (
1383 "$(inherited)",
1384 "@executable_path/../Frameworks",
1385 );
1386 MACOSX_DEPLOYMENT_TARGET = 26.0;
1387 MARKETING_VERSION = 1.1.0;
1388 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar;
1389 PRODUCT_MODULE_NAME = Orgstar;
1390 PRODUCT_NAME = orgstar;
1391 SDKROOT = macosx;
1392 SUPPORTED_PLATFORMS = macosx;
1393 SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) APPSTORE";
1394 };
1395 name = Debug;
1396 };
1397 FEBB323890D181DA410264E9 /* Release */ = {
1398 isa = XCBuildConfiguration;
1399 buildSettings = {
1400 ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
1401 CODE_SIGN_ENTITLEMENTS = OrgstarMac/Orgstar.entitlements;
1402 CODE_SIGN_STYLE = Automatic;
1403 COMBINE_HIDPI_IMAGES = YES;
1404 CURRENT_PROJECT_VERSION = 17;
1405 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1406 GENERATE_INFOPLIST_FILE = NO;
1407 INFOPLIST_FILE = OrgstarMac/Info.plist;
1408 LD_RUNPATH_SEARCH_PATHS = (
1409 "$(inherited)",
1410 "@executable_path/../Frameworks",
1411 );
1412 MACOSX_DEPLOYMENT_TARGET = 26.0;
1413 MARKETING_VERSION = 1.1.0;
1414 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar;
1415 PRODUCT_MODULE_NAME = Orgstar;
1416 PRODUCT_NAME = orgstar;
1417 SDKROOT = macosx;
1418 SUPPORTED_PLATFORMS = macosx;
1419 SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) APPSTORE";
1420 };
1421 name = Release;
1422 };
1423 68F53E07FC366481771DDDB1 /* Debug */ = {
1424 isa = XCBuildConfiguration;
1425 buildSettings = {
1426 CODE_SIGN_ENTITLEMENTS = OrgstarSpotlight/OrgstarSpotlight.entitlements;
1427 CODE_SIGN_STYLE = Automatic;
1428 CURRENT_PROJECT_VERSION = 17;
1429 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1430 GENERATE_INFOPLIST_FILE = NO;
1431 INFOPLIST_FILE = OrgstarSpotlight/Info.plist;
1432 LD_RUNPATH_SEARCH_PATHS = (
1433 "$(inherited)",
1434 "@executable_path/../Frameworks",
1435 "@executable_path/../../../../Frameworks",
1436 );
1437 MACOSX_DEPLOYMENT_TARGET = 26.0;
1438 MARKETING_VERSION = 1.1.0;
1439 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.spotlight;
1440 PRODUCT_NAME = "$(TARGET_NAME)";
1441 SDKROOT = macosx;
1442 SKIP_INSTALL = YES;
1443 SUPPORTED_PLATFORMS = macosx;
1444 SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) APPSTORE";
1445 };
1446 name = Debug;
1447 };
1448 7F0C08C96E27C66039571111 /* Release */ = {
1449 isa = XCBuildConfiguration;
1450 buildSettings = {
1451 CODE_SIGN_ENTITLEMENTS = OrgstarSpotlight/OrgstarSpotlight.entitlements;
1452 CODE_SIGN_STYLE = Automatic;
1453 CURRENT_PROJECT_VERSION = 17;
1454 DEVELOPMENT_TEAM = ZCNAX3VL9D;
1455 GENERATE_INFOPLIST_FILE = NO;
1456 INFOPLIST_FILE = OrgstarSpotlight/Info.plist;
1457 LD_RUNPATH_SEARCH_PATHS = (
1458 "$(inherited)",
1459 "@executable_path/../Frameworks",
1460 "@executable_path/../../../../Frameworks",
1461 );
1462 MACOSX_DEPLOYMENT_TARGET = 26.0;
1463 MARKETING_VERSION = 1.1.0;
1464 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.spotlight;
1465 PRODUCT_NAME = "$(TARGET_NAME)";
1466 SDKROOT = macosx;
1467 SKIP_INSTALL = YES;
1468 SUPPORTED_PLATFORMS = macosx;
1469 SWIFT_ACTIVE_COMPILATION_CONDITIONS = "$(inherited) APPSTORE";
1470 };
1471 name = Release;
1472 };
10771473/* End XCBuildConfiguration section */
10781474
10791475/* Begin XCConfigurationList section */
@@ -1140,6 +1536,24 @@
11401536 defaultConfigurationIsVisible = 0;
11411537 defaultConfigurationName = Release;
11421538 };
1539 F9E8A973377C36C09C37D74B /* Build configuration list for PBXNativeTarget "Orgstar macOS" */ = {
1540 isa = XCConfigurationList;
1541 buildConfigurations = (
1542 054B9495D84C3E79F2234534 /* Debug */,
1543 FEBB323890D181DA410264E9 /* Release */,
1544 );
1545 defaultConfigurationIsVisible = 0;
1546 defaultConfigurationName = Release;
1547 };
1548 7B19660ED1008ECEF3FBC821 /* Build configuration list for PBXNativeTarget "OrgstarSpotlight" */ = {
1549 isa = XCConfigurationList;
1550 buildConfigurations = (
1551 68F53E07FC366481771DDDB1 /* Debug */,
1552 7F0C08C96E27C66039571111 /* Release */,
1553 );
1554 defaultConfigurationIsVisible = 0;
1555 defaultConfigurationName = Release;
1556 };
11431557/* End XCConfigurationList section */
11441558
11451559/* Begin XCLocalSwiftPackageReference section */
@@ -1185,6 +1599,26 @@
11851599 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
11861600 productName = OrgWatchData;
11871601 };
1602 B1EC171400CB989363332D07 /* OrgApp */ = {
1603 isa = XCSwiftPackageProductDependency;
1604 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1605 productName = OrgApp;
1606 };
1607 0E5F6DB1CD783274FB49FD5E /* OrgEditorAppKit */ = {
1608 isa = XCSwiftPackageProductDependency;
1609 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1610 productName = OrgEditorAppKit;
1611 };
1612 88F9A423F8C1EBE523B6438B /* OrgHighlight */ = {
1613 isa = XCSwiftPackageProductDependency;
1614 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1615 productName = OrgHighlight;
1616 };
1617 43689CAB6915EAB97D264A39 /* OrgCore */ = {
1618 isa = XCSwiftPackageProductDependency;
1619 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1620 productName = OrgCore;
1621 };
11881622/* End XCSwiftPackageProductDependency section */
11891623 };
11901624 rootObject = 46F86FAA6BBF9AC94A7E4595 /* Project object */;
ios/Orgstar.xcodeproj/xcshareddata/xcschemes/Orgstar macOS.xcscheme added +88
@@ -0,0 +1,88 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<Scheme
3 LastUpgradeVersion = "2700"
4 version = "1.3">
5 <BuildAction
6 parallelizeBuildables = "YES"
7 buildImplicitDependencies = "YES">
8 <BuildActionEntries>
9 <BuildActionEntry
10 buildForTesting = "YES"
11 buildForRunning = "YES"
12 buildForProfiling = "YES"
13 buildForArchiving = "YES"
14 buildForAnalyzing = "YES">
15 <BuildableReference
16 BuildableIdentifier = "primary"
17 BlueprintIdentifier = "B4840CC47B21EF2ECB49A2B1"
18 BuildableName = "orgstar.app"
19 BlueprintName = "Orgstar macOS"
20 ReferencedContainer = "container:Orgstar.xcodeproj">
21 </BuildableReference>
22 </BuildActionEntry>
23 </BuildActionEntries>
24 </BuildAction>
25 <TestAction
26 buildConfiguration = "Debug"
27 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
28 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
29 shouldUseLaunchSchemeArgsEnv = "YES">
30 <Testables>
31 </Testables>
32 </TestAction>
33 <LaunchAction
34 buildConfiguration = "Release"
35 selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
36 selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
37 launchStyle = "0"
38 useCustomWorkingDirectory = "NO"
39 ignoresPersistentStateOnLaunch = "NO"
40 debugDocumentVersioning = "YES"
41 debugServiceExtension = "internal"
42 allowLocationSimulation = "YES">
43 <BuildableProductRunnable
44 runnableDebuggingMode = "0">
45 <BuildableReference
46 BuildableIdentifier = "primary"
47 BlueprintIdentifier = "B4840CC47B21EF2ECB49A2B1"
48 BuildableName = "orgstar.app"
49 BlueprintName = "Orgstar macOS"
50 ReferencedContainer = "container:Orgstar.xcodeproj">
51 </BuildableReference>
52 </BuildableProductRunnable>
53 <EnvironmentVariables>
54 <EnvironmentVariable
55 key = "ORGSTAR_PERF"
56 value = "1"
57 isEnabled = "YES">
58 </EnvironmentVariable>
59 </EnvironmentVariables>
60 <StoreKitConfigurationFileReference
61 identifier = "../../Orgstar.storekit">
62 </StoreKitConfigurationFileReference>
63 </LaunchAction>
64 <ProfileAction
65 buildConfiguration = "Release"
66 shouldUseLaunchSchemeArgsEnv = "YES"
67 savedToolIdentifier = ""
68 useCustomWorkingDirectory = "NO"
69 debugDocumentVersioning = "YES">
70 <BuildableProductRunnable
71 runnableDebuggingMode = "0">
72 <BuildableReference
73 BuildableIdentifier = "primary"
74 BlueprintIdentifier = "B4840CC47B21EF2ECB49A2B1"
75 BuildableName = "orgstar.app"
76 BlueprintName = "Orgstar macOS"
77 ReferencedContainer = "container:Orgstar.xcodeproj">
78 </BuildableReference>
79 </BuildableProductRunnable>
80 </ProfileAction>
81 <AnalyzeAction
82 buildConfiguration = "Debug">
83 </AnalyzeAction>
84 <ArchiveAction
85 buildConfiguration = "Release"
86 revealArchiveInOrganizer = "YES">
87 </ArchiveAction>
88</Scheme>
ios/Orgstar/Info.plist +2
@@ -46,6 +46,8 @@
4646 </array>
4747 <key>CFBundleVersion</key>
4848 <string>$(CURRENT_PROJECT_VERSION)</string>
49 <key>ITSAppUsesNonExemptEncryption</key>
50 <false/>
4951 <key>LSApplicationCategoryType</key>
5052 <string>public.app-category.productivity</string>
5153 <key>NSCalendarsFullAccessUsageDescription</key>
ios/OrgstarMac/Info.plist added +107
@@ -0,0 +1,107 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>CFBundleDevelopmentRegion</key>
6 <string>en</string>
7 <key>CFBundleDisplayName</key>
8 <string>orgstar</string>
9 <key>CFBundleDocumentTypes</key>
10 <array>
11 <dict>
12 <key>CFBundleTypeName</key>
13 <string>Org document</string>
14 <key>CFBundleTypeRole</key>
15 <string>Editor</string>
16 <key>LSHandlerRank</key>
17 <string>Default</string>
18 <key>LSItemContentTypes</key>
19 <array>
20 <string>org.orgmode.org</string>
21 </array>
22 </dict>
23 <dict>
24 <key>CFBundleTypeName</key>
25 <string>Text</string>
26 <key>CFBundleTypeRole</key>
27 <string>Editor</string>
28 <key>LSHandlerRank</key>
29 <string>Alternate</string>
30 <key>LSItemContentTypes</key>
31 <array>
32 <string>public.plain-text</string>
33 </array>
34 </dict>
35 </array>
36 <key>CFBundleExecutable</key>
37 <string>$(EXECUTABLE_NAME)</string>
38 <key>CFBundleIconName</key>
39 <string>AppIcon</string>
40 <key>CFBundleIdentifier</key>
41 <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
42 <key>CFBundleLocalizations</key>
43 <array>
44 <string>en</string>
45 <string>de</string>
46 <string>fr</string>
47 <string>ja</string>
48 <string>es</string>
49 <string>pt-BR</string>
50 </array>
51 <key>CFBundleName</key>
52 <string>orgstar</string>
53 <key>CFBundlePackageType</key>
54 <string>APPL</string>
55 <key>CFBundleShortVersionString</key>
56 <string>$(MARKETING_VERSION)</string>
57 <key>CFBundleURLTypes</key>
58 <array>
59 <dict>
60 <key>CFBundleURLName</key>
61 <string>org-protocol</string>
62 <key>CFBundleURLSchemes</key>
63 <array>
64 <string>org-protocol</string>
65 <string>orgstar</string>
66 </array>
67 </dict>
68 </array>
69 <key>CFBundleVersion</key>
70 <string>$(CURRENT_PROJECT_VERSION)</string>
71 <key>ITSAppUsesNonExemptEncryption</key>
72 <false/>
73 <key>LSApplicationCategoryType</key>
74 <string>public.app-category.productivity</string>
75 <key>LSMinimumSystemVersion</key>
76 <string>$(MACOSX_DEPLOYMENT_TARGET)</string>
77 <key>NSCalendarsFullAccessUsageDescription</key>
78 <string>The agenda shows your calendar events alongside your Org entries. orgstar changes your calendars only when you edit an event or add an entry to one.</string>
79 <key>NSHighResolutionCapable</key>
80 <true/>
81 <key>NSPrincipalClass</key>
82 <string>NSApplication</string>
83 <key>NSRemindersFullAccessUsageDescription</key>
84 <string>The agenda shows your reminders alongside your Org entries. orgstar only reads them.</string>
85 <key>UTImportedTypeDeclarations</key>
86 <array>
87 <dict>
88 <key>UTTypeConformsTo</key>
89 <array>
90 <string>public.plain-text</string>
91 </array>
92 <key>UTTypeDescription</key>
93 <string>Org document</string>
94 <key>UTTypeIdentifier</key>
95 <string>org.orgmode.org</string>
96 <key>UTTypeTagSpecification</key>
97 <dict>
98 <key>public.filename-extension</key>
99 <array>
100 <string>org</string>
101 <string>org_archive</string>
102 </array>
103 </dict>
104 </dict>
105 </array>
106</dict>
107</plist>
ios/OrgstarMac/Orgstar.entitlements added +24
@@ -0,0 +1,24 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>com.apple.security.app-sandbox</key>
6 <true/>
7 <key>com.apple.security.application-groups</key>
8 <array>
9 <string>group.sh.krz.orgstar</string>
10 </array>
11 <key>com.apple.security.files.bookmarks.app-scope</key>
12 <true/>
13 <key>com.apple.security.files.user-selected.executable</key>
14 <true/>
15 <key>com.apple.security.files.user-selected.read-write</key>
16 <true/>
17 <key>com.apple.security.network.client</key>
18 <true/>
19 <key>com.apple.security.personal-information.calendars</key>
20 <true/>
21 <key>com.apple.security.print</key>
22 <true/>
23</dict>
24</plist>
ios/OrgstarMac/PrivacyInfo.xcprivacy added +37
@@ -0,0 +1,37 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>NSPrivacyTracking</key>
6 <false/>
7 <key>NSPrivacyTrackingDomains</key>
8 <array/>
9 <key>NSPrivacyCollectedDataTypes</key>
10 <array/>
11 <key>NSPrivacyAccessedAPITypes</key>
12 <array>
13 <dict>
14 <key>NSPrivacyAccessedAPIType</key>
15 <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
16 <key>NSPrivacyAccessedAPITypeReasons</key>
17 <array>
18 <!-- Settings the app keeps for itself. -->
19 <string>CA92.1</string>
20 <!-- The app group suite it shares with the widgets (pro.grant). -->
21 <string>1C8F.1</string>
22 </array>
23 </dict>
24 <dict>
25 <key>NSPrivacyAccessedAPIType</key>
26 <string>NSPrivacyAccessedAPICategoryFileTimestamp</string>
27 <key>NSPrivacyAccessedAPITypeReasons</key>
28 <array>
29 <!-- Dates of files in the folders and documents the user opened. -->
30 <string>3B52.1</string>
31 <!-- Dates of files in the app's container and app group. -->
32 <string>C617.1</string>
33 </array>
34 </dict>
35 </array>
36</dict>
37</plist>
ios/OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements added +8
@@ -0,0 +1,8 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>com.apple.security.app-sandbox</key>
6 <true/>
7</dict>
8</plist>
ios/OrgstarQuickLook/PrivacyInfo.xcprivacy added +14
@@ -0,0 +1,14 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>NSPrivacyTracking</key>
6 <false/>
7 <key>NSPrivacyTrackingDomains</key>
8 <array/>
9 <key>NSPrivacyCollectedDataTypes</key>
10 <array/>
11 <key>NSPrivacyAccessedAPITypes</key>
12 <array/>
13</dict>
14</plist>
ios/OrgstarSpotlight/Info.plist added +31
@@ -0,0 +1,31 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>CFBundleDevelopmentRegion</key>
6 <string>en</string>
7 <key>CFBundleIdentifier</key>
8 <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
9 <key>CFBundleName</key>
10 <string>$(PRODUCT_NAME)</string>
11 <key>CFBundleDisplayName</key>
12 <string>orgstar</string>
13 <key>CFBundleExecutable</key>
14 <string>$(EXECUTABLE_NAME)</string>
15 <key>CFBundlePackageType</key>
16 <string>XPC!</string>
17 <key>CFBundleShortVersionString</key>
18 <string>$(MARKETING_VERSION)</string>
19 <key>CFBundleVersion</key>
20 <string>$(CURRENT_PROJECT_VERSION)</string>
21 <key>NSExtension</key>
22 <dict>
23 <key>NSExtensionPointIdentifier</key>
24 <string>com.apple.spotlight.import</string>
25 <key>NSExtensionPrincipalClass</key>
26 <string>ImportExtension</string>
27 <key>NSExtensionAttributes</key>
28 <dict><key>CSSupportedContentTypes</key><array><string>org.orgmode.org</string></array></dict>
29 </dict>
30</dict>
31</plist>
ios/OrgstarSpotlight/OrgstarSpotlight.entitlements added +8
@@ -0,0 +1,8 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>com.apple.security.app-sandbox</key>
6 <true/>
7</dict>
8</plist>
ios/OrgstarSpotlight/PrivacyInfo.xcprivacy added +14
@@ -0,0 +1,14 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>NSPrivacyTracking</key>
6 <false/>
7 <key>NSPrivacyTrackingDomains</key>
8 <array/>
9 <key>NSPrivacyCollectedDataTypes</key>
10 <array/>
11 <key>NSPrivacyAccessedAPITypes</key>
12 <array/>
13</dict>
14</plist>
ios/OrgstarWidgets/OrgstarWidgets-macOS.entitlements added +12
@@ -0,0 +1,12 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>com.apple.security.app-sandbox</key>
6 <true/>
7 <key>com.apple.security.application-groups</key>
8 <array>
9 <string>group.sh.krz.orgstar</string>
10 </array>
11</dict>
12</plist>
ios/OrgstarWidgets/PrivacyInfo.xcprivacy added +24
@@ -0,0 +1,24 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3<plist version="1.0">
4<dict>
5 <key>NSPrivacyTracking</key>
6 <false/>
7 <key>NSPrivacyTrackingDomains</key>
8 <array/>
9 <key>NSPrivacyCollectedDataTypes</key>
10 <array/>
11 <key>NSPrivacyAccessedAPITypes</key>
12 <array>
13 <dict>
14 <key>NSPrivacyAccessedAPIType</key>
15 <string>NSPrivacyAccessedAPICategoryUserDefaults</string>
16 <key>NSPrivacyAccessedAPITypeReasons</key>
17 <array>
18 <!-- The app group suite the app writes (pro.grant). -->
19 <string>1C8F.1</string>
20 </array>
21 </dict>
22 </array>
23</dict>
24</plist>
l10n/DeveloperID.xcstrings added +414
@@ -0,0 +1,414 @@
1{
2 "sourceLanguage": "en",
3 "strings": {
4 "Activate": {
5 "localizations": {
6 "de": {
7 "stringUnit": {
8 "state": "translated",
9 "value": "Aktivieren"
10 }
11 },
12 "es": {
13 "stringUnit": {
14 "state": "translated",
15 "value": "Activar"
16 }
17 },
18 "fr": {
19 "stringUnit": {
20 "state": "translated",
21 "value": "Activer"
22 }
23 },
24 "ja": {
25 "stringUnit": {
26 "state": "translated",
27 "value": "アクティベート"
28 }
29 },
30 "pt-BR": {
31 "stringUnit": {
32 "state": "translated",
33 "value": "Ativar"
34 }
35 }
36 }
37 },
38 "Check for Updates…": {
39 "localizations": {
40 "de": {
41 "stringUnit": {
42 "state": "translated",
43 "value": "Nach Updates suchen …"
44 }
45 },
46 "es": {
47 "stringUnit": {
48 "state": "translated",
49 "value": "Buscar actualizaciones…"
50 }
51 },
52 "fr": {
53 "stringUnit": {
54 "state": "translated",
55 "value": "Rechercher les mises à jour…"
56 }
57 },
58 "ja": {
59 "stringUnit": {
60 "state": "translated",
61 "value": "アップデートを確認…"
62 }
63 },
64 "pt-BR": {
65 "stringUnit": {
66 "state": "translated",
67 "value": "Buscar Atualizações…"
68 }
69 }
70 }
71 },
72 "Check for updates automatically": {
73 "localizations": {
74 "de": {
75 "stringUnit": {
76 "state": "translated",
77 "value": "Automatisch nach Updates suchen"
78 }
79 },
80 "es": {
81 "stringUnit": {
82 "state": "translated",
83 "value": "Buscar actualizaciones automáticamente"
84 }
85 },
86 "fr": {
87 "stringUnit": {
88 "state": "translated",
89 "value": "Rechercher automatiquement les mises à jour"
90 }
91 },
92 "ja": {
93 "stringUnit": {
94 "state": "translated",
95 "value": "アップデートを自動的に確認"
96 }
97 },
98 "pt-BR": {
99 "stringUnit": {
100 "state": "translated",
101 "value": "Buscar atualizações automaticamente"
102 }
103 }
104 }
105 },
106 "Get Your Key…": {
107 "localizations": {
108 "de": {
109 "stringUnit": {
110 "state": "translated",
111 "value": "Schlüssel abrufen …"
112 }
113 },
114 "es": {
115 "stringUnit": {
116 "state": "translated",
117 "value": "Obtener tu clave…"
118 }
119 },
120 "fr": {
121 "stringUnit": {
122 "state": "translated",
123 "value": "Obtenir votre clé…"
124 }
125 },
126 "ja": {
127 "stringUnit": {
128 "state": "translated",
129 "value": "キーを取得…"
130 }
131 },
132 "pt-BR": {
133 "stringUnit": {
134 "state": "translated",
135 "value": "Obter sua chave…"
136 }
137 }
138 }
139 },
140 "License key": {
141 "localizations": {
142 "de": {
143 "stringUnit": {
144 "state": "translated",
145 "value": "Lizenzschlüssel"
146 }
147 },
148 "es": {
149 "stringUnit": {
150 "state": "translated",
151 "value": "Clave de licencia"
152 }
153 },
154 "fr": {
155 "stringUnit": {
156 "state": "translated",
157 "value": "Clé de licence"
158 }
159 },
160 "ja": {
161 "stringUnit": {
162 "state": "translated",
163 "value": "ライセンスキー"
164 }
165 },
166 "pt-BR": {
167 "stringUnit": {
168 "state": "translated",
169 "value": "Chave de licença"
170 }
171 }
172 }
173 },
174 "ORGSTAR1-…": {
175 "localizations": {
176 "de": {
177 "stringUnit": {
178 "state": "translated",
179 "value": "ORGSTAR1-…"
180 }
181 },
182 "es": {
183 "stringUnit": {
184 "state": "translated",
185 "value": "ORGSTAR1-…"
186 }
187 },
188 "fr": {
189 "stringUnit": {
190 "state": "translated",
191 "value": "ORGSTAR1-…"
192 }
193 },
194 "ja": {
195 "stringUnit": {
196 "state": "translated",
197 "value": "ORGSTAR1-…"
198 }
199 },
200 "pt-BR": {
201 "stringUnit": {
202 "state": "translated",
203 "value": "ORGSTAR1-…"
204 }
205 }
206 }
207 },
208 "Once a day, from the app's own feed. orgstar ▸ Check for Updates… checks now.": {
209 "localizations": {
210 "de": {
211 "stringUnit": {
212 "state": "translated",
213 "value": "Einmal täglich, aus dem Feed der App. orgstar ▸ Nach Updates suchen … prüft sofort."
214 }
215 },
216 "es": {
217 "stringUnit": {
218 "state": "translated",
219 "value": "Una vez al día, desde el canal de la propia app. orgstar ▸ Buscar actualizaciones… lo comprueba ahora."
220 }
221 },
222 "fr": {
223 "stringUnit": {
224 "state": "translated",
225 "value": "Une fois par jour, depuis le flux de l'app. orgstar ▸ Rechercher les mises à jour… vérifie immédiatement."
226 }
227 },
228 "ja": {
229 "stringUnit": {
230 "state": "translated",
231 "value": "1日1回、App独自のフィードから確認します。orgstar ▸ アップデートを確認…ですぐに確認できます。"
232 }
233 },
234 "pt-BR": {
235 "stringUnit": {
236 "state": "translated",
237 "value": "Uma vez por dia, a partir do feed do próprio app. orgstar ▸ Buscar Atualizações… verifica agora."
238 }
239 }
240 }
241 },
242 "Remove License from This Mac": {
243 "localizations": {
244 "de": {
245 "stringUnit": {
246 "state": "translated",
247 "value": "Lizenz von diesem Mac entfernen"
248 }
249 },
250 "es": {
251 "stringUnit": {
252 "state": "translated",
253 "value": "Quitar la licencia de este Mac"
254 }
255 },
256 "fr": {
257 "stringUnit": {
258 "state": "translated",
259 "value": "Retirer la licence de ce Mac"
260 }
261 },
262 "ja": {
263 "stringUnit": {
264 "state": "translated",
265 "value": "このMacからライセンスを削除"
266 }
267 },
268 "pt-BR": {
269 "stringUnit": {
270 "state": "translated",
271 "value": "Remover Licença Deste Mac"
272 }
273 }
274 }
275 },
276 "Renews while you sponsor monthly. This key is valid until %@.": {
277 "localizations": {
278 "de": {
279 "stringUnit": {
280 "state": "translated",
281 "value": "Wird verlängert, solange du monatlich sponserst. Dieser Schlüssel gilt bis %@."
282 }
283 },
284 "es": {
285 "stringUnit": {
286 "state": "translated",
287 "value": "Se renueva mientras patrocines cada mes. Esta clave es válida hasta el %@."
288 }
289 },
290 "fr": {
291 "stringUnit": {
292 "state": "translated",
293 "value": "Renouvelée tant que vous sponsorisez chaque mois. Cette clé est valable jusqu'au %@."
294 }
295 },
296 "ja": {
297 "stringUnit": {
298 "state": "translated",
299 "value": "毎月スポンサーを続けている間は更新されます。このキーは%@まで有効です。"
300 }
301 },
302 "pt-BR": {
303 "stringUnit": {
304 "state": "translated",
305 "value": "É renovada enquanto você patrocina mensalmente. Esta chave é válida até %@."
306 }
307 }
308 }
309 },
310 "Sponsor for orgstar+…": {
311 "localizations": {
312 "de": {
313 "stringUnit": {
314 "state": "translated",
315 "value": "Für orgstar+ sponsern …"
316 }
317 },
318 "es": {
319 "stringUnit": {
320 "state": "translated",
321 "value": "Patrocinar para orgstar+…"
322 }
323 },
324 "fr": {
325 "stringUnit": {
326 "state": "translated",
327 "value": "Sponsoriser pour orgstar+…"
328 }
329 },
330 "ja": {
331 "stringUnit": {
332 "state": "translated",
333 "value": "スポンサーになってorgstar+を利用…"
334 }
335 },
336 "pt-BR": {
337 "stringUnit": {
338 "state": "translated",
339 "value": "Patrocinar para o orgstar+…"
340 }
341 }
342 }
343 },
344 "Sponsors get their key by signing in with GitHub. It is checked on this Mac; a monthly sponsor's key is renewed with krz.sh.": {
345 "localizations": {
346 "de": {
347 "stringUnit": {
348 "state": "translated",
349 "value": "Sponsoren erhalten ihren Schlüssel, indem sie sich mit GitHub anmelden. Er wird auf diesem Mac geprüft; der Schlüssel monatlicher Sponsoren wird über krz.sh verlängert."
350 }
351 },
352 "es": {
353 "stringUnit": {
354 "state": "translated",
355 "value": "Los patrocinadores obtienen su clave iniciando sesión con GitHub. Se comprueba en este Mac; la clave de un patrocinador mensual se renueva con krz.sh."
356 }
357 },
358 "fr": {
359 "stringUnit": {
360 "state": "translated",
361 "value": "Les sponsors obtiennent leur clé en se connectant avec GitHub. Elle est vérifiée sur ce Mac ; la clé d'un sponsor mensuel est renouvelée auprès de krz.sh."
362 }
363 },
364 "ja": {
365 "stringUnit": {
366 "state": "translated",
367 "value": "スポンサーはGitHubでサインインしてキーを取得します。キーはこのMac上で確認されます。月額スポンサーのキーはkrz.shで更新されます。"
368 }
369 },
370 "pt-BR": {
371 "stringUnit": {
372 "state": "translated",
373 "value": "Os patrocinadores obtêm a chave entrando com o GitHub. Ela é verificada neste Mac; a chave de um patrocinador mensal é renovada com o krz.sh."
374 }
375 }
376 }
377 },
378 "orgstar+ for Mac comes with sponsoring orgstar on GitHub: $60 once, or $5 a month. Editing, the agenda, capture, clocking and search stay free.": {
379 "localizations": {
380 "de": {
381 "stringUnit": {
382 "state": "translated",
383 "value": "orgstar+ für Mac gibt es, wenn du orgstar auf GitHub sponserst: einmalig $60 oder $5 im Monat. Bearbeiten, Agenda, Erfassen, Zeiterfassung und Suche bleiben kostenlos."
384 }
385 },
386 "es": {
387 "stringUnit": {
388 "state": "translated",
389 "value": "orgstar+ para Mac se incluye al patrocinar orgstar en GitHub: $60 una vez o $5 al mes. La edición, la agenda, la captura, el registro de tiempo y la búsqueda siguen siendo gratuitos."
390 }
391 },
392 "fr": {
393 "stringUnit": {
394 "state": "translated",
395 "value": "orgstar+ pour Mac est inclus quand vous sponsorisez orgstar sur GitHub : $60 une fois, ou $5 par mois. L'édition, l'agenda, la capture, le chronométrage et la recherche restent gratuits."
396 }
397 },
398 "ja": {
399 "stringUnit": {
400 "state": "translated",
401 "value": "Mac版orgstar+は、GitHubでorgstarのスポンサーになると利用できます(1回$60、または月額$5)。編集、アジェンダ、キャプチャ、クロック、検索は引き続き無料です。"
402 }
403 },
404 "pt-BR": {
405 "stringUnit": {
406 "state": "translated",
407 "value": "O orgstar+ para Mac vem com o patrocínio do orgstar no GitHub: $60 uma vez ou $5 por mês. A edição, a agenda, a captura, o registro de tempo e a busca continuam gratuitos."
408 }
409 }
410 }
411 }
412 },
413 "version": "1.1"
414}
l10n/Localizable.xcstrings +1228 −383
@@ -86,6 +86,74 @@
8686 }
8787 }
8888 },
89 "%@ / month": {
90 "localizations": {
91 "de": {
92 "stringUnit": {
93 "state": "translated",
94 "value": "%@ / Monat"
95 }
96 },
97 "es": {
98 "stringUnit": {
99 "state": "translated",
100 "value": "%@ / mes"
101 }
102 },
103 "fr": {
104 "stringUnit": {
105 "state": "translated",
106 "value": "%@ / mois"
107 }
108 },
109 "ja": {
110 "stringUnit": {
111 "state": "translated",
112 "value": "%@ / 月"
113 }
114 },
115 "pt-BR": {
116 "stringUnit": {
117 "state": "translated",
118 "value": "%@ / mês"
119 }
120 }
121 }
122 },
123 "%@ / year": {
124 "localizations": {
125 "de": {
126 "stringUnit": {
127 "state": "translated",
128 "value": "%@ / Jahr"
129 }
130 },
131 "es": {
132 "stringUnit": {
133 "state": "translated",
134 "value": "%@ / año"
135 }
136 },
137 "fr": {
138 "stringUnit": {
139 "state": "translated",
140 "value": "%@ / an"
141 }
142 },
143 "ja": {
144 "stringUnit": {
145 "state": "translated",
146 "value": "%@ / 年"
147 }
148 },
149 "pt-BR": {
150 "stringUnit": {
151 "state": "translated",
152 "value": "%@ / ano"
153 }
154 }
155 }
156 },
89157 "%@ a month, billed yearly": {
90158 "localizations": {
91159 "de": {
@@ -189,6 +257,47 @@
189257 }
190258 }
191259 },
260 "%@ doesn't contain %@.": {
261 "comment": "Alert when the folder chosen to grant access doesn't contain the one needed",
262 "localizations": {
263 "de": {
264 "stringUnit": {
265 "state": "translated",
266 "value": "%1$@ enthält %2$@ nicht."
267 }
268 },
269 "en": {
270 "stringUnit": {
271 "state": "new",
272 "value": "%1$@ doesn't contain %2$@."
273 }
274 },
275 "es": {
276 "stringUnit": {
277 "state": "translated",
278 "value": "%1$@ no contiene %2$@."
279 }
280 },
281 "fr": {
282 "stringUnit": {
283 "state": "translated",
284 "value": "%1$@ ne contient pas %2$@."
285 }
286 },
287 "ja": {
288 "stringUnit": {
289 "state": "translated",
290 "value": "%1$@には%2$@が含まれていません。"
291 }
292 },
293 "pt-BR": {
294 "stringUnit": {
295 "state": "translated",
296 "value": "%1$@ não contém %2$@."
297 }
298 }
299 }
300 },
192301 "%@ isn't available on iPhone and iPad.": {
193302 "comment": "A command that runs only on the Mac",
194303 "localizations": {
@@ -224,6 +333,76 @@
224333 }
225334 }
226335 },
336 "%@ isn't available.": {
337 "comment": "A command the Mac App Store build leaves out",
338 "localizations": {
339 "de": {
340 "stringUnit": {
341 "state": "translated",
342 "value": "%@ ist nicht verfügbar."
343 }
344 },
345 "es": {
346 "stringUnit": {
347 "state": "translated",
348 "value": "%@ no está disponible."
349 }
350 },
351 "fr": {
352 "stringUnit": {
353 "state": "translated",
354 "value": "%@ n'est pas disponible."
355 }
356 },
357 "ja": {
358 "stringUnit": {
359 "state": "translated",
360 "value": "%@は利用できません。"
361 }
362 },
363 "pt-BR": {
364 "stringUnit": {
365 "state": "translated",
366 "value": "%@ não está disponível."
367 }
368 }
369 }
370 },
371 "%@ isn't in one of your folders, so it can't be moved. Attach a copy instead.": {
372 "comment": "Attach by moving a file from outside the sidebar's folders",
373 "localizations": {
374 "de": {
375 "stringUnit": {
376 "state": "translated",
377 "value": "%@ liegt in keinem deiner Ordner und kann daher nicht bewegt werden. Hänge stattdessen eine Kopie an."
378 }
379 },
380 "es": {
381 "stringUnit": {
382 "state": "translated",
383 "value": "%@ no está en ninguna de tus carpetas, así que no se puede mover. Adjunta una copia en su lugar."
384 }
385 },
386 "fr": {
387 "stringUnit": {
388 "state": "translated",
389 "value": "%@ ne se trouve dans aucun de vos dossiers et ne peut donc pas être déplacé. Joignez plutôt une copie."
390 }
391 },
392 "ja": {
393 "stringUnit": {
394 "state": "translated",
395 "value": "%@はどのフォルダにもないため、移動できません。代わりにコピーを添付してください。"
396 }
397 },
398 "pt-BR": {
399 "stringUnit": {
400 "state": "translated",
401 "value": "%@ não está em nenhuma das suas pastas, então não pode ser movido. Anexe uma cópia em vez disso."
402 }
403 }
404 }
405 },
227406 "%@ late": {
228407 "localizations": {
229408 "de": {
@@ -1658,140 +1837,141 @@
16581837 }
16591838 }
16601839 },
1661 "Act at Point": {
1662 "comment": "Command title",
1840 "Access lasts until orgstar quits.": {
1841 "comment": "Alert when a folder grant or the configuration folder can't be saved",
16631842 "localizations": {
16641843 "de": {
16651844 "stringUnit": {
16661845 "state": "translated",
1667 "value": "An der Einfügemarke ausführen"
1846 "value": "Der Zugriff gilt, bis orgstar beendet wird."
16681847 }
16691848 },
16701849 "es": {
16711850 "stringUnit": {
16721851 "state": "translated",
1673 "value": "Actuar en el punto"
1852 "value": "El acceso dura hasta que se cierre orgstar."
16741853 }
16751854 },
16761855 "fr": {
16771856 "stringUnit": {
16781857 "state": "translated",
1679 "value": "Agir au point"
1858 "value": "L'accès dure jusqu'à ce que vous quittiez orgstar."
16801859 }
16811860 },
16821861 "ja": {
16831862 "stringUnit": {
16841863 "state": "translated",
1685 "value": "ポイントで実行"
1864 "value": "アクセスはorgstarを終了するまで有効です。"
16861865 }
16871866 },
16881867 "pt-BR": {
16891868 "stringUnit": {
16901869 "state": "translated",
1691 "value": "Agir no Cursor"
1870 "value": "O acesso dura até o orgstar ser encerrado."
16921871 }
16931872 }
16941873 }
16951874 },
1696 "Act at Point (C-c C-c)": {
1875 "Act at Point": {
16971876 "comment": "Command title",
16981877 "localizations": {
16991878 "de": {
17001879 "stringUnit": {
17011880 "state": "translated",
1702 "value": "An der Einfügemarke ausführen (C-c C-c)"
1881 "value": "An der Einfügemarke ausführen"
17031882 }
17041883 },
17051884 "es": {
17061885 "stringUnit": {
17071886 "state": "translated",
1708 "value": "Actuar en el punto (C-c C-c)"
1887 "value": "Actuar en el punto"
17091888 }
17101889 },
17111890 "fr": {
17121891 "stringUnit": {
17131892 "state": "translated",
1714 "value": "Agir au point (C-c C-c)"
1893 "value": "Agir au point"
17151894 }
17161895 },
17171896 "ja": {
17181897 "stringUnit": {
17191898 "state": "translated",
1720 "value": "ポイントで実行(C-c C-c)"
1899 "value": "ポイントで実行"
17211900 }
17221901 },
17231902 "pt-BR": {
17241903 "stringUnit": {
17251904 "state": "translated",
1726 "value": "Agir no Cursor (C-c C-c)"
1905 "value": "Agir no Cursor"
17271906 }
17281907 }
17291908 }
17301909 },
1731 "Actions": {
1910 "Act at Point (C-c C-c)": {
1911 "comment": "Command title",
17321912 "localizations": {
17331913 "de": {
17341914 "stringUnit": {
17351915 "state": "translated",
1736 "value": "Aktionen"
1916 "value": "An der Einfügemarke ausführen (C-c C-c)"
17371917 }
17381918 },
17391919 "es": {
17401920 "stringUnit": {
17411921 "state": "translated",
1742 "value": "Acciones"
1922 "value": "Actuar en el punto (C-c C-c)"
17431923 }
17441924 },
17451925 "fr": {
17461926 "stringUnit": {
17471927 "state": "translated",
1748 "value": "Actions"
1928 "value": "Agir au point (C-c C-c)"
17491929 }
17501930 },
17511931 "ja": {
17521932 "stringUnit": {
17531933 "state": "translated",
1754 "value": "アクション"
1934 "value": "ポイントで実行(C-c C-c)"
17551935 }
17561936 },
17571937 "pt-BR": {
17581938 "stringUnit": {
17591939 "state": "translated",
1760 "value": "Ações"
1940 "value": "Agir no Cursor (C-c C-c)"
17611941 }
17621942 }
17631943 }
17641944 },
1765 "Activate": {
1945 "Actions": {
17661946 "localizations": {
17671947 "de": {
17681948 "stringUnit": {
17691949 "state": "translated",
1770 "value": "Aktivieren"
1950 "value": "Aktionen"
17711951 }
17721952 },
17731953 "es": {
17741954 "stringUnit": {
17751955 "state": "translated",
1776 "value": "Activar"
1956 "value": "Acciones"
17771957 }
17781958 },
17791959 "fr": {
17801960 "stringUnit": {
17811961 "state": "translated",
1782 "value": "Activer"
1962 "value": "Actions"
17831963 }
17841964 },
17851965 "ja": {
17861966 "stringUnit": {
17871967 "state": "translated",
1788 "value": "アクティベート"
1968 "value": "アクション"
17891969 }
17901970 },
17911971 "pt-BR": {
17921972 "stringUnit": {
17931973 "state": "translated",
1794 "value": "Ativar"
1974 "value": "Ações"
17951975 }
17961976 }
17971977 }
@@ -4569,6 +4749,76 @@
45694749 }
45704750 }
45714751 },
4752 "Can't Open": {
4753 "comment": "Sidebar section for folders orgstar can't open",
4754 "localizations": {
4755 "de": {
4756 "stringUnit": {
4757 "state": "translated",
4758 "value": "Kann nicht geöffnet werden"
4759 }
4760 },
4761 "es": {
4762 "stringUnit": {
4763 "state": "translated",
4764 "value": "No se pueden abrir"
4765 }
4766 },
4767 "fr": {
4768 "stringUnit": {
4769 "state": "translated",
4770 "value": "Impossible d'ouvrir"
4771 }
4772 },
4773 "ja": {
4774 "stringUnit": {
4775 "state": "translated",
4776 "value": "開けません"
4777 }
4778 },
4779 "pt-BR": {
4780 "stringUnit": {
4781 "state": "translated",
4782 "value": "Não É Possível Abrir"
4783 }
4784 }
4785 }
4786 },
4787 "Can't include %@.": {
4788 "comment": "Export stopped by an #+INCLUDE file that can't be read",
4789 "localizations": {
4790 "de": {
4791 "stringUnit": {
4792 "state": "translated",
4793 "value": "%@ kann nicht eingebunden werden."
4794 }
4795 },
4796 "es": {
4797 "stringUnit": {
4798 "state": "translated",
4799 "value": "No se puede incluir %@."
4800 }
4801 },
4802 "fr": {
4803 "stringUnit": {
4804 "state": "translated",
4805 "value": "Impossible d'inclure %@."
4806 }
4807 },
4808 "ja": {
4809 "stringUnit": {
4810 "state": "translated",
4811 "value": "%@ を取り込めません。"
4812 }
4813 },
4814 "pt-BR": {
4815 "stringUnit": {
4816 "state": "translated",
4817 "value": "Não é possível incluir %@."
4818 }
4819 }
4820 }
4821 },
45724822 "Can't open the entry": {
45734823 "localizations": {
45744824 "de": {
@@ -5257,74 +5507,6 @@
52575507 }
52585508 }
52595509 },
5260 "Check for Updates…": {
5261 "localizations": {
5262 "de": {
5263 "stringUnit": {
5264 "state": "translated",
5265 "value": "Nach Updates suchen …"
5266 }
5267 },
5268 "es": {
5269 "stringUnit": {
5270 "state": "translated",
5271 "value": "Buscar actualizaciones…"
5272 }
5273 },
5274 "fr": {
5275 "stringUnit": {
5276 "state": "translated",
5277 "value": "Rechercher les mises à jour…"
5278 }
5279 },
5280 "ja": {
5281 "stringUnit": {
5282 "state": "translated",
5283 "value": "アップデートを確認…"
5284 }
5285 },
5286 "pt-BR": {
5287 "stringUnit": {
5288 "state": "translated",
5289 "value": "Buscar Atualizações…"
5290 }
5291 }
5292 }
5293 },
5294 "Check for updates automatically": {
5295 "localizations": {
5296 "de": {
5297 "stringUnit": {
5298 "state": "translated",
5299 "value": "Automatisch nach Updates suchen"
5300 }
5301 },
5302 "es": {
5303 "stringUnit": {
5304 "state": "translated",
5305 "value": "Buscar actualizaciones automáticamente"
5306 }
5307 },
5308 "fr": {
5309 "stringUnit": {
5310 "state": "translated",
5311 "value": "Rechercher automatiquement les mises à jour"
5312 }
5313 },
5314 "ja": {
5315 "stringUnit": {
5316 "state": "translated",
5317 "value": "アップデートを自動的に確認"
5318 }
5319 },
5320 "pt-BR": {
5321 "stringUnit": {
5322 "state": "translated",
5323 "value": "Buscar atualizações automaticamente"
5324 }
5325 }
5326 }
5327 },
53285510 "Check spelling while typing (spell-check)": {
53295511 "localizations": {
53305512 "de": {
@@ -5393,6 +5575,145 @@
53935575 }
53945576 }
53955577 },
5578 "Choose": {
5579 "localizations": {
5580 "de": {
5581 "stringUnit": {
5582 "state": "translated",
5583 "value": "Wählen"
5584 }
5585 },
5586 "es": {
5587 "stringUnit": {
5588 "state": "translated",
5589 "value": "Elegir"
5590 }
5591 },
5592 "fr": {
5593 "stringUnit": {
5594 "state": "translated",
5595 "value": "Choisir"
5596 }
5597 },
5598 "ja": {
5599 "stringUnit": {
5600 "state": "translated",
5601 "value": "選択"
5602 }
5603 },
5604 "pt-BR": {
5605 "stringUnit": {
5606 "state": "translated",
5607 "value": "Escolher"
5608 }
5609 }
5610 }
5611 },
5612 "Choose %@ or a folder that contains it.": {
5613 "comment": "Open panel for giving orgstar access to a folder",
5614 "localizations": {
5615 "de": {
5616 "stringUnit": {
5617 "state": "translated",
5618 "value": "Wähle %@ oder einen Ordner, der ihn enthält."
5619 }
5620 },
5621 "es": {
5622 "stringUnit": {
5623 "state": "translated",
5624 "value": "Elige %@ o una carpeta que la contenga."
5625 }
5626 },
5627 "fr": {
5628 "stringUnit": {
5629 "state": "translated",
5630 "value": "Choisissez %@ ou un dossier qui le contient."
5631 }
5632 },
5633 "ja": {
5634 "stringUnit": {
5635 "state": "translated",
5636 "value": "%@ またはそれを含むフォルダを選択してください。"
5637 }
5638 },
5639 "pt-BR": {
5640 "stringUnit": {
5641 "state": "translated",
5642 "value": "Escolha %@ ou uma pasta que a contenha."
5643 }
5644 }
5645 }
5646 },
5647 "Choose %@ to add it to the sidebar.": {
5648 "comment": "Open panel for a folder imported from Emacs",
5649 "localizations": {
5650 "de": {
5651 "stringUnit": {
5652 "state": "translated",
5653 "value": "Wähle %@, um ihn zur Seitenleiste hinzuzufügen."
5654 }
5655 },
5656 "es": {
5657 "stringUnit": {
5658 "state": "translated",
5659 "value": "Elige %@ para añadirla a la barra lateral."
5660 }
5661 },
5662 "fr": {
5663 "stringUnit": {
5664 "state": "translated",
5665 "value": "Choisissez %@ pour l'ajouter à la barre latérale."
5666 }
5667 },
5668 "ja": {
5669 "stringUnit": {
5670 "state": "translated",
5671 "value": "%@ を選択してサイドバーに追加してください。"
5672 }
5673 },
5674 "pt-BR": {
5675 "stringUnit": {
5676 "state": "translated",
5677 "value": "Escolha %@ para adicioná-la à barra lateral."
5678 }
5679 }
5680 }
5681 },
5682 "Choose %@ to give orgstar access to it again.": {
5683 "comment": "Open panel for a sidebar folder orgstar can't open",
5684 "localizations": {
5685 "de": {
5686 "stringUnit": {
5687 "state": "translated",
5688 "value": "Wähle %@, um orgstar wieder Zugriff darauf zu geben."
5689 }
5690 },
5691 "es": {
5692 "stringUnit": {
5693 "state": "translated",
5694 "value": "Elige %@ para volver a dar acceso a orgstar."
5695 }
5696 },
5697 "fr": {
5698 "stringUnit": {
5699 "state": "translated",
5700 "value": "Choisissez %@ pour redonner l'accès à orgstar."
5701 }
5702 },
5703 "ja": {
5704 "stringUnit": {
5705 "state": "translated",
5706 "value": "%@ を選択して、orgstarに再度アクセスを許可してください。"
5707 }
5708 },
5709 "pt-BR": {
5710 "stringUnit": {
5711 "state": "translated",
5712 "value": "Escolha %@ para dar acesso ao orgstar novamente."
5713 }
5714 }
5715 }
5716 },
53965717 "Choose Another Folder…": {
53975718 "localizations": {
53985719 "de": {
@@ -5427,6 +5748,74 @@
54275748 }
54285749 }
54295750 },
5751 "Choose Configuration Folder…": {
5752 "localizations": {
5753 "de": {
5754 "stringUnit": {
5755 "state": "translated",
5756 "value": "Konfigurationsordner wählen …"
5757 }
5758 },
5759 "es": {
5760 "stringUnit": {
5761 "state": "translated",
5762 "value": "Elegir carpeta de configuración…"
5763 }
5764 },
5765 "fr": {
5766 "stringUnit": {
5767 "state": "translated",
5768 "value": "Choisir le dossier de configuration…"
5769 }
5770 },
5771 "ja": {
5772 "stringUnit": {
5773 "state": "translated",
5774 "value": "構成フォルダを選択…"
5775 }
5776 },
5777 "pt-BR": {
5778 "stringUnit": {
5779 "state": "translated",
5780 "value": "Escolher Pasta de Configuração…"
5781 }
5782 }
5783 }
5784 },
5785 "Choose Doom Folder…": {
5786 "localizations": {
5787 "de": {
5788 "stringUnit": {
5789 "state": "translated",
5790 "value": "Doom-Ordner wählen …"
5791 }
5792 },
5793 "es": {
5794 "stringUnit": {
5795 "state": "translated",
5796 "value": "Elegir carpeta de Doom…"
5797 }
5798 },
5799 "fr": {
5800 "stringUnit": {
5801 "state": "translated",
5802 "value": "Choisir le dossier de Doom…"
5803 }
5804 },
5805 "ja": {
5806 "stringUnit": {
5807 "state": "translated",
5808 "value": "Doomフォルダを選択…"
5809 }
5810 },
5811 "pt-BR": {
5812 "stringUnit": {
5813 "state": "translated",
5814 "value": "Escolher Pasta do Doom…"
5815 }
5816 }
5817 }
5818 },
54305819 "Choose Folder": {
54315820 "localizations": {
54325821 "de": {
@@ -5597,7 +5986,113 @@
55975986 }
55985987 }
55995988 },
5989 "Choose or make the folder for your notes in iCloud Drive.": {
5990 "comment": "Open panel on the welcome sheet",
5991 "localizations": {
5992 "de": {
5993 "stringUnit": {
5994 "state": "translated",
5995 "value": "Wähle oder erstelle in iCloud Drive den Ordner für deine Notizen."
5996 }
5997 },
5998 "es": {
5999 "stringUnit": {
6000 "state": "translated",
6001 "value": "Elige o crea en iCloud Drive la carpeta para tus notas."
6002 }
6003 },
6004 "fr": {
6005 "stringUnit": {
6006 "state": "translated",
6007 "value": "Choisissez ou créez dans iCloud Drive le dossier de vos notes."
6008 }
6009 },
6010 "ja": {
6011 "stringUnit": {
6012 "state": "translated",
6013 "value": "iCloud Driveでメモ用のフォルダを選択または作成してください。"
6014 }
6015 },
6016 "pt-BR": {
6017 "stringUnit": {
6018 "state": "translated",
6019 "value": "Escolha ou crie no iCloud Drive a pasta para suas notas."
6020 }
6021 }
6022 }
6023 },
6024 "Choose the folder Doom is installed in (~/.config/emacs or ~/.emacs.d) to read Doom's own org defaults.": {
6025 "comment": "Open panel for Doom's install folder when importing from Emacs",
6026 "localizations": {
6027 "de": {
6028 "stringUnit": {
6029 "state": "translated",
6030 "value": "Wähle den Ordner, in dem Doom installiert ist (~/.config/emacs oder ~/.emacs.d), um Dooms eigene Org-Voreinstellungen zu lesen."
6031 }
6032 },
6033 "es": {
6034 "stringUnit": {
6035 "state": "translated",
6036 "value": "Elige la carpeta donde está instalado Doom (~/.config/emacs o ~/.emacs.d) para leer los valores predeterminados de org de Doom."
6037 }
6038 },
6039 "fr": {
6040 "stringUnit": {
6041 "state": "translated",
6042 "value": "Choisissez le dossier où Doom est installé (~/.config/emacs ou ~/.emacs.d) pour lire les réglages org par défaut de Doom."
6043 }
6044 },
6045 "ja": {
6046 "stringUnit": {
6047 "state": "translated",
6048 "value": "Doomのorg既定値を読み込むには、Doomがインストールされているフォルダ(~/.config/emacs または ~/.emacs.d)を選択してください。"
6049 }
6050 },
6051 "pt-BR": {
6052 "stringUnit": {
6053 "state": "translated",
6054 "value": "Escolha a pasta onde o Doom está instalado (~/.config/emacs ou ~/.emacs.d) para ler os padrões de org do próprio Doom."
6055 }
6056 }
6057 }
6058 },
6059 "Choose the folder for config.toml and orgstar's other configuration files.": {
6060 "comment": "Choose Configuration Folder panel",
6061 "localizations": {
6062 "de": {
6063 "stringUnit": {
6064 "state": "translated",
6065 "value": "Wähle den Ordner für config.toml und die anderen Konfigurationsdateien von orgstar."
6066 }
6067 },
6068 "es": {
6069 "stringUnit": {
6070 "state": "translated",
6071 "value": "Elige la carpeta para config.toml y los demás archivos de configuración de orgstar."
6072 }
6073 },
6074 "fr": {
6075 "stringUnit": {
6076 "state": "translated",
6077 "value": "Choisissez le dossier de config.toml et des autres fichiers de configuration d'orgstar."
6078 }
6079 },
6080 "ja": {
6081 "stringUnit": {
6082 "state": "translated",
6083 "value": "config.toml と orgstar のほかの構成ファイルを置くフォルダを選択してください。"
6084 }
6085 },
6086 "pt-BR": {
6087 "stringUnit": {
6088 "state": "translated",
6089 "value": "Escolha a pasta para o config.toml e os outros arquivos de configuração do orgstar."
6090 }
6091 }
6092 }
6093 },
56006094 "Choose your init.el, or the folder holding it (~/.emacs.d, ~/.config/doom).": {
6095 "comment": "Open panel for importing an Emacs configuration",
56016096 "localizations": {
56026097 "de": {
56036098 "stringUnit": {
@@ -9328,6 +9823,40 @@
93289823 }
93299824 }
93309825 },
9826 "Doom's own org defaults are read from the folder Doom is installed in": {
9827 "localizations": {
9828 "de": {
9829 "stringUnit": {
9830 "state": "translated",
9831 "value": "Dooms eigene Org-Voreinstellungen werden aus dem Ordner gelesen, in dem Doom installiert ist"
9832 }
9833 },
9834 "es": {
9835 "stringUnit": {
9836 "state": "translated",
9837 "value": "Los valores predeterminados de org de Doom se leen de la carpeta donde está instalado Doom"
9838 }
9839 },
9840 "fr": {
9841 "stringUnit": {
9842 "state": "translated",
9843 "value": "Les réglages org par défaut de Doom sont lus dans le dossier où Doom est installé"
9844 }
9845 },
9846 "ja": {
9847 "stringUnit": {
9848 "state": "translated",
9849 "value": "Doomのorg既定値は、Doomがインストールされているフォルダから読み込まれます"
9850 }
9851 },
9852 "pt-BR": {
9853 "stringUnit": {
9854 "state": "translated",
9855 "value": "Os padrões de org do próprio Doom são lidos da pasta onde o Doom está instalado"
9856 }
9857 }
9858 }
9859 },
93319860 "Downloading from iCloud": {
93329861 "localizations": {
93339862 "de": {
@@ -12635,40 +13164,6 @@
1263513164 }
1263613165 }
1263713166 },
12638 "Get Your Key…": {
12639 "localizations": {
12640 "de": {
12641 "stringUnit": {
12642 "state": "translated",
12643 "value": "Schlüssel abrufen …"
12644 }
12645 },
12646 "es": {
12647 "stringUnit": {
12648 "state": "translated",
12649 "value": "Obtener tu clave…"
12650 }
12651 },
12652 "fr": {
12653 "stringUnit": {
12654 "state": "translated",
12655 "value": "Obtenir votre clé…"
12656 }
12657 },
12658 "ja": {
12659 "stringUnit": {
12660 "state": "translated",
12661 "value": "キーを取得…"
12662 }
12663 },
12664 "pt-BR": {
12665 "stringUnit": {
12666 "state": "translated",
12667 "value": "Obter sua chave…"
12668 }
12669 }
12670 }
12671 },
1267213167 "Git branch": {
1267313168 "localizations": {
1267413169 "de": {
@@ -13085,6 +13580,76 @@
1308513580 }
1308613581 }
1308713582 },
13583 "Grant Access": {
13584 "comment": "Open panel button that gives orgstar access to a folder",
13585 "localizations": {
13586 "de": {
13587 "stringUnit": {
13588 "state": "translated",
13589 "value": "Zugriff erlauben"
13590 }
13591 },
13592 "es": {
13593 "stringUnit": {
13594 "state": "translated",
13595 "value": "Conceder acceso"
13596 }
13597 },
13598 "fr": {
13599 "stringUnit": {
13600 "state": "translated",
13601 "value": "Autoriser l'accès"
13602 }
13603 },
13604 "ja": {
13605 "stringUnit": {
13606 "state": "translated",
13607 "value": "アクセスを許可"
13608 }
13609 },
13610 "pt-BR": {
13611 "stringUnit": {
13612 "state": "translated",
13613 "value": "Conceder Acesso"
13614 }
13615 }
13616 }
13617 },
13618 "Grant Access…": {
13619 "comment": "Button that opens a panel to give orgstar access to a folder",
13620 "localizations": {
13621 "de": {
13622 "stringUnit": {
13623 "state": "translated",
13624 "value": "Zugriff erlauben…"
13625 }
13626 },
13627 "es": {
13628 "stringUnit": {
13629 "state": "translated",
13630 "value": "Conceder acceso…"
13631 }
13632 },
13633 "fr": {
13634 "stringUnit": {
13635 "state": "translated",
13636 "value": "Autoriser l'accès…"
13637 }
13638 },
13639 "ja": {
13640 "stringUnit": {
13641 "state": "translated",
13642 "value": "アクセスを許可…"
13643 }
13644 },
13645 "pt-BR": {
13646 "stringUnit": {
13647 "state": "translated",
13648 "value": "Conceder Acesso…"
13649 }
13650 }
13651 }
13652 },
1308813653 "Habit": {
1308913654 "localizations": {
1309013655 "de": {
@@ -14990,6 +15555,41 @@
1499015555 }
1499115556 }
1499215557 },
15558 "It isn't in one of your folders. Grant access to it to continue.": {
15559 "comment": "Alert for a folder outside the sidebar's folders",
15560 "localizations": {
15561 "de": {
15562 "stringUnit": {
15563 "state": "translated",
15564 "value": "Er liegt in keinem deiner Ordner. Erlaube den Zugriff, um fortzufahren."
15565 }
15566 },
15567 "es": {
15568 "stringUnit": {
15569 "state": "translated",
15570 "value": "No está en ninguna de tus carpetas. Concede acceso para continuar."
15571 }
15572 },
15573 "fr": {
15574 "stringUnit": {
15575 "state": "translated",
15576 "value": "Il ne se trouve dans aucun de vos dossiers. Autorisez l'accès pour continuer."
15577 }
15578 },
15579 "ja": {
15580 "stringUnit": {
15581 "state": "translated",
15582 "value": "どのフォルダにも含まれていません。続けるにはアクセスを許可してください。"
15583 }
15584 },
15585 "pt-BR": {
15586 "stringUnit": {
15587 "state": "translated",
15588 "value": "Ela não está em nenhuma das suas pastas. Conceda acesso para continuar."
15589 }
15590 }
15591 }
15592 },
1499315593 "Italic": {
1499415594 "comment": "Command title",
1499515595 "localizations": {
@@ -15679,40 +16279,6 @@
1567916279 }
1568016280 }
1568116281 },
15682 "License key": {
15683 "localizations": {
15684 "de": {
15685 "stringUnit": {
15686 "state": "translated",
15687 "value": "Lizenzschlüssel"
15688 }
15689 },
15690 "es": {
15691 "stringUnit": {
15692 "state": "translated",
15693 "value": "Clave de licencia"
15694 }
15695 },
15696 "fr": {
15697 "stringUnit": {
15698 "state": "translated",
15699 "value": "Clé de licence"
15700 }
15701 },
15702 "ja": {
15703 "stringUnit": {
15704 "state": "translated",
15705 "value": "ライセンスキー"
15706 }
15707 },
15708 "pt-BR": {
15709 "stringUnit": {
15710 "state": "translated",
15711 "value": "Chave de licença"
15712 }
15713 }
15714 }
15715 },
1571616282 "Light": {
1571716283 "localizations": {
1571816284 "de": {
@@ -16435,6 +17001,40 @@
1643517001 }
1643617002 }
1643717003 },
17004 "Makes notes.org in a folder you choose or make in iCloud Drive and adds the folder": {
17005 "localizations": {
17006 "de": {
17007 "stringUnit": {
17008 "state": "translated",
17009 "value": "Legt notes.org in einem Ordner an, den du in iCloud Drive wählst oder erstellst, und fügt den Ordner hinzu"
17010 }
17011 },
17012 "es": {
17013 "stringUnit": {
17014 "state": "translated",
17015 "value": "Crea notes.org en una carpeta que eliges o creas en iCloud Drive y añade la carpeta"
17016 }
17017 },
17018 "fr": {
17019 "stringUnit": {
17020 "state": "translated",
17021 "value": "Crée notes.org dans un dossier que vous choisissez ou créez dans iCloud Drive et ajoute le dossier"
17022 }
17023 },
17024 "ja": {
17025 "stringUnit": {
17026 "state": "translated",
17027 "value": "iCloud Driveで選択または作成したフォルダにnotes.orgを作成し、フォルダを追加します"
17028 }
17029 },
17030 "pt-BR": {
17031 "stringUnit": {
17032 "state": "translated",
17033 "value": "Cria notes.org em uma pasta que você escolhe ou cria no iCloud Drive e adiciona a pasta"
17034 }
17035 }
17036 }
17037 },
1643817038 "Makes org/notes.org in iCloud Drive and adds the folder": {
1643917039 "localizations": {
1644017040 "de": {
@@ -16503,6 +17103,40 @@
1650317103 }
1650417104 }
1650517105 },
17106 "Manage Subscription…": {
17107 "localizations": {
17108 "de": {
17109 "stringUnit": {
17110 "state": "translated",
17111 "value": "Abonnement verwalten …"
17112 }
17113 },
17114 "es": {
17115 "stringUnit": {
17116 "state": "translated",
17117 "value": "Gestionar suscripción…"
17118 }
17119 },
17120 "fr": {
17121 "stringUnit": {
17122 "state": "translated",
17123 "value": "Gérer l'abonnement…"
17124 }
17125 },
17126 "ja": {
17127 "stringUnit": {
17128 "state": "translated",
17129 "value": "サブスクリプションを管理…"
17130 }
17131 },
17132 "pt-BR": {
17133 "stringUnit": {
17134 "state": "translated",
17135 "value": "Gerenciar Assinatura…"
17136 }
17137 }
17138 }
17139 },
1650617140 "Manual": {
1650717141 "localizations": {
1650817142 "de": {
@@ -17845,6 +18479,40 @@
1784518479 }
1784618480 }
1784718481 },
18482 "New Folder in iCloud Drive…": {
18483 "localizations": {
18484 "de": {
18485 "stringUnit": {
18486 "state": "translated",
18487 "value": "Neuer Ordner in iCloud Drive …"
18488 }
18489 },
18490 "es": {
18491 "stringUnit": {
18492 "state": "translated",
18493 "value": "Nueva carpeta en iCloud Drive…"
18494 }
18495 },
18496 "fr": {
18497 "stringUnit": {
18498 "state": "translated",
18499 "value": "Nouveau dossier dans iCloud Drive…"
18500 }
18501 },
18502 "ja": {
18503 "stringUnit": {
18504 "state": "translated",
18505 "value": "iCloud Driveに新規フォルダ…"
18506 }
18507 },
18508 "pt-BR": {
18509 "stringUnit": {
18510 "state": "translated",
18511 "value": "Nova Pasta no iCloud Drive…"
18512 }
18513 }
18514 }
18515 },
1784818516 "New Folder…": {
1784918517 "localizations": {
1785018518 "de": {
@@ -19910,74 +20578,6 @@
1991020578 }
1991120579 }
1991220580 },
19913 "ORGSTAR1-…": {
19914 "localizations": {
19915 "de": {
19916 "stringUnit": {
19917 "state": "translated",
19918 "value": "ORGSTAR1-…"
19919 }
19920 },
19921 "es": {
19922 "stringUnit": {
19923 "state": "translated",
19924 "value": "ORGSTAR1-…"
19925 }
19926 },
19927 "fr": {
19928 "stringUnit": {
19929 "state": "translated",
19930 "value": "ORGSTAR1-…"
19931 }
19932 },
19933 "ja": {
19934 "stringUnit": {
19935 "state": "translated",
19936 "value": "ORGSTAR1-…"
19937 }
19938 },
19939 "pt-BR": {
19940 "stringUnit": {
19941 "state": "translated",
19942 "value": "ORGSTAR1-…"
19943 }
19944 }
19945 }
19946 },
19947 "Once a day, from the app's own feed. orgstar ▸ Check for Updates… checks now.": {
19948 "localizations": {
19949 "de": {
19950 "stringUnit": {
19951 "state": "translated",
19952 "value": "Einmal täglich, aus dem Feed der App. orgstar ▸ Nach Updates suchen … prüft sofort."
19953 }
19954 },
19955 "es": {
19956 "stringUnit": {
19957 "state": "translated",
19958 "value": "Una vez al día, desde el canal de la propia app. orgstar ▸ Buscar actualizaciones… lo comprueba ahora."
19959 }
19960 },
19961 "fr": {
19962 "stringUnit": {
19963 "state": "translated",
19964 "value": "Une fois par jour, depuis le flux de l'app. orgstar ▸ Rechercher les mises à jour… vérifie immédiatement."
19965 }
19966 },
19967 "ja": {
19968 "stringUnit": {
19969 "state": "translated",
19970 "value": "1日1回、App独自のフィードから確認します。orgstar ▸ アップデートを確認…ですぐに確認できます。"
19971 }
19972 },
19973 "pt-BR": {
19974 "stringUnit": {
19975 "state": "translated",
19976 "value": "Uma vez por dia, a partir do feed do próprio app. orgstar ▸ Buscar Atualizações… verifica agora."
19977 }
19978 }
19979 }
19980 },
1998120581 "One payment, no subscription": {
1998220582 "localizations": {
1998320583 "de": {
@@ -23559,40 +24159,6 @@
2355924159 }
2356024160 }
2356124161 },
23562 "Remove License from This Mac": {
23563 "localizations": {
23564 "de": {
23565 "stringUnit": {
23566 "state": "translated",
23567 "value": "Lizenz von diesem Mac entfernen"
23568 }
23569 },
23570 "es": {
23571 "stringUnit": {
23572 "state": "translated",
23573 "value": "Quitar la licencia de este Mac"
23574 }
23575 },
23576 "fr": {
23577 "stringUnit": {
23578 "state": "translated",
23579 "value": "Retirer la licence de ce Mac"
23580 }
23581 },
23582 "ja": {
23583 "stringUnit": {
23584 "state": "translated",
23585 "value": "このMacからライセンスを削除"
23586 }
23587 },
23588 "pt-BR": {
23589 "stringUnit": {
23590 "state": "translated",
23591 "value": "Remover Licença Deste Mac"
23592 }
23593 }
23594 }
23595 },
2359624162 "Remove Priority": {
2359724163 "comment": "Command title",
2359824164 "localizations": {
@@ -24007,40 +24573,6 @@
2400724573 }
2400824574 }
2400924575 },
24010 "Renews while you sponsor monthly. This key is valid until %@.": {
24011 "localizations": {
24012 "de": {
24013 "stringUnit": {
24014 "state": "translated",
24015 "value": "Wird verlängert, solange du monatlich sponserst. Dieser Schlüssel gilt bis %@."
24016 }
24017 },
24018 "es": {
24019 "stringUnit": {
24020 "state": "translated",
24021 "value": "Se renueva mientras patrocines cada mes. Esta clave es válida hasta el %@."
24022 }
24023 },
24024 "fr": {
24025 "stringUnit": {
24026 "state": "translated",
24027 "value": "Renouvelée tant que vous sponsorisez chaque mois. Cette clé est valable jusqu'au %@."
24028 }
24029 },
24030 "ja": {
24031 "stringUnit": {
24032 "state": "translated",
24033 "value": "毎月スポンサーを続けている間は更新されます。このキーは%@まで有効です。"
24034 }
24035 },
24036 "pt-BR": {
24037 "stringUnit": {
24038 "state": "translated",
24039 "value": "É renovada enquanto você patrocina mensalmente. Esta chave é válida até %@."
24040 }
24041 }
24042 }
24043 },
2404424576 "Reparent Note with Descendants…": {
2404524577 "comment": "Command title",
2404624578 "localizations": {
@@ -24522,6 +25054,40 @@
2452225054 }
2452325055 }
2452425056 },
25057 "Run Emacs Lisp blocks and tangle": {
25058 "localizations": {
25059 "de": {
25060 "stringUnit": {
25061 "state": "translated",
25062 "value": "Emacs-Lisp-Blöcke ausführen und tanglen"
25063 }
25064 },
25065 "es": {
25066 "stringUnit": {
25067 "state": "translated",
25068 "value": "Ejecutar bloques de Emacs Lisp y extraer código (tangle)"
25069 }
25070 },
25071 "fr": {
25072 "stringUnit": {
25073 "state": "translated",
25074 "value": "Exécuter les blocs Emacs Lisp et extraire (tangle)"
25075 }
25076 },
25077 "ja": {
25078 "stringUnit": {
25079 "state": "translated",
25080 "value": "Emacs Lispブロックを実行してタングル"
25081 }
25082 },
25083 "pt-BR": {
25084 "stringUnit": {
25085 "state": "translated",
25086 "value": "Executar blocos de Emacs Lisp e fazer tangle"
25087 }
25088 }
25089 }
25090 },
2452525091 "Run Source Block": {
2452625092 "comment": "Command title",
2452725093 "localizations": {
@@ -24832,6 +25398,41 @@
2483225398 }
2483325399 }
2483425400 },
25401 "Save Elsewhere…": {
25402 "comment": "Button that asks where an export goes instead",
25403 "localizations": {
25404 "de": {
25405 "stringUnit": {
25406 "state": "translated",
25407 "value": "Woanders sichern…"
25408 }
25409 },
25410 "es": {
25411 "stringUnit": {
25412 "state": "translated",
25413 "value": "Guardar en otro lugar…"
25414 }
25415 },
25416 "fr": {
25417 "stringUnit": {
25418 "state": "translated",
25419 "value": "Enregistrer ailleurs…"
25420 }
25421 },
25422 "ja": {
25423 "stringUnit": {
25424 "state": "translated",
25425 "value": "別の場所に保存…"
25426 }
25427 },
25428 "pt-BR": {
25429 "stringUnit": {
25430 "state": "translated",
25431 "value": "Salvar em Outro Lugar…"
25432 }
25433 }
25434 }
25435 },
2483525436 "Save Field": {
2483625437 "localizations": {
2483725438 "de": {
@@ -27551,6 +28152,40 @@
2755128152 }
2755228153 }
2755328154 },
28155 "Some plans aren't available from the App Store right now.": {
28156 "localizations": {
28157 "de": {
28158 "stringUnit": {
28159 "state": "translated",
28160 "value": "Einige Abos sind gerade nicht im App Store verfügbar."
28161 }
28162 },
28163 "es": {
28164 "stringUnit": {
28165 "state": "translated",
28166 "value": "Algunos planes no están disponibles en la App Store en este momento."
28167 }
28168 },
28169 "fr": {
28170 "stringUnit": {
28171 "state": "translated",
28172 "value": "Certaines formules ne sont pas disponibles sur l'App Store pour le moment."
28173 }
28174 },
28175 "ja": {
28176 "stringUnit": {
28177 "state": "translated",
28178 "value": "一部のプランは現在App Storeで利用できません。"
28179 }
28180 },
28181 "pt-BR": {
28182 "stringUnit": {
28183 "state": "translated",
28184 "value": "Alguns planos não estão disponíveis na App Store no momento."
28185 }
28186 }
28187 }
28188 },
2755428189 "Some tips aren't available from the App Store right now.": {
2755528190 "localizations": {
2755628191 "de": {
@@ -27897,74 +28532,6 @@
2789728532 }
2789828533 }
2789928534 },
27900 "Sponsor for orgstar+…": {
27901 "localizations": {
27902 "de": {
27903 "stringUnit": {
27904 "state": "translated",
27905 "value": "Für orgstar+ sponsern …"
27906 }
27907 },
27908 "es": {
27909 "stringUnit": {
27910 "state": "translated",
27911 "value": "Patrocinar para orgstar+…"
27912 }
27913 },
27914 "fr": {
27915 "stringUnit": {
27916 "state": "translated",
27917 "value": "Sponsoriser pour orgstar+…"
27918 }
27919 },
27920 "ja": {
27921 "stringUnit": {
27922 "state": "translated",
27923 "value": "スポンサーになってorgstar+を利用…"
27924 }
27925 },
27926 "pt-BR": {
27927 "stringUnit": {
27928 "state": "translated",
27929 "value": "Patrocinar para o orgstar+…"
27930 }
27931 }
27932 }
27933 },
27934 "Sponsors get their key by signing in with GitHub. It is checked on this Mac; a monthly sponsor's key is renewed with krz.sh.": {
27935 "localizations": {
27936 "de": {
27937 "stringUnit": {
27938 "state": "translated",
27939 "value": "Sponsoren erhalten ihren Schlüssel, indem sie sich mit GitHub anmelden. Er wird auf diesem Mac geprüft; der Schlüssel monatlicher Sponsoren wird über krz.sh verlängert."
27940 }
27941 },
27942 "es": {
27943 "stringUnit": {
27944 "state": "translated",
27945 "value": "Los patrocinadores obtienen su clave iniciando sesión con GitHub. Se comprueba en este Mac; la clave de un patrocinador mensual se renueva con krz.sh."
27946 }
27947 },
27948 "fr": {
27949 "stringUnit": {
27950 "state": "translated",
27951 "value": "Les sponsors obtiennent leur clé en se connectant avec GitHub. Elle est vérifiée sur ce Mac ; la clé d'un sponsor mensuel est renouvelée auprès de krz.sh."
27952 }
27953 },
27954 "ja": {
27955 "stringUnit": {
27956 "state": "translated",
27957 "value": "スポンサーはGitHubでサインインしてキーを取得します。キーはこのMac上で確認されます。月額スポンサーのキーはkrz.shで更新されます。"
27958 }
27959 },
27960 "pt-BR": {
27961 "stringUnit": {
27962 "state": "translated",
27963 "value": "Os patrocinadores obtêm a chave entrando com o GitHub. Ela é verificada neste Mac; a chave de um patrocinador mensal é renovada com o krz.sh."
27964 }
27965 }
27966 }
27967 },
2796828535 "Standard Mac editing keys, with Org commands on ⌃⌘: ⌃⌘T cycles TODO, ⌃⌘S schedules.": {
2796928536 "localizations": {
2797028537 "de": {
@@ -30332,6 +30899,41 @@
3033230899 }
3033330900 }
3033430901 },
30902 "This file isn't in one of your folders. Choose where the export goes.": {
30903 "comment": "Save panel for an export outside the sidebar's folders",
30904 "localizations": {
30905 "de": {
30906 "stringUnit": {
30907 "state": "translated",
30908 "value": "Diese Datei liegt in keinem deiner Ordner. Wähle, wohin der Export geht."
30909 }
30910 },
30911 "es": {
30912 "stringUnit": {
30913 "state": "translated",
30914 "value": "Este archivo no está en ninguna de tus carpetas. Elige dónde guardar la exportación."
30915 }
30916 },
30917 "fr": {
30918 "stringUnit": {
30919 "state": "translated",
30920 "value": "Ce fichier ne se trouve dans aucun de vos dossiers. Choisissez où enregistrer l'exportation."
30921 }
30922 },
30923 "ja": {
30924 "stringUnit": {
30925 "state": "translated",
30926 "value": "このファイルはどのフォルダにもありません。書き出し先を選択してください。"
30927 }
30928 },
30929 "pt-BR": {
30930 "stringUnit": {
30931 "state": "translated",
30932 "value": "Este arquivo não está em nenhuma das suas pastas. Escolha onde salvar a exportação."
30933 }
30934 }
30935 }
30936 },
3033530937 "This table needs Emacs, which runs on the Mac: %@.": {
3033630938 "comment": "Table formulas only Emacs can calculate",
3033730939 "localizations": {
@@ -30367,6 +30969,41 @@
3036730969 }
3036830970 }
3036930971 },
30972 "This table's formulas can't be calculated here: %@.": {
30973 "comment": "Table formulas orgstar can't calculate",
30974 "localizations": {
30975 "de": {
30976 "stringUnit": {
30977 "state": "translated",
30978 "value": "Die Formeln dieser Tabelle können hier nicht berechnet werden: %@."
30979 }
30980 },
30981 "es": {
30982 "stringUnit": {
30983 "state": "translated",
30984 "value": "Las fórmulas de esta tabla no se pueden calcular aquí: %@."
30985 }
30986 },
30987 "fr": {
30988 "stringUnit": {
30989 "state": "translated",
30990 "value": "Les formules de ce tableau ne peuvent pas être calculées ici : %@."
30991 }
30992 },
30993 "ja": {
30994 "stringUnit": {
30995 "state": "translated",
30996 "value": "この表の数式はここでは計算できません:%@。"
30997 }
30998 },
30999 "pt-BR": {
31000 "stringUnit": {
31001 "state": "translated",
31002 "value": "As fórmulas desta tabela não podem ser calculadas aqui: %@."
31003 }
31004 }
31005 }
31006 },
3037031007 "Time": {
3037131008 "localizations": {
3037231009 "de": {
@@ -31748,6 +32385,40 @@
3174832385 }
3174932386 }
3175032387 },
32388 "Use Default Folder": {
32389 "localizations": {
32390 "de": {
32391 "stringUnit": {
32392 "state": "translated",
32393 "value": "Standardordner verwenden"
32394 }
32395 },
32396 "es": {
32397 "stringUnit": {
32398 "state": "translated",
32399 "value": "Usar carpeta predeterminada"
32400 }
32401 },
32402 "fr": {
32403 "stringUnit": {
32404 "state": "translated",
32405 "value": "Utiliser le dossier par défaut"
32406 }
32407 },
32408 "ja": {
32409 "stringUnit": {
32410 "state": "translated",
32411 "value": "デフォルトのフォルダを使用"
32412 }
32413 },
32414 "pt-BR": {
32415 "stringUnit": {
32416 "state": "translated",
32417 "value": "Usar Pasta Padrão"
32418 }
32419 }
32420 }
32421 },
3175132422 "Use Disk Version": {
3175232423 "localizations": {
3175332424 "de": {
@@ -31782,6 +32453,41 @@
3178232453 }
3178332454 }
3178432455 },
32456 "Use Folder": {
32457 "comment": "Open panel button on the welcome sheet",
32458 "localizations": {
32459 "de": {
32460 "stringUnit": {
32461 "state": "translated",
32462 "value": "Ordner verwenden"
32463 }
32464 },
32465 "es": {
32466 "stringUnit": {
32467 "state": "translated",
32468 "value": "Usar carpeta"
32469 }
32470 },
32471 "fr": {
32472 "stringUnit": {
32473 "state": "translated",
32474 "value": "Utiliser le dossier"
32475 }
32476 },
32477 "ja": {
32478 "stringUnit": {
32479 "state": "translated",
32480 "value": "フォルダを使用"
32481 }
32482 },
32483 "pt-BR": {
32484 "stringUnit": {
32485 "state": "translated",
32486 "value": "Usar Pasta"
32487 }
32488 }
32489 }
32490 },
3178532491 "Use Selection for Find": {
3178632492 "comment": "Command title",
3178732493 "localizations": {
@@ -34232,6 +34938,145 @@
3423234938 }
3423334939 }
3423434940 },
34941 "orgstar can't keep %@ as the configuration folder.": {
34942 "comment": "Alert when the chosen configuration folder can't be saved",
34943 "localizations": {
34944 "de": {
34945 "stringUnit": {
34946 "state": "translated",
34947 "value": "orgstar kann %@ nicht als Konfigurationsordner behalten."
34948 }
34949 },
34950 "es": {
34951 "stringUnit": {
34952 "state": "translated",
34953 "value": "orgstar no puede conservar %@ como carpeta de configuración."
34954 }
34955 },
34956 "fr": {
34957 "stringUnit": {
34958 "state": "translated",
34959 "value": "orgstar ne peut pas conserver %@ comme dossier de configuration."
34960 }
34961 },
34962 "ja": {
34963 "stringUnit": {
34964 "state": "translated",
34965 "value": "orgstarは%@を設定フォルダとして保持できません。"
34966 }
34967 },
34968 "pt-BR": {
34969 "stringUnit": {
34970 "state": "translated",
34971 "value": "O orgstar não consegue manter %@ como pasta de configuração."
34972 }
34973 }
34974 }
34975 },
34976 "orgstar can't keep access to %@.": {
34977 "comment": "Alert when a folder grant can't be saved",
34978 "localizations": {
34979 "de": {
34980 "stringUnit": {
34981 "state": "translated",
34982 "value": "orgstar kann den Zugriff auf %@ nicht behalten."
34983 }
34984 },
34985 "es": {
34986 "stringUnit": {
34987 "state": "translated",
34988 "value": "orgstar no puede conservar el acceso a %@."
34989 }
34990 },
34991 "fr": {
34992 "stringUnit": {
34993 "state": "translated",
34994 "value": "orgstar ne peut pas conserver l'accès à %@."
34995 }
34996 },
34997 "ja": {
34998 "stringUnit": {
34999 "state": "translated",
35000 "value": "orgstarは%@へのアクセスを保持できません。"
35001 }
35002 },
35003 "pt-BR": {
35004 "stringUnit": {
35005 "state": "translated",
35006 "value": "O orgstar não consegue manter o acesso a %@."
35007 }
35008 }
35009 }
35010 },
35011 "orgstar can't open this folder": {
35012 "localizations": {
35013 "de": {
35014 "stringUnit": {
35015 "state": "translated",
35016 "value": "orgstar kann diesen Ordner nicht öffnen"
35017 }
35018 },
35019 "es": {
35020 "stringUnit": {
35021 "state": "translated",
35022 "value": "orgstar no puede abrir esta carpeta"
35023 }
35024 },
35025 "fr": {
35026 "stringUnit": {
35027 "state": "translated",
35028 "value": "orgstar ne peut pas ouvrir ce dossier"
35029 }
35030 },
35031 "ja": {
35032 "stringUnit": {
35033 "state": "translated",
35034 "value": "orgstarはこのフォルダを開けません"
35035 }
35036 },
35037 "pt-BR": {
35038 "stringUnit": {
35039 "state": "translated",
35040 "value": "O orgstar não consegue abrir esta pasta"
35041 }
35042 }
35043 }
35044 },
35045 "orgstar can't reach %@.": {
35046 "comment": "Alert for a folder outside the sidebar's folders",
35047 "localizations": {
35048 "de": {
35049 "stringUnit": {
35050 "state": "translated",
35051 "value": "orgstar kann nicht auf %@ zugreifen."
35052 }
35053 },
35054 "es": {
35055 "stringUnit": {
35056 "state": "translated",
35057 "value": "orgstar no puede acceder a %@."
35058 }
35059 },
35060 "fr": {
35061 "stringUnit": {
35062 "state": "translated",
35063 "value": "orgstar ne peut pas accéder à %@."
35064 }
35065 },
35066 "ja": {
35067 "stringUnit": {
35068 "state": "translated",
35069 "value": "orgstarは%@にアクセスできません。"
35070 }
35071 },
35072 "pt-BR": {
35073 "stringUnit": {
35074 "state": "translated",
35075 "value": "O orgstar não consegue acessar %@."
35076 }
35077 }
35078 }
35079 },
3423535080 "orgstar edits a folder of plain-text org files in place. Add the folder your notes are in, or start a new one. Nothing is copied or moved, and you can add more folders later with File ▸ Add Folder….": {
3423635081 "localizations": {
3423735082 "de": {
@@ -34334,104 +35179,104 @@
3433435179 }
3433535180 }
3433635181 },
34337 "orgstar's shared folder isn't available.": {
35182 "orgstar keeps its settings in a folder of its own. To use the ones in ~/.config/orgstar, choose that folder in Settings ▸ General ▸ Choose Configuration Folder….": {
3433835183 "localizations": {
3433935184 "de": {
3434035185 "stringUnit": {
3434135186 "state": "translated",
34342 "value": "Der gemeinsame Ordner von orgstar ist nicht verfügbar."
35187 "value": "orgstar speichert seine Einstellungen in einem eigenen Ordner. Um die aus ~/.config/orgstar zu verwenden, wähle diesen Ordner unter Einstellungen ▸ Allgemein ▸ Konfigurationsordner wählen …."
3434335188 }
3434435189 },
3434535190 "es": {
3434635191 "stringUnit": {
3434735192 "state": "translated",
34348 "value": "La carpeta compartida de orgstar no está disponible."
35193 "value": "orgstar guarda sus ajustes en una carpeta propia. Para usar los de ~/.config/orgstar, elige esa carpeta en Ajustes ▸ General ▸ Elegir carpeta de configuración…."
3434935194 }
3435035195 },
3435135196 "fr": {
3435235197 "stringUnit": {
3435335198 "state": "translated",
34354 "value": "Le dossier partagé d'orgstar n'est pas disponible."
35199 "value": "orgstar range ses réglages dans un dossier à lui. Pour utiliser ceux de ~/.config/orgstar, choisissez ce dossier dans Réglages ▸ Général ▸ Choisir le dossier de configuration…."
3435535200 }
3435635201 },
3435735202 "ja": {
3435835203 "stringUnit": {
3435935204 "state": "translated",
34360 "value": "orgstarの共有フォルダを利用できません。"
35205 "value": "orgstarは設定を専用のフォルダに保存します。~/.config/orgstarの設定を使うには、設定 ▸ 一般 ▸ 構成フォルダを選択…でそのフォルダを選択してください。"
3436135206 }
3436235207 },
3436335208 "pt-BR": {
3436435209 "stringUnit": {
3436535210 "state": "translated",
34366 "value": "A pasta compartilhada do orgstar não está disponível."
35211 "value": "O orgstar guarda seus ajustes em uma pasta própria. Para usar os de ~/.config/orgstar, escolha essa pasta em Ajustes ▸ Geral ▸ Escolher Pasta de Configuração…."
3436735212 }
3436835213 }
3436935214 }
3437035215 },
34371 "orgstar+": {
35216 "orgstar's shared folder isn't available.": {
3437235217 "localizations": {
3437335218 "de": {
3437435219 "stringUnit": {
3437535220 "state": "translated",
34376 "value": "orgstar+"
35221 "value": "Der gemeinsame Ordner von orgstar ist nicht verfügbar."
3437735222 }
3437835223 },
3437935224 "es": {
3438035225 "stringUnit": {
3438135226 "state": "translated",
34382 "value": "orgstar+"
35227 "value": "La carpeta compartida de orgstar no está disponible."
3438335228 }
3438435229 },
3438535230 "fr": {
3438635231 "stringUnit": {
3438735232 "state": "translated",
34388 "value": "orgstar+"
35233 "value": "Le dossier partagé d'orgstar n'est pas disponible."
3438935234 }
3439035235 },
3439135236 "ja": {
3439235237 "stringUnit": {
3439335238 "state": "translated",
34394 "value": "orgstar+"
35239 "value": "orgstarの共有フォルダを利用できません。"
3439535240 }
3439635241 },
3439735242 "pt-BR": {
3439835243 "stringUnit": {
3439935244 "state": "translated",
34400 "value": "orgstar+"
35245 "value": "A pasta compartilhada do orgstar não está disponível."
3440135246 }
3440235247 }
3440335248 }
3440435249 },
34405 "orgstar+ for Mac comes with sponsoring orgstar on GitHub: $60 once, or $5 a month. Editing, the agenda, capture, clocking and search stay free.": {
35250 "orgstar+": {
3440635251 "localizations": {
3440735252 "de": {
3440835253 "stringUnit": {
3440935254 "state": "translated",
34410 "value": "orgstar+ für Mac gibt es, wenn du orgstar auf GitHub sponserst: einmalig $60 oder $5 im Monat. Bearbeiten, Agenda, Erfassen, Zeiterfassung und Suche bleiben kostenlos."
35255 "value": "orgstar+"
3441135256 }
3441235257 },
3441335258 "es": {
3441435259 "stringUnit": {
3441535260 "state": "translated",
34416 "value": "orgstar+ para Mac se incluye al patrocinar orgstar en GitHub: $60 una vez o $5 al mes. La edición, la agenda, la captura, el registro de tiempo y la búsqueda siguen siendo gratuitos."
35261 "value": "orgstar+"
3441735262 }
3441835263 },
3441935264 "fr": {
3442035265 "stringUnit": {
3442135266 "state": "translated",
34422 "value": "orgstar+ pour Mac est inclus quand vous sponsorisez orgstar sur GitHub : $60 une fois, ou $5 par mois. L'édition, l'agenda, la capture, le chronométrage et la recherche restent gratuits."
35267 "value": "orgstar+"
3442335268 }
3442435269 },
3442535270 "ja": {
3442635271 "stringUnit": {
3442735272 "state": "translated",
34428 "value": "Mac版orgstar+は、GitHubでorgstarのスポンサーになると利用できます(1回$60、または月額$5)。編集、アジェンダ、キャプチャ、クロック、検索は引き続き無料です。"
35273 "value": "orgstar+"
3442935274 }
3443035275 },
3443135276 "pt-BR": {
3443235277 "stringUnit": {
3443335278 "state": "translated",
34434 "value": "O orgstar+ para Mac vem com o patrocínio do orgstar no GitHub: $60 uma vez ou $5 por mês. A edição, a agenda, a captura, o registro de tempo e a busca continuam gratuitos."
35279 "value": "orgstar+"
3443535280 }
3443635281 }
3443735282 }
scripts/build-app.sh +2 −2
@@ -54,8 +54,8 @@ if [ "$sign" != "-" ]; then
5454else
5555 feed_keys=""
5656fi
57# The UI's translations, from l10n/Localizable.xcstrings.
58scripts/localize.sh "$app/Contents/Resources"
57# The UI's translations, from l10n/Localizable.xcstrings and l10n/DeveloperID.xcstrings.
58scripts/localize.sh --developer-id "$app/Contents/Resources"
5959
6060# The icon (macOS derives its dark and tinted styles), and the Dock icons Settings offers.
6161work="$(mktemp -d)"
scripts/localize.sh +7 −2
@@ -1,13 +1,18 @@
11#!/bin/sh
22# Compiles l10n/Localizable.xcstrings into the .lproj folders of each bundle folder given (an
33# app's Contents/Resources, an iOS app or extension folder). English is the source language:
4# its folder is empty, so the keys show as they are.
5# Usage: scripts/localize.sh <folder>...
4# its folder is empty, so the keys show as they are. With --developer-id, the DeveloperID table
5# too: the license and update strings, which only the Developer ID Mac app shows.
6# Usage: scripts/localize.sh [--developer-id] <folder>...
67set -eu
78
89cd "$(dirname "$0")/.."
910work="$(mktemp -d)"
1011xcrun xcstringstool compile l10n/Localizable.xcstrings --output-directory "$work" > /dev/null
12if [ "${1:-}" = --developer-id ]; then
13 shift
14 xcrun xcstringstool compile l10n/DeveloperID.xcstrings --output-directory "$work" > /dev/null
15fi
1116mkdir -p "$work/en.lproj"
1217for folder in "$@"; do
1318 for lproj in "$work"/*.lproj; do
scripts/release-ios.sh +2 −1
@@ -1,7 +1,8 @@
11#!/bin/sh
22# Archives the iOS app (with its extensions and the watch app) and uploads it to App Store
33# Connect for TestFlight. The version is the project's MARKETING_VERSION; the build number is the
4# commit count, as the Mac release's is. Run after scripts/release-mac.sh. The work is done by
4# commit count, as the Mac releases' are. Run after scripts/release-mac.sh and before
5# scripts/release-macos.sh, from the same commit. The work is done by
56# appstore-kit, checked out beside this repository or at $APPSTORE_KIT.
67# Usage: scripts/release-ios.sh
78# ORGSTAR_PUBLISH 0 archives and exports the .ipa to .build/ios-release without uploading
scripts/release-macos.sh added +67
@@ -0,0 +1,67 @@
1#!/bin/sh
2# Archives the Mac App Store app (with its widgets, Quick Look and Spotlight extensions) and uploads
3# it to App Store Connect. The version is the project's MARKETING_VERSION; the build number is the
4# commit count. The Developer ID app is released by scripts/release-mac.sh instead. The work is done
5# by appstore-kit, checked out beside this repository or at $APPSTORE_KIT.
6# Usage: scripts/release-macos.sh
7# ORGSTAR_PUBLISH 0 archives and exports the .pkg to .build/macos-release without uploading
8PUBLISH="${ORGSTAR_PUBLISH:-1}"
9name=orgstar
10project=ios/Orgstar.xcodeproj
11scheme="Orgstar macOS"
12platform=macos
13configuration=Release
14
15# Runs before the archive, so it can only check build settings.
16preflight() {
17 settings="$(command xcodebuild -project "$project" -scheme "$scheme" -configuration "$configuration" \
18 -destination 'generic/platform=macOS' -showBuildSettings 2>/dev/null)" || fail "can't read the build settings of $scheme"
19 value() {
20 printf '%s\n' "$settings" | sed -n "s/^ *$1 = //p" | head -1
21 }
22 case " $(value SWIFT_ACTIVE_COMPILATION_CONDITIONS) " in
23 *" APPSTORE "*) ;;
24 *) fail "SWIFT_ACTIVE_COMPILATION_CONDITIONS of $scheme ($configuration) lacks APPSTORE" ;;
25 esac
26 [ "$(value PRODUCT_BUNDLE_IDENTIFIER)" = sh.krz.orgstar ] || fail "$scheme's bundle ID is $(value PRODUCT_BUNDLE_IDENTIFIER), not sh.krz.orgstar"
27 for entitlements in ios/OrgstarMac/*.entitlements ios/OrgstarWidgets/*-macOS.entitlements \
28 ios/OrgstarQuickLook/*-macOS.entitlements ios/OrgstarSpotlight/*.entitlements; do
29 ! grep -q temporary-exception "$entitlements" || fail "$entitlements has a temporary exception"
30 done
31}
32
33# Checks the built app: no Sparkle, no updater keys, no process launching, no temporary exceptions,
34# a provisioning profile in the app and in each extension, and no license or update text in its
35# string tables.
36check_archive() {
37 set -- "$1"/Products/Applications/*.app
38 [ -d "$1" ] || fail "no app in the archive"
39 app="$1"
40 [ -z "$(find "$app" -iname '*sparkle*' | head -1)" ] || fail "the archive contains Sparkle: $(find "$app" -iname '*sparkle*' | head -1)"
41 keys="$(plutil -convert json -o - "$app/Contents/Info.plist" \
42 | python3 -c 'import json, sys; print(" ".join(k for k in json.load(sys.stdin) if k.startswith("SU")))')"
43 [ -z "$keys" ] || fail "Info.plist has Sparkle keys: $keys"
44 for bundle in "$app" "$app"/Contents/PlugIns/*.appex "$app"/Contents/Extensions/*.appex; do
45 [ -d "$bundle" ] || continue
46 executable="$bundle/Contents/MacOS/$(/usr/libexec/PlistBuddy -c 'Print :CFBundleExecutable' "$bundle/Contents/Info.plist")"
47 symbols="$(nm -u "$executable" | grep -E '_OBJC_CLASS_\$_NSTask$|_posix_spawnp?$' | sort -u | tr '\n' ' ')"
48 [ -z "$symbols" ] || fail "$(basename "$bundle") launches processes: $symbols"
49 entitlements="$(codesign -d --entitlements - --xml "$bundle" 2>/dev/null)" || fail "$(basename "$bundle") isn't signed"
50 case "$entitlements" in
51 *temporary-exception*) fail "$(basename "$bundle") has a temporary-exception entitlement" ;;
52 esac
53 [ -f "$bundle/Contents/embedded.provisionprofile" ] || fail "$(basename "$bundle") has no embedded.provisionprofile"
54 done
55 found="$(find "$app" -path '*.lproj/*' -name '*.strings' -exec sh -c \
56 'plutil -convert json -o - "$1" | grep -Eio "sponsor|license key|krz\.sh|check for updates" | sed "s|^|$1: |"' _ {} \; | head -1)"
57 [ -z "$found" ] || fail "the app has Developer ID text: $found"
58}
59
60# appstore-kit has no step between archiving and exporting, so its export call checks the archive first.
61xcodebuild() {
62 if [ "$1" = -exportArchive ] && [ "$2" = -archivePath ]; then
63 check_archive "$3"
64 fi
65 command xcodebuild "$@"
66}
67. "${APPSTORE_KIT:-$(dirname "$0")/../../appstore-kit}/release-ios.sh"
scripts/sync-strings.sh +19 −5
@@ -1,6 +1,8 @@
11#!/bin/sh
2# Brings l10n/Localizable.xcstrings up to date with the strings the apps show: builds the Mac and
3# iOS targets with SWIFT_EMIT_LOC_STRINGS and syncs the catalog from their .stringsdata files.
2# Brings l10n/Localizable.xcstrings and l10n/DeveloperID.xcstrings (the strings with that table,
3# which only the Developer ID Mac app shows) up to date with the strings the apps show: builds the Mac, Mac
4# App Store and iOS targets with SWIFT_EMIT_LOC_STRINGS and syncs the catalog from their .stringsdata
5# files.
46# New strings are added, ones no longer used are marked stale; translations are kept.
57# Command titles come from Sources/OrgApp/CommandTitles.swift, which CommandTitleTests keeps current.
68set -eu
@@ -9,10 +11,15 @@ cd "$(dirname "$0")/.."
911catalog=l10n/Localizable.xcstrings
1012mac=.build/loc-mac
1113ios=.build/loc-ios
14mas=.build/loc-mas
1215
1316for scheme in Orgstar OrgstarWidgets; do
1417 xcodebuild -scheme "$scheme" -destination 'platform=macOS' -derivedDataPath "$mac" build -quiet SWIFT_EMIT_LOC_STRINGS=YES
1518done
19# The App Store targets compile Sources/Orgstar and Sources/OrgstarWidgets with APPSTORE, which
20# shows strings the SwiftPM schemes don't.
21xcodebuild -project ios/Orgstar.xcodeproj -scheme 'Orgstar macOS' -destination 'generic/platform=macOS' -derivedDataPath "$mas" \
22 build -quiet SWIFT_EMIT_LOC_STRINGS=YES CODE_SIGNING_ALLOWED=NO
1623for scheme in OrgstarMobile OrgstarShare OrgstarWidgets; do
1724 xcodebuild -scheme "$scheme" -destination 'generic/platform=iOS Simulator' -derivedDataPath "$ios" build -quiet SWIFT_EMIT_LOC_STRINGS=YES
1825done
@@ -24,6 +31,13 @@ done
2431find "$mac" "$ios" -path '*/arm64/*' -name '*.stringsdata' \
2532 | grep -E '/(Orgstar|OrgstarMobile|OrgstarWidgets|OrgstarShare|OrgstarWatch|OrgstarWatchWidgets)-p\.build/|/(OrgApp|OrgPresentation|OrgEditorAppKit)-t?\.build/' \
2633 > "$mac/stringsdata.txt"
27# shellcheck disable=SC2046
28xcrun xcstringstool sync "$catalog" --stringsdata $(tr '\n' ' ' < "$mac/stringsdata.txt")
29echo "$(python3 -c "import json; print(len(json.load(open('$catalog'))['strings']))") strings in $catalog"
34find "$mas" -path '*/arm64/*' -name '*.stringsdata' | grep -E '/(Orgstar macOS|OrgstarWidgets)\.build/' >> "$mac/stringsdata.txt"
35# The App Store target's folder name has a space, so the list is read a line at a time.
36set --
37while IFS= read -r file; do set -- "$@" "$file"; done < "$mac/stringsdata.txt"
38for catalog in "$catalog" l10n/DeveloperID.xcstrings; do
39 xcrun xcstringstool sync "$catalog" --stringsdata "$@"
40 # xcstringstool writes its own spacing; the committed catalog is Python's sorted JSON.
41 python3 -c "import json, sys; p = sys.argv[1]; d = json.load(open(p)); open(p, 'w').write(json.dumps(d, indent=2, ensure_ascii=False, sort_keys=True) + '\n')" "$catalog"
42 echo "$(python3 -c "import json; print(len(json.load(open('$catalog'))['strings']))") strings in $catalog"
43done