Skip to content

Commit 167c3a4

Browse files
remove HTMLExpansionResultType.chunksInline (can be represented using chunks) and...
- move exports to `Exports.swift`
1 parent 6ec1ba0 commit 167c3a4

File tree

6 files changed

+46
-38
lines changed

6 files changed

+46
-38
lines changed

Sources/HTMLKit/Exports.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
@_exported import CSS
3+
@_exported import HTMLAttributes
4+
@_exported import HTMLElements
5+
@_exported import HTMLKitUtilities
6+
@_exported import HTMX

Sources/HTMLKit/HTMLKit.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,4 @@
11

2-
@_exported import CSS
3-
@_exported import HTMLAttributes
4-
@_exported import HTMLElements
5-
@_exported import HTMLKitUtilities
6-
@_exported import HTMX
7-
82
// MARK: Escape HTML
93
@freestanding(expression)
104
public macro escapeHTML(

Sources/HTMLKitParse/ExpandHTMLMacro.swift

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,6 @@ extension HTMLExpansionResultTypeAST {
9494
case .chunks(let optimized, let chunkSize):
9595
let slices = chunks(encoding: encoding, encodedResult: encodedResult, async: false, optimized: optimized, chunkSize: chunkSize).joined(separator: ",\n")
9696
return "[" + (slices.isEmpty ? "" : "\n\(slices)\n") + "]"
97-
#if compiler(>=6.2)
98-
case .chunksInline(let optimized, let chunkSize):
99-
let typeAnnotation:String = "String" // TODO: fix
100-
let slices = chunks(encoding: encoding, encodedResult: encodedResult, async: false, optimized: optimized, chunkSize: chunkSize).joined(separator: ",\n")
101-
return "InlineArray<\(chunks.count), \(typeAnnotation)>([" + (slices.isEmpty ? "" : "\n\(slices)\n") + "])"
102-
#endif
10397
case .stream(let optimized, let chunkSize):
10498
return streamed(
10599
encoding: encoding,

Sources/HTMLKitParse/ParseData.swift

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,12 +95,6 @@ extension HTMLExpansionResultTypeAST {
9595
case "literal": return .literal
9696
//case "literalOptimized": return .literalOptimized
9797
case "chunks": return .chunks()
98-
case "chunksInline":
99-
#if compiler(>=6.2)
100-
return .chunksInline()
101-
#else
102-
return nil // TODO: show compiler diagnostic
103-
#endif
10498

10599
case "stream": return .stream()
106100
case "streamAsync": return .streamAsync()
@@ -138,12 +132,6 @@ extension HTMLExpansionResultTypeAST {
138132
switch function.calledExpression.memberAccess?.declName.baseName.text {
139133
case "chunks":
140134
return .chunks(optimized: optimized, chunkSize: chunkSize)
141-
case "chunksInline":
142-
#if compiler(>=6.2)
143-
return .chunksInline(optimized: optimized, chunkSize: chunkSize)
144-
#else
145-
return nil // TODO: show compiler diagnostic
146-
#endif
147135
case "stream":
148136
return .stream(optimized: optimized, chunkSize: chunkSize)
149137
case "streamAsync":

Sources/HTMLKitUtilities/HTMLExpansionResultType.swift

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11

2+
/// The expected data type the macro expansion should return the result as.
23
public enum HTMLExpansionResultType: Sendable {
34

45

@@ -24,16 +25,6 @@ public enum HTMLExpansionResultType: Sendable {
2425
/// - Returns: An array of encoded literals of length up-to `chunkSize`.
2526
case chunks(optimized: Bool = true, chunkSize: Int = 1024)
2627

27-
#if compiler(>=6.2)
28-
/// Breaks up the encoded literal into chunks.
29-
///
30-
/// - Parameters:
31-
/// - optimized: Whether or not to use optimized literals. Default is `true`.
32-
/// - chunkSize: The maximum size of an individual literal. Default is `1024`.
33-
/// - Returns: An `InlineArray` of encoded literals of length up-to `chunkSize`.
34-
case chunksInline(optimized: Bool = true, chunkSize: Int = 1024)
35-
#endif
36-
3728

3829

3930
// MARK: Stream
@@ -73,10 +64,6 @@ public enum HTMLExpansionResultTypeAST: Sendable {
7364

7465
case chunks(optimized: Bool = true, chunkSize: Int = 1024)
7566

76-
#if compiler(>=6.2)
77-
case chunksInline(optimized: Bool = true, chunkSize: Int = 1024)
78-
#endif
79-
8067
case stream(optimized: Bool = true, chunkSize: Int = 1024)
8168
case streamAsync(
8269
optimized: Bool = true,

Tests/HTMLKitTests/ResultTypeTests.swift

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,45 @@ extension ResultTypeTests {
8080
}
8181
}
8282

83+
#if compiler(>=6.2)
84+
// MARK: Chunks inline
85+
extension ResultTypeTests {
86+
@Test
87+
func resultTypeChunksInline() {
88+
let _:InlineArray<1, String> = #html(resultType: .chunks()) {
89+
div("oh yeah")
90+
}
91+
92+
let expected = "<div>oh yeah</div>"
93+
let chunks1:InlineArray<1, String> = #html(resultType: .chunks()) {
94+
div("oh yeah")
95+
}
96+
#expect(chunks1[0] == expected)
97+
98+
let chunks6:InlineArray<6, String> = #html(resultType: .chunks(chunkSize: 3)) {
99+
div("oh \(yeah)")
100+
}
101+
#expect(chunks6[0] == "<di")
102+
#expect(chunks6[1] == "v>o")
103+
#expect(chunks6[2] == "h ")
104+
#expect(chunks6[3] == "\(yeah)")
105+
#expect(chunks6[4] == "</d")
106+
#expect(chunks6[5] == "iv>")
107+
108+
let chunks7:InlineArray<7, String> = #html(resultType: .chunks(chunkSize: 3)) {
109+
div("oh \(yeah)", yeah)
110+
}
111+
#expect(chunks7[0] == "<di")
112+
#expect(chunks7[1] == "v>o")
113+
#expect(chunks7[2] == "h ")
114+
#expect(chunks7[3] == "\(yeah)")
115+
#expect(chunks7[4] == "\(yeah)")
116+
#expect(chunks7[5] == "</d")
117+
#expect(chunks7[6] == "iv>")
118+
}
119+
}
120+
#endif
121+
83122
// MARK: Stream
84123
extension ResultTypeTests {
85124
@Test

0 commit comments

Comments
 (0)