@kymoscope/sdk 0.21.0 → 0.22.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.
@@ -92,3 +92,17 @@ export declare const REVIEW_ACTIONS = 5, REVIEW_SUMMARY = 3;
92
92
  * sentences citing findings or results. Every number written must be in what it rests on (an action: its own text and
93
93
  * what it cites; a reason: any finding or result). Malformed input never throws. */
94
94
  export declare function checkReview(input: ReviewCheckInput, ai: unknown): ReviewChecked;
95
+ /** A sentence of a handover or of an answer to a question, as checked: kept even when it fails, marked unverified. */
96
+ export interface CitedSentence extends AiSentence {
97
+ verified: boolean;
98
+ }
99
+ /** Most characters of a cited sentence kept (a longer one is cut, and unverified). */
100
+ export declare const CITED_CHARS = 600;
101
+ /** Sentences that each cite the items they rest on (`items`: an id and the item's text, usually its JSON): verified
102
+ * when the sentence cites at least one item, every cite exists, it fits the sentence caps and states no number its
103
+ * cited items don't (an item's negative number also counts unsigned). A sentence that fails is kept with `verified`
104
+ * false, so the reader sees it marked; one with no text is dropped. At most `max`. Malformed input never throws. */
105
+ export declare function checkCited(sentences: unknown, items: Array<{
106
+ id: string;
107
+ text: string;
108
+ }>, max: number): CitedSentence[];
@@ -3,7 +3,7 @@
3
3
  * namespace, plus the few names the app's viewer and PDF use. */
4
4
  export { buildReport, listedFindings, viewSections } from './report';
5
5
  export { AI_NOTE, AI_SENTENCES, AI_WORDS, aiInput, applyAi, type AiInput, type AiSentence, type AiText } from './ai';
6
- export { checkReview, type ReviewChecked } from './aiCheck';
6
+ export { checkCited, checkReview, type CitedSentence, type ReviewChecked } from './aiCheck';
7
7
  export { KNOWN_GROWTH, KNOWN_MAX, KNOWN_REASONS, KNOWN_REASON_TEXT, applyKnown, findingSignature, grew, type KnownFinding, type KnownReason } from './known';
8
8
  export { REVIEW_CHECKS, applyReview, parseChecks, reviewPack, runChecks, type Check, type CheckResult, type ReportReview, type ReviewPack, type ReviewVerdict } from './review';
9
9
  export { CHANNEL_ROLES, CHANNEL_ROLE_TEXT, PROCESS_MAX, completeness, confirmAll, confirmed, contextGaps, moneyGaps, emptyChannel, emptyContext, energyChannel, parseContext, roleOf, shiftOf, stopSpans, suggestedCount, type PlannedStop, type ChannelContext, type ChannelRole, type ContextGap, type ProcessContext, type Shift, } from './context';
@@ -17,7 +17,7 @@ export interface Preset {
17
17
  roles: Partial<Record<SectionId, ReportRole[]>>;
18
18
  /** The report's words in this industry, lower case, whole words or phrases ("batches" → "parts"). */
19
19
  terms: Record<string, string>;
20
- /** A regulated industry (pharma, food): a project that takes this style starts with AI writing off (a lead can turn it on). */
20
+ /** A regulated industry (pharma, food): reports in this style are worded from the fixed templates, never by the AI. */
21
21
  regulated?: true;
22
22
  }
23
23
  export declare const PRESETS: Record<PresetId, Preset>;
@@ -2,6 +2,7 @@ import { type KymoscopeEngine } from '../engine/createEngine';
2
2
  import { type ChartStatus, type ContextMenuEvent } from './ChartBody';
3
3
  import { type AnnotationTool, type ChartAnnotation } from '../lib/annotations';
4
4
  import type { ChartMark } from '../engine/alerts';
5
+ import { type PanelChartSettings } from '../lib/panelChartSettings';
5
6
  import { type PlotFrame } from '../lib/render/plotFrame';
6
7
  export interface ChartStyle {
7
8
  /** Plot background (overrides the chart's own background setting). */
@@ -69,6 +70,9 @@ export declare function disposeCharts(engine: KymoscopeEngine): void;
69
70
  * The alert marks a chart shows: those of a plotted dataset or stream whose rule ran on the chart's X key (D6: a chart
70
71
  * on another axis has no time relation). Memoised on its inputs so charts don't redraw for nothing.
