@gtkx/components 2.0.0-beta.1 → 2.0.0-beta.11

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.
Files changed (79) hide show
  1. package/README.md +8 -165
  2. package/dist/column-view.d.ts.map +1 -1
  3. package/dist/column-view.js +20 -9
  4. package/dist/column-view.js.map +1 -1
  5. package/dist/index.d.ts +3 -2
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -1
  8. package/dist/index.js.map +1 -1
  9. package/dist/internal/cells.d.ts +19 -2
  10. package/dist/internal/cells.d.ts.map +1 -1
  11. package/dist/internal/cells.js +202 -39
  12. package/dist/internal/cells.js.map +1 -1
  13. package/dist/internal/collection-index.d.ts +3 -2
  14. package/dist/internal/collection-index.d.ts.map +1 -1
  15. package/dist/internal/collection-index.js +3 -3
  16. package/dist/internal/collection-index.js.map +1 -1
  17. package/dist/internal/collection-model.d.ts +28 -7
  18. package/dist/internal/collection-model.d.ts.map +1 -1
  19. package/dist/internal/collection-model.js +147 -127
  20. package/dist/internal/collection-model.js.map +1 -1
  21. package/dist/internal/collection.d.ts +5 -4
  22. package/dist/internal/collection.d.ts.map +1 -1
  23. package/dist/internal/collection.js +20 -21
  24. package/dist/internal/collection.js.map +1 -1
  25. package/dist/internal/controlled-sync.d.ts +6 -8
  26. package/dist/internal/controlled-sync.d.ts.map +1 -1
  27. package/dist/internal/controlled-sync.js +3 -3
  28. package/dist/internal/controlled-sync.js.map +1 -1
  29. package/dist/internal/drop-down.d.ts.map +1 -1
  30. package/dist/internal/drop-down.js +43 -44
  31. package/dist/internal/drop-down.js.map +1 -1
  32. package/dist/internal/expansion.js +4 -4
  33. package/dist/internal/expansion.js.map +1 -1
  34. package/dist/internal/selection.d.ts +1 -0
  35. package/dist/internal/selection.d.ts.map +1 -1
  36. package/dist/internal/selection.js +6 -6
  37. package/dist/internal/selection.js.map +1 -1
  38. package/dist/internal/tree-expansion.d.ts.map +1 -1
  39. package/dist/internal/tree-expansion.js +2 -11
  40. package/dist/internal/tree-expansion.js.map +1 -1
  41. package/dist/internal/tree-order.d.ts.map +1 -1
  42. package/dist/internal/tree-order.js +32 -76
  43. package/dist/internal/tree-order.js.map +1 -1
  44. package/dist/internal/use-collection.d.ts +5 -1
  45. package/dist/internal/use-collection.d.ts.map +1 -1
  46. package/dist/internal/use-collection.js +21 -7
  47. package/dist/internal/use-collection.js.map +1 -1
  48. package/dist/list-item-factory.d.ts +10 -0
  49. package/dist/list-item-factory.d.ts.map +1 -0
  50. package/dist/list-item-factory.js +14 -0
  51. package/dist/list-item-factory.js.map +1 -0
  52. package/dist/list-view.d.ts.map +1 -1
  53. package/dist/list-view.js +1 -0
  54. package/dist/list-view.js.map +1 -1
  55. package/dist/toast.d.ts +3 -5
  56. package/dist/toast.d.ts.map +1 -1
  57. package/dist/toast.js +3 -12
  58. package/dist/toast.js.map +1 -1
  59. package/dist/types.d.ts +44 -52
  60. package/dist/types.d.ts.map +1 -1
  61. package/dist/types.js.map +1 -1
  62. package/package.json +13 -10
  63. package/src/column-view.tsx +24 -12
  64. package/src/index.ts +3 -2
  65. package/src/internal/cells.tsx +330 -53
  66. package/src/internal/collection-index.ts +8 -6
  67. package/src/internal/collection-model.ts +190 -168
  68. package/src/internal/collection.ts +28 -24
  69. package/src/internal/controlled-sync.ts +9 -12
  70. package/src/internal/drop-down.tsx +64 -60
  71. package/src/internal/expansion.ts +4 -4
  72. package/src/internal/selection.tsx +8 -8
  73. package/src/internal/tree-expansion.ts +2 -14
  74. package/src/internal/tree-order.ts +33 -121
  75. package/src/internal/use-collection.tsx +29 -8
  76. package/src/list-item-factory.tsx +27 -0
  77. package/src/list-view.tsx +1 -0
  78. package/src/toast.tsx +4 -18
  79. package/src/types.ts +48 -52
@@ -1,3 +1,4 @@
1
+ import type { ReactNode, Ref } from "react";
1
2
  import * as Gio from "@gtkx/gi/gio";
2
3
  import * as GObject from "@gtkx/gi/gobject";
3
4
  import * as Gtk from "@gtkx/gi/gtk";
