tinybase 8.1.0-beta.1 → 8.1.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.
Files changed (124) hide show
  1. package/@types/_internal/ui/index.d.ts +0 -0
  2. package/@types/_internal/ui/with-schemas/index.d.ts +47 -0
  3. package/@types/_internal/ui-react/with-schemas/index.d.ts +9 -31
  4. package/@types/omni/index.d.ts +0 -3
  5. package/@types/omni/with-schemas/index.d.ts +0 -3
  6. package/@types/ui-react/with-schemas/index.d.ts +10 -8
  7. package/@types/ui-react-dom/with-schemas/index.d.ts +6 -4
  8. package/@types/ui-svelte/index.d.ts +1458 -222
  9. package/@types/ui-svelte/with-schemas/index.d.ts +2482 -406
  10. package/checkpoints/index.js +4 -1
  11. package/checkpoints/with-schemas/index.js +4 -1
  12. package/common/index.js +4 -1
  13. package/common/with-schemas/index.js +4 -1
  14. package/index.js +4 -1
  15. package/indexes/index.js +4 -1
  16. package/indexes/with-schemas/index.js +4 -1
  17. package/mergeable-store/index.js +4 -1
  18. package/mergeable-store/with-schemas/index.js +4 -1
  19. package/metrics/index.js +4 -1
  20. package/metrics/with-schemas/index.js +4 -1
  21. package/min/omni/index.js +1 -1
  22. package/min/omni/index.js.gz +0 -0
  23. package/min/omni/with-schemas/index.js +1 -1
  24. package/min/omni/with-schemas/index.js.gz +0 -0
  25. package/min/ui-react/index.js +1 -1
  26. package/min/ui-react/index.js.gz +0 -0
  27. package/min/ui-react/with-schemas/index.js +1 -1
  28. package/min/ui-react/with-schemas/index.js.gz +0 -0
  29. package/min/ui-svelte/index.js +1 -1
  30. package/min/ui-svelte/index.js.gz +0 -0
  31. package/min/ui-svelte/with-schemas/index.js +1 -1
  32. package/min/ui-svelte/with-schemas/index.js.gz +0 -0
  33. package/omni/index.js +11 -4739
  34. package/omni/with-schemas/index.js +11 -4739
  35. package/package.json +8 -8
  36. package/persisters/index.js +4 -1
  37. package/persisters/persister-automerge/index.js +4 -1
  38. package/persisters/persister-automerge/with-schemas/index.js +4 -1
  39. package/persisters/persister-browser/index.js +4 -1
  40. package/persisters/persister-browser/with-schemas/index.js +4 -1
  41. package/persisters/persister-cr-sqlite-wasm/index.js +4 -1
  42. package/persisters/persister-cr-sqlite-wasm/with-schemas/index.js +4 -1
  43. package/persisters/persister-durable-object-sql-storage/index.js +4 -1
  44. package/persisters/persister-durable-object-sql-storage/with-schemas/index.js +4 -1
  45. package/persisters/persister-durable-object-storage/index.js +4 -1
  46. package/persisters/persister-durable-object-storage/with-schemas/index.js +4 -1
  47. package/persisters/persister-electric-sql/index.js +4 -1
  48. package/persisters/persister-electric-sql/with-schemas/index.js +4 -1
  49. package/persisters/persister-expo-sqlite/index.js +4 -1
  50. package/persisters/persister-expo-sqlite/with-schemas/index.js +4 -1
  51. package/persisters/persister-file/index.js +4 -1
  52. package/persisters/persister-file/with-schemas/index.js +4 -1
  53. package/persisters/persister-indexed-db/index.js +4 -1
  54. package/persisters/persister-indexed-db/with-schemas/index.js +4 -1
  55. package/persisters/persister-libsql/index.js +4 -1
  56. package/persisters/persister-libsql/with-schemas/index.js +4 -1
  57. package/persisters/persister-partykit-client/index.js +4 -1
  58. package/persisters/persister-partykit-client/with-schemas/index.js +4 -1
  59. package/persisters/persister-partykit-server/index.js +4 -1
  60. package/persisters/persister-partykit-server/with-schemas/index.js +4 -1
  61. package/persisters/persister-pglite/index.js +4 -1
  62. package/persisters/persister-pglite/with-schemas/index.js +4 -1
  63. package/persisters/persister-postgres/index.js +4 -1
  64. package/persisters/persister-postgres/with-schemas/index.js +4 -1
  65. package/persisters/persister-powersync/index.js +4 -1
  66. package/persisters/persister-powersync/with-schemas/index.js +4 -1
  67. package/persisters/persister-react-native-mmkv/index.js +4 -1
  68. package/persisters/persister-react-native-mmkv/with-schemas/index.js +4 -1
  69. package/persisters/persister-react-native-sqlite/index.js +4 -1
  70. package/persisters/persister-react-native-sqlite/with-schemas/index.js +4 -1
  71. package/persisters/persister-remote/index.js +4 -1
  72. package/persisters/persister-remote/with-schemas/index.js +4 -1
  73. package/persisters/persister-sqlite-bun/index.js +4 -1
  74. package/persisters/persister-sqlite-bun/with-schemas/index.js +4 -1
  75. package/persisters/persister-sqlite-wasm/index.js +4 -1
  76. package/persisters/persister-sqlite-wasm/with-schemas/index.js +4 -1
  77. package/persisters/persister-sqlite3/index.js +4 -1
  78. package/persisters/persister-sqlite3/with-schemas/index.js +4 -1
  79. package/persisters/persister-yjs/index.js +4 -1
  80. package/persisters/persister-yjs/with-schemas/index.js +4 -1
  81. package/persisters/with-schemas/index.js +4 -1
  82. package/queries/index.js +4 -1
  83. package/queries/with-schemas/index.js +4 -1
  84. package/relationships/index.js +4 -1
  85. package/relationships/with-schemas/index.js +4 -1
  86. package/schematizers/index.js +4 -1
  87. package/schematizers/schematizer-arktype/index.js +4 -1
  88. package/schematizers/schematizer-arktype/with-schemas/index.js +4 -1
  89. package/schematizers/schematizer-effect/index.js +4 -1
  90. package/schematizers/schematizer-effect/with-schemas/index.js +4 -1
  91. package/schematizers/schematizer-typebox/index.js +4 -1
  92. package/schematizers/schematizer-typebox/with-schemas/index.js +4 -1
  93. package/schematizers/schematizer-valibot/index.js +4 -1
  94. package/schematizers/schematizer-valibot/with-schemas/index.js +4 -1
  95. package/schematizers/schematizer-yup/index.js +4 -1
  96. package/schematizers/schematizer-yup/with-schemas/index.js +4 -1
  97. package/schematizers/schematizer-zod/index.js +4 -1
  98. package/schematizers/schematizer-zod/with-schemas/index.js +4 -1
  99. package/schematizers/with-schemas/index.js +4 -1
  100. package/store/index.js +4 -1
  101. package/store/with-schemas/index.js +4 -1
  102. package/synchronizers/index.js +4 -1
  103. package/synchronizers/synchronizer-broadcast-channel/index.js +4 -1
  104. package/synchronizers/synchronizer-broadcast-channel/with-schemas/index.js +4 -1
  105. package/synchronizers/synchronizer-local/index.js +4 -1
  106. package/synchronizers/synchronizer-local/with-schemas/index.js +4 -1
  107. package/synchronizers/synchronizer-ws-client/index.js +4 -1
  108. package/synchronizers/synchronizer-ws-client/with-schemas/index.js +4 -1
  109. package/synchronizers/synchronizer-ws-server/index.js +4 -1
  110. package/synchronizers/synchronizer-ws-server/with-schemas/index.js +4 -1
  111. package/synchronizers/synchronizer-ws-server-durable-object/index.js +4 -1
  112. package/synchronizers/synchronizer-ws-server-durable-object/with-schemas/index.js +4 -1
  113. package/synchronizers/synchronizer-ws-server-simple/index.js +4 -1
  114. package/synchronizers/synchronizer-ws-server-simple/with-schemas/index.js +4 -1
  115. package/synchronizers/with-schemas/index.js +4 -1
  116. package/ui-react/index.js +100 -100
  117. package/ui-react/with-schemas/index.js +100 -100
  118. package/ui-react-dom/index.js +4 -1
  119. package/ui-react-dom/with-schemas/index.js +4 -1
  120. package/ui-react-inspector/index.js +4 -1
  121. package/ui-react-inspector/with-schemas/index.js +4 -1
  122. package/ui-svelte/index.js +1016 -347
  123. package/ui-svelte/with-schemas/index.js +1002 -333
  124. package/with-schemas/index.js +4 -1
@@ -1,4 +1,4 @@
1
- import {getContext, setContext} from 'svelte';
1
+ import {getContext, setContext, untrack} from 'svelte';
2
2
  import * as $ from 'svelte/internal/client';
3
3
  import 'svelte/internal/disclose-version';
4
4
 
@@ -6,6 +6,7 @@ const getTypeOf = (thing) => typeof thing;
6
6
  const TINYBASE = 'tinybase';
7
7
  const EMPTY_STRING = '';
8
8
  const STRING = getTypeOf(EMPTY_STRING);
9
+ const FUNCTION = getTypeOf(getTypeOf);
9
10
  const LISTENER = 'Listener';
10
11
  const RESULT = 'Result';
11
12
  const GET = 'get';
@@ -25,6 +26,8 @@ const CELL_IDS = CELL + IDS;
25
26
  const VALUE = 'Value';
26
27
  const VALUES = VALUE + 's';
27
28
  const VALUE_IDS = VALUE + IDS;
29
+ const TRANSACTION = 'Transaction';
30
+ const FINISH = 'Finish';
28
31
  const STATUS = 'Status';
29
32
  const METRIC = 'Metric';
30
33
  const INDEX = 'Index';
@@ -37,10 +40,14 @@ const QUERY = 'Query';
37
40
  const CHECKPOINT = 'Checkpoint';
38
41
 
39
42
  const getIfNotFunction = (predicate) => (value, then, otherwise) =>
40
- predicate(value) ? otherwise?.() : then(value);
43
+ predicate(value)
44
+ ? /* istanbul ignore next */
45
+ otherwise?.()
46
+ : then(value);
41
47
  const isUndefined = (thing) => thing === void 0;
42
48
  const ifNotUndefined = getIfNotFunction(isUndefined);
43
49
  const isString = (thing) => getTypeOf(thing) == STRING;
50
+ const isFunction = (thing) => getTypeOf(thing) == FUNCTION;
44
51
 
45
52
  const object = Object;
46
53
  const objIds = object.keys;
@@ -48,12 +55,11 @@ const objGet = (obj, id) => ifNotUndefined(obj, (obj2) => obj2[id]);
48
55
 
49
56
  const TINYBASE_CONTEXT_KEY = TINYBASE + '_uisc';
50
57
 
51
- /* hooks.svelte.ts generated by Svelte v5.53.8 */
58
+ /* hooks.svelte.ts generated by Svelte v5.53.11 */
52
59
 
53
60
  const EMPTY_ARR = [];
54
61
  const EMPTY_OBJ = {};
55
62
  const DEFAULT_CHECKPOINT_IDS = [EMPTY_ARR, void 0, EMPTY_ARR];
56
- const rv = (v) => (typeof v === 'function' ? v() : v);
57
63
  const OFFSET_STORE = 0;
58
64
  const OFFSET_METRICS = 1;
59
65
  const OFFSET_INDEXES = 2;
@@ -62,63 +68,72 @@ const OFFSET_QUERIES = 4;
62
68
  const OFFSET_CHECKPOINTS = 5;
63
69
  const OFFSET_PERSISTER = 6;
64
70
  const OFFSET_SYNCHRONIZER = 7;
65
- const getCtx = () => getContext(TINYBASE_CONTEXT_KEY) ?? [];
71
+ const maybeGet = (thing) => (isFunction(thing) ? thing() : thing);
72
+ const getContextValue = () => getContext(TINYBASE_CONTEXT_KEY) ?? [];
66
73
 
