Skip to content

Instantly share code, notes, and snippets.

@saulshanabrook
Created November 20, 2019 20:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saulshanabrook/e39a4c44e481901d13c67e8d00f7f627 to your computer and use it in GitHub Desktop.
Save saulshanabrook/e39a4c44e481901d13c67e8d00f7f627 to your computer and use it in GitHub Desktop.
Jupyter output renderers

Jupyter output renderers

Add new MIME type: application/vnd.jupyter.renderer+json;package={package_name} where {package_name} is the name (and possible version) of an NPM package, like standalone-dx or standalone-dx@^1.0.0.

You should be able to import a renderMime function from that package with this signature:

type RenderMIME = (options: {
    node: HTMLElement,
    // Call a remote function on the server that has been
    // registered
    // NOTE: We could replace this with a full open comm
    // interface instead of a more restricted RPC interface
    invokeFunction: (options: {
        name: string,
        args: JSON
    }) => Promise<JSON>,
    data: JSON
}) => {
        // Called when the output is updated with new data
        onData: (data: JSON) => void,
        // Called when the output is deleted
        onCleanup: () => void
        // NOTE: We could also extend this with notifications
        // for add/remove dom nodes if we wanna support multiple
        // output views, like in JL
};

Frontends are free to fetch and call this package however they like, either by using a version already built with them or by calling out to something like unpkg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment