serverside_pivot 0.0.96 → 0.0.98

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 (52) hide show
  1. package/README.md +5 -4
  2. package/dist/react/chunks/ContextMenu-DQGCdUhU.mjs +211 -0
  3. package/dist/react/chunks/{DetailDrawer-DgKSC5Vu.mjs → DetailDrawer-yMFRd6Td.mjs} +1 -1
  4. package/dist/react/chunks/{DetailSidePanel-CC5Dugyl.mjs → DetailSidePanel-B6fYMnn7.mjs} +1 -1
  5. package/dist/react/chunks/{DetailSurfaceContent-CrQVHlcU.mjs → DetailSurfaceContent-B9cfLYti.mjs} +1 -1
  6. package/dist/react/chunks/{ECharts2dRenderer-46gLrUdf.mjs → ECharts2dRenderer-ER6rHtch.mjs} +1 -1
  7. package/dist/react/chunks/{ECharts3dRenderer-Dg4ta5Bl.mjs → ECharts3dRenderer-BMVfbpXH.mjs} +1 -1
  8. package/dist/react/chunks/{EditSidePanel-CkShaByb.mjs → EditSidePanel-BjJd5BaX.mjs} +1 -1
  9. package/dist/react/chunks/{InlineDetailPanel-mnwjoD0I.mjs → InlineDetailPanel-Bbkpv9jz.mjs} +1 -1
  10. package/dist/react/chunks/{PivotCharts-MX-Z7DlR.mjs → PivotCharts-P5cBJcwu.mjs} +5 -3
  11. package/dist/react/chunks/{ReportEditor-U0E42xKL.mjs → ReportEditor-P4UZ97Ik.mjs} +174 -175
  12. package/dist/react/chunks/{SidebarPanel-BzRW1Kgq.mjs → SidebarPanel-DRoxHRhK.mjs} +1039 -1024
  13. package/dist/react/chunks/{SparklineDetailGraph-35Tim_8B.mjs → SparklineDetailGraph-C9UX-feP.mjs} +22 -22
  14. package/dist/react/chunks/clientCoreRuntime-n2guUxhp.mjs +790 -0
  15. package/dist/react/chunks/{installCanvasRenderer-DRq0xpXO.mjs → installCanvasRenderer-BR0XmdVX.mjs} +1 -1
  16. package/dist/react/chunks/{react-CL4GbEOd.mjs → react-B5JcZShu.mjs} +17394 -13825
  17. package/dist/react/chunks/{xlsx.mini.min-kfIgXMVB.mjs → xlsx.mini.min-YUTWASKG.mjs} +1 -1
  18. package/dist/react/components/DashTanstackPivot.react.d.ts +6 -0
  19. package/dist/react/components/GlobalSearchInput.d.ts +17 -0
  20. package/dist/react/components/LiveCellDisplay.d.ts +25 -0
  21. package/dist/react/components/LiveExplainSidePanel.d.ts +15 -0
  22. package/dist/react/components/LiveStreamDiffBar.d.ts +15 -0
  23. package/dist/react/hooks/useDismiss.d.ts +43 -0
  24. package/dist/react/hooks/usePivotNormalization.d.ts +4 -0
  25. package/dist/react/hooks/usePrefersReducedMotion.d.ts +8 -0
  26. package/dist/react/hooks/useRenderHelpers.d.ts +1 -1
  27. package/dist/react/hooks/useRowCache.d.ts +2 -0
  28. package/dist/react/hooks/useServerSideRowModel.d.ts +1 -1
  29. package/dist/react/index.mjs +28 -19
  30. package/dist/react/react.d.ts +6 -1
  31. package/dist/react/runtime/client/clientPivotTransport.d.ts +16 -0
  32. package/dist/react/runtime/client/clientResponsePostProcessor.d.ts +8 -1
  33. package/dist/react/runtime/client/clientSubscriptionEngine.d.ts +88 -0
  34. package/dist/react/runtime/client/duckdbWasmExecutor.d.ts +22 -0
  35. package/dist/react/runtime/client/index.d.ts +1 -0
  36. package/dist/react/runtime/client/types.d.ts +6 -0
  37. package/dist/react/runtime/core/clientCoreRuntime.d.ts +46 -0
  38. package/dist/react/runtime/core/duckdbSqlEmitter.d.ts +37 -0
  39. package/dist/react/runtime/core/semanticIr.generated.d.ts +196 -0
  40. package/dist/react/runtime/responseQueue.d.ts +21 -0
  41. package/dist/react/runtime/rowIdentity.d.ts +20 -0
  42. package/dist/react/runtime/runtimeDomains.d.ts +8 -1
  43. package/dist/react/runtime/streamingTypes.d.ts +182 -0
  44. package/dist/react/runtime/useRuntimeViewportTableData.d.ts +1 -1
  45. package/dist/react/runtime/useViewportSubscriptionStore.d.ts +112 -0
  46. package/dist/react/runtime/useWorkspaceStatusPresentation.d.ts +1 -1
  47. package/dist/react/utils/helpers.d.ts +1 -1
  48. package/dist/react/utils/pivotLayoutUtils.d.ts +3 -3
  49. package/dist/react/utils/rowMotion.d.ts +108 -0
  50. package/dist/react/utils/styles.d.ts +1 -0
  51. package/package.json +6 -8
  52. package/dist/react/chunks/ContextMenu-DJuS4qTZ.mjs +0 -198
