@genesislcap/foundation-comms 15.79.2-alpha-e9d30db797.0 → 15.80.0-FUI-2666.1

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 (64) hide show
  1. package/asconfig.json +15 -0
  2. package/assembly/scdb/README.md +74 -0
  3. package/assembly/scdb/bench.mjs +32 -0
  4. package/assembly/scdb/decoder.ts +217 -0
  5. package/assembly/scdb/decoder.wasm +0 -0
  6. package/assembly/scdb/inline-wasm-base64.mjs +24 -0
  7. package/dist/dts/connect/connect.d.ts +2 -0
  8. package/dist/dts/connect/connect.d.ts.map +1 -1
  9. package/dist/dts/connect/http.connect.d.ts +10 -0
  10. package/dist/dts/connect/http.connect.d.ts.map +1 -1
  11. package/dist/dts/connect/message.d.ts +18 -0
  12. package/dist/dts/connect/message.d.ts.map +1 -1
  13. package/dist/dts/connect/scdbStreamDecoder.d.ts +66 -0
  14. package/dist/dts/connect/scdbStreamDecoder.d.ts.map +1 -0
  15. package/dist/dts/connect/socket.d.ts +33 -0
  16. package/dist/dts/connect/socket.d.ts.map +1 -1
  17. package/dist/dts/connect/socket.types.d.ts +14 -0
  18. package/dist/dts/connect/socket.types.d.ts.map +1 -1
  19. package/dist/dts/datasource/datasource.d.ts.map +1 -1
  20. package/dist/dts/datasource/datasource.types.d.ts +8 -0
  21. package/dist/dts/datasource/datasource.types.d.ts.map +1 -1
  22. package/dist/dts/datasource/index.d.ts +1 -0
  23. package/dist/dts/datasource/index.d.ts.map +1 -1
  24. package/dist/dts/datasource/scdb/base64.d.ts +6 -0
  25. package/dist/dts/datasource/scdb/base64.d.ts.map +1 -0
  26. package/dist/dts/datasource/scdb/dictionaryHash.d.ts +40 -0
  27. package/dist/dts/datasource/scdb/dictionaryHash.d.ts.map +1 -0
  28. package/dist/dts/datasource/scdb/index.d.ts +6 -0
  29. package/dist/dts/datasource/scdb/index.d.ts.map +1 -0
  30. package/dist/dts/datasource/scdb/scdb-js-bench.d.mts +2 -0
  31. package/dist/dts/datasource/scdb/scdb-js-bench.d.mts.map +1 -0
  32. package/dist/dts/datasource/scdb/scdbDecode.d.ts +24 -0
  33. package/dist/dts/datasource/scdb/scdbDecode.d.ts.map +1 -0
  34. package/dist/dts/datasource/scdb/scdbDecoder.d.ts +42 -0
  35. package/dist/dts/datasource/scdb/scdbDecoder.d.ts.map +1 -0
  36. package/dist/dts/datasource/scdb/scdbWasmDecoder.d.ts +27 -0
  37. package/dist/dts/datasource/scdb/scdbWasmDecoder.d.ts.map +1 -0
  38. package/dist/dts/datasource/scdb/scdbjDecoder.d.ts +35 -0
  39. package/dist/dts/datasource/scdb/scdbjDecoder.d.ts.map +1 -0
  40. package/dist/dts/datasource/scdb/wasm/decoder.wasm.base64.d.ts +7 -0
  41. package/dist/dts/datasource/scdb/wasm/decoder.wasm.base64.d.ts.map +1 -0
  42. package/dist/dts/testing/mocks/connect/socket.d.ts +1 -0
  43. package/dist/dts/testing/mocks/connect/socket.d.ts.map +1 -1
  44. package/dist/esm/connect/connect.js +22 -3
  45. package/dist/esm/connect/http.connect.js +33 -1
  46. package/dist/esm/connect/message.js +3 -1
  47. package/dist/esm/connect/scdbStreamDecoder.js +160 -0
  48. package/dist/esm/connect/socket.js +132 -2
  49. package/dist/esm/datasource/datasource.js +3 -0
  50. package/dist/esm/datasource/index.js +1 -0
  51. package/dist/esm/datasource/scdb/base64.js +17 -0
  52. package/dist/esm/datasource/scdb/dictionaryHash.js +45 -0
  53. package/dist/esm/datasource/scdb/index.js +5 -0
  54. package/dist/esm/datasource/scdb/scdb-golden-v1.json +15 -0
  55. package/dist/esm/datasource/scdb/scdb-js-bench.mjs +461 -0
  56. package/dist/esm/datasource/scdb/scdbDecode.js +67 -0
  57. package/dist/esm/datasource/scdb/scdbDecoder.js +279 -0
  58. package/dist/esm/datasource/scdb/scdbWasmDecoder.js +213 -0
  59. package/dist/esm/datasource/scdb/scdbjDecoder.js +60 -0
  60. package/dist/esm/datasource/scdb/wasm/decoder.wasm.base64.js +6 -0
  61. package/dist/esm/testing/mocks/connect/socket.js +3 -0
  62. package/dist/foundation-comms.api.json +1453 -8
  63. package/dist/foundation-comms.d.ts +261 -0
  64. package/package.json +14 -12
