@crysound/crychart 1.0.6 → 1.0.7
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 +24 -2
- package/README.zh-CN.md +24 -2
- package/dist/crychart.cjs +390 -19
- package/dist/crychart.global.js +390 -19
- package/dist/crychart.js +390 -19
- package/dist/types/adapters/opentest.d.ts +3 -1
- package/dist/types/chart.d.ts +9 -0
- package/dist/types/index.d.ts +13 -2
- package/dist/types/render-heatmap.d.ts +2 -0
- package/dist/types/render.d.ts +4 -0
- package/dist/types/shared-webgl-context.d.ts +83 -0
- package/docs/npm-usage.md +1 -1
- package/package.json +1 -1
package/dist/types/render.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { DrawPacket, Rect } from "./contracts.js";
|
|
2
2
|
import { type GpuClipPolicy, type RasterTarget } from './raster-clip.js';
|
|
3
|
+
import { type SharedWebGLContext } from './shared-webgl-context.js';
|
|
3
4
|
export declare class DataRenderer {
|
|
4
5
|
readonly canvas: HTMLCanvasElement;
|
|
5
6
|
readonly backend: "webgl2" | "canvas2d";
|
|
@@ -30,6 +31,8 @@ export declare class DataRenderer {
|
|
|
30
31
|
private lost;
|
|
31
32
|
private iconPipeline?;
|
|
32
33
|
private readonly iconTextures;
|
|
34
|
+
readonly sharedContext?: SharedWebGLContext;
|
|
35
|
+
readonly contextEvents: EventTarget;
|
|
33
36
|
readonly stats: {
|
|
34
37
|
frames: number;
|
|
35
38
|
uploads: number;
|
|
@@ -46,6 +49,7 @@ export declare class DataRenderer {
|
|
|
46
49
|
lineCoverageStateScope?: 'draw' | 'frame';
|
|
47
50
|
ownedCoverageFrame?: boolean;
|
|
48
51
|
gpuClipPolicy?: GpuClipPolicy;
|
|
52
|
+
sharedContext?: SharedWebGLContext;
|
|
49
53
|
});
|
|
50
54
|
private onLost;
|
|
51
55
|
private clearIcons;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
export interface SharedContextOptions {
|
|
2
|
+
/**
|
|
3
|
+
* Optional externally owned canvas used to host the shared WebGL2 context.
|
|
4
|
+
* Must be a dedicated canvas not currently bound to another active SharedWebGLContext.
|
|
5
|
+
* When omitted, an offscreen detached canvas is created via document.createElement('canvas').
|
|
6
|
+
* Reusing an external canvas after dispose() retains the browser's existing WebGL2 context
|
|
7
|
+
* attributes; changing antialias requires passing a fresh canvas.
|
|
8
|
+
*/
|
|
9
|
+
canvas?: HTMLCanvasElement;
|
|
10
|
+
/** Whether the shared WebGL2 context enables MSAA. Defaults to false (matching ChartXY). */
|
|
11
|
+
antialias?: boolean;
|
|
12
|
+
/** Pause scheduled redraws for charts outside the viewport. Defaults to true (implemented in WP5). */
|
|
13
|
+
cullOffscreen?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface SharedWebGLContextStats {
|
|
16
|
+
available: boolean;
|
|
17
|
+
disposed: boolean;
|
|
18
|
+
registeredCharts: number;
|
|
19
|
+
offscreenCharts: number;
|
|
20
|
+
backingWidth: number;
|
|
21
|
+
backingHeight: number;
|
|
22
|
+
chartDraws: number;
|
|
23
|
+
blits: number;
|
|
24
|
+
backingResizes: number;
|
|
25
|
+
contextLosses: number;
|
|
26
|
+
contextRestores: number;
|
|
27
|
+
}
|
|
28
|
+
/** @internal Used by chart.ts and render.ts; must not be re-exported from src/index.ts. */
|
|
29
|
+
export interface SharedChartClient {
|
|
30
|
+
readonly root: HTMLElement;
|
|
31
|
+
setOffscreen?(offscreen: boolean): void;
|
|
32
|
+
}
|
|
33
|
+
/** @internal Resolve the private core for a SharedWebGLContext; must not be re-exported from src/index.ts. */
|
|
34
|
+
export declare function sharedContextCore(context: SharedWebGLContext): SharedContextCore;
|
|
35
|
+
/** @internal Private backing implementation for SharedWebGLContext. */
|
|
36
|
+
export declare class SharedContextCore {
|
|
37
|
+
readonly canvas: HTMLCanvasElement | undefined;
|
|
38
|
+
readonly cullOffscreen: boolean;
|
|
39
|
+
private readonly antialias;
|
|
40
|
+
private readonly ownsCanvas;
|
|
41
|
+
private readonly clients;
|
|
42
|
+
private observer?;
|
|
43
|
+
private readonly observedRoots;
|
|
44
|
+
private readonly offscreenClients;
|
|
45
|
+
private gl;
|
|
46
|
+
private attempted;
|
|
47
|
+
private disposed;
|
|
48
|
+
private maxVertexAttribs;
|
|
49
|
+
private pendingPresent?;
|
|
50
|
+
private chartDraws;
|
|
51
|
+
private blits;
|
|
52
|
+
private backingResizes;
|
|
53
|
+
private contextLosses;
|
|
54
|
+
private contextRestores;
|
|
55
|
+
private readonly onLost;
|
|
56
|
+
private readonly onRestore;
|
|
57
|
+
constructor(options: SharedContextOptions | undefined);
|
|
58
|
+
acquire(): WebGL2RenderingContext | null;
|
|
59
|
+
isAvailable(): boolean;
|
|
60
|
+
isDisposed(): boolean;
|
|
61
|
+
getChartCount(): number;
|
|
62
|
+
getStats(): SharedWebGLContextStats;
|
|
63
|
+
register(client: SharedChartClient): void;
|
|
64
|
+
unregister(client: SharedChartClient): void;
|
|
65
|
+
beginChartDraw(pixelWidth: number, pixelHeight: number): boolean;
|
|
66
|
+
present(target: CanvasRenderingContext2D | null, pixelWidth: number, pixelHeight: number): void;
|
|
67
|
+
dispose(): void;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Coordinates a single shared WebGL2 rendering context across multiple 2D charts.
|
|
71
|
+
* Always dispose charts registered to this context before calling dispose() on the context itself.
|
|
72
|
+
*/
|
|
73
|
+
export declare class SharedWebGLContext {
|
|
74
|
+
constructor(options?: SharedContextOptions);
|
|
75
|
+
/** Lazily acquires the shared WebGL2 context on first call and caches the result without retrying. */
|
|
76
|
+
isAvailable(): boolean;
|
|
77
|
+
isDisposed(): boolean;
|
|
78
|
+
/** Number of charts currently registered with this shared context. */
|
|
79
|
+
getChartCount(): number;
|
|
80
|
+
getStats(): SharedWebGLContextStats;
|
|
81
|
+
/** Idempotently disposes the shared context. Dispose all registered charts first. */
|
|
82
|
+
dispose(): void;
|
|
83
|
+
}
|
package/docs/npm-usage.md
CHANGED