@olvnck/ingrid 0.0.0-stage → 0.15.21
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 +13 -0
- package/LICENSE +21 -0
- package/README.md +5535 -2
- package/THIRD_PARTY_NOTICES.md +10 -0
- package/dist/engine/clipboard/copy.d.ts +40 -0
- package/dist/engine/clipboard/options.d.ts +16 -0
- package/dist/engine/clipboard/text.d.ts +32 -0
- package/dist/engine/columns/autosize.d.ts +43 -0
- package/dist/engine/columns/dataType.d.ts +30 -0
- package/dist/engine/columns/fold.d.ts +48 -0
- package/dist/engine/columns/layout.d.ts +150 -0
- package/dist/engine/columns/model.d.ts +369 -0
- package/dist/engine/columns/query.d.ts +16 -0
- package/dist/engine/columns/tooltips.d.ts +27 -0
- package/dist/engine/data/client/clientSource.d.ts +151 -0
- package/dist/engine/data/client/columnFilters.d.ts +106 -0
- package/dist/engine/data/client/descendants.d.ts +35 -0
- package/dist/engine/data/client/diff.d.ts +23 -0
- package/dist/engine/data/client/fields.d.ts +70 -0
- package/dist/engine/data/client/filter.d.ts +95 -0
- package/dist/engine/data/client/flatten.d.ts +141 -0
- package/dist/engine/data/client/groupSize.d.ts +14 -0
- package/dist/engine/data/client/hierarchy.d.ts +85 -0
- package/dist/engine/data/client/order.d.ts +32 -0
- package/dist/engine/data/client/pipeline.d.ts +277 -0
- package/dist/engine/data/client/remap.d.ts +33 -0
- package/dist/engine/data/client/trees.d.ts +41 -0
- package/dist/engine/data/client/types.d.ts +173 -0
- package/dist/engine/data/memory/generate.d.ts +36 -0
- package/dist/engine/data/memory/memoryDatasource.d.ts +46 -0
- package/dist/engine/data/rowKey.d.ts +15 -0
- package/dist/engine/data/server/contract.d.ts +64 -0
- package/dist/engine/data/server/expansion.d.ts +35 -0
- package/dist/engine/data/server/levelStore.d.ts +99 -0
- package/dist/engine/data/server/loader.d.ts +128 -0
- package/dist/engine/data/server/reader.d.ts +88 -0
- package/dist/engine/data/server/response.d.ts +31 -0
- package/dist/engine/data/server/serverSource.d.ts +130 -0
- package/dist/engine/data/shared/aggregate.d.ts +12 -0
- package/dist/engine/data/shared/columnFilter.d.ts +19 -0
- package/dist/engine/data/shared/compare.d.ts +12 -0
- package/dist/engine/data/shared/dateParts.d.ts +19 -0
- package/dist/engine/data/shared/distinct.d.ts +30 -0
- package/dist/engine/data/shared/filterRecord.d.ts +7 -0
- package/dist/engine/data/shared/keys.d.ts +17 -0
- package/dist/engine/data/shared/quickFilter.d.ts +17 -0
- package/dist/engine/data/shared/sourceUtils.d.ts +11 -0
- package/dist/engine/data/shared/splice.d.ts +9 -0
- package/dist/engine/detail/builds.d.ts +26 -0
- package/dist/engine/detail/content.d.ts +24 -0
- package/dist/engine/detail/controller.d.ts +176 -0
- package/dist/engine/detail/events.d.ts +11 -0
- package/dist/engine/detail/follow.d.ts +56 -0
- package/dist/engine/detail/layer.d.ts +119 -0
- package/dist/engine/detail/live.d.ts +96 -0
- package/dist/engine/detail/options.d.ts +53 -0
- package/dist/engine/detail/state.d.ts +140 -0
- package/dist/engine/edit/clear.d.ts +20 -0
- package/dist/engine/edit/editing.d.ts +4 -0
- package/dist/engine/edit/editors/date.d.ts +3 -0
- package/dist/engine/edit/editors/index.d.ts +23 -0
- package/dist/engine/edit/editors/internals.d.ts +25 -0
- package/dist/engine/edit/editors/largeText.d.ts +2 -0
- package/dist/engine/edit/editors/number.d.ts +4 -0
- package/dist/engine/edit/editors/select.d.ts +2 -0
- package/dist/engine/edit/editors/text.d.ts +15 -0
- package/dist/engine/edit/fill.d.ts +47 -0
- package/dist/engine/edit/fillHandle.d.ts +66 -0
- package/dist/engine/edit/fillValues.d.ts +15 -0
- package/dist/engine/edit/operations.d.ts +68 -0
- package/dist/engine/edit/paste.d.ts +23 -0
- package/dist/engine/edit/pastePlan.d.ts +17 -0
- package/dist/engine/edit/popupHost.d.ts +63 -0
- package/dist/engine/edit/session.d.ts +52 -0
- package/dist/engine/edit/types.d.ts +234 -0
- package/dist/engine/edit/undo.d.ts +38 -0
- package/dist/engine/edit/validation.d.ts +10 -0
- package/dist/engine/edit/values.d.ts +38 -0
- package/dist/engine/export/columns.d.ts +19 -0
- package/dist/engine/export/deliver.d.ts +47 -0
- package/dist/engine/export/dsv.d.ts +2 -0
- package/dist/engine/export/expanded.d.ts +69 -0
- package/dist/engine/export/export.d.ts +25 -0
- package/dist/engine/export/headers.d.ts +15 -0
- package/dist/engine/export/options.d.ts +19 -0
- package/dist/engine/export/plan.d.ts +43 -0
- package/dist/engine/export/values.d.ts +33 -0
- package/dist/engine/export/walk.d.ts +31 -0
- package/dist/engine/export/writer.d.ts +62 -0
- package/dist/engine/export/xlsx/cells.d.ts +31 -0
- package/dist/engine/export/xlsx/index.d.ts +12 -0
- package/dist/engine/export/xlsx/parts.d.ts +36 -0
- package/dist/engine/export/xlsx/sheet.d.ts +30 -0
- package/dist/engine/export/xlsx/styles.d.ts +15 -0
- package/dist/engine/export/xlsx/table.d.ts +8 -0
- package/dist/engine/export/xlsx/zip.d.ts +24 -0
- package/dist/engine/filter/groupFilter.d.ts +28 -0
- package/dist/engine/filter/model.d.ts +235 -0
- package/dist/engine/filter/shorthand.d.ts +36 -0
- package/dist/engine/filter/state.d.ts +76 -0
- package/dist/engine/filter/summary.d.ts +16 -0
- package/dist/engine/filter/values.d.ts +40 -0
- package/dist/engine/find/index.d.ts +94 -0
- package/dist/engine/find/match.d.ts +38 -0
- package/dist/engine/find/model.d.ts +115 -0
- package/dist/engine/grid.d.ts +42 -0
- package/dist/engine/i18n/numbers.d.ts +34 -0
- package/dist/engine/i18n/texts.d.ts +306 -0
- package/dist/engine/interact/autoScroll.d.ts +11 -0
- package/dist/engine/interact/body.d.ts +41 -0
- package/dist/engine/interact/focus.d.ts +158 -0
- package/dist/engine/interact/header.d.ts +216 -0
- package/dist/engine/interact/host.d.ts +400 -0
- package/dist/engine/interact/keyboard.d.ts +20 -0
- package/dist/engine/interact/menuKey.d.ts +7 -0
- package/dist/engine/interact/own.d.ts +2 -0
- package/dist/engine/interact/ranges.d.ts +68 -0
- package/dist/engine/interact/rowSelection.d.ts +53 -0
- package/dist/engine/interact/shortcut.d.ts +21 -0
- package/dist/engine/interact/tooltips.d.ts +63 -0
- package/dist/engine/measure.d.ts +30 -0
- package/dist/engine/render/cells.d.ts +322 -0
- package/dist/engine/render/columns.d.ts +28 -0
- package/dist/engine/render/dom.d.ts +24 -0
- package/dist/engine/render/flash.d.ts +74 -0
- package/dist/engine/render/groupCell.d.ts +50 -0
- package/dist/engine/render/groupPanel.d.ts +21 -0
- package/dist/engine/render/header.d.ts +162 -0
- package/dist/engine/render/overlay.d.ts +15 -0
- package/dist/engine/render/pinnedRows.d.ts +106 -0
- package/dist/engine/render/rowPool.d.ts +3 -0
- package/dist/engine/render/scrollbars.d.ts +77 -0
- package/dist/engine/render/strategy.d.ts +397 -0
- package/dist/engine/reportError.d.ts +7 -0
- package/dist/engine/rowdrag/controller.d.ts +80 -0
- package/dist/engine/rowdrag/events.d.ts +17 -0
- package/dist/engine/rowdrag/gesture.d.ts +33 -0
- package/dist/engine/rowdrag/keys.d.ts +21 -0
- package/dist/engine/rowdrag/model.d.ts +67 -0
- package/dist/engine/rowdrag/options.d.ts +34 -0
- package/dist/engine/rowdrag/rows.d.ts +61 -0
- package/dist/engine/rowdrag/target.d.ts +59 -0
- package/dist/engine/rowdrag/zones.d.ts +79 -0
- package/dist/engine/schedule.d.ts +29 -0
- package/dist/engine/selection/aggregate.d.ts +30 -0
- package/dist/engine/selection/options.d.ts +7 -0
- package/dist/engine/selection/rangeRows.d.ts +19 -0
- package/dist/engine/selection/ranges.d.ts +114 -0
- package/dist/engine/selection/rows.d.ts +207 -0
- package/dist/engine/source.d.ts +225 -0
- package/dist/engine/synthetic.d.ts +28 -0
- package/dist/engine/table/cells.d.ts +52 -0
- package/dist/engine/table/headers.d.ts +20 -0
- package/dist/engine/table/host.d.ts +65 -0
- package/dist/engine/table/job.d.ts +21 -0
- package/dist/engine/table/rows.d.ts +99 -0
- package/dist/engine/table/slicer.d.ts +54 -0
- package/dist/engine/table/takes.d.ts +145 -0
- package/dist/engine/types.d.ts +2950 -0
- package/dist/engine/ui/announce.d.ts +7 -0
- package/dist/engine/ui/chooser.d.ts +19 -0
- package/dist/engine/ui/columnList.d.ts +41 -0
- package/dist/engine/ui/columnMenu.d.ts +96 -0
- package/dist/engine/ui/columnsPanel.d.ts +16 -0
- package/dist/engine/ui/contextMenu.d.ts +48 -0
- package/dist/engine/ui/controller.d.ts +295 -0
- package/dist/engine/ui/filters/apply.d.ts +53 -0
- package/dist/engine/ui/filters/custom.d.ts +3 -0
- package/dist/engine/ui/filters/date.d.ts +12 -0
- package/dist/engine/ui/filters/host.d.ts +102 -0
- package/dist/engine/ui/filters/multi.d.ts +6 -0
- package/dist/engine/ui/filters/number.d.ts +15 -0
- package/dist/engine/ui/filters/numberMask.d.ts +15 -0
- package/dist/engine/ui/filters/set.d.ts +3 -0
- package/dist/engine/ui/filters/simple.d.ts +52 -0
- package/dist/engine/ui/filters/text.d.ts +5 -0
- package/dist/engine/ui/filtersPanel.d.ts +18 -0
- package/dist/engine/ui/floating.d.ts +66 -0
- package/dist/engine/ui/floatingShorthand.d.ts +20 -0
- package/dist/engine/ui/floatingTypes.d.ts +82 -0
- package/dist/engine/ui/icons.d.ts +25 -0
- package/dist/engine/ui/menu.d.ts +45 -0
- package/dist/engine/ui/overlayHost.d.ts +7 -0
- package/dist/engine/ui/place.d.ts +37 -0
- package/dist/engine/ui/popup.d.ts +97 -0
- package/dist/engine/ui/sideBar.d.ts +26 -0
- package/dist/engine/ui/statusBar.d.ts +29 -0
- package/dist/engine/ui/toolbar/buttons.d.ts +21 -0
- package/dist/engine/ui/toolbar/chipState.d.ts +52 -0
- package/dist/engine/ui/toolbar/chips.d.ts +23 -0
- package/dist/engine/ui/toolbar/findBox.d.ts +10 -0
- package/dist/engine/ui/toolbar/quickFilterBox.d.ts +12 -0
- package/dist/engine/ui/toolbar/registry.d.ts +5 -0
- package/dist/engine/ui/toolbar/toolbar.d.ts +31 -0
- package/dist/engine/ui/toolbar/types.d.ts +23 -0
- package/dist/engine/ui/tooltip.d.ts +34 -0
- package/dist/engine/ui/virtualList.d.ts +35 -0
- package/dist/engine/viewport/heightView.d.ts +62 -0
- package/dist/engine/viewport/heights.d.ts +39 -0
- package/dist/engine/viewport/intervals.d.ts +19 -0
- package/dist/engine/viewport/range.d.ts +51 -0
- package/dist/engine/viewport/scroll.d.ts +45 -0
- package/dist/engine/viewport/stack.d.ts +160 -0
- package/dist/grid-C34VEap6.js +32310 -0
- package/dist/index.d.ts +19 -0
- package/dist/index.js +1273 -0
- package/dist/ingrid.css +1 -0
- package/dist/internal.d.ts +13 -0
- package/dist/internal.js +1 -0
- package/dist/locale/de.d.ts +4 -0
- package/dist/locale/de.js +222 -0
- package/dist/themes/primevue.css +63 -0
- package/dist/themes/tailwind.css +68 -0
- package/dist/vue/InGrid.vue.d.ts +263 -0
- package/dist/vue/stableOptions.d.ts +8 -0
- package/dist/vue/useClientSource.d.ts +28 -0
- package/dist/vue/useServerSource.d.ts +8 -0
- package/dist/vue/vueRenderer.d.ts +164 -0
- package/dist/xlsx-59umS_n_.js +325 -0
- package/package.json +78 -5
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { FieldFilter, FilterValues, QuickFilterQuery, RowQuery, ValuesRequest } from '../../source';
|
|
2
|
+
/** A group value or a tree node id. */
|
|
3
|
+
export type GroupKey = string | number | boolean | null;
|
|
4
|
+
/**
|
|
5
|
+
* One block request: rows [start, end) of the level below `path`. `treeField` is not sent, and
|
|
6
|
+
* `quickFilter` only while the grid's quick filter has a word.
|
|
7
|
+
*/
|
|
8
|
+
export interface RowsRequest extends Omit<RowQuery, 'quickFilter' | 'treeField' | 'filter'> {
|
|
9
|
+
/** The query's column-filter entries, only while a filter is active. */
|
|
10
|
+
filter?: readonly FieldFilter[];
|
|
11
|
+
/** Keep the rows where every word of `text` occurs in one of `fields` (case-insensitive substrings). */
|
|
12
|
+
quickFilter?: QuickFilterQuery;
|
|
13
|
+
start: number;
|
|
14
|
+
end: number;
|
|
15
|
+
/** Keys of the expanded ancestors, root first; [] = top level. */
|
|
16
|
+
path: readonly GroupKey[];
|
|
17
|
+
/** Aborted when the block is no longer wanted. */
|
|
18
|
+
signal: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
/** The answer to a `RowsRequest`. */
|
|
21
|
+
export interface RowsResponse {
|
|
22
|
+
/** Exact number of rows of this level. */
|
|
23
|
+
total: number;
|
|
24
|
+
/** Columnar: field → values (preferred)… */
|
|
25
|
+
columns?: Record<string, ArrayLike<unknown>>;
|
|
26
|
+
/** …or one object per row (converted to columnar on arrival). */
|
|
27
|
+
rows?: readonly Record<string, unknown>[];
|
|
28
|
+
/** Per row: child count; true = has children, count unknown; 0 / false = leaf. */
|
|
29
|
+
children?: ArrayLike<number | boolean>;
|
|
30
|
+
/** Per row: key of an expandable row (a group's key defaults to its value). */
|
|
31
|
+
keys?: ArrayLike<GroupKey>;
|
|
32
|
+
/** Per row: a stable id. */
|
|
33
|
+
ids?: ArrayLike<string | number>;
|
|
34
|
+
}
|
|
35
|
+
export interface ServerDatasource {
|
|
36
|
+
getRows(request: RowsRequest): Promise<RowsResponse>;
|
|
37
|
+
/** Distinct values of a field for the set filter. */
|
|
38
|
+
getValues?(request: ValuesRequest): Promise<FilterValues>;
|
|
39
|
+
}
|
|
40
|
+
export interface ServerSourceOptions {
|
|
41
|
+
/** Rows per request (default 100; a desktop CSV viewer: 500). */
|
|
42
|
+
blockSize?: number;
|
|
43
|
+
/** Requests in flight (default 2; a serialised backend: 1). */
|
|
44
|
+
maxConcurrent?: number;
|
|
45
|
+
/** Cached blocks across all levels (default 64). */
|
|
46
|
+
maxBlocks?: number;
|
|
47
|
+
/** Root size before the first response, when the first query has no grouping (default 0). */
|
|
48
|
+
initialRowCount?: number;
|
|
49
|
+
}
|
|
50
|
+
/** Expansion as saved by apps (JSON-safe when the keys are). */
|
|
51
|
+
export interface ExpansionState {
|
|
52
|
+
default: 'collapsed' | 'expanded';
|
|
53
|
+
exceptions: GroupKey[][];
|
|
54
|
+
}
|
|
55
|
+
export interface ServerSourceError {
|
|
56
|
+
path: GroupKey[];
|
|
57
|
+
/** Rows of the failed block inside its level (inclusive). */
|
|
58
|
+
first: number;
|
|
59
|
+
last: number;
|
|
60
|
+
reason: unknown;
|
|
61
|
+
}
|
|
62
|
+
export declare const DEFAULT_BLOCK_SIZE = 100;
|
|
63
|
+
export declare const DEFAULT_MAX_CONCURRENT = 2;
|
|
64
|
+
export declare const DEFAULT_MAX_BLOCKS = 64;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ExpansionState, GroupKey } from './contract';
|
|
2
|
+
/**
|
|
3
|
+
* Which groups and tree nodes are expanded: a default plus exception paths, kept apart from the
|
|
4
|
+
* level stores, so expand-all also covers groups that are not loaded yet and a collapsed subtree keeps its nested state.
|
|
5
|
+
* Paths are kept normalised (`keyOf`); the client source shares this class.
|
|
6
|
+
*/
|
|
7
|
+
export declare class Expansion {
|
|
8
|
+
private all;
|
|
9
|
+
/** Path key → path (keys normalised). */
|
|
10
|
+
private readonly exceptions;
|
|
11
|
+
get defaultExpanded(): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Rows may still open as blocks arrive: expand-all is on, or some path is expanded. A loaded block then
|
|
14
|
+
* inserts the levels below its rows, which is why loading goes top-down while this holds.
|
|
15
|
+
*/
|
|
16
|
+
get canOpen(): boolean;
|
|
17
|
+
/** Some path differs from the default. */
|
|
18
|
+
get hasExceptions(): boolean;
|
|
19
|
+
isExpanded(key: string): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Returns true when the state of `path` changed. Its keys are normalised first: a Date, NaN or
|
|
22
|
+
* undefined key names the same path as its normalised form.
|
|
23
|
+
*/
|
|
24
|
+
set(path: readonly GroupKey[], expanded: boolean): boolean;
|
|
25
|
+
/** Expand-all / collapse-all: the default flips and the exceptions go. */
|
|
26
|
+
setAll(expanded: boolean): boolean;
|
|
27
|
+
get(): ExpansionState;
|
|
28
|
+
/**
|
|
29
|
+
* Replaces the whole state (keys normalised); returns true when it differs from the current one: another default,
|
|
30
|
+
* or another set of exception paths — their order does not count.
|
|
31
|
+
*/
|
|
32
|
+
replace(state: ExpansionState): boolean;
|
|
33
|
+
/** A `groupBy` change: exceptions deeper than the old and new groupBy's common prefix are dropped. */
|
|
34
|
+
keepDepth(depth: number): boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import type { Splice } from '../shared/splice';
|
|
2
|
+
import type { GroupKey } from './contract';
|
|
3
|
+
/** Rows received for one block, columnar; produced by `normaliseResponse`. */
|
|
4
|
+
export interface BlockData {
|
|
5
|
+
/** Rows held; may be fewer than the block spans (the rest count as failed). */
|
|
6
|
+
count: number;
|
|
7
|
+
/** Field → values (index = row within the block). */
|
|
8
|
+
columns: ReadonlyMap<string, ArrayLike<unknown>>;
|
|
9
|
+
/** Per row: the row can be expanded; null = no row of this block can. */
|
|
10
|
+
expandable: readonly boolean[] | null;
|
|
11
|
+
/** Per row: the known child count; null entries = unknown. */
|
|
12
|
+
childCount: readonly (number | null)[] | null;
|
|
13
|
+
/** Per row: the key of an expandable row (null for the others and for blank keys alike — check `expandable`). */
|
|
14
|
+
keys: readonly GroupKey[] | null;
|
|
15
|
+
ids: ArrayLike<string | number> | null;
|
|
16
|
+
}
|
|
17
|
+
export interface Block {
|
|
18
|
+
readonly index: number;
|
|
19
|
+
/** Rows last received, of any generation (stale while older than the source's); null = nothing to show. */
|
|
20
|
+
data: BlockData | null;
|
|
21
|
+
dataGeneration: number;
|
|
22
|
+
/** The current generation's request failed; `armed` = it may be retried (it left the wanted set, or retry()). */
|
|
23
|
+
failure: {
|
|
24
|
+
generation: number;
|
|
25
|
+
reason: unknown;
|
|
26
|
+
armed: boolean;
|
|
27
|
+
} | null;
|
|
28
|
+
request: {
|
|
29
|
+
generation: number;
|
|
30
|
+
controller: AbortController;
|
|
31
|
+
} | null;
|
|
32
|
+
/** `BlockLoader.tick` of the last wanted set that held the block (least recently wanted is evicted first). */
|
|
33
|
+
lastWanted: number;
|
|
34
|
+
}
|
|
35
|
+
interface Entry {
|
|
36
|
+
index: number;
|
|
37
|
+
child: LevelStore;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* One level of the hierarchy: the root, or an expanded group or tree node. Holds its total, its blocks
|
|
41
|
+
* and its expanded children; the whole tree's flat index comes from the children's flat sizes: a binary search
|
|
42
|
+
* over each level's expanded rows, O(depth × log k) per row.
|
|
43
|
+
*/
|
|
44
|
+
export declare class LevelStore {
|
|
45
|
+
readonly path: readonly GroupKey[];
|
|
46
|
+
readonly key: string;
|
|
47
|
+
readonly isRoot: boolean;
|
|
48
|
+
parent: LevelStore | null;
|
|
49
|
+
/** Local index of this level's row in the parent (while attached). */
|
|
50
|
+
parentIndex: number;
|
|
51
|
+
total: number;
|
|
52
|
+
/**
|
|
53
|
+
* A response set `total`; otherwise it is the root's initial count, 0 for an opened level waiting for its first
|
|
54
|
+
* block, or 1 for that level's error row.
|
|
55
|
+
*/
|
|
56
|
+
totalKnown: boolean;
|
|
57
|
+
readonly blocks: Map<number, Block>;
|
|
58
|
+
private readonly list;
|
|
59
|
+
/** prefix[k] = Σ flat sizes of entries 0…k−1; rebuilt lazily (at most once per change). */
|
|
60
|
+
private readonly prefix;
|
|
61
|
+
private dirty;
|
|
62
|
+
private size;
|
|
63
|
+
constructor(path: readonly GroupKey[], total: number, isRoot?: boolean);
|
|
64
|
+
/** Rows of this level plus the rows of its expanded subtrees. */
|
|
65
|
+
get flatSize(): number;
|
|
66
|
+
/** Part of the flat list: the root, or attached all the way up to it. */
|
|
67
|
+
get live(): boolean;
|
|
68
|
+
entries(): readonly Entry[];
|
|
69
|
+
entryAt(index: number): LevelStore | undefined;
|
|
70
|
+
/** Local index of the first expanded row at or after `index`; −1 when there is none (the reader's runs). */
|
|
71
|
+
nextEntry(index: number): number;
|
|
72
|
+
/** The block `index`, created empty on first use. */
|
|
73
|
+
block(index: number): Block;
|
|
74
|
+
/** Flat index of this level's first row (a live store). */
|
|
75
|
+
start(): number;
|
|
76
|
+
/** Flat index of local row `index`; `index = total` is the position right after the level and its subtrees. */
|
|
77
|
+
rowFlat(index: number): number;
|
|
78
|
+
/** Level and local row of `flat`, counted from this store's start (0 ≤ flat < flatSize). */
|
|
79
|
+
locate(flat: number): {
|
|
80
|
+
store: LevelStore;
|
|
81
|
+
index: number;
|
|
82
|
+
};
|
|
83
|
+
/** Puts a detached store under row `index` (no entry there yet); its splice when this store is live. */
|
|
84
|
+
attach(index: number, child: LevelStore): Splice | null;
|
|
85
|
+
/** Takes the child under row `index` off; it keeps its own entries and blocks. */
|
|
86
|
+
detach(index: number): {
|
|
87
|
+
child: LevelStore;
|
|
88
|
+
splice: Splice | null;
|
|
89
|
+
} | null;
|
|
90
|
+
/** A new total: entries past a shrinking end are detached first, then rows change at the level's end. */
|
|
91
|
+
setTotal(total: number, known: boolean): Splice[];
|
|
92
|
+
/** Drops every expanded entry, recursively, without splices (a purge); sizes fall back to the totals. */
|
|
93
|
+
clearEntries(): void;
|
|
94
|
+
private grow;
|
|
95
|
+
private ensurePrefix;
|
|
96
|
+
/** First entry position whose index ≥ `index`. */
|
|
97
|
+
private lowerBound;
|
|
98
|
+
}
|
|
99
|
+
export {};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import type { RowQuery } from '../../source';
|
|
2
|
+
import type { GroupKey, RowsRequest, ServerDatasource } from './contract';
|
|
3
|
+
import type { Block, LevelStore } from './levelStore';
|
|
4
|
+
export interface WantedBlock {
|
|
5
|
+
store: LevelStore;
|
|
6
|
+
block: number;
|
|
7
|
+
/**
|
|
8
|
+
* Lower = sooner (distance from the centre of the requested range; while rows can open, from the
|
|
9
|
+
* anchor, rows above it last).
|
|
10
|
+
*/
|
|
11
|
+
priority: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The longest sending waits after rows moved under the wanted set. A grid asks again in its next frame's pass,
|
|
15
|
+
* well within this; it only bounds the wait when nobody does (no grid, a hidden one that skips its pass).
|
|
16
|
+
*/
|
|
17
|
+
export declare const HOLD_MS = 50;
|
|
18
|
+
export type Outcome = {
|
|
19
|
+
ok: true;
|
|
20
|
+
value: unknown;
|
|
21
|
+
} | {
|
|
22
|
+
ok: false;
|
|
23
|
+
reason: unknown;
|
|
24
|
+
};
|
|
25
|
+
export interface LoaderHost {
|
|
26
|
+
readonly datasource: ServerDatasource;
|
|
27
|
+
readonly blockSize: number;
|
|
28
|
+
readonly maxConcurrent: number;
|
|
29
|
+
query(): RowQuery;
|
|
30
|
+
generation(): number;
|
|
31
|
+
/** The store still belongs to the source (a rebuild or destroy drops stores). */
|
|
32
|
+
owns(store: LevelStore): boolean;
|
|
33
|
+
/** A request of the current generation settled, for a store the source still owns. */
|
|
34
|
+
settled(store: LevelStore, block: Block, outcome: Outcome, request: RowsRequest): void;
|
|
35
|
+
loadingChanged(inFlight: number): void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* How a read outside the block cache ended: the datasource's answer with the request it answered, its
|
|
39
|
+
* rejection, or `cancelled` (the reader cancelled it, or every request was aborted: a new generation, destroy).
|
|
40
|
+
*/
|
|
41
|
+
export type ReadOutcome = {
|
|
42
|
+
ok: true;
|
|
43
|
+
value: unknown;
|
|
44
|
+
request: RowsRequest;
|
|
45
|
+
} | {
|
|
46
|
+
ok: false;
|
|
47
|
+
reason: unknown;
|
|
48
|
+
cancelled: boolean;
|
|
49
|
+
};
|
|
50
|
+
/** A queued or sent read; `cancel()` takes it out of the queue or aborts it, freeing its slot. */
|
|
51
|
+
export interface ReadHandle {
|
|
52
|
+
readonly promise: Promise<ReadOutcome>;
|
|
53
|
+
cancel(): void;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Block requests: a wanted set replaced on every `ensureLoaded`, a priority queue, at most
|
|
57
|
+
* `maxConcurrent` requests in flight, a latest-wanted check right before sending (held while rows moved under the
|
|
58
|
+
* set), aborts for blocks that left the wanted set (plus a margin of one block on each side), and generations: a
|
|
59
|
+
* superseded response is dropped even if the datasource ignored its signal.
|
|
60
|
+
*
|
|
61
|
+
* Reads outside the block cache (copies, Shift ranges over rows not loaded) share the `maxConcurrent` slots
|
|
62
|
+
* at a lower priority: a queued read is sent only while no wanted block waits for a slot (and not while the wanted set
|
|
63
|
+
* is held), first come first served. Their answers go back to the reader, never into a block.
|
|
64
|
+
*/
|
|
65
|
+
export declare class BlockLoader {
|
|
66
|
+
/** Moves with every wanted set; blocks remember the tick they were last wanted in. */
|
|
67
|
+
tick: number;
|
|
68
|
+
private readonly host;
|
|
69
|
+
private wanted;
|
|
70
|
+
private wantedIndex;
|
|
71
|
+
private readonly flying;
|
|
72
|
+
/** Reads waiting for a slot, oldest first, and reads in flight. */
|
|
73
|
+
private readonly queue;
|
|
74
|
+
private readonly reading;
|
|
75
|
+
/** A pump is due once the caller's synchronous work is done (see `pumpSoon`). */
|
|
76
|
+
private pumpDue;
|
|
77
|
+
private disposed;
|
|
78
|
+
/** Rows moved since the wanted set was made: its blocks may no longer be the wanted ones. */
|
|
79
|
+
private stale;
|
|
80
|
+
/**
|
|
81
|
+
* Owns the release timer: detached, so the timer lives as long as the loader, not as long as whatever effect scope
|
|
82
|
+
* happened to be active when the source was created (a component's setup); `dispose()` stops it.
|
|
83
|
+
*/
|
|
84
|
+
private readonly scope;
|
|
85
|
+
private readonly release;
|
|
86
|
+
constructor(host: LoaderHost);
|
|
87
|
+
/** Requests in flight: block loads and reads. */
|
|
88
|
+
get inFlight(): number;
|
|
89
|
+
isWanted(store: LevelStore, block: number): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Rows moved under the wanted set (an answer's splices): nothing is sent from it until the next `want()`, or
|
|
92
|
+
* `HOLD_MS` after the first send it held back.
|
|
93
|
+
*/
|
|
94
|
+
moved(): void;
|
|
95
|
+
/** Replaces the wanted set and sends what it needs. */
|
|
96
|
+
want(blocks: readonly WantedBlock[]): void;
|
|
97
|
+
/**
|
|
98
|
+
* Sends wanted blocks that need data, by priority, while there is room; then queued reads, only when no wanted block
|
|
99
|
+
* is left waiting. Nothing is sent while the wanted set is stale.
|
|
100
|
+
*/
|
|
101
|
+
pump(): void;
|
|
102
|
+
/**
|
|
103
|
+
* Queues a read of rows [start, end) of the level below `path` with the current query. Its promise never
|
|
104
|
+
* rejects: it settles with the answer, the datasource's rejection, or `cancelled`.
|
|
105
|
+
*/
|
|
106
|
+
read(path: readonly GroupKey[], start: number, end: number): ReadHandle;
|
|
107
|
+
/**
|
|
108
|
+
* Pumps after the current synchronous work: a read cancelled by a splice is cancelled in the middle of an answer
|
|
109
|
+
* (between its new total and its rows), where a pump would ask for the answered block again.
|
|
110
|
+
*/
|
|
111
|
+
private pumpSoon;
|
|
112
|
+
abortAll(): void;
|
|
113
|
+
/** The source is destroyed: requests aborted, the release timer gone for good. */
|
|
114
|
+
dispose(): void;
|
|
115
|
+
private abort;
|
|
116
|
+
/**
|
|
117
|
+
* Takes a read out of flight with its request aborted; a queued one stays queued and is skipped once settled. Does
|
|
118
|
+
* not settle it.
|
|
119
|
+
*/
|
|
120
|
+
private dropRead;
|
|
121
|
+
/** The request for rows [start, end) of the level below `path`, with the current query. */
|
|
122
|
+
private request;
|
|
123
|
+
/** Calls the datasource; a synchronous throw becomes a rejection. */
|
|
124
|
+
private call;
|
|
125
|
+
private send;
|
|
126
|
+
private sendRead;
|
|
127
|
+
private done;
|
|
128
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { type RowInfo } from '../../source';
|
|
2
|
+
import type { Splice } from '../shared/splice';
|
|
3
|
+
import type { GroupKey } from './contract';
|
|
4
|
+
import type { BlockData, LevelStore } from './levelStore';
|
|
5
|
+
import type { ReadHandle } from './loader';
|
|
6
|
+
/** Blocks per read window: a read asks for `blockSize × 10` rows at a time. */
|
|
7
|
+
export declare const READ_BLOCKS = 10;
|
|
8
|
+
/** Rows read outside the block cache. */
|
|
9
|
+
export interface ReadRows {
|
|
10
|
+
/**
|
|
11
|
+
* Per row read: its display index when the read resolved; −1 for a row of an open group whose level had not arrived
|
|
12
|
+
* when the read listed it (`expandAll`).
|
|
13
|
+
*/
|
|
14
|
+
rows: number[];
|
|
15
|
+
/** Per field: the rows' values, as `getValue` gives them once the rows are loaded. */
|
|
16
|
+
values: Record<string, unknown[]>;
|
|
17
|
+
/** Per row: its id (`RowsResponse.ids`); null for group rows and rows without one — what a row selection keeps. */
|
|
18
|
+
ids: (string | number | null)[];
|
|
19
|
+
/**
|
|
20
|
+
* Row `i`'s info, as the source's `rowInfo(row, into?)` gives it once the row is loaded (`id`: the response's id,
|
|
21
|
+
* group rows included; an opened level's error row: state 'error'). Fills and returns `into` when given, so a
|
|
22
|
+
* caller walking millions of rows allocates nothing per row (kept as columns, not one object per row).
|
|
23
|
+
*/
|
|
24
|
+
info(i: number, into?: RowInfo): RowInfo;
|
|
25
|
+
/**
|
|
26
|
+
* The rows changed while they were read — a new generation (purge, refresh, regroup, destroy), a splice at or above
|
|
27
|
+
* the last row, a response whose level total differs — or the signal aborted. Every list is empty then.
|
|
28
|
+
*/
|
|
29
|
+
cancelled: boolean;
|
|
30
|
+
}
|
|
31
|
+
/** What the reader needs from the server source. */
|
|
32
|
+
export interface ReaderHost {
|
|
33
|
+
root(): LevelStore;
|
|
34
|
+
readonly blockSize: number;
|
|
35
|
+
generation(): number;
|
|
36
|
+
/** Started (it has a query) and not destroyed. */
|
|
37
|
+
live(): boolean;
|
|
38
|
+
groupBy(): readonly string[];
|
|
39
|
+
/** The expansion state of `path` (normalised keys). */
|
|
40
|
+
expanded(path: readonly GroupKey[]): boolean;
|
|
41
|
+
/** A read through the loader's low-priority queue. */
|
|
42
|
+
read(path: readonly GroupKey[], start: number, end: number): ReadHandle;
|
|
43
|
+
/**
|
|
44
|
+
* Block `block` of the level below `path` when the cache holds all its rows of the current generation, with the
|
|
45
|
+
* level's total (`readTree`); null otherwise.
|
|
46
|
+
*/
|
|
47
|
+
cached(path: readonly GroupKey[], block: number): {
|
|
48
|
+
data: BlockData;
|
|
49
|
+
total: number;
|
|
50
|
+
} | null;
|
|
51
|
+
/** A response problem, reported once per source and kind. */
|
|
52
|
+
report(problem: string): void;
|
|
53
|
+
/** Splices from now on reach `read`. Returns the unregister function. */
|
|
54
|
+
watch(read: ReadWatch): () => void;
|
|
55
|
+
}
|
|
56
|
+
/** What a read hears of the source's splices. */
|
|
57
|
+
export interface ReadWatch {
|
|
58
|
+
/** `firstAnswer`: the splice adds an opened level's first rows (its first answer). */
|
|
59
|
+
moved(splice: Splice, firstAnswer: boolean): void;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Reads display rows `first … last` and, with `expandAll`, the levels of open groups that have not arrived, depth-first
|
|
63
|
+
* after their rows. Each display row is mapped to its level and index (`locate`); blocks of the current
|
|
64
|
+
* generation already cached are used as they are; the other rows are read in windows of up to ten blocks per level
|
|
65
|
+
* through the loader's read queue, which shares `maxConcurrent` with the viewport's loads at a lower priority. Nothing
|
|
66
|
+
* read is cached. A new generation, a splice at or above `last`, a response whose total differs from its level's, or
|
|
67
|
+
* the signal ends the read with `cancelled: true` — except, for `expandAll`, an opened level's first rows: the
|
|
68
|
+
* read takes that level itself and only moves the display indices below it. With `all` (and `expandAll`) every group
|
|
69
|
+
* the read lists is read as if open: closed groups' levels too (an export of rows that bring their groups).
|
|
70
|
+
* A datasource failure or a malformed answer rejects (the latter reported once, as for blocks).
|
|
71
|
+
*/
|
|
72
|
+
export declare function readRows(host: ReaderHost, first: number, last: number, asked: readonly string[], signal: AbortSignal, expandAll: boolean, all?: boolean): Promise<ReadRows>;
|
|
73
|
+
/** One segment of `readTree`: up to a window of rows, and whether any row follows it. */
|
|
74
|
+
export interface TreeSegment {
|
|
75
|
+
read: ReadRows;
|
|
76
|
+
/** No row follows (the walk is through), or the segment is a cancelled one. */
|
|
77
|
+
last: boolean;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Every row of the hierarchy, open or closed, depth-first in the server's order: each level read in
|
|
81
|
+
* windows of `span` rows — its cached blocks of the current generation as they are, the rest through the loader's read
|
|
82
|
+
* queue at its low priority — a group's level right after its row. Yielded in segments of up to `span` rows, so
|
|
83
|
+
* memory holds one window per level on the way down plus the segment being filled, whatever the row count. Rows carry
|
|
84
|
+
* display index −1: they are read by level, not by display row. `found(total)` hears each level's total when its first
|
|
85
|
+
* window arrives (the rows known so far). A new generation, the signal, the source's end or an answer whose total
|
|
86
|
+
* differs from its level's ends the walk with a cancelled segment; a datasource failure or a malformed answer rejects.
|
|
87
|
+
*/
|
|
88
|
+
export declare function readTree(host: ReaderHost, asked: readonly string[], signal: AbortSignal, span: number, found: (total: number) => void): AsyncGenerator<TreeSegment, void>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { BlockData } from './levelStore';
|
|
2
|
+
/** What a level holds: group rows keyed by `field`, the leaf rows of a grouping, or flat / tree rows. */
|
|
3
|
+
export type LevelKind = {
|
|
4
|
+
kind: 'group';
|
|
5
|
+
field: string;
|
|
6
|
+
} | {
|
|
7
|
+
kind: 'leaf';
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'tree';
|
|
10
|
+
};
|
|
11
|
+
export type Normalised = {
|
|
12
|
+
ok: true;
|
|
13
|
+
total: number;
|
|
14
|
+
data: BlockData;
|
|
15
|
+
problems: string[];
|
|
16
|
+
} | {
|
|
17
|
+
ok: false;
|
|
18
|
+
problem: string;
|
|
19
|
+
};
|
|
20
|
+
/** Problem texts (reported once per source and text, so they carry no numbers). */
|
|
21
|
+
export declare const PROBLEMS: {
|
|
22
|
+
readonly notObject: "the response is not an object";
|
|
23
|
+
readonly total: "the response total is not a non-negative integer";
|
|
24
|
+
readonly short: "the response has fewer rows than its window and total call for; the missing rows are shown as failed";
|
|
25
|
+
readonly lengths: "the response arrays have different lengths; the shortest one counts";
|
|
26
|
+
readonly coerced: "keys must be strings, numbers, booleans or null; other values were converted with String()";
|
|
27
|
+
readonly noKey: "an expandable tree row has no key; it is shown as a leaf";
|
|
28
|
+
readonly shape: "the response fields have the wrong shape (rows must be an array, columns and the arrays must be array-like); the response is refused";
|
|
29
|
+
};
|
|
30
|
+
/** Checks a `RowsResponse` for the request [start, end) and turns it into a columnar block. */
|
|
31
|
+
export declare function normaliseResponse(res: unknown, start: number, end: number, level: LevelKind): Normalised;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { type ExpansionChange, type FilterValues, type RowInfo, type RowQuery, type SourceStatus, type ValuesRequest, type ViewportSource } from '../../source';
|
|
2
|
+
import { type ExpansionState, type GroupKey, type ServerDatasource, type ServerSourceError, type ServerSourceOptions } from './contract';
|
|
3
|
+
import { type ReadRows, type TreeSegment } from './reader';
|
|
4
|
+
export type { ReadRows, TreeSegment } from './reader';
|
|
5
|
+
/** The source behind `serverSource()`. */
|
|
6
|
+
export interface ServerSource extends ViewportSource {
|
|
7
|
+
rowInfo(row: number, into?: RowInfo): RowInfo;
|
|
8
|
+
parentRow(row: number): number;
|
|
9
|
+
groupEnd(row: number): number;
|
|
10
|
+
setQuery(query: RowQuery): void;
|
|
11
|
+
filterValues(request: ValuesRequest): Promise<FilterValues>;
|
|
12
|
+
status(): SourceStatus;
|
|
13
|
+
setExpanded(row: number, expanded: boolean, options?: {
|
|
14
|
+
all?: boolean;
|
|
15
|
+
source?: 'ui' | 'api';
|
|
16
|
+
}): void;
|
|
17
|
+
expand(path: readonly GroupKey[]): void;
|
|
18
|
+
collapse(path: readonly GroupKey[]): void;
|
|
19
|
+
isExpanded(path: readonly GroupKey[]): boolean;
|
|
20
|
+
expandAll(): void;
|
|
21
|
+
collapseAll(): void;
|
|
22
|
+
/** Keys of the row's ancestors, plus its own key when it has one. */
|
|
23
|
+
pathOf(row: number): GroupKey[];
|
|
24
|
+
getExpansion(): ExpansionState;
|
|
25
|
+
setExpansion(state: ExpansionState): void;
|
|
26
|
+
/** A level's total; null while unknown (no response yet). */
|
|
27
|
+
total(path?: readonly GroupKey[]): number | null;
|
|
28
|
+
/** Stale rows stay visible until fresh data arrives; `purge` drops them. */
|
|
29
|
+
refresh(options?: {
|
|
30
|
+
purge?: boolean;
|
|
31
|
+
}): void;
|
|
32
|
+
/** Asks again for every failed block. */
|
|
33
|
+
retry(): void;
|
|
34
|
+
/**
|
|
35
|
+
* Value writes: `write` gets a loaded leaf or tree row (not a group row) as a plain
|
|
36
|
+
* object of the fields its block holds; the own fields a write that happened changed or added are kept as a local
|
|
37
|
+
* patch of the cached block — what `getValue` returns until the block is loaded again (a refresh, a purge), when
|
|
38
|
+
* the server's row replaces the patch. No field of a server row is computed: `plain` writes are taken too. The
|
|
39
|
+
* datasource is not told: the app persists from `onCellValueChanged`.
|
|
40
|
+
*/
|
|
41
|
+
writeCell(row: number, field: string, write: (data: object) => boolean, plain: boolean): boolean;
|
|
42
|
+
onExpansionChange(listener: (change: ExpansionChange) => void): () => void;
|
|
43
|
+
onError(listener: (error: ServerSourceError) => void): () => void;
|
|
44
|
+
onLoadingChange(listener: (requestsInFlight: number) => void): () => void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
|
47
|
+
/** A server source's reader of rows outside its block cache: copies, Shift ranges over rows not loaded. */
|
|
48
|
+
export interface ServerInternals {
|
|
49
|
+
/**
|
|
50
|
+
* Moves at each block land after a plain `refresh()`, until the next purge or regroup: what a refresh kept on
|
|
51
|
+
* screen as stale gets its new values.
|
|
52
|
+
*/
|
|
53
|
+
valuePasses(): number;
|
|
54
|
+
/** Runs `listener` at each plain `refresh()` (not a purge: that resets); returns the remover. Undo clears on it. */
|
|
55
|
+
onRefresh(listener: () => void): () => void;
|
|
56
|
+
/**
|
|
57
|
+
* Values (and ids, row info) of display rows [first, last], read outside the cache; with `expandAll`
|
|
58
|
+
* also the levels of open groups that have not arrived, depth-first after their rows. See `ReadRows.cancelled`.
|
|
59
|
+
*/
|
|
60
|
+
readRows(first: number, last: number, fields: readonly string[], signal: AbortSignal, options?: {
|
|
61
|
+
expandAll?: boolean;
|
|
62
|
+
/** With `expandAll`: closed groups' levels too (rows that bring their groups). */
|
|
63
|
+
all?: boolean;
|
|
64
|
+
}): Promise<ReadRows>;
|
|
65
|
+
/**
|
|
66
|
+
* Every row of the hierarchy, open or closed, depth-first, in segments of up to `chunkRows()` rows (`readTree`):
|
|
67
|
+
* what an export of every row of a grouped or tree view writes, segment by segment.
|
|
68
|
+
*/
|
|
69
|
+
readTree(fields: readonly string[], signal: AbortSignal, found: (total: number) => void): AsyncGenerator<TreeSegment, void>;
|
|
70
|
+
/**
|
|
71
|
+
* What the source knows of every row of the hierarchy before reading it: `rows` — the display rows plus
|
|
72
|
+
* the child counts the datasource sent for loaded groups whose rows are not shown (closed, or opened and waiting;
|
|
73
|
+
* their deeper levels are unknown: a lower bound) — and `loaded`, the rows its cache holds among the display rows.
|
|
74
|
+
*/
|
|
75
|
+
knownRows(): {
|
|
76
|
+
rows: number;
|
|
77
|
+
loaded: number;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* The display row right after the subtree of the outermost row that is `row` or an ancestor of it with a display row
|
|
81
|
+
* at or after `from` (`row + 1` for a closed group or a leaf on its own): the display rows a range ending at `row`
|
|
82
|
+
* covers once its group rows bring their groups.
|
|
83
|
+
*/
|
|
84
|
+
subtreeEnd(row: number, from: number): number;
|
|
85
|
+
/** Moves on every purge, refresh, regroup and destroy. */
|
|
86
|
+
generation(): number;
|
|
87
|
+
/**
|
|
88
|
+
* The row is loaded with data of the current generation: its block arrived after the last purge, refresh or regroup,
|
|
89
|
+
* so it is not a stale row a refresh keeps on screen. A dropped row's follow waits for it.
|
|
90
|
+
*/
|
|
91
|
+
fresh(row: number): boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Rows per read window, `blockSize × READ_BLOCKS`: an export of a flat view reads and writes its rows one such
|
|
94
|
+
* window at a time.
|
|
95
|
+
*/
|
|
96
|
+
chunkRows(): number;
|
|
97
|
+
/**
|
|
98
|
+
* The query is grouped or a tree: open groups may have levels that have not arrived (their rows were never in the
|
|
99
|
+
* `ensureLoaded` range), so the display rows alone are not the tree the expansion state shows.
|
|
100
|
+
*/
|
|
101
|
+
hierarchical(): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* Calls `visit` with the display index of every row the block cache holds data for (live levels only), each once,
|
|
104
|
+
* in no particular order: the rows `isLoaded` can answer true for (a new `selectable` re-checks only
|
|
105
|
+
* those). Bounded by the cache (`maxBlocks`), not by the row count. `visit` must not change the source.
|
|
106
|
+
*/
|
|
107
|
+
forEachLoaded(visit: (row: number) => void): void;
|
|
108
|
+
/**
|
|
109
|
+
* A loaded data row's fields as a plain object (the shape the write path builds); null for
|
|
110
|
+
* a row not loaded, failed or a group row. The object is a copy.
|
|
111
|
+
*/
|
|
112
|
+
loadedRow(row: number): Record<string, unknown> | null;
|
|
113
|
+
/**
|
|
114
|
+
* The display row of an open edit (−1 none), whose block every `ensureLoaded` keeps wanted after the
|
|
115
|
+
* range's, so scrolling far away never evicts it (`maxBlocks`) and the typed text keeps its row.
|
|
116
|
+
*/
|
|
117
|
+
holdRow(row: number): void;
|
|
118
|
+
}
|
|
119
|
+
/** The reader of a `serverSource`; null for any other source. Internal, like `cachedBlocks`. */
|
|
120
|
+
export declare function serverInternals(source: ViewportSource): ServerInternals | null;
|
|
121
|
+
/**
|
|
122
|
+
* Blocks holding data (loaded or stale) across all levels, detached stores included: the count `maxBlocks` bounds.
|
|
123
|
+
* `null` for a source that is not a `serverSource`. Exported through `@olvnck/ingrid/internal`, not public.
|
|
124
|
+
*/
|
|
125
|
+
export declare function cachedBlocks(source: ViewportSource): number | null;
|
|
126
|
+
/**
|
|
127
|
+
* Server-side rows: a tree of level stores (one per expanded path, columnar blocks), the expansion kept
|
|
128
|
+
* by path, and a block loader. The engine sees one flat list through `ViewportSource`.
|
|
129
|
+
*/
|
|
130
|
+
export declare function serverSource(datasource: ServerDatasource, options?: ServerSourceOptions): ServerSource;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/** Ascending order of two values: a field's `compare`, or `compareValues`. */
|
|
2
|
+
export type Comparator = (a: unknown, b: unknown) => number;
|
|
3
|
+
/** The aggregate functions every source knows; other names are the app's or the server's. */
|
|
4
|
+
export declare const BUILT_IN_AGGREGATES: readonly ["sum", "avg", "min", "max", "count"];
|
|
5
|
+
export declare function isBuiltInAggregate(fn: string): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* A built-in aggregate over a group's leaf values: 'count' counts every value; 'sum' and
|
|
8
|
+
* 'avg' take finite numbers and non-blank numeric strings, null when there is none; 'min' and 'max' order the
|
|
9
|
+
* non-blank values by `compare` (default `compareValues`; the first of equal values wins), null when there is none.
|
|
10
|
+
* Other names give undefined.
|
|
11
|
+
*/
|
|
12
|
+
export declare function aggregateValues(fn: string, values: readonly unknown[], compare?: Comparator): unknown;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { FieldFilter } from '../../source';
|
|
2
|
+
/** `lowered` = lowerCased(textOf(value)), for a scalar value only; the filter computes its own otherwise. */
|
|
3
|
+
export type FilterTest = (value: unknown, row: unknown, lowered?: string) => boolean;
|
|
4
|
+
export interface CompiledFilter {
|
|
5
|
+
test: FilterTest;
|
|
6
|
+
/** The caller may pass `lowered` for a scalar value: a text kind (or a multi with one) without caseSensitive. */
|
|
7
|
+
usesText: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface FilterContext {
|
|
10
|
+
filterTypes?: Readonly<Record<string, (model: unknown, value: unknown, row: never) => boolean>>;
|
|
11
|
+
report: (key: string, error: unknown) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Epoch ms of a non-blank value: a valid Date; a finite number (epoch ms); a string
|
|
15
|
+
* `YYYY-MM-DD` with an optional time (`hh:mm`, `:ss`, `.sss`, space or `T`) as local time, or with a `Z` / `±hh:mm`
|
|
16
|
+
* zone as that instant. Anything else: NaN.
|
|
17
|
+
*/
|
|
18
|
+
export declare function dateValue(value: unknown): number;
|
|
19
|
+
export declare function compileFilter(entry: FieldFilter, ctx: FilterContext): CompiledFilter;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Value order of the data sources: blanks (null, undefined, '') first, then numbers by
|
|
3
|
+
* value (NaN is no number here but the text 'NaN', like `keyOf`: it would tie with every number, which is not transitive), then everything else by its string form (code-unit order). Descending order negates it, so blanks come last
|
|
4
|
+
* there.
|
|
5
|
+
*/
|
|
6
|
+
export declare function compareValues(a: unknown, b: unknown): number;
|
|
7
|
+
/**
|
|
8
|
+
* The quick-filter text of a value: '' for null and undefined, strings as they are, numbers, booleans
|
|
9
|
+
* and bigints by String(), a valid Date by toISOString() (an invalid one ''), arrays as their items' texts joined by a
|
|
10
|
+
* space; any other object, a symbol or a function ''. Never throws.
|
|
11
|
+
*/
|
|
12
|
+
export declare function textOf(value: unknown): string;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** The parts `ColumnDef.groupHierarchy` takes. */
|
|
2
|
+
export declare const DATE_PARTS: readonly ["year", "quarter", "month", "formattedMonth", "day", "hour", "minute", "second"];
|
|
3
|
+
export type DatePart = (typeof DATE_PARTS)[number];
|
|
4
|
+
export declare function isDatePart(value: unknown): value is DatePart;
|
|
5
|
+
/** The field of `part` over `field` (a part column's field; also its id over the column's id). */
|
|
6
|
+
export declare function partField(part: DatePart, field: string): string;
|
|
7
|
+
/** `partField`'s parts; null for any other field. */
|
|
8
|
+
export declare function parsePartField(field: string): {
|
|
9
|
+
part: DatePart;
|
|
10
|
+
field: string;
|
|
11
|
+
} | null;
|
|
12
|
+
/**
|
|
13
|
+
* `part` of a date: a `Date` (its local components) or an ISO-8601 string (its components as written, no time-zone
|
|
14
|
+
* conversion, so a date-only string never shifts a day). `formattedMonth` gives the month number (its label is the
|
|
15
|
+
* name, its order chronological). Null for anything else, an invalid date and a component out of range.
|
|
16
|
+
*/
|
|
17
|
+
export declare function datePartOf(value: unknown, part: DatePart): number | null;
|
|
18
|
+
/** The name of month `month` (1–12) in `lang`; the number as text when `Intl` can't name it. */
|
|
19
|
+
export declare function monthName(month: number, lang: string): string;
|