67
- const resolveWithCtx = (ctx, thingOrId, offset) => {
68
- if (!isUndefined(thingOrId) && !isString(thingOrId)) return thingOrId;
74
+ const getThing = (contextValue, thingOrThingId, offset) =>
75
+ isUndefined(thingOrThingId)
76
+ ? contextValue[offset * 2]
77
+ : isString(thingOrThingId)
78
+ ? objGet(contextValue[offset * 2 + 1], thingOrThingId)
79
+ : thingOrThingId;
69
80
 
70
- return isUndefined(thingOrId)
71
- ? ctx[offset * 2]
72
- : objGet(ctx[offset * 2 + 1], thingOrId);
73
- };
74
-
75
- const resolveByOffset = (thingOrId, offset) =>
76
- resolveWithCtx(getCtx(), thingOrId, offset);
81
+ const useThing = (thingOrThingId, offset) =>
82
+ getThing(getContextValue(), thingOrThingId, offset);
77
83
 
78
- const mkGetter = (offset, thingOrId) => {
79
- const ctx = getCtx();
84
+ const useThingOrThingById = (thingOrThingId, offset) => {
85
+ const contextValue = getContextValue();
80
86
 
81
- return () =>
82
- resolveWithCtx(
83
- ctx,
84
- typeof thingOrId === 'function' ? thingOrId() : thingOrId,
85
- offset,
86
- );
87
+ return () => getThing(contextValue, maybeGet(thingOrThingId), offset);
87
88
  };
88
89
 
89
- const getThingIds = (ctx, offset) => objIds(ctx[offset * 2 + 1] ?? EMPTY_OBJ);
90
- const sg = (s) => mkGetter(OFFSET_STORE, s);
91
- const mg = (m) => mkGetter(OFFSET_METRICS, m);
92
- const ig = (i) => mkGetter(OFFSET_INDEXES, i);
93
- const rg = (r) => mkGetter(OFFSET_RELATIONSHIPS, r);
94
- const qg = (q) => mkGetter(OFFSET_QUERIES, q);
95
- const cg = (c) => mkGetter(OFFSET_CHECKPOINTS, c);
96
- const pg = (p) => mkGetter(OFFSET_PERSISTER, p);
97
- const syg = (sy) => mkGetter(OFFSET_SYNCHRONIZER, sy);
90
+ const getThingIds = (contextValue, offset) =>
91
+ objIds(contextValue[offset * 2 + 1] ?? EMPTY_OBJ);
92
+
93
+ const useStoreOrStoreById = (storeOrStoreId) =>
94
+ useThingOrThingById(storeOrStoreId, OFFSET_STORE);
95
+ const useMetricsOrMetricsById = (metricsOrMetricsId) =>
96
+ useThingOrThingById(metricsOrMetricsId, OFFSET_METRICS);
97
+ const useIndexesOrIndexesById = (indexesOrIndexesId) =>
98
+ useThingOrThingById(indexesOrIndexesId, OFFSET_INDEXES);
99
+ const useRelationshipsOrRelationshipsById = (relationshipsOrRelationshipsId) =>
100
+ useThingOrThingById(relationshipsOrRelationshipsId, OFFSET_RELATIONSHIPS);
101
+ const useQueriesOrQueriesById = (queriesOrQueriesId) =>
102
+ useThingOrThingById(queriesOrQueriesId, OFFSET_QUERIES);
103
+ const useCheckpointsOrCheckpointsById = (checkpointsOrCheckpointsId) =>
104
+ useThingOrThingById(checkpointsOrCheckpointsId, OFFSET_CHECKPOINTS);
105
+ const usePersisterOrPersisterById = (persisterOrPersisterId) =>
106
+ useThingOrThingById(persisterOrPersisterId, OFFSET_PERSISTER);
107
+ const useSynchronizerOrSynchronizerById = (synchronizerOrSynchronizerId) =>
108
+ useThingOrThingById(synchronizerOrSynchronizerId, OFFSET_SYNCHRONIZER);
98
109
 
99
110
  const useListenable = (
100
- getThing,
101
- getMethod,
102
- addMethod,
111
+ getThing2,
112
+ listenable,
103
113
  defaultValue,
104
- getArgs,
114
+ getArgs = () => EMPTY_ARR,
115
+ isHas,
105
116
  ) => {
117
+ const getMethod = (isHas ? _HAS : GET) + listenable;
118
+ const addMethod = ADD + (isHas ? HAS : '') + listenable + LISTENER;
106
119
  let value = $.state(
107
- $.proxy(getThing()?.[getMethod]?.(...getArgs()) ?? defaultValue),
120
+ $.proxy(getThing2()?.[getMethod]?.(...getArgs()) ?? defaultValue),
108
121
  );
109
122
 
110
- $.user_effect(() => {
111
- const thing = getThing();
112
- const args = getArgs();
123
+ if (typeof window !== 'undefined') {
124
+ $.user_effect(() => {
125
+ const thing = getThing2();
126
+ const args = getArgs();
113
127
 
114
- $.set(value, thing?.[getMethod]?.(...args) ?? defaultValue, true);
128
+ $.set(value, thing?.[getMethod]?.(...args) ?? defaultValue, true);
115
129
 
116
- const listenerId = thing?.[addMethod]?.(...args, () => {
117
- $.set(value, thing[getMethod](...getArgs()) ?? defaultValue, true);
118
- });
130
+ const listenerId = thing?.[addMethod]?.(...args, () => {
131
+ $.set(value, thing[getMethod](...getArgs()) ?? defaultValue, true);
132
+ });
119
133
 
120
- return () => thing?.delListener?.(listenerId);
121
- });
134
+ return () => thing?.delListener?.(listenerId);
135
+ });
136
+ }
122
137
 
123
138
  return {
124
139
  get current() {
@@ -127,46 +142,75 @@ const useListenable = (
127
142
  };
128
143
  };
129
144
 
130
- const useGet = (
131
- getThing,
145
+ const useListener = (
146
+ getThing2,
132
147
  listenable,
133
- defaultValue,
134
- getArgs = () => EMPTY_ARR,
135
- ) =>
136
- useListenable(
137
- getThing,
138
- GET + listenable,
139
- ADD + listenable + LISTENER,
140
- defaultValue,
141
- getArgs,
142
- );
148
+ listener,
149
+ getPreArgs = () => EMPTY_ARR,
150
+ mutator,
151
+ ) => {
152
+ if (typeof window !== 'undefined') {
153
+ $.user_effect(() => {
154
+ const thing = getThing2();
155
+ const preArgs = getPreArgs();
156
+ const listenerId = thing?.[ADD + listenable + LISTENER]?.(
157
+ ...preArgs,
158
+ listener,
159
+ ...(mutator !== void 0 ? [mutator] : EMPTY_ARR),
160
+ );
161
+
162
+ return () => thing?.delListener?.(listenerId);
163
+ });
164
+ }
165
+ };
143
166
 
144
- const useHas = (getThing, listenable, getArgs = () => EMPTY_ARR) =>
167
+ const useHasTables = (storeOrStoreId) =>
145
168
  useListenable(
146
- getThing,
147
- _HAS + listenable,
148
- ADD + HAS + listenable + LISTENER,
169
+ useStoreOrStoreById(storeOrStoreId),
170
+ TABLES,
149
171
  false,
150
- getArgs,
172
+ () => EMPTY_ARR,
173
+ 1,
151
174
  );
152
-
153
- const useHasTables = (storeOrStoreId) => useHas(sg(storeOrStoreId), TABLES);
154
175
  const useTables = (storeOrStoreId) =>
155
- useGet(sg(storeOrStoreId), TABLES, EMPTY_OBJ);
176
+ useListenable(useStoreOrStoreById(storeOrStoreId), TABLES, EMPTY_OBJ);
156
177
  const useTableIds = (storeOrStoreId) =>
157
- useGet(sg(storeOrStoreId), TABLE_IDS, EMPTY_ARR);
178
+ useListenable(useStoreOrStoreById(storeOrStoreId), TABLE_IDS, EMPTY_ARR);
158
179
  const useHasTable = (tableId, storeOrStoreId) =>
159
- useHas(sg(storeOrStoreId), TABLE, () => [rv(tableId)]);
180
+ useListenable(
181
+ useStoreOrStoreById(storeOrStoreId),
182
+ TABLE,
183
+ false,
184
+ () => [maybeGet(tableId)],
185
+ 1,
186
+ );
160
187
  const useTable = (tableId, storeOrStoreId) =>
161
- useGet(sg(storeOrStoreId), TABLE, EMPTY_OBJ, () => [rv(tableId)]);
188
+ useListenable(useStoreOrStoreById(storeOrStoreId), TABLE, EMPTY_OBJ, () => [
189
+ maybeGet(tableId),
190
+ ]);
162
191
  const useTableCellIds = (tableId, storeOrStoreId) =>
163
- useGet(sg(storeOrStoreId), TABLE + CELL_IDS, EMPTY_ARR, () => [rv(tableId)]);
192
+ useListenable(
193
+ useStoreOrStoreById(storeOrStoreId),
194
+ TABLE + CELL_IDS,
195
+ EMPTY_ARR,
196
+ () => [maybeGet(tableId)],
197
+ );
164
198
  const useHasTableCell = (tableId, cellId, storeOrStoreId) =>
165
- useHas(sg(storeOrStoreId), TABLE + CELL, () => [rv(tableId), rv(cellId)]);
199
+ useListenable(
200
+ useStoreOrStoreById(storeOrStoreId),
201
+ TABLE + CELL,
202
+ false,
203
+ () => [maybeGet(tableId), maybeGet(cellId)],
204
+ 1,
205
+ );
166
206
  const useRowCount = (tableId, storeOrStoreId) =>
167
- useGet(sg(storeOrStoreId), ROW_COUNT, 0, () => [rv(tableId)]);
207
+ useListenable(useStoreOrStoreById(storeOrStoreId), ROW_COUNT, 0, () => [
208
+ maybeGet(tableId),
209
+ ]);
168
210
  const useRowIds = (tableId, storeOrStoreId) =>
169
- useGet(sg(storeOrStoreId), ROW_IDS, EMPTY_ARR, () => [rv(tableId)]);
211
+ useListenable(useStoreOrStoreById(storeOrStoreId), ROW_IDS, EMPTY_ARR, () => [
212
+ maybeGet(tableId),
213
+ ]);
170
214
 
171
215
  const useSortedRowIds = (
172
216
  tableId,
@@ -176,53 +220,83 @@ const useSortedRowIds = (
176
220
  limit,
177
221
  storeOrStoreId,
178
222
  ) =>
179
- useGet(sg(storeOrStoreId), SORTED_ROW_IDS, EMPTY_ARR, () => [
180
- rv(tableId),
181
- rv(cellId),
182
- rv(descending),
183
- rv(offset),
184
- rv(limit),
185
- ]);
223
+ useListenable(
224
+ useStoreOrStoreById(storeOrStoreId),
225
+ SORTED_ROW_IDS,
226
+ EMPTY_ARR,
227
+ () => [
228
+ maybeGet(tableId),
229
+ maybeGet(cellId),
230
+ maybeGet(descending),
231
+ maybeGet(offset),
232
+ maybeGet(limit),
233
+ ],
234
+ );
186
235
 
187
236
  const useHasRow = (tableId, rowId, storeOrStoreId) =>
188
- useHas(sg(storeOrStoreId), ROW, () => [rv(tableId), rv(rowId)]);
237
+ useListenable(
238
+ useStoreOrStoreById(storeOrStoreId),
239
+ ROW,
240
+ false,
241
+ () => [maybeGet(tableId), maybeGet(rowId)],
242
+ 1,
243
+ );
189
244
  const useRow = (tableId, rowId, storeOrStoreId) =>
190
- useGet(sg(storeOrStoreId), ROW, EMPTY_OBJ, () => [rv(tableId), rv(rowId)]);
191
- const useCellIds = (tableId, rowId, storeOrStoreId) =>
192
- useGet(sg(storeOrStoreId), CELL_IDS, EMPTY_ARR, () => [
193
- rv(tableId),
194
- rv(rowId),
245
+ useListenable(useStoreOrStoreById(storeOrStoreId), ROW, EMPTY_OBJ, () => [
246
+ maybeGet(tableId),
247
+ maybeGet(rowId),
195
248
  ]);
249
+ const useCellIds = (tableId, rowId, storeOrStoreId) =>
250
+ useListenable(
251
+ useStoreOrStoreById(storeOrStoreId),
252
+ CELL_IDS,
253
+ EMPTY_ARR,
254
+ () => [maybeGet(tableId), maybeGet(rowId)],
255
+ );
196
256
  const useHasCell = (tableId, rowId, cellId, storeOrStoreId) =>
197
- useHas(sg(storeOrStoreId), CELL, () => [rv(tableId), rv(rowId), rv(cellId)]);
257
+ useListenable(
258
+ useStoreOrStoreById(storeOrStoreId),
259
+ CELL,
260
+ false,
261
+ () => [maybeGet(tableId), maybeGet(rowId), maybeGet(cellId)],
262
+ 1,
263
+ );
198
264
  const useCell = (tableId, rowId, cellId, storeOrStoreId) =>
199
- useGet(sg(storeOrStoreId), CELL, void 0, () => [
200
- rv(tableId),
201
- rv(rowId),
202
- rv(cellId),
265
+ useListenable(useStoreOrStoreById(storeOrStoreId), CELL, void 0, () => [
266
+ maybeGet(tableId),
267
+ maybeGet(rowId),
268
+ maybeGet(cellId),
203
269
  ]);
204
270
 
205
- const useCellState = (tableId, rowId, cellId, storeOrStoreId) => {
206
- const getS = sg(storeOrStoreId);
271
+ const useBindableCell = (tableId, rowId, cellId, storeOrStoreId) => {
272
+ const getS = useStoreOrStoreById(storeOrStoreId);
207
273
  let value = $.state(
208
- $.proxy(getS()?.getCell(rv(tableId), rv(rowId), rv(cellId))),
274
+ $.proxy(
275
+ getS()?.getCell(maybeGet(tableId), maybeGet(rowId), maybeGet(cellId)),
276
+ ),
209
277
  );
210
278
 
211
- $.user_effect(() => {
212
- const s = getS();
279
+ if (typeof window !== 'undefined') {
280
+ $.user_effect(() => {
281
+ const s = getS();
213
282
 
214
- const t = rv(tableId),
215
- r = rv(rowId),
216
- c = rv(cellId);
283
+ const t = maybeGet(tableId),
284
+ r = maybeGet(rowId),
285
+ c = maybeGet(cellId);
217
286
 
218
- $.set(value, s?.getCell(t, r, c), true);
287
+ $.set(value, s?.getCell(t, r, c), true);
219
288
 
220
- const listenerId = s?.addCellListener(t, r, c, (st) => {
221
- $.set(value, st.getCell(rv(tableId), rv(rowId), rv(cellId)), true);
222
- });
289
+ const listenerId = s?.addCellListener(t, r, c, (st) => {
290
+ $.set(
291
+ value,
292
+ st.getCell(maybeGet(tableId), maybeGet(rowId), maybeGet(cellId)),
293
+ true,
294
+ );
295
+ });
223
296
 
224
- return () => s?.delListener?.(listenerId);
225
- });
297
+ return () => s?.delListener?.(listenerId);
298
+ });
299
+ }
226
300
 
227
301
  return {
228
302
  get current() {
@@ -230,37 +304,54 @@ const useCellState = (tableId, rowId, cellId, storeOrStoreId) => {
230
304
  },
231
305
 
232
306
  set current(v) {
233
- getS()?.setCell(rv(tableId), rv(rowId), rv(cellId), v);
307
+ getS()?.setCell(maybeGet(tableId), maybeGet(rowId), maybeGet(cellId), v);
234
308
  },
235
309
  };
236
310
  };
237
311
 
238
- const useHasValues = (storeOrStoreId) => useHas(sg(storeOrStoreId), VALUES);
312
+ const useHasValues = (storeOrStoreId) =>
313
+ useListenable(
314
+ useStoreOrStoreById(storeOrStoreId),
315
+ VALUES,
316
+ false,
317
+ () => EMPTY_ARR,
318
+ 1,
319
+ );
239
320
  const useValues = (storeOrStoreId) =>
240
- useGet(sg(storeOrStoreId), VALUES, EMPTY_OBJ);
321
+ useListenable(useStoreOrStoreById(storeOrStoreId), VALUES, EMPTY_OBJ);
241
322
  const useValueIds = (storeOrStoreId) =>
242
- useGet(sg(storeOrStoreId), VALUE_IDS, EMPTY_ARR);
323
+ useListenable(useStoreOrStoreById(storeOrStoreId), VALUE_IDS, EMPTY_ARR);
243
324
  const useHasValue = (valueId, storeOrStoreId) =>
244
- useHas(sg(storeOrStoreId), VALUE, () => [rv(valueId)]);
325
+ useListenable(
326
+ useStoreOrStoreById(storeOrStoreId),
327
+ VALUE,
328
+ false,
329
+ () => [maybeGet(valueId)],
330
+ 1,
331
+ );
245
332
  const useValue = (valueId, storeOrStoreId) =>
246
- useGet(sg(storeOrStoreId), VALUE, void 0, () => [rv(valueId)]);
333
+ useListenable(useStoreOrStoreById(storeOrStoreId), VALUE, void 0, () => [
334
+ maybeGet(valueId),
335
+ ]);
247
336
 
248
- const useValueState = (valueId, storeOrStoreId) => {
249
- const getS = sg(storeOrStoreId);
250
- let value = $.state($.proxy(getS()?.getValue(rv(valueId))));
337
+ const useBindableValue = (valueId, storeOrStoreId) => {
338
+ const getS = useStoreOrStoreById(storeOrStoreId);
339
+ let value = $.state($.proxy(getS()?.getValue(maybeGet(valueId))));
251
340
 
252
- $.user_effect(() => {
253
- const s = getS();
254
- const vid = rv(valueId);
341
+ if (typeof window !== 'undefined') {
342
+ $.user_effect(() => {
343
+ const s = getS();
344
+ const vid = maybeGet(valueId);
255
345
 
256
- $.set(value, s?.getValue(vid), true);
346
+ $.set(value, s?.getValue(vid), true);
257
347
 
258
- const listenerId = s?.addValueListener(vid, (st) => {
259
- $.set(value, st.getValue(rv(valueId)), true);
260
- });
348
+ const listenerId = s?.addValueListener(vid, (st) => {
349
+ $.set(value, st.getValue(maybeGet(valueId)), true);
350
+ });
261
351
 
262
- return () => s?.delListener?.(listenerId);
263
- });
352
+ return () => s?.delListener?.(listenerId);
353
+ });
354
+ }
264
355
 
265
356
  return {
266
357
  get current() {
@@ -268,20 +359,22 @@ const useValueState = (valueId, storeOrStoreId) => {
268
359
  },
269
360
 
270
361
  set current(v) {
271
- getS()?.setValue(rv(valueId), v);
362
+ getS()?.setValue(maybeGet(valueId), v);
272
363
  },
273
364
  };
274
365
  };
275
366
 
276
- const useStore = (id) => resolveByOffset(id, OFFSET_STORE);
367
+ const useStore = (id) => useThing(id, OFFSET_STORE);
277
368
 
278
369
  const useStoreIds = () => {
279
- const ctx = getCtx();
280
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_STORE)));
370
+ const contextValue = getContextValue();
371
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_STORE)));
281
372
 
282
- $.user_effect(() => {
283
- $.set(ids, getThingIds(ctx, OFFSET_STORE), true);
284
- });
373
+ if (typeof window !== 'undefined') {
374
+ $.user_effect(() => {
375
+ $.set(ids, getThingIds(contextValue, OFFSET_STORE), true);
376
+ });
377
+ }
285
378
 
286
379
  return {
287
380
  get current() {
@@ -290,15 +383,17 @@ const useStoreIds = () => {
290
383
  };
291
384
  };
292
385
 
293
- const useMetrics = (id) => resolveByOffset(id, OFFSET_METRICS);
386
+ const useMetrics = (id) => useThing(id, OFFSET_METRICS);
294
387
 
295
388
  const useMetricsIds = () => {
296
- const ctx = getCtx();
297
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_METRICS)));
389
+ const contextValue = getContextValue();
390
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_METRICS)));
298
391
 
299
- $.user_effect(() => {
300
- $.set(ids, getThingIds(ctx, OFFSET_METRICS), true);
301
- });
392
+ if (typeof window !== 'undefined') {
393
+ $.user_effect(() => {
394
+ $.set(ids, getThingIds(contextValue, OFFSET_METRICS), true);
395
+ });
396
+ }
302
397
 
303
398
  return {
304
399
  get current() {
@@ -308,18 +403,29 @@ const useMetricsIds = () => {
308
403
  };
309
404
 
310
405
  const useMetricIds = (metricsOrMetricsId) =>
311
- useGet(mg(metricsOrMetricsId), METRIC + IDS, EMPTY_ARR);
406
+ useListenable(
407
+ useMetricsOrMetricsById(metricsOrMetricsId),
408
+ METRIC + IDS,
409
+ EMPTY_ARR,
410
+ );
312
411
  const useMetric = (metricId, metricsOrMetricsId) =>
313
- useGet(mg(metricsOrMetricsId), METRIC, void 0, () => [rv(metricId)]);
314
- const useIndexes = (id) => resolveByOffset(id, OFFSET_INDEXES);
412
+ useListenable(
413
+ useMetricsOrMetricsById(metricsOrMetricsId),
414
+ METRIC,
415
+ void 0,
416
+ () => [maybeGet(metricId)],
417
+ );
418
+ const useIndexes = (id) => useThing(id, OFFSET_INDEXES);
315
419
 
316
420
  const useIndexesIds = () => {
317
- const ctx = getCtx();
318
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_INDEXES)));
421
+ const contextValue = getContextValue();
422
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_INDEXES)));
319
423
 
