jazz-tools 0.19.19 → 0.19.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/.svelte-kit/__package__/client.d.ts.map +1 -1
  2. package/.svelte-kit/__package__/client.js +3 -1
  3. package/.svelte-kit/__package__/tests/client.test.js +48 -0
  4. package/.turbo/turbo-build.log +65 -61
  5. package/dist/better-auth/auth/client.d.ts.map +1 -1
  6. package/dist/better-auth/auth/client.js +1 -1
  7. package/dist/better-auth/auth/client.js.map +1 -1
  8. package/dist/{chunk-PEHQ7TN2.js → chunk-MI24YFCY.js} +31 -4
  9. package/dist/chunk-MI24YFCY.js.map +1 -0
  10. package/dist/index.js +1 -1
  11. package/dist/react-core/hooks.d.ts +2 -2
  12. package/dist/react-core/hooks.d.ts.map +1 -1
  13. package/dist/react-core/index.js +4 -78
  14. package/dist/react-core/index.js.map +1 -1
  15. package/dist/react-native/chunk-DGUM43GV.js +11 -0
  16. package/dist/react-native/chunk-DGUM43GV.js.map +1 -0
  17. package/dist/react-native/crypto.js +2 -0
  18. package/dist/react-native/crypto.js.map +1 -1
  19. package/dist/react-native/index.js +540 -29
  20. package/dist/react-native/index.js.map +1 -1
  21. package/dist/react-native-core/auth/PasskeyAuth.d.ts +123 -0
  22. package/dist/react-native-core/auth/PasskeyAuth.d.ts.map +1 -0
  23. package/dist/react-native-core/auth/PasskeyAuthBasicUI.d.ts +34 -0
  24. package/dist/react-native-core/auth/PasskeyAuthBasicUI.d.ts.map +1 -0
  25. package/dist/react-native-core/auth/auth.d.ts +3 -0
  26. package/dist/react-native-core/auth/auth.d.ts.map +1 -1
  27. package/dist/react-native-core/auth/passkey-utils.d.ts +16 -0
  28. package/dist/react-native-core/auth/passkey-utils.d.ts.map +1 -0
  29. package/dist/react-native-core/auth/usePasskeyAuth.d.ts +48 -0
  30. package/dist/react-native-core/auth/usePasskeyAuth.d.ts.map +1 -0
  31. package/dist/react-native-core/chunk-DGUM43GV.js +11 -0
  32. package/dist/react-native-core/chunk-DGUM43GV.js.map +1 -0
  33. package/dist/react-native-core/crypto.js +2 -0
  34. package/dist/react-native-core/crypto.js.map +1 -1
  35. package/dist/react-native-core/index.js +535 -24
  36. package/dist/react-native-core/index.js.map +1 -1
  37. package/dist/react-native-core/tests/PasskeyAuth.test.d.ts +2 -0
  38. package/dist/react-native-core/tests/PasskeyAuth.test.d.ts.map +1 -0
  39. package/dist/react-native-core/tests/passkey-utils.test.d.ts +2 -0
  40. package/dist/react-native-core/tests/passkey-utils.test.d.ts.map +1 -0
  41. package/dist/testing.js +1 -1
  42. package/dist/tools/coValues/account.d.ts +5 -1
  43. package/dist/tools/coValues/account.d.ts.map +1 -1
  44. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +30 -1
  45. package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
  46. package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
  47. package/dist/tools/testing.d.ts.map +1 -1
  48. package/package.json +8 -4
  49. package/src/better-auth/auth/client.ts +3 -1
  50. package/src/better-auth/auth/tests/client.test.ts +66 -2
  51. package/src/react-core/hooks.ts +12 -103
  52. package/src/react-native-core/auth/PasskeyAuth.ts +316 -0
  53. package/src/react-native-core/auth/PasskeyAuthBasicUI.tsx +284 -0
  54. package/src/react-native-core/auth/auth.ts +3 -0
  55. package/src/react-native-core/auth/passkey-utils.ts +47 -0
  56. package/src/react-native-core/auth/usePasskeyAuth.tsx +85 -0
  57. package/src/react-native-core/tests/PasskeyAuth.test.ts +463 -0
  58. package/src/react-native-core/tests/passkey-utils.test.ts +144 -0
  59. package/src/tools/coValues/account.ts +11 -3
  60. package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +27 -1
  61. package/src/tools/tests/account.test.ts +2 -1
  62. package/testSetup.ts +4 -0
  63. package/vitest.config.ts +1 -0
  64. package/dist/chunk-PEHQ7TN2.js.map +0 -1
