@casoon/opengrid 0.16.0 → 0.18.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 +171 -1
- package/README.md +3 -3
- package/collation/opengrid_collation.d.ts +47 -0
- package/collation/opengrid_collation.js +256 -0
- package/collation/opengrid_collation_bg.wasm +0 -0
- package/collation/opengrid_collation_bg.wasm.d.ts +10 -0
- package/collation.js +48 -0
- package/engine/opengrid_wasm.d.ts +77 -1
- package/engine/opengrid_wasm.js +187 -0
- package/engine/opengrid_wasm_bg.wasm +0 -0
- package/engine/opengrid_wasm_bg.wasm.d.ts +14 -1
- package/loader.d.ts +45 -0
- package/loader.js +452 -8
- package/package.json +4 -1
- package/pkg/opengrid_web_components.d.ts +10 -10
- package/pkg/opengrid_web_components.js +50 -50
- package/pkg/opengrid_web_components_bg.wasm +0 -0
- package/pkg/opengrid_web_components_bg.wasm.d.ts +10 -10
- package/react/index.d.ts +2 -0
- package/react/index.js +1 -0
- package/svelte/OpengridGrid.svelte +2 -0
- package/svelte/index.d.ts +2 -0
- package/vue/index.d.ts +2 -0
- package/vue/index.js +1 -0
- package/worker.js +84 -1
- package/xlsx/opengrid_xlsx_bg.wasm +0 -0
- /package/pkg/snippets/{opengrid-web-components-35ed06b453a9b215 → opengrid-web-components-bcd23b5e2228bf0e}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-components-35ed06b453a9b215 → opengrid-web-components-bcd23b5e2228bf0e}/inline1.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-b41714d4e7311909 → opengrid-web-core-5e04e9ab83050ad3}/inline0.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-b41714d4e7311909 → opengrid-web-core-5e04e9ab83050ad3}/inline1.js +0 -0
- /package/pkg/snippets/{opengrid-web-core-b41714d4e7311909 → opengrid-web-core-5e04e9ab83050ad3}/inline2.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -19,6 +19,174 @@ Two things belong in every release entry and are easy to leave out:
|
|
|
19
19
|
|
|
20
20
|
## [Unreleased]
|
|
21
21
|
|
|
22
|
+
## [0.18.0] - 2026-11-17
|
|
23
|
+
|
|
24
|
+
Not yet verified by a screen reader: no pass with assistive technology has been recorded for this
|
|
25
|
+
release ([#5](https://github.com/casoon/opengrid/issues/5)). The keyboard and `axe-core` checks run on
|
|
26
|
+
every change.
|
|
27
|
+
|
|
28
|
+
**What breaks:** the Rust API of `opengrid-columns` (`SortKeys`, `Values::Decimal`, `Values::Utf8`
|
|
29
|
+
and `Values::Int64` changed their shape, see *Changed*). The npm package's API is unchanged.
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
|
|
33
|
+
- **Grouping:** a group row's label stays on one line when its cell has the focus. It was
|
|
34
|
+
unfolded like any focused cell and wrapped over three lines inside the narrow first column.
|
|
35
|
+
- **Package:** a page that serves the package's files itself and leaves out `collation.js` no
|
|
36
|
+
longer breaks. Since 0.17.0 `loader.js` and `worker.js` imported it statically, so the loader
|
|
37
|
+
failed to load or the worker died without a word and the grid never showed a row. Both import
|
|
38
|
+
it on the first query that names a locale now; without the file only that sort is refused,
|
|
39
|
+
with an error that names it. `installation.mdx` lists what a page that copies the files must
|
|
40
|
+
copy ([#415](https://github.com/casoon/opengrid/issues/415)).
|
|
41
|
+
- **Pages:** the demo on the project page did not start since 0.17.0 (`loader.js` imports
|
|
42
|
+
`collation.js`, which the site did not copy).
|
|
43
|
+
- **Docs:** the API reference linked the protocol page as `protocol.md`, which is a 404 on the site.
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- **Docs:** the performance guide compares opengrid with AG Grid Community, RevoGrid, SlickGrid, Tabulator and w2ui (all MIT) on 100,000 and 1,000,000 rows, says why it is faster where it is and where it is behind, and says how far to trust the adapters ([#421](https://github.com/casoon/opengrid/issues/421)).
|
|
48
|
+
- **Docs, tools:** the performance guide has a section "In the browser, as a visitor sees it" with
|
|
49
|
+
opengrid's own page-level figures (first rows, sort, filter, group, scrolling, bytes fetched, page
|
|
50
|
+
memory; in the tab and in server mode), and `bench/baselines/` keeps them in the tool's format, also with the CPU four and six times slower;
|
|
51
|
+
`just bench-local` measures this checkout against them, `--baseline` marks what got worse
|
|
52
|
+
([#421](https://github.com/casoon/opengrid/issues/421)).
|
|
53
|
+
- **Package, engine:** `provider.unload(name)` on the local and the worker provider, and `unload` on the engine module, free one source; a load after it takes the room the table had, so a page that reloads stays at one table instead of two ([Loading again](https://casoon.github.io/opengrid/docs/guides/performance/#loading-again), [#459](https://github.com/casoon/opengrid/issues/459)).
|
|
54
|
+
- **Docs:** the performance guide measures loading again: what the engine and the browser hold after ten loads of a million rows under one name and under ten, and what `terminate()` hands back, with `scripts/measure-reload.mjs` to repeat it ([Loading again](https://casoon.github.io/opengrid/docs/guides/performance/#loading-again), [#459](https://github.com/casoon/opengrid/issues/459)).
|
|
55
|
+
- **Docs:** the performance guide measures server mode: a window of 40 rows, a filter, a text search and a grouping from PostgreSQL and SQLite at one and ten million rows, with the server's memory and `cargo run --example server_bench` to repeat it ([In server mode](https://casoon.github.io/opengrid/docs/guides/performance/#in-server-mode), [#452](https://github.com/casoon/opengrid/issues/452)).
|
|
56
|
+
- **Pages:** the start page explains where the data lives — in the tab, on the server, or split — side by side, with when to start where, the query the browser sends instead of SQL, a diagram of one window fetched from the server, the sources a server reads and measured figures ([#453](https://github.com/casoon/opengrid/issues/453)).
|
|
57
|
+
- **Engine:** the WebAssembly engine reads rows as packs of typed columns: `begin_columns`,
|
|
58
|
+
`push_columns`, `end_columns` and `abort_columns`, as it reads CSV in pieces. An engine module
|
|
59
|
+
without them still loads rows, as JSON text
|
|
60
|
+
([#445](https://github.com/casoon/opengrid/issues/445)).
|
|
61
|
+
- **Package, engine:** a CSV file can be read piece by piece: `provider.loadStream(name, source, schema, { chunkSize? })` on the worker and the local provider takes a `File`/`Blob`, a `ReadableStream` of bytes or an async iterable, and the engine module has `begin_csv`, `push_csv`, `end_csv` and `abort_csv` (Rust: `ingest::CsvLoader`). Only a piece and the columns are in memory, not the whole file as well: a 43 MB file loaded from a `fetch` stream takes about 30 MiB less in the browser than `load` of its bytes (the engine's module 118 MiB instead of 78–90 MiB). The pieces may end anywhere; the table, the errors and their line numbers are those of the whole file (#427). [Data you already have](docs/guides/data-you-have.md) has a section on it.
|
|
62
|
+
- **Columns:** `ColumnBuilder` has typed pushes, `push_bool`, `push_i64`, `push_f64`,
|
|
63
|
+
`push_decimal`, `push_date` and `push_timestamp`, for a cell that has just been read as that type.
|
|
64
|
+
A column of another type, or a decimal of another scale, is refused with an error
|
|
65
|
+
([#442](https://github.com/casoon/opengrid/issues/442)).
|
|
66
|
+
- **Columns:** `ColumnBuilder::push_str` appends text to a text column without a `Value` in between. The CSV reader uses it, so a text cell is copied into its column once instead of being made a `String`, copied and freed (#429).
|
|
67
|
+
- **Docs:** *What the engine costs* — the engine on 100,000 and 1,000,000 rows (load, filter, sort,
|
|
68
|
+
group, pivot, memory), measured on an Apple M4 Pro, what a page pays for the WebAssembly modules,
|
|
69
|
+
what the figures are not, and `scripts/measure-queries.mjs` to repeat them.
|
|
70
|
+
|
|
71
|
+
### Changed
|
|
72
|
+
|
|
73
|
+
- **Package:** `loadRows` of an array of objects starts the worker while the rows are made into columns, and makes the next pack while the engine takes the one before: the first rows of a million-row table show after 190 ms instead of 300 ms (100,000 rows: 86 instead of 112 ms). A pack the engine refuses stops the rest, as before.
|
|
74
|
+
- **Server:** the count of a query is remembered for 5 seconds, so the next window of it (only
|
|
75
|
+
`offset` changes) does not count again: on ten million rows in PostgreSQL the first window takes
|
|
76
|
+
0.5 ms instead of 146 ms, a filtered one 246 instead of 461 ms. The key is the filter (the token's
|
|
77
|
+
row filter included), grouping and aggregates; `notify_changed` drops it, `count_cache_ttl` sets
|
|
78
|
+
the time, zero switches it off. A count can be stale for that time when a database changes without
|
|
79
|
+
the server being told. `Connector::execute_counted` is new and defaults to `execute`; PostgreSQL
|
|
80
|
+
and SQLite skip their count statement with it
|
|
81
|
+
([#457](https://github.com/casoon/opengrid/issues/457)).
|
|
82
|
+
- **Engine, columns:** a sort by a locale makes one sort key per distinct text of a column with few
|
|
83
|
+
of them, and the rows share the keys, instead of one per row: a million rows by `customer` take 17 ms
|
|
84
|
+
for the first 100 rows with `de` instead of 501 ms, by `country` 16 ms instead of 208. The order is
|
|
85
|
+
the same. **What breaks:** `opengrid_columns::sort::SortKeys` has a second form (`by_codes`); `len`
|
|
86
|
+
and `get` read the same
|
|
87
|
+
([#467](https://github.com/casoon/opengrid/issues/467)).
|
|
88
|
+
- **Engine:** grouping by text columns with few distinct texts finds a row's group by the codes of
|
|
89
|
+
its texts instead of building and hashing a key from each text: a million rows grouped by country
|
|
90
|
+
take 55 ms instead of 101, by customer (500 groups) 41 instead of 107, and the pivot of country
|
|
91
|
+
and customer 190 instead of 316. Groups come in the same order as before and nothing else
|
|
92
|
+
changes; columns of other types, flat texts and more than 262,144 combinations of codes group
|
|
93
|
+
as before
|
|
94
|
+
([#465](https://github.com/casoon/opengrid/issues/465)).
|
|
95
|
+
- **Engine, columns:** an exact decimal of up to 18 digits of precision — an amount, a rate, a
|
|
96
|
+
price: `decimal(12, 2)` — keeps its coefficient in eight bytes instead of sixteen; the type
|
|
97
|
+
decides, wider decimals stay as they were. The ten columns of the benchmark table take 43 bytes a
|
|
98
|
+
row instead of 51, and the module's memory after loading a million of them 121 MiB instead of
|
|
99
|
+
128. No answer changes (an exact sum stays exact), and no query gets slower. A coefficient that
|
|
100
|
+
does not fit the storage is refused when it is pushed, not cut. **What breaks:**
|
|
101
|
+
`opengrid_columns::Values::Decimal` holds a `Decimals` and not a `Vec<i128>`; read it with
|
|
102
|
+
`Decimals::get` or `iter`
|
|
103
|
+
([#450](https://github.com/casoon/opengrid/issues/450)).
|
|
104
|
+
- **Engine, columns:** a text column with few distinct texts — a country, a status, a customer of a few
|
|
105
|
+
hundred — keeps each text once and a code of one or two bytes a row; a column of distinct texts
|
|
106
|
+
is stored as before. The ten columns of the benchmark table take 51 bytes a row instead of 73,
|
|
107
|
+
and the module's memory after loading a million of them 128 MiB instead of 173, and 68 instead
|
|
108
|
+
of 112 when the file is read in pieces. A search or a filter on such a column tests each distinct
|
|
109
|
+
text once: a text search over a million rows takes 21 ms instead of 47. Loading takes about a
|
|
110
|
+
tenth longer. No answer changes. **What breaks:** `opengrid_columns::Values::Utf8` holds a
|
|
111
|
+
`Strs`, a dictionary or a flat column, and not `offsets` and `text`; read it with `Column::str`
|
|
112
|
+
or `Strs::get`
|
|
113
|
+
([#451](https://github.com/casoon/opengrid/issues/451)).
|
|
114
|
+
- **Engine, columns:** an `int64` column stores its values in as few bytes as they need — one for a
|
|
115
|
+
count, four for an id, eight at most — instead of eight each, and so do the columns derived
|
|
116
|
+
from a date. The ten columns of the benchmark table take 73 bytes a row instead of 103, the
|
|
117
|
+
module's memory after loading a million of them 173 MiB instead of 199, and 112 instead of 140
|
|
118
|
+
when the file is read in pieces. No answer changes, and no query gets slower. **What breaks:**
|
|
119
|
+
`opengrid_columns::Values::Int64` holds an `Ints` and not a `Vec<i64>`; read it with
|
|
120
|
+
`Ints::get`, `iter` or `to_vec`
|
|
121
|
+
([#447](https://github.com/casoon/opengrid/issues/447)).
|
|
122
|
+
- **Package, engine:** `loadRows` of an array of objects hands them over as typed columns, in packs of
|
|
123
|
+
65,536 rows, instead of as one JSON text. A million rows reach the first rows in 0.27 s instead
|
|
124
|
+
of 1.2 s, and the page holds 386 MiB instead of 847; 100,000 rows in 0.1 s instead of 0.17 s and
|
|
125
|
+
128 MiB instead of 158. The table and every refusal are the same, and anything that is not
|
|
126
|
+
plain still goes as JSON text. See [Data you already have](docs/guides/data-you-have.md)
|
|
127
|
+
([#445](https://github.com/casoon/opengrid/issues/445)).
|
|
128
|
+
- **Engine:** a CSV file loads in less than half the time: a million rows of ten columns in
|
|
129
|
+
0.44 s instead of 1.0 s, 100,000 in 59 ms instead of 118, and a file read piece by piece
|
|
130
|
+
(`loadStream`) in 0.5 s instead of 1.1 s. The tables and the errors are the same
|
|
131
|
+
([#440](https://github.com/casoon/opengrid/issues/440),
|
|
132
|
+
[#442](https://github.com/casoon/opengrid/issues/442)).
|
|
133
|
+
- **Docs:** *What the engine costs* says what using the grid adds to the page's memory: about
|
|
134
|
+
55 MiB once, the browser's painting, and none of it in the engine
|
|
135
|
+
([#428](https://github.com/casoon/opengrid/issues/428)).
|
|
136
|
+
- **Pages:** the start page and *What the engine costs* carry the loading times since the CSV reader's faster passes (a million rows in 0.44 s, 100,000 in 59 ms) and the module sizes as they are now (the engine about 172 KiB, the collation about 325 KiB).
|
|
137
|
+
- **Pages:** the figures of *What the engine costs* and of the start page are measured again after the optimisations (#426–#429, #428): a million rows load in 1.1 s instead of 1.3 s, a sort of the first 100 takes 26 ms instead of 52, the module holds 199 MiB instead of 213, and the whole page, with a fetched CSV and no rows of its own, about 175 MiB (145 read in pieces) instead of the 658 MiB the earlier test page showed, which included a million JavaScript objects it kept itself.
|
|
138
|
+
- **Engine:** a sort that asks for a page of a big table (the first 100 of a million rows) keeps the best rows as it reads them instead of building and sorting a pair for every row: sorting a million rows by one key takes 25 ms instead of 51 ms, and the module no longer grows by 51 MiB for it (the memory after the usual queries on a streamed load: 191 MiB before, 149 MiB after). The order is the same, ties by position (#428).
|
|
139
|
+
- **Engine:** loading a CSV file or a JSON array sizes the columns by the number of lines or objects in the text, so each is allocated once instead of grown by doubling. The module's memory, which never shrinks, holds 199 MiB instead of 215 MiB after a million CSV rows (the columns themselves take 98 MiB, the copy of the file 71 MiB) (#427).
|
|
140
|
+
- **Engine:** loading a CSV file is about 18 % faster (1,000,000 rows of the benchmark's ten columns: 1.41 s to 1.16 s in WebAssembly; native 0.86 s to 0.68 s before the text change). A timestamp in the usual spelling and a decimal of up to 18 digits are read by position and in 64 bits, a row no longer allocates two vectors, and text cells go straight into their column. Anything else is read as before; results and error messages are unchanged (#429).
|
|
141
|
+
- **Engine:** loading a JSON array of objects reads the text in one pass into the column builders instead of building a tree and a vector per row first: 1.7 times faster at 100,000 rows and 3 times at 1,000,000 (191 ms to 110 ms, 3.3 s to 1.1 s, WebAssembly in Node). Anything the fast path does not read the same way — escapes in keys, unknown or repeated keys, nested values, malformed text — goes to the general reader, so results and error messages are unchanged (#426).
|
|
142
|
+
- **Pages:** the start page no longer says *Light on memory*. It says *Compact, not free*: the columns
|
|
143
|
+
take 98 MiB for a million rows, and the whole page holds about 660 MiB with the engine beside the
|
|
144
|
+
page's data (loaded from CSV; 1.1 GiB when the page hands over JavaScript objects). *What the engine
|
|
145
|
+
costs* has the table, measured with `bench/`.
|
|
146
|
+
- **Pages:** the start page has two more cards, *Text in your language* (the collation of a
|
|
147
|
+
locale) and *Next to an AI assistant* (MCP), and *What sets it apart* says what the collation
|
|
148
|
+
is and promises.
|
|
149
|
+
- **Pages:** the project site uses the current shared theme (0.12.14): a wider header, a smaller
|
|
150
|
+
CASOON badge, and a block right after the hero no longer sits flush against it.
|
|
151
|
+
- **Pages:** the start page leads with *Why WebAssembly* — what the engine buys and what it costs,
|
|
152
|
+
with figures measured on an Apple M4 Pro — and then four points on what sets opengrid apart,
|
|
153
|
+
in blocks of four so no card stands alone. Its other figures (conformance cases, axe specs,
|
|
154
|
+
module sizes) are counted and measured when the site is built.
|
|
155
|
+
|
|
156
|
+
## [0.17.0] - 2026-11-13
|
|
157
|
+
|
|
158
|
+
Not yet verified by a screen reader: no pass with assistive technology has been recorded for this
|
|
159
|
+
release ([#5](https://github.com/casoon/opengrid/issues/5)). The keyboard and `axe-core` checks run on
|
|
160
|
+
every change.
|
|
161
|
+
|
|
162
|
+
### Added
|
|
163
|
+
|
|
164
|
+
- **Query:** a sort key may order text by a locale: `"collation": "de"` (rule S4a). The engine,
|
|
165
|
+
SQLite and PostgreSQL give the same order for Latin, Greek and Cyrillic text. See
|
|
166
|
+
[Query semantics](docs/guides/query-semantics.mdx)
|
|
167
|
+
([#391](https://github.com/casoon/opengrid/issues/391)).
|
|
168
|
+
- **Query:** the capability `collation`; the planner leaves a sort by a locale to the client where
|
|
169
|
+
a source does not declare it.
|
|
170
|
+
- **Grid:** `collation="de"` sorts the grid's text columns by a locale (`collation` in the
|
|
171
|
+
framework components). See [Sorting text by a locale](docs/api.md#sorting-text-by-a-locale).
|
|
172
|
+
- **Package:** the collation module, `collation/`, about 330 KiB brotli. The providers load it
|
|
173
|
+
when a query first sorts by a locale in the browser, and not otherwise; `Engine.set_collator`
|
|
174
|
+
and `Planner.set_collator` take it.
|
|
175
|
+
- **Crates:** `opengrid-engine` has the feature `icu` (ICU4X's collator, `collation::Icu`);
|
|
176
|
+
`opengrid-connector` and `opengrid-connector-sqlite` turn it on.
|
|
177
|
+
|
|
178
|
+
### Changed
|
|
179
|
+
|
|
180
|
+
- **Crates:** `opengrid_query::Collation` has the variant `Locale` and is no longer `Copy`.
|
|
181
|
+
**What breaks:** a copied collation is cloned now and a `match` on it needs the new arm;
|
|
182
|
+
`QueryError::CollationNotText`, `ExecuteError::Collation`, `DataSourceCapabilities::collation`
|
|
183
|
+
and `SortKey::collated` are new and matter to code that writes these types out in full.
|
|
184
|
+
- **Build:** the engine module is 4.2 KiB larger and the element module 1.4 KiB; their budgets
|
|
185
|
+
are raised to match.
|
|
186
|
+
- **Pages:** the live demo's first grid sets its header, filter row and facets apart from the
|
|
187
|
+
page behind it, its checkboxes and fields have a darker outline and follow the site's dark
|
|
188
|
+
theme; the card under the hero on the start page has space above it.
|
|
189
|
+
|
|
22
190
|
## [0.16.0] - 2026-11-12
|
|
23
191
|
|
|
24
192
|
Not yet verified by a screen reader: no pass with assistive technology has been recorded for this
|
|
@@ -1630,7 +1798,9 @@ tested.
|
|
|
1630
1798
|
tested: React 18 rendering on the server, SvelteKit, Nuxt, Next.js and Astro
|
|
1631
1799
|
as real applications. A Vite production build needs `loadOpengrid({ moduleUrl })`.
|
|
1632
1800
|
|
|
1633
|
-
[Unreleased]: https://github.com/casoon/opengrid/compare/v0.
|
|
1801
|
+
[Unreleased]: https://github.com/casoon/opengrid/compare/v0.18.0...HEAD
|
|
1802
|
+
[0.18.0]: https://github.com/casoon/opengrid/compare/v0.17.0...v0.18.0
|
|
1803
|
+
[0.17.0]: https://github.com/casoon/opengrid/compare/v0.16.0...v0.17.0
|
|
1634
1804
|
[0.16.0]: https://github.com/casoon/opengrid/compare/v0.15.0...v0.16.0
|
|
1635
1805
|
[0.15.0]: https://github.com/casoon/opengrid/compare/v0.14.0...v0.15.0
|
|
1636
1806
|
[0.14.0]: https://github.com/casoon/opengrid/compare/v0.13.0...v0.14.0
|
package/README.md
CHANGED
|
@@ -57,9 +57,9 @@ as the npm package, so give every `opengrid-*` crate the same one:
|
|
|
57
57
|
|
|
58
58
|
```toml
|
|
59
59
|
[dependencies]
|
|
60
|
-
opengrid-server = "0.
|
|
61
|
-
opengrid-connector-sqlite = "0.
|
|
62
|
-
opengrid-engine = "0.
|
|
60
|
+
opengrid-server = "0.18" # the gateway, as a library
|
|
61
|
+
opengrid-connector-sqlite = "0.18" # or opengrid-datasource-postgres
|
|
62
|
+
opengrid-engine = "0.18" # the engine alone, native
|
|
63
63
|
```
|
|
64
64
|
|
|
65
65
|
While the version is 0.x, a minor bump may break the Rust API
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The sort keys of `locale` for a batch of strings.
|
|
6
|
+
*
|
|
7
|
+
* `texts` is every string's UTF-8 one after the other and `ends` where each
|
|
8
|
+
* one ends in it. The answer is packed the same way round: the end of every
|
|
9
|
+
* key as a little-endian `u32`, then the keys' bytes — one buffer, since a
|
|
10
|
+
* call across two modules copies each argument once.
|
|
11
|
+
*/
|
|
12
|
+
export function sort_keys(locale: string, texts: Uint8Array, ends: Uint32Array): Uint8Array;
|
|
13
|
+
|
|
14
|
+
export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembly.Module;
|
|
15
|
+
|
|
16
|
+
export interface InitOutput {
|
|
17
|
+
readonly memory: WebAssembly.Memory;
|
|
18
|
+
readonly sort_keys: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
19
|
+
readonly __wbindgen_externrefs: WebAssembly.Table;
|
|
20
|
+
readonly __wbindgen_malloc: (a: number, b: number) => number;
|
|
21
|
+
readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
22
|
+
readonly __externref_table_dealloc: (a: number) => void;
|
|
23
|
+
readonly __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
24
|
+
readonly __wbindgen_start: () => void;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type SyncInitInput = BufferSource | WebAssembly.Module;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Instantiates the given `module`, which can either be bytes or
|
|
31
|
+
* a precompiled `WebAssembly.Module`.
|
|
32
|
+
*
|
|
33
|
+
* @param {{ module: SyncInitInput }} module - Passing `SyncInitInput` directly is deprecated.
|
|
34
|
+
*
|
|
35
|
+
* @returns {InitOutput}
|
|
36
|
+
*/
|
|
37
|
+
export function initSync(module: { module: SyncInitInput } | SyncInitInput): InitOutput;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* If `module_or_path` is {RequestInfo} or {URL}, makes a request and
|
|
41
|
+
* for everything else, calls `WebAssembly.instantiate` directly.
|
|
42
|
+
*
|
|
43
|
+
* @param {{ module_or_path: InitInput | Promise<InitInput> }} module_or_path - Passing `InitInput` directly is deprecated.
|
|
44
|
+
*
|
|
45
|
+
* @returns {Promise<InitOutput>}
|
|
46
|
+
*/
|
|
47
|
+
export default function __wbg_init (module_or_path?: { module_or_path: InitInput | Promise<InitInput> } | InitInput | Promise<InitInput>): Promise<InitOutput>;
|
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
/* @ts-self-types="./opengrid_collation.d.ts" */
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The sort keys of `locale` for a batch of strings.
|
|
5
|
+
*
|
|
6
|
+
* `texts` is every string's UTF-8 one after the other and `ends` where each
|
|
7
|
+
* one ends in it. The answer is packed the same way round: the end of every
|
|
8
|
+
* key as a little-endian `u32`, then the keys' bytes — one buffer, since a
|
|
9
|
+
* call across two modules copies each argument once.
|
|
10
|
+
* @param {string} locale
|
|
11
|
+
* @param {Uint8Array} texts
|
|
12
|
+
* @param {Uint32Array} ends
|
|
13
|
+
* @returns {Uint8Array}
|
|
14
|
+
*/
|
|
15
|
+
export function sort_keys(locale, texts, ends) {
|
|
16
|
+
const ptr0 = passStringToWasm0(locale, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
17
|
+
const len0 = WASM_VECTOR_LEN;
|
|
18
|
+
const ptr1 = passArray8ToWasm0(texts, wasm.__wbindgen_malloc);
|
|
19
|
+
const len1 = WASM_VECTOR_LEN;
|
|
20
|
+
const ptr2 = passArray32ToWasm0(ends, wasm.__wbindgen_malloc);
|
|
21
|
+
const len2 = WASM_VECTOR_LEN;
|
|
22
|
+
const ret = wasm.sort_keys(ptr0, len0, ptr1, len1, ptr2, len2);
|
|
23
|
+
if (ret[3]) {
|
|
24
|
+
throw takeFromExternrefTable0(ret[2]);
|
|
25
|
+
}
|
|
26
|
+
var v4 = getArrayU8FromWasm0(ret[0], ret[1]).slice();
|
|
27
|
+
wasm.__wbindgen_free(ret[0], ret[1] * 1, 1);
|
|
28
|
+
return v4;
|
|
29
|
+
}
|
|
30
|
+
function __wbg_get_imports() {
|
|
31
|
+
const import0 = {
|
|
32
|
+
__proto__: null,
|
|
33
|
+
__wbg_Error_92b29b0548f8b746: function(arg0, arg1) {
|
|
34
|
+
const ret = Error(getStringFromWasm0(arg0, arg1));
|
|
35
|
+
return ret;
|
|
36
|
+
},
|
|
37
|
+
__wbindgen_init_externref_table: function() {
|
|
38
|
+
const table = wasm.__wbindgen_externrefs;
|
|
39
|
+
const offset = table.grow(4);
|
|
40
|
+
table.set(0, undefined);
|
|
41
|
+
table.set(offset + 0, undefined);
|
|
42
|
+
table.set(offset + 1, null);
|
|
43
|
+
table.set(offset + 2, true);
|
|
44
|
+
table.set(offset + 3, false);
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
return {
|
|
48
|
+
__proto__: null,
|
|
49
|
+
"./opengrid_collation_bg.js": import0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function getArrayU8FromWasm0(ptr, len) {
|
|
54
|
+
ptr = ptr >>> 0;
|
|
55
|
+
return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function getStringFromWasm0(ptr, len) {
|
|
59
|
+
return decodeText(ptr >>> 0, len);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
let cachedUint32ArrayMemory0 = null;
|
|
63
|
+
function getUint32ArrayMemory0() {
|
|
64
|
+
if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
|
|
65
|
+
cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
|
|
66
|
+
}
|
|
67
|
+
return cachedUint32ArrayMemory0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
let cachedUint8ArrayMemory0 = null;
|
|
71
|
+
function getUint8ArrayMemory0() {
|
|
72
|
+
if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
|
|
73
|
+
cachedUint8ArrayMemory0 = new Uint8Array(wasm.memory.buffer);
|
|
74
|
+
}
|
|
75
|
+
return cachedUint8ArrayMemory0;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function passArray32ToWasm0(arg, malloc) {
|
|
79
|
+
const ptr = malloc(arg.length * 4, 4) >>> 0;
|
|
80
|
+
getUint32ArrayMemory0().set(arg, ptr / 4);
|
|
81
|
+
WASM_VECTOR_LEN = arg.length;
|
|
82
|
+
return ptr;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function passArray8ToWasm0(arg, malloc) {
|
|
86
|
+
const ptr = malloc(arg.length * 1, 1) >>> 0;
|
|
87
|
+
getUint8ArrayMemory0().set(arg, ptr / 1);
|
|
88
|
+
WASM_VECTOR_LEN = arg.length;
|
|
89
|
+
return ptr;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function passStringToWasm0(arg, malloc, realloc) {
|
|
93
|
+
if (realloc === undefined) {
|
|
94
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
95
|
+
const ptr = malloc(buf.length, 1) >>> 0;
|
|
96
|
+
getUint8ArrayMemory0().subarray(ptr, ptr + buf.length).set(buf);
|
|
97
|
+
WASM_VECTOR_LEN = buf.length;
|
|
98
|
+
return ptr;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let len = arg.length;
|
|
102
|
+
let ptr = malloc(len, 1) >>> 0;
|
|
103
|
+
|
|
104
|
+
const mem = getUint8ArrayMemory0();
|
|
105
|
+
|
|
106
|
+
let offset = 0;
|
|
107
|
+
|
|
108
|
+
for (; offset < len; offset++) {
|
|
109
|
+
const code = arg.charCodeAt(offset);
|
|
110
|
+
if (code > 0x7F) break;
|
|
111
|
+
mem[ptr + offset] = code;
|
|
112
|
+
}
|
|
113
|
+
if (offset !== len) {
|
|
114
|
+
if (offset !== 0) {
|
|
115
|
+
arg = arg.slice(offset);
|
|
116
|
+
}
|
|
117
|
+
ptr = realloc(ptr, len, len = offset + arg.length * 3, 1) >>> 0;
|
|
118
|
+
const view = getUint8ArrayMemory0().subarray(ptr + offset, ptr + len);
|
|
119
|
+
const ret = cachedTextEncoder.encodeInto(arg, view);
|
|
120
|
+
|
|
121
|
+
offset += ret.written;
|
|
122
|
+
ptr = realloc(ptr, len, offset, 1) >>> 0;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
WASM_VECTOR_LEN = offset;
|
|
126
|
+
return ptr;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function takeFromExternrefTable0(idx) {
|
|
130
|
+
const value = wasm.__wbindgen_externrefs.get(idx);
|
|
131
|
+
wasm.__externref_table_dealloc(idx);
|
|
132
|
+
return value;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
136
|
+
cachedTextDecoder.decode();
|
|
137
|
+
const MAX_SAFARI_DECODE_BYTES = 2146435072;
|
|
138
|
+
let numBytesDecoded = 0;
|
|
139
|
+
function decodeText(ptr, len) {
|
|
140
|
+
numBytesDecoded += len;
|
|
141
|
+
if (numBytesDecoded >= MAX_SAFARI_DECODE_BYTES) {
|
|
142
|
+
cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true });
|
|
143
|
+
cachedTextDecoder.decode();
|
|
144
|
+
numBytesDecoded = len;
|
|
145
|
+
}
|
|
146
|
+
return cachedTextDecoder.decode(getUint8ArrayMemory0().subarray(ptr, ptr + len));
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const cachedTextEncoder = new TextEncoder();
|
|
150
|
+
|
|
151
|
+
if (!('encodeInto' in cachedTextEncoder)) {
|
|
152
|
+
cachedTextEncoder.encodeInto = function (arg, view) {
|
|
153
|
+
const buf = cachedTextEncoder.encode(arg);
|
|
154
|
+
view.set(buf);
|
|
155
|
+
return {
|
|
156
|
+
read: arg.length,
|
|
157
|
+
written: buf.length
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
let WASM_VECTOR_LEN = 0;
|
|
163
|
+
|
|
164
|
+
let wasmModule, wasmInstance, wasm;
|
|
165
|
+
function __wbg_finalize_init(instance, module) {
|
|
166
|
+
wasmInstance = instance;
|
|
167
|
+
wasm = instance.exports;
|
|
168
|
+
wasmModule = module;
|
|
169
|
+
cachedUint32ArrayMemory0 = null;
|
|
170
|
+
cachedUint8ArrayMemory0 = null;
|
|
171
|
+
wasm.__wbindgen_start();
|
|
172
|
+
return wasm;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
async function __wbg_load(module, imports) {
|
|
176
|
+
if (typeof Response === 'function' && module instanceof Response) {
|
|
177
|
+
if (typeof WebAssembly.instantiateStreaming === 'function') {
|
|
178
|
+
try {
|
|
179
|
+
return await WebAssembly.instantiateStreaming(module, imports);
|
|
180
|
+
} catch (e) {
|
|
181
|
+
const validResponse = module.ok && expectedResponseType(module.type);
|
|
182
|
+
|
|
183
|
+
if (validResponse && module.headers.get('Content-Type') !== 'application/wasm') {
|
|
184
|
+
console.warn("`WebAssembly.instantiateStreaming` failed because your server does not serve Wasm with `application/wasm` MIME type. Falling back to `WebAssembly.instantiate` which is slower. Original error:\n", e);
|
|
185
|
+
|
|
186
|
+
} else { throw e; }
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
const bytes = await module.arrayBuffer();
|
|
191
|
+
return await WebAssembly.instantiate(bytes, imports);
|
|
192
|
+
} else {
|
|
193
|
+
const instance = await WebAssembly.instantiate(module, imports);
|
|
194
|
+
|
|
195
|
+
if (instance instanceof WebAssembly.Instance) {
|
|
196
|
+
return { instance, module };
|
|
197
|
+
} else {
|
|
198
|
+
return instance;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
function expectedResponseType(type) {
|
|
203
|
+
switch (type) {
|
|
204
|
+
case 'basic': case 'cors': case 'default': return true;
|
|
205
|
+
}
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function initSync(module) {
|
|
211
|
+
if (wasm !== undefined) return wasm;
|
|
212
|
+
|
|
213
|
+
|
|
214
|
+
if (module !== undefined) {
|
|
215
|
+
if (Object.getPrototypeOf(module) === Object.prototype) {
|
|
216
|
+
({module} = module)
|
|
217
|
+
} else {
|
|
218
|
+
console.warn('using deprecated parameters for `initSync()`; pass a single object instead')
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const imports = __wbg_get_imports();
|
|
223
|
+
if (!(module instanceof WebAssembly.Module)) {
|
|
224
|
+
module = new WebAssembly.Module(module);
|
|
225
|
+
}
|
|
226
|
+
const instance = new WebAssembly.Instance(module, imports);
|
|
227
|
+
return __wbg_finalize_init(instance, module);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
async function __wbg_init(module_or_path) {
|
|
231
|
+
if (wasm !== undefined) return wasm;
|
|
232
|
+
|
|
233
|
+
|
|
234
|
+
if (module_or_path !== undefined) {
|
|
235
|
+
if (Object.getPrototypeOf(module_or_path) === Object.prototype) {
|
|
236
|
+
({module_or_path} = module_or_path)
|
|
237
|
+
} else {
|
|
238
|
+
console.warn('using deprecated parameters for the initialization function; pass a single object instead')
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
if (module_or_path === undefined) {
|
|
243
|
+
module_or_path = new URL('opengrid_collation_bg.wasm', import.meta.url);
|
|
244
|
+
}
|
|
245
|
+
const imports = __wbg_get_imports();
|
|
246
|
+
|
|
247
|
+
if (typeof module_or_path === 'string' || (typeof Request === 'function' && module_or_path instanceof Request) || (typeof URL === 'function' && module_or_path instanceof URL)) {
|
|
248
|
+
module_or_path = fetch(module_or_path);
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
const { instance, module } = await __wbg_load(await module_or_path, imports);
|
|
252
|
+
|
|
253
|
+
return __wbg_finalize_init(instance, module);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export { initSync, __wbg_init as default };
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* tslint:disable */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const sort_keys: (a: number, b: number, c: number, d: number, e: number, f: number) => [number, number, number, number];
|
|
5
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
6
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
7
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
8
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
9
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
10
|
+
export const __wbindgen_start: () => void;
|
package/collation.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The collator of the engine (rule S4a): loaded when a query first sorts by a
|
|
3
|
+
* locale.
|
|
4
|
+
*
|
|
5
|
+
* A sort key may name a locale — `{ "field": "name", "collation": "de" }` — and
|
|
6
|
+
* the engine then needs the collation's tables, some hundred kilobytes it does
|
|
7
|
+
* not carry. They are a module of their own (`collation/`, built by
|
|
8
|
+
* `just wasm-build-collation`); a page that never sorts by a locale does not
|
|
9
|
+
* fetch it. `loader.js` and `worker.js` import **this file lazily**, on the first
|
|
10
|
+
* query that names a locale, so a page that serves the package's files itself and
|
|
11
|
+
* leaves this one out breaks locale sorts only (issue #415).
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/** The engines and planners that have their collator. */
|
|
15
|
+
const given = new WeakSet();
|
|
16
|
+
|
|
17
|
+
/** The collation module, loaded once; a failed load is not kept. */
|
|
18
|
+
let module;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Loads the collation module and gives `engine` its collator. Once per engine;
|
|
22
|
+
* later calls answer at once.
|
|
23
|
+
*
|
|
24
|
+
* @param {{set_collator: Function}} engine an `Engine` or a `Planner`.
|
|
25
|
+
* @returns {Promise<void>}
|
|
26
|
+
*/
|
|
27
|
+
export async function giveCollator(engine) {
|
|
28
|
+
if (given.has(engine)) {
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
module ??= import("./collation/opengrid_collation.js").then(async (glue) => {
|
|
32
|
+
await glue.default();
|
|
33
|
+
return glue;
|
|
34
|
+
});
|
|
35
|
+
let glue;
|
|
36
|
+
try {
|
|
37
|
+
glue = await module;
|
|
38
|
+
} catch (error) {
|
|
39
|
+
module = undefined;
|
|
40
|
+
const failed = new Error(
|
|
41
|
+
`the collation module did not load (${error?.message ?? error})`,
|
|
42
|
+
);
|
|
43
|
+
failed.code = "module_not_loaded";
|
|
44
|
+
throw failed;
|
|
45
|
+
}
|
|
46
|
+
engine.set_collator(glue.sort_keys);
|
|
47
|
+
given.add(engine);
|
|
48
|
+
}
|