-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPackage.swift
More file actions
161 lines (159 loc) · 8.67 KB
/
Copy pathPackage.swift
File metadata and controls
161 lines (159 loc) · 8.67 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
// swift-tools-version: 6.2
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "MarkdownView",
defaultLocalization: "en",
platforms: [
.iOS(.v16),
.macCatalyst(.v16),
.macOS(.v13),
.visionOS(.v1),
],
products: [
.library(name: "MarkdownView", targets: ["MarkdownView"]),
.library(name: "MarkdownParser", targets: ["MarkdownParser"]),
],
traits: [
// Default to the web-focused languages v0 chat renders. Trait *selection*
// by a consumer isn't carried through Xcode / CocoaPods-generated projects
// (the pbxproj has no per-consumer trait field, so Xcode always resolves
// with the package default) — so the default is the only lever that prunes
// grammars in that environment. The rest stay available by overriding the
// default in a SwiftPM (CLI) consumer, e.g. `traits: ["Swift", "Go"]`.
.default(enabledTraits: [
"JavaScript",
"TypeScript",
"JSON",
"HTML",
"CSS",
"Bash",
]),
.trait(name: "Python", description: "Python syntax highlighting"),
.trait(name: "JavaScript", description: "JavaScript syntax highlighting"),
.trait(name: "TypeScript", description: "TypeScript and TSX syntax highlighting"),
.trait(name: "Go", description: "Go syntax highlighting"),
.trait(name: "Rust", description: "Rust syntax highlighting"),
.trait(name: "Swift", description: "Swift syntax highlighting"),
.trait(name: "C", description: "C syntax highlighting"),
.trait(name: "CPP", description: "C++ syntax highlighting"),
.trait(name: "Java", description: "Java syntax highlighting"),
.trait(name: "Ruby", description: "Ruby syntax highlighting"),
.trait(name: "Bash", description: "Bash/shell syntax highlighting"),
.trait(name: "JSON", description: "JSON syntax highlighting"),
.trait(name: "HTML", description: "HTML syntax highlighting"),
.trait(name: "CSS", description: "CSS syntax highlighting"),
.trait(name: "CSharp", description: "C# syntax highlighting"),
.trait(name: "Kotlin", description: "Kotlin syntax highlighting"),
.trait(name: "SQL", description: "SQL syntax highlighting"),
.trait(name: "YAML", description: "YAML syntax highlighting"),
],
dependencies: [
.package(url: "https://github.com/HumanInterfaceDesign/SwiftMath", branch: "main"),
.package(url: "https://github.com/tree-sitter/swift-tree-sitter", from: "0.9.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-python", "0.23.0"..<"0.25.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-javascript", "0.23.0"..<"0.25.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-typescript", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-go", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-rust", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-cpp", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-java", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-ruby", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-bash", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-json", from: "0.24.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-html", from: "0.23.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-css", "0.23.0"..<"0.25.0"),
.package(url: "https://github.com/tree-sitter/tree-sitter-c-sharp", "0.23.0"..<"0.25.0"),
.package(url: "https://github.com/fwcd/tree-sitter-kotlin", from: "0.3.8"),
.package(url: "https://github.com/HumanInterfaceDesign/tree-sitter-swift", branch: "main"),
.package(url: "https://github.com/HumanInterfaceDesign/tree-sitter-c", branch: "master"),
.package(url: "https://github.com/HumanInterfaceDesign/tree-sitter-sql", branch: "main"),
.package(url: "https://github.com/HumanInterfaceDesign/tree-sitter-yaml", branch: "master"),
.package(url: "https://github.com/swiftlang/swift-cmark", branch: "gfm"),
],
targets: [
.target(
name: "Litext",
resources: [.process("Resources")],
// UIView/NSView-based text label — main-actor by default.
swiftSettings: [
.swiftLanguageMode(.v6),
.defaultIsolation(MainActor.self),
]
),
.target(
name: "MarkdownView",
dependencies: [
"Litext",
"MarkdownParser",
"SwiftMath",
.product(name: "SwiftTreeSitter", package: "swift-tree-sitter"),
.product(name: "TreeSitterPython", package: "tree-sitter-python",
condition: .when(traits: ["Python"])),
.product(name: "TreeSitterJavaScript", package: "tree-sitter-javascript",
condition: .when(traits: ["JavaScript"])),
.product(name: "TreeSitterTypeScript", package: "tree-sitter-typescript",
condition: .when(traits: ["TypeScript"])),
.product(name: "TreeSitterGo", package: "tree-sitter-go",
condition: .when(traits: ["Go"])),
.product(name: "TreeSitterRust", package: "tree-sitter-rust",
condition: .when(traits: ["Rust"])),
.product(name: "TreeSitterSwift", package: "tree-sitter-swift",
condition: .when(traits: ["Swift"])),
.product(name: "TreeSitterC", package: "tree-sitter-c",
condition: .when(traits: ["C"])),
.product(name: "TreeSitterCPP", package: "tree-sitter-cpp",
condition: .when(traits: ["CPP"])),
.product(name: "TreeSitterJava", package: "tree-sitter-java",
condition: .when(traits: ["Java"])),
.product(name: "TreeSitterRuby", package: "tree-sitter-ruby",
condition: .when(traits: ["Ruby"])),
.product(name: "TreeSitterBash", package: "tree-sitter-bash",
condition: .when(traits: ["Bash"])),
.product(name: "TreeSitterJSON", package: "tree-sitter-json",
condition: .when(traits: ["JSON"])),
.product(name: "TreeSitterHTML", package: "tree-sitter-html",
condition: .when(traits: ["HTML"])),
.product(name: "TreeSitterCSS", package: "tree-sitter-css",
condition: .when(traits: ["CSS"])),
.product(name: "TreeSitterCSharp", package: "tree-sitter-c-sharp",
condition: .when(traits: ["CSharp"])),
.product(name: "TreeSitterKotlin", package: "tree-sitter-kotlin",
condition: .when(traits: ["Kotlin"])),
.product(name: "TreeSitterSql", package: "tree-sitter-sql",
condition: .when(traits: ["SQL"])),
.product(name: "TreeSitterYAML", package: "tree-sitter-yaml",
condition: .when(traits: ["YAML"])),
],
resources: [.process("Resources")],
// SwiftUI/UIKit rendering layer — main-actor by default.
swiftSettings: [
.swiftLanguageMode(.v6),
.defaultIsolation(MainActor.self),
]
),
.target(
name: "MarkdownParser",
dependencies: [
.product(name: "cmark-gfm", package: "swift-cmark"),
.product(name: "cmark-gfm-extensions", package: "swift-cmark"),
],
// Pure data / parsing — safe to run off the main actor, so it stays
// nonisolated and models are `Sendable`.
swiftSettings: [.swiftLanguageMode(.v6)]
),
.testTarget(
name: "MarkdownViewTests",
dependencies: [
"Litext",
"MarkdownView",
"MarkdownParser",
]
),
],
// Targets are migrated to the Swift 6 language mode individually (see each
// target's `swiftSettings`). This package default keeps any not-yet-migrated
// target in the Swift 5 mode so its pre-existing concurrency warnings don't
// become errors mid-migration.
swiftLanguageModes: [.v5]
)