Skip to content

Commit 304b3e7

Browse files
fixed GenerateElements/main.swift
1 parent 658397d commit 304b3e7

File tree

6 files changed

+44
-0
lines changed

6 files changed

+44
-0
lines changed

Sources/CSS/CSSUnit.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Created by Evan Anderson on 11/19/24.
66
//
77

8+
#if canImport(HTMLKitUtilities)
89
import HTMLKitUtilities
10+
#endif
911

1012
#if canImport(SwiftSyntax)
1113
import SwiftSyntax

Sources/GenerateElements/main.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
swiftc main.swift \
1111
../HTMLKitUtilities/HTMLElementType.swift \
1212
../HTMLKitUtilities/HTMLEncoding.swift \
13+
../HTMLKitUtilities/HTMLInitializable.swift \
1314
../HTMLAttributes/HTMLAttributes.swift \
1415
../HTMLAttributes/HTMLAttributes+Extra.swift \
1516
../CSS/CSSUnit.swift \
@@ -22,6 +23,7 @@
2223

2324
// Why do we do it this way?
2425
// - The documentation doesn't link correctly (or at all) if we generate from a macro
26+
// - Noticable performance hit for incremental builds under certain conditions due to multiple macro expansions/indexing
2527

2628
import Foundation
2729

Sources/HTMLAttributes/HTMLAttributes+Extra.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,13 @@
55
// Created by Evan Anderson on 11/21/24.
66
//
77

8+
#if canImport(CSS)
89
import CSS
10+
#endif
11+
12+
#if canImport(HTMLKitUtilities)
913
import HTMLKitUtilities
14+
#endif
1015

1116
#if canImport(SwiftSyntax)
1217
import SwiftSyntax

Sources/HTMLAttributes/HTMLAttributes.swift

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,17 @@
55
// Created by Evan Anderson on 11/19/24.
66
//
77

8+
#if canImport(CSS)
89
import CSS
10+
#endif
11+
12+
#if canImport(HTMLKitUtilities)
913
import HTMLKitUtilities
14+
#endif
15+
16+
#if canImport(HTMX)
1017
import HTMX
18+
#endif
1119

1220
#if canImport(SwiftSyntax)
1321
import SwiftSyntax
@@ -46,7 +54,11 @@ public enum HTMLAttribute : HTMLInitializable {
4654
case popover(Extra.popover? = nil)
4755
case slot(String? = nil)
4856
case spellcheck(Extra.spellcheck? = nil)
57+
58+
#if canImport(CSS)
4959
case style([CSSStyle]? = nil)
60+
#endif
61+
5062
case tabindex(Int? = nil)
5163
case title(String? = nil)
5264
case translate(Extra.translate? = nil)
@@ -117,7 +129,11 @@ public enum HTMLAttribute : HTMLInitializable {
117129
case "popover": self = .popover(enumeration())
118130
case "slot": self = .slot(string())
119131
case "spellcheck": self = .spellcheck(enumeration())
132+
133+
#if canImport(CSS)
120134
case "style": self = .style(array_enumeration())
135+
#endif
136+
121137
case "tabindex": self = .tabindex(int())
122138
case "title": self = .title(string())
123139
case "translate": self = .translate(enumeration())
@@ -169,7 +185,11 @@ public enum HTMLAttribute : HTMLInitializable {
169185
case .popover: return "popover"
170186
case .slot: return "slot"
171187
case .spellcheck: return "spellcheck"
188+
189+
#if canImport(CSS)
172190
case .style: return "style"
191+
#endif
192+
173193
case .tabindex: return "tabindex"
174194
case .title: return "title"
175195
case .translate: return "translate"
@@ -224,7 +244,11 @@ public enum HTMLAttribute : HTMLInitializable {
224244
case .popover(let value): return value?.rawValue
225245
case .slot(let value): return value
226246
case .spellcheck(let value): return value?.rawValue
247+
248+
#if canImport(CSS)
227249
case .style(let value): return value?.compactMap({ $0.htmlValue(encoding: encoding, forMacro: forMacro) }).joined(separator: ";")
250+
#endif
251+
228252
case .tabindex(let value): return value?.description
229253
case .title(let value): return value
230254
case .translate(let value): return value?.rawValue

Sources/HTMX/HTMX+Attributes.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Created by Evan Anderson on 11/19/24.
66
//
77

8+
#if canImport(HTMLKitUtilities)
89
import HTMLKitUtilities
10+
#endif
911

1012
#if canImport(SwiftSyntax)
1113
import SwiftSyntax

Sources/HTMX/HTMX.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
// Created by Evan Anderson on 11/12/24.
66
//
77

8+
#if canImport(HTMLKitUtilities)
89
import HTMLKitUtilities
10+
#endif
911

1012
#if canImport(SwiftSyntax)
1113
import SwiftSyntax
@@ -40,7 +42,14 @@ public enum HTMX : HTMLInitializable {
4042
case get(String?)
4143
case post(String?)
4244
case on(Event?, String)
45+
46+
#if canImport(HTMLKitUtilities)
4347
case onevent(HTMLElementAttribute.Extra.event?, String)
48+
#else
49+
case onevent(HTMLAttribute.Extra.event?, String)
50+
#endif
51+
52+
4453
case pushURL(URL?)
4554
case select(String?)
4655
case selectOOB(String?)

0 commit comments

Comments
 (0)