@vertz/ui 0.2.23 → 0.2.25

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 (36) hide show
  1. package/dist/shared/chunk-09ntccdx.js +39 -0
  2. package/dist/shared/{chunk-g6fb5yc2.js → chunk-1jgws7rs.js} +210 -258
  3. package/dist/shared/{chunk-016m1fq0.js → chunk-2krx4aqe.js} +119 -15
  4. package/dist/shared/{chunk-f4d5nphq.js → chunk-7nr2ebrf.js} +1 -1
  5. package/dist/shared/{chunk-4gmtsf6v.js → chunk-bk7mmn92.js} +1 -1
  6. package/dist/shared/chunk-djvarb8r.js +333 -0
  7. package/dist/shared/{chunk-jtma4sh4.js → chunk-e09mdqcx.js} +2 -2
  8. package/dist/shared/{chunk-4xkw6h1s.js → chunk-h1fsr8kv.js} +67 -1
  9. package/dist/shared/{chunk-xhc7arn9.js → chunk-j1a7t906.js} +14 -12
  10. package/dist/shared/{chunk-656n0x6y.js → chunk-ppr06jgn.js} +8 -2
  11. package/dist/shared/{chunk-2kyhn86t.js → chunk-svvqjmyy.js} +5 -63
  12. package/dist/shared/{chunk-da2w7j7w.js → chunk-xs5s8gqe.js} +1 -1
  13. package/dist/shared/{chunk-p3fz6qqp.js → chunk-ymc3wwam.js} +8 -2
  14. package/dist/src/auth/public.d.ts +35 -1
  15. package/dist/src/auth/public.js +72 -3
  16. package/dist/src/components/index.d.ts +3 -2
  17. package/dist/src/components/index.js +56 -46
  18. package/dist/src/css/public.d.ts +5 -1
  19. package/dist/src/css/public.js +4 -5
  20. package/dist/src/form/public.js +2 -2
  21. package/dist/src/index.d.ts +162 -53
  22. package/dist/src/index.js +341 -320
  23. package/dist/src/internals.d.ts +85 -10
  24. package/dist/src/internals.js +380 -90
  25. package/dist/src/jsx-runtime/index.js +3 -5
  26. package/dist/src/query/public.d.ts +6 -33
  27. package/dist/src/query/public.js +5 -7
  28. package/dist/src/router/public.d.ts +27 -4
  29. package/dist/src/router/public.js +8 -10
  30. package/dist/src/test/index.d.ts +12 -3
  31. package/dist/src/test/index.js +3 -3
  32. package/package.json +4 -3
  33. package/reactivity.json +1 -1
  34. package/dist/shared/chunk-13tvh4wq.js +0 -229
  35. package/dist/shared/chunk-2y9f9j62.js +0 -40
  36. package/dist/shared/chunk-prj7nm08.js +0 -67
@@ -0,0 +1,39 @@
1
+ import {
2
+ getSSRContext
3
+ } from "./chunk-ppr06jgn.js";
4
+
5
+ // src/query/invalidate.ts
6
+ var registry = new Set;
7
+ function registerActiveQuery(entityMeta, refetch, clearData) {
8
+ const registration = { entityMeta, refetch, clearData };
9
+ registry.add(registration);
10
+ return () => registry.delete(registration);
11
+ }
12
+ function invalidate(descriptor) {
13
+ const meta = descriptor._entity;
14
+ if (!meta)
15
+ return;
16
+ if (meta.kind === "get" && !meta.id)
17
+ return;
18
+ for (const reg of [...registry]) {
19
+ if (reg.entityMeta.entityType !== meta.entityType)
20
+ continue;
21
+ if (reg.entityMeta.kind !== meta.kind)
22
+ continue;
23
+ if (meta.kind === "get" && reg.entityMeta.id !== meta.id)
24
+ continue;
25
+ reg.refetch();
26
+ }
27
+ }
28
+ function invalidateTenantQueries() {
29
+ if (getSSRContext() !== undefined)
30
+ return;
31
+ for (const reg of [...registry]) {
32
+ if (reg.entityMeta.tenantScoped !== true)
33
+ continue;
34
+ reg.clearData?.();
35
+ reg.refetch();
36
+ }
37
+ }
38
+
39
+ export { registerActiveQuery, invalidate, invalidateTenantQueries };
@@ -2,26 +2,21 @@ import {
2
2
  isNavPrefetchActive
3
3
  } from "./chunk-jrtrk5z4.js";
