Skip to content

Integrate GutenbergKit remote editor asset caching #24639

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

Draft
wants to merge 5 commits into
base: trunk
Choose a base branch
from

Conversation

crazytonyli
Copy link
Contributor

@crazytonyli crazytonyli commented Jun 27, 2025

Description

Close CMM-509. This PR uses wordpress-mobile/GutenbergKit#148.

To try it out locally:

  1. Checkout Support caching remote assets GutenbergKit#148 in your local GutenbergKit repo.
  2. Update the Package.swift to reference your local GutenbergKit repo.
  3. Build & run to launch the Jetpack app.
  4. Log in with your a8c account and open a post.

Testing instructions

@crazytonyli crazytonyli requested a review from dcalhoun June 27, 2025 03:02
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ Modules/Package.swift was changed without updating its corresponding Package.resolved. Please resolve the Swift packages as appropriate to your project setup (e.g. in Xcode or by running swift package resolve).
1 Message
📖 This PR is still a Draft: some checks will be skipped.

Generated by 🚫 Danger

GutenbergKit.EditorViewController.warmup()
GutenbergKit.EditorViewController.warmup(
configuration: blog.flatMap(EditorConfiguration.init(blog:)) ?? .default
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can move/copy this code to "warm up" the GBK editor after switching sites, which pre-fetches the remote editor assets.

editorAssetsEndpoint.appendPathComponent("editor-assets")
self.editorAssetsEndpoint = editorAssetsEndpoint
}
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This if statement is new. The rest are moved from the view controller initializer above.

siteApiNamespace.append("sites/\(siteId)")
} else {
siteApiNamespace.append("sites/\(siteDomain)")
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I lied. This if statement is also changed. The siteApiNamespace should not be ["sites/<site-id>", "sites/<mysite.wordpress.com>"], right? It should contain either the id or the domain?

Here is the original code, for easier review:

        if isWPComSite {
            if let siteId {
                siteApiNamespace.append("sites/\(siteId)")
            }
            siteApiNamespace.append("sites/\(siteDomain)")
        }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh wait... I see the code comment now. I'll revert this change.

Copy link
Member

Choose a reason for hiding this comment

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

Correct, we need to retain this. Third-party blocks can utilize either namespace. So, we need both for proper matching, otherwise we may mistakenly add a duplicative namespace to a path already containing a namespace.

Copy link

@dcalhoun dcalhoun changed the title Integrate GutenbergKit remote editor Integrate GutenbergKit remote editor asset caching Jun 27, 2025
Copy link
Member

@dcalhoun dcalhoun left a comment

Choose a reason for hiding this comment

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

This works well from my testing. 🎉 Aside from the noted GBK release requirement, this seems good to merge.

Comment on lines +57 to +58
//.package(url: "https://github.com/wordpress-mobile/GutenbergKit", from: "0.3.0"),
.package(path: "../../../GutenbergKit"),
Copy link
Member

Choose a reason for hiding this comment

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

Friendly note: we need to replace the local path with a new GBK release before merging this PR.

FYI I have a open wordpress-mobile/GutenbergKit#151 for documenting and automating the GBK release process.

siteApiNamespace.append("sites/\(siteId)")
} else {
siteApiNamespace.append("sites/\(siteDomain)")
}
Copy link
Member

Choose a reason for hiding this comment

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

Correct, we need to retain this. Third-party blocks can utilize either namespace. So, we need both for proper matching, otherwise we may mistakenly add a duplicative namespace to a path already containing a namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants