Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antoine/swift6 prep #46

Merged
merged 5 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,6 @@ let package = Package(
"StorybookKit",
]
),
]
],
swiftLanguageVersions: [.v5]
)
1 change: 1 addition & 0 deletions Sources/StorybookKit/Primitives/Book.swift
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public struct FolderBuilder {

public typealias Element = Book.Node

@MainActor
public static func buildExpression<Provider: BookProvider>(_ expression: Provider.Type) -> [FolderBuilder.Element] {
return [.page(expression.bookBody)]
}
Expand Down
1 change: 1 addition & 0 deletions Sources/StorybookKit/Primitives/BookProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import SwiftUI

@_alwaysEmitConformanceMetadata
public protocol BookProvider {
@MainActor
static var bookBody: BookPage { get }
}

Expand Down
8 changes: 4 additions & 4 deletions Sources/StorybookKit/StorybookKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,36 +24,36 @@
@_exported import SwiftUI

@freestanding(declaration)
public macro StorybookPage(

Check warning on line 27 in Sources/StorybookKit/StorybookKit.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

external macro implementation type 'StorybookMacrosPlugin.StorybookPageMacro' could not be found for macro 'StorybookPage(title:contents:)'; '/Users/runner/Library/Developer/Xcode/DerivedData/Storybook-ios-gadhxqvvbkzwzsdqmeljtdwtzzgv/Build/Products/Debug-iphonesimulator/StorybookMacrosPlugin' produced malformed response

Check warning on line 27 in Sources/StorybookKit/StorybookKit.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

external macro implementation type 'StorybookMacrosPlugin.StorybookPageMacro' could not be found for macro 'StorybookPage(title:contents:)'; '/Users/runner/Library/Developer/Xcode/DerivedData/Storybook-ios-gadhxqvvbkzwzsdqmeljtdwtzzgv/Build/Products/Debug-iphonesimulator/StorybookMacrosPlugin' produced malformed response
title: String,
@ViewBuilder contents: @escaping () -> any View
@ViewBuilder contents: @escaping @MainActor () -> any View
) = #externalMacro(
module: "StorybookMacrosPlugin",
type: "StorybookPageMacro"
)

@freestanding(declaration)
public macro StorybookPage<Target>(

Check warning on line 36 in Sources/StorybookKit/StorybookKit.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

external macro implementation type 'StorybookMacrosPlugin.StorybookPageMacro' could not be found for macro 'StorybookPage(target:contents:)'; '/Users/runner/Library/Developer/Xcode/DerivedData/Storybook-ios-gadhxqvvbkzwzsdqmeljtdwtzzgv/Build/Products/Debug-iphonesimulator/StorybookMacrosPlugin' produced malformed response

Check warning on line 36 in Sources/StorybookKit/StorybookKit.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

external macro implementation type 'StorybookMacrosPlugin.StorybookPageMacro' could not be found for macro 'StorybookPage(target:contents:)'; '/Users/runner/Library/Developer/Xcode/DerivedData/Storybook-ios-gadhxqvvbkzwzsdqmeljtdwtzzgv/Build/Products/Debug-iphonesimulator/StorybookMacrosPlugin' produced malformed response
target: Target.Type = Target.self,
@ViewBuilder contents: @escaping () -> any View
@ViewBuilder contents: @escaping @MainActor () -> any View
) = #externalMacro(
module: "StorybookMacrosPlugin",
type: "StorybookPageMacro"
)

@freestanding(expression)
public macro StorybookPreview(

Check warning on line 45 in Sources/StorybookKit/StorybookKit.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

external macro implementation type 'StorybookMacrosPlugin.StorybookPreviewMacro' could not be found for macro 'StorybookPreview(title:contents:)'; '/Users/runner/Library/Developer/Xcode/DerivedData/Storybook-ios-gadhxqvvbkzwzsdqmeljtdwtzzgv/Build/Products/Debug-iphonesimulator/StorybookMacrosPlugin' produced malformed response
title: String,
@ViewBuilder contents: @escaping () -> any View
@ViewBuilder contents: @escaping @MainActor () -> any View
) -> AnyView = #externalMacro(
module: "StorybookMacrosPlugin",
type: "StorybookPreviewMacro"
)

