@rerun-io/web-viewer
Advanced tools
Comparing version 0.17.0-alpha.104 to 0.17.0-alpha.105
export type Panel = "top" | "blueprint" | "selection" | "time"; | ||
export type PanelState = "hidden" | "collapsed" | "expanded"; | ||
export type Backend = "webgpu" | "webgl"; | ||
export type CanvasRect = { | ||
width: string; | ||
height: string; | ||
top: string; | ||
left: string; | ||
bottom: string; | ||
right: string; | ||
}; | ||
export type CanvasStyle = { | ||
canvas: CanvasRect & { | ||
position: string; | ||
transition: string; | ||
zIndex: string; | ||
}; | ||
document: { | ||
body: { | ||
overflow: string; | ||
scrollbarGutter: string; | ||
}; | ||
root: { | ||
overflow: string; | ||
scrollbarGutter: string; | ||
}; | ||
}; | ||
}; | ||
interface WebViewerOptions { | ||
@@ -39,7 +14,7 @@ manifest_url?: string; | ||
} | ||
type WithValue<Events> = { | ||
[K in keyof Events as Events[K] extends void ? never : K]: Events[K]; | ||
type EventsWithValue = { | ||
[K in keyof WebViewerEvents as WebViewerEvents[K] extends void ? never : K]: WebViewerEvents[K]; | ||
}; | ||
type WithoutValue<Events> = { | ||
[K in keyof Events as Events[K] extends void ? K : never]: Events[K]; | ||
type EventsWithoutValue = { | ||
[K in keyof WebViewerEvents as WebViewerEvents[K] extends void ? K : never]: WebViewerEvents[K]; | ||
}; | ||
@@ -63,4 +38,4 @@ type Cancel = () => void; | ||
*/ | ||
on<E extends keyof WithValue<WebViewerEvents>>(event: E, callback: (value: WithValue<WebViewerEvents>[E]) => void): Cancel; | ||
on<E extends keyof WithoutValue<WebViewerEvents>>(event: E, callback: () => void): Cancel; | ||
on<E extends keyof EventsWithValue>(event: E, callback: (value: EventsWithValue[E]) => void): Cancel; | ||
on<E extends keyof EventsWithoutValue>(event: E, callback: () => void): Cancel; | ||
/** | ||
@@ -71,4 +46,4 @@ * Register an event listener which runs only once. | ||
*/ | ||
once<E extends keyof WithValue<WebViewerEvents>>(event: E, callback: (value: WithValue<WebViewerEvents>[E]) => void): Cancel; | ||
once<E extends keyof WithoutValue<WebViewerEvents>>(event: E, callback: () => void): Cancel; | ||
once<E extends keyof EventsWithValue>(event: E, callback: (value: EventsWithValue[E]) => void): Cancel; | ||
once<E extends keyof EventsWithoutValue>(event: E, callback: () => void): Cancel; | ||
/** | ||
@@ -80,4 +55,4 @@ * Unregister an event listener. | ||
*/ | ||
off<E extends keyof WithValue<WebViewerEvents>>(event: E, callback: (value: WithValue<WebViewerEvents>[E]) => void): void; | ||
off<E extends keyof WithoutValue<WebViewerEvents>>(event: E, callback: () => void): void; | ||
off<E extends keyof EventsWithValue>(event: E, callback: (value: EventsWithValue[E]) => void): void; | ||
off<E extends keyof EventsWithoutValue>(event: E, callback: () => void): void; | ||
/** | ||
@@ -84,0 +59,0 @@ * Returns `true` if the viewer is ready to connect to data sources. |
@@ -104,3 +104,3 @@ let WebHandleConstructor = null; | ||
else { | ||
console.warn("Attempted to call `WebViewer.off` with an unregistered callback. Are you using "); | ||
console.warn("Attempted to call `WebViewer.off` with an unregistered callback. Are you passing in the same function instance?"); | ||
} | ||
@@ -283,2 +283,3 @@ } | ||
document.documentElement.classList.add(classes.hide_scrollbars); | ||
this.#dispatch_event("fullscreen", true); | ||
}); | ||
@@ -303,3 +304,2 @@ }); | ||
this.#fullscreen = true; | ||
this.#dispatch_event("fullscreen", true); | ||
}; | ||
@@ -306,0 +306,0 @@ } |
57
index.ts
@@ -41,19 +41,3 @@ import type { WebHandle } from "./re_viewer.js"; | ||
export type Backend = "webgpu" | "webgl"; | ||
export type CanvasRect = { | ||
width: string; | ||
height: string; | ||
top: string; | ||
left: string; | ||
bottom: string; | ||
right: string; | ||
}; | ||
export type CanvasStyle = { | ||
canvas: CanvasRect & { position: string; transition: string; zIndex: string }; | ||
document: { | ||
body: { overflow: string; scrollbarGutter: string }; | ||
root: { overflow: string; scrollbarGutter: string }; | ||
}; | ||
}; | ||
interface WebViewerOptions { | ||
@@ -76,2 +60,5 @@ manifest_url?: string; | ||
// This abomination is a mapped type with key filtering, and is used to split the events | ||
// into those which take no value in their callback, and those which do. | ||
// https://www.typescriptlang.org/docs/handbook/2/mapped-types.html#key-remapping-via-as | ||
type EventsWithValue = { | ||
@@ -89,10 +76,2 @@ [K in keyof WebViewerEvents as WebViewerEvents[K] extends void | ||
type WithValue<Events> = { | ||
[K in keyof Events as Events[K] extends void ? never : K]: Events[K]; | ||
}; | ||
type WithoutValue<Events> = { | ||
[K in keyof Events as Events[K] extends void ? K : never]: Events[K]; | ||
}; | ||
type Cancel = () => void; | ||
@@ -102,11 +81,6 @@ | ||
#id = randomId(); | ||
#handle: WebHandle | null = null; | ||
#canvas: HTMLCanvasElement | null = null; | ||
#state: "ready" | "starting" | "stopped" = "stopped"; | ||
#fullscreen = false; | ||
#allow_fullscreen = false; | ||
@@ -203,7 +177,7 @@ | ||
*/ | ||
on<E extends keyof WithValue<WebViewerEvents>>( | ||
on<E extends keyof EventsWithValue>( | ||
event: E, | ||
callback: (value: WithValue<WebViewerEvents>[E]) => void, | ||
callback: (value: EventsWithValue[E]) => void, | ||
): Cancel; | ||
on<E extends keyof WithoutValue<WebViewerEvents>>( | ||
on<E extends keyof EventsWithoutValue>( | ||
event: E, | ||
@@ -224,7 +198,7 @@ callback: () => void, | ||
*/ | ||
once<E extends keyof WithValue<WebViewerEvents>>( | ||
once<E extends keyof EventsWithValue>( | ||
event: E, | ||
callback: (value: WithValue<WebViewerEvents>[E]) => void, | ||
callback: (value: EventsWithValue[E]) => void, | ||
): Cancel; | ||
once<E extends keyof WithoutValue<WebViewerEvents>>( | ||
once<E extends keyof EventsWithoutValue>( | ||
event: E, | ||
@@ -246,10 +220,7 @@ callback: () => void, | ||
*/ | ||
off<E extends keyof WithValue<WebViewerEvents>>( | ||
off<E extends keyof EventsWithValue>( | ||
event: E, | ||
callback: (value: WithValue<WebViewerEvents>[E]) => void, | ||
callback: (value: EventsWithValue[E]) => void, | ||
): void; | ||
off<E extends keyof WithoutValue<WebViewerEvents>>( | ||
event: E, | ||
callback: () => void, | ||
): void; | ||
off<E extends keyof EventsWithoutValue>(event: E, callback: () => void): void; | ||
off(event: any, callback: any): void { | ||
@@ -261,3 +232,3 @@ const callbacks = this.#event_map.get(event); | ||
console.warn( | ||
"Attempted to call `WebViewer.off` with an unregistered callback. Are you using ", | ||
"Attempted to call `WebViewer.off` with an unregistered callback. Are you passing in the same function instance?", | ||
); | ||
@@ -468,2 +439,3 @@ } | ||
document.documentElement.classList.add(classes.hide_scrollbars); | ||
this.#dispatch_event("fullscreen", true); | ||
}); | ||
@@ -492,3 +464,2 @@ }); | ||
this.#fullscreen = true; | ||
this.#dispatch_event("fullscreen", true); | ||
}; | ||
@@ -495,0 +466,0 @@ } |
{ | ||
"name": "@rerun-io/web-viewer", | ||
"version": "0.17.0-alpha.104", | ||
"version": "0.17.0-alpha.105", | ||
"description": "Embed the Rerun web viewer in your app", | ||
@@ -5,0 +5,0 @@ "licenses": [ |
@@ -44,3 +44,3 @@ # Rerun web viewer | ||
The `rrd` in the snippet above should be a URL pointing to either: | ||
- A hosted `.rrd` file, such as <https://app.rerun.io/version/0.17.0-alpha.104/examples/dna.rrd> | ||
- A hosted `.rrd` file, such as <https://app.rerun.io/version/0.17.0-alpha.105/examples/dna.rrd> | ||
- A WebSocket connection to the SDK opened via the [`serve`](https://www.rerun.io/docs/reference/sdk-operating-modes#serve) API | ||
@@ -47,0 +47,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
23249488
4563