tinybase 8.3.0-beta.1 → 8.3.0-beta.2

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.
@@ -0,0 +1,2154 @@
1
+ import {
2
+ createContext,
3
+ createEffect,
4
+ createMemo,
5
+ createRenderEffect,
6
+ createSignal,
7
+ onCleanup,
8
+ untrack,
9
+ useContext,
10
+ } from 'solid-js';
11
+ import h from 'solid-js/h';
12
+
13
+ const getTypeOf = (thing) => typeof thing;
14
+ const TINYBASE = 'tinybase';
15
+ const EMPTY_STRING = '';
16
+ const STRING = getTypeOf(EMPTY_STRING);
17
+ const FUNCTION = getTypeOf(getTypeOf);
18
+ const LISTENER = 'Listener';
19
+ const RESULT = 'Result';
20
+ const GET = 'get';
21
+ const SET = 'set';
22
+ const ADD = 'add';
23
+ const DEL = 'del';
24
+ const HAS = 'Has';
25
+ const _HAS = 'has';
26
+ const IDS = 'Ids';
27
+ const TABLE = 'Table';
28
+ const TABLES = TABLE + 's';
29
+ const TABLE_IDS = TABLE + IDS;
30
+ const ROW = 'Row';
31
+ const ROW_COUNT = ROW + 'Count';
32
+ const ROW_IDS = ROW + IDS;
33
+ const SORTED_ROW_IDS = 'Sorted' + ROW + IDS;
34
+ const CELL = 'Cell';
35
+ const CELL_IDS = CELL + IDS;
36
+ const VALUE = 'Value';
37
+ const VALUES = VALUE + 's';
38
+ const VALUE_IDS = VALUE + IDS;
39
+ const TRANSACTION = 'Transaction';
40
+ const PARTIAL = 'Partial';
41
+ const FINISH = 'Finish';
42
+ const STATUS = 'Status';
43
+ const METRIC = 'Metric';
44
+ const INDEX = 'Index';
45
+ const SLICE = 'Slice';
46
+ const RELATIONSHIP = 'Relationship';
47
+ const REMOTE_ROW_ID = 'Remote' + ROW + 'Id';
48
+ const LOCAL = 'Local';
49
+ const LINKED = 'Linked';
50
+ const QUERY = 'Query';
51
+ const CHECKPOINT = 'Checkpoint';
52
+
53
+ const getIfNotFunction = (predicate) => (value, then, otherwise) =>
54
+ predicate(value)
55
+ ? /* istanbul ignore next */
56
+ otherwise?.()
57
+ : then(value);
58
+ const GLOBAL = globalThis;
59
+ const isNullish = (thing) => thing == null;
60
+ const isUndefined = (thing) => thing === void 0;
61
+ const ifNotNullish = getIfNotFunction(isNullish);
62
+ const ifNotUndefined = getIfNotFunction(isUndefined);
63
+ const isString = (thing) => getTypeOf(thing) == STRING;
64
+ const isFunction = (thing) => getTypeOf(thing) == FUNCTION;
65
+ const isArray = (thing) => Array.isArray(thing);
66
+ const size = (arrayOrString) => arrayOrString.length;
67
+ const getUndefined = () => void 0;
68
+ const getArg = (value) => value;
69
+
70
+ const arrayNew = (size2, cb) =>
71
+ arrayMap(new Array(size2).fill(0), (_, index) => cb(index));
72
+ const arrayEvery = (array, cb) => array.every(cb);
73
+ const arrayIsEqual = (array1, array2) =>
74
+ size(array1) === size(array2) &&
75
+ arrayEvery(array1, (value1, index) => array2[index] === value1);
76
+ const arrayOrValueEqual = (value1, value2) =>
77
+ isArray(value1) && isArray(value2)
78
+ ? arrayIsEqual(value1, value2)
79
+ : value1 === value2;
80
+ const arrayMap = (array, cb) => array.map(cb);
81
+ const arrayIsEmpty = (array) => size(array) == 0;
82
+ const arrayWith = (array, index, value) => array.with(index, value);
83
+
84
+ const object = Object;
85
+ const getPrototypeOf = (obj) => object.getPrototypeOf(obj);
86
+ const objEntries = object.entries;
87
+ const isObject = (obj) =>
88
+ !isNullish(obj) &&
89
+ ifNotNullish(
90
+ getPrototypeOf(obj),
91
+ (objPrototype) =>
92
+ objPrototype == object.prototype ||
93
+ isNullish(getPrototypeOf(objPrototype)),
94
+
95
+ /* istanbul ignore next */
96
+ () => true,
97
+ );
98
+ const objIds = object.keys;
99
+ const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
100
+ const objHas = (obj, id) => id in obj;
101
+ const objDel = (obj, id) => {
102
+ delete obj[id];
103
+ return obj;
104
+ };
105
+ const objSize = (obj) => size(objIds(obj));
106
+
107
+ /* istanbul ignore next */
108
+ const objIsEqual = (
109
+ obj1,
110
+ obj2,
111
+ isEqual = (value1, value2) => value1 === value2,
112
+ ) => {
113
+ const entries1 = objEntries(obj1);
114
+ return (
115
+ size(entries1) === objSize(obj2) &&
116
+ arrayEvery(entries1, ([index, value1]) =>
117
+ isObject(value1)
118
+ ? /* istanbul ignore next */
119
+ isObject(obj2[index])
120
+ ? objIsEqual(obj2[index], value1, isEqual)
121
+ : false
122
+ : isEqual(value1, obj2[index]),
123
+ )
124
+ );
125
+ };
126
+
127
+ const getValue = (value) => (isFunction(value) ? value() : value);
128
+ const getProps = (getProps2, ...ids) =>
129
+ isUndefined(getProps2) ? {} : getProps2(...ids);
130
+ const getRelationshipsStoreTableIds = (relationships, relationshipId) => [
131
+ relationships,
132
+ relationships?.getStore(),
133
+ relationships?.getLocalTableId(relationshipId),
134
+ relationships?.getRemoteTableId(relationshipId),
135
+ ];
136
+ const getIndexStoreTableId = (indexes, indexId) => [
137
+ indexes,
138
+ indexes?.getStore(),
139
+ indexes?.getTableId(indexId),
140
+ ];
141
+
142
+ const TINYBASE_CONTEXT = TINYBASE + '_uisc';
143
+ const EMPTY_CONTEXT$1 = () => [];
144
+ const EMPTY_CONTEXT_VALUE = {value: EMPTY_CONTEXT$1};
145
+ const GLOBAL_CONTEXT = GLOBAL;
146
+ const Context = GLOBAL_CONTEXT[TINYBASE_CONTEXT]
147
+ ? /* istanbul ignore next */
148
+ GLOBAL_CONTEXT[TINYBASE_CONTEXT]
149
+ : (GLOBAL_CONTEXT[TINYBASE_CONTEXT] = createContext(EMPTY_CONTEXT_VALUE));
150
+ const useThing = (id, offset) => {
151
+ const contextValue = useContext(Context)?.value ?? EMPTY_CONTEXT$1;
152
+ return () => {
153
+ const resolvedContextValue = contextValue();
154
+ const resolvedId = getValue(id);
155
+ return isUndefined(resolvedId)
156
+ ? resolvedContextValue[offset * 2]
157
+ : isString(resolvedId)
158
+ ? objGet(resolvedContextValue[offset * 2 + 1], resolvedId)
159
+ : resolvedId;
160
+ };
161
+ };
162
+ const useThings = (offset) => {
163
+ const contextValue = useContext(Context)?.value ?? EMPTY_CONTEXT$1;
164
+ return () => ({...contextValue()[offset * 2 + 1]});
165
+ };
166
+ const useThingOrThingById = (thingOrThingId, offset) => {
167
+ const thing = useThing(thingOrThingId, offset);
168
+ return () => {
169
+ const resolvedThingOrThingId = getValue(thingOrThingId);
170
+ return isUndefined(resolvedThingOrThingId) ||
171
+ isString(resolvedThingOrThingId)
172
+ ? thing()
173
+ : resolvedThingOrThingId;
174
+ };
175
+ };
176
+ const useProvideThing = (thingId, thing, offset) => {
177
+ const contextValue = useContext(Context)?.value ?? EMPTY_CONTEXT$1;
178
+ createRenderEffect(() => {
179
+ const {16: addExtraThingById, 17: delExtraThingById} =
180
+ untrack(contextValue);
181
+ addExtraThingById?.(offset, thingId, thing);
182
+ onCleanup(() => delExtraThingById?.(offset, thingId));
183
+ });
184
+ };
185
+ const useThingIds = (offset) => {
186
+ const contextValue = useContext(Context)?.value ?? EMPTY_CONTEXT$1;
187
+ return () => objIds(contextValue()[offset * 2 + 1] ?? {});
188
+ };
189
+
190
+ const OFFSET_STORE = 0;
191
+ const OFFSET_METRICS = 1;
192
+ const OFFSET_INDEXES = 2;
193
+ const OFFSET_RELATIONSHIPS = 3;
194
+ const OFFSET_QUERIES = 4;
195
+ const OFFSET_CHECKPOINTS = 5;
196
+ const OFFSET_PERSISTER = 6;
197
+ const OFFSET_SYNCHRONIZER = 7;
198
+ const mergeParentThings = (
199
+ offset,
200
+ parentValue,
201
+ defaultThing,
202
+ thingsById,
203
+ extraThingsById,
204
+ ) => [
205
+ defaultThing ?? parentValue[offset * 2],
206
+ {
207
+ ...parentValue[offset * 2 + 1],
208
+ ...thingsById,
209
+ ...extraThingsById[offset],
210
+ },
211
+ ];
212
+ const EMPTY_CONTEXT = () => [];
213
+ const Provider = (props) => {
214
+ const parentValue = useContext(Context)?.value ?? EMPTY_CONTEXT;
215
+ const [extraThingsById, setExtraThingsById] = createSignal(
216
+ arrayNew(8, () => ({})),
217
+ );
218
+ const addExtraThingById = (thingOffset, id, thing) => {
219
+ setExtraThingsById((extraThingsById2) =>
220
+ objGet(extraThingsById2[thingOffset], id) == thing
221
+ ? extraThingsById2
222
+ : arrayWith(extraThingsById2, thingOffset, {
223
+ ...extraThingsById2[thingOffset],
224
+ [id]: thing,
225
+ }),
226
+ );
227
+ };
228
+ const delExtraThingById = (thingOffset, id) => {
229
+ setExtraThingsById((extraThingsById2) =>
230
+ !objHas(extraThingsById2[thingOffset], id)
231
+ ? extraThingsById2
232
+ : arrayWith(
233
+ extraThingsById2,
234
+ thingOffset,
235
+ objDel(extraThingsById2[thingOffset], id),
236
+ ),
237
+ );
238
+ };
239
+ const contextValue = createMemo(() => [
240
+ ...mergeParentThings(
241
+ OFFSET_STORE,
242
+ parentValue(),
243
+ props.store,
244
+ props.storesById,
245
+ extraThingsById(),
246
+ ),
247
+ ...mergeParentThings(
248
+ OFFSET_METRICS,
249
+ parentValue(),
250
+ props.metrics,
251
+ props.metricsById,
252
+ extraThingsById(),
253
+ ),
254
+ ...mergeParentThings(
255
+ OFFSET_INDEXES,
256
+ parentValue(),
257
+ props.indexes,
258
+ props.indexesById,
259
+ extraThingsById(),
260
+ ),
261
+ ...mergeParentThings(
262
+ OFFSET_RELATIONSHIPS,
263
+ parentValue(),
264
+ props.relationships,
265
+ props.relationshipsById,
266
+ extraThingsById(),
267
+ ),
268
+ ...mergeParentThings(
269
+ OFFSET_QUERIES,
270
+ parentValue(),
271
+ props.queries,
272
+ props.queriesById,
273
+ extraThingsById(),
274
+ ),
275
+ ...mergeParentThings(
276
+ OFFSET_CHECKPOINTS,
277
+ parentValue(),
278
+ props.checkpoints,
279
+ props.checkpointsById,
280
+ extraThingsById(),
281
+ ),
282
+ ...mergeParentThings(
283
+ OFFSET_PERSISTER,
284
+ parentValue(),
285
+ props.persister,
286
+ props.persistersById,
287
+ extraThingsById(),
288
+ ),
289
+ ...mergeParentThings(
290
+ OFFSET_SYNCHRONIZER,
291
+ parentValue(),
292
+ props.synchronizer,
293
+ props.synchronizersById,
294
+ extraThingsById(),
295
+ ),
296
+ addExtraThingById,
297
+ delExtraThingById,
298
+ ]);
299
+ return /* @__PURE__ */ h(
300
+ Context.Provider,
301
+ {value: {value: contextValue}},
302
+ () => props.children,
303
+ );
304
+ };
305
+
306
+ const EMPTY_ARRAY = [];
307
+ const DEFAULTS = [
308
+ {},
309
+ [],
310
+ [EMPTY_ARRAY, void 0, EMPTY_ARRAY],
311
+ {},
312
+ void 0,
313
+ void 0,
314
+ false,
315
+ 0,
316
+ ];
317
+ const IS_EQUALS = [
318
+ objIsEqual,
319
+ arrayIsEqual,
320
+ (
321
+ [backwardIds1, currentId1, forwardIds1],
322
+ [backwardIds2, currentId2, forwardIds2],
323
+ ) =>
324
+ currentId1 === currentId2 &&
325
+ arrayIsEqual(backwardIds1, backwardIds2) &&
326
+ arrayIsEqual(forwardIds1, forwardIds2),
327
+ (paramValues1, paramValues2) =>
328
+ objIsEqual(paramValues1, paramValues2, arrayOrValueEqual),
329
+ arrayOrValueEqual,
330
+ ];
331
+ const isEqual = (thing1, thing2) => thing1 === thing2;
332
+ const getThing = (thing) => (isFunction(thing) ? thing() : thing);
333
+ const EMPTY_LISTENER_ARG_GETTERS = [];
334
+ const useCreate = (store, create) => {
335
+ const [thing, setThing] = createSignal();
336
+ createEffect(() => {
337
+ const resolvedStore = getThing(store);
338
+ const newThing = resolvedStore ? create(resolvedStore) : void 0;
339
+ setThing(() => newThing);
340
+ onCleanup(() => newThing?.destroy?.());
341
+ });
342
+ return thing;
343
+ };
344
+ const addAndDelListener = (thing, listenable, ...args) => {
345
+ const listenerId = thing?.[ADD + listenable + LISTENER]?.(...args);
346
+ return () => thing?.delListener?.(listenerId);
347
+ };
348
+ const useListenable = (
349
+ listenable,
350
+ thing,
351
+ returnType,
352
+ listenerArgGetters = EMPTY_LISTENER_ARG_GETTERS,
353
+ ) => {
354
+ const [result, setResult] = createSignal(DEFAULTS[returnType]);
355
+ const getListenerArguments = () => arrayMap(listenerArgGetters, getThing);
356
+ const getResult = () =>
357
+ getThing(thing)?.[
358
+ (returnType == 6 /* Boolean */ ? _HAS : GET) + listenable
359
+ ]?.(...getListenerArguments()) ?? DEFAULTS[returnType];
360
+ const updateResult = () => {
361
+ const nextResult = getResult();
362
+ const prevResult = untrack(result);
363
+ setResult(() =>
364
+ !(IS_EQUALS[returnType] ?? isEqual)(nextResult, prevResult)
365
+ ? nextResult
366
+ : prevResult,
367
+ );
368
+ };
369
+ createRenderEffect(() => {
370
+ const resolvedThing = getThing(thing);
371
+ const listenerArguments = getListenerArguments();
372
+ updateResult();
373
+ const cleanup = addAndDelListener(
374
+ resolvedThing,
375
+ (returnType == 6 /* Boolean */ ? HAS : EMPTY_STRING) + listenable,
376
+ ...listenerArguments,
377
+ updateResult,
378
+ );
379
+ onCleanup(cleanup);
380
+ });
381
+ return result;
382
+ };
383
+ const useListener = (
384
+ listenable,
385
+ thing,
386
+ listener,
387
+ preListenerArgGetters = EMPTY_LISTENER_ARG_GETTERS,
388
+ ...postListenerArgGetters
389
+ ) =>
390
+ createRenderEffect(() => {
391
+ const cleanup = addAndDelListener(
392
+ getThing(thing),
393
+ listenable,
394
+ ...arrayMap(preListenerArgGetters, getThing),
395
+ listener,
396
+ ...arrayMap(postListenerArgGetters, getThing),
397
+ );
398
+ onCleanup(cleanup);
399
+ });
400
+ const useSetCallback =
401
+ (storeOrQueries, settable, get, then = getUndefined, methodPrefix, ...args) =>
402
+ (parameter) =>
403
+ ifNotUndefined(getThing(storeOrQueries), (obj) =>
404
+ ifNotUndefined(get(parameter, obj), (thing) =>
405
+ then(
406
+ obj[methodPrefix + settable](
407
+ ...argsOrGetArgs(args, obj, parameter),
408
+ thing,
409
+ ),
410
+ thing,
411
+ ),
412
+ ),
413
+ );
414
+ const useStoreSetCallback = (storeOrStoreId, settable, get, then, ...args) =>
415
+ useSetCallback(
416
+ useStoreOrStoreById(storeOrStoreId),
417
+ settable,
418
+ get,
419
+ then,
420
+ SET,
421
+ ...args,
422
+ );
423
+ const useQueriesSetCallback = (
424
+ queriesOrQueriesId,
425
+ settable,
426
+ get,
427
+ then,
428
+ ...args
429
+ ) =>
430
+ useSetCallback(
431
+ useQueriesOrQueriesById(queriesOrQueriesId),
432
+ settable,
433
+ get,
434
+ then,
435
+ EMPTY_STRING,
436
+ ...args,
437
+ );
438
+ const argsOrGetArgs = (args, store, parameter) =>
439
+ arrayMap(args, (arg) =>
440
+ isFunction(arg)
441
+ ? arg.length == 0
442
+ ? getThing(arg)
443
+ : arg(parameter, store)
444
+ : arg,
445
+ );
446
+ const useDel = (storeOrStoreId, deletable, then = getUndefined, ...args) => {
447
+ const store = useStoreOrStoreById(storeOrStoreId);
448
+ return (parameter) => {
449
+ const resolvedStore = getThing(store);
450
+ ifNotUndefined(resolvedStore, (store2) =>
451
+ then(store2[DEL + deletable](...argsOrGetArgs(args, store2, parameter))),
452
+ );
453
+ };
454
+ };
455
+ const useCheckpointAction = (checkpointsOrCheckpointsId, action, arg) => {
456
+ const checkpoints = useCheckpointsOrCheckpointsById(
457
+ checkpointsOrCheckpointsId,
458
+ );
459
+ return () => getThing(checkpoints)?.[action](arg);
460
+ };
461
+ const useSortedRowIdsImpl = (
462
+ tableId,
463
+ cellId,
464
+ descending,
465
+ offset,
466
+ limit,
467
+ storeOrStoreId,
468
+ ) =>
469
+ useListenable(
470
+ SORTED_ROW_IDS,
471
+ useStoreOrStoreById(storeOrStoreId),
472
+ 1 /* Array */,
473
+ [tableId, cellId, descending, offset, limit],
474
+ );
475
+ const useSortedRowIdsListenerImpl = (
476
+ tableId,
477
+ cellId,
478
+ descending,
479
+ offset,
480
+ limit,
481
+ listener,
482
+ mutator,
483
+ storeOrStoreId,
484
+ ) =>
485
+ useListener(
486
+ SORTED_ROW_IDS,
487
+ useStoreOrStoreById(storeOrStoreId),
488
+ listener,
489
+ [tableId, cellId, descending, offset, limit],
490
+ mutator,
491
+ );
492
+ const useCreateStore = (create) => {
493
+ const store = createMemo(create);
494
+ return store;
495
+ };
496
+ const useStoreIds = () => useThingIds(OFFSET_STORE);
497
+ const useStore = (id) => useThing(id, OFFSET_STORE);
498
+ const useStores = () => useThings(OFFSET_STORE);
499
+ const useStoreOrStoreById = (storeOrStoreId) =>
500
+ useThingOrThingById(storeOrStoreId, OFFSET_STORE);
501
+ const useProvideStore = (storeId, store) =>
502
+ useProvideThing(storeId, store, OFFSET_STORE);
503
+ const useCreateMergeableStore = (create) => {
504
+ const mergeableStore = createMemo(create);
505
+ return mergeableStore;
506
+ };
507
+ const useHasTables = (storeOrStoreId) =>
508
+ useListenable(
509
+ TABLES,
510
+ useStoreOrStoreById(storeOrStoreId),
511
+ 6 /* Boolean */,
512
+ [],
513
+ );
514
+ const useTables = (storeOrStoreId) =>
515
+ useListenable(TABLES, useStoreOrStoreById(storeOrStoreId), 0 /* Object */);
516
+ const useTablesState = (storeOrStoreId) => [
517
+ useTables(storeOrStoreId),
518
+ useSetTablesCallback(getArg, storeOrStoreId),
519
+ ];
520
+ const useTableIds = (storeOrStoreId) =>
521
+ useListenable(TABLE_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */);
522
+ const useHasTable = (tableId, storeOrStoreId) =>
523
+ useListenable(TABLE, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
524
+ tableId,
525
+ ]);
526
+ const useTable = (tableId, storeOrStoreId) =>
527
+ useListenable(TABLE, useStoreOrStoreById(storeOrStoreId), 0 /* Object */, [
528
+ tableId,
529
+ ]);
530
+ const useTableState = (tableId, storeOrStoreId) => [
531
+ useTable(tableId, storeOrStoreId),
532
+ useSetTableCallback(tableId, getArg, storeOrStoreId),
533
+ ];
534
+ const useTableCellIds = (tableId, storeOrStoreId) =>
535
+ useListenable(
536
+ TABLE + CELL_IDS,
537
+ useStoreOrStoreById(storeOrStoreId),
538
+ 1 /* Array */,
539
+ [tableId],
540
+ );
541
+ const useHasTableCell = (tableId, cellId, storeOrStoreId) =>
542
+ useListenable(
543
+ TABLE + CELL,
544
+ useStoreOrStoreById(storeOrStoreId),
545
+ 6 /* Boolean */,
546
+ [tableId, cellId],
547
+ );
548
+ const useRowCount = (tableId, storeOrStoreId) =>
549
+ useListenable(
550
+ ROW_COUNT,
551
+ useStoreOrStoreById(storeOrStoreId),
552
+ 7 /* Number */,
553
+ [tableId],
554
+ );
555
+ const useRowIds = (tableId, storeOrStoreId) =>
556
+ useListenable(ROW_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */, [
557
+ tableId,
558
+ ]);
559
+ const useSortedRowIds = (
560
+ tableIdOrArgs,
561
+ cellIdOrStoreOrStoreId,
562
+ descending,
563
+ offset,
564
+ limit,
565
+ storeOrStoreId,
566
+ ) =>
567
+ isObject(tableIdOrArgs)
568
+ ? useSortedRowIdsImpl(
569
+ tableIdOrArgs.tableId,
570
+ tableIdOrArgs.cellId,
571
+ tableIdOrArgs.descending ?? false,
572
+ tableIdOrArgs.offset ?? 0,
573
+ tableIdOrArgs.limit,
574
+ cellIdOrStoreOrStoreId,
575
+ )
576
+ : useSortedRowIdsImpl(
577
+ tableIdOrArgs,
578
+ cellIdOrStoreOrStoreId,
579
+ descending,
580
+ offset,
581
+ limit,
582
+ storeOrStoreId,
583
+ );
584
+ const useHasRow = (tableId, rowId, storeOrStoreId) =>
585
+ useListenable(ROW, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
586
+ tableId,
587
+ rowId,
588
+ ]);
589
+ const useRow = (tableId, rowId, storeOrStoreId) =>
590
+ useListenable(ROW, useStoreOrStoreById(storeOrStoreId), 0 /* Object */, [
591
+ tableId,
592
+ rowId,
593
+ ]);
594
+ const useRowState = (tableId, rowId, storeOrStoreId) => [
595
+ useRow(tableId, rowId, storeOrStoreId),
596
+ useSetRowCallback(tableId, rowId, getArg, storeOrStoreId),
597
+ ];
598
+ const useCellIds = (tableId, rowId, storeOrStoreId) =>
599
+ useListenable(CELL_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */, [
600
+ tableId,
601
+ rowId,
602
+ ]);
603
+ const useHasCell = (tableId, rowId, cellId, storeOrStoreId) =>
604
+ useListenable(CELL, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
605
+ tableId,
606
+ rowId,
607
+ cellId,
608
+ ]);
609
+ const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
610
+ useListenable(
611
+ CELL,
612
+ useStoreOrStoreById(storeOrStoreId),
613
+ 5 /* CellOrValue */,
614
+ [tableId, rowId, cellId],
615
+ );
616
+ const useCellState = (tableId, rowId, cellId, storeOrStoreId) => [
617
+ useCell(tableId, rowId, cellId, storeOrStoreId),
618
+ useSetCellCallback(tableId, rowId, cellId, getArg, storeOrStoreId),
619
+ ];
620
+ const useHasValues = (storeOrStoreId) =>
621
+ useListenable(
622
+ VALUES,
623
+ useStoreOrStoreById(storeOrStoreId),
624
+ 6 /* Boolean */,
625
+ [],
626
+ );
627
+ const useValues = (storeOrStoreId) =>
628
+ useListenable(VALUES, useStoreOrStoreById(storeOrStoreId), 0 /* Object */);
629
+ const useValuesState = (storeOrStoreId) => [
630
+ useValues(storeOrStoreId),
631
+ useSetValuesCallback(getArg, storeOrStoreId),
632
+ ];
633
+ const useValueIds = (storeOrStoreId) =>
634
+ useListenable(VALUE_IDS, useStoreOrStoreById(storeOrStoreId), 1 /* Array */);
635
+ const useHasValue = (valueId, storeOrStoreId) =>
636
+ useListenable(VALUE, useStoreOrStoreById(storeOrStoreId), 6 /* Boolean */, [
637
+ valueId,
638
+ ]);
639
+ const useValue = (valueId, storeOrStoreId) =>
640
+ useListenable(
641
+ VALUE,
642
+ useStoreOrStoreById(storeOrStoreId),
643
+ 5 /* CellOrValue */,
644
+ [valueId],
645
+ );
646
+ const useValueState = (valueId, storeOrStoreId) => [
647
+ useValue(valueId, storeOrStoreId),
648
+ useSetValueCallback(valueId, getArg, storeOrStoreId),
649
+ ];
650
+ const useSetTablesCallback = (getTables, storeOrStoreId, then) =>
651
+ useStoreSetCallback(storeOrStoreId, TABLES, getTables, then);
652
+ const useSetTableCallback = (tableId, getTable, storeOrStoreId, then) =>
653
+ useStoreSetCallback(storeOrStoreId, TABLE, getTable, then, tableId);
654
+ const useSetRowCallback = (tableId, rowId, getRow, storeOrStoreId, then) =>
655
+ useStoreSetCallback(storeOrStoreId, ROW, getRow, then, tableId, rowId);
656
+ const useAddRowCallback = (
657
+ tableId,
658
+ getRow,
659
+ storeOrStoreId,
660
+ then = getUndefined,
661
+ reuseRowIds = true,
662
+ ) => {
663
+ const store = useStoreOrStoreById(storeOrStoreId);
664
+ return (parameter) =>
665
+ ifNotUndefined(getThing(store), (resolvedStore) =>
666
+ ifNotUndefined(getRow(parameter, resolvedStore), (row) =>
667
+ then(
668
+ resolvedStore.addRow(
669
+ isFunction(tableId) ? tableId(parameter, resolvedStore) : tableId,
670
+ row,
671
+ reuseRowIds,
672
+ ),
673
+ resolvedStore,
674
+ row,
675
+ ),
676
+ ),
677
+ );
678
+ };
679
+ const useSetPartialRowCallback = (
680
+ tableId,
681
+ rowId,
682
+ getPartialRow,
683
+ storeOrStoreId,
684
+ then,
685
+ ) =>
686
+ useStoreSetCallback(
687
+ storeOrStoreId,
688
+ PARTIAL + ROW,
689
+ getPartialRow,
690
+ then,
691
+ tableId,
692
+ rowId,
693
+ );
694
+ const useSetCellCallback = (
695
+ tableId,
696
+ rowId,
697
+ cellId,
698
+ getCell,
699
+ storeOrStoreId,
700
+ then,
701
+ ) =>
702
+ useStoreSetCallback(
703
+ storeOrStoreId,
704
+ CELL,
705
+ getCell,
706
+ then,
707
+ tableId,
708
+ rowId,
709
+ cellId,
710
+ );
711
+ const useSetValuesCallback = (getValues, storeOrStoreId, then) =>
712
+ useStoreSetCallback(storeOrStoreId, VALUES, getValues, then);
713
+ const useSetPartialValuesCallback = (getPartialValues, storeOrStoreId, then) =>
714
+ useStoreSetCallback(storeOrStoreId, PARTIAL + VALUES, getPartialValues, then);
715
+ const useSetValueCallback = (valueId, getValue, storeOrStoreId, then) =>
716
+ useStoreSetCallback(storeOrStoreId, VALUE, getValue, then, valueId);
717
+ const useDelTablesCallback = (storeOrStoreId, then) =>
718
+ useDel(storeOrStoreId, TABLES, then);
719
+ const useDelTableCallback = (tableId, storeOrStoreId, then) =>
720
+ useDel(storeOrStoreId, TABLE, then, tableId);
721
+ const useDelRowCallback = (tableId, rowId, storeOrStoreId, then) =>
722
+ useDel(storeOrStoreId, ROW, then, tableId, rowId);
723
+ const useDelCellCallback = (
724
+ tableId,
725
+ rowId,
726
+ cellId,
727
+ forceDel,
728
+ storeOrStoreId,
729
+ then,
730
+ ) => useDel(storeOrStoreId, CELL, then, tableId, rowId, cellId, forceDel);
731
+ const useDelValuesCallback = (storeOrStoreId, then) =>
732
+ useDel(storeOrStoreId, VALUES, then);
733
+ const useDelValueCallback = (valueId, storeOrStoreId, then) =>
734
+ useDel(storeOrStoreId, VALUE, then, valueId);
735
+ const useHasTablesListener = (listener, mutator, storeOrStoreId) =>
736
+ useListener(
737
+ HAS + TABLES,
738
+ useStoreOrStoreById(storeOrStoreId),
739
+ listener,
740
+ [],
741
+ mutator,
742
+ );
743
+ const useTablesListener = (listener, mutator, storeOrStoreId) =>
744
+ useListener(
745
+ TABLES,
746
+ useStoreOrStoreById(storeOrStoreId),
747
+ listener,
748
+ EMPTY_LISTENER_ARG_GETTERS,
749
+ mutator,
750
+ );
751
+ const useTableIdsListener = (listener, mutator, storeOrStoreId) =>
752
+ useListener(
753
+ TABLE_IDS,
754
+ useStoreOrStoreById(storeOrStoreId),
755
+ listener,
756
+ EMPTY_LISTENER_ARG_GETTERS,
757
+ mutator,
758
+ );
759
+ const useHasTableListener = (tableId, listener, mutator, storeOrStoreId) =>
760
+ useListener(
761
+ HAS + TABLE,
762
+ useStoreOrStoreById(storeOrStoreId),
763
+ listener,
764
+ [tableId],
765
+ mutator,
766
+ );
767
+ const useTableListener = (tableId, listener, mutator, storeOrStoreId) =>
768
+ useListener(
769
+ TABLE,
770
+ useStoreOrStoreById(storeOrStoreId),
771
+ listener,
772
+ [tableId],
773
+ mutator,
774
+ );
775
+ const useTableCellIdsListener = (tableId, listener, mutator, storeOrStoreId) =>
776
+ useListener(
777
+ TABLE + CELL_IDS,
778
+ useStoreOrStoreById(storeOrStoreId),
779
+ listener,
780
+ [tableId],
781
+ mutator,
782
+ );
783
+ const useHasTableCellListener = (
784
+ tableId,
785
+ cellId,
786
+ listener,
787
+ mutator,
788
+ storeOrStoreId,
789
+ ) =>
790
+ useListener(
791
+ HAS + TABLE + CELL,
792
+ useStoreOrStoreById(storeOrStoreId),
793
+ listener,
794
+ [tableId, cellId],
795
+ mutator,
796
+ );
797
+ const useRowCountListener = (tableId, listener, mutator, storeOrStoreId) =>
798
+ useListener(
799
+ ROW_COUNT,
800
+ useStoreOrStoreById(storeOrStoreId),
801
+ listener,
802
+ [tableId],
803
+ mutator,
804
+ );
805
+ const useRowIdsListener = (tableId, listener, mutator, storeOrStoreId) =>
806
+ useListener(
807
+ ROW_IDS,
808
+ useStoreOrStoreById(storeOrStoreId),
809
+ listener,
810
+ [tableId],
811
+ mutator,
812
+ );
813
+ const useSortedRowIdsListener = (
814
+ tableIdOrArgs,
815
+ cellIdOrListener,
816
+ descendingOrMutator,
817
+ offsetOrStoreOrStoreId,
818
+ limit,
819
+ listener,
820
+ mutator,
821
+ storeOrStoreId,
822
+ ) =>
823
+ isObject(tableIdOrArgs)
824
+ ? useSortedRowIdsListenerImpl(
825
+ tableIdOrArgs.tableId,
826
+ tableIdOrArgs.cellId,
827
+ tableIdOrArgs.descending ?? false,
828
+ tableIdOrArgs.offset ?? 0,
829
+ tableIdOrArgs.limit,
830
+ cellIdOrListener,
831
+ descendingOrMutator,
832
+ offsetOrStoreOrStoreId,
833
+ )
834
+ : useSortedRowIdsListenerImpl(
835
+ tableIdOrArgs,
836
+ cellIdOrListener,
837
+ descendingOrMutator ?? false,
838
+ offsetOrStoreOrStoreId ?? 0,
839
+ limit,
840
+ listener,
841
+ mutator,
842
+ storeOrStoreId,
843
+ );
844
+ const useHasRowListener = (tableId, rowId, listener, mutator, storeOrStoreId) =>
845
+ useListener(
846
+ HAS + ROW,
847
+ useStoreOrStoreById(storeOrStoreId),
848
+ listener,
849
+ [tableId, rowId],
850
+ mutator,
851
+ );
852
+ const useRowListener = (tableId, rowId, listener, mutator, storeOrStoreId) =>
853
+ useListener(
854
+ ROW,
855
+ useStoreOrStoreById(storeOrStoreId),
856
+ listener,
857
+ [tableId, rowId],
858
+ mutator,
859
+ );
860
+ const useCellIdsListener = (
861
+ tableId,
862
+ rowId,
863
+ listener,
864
+ mutator,
865
+ storeOrStoreId,
866
+ ) =>
867
+ useListener(
868
+ CELL_IDS,
869
+ useStoreOrStoreById(storeOrStoreId),
870
+ listener,
871
+ [tableId, rowId],
872
+ mutator,
873
+ );
874
+ const useHasCellListener = (
875
+ tableId,
876
+ rowId,
877
+ cellId,
878
+ listener,
879
+ mutator,
880
+ storeOrStoreId,
881
+ ) =>
882
+ useListener(
883
+ HAS + CELL,
884
+ useStoreOrStoreById(storeOrStoreId),
885
+ listener,
886
+ [tableId, rowId, cellId],
887
+ mutator,
888
+ );
889
+ const useCellListener = (
890
+ tableId,
891
+ rowId,
892
+ cellId,
893
+ listener,
894
+ mutator,
895
+ storeOrStoreId,
896
+ ) =>
897
+ useListener(
898
+ CELL,
899
+ useStoreOrStoreById(storeOrStoreId),
900
+ listener,
901
+ [tableId, rowId, cellId],
902
+ mutator,
903
+ );
904
+ const useHasValuesListener = (listener, mutator, storeOrStoreId) =>
905
+ useListener(
906
+ HAS + VALUES,
907
+ useStoreOrStoreById(storeOrStoreId),
908
+ listener,
909
+ [],
910
+ mutator,
911
+ );
912
+ const useValuesListener = (listener, mutator, storeOrStoreId) =>
913
+ useListener(
914
+ VALUES,
915
+ useStoreOrStoreById(storeOrStoreId),
916
+ listener,
917
+ EMPTY_LISTENER_ARG_GETTERS,
918
+ mutator,
919
+ );
920
+ const useValueIdsListener = (listener, mutator, storeOrStoreId) =>
921
+ useListener(
922
+ VALUE_IDS,
923
+ useStoreOrStoreById(storeOrStoreId),
924
+ listener,
925
+ EMPTY_LISTENER_ARG_GETTERS,
926
+ mutator,
927
+ );
928
+ const useHasValueListener = (valueId, listener, mutator, storeOrStoreId) =>
929
+ useListener(
930
+ HAS + VALUE,
931
+ useStoreOrStoreById(storeOrStoreId),
932
+ listener,
933
+ [valueId],
934
+ mutator,
935
+ );
936
+ const useValueListener = (valueId, listener, mutator, storeOrStoreId) =>
937
+ useListener(
938
+ VALUE,
939
+ useStoreOrStoreById(storeOrStoreId),
940
+ listener,
941
+ [valueId],
942
+ mutator,
943
+ );
944
+ const useStartTransactionListener = (listener, storeOrStoreId) =>
945
+ useListener(
946
+ 'Start' + TRANSACTION,
947
+ useStoreOrStoreById(storeOrStoreId),
948
+ listener,
949
+ );
950
+ const useWillFinishTransactionListener = (listener, storeOrStoreId) =>
951
+ useListener(
952
+ 'Will' + FINISH + TRANSACTION,
953
+ useStoreOrStoreById(storeOrStoreId),
954
+ listener,
955
+ );
956
+ const useDidFinishTransactionListener = (listener, storeOrStoreId) =>
957
+ useListener(
958
+ 'Did' + FINISH + TRANSACTION,
959
+ useStoreOrStoreById(storeOrStoreId),
960
+ listener,
961
+ );
962
+ const useCreateMetrics = (store, create) => useCreate(store, create);
963
+ const useMetricsIds = () => useThingIds(OFFSET_METRICS);
964
+ const useMetrics = (id) => useThing(id, OFFSET_METRICS);
965
+ const useMetricsOrMetricsById = (metricsOrMetricsId) =>
966
+ useThingOrThingById(metricsOrMetricsId, OFFSET_METRICS);
967
+ const useProvideMetrics = (metricsId, metrics) =>
968
+ useProvideThing(metricsId, metrics, OFFSET_METRICS);
969
+ const useMetricIds = (metricsOrMetricsId) =>
970
+ useListenable(
971
+ METRIC + IDS,
972
+ useMetricsOrMetricsById(metricsOrMetricsId),
973
+ 1 /* Array */,
974
+ );
975
+ const useMetric = (metricId, metricsOrMetricsId) =>
976
+ useListenable(
977
+ METRIC,
978
+ useMetricsOrMetricsById(metricsOrMetricsId),
979
+ 5 /* CellOrValue */,
980
+ [metricId],
981
+ );
982
+ const useMetricListener = (metricId, listener, metricsOrMetricsId) =>
983
+ useListener(METRIC, useMetricsOrMetricsById(metricsOrMetricsId), listener, [
984
+ metricId,
985
+ ]);
986
+ const useCreateIndexes = (store, create) => useCreate(store, create);
987
+ const useIndexesIds = () => useThingIds(OFFSET_INDEXES);
988
+ const useIndexes = (id) => useThing(id, OFFSET_INDEXES);
989
+ const useIndexesOrIndexesById = (indexesOrIndexesId) =>
990
+ useThingOrThingById(indexesOrIndexesId, OFFSET_INDEXES);
991
+ const useProvideIndexes = (indexesId, indexes) =>
992
+ useProvideThing(indexesId, indexes, OFFSET_INDEXES);
993
+ const useSliceIds = (indexId, indexesOrIndexesId) =>
994
+ useListenable(
995
+ SLICE + IDS,
996
+ useIndexesOrIndexesById(indexesOrIndexesId),
997
+ 1 /* Array */,
998
+ [indexId],
999
+ );
1000
+ const useIndexIds = (indexesOrIndexesId) =>
1001
+ useListenable(
1002
+ INDEX + IDS,
1003
+ useIndexesOrIndexesById(indexesOrIndexesId),
1004
+ 1 /* Array */,
1005
+ );
1006
+ const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
1007
+ useListenable(
1008
+ SLICE + ROW_IDS,
1009
+ useIndexesOrIndexesById(indexesOrIndexesId),
1010
+ 1 /* Array */,
1011
+ [indexId, sliceId],
1012
+ );
1013
+ const useSliceIdsListener = (indexId, listener, indexesOrIndexesId) =>
1014
+ useListener(
1015
+ SLICE + IDS,
1016
+ useIndexesOrIndexesById(indexesOrIndexesId),
1017
+ listener,
1018
+ [indexId],
1019
+ );
1020
+ const useSliceRowIdsListener = (
1021
+ indexId,
1022
+ sliceId,
1023
+ listener,
1024
+ indexesOrIndexesId,
1025
+ ) =>
1026
+ useListener(
1027
+ SLICE + ROW_IDS,
1028
+ useIndexesOrIndexesById(indexesOrIndexesId),
1029
+ listener,
1030
+ [indexId, sliceId],
1031
+ );
1032
+ const useCreateRelationships = (store, create) => useCreate(store, create);
1033
+ const useRelationshipsIds = () => useThingIds(OFFSET_RELATIONSHIPS);
1034
+ const useRelationships = (id) => useThing(id, OFFSET_RELATIONSHIPS);
1035
+ const useRelationshipsOrRelationshipsById = (relationshipsOrRelationshipsId) =>
1036
+ useThingOrThingById(relationshipsOrRelationshipsId, OFFSET_RELATIONSHIPS);
1037
+ const useProvideRelationships = (relationshipsId, relationships) =>
1038
+ useProvideThing(relationshipsId, relationships, OFFSET_RELATIONSHIPS);
1039
+ const useRelationshipIds = (relationshipsOrRelationshipsId) =>
1040
+ useListenable(
1041
+ RELATIONSHIP + IDS,
1042
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1043
+ 1 /* Array */,
1044
+ );
1045
+ const useRemoteRowId = (
1046
+ relationshipId,
1047
+ localRowId,
1048
+ relationshipsOrRelationshipsId,
1049
+ ) =>
1050
+ useListenable(
1051
+ REMOTE_ROW_ID,
1052
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1053
+ 5 /* CellOrValue */,
1054
+ [relationshipId, localRowId],
1055
+ );
1056
+ const useLocalRowIds = (
1057
+ relationshipId,
1058
+ remoteRowId,
1059
+ relationshipsOrRelationshipsId,
1060
+ ) =>
1061
+ useListenable(
1062
+ LOCAL + ROW_IDS,
1063
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1064
+ 1 /* Array */,
1065
+ [relationshipId, remoteRowId],
1066
+ );
1067
+ const useLinkedRowIds = (
1068
+ relationshipId,
1069
+ firstRowId,
1070
+ relationshipsOrRelationshipsId,
1071
+ ) =>
1072
+ useListenable(
1073
+ LINKED + ROW_IDS,
1074
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1075
+ 1 /* Array */,
1076
+ [relationshipId, firstRowId],
1077
+ );
1078
+ const useRemoteRowIdListener = (
1079
+ relationshipId,
1080
+ localRowId,
1081
+ listener,
1082
+ relationshipsOrRelationshipsId,
1083
+ ) =>
1084
+ useListener(
1085
+ REMOTE_ROW_ID,
1086
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1087
+ listener,
1088
+ [relationshipId, localRowId],
1089
+ );
1090
+ const useLocalRowIdsListener = (
1091
+ relationshipId,
1092
+ remoteRowId,
1093
+ listener,
1094
+ relationshipsOrRelationshipsId,
1095
+ ) =>
1096
+ useListener(
1097
+ LOCAL + ROW_IDS,
1098
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1099
+ listener,
1100
+ [relationshipId, remoteRowId],
1101
+ );
1102
+ const useLinkedRowIdsListener = (
1103
+ relationshipId,
1104
+ firstRowId,
1105
+ listener,
1106
+ relationshipsOrRelationshipsId,
1107
+ ) =>
1108
+ useListener(
1109
+ LINKED + ROW_IDS,
1110
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1111
+ listener,
1112
+ [relationshipId, firstRowId],
1113
+ );
1114
+ const useCreateQueries = (store, create) => useCreate(store, create);
1115
+ const useQueriesIds = () => useThingIds(OFFSET_QUERIES);
1116
+ const useQueries = (id) => useThing(id, OFFSET_QUERIES);
1117
+ const useQueriesOrQueriesById = (queriesOrQueriesId) =>
1118
+ useThingOrThingById(queriesOrQueriesId, OFFSET_QUERIES);
1119
+ const useProvideQueries = (queriesId, queries) =>
1120
+ useProvideThing(queriesId, queries, OFFSET_QUERIES);
1121
+ const useQueryIds = (queriesOrQueriesId) =>
1122
+ useListenable(
1123
+ QUERY + IDS,
1124
+ useQueriesOrQueriesById(queriesOrQueriesId),
1125
+ 1 /* Array */,
1126
+ );
1127
+ const useResultTable = (queryId, queriesOrQueriesId) =>
1128
+ useListenable(
1129
+ RESULT + TABLE,
1130
+ useQueriesOrQueriesById(queriesOrQueriesId),
1131
+ 0 /* Object */,
1132
+ [queryId],
1133
+ );
1134
+ const useResultTableCellIds = (queryId, queriesOrQueriesId) =>
1135
+ useListenable(
1136
+ RESULT + TABLE + CELL_IDS,
1137
+ useQueriesOrQueriesById(queriesOrQueriesId),
1138
+ 1 /* Array */,
1139
+ [queryId],
1140
+ );
1141
+ const useResultRowCount = (queryId, queriesOrQueriesId) =>
1142
+ useListenable(
1143
+ RESULT + ROW_COUNT,
1144
+ useQueriesOrQueriesById(queriesOrQueriesId),
1145
+ 7 /* Number */,
1146
+ [queryId],
1147
+ );
1148
+ const useResultRowIds = (queryId, queriesOrQueriesId) =>
1149
+ useListenable(
1150
+ RESULT + ROW_IDS,
1151
+ useQueriesOrQueriesById(queriesOrQueriesId),
1152
+ 1 /* Array */,
1153
+ [queryId],
1154
+ );
1155
+ const useResultSortedRowIds = (
1156
+ queryId,
1157
+ cellId,
1158
+ descending,
1159
+ offset = 0,
1160
+ limit,
1161
+ queriesOrQueriesId,
1162
+ ) =>
1163
+ useListenable(
1164
+ RESULT + SORTED_ROW_IDS,
1165
+ useQueriesOrQueriesById(queriesOrQueriesId),
1166
+ 1 /* Array */,
1167
+ [queryId, cellId, descending, offset, limit],
1168
+ );
1169
+ const useResultRow = (queryId, rowId, queriesOrQueriesId) =>
1170
+ useListenable(
1171
+ RESULT + ROW,
1172
+ useQueriesOrQueriesById(queriesOrQueriesId),
1173
+ 0 /* Object */,
1174
+ [queryId, rowId],
1175
+ );
1176
+ const useResultCellIds = (queryId, rowId, queriesOrQueriesId) =>
1177
+ useListenable(
1178
+ RESULT + CELL_IDS,
1179
+ useQueriesOrQueriesById(queriesOrQueriesId),
1180
+ 1 /* Array */,
1181
+ [queryId, rowId],
1182
+ );
1183
+ const useResultCell = (queryId, rowId, cellId, queriesOrQueriesId) =>
1184
+ useListenable(
1185
+ RESULT + CELL,
1186
+ useQueriesOrQueriesById(queriesOrQueriesId),
1187
+ 5 /* CellOrValue */,
1188
+ [queryId, rowId, cellId],
1189
+ );
1190
+ const useResultTableListener = (queryId, listener, queriesOrQueriesId) =>
1191
+ useListener(
1192
+ RESULT + TABLE,
1193
+ useQueriesOrQueriesById(queriesOrQueriesId),
1194
+ listener,
1195
+ [queryId],
1196
+ );
1197
+ const useResultTableCellIdsListener = (queryId, listener, queriesOrQueriesId) =>
1198
+ useListener(
1199
+ RESULT + TABLE + CELL_IDS,
1200
+ useQueriesOrQueriesById(queriesOrQueriesId),
1201
+ listener,
1202
+ [queryId],
1203
+ );
1204
+ const useResultRowCountListener = (queryId, listener, queriesOrQueriesId) =>
1205
+ useListener(
1206
+ RESULT + ROW_COUNT,
1207
+ useQueriesOrQueriesById(queriesOrQueriesId),
1208
+ listener,
1209
+ [queryId],
1210
+ );
1211
+ const useResultRowIdsListener = (queryId, listener, queriesOrQueriesId) =>
1212
+ useListener(
1213
+ RESULT + ROW_IDS,
1214
+ useQueriesOrQueriesById(queriesOrQueriesId),
1215
+ listener,
1216
+ [queryId],
1217
+ );
1218
+ const useResultSortedRowIdsListener = (
1219
+ queryId,
1220
+ cellId,
1221
+ descending,
1222
+ offset,
1223
+ limit,
1224
+ listener,
1225
+ queriesOrQueriesId,
1226
+ ) =>
1227
+ useListener(
1228
+ RESULT + SORTED_ROW_IDS,
1229
+ useQueriesOrQueriesById(queriesOrQueriesId),
1230
+ listener,
1231
+ [queryId, cellId, descending, offset, limit],
1232
+ );
1233
+ const useResultRowListener = (queryId, rowId, listener, queriesOrQueriesId) =>
1234
+ useListener(
1235
+ RESULT + ROW,
1236
+ useQueriesOrQueriesById(queriesOrQueriesId),
1237
+ listener,
1238
+ [queryId, rowId],
1239
+ );
1240
+ const useResultCellIdsListener = (
1241
+ queryId,
1242
+ rowId,
1243
+ listener,
1244
+ queriesOrQueriesId,
1245
+ ) =>
1246
+ useListener(
1247
+ RESULT + CELL_IDS,
1248
+ useQueriesOrQueriesById(queriesOrQueriesId),
1249
+ listener,
1250
+ [queryId, rowId],
1251
+ );
1252
+ const useResultCellListener = (
1253
+ queryId,
1254
+ rowId,
1255
+ cellId,
1256
+ listener,
1257
+ queriesOrQueriesId,
1258
+ ) =>
1259
+ useListener(
1260
+ RESULT + CELL,
1261
+ useQueriesOrQueriesById(queriesOrQueriesId),
1262
+ listener,
1263
+ [queryId, rowId, cellId],
1264
+ );
1265
+ const useParamValues = (queryId, queriesOrQueriesId) =>
1266
+ useListenable(
1267
+ 'ParamValues',
1268
+ useQueriesOrQueriesById(queriesOrQueriesId),
1269
+ 3 /* ParamValues */,
1270
+ [queryId],
1271
+ );
1272
+ const useParamValuesState = (queryId, queriesOrQueriesId) => [
1273
+ useParamValues(queryId, queriesOrQueriesId),
1274
+ useSetParamValuesCallback(queryId, getArg, queriesOrQueriesId),
1275
+ ];
1276
+ const useParamValue = (queryId, paramId, queriesOrQueriesId) =>
1277
+ useListenable(
1278
+ 'ParamValue',
1279
+ useQueriesOrQueriesById(queriesOrQueriesId),
1280
+ 4 /* ParamValue */,
1281
+ [queryId, paramId],
1282
+ );
1283
+ const useParamValueState = (queryId, paramId, queriesOrQueriesId) => [
1284
+ useParamValue(queryId, paramId, queriesOrQueriesId),
1285
+ useSetParamValueCallback(queryId, paramId, getArg, queriesOrQueriesId),
1286
+ ];
1287
+ const useParamValuesListener = (queryId, listener, queriesOrQueriesId) =>
1288
+ useListener(
1289
+ 'ParamValues',
1290
+ useQueriesOrQueriesById(queriesOrQueriesId),
1291
+ listener,
1292
+ [queryId],
1293
+ );
1294
+ const useParamValueListener = (
1295
+ queryId,
1296
+ paramId,
1297
+ listener,
1298
+ queriesOrQueriesId,
1299
+ ) =>
1300
+ useListener(
1301
+ 'ParamValue',
1302
+ useQueriesOrQueriesById(queriesOrQueriesId),
1303
+ listener,
1304
+ [queryId, paramId],
1305
+ );
1306
+ const useSetParamValueCallback = (
1307
+ queryId,
1308
+ paramId,
1309
+ getParamValue,
1310
+ queriesOrQueriesId,
1311
+ then,
1312
+ ) =>
1313
+ useQueriesSetCallback(
1314
+ queriesOrQueriesId,
1315
+ 'setParamValue',
1316
+ getParamValue,
1317
+ then,
1318
+ queryId,
1319
+ paramId,
1320
+ );
1321
+ const useSetParamValuesCallback = (
1322
+ queryId,
1323
+ getParamValues,
1324
+ queriesOrQueriesId,
1325
+ then,
1326
+ ) =>
1327
+ useQueriesSetCallback(
1328
+ queriesOrQueriesId,
1329
+ 'setParamValues',
1330
+ getParamValues,
1331
+ then,
1332
+ queryId,
1333
+ );
1334
+ const useCreateCheckpoints = (store, create) => useCreate(store, create);
1335
+ const useCheckpointsIds = () => useThingIds(OFFSET_CHECKPOINTS);
1336
+ const useCheckpoints = (id) => useThing(id, OFFSET_CHECKPOINTS);
1337
+ const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
1338
+ useThingOrThingById(checkpointsOrCheckpointsId, OFFSET_CHECKPOINTS);
1339
+ const useProvideCheckpoints = (checkpointsId, checkpoints) =>
1340
+ useProvideThing(checkpointsId, checkpoints, OFFSET_CHECKPOINTS);
1341
+ const useCheckpointIds = (checkpointsOrCheckpointsId) =>
1342
+ useListenable(
1343
+ CHECKPOINT + IDS,
1344
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
1345
+ 2 /* Checkpoints */,
1346
+ );
1347
+ const useCheckpoint = (checkpointId, checkpointsOrCheckpointsId) =>
1348
+ useListenable(
1349
+ CHECKPOINT,
1350
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
1351
+ 5 /* CellOrValue */,
1352
+ [checkpointId],
1353
+ );
1354
+ const useSetCheckpointCallback = (
1355
+ getCheckpoint = getUndefined,
1356
+ checkpointsOrCheckpointsId,
1357
+ then = getUndefined,
1358
+ ) => {
1359
+ const checkpoints = useCheckpointsOrCheckpointsById(
1360
+ checkpointsOrCheckpointsId,
1361
+ );
1362
+ return (parameter) =>
1363
+ ifNotUndefined(getThing(checkpoints), (resolvedCheckpoints) => {
1364
+ const label = getCheckpoint(parameter);
1365
+ then(
1366
+ resolvedCheckpoints.addCheckpoint(label),
1367
+ resolvedCheckpoints,
1368
+ label,
1369
+ );
1370
+ });
1371
+ };
1372
+ const useGoBackwardCallback = (checkpointsOrCheckpointsId) =>
1373
+ useCheckpointAction(checkpointsOrCheckpointsId, 'goBackward');
1374
+ const useGoForwardCallback = (checkpointsOrCheckpointsId) =>
1375
+ useCheckpointAction(checkpointsOrCheckpointsId, 'goForward');
1376
+ const useGoToCallback = (
1377
+ getCheckpointId,
1378
+ checkpointsOrCheckpointsId,
1379
+ then = getUndefined,
1380
+ ) => {
1381
+ const checkpoints = useCheckpointsOrCheckpointsById(
1382
+ checkpointsOrCheckpointsId,
1383
+ );
1384
+ return (parameter) =>
1385
+ ifNotUndefined(getThing(checkpoints), (resolvedCheckpoints) =>
1386
+ ifNotUndefined(getCheckpointId(parameter), (checkpointId) =>
1387
+ then(resolvedCheckpoints.goTo(checkpointId), checkpointId),
1388
+ ),
1389
+ );
1390
+ };
1391
+ const useUndoInformation = (checkpointsOrCheckpointsId) => {
1392
+ const checkpoints = useCheckpointsOrCheckpointsById(
1393
+ checkpointsOrCheckpointsId,
1394
+ );
1395
+ const [backwardIds, currentId] = getThing(useCheckpointIds(checkpoints));
1396
+ return [
1397
+ !arrayIsEmpty(backwardIds),
1398
+ useGoBackwardCallback(checkpoints),
1399
+ currentId,
1400
+ ifNotUndefined(currentId, (id) =>
1401
+ getThing(checkpoints)?.getCheckpoint(id),
1402
+ ) ?? EMPTY_STRING,
1403
+ ];
1404
+ };
1405
+ const useRedoInformation = (checkpointsOrCheckpointsId) => {
1406
+ const checkpoints = useCheckpointsOrCheckpointsById(
1407
+ checkpointsOrCheckpointsId,
1408
+ );
1409
+ const [, , [forwardId]] = getThing(useCheckpointIds(checkpoints));
1410
+ return [
1411
+ !isUndefined(forwardId),
1412
+ useGoForwardCallback(checkpoints),
1413
+ forwardId,
1414
+ ifNotUndefined(forwardId, (id) =>
1415
+ getThing(checkpoints)?.getCheckpoint(id),
1416
+ ) ?? EMPTY_STRING,
1417
+ ];
1418
+ };
1419
+ const useCheckpointIdsListener = (listener, checkpointsOrCheckpointsId) =>
1420
+ useListener(
1421
+ CHECKPOINT + IDS,
1422
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
1423
+ listener,
1424
+ );
1425
+ const useCheckpointListener = (
1426
+ checkpointId,
1427
+ listener,
1428
+ checkpointsOrCheckpointsId,
1429
+ ) =>
1430
+ useListener(
1431
+ CHECKPOINT,
1432
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
1433
+ listener,
1434
+ [checkpointId],
1435
+ );
1436
+ const useCreatePersister = (store, create, then, destroy) => {
1437
+ const [persister, setPersister] = createSignal();
1438
+ createEffect(() => {
1439
+ let current = true;
1440
+ let createdPersister;
1441
+ const destroyPersister = (persister2) => {
1442
+ persister2.destroy();
1443
+ destroy?.(persister2);
1444
+ };
1445
+ (async () => {
1446
+ const resolvedStore = getThing(store);
1447
+ createdPersister = resolvedStore ? await create(resolvedStore) : void 0;
1448
+ if (!current) {
1449
+ if (createdPersister) {
1450
+ destroyPersister(createdPersister);
1451
+ }
1452
+ return;
1453
+ }
1454
+ setPersister(() => createdPersister);
1455
+ if (createdPersister && then) {
1456
+ await then(createdPersister);
1457
+ }
1458
+ })();
1459
+ onCleanup(() => {
1460
+ current = false;
1461
+ setPersister(() => void 0);
1462
+ if (createdPersister) {
1463
+ destroyPersister(createdPersister);
1464
+ }
1465
+ });
1466
+ });
1467
+ return persister;
1468
+ };
1469
+ const usePersisterIds = () => useThingIds(OFFSET_PERSISTER);
1470
+ const usePersister = (id) => useThing(id, OFFSET_PERSISTER);
1471
+ const usePersisterOrPersisterById = (persisterOrPersisterId) =>
1472
+ useThingOrThingById(persisterOrPersisterId, OFFSET_PERSISTER);
1473
+ const useProvidePersister = (persisterId, persister) =>
1474
+ useProvideThing(persisterId, persister, OFFSET_PERSISTER);
1475
+ const usePersisterStatus = (persisterOrPersisterId) =>
1476
+ useListenable(
1477
+ STATUS,
1478
+ usePersisterOrPersisterById(persisterOrPersisterId),
1479
+ 7 /* Number */,
1480
+ [],
1481
+ );
1482
+ const usePersisterStatusListener = (listener, persisterOrPersisterId) =>
1483
+ useListener(
1484
+ STATUS,
1485
+ usePersisterOrPersisterById(persisterOrPersisterId),
1486
+ listener,
1487
+ [],
1488
+ );
1489
+ const useCreateSynchronizer = (store, create, destroy) => {
1490
+ const [synchronizer, setSynchronizer] = createSignal();
1491
+ createEffect(() => {
1492
+ let current = true;
1493
+ let createdSynchronizer;
1494
+ const destroySynchronizer = (synchronizer2) => {
1495
+ synchronizer2.destroy();
1496
+ destroy?.(synchronizer2);
1497
+ };
1498
+ (async () => {
1499
+ const resolvedStore = getThing(store);
1500
+ createdSynchronizer = resolvedStore
1501
+ ? await create(resolvedStore)
1502
+ : void 0;
1503
+ if (!current) {
1504
+ if (createdSynchronizer) {
1505
+ destroySynchronizer(createdSynchronizer);
1506
+ }
1507
+ return;
1508
+ }
1509
+ setSynchronizer(() => createdSynchronizer);
1510
+ })();
1511
+ onCleanup(() => {
1512
+ current = false;
1513
+ setSynchronizer(() => void 0);
1514
+ if (createdSynchronizer) {
1515
+ destroySynchronizer(createdSynchronizer);
1516
+ }
1517
+ });
1518
+ });
1519
+ return synchronizer;
1520
+ };
1521
+ const useSynchronizerIds = () => useThingIds(OFFSET_SYNCHRONIZER);
1522
+ const useSynchronizer = (id) => useThing(id, OFFSET_SYNCHRONIZER);
1523
+ const useSynchronizerOrSynchronizerById = (synchronizerOrSynchronizerId) =>
1524
+ useThingOrThingById(synchronizerOrSynchronizerId, OFFSET_SYNCHRONIZER);
1525
+ const useProvideSynchronizer = (persisterId, persister) =>
1526
+ useProvideThing(persisterId, persister, OFFSET_SYNCHRONIZER);
1527
+ const useSynchronizerStatus = (synchronizerOrSynchronizerId) =>
1528
+ useListenable(
1529
+ STATUS,
1530
+ useSynchronizerOrSynchronizerById(synchronizerOrSynchronizerId),
1531
+ 7 /* Number */,
1532
+ [],
1533
+ );
1534
+ const useSynchronizerStatusListener = (
1535
+ listener,
1536
+ synchronizerOrSynchronizerId,
1537
+ ) =>
1538
+ useListener(
1539
+ STATUS,
1540
+ useSynchronizerOrSynchronizerById(synchronizerOrSynchronizerId),
1541
+ listener,
1542
+ [],
1543
+ );
1544
+
1545
+ const wrap = (children, separator, encloseWithId, id) => {
1546
+ const separated =
1547
+ isUndefined(separator) || !isArray(children)
1548
+ ? children
1549
+ : arrayMap(children, (child, c) => (c > 0 ? [separator, child] : child));
1550
+ return encloseWithId ? [id, ':{', separated, '}'] : separated;
1551
+ };
1552
+
1553
+ const CheckpointView = (props) => {
1554
+ const checkpoint = useCheckpoint(
1555
+ () => props.checkpointId,
1556
+ () => props.checkpoints,
1557
+ );
1558
+ return () =>
1559
+ wrap(
1560
+ getValue(checkpoint) ?? EMPTY_STRING,
1561
+ void 0,
1562
+ props.debugIds,
1563
+ props.checkpointId,
1564
+ );
1565
+ };
1566
+
1567
+ const ResultCellView = (props) => {
1568
+ const resultCell = useResultCell(
1569
+ () => props.queryId,
1570
+ () => props.rowId,
1571
+ () => props.cellId,
1572
+ () => props.queries,
1573
+ );
1574
+ return () =>
1575
+ wrap(
1576
+ EMPTY_STRING + (getValue(resultCell) ?? EMPTY_STRING),
1577
+ void 0,
1578
+ props.debugIds,
1579
+ props.cellId,
1580
+ );
1581
+ };
1582
+
1583
+ const ResultRowView = (props) => {
1584
+ const resultCellIds = useResultCellIds(
1585
+ () => props.queryId,
1586
+ () => props.rowId,
1587
+ () => props.queries,
1588
+ );
1589
+ return () => {
1590
+ const ResultCell = props.resultCellComponent ?? ResultCellView;
1591
+ return wrap(
1592
+ arrayMap(getValue(resultCellIds), (cellId) =>
1593
+ /* @__PURE__ */ h(ResultCell, {
1594
+ ...getProps(props.getResultCellComponentProps, cellId),
1595
+ queryId: props.queryId,
1596
+ rowId: props.rowId,
1597
+ cellId,
1598
+ queries: props.queries,
1599
+ debugIds: props.debugIds,
1600
+ }),
1601
+ ),
1602
+ props.separator,
1603
+ props.debugIds,
1604
+ props.rowId,
1605
+ );
1606
+ };
1607
+ };
1608
+
1609
+ const CellView = (props) => {
1610
+ const cell = useCell(
1611
+ () => props.tableId,
1612
+ () => props.rowId,
1613
+ () => props.cellId,
1614
+ () => props.store,
1615
+ );
1616
+ return () =>
1617
+ wrap(
1618
+ EMPTY_STRING + (getValue(cell) ?? EMPTY_STRING),
1619
+ void 0,
1620
+ props.debugIds,
1621
+ props.cellId,
1622
+ );
1623
+ };
1624
+
1625
+ const useCustomOrDefaultCellIds = (customCellIds, tableId, rowId, store) => {
1626
+ const defaultCellIds = useCellIds(tableId, rowId, store);
1627
+ return () => getValue(customCellIds) ?? getValue(defaultCellIds);
1628
+ };
1629
+
1630
+ const RowView = (props) => {
1631
+ const cellIds = useCustomOrDefaultCellIds(
1632
+ () => props.customCellIds,
1633
+ () => props.tableId,
1634
+ () => props.rowId,
1635
+ () => props.store,
1636
+ );
1637
+ return () => {
1638
+ const Cell = props.cellComponent ?? CellView;
1639
+ return wrap(
1640
+ arrayMap(getValue(cellIds), (cellId) =>
1641
+ /* @__PURE__ */ h(Cell, {
1642
+ ...getProps(props.getCellComponentProps, cellId),
1643
+ tableId: props.tableId,
1644
+ rowId: props.rowId,
1645
+ cellId,
1646
+ store: props.store,
1647
+ debugIds: props.debugIds,
1648
+ }),
1649
+ ),
1650
+ props.separator,
1651
+ props.debugIds,
1652
+ props.rowId,
1653
+ );
1654
+ };
1655
+ };
1656
+
1657
+ const tableView = (props, rowIds) => {
1658
+ return () => {
1659
+ const Row = props.rowComponent ?? RowView;
1660
+ return wrap(
1661
+ arrayMap(getValue(rowIds), (rowId) =>
1662
+ /* @__PURE__ */ h(Row, {
1663
+ ...getProps(props.getRowComponentProps, rowId),
1664
+ tableId: props.tableId,
1665
+ rowId,
1666
+ customCellIds: props.customCellIds,
1667
+ store: props.store,
1668
+ debugIds: props.debugIds,
1669
+ }),
1670
+ ),
1671
+ props.separator,
1672
+ props.debugIds,
1673
+ props.tableId,
1674
+ );
1675
+ };
1676
+ };
1677
+ const resultTableView = (props, rowIds) => {
1678
+ return () => {
1679
+ const ResultRow = props.resultRowComponent ?? ResultRowView;
1680
+ return wrap(
1681
+ arrayMap(getValue(rowIds), (rowId) =>
1682
+ /* @__PURE__ */ h(ResultRow, {
1683
+ ...getProps(props.getResultRowComponentProps, rowId),
1684
+ queryId: props.queryId,
1685
+ rowId,
1686
+ queries: props.queries,
1687
+ debugIds: props.debugIds,
1688
+ }),
1689
+ ),
1690
+ props.separator,
1691
+ props.debugIds,
1692
+ props.queryId,
1693
+ );
1694
+ };
1695
+ };
1696
+ const useComponentPerRow = (props, getRowIdsHook, rowId) => {
1697
+ const resolvedRelationships = useRelationshipsOrRelationshipsById(
1698
+ () => props.relationships,
1699
+ );
1700
+ const rowIds = getRowIdsHook(
1701
+ () => props.relationshipId,
1702
+ rowId,
1703
+ resolvedRelationships,
1704
+ );
1705
+ return () => {
1706
+ const Row = props.rowComponent ?? RowView;
1707
+ const [_relationship, store, localTableId] = getRelationshipsStoreTableIds(
1708
+ getValue(resolvedRelationships),
1709
+ props.relationshipId,
1710
+ );
1711
+ return wrap(
1712
+ arrayMap(getValue(rowIds), (localRowId) =>
1713
+ /* @__PURE__ */ h(Row, {
1714
+ ...getProps(props.getRowComponentProps, localRowId),
1715
+ tableId: localTableId,
1716
+ rowId: localRowId,
1717
+ store,
1718
+ debugIds: props.debugIds,
1719
+ }),
1720
+ ),
1721
+ props.separator,
1722
+ props.debugIds,
1723
+ getValue(rowId),
1724
+ );
1725
+ };
1726
+ };
1727
+ const getUseCheckpointView = (getCheckpoints) => (props) => {
1728
+ const resolvedCheckpoints = useCheckpointsOrCheckpointsById(
1729
+ () => props.checkpoints,
1730
+ );
1731
+ const checkpointIds = useCheckpointIds(resolvedCheckpoints);
1732
+ return () => {
1733
+ const Checkpoint = props.checkpointComponent ?? CheckpointView;
1734
+ return wrap(
1735
+ arrayMap(getCheckpoints(getValue(checkpointIds)), (checkpointId) =>
1736
+ /* @__PURE__ */ h(Checkpoint, {
1737
+ ...getProps(props.getCheckpointComponentProps, checkpointId),
1738
+ checkpoints: getValue(resolvedCheckpoints),
1739
+ checkpointId,
1740
+ debugIds: props.debugIds,
1741
+ }),
1742
+ ),
1743
+ props.separator,
1744
+ );
1745
+ };
1746
+ };
1747
+
1748
+ const BackwardCheckpointsView = getUseCheckpointView(
1749
+ (checkpointIds) => checkpointIds[0],
1750
+ );
1751
+
1752
+ const CurrentCheckpointView = getUseCheckpointView((checkpointIds) =>
1753
+ isNullish(checkpointIds[1]) ? [] : [checkpointIds[1]],
1754
+ );
1755
+
1756
+ const ForwardCheckpointsView = getUseCheckpointView(
1757
+ (checkpointIds) => checkpointIds[2],
1758
+ );
1759
+
1760
+ const SliceView = (props) => {
1761
+ const resolvedIndexes = useIndexesOrIndexesById(() => props.indexes);
1762
+ const rowIds = useSliceRowIds(
1763
+ () => props.indexId,
1764
+ () => props.sliceId,
1765
+ resolvedIndexes,
1766
+ );
1767
+ return () => {
1768
+ const Row = props.rowComponent ?? RowView;
1769
+ const [_indexesValue, store, tableId] = getIndexStoreTableId(
1770
+ getValue(resolvedIndexes),
1771
+ props.indexId,
1772
+ );
1773
+ return wrap(
1774
+ arrayMap(getValue(rowIds), (rowId) =>
1775
+ /* @__PURE__ */ h(Row, {
1776
+ ...getProps(props.getRowComponentProps, rowId),
1777
+ tableId,
1778
+ rowId,
1779
+ store,
1780
+ debugIds: props.debugIds,
1781
+ }),
1782
+ ),
1783
+ props.separator,
1784
+ props.debugIds,
1785
+ props.sliceId,
1786
+ );
1787
+ };
1788
+ };
1789
+
1790
+ const IndexView = (props) => {
1791
+ const sliceIds = useSliceIds(
1792
+ () => props.indexId,
1793
+ () => props.indexes,
1794
+ );
1795
+ return () => {
1796
+ const Slice = props.sliceComponent ?? SliceView;
1797
+ return wrap(
1798
+ arrayMap(getValue(sliceIds), (sliceId) =>
1799
+ /* @__PURE__ */ h(Slice, {
1800
+ ...getProps(props.getSliceComponentProps, sliceId),
1801
+ indexId: props.indexId,
1802
+ sliceId,
1803
+ indexes: props.indexes,
1804
+ debugIds: props.debugIds,
1805
+ }),
1806
+ ),
1807
+ props.separator,
1808
+ props.debugIds,
1809
+ props.indexId,
1810
+ );
1811
+ };
1812
+ };
1813
+
1814
+ const LinkedRowsView = (props) =>
1815
+ useComponentPerRow(props, useLinkedRowIds, () => props.firstRowId);
1816
+
1817
+ const LocalRowsView = (props) =>
1818
+ useComponentPerRow(props, useLocalRowIds, () => props.remoteRowId);
1819
+
1820
+ const MetricView = (props) => {
1821
+ const metric = useMetric(
1822
+ () => props.metricId,
1823
+ () => props.metrics,
1824
+ );
1825
+ return () =>
1826
+ wrap(
1827
+ getValue(metric) ?? EMPTY_STRING,
1828
+ void 0,
1829
+ props.debugIds,
1830
+ props.metricId,
1831
+ );
1832
+ };
1833
+
1834
+ const RemoteRowView = (props) => {
1835
+ const resolvedRelationships = useRelationshipsOrRelationshipsById(
1836
+ () => props.relationships,
1837
+ );
1838
+ const rowId = useRemoteRowId(
1839
+ () => props.relationshipId,
1840
+ () => props.localRowId,
1841
+ resolvedRelationships,
1842
+ );
1843
+ return () => {
1844
+ const Row = props.rowComponent ?? RowView;
1845
+ const [_relationshipsValue, store, , remoteTableId] =
1846
+ getRelationshipsStoreTableIds(
1847
+ getValue(resolvedRelationships),
1848
+ props.relationshipId,
1849
+ );
1850
+ const remoteRowId = getValue(rowId);
1851
+ return wrap(
1852
+ isUndefined(remoteTableId) || isUndefined(remoteRowId)
1853
+ ? null
1854
+ : /* @__PURE__ */ h(Row, {
1855
+ ...getProps(props.getRowComponentProps, remoteRowId),
1856
+ tableId: remoteTableId,
1857
+ rowId: remoteRowId,
1858
+ store,
1859
+ debugIds: props.debugIds,
1860
+ }),
1861
+ void 0,
1862
+ props.debugIds,
1863
+ props.localRowId,
1864
+ );
1865
+ };
1866
+ };
1867
+
1868
+ const ResultSortedTableView = (props) =>
1869
+ resultTableView(
1870
+ props,
1871
+ useResultSortedRowIds(
1872
+ () => props.queryId,
1873
+ () => props.cellId,
1874
+ () => props.descending,
1875
+ () => props.offset,
1876
+ () => props.limit,
1877
+ () => props.queries,
1878
+ ),
1879
+ );
1880
+
1881
+ const ResultTableView = (props) =>
1882
+ resultTableView(
1883
+ props,
1884
+ useResultRowIds(
1885
+ () => props.queryId,
1886
+ () => props.queries,
1887
+ ),
1888
+ );
1889
+
1890
+ const SortedTableView = (props) =>
1891
+ tableView(
1892
+ props,
1893
+ useSortedRowIds(
1894
+ () => props.tableId,
1895
+ () => props.cellId,
1896
+ () => props.descending,
1897
+ () => props.offset,
1898
+ () => props.limit,
1899
+ () => props.store,
1900
+ ),
1901
+ );
1902
+
1903
+ const TableView = (props) =>
1904
+ tableView(
1905
+ props,
1906
+ useRowIds(
1907
+ () => props.tableId,
1908
+ () => props.store,
1909
+ ),
1910
+ );
1911
+
1912
+ const TablesView = (props) => {
1913
+ const tableIds = useTableIds(() => props.store);
1914
+ return () => {
1915
+ const Table = props.tableComponent ?? TableView;
1916
+ return wrap(
1917
+ arrayMap(getValue(tableIds), (tableId) =>
1918
+ /* @__PURE__ */ h(Table, {
1919
+ ...getProps(props.getTableComponentProps, tableId),
1920
+ tableId,
1921
+ store: props.store,
1922
+ debugIds: props.debugIds,
1923
+ }),
1924
+ ),
1925
+ props.separator,
1926
+ );
1927
+ };
1928
+ };
1929
+
1930
+ const ValueView = (props) => {
1931
+ const value = useValue(
1932
+ () => props.valueId,
1933
+ () => props.store,
1934
+ );
1935
+ return () =>
1936
+ wrap(
1937
+ EMPTY_STRING + (getValue(value) ?? EMPTY_STRING),
1938
+ void 0,
1939
+ props.debugIds,
1940
+ props.valueId,
1941
+ );
1942
+ };
1943
+
1944
+ const ValuesView = (props) => {
1945
+ const valueIds = useValueIds(() => props.store);
1946
+ return () => {
1947
+ const Value = props.valueComponent ?? ValueView;
1948
+ return wrap(
1949
+ arrayMap(getValue(valueIds), (valueId) =>
1950
+ /* @__PURE__ */ h(Value, {
1951
+ ...getProps(props.getValueComponentProps, valueId),
1952
+ valueId,
1953
+ store: props.store,
1954
+ debugIds: props.debugIds,
1955
+ }),
1956
+ ),
1957
+ props.separator,
1958
+ );
1959
+ };
1960
+ };
1961
+
1962
+ export {
1963
+ BackwardCheckpointsView,
1964
+ CellView,
1965
+ CheckpointView,
1966
+ CurrentCheckpointView,
1967
+ ForwardCheckpointsView,
1968
+ IndexView,
1969
+ LinkedRowsView,
1970
+ LocalRowsView,
1971
+ MetricView,
1972
+ OFFSET_CHECKPOINTS,
1973
+ OFFSET_INDEXES,
1974
+ OFFSET_METRICS,
1975
+ OFFSET_PERSISTER,
1976
+ OFFSET_QUERIES,
1977
+ OFFSET_RELATIONSHIPS,
1978
+ OFFSET_STORE,
1979
+ OFFSET_SYNCHRONIZER,
1980
+ Provider,
1981
+ RemoteRowView,
1982
+ ResultCellView,
1983
+ ResultRowView,
1984
+ ResultSortedTableView,
1985
+ ResultTableView,
1986
+ RowView,
1987
+ SliceView,
1988
+ SortedTableView,
1989
+ TablesView,
1990
+ TableView,
1991
+ useAddRowCallback,
1992
+ useCell,
1993
+ useCellIds,
1994
+ useCellIdsListener,
1995
+ useCellListener,
1996
+ useCellState,
1997
+ useCheckpoint,
1998
+ useCheckpointIds,
1999
+ useCheckpointIdsListener,
2000
+ useCheckpointListener,
2001
+ useCheckpoints,
2002
+ useCheckpointsIds,
2003
+ useCheckpointsOrCheckpointsById,
2004
+ useCreateCheckpoints,
2005
+ useCreateIndexes,
2006
+ useCreateMergeableStore,
2007
+ useCreateMetrics,
2008
+ useCreatePersister,
2009
+ useCreateQueries,
2010
+ useCreateRelationships,
2011
+ useCreateStore,
2012
+ useCreateSynchronizer,
2013
+ useDelCellCallback,
2014
+ useDelRowCallback,
2015
+ useDelTableCallback,
2016
+ useDelTablesCallback,
2017
+ useDelValueCallback,
2018
+ useDelValuesCallback,
2019
+ useDidFinishTransactionListener,
2020
+ useGoBackwardCallback,
2021
+ useGoForwardCallback,
2022
+ useGoToCallback,
2023
+ useHasCell,
2024
+ useHasCellListener,
2025
+ useHasRow,
2026
+ useHasRowListener,
2027
+ useHasTable,
2028
+ useHasTableCell,
2029
+ useHasTableCellListener,
2030
+ useHasTableListener,
2031
+ useHasTables,
2032
+ useHasTablesListener,
2033
+ useHasValue,
2034
+ useHasValueListener,
2035
+ useHasValues,
2036
+ useHasValuesListener,
2037
+ useIndexes,
2038
+ useIndexesIds,
2039
+ useIndexesOrIndexesById,
2040
+ useIndexIds,
2041
+ useLinkedRowIds,
2042
+ useLinkedRowIdsListener,
2043
+ useLocalRowIds,
2044
+ useLocalRowIdsListener,
2045
+ useMetric,
2046
+ useMetricIds,
2047
+ useMetricListener,
2048
+ useMetrics,
2049
+ useMetricsIds,
2050
+ useMetricsOrMetricsById,
2051
+ useParamValue,
2052
+ useParamValueListener,
2053
+ useParamValues,
2054
+ useParamValuesListener,
2055
+ useParamValuesState,
2056
+ useParamValueState,
2057
+ usePersister,
2058
+ usePersisterIds,
2059
+ usePersisterOrPersisterById,
2060
+ usePersisterStatus,
2061
+ usePersisterStatusListener,
2062
+ useProvideCheckpoints,
2063
+ useProvideIndexes,
2064
+ useProvideMetrics,
2065
+ useProvidePersister,
2066
+ useProvideQueries,
2067
+ useProvideRelationships,
2068
+ useProvideStore,
2069
+ useProvideSynchronizer,
2070
+ useQueries,
2071
+ useQueriesIds,
2072
+ useQueriesOrQueriesById,
2073
+ useQueryIds,
2074
+ useRedoInformation,
2075
+ useRelationshipIds,
2076
+ useRelationships,
2077
+ useRelationshipsIds,
2078
+ useRelationshipsOrRelationshipsById,
2079
+ useRemoteRowId,
2080
+ useRemoteRowIdListener,
2081
+ useResultCell,
2082
+ useResultCellIds,
2083
+ useResultCellIdsListener,
2084
+ useResultCellListener,
2085
+ useResultRow,
2086
+ useResultRowCount,
2087
+ useResultRowCountListener,
2088
+ useResultRowIds,
2089
+ useResultRowIdsListener,
2090
+ useResultRowListener,
2091
+ useResultSortedRowIds,
2092
+ useResultSortedRowIdsListener,
2093
+ useResultTable,
2094
+ useResultTableCellIds,
2095
+ useResultTableCellIdsListener,
2096
+ useResultTableListener,
2097
+ useRow,
2098
+ useRowCount,
2099
+ useRowCountListener,
2100
+ useRowIds,
2101
+ useRowIdsListener,
2102
+ useRowListener,
2103
+ useRowState,
2104
+ useSetCellCallback,
2105
+ useSetCheckpointCallback,
2106
+ useSetParamValueCallback,
2107
+ useSetParamValuesCallback,
2108
+ useSetPartialRowCallback,
2109
+ useSetPartialValuesCallback,
2110
+ useSetRowCallback,
2111
+ useSetTableCallback,
2112
+ useSetTablesCallback,
2113
+ useSetValueCallback,
2114
+ useSetValuesCallback,
2115
+ useSliceIds,
2116
+ useSliceIdsListener,
2117
+ useSliceRowIds,
2118
+ useSliceRowIdsListener,
2119
+ useSortedRowIds,
2120
+ useSortedRowIdsListener,
2121
+ useSortedRowIdsListenerImpl,
2122
+ useStartTransactionListener,
2123
+ useStore,
2124
+ useStoreIds,
2125
+ useStoreOrStoreById,
2126
+ useStores,
2127
+ useSynchronizer,
2128
+ useSynchronizerIds,
2129
+ useSynchronizerOrSynchronizerById,
2130
+ useSynchronizerStatus,
2131
+ useSynchronizerStatusListener,
2132
+ useTable,
2133
+ useTableCellIds,
2134
+ useTableCellIdsListener,
2135
+ useTableIds,
2136
+ useTableIdsListener,
2137
+ useTableListener,
2138
+ useTables,
2139
+ useTablesListener,
2140
+ useTablesState,
2141
+ useTableState,
2142
+ useUndoInformation,
2143
+ useValue,
2144
+ useValueIds,
2145
+ useValueIdsListener,
2146
+ useValueListener,
2147
+ useValues,
2148
+ useValuesListener,
2149
+ useValuesState,
2150
+ useValueState,
2151
+ useWillFinishTransactionListener,
2152
+ ValuesView,
2153
+ ValueView,
2154
+ };