Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
5ef6674
Add EditorService
kean Nov 20, 2025
e60b72d
Remove editorAssetsEndpoint parameter from EditorConfiguration
kean Nov 20, 2025
0d7305f
Move assets management to EditorService
kean Nov 20, 2025
b67f3b2
Add logging
kean Nov 20, 2025
be494ff
Add a way to clear loaded assets
kean Nov 20, 2025
b8b92ae
Inject manifest directly without EditorAssetsProvider
kean Nov 20, 2025
d85b7e9
Simplify CachedAssetSchemeHandler
kean Nov 20, 2025
e1ac3a9
Move private methods below
kean Nov 20, 2025
463bc51
Add manifest verification
kean Nov 20, 2025
4746e07
Make refresh non-throwing
kean Nov 20, 2025
5fb910a
Add State file as an indicator where the request finished or not
kean Nov 20, 2025
6ff7728
Fix build errors
kean Nov 20, 2025
a55b1a9
Remove EditorAssetsManifest
kean Nov 20, 2025
82d7dd3
Fix build errors
kean Nov 20, 2025
5b27865
Add shared EditorService instances
kean Nov 20, 2025
e77b8e6
Cleanup
kean Nov 20, 2025
28f03b0
Do not refresh too often
kean Nov 20, 2025
daf5106
Use Application directory instead of Documents
kean Nov 21, 2025
8073026
Make logging a cross-cutting concern
kean Nov 21, 2025
39b4200
Cleanup
kean Nov 21, 2025
ad776c6
Replace safeFilename with sha1
kean Nov 21, 2025
9e4a8de
Cleanup
kean Nov 21, 2025
dac7dc6
Trigger refresh automatically in the background after teh editor is l…
kean Nov 21, 2025
3dde90c
Fix typos
kean Nov 21, 2025
2965a20
Add performance tracking for dependencies
kean Nov 21, 2025
763b0ff
Simlify warmup for editor
kean Nov 21, 2025
05a0ac2
Make dependencies func non-throwing
kean Nov 21, 2025
d245387
Fix typos in EditorManifestTests
kean Nov 21, 2025
fdeae8b
Add missing startEditorSetup call
kean Nov 21, 2025
3c0c532
Swift to Application Support directory
kean Nov 21, 2025
0405760
Add EditorSeviceTests
kean Nov 21, 2025
503da92
Add loadsSettingsWhenAssetFails
kean Nov 21, 2025
8fd121f
Simplify fetchAssets
kean Nov 21, 2025
2db64e6
Add upgradesManifestOnVersionChange
kean Nov 21, 2025
063b102
Refactor tests
kean Nov 21, 2025
ac14d11
Simplify getCachedAsset
kean Nov 21, 2025
cae905c
Add assertion to check that the assets are actually available
kean Nov 21, 2025
378eccc
Cache processed manifest (takes ~100ms)
kean Nov 21, 2025
2325b3b
Add cleanupOrphanedAssets
kean Nov 21, 2025
bff54bd
Fix concurrency warnings
kean Nov 21, 2025
8ddface
Revert createBundledConfiguration change
kean Nov 27, 2025
7a51bf7
Restore EditorAssetsProvider and revert manifest injection changes
kean Nov 28, 2025
7f0ddd0
Fix LogLevel references to use EditorLogLevel
kean Nov 28, 2025
1613171
Update tests
kean Dec 1, 2025
1a35a1b
Add more unit tests
kean Dec 1, 2025
25fdafb
Remove empty file
kean Dec 2, 2025
40eff71
Revert the preview change
kean Dec 2, 2025
1b09406
Restore editorAssetsEndpoint parameter
kean Dec 2, 2025
680242d
Remove log for local files
kean Dec 2, 2025
22ff2c8
Clean up the merge mess
jkmassel Dec 2, 2025
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
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ let package = Package(
path: "ios/Tests",
exclude: [],
resources: [
.copy("GutenbergKitTests/Resources/manifest-test-case-1.json")
.process("GutenbergKitTests/Resources/")
]
),
]
Expand Down
25 changes: 25 additions & 0 deletions ios/Demo-iOS/Sources/GutenbergApp.swift
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import SwiftUI
import OSLog
import GutenbergKit

