Skip to content

Commit 9db14ac

Browse files
JSON stylesheet decoder generation (#1515)
* Functional modifier generation build plugin * Add supporting StylesheetResolvable types * Fix concurrency issues and decoders nested in `IfConfigDeclSyntax` * Add BuiltinModifier generator * Fix AttributeReference decoder * Chunk modifier decoding to reduce memory consumption * Fix TextReference display of raw string values * Add image modifiers and improve clause matching and labeled argument handling * Handle atom ast node * Working gesture state * Add ShapeFinalizerModifier * Add shape modifiers, support for variadic arguments, and improved ShapeStyle support * Fix default values on unlabeled arguments preceding other arguments * Expand gesture support * Disable Edge.Set decoder * Add Edge.Set that supports array literals * Working ChangeTracked arguments to replace Binding in modifier definitions * Refactor Event property wrapper * Fix event decoding and usage from modifiers with `event(...)` helper * Refactor ChangeTracked to use `.Resolvable` for decoding to avoid StateObject runtime warnings * macOS build support * Fix diff error by checking change type * Fix debounce checks outside of environment by caching value in EventHandler * replace changeType: Send updates to parent and replaced node * don't cancel running reconnect (#1536) * don't cancel running reconnect * add startup task, remove return statement * debounce rapid reconnect events * debounce even more * Remove change event on blur * Support ToolbarContentBuilder * Remove outdating parsing tests * Fix watchOS/tvOS builds * Prevent nonexistant variant from breaking MacOs Desktop Builds (#1542) * desktop_json_fix * Update Sources/LiveViewNative/Stylesheets/ResolvableTypes/SwiftUI/Styles/ListStyle.swift Signed-off-by: Carson Katri <[email protected]> --------- Signed-off-by: Carson Katri <[email protected]> Co-authored-by: Carson Katri <[email protected]> --------- Signed-off-by: Carson Katri <[email protected]> Co-authored-by: mobile-bungalow <[email protected]>
1 parent 48b226e commit 9db14ac

File tree

278 files changed

+14278
-35328
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

278 files changed

+14278
-35328
lines changed

Package.resolved

Lines changed: 5 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 45 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,8 @@ let package = Package(
2828
.package(url: "https://github.com/liveview-native/liveview-native-core", exact: "0.4.1-rc-1"),
2929

3030
.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0"),
31-
.package(url: "https://github.com/swiftlang/swift-markdown.git", from: "0.2.0"),
3231

3332
.package(url: "https://github.com/swiftlang/swift-syntax.git", from: "600.0.1"),
34-
35-
.package(url: "https://github.com/pointfreeco/swift-parsing", from: "0.13.0"),
3633
],
3734
targets: [
3835
// Targets are the basic building blocks of a package. A target can define a module or a test suite.
@@ -46,7 +43,8 @@ let package = Package(
4643
"LiveViewNativeStylesheet"
4744
],
4845
plugins: [
49-
.plugin(name: "BuiltinRegistryGeneratorPlugin")
46+
.plugin(name: "BuiltinRegistryGeneratorPlugin"),
47+
.plugin(name: "ModifierGeneratorPlugin"),
5048
]
5149
),
5250
.testTarget(
@@ -58,16 +56,7 @@ let package = Package(
5856
dependencies: ["LiveViewNative"]
5957
),
6058

61-
.executableTarget(
62-
name: "ModifierGenerator",
63-
dependencies: [
64-
.product(name: "ArgumentParser", package: "swift-argument-parser"),
65-
.product(name: "SwiftSyntax", package: "swift-syntax"),
66-
.product(name: "SwiftParser", package: "swift-syntax"),
67-
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
68-
]
69-
),
70-
59+
// Builtin Registry
7160
.executableTarget(
7261
name: "BuiltinRegistryGenerator",
7362
dependencies: [
@@ -79,7 +68,8 @@ let package = Package(
7968
capability: .buildTool(),
8069
dependencies: [.target(name: "BuiltinRegistryGenerator")]
8170
),
82-
71+
72+
// Tools
8373
.executableTarget(
8474
name: "DocumentationExtensionGenerator",
8575
dependencies: [.product(name: "ArgumentParser", package: "swift-argument-parser")]
@@ -106,6 +96,7 @@ let package = Package(
10696
dependencies: []
10797
),
10898

99+
// Macros
109100
.macro(
110101
name: "LiveViewNativeMacros",
111102
dependencies: [
@@ -121,30 +112,63 @@ let package = Package(
121112
]
122113
),
123114

115+
// Modifier Generator
116+
.executableTarget(
117+
name: "ModifierGenerator",
118+
dependencies: [
119+
"ASTDecodableImplementation",
120+
"SwiftSyntaxExtensions",
121+
.product(name: "ArgumentParser", package: "swift-argument-parser"),
122+
.product(name: "SwiftSyntax", package: "swift-syntax"),
123+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
124+
.product(name: "SwiftParser", package: "swift-syntax"),
125+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
126+
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
127+
]
128+
),
129+
.plugin(
130+
name: "ModifierGeneratorPlugin",
131+
capability: .buildTool(),
132+
dependencies: [.target(name: "ModifierGenerator")]
133+
),
134+
135+
// Stylesheet
136+
.target(
137+
name: "ASTDecodableImplementation",
138+
dependencies: [
139+
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
140+
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
141+
"SwiftSyntaxExtensions",
142+
]
143+
),
124144
.macro(
125145
name: "LiveViewNativeStylesheetMacros",
126146
dependencies: [
147+
"ASTDecodableImplementation",
148+
127149
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
128-
.product(name: "SwiftCompilerPlugin", package: "swift-syntax")
150+
.product(name: "SwiftCompilerPlugin", package: "swift-syntax"),
151+
"SwiftSyntaxExtensions",
129152
]
130153
),
131154
.target(
132155
name: "LiveViewNativeStylesheet",
133156
dependencies: [
134157
"LiveViewNativeStylesheetMacros",
135158
.product(name: "LiveViewNativeCore", package: "liveview-native-core"),
136-
.product(name: "Parsing", package: "swift-parsing"),
137159
]
138160
),
139161
.testTarget(
140162
name: "LiveViewNativeStylesheetTests",
141163
dependencies: ["LiveViewNativeStylesheet", "LiveViewNative"]
142164
),
143-
.testTarget(
144-
name: "LiveViewNativeStylesheetMacrosTests",
165+
166+
// Helpers
167+
.target(
168+
name: "SwiftSyntaxExtensions",
145169
dependencies: [
146-
"LiveViewNativeStylesheetMacros",
147-
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
170+
.product(name: "SwiftSyntax", package: "swift-syntax"),
171+
.product(name: "SwiftSyntaxBuilder", package: "swift-syntax"),
148172
]
149173
),
150174
]
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//
2+
// BuiltinRegistryGeneratorPlugin.swift
3+
//
4+
//
5+
// Created by Carson Katri on 4/18/23.
6+
//
7+
8+
import PackagePlugin
9+
import Foundation
10+
11+
@main
12+
struct ModifierGeneratorPlugin: BuildToolPlugin {
13+
func createBuildCommands(context: PluginContext, target: Target) async throws -> [Command] {
14+
guard let target = target as? SwiftSourceModuleTarget else { return [] }
15+
let tool = try context.tool(named: "ModifierGenerator")
16+
let output = context.pluginWorkDirectoryURL.appending(path: "GeneratedModifiers.swift")
17+
18+
// target.directoryURL.path(percentEncoded: false)
19+
let arguments: [String] = [output.path(percentEncoded: false)]
20+
21+
return [
22+
.buildCommand(
23+
displayName: tool.name,
24+
executable: tool.url,
25+
arguments: arguments,
26+
environment: ProcessInfo.processInfo.environment,
27+
inputFiles: [],
28+
outputFiles: [output]
29+
)
30+
]
31+
}
32+
}

0 commit comments

Comments
 (0)