@gtkx/components 2.0.0-beta.12 → 2.0.0-beta.13
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/README.md +1 -1
- package/dist/column-view.d.ts.map +1 -1
- package/dist/column-view.js +7 -3
- package/dist/column-view.js.map +1 -1
- package/dist/combo-row.d.ts.map +1 -1
- package/dist/combo-row.js +3 -1
- package/dist/combo-row.js.map +1 -1
- package/dist/grid-view.d.ts.map +1 -1
- package/dist/grid-view.js +3 -2
- package/dist/grid-view.js.map +1 -1
- package/dist/index.d.ts +1 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -1
- package/dist/index.js.map +1 -1
- package/dist/internal/cells.d.ts +5 -2
- package/dist/internal/cells.d.ts.map +1 -1
- package/dist/internal/cells.js +86 -43
- package/dist/internal/cells.js.map +1 -1
- package/dist/internal/collection-index.d.ts +3 -5
- package/dist/internal/collection-index.d.ts.map +1 -1
- package/dist/internal/collection-index.js +3 -7
- package/dist/internal/collection-index.js.map +1 -1
- package/dist/internal/collection-model.d.ts +15 -4
- package/dist/internal/collection-model.d.ts.map +1 -1
- package/dist/internal/collection-model.js +154 -73
- package/dist/internal/collection-model.js.map +1 -1
- package/dist/internal/collection.d.ts +3 -3
- package/dist/internal/collection.d.ts.map +1 -1
- package/dist/internal/collection.js +11 -9
- package/dist/internal/collection.js.map +1 -1
- package/dist/internal/controlled-sync.d.ts +2 -1
- package/dist/internal/controlled-sync.d.ts.map +1 -1
- package/dist/internal/controlled-sync.js +6 -1
- package/dist/internal/controlled-sync.js.map +1 -1
- package/dist/internal/drop-down.d.ts +10 -4
- package/dist/internal/drop-down.d.ts.map +1 -1
- package/dist/internal/drop-down.js +60 -8
- package/dist/internal/drop-down.js.map +1 -1
- package/dist/internal/expansion.d.ts.map +1 -1
- package/dist/internal/expansion.js +46 -19
- package/dist/internal/expansion.js.map +1 -1
- package/dist/internal/first-header.d.ts +11 -0
- package/dist/internal/first-header.d.ts.map +1 -0
- package/dist/internal/first-header.js +21 -0
- package/dist/internal/first-header.js.map +1 -0
- package/dist/internal/level-splice.d.ts +27 -0
- package/dist/internal/level-splice.d.ts.map +1 -0
- package/dist/internal/level-splice.js +98 -0
- package/dist/internal/level-splice.js.map +1 -0
- package/dist/internal/selection.d.ts.map +1 -1
- package/dist/internal/selection.js +23 -16
- package/dist/internal/selection.js.map +1 -1
- package/dist/internal/tree-expansion.d.ts +3 -1
- package/dist/internal/tree-expansion.d.ts.map +1 -1
- package/dist/internal/tree-expansion.js +31 -2
- package/dist/internal/tree-expansion.js.map +1 -1
- package/dist/internal/tree-order.d.ts +1 -0
- package/dist/internal/tree-order.d.ts.map +1 -1
- package/dist/internal/tree-order.js +2 -1
- package/dist/internal/tree-order.js.map +1 -1
- package/dist/internal/use-collection.d.ts +1 -0
- package/dist/internal/use-collection.d.ts.map +1 -1
- package/dist/internal/use-collection.js +6 -2
- package/dist/internal/use-collection.js.map +1 -1
- package/dist/list-item-factory.d.ts +1 -1
- package/dist/list-item-factory.d.ts.map +1 -1
- package/dist/list-item-factory.js +2 -2
- package/dist/list-item-factory.js.map +1 -1
- package/dist/list-view.d.ts.map +1 -1
- package/dist/list-view.js +8 -3
- package/dist/list-view.js.map +1 -1
- package/dist/types.d.ts +37 -47
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -8
- package/src/column-view.tsx +8 -4
- package/src/combo-row.tsx +4 -1
- package/src/grid-view.tsx +3 -2
- package/src/index.ts +0 -4
- package/src/internal/cells.tsx +141 -53
- package/src/internal/collection-index.ts +7 -14
- package/src/internal/collection-model.ts +211 -76
- package/src/internal/collection.ts +14 -13
- package/src/internal/controlled-sync.ts +8 -1
- package/src/internal/drop-down.tsx +111 -14
- package/src/internal/expansion.ts +52 -20
- package/src/internal/first-header.ts +23 -0
- package/src/internal/level-splice.ts +157 -0
- package/src/internal/selection.tsx +24 -19
- package/src/internal/tree-expansion.ts +52 -2
- package/src/internal/tree-order.ts +3 -1
- package/src/internal/use-collection.tsx +8 -2
- package/src/list-item-factory.tsx +2 -1
- package/src/list-view.tsx +10 -2
- package/src/types.ts +39 -51
- package/dist/tab-collection.d.ts +0 -9
- package/dist/tab-collection.d.ts.map +0 -1
- package/dist/tab-collection.js +0 -114
- package/dist/tab-collection.js.map +0 -1
- package/src/tab-collection.tsx +0 -124
|
@@ -5,11 +5,17 @@ import { createElementComponent } from "@gtkx/react";
|
|
|
5
5
|
import { registerClass } from "@gtkx/runtime";
|
|
6
6
|
import { createCollectionIndex } from "./collection-index.js";
|
|
7
7
|
import { encodePart } from "./keys.js";
|
|
8
|
-
import {
|
|
8
|
+
import { findSplice, hasSplice, matchMoves, NO_SPLICE, relocateEntries, relocateSlot, searchableSplice, } from "./level-splice.js";
|
|
9
|
+
import { adoptIndex, createTreeExpansion, pruneSlots, relocateSlots } from "./tree-expansion.js";
|
|
9
10
|
const STORE_CLASS_KEY = Symbol.for("gtkx.components.lazy-level-store");
|
|
10
11
|
const ROOT_CLASS_KEY = Symbol.for("gtkx.components.collection-root-store");
|
|
11
12
|
const SLOTS_KEY = Symbol.for("gtkx.components.lazy-level-store.slots");
|
|
12
13
|
const EMPTY_INDEX = createCollectionIndex(undefined, [], true);
|
|
14
|
+
const serial = { value: 0 };
|
|
15
|
+
function nextKey() {
|
|
16
|
+
serial.value += 1;
|
|
17
|
+
return String(serial.value);
|
|
18
|
+
}
|
|
13
19
|
function sharedSlots() {
|
|
14
20
|
const cached = Reflect.get(globalThis, SLOTS_KEY);
|
|
15
21
|
if (cached instanceof WeakMap) {
|
|
@@ -37,13 +43,16 @@ function registeredRootClass() {
|
|
|
37
43
|
Reflect.set(globalThis, ROOT_CLASS_KEY, CollectionRootStore);
|
|
38
44
|
return CollectionRootStore;
|
|
39
45
|
}
|
|
40
|
-
function
|
|
46
|
+
function anySlotRefFor(value) {
|
|
41
47
|
const item = value instanceof Gtk.TreeListRow ? value.getItem() : value;
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const ref =
|
|
46
|
-
return ref ===
|
|
48
|
+
return item === null ? null : (sharedSlots().get(item) ?? null);
|
|
49
|
+
}
|
|
50
|
+
function slotRefFor(value) {
|
|
51
|
+
const ref = anySlotRefFor(value);
|
|
52
|
+
return ref === null || ref.slot === -1 ? null : ref;
|
|
53
|
+
}
|
|
54
|
+
function levelStoreFor(value) {
|
|
55
|
+
return anySlotRefFor(value)?.store ?? null;
|
|
47
56
|
}
|
|
48
57
|
function slotPathAt(store, slot) {
|
|
49
58
|
return store.level.path + encodePart(String(slot));
|
|
@@ -53,53 +62,89 @@ function newLevelStore(level) {
|
|
|
53
62
|
store.level = level;
|
|
54
63
|
return store;
|
|
55
64
|
}
|
|
56
|
-
function
|
|
65
|
+
function itemKeys(previous, next) {
|
|
66
|
+
return {
|
|
67
|
+
previousLength: previous.items.length,
|
|
68
|
+
nextLength: next.items.length,
|
|
69
|
+
previousKey: (slot) => previous.items[slot]?.id ?? "",
|
|
70
|
+
nextKey: (slot) => next.items[slot]?.id ?? "",
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function groupKey(index, group) {
|
|
74
|
+
const level = index.groups[group];
|
|
75
|
+
return level?.section?.id ?? "";
|
|
76
|
+
}
|
|
77
|
+
function groupKeys(previous, next) {
|
|
78
|
+
return {
|
|
79
|
+
previousLength: previous.groups.length,
|
|
80
|
+
nextLength: next.groups.length,
|
|
81
|
+
previousKey: (group) => groupKey(previous, group),
|
|
82
|
+
nextKey: (group) => groupKey(next, group),
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
function isExpandableAt(level, slot) {
|
|
86
|
+
return level.expandableFlags[slot] ?? false;
|
|
87
|
+
}
|
|
88
|
+
function collectFlips(previous, next, splice) {
|
|
57
89
|
const flipped = new Set();
|
|
58
90
|
if (previous.expandableFlags.length === 0 && next.expandableFlags.length === 0) {
|
|
59
91
|
return flipped;
|
|
60
92
|
}
|
|
61
|
-
for (let slot = 0; slot <
|
|
62
|
-
if ((previous
|
|
93
|
+
for (let slot = 0; slot < splice.start; slot++) {
|
|
94
|
+
if (isExpandableAt(previous, slot) !== isExpandableAt(next, slot)) {
|
|
63
95
|
flipped.add(slot);
|
|
64
96
|
}
|
|
65
97
|
}
|
|
98
|
+
const shift = splice.added - splice.removed;
|
|
99
|
+
for (let slot = splice.start + splice.removed; slot < previous.items.length; slot++) {
|
|
100
|
+
if (isExpandableAt(previous, slot) !== isExpandableAt(next, slot + shift)) {
|
|
101
|
+
flipped.add(slot + shift);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
66
104
|
return flipped;
|
|
67
105
|
}
|
|
106
|
+
function detachStore(store) {
|
|
107
|
+
for (const { ref } of store.slots.values()) {
|
|
108
|
+
ref.slot = -1;
|
|
109
|
+
}
|
|
110
|
+
for (const child of store.childStores.values()) {
|
|
111
|
+
detachStore(child);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
68
114
|
function pruneFlips(context, store, flipped) {
|
|
69
115
|
if (flipped.size === 0) {
|
|
70
116
|
return;
|
|
71
117
|
}
|
|
72
118
|
pruneSlots(context.expansion, store.level.path, (slot) => flipped.has(slot));
|
|
73
119
|
for (const slot of flipped) {
|
|
74
|
-
store.childStores.
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
for (const [slot, ref] of store.refs) {
|
|
79
|
-
if (slot < nextLength) {
|
|
80
|
-
continue;
|
|
120
|
+
const child = store.childStores.get(slot);
|
|
121
|
+
if (child !== undefined) {
|
|
122
|
+
detachStore(child);
|
|
123
|
+
store.childStores.delete(slot);
|
|
81
124
|
}
|
|
82
|
-
ref.slot = -1;
|
|
83
|
-
store.refs.delete(slot);
|
|
84
|
-
store.objects.delete(slot);
|
|
85
|
-
store.childStores.delete(slot);
|
|
86
125
|
}
|
|
87
126
|
}
|
|
88
|
-
function
|
|
89
|
-
if (
|
|
127
|
+
function renewKeys(store, previous, from, to) {
|
|
128
|
+
if (from === to) {
|
|
90
129
|
return;
|
|
91
130
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
if (nextLength < previousLength) {
|
|
97
|
-
store.itemsChanged(nextLength, previousLength - nextLength, 0);
|
|
98
|
-
return;
|
|
131
|
+
for (const [slot, { ref }] of store.slots) {
|
|
132
|
+
if (slot >= from && slot < to && previous.items[slot]?.id !== store.level.items[slot]?.id) {
|
|
133
|
+
ref.key = nextKey();
|
|
134
|
+
}
|
|
99
135
|
}
|
|
100
|
-
|
|
101
|
-
|
|
136
|
+
}
|
|
137
|
+
function relocateStore(context, store, keys, splice) {
|
|
138
|
+
const moves = matchMoves(keys, splice, store.slots.keys());
|
|
139
|
+
const shift = (slot) => relocateSlot(splice, slot);
|
|
140
|
+
store.slots = relocateEntries(store.slots, (slot) => relocateSlot(splice, slot, moves), ({ ref }) => {
|
|
141
|
+
ref.slot = -1;
|
|
142
|
+
});
|
|
143
|
+
for (const [slot, { ref }] of store.slots) {
|
|
144
|
+
ref.slot = slot;
|
|
102
145
|
}
|
|
146
|
+
store.childStores = relocateEntries(store.childStores, shift, detachStore);
|
|
147
|
+
relocateSlots(context.expansion, store.level.path, shift);
|
|
103
148
|
}
|
|
104
149
|
function extendRuns(runs, slot) {
|
|
105
150
|
const last = runs.at(-1);
|
|
@@ -123,18 +168,21 @@ function emitFlips(store, flipped) {
|
|
|
123
168
|
}
|
|
124
169
|
function syncLevel(context, store, level) {
|
|
125
170
|
const previous = store.level;
|
|
126
|
-
const
|
|
127
|
-
const
|
|
128
|
-
const
|
|
171
|
+
const keys = itemKeys(previous, level);
|
|
172
|
+
const found = previous.items === level.items ? NO_SPLICE : findSplice(keys);
|
|
173
|
+
const splice = searchableSplice(found, found.added);
|
|
129
174
|
store.level = level;
|
|
175
|
+
renewKeys(store, previous, found.start, splice.start);
|
|
176
|
+
if (hasSplice(splice)) {
|
|
177
|
+
relocateStore(context, store, keys, splice);
|
|
178
|
+
}
|
|
179
|
+
const flipped = collectFlips(previous, level, splice);
|
|
130
180
|
pruneFlips(context, store, flipped);
|
|
131
|
-
|
|
132
|
-
|
|
181
|
+
if (hasSplice(splice)) {
|
|
182
|
+
store.itemsChanged(splice.start, splice.removed, splice.added);
|
|
183
|
+
}
|
|
133
184
|
emitFlips(store, flipped);
|
|
134
185
|
for (const [slot, child] of store.childStores) {
|
|
135
|
-
if (slot >= overlap || flipped.has(slot)) {
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
186
|
const childLevel = context.index.childLevel(level, slot);
|
|
139
187
|
if (childLevel !== undefined) {
|
|
140
188
|
syncLevel(context, child, childLevel);
|
|
@@ -143,7 +191,7 @@ function syncLevel(context, store, level) {
|
|
|
143
191
|
}
|
|
144
192
|
function ensureChildStore(index, store, slot) {
|
|
145
193
|
const existing = store.childStores.get(slot) ?? null;
|
|
146
|
-
if (existing !== null || !(store.level
|
|
194
|
+
if (existing !== null || !isExpandableAt(store.level, slot)) {
|
|
147
195
|
return existing;
|
|
148
196
|
}
|
|
149
197
|
const level = index.childLevel(store.level, slot);
|
|
@@ -174,30 +222,42 @@ function rowAt(state, position) {
|
|
|
174
222
|
const item = state.model?.getItem(position);
|
|
175
223
|
return item instanceof Gtk.TreeListRow ? item : null;
|
|
176
224
|
}
|
|
177
|
-
function
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
225
|
+
function dropGroup(state, store) {
|
|
226
|
+
detachStore(store);
|
|
227
|
+
state.trees.delete(store);
|
|
228
|
+
}
|
|
229
|
+
function replaceGroups(state, before) {
|
|
230
|
+
for (const store of state.groupStores.values()) {
|
|
231
|
+
dropGroup(state, store);
|
|
232
|
+
}
|
|
233
|
+
state.groupStores.clear();
|
|
234
|
+
state.expansion.expanded.clear();
|
|
235
|
+
state.expansion.slots.clear();
|
|
236
|
+
state.root?.itemsChanged(0, before, state.index.groups.length);
|
|
237
|
+
}
|
|
238
|
+
function addedRows(index, splice) {
|
|
239
|
+
return index.groups
|
|
240
|
+
.slice(splice.start, splice.start + splice.added)
|
|
241
|
+
.reduce((rows, level) => rows + level.items.length, 0);
|
|
189
242
|
}
|
|
190
243
|
function syncRoot(state, previous) {
|
|
191
|
-
const before = previous.groups.length;
|
|
192
|
-
const after = state.index.groups.length;
|
|
193
244
|
if (previous.isTree !== state.index.isTree) {
|
|
194
|
-
state
|
|
245
|
+
replaceGroups(state, previous.groups.length);
|
|
195
246
|
return;
|
|
196
247
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
248
|
+
const keys = groupKeys(previous, state.index);
|
|
249
|
+
const found = findSplice(keys);
|
|
250
|
+
const splice = searchableSplice(found, addedRows(state.index, found));
|
|
251
|
+
if (!hasSplice(splice)) {
|
|
252
|
+
return;
|
|
200
253
|
}
|
|
254
|
+
const moves = matchMoves(keys, splice, state.groupStores.keys());
|
|
255
|
+
const relocate = (group) => relocateSlot(splice, group, moves);
|
|
256
|
+
state.groupStores = relocateEntries(state.groupStores, relocate, (store) => {
|
|
257
|
+
dropGroup(state, store);
|
|
258
|
+
});
|
|
259
|
+
relocateSlots(state.expansion, "", relocate);
|
|
260
|
+
state.root?.itemsChanged(splice.start, splice.removed, splice.added);
|
|
201
261
|
}
|
|
202
262
|
function stepGroupStores(state, context) {
|
|
203
263
|
for (const [group, store] of state.groupStores) {
|
|
@@ -207,7 +267,13 @@ function stepGroupStores(state, context) {
|
|
|
207
267
|
}
|
|
208
268
|
}
|
|
209
269
|
}
|
|
210
|
-
function
|
|
270
|
+
function rowCount(index) {
|
|
271
|
+
return index.groups.reduce((rows, level) => rows + level.items.length, 0);
|
|
272
|
+
}
|
|
273
|
+
function hasFilledSections(previous, index) {
|
|
274
|
+
return (rowCount(previous) === 0 && index.groups.some((level) => level.section !== undefined && level.items.length > 0));
|
|
275
|
+
}
|
|
276
|
+
function syncModel(state, index, onSectionsFilled) {
|
|
211
277
|
if (state.root === null) {
|
|
212
278
|
return;
|
|
213
279
|
}
|
|
@@ -216,14 +282,20 @@ function syncModel(state, index) {
|
|
|
216
282
|
state.index = index;
|
|
217
283
|
state.expansion.isSyncing = true;
|
|
218
284
|
try {
|
|
219
|
-
pruneGroups(state, previous);
|
|
220
285
|
syncRoot(state, previous);
|
|
221
286
|
stepGroupStores(state, context);
|
|
287
|
+
if (hasFilledSections(previous, index)) {
|
|
288
|
+
onSectionsFilled();
|
|
289
|
+
}
|
|
222
290
|
}
|
|
223
291
|
finally {
|
|
224
292
|
state.expansion.isSyncing = false;
|
|
225
293
|
}
|
|
226
294
|
adoptIndex(state.expansion, index);
|
|
295
|
+
state.version += 1;
|
|
296
|
+
for (const listener of state.listeners) {
|
|
297
|
+
listener();
|
|
298
|
+
}
|
|
227
299
|
}
|
|
228
300
|
function clearModel(state) {
|
|
229
301
|
const root = state.root;
|
|
@@ -251,6 +323,8 @@ function clearModel(state) {
|
|
|
251
323
|
}
|
|
252
324
|
function createCollectionModel() {
|
|
253
325
|
const state = {
|
|
326
|
+
version: 0,
|
|
327
|
+
listeners: new Set(),
|
|
254
328
|
root: null,
|
|
255
329
|
model: null,
|
|
256
330
|
groupStores: new Map(),
|
|
@@ -260,6 +334,14 @@ function createCollectionModel() {
|
|
|
260
334
|
};
|
|
261
335
|
return {
|
|
262
336
|
expansion: state.expansion,
|
|
337
|
+
subscribe: (onChange) => {
|
|
338
|
+
state.listeners.add(onChange);
|
|
339
|
+
return () => {
|
|
340
|
+
state.listeners.delete(onChange);
|
|
341
|
+
};
|
|
342
|
+
},
|
|
343
|
+
getVersion: () => state.version,
|
|
344
|
+
isPending: (index) => state.root !== null && state.index !== index,
|
|
263
345
|
rowAt: (position) => rowAt(state, position),
|
|
264
346
|
bind: (root, model) => {
|
|
265
347
|
root.state = state;
|
|
@@ -269,8 +351,8 @@ function createCollectionModel() {
|
|
|
269
351
|
clear: () => {
|
|
270
352
|
clearModel(state);
|
|
271
353
|
},
|
|
272
|
-
sync: (index) => {
|
|
273
|
-
syncModel(state, index);
|
|
354
|
+
sync: (index, onSectionsFilled) => {
|
|
355
|
+
syncModel(state, index, onSectionsFilled);
|
|
274
356
|
},
|
|
275
357
|
};
|
|
276
358
|
}
|
|
@@ -297,17 +379,16 @@ class CollectionRootStore extends GObject.Object {
|
|
|
297
379
|
}
|
|
298
380
|
}
|
|
299
381
|
class LazyLevelStore extends GObject.Object {
|
|
382
|
+
key = nextKey();
|
|
300
383
|
level = { path: "", items: [], expandableFlags: [] };
|
|
301
|
-
|
|
302
|
-
objects = new Map();
|
|
384
|
+
slots = new Map();
|
|
303
385
|
childStores = new Map();
|
|
304
386
|
createItem(position) {
|
|
305
|
-
const ref = { store: this, slot: position };
|
|
306
|
-
const
|
|
307
|
-
this.
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
return created;
|
|
387
|
+
const ref = { key: nextKey(), store: this, slot: position };
|
|
388
|
+
const object = Gtk.StringObject.new("");
|
|
389
|
+
this.slots.set(position, { ref, object });
|
|
390
|
+
sharedSlots().set(object, ref);
|
|
391
|
+
return object;
|
|
311
392
|
}
|
|
312
393
|
vfuncGetItemType() {
|
|
313
394
|
return GObject.TYPE_OBJECT;
|
|
@@ -319,9 +400,9 @@ class LazyLevelStore extends GObject.Object {
|
|
|
319
400
|
if (position < 0 || position >= this.level.items.length) {
|
|
320
401
|
return null;
|
|
321
402
|
}
|
|
322
|
-
return this.
|
|
403
|
+
return this.slots.get(position)?.object ?? this.createItem(position);
|
|
323
404
|
}
|
|
324
405
|
}
|
|
325
406
|
const CollectionRoot = createElementComponent("GtkxCollectionRootStore", registeredRootClass());
|
|
326
|
-
export { CollectionRoot, createCollectionModel, slotPathAt, slotRefFor, };
|
|
407
|
+
export { CollectionRoot, createCollectionModel, levelStoreFor, slotPathAt, slotRefFor, };
|
|
327
408
|
//# sourceMappingURL=collection-model.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-model.js","sourceRoot":"","s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@gtkx/gi/gio\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { createElementComponent } from \"@gtkx/react\";\nimport { registerClass } from \"@gtkx/runtime\";\nimport type { CollectionIndex, Level } from \"./collection-index.js\";\nimport type { TreeExpansion } from \"./tree-expansion.js\";\nimport { createCollectionIndex } from \"./collection-index.js\";\nimport { encodePart } from \"./keys.js\";\nimport { adoptIndex, createTreeExpansion, pruneSlots } from \"./tree-expansion.js\";\n\ntype LevelStore = Gio.ListModel & LazyLevelStore;\n\ntype SlotRef = {\n store: LazyLevelStore;\n slot: number;\n};\n\ntype SyncContext = {\n index: CollectionIndex;\n expansion: TreeExpansion;\n};\n\ntype SlotRun = {\n start: number;\n length: number;\n};\n\ntype ModelState = {\n root: CollectionRootStore | null;\n model: Gtk.FlattenListModel | null;\n groupStores: Map<number, LevelStore>;\n trees: Map<LevelStore, Gtk.TreeListModel>;\n expansion: TreeExpansion;\n index: CollectionIndex;\n};\n\ntype CollectionModel = {\n expansion: TreeExpansion;\n rowAt: (position: number) => Gtk.TreeListRow | null;\n bind: (root: CollectionRootStore, model: Gtk.FlattenListModel) => void;\n clear: () => void;\n sync: (index: CollectionIndex) => void;\n};\n\ntype CollectionRootProps = { ref: Ref<CollectionRootStore> };\n\nconst STORE_CLASS_KEY = Symbol.for(\"gtkx.components.lazy-level-store\");\nconst ROOT_CLASS_KEY = Symbol.for(\"gtkx.components.collection-root-store\");\nconst SLOTS_KEY = Symbol.for(\"gtkx.components.lazy-level-store.slots\");\nconst EMPTY_INDEX = createCollectionIndex(undefined, [], true);\n\nfunction sharedSlots(): WeakMap<GObject.Object, SlotRef> {\n const cached: unknown = Reflect.get(globalThis, SLOTS_KEY);\n\n if (cached instanceof WeakMap) {\n return cached as WeakMap<GObject.Object, SlotRef>;\n }\n\n const created: WeakMap<GObject.Object, SlotRef> = new WeakMap();\n Reflect.set(globalThis, SLOTS_KEY, created);\n\n return created;\n}\n\nfunction registeredStoreClass(): typeof LazyLevelStore {\n const cached: unknown = Reflect.get(globalThis, STORE_CLASS_KEY);\n\n if (typeof cached === \"function\") {\n return cached as typeof LazyLevelStore;\n }\n\n registerClass(LazyLevelStore, { typeName: \"GtkxLazyLevelStore\", implements: [Gio.ListModel] });\n Reflect.set(globalThis, STORE_CLASS_KEY, LazyLevelStore);\n\n return LazyLevelStore;\n}\n\nfunction registeredRootClass(): unknown {\n const cached: unknown = Reflect.get(globalThis, ROOT_CLASS_KEY);\n\n if (typeof cached === \"function\") {\n return cached;\n }\n\n registerClass(CollectionRootStore, { typeName: \"GtkxCollectionRootStore\", implements: [Gio.ListModel] });\n Reflect.set(globalThis, ROOT_CLASS_KEY, CollectionRootStore);\n\n return CollectionRootStore;\n}\n\nfunction slotRefFor(value: GObject.Object | null): SlotRef | null {\n const item = value instanceof Gtk.TreeListRow ? value.getItem() : value;\n\n if (item === null) {\n return null;\n }\n\n const ref = sharedSlots().get(item);\n\n return ref === undefined || ref.slot === -1 ? null : ref;\n}\n\nfunction slotPathAt(store: LazyLevelStore, slot: number): string {\n return store.level.path + encodePart(String(slot));\n}\n\nfunction newLevelStore(level: Level): LevelStore {\n const store = new (registeredStoreClass())() as LevelStore;\n store.level = level;\n\n return store;\n}\n\nfunction collectFlips(previous: Level, next: Level, overlap: number): Set<number> {\n const flipped: Set<number> = new Set();\n\n if (previous.expandableFlags.length === 0 && next.expandableFlags.length === 0) {\n return flipped;\n }\n\n for (let slot = 0; slot < overlap; slot++) {\n if ((previous.expandableFlags[slot] ?? false) !== (next.expandableFlags[slot] ?? false)) {\n flipped.add(slot);\n }\n }\n\n return flipped;\n}\n\nfunction pruneFlips(context: SyncContext, store: LevelStore, flipped: Set<number>): void {\n if (flipped.size === 0) {\n return;\n }\n\n pruneSlots(context.expansion, store.level.path, (slot) => flipped.has(slot));\n\n for (const slot of flipped) {\n store.childStores.delete(slot);\n }\n}\n\nfunction detachRefs(store: LevelStore, nextLength: number): void {\n for (const [slot, ref] of store.refs) {\n if (slot < nextLength) {\n continue;\n }\n\n ref.slot = -1;\n store.refs.delete(slot);\n store.objects.delete(slot);\n store.childStores.delete(slot);\n }\n}\n\nfunction shrinkStore(context: SyncContext, store: LevelStore, previousLength: number, nextLength: number): void {\n if (previousLength <= nextLength) {\n return;\n }\n\n detachRefs(store, nextLength);\n pruneSlots(context.expansion, store.level.path, (slot) => slot >= nextLength);\n}\n\nfunction emitTailSplice(store: LevelStore, previousLength: number, nextLength: number): void {\n if (nextLength < previousLength) {\n store.itemsChanged(nextLength, previousLength - nextLength, 0);\n\n return;\n }\n\n if (nextLength > previousLength) {\n store.itemsChanged(previousLength, 0, nextLength - previousLength);\n }\n}\n\nfunction extendRuns(runs: SlotRun[], slot: number): void {\n const last = runs.at(-1);\n\n if (last !== undefined && last.start + last.length === slot) {\n last.length += 1;\n\n return;\n }\n\n runs.push({ start: slot, length: 1 });\n}\n\nfunction collectFlipRuns(flipped: Set<number>): SlotRun[] {\n const runs: SlotRun[] = [];\n\n for (const slot of flipped) {\n extendRuns(runs, slot);\n }\n\n return runs;\n}\n\nfunction emitFlips(store: LevelStore, flipped: Set<number>): void {\n for (const run of collectFlipRuns(flipped)) {\n store.itemsChanged(run.start, run.length, run.length);\n }\n}\n\nfunction syncLevel(context: SyncContext, store: LevelStore, level: Level): void {\n const previous = store.level;\n const previousLength = previous.items.length;\n const overlap = Math.min(previousLength, level.items.length);\n const flipped = collectFlips(previous, level, overlap);\n store.level = level;\n pruneFlips(context, store, flipped);\n shrinkStore(context, store, previousLength, level.items.length);\n emitTailSplice(store, previousLength, level.items.length);\n emitFlips(store, flipped);\n\n for (const [slot, child] of store.childStores) {\n if (slot >= overlap || flipped.has(slot)) {\n continue;\n }\n\n const childLevel = context.index.childLevel(level, slot);\n\n if (childLevel !== undefined) {\n syncLevel(context, child, childLevel);\n }\n }\n}\n\nfunction ensureChildStore(index: CollectionIndex, store: LazyLevelStore, slot: number): LevelStore | null {\n const existing = store.childStores.get(slot) ?? null;\n\n if (existing !== null || !(store.level.expandableFlags[slot] ?? false)) {\n return existing;\n }\n\n const level = index.childLevel(store.level, slot);\n\n if (level === undefined) {\n return null;\n }\n\n const created = newLevelStore(level);\n store.childStores.set(slot, created);\n\n return created;\n}\n\nfunction childStoreFor(state: ModelState, object: GObject.Object): Gio.ListModel | null {\n const ref = slotRefFor(object);\n\n if (ref === null) {\n return null;\n }\n\n return ensureChildStore(state.index, ref.store, ref.slot);\n}\n\nfunction treeFor(state: ModelState, store: LevelStore): Gtk.TreeListModel {\n const existing = state.trees.get(store);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const created = Gtk.TreeListModel.new(store, false, false, (object) => childStoreFor(state, object));\n state.trees.set(store, created);\n\n return created;\n}\n\nfunction rowAt(state: ModelState, position: number): Gtk.TreeListRow | null {\n const item = state.model?.getItem(position);\n\n return item instanceof Gtk.TreeListRow ? item : null;\n}\n\nfunction pruneGroups(state: ModelState, previous: CollectionIndex): void {\n const hasModeChanged = previous.isTree !== state.index.isTree;\n\n for (const [group, store] of state.groupStores) {\n const isRemoved = group >= state.index.groups.length;\n\n if (isRemoved || hasModeChanged) {\n pruneSlots(state.expansion, store.level.path, () => true);\n state.trees.delete(store);\n }\n\n if (isRemoved) {\n state.groupStores.delete(group);\n }\n }\n}\n\nfunction syncRoot(state: ModelState, previous: CollectionIndex): void {\n const before = previous.groups.length;\n const after = state.index.groups.length;\n\n if (previous.isTree !== state.index.isTree) {\n state.root?.itemsChanged(0, before, after);\n\n return;\n }\n\n if (before !== after) {\n const start = Math.min(before, after);\n state.root?.itemsChanged(start, before - start, after - start);\n }\n}\n\nfunction stepGroupStores(state: ModelState, context: SyncContext): void {\n for (const [group, store] of state.groupStores) {\n const level = context.index.groups[group];\n\n if (level !== undefined && store.level !== level) {\n syncLevel(context, store, level);\n }\n }\n}\n\nfunction syncModel(state: ModelState, index: CollectionIndex): void {\n if (state.root === null) {\n return;\n }\n\n const context: SyncContext = { index, expansion: state.expansion };\n const previous = state.index;\n state.index = index;\n state.expansion.isSyncing = true;\n\n try {\n pruneGroups(state, previous);\n syncRoot(state, previous);\n stepGroupStores(state, context);\n } finally {\n state.expansion.isSyncing = false;\n }\n\n adoptIndex(state.expansion, index);\n}\n\nfunction clearModel(state: ModelState): void {\n const root = state.root;\n const previousLength = state.index.groups.length;\n state.expansion.isSyncing = true;\n\n try {\n if (root !== null) {\n root.state = null;\n }\n\n state.root = null;\n state.model = null;\n state.index = EMPTY_INDEX;\n state.groupStores.clear();\n state.trees.clear();\n state.expansion.expanded.clear();\n state.expansion.slots.clear();\n adoptIndex(state.expansion, EMPTY_INDEX);\n\n if (previousLength > 0) {\n root?.itemsChanged(0, previousLength, 0);\n }\n } finally {\n state.expansion.isSyncing = false;\n }\n}\n\nfunction createCollectionModel(): CollectionModel {\n const state: ModelState = {\n root: null,\n model: null,\n groupStores: new Map(),\n trees: new Map(),\n expansion: createTreeExpansion(EMPTY_INDEX),\n index: EMPTY_INDEX,\n };\n\n return {\n expansion: state.expansion,\n rowAt: (position) => rowAt(state, position),\n bind: (root, model) => {\n root.state = state;\n state.root = root;\n state.model = model;\n },\n clear: () => {\n clearModel(state);\n },\n sync: (index) => {\n syncModel(state, index);\n },\n };\n}\n\nclass CollectionRootStore extends GObject.Object implements Gio.ListModelImpl {\n declare itemsChanged: Gio.ListModel[\"itemsChanged\"];\n state: ModelState | null = null;\n\n vfuncGetItemType(): bigint {\n return GObject.TYPE_OBJECT;\n }\n\n vfuncGetNItems(): number {\n return this.state?.index.groups.length ?? 0;\n }\n\n vfuncGetItem(position: number): GObject.Object | null {\n const state = this.state;\n const level = state?.index.groups[position];\n\n if (state === null || level === undefined) {\n return null;\n }\n\n let store = state.groupStores.get(position);\n\n if (store === undefined) {\n store = newLevelStore(level);\n state.groupStores.set(position, store);\n }\n\n return state.index.isTree ? treeFor(state, store) : store;\n }\n}\n\nclass LazyLevelStore extends GObject.Object implements Gio.ListModelImpl {\n declare itemsChanged: Gio.ListModel[\"itemsChanged\"];\n level: Level = { path: \"\", items: [], expandableFlags: [] };\n refs: Map<number, SlotRef> = new Map();\n objects: Map<number, Gtk.StringObject> = new Map();\n childStores: Map<number, LevelStore> = new Map();\n\n private createItem(position: number): Gtk.StringObject {\n const ref = { store: this, slot: position };\n const created = Gtk.StringObject.new(\"\");\n this.refs.set(position, ref);\n this.objects.set(position, created);\n sharedSlots().set(created, ref);\n\n return created;\n }\n\n vfuncGetItemType(): bigint {\n return GObject.TYPE_OBJECT;\n }\n\n vfuncGetNItems(): number {\n return this.level.items.length;\n }\n\n vfuncGetItem(position: number): GObject.Object | null {\n if (position < 0 || position >= this.level.items.length) {\n return null;\n }\n\n return this.objects.get(position) ?? this.createItem(position);\n }\n}\n\nconst CollectionRoot: (props: CollectionRootProps) => ReactNode = createElementComponent<CollectionRootProps>(\n \"GtkxCollectionRootStore\",\n registeredRootClass(),\n);\n\nexport {\n CollectionRoot,\n createCollectionModel,\n slotPathAt,\n slotRefFor,\n type CollectionModel,\n type CollectionRootStore,\n type SlotRef,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"collection-model.js","sourceRoot":"","sources":["../../src/internal/collection-model.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EACH,UAAU,EACV,SAAS,EACT,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,EACZ,gBAAgB,GACnB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,aAAa,EAA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O,CAAC,WAAW,CAAC;IAC/B,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC;IACnC,CAAC;IAED,YAAY,CAAC,QAAgB;QACzB,IAAI,QAAQ,GAAG,CAAC,IAAI,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC;YACtD,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,MAAM,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACzE,CAAC;CACJ;AAED,MAAM,cAAc,GAA8C,sBAAsB,CACpF,yBAAyB,EACzB,mBAAmB,EAAE,CACxB,CAAC;AAEF,OAAO,EACH,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,UAAU,GAKb,CAAC","sourcesContent":["import type { ReactNode, Ref } from \"react\";\nimport * as Gio from \"@gtkx/gi/gio\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\nimport { createElementComponent } from \"@gtkx/react\";\nimport { registerClass } from \"@gtkx/runtime\";\nimport type { CollectionIndex, Level } from \"./collection-index.js\";\nimport type { TreeExpansion } from \"./tree-expansion.js\";\nimport { createCollectionIndex } from \"./collection-index.js\";\nimport type { LevelKeys, Relocate, Splice } from \"./level-splice.js\";\nimport { encodePart } from \"./keys.js\";\nimport {\n findSplice,\n hasSplice,\n matchMoves,\n NO_SPLICE,\n relocateEntries,\n relocateSlot,\n searchableSplice,\n} from \"./level-splice.js\";\nimport { adoptIndex, createTreeExpansion, pruneSlots, relocateSlots } from \"./tree-expansion.js\";\n\ntype LevelStore = Gio.ListModel & LazyLevelStore;\n\ntype SlotRef = {\n key: string;\n store: LazyLevelStore;\n slot: number;\n};\n\ntype SlotItem = {\n ref: SlotRef;\n object: Gtk.StringObject;\n};\n\ntype SyncContext = {\n index: CollectionIndex;\n expansion: TreeExpansion;\n};\n\ntype SlotRun = {\n start: number;\n length: number;\n};\n\ntype Serial = {\n value: number;\n};\n\ntype ModelState = {\n version: number;\n listeners: Set<() => void>;\n root: CollectionRootStore | null;\n model: Gtk.FlattenListModel | null;\n groupStores: Map<number, LevelStore>;\n trees: Map<LevelStore, Gtk.TreeListModel>;\n expansion: TreeExpansion;\n index: CollectionIndex;\n};\n\ntype CollectionModel = {\n expansion: TreeExpansion;\n subscribe: (onChange: () => void) => () => void;\n getVersion: () => number;\n isPending: (index: CollectionIndex) => boolean;\n rowAt: (position: number) => Gtk.TreeListRow | null;\n bind: (root: CollectionRootStore, model: Gtk.FlattenListModel) => void;\n clear: () => void;\n sync: (index: CollectionIndex, onSectionsFilled: () => void) => void;\n};\n\ntype CollectionRootProps = { ref: Ref<CollectionRootStore> };\n\nconst STORE_CLASS_KEY = Symbol.for(\"gtkx.components.lazy-level-store\");\nconst ROOT_CLASS_KEY = Symbol.for(\"gtkx.components.collection-root-store\");\nconst SLOTS_KEY = Symbol.for(\"gtkx.components.lazy-level-store.slots\");\nconst EMPTY_INDEX = createCollectionIndex(undefined, [], true);\nconst serial: Serial = { value: 0 };\n\nfunction nextKey(): string {\n serial.value += 1;\n\n return String(serial.value);\n}\n\nfunction sharedSlots(): WeakMap<GObject.Object, SlotRef> {\n const cached: unknown = Reflect.get(globalThis, SLOTS_KEY);\n\n if (cached instanceof WeakMap) {\n return cached as WeakMap<GObject.Object, SlotRef>;\n }\n\n const created: WeakMap<GObject.Object, SlotRef> = new WeakMap();\n Reflect.set(globalThis, SLOTS_KEY, created);\n\n return created;\n}\n\nfunction registeredStoreClass(): typeof LazyLevelStore {\n const cached: unknown = Reflect.get(globalThis, STORE_CLASS_KEY);\n\n if (typeof cached === \"function\") {\n return cached as typeof LazyLevelStore;\n }\n\n registerClass(LazyLevelStore, { typeName: \"GtkxLazyLevelStore\", implements: [Gio.ListModel] });\n Reflect.set(globalThis, STORE_CLASS_KEY, LazyLevelStore);\n\n return LazyLevelStore;\n}\n\nfunction registeredRootClass(): unknown {\n const cached: unknown = Reflect.get(globalThis, ROOT_CLASS_KEY);\n\n if (typeof cached === \"function\") {\n return cached;\n }\n\n registerClass(CollectionRootStore, { typeName: \"GtkxCollectionRootStore\", implements: [Gio.ListModel] });\n Reflect.set(globalThis, ROOT_CLASS_KEY, CollectionRootStore);\n\n return CollectionRootStore;\n}\n\nfunction anySlotRefFor(value: GObject.Object | null): SlotRef | null {\n const item = value instanceof Gtk.TreeListRow ? value.getItem() : value;\n\n return item === null ? null : (sharedSlots().get(item) ?? null);\n}\n\nfunction slotRefFor(value: GObject.Object | null): SlotRef | null {\n const ref = anySlotRefFor(value);\n\n return ref === null || ref.slot === -1 ? null : ref;\n}\n\nfunction levelStoreFor(value: GObject.Object | null): LazyLevelStore | null {\n return anySlotRefFor(value)?.store ?? null;\n}\n\nfunction slotPathAt(store: LazyLevelStore, slot: number): string {\n return store.level.path + encodePart(String(slot));\n}\n\nfunction newLevelStore(level: Level): LevelStore {\n const store = new (registeredStoreClass())() as LevelStore;\n store.level = level;\n\n return store;\n}\n\nfunction itemKeys(previous: Level, next: Level): LevelKeys {\n return {\n previousLength: previous.items.length,\n nextLength: next.items.length,\n previousKey: (slot) => previous.items[slot]?.id ?? \"\",\n nextKey: (slot) => next.items[slot]?.id ?? \"\",\n };\n}\n\nfunction groupKey(index: CollectionIndex, group: number): string {\n const level = index.groups[group];\n\n return level?.section?.id ?? \"\";\n}\n\nfunction groupKeys(previous: CollectionIndex, next: CollectionIndex): LevelKeys {\n return {\n previousLength: previous.groups.length,\n nextLength: next.groups.length,\n previousKey: (group) => groupKey(previous, group),\n nextKey: (group) => groupKey(next, group),\n };\n}\n\nfunction isExpandableAt(level: Level, slot: number): boolean {\n return level.expandableFlags[slot] ?? false;\n}\n\nfunction collectFlips(previous: Level, next: Level, splice: Splice): Set<number> {\n const flipped: Set<number> = new Set();\n\n if (previous.expandableFlags.length === 0 && next.expandableFlags.length === 0) {\n return flipped;\n }\n\n for (let slot = 0; slot < splice.start; slot++) {\n if (isExpandableAt(previous, slot) !== isExpandableAt(next, slot)) {\n flipped.add(slot);\n }\n }\n\n const shift = splice.added - splice.removed;\n\n for (let slot = splice.start + splice.removed; slot < previous.items.length; slot++) {\n if (isExpandableAt(previous, slot) !== isExpandableAt(next, slot + shift)) {\n flipped.add(slot + shift);\n }\n }\n\n return flipped;\n}\n\nfunction detachStore(store: LevelStore): void {\n for (const { ref } of store.slots.values()) {\n ref.slot = -1;\n }\n\n for (const child of store.childStores.values()) {\n detachStore(child);\n }\n}\n\nfunction pruneFlips(context: SyncContext, store: LevelStore, flipped: Set<number>): void {\n if (flipped.size === 0) {\n return;\n }\n\n pruneSlots(context.expansion, store.level.path, (slot) => flipped.has(slot));\n\n for (const slot of flipped) {\n const child = store.childStores.get(slot);\n\n if (child !== undefined) {\n detachStore(child);\n store.childStores.delete(slot);\n }\n }\n}\n\nfunction renewKeys(store: LevelStore, previous: Level, from: number, to: number): void {\n if (from === to) {\n return;\n }\n\n for (const [slot, { ref }] of store.slots) {\n if (slot >= from && slot < to && previous.items[slot]?.id !== store.level.items[slot]?.id) {\n ref.key = nextKey();\n }\n }\n}\n\nfunction relocateStore(context: SyncContext, store: LevelStore, keys: LevelKeys, splice: Splice): void {\n const moves = matchMoves(keys, splice, store.slots.keys());\n const shift: Relocate = (slot) => relocateSlot(splice, slot);\n\n store.slots = relocateEntries(\n store.slots,\n (slot) => relocateSlot(splice, slot, moves),\n ({ ref }) => {\n ref.slot = -1;\n },\n );\n\n for (const [slot, { ref }] of store.slots) {\n ref.slot = slot;\n }\n\n store.childStores = relocateEntries(store.childStores, shift, detachStore);\n relocateSlots(context.expansion, store.level.path, shift);\n}\n\nfunction extendRuns(runs: SlotRun[], slot: number): void {\n const last = runs.at(-1);\n\n if (last !== undefined && last.start + last.length === slot) {\n last.length += 1;\n\n return;\n }\n\n runs.push({ start: slot, length: 1 });\n}\n\nfunction collectFlipRuns(flipped: Set<number>): SlotRun[] {\n const runs: SlotRun[] = [];\n\n for (const slot of flipped) {\n extendRuns(runs, slot);\n }\n\n return runs;\n}\n\nfunction emitFlips(store: LevelStore, flipped: Set<number>): void {\n for (const run of collectFlipRuns(flipped)) {\n store.itemsChanged(run.start, run.length, run.length);\n }\n}\n\nfunction syncLevel(context: SyncContext, store: LevelStore, level: Level): void {\n const previous = store.level;\n const keys = itemKeys(previous, level);\n const found = previous.items === level.items ? NO_SPLICE : findSplice(keys);\n const splice = searchableSplice(found, found.added);\n store.level = level;\n renewKeys(store, previous, found.start, splice.start);\n\n if (hasSplice(splice)) {\n relocateStore(context, store, keys, splice);\n }\n\n const flipped = collectFlips(previous, level, splice);\n pruneFlips(context, store, flipped);\n\n if (hasSplice(splice)) {\n store.itemsChanged(splice.start, splice.removed, splice.added);\n }\n\n emitFlips(store, flipped);\n\n for (const [slot, child] of store.childStores) {\n const childLevel = context.index.childLevel(level, slot);\n\n if (childLevel !== undefined) {\n syncLevel(context, child, childLevel);\n }\n }\n}\n\nfunction ensureChildStore(index: CollectionIndex, store: LazyLevelStore, slot: number): LevelStore | null {\n const existing = store.childStores.get(slot) ?? null;\n\n if (existing !== null || !isExpandableAt(store.level, slot)) {\n return existing;\n }\n\n const level = index.childLevel(store.level, slot);\n\n if (level === undefined) {\n return null;\n }\n\n const created = newLevelStore(level);\n store.childStores.set(slot, created);\n\n return created;\n}\n\nfunction childStoreFor(state: ModelState, object: GObject.Object): Gio.ListModel | null {\n const ref = slotRefFor(object);\n\n if (ref === null) {\n return null;\n }\n\n return ensureChildStore(state.index, ref.store, ref.slot);\n}\n\nfunction treeFor(state: ModelState, store: LevelStore): Gtk.TreeListModel {\n const existing = state.trees.get(store);\n\n if (existing !== undefined) {\n return existing;\n }\n\n const created = Gtk.TreeListModel.new(store, false, false, (object) => childStoreFor(state, object));\n state.trees.set(store, created);\n\n return created;\n}\n\nfunction rowAt(state: ModelState, position: number): Gtk.TreeListRow | null {\n const item = state.model?.getItem(position);\n\n return item instanceof Gtk.TreeListRow ? item : null;\n}\n\nfunction dropGroup(state: ModelState, store: LevelStore): void {\n detachStore(store);\n state.trees.delete(store);\n}\n\nfunction replaceGroups(state: ModelState, before: number): void {\n for (const store of state.groupStores.values()) {\n dropGroup(state, store);\n }\n\n state.groupStores.clear();\n state.expansion.expanded.clear();\n state.expansion.slots.clear();\n state.root?.itemsChanged(0, before, state.index.groups.length);\n}\n\nfunction addedRows(index: CollectionIndex, splice: Splice): number {\n return index.groups\n .slice(splice.start, splice.start + splice.added)\n .reduce((rows, level) => rows + level.items.length, 0);\n}\n\nfunction syncRoot(state: ModelState, previous: CollectionIndex): void {\n if (previous.isTree !== state.index.isTree) {\n replaceGroups(state, previous.groups.length);\n\n return;\n }\n\n const keys = groupKeys(previous, state.index);\n const found = findSplice(keys);\n const splice = searchableSplice(found, addedRows(state.index, found));\n\n if (!hasSplice(splice)) {\n return;\n }\n\n const moves = matchMoves(keys, splice, state.groupStores.keys());\n const relocate: Relocate = (group) => relocateSlot(splice, group, moves);\n state.groupStores = relocateEntries(state.groupStores, relocate, (store) => {\n dropGroup(state, store);\n });\n relocateSlots(state.expansion, \"\", relocate);\n\n state.root?.itemsChanged(splice.start, splice.removed, splice.added);\n}\n\nfunction stepGroupStores(state: ModelState, context: SyncContext): void {\n for (const [group, store] of state.groupStores) {\n const level = context.index.groups[group];\n\n if (level !== undefined && store.level !== level) {\n syncLevel(context, store, level);\n }\n }\n}\n\nfunction rowCount(index: CollectionIndex): number {\n return index.groups.reduce((rows, level) => rows + level.items.length, 0);\n}\n\nfunction hasFilledSections(previous: CollectionIndex, index: CollectionIndex): boolean {\n return (\n rowCount(previous) === 0 && index.groups.some((level) => level.section !== undefined && level.items.length > 0)\n );\n}\n\nfunction syncModel(state: ModelState, index: CollectionIndex, onSectionsFilled: () => void): void {\n if (state.root === null) {\n return;\n }\n\n const context: SyncContext = { index, expansion: state.expansion };\n const previous = state.index;\n state.index = index;\n state.expansion.isSyncing = true;\n\n try {\n syncRoot(state, previous);\n stepGroupStores(state, context);\n\n if (hasFilledSections(previous, index)) {\n onSectionsFilled();\n }\n } finally {\n state.expansion.isSyncing = false;\n }\n\n adoptIndex(state.expansion, index);\n state.version += 1;\n\n for (const listener of state.listeners) {\n listener();\n }\n}\n\nfunction clearModel(state: ModelState): void {\n const root = state.root;\n const previousLength = state.index.groups.length;\n state.expansion.isSyncing = true;\n\n try {\n if (root !== null) {\n root.state = null;\n }\n\n state.root = null;\n state.model = null;\n state.index = EMPTY_INDEX;\n state.groupStores.clear();\n state.trees.clear();\n state.expansion.expanded.clear();\n state.expansion.slots.clear();\n adoptIndex(state.expansion, EMPTY_INDEX);\n\n if (previousLength > 0) {\n root?.itemsChanged(0, previousLength, 0);\n }\n } finally {\n state.expansion.isSyncing = false;\n }\n}\n\nfunction createCollectionModel(): CollectionModel {\n const state: ModelState = {\n version: 0,\n listeners: new Set(),\n root: null,\n model: null,\n groupStores: new Map(),\n trees: new Map(),\n expansion: createTreeExpansion(EMPTY_INDEX),\n index: EMPTY_INDEX,\n };\n\n return {\n expansion: state.expansion,\n subscribe: (onChange) => {\n state.listeners.add(onChange);\n\n return () => {\n state.listeners.delete(onChange);\n };\n },\n getVersion: () => state.version,\n isPending: (index) => state.root !== null && state.index !== index,\n rowAt: (position) => rowAt(state, position),\n bind: (root, model) => {\n root.state = state;\n state.root = root;\n state.model = model;\n },\n clear: () => {\n clearModel(state);\n },\n sync: (index, onSectionsFilled) => {\n syncModel(state, index, onSectionsFilled);\n },\n };\n}\n\nclass CollectionRootStore extends GObject.Object implements Gio.ListModelImpl {\n declare itemsChanged: Gio.ListModel[\"itemsChanged\"];\n state: ModelState | null = null;\n\n vfuncGetItemType(): bigint {\n return GObject.TYPE_OBJECT;\n }\n\n vfuncGetNItems(): number {\n return this.state?.index.groups.length ?? 0;\n }\n\n vfuncGetItem(position: number): GObject.Object | null {\n const state = this.state;\n const level = state?.index.groups[position];\n\n if (state === null || level === undefined) {\n return null;\n }\n\n let store = state.groupStores.get(position);\n\n if (store === undefined) {\n store = newLevelStore(level);\n state.groupStores.set(position, store);\n }\n\n return state.index.isTree ? treeFor(state, store) : store;\n }\n}\n\nclass LazyLevelStore extends GObject.Object implements Gio.ListModelImpl {\n declare itemsChanged: Gio.ListModel[\"itemsChanged\"];\n key: string = nextKey();\n level: Level = { path: \"\", items: [], expandableFlags: [] };\n slots: Map<number, SlotItem> = new Map();\n childStores: Map<number, LevelStore> = new Map();\n\n private createItem(position: number): Gtk.StringObject {\n const ref = { key: nextKey(), store: this, slot: position };\n const object = Gtk.StringObject.new(\"\");\n this.slots.set(position, { ref, object });\n sharedSlots().set(object, ref);\n\n return object;\n }\n\n vfuncGetItemType(): bigint {\n return GObject.TYPE_OBJECT;\n }\n\n vfuncGetNItems(): number {\n return this.level.items.length;\n }\n\n vfuncGetItem(position: number): GObject.Object | null {\n if (position < 0 || position >= this.level.items.length) {\n return null;\n }\n\n return this.slots.get(position)?.object ?? this.createItem(position);\n }\n}\n\nconst CollectionRoot: (props: CollectionRootProps) => ReactNode = createElementComponent<CollectionRootProps>(\n \"GtkxCollectionRootStore\",\n registeredRootClass(),\n);\n\nexport {\n CollectionRoot,\n createCollectionModel,\n levelStoreFor,\n slotPathAt,\n slotRefFor,\n type CollectionModel,\n type CollectionRootStore,\n type LazyLevelStore,\n type SlotRef,\n};\n"]}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type * as Gtk from "@gtkx/gi/gtk";
|
|
2
2
|
import type { ListItem } from "../types.js";
|
|
3
|
-
import type { CollectionIndex
|
|
3
|
+
import type { CollectionIndex } from "./collection-index.js";
|
|
4
4
|
import type { CollectionModel, SlotRef } from "./collection-model.js";
|
|
5
5
|
import type { MatchedRows } from "./tree-order.js";
|
|
6
|
-
type Collection = Pick<CollectionModel, "expansion" | "rowAt"> & {
|
|
6
|
+
type Collection = Pick<CollectionModel, "expansion" | "rowAt" | "subscribe" | "getVersion"> & {
|
|
7
7
|
isTree: boolean;
|
|
8
8
|
itemAt: (ref: SlotRef) => ListItem | undefined;
|
|
9
|
-
sectionFor: (levelPath: string) => SectionIdentity | undefined;
|
|
10
9
|
idAt: (position: number) => string | null;
|
|
11
10
|
idsAt: (positions: number[]) => string[];
|
|
12
11
|
pathAt: (position: number) => string | null;
|
|
12
|
+
isPending: () => boolean;
|
|
13
13
|
positionFor: (id: string) => number;
|
|
14
14
|
rowsFor: (ids: string[]) => MatchedRows;
|
|
15
15
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/internal/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,
|
|
1
|
+
{"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/internal/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACtE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAKnD,KAAK,UAAU,GAAG,IAAI,CAAC,eAAe,EAAE,WAAW,GAAG,OAAO,GAAG,WAAW,GAAG,YAAY,CAAC,GAAG;IAC1F,MAAM,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,QAAQ,GAAG,SAAS,CAAC;IAC/C,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC1C,KAAK,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,MAAM,EAAE,CAAC;IACzC,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC5C,SAAS,EAAE,MAAM,OAAO,CAAC;IACzB,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,MAAM,CAAC;IACpC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,WAAW,CAAC;CAC3C,CAAC;AAyDF,iBAAS,gBAAgB,CAAC,UAAU,EAAE,UAAU,GAAG,OAAO,CAIzD;AAED,iBAAS,gBAAgB,CACrB,QAAQ,EAAE,eAAe,EACzB,KAAK,EAAE,eAAe,EACtB,KAAK,EAAE,GAAG,CAAC,gBAAgB,GAAG,IAAI,GACnC,UAAU,CAeZ;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,KAAK,UAAU,EAAE,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { slotPathAt, slotRefFor } from "./collection-model.js";
|
|
2
|
+
import { orderFor } from "./tree-expansion.js";
|
|
2
3
|
import { findIds, findRows } from "./tree-order.js";
|
|
3
4
|
const NO_ROWS = { positions: [], ids: [] };
|
|
4
5
|
const NO_IDS = [];
|
|
@@ -10,8 +11,7 @@ function rowsFor(gtkModel, ids) {
|
|
|
10
11
|
return findRows(expansion.index, expansion.slots, new Set(ids));
|
|
11
12
|
}
|
|
12
13
|
function positionFor(gtkModel, id) {
|
|
13
|
-
|
|
14
|
-
return first;
|
|
14
|
+
return orderFor(gtkModel.expansion).positions.get(id) ?? -1;
|
|
15
15
|
}
|
|
16
16
|
function refAt(model, position) {
|
|
17
17
|
if (position < 0) {
|
|
@@ -19,12 +19,12 @@ function refAt(model, position) {
|
|
|
19
19
|
}
|
|
20
20
|
return slotRefFor(model?.getItem(position) ?? null);
|
|
21
21
|
}
|
|
22
|
-
function itemAt(
|
|
23
|
-
return
|
|
22
|
+
function itemAt(ref) {
|
|
23
|
+
return ref.store.level.items[ref.slot];
|
|
24
24
|
}
|
|
25
|
-
function idAt(model,
|
|
25
|
+
function idAt(model, position) {
|
|
26
26
|
const ref = refAt(model, position);
|
|
27
|
-
return ref === null ? null : (itemAt(
|
|
27
|
+
return ref === null ? null : (itemAt(ref)?.id ?? null);
|
|
28
28
|
}
|
|
29
29
|
function pathAt(model, position) {
|
|
30
30
|
const ref = refAt(model, position);
|
|
@@ -49,11 +49,13 @@ function createCollection(gtkModel, index, model) {
|
|
|
49
49
|
expansion: gtkModel.expansion,
|
|
50
50
|
isTree: index.isTree,
|
|
51
51
|
rowAt: gtkModel.rowAt,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
subscribe: gtkModel.subscribe,
|
|
53
|
+
getVersion: gtkModel.getVersion,
|
|
54
|
+
itemAt,
|
|
55
|
+
idAt: (position) => idAt(model, position),
|
|
55
56
|
idsAt: (positions) => idsAt(gtkModel, positions),
|
|
56
57
|
pathAt: (position) => pathAt(model, position),
|
|
58
|
+
isPending: () => gtkModel.isPending(index),
|
|
57
59
|
positionFor: (id) => positionFor(gtkModel, id),
|
|
58
60
|
rowsFor: (ids) => rowsFor(gtkModel, ids),
|
|
59
61
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/internal/collection.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAapD,MAAM,OAAO,GAAgB,EAAE,SAAS,EAAE,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,CAAC;AACxD,MAAM,MAAM,GAAa,EAAE,CAAC;AAE5B,SAAS,OAAO,CAAC,QAAyB,EAAE,GAAa;IACrD,IAAI,GAAG,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACnB,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,MAA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AgB,CACrB,QAAyB,EACzB,KAAsB,EACtB,KAAkC;IAElC,OAAO;QACH,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,QAAQ,CAAC,KAAK;QACrB,SAAS,EAAE,QAAQ,CAAC,SAAS;QAC7B,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,MAAM;QACN,IAAI,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC;QACzC,KAAK,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,SAAS,CAAC;QAChD,MAAM,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC;QAC7C,SAAS,EAAE,GAAG,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC;QAC1C,WAAW,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,EAAE,EAAE,CAAC;QAC9C,OAAO,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,CAAC;KAC3C,CAAC;AACN,CAAC;AAED,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAmB,CAAC","sourcesContent":["import type * as Gtk from \"@gtkx/gi/gtk\";\nimport type { ListItem } from \"../types.js\";\nimport type { CollectionIndex } from \"./collection-index.js\";\nimport type { CollectionModel, SlotRef } from \"./collection-model.js\";\nimport type { MatchedRows } from \"./tree-order.js\";\nimport { slotPathAt, slotRefFor } from \"./collection-model.js\";\nimport { orderFor } from \"./tree-expansion.js\";\nimport { findIds, findRows } from \"./tree-order.js\";\n\ntype Collection = Pick<CollectionModel, \"expansion\" | \"rowAt\" | \"subscribe\" | \"getVersion\"> & {\n isTree: boolean;\n itemAt: (ref: SlotRef) => ListItem | undefined;\n idAt: (position: number) => string | null;\n idsAt: (positions: number[]) => string[];\n pathAt: (position: number) => string | null;\n isPending: () => boolean;\n positionFor: (id: string) => number;\n rowsFor: (ids: string[]) => MatchedRows;\n};\n\nconst NO_ROWS: MatchedRows = { positions: [], ids: [] };\nconst NO_IDS: string[] = [];\n\nfunction rowsFor(gtkModel: CollectionModel, ids: string[]): MatchedRows {\n if (ids.length === 0) {\n return NO_ROWS;\n }\n\n const { expansion } = gtkModel;\n\n return findRows(expansion.index, expansion.slots, new Set(ids));\n}\n\nfunction positionFor(gtkModel: CollectionModel, id: string): number {\n return orderFor(gtkModel.expansion).positions.get(id) ?? -1;\n}\n\nfunction refAt(model: Gtk.FlattenListModel | null, position: number): SlotRef | null {\n if (position < 0) {\n return null;\n }\n\n return slotRefFor(model?.getItem(position) ?? null);\n}\n\nfunction itemAt(ref: SlotRef): ListItem | undefined {\n return ref.store.level.items[ref.slot];\n}\n\nfunction idAt(model: Gtk.FlattenListModel | null, position: number): string | null {\n const ref = refAt(model, position);\n\n return ref === null ? null : (itemAt(ref)?.id ?? null);\n}\n\nfunction pathAt(model: Gtk.FlattenListModel | null, position: number): string | null {\n const ref = refAt(model, position);\n\n if (ref === null) {\n return null;\n }\n\n return slotPathAt(ref.store, ref.slot);\n}\n\nfunction idsAt(gtkModel: CollectionModel, positions: number[]): string[] {\n if (positions.length === 0) {\n return NO_IDS;\n }\n\n const { expansion } = gtkModel;\n\n return findIds(expansion.index, expansion.slots, new Set(positions));\n}\n\nfunction isCollectionIdle(collection: Collection): boolean {\n const { expansion } = collection;\n\n return !expansion.isApplying && !expansion.isSyncing;\n}\n\nfunction createCollection(\n gtkModel: CollectionModel,\n index: CollectionIndex,\n model: Gtk.FlattenListModel | null,\n): Collection {\n return {\n expansion: gtkModel.expansion,\n isTree: index.isTree,\n rowAt: gtkModel.rowAt,\n subscribe: gtkModel.subscribe,\n getVersion: gtkModel.getVersion,\n itemAt,\n idAt: (position) => idAt(model, position),\n idsAt: (positions) => idsAt(gtkModel, positions),\n pathAt: (position) => pathAt(model, position),\n isPending: () => gtkModel.isPending(index),\n positionFor: (id) => positionFor(gtkModel, id),\n rowsFor: (ids) => rowsFor(gtkModel, ids),\n };\n}\n\nexport { createCollection, isCollectionIdle, type Collection };\n"]}
|
|
@@ -4,6 +4,7 @@ type ControlledSyncOptions<T> = {
|
|
|
4
4
|
target?: object | null | undefined;
|
|
5
5
|
apply: (value: T) => void;
|
|
6
6
|
};
|
|
7
|
+
declare function hasSameIds(reported: string[], requested: string[]): boolean;
|
|
7
8
|
declare function useControlledSync<T>(options: ControlledSyncOptions<T>): () => void;
|
|
8
|
-
export { useControlledSync };
|
|
9
|
+
export { hasSameIds, useControlledSync };
|
|
9
10
|
//# sourceMappingURL=controlled-sync.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controlled-sync.d.ts","sourceRoot":"","sources":["../../src/internal/controlled-sync.ts"],"names":[],"mappings":"AAGA,KAAK,qBAAqB,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B,CAAC;AAEF,iBAAS,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAiB3E;AAED,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"controlled-sync.d.ts","sourceRoot":"","sources":["../../src/internal/controlled-sync.ts"],"names":[],"mappings":"AAGA,KAAK,qBAAqB,CAAC,CAAC,IAAI;IAC5B,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;IACnC,KAAK,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,CAAC;CAC7B,CAAC;AAEF,iBAAS,UAAU,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAKpE;AAED,iBAAS,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,qBAAqB,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI,CAiB3E;AAED,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAC"}
|