@rerun-io/web-viewer 0.12.0-rc.3 → 0.12.0-rc.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -41,7 +41,7 @@ viewer.stop();
41
41
  ```
42
42
 
43
43
  The `rrd` in the snippet above should be a URL pointing to either:
44
- - A hosted `.rrd` file, such as <https://app.rerun.io/version/0.12.0-rc.3/examples/dna.rrd>
44
+ - A hosted `.rrd` file, such as <https://app.rerun.io/version/0.12.0-rc.4/examples/dna.rrd>
45
45
  - A WebSocket connection to the SDK opened via the [`serve`](https://www.rerun.io/docs/reference/sdk-operating-modes#serve) API
46
46
 
47
47
  If `rrd` is not set, the viewer will display the same welcome screen as <https://app.rerun.io>.
package/index.d.ts CHANGED
@@ -3,10 +3,30 @@ declare module '@rerun-io/web-viewer' {
3
3
  /**
4
4
  * Start the viewer.
5
5
  *
6
- * @param rrd Optional URL to an `.rrd` file or a WebSocket connection to our SDK.
6
+ * @param rrd URLs to `.rrd` files or WebSocket connections to our SDK.
7
7
  * @param parent The element to attach the canvas onto.
8
8
  * */
9
- start(rrd?: string | undefined, parent?: HTMLElement | undefined): Promise<this>;
9
+ start(rrd?: string | string[] | undefined, parent?: HTMLElement | undefined): Promise<void>;
10
+ /**
11
+ * Returns `true` if the viewer is ready to connect to data sources.
12
+ */
13
+ get ready(): boolean;
14
+ /**
15
+ * Open a recording.
16
+ *
17
+ * The viewer must have been started via `WebViewer.start`.
18
+ *
19
+ * @param rrd URLs to `.rrd` files or WebSocket connections to our SDK.
20
+ */
21
+ open(rrd: string | string[]): void;
22
+ /**
23
+ * Close a recording.
24
+ *
25
+ * The viewer must have been started via `WebViewer.start`.
26
+ *
27
+ * @param rrd URLs to `.rrd` files or WebSocket connections to our SDK.
28
+ */
29
+ close(rrd: string | string[]): void;
10
30
  /**
11
31
  * Stop the viewer, freeing all associated memory.
12
32
  *
package/index.js CHANGED
@@ -28,31 +28,91 @@ export class WebViewer {
28
28
  /** @type {HTMLCanvasElement | null} */
29
29
  #canvas = null;
30
30
 
31
+ /** @type {'ready' | 'starting' | 'stopped'} */
32
+ #state = "stopped";
33
+
31
34
  /**
32
35
  * Start the viewer.
33
36
  *
34
- * @param {string} [rrd] Optional URL to an `.rrd` file or a WebSocket connection to our SDK.
37
+ * @param {string | string[]} [rrd] URLs to `.rrd` files or WebSocket connections to our SDK.
35
38
  * @param {HTMLElement} [parent] The element to attach the canvas onto.
36
- * @returns {Promise<this>}
39
+ * @returns {Promise<void>}
37
40
  */
38
41
  async start(rrd, parent = document.body) {
39
- if (this.#canvas || this.#handle) return this;
42
+ if (this.#state !== "stopped") return;
43
+ this.#state = "starting";
40
44
 
41
- const canvas = document.createElement("canvas");
42
- canvas.id = randomId();
43
- parent.append(canvas);
45
+ this.#canvas = document.createElement("canvas");
46
+ this.#canvas.id = randomId();
47
+ parent.append(this.#canvas);
44
48
 
45
49
  let WebHandle_class = await load();
46
- const handle = new WebHandle_class();
47
- await handle.start(canvas.id, rrd);
48
- if (handle.has_panicked()) {
49
- throw new Error(`Web viewer crashed: ${handle.panic_message()}`);
50
+ if (this.#state !== "starting") return;
51
+
52
+ this.#handle = new WebHandle_class();
53
+ await this.#handle.start(this.#canvas.id, undefined);
54
+ if (this.#state !== "starting") return;
55
+
56
+ if (this.#handle.has_panicked()) {
57
+ throw new Error(`Web viewer crashed: ${this.#handle.panic_message()}`);
58
+ }
59
+
60
+ if (rrd) {
61
+ this.open(rrd);
50
62
  }
51
63
 
52
- this.#canvas = canvas;
53
- this.#handle = handle;
64
+ return;
65
+ }
54
66
 
