Skip to content

Conversation

@lazarusA
Copy link
Collaborator

No description provided.

@asinghvi17
Copy link
Contributor

hmm...DV might need some updates like the ClientOnly thing if we are switching Bonito docs over. Same reason WGLMakie fails.

@SimonDanisch
Copy link
Owner

SimonDanisch commented Apr 4, 2025

A few things that almost worked, but ended up getting incorrectly escaped randomly:

app = App(scatter(rand(Point3f, 100));

function app_to_bin(session, app)
    dom = Bonito.session_dom(session, app)
    return Bonito.serialize_binary(session, Bonito.SerializedNode(session, dom))
end

open("test.html", "w") do io
    session = Session(Bonito.NoConnection(); asset_server=Bonito.NoServer())
    app_bin = app_to_bin(session, app)
    write("app.bin", app_bin)
    div_id = string(hash(app_bin))
    println(io, ":::raw")
    println(io, DOM.div(id=div_id))
    println(io, "<script>")
    println(io, """
        if (typeof document !== "undefined") {
            const script = document.createElement("script");
            script.src = "./bonito/Bonito.bundled.js";
            script.type = "module";
            script.onload = () => {
                Bonito.fetch_binary("./bonito/app.bin").then(bin_messages=>{
                    const node = Bonito.decode_binary(bin_messages, $(session.compression_enabled));
                    console.log(node);
                    const parent = document.getElementById($(div_id));
                    parent.appendChild(node);
                })
            }
            document.body.appendChild(script);
        }
    """)
    println(io, "</script>")
    println(io, ":::")
end


open("test.html", "w") do io
    ass = Bonito.AssetFolder("./dev/Makie/docs/build", "./dev/Makie/docs/build")
    session = Session(Bonito.NoConnection(); asset_server=ass)
    println(io, ":::raw")
    Bonito.show_html(io, app; parent=session)
    println(io, ":::")
end

I just pasted the output of those test.html into .documenter/index.md and run npm build:docs, and moved app.bin and Bonito.bundled.js into final_site/bonito/*

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.

4 participants