Skip to content

Commit e0c3c52

Browse files
enable StrictConcurrency; Sendable fixes
1 parent a550e40 commit e0c3c52

File tree

10 files changed

+24
-17
lines changed

10 files changed

+24
-17
lines changed

Package.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,9 @@ let package = Package(
116116
),
117117
]
118118
)
119+
120+
for target in package.targets {
121+
target.swiftSettings = [
122+
.enableExperimentalFeature("StrictConcurrency")
123+
]
124+
}

Sources/HTMLAttributes/HTMLAttribute.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,18 +229,18 @@ public enum HTMLAttribute : HTMLInitializable {
229229

230230
// MARK: ElementData
231231
extension HTMLKitUtilities {
232-
public struct ElementData {
232+
public struct ElementData : Sendable {
233233
public let encoding:HTMLEncoding
234234
public let globalAttributes:[HTMLAttribute]
235-
public let attributes:[String:Any]
236-
public let innerHTML:[CustomStringConvertible]
235+
public let attributes:[String:Sendable]
236+
public let innerHTML:[CustomStringConvertible & Sendable]
237237
public let trailingSlash:Bool
238238

239239
package init(
240240
_ encoding: HTMLEncoding,
241241
_ globalAttributes: [HTMLAttribute],
242-
_ attributes: [String:Any],
243-
_ innerHTML: [CustomStringConvertible],
242+
_ attributes: [String:Sendable],
243+
_ innerHTML: [CustomStringConvertible & Sendable],
244244
_ trailingSlash: Bool
245245
) {
246246
self.encoding = encoding

Sources/HTMLElements/CustomElement.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public struct custom : HTMLElement {
3737
tag: String,
3838
isVoid: Bool,
3939
attributes: [HTMLAttribute] = [],
40-
_ innerHTML: CustomStringConvertible...
40+
_ innerHTML: CustomStringConvertible & Sendable...
4141
) {
4242
self.tag = tag
4343
self.isVoid = isVoid

Sources/HTMLElements/svg/svg.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ struct svg : HTMLElement {
4040
}
4141
public init(
4242
attributes: [HTMLAttribute] = [],
43-
_ innerHTML: CustomStringConvertible...
43+
_ innerHTML: CustomStringConvertible & Sendable...
4444
) {
4545
trailingSlash = attributes.contains(.trailingSlash)
4646
self.attributes = attributes

Sources/HTMLKitParse/InterpolationLookup.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,9 @@ import SwiftParser
1313
import SwiftSyntax
1414

1515
enum InterpolationLookup {
16-
private static var cached:[String:CodeBlockItemListSyntax] = [:]
16+
@MainActor private static var cached:[String:CodeBlockItemListSyntax] = [:]
1717

18+
@MainActor
1819
static func find(context: HTMLExpansionContext, _ node: some ExprSyntaxProtocol, files: Set<String>) -> String? {
1920
guard !files.isEmpty, let item:Item = item(context: context, node) else { return nil }
2021
for file in files {

Sources/HTMLKitParse/ParseData.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ extension HTMLKitUtilities {
8888
) -> ElementData {
8989
var context:HTMLExpansionContext = context
9090
var global_attributes:[HTMLAttribute] = []
91-
var attributes:[String:Any] = [:]
92-
var innerHTML:[CustomStringConvertible] = []
91+
var attributes:[String:Sendable] = [:]
92+
var innerHTML:[CustomStringConvertible & Sendable] = []
9393
var trailingSlash:Bool = false
9494
for element in context.arguments.children(viewMode: .all) {
9595
if let child:LabeledExprSyntax = element.labeled {
@@ -126,7 +126,7 @@ extension HTMLKitUtilities {
126126
}
127127
}
128128
// inner html
129-
} else if let inner_html:CustomStringConvertible = parseInnerHTML(context: context, child: child) {
129+
} else if let inner_html:CustomStringConvertible & Sendable = parseInnerHTML(context: context, child: child) {
130130
innerHTML.append(inner_html)
131131
}
132132
}
@@ -194,7 +194,7 @@ extension HTMLKitUtilities {
194194
public static func parseInnerHTML(
195195
context: HTMLExpansionContext,
196196
child: LabeledExprSyntax
197-
) -> CustomStringConvertible? {
197+
) -> (CustomStringConvertible & Sendable)? {
198198
if let expansion:MacroExpansionExprSyntax = child.expression.macroExpansion {
199199
if expansion.macroName.text == "escapeHTML" {
200200
var c:HTMLExpansionContext = context

Sources/HTMLKitParse/ParseLiteral.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ extension HTMLKitUtilities {
174174
default:
175175
separator = " "
176176
}
177-
var results:[Any] = []
177+
var results:[Sendable] = []
178178
for element in array.elements {
179179
if let attribute:any HTMLInitializable = HTMLAttribute.Extra.parse(context: context, expr: element.expression) {
180180
results.append(attribute)
@@ -210,7 +210,7 @@ public enum LiteralReturnType {
210210
case int(Int)
211211
case float(Float)
212212
case interpolation(String)
213-
case array([Any])
213+
case array([Sendable])
214214

215215
public var isInterpolation : Bool {
216216
switch self {

Sources/HTMLKitUtilities/HTMLElementType.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// Created by Evan Anderson on 11/21/24.
66
//
77

8-
public enum HTMLElementType : String, CaseIterable {
8+
public enum HTMLElementType : String, CaseIterable, Sendable {
99
case html
1010

1111
case a

Sources/HTMLKitUtilities/HTMLExpansionContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import SwiftSyntaxMacros
1111
#endif
1212

1313
/// Data required to process an HTML expansion.
14-
public struct HTMLExpansionContext {
14+
public struct HTMLExpansionContext : @unchecked Sendable {
1515
#if canImport(SwiftSyntax) && canImport(SwiftSyntaxMacros)
1616
public let context:MacroExpansionContext
1717
public let expansion:MacroExpansionExprSyntax

Sources/HTMLKitUtilityMacros/HTMLElements.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ enum HTMLElements : DeclarationMacro {
9797
for (key, value_type, default_value) in attributes {
9898
initializers += key + ": " + value_type + default_value + ",\n"
9999
}
100-
initializers += "_ innerHTML: CustomStringConvertible...\n) {\n"
100+
initializers += "_ innerHTML: CustomStringConvertible & Sendable...\n) {\n"
101101
initializers += "self.attributes = attributes\n"
102102
for (key, _, _) in attributes {
103103
var key_literal:String = key

0 commit comments

Comments
 (0)