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(
1616 .library(name: "OrgEditorAppKit", targets: ["OrgEditorAppKit"]),
1717 .executable(name: "OrgstarSpike", targets: ["OrgstarSpike"]),
1818 .library(name: "OrgApp", targets: ["OrgApp"]),
19 .library(name: "OrgMathJax", targets: ["OrgMathJax"]),
1920 .library(name: "OrgWatchData", targets: ["OrgWatchData"]),
2021 .library(name: "OrgHighlight", targets: ["OrgHighlight"]),
2122 .executable(name: "Orgstar", targets: ["Orgstar"]),
@@ -87,8 +88,9 @@ let package = Package(
8788 ]
8889 ),
8990 .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"], resources: [.copy("Resources/MathJax")]),
91 .target(name: "OrgApp", dependencies: ["OrgWorkspace", "OrgDocument", "OrgPresentation", "OrgWatchData"]),
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")]),
9294 // What the phone and the watch send each other; Foundation only, so the watch builds it.
9395 .target(name: "OrgWatchData"),
9496 // The watch app and its complications, bundled by scripts/build-watch-app.sh.
@@ -96,9 +98,9 @@ let package = Package(
9698 .executableTarget(name: "OrgstarWatchWidgets", dependencies: ["OrgWatchData"]),
9799 // Babel, Emacs and gnuplot as processes; the Developer ID app alone links it.
98100 .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")]),
100102 // 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"]),
102104 // App extensions, bundled into orgstar.app by scripts/build-app.sh.
103105 .executableTarget(name: "OrgstarQuickLook", dependencies: ["OrgCore"], linkerSettings: extensionEntry),
104106 .executableTarget(name: "OrgstarSpotlight", dependencies: ["OrgCore"], linkerSettings: extensionEntry),
@@ -114,7 +116,7 @@ let package = Package(
114116 .testTarget(name: "OrgWorkspaceTests", dependencies: ["OrgWorkspace"]),
115117 .testTarget(name: "OrgPresentationTests", dependencies: ["OrgPresentation"]),
116118 .testTarget(name: "OrgEditorAppKitTests", dependencies: ["OrgEditorAppKit", "OrgApp"]),
117 .testTarget(name: "OrgAppTests", dependencies: ["OrgApp", "OrgDocument"]),
119 .testTarget(name: "OrgAppTests", dependencies: ["OrgApp", "OrgDocument", "OrgMathJax"]),
118120 .testTarget(name: "OrgProgramsTests", dependencies: ["OrgPrograms", "OrgApp", "OrgDocument"]),
119121 .testTarget(name: "OrgHighlightTests", dependencies: ["OrgHighlight", "OrgCore", "OrgPresentation"])
120122 ]
Sources/OrgApp/PDFExport.swift +5 −5
@@ -125,12 +125,12 @@ public enum PDFExport {
125125 </style>
126126 """
127127
128 /// MathJax 3.2.2's `tex-svg-full.js`: every TeX extension in one file, with SVG output that
129 /// needs no font files, so nothing is fetched.
128 /// MathJax's `tex-svg-full.js`, which the app sets from `OrgMathJax.script`: every TeX
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
130132 nonisolated static func bundledMathJax() throws -> String {
131 guard let url = Bundle.module.url(forResource: "tex-svg-full", withExtension: "js", subdirectory: "MathJax") else {
132 throw Failure(description: "MathJax is missing from the app.")
133 }
133 guard let url = mathJaxURL else { throw Failure(description: "MathJax is missing from the app.") }
134134 return try String(contentsOf: url, encoding: .utf8)
135135 }
136136
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
22import OrgApp
33import OrgCore
44import OrgEditorAppKit
5import OrgMathJax
56import OrgPresentation
67#if !APPSTORE
78import OrgPrograms
@@ -374,6 +375,7 @@ struct OrgstarApp: App {
374375 }()
375376
376377 init() {
378 PDFExport.mathJaxURL = OrgMathJax.script
377379 #if APPSTORE
378380 AgendaSnapshot.useGroupContainer = true
379381 EmacsFallback.offered = false
Sources/OrgstarMobile/OrgstarMobileApp.swift +2
@@ -2,6 +2,7 @@
22import CoreSpotlight
33import OrgApp
44import OrgCore
5import OrgMathJax
56import SwiftUI
67import UserNotifications
78
@@ -14,6 +15,7 @@ struct OrgstarMobileApp: App {
1415 @Environment(\.scenePhase) private var scenePhase
1516
1617 init() {
18 PDFExport.mathJaxURL = OrgMathJax.script
1719 // Debug builds, and runs from Xcode, whose scheme sets ORGSTAR_PERF.
1820 #if DEBUG
1921 Perf.watchMainThread()
THIRD_PARTY.org +1 −1
@@ -10,7 +10,7 @@ orgstar is proprietary (see [[file:LICENSE]]). It builds on these projects, unde
1010| [[https://github.com/r-lib/tree-sitter-r][tree-sitter-r]] | Highlighting | MIT |
1111| [[https://github.com/6cdh/tree-sitter-scheme][tree-sitter-scheme]] | Highlighting | MIT |
1212| [[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 |
1414| [[https://github.com/Wilfred/tree-sitter-elisp][tree-sitter-elisp]] | Highlighting (vendored in =Sources/TreeSitterElisp=) | MIT |
1515| [[https://github.com/sogaiu/tree-sitter-clojure][tree-sitter-clojure]] | Highlighting (vendored in =Sources/TreeSitterClojure=) | CC0-1.0 |
1616| [[https://ethanschoonover.com/solarized/][Solarized]] | Colors of the Solarized themes | MIT |
Tests/OrgAppTests/PDFExportTests.swift +3
@@ -1,5 +1,6 @@
11import Foundation
22import OrgCore
3import OrgMathJax
34import PDFKit
45import Testing
56import WebKit
@@ -7,6 +8,8 @@ import WebKit
78
89@MainActor
910struct PDFExportTests {
11 init() { PDFExport.mathJaxURL = OrgMathJax.script }
12
1013 /// A long document comes out as several pages with its text, without Emacs.
1114 @Test func paginatesTheHTMLExport() async throws {
1215 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 @@
77 objects = {
88
99/* Begin PBXBuildFile section */
10 EC91295D4306AF0CE88F1D07 /* OrgMathJax in Frameworks */ = {isa = PBXBuildFile; productRef = 70EC41AF804F61B000FC5A1E /* OrgMathJax */; };
11 7080D3827813E58F1F3C6ABC /* OrgMathJax in Frameworks */ = {isa = PBXBuildFile; productRef = FE5434EBA139A800E8727F4B /* OrgMathJax */; };
1012 1B78003BBCE8A4B809333342 /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = A2BE626BBE45EA52880B6169 /* OrgApp */; };
1113 1E5861C0EFE1D96CDC21A22F /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = BA239181876756F7732397EB /* OrgApp */; };
1214 2BE799BF03ED43EAA6849F53 /* OrgApp in Frameworks */ = {isa = PBXBuildFile; productRef = EDEF22C5B4F393296F1D17BB /* OrgApp */; };
@@ -281,6 +283,7 @@
281283 buildActionMask = 2147483647;
282284 files = (
283285 1B78003BBCE8A4B809333342 /* OrgApp in Frameworks */,
286 7080D3827813E58F1F3C6ABC /* OrgMathJax in Frameworks */,
284287 9BE045FD696469CA8D19F22C /* OrgHighlight in Frameworks */,
285288 );
286289 runOnlyForDeploymentPostprocessing = 0;
@@ -314,6 +317,7 @@
314317 buildActionMask = 2147483647;
315318 files = (
316319 34F40D483630871B50619E6F /* OrgApp in Frameworks */,
320 EC91295D4306AF0CE88F1D07 /* OrgMathJax in Frameworks */,
317321 4392873ADA2B1FC8930BE6C9 /* OrgEditorAppKit in Frameworks */,
318322 CA594F2E6DAFED2D16900872 /* OrgHighlight in Frameworks */,
319323 );
@@ -422,6 +426,7 @@
422426 name = "Orgstar iOS";
423427 packageProductDependencies = (
424428 A2BE626BBE45EA52880B6169 /* OrgApp */,
429 FE5434EBA139A800E8727F4B /* OrgMathJax */,
425430 47D54A361A74FE9E2B0722BB /* OrgHighlight */,
426431 );
427432 productName = Orgstar;
@@ -572,6 +577,7 @@
572577 name = "Orgstar macOS";
573578 packageProductDependencies = (
574579 B1EC171400CB989363332D07 /* OrgApp */,
580 70EC41AF804F61B000FC5A1E /* OrgMathJax */,
575581 0E5F6DB1CD783274FB49FD5E /* OrgEditorAppKit */,
576582 88F9A423F8C1EBE523B6438B /* OrgHighlight */,
577583 );
@@ -1619,6 +1625,16 @@
16191625 package = A46A1BCE0B67C45BEC8F435B /* XCLocalSwiftPackageReference ".." */;
16201626 productName = OrgCore;
16211627 };
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 };
16221638/* End XCSwiftPackageProductDependency section */
16231639 };
16241640 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
4545# SwiftMath's math fonts, which it finds in the app's resources.
4646cp -R "$(dirname "$binary")/SwiftMath_SwiftMath.bundle" "$app/Contents/Resources/"
4747# MathJax, for PDF export.
48cp -R "$(dirname "$binary")/Orgstar_OrgApp.bundle" "$app/Contents/Resources/"
48cp -R "$(dirname "$binary")/Orgstar_OrgMathJax.bundle" "$app/Contents/Resources/"
4949
5050# Updates: the appcast and its signing key, for signed builds only; a dev build never checks.
5151if [ "$sign" != "-" ]; then