@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,106 @@
|
|
|
1
|
+
import { type FieldFilter } from '../../source';
|
|
2
|
+
import type { GroupKey } from '../server/contract';
|
|
3
|
+
import { type FilterContext } from '../shared/columnFilter';
|
|
4
|
+
import type { Fields } from './fields';
|
|
5
|
+
import type { NodeRemap } from './remap';
|
|
6
|
+
/**
|
|
7
|
+
* The column filters over data nodes: `RowQuery.filter` as one mask, the AND of one mask per
|
|
8
|
+
* entry. Per field, its filter values (`Fields.filterColumn`) and, when a text test needs them, their lower-cased texts
|
|
9
|
+
* Are kept for the data version (`reset()`, another `nodes` array or count drop them), so a keystroke reads two
|
|
10
|
+
* arrays; a new array carries them by row identity (`carry`). Per entry, the compiled test (`compileFilter`) and
|
|
11
|
+
* its mask are cached by value (`entryKey`): changing one column's filter tests that column only.
|
|
12
|
+
*
|
|
13
|
+
* Two sides use the cache: the query (`mask`, `append`) and the set filter's values (`valuesMask`). Only
|
|
14
|
+
* what the last call of either side used stays: masks of entries neither side's last call used are
|
|
15
|
+
* evicted, so typing does not keep one mask per keystroke and the two sides do not evict each other while a set filter
|
|
16
|
+
* is open; so are the value and text columns of fields neither used (a value column is about 8 MB at 1M rows). The row
|
|
17
|
+
* masks skip every entry on the group column (`GROUP_FILTER_FIELD`): the built-in `groupSize` kind is evaluated by the
|
|
18
|
+
* pipeline's grouping pass (rule B; the set lists ignore it), a custom kind is ignored on client data
|
|
19
|
+
* with the source's one hint. Worker-safe: no Vue, no DOM.
|
|
20
|
+
*/
|
|
21
|
+
export declare class ColumnFilterMasks<T> {
|
|
22
|
+
private readonly fields;
|
|
23
|
+
private readonly ctx;
|
|
24
|
+
/** The nodes the columns and masks describe: nodes[0 … count − 1] (null: nothing held). */
|
|
25
|
+
private nodes;
|
|
26
|
+
private count;
|
|
27
|
+
/** Per field: its filter values. */
|
|
28
|
+
private values;
|
|
29
|
+
/** Per field: the lower-cased texts of its scalar filter values; built when a text test first needs them. */
|
|
30
|
+
private texts;
|
|
31
|
+
/** By entry key: the records the query's last call or the last values request used. */
|
|
32
|
+
private cache;
|
|
33
|
+
/** What the query's last call (`mask`, `append`) used. */
|
|
34
|
+
private query;
|
|
35
|
+
/** What the last values request (`valuesMask`) used, its listed field included. */
|
|
36
|
+
private request;
|
|
37
|
+
/** `testKey`'s tests for the entries and tree field it was last asked about (null: an entry is on another field). */
|
|
38
|
+
private keyEntries;
|
|
39
|
+
private keyField;
|
|
40
|
+
private keyTests;
|
|
41
|
+
constructor(fields: Fields<T>, ctx: FilterContext);
|
|
42
|
+
/** Drops every column and mask: the rows changed (`setData`, `refresh`). */
|
|
43
|
+
reset(): void;
|
|
44
|
+
/** Value columns are held: what `carry` keeps. */
|
|
45
|
+
holds(): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* The query's side: 1 per node of `nodes[0 … count − 1]` that passes every entry; null without entries (the group
|
|
48
|
+
* column's excepted). One entry: its cached mask as it is. Callers must not change the result.
|
|
49
|
+
*/
|
|
50
|
+
mask(nodes: readonly T[], count: number, entries: readonly FieldFilter[]): Uint8Array | null;
|
|
51
|
+
/**
|
|
52
|
+
* The set filter's side: the mask of a values request's `entries` (the other filters), as `mask`;
|
|
53
|
+
* `field`, the field whose values are listed, is read now and stays held with them (`column`), so the caller sees
|
|
54
|
+
* a held cache when it records the nodes' identities even when no other cache is held.
|
|
55
|
+
*/
|
|
56
|
+
valuesMask(nodes: readonly T[], count: number, entries: readonly FieldFilter[], field: string): Uint8Array | null;
|
|
57
|
+
/** `field`'s filter values over the nodes held (`Fields.filterColumn`, read on first use). */
|
|
58
|
+
column(field: string): readonly unknown[];
|
|
59
|
+
/**
|
|
60
|
+
* Rows from … to − 1 were appended to `nodes`, the array the masks hold, and the earlier rows did not change
|
|
61
|
+
* (`refresh({ appended })`): every held column is extended by the new rows (each belongs to a field in use),
|
|
62
|
+
* and each of `entries`' masks by testing them alone; the last values request's masks are dropped (its next
|
|
63
|
+
* call tests them again). Returns the mask for `entries` (null without entries), or undefined when the masks do not
|
|
64
|
+
* hold `nodes[0 … from − 1]` (the caller runs `mask` then).
|
|
65
|
+
*/
|
|
66
|
+
append(nodes: readonly T[], from: number, to: number, entries: readonly FieldFilter[]): Uint8Array | null | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Node `node` of `nodes` changed in place (a value write): its held filter values and texts are read
|
|
69
|
+
* again and every mask goes (a custom test may read any part of the row; the next call tests again over the held
|
|
70
|
+
* columns). True when masks went; false when none was held, or when nothing is held for `nodes`.
|
|
71
|
+
*/
|
|
72
|
+
rowChanged(nodes: readonly T[], node: number): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* A new data version whose nodes `r` matched to the ones held by row identity: the value and
|
|
75
|
+
* text columns (the fields in use) are carried, a new row's filter value computed from `r.values` (read once for
|
|
76
|
+
* every cache); the compiled tests stay, their masks are dropped (the next call tests again over the carried
|
|
77
|
+
* columns: an app test may depend on app state). Holding nothing: reset.
|
|
78
|
+
*/
|
|
79
|
+
carry(r: NodeRemap<T>): void;
|
|
80
|
+
/**
|
|
81
|
+
* A path filler's own result: a filler has no row, so it passes only when every
|
|
82
|
+
* entry is on the tree field and passes with the filler's key as the value (`row` undefined); no entries: true.
|
|
83
|
+
* The group column's entries are skipped, as in `mask`.
|
|
84
|
+
*/
|
|
85
|
+
testKey(entries: readonly FieldFilter[], treeField: string | null, key: GroupKey): boolean;
|
|
86
|
+
/** Starts over when `nodes` / `count` are not the ones held (another data version). */
|
|
87
|
+
private hold;
|
|
88
|
+
/** The AND of `entries`' masks over the nodes held, each computed once per record; recorded in `use`. */
|
|
89
|
+
private combine;
|
|
90
|
+
/** Drops the masks and columns neither side's last call used. */
|
|
91
|
+
private evict;
|
|
92
|
+
/**
|
|
93
|
+
* `entry`'s cache record: the one held for its key (when equal by value: the JSON key cannot tell every model
|
|
94
|
+
* apart, e.g. a custom model holding a Set), else a new one, compiled now. With `use`, the record is held under its
|
|
95
|
+
* key and the key recorded in `use`.
|
|
96
|
+
*/
|
|
97
|
+
private cached;
|
|
98
|
+
/**
|
|
99
|
+
* `c`'s mask over nodes 0 … to − 1: `prev` (nodes 0 … from − 1) copied, nodes from … to − 1 tested. Hot path (a
|
|
100
|
+
* keystroke in a filter over every row): one call of the compiled test per node over the held value column,
|
|
101
|
+
* with the lower-cased text column when the test takes it.
|
|
102
|
+
*/
|
|
103
|
+
private test;
|
|
104
|
+
private valuesOf;
|
|
105
|
+
private textsOf;
|
|
106
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Hierarchy } from './hierarchy';
|
|
2
|
+
import type { TreeShape } from './trees';
|
|
3
|
+
/** What the lists are built from: one pipeline output's structure. */
|
|
4
|
+
export interface StructureInput {
|
|
5
|
+
readonly dataCount: number;
|
|
6
|
+
readonly hierarchy: Hierarchy;
|
|
7
|
+
readonly shape: TreeShape<unknown> | null;
|
|
8
|
+
readonly groupValues: readonly (readonly unknown[])[] | null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The data descendants of the client source's nodes for row selection: every descendant with
|
|
12
|
+
* data, filtered-out ones included (`all`), the ones the filters pass (`passing`), and whether a data node has any
|
|
13
|
+
* (`hasData`, a tree parent: independent of filter and expansion). Built on first use per structure — a tree's shape,
|
|
14
|
+
* or grouped rows' hierarchy — and then O(1) per call: each node's descendants are one run of a depth-first order, and
|
|
15
|
+
* the list handed out for a node is kept (no allocation per drawn row while the structure stays). Flat rows and grouped
|
|
16
|
+
* rows' data nodes have none, without building anything.
|
|
17
|
+
*/
|
|
18
|
+
export declare class Descendants {
|
|
19
|
+
/** What `full` was built from: the tree's shape, or the grouped hierarchy. */
|
|
20
|
+
private fullFrom;
|
|
21
|
+
private full;
|
|
22
|
+
private passingFrom;
|
|
23
|
+
private passing;
|
|
24
|
+
private readonly lists;
|
|
25
|
+
private readonly passingLists;
|
|
26
|
+
/** Every data descendant of `node`, filtered-out ones included; never the node itself. */
|
|
27
|
+
all(o: StructureInput, node: number): Int32Array;
|
|
28
|
+
/** The data descendants of `node` the filters pass (shown once expanded); never the node itself. */
|
|
29
|
+
passingOf(o: StructureInput, node: number): Int32Array;
|
|
30
|
+
/** A data node with data descendants: a tree parent (grouped and flat rows have none). */
|
|
31
|
+
hasData(o: StructureInput, node: number): boolean;
|
|
32
|
+
/** The full structure when `node` can have descendants; null when it has none (flat rows, grouped data rows). */
|
|
33
|
+
private fullOf;
|
|
34
|
+
private passingIndex;
|
|
35
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type { Splice } from '../shared/splice';
|
|
2
|
+
import type { Splice } from '../shared/splice';
|
|
3
|
+
/** Above this many splice ranges a data change is announced as one `reset`. */
|
|
4
|
+
export declare const MAX_SPLICES = 256;
|
|
5
|
+
export type DiffResult = {
|
|
6
|
+
kind: 'splices';
|
|
7
|
+
splices: Splice[];
|
|
8
|
+
} | {
|
|
9
|
+
kind: 'reset';
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* The displayed order before and after a data or filter change, diffed by identity.
|
|
13
|
+
* Identities are compared with SameValueZero (Map keys). The longest subsequence of entries kept in the same relative
|
|
14
|
+
* order stays; every other entry is removed or inserted, a moved one as both. A duplicate identity matches at most
|
|
15
|
+
* once: the first occurrence in `next` takes the first occurrence in `prev`. Splices come top to bottom, each against
|
|
16
|
+
* the list the previous one left; more than `maxSplices` of them, or no identity in common (both lists non-empty),
|
|
17
|
+
* give a reset. `maxSplices` must be at least 1: an empty side (one list empty) returns its single splice without
|
|
18
|
+
* the cap.
|
|
19
|
+
*
|
|
20
|
+
* O(n log n): one Map over `prev`, then the longest increasing subsequence of the matched positions (patience sorting
|
|
21
|
+
* with a binary search per entry); typed arrays, no object per entry.
|
|
22
|
+
*/
|
|
23
|
+
export declare function diffOrders(prev: readonly unknown[], next: readonly unknown[], maxSplices?: number): DiffResult;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { Comparator } from '../shared/aggregate';
|
|
2
|
+
import type { FieldDef, Reporter } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Field access for the client pipeline: a field's getter or `row[field]`, its comparator, its
|
|
5
|
+
* quick-filter text and its filter value. App callbacks are isolated: a throwing
|
|
6
|
+
* one is reported once per field and kind, and falls back. So is a plain `row[field]` read, which runs app code when the
|
|
7
|
+
* property is an accessor (a class getter): reported once (key `value:<field>`), read as undefined. The loops
|
|
8
|
+
* over every row (`column`, `filterColumn`, the quick filter's haystacks) isolate those reads per loop, not per read,
|
|
9
|
+
* and go row by row only after a throw.
|
|
10
|
+
*/
|
|
11
|
+
export interface Fields<T> {
|
|
12
|
+
/**
|
|
13
|
+
* The getter's value or `row[field]`; a throwing getter or property read (an accessor) → reported once (key
|
|
14
|
+
* `value:<field>`), undefined.
|
|
15
|
+
*/
|
|
16
|
+
value(row: T, field: string): unknown;
|
|
17
|
+
/**
|
|
18
|
+
* The values of `nodes[from … count − 1]` (`from` default 0), one read per row; the pipeline keeps the column until
|
|
19
|
+
* the data changes, and extends it with appended rows' values.
|
|
20
|
+
*/
|
|
21
|
+
column(nodes: readonly T[], count: number, field: string, from?: number): unknown[];
|
|
22
|
+
/**
|
|
23
|
+
* `FieldDef.compare`, reduced to −1 / 0 / 1 (a number's sign; NaN: 0; other values coerce like `> 0`); a throwing call → reported once (key
|
|
24
|
+
* `compare:<field>`), "equal". Without one: `compareValues` itself, so callers can recognise the default.
|
|
25
|
+
*/
|
|
26
|
+
compare(field: string): Comparator;
|
|
27
|
+
/**
|
|
28
|
+
* `FieldDef.text` (a non-string result goes through `textOf`); a throwing call → reported once (key
|
|
29
|
+
* `text:<field>`), `textOf(value)`. Without one: `textOf(value)`.
|
|
30
|
+
*/
|
|
31
|
+
text(field: string, value: unknown, row: T): string;
|
|
32
|
+
/** `FieldDef.quickFilter !== false`. */
|
|
33
|
+
inQuickFilter(field: string): boolean;
|
|
34
|
+
/**
|
|
35
|
+
* The value column filters test: `FieldDef.filterValue(value(row, field), row)`, else
|
|
36
|
+
* `value(row, field)`. A throwing `filterValue` → reported once (key `filterValue:<field>`), undefined.
|
|
37
|
+
*/
|
|
38
|
+
filterValue(row: T, field: string): unknown;
|
|
39
|
+
/**
|
|
40
|
+
* `filterValue` of `nodes[from … count − 1]` (`from` default 0), as `column` reads values (one read per row, one
|
|
41
|
+
* try per column for the property reads); the column filters keep it until the data changes.
|
|
42
|
+
*/
|
|
43
|
+
filterColumn(nodes: readonly T[], count: number, field: string, from?: number): unknown[];
|
|
44
|
+
/**
|
|
45
|
+
* The filter values of `rows` whose values (`column`) were read already (`values[i]` is `rows[i]`'s): through
|
|
46
|
+
* `FieldDef.filterValue` (isolated, as `filterValue`), else `values` itself. A carry reads a new row once
|
|
47
|
+
* for every cache.
|
|
48
|
+
*/
|
|
49
|
+
filterValuesOf(field: string, values: readonly unknown[], rows: readonly T[]): readonly unknown[];
|
|
50
|
+
/**
|
|
51
|
+
* `text(field, value(row, field), row)` with the field resolved once, for loops over many rows. Hot path: a plain
|
|
52
|
+
* property read that throws escapes it unless `isolated` (then it is read as `value` reads it); a loop catches it
|
|
53
|
+
* once and goes on with isolated parts (`QuickFilterIndex`).
|
|
54
|
+
*/
|
|
55
|
+
haystackPart(field: string, isolated?: boolean): (row: T) => string;
|
|
56
|
+
/**
|
|
57
|
+
* No `value` getter and no `text`: the field's quick-filter text is `textOf(row[field])`, which a loop over many
|
|
58
|
+
* rows may read directly (hot path, `QuickFilterIndex`); a throwing property read escapes such a loop as it escapes
|
|
59
|
+
* `haystackPart`.
|
|
60
|
+
*/
|
|
61
|
+
plain(field: string): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The field has a `value` getter: its value is computed, so a plain write of `row[field]` would not change it
|
|
64
|
+
* (such a column is written only through `ColumnDef.setValue`).
|
|
65
|
+
*/
|
|
66
|
+
computed(field: string): boolean;
|
|
67
|
+
}
|
|
68
|
+
/** `row[field]`; a hole or a null row reads as undefined. */
|
|
69
|
+
export declare function own(row: unknown, field: string): unknown;
|
|
70
|
+
export declare function createFields<T>(defs: Readonly<Record<string, FieldDef<T>>> | undefined, report: Reporter): Fields<T>;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import type { QuickFilterQuery } from '../../source';
|
|
2
|
+
import type { GroupKey } from '../server/contract';
|
|
3
|
+
import type { Fields } from './fields';
|
|
4
|
+
import type { NodeRemap } from './remap';
|
|
5
|
+
import type { TreeShape } from './trees';
|
|
6
|
+
import type { Reporter } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* The quick filter over data nodes. A node's haystack is the texts of the query fields that take
|
|
9
|
+
* part (`FieldDef.quickFilter !== false`), joined by '\n' (no word holds whitespace, so none spans two fields) and
|
|
10
|
+
* lower-cased (`lowerCased`). Haystacks are built on the first search after a change and kept until `reset()`
|
|
11
|
+
* (`refresh`, `setData` with the same array), another `nodes` array or count, or another field list; appended rows
|
|
12
|
+
* extend them (`append`), a new array carries them by row identity (`carry`). Typing narrows: while
|
|
13
|
+
* every previous word is part of a new word, only the nodes the previous text kept are tested again.
|
|
14
|
+
*/
|
|
15
|
+
export declare class QuickFilterIndex<T> {
|
|
16
|
+
private readonly fields;
|
|
17
|
+
private haystacks;
|
|
18
|
+
private nodes;
|
|
19
|
+
private count;
|
|
20
|
+
/** The searched fields the haystacks were built from. */
|
|
21
|
+
private list;
|
|
22
|
+
/** The last mask and its words: the base for narrowing (null: nothing to narrow from). */
|
|
23
|
+
private last;
|
|
24
|
+
private lastWords;
|
|
25
|
+
/** matchesKey's words, by text (fillers are tested one at a time). */
|
|
26
|
+
private keyText;
|
|
27
|
+
private keyWords;
|
|
28
|
+
constructor(fields: Fields<T>);
|
|
29
|
+
/** Drops the haystacks and the narrowing base: the rows changed (`setData`, `refresh`). */
|
|
30
|
+
reset(): void;
|
|
31
|
+
/** Haystacks are held: what `carry` keeps. */
|
|
32
|
+
holds(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* A new data version whose nodes `r` matched to the ones the index holds by row identity: a kept node
|
|
35
|
+
* keeps its haystack, a new row's is built from `r.values` (each field read once for every cache, as `build` would
|
|
36
|
+
* read it); the narrowing base is dropped. Without haystacks the index is reset instead.
|
|
37
|
+
*/
|
|
38
|
+
carry(r: NodeRemap<T>): void;
|
|
39
|
+
/**
|
|
40
|
+
* 1 per node of `nodes[0 … count − 1]` that matches every word; null without words (the quick filter is off). The
|
|
41
|
+
* mask is also the next call's narrowing base: callers must not change it.
|
|
42
|
+
*/
|
|
43
|
+
mask(nodes: readonly T[], count: number, query: QuickFilterQuery | null): Uint8Array | null;
|
|
44
|
+
/**
|
|
45
|
+
* Rows from … to − 1 were appended to `nodes`, the array the index holds, and the earlier rows did not change
|
|
46
|
+
* (`refresh({ appended })`): their haystacks join the cached ones (when there are any) and the last mask is
|
|
47
|
+
* extended by testing the new rows alone. Returns the mask for `query` (null while the quick filter is off), or
|
|
48
|
+
* undefined when the index does not hold `query`'s mask over `nodes[0 … from − 1]` (the caller runs the whole
|
|
49
|
+
* filter then).
|
|
50
|
+
*/
|
|
51
|
+
append(nodes: readonly T[], from: number, to: number, query: QuickFilterQuery | null): Uint8Array | null | undefined;
|
|
52
|
+
/**
|
|
53
|
+
* Node `node` of `nodes` changed in place (a value write): its haystack is built again. True when it
|
|
54
|
+
* changed, and then the narrowing base goes too (the node may match words it did not); false when it did not, or
|
|
55
|
+
* when the index holds no haystacks for `nodes` (the next search builds them all).
|
|
56
|
+
*/
|
|
57
|
+
rowChanged(nodes: readonly T[], node: number): boolean;
|
|
58
|
+
/**
|
|
59
|
+
* A filler's own test: its haystack is its key's text when `treeField` is a searched query field
|
|
60
|
+
* (a filler has no row, so `FieldDef.text` does not apply), else empty. True while the quick filter is off.
|
|
61
|
+
*/
|
|
62
|
+
matchesKey(key: GroupKey, query: QuickFilterQuery | null, treeField: string | null): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Every node's haystack, in one pass (an un-narrowed search reads them all anyway). Hot path (the first keystroke
|
|
65
|
+
* after a data change): a plain field (no getter, no text function) is read directly
|
|
66
|
+
* (`row[field]`, a string as it is, else `textOf`), the others through `Fields.haystackPart`; a row's texts are
|
|
67
|
+
* joined once (`Array.join`: in JSC about a third cheaper than `+=` per text) and lower-cased once. One try for
|
|
68
|
+
* the pass, not one per read; after a throw (a row property that is a throwing accessor) the pass starts that
|
|
69
|
+
* row again with every property read isolated (`Fields.haystackPart`) and goes on that way. A throw that is no
|
|
70
|
+
* property read (`textOf`) escapes on the retry. `start`: the first node built (appended rows); the result
|
|
71
|
+
* holds nodes start … count − 1.
|
|
72
|
+
*/
|
|
73
|
+
private build;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* The app's predicate as a mask; null without one. A throwing call is reported once (key 'filter') and
|
|
77
|
+
* lets its row pass. `prev`: the mask of nodes 0 … prev.length − 1 when only the nodes after
|
|
78
|
+
* them are new (appended rows): copied, and the predicate asked for the new nodes alone.
|
|
79
|
+
*/
|
|
80
|
+
export declare function predicateMask<T>(nodes: readonly T[], count: number, predicate: ((row: T) => boolean) | null, report: Reporter, prev?: Uint8Array | null): Uint8Array | null;
|
|
81
|
+
/**
|
|
82
|
+
* The masks (same length) ANDed; null passes everything. Returns the one non-null mask as it is (masks are never
|
|
83
|
+
* written into: each belongs to its stage's cache), else a new mask; null when every mask is null.
|
|
84
|
+
*/
|
|
85
|
+
export declare function combineMasks(...masks: (Uint8Array | null)[]): Uint8Array | null;
|
|
86
|
+
/**
|
|
87
|
+
* Which tree nodes are shown under a filter: a node is shown when it passes, when one of its
|
|
88
|
+
* descendants passes (an ancestor of a match), or — `keepDescendants` — when one of its ancestors passes (the whole
|
|
89
|
+
* subtree of a match). Dropped rows never are. `pass` covers every node, fillers included; the caller builds it
|
|
90
|
+
* (the pipeline): data nodes — `combineMasks(quick mask, predicate mask, column mask)`, 1 where all are null;
|
|
91
|
+
* fillers — `predicate === null && quick.matchesKey(key, query, treeField) && columns.testKey(filter, treeField, key)`
|
|
92
|
+
* (a filler has no row: a set predicate cannot accept it, a column filter tests its key only on the tree field).
|
|
93
|
+
* Without any filter the caller skips this (visible = null). O(nodes): every walk stops at a node already decided.
|
|
94
|
+
*/
|
|
95
|
+
export declare function treeVisibility(shape: TreeShape<unknown>, pass: Uint8Array, keepDescendants: boolean): Uint8Array;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import type { Splice } from '../shared/splice';
|
|
2
|
+
import type { Hierarchy } from './hierarchy';
|
|
3
|
+
/** A displayed order: `flat[0 … size)` holds the node of each row; the buffer may be longer than `size`. */
|
|
4
|
+
export interface FlatList {
|
|
5
|
+
readonly flat: Int32Array;
|
|
6
|
+
readonly size: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Where a node's total row sits while the node is open — `TOTAL_TOP` its first displayed child,
|
|
10
|
+
* `TOTAL_BOTTOM` its last, `TOTAL_NONE` no total row. The client source's `place(node)` answers it.
|
|
11
|
+
*/
|
|
12
|
+
export declare const TOTAL_NONE = 0;
|
|
13
|
+
export declare const TOTAL_TOP = 1;
|
|
14
|
+
export declare const TOTAL_BOTTOM = 2;
|
|
15
|
+
export type TotalPlace = typeof TOTAL_NONE | typeof TOTAL_TOP | typeof TOTAL_BOTTOM;
|
|
16
|
+
/**
|
|
17
|
+
* The node number of node `n`'s total row in a `FlatOrder`: past the hierarchy's nodes and its virtual top node
|
|
18
|
+
* (the grand total's number), `nodeCount + 1 + n`.
|
|
19
|
+
*/
|
|
20
|
+
export declare function totalNodeOf(h: Hierarchy, n: number): number;
|
|
21
|
+
/** The node whose total row has node number `t`; −1 when `t` is not a group total's number. */
|
|
22
|
+
export declare function ownerOfTotal(h: Hierarchy, t: number): number;
|
|
23
|
+
/**
|
|
24
|
+
* The displayed rows of a hierarchy: a depth-first walk over the ordered children of expanded nodes writes
|
|
25
|
+
* `flat` (row → node). Expanding or collapsing one node moves the tail with `copyWithin` and gives one splice at the
|
|
26
|
+
* row after it; `rowOf` uses an inverse built on first use and kept current by later toggles.
|
|
27
|
+
*
|
|
28
|
+
* Costs (they matter at 100k–1M rows): `rebuild` O(nodes); `toggle` O(rows after the node + rows of its subtree);
|
|
29
|
+
* `rowOf` O(1) after an O(rows + nodes) build; no allocation per row (two row buffers, used in turn).
|
|
30
|
+
*
|
|
31
|
+
* With a `place` an open node's total row is a row of its own, numbered `totalNodeOf(h, node)`,
|
|
32
|
+
* right after the node (`TOTAL_TOP`) or after its displayed descendants (`TOTAL_BOTTOM`), one level deeper than the
|
|
33
|
+
* node. It is no child of the node in the hierarchy, so positions and counts among siblings stay as they are.
|
|
34
|
+
*/
|
|
35
|
+
export declare class FlatOrder implements FlatList {
|
|
36
|
+
private rows;
|
|
37
|
+
private count;
|
|
38
|
+
/** The other row buffer: the list before the last rebuild, then scratch space for a subtree being inserted. */
|
|
39
|
+
private spare;
|
|
40
|
+
private h;
|
|
41
|
+
private ordered;
|
|
42
|
+
private expanded;
|
|
43
|
+
/** Where an open node's total row sits; null: no total rows. */
|
|
44
|
+
private place;
|
|
45
|
+
/** Node numbers a row may hold: the hierarchy's, and with a `place` its total rows' too (`2 · nodeCount + 1`). */
|
|
46
|
+
private limit;
|
|
47
|
+
/** Per node: −1 = not asked yet, 0 = collapsed, 1 = expanded. */
|
|
48
|
+
private open;
|
|
49
|
+
/** Per node: position among its visible siblings. */
|
|
50
|
+
private pos;
|
|
51
|
+
/** Node → row (−1 = not displayed); valid while `inverseValid`. */
|
|
52
|
+
private inverse;
|
|
53
|
+
private inverseValid;
|
|
54
|
+
/** The walk's stack: a node and the next of its children to visit (no recursion: trees can be 100k deep). */
|
|
55
|
+
private stackNode;
|
|
56
|
+
private stackNext;
|
|
57
|
+
get flat(): Int32Array;
|
|
58
|
+
get size(): number;
|
|
59
|
+
/**
|
|
60
|
+
* Writes the displayed rows of `h` from scratch. `expanded(node)` is asked lazily — at most once per node, only for
|
|
61
|
+
* nodes with visible children, when a walk (this one or a later toggle) reaches the node — so it must answer the
|
|
62
|
+
* current expansion state. The list from before the call stays readable in the other buffer until the next
|
|
63
|
+
* `rebuild` or `toggle`: `{ flat, size }` taken before it is a valid `runSplices` input. `place(node)`:
|
|
64
|
+
* where an open node's total row sits, asked for nodes with visible children only; null (and always on flat rows):
|
|
65
|
+
* no total rows.
|
|
66
|
+
*/
|
|
67
|
+
rebuild(h: Hierarchy, ordered: Int32Array, expanded: (node: number) => boolean, place?: ((node: number) => TotalPlace) | null): void;
|
|
68
|
+
/**
|
|
69
|
+
* Expands or collapses `node`: the splice of the displayed rows, at the row after the node — its total
|
|
70
|
+
* row included. The state of any node is recorded; the result is null, and no row moves, when the state
|
|
71
|
+
* does not change, the node has no visible children, or it is not displayed (a later toggle of an ancestor shows it
|
|
72
|
+
* in this state).
|
|
73
|
+
*/
|
|
74
|
+
toggle(node: number, expanded: boolean): Splice | null;
|
|
75
|
+
/**
|
|
76
|
+
* The displayed row of `node` (a total row's number included); −1 when it is not displayed (filtered out, or
|
|
77
|
+
* inside a collapsed parent).
|
|
78
|
+
*/
|
|
79
|
+
rowOf(node: number): number;
|
|
80
|
+
/**
|
|
81
|
+
* Position among its visible siblings (aria-posinset − 1); −1 for a node that is out of range or not shown (filtered
|
|
82
|
+
* out), and for a total row (no sibling). A node inside a collapsed parent still has its position among its
|
|
83
|
+
* siblings.
|
|
84
|
+
*/
|
|
85
|
+
posInLevel(node: number): number;
|
|
86
|
+
/**
|
|
87
|
+
* Number of visible siblings, itself included (aria-setsize); 0 for a node that is out of range or not shown, and
|
|
88
|
+
* for a total row. A total row is counted nowhere: its group's siblings keep their numbers.
|
|
89
|
+
*/
|
|
90
|
+
levelSize(node: number): number;
|
|
91
|
+
/** Visible children — its total row not among them; 0 for a node that is out of range or not shown. */
|
|
92
|
+
childCount(node: number): number;
|
|
93
|
+
/** The state the last rebuild or toggle used (asked now when no walk has needed it yet). */
|
|
94
|
+
isExpanded(node: number): boolean;
|
|
95
|
+
private isOpen;
|
|
96
|
+
/**
|
|
97
|
+
* Writes the displayed rows below `root` (its open descendants, depth-first) into `spare`; returns how many. With a
|
|
98
|
+
* `place`, each open node's total row goes right after it or after its descendants — `root`'s own too, unless it is
|
|
99
|
+
* the top level (whose total, the grand total, is the source's offset).
|
|
100
|
+
*/
|
|
101
|
+
private subtree;
|
|
102
|
+
private reserveStack;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Every node of the hierarchy, depth-first in its order, as if everything were expanded (filteredRows, dfsRank).
|
|
106
|
+
* The result has `childStart[nodeCount + 1]` entries (every shown node once), allocated once.
|
|
107
|
+
*
|
|
108
|
+
* With a `place`, each node with visible children also has its total row, numbered
|
|
109
|
+
* `totalNodeOf(h, node)`, where `FlatOrder` writes it once the node is open — right after the node (`TOTAL_TOP`) or
|
|
110
|
+
* after its descendants (`TOTAL_BOTTOM`) — so every displayed list is a subsequence of this order whatever is open
|
|
111
|
+
* (`runSplices`, the as-if-open export walk). `place` is asked for every such node; the top level's total, the grand
|
|
112
|
+
* total, is the source's offset and not in this order. Null (and always on flat rows): no total rows, the walk
|
|
113
|
+
* as before.
|
|
114
|
+
*
|
|
115
|
+
* Invariant (all builders satisfy it): every shown node is reachable from the top, and `h.level` is its depth in
|
|
116
|
+
* the CSR (`childStart` / `ordered`) structure, so a stack of `maxLevel + 2` entries is enough. A hierarchy that
|
|
117
|
+
* breaks it (a cycle, a stale `level`) must not hang: the stack grows when a level is too small, and a walk that
|
|
118
|
+
* writes more nodes than `childStart` counts (plus one total row per node with children) throws; one that reaches
|
|
119
|
+
* fewer gives the entries written.
|
|
120
|
+
*/
|
|
121
|
+
export declare function depthFirst(h: Hierarchy, ordered: Int32Array, place?: ((node: number) => TotalPlace) | null): Int32Array;
|
|
122
|
+
/**
|
|
123
|
+
* The splices that turn `before` into `after` when both are subsequences of one depth-first order (expand-all,
|
|
124
|
+
* collapse-all, setExpansion, reveal): one splice per maximal run of rows that appeared or disappeared, top
|
|
125
|
+
* to bottom, each against the list the previous one left. `dfsRank[node]` is the node's position in that order — with
|
|
126
|
+
* total rows the order `depthFirst` writes with the same `place`, so a group's total comes and goes in
|
|
127
|
+
* the run of its rows. O(n), one merge pass.
|
|
128
|
+
*/
|
|
129
|
+
export declare function runSplices(before: FlatList, after: FlatList, dfsRank: Int32Array): Splice[];
|
|
130
|
+
/** `mergeRuns`' result: the splices, and whether a row is in both lists. */
|
|
131
|
+
export interface Runs {
|
|
132
|
+
splices: Splice[];
|
|
133
|
+
shared: boolean;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* `runSplices`' merge for any order both lists follow (`rank[node]`: the node's position in it): also flat rows under
|
|
137
|
+
* a filter change or an append, whose permutation did not change. A node in both lists is kept, the
|
|
138
|
+
* others are removed or inserted, so the result equals `diffOrders` over the rows' identities whenever no identity is
|
|
139
|
+
* held by two nodes, in O(before + after) without a Map. Null once more than `maxSplices` splices are needed.
|
|
140
|
+
*/
|
|
141
|
+
export declare function mergeRuns(before: FlatList, after: FlatList, rank: Int32Array, maxSplices: number): Runs | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type FieldFilter } from '../../source';
|
|
2
|
+
import type { Hierarchy } from './hierarchy';
|
|
3
|
+
/**
|
|
4
|
+
* The query's built-in group-size entry (kind `groupSize` on the group column), or null. An entry of
|
|
5
|
+
* an app-defined kind on the group column is not one: client data ignores it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function groupSizeEntry(filter: readonly FieldFilter[]): FieldFilter | null;
|
|
8
|
+
/**
|
|
9
|
+
* The data nodes inside innermost groups whose row count passes `test` (1), the rest 0 (rule B). `h` is a
|
|
10
|
+
* grouped hierarchy built from the rows the other filters pass: its innermost groups (level `groupFields.length − 1`)
|
|
11
|
+
* hold data nodes only, so a group's child count is its row count after those filters, and every 1 is a row they
|
|
12
|
+
* passed. Null when every group passes (`>0`): nothing is removed, `h` is the grouping already. O(nodes).
|
|
13
|
+
*/
|
|
14
|
+
export declare function groupSizeMask(h: Hierarchy, dataCount: number, test: (count: number) => boolean): Uint8Array | null;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { QueryAggregate } from '../../source';
|
|
2
|
+
import type { GroupKey } from '../server/contract';
|
|
3
|
+
import { type Comparator } from '../shared/aggregate';
|
|
4
|
+
import type { TreeShape } from './trees';
|
|
5
|
+
import type { Reporter } from './types';
|
|
6
|
+
/**
|
|
7
|
+
* The displayed structure before expansion, as typed arrays indexed by node. Data nodes are
|
|
8
|
+
* 0 … dataCount − 1 (the input positions; a nested tree's depth-first positions); group nodes and path fillers
|
|
9
|
+
* are numbered after them. Children are one CSR pair; the top level is the virtual node `nodeCount`. Built once per
|
|
10
|
+
* pipeline run and cached by the pipeline: nothing changes it afterwards.
|
|
11
|
+
*/
|
|
12
|
+
export interface Hierarchy {
|
|
13
|
+
dataCount: number;
|
|
14
|
+
/** Data nodes + synthetic nodes (group nodes or path fillers), numbered after the data. */
|
|
15
|
+
nodeCount: number;
|
|
16
|
+
/** Per node: parent node, −1 = top level, −2 = not shown (filtered out or dropped). */
|
|
17
|
+
parent: Int32Array;
|
|
18
|
+
/** Depth, 0 = top. */
|
|
19
|
+
level: Int32Array;
|
|
20
|
+
/** Group nodes, fillers and tree data nodes: their key; else undefined (flat: an empty array). */
|
|
21
|
+
keys: readonly (GroupKey | undefined)[];
|
|
22
|
+
/** Length nodeCount + 2; the top level is the virtual node `nodeCount`. */
|
|
23
|
+
childStart: Int32Array;
|
|
24
|
+
/** Visible children of n = children[childStart[n] … childStart[n + 1]). */
|
|
25
|
+
children: Int32Array;
|
|
26
|
+
/** Grouping: a group node's field is groupFields[level]; else null. */
|
|
27
|
+
groupFields: readonly string[] | null;
|
|
28
|
+
tree: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Per node: data nodes themselves; synthetic nodes their smallest data descendant (input position). The set of
|
|
31
|
+
* descendants differs by mode under a filter: grouping covers the passing rows only (groups are built from
|
|
32
|
+
* them); trees cover all non-dropped descendants, filtered-out ones included, so a filler keeps its place in an
|
|
33
|
+
* unsorted, filtered tree while the user types.
|
|
34
|
+
*/
|
|
35
|
+
firstData: Int32Array;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Field → aggregate per node (undefined where a node has none), for every field of the query's aggregates (the first
|
|
39
|
+
* entry per field wins), plus each field's function: `orderHierarchy` compares min / max by the field's comparator
|
|
40
|
+
* and the other results by `compareValues`. Flat rows have no per-node entries.
|
|
41
|
+
*/
|
|
42
|
+
export interface AggregateValues extends ReadonlyMap<string, readonly unknown[]> {
|
|
43
|
+
readonly fns: ReadonlyMap<string, string>;
|
|
44
|
+
/**
|
|
45
|
+
* Field → the virtual top node's aggregate (every visible leaf: the grand total's values), only when
|
|
46
|
+
* asked; null otherwise.
|
|
47
|
+
*/
|
|
48
|
+
readonly top: ReadonlyMap<string, unknown> | null;
|
|
49
|
+
}
|
|
50
|
+
/** No aggregates (flat rows without a grand total, or a query without any). */
|
|
51
|
+
export declare const NO_AGGREGATES: AggregateValues;
|
|
52
|
+
/**
|
|
53
|
+
* Flat rows: the passing rows in permutation order at the top level. Hot path (every filter change and
|
|
54
|
+
* append over flat rows): two passes and no per-node child lists — the top
|
|
55
|
+
* level's list is the permutation without the rows the mask drops.
|
|
56
|
+
*/
|
|
57
|
+
export declare function flatHierarchy(dataCount: number, perm: Int32Array, mask: Uint8Array | null): Hierarchy;
|
|
58
|
+
/**
|
|
59
|
+
* Row grouping: one walk over the permutation buckets each passing row level by level by `keyOf` of its
|
|
60
|
+
* grouped field; a group node is created at its first row, so every leaf list comes out in permutation order. Blank
|
|
61
|
+
* keys (`null`, `''`) are separate groups; `undefined` is `null`. A key that had to be converted (not a string,
|
|
62
|
+
* finite number or boolean) is reported once per field (key `group:<field>`). An empty `groupBy` gives `flatHierarchy`.
|
|
63
|
+
*/
|
|
64
|
+
export declare function groupHierarchy(dataCount: number, perm: Int32Array, mask: Uint8Array | null, groupBy: readonly string[], column: (field: string) => readonly unknown[], report: Reporter): Hierarchy;
|
|
65
|
+
/**
|
|
66
|
+
* The keys of a node's ancestors, plus its own key when it has one (the expansion paths): grouping — the group
|
|
67
|
+
* keys; trees — the chain of node keys (path shape: the data path itself); flat rows — [].
|
|
68
|
+
*/
|
|
69
|
+
export declare function pathOfNode(h: Hierarchy, node: number): GroupKey[];
|
|
70
|
+
/**
|
|
71
|
+
* Aggregates for every group node and every shown tree node with visible children, over its visible
|
|
72
|
+
* leaf descendants — data nodes only (a filler has no value), a tree node with visible children never with its own
|
|
73
|
+
* value — in input order (sums equal memoryDatasource's whatever the sort). Built-in names win over custom ones; min /
|
|
74
|
+
* max use the field's comparator. An unknown name gives undefined, reported once (key `aggregate:<fn>`); a function
|
|
75
|
+
* that throws gives undefined for that node, reported once (key `aggregate:<fn>`). `top` (only while a grand total
|
|
76
|
+
* is asked): also the virtual top node, over every visible leaf by the same rules —
|
|
77
|
+
* grouped, tree and flat rows alike (flat rows get only that one).
|
|
78
|
+
*/
|
|
79
|
+
export declare function computeAggregates(h: Hierarchy, aggregates: readonly QueryAggregate[], column: (field: string) => readonly unknown[], compare: (field: string) => Comparator, custom: Readonly<Record<string, (values: readonly unknown[]) => unknown>>, report: Reporter, top?: boolean): AggregateValues;
|
|
80
|
+
/**
|
|
81
|
+
* A tree's displayed structure: the shape's nodes, the ones `visible` excludes (or the shape dropped) not
|
|
82
|
+
* shown; each node's visible children with the data nodes in permutation order (`rank`) and the fillers after them —
|
|
83
|
+
* `orderHierarchy` places the fillers. Depths by a breadth-first walk over the visible children. O(nodes).
|
|
84
|
+
*/
|
|
85
|
+
export declare function treeHierarchy(shape: TreeShape<unknown>, visible: Uint8Array | null, rank: Int32Array): Hierarchy;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { QuerySort } from '../../source';
|
|
2
|
+
import type { Comparator } from '../shared/aggregate';
|
|
3
|
+
import type { AggregateValues, Hierarchy } from './hierarchy';
|
|
4
|
+
import type { Reporter } from './types';
|
|
5
|
+
/**
|
|
6
|
+
* The sort permutation over all data rows: an `Int32Array` of row indices ordered by `sort` with the
|
|
7
|
+
* fields' comparators, descending negated. Each sorted field's values are read once (`column`); ties fall to the row
|
|
8
|
+
* index, so the order is stable whatever the engine's sort is. Without a sort: the identity (input order). A
|
|
9
|
+
* NaN value sorts as the text 'NaN'; a custom comparator's NaN counts as a tie. O(n log n) comparisons.
|
|
10
|
+
*/
|
|
11
|
+
export declare function sortPermutation(count: number, sort: readonly QuerySort[], column: (field: string) => readonly unknown[], compare: (field: string) => Comparator): Int32Array;
|
|
12
|
+
/**
|
|
13
|
+
* The permutation of data nodes 0 … to − 1, given `perm`, the permutation of nodes 0 … from − 1 under the same `sort`
|
|
14
|
+
* (appended rows; `column` holds every node's values): the new nodes sorted among themselves, then each placed
|
|
15
|
+
* by a binary search, with `sortPermutation`'s comparators and tie-break (the node index), so the result equals
|
|
16
|
+
* sorting all nodes again. O(k log k + k log n) comparisons for k new nodes, values compared as they are (no keys:
|
|
17
|
+
* there are too few comparisons for keys to pay), plus one copy of `perm`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function insertSorted(perm: Int32Array, from: number, to: number, sort: readonly QuerySort[], column: (field: string) => readonly unknown[], compare: (field: string) => Comparator): Int32Array;
|
|
20
|
+
/** rank[node] = the node's position in `perm`. */
|
|
21
|
+
export declare function rankOf(perm: Int32Array): Int32Array;
|
|
22
|
+
/**
|
|
23
|
+
* The ordered children: a new array beside `h.childStart` (the cached hierarchy is not changed). Flat rows
|
|
24
|
+
* keep permutation order. Grouping: every list of group nodes by the group order (see groupComparator); leaf lists keep
|
|
25
|
+
* permutation order. Trees: siblings keep permutation order (`rank`); a filler is placed among them by the same sort —
|
|
26
|
+
* its key is its value for `treeField`, it has no value in any other field — and, without a sort or on ties, at its
|
|
27
|
+
* first data descendant's input position (`h.firstData`); a sort on an aggregated field orders a node with visible
|
|
28
|
+
* children by the aggregate it shows (see orderSiblings). `column(field)` gives the data nodes' values of a
|
|
29
|
+
* field. A sibling list whose comparison throws keeps its order; `report` gets one report per key and call
|
|
30
|
+
* however many lists throw.
|
|
31
|
+
*/
|
|
32
|
+
export declare function orderHierarchy(h: Hierarchy, sort: readonly QuerySort[], aggregates: AggregateValues, compare: (field: string) => Comparator, rank: Int32Array, treeField: string | null, column: (field: string) => readonly unknown[], report: Reporter): Int32Array;
|