320
- $.user_effect(() => {
321
- $.set(ids, getThingIds(ctx, OFFSET_INDEXES), true);
322
- });
424
+ if (typeof window !== 'undefined') {
425
+ $.user_effect(() => {
426
+ $.set(ids, getThingIds(contextValue, OFFSET_INDEXES), true);
427
+ });
428
+ }
323
429
 
324
430
  return {
325
431
  get current() {
@@ -329,23 +435,51 @@ const useIndexesIds = () => {
329
435
  };
330
436
 
331
437
  const useIndexIds = (indexesOrIndexesId) =>
332
- useGet(ig(indexesOrIndexesId), INDEX + IDS, EMPTY_ARR);
438
+ useListenable(
439
+ useIndexesOrIndexesById(indexesOrIndexesId),
440
+ INDEX + IDS,
441
+ EMPTY_ARR,
442
+ );
333
443
  const useSliceIds = (indexId, indexesOrIndexesId) =>
334
- useGet(ig(indexesOrIndexesId), SLICE + IDS, EMPTY_ARR, () => [rv(indexId)]);
444
+ useListenable(
445
+ useIndexesOrIndexesById(indexesOrIndexesId),
446
+ SLICE + IDS,
447
+ EMPTY_ARR,
448
+ () => [maybeGet(indexId)],
449
+ );
335
450
  const useSliceRowIds = (indexId, sliceId, indexesOrIndexesId) =>
336
- useGet(ig(indexesOrIndexesId), SLICE + ROW_IDS, EMPTY_ARR, () => [
337
- rv(indexId),
338
- rv(sliceId),
339
- ]);
340
- const useQueries = (id) => resolveByOffset(id, OFFSET_QUERIES);
451
+ useListenable(
452
+ useIndexesOrIndexesById(indexesOrIndexesId),
453
+ SLICE + ROW_IDS,
454
+ EMPTY_ARR,
455
+ () => [maybeGet(indexId), maybeGet(sliceId)],
456
+ );
457
+
458
+ const useIndexStoreTableId = (indexesOrId, indexId) => {
459
+ const getI = useIndexesOrIndexesById(indexesOrId);
460
+
461
+ return {
462
+ get store() {
463
+ return getI()?.getStore();
464
+ },
465
+
466
+ get tableId() {
467
+ return getI()?.getTableId(maybeGet(indexId));
468
+ },
469
+ };
470
+ };
471
+
472
+ const useQueries = (id) => useThing(id, OFFSET_QUERIES);
341
473
 
342
474
  const useQueriesIds = () => {
343
- const ctx = getCtx();
344
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_QUERIES)));
475
+ const contextValue = getContextValue();
476
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_QUERIES)));
345
477
 
