Skip to content
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 a new javascript API for submitting an RRD that is stored directly as bytes #6189

Merged
merged 9 commits into from
May 2, 2024

Conversation

jleibs
Copy link
Member

@jleibs jleibs commented May 2, 2024

What

This API means that an RRD file transmitted over a side-channel such as gradio can be injected directly into the viewer instead of needing to point the viewer at a separate url.

Tested with an adhoc svelte component:

<script lang="ts">
    import { WebViewer, LogChannel } from "@rerun-io/web-viewer";

    import { onMount } from "svelte";

    let rr: WebViewer;
    let ref: HTMLDivElement;
    let channel: LogChannel;

    onMount(() => {
        rr = new WebViewer();
        rr.start(undefined, ref).then(() => {
            channel = rr.open_channel("gradio");
        });

        return () => {
            channel.close();
            rr.stop();
        };
    });

    let data1 = '...'
    let data2 = '...'
    let data3 = '...'

    function push(data: string) {
        var intermediate = atob(data);
        var buff = new Uint8Array(intermediate.length);
        for (var i = 0; i < intermediate.length; i++) {
            {
                buff[i] = intermediate.charCodeAt(i);
            }
        }
        channel.send_rrd(buff);
    }

</script>

<div class="container">
    <button on:click={() => push(data1)}>
    Data1
    </button>
    <button on:click={() => push(data2)}>
    Data2
    </button>
    <button on:click={() => push(data3)}>
    Data3
    </button>
</div>

<div class="viewer" bind:this={ref} />

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG
  • If applicable, add a new check to the release checklist!

To run all checks from main, comment on the PR with @rerun-bot full-check.

@jleibs jleibs added notebook Jupyter notebooks etc include in changelog labels May 2, 2024
@jleibs jleibs marked this pull request as ready for review May 2, 2024 00:21
rerun_js/web-viewer/index.js Outdated Show resolved Hide resolved
@nikolausWest
Copy link
Member

Reminder to update any relevant js package docs + our Rerun on web docs on the main docs site as part of this stream of (very awesome) work

@jleibs jleibs added the 🪵 Log & send APIs Affects the user-facing API for all languages label May 2, 2024
@jleibs jleibs merged commit 01efdf5 into main May 2, 2024
34 checks passed
@jleibs jleibs deleted the jleibs/js_bytes branch May 2, 2024 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
include in changelog 🪵 Log & send APIs Affects the user-facing API for all languages notebook Jupyter notebooks etc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants