-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPackage.swift
More file actions
275 lines (252 loc) · 10.1 KB
/
Copy pathPackage.swift
File metadata and controls
275 lines (252 loc) · 10.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
// swift-tools-version: 6.2
import PackageDescription
let package = Package(
name: "swift-markdown-view",
// tvOS and watchOS are deliberately absent. swift-design-system and swift-latex-view declare
// neither, so the graph cannot resolve for them. Declaring a platform the dependencies cannot
// support turns a clear "unsupported" into a failure nobody can explain.
platforms: [
.iOS(.v17),
.macOS(.v14)
],
products: [
.library(
name: "SwiftMarkdownView",
targets: ["SwiftMarkdownView"]
),
.library(
name: "SwiftMarkdownViewHighlightJS",
targets: ["SwiftMarkdownViewHighlightJS"]
),
.library(
name: "SwiftMarkdownViewLaTeX",
targets: ["SwiftMarkdownViewLaTeX"]
),
.library(
name: "SwiftMarkdownEditor",
targets: ["SwiftMarkdownEditor"]
),
// Bridge for apps already on swift-design-system. The core does not depend on any external
// design system, so only those who need theme integration take this on top.
.library(
name: "SwiftMarkdownViewDesignSystem",
targets: ["SwiftMarkdownViewDesignSystem"]
),
.library(
name: "SwiftMarkdownEditorDesignSystem",
targets: ["SwiftMarkdownEditorDesignSystem"]
),
// Demo screens that render each feature. Not a library capability, so it stays out of the
// core and is opted into by whoever wants to look.
.library(
name: "SwiftMarkdownViewCatalog",
targets: ["SwiftMarkdownViewCatalog"]
)
],
dependencies: [
.package(url: "https://github.com/no-problem-dev/swift-design-system.git", from: "4.0.0"),
.package(url: "https://github.com/swiftlang/swift-markdown.git", .upToNextMajor(from: "0.7.3")),
.package(url: "https://github.com/no-problem-dev/swift-visual-testing.git", .upToNextMajor(from: "3.0.0")),
.package(url: "https://github.com/apple/swift-docc-plugin.git", .upToNextMajor(from: "1.4.0")),
.package(url: "https://github.com/appstefan/HighlightSwift.git", .upToNextMajor(from: "1.0.0")),
.package(url: "https://github.com/no-problem-dev/swift-latex-view.git", .upToNextMinor(from: "0.5.0"))
],
targets: [
// Nothing but the UIKit / AppKit cross-platform aliases. The renderer side
// (MarkdownAttributedKit) and the editor side (SwiftMarkdownEditorTextKit) each declared
// their own public typealias under the same name, which became ambiguous in the scope of
// anyone importing both. One definition, in one place.
.target(name: "MarkdownPlatform"),
.target(
name: "MarkdownModel",
dependencies: [
.product(name: "Markdown", package: "swift-markdown")
]
),
.testTarget(
name: "MarkdownModelTests",
dependencies: [
"MarkdownModel"
]
),
// Cross-platform (UIKit / AppKit) but free of SwiftUI. Composes the model into a single
// NSAttributedString, and owns the semantic attribute keys, the decoration descriptors, and
// the TextKit extension protocols for highlighting and math. Whether selection and Copy come
// out right is decided here, which is why this layer is headless and unit-testable.
.target(
name: "MarkdownAttributedKit",
dependencies: [
"MarkdownPlatform",
"MarkdownModel"
]
),
.testTarget(
name: "MarkdownAttributedKitTests",
dependencies: [
"MarkdownAttributedKit"
]
),
// One text storage, one TextKit 2 view: a representable over a read-only UITextView /
// NSTextView, custom layout fragment drawing, selection, and Copy. iOS and macOS only.
.target(
name: "MarkdownTextKit",
dependencies: [
"MarkdownAttributedKit"
]
),
.testTarget(
name: "MarkdownTextKitTests",
dependencies: [
"MarkdownTextKit"
]
),
// The renderer itself, with no external design system in it. Colors, metrics, and type
// sizes are its own abstractions — MarkdownPalette, MarkdownMetrics, MarkdownTypeScale — and
// the defaults are system semantic colors, which follow light and dark on their own.
.target(
name: "SwiftMarkdownView",
dependencies: [
"MarkdownModel",
"MarkdownAttributedKit",
"MarkdownTextKit"
]
),
// Maps swift-design-system tokens onto the renderer's own theming abstractions.
.target(
name: "SwiftMarkdownViewDesignSystem",
dependencies: [
"SwiftMarkdownView",
.product(name: "DesignSystem", package: "swift-design-system")
]
),
// The catalog of feature demos. It is split out because a demo changes when there is
// something new to show, and the renderer changes when the Markdown handling or the layout
// is wrong. Together in one target, editing a demo screen forces a major bump on the library.
.target(
name: "SwiftMarkdownViewCatalog",
dependencies: [
"SwiftMarkdownView",
"SwiftMarkdownViewDesignSystem",
.product(name: "DesignSystem", package: "swift-design-system")
]
),
.target(
name: "SwiftMarkdownViewHighlightJS",
dependencies: [
"SwiftMarkdownView",
.product(name: "HighlightSwift", package: "HighlightSwift")
]
),
.target(
name: "SwiftMarkdownViewLaTeX",
dependencies: [
"SwiftMarkdownView",
// swift-latex-view's MathStyle protocol requires ColorPalette and SpacingScale, so
// this is the one add-on that cannot avoid DesignSystem. The core does not depend on
// it, so the cost is taken on only by whoever opts into math.
.product(name: "DesignSystem", package: "swift-design-system"),
.product(name: "SwiftLaTeXView", package: "swift-latex-view")
]
),
.testTarget(
name: "SwiftMarkdownViewLaTeXTests",
dependencies: [
"SwiftMarkdownViewLaTeX"
]
),
// MARK: - Editor
// The editor's UI-free document model: EditorState, TextChange, offset mapping, tokenizer.
// Depends only on Foundation and the content model, and imports neither UIKit nor SwiftUI, so
// the logic can be pinned down by unit tests.
.target(
name: "SwiftMarkdownEditorCore",
dependencies: [
"MarkdownModel"
]
),
.testTarget(
name: "SwiftMarkdownEditorCoreTests",
dependencies: [
"SwiftMarkdownEditorCore"
]
),
// Markdown autoformatting (input rules). Pure logic, layered on the editor core.
.target(
name: "SwiftMarkdownEditorRules",
dependencies: [
"SwiftMarkdownEditorCore"
]
),
.testTarget(
name: "SwiftMarkdownEditorRulesTests",
dependencies: [
"SwiftMarkdownEditorRules"
]
),
// The TextKit 2 bridge: representables over UITextView / NSTextView, plus live syntax
// highlighting. This is where UI enters, so SwiftUI and UIKit arrive with it.
.target(
name: "SwiftMarkdownEditorTextKit",
dependencies: [
"MarkdownPlatform",
"SwiftMarkdownEditorCore",
"SwiftMarkdownEditorRules"
]
),
.testTarget(
name: "SwiftMarkdownEditorTextKitTests",
dependencies: [
"SwiftMarkdownEditorTextKit"
]
),
// The public SwiftUI layer: the MarkdownEditor view, its toolbar, mode switching, and the
// split preview. No external design system; colors come from the MarkdownEditorTheme
// environment value.
.target(
name: "SwiftMarkdownEditor",
dependencies: [
"SwiftMarkdownView",
"SwiftMarkdownEditorCore",
"SwiftMarkdownEditorRules",
"SwiftMarkdownEditorTextKit"
]
),
// Derives a MarkdownEditorTheme from the swift-design-system palette.
.target(
name: "SwiftMarkdownEditorDesignSystem",
dependencies: [
"SwiftMarkdownEditor",
"SwiftMarkdownEditorTextKit",
.product(name: "DesignSystem", package: "swift-design-system")
]
),
.testTarget(
name: "SwiftMarkdownEditorTests",
dependencies: [
"SwiftMarkdownEditor",
.product(name: "VisualTesting", package: "swift-visual-testing")
]
),
.testTarget(
name: "SwiftMarkdownViewTests",
dependencies: [
"SwiftMarkdownView",
"SwiftMarkdownViewHighlightJS",
"SwiftMarkdownViewLaTeX",
.product(name: "VisualTesting", package: "swift-visual-testing")
],
resources: [
// A directory named "Resources" at the root of an iOS bundle is mistaken by codesign
// for the macOS bundle layout and fails signing. Hence this name.
.copy("TestResources")
]
),
.testTarget(
name: "SwiftMarkdownViewHighlightJSTests",
dependencies: [
"SwiftMarkdownViewHighlightJS",
.product(name: "VisualTesting", package: "swift-visual-testing")
]
)
]
)