@pretable/core 0.20.2 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +588 -268
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +56 -52
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +56 -52
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +588 -268
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
|
|
2
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
3
3
|
function _typeof(o) {
|
|
4
4
|
"@babel/helpers - typeof";
|
|
5
5
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -9,28 +9,25 @@ function _typeof(o) {
|
|
|
9
9
|
}, _typeof(o);
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
function toPrimitive(t, r) {
|
|
12
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
13
|
+
function toPrimitive(t, e) {
|
|
15
14
|
if ("object" != _typeof(t) || !t) return t;
|
|
16
|
-
var
|
|
17
|
-
if (void 0 !==
|
|
18
|
-
var i =
|
|
15
|
+
var r;
|
|
16
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
17
|
+
var i = r.call(t, e || "default");
|
|
19
18
|
if ("object" != _typeof(i)) return i;
|
|
20
19
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
21
20
|
}
|
|
22
|
-
return ("string" ===
|
|
21
|
+
return ("string" === e ? String : Number)(t);
|
|
23
22
|
}
|
|
24
23
|
|
|
25
|
-
|
|
26
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/toPropertyKey.js
|
|
24
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
27
25
|
function toPropertyKey(t) {
|
|
28
26
|
var i = toPrimitive(t, "string");
|
|
29
27
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
30
28
|
}
|
|
31
29
|
|
|
32
|
-
|
|
33
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/defineProperty.js
|
|
30
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
34
31
|
function _defineProperty(e, r, t) {
|
|
35
32
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
36
33
|
value: t,
|
|
@@ -40,45 +37,38 @@ function _defineProperty(e, r, t) {
|
|
|
40
37
|
}) : e[r] = t, e;
|
|
41
38
|
}
|
|
42
39
|
|
|
43
|
-
|
|
44
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/checkPrivateRedeclaration.js
|
|
40
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/checkPrivateRedeclaration.js
|
|
45
41
|
function _checkPrivateRedeclaration(e, t) {
|
|
46
42
|
if (t.has(e)) throw new TypeError("Cannot initialize the same private elements twice on an object");
|
|
47
43
|
}
|
|
48
44
|
|
|
49
|
-
|
|
50
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateMethodInitSpec.js
|
|
45
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/classPrivateMethodInitSpec.js
|
|
51
46
|
function _classPrivateMethodInitSpec(e, a) {
|
|
52
47
|
_checkPrivateRedeclaration(e, a), a.add(e);
|
|
53
48
|
}
|
|
54
49
|
|
|
55
|
-
|
|
56
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
50
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/classPrivateFieldInitSpec.js
|
|
57
51
|
function _classPrivateFieldInitSpec(e, t, a) {
|
|
58
52
|
_checkPrivateRedeclaration(e, t), t.set(e, a);
|
|
59
53
|
}
|
|
60
54
|
|
|
61
|
-
|
|
62
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/assertClassBrand.js
|
|
55
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/assertClassBrand.js
|
|
63
56
|
function _assertClassBrand(e, t, n) {
|
|
64
57
|
if ("function" == typeof e ? e === t : e.has(t)) return arguments.length < 3 ? t : n;
|
|
65
58
|
throw new TypeError("Private element is not present on this object");
|
|
66
59
|
}
|
|
67
60
|
|
|
68
|
-
|
|
69
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldSet2.js
|
|
61
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/classPrivateFieldSet2.js
|
|
70
62
|
function _classPrivateFieldSet2(s, a, r) {
|
|
71
63
|
return s.set(_assertClassBrand(s, a), r), r;
|
|
72
64
|
}
|
|
73
65
|
|
|
74
|
-
|
|
75
|
-
//#region \0@oxc-project+runtime@0.143.0/helpers/esm/classPrivateFieldGet2.js
|
|
66
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/classPrivateFieldGet2.js
|
|
76
67
|
function _classPrivateFieldGet2(s, a) {
|
|
77
68
|
return s.get(_assertClassBrand(s, a));
|
|
78
69
|
}
|
|
79
70
|
|
|
80
|
-
|
|
81
|
-
//#region ../layout-core/dist/dense-membership.js
|
|
71
|
+
// ../layout-core/dist/dense-membership.js
|
|
82
72
|
/**
|
|
83
73
|
* Membership bitset: one bit per dense key (row-model SLOT). Duplicated from
|
|
84
74
|
* `@pretable-internal/row-model`'s `membership-bitset.ts` BY DESIGN —
|
|
@@ -111,8 +101,7 @@ function testDenseBit(bits, slot) {
|
|
|
111
101
|
return word === void 0 ? false : (word >>> (slot & 31) & 1) === 1;
|
|
112
102
|
}
|
|
113
103
|
|
|
114
|
-
|
|
115
|
-
//#region ../layout-core/dist/row-height-index.js
|
|
104
|
+
// ../layout-core/dist/row-height-index.js
|
|
116
105
|
var _a$1;
|
|
117
106
|
function createWork(entriesVisited = 0) {
|
|
118
107
|
return {
|
|
@@ -1965,8 +1954,7 @@ function _release() {
|
|
|
1965
1954
|
_classPrivateFieldSet2(_root2$2, this, null);
|
|
1966
1955
|
}
|
|
1967
1956
|
|
|
1968
|
-
|
|
1969
|
-
//#region ../grid-core/dist/indexed-selection.js
|
|
1957
|
+
// ../grid-core/dist/indexed-selection.js
|
|
1970
1958
|
let _Symbol$iterator;
|
|
1971
1959
|
let _Symbol$toStringTag;
|
|
1972
1960
|
let _Symbol$iterator2;
|
|
@@ -3415,8 +3403,7 @@ function reconcileIndexedSelection(selection, snapshot, eviction) {
|
|
|
3415
3403
|
});
|
|
3416
3404
|
}
|
|
3417
3405
|
|
|
3418
|
-
|
|
3419
|
-
//#region ../grid-core/dist/indexed-focus.js
|
|
3406
|
+
// ../grid-core/dist/indexed-focus.js
|
|
3420
3407
|
/**
|
|
3421
3408
|
* The one header address there is.
|
|
3422
3409
|
*
|
|
@@ -3581,8 +3568,7 @@ function moveIndexedFocus(input) {
|
|
|
3581
3568
|
return nextRow === rowIndex ? current : (_focusAt5 = focusAt(snapshot, nextRow, current.columnId)) !== null && _focusAt5 !== void 0 ? _focusAt5 : current;
|
|
3582
3569
|
}
|
|
3583
3570
|
|
|
3584
|
-
|
|
3585
|
-
//#region ../grid-core/dist/create-grid-ui-core.js
|
|
3571
|
+
// ../grid-core/dist/create-grid-ui-core.js
|
|
3586
3572
|
var PretableGridUiError = class extends Error {
|
|
3587
3573
|
constructor(code, message, cause) {
|
|
3588
3574
|
super(message);
|
|
@@ -4331,13 +4317,11 @@ function createGridUiCore(options) {
|
|
|
4331
4317
|
};
|
|
4332
4318
|
}
|
|
4333
4319
|
|
|
4334
|
-
|
|
4335
|
-
//#region ../grid-core/dist/group-column.js
|
|
4320
|
+
// ../grid-core/dist/group-column.js
|
|
4336
4321
|
/** Id of the synthetic visual column that carries grouped row labels. @public */
|
|
4337
4322
|
const GROUP_COLUMN_ID = "__pretable_group__";
|
|
4338
4323
|
|
|
4339
|
-
|
|
4340
|
-
//#region src/create-grid.ts
|
|
4324
|
+
// src/create-grid.ts
|
|
4341
4325
|
/**
|
|
4342
4326
|
* Create a framework-independent UI-state grid over an explicit indexed row
|
|
4343
4327
|
* model. Data, queries, grouping, aggregation, and expansion remain owned by
|
|
@@ -4350,8 +4334,7 @@ function createGrid(options) {
|
|
|
4350
4334
|
return createGridUiCore(options);
|
|
4351
4335
|
}
|
|
4352
4336
|
|
|
4353
|
-
|
|
4354
|
-
//#region ../row-model/dist/column-types.js
|
|
4337
|
+
// ../row-model/dist/column-types.js
|
|
4355
4338
|
/** @public */
|
|
4356
4339
|
function createColumnHelper$1() {
|
|
4357
4340
|
return { accessor(id, accessorOrOptions, maybeOptions) {
|
|
@@ -4376,8 +4359,7 @@ function isPretableFilterGroup(node) {
|
|
|
4376
4359
|
return typeof node === "object" && node !== null && "children" in node && (node.op === "and" || node.op === "or");
|
|
4377
4360
|
}
|
|
4378
4361
|
|
|
4379
|
-
|
|
4380
|
-
//#region ../calendar-date/dist/calendar-date.js
|
|
4362
|
+
// ../calendar-date/dist/calendar-date.js
|
|
4381
4363
|
const ASCII_ZERO = 48;
|
|
4382
4364
|
const ASCII_NINE = 57;
|
|
4383
4365
|
const ASCII_HYPHEN = 45;
|
|
@@ -4409,8 +4391,7 @@ function compareDateValues(left, right) {
|
|
|
4409
4391
|
return 0;
|
|
4410
4392
|
}
|
|
4411
4393
|
|
|
4412
|
-
|
|
4413
|
-
//#region ../row-model/dist/calendar-date-aggregates.js
|
|
4394
|
+
// ../row-model/dist/calendar-date-aggregates.js
|
|
4414
4395
|
function calendarDateExtremum(kind) {
|
|
4415
4396
|
return Object.freeze({
|
|
4416
4397
|
init: () => null,
|
|
@@ -4439,8 +4420,7 @@ function isCalendarDateAggregate(aggregate) {
|
|
|
4439
4420
|
return aggregate === calendarDateMin || aggregate === calendarDateMax;
|
|
4440
4421
|
}
|
|
4441
4422
|
|
|
4442
|
-
|
|
4443
|
-
//#region ../row-model/dist/errors.js
|
|
4423
|
+
// ../row-model/dist/errors.js
|
|
4444
4424
|
/** @public */
|
|
4445
4425
|
var PretableRowModelError = class extends Error {
|
|
4446
4426
|
constructor(code, message, context) {
|
|
@@ -4533,8 +4513,7 @@ var PretableTransitionCancelledError = class extends Error {
|
|
|
4533
4513
|
}
|
|
4534
4514
|
};
|
|
4535
4515
|
|
|
4536
|
-
|
|
4537
|
-
//#region ../row-model/dist/query-equality.js
|
|
4516
|
+
// ../row-model/dist/query-equality.js
|
|
4538
4517
|
function isRuntimeFilterGroup$1(node) {
|
|
4539
4518
|
return "children" in node;
|
|
4540
4519
|
}
|
|
@@ -4585,8 +4564,7 @@ function queryEqual(left, right) {
|
|
|
4585
4564
|
return filterNodeListEqual(left.filters, right.filters) && orderingEqual(left.sort, right.sort) && orderingEqual(left.rowGroups, right.rowGroups);
|
|
4586
4565
|
}
|
|
4587
4566
|
|
|
4588
|
-
|
|
4589
|
-
//#region ../row-model/dist/compiled-query.js
|
|
4567
|
+
// ../row-model/dist/compiled-query.js
|
|
4590
4568
|
var CompiledQueryValidationError = class extends TypeError {
|
|
4591
4569
|
constructor(detail, path, columnId, options) {
|
|
4592
4570
|
super(`Invalid compiled query at ${path}: ${detail}`, options);
|
|
@@ -5287,6 +5265,7 @@ var CompiledQueryPlan = class CompiledQueryPlan {
|
|
|
5287
5265
|
constructor(capturedColumns, capturedQuery, operation, filterAuthority, sortAuthority) {
|
|
5288
5266
|
_classPrivateMethodInitSpec(this, _CompiledQueryPlan_brand);
|
|
5289
5267
|
_defineProperty(this, "activeColumnIds", void 0);
|
|
5268
|
+
_defineProperty(this, "aggregateColumnIds", void 0);
|
|
5290
5269
|
_classPrivateFieldInitSpec(this, _publicColumns, void 0);
|
|
5291
5270
|
_classPrivateFieldInitSpec(this, _publicQuery, void 0);
|
|
5292
5271
|
_classPrivateFieldInitSpec(this, _runtimeColumns, void 0);
|
|
@@ -5316,6 +5295,7 @@ var CompiledQueryPlan = class CompiledQueryPlan {
|
|
|
5316
5295
|
_classPrivateFieldGet2(_runtimeQuery, this).rowGroups.forEach((entry) => activeIds.add(entry.columnId));
|
|
5317
5296
|
_classPrivateFieldGet2(_runtimeQuery, this).sort.forEach((entry) => activeIds.add(entry.columnId));
|
|
5318
5297
|
_classPrivateFieldSet2(_aggregateColumns, this, _classPrivateFieldGet2(_runtimeColumns, this).filter((column) => column.aggregate !== void 0));
|
|
5298
|
+
this.aggregateColumnIds = Object.freeze(_classPrivateFieldGet2(_aggregateColumns, this).map((column) => column.id));
|
|
5319
5299
|
_classPrivateFieldGet2(_aggregateColumns, this).forEach((column) => activeIds.add(column.id));
|
|
5320
5300
|
_classPrivateFieldSet2(_active, this, _classPrivateFieldGet2(_runtimeColumns, this).filter((column) => activeIds.has(column.id)));
|
|
5321
5301
|
this.activeColumnIds = Object.freeze(_classPrivateFieldGet2(_active, this).map((column) => column.id));
|
|
@@ -5770,50 +5750,25 @@ function compileQuery(input) {
|
|
|
5770
5750
|
return new CompiledQueryPlan(captured.columns, captured.query, (_input$operation = input.operation) !== null && _input$operation !== void 0 ? _input$operation : "set-query", captured.filterAuthority, captured.sortAuthority);
|
|
5771
5751
|
}
|
|
5772
5752
|
|
|
5773
|
-
|
|
5774
|
-
//#region ../row-model/dist/membership-bitset.js
|
|
5753
|
+
// ../row-model/dist/ordered-row-entry.js
|
|
5775
5754
|
/**
|
|
5776
|
-
*
|
|
5777
|
-
*
|
|
5778
|
-
* bitset is a faster INDEX of that same structural answer for flat roots,
|
|
5779
|
-
* never a stored verdict. Grouped roots carry `EMPTY_MEMBERSHIP` and keep
|
|
5780
|
-
* answering from the group index.
|
|
5781
|
-
*
|
|
5782
|
-
* Mutable while a producer is building the next revision's set; frozen by
|
|
5783
|
-
* convention once a root captures it (no Object.freeze — typed arrays do not
|
|
5784
|
-
* support it; discipline is "producers build fresh or clone, never write a
|
|
5785
|
-
* captured root's bitset", the same convention every persistent structure
|
|
5786
|
-
* here relies on).
|
|
5755
|
+
* Standalone module because both visible-index and group-index need it and
|
|
5756
|
+
* visible-index already imports group-index — either home would cycle.
|
|
5787
5757
|
*
|
|
5788
|
-
*
|
|
5789
|
-
*
|
|
5758
|
+
* Decorates a record for tree residence: ONE store get, at insert time. The
|
|
5759
|
+
* record must already be evaluated (or swap-filled) under `queryPlan` —
|
|
5760
|
+
* `sortKeysOf` throws otherwise, which is the fail-loud contract. Entry keys
|
|
5761
|
+
* stay valid for the tree's lifetime because a tree is bound to one plan
|
|
5762
|
+
* (the A2 rebuild-or-reseed invariant) and row updates replace the entry.
|
|
5790
5763
|
*/
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
}
|
|
5796
|
-
/** Clone, growing to `capacity` when it exceeds the source's words. */
|
|
5797
|
-
function cloneMembership(bits, capacity) {
|
|
5798
|
-
const words = Math.max(bits.length, capacity + 31 >>> 5);
|
|
5799
|
-
const next = new Uint32Array(words);
|
|
5800
|
-
next.set(bits);
|
|
5801
|
-
return next;
|
|
5802
|
-
}
|
|
5803
|
-
function setMembershipBit(bits, slot) {
|
|
5804
|
-
bits[slot >>> 5] |= 1 << (slot & 31);
|
|
5805
|
-
}
|
|
5806
|
-
function clearMembershipBit(bits, slot) {
|
|
5807
|
-
bits[slot >>> 5] &= ~(1 << (slot & 31));
|
|
5808
|
-
}
|
|
5809
|
-
/** Out-of-range slots read as false — the EMPTY sentinel relies on this. */
|
|
5810
|
-
function testMembershipBit(bits, slot) {
|
|
5811
|
-
const word = bits[slot >>> 5];
|
|
5812
|
-
return word === void 0 ? false : (word >>> (slot & 31) & 1) === 1;
|
|
5764
|
+
function orderedRowEntry(queryPlan, record) {
|
|
5765
|
+
return Object.freeze({
|
|
5766
|
+
record,
|
|
5767
|
+
keys: sortKeysOf(queryPlan, record)
|
|
5768
|
+
});
|
|
5813
5769
|
}
|
|
5814
5770
|
|
|
5815
|
-
|
|
5816
|
-
//#region ../row-model/dist/persistent/transient.js
|
|
5771
|
+
// ../row-model/dist/persistent/transient.js
|
|
5817
5772
|
var _editable$1 = /* @__PURE__ */ new WeakMap();
|
|
5818
5773
|
var TransientEditToken = class {
|
|
5819
5774
|
constructor() {
|
|
@@ -5827,8 +5782,7 @@ var TransientEditToken = class {
|
|
|
5827
5782
|
}
|
|
5828
5783
|
};
|
|
5829
5784
|
|
|
5830
|
-
|
|
5831
|
-
//#region ../row-model/dist/persistent/persistent-map.js
|
|
5785
|
+
// ../row-model/dist/persistent/persistent-map.js
|
|
5832
5786
|
const inspectPersistentPath = Symbol("inspectPersistentPath");
|
|
5833
5787
|
const inspectTransientPath = Symbol("inspectTransientPath");
|
|
5834
5788
|
const attachInstrumentation$2 = Symbol("attachInstrumentation");
|
|
@@ -6196,8 +6150,7 @@ function instrumentPersistentMap(map, instrumentation) {
|
|
|
6196
6150
|
return map[attachInstrumentation$2](instrumentation);
|
|
6197
6151
|
}
|
|
6198
6152
|
|
|
6199
|
-
|
|
6200
|
-
//#region ../row-model/dist/persistent/order-statistic-tree.js
|
|
6153
|
+
// ../row-model/dist/persistent/order-statistic-tree.js
|
|
6201
6154
|
var _a;
|
|
6202
6155
|
const attachInstrumentation$1 = Symbol("attachOrderInstrumentation");
|
|
6203
6156
|
const createDeferredMeasureDraft$1 = Symbol("createDeferredMeasureDraft");
|
|
@@ -6892,102 +6845,7 @@ function instrumentMeasuredOrderStatisticTree(tree, instrumentation, beforeCombi
|
|
|
6892
6845
|
return tree[attachInstrumentation$1](instrumentation, beforeCombine);
|
|
6893
6846
|
}
|
|
6894
6847
|
|
|
6895
|
-
|
|
6896
|
-
//#region ../row-model/dist/slot-vector.js
|
|
6897
|
-
/**
|
|
6898
|
-
* Immutable chunked slot-indexed vector: a chunk table over
|
|
6899
|
-
* `SLOT_VECTOR_CHUNK`-element chunks, copy-on-write per commit. A commit
|
|
6900
|
-
* touching k slots copies the table plus each touched chunk once — this is
|
|
6901
|
-
* what keeps old snapshots valid under slot reuse: every revision holds its
|
|
6902
|
-
* own table, so revision N still binds slot s to whatever row owned s at
|
|
6903
|
-
* revision N no matter what later commits do (M0 priced maintenance at
|
|
6904
|
-
* ~33–98µs per 100-write commit).
|
|
6905
|
-
*
|
|
6906
|
-
* Holes (`undefined`) are free slots. Iteration hole-skips, which is why no
|
|
6907
|
-
* separate "live" bitset exists (recorded plan deviation from the spec).
|
|
6908
|
-
*/
|
|
6909
|
-
const SLOT_VECTOR_CHUNK = 1024;
|
|
6910
|
-
const EMPTY = Object.freeze({ chunks: Object.freeze([]) });
|
|
6911
|
-
function slotVectorFromEntries(entries, capacity) {
|
|
6912
|
-
const tableSize = Math.ceil(capacity / SLOT_VECTOR_CHUNK);
|
|
6913
|
-
const limit = tableSize * SLOT_VECTOR_CHUNK;
|
|
6914
|
-
const chunks = new Array(tableSize);
|
|
6915
|
-
for (const [slot, value] of entries) {
|
|
6916
|
-
if (slot >= limit) throw new RangeError(`Slot ${slot} is beyond capacity ${capacity}.`);
|
|
6917
|
-
const index = slot / SLOT_VECTOR_CHUNK | 0;
|
|
6918
|
-
let chunk = chunks[index];
|
|
6919
|
-
if (chunk === void 0) {
|
|
6920
|
-
chunk = new Array(SLOT_VECTOR_CHUNK);
|
|
6921
|
-
chunks[index] = chunk;
|
|
6922
|
-
}
|
|
6923
|
-
chunk[slot % SLOT_VECTOR_CHUNK] = value;
|
|
6924
|
-
}
|
|
6925
|
-
return { chunks };
|
|
6926
|
-
}
|
|
6927
|
-
/**
|
|
6928
|
-
* One commit's writes (`undefined` value = clear the slot), COW: table copied
|
|
6929
|
-
* once, each touched chunk copied once. `capacity` may exceed the old
|
|
6930
|
-
* table's reach (allocator growth).
|
|
6931
|
-
*
|
|
6932
|
-
* `chunksTouched` counts every chunk this commit allocated or copied,
|
|
6933
|
-
* including a brand-new chunk created for a hole beyond the old table — that
|
|
6934
|
-
* counts as touched even though nothing was copied.
|
|
6935
|
-
*/
|
|
6936
|
-
function slotVectorWithAll(vector, writes, capacity) {
|
|
6937
|
-
const tableSize = Math.max(vector.chunks.length, Math.ceil(capacity / SLOT_VECTOR_CHUNK));
|
|
6938
|
-
const limit = tableSize * SLOT_VECTOR_CHUNK;
|
|
6939
|
-
const chunks = new Array(tableSize);
|
|
6940
|
-
for (let i = 0; i < vector.chunks.length; i += 1) chunks[i] = vector.chunks[i];
|
|
6941
|
-
let chunksTouched = 0;
|
|
6942
|
-
for (const [slot, value] of writes) {
|
|
6943
|
-
if (slot >= limit) throw new RangeError(`Slot ${slot} is beyond capacity ${capacity}.`);
|
|
6944
|
-
const index = slot / SLOT_VECTOR_CHUNK | 0;
|
|
6945
|
-
if (chunks[index] === void 0 || chunks[index] === vector.chunks[index]) {
|
|
6946
|
-
const existing = chunks[index];
|
|
6947
|
-
chunks[index] = existing === void 0 ? new Array(SLOT_VECTOR_CHUNK) : existing.slice();
|
|
6948
|
-
chunksTouched += 1;
|
|
6949
|
-
}
|
|
6950
|
-
chunks[index][slot % SLOT_VECTOR_CHUNK] = value;
|
|
6951
|
-
}
|
|
6952
|
-
return {
|
|
6953
|
-
next: { chunks },
|
|
6954
|
-
chunksTouched
|
|
6955
|
-
};
|
|
6956
|
-
}
|
|
6957
|
-
/** Hole-skipping walk in slot order. */
|
|
6958
|
-
function forEachSlotEntry(vector, callback) {
|
|
6959
|
-
for (let index = 0; index < vector.chunks.length; index += 1) {
|
|
6960
|
-
const chunk = vector.chunks[index];
|
|
6961
|
-
if (chunk === void 0) continue;
|
|
6962
|
-
const base = index * SLOT_VECTOR_CHUNK;
|
|
6963
|
-
for (let offset = 0; offset < chunk.length; offset += 1) {
|
|
6964
|
-
const value = chunk[offset];
|
|
6965
|
-
if (value !== void 0) callback(value, base + offset);
|
|
6966
|
-
}
|
|
6967
|
-
}
|
|
6968
|
-
}
|
|
6969
|
-
|
|
6970
|
-
//#endregion
|
|
6971
|
-
//#region ../row-model/dist/ordered-row-entry.js
|
|
6972
|
-
/**
|
|
6973
|
-
* Standalone module because both visible-index and group-index need it and
|
|
6974
|
-
* visible-index already imports group-index — either home would cycle.
|
|
6975
|
-
*
|
|
6976
|
-
* Decorates a record for tree residence: ONE store get, at insert time. The
|
|
6977
|
-
* record must already be evaluated (or swap-filled) under `queryPlan` —
|
|
6978
|
-
* `sortKeysOf` throws otherwise, which is the fail-loud contract. Entry keys
|
|
6979
|
-
* stay valid for the tree's lifetime because a tree is bound to one plan
|
|
6980
|
-
* (the A2 rebuild-or-reseed invariant) and row updates replace the entry.
|
|
6981
|
-
*/
|
|
6982
|
-
function orderedRowEntry(queryPlan, record) {
|
|
6983
|
-
return Object.freeze({
|
|
6984
|
-
record,
|
|
6985
|
-
keys: sortKeysOf(queryPlan, record)
|
|
6986
|
-
});
|
|
6987
|
-
}
|
|
6988
|
-
|
|
6989
|
-
//#endregion
|
|
6990
|
-
//#region ../row-model/dist/persistent/aggregate-tree.js
|
|
6848
|
+
// ../row-model/dist/persistent/aggregate-tree.js
|
|
6991
6849
|
const attachInstrumentation = Symbol("attachAggregateInstrumentation");
|
|
6992
6850
|
const createDeferredMeasureDraft = Symbol("createDeferredMeasureDraft");
|
|
6993
6851
|
const DEVELOPMENT$2 = process.env.NODE_ENV !== "production";
|
|
@@ -7477,8 +7335,7 @@ function instrumentAggregateTree(tree, instrumentation) {
|
|
|
7477
7335
|
return tree[attachInstrumentation](instrumentation);
|
|
7478
7336
|
}
|
|
7479
7337
|
|
|
7480
|
-
|
|
7481
|
-
//#region ../row-model/dist/group-index.js
|
|
7338
|
+
// ../row-model/dist/group-index.js
|
|
7482
7339
|
const visibleRangeDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
7483
7340
|
const EMPTY_COUNTS = Object.freeze({
|
|
7484
7341
|
collapsed: 0,
|
|
@@ -8557,8 +8414,308 @@ function nearestVisible(root, ref, policy) {
|
|
|
8557
8414
|
}
|
|
8558
8415
|
}
|
|
8559
8416
|
|
|
8560
|
-
|
|
8561
|
-
|
|
8417
|
+
// ../row-model/dist/filter-membership.js
|
|
8418
|
+
/**
|
|
8419
|
+
* Filter verdicts are not stored. A committed root already carries the answer
|
|
8420
|
+
* structurally: a row passes this root's filters exactly when it is a MEMBER
|
|
8421
|
+
* of the root's visible structure. This module is the one place that knows
|
|
8422
|
+
* which structure answers for which root shape.
|
|
8423
|
+
*
|
|
8424
|
+
* - **Flat root** (`query.rowGroups.length === 0`): `root.visible.rows` holds
|
|
8425
|
+
* one entry per passing row and nothing else, so membership is a lookup.
|
|
8426
|
+
* This is the same predicate `nearestVisibleRef` has always used.
|
|
8427
|
+
* - **Grouped root**: `root.visible.rows` is deliberately EMPTY (a grouped
|
|
8428
|
+
* visible index attaches the group index to an empty flat tree), so the
|
|
8429
|
+
* answer lives in the group index: every inserted row — passing or not —
|
|
8430
|
+
* gets a `rowParents` entry, and only passing rows are inserted into their
|
|
8431
|
+
* leaf group's `leaves` tree. So `rowParents` locates the leaf group and
|
|
8432
|
+
* `leaves` holds the verdict.
|
|
8433
|
+
*
|
|
8434
|
+
* Absence is the answer, not a fault: a row this root never saw, or one its
|
|
8435
|
+
* filters reject, is simply not a member. Nothing here fails loud.
|
|
8436
|
+
*
|
|
8437
|
+
* These read a COMMITTED root, so they answer "did this row pass under the
|
|
8438
|
+
* plan that built this root" — the OLD verdict at every site that compares
|
|
8439
|
+
* against a new one. A NEW verdict is computed, never resolved: producers
|
|
8440
|
+
* call `filterVerdict(plan, record)` and use it locally to decide where the
|
|
8441
|
+
* row goes.
|
|
8442
|
+
*/
|
|
8443
|
+
/** Did `rowId` pass the filters of the plan that built `root`? */
|
|
8444
|
+
function rowPassesFilter(root, rowId) {
|
|
8445
|
+
const grouped = getGroupIndex(root.visible);
|
|
8446
|
+
return grouped === void 0 ? root.visible.rows.get(rowId) !== void 0 : rowPassesFilterInGroupIndex(grouped, rowId);
|
|
8447
|
+
}
|
|
8448
|
+
|
|
8449
|
+
// ../row-model/dist/summary-index.js
|
|
8450
|
+
function emptyRoots(plan, instrumentation) {
|
|
8451
|
+
const roots = /* @__PURE__ */ new Map();
|
|
8452
|
+
for (const column of plan.derivations) {
|
|
8453
|
+
if (column.aggregate === void 0) continue;
|
|
8454
|
+
const aggregate = lowerCalendarDateAggregate(column.type, column.aggregate);
|
|
8455
|
+
const factory = createAggregateTree;
|
|
8456
|
+
const tree = isScalarBuiltinAggregator(aggregate) ? createScalarAggregateCell({
|
|
8457
|
+
columnId: column.id,
|
|
8458
|
+
aggregator: aggregate
|
|
8459
|
+
}) : factory({
|
|
8460
|
+
columnId: column.id,
|
|
8461
|
+
aggregator: aggregate,
|
|
8462
|
+
compare: (a, b) => compareWithSortKeys(plan, {
|
|
8463
|
+
rowId: a.id,
|
|
8464
|
+
row: a.row,
|
|
8465
|
+
sourceOrder: a.dependency.sourceOrder
|
|
8466
|
+
}, a.dependency.sortKeys, {
|
|
8467
|
+
rowId: b.id,
|
|
8468
|
+
row: b.row,
|
|
8469
|
+
sourceOrder: b.dependency.sourceOrder
|
|
8470
|
+
}, b.dependency.sortKeys)
|
|
8471
|
+
});
|
|
8472
|
+
roots.set(column.id, instrumentAggregateTree(tree, instrumentation));
|
|
8473
|
+
}
|
|
8474
|
+
return roots;
|
|
8475
|
+
}
|
|
8476
|
+
function finish(roots) {
|
|
8477
|
+
const results = {};
|
|
8478
|
+
for (const scope of ["all", "filtered"]) {
|
|
8479
|
+
const trees = roots[scope];
|
|
8480
|
+
if (trees === void 0) continue;
|
|
8481
|
+
const values = Object.create(null);
|
|
8482
|
+
for (const [id, tree] of trees) values[id] = tree.finalize();
|
|
8483
|
+
results[scope] = Object.freeze({
|
|
8484
|
+
scope,
|
|
8485
|
+
values: Object.freeze(values)
|
|
8486
|
+
});
|
|
8487
|
+
}
|
|
8488
|
+
return Object.freeze({
|
|
8489
|
+
roots: Object.freeze(roots),
|
|
8490
|
+
results: Object.freeze(results)
|
|
8491
|
+
});
|
|
8492
|
+
}
|
|
8493
|
+
function contribute(roots, record, plan, add, instrumentation) {
|
|
8494
|
+
if (instrumentation) instrumentation.work.summaryRowsVisited += 1;
|
|
8495
|
+
const next = new Map(roots);
|
|
8496
|
+
for (const entry of record.metadata.aggregateLeaves) {
|
|
8497
|
+
const tree = next.get(entry.columnId);
|
|
8498
|
+
if (tree === void 0) continue;
|
|
8499
|
+
if (instrumentation) instrumentation.work.summaryCellsUpdated += 1;
|
|
8500
|
+
const leaf = {
|
|
8501
|
+
...entry.allLeaf,
|
|
8502
|
+
dependency: {
|
|
8503
|
+
sourceOrder: record.sourceOrder,
|
|
8504
|
+
sortKeys: sortKeysOf(plan, record)
|
|
8505
|
+
}
|
|
8506
|
+
};
|
|
8507
|
+
next.set(entry.columnId, add ? tree.insertOrReplace(leaf) : tree.remove(record.rowId, leaf));
|
|
8508
|
+
}
|
|
8509
|
+
return next;
|
|
8510
|
+
}
|
|
8511
|
+
/** Only affected records are visited, scalar cells apply exact inverse deltas. */
|
|
8512
|
+
function updateSummaryIndex(previous, next, ids, instrumentation) {
|
|
8513
|
+
if (previous.summaries === void 0) return void 0;
|
|
8514
|
+
const roots = { ...previous.summaries.roots };
|
|
8515
|
+
for (const scope of ["all", "filtered"]) {
|
|
8516
|
+
let trees = roots[scope];
|
|
8517
|
+
if (trees === void 0) continue;
|
|
8518
|
+
for (const id of ids) {
|
|
8519
|
+
const old = previous.rows.get(id);
|
|
8520
|
+
const current = next.rows.get(id);
|
|
8521
|
+
if (old && (scope === "all" || rowPassesFilter(previous, id))) trees = contribute(trees, old, previous.queryPlan, false, instrumentation);
|
|
8522
|
+
if (current && (scope === "all" || rowPassesFilter(next, id))) trees = contribute(trees, current, next.queryPlan, true, instrumentation);
|
|
8523
|
+
}
|
|
8524
|
+
roots[scope] = trees;
|
|
8525
|
+
}
|
|
8526
|
+
return finish(roots);
|
|
8527
|
+
}
|
|
8528
|
+
function retainSummaryScopes(index, scopes) {
|
|
8529
|
+
if (index === void 0 || scopes.length === 0) return void 0;
|
|
8530
|
+
const roots = {};
|
|
8531
|
+
const results = {};
|
|
8532
|
+
for (const scope of scopes) {
|
|
8533
|
+
roots[scope] = index.roots[scope];
|
|
8534
|
+
results[scope] = index.results[scope];
|
|
8535
|
+
}
|
|
8536
|
+
return Object.freeze({
|
|
8537
|
+
roots: Object.freeze(roots),
|
|
8538
|
+
results: Object.freeze(results)
|
|
8539
|
+
});
|
|
8540
|
+
}
|
|
8541
|
+
/** A private rebuild: one source record or replay record per cooperative step. */
|
|
8542
|
+
function createSummaryBuild(captured, plan, scopes, instrumentation) {
|
|
8543
|
+
let activeScopes = [...scopes];
|
|
8544
|
+
const roots = {};
|
|
8545
|
+
for (const scope of activeScopes) roots[scope] = emptyRoots(plan, instrumentation);
|
|
8546
|
+
const records = /* @__PURE__ */ new Map();
|
|
8547
|
+
let iterator = captured.rows.entries();
|
|
8548
|
+
const deltas = /* @__PURE__ */ new Map();
|
|
8549
|
+
function replace(id, original) {
|
|
8550
|
+
const old = records.get(id);
|
|
8551
|
+
if (old) {
|
|
8552
|
+
for (const scope of activeScopes) if (scope === "all" || old.matches) roots[scope] = contribute(roots[scope], old.record, plan, false, instrumentation);
|
|
8553
|
+
}
|
|
8554
|
+
records.delete(id);
|
|
8555
|
+
if (!original) return;
|
|
8556
|
+
const record = plan === captured.queryPlan ? original : {
|
|
8557
|
+
...original,
|
|
8558
|
+
metadata: plan.evaluate({
|
|
8559
|
+
rowId: id,
|
|
8560
|
+
row: original.row,
|
|
8561
|
+
sourceOrder: original.sourceOrder,
|
|
8562
|
+
slot: original.slot
|
|
8563
|
+
})
|
|
8564
|
+
};
|
|
8565
|
+
const matches = filterVerdict(plan, record);
|
|
8566
|
+
records.set(id, {
|
|
8567
|
+
record,
|
|
8568
|
+
matches
|
|
8569
|
+
});
|
|
8570
|
+
for (const scope of activeScopes) if (scope === "all" || matches) roots[scope] = contribute(roots[scope], record, plan, true, instrumentation);
|
|
8571
|
+
}
|
|
8572
|
+
return {
|
|
8573
|
+
retainScopes(requested) {
|
|
8574
|
+
activeScopes = activeScopes.filter((scope) => requested.includes(scope));
|
|
8575
|
+
for (const scope of ["all", "filtered"]) if (!activeScopes.includes(scope)) delete roots[scope];
|
|
8576
|
+
},
|
|
8577
|
+
append(target, ids) {
|
|
8578
|
+
for (const id of ids) deltas.set(id, target.rows.get(id));
|
|
8579
|
+
},
|
|
8580
|
+
step() {
|
|
8581
|
+
if (iterator) {
|
|
8582
|
+
const item = iterator.next();
|
|
8583
|
+
if (!item.done) {
|
|
8584
|
+
replace(item.value[0], item.value[1]);
|
|
8585
|
+
return false;
|
|
8586
|
+
}
|
|
8587
|
+
iterator = void 0;
|
|
8588
|
+
}
|
|
8589
|
+
const delta = deltas.entries().next();
|
|
8590
|
+
if (!delta.done) {
|
|
8591
|
+
deltas.delete(delta.value[0]);
|
|
8592
|
+
replace(delta.value[0], delta.value[1]);
|
|
8593
|
+
return false;
|
|
8594
|
+
}
|
|
8595
|
+
return true;
|
|
8596
|
+
},
|
|
8597
|
+
finish() {
|
|
8598
|
+
return finish(roots);
|
|
8599
|
+
}
|
|
8600
|
+
};
|
|
8601
|
+
}
|
|
8602
|
+
|
|
8603
|
+
// ../row-model/dist/membership-bitset.js
|
|
8604
|
+
/**
|
|
8605
|
+
* Membership bitsets: one bit per SLOT (see `slot-allocator`). A committed
|
|
8606
|
+
* root's verdict is its membership (the filter-membership invariant); the
|
|
8607
|
+
* bitset is a faster INDEX of that same structural answer for flat roots,
|
|
8608
|
+
* never a stored verdict. Grouped roots carry `EMPTY_MEMBERSHIP` and keep
|
|
8609
|
+
* answering from the group index.
|
|
8610
|
+
*
|
|
8611
|
+
* Mutable while a producer is building the next revision's set; frozen by
|
|
8612
|
+
* convention once a root captures it (no Object.freeze — typed arrays do not
|
|
8613
|
+
* support it; discipline is "producers build fresh or clone, never write a
|
|
8614
|
+
* captured root's bitset", the same convention every persistent structure
|
|
8615
|
+
* here relies on).
|
|
8616
|
+
*
|
|
8617
|
+
* Whole-copy on change is the point: 50k rows is 6.25KB, negligible per
|
|
8618
|
+
* commit (M0 measured ~1µs), so no COW machinery exists at this layer.
|
|
8619
|
+
*/
|
|
8620
|
+
/** Shared sentinel for roots whose membership lives elsewhere (grouped). */
|
|
8621
|
+
const EMPTY_MEMBERSHIP = /* @__PURE__ */ new Uint32Array(0);
|
|
8622
|
+
function createMembership(capacity) {
|
|
8623
|
+
return new Uint32Array(capacity + 31 >>> 5);
|
|
8624
|
+
}
|
|
8625
|
+
/** Clone, growing to `capacity` when it exceeds the source's words. */
|
|
8626
|
+
function cloneMembership(bits, capacity) {
|
|
8627
|
+
const words = Math.max(bits.length, capacity + 31 >>> 5);
|
|
8628
|
+
const next = new Uint32Array(words);
|
|
8629
|
+
next.set(bits);
|
|
8630
|
+
return next;
|
|
8631
|
+
}
|
|
8632
|
+
function setMembershipBit(bits, slot) {
|
|
8633
|
+
bits[slot >>> 5] |= 1 << (slot & 31);
|
|
8634
|
+
}
|
|
8635
|
+
function clearMembershipBit(bits, slot) {
|
|
8636
|
+
bits[slot >>> 5] &= ~(1 << (slot & 31));
|
|
8637
|
+
}
|
|
8638
|
+
/** Out-of-range slots read as false — the EMPTY sentinel relies on this. */
|
|
8639
|
+
function testMembershipBit(bits, slot) {
|
|
8640
|
+
const word = bits[slot >>> 5];
|
|
8641
|
+
return word === void 0 ? false : (word >>> (slot & 31) & 1) === 1;
|
|
8642
|
+
}
|
|
8643
|
+
|
|
8644
|
+
// ../row-model/dist/slot-vector.js
|
|
8645
|
+
/**
|
|
8646
|
+
* Immutable chunked slot-indexed vector: a chunk table over
|
|
8647
|
+
* `SLOT_VECTOR_CHUNK`-element chunks, copy-on-write per commit. A commit
|
|
8648
|
+
* touching k slots copies the table plus each touched chunk once — this is
|
|
8649
|
+
* what keeps old snapshots valid under slot reuse: every revision holds its
|
|
8650
|
+
* own table, so revision N still binds slot s to whatever row owned s at
|
|
8651
|
+
* revision N no matter what later commits do (M0 priced maintenance at
|
|
8652
|
+
* ~33–98µs per 100-write commit).
|
|
8653
|
+
*
|
|
8654
|
+
* Holes (`undefined`) are free slots. Iteration hole-skips, which is why no
|
|
8655
|
+
* separate "live" bitset exists (recorded plan deviation from the spec).
|
|
8656
|
+
*/
|
|
8657
|
+
const SLOT_VECTOR_CHUNK = 1024;
|
|
8658
|
+
const EMPTY = Object.freeze({ chunks: Object.freeze([]) });
|
|
8659
|
+
function slotVectorFromEntries(entries, capacity) {
|
|
8660
|
+
const tableSize = Math.ceil(capacity / SLOT_VECTOR_CHUNK);
|
|
8661
|
+
const limit = tableSize * SLOT_VECTOR_CHUNK;
|
|
8662
|
+
const chunks = new Array(tableSize);
|
|
8663
|
+
for (const [slot, value] of entries) {
|
|
8664
|
+
if (slot >= limit) throw new RangeError(`Slot ${slot} is beyond capacity ${capacity}.`);
|
|
8665
|
+
const index = slot / SLOT_VECTOR_CHUNK | 0;
|
|
8666
|
+
let chunk = chunks[index];
|
|
8667
|
+
if (chunk === void 0) {
|
|
8668
|
+
chunk = new Array(SLOT_VECTOR_CHUNK);
|
|
8669
|
+
chunks[index] = chunk;
|
|
8670
|
+
}
|
|
8671
|
+
chunk[slot % SLOT_VECTOR_CHUNK] = value;
|
|
8672
|
+
}
|
|
8673
|
+
return { chunks };
|
|
8674
|
+
}
|
|
8675
|
+
/**
|
|
8676
|
+
* One commit's writes (`undefined` value = clear the slot), COW: table copied
|
|
8677
|
+
* once, each touched chunk copied once. `capacity` may exceed the old
|
|
8678
|
+
* table's reach (allocator growth).
|
|
8679
|
+
*
|
|
8680
|
+
* `chunksTouched` counts every chunk this commit allocated or copied,
|
|
8681
|
+
* including a brand-new chunk created for a hole beyond the old table — that
|
|
8682
|
+
* counts as touched even though nothing was copied.
|
|
8683
|
+
*/
|
|
8684
|
+
function slotVectorWithAll(vector, writes, capacity) {
|
|
8685
|
+
const tableSize = Math.max(vector.chunks.length, Math.ceil(capacity / SLOT_VECTOR_CHUNK));
|
|
8686
|
+
const limit = tableSize * SLOT_VECTOR_CHUNK;
|
|
8687
|
+
const chunks = new Array(tableSize);
|
|
8688
|
+
for (let i = 0; i < vector.chunks.length; i += 1) chunks[i] = vector.chunks[i];
|
|
8689
|
+
let chunksTouched = 0;
|
|
8690
|
+
for (const [slot, value] of writes) {
|
|
8691
|
+
if (slot >= limit) throw new RangeError(`Slot ${slot} is beyond capacity ${capacity}.`);
|
|
8692
|
+
const index = slot / SLOT_VECTOR_CHUNK | 0;
|
|
8693
|
+
if (chunks[index] === void 0 || chunks[index] === vector.chunks[index]) {
|
|
8694
|
+
const existing = chunks[index];
|
|
8695
|
+
chunks[index] = existing === void 0 ? new Array(SLOT_VECTOR_CHUNK) : existing.slice();
|
|
8696
|
+
chunksTouched += 1;
|
|
8697
|
+
}
|
|
8698
|
+
chunks[index][slot % SLOT_VECTOR_CHUNK] = value;
|
|
8699
|
+
}
|
|
8700
|
+
return {
|
|
8701
|
+
next: { chunks },
|
|
8702
|
+
chunksTouched
|
|
8703
|
+
};
|
|
8704
|
+
}
|
|
8705
|
+
/** Hole-skipping walk in slot order. */
|
|
8706
|
+
function forEachSlotEntry(vector, callback) {
|
|
8707
|
+
for (let index = 0; index < vector.chunks.length; index += 1) {
|
|
8708
|
+
const chunk = vector.chunks[index];
|
|
8709
|
+
if (chunk === void 0) continue;
|
|
8710
|
+
const base = index * SLOT_VECTOR_CHUNK;
|
|
8711
|
+
for (let offset = 0; offset < chunk.length; offset += 1) {
|
|
8712
|
+
const value = chunk[offset];
|
|
8713
|
+
if (value !== void 0) callback(value, base + offset);
|
|
8714
|
+
}
|
|
8715
|
+
}
|
|
8716
|
+
}
|
|
8717
|
+
|
|
8718
|
+
// ../row-model/dist/visible-index.js
|
|
8562
8719
|
function createFlatVisibleIndex(records, queryPlan) {
|
|
8563
8720
|
const draft = createFlatVisibleTree(queryPlan).asTransient();
|
|
8564
8721
|
for (const record of records) if (filterVerdict(queryPlan, record)) draft.insertOrReplace(orderedRowEntry(queryPlan, record));
|
|
@@ -8614,6 +8771,11 @@ function createFlatSnapshot(root) {
|
|
|
8614
8771
|
const count = visibleCount(grouped, policy);
|
|
8615
8772
|
const dataCount = visibleDataCount(grouped, policy);
|
|
8616
8773
|
return Object.freeze({
|
|
8774
|
+
getSummary: (scope) => {
|
|
8775
|
+
var _root$summaries;
|
|
8776
|
+
return (_root$summaries = root.summaries) === null || _root$summaries === void 0 ? void 0 : _root$summaries.results[scope];
|
|
8777
|
+
},
|
|
8778
|
+
aggregateColumnIds: root.queryPlan.aggregateColumnIds,
|
|
8617
8779
|
revision: root.revision,
|
|
8618
8780
|
sourceRowCount: root.rows.size,
|
|
8619
8781
|
visibleRowCount: count,
|
|
@@ -8648,6 +8810,11 @@ function createFlatSnapshot(root) {
|
|
|
8648
8810
|
};
|
|
8649
8811
|
const lookupRank = (ref) => ref.kind === "data" ? visible.rankOf(ref.rowId) : void 0;
|
|
8650
8812
|
return Object.freeze({
|
|
8813
|
+
getSummary: (scope) => {
|
|
8814
|
+
var _root$summaries2;
|
|
8815
|
+
return (_root$summaries2 = root.summaries) === null || _root$summaries2 === void 0 ? void 0 : _root$summaries2.results[scope];
|
|
8816
|
+
},
|
|
8817
|
+
aggregateColumnIds: root.queryPlan.aggregateColumnIds,
|
|
8651
8818
|
revision: root.revision,
|
|
8652
8819
|
sourceRowCount: root.rows.size,
|
|
8653
8820
|
visibleRowCount: visible.size,
|
|
@@ -8693,8 +8860,7 @@ function createFlatSnapshot(root) {
|
|
|
8693
8860
|
});
|
|
8694
8861
|
}
|
|
8695
8862
|
|
|
8696
|
-
|
|
8697
|
-
//#region ../row-model/dist/filter-rebuild.js
|
|
8863
|
+
// ../row-model/dist/filter-rebuild.js
|
|
8698
8864
|
/**
|
|
8699
8865
|
* Synchronous subset rebuild for a filter-only plan change on an ungrouped
|
|
8700
8866
|
* query. Runs to completion on the caller's stack, like `sort-rebuild` — a
|
|
@@ -8781,41 +8947,7 @@ function rebuildRootForFilterOnlyChange(options) {
|
|
|
8781
8947
|
return root;
|
|
8782
8948
|
}
|
|
8783
8949
|
|
|
8784
|
-
|
|
8785
|
-
//#region ../row-model/dist/filter-membership.js
|
|
8786
|
-
/**
|
|
8787
|
-
* Filter verdicts are not stored. A committed root already carries the answer
|
|
8788
|
-
* structurally: a row passes this root's filters exactly when it is a MEMBER
|
|
8789
|
-
* of the root's visible structure. This module is the one place that knows
|
|
8790
|
-
* which structure answers for which root shape.
|
|
8791
|
-
*
|
|
8792
|
-
* - **Flat root** (`query.rowGroups.length === 0`): `root.visible.rows` holds
|
|
8793
|
-
* one entry per passing row and nothing else, so membership is a lookup.
|
|
8794
|
-
* This is the same predicate `nearestVisibleRef` has always used.
|
|
8795
|
-
* - **Grouped root**: `root.visible.rows` is deliberately EMPTY (a grouped
|
|
8796
|
-
* visible index attaches the group index to an empty flat tree), so the
|
|
8797
|
-
* answer lives in the group index: every inserted row — passing or not —
|
|
8798
|
-
* gets a `rowParents` entry, and only passing rows are inserted into their
|
|
8799
|
-
* leaf group's `leaves` tree. So `rowParents` locates the leaf group and
|
|
8800
|
-
* `leaves` holds the verdict.
|
|
8801
|
-
*
|
|
8802
|
-
* Absence is the answer, not a fault: a row this root never saw, or one its
|
|
8803
|
-
* filters reject, is simply not a member. Nothing here fails loud.
|
|
8804
|
-
*
|
|
8805
|
-
* These read a COMMITTED root, so they answer "did this row pass under the
|
|
8806
|
-
* plan that built this root" — the OLD verdict at every site that compares
|
|
8807
|
-
* against a new one. A NEW verdict is computed, never resolved: producers
|
|
8808
|
-
* call `filterVerdict(plan, record)` and use it locally to decide where the
|
|
8809
|
-
* row goes.
|
|
8810
|
-
*/
|
|
8811
|
-
/** Did `rowId` pass the filters of the plan that built `root`? */
|
|
8812
|
-
function rowPassesFilter(root, rowId) {
|
|
8813
|
-
const grouped = getGroupIndex(root.visible);
|
|
8814
|
-
return grouped === void 0 ? root.visible.rows.get(rowId) !== void 0 : rowPassesFilterInGroupIndex(grouped, rowId);
|
|
8815
|
-
}
|
|
8816
|
-
|
|
8817
|
-
//#endregion
|
|
8818
|
-
//#region ../row-model/dist/sort-rebuild.js
|
|
8950
|
+
// ../row-model/dist/sort-rebuild.js
|
|
8819
8951
|
/**
|
|
8820
8952
|
* Synchronous whole-root rebuild for a sort-only plan change on an ungrouped
|
|
8821
8953
|
* query. Runs to completion on the caller's stack — the deliberate trade
|
|
@@ -8862,8 +8994,7 @@ function rebuildRootForSortOnlyChange(options) {
|
|
|
8862
8994
|
return root;
|
|
8863
8995
|
}
|
|
8864
8996
|
|
|
8865
|
-
|
|
8866
|
-
//#region ../row-model/dist/flat-cooperative-candidate.js
|
|
8997
|
+
// ../row-model/dist/flat-cooperative-candidate.js
|
|
8867
8998
|
/**
|
|
8868
8999
|
* The flat (ungrouped) cooperative transition candidate. Builds against an
|
|
8869
9000
|
* immutable source root and replays exact live-row deltas; nothing reachable
|
|
@@ -9218,8 +9349,7 @@ function createFlatCooperativeCandidate(options) {
|
|
|
9218
9349
|
return candidate;
|
|
9219
9350
|
}
|
|
9220
9351
|
|
|
9221
|
-
|
|
9222
|
-
//#region ../row-model/dist/cooperative-transition.js
|
|
9352
|
+
// ../row-model/dist/cooperative-transition.js
|
|
9223
9353
|
const candidateDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
9224
9354
|
/**
|
|
9225
9355
|
* Registers a candidate's diagnostics reader in the shared WeakMap so
|
|
@@ -9681,8 +9811,7 @@ function createCooperativeTransitionCandidate(options) {
|
|
|
9681
9811
|
return candidate;
|
|
9682
9812
|
}
|
|
9683
9813
|
|
|
9684
|
-
|
|
9685
|
-
//#region ../row-model/dist/distinct-values.js
|
|
9814
|
+
// ../row-model/dist/distinct-values.js
|
|
9686
9815
|
const DEFAULT_RESULT_LIMIT = 100;
|
|
9687
9816
|
const MAX_RESULT_LIMIT = 1e3;
|
|
9688
9817
|
const DEFAULT_CACHE_CAPACITY = 8;
|
|
@@ -10405,8 +10534,7 @@ function createDistinctValueManager(options) {
|
|
|
10405
10534
|
};
|
|
10406
10535
|
}
|
|
10407
10536
|
|
|
10408
|
-
|
|
10409
|
-
//#region ../row-model/dist/change-journal.js
|
|
10537
|
+
// ../row-model/dist/change-journal.js
|
|
10410
10538
|
const DEFAULT_CHANGE_JOURNAL_CAPACITY = 128;
|
|
10411
10539
|
const operationDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
10412
10540
|
const journalDiagnostics = /* @__PURE__ */ new WeakMap();
|
|
@@ -10568,8 +10696,7 @@ function createChangeJournal(capacity = 128) {
|
|
|
10568
10696
|
return frozen;
|
|
10569
10697
|
}
|
|
10570
10698
|
|
|
10571
|
-
|
|
10572
|
-
//#region ../row-model/dist/row-integrity.js
|
|
10699
|
+
// ../row-model/dist/row-integrity.js
|
|
10573
10700
|
const DEVELOPMENT$1 = process.env.NODE_ENV !== "production";
|
|
10574
10701
|
function failIntegrity(operation, cause) {
|
|
10575
10702
|
throw new PretableRowModelError("derivation-failed", "A row could not be inspected safely before publication.", {
|
|
@@ -10671,8 +10798,7 @@ function fingerprintInspection(current, rowId, previous, sameReference) {
|
|
|
10671
10798
|
};
|
|
10672
10799
|
}
|
|
10673
10800
|
|
|
10674
|
-
|
|
10675
|
-
//#region ../row-model/dist/row-store.js
|
|
10801
|
+
// ../row-model/dist/row-store.js
|
|
10676
10802
|
function createSourceOrderTree(instrumentation) {
|
|
10677
10803
|
return instrumentOrderStatisticTree(createOrderStatisticTree({
|
|
10678
10804
|
getId: (entry) => entry.rowId,
|
|
@@ -10780,8 +10906,7 @@ function buildRowStore(input) {
|
|
|
10780
10906
|
};
|
|
10781
10907
|
}
|
|
10782
10908
|
|
|
10783
|
-
|
|
10784
|
-
//#region ../row-model/dist/slot-allocator.js
|
|
10909
|
+
// ../row-model/dist/slot-allocator.js
|
|
10785
10910
|
/**
|
|
10786
10911
|
* Per-MODEL slot allocator: every row gets a small dense integer for its
|
|
10787
10912
|
* lifetime, assigned at ingest and released only on permanent removal.
|
|
@@ -10823,8 +10948,7 @@ function createSlotAllocator() {
|
|
|
10823
10948
|
};
|
|
10824
10949
|
}
|
|
10825
10950
|
|
|
10826
|
-
|
|
10827
|
-
//#region ../row-model/dist/transaction-draft.js
|
|
10951
|
+
// ../row-model/dist/transaction-draft.js
|
|
10828
10952
|
var TransactionExecutionError = class extends PretableRowModelError {
|
|
10829
10953
|
constructor(error) {
|
|
10830
10954
|
super(error.code, error.message, {
|
|
@@ -11437,10 +11561,21 @@ function applyFlatTransactionDraft(input) {
|
|
|
11437
11561
|
const slotWrites = [...removedRecords.map((record) => [record.slot, void 0]), ...prepared.map((record) => [record.slot, record])];
|
|
11438
11562
|
const { next: recordsBySlot, chunksTouched } = slotVectorWithAll(input.root.recordsBySlot, slotWrites, input.slots.capacity);
|
|
11439
11563
|
if (input.instrumentation !== void 0) input.instrumentation.work.slotChunksTouched += chunksTouched;
|
|
11564
|
+
const frozenSource = sourceDraft.freeze();
|
|
11565
|
+
const summaries = input.root.summaries === void 0 ? void 0 : updateSummaryIndex(input.root, {
|
|
11566
|
+
...input.root,
|
|
11567
|
+
rows: frozenRows,
|
|
11568
|
+
sourceOrder: frozenSource,
|
|
11569
|
+
visible,
|
|
11570
|
+
recordsBySlot,
|
|
11571
|
+
visibleSlots,
|
|
11572
|
+
queryPlan: input.queryPlan
|
|
11573
|
+
}, [...effectiveRemoves, ...prepared.map((record) => record.rowId)], input.instrumentation);
|
|
11440
11574
|
for (const record of removedRecords) input.slots.release(record.slot);
|
|
11441
11575
|
return {
|
|
11442
11576
|
rows: frozenRows,
|
|
11443
|
-
sourceOrder:
|
|
11577
|
+
sourceOrder: frozenSource,
|
|
11578
|
+
summaries,
|
|
11444
11579
|
visible,
|
|
11445
11580
|
recordsBySlot,
|
|
11446
11581
|
visibleSlots,
|
|
@@ -11662,10 +11797,20 @@ function replaceFlatRowsDraft(input) {
|
|
|
11662
11797
|
const slotWrites = [...removedRecords.map((record) => [record.slot, void 0]), ...changedRecords.map((record) => [record.slot, record])];
|
|
11663
11798
|
const { next: recordsBySlot, chunksTouched } = slotVectorWithAll(input.root.recordsBySlot, slotWrites, input.slots.capacity);
|
|
11664
11799
|
if (input.instrumentation !== void 0) input.instrumentation.work.slotChunksTouched += chunksTouched;
|
|
11800
|
+
const summaries = input.root.summaries === void 0 ? void 0 : updateSummaryIndex(input.root, {
|
|
11801
|
+
...input.root,
|
|
11802
|
+
rows: frozenRows,
|
|
11803
|
+
sourceOrder: frozenSource,
|
|
11804
|
+
visible,
|
|
11805
|
+
recordsBySlot,
|
|
11806
|
+
visibleSlots,
|
|
11807
|
+
queryPlan: input.queryPlan
|
|
11808
|
+
}, [...removedRecords.map((record) => record.rowId), ...changedRecords.map((record) => record.rowId)], input.instrumentation);
|
|
11665
11809
|
for (const slot of reusableRemovedSlots) input.slots.release(slot);
|
|
11666
11810
|
return {
|
|
11667
11811
|
rows: frozenRows,
|
|
11668
11812
|
sourceOrder: frozenSource,
|
|
11813
|
+
summaries,
|
|
11669
11814
|
visible,
|
|
11670
11815
|
recordsBySlot,
|
|
11671
11816
|
visibleSlots,
|
|
@@ -11688,8 +11833,7 @@ function replaceFlatRowsDraft(input) {
|
|
|
11688
11833
|
}
|
|
11689
11834
|
}
|
|
11690
11835
|
|
|
11691
|
-
|
|
11692
|
-
//#region ../row-model/dist/create-local-row-model.js
|
|
11836
|
+
// ../row-model/dist/create-local-row-model.js
|
|
11693
11837
|
function createSnapshot(root, instrumentation) {
|
|
11694
11838
|
const snapshot = createFlatSnapshot(root);
|
|
11695
11839
|
if (instrumentation === void 0) return snapshot;
|
|
@@ -11972,6 +12116,25 @@ function createLocalRowModel$1(options) {
|
|
|
11972
12116
|
let nextSourceOrder = initialStore.records.length;
|
|
11973
12117
|
let nextTransitionId = 1;
|
|
11974
12118
|
let activeTransition;
|
|
12119
|
+
const summaryLeases = /* @__PURE__ */ new Map();
|
|
12120
|
+
const requestedSummaryScopes = () => ["all", "filtered"].filter((scope) => {
|
|
12121
|
+
var _summaryLeases$get;
|
|
12122
|
+
return ((_summaryLeases$get = summaryLeases.get(scope)) !== null && _summaryLeases$get !== void 0 ? _summaryLeases$get : 0) > 0;
|
|
12123
|
+
});
|
|
12124
|
+
let summaryAcquisition;
|
|
12125
|
+
let cancelSummaryRetry;
|
|
12126
|
+
const cancelSummaryAcquisition = () => {
|
|
12127
|
+
try {
|
|
12128
|
+
cancelSummaryRetry === null || cancelSummaryRetry === void 0 || cancelSummaryRetry();
|
|
12129
|
+
} catch (_unused2) {}
|
|
12130
|
+
cancelSummaryRetry = void 0;
|
|
12131
|
+
const pending = summaryAcquisition;
|
|
12132
|
+
summaryAcquisition = void 0;
|
|
12133
|
+
try {
|
|
12134
|
+
var _pending$cancel;
|
|
12135
|
+
pending === null || pending === void 0 || (_pending$cancel = pending.cancel) === null || _pending$cancel === void 0 || _pending$cancel.call(pending);
|
|
12136
|
+
} catch (_unused3) {}
|
|
12137
|
+
};
|
|
11975
12138
|
const listeners = /* @__PURE__ */ new Set();
|
|
11976
12139
|
const changeJournal = createChangeJournal(options.changeJournalCapacity);
|
|
11977
12140
|
const sortFastPathRowLimit = (_options$ɵsortFastPa = options.ɵsortFastPathRowLimit) !== null && _options$ɵsortFastPa !== void 0 ? _options$ɵsortFastPa : SORT_FAST_PATH_ROW_LIMIT_DEFAULT;
|
|
@@ -12023,9 +12186,10 @@ function createLocalRowModel$1(options) {
|
|
|
12023
12186
|
const notify = () => {
|
|
12024
12187
|
for (const listener of Array.from(listeners)) try {
|
|
12025
12188
|
listener();
|
|
12026
|
-
} catch (
|
|
12189
|
+
} catch (_unused4) {}
|
|
12027
12190
|
};
|
|
12028
12191
|
const publishCommittedRoot = (committedRoot, previousRevision, revision, barrierReason = "bulk-replace") => {
|
|
12192
|
+
cancelSummaryAcquisition();
|
|
12029
12193
|
queryPlan = committedRoot.queryPlan;
|
|
12030
12194
|
query = committedRoot.queryPlan.query;
|
|
12031
12195
|
derivations = committedRoot.queryPlan.derivations;
|
|
@@ -12048,7 +12212,8 @@ function createLocalRowModel$1(options) {
|
|
|
12048
12212
|
transition.cancelScheduled = void 0;
|
|
12049
12213
|
try {
|
|
12050
12214
|
cancelScheduled === null || cancelScheduled === void 0 || cancelScheduled();
|
|
12051
|
-
} catch (
|
|
12215
|
+
} catch (_unused5) {}
|
|
12216
|
+
transition.summaryBuild = void 0;
|
|
12052
12217
|
transition.candidate.release();
|
|
12053
12218
|
transition.reject(new PretableTransitionCancelledError(transition.id, reason));
|
|
12054
12219
|
return transition;
|
|
@@ -12061,7 +12226,8 @@ function createLocalRowModel$1(options) {
|
|
|
12061
12226
|
transition.cancelScheduled = void 0;
|
|
12062
12227
|
try {
|
|
12063
12228
|
cancelScheduled === null || cancelScheduled === void 0 || cancelScheduled();
|
|
12064
|
-
} catch (
|
|
12229
|
+
} catch (_unused6) {}
|
|
12230
|
+
transition.summaryBuild = void 0;
|
|
12065
12231
|
transition.candidate.release();
|
|
12066
12232
|
const typed = (_findPretableReentran = findPretableReentrantMutationError(error)) !== null && _findPretableReentran !== void 0 ? _findPretableReentran : transitionError(error, transition.operation);
|
|
12067
12233
|
state = Object.freeze({
|
|
@@ -12093,7 +12259,18 @@ function createLocalRowModel$1(options) {
|
|
|
12093
12259
|
const runTransitionSlice = (transition) => {
|
|
12094
12260
|
if (activeTransition !== transition || disposed) return false;
|
|
12095
12261
|
try {
|
|
12096
|
-
|
|
12262
|
+
var _transition$summaryBu3;
|
|
12263
|
+
const scopes = requestedSummaryScopes();
|
|
12264
|
+
const key = scopes.join(",");
|
|
12265
|
+
if (transition.summaryScopesKey !== key) {
|
|
12266
|
+
transition.summaryScopesKey = key;
|
|
12267
|
+
transition.summaryBuild = scopes.length ? createSummaryBuild(root, transition.summaryPlan, scopes, instrumentation) : void 0;
|
|
12268
|
+
}
|
|
12269
|
+
const complete = runCooperativeTransitionSlice(transitionRuntime, () => {
|
|
12270
|
+
var _transition$summaryBu, _transition$summaryBu2;
|
|
12271
|
+
if (!transition.candidate.step()) return false;
|
|
12272
|
+
return (_transition$summaryBu = (_transition$summaryBu2 = transition.summaryBuild) === null || _transition$summaryBu2 === void 0 ? void 0 : _transition$summaryBu2.step()) !== null && _transition$summaryBu !== void 0 ? _transition$summaryBu : true;
|
|
12273
|
+
});
|
|
12097
12274
|
if (activeTransition !== transition || disposed) return false;
|
|
12098
12275
|
if (!complete) {
|
|
12099
12276
|
state = Object.freeze({
|
|
@@ -12105,14 +12282,18 @@ function createLocalRowModel$1(options) {
|
|
|
12105
12282
|
}
|
|
12106
12283
|
const previousRevision = root.revision;
|
|
12107
12284
|
const revision = previousRevision + 1;
|
|
12108
|
-
const committedRoot =
|
|
12285
|
+
const committedRoot = Object.freeze({
|
|
12286
|
+
...transition.candidate.finish(revision),
|
|
12287
|
+
summaries: (_transition$summaryBu3 = transition.summaryBuild) === null || _transition$summaryBu3 === void 0 ? void 0 : _transition$summaryBu3.finish()
|
|
12288
|
+
});
|
|
12109
12289
|
activeTransition = void 0;
|
|
12110
12290
|
const cancelScheduled = transition.cancelScheduled;
|
|
12111
12291
|
transition.cancelScheduled = void 0;
|
|
12112
12292
|
try {
|
|
12113
12293
|
cancelScheduled === null || cancelScheduled === void 0 || cancelScheduled();
|
|
12114
|
-
} catch (
|
|
12294
|
+
} catch (_unused7) {}
|
|
12115
12295
|
publishCommittedRoot(committedRoot, previousRevision, revision);
|
|
12296
|
+
transition.summaryBuild = void 0;
|
|
12116
12297
|
transition.candidate.release();
|
|
12117
12298
|
transition.resolve(revision);
|
|
12118
12299
|
return true;
|
|
@@ -12140,6 +12321,9 @@ function createLocalRowModel$1(options) {
|
|
|
12140
12321
|
operation,
|
|
12141
12322
|
instrumentation
|
|
12142
12323
|
}),
|
|
12324
|
+
summaryPlan: nextPlan,
|
|
12325
|
+
summaryScopesKey: "",
|
|
12326
|
+
summaryBuild: void 0,
|
|
12143
12327
|
finished,
|
|
12144
12328
|
resolve,
|
|
12145
12329
|
reject,
|
|
@@ -12154,6 +12338,14 @@ function createLocalRowModel$1(options) {
|
|
|
12154
12338
|
return transition;
|
|
12155
12339
|
};
|
|
12156
12340
|
const appendTransitionDelta = (target, affectedRowIds) => {
|
|
12341
|
+
var _activeTransition$sum;
|
|
12342
|
+
if (summaryAcquisition) {
|
|
12343
|
+
if (summaryAcquisition.rebase !== void 0 || summaryAcquisition.plan !== target.queryPlan) {
|
|
12344
|
+
summaryAcquisition.plan = target.queryPlan;
|
|
12345
|
+
summaryAcquisition.rebase = target;
|
|
12346
|
+
} else summaryAcquisition.build.append(target, affectedRowIds);
|
|
12347
|
+
}
|
|
12348
|
+
activeTransition === null || activeTransition === void 0 || (_activeTransition$sum = activeTransition.summaryBuild) === null || _activeTransition$sum === void 0 || _activeTransition$sum.append(target, affectedRowIds);
|
|
12157
12349
|
activeTransition === null || activeTransition === void 0 || activeTransition.candidate.append(Object.freeze({
|
|
12158
12350
|
target,
|
|
12159
12351
|
affectedRowIds: Object.freeze([...affectedRowIds])
|
|
@@ -12213,9 +12405,139 @@ function createLocalRowModel$1(options) {
|
|
|
12213
12405
|
throw remapOperationError(error, operation);
|
|
12214
12406
|
}
|
|
12215
12407
|
};
|
|
12408
|
+
const reportSummaryFailure = (error) => {
|
|
12409
|
+
if (activeTransition === void 0) state = Object.freeze({
|
|
12410
|
+
snapshot,
|
|
12411
|
+
status: Object.freeze({
|
|
12412
|
+
kind: "error",
|
|
12413
|
+
transitionId: nextTransitionId++,
|
|
12414
|
+
error: transitionError(error, "set-derivations")
|
|
12415
|
+
})
|
|
12416
|
+
});
|
|
12417
|
+
};
|
|
12418
|
+
const restartSummaryAcquisition = () => {
|
|
12419
|
+
const scopes = requestedSummaryScopes();
|
|
12420
|
+
const key = scopes.join(",");
|
|
12421
|
+
if ((summaryAcquisition === null || summaryAcquisition === void 0 ? void 0 : summaryAcquisition.key) === key && summaryAcquisition.plan === root.queryPlan) return;
|
|
12422
|
+
if (scopes.every((scope) => {
|
|
12423
|
+
var _root$summaries;
|
|
12424
|
+
return ((_root$summaries = root.summaries) === null || _root$summaries === void 0 ? void 0 : _root$summaries.results[scope]) !== void 0;
|
|
12425
|
+
})) {
|
|
12426
|
+
cancelSummaryAcquisition();
|
|
12427
|
+
return;
|
|
12428
|
+
}
|
|
12429
|
+
const previousAcquisition = summaryAcquisition;
|
|
12430
|
+
const pending = {
|
|
12431
|
+
plan: root.queryPlan,
|
|
12432
|
+
key,
|
|
12433
|
+
rebase: void 0,
|
|
12434
|
+
build: createSummaryBuild(root, root.queryPlan, scopes, instrumentation),
|
|
12435
|
+
cancel: void 0
|
|
12436
|
+
};
|
|
12437
|
+
summaryAcquisition = pending;
|
|
12438
|
+
const advance = () => {
|
|
12439
|
+
if (disposed || summaryAcquisition !== pending) return;
|
|
12440
|
+
if (pending.rebase !== void 0) {
|
|
12441
|
+
pending.build = createSummaryBuild(pending.rebase, pending.plan, requestedSummaryScopes(), instrumentation);
|
|
12442
|
+
pending.rebase = void 0;
|
|
12443
|
+
}
|
|
12444
|
+
if (runCooperativeTransitionSlice(transitionRuntime, () => pending.build.step())) {
|
|
12445
|
+
const previous = root;
|
|
12446
|
+
const next = Object.freeze({
|
|
12447
|
+
...root,
|
|
12448
|
+
revision: root.revision + 1,
|
|
12449
|
+
parentRevision: root.revision,
|
|
12450
|
+
summaries: retainSummaryScopes(pending.build.finish(), requestedSummaryScopes())
|
|
12451
|
+
});
|
|
12452
|
+
summaryAcquisition = void 0;
|
|
12453
|
+
appendTransitionDelta(next, []);
|
|
12454
|
+
commit(next);
|
|
12455
|
+
changeJournal.appendChanges(previous.revision, next.revision, Object.freeze([]));
|
|
12456
|
+
} else pending.cancel = transitionRuntime.scheduler.schedule(() => {
|
|
12457
|
+
if (disposed || summaryAcquisition !== pending) return;
|
|
12458
|
+
try {
|
|
12459
|
+
guarded("set-derivations", advance);
|
|
12460
|
+
} catch (error) {
|
|
12461
|
+
cancelSummaryAcquisition();
|
|
12462
|
+
reportSummaryFailure(error);
|
|
12463
|
+
}
|
|
12464
|
+
notify();
|
|
12465
|
+
});
|
|
12466
|
+
};
|
|
12467
|
+
try {
|
|
12468
|
+
advance();
|
|
12469
|
+
} catch (error) {
|
|
12470
|
+
try {
|
|
12471
|
+
var _pending$cancel2;
|
|
12472
|
+
(_pending$cancel2 = pending.cancel) === null || _pending$cancel2 === void 0 || _pending$cancel2.call(pending);
|
|
12473
|
+
} catch (_unused8) {}
|
|
12474
|
+
summaryAcquisition = previousAcquisition;
|
|
12475
|
+
throw error;
|
|
12476
|
+
}
|
|
12477
|
+
try {
|
|
12478
|
+
var _previousAcquisition$;
|
|
12479
|
+
previousAcquisition === null || previousAcquisition === void 0 || (_previousAcquisition$ = previousAcquisition.cancel) === null || _previousAcquisition$ === void 0 || _previousAcquisition$.call(previousAcquisition);
|
|
12480
|
+
} catch (_unused9) {}
|
|
12481
|
+
};
|
|
12216
12482
|
const model = {
|
|
12217
12483
|
getState: () => state,
|
|
12218
12484
|
getColumns: () => columns,
|
|
12485
|
+
acquireSummaryScopes(scopes) {
|
|
12486
|
+
assertCommandAllowed("set-derivations");
|
|
12487
|
+
const unique = [...new Set(scopes)];
|
|
12488
|
+
if (unique.some((scope) => scope !== "all" && scope !== "filtered")) throw new TypeError("Unknown summary scope.");
|
|
12489
|
+
guarded("set-derivations", () => {
|
|
12490
|
+
var _summaryLeases$get2;
|
|
12491
|
+
for (const scope of unique) summaryLeases.set(scope, ((_summaryLeases$get2 = summaryLeases.get(scope)) !== null && _summaryLeases$get2 !== void 0 ? _summaryLeases$get2 : 0) + 1);
|
|
12492
|
+
try {
|
|
12493
|
+
restartSummaryAcquisition();
|
|
12494
|
+
} catch (error) {
|
|
12495
|
+
for (const scope of unique) summaryLeases.set(scope, summaryLeases.get(scope) - 1);
|
|
12496
|
+
throw error;
|
|
12497
|
+
}
|
|
12498
|
+
});
|
|
12499
|
+
notify();
|
|
12500
|
+
let released = false;
|
|
12501
|
+
return () => {
|
|
12502
|
+
if (released || disposed) return;
|
|
12503
|
+
guarded("set-derivations", () => {
|
|
12504
|
+
released = true;
|
|
12505
|
+
for (const scope of unique) summaryLeases.set(scope, summaryLeases.get(scope) - 1);
|
|
12506
|
+
const retained = retainSummaryScopes(root.summaries, requestedSummaryScopes());
|
|
12507
|
+
commit(Object.freeze({
|
|
12508
|
+
...root,
|
|
12509
|
+
summaries: retained
|
|
12510
|
+
}));
|
|
12511
|
+
const requested = requestedSummaryScopes();
|
|
12512
|
+
if (summaryAcquisition) {
|
|
12513
|
+
summaryAcquisition.build.retainScopes(requested);
|
|
12514
|
+
summaryAcquisition.key = requested.join(",");
|
|
12515
|
+
if (requested.every((scope) => {
|
|
12516
|
+
var _root$summaries2;
|
|
12517
|
+
return ((_root$summaries2 = root.summaries) === null || _root$summaries2 === void 0 ? void 0 : _root$summaries2.results[scope]) !== void 0;
|
|
12518
|
+
})) cancelSummaryAcquisition();
|
|
12519
|
+
} else if (requested.some((scope) => {
|
|
12520
|
+
var _root$summaries3;
|
|
12521
|
+
return ((_root$summaries3 = root.summaries) === null || _root$summaries3 === void 0 ? void 0 : _root$summaries3.results[scope]) === void 0;
|
|
12522
|
+
})) try {
|
|
12523
|
+
cancelSummaryRetry === null || cancelSummaryRetry === void 0 || cancelSummaryRetry();
|
|
12524
|
+
cancelSummaryRetry = transitionRuntime.scheduler.schedule(() => {
|
|
12525
|
+
cancelSummaryRetry = void 0;
|
|
12526
|
+
if (disposed) return;
|
|
12527
|
+
try {
|
|
12528
|
+
guarded("set-derivations", restartSummaryAcquisition);
|
|
12529
|
+
} catch (error) {
|
|
12530
|
+
reportSummaryFailure(error);
|
|
12531
|
+
}
|
|
12532
|
+
notify();
|
|
12533
|
+
});
|
|
12534
|
+
} catch (error) {
|
|
12535
|
+
reportSummaryFailure(error);
|
|
12536
|
+
}
|
|
12537
|
+
});
|
|
12538
|
+
notify();
|
|
12539
|
+
};
|
|
12540
|
+
},
|
|
12219
12541
|
subscribe(listener) {
|
|
12220
12542
|
if (disposed) return () => void 0;
|
|
12221
12543
|
listeners.add(listener);
|
|
@@ -12283,6 +12605,7 @@ function createLocalRowModel$1(options) {
|
|
|
12283
12605
|
revision: previousRevision + 1,
|
|
12284
12606
|
parentRevision: previousRevision,
|
|
12285
12607
|
rows: drafted.rows,
|
|
12608
|
+
summaries: drafted.summaries,
|
|
12286
12609
|
sourceOrder: drafted.sourceOrder,
|
|
12287
12610
|
recordsBySlot: drafted.recordsBySlot,
|
|
12288
12611
|
slotCapacity: slots.capacity,
|
|
@@ -12335,6 +12658,7 @@ function createLocalRowModel$1(options) {
|
|
|
12335
12658
|
revision: result.revision,
|
|
12336
12659
|
parentRevision: previousRoot.revision,
|
|
12337
12660
|
rows: drafted.rows,
|
|
12661
|
+
summaries: drafted.summaries,
|
|
12338
12662
|
sourceOrder: drafted.sourceOrder,
|
|
12339
12663
|
recordsBySlot: drafted.recordsBySlot,
|
|
12340
12664
|
slotCapacity: slots.capacity,
|
|
@@ -12388,7 +12712,7 @@ function createLocalRowModel$1(options) {
|
|
|
12388
12712
|
};
|
|
12389
12713
|
}
|
|
12390
12714
|
const residentRowCount = root.rows.size;
|
|
12391
|
-
const fastPath = nextPlan.query.rowGroups.length > 0 ? void 0 : isSortOnlyChange(queryPlan, nextPlan) ? residentRowCount <= sortFastPathRowLimit ? Object.freeze({
|
|
12715
|
+
const fastPath = nextPlan.query.rowGroups.length > 0 || requestedSummaryScopes().length > 0 ? void 0 : isSortOnlyChange(queryPlan, nextPlan) ? residentRowCount <= sortFastPathRowLimit ? Object.freeze({
|
|
12392
12716
|
rebuild: rebuildRootForSortOnlyChange,
|
|
12393
12717
|
barrierReason: "reorder"
|
|
12394
12718
|
}) : void 0 : isFilterOnlyChange(queryPlan, nextPlan) ? residentRowCount <= filterFastPathRowLimit ? Object.freeze({
|
|
@@ -12583,6 +12907,8 @@ function createLocalRowModel$1(options) {
|
|
|
12583
12907
|
if (activeMutation !== void 0) throw new PretableReentrantMutationError("dispose", activeMutation);
|
|
12584
12908
|
if (disposed) return;
|
|
12585
12909
|
const current = guarded("dispose", () => {
|
|
12910
|
+
cancelSummaryAcquisition();
|
|
12911
|
+
summaryLeases.clear();
|
|
12586
12912
|
cancelActiveTransition("disposed");
|
|
12587
12913
|
distinctValues.dispose(new PretableDisposedModelError("distinct-values"));
|
|
12588
12914
|
changeJournal.clear();
|
|
@@ -12598,7 +12924,7 @@ function createLocalRowModel$1(options) {
|
|
|
12598
12924
|
});
|
|
12599
12925
|
for (const listener of current) try {
|
|
12600
12926
|
listener();
|
|
12601
|
-
} catch (
|
|
12927
|
+
} catch (_unused10) {}
|
|
12602
12928
|
}
|
|
12603
12929
|
};
|
|
12604
12930
|
modelChangeJournals.set(model, changeJournal);
|
|
@@ -12623,8 +12949,7 @@ function createLocalRowModel$1(options) {
|
|
|
12623
12949
|
return model;
|
|
12624
12950
|
}
|
|
12625
12951
|
|
|
12626
|
-
|
|
12627
|
-
//#region ../row-model/dist/aggregate-overrides.js
|
|
12952
|
+
// ../row-model/dist/aggregate-overrides.js
|
|
12628
12953
|
/**
|
|
12629
12954
|
* Per-column aggregate OVERRIDES, applied to a derivation list.
|
|
12630
12955
|
*
|
|
@@ -12710,13 +13035,11 @@ function mergeColumnAggregateOverrides(derivations, overrides) {
|
|
|
12710
13035
|
return changed ? merged : derivations;
|
|
12711
13036
|
}
|
|
12712
13037
|
|
|
12713
|
-
|
|
12714
|
-
//#region ../row-model/dist/aggregator-law.js
|
|
13038
|
+
// ../row-model/dist/aggregator-law.js
|
|
12715
13039
|
const DEVELOPMENT = process.env.NODE_ENV !== "production";
|
|
12716
13040
|
const productionValidator = Object.freeze({ observe: () => void 0 });
|
|
12717
13041
|
|
|
12718
|
-
|
|
12719
|
-
//#region src/create-column-helper.ts
|
|
13042
|
+
// src/create-column-helper.ts
|
|
12720
13043
|
/**
|
|
12721
13044
|
* Creates a typed column-definition helper for an ordinary row object.
|
|
12722
13045
|
*
|
|
@@ -12726,14 +13049,12 @@ function createColumnHelper() {
|
|
|
12726
13049
|
return createColumnHelper$1();
|
|
12727
13050
|
}
|
|
12728
13051
|
|
|
12729
|
-
|
|
12730
|
-
//#region src/create-local-row-model.ts
|
|
13052
|
+
// src/create-local-row-model.ts
|
|
12731
13053
|
function createLocalRowModel(options) {
|
|
12732
13054
|
return createLocalRowModel$1(options);
|
|
12733
13055
|
}
|
|
12734
13056
|
|
|
12735
|
-
|
|
12736
|
-
//#region src/number-formats.ts
|
|
13057
|
+
// src/number-formats.ts
|
|
12737
13058
|
function currencyOptions(options, currencySign) {
|
|
12738
13059
|
return {
|
|
12739
13060
|
...options,
|
|
@@ -12756,7 +13077,6 @@ const numberFormats = {
|
|
|
12756
13077
|
}
|
|
12757
13078
|
};
|
|
12758
13079
|
|
|
12759
|
-
//#endregion
|
|
12760
13080
|
exports.GROUP_COLUMN_ID = GROUP_COLUMN_ID;
|
|
12761
13081
|
exports.PretableDisposedModelError = PretableDisposedModelError;
|
|
12762
13082
|
exports.PretableInvalidGroupKeyError = PretableInvalidGroupKeyError;
|