@@ -5,28 +6,48 @@ import type { CollectionIndex, Level } from "./collection-index.js";
5
6
  import type { TreeExpansion } from "./tree-expansion.js";
6
7
  type LevelStore = Gio.ListModel & LazyLevelStore;
7
8
  type SlotRef = {
8
- store: LevelStore;
9
+ store: LazyLevelStore;
9
10
  slot: number;
10
11
  };
12
+ type ModelState = {
13
+ root: CollectionRootStore | null;
14
+ model: Gtk.FlattenListModel | null;
15
+ groupStores: Map<number, LevelStore>;
16
+ trees: Map<LevelStore, Gtk.TreeListModel>;
17
+ expansion: TreeExpansion;
18
+ index: CollectionIndex;
19
+ };
11
20
  type CollectionModel = {
12
- model: Gtk.FlattenListModel;
13
21
  expansion: TreeExpansion;
14
22
  rowAt: (position: number) => Gtk.TreeListRow | null;
23
+ bind: (root: CollectionRootStore, model: Gtk.FlattenListModel) => void;
24
+ clear: () => void;
15
25
  sync: (index: CollectionIndex) => void;
16
26
  };
27
+ type CollectionRootProps = {
28
+ ref: Ref<CollectionRootStore>;
29
+ };
17
30
  declare function slotRefFor(value: GObject.Object | null): SlotRef | null;
18
- declare function slotPathAt(store: LevelStore, slot: number): string;
31
+ declare function slotPathAt(store: LazyLevelStore, slot: number): string;
19
32
  declare function createCollectionModel(): CollectionModel;
33
+ declare class CollectionRootStore extends GObject.Object implements Gio.ListModelImpl {
34
+ itemsChanged: Gio.ListModel["itemsChanged"];
35
+ state: ModelState | null;
36
+ vfuncGetItemType(): bigint;
37
+ vfuncGetNItems(): number;
38
+ vfuncGetItem(position: number): GObject.Object | null;
39
+ }
20
40
  declare class LazyLevelStore extends GObject.Object implements Gio.ListModelImpl {
21
41
  itemsChanged: Gio.ListModel["itemsChanged"];
22
42
  level: Level;
23
- refs: SlotRef[];
24
- objects: (Gtk.StringObject | null)[];
25
- childStores: (LevelStore | null)[];
43
+ refs: Map<number, SlotRef>;
44
+ objects: Map<number, Gtk.StringObject>;
45
+ childStores: Map<number, LevelStore>;
26
46
  private createItem;
27
47
  vfuncGetItemType(): bigint;
28
48
  vfuncGetNItems(): number;
29
49
  vfuncGetItem(position: number): GObject.Object | null;
30
50
  }
31
- export { createCollectionModel, slotPathAt, slotRefFor, type CollectionModel, type SlotRef };
51
+ declare const CollectionRoot: (props: CollectionRootProps) => ReactNode;
52
+ export { CollectionRoot, createCollectionModel, slotPathAt, slotRefFor, type CollectionModel, type CollectionRootStore, type SlotRef, };
32
53
  //# sourceMappingURL=collection-model.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-model.d.ts","sourceRoot":"","sources":["../../src/internal/collection-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD,KAAK,UAAU,GAAG,GAAG,CAAC,SAAS,GAAG,cAAc,CAAC;AAEjD,KAAK,OAAO,GAAG;IACX,KAAK,EAAE,UAAU,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CAChB,CAAC;AA4BF,KAAK,eAAe,GAAG;IACnB,KAAK,EAAE,GAAG,CAAC,gBAAgB,CAAC;IAC5B,SAAS,EAAE,aAAa,CAAC;IACzB,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;IACpD,IAAI,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;CAC1C,CAAC;AAmCF,iBAAS,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,GAAG,IAAI,GAAG,OAAO,GAAG,IAAI,CAUhE;AAED,iBAAS,UAAU,CAAC,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAE3D;AAuSD,iBAAS,qB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,IAAI;CAiBxD;AAED,cAAM,cAAe,SAAQ,OAAO,CAAC,MAAO,YAAW,GAAG,CAAC,aAAa;IAC5D,YAAY,EAAE,GAAG,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IACpD,KAAK,EAAE,KAAK,CAAgD;IAC5D,IAAI,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAa;IACvC,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,YAAY,CAAC,CAAa;IACnD,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,UAAU,CAAC,CAAa;IAEjD,OAAO,CAAC,UAAU;IAUlB,gBAAgB,IAAI,MAAM;IAI1B,cAAc,IAAI,MAAM;IAIxB,YAAY,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI;CAOxD;AAED,QAAA,MAAM,cAAc,EAAE,CAAC,KAAK,EAAE,mBAAmB,KAAK,SAGrD,CAAC;AAEF,OAAO,EACH,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,UAAU,EACV,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,OAAO,GACf,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import * as Gio from "@gtkx/gi/gio";