71
72
  */
73
+ /** The column a chart's X axis plots, for its alert marks: the worksheet's X on a multiband, the X column on an
74
+ * X-Y scatter; '' on charts whose X is no column (spectrum frequency, histogram bins, categories…). */
75
+ export declare function chartTimeX(settings: PanelChartSettings | undefined, worksheetX: string): string;
72
76
  export declare const chartMarks: (a: ChartMark[], b: string[], c: string) => ChartMark[];
73
77
  /** What PNG export paints: the alert marks (under) and the chart's annotations; open marks end at the plot's edge. */
74
78
  export declare function exportNotes(notes: ChartAnnotation[], marks: ChartMark[], frame: PlotFrame | null): ChartAnnotation[];
@@ -0,0 +1 @@
1
+ export declare function attachTouchGestures(root: HTMLElement): () => void;
@@ -28,6 +28,12 @@ import type { GanttTask } from '../components/GanttChart';
28
28
  import { type XYColumns } from '../lib/data/xyColumns';
29
29
  import { type Dataset, type DatasetRow } from '../lib/parseDataset';
30
30
  import type { DuckDbLayerSpec } from '../components/DuckDbMultiBandPanel';
31
+ /** The first plotted source that has `col`, as a column of its own or a math channel it evaluates (`okByPart`). */
32
+ export declare function firstWithColumn(sources: {
33
+ data: {
34
+ columnNames: string[];
35
+ };
36
+ }[], okByPart: string[][] | undefined, col: string): number;
31
37
  export interface WorksheetDataInput {
32
38
  worksheet: Worksheet;
33
39
  viewXRange: [number, number] | null;
@@ -104,6 +110,7 @@ export declare function useWorksheetData(input: WorksheetDataInput): {
104
110
  spectrogramDataByPanel: Record<string, {
105
111
  signal: Float64Array;
106
112
  rate: number;
113
+ times?: Float64Array;
107
114
  }>;
108
115
  heatmapDataByPanel: Record<string, {
109
116
  cells: HeatmapCell[];
@@ -12,4 +12,6 @@ export interface HistogramChartProps {
12
12
  clientY: number;
13
13
  }) => void;
14
14
  }
15
+ /** Y tick values, in counts: 1, 10, 100… up to yMax on a log axis (yMax is in decades there), else nice steps. */
16
+ export declare function histogramYTicks(maxCount: number, yMax: number, logY: boolean): number[];
15
17
  export declare function HistogramChart({ values, label, bins: binsProp, color, showNormal, logY, height, backgroundToken, onPlotContextMenu, }: HistogramChartProps): import("react/jsx-runtime").JSX.Element;
@@ -52,6 +52,28 @@ export interface LiveChartSource {
52
52
  /** The stream's id: charts showing the same stream share one playout (see streamPlayout), so they show one instant. */
53
53
  id?: string;
54
54
  }
55
+ interface LegendGroup {
56
+ /** Display name (base channel name, `__N` stripped). */
57
+ base: string;
58
+ /** First member — determines band position and anchor. */
59
+ leader: PlotSeries;
60
+ /** All members in their original series order. */
61
+ members: PlotSeries[];
62
+ }
63
+ /**
64
+ * Which series draw a Y axis column: one per distinct band + scale. Legend groups (the same channel of several
65
+ * datasets) draw their leader's; other series on the same band with the same scale and ticks (same unit, same
66
+ * scale) share the first one's axis. `shared`: every series whose axis column stands for more than one series.
67
+ */
68
+ /**
69
+ * Where a band's tick label sits on its tick: one at a band edge that touches another band is drawn inside its own
70
+ * band (above a bottom edge, below a top edge), so it never lands on the next band's label ("0" over "150").
71
+ */
72
+ export declare function bandTickBaseline(y: number, bandTop: number, bandBottom: number, plotTop: number, plotBottom: number): CanvasTextBaseline;
73
+ export declare function axisLeaders(groups: Pick<LegendGroup, 'leader'>[]): {
74
+ leaders: Set<string>;
75
+ shared: Set<string>;
76
+ };
55
77
  /**
56
78
  * Per-series X gap threshold: consecutive valid points farther apart than this
57
79
  * are not joined by a line. Derived from the series' OWN mean spacing so a
@@ -164,3 +186,4 @@ export interface MultiBandCanvasChartProps {
164
186
  onCursorX?: (x: number | null) => void;
165
187
  }
166
188
  export declare function MultiBandCanvasChart({ xLabel, series, points, columnUnits, height, onPlotContextMenu, backgroundToken, viewXRange, onViewXRangeChange, liveZoom, liveZoomId, fullXRange, shiftMode, xAxisLine, yAxisLine, gridLine, lineWidth, envelopes, showLatestValues, liveSource, liveWindowSeconds, onLiveWindowChange, liveZoomMode, onPlotWidthCss, onCursorX, }: MultiBandCanvasChartProps): import("react/jsx-runtime").JSX.Element;
189
+ export {};
@@ -6,6 +6,9 @@ export interface SpectrogramChartProps {
6
6
  winFunc?: 'hann' | 'rectangular';
7
7
  yMode?: 'amplitude' | 'db';
8
8
  logFreq?: boolean;
9
+ /** The time of each sample of `signal`, ascending: the time axis reads them, so a signal recorded at several rates
10
+ * (a recorder's fast window in a slow track) reads in its file's seconds. Omitted: samples / sampleRate from 0. */
11
+ times?: ArrayLike<number>;
9
12
  label?: string;
10
13
  backgroundToken?: string;
11
14
  onPlotContextMenu?: (e: {
@@ -36,4 +39,19 @@ export interface SpectrogramLive {
36
39
  /** Seconds shown, ending now (the worksheet's live window); null: everything buffered. */
37
40
  windowSeconds: number | null;
38
41
  }
39
- export declare function SpectrogramChart({ signal, sampleRate, windowSize, overlap, winFunc, yMode, logFreq, label, backgroundToken, onPlotContextMenu, live, }: SpectrogramChartProps): import("react/jsx-runtime").JSX.Element;
42
+ /**
43
+ * The time axis over `n` samples: its ends, and where (0..1 of the width) a time sits. With the samples' times the
44
+ * columns stay one per window (the picture is in samples), so a time is placed at its sample: a slow stretch of a
45
+ * multi-rate signal is narrow, a fast one wide. Without them the axis is linear from `t0` to `t1`.
46
+ */
47
+ export declare function timeAxis(times: ArrayLike<number> | null | undefined, n: number, t0: number, t1: number): {
48
+ t0: number;
49
+ t1: number;
50
+ at: (t: number) => number;
51
+ };
52
+ /** Display height (0..1) of a frequency on the log axis, and back: decades from `min` (the first bin above DC) to
53
+ * `max` (Nyquist), as the spectrum's log axis. */
54
+ export declare const logFreqY: (f: number, min: number, max: number) => number;
55
+ /** Ticks of the log frequency axis: 1, 2 and 5 of each decade in [min, max]. */
56
+ export declare function logFreqTicks(min: number, max: number): number[];
57
+ export declare function SpectrogramChart({ signal, sampleRate, windowSize, overlap, winFunc, yMode, logFreq, times, label, backgroundToken, onPlotContextMenu, live, }: SpectrogramChartProps): import("react/jsx-runtime").JSX.Element;
@@ -36,13 +36,16 @@ export declare function rectsOverlap(a: DashboardGridRect, b: DashboardGridRect)
36
36
  export declare function clampRectForKind(kind: DashboardPanelKind, r: DashboardGridRect, cols: number, rows?: number): DashboardGridRect;
37
37
  /**
38
38
  * A chart's grid rectangle after a pointer drag of (dxPx, dyPx) on a board of
39
- * `board` CSS pixels: 'move' shifts it, 'resize' moves its bottom-right corner.
39
+ * `board` CSS pixels: 'move' shifts it; 'resize' moves its bottom-right corner,
40
+ * and an edge or corner ('n', 'e', 's', 'w', 'ne', 'nw', 'se', 'sw') moves that
41
+ * one, the opposite side staying put.
40
42
  * The result stays on the grid and never shrinks below the kind's minimum; a
41
43
  * move past an edge trims the chart rather than stopping it. Call
42
44
  * it on pointermove with the rectangle from pointerdown, then store the result
43
45
  * with `charts.setLayout`.
44
46
  */
45
- export declare function dragLayout(kind: DashboardPanelKind, start: DashboardGridRect, mode: 'move' | 'resize', dxPx: number, dyPx: number, board: {
47
+ export type ResizeEdge = 'n' | 'e' | 's' | 'w' | 'ne' | 'nw' | 'se' | 'sw';
48
+ export declare function dragLayout(kind: DashboardPanelKind, start: DashboardGridRect, mode: 'move' | 'resize' | ResizeEdge, dxPx: number, dyPx: number, board: {
46
49
  width: number;
47
50
  height: number;
48
51
  }, cols?: number, rows?: number): DashboardGridRect;
@@ -30,7 +30,7 @@ export { ANNOTATION_CONTROLS_ATTR } from './charts/AnnotationLayer';
30
30
  export { colorAt, colorsCss, presetStops, type GaugeColorMode, type GaugeColorStop, type GaugePreset } from './lib/gaugeColors';
31
31
  export type { PlotSeries, AlarmLine, AlarmStyle } from './types/plotSeries';
32
32
  export { newSeriesId, clampPct } from './types/plotSeries';
33
- export type { DashboardPanel, DashboardPanelKind } from './components/dashboardGridLayout';
33
+ export type { DashboardPanel, DashboardPanelKind, ResizeEdge } from './components/dashboardGridLayout';
34
34
  export { DASHBOARD_GRID_COLS, DASHBOARD_GRID_ROWS, DASHBOARD_GRID_GAP_PX, MIN_PANEL_W, MIN_PANEL_H, clampRectForKind, dragLayout, newPanel, arrangeAutoLayout } from './components/dashboardGridLayout';
35
35
  export type { Worksheet } from './lib/savedLayout';
36
36
  export { DEFAULT_XY_POINT_RADIUS, DEFAULT_XYZ_POINT_RADIUS } from './lib/savedLayout';
@@ -26,6 +26,12 @@ export declare function xyPointAt(cols: XYColumns, i: number): XYPoint;
26
26
  export declare function rowsColumn(rows: DatasetRow[], name: string, full?: ReadonlyMap<string, Float64Array>): Float64Array | undefined;
27
27
  /** The finite values of a column, in order: the column itself when it has none missing. */
28
28
  export declare function finiteValues(rows: DatasetRow[], name: string, full?: ReadonlyMap<string, Float64Array>): Float64Array | undefined;
29
+ /** The finite values of a column and the time of each (from `timeCol`); undefined without that time column, or when
30
+ * a time is missing where a value is not. */
31
+ export declare function finiteWithTimes(rows: DatasetRow[], name: string, timeCol: string, full?: ReadonlyMap<string, Float64Array>): {
32
+ signal: Float64Array;
33
+ times: Float64Array;
34
+ } | undefined;
29
35
  /**
30
36
  * The finite values of `valueCol` split by the value of `groupCol`, groups in
31
37
  * order of first appearance (label 'unknown' for a missing group); without a
@@ -65,7 +71,8 @@ export declare function buildXyColumns(src: XySource, xCol: string, yCol: string
65
71
  max: number;
66
72
  };
67
73
  } | null;
68
- /** Several datasets on one scatter, each point carrying its dataset index and colour. */
74
+ /** Several datasets on one scatter, each point carrying its dataset index and colour. Only the datasets on the
75
+ * worksheet's X (`xKey`), as on its multiband charts: another file plotted beside them is not on this worksheet. */
69
76
  export declare function buildMultiDatasetXyColumns(sources: XySource[], xCol: string, yCol: string, opts: {
70
77
  xKey: string;
71
78
  viewXRange: [number, number] | null;
@@ -52,6 +52,8 @@ export interface OffscreenChartRenderer {
52
52
  export declare function glWorkersAvailable(): boolean;
53
53
  /** Name of the performance mark made when a worker has drawn a canvas's first picture. */
54
54
  export declare const GL_FIRST_FRAME_MARK = "kymoscope-gl-first-frame";
55
+ /** True once `canvas`'s control went to a worker (getContext and a second transfer would throw). */
56
+ export declare function canvasTransferred(canvas: HTMLCanvasElement | null): boolean;
55
57
  export declare function createOffscreenChartRenderer(canvas: HTMLCanvasElement, lineWidth?: number,
56
58
  /** Its context was lost (Chrome dropped it): the caller makes a new canvas and renderer. */
57
59
  onLost?: () => void,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kymoscope/sdk",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "The Kymoscope data engine and charts for the browser: import large measurement files, plot them, stream live data end-to-end encrypted.",
5
5
  "license": "SEE LICENSE IN LICENSE.md",
6
6
  "homepage": "https://kymoscope.com/docs/introduction",