package/dist/index.js CHANGED
@@ -48,7 +48,7 @@ import {
48
48
  subscribeToCoValue,
49
49
  unstable_loadUnique,
50
50
  zodReExport_exports
51
- } from "./chunk-PEHQ7TN2.js";
51
+ } from "./chunk-MI24YFCY.js";
52
52
  import {
53
53
  createSSRJazzAgent
54
54
  } from "./chunk-M2HGBOXS.js";
@@ -227,8 +227,8 @@ options?: {
227
227
  unstable_branch?: BranchDefinition;
228
228
  preloaded?: ExportedCoValue<Loaded<S, R>>;
229
229
  }): TSelectorReturn;
230
- export declare function useSubscriptionSelector<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = SchemaResolveQuery<S>, TSelectorReturn = MaybeLoaded<Loaded<S, R>>>(subscription: CoValueSubscription<S, R>, options?: {
231
- select?: (value: MaybeLoaded<Loaded<S, R>>) => TSelectorReturn;
230
+ export declare function useSubscriptionSelector<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = SchemaResolveQuery<S>, TSelectorInput = MaybeLoaded<Loaded<S, R>>, TSelectorReturn = TSelectorInput>(subscription: CoValueSubscription<S, R>, options?: {
231
+ select?: (value: TSelectorInput) => TSelectorReturn;
232
232
  equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;
233
233
  }): TSelectorReturn;
234
234
  export declare function useAccountSubscription<S extends AccountClass<Account> | AnyAccountSchema, const R extends ResolveQuery<S> = SchemaResolveQuery<S>>(Schema: S, options?: {
@@ -1 +1 @@
1
- {"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react-core/hooks.ts"],"names":[],"mappings":"AASA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,oBAAoB,EAEpB,eAAe,EAGf,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,WAAW,EAGX,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAKlB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAA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C,CAAC,EAAE,CAAC,CAAC;AAE9B,qEAAqE;AACrE,aAAa,GAAE,CAA2B;AAC1C,kDAAkD;AAClD,OAAO,CAAC,EAAE;IACR,8EAA8E;IAC9E,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC,yDAAyD;IACzD,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,eAAe,CAAC;IACpD,gGAAgG;IAChG,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,EAAE,eAAe,KAAK,OAAO,CAAC;IACjE;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACpC,GACA,eAAe,CAYjB;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,MAAM,IAAI,CAGtC;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CACtB,CAAC,SAAS,YAAY,CAAC,OAAO,CAAC,GAAG,gBAAgB,GAAG,OAAO,OAAO,KAChE,kBAAkB,GAAG,MAAM,CAAC,CAAC,EAAE,IAAI,CAAC,CAkBxC;AAED,wBAAgB,2BAA2B,CACzC,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,OAAO,GAAG,SAAS,EAC7B,YAAY,EAAE,MAAM,GAAG,SAAS,aAad,CAAC,qDAuBpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,YAetC"}
@@ -187,24 +187,7 @@ function useGetCurrentValue(subscription) {
187
187
  function useCoState(Schema, id, options) {
188
188
  useImportCoValueContent(id, options?.preloaded);
189
189
  const subscription = useCoValueSubscription(Schema, id, options);
190
- const getCurrentValue = useGetCurrentValue(subscription);
191
- const value = useSyncExternalStoreWithSelector(
192
- React2.useCallback(
193
- (callback) => {
194
- if (!subscription) {
195
- return () => {
196
- };
197
- }
198
- return subscription.subscribe(callback);
199
- },
200
- [subscription]
201
- ),
202
- getCurrentValue,
203
- getCurrentValue,
204
- options?.select ?? ((value2) => value2),
205
- options?.equalityFn ?? Object.is
206
- );
207
- return value;
190
+ return useSubscriptionSelector(subscription, options);
208
191
  }
209
192
  function useSuspenseCoState(Schema, id, options) {
210
193
  useImportCoValueContent(id, options?.preloaded);
@@ -213,26 +196,7 @@ function useSuspenseCoState(Schema, id, options) {
213
196
  throw new Error("Subscription not found");
214
197
  }
215
198
  use(subscription.getCachedPromise());
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;
199
+ return useSubscriptionSelector(subscription, options);
236
200
  }
237
201
  function useSubscriptionSelector(subscription, options) {
238
202
  const getCurrentValue = useGetCurrentValue(subscription);
@@ -306,23 +270,7 @@ function useAccountSubscription(Schema, options) {
306
270
  }
307
271
  function useAccount(AccountSchema = Account, options) {
308
272
  const subscription = useAccountSubscription(AccountSchema, options);
309
- const getCurrentValue = useGetCurrentValue(subscription);
310
- return useSyncExternalStoreWithSelector(
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
- );
273
+ return useSubscriptionSelector(subscription, options);
326
274
  }
327
275
  function useSuspenseAccount(AccountSchema = Account, options) {
328
276
  const subscription = useAccountSubscription(AccountSchema, options);
@@ -332,29 +280,7 @@ function useSuspenseAccount(AccountSchema = Account, options) {
332
280
  );
333
281
  }
334
282
  use(subscription.getCachedPromise());
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(
344
- (callback) => {
345
- if (!subscription) {
346
- return () => {
347
- };
348
- }
349
- return subscription.subscribe(callback);
350
- },
351
- [subscription]
352
- ),
353
- getCurrentValue,
354
- getCurrentValue,
355
- options?.select ?? ((value) => value),
356
- options?.equalityFn ?? Object.is
357
- );
283
+ return useSubscriptionSelector(subscription, options);
358
284
  }
359
285
  function useLogOut() {
360
286
  const contextManager = useJazzContextManager();
@@ -1 +1 @@
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.getCachedPromise());\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.getCachedPromise());\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.regist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uBAAiB,cAAc,OAAO,CAAC,QAAQ,CAAC,CAAC;AAAA,IACnD,CAAC;AAAA,EACH;AAEA,SAAO;AAAA,IACL,OAAO,kBAAkB,aAAa;AAAA,IACtC,OAAO,WAAW;AAAA,IAClB,QAAQ;AAAA,IACR;AAAA,EACF;AACF;;;AC9CA,SAAS,sBAAsB;AAC/B,SAAS,eAAAC,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":["React","React","subscription","value","inbox","React","CoValueLoadingState","React","CoValueLoadingState","useMemo","useMemo","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 const subscription = useCoValueSubscription(Schema, id, options);\n return useSubscriptionSelector(subscription, options);\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.getCachedPromise());\n\n return useSubscriptionSelector(subscription, options);\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 // Selector input can be an already loaded or a maybe-loaded value,\n // depending on whether a suspense hook is used or not, respectively.\n TSelectorInput = MaybeLoaded<Loaded<S, R>>,\n TSelectorReturn = TSelectorInput,\n>(\n subscription: CoValueSubscription<S, R>,\n options?: {\n select?: (value: TSelectorInput) => TSelectorReturn;\n equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;\n },\n): TSelectorReturn {\n const getCurrentValue = useGetCurrentValue(subscription);\n\n return useSyncExternalStoreWithSelector<TSelectorInput, 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 unknown 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 return useSubscriptionSelector(subscription, options);\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.getCachedPromise());\n\n return useSubscriptionSelector(subscription, options);\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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A,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":["React","React","subscription","inbox","React","CoValueLoadingState","React","CoValueLoadingState","useMemo","useMemo","useCallback","useMemo","useSyncExternalStore","useMemo","useSyncExternalStore","useCallback"]}
@@ -0,0 +1,11 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ export {
9
+ __require
10
+ };
11
+ //# sourceMappingURL=chunk-DGUM43GV.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,3 +1,5 @@
1
+ import "./chunk-DGUM43GV.js";
2
+
1
3
  // src/react-native/crypto.ts
2
4
  import { RNQuickCrypto } from "jazz-tools/react-native-core/crypto";
3
5
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/react-native/crypto.ts"],"sourcesContent":["export { RNQuickCrypto } from \"jazz-tools/react-native-core/crypto\";\n"],"mappings":";AAAA,SAAS,qBAAqB;","names":[]}
1
+ {"version":3,"sources":["../../src/react-native/crypto.ts"],"sourcesContent":["export { RNQuickCrypto } from \"jazz-tools/react-native-core/crypto\";\n"],"mappings":";;;AAAA,SAAS,qBAAqB;","names":[]}