Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnEstropia committed Dec 2, 2024
1 parent e5fc781 commit 3aa94b1
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Sources/StorybookKit/Internals/machOLoader.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,38 @@ extension Book {
metadataAccessFunction,
to: Any.Type.self
)
if #available(iOS 17.0, *) {
if let previewType = anyType as? any DeveloperToolsSupport.PreviewRegistry.Type {
print("========")
print("fileID: \(previewType.fileID)")
print("line: \(previewType.line)")
print("column: \(previewType.column)")

let preview = try! previewType.makePreview()
dump(preview)

let mirror: Mirror = .init(reflecting: preview)
for child in mirror.children {
switch child.label {
case "displayName":
print("displayName: \(child.value)")

case "source":
let mirror: Mirror = .init(reflecting: child.value)
let factory = mirror.children.first!.value as! @MainActor () -> any SwiftUI.View
// let view = AnyView(factory())
print("view:")
let anyView: AnyView = MainActor.assumeIsolated(factory) as! AnyView
dump(anyView)
print("========")

default:
break
}
}
print("========")
}
}
guard let bookProviderType = anyType as? any BookProvider.Type else {
continue
}
Expand Down

0 comments on commit 3aa94b1

Please sign in to comment.