@main
struct GutenbergApp: App {
init() {
// Configure logger for GutenbergKit
EditorLogger.shared = OSLogEditorLogger()
EditorLogger.logLevel = .debug
}

var body: some Scene {
WindowGroup {
NavigationStack {
Expand All @@ -12,3 +20,20 @@ struct GutenbergApp: App {
.environmentObject(AuthenticationManager())
}
}

struct OSLogEditorLogger: GutenbergKit.EditorLogging {
private let logger: Logger

init(subsystem: String = "com.gutenbergkit.demo", category: String = "GutenbergKit") {
self.logger = Logger(subsystem: subsystem, category: category)
}

func log(_ level: GutenbergKit.EditorLogLevel, _ message: String) {
switch level {
case .debug: logger.debug("\(message)")
case .info: logger.info("\(message)")
case .warn: logger.warning("\(message)")
case .error: logger.error("\(message)")
}
}
}
16 changes: 10 additions & 6 deletions ios/Demo-iOS/Sources/Views/AppRootView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,13 @@ struct AppRootView: View {
}
.onChange(of: self.selectedConfiguration) { oldValue, newValue in
switch newValue {
case .bundledEditor: activeEditorConfiguration = createBundledConfiguration()
case .editorConfiguration(let config): self.loadEditorConfiguration(for: config)
case .none: self.activeEditorConfiguration = nil
case .bundledEditor:
let config = createBundledConfiguration()
activeEditorConfiguration = config
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Likely worthwhile consistently using self in this switch.

Suggested change
activeEditorConfiguration = config
self.activeEditorConfiguration = config

case .editorConfiguration(let config):
self.loadEditorConfiguration(for: config)
case .none:
self.activeEditorConfiguration = nil
}
}
}
Expand Down Expand Up @@ -85,10 +89,10 @@ struct AppRootView: View {

if let baseURL = URL(string: config.siteApiRoot) {
let service = EditorService(
siteID: config.siteUrl,
baseURL: baseURL,
authHeader: config.authHeader
siteURL: config.siteUrl,
networkSession: URLSession.shared
)

do {
try await service.setup(&updatedConfiguration)
} catch {
Expand Down
40 changes: 40 additions & 0 deletions ios/Demo-iOS/Sources/Views/DebugSettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ struct DebugSettingsView: View {
@Environment(\.dismiss) private var dismiss
@State private var showingClearCacheAlert = false
@State private var cacheCleared = false
@State private var showingClearEditorDataAlert = false
@State private var editorDataCleared = false

var body: some View {
List {
Expand All @@ -26,6 +28,25 @@ struct DebugSettingsView: View {
} footer: {
Text("Clears all cached preview images. Previews will be re-rendered on next view.")
}

Section {
Button(role: .destructive) {
showingClearEditorDataAlert = true
} label: {
HStack {
Text("Clear Editor Data")
Spacer()
if editorDataCleared {
Image(systemName: "checkmark.circle.fill")
.foregroundStyle(.green)
}
}
}
} header: {
Text("Editor Service")
} footer: {
Text("Deletes all cached editor settings and assets. The editor will re-download everything on next launch.")
}
}
.navigationTitle("Debug Settings")
.navigationBarTitleDisplayMode(.inline)
Expand All @@ -44,6 +65,14 @@ struct DebugSettingsView: View {
} message: {
Text("This will delete all cached preview images. They will be regenerated when needed.")
}
.alert("Clear Editor Data?", isPresented: $showingClearEditorDataAlert) {
Button("Clear", role: .destructive) {
clearEditorData()
}
Button("Cancel", role: .cancel) {}
} message: {
Text("This will delete all cached editor settings and assets. The editor will re-download everything on next launch.")
}
}

private func clearCache() {
Expand All @@ -56,6 +85,17 @@ struct DebugSettingsView: View {
cacheCleared = false
}
}

private func clearEditorData() {
Task {
try? EditorViewController.deleteAllData()
editorDataCleared = true

// Reset the checkmark after 2 seconds
try? await Task.sleep(nanoseconds: 2_000_000_000)
editorDataCleared = false
}
}
}

#Preview {
Expand Down
6 changes: 1 addition & 5 deletions ios/Demo-iOS/Sources/Views/EditorView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ private struct _EditorView: UIViewControllerRepresentable {

init(
configuration: EditorConfiguration,
viewModel: EditorViewModel,
viewModel: EditorViewModel
) {
self.configuration = configuration
self.viewModel = viewModel
Expand Down Expand Up @@ -159,10 +159,6 @@ private struct _EditorView: UIViewControllerRepresentable {
// No-op for demo
}

func editor(_ viewController: EditorViewController, didLogMessage message: String, level: LogLevel) {
print("[\(level)]: \(message)")
}

func editor(_ viewController: EditorViewController, didLogException error: GutenbergJSException) {
// No-op for demo
}
Expand Down
108 changes: 0 additions & 108 deletions ios/Sources/GutenbergKit/Sources/Cache/CachedAssetSchemeHandler.swift

This file was deleted.

Loading