@vertz/ui 0.2.22 → 0.2.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/shared/{chunk-pdqr78k9.js → chunk-18frwfc4.js} +1 -1
- package/dist/shared/chunk-2eh4p2n7.js +39 -0
- package/dist/shared/{chunk-67z8b0q8.js → chunk-2wag9c7v.js} +182 -53
- package/dist/shared/{chunk-c61572xp.js → chunk-2y9f9j62.js} +1 -1
- package/dist/shared/{chunk-szk0hyjg.js → chunk-4gen306a.js} +212 -155
- package/dist/shared/{chunk-yb4a0smw.js → chunk-4gmtsf6v.js} +1 -1
- package/dist/shared/{chunk-2qe6aqhb.js → chunk-656n0x6y.js} +48 -48
- package/dist/shared/{chunk-bybgyjye.js → chunk-da2w7j7w.js} +1 -1
- package/dist/shared/{chunk-4cmt1ve8.js → chunk-f4d5nphq.js} +1 -1
- package/dist/shared/chunk-ge2e6y2s.js +102 -0
- package/dist/shared/{chunk-4xkw6h1s.js → chunk-h1fsr8kv.js} +67 -1
- package/dist/shared/{chunk-7g722pdh.js → chunk-jtma4sh4.js} +2 -2
- package/dist/shared/{chunk-vwz86vg9.js → chunk-mbnda3pv.js} +96 -18
- package/dist/shared/{chunk-pq8khh47.js → chunk-t3rnfxc0.js} +64 -23
- package/dist/src/auth/public.d.ts +35 -1
- package/dist/src/auth/public.js +72 -3
- package/dist/src/components/index.d.ts +2 -2
- package/dist/src/components/index.js +51 -46
- package/dist/src/css/public.d.ts +7 -3
- package/dist/src/css/public.js +5 -5
- package/dist/src/form/public.js +2 -2
- package/dist/src/index.d.ts +211 -39
- package/dist/src/index.js +372 -153
- package/dist/src/internals.d.ts +70 -6
- package/dist/src/internals.js +161 -34
- package/dist/src/jsx-runtime/index.js +3 -5
- package/dist/src/query/public.d.ts +7 -3
- package/dist/src/query/public.js +5 -4
- package/dist/src/router/public.d.ts +27 -4
- package/dist/src/router/public.js +9 -10
- package/dist/src/test/index.d.ts +12 -3
- package/dist/src/test/index.js +3 -3
- package/package.json +4 -3
- package/reactivity.json +1 -1
- package/dist/shared/chunk-kjwp5q5s.js +0 -53
- package/dist/shared/chunk-prj7nm08.js +0 -67
|
@@ -4,10 +4,13 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
getAdapter,
|
|
6
6
|
isRenderNode
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-2y9f9j62.js";
|
|
8
|
+
import {
|
|
9
|
+
registerActiveQuery
|
|
10
|
+
} from "./chunk-2eh4p2n7.js";
|
|
8
11
|
import {
|
|
9
12
|
isBrowser
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-da2w7j7w.js";
|
|
11
14
|
import {
|
|
12
15
|
_tryOnCleanup,
|
|
13
16
|
batch,
|
|
@@ -21,7 +24,7 @@ import {
|
|
|
21
24
|
setReadValueCallback,
|
|
22
25
|
signal,
|
|
23
26
|
untrack
|
|
24
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-656n0x6y.js";
|
|
25
28
|
|
|
26
29
|
// src/query/cache.ts
|
|
27
30
|
class MemoryCache {
|
|
@@ -107,30 +110,6 @@ class MemoryCache {
|
|
|
107
110
|
}
|
|
108
111
|
}
|
|
109
112
|
|
|
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
113
|
// src/query/key-derivation.ts
|
|
135
114
|
function deriveKey(thunk) {
|
|
136
115
|
return `__q:${hashString(thunk.toString())}`;
|
|
@@ -231,15 +210,15 @@ var INTERNAL_PROPS = new Set([
|
|
|
231
210
|
]);
|
|
232
211
|
|
|
233
212
|
// src/store/relation-registry.ts
|
|
234
|
-
var
|
|
213
|
+
var registry = new Map;
|
|
235
214
|
function registerRelationSchema(entityType, schema) {
|
|
236
|
-
|
|
215
|
+
registry.set(entityType, Object.freeze(schema));
|
|
237
216
|
}
|
|
238
217
|
function getRelationSchema(entityType) {
|
|
239
|
-
return
|
|
218
|
+
return registry.get(entityType);
|
|
240
219
|
}
|
|
241
220
|
function resetRelationSchemas_TEST_ONLY() {
|
|
242
|
-
|
|
221
|
+
registry.clear();
|
|
243
222
|
}
|
|
244
223
|
|
|
245
224
|
// src/store/merge.ts
|
|
@@ -700,6 +679,9 @@ class QueryEnvelopeStore {
|
|
|
700
679
|
set(queryKey, envelope) {
|
|
701
680
|
this._envelopes.set(queryKey, envelope);
|
|
702
681
|
}
|
|
682
|
+
delete(queryKey) {
|
|
683
|
+
this._envelopes.delete(queryKey);
|
|
684
|
+
}
|
|
703
685
|
clear() {
|
|
704
686
|
this._envelopes.clear();
|
|
705
687
|
}
|
|
@@ -874,11 +856,11 @@ function query(source, options = {}) {
|
|
|
874
856
|
const {
|
|
875
857
|
initialData,
|
|
876
858
|
debounce: debounceMs,
|
|
877
|
-
enabled = true,
|
|
878
859
|
key: customKey,
|
|
879
860
|
cache = getDefaultCache(),
|
|
880
|
-
_entityMeta:
|
|
861
|
+
_entityMeta: optionsEntityMeta
|
|
881
862
|
} = options;
|
|
863
|
+
let entityMeta = optionsEntityMeta;
|
|
882
864
|
const baseKey = deriveKey(thunk);
|
|
883
865
|
const depHashSignal = signal("");
|
|
884
866
|
const cacheKeyComputed = computed(() => {
|
|
@@ -910,9 +892,9 @@ function query(source, options = {}) {
|
|
|
910
892
|
function callThunkWithCapture() {
|
|
911
893
|
const captured = [];
|
|
912
894
|
const prevCb = setReadValueCallback((v) => captured.push(v));
|
|
913
|
-
let
|
|
895
|
+
let result;
|
|
914
896
|
try {
|
|
915
|
-
|
|
897
|
+
result = thunk();
|
|
916
898
|
} finally {
|
|
917
899
|
setReadValueCallback(prevCb);
|
|
918
900
|
}
|
|
@@ -920,12 +902,13 @@ function query(source, options = {}) {
|
|
|
920
902
|
untrack(() => {
|
|
921
903
|
depHashSignal.value = hashString(serialized);
|
|
922
904
|
});
|
|
923
|
-
return
|
|
905
|
+
return result;
|
|
924
906
|
}
|
|
925
907
|
const rawData = signal(initialData);
|
|
926
|
-
const loading = signal(initialData === undefined
|
|
908
|
+
const loading = signal(initialData === undefined);
|
|
927
909
|
const revalidating = signal(false);
|
|
928
910
|
const error = signal(undefined);
|
|
911
|
+
const idle = signal(initialData === undefined);
|
|
929
912
|
const entityBacked = signal(false);
|
|
930
913
|
function normalizeToEntityStore(result) {
|
|
931
914
|
if (!entityMeta)
|
|
@@ -951,30 +934,31 @@ function query(source, options = {}) {
|
|
|
951
934
|
}
|
|
952
935
|
}
|
|
953
936
|
const referencedKeys = new Set;
|
|
954
|
-
const
|
|
937
|
+
const initialEntityMeta = entityMeta;
|
|
938
|
+
const data = initialEntityMeta ? computed(() => {
|
|
955
939
|
if (!entityBacked.value)
|
|
956
940
|
return rawData.value;
|
|
957
941
|
const raw = rawData.value;
|
|
958
942
|
const store = getEntityStore();
|
|
959
943
|
const newKeys = new Set;
|
|
960
|
-
if (
|
|
961
|
-
const entity = store.get(
|
|
944
|
+
if (initialEntityMeta.kind === "get" && initialEntityMeta.id) {
|
|
945
|
+
const entity = store.get(initialEntityMeta.entityType, initialEntityMeta.id).value;
|
|
962
946
|
if (!entity) {
|
|
963
947
|
updateRefCounts(store, referencedKeys, newKeys);
|
|
964
948
|
return;
|
|
965
949
|
}
|
|
966
|
-
const resolved = resolveReferences(entity,
|
|
950
|
+
const resolved = resolveReferences(entity, initialEntityMeta.entityType, store, undefined, newKeys);
|
|
967
951
|
updateRefCounts(store, referencedKeys, newKeys);
|
|
968
952
|
return resolved;
|
|
969
953
|
}
|
|
970
|
-
const queryKey = customKey ??
|
|
954
|
+
const queryKey = customKey ?? initialEntityMeta.entityType;
|
|
971
955
|
const ids = store.queryIndices.get(queryKey);
|
|
972
956
|
if (ids) {
|
|
973
957
|
const items = ids.map((id) => {
|
|
974
|
-
const entity = store.get(
|
|
958
|
+
const entity = store.get(initialEntityMeta.entityType, id).value;
|
|
975
959
|
if (!entity)
|
|
976
960
|
return null;
|
|
977
|
-
return resolveReferences(entity,
|
|
961
|
+
return resolveReferences(entity, initialEntityMeta.entityType, store, undefined, newKeys);
|
|
978
962
|
}).filter((item) => item != null);
|
|
979
963
|
const envelope = getQueryEnvelopeStore().get(queryKey);
|
|
980
964
|
updateRefCounts(store, referencedKeys, newKeys);
|
|
@@ -989,37 +973,57 @@ function query(source, options = {}) {
|
|
|
989
973
|
retainKey(initKey);
|
|
990
974
|
}
|
|
991
975
|
const ssrTimeout = options.ssrTimeout ?? getGlobalSSRTimeout() ?? 300;
|
|
992
|
-
if (isSSR() &&
|
|
993
|
-
const
|
|
994
|
-
|
|
995
|
-
const cached = cache.get(key);
|
|
996
|
-
if (cached !== undefined) {
|
|
997
|
-
promise.catch(() => {});
|
|
998
|
-
normalizeToEntityStore(cached);
|
|
999
|
-
rawData.value = cached;
|
|
976
|
+
if (isSSR() && ssrTimeout !== 0 && initialData === undefined) {
|
|
977
|
+
const ssrRaw = callThunkWithCapture();
|
|
978
|
+
if (ssrRaw === null) {
|
|
1000
979
|
loading.value = false;
|
|
1001
980
|
} else {
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
normalizeToEntityStore(result);
|
|
1010
|
-
rawData.value = result;
|
|
1011
|
-
loading.value = false;
|
|
1012
|
-
cache.set(key, result);
|
|
1013
|
-
},
|
|
1014
|
-
key
|
|
981
|
+
let ssrPromise;
|
|
982
|
+
if (isQueryDescriptor(ssrRaw)) {
|
|
983
|
+
const fetchResult = ssrRaw._fetch();
|
|
984
|
+
ssrPromise = fetchResult.then((result) => {
|
|
985
|
+
if (!result.ok)
|
|
986
|
+
throw result.error;
|
|
987
|
+
return result.data;
|
|
1015
988
|
});
|
|
989
|
+
if (ssrRaw._entity && !entityMeta) {
|
|
990
|
+
entityMeta = ssrRaw._entity;
|
|
991
|
+
}
|
|
992
|
+
} else {
|
|
993
|
+
ssrPromise = ssrRaw;
|
|
994
|
+
}
|
|
995
|
+
const key = untrack(() => getCacheKey());
|
|
996
|
+
const cached = cache.get(key);
|
|
997
|
+
if (cached !== undefined) {
|
|
998
|
+
ssrPromise.catch(() => {});
|
|
999
|
+
normalizeToEntityStore(cached);
|
|
1000
|
+
rawData.value = cached;
|
|
1001
|
+
loading.value = false;
|
|
1002
|
+
idle.value = false;
|
|
1003
|
+
} else {
|
|
1004
|
+
ssrPromise.catch(() => {});
|
|
1005
|
+
const ctx = getSSRContext();
|
|
1006
|
+
if (ctx) {
|
|
1007
|
+
ctx.queries.push({
|
|
1008
|
+
promise: ssrPromise,
|
|
1009
|
+
timeout: ssrTimeout,
|
|
1010
|
+
resolve: (result) => {
|
|
1011
|
+
normalizeToEntityStore(result);
|
|
1012
|
+
rawData.value = result;
|
|
1013
|
+
loading.value = false;
|
|
1014
|
+
idle.value = false;
|
|
1015
|
+
cache.set(key, result);
|
|
1016
|
+
},
|
|
1017
|
+
key
|
|
1018
|
+
});
|
|
1019
|
+
}
|
|
1016
1020
|
}
|
|
1017
1021
|
}
|
|
1018
1022
|
}
|
|
1019
1023
|
let ssrHydrationCleanup = null;
|
|
1020
1024
|
let ssrHydrated = false;
|
|
1021
1025
|
let navPrefetchDeferred = false;
|
|
1022
|
-
if (!isSSR() &&
|
|
1026
|
+
if (!isSSR() && initialData === undefined) {
|
|
1023
1027
|
const hydrationKey = customKey ?? baseKey;
|
|
1024
1028
|
const isNavigation = isNavPrefetchActive();
|
|
1025
1029
|
ssrHydrationCleanup = hydrateQueryFromSSR(hydrationKey, (result) => {
|
|
@@ -1086,7 +1090,7 @@ function query(source, options = {}) {
|
|
|
1086
1090
|
}, ms);
|
|
1087
1091
|
}
|
|
1088
1092
|
let visibilityHandler;
|
|
1089
|
-
if (hasInterval &&
|
|
1093
|
+
if (hasInterval && isBrowser()) {
|
|
1090
1094
|
visibilityHandler = () => {
|
|
1091
1095
|
if (document.visibilityState === "hidden") {
|
|
1092
1096
|
intervalPaused = true;
|
|
@@ -1149,116 +1153,154 @@ function query(source, options = {}) {
|
|
|
1149
1153
|
refetchTrigger.value = refetchTrigger.peek() + 1;
|
|
1150
1154
|
}
|
|
1151
1155
|
let disposeFn;
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
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
|
-
}
|
|
1156
|
+
let isFirst = true;
|
|
1157
|
+
disposeFn = lifecycleEffect(() => {
|
|
1158
|
+
refetchTrigger.value;
|
|
1159
|
+
if (isFirst && ssrHydrated) {
|
|
1160
|
+
isFirst = false;
|
|
1161
|
+
return;
|
|
1162
|
+
}
|
|
1163
|
+
if (isFirst && navPrefetchDeferred) {
|
|
1190
1164
|
if (customKey) {
|
|
1191
|
-
const
|
|
1192
|
-
if (
|
|
1193
|
-
|
|
1165
|
+
const cached = untrack(() => cache.get(customKey));
|
|
1166
|
+
if (cached !== undefined) {
|
|
1167
|
+
retainKey(customKey);
|
|
1194
1168
|
untrack(() => {
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
} else {
|
|
1198
|
-
loading.value = true;
|
|
1199
|
-
}
|
|
1200
|
-
error.value = undefined;
|
|
1169
|
+
rawData.value = cached;
|
|
1170
|
+
loading.value = false;
|
|
1201
1171
|
});
|
|
1202
|
-
handleFetchPromise(existing, id, customKey);
|
|
1203
1172
|
isFirst = false;
|
|
1204
1173
|
return;
|
|
1205
1174
|
}
|
|
1206
|
-
}
|
|
1207
|
-
|
|
1208
|
-
|
|
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);
|
|
1175
|
+
} else {
|
|
1176
|
+
const trackRaw = callThunkWithCapture();
|
|
1177
|
+
if (trackRaw === null) {
|
|
1223
1178
|
isFirst = false;
|
|
1224
1179
|
return;
|
|
1225
1180
|
}
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
const cached = untrack(() => cache.get(
|
|
1181
|
+
if (!isQueryDescriptor(trackRaw)) {
|
|
1182
|
+
trackRaw.catch(() => {});
|
|
1183
|
+
}
|
|
1184
|
+
const derivedKey = untrack(() => getCacheKey());
|
|
1185
|
+
const cached = untrack(() => cache.get(derivedKey));
|
|
1231
1186
|
if (cached !== undefined) {
|
|
1232
|
-
retainKey(
|
|
1233
|
-
promise.catch(() => {});
|
|
1187
|
+
retainKey(derivedKey);
|
|
1234
1188
|
untrack(() => {
|
|
1235
1189
|
rawData.value = cached;
|
|
1236
1190
|
loading.value = false;
|
|
1237
|
-
error.value = undefined;
|
|
1238
1191
|
});
|
|
1239
1192
|
isFirst = false;
|
|
1240
|
-
scheduleInterval();
|
|
1241
1193
|
return;
|
|
1242
1194
|
}
|
|
1243
1195
|
}
|
|
1244
|
-
|
|
1196
|
+
isFirst = false;
|
|
1197
|
+
return;
|
|
1198
|
+
}
|
|
1199
|
+
if (customKey) {
|
|
1200
|
+
const existing = untrack(() => getInflight().get(customKey));
|
|
1201
|
+
if (existing) {
|
|
1202
|
+
const id = ++fetchId;
|
|
1203
|
+
untrack(() => {
|
|
1204
|
+
if (rawData.value !== undefined) {
|
|
1205
|
+
revalidating.value = true;
|
|
1206
|
+
} else {
|
|
1207
|
+
loading.value = true;
|
|
1208
|
+
}
|
|
1209
|
+
error.value = undefined;
|
|
1210
|
+
});
|
|
1211
|
+
handleFetchPromise(existing, id, customKey);
|
|
1212
|
+
isFirst = false;
|
|
1213
|
+
return;
|
|
1214
|
+
}
|
|
1215
|
+
}
|
|
1216
|
+
const raw = callThunkWithCapture();
|
|
1217
|
+
if (raw === null) {
|
|
1218
|
+
clearTimeout(debounceTimer);
|
|
1219
|
+
untrack(() => {
|
|
1220
|
+
loading.value = false;
|
|
1221
|
+
});
|
|
1222
|
+
isFirst = false;
|
|
1223
|
+
return;
|
|
1224
|
+
}
|
|
1225
|
+
let promise;
|
|
1226
|
+
let effectKey;
|
|
1227
|
+
let effectEntityMeta;
|
|
1228
|
+
if (isQueryDescriptor(raw)) {
|
|
1229
|
+
effectKey = raw._key;
|
|
1230
|
+
effectEntityMeta = raw._entity;
|
|
1231
|
+
const fetchResult = raw._fetch();
|
|
1232
|
+
promise = fetchResult.then((result) => {
|
|
1233
|
+
if (!result.ok)
|
|
1234
|
+
throw result.error;
|
|
1235
|
+
return result.data;
|
|
1236
|
+
});
|
|
1237
|
+
if (effectEntityMeta && !entityMeta) {
|
|
1238
|
+
entityMeta = effectEntityMeta;
|
|
1239
|
+
if (!isSSR()) {
|
|
1240
|
+
unsubscribeBus = getMutationEventBus().subscribe(entityMeta.entityType, refetch);
|
|
1241
|
+
unregisterFromRegistry = registerActiveQuery(entityMeta, refetch, createClearData(entityMeta));
|
|
1242
|
+
}
|
|
1243
|
+
}
|
|
1244
|
+
} else {
|
|
1245
|
+
promise = raw;
|
|
1246
|
+
}
|
|
1247
|
+
untrack(() => {
|
|
1248
|
+
idle.value = false;
|
|
1249
|
+
});
|
|
1250
|
+
const key = effectKey ?? untrack(() => getCacheKey());
|
|
1251
|
+
if (!customKey && !effectKey) {
|
|
1252
|
+
const existing = untrack(() => getInflight().get(key));
|
|
1253
|
+
if (existing) {
|
|
1254
|
+
promise.catch(() => {});
|
|
1255
|
+
const id = ++fetchId;
|
|
1256
|
+
untrack(() => {
|
|
1257
|
+
if (rawData.value !== undefined) {
|
|
1258
|
+
revalidating.value = true;
|
|
1259
|
+
} else {
|
|
1260
|
+
loading.value = true;
|
|
1261
|
+
}
|
|
1262
|
+
error.value = undefined;
|
|
1263
|
+
});
|
|
1264
|
+
handleFetchPromise(existing, id, key);
|
|
1265
|
+
isFirst = false;
|
|
1266
|
+
return;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
const isNavigation = ssrHydrationCleanup !== null;
|
|
1270
|
+
const shouldCheckCache = effectKey || isNavigation || (isFirst ? !!customKey : !customKey);
|
|
1271
|
+
if (shouldCheckCache) {
|
|
1272
|
+
const cached = untrack(() => cache.get(key));
|
|
1273
|
+
if (cached !== undefined) {
|
|
1274
|
+
retainKey(key);
|
|
1245
1275
|
promise.catch(() => {});
|
|
1276
|
+
untrack(() => {
|
|
1277
|
+
normalizeToEntityStore(cached);
|
|
1278
|
+
rawData.value = cached;
|
|
1279
|
+
loading.value = false;
|
|
1280
|
+
error.value = undefined;
|
|
1281
|
+
});
|
|
1246
1282
|
isFirst = false;
|
|
1247
1283
|
scheduleInterval();
|
|
1248
1284
|
return;
|
|
1249
1285
|
}
|
|
1286
|
+
}
|
|
1287
|
+
if (isFirst && initialData !== undefined) {
|
|
1288
|
+
promise.catch(() => {});
|
|
1250
1289
|
isFirst = false;
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1290
|
+
scheduleInterval();
|
|
1291
|
+
return;
|
|
1292
|
+
}
|
|
1293
|
+
isFirst = false;
|
|
1294
|
+
if (debounceMs !== undefined && debounceMs > 0) {
|
|
1295
|
+
clearTimeout(debounceTimer);
|
|
1296
|
+
promise.catch(() => {});
|
|
1297
|
+
debounceTimer = setTimeout(() => {
|
|
1258
1298
|
startFetch(promise, key);
|
|
1259
|
-
}
|
|
1260
|
-
}
|
|
1261
|
-
|
|
1299
|
+
}, debounceMs);
|
|
1300
|
+
} else {
|
|
1301
|
+
startFetch(promise, key);
|
|
1302
|
+
}
|
|
1303
|
+
});
|
|
1262
1304
|
function dispose() {
|
|
1263
1305
|
if (referencedKeys.size > 0) {
|
|
1264
1306
|
const store = getEntityStore();
|
|
@@ -1284,11 +1326,25 @@ function query(source, options = {}) {
|
|
|
1284
1326
|
}
|
|
1285
1327
|
inflightKeys.clear();
|
|
1286
1328
|
}
|
|
1329
|
+
function createClearData(meta) {
|
|
1330
|
+
return () => {
|
|
1331
|
+
untrack(() => {
|
|
1332
|
+
entityBacked.value = false;
|
|
1333
|
+
rawData.value = undefined;
|
|
1334
|
+
loading.value = true;
|
|
1335
|
+
});
|
|
1336
|
+
const cacheKey = untrack(() => getCacheKey());
|
|
1337
|
+
cache.delete(cacheKey);
|
|
1338
|
+
const queryKey = customKey ?? meta.entityType;
|
|
1339
|
+
getEntityStore().queryIndices.clear(queryKey);
|
|
1340
|
+
getQueryEnvelopeStore().delete(queryKey);
|
|
1341
|
+
};
|
|
1342
|
+
}
|
|
1287
1343
|
let unsubscribeBus;
|
|
1288
1344
|
let unregisterFromRegistry;
|
|
1289
|
-
if (entityMeta &&
|
|
1345
|
+
if (entityMeta && !isSSR()) {
|
|
1290
1346
|
unsubscribeBus = getMutationEventBus().subscribe(entityMeta.entityType, refetch);
|
|
1291
|
-
unregisterFromRegistry = registerActiveQuery(entityMeta, refetch);
|
|
1347
|
+
unregisterFromRegistry = registerActiveQuery(entityMeta, refetch, createClearData(entityMeta));
|
|
1292
1348
|
}
|
|
1293
1349
|
_tryOnCleanup(dispose);
|
|
1294
1350
|
return {
|
|
@@ -1296,6 +1352,7 @@ function query(source, options = {}) {
|
|
|
1296
1352
|
loading,
|
|
1297
1353
|
revalidating,
|
|
1298
1354
|
error,
|
|
1355
|
+
idle,
|
|
1299
1356
|
refetch,
|
|
1300
1357
|
revalidate: refetch,
|
|
1301
1358
|
dispose
|
|
@@ -1420,4 +1477,4 @@ function queryMatch(queryResult, handlers) {
|
|
|
1420
1477
|
return wrapper;
|
|
1421
1478
|
}
|
|
1422
1479
|
|
|
1423
|
-
export { MemoryCache,
|
|
1480
|
+
export { MemoryCache, deriveKey, FieldSelectionTracker, registerRelationSchema, getRelationSchema, resetRelationSchemas_TEST_ONLY, EntityStore, QueryEnvelopeStore, getEntityStore, getQueryEnvelopeStore, getMutationEventBus, query, queryMatch };
|
|
@@ -188,52 +188,6 @@ function runCleanups(cleanups) {
|
|
|
188
188
|
cleanups.length = 0;
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
-
// src/runtime/tracking.ts
|
|
192
|
-
var currentSubscriber = null;
|
|
193
|
-
var readValueCallback = null;
|
|
194
|
-
function getSubscriber() {
|
|
195
|
-
const ctx = getSSRContext();
|
|
196
|
-
if (ctx)
|
|
197
|
-
return ctx.subscriber;
|
|
198
|
-
return currentSubscriber;
|
|
199
|
-
}
|
|
200
|
-
function setSubscriber(sub) {
|
|
201
|
-
const ctx = getSSRContext();
|
|
202
|
-
if (ctx) {
|
|
203
|
-
const prev2 = ctx.subscriber;
|
|
204
|
-
ctx.subscriber = sub;
|
|
205
|
-
return prev2;
|
|
206
|
-
}
|
|
207
|
-
const prev = currentSubscriber;
|
|
208
|
-
currentSubscriber = sub;
|
|
209
|
-
return prev;
|
|
210
|
-
}
|
|
211
|
-
function getReadValueCallback() {
|
|
212
|
-
const ctx = getSSRContext();
|
|
213
|
-
if (ctx)
|
|
214
|
-
return ctx.readValueCb;
|
|
215
|
-
return readValueCallback;
|
|
216
|
-
}
|
|
217
|
-
function setReadValueCallback(cb) {
|
|
218
|
-
const ctx = getSSRContext();
|
|
219
|
-
if (ctx) {
|
|
220
|
-
const prev2 = ctx.readValueCb;
|
|
221
|
-
ctx.readValueCb = cb;
|
|
222
|
-
return prev2;
|
|
223
|
-
}
|
|
224
|
-
const prev = readValueCallback;
|
|
225
|
-
readValueCallback = cb;
|
|
226
|
-
return prev;
|
|
227
|
-
}
|
|
228
|
-
function untrack(fn) {
|
|
229
|
-
const prev = setSubscriber(null);
|
|
230
|
-
try {
|
|
231
|
-
return fn();
|
|
232
|
-
} finally {
|
|
233
|
-
setSubscriber(prev);
|
|
234
|
-
}
|
|
235
|
-
}
|
|
236
|
-
|
|
237
191
|
// src/runtime/scheduler.ts
|
|
238
192
|
var batchDepth = 0;
|
|
239
193
|
var pendingEffects = new Map;
|
|
@@ -285,6 +239,52 @@ function batch(fn) {
|
|
|
285
239
|
}
|
|
286
240
|
}
|
|
287
241
|
|
|
242
|
+
// src/runtime/tracking.ts
|
|
243
|
+
var currentSubscriber = null;
|
|
244
|
+
var readValueCallback = null;
|
|
245
|
+
function getSubscriber() {
|
|
246
|
+
const ctx = getSSRContext();
|
|
247
|
+
if (ctx)
|
|
248
|
+
return ctx.subscriber;
|
|
249
|
+
return currentSubscriber;
|
|
250
|
+
}
|
|
251
|
+
function setSubscriber(sub) {
|
|
252
|
+
const ctx = getSSRContext();
|
|
253
|
+
if (ctx) {
|
|
254
|
+
const prev2 = ctx.subscriber;
|
|
255
|
+
ctx.subscriber = sub;
|
|
256
|
+
return prev2;
|
|
257
|
+
}
|
|
258
|
+
const prev = currentSubscriber;
|
|
259
|
+
currentSubscriber = sub;
|
|
260
|
+
return prev;
|
|
261
|
+
}
|
|
262
|
+
function getReadValueCallback() {
|
|
263
|
+
const ctx = getSSRContext();
|
|
264
|
+
if (ctx)
|
|
265
|
+
return ctx.readValueCb;
|
|
266
|
+
return readValueCallback;
|
|
267
|
+
}
|
|
268
|
+
function setReadValueCallback(cb) {
|
|
269
|
+
const ctx = getSSRContext();
|
|
270
|
+
if (ctx) {
|
|
271
|
+
const prev2 = ctx.readValueCb;
|
|
272
|
+
ctx.readValueCb = cb;
|
|
273
|
+
return prev2;
|
|
274
|
+
}
|
|
275
|
+
const prev = readValueCallback;
|
|
276
|
+
readValueCallback = cb;
|
|
277
|
+
return prev;
|
|
278
|
+
}
|
|
279
|
+
function untrack(fn) {
|
|
280
|
+
const prev = setSubscriber(null);
|
|
281
|
+
try {
|
|
282
|
+
return fn();
|
|
283
|
+
} finally {
|
|
284
|
+
setSubscriber(prev);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
|
|
288
288
|
// src/hydrate/hydration-context.ts
|
|
289
289
|
var isHydrating = false;
|
|
290
290
|
var currentNode = null;
|
|
@@ -374,7 +374,7 @@ function claimElement(tag) {
|
|
|
374
374
|
while (currentNode) {
|
|
375
375
|
if (currentNode.nodeType === Node.ELEMENT_NODE) {
|
|
376
376
|
const el = currentNode;
|
|
377
|
-
if (el.tagName === upperTag) {
|
|
377
|
+
if (el.tagName.toUpperCase() === upperTag) {
|
|
378
378
|
if (isDebug()) {
|
|
379
379
|
const id = el.id ? `#${el.id}` : "";
|
|
380
380
|
const cls = el.className ? `.${el.className.split(" ")[0]}` : "";
|
|
@@ -716,4 +716,4 @@ function lifecycleEffect(fn) {
|
|
|
716
716
|
return dispose;
|
|
717
717
|
}
|
|
718
718
|
|
|
719
|
-
export { registerSSRResolver, getSSRContext, hasSSRResolver, createContext, useContext, getContextScope, setContextScope,
|
|
719
|
+
export { registerSSRResolver, getSSRContext, hasSSRResolver, createContext, useContext, getContextScope, setContextScope, startHydration, endHydration, discardDeferredEffects, getIsHydrating, pauseHydration, resumeHydration, claimElement, claimText, claimComment, enterChildren, exitChildren, DisposalScopeError, onCleanup, _tryOnCleanup, pushScope, popScope, runCleanups, batch, setReadValueCallback, untrack, startSignalCollection, stopSignalCollection, signal, computed, domEffect, deferredDomEffect, lifecycleEffect };
|