@freestanding(expression)
public macro StorybookPreview<Target>(

Check warning on line 54 in Sources/StorybookKit/StorybookKit.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

external macro implementation type 'StorybookMacrosPlugin.StorybookPreviewMacro' could not be found for macro 'StorybookPreview(target:contents:)'; '/Users/runner/Library/Developer/Xcode/DerivedData/Storybook-ios-gadhxqvvbkzwzsdqmeljtdwtzzgv/Build/Products/Debug-iphonesimulator/StorybookMacrosPlugin' produced malformed response
target: Target.Type = Target.self,
@ViewBuilder contents: @escaping () -> any View
@ViewBuilder contents: @escaping @MainActor () -> any View
) -> AnyView = #externalMacro(
module: "StorybookMacrosPlugin",
type: "StorybookPreviewMacro"
Expand Down
1 change: 1 addition & 0 deletions Sources/StorybookMacrosPlugin/StorybookPageMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
.init(
stringLiteral: """
enum \(enumName): BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: \(title),
Expand All @@ -69,7 +70,7 @@
title: ExprSyntax,
closure: ClosureExprSyntax
) {
var argumentsIterator = node.argumentList.makeIterator()

Check warning on line 73 in Sources/StorybookMacrosPlugin/StorybookPageMacro.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

'argumentList' is deprecated: renamed to 'arguments'
var title: ExprSyntax? = (node.genericArgumentClause?.arguments.first?.argument)
.flatMap { genericType -> TypeSyntaxProtocol? in
genericType.as(IdentifierTypeSyntax.self)
Expand All @@ -79,7 +80,7 @@

var closure: ClosureExprSyntax? = node.trailingClosure
while let argument = argumentsIterator.next()?
.as(LabeledExprSyntax.self) {

Check warning on line 83 in Sources/StorybookMacrosPlugin/StorybookPageMacro.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

'as' is deprecated: This cast will always succeed

switch argument.label?.text {

Expand Down
1 change: 1 addition & 0 deletions Sources/StorybookMacrosPlugin/StorybookPreviewMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
stringLiteral: """
{
enum \(enumName): BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: \(title),
Expand All @@ -70,7 +71,7 @@
title: ExprSyntax,
closure: ClosureExprSyntax
) {
var argumentsIterator = node.argumentList.makeIterator()

Check warning on line 74 in Sources/StorybookMacrosPlugin/StorybookPreviewMacro.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

'argumentList' is deprecated: renamed to 'arguments'
var title: ExprSyntax? = (node.genericArgumentClause?.arguments.first?.argument)
.flatMap { genericType -> TypeSyntaxProtocol? in
genericType.as(IdentifierTypeSyntax.self)
Expand All @@ -80,7 +81,7 @@

var closure: ClosureExprSyntax? = node.trailingClosure
while let argument = argumentsIterator.next()?
.as(LabeledExprSyntax.self) {

Check warning on line 84 in Sources/StorybookMacrosPlugin/StorybookPreviewMacro.swift

View workflow job for this annotation

GitHub Actions / build-storybook-kit

'as' is deprecated: This cast will always succeed

switch argument.label?.text {

Expand Down
8 changes: 8 additions & 0 deletions Sources/StorybookMacrosTests/StorybookPageTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ final class StorybookPageTests: XCTestCase {
} expansion: {
"""
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(UIView.self),
Expand Down Expand Up @@ -74,6 +75,7 @@ final class StorybookPageTests: XCTestCase {
} expansion: {
"""
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down Expand Up @@ -105,6 +107,7 @@ final class StorybookPageTests: XCTestCase {
"""
enum Namespace1 { enum Namespace2 { enum Namespace3 { class TestableView: UIView {} } } }
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(target: Namespace1.Namespace2.Namespace3.TestableView.self),
Expand Down Expand Up @@ -132,6 +135,7 @@ final class StorybookPageTests: XCTestCase {
} expansion: {
"""
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down Expand Up @@ -163,6 +167,7 @@ final class StorybookPageTests: XCTestCase {
} expansion: {
"""
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(UIView.self),
Expand Down Expand Up @@ -193,6 +198,7 @@ final class StorybookPageTests: XCTestCase {
} expansion: {
"""
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down Expand Up @@ -227,6 +233,7 @@ final class StorybookPageTests: XCTestCase {
"""
enum Namespace1 { enum Namespace2 { enum Namespace3 { class TestableView: UIView {} } } }
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(
Expand Down Expand Up @@ -258,6 +265,7 @@ final class StorybookPageTests: XCTestCase {
} expansion: {
"""
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down
8 changes: 8 additions & 0 deletions Sources/StorybookMacrosTests/StorybookPreviewTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview("Some title") {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(UIView.self),
Expand Down Expand Up @@ -85,6 +86,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down Expand Up @@ -123,6 +125,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(target: Namespace1.Namespace2.Namespace3.TestableView.self),
Expand Down Expand Up @@ -157,6 +160,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down Expand Up @@ -195,6 +199,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(UIView.self),
Expand Down Expand Up @@ -232,6 +237,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down Expand Up @@ -273,6 +279,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: _typeName(
Expand Down Expand Up @@ -311,6 +318,7 @@ final class StorybookPreviewTests: XCTestCase {
#Preview {
{
enum __macro_local_20__🤖🛠️_StorybookMagic_fMu_: BookProvider {
@MainActor
static var bookBody: BookPage {
.init(
title: "Path1.Path2.Title",
Expand Down
Loading