Commit 0aba84182e

0aba84182e7a319ce75d83c894fe9c4ce46c0301

parent: 1166575747

Verified · cmc

cmc <hello@cleberg.net> · 2026-11-22 00:03 UTC

Move MathJax to an OrgMathJax product only the apps link, so extensions don't carry it

Layout: unified · split

Package.swift +7 −5
@@ -16,6 +16,7 @@ let package = Package(
16 .library(name: "OrgEditorAppKit", targets: ["OrgEditorAppKit"]), 16 .library(name: "OrgEditorAppKit", targets: ["OrgEditorAppKit"]),
17 .executable(name: "OrgstarSpike", targets: ["OrgstarSpike"]), 17 .executable(name: "OrgstarSpike", targets: ["OrgstarSpike"]),
18 .library(name: "OrgApp", targets: ["OrgApp"]), 18 .library(name: "OrgApp", targets: ["OrgApp"]),
19 .library(name: "OrgMathJax", targets: ["OrgMathJax"]),
19 .library(name: "OrgWatchData", targets: ["OrgWatchData"]), 20 .library(name: "OrgWatchData", targets: ["OrgWatchData"]),
20 .library(name: "OrgHighlight", targets: ["OrgHighlight"]), 21 .library(name: "OrgHighlight", targets: ["OrgHighlight"]),
21 .executable(name: "Orgstar", targets: ["Orgstar"]), 22 .executable(name: "Orgstar", targets: ["Orgstar"]),
@@ -87,8 +88,9 @@ let package = Package(
87 ] 88 ]
88 ), 89 ),
89 .executableTarget(name: "OrgstarSpike", dependencies: ["OrgEditorAppKit"]), 90 .executableTarget(name: "OrgstarSpike", dependencies: ["OrgEditorAppKit"]),
90 // MathJax for PDF export, which typesets math without the network. 91 .target(name: "OrgApp", dependencies: ["OrgWorkspace", "OrgDocument", "OrgPresentation", "OrgWatchData"]),
91 .target(name: "OrgApp", dependencies: ["OrgWorkspace", "OrgDocument", "OrgPresentation", "OrgWatchData"], resources: [.copy("Resources/MathJax")]), 92 // MathJax for PDF export, which typesets math without the network; the apps link it, extensions don't.
93 .target(name: "OrgMathJax", resources: [.copy("MathJax")]),
92 // What the phone and the watch send each other; Foundation only, so the watch builds it. 94 // What the phone and the watch send each other; Foundation only, so the watch builds it.
93 .target(name: "OrgWatchData"), 95 .target(name: "OrgWatchData"),
94 // The watch app and its complications, bundled by scripts/build-watch-app.sh. 96 // The watch app and its complications, bundled by scripts/build-watch-app.sh.
@@ -96,9 +98,9 @@ let package = Package(
96 .executableTarget(name: "OrgstarWatchWidgets", dependencies: ["OrgWatchData"]), 98 .executableTarget(name: "OrgstarWatchWidgets", dependencies: ["OrgWatchData"]),
97 // Babel, Emacs and gnuplot as processes; the Developer ID app alone links it. 99 // Babel, Emacs and gnuplot as processes; the Developer ID app alone links it.
98 .target(name: "OrgPrograms", dependencies: ["OrgApp"]), 100 .target(name: "OrgPrograms", dependencies: ["OrgApp"]),
99 .executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgPrograms", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]), 101 .executableTarget(name: "Orgstar", dependencies: ["OrgApp", "OrgMathJax", "OrgPrograms", "OrgEditorAppKit", "OrgHighlight", .product(name: "Sparkle", package: "Sparkle")]),
100 // The iOS app, bundled by scripts/build-ios-app.sh. 102 // The iOS app, bundled by scripts/build-ios-app.sh.
101 .executableTarget(name: "OrgstarMobile", dependencies: ["OrgApp", "OrgHighlight"]), 103 .executableTarget(name: "OrgstarMobile", dependencies: ["OrgApp", "OrgMathJax", "OrgHighlight"]),
102 // App extensions, bundled into orgstar.app by scripts/build-app.sh. 104 // App extensions, bundled into orgstar.app by scripts/build-app.sh.
103 .executableTarget(name: "OrgstarQuickLook", dependencies: ["OrgCore"], linkerSettings: extensionEntry), 105 .executableTarget(name: "OrgstarQuickLook", dependencies: ["OrgCore"], linkerSettings: extensionEntry),
104 .executableTarget(name: "OrgstarSpotlight", dependencies: ["OrgCore"], linkerSettings: extensionEntry), 106 .executableTarget(name: "OrgstarSpotlight", dependencies: ["OrgCore"], linkerSettings: extensionEntry),
@@ -114,7 +116,7 @@ let package = Package(
114 .testTarget(name: "OrgWorkspaceTests", dependencies: ["OrgWorkspace"]), 116 .testTarget(name: "OrgWorkspaceTests", dependencies: ["OrgWorkspace"]),
115 .testTarget(name: "OrgPresentationTests", dependencies: ["OrgPresentation"]), 117 .testTarget(name: "OrgPresentationTests", dependencies: ["OrgPresentation"]),
116 .testTarget(name: "OrgEditorAppKitTests", dependencies: ["OrgEditorAppKit", "OrgApp"]), 118 .testTarget(name: "OrgEditorAppKitTests", dependencies: ["OrgEditorAppKit", "OrgApp"]),
117 .testTarget(name: "OrgAppTests", dependencies: ["OrgApp", "OrgDocument"]), 119 .testTarget(name: "OrgAppTests", dependencies: ["OrgApp", "OrgDocument", "OrgMathJax"]),
118 .testTarget(name: "OrgProgramsTests", dependencies: ["OrgPrograms", "OrgApp", "OrgDocument"]), 120 .testTarget(name: "OrgProgramsTests", dependencies: ["OrgPrograms", "OrgApp", "OrgDocument"]),
119 .testTarget(name: "OrgHighlightTests", dependencies: ["OrgHighlight", "OrgCore", "OrgPresentation"]) 121 .testTarget(name: "OrgHighlightTests", dependencies: ["OrgHighlight", "OrgCore", "OrgPresentation"])
120 ] 122 ]
Sources/OrgApp/PDFExport.swift +5 −5
@@ -125,12 +125,12 @@ public enum PDFExport {
125 </style> 125 </style>
126 """ 126 """
127 127
128 /// MathJax 3.2.2's `tex-svg-full.js`: every TeX extension in one file, with SVG output that 128 /// MathJax's `tex-svg-full.js`, which the app sets from `OrgMathJax.script`: every TeX
129 /// needs no font files, so nothing is fetched. 129 /// extension in one file, with SVG output that needs no font files, so nothing is fetched.
130 nonisolated(unsafe) public static var mathJaxURL: URL?
131
130 nonisolated static func bundledMathJax() throws -> String { 132 nonisolated static func bundledMathJax() throws -> String {
131 guard let url = Bundle.module.url(forResource: "tex-svg-full", withExtension: "js", subdirectory: "MathJax") else { 133 guard let url = mathJaxURL else { throw Failure(description: "MathJax is missing from the app.") }
132 throw Failure(description: "MathJax is missing from the app.")
133 }
134 return try String(contentsOf: url, encoding: .utf8) 134 return try String(contentsOf: url, encoding: .utf8)
135 } 135 }
136 136
Sources/OrgApp/Resources/MathJax/LICENSE → Sources/OrgMathJax/MathJax/LICENSE renamed
Sources/OrgApp/Resources/MathJax/tex-svg-full.js → Sources/OrgMathJax/MathJax/tex-svg-full.js renamed
Sources/OrgMathJax/OrgMathJax.swift added +7
@@ -0,0 +1,7 @@
1import Foundation
2
3/// MathJax 3.2.2's `tex-svg-full.js`, for PDF export. Only the apps link it, so extensions don't
4/// carry the file.
5public enum OrgMathJax {
6 public static var script: URL? { Bundle.module.url(forResource: "tex-svg-full", withExtension: "js", subdirectory: "MathJax") }
7}
Sources/Orgstar/OrgstarApp.swift +2
@@ -2,6 +2,7 @@ import AppKit
2import OrgApp 2import OrgApp
3import OrgCore 3import OrgCore
4import OrgEditorAppKit 4import OrgEditorAppKit
5import OrgMathJax
5import OrgPresentation 6import OrgPresentation
6#if !APPSTORE 7#if !APPSTORE
7import OrgPrograms 8import OrgPrograms
@@ -374,6 +375,7 @@ struct OrgstarApp: App {
374 }() 375 }()
375 376
376 init() { 377 init() {
378 PDFExport.mathJaxURL = OrgMathJax.script
377 #if APPSTORE 379 #if APPSTORE
378 AgendaSnapshot.useGroupContainer = true 380 AgendaSnapshot.useGroupContainer = true
379 EmacsFallback.offered = false 381 EmacsFallback.offered = false
Sources/OrgstarMobile/OrgstarMobileApp.swift +2
@@ -2,6 +2,7 @@
2import CoreSpotlight 2import CoreSpotlight
3import OrgApp 3import OrgApp
4import OrgCore 4import OrgCore
5import OrgMathJax
5import SwiftUI 6import SwiftUI
6import UserNotifications 7import UserNotifications
7 8
@@ -14,6 +15,7 @@ struct OrgstarMobileApp: App {
14 @Environment(\.scenePhase) private var scenePhase 15 @Environment(\.scenePhase) private var scenePhase
15 16
16 init() { 17 init() {
18 PDFExport.mathJaxURL = OrgMathJax.script
17 // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF. 19 // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF.
18 #if DEBUG 20 #if DEBUG
19 Perf.watchMainThread() 21 Perf.watchMainThread()
THIRD_PARTY.org +1 −1
@@ -10,7 +10,7 @@ orgstar is proprietary (see [[file:LICENSE]]). It builds on these projects, unde
10| [[https://github.com/r-lib/tree-sitter-r][tree-sitter-r]] | Highlighting | MIT | 10| [[https://github.com/r-lib/tree-sitter-r][tree-sitter-r]] | Highlighting | MIT |
11| [[https://github.com/6cdh/tree-sitter-scheme][tree-sitter-scheme]] | Highlighting | MIT | 11| [[https://github.com/6cdh/tree-sitter-scheme][tree-sitter-scheme]] | Highlighting | MIT |
12| [[https://github.com/nodejs/node][Node.js]] | =util.inspect= and =util.format=, ported to run in JavaScriptCore (in =Sources/OrgApp/JavaScriptBlocks.swift=) | MIT | 12| [[https://github.com/nodejs/node][Node.js]] | =util.inspect= and =util.format=, ported to run in JavaScriptCore (in =Sources/OrgApp/JavaScriptBlocks.swift=) | MIT |
13| [[https://github.com/mathjax/MathJax][MathJax]] 3.2.2 | Math in PDF export (=es5/tex-svg-full.js= from the npm package, in =Sources/OrgApp/Resources/MathJax= with its license) | Apache-2.0 | 13| [[https://github.com/mathjax/MathJax][MathJax]] 3.2.2 | Math in PDF export (=es5/tex-svg-full.js= from the npm package, in =Sources/OrgMathJax/MathJax= with its license) | Apache-2.0 |
14| [[https://github.com/Wilfred/tree-sitter-elisp][tree-sitter-elisp]] | Highlighting (vendored in =Sources/TreeSitterElisp=) | MIT | 14| [[https://github.com/Wilfred/tree-sitter-elisp][tree-sitter-elisp]] | Highlighting (vendored in =Sources/TreeSitterElisp=) | MIT |
15| [[https://github.com/sogaiu/tree-sitter-clojure][tree-sitter-clojure]] | Highlighting (vendored in =Sources/TreeSitterClojure=) | CC0-1.0 | 15| [[https://github.com/sogaiu/tree-sitter-clojure][tree-sitter-clojure]] | Highlighting (vendored in =Sources/TreeSitterClojure=) | CC0-1.0 |
16| [[https://ethanschoonover.com/solarized/][Solarized]] | Colors of the Solarized themes | MIT | 16| [[https://ethanschoonover.com/solarized/][Solarized]] | Colors of the Solarized themes | MIT |
Tests/OrgAppTests/PDFExportTests.swift +3
@@ -1,5 +1,6 @@
1import Foundation 1import Foundation
2import OrgCore 2import OrgCore
3import OrgMathJax
3import PDFKit 4import PDFKit
4import Testing 5import Testing
5import WebKit 6import WebKit
@@ -7,6 +8,8 @@ import WebKit
7 8
8@MainActor 9@MainActor
9struct PDFExportTests { 10struct PDFExportTests {
11 init() { PDFExport.mathJaxURL = OrgMathJax.script }
12
10 /// A long document comes out as several pages with its text, without Emacs. 13 /// A long document comes out as several pages with its text, without Emacs.
11 @Test func paginatesTheHTMLExport() async throws { 14 @Test func paginatesTheHTMLExport() async throws {
12 let sections = (1...40).map { "* Section \($0)\n" + String(repeating: "Some words in a paragraph. ", count: 30) + "\n" }.joined() 15 let sections = (1...40).map { "* Section \($0)\n" + String(repeating: "Some words in a paragraph. ", count: 30) + "\n" }.joined()
ios/Orgstar.xcodeproj/project.pbxproj +16
@@ -7,6 +7,8 @@
7 objects = { 7 objects = {
8 8
9/* Begin PBXBuildFile section */ 9/* Begin PBXBuildFile section */
10 EC91295D4306AF0CE88F1D07 /* OrgMathJax in Frameworks */ = {isa = PBXBuildFile; productRef = 70EC41AF804F61B000FC5A1E /* OrgMathJax */; };
11 7080D3827813E58F1F3C6ABC /* OrgMathJax in Frameworks */ = {isa = PBXBuildFile; productRef = FE5434EBA139A800E8727F4B /* OrgMathJax */; };
10 1B78003BBCE8A4B809333342 /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = A2BE626BBE45EA52880B6169 /* OrgApp */; }; 12 1B78003BBCE8A4B809333342 /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = A2BE626BBE45EA52880B6169 /* OrgApp */; };
11 1E5861C0EFE1D96CDC21A22F /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = BA239181876756F7732397EB /* OrgApp */; }; 13 1E5861C0EFE1D96CDC21A22F /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = BA239181876756F7732397EB /* OrgApp */; };
12 2BE799BF03ED43EAA6849F53 /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = EDEF22C5B4F393296F1D17BB /* OrgApp */; }; 14 2BE799BF03ED43EAA6849F53 /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = EDEF22C5B4F393296F1D17BB /* OrgApp */; };
@@ -281,6 +283,7 @@
281 buildActionMask = 2147483647; 283 buildActionMask = 2147483647;
282 files = ( 284 files = (
283 1B78003BBCE8A4B809333342 /* OrgApp in Frameworks */, 285 1B78003BBCE8A4B809333342 /* OrgApp in Frameworks */,
286 7080D3827813E58F1F3C6ABC /* OrgMathJax in Frameworks */,
284 9BE045FD696469CA8D19F22C /* OrgHighlight in Frameworks */, 287 9BE045FD696469CA8D19F22C /* OrgHighlight in Frameworks */,
285 ); 288 );
286 runOnlyForDeploymentPostprocessing = 0; 289 runOnlyForDeploymentPostprocessing = 0;
@@ -314,6 +317,7 @@
314 buildActionMask = 2147483647; 317 buildActionMask = 2147483647;
315 files = ( 318 files = (
316 34F40D483630871B50619E6F /* OrgApp in Frameworks */, 319 34F40D483630871B50619E6F /* OrgApp in Frameworks */,
320 EC91295D4306AF0CE88F1D07 /* OrgMathJax in Frameworks */,
317 4392873ADA2B1FC8930BE6C9 /* OrgEditorAppKit in Frameworks */, 321 4392873ADA2B1FC8930BE6C9 /* OrgEditorAppKit in Frameworks */,
318 CA594F2E6DAFED2D16900872 /* OrgHighlight in Frameworks */, 322 CA594F2E6DAFED2D16900872 /* OrgHighlight in Frameworks */,
319 ); 323 );
@@ -422,6 +426,7 @@
422 name = "Orgstar iOS"; 426 name = "Orgstar iOS";
423 packageProductDependencies = ( 427 packageProductDependencies = (
424 A2BE626BBE45EA52880B6169 /* OrgApp */, 428 A2BE626BBE45EA52880B6169 /* OrgApp */,
429 FE5434EBA139A800E8727F4B /* OrgMathJax */,
425 47D54A361A74FE9E2B0722BB /* OrgHighlight */, 430 47D54A361A74FE9E2B0722BB /* OrgHighlight */,
426 ); 431 );
427 productName = Orgstar; 432 productName = Orgstar;
@@ -572,6 +577,7 @@
572 name = "Orgstar macOS"; 577 name = "Orgstar macOS";
573 packageProductDependencies = ( 578 packageProductDependencies = (
574 B1EC171400CB989363332D07 /* OrgApp */, 579 B1EC171400CB989363332D07 /* OrgApp */,
580 70EC41AF804F61B000FC5A1E /* OrgMathJax */,
575 0E5F6DB1CD783274FB49FD5E /* OrgEditorAppKit */, 581 0E5F6DB1CD783274FB49FD5E /* OrgEditorAppKit */,
576 88F9A423F8C1EBE523B6438B /* OrgHighlight */, 582 88F9A423F8C1EBE523B6438B /* OrgHighlight */,
577 ); 583 );
@@ -1619,6 +1625,16 @@
1619 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */; 1625 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1620 productName = OrgCore; 1626 productName = OrgCore;
1621 }; 1627 };
1628 FE5434EBA139A800E8727F4B /* OrgMathJax */ = {
1629 isa = XCSwiftPackageProductDependency;
1630 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1631 productName = OrgMathJax;
1632 };
1633 70EC41AF804F61B000FC5A1E /* OrgMathJax */ = {
1634 isa = XCSwiftPackageProductDependency;
1635 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
1636 productName = OrgMathJax;
1637 };
1622/* End XCSwiftPackageProductDependency section */ 1638/* End XCSwiftPackageProductDependency section */
1623 }; 1639 };
1624 rootObject = 46F86FAA6BBF9AC94A7E4595 /* Project object */; 1640 rootObject = 46F86FAA6BBF9AC94A7E4595 /* Project object */;
scripts/build-app.sh +1 −1
@@ -45,7 +45,7 @@ otool -l "$app/Contents/MacOS/Orgstar" | grep -q '@executable_path/../Frameworks
45# SwiftMath's math fonts, which it finds in the app's resources. 45# SwiftMath's math fonts, which it finds in the app's resources.
46cp -R "$(dirname "$binary")/SwiftMath_SwiftMath.bundle" "$app/Contents/Resources/" 46cp -R "$(dirname "$binary")/SwiftMath_SwiftMath.bundle" "$app/Contents/Resources/"
47# MathJax, for PDF export. 47# MathJax, for PDF export.
48cp -R "$(dirname "$binary")/Orgstar_OrgApp.bundle" "$app/Contents/Resources/" 48cp -R "$(dirname "$binary")/Orgstar_OrgMathJax.bundle" "$app/Contents/Resources/"
49 49
50# Updates: the appcast and its signing key, for signed builds only; a dev build never checks. 50# Updates: the appcast and its signing key, for signed builds only; a dev build never checks.
51if [ "$sign" != "-" ]; then 51if [ "$sign" != "-" ]; then