55
- return this;
67
+ /**
68
+ * Returns `true` if the viewer is ready to connect to data sources.
69
+ */
70
+ get ready() {
71
+ return this.#state === "ready";
72
+ }
73
+
74
+ /**
75
+ * Open a recording.
76
+ *
77
+ * The viewer must have been started via `WebViewer.start`.
78
+ *
79
+ * @see {WebViewer.start}
80
+ *
81
+ * @param {string | string[]} rrd URLs to `.rrd` files or WebSocket connections to our SDK.
82
+ */
83
+ open(rrd) {
84
+ if (!this.#handle) {
85
+ throw new Error(`attempted to open \`${rrd}\` in a stopped viewer`);
86
+ }
87
+ const urls = Array.isArray(rrd) ? rrd : [rrd];
88
+ for (const url of urls) {
89
+ this.#handle.add_receiver(url);
90
+ if (this.#handle.has_panicked()) {
91
+ throw new Error(`Web viewer crashed: ${this.#handle.panic_message()}`);
92
+ }
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Close a recording.
98
+ *
99
+ * The viewer must have been started via `WebViewer.start`.
100
+ *
101
+ * @see {WebViewer.start}
102
+ *
103
+ * @param {string | string[]} rrd URLs to `.rrd` files or WebSocket connections to our SDK.
104
+ */
105
+ close(rrd) {
106
+ if (!this.#handle) {
107
+ throw new Error(`attempted to close \`${rrd}\` in a stopped viewer`);
108
+ }
109
+ const urls = Array.isArray(rrd) ? rrd : [rrd];
110
+ for (const url of urls) {
111
+ this.#handle.remove_receiver(url);
112
+ if (this.#handle.has_panicked()) {
113
+ throw new Error(`Web viewer crashed: ${this.#handle.panic_message()}`);
114
+ }
115
+ }
56
116
  }
57
117
 
58
118
  /**
@@ -61,17 +121,14 @@ export class WebViewer {
61
121
  * The same viewer instance may be started multiple times.
62
122
  */
63
123
  stop() {
64
- const canvas = this.#canvas;
65
- this.#canvas = null;
66
- if (canvas) {
67
- canvas.remove();
68
- }
124
+ if (this.#state !== "stopped") return;
125
+ this.#state = "stopped";
69
126
 
70
- const handle = this.#handle;
127
+ this.#canvas?.remove();
128
+ this.#handle?.destroy();
129
+ this.#handle?.free();
130
+
131
+ this.#canvas = null;
71
132
  this.#handle = null;
72
- if (handle) {
73
- handle.destroy();
74
- handle.free();
75
- }
76
133
  }
77
134
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rerun-io/web-viewer",
3
- "version": "0.12.0-rc.3",
3
+ "version": "0.12.0-rc.4",
4
4
  "description": "Embed the Rerun web viewer in your app",
5
5
  "private": false,
6
6
  "scripts": {
package/re_viewer.d.ts CHANGED
@@ -134,4 +134,12 @@ export class WebHandle {
134
134
  * @returns {string | undefined}
135
135
  */
136
136
  panic_callstack(): string | undefined;
137
+ /**
138
+ * @param {string} url
139
+ */
140
+ add_receiver(url: string): void;
141
+ /**
142
+ * @param {string} url
143
+ */
144
+ remove_receiver(url: string): void;
137
145
  }
package/re_viewer_bg.js CHANGED
@@ -222,7 +222,7 @@ function makeMutClosure(arg0, arg1, dtor, f) {
222
222
  return real;
223
223
  }
224
224
  function __wbg_adapter_34(arg0, arg1) {
225
- wasm.wasm_bindgen__convert__closures__invoke0_mut__h8b44393dabe373c9(arg0, arg1);
225
+ wasm.wasm_bindgen__convert__closures__invoke0_mut__ha27c7e68dc7e6fec(arg0, arg1);
226
226
  }
227
227
 
228
228
  function __wbg_adapter_37(arg0, arg1) {
@@ -256,7 +256,7 @@ function __wbg_adapter_49(arg0, arg1, arg2) {
256
256
  }
257
257
 
258
258
  function __wbg_adapter_58(arg0, arg1, arg2) {
259
- wasm.wasm_bindgen__convert__closures__invoke1_mut__h4c0e725c1e378c2a(arg0, arg1, addHeapObject(arg2));
259
+ wasm.wasm_bindgen__convert__closures__invoke1_mut__hc6b86564fbbb6bb5(arg0, arg1, addHeapObject(arg2));
260
260
  }
261
261
 
262
262
  function __wbg_adapter_61(arg0, arg1, arg2) {
@@ -329,7 +329,7 @@ function getArrayU32FromWasm0(ptr, len) {
329
329
  ptr = ptr >>> 0;
330
330
  return getUint32Memory0().subarray(ptr / 4, ptr / 4 + len);
331
331
  }
332
- function __wbg_adapter_977(arg0, arg1, arg2, arg3) {
332
+ function __wbg_adapter_979(arg0, arg1, arg2, arg3) {
333
333
  wasm.wasm_bindgen__convert__closures__invoke2_mut__h7fb2e6b27a00dd95(arg0, arg1, addHeapObject(arg2), addHeapObject(arg3));
334
334
  }
335
335
 
@@ -648,8 +648,33 @@ export class WebHandle {
648
648
  wasm.__wbindgen_add_to_stack_pointer(16);
649
649
  }
650
650
  }
651
+ /**
652
+ * @param {string} url
653
+ */
654
+ add_receiver(url) {
655
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
656
+ const len0 = WASM_VECTOR_LEN;
657
+ wasm.webhandle_add_receiver(this.__wbg_ptr, ptr0, len0);
658
+ }
659
+ /**
660
+ * @param {string} url
661
+ */
662
+ remove_receiver(url) {
663
+ const ptr0 = passStringToWasm0(url, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
664
+ const len0 = WASM_VECTOR_LEN;
665
+ wasm.webhandle_remove_receiver(this.__wbg_ptr, ptr0, len0);
666
+ }
651
667
  }
652
668
 
669
+ export function __wbindgen_object_drop_ref(arg0) {
670
+ takeObject(arg0);
671
+ };
672
+
673
+ export function __wbindgen_string_new(arg0, arg1) {
674
+ const ret = getStringFromWasm0(arg0, arg1);
675
+ return addHeapObject(ret);
676
+ };
677
+
653
678
  export function __wbindgen_cb_drop(arg0) {
654
679
  const obj = takeObject(arg0).original;
655
680
  if (obj.cnt-- == 1) {
@@ -660,15 +685,6 @@ export function __wbindgen_cb_drop(arg0) {
660
685
  return ret;
661
686
  };
662
687
 
663
- export function __wbindgen_object_drop_ref(arg0) {
664
- takeObject(arg0);
665
- };
666
-
667
- export function __wbindgen_string_new(arg0, arg1) {
668
- const ret = getStringFromWasm0(arg0, arg1);
669
- return addHeapObject(ret);
670
- };
671
-
672
688
  export function __wbindgen_object_clone_ref(arg0) {
673
689
  const ret = getObject(arg0);
674
690
  return addHeapObject(ret);
@@ -715,12 +731,12 @@ export function __wbg_stack_5e4edbe5d1e14374(arg0, arg1) {
715
731
  getInt32Memory0()[arg0 / 4 + 0] = ptr1;
716
732
  };
717
733
 
718
- export function __wbg_new_799ae9c8b1bbed12() {
734
+ export function __wbg_new_395a8514ed40239d() {
719
735
  const ret = new Error();
720
736
  return addHeapObject(ret);
721
737
  };
722
738
 
723
- export function __wbg_stack_94b6645f0a650755(arg0, arg1) {
739
+ export function __wbg_stack_d537cf45a4444568(arg0, arg1) {
724
740
  const ret = getObject(arg1).stack;
725
741
  const ptr1 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
726
742
  const len1 = WASM_VECTOR_LEN;
@@ -2670,19 +2686,19 @@ export function __wbg_focus_dbcbbbb2a04c0e1f() { return handleError(function (ar
2670
2686
  getObject(arg0).focus();
2671
2687
  }, arguments) };
2672
2688
 
2673
- export function __wbg_warn_5bdaa37db713d63c(arg0, arg1) {
2689
+ export function __wbg_warn_61f8e6f5038afcb9(arg0, arg1) {
2674
2690
  console.warn(getStringFromWasm0(arg0, arg1));
2675
2691
  };
2676
2692
 
2677
- export function __wbg_info_805a92fcea68dc15(arg0, arg1) {
2693
+ export function __wbg_info_91f94e7c63d2ff55(arg0, arg1) {
2678
2694
  console.info(getStringFromWasm0(arg0, arg1));
2679
2695
  };
2680
2696
 
2681
- export function __wbg_debug_ab7cf4cd5b7653b3(arg0, arg1) {
2697
+ export function __wbg_debug_e55be755fe0c8f25(arg0, arg1) {
2682
2698
  console.debug(getStringFromWasm0(arg0, arg1));
2683
2699
  };
2684
2700
 
2685
- export function __wbg_trace_b11602bd282cb791(arg0, arg1) {
2701
+ export function __wbg_trace_111cce78168df566(arg0, arg1) {
2686
2702
  console.trace(getStringFromWasm0(arg0, arg1));
2687
2703
  };
2688
2704
 
@@ -2914,7 +2930,7 @@ export function __wbg_new_43f1b47c28813cbd(arg0, arg1) {
2914
2930
  const a = state0.a;
2915
2931
  state0.a = 0;
2916
2932
  try {
2917
- return __wbg_adapter_977(a, state0.b, arg0, arg1);
2933
+ return __wbg_adapter_979(a, state0.b, arg0, arg1);
2918
2934
  } finally {
2919
2935
  state0.a = a;
2920
2936
  }
@@ -3041,63 +3057,63 @@ export function __wbindgen_memory() {
3041
3057
  return addHeapObject(ret);
3042
3058
  };
3043
3059
 
3044
- export function __wbindgen_closure_wrapper763(arg0, arg1, arg2) {
3045
- const ret = makeMutClosure(arg0, arg1, 119, __wbg_adapter_34);
3060
+ export function __wbindgen_closure_wrapper1997(arg0, arg1, arg2) {
3061
+ const ret = makeMutClosure(arg0, arg1, 534, __wbg_adapter_34);
3046
3062
  return addHeapObject(ret);
3047
3063
  };
3048
3064
 
3049
- export function __wbindgen_closure_wrapper2637(arg0, arg1, arg2) {
3050
- const ret = makeMutClosure(arg0, arg1, 730, __wbg_adapter_37);
3065
+ export function __wbindgen_closure_wrapper2596(arg0, arg1, arg2) {
3066
+ const ret = makeMutClosure(arg0, arg1, 750, __wbg_adapter_37);
3051
3067
  return addHeapObject(ret);
3052
3068
  };
3053
3069
 
3054
- export function __wbindgen_closure_wrapper4299(arg0, arg1, arg2) {
3055
- const ret = makeMutClosure(arg0, arg1, 1255, __wbg_adapter_40);
3070
+ export function __wbindgen_closure_wrapper4259(arg0, arg1, arg2) {
3071
+ const ret = makeMutClosure(arg0, arg1, 1275, __wbg_adapter_40);
3056
3072
  return addHeapObject(ret);
3057
3073
  };
3058
3074
 
3059
- export function __wbindgen_closure_wrapper4301(arg0, arg1, arg2) {
3060
- const ret = makeMutClosure(arg0, arg1, 1255, __wbg_adapter_43);
3075
+ export function __wbindgen_closure_wrapper4261(arg0, arg1, arg2) {
3076
+ const ret = makeMutClosure(arg0, arg1, 1275, __wbg_adapter_43);
3061
3077
  return addHeapObject(ret);
3062
3078
  };
3063
3079
 
3064
- export function __wbindgen_closure_wrapper4303(arg0, arg1, arg2) {
3065
- const ret = makeMutClosure(arg0, arg1, 1255, __wbg_adapter_46);
3080
+ export function __wbindgen_closure_wrapper4263(arg0, arg1, arg2) {
3081
+ const ret = makeMutClosure(arg0, arg1, 1275, __wbg_adapter_46);
3066
3082
  return addHeapObject(ret);
3067
3083
  };
3068
3084
 
3069
- export function __wbindgen_closure_wrapper20778(arg0, arg1, arg2) {
3070
- const ret = makeMutClosure(arg0, arg1, 7098, __wbg_adapter_49);
3085
+ export function __wbindgen_closure_wrapper20739(arg0, arg1, arg2) {
3086
+ const ret = makeMutClosure(arg0, arg1, 7118, __wbg_adapter_49);
3071
3087
  return addHeapObject(ret);
3072
3088
  };
3073
3089
 
3074
- export function __wbindgen_closure_wrapper20780(arg0, arg1, arg2) {
3075
- const ret = makeMutClosure(arg0, arg1, 7098, __wbg_adapter_49);
3090
+ export function __wbindgen_closure_wrapper20741(arg0, arg1, arg2) {
3091
+ const ret = makeMutClosure(arg0, arg1, 7118, __wbg_adapter_49);
3076
3092
  return addHeapObject(ret);
3077
3093
  };
3078
3094
 
3079
- export function __wbindgen_closure_wrapper20782(arg0, arg1, arg2) {
3080
- const ret = makeMutClosure(arg0, arg1, 7098, __wbg_adapter_49);
3095
+ export function __wbindgen_closure_wrapper20743(arg0, arg1, arg2) {
3096
+ const ret = makeMutClosure(arg0, arg1, 7118, __wbg_adapter_49);
3081
3097
  return addHeapObject(ret);
3082
3098
  };
3083
3099
 
3084
- export function __wbindgen_closure_wrapper20784(arg0, arg1, arg2) {
3085
- const ret = makeMutClosure(arg0, arg1, 7098, __wbg_adapter_49);
3100
+ export function __wbindgen_closure_wrapper20745(arg0, arg1, arg2) {
3101
+ const ret = makeMutClosure(arg0, arg1, 7118, __wbg_adapter_49);
3086
3102
  return addHeapObject(ret);
3087
3103
  };
3088
3104
 
3089
- export function __wbindgen_closure_wrapper23791(arg0, arg1, arg2) {
3090
- const ret = makeMutClosure(arg0, arg1, 8618, __wbg_adapter_58);
3105
+ export function __wbindgen_closure_wrapper23852(arg0, arg1, arg2) {
3106
+ const ret = makeMutClosure(arg0, arg1, 8627, __wbg_adapter_58);
3091
3107
  return addHeapObject(ret);
3092
3108
  };
3093
3109
 
3094
- export function __wbindgen_closure_wrapper24065(arg0, arg1, arg2) {
3095
- const ret = makeMutClosure(arg0, arg1, 8676, __wbg_adapter_61);
3110
+ export function __wbindgen_closure_wrapper24032(arg0, arg1, arg2) {
3111
+ const ret = makeMutClosure(arg0, arg1, 8698, __wbg_adapter_61);
3096
3112
  return addHeapObject(ret);
3097
3113
  };
3098
3114
 
3099
- export function __wbindgen_closure_wrapper24191(arg0, arg1, arg2) {
3100
- const ret = makeMutClosure(arg0, arg1, 8713, __wbg_adapter_64);
3115
+ export function __wbindgen_closure_wrapper24158(arg0, arg1, arg2) {
3116
+ const ret = makeMutClosure(arg0, arg1, 8735, __wbg_adapter_64);
3101
3117
  return addHeapObject(ret);
3102
3118
  };
3103
3119
 
package/re_viewer_bg.wasm CHANGED
Binary file
@@ -8,6 +8,8 @@ export function webhandle_destroy(a: number): void;
8
8
  export function webhandle_has_panicked(a: number): number;
9
9
  export function webhandle_panic_message(a: number, b: number): void;
10
10
  export function webhandle_panic_callstack(a: number, b: number): void;
11
+ export function webhandle_add_receiver(a: number, b: number, c: number): void;
12
+ export function webhandle_remove_receiver(a: number, b: number, c: number): void;
11
13
  export function set_email(a: number, b: number): void;
12
14
  export function is_webgpu_build(): number;
13
15
  export function wgpu_compute_pass_set_pipeline(a: number, b: number): void;
@@ -84,14 +86,14 @@ export function pipeoptions_signal(a: number): number;
84
86
  export function __wbindgen_malloc(a: number, b: number): number;
85
87
  export function __wbindgen_realloc(a: number, b: number, c: number, d: number): number;
86
88
  export const __wbindgen_export_2: WebAssembly.Table;
87
- export function wasm_bindgen__convert__closures__invoke0_mut__h8b44393dabe373c9(a: number, b: number): void;
89
+ export function wasm_bindgen__convert__closures__invoke0_mut__ha27c7e68dc7e6fec(a: number, b: number): void;
88
90
  export function _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h4b1e59d19e751877(a: number, b: number): void;
89
91
  export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h495e021177c053ee(a: number, b: number, c: number): void;
90
92
  export function _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h8fa267ecc1eb02a4(a: number, b: number): void;
91
93
  export function __wbindgen_add_to_stack_pointer(a: number): number;
92
94
  export function _dyn_core__ops__function__FnMut_____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h49d90045e5200b5e(a: number, b: number, c: number): void;
93
95
  export function wasm_bindgen__convert__closures__invoke1_mut__h5c5582a4f18faa87(a: number, b: number, c: number): void;
94
- export function wasm_bindgen__convert__closures__invoke1_mut__h4c0e725c1e378c2a(a: number, b: number, c: number): void;
96
+ export function wasm_bindgen__convert__closures__invoke1_mut__hc6b86564fbbb6bb5(a: number, b: number, c: number): void;
95
97
  export function wasm_bindgen__convert__closures__invoke1_mut__h8f179b773c7ba316(a: number, b: number, c: number): void;
96
98
  export function _dyn_core__ops__function__FnMut__A____Output___R_as_wasm_bindgen__closure__WasmClosure___describe__invoke__h83ad0401821b73ca(a: number, b: number, c: number): void;
97
99
  export function __wbindgen_free(a: number, b: number, c: number): void;