Bonito.jl icon indicating copy to clipboard operation
Bonito.jl copied to clipboard

vitepress

Open lazarusA opened this issue 8 months ago • 2 comments

lazarusA avatar Mar 15 '25 06:03 lazarusA

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

asinghvi17 avatar Mar 22 '25 23:03 asinghvi17

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/*

SimonDanisch avatar Apr 04 '25 16:04 SimonDanisch