2
2
  import * as GObject from "@gtkx/gi/gobject";
3
3
  import * as Gtk from "@gtkx/gi/gtk";
4
+ import { createElementComponent } from "@gtkx/react";
4
5
  import { registerClass } from "@gtkx/runtime";
5
6
  import { createCollectionIndex } from "./collection-index.js";
6
7
  import { encodePart } from "./keys.js";
7
8
  import { adoptIndex, createTreeExpansion, pruneSlots } from "./tree-expansion.js";
8
9
  const STORE_CLASS_KEY = Symbol.for("gtkx.components.lazy-level-store");
10
+ const ROOT_CLASS_KEY = Symbol.for("gtkx.components.collection-root-store");
9
11
  const SLOTS_KEY = Symbol.for("gtkx.components.lazy-level-store.slots");
10
- const EMPTY_INDEX = createCollectionIndex(undefined, undefined, true);
11
- const SLOTS = sharedSlots();
12
- const newRootStore = () => new Gio.ListStore({ itemType: GObject.TYPE_OBJECT });
12
+ const EMPTY_INDEX = createCollectionIndex(undefined, [], true);
13
13
  function sharedSlots() {
14
14
  const cached = Reflect.get(globalThis, SLOTS_KEY);
15
15
  if (cached instanceof WeakMap) {
@@ -28,32 +28,36 @@ function registeredStoreClass() {
28
28
  Reflect.set(globalThis, STORE_CLASS_KEY, LazyLevelStore);
29
29
  return LazyLevelStore;
30
30
  }
31
+ function registeredRootClass() {
32
+ const cached = Reflect.get(globalThis, ROOT_CLASS_KEY);
33
+ if (typeof cached === "function") {
34
+ return cached;
35
+ }
36
+ registerClass(CollectionRootStore, { typeName: "GtkxCollectionRootStore", implements: [Gio.ListModel] });
37
+ Reflect.set(globalThis, ROOT_CLASS_KEY, CollectionRootStore);
38
+ return CollectionRootStore;
39
+ }
31
40
  function slotRefFor(value) {
32
41
  const item = value instanceof Gtk.TreeListRow ? value.getItem() : value;
33
42
  if (item === null) {
34
43
  return null;
35
44
  }
36
- const ref = SLOTS.get(item);
45
+ const ref = sharedSlots().get(item);
37
46
  return ref === undefined || ref.slot === -1 ? null : ref;
38
47
  }
39
48
  function slotPathAt(store, slot) {
40
49
  return store.level.path + encodePart(String(slot));
41
50
  }
42
- function growStore(store) {
43
- for (let slot = store.refs.length; slot < store.level.items.length; slot++) {
44
- store.refs.push({ store, slot });
45
- store.objects.push(null);
46
- store.childStores.push(null);
47
- }
48
- }
49
51
  function newLevelStore(level) {
50
52
  const store = new (registeredStoreClass())();
51
53
  store.level = level;
52
- growStore(store);
53
54
  return store;
54
55
  }
55
56
  function collectFlips(previous, next, overlap) {
56
57
  const flipped = new Set();
58
+ if (previous.expandableFlags.length === 0 && next.expandableFlags.length === 0) {
59
+ return flipped;
60
+ }
57
61
  for (let slot = 0; slot < overlap; slot++) {
58
62
  if ((previous.expandableFlags[slot] ?? false) !== (next.expandableFlags[slot] ?? false)) {
59
63
  flipped.add(slot);
@@ -67,26 +71,26 @@ function pruneFlips(context, store, flipped) {
67
71
  }
68
72
  pruneSlots(context.expansion, store.level.path, (slot) => flipped.has(slot));
69
73
  for (const slot of flipped) {
70
- store.childStores[slot] = null;
74
+ store.childStores.delete(slot);
71
75
  }
72
76
  }
73
77
  function detachRefs(store, nextLength) {
74
- for (let slot = nextLength; slot < store.refs.length; slot++) {
75
- const ref = store.refs[slot];
76
- if (ref !== undefined) {
77
- ref.slot = -1;
78
+ for (const [slot, ref] of store.refs) {
79
+ if (slot < nextLength) {
80
+ continue;
78
81
  }
82
+ ref.slot = -1;
83
+ store.refs.delete(slot);
84
+ store.objects.delete(slot);
85
+ store.childStores.delete(slot);
79
86
  }
80
87
  }
81
- function shrinkStore(context, store, nextLength) {
82
- if (store.refs.length <= nextLength) {
88
+ function shrinkStore(context, store, previousLength, nextLength) {
89
+ if (previousLength <= nextLength) {
83
90
  return;
84
91
  }
85
92
  detachRefs(store, nextLength);
86
93
  pruneSlots(context.expansion, store.level.path, (slot) => slot >= nextLength);
87
- store.refs.length = nextLength;
88
- store.objects.length = nextLength;
89
- store.childStores.length = nextLength;
90
94
  }
91
95
  function emitTailSplice(store, previousLength, nextLength) {
92
96
  if (nextLength < previousLength) {
@@ -117,48 +121,28 @@ function emitFlips(store, flipped) {
117
121
  store.itemsChanged(run.start, run.length, run.length);
118
122
  }
119
123
  }
120
- function childSync(context, store, slot, flipped) {
121
- const child = store.childStores[slot] ?? null;
122
- if (child === null || flipped.has(slot)) {
123
- return undefined;
124
- }
125
- const level = context.index.childLevel(store.level, slot);
126
- return level === undefined ? undefined : { store: child, level };
127
- }
128
- function childSyncs(context, store, overlap, flipped) {
129
- const syncs = [];
130
- for (let slot = 0; slot < overlap; slot++) {
131
- const sync = childSync(context, store, slot, flipped);
132
- if (sync !== undefined) {
133
- syncs.push(sync);
134
- }
135
- }
136
- return syncs;
137
- }
138
- function syncEntry(context, entry) {
139
- const { store, level } = entry;
140
- const previousLength = store.refs.length;
124
+ function syncLevel(context, store, level) {
125
+ const previous = store.level;
126
+ const previousLength = previous.items.length;
141
127
  const overlap = Math.min(previousLength, level.items.length);
142
- const flipped = collectFlips(store.level, level, overlap);
128
+ const flipped = collectFlips(previous, level, overlap);
143
129
  store.level = level;
144
130
  pruneFlips(context, store, flipped);
145
- shrinkStore(context, store, level.items.length);
146
- growStore(store);
131
+ shrinkStore(context, store, previousLength, level.items.length);
147
132
  emitTailSplice(store, previousLength, level.items.length);
148
133
  emitFlips(store, flipped);
149
- return childSyncs(context, store, overlap, flipped);
150
- }
151
- function syncLevel(context, store, level) {
152
- const pending = [{ store, level }];
153
- while (pending.length > 0) {
154
- const entry = pending.pop();
155
- if (entry !== undefined) {
156
- pending.push(...syncEntry(context, entry).toReversed());
134
+ for (const [slot, child] of store.childStores) {
135
+ if (slot >= overlap || flipped.has(slot)) {
136
+ continue;
137
+ }
138
+ const childLevel = context.index.childLevel(level, slot);
139
+ if (childLevel !== undefined) {
140
+ syncLevel(context, child, childLevel);
157
141
  }
158
142
  }
159
143
  }
160
144
  function ensureChildStore(index, store, slot) {
161
- const existing = store.childStores[slot] ?? null;
145
+ const existing = store.childStores.get(slot) ?? null;
162
146
  if (existing !== null || !(store.level.expandableFlags[slot] ?? false)) {
163
147
  return existing;
164
148
  }
@@ -167,7 +151,7 @@ function ensureChildStore(index, store, slot) {
167
151
  return null;
168
152
  }
169
153
  const created = newLevelStore(level);
170
- store.childStores[slot] = created;
154
+ store.childStores.set(slot, created);
171
155
  return created;
172
156
  }
173
157
  function childStoreFor(state, object) {
@@ -178,130 +162,166 @@ function childStoreFor(state, object) {
178
162
  return ensureChildStore(state.index, ref.store, ref.slot);
179
163
  }
180
164
  function treeFor(state, store) {
181
- return (state.trees.get(store) ?? Gtk.TreeListModel.new(store, false, false, (object) => childStoreFor(state, object)));
182
- }
183
- function nextTrees(state, index) {
184
- if (!index.isTree) {
185
- return new Map();
165
+ const existing = state.trees.get(store);
166
+ if (existing !== undefined) {
167
+ return existing;
186
168
  }
187
- return new Map(state.groupStores.map((store) => [store, treeFor(state, store)]));
169
+ const created = Gtk.TreeListModel.new(store, false, false, (object) => childStoreFor(state, object));
170
+ state.trees.set(store, created);
171
+ return created;
188
172
  }
189
- function pruneRebuiltLevels(state, next) {
190
- const stores = new Set([...state.trees.keys(), ...next.keys()]);
191
- for (const store of stores) {
192
- if (state.trees.get(store) !== next.get(store)) {
173
+ function rowAt(state, position) {
174
+ const item = state.model?.getItem(position);
175
+ return item instanceof Gtk.TreeListRow ? item : null;
176
+ }
177
+ function pruneGroups(state, previous) {
178
+ const hasModeChanged = previous.isTree !== state.index.isTree;
179
+ for (const [group, store] of state.groupStores) {
180
+ const isRemoved = group >= state.index.groups.length;
181
+ if (isRemoved || hasModeChanged) {
193
182
  pruneSlots(state.expansion, store.level.path, () => true);
183
+ state.trees.delete(store);
194
184
  }
195
- }
196
- }
197
- function adoptTrees(state, index) {
198
- const next = nextTrees(state, index);
199
- pruneRebuiltLevels(state, next);
200
- state.trees = next;
201
- state.treeModels = next.values().toArray();
202
- }
203
- function desiredRootModels(state, index) {
204
- adoptTrees(state, index);
205
- return index.isTree ? [...state.treeModels] : [...state.groupStores];
206
- }
207
- function rowAt(state, position) {
208
- let offset = position;
209
- for (const tree of state.treeModels) {
210
- const count = tree.getNItems();
211
- if (offset < count) {
212
- return tree.getRow(offset);
185
+ if (isRemoved) {
186
+ state.groupStores.delete(group);
213
187
  }
214
- offset -= count;
215
188
  }
216
- return null;
217
189
  }
218
- function hasSameModels(previous, next) {
219
- return previous.length === next.length && next.every((model, index) => previous[index] === model);
220
- }
221
- function syncRoot(state, index) {
222
- const next = desiredRootModels(state, index);
223
- if (hasSameModels(state.rootModels, next)) {
190
+ function syncRoot(state, previous) {
191
+ const before = previous.groups.length;
192
+ const after = state.index.groups.length;
193
+ if (previous.isTree !== state.index.isTree) {
194
+ state.root?.itemsChanged(0, before, after);
224
195
  return;
225
196
  }
226
- state.root.splice(0, state.rootModels.length, next);
227
- state.rootModels = next;
228
- }
229
- function adjustGroupStores(state, context) {
230
- const { groups } = context.index;
231
- state.groupStores.length = Math.min(state.groupStores.length, groups.length);
232
- for (const level of groups.slice(state.groupStores.length)) {
233
- state.groupStores.push(newLevelStore(level));
197
+ if (before !== after) {
198
+ const start = Math.min(before, after);
199
+ state.root?.itemsChanged(start, before - start, after - start);
234
200
  }
235
201
  }
236
- function stepGroupStores(state, context, surviving) {
237
- for (const [group, level] of context.index.groups.entries()) {
238
- const store = state.groupStores[group];
239
- if (store !== undefined && group < surviving) {
202
+ function stepGroupStores(state, context) {
203
+ for (const [group, store] of state.groupStores) {
204
+ const level = context.index.groups[group];
205
+ if (level !== undefined && store.level !== level) {
240
206
  syncLevel(context, store, level);
241
207
  }
242
208
  }
243
209
  }
244
210
  function syncModel(state, index) {
211
+ if (state.root === null) {
212
+ return;
213
+ }
245
214
  const context = { index, expansion: state.expansion };
246
- const surviving = Math.min(state.groupStores.length, index.groups.length);
215
+ const previous = state.index;
247
216
  state.index = index;
248
217
  state.expansion.isSyncing = true;
249
218
  try {
250
- adjustGroupStores(state, context);
251
- syncRoot(state, index);
252
- stepGroupStores(state, context, surviving);
219
+ pruneGroups(state, previous);
220
+ syncRoot(state, previous);
221
+ stepGroupStores(state, context);
253
222
  }
254
223
  finally {
255
224
  state.expansion.isSyncing = false;
256
225
  }
257
226
  adoptIndex(state.expansion, index);
258
227
  }
228
+ function clearModel(state) {
229
+ const root = state.root;
230
+ const previousLength = state.index.groups.length;
231
+ state.expansion.isSyncing = true;
232
+ try {
233
+ if (root !== null) {
234
+ root.state = null;
235
+ }
236
+ state.root = null;
237
+ state.model = null;
238
+ state.index = EMPTY_INDEX;
239
+ state.groupStores.clear();
240
+ state.trees.clear();
241
+ state.expansion.expanded.clear();
242
+ state.expansion.slots.clear();
243
+ adoptIndex(state.expansion, EMPTY_INDEX);
244
+ if (previousLength > 0) {
245
+ root?.itemsChanged(0, previousLength, 0);
246
+ }
247
+ }
248
+ finally {
249
+ state.expansion.isSyncing = false;
250
+ }
251
+ }
259
252
  function createCollectionModel() {
260
- registeredStoreClass();
261
- const root = newRootStore();
262
253
  const state = {
263
- root,
264
- rootModels: [],
265
- model: Gtk.FlattenListModel.new(root),
266
- groupStores: [],
254
+ root: null,
255
+ model: null,
256
+ groupStores: new Map(),
267
257
  trees: new Map(),
268
- treeModels: [],
269
258
  expansion: createTreeExpansion(EMPTY_INDEX),
270
259
  index: EMPTY_INDEX,
271
260
  };
272
261
  return {
273
- model: state.model,
274
262
  expansion: state.expansion,
275
263
  rowAt: (position) => rowAt(state, position),
264
+ bind: (root, model) => {
265
+ root.state = state;
266
+ state.root = root;
267
+ state.model = model;
268
+ },
269
+ clear: () => {
270
+ clearModel(state);
271
+ },
276
272
  sync: (index) => {
277
273
  syncModel(state, index);
278
274
  },
279
275
  };
280
276
  }
277
+ class CollectionRootStore extends GObject.Object {
278
+ state = null;
279
+ vfuncGetItemType() {
280
+ return GObject.TYPE_OBJECT;
281
+ }
282
+ vfuncGetNItems() {
283
+ return this.state?.index.groups.length ?? 0;
284
+ }
285
+ vfuncGetItem(position) {
286
+ const state = this.state;
287
+ const level = state?.index.groups[position];
288
+ if (state === null || level === undefined) {
289
+ return null;
290
+ }
291
+ let store = state.groupStores.get(position);
292
+ if (store === undefined) {
293
+ store = newLevelStore(level);
294
+ state.groupStores.set(position, store);
295
+ }
296
+ return state.index.isTree ? treeFor(state, store) : store;
297
+ }
298
+ }
281
299
  class LazyLevelStore extends GObject.Object {
282
300
  level = { path: "", items: [], expandableFlags: [] };
283
- refs = [];
284
- objects = [];
285
- childStores = [];
286
- createItem(position, ref) {
301
+ refs = new Map();
302
+ objects = new Map();
303
+ childStores = new Map();
304
+ createItem(position) {
305
+ const ref = { store: this, slot: position };
287
306
  const created = Gtk.StringObject.new("");
288
- this.objects[position] = created;
289
- SLOTS.set(created, ref);
307
+ this.refs.set(position, ref);
308
+ this.objects.set(position, created);
309
+ sharedSlots().set(created, ref);
290
310
  return created;
291
311
  }
292
312
  vfuncGetItemType() {
293
313
  return GObject.TYPE_OBJECT;
294
314
  }
295
315
  vfuncGetNItems() {
296
- return this.refs.length;
316
+ return this.level.items.length;
297
317
  }
298
318
  vfuncGetItem(position) {
299
- const ref = this.refs[position];
300
- if (ref === undefined) {
319
+ if (position < 0 || position >= this.level.items.length) {
301
320
  return null;
302
321
  }
303
- return this.objects[position] ?? this.createItem(position, ref);
322
+ return this.objects.get(position) ?? this.createItem(position);
304
323
  }
305
324
  }
306
- export { createCollectionModel, slotPathAt, slotRefFor };
325
+ const CollectionRoot = createElementComponent("GtkxCollectionRootStore", registeredRootClass());
326
+ export { CollectionRoot, createCollectionModel, slotPathAt, slotRefFor, };
307
327
  //# sourceMappingURL=collection-model.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection-model.js","sourceRoot":"","sources":["../../src/internal/collection-model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,OAAO,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAG9C,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AA0ClF,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;AACvE,MAAM,SAAS,GAAG,MAAM,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;AACvE,MAAM,WAAW,GAAG,qBAAqB,CAAC,SAAS,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;AACtE,MAAM,KAAK,GAAG,WAAW,EAAE,CAAC;AAE5B,MAAM,YAAY,GAAG,GAAkB,EAAE,CAAC,IAAI,GAAG,CAAC,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,W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gB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;QAEhC,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACpB,OAAO,IAAI,CAAC;QAChB,CAAC;QAED,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IACpE,CAAC;CACJ;AAED,OAAO,EAAE,qBAAqB,EAAE,UAAU,EAAE,UAAU,EAAsC,CAAC","sourcesContent":["import * as Gio from \"@gtkx/gi/gio\";\nimport * as GObject from \"@gtkx/gi/gobject\";\nimport * as Gtk from \"@gtkx/gi/gtk\";\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: LevelStore;\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 LevelSync = {\n store: LevelStore;\n level: Level;\n};\n\ntype ModelState = {\n root: Gio.ListStore;\n rootModels: GObject.Object[];\n model: Gtk.FlattenListModel;\n groupStores: LevelStore[];\n trees: Map<LevelStore, Gtk.TreeListModel>;\n treeModels: Gtk.TreeListModel[];\n expansion: TreeExpansion;\n index: CollectionIndex;\n};\n\ntype CollectionModel = {\n model: Gtk.FlattenListModel;\n expansion: TreeExpansion;\n rowAt: (position: number) => Gtk.TreeListRow | null;\n sync: (index: CollectionIndex) => void;\n};\n\nconst STORE_CLASS_KEY = Symbol.for(\"gtkx.components.lazy-level-store\");\nconst SLOTS_KEY = Symbol.for(\"gtkx.components.lazy-level-store.slots\");\nconst EMPTY_INDEX = createCollectionIndex(undefined, undefined, true);\nconst SLOTS = sharedSlots();\n\nconst newRootStore = (): Gio.ListStore => new Gio.ListStore({ itemType: GObject.TYPE_OBJECT });\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 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 = SLOTS.get(item);\n\n return ref === undefined || ref.slot === -1 ? null : ref;\n}\n\nfunction slotPathAt(store: LevelStore, slot: number): string {\n return store.level.path + encodePart(String(slot));\n}\n\nfunction growStore(store: LevelStore): void {\n for (let slot = store.refs.length; slot < store.level.items.length; slot++) {\n store.refs.push({ store, slot });\n store.objects.push(null);\n store.childStores.push(null);\n }\n}\n\nfunction newLevelStore(level: Level): LevelStore {\n const store = new (registeredStoreClass())() as LevelStore;\n store.level = level;\n growStore(store);\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 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[slot] = null;\n }\n}\n\nfunction detachRefs(store: LevelStore, nextLength: number): void {\n for (let slot = nextLength; slot < store.refs.length; slot++) {\n const ref = store.refs[slot];\n\n if (ref !== undefined) {\n ref.slot = -1;\n }\n }\n}\n\nfunction shrinkStore(context: SyncContext, store: LevelStore, nextLength: number): void {\n if (store.refs.length <= nextLength) {\n return;\n }\n\n detachRefs(store, nextLength);\n pruneSlots(context.expansion, store.level.path, (slot) => slot >= nextLength);\n store.refs.length = nextLength;\n store.objects.length = nextLength;\n store.childStores.length = 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 childSync(\n context: SyncContext,\n store: LevelStore,\n slot: number,\n flipped: Set<number>,\n): LevelSync | undefined {\n const child = store.childStores[slot] ?? null;\n\n if (child === null || flipped.has(slot)) {\n return undefined;\n }\n\n const level = context.index.childLevel(store.level, slot);\n\n return level === undefined ? undefined : { store: child, level };\n}\n\nfunction childSyncs(context: SyncContext, store: LevelStore, overlap: number, flipped: Set<number>): LevelSync[] {\n const syncs: LevelSync[] = [];\n\n for (let slot = 0; slot < overlap; slot++) {\n const sync = childSync(context, store, slot, flipped);\n\n if (sync !== undefined) {\n syncs.push(sync);\n }\n }\n\n return syncs;\n}\n\nfunction syncEntry(context: SyncContext, entry: LevelSync): LevelSync[] {\n const { store, level } = entry;\n const previousLength = store.refs.length;\n const overlap = Math.min(previousLength, level.items.length);\n const flipped = collectFlips(store.level, level, overlap);\n store.level = level;\n pruneFlips(context, store, flipped);\n shrinkStore(context, store, level.items.length);\n growStore(store);\n emitTailSplice(store, previousLength, level.items.length);\n emitFlips(store, flipped);\n\n return childSyncs(context, store, overlap, flipped);\n}\n\nfunction syncLevel(context: SyncContext, store: LevelStore, level: Level): void {\n const pending: LevelSync[] = [{ store, level }];\n\n while (pending.length > 0) {\n const entry = pending.pop();\n\n if (entry !== undefined) {\n pending.push(...syncEntry(context, entry).toReversed());\n }\n }\n}\n\nfunction ensureChildStore(index: CollectionIndex, store: LevelStore, slot: number): LevelStore | null {\n const existing = store.childStores[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[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 return (\n state.trees.get(store) ?? Gtk.TreeListModel.new(store, false, false, (object) => childStoreFor(state, object))\n );\n}\n\nfunction nextTrees(state: ModelState, index: CollectionIndex): Map<LevelStore, Gtk.TreeListModel> {\n if (!index.isTree) {\n return new Map();\n }\n\n return new Map(state.groupStores.map((store) => [store, treeFor(state, store)]));\n}\n\nfunction pruneRebuiltLevels(state: ModelState, next: Map<LevelStore, Gtk.TreeListModel>): void {\n const stores: Set<LevelStore> = new Set([...state.trees.keys(), ...next.keys()]);\n\n for (const store of stores) {\n if (state.trees.get(store) !== next.get(store)) {\n pruneSlots(state.expansion, store.level.path, () => true);\n }\n }\n}\n\nfunction adoptTrees(state: ModelState, index: CollectionIndex): void {\n const next = nextTrees(state, index);\n pruneRebuiltLevels(state, next);\n state.trees = next;\n state.treeModels = next.values().toArray();\n}\n\nfunction desiredRootModels(state: ModelState, index: CollectionIndex): GObject.Object[] {\n adoptTrees(state, index);\n\n return index.isTree ? [...state.treeModels] : [...state.groupStores];\n}\n\nfunction rowAt(state: ModelState, position: number): Gtk.TreeListRow | null {\n let offset = position;\n\n for (const tree of state.treeModels) {\n const count = tree.getNItems();\n\n if (offset < count) {\n return tree.getRow(offset);\n }\n\n offset -= count;\n }\n\n return null;\n}\n\nfunction hasSameModels(previous: GObject.Object[], next: GObject.Object[]): boolean {\n return previous.length === next.length && next.every((model, index) => previous[index] === model);\n}\n\nfunction syncRoot(state: ModelState, index: CollectionIndex): void {\n const next = desiredRootModels(state, index);\n\n if (hasSameModels(state.rootModels, next)) {\n return;\n }\n\n state.root.splice(0, state.rootModels.length, next);\n state.rootModels = next;\n}\n\nfunction adjustGroupStores(state: ModelState, context: SyncContext): void {\n const { groups } = context.index;\n state.groupStores.length = Math.min(state.groupStores.length, groups.length);\n\n for (const level of groups.slice(state.groupStores.length)) {\n state.groupStores.push(newLevelStore(level));\n }\n}\n\nfunction stepGroupStores(state: ModelState, context: SyncContext, surviving: number): void {\n for (const [group, level] of context.index.groups.entries()) {\n const store = state.groupStores[group];\n\n if (store !== undefined && group < surviving) {\n syncLevel(context, store, level);\n }\n }\n}\n\nfunction syncModel(state: ModelState, index: CollectionIndex): void {\n const context: SyncContext = { index, expansion: state.expansion };\n const surviving = Math.min(state.groupStores.length, index.groups.length);\n state.index = index;\n state.expansion.isSyncing = true;\n\n try {\n adjustGroupStores(state, context);\n syncRoot(state, index);\n stepGroupStores(state, context, surviving);\n } finally {\n state.expansion.isSyncing = false;\n }\n\n adoptIndex(state.expansion, index);\n}\n\nfunction createCollectionModel(): CollectionModel {\n registeredStoreClass();\n const root = newRootStore();\n\n const state: ModelState = {\n root,\n rootModels: [],\n model: Gtk.FlattenListModel.new(root),\n groupStores: [],\n trees: new Map(),\n treeModels: [],\n expansion: createTreeExpansion(EMPTY_INDEX),\n index: EMPTY_INDEX,\n };\n\n return {\n model: state.model,\n expansion: state.expansion,\n rowAt: (position) => rowAt(state, position),\n sync: (index) => {\n syncModel(state, index);\n },\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: SlotRef[] = [];\n objects: (Gtk.StringObject | null)[] = [];\n childStores: (LevelStore | null)[] = [];\n\n private createItem(position: number, ref: SlotRef): Gtk.StringObject {\n const created = Gtk.StringObject.new(\"\");\n this.objects[position] = created;\n SLOTS.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.refs.length;\n }\n\n vfuncGetItem(position: number): GObject.Object | null {\n const ref = this.refs[position];\n\n if (ref === undefined) {\n return null;\n }\n\n return this.objects[position] ?? this.createItem(position, ref);\n }\n}\n\nexport { createCollectionModel, slotPathAt, slotRefFor, type CollectionModel, type SlotRef };\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,M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CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;QAC7B,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QACpC,WAAW,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC;QAEhC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,gBAAgB;QACZ,OAAO,OAAO,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,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;IACnE,CAAC;CACJ;AAED,MAAM,cAAc,GAA8C,sBAAsB,CACpF,yBAAyB,EACzB,mBAAmB,EAAE,CACxB,CAAC;AAEF,OAAO,EACH,cAAc,EACd,qBAAqB,EACrB,UAAU,EACV,UAAU,GAIb,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 { 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,11 +1,12 @@
1
+ import type * as Gtk from "@gtkx/gi/gtk";
1
2
  import type { ListItem } from "../types.js";
2
- import type { CollectionIndex } from "./collection-index.js";
3
+ import type { CollectionIndex, SectionIdentity } from "./collection-index.js";
3
4
  import type { CollectionModel, SlotRef } from "./collection-model.js";
4
5
  import type { MatchedRows } from "./tree-order.js";
5
- type Collection = Pick<CollectionModel, "model" | "expansion" | "rowAt"> & {
6
+ type Collection = Pick<CollectionModel, "expansion" | "rowAt"> & {
6
7
  isTree: boolean;
7
8
  itemAt: (ref: SlotRef) => ListItem | undefined;
8
- sectionFor: (levelPath: string) => unknown;
9
+ sectionFor: (levelPath: string) => SectionIdentity | undefined;
9
10
  idAt: (position: number) => string | null;
10
11
  idsAt: (positions: number[]) => string[];
11
12
  pathAt: (position: number) => string | null;
@@ -13,6 +14,6 @@ type Collection = Pick<CollectionModel, "model" | "expansion" | "rowAt"> & {
13
14
  rowsFor: (ids: string[]) => MatchedRows;
14
15
  };
15
16
  declare function isCollectionIdle(collection: Collection): boolean;
16
- declare function createCollection(collectionModel: CollectionModel, index: CollectionIndex): Collection;
17
+ declare function createCollection(gtkModel: CollectionModel, index: CollectionIndex, model: Gtk.FlattenListModel | null): Collection;
17
18
  export { createCollection, isCollectionIdle, type Collection };
18
19
  //# sourceMappingURL=collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/internal/collection.ts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