semiotic 3.7.3 → 3.7.5

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.
Files changed (138) hide show
  1. package/CLAUDE.md +13 -7
  2. package/README.md +36 -20
  3. package/ai/schema.json +221 -1
  4. package/ai/system-prompt.md +2 -1
  5. package/dist/components/Annotation.d.ts +4 -0
  6. package/dist/components/DataSummaryContext.d.ts +1 -0
  7. package/dist/components/LinkedCharts.d.ts +2 -2
  8. package/dist/components/ai/chartCapabilityTypes.d.ts +16 -0
  9. package/dist/components/ai/dataPitfallsBridge.d.ts +101 -0
  10. package/dist/components/ai/dataQualityBridge.d.ts +201 -0
  11. package/dist/components/ai/describeChart.d.ts +2 -0
  12. package/dist/components/ai/generativeChart.d.ts +145 -0
  13. package/dist/components/charts/custom/NetworkCustomChart.d.ts +15 -2
  14. package/dist/components/charts/ordinal/SwarmPlot.d.ts +7 -0
  15. package/dist/components/charts/realtime/RealtimeLineChart.d.ts +21 -0
  16. package/dist/components/charts/realtime/aggregate.d.ts +51 -0
  17. package/dist/components/charts/realtime/eventTime.d.ts +26 -0
  18. package/dist/components/charts/shared/colorPalettes.d.ts +2 -0
  19. package/dist/components/charts/shared/colorUtils.d.ts +1 -12
  20. package/dist/components/charts/shared/minMax.d.ts +3 -0
  21. package/dist/components/charts/shared/radialGeometry.d.ts +0 -18
  22. package/dist/components/charts/shared/smartTooltip.d.ts +27 -0
  23. package/dist/components/charts/shared/statisticalOverlays.d.ts +35 -0
  24. package/dist/components/charts/shared/tooltipUtils.d.ts +2 -0
  25. package/dist/components/charts/shared/useChartSetup.d.ts +1 -1
  26. package/dist/components/charts/shared/useCustomChartSetup.d.ts +1 -1
  27. package/dist/components/charts/shared/validateChartData.d.ts +1 -1
  28. package/dist/components/charts/xy/Scatterplot.d.ts +9 -0
  29. package/dist/components/data/fromArrow.d.ts +54 -0
  30. package/dist/components/data/fromMermaid.d.ts +47 -0
  31. package/dist/components/data/fromObservablePlot.d.ts +69 -0
  32. package/dist/components/data/portability/index.d.ts +14 -0
  33. package/dist/components/data/portability/spec.d.ts +129 -0
  34. package/dist/components/data/portability/vegaLite.d.ts +62 -0
  35. package/dist/components/realtime/ReorderBuffer.d.ts +54 -0
  36. package/dist/components/realtime/RunningStats.d.ts +66 -0
  37. package/dist/components/realtime/WindowAccumulator.d.ts +105 -0
  38. package/dist/components/realtime/parseWindowDuration.d.ts +12 -0
  39. package/dist/components/recipes/customTooltip.d.ts +31 -0
  40. package/dist/components/recipes/gofish.d.ts +207 -0
  41. package/dist/components/recipes/gofishBoba.d.ts +23 -0
  42. package/dist/components/recipes/gofishIR.d.ts +169 -0
  43. package/dist/components/recipes/gofishIRExamples.d.ts +89 -0
  44. package/dist/components/recipes/gofishInterpreter.d.ts +52 -0
  45. package/dist/components/recipes/gofishLambdas.d.ts +145 -0
  46. package/dist/components/recipes/lineageDag.d.ts +129 -0
  47. package/dist/components/recipes/mermaidDag.d.ts +44 -0
  48. package/dist/components/recipes/packedClusterMatrix.d.ts +166 -0
  49. package/dist/components/recipes/recipeChrome.d.ts +100 -0
  50. package/dist/components/recipes/recipeLegend.d.ts +57 -0
  51. package/dist/components/recipes/recipeUtils.d.ts +105 -0
  52. package/dist/components/semiotic-ai.d.ts +6 -0
  53. package/dist/components/semiotic-data.d.ts +2 -0
  54. package/dist/components/semiotic-experimental.d.ts +20 -0
  55. package/dist/components/semiotic-network.d.ts +3 -1
  56. package/dist/components/semiotic-ordinal.d.ts +2 -0
  57. package/dist/components/semiotic-realtime.d.ts +9 -1
  58. package/dist/components/semiotic-recipes.d.ts +20 -1
  59. package/dist/components/semiotic-themes.d.ts +2 -0
  60. package/dist/components/semiotic-xy.d.ts +2 -0
  61. package/dist/components/semiotic.d.ts +6 -2
  62. package/dist/components/store/ObservationStore.d.ts +21 -2
  63. package/dist/components/store/SelectionStore.d.ts +1 -1
  64. package/dist/components/store/ThemeStore.d.ts +1 -1
  65. package/dist/components/store/TooltipStore.d.ts +1 -1
  66. package/dist/components/store/createStore.d.ts +1 -1
  67. package/dist/components/store/designTokens.d.ts +15 -0
  68. package/dist/components/store/useSelection.d.ts +22 -0
  69. package/dist/components/stream/NetworkHtmlMarksLayer.d.ts +44 -0
  70. package/dist/components/stream/NetworkPipelineStore.d.ts +32 -0
  71. package/dist/components/stream/NetworkSVGOverlay.d.ts +12 -0
  72. package/dist/components/stream/OrdinalPipelineStore.d.ts +18 -0
  73. package/dist/components/stream/PipelineStore.d.ts +27 -0
  74. package/dist/components/stream/SceneGraph.d.ts +5 -1
  75. package/dist/components/stream/customLayout.d.ts +20 -0
  76. package/dist/components/stream/customLayoutDiagnostics.d.ts +11 -0
  77. package/dist/components/stream/customLayoutSelection.d.ts +52 -0
  78. package/dist/components/stream/networkCustomLayout.d.ts +101 -1
  79. package/dist/components/stream/networkTypes.d.ts +38 -1
  80. package/dist/components/stream/ordinalCustomLayout.d.ts +17 -1
  81. package/dist/components/stream/ordinalSceneBuilders/types.d.ts +2 -0
  82. package/dist/components/stream/ordinalTypes.d.ts +19 -3
  83. package/dist/components/stream/renderers/networkSymbolRenderer.d.ts +2 -0
  84. package/dist/components/stream/renderers/symbolCanvasRenderer.d.ts +2 -0
  85. package/dist/components/stream/stalenessBands.d.ts +28 -0
  86. package/dist/components/stream/symbolPath.d.ts +24 -0
  87. package/dist/components/stream/types.d.ts +72 -3
  88. package/dist/components/stream/useStalenessCheck.d.ts +6 -1
  89. package/dist/components/stream/xySceneBuilders/pointScene.d.ts +2 -2
  90. package/dist/components/stream/xySceneBuilders/types.d.ts +5 -0
  91. package/dist/geo.min.js +1 -1
  92. package/dist/geo.module.min.js +1 -1
  93. package/dist/network.min.js +1 -1
  94. package/dist/network.module.min.js +1 -1
  95. package/dist/ordinal.min.js +1 -1
  96. package/dist/ordinal.module.min.js +1 -1
  97. package/dist/realtime.min.js +1 -1
  98. package/dist/realtime.module.min.js +1 -1
  99. package/dist/semiotic-ai-semiotic-ai-u954ylUn.js +2 -0
  100. package/dist/semiotic-ai-statisticalOverlays-CU7jW05Q.js +1 -0
  101. package/dist/semiotic-ai.d.ts +6 -0
  102. package/dist/semiotic-ai.min.js +1 -1
  103. package/dist/semiotic-ai.module.min.js +1 -1
  104. package/dist/semiotic-data.d.ts +2 -0
  105. package/dist/semiotic-data.min.js +1 -1
  106. package/dist/semiotic-data.module.min.js +1 -1
  107. package/dist/semiotic-experimental.d.ts +20 -0
  108. package/dist/semiotic-experimental.min.js +1 -0
  109. package/dist/semiotic-experimental.module.min.js +1 -0
  110. package/dist/semiotic-network.d.ts +3 -1
  111. package/dist/semiotic-ordinal.d.ts +2 -0
  112. package/dist/semiotic-realtime.d.ts +9 -1
  113. package/dist/semiotic-recipes.d.ts +20 -1
  114. package/dist/semiotic-recipes.min.js +1 -1
  115. package/dist/semiotic-recipes.module.min.js +1 -1
  116. package/dist/semiotic-semiotic-BmrYbi99.js +2 -0
  117. package/dist/semiotic-statisticalOverlays-IjZw8Lsu.js +1 -0
  118. package/dist/semiotic-themes.d.ts +2 -0
  119. package/dist/semiotic-themes.min.js +1 -1
  120. package/dist/semiotic-themes.module.min.js +1 -1
  121. package/dist/semiotic-utils.min.js +1 -1
  122. package/dist/semiotic-utils.module.min.js +1 -1
  123. package/dist/semiotic-value.min.js +1 -1
  124. package/dist/semiotic-value.module.min.js +1 -1
  125. package/dist/semiotic-xy.d.ts +2 -0
  126. package/dist/semiotic.d.ts +6 -2
  127. package/dist/semiotic.min.js +1 -1
  128. package/dist/semiotic.module.min.js +1 -1
  129. package/dist/server.min.js +1 -1
  130. package/dist/server.module.min.js +1 -1
  131. package/dist/xy-semiotic-xy-Dufu3D0-.js +2 -0
  132. package/dist/xy-statisticalOverlays-3Ni9bRph.js +1 -0
  133. package/dist/xy.min.js +1 -1
  134. package/dist/xy.module.min.js +1 -1
  135. package/package.json +11 -3
  136. package/dist/semiotic-ai-statisticalOverlays-C2PPlmXv.js +0 -1
  137. package/dist/semiotic-statisticalOverlays-C3DsOgr_.js +0 -1
  138. package/dist/xy-statisticalOverlays-C2PPlmXv.js +0 -1