4
4
  import {
5
- getAdapter,
6
- isRenderNode
7
- } from "./chunk-2y9f9j62.js";
5
+ registerActiveQuery
6
+ } from "./chunk-09ntccdx.js";
8
7
  import {
9
8
  isBrowser
10
- } from "./chunk-da2w7j7w.js";
9
+ } from "./chunk-xs5s8gqe.js";
11
10
  import {
12
11
  _tryOnCleanup,
13
12
  batch,
14
13
  computed,
15
- domEffect,
16
14
  getSSRContext,
17
15
  lifecycleEffect,
18
- popScope,
19
- pushScope,
20
- runCleanups,
21
16
  setReadValueCallback,
22
17
  signal,
23
18
  untrack
24
- } from "./chunk-656n0x6y.js";
19
+ } from "./chunk-ppr06jgn.js";
25
20
 
26
21
  // src/query/cache.ts
27
22
  class MemoryCache {
@@ -107,30 +102,6 @@ class MemoryCache {
107
102
  }
108
103
  }
109
104
 
110
- // src/query/invalidate.ts
111
- var registry = new Set;
112
- function registerActiveQuery(entityMeta, refetch) {
113
- const registration = { entityMeta, refetch };
114
- registry.add(registration);
115
- return () => registry.delete(registration);
116
- }
117
- function invalidate(descriptor) {
118
- const meta = descriptor._entity;
119
- if (!meta)
120
- return;
121
- if (meta.kind === "get" && !meta.id)
122
- return;
123
- for (const reg of [...registry]) {
124
- if (reg.entityMeta.entityType !== meta.entityType)
125
- continue;
126
- if (reg.entityMeta.kind !== meta.kind)
127
- continue;
128
- if (meta.kind === "get" && reg.entityMeta.id !== meta.id)
129
- continue;
130
- reg.refetch();
131
- }
132
- }
133
-
134
105
  // src/query/key-derivation.ts