@@ -1,4 +1,4 @@
1
- import { g as Zf } from "./react-CL4GbEOd.mjs";
1
+ import { g as Zf } from "./react-B5JcZShu.mjs";
2
2
  function qf(Rt, wr) {
3
3
  for (var Zt = 0; Zt < wr.length; Zt++) {
4
4
  const St = wr[Zt];
@@ -103,6 +103,9 @@ export interface DashTanstackPivotProps {
103
103
  activeReportId?: string;
104
104
  rowSelection?: string | boolean;
105
105
  selectedRows?: Array<string>;
106
+ streamingConfig?: object;
107
+ streamUpdates?: object;
108
+ diffConfig?: object;
106
109
  }
107
110
  /** Value-axis configuration accepted by the public Dash API. */
108
111
  export interface DashValueConfig {
@@ -407,6 +410,9 @@ declare namespace DashTanstackPivot {
407
410
  activeReportId: PropTypes.Requireable<string>;
408
411
  rowSelection: PropTypes.Requireable<NonNullable<string | boolean | null | undefined>>;
409
412
  selectedRows: PropTypes.Requireable<(string | null | undefined)[]>;
413
+ streamingConfig: PropTypes.Requireable<object>;
414
+ streamUpdates: PropTypes.Requireable<object>;
415
+ diffConfig: PropTypes.Requireable<object>;
410
416
  };
411
417
  }
412
418
  export default DashTanstackPivot;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * The global search box. Typing updates the box at once; the ``filters.global`` change, and with it
3
+ * the server request, is committed once typing pauses, so a typed word is one request instead of
4
+ * one per keystroke. Clearing the box commits immediately. A value changed elsewhere (saved view,
5
+ * reset) replaces the draft.
6
+ * @param {{ value: string, onCommit: (value: string) => void, style?: React.CSSProperties, placeholder?: string }} props
7
+ * @returns {any}
8
+ */
9
+ export function GlobalSearchInput({ value, onCommit, style, placeholder }: {
10
+ value: string;
11
+ onCommit: (value: string) => void;
12
+ style?: React.CSSProperties;
13
+ placeholder?: string;
14
+ }): any;
15
+ /** Quiet time after the last keystroke before the search becomes a filter (one data request). */
16
+ export const GLOBAL_SEARCH_COMMIT_DELAY_MS: 250;
17
+ import React from 'react';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Granular Per-Cell Reactive Live & Diff Renderer (Component 6).
3
+ *
4
+ * Subscribes ONLY to its own `(rowKey, colId)` entry inside `ViewportSubscriptionStore`:
5
+ * - Triggers compositor-only tick flashes (an overlay's opacity via `Element.animate()`, ZERO React timers)
6
+ * with a ▲/▼ glyph so the direction is never conveyed by colour alone.
7
+ * - Renders 4-way Diff Display (`Value`, `Δ`, `%Δ` or `pp`, `Split`) with tabular-nums.
8
+ * - Renders `NEW` / `REMOVED` row badges on hierarchy cells & `softStale` syncing indicator.
9
+ * - Renders an institutional **PnL Explain & 30-Point Rolling Sparkline** popover on hover.
10
+ */
11
+ import React from 'react';
12
+ import { type ViewportSubscriptionStore } from '../runtime/useViewportSubscriptionStore';
13
+ export interface LiveCellDisplayProps {
14
+ readonly store: ViewportSubscriptionStore;
15
+ readonly rowKey: string;
16
+ readonly colId: string;
17
+ readonly rowLabel?: string;
18
+ readonly colLabel?: string;
19
+ readonly isHierarchy?: boolean;
20
+ readonly softStale?: boolean;
21
+ readonly isDark?: boolean;
22
+ readonly theme?: Record<string, unknown> | null;
23
+ readonly fallbackContent: React.ReactNode;
24
+ }
25
+ export declare const LiveCellDisplay: React.FC<LiveCellDisplayProps>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Docked Live PnL Explain & Trajectory Side Panel.
3
+ *
4
+ * Opened by clicking any cell's hover PnL Explain card (just like docked chart / detail
5
+ * side panels). Subscribes directly to the pinned `(rowKey, colId)` inside
6
+ * `ViewportSubscriptionStore`, updating live on every tick with zero grid re-renders.
7
+ */
8
+ import React from 'react';
9
+ import { type ViewportSubscriptionStore } from '../runtime/useViewportSubscriptionStore';
10
+ export interface LiveExplainSidePanelProps {
11
+ readonly store?: ViewportSubscriptionStore | null;
12
+ readonly theme?: Record<string, unknown> | null;
13
+ readonly width?: number;
14
+ }
15
+ export declare const LiveExplainSidePanel: React.FC<LiveExplainSidePanelProps>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Institutional Live Stream & Baseline Diff Control Strip.
3
+ *
4
+ * Renders directly above the pivot grid ONLY when streaming or baseline diff is active.
5
+ * Subscribes exclusively to `ViewportSubscriptionStore.subscribeStatus`, isolating
6
+ * toolbar updates from grid cells.
7
+ * Sized to fit cleanly on a single row even inside constrained 580px center panes.
8
+ */
9
+ import React from 'react';
10
+ import { type ViewportSubscriptionStore } from '../runtime/useViewportSubscriptionStore';
11
+ export interface LiveStreamDiffBarProps {
12
+ readonly store?: ViewportSubscriptionStore | null;
13
+ readonly theme?: Record<string, unknown> | null;
14
+ }
15
+ export declare const LiveStreamDiffBar: React.FC<LiveStreamDiffBarProps>;
@@ -0,0 +1,43 @@
1
+ /**
2
+ * Shared overlay dismissal hook: handles Escape (capture phase), outside clicks,
3
+ * and clean focus restoration to the previously focused trigger element.
4
+ *
5
+ * @param {object} options
6
+ * @param {boolean} options.open
7
+ * @param {(() => void) | null | undefined} options.onClose
8
+ * @param {Array<React.RefObject<any> | Element | null | undefined>} [options.refs]
9
+ * @param {boolean} [options.restoreFocus]
10
+ * @param {boolean} [options.enabled]
11
+ */
12
+ export function useDismiss({ open, onClose, refs, restoreFocus, enabled, }: {
13
+ open: boolean;
14
+ onClose: (() => void) | null | undefined;
15
+ refs?: (Element | React.RefObject<any> | null | undefined)[] | undefined;
16
+ restoreFocus?: boolean | undefined;
17
+ enabled?: boolean | undefined;
18
+ }): void;
19
+ /**
20
+ * Resolves the safest portal container: ShadowRoot host container if mounted inside
21
+ * a ShadowRoot (e.g. Streamlit/web component), otherwise `document.body`.
22
+ * Returns `null` in SSR or pure-Node VDOM tests.
23
+ *
24
+ * @param {any} [anchorEl]
25
+ * @returns {Element | DocumentFragment | null}
26
+ */
27
+ export function resolveOverlayPortalTarget(anchorEl?: any): Element | DocumentFragment | null;
28
+ /**
29
+ * Renders floating overlay content into a top-level portal while preserving
30
+ * `data-pivot-workspace-root` selectors, `--sp-*` CSS tokens, colorScheme,
31
+ * and `@media (prefers-reduced-motion: reduce)` rules.
32
+ *
33
+ * @param {{ children: React.ReactNode, theme?: any, anchorEl?: any, zIndex?: number }} props
34
+ * @returns {any}
35
+ */
36
+ export function OverlayPortal({ children, theme, anchorEl, zIndex }: {
37
+ children: React.ReactNode;
38
+ theme?: any;
39
+ anchorEl?: any;
40
+ zIndex?: number;
41
+ }): any;
42
+ export default useDismiss;
43
+ import React from 'react';
@@ -137,6 +137,10 @@ export function clampSidebarWidth(value?: any, fallback?: any): any;
137
137
  export function clampDecimalPlaces(value?: any, fallback?: any): any;
138
138
  export function normalizeDefaultValueFormat(value?: any): any;
139
139
  export function mergeSparseColSchema(previousSchema?: any, incomingSchema?: any, fallbackSize?: any): any;
140
+ export function deliveredSchemaWindow(columns?: any): {
141
+ start: number | null;
142
+ end: number | null;
143
+ };
140
144
  export function isSparseSchemaRangeLoaded(schema?: any, start?: any, end?: any): any;
141
145
  export function normalizePerformanceConfigValue(value?: any): any;
142
146
  export function buildLargeColumnAdvisory({ serverSide, totalCenterCols, colFields }: any): any;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Returns true when the user has requested reduced motion at the OS/browser level.
3
+ * SSR- and JSDOM-safe: returns false when `window.matchMedia` is unavailable.
4
+ *
5
+ * @returns {boolean}
6
+ */
7
+ export function usePrefersReducedMotion(): boolean;
8
+ export default usePrefersReducedMotion;
@@ -13,5 +13,5 @@
13
13
  * hoveredHeaderId, focusedHeaderId, theme — all are read synchronously when
14
14
  * renderHeaderCell is called, capturing the value from the current render pass.
15
15
  @param {any} p0 @returns {any} */
16
- export function useRenderHelpers({ serverSide, selectedCells, fillRange, dragStart, theme, getStickyStyle, isDarkTheme, handleCellMouseDown, handleCellMouseEnter, handleContextMenu, handleFillMouseDown, visibleLeafColIndexMap, lastSelected, styles, getConditionalStyle, rowHeight, headerHeight: headerHeightProp, rowFields, tableRef, leftCols, centerCols, rightCols, columnPinning, sorting, sortOptions, fontFamily, fontSize, handleHeaderContextMenu, autoSizeColumn, autoSizeBounds, hoveredHeaderIdRef, setHoveredHeaderId, focusedHeaderIdRef, setFocusedHeaderId, onDragStart, onHeaderDrop, onHeaderDragOver, onHeaderDragEnd, onHeaderKeyboardMove, onHeaderKeyboardPin, dragOverHeaderId, dragOverSide, handleFilterClick, handleHeaderFilter, activeFilterCol, filterAnchorEl, closeFilterPopover, activeFilterOptions, activeFilterOptionMeta, requestFilterOptions, filters, selectedCols, getHeaderStickyStyle, dataBarsColumns, dataBarMaximums, dataBarVariant, colorScaleStats, cellFormatRules, resolveEditedCellMarker, resolveCellDisplayValue, editedCellEpoch, headerFormatting, getLocaleText, wrapHeaders, table, selectedRowKeys, toggleRowCheckbox, rowCheckboxMode, }: any): any;
16
+ export function useRenderHelpers({ serverSide, selectedCells, fillRange, dragStart, theme, getStickyStyle, isDarkTheme, handleCellMouseDown, handleCellMouseEnter, handleContextMenu, handleFillMouseDown, visibleLeafColIndexMap, lastSelected, styles, getConditionalStyle, rowHeight, headerHeight: headerHeightProp, rowFields, tableRef, leftCols, centerCols, rightCols, columnPinning, sorting, sortOptions, fontFamily, fontSize, handleHeaderContextMenu, autoSizeColumn, autoSizeBounds, hoveredHeaderIdRef, setHoveredHeaderId, focusedHeaderIdRef, setFocusedHeaderId, onDragStart, onHeaderDrop, onHeaderDragOver, onHeaderDragEnd, onHeaderKeyboardMove, onHeaderKeyboardPin, dragOverHeaderId, dragOverSide, handleFilterClick, handleHeaderFilter, activeFilterCol, filterAnchorEl, closeFilterPopover, activeFilterOptions, activeFilterOptionMeta, requestFilterOptions, filters, selectedCols, getHeaderStickyStyle, dataBarsColumns, dataBarMaximums, dataBarVariant, colorScaleStats, cellFormatRules, resolveEditedCellMarker, resolveCellDisplayValue, editedCellEpoch, headerFormatting, getLocaleText, wrapHeaders, table, selectedRowKeys, toggleRowCheckbox, rowCheckboxMode, liveSubscriptionStore, }: any): any;
17
17
  export function resolveHeaderRowSpan(header?: any): any;
@@ -10,11 +10,13 @@ export function useRowCache({ blockSize, maxBlocks }?: {
10
10
  invalidateFromBlock: (...args: any[]) => any;
11
11
  softInvalidateFromBlock: (...args: any[]) => any;
12
12
  softInvalidateRange: (...args: any[]) => any;
13
+ patchRowsByKey: (...args: any[]) => any;
13
14
  pruneToRange: (...args: any[]) => any;
14
15
  setPinnedRange: (...args: any[]) => any;
15
16
  getRow: (...args: any[]) => any;
16
17
  getLoadedBlocks: (...args: any[]) => any;
17
18
  cacheVersion: any;
19
+ blockStructureVersion: any;
18
20
  blockSize: number;
19
21
  currentEpochRef: any;
20
22
  };
@@ -1 +1 @@
1
- export function useServerSideRowModel({ parentRef, serverSide, rowCount, rowHeight, data, dataOffset, dataVersion, dataStateEpoch, setProps, blockSize, maxBlocksInCache, blockLoadDebounceMs, rowOverscan, prefetchColumns, estimateRowHeight, keyMapper, cacheKey, excludeGrandTotal, immersiveMode, stateEpoch, sessionId, clientInstance, tableName, abortGeneration, structuralInFlight, stateEpochRef, structuralPendingVersionRef, requestVersionRef: externalRequestVersionRef, colStart, colEnd, responseColStart, responseColEnd, needsColSchema, columnRangeUrgencyToken, onViewportRequest, layoutMode, showSubtotals, layoutRequestFields, }: any): any;
1
+ export function useServerSideRowModel({ parentRef, serverSide, rowCount, rowHeight, data, dataOffset, dataVersion, dataStateEpoch, setProps, blockSize, maxBlocksInCache, blockLoadDebounceMs, rowOverscan, prefetchColumns, estimateRowHeight, keyMapper, cacheKey, excludeGrandTotal, immersiveMode, stateEpoch, sessionId, clientInstance, tableName, abortGeneration, structuralInFlight, stateEpochRef, structuralPendingVersionRef, pendingExpansionRef, requestVersionRef: externalRequestVersionRef, colStart, colEnd, responseColStart, responseColEnd, needsColSchema, columnRangeUrgencyToken, onViewportRequest, layoutMode, showSubtotals, layoutRequestFields, }: any): any;
@@ -1,22 +1,31 @@
1
- import { aq as s, ar as t, as as o, at as i, au as r, av as n, aw as l, ax as u, ay as c, az as m, aA as p, aB as v, aC as d, aD as C, aE as h, aF as E, aG as P, aH as T, aI as x } from "./chunks/react-CL4GbEOd.mjs";
1
+ import { as as s, at as i, au as t, av as r, aw as o, ax as n, ay as l, az as c, aA as p, aB as u, aC as m, aD as v, aE as d, aF as S, aG as C, aH as D, aI as E, aJ as P, aK as T, aL as V, aM as h, aN as x, aO as L, aP as W, aQ as b, aR as f, aS as g, aT as y } from "./chunks/react-B5JcZShu.mjs";
2
2
  export {
3
3
  s as ClientPivotTransport,
4
- t as ClientResponsePostProcessor,
5
- o as ClientSqlPlanner,
6
- i as DuckDbWasmExecutor,
7
- r as HttpPivotTransport,
8
- n as LatestViewportScheduler,
9
- l as PivotWorkspace,
10
- u as buildThemeCssVars,
11
- c as computeFitToWidthLayout,
12
- m as formatValue,
13
- p as injectThemeCssVars,
14
- v as isDisplayNegative,
15
- d as normalizeClientEngineKind,
16
- C as normalizeExecutionMode,
17
- h as resolveClientEngineKind,
18
- E as resolveExecutionMode,
19
- P as resolveThemeOverrides,
20
- T as scaleValueForDisplay,
21
- x as themes
4
+ i as ClientResponsePostProcessor,
5
+ t as ClientSqlPlanner,
6
+ r as ClientSubscriptionEngine,
7
+ o as DuckDbWasmExecutor,
8
+ n as HttpPivotTransport,
9
+ l as LatestViewportScheduler,
10
+ c as LiveCellDisplay,
11
+ p as LiveExplainSidePanel,
12
+ u as LiveStreamDiffBar,
13
+ m as PivotWorkspace,
14
+ v as ViewportSubscriptionStore,
15
+ d as buildThemeCssVars,
16
+ S as computeFitToWidthLayout,
17
+ C as decodeWireNumeric,
18
+ D as formatValue,
19
+ E as formatWireDecimalString,
20
+ P as injectThemeCssVars,
21
+ T as isDisplayNegative,
22
+ V as isWireDecimal,
23
+ h as normalizeClientEngineKind,
24
+ x as normalizeExecutionMode,
25
+ L as resolveClientEngineKind,
26
+ W as resolveExecutionMode,
27
+ b as resolveThemeOverrides,
28
+ f as scaleValueForDisplay,
29
+ g as themes,
30
+ y as useViewportSubscriptionStore
22
31
  };
@@ -5,7 +5,12 @@ export { themes, injectThemeCssVars } from './utils/styles';
5
5
  export { resolveThemeOverrides, buildThemeCssVars } from './utils/styles';
6
6
  export { isDisplayNegative, formatValue, scaleValueForDisplay } from './utils/helpers';
7
7
  export { computeFitToWidthLayout } from './utils/pivotLayoutUtils';
8
- export { ClientPivotTransport, DuckDbWasmExecutor, ClientSqlPlanner, ClientResponsePostProcessor, resolveExecutionMode, resolveClientEngineKind, normalizeExecutionMode, normalizeClientEngineKind, type ExecutionMode, type ClientEngineKind, type ClientRuntimeConfig, type ClientEngineTelemetry, type LogicalPivotPlan, } from './runtime/client/index';
8
+ export { ClientPivotTransport, ClientSubscriptionEngine, DuckDbWasmExecutor, ClientSqlPlanner, ClientResponsePostProcessor, resolveExecutionMode, resolveClientEngineKind, normalizeExecutionMode, normalizeClientEngineKind, type ExecutionMode, type ClientEngineKind, type ClientRuntimeConfig, type ClientEngineTelemetry, type LogicalPivotPlan, } from './runtime/client/index';
9
+ export { ViewportSubscriptionStore, useViewportSubscriptionStore, } from './runtime/useViewportSubscriptionStore';
10
+ export { LiveStreamDiffBar } from './components/LiveStreamDiffBar';
11
+ export { LiveCellDisplay } from './components/LiveCellDisplay';
12
+ export { LiveExplainSidePanel } from './components/LiveExplainSidePanel';
13
+ export { isWireDecimal, decodeWireNumeric, formatWireDecimalString, type StreamingConfig, type DiffConfig, type DiffDisplayMode, type SortLockMode, type StreamUpdateBatch, type ProtocolV2Frame, type StreamCellPatch, type StreamRowPatch, type BaselineCellDiff, type BaselineDescriptor, type VarianceDriver, type CellLiveMeta, type PinnedExplainCell, type SubscriptionStatusSnapshot, type WireDecimal, } from './runtime/streamingTypes';
9
14
  export type { PivotWorkspaceProps } from './components/PivotWorkspace';
10
15
  export type { PivotRuntimeProps, PivotThemeName, PivotThemeOverrides, PivotValueConfig, ValConfig, FilterCondition, FilterConfig, SortConfig, ChartDefinition, } from './runtime/runtimeDomains';
11
16
  export type { RuntimeRequestV1, RuntimeResponseV1, RuntimeRequestSchemaV1, RuntimeResponseSchemaV1, } from './runtime/runtimeContract';
@@ -1,5 +1,7 @@
1
1
  import type { PayloadReference, RuntimeTransportRequestOptions } from '../httpTransport';
2
2
  import { type JsonObject, type RuntimeRequestV1, type RuntimeResponseV1 } from '../runtimeContract';
3
+ import { ClientSubscriptionEngine } from './clientSubscriptionEngine';
4
+ import type { BaselineDescriptor, StreamUpdateBatch } from '../streamingTypes';
3
5
  import type { ClientEngineTelemetry, ClientPivotTransportInterface, ClientRuntimeConfig, DrillThroughQuery, DrillThroughResult } from './types';
4
6
  export interface ClientPivotTransportOptions extends ClientRuntimeConfig {
5
7
  data?: Array<{
@@ -13,10 +15,18 @@ export declare class ClientPivotTransport implements ClientPivotTransportInterfa
13
15
  private payloadStore;
14
16
  private exportStore;
15
17
  private exportJobStore;
18
+ private subscriptionEngine;
16
19
  constructor(options?: ClientPivotTransportOptions);
20
+ /** Release DuckDB-Wasm resources (the transport stays usable and re-initialises lazily). */
21
+ dispose(): void;
17
22
  setData(rows: Array<{
18
23
  [key: string]: unknown;
19
24
  }>): void;
25
+ applyStreamUpdates(batch: StreamUpdateBatch): number;
26
+ captureBaseline(label?: string): BaselineDescriptor;
27
+ freezeSnapshot(label?: string): BaselineDescriptor;
28
+ listBaselines(): BaselineDescriptor[];
29
+ getSubscriptionEngine(): ClientSubscriptionEngine;
20
30
  getData(): Array<{
21
31
  [key: string]: unknown;
22
32
  }>;
@@ -27,6 +37,12 @@ export declare class ClientPivotTransport implements ClientPivotTransportInterfa
27
37
  private retainExportJob;
28
38
  private loadXlsxWriter;
29
39
  request(request: RuntimeRequestV1, options?: RuntimeTransportRequestOptions): Promise<RuntimeResponseV1>;
40
+ /**
41
+ * Answer a data request with the semantic core: the IR is emitted as DuckDB SQL and run on the
42
+ * DuckDB-Wasm connection. ``null`` (legacy path) only when DuckDB cannot run here or the request
43
+ * uses a feature the core does not express; the reason is in the telemetry.
44
+ */
45
+ private serveDataFromCore;
30
46
  queryDrillThrough(query: DrillThroughQuery): Promise<DrillThroughResult>;
31
47
  fetchPayload(reference: PayloadReference, _options?: RuntimeTransportRequestOptions): Promise<JsonObject>;
32
48
  fetchExportPayload(reference: PayloadReference, _options?: RuntimeTransportRequestOptions): Promise<Blob>;
@@ -11,7 +11,14 @@ export declare function evaluateSafeFormula(expression: string, context: {
11
11
  };
12
12
  export declare class ClientResponsePostProcessor {
13
13
  static buildResponse(plan: LogicalPivotPlan, executed: ClientExecutedDataset): RuntimeResponseV1;
14
- static buildDataResponse(plan: LogicalPivotPlan, executed: ClientExecutedDataset): RuntimeResponseV1;
14
+ static buildDataResponse(plan: LogicalPivotPlan, executed: ClientExecutedDataset, prebuilt?: {
15
+ rows: Array<{
16
+ [key: string]: unknown;
17
+ }>;
18
+ grandTotalRow: {
19
+ [key: string]: unknown;
20
+ } | null;
21
+ }): RuntimeResponseV1;
15
22
  static buildFilterOptionsResponse(plan: LogicalPivotPlan, executed: ClientExecutedDataset): RuntimeResponseV1;
16
23
  static buildChartResponse(plan: LogicalPivotPlan, executed: ClientExecutedDataset): RuntimeResponseV1;
17
24
  static executeDrillThroughQuery(allRows: Array<{
@@ -0,0 +1,88 @@
1
+ /**
2
+ * Client-side implementation of the Protocol V2 Snapshot + Diff Subscription Engine.
3
+ *
4
+ * Mirrors the Python backend's exact mathematical & lifecycle contracts in the browser
5
+ * for `ClientPivotTransport` (in-memory & DuckDB-Wasm execution modes):
6
+ * - Monotonic `sourceRevision`, `eventSeq` (`baseSeq -> seq`), `queryEpoch`, `serverEpochId`
7
+ * - Exact valid-masked weighted averages (`x != null && w != null`)
8
+ * - Measure-specific removed-group diff rules (`SUM`/`COUNT` -> 0 / -B / -100%; `AVG`/`WAVG`/`MIN`/`MAX`/ratio -> null)
9
+ * - `0 -> 0` safe percentage delta (`delta = 0`, `pctDelta = null`)
10
+ * - Top-3 child variance attribution (`_varianceDrivers` for PnL Explain)
11
+ * - Distinct `Pause Live` (visual hold + buffered updates) vs `Freeze Snapshot` (immutable frozen view)
12
+ * - `Sort Lock` (`in_place` vs `live_rank`) & `changedOnly` filtering
13
+ */
14
+ import type { BaselineDescriptor, ProtocolV2Frame, SortLockMode, StreamUpdateBatch } from '../streamingTypes';
15
+ import type { NormalizedValConfig } from './types';
16
+ export interface ClientQueryShape {
17
+ readonly table: string;
18
+ readonly rowFields: readonly string[];
19
+ readonly colFields: readonly string[];
20
+ readonly valConfigs: readonly NormalizedValConfig[];
21
+ readonly sorting?: readonly {
22
+ id: string;
23
+ desc?: boolean;
24
+ }[];
25
+ }
26
+ export interface ClientSubscriptionState {
27
+ readonly subscriptionId: string;
28
+ shape: ClientQueryShape;
29
+ seq: number;
30
+ lastAckSeq: number;
31
+ queryEpoch: number;
32
+ paused: boolean;
33
+ bufferedUpdates: number;
34
+ frozenSnapshotId: string | null;
35
+ baselineId: string | null;
36
+ sortLock: SortLockMode;
37
+ changedOnly: boolean;
38
+ pinnedRowOrder: string[];
39
+ lastRowsByKey: Map<string, Record<string, unknown>>;
40
+ lastGrandTotal: Record<string, unknown> | null;
41
+ listener?: (frame: ProtocolV2Frame) => void;
42
+ }
43
+ export declare class ClientSubscriptionEngine {
44
+ readonly serverEpochId: string;
45
+ private sourceRevision;
46
+ private schemaVersion;
47
+ private rows;
48
+ private snapshots;
49
+ private subscriptions;
50
+ private onRowsReplaced?;
51
+ constructor(initialRows?: readonly Record<string, unknown>[], onRowsReplaced?: (rows: Record<string, unknown>[]) => void);
52
+ private computeSchemaVersion;
53
+ getSourceRevision(): number;
54
+ setRows(nextRows: readonly Record<string, unknown>[]): void;
55
+ getRows(): Record<string, unknown>[];
56
+ /** Apply an atomic insert/update/upsert/delete batch to the client dataset and notify subscribers. */
57
+ applyStreamUpdates(batch: StreamUpdateBatch): number;
58
+ captureSnapshot(label?: string, kind?: 'baseline' | 'freeze_snapshot'): BaselineDescriptor;
59
+ listBaselines(): BaselineDescriptor[];
60
+ subscribe(shape: ClientQueryShape, options?: {
61
+ baselineId?: string | null;
62
+ sortLock?: SortLockMode;
63
+ changedOnly?: boolean;
64
+ listener?: (frame: ProtocolV2Frame) => void;
65
+ }): {
66
+ subscription: ClientSubscriptionState;
67
+ initialFrame: ProtocolV2Frame;
68
+ };
69
+ unsubscribe(subscriptionId: string): void;
70
+ acknowledge(subscriptionId: string, seq: number): void;
71
+ pause(subscriptionId: string): ProtocolV2Frame | null;
72
+ resume(subscriptionId: string): ProtocolV2Frame | null;
73
+ freeze(subscriptionId: string, label?: string): {
74
+ descriptor: BaselineDescriptor;
75
+ frame: ProtocolV2Frame;
76
+ } | null;
77
+ unfreeze(subscriptionId: string): ProtocolV2Frame | null;
78
+ setBaseline(subscriptionId: string, baselineId: string | null): ProtocolV2Frame | null;
79
+ updateOptions(subscriptionId: string, opts: {
80
+ sortLock?: SortLockMode;
81
+ changedOnly?: boolean;
82
+ shape?: ClientQueryShape;
83
+ }): ProtocolV2Frame | null;
84
+ private materializeRows;
85
+ private buildSnapshotFrame;
86
+ private buildHeartbeatFrame;
87
+ private broadcastUpdates;
88
+ }
@@ -17,6 +17,7 @@ export declare class DuckDbWasmExecutor {
17
17
  private wasmRetryAfter;
18
18
  private dbInstance;
19
19
  private dbConn;
20
+ private worker;
20
21
  private registeredTableSignature;
21
22
  private preparedCache;
22
23
  private cachedAvailableFields;
@@ -32,8 +33,29 @@ export declare class DuckDbWasmExecutor {
32
33
  }>;
33
34
  getAvailableFields(): string[];
34
35
  updateConfig(config: Partial<ClientRuntimeConfig>): void;
36
+ /**
37
+ * Release the DuckDB connection, database and worker. The executor stays usable:
38
+ * the next request re-initialises DuckDB-Wasm (safe under React StrictMode remounts).
39
+ */
40
+ dispose(): void;
35
41
  getTelemetry(): ClientEngineTelemetry;
36
42
  private tryInitializeWasm;
37
43
  private ensureTableRegistered;
44
+ /**
45
+ * The DuckDB connection with ``table`` registered, initialising DuckDB-Wasm when it can run,
46
+ * or ``null`` when it cannot (no bundle, offline file origin, no Worker).
47
+ */
48
+ coreConnection(table: string): Promise<{
49
+ query: (sql: string) => Promise<unknown>;
50
+ } | null>;
51
+ /** Record a request answered by the semantic core (or the reason it was not). */
52
+ recordCoreOutcome(outcome: {
53
+ served: true;
54
+ sql: string;
55
+ executionMs: number;
56
+ } | {
57
+ served: false;
58
+ reason: string;
59
+ }): void;
38
60
  execute(plan: LogicalPivotPlan): Promise<ClientExecutedDataset>;
39
61
  }
@@ -3,4 +3,5 @@ export * from './modeResolver';
3
3
  export * from './clientSqlPlanner';
4
4
  export * from './duckdbWasmExecutor';
5
5
  export * from './clientResponsePostProcessor';
6
+ export * from './clientSubscriptionEngine';
6
7
  export * from './clientPivotTransport';
@@ -28,6 +28,9 @@ export interface ClientEngineTelemetry {
28
28
  rowCount: number;
29
29
  networkRoundtrips: number;
30
30
  lastUpdatedAt: number;
31
+ /** 'core' when the semantic core (emitted SQL on DuckDB) answered; else why the legacy path did. */
32
+ coreServed?: boolean;
33
+ coreFallbackReason?: string;
31
34
  }
32
35
  export interface NormalizedValConfig {
33
36
  field: string;
@@ -36,6 +39,7 @@ export interface NormalizedValConfig {
36
39
  label: string;
37
40
  shortLabel?: string;
38
41
  weightField?: string;
42
+ orderBy?: string;
39
43
  windowFn?: string;
40
44
  formula?: string;
41
45
  formulaScope?: 'measures' | 'columns';
@@ -113,6 +117,8 @@ export interface LogicalPivotPlan {
113
117
  };
114
118
  };
115
119
  expandedAll: boolean;
120
+ /** An expanded/collapsed display path has an empty member (NULL vs "" cannot be told apart). */
121
+ expandedAmbiguous?: boolean;
116
122
  expandedPaths: string[][];
117
123
  collapsedPaths: string[][];
118
124
  measureAxis: {
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Client mode on the semantic core (M3).
3
+ *
4
+ * A client `LogicalPivotPlan` (from `ClientSqlPlanner.compile`) is mapped to
5
+ * the same semantic IR the server bridge builds (`transport/core_bridge.py`),
6
+ * emitted as DuckDB SQL (`duckdbSqlEmitter.ts`), executed on the DuckDB-Wasm
7
+ * connection, and shaped into the client row format. Numbers therefore come
8
+ * from DuckDB with the core's semantics, not from JavaScript aggregation.
9
+ *
10
+ * Anything that cannot be mapped exactly throws `EmitterUnsupported`; the
11
+ * caller then serves the request through the legacy client path.
12
+ */
13
+ import type { LogicalPivotPlan } from '../client/types';
14
+ import { EmitterUnsupported, type ColumnInfo, type TypeFamily } from './duckdbSqlEmitter';
15
+ import type { PivotQuery } from './semanticIr.generated';
16
+ export { EmitterUnsupported };
17
+ type Row = {
18
+ [key: string]: unknown;
19
+ };
20
+ export interface QueryConnection {
21
+ query: (sql: string) => Promise<unknown>;
22
+ }
23
+ /** Python `repr(float)`: shortest round-trip digits, scientific below 1e-4 or from 1e16. */
24
+ export declare function pythonFloatRepr(x: number): string;
25
+ export declare function canonicalScalar(value: unknown, family: TypeFamily): string;
26
+ /** `CanonicalPathCodec.encode`: "[]" for the grand total. */
27
+ export declare function canonicalPath(values: unknown[], families: TypeFamily[]): string;
28
+ export interface ClientCoreQuery {
29
+ query: PivotQuery;
30
+ families: TypeFamily[];
31
+ }
32
+ /** Map a client plan to the semantic IR (before column members are known). */
33
+ export declare function planToQuery(plan: LogicalPivotPlan, columns: Record<string, ColumnInfo>): ClientCoreQuery;
34
+ export interface ClientCoreResult {
35
+ rows: Row[];
36
+ grandTotalRow: Row | null;
37
+ colCombinations: string[];
38
+ }
39
+ /** Shape core records (rows dims, value columns, __depth) into the client row format. */
40
+ export declare function shapeRows(plan: LogicalPivotPlan, core: ClientCoreQuery, records: Row[]): ClientCoreResult;
41
+ export declare function familyOf(sqlType: string): TypeFamily;
42
+ export declare function describeColumns(conn: QueryConnection, table: string): Promise<Record<string, ColumnInfo>>;
43
+ /** Serve a client data request from DuckDB with the core's semantics. */
44
+ export declare function runClientCore(plan: LogicalPivotPlan, conn: QueryConnection, table: string): Promise<ClientCoreResult & {
45
+ sql: string;
46
+ }>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * DuckDB SQL emitter for the semantic IR (client mode, M3).
3
+ *
4
+ * Emits, for one `PivotQuery` (the wire form in `semanticIr.generated.ts`,
5
+ * generated from `core/spec/semantic-ir.schema.json`), the same flattened,
6
+ * ordered, windowed tree as the Python core's reference strategy
7
+ * (`pivot_engine/core/logical.py` + `core/physical/union_all.py`):
8
+ *
9
+ * rows dims (NULL where rolled up), measures, derived measures, pivot cells, __depth
10
+ *
11
+ * Semantics are those of docs/semantics/SEMANTICS.md; the conformance test
12
+ * `tests/core/test_ts_emitter_conformance.py` executes this SQL on DuckDB
13
+ * (the engine DuckDB-Wasm runs) and requires it to equal the oracle.
14
+ *
15
+ * Everything the emitter cannot express throws `EmitterUnsupported`; it never
16
+ * approximates.
17
+ */
18
+ import type { PivotQuery } from './semanticIr.generated';
19
+ export type TypeFamily = 'string' | 'integer' | 'floating' | 'decimal' | 'boolean' | 'date' | 'timestamp' | 'other';
20
+ export interface ColumnInfo {
21
+ family: TypeFamily;
22
+ sqlType: string;
23
+ }
24
+ export interface EmitOptions {
25
+ table: string;
26
+ columns: Record<string, ColumnInfo>;
27
+ }
28
+ export declare class EmitterUnsupported extends Error {
29
+ constructor(message: string);
30
+ }
31
+ export declare const DEPTH = "__depth";
32
+ export declare function quoteIdent(name: string): string;
33
+ export declare function cellName(memberIndex: number, alias: string): string;
34
+ /** Output value columns: measures, derived measures, then cells (as `PivotQuery.value_columns`). */
35
+ export declare function valueColumns(query: PivotQuery): string[];
36
+ export declare function emitColumnMembersSql(query: PivotQuery, options: EmitOptions): string;
37
+ export declare function emitPivotSql(query: PivotQuery, options: EmitOptions): string;