@casoon/opengrid 0.4.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -18,6 +18,155 @@ Two things belong in every release entry and are easy to leave out:
18
18
 
19
19
  ## [Unreleased]
20
20
 
21
+ ## [0.6.0] — 2026-09-29
22
+
23
+ **Screen-reader pairings tested: none yet** — the VoiceOver pass is prepared and not yet run
24
+ ([issue #5](https://github.com/casoon/opengrid/issues/5)). **Browsers:** Chromium, the whole
25
+ e2e suite. WebKit (Playwright's, not Safari): the whole suite; its one failure, the plain-DOM
26
+ stand-in counting a second table, is fixed in this release (#93). Firefox: **not run**:
27
+ Playwright's Firefox does not start on the release machine.
28
+
29
+ **What breaks** (details in the entries below):
30
+ - the pivot's `header` part moved from its `<thead>` to each column header cell (#29);
31
+ - in the Rust crates, the opengrid types no longer implement `serde` — read and write them
32
+ with `opengrid_json` (#41). The npm package's JavaScript API is unchanged apart from
33
+ additions.
34
+
35
+ **Module sizes** (brotli, `just measure-modules`): the elements 215.8 → 204.1 KiB, the engine
36
+ 124.9 → 115.2 KiB — `serde` left both modules (#41), and the engine now answers pivots (#28).
37
+
38
+ ### Added
39
+
40
+ - **Data without JavaScript** ([#84](https://github.com/casoon/opengrid/issues/84)). A page
41
+ can write its data as a plain `<table>` inside an element. Without script, that's what
42
+ readers and crawlers see; once the element has rendered, its shadow root replaces it, so
43
+ nothing is read twice. When the module can't load, the plain-DOM stand-in now shows the
44
+ page's table (through a `<slot>`) instead of hiding it behind an empty skeleton. The
45
+ skeleton only shows when there is no table of its own.
46
+ - **The pivot in the browser** ([#28](https://github.com/casoon/opengrid/issues/28)).
47
+ `createLocalProvider` and `createWorkerProvider` answer `<opengrid-pivot>`: the engine runs
48
+ the pivot's grouping sets over the data the page loaded, with the server's limits
49
+ (`Engine.pivot`, `Engine.pivot_columns`, a `pivot` message in the worker). The element calls
50
+ a provider's new optional `pivot(json)` and falls back to `execute`, so providers of a page's
51
+ own keep working; `createPivotProvider` has `pivot` too. `examples/pivot-demo/browser.html`
52
+ shows it without a server.
53
+ - **XLSX export on the server** ([#72](https://github.com/casoon/opengrid/issues/72)).
54
+ `POST /export/{source}?format=xlsx` writes an Excel workbook, and `exportRows(rest, query,
55
+ { format: "xlsx" })` asks for it through `createRestProvider` — with any other provider it is
56
+ a `TypeError`. Values are Excel types where Excel holds them exactly (numbers, dates,
57
+ date-times in UTC, booleans) and text where it cannot (integers past 2⁵³, decimals past 15
58
+ digits, sub-millisecond timestamps), so no value changes; Excel's row and cell limits are
59
+ errors, never a shortened file. New server-side dependency: `rust_xlsxwriter`, behind the
60
+ feature `xlsx` of `opengrid-export`, so the browser modules do not carry it.
61
+ - **`<opengrid-table>` and `<opengrid-pivot>` can be styled, and the table takes formats**
62
+ ([#29](https://github.com/casoon/opengrid/issues/29)). Both render into a shadow root, so
63
+ no page rule reached their cells. They now carry parts named like the grid's — `table`,
64
+ `caption`, `header`, `row`, `cell`, the table's `sort-button`, the pivot's `row-header` and
65
+ `total-row` — and `examples/pivot-demo` and `examples/table-demo` style them through
66
+ `::part`. The table shows its values as the grid does: `formats` apply to its cells, and
67
+ `presentation` (`set_columns`) gives a column its `title`, `align`, `mono`, `emphasis` and
68
+ `muted`; the grid's `width`, `aggregate` and `facet` are refused for a table with an alert
69
+ rather than ignored. A number is right-aligned by its type, as in the grid.
70
+ **What breaks:** the pivot's `header` part was on its `<thead>`; it is now on each column
71
+ header cell, like the grid's.
72
+
73
+ ### Changed
74
+
75
+ - **One JSON codec for browser and server, and no `serde` in the browser**
76
+ ([#41](https://github.com/casoon/opengrid/issues/41)). `opengrid-json` reads and writes
77
+ every JSON form — query, schema, view, texts, errors, the JSON result — on both sides,
78
+ so the two cannot read the same bytes two ways. `serde` and `serde_json` are gone from
79
+ both browser modules. Against 0.5.0, with everything else in this release (`just
80
+ measure-modules`, brotli): the elements 215.8 → 204.1 KiB, the engine 124.9 → 115.2 KiB,
81
+ although the engine now answers pivots too. What is read and refused is what `serde_json` read
82
+ and refused (checked against it as an oracle); what is written is what it wrote, keys
83
+ aside — an object now keeps the order it is written in instead of sorting its keys —
84
+ and one rare case: where a float has two shortest spellings, the one closer to the
85
+ value is written. Both read back to the same number.
86
+
87
+ **What breaks** (Rust crates only; the npm package and its JavaScript API are
88
+ unchanged): the opengrid types no longer implement `serde::Serialize`/`Deserialize`.
89
+ Read and write them with `opengrid_json` (`from_str`, `to_string`, `FromJson`, `ToJson`);
90
+ `Value::deserialize_typed` is `Value::from_json_typed`, and a filter literal is an
91
+ `opengrid_json::Json`.
92
+
93
+ ### Fixed
94
+
95
+ - **`<opengrid-table>` says it is loading** ([#86](https://github.com/casoon/opengrid/issues/86)).
96
+ Until its first answer it was a table with a caption and no rows, which a screen reader
97
+ couldn't tell from an empty one. The waiting table now carries `aria-busy="true"`, and
98
+ the table with its answer doesn't.
99
+
100
+ ## [0.5.0] — 2026-09-28
101
+
102
+ **Screen-reader pairings tested: none yet** — unchanged since 0.1.0
103
+ ([issue #5](https://github.com/casoon/opengrid/issues/5)). **Browsers:** Chromium, the whole
104
+ e2e suite. WebKit (Playwright's, not Safari): the whole suite, one failure — the layout
105
+ misses the look's colour and font until the first restyle
106
+ ([#81](https://github.com/casoon/opengrid/issues/81), there since 0.3.0). Firefox: **not
107
+ run** — Playwright's Firefox did not start on the release machine.
108
+
109
+ **What breaks:** no frozen name was renamed or removed; what moved is structure a page
110
+ stylesheet or script may have leaned on:
111
+ - the pager is in `part="footer"` now, not above the header (#75);
112
+ - a boolean column's filter-row control is a `<select>` (any / yes / no), no longer a
113
+ checkbox (#60);
114
+ - a column is drawn at least 96 px wide with the column menu, 64 px without, and at least
115
+ 128 px while the filter row shows (#61, #62);
116
+ - the toolbar's buttons sit in an inner row without a part, and an opened column list
117
+ follows the density (#77).
118
+
119
+ **Module sizes** (brotli, `just measure-modules`): the elements 211.2 → 215.8 KiB, the
120
+ engine 122.6 → 124.9 KiB (the resource report's measuring, #70).
121
+
122
+ ### Added
123
+
124
+ - **A resource report** ([#70](https://github.com/casoon/opengrid/issues/70)). The grid fires
125
+ `opengrid-query` after every answer of its provider — `{ kind, ms, rows, total, bytes,
126
+ form, memory }`: where it ran, the round trip measured in the tab, what came back and in
127
+ which form, and the element module's WASM memory. The local and worker providers answer
128
+ `stats()` — the engine's WASM memory and, per loaded source, rows, columns and bytes held
129
+ (`Engine.stats()`, a worker message `stats`). Measured always, sent nowhere.
130
+ - **Column titles** ([#66](https://github.com/casoon/opengrid/issues/66)). `set_columns` takes
131
+ `title` per column — what a reader reads wherever the grid names the column: the header,
132
+ the column list, the filter row's labels, the column menu, the "+ Filter" dialog and
133
+ "+ Group" menu, group rows, chips, facet headings, search suggestions (which show the
134
+ field name beside it, since that is what an expression takes) and every announcement.
135
+ The field name stays the identifier in queries, views, expressions, exports and events.
136
+
137
+ ### Fixed
138
+
139
+ - **The toolbar on a narrow grid** ([#77](https://github.com/casoon/opengrid/issues/77)).
140
+ On a phone it wrapped into four rows, 178 of a 460 px grid, and left room for four
141
+ rows of data. Under 560 px of grid width, the search field now takes a line of its own
142
+ and the buttons stay in one row that scrolls sideways; a button that takes the focus
143
+ comes fully into view. At a 320 px viewport (reflow, 1.4.10) it wraps as before. The
144
+ buttons now sit in an inner row without a part, so `::part` rules are unaffected;
145
+ an opened column list comes after the density rather than before it.
146
+ - **The pager sits in the footer** ([#75](https://github.com/casoon/opengrid/issues/75)).
147
+ It stood between the filter row and the header, in the browser's unstyled buttons. It
148
+ now follows the status in `part="footer"`, below the rows it pages, as compact glyph
149
+ buttons (« ‹ › ») that keep their names — "First page" and so on — as `aria-label`.
150
+ A stylesheet that placed `[part="pager"]` by its old position has to follow.
151
+ - **A boolean column in the filter row** ([#60](https://github.com/casoon/opengrid/issues/60)).
152
+ It was a checkbox whose value reads `on` whether ticked or not: the grid showed a chip
153
+ "… is on" with nothing filtered, and the first filter on any other column silently
154
+ brought `= true` along. It is now a choice of three — *any*, *yes*, *no* — with three new
155
+ text keys `filterAny`, `booleanTrue`, `booleanFalse`. The "+ Filter" dialog reads a
156
+ boolean's checkbox by whether it is ticked.
157
+ - **A narrow column keeps its name** ([#61](https://github.com/casoon/opengrid/issues/61)).
158
+ With the column menu, a sorted 80 px column showed only "▲ ⋯": the header reserved a
159
+ fixed 2.75em for the sort marks on top of the menu button. It now reserves what stands
160
+ beside the name, the name keeps two characters at least, and a column is drawn at least
161
+ 96 px wide with the column menu (64 px without) whatever width it was given.
162
+ - **The filter row stands under the columns and scrolls with them** ([#62](https://github.com/casoon/opengrid/issues/62)).
163
+ Its groups sat at fixed 248 px steps and the row scrolled on its own, so at a phone's
164
+ width a field was under the wrong column. Each group is now as wide as its column and
165
+ starts where it starts (measured from the header, again whenever the table changes size),
166
+ rows and filter share one horizontal position, and the table is at least as wide as its
167
+ columns' minimum widths — a column without a width of its own no longer shrinks to a few
168
+ pixels, the grid scrolls sideways instead.
169
+
21
170
  ## [0.4.0] — 2026-09-28
22
171
 
23
172
  **Screen-reader pairings tested: none yet** — unchanged since 0.1.0
package/README.md CHANGED
@@ -3,9 +3,9 @@
3
3
  [![npm](https://img.shields.io/npm/v/@casoon/opengrid?color=3d5fd6&label=npm)](https://www.npmjs.com/package/@casoon/opengrid)
4
4
  [![licence](https://img.shields.io/badge/licence-MIT%20OR%20Apache--2.0-3d5fd6)](#licence)
5
5
 
6
- Accessible data grid, table and pivot as Web Components — driven by one query engine that
7
- runs in the browser (WebAssembly), on a server (PostgreSQL), or split between the two, with
8
- the same results everywhere.
6
+ Data grid, table and pivot as Web Components, built to be accessible and machine-readable —
7
+ driven by one query engine that runs in the browser (WebAssembly), on a server (PostgreSQL),
8
+ or split between the two, with the same results everywhere.
9
9
 
10
10
  <p>
11
11
  <img src="https://raw.githubusercontent.com/casoon/opengrid/main/docs/assets/grid-base.png" alt="opengrid-grid in the Base look: search, + Filter, + Group, filter row and 5,000 orders" width="49%">
@@ -13,11 +13,19 @@ the same results everywhere.
13
13
  </p>
14
14
 
15
15
  - **`<opengrid-grid>`** — sorting, filtering, search, facets, grouping with totals,
16
- selection, editing, virtualized or paged; fully operable from the keyboard.
16
+ selection, editing, virtualized or paged; operated from the keyboard.
17
17
  - **`<opengrid-table>`** — a plain semantic `<table>` for displaying data.
18
- - **`<opengrid-pivot>`** — a pivot with subtotals and a grand total.
19
- - **Export** — what the reader sees, every match of it, as CSV or JSON.
20
- - **Five built-in looks** — `theme="paper"`, and your own `--og-*` properties on top.
18
+ - **`<opengrid-pivot>`** — a pivot with subtotals and a grand total, from a server or from
19
+ the engine in the tab.
20
+ - **Column titles** — the page names its columns, in its own language, wherever the grid
21
+ names them.
22
+ - **Export** — what the reader sees, every match of it, as CSV or JSON; XLSX from the server.
23
+ - **A resource report** — every answer as an event (where it ran, how long, how big), and
24
+ what the engine holds in memory.
25
+ - **Data without JavaScript** — a page can put its own `<table>` inside an element, for
26
+ readers and crawlers that run no script.
27
+ - **Five built-in looks** — `theme="paper"`, your own `--og-*` properties on top, and
28
+ `::part` for every element.
21
29
 
22
30
  ## Live demos
23
31
 
@@ -141,8 +149,9 @@ const query = module.get_query(grid); // the reader's view, withou
141
149
  const blob = await exportRows(provider, query, { format: "csv" });
142
150
  ```
143
151
 
144
- CSV per RFC 4180 with a guard against formula injection, or JSON; a pivot exports as shown
145
- with `get_pivot`. See [Export](https://github.com/casoon/opengrid/blob/main/docs/guides/export.md).
152
+ CSV per RFC 4180 with a guard against formula injection, or JSON; through
153
+ `createRestProvider` also XLSX, written by the server (`format: "xlsx"`). A pivot exports as
154
+ shown with `get_pivot`. See [Export](https://github.com/casoon/opengrid/blob/main/docs/guides/export.md).
146
155
 
147
156
  ## Documentation
148
157
 
@@ -151,17 +160,39 @@ with `get_pivot`. See [Export](https://github.com/casoon/opengrid/blob/main/docs
151
160
  - [Guides](https://github.com/casoon/opengrid/tree/main/docs/guides) and the
152
161
  [project page](https://casoon.github.io/opengrid/)
153
162
 
154
- ## Accessibility
155
-
156
- Keyboard operation under the WAI-ARIA grid pattern, one polite live region for every state,
157
- no dragging required, and axe-core in every state of the end-to-end suite (Chromium, Firefox,
158
- WebKit). **Not yet verified with a screen reader** — that pass follows this release.
163
+ ## Accessible and machine-readable: the aim
164
+
165
+ opengrid is meant to be more than a WebAssembly engine that draws a grid. Its data should
166
+ reach **everyone and everything** that reads a page: a person using a keyboard or a screen
167
+ reader, and a program — a test, a browser agent, an export. How it is built toward that:
168
+
169
+ - **One structure for people and programs.** A native `<table>` where reading is all there
170
+ is to do, `role="grid"` (or `treegrid` when grouped) where interaction needs it: row and
171
+ column headers, `aria-rowcount` for the whole result behind a virtualized window,
172
+ `aria-sort`, `aria-selected`, a name for every control. The accessibility tree a screen
173
+ reader reads is the one an automation tool or an AI agent reads.
174
+ - **Designed for the keyboard.** The WAI-ARIA grid pattern for the keys, nothing that needs
175
+ dragging, and one polite live region for every change of state.
176
+ - **Open data at every step.** The schema is a JSON document, a query is a JSON AST, the view
177
+ is JSON, an export is CSV, JSON or XLSX, and a page can write its data as a plain table
178
+ inside the element for readers that run no script.
179
+ - **Tested, not assumed.** axe-core runs over every state of the end-to-end suite; target
180
+ sizes, reflow at 320 px and forced colours are tests; the announcements are recorded in
181
+ order.
182
+
183
+ **This is not a statement of conformance yet.** A pass with a screen reader is still to come
184
+ ([#5](https://github.com/casoon/opengrid/issues/5)), and a conformance report follows it. What
185
+ is tested and what is not: [Accessibility](https://github.com/casoon/opengrid/blob/main/docs/guides/accessibility.md).
159
186
 
160
187
  ## Status
161
188
 
162
189
  Pre-1.0: a minor version may change the API, a patch version does not
163
190
  ([CHANGELOG](https://github.com/casoon/opengrid/blob/main/CHANGELOG.md)).
164
191
 
192
+ This page describes `main`. The pivot in the browser, XLSX export, the table's parts and
193
+ formats, and data without JavaScript are in it but not yet on npm: they come with the next
194
+ release ([Unreleased](https://github.com/casoon/opengrid/blob/main/CHANGELOG.md#unreleased)).
195
+
165
196
  ## Licence
166
197
 
167
198
  MIT OR Apache-2.0.
@@ -38,10 +38,29 @@ export class Engine {
38
38
  * An engine without data. `load_csv` adds sources.
39
39
  */
40
40
  constructor();
41
+ /**
42
+ * Runs a pivot JSON over the source it names and answers the pivot's JSON
43
+ * form (issue #28) — what `POST /pivot/{source}` answers, computed here.
44
+ */
45
+ pivot(pivot_json: string): string;
46
+ /**
47
+ * The same pivot in the binary form (E35) — what the tab and the worker
48
+ * hand the element.
49
+ */
50
+ pivot_columns(pivot_json: string): Uint8Array;
41
51
  /**
42
52
  * The names of the registered sources, in unspecified order.
43
53
  */
44
54
  source_names(): string[];
55
+ /**
56
+ * What the engine holds (issue #70), as JSON:
57
+ * `{ "memory": bytes, "sources": [{ "name", "rows", "columns", "bytes" }] }`.
58
+ *
59
+ * `memory` is the module's whole linear memory — what the browser gave
60
+ * it, which only grows; `bytes` is what a source's columns take inside
61
+ * it. Sources by name.
62
+ */
63
+ stats(): string;
45
64
  }
46
65
 
47
66
  /**
@@ -107,7 +126,10 @@ export interface InitOutput {
107
126
  readonly engine_execute_columns: (a: number, b: number, c: number) => [number, number, number, number];
108
127
  readonly engine_load_csv: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
109
128
  readonly engine_new: () => number;
129
+ readonly engine_pivot: (a: number, b: number, c: number) => [number, number, number, number];
130
+ readonly engine_pivot_columns: (a: number, b: number, c: number) => [number, number, number, number];
110
131
  readonly engine_source_names: (a: number) => [number, number];
132
+ readonly engine_stats: (a: number) => [number, number];
111
133
  readonly planner_finish: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
112
134
  readonly planner_finish_columns: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
113
135
  readonly planner_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
@@ -97,6 +97,49 @@ export class Engine {
97
97
  EngineFinalization.register(this, this.__wbg_ptr, this);
98
98
  return this;
99
99
  }
100
+ /**
101
+ * Runs a pivot JSON over the source it names and answers the pivot's JSON
102
+ * form (issue #28) — what `POST /pivot/{source}` answers, computed here.
103
+ * @param {string} pivot_json
104
+ * @returns {string}
105
+ */
106
+ pivot(pivot_json) {
107
+ let deferred3_0;
108
+ let deferred3_1;
109
+ try {
110
+ const ptr0 = passStringToWasm0(pivot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
111
+ const len0 = WASM_VECTOR_LEN;
112
+ const ret = wasm.engine_pivot(this.__wbg_ptr, ptr0, len0);
113
+ var ptr2 = ret[0];
114
+ var len2 = ret[1];
115
+ if (ret[3]) {
116
+ ptr2 = 0; len2 = 0;
117
+ throw takeFromExternrefTable0(ret[2]);
118
+ }
119
+ deferred3_0 = ptr2;
120
+ deferred3_1 = len2;
121
+ return getStringFromWasm0(ptr2, len2);
122
+ } finally {
123
+ wasm.__wbindgen_free(deferred3_0, deferred3_1, 1);
124
+ }
125
+ }
126
+ /**
127
+ * The same pivot in the binary form (E35) — what the tab and the worker
128
+ * hand the element.
129
+ * @param {string} pivot_json
130
+ * @returns {Uint8Array}
131
+ */
132
+ pivot_columns(pivot_json) {
133
+ const ptr0 = passStringToWasm0(pivot_json, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
134
+ const len0 = WASM_VECTOR_LEN;
135
+ const ret = wasm.engine_pivot_columns(this.__wbg_ptr, ptr0, len0);
136
+ if (ret[3]) {
137
+ throw takeFromExternrefTable0(ret[2]);
138
+ }
139
+ var v2 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
140
+ wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
141
+ return v2;
142
+ }
100
143
  /**
101
144
  * The names of the registered sources, in unspecified order.
102
145
  * @returns {string[]}
@@ -107,6 +150,27 @@ export class Engine {
107
150
  wasm.__wbindgen_free(ret[0], ret[1] * 4, 4);
108
151
  return v1;
109
152
  }
153
+ /**
154
+ * What the engine holds (issue #70), as JSON:
155
+ * `{ "memory": bytes, "sources": [{ "name", "rows", "columns", "bytes" }] }`.
156
+ *
157
+ * `memory` is the module's whole linear memory — what the browser gave
158
+ * it, which only grows; `bytes` is what a source's columns take inside
159
+ * it. Sources by name.
160
+ * @returns {string}
161
+ */
162
+ stats() {
163
+ let deferred1_0;
164
+ let deferred1_1;
165
+ try {
166
+ const ret = wasm.engine_stats(this.__wbg_ptr);
167
+ deferred1_0 = ret[0];
168
+ deferred1_1 = ret[1];
169
+ return getStringFromWasm0(ret[0], ret[1]);
170
+ } finally {
171
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
172
+ }
173
+ }
110
174
  }
111
175
  if (Symbol.dispose) Engine.prototype[Symbol.dispose] = Engine.prototype.free;
112
176
 
Binary file
@@ -7,7 +7,10 @@ export const engine_execute: (a: number, b: number, c: number) => [number, numbe
7
7
  export const engine_execute_columns: (a: number, b: number, c: number) => [number, number, number, number];
8
8
  export const engine_load_csv: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => [number, number];
9
9
  export const engine_new: () => number;
10
+ export const engine_pivot: (a: number, b: number, c: number) => [number, number, number, number];
11
+ export const engine_pivot_columns: (a: number, b: number, c: number) => [number, number, number, number];
10
12
  export const engine_source_names: (a: number) => [number, number];
13
+ export const engine_stats: (a: number) => [number, number];
11
14
  export const planner_finish: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
12
15
  export const planner_finish_columns: (a: number, b: number, c: number, d: number, e: number) => [number, number, number, number];
13
16
  export const planner_new: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number];
package/loader.d.ts CHANGED
@@ -142,6 +142,12 @@ export type Answer = string | Uint8Array | ArrayBuffer;
142
142
  */
143
143
  export interface Provider {
144
144
  execute(queryJson: string, mode: string, options?: ExecuteOptions): Answer | Promise<Answer>;
145
+ /**
146
+ * Optional: a pivot JSON in, the pivot's answer out (issue #28).
147
+ * `<opengrid-pivot>` calls it when it is there, `execute` otherwise. The
148
+ * tab, worker and pivot providers have it.
149
+ */
150
+ pivot?(pivotJson: string, mode: string, options?: ExecuteOptions): Answer | Promise<Answer>;
145
151
  /**
146
152
  * Optional: where the queries run. The grid names it in its footer, beside
147
153
  * the number of queries asked for what is shown; the built-in providers set
@@ -169,10 +175,21 @@ export interface ExecuteOptions {
169
175
  export interface EngineProvider extends Provider {
170
176
  /** Loads CSV bytes as the source `name`, against a schema (JSON). */
171
177
  load(name: string, bytes: ArrayBuffer | Uint8Array, schema: string): Promise<void>;
178
+ /** What the engine holds: its memory and each source's size (issue #70). */
179
+ stats(): Promise<EngineStats>;
172
180
  /** Stops a worker; a no-op in the tab. */
173
181
  terminate(): void;
174
182
  }
175
183
 
184
+ /** What an engine holds, from `stats()` of an engine provider. */
185
+ export interface EngineStats {
186
+ kind: "local" | "worker";
187
+ /** The engine module's WASM linear memory in bytes — it only grows. */
188
+ memory: number;
189
+ /** Every loaded source, by name. */
190
+ sources: { name: string; rows: number; columns: number; bytes: number }[];
191
+ }
192
+
176
193
  /** The engine of the engine module, as `createLocalProvider` uses it. */
177
194
  export interface Engine {
178
195
  load_csv(name: string, bytes: Uint8Array, schema: string): void;
@@ -180,6 +197,12 @@ export interface Engine {
180
197
  execute(queryJson: string): string;
181
198
  /** The result in the binary form — what the tab and worker providers answer. */
182
199
  execute_columns(queryJson: string): Uint8Array;
200
+ /** What it holds, as JSON (see `EngineStats`). */
201
+ stats(): string;
202
+ /** A pivot over the engine's sources, as JSON (issue #28). */
203
+ pivot(pivotJson: string): string;
204
+ /** The same pivot in the binary form — what the tab and worker providers answer. */
205
+ pivot_columns(pivotJson: string): Uint8Array;
183
206
  }
184
207
 
185
208
  /** What a server says a source is. */
@@ -276,11 +299,15 @@ export interface ExportProgress {
276
299
  /**
277
300
  * How `exportRows` fetches and writes: its own keys, plus the
278
301
  * {@link CsvOptions} `get_pivot` takes too. Any other key is an error, and so
279
- * is a CSV option on a JSON export.
302
+ * is a CSV option on a JSON or XLSX export.
280
303
  */
281
304
  export interface ExportOptions extends CsvOptions {
282
- /** `"csv"` (the default) or `"json"` — an array of row objects. */
283
- format?: "csv" | "json";
305
+ /**
306
+ * `"csv"` (the default), `"json"` — an array of row objects — or `"xlsx"`,
307
+ * which only a provider that exports on the server (`createRestProvider`)
308
+ * writes; with any other provider it is a `TypeError`.
309
+ */
310
+ format?: "csv" | "json" | "xlsx";
284
311
  /** Rows per request; 10 000 by default, the server's `max_limit`. */
285
312
  chunkSize?: number;
286
313
  /** More matches than this is an error, never a truncated file; 1 000 000 by default. */
@@ -403,6 +430,12 @@ export type WireValue = string | number | boolean | null;
403
430
 
404
431
  /** Per-column presentation for `set_columns` — `presentation` in `connect`. */
405
432
  export interface ColumnConfig {
433
+ /**
434
+ * What the column is called where a reader reads it — header, column list,
435
+ * filter labels, menus, chips, announcements. The field name stays the
436
+ * identifier: query, view, search expressions, export.
437
+ */
438
+ title?: string;
406
439
  /** The starting width in pixels; a reader's resize leads after that. */
407
440
  width?: number;
408
441
  align?: "start" | "end" | "center";
@@ -579,6 +612,9 @@ export type TextKey =
579
612
  | "apply"
580
613
  | "addGrouping"
581
614
  | "groupingFull"
615
+ | "filterAny"
616
+ | "booleanTrue"
617
+ | "booleanFalse"
582
618
  | "sourceLocal"
583
619
  | "sourceWorker"
584
620
  | "sourceRemote"
@@ -649,6 +685,22 @@ export interface CellChangeDetail {
649
685
  previous: string;
650
686
  }
651
687
 
688
+ /** `opengrid-query`: one answer of the grid's provider (issue #70). */
689
+ export interface QueryDetail {
690
+ /** The provider's `kind`, or `null` when it names none. */
691
+ kind: ProviderKind | null;
692
+ /** The round trip in milliseconds, measured in the tab. */
693
+ ms: number;
694
+ /** Rows answered, and matches before paging. */
695
+ rows: number;
696
+ total: number;
697
+ /** The answer's size as it arrived, and its form. */
698
+ bytes: number;
699
+ form: "binary" | "json";
700
+ /** The element module's WASM linear memory in bytes. */
701
+ memory: number;
702
+ }
703
+
652
704
  /** `opengrid-view-change`: the whole view after the change. */
653
705
  export interface ViewChangeDetail {
654
706
  view: View;
@@ -659,6 +711,7 @@ export interface OpengridEventMap {
659
711
  "opengrid-selection-change": CustomEvent<SelectionChangeDetail>;
660
712
  "opengrid-cell-change": CustomEvent<CellChangeDetail>;
661
713
  "opengrid-view-change": CustomEvent<ViewChangeDetail>;
714
+ "opengrid-query": CustomEvent<QueryDetail>;
662
715
  }
663
716
 
664
717
  // ---------------------------------------------------------------------------
package/loader.js CHANGED
@@ -85,6 +85,12 @@ async function start({ moduleUrl = DEFAULT_MODULE_URL, wasmUrl } = {}) {
85
85
  * Defines the elements in plain DOM, mirroring the Rust skeleton: an open
86
86
  * shadow root, a native `<table>` with a `<caption>`, and `label` -> `aria-label`.
87
87
  *
88
+ * A page that wrote its data as a table inside the element (issue #84) keeps
89
+ * showing it when the module cannot load, which is when it is needed most: the
90
+ * stand-in then renders only a `<slot>`. Without such content it renders the
91
+ * skeleton, as before. Never both — as the slot's default content the skeleton
92
+ * still counted as a second table in WebKit's accessibility tree.
93
+ *
88
94
  * Not exported: `loadOpengrid` installs it when the module fails to load, and a
89
95
  * page that reaches for it directly is asking for the broken state on purpose
90
96
  * (plan point 39 — an export is a promise).
@@ -106,6 +112,10 @@ function installFallback(name = "opengrid-table") {
106
112
  return;
107
113
  }
108
114
  const root = this.attachShadow({ mode: "open" });
115
+ if (this.firstElementChild) {
116
+ root.append(document.createElement("slot"));
117
+ return;
118
+ }
109
119
  const table = document.createElement("table");
110
120
  const caption = document.createElement("caption");
111
121
  table.append(caption);
@@ -121,6 +131,9 @@ function installFallback(name = "opengrid-table") {
121
131
 
122
132
  #applyLabel() {
123
133
  const table = this.shadowRoot.querySelector("table");
134
+ if (!table) {
135
+ return;
136
+ }
124
137
  const caption = this.shadowRoot.querySelector("caption");
125
138
  const label = this.getAttribute("label");
126
139
  if (label) {
@@ -210,6 +223,21 @@ export function createWorkerProvider({
210
223
  return request({ type: "query", query: queryJson });
211
224
  },
212
225
 
226
+ /**
227
+ * What the engine in the worker holds (issue #70): its WASM memory and,
228
+ * per source, rows, columns and bytes.
229
+ */
230
+ async stats() {
231
+ await start();
232
+ return { kind: "worker", ...JSON.parse(await request({ type: "stats" })) };
233
+ },
234
+
235
+ /** Runs a pivot JSON and resolves with the pivot in the binary form (issue #28). */
236
+ async pivot(pivotJson) {
237
+ await start();
238
+ return request({ type: "pivot", pivot: pivotJson });
239
+ },
240
+
213
241
  /** Stops the worker and rejects everything still in flight. */
214
242
  terminate() {
215
243
  worker?.terminate();
@@ -250,6 +278,14 @@ export function createLocalProvider(engine) {
250
278
  execute(queryJson) {
251
279
  return engine.execute_columns(queryJson);
252
280
  },
281
+ /** What the engine holds (issue #70), as the worker provider says it. */
282
+ async stats() {
283
+ return { kind: "local", ...JSON.parse(engine.stats()) };
284
+ },
285
+ /** A pivot over the engine's sources, in the binary form (issue #28). */
286
+ pivot(pivotJson) {
287
+ return engine.pivot_columns(pivotJson);
288
+ },
253
289
  terminate() {},
254
290
  };
255
291
  }
@@ -385,9 +421,7 @@ export function createRestProvider({ url, source, token } = {}) {
385
421
  const blob = await response.blob();
386
422
  onProgress?.({ rows: total, total });
387
423
  // The type `exportRows` gives its Blob, whatever the header's spelling.
388
- return new Blob([blob], {
389
- type: format === "json" ? "application/json" : "text/csv;charset=utf-8",
390
- });
424
+ return new Blob([blob], { type: EXPORT_TYPES[format] ?? EXPORT_TYPES.csv });
391
425
  },
392
426
  };
393
427
  }
@@ -478,19 +512,24 @@ export function createPivotProvider({ url, source, token } = {}) {
478
512
  headers.Authorization = `Bearer ${token}`;
479
513
  }
480
514
 
515
+ async function pivot(pivotJson, _mode, { signal } = {}) {
516
+ const response = await fetch(endpoint, {
517
+ method: "POST",
518
+ headers,
519
+ body: pivotJson,
520
+ signal,
521
+ redirect: "error",
522
+ });
523
+ return answerOf(response);
524
+ }
525
+
481
526
  return {
482
527
  /** Where the queries run; the grid names it in its footer (issue #33). */
483
528
  kind: "remote",
484
- async execute(pivotJson, _mode, { signal } = {}) {
485
- const response = await fetch(endpoint, {
486
- method: "POST",
487
- headers,
488
- body: pivotJson,
489
- signal,
490
- redirect: "error",
491
- });
492
- return answerOf(response);
493
- },
529
+ // `pivot` is what `<opengrid-pivot>` calls (issue #28); `execute` stays for
530
+ // a page that called it before.
531
+ execute: pivot,
532
+ pivot,
494
533
  };
495
534
  }
496
535
 
@@ -548,6 +587,13 @@ export function createHybridProvider({ remote, planner, mode = "auto", onPlan }
548
587
  };
549
588
  }
550
589
 
590
+ /** The media type of each export's `Blob`. */
591
+ const EXPORT_TYPES = {
592
+ csv: "text/csv;charset=utf-8",
593
+ json: "application/json",
594
+ xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
595
+ };
596
+
551
597
  /** The options of `exportRows` that are its own. */
552
598
  const EXPORT_OPTIONS = ["format", "chunkSize", "maxRows", "onProgress", "signal"];
553
599
  /**
@@ -626,14 +672,25 @@ export async function exportRows(provider, query, options = {}) {
626
672
  protectFormulas,
627
673
  null: nullText,
628
674
  } = options;
629
- if (format !== "csv" && format !== "json") {
630
- throw new TypeError(`exportRows: format is "csv" or "json", not ${JSON.stringify(format)}`);
675
+ if (format !== "csv" && format !== "json" && format !== "xlsx") {
676
+ throw new TypeError(
677
+ `exportRows: format is "csv", "json" or "xlsx", not ${JSON.stringify(format)}`,
678
+ );
631
679
  }
632
- if (format === "json") {
633
- // A CSV option on a JSON export would do nothing, and do it silently.
680
+ if (format === "xlsx" && typeof provider?.export !== "function") {
681
+ // An XLSX file is written on the server (issue #72); pieces fetched here
682
+ // cannot become one.
683
+ throw new TypeError(
684
+ "exportRows: an XLSX export needs a provider that exports on the server (createRestProvider)",
685
+ );
686
+ }
687
+ if (format !== "csv") {
688
+ // A CSV option on another export would do nothing, and do it silently.
634
689
  const stray = CSV_OPTIONS.find((key) => options[key] !== undefined);
635
690
  if (stray) {
636
- throw new TypeError(`exportRows: "${stray}" is a CSV option, and this export is JSON`);
691
+ throw new TypeError(
692
+ `exportRows: "${stray}" is a CSV option, and this export is ${format.toUpperCase()}`,
693
+ );
637
694
  }
638
695
  }
639
696
  if (!Number.isSafeInteger(chunkSize) || chunkSize < 1) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casoon/opengrid",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "description": "Accessible data grid, table and pivot as web components, driven by a portable Rust/WASM query engine — with React, Vue and Svelte components.",
6
6
  "keywords": [
@@ -181,11 +181,12 @@ export interface InitOutput {
181
181
  readonly set_provider: (a: any, b: any) => void;
182
182
  readonly set_texts: (a: any, b: any) => void;
183
183
  readonly set_view: (a: any, b: any) => void;
184
- readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_: (a: number, b: number, c: any, d: number, e: number, f: number, g: number, h: number, i: number) => void;
184
+ readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_90ed3bea5014610e___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_: (a: number, b: number, c: any, d: number, e: number, f: number, g: number, h: number, i: number) => void;
185
185
  readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___wasm_bindgen_66404d18cc2edcc2___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_66404d18cc2edcc2___JsError___true_: (a: number, b: number, c: any) => [number, number];
186
- readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true_: (a: number, b: number, c: any) => void;
187
- readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__3: (a: number, b: number, c: any) => void;
188
- readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__4: (a: number, b: number, c: any) => void;
186
+ readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true_: (a: number, b: number, c: any) => void;
187
+ readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__2: (a: number, b: number, c: any) => void;
188
+ readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__4: (a: number, b: number, c: any) => void;
189
+ readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__5: (a: number, b: number, c: any) => void;
189
190
  readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___u32______true_: (a: number, b: number, c: number) => void;
190
191
  readonly wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke_______true_: (a: number, b: number) => void;
191
192
  readonly __wbindgen_malloc: (a: number, b: number) => number;
@@ -1,8 +1,8 @@
1
1
  /* @ts-self-types="./opengrid_web_components.d.ts" */
2
- import { __opengrid_define_element } from './snippets/opengrid-web-core-cf7d8c1a6d317e41/inline1.js';
3
- import * as import1 from "./snippets/opengrid-web-core-cf7d8c1a6d317e41/inline0.js"
4
- import * as import2 from "./snippets/opengrid-web-core-cf7d8c1a6d317e41/inline0.js"
5
- import * as import3 from "./snippets/opengrid-web-core-cf7d8c1a6d317e41/inline0.js"
2
+ import { __opengrid_define_element } from './snippets/opengrid-web-core-9731ccd8c20c4826/inline1.js';
3
+ import * as import1 from "./snippets/opengrid-web-core-9731ccd8c20c4826/inline0.js"
4
+ import * as import2 from "./snippets/opengrid-web-core-9731ccd8c20c4826/inline0.js"
5
+ import * as import3 from "./snippets/opengrid-web-core-9731ccd8c20c4826/inline0.js"
6
6
 
7
7
 
8
8
  /**
@@ -266,7 +266,7 @@ function __wbg_get_imports() {
266
266
  const ret = Error(getStringFromWasm0(arg0, arg1));
267
267
  return ret;
268
268
  },
269
- __wbg___opengrid_define_element_9fe4767b320e082c: function(arg0, arg1, arg2, arg3, arg4, arg5) {
269
+ __wbg___opengrid_define_element_9f1634216a398bd3: function(arg0, arg1, arg2, arg3, arg4, arg5) {
270
270
  __opengrid_define_element(getStringFromWasm0(arg0, arg1), arg2, arg3, arg4, arg5);
271
271
  },
272
272
  __wbg___wbindgen_boolean_get_fa956cfa2d1bd751: function(arg0) {
@@ -348,6 +348,10 @@ function __wbg_get_imports() {
348
348
  const ret = arg0.call(arg1, arg2, arg3, arg4);
349
349
  return ret;
350
350
  }, arguments); },
351
+ __wbg_call_8a2dd23819f8a60a: function() { return handleError(function (arg0, arg1) {
352
+ const ret = arg0.call(arg1);
353
+ return ret;
354
+ }, arguments); },
351
355
  __wbg_call_e3b662382210db98: function() { return handleError(function (arg0, arg1, arg2, arg3) {
352
356
  const ret = arg0.call(arg1, arg2, arg3);
353
357
  return ret;
@@ -364,6 +368,10 @@ function __wbg_get_imports() {
364
368
  const ret = arg0.clientHeight;
365
369
  return ret;
366
370
  },
371
+ __wbg_clientLeft_bdcddc3e40fccaa7: function(arg0) {
372
+ const ret = arg0.clientLeft;
373
+ return ret;
374
+ },
367
375
  __wbg_closest_d889c758da4bb13b: function() { return handleError(function (arg0, arg1, arg2) {
368
376
  const ret = arg0.closest(getStringFromWasm0(arg1, arg2));
369
377
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
@@ -384,6 +392,14 @@ function __wbg_get_imports() {
384
392
  const ret = arg0.customElements;
385
393
  return ret;
386
394
  },
395
+ __wbg_disabled_03c1f71b366d407a: function(arg0) {
396
+ const ret = arg0.disabled;
397
+ return ret;
398
+ },
399
+ __wbg_disabled_ff46632391f3512a: function(arg0) {
400
+ const ret = arg0.disabled;
401
+ return ret;
402
+ },
387
403
  __wbg_dispatchEvent_ca78eaf3d469bc25: function() { return handleError(function (arg0, arg1) {
388
404
  const ret = arg0.dispatchEvent(arg1);
389
405
  return ret;
@@ -425,6 +441,14 @@ function __wbg_get_imports() {
425
441
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
426
442
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
427
443
  }, arguments); },
444
+ __wbg_getRootNode_f724c3be671a9a57: function(arg0) {
445
+ const ret = arg0.getRootNode();
446
+ return ret;
447
+ },
448
+ __wbg_get_507a50627bffa49b: function(arg0, arg1) {
449
+ const ret = arg0[arg1 >>> 0];
450
+ return ret;
451
+ },
428
452
  __wbg_get_78f252d074a84d0b: function() { return handleError(function (arg0, arg1) {
429
453
  const ret = Reflect.get(arg0, arg1);
430
454
  return ret;
@@ -626,6 +650,10 @@ function __wbg_get_imports() {
626
650
  const ret = new Array();
627
651
  return ret;
628
652
  },
653
+ __wbg_new_5394f65338077341: function() { return handleError(function (arg0) {
654
+ const ret = new ResizeObserver(arg0);
655
+ return ret;
656
+ }, arguments); },
629
657
  __wbg_new_cd45aabdf6073e84: function(arg0) {
630
658
  const ret = new Uint8Array(arg0);
631
659
  return ret;
@@ -646,6 +674,13 @@ function __wbg_get_imports() {
646
674
  const ret = new CustomEvent(getStringFromWasm0(arg0, arg1), arg2);
647
675
  return ret;
648
676
  }, arguments); },
677
+ __wbg_now_86c0d4ba3fa605b8: function() {
678
+ const ret = Date.now();
679
+ return ret;
680
+ },
681
+ __wbg_observe_f27242eadc2ebd47: function(arg0, arg1) {
682
+ arg0.observe(arg1);
683
+ },
649
684
  __wbg_of_85f52f8b6491a7ca: function(arg0) {
650
685
  const ret = Array.of(arg0);
651
686
  return ret;
@@ -654,6 +689,10 @@ function __wbg_get_imports() {
654
689
  const ret = arg0.ownerDocument;
655
690
  return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
656
691
  },
692
+ __wbg_parentElement_5030754e30795652: function(arg0) {
693
+ const ret = arg0.parentElement;
694
+ return isLikeNone(ret) ? 0 : addToExternrefTable0(ret);
695
+ },
657
696
  __wbg_parse_1c0d8a8656d7e016: function() { return handleError(function (arg0, arg1) {
658
697
  const ret = JSON.parse(getStringFromWasm0(arg0, arg1));
659
698
  return ret;
@@ -723,6 +762,10 @@ function __wbg_get_imports() {
723
762
  __wbg_scrollIntoView_d8b806f471b7418e: function(arg0, arg1) {
724
763
  arg0.scrollIntoView(arg1);
725
764
  },
765
+ __wbg_scrollLeft_5be50f489b342a09: function(arg0) {
766
+ const ret = arg0.scrollLeft;
767
+ return ret;
768
+ },
726
769
  __wbg_scrollTop_b3effa9c5de14d21: function(arg0) {
727
770
  const ret = arg0.scrollTop;
728
771
  return ret;
@@ -762,6 +805,9 @@ function __wbg_get_imports() {
762
805
  __wbg_set_detail_564ad103413aa5dc: function(arg0, arg1) {
763
806
  arg0.detail = arg1;
764
807
  },
808
+ __wbg_set_disabled_0ae5c051bdb880d2: function(arg0, arg1) {
809
+ arg0.disabled = arg1 !== 0;
810
+ },
765
811
  __wbg_set_disabled_cad2c12b3643aa52: function(arg0, arg1) {
766
812
  arg0.disabled = arg1 !== 0;
767
813
  },
@@ -774,6 +820,9 @@ function __wbg_get_imports() {
774
820
  __wbg_set_mode_17bd6a9f8e12d5a5: function(arg0, arg1) {
775
821
  arg0.mode = __wbindgen_enum_ShadowRootMode[arg1];
776
822
  },
823
+ __wbg_set_scrollLeft_075e81a16fc93cca: function(arg0, arg1) {
824
+ arg0.scrollLeft = arg1;
825
+ },
777
826
  __wbg_set_scrollTop_431b03eeb3e9c636: function(arg0, arg1) {
778
827
  arg0.scrollTop = arg1;
779
828
  },
@@ -883,46 +932,51 @@ function __wbg_get_imports() {
883
932
  return ret;
884
933
  },
885
934
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
886
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 201, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
935
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 182, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
887
936
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___wasm_bindgen_66404d18cc2edcc2___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_66404d18cc2edcc2___JsError___true_);
888
937
  return ret;
889
938
  },
890
939
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
891
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 17, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
892
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true_);
940
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 18, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
941
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true_);
893
942
  return ret;
894
943
  },
895
944
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
896
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("HTMLElement"), String, Option(String), Option(String)], shim_idx: 18, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
897
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_);
945
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 18, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
946
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__2);
898
947
  return ret;
899
948
  },
900
949
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
901
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("HTMLElement")], shim_idx: 17, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
902
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__3);
950
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("HTMLElement"), String, Option(String), Option(String)], shim_idx: 19, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
951
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_90ed3bea5014610e___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_);
903
952
  return ret;
904
953
  },
905
954
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
906
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 17, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
907
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__4);
955
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("HTMLElement")], shim_idx: 18, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
956
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__4);
908
957
  return ret;
909
958
  },
910
959
  __wbindgen_cast_0000000000000006: function(arg0, arg1) {
911
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [U32], shim_idx: 188, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
912
- const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___u32______true_);
960
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 18, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
961
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__5);
913
962
  return ret;
914
963
  },
915
964
  __wbindgen_cast_0000000000000007: function(arg0, arg1) {
916
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 16, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
965
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [U32], shim_idx: 168, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
966
+ const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___u32______true_);
967
+ return ret;
968
+ },
969
+ __wbindgen_cast_0000000000000008: function(arg0, arg1) {
970
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 17, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
917
971
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke_______true_);
918
972
  return ret;
919
973
  },
920
- __wbindgen_cast_0000000000000008: function(arg0) {
974
+ __wbindgen_cast_0000000000000009: function(arg0) {
921
975
  // Cast intrinsic for `F64 -> Externref`.
922
976
  const ret = arg0;
923
977
  return ret;
924
978
  },
925
- __wbindgen_cast_0000000000000009: function(arg0, arg1) {
979
+ __wbindgen_cast_000000000000000a: function(arg0, arg1) {
926
980
  // Cast intrinsic for `Ref(String) -> Externref`.
927
981
  const ret = getStringFromWasm0(arg0, arg1);
928
982
  return ret;
@@ -940,9 +994,9 @@ function __wbg_get_imports() {
940
994
  return {
941
995
  __proto__: null,
942
996
  "./opengrid_web_components_bg.js": import0,
943
- "./snippets/opengrid-web-core-cf7d8c1a6d317e41/inline0.js": import1,
944
- "./snippets/opengrid-web-core-cf7d8c1a6d317e41/inline0.js": import2,
945
- "./snippets/opengrid-web-core-cf7d8c1a6d317e41/inline0.js": import3,
997
+ "./snippets/opengrid-web-core-9731ccd8c20c4826/inline0.js": import1,
998
+ "./snippets/opengrid-web-core-9731ccd8c20c4826/inline0.js": import2,
999
+ "./snippets/opengrid-web-core-9731ccd8c20c4826/inline0.js": import3,
946
1000
  };
947
1001
  }
948
1002
 
@@ -950,16 +1004,20 @@ function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke_______true
950
1004
  wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke_______true_(arg0, arg1);
951
1005
  }
952
1006
 
953
- function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true_(arg0, arg1, arg2) {
954
- wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true_(arg0, arg1, arg2);
1007
+ function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true_(arg0, arg1, arg2) {
1008
+ wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true_(arg0, arg1, arg2);
1009
+ }
1010
+
1011
+ function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__2(arg0, arg1, arg2) {
1012
+ wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__2(arg0, arg1, arg2);
955
1013
  }
956
1014
 
957
- function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__3(arg0, arg1, arg2) {
958
- wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__3(arg0, arg1, arg2);
1015
+ function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__4(arg0, arg1, arg2) {
1016
+ wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__4(arg0, arg1, arg2);
959
1017
  }
960
1018
 
961
- function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__4(arg0, arg1, arg2) {
962
- wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__4(arg0, arg1, arg2);
1019
+ function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__5(arg0, arg1, arg2) {
1020
+ wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__5(arg0, arg1, arg2);
963
1021
  }
964
1022
 
965
1023
  function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___wasm_bindgen_66404d18cc2edcc2___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_66404d18cc2edcc2___JsError___true_(arg0, arg1, arg2) {
@@ -969,14 +1027,14 @@ function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___wasm_bin
969
1027
  }
970
1028
  }
971
1029
 
972
- function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_(arg0, arg1, arg2, arg3, arg4, arg5) {
1030
+ function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_90ed3bea5014610e___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_(arg0, arg1, arg2, arg3, arg4, arg5) {
973
1031
  const ptr0 = passStringToWasm0(arg3, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
974
1032
  const len0 = WASM_VECTOR_LEN;
975
1033
  var ptr1 = isLikeNone(arg4) ? 0 : passStringToWasm0(arg4, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
976
1034
  var len1 = WASM_VECTOR_LEN;
977
1035
  var ptr2 = isLikeNone(arg5) ? 0 : passStringToWasm0(arg5, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
978
1036
  var len2 = WASM_VECTOR_LEN;
979
- wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_(arg0, arg1, arg2, ptr0, len0, ptr1, len1, ptr2, len2);
1037
+ wasm.wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_90ed3bea5014610e___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_(arg0, arg1, arg2, ptr0, len0, ptr1, len1, ptr2, len2);
980
1038
  }
981
1039
 
982
1040
  function wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___u32______true_(arg0, arg1, arg2) {
Binary file
@@ -13,11 +13,12 @@ export const set_formats: (a: any, b: any) => void;
13
13
  export const set_provider: (a: any, b: any) => void;
14
14
  export const set_texts: (a: any, b: any) => void;
15
15
  export const set_view: (a: any, b: any) => void;
16
- export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_: (a: number, b: number, c: any, d: number, e: number, f: number, g: number, h: number, i: number) => void;
16
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_90ed3bea5014610e___features__gen_HtmlElement__HtmlElement__alloc_508e33bd5656020b___string__String__core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String___core_ed718c3d60ebd546___option__Option_alloc_508e33bd5656020b___string__String_______true_: (a: number, b: number, c: any, d: number, e: number, f: number, g: number, h: number, i: number) => void;
17
17
  export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___wasm_bindgen_66404d18cc2edcc2___JsValue__core_ed718c3d60ebd546___result__Result_____wasm_bindgen_66404d18cc2edcc2___JsError___true_: (a: number, b: number, c: any) => [number, number];
18
- export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true_: (a: number, b: number, c: any) => void;
19
- export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__3: (a: number, b: number, c: any) => void;
20
- export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___web_sys_c43fef36ea7eb37c___features__gen_HtmlElement__HtmlElement______true__4: (a: number, b: number, c: any) => void;
18
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true_: (a: number, b: number, c: any) => void;
19
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__2: (a: number, b: number, c: any) => void;
20
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__4: (a: number, b: number, c: any) => void;
21
+ export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___js_sys_f6d81f9cdcf4f83___Array______true__5: (a: number, b: number, c: any) => void;
21
22
  export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke___u32______true_: (a: number, b: number, c: number) => void;
22
23
  export const wasm_bindgen_66404d18cc2edcc2___convert__closures_____invoke_______true_: (a: number, b: number) => void;
23
24
  export const __wbindgen_malloc: (a: number, b: number) => number;
package/worker.js CHANGED
@@ -13,6 +13,8 @@
13
13
  * load { type:"load", id, name, bytes, schema }
14
14
  * -> { type:"loaded", id }
15
15
  * query { type:"query", id, query } -> { id, result }
16
+ * stats { type:"stats", id } -> { id, result } (issue #70)
17
+ * pivot { type:"pivot", id, pivot } -> { id, result } (issue #28)
16
18
  *
17
19
  * Any request that throws answers `{ id, type:"error", message }`. The `bytes`
18
20
  * of `load` arrive as a transferable `ArrayBuffer`; a `result` is the engine's
@@ -40,11 +42,21 @@ self.onmessage = async ({ data }) => {
40
42
  self.postMessage({ type: "loaded", id: data.id });
41
43
  break;
42
44
  }
45
+ case "stats": {
46
+ // What the engine holds: its memory and each source's size, as JSON.
47
+ self.postMessage({ id: data.id, result: engine.stats() });
48
+ break;
49
+ }
43
50
  case "query": {
44
51
  const result = engine.execute_columns(data.query);
45
52
  self.postMessage({ id: data.id, result }, [result.buffer]);
46
53
  break;
47
54
  }
55
+ case "pivot": {
56
+ const result = engine.pivot_columns(data.pivot);
57
+ self.postMessage({ id: data.id, result }, [result.buffer]);
58
+ break;
59
+ }
48
60
  default:
49
61
  throw new Error(`unknown message type ${data.type}`);
50
62
  }