@@ -20,6 +20,9 @@ import { TypedBroadcastChannel } from '@genesislcap/foundation-broadcast-channel
20
20
  import { User as User_2 } from '@genesislcap/foundation-user';
21
21
  import { UUID } from '@genesislcap/foundation-utils';
22
22
 
23
+ /** @internal */
24
+ export declare function assertScdbMagic(bytes: Uint8Array): void;
25
+
23
26
  /**
24
27
  * Auth is the main interface for authenticating with a Genesis Server endpoint.
25
28
  * @public
@@ -164,6 +167,13 @@ export declare type BasicCredentialsInput = {
164
167
  */
165
168
  export declare function buildRequestCacheKey(resourceName: string, params?: RequestParams): string;
166
169
 
170
+ export declare interface ColumnarQueryUpdate {
171
+ ENCODING?: string;
172
+ ROW?: Array<Record<string, unknown>>;
173
+ RBUF?: Uint8Array | string | number[];
174
+ SCDBJ?: ScdbjPayload;
175
+ }
176
+
167
177
  /**
168
178
  * @public
169
179
  */
@@ -1001,6 +1011,8 @@ export declare type DataserverParams = {
1001
1011
  MOVING_VIEW?: boolean;
1002
1012
  ORDER_BY?: string;
1003
1013
  REVERSE?: boolean;
1014
+ /** Per-subscription columnar encoding override; overrides ConnectConfig.connect.dataserverEncoding. */
1015
+ ENCODING?: ScdbEncoding;
1004
1016
  };
1005
1017
 
1006
1018
  /**
@@ -1753,6 +1765,13 @@ export declare interface DatasourceOptions {
1753
1765
  * @remarks Only works with DATASERVER resources.
1754
1766
  */
1755
1767
  reverse?: boolean;