@@ -1,21 +1,3 @@
1
- /**
2
- * radialGeometry — pure math helpers for radial chart authoring.
3
- *
4
- * The original consumer is `GaugeChart`, which needs to:
5
- * - Convert a sweep angle (degrees) into start-angle + radian
6
- * forms that align with the convention pieScene.ts uses
7
- * (0° = 12 o'clock, positive = clockwise, gap centered at the
8
- * 6 o'clock position).
9
- * - Map a value in `[min, max]` to its angle along the arc.
10
- * - Compute the arc's visible bounding box in unit-circle coords
11
- * so a container can fit the arc and pick a maximum radius.
12
- *
13
- * Custom radial chart authors using `XYCustomChart` or building a
14
- * bespoke radial layout can reach for the same primitives without
15
- * reimplementing the trigonometry. Surface intentionally tight —
16
- * each function is a few lines of math with a documented input
17
- * convention.
18
- */
19
1
  /** Result of `sweepToAngles`. All angles are in the
20
2
  * 12-o'clock-zero, clockwise-positive convention used by pieScene
21
3
  * and the underlying gauge implementation. */
@@ -0,0 +1,27 @@
1
+ import type { Datum } from "./datumTypes";
2
+ export interface SmartTooltipEntry {
3
+ key: string;
4
+ value: unknown;
5
+ }
6
+ export interface SmartTooltipResult {
7
+ /** The key the title came from, if any. */
8
+ titleKey?: string;
9
+ /** The display title (a name/label/title/id). */
10
+ title?: unknown;
11
+ /** Ordered rows to show beneath the title (type → value → rest). */
12
+ entries: SmartTooltipEntry[];
13
+ }
14
+ /**
15
+ * Choose a title + ordered, de-noised rows from an arbitrary datum. Pure.
16
+ *
17
+ * - Skips `_`/`__`-prefixed keys, `data`, positional/topology keys, and
18
+ * non-primitive values (nested objects/arrays).
19
+ * - Title: the first `name`/`label`/`title` field, else `id`, else the first
20
+ * string field. When a real name is used, `id` is dropped as redundant.
21
+ * - Rows: one type-family field, then one value-family field, then the rest in
22
+ * insertion order (capped at `maxEntries`).
23
+ */
24
+ export declare function smartTooltipEntries(raw: Datum | null | undefined, options?: {
25
+ maxEntries?: number;
26
+ skipPositional?: boolean;
27
+ }): SmartTooltipResult;
@@ -48,6 +48,27 @@ export interface ForecastConfig {
48
48
  trainOpacity?: number;
49
49
  /** Stroke opacity for the forecast line segment (0–1). Default: 1 */
50
50
  forecastOpacity?: number;
51
+ /**
52
+ * Ramp each forecast point's opacity by its uncertainty — wider
53
+ * prediction interval (longer horizon) renders fainter, fusing
54
+ * confidence into the encoding instead of a single flat opacity.
55
+ * `true` ramps across `[0.15, 1]`; pass `{ min, max }` to bound the
56
+ * range. Honored by `createSegmentLineStyle`; overrides
57
+ * `forecastOpacity` per point. Mutually exclusive with
58
+ * `confidenceAccessor` (which wins if both are set).
59
+ */
60
+ uncertaintyOpacity?: boolean | {
61
+ min?: number;
62
+ max?: number;
63
+ };
64
+ /**
65
+ * Externally-supplied per-point confidence in `[0, 1]` (field name or
66
+ * function). When set, each forecast point's opacity is interpolated
67
+ * across the `uncertaintyOpacity` range (or `[0.15, 1]`) by its
68
+ * confidence — higher confidence, more opaque. Use when the consumer's
69
+ * model emits a confidence rather than a prediction interval.
70
+ */
71
+ confidenceAccessor?: string | ((d: Datum) => number);
51
72
  /**
52
73
  * Training line stroke color.
53
74
  * - `"darken"`: auto-darken the line's own color by 50% (hex colors only —
@@ -97,6 +118,20 @@ export interface ForecastConfig {
97
118
  /** Internal segment marker added to each datum */
98
119
  export declare const SEGMENT_FIELD: "__forecastSegment";
99
120
  export type SegmentType = "training" | "training-base" | "observed" | "forecast";
121
+ /** Internal per-point opacity stamped by the uncertainty ramp. */
122
+ export declare const FORECAST_OPACITY_FIELD: "__forecastOpacity";
123
+ /**
124
+ * Stamp `__forecastOpacity` on forecast points so `createSegmentLineStyle`
125
+ * can fade each by its uncertainty. Two sources, confidence wins:
126
+ *
127
+ * - `confidenceAccessor` — opacity = lerp(min, max, confidence∈[0,1]).
128
+ * - `uncertaintyOpacity` — opacity ramped by prediction-interval width
129
+ * (narrowest → max, widest → min), normalized across the given points.
130
+ *
131
+ * Mutates the supplied point objects in place; no-op when neither source
132
+ * is configured. Pure otherwise (only reads via the passed accessors).
133
+ */
134
+ export declare function stampForecastOpacity(points: Datum[], config: ForecastConfig, getUpper: (d: Datum) => number | undefined, getLower: (d: Datum) => number | undefined): void;
100
135
  export declare function buildAnomalyAnnotations(config: AnomalyConfig): Datum[];
101
136
  export interface ForecastResult {
102
137
  processedData: Datum[];
@@ -21,6 +21,8 @@ export interface TooltipFieldConfig {
21
21
  export declare function accessorName(acc: string | ((...args: any[]) => any)): string;
22
22
  export declare function formatVal(v: unknown): string;
23
23
  export declare function resolveValue(d: Datum, acc: string | ((d: Datum) => any)): unknown;
24
+ export { smartTooltipEntries } from "./smartTooltip";
25
+ export type { SmartTooltipEntry, SmartTooltipResult } from "./smartTooltip";
24
26
  /**
25
27
  * Build TooltipFieldConfig rows for a `band` prop config so the default
26
28
  * tooltip surfaces envelope values automatically. Reads from the
@@ -63,7 +63,7 @@ export interface ChartSetupInput {
63
63
  /** Custom content rendered in place of the default skeleton while `loading` is true. */
64
64
  loadingContent?: ReactNode | false;
65
65
  /** Empty content override */
66
- emptyContent?: ReactNode;
66
+ emptyContent?: ReactNode | false;
67
67
  /** Resolved width from useChartMode */
68
68
  width: number;
69
69
  /** Resolved height from useChartMode */
@@ -65,7 +65,7 @@ interface DataSetupOptions extends ScaffoldOptions {
65
65
  chartId?: string;
66
66
  loading?: boolean;
67
67
  loadingContent?: ReactNode | false;
68
- emptyContent?: ReactNode;
68
+ emptyContent?: ReactNode | false;
69
69
  }
70
70
  interface DataSetupResult<TFrameHandle> extends ScaffoldResult<TFrameHandle> {
71
71
  /** Sparse-filtered copy of the input data array. */
@@ -12,7 +12,7 @@ import type { Datum } from "./datumTypes";
12
12
  type AccessorLike = string | ((...args: any[]) => any);
13
13
  interface ArrayDataValidation {
14
14
  componentName: string;
15
- data: any[] | undefined | null;
15
+ data: any;
16
16
  accessors?: Record<string, AccessorLike | undefined>;
17
17
  requiredProps?: Datum;
18
18
  }
@@ -1,6 +1,7 @@
1
1
  import type { Datum } from "../shared/datumTypes";
2
2
  import * as React from "react";
3
3
  import type { StreamXYFrameProps, MarginalGraphicsConfig } from "../../stream/types";
4
+ import type { SymbolName } from "../../stream/symbolPath";
4
5
  import type { RealtimeFrameHandle } from "../../realtime/types";
5
6
  import type { BaseChartProps, AxisConfig, ChartAccessor } from "../shared/types";
6
7
  import { type TooltipProp } from "../../Tooltip/Tooltip";
@@ -29,6 +30,14 @@ export interface ScatterplotProps<TDatum extends Datum = Datum> extends BaseChar
29
30
  sizeBy?: ChartAccessor<TDatum, number>;
30
31
  /** Min and max radius for points @default [3, 15] */
31
32
  sizeRange?: [number, number];
33
+ /** Field name or function → glyph **shape**: each mark renders as a d3-shape
34
+ * glyph instead of a circle (the per-datum shape channel). Pair with a
35
+ * `symbolMap` for stable, legend-matchable shapes; unmapped categories
36
+ * auto-assign. Size still tracks `sizeBy`/`pointRadius`. */
37
+ symbolBy?: ChartAccessor<TDatum, string>;
38
+ /** Explicit `{category → shape}` map for `symbolBy` (e.g. `{ Civil: "star" }`);
39
+ * unmapped categories auto-assign from the shape sequence. */
40
+ symbolMap?: Record<string, SymbolName>;
32
41
  /** Default point radius when sizeBy is not specified @default 5 */
33
42
  pointRadius?: number;
34
43
  /** Point opacity @default 0.8 */
@@ -0,0 +1,54 @@
1
+ import type { Datum } from "../charts/shared/datumTypes";
2
+ /**
3
+ * Apache Arrow → Semiotic rows (v1).
4
+ *
5
+ * Reads an Arrow table (DuckDB-Wasm result set, Arrow IPC, Parquet-via-Arrow)
6
+ * into the plain row objects the chart accessor path expects, so an in-browser
7
+ * analytics engine can feed Semiotic with one call.
8
+ *
9
+ * **Honest scope (v1).** Semiotic's data path is row-oriented and validates the
10
+ * `data` prop with `Array.isArray`, so a chart's `data` must be a real array of
11
+ * row objects. This adapter therefore materializes rows — but leanly: it reads
12
+ * each requested column cell-by-cell into a plain object, avoiding Arrow's own
13
+ * `Table.toArray()` row-proxy machinery, and it supports column projection so
14
+ * you only pay for the fields you chart. The genuinely zero-copy columnar path
15
+ * (a typed-array accessor mode + bulk ring-buffer ingest) is deliberately
16
+ * *not* built here: it touches the ingestion core and waits on a named consumer
17
+ * plus profiling evidence, rather than being built on spec.
18
+ *
19
+ * Pure, dependency-free: the Arrow table is duck-typed, so `apache-arrow` never
20
+ * enters Semiotic's dependencies — you bring the table, this reads it.
21
+ */
22
+ /** A column vector, duck-typed to apache-arrow's `Vector`. */
23
+ export interface ArrowColumnLike {
24
+ get(index: number): unknown;
25
+ }
26
+ /** A schema field, duck-typed to apache-arrow's `Field`. */
27
+ export interface ArrowFieldLike {
28
+ name: string;
29
+ }
30
+ /** A table schema, duck-typed to apache-arrow's `Schema`. */
31
+ export interface ArrowSchemaLike {
32
+ fields: ReadonlyArray<ArrowFieldLike>;
33
+ }
34
+ /** An Arrow table, duck-typed to apache-arrow's `Table` (and DuckDB-Wasm results). */
35
+ export interface ArrowTableLike {
36
+ numRows: number;
37
+ schema: ArrowSchemaLike;
38
+ getChild(name: string): ArrowColumnLike | null | undefined;
39
+ }
40
+ export interface FromArrowOptions {
41
+ /** Project a subset of columns. Omit to read every column in the schema. */
42
+ fields?: ReadonlyArray<string>;
43
+ /**
44
+ * Convert Arrow int64/uint64 values (returned as `bigint`) to `number`, since
45
+ * the chart scales and `toNumber` coercion work in `number`. Default true.
46
+ * Values outside `Number.MAX_SAFE_INTEGER` are left as `bigint` (and warned).
47
+ */
48
+ coerceBigInt?: boolean;
49
+ }
50
+ /**
51
+ * Materialize an Arrow table into Semiotic row objects. Pass the result
52
+ * straight to a chart's `data` prop: `<LineChart data={fromArrow(table)} … />`.
53
+ */
54
+ export declare function fromArrow(table: ArrowTableLike, options?: FromArrowOptions): Datum[];
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Mermaid → Semiotic graph (alpha).
3
+ *
4
+ * Mermaid is the dominant text-to-graph language across GitHub, Notion, and LLM
5
+ * output — but it renders as flat, hard-to-style, non-interactive, *inaccessible*
6
+ * SVG. This adapter parses Mermaid `graph`/`flowchart` syntax into a topology
7
+ * Semiotic can render with hover, isolation, theme tokens, keyboard navigation,
8
+ * and an accessible navigation tree.
9
+ *
10
+ * The gofish lesson applies hard (D7): **reconstruct the diagram's semantics,
11
+ * not its pixels.** A Mermaid flowchart is a DAG, not a force graph, so this
12
+ * adapter doesn't just emit nodes/edges — it computes a layered layout
13
+ * (longest-path layering) and stamps each node with `layer`/`row` coordinates,
14
+ * ready for the `lineageDagLayout` recipe via `NetworkCustomChart`. The raw
15
+ * topology is also returned, so a consumer who wants a force layout
16
+ * (`ForceDirectedGraph`) can use it directly.
17
+ *
18
+ * Scope (alpha): `graph`/`flowchart` with TD/TB/BT/LR/RL direction, node shapes,
19
+ * and labeled edges. Other Mermaid diagram types (sequence, class, state, er,
20
+ * gantt, pie, mindmap, …) are declined with a reason rather than mistranslated.
21
+ *
22
+ * Pure, dependency-free: a small dedicated parser, never a Mermaid runtime dep.
23
+ */
24
+ export type MermaidDirection = "TD" | "TB" | "BT" | "LR" | "RL";
25
+ export type MermaidNodeShape = "rect" | "round" | "stadium" | "subroutine" | "cylinder" | "circle" | "diamond" | "hexagon" | "flag";
26
+ export interface MermaidNode {
27
+ id: string;
28
+ label: string;
29
+ shape: MermaidNodeShape;
30
+ /** Longest-path layer (0 = a source with no incoming edges). */
31
+ layer: number;
32
+ /** Order within the layer (insertion order). */
33
+ row: number;
34
+ }
35
+ export interface MermaidEdge {
36
+ source: string;
37
+ target: string;
38
+ label?: string;
39
+ }
40
+ export interface MermaidResult {
41
+ kind: "flowchart";
42
+ direction: MermaidDirection;
43
+ nodes: MermaidNode[];
44
+ edges: MermaidEdge[];
45
+ warnings?: string[];
46
+ }
47
+ export declare function fromMermaid(text: string): MermaidResult;
@@ -0,0 +1,69 @@
1
+ import type { Datum } from "../charts/shared/datumTypes";
2
+ /**
3
+ * Observable Plot → Semiotic translator.
4
+ *
5
+ * A sibling to `fromVegaLite`: maps a declarative Observable Plot spec to a
6
+ * Semiotic `ChartConfig`, so a chart sketched in a notebook crosses the
7
+ * notebook→production rewrite tax and arrives with everything a throwaway Plot
8
+ * chart never had — accessible tables, keyboard navigation, descriptions, the
9
+ * a11y audit, theme tokens, annotation provenance, and SSR.
10
+ *
11
+ * Honest hard part (the reason this stages behind `unstable_`): Plot's public
12
+ * API is *imperative JS* (`Plot.line(data, {…})`), not declarative JSON. This
13
+ * adapter consumes the **declarative shape of a Plot spec** — the `{ marks,
14
+ * x, y, color, … }` object you'd pass to `Plot.plot()`, with each mark
15
+ * expressed as `{ type, data?, options? }`. Where a mark, channel, or
16
+ * transform has no faithful Semiotic equivalent, it surfaces a warning and
17
+ * refuses to approximate, rather than emit a plausible-but-wrong chart.
18
+ *
19
+ * Scope (alpha): core marks — line/lineY/lineX, barY/barX, dot, areaY/area,
20
+ * rectY (binned → histogram), cell, tick — with basic channels. No layered
21
+ * multi-mark plots, facets, or Plot transforms (binX/groupY/stackY as option
22
+ * wrappers).
23
+ */
24
+ import type { ChartConfig } from "../export/chartConfig";
25
+ /** A channel value: a field name (string), a constant (number), or — declined — a function. */
26
+ export type ObservablePlotChannel = string | number | ((d: Datum, i: number) => unknown);
27
+ export interface ObservablePlotMarkOptions {
28
+ x?: ObservablePlotChannel;
29
+ y?: ObservablePlotChannel;
30
+ fill?: ObservablePlotChannel;
31
+ stroke?: ObservablePlotChannel;
32
+ r?: ObservablePlotChannel;
33
+ z?: ObservablePlotChannel;
34
+ curve?: string;
35
+ [key: string]: unknown;
36
+ }
37
+ export interface ObservablePlotMark {
38
+ /** The Plot mark function name, e.g. "line", "barY", "dot", "areaY", "cell". */
39
+ type: string;
40
+ data?: Datum[];
41
+ options?: ObservablePlotMarkOptions;
42
+ }
43
+ export interface ObservablePlotScale {
44
+ label?: string;
45
+ type?: string;
46
+ scheme?: string;
47
+ domain?: unknown;
48
+ range?: unknown;
49
+ [key: string]: unknown;
50
+ }
51
+ export interface ObservablePlotSpec {
52
+ marks?: ObservablePlotMark[];
53
+ /** Shared data, when marks don't each carry their own. */
54
+ data?: Datum[];
55
+ width?: number;
56
+ height?: number;
57
+ title?: string;
58
+ x?: ObservablePlotScale;
59
+ y?: ObservablePlotScale;
60
+ color?: ObservablePlotScale;
61
+ r?: ObservablePlotScale;
62
+ fx?: unknown;
63
+ fy?: unknown;
64
+ facet?: unknown;
65
+ [key: string]: unknown;
66
+ }
67
+ export declare function fromObservablePlot(spec: ObservablePlotSpec): ChartConfig & {
68
+ warnings?: string[];
69
+ };
@@ -0,0 +1,14 @@
1
+ /**
2
+ * IDID portability spec — runtime surface (v0.1, experimental).
3
+ *
4
+ * Library-neutral types, dependency-free validators, an outbound Vega-Lite
5
+ * translator, and the IDID-over-Vega-Lite binding. The canonical published
6
+ * artifact is the JSON Schema set in `/spec/v0.1`.
7
+ *
8
+ * Exposed via `semiotic/experimental` behind the `unstable_` prefix while the
9
+ * surface is proven against real consumers.
10
+ */
11
+ export { IDID_SPEC_VERSION, BUILTIN_INTENT_IDS, validatePortableCapability, validatePortableAudienceProfile, validatePortableAnnotation, } from "./spec";
12
+ export type { BuiltInIntentId, PortableIntentId, PortableChartRubric, PortableChartVariant, PortableChartCapability, PortableReceptionModality, PortableAudienceTarget, PortableAudienceProfile, PortableAnnotationActorKind, PortableAnnotationSource, PortableAnnotationBasis, PortableAnnotationProvenance, PortableAnnotationFreshness, PortableAnnotationStatus, PortableAnnotationAnchor, PortableAnnotationLifecycle, PortableAnnotated, ValidationResult, } from "./spec";
13
+ export { toVegaLite, attachIDID, readIDID, attachIDIDAnnotations, readIDIDAnnotations, } from "./vegaLite";
14
+ export type { IDIDVegaLiteMeta } from "./vegaLite";
@@ -0,0 +1,129 @@
1
+ /**
2
+ * The IDID portability spec — runtime surface (v0.1).
3
+ *
4
+ * The canonical, published artifact is the set of JSON Schemas in `/spec/v0.1`.
5
+ * This module is the reference implementation's *runtime companion*: portable
6
+ * TypeScript types that mirror those schemas, plus small dependency-free
7
+ * structural validators for hosts that don't want to pull in a full JSON-schema
8
+ * engine (per spec doctrine: zero new core dependencies).
9
+ *
10
+ * The schemas are library-neutral — none of these types import from a chart
11
+ * family. Keeping them pure is what lets the ideas travel into ecosystems that
12
+ * have no concept of a Semiotic chart.
13
+ *
14
+ * Field/type fidelity with the published JSON Schemas is enforced by
15
+ * `portability.test.ts` (the round-trip gate), so the two cannot drift.
16
+ */
17
+ /** The spec version this build targets. Matches the `/spec/v0.1` directory. */
18
+ export declare const IDID_SPEC_VERSION = "0.1";
19
+ /** The 13 built-in communicative intents. Hosts may register more (open string). */
20
+ export declare const BUILTIN_INTENT_IDS: readonly ["trend", "compare-series", "compare-categories", "rank", "part-to-whole", "distribution", "correlation", "flow", "hierarchy", "geo", "outlier-detection", "composition-over-time", "change-detection"];
21
+ export type BuiltInIntentId = (typeof BUILTIN_INTENT_IDS)[number];
22
+ /** Any intent id — built-in or host-registered. */
23
+ export type PortableIntentId = BuiltInIntentId | (string & {});
24
+ export interface PortableChartRubric {
25
+ /** How well-known the chart is to a general audience (1–5). */
26
+ familiarity: number;
27
+ /** How faithfully it represents the underlying data (1–5). */
28
+ accuracy: number;
29
+ /** How readable individual values are (1–5). */
30
+ precision: number;
31
+ }
32
+ export interface PortableChartVariant {
33
+ key: string;
34
+ label: string;
35
+ description?: string;
36
+ intentDeltas?: Partial<Record<PortableIntentId, number>>;
37
+ rubricDeltas?: Partial<PortableChartRubric>;
38
+ caveats?: ReadonlyArray<string>;
39
+ tags?: ReadonlyArray<string>;
40
+ /** Implementation-specific props; opaque to the spec. */
41
+ props?: Record<string, unknown>;
42
+ }
43
+ export interface PortableChartCapability {
44
+ /** Stable chart name (e.g. "BarChart"). */
45
+ component: string;
46
+ /** Coarse family — open string ("xy" | "ordinal" | "network" | …). */
47
+ family?: string;
48
+ /** Where the implementing library exposes the chart (advisory). */
49
+ importPath?: string;
50
+ rubric: PortableChartRubric;
51
+ /** Per-intent suitability, 0–5. Missing intents default to 0. */
52
+ intentScores?: Partial<Record<PortableIntentId, number>>;
53
+ variants?: ReadonlyArray<PortableChartVariant>;
54
+ /** Static, audience-independent caveats. */
55
+ caveats?: ReadonlyArray<string>;
56
+ tags?: ReadonlyArray<string>;
57
+ }
58
+ export type PortableReceptionModality = "visual" | "screen-reader" | "sonified" | "agent";
59
+ export interface PortableAudienceTarget {
60
+ direction: "increase" | "decrease";
61
+ /** 1–3; default 1. */
62
+ weight?: number;
63
+ reason?: string;
64
+ }
65
+ export interface PortableAudienceProfile {
66
+ name?: string;
67
+ /** Per-chart familiarity override, 1–5, keyed by component. */
68
+ familiarity?: Record<string, number>;
69
+ /** Adoption targets keyed by component. */
70
+ targets?: Record<string, PortableAudienceTarget>;
71
+ exposureLevel?: 0 | 1 | 2;
72
+ receptionModality?: PortableReceptionModality;
73
+ }
74
+ /** Open string — recognized: human | agent | watcher | system. */
75
+ export type PortableAnnotationActorKind = "human" | "agent" | "watcher" | "system" | (string & {});
76
+ /** Open string — recognized: user | ai | agent | import | computed | system. */
77
+ export type PortableAnnotationSource = "user" | "ai" | "agent" | "import" | "computed" | "system" | (string & {});
78
+ /** Open string — recognized: human-note | statistical-test | rule | llm-inference | external-source | computed. */
79
+ export type PortableAnnotationBasis = "human-note" | "statistical-test" | "rule" | "llm-inference" | "external-source" | "computed" | (string & {});
80
+ export interface PortableAnnotationProvenance {
81
+ author?: string;
82
+ authorKind?: PortableAnnotationActorKind;
83
+ source?: PortableAnnotationSource;
84
+ basis?: PortableAnnotationBasis;
85
+ /** 0–1. */
86
+ confidence?: number;
87
+ /** ISO 8601 timestamp. */
88
+ createdAt?: string;
89
+ dataVersion?: string;
90
+ stableId?: string;
91
+ }
92
+ /** Closed union. */
93
+ export type PortableAnnotationFreshness = "fresh" | "aging" | "stale" | "expired";
94
+ /** Closed union. */
95
+ export type PortableAnnotationStatus = "proposed" | "accepted" | "disputed" | "retracted";
96
+ /** Closed union. */
97
+ export type PortableAnnotationAnchor = "fixed" | "latest" | "sticky" | "semantic";
98
+ export interface PortableAnnotationLifecycle {
99
+ freshness?: PortableAnnotationFreshness;
100
+ status?: PortableAnnotationStatus;
101
+ /** provenance.stableId of the annotation this one replaces. */
102
+ supersedes?: string;
103
+ /** ISO 8601 duration string or milliseconds. */
104
+ ttlHint?: string | number;
105
+ anchor?: PortableAnnotationAnchor;
106
+ }
107
+ /** Any annotation may carry the two optional blocks. */
108
+ export type PortableAnnotated<T = Record<string, unknown>> = T & {
109
+ provenance?: PortableAnnotationProvenance;
110
+ lifecycle?: PortableAnnotationLifecycle;
111
+ };
112
+ export interface ValidationResult {
113
+ valid: boolean;
114
+ errors: string[];
115
+ }
116
+ /**
117
+ * Structurally validate a portable chart capability. Dependency-free; mirrors
118
+ * the required/range constraints in chart-capability.schema.json. Not a full
119
+ * JSON-Schema validation — for that, run the published schema through ajv.
120
+ */
121
+ export declare function validatePortableCapability(value: unknown): ValidationResult;
122
+ /** Structurally validate a portable audience profile. */
123
+ export declare function validatePortableAudienceProfile(value: unknown): ValidationResult;
124
+ /**
125
+ * Structurally validate the provenance + lifecycle blocks on an annotation.
126
+ * Validates only the two IDID blocks; the rest of the annotation (positional
127
+ * fields, type, label) is the host's concern.
128
+ */
129
+ export declare function validatePortableAnnotation(value: unknown): ValidationResult;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * Outbound Vega-Lite + the IDID-over-Vega-Lite binding (v0.1).
3
+ *
4
+ * `toVegaLite` is the inverse of `fromVegaLite`: a Semiotic ChartConfig back to
5
+ * a Vega-Lite spec. Round-tripping through the dominant interchange format —
6
+ * *with the IDID metadata preserved* — is the portability claim in runnable
7
+ * form.
8
+ *
9
+ * The binding functions (`attachIDID` / `readIDID`, `attachIDIDAnnotations` /
10
+ * `readIDIDAnnotations`) define WHERE the three portable primitives ride on a
11
+ * Vega-Lite spec so the spec and its IDID metadata travel together. The
12
+ * convention is documented in `/spec/README.md`.
13
+ *
14
+ * Pure, dependency-free, no chart-family imports.
15
+ */
16
+ import type { ChartConfig } from "../../export/chartConfig";
17
+ import type { VegaLiteSpec } from "../fromVegaLite";
18
+ import type { PortableAnnotated, PortableAudienceProfile, PortableChartCapability } from "./spec";
19
+ /**
20
+ * Translate a Semiotic ChartConfig into a Vega-Lite spec. Covers the families
21
+ * `fromVegaLite` covers, so the pair round-trips. Constructs unsupported by
22
+ * Vega-Lite's single-view core surface a warning rather than a wrong spec.
23
+ */
24
+ export declare function toVegaLite(config: ChartConfig): VegaLiteSpec & {
25
+ warnings?: string[];
26
+ };
27
+ /** The metadata block that rides under `usermeta.idid`. */
28
+ export interface IDIDVegaLiteMeta {
29
+ specVersion: string;
30
+ capability?: PortableChartCapability;
31
+ audience?: PortableAudienceProfile;
32
+ /** Provenanced annotations carried alongside the spec. */
33
+ annotations?: PortableAnnotated[];
34
+ }
35
+ /**
36
+ * Attach a capability descriptor and/or an audience profile to a Vega-Lite
37
+ * spec under `usermeta.idid`. A non-IDID renderer ignores `usermeta`; an
38
+ * IDID-aware host reads it (e.g. to route the capability through a suggestion
39
+ * engine). Returns a new spec; the input is not mutated.
40
+ */
41
+ export declare function attachIDID(spec: VegaLiteSpec, meta: {
42
+ capability?: PortableChartCapability;
43
+ audience?: PortableAudienceProfile;
44
+ }): VegaLiteSpec;
45
+ /** Read the IDID metadata block from a Vega-Lite spec, if present. */
46
+ export declare function readIDID(spec: VegaLiteSpec): IDIDVegaLiteMeta | undefined;
47
+ /**
48
+ * Attach provenanced/lifecycled annotations to a Vega-Lite spec.
49
+ *
50
+ * The annotations are stored verbatim (with their provenance/lifecycle blocks)
51
+ * under the spec's `usermeta.idid.annotations` — that is the round-trip
52
+ * contract, and it composes with capability/audience metadata under the same
53
+ * key. As a courtesy to non-IDID renderers, each annotation that has a
54
+ * representable shape also emits a best-effort `rule`/`text` mark in an
55
+ * appended layer, so a plain Vega-Lite renderer still draws something. When no
56
+ * annotation is representable, no layer is added (avoiding an invalid empty
57
+ * layer) and the metadata still rides on `usermeta`. Returns a new spec; the
58
+ * input is not mutated.
59
+ */
60
+ export declare function attachIDIDAnnotations(spec: VegaLiteSpec, annotations: ReadonlyArray<PortableAnnotated>): VegaLiteSpec;
61
+ /** Read provenanced annotations back from a Vega-Lite spec. */
62
+ export declare function readIDIDAnnotations(spec: VegaLiteSpec): PortableAnnotated[];
@@ -0,0 +1,54 @@
1
+ export type LatePolicy = "drop" | "keep";
2
+ export interface ReorderBufferConfig<T> {
3
+ /** Grace window in ms. Events older than `watermark − lateness` are late. */
4
+ lateness: number;
5
+ /** Event-time accessor (ms). */
6
+ getTime: (item: T) => number;
7
+ /**
8
+ * What to do with a late event:
9
+ * - `"drop"` (default): discard it (still counted).
10
+ * - `"keep"`: release it immediately, out of order (still counted).
11
+ */
12
+ latePolicy?: LatePolicy;
13
+ }
14
+ export interface ReorderResult<T> {
15
+ /**
16
+ * Events ready to append to the main buffer now, in event-time order.
17
+ * Already reflects the late policy — dropped late events are excluded.
18
+ */
19
+ released: T[];
20
+ /** The events that were late this push (informational; for diagnostics). */
21
+ late: T[];
22
+ }
23
+ /**
24
+ * Buffers pushed events and releases them in event-time order once they
25
+ * fall outside the grace window. Stateful; one instance per series.
26
+ */
27
+ export declare class ReorderBuffer<T> {
28
+ private readonly lateness;
29
+ private readonly getTime;
30
+ private readonly latePolicy;
31
+ private held;
32
+ private _watermark;
33
+ private _lateCount;
34
+ constructor(config: ReorderBufferConfig<T>);
35
+ /**
36
+ * Ingest one event. Returns the events that became safe to emit (in
37
+ * event-time order) plus any late events seen this push.
38
+ */
39
+ push(item: T): ReorderResult<T>;
40
+ /** Release all events whose time is at or before `watermark − lateness`. */
41
+ private drain;
42
+ /**
43
+ * Release everything still held, in event-time order — e.g. when the
44
+ * stream ends and the remaining grace-window events should be shown.
45
+ */
46
+ flush(): T[];
47
+ clear(): void;
48
+ /** Largest event-time seen, or `-Infinity` if empty. */
49
+ get watermark(): number;
50
+ /** Total late events seen since construction (or last `clear`). */
51
+ get lateCount(): number;
52
+ /** Events currently held inside the grace window. */
53
+ get heldCount(): number;
54
+ }
@@ -0,0 +1,66 @@
1
+ /**
2
+ * Accumulates count, mean, variance, standard deviation, min, and max
3
+ * over a stream of numbers using Welford's online algorithm.
4
+ *
5
+ * Numerically stable in a single pass — preferred over the naive
6
+ * "sum of squares minus square of sum" form, which loses precision
7
+ * when values are large or closely clustered.
8
+ */
9
+ export declare class RunningStats {
10
+ private _count;
11
+ private _mean;
12
+ private _m2;
13
+ private _min;
14
+ private _max;
15
+ /**
16
+ * Incorporate a value. O(1). Non-finite values (NaN, ±Infinity) are
17
+ * ignored — they would corrupt every downstream statistic — matching
18
+ * `IncrementalExtent`'s filter so all accumulators agree on what counts.
19
+ */
20
+ push(value: number): void;
21
+ /**
22
+ * Fold another accumulator's statistics into this one, in O(1),
23
+ * without revisiting the underlying values. Uses the parallel
24
+ * variance combine (Chan, Golub & LeVeque). Associative and
25
+ * commutative up to floating-point rounding — `a.merge(b)` then
26
+ * `a.merge(c)` yields the same result as merging in any order.
27
+ *
28
+ * Merging an empty accumulator is a no-op; merging into an empty
29
+ * accumulator copies the other's state.
30
+ */
31
+ merge(other: RunningStats): void;
32
+ /** Reset to the empty state. */
33
+ clear(): void;
34
+ /** A detached copy — useful for snapshotting a window before rollup. */
35
+ clone(): RunningStats;
36
+ /** Number of values incorporated. */
37
+ get count(): number;
38
+ /** Arithmetic mean, or 0 when empty. */
39
+ get mean(): number;
40
+ /**
41
+ * Sum of all values. Derived as `mean × count`, so it carries the
42
+ * same (tiny) floating drift as the running mean rather than a
43
+ * separate exact accumulator.
44
+ */
45
+ get sum(): number;
46
+ /**
47
+ * Population variance (divides by `count`). 0 when fewer than two
48
+ * values have been seen. Use this for a complete window of points —
49
+ * the window *is* the population. See {@link sampleVariance} for the
50
+ * unbiased estimator over a sample.
51
+ */
52
+ get variance(): number;
53
+ /** Population standard deviation — `sqrt(variance)`. */
54
+ get stddev(): number;
55
+ /**
56
+ * Sample variance (divides by `count − 1`, Bessel's correction).
57
+ * 0 when fewer than two values have been seen.
58
+ */
59
+ get sampleVariance(): number;
60
+ /** Sample standard deviation — `sqrt(sampleVariance)`. */
61
+ get sampleStddev(): number;
62
+ /** Smallest value seen, or `Infinity` when empty. */
63
+ get min(): number;
64
+ /** Largest value seen, or `-Infinity` when empty. */
65
+ get max(): number;
66
+ }