Skip to content

Add renderMethodReady() using postMessage().#15

Open
BigBlueHat wants to merge 2 commits into
mainfrom
render-ready
Open

Add renderMethodReady() using postMessage().#15
BigBlueHat wants to merge 2 commits into
mainfrom
render-ready

Conversation

@BigBlueHat
Copy link
Copy Markdown
Collaborator

The implementation uses an object passed to renderMethodReady(). It currently supports
values of {ready: true} or {error: {message: ...}}. Obviously additional data could
be passed through on that object making this a risk if the renderer is not meant to know
of the results or if the JS in the sandbox could surface JS (perhaps embedded in an SVG
or PDF) if that were sent back through the postMessage(). So...we should proceed with
caution.

The implementation uses an object passed to `renderMethodReady()`. It currently supports
values of `{ready: true}` or `{error: {message: ...}}`. Obviously additional data could
be passed through on that object making this a risk if the renderer is not meant to know
of the results or if the JS in the sandbox could surface JS (perhaps embedded in an SVG
or PDF) if that were sent back through the `postMessage()`. So...we should proceed with
caution.
It is now possible to supply an `application/pdf` value to the parent page (for better or worse)
via `renderMethodReady({ready: true, pdf: ...data URL of application/pdf...})`.
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented May 19, 2026

Deploying vc-viewer with  Cloudflare Pages  Cloudflare Pages

Latest commit: 62a35f6
Status: ✅  Deploy successful!
Preview URL: https://5feacd84.vc-viewer.pages.dev
Branch Preview URL: https://render-ready.vc-viewer.pages.dev

View logs

Comment thread viewers/html.js
Comment on lines +54 to +57
window.renderMethodReady = function(resp) {
portPromise.then(port => port.postMessage(
!resp.error ? resp : {error: {message: resp.error.message}}));
};
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we'll want a different name than renderMethodReady if we're going to pass other things -- or at least, we don't want to have both {ready: true} and renderMethodReady as the names, it seems redundant. Maybe it's the {ready: true} that should change -- and passing any object at all is optional.

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.

2 participants