346
- $.user_effect(() => {
347
- $.set(ids, getThingIds(ctx, OFFSET_QUERIES), true);
348
- });
478
+ if (typeof window !== 'undefined') {
479
+ $.user_effect(() => {
480
+ $.set(ids, getThingIds(contextValue, OFFSET_QUERIES), true);
481
+ });
482
+ }
349
483
 
350
484
  return {
351
485
  get current() {
@@ -355,21 +489,39 @@ const useQueriesIds = () => {
355
489
  };
356
490
 
357
491
  const useQueryIds = (queriesOrQueriesId) =>
358
- useGet(qg(queriesOrQueriesId), QUERY + IDS, EMPTY_ARR);
492
+ useListenable(
493
+ useQueriesOrQueriesById(queriesOrQueriesId),
494
+ QUERY + IDS,
495
+ EMPTY_ARR,
496
+ );
359
497
  const useResultTable = (queryId, queriesOrQueriesId) =>
360
- useGet(qg(queriesOrQueriesId), RESULT + TABLE, EMPTY_OBJ, () => [
361
- rv(queryId),
362
- ]);
498
+ useListenable(
499
+ useQueriesOrQueriesById(queriesOrQueriesId),
500
+ RESULT + TABLE,
501
+ EMPTY_OBJ,
502
+ () => [maybeGet(queryId)],
503
+ );
363
504
  const useResultTableCellIds = (queryId, queriesOrQueriesId) =>
364
- useGet(qg(queriesOrQueriesId), RESULT + TABLE + CELL_IDS, EMPTY_ARR, () => [
365
- rv(queryId),
366
- ]);
505
+ useListenable(
506
+ useQueriesOrQueriesById(queriesOrQueriesId),
507
+ RESULT + TABLE + CELL_IDS,
508
+ EMPTY_ARR,
509
+ () => [maybeGet(queryId)],
510
+ );
367
511
  const useResultRowCount = (queryId, queriesOrQueriesId) =>
368
- useGet(qg(queriesOrQueriesId), RESULT + ROW_COUNT, 0, () => [rv(queryId)]);
512
+ useListenable(
513
+ useQueriesOrQueriesById(queriesOrQueriesId),
514
+ RESULT + ROW_COUNT,
515
+ 0,
516
+ () => [maybeGet(queryId)],
517
+ );
369
518
  const useResultRowIds = (queryId, queriesOrQueriesId) =>
370
- useGet(qg(queriesOrQueriesId), RESULT + ROW_IDS, EMPTY_ARR, () => [
371
- rv(queryId),
372
- ]);
519
+ useListenable(
520
+ useQueriesOrQueriesById(queriesOrQueriesId),
521
+ RESULT + ROW_IDS,
522
+ EMPTY_ARR,
523
+ () => [maybeGet(queryId)],
524
+ );
373
525
 
374
526
  const useResultSortedRowIds = (
375
527
  queryId,
@@ -379,39 +531,51 @@ const useResultSortedRowIds = (
379
531
  limit,
380
532
  queriesOrQueriesId,
381
533
  ) =>
382
- useGet(qg(queriesOrQueriesId), RESULT + SORTED_ROW_IDS, EMPTY_ARR, () => [
383
- rv(queryId),
384
- rv(cellId),
385
- rv(descending),
386
- rv(offset),
387
- rv(limit),
388
- ]);
534
+ useListenable(
535
+ useQueriesOrQueriesById(queriesOrQueriesId),
536
+ RESULT + SORTED_ROW_IDS,
537
+ EMPTY_ARR,
538
+ () => [
539
+ maybeGet(queryId),
540
+ maybeGet(cellId),
541
+ maybeGet(descending),
542
+ maybeGet(offset),
543
+ maybeGet(limit),
544
+ ],
545
+ );
389
546
 
390
547
  const useResultRow = (queryId, rowId, queriesOrQueriesId) =>
391
- useGet(qg(queriesOrQueriesId), RESULT + ROW, EMPTY_OBJ, () => [
392
- rv(queryId),
393
- rv(rowId),
394
- ]);
548
+ useListenable(
549
+ useQueriesOrQueriesById(queriesOrQueriesId),
550
+ RESULT + ROW,
551
+ EMPTY_OBJ,
552
+ () => [maybeGet(queryId), maybeGet(rowId)],
553
+ );
395
554
  const useResultCellIds = (queryId, rowId, queriesOrQueriesId) =>
396
- useGet(qg(queriesOrQueriesId), RESULT + CELL_IDS, EMPTY_ARR, () => [
397
- rv(queryId),
398
- rv(rowId),
399
- ]);
555
+ useListenable(
556
+ useQueriesOrQueriesById(queriesOrQueriesId),
557
+ RESULT + CELL_IDS,
558
+ EMPTY_ARR,
559
+ () => [maybeGet(queryId), maybeGet(rowId)],
560
+ );
400
561
  const useResultCell = (queryId, rowId, cellId, queriesOrQueriesId) =>
401
- useGet(qg(queriesOrQueriesId), RESULT + CELL, void 0, () => [
402
- rv(queryId),
403
- rv(rowId),
404
- rv(cellId),
405
- ]);
406
- const useRelationships = (id) => resolveByOffset(id, OFFSET_RELATIONSHIPS);
562
+ useListenable(
563
+ useQueriesOrQueriesById(queriesOrQueriesId),
564
+ RESULT + CELL,
565
+ void 0,
566
+ () => [maybeGet(queryId), maybeGet(rowId), maybeGet(cellId)],
567
+ );
568
+ const useRelationships = (id) => useThing(id, OFFSET_RELATIONSHIPS);
407
569
 
408
570
  const useRelationshipsIds = () => {
409
- const ctx = getCtx();
410
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_RELATIONSHIPS)));
571
+ const contextValue = getContextValue();
572
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_RELATIONSHIPS)));
411
573
 
412
- $.user_effect(() => {
413
- $.set(ids, getThingIds(ctx, OFFSET_RELATIONSHIPS), true);
414
- });
574
+ if (typeof window !== 'undefined') {
575
+ $.user_effect(() => {
576
+ $.set(ids, getThingIds(contextValue, OFFSET_RELATIONSHIPS), true);
577
+ });
578
+ }
415
579
 
416
580
  return {
417
581
  get current() {
@@ -421,45 +585,74 @@ const useRelationshipsIds = () => {
421
585
  };
422
586
 
423
587
  const useRelationshipIds = (relationshipsOrRelationshipsId) =>
424
- useGet(rg(relationshipsOrRelationshipsId), RELATIONSHIP + IDS, EMPTY_ARR);
588
+ useListenable(
589
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
590
+ RELATIONSHIP + IDS,
591
+ EMPTY_ARR,
592
+ );
425
593
  const useRemoteRowId = (
426
594
  relationshipId,
427
595
  localRowId,
428
596
  relationshipsOrRelationshipsId,
429
597
  ) =>
430
- useGet(rg(relationshipsOrRelationshipsId), REMOTE_ROW_ID, void 0, () => [
431
- rv(relationshipId),
432
- rv(localRowId),
433
- ]);
598
+ useListenable(
599
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
600
+ REMOTE_ROW_ID,
601
+ void 0,
602
+ () => [maybeGet(relationshipId), maybeGet(localRowId)],
603
+ );
434
604
  const useLocalRowIds = (
435
605
  relationshipId,
436
606
  remoteRowId,
437
607
  relationshipsOrRelationshipsId,
438
608
  ) =>
439
- useGet(rg(relationshipsOrRelationshipsId), LOCAL + ROW_IDS, EMPTY_ARR, () => [
440
- rv(relationshipId),
441
- rv(remoteRowId),
442
- ]);
609
+ useListenable(
610
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
611
+ LOCAL + ROW_IDS,
612
+ EMPTY_ARR,
613
+ () => [maybeGet(relationshipId), maybeGet(remoteRowId)],
614
+ );
443
615
  const useLinkedRowIds = (
444
616
  relationshipId,
445
617
  firstRowId,
446
618
  relationshipsOrRelationshipsId,
447
619
  ) =>
448
- useGet(
449
- rg(relationshipsOrRelationshipsId),
620
+ useListenable(
621
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
450
622
  LINKED + ROW_IDS,
451
623
  EMPTY_ARR,
452
- () => [rv(relationshipId), rv(firstRowId)],
624
+ () => [maybeGet(relationshipId), maybeGet(firstRowId)],
453
625
  );
454
- const useCheckpoints = (id) => resolveByOffset(id, OFFSET_CHECKPOINTS);
626
+
627
+ const useRelationshipsStoreTableIds = (relationshipsOrId, relationshipId) => {
628
+ const getR = useRelationshipsOrRelationshipsById(relationshipsOrId);
629
+
630
+ return {
631
+ get store() {
632
+ return getR()?.getStore();
633
+ },
634
+
635
+ get localTableId() {
636
+ return getR()?.getLocalTableId(maybeGet(relationshipId));
637
+ },
638
+
639
+ get remoteTableId() {
640
+ return getR()?.getRemoteTableId(maybeGet(relationshipId));
641
+ },
642
+ };
643
+ };
644
+
645
+ const useCheckpoints = (id) => useThing(id, OFFSET_CHECKPOINTS);
455
646
 
456
647
  const useCheckpointsIds = () => {
457
- const ctx = getCtx();
458
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_CHECKPOINTS)));
648
+ const contextValue = getContextValue();
649
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_CHECKPOINTS)));
459
650
 
460
- $.user_effect(() => {
461
- $.set(ids, getThingIds(ctx, OFFSET_CHECKPOINTS), true);
462
- });
651
+ if (typeof window !== 'undefined') {
652
+ $.user_effect(() => {
653
+ $.set(ids, getThingIds(contextValue, OFFSET_CHECKPOINTS), true);
654
+ });
655
+ }
463
656
 
464
657
  return {
465
658
  get current() {
@@ -469,37 +662,42 @@ const useCheckpointsIds = () => {
469
662
  };
470
663
 
471
664
  const useCheckpointIds = (checkpointsOrCheckpointsId) =>
472
- useGet(
473
- cg(checkpointsOrCheckpointsId),
665
+ useListenable(
666
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
474
667
  CHECKPOINT + IDS,
475
668
  DEFAULT_CHECKPOINT_IDS,
476
669
  );
477
670
  const useCheckpoint = (checkpointId, checkpointsOrCheckpointsId) =>
478
- useGet(cg(checkpointsOrCheckpointsId), CHECKPOINT, void 0, () => [
479
- rv(checkpointId),
480
- ]);
671
+ useListenable(
672
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
673
+ CHECKPOINT,
674
+ void 0,
675
+ () => [maybeGet(checkpointId)],
676
+ );
481
677
 
482
678
  const useGoBackwardCallback = (checkpointsOrCheckpointsId) => {
483
- const getC = cg(checkpointsOrCheckpointsId);
679
+ const getC = useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId);
484
680
 
485
681
  return () => getC()?.goBackward();
486
682
  };
487
683
 
488
684
  const useGoForwardCallback = (checkpointsOrCheckpointsId) => {
489
- const getC = cg(checkpointsOrCheckpointsId);
685
+ const getC = useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId);
490
686
 
491
687
  return () => getC()?.goForward();
492
688
  };
493
689
 
494
- const usePersister = (id) => resolveByOffset(id, OFFSET_PERSISTER);
690
+ const usePersister = (id) => useThing(id, OFFSET_PERSISTER);
495
691
 
496
692
  const usePersisterIds = () => {
497
- const ctx = getCtx();
498
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_PERSISTER)));
693
+ const contextValue = getContextValue();
694
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_PERSISTER)));
499
695
 