135
106
  function deriveKey(thunk) {
136
107
  return `__q:${hashString(thunk.toString())}`;
@@ -231,15 +202,15 @@ var INTERNAL_PROPS = new Set([
231
202
  ]);
232
203
 
233
204
  // src/store/relation-registry.ts
234
- var registry2 = new Map;
205
+ var registry = new Map;
235
206
  function registerRelationSchema(entityType, schema) {
236
- registry2.set(entityType, Object.freeze(schema));
207
+ registry.set(entityType, Object.freeze(schema));
237
208
  }
238
209
  function getRelationSchema(entityType) {
239
- return registry2.get(entityType);
210
+ return registry.get(entityType);
240
211
  }
241
212
  function resetRelationSchemas_TEST_ONLY() {
242
- registry2.clear();
213
+ registry.clear();
243
214
  }
244
215
 
245
216
  // src/store/merge.ts
@@ -700,6 +671,9 @@ class QueryEnvelopeStore {
700
671
  set(queryKey, envelope) {
701
672
  this._envelopes.set(queryKey, envelope);
702
673
  }
674
+ delete(queryKey) {
675
+ this._envelopes.delete(queryKey);
676
+ }
703
677
  clear() {
704
678
  this._envelopes.clear();
705
679
  }
@@ -874,11 +848,11 @@ function query(source, options = {}) {
874
848
  const {
875
849
  initialData,
876
850
  debounce: debounceMs,
877
- enabled = true,
878
851
  key: customKey,
879
852
  cache = getDefaultCache(),
880
- _entityMeta: entityMeta
853
+ _entityMeta: optionsEntityMeta
881
854
  } = options;
855
+ let entityMeta = optionsEntityMeta;
882
856
  const baseKey = deriveKey(thunk);
883
857
  const depHashSignal = signal("");
884
858
  const cacheKeyComputed = computed(() => {
@@ -910,9 +884,9 @@ function query(source, options = {}) {
910
884
  function callThunkWithCapture() {
911
885
  const captured = [];
912
886
  const prevCb = setReadValueCallback((v) => captured.push(v));
913
- let promise;
887
+ let result;
914
888
  try {
915
- promise = thunk();
889
+ result = thunk();
916
890
  } finally {
917
891
  setReadValueCallback(prevCb);
918
892
  }
@@ -920,12 +894,13 @@ function query(source, options = {}) {
920
894
  untrack(() => {
921
895
  depHashSignal.value = hashString(serialized);
922
896
  });
923
- return promise;
897
+ return result;
924
898
  }
925
899
  const rawData = signal(initialData);
926
- const loading = signal(initialData === undefined && enabled);
900
+ const loading = signal(initialData === undefined);
927
901
  const revalidating = signal(false);
928
902
  const error = signal(undefined);
903
+ const idle = signal(initialData === undefined);
929
904
  const entityBacked = signal(false);
930
905
  function normalizeToEntityStore(result) {
931
906
  if (!entityMeta)
@@ -951,30 +926,31 @@ function query(source, options = {}) {
951
926
  }
952
927
  }
953
928
  const referencedKeys = new Set;
954
- const data = entityMeta ? computed(() => {
929
+ const initialEntityMeta = entityMeta;
930
+ const data = initialEntityMeta ? computed(() => {
955
931
  if (!entityBacked.value)
956
932
  return rawData.value;
957
933
  const raw = rawData.value;
958
934
  const store = getEntityStore();
959
935
  const newKeys = new Set;
960
- if (entityMeta.kind === "get" && entityMeta.id) {
961
- const entity = store.get(entityMeta.entityType, entityMeta.id).value;
936
+ if (initialEntityMeta.kind === "get" && initialEntityMeta.id) {
937
+ const entity = store.get(initialEntityMeta.entityType, initialEntityMeta.id).value;
962
938
  if (!entity) {
963
939
  updateRefCounts(store, referencedKeys, newKeys);
964
940
  return;
965
941
  }
966
- const resolved = resolveReferences(entity, entityMeta.entityType, store, undefined, newKeys);
942
+ const resolved = resolveReferences(entity, initialEntityMeta.entityType, store, undefined, newKeys);
967
943
  updateRefCounts(store, referencedKeys, newKeys);
968
944
  return resolved;
969
945
  }
970
- const queryKey = customKey ?? entityMeta.entityType;
946
+ const queryKey = customKey ?? initialEntityMeta.entityType;
971
947
  const ids = store.queryIndices.get(queryKey);
972
948
  if (ids) {
973
949
  const items = ids.map((id) => {
974
- const entity = store.get(entityMeta.entityType, id).value;
950
+ const entity = store.get(initialEntityMeta.entityType, id).value;
975
951
  if (!entity)
976
952
  return null;
977
- return resolveReferences(entity, entityMeta.entityType, store, undefined, newKeys);
953
+ return resolveReferences(entity, initialEntityMeta.entityType, store, undefined, newKeys);
978
954
  }).filter((item) => item != null);
979
955
  const envelope = getQueryEnvelopeStore().get(queryKey);
980
956
  updateRefCounts(store, referencedKeys, newKeys);
@@ -989,37 +965,57 @@ function query(source, options = {}) {
989
965
  retainKey(initKey);
990
966
  }
991
967
  const ssrTimeout = options.ssrTimeout ?? getGlobalSSRTimeout() ?? 300;
992
- if (isSSR() && enabled && ssrTimeout !== 0 && initialData === undefined) {
993
- const promise = callThunkWithCapture();
994
- const key = untrack(() => getCacheKey());
995
- const cached = cache.get(key);
996
- if (cached !== undefined) {
997
- promise.catch(() => {});
998
- normalizeToEntityStore(cached);
999
- rawData.value = cached;
968
+ if (isSSR() && ssrTimeout !== 0 && initialData === undefined) {
969
+ const ssrRaw = callThunkWithCapture();
970
+ if (ssrRaw === null) {
1000
971
  loading.value = false;
1001
972
  } else {
1002
- promise.catch(() => {});
1003
- const ctx = getSSRContext();
1004
- if (ctx) {
1005
- ctx.queries.push({
1006
- promise,
1007
- timeout: ssrTimeout,
1008
- resolve: (result) => {
1009
- normalizeToEntityStore(result);
1010
- rawData.value = result;
1011
- loading.value = false;
1012
- cache.set(key, result);
1013
- },
1014
- key
973
+ let ssrPromise;
974
+ if (isQueryDescriptor(ssrRaw)) {
975
+ const fetchResult = ssrRaw._fetch();
976
+ ssrPromise = fetchResult.then((result) => {
977
+ if (!result.ok)
978
+ throw result.error;
979
+ return result.data;
1015
980
  });
981
+ if (ssrRaw._entity && !entityMeta) {
982
+ entityMeta = ssrRaw._entity;
983
+ }
984
+ } else {
985
+ ssrPromise = ssrRaw;
986
+ }
987
+ const key = untrack(() => getCacheKey());
988
+ const cached = cache.get(key);
989
+ if (cached !== undefined) {
990
+ ssrPromise.catch(() => {});
991
+ normalizeToEntityStore(cached);
992
+ rawData.value = cached;
993
+ loading.value = false;
994
+ idle.value = false;
995
+ } else {
996
+ ssrPromise.catch(() => {});
997
+ const ctx = getSSRContext();
998
+ if (ctx) {
999
+ ctx.queries.push({
1000
+ promise: ssrPromise,
1001
+ timeout: ssrTimeout,
1002
+ resolve: (result) => {
1003
+ normalizeToEntityStore(result);
1004
+ rawData.value = result;
1005
+ loading.value = false;
1006
+ idle.value = false;
1007
+ cache.set(key, result);
1008
+ },
1009
+ key
1010
+ });
1011
+ }
1016
1012
  }
1017
1013
  }
1018
1014
  }
1019
1015
  let ssrHydrationCleanup = null;
1020
1016
  let ssrHydrated = false;
1021
1017
  let navPrefetchDeferred = false;
1022
- if (!isSSR() && enabled && initialData === undefined) {
1018
+ if (!isSSR() && initialData === undefined) {
1023
1019
  const hydrationKey = customKey ?? baseKey;
1024
1020
  const isNavigation = isNavPrefetchActive();
1025
1021
  ssrHydrationCleanup = hydrateQueryFromSSR(hydrationKey, (result) => {
@@ -1086,7 +1082,7 @@ function query(source, options = {}) {
1086
1082
  }, ms);
1087
1083
  }
1088
1084
  let visibilityHandler;
1089
- if (hasInterval && enabled && isBrowser()) {
1085
+ if (hasInterval && isBrowser()) {
1090
1086
  visibilityHandler = () => {
1091
1087
  if (document.visibilityState === "hidden") {
1092
1088
  intervalPaused = true;
@@ -1149,116 +1145,154 @@ function query(source, options = {}) {
1149
1145
  refetchTrigger.value = refetchTrigger.peek() + 1;
1150
1146
  }
1151
1147
  let disposeFn;
1152
- if (enabled) {
1153
- let isFirst = true;
1154
- disposeFn = lifecycleEffect(() => {
1155
- refetchTrigger.value;
1156
- if (isFirst && ssrHydrated) {
1157
- isFirst = false;
1158
- return;
1159
- }
1160
- if (isFirst && navPrefetchDeferred) {
1161
- if (customKey) {
1162
- const cached = untrack(() => cache.get(customKey));
1163
- if (cached !== undefined) {
1164
- retainKey(customKey);
1165
- untrack(() => {
1166
- rawData.value = cached;
1167
- loading.value = false;
1168
- });
1169
- isFirst = false;
1170
- return;
1171
- }
1172
- } else {
1173
- const trackPromise = callThunkWithCapture();
1174
- trackPromise.catch(() => {});
1175
- const derivedKey = untrack(() => getCacheKey());
1176
- const cached = untrack(() => cache.get(derivedKey));
1177
- if (cached !== undefined) {
1178
- retainKey(derivedKey);
1179
- untrack(() => {
1180
- rawData.value = cached;
1181
- loading.value = false;
1182
- });
1183
- isFirst = false;
1184
- return;
1185
- }
1186
- }
1187
- isFirst = false;
1188
- return;
1189
- }
1148
+ let isFirst = true;
1149
+ disposeFn = lifecycleEffect(() => {
1150
+ refetchTrigger.value;
1151
+ if (isFirst && ssrHydrated) {
1152
+ isFirst = false;
1153
+ return;
1154
+ }
1155
+ if (isFirst && navPrefetchDeferred) {
1190
1156
  if (customKey) {
1191
- const existing = untrack(() => getInflight().get(customKey));
1192
- if (existing) {
1193
- const id = ++fetchId;
1157
+ const cached = untrack(() => cache.get(customKey));
1158
+ if (cached !== undefined) {
1159
+ retainKey(customKey);
1194
1160
  untrack(() => {
1195
- if (rawData.value !== undefined) {
1196
- revalidating.value = true;
1197
- } else {
1198
- loading.value = true;
1199
- }
1200
- error.value = undefined;
1161
+ rawData.value = cached;
1162
+ loading.value = false;
1201
1163
  });
1202
- handleFetchPromise(existing, id, customKey);
1203
1164
  isFirst = false;
1204
1165
  return;
1205
1166
  }
1206
- }
1207
- const promise = callThunkWithCapture();
1208
- const key = untrack(() => getCacheKey());
1209
- if (!customKey) {
1210
- const existing = untrack(() => getInflight().get(key));
1211
- if (existing) {
1212
- promise.catch(() => {});
1213
- const id = ++fetchId;
1214
- untrack(() => {
1215
- if (rawData.value !== undefined) {
1216
- revalidating.value = true;
1217
- } else {
1218
- loading.value = true;
1219
- }
1220
- error.value = undefined;
1221
- });
1222
- handleFetchPromise(existing, id, key);
1167
+ } else {
1168
+ const trackRaw = callThunkWithCapture();
1169
+ if (trackRaw === null) {
1223
1170
  isFirst = false;
1224
1171
  return;
1225
1172
  }
1226
- }
1227
- const isNavigation = ssrHydrationCleanup !== null;
1228
- const shouldCheckCache = isNavigation || (isFirst ? !!customKey : !customKey);
1229
- if (shouldCheckCache) {
1230
- const cached = untrack(() => cache.get(key));
1173
+ if (!isQueryDescriptor(trackRaw)) {
1174
+ trackRaw.catch(() => {});
1175
+ }
1176
+ const derivedKey = untrack(() => getCacheKey());
1177
+ const cached = untrack(() => cache.get(derivedKey));
1231
1178
  if (cached !== undefined) {
1232
- retainKey(key);
1233
- promise.catch(() => {});
1179
+ retainKey(derivedKey);
1234
1180
  untrack(() => {
1235
1181
  rawData.value = cached;
1236
1182
  loading.value = false;
1237
- error.value = undefined;
1238
1183
  });
1239
1184
  isFirst = false;
1240
- scheduleInterval();
1241
1185
  return;
1242
1186
  }
1243
1187
  }
1244
- if (isFirst && initialData !== undefined) {
1188
+ isFirst = false;
1189
+ return;
1190
+ }
1191
+ if (customKey) {
1192
+ const existing = untrack(() => getInflight().get(customKey));
1193
+ if (existing) {
1194
+ const id = ++fetchId;
1195
+ untrack(() => {
1196
+ if (rawData.value !== undefined) {
1197
+ revalidating.value = true;
1198
+ } else {
1199
+ loading.value = true;
1200
+ }
1201
+ error.value = undefined;
1202
+ });
1203
+ handleFetchPromise(existing, id, customKey);
1204
+ isFirst = false;
1205
+ return;
1206
+ }
1207
+ }
1208
+ const raw = callThunkWithCapture();
1209
+ if (raw === null) {
1210
+ clearTimeout(debounceTimer);
1211
+ untrack(() => {
1212
+ loading.value = false;
1213
+ });
1214
+ isFirst = false;
1215
+ return;
1216
+ }
1217
+ let promise;
1218
+ let effectKey;
1219
+ let effectEntityMeta;
1220
+ if (isQueryDescriptor(raw)) {
1221
+ effectKey = raw._key;
1222
+ effectEntityMeta = raw._entity;
1223
+ const fetchResult = raw._fetch();
1224
+ promise = fetchResult.then((result) => {
1225
+ if (!result.ok)
1226
+ throw result.error;
1227
+ return result.data;
1228
+ });
1229
+ if (effectEntityMeta && !entityMeta) {
1230
+ entityMeta = effectEntityMeta;
1231
+ if (!isSSR()) {
1232
+ unsubscribeBus = getMutationEventBus().subscribe(entityMeta.entityType, refetch);
1233
+ unregisterFromRegistry = registerActiveQuery(entityMeta, refetch, createClearData(entityMeta));
1234
+ }
1235
+ }
1236
+ } else {
1237
+ promise = raw;
1238
+ }
1239
+ untrack(() => {
1240
+ idle.value = false;
1241
+ });
1242
+ const key = effectKey ?? untrack(() => getCacheKey());
1243
+ if (!customKey && !effectKey) {
1244
+ const existing = untrack(() => getInflight().get(key));
1245
+ if (existing) {
1245
1246
  promise.catch(() => {});
1247
+ const id = ++fetchId;
1248
+ untrack(() => {
1249
+ if (rawData.value !== undefined) {
1250
+ revalidating.value = true;
1251
+ } else {
1252
+ loading.value = true;
1253
+ }
1254
+ error.value = undefined;
1255
+ });
1256
+ handleFetchPromise(existing, id, key);
1257
+ isFirst = false;
1258
+ return;
1259
+ }
1260
+ }
1261
+ const isNavigation = ssrHydrationCleanup !== null;
1262
+ const shouldCheckCache = effectKey || isNavigation || (isFirst ? !!customKey : !customKey);
1263
+ if (shouldCheckCache) {
1264
+ const cached = untrack(() => cache.get(key));
1265
+ if (cached !== undefined) {
1266
+ retainKey(key);
1267
+ promise.catch(() => {});
1268
+ untrack(() => {
1269
+ normalizeToEntityStore(cached);
1270
+ rawData.value = cached;
1271
+ loading.value = false;
1272
+ error.value = undefined;
1273
+ });
1246
1274
  isFirst = false;
1247
1275
  scheduleInterval();
1248
1276
  return;
1249
1277
  }
1278
+ }
1279
+ if (isFirst && initialData !== undefined) {
1280
+ promise.catch(() => {});
1250
1281
  isFirst = false;
1251
- if (debounceMs !== undefined && debounceMs > 0) {
1252
- clearTimeout(debounceTimer);
1253
- promise.catch(() => {});
1254
- debounceTimer = setTimeout(() => {
1255
- startFetch(promise, key);
1256
- }, debounceMs);
1257
- } else {
1282
+ scheduleInterval();
1283
+ return;
1284
+ }
1285
+ isFirst = false;
1286
+ if (debounceMs !== undefined && debounceMs > 0) {
1287
+ clearTimeout(debounceTimer);
1288
+ promise.catch(() => {});
1289
+ debounceTimer = setTimeout(() => {
1258
1290
  startFetch(promise, key);
1259
- }
1260
- });
1261
- }
1291
+ }, debounceMs);
1292
+ } else {
1293
+ startFetch(promise, key);
1294
+ }
1295
+ });
1262
1296
  function dispose() {
1263
1297
  if (referencedKeys.size > 0) {
1264
1298
  const store = getEntityStore();
@@ -1284,11 +1318,25 @@ function query(source, options = {}) {
1284
1318
  }
1285
1319
  inflightKeys.clear();
1286
1320
  }
1321
+ function createClearData(meta) {
1322
+ return () => {
1323
+ untrack(() => {
1324
+ entityBacked.value = false;
1325
+ rawData.value = undefined;
1326
+ loading.value = true;
1327
+ });
1328
+ const cacheKey = untrack(() => getCacheKey());
1329
+ cache.delete(cacheKey);
1330
+ const queryKey = customKey ?? meta.entityType;
1331
+ getEntityStore().queryIndices.clear(queryKey);
1332
+ getQueryEnvelopeStore().delete(queryKey);
1333
+ };
1334
+ }
1287
1335
  let unsubscribeBus;
1288
1336
  let unregisterFromRegistry;
1289
- if (entityMeta && enabled && !isSSR()) {
1337
+ if (entityMeta && !isSSR()) {
1290
1338
  unsubscribeBus = getMutationEventBus().subscribe(entityMeta.entityType, refetch);
1291
- unregisterFromRegistry = registerActiveQuery(entityMeta, refetch);
1339
+ unregisterFromRegistry = registerActiveQuery(entityMeta, refetch, createClearData(entityMeta));
1292
1340
  }
1293
1341
  _tryOnCleanup(dispose);
1294
1342
  return {
@@ -1296,6 +1344,7 @@ function query(source, options = {}) {
1296
1344
  loading,
1297
1345
  revalidating,
1298
1346
  error,
1347
+ idle,
1299
1348
  refetch,
1300
1349
  revalidate: refetch,
1301
1350
  dispose
@@ -1323,101 +1372,4 @@ function splitRefKey(key) {
1323
1372
  return [key.slice(0, idx), key.slice(idx + 1)];
1324
1373
  }
1325
1374
 
1326
- // src/query/query-match.ts
1327
- var cache = new WeakMap;
1328
- function queryMatch(queryResult, handlers) {
1329
- const key = queryResult;
1330
- const existing = cache.get(key);
1331
- if (existing && !existing.disposed) {
1332
- existing.handlers = handlers;
1333
- return existing.wrapper;
1334
- }
1335
- if (existing) {
1336
- cache.delete(key);
1337
- }
1338
- const wrapper = getAdapter().createElement("span");
1339
- wrapper.style.display = "contents";
1340
- const entry = { wrapper, handlers, disposed: false };
1341
- cache.set(key, entry);
1342
- let currentBranch = null;
1343
- let branchCleanups = [];
1344
- const outerScope = pushScope();
1345
- domEffect(() => {
1346
- const isLoading = queryResult.loading.value;
1347
- const err = queryResult.error.value;
1348
- const dataValue = queryResult.data.value;
1349
- let branch;
1350
- if (isLoading || err === undefined && dataValue === undefined) {
1351
- branch = "loading";
1352
- } else if (err !== undefined) {
1353
- branch = "error";
1354
- } else {
1355
- branch = "data";
1356
- }
1357
- if (branch === currentBranch) {
1358
- return;
1359
- }
1360
- runCleanups(branchCleanups);
1361
- while (wrapper.firstChild) {
1362
- wrapper.removeChild(wrapper.firstChild);
1363
- }
1364
- currentBranch = branch;
1365
- const scope = pushScope();
1366
- let branchResult = null;
1367
- if (branch === "loading") {
1368
- branchResult = entry.handlers.loading();
1369
- } else if (branch === "error") {
1370
- branchResult = entry.handlers.error(err);
1371
- } else {
1372
- const dataSignal = queryResult.data;
1373
- const dataProxy = new Proxy({}, {
1374
- get(_target, prop, receiver) {
1375
- const current = dataSignal.value;
1376
- if (current == null)
1377
- return;
1378
- const value = Reflect.get(current, prop, receiver);
1379
- if (typeof value === "function") {
1380
- return value.bind(current);
1381
- }
1382
- return value;
1383
- },
1384
- has(_target, prop) {
1385
- const current = dataSignal.value;
1386
- if (current == null)
1387
- return false;
1388
- return Reflect.has(current, prop);
1389
- },
1390
- ownKeys() {
1391
- const current = dataSignal.value;
1392
- if (current == null)
1393
- return [];
1394
- return Reflect.ownKeys(current);
1395
- },
1396
- getOwnPropertyDescriptor(_target, prop) {
1397
- const current = dataSignal.value;
1398
- if (current == null)
1399
- return;
1400
- return Reflect.getOwnPropertyDescriptor(current, prop);
1401
- }
1402
- });
1403
- branchResult = entry.handlers.data(dataProxy);
1404
- }
1405
- popScope();
1406
- branchCleanups = scope;
1407
- if (branchResult != null && isRenderNode(branchResult)) {
1408
- wrapper.appendChild(branchResult);
1409
- }
1410
- });
1411
- popScope();
1412
- const dispose = () => {
1413
- entry.disposed = true;
1414
- runCleanups(branchCleanups);
1415
- runCleanups(outerScope);
1416
- cache.delete(key);
1417
- };
1418
- wrapper.dispose = dispose;
1419
- _tryOnCleanup(dispose);
1420
- return wrapper;
1421
- }
1422
-
1423
- export { MemoryCache, invalidate, deriveKey, FieldSelectionTracker, registerRelationSchema, getRelationSchema, resetRelationSchemas_TEST_ONLY, EntityStore, QueryEnvelopeStore, getEntityStore, getQueryEnvelopeStore, getMutationEventBus, query, queryMatch };
1375
+ export { MemoryCache, deriveKey, FieldSelectionTracker, registerRelationSchema, getRelationSchema, resetRelationSchemas_TEST_ONLY, EntityStore, QueryEnvelopeStore, getEntityStore, getQueryEnvelopeStore, getMutationEventBus, query };