1768
+ /**
1769
+ * Per-datasource columnar payload encoding, overriding the app-wide
1770
+ * `ConnectConfig.connect.dataserverEncoding`. `'SCDBJ_V1'` (JSON-columnar) or `'SCDB_V1'` (binary).
1771
+ * Negotiated + decoded transparently. Undefined => use the app-wide setting (or row mode).
1772
+ * @remarks Only works with DATASERVER resources.
1773
+ */
1774
+ encoding?: ScdbEncoding;
1756
1775
  /**
1757
1776
  * Whether to disable polling when using request/reply
1758
1777
  * @remarks Only works with REQUEST_SERVER resources, which have no stream and so poll for
@@ -1847,6 +1866,47 @@ export declare interface Dataview {
1847
1866
  hideSearch?: boolean;
1848
1867
  }
1849
1868
 
1869
+ /**
1870
+ * Decodes a QUERY_UPDATE to row objects. Chooses by `ENCODING`:
1871
+ * - `SCDB_V1` -> binary blob: WASM decoder when provided (fastest), else pure-JS.
1872
+ * - `SCDBJ_V1` -> JSON-columnar transpose.
1873
+ * - otherwise -> the message's existing `ROW` array (legacy).
1874
+ */
1875
+ export declare function decodeColumnarQueryUpdate(msg: ColumnarQueryUpdate, dictionary: readonly string[], wasm?: ScdbWasm): Array<Record<string, unknown>>;
1876
+
1877
+ /**
1878
+ * Decodes a self-describing columnar req/rep reply (dictionary inline) into plain result rows
1879
+ * (cells only, no synthetic `DETAILS`). req/rep replies are full result sets, so unlike a dataserver
1880
+ * `QUERY_UPDATE` they carry no per-row operation / rowRef.
1881
+ */
1882
+ export declare function decodeColumnarReply(msg: ColumnarQueryUpdate, dictionary: readonly string[]): Array<Record<string, unknown>>;
1883
+
1884
+ /**
1885
+ * Decodes an SCDB `RBUF` blob into delta records, using the column dictionary (ordered field-name
1886
+ * list) the client derives from the resource's metadata and validates against the server's
1887
+ * `DICT_HASH`. Each record's `cells` is a fresh target object passed to [decodeColumns].
1888
+ */
1889
+ export declare function decodeScdb(bytes: Uint8Array, dictionary: readonly string[]): ScdbRecord[];
1890
+
1891
+ /**
1892
+ * Transposes a parsed SCDBJ payload into plain result rows (cells only, no `DETAILS`). Used for
1893
+ * req/rep replies, which are full result sets without per-row operation / rowRef semantics.
1894
+ */
1895
+ export declare function decodeScdbjToCells(payload: ScdbjPayload, dictionary: readonly string[]): Array<Record<string, unknown>>;
1896
+
1897
+ /**
1898
+ * Transposes a parsed SCDBJ payload into the legacy dataserver ROW shape:
1899
+ * `[{ ...cells, DETAILS: { OPERATION, ROW_REF } }]`, using the column dictionary.
1900
+ */
1901
+ export declare function decodeScdbjToRows(payload: ScdbjPayload, dictionary: readonly string[]): Array<Record<string, unknown>>;
1902
+
1903
+ /**
1904
+ * Reconstructs the legacy `ROW` array shape directly (the hot path used in the live socket flow):
1905
+ * `[{ ...cells, DETAILS: { OPERATION, ROW_REF } }]`. Builds straight into the row objects with no
1906
+ * intermediate record/cells allocation.
1907
+ */
1908
+ export declare function decodeScdbToRows(bytes: Uint8Array, dictionary: readonly string[]): Array<Record<string, unknown>>;
1909
+
1850
1910
  /**
1851
1911
  * The default implementation for the Auth interface.
1852
1912
  * @public
@@ -1902,6 +1962,7 @@ export declare class DefaultConnect implements Connect {
1902
1962
  private config;
1903
1963
  private transport;
1904
1964
  isWorking: boolean;
1965
+ private readonly httpScdbDecoder;
1905
1966
  get isConnected(): boolean;
1906
1967
  get isConnectedSubject(): BehaviorSubject<boolean>;
1907
1968
  get isConnected$(): Observable<boolean>;
@@ -1921,6 +1982,7 @@ export declare class DefaultConnect implements Connect {
1921
1982
  * @internal
1922
1983
  */
1923
1984
  private get httpHost();
1985
+ private requestOverHttp;
1924
1986
  /**
1925
1987
  * Sends an event/commit or metadata-style message, routing it over HTTP (POST) when
1926
1988
  * `useHttpReqRep` is active and falling back to the WebSocket otherwise.
@@ -2272,6 +2334,9 @@ export declare class DefaultHttpConnect implements Connect {
2272
2334
  */
2273
2335
  private streams;
2274
2336
  private inFlightRequests;
2337
+ private readonly scdbDecoder;
2338
+ /** Guards the one-time warning when a columnar encoding is stripped from a dataserver HTTP call. */
2339
+ private dataserverEncodingStrippedWarned;
2275
2340
  /**
2276
2341
  * Promise that tracks an ongoing session refresh to prevent concurrent refreshes from the same instance.
2277
2342
  * @internal
@@ -2312,6 +2377,13 @@ export declare class DefaultHttpConnect implements Connect {
2312
2377
  getMetadata(resourceName: string, useCache?: boolean): Promise<Metadata>;
2313
2378
  getJSONSchema(resourceName: string): Promise<SchemaResponse>;
2314
2379
  request(resourceName: string, params?: RequestParams, useCache?: boolean): Promise<Message>;
2380
+ /**
2381
+ * Removes a negotiated columnar `ENCODING` from a dataserver HTTP message. Dataserver columnar
2382
+ * encodings batch updates across a streamed connection in a way the HTTP poll/snapshot model
2383
+ * cannot reconstruct, so dataserver-over-HTTP always uses row mode (req/rep-over-HTTP is fine and
2384
+ * is handled separately). Warns once if anything was stripped so misconfiguration is visible.
2385
+ */
2386
+ private stripDataserverColumnarEncoding;
2315
2387
  getAvailableResources(params?: any, useCache?: boolean): Promise<ResourcesMessage>;
