@crysound/crychart 1.0.6 → 1.0.8
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 +883 -328
- package/dist/crychart.global.js +883 -328
- package/dist/crychart.js +883 -328
- package/dist/types/adapters/opentest.d.ts +3 -1
- package/dist/types/axis-canvas.d.ts +12 -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-line-coverage.d.ts +4 -0
- package/dist/types/render-line-strip.d.ts +1 -0
- package/dist/types/render.d.ts +4 -0
- package/dist/types/series.d.ts +1 -0
- package/dist/types/shared-webgl-context.d.ts +86 -0
- package/docs/npm-usage.md +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ChartXY } from '../chart.js';
|
|
2
|
+
import type { SharedWebGLContext } from '../shared-webgl-context.js';
|
|
2
3
|
/** OpenTest's public data envelope, represented independently of its Vue host. */
|
|
3
4
|
export type NumericValues = readonly number[] | Float32Array | Float64Array | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array;
|
|
4
5
|
export interface DataEnvelope {
|
|
@@ -33,8 +34,9 @@ export interface FrameworkChartOptions {
|
|
|
33
34
|
fontSize?: number;
|
|
34
35
|
viewport?: ChartViewport;
|
|
35
36
|
showYCursor?: boolean;
|
|
37
|
+
sharedContext?: SharedWebGLContext;
|
|
36
38
|
}
|
|
37
|
-
export type FrameworkChartDisplayOptions = Partial<Omit<FrameworkChartOptions, 'xScale' | 'showYCursor'>>;
|
|
39
|
+
export type FrameworkChartDisplayOptions = Partial<Omit<FrameworkChartOptions, 'xScale' | 'showYCursor' | 'sharedContext'>>;
|
|
38
40
|
export interface FrameworkChartApi {
|
|
39
41
|
setData(data: DataEnvelope, options?: FrameworkSeriesOptions & {
|
|
40
42
|
append?: boolean;
|
|
@@ -57,6 +57,17 @@ export interface AxisCanvasTheme {
|
|
|
57
57
|
yAxisTitleFillStyle?: FillStyle;
|
|
58
58
|
zAxisTitleFillStyle?: FillStyle;
|
|
59
59
|
}
|
|
60
|
+
type MeasuredText = {
|
|
61
|
+
width: number;
|
|
62
|
+
ascent: number;
|
|
63
|
+
descent: number;
|
|
64
|
+
baseline: number;
|
|
65
|
+
actualBoundingBoxAscent?: number;
|
|
66
|
+
actualBoundingBoxDescent?: number;
|
|
67
|
+
actualBoundingBoxLeft?: number;
|
|
68
|
+
actualBoundingBoxRight?: number;
|
|
69
|
+
};
|
|
70
|
+
export declare function getAxisTextMetricsCache(ctx: CanvasRenderingContext2D | undefined): Map<string, MeasuredText> | undefined;
|
|
60
71
|
/** Content occupied by a one-line title, measured independently of axis labels.
|
|
61
72
|
* Canvas glyph bounds include the baseline row in a positive descent; count it
|
|
62
73
|
* once when converting that raster extent back to CSS pixels. Four CSS pixels
|
|
@@ -66,7 +77,7 @@ export declare function measureChartTitleContent(ctx: CanvasRenderingContext2D |
|
|
|
66
77
|
type TickLevel = 'great' | 'major' | 'minor';
|
|
67
78
|
export declare function resolvedTickFill(axis: Axis, level: TickLevel, style: TickStyle, theme?: AxisCanvasTheme, forDrawing?: boolean): any;
|
|
68
79
|
/** Measure compact content-based axis lanes for XY charts regardless of textRenderer. */
|
|
69
|
-
export declare function measureAxisCanvasLayout(ctx: CanvasRenderingContext2D | undefined, axesX: readonly Axis[], axesY: readonly Axis[], theme?: AxisCanvasTheme, resolveFont?: (font: FontSettings) => FontSettings): AxisCanvasLayout;
|
|
80
|
+
export declare function measureAxisCanvasLayout(ctx: CanvasRenderingContext2D | undefined, axesX: readonly Axis[], axesY: readonly Axis[], theme?: AxisCanvasTheme, resolveFont?: (font: FontSettings) => FontSettings, persistentCache?: Map<string, MeasuredText>): AxisCanvasLayout;
|
|
70
81
|
export declare function axisCanvasLaneOffset(layout: AxisCanvasLayout, axis: Axis): number;
|
|
71
82
|
/** Keep the actual ink inside the physical axis range, without changing text.
|
|
72
83
|
* A label wider than that range cannot fit: align its nearer end and retain
|
package/dist/types/chart.d.ts
CHANGED
|
@@ -14,12 +14,15 @@ import { SurfaceGrid3D, SurfaceMesh3D, MeshModel3D, BoxSeries3D } from './mesh3d
|
|
|
14
14
|
import { type PolarLayout, type PolarInsets } from './polar-layout.js';
|
|
15
15
|
import { type AxisPosition, type PublicEventListener, type ChartEventListenerOptions } from './chart-events.js';
|
|
16
16
|
import { type Projection3D, type Vec3 } from './world-camera.js';
|
|
17
|
+
import { type SharedWebGLContext } from './shared-webgl-context.js';
|
|
17
18
|
export interface ChartOptions {
|
|
18
19
|
/** Artifact research switch; this candidate defaults to the world camera. */
|
|
19
20
|
experimental3DCameraModel?: 'world' | 'legacy';
|
|
20
21
|
container?: HTMLElement | string;
|
|
21
22
|
antialias?: boolean;
|
|
22
23
|
renderer?: 'auto' | 'webgl2' | 'canvas2d';
|
|
24
|
+
/** Share one WebGL2 context across charts (ChartXY/Polar only). null opts out when a cryChart() context injects one. */
|
|
25
|
+
sharedContext?: SharedWebGLContext | null;
|
|
23
26
|
/** Explicit diagnostic opt-in. Pixel and paired-performance validation is ongoing. */
|
|
24
27
|
experimentalLineBlocks?: boolean;
|
|
25
28
|
/** Display-only extrema candidate; disabled unless an explicit pixel span is supplied. */
|
|
@@ -129,6 +132,11 @@ export declare class ChartXY {
|
|
|
129
132
|
private observer?;
|
|
130
133
|
private overlayContext?;
|
|
131
134
|
private underlayContext?;
|
|
135
|
+
private sharedCore?;
|
|
136
|
+
private sharedPresent;
|
|
137
|
+
private sharedClient?;
|
|
138
|
+
private sharedOffscreen;
|
|
139
|
+
private sharedDeferred;
|
|
132
140
|
private heatmapRenderer?;
|
|
133
141
|
private heatmapPalettes;
|
|
134
142
|
private heatCache;
|
|
@@ -319,6 +327,7 @@ export declare class ChartXY {
|
|
|
319
327
|
protected cancelAxisScrollAnimations(): void;
|
|
320
328
|
protected hasPendingAnimationFrame(): boolean;
|
|
321
329
|
protected cancelScheduledAnimation(): void;
|
|
330
|
+
private setSharedOffscreen;
|
|
322
331
|
invalidate(): void;
|
|
323
332
|
renderNow(): void;
|
|
324
333
|
/** Internal post-render publication hook; consumer callbacks may request a new frame. */
|
package/dist/types/index.d.ts
CHANGED
|
@@ -24,13 +24,21 @@ export * from './polar-heatmap.js';
|
|
|
24
24
|
export * from './polar-series.js';
|
|
25
25
|
export * from './mesh3d.js';
|
|
26
26
|
export * from "./adapters/opentest.js";
|
|
27
|
+
export { SharedWebGLContext, type SharedContextOptions, type SharedWebGLContextStats, } from "./shared-webgl-context.js";
|
|
27
28
|
import { ChartXY, Chart3D, Polar, type ChartOptions } from "./chart.js";
|
|
28
29
|
import { Pie, Gauge, Spider, BarChart, TreeMapChart, ParallelCoordinateChart, DataGrid } from "./specialty.js";
|
|
29
30
|
import { SunBurstChart, Funnel, Pyramid } from "./hierarchy.js";
|
|
30
31
|
import { MapChart, type MapOptions } from "./map.js";
|
|
31
32
|
import { type EventListener } from './core/events.js';
|
|
33
|
+
import { SharedWebGLContext, type SharedContextOptions } from "./shared-webgl-context.js";
|
|
34
|
+
export interface CryChartOptions {
|
|
35
|
+
sharedContext?: SharedWebGLContext;
|
|
36
|
+
sharedContextOptions?: SharedContextOptions;
|
|
37
|
+
/** Compatible with LightningChart-style options (such as license); ignored. */
|
|
38
|
+
[key: string]: unknown;
|
|
39
|
+
}
|
|
32
40
|
/** Create a CRYChart context that owns its chart instances. */
|
|
33
|
-
export declare function cryChart(
|
|
41
|
+
export declare function cryChart(options?: CryChartOptions): {
|
|
34
42
|
ChartXY: (o?: ChartOptions) => ChartXY;
|
|
35
43
|
Chart3D: (o?: ChartOptions) => Chart3D;
|
|
36
44
|
Polar: (o?: ChartOptions) => Polar;
|
|
@@ -50,10 +58,13 @@ export declare function cryChart(_options?: Record<string, unknown>): {
|
|
|
50
58
|
isDisposed: () => boolean;
|
|
51
59
|
/** Live charts owned by this context; disposed charts are released immediately. */
|
|
52
60
|
getChartCount: () => number;
|
|
61
|
+
/** Shared WebGL2 context used by this context; undefined when not enabled. */
|
|
62
|
+
getSharedContext: () => SharedWebGLContext | undefined;
|
|
53
63
|
};
|
|
54
|
-
export declare const version = "1.0.
|
|
64
|
+
export declare const version = "1.0.8";
|
|
55
65
|
export declare class Dashboard {
|
|
56
66
|
readonly root: HTMLDivElement;
|
|
67
|
+
private readonly sharedContext?;
|
|
57
68
|
private cells;
|
|
58
69
|
private children;
|
|
59
70
|
private events;
|
|
@@ -79,6 +79,7 @@ export declare class DataRendererHeatmap {
|
|
|
79
79
|
readonly canvas: HTMLCanvasElement;
|
|
80
80
|
readonly options: {
|
|
81
81
|
clipPolicy?: GpuClipPolicy;
|
|
82
|
+
contextEvents?: EventTarget;
|
|
82
83
|
};
|
|
83
84
|
readonly stats: {
|
|
84
85
|
frames: number;
|
|
@@ -102,6 +103,7 @@ export declare class DataRendererHeatmap {
|
|
|
102
103
|
private disposed;
|
|
103
104
|
constructor(gl: WebGL2RenderingContext, canvas: HTMLCanvasElement, options?: {
|
|
104
105
|
clipPolicy?: GpuClipPolicy;
|
|
106
|
+
contextEvents?: EventTarget;
|
|
105
107
|
});
|
|
106
108
|
/** Undefined until data has reached the current, live WebGL context. */
|
|
107
109
|
getUploadedRevision(id: number): number | undefined;
|
|
@@ -70,6 +70,10 @@ export declare class LineCoverageRenderer {
|
|
|
70
70
|
/** Synchronous all-coverage batch: capture actual incoming state, never an
|
|
71
71
|
* assumed private-context baseline. No other renderer may enter until flush. */
|
|
72
72
|
beginCapturedFrame(): void;
|
|
73
|
+
/** Shared-context all-coverage batch after SharedWebGLContext established its
|
|
74
|
+
* exact clean default-target baseline: avoids 28 synchronous GL state queries
|
|
75
|
+
* while preserving identical restoreState semantics for both draw and frame scopes. */
|
|
76
|
+
beginKnownCapturedFrame(program: WebGLProgram, viewport: readonly [number, number, number, number]): void;
|
|
73
77
|
/** Internal capability, only after DataRenderer established this exact private
|
|
74
78
|
* default-target baseline. Standalone draw()/frame users keep full capture.
|
|
75
79
|
* This record is ephemeral and cleared by every flush/end/context/dispose. */
|
|
@@ -84,6 +84,7 @@ export declare class LineStripRenderer {
|
|
|
84
84
|
/** Call before entering a different pipeline during an exclusive frame. */
|
|
85
85
|
flushCoverageState(): boolean;
|
|
86
86
|
beginCapturedCoverageFrame(): void;
|
|
87
|
+
beginKnownCapturedCoverageFrame(program: WebGLProgram, viewport: readonly [number, number, number, number]): void;
|
|
87
88
|
canDraw(packet: DrawPacket): boolean;
|
|
88
89
|
beginFrame(): void;
|
|
89
90
|
draw(packet: DrawPacket, rect: Rect, dpr: number, range?: LineStripRange, rasterTarget?: RasterTarget): boolean;
|
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;
|
package/dist/types/series.d.ts
CHANGED
|
@@ -0,0 +1,86 @@
|
|
|
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 baselineClean;
|
|
51
|
+
private chartDraws;
|
|
52
|
+
private blits;
|
|
53
|
+
private backingResizes;
|
|
54
|
+
private contextLosses;
|
|
55
|
+
private contextRestores;
|
|
56
|
+
private readonly onLost;
|
|
57
|
+
private readonly onRestore;
|
|
58
|
+
constructor(options: SharedContextOptions | undefined);
|
|
59
|
+
acquire(): WebGL2RenderingContext | null;
|
|
60
|
+
isAvailable(): boolean;
|
|
61
|
+
isDisposed(): boolean;
|
|
62
|
+
getChartCount(): number;
|
|
63
|
+
getStats(): SharedWebGLContextStats;
|
|
64
|
+
register(client: SharedChartClient): void;
|
|
65
|
+
unregister(client: SharedChartClient): void;
|
|
66
|
+
beginChartDraw(pixelWidth: number, pixelHeight: number): boolean;
|
|
67
|
+
/** Consume the clean baseline established by beginChartDraw() for the first drawGPU() in this chart frame. */
|
|
68
|
+
consumeCleanBaseline(): boolean;
|
|
69
|
+
present(target: CanvasRenderingContext2D | null, pixelWidth: number, pixelHeight: number): void;
|
|
70
|
+
dispose(): void;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Coordinates a single shared WebGL2 rendering context across multiple 2D charts.
|
|
74
|
+
* Always dispose charts registered to this context before calling dispose() on the context itself.
|
|
75
|
+
*/
|
|
76
|
+
export declare class SharedWebGLContext {
|
|
77
|
+
constructor(options?: SharedContextOptions);
|
|
78
|
+
/** Lazily acquires the shared WebGL2 context on first call and caches the result without retrying. */
|
|
79
|
+
isAvailable(): boolean;
|
|
80
|
+
isDisposed(): boolean;
|
|
81
|
+
/** Number of charts currently registered with this shared context. */
|
|
82
|
+
getChartCount(): number;
|
|
83
|
+
getStats(): SharedWebGLContextStats;
|
|
84
|
+
/** Idempotently disposes the shared context. Dispose all registered charts first. */
|
|
85
|
+
dispose(): void;
|
|
86
|
+
}
|
package/docs/npm-usage.md
CHANGED