-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add integration for the Blocks Editor #92
Conversation
Thanks for the PR. We try to make playground as generic as possible. It would be great if you can design an interface that is not tied to the blocks editor. There are several options:
|
Sounds good to me. We updated the PR to make this concept available for other third-party applications with similar use cases. I still think it makes sense to (at least initially) include a cross-origin whitelist to minimize the surface area of possible vulnerabilities, especially once Motoko Playground includes wallet-related features (e.g. #46). The updated implementation allows cross-window access from The system also requires Does this seem like a reasonable compromise to preserve the original level of security while making the system more general? Thanks for the alternate suggestions. We initially explored using the sharing / tag feature for loading projects; this integration will provide a significant UX improvement for our particular use case (and hopefully for other projects as well). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly LG.
src/App.tsx
Outdated
const hasUrlParams = !!( | ||
urlParams.get("git") || | ||
urlParams.get("tag") || | ||
urlParams.get("editor") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe post
? I think this is similar to the post message.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure; I switched to editor
to post
in the latest commit. The value of this query parameter corresponds to a unique ID defined by the external application in order to distinguish from other message sources (such as HMR).
return; | ||
} | ||
|
||
// Validate and parse integration message |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth documenting the format and protocol being used here, and how to call this from the client,
so that other apps can use it. Seems you are prepending a message before the JSON, and reply the ack number back to the client.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a section to the Readme. Is this what you were imagining? I'll also do another documentation pass once the protocol has been fully worked out.
2a9af8a
to
9faddf7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Awesome, thank you! Looking forward to seeing this in production. |
Deployed |
Thank you! The integration works as expected. |
This PR adds a lightweight integration for building and deploying canisters from the Blocks Editor.
When the
integration=blocks
query parameter is present, Motoko Playground will listen for serialized JSON messages fromhttp://localhost:*
orhttps://blocks-editor.github.io/*
parent windows. This makes it possible for Blocks to preload the workplace automatically (rather than copying/pasting everything and clicking the "Deploy" button).@chenyan-dfinity, does this look good to merge? We also updated the
package-set.dhall
upstream URL and removed a deprecated CLI flag indfx start
in order to get the project working with the latest DFX version. Let us know if you think it would be worth splitting these into a separate PR or anything like that.Cheers!