2316
2388
  commitEvent(eventName: string, params?: CommitParams): Promise<Message>;
2317
2389
  private maybeTurbo;
@@ -2430,6 +2502,12 @@ export declare const defaultKVStorageConfig: KVStorageConfig;
2430
2502
  export declare class DefaultMessageBuilder implements MessageBuilder {
2431
2503
  private session;
2432
2504
  private uuid;
2505
+ /**
2506
+ * Columnar payload encoding to request on DATA_LOGON via `DETAILS.ENCODING`
2507
+ * (`'SCDB_V1'` binary, `'SCDBJ_V1'` json-columnar). Undefined => legacy row mode.
2508
+ * A per-request `params.ENCODING` overrides this default.
2509
+ */
2510
+ scdbEncoding?: ScdbEncoding;
2433
2511
  /**
2434
2512
  * UUID will be created in the DI with the App specific requirements.
2435
2513
  * Keeping it encapsulated means messages will always conform.
@@ -2672,7 +2750,10 @@ export declare class DefaultSocket implements Socket {
2672
2750
  private websocket;
2673
2751
  private wsMessages;
2674
2752
  private wsMessageHandlers;
2753
+ private _scdbDecoder;
2754
+ private scdbWasmRequested;
2675
2755
  http: Http;
2756
+ private metaCache;
2676
2757
  get isConfigured(): boolean;
2677
2758
  get isConnecting(): boolean;
2678
2759
  get isConnected(): boolean;
@@ -2693,11 +2774,23 @@ export declare class DefaultSocket implements Socket {
2693
2774
  private connectOptions;
2694
2775
  private reconnectOptions;
2695
2776
  private socketSubscription;
2777
+ private pageLifecycleBound;
2778
+ /** True after freeze/bfcache until resume/pageshow recovery runs. */
2779
+ private suspendedByPageLifecycle;
2696
2780
  constructor(messageBuilder: MessageBuilder, session: Session, serializer: JSONSerializer, uuid: UUID, status: SocketStatus,
2697
2781
  /**
2698
2782
  * Temp putting the user in place to bridge the hasValidSession logic.
2699
2783
  */
2700
2784
  user: User_2, config: ConnectConfig);
2785
+ /**
2786
+ * Chrome terminates WebSockets when a tab is frozen or put in the back-forward cache.
2787
+ * Mark disconnected before freeze so datasources observe `false`, then on restore drop
2788
+ * stale stream handlers and reconnect (replaying old DATASERVER logons leaves grids stale).
2789
+ */
2790
+ private ensurePageLifecycleListeners;
2791
+ private recoverAfterPageLifecycle;
2792
+ /** Makes SCDB columnar payloads transparent (no-op unless an encoding was negotiated). */
2793
+ private get scdbDecoder();
2701
2794
  private get heartbeatLoggingIsEnabled();
2702
2795
  private get messageLoggingIsEnabled();
2703
2796
  connect(host?: string, connectOptions?: SocketConnectOptions, reconnectOptions?: SocketReconnectOptions): Promise<boolean>;
@@ -2730,6 +2823,19 @@ export declare class DefaultSocket implements Socket {
2730
2823
  private setMessageHandler;
2731
2824
  private sendDataLogoff;
2732
2825
  private removeMessageHandler;
2826
+ /**
2827
+ * Wires the SCDB decoder's metadata-refresh hook, used to fetch a resource's missing or stale
2828
+ * metadata. The host passes a force-refresh, e.g. `Connect.getMetadata(resource, false)`.
2829
+ */
2830
+ setScdbMetadataRefresher(refresher: (resourceName: string) => void | Promise<unknown>): void;
2831
+ /**
2832
+ * Loads the bundled WASM decoder for the `SCDB_V1` binary encoding once (lazy, idempotent). Called
2833
+ * eagerly when the app-wide `dataserverEncoding` is binary, and on demand the first time a binary
2834
+ * payload is seen (so a per-datasource/grid `encoding: 'SCDB_V1'` also gets the fast-path, not just
2835
+ * the app-wide opt-in). On any failure (no WebAssembly, CSP, SSR) we silently keep the pure-JS
2836
+ * decoder — output is identical.
2837
+ */
2838
+ private ensureScdbWasm;
2733
2839
  private getMessageHandler;
2734
2840
  private logMessageTypeFlow;
2735
2841
  }
@@ -2783,6 +2889,42 @@ export declare function describeDataserverPagingStop(stop: {
2783
2889
  attribute: string;
2784
2890
  }): string | undefined;
2785
2891
 
2892
+ /**
2893
+ * Ordered field-name list (the SCDB dictionary) for a resource, from its metadata. The order MUST
2894
+ * match the server's, which derives the dictionary per resource type: a DATASERVER hashes its `FIELD`
2895
+ * list, a REQUEST_SERVER its `REPLY_FIELD` (⇒ `REPLY.FIELD`) list. Selecting by `TYPE` — rather than
2896
+ * "first non-null" — matters because a metadata object can legitimately carry BOTH `FIELD` and
2897
+ * `REPLY_FIELD`; picking the wrong one yields a hash that never matches the server's `DICT_HASH`, so
2898
+ * no columnar message for that resource can be decoded. Falls back to a lenient scan for unknown types.
2899
+ */
2900
+ export declare function dictionaryFromMetadata(metadata: {
2901
+ TYPE?: string;
2902
+ FIELD?: FieldLike[];
2903
+ REPLY_FIELD?: FieldLike[];
2904
+ REPLY?: {
2905
+ FIELD?: FieldLike[];
2906
+ };
2907
+ }): string[];
2908
+
2909
+ /**
2910
+ * Dictionary derivation + fingerprinting for the metadata-driven dictionary mechanism.
2911
+ *
2912
+ * The server no longer ships the column dictionary; instead the client derives it from the resource
2913
+ * metadata it already holds (`id = index` into the ordered field list) and validates it against a
2914
+ * small hash the server sends with the columnar payload. A columnar message that fails validation
2915
+ * is not decoded.
2916
+ */
2917
+ /**
2918
+ * FNV-1a 32-bit hash of the field names joined by '\n', as lowercase 8-char hex. MUST match the
2919
+ * Kotlin `ColumnDictionary.contentHash` in genesis-columnar (cross-language vector:
2920
+ * ['QUANTITY','PRICE','SYMBOL'] -> '40e6db4f').
2921
+ *
2922
+ * Hashes UTF-16 code units (`charCodeAt`), matching Kotlin's `Char.code` — NOT the UTF-8 bytes used for
2923
+ * on-wire strings. Field names are ASCII in practice so the two coincide; keep both ends on UTF-16 units
2924
+ * (do not switch to UTF-8 bytes) or a non-ASCII field name would hash differently across languages.
2925
+ */
2926
+ export declare function dictionaryHash(fieldNames: readonly string[]): string;
2927
+
2786
2928
  /**
2787
2929
  * EntityDatasource DI interface.
2788
2930
  *
@@ -2937,6 +3079,11 @@ export declare const exponentialScheduler: SocketReconnectScheduler;
2937
3079
  */
2938
3080
  export declare const extractFieldDefinitions: (metadata: Metadata) => MetadataDetail[];
2939
3081
 
3082
+ /** Minimal shape of the cached resource metadata fields we need. */
3083
+ declare interface FieldLike {
3084
+ NAME: string;
3085
+ }
3086
+
2940
3087
  /**
2941
3088
  * Field Metadata definition.
2942
3089
  * @public
@@ -3265,6 +3412,13 @@ export declare type GetCredentialOptions = CredentialRequestOptions & {};
3265
3412
  */
3266
3413
  export declare function getDatasource(): Datasource;
3267
3414
 
3415
+ /**
3416
+ * Lazily instantiates (once) the bundled decoder from inlined base64 — no asset/fetch config, works
3417
+ * in any bundler and SSR. This is what the socket layer uses for the `SCDB_V1` fast-path. Rejects if
3418
+ * WebAssembly is unavailable; callers fall back to the pure-JS decoder.
3419
+ */
3420
+ export declare function getDefaultScdbWasm(): Promise<ScdbWasm>;
3421
+
3268
3422
  /**
3269
3423
  * Gets GenesisResources from the DI container.
3270
3424
  *
@@ -3518,6 +3672,12 @@ export declare type IndexDetail = {
3518
3672
  FIELDS: string;
3519
3673
  };
3520
3674
 
3675
+ /**
3676
+ * Instantiates the decoder. Defaults to the inlined `decoder.wasm`; pass your own bytes (bundler
3677
+ * import / fetch / fs.readFile) to override. Returns an object whose `decodeToRows` is synchronous.
3678
+ */
3679
+ export declare function initScdbWasm(wasmBytes?: BufferSource): Promise<ScdbWasm>;
3680
+
3521
3681
  /**
3522
3682
  * Regular Expression to test valid WebSocket (wss and ws) hosts
3523
3683
  * @public
@@ -3792,6 +3952,11 @@ declare type Message_2 = any;
3792
3952
  * @public
3793
3953
  */
3794
3954
  export declare interface MessageBuilder {
3955
+ /**
3956
+ * Columnar payload encoding to request on DATA_LOGON (`'SCDB_V1'` | `'SCDBJ_V1'`). Undefined =>
3957
+ * legacy row mode. Normally set from `ConnectConfig.connect.dataserverEncoding`.
3958
+ */
3959
+ scdbEncoding?: ScdbEncoding;
3795
3960
  /**
3796
3961
  * Creates a login message.
3797
3962
  *
@@ -4061,6 +4226,8 @@ export declare namespace MessageDetails {
4061
4226
  */
4062
4227
  export type DataserverRequest = {
4063
4228
  DATASOURCE_NAME: string;
4229
+ /** Requested columnar payload encoding: 'SCDB_V1' (binary) or 'SCDBJ_V1' (json-columnar). */
4230
+ ENCODING?: ScdbEncoding;
4064
4231
  };
4065
4232
  /**
4066
4233
  * Details type to request FEATURE metadata
@@ -4551,6 +4718,8 @@ export declare type RequestDetailsParam = {
4551
4718
  OFFSET?: number;
4552
4719
  ORDER_BY?: string;
4553
4720
  VIEW_NUMBER?: number;
4721
+ /** Requested columnar reply encoding (e.g. 'SCDBJ_V1'); mirrors the dataserver negotiation. */
4722
+ ENCODING?: ScdbEncoding;
4554
4723
  };
4555
4724
 
4556
4725
  /**
@@ -4663,6 +4832,79 @@ export declare type RowData = {
4663
4832
  ROW_REF: string;
4664
4833
  };
4665
4834
 
4835
+ /** The columnar wire encodings a client can negotiate via `DETAILS.ENCODING` (absent = legacy row mode). */
4836
+ export declare type ScdbEncoding = 'SCDB_V1' | 'SCDBJ_V1';
4837
+
4838
+ /**
4839
+ * SCDBJ (JSON-columnar) decoder.
4840
+ *
4841
+ * The no-WASM peer of the binary `scdbDecoder`. The server sends a `QUERY_UPDATE` whose payload is a
4842
+ * plain JSON object (decoded for free by the existing envelope `JSON.parse`); this transposes it back
4843
+ * into the legacy `ROW` array of row objects that ag-Grid consumes. Because native `JSON.parse` does
4844
+ * the bulk work and only the transpose is JS, this is at parity with row-JSON on a full snapshot and
4845
+ * faster on deltas, while being ~2x smaller on the wire (no repeated field-name keys).
4846
+ *
4847
+ * Wire shape (short keys; see genesis-columnar/docs/scdb-v1.md):
4848
+ * { n, r:[rowRef strings], o: opCode | [opCodes], c:[ { i:colId, x?:[presentIdx], v:[values] } ] }
4849
+ * `x` omitted => dense column. Values are aligned to the present cells; a `null` entry is an explicit
4850
+ * change-to-null. Column ids index the metadata-derived dictionary.
4851
+ */
4852
+ export declare interface ScdbjPayload {
4853
+ n: number;
4854
+ r: string[];
4855
+ o: number | number[];
4856
+ c: Array<{
4857
+ i: number;
4858
+ x?: number[];
4859
+ v: unknown[];
4860
+ }>;
4861
+ }
4862
+
4863
+ /**
4864
+ * SCDB v1 (Sparse Columnar Delta Block) decoder.
4865
+ *
4866
+ * Decodes the binary `RBUF` payload that a Genesis dataserver sends when a client negotiates
4867
+ * `DETAILS.ENCODING = SCDB_V1`. The wire format is defined, language-neutrally, in the server repo
4868
+ * at `genesis-columnar/docs/scdb-v1.md` and is pinned by the shared golden vectors in
4869
+ * `scdb-golden-v1.json` (this directory). The Kotlin `ScdbReader` is the reference implementation;
4870
+ * this decoder must stay byte-for-byte compatible with it.
4871
+ *
4872
+ * Performance notes (see scdb-js-bench.mjs):
4873
+ * - single pass straight into the output objects — no per-column intermediate arrays;
4874
+ * - dense columns (flagged by the encoder) skip the presence bitmap and the per-row presence test;
4875
+ * - varints decode in Number space (exact for |v| < 2^53), using BigInt only past 49 bits;
4876
+ * - strings take a manual ASCII fast-path (TextDecoder has a fixed per-call overhead).
4877
+ *
4878
+ * Browser contract:
4879
+ * - operates over the `Uint8Array` the existing msgpack envelope decoder already produces for `RBUF`;
4880
+ * - `ROW_REF` decodes to a `string` (sent as decimal text) — matches the existing contract, no BigInt;
4881
+ * - 64-bit LONG *values* decode to `number` when safe, else `bigint` (the customNumberParser rule).
4882
+ */
4883
+ export declare type ScdbOperation = 'INSERT' | 'MODIFY' | 'DELETE';
4884
+
4885
+ /** A decoded delta row. `cells` contains only changed fields; an explicit `null` is change-to-null. */
4886
+ export declare interface ScdbRecord {
4887
+ rowRef: string;
4888
+ operation: ScdbOperation;
4889
+ cells: Record<string, unknown>;
4890
+ }
4891
+
4892
+ /**
4893
+ * WASM fast-path decoder for the binary SCDB (`SCDB_V1`) payload.
4894
+ *
4895
+ * Instantiates the AssemblyScript decoder (`wasm/decoder.wasm`), which parses the binary blob at
4896
+ * near-native speed into a columnar result in linear memory; this module then assembles the legacy
4897
+ * `ROW` array of objects that ag-Grid consumes. Measured ~1.5x faster than native `JSON.parse` on a
4898
+ * full snapshot and ~2.5x on deltas, while the payload stays ~3x smaller on the wire. See
4899
+ * `wasm/README.md` and the benchmark for numbers.
4900
+ *
4901
+ * If wasm is unavailable (or instantiation fails), callers fall back to the pure-JS `decodeScdbToRows`
4902
+ * from `scdbDecoder.ts` — same output, no toolchain.
4903
+ */
4904
+ export declare interface ScdbWasm {
4905
+ decodeToRows(blob: Uint8Array, dictionary: readonly string[]): Array<Record<string, unknown>>;
4906
+ }
4907
+
4666
4908
  /**
4667
4909
  * Schema Response definition.
4668
4910
  * @public
@@ -4912,6 +5154,11 @@ export declare interface Socket extends Omit<SocketStatus, 'serialize' | 'onClos
4912
5154
  */
4913
5155
  sendForStreamWithoutTeardown<T>(message: Message<T | any>, onMessage: Function, onError: Function): Observable<Message>;
4914
5156
  socketMessages(): SocketSubject<Message>;
5157
+ /**
5158
+ * Wires a metadata-refresh hook for the SCDB columnar decoder, used to fetch a resource's missing
5159
+ * or stale metadata (e.g. `getMetadata(r, false)`).
5160
+ */
5161
+ setScdbMetadataRefresher?(refresher: (resourceName: string) => void | Promise<unknown>): void;
4915
5162
  host: string;
4916
5163
  }
