@crysound/crychart 0.0.0-stage → 1.0.2
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 +288 -0
- package/LICENSE.zh-CN.md +290 -0
- package/README.md +82 -2
- package/README.zh-CN.md +79 -0
- package/dist/crychart.cjs +25234 -0
- package/dist/crychart.global.js +25236 -0
- package/dist/crychart.js +25211 -0
- package/dist/themes.js +357 -0
- package/dist/types/adapters/opentest.d.ts +69 -0
- package/dist/types/annotation-interaction.d.ts +36 -0
- package/dist/types/axis-canvas.d.ts +78 -0
- package/dist/types/axis-layout.d.ts +10 -0
- package/dist/types/axis-scroll-animation.d.ts +16 -0
- package/dist/types/axis.d.ts +532 -0
- package/dist/types/axis3d-label-layout.d.ts +45 -0
- package/dist/types/chart-events.d.ts +89 -0
- package/dist/types/chart.d.ts +674 -0
- package/dist/types/compatibility-types.d.ts +55 -0
- package/dist/types/component-highlight.d.ts +21 -0
- package/dist/types/contracts.d.ts +88 -0
- package/dist/types/core/data.d.ts +204 -0
- package/dist/types/core/events.d.ts +16 -0
- package/dist/types/core/line-delta-certificate.d.ts +70 -0
- package/dist/types/core/paged-columns.d.ts +180 -0
- package/dist/types/core/styles.d.ts +350 -0
- package/dist/types/css-text-fonts.d.ts +13 -0
- package/dist/types/cursor-api.d.ts +47 -0
- package/dist/types/custom-icon.d.ts +46 -0
- package/dist/types/data-bounds.d.ts +28 -0
- package/dist/types/data-order.d.ts +49 -0
- package/dist/types/data-runs.d.ts +15 -0
- package/dist/types/date-time-formatting.d.ts +32 -0
- package/dist/types/date-time-grid.d.ts +56 -0
- package/dist/types/formatting-functions.d.ts +16 -0
- package/dist/types/geometry.d.ts +378 -0
- package/dist/types/gradients.d.ts +37 -0
- package/dist/types/grid-layout.d.ts +10 -0
- package/dist/types/heatmap-stream.d.ts +38 -0
- package/dist/types/hierarchy.d.ts +191 -0
- package/dist/types/index.d.ts +75 -0
- package/dist/types/interaction-policy.d.ts +56 -0
- package/dist/types/line-block-cache.d.ts +146 -0
- package/dist/types/line-coverage-geometry.d.ts +28 -0
- package/dist/types/line-display-arena.d.ts +64 -0
- package/dist/types/line-display-cache.d.ts +144 -0
- package/dist/types/line-display-packets.d.ts +43 -0
- package/dist/types/line-extrema-pair-proof.d.ts +23 -0
- package/dist/types/line-palette-3d.d.ts +6 -0
- package/dist/types/line-selection-ledger.d.ts +143 -0
- package/dist/types/map.d.ts +219 -0
- package/dist/types/mesh3d.d.ts +306 -0
- package/dist/types/native-legend.d.ts +208 -0
- package/dist/types/point-fill.d.ts +14 -0
- package/dist/types/point-stroke-geometry.d.ts +12 -0
- package/dist/types/polar-heatmap.d.ts +68 -0
- package/dist/types/polar-layout.d.ts +100 -0
- package/dist/types/polar-series.d.ts +79 -0
- package/dist/types/raster-clip.d.ts +37 -0
- package/dist/types/render-heatmap.d.ts +117 -0
- package/dist/types/render-line-coverage.d.ts +95 -0
- package/dist/types/render-line-direction.d.ts +27 -0
- package/dist/types/render-line-offsets.d.ts +61 -0
- package/dist/types/render-line-strip.d.ts +102 -0
- package/dist/types/render-line-texture.d.ts +30 -0
- package/dist/types/render.d.ts +66 -0
- package/dist/types/render3d.d.ts +137 -0
- package/dist/types/result-table-layout.d.ts +39 -0
- package/dist/types/series-attributes.d.ts +7 -0
- package/dist/types/series.d.ts +404 -0
- package/dist/types/specialty.d.ts +551 -0
- package/dist/types/streaming-line-policy.d.ts +11 -0
- package/dist/types/stroke-geometry.d.ts +5 -0
- package/dist/types/themes.d.ts +32 -0
- package/dist/types/time-formatting.d.ts +23 -0
- package/dist/types/time-grid.d.ts +26 -0
- package/dist/types/ui.d.ts +207 -0
- package/dist/types/viewport.d.ts +18 -0
- package/dist/types/world-axis.d.ts +21 -0
- package/dist/types/world-camera.d.ts +88 -0
- package/dist/types/zoom-clock.d.ts +36 -0
- package/docs/npm-usage.md +31 -0
- package/package.json +66 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/** Public types for CRYChart contexts, data and interaction surfaces. These
|
|
2
|
+
* aliases describe the implemented objects without adding runtime behavior. */
|
|
3
|
+
import type { Axis } from './axis.js';
|
|
4
|
+
import type { ChartOptions, Polar } from './chart.js';
|
|
5
|
+
import type { Interval, Point } from './contracts.js';
|
|
6
|
+
import type { DataSetSchema } from './core/data.js';
|
|
7
|
+
import type { GeometryOptions, GeometrySeries } from './geometry.js';
|
|
8
|
+
import type { cryChart } from './index.js';
|
|
9
|
+
import type { HeatmapSeries, PointLineAreaSeries, SeriesOptions } from './series.js';
|
|
10
|
+
import type { Cursor, UIElement } from './ui.js';
|
|
11
|
+
export type AxisInterval = Interval;
|
|
12
|
+
export interface AxisIntervalConfiguration {
|
|
13
|
+
start?: number;
|
|
14
|
+
end?: number;
|
|
15
|
+
stopAxisAfter?: boolean;
|
|
16
|
+
}
|
|
17
|
+
export type CursorXY = Cursor;
|
|
18
|
+
/** TextBox builders return the implemented UIElement text, layout and lifecycle surface. */
|
|
19
|
+
export type UITextBox = UIElement;
|
|
20
|
+
export type DataSetXYSchema = DataSetSchema;
|
|
21
|
+
export type CRYChart = ReturnType<typeof cryChart>;
|
|
22
|
+
export type CRYChartOptions = NonNullable<Parameters<typeof cryChart>[0]>;
|
|
23
|
+
export type ChartXYOptions = ChartOptions;
|
|
24
|
+
export type Chart3DOptions = ChartOptions;
|
|
25
|
+
export type PointLineAreaSeriesOptions = SeriesOptions;
|
|
26
|
+
export type RectangleSeriesOptions = GeometryOptions;
|
|
27
|
+
export type SeriesXY = PointLineAreaSeries | GeometrySeries | HeatmapSeries;
|
|
28
|
+
export type LineSeries3D = PointLineAreaSeries;
|
|
29
|
+
export type PointSeries3D = PointLineAreaSeries;
|
|
30
|
+
export type Point3D = Point & {
|
|
31
|
+
z: number;
|
|
32
|
+
};
|
|
33
|
+
export type PolarChart = Polar;
|
|
34
|
+
export type HeatmapScrollingGridSeriesIntensityValues = HeatmapSeries;
|
|
35
|
+
/** Only intensity heatmaps are implemented; color-packed heatmaps are not
|
|
36
|
+
* advertised by this compatibility type. */
|
|
37
|
+
export interface HeatmapScrollingGridSeriesOptions<DataType extends 'intensity' = 'intensity'> {
|
|
38
|
+
dataType?: DataType;
|
|
39
|
+
axisX?: Axis;
|
|
40
|
+
axisY?: Axis;
|
|
41
|
+
resolution?: number;
|
|
42
|
+
scrollDimension?: 'columns' | 'rows';
|
|
43
|
+
columns?: number;
|
|
44
|
+
rows?: number;
|
|
45
|
+
start?: {
|
|
46
|
+
x: number;
|
|
47
|
+
y: number;
|
|
48
|
+
};
|
|
49
|
+
step?: {
|
|
50
|
+
x: number;
|
|
51
|
+
y: number;
|
|
52
|
+
};
|
|
53
|
+
dataOrder?: 'columns' | 'rows';
|
|
54
|
+
legend?: Record<string, unknown> | null;
|
|
55
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { type Color, type Theme } from './core/styles.js';
|
|
2
|
+
/** Original time-based pulse. Timing/phase is not a vendor animation contract. */
|
|
3
|
+
export declare class ComponentHighlightState {
|
|
4
|
+
private configured;
|
|
5
|
+
private animated;
|
|
6
|
+
private active;
|
|
7
|
+
private startedAt;
|
|
8
|
+
private cancelled;
|
|
9
|
+
set(value: boolean | number): number;
|
|
10
|
+
get(): number;
|
|
11
|
+
setAnimation(enabled: boolean): void;
|
|
12
|
+
getAnimation(): boolean;
|
|
13
|
+
private finiteValue;
|
|
14
|
+
pending(visible?: boolean): boolean;
|
|
15
|
+
advance(timestamp: number, visible?: boolean): void;
|
|
16
|
+
strength(): number;
|
|
17
|
+
suspend(): void;
|
|
18
|
+
cancel(): void;
|
|
19
|
+
}
|
|
20
|
+
/** The public theme offset is in byte channels; styles and source colors stay immutable. */
|
|
21
|
+
export declare function highlightColor(color: Color, strength: number, theme: Theme): Color;
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { Icon } from './custom-icon.js';
|
|
2
|
+
export type Point = {
|
|
3
|
+
x: number;
|
|
4
|
+
y: number;
|
|
5
|
+
z?: number;
|
|
6
|
+
angle?: number;
|
|
7
|
+
amplitude?: number;
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
};
|
|
10
|
+
export type Interval = {
|
|
11
|
+
start: number;
|
|
12
|
+
end: number;
|
|
13
|
+
};
|
|
14
|
+
export type Mutator<T> = T | ((previous: T) => T);
|
|
15
|
+
export interface Rect {
|
|
16
|
+
left: number;
|
|
17
|
+
top: number;
|
|
18
|
+
width: number;
|
|
19
|
+
height: number;
|
|
20
|
+
}
|
|
21
|
+
export interface PlotDomain {
|
|
22
|
+
x: Interval;
|
|
23
|
+
y: Interval;
|
|
24
|
+
z?: Interval;
|
|
25
|
+
}
|
|
26
|
+
export interface DrawPacket {
|
|
27
|
+
id: number;
|
|
28
|
+
/** Consecutive packets belonging to one solid stroke. Coverage is merged
|
|
29
|
+
* before compositing its color, including block-boundary caps. */
|
|
30
|
+
strokeGroup?: number;
|
|
31
|
+
revision: number;
|
|
32
|
+
positions: Float32Array;
|
|
33
|
+
count: number;
|
|
34
|
+
dimensions: 2 | 3;
|
|
35
|
+
mode: "line" | "points" | "triangles";
|
|
36
|
+
color: [number, number, number, number];
|
|
37
|
+
thickness: number;
|
|
38
|
+
pointSize: number;
|
|
39
|
+
pointShape?: number;
|
|
40
|
+
/** Actual bitmap shape. Intrinsic RGBA is preserved rather than tinted as a vector shape. */
|
|
41
|
+
pointIcon?: Icon;
|
|
42
|
+
pointRotation?: number;
|
|
43
|
+
dashPattern?: readonly number[];
|
|
44
|
+
colors?: Float32Array;
|
|
45
|
+
pointSizes?: Float32Array;
|
|
46
|
+
pointRotations?: Float32Array;
|
|
47
|
+
pointStrokeColor?: [number, number, number, number];
|
|
48
|
+
pointStrokeThickness?: number;
|
|
49
|
+
/** Consecutive append optimization, valid only if the renderer has previousRevision. */
|
|
50
|
+
updateFrom?: number;
|
|
51
|
+
previousRevision?: number;
|
|
52
|
+
/** Position-pair patches relative to previousRevision. Valid only while the
|
|
53
|
+
* uploader retains that exact revision and enough GPU storage; otherwise it
|
|
54
|
+
* uploads the complete positions. Includes cap/halo edits as well as appends. */
|
|
55
|
+
dirtySampleRanges?: readonly {
|
|
56
|
+
first: number;
|
|
57
|
+
count: number;
|
|
58
|
+
}[];
|
|
59
|
+
/** Verified nondecreasing finite projected X values, for lossless viewport culling. */
|
|
60
|
+
monotonicX?: boolean;
|
|
61
|
+
/** No repeated X coordinates: permits sharing line joins without reversal ambiguity. */
|
|
62
|
+
strictlyMonotonicX?: boolean;
|
|
63
|
+
origin: {
|
|
64
|
+
x: number;
|
|
65
|
+
y: number;
|
|
66
|
+
z: number;
|
|
67
|
+
};
|
|
68
|
+
domain: PlotDomain;
|
|
69
|
+
logarithmic?: {
|
|
70
|
+
x: boolean;
|
|
71
|
+
y: boolean;
|
|
72
|
+
};
|
|
73
|
+
/** Optional clipping rectangle in chart CSS pixels for axes in separate stacks. */
|
|
74
|
+
clipRect?: Rect;
|
|
75
|
+
/** Optional owned sample range; surrounding stored samples supply line-join halos only. */
|
|
76
|
+
drawFirst?: number;
|
|
77
|
+
drawCount?: number;
|
|
78
|
+
}
|
|
79
|
+
export interface RenderHost {
|
|
80
|
+
invalidate(): void;
|
|
81
|
+
removeSeries(series: unknown): void;
|
|
82
|
+
getDefaultAxisX(): any;
|
|
83
|
+
getDefaultAxisY(): any;
|
|
84
|
+
getDefaultAxisZ?(): any;
|
|
85
|
+
}
|
|
86
|
+
export declare class UnsupportedFeatureError extends Error {
|
|
87
|
+
constructor(feature: string);
|
|
88
|
+
}
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import { type EventToken } from './events.js';
|
|
2
|
+
import { type PagedColumnView } from './paged-columns.js';
|
|
3
|
+
export type NumericArray = Float32Array | Float64Array | Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array;
|
|
4
|
+
export interface NumericStorage {
|
|
5
|
+
new (length: number): NumericArray;
|
|
6
|
+
}
|
|
7
|
+
export interface DataColumnSchema {
|
|
8
|
+
storage?: NumericStorage;
|
|
9
|
+
pattern?: 'progressive' | 'regressive' | string | null;
|
|
10
|
+
auto?: boolean;
|
|
11
|
+
[key: string]: unknown;
|
|
12
|
+
}
|
|
13
|
+
export type DataSetSchema = Record<string, DataColumnSchema>;
|
|
14
|
+
export interface PagedDataStorageOptions {
|
|
15
|
+
mode: 'paged';
|
|
16
|
+
pageSize?: number;
|
|
17
|
+
maxPoolBytesPerStorage?: number;
|
|
18
|
+
poolPagesPerStorage?: number;
|
|
19
|
+
poolHistoryLength?: number;
|
|
20
|
+
}
|
|
21
|
+
export interface DataSetXYOptions {
|
|
22
|
+
schema?: DataSetSchema;
|
|
23
|
+
includesNaN?: boolean;
|
|
24
|
+
columnStorage?: PagedDataStorageOptions;
|
|
25
|
+
}
|
|
26
|
+
export type SampleColumns = Record<string, ArrayLike<number> | undefined>;
|
|
27
|
+
export interface AppendSamplesOptions {
|
|
28
|
+
start?: number;
|
|
29
|
+
step?: number;
|
|
30
|
+
}
|
|
31
|
+
export type MaxSampleCount = number | {
|
|
32
|
+
mode: 'auto';
|
|
33
|
+
initial?: number;
|
|
34
|
+
max?: number;
|
|
35
|
+
} | undefined | null;
|
|
36
|
+
export interface ReadBackOptions {
|
|
37
|
+
onlyInRange?: {
|
|
38
|
+
key?: string | number;
|
|
39
|
+
start: number;
|
|
40
|
+
end: number;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface DataSetReadBack {
|
|
44
|
+
data: Record<string, NumericArray>;
|
|
45
|
+
iSampleFirst: number;
|
|
46
|
+
}
|
|
47
|
+
/** A retained part of this batch evaluates as start + (absoluteIndex - firstIndex) * step.
|
|
48
|
+
* Batch origins are deliberately never rebased: floating-point reassociation loses bits.
|
|
49
|
+
*/
|
|
50
|
+
export interface AffineColumnRun {
|
|
51
|
+
readonly firstIndex: number;
|
|
52
|
+
readonly count: number;
|
|
53
|
+
readonly start: number;
|
|
54
|
+
readonly step: number;
|
|
55
|
+
}
|
|
56
|
+
/** Internal borrowed storage view. All indices are absolute logical sample indices.
|
|
57
|
+
* Clip affine runs to [firstIndex, firstIndex + count); runStart skips expired runs.
|
|
58
|
+
* A data-set mutation invalidates the view. Reading it does not materialize automatic X.
|
|
59
|
+
*/
|
|
60
|
+
export type DataColumnRuns = {
|
|
61
|
+
kind: 'dense';
|
|
62
|
+
firstIndex: number;
|
|
63
|
+
count: number;
|
|
64
|
+
slices: readonly NumericArray[];
|
|
65
|
+
} | {
|
|
66
|
+
kind: 'affine';
|
|
67
|
+
firstIndex: number;
|
|
68
|
+
count: number;
|
|
69
|
+
runs: readonly AffineColumnRun[];
|
|
70
|
+
runStart: number;
|
|
71
|
+
} | PagedColumnView;
|
|
72
|
+
/** Storage directly held by this data set, excluding caller-held readbacks, renderer
|
|
73
|
+
* buffers and JavaScript heap overhead. These numbers are not process RSS.
|
|
74
|
+
*/
|
|
75
|
+
export interface DataSetStorageStats {
|
|
76
|
+
readonly sampleCount: number;
|
|
77
|
+
readonly capacity: number;
|
|
78
|
+
readonly denseTypedArrayBytes: number;
|
|
79
|
+
readonly snapshotBytes: number;
|
|
80
|
+
/** Includes expired run objects waiting for amortized prefix cleanup. */
|
|
81
|
+
readonly affineRunCount: number;
|
|
82
|
+
readonly liveAffineRunCount: number;
|
|
83
|
+
readonly autoColumnCount: number;
|
|
84
|
+
readonly affineColumnCount: number;
|
|
85
|
+
readonly denseColumnCount: number;
|
|
86
|
+
readonly pagedColumnCount: number;
|
|
87
|
+
readonly pagedUniqueBytes: number;
|
|
88
|
+
readonly pagedPoolBytes: number;
|
|
89
|
+
readonly pagedLogicalBytes: number;
|
|
90
|
+
readonly pagedLogicalPageBytes: number;
|
|
91
|
+
readonly pagedPageReferences: number;
|
|
92
|
+
readonly pagedPromotionCount: number;
|
|
93
|
+
readonly ownedNumericBytes: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Columnar ring storage with a logical sample index independent of physical capacity.
|
|
97
|
+
* Appends write at most the retained tail, so oversized batches do not allocate rows.
|
|
98
|
+
* Data belongs to the data set; attaching or disposing a series does not own it.
|
|
99
|
+
*/
|
|
100
|
+
export declare class DataSetXY {
|
|
101
|
+
private schemaSnapshot;
|
|
102
|
+
readonly includesNaN: boolean;
|
|
103
|
+
private readonly columns;
|
|
104
|
+
private readonly events;
|
|
105
|
+
private readonly snapshots;
|
|
106
|
+
private allocation;
|
|
107
|
+
private head;
|
|
108
|
+
private count;
|
|
109
|
+
private nextIndex;
|
|
110
|
+
private changeRevision;
|
|
111
|
+
private contentEpoch;
|
|
112
|
+
private mode;
|
|
113
|
+
private maxLimit;
|
|
114
|
+
private disposed;
|
|
115
|
+
private readonly pagedOptions?;
|
|
116
|
+
private paged?;
|
|
117
|
+
private pagedPromotionCount;
|
|
118
|
+
private inMutation;
|
|
119
|
+
private deferredChange;
|
|
120
|
+
constructor(options?: DataSetXYOptions);
|
|
121
|
+
get revision(): number;
|
|
122
|
+
get schema(): Readonly<DataSetSchema>;
|
|
123
|
+
/** Renderer access includes automatically generated, non-input coordinates. */
|
|
124
|
+
hasColumn(name: string): boolean;
|
|
125
|
+
get version(): number;
|
|
126
|
+
getSampleCount(): number;
|
|
127
|
+
getNextSampleIndex(): number;
|
|
128
|
+
/** Changes when existing logical sample identities are reset or destroyed.
|
|
129
|
+
* Appends, capacity changes and additional columns preserve retained identities.
|
|
130
|
+
*/
|
|
131
|
+
getContentEpoch(): number;
|
|
132
|
+
getMaxSampleCount(): number | undefined;
|
|
133
|
+
getStorageStats(): DataSetStorageStats;
|
|
134
|
+
getSchema(): DataSetSchema;
|
|
135
|
+
/** Internal automatic series coordinate, kept out of the raw input schema.
|
|
136
|
+
* Enable before the first append so each batch retains its own start and step.
|
|
137
|
+
*/
|
|
138
|
+
enableImplicitXColumn(): void;
|
|
139
|
+
onChange(listener: (dataSet: DataSetXY) => void): EventToken;
|
|
140
|
+
offChange(token: EventToken): boolean;
|
|
141
|
+
/** CRYChart extension: allocate only new columns without disturbing retained samples.
|
|
142
|
+
* Existing column definitions remain unchanged. An all-existing request is a no-op.
|
|
143
|
+
* Allocate the complete addition before committing so allocation failures are atomic.
|
|
144
|
+
*/
|
|
145
|
+
addColumns(schema: DataSetSchema): this;
|
|
146
|
+
private addColumnsInternal;
|
|
147
|
+
setMaxSampleCount(value?: MaxSampleCount): this;
|
|
148
|
+
private setMaxSampleCountInternal;
|
|
149
|
+
appendSamples(samples: SampleColumns, options?: AppendSamplesOptions): this;
|
|
150
|
+
private appendCertified;
|
|
151
|
+
/** Opt-in path: retain only private new pages and bounded dense input drafts
|
|
152
|
+
* until every getter, conversion and allocation succeeds. Dense default above
|
|
153
|
+
* stays on its existing allocation/copy path. */
|
|
154
|
+
private appendPaged;
|
|
155
|
+
/** CRYChart internal replacement transaction. Retains this data-set identity,
|
|
156
|
+
* schema and retention policy; resets absolute indices and automatic coordinates
|
|
157
|
+
* to a new sequence. Validation, allocation and input reads happen on isolated
|
|
158
|
+
* storage through the existing append path. Only a complete result is published.
|
|
159
|
+
* A notification listener can still throw after the replacement is committed.
|
|
160
|
+
*/
|
|
161
|
+
replaceSamples(samples: SampleColumns, options?: AppendSamplesOptions): this;
|
|
162
|
+
private replaceSamplesInternal;
|
|
163
|
+
/** Internal renderer access. Unlike getColumnSlices this keeps automatic X implicit. */
|
|
164
|
+
getColumnRuns(name: string): DataColumnRuns;
|
|
165
|
+
/** CRYChart internal extension: at most two borrowed views in retained logical order.
|
|
166
|
+
* Automatic Float64 columns materialize once on the first nonempty request. Later
|
|
167
|
+
* calls borrow the same dense ring without a whole-column copy. Callers must not
|
|
168
|
+
* write; reacquire after any data-set mutation. getColumnRuns avoids materialization.
|
|
169
|
+
* Unlike getColumn, these views can observe later writes into the same ring storage.
|
|
170
|
+
*/
|
|
171
|
+
getColumnSlices(name: string): readonly NumericArray[];
|
|
172
|
+
/** Cached logical-order column. Treat the returned snapshot as read-only. */
|
|
173
|
+
getColumn(name: string): NumericArray;
|
|
174
|
+
/** Direct, allocation-free access by offset within retained samples. */
|
|
175
|
+
getValue(name: string, retainedOffset: number): number | undefined;
|
|
176
|
+
/** Read by logical offset within retained samples, independent of the ring head. */
|
|
177
|
+
getSample(offset: number): Record<string, number> | undefined;
|
|
178
|
+
getSampleByIndex(index: number): Record<string, number> | undefined;
|
|
179
|
+
readBack(options?: ReadBackOptions): DataSetReadBack;
|
|
180
|
+
clear(): this;
|
|
181
|
+
private clearInternal;
|
|
182
|
+
dispose(): this;
|
|
183
|
+
private disposeInternal;
|
|
184
|
+
isDisposed(): boolean;
|
|
185
|
+
private deltaSourceHeader;
|
|
186
|
+
private changed;
|
|
187
|
+
private assertAlive;
|
|
188
|
+
private mutateAtomically;
|
|
189
|
+
private validateAppend;
|
|
190
|
+
private appendAllocation;
|
|
191
|
+
private assertPrivateAllocation;
|
|
192
|
+
private resize;
|
|
193
|
+
private findRun;
|
|
194
|
+
private pruneRuns;
|
|
195
|
+
private copyColumn;
|
|
196
|
+
private materialize;
|
|
197
|
+
private findRange;
|
|
198
|
+
private copyInput;
|
|
199
|
+
}
|
|
200
|
+
/** Bounds for drawing deliberately ignore gaps without changing source storage. */
|
|
201
|
+
export declare function finiteExtent(values: ArrayLike<number>): {
|
|
202
|
+
min: number;
|
|
203
|
+
max: number;
|
|
204
|
+
} | undefined;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Subscription identity is independent of event name and callback identity. */
|
|
2
|
+
export type EventToken = symbol;
|
|
3
|
+
export type Token = EventToken;
|
|
4
|
+
export type EventListener = (...args: any[]) => void;
|
|
5
|
+
/** Small synchronous event dispatcher. Mutations during delivery are deterministic. */
|
|
6
|
+
export declare class EventHub {
|
|
7
|
+
private readonly listeners;
|
|
8
|
+
private readonly names;
|
|
9
|
+
on(name: string | symbol, listener: EventListener): EventToken;
|
|
10
|
+
once(name: string | symbol, listener: EventListener): EventToken;
|
|
11
|
+
off(token: EventToken): boolean;
|
|
12
|
+
off(name: string | symbol, token: EventToken): boolean;
|
|
13
|
+
emit(name: string | symbol, ...args: any[]): void;
|
|
14
|
+
clear(name?: string | symbol): void;
|
|
15
|
+
listenerCount(name?: string | symbol): number;
|
|
16
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
/** Artifact-only producer contract. It owns numbers, never borrowed columns. */
|
|
2
|
+
export interface SourceHeader {
|
|
3
|
+
revision: number;
|
|
4
|
+
epoch: number;
|
|
5
|
+
first: number;
|
|
6
|
+
next: number;
|
|
7
|
+
capacity: number;
|
|
8
|
+
head: number;
|
|
9
|
+
paged: boolean;
|
|
10
|
+
pageSize: number;
|
|
11
|
+
disposed: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface SourceCertificate extends Readonly<SourceHeader> {
|
|
14
|
+
readonly producer: number;
|
|
15
|
+
readonly serial: number;
|
|
16
|
+
readonly lineage: number;
|
|
17
|
+
readonly reason: string;
|
|
18
|
+
/** A failed dense input read can have written bytes without a revision.
|
|
19
|
+
* The unchanged selector cannot certify its old cache until a new epoch. */
|
|
20
|
+
readonly tainted: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface AppendTicket {
|
|
23
|
+
readonly before: Readonly<SourceHeader>;
|
|
24
|
+
readonly prior?: SourceCertificate;
|
|
25
|
+
}
|
|
26
|
+
export interface CertifiedSourceDelta {
|
|
27
|
+
readonly kind: 'unchanged' | 'append-prefix';
|
|
28
|
+
readonly previous: SourceCertificate;
|
|
29
|
+
readonly current: SourceCertificate;
|
|
30
|
+
/** All original values in this absolute interval are unchanged. */
|
|
31
|
+
readonly stableFirst: number;
|
|
32
|
+
readonly stableEnd: number;
|
|
33
|
+
readonly appendedFirst: number;
|
|
34
|
+
readonly appendedEnd: number;
|
|
35
|
+
/** Storage ranges are diagnostic only. Selection always uses absolute indices. */
|
|
36
|
+
readonly physicalWrites: readonly {
|
|
37
|
+
first: number;
|
|
38
|
+
count: number;
|
|
39
|
+
}[];
|
|
40
|
+
readonly physicalKind: 'ring-slots-for-dense-columns';
|
|
41
|
+
/** Configured paged data sets can contain promoted dense columns as well.
|
|
42
|
+
* This envelope applies only to columns that still use absolute pages. */
|
|
43
|
+
readonly pagedWrites?: {
|
|
44
|
+
readonly firstPage: number;
|
|
45
|
+
readonly pageCount: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export type SourceDeltaResult = {
|
|
49
|
+
delta: CertifiedSourceDelta;
|
|
50
|
+
reason?: never;
|
|
51
|
+
} | {
|
|
52
|
+
delta?: never;
|
|
53
|
+
reason: string;
|
|
54
|
+
};
|
|
55
|
+
/** Captured before any user getter, copy or mutation can re-enter the producer. */
|
|
56
|
+
export declare function beginSourceAppend(owner: object, header: SourceHeader): AppendTicket;
|
|
57
|
+
/** Called after the complete source write, before the change event is emitted. */
|
|
58
|
+
export declare function commitSourceChange(owner: object, header: SourceHeader, ticket?: AppendTicket): SourceCertificate;
|
|
59
|
+
/** Representation changes and failures break the lineage even without revision changes. */
|
|
60
|
+
export declare function invalidateSourceCertificate(owner: object, header: SourceHeader, reason: string): void;
|
|
61
|
+
export declare function readSourceCertificate(owner: object, expected?: Pick<SourceHeader, 'revision' | 'epoch' | 'first' | 'next'>): SourceCertificate | undefined;
|
|
62
|
+
/** Proves an arbitrary number of commits, not just a revision increment of one. */
|
|
63
|
+
export declare function certifySourceDelta(owner: object, previous: SourceCertificate | undefined, expected: Pick<SourceHeader, 'revision' | 'epoch' | 'first' | 'next'>): SourceDeltaResult;
|
|
64
|
+
/** A page needs both original neighbors before it can be an immutable interior.
|
|
65
|
+
* The partial head, old tail and the page which just gained a right neighbor
|
|
66
|
+
* deliberately stay on the original selector. */
|
|
67
|
+
export declare function certifiedCompletePageRange(delta: CertifiedSourceDelta, pageSize: number, previousVisibleFirst: number, previousVisibleEnd: number, visibleFirst: number, visibleEnd: number): {
|
|
68
|
+
firstPage: number;
|
|
69
|
+
endPage: number;
|
|
70
|
+
};
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { NumericArray, NumericStorage, SampleColumns } from './data.js';
|
|
2
|
+
/** Experimental explicit-column storage. It is not used by DataSetXY yet. Automatic
|
|
3
|
+
* coordinates remain the responsibility of the existing affine-column backend. */
|
|
4
|
+
export interface PagedColumnDefinition {
|
|
5
|
+
storage?: NumericStorage;
|
|
6
|
+
}
|
|
7
|
+
export type PagedColumnsSchema = Record<string, PagedColumnDefinition>;
|
|
8
|
+
export interface PagedColumnsOptions {
|
|
9
|
+
schema: PagedColumnsSchema;
|
|
10
|
+
capacity: number;
|
|
11
|
+
pageSize?: number;
|
|
12
|
+
/** Fault-injection/measurement hook. Return a fresh, exclusively owned page. */
|
|
13
|
+
allocator?: (storage: NumericStorage, length: number) => NumericArray;
|
|
14
|
+
/** Optional fixed reusable-page limit. Omit for a bounded adaptive pool. */
|
|
15
|
+
poolPagesPerStorage?: number;
|
|
16
|
+
/** Hard byte bound for each constructor's adaptive pool; default 256 KiB. */
|
|
17
|
+
maxPoolBytesPerStorage?: number;
|
|
18
|
+
/** Adaptive targets use the largest draft set in this many recent successful
|
|
19
|
+
* appends, plus one head/tail-slack page per column; default 16 appends. */
|
|
20
|
+
poolHistoryLength?: number;
|
|
21
|
+
}
|
|
22
|
+
/** Borrowed read-only page view, invalid after any mutation. An absolute sample i
|
|
23
|
+
* uses page floor(i/pageSize), at offset i - pageIndex*pageSize. Only samples in
|
|
24
|
+
* [firstIndex, firstIndex+count) are valid; unused page bytes are NOT observations.
|
|
25
|
+
* getPage is a direct map lookup, not a search through preceding pages. */
|
|
26
|
+
export interface PagedColumnView {
|
|
27
|
+
readonly kind: 'paged';
|
|
28
|
+
readonly firstIndex: number;
|
|
29
|
+
readonly count: number;
|
|
30
|
+
readonly pageSize: number;
|
|
31
|
+
readonly revision: number;
|
|
32
|
+
readonly storage: NumericStorage;
|
|
33
|
+
readonly bytesPerElement: number;
|
|
34
|
+
getPage(absolutePageIndex: number): NumericArray | undefined;
|
|
35
|
+
}
|
|
36
|
+
/** Internal two-phase append. All constructors, input getters and byte comparisons
|
|
37
|
+
* finish before this is returned. commit publishes once; abort leaves the old
|
|
38
|
+
* column views, counters and logical sample identities unchanged. */
|
|
39
|
+
export interface PreparedPagedAppend {
|
|
40
|
+
readonly sampleCount: number;
|
|
41
|
+
readonly nextIndex: number;
|
|
42
|
+
readonly capacity: number;
|
|
43
|
+
commit(): void;
|
|
44
|
+
abort(): void;
|
|
45
|
+
}
|
|
46
|
+
export interface PagedColumnsStats {
|
|
47
|
+
readonly capacity: number;
|
|
48
|
+
readonly sampleCount: number;
|
|
49
|
+
readonly firstIndex: number;
|
|
50
|
+
readonly nextIndex: number;
|
|
51
|
+
readonly pageSize: number;
|
|
52
|
+
readonly columnCount: number;
|
|
53
|
+
/** Actual live, unique owned page bytes, including partial-page slack. */
|
|
54
|
+
readonly uniquePageBytes: number;
|
|
55
|
+
readonly uniquePageCount: number;
|
|
56
|
+
/** Actual bounded reusable pages. Include these when reporting allocated bytes. */
|
|
57
|
+
readonly pooledPageBytes: number;
|
|
58
|
+
readonly pooledPageCount: number;
|
|
59
|
+
readonly allocatedPageBytes: number;
|
|
60
|
+
/** Target pool capacity, not an allocation. Actual arrays are pooledPageBytes. */
|
|
61
|
+
readonly poolTargetPages: number;
|
|
62
|
+
readonly poolTargetBytes: number;
|
|
63
|
+
/** Physical bytes if each currently mapped logical page were independent. */
|
|
64
|
+
readonly logicalPageBytes: number;
|
|
65
|
+
readonly logicalPageReferences: number;
|
|
66
|
+
/** Retained samples * each column's element width, without page slack. */
|
|
67
|
+
readonly logicalSampleBytes: number;
|
|
68
|
+
readonly sharedPageCount: number;
|
|
69
|
+
readonly sharedReferences: number;
|
|
70
|
+
/** Object counts only; no claim about JavaScript heap bytes. */
|
|
71
|
+
readonly pageMapEntries: number;
|
|
72
|
+
readonly appendCount: number;
|
|
73
|
+
readonly appendedSamples: number;
|
|
74
|
+
readonly discardedInputSamples: number;
|
|
75
|
+
readonly pageAllocations: number;
|
|
76
|
+
readonly poolReuses: number;
|
|
77
|
+
readonly deduplicatedDrafts: number;
|
|
78
|
+
readonly sharedInputMatches: number;
|
|
79
|
+
readonly inputCopySkippedBytes: number;
|
|
80
|
+
readonly identityInputMatches: number;
|
|
81
|
+
readonly identityComparedBytesSkipped: number;
|
|
82
|
+
readonly inputCopiedBytes: number;
|
|
83
|
+
readonly retainedCopiedBytes: number;
|
|
84
|
+
readonly comparedBytes: number;
|
|
85
|
+
readonly pageComparisons: number;
|
|
86
|
+
readonly peakStagedPageBytes: number;
|
|
87
|
+
}
|
|
88
|
+
/** Page sharing is limited to columns in the same store at the same absolute page.
|
|
89
|
+
* It never guesses aliases from column names or from numeric equality. Candidate
|
|
90
|
+
* pages are compared by their normalized typed bytes over the retained interval.
|
|
91
|
+
* A transaction writes only private drafts and publishes after all conversions,
|
|
92
|
+
* allocations and comparisons succeed. Existing readers therefore see the entire
|
|
93
|
+
* old state if an allocator or an input getter throws. */
|
|
94
|
+
export declare class PagedColumns {
|
|
95
|
+
private readonly columns;
|
|
96
|
+
private readonly livePages;
|
|
97
|
+
private readonly ownedBuffers;
|
|
98
|
+
private pools;
|
|
99
|
+
private readonly allocator;
|
|
100
|
+
private readonly fixedPoolLimit;
|
|
101
|
+
private readonly maxPoolBytes;
|
|
102
|
+
private readonly poolHistoryLength;
|
|
103
|
+
private readonly userAllocator;
|
|
104
|
+
private readonly poolHistory;
|
|
105
|
+
private poolTargets;
|
|
106
|
+
private readonly totals;
|
|
107
|
+
private schemaSnapshot;
|
|
108
|
+
private capacity;
|
|
109
|
+
private count;
|
|
110
|
+
private nextIndex;
|
|
111
|
+
private changeRevision;
|
|
112
|
+
private contentEpoch;
|
|
113
|
+
private disposed;
|
|
114
|
+
private pending?;
|
|
115
|
+
readonly pageSize: number;
|
|
116
|
+
constructor(options: PagedColumnsOptions);
|
|
117
|
+
get schema(): Readonly<PagedColumnsSchema>;
|
|
118
|
+
get revision(): number;
|
|
119
|
+
getSampleCount(): number;
|
|
120
|
+
getNextSampleIndex(): number;
|
|
121
|
+
getContentEpoch(): number;
|
|
122
|
+
getCapacity(): number;
|
|
123
|
+
isDisposed(): boolean;
|
|
124
|
+
/** Internal allocator-alias guard; constant-time, without walking page maps. */
|
|
125
|
+
ownsBuffer(buffer: ArrayBufferLike): boolean;
|
|
126
|
+
appendSamples(samples: SampleColumns): this;
|
|
127
|
+
/** Explicit amount supports an all-omitted paged group while affine columns
|
|
128
|
+
* still advance. Capacity is committed atomically with the new page tail. */
|
|
129
|
+
prepareAppendSamples(samples: SampleColumns, sampleCount?: number, capacity?: number): PreparedPagedAppend;
|
|
130
|
+
/** Growing the limit does not allocate unwritten pages. Shrinking discards only
|
|
131
|
+
* the oldest logical samples; retained pages keep their absolute addresses. */
|
|
132
|
+
resize(capacity: number): this;
|
|
133
|
+
/** New columns contain the same typed NaN/zero fill as an omitted append column.
|
|
134
|
+
* Existing schema entries and the old frozen schema snapshot are untouched. */
|
|
135
|
+
addColumns(schema: PagedColumnsSchema): this;
|
|
136
|
+
/** Representation promotion detaches only this logical column. Other columns
|
|
137
|
+
* keep shared page references; live data is not copied or changed here. */
|
|
138
|
+
removeColumn(name: string): this;
|
|
139
|
+
getValue(name: string, retainedOffset: number): number | undefined;
|
|
140
|
+
/** Independent caller-owned snapshot; copying typed bytes preserves NaN payloads. */
|
|
141
|
+
readColumn(name: string, from?: number, count?: number): NumericArray;
|
|
142
|
+
getColumnView(name: string): PagedColumnView;
|
|
143
|
+
getStorageStats(): PagedColumnsStats;
|
|
144
|
+
clear(): this;
|
|
145
|
+
dispose(): this;
|
|
146
|
+
private assertAlive;
|
|
147
|
+
private requireColumn;
|
|
148
|
+
private makeColumn;
|
|
149
|
+
private transaction;
|
|
150
|
+
private acquire;
|
|
151
|
+
private copyInput;
|
|
152
|
+
/** A shared old prefix is already byte-identical. Compare only the incoming
|
|
153
|
+
* typed span before acquiring another draft; equal data is then written once.
|
|
154
|
+
* Ordinary arrays/conversions still take the staged conversion path. Mutable
|
|
155
|
+
* shared-memory input is excluded from this optimization. */
|
|
156
|
+
private matchInput;
|
|
157
|
+
private equalInputBytes;
|
|
158
|
+
private intern;
|
|
159
|
+
private equalBytes;
|
|
160
|
+
private publish;
|
|
161
|
+
private release;
|
|
162
|
+
private evictBefore;
|
|
163
|
+
/** Bounded metadata only: at most poolHistoryLength numbers per constructor.
|
|
164
|
+
* No retained-page map or history samples are copied or traversed here. */
|
|
165
|
+
private computePoolTargets;
|
|
166
|
+
private trimPools;
|
|
167
|
+
}
|
|
168
|
+
/** Cursor holds one page span at a time. Seek uses a direct absolute-page lookup;
|
|
169
|
+
* next advances to the following span. It allocates no object for each sample. */
|
|
170
|
+
export declare class PagedColumnCursor {
|
|
171
|
+
readonly view: PagedColumnView;
|
|
172
|
+
values: NumericArray | undefined;
|
|
173
|
+
absoluteIndex: number;
|
|
174
|
+
offset: number;
|
|
175
|
+
length: number;
|
|
176
|
+
constructor(view: PagedColumnView, absoluteIndex?: number);
|
|
177
|
+
seek(absoluteIndex: number): boolean;
|
|
178
|
+
next(): boolean;
|
|
179
|
+
}
|
|
180
|
+
export declare function readPagedValue(view: PagedColumnView, absoluteIndex: number): number | undefined;
|