jazz-tools 0.19.7 → 0.19.10
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/.turbo/turbo-build.log +65 -59
- package/CHANGELOG.md +34 -3
- package/dist/{chunk-CUS6O5NE.js → chunk-FFEEPZEG.js} +454 -122
- package/dist/chunk-FFEEPZEG.js.map +1 -0
- package/dist/expo/polyfills.js +22 -0
- package/dist/expo/polyfills.js.map +1 -0
- package/dist/index.js +26 -6
- package/dist/index.js.map +1 -1
- package/dist/react/hooks.d.ts +1 -1
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +5 -1
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts +59 -0
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +133 -34
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/tests/testUtils.d.ts +1 -0
- package/dist/react-core/tests/testUtils.d.ts.map +1 -1
- package/dist/react-core/tests/useSuspenseAccount.test.d.ts +2 -0
- package/dist/react-core/tests/useSuspenseAccount.test.d.ts.map +1 -0
- package/dist/react-core/tests/useSuspenseCoState.test.d.ts +2 -0
- package/dist/react-core/tests/useSuspenseCoState.test.d.ts.map +1 -0
- package/dist/react-core/use.d.ts +3 -0
- package/dist/react-core/use.d.ts.map +1 -0
- package/dist/react-native/index.d.ts +1 -1
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +717 -9
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/polyfills.js +22 -0
- package/dist/react-native/polyfills.js.map +1 -0
- package/dist/react-native-core/crypto/RNCrypto.d.ts +2 -0
- package/dist/react-native-core/crypto/RNCrypto.d.ts.map +1 -0
- package/dist/react-native-core/crypto/RNCrypto.js +3 -0
- package/dist/react-native-core/crypto/RNCrypto.js.map +1 -0
- package/dist/react-native-core/hooks.d.ts +1 -1
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.d.ts.map +1 -1
- package/dist/react-native-core/index.js +5 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/platform.d.ts +2 -1
- package/dist/react-native-core/platform.d.ts.map +1 -1
- package/dist/testing.js +1 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/account.d.ts +3 -3
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +3 -3
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +4 -4
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +7 -7
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +2 -2
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/coVector.d.ts +2 -2
- package/dist/tools/coValues/coVector.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +24 -0
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/group.d.ts +2 -2
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +7 -7
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +2 -2
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/config.d.ts +3 -0
- package/dist/tools/config.d.ts.map +1 -0
- package/dist/tools/exports.d.ts +2 -0
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/ContextManager.d.ts +3 -0
- package/dist/tools/implementation/ContextManager.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +8 -22
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
- package/dist/tools/subscribe/JazzError.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionCache.d.ts +51 -0
- package/dist/tools/subscribe/SubscriptionCache.d.ts.map +1 -0
- package/dist/tools/subscribe/SubscriptionScope.d.ts +27 -2
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/errorReporting.d.ts +31 -0
- package/dist/tools/subscribe/errorReporting.d.ts.map +1 -0
- package/dist/tools/subscribe/utils.d.ts +9 -1
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +2 -2
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/SubscriptionCache.test.d.ts +2 -0
- package/dist/tools/tests/SubscriptionCache.test.d.ts.map +1 -0
- package/dist/tools/tests/errorReporting.test.d.ts +2 -0
- package/dist/tools/tests/errorReporting.test.d.ts.map +1 -0
- package/package.json +22 -7
- package/src/react/hooks.tsx +2 -0
- package/src/react/index.ts +1 -14
- package/src/react-core/hooks.ts +181 -16
- package/src/react-core/tests/createCoValueSubscriptionContext.test.tsx +18 -8
- package/src/react-core/tests/testUtils.tsx +67 -5
- package/src/react-core/tests/useCoState.test.ts +3 -7
- package/src/react-core/tests/useSubscriptionSelector.test.ts +3 -7
- package/src/react-core/tests/useSuspenseAccount.test.tsx +343 -0
- package/src/react-core/tests/useSuspenseCoState.test.tsx +1182 -0
- package/src/react-core/use.ts +46 -0
- package/src/react-native/index.ts +1 -1
- package/src/react-native-core/crypto/RNCrypto.ts +1 -0
- package/src/react-native-core/hooks.tsx +2 -0
- package/src/react-native-core/index.ts +2 -0
- package/src/react-native-core/platform.ts +2 -1
- package/src/react-native-core/polyfills/index.js +28 -0
- package/src/tools/coValues/account.ts +3 -4
- package/src/tools/coValues/coFeed.ts +3 -2
- package/src/tools/coValues/coList.ts +4 -4
- package/src/tools/coValues/coMap.ts +4 -4
- package/src/tools/coValues/coPlainText.ts +2 -2
- package/src/tools/coValues/coVector.ts +2 -2
- package/src/tools/coValues/deepLoading.ts +31 -0
- package/src/tools/coValues/group.ts +2 -2
- package/src/tools/coValues/interfaces.ts +21 -26
- package/src/tools/coValues/schemaUnion.ts +2 -2
- package/src/tools/config.ts +9 -0
- package/src/tools/exports.ts +4 -0
- package/src/tools/implementation/ContextManager.ts +13 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +4 -4
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +4 -4
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +4 -10
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +2 -2
- package/src/tools/subscribe/CoValueCoreSubscription.ts +71 -100
- package/src/tools/subscribe/JazzError.ts +9 -6
- package/src/tools/subscribe/SubscriptionCache.ts +272 -0
- package/src/tools/subscribe/SubscriptionScope.ts +218 -29
- package/src/tools/subscribe/errorReporting.ts +67 -0
- package/src/tools/subscribe/utils.ts +77 -0
- package/src/tools/testing.ts +0 -3
- package/src/tools/tests/CoValueCoreSubscription.test.ts +46 -12
- package/src/tools/tests/ContextManager.test.ts +85 -0
- package/src/tools/tests/SubscriptionCache.test.ts +237 -0
- package/src/tools/tests/coMap.test.ts +5 -7
- package/src/tools/tests/deepLoading.test.ts +47 -47
- package/src/tools/tests/errorReporting.test.ts +103 -0
- package/src/tools/tests/load.test.ts +21 -1
- package/src/tools/tests/request.test.ts +2 -1
- package/src/tools/tests/subscribe.test.ts +44 -0
- package/tsup.config.ts +17 -0
- package/dist/chunk-CUS6O5NE.js.map +0 -1
package/dist/react-core/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
|
|
7
7
|
// src/react-core/hooks.ts
|
|
8
8
|
import { useSyncExternalStoreWithSelector } from "use-sync-external-store/shim/with-selector";
|
|
9
|
-
import
|
|
9
|
+
import React2, {
|
|
10
10
|
useCallback,
|
|
11
11
|
useContext,
|
|
12
12
|
useRef,
|
|
@@ -16,9 +16,8 @@ import {
|
|
|
16
16
|
Account,
|
|
17
17
|
CoValueLoadingState,
|
|
18
18
|
InboxSender,
|
|
19
|
-
SubscriptionScope,
|
|
20
|
-
coValueClassFromCoValueClassOrSchema,
|
|
21
19
|
importContentPieces,
|
|
20
|
+
captureStack,
|
|
22
21
|
getUnloadedCoValueWithoutId
|
|
23
22
|
} from "jazz-tools";
|
|
24
23
|
|
|
@@ -31,6 +30,37 @@ function getCurrentAccountFromContextManager(contextManager) {
|
|
|
31
30
|
return "me" in context ? context.me : context.guest;
|
|
32
31
|
}
|
|
33
32
|
|
|
33
|
+
// src/react-core/use.ts
|
|
34
|
+
import React from "react";
|
|
35
|
+
var attachPromiseStatus = (promise) => {
|
|
36
|
+
if (!promise.status) {
|
|
37
|
+
promise.status = "pending";
|
|
38
|
+
promise.then(
|
|
39
|
+
(v) => {
|
|
40
|
+
promise.status = "fulfilled";
|
|
41
|
+
promise.value = v;
|
|
42
|
+
},
|
|
43
|
+
(e) => {
|
|
44
|
+
promise.status = "rejected";
|
|
45
|
+
promise.reason = e;
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var use = React.use || // A shim for older React versions
|
|
51
|
+
((promise) => {
|
|
52
|
+
if (promise.status === "pending") {
|
|
53
|
+
throw promise;
|
|
54
|
+
} else if (promise.status === "fulfilled") {
|
|
55
|
+
return promise.value;
|
|
56
|
+
} else if (promise.status === "rejected") {
|
|
57
|
+
throw promise.reason;
|
|
58
|
+
} else {
|
|
59
|
+
attachPromiseStatus(promise);
|
|
60
|
+
throw promise;
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
34
64
|
// src/react-core/hooks.ts
|
|
35
65
|
function useJazzContext() {
|
|
36
66
|
const value = useContext(JazzContext);
|
|
@@ -75,6 +105,10 @@ function useIsAuthenticated() {
|
|
|
75
105
|
function useCoValueSubscription(Schema, id, options) {
|
|
76
106
|
const contextManager = useJazzContextManager();
|
|
77
107
|
const agent = useAgent();
|
|
108
|
+
const callerStack = React2.useRef(void 0);
|
|
109
|
+
if (!callerStack.current) {
|
|
110
|
+
callerStack.current = captureStack();
|
|
111
|
+
}
|
|
78
112
|
const createSubscription = () => {
|
|
79
113
|
if (!id) {
|
|
80
114
|
return {
|
|
@@ -94,18 +128,19 @@ function useCoValueSubscription(Schema, id, options) {
|
|
|
94
128
|
}
|
|
95
129
|
const resolve = getResolveQuery(Schema, options?.resolve);
|
|
96
130
|
const node = contextManager.getCurrentValue().node;
|
|
97
|
-
const
|
|
131
|
+
const cache = contextManager.getSubscriptionScopeCache();
|
|
132
|
+
const subscription2 = cache.getOrCreate(
|
|
98
133
|
node,
|
|
99
|
-
|
|
134
|
+
Schema,
|
|
100
135
|
id,
|
|
101
|
-
|
|
102
|
-
ref: coValueClassFromCoValueClassOrSchema(Schema),
|
|
103
|
-
optional: true
|
|
104
|
-
},
|
|
136
|
+
resolve,
|
|
105
137
|
false,
|
|
106
138
|
false,
|
|
107
139
|
options?.unstable_branch
|
|
108
140
|
);
|
|
141
|
+
if (callerStack.current) {
|
|
142
|
+
subscription2.callerStack = callerStack.current;
|
|
143
|
+
}
|
|
109
144
|
return {
|
|
110
145
|
value: subscription2,
|
|
111
146
|
contextManager,
|
|
@@ -116,7 +151,7 @@ function useCoValueSubscription(Schema, id, options) {
|
|
|
116
151
|
agent
|
|
117
152
|
};
|
|
118
153
|
};
|
|
119
|
-
const subscriptionRef =
|
|
154
|
+
const subscriptionRef = React2.useRef(null);
|
|
120
155
|
if (!subscriptionRef.current) {
|
|
121
156
|
subscriptionRef.current = createSubscription();
|
|
122
157
|
}
|
|
@@ -124,7 +159,6 @@ function useCoValueSubscription(Schema, id, options) {
|
|
|
124
159
|
const branchOwnerId = options?.unstable_branch?.owner?.$jazz.id;
|
|
125
160
|
let subscription = subscriptionRef.current;
|
|
126
161
|
if (subscription.contextManager !== contextManager || subscription.id !== id || subscription.Schema !== Schema || subscription.branchName !== branchName || subscription.branchOwnerId !== branchOwnerId || subscription.agent !== agent) {
|
|
127
|
-
subscription.value?.destroy();
|
|
128
162
|
subscriptionRef.current = createSubscription();
|
|
129
163
|
subscription = subscriptionRef.current;
|
|
130
164
|
}
|
|
@@ -155,7 +189,7 @@ function useCoState(Schema, id, options) {
|
|
|
155
189
|
const subscription = useCoValueSubscription(Schema, id, options);
|
|
156
190
|
const getCurrentValue = useGetCurrentValue(subscription);
|
|
157
191
|
const value = useSyncExternalStoreWithSelector(
|
|
158
|
-
|
|
192
|
+
React2.useCallback(
|
|
159
193
|
(callback) => {
|
|
160
194
|
if (!subscription) {
|
|
161
195
|
return () => {
|
|
@@ -172,10 +206,38 @@ function useCoState(Schema, id, options) {
|
|
|
172
206
|
);
|
|
173
207
|
return value;
|
|
174
208
|
}
|
|
209
|
+
function useSuspenseCoState(Schema, id, options) {
|
|
210
|
+
useImportCoValueContent(id, options?.preloaded);
|
|
211
|
+
const subscription = useCoValueSubscription(Schema, id, options);
|
|
212
|
+
if (!subscription) {
|
|
213
|
+
throw new Error("Subscription not found");
|
|
214
|
+
}
|
|
215
|
+
use(subscription.getPromise());
|
|
216
|
+
const getCurrentValue = () => {
|
|
217
|
+
const value2 = subscription.getCurrentValue();
|
|
218
|
+
if (!value2.$isLoaded) {
|
|
219
|
+
throw new Error("CoValue must be loaded in a suspense context");
|
|
220
|
+
}
|
|
221
|
+
return value2;
|
|
222
|
+
};
|
|
223
|
+
const value = useSyncExternalStoreWithSelector(
|
|
224
|
+
React2.useCallback(
|
|
225
|
+
(callback) => {
|
|
226
|
+
return subscription.subscribe(callback);
|
|
227
|
+
},
|
|
228
|
+
[subscription]
|
|
229
|
+
),
|
|
230
|
+
getCurrentValue,
|
|
231
|
+
getCurrentValue,
|
|
232
|
+
options?.select ?? ((value2) => value2),
|
|
233
|
+
options?.equalityFn ?? Object.is
|
|
234
|
+
);
|
|
235
|
+
return value;
|
|
236
|
+
}
|
|
175
237
|
function useSubscriptionSelector(subscription, options) {
|
|
176
238
|
const getCurrentValue = useGetCurrentValue(subscription);
|
|
177
239
|
return useSyncExternalStoreWithSelector(
|
|
178
|
-
|
|
240
|
+
React2.useCallback(
|
|
179
241
|
(callback) => {
|
|
180
242
|
if (!subscription) {
|
|
181
243
|
return () => {
|
|
@@ -193,6 +255,10 @@ function useSubscriptionSelector(subscription, options) {
|
|
|
193
255
|
}
|
|
194
256
|
function useAccountSubscription(Schema, options) {
|
|
195
257
|
const contextManager = useJazzContextManager();
|
|
258
|
+
const callerStack = React2.useRef(void 0);
|
|
259
|
+
if (!callerStack.current) {
|
|
260
|
+
callerStack.current = captureStack();
|
|
261
|
+
}
|
|
196
262
|
const createSubscription = () => {
|
|
197
263
|
const agent = getCurrentAccountFromContextManager(contextManager);
|
|
198
264
|
if (agent.$type$ === "Anonymous") {
|
|
@@ -204,18 +270,19 @@ function useAccountSubscription(Schema, options) {
|
|
|
204
270
|
}
|
|
205
271
|
const resolve = getResolveQuery(Schema, options?.resolve);
|
|
206
272
|
const node = contextManager.getCurrentValue().node;
|
|
207
|
-
const
|
|
273
|
+
const cache = contextManager.getSubscriptionScopeCache();
|
|
274
|
+
const subscription2 = cache.getOrCreate(
|
|
208
275
|
node,
|
|
209
|
-
|
|
276
|
+
Schema,
|
|
210
277
|
agent.$jazz.id,
|
|
211
|
-
|
|
212
|
-
ref: coValueClassFromCoValueClassOrSchema(Schema),
|
|
213
|
-
optional: true
|
|
214
|
-
},
|
|
278
|
+
resolve,
|
|
215
279
|
false,
|
|
216
280
|
false,
|
|
217
281
|
options?.unstable_branch
|
|
218
282
|
);
|
|
283
|
+
if (callerStack.current) {
|
|
284
|
+
subscription2.callerStack = callerStack.current;
|
|
285
|
+
}
|
|
219
286
|
return {
|
|
220
287
|
subscription: subscription2,
|
|
221
288
|
contextManager,
|
|
@@ -224,16 +291,14 @@ function useAccountSubscription(Schema, options) {
|
|
|
224
291
|
branchOwnerId: options?.unstable_branch?.owner?.$jazz.id
|
|
225
292
|
};
|
|
226
293
|
};
|
|
227
|
-
const [subscription, setSubscription] =
|
|
294
|
+
const [subscription, setSubscription] = React2.useState(createSubscription);
|
|
228
295
|
const branchName = options?.unstable_branch?.name;
|
|
229
296
|
const branchOwnerId = options?.unstable_branch?.owner?.$jazz.id;
|
|
230
|
-
|
|
297
|
+
React2.useLayoutEffect(() => {
|
|
231
298
|
if (subscription.contextManager !== contextManager || subscription.Schema !== Schema || subscription.branchName !== options?.unstable_branch?.name || subscription.branchOwnerId !== options?.unstable_branch?.owner?.$jazz.id) {
|
|
232
|
-
subscription.subscription?.destroy();
|
|
233
299
|
setSubscription(createSubscription());
|
|
234
300
|
}
|
|
235
301
|
return contextManager.subscribe(() => {
|
|
236
|
-
subscription.subscription?.destroy();
|
|
237
302
|
setSubscription(createSubscription());
|
|
238
303
|
});
|
|
239
304
|
}, [Schema, contextManager, branchName, branchOwnerId]);
|
|
@@ -243,7 +308,39 @@ function useAccount(AccountSchema = Account, options) {
|
|
|
243
308
|
const subscription = useAccountSubscription(AccountSchema, options);
|
|
244
309
|
const getCurrentValue = useGetCurrentValue(subscription);
|
|
245
310
|
return useSyncExternalStoreWithSelector(
|
|
246
|
-
|
|
311
|
+
React2.useCallback(
|
|
312
|
+
(callback) => {
|
|
313
|
+
if (!subscription) {
|
|
314
|
+
return () => {
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
return subscription.subscribe(callback);
|
|
318
|
+
},
|
|
319
|
+
[subscription]
|
|
320
|
+
),
|
|
321
|
+
getCurrentValue,
|
|
322
|
+
getCurrentValue,
|
|
323
|
+
options?.select ?? ((value) => value),
|
|
324
|
+
options?.equalityFn ?? Object.is
|
|
325
|
+
);
|
|
326
|
+
}
|
|
327
|
+
function useSuspenseAccount(AccountSchema = Account, options) {
|
|
328
|
+
const subscription = useAccountSubscription(AccountSchema, options);
|
|
329
|
+
if (!subscription) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
"Subscription not found, are you using useSuspenseAccount in guest mode?"
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
use(subscription.getPromise());
|
|
335
|
+
const getCurrentValue = () => {
|
|
336
|
+
const value = subscription.getCurrentValue();
|
|
337
|
+
if (!value.$isLoaded) {
|
|
338
|
+
throw new Error("Account must be loaded in a suspense context");
|
|
339
|
+
}
|
|
340
|
+
return value;
|
|
341
|
+
};
|
|
342
|
+
return useSyncExternalStoreWithSelector(
|
|
343
|
+
React2.useCallback(
|
|
247
344
|
(callback) => {
|
|
248
345
|
if (!subscription) {
|
|
249
346
|
return () => {
|
|
@@ -266,7 +363,7 @@ function useLogOut() {
|
|
|
266
363
|
function useAgent() {
|
|
267
364
|
const contextManager = useJazzContextManager();
|
|
268
365
|
const getCurrentValue = () => getCurrentAccountFromContextManager(contextManager);
|
|
269
|
-
return
|
|
366
|
+
return React2.useSyncExternalStore(
|
|
270
367
|
useCallback(
|
|
271
368
|
(callback) => {
|
|
272
369
|
return contextManager.subscribe(callback);
|
|
@@ -330,13 +427,13 @@ function getResolveQuery(Schema, resolveQuery) {
|
|
|
330
427
|
}
|
|
331
428
|
|
|
332
429
|
// src/react-core/subscription-provider.tsx
|
|
333
|
-
import
|
|
430
|
+
import React3 from "react";
|
|
334
431
|
import {
|
|
335
432
|
CoValueLoadingState as CoValueLoadingState2
|
|
336
433
|
} from "jazz-tools";
|
|
337
434
|
import { jsx } from "react/jsx-runtime";
|
|
338
435
|
function createCoValueSubscriptionContext(schema, resolve) {
|
|
339
|
-
const Context =
|
|
436
|
+
const Context = React3.createContext(null);
|
|
340
437
|
return {
|
|
341
438
|
Provider: ({
|
|
342
439
|
id,
|
|
@@ -361,7 +458,7 @@ function createCoValueSubscriptionContext(schema, resolve) {
|
|
|
361
458
|
return /* @__PURE__ */ jsx(Context.Provider, { value: subscription, children });
|
|
362
459
|
},
|
|
363
460
|
useSelector: (options) => {
|
|
364
|
-
const subscription =
|
|
461
|
+
const subscription = React3.useContext(Context);
|
|
365
462
|
if (!subscription) {
|
|
366
463
|
throw new Error(
|
|
367
464
|
"useSelector must be used within a coValue subscription provider"
|
|
@@ -375,7 +472,7 @@ function createCoValueSubscriptionContext(schema, resolve) {
|
|
|
375
472
|
};
|
|
376
473
|
}
|
|
377
474
|
function createAccountSubscriptionContext(schema, resolve) {
|
|
378
|
-
const Context =
|
|
475
|
+
const Context = React3.createContext(null);
|
|
379
476
|
return {
|
|
380
477
|
Provider: ({
|
|
381
478
|
options,
|
|
@@ -399,7 +496,7 @@ function createAccountSubscriptionContext(schema, resolve) {
|
|
|
399
496
|
return /* @__PURE__ */ jsx(Context.Provider, { value: subscription, children });
|
|
400
497
|
},
|
|
401
498
|
useSelector: (options) => {
|
|
402
|
-
const subscription =
|
|
499
|
+
const subscription = React3.useContext(Context);
|
|
403
500
|
if (!subscription) {
|
|
404
501
|
throw new Error(
|
|
405
502
|
"useSelector must be used within an account subscription provider"
|
|
@@ -415,14 +512,14 @@ function createAccountSubscriptionContext(schema, resolve) {
|
|
|
415
512
|
|
|
416
513
|
// src/react-core/auth/DemoAuth.tsx
|
|
417
514
|
import { DemoAuth } from "jazz-tools";
|
|
418
|
-
import { useEffect, useMemo, useState } from "react";
|
|
515
|
+
import { useEffect, useMemo as useMemo2, useState } from "react";
|
|
419
516
|
function useDemoAuth() {
|
|
420
517
|
const context = useJazzContext();
|
|
421
518
|
const authSecretStorage = useAuthSecretStorage();
|
|
422
519
|
if ("guest" in context) {
|
|
423
520
|
throw new Error("Demo auth is not supported in guest mode");
|
|
424
521
|
}
|
|
425
|
-
const authMethod =
|
|
522
|
+
const authMethod = useMemo2(() => {
|
|
426
523
|
return new DemoAuth(context.authenticate, authSecretStorage);
|
|
427
524
|
}, []);
|
|
428
525
|
const isAuthenticated = useIsAuthenticated();
|
|
@@ -445,14 +542,14 @@ function useDemoAuth() {
|
|
|
445
542
|
|
|
446
543
|
// src/react-core/auth/PassphraseAuth.tsx
|
|
447
544
|
import { PassphraseAuth } from "jazz-tools";
|
|
448
|
-
import { useCallback as useCallback2, useMemo as
|
|
545
|
+
import { useCallback as useCallback2, useMemo as useMemo3, useSyncExternalStore as useSyncExternalStore2 } from "react";
|
|
449
546
|
function usePassphraseAuth({ wordlist }) {
|
|
450
547
|
const context = useJazzContext();
|
|
451
548
|
const authSecretStorage = useAuthSecretStorage();
|
|
452
549
|
if ("guest" in context) {
|
|
453
550
|
throw new Error("Passphrase auth is not supported in guest mode");
|
|
454
551
|
}
|
|
455
|
-
const authMethod =
|
|
552
|
+
const authMethod = useMemo3(() => {
|
|
456
553
|
return new PassphraseAuth(
|
|
457
554
|
context.node.crypto,
|
|
458
555
|
context.authenticate,
|
|
@@ -500,6 +597,8 @@ export {
|
|
|
500
597
|
useLogOut,
|
|
501
598
|
usePassphraseAuth,
|
|
502
599
|
useSubscriptionSelector,
|
|
600
|
+
useSuspenseAccount,
|
|
601
|
+
useSuspenseCoState,
|
|
503
602
|
useSyncConnectionStatus
|
|
504
603
|
};
|
|
505
604
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/react-core/hooks.ts","../../src/react-core/utils.ts","../../src/react-core/subscription-provider.tsx","../../src/react-core/auth/DemoAuth.tsx","../../src/react-core/auth/PassphraseAuth.tsx"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from \"use-sync-external-store/shim/with-selector\";\nimport React, {\n useCallback,\n useContext,\n useRef,\n useSyncExternalStore,\n} from \"react\";\n\nimport {\n Account,\n AccountClass,\n AnonymousJazzAgent,\n AnyAccountSchema,\n CoValue,\n CoValueClassOrSchema,\n CoValueLoadingState,\n ExportedCoValue,\n InboxSender,\n InstanceOfSchema,\n JazzContextManager,\n JazzContextType,\n Loaded,\n MaybeLoaded,\n NotLoaded,\n ResolveQuery,\n ResolveQueryStrict,\n SchemaResolveQuery,\n SubscriptionScope,\n coValueClassFromCoValueClassOrSchema,\n importContentPieces,\n getUnloadedCoValueWithoutId,\n type BranchDefinition,\n} from \"jazz-tools\";\nimport { JazzContext, JazzContextManagerContext } from \"./provider.js\";\nimport { getCurrentAccountFromContextManager } from \"./utils.js\";\nimport { CoValueSubscription } from \"./types.js\";\n\nexport function useJazzContext<Acc extends Account>() {\n const value = useContext(JazzContext) as JazzContextType<Acc>;\n\n if (!value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this hook.\",\n );\n }\n\n return value;\n}\n\nexport function useJazzContextManager<Acc extends Account>() {\n const value = useContext(JazzContextManagerContext) as JazzContextManager<\n Acc,\n {}\n >;\n\n if (!value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this hook.\",\n );\n }\n\n return value;\n}\n\nexport function useAuthSecretStorage() {\n const value = useContext(JazzContextManagerContext);\n\n if (!value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this useAuthSecretStorage.\",\n );\n }\n\n return value.getAuthSecretStorage();\n}\n\nexport function useIsAuthenticated() {\n const authSecretStorage = useAuthSecretStorage();\n\n return useSyncExternalStore(\n useCallback(\n (callback) => {\n return authSecretStorage.onUpdate(callback);\n },\n [authSecretStorage],\n ),\n () => authSecretStorage.isAuthenticated,\n () => authSecretStorage.isAuthenticated,\n );\n}\n\nexport function useCoValueSubscription<\n S extends CoValueClassOrSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n>(\n Schema: S,\n id: string | undefined | null,\n options?: {\n resolve?: ResolveQueryStrict<S, R>;\n unstable_branch?: BranchDefinition;\n },\n) {\n const contextManager = useJazzContextManager();\n const agent = useAgent();\n\n const createSubscription = () => {\n if (!id) {\n return {\n subscription: null,\n contextManager,\n id,\n Schema,\n };\n }\n\n if (options?.unstable_branch?.owner === null) {\n return {\n subscription: null,\n contextManager,\n id,\n Schema,\n };\n }\n\n const resolve = getResolveQuery(Schema, options?.resolve);\n\n const node = contextManager.getCurrentValue()!.node;\n const subscription = new SubscriptionScope<any>(\n node,\n resolve,\n id,\n {\n ref: coValueClassFromCoValueClassOrSchema(Schema),\n optional: true,\n },\n false,\n false,\n options?.unstable_branch,\n );\n\n return {\n value: subscription,\n contextManager,\n id,\n Schema,\n branchName: options?.unstable_branch?.name,\n branchOwnerId: options?.unstable_branch?.owner?.$jazz.id,\n agent,\n };\n };\n\n const subscriptionRef = React.useRef<null | ReturnType<\n typeof createSubscription\n >>(null);\n\n if (!subscriptionRef.current) {\n subscriptionRef.current = createSubscription();\n }\n\n const branchName = options?.unstable_branch?.name;\n const branchOwnerId = options?.unstable_branch?.owner?.$jazz.id;\n\n let subscription = subscriptionRef.current;\n\n // Check if the subscription needs to be updated\n // because one of the dependencies has changed\n if (\n subscription.contextManager !== contextManager ||\n subscription.id !== id ||\n subscription.Schema !== Schema ||\n subscription.branchName !== branchName ||\n subscription.branchOwnerId !== branchOwnerId ||\n subscription.agent !== agent\n ) {\n subscription.value?.destroy();\n subscriptionRef.current = createSubscription();\n subscription = subscriptionRef.current;\n }\n\n // Subscribe to the context manager to react to auth changes\n return subscription.value as CoValueSubscription<S, R>;\n}\n\nfunction useImportCoValueContent<V>(\n id: string | undefined | null,\n content?: ExportedCoValue<V>,\n) {\n const agent = useAgent();\n const preloadExecuted = useRef<typeof agent | null>(null);\n if (content && preloadExecuted.current !== agent && id) {\n if (content.id === id) {\n importContentPieces(content.contentPieces, agent);\n } else {\n console.warn(\"Preloaded value ID does not match the subscription ID\");\n }\n\n preloadExecuted.current = agent;\n }\n}\n\nfunction useGetCurrentValue<C extends CoValue>(\n subscription: SubscriptionScope<C> | null,\n) {\n return useCallback(() => {\n if (!subscription) {\n return getUnloadedCoValueWithoutId(CoValueLoadingState.UNAVAILABLE);\n }\n\n return subscription.getCurrentValue();\n }, [subscription]);\n}\n\n/**\n * React hook for subscribing to CoValues and handling loading states.\n *\n * This hook provides a convenient way to subscribe to CoValues and automatically\n * handles the subscription lifecycle (subscribe on mount, unsubscribe on unmount).\n * It also supports deep loading of nested CoValues through resolve queries.\n *\n * The {@param options.select} function allows returning only specific parts of the CoValue data,\n * which helps reduce unnecessary re-renders by narrowing down the returned data.\n * Additionally, you can provide a custom {@param options.equalityFn} to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * @returns The loaded CoValue, or an {@link NotLoaded} value. Use `$isLoaded` to check whether the\n * CoValue is loaded, or use {@link MaybeLoaded.$jazz.loadingState} to get the detailed loading state.\n * If a selector function is provided, returns the result of the selector function.\n *\n * @example\n * ```tsx\n * // Select only specific fields to reduce re-renders\n * const Project = co.map({\n * name: z.string(),\n * description: z.string(),\n * tasks: co.list(Task),\n * lastModified: z.date(),\n * });\n *\n * function ProjectTitle({ projectId }: { projectId: string }) {\n * // Only re-render when the project name changes, not other fields\n * const projectName = useCoState(\n * Project,\n * projectId,\n * {\n * select: (project) => !project.$isLoading ? project.name : \"Loading...\",\n * }\n * );\n *\n * return <h1>{projectName}</h1>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Deep loading with resolve queries\n * const Project = co.map({\n * name: z.string(),\n * tasks: co.list(Task),\n * owner: TeamMember,\n * });\n *\n * function ProjectView({ projectId }: { projectId: string }) {\n * const project = useCoState(Project, projectId, {\n * resolve: {\n * tasks: { $each: true },\n * owner: true,\n * },\n * });\n *\n * if (!project.$isLoaded) {\n * switch (project.$jazz.loadingState) {\n * case \"unauthorized\":\n * return \"Project not accessible\";\n * case \"unavailable\":\n * return \"Project not found\";\n * case \"loading\":\n * return \"Loading project...\";\n * }\n * }\n *\n * return (\n * <div>\n * <h1>{project.name}</h1>\n * <p>Owner: {project.owner.name}</p>\n * <ul>\n * {project.tasks.map((task) => (\n * <li key={task.id}>{task.title}</li>\n * ))}\n * </ul>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Using with optional references and error handling\n * const Task = co.map({\n * title: z.string(),\n * assignee: co.optional(TeamMember),\n * subtasks: co.list(Task),\n * });\n *\n * function TaskDetail({ taskId }: { taskId: string }) {\n * const task = useCoState(Task, taskId, {\n * resolve: {\n * assignee: true,\n * subtasks: { $each: { $onError: 'catch' } },\n * },\n * });\n *\n * if (!task.$isLoaded) {\n * switch (task.$jazz.loadingState) {\n * case \"unauthorized\":\n * return \"Task not accessible\";\n * case \"unavailable\":\n * return \"Task not found\";\n * case \"loading\":\n * return \"Loading task...\";\n * }\n * }\n *\n * return (\n * <div>\n * <h2>{task.title}</h2>\n * {task.assignee && <p>Assigned to: {task.assignee.name}</p>}\n * <ul>\n * {task.subtasks.map((subtask, index) => (\n * subtask.$isLoaded ? <li key={subtask.id}>{subtask.title}</li> : <li key={index}>Inaccessible subtask</li>\n * ))}\n * </ul>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Use custom equality function for complex data structures\n * const TaskList = co.list(Task);\n *\n * function TaskCount({ listId }: { listId: string }) {\n * const taskStats = useCoState(\n * TaskList,\n * listId,\n * {\n * resolve: { $each: true },\n * select: (tasks) => {\n * if (!tasks.$isLoaded) return { total: 0, completed: 0 };\n * return {\n * total: tasks.length,\n * completed: tasks.filter(task => task.completed).length,\n * };\n * },\n * // Custom equality to prevent re-renders when stats haven't changed\n * equalityFn: (a, b) => a.total === b.total && a.completed === b.completed,\n * }\n * );\n *\n * return (\n * <div>\n * {taskStats.completed} of {taskStats.total} tasks completed\n * </div>\n * );\n * }\n * ```\n *\n * For more examples, see the [subscription and deep loading](https://jazz.tools/docs/react/using-covalues/subscription-and-loading) documentation.\n */\nexport function useCoState<\n S extends CoValueClassOrSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n TSelectorReturn = MaybeLoaded<Loaded<S, R>>,\n>(\n /** The CoValue schema or class constructor */\n Schema: S,\n /** The ID of the CoValue to subscribe to. If `undefined`, returns an `unavailable` value */\n id: string | undefined,\n /** Optional configuration for the subscription */\n options?: {\n /** Resolve query to specify which nested CoValues to load */\n resolve?: ResolveQueryStrict<S, R>;\n /** Select which value to return */\n select?: (value: MaybeLoaded<Loaded<S, R>>) => TSelectorReturn;\n /** Equality function to determine if the selected value has changed, defaults to `Object.is` */\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n /**\n * Create or load a branch for isolated editing.\n *\n * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.\n * It's a fork of your data graph: the same schema, but with diverging values.\n *\n * The checkout of the branch is applied on all the resolved values.\n *\n * @param name - A unique name for the branch. This identifies the branch\n * and can be used to switch between different branches of the same CoValue.\n * @param owner - The owner of the branch. Determines who can access and modify\n * the branch. If not provided, the branch is owned by the current user.\n *\n * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.\n */\n unstable_branch?: BranchDefinition;\n preloaded?: ExportedCoValue<Loaded<S, R>>;\n },\n): TSelectorReturn {\n useImportCoValueContent(id, options?.preloaded);\n\n const subscription = useCoValueSubscription(Schema, id, options);\n const getCurrentValue = useGetCurrentValue(subscription);\n\n const value = useSyncExternalStoreWithSelector<\n MaybeLoaded<Loaded<S, R>>,\n TSelectorReturn\n >(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n\n return value;\n}\n\nexport function useSubscriptionSelector<\n S extends CoValueClassOrSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n TSelectorReturn = MaybeLoaded<Loaded<S, R>>,\n>(\n subscription: CoValueSubscription<S, R>,\n options?: {\n select?: (value: MaybeLoaded<Loaded<S, R>>) => TSelectorReturn;\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n },\n) {\n const getCurrentValue = useGetCurrentValue(subscription);\n\n return useSyncExternalStoreWithSelector<\n MaybeLoaded<Loaded<S, R>>,\n TSelectorReturn\n >(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n}\n\nexport function useAccountSubscription<\n S extends AccountClass<Account> | AnyAccountSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n>(\n Schema: S,\n options?: {\n resolve?: ResolveQueryStrict<S, R>;\n unstable_branch?: BranchDefinition;\n },\n) {\n const contextManager = useJazzContextManager();\n\n const createSubscription = () => {\n const agent = getCurrentAccountFromContextManager(contextManager);\n\n if (agent.$type$ === \"Anonymous\") {\n return {\n subscription: null,\n contextManager,\n agent,\n };\n }\n\n const resolve = getResolveQuery(Schema, options?.resolve);\n\n const node = contextManager.getCurrentValue()!.node;\n const subscription = new SubscriptionScope<any>(\n node,\n resolve,\n agent.$jazz.id,\n {\n ref: coValueClassFromCoValueClassOrSchema(Schema),\n optional: true,\n },\n false,\n false,\n options?.unstable_branch,\n );\n\n return {\n subscription,\n contextManager,\n Schema,\n branchName: options?.unstable_branch?.name,\n branchOwnerId: options?.unstable_branch?.owner?.$jazz.id,\n };\n };\n\n const [subscription, setSubscription] = React.useState(createSubscription);\n\n const branchName = options?.unstable_branch?.name;\n const branchOwnerId = options?.unstable_branch?.owner?.$jazz.id;\n\n React.useLayoutEffect(() => {\n if (\n subscription.contextManager !== contextManager ||\n subscription.Schema !== Schema ||\n subscription.branchName !== options?.unstable_branch?.name ||\n subscription.branchOwnerId !== options?.unstable_branch?.owner?.$jazz.id\n ) {\n subscription.subscription?.destroy();\n setSubscription(createSubscription());\n }\n\n return contextManager.subscribe(() => {\n subscription.subscription?.destroy();\n setSubscription(createSubscription());\n });\n }, [Schema, contextManager, branchName, branchOwnerId]);\n\n return subscription.subscription as CoValueSubscription<S, R>;\n}\n\n/**\n * React hook for accessing the current user's account.\n *\n * This hook provides access to the current user's account profile and root data.\n * It automatically handles the subscription lifecycle and supports deep loading of nested\n * CoValues through resolve queries.\n *\n * The {@param options.select} function allows returning only specific parts of the account data,\n * which helps reduce unnecessary re-renders by narrowing down the returned data.\n * Additionally, you can provide a custom {@param options.equalityFn} to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * @returns The account data, or an {@link NotLoaded} value. Use `$isLoaded` to check whether the\n * CoValue is loaded, or use {@link MaybeLoaded.$jazz.loadingState} to get the detailed loading state.\n * If a selector function is provided, returns the result of the selector function.\n *\n * @example\n * ```tsx\n * // Select only specific fields to reduce re-renders\n * const MyAppAccount = co.account({\n * profile: co.profile(),\n * root: co.map({\n * name: z.string(),\n * email: z.string(),\n * lastLogin: z.date(),\n * }),\n * });\n *\n * function UserProfile({ accountId }: { accountId: string }) {\n * // Only re-render when the profile name changes, not other fields\n * const profileName = useAccount(\n * MyAppAccount,\n * {\n * resolve: {\n * profile: true,\n * root: true,\n * },\n * select: (account) => account.$isLoaded ? account.profile.name : \"Loading...\",\n * }\n * );\n *\n * return <h1>{profileName}</h1>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Deep loading with resolve queries\n * function ProjectListWithDetails() {\n * const me = useAccount(MyAppAccount, {\n * resolve: {\n * profile: true,\n * root: {\n * myProjects: {\n * $each: {\n * tasks: true,\n * },\n * },\n * },\n * },\n * });\n *\n * if (!me.$isLoaded) {\n * switch (me.$jazz.loadingState) {\n * case \"unauthorized\":\n * return \"Account not accessible\";\n * case \"unavailable\":\n * return \"Account not found\";\n * case \"loading\":\n * return \"Loading account...\";\n * }\n * }\n *\n * return (\n * <div>\n * <h1>{me.profile.name}'s projects</h1>\n * <ul>\n * {me.root.myProjects.map((project) => (\n * <li key={project.id}>\n * {project.name} ({project.tasks.length} tasks)\n * </li>\n * ))}\n * </ul>\n * </div>\n * );\n * }\n * ```\n *\n */\nexport function useAccount<\n A extends AccountClass<Account> | AnyAccountSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<A> = SchemaResolveQuery<A>,\n TSelectorReturn = MaybeLoaded<Loaded<A, R>>,\n>(\n /** The account schema to use. Defaults to the base Account schema */\n AccountSchema: A = Account as unknown as A,\n /** Optional configuration for the subscription */\n options?: {\n /** Resolve query to specify which nested CoValues to load from the account */\n resolve?: ResolveQueryStrict<A, R>;\n /** Select which value to return from the account data */\n select?: (account: MaybeLoaded<Loaded<A, R>>) => TSelectorReturn;\n /** Equality function to determine if the selected value has changed, defaults to `Object.is` */\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n /**\n * Create or load a branch for isolated editing.\n *\n * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.\n * It's a fork of your data graph: the same schema, but with diverging values.\n *\n * The checkout of the branch is applied on all the resolved values.\n *\n * @param name - A unique name for the branch. This identifies the branch\n * and can be used to switch between different branches of the same CoValue.\n * @param owner - The owner of the branch. Determines who can access and modify\n * the branch. If not provided, the branch is owned by the current user.\n *\n * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.\n */\n unstable_branch?: BranchDefinition;\n },\n): TSelectorReturn {\n const subscription = useAccountSubscription(AccountSchema, options);\n const getCurrentValue = useGetCurrentValue(subscription);\n\n return useSyncExternalStoreWithSelector<\n MaybeLoaded<Loaded<A, R>>,\n TSelectorReturn\n >(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n}\n\n/**\n * Returns a function for logging out of the current account.\n */\nexport function useLogOut(): () => void {\n const contextManager = useJazzContextManager();\n return contextManager.logOut;\n}\n\n/**\n * React hook for accessing the current agent. An agent can either be:\n * - an Authenticated Account, if the user is logged in\n * - an Anonymous Account, if the user didn't log in\n * - or an anonymous agent, if in guest mode\n *\n * The agent can be used as the `loadAs` parameter for load and subscribe methods.\n */\nexport function useAgent<\n A extends AccountClass<Account> | AnyAccountSchema = typeof Account,\n>(): AnonymousJazzAgent | Loaded<A, true> {\n const contextManager = useJazzContextManager<InstanceOfSchema<A>>();\n\n const getCurrentValue = () =>\n getCurrentAccountFromContextManager(contextManager) as\n | AnonymousJazzAgent\n | Loaded<A, true>;\n\n return React.useSyncExternalStore(\n useCallback(\n (callback) => {\n return contextManager.subscribe(callback);\n },\n [contextManager],\n ),\n getCurrentValue,\n getCurrentValue,\n );\n}\n\nexport function experimental_useInboxSender<\n I extends CoValue,\n O extends CoValue | undefined,\n>(inboxOwnerID: string | undefined) {\n const context = useJazzContext();\n\n if (!(\"me\" in context)) {\n throw new Error(\n \"useInboxSender can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n const me = context.me;\n const inboxRef = useRef<Promise<InboxSender<I, O>> | undefined>(undefined);\n\n const sendMessage = useCallback(\n async (message: I) => {\n if (!inboxOwnerID) throw new Error(\"Inbox owner ID is required\");\n\n if (!inboxRef.current) {\n const inbox = InboxSender.load<I, O>(inboxOwnerID, me);\n inboxRef.current = inbox;\n }\n\n let inbox = await inboxRef.current;\n\n // Regenerate the InboxSender if the inbox owner or current account changes\n if (inbox.owner.id !== inboxOwnerID || inbox.currentAccount !== me) {\n const req = InboxSender.load<I, O>(inboxOwnerID, me);\n inboxRef.current = req;\n inbox = await req;\n }\n\n return inbox.sendMessage(message);\n },\n [inboxOwnerID, me.$jazz.id],\n );\n\n return sendMessage;\n}\n\n/**\n * Hook that returns the current connection status to the Jazz sync server.\n *\n * @returns `true` when connected to the server, `false` when disconnected\n *\n * @remarks\n * On connection drop, this hook will return `false` only when Jazz detects the disconnection\n * after 5 seconds of not receiving a ping from the server.\n */\nexport function useSyncConnectionStatus() {\n const context = useJazzContext();\n\n const connected = useSyncExternalStore(\n useCallback(\n (callback) => {\n return context.addConnectionListener(callback);\n },\n [context],\n ),\n () => context.connected(),\n () => context.connected(),\n );\n\n return connected;\n}\n\nfunction getResolveQuery(\n Schema: CoValueClassOrSchema,\n // We don't need type validation here, since this is an internal API\n resolveQuery?: ResolveQuery<any>,\n): ResolveQuery<any> {\n if (resolveQuery) {\n return resolveQuery;\n }\n // Check the schema is a CoValue schema (and not a CoValue class)\n if (\"resolveQuery\" in Schema) {\n return Schema.resolveQuery;\n }\n return true;\n}\n","import { Account, JazzContextManager } from \"jazz-tools\";\n\nexport function getCurrentAccountFromContextManager<Acc extends Account>(\n contextManager: JazzContextManager<Acc, any>,\n) {\n const context = contextManager.getCurrentValue();\n\n if (!context) {\n throw new Error(\"No context found\");\n }\n\n return \"me\" in context ? context.me : context.guest;\n}\n\nexport function subscribeToContextManager<Acc extends Account>(\n contextManager: JazzContextManager<Acc, any>,\n callback: () => () => void,\n) {\n let unsub = () => {};\n\n const handler = () => {\n unsub();\n unsub = callback();\n };\n\n handler();\n return contextManager.subscribe(handler);\n}\n","import React from \"react\";\nimport {\n Account,\n AccountClass,\n AnyAccountSchema,\n CoValueClassOrSchema,\n CoValueLoadingState,\n Loaded,\n MaybeLoaded,\n ResolveQuery,\n ResolveQueryStrict,\n} from \"jazz-tools\";\nimport {\n useAccountSubscription,\n useCoValueSubscription,\n useSubscriptionSelector,\n} from \"./hooks.js\";\nimport type { CoValueSubscription } from \"./types.js\";\n\nexport function createCoValueSubscriptionContext<\n S extends CoValueClassOrSchema,\n const R extends ResolveQuery<S> = true,\n>(schema: S, resolve?: ResolveQueryStrict<S, R>) {\n const Context = React.createContext<CoValueSubscription<S, R>>(null);\n\n return {\n Provider: ({\n id,\n options,\n loadingFallback,\n unavailableFallback,\n children,\n }: React.PropsWithChildren<{\n id: string | undefined | null;\n options?: Omit<\n Parameters<typeof useCoValueSubscription<S, R>>[2],\n \"resolve\"\n >;\n loadingFallback?: React.ReactNode;\n unavailableFallback?: React.ReactNode;\n }>) => {\n const subscription = useCoValueSubscription(schema, id, {\n ...options,\n resolve: resolve,\n });\n\n const loadState = useSubscriptionSelector(subscription, {\n select: (value) => value.$jazz.loadingState,\n });\n\n if (loadState === CoValueLoadingState.LOADING) {\n return loadingFallback ?? null;\n }\n if (\n loadState === CoValueLoadingState.UNAUTHORIZED ||\n loadState === CoValueLoadingState.UNAVAILABLE\n ) {\n return unavailableFallback ?? null;\n }\n\n return (\n <Context.Provider value={subscription}>{children}</Context.Provider>\n );\n },\n useSelector: <TSelectorReturn = Loaded<S, R>>(options?: {\n select?: (value: Loaded<S, R>) => TSelectorReturn;\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n }) => {\n const subscription = React.useContext(Context);\n\n if (!subscription) {\n throw new Error(\n \"useSelector must be used within a coValue subscription provider\",\n );\n }\n\n return useSubscriptionSelector<S, R, TSelectorReturn>(\n subscription,\n options as Parameters<\n typeof useSubscriptionSelector<S, R, TSelectorReturn>\n >[1],\n );\n },\n };\n}\n\nexport function createAccountSubscriptionContext<\n A extends AccountClass<Account> | AnyAccountSchema,\n const R extends ResolveQuery<A> = true,\n>(schema: A, resolve?: ResolveQueryStrict<A, R>) {\n const Context = React.createContext<CoValueSubscription<A, R>>(null);\n\n return {\n Provider: ({\n options,\n loadingFallback,\n unavailableFallback,\n children,\n }: React.PropsWithChildren<{\n options?: Omit<\n Parameters<typeof useAccountSubscription<A, R>>[1],\n \"resolve\"\n >;\n loadingFallback?: React.ReactNode;\n unavailableFallback?: React.ReactNode;\n }>) => {\n const subscription = useAccountSubscription(schema, {\n ...options,\n resolve: resolve,\n });\n\n const loadState = useSubscriptionSelector(subscription, {\n select: (value) => value.$jazz.loadingState,\n });\n\n if (loadState === CoValueLoadingState.LOADING) {\n return loadingFallback ?? null;\n }\n\n if (\n loadState === CoValueLoadingState.UNAUTHORIZED ||\n loadState === CoValueLoadingState.UNAVAILABLE\n ) {\n return unavailableFallback ?? null;\n }\n\n return (\n <Context.Provider value={subscription}>{children}</Context.Provider>\n );\n },\n useSelector: <TSelectorReturn = Loaded<A, R>>(options?: {\n select?: (value: Loaded<A, R>) => TSelectorReturn;\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n }) => {\n const subscription = React.useContext(Context);\n\n if (!subscription) {\n throw new Error(\n \"useSelector must be used within an account subscription provider\",\n );\n }\n\n return useSubscriptionSelector<A, R, TSelectorReturn>(\n subscription,\n options as Parameters<\n typeof useSubscriptionSelector<A, R, TSelectorReturn>\n >[1],\n );\n },\n };\n}\n","import { DemoAuth } from \"jazz-tools\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useAuthSecretStorage, useJazzContext } from \"../hooks.js\";\nimport { useIsAuthenticated } from \"../hooks.js\";\n\n/**\n * `useDemoAuth` is a hook that provides a `JazzAuth` object for demo authentication.\n *\n *\n * ```ts\n * const { state, logIn, signUp, existingUsers } = useDemoAuth();\n * ```\n *\n * @category Auth Providers\n */\nexport function useDemoAuth() {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n\n if (\"guest\" in context) {\n throw new Error(\"Demo auth is not supported in guest mode\");\n }\n\n const authMethod = useMemo(() => {\n return new DemoAuth(context.authenticate, authSecretStorage);\n }, []);\n\n const isAuthenticated = useIsAuthenticated();\n const [existingUsers, setExistingUsers] = useState<string[]>([]);\n\n useEffect(() => {\n authMethod.getExistingUsers().then(setExistingUsers);\n }, [authMethod]);\n\n function handleSignUp(username: string) {\n return authMethod.signUp(username).then(() => {\n setExistingUsers(existingUsers.concat([username]));\n });\n }\n\n return {\n state: isAuthenticated ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.logIn,\n signUp: handleSignUp,\n existingUsers,\n } as const;\n}\n","import { PassphraseAuth } from \"jazz-tools\";\nimport { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport { useAuthSecretStorage, useJazzContext } from \"../hooks.js\";\nimport { useIsAuthenticated } from \"../hooks.js\";\n\n/**\n * `usePassphraseAuth` hook provides a `JazzAuth` object for passphrase authentication.\n *\n * @example\n * ```ts\n * const auth = usePassphraseAuth({ appName, appHostname, wordlist });\n * ```\n *\n * @category Auth Providers\n */\nexport function usePassphraseAuth({ wordlist }: { wordlist: string[] }) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n\n if (\"guest\" in context) {\n throw new Error(\"Passphrase auth is not supported in guest mode\");\n }\n\n const authMethod = useMemo(() => {\n return new PassphraseAuth(\n context.node.crypto,\n context.authenticate,\n context.register,\n authSecretStorage,\n wordlist,\n );\n }, [wordlist]);\n\n const passphrase = useSyncExternalStore(\n useCallback(\n (callback) => {\n authMethod.loadCurrentAccountPassphrase();\n return authMethod.subscribe(callback);\n },\n [authMethod],\n ),\n () => authMethod.passphrase,\n );\n\n const isAuthenticated = useIsAuthenticated();\n return {\n state: isAuthenticated ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.logIn,\n signUp: authMethod.signUp,\n registerNewAccount: authMethod.registerNewAccount,\n generateRandomPassphrase: authMethod.generateRandomPassphrase,\n passphrase,\n } as const;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,wCAAwC;AACjD,OAAO;AAAA,EACL;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EAMA;AAAA,EAEA;AAAA,EAUA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;AC9BA,SAAS,oCACd,gBACA;AACA,QAAM,UAAU,eAAe,gBAAgB;AAE/C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kBAAkB;AAAA,EACpC;AAEA,SAAO,QAAQ,UAAU,QAAQ,KAAK,QAAQ;AAChD;;;ADyBO,SAAS,iBAAsC;AACpD,QAAM,QAAQ,WAAW,WAAW;AAEpC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;A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;AAC/B,SAAS,eAAAE,cAAa,WAAAC,UAAS,wBAAAC,6BAA4B;AAcpD,SAAS,kBAAkB,EAAE,SAAS,GAA2B;AACtE,QAAM,UAAU,eAAe;AAC/B,QAAM,oBAAoB,qBAAqB;AAE/C,MAAI,WAAW,SAAS;AACtB,UAAM,IAAI,MAAM,gDAAgD;AAAA,EAClE;AAEA,QAAM,aAAaC,SAAQ,MAAM;AAC/B,WAAO,IAAI;AAAA,MACT,QAAQ,KAAK;AAAA,MACb,QAAQ;AAAA,MACR,QAAQ;AAAA,MACR;AAAA,MACA;AAAA,IACF;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAEb,QAAM,aAAaC;AAAA,IACjBC;AAAA,MACE,CAAC,aAAa;AACZ,mBAAW,6BAA6B;AACxC,eAAO,WAAW,UAAU,QAAQ;AAAA,MACtC;AAAA,MACA,CAAC,UAAU;AAAA,IACb;AAAA,IACA,MAAM,WAAW;AAAA,EACnB;AAEA,QAAM,kBAAkB,mBAAmB;AAC3C,SAAO;AAAA,IACL,OAAO,kBAAkB,aAAa;AAAA,IACtC,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW;AAAA,IACnB,oBAAoB,WAAW;AAAA,IAC/B,0BAA0B,WAAW;AAAA,IACrC;AAAA,EACF;AACF;","names":["subscription","value","inbox","React","CoValueLoadingState","React","CoValueLoadingState","useCallback","useMemo","useSyncExternalStore","useMemo","useSyncExternalStore","useCallback"]}
|
|
1
|
+
{"version":3,"sources":["../../src/react-core/hooks.ts","../../src/react-core/utils.ts","../../src/react-core/use.ts","../../src/react-core/subscription-provider.tsx","../../src/react-core/auth/DemoAuth.tsx","../../src/react-core/auth/PassphraseAuth.tsx"],"sourcesContent":["import { useSyncExternalStoreWithSelector } from \"use-sync-external-store/shim/with-selector\";\nimport React, {\n useCallback,\n useContext,\n useMemo,\n useRef,\n useSyncExternalStore,\n} from \"react\";\n\nimport {\n Account,\n AccountClass,\n AnonymousJazzAgent,\n AnyAccountSchema,\n CoValue,\n CoValueClassOrSchema,\n CoValueLoadingState,\n ExportedCoValue,\n InboxSender,\n InstanceOfSchema,\n JazzContextManager,\n JazzContextType,\n Loaded,\n MaybeLoaded,\n NotLoaded,\n RefsToResolve,\n ResolveQuery,\n ResolveQueryStrict,\n SchemaResolveQuery,\n SubscriptionScope,\n importContentPieces,\n captureStack,\n getUnloadedCoValueWithoutId,\n type BranchDefinition,\n} from \"jazz-tools\";\nimport { JazzContext, JazzContextManagerContext } from \"./provider.js\";\nimport { getCurrentAccountFromContextManager } from \"./utils.js\";\nimport { CoValueSubscription } from \"./types.js\";\nimport { use } from \"./use.js\";\n\nexport function useJazzContext<Acc extends Account>() {\n const value = useContext(JazzContext) as JazzContextType<Acc>;\n\n if (!value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this hook.\",\n );\n }\n\n return value;\n}\n\nexport function useJazzContextManager<Acc extends Account>() {\n const value = useContext(JazzContextManagerContext) as JazzContextManager<\n Acc,\n {}\n >;\n\n if (!value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this hook.\",\n );\n }\n\n return value;\n}\n\nexport function useAuthSecretStorage() {\n const value = useContext(JazzContextManagerContext);\n\n if (!value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this useAuthSecretStorage.\",\n );\n }\n\n return value.getAuthSecretStorage();\n}\n\nexport function useIsAuthenticated() {\n const authSecretStorage = useAuthSecretStorage();\n\n return useSyncExternalStore(\n useCallback(\n (callback) => {\n return authSecretStorage.onUpdate(callback);\n },\n [authSecretStorage],\n ),\n () => authSecretStorage.isAuthenticated,\n () => authSecretStorage.isAuthenticated,\n );\n}\n\nexport function useCoValueSubscription<\n S extends CoValueClassOrSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n>(\n Schema: S,\n id: string | undefined | null,\n options?: {\n resolve?: ResolveQueryStrict<S, R>;\n unstable_branch?: BranchDefinition;\n },\n) {\n const contextManager = useJazzContextManager();\n const agent = useAgent();\n\n const callerStack = React.useRef<Error | undefined>(undefined);\n\n if (!callerStack.current) {\n callerStack.current = captureStack();\n }\n\n const createSubscription = () => {\n if (!id) {\n return {\n subscription: null,\n contextManager,\n id,\n Schema,\n };\n }\n\n if (options?.unstable_branch?.owner === null) {\n return {\n subscription: null,\n contextManager,\n id,\n Schema,\n };\n }\n\n const resolve = getResolveQuery(Schema, options?.resolve);\n\n const node = contextManager.getCurrentValue()!.node;\n const cache = contextManager.getSubscriptionScopeCache();\n const subscription = cache.getOrCreate(\n node,\n Schema,\n id,\n resolve,\n false,\n false,\n options?.unstable_branch,\n );\n\n // Set callerStack on returned subscription after retrieval\n if (callerStack.current) {\n subscription.callerStack = callerStack.current;\n }\n\n return {\n value: subscription,\n contextManager,\n id,\n Schema,\n branchName: options?.unstable_branch?.name,\n branchOwnerId: options?.unstable_branch?.owner?.$jazz.id,\n agent,\n };\n };\n\n const subscriptionRef = React.useRef<null | ReturnType<\n typeof createSubscription\n >>(null);\n\n if (!subscriptionRef.current) {\n subscriptionRef.current = createSubscription();\n }\n\n const branchName = options?.unstable_branch?.name;\n const branchOwnerId = options?.unstable_branch?.owner?.$jazz.id;\n\n let subscription = subscriptionRef.current;\n\n // Check if the subscription needs to be updated\n // because one of the dependencies has changed\n if (\n subscription.contextManager !== contextManager ||\n subscription.id !== id ||\n subscription.Schema !== Schema ||\n subscription.branchName !== branchName ||\n subscription.branchOwnerId !== branchOwnerId ||\n subscription.agent !== agent\n ) {\n subscriptionRef.current = createSubscription();\n subscription = subscriptionRef.current;\n }\n\n // Subscribe to the context manager to react to auth changes\n return subscription.value as CoValueSubscription<S, R>;\n}\n\nfunction useImportCoValueContent<V>(\n id: string | undefined | null,\n content?: ExportedCoValue<V>,\n) {\n const agent = useAgent();\n const preloadExecuted = useRef<typeof agent | null>(null);\n if (content && preloadExecuted.current !== agent && id) {\n if (content.id === id) {\n importContentPieces(content.contentPieces, agent);\n } else {\n console.warn(\"Preloaded value ID does not match the subscription ID\");\n }\n\n preloadExecuted.current = agent;\n }\n}\n\nfunction useGetCurrentValue<C extends CoValue>(\n subscription: SubscriptionScope<C> | null,\n) {\n return useCallback(() => {\n if (!subscription) {\n return getUnloadedCoValueWithoutId(CoValueLoadingState.UNAVAILABLE);\n }\n\n return subscription.getCurrentValue();\n }, [subscription]);\n}\n\n/**\n * React hook for subscribing to CoValues and handling loading states.\n *\n * This hook provides a convenient way to subscribe to CoValues and automatically\n * handles the subscription lifecycle (subscribe on mount, unsubscribe on unmount).\n * It also supports deep loading of nested CoValues through resolve queries.\n *\n * The {@param options.select} function allows returning only specific parts of the CoValue data,\n * which helps reduce unnecessary re-renders by narrowing down the returned data.\n * Additionally, you can provide a custom {@param options.equalityFn} to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * @returns The loaded CoValue, or an {@link NotLoaded} value. Use `$isLoaded` to check whether the\n * CoValue is loaded, or use {@link MaybeLoaded.$jazz.loadingState} to get the detailed loading state.\n * If a selector function is provided, returns the result of the selector function.\n *\n * @example\n * ```tsx\n * // Select only specific fields to reduce re-renders\n * const Project = co.map({\n * name: z.string(),\n * description: z.string(),\n * tasks: co.list(Task),\n * lastModified: z.date(),\n * });\n *\n * function ProjectTitle({ projectId }: { projectId: string }) {\n * // Only re-render when the project name changes, not other fields\n * const projectName = useCoState(\n * Project,\n * projectId,\n * {\n * select: (project) => !project.$isLoading ? project.name : \"Loading...\",\n * }\n * );\n *\n * return <h1>{projectName}</h1>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Deep loading with resolve queries\n * const Project = co.map({\n * name: z.string(),\n * tasks: co.list(Task),\n * owner: TeamMember,\n * });\n *\n * function ProjectView({ projectId }: { projectId: string }) {\n * const project = useCoState(Project, projectId, {\n * resolve: {\n * tasks: { $each: true },\n * owner: true,\n * },\n * });\n *\n * if (!project.$isLoaded) {\n * switch (project.$jazz.loadingState) {\n * case \"unauthorized\":\n * return \"Project not accessible\";\n * case \"unavailable\":\n * return \"Project not found\";\n * case \"loading\":\n * return \"Loading project...\";\n * }\n * }\n *\n * return (\n * <div>\n * <h1>{project.name}</h1>\n * <p>Owner: {project.owner.name}</p>\n * <ul>\n * {project.tasks.map((task) => (\n * <li key={task.id}>{task.title}</li>\n * ))}\n * </ul>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Using with optional references and error handling\n * const Task = co.map({\n * title: z.string(),\n * assignee: co.optional(TeamMember),\n * subtasks: co.list(Task),\n * });\n *\n * function TaskDetail({ taskId }: { taskId: string }) {\n * const task = useCoState(Task, taskId, {\n * resolve: {\n * assignee: true,\n * subtasks: { $each: { $onError: 'catch' } },\n * },\n * });\n *\n * if (!task.$isLoaded) {\n * switch (task.$jazz.loadingState) {\n * case \"unauthorized\":\n * return \"Task not accessible\";\n * case \"unavailable\":\n * return \"Task not found\";\n * case \"loading\":\n * return \"Loading task...\";\n * }\n * }\n *\n * return (\n * <div>\n * <h2>{task.title}</h2>\n * {task.assignee && <p>Assigned to: {task.assignee.name}</p>}\n * <ul>\n * {task.subtasks.map((subtask, index) => (\n * subtask.$isLoaded ? <li key={subtask.id}>{subtask.title}</li> : <li key={index}>Inaccessible subtask</li>\n * ))}\n * </ul>\n * </div>\n * );\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Use custom equality function for complex data structures\n * const TaskList = co.list(Task);\n *\n * function TaskCount({ listId }: { listId: string }) {\n * const taskStats = useCoState(\n * TaskList,\n * listId,\n * {\n * resolve: { $each: true },\n * select: (tasks) => {\n * if (!tasks.$isLoaded) return { total: 0, completed: 0 };\n * return {\n * total: tasks.length,\n * completed: tasks.filter(task => task.completed).length,\n * };\n * },\n * // Custom equality to prevent re-renders when stats haven't changed\n * equalityFn: (a, b) => a.total === b.total && a.completed === b.completed,\n * }\n * );\n *\n * return (\n * <div>\n * {taskStats.completed} of {taskStats.total} tasks completed\n * </div>\n * );\n * }\n * ```\n *\n * For more examples, see the [subscription and deep loading](https://jazz.tools/docs/react/using-covalues/subscription-and-loading) documentation.\n */\nexport function useCoState<\n S extends CoValueClassOrSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n TSelectorReturn = MaybeLoaded<Loaded<S, R>>,\n>(\n /** The CoValue schema or class constructor */\n Schema: S,\n /** The ID of the CoValue to subscribe to. If `undefined`, returns an `unavailable` value */\n id: string | undefined,\n /** Optional configuration for the subscription */\n options?: {\n /** Resolve query to specify which nested CoValues to load */\n resolve?: ResolveQueryStrict<S, R>;\n /** Select which value to return */\n select?: (value: MaybeLoaded<Loaded<S, R>>) => TSelectorReturn;\n /** Equality function to determine if the selected value has changed, defaults to `Object.is` */\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n /**\n * Create or load a branch for isolated editing.\n *\n * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.\n * It's a fork of your data graph: the same schema, but with diverging values.\n *\n * The checkout of the branch is applied on all the resolved values.\n *\n * @param name - A unique name for the branch. This identifies the branch\n * and can be used to switch between different branches of the same CoValue.\n * @param owner - The owner of the branch. Determines who can access and modify\n * the branch. If not provided, the branch is owned by the current user.\n *\n * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.\n */\n unstable_branch?: BranchDefinition;\n preloaded?: ExportedCoValue<Loaded<S, R>>;\n },\n): TSelectorReturn {\n useImportCoValueContent(id, options?.preloaded);\n\n const subscription = useCoValueSubscription(Schema, id, options);\n const getCurrentValue = useGetCurrentValue(subscription);\n\n const value = useSyncExternalStoreWithSelector<\n MaybeLoaded<Loaded<S, R>>,\n TSelectorReturn\n >(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n\n return value;\n}\n\nexport function useSuspenseCoState<\n S extends CoValueClassOrSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n TSelectorReturn = Loaded<S, R>,\n>(\n /** The CoValue schema or class constructor */\n Schema: S,\n /** The ID of the CoValue to subscribe to */\n id: string,\n /** Optional configuration for the subscription */\n options?: {\n /** Resolve query to specify which nested CoValues to load */\n resolve?: ResolveQueryStrict<S, R>;\n /** Select which value to return */\n select?: (value: Loaded<S, R>) => TSelectorReturn;\n /** Equality function to determine if the selected value has changed, defaults to `Object.is` */\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n /**\n * Create or load a branch for isolated editing.\n *\n * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.\n * It's a fork of your data graph: the same schema, but with diverging values.\n *\n * The checkout of the branch is applied on all the resolved values.\n *\n * @param name - A unique name for the branch. This identifies the branch\n * and can be used to switch between different branches of the same CoValue.\n * @param owner - The owner of the branch. Determines who can access and modify\n * the branch. If not provided, the branch is owned by the current user.\n *\n * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.\n */\n unstable_branch?: BranchDefinition;\n preloaded?: ExportedCoValue<Loaded<S, R>>;\n },\n): TSelectorReturn {\n useImportCoValueContent(id, options?.preloaded);\n\n const subscription = useCoValueSubscription(Schema, id, options);\n\n if (!subscription) {\n throw new Error(\"Subscription not found\");\n }\n\n use(subscription.getPromise());\n\n const getCurrentValue = () => {\n const value = subscription.getCurrentValue();\n\n if (!value.$isLoaded) {\n throw new Error(\"CoValue must be loaded in a suspense context\");\n }\n\n return value;\n };\n\n const value = useSyncExternalStoreWithSelector<Loaded<S, R>, TSelectorReturn>(\n React.useCallback(\n (callback) => {\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n\n return value;\n}\n\nexport function useSubscriptionSelector<\n S extends CoValueClassOrSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n TSelectorReturn = MaybeLoaded<Loaded<S, R>>,\n>(\n subscription: CoValueSubscription<S, R>,\n options?: {\n select?: (value: MaybeLoaded<Loaded<S, R>>) => TSelectorReturn;\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n },\n) {\n const getCurrentValue = useGetCurrentValue(subscription);\n\n return useSyncExternalStoreWithSelector<\n MaybeLoaded<Loaded<S, R>>,\n TSelectorReturn\n >(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n}\n\nexport function useAccountSubscription<\n S extends AccountClass<Account> | AnyAccountSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<S> = SchemaResolveQuery<S>,\n>(\n Schema: S,\n options?: {\n resolve?: ResolveQueryStrict<S, R>;\n unstable_branch?: BranchDefinition;\n },\n) {\n const contextManager = useJazzContextManager();\n\n // Capture stack trace at hook call time\n const callerStack = React.useRef<Error | undefined>(undefined);\n if (!callerStack.current) {\n callerStack.current = captureStack();\n }\n\n const createSubscription = () => {\n const agent = getCurrentAccountFromContextManager(contextManager);\n\n if (agent.$type$ === \"Anonymous\") {\n return {\n subscription: null,\n contextManager,\n agent,\n };\n }\n\n const resolve = getResolveQuery(Schema, options?.resolve);\n\n const node = contextManager.getCurrentValue()!.node;\n const cache = contextManager.getSubscriptionScopeCache();\n const subscription = cache.getOrCreate(\n node,\n Schema,\n agent.$jazz.id,\n resolve,\n false,\n false,\n options?.unstable_branch,\n );\n\n // Set callerStack on returned subscription after retrieval\n if (callerStack.current) {\n subscription.callerStack = callerStack.current;\n }\n\n return {\n subscription,\n contextManager,\n Schema,\n branchName: options?.unstable_branch?.name,\n branchOwnerId: options?.unstable_branch?.owner?.$jazz.id,\n };\n };\n\n const [subscription, setSubscription] = React.useState(createSubscription);\n\n const branchName = options?.unstable_branch?.name;\n const branchOwnerId = options?.unstable_branch?.owner?.$jazz.id;\n\n React.useLayoutEffect(() => {\n if (\n subscription.contextManager !== contextManager ||\n subscription.Schema !== Schema ||\n subscription.branchName !== options?.unstable_branch?.name ||\n subscription.branchOwnerId !== options?.unstable_branch?.owner?.$jazz.id\n ) {\n // No need to manually destroy - cache handles cleanup via SubscriptionScope lifecycle\n setSubscription(createSubscription());\n }\n\n return contextManager.subscribe(() => {\n // No need to manually destroy - cache handles cleanup via SubscriptionScope lifecycle\n setSubscription(createSubscription());\n });\n }, [Schema, contextManager, branchName, branchOwnerId]);\n\n return subscription.subscription as CoValueSubscription<S, R>;\n}\n\n/**\n * React hook for accessing the current user's account.\n *\n * This hook provides access to the current user's account profile and root data.\n * It automatically handles the subscription lifecycle and supports deep loading of nested\n * CoValues through resolve queries.\n *\n * The {@param options.select} function allows returning only specific parts of the account data,\n * which helps reduce unnecessary re-renders by narrowing down the returned data.\n * Additionally, you can provide a custom {@param options.equalityFn} to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * @returns The account data, or an {@link NotLoaded} value. Use `$isLoaded` to check whether the\n * CoValue is loaded, or use {@link MaybeLoaded.$jazz.loadingState} to get the detailed loading state.\n * If a selector function is provided, returns the result of the selector function.\n *\n * @example\n * ```tsx\n * // Select only specific fields to reduce re-renders\n * const MyAppAccount = co.account({\n * profile: co.profile(),\n * root: co.map({\n * name: z.string(),\n * email: z.string(),\n * lastLogin: z.date(),\n * }),\n * });\n *\n * function UserProfile({ accountId }: { accountId: string }) {\n * // Only re-render when the profile name changes, not other fields\n * const profileName = useAccount(\n * MyAppAccount,\n * {\n * resolve: {\n * profile: true,\n * root: true,\n * },\n * select: (account) => account.$isLoaded ? account.profile.name : \"Loading...\",\n * }\n * );\n *\n * return <h1>{profileName}</h1>;\n * }\n * ```\n *\n * @example\n * ```tsx\n * // Deep loading with resolve queries\n * function ProjectListWithDetails() {\n * const me = useAccount(MyAppAccount, {\n * resolve: {\n * profile: true,\n * root: {\n * myProjects: {\n * $each: {\n * tasks: true,\n * },\n * },\n * },\n * },\n * });\n *\n * if (!me.$isLoaded) {\n * switch (me.$jazz.loadingState) {\n * case \"unauthorized\":\n * return \"Account not accessible\";\n * case \"unavailable\":\n * return \"Account not found\";\n * case \"loading\":\n * return \"Loading account...\";\n * }\n * }\n *\n * return (\n * <div>\n * <h1>{me.profile.name}'s projects</h1>\n * <ul>\n * {me.root.myProjects.map((project) => (\n * <li key={project.id}>\n * {project.name} ({project.tasks.length} tasks)\n * </li>\n * ))}\n * </ul>\n * </div>\n * );\n * }\n * ```\n *\n */\nexport function useAccount<\n A extends AccountClass<Account> | AnyAccountSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<A> = SchemaResolveQuery<A>,\n TSelectorReturn = MaybeLoaded<Loaded<A, R>>,\n>(\n /** The account schema to use. Defaults to the base Account schema */\n AccountSchema: A = Account as unknown as A,\n /** Optional configuration for the subscription */\n options?: {\n /** Resolve query to specify which nested CoValues to load from the account */\n resolve?: ResolveQueryStrict<A, R>;\n /** Select which value to return from the account data */\n select?: (account: MaybeLoaded<Loaded<A, R>>) => TSelectorReturn;\n /** Equality function to determine if the selected value has changed, defaults to `Object.is` */\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n /**\n * Create or load a branch for isolated editing.\n *\n * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.\n * It's a fork of your data graph: the same schema, but with diverging values.\n *\n * The checkout of the branch is applied on all the resolved values.\n *\n * @param name - A unique name for the branch. This identifies the branch\n * and can be used to switch between different branches of the same CoValue.\n * @param owner - The owner of the branch. Determines who can access and modify\n * the branch. If not provided, the branch is owned by the current user.\n *\n * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.\n */\n unstable_branch?: BranchDefinition;\n },\n): TSelectorReturn {\n const subscription = useAccountSubscription(AccountSchema, options);\n const getCurrentValue = useGetCurrentValue(subscription);\n\n return useSyncExternalStoreWithSelector<\n MaybeLoaded<Loaded<A, R>>,\n TSelectorReturn\n >(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n}\n\nexport function useSuspenseAccount<\n A extends AccountClass<Account> | AnyAccountSchema,\n // @ts-expect-error we can't statically enforce the schema's resolve query is a valid resolve query, but in practice it is\n const R extends ResolveQuery<A> = SchemaResolveQuery<A>,\n TSelectorReturn = Loaded<A, R>,\n>(\n /** The account schema to use. Defaults to the base Account schema */\n AccountSchema: A = Account as unknown as A,\n /** Optional configuration for the subscription */\n options?: {\n /** Resolve query to specify which nested CoValues to load from the account */\n resolve?: ResolveQueryStrict<A, R>;\n /** Select which value to return from the account data */\n select?: (account: Loaded<A, R>) => TSelectorReturn;\n /** Equality function to determine if the selected value has changed, defaults to `Object.is` */\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n /**\n * Create or load a branch for isolated editing.\n *\n * Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.\n * It's a fork of your data graph: the same schema, but with diverging values.\n *\n * The checkout of the branch is applied on all the resolved values.\n *\n * @param name - A unique name for the branch. This identifies the branch\n * and can be used to switch between different branches of the same CoValue.\n * @param owner - The owner of the branch. Determines who can access and modify\n * the branch. If not provided, the branch is owned by the current user.\n *\n * For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.\n */\n unstable_branch?: BranchDefinition;\n },\n): TSelectorReturn {\n const subscription = useAccountSubscription(AccountSchema, options);\n\n if (!subscription) {\n throw new Error(\n \"Subscription not found, are you using useSuspenseAccount in guest mode?\",\n );\n }\n\n use(subscription.getPromise());\n\n const getCurrentValue = () => {\n const value = subscription.getCurrentValue();\n\n if (!value.$isLoaded) {\n throw new Error(\"Account must be loaded in a suspense context\");\n }\n\n return value;\n };\n\n return useSyncExternalStoreWithSelector<Loaded<A, R>, TSelectorReturn>(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n getCurrentValue,\n getCurrentValue,\n options?.select ?? ((value) => value as TSelectorReturn),\n options?.equalityFn ?? Object.is,\n );\n}\n\n/**\n * Returns a function for logging out of the current account.\n */\nexport function useLogOut(): () => void {\n const contextManager = useJazzContextManager();\n return contextManager.logOut;\n}\n\n/**\n * React hook for accessing the current agent. An agent can either be:\n * - an Authenticated Account, if the user is logged in\n * - an Anonymous Account, if the user didn't log in\n * - or an anonymous agent, if in guest mode\n *\n * The agent can be used as the `loadAs` parameter for load and subscribe methods.\n */\nexport function useAgent<\n A extends AccountClass<Account> | AnyAccountSchema = typeof Account,\n>(): AnonymousJazzAgent | Loaded<A, true> {\n const contextManager = useJazzContextManager<InstanceOfSchema<A>>();\n\n const getCurrentValue = () =>\n getCurrentAccountFromContextManager(contextManager) as\n | AnonymousJazzAgent\n | Loaded<A, true>;\n\n return React.useSyncExternalStore(\n useCallback(\n (callback) => {\n return contextManager.subscribe(callback);\n },\n [contextManager],\n ),\n getCurrentValue,\n getCurrentValue,\n );\n}\n\nexport function experimental_useInboxSender<\n I extends CoValue,\n O extends CoValue | undefined,\n>(inboxOwnerID: string | undefined) {\n const context = useJazzContext();\n\n if (!(\"me\" in context)) {\n throw new Error(\n \"useInboxSender can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n const me = context.me;\n const inboxRef = useRef<Promise<InboxSender<I, O>> | undefined>(undefined);\n\n const sendMessage = useCallback(\n async (message: I) => {\n if (!inboxOwnerID) throw new Error(\"Inbox owner ID is required\");\n\n if (!inboxRef.current) {\n const inbox = InboxSender.load<I, O>(inboxOwnerID, me);\n inboxRef.current = inbox;\n }\n\n let inbox = await inboxRef.current;\n\n // Regenerate the InboxSender if the inbox owner or current account changes\n if (inbox.owner.id !== inboxOwnerID || inbox.currentAccount !== me) {\n const req = InboxSender.load<I, O>(inboxOwnerID, me);\n inboxRef.current = req;\n inbox = await req;\n }\n\n return inbox.sendMessage(message);\n },\n [inboxOwnerID, me.$jazz.id],\n );\n\n return sendMessage;\n}\n\n/**\n * Hook that returns the current connection status to the Jazz sync server.\n *\n * @returns `true` when connected to the server, `false` when disconnected\n *\n * @remarks\n * On connection drop, this hook will return `false` only when Jazz detects the disconnection\n * after 5 seconds of not receiving a ping from the server.\n */\nexport function useSyncConnectionStatus() {\n const context = useJazzContext();\n\n const connected = useSyncExternalStore(\n useCallback(\n (callback) => {\n return context.addConnectionListener(callback);\n },\n [context],\n ),\n () => context.connected(),\n () => context.connected(),\n );\n\n return connected;\n}\n\nfunction getResolveQuery(\n Schema: CoValueClassOrSchema,\n // We don't need type validation here, since this is an internal API\n resolveQuery?: ResolveQuery<any>,\n): ResolveQuery<any> {\n if (resolveQuery) {\n return resolveQuery;\n }\n // Check the schema is a CoValue schema (and not a CoValue class)\n if (\"resolveQuery\" in Schema) {\n return Schema.resolveQuery;\n }\n return true;\n}\n","import { Account, JazzContextManager } from \"jazz-tools\";\n\nexport function getCurrentAccountFromContextManager<Acc extends Account>(\n contextManager: JazzContextManager<Acc, any>,\n) {\n const context = contextManager.getCurrentValue();\n\n if (!context) {\n throw new Error(\"No context found\");\n }\n\n return \"me\" in context ? context.me : context.guest;\n}\n\nexport function subscribeToContextManager<Acc extends Account>(\n contextManager: JazzContextManager<Acc, any>,\n callback: () => () => void,\n) {\n let unsub = () => {};\n\n const handler = () => {\n unsub();\n unsub = callback();\n };\n\n handler();\n return contextManager.subscribe(handler);\n}\n","import React from \"react\";\n\n// shim from https://github.com/pmndrs/jotai/blob/f287c5d665a807e676bc731e83174c62c1fe1fc9/src/react/useAtomValue.ts#L13C1-L56C1\nconst attachPromiseStatus = <T>(\n promise: PromiseLike<T> & {\n status?: \"pending\" | \"fulfilled\" | \"rejected\";\n value?: T;\n reason?: unknown;\n },\n) => {\n if (!promise.status) {\n promise.status = \"pending\";\n promise.then(\n (v) => {\n promise.status = \"fulfilled\";\n promise.value = v;\n },\n (e) => {\n promise.status = \"rejected\";\n promise.reason = e;\n },\n );\n }\n};\n\nexport const use =\n React.use ||\n // A shim for older React versions\n (<T>(\n promise: PromiseLike<T> & {\n status?: \"pending\" | \"fulfilled\" | \"rejected\";\n value?: T;\n reason?: unknown;\n },\n ): T => {\n if (promise.status === \"pending\") {\n throw promise;\n } else if (promise.status === \"fulfilled\") {\n return promise.value as T;\n } else if (promise.status === \"rejected\") {\n throw promise.reason;\n } else {\n attachPromiseStatus(promise);\n throw promise;\n }\n });\n","import React from \"react\";\nimport {\n Account,\n AccountClass,\n AnyAccountSchema,\n CoValueClassOrSchema,\n CoValueLoadingState,\n Loaded,\n MaybeLoaded,\n ResolveQuery,\n ResolveQueryStrict,\n} from \"jazz-tools\";\nimport {\n useAccountSubscription,\n useCoValueSubscription,\n useSubscriptionSelector,\n} from \"./hooks.js\";\nimport type { CoValueSubscription } from \"./types.js\";\n\nexport function createCoValueSubscriptionContext<\n S extends CoValueClassOrSchema,\n const R extends ResolveQuery<S> = true,\n>(schema: S, resolve?: ResolveQueryStrict<S, R>) {\n const Context = React.createContext<CoValueSubscription<S, R>>(null);\n\n return {\n Provider: ({\n id,\n options,\n loadingFallback,\n unavailableFallback,\n children,\n }: React.PropsWithChildren<{\n id: string | undefined | null;\n options?: Omit<\n Parameters<typeof useCoValueSubscription<S, R>>[2],\n \"resolve\"\n >;\n loadingFallback?: React.ReactNode;\n unavailableFallback?: React.ReactNode;\n }>) => {\n const subscription = useCoValueSubscription(schema, id, {\n ...options,\n resolve: resolve,\n });\n\n const loadState = useSubscriptionSelector(subscription, {\n select: (value) => value.$jazz.loadingState,\n });\n\n if (loadState === CoValueLoadingState.LOADING) {\n return loadingFallback ?? null;\n }\n if (\n loadState === CoValueLoadingState.UNAUTHORIZED ||\n loadState === CoValueLoadingState.UNAVAILABLE\n ) {\n return unavailableFallback ?? null;\n }\n\n return (\n <Context.Provider value={subscription}>{children}</Context.Provider>\n );\n },\n useSelector: <TSelectorReturn = Loaded<S, R>>(options?: {\n select?: (value: Loaded<S, R>) => TSelectorReturn;\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n }) => {\n const subscription = React.useContext(Context);\n\n if (!subscription) {\n throw new Error(\n \"useSelector must be used within a coValue subscription provider\",\n );\n }\n\n return useSubscriptionSelector<S, R, TSelectorReturn>(\n subscription,\n options as Parameters<\n typeof useSubscriptionSelector<S, R, TSelectorReturn>\n >[1],\n );\n },\n };\n}\n\nexport function createAccountSubscriptionContext<\n A extends AccountClass<Account> | AnyAccountSchema,\n const R extends ResolveQuery<A> = true,\n>(schema: A, resolve?: ResolveQueryStrict<A, R>) {\n const Context = React.createContext<CoValueSubscription<A, R>>(null);\n\n return {\n Provider: ({\n options,\n loadingFallback,\n unavailableFallback,\n children,\n }: React.PropsWithChildren<{\n options?: Omit<\n Parameters<typeof useAccountSubscription<A, R>>[1],\n \"resolve\"\n >;\n loadingFallback?: React.ReactNode;\n unavailableFallback?: React.ReactNode;\n }>) => {\n const subscription = useAccountSubscription(schema, {\n ...options,\n resolve: resolve,\n });\n\n const loadState = useSubscriptionSelector(subscription, {\n select: (value) => value.$jazz.loadingState,\n });\n\n if (loadState === CoValueLoadingState.LOADING) {\n return loadingFallback ?? null;\n }\n\n if (\n loadState === CoValueLoadingState.UNAUTHORIZED ||\n loadState === CoValueLoadingState.UNAVAILABLE\n ) {\n return unavailableFallback ?? null;\n }\n\n return (\n <Context.Provider value={subscription}>{children}</Context.Provider>\n );\n },\n useSelector: <TSelectorReturn = Loaded<A, R>>(options?: {\n select?: (value: Loaded<A, R>) => TSelectorReturn;\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n }) => {\n const subscription = React.useContext(Context);\n\n if (!subscription) {\n throw new Error(\n \"useSelector must be used within an account subscription provider\",\n );\n }\n\n return useSubscriptionSelector<A, R, TSelectorReturn>(\n subscription,\n options as Parameters<\n typeof useSubscriptionSelector<A, R, TSelectorReturn>\n >[1],\n );\n },\n };\n}\n","import { DemoAuth } from \"jazz-tools\";\nimport { useEffect, useMemo, useState } from \"react\";\nimport { useAuthSecretStorage, useJazzContext } from \"../hooks.js\";\nimport { useIsAuthenticated } from \"../hooks.js\";\n\n/**\n * `useDemoAuth` is a hook that provides a `JazzAuth` object for demo authentication.\n *\n *\n * ```ts\n * const { state, logIn, signUp, existingUsers } = useDemoAuth();\n * ```\n *\n * @category Auth Providers\n */\nexport function useDemoAuth() {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n\n if (\"guest\" in context) {\n throw new Error(\"Demo auth is not supported in guest mode\");\n }\n\n const authMethod = useMemo(() => {\n return new DemoAuth(context.authenticate, authSecretStorage);\n }, []);\n\n const isAuthenticated = useIsAuthenticated();\n const [existingUsers, setExistingUsers] = useState<string[]>([]);\n\n useEffect(() => {\n authMethod.getExistingUsers().then(setExistingUsers);\n }, [authMethod]);\n\n function handleSignUp(username: string) {\n return authMethod.signUp(username).then(() => {\n setExistingUsers(existingUsers.concat([username]));\n });\n }\n\n return {\n state: isAuthenticated ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.logIn,\n signUp: handleSignUp,\n existingUsers,\n } as const;\n}\n","import { PassphraseAuth } from \"jazz-tools\";\nimport { useCallback, useMemo, useSyncExternalStore } from \"react\";\nimport { useAuthSecretStorage, useJazzContext } from \"../hooks.js\";\nimport { useIsAuthenticated } from \"../hooks.js\";\n\n/**\n * `usePassphraseAuth` hook provides a `JazzAuth` object for passphrase authentication.\n *\n * @example\n * ```ts\n * const auth = usePassphraseAuth({ appName, appHostname, wordlist });\n * ```\n *\n * @category Auth Providers\n */\nexport function usePassphraseAuth({ wordlist }: { wordlist: string[] }) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n\n if (\"guest\" in context) {\n throw new Error(\"Passphrase auth is not supported in guest mode\");\n }\n\n const authMethod = useMemo(() => {\n return new PassphraseAuth(\n context.node.crypto,\n context.authenticate,\n context.register,\n authSecretStorage,\n wordlist,\n );\n }, [wordlist]);\n\n const passphrase = useSyncExternalStore(\n useCallback(\n (callback) => {\n authMethod.loadCurrentAccountPassphrase();\n return authMethod.subscribe(callback);\n },\n [authMethod],\n ),\n () => authMethod.passphrase,\n );\n\n const isAuthenticated = useIsAuthenticated();\n return {\n state: isAuthenticated ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.logIn,\n signUp: authMethod.signUp,\n registerNewAccount: authMethod.registerNewAccount,\n generateRandomPassphrase: authMethod.generateRandomPassphrase,\n passphrase,\n } as const;\n}\n"],"mappings":";;;;;;;AAAA,SAAS,wCAAwC;AACjD,OAAOA;AAAA,EACL;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEP;AAAA,EACE;AAAA,EAMA;AAAA,EAEA;AAAA,EAYA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;;;AChCA,SAAS,oCACd,gBACA;AACA,QAAM,UAAU,eAAe,gBAAgB;AAE/C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kBAAkB;AAAA,EACpC;AAEA,SAAO,QAAQ,UAAU,QAAQ,KAAK,QAAQ;AAChD;;;ACZA,OAAO,WAAW;AAGlB,IAAM,sBAAsB,CAC1B,YAKG;AACH,MAAI,CAAC,QAAQ,QAAQ;AACnB,YAAQ,SAAS;AACjB,YAAQ;AAAA,MACN,CAAC,MAAM;AACL,gBAAQ,SAAS;AACjB,gBAAQ,QAAQ;AAAA,MAClB;AAAA,MACA,CAAC,MAAM;AACL,gBAAQ,SAAS;AACjB,gBAAQ,SAAS;AAAA,MACnB;AAAA,IACF;AAAA,EACF;AACF;AAEO,IAAM,MACX,MAAM;AAA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ACb;AAAA,IACA,MAAM,WAAW;AAAA,EACnB;AAEA,QAAM,kBAAkB,mBAAmB;AAC3C,SAAO;AAAA,IACL,OAAO,kBAAkB,aAAa;AAAA,IACtC,OAAO,WAAW;AAAA,IAClB,QAAQ,WAAW;AAAA,IACnB,oBAAoB,WAAW;AAAA,IAC/B,0BAA0B,WAAW;AAAA,IACrC;AAAA,EACF;AACF;","names":["React","React","subscription","value","inbox","React","CoValueLoadingState","React","CoValueLoadingState","useMemo","useMemo","useCallback","useMemo","useSyncExternalStore","useMemo","useSyncExternalStore","useCallback"]}
|
|
@@ -12,4 +12,5 @@ declare const customRenderHook: <TProps, TResult>(callback: (props: TProps) => T
|
|
|
12
12
|
export * from "@testing-library/react";
|
|
13
13
|
export { customRender as render };
|
|
14
14
|
export { customRenderHook as renderHook };
|
|
15
|
+
export declare function createAsyncStorage(): Promise<import("cojson").StorageApiAsync>;
|
|
15
16
|
//# sourceMappingURL=testUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../../../src/react-core/tests/testUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EAGd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,kBAAkB,
|
|
1
|
+
{"version":3,"file":"testUtils.d.ts","sourceRoot":"","sources":["../../../src/react-core/tests/testUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,aAAa,EAGd,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,KAAK,mBAAmB,GAAG;IACzB,OAAO,CAAC,EAAE,OAAO,GAAG;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,CAAC;IAClD,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,CAAC;AAEF,QAAA,MAAM,YAAY,OACZ,KAAK,CAAC,SAAS,YACV,aAAa,GAAG,mBAAmB,oIAkB7C,CAAC;AAEF,QAAA,MAAM,gBAAgB,GAAI,MAAM,EAAE,OAAO,YAC7B,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,YAC3B,iBAAiB,CAAC,MAAM,CAAC,GAAG,mBAAmB,uEAkBzD,CAAC;AAGF,cAAc,wBAAwB,CAAC;AAGvC,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,CAAC;AAClC,OAAO,EAAE,gBAAgB,IAAI,UAAU,EAAE,CAAC;AAyC1C,wBAAsB,kBAAkB,8CAUvC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSuspenseAccount.test.d.ts","sourceRoot":"","sources":["../../../src/react-core/tests/useSuspenseAccount.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useSuspenseCoState.test.d.ts","sourceRoot":"","sources":["../../../src/react-core/tests/useSuspenseCoState.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use.d.ts","sourceRoot":"","sources":["../../src/react-core/use.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAyB1B,eAAO,MAAM,GAAG,kBAoBZ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react-native/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/react-native/index.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAC;AAE9C,cAAc,eAAe,CAAC;AAC9B,cAAc,iCAAiC,CAAC;AAChD,cAAc,gCAAgC,CAAC"}
|