4917
5164
 
@@ -4975,6 +5222,19 @@ export declare type SocketConnectOptions = {
4975
5222
  * The path to a proxy server to use for the connection.
4976
5223
  */
4977
5224
  proxyPath?: string;
5225
+ /**
5226
+ * Opt in to a columnar dataserver payload encoding for all DATA_LOGON subscriptions, negotiated
5227
+ * transparently — every consumer (grids, React wrappers, FAST components, custom datasources)
5228
+ * benefits with no code change, since request + decode happen in this comms layer.
5229
+ *
5230
+ * - `'SCDBJ_V1'` — JSON-columnar: ~2x smaller, decoded with native JSON.parse + transpose. No
5231
+ * extra runtime; works in every bundler and SSR. Recommended default.
5232
+ * - `'SCDB_V1'` — binary blob: ~3x smaller and ~1.5–2.5x faster to decode via the bundled WASM
5233
+ * decoder (falls back to a pure-JS decoder if WebAssembly is unavailable).
5234
+ *
5235
+ * Undefined (default) keeps the legacy row encoding. Old servers ignore it and send rows.
5236
+ */
5237
+ dataserverEncoding?: ScdbEncoding;
4978
5238
  };
4979
5239
 
4980
5240
  /**
@@ -5042,6 +5302,7 @@ export declare class SocketMock implements Socket {
5042
5302
  sendForStream<T>(message: Message<any>, onMessage: Function, onError: Function, onComplete?: Function): Observable<Message>;
5043
5303
  sendForStreamWithoutTeardown<T>(message: Message<any>, onMessage: Function, onError: Function): Observable<Message>;
5044
5304
  socketMessages(): SocketSubject<Message>;
5305
+ setScdbMetadataRefresher(): void;
5045
5306
  reset(): void;
5046
5307
  }
5047
5308
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@genesislcap/foundation-comms",
3
3
  "description": "Genesis Foundation UI Comms",
4
- "version": "15.79.2-alpha-e9d30db797.0",
4
+ "version": "15.80.0-FUI-2666.1",
5
5
  "sideEffects": false,
6
6
  "license": "SEE LICENSE IN license.txt",
7
7
  "main": "dist/esm/index.js",
@@ -42,6 +42,7 @@
42
42
  "build": "genx build -b ts",
43
43
  "build:webpack": "genx build",
44
44
  "build:vite": "genx build -b vite",
45
+ "build:wasm": "asc --target release && node assembly/scdb/inline-wasm-base64.mjs",
45
46
  "build:webpack:stats": "genx analyze",
46
47
  "circular": "npx -y madge --extensions ts --circular ./src",
47
48
  "clean": "rimraf dist temp tsconfig.tsbuildinfo",
@@ -74,23 +75,24 @@
74
75
  }
75
76
  },
76
77
  "devDependencies": {
77
- "@genesislcap/foundation-testing": "15.79.2-alpha-e9d30db797.0",
78
- "@genesislcap/genx": "15.79.2-alpha-e9d30db797.0",
79
- "@genesislcap/ts-builder": "15.79.2-alpha-e9d30db797.0",
80
- "@genesislcap/uvu-playwright-builder": "15.79.2-alpha-e9d30db797.0",
81
- "@genesislcap/vite-builder": "15.79.2-alpha-e9d30db797.0",
82
- "@genesislcap/webpack-builder": "15.79.2-alpha-e9d30db797.0",
78
+ "@genesislcap/foundation-testing": "15.80.0-FUI-2666.1",
79
+ "@genesislcap/genx": "15.80.0-FUI-2666.1",
80
+ "@genesislcap/ts-builder": "15.80.0-FUI-2666.1",
81
+ "@genesislcap/uvu-playwright-builder": "15.80.0-FUI-2666.1",
82
+ "@genesislcap/vite-builder": "15.80.0-FUI-2666.1",
83
+ "@genesislcap/webpack-builder": "15.80.0-FUI-2666.1",
83
84
  "@types/js-cookie": "^3.0.2",
84
85
  "@types/json-schema": "^7.0.11",
85
86
  "@types/webappsec-credential-management": "^0.6.2",
87
+ "assemblyscript": "^0.28.19",
86
88
  "sinon": "^17.0.1"
87
89
  },
88
90
  "dependencies": {
89
- "@genesislcap/foundation-broadcast-channel": "15.79.2-alpha-e9d30db797.0",
90
- "@genesislcap/foundation-logger": "15.79.2-alpha-e9d30db797.0",
91
- "@genesislcap/foundation-user": "15.79.2-alpha-e9d30db797.0",
92
- "@genesislcap/foundation-utils": "15.79.2-alpha-e9d30db797.0",
93
- "@genesislcap/web-core": "15.79.2-alpha-e9d30db797.0",
91
+ "@genesislcap/foundation-broadcast-channel": "15.80.0-FUI-2666.1",
92
+ "@genesislcap/foundation-logger": "15.80.0-FUI-2666.1",
93
+ "@genesislcap/foundation-user": "15.80.0-FUI-2666.1",
94
+ "@genesislcap/foundation-utils": "15.80.0-FUI-2666.1",
95
+ "@genesislcap/web-core": "15.80.0-FUI-2666.1",
94
96
  "@microsoft/fast-element": "1.14.0",
95
97
  "@microsoft/fast-foundation": "2.50.0",
96
98
  "bowser": "^2.11.0",