500
- $.user_effect(() => {
501
- $.set(ids, getThingIds(ctx, OFFSET_PERSISTER), true);
502
- });
696
+ if (typeof window !== 'undefined') {
697
+ $.user_effect(() => {
698
+ $.set(ids, getThingIds(contextValue, OFFSET_PERSISTER), true);
699
+ });
700
+ }
503
701
 
504
702
  return {
505
703
  get current() {
@@ -509,16 +707,18 @@ const usePersisterIds = () => {
509
707
  };
510
708
 
511
709
  const usePersisterStatus = (persisterOrPersisterId) =>
512
- useGet(pg(persisterOrPersisterId), STATUS, 0);
513
- const useSynchronizer = (id) => resolveByOffset(id, OFFSET_SYNCHRONIZER);
710
+ useListenable(usePersisterOrPersisterById(persisterOrPersisterId), STATUS, 0);
711
+ const useSynchronizer = (id) => useThing(id, OFFSET_SYNCHRONIZER);
514
712
 
515
713
  const useSynchronizerIds = () => {
516
- const ctx = getCtx();
517
- let ids = $.state($.proxy(getThingIds(ctx, OFFSET_SYNCHRONIZER)));
714
+ const contextValue = getContextValue();
715
+ let ids = $.state($.proxy(getThingIds(contextValue, OFFSET_SYNCHRONIZER)));
518
716
 
519
- $.user_effect(() => {
520
- $.set(ids, getThingIds(ctx, OFFSET_SYNCHRONIZER), true);
521
- });
717
+ if (typeof window !== 'undefined') {
718
+ $.user_effect(() => {
719
+ $.set(ids, getThingIds(contextValue, OFFSET_SYNCHRONIZER), true);
720
+ });
721
+ }
522
722
 
523
723
  return {
524
724
  get current() {
@@ -528,34 +728,461 @@ const useSynchronizerIds = () => {
528
728
  };
529
729
 
530
730
  const useSynchronizerStatus = (synchronizerOrSynchronizerId) =>
531
- useGet(syg(synchronizerOrSynchronizerId), STATUS, 0);
731
+ useListenable(
732
+ useSynchronizerOrSynchronizerById(synchronizerOrSynchronizerId),
733
+ STATUS,
734
+ 0,
735
+ );
736
+ const useHasTablesListener = (listener, mutator, storeOrStoreId) =>
737
+ useListener(
738
+ useStoreOrStoreById(storeOrStoreId),
739
+ HAS + TABLES,
740
+ listener,
741
+ () => EMPTY_ARR,
742
+ mutator,
743
+ );
744
+ const useTablesListener = (listener, mutator, storeOrStoreId) =>
745
+ useListener(
746
+ useStoreOrStoreById(storeOrStoreId),
747
+ TABLES,
748
+ listener,
749
+ () => EMPTY_ARR,
750
+ mutator,
751
+ );
752
+ const useTableIdsListener = (listener, mutator, storeOrStoreId) =>
753
+ useListener(
754
+ useStoreOrStoreById(storeOrStoreId),
755
+ TABLE_IDS,
756
+ listener,
757
+ () => EMPTY_ARR,
758
+ mutator,
759
+ );
760
+ const useHasTableListener = (tableId, listener, mutator, storeOrStoreId) =>
761
+ useListener(
762
+ useStoreOrStoreById(storeOrStoreId),
763
+ HAS + TABLE,
764
+ listener,
765
+ () => [maybeGet(tableId)],
766
+ mutator,
767
+ );
768
+ const useTableListener = (tableId, listener, mutator, storeOrStoreId) =>
769
+ useListener(
770
+ useStoreOrStoreById(storeOrStoreId),
771
+ TABLE,
772
+ listener,
773
+ () => [maybeGet(tableId)],
774
+ mutator,
775
+ );
776
+ const useTableCellIdsListener = (tableId, listener, mutator, storeOrStoreId) =>
777
+ useListener(
778
+ useStoreOrStoreById(storeOrStoreId),
779
+ TABLE + CELL_IDS,
780
+ listener,
781
+ () => [maybeGet(tableId)],
782
+ mutator,
783
+ );
784
+ const useHasTableCellListener = (
785
+ tableId,
786
+ cellId,
787
+ listener,
788
+ mutator,
789
+ storeOrStoreId,
790
+ ) =>
791
+ useListener(
792
+ useStoreOrStoreById(storeOrStoreId),
793
+ HAS + TABLE + CELL,
794
+ listener,
795
+ () => [maybeGet(tableId), maybeGet(cellId)],
796
+ mutator,
797
+ );
798
+ const useRowCountListener = (tableId, listener, mutator, storeOrStoreId) =>
799
+ useListener(
800
+ useStoreOrStoreById(storeOrStoreId),
801
+ ROW_COUNT,
802
+ listener,
803
+ () => [maybeGet(tableId)],
804
+ mutator,
805
+ );
806
+ const useRowIdsListener = (tableId, listener, mutator, storeOrStoreId) =>
807
+ useListener(
808
+ useStoreOrStoreById(storeOrStoreId),
809
+ ROW_IDS,
810
+ listener,
811
+ () => [maybeGet(tableId)],
812
+ mutator,
813
+ );
814
+
815
+ const useSortedRowIdsListener = (
816
+ tableId,
817
+ cellId,
818
+ descending,
819
+ offset,
820
+ limit,
821
+ listener,
822
+ mutator,
823
+ storeOrStoreId,
824
+ ) =>
825
+ useListener(
826
+ useStoreOrStoreById(storeOrStoreId),
827
+ SORTED_ROW_IDS,
828
+ listener,
829
+ () => [
830
+ maybeGet(tableId),
831
+ maybeGet(cellId),
832
+ maybeGet(descending),
833
+ maybeGet(offset),
834
+ maybeGet(limit),
835
+ ],
836
+ mutator,
837
+ );
838
+
839
+ const useHasRowListener = (tableId, rowId, listener, mutator, storeOrStoreId) =>
840
+ useListener(
841
+ useStoreOrStoreById(storeOrStoreId),
842
+ HAS + ROW,
843
+ listener,
844
+ () => [maybeGet(tableId), maybeGet(rowId)],
845
+ mutator,
846
+ );
847
+ const useRowListener = (tableId, rowId, listener, mutator, storeOrStoreId) =>
848
+ useListener(
849
+ useStoreOrStoreById(storeOrStoreId),
850
+ ROW,
851
+ listener,
852
+ () => [maybeGet(tableId), maybeGet(rowId)],
853
+ mutator,
854
+ );
855
+ const useCellIdsListener = (
856
+ tableId,
857
+ rowId,
858
+ listener,
859
+ mutator,
860
+ storeOrStoreId,
861
+ ) =>
862
+ useListener(
863
+ useStoreOrStoreById(storeOrStoreId),
864
+ CELL_IDS,
865
+ listener,
866
+ () => [maybeGet(tableId), maybeGet(rowId)],
867
+ mutator,
868
+ );
869
+ const useHasCellListener = (
870
+ tableId,
871
+ rowId,
872
+ cellId,
873
+ listener,
874
+ mutator,
875
+ storeOrStoreId,
876
+ ) =>
877
+ useListener(
878
+ useStoreOrStoreById(storeOrStoreId),
879
+ HAS + CELL,
880
+ listener,
881
+ () => [maybeGet(tableId), maybeGet(rowId), maybeGet(cellId)],
882
+ mutator,
883
+ );
884
+ const useCellListener = (
885
+ tableId,
886
+ rowId,
887
+ cellId,
888
+ listener,
889
+ mutator,
890
+ storeOrStoreId,
891
+ ) =>
892
+ useListener(
893
+ useStoreOrStoreById(storeOrStoreId),
894
+ CELL,
895
+ listener,
896
+ () => [maybeGet(tableId), maybeGet(rowId), maybeGet(cellId)],
897
+ mutator,
898
+ );
899
+ const useHasValuesListener = (listener, mutator, storeOrStoreId) =>
900
+ useListener(
901
+ useStoreOrStoreById(storeOrStoreId),
902
+ HAS + VALUES,
903
+ listener,
904
+ () => EMPTY_ARR,
905
+ mutator,
906
+ );
907
+ const useValuesListener = (listener, mutator, storeOrStoreId) =>
908
+ useListener(
909
+ useStoreOrStoreById(storeOrStoreId),
910
+ VALUES,
911
+ listener,
912
+ () => EMPTY_ARR,
913
+ mutator,
914
+ );
915
+ const useValueIdsListener = (listener, mutator, storeOrStoreId) =>
916
+ useListener(
917
+ useStoreOrStoreById(storeOrStoreId),
918
+ VALUE_IDS,
919
+ listener,
920
+ () => EMPTY_ARR,
921
+ mutator,
922
+ );
923
+ const useHasValueListener = (valueId, listener, mutator, storeOrStoreId) =>
924
+ useListener(
925
+ useStoreOrStoreById(storeOrStoreId),
926
+ HAS + VALUE,
927
+ listener,
928
+ () => [maybeGet(valueId)],
929
+ mutator,
930
+ );
931
+ const useValueListener = (valueId, listener, mutator, storeOrStoreId) =>
932
+ useListener(
933
+ useStoreOrStoreById(storeOrStoreId),
934
+ VALUE,
935
+ listener,
936
+ () => [maybeGet(valueId)],
937
+ mutator,
938
+ );
939
+ const useStartTransactionListener = (listener, storeOrStoreId) =>
940
+ useListener(
941
+ useStoreOrStoreById(storeOrStoreId),
942
+ 'Start' + TRANSACTION,
943
+ listener,
944
+ );
945
+ const useWillFinishTransactionListener = (listener, storeOrStoreId) =>
946
+ useListener(
947
+ useStoreOrStoreById(storeOrStoreId),
948
+ 'Will' + FINISH + TRANSACTION,
949
+ listener,
950
+ );
951
+ const useDidFinishTransactionListener = (listener, storeOrStoreId) =>
952
+ useListener(
953
+ useStoreOrStoreById(storeOrStoreId),
954
+ 'Did' + FINISH + TRANSACTION,
955
+ listener,
956
+ );
957
+ const useMetricListener = (metricId, listener, metricsOrMetricsId) =>
958
+ useListener(
959
+ useMetricsOrMetricsById(metricsOrMetricsId),
960
+ METRIC,
961
+ listener,
962
+ () => [maybeGet(metricId)],
963
+ );
964
+ const useSliceIdsListener = (indexId, listener, indexesOrIndexesId) =>
965
+ useListener(
966
+ useIndexesOrIndexesById(indexesOrIndexesId),
967
+ SLICE + IDS,
968
+ listener,
969
+ () => [maybeGet(indexId)],
970
+ );
971
+ const useSliceRowIdsListener = (
972
+ indexId,
973
+ sliceId,
974
+ listener,
975
+ indexesOrIndexesId,
976
+ ) =>
977
+ useListener(
978
+ useIndexesOrIndexesById(indexesOrIndexesId),
979
+ SLICE + ROW_IDS,
980
+ listener,
981
+ () => [maybeGet(indexId), maybeGet(sliceId)],
982
+ );
983
+
984
+ const useRemoteRowIdListener = (
985
+ relationshipId,
986
+ localRowId,
987
+ listener,
988
+ relationshipsOrRelationshipsId,
989
+ ) =>
990
+ useListener(
991
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
992
+ REMOTE_ROW_ID,
993
+ listener,
994
+ () => [maybeGet(relationshipId), maybeGet(localRowId)],
995
+ );
996
+
997
+ const useLocalRowIdsListener = (
998
+ relationshipId,
999
+ remoteRowId,
1000
+ listener,
1001
+ relationshipsOrRelationshipsId,
1002
+ ) =>
1003
+ useListener(
1004
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1005
+ LOCAL + ROW_IDS,
1006
+ listener,
1007
+ () => [maybeGet(relationshipId), maybeGet(remoteRowId)],
1008
+ );
532
1009
 
533
- const injectThing = (offset, id, thing) => {
534
- const ctx = getCtx();
1010
+ const useLinkedRowIdsListener = (
1011
+ relationshipId,
1012
+ firstRowId,
1013
+ listener,
1014
+ relationshipsOrRelationshipsId,
1015
+ ) =>
1016
+ useListener(
1017
+ useRelationshipsOrRelationshipsById(relationshipsOrRelationshipsId),
1018
+ LINKED + ROW_IDS,
1019
+ listener,
1020
+ () => [maybeGet(relationshipId), maybeGet(firstRowId)],
1021
+ );
535
1022
 
536
- $.user_effect(() => {
537
- ctx[16]?.(offset, id, thing);
1023
+ const useResultTableListener = (queryId, listener, queriesOrQueriesId) =>
1024
+ useListener(
1025
+ useQueriesOrQueriesById(queriesOrQueriesId),
1026
+ RESULT + TABLE,
1027
+ listener,
1028
+ () => [maybeGet(queryId)],
1029
+ );
1030
+ const useResultTableCellIdsListener = (queryId, listener, queriesOrQueriesId) =>
1031
+ useListener(
1032
+ useQueriesOrQueriesById(queriesOrQueriesId),
1033
+ RESULT + TABLE + CELL_IDS,
1034
+ listener,
1035
+ () => [maybeGet(queryId)],
1036
+ );
1037
+ const useResultRowCountListener = (queryId, listener, queriesOrQueriesId) =>
1038
+ useListener(
1039
+ useQueriesOrQueriesById(queriesOrQueriesId),
1040
+ RESULT + ROW_COUNT,
1041
+ listener,
1042
+ () => [maybeGet(queryId)],
1043
+ );
1044
+ const useResultRowIdsListener = (queryId, listener, queriesOrQueriesId) =>
1045
+ useListener(
1046
+ useQueriesOrQueriesById(queriesOrQueriesId),
1047
+ RESULT + ROW_IDS,
1048
+ listener,
1049
+ () => [maybeGet(queryId)],
1050
+ );
1051
+
1052
+ const useResultSortedRowIdsListener = (
1053
+ queryId,
1054
+ cellId,
1055
+ descending,
1056
+ offset,
1057
+ limit,
1058
+ listener,
1059
+ queriesOrQueriesId,
1060
+ ) =>
1061
+ useListener(
1062
+ useQueriesOrQueriesById(queriesOrQueriesId),
1063
+ RESULT + SORTED_ROW_IDS,
1064
+ listener,
1065
+ () => [
1066
+ maybeGet(queryId),
1067
+ maybeGet(cellId),
1068
+ maybeGet(descending),
1069
+ maybeGet(offset),
1070
+ maybeGet(limit),
1071
+ ],
1072
+ );
538
1073
 
539
- return () => ctx[17]?.(offset, id);
540
- });
1074
+ const useResultRowListener = (queryId, rowId, listener, queriesOrQueriesId) =>
1075
+ useListener(
1076
+ useQueriesOrQueriesById(queriesOrQueriesId),
1077
+ RESULT + ROW,
1078
+ listener,
1079
+ () => [maybeGet(queryId), maybeGet(rowId)],
1080
+ );
1081
+ const useResultCellIdsListener = (
1082
+ queryId,
1083
+ rowId,
1084
+ listener,
1085
+ queriesOrQueriesId,
1086
+ ) =>
1087
+ useListener(
1088
+ useQueriesOrQueriesById(queriesOrQueriesId),
1089
+ RESULT + CELL_IDS,
1090
+ listener,
1091
+ () => [maybeGet(queryId), maybeGet(rowId)],
1092
+ );
1093
+ const useResultCellListener = (
1094
+ queryId,
1095
+ rowId,
1096
+ cellId,
1097
+ listener,
1098
+ queriesOrQueriesId,
1099
+ ) =>
1100
+ useListener(
1101
+ useQueriesOrQueriesById(queriesOrQueriesId),
1102
+ RESULT + CELL,
1103
+ listener,
1104
+ () => [maybeGet(queryId), maybeGet(rowId), maybeGet(cellId)],
1105
+ );
1106
+ const useParamValuesListener = (queryId, listener, queriesOrQueriesId) =>
1107
+ useListener(
1108
+ useQueriesOrQueriesById(queriesOrQueriesId),
1109
+ 'ParamValues',
1110
+ listener,
1111
+ () => [maybeGet(queryId)],
1112
+ );
1113
+ const useParamValueListener = (
1114
+ queryId,
1115
+ paramId,
1116
+ listener,
1117
+ queriesOrQueriesId,
1118
+ ) =>
1119
+ useListener(
1120
+ useQueriesOrQueriesById(queriesOrQueriesId),
1121
+ 'ParamValue',
1122
+ listener,
1123
+ () => [maybeGet(queryId), maybeGet(paramId)],
1124
+ );
1125
+ const useCheckpointIdsListener = (listener, checkpointsOrCheckpointsId) =>
1126
+ useListener(
1127
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
1128
+ CHECKPOINT + IDS,
1129
+ listener,
1130
+ );
1131
+ const useCheckpointListener = (
1132
+ checkpointId,
1133
+ listener,
1134
+ checkpointsOrCheckpointsId,
1135
+ ) =>
1136
+ useListener(
1137
+ useCheckpointsOrCheckpointsById(checkpointsOrCheckpointsId),
1138
+ CHECKPOINT,
1139
+ listener,
1140
+ () => [maybeGet(checkpointId)],
1141
+ );
1142
+ const usePersisterStatusListener = (listener, persisterOrPersisterId) =>
1143
+ useListener(
1144
+ usePersisterOrPersisterById(persisterOrPersisterId),
1145
+ STATUS,
1146
+ listener,
1147
+ );
1148
+ const useSynchronizerStatusListener = (
1149
+ listener,
1150
+ synchronizerOrSynchronizerId,
1151
+ ) =>
1152
+ useListener(
1153
+ useSynchronizerOrSynchronizerById(synchronizerOrSynchronizerId),
1154
+ STATUS,
1155
+ listener,
1156
+ );
1157
+
1158
+ const provideThing = (thingId, thing, offset) => {
1159
+ const contextValue = getContextValue();
1160
+
1161
+ if (typeof window !== 'undefined') {
1162
+ $.user_effect(() => {
1163
+ contextValue[16]?.(offset, thingId, thing);
1164
+
1165
+ return () => contextValue[17]?.(offset, thingId);
1166
+ });
1167
+ }
541
1168
  };
542
1169
 
543
1170
  const provideStore = (storeId, store) =>
544
- injectThing(OFFSET_STORE, storeId, store);
1171
+ provideThing(storeId, store, OFFSET_STORE);
545
1172
  const provideMetrics = (metricsId, metrics) =>
546
- injectThing(OFFSET_METRICS, metricsId, metrics);
1173
+ provideThing(metricsId, metrics, OFFSET_METRICS);
547
1174
  const provideIndexes = (indexesId, indexes) =>
548
- injectThing(OFFSET_INDEXES, indexesId, indexes);
1175
+ provideThing(indexesId, indexes, OFFSET_INDEXES);
549
1176
  const provideRelationships = (relationshipsId, relationships) =>
550
- injectThing(OFFSET_RELATIONSHIPS, relationshipsId, relationships);
1177
+ provideThing(relationshipsId, relationships, OFFSET_RELATIONSHIPS);
551
1178
  const provideQueries = (queriesId, queries) =>
552
- injectThing(OFFSET_QUERIES, queriesId, queries);
1179
+ provideThing(queriesId, queries, OFFSET_QUERIES);
553
1180
  const provideCheckpoints = (checkpointsId, checkpoints) =>
554
- injectThing(OFFSET_CHECKPOINTS, checkpointsId, checkpoints);
1181
+ provideThing(checkpointsId, checkpoints, OFFSET_CHECKPOINTS);
555
1182
  const providePersister = (persisterId, persister) =>
556
- injectThing(OFFSET_PERSISTER, persisterId, persister);
1183
+ provideThing(persisterId, persister, OFFSET_PERSISTER);
557
1184
  const provideSynchronizer = (synchronizerId, synchronizer) =>
558
- injectThing(OFFSET_SYNCHRONIZER, synchronizerId, synchronizer);
1185
+ provideThing(synchronizerId, synchronizer, OFFSET_SYNCHRONIZER);
559
1186
 
560
1187
  function CheckpointView($$anchor, $$props) {
561
1188
  $.push($$props, true);
@@ -584,7 +1211,9 @@ function CheckpointView($$anchor, $$props) {
584
1211
  var root_2 = $.from_html(`<!><!>`, 1);
585
1212
  var root$1 = $.from_html(`<!><!><!>`, 1);
586
1213
 
587
- function ItemsView($$anchor, $$props) {
1214
+ function Wrap($$anchor, $$props) {
1215
+ $.push($$props, true);
1216
+
588
1217
  var fragment = root$1();
589
1218
  var node = $.first_child(fragment);
590
1219
 
@@ -596,8 +1225,10 @@ function ItemsView($$anchor, $$props) {
596
1225
  $.append($$anchor, text);
597
1226
  };
598
1227
 
1228
+ var d = $.derived(() => $$props.debugIds && !isUndefined($$props.id));
1229
+
599
1230
  $.if(node, ($$render) => {
600
- if ($$props.debugIds && $$props.id !== undefined) $$render(consequent);
1231
+ if ($.get(d)) $$render(consequent);
601
1232
  });
602
1233
  }
603
1234
 
@@ -605,9 +1236,9 @@ function ItemsView($$anchor, $$props) {
605
1236
 
606
1237
  $.each(
607
1238
  node_1,
608
- 17,
1239
+ 18,
609
1240
  () => $$props.ids,
610
- $.index,
1241
+ (itemId) => itemId,
611
1242
  ($$anchor, itemId, i) => {
612
1243
  var fragment_2 = root_2();
613
1244
  var node_2 = $.first_child(fragment_2);
@@ -622,7 +1253,7 @@ function ItemsView($$anchor, $$props) {
622
1253
  };
623
1254
 
624
1255
  $.if(node_2, ($$render) => {
625
- if (i > 0 && $$props.separator) $$render(consequent_1);
1256
+ if ($.get(i) > 0 && $$props.separator) $$render(consequent_1);
626
1257
  });
627
1258
  }
628
1259
 
@@ -636,7 +1267,7 @@ function ItemsView($$anchor, $$props) {
636
1267
  $.snippet(
637
1268
  node_5,
638
1269
  () => $$props.custom,
639
- () => $.get(itemId),
1270
+ () => itemId,
640
1271
  );
641
1272
  $.append($$anchor, fragment_4);
642
1273
  };
@@ -648,7 +1279,7 @@ function ItemsView($$anchor, $$props) {
648
1279
  $.snippet(
649
1280
  node_6,
650
1281
  () => $$props.children,
651
- () => $.get(itemId),
1282
+ () => itemId,
652
1283
  );
653
1284
  $.append($$anchor, fragment_5);
654
1285
  };
@@ -673,12 +1304,15 @@ function ItemsView($$anchor, $$props) {
673
1304
  $.append($$anchor, text_1);
674
1305
  };
675
1306
 
1307
+ var d_1 = $.derived(() => $$props.debugIds && !isUndefined($$props.id));
1308
+
676
1309
  $.if(node_7, ($$render) => {
677
- if ($$props.debugIds && $$props.id !== undefined) $$render(consequent_3);
1310
+ if ($.get(d_1)) $$render(consequent_3);
678
1311
  });
679
1312
  }
680
1313
 
681
1314
  $.append($$anchor, fragment);
1315
+ $.pop();
682
1316
  }
683
1317
 
684
1318
  function BackwardCheckpointsView($$anchor, $$props) {
@@ -704,7 +1338,7 @@ function BackwardCheckpointsView($$anchor, $$props) {
704
1338
  });
705
1339
  };
706
1340
 
707
- ItemsView($$anchor, {
1341
+ Wrap($$anchor, {
708
1342
  get ids() {
709
1343
  return $.get(ids);
710
1344
  },
@@ -721,6 +1355,7 @@ function BackwardCheckpointsView($$anchor, $$props) {
721
1355
  return $$props.checkpoint;
722
1356
  },
723
1357
  children,
1358
+ $$slots: {default: true},
724
1359
  });
725
1360
  }
726
1361
 
@@ -802,8 +1437,10 @@ function CurrentCheckpointView($$anchor, $$props) {
802
1437
  $.append($$anchor, fragment_1);
803
1438
  };
804
1439
 
1440
+ var d = $.derived(() => !isUndefined($.get(currentId)));
1441
+
805
1442
  $.if(node, ($$render) => {
806
- if ($.get(currentId) !== undefined) $$render(consequent_1);
1443
+ if ($.get(d)) $$render(consequent_1);
807
1444
  });
808
1445
  }
809
1446
 
@@ -834,7 +1471,7 @@ function ForwardCheckpointsView($$anchor, $$props) {
834
1471
  });
835
1472
  };
836
1473
 
837
- ItemsView($$anchor, {
1474
+ Wrap($$anchor, {
838
1475
  get ids() {
839
1476
  return $.get(ids);
840
1477
  },
@@ -851,6 +1488,7 @@ function ForwardCheckpointsView($$anchor, $$props) {
851
1488
  return $$props.checkpoint;
852
1489
  },
853
1490
  children,
1491
+ $$slots: {default: true},
854
1492
  });
855
1493
  }
856
1494
 
@@ -894,7 +1532,7 @@ function RowView($$anchor, $$props) {
894
1532
  });
895
1533
  };
896
1534
 
897
- ItemsView($$anchor, {
1535
+ Wrap($$anchor, {
898
1536
  get ids() {
899
1537
  return $.get(activeCellIds);
900
1538
  },
@@ -915,6 +1553,7 @@ function RowView($$anchor, $$props) {
915
1553
  return $$props.cell;
916
1554
  },
917
1555
  children,
1556
+ $$slots: {default: true},
918
1557
  });
919
1558
  }
920
1559
 
@@ -924,18 +1563,9 @@ function RowView($$anchor, $$props) {
924
1563
  function SliceView($$anchor, $$props) {
925
1564
  $.push($$props, true);
926
1565
 
927
- // Capture context at init to resolve Indexes → store/tableId
928
- const _ctx = getContext(TINYBASE_CONTEXT_KEY) ?? [];
929
-
930
- const _resolvedIndexes = $.derived(() =>
931
- isString($$props.indexes)
932
- ? objGet(_ctx[5], $$props.indexes)
933
- : ($$props.indexes ?? _ctx[4]),
934
- );
935
-
936
- const _store = $.derived(() => $.get(_resolvedIndexes)?.getStore());
937
- const _tableId = $.derived(() =>
938
- $.get(_resolvedIndexes)?.getTableId($$props.indexId),
1566
+ const {store, tableId} = useIndexStoreTableId(
1567
+ () => $$props.indexes,
1568
+ () => $$props.indexId,
939
1569
  );
940
1570
  const rowIds = useSliceRowIds(
941
1571
  () => $$props.indexId,
@@ -952,7 +1582,7 @@ function SliceView($$anchor, $$props) {
952
1582
  var consequent = ($$anchor) => {
953
1583
  RowView($$anchor, {
954
1584
  get tableId() {
955
- return $.get(_tableId);
1585
+ return tableId;
956
1586
  },
957
1587
 
958
1588
  get rowId() {
@@ -960,7 +1590,7 @@ function SliceView($$anchor, $$props) {
960
1590
  },
961
1591
 
962
1592
  get store() {
963
- return $.get(_store);
1593
+ return store;
964
1594
  },
965
1595
 
966
1596
  get debugIds() {
@@ -970,14 +1600,14 @@ function SliceView($$anchor, $$props) {
970
1600
  };
971
1601
 
972
1602
  $.if(node, ($$render) => {
973
- if ($.get(_tableId)) $$render(consequent);
1603
+ if (tableId) $$render(consequent);
974
1604
  });
975
1605
  }
976
1606
 
977
1607
  $.append($$anchor, fragment_1);
978
1608
  };
979
1609
 
980
- ItemsView($$anchor, {
1610
+ Wrap($$anchor, {
981
1611
  get ids() {
982
1612
  return rowIds.current;
983
1613
  },
@@ -998,6 +1628,7 @@ function SliceView($$anchor, $$props) {
998
1628
  return $$props.row;
999
1629
  },
1000
1630
  children,
1631
+ $$slots: {default: true},
1001
1632
  });
1002
1633
  }
1003
1634
 
@@ -1033,7 +1664,7 @@ function IndexView($$anchor, $$props) {
1033
1664
  });
1034
1665
  };
1035
1666
 
1036
- ItemsView($$anchor, {
1667
+ Wrap($$anchor, {
1037
1668
  get ids() {
1038
1669
  return sliceIds.current;
1039
1670
  },
@@ -1054,6 +1685,7 @@ function IndexView($$anchor, $$props) {
1054
1685
  return $$props.slice;
1055
1686
  },
1056
1687
  children,
1688
+ $$slots: {default: true},
1057
1689
  });
1058
1690
  }
1059
1691
 
@@ -1063,18 +1695,9 @@ function IndexView($$anchor, $$props) {
1063
1695
  function LinkedRowsView($$anchor, $$props) {
1064
1696
  $.push($$props, true);
1065
1697
 
1066
- // Capture context at init to resolve Relationships → store/tableId
1067
- const _ctx = getContext(TINYBASE_CONTEXT_KEY) ?? [];
1068
-
1069
- const _resolvedRelationships = $.derived(() =>
1070
- isString($$props.relationships)
1071
- ? objGet(_ctx[7], $$props.relationships)
1072
- : ($$props.relationships ?? _ctx[6]),
1073
- );
1074
-
1075
- const _store = $.derived(() => $.get(_resolvedRelationships)?.getStore());
1076
- const _tableId = $.derived(() =>
1077
- $.get(_resolvedRelationships)?.getLocalTableId($$props.relationshipId),
1698
+ const {store, localTableId} = useRelationshipsStoreTableIds(
1699
+ () => $$props.relationships,
1700
+ () => $$props.relationshipId,
1078
1701
  );
1079
1702
  const rowIds = useLinkedRowIds(
1080
1703
  () => $$props.relationshipId,
@@ -1091,7 +1714,7 @@ function LinkedRowsView($$anchor, $$props) {
1091
1714
  var consequent = ($$anchor) => {
1092
1715
  RowView($$anchor, {
1093
1716
  get tableId() {
1094
- return $.get(_tableId);
1717
+ return localTableId;
1095
1718
  },
1096
1719
 
1097
1720
  get rowId() {
@@ -1099,7 +1722,7 @@ function LinkedRowsView($$anchor, $$props) {
1099
1722
  },
1100
1723
 
1101
1724
  get store() {
1102
- return $.get(_store);
1725
+ return store;
1103
1726
  },
1104
1727
 
1105
1728
  get debugIds() {
@@ -1109,14 +1732,14 @@ function LinkedRowsView($$anchor, $$props) {
1109
1732
  };
1110
1733
 
1111
1734
  $.if(node, ($$render) => {
1112
- if ($.get(_tableId)) $$render(consequent);
1735
+ if (localTableId) $$render(consequent);
1113
1736
  });
1114
1737
  }
1115
1738
 
1116
1739
  $.append($$anchor, fragment_1);
1117
1740
  };
1118
1741
 
1119
- ItemsView($$anchor, {
1742
+ Wrap($$anchor, {
1120
1743
  get ids() {
1121
1744
  return rowIds.current;
1122
1745
  },
@@ -1137,6 +1760,7 @@ function LinkedRowsView($$anchor, $$props) {
1137
1760
  return $$props.row;
1138
1761
  },
1139
1762
  children,
1763
+ $$slots: {default: true},
1140
1764
  });
1141
1765
  }
1142
1766
 
@@ -1146,18 +1770,9 @@ function LinkedRowsView($$anchor, $$props) {
1146
1770
  function LocalRowsView($$anchor, $$props) {
1147
1771
  $.push($$props, true);
1148
1772
 
1149
- // Capture context at init to resolve Relationships → store/tableId
1150
- const _ctx = getContext(TINYBASE_CONTEXT_KEY) ?? [];
1151
-
1152
- const _resolvedRelationships = $.derived(() =>
1153
- isString($$props.relationships)
1154
- ? objGet(_ctx[7], $$props.relationships)
1155
- : ($$props.relationships ?? _ctx[6]),
1156
- );
1157
-
1158
- const _store = $.derived(() => $.get(_resolvedRelationships)?.getStore());
1159
- const _tableId = $.derived(() =>
1160
- $.get(_resolvedRelationships)?.getLocalTableId($$props.relationshipId),
1773
+ const {store, localTableId} = useRelationshipsStoreTableIds(
1774
+ () => $$props.relationships,
1775
+ () => $$props.relationshipId,
1161
1776
  );
1162
1777
  const rowIds = useLocalRowIds(
1163
1778
  () => $$props.relationshipId,
@@ -1174,7 +1789,7 @@ function LocalRowsView($$anchor, $$props) {
1174
1789
  var consequent = ($$anchor) => {
1175
1790
  RowView($$anchor, {
1176
1791
  get tableId() {
1177
- return $.get(_tableId);
1792
+ return localTableId;
1178
1793
  },
1179
1794
 
1180
1795
  get rowId() {
@@ -1182,7 +1797,7 @@ function LocalRowsView($$anchor, $$props) {
1182
1797
  },
1183
1798
 
1184
1799
  get store() {
1185
- return $.get(_store);
1800
+ return store;
1186
1801
  },
1187
1802
 
1188
1803
  get debugIds() {
@@ -1192,14 +1807,14 @@ function LocalRowsView($$anchor, $$props) {
1192
1807
  };
1193
1808
 
1194
1809
  $.if(node, ($$render) => {
1195
- if ($.get(_tableId)) $$render(consequent);
1810
+ if (localTableId) $$render(consequent);
1196
1811
  });
1197
1812
  }
1198
1813
 
1199
1814
  $.append($$anchor, fragment_1);
1200
1815
  };
1201
1816
 
1202
- ItemsView($$anchor, {
1817
+ Wrap($$anchor, {
1203
1818
  get ids() {
1204
1819
  return rowIds.current;
1205
1820
  },
@@ -1220,6 +1835,7 @@ function LocalRowsView($$anchor, $$props) {
1220
1835
  return $$props.row;
1221
1836
  },
1222
1837
  children,
1838
+ $$slots: {default: true},
1223
1839
  });
1224
1840
  }
1225
1841
 
@@ -1257,11 +1873,11 @@ function Provider($$anchor, $$props) {
1257
1873
  let extras = $.proxy(Array.from({length: 8}, () => ({})));
1258
1874
 
1259
1875
  const addThing = (offset, id, thing) => {
1260
- extras[offset] = {...extras[offset], [id]: thing};
1876
+ extras[offset] = {...untrack(() => extras[offset]), [id]: thing};
1261
1877
  };
1262
1878
 
1263
1879
  const delThing = (offset, id) => {
1264
- const {[id]: _, ...rest} = extras[offset];
1880
+ const {[id]: _, ...rest} = untrack(() => extras[offset]);
1265
1881
 
1266
1882
  extras[offset] = rest;
1267
1883
  };
@@ -1371,18 +1987,9 @@ var root = $.from_html(`<!><!><!>`, 1);
1371
1987
  function RemoteRowView($$anchor, $$props) {
1372
1988
  $.push($$props, true);
1373
1989
 
1374
- // Capture context at init to resolve Relationships → store/tableId
1375
- const _ctx = getContext(TINYBASE_CONTEXT_KEY) ?? [];
1376
-
1377
- const _resolvedRelationships = $.derived(() =>
1378
- isString($$props.relationships)
1379
- ? objGet(_ctx[7], $$props.relationships)
1380
- : ($$props.relationships ?? _ctx[6]),
1381
- );
1382
-
1383
- const _store = $.derived(() => $.get(_resolvedRelationships)?.getStore());
1384
- const _tableId = $.derived(() =>
1385
- $.get(_resolvedRelationships)?.getRemoteTableId($$props.relationshipId),
1990
+ const {store, remoteTableId} = useRelationshipsStoreTableIds(
1991
+ () => $$props.relationships,
1992
+ () => $$props.relationshipId,
1386
1993
  );
1387
1994
  const remoteRowId = useRemoteRowId(
1388
1995
  () => $$props.relationshipId,
@@ -1430,7 +2037,7 @@ function RemoteRowView($$anchor, $$props) {
1430
2037
  var consequent_2 = ($$anchor) => {
1431
2038
  RowView($$anchor, {
1432
2039
  get tableId() {
1433
- return $.get(_tableId);
2040
+ return remoteTableId;
1434
2041
  },
1435
2042
 
1436
2043
  get rowId() {
@@ -1438,7 +2045,7 @@ function RemoteRowView($$anchor, $$props) {
1438
2045
  },
1439
2046
 
1440
2047
  get store() {
1441
- return $.get(_store);
2048
+ return store;
1442
2049
  },
1443
2050
 
1444
2051
  get debugIds() {
@@ -1449,15 +2056,17 @@ function RemoteRowView($$anchor, $$props) {
1449
2056
 
1450
2057
  $.if(node_2, ($$render) => {
1451
2058
  if ($$props.row) $$render(consequent_1);
1452
- else if ($.get(_tableId)) $$render(consequent_2, 1);
2059
+ else if (remoteTableId) $$render(consequent_2, 1);
1453
2060
  });
1454
2061
  }
1455
2062
 
1456
2063
  $.append($$anchor, fragment_2);
1457
2064
  };
1458
2065
 
2066
+ var d = $.derived(() => !isUndefined(remoteRowId.current));
2067
+
1459
2068
  $.if(node_1, ($$render) => {
1460
- if (remoteRowId.current !== undefined) $$render(consequent_3);
2069
+ if ($.get(d)) $$render(consequent_3);
1461
2070
  });
1462
2071
  }
1463
2072
 
@@ -1538,7 +2147,7 @@ function ResultRowView($$anchor, $$props) {
1538
2147
  });
1539
2148
  };
1540
2149
 
1541
- ItemsView($$anchor, {
2150
+ Wrap($$anchor, {
1542
2151
  get ids() {
1543
2152
  return cellIds.current;
1544
2153
  },
@@ -1559,6 +2168,7 @@ function ResultRowView($$anchor, $$props) {
1559
2168
  return $$props.cell;
1560
2169
  },
1561
2170
  children,
2171
+ $$slots: {default: true},
1562
2172
  });
1563
2173
  }
1564
2174
 
@@ -1598,7 +2208,7 @@ function ResultSortedTableView($$anchor, $$props) {
1598
2208
  });
1599
2209
  };
1600
2210
 
1601
- ItemsView($$anchor, {
2211
+ Wrap($$anchor, {
1602
2212
  get ids() {
1603
2213
  return rowIds.current;
1604
2214
  },
@@ -1619,6 +2229,7 @@ function ResultSortedTableView($$anchor, $$props) {
1619
2229
  return $$props.row;
1620
2230
  },
1621
2231
  children,
2232
+ $$slots: {default: true},
1622
2233
  });
1623
2234
  }
1624
2235
 
@@ -1654,7 +2265,7 @@ function ResultTableView($$anchor, $$props) {
1654
2265
  });
1655
2266
  };
1656
2267
 
1657
- ItemsView($$anchor, {
2268
+ Wrap($$anchor, {
1658
2269
  get ids() {
1659
2270
  return rowIds.current;
1660
2271
  },
@@ -1675,6 +2286,7 @@ function ResultTableView($$anchor, $$props) {
1675
2286
  return $$props.row;
1676
2287
  },
1677
2288
  children,
2289
+ $$slots: {default: true},
1678
2290
  });
1679
2291
  }
1680
2292
 
@@ -1718,7 +2330,7 @@ function SortedTableView($$anchor, $$props) {
1718
2330
  });
1719
2331
  };
1720
2332
 
1721
- ItemsView($$anchor, {
2333
+ Wrap($$anchor, {
1722
2334
  get ids() {
1723
2335
  return rowIds.current;
1724
2336
  },
@@ -1739,6 +2351,7 @@ function SortedTableView($$anchor, $$props) {
1739
2351
  return $$props.row;
1740
2352
  },
1741
2353
  children,
2354
+ $$slots: {default: true},
1742
2355
  });
1743
2356
  }
1744
2357
 
@@ -1778,7 +2391,7 @@ function TableView($$anchor, $$props) {
1778
2391
  });
1779
2392
  };
1780
2393
 
1781
- ItemsView($$anchor, {
2394
+ Wrap($$anchor, {
1782
2395
  get ids() {
1783
2396
  return rowIds.current;
1784
2397
  },
@@ -1799,6 +2412,7 @@ function TableView($$anchor, $$props) {
1799
2412
  return $$props.row;
1800
2413
  },
1801
2414
  children,
2415
+ $$slots: {default: true},
1802
2416
  });
1803
2417
  }
1804
2418
 
@@ -1827,7 +2441,7 @@ function TablesView($$anchor, $$props) {
1827
2441
  });
1828
2442
  };
1829
2443
 
1830
- ItemsView($$anchor, {
2444
+ Wrap($$anchor, {
1831
2445
  get ids() {
1832
2446
  return tableIds.current;
1833
2447
  },
@@ -1844,6 +2458,7 @@ function TablesView($$anchor, $$props) {
1844
2458
  return $$props.table;
1845
2459
  },
1846
2460
  children,
2461
+ $$slots: {default: true},
1847
2462
  });
1848
2463
  }
1849
2464
 
@@ -1896,7 +2511,7 @@ function ValuesView($$anchor, $$props) {
1896
2511
  });
1897
2512
  };
1898
2513
 
1899
- ItemsView($$anchor, {
2514
+ Wrap($$anchor, {
1900
2515
  get ids() {
1901
2516
  return valueIds.current;
1902
2517
  },
@@ -1913,6 +2528,7 @@ function ValuesView($$anchor, $$props) {
1913
2528
  return $$props.value;
1914
2529
  },
1915
2530
  children,
2531
+ $$slots: {default: true},
1916
2532
  });
1917
2533
  }
1918
2534
 
@@ -1948,68 +2564,121 @@ export {
1948
2564
  SortedTableView,
1949
2565
  TablesView,
1950
2566
  TableView,
2567
+ useBindableCell,
2568
+ useBindableValue,
1951
2569
  useCell,
1952
2570
  useCellIds,
1953
- useCellState,
2571
+ useCellIdsListener,
2572
+ useCellListener,
1954
2573
  useCheckpoint,
1955
2574
  useCheckpointIds,
2575
+ useCheckpointIdsListener,
2576
+ useCheckpointListener,
1956
2577
  useCheckpoints,
1957
2578
  useCheckpointsIds,
2579
+ useCheckpointsOrCheckpointsById,
2580
+ useDidFinishTransactionListener,
1958
2581
  useGoBackwardCallback,
1959
2582
  useGoForwardCallback,
1960
2583
  useHasCell,
2584
+ useHasCellListener,
1961
2585
  useHasRow,
2586
+ useHasRowListener,
1962
2587
  useHasTable,
1963
2588
  useHasTableCell,
2589
+ useHasTableCellListener,
2590
+ useHasTableListener,
1964
2591
  useHasTables,
2592
+ useHasTablesListener,
1965
2593
  useHasValue,
2594
+ useHasValueListener,
1966
2595
  useHasValues,
2596
+ useHasValuesListener,
1967
2597
  useIndexes,
1968
2598
  useIndexesIds,
2599
+ useIndexesOrIndexesById,
1969
2600
  useIndexIds,
2601
+ useIndexStoreTableId,
1970
2602
  useLinkedRowIds,
2603
+ useLinkedRowIdsListener,
1971
2604
  useLocalRowIds,
2605
+ useLocalRowIdsListener,
1972
2606
  useMetric,
1973
2607
  useMetricIds,
2608
+ useMetricListener,
1974
2609
  useMetrics,
1975
2610
  useMetricsIds,
2611
+ useMetricsOrMetricsById,
2612
+ useParamValueListener,
2613
+ useParamValuesListener,
1976
2614
  usePersister,
1977
2615
  usePersisterIds,
2616
+ usePersisterOrPersisterById,
1978
2617
  usePersisterStatus,
2618
+ usePersisterStatusListener,
1979
2619
  useQueries,
1980
2620
  useQueriesIds,
2621
+ useQueriesOrQueriesById,
1981
2622
  useQueryIds,
1982
2623
  useRelationshipIds,
1983
2624
  useRelationships,
1984
2625
  useRelationshipsIds,
2626
+ useRelationshipsOrRelationshipsById,
2627
+ useRelationshipsStoreTableIds,
1985
2628
  useRemoteRowId,
2629
+ useRemoteRowIdListener,
1986
2630
  useResultCell,
1987
2631
  useResultCellIds,
2632
+ useResultCellIdsListener,
2633
+ useResultCellListener,
1988
2634
  useResultRow,
1989
2635
  useResultRowCount,
2636
+ useResultRowCountListener,
1990
2637
  useResultRowIds,
2638
+ useResultRowIdsListener,
2639
+ useResultRowListener,
1991
2640
  useResultSortedRowIds,
2641
+ useResultSortedRowIdsListener,
1992
2642
  useResultTable,
1993
2643
  useResultTableCellIds,
2644
+ useResultTableCellIdsListener,
2645
+ useResultTableListener,
1994
2646
  useRow,
1995
2647
  useRowCount,
2648
+ useRowCountListener,
1996
2649
  useRowIds,
2650
+ useRowIdsListener,
2651
+ useRowListener,
1997
2652
  useSliceIds,
2653
+ useSliceIdsListener,
1998
2654
  useSliceRowIds,
2655
+ useSliceRowIdsListener,
1999
2656
  useSortedRowIds,
2657
+ useSortedRowIdsListener,
2658
+ useStartTransactionListener,
2000
2659
  useStore,
2001
2660
  useStoreIds,
2661
+ useStoreOrStoreById,
2002
2662
  useSynchronizer,
2003
2663
  useSynchronizerIds,
2664
+ useSynchronizerOrSynchronizerById,
2004
2665
  useSynchronizerStatus,
2666
+ useSynchronizerStatusListener,
2005
2667
  useTable,
2006
2668
  useTableCellIds,
2669
+ useTableCellIdsListener,
2007
2670
  useTableIds,
2671
+ useTableIdsListener,
2672
+ useTableListener,
2008
2673
  useTables,
2674
+ useTablesListener,
2009
2675
  useValue,
2010
2676
  useValueIds,
2677
+ useValueIdsListener,
2678
+ useValueListener,
2011
2679
  useValues,
2012
- useValueState,
2680
+ useValuesListener,
2681
+ useWillFinishTransactionListener,
2013
2682
  ValuesView,
2014
2683
  ValueView,
2015
2684
  };