@ember-lattice/data 0.0.0-stage → 1.1.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 +48 -0
- package/LICENSE.md +21 -0
- package/NOTICE +30 -0
- package/README.md +75 -2
- package/addon-main.cjs +4 -0
- package/declarations/array-source.d.ts +12 -0
- package/declarations/array-source.d.ts.map +1 -0
- package/declarations/base.d.ts +41 -0
- package/declarations/base.d.ts.map +1 -0
- package/declarations/batch.d.ts +14 -0
- package/declarations/batch.d.ts.map +1 -0
- package/declarations/block-cache.d.ts +37 -0
- package/declarations/block-cache.d.ts.map +1 -0
- package/declarations/block.d.ts +61 -0
- package/declarations/block.d.ts.map +1 -0
- package/declarations/client.d.ts +9 -0
- package/declarations/client.d.ts.map +1 -0
- package/declarations/cursor.d.ts +54 -0
- package/declarations/cursor.d.ts.map +1 -0
- package/declarations/index.d.ts +23 -0
- package/declarations/index.d.ts.map +1 -0
- package/declarations/infinite.d.ts +50 -0
- package/declarations/infinite.d.ts.map +1 -0
- package/declarations/lru.d.ts +23 -0
- package/declarations/lru.d.ts.map +1 -0
- package/declarations/request.d.ts +39 -0
- package/declarations/request.d.ts.map +1 -0
- package/declarations/server.d.ts +100 -0
- package/declarations/server.d.ts.map +1 -0
- package/declarations/types.d.ts +24 -0
- package/declarations/types.d.ts.map +1 -0
- package/declarations/viewport.d.ts +36 -0
- package/declarations/viewport.d.ts.map +1 -0
- package/dist/index.js +1535 -0
- package/dist/index.js.map +1 -0
- package/package.json +88 -3
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# @ember-lattice/data
|
|
2
|
+
|
|
3
|
+
## 1.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f931851: Configure a grid in its template (ADR 0028). `LatticeGrid` takes the rows as `@data` and makes the
|
|
8
|
+
table from the declarations in its block: `g.Column`, `g.ColumnGroup`, `g.SelectionColumn` and
|
|
9
|
+
`g.RowNumberColumn`. A column takes `<:cell>`, `<:header>`, `<:headerEnd>` and `<:editor>` blocks.
|
|
10
|
+
The grid also takes `@features`, `@initialState`, `@state`, `@onStateChange` and `@tableOptions`.
|
|
11
|
+
|
|
12
|
+
- `<:toolbar>`, `<:statusBar>` and `<:sideBar>` get the table and the grid root.
|
|
13
|
+
- `@rowModel` takes a function that makes the model from the table of the grid:
|
|
14
|
+
`ServerRowModel.forGrid({ source })`. The pivot columns of the server row model go after the
|
|
15
|
+
declared columns.
|
|
16
|
+
- `persistGridState` takes the `@stateHost` handle and waits for the table of the grid.
|
|
17
|
+
- The chrome blocks and the `@stateHost` handle give the table as `GridEngineTable`, the engine
|
|
18
|
+
table type. The components of `@ember-lattice/ui` and `persistGridState` take it.
|
|
19
|
+
- `GridRowModel<T>` has the row type, and `forGrid` of each row model keeps the row type of its
|
|
20
|
+
source. The grid gets its row type from `@rowModel`, as it does from `@data`.
|
|
21
|
+
- The grid disconnects a row model that it made from a `@rowModel` function: when the grid goes,
|
|
22
|
+
or when a new function replaces the model.
|
|
23
|
+
- `g.SelectionColumn` and `g.RowNumberColumn` take `@pinned` and `@hidden`.
|
|
24
|
+
- The editing args (`@editor`, `@editable`, `@schema`, `@parse`, `@options`) and the filter arg
|
|
25
|
+
(`@filter`) are args of `g.Column`.
|
|
26
|
+
|
|
27
|
+
`@table` and `constructTable` stay. Nothing is removed or deprecated.
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- @ember-lattice/core@1.1.0
|
|
32
|
+
- @ember-lattice/protocol@1.1.0
|
|
33
|
+
|
|
34
|
+
## 1.0.0
|
|
35
|
+
|
|
36
|
+
### Major Changes
|
|
37
|
+
|
|
38
|
+
- 7ce4af2: Lattice 1.0: one grid for every collection in Ember. Lists, feeds, tables, boards and
|
|
39
|
+
spreadsheets come from one headless engine, a port of TanStack Table. It has 80 of the 81
|
|
40
|
+
AG Grid features in the parity matrix; the external filter runs after grouping. The release has the client row models, the Lattice wire protocol with servers for Node,
|
|
41
|
+
Rails and Python, an IronCalc spreadsheet with live collaboration, themes, test harnesses, Jig
|
|
42
|
+
stories and Marquetry catalog entries.
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies [7ce4af2]
|
|
47
|
+
- @ember-lattice/core@1.0.0
|
|
48
|
+
- @ember-lattice/protocol@1.0.0
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Joe Gaudet
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/NOTICE
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Lattice
|
|
2
|
+
Copyright (c) 2026 Joe Gaudet. MIT licensed; see LICENSE.md.
|
|
3
|
+
|
|
4
|
+
Lattice ports code from two MIT-licensed TanStack projects into Ember-native code. Lattice does
|
|
5
|
+
not depend on either package. PORT_MAP.md names each ported file and its source.
|
|
6
|
+
|
|
7
|
+
TanStack Table (@tanstack/table-core 9.3.1)
|
|
8
|
+
https://github.com/TanStack/table
|
|
9
|
+
Copyright (c) 2016 Tanner Linsley
|
|
10
|
+
|
|
11
|
+
TanStack Virtual (@tanstack/virtual-core 3.19.16)
|
|
12
|
+
https://github.com/TanStack/virtual
|
|
13
|
+
Copyright (c) 2021-present Tanner Linsley
|
|
14
|
+
|
|
15
|
+
Both are licensed under the MIT License:
|
|
16
|
+
|
|
17
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
|
|
18
|
+
and associated documentation files (the "Software"), to deal in the Software without
|
|
19
|
+
restriction, including without limitation the rights to use, copy, modify, merge, publish,
|
|
20
|
+
distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
|
|
21
|
+
Software is furnished to do so, subject to the following conditions:
|
|
22
|
+
|
|
23
|
+
The above copyright notice and this permission notice shall be included in all copies or
|
|
24
|
+
substantial portions of the Software.
|
|
25
|
+
|
|
26
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
|
|
27
|
+
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
28
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|
29
|
+
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
30
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,76 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @ember-lattice/data
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Row models for Lattice: client, infinite, cursor, server and viewport, over one `DataSource`
|
|
4
|
+
interface, with block caches, transactions and live updates. The design is in
|
|
5
|
+
[ADR 0010](https://joegaudet.com/ember-lattice/docs/adr/0010-row-models/index.html).
|
|
6
|
+
|
|
7
|
+
Part of [Lattice](https://joegaudet.com/ember-lattice/). Not released yet.
|
|
8
|
+
|
|
9
|
+
## A row model on the grid
|
|
10
|
+
|
|
11
|
+
Give the grid a function that makes the model from its table (ADR 0028). The grid declares the
|
|
12
|
+
columns, puts its table in manual mode, and the server sorts, filters and groups the rows:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
import { InfiniteRowModel } from '@ember-lattice/data'
|
|
16
|
+
import { fetchDataSource } from '@ember-lattice/data-fetch'
|
|
17
|
+
|
|
18
|
+
const source = fetchDataSource({ url: '/people/rows', getRowId: row => String(row.id) })
|
|
19
|
+
const rows = InfiniteRowModel.forGrid({ source, blockSize: 100, maxBlocks: 10 })
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```hbs
|
|
23
|
+
<LatticeGrid @rowModel={{this.rows}} @features={{this.features}} @label='People' as |g|>
|
|
24
|
+
<g.Column @id='name' @label='Name' @sortable={{true}} />
|
|
25
|
+
<g.Column @id='team' @label='Team' />
|
|
26
|
+
</LatticeGrid>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
In the engine form, make the table with `constructTable` in manual mode (`manualSorting`,
|
|
30
|
+
`manualFiltering`, `manualGrouping`), then `new InfiniteRowModel({ source, table })`, and give
|
|
31
|
+
the grid `@table` and `@rowModel`. The pivot columns of `ServerRowModel` go after the columns of
|
|
32
|
+
the table in both forms.
|
|
33
|
+
|
|
34
|
+
## Row models
|
|
35
|
+
|
|
36
|
+
| Model | Use it for |
|
|
37
|
+
| ------------------ | --------------------------------------------------------------------------- |
|
|
38
|
+
| `loadAllRows` | Small sets. It loads all rows; give them to `@data` of the grid. |
|
|
39
|
+
| `InfiniteRowModel` | Big flat sets. Offset blocks, an LRU block cache, and abort on fast scroll. |
|
|
40
|
+
| `CursorRowModel` | Lists and deep scroll. Keyset blocks in two directions from an anchor. |
|
|
41
|
+
| `ServerRowModel` | Server groups, aggregates and pivot. Group rows expand lazily. |
|
|
42
|
+
| `ViewportRowModel` | Live data at a high rate. Only the rows in view, with pushed changes. |
|
|
43
|
+
|
|
44
|
+
Each model has `refresh({ purge })`, `retryFailed()`, `applyTransaction(tx)` and
|
|
45
|
+
`applyTransactionAsync(tx)`. The async form applies all the transactions of one frame in one
|
|
46
|
+
update. `disconnect()` stops the live updates of a viewport model. A grid calls it on a model
|
|
47
|
+
that it made with `forGrid`.
|
|
48
|
+
|
|
49
|
+
## Column filters
|
|
50
|
+
|
|
51
|
+
A column filter value becomes one filter leaf:
|
|
52
|
+
|
|
53
|
+
- A string is `contains`.
|
|
54
|
+
- A number or a boolean is `eq`.
|
|
55
|
+
- An array is `in`.
|
|
56
|
+
- `{ op, value }` is that op, for example `{ op: 'between', value: [1, 9] }`.
|
|
57
|
+
|
|
58
|
+
## A data source
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
interface DataSource<Row> {
|
|
62
|
+
capabilities: DataSourceCapabilities
|
|
63
|
+
getRows(request: RowsRequest, signal: AbortSignal): Promise<RowsResponse<Row>>
|
|
64
|
+
subscribe?(onChange: (tx: Transaction<Row>) => void): () => void
|
|
65
|
+
mutate?(ops: RowOp<Row>[]): Promise<MutateResult<Row>>
|
|
66
|
+
getRowId(row: Row): string
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`arrayDataSource(rows, allowList)` is a source over rows in memory, for tests and demos. Its
|
|
71
|
+
`push(tx)` sends a transaction to the subscribers, as a server does.
|
|
72
|
+
|
|
73
|
+
## Block states
|
|
74
|
+
|
|
75
|
+
A Switchyard machine runs each block: `idle`, `loading`, `loaded`, `stale`, `reloading` and
|
|
76
|
+
`failed`. Only the load path uses the machine. Scroll and render read tracked fields.
|
package/addon-main.cjs
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type AllowList, type Transaction } from '@ember-lattice/protocol';
|
|
2
|
+
import type { DataSource } from './types.ts';
|
|
3
|
+
/** A new row list with the transaction applied: remove, then update in place, then add. */
|
|
4
|
+
export declare function applyTransaction<Row>(rows: readonly Row[], tx: Transaction<Row>, getRowId: (row: Row) => string): Row[];
|
|
5
|
+
export interface ArrayDataSource<Row> extends DataSource<Row> {
|
|
6
|
+
/** The current rows. */
|
|
7
|
+
readonly rows: readonly Row[];
|
|
8
|
+
/** Apply a transaction and send it to the subscribers, as a server push does. */
|
|
9
|
+
push(tx: Transaction<Row>): void;
|
|
10
|
+
}
|
|
11
|
+
export declare function arrayDataSource<Row extends object>(initial: readonly Row[], allowList: AllowList): ArrayDataSource<Row>;
|
|
12
|
+
//# sourceMappingURL=array-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"array-source.d.ts","sourceRoot":"","sources":["../src/array-source.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,KAAK,SAAS,EAKd,KAAK,WAAW,EACjB,MAAM,yBAAyB,CAAA;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,2FAA2F;AAC3F,wBAAgB,gBAAgB,CAAC,GAAG,EAClC,IAAI,EAAE,SAAS,GAAG,EAAE,EACpB,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,EACpB,QAAQ,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAC7B,GAAG,EAAE,CASP;AAED,MAAM,WAAW,eAAe,CAAC,GAAG,CAAE,SAAQ,UAAU,CAAC,GAAG,CAAC;IAC3D,wBAAwB;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAA;IAC7B,iFAAiF;IACjF,IAAI,CAAC,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;CACjC;AAID,wBAAgB,eAAe,CAAC,GAAG,SAAS,MAAM,EAChD,OAAO,EAAE,SAAS,GAAG,EAAE,EACvB,SAAS,EAAE,SAAS,GACnB,eAAe,CAAC,GAAG,CAAC,CAyEtB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Row as EngineRow, Table, TableFeatures, Table_Internal } from '@ember-lattice/core';
|
|
2
|
+
import type { Transaction } from '@ember-lattice/protocol';
|
|
3
|
+
import type { QueryState } from './request.ts';
|
|
4
|
+
import type { DataSource } from './types.ts';
|
|
5
|
+
export interface RowModelOptions<TFeatures extends TableFeatures, Row extends object> {
|
|
6
|
+
source: DataSource<Row>;
|
|
7
|
+
/** The table. Give it `manualSorting`, `manualFiltering`, `manualGrouping` and `manualPagination`. */
|
|
8
|
+
table: Table<TFeatures, Row>;
|
|
9
|
+
}
|
|
10
|
+
export declare abstract class BaseRowModel<TFeatures extends TableFeatures, Row extends object> {
|
|
11
|
+
/** The number of requests in flight. */
|
|
12
|
+
pending: number;
|
|
13
|
+
readonly source: DataSource<Row>;
|
|
14
|
+
protected table: Table_Internal<TFeatures, Row>;
|
|
15
|
+
protected range: [number, number];
|
|
16
|
+
private rows;
|
|
17
|
+
private scheduled;
|
|
18
|
+
private batcher;
|
|
19
|
+
constructor(options: RowModelOptions<TFeatures, Row>);
|
|
20
|
+
/** True when no request is in flight. */
|
|
21
|
+
get idle(): boolean;
|
|
22
|
+
/** The engine state that changes the rows of the server. */
|
|
23
|
+
get query(): QueryState;
|
|
24
|
+
/** A string that changes when the query changes. The grid passes it to its range modifier. */
|
|
25
|
+
get queryKey(): string;
|
|
26
|
+
protected onPending: (delta: number) => void;
|
|
27
|
+
/** The engine row of a data row: the table's columns read its values. */
|
|
28
|
+
protected engineRow(original: Row, index: number, depth?: number): EngineRow<TFeatures, Row>;
|
|
29
|
+
protected rowId(original: Row): string;
|
|
30
|
+
/**
|
|
31
|
+
* The grid calls this after each render with the rows in view (`end` is exclusive). The
|
|
32
|
+
* work runs in a microtask: never during render, and once for many calls.
|
|
33
|
+
*/
|
|
34
|
+
setRange(start: number, end: number): void;
|
|
35
|
+
protected schedule(): void;
|
|
36
|
+
protected abstract flush(): void;
|
|
37
|
+
abstract applyTransaction(tx: Transaction<Row>): void;
|
|
38
|
+
/** Apply the transaction with the other transactions of this frame, in one update. */
|
|
39
|
+
applyTransactionAsync(tx: Transaction<Row>): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,GAAG,IAAI,SAAS,EAAE,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACjG,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AAE1D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,eAAe,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,MAAM;IAClF,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;IACvB,sGAAsG;IACtG,KAAK,EAAE,KAAK,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;CAC7B;AAED,8BAAsB,YAAY,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,MAAM;IACpF,wCAAwC;IAC/B,OAAO,SAAI;IACpB,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;IAChC,SAAS,CAAC,KAAK,EAAE,cAAc,CAAC,SAAS,EAAE,GAAG,CAAC,CAAA;IAC/C,SAAS,CAAC,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAS;IAC1C,OAAO,CAAC,IAAI,CAAgD;IAC5D,OAAO,CAAC,SAAS,CAAQ;IACzB,OAAO,CAAC,OAAO,CAEb;gBAEU,OAAO,EAAE,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC;IAMpD,yCAAyC;IACzC,IAAI,IAAI,YAEP;IAED,4DAA4D;IAC5D,IAAI,KAAK,IAAI,UAAU,CAQtB;IAED,8FAA8F;IAC9F,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,SAAS,CAAC,SAAS,GAAI,OAAO,MAAM,UAEnC;IAED,yEAAyE;IACzE,SAAS,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,SAAI,GAAG,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC;IASvF,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,GAAG,MAAM;IAItC;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM;IAKnC,SAAS,CAAC,QAAQ;IASlB,SAAS,CAAC,QAAQ,CAAC,KAAK,IAAI,IAAI;IAEhC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,IAAI;IAErD,sFAAsF;IACtF,qBAAqB,CAAC,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Call `callback` on the next animation frame, or on the next task where no frame exists. */
|
|
2
|
+
export declare const nextFrame: (callback: () => void) => void;
|
|
3
|
+
/** Collects the items of one frame and applies them in one call (`applyTransactionAsync`). */
|
|
4
|
+
export declare class TransactionBatcher<T> {
|
|
5
|
+
private queue;
|
|
6
|
+
private waiting;
|
|
7
|
+
private apply;
|
|
8
|
+
private schedule;
|
|
9
|
+
constructor(apply: (items: T[]) => void, schedule?: (callback: () => void) => void);
|
|
10
|
+
/** Resolves when the frame applied the item. */
|
|
11
|
+
add(item: T): Promise<void>;
|
|
12
|
+
flush: () => void;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=batch.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../src/batch.ts"],"names":[],"mappings":"AAEA,8FAA8F;AAC9F,eAAO,MAAM,SAAS,GAAI,UAAU,MAAM,IAAI,SAG7C,CAAA;AAED,8FAA8F;AAC9F,qBAAa,kBAAkB,CAAC,CAAC;IAC/B,OAAO,CAAC,KAAK,CAAU;IACvB,OAAO,CAAC,OAAO,CAAwB;IAEvC,OAAO,CAAC,KAAK,CAAsB;IACnC,OAAO,CAAC,QAAQ,CAAgC;gBAEpC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,EAAE,KAAK,IAAI,EAAE,QAAQ,GAAE,CAAC,QAAQ,EAAE,MAAM,IAAI,KAAK,IAAgB;IAK7F,gDAAgD;IAChD,GAAG,CAAC,IAAI,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAM3B,KAAK,aAOJ;CACF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type RowsRequest, type RowsResponse } from '@ember-lattice/protocol';
|
|
2
|
+
import { Block } from './block.ts';
|
|
3
|
+
import { LruMap } from './lru.ts';
|
|
4
|
+
export interface BlockCacheOptions<Row> {
|
|
5
|
+
blockSize: number;
|
|
6
|
+
maxBlocks: number;
|
|
7
|
+
/** Make the request of a block. */
|
|
8
|
+
request(block: Block<Row>): RowsRequest;
|
|
9
|
+
fetch(request: RowsRequest, signal: AbortSignal): Promise<RowsResponse<Row>>;
|
|
10
|
+
/** Called after each block loads. */
|
|
11
|
+
onLoad?(block: Block<Row>, response: RowsResponse<Row>): void;
|
|
12
|
+
/** Called when a load starts or ends, for the pending count. */
|
|
13
|
+
onPending?(delta: number): void;
|
|
14
|
+
}
|
|
15
|
+
export declare function checkBlockOptions(blockSize: number, maxBlocks: number): void;
|
|
16
|
+
export declare class BlockCache<Row> {
|
|
17
|
+
readonly blocks: LruMap<number, Block<Row>>;
|
|
18
|
+
private options;
|
|
19
|
+
constructor(options: BlockCacheOptions<Row>);
|
|
20
|
+
get blockSize(): number;
|
|
21
|
+
/** The block of a row, if the cache has it. It does not change the use order (render path). */
|
|
22
|
+
blockOf(index: number): Block<Row> | undefined;
|
|
23
|
+
rowAt(index: number): Row | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Make the rows `start` to `end` (exclusive) loaded: load the missing blocks, abort the
|
|
26
|
+
* blocks in flight outside the range, and evict the oldest blocks above `maxBlocks`.
|
|
27
|
+
*/
|
|
28
|
+
ensure(start: number, end: number): void;
|
|
29
|
+
load(block: Block<Row>): void;
|
|
30
|
+
/** Mark every loaded block stale. With `purge`, drop them all. */
|
|
31
|
+
refresh(purge: boolean): void;
|
|
32
|
+
/** Load the failed blocks again. */
|
|
33
|
+
retryFailed(): void;
|
|
34
|
+
/** Update the rows with these ids in place. Returns the ids it found. */
|
|
35
|
+
update(rows: readonly Row[], getRowId: (row: Row) => string): Set<string>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=block-cache.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block-cache.d.ts","sourceRoot":"","sources":["../src/block-cache.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACrF,OAAO,EAAE,KAAK,EAAc,MAAM,YAAY,CAAA;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,WAAW,iBAAiB,CAAC,GAAG;IACpC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;IACjB,mCAAmC;IACnC,OAAO,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,CAAC,GAAG,WA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/core';
|
|
2
|
+
import type { RowsResponse } from '@ember-lattice/protocol';
|
|
3
|
+
export declare class BlockState extends State {
|
|
4
|
+
private readonly brand;
|
|
5
|
+
static Idle: BlockState & {
|
|
6
|
+
readonly value: "idle";
|
|
7
|
+
};
|
|
8
|
+
static Loading: BlockState & {
|
|
9
|
+
readonly value: "loading";
|
|
10
|
+
};
|
|
11
|
+
static Loaded: BlockState & {
|
|
12
|
+
readonly value: "loaded";
|
|
13
|
+
};
|
|
14
|
+
static Stale: BlockState & {
|
|
15
|
+
readonly value: "stale";
|
|
16
|
+
};
|
|
17
|
+
static Reloading: BlockState & {
|
|
18
|
+
readonly value: "reloading";
|
|
19
|
+
};
|
|
20
|
+
static Failed: BlockState & {
|
|
21
|
+
readonly value: "failed";
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
export declare class BlockMachine extends Machine<BlockState> {
|
|
25
|
+
static strict: boolean;
|
|
26
|
+
load(): void;
|
|
27
|
+
resolve(): void;
|
|
28
|
+
fail(): void;
|
|
29
|
+
invalidate(): void;
|
|
30
|
+
reload(): void;
|
|
31
|
+
retry(): void;
|
|
32
|
+
/** An aborted load. A block with rows keeps them and stays stale. */
|
|
33
|
+
cancel(): void;
|
|
34
|
+
cancelReload(): void;
|
|
35
|
+
}
|
|
36
|
+
/** The states in which a block has a request in flight. */
|
|
37
|
+
export declare const isBusy: (state: BlockState) => boolean;
|
|
38
|
+
export declare class Block<Row> {
|
|
39
|
+
/** The mirror of the machine state, for render. */
|
|
40
|
+
state: BlockState;
|
|
41
|
+
rows: readonly Row[];
|
|
42
|
+
error: unknown;
|
|
43
|
+
response: RowsResponse<Row> | null;
|
|
44
|
+
readonly machine: BlockMachine;
|
|
45
|
+
private controller;
|
|
46
|
+
readonly index: number;
|
|
47
|
+
/** The first row of the block in its level. */
|
|
48
|
+
readonly start: number;
|
|
49
|
+
constructor(index: number, start: number);
|
|
50
|
+
get busy(): boolean;
|
|
51
|
+
/** Start a load (from idle, stale or failed) and give its signal. Null: no load to start. */
|
|
52
|
+
begin(): AbortSignal | null;
|
|
53
|
+
finish(response: RowsResponse<Row>): void;
|
|
54
|
+
failWith(error: unknown): void;
|
|
55
|
+
/** Abort the request in flight. */
|
|
56
|
+
abort(): void;
|
|
57
|
+
invalidate(): void;
|
|
58
|
+
/** Replace the rows in place (a live update). */
|
|
59
|
+
replaceRows(rows: readonly Row[]): void;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=block.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../src/block.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAc,MAAM,qBAAqB,CAAA;AAChE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAE3D,qBAAa,UAAW,SAAQ,KAAK;IACnC,iBAAyB,KAAK,CAAO;IACrC,MAAM,CAAC,IAAI;;MAAwB;IACnC,MAAM,CAAC,OAAO;;MAA2B;IACzC,MAAM,CAAC,MAAM;;MAA0B;IACvC,MAAM,CAAC,KAAK;;MAAyB;IACrC,MAAM,CAAC,SAAS;;MAA6B;IAC7C,MAAM,CAAC,MAAM;;MAA0B;CACxC;AAED,qBAAa,YAAa,SAAQ,OAAO,CAAC,UAAU,CAAC;IACnD,OAAgB,MAAM,UAAO;IAG7B,IAAI;IAGJ,OAAO;IAGP,IAAI;IAGJ,UAAU;IAGV,MAAM;IAGN,KAAK;IAEL,qEAAqE;IAErE,MAAM;IAGN,YAAY;CACb;AAED,2DAA2D;AAC3D,eAAO,MAAM,MAAM,GAAI,OAAO,UAAU,YACwB,CAAA;AAEhE,qBAAa,KAAK,CAAC,GAAG;IACpB,mDAAmD;IAC1C,KAAK,EAAE,UAAU,CAAkB;IACnC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAK;IAClC,KAAK,EAAE,OAAO,CAAO;IACrB,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,GAAG,IAAI,CAAO;IACzC,QAAQ,CAAC,OAAO,eAAqB;IACrC,OAAO,CAAC,UAAU,CAA+B;IAEjD,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;gBAEV,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;IAQxC,IAAI,IAAI,YAEP;IAED,6FAA6F;IAC7F,KAAK,IAAI,WAAW,GAAG,IAAI;IAU3B,MAAM,CAAC,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC;IAQlC,QAAQ,CAAC,KAAK,EAAE,OAAO;IAMvB,mCAAmC;IACnC,KAAK;IAOL,UAAU;IAIV,iDAAiD;IACjD,WAAW,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE;CAGjC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DataSource } from './types.ts';
|
|
2
|
+
export interface LoadAllOptions {
|
|
3
|
+
/** Rows in one request. Default and maximum: the protocol page limit. */
|
|
4
|
+
pageSize?: number;
|
|
5
|
+
signal?: AbortSignal;
|
|
6
|
+
}
|
|
7
|
+
/** Ask for pages until a page is short. The rows come in the order of the key column. */
|
|
8
|
+
export declare function loadAllRows<Row>(source: DataSource<Row>, { pageSize, signal }?: LoadAllOptions): Promise<Row[]>;
|
|
9
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE5C,MAAM,WAAW,cAAc;IAC7B,yEAAyE;IACzE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAED,yFAAyF;AACzF,wBAAsB,WAAW,CAAC,GAAG,EACnC,MAAM,EAAE,UAAU,CAAC,GAAG,CAAC,EACvB,EAAE,QAAyB,EAAE,MAAqC,EAAE,GAAE,cAAmB,GACxF,OAAO,CAAC,GAAG,EAAE,CAAC,CAkBhB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { TableFeatures } from '@ember-lattice/core';
|
|
2
|
+
import type { Transaction } from '@ember-lattice/protocol';
|
|
3
|
+
import { BaseRowModel, type RowModelOptions } from './base.ts';
|
|
4
|
+
export interface CursorRowModelOptions<TFeatures extends TableFeatures, Row extends object> extends RowModelOptions<TFeatures, Row> {
|
|
5
|
+
/** Rows in one block. Default 100. */
|
|
6
|
+
blockSize?: number;
|
|
7
|
+
/** Checked like the other models, but not used yet: see the shortcut in the class. */
|
|
8
|
+
maxBlocks?: number;
|
|
9
|
+
/** The anchor: the first block loads after (or before) this cursor. Default: the start. */
|
|
10
|
+
start?: {
|
|
11
|
+
after?: string;
|
|
12
|
+
before?: string;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export declare class CursorRowModel<TFeatures extends TableFeatures, Row extends object> extends BaseRowModel<TFeatures, Row> {
|
|
16
|
+
readonly blockSize: number;
|
|
17
|
+
private start;
|
|
18
|
+
/** The loaded blocks, in row order. */
|
|
19
|
+
private blocks;
|
|
20
|
+
/** The block that loads (or failed) at each end. */
|
|
21
|
+
private edge;
|
|
22
|
+
private more;
|
|
23
|
+
/** The number of rows added before the first row. A list keeps its scroll anchor with it. */
|
|
24
|
+
prepended: number;
|
|
25
|
+
private cursors;
|
|
26
|
+
private key;
|
|
27
|
+
private nextIndex;
|
|
28
|
+
/**
|
|
29
|
+
* A function that makes the model from a table, for `@rowModel` of a grid in the template form:
|
|
30
|
+
* the grid makes the table from its declarations, then calls the function (ADR 0028). The grid
|
|
31
|
+
* gives that table the `manual*` options. Give it the features of the query in `@features`.
|
|
32
|
+
* The model has the row type of `source`, so the grid has it too.
|
|
33
|
+
*/
|
|
34
|
+
static forGrid<TFeatures extends TableFeatures, Row extends object>(options: Omit<CursorRowModelOptions<TFeatures, Row>, 'table'>): (table: object) => CursorRowModel<TFeatures, Row>;
|
|
35
|
+
constructor(options: CursorRowModelOptions<TFeatures, Row>);
|
|
36
|
+
private get loadedCount();
|
|
37
|
+
get rowCount(): number | null;
|
|
38
|
+
/** The loaded rows and one skeleton row at the end while more rows can come. */
|
|
39
|
+
get displayCount(): number;
|
|
40
|
+
rowAt(index: number): import("@ember-lattice/core").Row<TFeatures, Row> | undefined;
|
|
41
|
+
failedAt(index: number): boolean;
|
|
42
|
+
protected flush(): void;
|
|
43
|
+
private load;
|
|
44
|
+
private reset;
|
|
45
|
+
/** Cursor blocks depend on each other, so a refresh always purges and starts at the anchor. */
|
|
46
|
+
refresh(): void;
|
|
47
|
+
retryFailed(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Updates change rows in place. A remove drops the row. An add goes at the end (or, with
|
|
50
|
+
* `addIndex: 0`, at the start) only when that end is loaded; else the paging brings it.
|
|
51
|
+
*/
|
|
52
|
+
applyTransaction(tx: Transaction<Row>): void;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=cursor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cursor.d.ts","sourceRoot":"","sources":["../src/cursor.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACvE,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAK9D,MAAM,WAAW,qBAAqB,CACpC,SAAS,SAAS,aAAa,EAC/B,GAAG,SAAS,MAAM,CAClB,SAAQ,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC;IACvC,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,sFAAsF;IACtF,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,2FAA2F;IAC3F,KAAK,CAAC,EAAE;QAAE,KAAK,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AsBtC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type { DataSource, DataSourceCapabilities } from './types.ts';
|
|
2
|
+
export { arrayDataSource, applyTransaction } from './array-source.ts';
|
|
3
|
+
export type { ArrayDataSource } from './array-source.ts';
|
|
4
|
+
export { toRowsRequest, columnFilterNode } from './request.ts';
|
|
5
|
+
export type { QueryState, RequestOptions } from './request.ts';
|
|
6
|
+
export { LruMap } from './lru.ts';
|
|
7
|
+
export { TransactionBatcher } from './batch.ts';
|
|
8
|
+
export { Block, BlockMachine, BlockState } from './block.ts';
|
|
9
|
+
export { BlockCache } from './block-cache.ts';
|
|
10
|
+
export type { BlockCacheOptions } from './block-cache.ts';
|
|
11
|
+
export { BaseRowModel } from './base.ts';
|
|
12
|
+
export type { RowModelOptions } from './base.ts';
|
|
13
|
+
export { InfiniteRowModel } from './infinite.ts';
|
|
14
|
+
export type { InfiniteRowModelOptions } from './infinite.ts';
|
|
15
|
+
export { ServerRowModel } from './server.ts';
|
|
16
|
+
export type { ServerRowModelOptions } from './server.ts';
|
|
17
|
+
export { ViewportRowModel } from './viewport.ts';
|
|
18
|
+
export type { ViewportRowModelOptions } from './viewport.ts';
|
|
19
|
+
export { loadAllRows } from './client.ts';
|
|
20
|
+
export type { LoadAllOptions } from './client.ts';
|
|
21
|
+
export { CursorRowModel } from './cursor.ts';
|
|
22
|
+
export type { CursorRowModelOptions } from './cursor.ts';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,UAAU,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAA;AACpE,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAA;AACrE,YAAY,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACxD,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC9D,YAAY,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC9D,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAC7C,YAAY,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AACxC,YAAY,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAA;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AACzC,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5C,YAAY,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { TableFeatures } from '@ember-lattice/core';
|
|
2
|
+
import type { Aggregate, Transaction } from '@ember-lattice/protocol';
|
|
3
|
+
import { BaseRowModel, type RowModelOptions } from './base.ts';
|
|
4
|
+
import { BlockState } from './block.ts';
|
|
5
|
+
import { BlockCache } from './block-cache.ts';
|
|
6
|
+
export interface InfiniteRowModelOptions<TFeatures extends TableFeatures, Row extends object> extends RowModelOptions<TFeatures, Row> {
|
|
7
|
+
/** Rows in one block. Default 100. */
|
|
8
|
+
blockSize?: number;
|
|
9
|
+
/** Blocks in the cache. Default 10. */
|
|
10
|
+
maxBlocks?: number;
|
|
11
|
+
aggregate?: ReadonlyArray<Omit<Aggregate, 'as'>>;
|
|
12
|
+
}
|
|
13
|
+
export declare class InfiniteRowModel<TFeatures extends TableFeatures, Row extends object> extends BaseRowModel<TFeatures, Row> {
|
|
14
|
+
readonly blockSize: number;
|
|
15
|
+
readonly cache: BlockCache<Row>;
|
|
16
|
+
/** The total from the server, or null when it is not known. */
|
|
17
|
+
private count;
|
|
18
|
+
/** The rows known to exist, when the count is not known. */
|
|
19
|
+
private seen;
|
|
20
|
+
private key;
|
|
21
|
+
/**
|
|
22
|
+
* A function that makes the model from a table, for `@rowModel` of a grid in the template form:
|
|
23
|
+
* the grid makes the table from its declarations, then calls the function (ADR 0028). The grid
|
|
24
|
+
* gives that table the `manual*` options. Give it the features of the query in `@features`.
|
|
25
|
+
* The model has the row type of `source`, so the grid has it too.
|
|
26
|
+
*/
|
|
27
|
+
static forGrid<TFeatures extends TableFeatures, Row extends object>(options: Omit<InfiniteRowModelOptions<TFeatures, Row>, 'table'>): (table: object) => InfiniteRowModel<TFeatures, Row>;
|
|
28
|
+
constructor(options: InfiniteRowModelOptions<TFeatures, Row>);
|
|
29
|
+
get rowCount(): number | null;
|
|
30
|
+
/** The rows the grid shows: all rows, or the known rows and one block of skeleton rows. */
|
|
31
|
+
get displayCount(): number;
|
|
32
|
+
rowAt(index: number): import("@ember-lattice/core").Row<TFeatures, Row> | undefined;
|
|
33
|
+
/** The state of the block of a row, or undefined when the cache has no block for it. */
|
|
34
|
+
stateAt(index: number): BlockState | undefined;
|
|
35
|
+
failedAt(index: number): boolean;
|
|
36
|
+
private onLoad;
|
|
37
|
+
protected flush(): void;
|
|
38
|
+
private reset;
|
|
39
|
+
/** Load the rows again. Without `purge` the old rows stay on screen until the new rows come. */
|
|
40
|
+
refresh({ purge }?: {
|
|
41
|
+
purge?: boolean;
|
|
42
|
+
}): void;
|
|
43
|
+
retryFailed(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Updates change the loaded rows in place. Adds and removes move rows between blocks, so
|
|
46
|
+
* they make the blocks stale: the blocks load again and keep their rows until then.
|
|
47
|
+
*/
|
|
48
|
+
applyTransaction(tx: Transaction<Row>): void;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=infinite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"infinite.d.ts","sourceRoot":"","sources":["../src/infinite.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,KAAK,eAAe,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,UAAU,EAAc,MAAM,YAAY,CAAA;AACnD,OAAO,EAAE,UAAU,EAAqB,MAAM,kBAAkB,CAAA;AAGhE,MAAM,WAAW,uBAAuB,CACtC,SAAS,SAAS,aAAa,EAC/B,GAAG,SAAS,MAAM,CAClB,SAAQ,eAAe,CAAC,SAAS,EAAE,GAAG,CAAC;IACvC,sCAAsC;IACtC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,SAAS,CAAC,EAAE,aAAa,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC,CAAA;CACjD;AAED,qBAAa,gBAAgB,CAC3B,SAAS,SAAS,aAAa,EAC/B,GAAG,SAAS,MAAM,CAClB,SAAQ,YAAY,CAAC,SAAS,EAAE,GAAG,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC,GAAG,CAAC,CAAA;IAC/B,+DAA+D;IACtD,OAAO,CAAC,KAAK,CAAsB;IAC5C,4DAA4D;IACnD,OAAO,CAAC,IAAI,CAAI;IACzB,OAAO,CAAC,GAAG,CAAsB;IAEjC;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,SAAS,SAAS,aAAa,EAAE,GAAG,SAAS,MAAM,EAChE,OAAO,EAAE,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,GAAG,CAAC,EAAE,OAAO,CAAC,GAC9D,CAAC,KAAK,EAAE,MAAM,KAAK,gBAAgB,CAAC,SAAS,EAAE,GAAG,CAAC;gBAI1C,OAAO,EAAE,uBAAuB,CAAC,SAAS,EAAE,GAAG,CAAC;IAqB5D,IAAI,QAAQ,IAAI,MAAM,GAAG,IAAI,CAE5B;IAED,2FAA2F;IAC3F,IAAI,YAAY,IAAI,MAAM,CAEzB;IAED,KAAK,CAAC,KAAK,EAAE,MAAM;IAKnB,wFAAwF;IACxF,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS;IAI9C,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO;IAIhC,OAAO,CAAC,MAAM;IAMd,SAAS,CAAC,KAAK;IAUf,OAAO,CAAC,KAAK;IAMb,gGAAgG;IAChG,OAAO,CAAC,EAAE,KAAa,EAAE,GAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAO;IAMnD,WAAW;IAIX;;;OAGG;IACH,gBAAgB,CAAC,EAAE,EAAE,WAAW,CAAC,GAAG,CAAC;CAItC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A map that keeps its entries in use order. `evict` removes the oldest entries above the limit;
|
|
3
|
+
* the caller calls it after it marks the keys in use.
|
|
4
|
+
*/
|
|
5
|
+
export declare class LruMap<K, V> {
|
|
6
|
+
private map;
|
|
7
|
+
readonly max: number;
|
|
8
|
+
private onEvict;
|
|
9
|
+
constructor(max: number, onEvict?: (key: K, value: V) => void);
|
|
10
|
+
get size(): number;
|
|
11
|
+
get(key: K): V | undefined;
|
|
12
|
+
has(key: K): boolean;
|
|
13
|
+
keys(): MapIterator<K>;
|
|
14
|
+
values(): MapIterator<V>;
|
|
15
|
+
/** Make the entry the most recently used. */
|
|
16
|
+
touch(key: K): void;
|
|
17
|
+
set(key: K, value: V): void;
|
|
18
|
+
delete(key: K): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
/** Evict the oldest entries above the limit. Pinned keys stay, also above the limit. */
|
|
21
|
+
evict(pinned?: ReadonlySet<K>): void;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=lru.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru.d.ts","sourceRoot":"","sources":["../src/lru.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,MAAM,CAAC,CAAC,EAAE,CAAC;IACtB,OAAO,CAAC,GAAG,CAAkB;IAE7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,OAAO,CAAC,OAAO,CAA0C;gBAE7C,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,IAAI;IAK7D,IAAI,IAAI,WAEP;IAED,GAAG,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,GAAG,SAAS;IAI1B,GAAG,CAAC,GAAG,EAAE,CAAC;IAIV,IAAI;IAIJ,MAAM;IAIN,6CAA6C;IAC7C,KAAK,CAAC,GAAG,EAAE,CAAC;IAOZ,GAAG,CAAC,GAAG,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC;IAKpB,MAAM,CAAC,GAAG,EAAE,CAAC;IAOb,KAAK;IAIL,wFAAwF;IACxF,KAAK,CAAC,MAAM,GAAE,WAAW,CAAC,CAAC,CAAa;CAMzC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type Aggregate, type CursorRange, type FilterNode, type GroupKey, type OffsetRange, type RowsRequest, type Scalar } from '@ember-lattice/protocol';
|
|
2
|
+
/** The parts of the engine state (`table.store.state`) that change the rows of the server. */
|
|
3
|
+
export interface QueryState {
|
|
4
|
+
sorting?: ReadonlyArray<{
|
|
5
|
+
id: string;
|
|
6
|
+
desc: boolean;
|
|
7
|
+
}>;
|
|
8
|
+
columnFilters?: ReadonlyArray<{
|
|
9
|
+
id: string;
|
|
10
|
+
value: unknown;
|
|
11
|
+
}>;
|
|
12
|
+
globalFilter?: unknown;
|
|
13
|
+
grouping?: ReadonlyArray<string>;
|
|
14
|
+
pagination?: {
|
|
15
|
+
pageIndex: number;
|
|
16
|
+
pageSize: number;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
export interface RequestOptions {
|
|
20
|
+
/** Default: the page of the pagination state, else the first 100 rows. */
|
|
21
|
+
range?: OffsetRange | CursorRange;
|
|
22
|
+
/** The group path: `keys.length` is the level. */
|
|
23
|
+
keys?: GroupKey[];
|
|
24
|
+
/** The aggregates. Each value comes back under the column id (`as`), so cells read it. */
|
|
25
|
+
aggregate?: ReadonlyArray<Omit<Aggregate, 'as'>>;
|
|
26
|
+
pivot?: RowsRequest['pivot'];
|
|
27
|
+
columns?: string[];
|
|
28
|
+
count?: boolean;
|
|
29
|
+
/** Tree data (ADR 0022): the path of row keys to the parent row. It replaces the group levels. */
|
|
30
|
+
tree?: Scalar[];
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* One column filter value to one filter leaf. The convention (ADR 0010):
|
|
34
|
+
* a string is `contains`, a number or a boolean is `eq`, an array is `in`, and
|
|
35
|
+
* `{ op, value? }` is that op. An empty value is no filter.
|
|
36
|
+
*/
|
|
37
|
+
export declare function columnFilterNode(column: string, value: unknown): FilterNode | null;
|
|
38
|
+
export declare function toRowsRequest(state: QueryState, options: RequestOptions): RowsRequest;
|
|
39
|
+
//# sourceMappingURL=request.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1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