@perspective-dev/viewer-charts 4.3.0
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/LICENSE.md +193 -0
- package/dist/cdn/perspective-viewer-charts.js +3 -0
- package/dist/cdn/perspective-viewer-charts.js.map +7 -0
- package/dist/esm/axis/axis-primitives.d.ts +24 -0
- package/dist/esm/axis/bar-axis.d.ts +51 -0
- package/dist/esm/axis/canvas.d.ts +24 -0
- package/dist/esm/axis/categorical-axis-core.d.ts +42 -0
- package/dist/esm/axis/categorical-axis.d.ts +27 -0
- package/dist/esm/axis/facet-chrome.d.ts +13 -0
- package/dist/esm/axis/label-geometry.d.ts +41 -0
- package/dist/esm/axis/legend.d.ts +44 -0
- package/dist/esm/axis/numeric-axis.d.ts +20 -0
- package/dist/esm/charts/candlestick/candlestick-build.d.ts +129 -0
- package/dist/esm/charts/candlestick/candlestick-interact.d.ts +10 -0
- package/dist/esm/charts/candlestick/candlestick-render.d.ts +24 -0
- package/dist/esm/charts/candlestick/candlestick.d.ts +144 -0
- package/dist/esm/charts/candlestick/glyphs/draw-candlesticks.d.ts +36 -0
- package/dist/esm/charts/candlestick/glyphs/draw-ohlc.d.ts +33 -0
- package/dist/esm/charts/canvas-types.d.ts +15 -0
- package/dist/esm/charts/cartesian/cartesian-build.d.ts +14 -0
- package/dist/esm/charts/cartesian/cartesian-interact.d.ts +20 -0
- package/dist/esm/charts/cartesian/cartesian-render.d.ts +26 -0
- package/dist/esm/charts/cartesian/cartesian.d.ts +239 -0
- package/dist/esm/charts/cartesian/glyph.d.ts +53 -0
- package/dist/esm/charts/cartesian/glyphs/density.d.ts +142 -0
- package/dist/esm/charts/cartesian/glyphs/lines.d.ts +23 -0
- package/dist/esm/charts/cartesian/glyphs/points.d.ts +24 -0
- package/dist/esm/charts/cartesian/label-interner.d.ts +21 -0
- package/dist/esm/charts/cartesian/tooltip-lines.d.ts +11 -0
- package/dist/esm/charts/chart-base.d.ts +402 -0
- package/dist/esm/charts/chart.d.ts +338 -0
- package/dist/esm/charts/common/band-layout.d.ts +32 -0
- package/dist/esm/charts/common/categorical-y-chart.d.ts +53 -0
- package/dist/esm/charts/common/category-axis-resolver.d.ts +90 -0
- package/dist/esm/charts/common/chrome-cache.d.ts +18 -0
- package/dist/esm/charts/common/draw-tooltip-box.d.ts +9 -0
- package/dist/esm/charts/common/leaf-color.d.ts +33 -0
- package/dist/esm/charts/common/node-store.d.ts +81 -0
- package/dist/esm/charts/common/tree-chart.d.ts +48 -0
- package/dist/esm/charts/common/tree-chrome.d.ts +31 -0
- package/dist/esm/charts/common/tree-data.d.ts +54 -0
- package/dist/esm/charts/common/visible-extent.d.ts +51 -0
- package/dist/esm/charts/heatmap/heatmap-build.d.ts +86 -0
- package/dist/esm/charts/heatmap/heatmap-interact.d.ts +19 -0
- package/dist/esm/charts/heatmap/heatmap-render.d.ts +19 -0
- package/dist/esm/charts/heatmap/heatmap-y-axis.d.ts +46 -0
- package/dist/esm/charts/heatmap/heatmap.d.ts +117 -0
- package/dist/esm/charts/map/map.d.ts +67 -0
- package/dist/esm/charts/registry.d.ts +14 -0
- package/dist/esm/charts/series/glyphs/draw-areas.d.ts +30 -0
- package/dist/esm/charts/series/glyphs/draw-bars.d.ts +15 -0
- package/dist/esm/charts/series/glyphs/draw-lines.d.ts +34 -0
- package/dist/esm/charts/series/glyphs/draw-scatter.d.ts +33 -0
- package/dist/esm/charts/series/series-build.d.ts +228 -0
- package/dist/esm/charts/series/series-interact.d.ts +35 -0
- package/dist/esm/charts/series/series-render.d.ts +41 -0
- package/dist/esm/charts/series/series-type.d.ts +49 -0
- package/dist/esm/charts/series/series.d.ts +317 -0
- package/dist/esm/charts/sunburst/sunburst-interact.d.ts +7 -0
- package/dist/esm/charts/sunburst/sunburst-layout.d.ts +33 -0
- package/dist/esm/charts/sunburst/sunburst-render.d.ts +22 -0
- package/dist/esm/charts/sunburst/sunburst.d.ts +85 -0
- package/dist/esm/charts/treemap/treemap-interact.d.ts +12 -0
- package/dist/esm/charts/treemap/treemap-layout.d.ts +28 -0
- package/dist/esm/charts/treemap/treemap-render.d.ts +18 -0
- package/dist/esm/charts/treemap/treemap.d.ts +74 -0
- package/dist/esm/config.d.ts +27 -0
- package/dist/esm/data/lazy-row.d.ts +32 -0
- package/dist/esm/data/split-groups.d.ts +20 -0
- package/dist/esm/data/view-reader.d.ts +35 -0
- package/dist/esm/event-detail.d.ts +28 -0
- package/dist/esm/index.d.ts +3 -0
- package/dist/esm/interaction/hit-test.d.ts +30 -0
- package/dist/esm/interaction/host-sink-dom.d.ts +19 -0
- package/dist/esm/interaction/host-sink-message.d.ts +46 -0
- package/dist/esm/interaction/lazy-tooltip.d.ts +61 -0
- package/dist/esm/interaction/raw-event-forwarder.d.ts +27 -0
- package/dist/esm/interaction/spatial-grid.d.ts +15 -0
- package/dist/esm/interaction/tooltip-controller.d.ts +193 -0
- package/dist/esm/interaction/zoom-controller.d.ts +106 -0
- package/dist/esm/interaction/zoom-router.d.ts +48 -0
- package/dist/esm/layout/facet-grid.d.ts +126 -0
- package/dist/esm/layout/plot-layout.d.ts +104 -0
- package/dist/esm/layout/ticks.d.ts +17 -0
- package/dist/esm/map/mercator.d.ts +102 -0
- package/dist/esm/map/tile-cache.d.ts +38 -0
- package/dist/esm/map/tile-layer.d.ts +66 -0
- package/dist/esm/map/tile-loader.d.ts +52 -0
- package/dist/esm/map/tile-source.d.ts +66 -0
- package/dist/esm/perspective-viewer-charts.js +3 -0
- package/dist/esm/perspective-viewer-charts.js.map +7 -0
- package/dist/esm/plugin/charts.d.ts +40 -0
- package/dist/esm/plugin/plugin.d.ts +95 -0
- package/dist/esm/render/scheduler.d.ts +41 -0
- package/dist/esm/theme/gradient.d.ts +48 -0
- package/dist/esm/theme/palette.d.ts +13 -0
- package/dist/esm/theme/theme-snapshot.d.ts +7 -0
- package/dist/esm/theme/theme.d.ts +53 -0
- package/dist/esm/transport/protocol.d.ts +430 -0
- package/dist/esm/transport/renderer-transport.d.ts +201 -0
- package/dist/esm/utils/css.d.ts +1 -0
- package/dist/esm/utils/font-snapshot.d.ts +50 -0
- package/dist/esm/webgl/buffer-pool.d.ts +62 -0
- package/dist/esm/webgl/context-manager.d.ts +184 -0
- package/dist/esm/webgl/gradient-texture.d.ts +17 -0
- package/dist/esm/webgl/instanced-attrs.d.ts +44 -0
- package/dist/esm/webgl/plot-frame.d.ts +39 -0
- package/dist/esm/webgl/program-cache.d.ts +13 -0
- package/dist/esm/webgl/shader-manifest.d.ts +53 -0
- package/dist/esm/webgl/shader-registry.d.ts +22 -0
- package/dist/esm/worker/boot.d.ts +0 -0
- package/dist/esm/worker/dispatch.d.ts +9 -0
- package/dist/esm/worker/font-loader.d.ts +2 -0
- package/dist/esm/worker/renderer.worker.d.ts +115 -0
- package/dist/esm/worker/session-host.d.ts +26 -0
- package/package.json +47 -0
- package/src/css/perspective-viewer-charts.css +95 -0
- package/src/ts/axis/axis-primitives.ts +125 -0
- package/src/ts/axis/bar-axis.ts +345 -0
- package/src/ts/axis/canvas.ts +64 -0
- package/src/ts/axis/categorical-axis-core.ts +125 -0
- package/src/ts/axis/categorical-axis.ts +716 -0
- package/src/ts/axis/facet-chrome.ts +42 -0
- package/src/ts/axis/label-geometry.ts +188 -0
- package/src/ts/axis/legend.ts +218 -0
- package/src/ts/axis/numeric-axis.ts +353 -0
- package/src/ts/charts/candlestick/candlestick-build.ts +516 -0
- package/src/ts/charts/candlestick/candlestick-interact.ts +256 -0
- package/src/ts/charts/candlestick/candlestick-render.ts +387 -0
- package/src/ts/charts/candlestick/candlestick.ts +367 -0
- package/src/ts/charts/candlestick/glyphs/draw-candlesticks.ts +432 -0
- package/src/ts/charts/candlestick/glyphs/draw-ohlc.ts +317 -0
- package/src/ts/charts/canvas-types.ts +30 -0
- package/src/ts/charts/cartesian/cartesian-build.ts +616 -0
- package/src/ts/charts/cartesian/cartesian-interact.ts +355 -0
- package/src/ts/charts/cartesian/cartesian-render.ts +948 -0
- package/src/ts/charts/cartesian/cartesian.ts +469 -0
- package/src/ts/charts/cartesian/glyph.ts +81 -0
- package/src/ts/charts/cartesian/glyphs/density.ts +1263 -0
- package/src/ts/charts/cartesian/glyphs/lines.ts +320 -0
- package/src/ts/charts/cartesian/glyphs/points.ts +239 -0
- package/src/ts/charts/cartesian/label-interner.ts +56 -0
- package/src/ts/charts/cartesian/tooltip-lines.ts +80 -0
- package/src/ts/charts/chart-base.ts +840 -0
- package/src/ts/charts/chart.ts +427 -0
- package/src/ts/charts/common/band-layout.ts +63 -0
- package/src/ts/charts/common/categorical-y-chart.ts +81 -0
- package/src/ts/charts/common/category-axis-resolver.ts +314 -0
- package/src/ts/charts/common/chrome-cache.ts +79 -0
- package/src/ts/charts/common/draw-tooltip-box.ts +84 -0
- package/src/ts/charts/common/leaf-color.ts +92 -0
- package/src/ts/charts/common/node-store.ts +235 -0
- package/src/ts/charts/common/tree-chart.ts +76 -0
- package/src/ts/charts/common/tree-chrome.ts +123 -0
- package/src/ts/charts/common/tree-data.ts +623 -0
- package/src/ts/charts/common/visible-extent.ts +112 -0
- package/src/ts/charts/heatmap/heatmap-build.ts +426 -0
- package/src/ts/charts/heatmap/heatmap-interact.ts +274 -0
- package/src/ts/charts/heatmap/heatmap-render.ts +815 -0
- package/src/ts/charts/heatmap/heatmap-y-axis.ts +351 -0
- package/src/ts/charts/heatmap/heatmap.ts +368 -0
- package/src/ts/charts/map/map.ts +201 -0
- package/src/ts/charts/registry.ts +65 -0
- package/src/ts/charts/series/glyphs/draw-areas.ts +331 -0
- package/src/ts/charts/series/glyphs/draw-bars.ts +113 -0
- package/src/ts/charts/series/glyphs/draw-lines.ts +320 -0
- package/src/ts/charts/series/glyphs/draw-scatter.ts +328 -0
- package/src/ts/charts/series/series-build.ts +848 -0
- package/src/ts/charts/series/series-interact.ts +604 -0
- package/src/ts/charts/series/series-render.ts +1109 -0
- package/src/ts/charts/series/series-type.ts +99 -0
- package/src/ts/charts/series/series.ts +794 -0
- package/src/ts/charts/sunburst/sunburst-interact.ts +460 -0
- package/src/ts/charts/sunburst/sunburst-layout.ts +238 -0
- package/src/ts/charts/sunburst/sunburst-render.ts +887 -0
- package/src/ts/charts/sunburst/sunburst.ts +248 -0
- package/src/ts/charts/treemap/treemap-interact.ts +445 -0
- package/src/ts/charts/treemap/treemap-layout.ts +328 -0
- package/src/ts/charts/treemap/treemap-render.ts +886 -0
- package/src/ts/charts/treemap/treemap.ts +247 -0
- package/src/ts/config.ts +41 -0
- package/src/ts/data/lazy-row.ts +140 -0
- package/src/ts/data/split-groups.ts +97 -0
- package/src/ts/data/view-reader.ts +107 -0
- package/src/ts/event-detail.ts +44 -0
- package/src/ts/index.ts +53 -0
- package/src/ts/interaction/hit-test.ts +106 -0
- package/src/ts/interaction/host-sink-dom.ts +85 -0
- package/src/ts/interaction/host-sink-message.ts +75 -0
- package/src/ts/interaction/lazy-tooltip.ts +102 -0
- package/src/ts/interaction/raw-event-forwarder.ts +175 -0
- package/src/ts/interaction/spatial-grid.ts +100 -0
- package/src/ts/interaction/tooltip-controller.ts +407 -0
- package/src/ts/interaction/zoom-controller.ts +468 -0
- package/src/ts/interaction/zoom-router.ts +230 -0
- package/src/ts/layout/facet-grid.ts +346 -0
- package/src/ts/layout/plot-layout.ts +277 -0
- package/src/ts/layout/ticks.ts +168 -0
- package/src/ts/map/mercator.ts +204 -0
- package/src/ts/map/tile-cache.ts +96 -0
- package/src/ts/map/tile-layer.ts +382 -0
- package/src/ts/map/tile-loader.ts +143 -0
- package/src/ts/map/tile-source.ts +156 -0
- package/src/ts/plugin/charts.ts +286 -0
- package/src/ts/plugin/plugin.ts +668 -0
- package/src/ts/render/scheduler.ts +339 -0
- package/src/ts/shaders/area.frag.glsl +20 -0
- package/src/ts/shaders/area.vert.glsl +19 -0
- package/src/ts/shaders/bar.frag.glsl +25 -0
- package/src/ts/shaders/bar.vert.glsl +60 -0
- package/src/ts/shaders/candlestick-body.frag.glsl +19 -0
- package/src/ts/shaders/candlestick-body.vert.glsl +34 -0
- package/src/ts/shaders/density-extreme.frag.glsl +30 -0
- package/src/ts/shaders/density-mrt.frag.glsl +44 -0
- package/src/ts/shaders/density-mrt.vert.glsl +48 -0
- package/src/ts/shaders/density-resolve.frag.glsl +89 -0
- package/src/ts/shaders/density-resolve.vert.glsl +23 -0
- package/src/ts/shaders/density-splat.frag.glsl +34 -0
- package/src/ts/shaders/density-splat.vert.glsl +52 -0
- package/src/ts/shaders/gridline.frag.glsl +18 -0
- package/src/ts/shaders/gridline.vert.glsl +18 -0
- package/src/ts/shaders/heatmap.frag.glsl +23 -0
- package/src/ts/shaders/heatmap.vert.glsl +42 -0
- package/src/ts/shaders/line-uniform.frag.glsl +26 -0
- package/src/ts/shaders/line-uniform.vert.glsl +54 -0
- package/src/ts/shaders/line.frag.glsl +28 -0
- package/src/ts/shaders/line.vert.glsl +87 -0
- package/src/ts/shaders/scatter.frag.glsl +39 -0
- package/src/ts/shaders/scatter.vert.glsl +67 -0
- package/src/ts/shaders/sunburst-arc.frag.glsl +19 -0
- package/src/ts/shaders/sunburst-arc.vert.glsl +79 -0
- package/src/ts/shaders/tile.frag.glsl +27 -0
- package/src/ts/shaders/tile.vert.glsl +35 -0
- package/src/ts/shaders/treemap.frag.glsl +19 -0
- package/src/ts/shaders/treemap.vert.glsl +25 -0
- package/src/ts/shaders/y-scatter.frag.glsl +30 -0
- package/src/ts/shaders/y-scatter.vert.glsl +31 -0
- package/src/ts/theme/gradient.ts +312 -0
- package/src/ts/theme/palette.ts +64 -0
- package/src/ts/theme/theme-snapshot.ts +66 -0
- package/src/ts/theme/theme.ts +166 -0
- package/src/ts/transport/protocol.ts +497 -0
- package/src/ts/transport/renderer-transport.ts +788 -0
- package/src/ts/utils/css.ts +36 -0
- package/src/ts/utils/font-snapshot.ts +159 -0
- package/src/ts/webgl/buffer-pool.ts +163 -0
- package/src/ts/webgl/context-manager.ts +414 -0
- package/src/ts/webgl/gradient-texture.ts +84 -0
- package/src/ts/webgl/instanced-attrs.ts +139 -0
- package/src/ts/webgl/plot-frame.ts +91 -0
- package/src/ts/webgl/program-cache.ts +46 -0
- package/src/ts/webgl/shader-manifest.ts +148 -0
- package/src/ts/webgl/shader-registry.ts +97 -0
- package/src/ts/worker/boot.ts +22 -0
- package/src/ts/worker/dispatch.ts +99 -0
- package/src/ts/worker/font-loader.ts +89 -0
- package/src/ts/worker/renderer.worker.ts +734 -0
- package/src/ts/worker/session-host.ts +118 -0
|
@@ -0,0 +1,430 @@
|
|
|
1
|
+
import type { FacetConfig, PluginConfig } from "../charts/chart";
|
|
2
|
+
import type { PerspectiveClickDetail } from "../event-detail";
|
|
3
|
+
import type { ViewConfig } from "@perspective-dev/client";
|
|
4
|
+
/**
|
|
5
|
+
* Worker-mode control-channel messages. Distinct from the perspective
|
|
6
|
+
* `ProxySession` channel that the worker's `Client` uses to talk to the
|
|
7
|
+
* host's real `Client` — that's pure protobuf bytes; this one is the
|
|
8
|
+
* chart's own renderer control plane.
|
|
9
|
+
*/
|
|
10
|
+
export type ControlMsg = InitMsg | SetViewByNameMsg | SetColumnsConfigMsg | SetPluginConfigMsg | SetBufferMaxCapacityMsg | LoadAndRenderMsg | RedrawMsg | ResizeMsg | ClearMsg | InvalidateThemeMsg | RestoreZoomMsg | ResetAllZoomsMsg | ResetExpandedDomainMsg | SaveZoomReqMsg | SnapshotPngReqMsg | InteractionMsg | DestroyMsg;
|
|
11
|
+
export type WorkerMsg = ReadyMsg | ZoomChangedMsg | SaveZoomReplyMsg | SnapshotPngReplyMsg | PinTooltipMsg | DismissTooltipMsg | SetCursorMsg | UserClickMsg | UserSelectMsg | LoadAndRenderAckMsg | FrameBitmapMsg | ErrorMsg;
|
|
12
|
+
/**
|
|
13
|
+
* Session-tagged envelopes for the shared-worker transport. Every
|
|
14
|
+
* message between the host and the shared `Worker` carries a numeric
|
|
15
|
+
* `sessionId` that addresses a specific `WorkerRenderer` slot in the
|
|
16
|
+
* worker's `RENDERERS` map.
|
|
17
|
+
*
|
|
18
|
+
* In-process mode bypasses these — its `MessageChannel` is per-
|
|
19
|
+
* transport, so messages are already private and routing isn't
|
|
20
|
+
* needed. Only worker-mode `RendererTransport` and the worker-scope
|
|
21
|
+
* message handler wrap / unwrap envelopes.
|
|
22
|
+
*/
|
|
23
|
+
export interface ControlEnvelope {
|
|
24
|
+
sessionId: number;
|
|
25
|
+
msg: ControlMsg;
|
|
26
|
+
}
|
|
27
|
+
export interface WorkerEnvelope {
|
|
28
|
+
sessionId: number;
|
|
29
|
+
msg: WorkerMsg;
|
|
30
|
+
}
|
|
31
|
+
export interface InitMsg {
|
|
32
|
+
kind: "init";
|
|
33
|
+
/**
|
|
34
|
+
* GL canvas display strategy. `"direct"` means `glCanvas` below is
|
|
35
|
+
* the host's `.webgl-canvas` transferred via
|
|
36
|
+
* `transferControlToOffscreen` and the renderer paints straight
|
|
37
|
+
* into it. `"blit"` means `glCanvas` is omitted; the renderer
|
|
38
|
+
* allocates its own internal `OffscreenCanvas`, renders into it,
|
|
39
|
+
* and posts each completed frame back as a `FrameBitmapMsg` for
|
|
40
|
+
* the host to draw into a 2D-context display canvas.
|
|
41
|
+
*/
|
|
42
|
+
renderMode: "direct" | "blit";
|
|
43
|
+
/**
|
|
44
|
+
* Transferred via `transferControlToOffscreen` on the host. Present
|
|
45
|
+
* iff `renderMode === "direct"`. In blit mode the renderer
|
|
46
|
+
* constructs its own offscreen surface from `cssWidth`/`cssHeight`/
|
|
47
|
+
* `dpr` and there is no host-side GL drawing buffer.
|
|
48
|
+
*/
|
|
49
|
+
glCanvas?: OffscreenCanvas;
|
|
50
|
+
gridlinesCanvas: OffscreenCanvas;
|
|
51
|
+
chromeCanvas: OffscreenCanvas;
|
|
52
|
+
/**
|
|
53
|
+
* `MessagePort` to the host's `ProxySession`. Worker mode only —
|
|
54
|
+
* the worker bootstraps a fresh `Client` and bridges it through
|
|
55
|
+
* this port. In-process mode uses the host's `Client` directly
|
|
56
|
+
* (handed in via `bootstrapInProcess`'s `client` option), so no
|
|
57
|
+
* proxy bridge is needed.
|
|
58
|
+
*/
|
|
59
|
+
proxyPort?: MessagePort;
|
|
60
|
+
/**
|
|
61
|
+
* Compiled perspective-js client wasm forwarded from the host.
|
|
62
|
+
* Worker mode only — passed to `module.initSync(...)` after the
|
|
63
|
+
* worker dynamic-imports `clientWorkerURL`. In-process mode
|
|
64
|
+
* inherits the host's already-bound wasm via the supplied
|
|
65
|
+
* `Client` instance.
|
|
66
|
+
*/
|
|
67
|
+
clientWasm?: WebAssembly.Module;
|
|
68
|
+
/**
|
|
69
|
+
* URL the worker uses to dynamic-import the perspective-viewer
|
|
70
|
+
* wasm-bindgen JS module. Worker mode only — required because
|
|
71
|
+
* the worker scope can't share module instances with the host.
|
|
72
|
+
* In-process mode uses the host's already-loaded module via
|
|
73
|
+
* the supplied `Client` instance.
|
|
74
|
+
*/
|
|
75
|
+
clientWorkerURL?: URL;
|
|
76
|
+
/**
|
|
77
|
+
* `ChartTypeConfig.tag` — selects which `ChartImplementation` to
|
|
78
|
+
* construct in the worker. The worker has its own copy of the
|
|
79
|
+
* chart class registry.
|
|
80
|
+
*/
|
|
81
|
+
chartTag: string;
|
|
82
|
+
/**
|
|
83
|
+
* Server-assigned `View` name for `client.__unsafe_open_view(name)`.
|
|
84
|
+
*/
|
|
85
|
+
viewName: string;
|
|
86
|
+
/**
|
|
87
|
+
* `Table` name for the worker to resolve via `client.open_table(...)`
|
|
88
|
+
* once at bootstrap. Used for source-schema lookups (group-by level
|
|
89
|
+
* types) on the render path so the host doesn't have to await
|
|
90
|
+
* `table.schema()` on every draw. May be omitted if the host viewer
|
|
91
|
+
* has no table loaded yet — `loadAndRender` falls back to an empty
|
|
92
|
+
* source schema in that case.
|
|
93
|
+
*/
|
|
94
|
+
tableName?: string;
|
|
95
|
+
facetConfig: FacetConfig;
|
|
96
|
+
/**
|
|
97
|
+
* Initial plugin-scoped global config. Seeds the chart impl's
|
|
98
|
+
* `_pluginConfig` before the first `loadAndRender` so the build
|
|
99
|
+
* pipeline (`auto_alt_y_axis`, `band_inner_frac`, `bar_inner_pad`)
|
|
100
|
+
* and render-path uniforms see correct values on the very first
|
|
101
|
+
* frame. The host's later `restore({ plugin_config })` arrives as
|
|
102
|
+
* a `setPluginConfig` control msg.
|
|
103
|
+
*/
|
|
104
|
+
pluginConfig: PluginConfig;
|
|
105
|
+
defaultChartType?: string;
|
|
106
|
+
/**
|
|
107
|
+
* Pre-resolved CSS-variable theme snapshot from the host.
|
|
108
|
+
*/
|
|
109
|
+
themeVars: ThemeSnapshot;
|
|
110
|
+
/**
|
|
111
|
+
* `@font-face` rules captured from the host document, to be
|
|
112
|
+
* re-loaded into the worker's `self.fonts` set before first
|
|
113
|
+
* paint. Worker mode only — workers don't share `FontFaceSet`
|
|
114
|
+
* with the document, so any font referenced via `font-family`
|
|
115
|
+
* must be reloaded there. In-process mode shares
|
|
116
|
+
* `document.fonts` with the host so the array is empty / unused.
|
|
117
|
+
* See `snapshotFontFaces()` for CORS / scope caveats.
|
|
118
|
+
*/
|
|
119
|
+
fontFaces: FontFaceDescriptor[];
|
|
120
|
+
/**
|
|
121
|
+
* Initial CSS size + DPR; subsequent resizes arrive as `resize`.
|
|
122
|
+
*/
|
|
123
|
+
cssWidth: number;
|
|
124
|
+
cssHeight: number;
|
|
125
|
+
dpr: number;
|
|
126
|
+
/**
|
|
127
|
+
* `ChartTypeConfig.max_cells` for the buffer pool.
|
|
128
|
+
*/
|
|
129
|
+
bufferMaxCapacity: number;
|
|
130
|
+
/**
|
|
131
|
+
* If `true`, the `WebGLContextManager` constructed on the
|
|
132
|
+
* renderer side compiles + links every shader in
|
|
133
|
+
* `SHADER_MANIFEST` during construction. Trades a known init-time
|
|
134
|
+
* cost for elimination of inline compile latency on first frame.
|
|
135
|
+
* Default behavior (when undefined) is lazy compilation as a
|
|
136
|
+
* side effect of each glyph's first `getOrCreate` call.
|
|
137
|
+
*/
|
|
138
|
+
precompileShaders?: boolean;
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Plain-object form of an `@font-face` rule, structured-cloneable for
|
|
142
|
+
* `postMessage`. The worker reconstitutes a `FontFace` via
|
|
143
|
+
* `new FontFace(family, src, descriptors)`, awaits its load, and
|
|
144
|
+
* registers it in `self.fonts`.
|
|
145
|
+
*
|
|
146
|
+
* `src` is the raw CSS `src:` value (e.g.
|
|
147
|
+
* `url(https://…/foo.woff2) format("woff2")`), with every `url(...)`
|
|
148
|
+
* already absolutized on the host against the parent stylesheet's
|
|
149
|
+
* `href` — the worker's script URL is a Blob URL, so relative URLs
|
|
150
|
+
* would otherwise fail to resolve.
|
|
151
|
+
*/
|
|
152
|
+
export interface FontFaceDescriptor {
|
|
153
|
+
family: string;
|
|
154
|
+
src: string;
|
|
155
|
+
style?: string;
|
|
156
|
+
weight?: string;
|
|
157
|
+
stretch?: string;
|
|
158
|
+
unicodeRange?: string;
|
|
159
|
+
variant?: string;
|
|
160
|
+
featureSettings?: string;
|
|
161
|
+
display?: string;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Theme values resolved on the host via `getComputedStyle` and shipped
|
|
165
|
+
* to the renderer scope, which has no DOM. Decoded by the chart via
|
|
166
|
+
* `theme/theme.ts::resolveThemeFromVars`. Plain map for
|
|
167
|
+
* structured-clone.
|
|
168
|
+
*/
|
|
169
|
+
export type ThemeSnapshot = Record<string, string>;
|
|
170
|
+
export interface SetViewByNameMsg {
|
|
171
|
+
kind: "setViewByName";
|
|
172
|
+
name: string;
|
|
173
|
+
}
|
|
174
|
+
export interface SetColumnsConfigMsg {
|
|
175
|
+
kind: "setColumnsConfig";
|
|
176
|
+
cfg: Record<string, any>;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Host → worker: replace the chart impl's `_pluginConfig` with a new
|
|
180
|
+
* snapshot. Sent on every `plugin.restore({ plugin_config })`. The
|
|
181
|
+
* chart re-syncs derived state (`_facetConfig.facet_mode`,
|
|
182
|
+
* `_facetConfig.zoom_mode`, `_autoFitValue`) in `setPluginConfig` and
|
|
183
|
+
* the host posts a `redraw` so render-path uniform changes (line
|
|
184
|
+
* widths, point size) take effect on the next frame. Build-time
|
|
185
|
+
* fields (`auto_alt_y_axis`, `band_inner_frac`, `bar_inner_pad`) take
|
|
186
|
+
* effect on the next `loadAndRender`.
|
|
187
|
+
*/
|
|
188
|
+
export interface SetPluginConfigMsg {
|
|
189
|
+
kind: "setPluginConfig";
|
|
190
|
+
cfg: PluginConfig;
|
|
191
|
+
}
|
|
192
|
+
export interface SetBufferMaxCapacityMsg {
|
|
193
|
+
kind: "setBufferMaxCapacity";
|
|
194
|
+
n: number;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Host → worker: trigger a full data-fetch + render cycle. The worker
|
|
198
|
+
* resolves all schema / row-count metadata against its own `View` and
|
|
199
|
+
* `Table` (no host-side `Client`/`Table`/`View` await on the render
|
|
200
|
+
* path), runs `view.with_typed_arrays`, and uploads the resulting
|
|
201
|
+
* column data straight into the chart impl on the same thread —
|
|
202
|
+
* eliminating the prior cross-boundary `postMessage` of column buffers.
|
|
203
|
+
*
|
|
204
|
+
* `viewerConfig` ships the bits the worker can't read for itself
|
|
205
|
+
* (`<perspective-viewer>` element APIs, not `Client`/`Table`/`View`).
|
|
206
|
+
*
|
|
207
|
+
* Mid-flight cancellation: each call increments a worker-side
|
|
208
|
+
* generation counter. A newer `loadAndRender` arriving while one is in
|
|
209
|
+
* flight causes the older call's `with_typed_arrays` callback to throw
|
|
210
|
+
* a sentinel before any chart mutation, unwinding the wasm Arrow
|
|
211
|
+
* buffer release before the new call proceeds. Both calls reply with
|
|
212
|
+
* `loadAndRenderAck` so the host promise resolves either way.
|
|
213
|
+
*/
|
|
214
|
+
export interface LoadAndRenderMsg {
|
|
215
|
+
kind: "loadAndRender";
|
|
216
|
+
msgId: number;
|
|
217
|
+
viewerConfig: {
|
|
218
|
+
group_by: string[];
|
|
219
|
+
split_by: string[];
|
|
220
|
+
columns: (string | null)[];
|
|
221
|
+
};
|
|
222
|
+
options: {
|
|
223
|
+
float32: boolean;
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Worker → host reply to a `LoadAndRenderMsg`. Always sent — including
|
|
228
|
+
* on stale-generation drop — so the host's awaited promise resolves
|
|
229
|
+
* deterministically.
|
|
230
|
+
*/
|
|
231
|
+
export interface LoadAndRenderAckMsg {
|
|
232
|
+
kind: "loadAndRenderAck";
|
|
233
|
+
msgId: number;
|
|
234
|
+
}
|
|
235
|
+
export interface RedrawMsg {
|
|
236
|
+
kind: "redraw";
|
|
237
|
+
}
|
|
238
|
+
export interface ResizeMsg {
|
|
239
|
+
kind: "resize";
|
|
240
|
+
cssWidth: number;
|
|
241
|
+
cssHeight: number;
|
|
242
|
+
dpr: number;
|
|
243
|
+
}
|
|
244
|
+
export interface ClearMsg {
|
|
245
|
+
kind: "clear";
|
|
246
|
+
}
|
|
247
|
+
export interface InvalidateThemeMsg {
|
|
248
|
+
kind: "invalidateTheme";
|
|
249
|
+
/**
|
|
250
|
+
* Fresh CSS-variable snapshot — the worker can't read DOM.
|
|
251
|
+
*/
|
|
252
|
+
themeVars: ThemeSnapshot;
|
|
253
|
+
}
|
|
254
|
+
export interface RestoreZoomMsg {
|
|
255
|
+
kind: "restoreZoom";
|
|
256
|
+
state: any;
|
|
257
|
+
}
|
|
258
|
+
export interface ResetAllZoomsMsg {
|
|
259
|
+
kind: "resetAllZooms";
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Host → worker: clear the chart's `domain_mode: "expand"` accumulator
|
|
263
|
+
* so the next data load starts from a fresh extent. Sent at the head
|
|
264
|
+
* of every `plugin.draw()` (which always indicates a view-level
|
|
265
|
+
* change). `plugin.update()` does not send this — same view, more
|
|
266
|
+
* data, the accumulator should keep growing.
|
|
267
|
+
*/
|
|
268
|
+
export interface ResetExpandedDomainMsg {
|
|
269
|
+
kind: "resetExpandedDomain";
|
|
270
|
+
}
|
|
271
|
+
export interface SaveZoomReqMsg {
|
|
272
|
+
kind: "saveZoom";
|
|
273
|
+
requestId: number;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Host → worker: ask the renderer to flush a frame and return a PNG of
|
|
277
|
+
* the composited canvas stack. The reply ships a `Blob` correlated to
|
|
278
|
+
* the request via `requestId` (allocated by the host's
|
|
279
|
+
* `RendererTransport.snapshotPng()`).
|
|
280
|
+
*/
|
|
281
|
+
export interface SnapshotPngReqMsg {
|
|
282
|
+
kind: "snapshotPng";
|
|
283
|
+
requestId: number;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Worker → host reply to a `SnapshotPngReqMsg`. Resolves the
|
|
287
|
+
* corresponding host-side promise with the encoded `Blob`.
|
|
288
|
+
*/
|
|
289
|
+
export interface SnapshotPngReplyMsg {
|
|
290
|
+
kind: "snapshotPngReply";
|
|
291
|
+
requestId: number;
|
|
292
|
+
blob: Blob;
|
|
293
|
+
}
|
|
294
|
+
export interface DestroyMsg {
|
|
295
|
+
kind: "destroy";
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* Raw pointer / wheel event forwarded from the host's
|
|
299
|
+
* `RawEventForwarder` to the renderer. Coordinates are canvas-relative
|
|
300
|
+
* CSS pixels (host already subtracted `getBoundingClientRect`).
|
|
301
|
+
*
|
|
302
|
+
* `pointerdown` carries `pointerId` so the host can drive
|
|
303
|
+
* `setPointerCapture` while the corresponding `pointermove` /
|
|
304
|
+
* `pointerup` events fire even when the cursor leaves the canvas.
|
|
305
|
+
*
|
|
306
|
+
* `pointermove` drives both pan (when a drag is active) and tooltip
|
|
307
|
+
* hover (when not). `pointerleave` drives tooltip leave. `click` /
|
|
308
|
+
* `dblclick` drive tooltip click handling. One channel per cursor
|
|
309
|
+
* stream — no parallel `mouse*` mirror.
|
|
310
|
+
*/
|
|
311
|
+
export type InteractionEvent = {
|
|
312
|
+
type: "wheel";
|
|
313
|
+
mx: number;
|
|
314
|
+
my: number;
|
|
315
|
+
deltaY: number;
|
|
316
|
+
} | {
|
|
317
|
+
type: "pointerdown";
|
|
318
|
+
mx: number;
|
|
319
|
+
my: number;
|
|
320
|
+
pointerId: number;
|
|
321
|
+
} | {
|
|
322
|
+
type: "pointermove";
|
|
323
|
+
mx: number;
|
|
324
|
+
my: number;
|
|
325
|
+
} | {
|
|
326
|
+
type: "pointerup";
|
|
327
|
+
} | {
|
|
328
|
+
type: "pointerleave";
|
|
329
|
+
} | {
|
|
330
|
+
type: "click";
|
|
331
|
+
mx: number;
|
|
332
|
+
my: number;
|
|
333
|
+
} | {
|
|
334
|
+
type: "dblclick";
|
|
335
|
+
mx: number;
|
|
336
|
+
my: number;
|
|
337
|
+
};
|
|
338
|
+
export interface InteractionMsg {
|
|
339
|
+
kind: "interaction";
|
|
340
|
+
event: InteractionEvent;
|
|
341
|
+
}
|
|
342
|
+
export interface ReadyMsg {
|
|
343
|
+
kind: "ready";
|
|
344
|
+
}
|
|
345
|
+
export interface ZoomChangedMsg {
|
|
346
|
+
kind: "zoomChanged";
|
|
347
|
+
isDefault: boolean;
|
|
348
|
+
}
|
|
349
|
+
export interface SaveZoomReplyMsg {
|
|
350
|
+
kind: "saveZoomReply";
|
|
351
|
+
requestId: number;
|
|
352
|
+
state: any;
|
|
353
|
+
}
|
|
354
|
+
export interface ErrorMsg {
|
|
355
|
+
kind: "error";
|
|
356
|
+
message: string;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Worker-side request to render a pinned tooltip on the host. The
|
|
360
|
+
* worker has no DOM, so the persistent tooltip `<div>` is materialized
|
|
361
|
+
* by `RendererTransport` (via a `DomHostSink`) on receipt. `bounds` ships
|
|
362
|
+
* the chart's CSS size so the host can clamp the tooltip without
|
|
363
|
+
* reading the canvas geometry itself.
|
|
364
|
+
*/
|
|
365
|
+
export interface PinTooltipMsg {
|
|
366
|
+
kind: "pinTooltip";
|
|
367
|
+
lines: string[];
|
|
368
|
+
pos: {
|
|
369
|
+
px: number;
|
|
370
|
+
py: number;
|
|
371
|
+
};
|
|
372
|
+
bounds: {
|
|
373
|
+
cssWidth: number;
|
|
374
|
+
cssHeight: number;
|
|
375
|
+
};
|
|
376
|
+
}
|
|
377
|
+
export interface DismissTooltipMsg {
|
|
378
|
+
kind: "dismissTooltip";
|
|
379
|
+
}
|
|
380
|
+
/**
|
|
381
|
+
* Renderer → host: set the GL canvas's `style.cursor`. The renderer
|
|
382
|
+
* has no DOM (worker mode) — `cursor` is a CSS cursor value
|
|
383
|
+
* (`"pointer"`, `"default"`, etc.) applied directly by the host on
|
|
384
|
+
* receipt.
|
|
385
|
+
*/
|
|
386
|
+
export interface SetCursorMsg {
|
|
387
|
+
kind: "setCursor";
|
|
388
|
+
cursor: string;
|
|
389
|
+
}
|
|
390
|
+
/**
|
|
391
|
+
* Renderer → host: a user click landed on a chart glyph. Host
|
|
392
|
+
* re-dispatches as `CustomEvent<PerspectiveClickDetail>` on the
|
|
393
|
+
* `<perspective-viewer>` ancestor. Payload is a plain object so it
|
|
394
|
+
* survives `postMessage` without losing the class prototype.
|
|
395
|
+
*/
|
|
396
|
+
export interface UserClickMsg {
|
|
397
|
+
kind: "userClick";
|
|
398
|
+
detail: PerspectiveClickDetail;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
* Renderer → host: a user click pinned or unpinned a chart target.
|
|
402
|
+
* Host materializes a `PerspectiveSelectDetail` from this payload plus
|
|
403
|
+
* its own cached previous-insert config and dispatches as
|
|
404
|
+
* `CustomEvent<PerspectiveSelectDetail>` (`perspective-global-filter`).
|
|
405
|
+
* `removeConfigs` is computed host-side — not sent.
|
|
406
|
+
*/
|
|
407
|
+
export interface UserSelectMsg {
|
|
408
|
+
kind: "userSelect";
|
|
409
|
+
selected: boolean;
|
|
410
|
+
row: Record<string, unknown>;
|
|
411
|
+
column_names: string[];
|
|
412
|
+
insertConfig: Partial<ViewConfig>;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Worker → host: a completed GL frame, materialized as an
|
|
416
|
+
* `ImageBitmap` from the renderer's internal offscreen canvas via
|
|
417
|
+
* `transferToImageBitmap()`. Sent only in `renderMode === "blit"`,
|
|
418
|
+
* after each `_fullRender` completes. The host draws the bitmap into
|
|
419
|
+
* its 2D-context display canvas and calls `bitmap.close()` to release
|
|
420
|
+
* the GPU-backed surface.
|
|
421
|
+
*
|
|
422
|
+
* The bitmap MUST appear in the postMessage transfer list — the
|
|
423
|
+
* underlying surface is moved, not copied, so failing to transfer
|
|
424
|
+
* renders the host's drawImage a no-op (or worse, a Safari crash on
|
|
425
|
+
* older WebKits).
|
|
426
|
+
*/
|
|
427
|
+
export interface FrameBitmapMsg {
|
|
428
|
+
kind: "frameBitmap";
|
|
429
|
+
bitmap: ImageBitmap;
|
|
430
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import type { Client, View } from "@perspective-dev/client";
|
|
2
|
+
import type { FacetConfig, PluginConfig } from "../charts/chart";
|
|
3
|
+
import type { InteractionEvent } from "./protocol";
|
|
4
|
+
/**
|
|
5
|
+
* Unified host-side driver for the chart renderer. Owns one of two
|
|
6
|
+
* handle shapes:
|
|
7
|
+
*
|
|
8
|
+
* - **Worker mode**: a real `Worker` running the same module. The
|
|
9
|
+
* handle posts `ControlMsg`s over `Worker.postMessage`.
|
|
10
|
+
* - **In-process mode**: a `MessageChannel` whose `port2` is owned
|
|
11
|
+
* by an in-thread `WorkerRenderer` instantiated via
|
|
12
|
+
* `await import(workerURL)`. Same module bytes, different host.
|
|
13
|
+
*
|
|
14
|
+
* Both modes go through the same control channel, the same
|
|
15
|
+
* `ProxySession` proxy port, and the same `OffscreenCanvas` transfer
|
|
16
|
+
* — `MessageChannel` and `transferControlToOffscreen` work in-realm
|
|
17
|
+
* just as well as cross-thread. The only branching is at construction
|
|
18
|
+
* (handle creation) and bootstrap (worker scope sets up its own
|
|
19
|
+
* `Client`; in-process reuses the host's).
|
|
20
|
+
*/
|
|
21
|
+
export declare class RendererTransport {
|
|
22
|
+
private _handle;
|
|
23
|
+
private _proxyChannel;
|
|
24
|
+
private _proxySession;
|
|
25
|
+
private _client;
|
|
26
|
+
private _view;
|
|
27
|
+
private _tableName;
|
|
28
|
+
private _clientWorkerURL;
|
|
29
|
+
private _clientWasm;
|
|
30
|
+
private _chartTag;
|
|
31
|
+
private _maxCells;
|
|
32
|
+
private _precompileShaders;
|
|
33
|
+
private _ready;
|
|
34
|
+
private _resolveReady;
|
|
35
|
+
private _rejectReady;
|
|
36
|
+
/**
|
|
37
|
+
* Pending request/reply promises across all worker round-trips —
|
|
38
|
+
* `saveZoom`, `uploadChunk` ACKs, and `snapshotPng`. Each entry
|
|
39
|
+
* carries its `kind` so `destroy()` can apply per-kind teardown
|
|
40
|
+
* semantics (uploadChunk resolves silently, the rest reject with
|
|
41
|
+
* a teardown error).
|
|
42
|
+
*
|
|
43
|
+
* Keyed by a single monotonic counter; the worker's reply messages
|
|
44
|
+
* carry that id back verbatim. One counter for all kinds is safe
|
|
45
|
+
* because the host's switch already keys on `msg.kind` before
|
|
46
|
+
* resolving.
|
|
47
|
+
*/
|
|
48
|
+
private _pending;
|
|
49
|
+
private _pendingCounter;
|
|
50
|
+
private _onZoomChanged;
|
|
51
|
+
/**
|
|
52
|
+
* Cached zoom-default flag pushed by the renderer after each zoom
|
|
53
|
+
* mutation. Surfaced sync via `allZoomsDefault()`; updates between
|
|
54
|
+
* calls are best-effort.
|
|
55
|
+
*/
|
|
56
|
+
private _allZoomsDefault;
|
|
57
|
+
private _hostGlCanvas;
|
|
58
|
+
/**
|
|
59
|
+
* Blit-mode only: the visible `.webgl-canvas`'s 2D context. The
|
|
60
|
+
* worker emits each completed GL frame as a `FrameBitmapMsg`; on
|
|
61
|
+
* receipt we `drawImage` the bitmap into this context and `close()`
|
|
62
|
+
* it to release the GPU surface. Null in direct mode (the visible
|
|
63
|
+
* canvas's drawing buffer is the worker's transferred GL canvas).
|
|
64
|
+
*/
|
|
65
|
+
private _displayCtx;
|
|
66
|
+
/**
|
|
67
|
+
* Host-side sink for tooltip + cursor side-effects. The chart
|
|
68
|
+
* inside the renderer calls into a `MessageHostSink` that posts
|
|
69
|
+
* `pinTooltip` / `dismissTooltip` / `setCursor` over the control
|
|
70
|
+
* channel; this sink applies them to the DOM. Initialized lazily
|
|
71
|
+
* on first signal so we don't pay for the parent-style lookup
|
|
72
|
+
* unless a user interacts.
|
|
73
|
+
*/
|
|
74
|
+
private _hostSink;
|
|
75
|
+
/**
|
|
76
|
+
* Last `insertConfig` accepted by a `userSelect { selected: true }`
|
|
77
|
+
* message. Used to populate `removeConfigs` on the next
|
|
78
|
+
* `selected: false` (unpin / drill-up / view-change) — mirrors
|
|
79
|
+
* datagrid's `model._last_insert_configs` so coordinated-filter
|
|
80
|
+
* consumers can roll back the previous select when a new one
|
|
81
|
+
* supplants it.
|
|
82
|
+
*/
|
|
83
|
+
private _lastInsertConfig;
|
|
84
|
+
constructor(opts: {
|
|
85
|
+
client: Client;
|
|
86
|
+
view: View;
|
|
87
|
+
tableName?: string;
|
|
88
|
+
clientWasm: WebAssembly.Module;
|
|
89
|
+
clientWorkerURL: URL;
|
|
90
|
+
chartTag: string;
|
|
91
|
+
maxCells: number;
|
|
92
|
+
precompileShaders?: boolean;
|
|
93
|
+
onZoomChanged?: (isDefault: boolean) => void;
|
|
94
|
+
});
|
|
95
|
+
init(opts: {
|
|
96
|
+
gl: HTMLCanvasElement;
|
|
97
|
+
gridlines: HTMLCanvasElement;
|
|
98
|
+
chrome: HTMLCanvasElement;
|
|
99
|
+
facetConfig: FacetConfig;
|
|
100
|
+
pluginConfig: PluginConfig;
|
|
101
|
+
defaultChartType?: string;
|
|
102
|
+
renderBlitMode: "blit" | "direct";
|
|
103
|
+
}): Promise<void>;
|
|
104
|
+
/**
|
|
105
|
+
* Construct the underlying transport. Worker mode wraps the
|
|
106
|
+
* module-shared `Worker` (lazy, page-singleton) and tags every
|
|
107
|
+
* message with a unique `sessionId`. In-process mode pairs a
|
|
108
|
+
* `MessageChannel` with a dynamically-imported
|
|
109
|
+
* {@link bootstrapInProcess}.
|
|
110
|
+
*/
|
|
111
|
+
private _createHandle;
|
|
112
|
+
setView(view: View): void;
|
|
113
|
+
setColumnsConfig(cfg: Record<string, any>): void;
|
|
114
|
+
setPluginConfig(cfg: PluginConfig): void;
|
|
115
|
+
setBufferMaxCapacity(n: number): void;
|
|
116
|
+
/**
|
|
117
|
+
* Trigger a worker-side data fetch + render cycle. The worker
|
|
118
|
+
* resolves all schema / row-count metadata against its own `View`
|
|
119
|
+
* and `Table`, runs `view.with_typed_arrays`, and pipes the
|
|
120
|
+
* resulting `ColumnDataMap` directly into `chartImpl.uploadAndRender`
|
|
121
|
+
* — no host-side `Client`/`Table`/`View` await, no `postMessage` of
|
|
122
|
+
* column buffers.
|
|
123
|
+
*
|
|
124
|
+
* The returned promise resolves when the worker replies with
|
|
125
|
+
* `loadAndRenderAck`. Per the worker's "resolve on stale"
|
|
126
|
+
* contract, a mid-flight cancellation (a newer `loadAndRender`
|
|
127
|
+
* superseding this one) still acks — the host's awaiter just
|
|
128
|
+
* resolves quietly.
|
|
129
|
+
*/
|
|
130
|
+
loadAndRender(opts: {
|
|
131
|
+
viewerConfig: {
|
|
132
|
+
group_by: string[];
|
|
133
|
+
split_by: string[];
|
|
134
|
+
columns: (string | null)[];
|
|
135
|
+
};
|
|
136
|
+
options?: {
|
|
137
|
+
float32?: boolean;
|
|
138
|
+
};
|
|
139
|
+
}): Promise<void>;
|
|
140
|
+
redraw(): void;
|
|
141
|
+
resize(): void;
|
|
142
|
+
clear(): void;
|
|
143
|
+
invalidateTheme(): void;
|
|
144
|
+
saveZoom(): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Allocate a pending request slot of the given `kind`. Returns the
|
|
147
|
+
* id (encoded into the outgoing `ControlMsg`) and a promise that
|
|
148
|
+
* resolves / rejects when the matching reply arrives or
|
|
149
|
+
* `destroy()` drains the table.
|
|
150
|
+
*/
|
|
151
|
+
private _allocPending;
|
|
152
|
+
restoreZoom(state: any): void;
|
|
153
|
+
allZoomsDefault(): boolean;
|
|
154
|
+
resetAllZooms(): void;
|
|
155
|
+
resetExpandedDomain(): void;
|
|
156
|
+
/**
|
|
157
|
+
* Request a PNG snapshot of the current frame. The worker flushes a
|
|
158
|
+
* synchronous render across the GL + gridlines + chrome layers,
|
|
159
|
+
* composites them into a single `OffscreenCanvas`, fills the theme
|
|
160
|
+
* background, and replies with the `convertToBlob` result.
|
|
161
|
+
*/
|
|
162
|
+
snapshotPng(): Promise<Blob>;
|
|
163
|
+
forwardInteraction(event: InteractionEvent): void;
|
|
164
|
+
destroy(): void;
|
|
165
|
+
private _post;
|
|
166
|
+
private _postRaw;
|
|
167
|
+
private _handleRendererMsg;
|
|
168
|
+
/**
|
|
169
|
+
* Look up a pending request by id, verify the recorded kind
|
|
170
|
+
* matches the inbound reply, resolve, and remove. Mismatches are
|
|
171
|
+
* silently dropped — they would only fire if the worker echoed
|
|
172
|
+
* the wrong kind for a given id, which would itself be a bug
|
|
173
|
+
* worth catching at the worker side.
|
|
174
|
+
*/
|
|
175
|
+
private _resolvePending;
|
|
176
|
+
/**
|
|
177
|
+
* Blit-mode handler: draw a renderer-emitted frame into the
|
|
178
|
+
* visible 2D-context display canvas, then close the bitmap so its
|
|
179
|
+
* GPU-backed surface is released. Resizes the visible canvas's
|
|
180
|
+
* drawing buffer to the bitmap dimensions on first frame and
|
|
181
|
+
* after any worker-side resize — the host doesn't directly
|
|
182
|
+
* control GL canvas size in blit mode, so we follow whatever the
|
|
183
|
+
* renderer emits.
|
|
184
|
+
*/
|
|
185
|
+
private _drawFrameBitmap;
|
|
186
|
+
/**
|
|
187
|
+
* Dispatch a `CustomEvent` on the `<perspective-viewer>` ancestor
|
|
188
|
+
* of this transport's GL canvas. Walks the parent chain so the
|
|
189
|
+
* event bubbles from the viewer (matching where datagrid
|
|
190
|
+
* dispatches its `perspective-click` / `perspective-global-filter`
|
|
191
|
+
* events). No-op when the canvas is detached or no viewer ancestor
|
|
192
|
+
* exists (test harnesses, snapshot mode).
|
|
193
|
+
*/
|
|
194
|
+
private _dispatchOnViewer;
|
|
195
|
+
/**
|
|
196
|
+
* Lazily construct a `DomHostSink` rooted at the host GL canvas
|
|
197
|
+
* (cursor mutations) and its parent (pinned-tooltip `<div>`).
|
|
198
|
+
* Returns `null` if the canvas has been detached.
|
|
199
|
+
*/
|
|
200
|
+
private _ensureHostSink;
|
|
201
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function parseCSSColorToVec3(colorStr: string): [number, number, number];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { FontFaceDescriptor } from "../transport/protocol";
|
|
2
|
+
/**
|
|
3
|
+
* Walk every accessible `@font-face` rule in the document and collect a
|
|
4
|
+
* descriptor list ready for forwarding to a Web Worker, where each
|
|
5
|
+
* entry is reconstituted via `new FontFace(family, src, descriptors)`
|
|
6
|
+
* and registered in the worker's own `self.fonts` set.
|
|
7
|
+
*
|
|
8
|
+
* Background: a `Worker` has its own `FontFaceSet` distinct from the
|
|
9
|
+
* document's. Fonts loaded into `document.fonts` (by `<link>`,
|
|
10
|
+
* `@font-face`, or programmatic `FontFace`) are *not* visible to the
|
|
11
|
+
* worker — Canvas2D `ctx.font` lookups inside the worker fall back to
|
|
12
|
+
* the platform default if the family isn't in `self.fonts`. This
|
|
13
|
+
* helper bridges that gap for the in-CSS case.
|
|
14
|
+
*
|
|
15
|
+
* # CORS / security caveats
|
|
16
|
+
*
|
|
17
|
+
* 1. **Cross-origin stylesheets without permissive CORS** throw
|
|
18
|
+
* `SecurityError` on `cssRules` access, and we silently skip them.
|
|
19
|
+
* Their `@font-face` rules are unreachable to JS regardless of
|
|
20
|
+
* where the worker would re-load them, so this is the same
|
|
21
|
+
* fundamental limitation the document itself has.
|
|
22
|
+
*
|
|
23
|
+
* 2. **Font URLs are absolutized against the parent stylesheet's
|
|
24
|
+
* `href`** before forwarding. The worker's own script URL is a
|
|
25
|
+
* Blob URL produced by `WorkerPlugin`, so relative URLs in the raw
|
|
26
|
+
* `src:` declaration would resolve against the Blob origin (i.e.
|
|
27
|
+
* fail). Callers should treat the absolute URLs as the canonical
|
|
28
|
+
* source.
|
|
29
|
+
*
|
|
30
|
+
* 3. **The actual font fetch issued by `face.load()` in the worker
|
|
31
|
+
* is a fresh cross-origin request from the worker scope.** The
|
|
32
|
+
* font server must respond with `Access-Control-Allow-Origin`
|
|
33
|
+
* (e.g. `*` or the page origin) and an appropriate
|
|
34
|
+
* `Access-Control-Allow-Headers` policy if any non-simple headers
|
|
35
|
+
* are involved. A "no-cors" / opaque response is *not* usable
|
|
36
|
+
* here: `FontFace.load()` rejects on opaque responses, and even
|
|
37
|
+
* if it didn't, painted glyphs would taint the canvas and break
|
|
38
|
+
* `getImageData`. Same-origin fonts (including `data:` URIs)
|
|
39
|
+
* sidestep this entirely.
|
|
40
|
+
*
|
|
41
|
+
* 4. **Programmatic fonts** (e.g. `document.fonts.add(new
|
|
42
|
+
* FontFace(name, source))`) are *not* captured by this walker —
|
|
43
|
+
* they don't appear in any stylesheet's `cssRules`. Iterating
|
|
44
|
+
* `document.fonts` directly would catch them, but `FontFace`
|
|
45
|
+
* instances don't expose their source URL or buffer post-
|
|
46
|
+
* construction, so there's no public path to forward them. If a
|
|
47
|
+
* test or app needs that, it must register the same fonts in the
|
|
48
|
+
* worker explicitly.
|
|
49
|
+
*/
|
|
50
|
+
export declare function snapshotFontFaces(): FontFaceDescriptor[];
|