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 @@
3* Status 3* Status
4 4
5Design phases 1–7 are built. The Mac app is released as a notarized DMG and a Homebrew 5Design 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 6cask, with Sparkle updates; a second, sandboxed build for the Mac App Store is not yet
7Simulator and for a device signed with your own team, and go to TestFlight and the 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
8[[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 9[[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
9passes on the Mac and iOS (issues 3 and 4). 10passes on the Mac and iOS (issues 3 and 4).
10 11
@@ -54,12 +55,18 @@ orgstar" action as on the Mac.
54 55
55** In-app purchases 56** In-app purchases
56 57
57=ios/Orgstar.storekit= is the StoreKit configuration the "Orgstar iOS" scheme runs with, so 58=ios/Orgstar.storekit= is the StoreKit configuration the "Orgstar iOS" and "Orgstar macOS"
58purchases work in Xcode without App Store Connect. It holds orgstar+ 59schemes run with, so purchases work in Xcode without App Store Connect. It holds orgstar+
59(=sh.krz.orgstar.pro.monthly=, =.yearly=, =.lifetime=) and the consumable tips 60(=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 61(=sh.krz.orgstar.tip.small=, =.medium=, =.large=, at 0.99, 2.99 and 4.99). Tips unlock
61Settings ▸ About orgstar ▸ Support Development, for everyone, and unlock nothing. The Mac app 62nothing. On iOS they are in Settings ▸ About orgstar ▸ Support Development, and in the Mac App
62has no tips: it is sold outside the App Store and has no StoreKit. 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.
63 70
64In App Store Connect, create each tip as a Consumable with the exact product ID, a display 71In App Store Connect, create each tip as a Consumable with the exact product ID, a display
65name and description in every localization the app has (de, fr, ja, es-ES, pt-BR), a price 72name 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
67Submit new in-app purchases with an app version. Changes take up to an hour to reach the 74Submit new in-app purchases with an app version. Changes take up to an hour to reach the
68sandbox; test there with a Sandbox Apple Account (Settings ▸ Developer on the device). 75sandbox; test there with a Sandbox Apple Account (Settings ▸ Developer on the device).
69 76
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
70* Mac licenses 130* Mac licenses
71 131
72orgstar+ for Mac comes with GitHub Sponsors: $60 once for a key that doesn't expire, or $5 a 132orgstar+ 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
95ORGSTAR_GATES=1 swift test -c release --filter GateTests # performance gates 155ORGSTAR_GATES=1 swift test -c release --filter GateTests # performance gates
96#+END_SRC 156#+END_SRC
97 157
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
98* Release 170* Release
99 171
100=scripts/release-mac.sh <version>= builds a universal app, signs it with the 172=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
105update window shows, and =ORGSTAR_RELEASE_NOTES= to a Markdown file for the gitbay 177update window shows, and =ORGSTAR_RELEASE_NOTES= to a Markdown file for the gitbay
106release. Without them both get the one-line platform note. 178release. Without them both get the one-line platform note.
107 179
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
109watch app, and uploads it to App Store Connect for TestFlight. It signs automatically with the 191watch app, and uploads it to App Store Connect for TestFlight. It signs automatically with the
110team's distribution certificate through the Apple ID signed in to Xcode (Xcode ▸ Settings ▸ 192team's distribution certificate through the Apple ID signed in to Xcode (Xcode ▸ Settings ▸
111Accounts), so it needs no key of its own. The version is the project's =MARKETING_VERSION=; 193Accounts), 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
114The script sources =release-ios.sh= from appstore-kit, checked out beside this repository or 196The script sources =release-ios.sh= from appstore-kit, checked out beside this repository or
115at =$APPSTORE_KIT=. 197at =$APPSTORE_KIT=.
116 198
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
117* App Store header 209* App Store header
118 210
119=ios/AppStore/header.conf= sets the product page header's background and screenshots; 211=ios/AppStore/header.conf= sets the product page header's background and screenshots;
Package.swift +5 −2
@@ -53,7 +53,7 @@ let package = Package(
53 .target(name: "OrgCore"), 53 .target(name: "OrgCore"),
54 .target(name: "OrgDocument", dependencies: ["OrgCore"]), 54 .target(name: "OrgDocument", dependencies: ["OrgCore"]),
55 .target(name: "OrgIndex", dependencies: ["OrgCore", .product(name: "GRDB", package: "GRDB.swift")]), 55 .target(name: "OrgIndex", dependencies: ["OrgCore", .product(name: "GRDB", package: "GRDB.swift")]),
56 .target(name: "OrgWorkspace", dependencies: ["OrgIndex"]), 56 .target(name: "OrgWorkspace", dependencies: ["OrgCore", "OrgIndex"]),
57 .target(name: "OrgPresentation", dependencies: ["OrgCore", .product(name: "SwiftMath", package: "SwiftMath")]), 57 .target(name: "OrgPresentation", dependencies: ["OrgCore", .product(name: "SwiftMath", package: "SwiftMath")]),
58 .target(name: "OrgEditorAppKit", dependencies: ["OrgDocument", "OrgPresentation"]), 58 .target(name: "OrgEditorAppKit", dependencies: ["OrgDocument", "OrgPresentation"]),
59 .target(name: "TreeSitterElisp", path: "Sources/TreeSitterElisp", sources: ["src/parser.c"], cSettings: [.headerSearchPath("src")]), 59 .target(name: "TreeSitterElisp", path: "Sources/TreeSitterElisp", sources: ["src/parser.c"], cSettings: [.headerSearchPath("src")]),
@@ -93,7 +93,9 @@ let package = Package(
93 // The watch app and its complications, bundled by scripts/build-watch-app.sh. 93 // The watch app and its complications, bundled by scripts/build-watch-app.sh.
94 .executableTarget(name: "OrgstarWatch", dependencies: ["OrgWatchData"]), 94 .executableTarget(name: "OrgstarWatch", dependencies: ["OrgWatchData"]),
95 .executableTarget(name: "OrgstarWatchWidgets", dependencies: ["OrgWatchData"]), 95 .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")]),
97 // The iOS app, bundled by scripts/build-ios-app.sh. 99 // The iOS app, bundled by scripts/build-ios-app.sh.
98 .executableTarget(name: "OrgstarMobile", dependencies: ["OrgApp", "OrgHighlight"]), 100 .executableTarget(name: "OrgstarMobile", dependencies: ["OrgApp", "OrgHighlight"]),
99 // App extensions, bundled into orgstar.app by scripts/build-app.sh. 101 // App extensions, bundled into orgstar.app by scripts/build-app.sh.
@@ -112,6 +114,7 @@ let package = Package(
112 .testTarget(name: "OrgPresentationTests", dependencies: ["OrgPresentation"]), 114 .testTarget(name: "OrgPresentationTests", dependencies: ["OrgPresentation"]),
113 .testTarget(name: "OrgEditorAppKitTests", dependencies: ["OrgEditorAppKit", "OrgApp"]), 115 .testTarget(name: "OrgEditorAppKitTests", dependencies: ["OrgEditorAppKit", "OrgApp"]),
114 .testTarget(name: "OrgAppTests", dependencies: ["OrgApp", "OrgDocument"]), 116 .testTarget(name: "OrgAppTests", dependencies: ["OrgApp", "OrgDocument"]),
117 .testTarget(name: "OrgProgramsTests", dependencies: ["OrgPrograms", "OrgApp", "OrgDocument"]),
115 .testTarget(name: "OrgHighlightTests", dependencies: ["OrgHighlight", "OrgCore", "OrgPresentation"]) 118 .testTarget(name: "OrgHighlightTests", dependencies: ["OrgHighlight", "OrgCore", "OrgPresentation"])
116 ] 119 ]
117) 120)
README.org +29 −17
@@ -10,8 +10,8 @@ iPad. It reads and writes the same plain-text =.org= files Emacs does, and leave
10byte you didn't change as it was, so Emacs, the Mac app, the iOS app and your sync tool 10byte you didn't change as it was, so Emacs, the Mac app, the iOS app and your sync tool
11can all work on the same folder. 11can all work on the same folder.
12 12
13[[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][App Store (Mac, iPhone and iPad)]] ·
13[[https://files.krz.sh/orgstar/][Download for Mac]] · 14[[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)]] ·
15[[https://files.krz.sh/orgstar/][Manual]] · 15[[https://files.krz.sh/orgstar/][Manual]] ·
16[[file:ios/AppStore/screenshots][Screenshots]] 16[[file:ios/AppStore/screenshots][Screenshots]]
17 17
@@ -36,8 +36,8 @@ Emacs tomorrow and nothing has been reformatted.
36- *Tables.* Aligned as you type, with =#+TBLFM= formulas. 36- *Tables.* Aligned as you type, with =#+TBLFM= formulas.
37- *Code blocks.* Run source blocks and tangle them into files, as =org-babel-tangle= 37- *Code blocks.* Run source blocks and tangle them into files, as =org-babel-tangle=
38 does. 38 does.
39- *Export.* HTML and Markdown built in; PDF, LaTeX, ODT and more through Emacs when 39- *Export.* HTML, Markdown, PDF, Word, RTF and iCalendar built in; PDF through LaTeX, ODT
40 it is installed. 40 and more through Emacs when it is installed (download version only).
41- *Search.* Across file names, headings and text, plus Spotlight and Quick Look 41- *Search.* Across file names, headings and text, plus Spotlight and Quick Look
42 previews of =.org= files. 42 previews of =.org= files.
43 43
@@ -48,16 +48,25 @@ folders, capture templates, key bindings and agenda views. Settings live in plai
48under =~/.config/orgstar/=, so they can sit in your dotfiles next to your Emacs config. 48under =~/.config/orgstar/=, so they can sit in your dotfiles next to your Emacs config.
49 49
50** Get it 50** Get it
51On the Mac (macOS 26 or later), with Homebrew: 51The Mac app (macOS 26 or later) comes in two versions:
52 52
53#+begin_src sh 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
54brew tap krz/tap https://gitbay.org/krz/homebrew-tap.git 54 Lisp blocks run in orgstar's own interpreter, other languages don't run, and nothing is
55brew install --cask orgstar 55 handed to Emacs. Folders outside the ones you add need your permission once.
56#+end_src 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:
57 59
58or download the notarized DMG from the 60 #+begin_src sh
59[[https://files.krz.sh/orgstar/][files.krz.sh/orgstar]]. The iPhone and iPad app (iOS 26 61 brew tap krz/tap https://gitbay.org/krz/homebrew-tap.git
60or later), with its Apple Watch app, is on the [[https://apps.apple.com/us/app/orgstar-org-mode-agenda/id6821552018][App Store]]. 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]].
61 70
62** orgstar+ 71** orgstar+
63Editing, the agenda, capture, clocking, tables, search, and HTML and Markdown export are 72Editing, 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
66backlinks; widgets, the Apple Watch app and the clock Live Activity; Calendar and Reminders in 75backlinks; widgets, the Apple Watch app and the clock Live Activity; Calendar and Reminders in
67the agenda; and Shortcuts actions. 76the agenda; and Shortcuts actions.
68 77
69- iPhone and iPad: in-app, $1.99 a month, $19.99 a year or $39.99 once. 78- iPhone, iPad and the Mac App Store version: in-app, $1.99 a month, $19.99 a year or $39.99
70- Mac: by [[https://github.com/sponsors/krazywarez][sponsoring on GitHub]], $60 once for a license key that doesn't expire, 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,
71 or $5 a month for a key orgstar renews while you sponsor. Sign in with GitHub at 81 or $5 a month for a key orgstar renews while you sponsor. Sign in with GitHub at
72 [[https://krz.sh/apps/orgstar/license][krz.sh/apps/orgstar/license]] for the key and enter it in Settings ▸ orgstar+. 82 [[https://krz.sh/apps/orgstar/license][krz.sh/apps/orgstar/license]] for the key and enter it in Settings ▸ orgstar+.
73 83
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.
75 86
76On iPhone and iPad, anyone can also leave a one-time tip in Settings ▸ About orgstar. Tips 87On iPhone and iPad, anyone can also leave a one-time tip in Settings ▸ About orgstar, and in
77unlock nothing. 88the Mac App Store version in Settings ▸ orgstar+. Tips unlock nothing.
78 89
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
80[[file:CONTRIBUTING.org]]. 92[[file:CONTRIBUTING.org]].
81 93
82Copyright © 2026 Christian Cleberg. All rights reserved; see [[file:LICENSE]]. 94Copyright © 2026 Christian Cleberg. All rights reserved; see [[file:LICENSE]].
Sources/OrgApp/AgendaFiles.swift +2 −1
@@ -1,4 +1,5 @@
1import Foundation 1import Foundation
2import OrgCore
2 3
3/// `org-agenda-files` as the `(org-agenda-files)` function reads it: each entry a folder (its 4/// `org-agenda-files` as the `(org-agenda-files)` function reads it: each entry a folder (its
4/// `.org` files not starting with a dot, in name order, not below it), an `.org` file, or a 5/// `.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 {
9 var out: [String] = [] 10 var out: [String] = []
10 var seen: Set<String> = [] 11 var seen: Set<String> = []
11 func expand(_ entry: String, from base: String?) -> String { 12 func expand(_ entry: String, from base: String?) -> String {
12 let path = (entry as NSString).expandingTildeInPath 13 let path = OrgPaths.expandingTilde(entry)
13 if path.hasPrefix("/") || base == nil { return (path as NSString).standardizingPath } 14 if path.hasPrefix("/") || base == nil { return (path as NSString).standardizingPath }
14 return ((base! as NSString).appendingPathComponent(path) as NSString).standardizingPath 15 return ((base! as NSString).appendingPathComponent(path) as NSString).standardizingPath
15 } 16 }
Sources/OrgApp/AgendaSnapshot.swift +12 −8
@@ -204,22 +204,26 @@ public struct AgendaSnapshot: Codable, Equatable, Sendable {
204 204
205 // MARK: - The file 205 // MARK: - The file
206 206
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
207 /// `Widgets/agenda.json` in the app group's container; nil without the group. On the Mac, 211 /// `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 212 /// unless `useGroupContainer`, in `~/Library/Application Support/Orgstar/Widgets`, which the
209 /// reads by a sandbox exception, as an app group there needs a provisioning profile. 213 /// sandboxed widget extension reads by a sandbox exception, as an app group there needs a
210 public static func file(group: String = CaptureInbox.group) -> URL? { 214 /// provisioning profile.
215 public static func file(group: String = CaptureInbox.group, inGroup: Bool = useGroupContainer) -> URL? {
211 #if os(macOS) 216 #if os(macOS)
212 return macWidgetsFolder.appendingPathComponent("agenda.json") 217 guard inGroup else { return macWidgetsFolder.appendingPathComponent("agenda.json") }
213 #else
214 FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group)?
215 .appendingPathComponent("Widgets").appendingPathComponent("agenda.json")
216 #endif 218 #endif
219 return FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: group)?
220 .appendingPathComponent("Widgets").appendingPathComponent("agenda.json")
217 } 221 }
218 222
219 #if os(macOS) 223 #if os(macOS)
220 /// From the account's home folder, not a sandbox container's. 224 /// From the account's home folder, not a sandbox container's.
221 static var macWidgetsFolder: URL { 225 static var macWidgetsFolder: URL {
222 let home = getpwuid(getuid())?.pointee.pw_dir.map { String(cString: $0) } ?? NSHomeDirectory() 226 let home = OrgPaths.home
223 return URL(fileURLWithPath: home).appendingPathComponent("Library/Application Support/Orgstar/Widgets") 227 return URL(fileURLWithPath: home).appendingPathComponent("Library/Application Support/Orgstar/Widgets")
224 } 228 }
225 #endif 229 #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 {
172 /// A template's file: absolute, `~/…`, or relative to `root`. 172 /// A template's file: absolute, `~/…`, or relative to `root`.
173 public static func resolve(_ file: String, root: String?) -> String { 173 public static func resolve(_ file: String, root: String?) -> String {
174 if file.hasPrefix("/") { return file } 174 if file.hasPrefix("/") { return file }
175 if file.hasPrefix("~") { return (file as NSString).expandingTildeInPath } 175 if file.hasPrefix("~") { return OrgPaths.expandingTilde(file) }
176 return ((root ?? NSHomeDirectory()) as NSString).appendingPathComponent(file) 176 return ((root ?? OrgPaths.home) as NSString).appendingPathComponent(file)
177 } 177 }
178 178
179 /// `%a`: a link to the heading at the caret, as `org-store-link` makes one. 179 /// `%a`: a link to the heading at the caret, as `org-store-link` makes one.
180 public func captureAnnotation() -> String { 180 public func captureAnnotation() -> String {
181 guard let path, self.document != nil else { return "" } 181 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)
183 guard let entry = outline.last(where: { $0.start <= caret }) else { return "[[file:\(abbreviated)]]" } 183 guard let entry = outline.last(where: { $0.start <= caret }) else { return "[[file:\(abbreviated)]]" }
184 return "[[file:\(abbreviated)::*\(entry.title)][\(entry.title)]]" 184 return "[[file:\(abbreviated)::*\(entry.title)][\(entry.title)]]"
185 } 185 }
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 {
20 /// The last file of the configuration folder that changed, with a serial number. 20 /// The last file of the configuration folder that changed, with a serial number.
21 public private(set) var changedFile: (name: String, serial: Int)? 21 public private(set) var changedFile: (name: String, serial: Int)?
22 22
23 private let url: URL 23 @ObservationIgnored private var url: URL
24 private let defaults: UserDefaults 24 private let defaults: UserDefaults
25 @ObservationIgnored private var text: String? 25 @ObservationIgnored private var text: String?
26 @ObservationIgnored private var configProblems: [String] = [] 26 @ObservationIgnored private var configProblems: [String] = []
@@ -28,6 +28,7 @@ public final class ConfigSync {
28 @ObservationIgnored private var watcher: FSEventsWatcher? 28 @ObservationIgnored private var watcher: FSEventsWatcher?
29 @ObservationIgnored private var observer: NSObjectProtocol? 29 @ObservationIgnored private var observer: NSObjectProtocol?
30 @ObservationIgnored private var serial = 0 30 @ObservationIgnored private var serial = 0
31 @ObservationIgnored private var watches = true
31 32
32 /// Where `url` leads: a symlinked config.toml is written through, not replaced by a file. 33 /// Where `url` leads: a symlinked config.toml is written through, not replaced by a file.
33 private var target: URL { url.resolvingSymlinksInPath() } 34 private var target: URL { url.resolvingSymlinksInPath() }
@@ -39,6 +40,7 @@ public final class ConfigSync {
39 40
40 public func start(watch: Bool = true) { 41 public func start(watch: Bool = true) {
41 guard observer == nil else { return } 42 guard observer == nil else { return }
43 watches = watch
42 try? FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true) 44 try? FileManager.default.createDirectory(at: url.deletingLastPathComponent(), withIntermediateDirectories: true)
43 let reference = url.deletingLastPathComponent().appendingPathComponent("default-theme.toml") 45 let reference = url.deletingLastPathComponent().appendingPathComponent("default-theme.toml")
44 if (try? String(contentsOf: reference, encoding: .utf8)) != ThemeSpec.defaultThemeFile() { 46 if (try? String(contentsOf: reference, encoding: .utf8)) != ThemeSpec.defaultThemeFile() {
@@ -71,7 +73,7 @@ public final class ConfigSync {
71 let watchesLinked = linked.path != directory.path 73 let watchesLinked = linked.path != directory.path
72 // Files still read from where earlier versions kept them reload when edited there too. 74 // Files still read from where earlier versions kept them reload when edited there too.
73 let legacy = UserConfig.legacyDirectory.resolvingSymlinksInPath() 75 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)
75 watcher = FSEventsWatcher(roots: [directory] + (watchesLinked ? [linked] : []) + (watchesLegacy ? [legacy] : [])) { [weak self] events in 77 watcher = FSEventsWatcher(roots: [directory] + (watchesLinked ? [linked] : []) + (watchesLegacy ? [legacy] : [])) { [weak self] events in
76 let changed = Set(events.compactMap { event -> URL? in 78 let changed = Set(events.compactMap { event -> URL? in
77 if case .changed(let url) = event { return url } 79 if case .changed(let url) = event { return url }
@@ -93,6 +95,24 @@ public final class ConfigSync {
93 watcher?.start() 95 watcher?.start()
94 } 96 }
95 97
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
96 /// Reads the file and applies it when it changed since the last read or write. 116 /// Reads the file and applies it when it changed since the last read or write.
97 public func reload() { 117 public func reload() {
98 guard let new = try? String(contentsOf: url, encoding: .utf8), new != text else { return } 118 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 {
73 interval: OrgPreferences.denoteJournalInterval(defaults))) 73 interval: OrgPreferences.denoteJournalInterval(defaults)))
74 } 74 }
75 let roam = OrgPreferences.roamDirectory(defaults) 75 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 }
77 return Dailies(directory: OrgAttach.expand(OrgPreferences.dailiesDirectory(defaults), in: base), 77 return Dailies(directory: OrgAttach.expand(OrgPreferences.dailiesDirectory(defaults), in: base),
78 file: OrgPreferences.dailiesFile(defaults), head: OrgPreferences.dailiesHead(defaults), entry: OrgPreferences.dailiesEntry(defaults)) 78 file: OrgPreferences.dailiesFile(defaults), head: OrgPreferences.dailiesHead(defaults), entry: OrgPreferences.dailiesEntry(defaults))
79 } 79 }
Sources/OrgApp/DenoteNote.swift +2 −2
@@ -25,12 +25,12 @@ public enum DenoteNote {
25 25
26 static func paths(_ setting: String, roots: [String]) -> [String] { 26 static func paths(_ setting: String, roots: [String]) -> [String] {
27 setting.split(separator: ":").map { $0.trimmingCharacters(in: .whitespaces) }.filter { !$0.isEmpty } 27 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) }
29 } 29 }
30 30
31 /// A folder as the folder prompts show it, under `~` when it's in the home folder. 31 /// A folder as the folder prompts show it, under `~` when it's in the home folder.
32 public static func abbreviated(_ path: String) -> String { 32 public static func abbreviated(_ path: String) -> String {
33 let home = NSHomeDirectory() 33 let home = OrgPaths.home
34 return path == home || path.hasPrefix(home + "/") ? "~" + path.dropFirst(home.count) : path 34 return path == home || path.hasPrefix(home + "/") ? "~" + path.dropFirst(home.count) : path
35 } 35 }
36 36
Sources/OrgApp/DocumentSession.swift +36 −12
@@ -752,6 +752,12 @@ public final class DocumentSession {
752 return (TextEdit(range: at..<at, replacement: insertion), newStart, level) 752 return (TextEdit(range: at..<at, replacement: insertion), newStart, level)
753 } 753 }
754 754
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
755 /// Archives the subtree at the caret, or at `from`, where `org-archive-subtree` would. 761 /// Archives the subtree at the caret, or at `from`, where `org-archive-subtree` would.
756 /// Returns a message. 762 /// Returns a message.
757 @discardableResult 763 @discardableResult
@@ -877,7 +883,13 @@ public final class DocumentSession {
877 /// Recalculates a table in Emacs from a snapshot of the buffer, then replaces the table 883 /// Recalculates a table in Emacs from a snapshot of the buffer, then replaces the table
878 /// with Emacs's text if it hasn't changed meanwhile. Returns a message for the echo area. 884 /// with Emacs's text if it hasn't changed meanwhile. Returns a message for the echo area.
879 public func recalculateInEmacs(table: Range<Int>, point: Int, form: String) async -> String { 885 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 }
881 guard let entry = current else { return "No file is open." } 893 guard let entry = current else { return "No file is open." }
882 let path = entry.path 894 let path = entry.path
883 let snapshot = entry.buffer.document.text as NSString 895 let snapshot = entry.buffer.document.text as NSString
@@ -885,7 +897,7 @@ public final class DocumentSession {
885 let old = snapshot.substring(with: NSRange(table)) 897 let old = snapshot.substring(with: NSRange(table))
886 let directory = URL(fileURLWithPath: path).deletingLastPathComponent() 898 let directory = URL(fileURLWithPath: path).deletingLastPathComponent()
887 do { 899 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)
889 guard entries.contains(where: { $0 === entry }) else { return "The file was closed before Emacs finished." } 901 guard entries.contains(where: { $0 === entry }) else { return "The file was closed before Emacs finished." }
890 let current = entry.buffer 902 let current = entry.buffer
891 let text = current.document.text as NSString 903 let text = current.document.text as NSString
@@ -902,9 +914,6 @@ public final class DocumentSession {
902 } catch { 914 } catch {
903 return "\(error)" 915 return "\(error)"
904 } 916 }
905 #else
906 return "Tables that need Emacs aren't recalculated on iOS."
907 #endif
908 } 917 }
909 918
910 /// Runs a src block and writes its result under it, unless the block changed while it 919 /// Runs a src block and writes its result under it, unless the block changed while it
@@ -912,18 +921,22 @@ public final class DocumentSession {
912 public func runBabel(_ job: BabelJob) async -> String { 921 public func runBabel(_ job: BabelJob) async -> String {
913 guard let entry = current else { return "No file is open." } 922 guard let entry = current else { return "No file is open." }
914 let directory = URL(fileURLWithPath: entry.path).deletingLastPathComponent() 923 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.
916 func run(_ job: BabelJob) async throws -> BabelOutput { 926 func run(_ job: BabelJob) async throws -> BabelOutput {
917 #if os(macOS) 927 if let programs { return try await programs.runBabel(job, fileDirectory: directory) }
918 return try await BabelRunner.run(job, fileDirectory: directory)
919 #else
920 guard let output = try Babel.evaluateNatively(job) else { 928 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
921 throw Babel.Failure.message(job.lispForm == nil 934 throw Babel.Failure.message(job.lispForm == nil
922 ? "\(job.language) blocks need the Mac to run." 935 ? "\(job.language) blocks need the Mac to run."
923 : "This block uses Emacs Lisp that runs only in Emacs, on the Mac.") 936 : "This block uses Emacs Lisp that runs only in Emacs, on the Mac.")
937 #endif
924 } 938 }
925 return output 939 return output
926 #endif
927 } 940 }
928 do { 941 do {
929 // Blocks the `:var`s refer to run first, one at a time. 942 // Blocks the `:var`s refer to run first, one at a time.
@@ -953,8 +966,7 @@ public final class DocumentSession {
953 let output = try await run(job) 966 let output = try await run(job)
954 guard entries.contains(where: { $0 === entry }) else { return "The file was closed before the block finished." } 967 guard entries.contains(where: { $0 === entry }) else { return "The file was closed before the block finished." }
955 if let file = Babel.fileResult(job, output: output) { 968 if let file = Babel.fileResult(job, output: output) {
956 let runDirectory = job.directory.map { URL(fileURLWithPath: $0, relativeTo: directory).standardizedFileURL } ?? directory 969 let target = Self.resultFile(file.path, job: job, directory: directory)
957 let target = file.path.hasPrefix("/") ? URL(fileURLWithPath: file.path) : runDirectory.appendingPathComponent(file.path)
958 do { 970 do {
959 try file.contents.write(to: target, atomically: true, encoding: .utf8) 971 try file.contents.write(to: target, atomically: true, encoding: .utf8)
960 } catch { 972 } catch {
@@ -983,6 +995,18 @@ public final class DocumentSession {
983 } 995 }
984 } 996 }
985 997
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
986 /// The block running now, to cancel. 1010 /// The block running now, to cancel.
987 @ObservationIgnored private var babelTask: Task<String, Never>? 1011 @ObservationIgnored private var babelTask: Task<String, Never>?
988 public private(set) var isRunningBabel = false 1012 public private(set) var isRunningBabel = false
Sources/OrgApp/EmacsImport.swift +57 −12
@@ -55,6 +55,8 @@ public struct EmacsImport: Sendable {
55 /// Doom's own org defaults Orgstar has no use for, not listed one by one. 55 /// Doom's own org defaults Orgstar has no use for, not listed one by one.
56 public var doomDefaultsLeftOut = 0 56 public var doomDefaultsLeftOut = 0
57 public var isDoom = false 57 public var isDoom = false
58 /// Doom's own org defaults were found and read.
59 public var doomDefaultsRead = false
58 60
59 // MARK: - Finding the configuration 61 // MARK: - Finding the configuration
60 62
@@ -71,7 +73,7 @@ public struct EmacsImport: Sendable {
71 73
72 /// Where an Emacs configuration usually is, first found first. 74 /// Where an Emacs configuration usually is, first found first.
73 public static func defaultLocations() -> [URL] { 75 public static func defaultLocations() -> [URL] {
74 let home = URL(fileURLWithPath: NSHomeDirectory()) 76 let home = URL(fileURLWithPath: OrgPaths.home)
75 let environment = ProcessInfo.processInfo.environment 77 let environment = ProcessInfo.processInfo.environment
76 var candidates: [URL] = [] 78 var candidates: [URL] = []
77 if let doom = environment["DOOMDIR"] { candidates.append(URL(fileURLWithPath: doom)) } 79 if let doom = environment["DOOMDIR"] { candidates.append(URL(fileURLWithPath: doom)) }
@@ -80,6 +82,19 @@ public struct EmacsImport: Sendable {
80 return candidates.filter { !files(in: $0).isEmpty && !isDoomInstall($0) } 82 return candidates.filter { !files(in: $0).isEmpty && !isDoomInstall($0) }
81 } 83 }
82 84
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
83 /// Doom's own source folder, which holds `lisp/doom.el`, isn't a user configuration. 98 /// Doom's own source folder, which holds `lisp/doom.el`, isn't a user configuration.
84 static func isDoomInstall(_ url: URL) -> Bool { 99 static func isDoomInstall(_ url: URL) -> Bool {
85 FileManager.default.fileExists(atPath: url.appendingPathComponent("lisp/doom.el").path) 100 FileManager.default.fileExists(atPath: url.appendingPathComponent("lisp/doom.el").path)
@@ -87,11 +102,13 @@ public struct EmacsImport: Sendable {
87 102
88 /// Doom's org module and core defaults, if Doom is installed. 103 /// Doom's org module and core defaults, if Doom is installed.
89 static func doomDefaultFiles() -> [URL] { 104 static func doomDefaultFiles() -> [URL] {
90 let home = URL(fileURLWithPath: NSHomeDirectory()) 105 guard let install = doomInstallLocations().first(where: isDoomInstall) else { return [] }
91 let environment = ProcessInfo.processInfo.environment 106 return doomDefaultFiles(in: install)
92 let installs = ([environment["EMACSDIR"]].compactMap { $0 }.map { URL(fileURLWithPath: $0) }) 107 }
93 + [".config/emacs", ".emacs.d"].map { home.appendingPathComponent($0) } 108
94 guard let install = installs.first(where: isDoomInstall) else { return [] } 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 [] }
95 var files = [install.appendingPathComponent("lisp/doom-emacs.el")] 112 var files = [install.appendingPathComponent("lisp/doom-emacs.el")]
96 var moduleRoots = [install.appendingPathComponent("modules")] 113 var moduleRoots = [install.appendingPathComponent("modules")]
97 if let sources = try? FileManager.default.contentsOfDirectory(at: install.appendingPathComponent("sources"), includingPropertiesForKeys: nil) { 114 if let sources = try? FileManager.default.contentsOfDirectory(at: install.appendingPathComponent("sources"), includingPropertiesForKeys: nil) {
@@ -119,7 +136,10 @@ public struct EmacsImport: Sendable {
119 result.isDoom = sources.contains { $0.text.contains("(doom!") || $0.text.contains("(map! ") || $0.text.contains("(after! ") } 136 result.isDoom = sources.contains { $0.text.contains("(doom!") || $0.text.contains("(map! ") || $0.text.contains("(after! ") }
120 if result.isDoom { 137 if result.isDoom {
121 for url in doomDefaults ?? doomDefaultFiles() { 138 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 }
123 } 143 }
124 } 144 }
125 var scanner = Scanner() 145 var scanner = Scanner()
@@ -469,7 +489,7 @@ public struct EmacsImport: Sendable {
469 var folders: Set<String> = [] 489 var folders: Set<String> = []
470 items.removeAll { item in 490 items.removeAll { item in
471 guard case .folder(let path) = item.change else { return false } 491 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: "/"))
473 return !folders.insert(key).inserted 493 return !folders.insert(key).inserted
474 } 494 }
475 for binding in scanner.bindings { 495 for binding in scanner.bindings {
@@ -1064,16 +1084,33 @@ public struct EmacsImport: Sendable {
1064} 1084}
1065 1085
1066extension EmacsImport { 1086extension 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
1067 /// Applies `items`: settings to `defaults` (and so config.toml), folders to the workspace, 1103 /// Applies `items`: settings to `defaults` (and so config.toml), folders to the workspace,
1068 /// capture templates and key bindings appended to capture.toml and keymap.toml in 1104 /// capture templates and key bindings appended to capture.toml and keymap.toml in
1069 /// `directory`, leaving out templates whose key is there already and bindings that are 1105 /// `directory`, leaving out templates whose key is there already and bindings that are
1070 /// there already. Returns a summary. 1106 /// there already. Returns a summary.
1071 @MainActor 1107 @MainActor
1072 /// With `writeConfig`, settings and structure templates are written into `config.toml` too, 1108 /// 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.
1074 public static func apply( 1111 public static func apply(
1075 _ items: [Item], defaults: UserDefaults = .standard, workspace: WorkspaceModel?, directory: URL = UserConfig.directory, 1112 _ items: [Item], defaults: UserDefaults = .standard, workspace: WorkspaceModel?, directory: URL = UserConfig.directory,
1076 writeConfig: Bool = false 1113 writeConfig: Bool = false, chosenFolders: [String: URL]? = nil
1077 ) async -> String { 1114 ) async -> String {
1078 var stored: [UserConfig.Setting] = [] 1115 var stored: [UserConfig.Setting] = []
1079 var settings = 0, folders = 0, templates = 0, bindings = 0, blocks = 0, views = 0, projects = 0 1116 var settings = 0, folders = 0, templates = 0, bindings = 0, blocks = 0, views = 0, projects = 0
@@ -1090,12 +1127,20 @@ extension EmacsImport {
1090 } 1127 }
1091 for item in items { 1128 for item in items {
1092 guard case .folder(let path) = item.change else { continue } 1129 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 }
1094 guard let workspace, FileManager.default.fileExists(atPath: url.path) else { 1139 guard let workspace, FileManager.default.fileExists(atPath: url.path) else {
1095 problems.append("\(path) doesn't exist") 1140 problems.append("\(path) doesn't exist")
1096 continue 1141 continue
1097 } 1142 }
1098 if workspace.roots.contains(where: { URL(fileURLWithPath: $0.path).standardizedFileURL.path == url.path }) { continue } 1143 if Self.isRoot(url, in: workspace) { continue }
1099 do { 1144 do {
1100 try await workspace.addRoot(url) 1145 try await workspace.addRoot(url)
1101 folders += 1 1146 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 {
48 /// file's folder, else absolute with `~` for the home folder. 48 /// file's folder, else absolute with `~` for the home folder.
49 static func fileLink(_ path: String, from orgPath: String) -> String { 49 static func fileLink(_ path: String, from orgPath: String) -> String {
50 let folder = (orgPath as NSString).deletingLastPathComponent + "/" 50 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)
52 return "[[file:\(target)]]" 52 return "[[file:\(target)]]"
53 } 53 }
54 54
55 /// The folder a `directory` method names, made if missing. 55 /// The folder a `directory` method names, made if missing.
56 static func folder(_ dir: String, for entry: Attachments.Entry) throws -> String { 56 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)
58 try FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: true) 58 try FileManager.default.createDirectory(atPath: folder, withIntermediateDirectories: true)
59 return folder 59 return folder
60 } 60 }
Sources/OrgApp/LinkFollow.swift +2 −2
@@ -83,9 +83,9 @@ extension DocumentSession {
83 83
84 /// A file link's path against the open file's folder, as Org resolves relative links. 84 /// A file link's path against the open file's folder, as Org resolves relative links.
85 public static func resolve(_ path: String, from current: String?) -> String { 85 public static func resolve(_ path: String, from current: String?) -> String {
86 let expanded = (path as NSString).expandingTildeInPath 86 let expanded = OrgPaths.expandingTilde(path)
87 if expanded.hasPrefix("/") { return (expanded as NSString).standardizingPath } 87 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
89 return ((folder as NSString).appendingPathComponent(expanded) as NSString).standardizingPath 89 return ((folder as NSString).appendingPathComponent(expanded) as NSString).standardizingPath
90 } 90 }
91 91
Sources/OrgApp/OrgPreferences.swift +1 −1
@@ -221,7 +221,7 @@ public enum OrgPreferences {
221 } 221 }
222 /// `org-icalendar-combined-agenda-file`, `~` expanded. 222 /// `org-icalendar-combined-agenda-file`, `~` expanded.
223 public static func icalendarCombinedFile(_ defaults: UserDefaults = .standard) -> String { 223 public static func icalendarCombinedFile(_ defaults: UserDefaults = .standard) -> String {
224 (string("icalendarCombinedAgendaFile", defaults) as NSString).expandingTildeInPath 224 OrgPaths.expandingTilde(string("icalendarCombinedAgendaFile", defaults))
225 } 225 }
226 /// `org-stuck-projects`. 226 /// `org-stuck-projects`.
227 public static func stuckProjects(_ defaults: UserDefaults = .standard) -> StuckProjects { 227 public static func stuckProjects(_ defaults: UserDefaults = .standard) -> StuckProjects {
Sources/OrgApp/PDFExport.swift +55 −3
@@ -1,5 +1,7 @@
1import Foundation 1import Foundation
2import OrgCore
2import PDFKit 3import PDFKit
4import UniformTypeIdentifiers
3import WebKit 5import WebKit
4#if os(macOS) 6#if os(macOS)
5import AppKit 7import AppKit
@@ -39,6 +41,53 @@ public enum PDFExport {
39 return printCSS.replacingOccurrences(of: "</style>", with: "body { font-family: \"\(family)\", -apple-system, sans-serif; }\n</style>") 41 return printCSS.replacingOccurrences(of: "</style>", with: "body { font-family: \"\(family)\", -apple-system, sans-serif; }\n</style>")
40 } 42 }
41 43
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
42 /// Each page's number, centred in its bottom margin, as an annotation: drawing it into the 91 /// Each page's number, centred in its bottom margin, as an annotation: drawing it into the
43 /// page would mean drawing the page again and losing WebKit's links. 92 /// page would mean drawing the page again and losing WebKit's links.
44 static func numberPages(_ data: Data, margin: Int) -> Data { 93 static func numberPages(_ data: Data, margin: Int) -> Data {
@@ -85,14 +134,17 @@ public enum PDFExport {
85 webView.navigationDelegate = loader 134 webView.navigationDelegate = loader
86 #if os(macOS) 135 #if os(macOS)
87 webView.appearance = NSAppearance(named: .aqua) 136 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
89 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-pdf-\(UUID().uuidString)") 140 let folder = FileManager.default.temporaryDirectory.appendingPathComponent("orgstar-pdf-\(UUID().uuidString)")
90 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true) 141 try FileManager.default.createDirectory(at: folder, withIntermediateDirectories: true)
91 defer { try? FileManager.default.removeItem(at: folder) } 142 defer { try? FileManager.default.removeItem(at: folder) }
92 let file = folder.appendingPathComponent("page.html") 143 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
94 try based.write(to: file, atomically: true, encoding: .utf8) 146 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: "/"))
96 #else 148 #else
97 webView.overrideUserInterfaceStyle = .light 149 webView.overrideUserInterfaceStyle = .light
98 webView.loadHTMLString(page, baseURL: directory) 150 webView.loadHTMLString(page, baseURL: directory)
Sources/OrgApp/PlotChart.swift +4 −46
@@ -216,13 +216,15 @@ struct Wireframe: View {
216public enum PlotOutput { 216public enum PlotOutput {
217 public struct Failure: Error, CustomStringConvertible { 217 public struct Failure: Error, CustomStringConvertible {
218 public let description: String 218 public let description: String
219
220 public init(description: String) { self.description = description }
219 } 221 }
220 222
221 /// `file:` relative to the Org file's folder. 223 /// `file:` relative to the Org file's folder.
222 public static func file(_ plot: TablePlot.Plot, directory: URL?) -> URL? { 224 public static func file(_ plot: TablePlot.Plot, directory: URL?) -> URL? {
223 guard let name = plot.options.file, !name.isEmpty else { return nil } 225 guard let name = plot.options.file, !name.isEmpty else { return nil }
224 let expanded = (name as NSString).expandingTildeInPath 226 let expanded = OrgPaths.expandingTilde(name)
225 return expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : (directory ?? URL(fileURLWithPath: NSHomeDirectory())).appendingPathComponent(expanded) 227 return expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : (directory ?? URL(fileURLWithPath: OrgPaths.home)).appendingPathComponent(expanded)
226 } 228 }
227 229
228 /// The chart as gnuplot's default 640×480, as PNG, JPEG or PDF by the file's extension. 230 /// 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 {
254 throw Failure(description: "Without gnuplot, plots are written as .png, .jpg or .pdf, not .\(url.pathExtension)") 256 throw Failure(description: "Without gnuplot, plots are written as .png, .jpg or .pdf, not .\(url.pathExtension)")
255 } 257 }
256 } 258 }
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
301} 259}
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 {
91 /// Absolute, `~/…`, or relative to `root`. 91 /// Absolute, `~/…`, or relative to `root`.
92 static func resolve(_ path: String, root: String?) -> String { 92 static func resolve(_ path: String, root: String?) -> String {
93 if path.hasPrefix("/") { return path } 93 if path.hasPrefix("/") { return path }
94 if path.hasPrefix("~") { return (path as NSString).expandingTildeInPath } 94 if path.hasPrefix("~") { return OrgPaths.expandingTilde(path) }
95 return ((root ?? NSHomeDirectory()) as NSString).appendingPathComponent(path) 95 return ((root ?? OrgPaths.home) as NSString).appendingPathComponent(path)
96 } 96 }
97 97
98 public struct Failure: Error, Equatable, CustomStringConvertible { 98 public struct Failure: Error, Equatable, CustomStringConvertible {
Sources/OrgApp/RefileTargets.swift +1 −1
@@ -185,7 +185,7 @@ extension WorkspaceModel {
185 case .paths(let list): 185 case .paths(let list):
186 let base = openPath.map { ($0 as NSString).deletingLastPathComponent } ?? rootPaths.first 186 let base = openPath.map { ($0 as NSString).deletingLastPathComponent } ?? rootPaths.first
187 paths = list.map { entry in 187 paths = list.map { entry in
188 let path = (entry as NSString).expandingTildeInPath 188 let path = OrgPaths.expandingTilde(entry)
189 return ((path.hasPrefix("/") || base == nil ? path : (base! as NSString).appendingPathComponent(path)) as NSString).standardizingPath 189 return ((path.hasPrefix("/") || base == nil ? path : (base! as NSString).appendingPathComponent(path)) as NSString).standardizingPath
190 } 190 }
191 } 191 }
Sources/OrgApp/RoamActions.swift +7
@@ -21,6 +21,9 @@ public struct RoamActions {
21 public var insertLink: (_ link: String, _ title: String) -> Void 21 public var insertLink: (_ link: String, _ title: String) -> Void
22 /// The index reads new files. 22 /// The index reads new files.
23 public var refresh: () -> Void 23 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 }
24 27
25 public init( 28 public init(
26 session: DocumentSession, roots: @escaping () -> [String], nodes: @escaping () -> [IndexStore.Node], show: @escaping (String) -> Void, 29 session: DocumentSession, roots: @escaping () -> [String], nodes: @escaping () -> [IndexStore.Node], show: @escaping (String) -> Void,
@@ -126,6 +129,7 @@ public struct RoamActions {
126 /// `org-roam-dailies-goto-*`: the day's file, made if missing. 129 /// `org-roam-dailies-goto-*`: the day's file, made if missing.
127 func goto(_ day: Date) { 130 func goto(_ day: Date) {
128 guard let dailies else { return show("No folder for daily notes") } 131 guard let dailies else { return show("No folder for daily notes") }
132 guard reachFolders([dailies.directory]) else { return }
129 do { 133 do {
130 let (path, created) = try dailies.ensure(day) 134 let (path, created) = try dailies.ensure(day)
131 if created { refresh() } 135 if created { refresh() }
@@ -139,6 +143,7 @@ public struct RoamActions {
139 /// which opens with the caret at `%?`. 143 /// which opens with the caret at `%?`.
140 func capture(_ day: Date) { 144 func capture(_ day: Date) {
141 guard let dailies else { return show("No folder for daily notes") } 145 guard let dailies else { return show("No folder for daily notes") }
146 guard reachFolders([dailies.directory]) else { return }
142 let context = CaptureContext(now: day, file: session.path ?? "", userName: NSFullUserName()) 147 let context = CaptureContext(now: day, file: session.path ?? "", userName: NSFullUserName())
143 let questions = Capture.questions(dailies.entry, context: context) 148 let questions = Capture.questions(dailies.entry, context: context)
144 func ask(_ answers: [String]) { 149 func ask(_ answers: [String]) {
@@ -193,6 +198,7 @@ public struct RoamActions {
193 guard !title.isEmpty else { return } 198 guard !title.isEmpty else { return }
194 if denote || silo != nil { return createDenote(title, known: all, silo: silo, then) } 199 if denote || silo != nil { return createDenote(title, known: all, silo: silo, then) }
195 guard let folder = RoamNode.directory(roots: roots()) else { return show("No folder for new nodes") } 200 guard let folder = RoamNode.directory(roots: roots()) else { return show("No folder for new nodes") }
201 guard reachFolders([folder]) else { return }
196 do { 202 do {
197 let node = try RoamNode.create(title: title, in: folder) 203 let node = try RoamNode.create(title: title, in: folder)
198 refresh() 204 refresh()
@@ -240,6 +246,7 @@ public struct RoamActions {
240 var answers = answers 246 var answers = answers
241 switch prompts.first { 247 switch prompts.first {
242 case nil: 248 case nil:
249 guard reachFolders([answers.folder ?? root]) else { return }
243 do { 250 do {
244 let note = try DenoteNote.create(title: title, keywords: answers.keywords, in: answers.folder ?? root, roots: roots, 251 let note = try DenoteNote.create(title: title, keywords: answers.keywords, in: answers.folder ?? root, roots: roots,
245 now: answers.date ?? Date(), signature: answers.signature, template: answers.template) 252 now: answers.date ?? Date(), signature: answers.signature, template: answers.template)
Sources/OrgApp/RoamNode.swift +1 −1
@@ -8,7 +8,7 @@ public enum RoamNode {
8 /// `org-roam-directory`: the setting, else the first folder. 8 /// `org-roam-directory`: the setting, else the first folder.
9 public static func directory(roots: [String], defaults: UserDefaults = .standard) -> String? { 9 public static func directory(roots: [String], defaults: UserDefaults = .standard) -> String? {
10 let roam = OrgPreferences.roamDirectory(defaults) 10 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)
12 } 12 }
13 13
14 /// `org-roam-node-slugify`: without the combining marks org-roam drops, everything but 14 /// `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
3 3
4/// Writes what `Tangle.run` produced, as `org-babel-tangle` does: a file whose contents 4/// Writes what `Tangle.run` produced, as `org-babel-tangle` does: a file whose contents
5/// haven't changed is left alone, `:mkdirp` makes its folder, a read-only file is replaced, 5/// 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.
7public enum TangleWriter { 7public enum TangleWriter {
8 public struct Failure: Error, Equatable { 8 public struct Failure: Error, Equatable {
9 public let message: String 9 public let message: String
@@ -14,6 +14,7 @@ public enum TangleWriter {
14 public static func write(_ output: Tangle.Output, source: String) throws(Failure) -> [String] { 14 public static func write(_ output: Tangle.Output, source: String) throws(Failure) -> [String] {
15 let manager = FileManager.default 15 let manager = FileManager.default
16 var paths: [String] = [] 16 var paths: [String] = []
17 var modeFailure: Failure?
17 for file in output.files { 18 for file in output.files {
18 let url = URL(fileURLWithPath: file.path) 19 let url = URL(fileURLWithPath: file.path)
19 let data = Data(file.contents.utf8) 20 let data = Data(file.contents.utf8)
@@ -37,12 +38,19 @@ public enum TangleWriter {
37 } 38 }
38 do { 39 do {
39 try data.write(to: url) 40 try data.write(to: url)
40 if let mode = file.mode { try manager.setAttributes([.posixPermissions: mode], ofItemAtPath: file.path) }
41 } catch { 41 } catch {
42 throw Failure(message: "Can't write \(file.path): \(error.localizedDescription)") 42 throw Failure(message: "Can't write \(file.path): \(error.localizedDescription)")
43 } 43 }
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 }
44 paths.append(file.path) 51 paths.append(file.path)
45 } 52 }
53 if let modeFailure { throw modeFailure }
46 return paths 54 return paths
47 } 55 }
48 56
@@ -53,6 +61,12 @@ public enum TangleWriter {
53} 61}
54 62
55extension DocumentSession { 63extension 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
56 /// Tangles the open file: its text as it is now, written beside it. 70 /// Tangles the open file: its text as it is now, written beside it.
57 public func tangle(_ scope: Tangle.Scope) -> String { 71 public func tangle(_ scope: Tangle.Scope) -> String {
58 guard let path, let document else { return "No file is open" } 72 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 {
13 13
14 public static var directory: URL { 14 public static var directory: URL {
15 if let directoryOverride { return directoryOverride } 15 if let directoryOverride { return directoryOverride }
16 let environment = ProcessInfo.processInfo.environment 16 return defaultDirectory(environment: ProcessInfo.processInfo.environment, home: NSHomeDirectory(), sandboxed: Sandbox.isActive)
17 if let override = environment["ORGSTAR_CONFIG_DIR"] { return URL(fileURLWithPath: override) } 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) }
18 // Development runs keep everything in their data folder. 27 // Development runs keep everything in their data folder.
19 if let data = environment["ORGSTAR_DATA_DIR"] { return URL(fileURLWithPath: data) } 28 if let data = environment["ORGSTAR_DATA_DIR"], usable(data) { return URL(fileURLWithPath: data) }
20 if let xdg = environment["XDG_CONFIG_HOME"], !xdg.isEmpty { 29 if let xdg = environment["XDG_CONFIG_HOME"], !xdg.isEmpty, usable(xdg) {
21 return URL(fileURLWithPath: xdg).appendingPathComponent("orgstar") 30 return URL(fileURLWithPath: xdg).appendingPathComponent("orgstar")
22 } 31 }
23 return URL(fileURLWithPath: NSHomeDirectory()).appendingPathComponent(".config/orgstar") 32 return URL(fileURLWithPath: home).appendingPathComponent(".config/orgstar")
24 } 33 }
25 34
26 /// The theme `config.toml` (`text`) sets: its `[theme]` tables' colors over those of 35 /// 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 {
31 private let rootsFile: URL 31 private let rootsFile: URL
32 /// Resolved root folders, keyed by their resolved path, which is how the index stores them. 32 /// Resolved root folders, keyed by their resolved path, which is how the index stores them.
33 private var resolvedRoots: [String: URL] = [:] 33 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] = []
34 @ObservationIgnored private var watcher: AnyObject? 37 @ObservationIgnored private var watcher: AnyObject?
35 /// Watchers of the roots where there are no FSEvents. 38 /// Watchers of the roots where there are no FSEvents.
36 @ObservationIgnored private var presenters: [FolderPresenter] = [] 39 @ObservationIgnored private var presenters: [FolderPresenter] = []
@@ -92,6 +95,17 @@ public final class WorkspaceModel {
92 await refresh() 95 await refresh()
93 } 96 }
94 97
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
95 /// Removes a root by its resolved path, as `FileEntry.root` gives it. 109 /// Removes a root by its resolved path, as `FileEntry.root` gives it.
96 public func removeRoot(path: String) throws { 110 public func removeRoot(path: String) throws {
97 let bookmarkPaths = roots.filter { (try? $0.resolve().url.path) == path || $0.path == path }.map(\.path) 111 let bookmarkPaths = roots.filter { (try? $0.resolve().url.path) == path || $0.path == path }.map(\.path)
@@ -116,10 +130,12 @@ public final class WorkspaceModel {
116 /// Resolves bookmarks; refreshes stale ones; reports folders that can't be found. 130 /// Resolves bookmarks; refreshes stale ones; reports folders that can't be found.
117 private func resolveRoots() { 131 private func resolveRoots() {
118 resolvedRoots = [:] 132 resolvedRoots = [:]
133 unresolvedRoots = []
119 var refreshed = roots 134 var refreshed = roots
120 for (i, root) in roots.enumerated() { 135 for (i, root) in roots.enumerated() {
121 guard let (url, isStale) = try? root.resolve() else { 136 guard let (url, isStale) = try? root.resolve() else {
122 lastError = "Can't find the folder \(root.path)." 137 lastError = "Can't find the folder \(root.path)."
138 unresolvedRoots.append(root)
123 continue 139 continue
124 } 140 }
125 if isStale, let fresh = try? WorkspaceRoot(url: url) { refreshed[i] = fresh } 141 if isStale, let fresh = try? WorkspaceRoot(url: url) { refreshed[i] = fresh }
@@ -136,6 +152,60 @@ public final class WorkspaceModel {
136 /// Resolved root paths, sorted. 152 /// Resolved root paths, sorted.
137 public var rootPaths: [String] { resolvedRoots.keys.sorted() } 153 public var rootPaths: [String] { resolvedRoots.keys.sorted() }
138 154
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
139 // MARK: - Indexing 209 // MARK: - Indexing
140 210
141 /// Which files the folders show; a change rescans them. 211 /// Which files the folders show; a change rescans them.
Sources/OrgCore/Capture/Capture.swift +2 −2
@@ -171,7 +171,7 @@ public struct CaptureContext: Sendable {
171 public var linkProperties: [String: String] = [:] 171 public var linkProperties: [String: String] = [:]
172 /// `%[file]`: what relative paths are relative to, and the contents of a file by its 172 /// `%[file]`: what relative paths are relative to, and the contents of a file by its
173 /// absolute path, nil when it can't be read. 173 /// absolute path, nil when it can't be read.
174 public var directory = NSHomeDirectory() 174 public var directory = OrgPaths.home
175 public var readFile: @Sendable (String) -> String? = { _ in nil } 175 public var readFile: @Sendable (String) -> String? = { _ in nil }
176 176
177 public init( 177 public init(
@@ -390,7 +390,7 @@ public enum Capture {
390 buffer.release(end) 390 buffer.release(end)
391 } 391 }
392 if unescape(buffer, at: start.position) { continue } 392 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
394 let path = ((expanded as NSString).isAbsolutePath ? expanded : (context.directory as NSString).appendingPathComponent(expanded) as String) 394 let path = ((expanded as NSString).isAbsolutePath ? expanded : (context.directory as NSString).appendingPathComponent(expanded) as String)
395 let file = (path as NSString).standardizingPath 395 let file = (path as NSString).standardizingPath
396 buffer.deleteRegion(start.position, end.position) 396 buffer.deleteRegion(start.position, end.position)
Sources/OrgCore/Commands/Archive.swift +3 −3
@@ -199,7 +199,7 @@ public enum Archive {
199 if fileFormat.contains(where: { !$0.isWhitespace }) { 199 if fileFormat.contains(where: { !$0.isWhitespace }) {
200 let file = fileFormat.replacingOccurrences(of: "%s", with: name) 200 let file = fileFormat.replacingOccurrences(of: "%s", with: name)
201 let directory = (sourcePath as NSString).deletingLastPathComponent 201 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)
203 } else { 203 } else {
204 path = sourcePath 204 path = sourcePath
205 } 205 }
@@ -215,7 +215,7 @@ public enum Archive {
215 guard fileFormat.contains(where: { !$0.isWhitespace }) else { return sourcePath } 215 guard fileFormat.contains(where: { !$0.isWhitespace }) else { return sourcePath }
216 let file = fileFormat.replacingOccurrences(of: "%s", with: (sourcePath as NSString).lastPathComponent) 216 let file = fileFormat.replacingOccurrences(of: "%s", with: (sourcePath as NSString).lastPathComponent)
217 let directory = (sourcePath as NSString).deletingLastPathComponent 217 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)
219 return (path as NSString).standardizingPath 219 return (path as NSString).standardizingPath
220 } 220 }
221 221
@@ -258,7 +258,7 @@ public enum Archive {
258 258
259 /// `~/` for paths in the home folder, as `abbreviate-file-name`. 259 /// `~/` for paths in the home folder, as `abbreviate-file-name`.
260 static func abbreviate(_ path: String) -> String { 260 static func abbreviate(_ path: String) -> String {
261 let home = NSHomeDirectory() 261 let home = OrgPaths.home
262 return path.hasPrefix(home + "/") ? "~" + path.dropFirst(home.count) : path 262 return path.hasPrefix(home + "/") ? "~" + path.dropFirst(home.count) : path
263 } 263 }
264 264
Sources/OrgCore/Commands/Attach.swift +1 −1
@@ -17,7 +17,7 @@ public enum OrgAttach {
17 17
18 /// `expand-file-name` of `path` in `folder`: `.` and `..` resolved, symbolic links not. 18 /// `expand-file-name` of `path` in `folder`: `.` and `..` resolved, symbolic links not.
19 public static func expand(_ path: String, in folder: String) -> String { 19 public static func expand(_ path: String, in folder: String) -> String {
20 let expanded = (path as NSString).expandingTildeInPath 20 let expanded = OrgPaths.expandingTilde(path)
21 let absolute = expanded.hasPrefix("/") ? expanded : (folder as NSString).appendingPathComponent(expanded) 21 let absolute = expanded.hasPrefix("/") ? expanded : (folder as NSString).appendingPathComponent(expanded)
22 return URL(fileURLWithPath: absolute).standardized.path 22 return URL(fileURLWithPath: absolute).standardized.path
23 } 23 }
Sources/OrgCore/Commands/ClockTable.swift +1 −1
@@ -435,7 +435,7 @@ extension EmacsBuffer {
435 var expanded: [String] = [] 435 var expanded: [String] = []
436 for item in list { 436 for item in list {
437 guard let name = item.string else { throw UserError(message: "Unknown scope: \(scopeValue.description)") } 437 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)
439 if !file.hasPrefix("/"), let base { file = (base as NSString).appendingPathComponent(file) } 439 if !file.hasPrefix("/"), let base { file = (base as NSString).appendingPathComponent(file) }
440 file = (file as NSString).standardizingPath 440 file = (file as NSString).standardizingPath
441 var isDirectory: ObjCBool = false 441 var isDirectory: ObjCBool = false
Sources/OrgCore/Commands/ColumnView.swift +1 −1
@@ -410,7 +410,7 @@ extension EmacsBuffer {
410 case "local", "nil", "": break 410 case "local", "nil", "": break
411 case let value where value.hasPrefix("file:"): 411 case let value where value.hasPrefix("file:"):
412 // `file:PATH`: the whole file, read from disk; relative to this file's folder. 412 // `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)))
414 if !path.hasPrefix("/"), let file = options.filePath { path = ((file as NSString).deletingLastPathComponent as NSString).appendingPathComponent(path) } 414 if !path.hasPrefix("/"), let file = options.filePath { path = ((file as NSString).deletingLastPathComponent as NSString).appendingPathComponent(path) }
415 guard let text = path == options.filePath ? string : try? String(contentsOfFile: path, encoding: .utf8) else { 415 guard let text = path == options.filePath ? string : try? String(contentsOfFile: path, encoding: .utf8) else {
416 throw UserError(message: "No such file: \"\(value)\"") 416 throw UserError(message: "No such file: \"\(value)\"")
Sources/OrgCore/Compute/Babel.swift +1 −1
@@ -74,7 +74,7 @@ public struct BabelJob: Sendable, Equatable {
74 /// An inline block: the result goes after it, in `{{{results(…)}}}`. 74 /// An inline block: the result goes after it, in `{{{results(…)}}}`.
75 var inline = false 75 var inline = false
76 /// `:file` (under `:output-dir`) with `:results file`, and `:file-desc`. 76 /// `:file` (under `:output-dir`) with `:results file`, and `:file-desc`.
77 var file: String? 77 public internal(set) var file: String?
78 var fileDescription: String? 78 var fileDescription: String?
79 /// The program writes `file` itself, as graphics languages do. 79 /// The program writes `file` itself, as graphics languages do.
80 var writesFile = false 80 var writesFile = false
Sources/OrgCore/Compute/BabelCache.swift +2 −1
@@ -45,7 +45,8 @@ extension Babel {
45 /// sorted by key and printed with `%S`, then the expanded body. 45 /// sorted by key and printed with `%S`, then the expanded body.
46 static func cacheInput(language: String, params: Params, tables: Tables, expanded: String, call: Bool) throws -> String { 46 static func cacheInput(language: String, params: Params, tables: Tables, expanded: String, call: Bool) throws -> String {
47 if let key = params.lisp.first(where: { params.evaluated[$0] == nil }) { 47 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."))
49 } 50 }
50 let ignored: Set<String> = ["replace", "silent", "none", "discard", "append", "prepend"] 51 let ignored: Set<String> = ["replace", "silent", "none", "discard", "append", "prepend"]
51 let drawsFile = language == "dot" || language == "plantuml" 52 let drawsFile = language == "dot" || language == "plantuml"
Sources/OrgCore/Compute/BabelExpand.swift +1 −1
@@ -518,7 +518,7 @@ extension Babel {
518 run = "echo | clojure -M \(file)\n" 518 run = "echo | clojure -M \(file)\n"
519 programs = ["clojure"] 519 programs = ["clojure"]
520 case let backend?: 520 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.")
522 } 522 }
523 return CompiledRun(source: expanded, script: start + "cat > \(file)\n" + run + end, programs: [programs]) 523 return CompiledRun(source: expanded, script: start + "cat > \(file)\n" + run + end, programs: [programs])
524 default: 524 default:
Sources/OrgCore/Compute/TableFormulaCommands.swift +2 −2
@@ -9,7 +9,7 @@ public struct TableRecalculate: OrgCommand {
9 public var id: String { all ? "org.table.recalc-all" : "org.table.recalc" } 9 public var id: String { all ? "org.table.recalc-all" : "org.table.recalc" }
10 public var title: String { all ? "Recalculate Table" : "Recalculate Table Row" } 10 public var title: String { all ? "Recalculate Table" : "Recalculate Table Row" }
11 11
12 public static let emacsMessage = "needs Emacs: " 12 public static var emacsMessage: String { EmacsFallback.wording("needs Emacs: ", "can't be calculated here: ") }
13 13
14 public func applies(in context: EditContext) -> Bool { 14 public func applies(in context: EditContext) -> Bool {
15 KeyContext.holds("table", in: context) || Self.tblfmLine(in: context) != nil 15 KeyContext.holds("table", in: context) || Self.tblfmLine(in: context) != nil
@@ -199,7 +199,7 @@ extension EmacsBuffer {
199 do { 199 do {
200 try tableEvalFormula(formula, analysis: analysis, substituted: false) 200 try tableEvalFormula(formula, analysis: analysis, substituted: false)
201 } catch let error as Calc.Unsupported { 201 } 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
203 } 203 }
204 tableAlign() 204 tableAlign()
205 } 205 }
Sources/OrgCore/Compute/Tangle.swift +2 −2
@@ -153,7 +153,7 @@ public enum Tangle {
153 lisp.define("expand-file-name") { lisp, args in 153 lisp.define("expand-file-name") { lisp, args in
154 try Elisp.arity(args, 1...2, "expand-file-name") 154 try Elisp.arity(args, 1...2, "expand-file-name")
155 let base = args.count > 1 && !Elisp.isNil(args[1]) ? try string(args, 1) : (try Elisp.string(lisp.value("default-directory"))) 155 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)))
157 } 157 }
158 lisp.define("file-name-directory") { _, args in 158 lisp.define("file-name-directory") { _, args in
159 try Elisp.arity(args, 1...1, "file-name-directory") 159 try Elisp.arity(args, 1...1, "file-name-directory")
@@ -206,7 +206,7 @@ public enum Tangle {
206 206
207 /// `expand-file-name`. 207 /// `expand-file-name`.
208 static func expand(_ name: String, in directory: String) -> String { 208 static func expand(_ name: String, in directory: String) -> String {
209 let expanded = (name as NSString).expandingTildeInPath 209 let expanded = OrgPaths.expandingTilde(name)
210 let absolute = expanded.hasPrefix("/") ? expanded : (directory as NSString).appendingPathComponent(expanded) 210 let absolute = expanded.hasPrefix("/") ? expanded : (directory as NSString).appendingPathComponent(expanded)
211 return (absolute as NSString).standardizingPath 211 return (absolute as NSString).standardizingPath
212 } 212 }
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 {
389 // Each `#+bibliography:` names one file. 389 // Each `#+bibliography:` names one file.
390 for m in text.matches(of: #/(?mi)^[ \t]*#\+bibliography:[ \t]*(.*?)[ \t]*$/#) { 390 for m in text.matches(of: #/(?mi)^[ \t]*#\+bibliography:[ \t]*(.*?)[ \t]*$/#) {
391 for name in [String(m.1)].map({ $0.count > 1 && $0.hasPrefix("\"") && $0.hasSuffix("\"") ? String($0.dropFirst().dropLast()) : $0 }) where !name.isEmpty { 391 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)
393 let url = path.hasPrefix("/") ? URL(fileURLWithPath: path) : (directory ?? URL(fileURLWithPath: "/")).appendingPathComponent(path) 393 let url = path.hasPrefix("/") ? URL(fileURLWithPath: path) : (directory ?? URL(fileURLWithPath: "/")).appendingPathComponent(path)
394 guard let data = try? Data(contentsOf: url) else { continue } 394 guard let data = try? Data(contentsOf: url) else { continue }
395 let parsed = url.pathExtension.lowercased() == "json" ? Self.parseJSON(data) : Self.parseBibTeX(String(decoding: data, as: UTF8.self)) 395 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 {
116 file = String(spec[..<r.lowerBound]) 116 file = String(spec[..<r.lowerBound])
117 target = String(spec[r.upperBound...]) 117 target = String(spec[r.upperBound...])
118 } 118 }
119 let url = (file as NSString).isAbsolutePath || directory == nil 119 let url = includeURL(file, directory: directory)
120 ? URL(fileURLWithPath: (file as NSString).expandingTildeInPath)
121 : directory!.appendingPathComponent(file)
122 guard var included = try? String(contentsOf: url, encoding: .utf8) else { 120 guard var included = try? String(contentsOf: url, encoding: .utf8) else {
123 lines.append("") 121 lines.append("")
124 continue 122 continue
@@ -152,6 +150,32 @@ public enum ExportPreprocess {
152 return lines.joined(separator: "\n") 150 return lines.joined(separator: "\n")
153 } 151 }
154 152
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
155 /// The subtree of `text` at `*Heading` or `#custom-id`. 179 /// The subtree of `text` at `*Heading` or `#custom-id`.
156 static func subtree(_ text: String, _ target: String) -> String? { 180 static func subtree(_ text: String, _ target: String) -> String? {
157 let tree = OrgParser.parse(text) 181 let tree = OrgParser.parse(text)
Sources/OrgCore/Export/ExportScope.swift +1 −1
@@ -59,7 +59,7 @@ public enum ExportScope {
59 /// expanded) with its extension replaced by `ext`, or the source's name with `ext`. 59 /// expanded) with its extension replaced by `ext`, or the source's name with `ext`.
60 public static func output(for source: URL, name: String?, extension ext: String) -> URL { 60 public static func output(for source: URL, name: String?, extension ext: String) -> URL {
61 guard let name, !name.isEmpty else { return source.deletingPathExtension().appendingPathExtension(ext) } 61 guard let name, !name.isEmpty else { return source.deletingPathExtension().appendingPathExtension(ext) }
62 let expanded = (name as NSString).expandingTildeInPath 62 let expanded = OrgPaths.expandingTilde(name)
63 let url = expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : source.deletingLastPathComponent().appendingPathComponent(expanded) 63 let url = expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : source.deletingLastPathComponent().appendingPathComponent(expanded)
64 return url.deletingPathExtension().appendingPathExtension(ext).standardizedFileURL 64 return url.deletingPathExtension().appendingPathExtension(ext).standardizedFileURL
65 } 65 }
Sources/OrgCore/Links/Backlinks.swift +1 −1
@@ -20,7 +20,7 @@ public enum Backlinks {
20 } 20 }
21 21
22 /// Whether `link`, written in the file at `source`, leads to `target`. 22 /// 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 {
24 let link = Links.unescape(link) 24 let link = Links.unescape(link)
25 if link.lowercased().hasPrefix("id:") { 25 if link.lowercased().hasPrefix("id:") {
26 let id = link.dropFirst(3).components(separatedBy: "::")[0] 26 let id = link.dropFirst(3).components(separatedBy: "::")[0]
Sources/OrgCore/Links/LinkStore.swift +1 −1
@@ -235,7 +235,7 @@ public struct InsertLink: OrgCommand {
235 public let file: String? 235 public let file: String?
236 public let home: String 236 public let home: String
237 237
238 public init(stored: [StoredLink] = [], file: String? = nil, home: String = NSHomeDirectory()) { 238 public init(stored: [StoredLink] = [], file: String? = nil, home: String = OrgPaths.home) {
239 self.stored = stored 239 self.stored = stored
240 self.file = file 240 self.file = file
241 self.home = home 241 self.home = home
Sources/OrgCore/Parser/SetupFile.swift +1 −1
@@ -25,7 +25,7 @@ public enum SetupFile {
25 var value = line[line.index(after: colon)...].trimmingCharacters(in: .whitespaces) 25 var value = line[line.index(after: colon)...].trimmingCharacters(in: .whitespaces)
26 if value.count >= 2, value.hasPrefix("\""), value.hasSuffix("\"") { value = String(value.dropFirst().dropLast()) } 26 if value.count >= 2, value.hasPrefix("\""), value.hasSuffix("\"") { value = String(value.dropFirst().dropLast()) }
27 guard !value.isEmpty, value.range(of: "^[a-zA-Z][a-zA-Z0-9+.-]*://", options: .regularExpression) == nil else { continue } 27 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)
29 let path = ((expanded.hasPrefix("/") ? expanded : (directory as NSString).appendingPathComponent(expanded)) as NSString).standardizingPath 29 let path = ((expanded.hasPrefix("/") ? expanded : (directory as NSString).appendingPathComponent(expanded)) as NSString).standardizingPath
30 guard !seen.contains(path), let contents = read(path) else { continue } 30 guard !seen.contains(path), let contents = read(path) else { continue }
31 out += lines(in: contents, directory: (path as NSString).deletingLastPathComponent, read: read, own: true, seen: seen.union([path])) 31 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 @@
1import CryptoKit 1import CryptoKit
2import Foundation 2import Foundation
3import OrgCore
3 4
4/// Reads and replaces files under `NSFileCoordinator`, so iCloud and other coordinating 5/// Reads and replaces files under `NSFileCoordinator`, so iCloud and other coordinating
5/// writers see a consistent file. 6/// writers see a consistent file.
6public struct CoordinatedFileSystem: FileSystem { 7public 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 }
8 15
9 public func read(_ url: URL) throws -> [UInt8]? { 16 public func read(_ url: URL) throws -> [UInt8]? {
10 try coordinate(reading: url) { url in 17 try coordinate(reading: url) { url in
@@ -17,7 +24,13 @@ public struct CoordinatedFileSystem: FileSystem {
17 let manager = FileManager.default 24 let manager = FileManager.default
18 let folder = url.deletingLastPathComponent() 25 let folder = url.deletingLastPathComponent()
19 let temporary = folder.appendingPathComponent(".\(url.lastPathComponent).orgstar-\(UUID().uuidString)") 26 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 }
21 guard manager.fileExists(atPath: url.path) else { 34 guard manager.fileExists(atPath: url.path) else {
22 try manager.moveItem(at: temporary, to: url) 35 try manager.moveItem(at: temporary, to: url)
23 return nil 36 return nil
@@ -32,6 +45,14 @@ public struct CoordinatedFileSystem: FileSystem {
32 } 45 }
33 } 46 }
34 47
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
35 private func coordinate<T>(reading url: URL, _ body: (URL) throws -> T) throws -> T { 56 private func coordinate<T>(reading url: URL, _ body: (URL) throws -> T) throws -> T {
36 var coordinationError: NSError? 57 var coordinationError: NSError?
37 var result: Result<T, Error>? 58 var result: Result<T, Error>?
Sources/OrgEditorAppKit/OrgEditor+Images.swift +1 −1
@@ -54,7 +54,7 @@ extension OrgEditor {
54 } 54 }
55 return data.flatMap(NSImage.init(data:)) 55 return data.flatMap(NSImage.init(data:))
56 } 56 }
57 let expanded = (path as NSString).expandingTildeInPath 57 let expanded = OrgPaths.expandingTilde(path)
58 let url = expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : (baseDirectory ?? URL(fileURLWithPath: FileManager.default.currentDirectoryPath)).appendingPathComponent(expanded) 58 let url = expanded.hasPrefix("/") ? URL(fileURLWithPath: expanded) : (baseDirectory ?? URL(fileURLWithPath: FileManager.default.currentDirectoryPath)).appendingPathComponent(expanded)
59 let modified = (try? url.resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate?.timeIntervalSince1970 ?? 0 59 let modified = (try? url.resourceValues(forKeys: [.contentModificationDateKey]))?.contentModificationDate?.timeIntervalSince1970 ?? 0
60 let key = "\(url.path)|\(modified)" as NSString 60 let key = "\(url.path)|\(modified)" as NSString
Sources/OrgEditorAppKit/OrgEditor.swift +1 −1
@@ -652,7 +652,7 @@ public final class OrgEditor: NSObject {
652 case .failed(let message): 652 case .failed(let message):
653 onMessage?(message) 653 onMessage?(message)
654 case .external(let request): 654 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.")) }
656 case .prompt(let prompt): 656 case .prompt(let prompt):
657 onPrompt?(prompt) { [weak self] answer in 657 onPrompt?(prompt) { [weak self] answer in
658 guard let self else { return } 658 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 @@
1import Foundation 1import Foundation
2import OrgCore
2import OrgIndex 3import OrgIndex
3 4
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.
5public struct WorkspaceRoot: Sendable, Equatable, Codable { 7public struct WorkspaceRoot: Sendable, Equatable, Codable {
6 public let bookmark: Data 8 public let bookmark: Data
7 /// The path when the bookmark was made or last refreshed, for display. 9 /// The path when the bookmark was made or last refreshed, for display.
8 public var path: String 10 public var path: String
9 11
10 public init(url: URL) throws { 12 public init(url: URL, sandboxed: Bool = Sandbox.isActive) throws {
11 bookmark = try url.bookmarkData(options: [], includingResourceValuesForKeys: nil, relativeTo: nil) 13 bookmark = try Sandbox.bookmark(url, sandboxed: sandboxed)
12 path = url.standardizedFileURL.path 14 path = url.standardizedFileURL.path
13 } 15 }
14 16
15 /// The folder's current location. `isStale` means the bookmark should be made again. 17 /// 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) {
17 var isStale = false 19 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)
19 _ = url.startAccessingSecurityScopedResource() 22 _ = url.startAccessingSecurityScopedResource()
20 return (url.standardizedFileURL, isStale) 23 return (url.standardizedFileURL, isStale)
21 } 24 }
Sources/Orgstar/AgendaView+Actions.swift +3
@@ -146,6 +146,9 @@ extension AgendaView {
146 message = "No entry selected" 146 message = "No entry selected"
147 return 147 return
148 } 148 }
149 #if APPSTORE
150 guard commands.reach(session.archiveFile(from: (entry.path, offset)).map { [$0] } ?? []) else { return }
151 #endif
149 message = session.archive(from: (entry.path, offset)) 152 message = session.archive(from: (entry.path, offset))
150 tick += 1 153 tick += 1
151 } 154 }
Sources/Orgstar/CaptureView.swift +8 −2
@@ -164,7 +164,7 @@ struct CaptureView: View {
164 keys = "" 164 keys = ""
165 day = nil 165 day = nil
166 let clocked = clock.running 166 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) }
168 context = CaptureContext( 168 context = CaptureContext(
169 initial: commands.editor?.selectedText ?? "", 169 initial: commands.editor?.selectedText ?? "",
170 annotation: session.captureAnnotation(), 170 annotation: session.captureAnnotation(),
@@ -270,7 +270,13 @@ struct CaptureView: View {
270 } 270 }
271 } else { 271 } else {
272 placed = template.resolved(workspace: workspace, session: session, clock: clock).flatMap { resolved in 272 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))
274 } 280 }
275 } 281 }
276 switch placed { 282 switch placed {
Sources/Orgstar/ContentView.swift +151 −13
@@ -5,6 +5,9 @@ import OrgEditorAppKit
5import OrgPresentation 5import OrgPresentation
6import OrgWorkspace 6import OrgWorkspace
7import OrgIndex 7import OrgIndex
8#if !APPSTORE
9import OrgPrograms
10#endif
8import SwiftUI 11import SwiftUI
9import UniformTypeIdentifiers 12import UniformTypeIdentifiers
10import WidgetKit 13import WidgetKit
@@ -180,15 +183,25 @@ struct ContentView: View {
180 } 183 }
181 } else { 184 } else {
182 ContentUnavailableView { 185 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")
184 } description: { 187 } 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.")
186 } actions: { 189 } actions: {
187 if workspace.roots.isEmpty { Button("Get Started…") { commands.showingWelcome = true } } 190 if noFolders { Button("Get Started…") { commands.showingWelcome = true } }
188 } 191 }
189 } 192 }
190 } 193 }
191 194
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
192 @ToolbarContentBuilder 205 @ToolbarContentBuilder
193 private var toolbarItems: some ToolbarContent { 206 private var toolbarItems: some ToolbarContent {
194 ToolbarItem(placement: .navigation) { 207 ToolbarItem(placement: .navigation) {
@@ -286,13 +299,13 @@ struct ContentView: View {
286 // Buffers switched by keys show in the sidebar too; a restored caret shows once. 299 // Buffers switched by keys show in the sidebar too; a restored caret shows once.
287 if let path = session.path, selectedFile != path { selectedFile = path } 300 if let path = session.path, selectedFile != path { selectedFile = path }
288 if let path = session.path, let caret = pendingCarets.removeValue(forKey: path) { session.reveal(caret) } 301 if let path = session.path, let caret = pendingCarets.removeValue(forKey: path) { session.reveal(caret) }
289 BufferRestore.save(session) 302 saveBuffers()
290 // Syncthing's conflict copies of the file. 303 // Syncthing's conflict copies of the file.
291 let copies = session.syncConflictCopies().count 304 let copies = session.syncConflictCopies().count
292 if copies > 0 { commands.show("\(copies) sync conflict \(copies == 1 ? "copy" : "copies") of this file; Resolve Sync Conflicts compares them.") } 305 if copies > 0 { commands.show("\(copies) sync conflict \(copies == 1 ? "copy" : "copies") of this file; Resolve Sync Conflicts compares them.") }
293 } 306 }
294 .onChange(of: session.openPaths) { _, paths in 307 .onChange(of: session.openPaths) { _, paths in
295 BufferRestore.save(session) 308 saveBuffers()
296 for path in commands.store.editors.keys where !paths.contains(path) { commands.store.releasePath(path) } 309 for path in commands.store.editors.keys where !paths.contains(path) { commands.store.releasePath(path) }
297 } 310 }
298 .onChange(of: editorSettings, initial: true) { _, settings in commands.editorSettings = settings } 311 .onChange(of: editorSettings, initial: true) { _, settings in commands.editorSettings = settings }
@@ -300,6 +313,9 @@ struct ContentView: View {
300 commands.externalHandler = runExternal 313 commands.externalHandler = runExternal
301 commands.filesHandler = { attachActions.drop($0) } 314 commands.filesHandler = { attachActions.drop($0) }
302 commands.imageHandler = { attachActions.yankImage($0, ext: $1) } 315 commands.imageHandler = { attachActions.yankImage($0, ext: $1) }
316 #if APPSTORE
317 commands.reach = { [workspace] in GrantAccess.reach($0, workspace: workspace) }
318 #endif
303 // `org-clock-out-when-done`, and the notification when the Effort runs out. 319 // `org-clock-out-when-done`, and the notification when the Effort runs out.
304 clock.notifications = SystemReminderCenter.isAvailable ? SystemReminderCenter() : nil 320 clock.notifications = SystemReminderCenter.isAvailable ? SystemReminderCenter() : nil
305 session.textChanged = { [weak session, weak clock, weak commands] path in 321 session.textChanged = { [weak session, weak clock, weak commands] path in
@@ -309,7 +325,7 @@ struct ContentView: View {
309 clock.remindAtEffort(session) 325 clock.remindAtEffort(session)
310 commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] } 326 commands.knownTags = { [index = workspace.index] in (try? index.tags()) ?? [] }
311 commands.mainWindowOpen = true 327 commands.mainWindowOpen = true
312 if workspace.roots.isEmpty, !welcomeShown { 328 if noFolders, !welcomeShown {
313 welcomeShown = true 329 welcomeShown = true
314 commands.showingWelcome = true 330 commands.showingWelcome = true
315 } 331 }
@@ -343,7 +359,13 @@ struct ContentView: View {
343 .onChange(of: preset, initial: true) { loadKeymap() } 359 .onChange(of: preset, initial: true) { loadKeymap() }
344 .sheet(isPresented: $showingImport) { EmacsImportView(workspace: workspace) } 360 .sheet(isPresented: $showingImport) { EmacsImportView(workspace: workspace) }
345 .sheet(item: $panel) { panel in panelView(panel) } 361 .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 }
347 .sheet(item: $blockEdit) { request in 369 .sheet(item: $blockEdit) { request in
348 BlockEditorView(edit: request.edit) { content in 370 BlockEditorView(edit: request.edit) { content in
349 blockEdit = nil 371 blockEdit = nil
@@ -487,12 +509,18 @@ struct ContentView: View {
487 } 509 }
488 } 510 }
489 .task { 511 .task {
512 #if !APPSTORE
490 DevelopmentHooks.scheduleSnapshot() 513 DevelopmentHooks.scheduleSnapshot()
514 #endif
491 pendingCarets = BufferRestore.restore(session) 515 pendingCarets = BufferRestore.restore(session)
492 if let path = session.path, let caret = pendingCarets.removeValue(forKey: path) { session.reveal(caret) } 516 if let path = session.path, let caret = pendingCarets.removeValue(forKey: path) { session.reveal(caret) }
493 // Files handed over at launch open after the restored buffers, and show. 517 // Files handed over at launch open after the restored buffers, and show.
494 for path in AppDelegate.pendingOpens { session.open(path) } 518 for path in AppDelegate.pendingOpens { session.open(path) }
495 AppDelegate.pendingOpens = [] 519 AppDelegate.pendingOpens = []
520 #if APPSTORE
521 for link in AppDelegate.pendingLinks { commands.handle(protocolURL: link) }
522 AppDelegate.pendingLinks = []
523 #else
496 for link in AppDelegate.pendingLinks + [DevelopmentHooks.urlToOpen].compactMap({ $0 }) { commands.handle(protocolURL: link) } 524 for link in AppDelegate.pendingLinks + [DevelopmentHooks.urlToOpen].compactMap({ $0 }) { commands.handle(protocolURL: link) }
497 AppDelegate.pendingLinks = [] 525 AppDelegate.pendingLinks = []
498 if let path = DevelopmentHooks.fileToOpen { selectedFile = path } 526 if let path = DevelopmentHooks.fileToOpen { selectedFile = path }
@@ -509,6 +537,7 @@ struct ContentView: View {
509 if let id = DevelopmentHooks.windowToOpen { 537 if let id = DevelopmentHooks.windowToOpen {
510 if id == "settings" { openSettings() } else { openWindow(id: id) } 538 if id == "settings" { openSettings() } else { openWindow(id: id) }
511 } 539 }
540 #endif
512 await workspace.refresh() 541 await workspace.refresh()
513 workspace.startWatching() 542 workspace.startWatching()
514 } 543 }
@@ -559,6 +588,7 @@ struct ContentView: View {
559 commands.show("No file is open") 588 commands.show("No file is open")
560 return 589 return
561 } 590 }
591 guard readsIncludes(text, path: path) else { return }
562 let url = URL(fileURLWithPath: path) 592 let url = URL(fileURLWithPath: path)
563 let base = url.deletingPathExtension() 593 let base = url.deletingPathExtension()
564 let defaults = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile) 594 let defaults = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
@@ -571,6 +601,8 @@ struct ContentView: View {
571 } 601 }
572 switch format { 602 switch format {
573 case "icalendar": 603 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 }
574 do { 606 do {
575 let target = try ICalendarFiles.export(whole, path: path, settings: defaults, options: OrgPreferences.icalendarOptions(), 607 let target = try ICalendarFiles.export(whole, path: path, settings: defaults, options: OrgPreferences.icalendarOptions(),
576 subtree: subtree ? caret : nil, destination: destination) 608 subtree: subtree ? caret : nil, destination: destination)
@@ -581,7 +613,7 @@ struct ContentView: View {
581 } 613 }
582 case "html", "html-open", "markdown": 614 case "html", "html-open", "markdown":
583 let name = ExportScope.fileName(whole, subtreeAt: subtree ? caret : nil, settings: defaults) 615 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 }
585 let content = format == "markdown" 617 let content = format == "markdown"
586 ? MarkdownExport.document(text, settings: defaults, path: path, bodyOnly: bodyOnly) 618 ? MarkdownExport.document(text, settings: defaults, path: path, bodyOnly: bodyOnly)
587 : HTMLExport.page( 619 : HTMLExport.page(
@@ -599,12 +631,14 @@ struct ContentView: View {
599 case "print-pdf", "docx", "rtf", "plain-text": 631 case "print-pdf", "docx", "rtf", "plain-text":
600 let ext = ["print-pdf": "pdf", "plain-text": "txt"][format] ?? format 632 let ext = ["print-pdf": "pdf", "plain-text": "txt"][format] ?? format
601 let name = ExportScope.fileName(whole, subtreeAt: subtree ? caret : nil, settings: defaults) 633 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 }
603 let html = HTMLExport.page( 635 let html = HTMLExport.page(
604 text, fallbackTitle: base.lastPathComponent, settings: defaults, path: path, 636 text, fallbackTitle: base.lastPathComponent, settings: defaults, path: path,
605 codeStyle: HTMLCodeStyle(highlighter: PaneView.highlighter, theme: theme), language: OrgPreferences.exportLanguage() 637 codeStyle: HTMLCodeStyle(highlighter: PaneView.highlighter, theme: theme), language: OrgPreferences.exportLanguage()
606 ) 638 )
607 let directory = url.deletingLastPathComponent() 639 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))
608 if format == "print-pdf" { commands.show("Exporting to PDF…") } 642 if format == "print-pdf" { commands.show("Exporting to PDF…") }
609 Task { 643 Task {
610 do { 644 do {
@@ -624,6 +658,7 @@ struct ContentView: View {
624 } 658 }
625 } 659 }
626 default: 660 default:
661 #if !APPSTORE
627 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"] 662 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"]
628 guard let function = functions[format] else { return } 663 guard let function = functions[format] else { return }
629 commands.show("Exporting with Emacs…") 664 commands.show("Exporting with Emacs…")
@@ -647,12 +682,84 @@ struct ContentView: View {
647 commands.show("\(error)") 682 commands.show("\(error)")
648 } 683 }
649 } 684 }
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
650 } 702 }
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")
651 } 757 }
652 758
653 /// `org-icalendar-export-agenda-files`, or with `combined`, `org-icalendar-combine-agenda-files`. 759 /// `org-icalendar-export-agenda-files`, or with `combined`, `org-icalendar-combine-agenda-files`.
654 private func exportAgendaCalendars(combined: Bool) { 760 private func exportAgendaCalendars(combined: Bool) {
655 let paths = workspace.agendaFilePaths() 761 let paths = workspace.agendaFilePaths()
762 guard reach(paths + (combined ? [OrgPreferences.icalendarCombinedFile()] : [])) else { return }
656 let read = { (path: String) -> (text: String, settings: OrgSettings)? in 763 let read = { (path: String) -> (text: String, settings: OrgSettings)? in
657 guard let text = session.openDocuments.first(where: { $0.path == path })?.document.text ?? (try? String(contentsOfFile: path, encoding: .utf8)) else { return nil } 764 guard let text = session.openDocuments.first(where: { $0.path == path })?.document.text ?? (try? String(contentsOfFile: path, encoding: .utf8)) else { return nil }
658 return (text, Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)) 765 return (text, Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile))
@@ -696,7 +803,7 @@ struct ContentView: View {
696 803
697 /// org-roam's daily notes and nodes. 804 /// org-roam's daily notes and nodes.
698 private var roamActions: RoamActions { 805 private var roamActions: RoamActions {
699 RoamActions( 806 var actions = RoamActions(
700 session: session, roots: { [workspace] in workspace.rootPaths }, 807 session: session, roots: { [workspace] in workspace.rootPaths },
701 nodes: { [workspace, session] in workspace.nodes(overlay: workspace.overlay(session.openDocuments)) }, 808 nodes: { [workspace, session] in workspace.nodes(overlay: workspace.overlay(session.openDocuments)) },
702 show: { [commands] in commands.show($0) }, ask: { [commands] in commands.ask($0, reply: $1) }, 809 show: { [commands] in commands.show($0) }, ask: { [commands] in commands.ask($0, reply: $1) },
@@ -711,6 +818,10 @@ struct ContentView: View {
711 editor.perform(PrecomputedEdit(EditResult(baseRevision: context.revision, edits: [TextEdit(range: range, replacement: text)], selection: [end..<end]))) 818 editor.perform(PrecomputedEdit(EditResult(baseRevision: context.revision, edits: [TextEdit(range: range, replacement: text)], selection: [end..<end])))
712 }, 819 },
713 refresh: { [workspace] in Task { await workspace.refresh() } }) 820 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
714 } 825 }
715 826
716 /// org-attach's commands for the entry at the caret. 827 /// org-attach's commands for the entry at the caret.
@@ -733,6 +844,13 @@ struct ContentView: View {
733 panel.allowsMultipleSelection = true 844 panel.allowsMultipleSelection = true
734 panel.message = "File to keep as an attachment" 845 panel.message = "File to keep as an attachment"
735 guard panel.runModal() == .OK else { return } 846 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
736 attachActions.attach(panel.urls, method: method) 854 attachActions.attach(panel.urls, method: method)
737 }) 855 })
738 } 856 }
@@ -783,6 +901,7 @@ struct ContentView: View {
783 let plot: TablePlot.Plot 901 let plot: TablePlot.Plot
784 do { plot = try TablePlot.plot(context.text, at: context.caret) } catch { return commands.show("\(error)") } 902 do { plot = try TablePlot.plot(context.text, at: context.caret) } catch { return commands.show("\(error)") }
785 let directory = URL(fileURLWithPath: path).deletingLastPathComponent() 903 let directory = URL(fileURLWithPath: path).deletingLastPathComponent()
904 #if !APPSTORE
786 if let gnuplot = PlotOutput.gnuplot { 905 if let gnuplot = PlotOutput.gnuplot {
787 commands.show("Plotting with gnuplot…") 906 commands.show("Plotting with gnuplot…")
788 Task { 907 Task {
@@ -793,7 +912,11 @@ struct ContentView: View {
793 commands.show("\(error)") 912 commands.show("\(error)")
794 } 913 }
795 } 914 }
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 }
797 do { 920 do {
798 try PlotOutput.write(plot, to: url) 921 try PlotOutput.write(plot, to: url)
799 plotWritten(url, editor: editor) 922 plotWritten(url, editor: editor)
@@ -823,6 +946,9 @@ struct ContentView: View {
823 } 946 }
824 let codeStyle = HTMLCodeStyle(highlighter: PaneView.highlighter, theme: theme) 947 let codeStyle = HTMLCodeStyle(highlighter: PaneView.highlighter, theme: theme)
825 func run(_ chosen: [PublishProject], only: String? = nil) { 948 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 }
826 do { 952 do {
827 let report = try Publish.publish(chosen, all: loaded.projects, only: only, read: read) { function, text, path, bodyOnly in 953 let report = try Publish.publish(chosen, all: loaded.projects, only: only, read: read) { function, text, path, bodyOnly in
828 let settings = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile) 954 let settings = Preferences.orgSettings.resolvingSetupFiles(in: text, path: path, read: OrgSettings.readFile)
@@ -864,7 +990,7 @@ struct ContentView: View {
864 DispatchQueue.main.async { commands.editor?.perform(SparseTreeCommand(), answers: ["sparse": "/", "regexp": regexp]) } 990 DispatchQueue.main.async { commands.editor?.perform(SparseTreeCommand(), answers: ["sparse": "/", "regexp": regexp]) }
865 } 991 }
866 case .tangle(let scope): 992 case .tangle(let scope):
867 guard ProAccess.shared.allows(.babel) else { return } 993 guard ProAccess.shared.allows(.babel), reach(session.tangleFiles(scope)) else { return }
868 commands.show(session.tangle(scope)) 994 commands.show(session.tangle(scope))
869 case .agenda(let start, let days): 995 case .agenda(let start, let days):
870 commands.agendaRequest = (start, days) 996 commands.agendaRequest = (start, days)
@@ -873,6 +999,10 @@ struct ContentView: View {
873 blockEdit = BlockEditRequest(edit: edit) 999 blockEdit = BlockEditRequest(edit: edit)
874 case .columnView(let view): 1000 case .columnView(let view):
875 panel = .columns(UUID(), view) 1001 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
876 case .emacsTable(let table, let point, let form, let reason, let lisp): 1006 case .emacsTable(let table, let point, let form, let reason, let lisp):
877 let run = { 1007 let run = {
878 commands.show(String(localized: "Recalculating in Emacs (\(TableReason.localized(reason)))…", comment: "Table formulas sent to Emacs, and why")) 1008 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 {
890 default: commands.show("Not recalculated") 1020 default: commands.show("Not recalculated")
891 } 1021 }
892 } 1022 }
1023 #endif
893 case .babel(let job): 1024 case .babel(let job):
894 guard ProAccess.shared.allows(.babel) else { return } 1025 guard ProAccess.shared.allows(.babel) else { return }
895 let run = { 1026 let run = {
1027 guard reach(session.resultFile(of: job).map { [$0] } ?? []) else { return }
896 commands.show("Running \(job.language) block… (⌘. to cancel)") 1028 commands.show("Running \(job.language) block… (⌘. to cancel)")
897 session.startBabel(job) { commands.show($0) } 1029 session.startBabel(job) { commands.show($0) }
898 } 1030 }
@@ -996,6 +1128,10 @@ struct ContentView: View {
996 1128
997 /// Runs a command from a key, the palette or the Org menu. 1129 /// Runs a command from a key, the palette or the Org menu.
998 private func perform(_ id: String) { 1130 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 }
999 if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return } 1135 if let feature = ProFeature.required(byCommand: id), !ProAccess.shared.allows(feature) { return }
1000 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.") 1136 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.")
1001 if orgOnly, !session.isOrg { 1137 if orgOnly, !session.isOrg {
@@ -1096,6 +1232,7 @@ struct ContentView: View {
1096 commands.jump(path: target.path, offset: target.start ?? Int.max) 1232 commands.jump(path: target.path, offset: target.start ?? Int.max)
1097 } 1233 }
1098 case "app.archive": 1234 case "app.archive":
1235 guard reach(session.archiveFile().map { [$0] } ?? []) else { return }
1099 if let message = session.archive() { commands.show(message) } 1236 if let message = session.archive() { commands.show(message) }
1100 case "app.table-import": 1237 case "app.table-import":
1101 // `org-table-import`: a TSV, CSV or space-separated file becomes a table at point. 1238 // `org-table-import`: a TSV, CSV or space-separated file becomes a table at point.
@@ -1129,7 +1266,7 @@ struct ContentView: View {
1129 guard let editor = commands.editor, let path = session.path else { return commands.show("No method for storing a link from this buffer") } 1266 guard let editor = commands.editor, let path = session.path else { return commands.show("No method for storing a link from this buffer") }
1130 let context = editor.context() 1267 let context = editor.context()
1131 let denote = OrgPreferences.usesDenote() ? Links.storeDenote(in: context, path: path) : nil 1268 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)))
1133 case "org.id.store-link": 1270 case "org.id.store-link":
1134 guard let editor = commands.editor, let path = session.path else { return } 1271 guard let editor = commands.editor, let path = session.path else { return }
1135 if case .commit = editor.perform(CreateID()), 1272 if case .commit = editor.perform(CreateID()),
@@ -1196,6 +1333,7 @@ struct ContentView: View {
1196 case let id where id.hasPrefix("app.crypt."): 1333 case let id where id.hasPrefix("app.crypt."):
1197 crypt(id) 1334 crypt(id)
1198 case let id where id.hasPrefix("app.attach."): 1335 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 }
1199 attachActions.run(id) 1337 attachActions.run(id)
1200 case let id where id.hasPrefix("app.dailies.") || id.hasPrefix("app.node."): 1338 case let id where id.hasPrefix("app.dailies.") || id.hasPrefix("app.node."):
1201 roamActions.run(id) 1339 roamActions.run(id)
Sources/Orgstar/DevelopmentHooks.swift +2
@@ -1,3 +1,4 @@
1#if !APPSTORE
1import AppKit 2import AppKit
2import OrgEditorAppKit 3import OrgEditorAppKit
3 4
@@ -47,3 +48,4 @@ enum DevelopmentHooks {
47 } 48 }
48 } 49 }
49} 50}
51#endif
Sources/Orgstar/EmacsImportView.swift +76 −3
@@ -12,6 +12,8 @@ struct EmacsImportView: View {
12 @State private var choosing = false 12 @State private var choosing = false
13 @State private var summary: String? 13 @State private var summary: String?
14 @State private var importing = false 14 @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?
15 17
16 var body: some View { 18 var body: some View {
17 VStack(alignment: .leading, spacing: 0) { 19 VStack(alignment: .leading, spacing: 0) {
@@ -44,7 +46,12 @@ struct EmacsImportView: View {
44 } 46 }
45 .frame(width: 640, height: 560) 47 .frame(width: 640, height: 560)
46 .onAppear { 48 .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
47 if location == nil, let first = EmacsImport.defaultLocations().first { read(first) } 53 if location == nil, let first = EmacsImport.defaultLocations().first { read(first) }
54 #endif
48 } 55 }
49 .fileImporter(isPresented: $choosing, allowedContentTypes: [.folder, .item]) { chosen in 56 .fileImporter(isPresented: $choosing, allowedContentTypes: [.folder, .item]) { chosen in
50 if case .success(let url) = chosen { read(url) } 57 if case .success(let url) = chosen { read(url) }
@@ -55,15 +62,69 @@ struct EmacsImportView: View {
55 HStack { 62 HStack {
56 VStack(alignment: .leading, spacing: 2) { 63 VStack(alignment: .leading, spacing: 2) {
57 Text("Import from Emacs").font(.headline) 64 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" : "") } ?? "")
59 .font(.caption).foregroundStyle(.secondary).lineLimit(2) 66 .font(.caption).foregroundStyle(.secondary).lineLimit(2)
60 } 67 }
61 Spacer() 68 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() }
63 } 76 }
64 .padding(12) 77 .padding(12)
65 } 78 }
66 79
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
67 private func list(_ result: EmacsImport) -> some View { 128 private func list(_ result: EmacsImport) -> some View {
68 List { 129 List {
69 EmacsImportSections(result: result, groups: result.groups(folders: true), selected: $selected, 130 EmacsImportSections(result: result, groups: result.groups(folders: true), selected: $selected,
@@ -74,6 +135,9 @@ struct EmacsImportView: View {
74 private func footnote(_ result: EmacsImport) -> String { 135 private func footnote(_ result: EmacsImport) -> String {
75 var parts = ["\(result.skipped) variables not about org left alone"] 136 var parts = ["\(result.skipped) variables not about org left alone"]
76 if result.doomDefaultsLeftOut > 0 { parts.append("\(result.doomDefaultsLeftOut) Doom defaults orgstar has no use for") } 137 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
77 return parts.joined(separator: "; ") 141 return parts.joined(separator: "; ")
78 } 142 }
79 143
@@ -81,7 +145,11 @@ struct EmacsImportView: View {
81 let accessing = url.startAccessingSecurityScopedResource() 145 let accessing = url.startAccessingSecurityScopedResource()
82 defer { if accessing { url.stopAccessingSecurityScopedResource() } } 146 defer { if accessing { url.stopAccessingSecurityScopedResource() } }
83 location = url 147 location = url
148 #if APPSTORE
149 let scanned = EmacsImport.scan(EmacsImport.files(in: url), doomDefaults: doomInstall.map(EmacsImport.doomDefaultFiles(in:)))
150 #else
84 let scanned = EmacsImport.scan(EmacsImport.files(in: url)) 151 let scanned = EmacsImport.scan(EmacsImport.files(in: url))
152 #endif
85 result = scanned 153 result = scanned
86 selected = Set(scanned.items.map(\.id)) 154 selected = Set(scanned.items.map(\.id))
87 summary = nil 155 summary = nil
@@ -91,8 +159,13 @@ struct EmacsImportView: View {
91 guard let result else { return } 159 guard let result else { return }
92 importing = true 160 importing = true
93 let chosen = result.items.filter { selected.contains($0.id) } 161 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
94 Task { 167 Task {
95 summary = await EmacsImport.apply(chosen, workspace: workspace) 168 summary = await EmacsImport.apply(chosen, workspace: workspace, chosenFolders: folders)
96 importing = false 169 importing = false
97 } 170 }
98 } 171 }
Sources/Orgstar/ExportSheet.swift +14 −1
@@ -8,7 +8,9 @@ struct ExportSheet: View {
8 let inSubtree: Bool 8 let inSubtree: Bool
9 /// The default destination for an extension, with or without the subtree. 9 /// The default destination for an extension, with or without the subtree.
10 let target: (_ ext: String, _ subtree: Bool) -> URL 10 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
12 @AppStorage("exportFormat") private var format = "html" 14 @AppStorage("exportFormat") private var format = "html"
13 @AppStorage("exportOpenAfter") private var openAfter = false 15 @AppStorage("exportOpenAfter") private var openAfter = false
14 @AppStorage("exportBodyOnly") private var bodyOnly = false 16 @AppStorage("exportBodyOnly") private var bodyOnly = false
@@ -19,12 +21,19 @@ struct ExportSheet: View {
19 @State private var destination: URL? 21 @State private var destination: URL?
20 @Environment(\.dismiss) private var dismiss 22 @Environment(\.dismiss) private var dismiss
21 23
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
22 static let formats: [(id: String, title: String, ext: String)] = [ 30 static let formats: [(id: String, title: String, ext: String)] = [
23 ("html", "HTML", "html"), ("markdown", "Markdown", "md"), ("print-pdf", "PDF", "pdf"), ("docx", "Word", "docx"), 31 ("html", "HTML", "html"), ("markdown", "Markdown", "md"), ("print-pdf", "PDF", "pdf"), ("docx", "Word", "docx"),
24 ("rtf", "Rich Text (RTF)", "rtf"), ("plain-text", "Plain text", "txt"), ("pdf", "PDF via LaTeX (Emacs)", "pdf"), 32 ("rtf", "Rich Text (RTF)", "rtf"), ("plain-text", "Plain text", "txt"), ("pdf", "PDF via LaTeX (Emacs)", "pdf"),
25 ("odt", "ODT (Emacs)", "odt"), ("latex", "LaTeX (Emacs)", "tex"), ("text", "Plain text, ASCII (Emacs)", "txt"), 33 ("odt", "ODT (Emacs)", "odt"), ("latex", "LaTeX (Emacs)", "tex"), ("text", "Plain text, ASCII (Emacs)", "txt"),
26 ("icalendar", "iCalendar", "ics"), 34 ("icalendar", "iCalendar", "ics"),
27 ] 35 ]
36 #endif
28 37
29 private var ext: String { Self.formats.first { $0.id == format }?.ext ?? "html" } 38 private var ext: String { Self.formats.first { $0.id == format }?.ext ?? "html" }
30 private var chosen: URL { destination ?? target(ext, subtree) } 39 private var chosen: URL { destination ?? target(ext, subtree) }
@@ -68,7 +77,11 @@ struct ExportSheet: View {
68 Spacer() 77 Spacer()
69 Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction) 78 Button("Cancel") { dismiss() }.keyboardShortcut(.cancelAction)
70 Button("Export") { 79 Button("Export") {
80 #if APPSTORE
81 export(format, destination, openAfter, subtree && inSubtree, bodyOnly && allowsBodyOnly)
82 #else
71 export(format, chosen, openAfter, subtree && inSubtree, bodyOnly && allowsBodyOnly) 83 export(format, chosen, openAfter, subtree && inSubtree, bodyOnly && allowsBodyOnly)
84 #endif
72 dismiss() 85 dismiss()
73 } 86 }
74 .keyboardShortcut(.defaultAction) 87 .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 {
179 } 179 }
180} 180}
181 181
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
182/// M-x and ⇧⌘P: every command by title, with its keys. 189/// M-x and ⇧⌘P: every command by title, with its keys.
183struct PaletteView: View { 190struct PaletteView: View {
184 let commands: AppCommands 191 let commands: AppCommands
@@ -187,7 +194,7 @@ struct PaletteView: View {
187 @Environment(\.dismiss) private var dismiss 194 @Environment(\.dismiss) private var dismiss
188 195
189 private var matches: [EditorCommand] { 196 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
191 guard let score = FuzzyMatch.score(query, command.localizedTitle) ?? FuzzyMatch.score(query, command.title) else { return nil } 198 guard let score = FuzzyMatch.score(query, command.localizedTitle) ?? FuzzyMatch.score(query, command.title) else { return nil }
192 return (command, score) 199 return (command, score)
193 } 200 }
Sources/Orgstar/LinkOpener.swift +5
@@ -8,6 +8,11 @@ enum LinkOpener {
8 /// Returns a message when the link can't be followed. 8 /// Returns a message when the link can't be followed.
9 /// `ask` picks among a query link's matches. 9 /// `ask` picks among a query link's matches.
10 static func open(_ link: OrgLink, session: DocumentSession, workspace: WorkspaceModel, ask: @escaping (Prompt, @escaping (String?) -> Void) -> Void) -> String? { 10 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
11 switch session.follow(link, workspace: workspace, isText: FileTypes.isText) { 16 switch session.follow(link, workspace: workspace, isText: FileTypes.isText) {
12 case .shown: return nil 17 case .shown: return nil
13 case .openExternally(let url): 18 case .openExternally(let url):
Sources/Orgstar/OrgstarApp.swift +118 −6
@@ -3,6 +3,9 @@ import OrgApp
3import OrgCore 3import OrgCore
4import OrgEditorAppKit 4import OrgEditorAppKit
5import OrgPresentation 5import OrgPresentation
6#if !APPSTORE
7import OrgPrograms
8#endif
6import SwiftUI 9import SwiftUI
7import UserNotifications 10import UserNotifications
8 11
@@ -36,6 +39,10 @@ final class AppCommands {
36 /// Files and images pasted or dropped on an editor; the main window sets them. 39 /// Files and images pasted or dropped on an editor; the main window sets them.
37 var filesHandler: (([URL]) -> Void)? 40 var filesHandler: (([URL]) -> Void)?
38 var imageHandler: ((Data, String) -> Void)? 41 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
39 /// Tags used across the workspace, for tag completion; the main window sets it. 46 /// Tags used across the workspace, for tag completion; the main window sets it.
40 var knownTags: () -> [String] = { [] } 47 var knownTags: () -> [String] = { [] }
41 /// The pending key prefix, and what can follow it. 48 /// The pending key prefix, and what can follow it.
@@ -179,17 +186,32 @@ struct PromptRequest: Identifiable {
179final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate { 186final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDelegate {
180 var session: DocumentSession? 187 var session: DocumentSession?
181 var commands: AppCommands? 188 var commands: AppCommands?
189 #if APPSTORE
190 var workspace: WorkspaceModel?
191 #else
182 let updates = Updates() 192 let updates = Updates()
193 #endif
183 194
184 func applicationDidFinishLaunching(_ notification: Notification) { 195 func applicationDidFinishLaunching(_ notification: Notification) {
185 DockIcon.start() 196 DockIcon.start()
186 if SystemReminderCenter.isAvailable { UNUserNotificationCenter.current().delegate = self } 197 if SystemReminderCenter.isAvailable { UNUserNotificationCenter.current().delegate = self }
198 #if !APPSTORE
187 updates.start() 199 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() }
188 } 207 }
208 #endif
189 209
190 /// `:session` interpreters end with the app. 210 /// `:session` interpreters end with the app.
191 func applicationWillTerminate(_ notification: Notification) { 211 func applicationWillTerminate(_ notification: Notification) {
212 #if !APPSTORE
192 BabelSessions.shared.stopAll() 213 BabelSessions.shared.stopAll()
214 #endif
193 } 215 }
194 216
195 /// Reminders show while Orgstar is in front too. 217 /// Reminders show while Orgstar is in front too.
@@ -233,7 +255,11 @@ final class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCent
233 255
234 func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply { 256 func applicationShouldTerminate(_ sender: NSApplication) -> NSApplication.TerminateReply {
235 guard let session else { return .terminateNow } 257 guard let session else { return .terminateNow }
258 #if APPSTORE
259 BufferRestore.save(session, workspace: workspace)
260 #else
236 BufferRestore.save(session) 261 BufferRestore.save(session)
262 #endif
237 return UnsavedChanges.resolve(session, paths: session.openPaths) ? .terminateNow : .terminateCancel 263 return UnsavedChanges.resolve(session, paths: session.openPaths) ? .terminateNow : .terminateCancel
238 } 264 }
239} 265}
@@ -289,18 +315,42 @@ enum BufferRestore {
289 var paths: [String] 315 var paths: [String]
290 var current: String? 316 var current: String?
291 var carets: [String: Int] 317 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]?
292 } 321 }
293 322
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) {
295 var carets: [String: Int] = [:] 326 var carets: [String: Int] = [:]
296 for path in session.openPaths { carets[path] = session.caret(of: path) } 327 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)
298 if let data = try? JSONEncoder().encode(state) { defaults.set(data, forKey: key) } 334 if let data = try? JSONEncoder().encode(state) { defaults.set(data, forKey: key) }
299 } 335 }
300 336
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
301 /// Opens the buffers that were open, in order, and returns the carets to show them at. 344 /// Opens the buffers that were open, in order, and returns the carets to show them at.
302 static func restore(_ session: DocumentSession, defaults: UserDefaults = .standard) -> [String: Int] { 345 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 }
304 let existing = state.paths.filter { FileManager.default.fileExists(atPath: $0) } 354 let existing = state.paths.filter { FileManager.default.fileExists(atPath: $0) }
305 for path in existing { session.open(path) } 355 for path in existing { session.open(path) }
306 if let current = state.current, existing.contains(current) { session.open(current) } 356 if let current = state.current, existing.contains(current) { session.open(current) }
@@ -324,8 +374,16 @@ struct OrgstarApp: App {
324 }() 374 }()
325 375
326 init() { 376 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()
327 MacPro.resolve() 384 MacPro.resolve()
328 MacPro.renewInBackground() 385 MacPro.renewInBackground()
386 #endif
329 // Debug builds, and runs with ORGSTAR_PERF set: main-thread stalls in the console. 387 // Debug builds, and runs with ORGSTAR_PERF set: main-thread stalls in the console.
330 #if DEBUG 388 #if DEBUG
331 Perf.watchMainThread() 389 Perf.watchMainThread()
@@ -344,6 +402,9 @@ struct OrgstarApp: App {
344 .onAppear { 402 .onAppear {
345 delegate.session = session 403 delegate.session = session
346 delegate.commands = commands 404 delegate.commands = commands
405 #if APPSTORE
406 delegate.workspace = model
407 #endif
347 CaptureIntent.environment = (model, session, clock, commands) 408 CaptureIntent.environment = (model, session, clock, commands)
348 } 409 }
349 case .failure(let error): 410 case .failure(let error):
@@ -400,7 +461,7 @@ struct OrgstarApp: App {
400 } 461 }
401 CommandGroup(after: .saveItem) { 462 CommandGroup(after: .saveItem) {
402 Menu("Export") { 463 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
404 Button(command.localizedTitle) { commands.run(command.id) } 465 Button(command.localizedTitle) { commands.run(command.id) }
405 } 466 }
406 } 467 }
@@ -503,12 +564,18 @@ struct OrgstarApp: App {
503 Button("Edit Config File") { commands.jump(path: UserConfig.configFile.path, offset: 0) } 564 Button("Edit Config File") { commands.jump(path: UserConfig.configFile.path, offset: 0) }
504 .keyboardShortcut(",", modifiers: [.command, .option]) 565 .keyboardShortcut(",", modifiers: [.command, .option])
505 } 566 }
567 #if !APPSTORE
506 CommandGroup(after: .appInfo) { 568 CommandGroup(after: .appInfo) {
507 CheckForUpdatesItem(updates: delegate.updates) 569 CheckForUpdatesItem(updates: delegate.updates)
508 } 570 }
571 #endif
509 } 572 }
510 Settings { 573 Settings {
574 #if APPSTORE
575 SettingsView(commands: commands, workspace: try? workspace.get())
576 #else
511 SettingsView(commands: commands, workspace: try? workspace.get(), updates: delegate.updates) 577 SettingsView(commands: commands, workspace: try? workspace.get(), updates: delegate.updates)
578 #endif
512 } 579 }
513 } 580 }
514} 581}
@@ -587,8 +654,13 @@ struct AgendaMenuItem: View {
587struct SettingsView: View { 654struct SettingsView: View {
588 let commands: AppCommands 655 let commands: AppCommands
589 let workspace: WorkspaceModel? 656 let workspace: WorkspaceModel?
657 #if !APPSTORE
590 let updates: Updates 658 let updates: Updates
659 #endif
591 @State private var importing = false 660 @State private var importing = false
661 #if APPSTORE
662 @State private var configFolder = UserConfig.directoryOverride
663 #endif
592 @Environment(\.openWindow) private var openWindow 664 @Environment(\.openWindow) private var openWindow
593 @AppStorage("saveMode") private var saveMode = SaveMode.automatic 665 @AppStorage("saveMode") private var saveMode = SaveMode.automatic
594 @AppStorage("keymap") private var preset = KeymapPreset.emacs 666 @AppStorage("keymap") private var preset = KeymapPreset.emacs
@@ -651,7 +723,11 @@ struct SettingsView: View {
651 Tab("Appearance", systemImage: "paintpalette", value: "appearance") { appearance } 723 Tab("Appearance", systemImage: "paintpalette", value: "appearance") { appearance }
652 Tab("Agenda", systemImage: "calendar", value: "agenda") { agenda } 724 Tab("Agenda", systemImage: "calendar", value: "agenda") { agenda }
653 Tab("Capture", systemImage: "tray.and.arrow.down", value: "capture") { capture } 725 Tab("Capture", systemImage: "tray.and.arrow.down", value: "capture") { capture }
726 #if APPSTORE
727 Tab("orgstar+", systemImage: "star", value: "pro") { StoreForm() }
728 #else
654 Tab("orgstar+", systemImage: "star", value: "pro") { LicenseForm() } 729 Tab("orgstar+", systemImage: "star", value: "pro") { LicenseForm() }
730 #endif
655 } 731 }
656 .frame(width: 600) 732 .frame(width: 600)
657 } 733 }
@@ -662,6 +738,32 @@ struct SettingsView: View {
662 commands.jump(path: UserConfig.configFile.path, offset: 0) 738 commands.jump(path: UserConfig.configFile.path, offset: 0)
663 } 739 }
664 740
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
665 private var general: some View { 767 private var general: some View {
666 Form { 768 Form {
667 Section { 769 Section {
@@ -672,6 +774,14 @@ struct SettingsView: View {
672 Button("Show in Finder") { NSWorkspace.shared.activateFileViewerSelecting([UserConfig.configFile]) } 774 Button("Show in Finder") { NSWorkspace.shared.activateFileViewerSelecting([UserConfig.configFile]) }
673 } 775 }
674 } 776 }
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
675 LabeledContent("Emacs") { 785 LabeledContent("Emacs") {
676 Button("Import from Emacs…") { importing = true } 786 Button("Import from Emacs…") { importing = true }
677 } 787 }
@@ -679,14 +789,16 @@ struct SettingsView: View {
679 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.") 789 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.")
680 .settingsFooter() 790 .settingsFooter()
681 } 791 }
792 #if !APPSTORE
682 if updates.canCheck { 793 if updates.canCheck {
683 Section { 794 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") }
685 } footer: { 796 } 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")
687 .settingsFooter() 798 .settingsFooter()
688 } 799 }
689 } 800 }
801 #endif
690 Section { 802 Section {
691 Picker("Save files", selection: $saveMode) { 803 Picker("Save files", selection: $saveMode) {
692 Text("Automatically, when typing stops").tag(SaveMode.automatic) 804 Text("Automatically, when typing stops").tag(SaveMode.automatic)
Sources/Orgstar/PaneView.swift +4 −1
@@ -109,9 +109,12 @@ struct PaneView: NSViewRepresentable {
109 } 109 }
110 editor.onAppCommand = onAppCommand 110 editor.onAppCommand = onAppCommand
111 editor.onOpenFile = { [weak session, weak commands] typed in 111 editor.onOpenFile = { [weak session, weak commands] typed in
112 let expanded = (typed as NSString).expandingTildeInPath 112 let expanded = OrgPaths.expandingTilde(typed)
113 let base = URL(fileURLWithPath: path).deletingLastPathComponent() 113 let base = URL(fileURLWithPath: path).deletingLastPathComponent()
114 let target = expanded.hasPrefix("/") ? expanded : base.appendingPathComponent(expanded).standardizedFileURL.path 114 let target = expanded.hasPrefix("/") ? expanded : base.appendingPathComponent(expanded).standardizedFileURL.path
115 #if APPSTORE
116 guard commands?.reach([target]) ?? false else { return }
117 #endif
115 guard FileManager.default.fileExists(atPath: target) else { 118 guard FileManager.default.fileExists(atPath: target) else {
116 commands?.show("No file \(typed)") 119 commands?.show("No file \(typed)")
117 return 120 return
Sources/Orgstar/Preferences.swift +9
@@ -6,9 +6,18 @@ import OrgCore
6enum Preferences { 6enum Preferences {
7 static let defaultTodoKeywords = OrgPreferences.defaultTodoKeywords 7 static let defaultTodoKeywords = OrgPreferences.defaultTodoKeywords
8 8
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
9 /// TODO keywords for files without `#+TODO`, read at launch. 15 /// TODO keywords for files without `#+TODO`, read at launch.
10 @MainActor 16 @MainActor
11 static var orgSettings: OrgSettings { 17 static var orgSettings: OrgSettings {
18 #if APPSTORE
19 _ = chosenConfigFolder
20 #endif
12 // config.toml applies before anything reads settings. 21 // config.toml applies before anything reads settings.
13 ConfigSync.shared.start() 22 ConfigSync.shared.start()
14 return OrgPreferences.orgSettings() 23 return OrgPreferences.orgSettings()
Sources/Orgstar/ProLicense.swift +13 −8
@@ -1,6 +1,7 @@
1import OrgApp 1import OrgApp
2import SwiftUI 2import SwiftUI
3 3
4#if !APPSTORE
4/// Pro on the Mac: a license key for sponsoring on GitHub, or an install that predates Pro. 5/// Pro on the Mac: a license key for sponsoring on GitHub, or an install that predates Pro.
5enum MacPro { 6enum MacPro {
6 static let buyURL = URL(string: "https://krz.sh/apps/orgstar/buy")! 7 static let buyURL = URL(string: "https://krz.sh/apps/orgstar/buy")!
@@ -45,7 +46,7 @@ struct LicenseForm: View {
45 LabeledContent("orgstar+", value: license.map { "Licensed to \($0.holder)" } ?? "Licensed") 46 LabeledContent("orgstar+", value: license.map { "Licensed to \($0.holder)" } ?? "Licensed")
46 if let expires = license?.expires { 47 if let expires = license?.expires {
47 let date = Date(timeIntervalSince1970: TimeInterval(expires)).formatted(date: .abbreviated, time: .omitted) 48 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")
49 .foregroundStyle(.secondary) 50 .foregroundStyle(.secondary)
50 } 51 }
51 case .grandfathered: 52 case .grandfathered:
@@ -56,26 +57,28 @@ struct LicenseForm: View {
56 } 57 }
57 if access.grant != .license { 58 if access.grant != .license {
58 Section { 59 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") }
60 .lineLimit(2...4) 61 .lineLimit(2...4)
61 .font(.body.monospaced()) 62 .font(.body.monospaced())
62 .onSubmit(activate) 63 .onSubmit(activate)
63 if let error { Text(error).foregroundStyle(.red) } 64 if let error { Text(error).foregroundStyle(.red) }
64 HStack { 65 HStack {
65 Link("Sponsor for orgstar+…", destination: MacPro.buyURL) 66 Link(destination: MacPro.buyURL) { Text("Sponsor for orgstar+…", tableName: "DeveloperID") }
66 Link("Get Your Key…", destination: MacPro.keyURL) 67 Link(destination: MacPro.keyURL) { Text("Get Your Key…", tableName: "DeveloperID") }
67 Spacer() 68 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)
69 } 70 }
70 } footer: { 71 } 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")
72 } 73 }
73 } else { 74 } else {
74 Section { 75 Section {
75 Button("Remove License from This Mac", role: .destructive) { 76 Button(role: .destructive) {
76 LicenseStore.remove() 77 LicenseStore.remove()
77 license = nil 78 license = nil
78 MacPro.resolve() 79 MacPro.resolve()
80 } label: {
81 Text("Remove License from This Mac", tableName: "DeveloperID")
79 } 82 }
80 } 83 }
81 } 84 }
@@ -113,7 +116,7 @@ struct ProPaywallSheet: View {
113 VStack(alignment: .leading, spacing: 0) { 116 VStack(alignment: .leading, spacing: 0) {
114 VStack(alignment: .leading, spacing: 6) { 117 VStack(alignment: .leading, spacing: 6) {
115 Label("\(feature.title) needs orgstar+", systemImage: feature.systemImage).font(.headline) 118 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")
117 .foregroundStyle(.secondary) 120 .foregroundStyle(.secondary)
118 } 121 }
119 .padding([.horizontal, .top], 20) 122 .padding([.horizontal, .top], 20)
@@ -129,6 +132,8 @@ struct ProPaywallSheet: View {
129 } 132 }
130} 133}
131 134
135#endif
136
132extension ProFeature { 137extension ProFeature {
133 /// The Pro features the Mac app has. 138 /// The Pro features the Mac app has.
134 static let macFeatures: [ProFeature] = [.babel, .export, .encryption, .roam, .widgets, .calendar, .shortcuts] 139 static let macFeatures: [ProFeature] = [.babel, .export, .encryption, .roam, .widgets, .calendar, .shortcuts]
Sources/Orgstar/Sidebar.swift +21
@@ -49,6 +49,27 @@ struct Sidebar: View {
49 .contextMenu { folderMenu(root) } 49 .contextMenu { folderMenu(root) }
50 } 50 }
51 } 51 }
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
52 } 73 }
53 .listStyle(.sidebar) 74 .listStyle(.sidebar)
54 .themedListBackground(theme.color("sidebar-background", in: colorScheme)) 75 .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
1import Combine 2import Combine
2import Sparkle 3import Sparkle
3import SwiftUI 4import SwiftUI
@@ -36,7 +37,8 @@ struct CheckForUpdatesItem: View {
36 let updates: Updates 37 let updates: Updates
37 38
38 var body: some View { 39 var body: some View {
39 Button("Check for Updates…") { updates.check() } 40 Button { updates.check() } label: { Text("Check for Updates…", tableName: "DeveloperID") }
40 .disabled(!updates.canCheck) 41 .disabled(!updates.canCheck)
41 } 42 }
42} 43}
44#endif
Sources/Orgstar/WelcomeView.swift +32 −3
@@ -1,5 +1,6 @@
1import OrgApp 1import OrgApp
2import OrgCore 2import OrgCore
3import OrgWorkspace
3import SwiftUI 4import SwiftUI
4 5
5/// The first launch, with no folder added: add a folder or start one, and pick the keys. 6/// The first launch, with no folder added: add a folder or start one, and pick the keys.
@@ -13,11 +14,12 @@ struct WelcomeView: View {
13 @State private var error: String? 14 @State private var error: String?
14 @Environment(\.dismiss) private var dismiss 15 @Environment(\.dismiss) private var dismiss
15 16
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
16 /// iCloud Drive's folder, when iCloud Drive is on for this user. 20 /// iCloud Drive's folder, when iCloud Drive is on for this user.
17 static var iCloudDrive: URL? { 21 static var iCloudDrive: URL? {
18 let url = FileManager.default.homeDirectoryForCurrentUser 22 FileManager.default.fileExists(atPath: iCloudDriveFolder.path) ? iCloudDriveFolder : nil
19 .appendingPathComponent("Library/Mobile Documents/com~apple~CloudDocs")
20 return FileManager.default.fileExists(atPath: url.path) ? url : nil
21 } 23 }
22 24
23 var body: some View { 25 var body: some View {
@@ -28,14 +30,32 @@ struct WelcomeView: View {
28 ForEach(KeymapPreset.allCases, id: \.self) { Text($0.title).tag($0) } 30 ForEach(KeymapPreset.allCases, id: \.self) { Text($0.title).tag($0) }
29 } 31 }
30 Text(presetNote).font(.callout).foregroundStyle(.secondary) 32 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
31 if let error { Text(error).foregroundStyle(.red) } 45 if let error { Text(error).foregroundStyle(.red) }
32 HStack { 46 HStack {
33 Button("Not Now") { dismiss() } 47 Button("Not Now") { dismiss() }
34 Spacer() 48 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
35 if let drive = Self.iCloudDrive { 54 if let drive = Self.iCloudDrive {
36 Button("New Folder in iCloud Drive") { start(in: drive.appendingPathComponent("org")) } 55 Button("New Folder in iCloud Drive") { start(in: drive.appendingPathComponent("org")) }
37 .help("Makes org/notes.org in iCloud Drive and adds the folder") 56 .help("Makes org/notes.org in iCloud Drive and adds the folder")
38 } 57 }
58 #endif
39 Button("Choose Folder…") { 59 Button("Choose Folder…") {
40 dismiss() 60 dismiss()
41 chooseFolder() 61 chooseFolder()
@@ -55,6 +75,15 @@ struct WelcomeView: View {
55 } 75 }
56 } 76 }
57 77
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
58 /// Makes `folder` with a notes file in it, adds it, and opens the file. 87 /// Makes `folder` with a notes file in it, adds it, and opens the file.
59 private func start(in folder: URL) { 88 private func start(in folder: URL) {
60 Task { 89 Task {
Sources/OrgstarMobile/EditorScreen.swift +1 −1
@@ -337,7 +337,7 @@ struct EditorScreen: View {
337 case "org.link.store": 337 case "org.link.store":
338 let context = editor.editContext() 338 let context = editor.editContext()
339 let denote = OrgPreferences.usesDenote() ? Links.storeDenote(in: context, path: path) : nil 339 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)
341 case "org.id.store-link": 341 case "org.id.store-link":
342 if case .commit = editor.perform(CreateID()), 342 if case .commit = editor.perform(CreateID()),
343 let link = Links.storeID(in: editor.editContext(), fileName: (path as NSString).lastPathComponent) { 343 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 {
93 guard let url = URL(string: path) else { return nil } 93 guard let url = URL(string: path) else { return nil }
94 return RemoteImages.shared.data(for: url, mode: remote, loaded: loaded).flatMap(UIImage.init(data:)) 94 return RemoteImages.shared.data(for: url, mode: remote, loaded: loaded).flatMap(UIImage.init(data:))
95 } 95 }
96 let expanded = (path as NSString).expandingTildeInPath 96 let expanded = OrgPaths.expandingTilde(path)
97 let url: URL 97 let url: URL
98 if expanded.hasPrefix("/") { 98 if expanded.hasPrefix("/") {
99 url = URL(fileURLWithPath: expanded) 99 url = URL(fileURLWithPath: expanded)
Sources/OrgstarMobile/MobileModel.swift +3 −15
@@ -66,11 +66,9 @@ final class MobileModel {
66 @ObservationIgnored private var presenter: FolderPresenter? 66 @ObservationIgnored private var presenter: FolderPresenter?
67 @ObservationIgnored private var sizeObserver: NSObjectProtocol? 67 @ObservationIgnored private var sizeObserver: NSObjectProtocol?
68 68
69 private static let bookmarkKey = "configFolderBookmark"
70
71 private init() { 69 private init() {
72 // Development: `ORGSTAR_CONFIG_DIR` stands in for a chosen folder. 70 // 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) }
74 UserConfig.directoryOverride = folder 72 UserConfig.directoryOverride = folder
75 let (problems, colors) = Self.readConfig(folder) 73 let (problems, colors) = Self.readConfig(folder)
76 let settings = OrgPreferences.orgSettings() 74 let settings = OrgPreferences.orgSettings()
@@ -109,11 +107,10 @@ final class MobileModel {
109 /// Chooses the configuration folder, or with nil stops using one; its settings apply now. 107 /// Chooses the configuration folder, or with nil stops using one; its settings apply now.
110 func setConfigFolder(_ url: URL?) { 108 func setConfigFolder(_ url: URL?) {
111 if let url { 109 if let url {
112 _ = url.startAccessingSecurityScopedResource() 110 ConfigFolder.set(url)
113 if let bookmark = try? url.bookmarkData() { UserDefaults.standard.set(bookmark, forKey: Self.bookmarkKey) }
114 Self.createConfig(in: url) 111 Self.createConfig(in: url)
115 } else { 112 } else {
116 UserDefaults.standard.removeObject(forKey: Self.bookmarkKey) 113 ConfigFolder.clear()
117 // What the folder set no longer applies. 114 // What the folder set no longer applies.
118 for setting in UserConfig.settings { UserDefaults.standard.removeObject(forKey: setting.defaultsKey) } 115 for setting in UserConfig.settings { UserDefaults.standard.removeObject(forKey: setting.defaultsKey) }
119 } 116 }
@@ -217,15 +214,6 @@ final class MobileModel {
217 self.presenter = presenter 214 self.presenter = presenter
218 } 215 }
219 216
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
229 /// Applies the folder's `config.toml` to the settings; returns its problems and the theme's 217 /// Applies the folder's `config.toml` to the settings; returns its problems and the theme's
230 /// colors. 218 /// colors.
231 /// Writes `config.toml` with every setting at its default when the folder has none. 219 /// 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
4import SwiftUI 4import SwiftUI
5import UIKit 5import UIKit
6 6
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
113/// orgstar+'s gold, for its banner in Settings and its screen. 7/// orgstar+'s gold, for its banner in Settings and its screen.
114extension ShapeStyle where Self == LinearGradient { 8extension ShapeStyle where Self == LinearGradient {
115 static var plusGold: LinearGradient { 9 static var plusGold: LinearGradient {
@@ -246,11 +140,9 @@ struct ProScreen: View {
246 /// How much the yearly plan saves against twelve months, in whole percent. 140 /// How much the yearly plan saves against twelve months, in whole percent.
247 private func savings(_ product: Product) -> Int? { 141 private func savings(_ product: Product) -> Int? {
248 guard product.id == ProStore.yearly, 142 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 })
250 else { return nil } 144 else { return nil }
251 let ratio = NSDecimalNumber(decimal: product.price / (monthly.price * 12)).doubleValue 145 return ProStore.yearlySavings(yearly: product.price, monthly: monthly.price)
252 let percent = Int((1 - ratio) * 100)
253 return percent > 0 ? percent : nil
254 } 146 }
255 147
256 private var status: LocalizedStringKey { 148 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
2import SwiftUI 2import SwiftUI
3import WidgetKit 3import WidgetKit
4 4
5/// Whether the app lacks Pro, which the widgets need. Only iOS shares the flag with the widgets; 5/// Whether the app lacks Pro, which the widgets need. iOS and the App Store Mac app share the flag
6/// the Mac app stops writing their data instead. 6/// with the widgets; the Developer ID Mac app stops writing their data instead.
7var widgetsLocked: Bool { 7var widgetsLocked: Bool {
8 #if os(iOS) 8 #if os(iOS) || APPSTORE
9 !ProAccess.isUnlockedNow 9 !ProAccess.isUnlockedNow
10 #else 10 #else
11 false 11 false
Sources/OrgstarWidgets/OrgstarWidgets.swift +7
@@ -8,6 +8,13 @@ import WidgetKit
8/// the desktop and in Notification Center. 8/// the desktop and in Notification Center.
9@main 9@main
10struct OrgstarWidgets: WidgetBundle { 10struct 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
11 var body: some Widget { 18 var body: some Widget {
12 TodayWidget() 19 TodayWidget()
13 HabitsWidget() 20 HabitsWidget()
Tests/OrgAppTests/AppTests.swift +45 −145
@@ -95,6 +95,37 @@ struct WorkspaceModelTests {
95 #expect(reopened.roots.count == 1) 95 #expect(reopened.roots.count == 1)
96 } 96 }
97 97
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
98 @Test func listsDownloadsInTheTree() { 129 @Test func listsDownloadsInTheTree() {
99 let files = [FileEntry(path: "/r/a.org", root: "/r", kind: .org)] 130 let files = [FileEntry(path: "/r/a.org", root: "/r", kind: .org)]
100 let tree = FileTreeNode.build(root: "/r", files: files, downloading: ["/r/b.org", "/r/sub/c.org"]) 131 let tree = FileTreeNode.build(root: "/r", files: files, downloading: ["/r/b.org", "/r/sub/c.org"])
@@ -949,157 +980,26 @@ struct ReminderSchedulerTests {
949 } 980 }
950} 981}
951 982
983/// Without `DocumentSession.programs`, only Emacs Lisp runs, natively.
952@MainActor 984@MainActor
953struct EmacsFallbackTests { 985struct NativeProgramsTests {
954 @Test(.enabled(if: EmacsRunner.executable() != nil && ProcessInfo.processInfo.environment["ORGSTAR_SKIP_ORACLE"] == nil)) 986 @Test func runsOnlyNativeBlocksWithoutARunner() async throws {
955 func recalculatesTablesNativeCodeCannot() async throws { 987 #expect(DocumentSession.runner == nil)
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 {
994 let notes = try Folder() 988 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")
996 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r"))) 990 let session = DocumentSession(recovery: FileRecoveryStore(directory: notes.url.appendingPathComponent(".r")))
997 session.open(file.path) 991 session.open(file.path)
998 let step = session.perform(ExecuteSrcBlock(), path: file.path, at: 3, expect: nil) 992 guard case .external(.babel(let sh)) = session.perform(ExecuteSrcBlock(), path: file.path, at: 3, expect: nil),
999 guard case .external(.babel(let job)) = step else { 993 case .external(.babel(let lisp)) = session.perform(ExecuteSrcBlock(), path: file.path, at: 40, expect: nil) else {
1000 Issue.record("\(step)") 994 Issue.record("not planned")
1001 return 995 return
1002 } 996 }
1003 #expect(await session.runBabel(job) == "Code block evaluation complete.") 997 #if os(macOS)
1004 // A column that is half numbers is right-aligned, as org-table-align does. 998 #expect(await session.runBabel(sh) == "sh blocks don't run in this version of orgstar.")
1005 #expect(session.document?.text == "#+begin_src sh\necho answer\necho \"$((6 * 7))\"\n#+end_src\n\n#+RESULTS:\n| answer |\n| 42 |\n") 999 #expect(await session.recalculateInEmacs(table: 0..<1, point: 0, form: "") == "Tables that need Emacs aren't recalculated in this version of orgstar.")
1006 } 1000 #endif
1007} 1001 #expect(await session.runBabel(lisp) == "Code block evaluation complete.")
1008 1002 #expect(session.document?.text.hasSuffix("#+RESULTS:\n: 3\n") == true)
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)
1103 } 1003 }
1104} 1004}
1105 1005
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 {
31 #expect(css.contains("font-family: \"Georgia\"")) 31 #expect(css.contains("font-family: \"Georgia\""))
32 #expect(!PDFExport.css(PDFExport.Options()).contains("font-family")) 32 #expect(!PDFExport.css(PDFExport.Options()).contains("font-family"))
33 } 33 }
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 }
34} 57}
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 @@
1import Foundation 1import Foundation
2import OrgCore
3import Testing 2import Testing
4@testable import OrgApp 3@testable import OrgApp
4@testable import OrgCore
5 5
6struct TangleWriterTests { 6struct TangleWriterTests {
7 @Test func writesMakesFoldersAndSetsModes() throws { 7 @Test func writesMakesFoldersAndSetsModes() throws {
@@ -42,4 +42,23 @@ struct TangleWriterTests {
42 try TangleWriter.write(own, source: source.path) 42 try TangleWriter.write(own, source: source.path)
43 } 43 }
44 } 44 }
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 }
45} 64}
Tests/OrgAppTests/TipTests.swift +30
@@ -1,3 +1,4 @@
1import Foundation
1import Testing 2import Testing
2@testable import OrgApp 3@testable import OrgApp
3 4
@@ -15,3 +16,32 @@ struct TipTests {
15 #expect(Tip.productIDs.allSatisfy { !$0.hasPrefix("sh.krz.orgstar.pro.") }) 16 #expect(Tip.productIDs.allSatisfy { !$0.hasPrefix("sh.krz.orgstar.pro.") })
16 } 17 }
17} 18}
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 {
310 #expect(try String(contentsOf: folder.appendingPathComponent("config.toml"), encoding: .utf8).contains("dark-theme = \"nord\"")) 310 #expect(try String(contentsOf: folder.appendingPathComponent("config.toml"), encoding: .utf8).contains("dark-theme = \"nord\""))
311 #expect(sync.theme.dark["background"] == ThemeSpec.palette("nord", .dark)?.colors["background"]) 311 #expect(sync.theme.dark["background"] == ThemeSpec.palette("nord", .dark)?.colors["background"])
312 } 312 }
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 }
313} 323}
Tests/OrgAppTests/WidgetDataTests.swift +8
@@ -101,5 +101,13 @@ struct MacWidgetFolderTests {
101 #expect(!agenda.path.contains("/Containers/")) 101 #expect(!agenda.path.contains("/Containers/"))
102 #expect(HabitSnapshot.file()?.deletingLastPathComponent() == agenda.deletingLastPathComponent()) 102 #expect(HabitSnapshot.file()?.deletingLastPathComponent() == agenda.deletingLastPathComponent())
103 } 103 }
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 }
104} 112}
105#endif 113#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 {
104 let ours = ExportPreprocess.macros(ExportPreprocess.includes(text, directory: folder), path: path) 104 let ours = ExportPreprocess.macros(ExportPreprocess.includes(text, directory: folder), path: path)
105 #expect(ours == emacs.first, "ours:\n\(ours)\nemacs:\n\(emacs.first ?? "")") 105 #expect(ours == emacs.first, "ours:\n\(ours)\nemacs:\n\(emacs.first ?? "")")
106 } 106 }
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 }
107} 123}
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 {
181 #expect(try FileManager.default.contentsOfDirectory(atPath: folder.path) == ["a.org"]) 181 #expect(try FileManager.default.contentsOfDirectory(atPath: folder.path) == ["a.org"])
182 } 182 }
183 183
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
184 @Test func savesThroughTheRealFileSystem() throws { 210 @Test func savesThroughTheRealFileSystem() throws {
185 let folder = try temporaryFolder() 211 let folder = try temporaryFolder()
186 defer { try? FileManager.default.removeItem(at: folder) } 212 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
2import Testing 2import Testing
3import OrgCore 3import OrgCore
4@testable import OrgApp 4@testable import OrgApp
5@testable import OrgPrograms
5 6
6/// Serial: the sessions are shared, and each test stops them all when it ends. 7/// Serial: the sessions are shared, and each test stops them all when it ends.
7@Suite(.serialized) 8@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
538=Recalculation canceled= and the table is unchanged. Starting another recalculation or 538=Recalculation canceled= and the table is unchanged. Starting another recalculation or
539export in Emacs cancels the one that is running. 539export in Emacs cancels the one that is running.
540 540
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
541If the table's formulas contain Lisp, orgstar asks first: 545If the table's formulas contain Lisp, orgstar asks first:
542=This table's formulas run Lisp. Run them? (yes, no, always)=. =always= trusts this 546=This table's formulas run Lisp. Run them? (yes, no, always)=. =always= trusts this
543table's text in this file, so the question isn't asked again until the text changes. 547table's text in this file, so the question isn't asked again until the text changes.
@@ -624,6 +628,9 @@ new plot.
624 628
625=type:radar= needs gnuplot; orgstar reports it. 629=type:radar= needs gnuplot; orgstar reports it.
626 630
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
627* On iOS 634* On iOS
628 635
629The iOS app evaluates formulas natively with the same engine. Tables that need Emacs 636The 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."
103 103
104A run that takes longer than five minutes is stopped. Runs in a =:session= have no time limit. 104A run that takes longer than five minutes is stopped. Runs in a =:session= have no time limit.
105 105
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
106** Compiled languages 108** Compiled languages
107 109
108On 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. 110On 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
600 602
601On 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. 603On 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.
602 604
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
603Variables are bound with =let= around the body. =:results output= collects what the block prints with =princ=, =prin1=, =print= and =terpri=. 607Variables are bound with =let= around the body. =:results output= collects what the block prints with =princ=, =prin1=, =print= and =terpri=.
604 608
605* Graphics 609* Graphics
@@ -708,6 +712,7 @@ Comments need the language's comment syntax. orgstar knows it for: =emacs-lisp=,
708- A file whose contents would not change is left alone, so its modification time stays the same. 712- A file whose contents would not change is left alone, so its modification time stays the same.
709- A read-only file is replaced. 713- A read-only file is replaced.
710- Tangling into the Org file itself is refused: "Not allowed to tangle into the same file as self". 714- 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/".
711 716
712** What tangling refuses 717** What tangling refuses
713 718
@@ -731,3 +736,10 @@ Tangling stops, writes nothing and says why when:
731- Edit Block opens a plain text sheet without highlighting. 736- Edit Block opens a plain text sheet without highlighting.
732 737
733See [[file:14-ios.org][iOS]] for the rest of the iOS app. 738See [[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
29 29
30All 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/". 30All 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/".
31 31
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
32** The export dialog 34** The export dialog
33 35
34*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: 36*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 =
338| ODT | =org-odt-export-to-odt= | 340| ODT | =org-odt-export-to-odt= |
339| Plain text | =org-ascii-export-to-ascii= | 341| Plain text | =org-ascii-export-to-ascii= |
340 342
343The [[file:../install.org][Mac App Store version]] doesn't run Emacs and has none of these exports.
344
341orgstar 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/". 345orgstar 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/".
342 346
343What you need: 347What you need:
docs/manual/guide/13-configuration.org +6
@@ -11,6 +11,8 @@ orgstar keeps its settings in a configuration folder:
11 11
12The 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. 12The 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.
13 13
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
14The folder holds these files: 16The folder holds these files:
15 17
16| File | What it holds | Written by orgstar | 18| File | What it holds | Written by orgstar |
@@ -54,6 +56,8 @@ Open it with orgstar ▸ Settings (=⌘,=). It has five panes. Each control writ
54| config.toml: Edit in orgstar | Opens the file in the main window | | | 56| config.toml: Edit in orgstar | Opens the file in the main window | | |
55| config.toml: Open with Default App | Opens the file in the app macOS uses for =.toml= | | | 57| config.toml: Open with Default App | Opens the file in the app macOS uses for =.toml= | | |
56| config.toml: Show in Finder | Selects the file in Finder | | | 58| 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 | | |
57| Emacs: Import from Emacs… | Opens the import sheet; see Import from Emacs below| | | 61| Emacs: Import from Emacs… | Opens the import sheet; see Import from Emacs below| | |
58| Save files | Automatically, when typing stops; Only with File ▸ Save (=⌘S=) | Automatically | =save= | 62| Save files | Automatically, when typing stops; Only with File ▸ Save (=⌘S=) | Automatically | =save= |
59| Keys | Emacs; Mac; Doom (Vim keys) | Emacs | =keymap= | 63| 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
569 573
570On iOS, Settings ▸ Import from Emacs reads a configuration folder you choose; see [[file:14-ios.org][iOS]]. 574On iOS, Settings ▸ Import from Emacs reads a configuration folder you choose; see [[file:14-ios.org][iOS]].
571 575
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
572** Doom Emacs 578** Doom Emacs
573 579
574A 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. 580A 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
97Every 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: 97Every 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:
98 98
99- on the Mac, =~/Library/Application Support/Orgstar/Recovery= (or =$ORGSTAR_DATA_DIR/Recovery=), 99- 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=,
100- on iOS, the app's own Application Support folder. 101- on iOS, the app's own Application Support folder.
101 102
102Each 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: 103Each 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
112 113
113* Features that use Emacs on the Mac 114* Features that use Emacs on the Mac
114 115
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.
116 117
117| Feature | What runs | 118| Feature | What runs |
118|----------------------------------------------------------------+-----------------------------------------------------------------------------------------------| 119|----------------------------------------------------------------+-----------------------------------------------------------------------------------------------|
docs/manual/index.org +1 −1
@@ -15,7 +15,7 @@ reminders, export and tangling.
15 15
16* Start here 16* Start here
17 17
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.
19- [[file:quickstart.org][Quick start]]: add a folder, open a file, and the first keys to learn. 19- [[file:quickstart.org][Quick start]]: add a folder, open a file, and the first keys to learn.
20- The manual, below: every feature, chapter by chapter. 20- The manual, below: every feature, chapter by chapter.
21 21
docs/manual/install.org +111 −5
@@ -1,17 +1,35 @@
1#+TITLE: Install 1#+TITLE: Install
2#+DESCRIPTION: Installing orgstar on the Mac with Homebrew or a download, and on iPhone and iPad from 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 as a notarized download and a Homebrew cask; the iOS app is on 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.
4 4
5* Requirements 5* Requirements
6 6
7- macOS 26 or later. 7- 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
9 (Emacs Lisp code blocks that need full Emacs, Lisp table formulas the built-in 9 (Emacs Lisp code blocks that need full Emacs, Lisp table formulas the built-in
10 interpreter can't run, and export to PDF, LaTeX, ODT and other formats). See 10 interpreter can't run, and export to PDF, LaTeX, ODT and other formats). See
11 [[file:guide/15-alongside-emacs.org][Working alongside Emacs and other tools]]. 11 [[file:guide/15-alongside-emacs.org][Working alongside Emacs and other tools]].
12 12
13* The Mac app 13* The Mac app
14 14
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
15** With Homebrew 33** With Homebrew
16 34
17#+BEGIN_SRC sh 35#+BEGIN_SRC sh
@@ -26,7 +44,89 @@ orgstar to Applications. The app is universal (Apple silicon and Intel), signed
26Developer ID and notarized by Apple, so it opens without warnings. 44Developer ID and notarized by Apple, so it opens without warnings.
27 45
28Once the app has been launched, Finder opens =.org= files with it, Quick Look shows 46Once 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
30 130
31* The iOS app 131* The iOS app
32 132
@@ -37,6 +137,9 @@ See [[file:guide/14-ios.org][iPhone and iPad]] for what it does.
37 137
38* Updating 138* Updating
39 139
140The Mac App Store updates the App Store version. The rest of this section is about the download
141version.
142
40orgstar checks for a new release once a day, after asking on its second launch whether it 143orgstar checks for a new release once a day, after asking on its second launch whether it
41may; orgstar ▸ Check for Updates… checks now, and Settings ▸ General has the switch. An update 144may; orgstar ▸ Check for Updates… checks now, and Settings ▸ General has the switch. An update
42downloads, is checked against the key the releases are signed with, and installs when you 145downloads, 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.
53* Uninstalling 156* Uninstalling
54 157
55Delete =orgstar.app=, or run =brew uninstall --cask orgstar=. To remove your settings as 158Delete =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/=.
57Your org files are never stored inside the app. 163Your 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
61## Privacy policy URL 61## Privacy policy URL
62 62
63https://krz.sh/privacy/orgstar/ 63https://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 @@
21 0A61626884F48A1B4963D767 /* OrgWatchData in Frameworks */ = {isa = PBXBuildFile; productRef = 925F6F580D155C1597A5F07B /* OrgWatchData */; }; 21 0A61626884F48A1B4963D767 /* OrgWatchData in Frameworks */ = {isa = PBXBuildFile; productRef = 925F6F580D155C1597A5F07B /* OrgWatchData */; };
22 C6824548013D3A2076EAF9C7 /* OrgWatchData in Frameworks */ = {isa = PBXBuildFile; productRef = 2EFA0D9CD8BD435F6283F3AA /* OrgWatchData */; }; 22 C6824548013D3A2076EAF9C7 /* OrgWatchData in Frameworks */ = {isa = PBXBuildFile; productRef = 2EFA0D9CD8BD435F6283F3AA /* OrgWatchData */; };
23 625E39E946591E6D43200C02 /* OrgstarWatch/Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C908C5209CABA6130FD12641 /* OrgstarWatch/Assets.xcassets */; }; 23 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, ); };
24/* End PBXBuildFile section */ 37/* End PBXBuildFile section */
25 38
26/* Begin PBXContainerItemProxy section */ 39/* Begin PBXContainerItemProxy section */
@@ -59,6 +72,27 @@
59 remoteGlobalIDString = 9571051E69F5D60E9CDFD246; 72 remoteGlobalIDString = 9571051E69F5D60E9CDFD246;
60 remoteInfo = OrgstarWatch; 73 remoteInfo = OrgstarWatch;
61 }; 74 };
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 };
62/* End PBXContainerItemProxy section */ 96/* End PBXContainerItemProxy section */
63 97
64/* Begin PBXCopyFilesBuildPhase section */ 98/* Begin PBXCopyFilesBuildPhase section */
@@ -97,6 +131,19 @@
97 name = "Embed Watch Content"; 131 name = "Embed Watch Content";
98 runOnlyForDeploymentPostprocessing = 0; 132 runOnlyForDeploymentPostprocessing = 0;
99 }; 133 };
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 };
100/* End PBXCopyFilesBuildPhase section */ 147/* End PBXCopyFilesBuildPhase section */
101 148
102/* Begin PBXFileReference section */ 149/* Begin PBXFileReference section */
@@ -120,6 +167,20 @@
120 512F8C0EB67DE2C4AB5051D4 /* OrgstarWatchWidgets/Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = OrgstarWatchWidgets/Info.plist; sourceTree = "<group>"; }; 167 512F8C0EB67DE2C4AB5051D4 /* OrgstarWatchWidgets/Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = OrgstarWatchWidgets/Info.plist; sourceTree = "<group>"; };
121 970E22E052046C63CA01A88F /* OrgstarWatch/OrgstarWatch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarWatch/OrgstarWatch.entitlements; sourceTree = "<group>"; }; 168 970E22E052046C63CA01A88F /* OrgstarWatch/OrgstarWatch.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarWatch/OrgstarWatch.entitlements; sourceTree = "<group>"; };
122 F75B5AA8EBA6F457B6D124AC /* OrgstarWatchWidgets/OrgstarWatchWidgets.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = OrgstarWatchWidgets/OrgstarWatchWidgets.entitlements; sourceTree = "<group>"; }; 169 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>"; };
123/* End PBXFileReference section */ 184/* End PBXFileReference section */
124 185
125/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */ 186/* Begin PBXFileSystemSynchronizedBuildFileExceptionSet section */
@@ -137,6 +198,13 @@
137 ); 198 );
138 target = 92364A1473ECC9B162FEAE51 /* OrgstarShare */; 199 target = 92364A1473ECC9B162FEAE51 /* OrgstarShare */;
139 }; 200 };
201 4B121E9E27D011F773E768FF /* Exceptions for "../Sources/OrgstarSpotlight" folder in "OrgstarSpotlight" target */ = {
202 isa = PBXFileSystemSynchronizedBuildFileExceptionSet;
203 membershipExceptions = (
204 main.swift,
205 );
206 target = 983BBE813E871966964F6876 /* OrgstarSpotlight */;
207 };
140/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */ 208/* End PBXFileSystemSynchronizedBuildFileExceptionSet section */
141 209
142/* Begin PBXFileSystemSynchronizedRootGroup section */ 210/* Begin PBXFileSystemSynchronizedRootGroup section */
@@ -176,6 +244,19 @@
176 path = ../Sources/OrgstarWatchWidgets; 244 path = ../Sources/OrgstarWatchWidgets;
177 sourceTree = "<group>"; 245 sourceTree = "<group>";
178 }; 246 };
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 };
179/* End PBXFileSystemSynchronizedRootGroup section */ 260/* End PBXFileSystemSynchronizedRootGroup section */
180 261
181/* Begin PBXFrameworksBuildPhase section */ 262/* Begin PBXFrameworksBuildPhase section */
@@ -228,6 +309,24 @@
228 ); 309 );
229 runOnlyForDeploymentPostprocessing = 0; 310 runOnlyForDeploymentPostprocessing = 0;
230 }; 311 };
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 };
231/* End PBXFrameworksBuildPhase section */ 330/* End PBXFrameworksBuildPhase section */
232 331
233/* Begin PBXGroup section */ 332/* Begin PBXGroup section */
@@ -240,6 +339,8 @@
240 B54C32C5D364C02EE21DB092 /* OrgstarWidgets.appex */, 339 B54C32C5D364C02EE21DB092 /* OrgstarWidgets.appex */,
241 8A7A8B14798B54AA57D91D55 /* OrgstarWatch.app */, 340 8A7A8B14798B54AA57D91D55 /* OrgstarWatch.app */,
242 03F7E491D72C8915E6CB2542 /* OrgstarWatchWidgets.appex */, 341 03F7E491D72C8915E6CB2542 /* OrgstarWatchWidgets.appex */,
342 C51149D0B6EA8A5C84383462 /* orgstar.app */,
343 AC88ABFF2E0DEC4AD6935E44 /* OrgstarSpotlight.appex */,
243 ); 344 );
244 name = Products; 345 name = Products;
245 sourceTree = "<group>"; 346 sourceTree = "<group>";
@@ -250,6 +351,8 @@
250 6425CB8F177EDFF8EE2BD447 /* ../Sources/OrgstarShare */, 351 6425CB8F177EDFF8EE2BD447 /* ../Sources/OrgstarShare */,
251 2412EC8ED6427B76498FCD18 /* ../Sources/OrgstarQuickLook */, 352 2412EC8ED6427B76498FCD18 /* ../Sources/OrgstarQuickLook */,
252 7E85FA5E5BA11D0F6891693E /* ../Sources/OrgstarMobile */, 353 7E85FA5E5BA11D0F6891693E /* ../Sources/OrgstarMobile */,
354 5492CCAC81DA9B3B7C8E53D9 /* ../Sources/Orgstar */,
355 DCA0D699899E2CA4B0F5956F /* ../Sources/OrgstarSpotlight */,
253 DE99BDA1BB90EEDFA8FF4CC2 /* ../Sources/OrgstarWidgets */, 356 DE99BDA1BB90EEDFA8FF4CC2 /* ../Sources/OrgstarWidgets */,
254 0D702B6721D2BC88F89E3883 /* ../Sources/OrgstarWatch */, 357 0D702B6721D2BC88F89E3883 /* ../Sources/OrgstarWatch */,
255 C2450FF4F75DA4598ABE47D6 /* ../Sources/OrgstarWatchWidgets */, 358 C2450FF4F75DA4598ABE47D6 /* ../Sources/OrgstarWatchWidgets */,
@@ -275,6 +378,18 @@
275 970E22E052046C63CA01A88F /* OrgstarWatch/OrgstarWatch.entitlements */, 378 970E22E052046C63CA01A88F /* OrgstarWatch/OrgstarWatch.entitlements */,
276 512F8C0EB67DE2C4AB5051D4 /* OrgstarWatchWidgets/Info.plist */, 379 512F8C0EB67DE2C4AB5051D4 /* OrgstarWatchWidgets/Info.plist */,
277 F75B5AA8EBA6F457B6D124AC /* OrgstarWatchWidgets/OrgstarWatchWidgets.entitlements */, 380 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 */,
278 ); 393 );
279 name = Support; 394 name = Support;
280 sourceTree = "<group>"; 395 sourceTree = "<group>";
@@ -434,6 +549,59 @@
434 productReference = 03F7E491D72C8915E6CB2542 /* OrgstarWatchWidgets.appex */; 549 productReference = 03F7E491D72C8915E6CB2542 /* OrgstarWatchWidgets.appex */;
435 productType = "com.apple.product-type.app-extension"; 550 productType = "com.apple.product-type.app-extension";
436 }; 551 };
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 };
437/* End PBXNativeTarget section */ 605/* End PBXNativeTarget section */
438 606
439/* Begin PBXProject section */ 607/* Begin PBXProject section */
@@ -472,6 +640,8 @@
472 E87BE20AFDC99FD25E1A163F /* OrgstarWidgets */, 640 E87BE20AFDC99FD25E1A163F /* OrgstarWidgets */,
473 9571051E69F5D60E9CDFD246 /* OrgstarWatch */, 641 9571051E69F5D60E9CDFD246 /* OrgstarWatch */,
474 A7FEE6F7EC27BB417D26E08E /* OrgstarWatchWidgets */, 642 A7FEE6F7EC27BB417D26E08E /* OrgstarWatchWidgets */,
643 B4840CC47B21EF2ECB49A2B1 /* Orgstar macOS */,
644 983BBE813E871966964F6876 /* OrgstarSpotlight */,
475 ); 645 );
476 }; 646 };
477/* End PBXProject section */ 647/* End PBXProject section */
@@ -496,6 +666,7 @@
496 isa = PBXResourcesBuildPhase; 666 isa = PBXResourcesBuildPhase;
497 buildActionMask = 2147483647; 667 buildActionMask = 2147483647;
498 files = ( 668 files = (
669 9B607A4A9227D06D4F53091C /* OrgstarQuickLook/PrivacyInfo.xcprivacy in Resources */,
499 ); 670 );
500 runOnlyForDeploymentPostprocessing = 0; 671 runOnlyForDeploymentPostprocessing = 0;
501 }; 672 };
@@ -503,6 +674,7 @@
503 isa = PBXResourcesBuildPhase; 674 isa = PBXResourcesBuildPhase;
504 buildActionMask = 2147483647; 675 buildActionMask = 2147483647;
505 files = ( 676 files = (
677 3AA1AFEEC1E57E8A3A1AF804 /* OrgstarWidgets/PrivacyInfo.xcprivacy in Resources */,
506 ); 678 );
507 runOnlyForDeploymentPostprocessing = 0; 679 runOnlyForDeploymentPostprocessing = 0;
508 }; 680 };
@@ -521,6 +693,24 @@
521 ); 693 );
522 runOnlyForDeploymentPostprocessing = 0; 694 runOnlyForDeploymentPostprocessing = 0;
523 }; 695 };
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 };
524/* End PBXResourcesBuildPhase section */ 714/* End PBXResourcesBuildPhase section */
525 715
526/* Begin PBXShellScriptBuildPhase section */ 716/* Begin PBXShellScriptBuildPhase section */
@@ -679,6 +869,37 @@
679 shellPath = /bin/sh; 869 shellPath = /bin/sh;
680 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"; 870 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";
681 }; 871 };
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 };
682/* End PBXShellScriptBuildPhase section */ 903/* End PBXShellScriptBuildPhase section */
683 904
684/* Begin PBXSourcesBuildPhase section */ 905/* Begin PBXSourcesBuildPhase section */
@@ -724,6 +945,20 @@
724 ); 945 );
725 runOnlyForDeploymentPostprocessing = 0; 946 runOnlyForDeploymentPostprocessing = 0;
726 }; 947 };
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 };
727/* End PBXSourcesBuildPhase section */ 962/* End PBXSourcesBuildPhase section */
728 963
729/* Begin PBXTargetDependency section */ 964/* Begin PBXTargetDependency section */
@@ -752,12 +987,28 @@
752 target = 9571051E69F5D60E9CDFD246 /* OrgstarWatch */; 987 target = 9571051E69F5D60E9CDFD246 /* OrgstarWatch */;
753 targetProxy = 3CD251D01E4C9C2DC6EA4271 /* PBXContainerItemProxy */; 988 targetProxy = 3CD251D01E4C9C2DC6EA4271 /* PBXContainerItemProxy */;
754 }; 989 };
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 };
755/* End PBXTargetDependency section */ 1005/* End PBXTargetDependency section */
756 1006
757/* Begin XCBuildConfiguration section */ 1007/* Begin XCBuildConfiguration section */
758 0BF40655E429259B35B06BEC /* Release */ = { 1008 0BF40655E429259B35B06BEC /* Release */ = {
759 isa = XCBuildConfiguration; 1009 isa = XCBuildConfiguration;
760 buildSettings = { 1010 buildSettings = {
1011 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements;
761 CODE_SIGN_STYLE = Automatic; 1012 CODE_SIGN_STYLE = Automatic;
762 CURRENT_PROJECT_VERSION = 17; 1013 CURRENT_PROJECT_VERSION = 17;
763 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1014 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -768,10 +1019,20 @@
768 "@executable_path/Frameworks", 1019 "@executable_path/Frameworks",
769 "@executable_path/../../Frameworks", 1020 "@executable_path/../../Frameworks",
770 ); 1021 );
1022 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1023 "$(inherited)",
1024 "@executable_path/../Frameworks",
1025 "@executable_path/../../../../Frameworks",
1026 );
1027 MACOSX_DEPLOYMENT_TARGET = 26.0;
771 MARKETING_VERSION = 1.1.0; 1028 MARKETING_VERSION = 1.1.0;
772 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.quicklook; 1029 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.quicklook;
773 PRODUCT_NAME = "$(TARGET_NAME)"; 1030 PRODUCT_NAME = "$(TARGET_NAME)";
1031 SDKROOT = auto;
774 SKIP_INSTALL = YES; 1032 SKIP_INSTALL = YES;
1033 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1034 SUPPORTS_MACCATALYST = NO;
1035 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
775 TARGETED_DEVICE_FAMILY = "1,2"; 1036 TARGETED_DEVICE_FAMILY = "1,2";
776 }; 1037 };
777 name = Release; 1038 name = Release;
@@ -849,6 +1110,7 @@
849 isa = XCBuildConfiguration; 1110 isa = XCBuildConfiguration;
850 buildSettings = { 1111 buildSettings = {
851 CODE_SIGN_ENTITLEMENTS = OrgstarWidgets/OrgstarWidgets.entitlements; 1112 CODE_SIGN_ENTITLEMENTS = OrgstarWidgets/OrgstarWidgets.entitlements;
1113 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarWidgets/OrgstarWidgets-macOS.entitlements;
852 CODE_SIGN_STYLE = Automatic; 1114 CODE_SIGN_STYLE = Automatic;
853 CURRENT_PROJECT_VERSION = 17; 1115 CURRENT_PROJECT_VERSION = 17;
854 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1116 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -860,10 +1122,20 @@
860 "@executable_path/Frameworks", 1122 "@executable_path/Frameworks",
861 "@executable_path/../../Frameworks", 1123 "@executable_path/../../Frameworks",
862 ); 1124 );
1125 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1126 "$(inherited)",
1127 "@executable_path/../Frameworks",
1128 "@executable_path/../../../../Frameworks",
1129 );
1130 MACOSX_DEPLOYMENT_TARGET = 26.0;
863 MARKETING_VERSION = 1.1.0; 1131 MARKETING_VERSION = 1.1.0;
864 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.widgets; 1132 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.widgets;
865 PRODUCT_NAME = "$(TARGET_NAME)"; 1133 PRODUCT_NAME = "$(TARGET_NAME)";
1134 SDKROOT = auto;
866 SKIP_INSTALL = YES; 1135 SKIP_INSTALL = YES;
1136 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1137 SUPPORTS_MACCATALYST = NO;
1138 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
867 TARGETED_DEVICE_FAMILY = "1,2"; 1139 TARGETED_DEVICE_FAMILY = "1,2";
868 }; 1140 };
869 name = Debug; 1141 name = Debug;
@@ -871,6 +1143,7 @@
871 942C95A5D90B164020736D83 /* Debug */ = { 1143 942C95A5D90B164020736D83 /* Debug */ = {
872 isa = XCBuildConfiguration; 1144 isa = XCBuildConfiguration;
873 buildSettings = { 1145 buildSettings = {
1146 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarQuickLook/OrgstarQuickLook-macOS.entitlements;
874 CODE_SIGN_STYLE = Automatic; 1147 CODE_SIGN_STYLE = Automatic;
875 CURRENT_PROJECT_VERSION = 17; 1148 CURRENT_PROJECT_VERSION = 17;
876 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1149 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -881,10 +1154,20 @@
881 "@executable_path/Frameworks", 1154 "@executable_path/Frameworks",
882 "@executable_path/../../Frameworks", 1155 "@executable_path/../../Frameworks",
883 ); 1156 );
1157 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1158 "$(inherited)",
1159 "@executable_path/../Frameworks",
1160 "@executable_path/../../../../Frameworks",
1161 );
1162 MACOSX_DEPLOYMENT_TARGET = 26.0;
884 MARKETING_VERSION = 1.1.0; 1163 MARKETING_VERSION = 1.1.0;
885 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.quicklook; 1164 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.quicklook;
886 PRODUCT_NAME = "$(TARGET_NAME)"; 1165 PRODUCT_NAME = "$(TARGET_NAME)";
1166 SDKROOT = auto;
887 SKIP_INSTALL = YES; 1167 SKIP_INSTALL = YES;
1168 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1169 SUPPORTS_MACCATALYST = NO;
1170 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
888 TARGETED_DEVICE_FAMILY = "1,2"; 1171 TARGETED_DEVICE_FAMILY = "1,2";
889 }; 1172 };
890 name = Debug; 1173 name = Debug;
@@ -935,6 +1218,7 @@
935 isa = XCBuildConfiguration; 1218 isa = XCBuildConfiguration;
936 buildSettings = { 1219 buildSettings = {
937 CODE_SIGN_ENTITLEMENTS = OrgstarWidgets/OrgstarWidgets.entitlements; 1220 CODE_SIGN_ENTITLEMENTS = OrgstarWidgets/OrgstarWidgets.entitlements;
1221 "CODE_SIGN_ENTITLEMENTS[sdk=macosx*]" = OrgstarWidgets/OrgstarWidgets-macOS.entitlements;
938 CODE_SIGN_STYLE = Automatic; 1222 CODE_SIGN_STYLE = Automatic;
939 CURRENT_PROJECT_VERSION = 17; 1223 CURRENT_PROJECT_VERSION = 17;
940 DEVELOPMENT_TEAM = ZCNAX3VL9D; 1224 DEVELOPMENT_TEAM = ZCNAX3VL9D;
@@ -946,10 +1230,20 @@
946 "@executable_path/Frameworks", 1230 "@executable_path/Frameworks",
947 "@executable_path/../../Frameworks", 1231 "@executable_path/../../Frameworks",
948 ); 1232 );
1233 "LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1234 "$(inherited)",
1235 "@executable_path/../Frameworks",
1236 "@executable_path/../../../../Frameworks",
1237 );
1238 MACOSX_DEPLOYMENT_TARGET = 26.0;
949 MARKETING_VERSION = 1.1.0; 1239 MARKETING_VERSION = 1.1.0;
950 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.widgets; 1240 PRODUCT_BUNDLE_IDENTIFIER = sh.krz.orgstar.widgets;
951 PRODUCT_NAME = "$(TARGET_NAME)"; 1241 PRODUCT_NAME = "$(TARGET_NAME)";
1242 SDKROOT = auto;
952 SKIP_INSTALL = YES; 1243 SKIP_INSTALL = YES;
1244 SUPPORTED_PLATFORMS = "iphoneos iphonesimulator macosx";
1245 SUPPORTS_MACCATALYST = NO;
1246 "SWIFT_ACTIVE_COMPILATION_CONDITIONS[sdk=macosx*]" = "$(inherited) APPSTORE";
953 TARGETED_DEVICE_FAMILY = "1,2"; 1247 TARGETED_DEVICE_FAMILY = "1,2";
954 }; 1248 };
955 name = Release; 1249 name = Release;
@@ -1074,6 +1368,108 @@
1074 }; 1368 };
1075 name = Release; 1369 name = Release;
1076 }; 1370 };
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 };
1077/* End XCBuildConfiguration section */ 1473/* End XCBuildConfiguration section */
1078 1474
1079/* Begin XCConfigurationList section */ 1475/* Begin XCConfigurationList section */
@@ -1140,6 +1536,24 @@
1140 defaultConfigurationIsVisible = 0; 1536 defaultConfigurationIsVisible = 0;
1141 defaultConfigurationName = Release; 1537 defaultConfigurationName = Release;
1142 }; 1538 };
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 };
1143/* End XCConfigurationList section */ 1557/* End XCConfigurationList section */
1144 1558
1145/* Begin XCLocalSwiftPackageReference section */ 1559/* Begin XCLocalSwiftPackageReference section */
@@ -1185,6 +1599,26 @@
1185 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */; 1599 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1186 productName = OrgWatchData; 1600 productName = OrgWatchData;
1187 }; 1601 };
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 };
1188/* End XCSwiftPackageProductDependency section */ 1622/* End XCSwiftPackageProductDependency section */
1189 }; 1623 };
1190 rootObject = 46F86FAA6BBF9AC94A7E4595 /* Project object */; 1624 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 @@
46 </array> 46 </array>
47 <key>CFBundleVersion</key> 47 <key>CFBundleVersion</key>
48 <string>$(CURRENT_PROJECT_VERSION)</string> 48 <string>$(CURRENT_PROJECT_VERSION)</string>
49 <key>ITSAppUsesNonExemptEncryption</key>
50 <false/>
49 <key>LSApplicationCategoryType</key> 51 <key>LSApplicationCategoryType</key>
50 <string>public.app-category.productivity</string> 52 <string>public.app-category.productivity</string>
51 <key>NSCalendarsFullAccessUsageDescription</key> 53 <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 @@
86 } 86 }
87 } 87 }
88 }, 88 },
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 },
89 "%@ a month, billed yearly": { 157 "%@ a month, billed yearly": {
90 "localizations": { 158 "localizations": {
91 "de": { 159 "de": {
@@ -189,6 +257,47 @@
189 } 257 }
190 } 258 }
191 }, 259 },
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 },
192 "%@ isn't available on iPhone and iPad.": { 301 "%@ isn't available on iPhone and iPad.": {
193 "comment": "A command that runs only on the Mac", 302 "comment": "A command that runs only on the Mac",
194 "localizations": { 303 "localizations": {
@@ -224,6 +333,76 @@
224 } 333 }
225 } 334 }
226 }, 335 },
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 },
227 "%@ late": { 406 "%@ late": {
228 "localizations": { 407 "localizations": {
229 "de": { 408 "de": {
@@ -1658,140 +1837,141 @@
1658 } 1837 }
1659 } 1838 }
1660 }, 1839 },
1661 "Act at Point": { 1840 "Access lasts until orgstar quits.": {
1662 "comment": "Command title", 1841 "comment": "Alert when a folder grant or the configuration folder can't be saved",
1663 "localizations": { 1842 "localizations": {
1664 "de": { 1843 "de": {
1665 "stringUnit": { 1844 "stringUnit": {
1666 "state": "translated", 1845 "state": "translated",
1667 "value": "An der Einfügemarke ausführen" 1846 "value": "Der Zugriff gilt, bis orgstar beendet wird."
1668 } 1847 }
1669 }, 1848 },
1670 "es": { 1849 "es": {
1671 "stringUnit": { 1850 "stringUnit": {
1672 "state": "translated", 1851 "state": "translated",
1673 "value": "Actuar en el punto" 1852 "value": "El acceso dura hasta que se cierre orgstar."
1674 } 1853 }
1675 }, 1854 },
1676 "fr": { 1855 "fr": {
1677 "stringUnit": { 1856 "stringUnit": {
1678 "state": "translated", 1857 "state": "translated",
1679 "value": "Agir au point" 1858 "value": "L'accès dure jusqu'à ce que vous quittiez orgstar."
1680 } 1859 }
1681 }, 1860 },
1682 "ja": { 1861 "ja": {
1683 "stringUnit": { 1862 "stringUnit": {
1684 "state": "translated", 1863 "state": "translated",
1685 "value": "ポイントで実行" 1864 "value": "アクセスはorgstarを終了するまで有効です。"
1686 } 1865 }
1687 }, 1866 },
1688 "pt-BR": { 1867 "pt-BR": {
1689 "stringUnit": { 1868 "stringUnit": {
1690 "state": "translated", 1869 "state": "translated",
1691 "value": "Agir no Cursor" 1870 "value": "O acesso dura até o orgstar ser encerrado."
1692 } 1871 }
1693 } 1872 }
1694 } 1873 }
1695 }, 1874 },
1696 "Act at Point (C-c C-c)": { 1875 "Act at Point": {
1697 "comment": "Command title", 1876 "comment": "Command title",
1698 "localizations": { 1877 "localizations": {
1699 "de": { 1878 "de": {
1700 "stringUnit": { 1879 "stringUnit": {
1701 "state": "translated", 1880 "state": "translated",
1702 "value": "An der Einfügemarke ausführen (C-c C-c)" 1881 "value": "An der Einfügemarke ausführen"
1703 } 1882 }
1704 }, 1883 },
1705 "es": { 1884 "es": {
1706 "stringUnit": { 1885 "stringUnit": {
1707 "state": "translated", 1886 "state": "translated",
1708 "value": "Actuar en el punto (C-c C-c)" 1887 "value": "Actuar en el punto"
1709 } 1888 }
1710 }, 1889 },
1711 "fr": { 1890 "fr": {
1712 "stringUnit": { 1891 "stringUnit": {
1713 "state": "translated", 1892 "state": "translated",
1714 "value": "Agir au point (C-c C-c)" 1893 "value": "Agir au point"
1715 } 1894 }
1716 }, 1895 },
1717 "ja": { 1896 "ja": {
1718 "stringUnit": { 1897 "stringUnit": {
1719 "state": "translated", 1898 "state": "translated",
1720 "value": "ポイントで実行(C-c C-c)" 1899 "value": "ポイントで実行"
1721 } 1900 }
1722 }, 1901 },
1723 "pt-BR": { 1902 "pt-BR": {
1724 "stringUnit": { 1903 "stringUnit": {
1725 "state": "translated", 1904 "state": "translated",
1726 "value": "Agir no Cursor (C-c C-c)" 1905 "value": "Agir no Cursor"
1727 } 1906 }
1728 } 1907 }
1729 } 1908 }
1730 }, 1909 },
1731 "Actions": { 1910 "Act at Point (C-c C-c)": {
1911 "comment": "Command title",
1732 "localizations": { 1912 "localizations": {
1733 "de": { 1913 "de": {
1734 "stringUnit": { 1914 "stringUnit": {
1735 "state": "translated", 1915 "state": "translated",
1736 "value": "Aktionen" 1916 "value": "An der Einfügemarke ausführen (C-c C-c)"
1737 } 1917 }
1738 }, 1918 },
1739 "es": { 1919 "es": {
1740 "stringUnit": { 1920 "stringUnit": {
1741 "state": "translated", 1921 "state": "translated",
1742 "value": "Acciones" 1922 "value": "Actuar en el punto (C-c C-c)"
1743 } 1923 }
1744 }, 1924 },
1745 "fr": { 1925 "fr": {
1746 "stringUnit": { 1926 "stringUnit": {
1747 "state": "translated", 1927 "state": "translated",
1748 "value": "Actions" 1928 "value": "Agir au point (C-c C-c)"
1749 } 1929 }
1750 }, 1930 },
1751 "ja": { 1931 "ja": {
1752 "stringUnit": { 1932 "stringUnit": {
1753 "state": "translated", 1933 "state": "translated",
1754 "value": "アクション" 1934 "value": "ポイントで実行(C-c C-c)"
1755 } 1935 }
1756 }, 1936 },
1757 "pt-BR": { 1937 "pt-BR": {
1758 "stringUnit": { 1938 "stringUnit": {
1759 "state": "translated", 1939 "state": "translated",
1760 "value": "Ações" 1940 "value": "Agir no Cursor (C-c C-c)"
1761 } 1941 }
1762 } 1942 }
1763 } 1943 }
1764 }, 1944 },
1765 "Activate": { 1945 "Actions": {
1766 "localizations": { 1946 "localizations": {
1767 "de": { 1947 "de": {
1768 "stringUnit": { 1948 "stringUnit": {
1769 "state": "translated", 1949 "state": "translated",
1770 "value": "Aktivieren" 1950 "value": "Aktionen"
1771 } 1951 }
1772 }, 1952 },
1773 "es": { 1953 "es": {
1774 "stringUnit": { 1954 "stringUnit": {
1775 "state": "translated", 1955 "state": "translated",
1776 "value": "Activar" 1956 "value": "Acciones"
1777 } 1957 }
1778 }, 1958 },
1779 "fr": { 1959 "fr": {
1780 "stringUnit": { 1960 "stringUnit": {
1781 "state": "translated", 1961 "state": "translated",
1782 "value": "Activer" 1962 "value": "Actions"
1783 } 1963 }
1784 }, 1964 },
1785 "ja": { 1965 "ja": {
1786 "stringUnit": { 1966 "stringUnit": {
1787 "state": "translated", 1967 "state": "translated",
1788 "value": "アクティベート" 1968 "value": "アクション"
1789 } 1969 }
1790 }, 1970 },
1791 "pt-BR": { 1971 "pt-BR": {
1792 "stringUnit": { 1972 "stringUnit": {
1793 "state": "translated", 1973 "state": "translated",
1794 "value": "Ativar" 1974 "value": "Ações"
1795 } 1975 }
1796 } 1976 }
1797 } 1977 }
@@ -4569,6 +4749,76 @@
4569 } 4749 }
4570 } 4750 }
4571 }, 4751 },
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 },
4572 "Can't open the entry": { 4822 "Can't open the entry": {
4573 "localizations": { 4823 "localizations": {
4574 "de": { 4824 "de": {
@@ -5257,74 +5507,6 @@
5257 } 5507 }
5258 } 5508 }
5259 }, 5509 },
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 },
5328 "Check spelling while typing (spell-check)": { 5510 "Check spelling while typing (spell-check)": {
5329 "localizations": { 5511 "localizations": {
5330 "de": { 5512 "de": {
@@ -5393,6 +5575,145 @@
5393 } 5575 }
5394 } 5576 }
5395 }, 5577 },
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 },
5396 "Choose Another Folder…": { 5717 "Choose Another Folder…": {
5397 "localizations": { 5718 "localizations": {
5398 "de": { 5719 "de": {
@@ -5427,6 +5748,74 @@
5427 } 5748 }
5428 } 5749 }
5429 }, 5750 },
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 },
5430 "Choose Folder": { 5819 "Choose Folder": {
5431 "localizations": { 5820 "localizations": {
5432 "de": { 5821 "de": {
@@ -5597,7 +5986,113 @@
5597 } 5986 }
5598 } 5987 }
5599 }, 5988 },
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 },
5600 "Choose your init.el, or the folder holding it (~/.emacs.d, ~/.config/doom).": { 6094 "Choose your init.el, or the folder holding it (~/.emacs.d, ~/.config/doom).": {
6095 "comment": "Open panel for importing an Emacs configuration",
5601 "localizations": { 6096 "localizations": {
5602 "de": { 6097 "de": {
5603 "stringUnit": { 6098 "stringUnit": {
@@ -9328,6 +9823,40 @@
9328 } 9823 }
9329 } 9824 }
9330 }, 9825 },
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 },
9331 "Downloading from iCloud": { 9860 "Downloading from iCloud": {
9332 "localizations": { 9861 "localizations": {
9333 "de": { 9862 "de": {
@@ -12635,40 +13164,6 @@
12635 } 13164 }
12636 } 13165 }
12637 }, 13166 },
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 },
12672 "Git branch": { 13167 "Git branch": {
12673 "localizations": { 13168 "localizations": {
12674 "de": { 13169 "de": {
@@ -13085,6 +13580,76 @@
13085 } 13580 }
13086 } 13581 }
13087 }, 13582 },
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 },
13088 "Habit": { 13653 "Habit": {
13089 "localizations": { 13654 "localizations": {
13090 "de": { 13655 "de": {
@@ -14990,6 +15555,41 @@
14990 } 15555 }
14991 } 15556 }
14992 }, 15557 },
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 },
14993 "Italic": { 15593 "Italic": {
14994 "comment": "Command title", 15594 "comment": "Command title",
14995 "localizations": { 15595 "localizations": {
@@ -15679,40 +16279,6 @@
15679 } 16279 }
15680 } 16280 }
15681 }, 16281 },
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 },
15716 "Light": { 16282 "Light": {
15717 "localizations": { 16283 "localizations": {
15718 "de": { 16284 "de": {
@@ -16435,6 +17001,40 @@
16435 } 17001 }
16436 } 17002 }
16437 }, 17003 },
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 },
16438 "Makes org/notes.org in iCloud Drive and adds the folder": { 17038 "Makes org/notes.org in iCloud Drive and adds the folder": {
16439 "localizations": { 17039 "localizations": {
16440 "de": { 17040 "de": {
@@ -16503,6 +17103,40 @@
16503 } 17103 }
16504 } 17104 }
16505 }, 17105 },
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 },
16506 "Manual": { 17140 "Manual": {
16507 "localizations": { 17141 "localizations": {
16508 "de": { 17142 "de": {
@@ -17845,6 +18479,40 @@
17845 } 18479 }
17846 } 18480 }
17847 }, 18481 },
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 },
17848 "New Folder…": { 18516 "New Folder…": {
17849 "localizations": { 18517 "localizations": {
17850 "de": { 18518 "de": {
@@ -19910,74 +20578,6 @@
19910 } 20578 }
19911 } 20579 }
19912 }, 20580 },
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 },
19981 "One payment, no subscription": { 20581 "One payment, no subscription": {
19982 "localizations": { 20582 "localizations": {
19983 "de": { 20583 "de": {
@@ -23559,40 +24159,6 @@
23559 } 24159 }
23560 } 24160 }
23561 }, 24161 },
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 },
23596 "Remove Priority": { 24162 "Remove Priority": {
23597 "comment": "Command title", 24163 "comment": "Command title",
23598 "localizations": { 24164 "localizations": {
@@ -24007,40 +24573,6 @@
24007 } 24573 }
24008 } 24574 }
24009 }, 24575 },
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 },
24044 "Reparent Note with Descendants…": { 24576 "Reparent Note with Descendants…": {
24045 "comment": "Command title", 24577 "comment": "Command title",
24046 "localizations": { 24578 "localizations": {
@@ -24522,6 +25054,40 @@
24522 } 25054 }
24523 } 25055 }
24524 }, 25056 },
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 },
24525 "Run Source Block": { 25091 "Run Source Block": {
24526 "comment": "Command title", 25092 "comment": "Command title",
24527 "localizations": { 25093 "localizations": {
@@ -24832,6 +25398,41 @@
24832 } 25398 }
24833 } 25399 }
24834 }, 25400 },
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 },
24835 "Save Field": { 25436 "Save Field": {
24836 "localizations": { 25437 "localizations": {
24837 "de": { 25438 "de": {
@@ -27551,6 +28152,40 @@
27551 } 28152 }
27552 } 28153 }
27553 }, 28154 },
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 },
27554 "Some tips aren't available from the App Store right now.": { 28189 "Some tips aren't available from the App Store right now.": {
27555 "localizations": { 28190 "localizations": {
27556 "de": { 28191 "de": {
@@ -27897,74 +28532,6 @@
27897 } 28532 }
27898 } 28533 }
27899 }, 28534 },
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 },
27968 "Standard Mac editing keys, with Org commands on ⌃⌘: ⌃⌘T cycles TODO, ⌃⌘S schedules.": { 28535 "Standard Mac editing keys, with Org commands on ⌃⌘: ⌃⌘T cycles TODO, ⌃⌘S schedules.": {
27969 "localizations": { 28536 "localizations": {
27970 "de": { 28537 "de": {
@@ -30332,6 +30899,41 @@
30332 } 30899 }
30333 } 30900 }
30334 }, 30901 },
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 },
30335 "This table needs Emacs, which runs on the Mac: %@.": { 30937 "This table needs Emacs, which runs on the Mac: %@.": {
30336 "comment": "Table formulas only Emacs can calculate", 30938 "comment": "Table formulas only Emacs can calculate",
30337 "localizations": { 30939 "localizations": {
@@ -30367,6 +30969,41 @@
30367 } 30969 }
30368 } 30970 }
30369 }, 30971 },
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 },
30370 "Time": { 31007 "Time": {
30371 "localizations": { 31008 "localizations": {
30372 "de": { 31009 "de": {
@@ -31748,6 +32385,40 @@
31748 } 32385 }
31749 } 32386 }
31750 }, 32387 },
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 },
31751 "Use Disk Version": { 32422 "Use Disk Version": {
31752 "localizations": { 32423 "localizations": {
31753 "de": { 32424 "de": {
@@ -31782,6 +32453,41 @@
31782 } 32453 }
31783 } 32454 }
31784 }, 32455 },
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 },
31785 "Use Selection for Find": { 32491 "Use Selection for Find": {
31786 "comment": "Command title", 32492 "comment": "Command title",
31787 "localizations": { 32493 "localizations": {
@@ -34232,6 +34938,145 @@
34232 } 34938 }
34233 } 34939 }
34234 }, 34940 },
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 },
34235 "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….": { 35080 "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….": {
34236 "localizations": { 35081 "localizations": {
34237 "de": { 35082 "de": {
@@ -34334,104 +35179,104 @@
34334 } 35179 }
34335 } 35180 }
34336 }, 35181 },
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….": {
34338 "localizations": { 35183 "localizations": {
34339 "de": { 35184 "de": {
34340 "stringUnit": { 35185 "stringUnit": {
34341 "state": "translated", 35186 "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 …."
34343 } 35188 }
34344 }, 35189 },
34345 "es": { 35190 "es": {
34346 "stringUnit": { 35191 "stringUnit": {
34347 "state": "translated", 35192 "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…."
34349 } 35194 }
34350 }, 35195 },
34351 "fr": { 35196 "fr": {
34352 "stringUnit": { 35197 "stringUnit": {
34353 "state": "translated", 35198 "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…."
34355 } 35200 }
34356 }, 35201 },
34357 "ja": { 35202 "ja": {
34358 "stringUnit": { 35203 "stringUnit": {
34359 "state": "translated", 35204 "state": "translated",
34360 "value": "orgstarの共有フォルダを利用できません。" 35205 "value": "orgstarは設定を専用のフォルダに保存します。~/.config/orgstarの設定を使うには、設定 ▸ 一般 ▸ 構成フォルダを選択…でそのフォルダを選択してください。"
34361 } 35206 }
34362 }, 35207 },
34363 "pt-BR": { 35208 "pt-BR": {
34364 "stringUnit": { 35209 "stringUnit": {
34365 "state": "translated", 35210 "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…."
34367 } 35212 }
34368 } 35213 }
34369 } 35214 }
34370 }, 35215 },
34371 "orgstar+": { 35216 "orgstar's shared folder isn't available.": {
34372 "localizations": { 35217 "localizations": {
34373 "de": { 35218 "de": {
34374 "stringUnit": { 35219 "stringUnit": {
34375 "state": "translated", 35220 "state": "translated",
34376 "value": "orgstar+" 35221 "value": "Der gemeinsame Ordner von orgstar ist nicht verfügbar."
34377 } 35222 }
34378 }, 35223 },
34379 "es": { 35224 "es": {
34380 "stringUnit": { 35225 "stringUnit": {
34381 "state": "translated", 35226 "state": "translated",
34382 "value": "orgstar+" 35227 "value": "La carpeta compartida de orgstar no está disponible."
34383 } 35228 }
34384 }, 35229 },
34385 "fr": { 35230 "fr": {
34386 "stringUnit": { 35231 "stringUnit": {
34387 "state": "translated", 35232 "state": "translated",
34388 "value": "orgstar+" 35233 "value": "Le dossier partagé d'orgstar n'est pas disponible."
34389 } 35234 }
34390 }, 35235 },
34391 "ja": { 35236 "ja": {
34392 "stringUnit": { 35237 "stringUnit": {
34393 "state": "translated", 35238 "state": "translated",
34394 "value": "orgstar+" 35239 "value": "orgstarの共有フォルダを利用できません。"
34395 } 35240 }
34396 }, 35241 },
34397 "pt-BR": { 35242 "pt-BR": {
34398 "stringUnit": { 35243 "stringUnit": {
34399 "state": "translated", 35244 "state": "translated",
34400 "value": "orgstar+" 35245 "value": "A pasta compartilhada do orgstar não está disponível."
34401 } 35246 }
34402 } 35247 }
34403 } 35248 }
34404 }, 35249 },
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+": {
34406 "localizations": { 35251 "localizations": {
34407 "de": { 35252 "de": {
34408 "stringUnit": { 35253 "stringUnit": {
34409 "state": "translated", 35254 "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+"
34411 } 35256 }
34412 }, 35257 },
34413 "es": { 35258 "es": {
34414 "stringUnit": { 35259 "stringUnit": {
34415 "state": "translated", 35260 "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+"
34417 } 35262 }
34418 }, 35263 },
34419 "fr": { 35264 "fr": {
34420 "stringUnit": { 35265 "stringUnit": {
34421 "state": "translated", 35266 "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+"
34423 } 35268 }
34424 }, 35269 },
34425 "ja": { 35270 "ja": {
34426 "stringUnit": { 35271 "stringUnit": {
34427 "state": "translated", 35272 "state": "translated",
34428 "value": "Mac版orgstar+は、GitHubでorgstarのスポンサーになると利用できます(1回$60、または月額$5)。編集、アジェンダ、キャプチャ、クロック、検索は引き続き無料です。" 35273 "value": "orgstar+"
34429 } 35274 }
34430 }, 35275 },
34431 "pt-BR": { 35276 "pt-BR": {
34432 "stringUnit": { 35277 "stringUnit": {
34433 "state": "translated", 35278 "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+"
34435 } 35280 }
34436 } 35281 }
34437 } 35282 }
scripts/build-app.sh +2 −2
@@ -54,8 +54,8 @@ if [ "$sign" != "-" ]; then
54else 54else
55 feed_keys="" 55 feed_keys=""
56fi 56fi
57# The UI's translations, from l10n/Localizable.xcstrings. 57# The UI's translations, from l10n/Localizable.xcstrings and l10n/DeveloperID.xcstrings.
58scripts/localize.sh "$app/Contents/Resources" 58scripts/localize.sh --developer-id "$app/Contents/Resources"
59 59
60# The icon (macOS derives its dark and tinted styles), and the Dock icons Settings offers. 60# The icon (macOS derives its dark and tinted styles), and the Dock icons Settings offers.
61work="$(mktemp -d)" 61work="$(mktemp -d)"
scripts/localize.sh +7 −2
@@ -1,13 +1,18 @@
1#!/bin/sh 1#!/bin/sh
2# Compiles l10n/Localizable.xcstrings into the .lproj folders of each bundle folder given (an 2# Compiles l10n/Localizable.xcstrings into the .lproj folders of each bundle folder given (an
3# app's Contents/Resources, an iOS app or extension folder). English is the source language: 3# 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. 4# its folder is empty, so the keys show as they are. With --developer-id, the DeveloperID table
5# Usage: scripts/localize.sh <folder>... 5# too: the license and update strings, which only the Developer ID Mac app shows.
6# Usage: scripts/localize.sh [--developer-id] <folder>...
6set -eu 7set -eu
7 8
8cd "$(dirname "$0")/.." 9cd "$(dirname "$0")/.."
9work="$(mktemp -d)" 10work="$(mktemp -d)"
10xcrun xcstringstool compile l10n/Localizable.xcstrings --output-directory "$work" > /dev/null 11xcrun 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
11mkdir -p "$work/en.lproj" 16mkdir -p "$work/en.lproj"
12for folder in "$@"; do 17for folder in "$@"; do
13 for lproj in "$work"/*.lproj; do 18 for lproj in "$work"/*.lproj; do
scripts/release-ios.sh +2 −1
@@ -1,7 +1,8 @@
1#!/bin/sh 1#!/bin/sh
2# Archives the iOS app (with its extensions and the watch app) and uploads it to App Store 2# Archives the iOS app (with its extensions and the watch app) and uploads it to App Store
3# Connect for TestFlight. The version is the project's MARKETING_VERSION; the build number is the 3# 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
5# appstore-kit, checked out beside this repository or at $APPSTORE_KIT. 6# appstore-kit, checked out beside this repository or at $APPSTORE_KIT.
6# Usage: scripts/release-ios.sh 7# Usage: scripts/release-ios.sh
7# ORGSTAR_PUBLISH 0 archives and exports the .ipa to .build/ios-release without uploading 8# 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 @@
1#!/bin/sh 1#!/bin/sh
2# Brings l10n/Localizable.xcstrings up to date with the strings the apps show: builds the Mac and 2# Brings l10n/Localizable.xcstrings and l10n/DeveloperID.xcstrings (the strings with that table,
3# iOS targets with SWIFT_EMIT_LOC_STRINGS and syncs the catalog from their .stringsdata files. 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.
4# New strings are added, ones no longer used are marked stale; translations are kept. 6# New strings are added, ones no longer used are marked stale; translations are kept.
5# Command titles come from Sources/OrgApp/CommandTitles.swift, which CommandTitleTests keeps current. 7# Command titles come from Sources/OrgApp/CommandTitles.swift, which CommandTitleTests keeps current.
6set -eu 8set -eu
@@ -9,10 +11,15 @@ cd "$(dirname "$0")/.."
9catalog=l10n/Localizable.xcstrings 11catalog=l10n/Localizable.xcstrings
10mac=.build/loc-mac 12mac=.build/loc-mac
11ios=.build/loc-ios 13ios=.build/loc-ios
14mas=.build/loc-mas
12 15
13for scheme in Orgstar OrgstarWidgets; do 16for scheme in Orgstar OrgstarWidgets; do
14 xcodebuild -scheme "$scheme" -destination 'platform=macOS' -derivedDataPath "$mac" build -quiet SWIFT_EMIT_LOC_STRINGS=YES 17 xcodebuild -scheme "$scheme" -destination 'platform=macOS' -derivedDataPath "$mac" build -quiet SWIFT_EMIT_LOC_STRINGS=YES
15done 18done
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
16for scheme in OrgstarMobile OrgstarShare OrgstarWidgets; do 23for scheme in OrgstarMobile OrgstarShare OrgstarWidgets; do
17 xcodebuild -scheme "$scheme" -destination 'generic/platform=iOS Simulator' -derivedDataPath "$ios" build -quiet SWIFT_EMIT_LOC_STRINGS=YES 24 xcodebuild -scheme "$scheme" -destination 'generic/platform=iOS Simulator' -derivedDataPath "$ios" build -quiet SWIFT_EMIT_LOC_STRINGS=YES
18done 25done
@@ -24,6 +31,13 @@ done
24find "$mac" "$ios" -path '*/arm64/*' -name '*.stringsdata' \ 31find "$mac" "$ios" -path '*/arm64/*' -name '*.stringsdata' \
25 | grep -E '/(Orgstar|OrgstarMobile|OrgstarWidgets|OrgstarShare|OrgstarWatch|OrgstarWatchWidgets)-p\.build/|/(OrgApp|OrgPresentation|OrgEditorAppKit)-t?\.build/' \ 32 | grep -E '/(Orgstar|OrgstarMobile|OrgstarWidgets|OrgstarShare|OrgstarWatch|OrgstarWatchWidgets)-p\.build/|/(OrgApp|OrgPresentation|OrgEditorAppKit)-t?\.build/' \
26 > "$mac/stringsdata.txt" 33 > "$mac/stringsdata.txt"
27# shellcheck disable=SC2046 34find "$mas" -path '*/arm64/*' -name '*.stringsdata' | grep -E '/(Orgstar macOS|OrgstarWidgets)\.build/' >> "$mac/stringsdata.txt"
28xcrun xcstringstool sync "$catalog" --stringsdata $(tr '\n' ' ' < "$mac/stringsdata.txt") 35# The App Store target's folder name has a space, so the list is read a line at a time.
29echo "$(python3 -c "import json; print(len(json.load(open('$catalog'))['strings']))") strings in $catalog" 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