jazz-tools 0.18.16 → 0.18.18
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/.svelte-kit/__package__/jazz.class.svelte.d.ts +14 -0
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/jazz.class.svelte.js +37 -0
- package/.svelte-kit/__package__/media/image.svelte +104 -98
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/testing.d.ts +1 -1
- package/.svelte-kit/__package__/testing.d.ts.map +1 -1
- package/.svelte-kit/__package__/testing.js +1 -1
- package/.svelte-kit/__package__/tests/TestConnectionStatus.svelte +8 -0
- package/.svelte-kit/__package__/tests/TestConnectionStatus.svelte.d.ts +27 -0
- package/.svelte-kit/__package__/tests/TestConnectionStatus.svelte.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/media/image.svelte.test.js +16 -2
- package/.svelte-kit/__package__/tests/sync-connection-status.svelte.test.d.ts +2 -0
- package/.svelte-kit/__package__/tests/sync-connection-status.svelte.test.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/sync-connection-status.svelte.test.js +47 -0
- package/.turbo/turbo-build.log +52 -52
- package/CHANGELOG.md +27 -0
- package/dist/browser/BrowserContextManager.d.ts +4 -0
- package/dist/browser/BrowserContextManager.d.ts.map +1 -1
- package/dist/browser/createBrowserContext.d.ts +4 -0
- package/dist/browser/createBrowserContext.d.ts.map +1 -1
- package/dist/browser/index.js +36 -4
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-GRN6OAUX.js → chunk-FHRKDKDY.js} +80 -6
- package/dist/chunk-FHRKDKDY.js.map +1 -0
- package/dist/index.js +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 +6 -2
- package/dist/react/index.js.map +1 -1
- package/dist/react/media/image.d.ts.map +1 -1
- package/dist/react-core/hooks.d.ts +26 -0
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +16 -1
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/testing.d.ts +1 -1
- package/dist/react-core/testing.d.ts.map +1 -1
- package/dist/react-core/testing.js +3 -1
- package/dist/react-core/testing.js.map +1 -1
- package/dist/react-core/tests/useSyncConnectionStatus.test.d.ts +2 -0
- package/dist/react-core/tests/useSyncConnectionStatus.test.d.ts.map +1 -0
- package/dist/react-native-core/ReactNativeContextManager.d.ts +4 -0
- package/dist/react-native-core/ReactNativeContextManager.d.ts.map +1 -1
- 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.js +41 -7
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/media/image.d.ts.map +1 -1
- package/dist/react-native-core/platform.d.ts +4 -0
- package/dist/react-native-core/platform.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.d.ts +14 -0
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +37 -0
- package/dist/svelte/media/image.svelte +104 -98
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/testing.d.ts +1 -1
- package/dist/svelte/testing.d.ts.map +1 -1
- package/dist/svelte/testing.js +1 -1
- package/dist/svelte/tests/TestConnectionStatus.svelte +8 -0
- package/dist/svelte/tests/TestConnectionStatus.svelte.d.ts +27 -0
- package/dist/svelte/tests/TestConnectionStatus.svelte.d.ts.map +1 -0
- package/dist/svelte/tests/media/image.svelte.test.js +16 -2
- package/dist/svelte/tests/sync-connection-status.svelte.test.d.ts +2 -0
- package/dist/svelte/tests/sync-connection-status.svelte.test.d.ts.map +1 -0
- package/dist/svelte/tests/sync-connection-status.svelte.test.js +47 -0
- package/dist/testing.js +34 -4
- package/dist/testing.js.map +1 -1
- package/dist/tools/implementation/ContextManager.d.ts +4 -0
- package/dist/tools/implementation/ContextManager.d.ts.map +1 -1
- package/dist/tools/implementation/refs.d.ts +1 -1
- package/dist/tools/implementation/refs.d.ts.map +1 -1
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +4 -0
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts +7 -0
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +8 -0
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/types.d.ts +4 -0
- package/dist/tools/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/browser/createBrowserContext.ts +34 -4
- package/src/react/hooks.tsx +1 -0
- package/src/react/index.ts +1 -0
- package/src/react/media/image.tsx +2 -0
- package/src/react/tests/media/image.test.tsx +20 -2
- package/src/react-core/hooks.ts +42 -0
- package/src/react-core/testing.tsx +1 -0
- package/src/react-core/tests/useAccountWithSelector.test.ts +98 -2
- package/src/react-core/tests/useSyncConnectionStatus.test.ts +48 -0
- package/src/react-native-core/hooks.tsx +1 -0
- package/src/react-native-core/media/image.tsx +4 -1
- package/src/react-native-core/platform.ts +32 -4
- package/src/svelte/jazz.class.svelte.ts +44 -0
- package/src/svelte/media/image.svelte +104 -98
- package/src/svelte/testing.ts +1 -0
- package/src/svelte/tests/TestConnectionStatus.svelte +8 -0
- package/src/svelte/tests/media/image.svelte.test.ts +18 -2
- package/src/svelte/tests/sync-connection-status.svelte.test.ts +61 -0
- package/src/tools/implementation/ContextManager.ts +8 -0
- package/src/tools/implementation/refs.ts +27 -3
- package/src/tools/subscribe/CoValueCoreSubscription.ts +14 -0
- package/src/tools/subscribe/SubscriptionScope.ts +67 -2
- package/src/tools/subscribe/index.ts +8 -0
- package/src/tools/testing.ts +29 -0
- package/src/tools/tests/ContextManager.test.ts +2 -2
- package/src/tools/tests/coMap.test.ts +42 -0
- package/src/tools/tests/subscribe.test.ts +1 -4
- package/src/tools/types.ts +4 -0
- package/dist/chunk-GRN6OAUX.js.map +0 -1
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/react-core/hooks.ts","../../src/react-core/utils.ts","../../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 Group,\n InboxSender,\n InstanceOfSchema,\n JazzContextManager,\n JazzContextType,\n Loaded,\n ResolveQuery,\n ResolveQueryStrict,\n SubscriptionScope,\n coValueClassFromCoValueClassOrSchema,\n type BranchDefinition,\n} from \"jazz-tools\";\nimport { JazzContext, JazzContextManagerContext } from \"./provider.js\";\nimport { getCurrentAccountFromContextManager } from \"./utils.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\nfunction useCoValueSubscription<\n S extends CoValueClassOrSchema,\n const R extends ResolveQuery<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\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 node = contextManager.getCurrentValue()!.node;\n const subscription = new SubscriptionScope<any>(\n node,\n options?.resolve ?? true,\n 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 id,\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.id !== id ||\n subscription.Schema !== Schema ||\n subscription.branchName !== branchName ||\n subscription.branchOwnerId !== branchOwnerId\n ) {\n subscription.subscription?.destroy();\n setSubscription(createSubscription());\n }\n\n return contextManager.subscribe(() => {\n subscription.subscription?.destroy();\n setSubscription(createSubscription());\n });\n }, [Schema, id, contextManager, branchName, branchOwnerId]);\n\n return subscription.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 * @returns The loaded CoValue, or `undefined` if loading, or `null` if not found/not accessible\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) {\n * return project === null\n * ? \"Project not found or not accessible\"\n * : \"Loading project...\";\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: null } },\n * },\n * });\n *\n * if (!task) {\n * return task === null\n * ? \"Task not found or not accessible\"\n * : \"Loading task...\";\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 ? <li key={subtask.id}>{subtask.title}</li> : <li key={index}>Inaccessible subtask</li>\n * ))}\n * </ul>\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 const R extends ResolveQuery<S> = true,\n>(\n /** The CoValue schema or class constructor */\n Schema: S,\n /** The ID of the CoValue to subscribe to. If `undefined`, returns `null` */\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 /**\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): Loaded<S, R> | undefined | null {\n const subscription = useCoValueSubscription(Schema, id, options);\n\n const value = React.useSyncExternalStore<Loaded<S, R> | undefined | null>(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n );\n\n return value;\n}\n\n/**\n * React hook for subscribing to CoValues with selective data extraction and custom equality checking.\n *\n * This hook extends `useCoState` by allowing you to select only specific parts of the CoValue data\n * through a selector function, which helps reduce unnecessary re-renders by narrowing down the\n * returned data. Additionally, you can provide a custom equality function to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * The hook automatically handles the subscription lifecycle and supports deep loading of nested\n * CoValues through resolve queries, just like `useCoState`.\n *\n * @returns The result of the selector function applied to the loaded CoValue data\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 = useCoStateWithSelector(\n * Project,\n * projectId,\n * {\n * select: (project) => project?.name ?? \"Loading...\",\n * }\n * );\n *\n * return <h1>{projectName}</h1>;\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 = useCoStateWithSelector(\n * TaskList,\n * listId,\n * {\n * resolve: { $each: true },\n * select: (tasks) => {\n * if (!tasks) 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 * @example\n * ```tsx\n * // Combine with deep loading and complex selectors\n * const Team = co.map({\n * name: z.string(),\n * members: co.list(TeamMember),\n * projects: co.list(Project),\n * });\n *\n * function TeamSummary({ teamId }: { teamId: string }) {\n * const summary = useCoStateWithSelector(\n * Team,\n * teamId,\n * {\n * resolve: {\n * members: { $each: true },\n * projects: { $each: { tasks: { $each: true } } },\n * },\n * select: (team) => {\n * if (!team) return null;\n *\n * const totalTasks = team.projects.reduce(\n * (sum, project) => sum + project.tasks.length,\n * 0\n * );\n *\n * return {\n * teamName: team.name,\n * memberCount: team.members.length,\n * projectCount: team.projects.length,\n * totalTasks,\n * };\n * },\n * }\n * );\n *\n * if (!summary) return <div>Loading team summary...</div>;\n *\n * return (\n * <div>\n * <h2>{summary.teamName}</h2>\n * <p>{summary.memberCount} members</p>\n * <p>{summary.projectCount} projects</p>\n * <p>{summary.totalTasks} total tasks</p>\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 useCoStateWithSelector<\n S extends CoValueClassOrSchema,\n TSelectorReturn,\n const R extends ResolveQuery<S> = true,\n>(\n /** The CoValue schema or class constructor */\n Schema: S,\n /** The ID of the CoValue to subscribe to. If `undefined`, returns the result of selector called with `null` */\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: Loaded<S, R> | undefined | null) => 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 = useCoValueSubscription(Schema, id, options);\n\n return useSyncExternalStoreWithSelector<\n Loaded<S, R> | undefined | null,\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 () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n options.select,\n options.equalityFn ?? Object.is,\n );\n}\n\nfunction useAccountSubscription<\n S extends AccountClass<Account> | AnyAccountSchema,\n const R extends ResolveQuery<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 // We don't need type validation here, since it's mostly to help users on public API\n const resolve: any = options?.resolve ?? true;\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;\n}\n\n/**\n * React hook for accessing the current user's account and authentication state.\n * \n * This hook provides access to the current user's account profile and root data,\n * along with authentication utilities. It automatically handles subscription to\n * the user's account data and provides a logout function.\n * \n * @returns An object containing:\n * - `me`: The loaded account data, or `undefined` if loading, or `null` if not authenticated\n * - `agent`: The current agent (anonymous or authenticated user). Can be used as `loadAs` parameter for load and subscribe methods.\n * - `logOut`: Function to log out the current user\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) {\n * return me === null\n * ? <div>Failed to load your projects</div>\n * : <div>Loading...</div>;\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 R extends ResolveQuery<A> = true,\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 /**\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): {\n me: Loaded<A, R> | undefined | null;\n agent: AnonymousJazzAgent | Loaded<A, true>;\n logOut: () => void;\n} {\n const contextManager = useJazzContextManager<InstanceOfSchema<A>>();\n const subscription = useAccountSubscription(AccountSchema, options);\n\n const agent = getCurrentAccountFromContextManager(contextManager);\n\n const value = React.useSyncExternalStore<Loaded<A, R> | undefined | null>(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n );\n\n return {\n me: value,\n agent,\n logOut: contextManager.logOut,\n };\n}\n\n/**\n * React hook for accessing the current user's account with selective data extraction and custom equality checking.\n *\n * This hook extends `useAccount` by allowing you to select only specific parts of the account data\n * through a selector function, which helps reduce unnecessary re-renders by narrowing down the\n * returned data. Additionally, you can provide a custom equality function to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * The hook automatically handles the subscription lifecycle and supports deep loading of nested\n * CoValues through resolve queries, just like `useAccount`.\n *\n * @returns The result of the selector function applied to the loaded account data\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 = useAccountWithSelector(\n * MyAppAccount,\n * {\n * resolve: {\n * profile: true,\n * root: true,\n * },\n * select: (account) => account?.profile?.name ?? \"Loading...\",\n * }\n * );\n *\n * return <h1>{profileName}</h1>;\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 useAccountWithSelector<\n A extends AccountClass<Account> | AnyAccountSchema,\n TSelectorReturn,\n R extends ResolveQuery<A> = true,\n>(\n /** The account schema to use. Defaults to the base Account schema */\n AccountSchema: A = Account as unknown as A,\n /** Configuration for the subscription and selection */\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> | undefined | null) => 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): TSelectorReturn {\n const subscription = useAccountSubscription(AccountSchema, options);\n\n return useSyncExternalStoreWithSelector<\n Loaded<A, R> | undefined | null,\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 () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n options.select,\n options.equalityFn ?? Object.is,\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 if (inbox.owner.id !== inboxOwnerID) {\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],\n );\n\n return sendMessage;\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 { 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,EAOA;AAAA,EAOA;AAAA,EACA;AAAA,OAEK;;;ACxBA,SAAS,oCACd,gBACA;AACA,QAAM,UAAU,eAAe,gBAAgB;AAE/C,MAAI,CAAC,SAAS;AACZ,UAAM,IAAI,MAAM,kBAAkB;AAAA,EACpC;AAEA,SAAO,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AS,aAAa,UAAkB;AACtC,WAAO,WAAW,OAAO,QAAQ,EAAE,KAAK,MAAM;AAC5C,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":["subscription","inbox","useCallback","useMemo","useSyncExternalStore","useMemo","useSyncExternalStore","useCallback"]}
|
1
|
+
{"version":3,"sources":["../../src/react-core/hooks.ts","../../src/react-core/utils.ts","../../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 Group,\n InboxSender,\n InstanceOfSchema,\n JazzContextManager,\n JazzContextType,\n Loaded,\n ResolveQuery,\n ResolveQueryStrict,\n SubscriptionScope,\n coValueClassFromCoValueClassOrSchema,\n type BranchDefinition,\n} from \"jazz-tools\";\nimport { JazzContext, JazzContextManagerContext } from \"./provider.js\";\nimport { getCurrentAccountFromContextManager } from \"./utils.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\nfunction useCoValueSubscription<\n S extends CoValueClassOrSchema,\n const R extends ResolveQuery<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\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 node = contextManager.getCurrentValue()!.node;\n const subscription = new SubscriptionScope<any>(\n node,\n options?.resolve ?? true,\n 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 id,\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.id !== id ||\n subscription.Schema !== Schema ||\n subscription.branchName !== branchName ||\n subscription.branchOwnerId !== branchOwnerId\n ) {\n subscription.subscription?.destroy();\n setSubscription(createSubscription());\n }\n\n return contextManager.subscribe(() => {\n subscription.subscription?.destroy();\n setSubscription(createSubscription());\n });\n }, [Schema, id, contextManager, branchName, branchOwnerId]);\n\n return subscription.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 * @returns The loaded CoValue, or `undefined` if loading, or `null` if not found/not accessible\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) {\n * return project === null\n * ? \"Project not found or not accessible\"\n * : \"Loading project...\";\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: null } },\n * },\n * });\n *\n * if (!task) {\n * return task === null\n * ? \"Task not found or not accessible\"\n * : \"Loading task...\";\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 ? <li key={subtask.id}>{subtask.title}</li> : <li key={index}>Inaccessible subtask</li>\n * ))}\n * </ul>\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 const R extends ResolveQuery<S> = true,\n>(\n /** The CoValue schema or class constructor */\n Schema: S,\n /** The ID of the CoValue to subscribe to. If `undefined`, returns `null` */\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 /**\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): Loaded<S, R> | undefined | null {\n const subscription = useCoValueSubscription(Schema, id, options);\n\n const value = React.useSyncExternalStore<Loaded<S, R> | undefined | null>(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n );\n\n return value;\n}\n\n/**\n * React hook for subscribing to CoValues with selective data extraction and custom equality checking.\n *\n * This hook extends `useCoState` by allowing you to select only specific parts of the CoValue data\n * through a selector function, which helps reduce unnecessary re-renders by narrowing down the\n * returned data. Additionally, you can provide a custom equality function to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * The hook automatically handles the subscription lifecycle and supports deep loading of nested\n * CoValues through resolve queries, just like `useCoState`.\n *\n * @returns The result of the selector function applied to the loaded CoValue data\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 = useCoStateWithSelector(\n * Project,\n * projectId,\n * {\n * select: (project) => project?.name ?? \"Loading...\",\n * }\n * );\n *\n * return <h1>{projectName}</h1>;\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 = useCoStateWithSelector(\n * TaskList,\n * listId,\n * {\n * resolve: { $each: true },\n * select: (tasks) => {\n * if (!tasks) 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 * @example\n * ```tsx\n * // Combine with deep loading and complex selectors\n * const Team = co.map({\n * name: z.string(),\n * members: co.list(TeamMember),\n * projects: co.list(Project),\n * });\n *\n * function TeamSummary({ teamId }: { teamId: string }) {\n * const summary = useCoStateWithSelector(\n * Team,\n * teamId,\n * {\n * resolve: {\n * members: { $each: true },\n * projects: { $each: { tasks: { $each: true } } },\n * },\n * select: (team) => {\n * if (!team) return null;\n *\n * const totalTasks = team.projects.reduce(\n * (sum, project) => sum + project.tasks.length,\n * 0\n * );\n *\n * return {\n * teamName: team.name,\n * memberCount: team.members.length,\n * projectCount: team.projects.length,\n * totalTasks,\n * };\n * },\n * }\n * );\n *\n * if (!summary) return <div>Loading team summary...</div>;\n *\n * return (\n * <div>\n * <h2>{summary.teamName}</h2>\n * <p>{summary.memberCount} members</p>\n * <p>{summary.projectCount} projects</p>\n * <p>{summary.totalTasks} total tasks</p>\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 useCoStateWithSelector<\n S extends CoValueClassOrSchema,\n TSelectorReturn,\n const R extends ResolveQuery<S> = true,\n>(\n /** The CoValue schema or class constructor */\n Schema: S,\n /** The ID of the CoValue to subscribe to. If `undefined`, returns the result of selector called with `null` */\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: Loaded<S, R> | undefined | null) => 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 = useCoValueSubscription(Schema, id, options);\n\n return useSyncExternalStoreWithSelector<\n Loaded<S, R> | undefined | null,\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 () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n options.select,\n options.equalityFn ?? Object.is,\n );\n}\n\nfunction useAccountSubscription<\n S extends AccountClass<Account> | AnyAccountSchema,\n const R extends ResolveQuery<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 // We don't need type validation here, since it's mostly to help users on public API\n const resolve: any = options?.resolve ?? true;\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;\n}\n\n/**\n * React hook for accessing the current user's account and authentication state.\n * \n * This hook provides access to the current user's account profile and root data,\n * along with authentication utilities. It automatically handles subscription to\n * the user's account data and provides a logout function.\n * \n * @returns An object containing:\n * - `me`: The loaded account data, or `undefined` if loading, or `null` if not authenticated\n * - `agent`: The current agent (anonymous or authenticated user). Can be used as `loadAs` parameter for load and subscribe methods.\n * - `logOut`: Function to log out the current user\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) {\n * return me === null\n * ? <div>Failed to load your projects</div>\n * : <div>Loading...</div>;\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 R extends ResolveQuery<A> = true,\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 /**\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): {\n me: Loaded<A, R> | undefined | null;\n agent: AnonymousJazzAgent | Loaded<A, true>;\n logOut: () => void;\n} {\n const contextManager = useJazzContextManager<InstanceOfSchema<A>>();\n const subscription = useAccountSubscription(AccountSchema, options);\n\n const agent = getCurrentAccountFromContextManager(contextManager);\n\n const value = React.useSyncExternalStore<Loaded<A, R> | undefined | null>(\n React.useCallback(\n (callback) => {\n if (!subscription) {\n return () => {};\n }\n\n return subscription.subscribe(callback);\n },\n [subscription],\n ),\n () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n );\n\n return {\n me: value,\n agent,\n logOut: contextManager.logOut,\n };\n}\n\n/**\n * React hook for accessing the current user's account with selective data extraction and custom equality checking.\n *\n * This hook extends `useAccount` by allowing you to select only specific parts of the account data\n * through a selector function, which helps reduce unnecessary re-renders by narrowing down the\n * returned data. Additionally, you can provide a custom equality function to further optimize\n * performance by controlling when the component should re-render based on the selected data.\n *\n * The hook automatically handles the subscription lifecycle and supports deep loading of nested\n * CoValues through resolve queries, just like `useAccount`.\n *\n * @returns The result of the selector function applied to the loaded account data\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 = useAccountWithSelector(\n * MyAppAccount,\n * {\n * resolve: {\n * profile: true,\n * root: true,\n * },\n * select: (account) => account?.profile?.name ?? \"Loading...\",\n * }\n * );\n *\n * return <h1>{profileName}</h1>;\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 useAccountWithSelector<\n A extends AccountClass<Account> | AnyAccountSchema,\n TSelectorReturn,\n R extends ResolveQuery<A> = true,\n>(\n /** The account schema to use. Defaults to the base Account schema */\n AccountSchema: A = Account as unknown as A,\n /** Configuration for the subscription and selection */\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> | undefined | null) => 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 return useSyncExternalStoreWithSelector<\n Loaded<A, R> | undefined | null,\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 () => (subscription ? subscription.getCurrentValue() : null),\n () => (subscription ? subscription.getCurrentValue() : null),\n options.select,\n options.equalityFn ?? Object.is,\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 if (inbox.owner.id !== inboxOwnerID) {\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],\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","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 { 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,EAOA;AAAA,EAOA;AAAA,EACA;AAAA,OAEK;;;ACxBA,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;;;ADkBO,SAAS,iBAAsC;AACpD,QAAM,QAAQ,WAAW,WAAW;AAEpC,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,wBAA6C;AAC3D,QAAM,QAAQ,WAAW,yBAAyB;AAKlD,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;AAEO,SAAS,uBAAuB;AACrC,QAAM,QAAQ,WAAW,yBAAyB;AAElD,MAAI,CAAC,OAAO;AACV,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EACF;AAEA,SAAO,MAAM,qBAAqB;AACpC;AAEO,SAAS,qBAAqB;AACnC,QAAM,oBAAoB,qBAAqB;AAE/C,SAAO;AAAA,IACL;AAAA,MACE,CAAC,aAAa;AACZ,eAAO,kBAAkB,SAAS,QAAQ;AAAA,MAC5C;AAAA,MACA,CAAC,iBAAiB;AAAA,IACpB;AAAA,IACA,MAAM,kBAAkB;AAAA,IACxB,MAAM,kBAAkB;AAAA,EAC1B;AACF;AAEA,SAAS,uBAIP,QACA,IACA,SAIA;AACA,QAAM,iBAAiB,sBAAsB;A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AAM;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","inbox","useCallback","useMemo","useSyncExternalStore","useMemo","useSyncExternalStore","useCallback"]}
|
@@ -6,5 +6,5 @@ export declare function JazzTestProvider<Acc extends Account>({ children, accoun
|
|
6
6
|
};
|
7
7
|
isAuthenticated?: boolean;
|
8
8
|
}): import("react/jsx-runtime").JSX.Element;
|
9
|
-
export { createJazzTestAccount, createJazzTestGuest, linkAccounts, setActiveAccount, setupJazzTestSync, } from "jazz-tools/testing";
|
9
|
+
export { createJazzTestAccount, createJazzTestGuest, linkAccounts, setActiveAccount, setupJazzTestSync, MockConnectionStatus, } from "jazz-tools/testing";
|
10
10
|
//# sourceMappingURL=testing.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/react-core/testing.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKzD,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,OAAO,EAAE,EACpD,QAAQ,EACR,OAAO,EACP,eAAe,GAChB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,GAAG,GAAG;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,CAAC;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,2CAoBA;AAED,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../../src/react-core/testing.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAKzD,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,OAAO,EAAE,EACpD,QAAQ,EACR,OAAO,EACP,eAAe,GAChB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,CAAC,EAAE,GAAG,GAAG;QAAE,KAAK,EAAE,kBAAkB,CAAA;KAAE,CAAC;IAC9C,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,2CAoBA;AAED,OAAO,EACL,qBAAqB,EACrB,mBAAmB,EACnB,YAAY,EACZ,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC"}
|
@@ -12,7 +12,8 @@ import {
|
|
12
12
|
createJazzTestGuest,
|
13
13
|
linkAccounts,
|
14
14
|
setActiveAccount,
|
15
|
-
setupJazzTestSync
|
15
|
+
setupJazzTestSync,
|
16
|
+
MockConnectionStatus
|
16
17
|
} from "jazz-tools/testing";
|
17
18
|
import { jsx } from "react/jsx-runtime";
|
18
19
|
function JazzTestProvider({
|
@@ -34,6 +35,7 @@ function JazzTestProvider({
|
|
34
35
|
}
|
35
36
|
export {
|
36
37
|
JazzTestProvider,
|
38
|
+
MockConnectionStatus,
|
37
39
|
createJazzTestAccount,
|
38
40
|
createJazzTestGuest,
|
39
41
|
linkAccounts,
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/react-core/testing.tsx"],"sourcesContent":["import { Account, AnonymousJazzAgent } from \"jazz-tools\";\nimport { TestJazzContextManager } from \"jazz-tools/testing\";\nimport { useCallback, useState, useSyncExternalStore } from \"react\";\nimport { JazzContext, JazzContextManagerContext } from \"./provider.js\";\n\nexport function JazzTestProvider<Acc extends Account>({\n children,\n account,\n isAuthenticated,\n}: {\n children: React.ReactNode;\n account?: Acc | { guest: AnonymousJazzAgent };\n isAuthenticated?: boolean;\n}) {\n const [contextManager] = useState(() => {\n return TestJazzContextManager.fromAccountOrGuest<Acc>(account, {\n isAuthenticated,\n });\n });\n\n const value = useSyncExternalStore(\n useCallback((callback) => contextManager.subscribe(callback), []),\n () => contextManager.getCurrentValue(),\n () => contextManager.getCurrentValue(),\n );\n\n return (\n <JazzContext.Provider value={value}>\n <JazzContextManagerContext.Provider value={contextManager}>\n {children}\n </JazzContextManagerContext.Provider>\n </JazzContext.Provider>\n );\n}\n\nexport {\n createJazzTestAccount,\n createJazzTestGuest,\n linkAccounts,\n setActiveAccount,\n setupJazzTestSync,\n} from \"jazz-tools/testing\";\n"],"mappings":";;;;;;;AACA,SAAS,8BAA8B;AACvC,SAAS,aAAa,UAAU,4BAA4B;AAiC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;
|
1
|
+
{"version":3,"sources":["../../src/react-core/testing.tsx"],"sourcesContent":["import { Account, AnonymousJazzAgent } from \"jazz-tools\";\nimport { TestJazzContextManager } from \"jazz-tools/testing\";\nimport { useCallback, useState, useSyncExternalStore } from \"react\";\nimport { JazzContext, JazzContextManagerContext } from \"./provider.js\";\n\nexport function JazzTestProvider<Acc extends Account>({\n children,\n account,\n isAuthenticated,\n}: {\n children: React.ReactNode;\n account?: Acc | { guest: AnonymousJazzAgent };\n isAuthenticated?: boolean;\n}) {\n const [contextManager] = useState(() => {\n return TestJazzContextManager.fromAccountOrGuest<Acc>(account, {\n isAuthenticated,\n });\n });\n\n const value = useSyncExternalStore(\n useCallback((callback) => contextManager.subscribe(callback), []),\n () => contextManager.getCurrentValue(),\n () => contextManager.getCurrentValue(),\n );\n\n return (\n <JazzContext.Provider value={value}>\n <JazzContextManagerContext.Provider value={contextManager}>\n {children}\n </JazzContextManagerContext.Provider>\n </JazzContext.Provider>\n );\n}\n\nexport {\n createJazzTestAccount,\n createJazzTestGuest,\n linkAccounts,\n setActiveAccount,\n setupJazzTestSync,\n MockConnectionStatus,\n} from \"jazz-tools/testing\";\n"],"mappings":";;;;;;;AACA,SAAS,8BAA8B;AACvC,SAAS,aAAa,UAAU,4BAA4B;AAiC5D;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAdD;AAvBC,SAAS,iBAAsC;AAAA,EACpD;AAAA,EACA;AAAA,EACA;AACF,GAIG;AACD,QAAM,CAAC,cAAc,IAAI,SAAS,MAAM;AACtC,WAAO,uBAAuB,mBAAwB,SAAS;AAAA,MAC7D;AAAA,IACF,CAAC;AAAA,EACH,CAAC;AAED,QAAM,QAAQ;AAAA,IACZ,YAAY,CAAC,aAAa,eAAe,UAAU,QAAQ,GAAG,CAAC,CAAC;AAAA,IAChE,MAAM,eAAe,gBAAgB;AAAA,IACrC,MAAM,eAAe,gBAAgB;AAAA,EACvC;AAEA,SACE,oBAAC,YAAY,UAAZ,EAAqB,OACpB,8BAAC,0BAA0B,UAA1B,EAAmC,OAAO,gBACxC,UACH,GACF;AAEJ;","names":[]}
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"useSyncConnectionStatus.test.d.ts","sourceRoot":"","sources":["../../../src/react-core/tests/useSyncConnectionStatus.test.ts"],"names":[],"mappings":""}
|
@@ -18,12 +18,16 @@ export declare class ReactNativeContextManager<S extends (AccountClass<Account>
|
|
18
18
|
node: import("cojson").LocalNode;
|
19
19
|
done: () => void;
|
20
20
|
logOut: () => Promise<void>;
|
21
|
+
addConnectionListener: (listener: (connected: boolean) => void) => () => void;
|
22
|
+
connected: () => boolean;
|
21
23
|
} | {
|
22
24
|
me: InstanceOfSchema<S>;
|
23
25
|
node: import("cojson").LocalNode;
|
24
26
|
authSecretStorage: import("jazz-tools").AuthSecretStorage;
|
25
27
|
done: () => void;
|
26
28
|
logOut: () => Promise<void>;
|
29
|
+
addConnectionListener: (listener: (connected: boolean) => void) => () => void;
|
30
|
+
connected: () => boolean;
|
27
31
|
}>;
|
28
32
|
getKvStore(): KvStore;
|
29
33
|
propsChanged(props: JazzContextManagerProps<S>): boolean;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"ReactNativeContextManager.d.ts","sourceRoot":"","sources":["../../src/react-native-core/ReactNativeContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,OAAO,EACP,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,6BAA6B,EAG9B,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,uBAAuB,CACjC,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,gBAAgB,IAClB;IACF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,6BAA6B,CAAC,SAAS,CAAC,CAAC;IACnD,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,2BAA2B,CAAC,EAAE,CAC5B,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAClC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,cAAc,CAAC,EAAE,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;CAClE,CAAC;AAEF,qBAAa,yBAAyB,CACpC,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,gBAAgB,CACpB,SAAQ,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACrE,aAAa,CACjB,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,EACjC,SAAS,CAAC,EAAE,2BAA2B
|
1
|
+
{"version":3,"file":"ReactNativeContextManager.d.ts","sourceRoot":"","sources":["../../src/react-native-core/ReactNativeContextManager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,OAAO,EACP,UAAU,EACX,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,2BAA2B,EAC5B,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,6BAA6B,EAG9B,MAAM,eAAe,CAAC;AAGvB,MAAM,MAAM,uBAAuB,CACjC,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,gBAAgB,IAClB;IACF,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,IAAI,EAAE,UAAU,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,IAAI,CAAC;IACtB,iBAAiB,CAAC,EAAE,MAAM,IAAI,CAAC;IAC/B,OAAO,CAAC,EAAE,6BAA6B,CAAC,SAAS,CAAC,CAAC;IACnD,aAAa,CAAC,EAAE,CAAC,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,2BAA2B,CAAC,EAAE,CAC5B,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,KAClC,OAAO,CAAC,IAAI,CAAC,CAAC;IACnB,cAAc,CAAC,EAAE,6BAA6B,CAAC,gBAAgB,CAAC,CAAC;CAClE,CAAC;AAEF,qBAAa,yBAAyB,CACpC,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,gBAAgB,CACpB,SAAQ,kBAAkB,CAAC,gBAAgB,CAAC,CAAC,CAAC,EAAE,uBAAuB,CAAC,CAAC,CAAC,CAAC;IACrE,aAAa,CACjB,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC,EACjC,SAAS,CAAC,EAAE,2BAA2B;;;;;;;;;;;;;;;;IAuBzC,UAAU,IAAI,OAAO;IAIrB,YAAY,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC,CAAC;CAW/C"}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { CoValueClassOrSchema } from "jazz-tools";
|
2
|
-
export { useCoState, experimental_useInboxSender, useDemoAuth, usePassphraseAuth, useJazzContext, useAuthSecretStorage, useIsAuthenticated, useAccount, useCoStateWithSelector, useAccountWithSelector, } from "jazz-tools/react-core";
|
2
|
+
export { useCoState, experimental_useInboxSender, useDemoAuth, usePassphraseAuth, useJazzContext, useAuthSecretStorage, useIsAuthenticated, useAccount, useCoStateWithSelector, useAccountWithSelector, useSyncConnectionStatus, } from "jazz-tools/react-core";
|
3
3
|
export declare function useAcceptInviteNative<S extends CoValueClassOrSchema>({ invitedObjectSchema, onAccept, forValueHint, }: {
|
4
4
|
invitedObjectSchema: S;
|
5
5
|
onAccept: (projectID: string) => void;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react-native-core/hooks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,YAAY,CAAC;AAInE,OAAO,EACL,UAAU,EACV,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EACtB,sBAAsB,
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react-native-core/hooks.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAmB,MAAM,YAAY,CAAC;AAInE,OAAO,EACL,UAAU,EACV,2BAA2B,EAC3B,WAAW,EACX,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,sBAAsB,EACtB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,uBAAuB,CAAC;AAE/B,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,oBAAoB,EAAE,EACpE,mBAAmB,EACnB,QAAQ,EACR,YAAY,GACb,EAAE;IACD,mBAAmB,EAAE,CAAC,CAAC;IACvB,QAAQ,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB,GAAG,IAAI,CAsCP"}
|
@@ -247,7 +247,8 @@ import {
|
|
247
247
|
useIsAuthenticated,
|
248
248
|
useAccount,
|
249
249
|
useCoStateWithSelector,
|
250
|
-
useAccountWithSelector
|
250
|
+
useAccountWithSelector,
|
251
|
+
useSyncConnectionStatus
|
251
252
|
} from "jazz-tools/react-core";
|
252
253
|
function useAcceptInviteNative({
|
253
254
|
invitedObjectSchema,
|
@@ -321,6 +322,9 @@ async function setupPeers(options) {
|
|
321
322
|
return {
|
322
323
|
toggleNetwork: () => {
|
323
324
|
},
|
325
|
+
addConnectionListener: () => () => {
|
326
|
+
},
|
327
|
+
connected: () => false,
|
324
328
|
peersToLoadFrom,
|
325
329
|
setNode: () => {
|
326
330
|
},
|
@@ -357,6 +361,13 @@ async function setupPeers(options) {
|
|
357
361
|
}
|
358
362
|
return {
|
359
363
|
toggleNetwork,
|
364
|
+
addConnectionListener(listener) {
|
365
|
+
wsPeer.subscribe(listener);
|
366
|
+
return () => {
|
367
|
+
wsPeer.unsubscribe(listener);
|
368
|
+
};
|
369
|
+
},
|
370
|
+
connected: () => wsPeer.connected,
|
360
371
|
peersToLoadFrom,
|
361
372
|
setNode,
|
362
373
|
crypto,
|
@@ -364,7 +375,15 @@ async function setupPeers(options) {
|
|
364
375
|
};
|
365
376
|
}
|
366
377
|
async function createJazzReactNativeGuestContext(options) {
|
367
|
-
const {
|
378
|
+
const {
|
379
|
+
toggleNetwork,
|
380
|
+
peersToLoadFrom,
|
381
|
+
setNode,
|
382
|
+
crypto,
|
383
|
+
storage,
|
384
|
+
addConnectionListener,
|
385
|
+
connected
|
386
|
+
} = await setupPeers(options);
|
368
387
|
const context = createAnonymousJazzContext({
|
369
388
|
crypto,
|
370
389
|
peersToLoadFrom,
|
@@ -381,11 +400,21 @@ async function createJazzReactNativeGuestContext(options) {
|
|
381
400
|
},
|
382
401
|
logOut: () => {
|
383
402
|
return context.logOut();
|
384
|
-
}
|
403
|
+
},
|
404
|
+
addConnectionListener,
|
405
|
+
connected
|
385
406
|
};
|
386
407
|
}
|
387
408
|
async function createJazzReactNativeContext(options) {
|
388
|
-
const {
|
409
|
+
const {
|
410
|
+
toggleNetwork,
|
411
|
+
peersToLoadFrom,
|
412
|
+
setNode,
|
413
|
+
crypto,
|
414
|
+
storage,
|
415
|
+
addConnectionListener,
|
416
|
+
connected
|
417
|
+
} = await setupPeers(options);
|
389
418
|
let unsubscribeAuthUpdate = () => {
|
390
419
|
};
|
391
420
|
if (options.sync.when === "signedUp") {
|
@@ -427,7 +456,9 @@ async function createJazzReactNativeContext(options) {
|
|
427
456
|
logOut: () => {
|
428
457
|
unsubscribeAuthUpdate();
|
429
458
|
return context.logOut();
|
430
|
-
}
|
459
|
+
},
|
460
|
+
addConnectionListener,
|
461
|
+
connected
|
431
462
|
};
|
432
463
|
}
|
433
464
|
async function provideLockSession(accountID, crypto) {
|
@@ -563,7 +594,9 @@ import { Image as RNImage } from "react-native";
|
|
563
594
|
import { jsx as jsx3 } from "react/jsx-runtime";
|
564
595
|
var Image = forwardRef(function Image2({ imageId, width, height, ...props }, ref) {
|
565
596
|
const image = useCoState(ImageDefinition, imageId);
|
566
|
-
const [src, setSrc] = useState2(
|
597
|
+
const [src, setSrc] = useState2(
|
598
|
+
image?.placeholderDataURL ?? "data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
|
599
|
+
);
|
567
600
|
const dimensions = useMemo(() => {
|
568
601
|
const originalWidth = image?.originalSize?.[0];
|
569
602
|
const originalHeight = image?.originalSize?.[1];
|
@@ -655,6 +688,7 @@ export {
|
|
655
688
|
useDemoAuth,
|
656
689
|
useIsAuthenticated,
|
657
690
|
useJazzContext2 as useJazzContext,
|
658
|
-
usePassphraseAuth
|
691
|
+
usePassphraseAuth,
|
692
|
+
useSyncConnectionStatus
|
659
693
|
};
|
660
694
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["../../src/react-native-core/storage/kv-store-context.ts","../../src/react-native-core/auth/DemoAuthUI.tsx","../../src/react-native-core/auth/auth.ts","../../src/react-native-core/hooks.tsx","../../src/react-native-core/provider.tsx","../../src/react-native-core/ReactNativeContextManager.ts","../../src/react-native-core/platform.ts","../../src/react-native-core/media/image.tsx","../../src/react-native-core/index.ts"],"sourcesContent":["export interface KvStore {\n get(key: string): Promise<string | null>;\n set(key: string, value: string): Promise<void>;\n delete(key: string): Promise<void>;\n clearAll(): Promise<void>;\n}\n\nexport class KvStoreContext {\n private static instance: KvStoreContext;\n private storageInstance: KvStore | null = null;\n\n private constructor() {}\n\n public static getInstance(): KvStoreContext {\n if (!KvStoreContext.instance) {\n KvStoreContext.instance = new KvStoreContext();\n }\n return KvStoreContext.instance;\n }\n\n public isInitialized(): boolean {\n return this.storageInstance !== null;\n }\n\n public initialize(store: KvStore): void {\n if (!this.storageInstance) {\n this.storageInstance = store;\n }\n }\n\n public getStorage(): KvStore {\n if (!this.storageInstance) {\n throw new Error(\"Storage instance is not initialized.\");\n }\n return this.storageInstance;\n }\n}\n\nexport default KvStoreContext;\n","import { useDemoAuth } from \"jazz-tools/react-core\";\nimport React, { useState } from \"react\";\nimport {\n StyleSheet,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n useColorScheme,\n} from \"react-native\";\n\nexport const DemoAuthBasicUI = ({\n appName,\n auth,\n children,\n}: {\n appName: string;\n auth: ReturnType<typeof useDemoAuth>;\n children: React.ReactNode;\n}) => {\n const colorScheme = useColorScheme();\n const darkMode = colorScheme === \"dark\";\n const [username, setUsername] = useState<string>(\"\");\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n\n const handleSignUp = () => {\n setErrorMessage(null);\n\n auth.signUp(username).catch((error) => {\n setErrorMessage(error.message);\n });\n };\n\n const handleLogIn = (username: string) => {\n setErrorMessage(null);\n\n auth.logIn(username).catch((error) => {\n setErrorMessage(error.message);\n });\n };\n\n if (auth.state === \"signedIn\") {\n return children;\n }\n\n return (\n <View\n style={[\n styles.container,\n darkMode ? styles.darkBackground : styles.lightBackground,\n ]}\n >\n <View style={styles.formContainer}>\n <Text\n style={[\n styles.headerText,\n darkMode ? styles.darkText : styles.lightText,\n ]}\n >\n {appName}\n </Text>\n\n {errorMessage && <Text style={styles.errorText}>{errorMessage}</Text>}\n\n <TextInput\n placeholder=\"Display name\"\n value={username}\n onChangeText={setUsername}\n placeholderTextColor={darkMode ? \"#fff\" : \"#000\"}\n style={[\n styles.textInput,\n darkMode ? styles.darkInput : styles.lightInput,\n ]}\n />\n\n <TouchableOpacity\n onPress={handleSignUp}\n style={[\n styles.button,\n darkMode ? styles.darkButton : styles.lightButton,\n ]}\n >\n <Text\n style={darkMode ? styles.darkButtonText : styles.lightButtonText}\n >\n Sign Up as new account\n </Text>\n </TouchableOpacity>\n\n <View style={styles.existingUsersContainer}>\n {auth.existingUsers.map((user) => (\n <TouchableOpacity\n key={user}\n onPress={() => handleLogIn(user)}\n style={[\n styles.existingUserButton,\n darkMode ? styles.darkUserButton : styles.lightUserButton,\n ]}\n >\n <Text style={darkMode ? styles.darkText : styles.lightText}>\n Log In as \"{user}\"\n </Text>\n </TouchableOpacity>\n ))}\n </View>\n </View>\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: \"center\",\n alignItems: \"center\",\n padding: 20,\n },\n formContainer: {\n width: \"80%\",\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n headerText: {\n fontSize: 24,\n marginBottom: 20,\n },\n errorText: {\n color: \"red\",\n marginVertical: 5,\n textAlign: \"center\",\n },\n textInput: {\n borderWidth: 1,\n padding: 10,\n marginVertical: 10,\n width: \"100%\",\n borderRadius: 6,\n },\n darkInput: {\n borderColor: \"#444\",\n backgroundColor: \"#000\",\n color: \"#fff\",\n },\n lightInput: {\n borderColor: \"#ddd\",\n backgroundColor: \"#fff\",\n color: \"#000\",\n },\n button: {\n paddingVertical: 15,\n paddingHorizontal: 10,\n borderRadius: 6,\n width: \"100%\",\n marginVertical: 10,\n },\n darkButton: {\n backgroundColor: \"#444\",\n },\n lightButton: {\n backgroundColor: \"#ddd\",\n },\n darkButtonText: {\n color: \"#fff\",\n textAlign: \"center\",\n },\n lightButtonText: {\n color: \"#000\",\n textAlign: \"center\",\n },\n existingUsersContainer: {\n width: \"100%\",\n marginTop: 20,\n },\n existingUserButton: {\n paddingVertical: 15,\n paddingHorizontal: 10,\n borderRadius: 6,\n marginVertical: 5,\n },\n darkUserButton: {\n backgroundColor: \"#222\",\n },\n lightUserButton: {\n backgroundColor: \"#eee\",\n },\n loadingText: {\n fontSize: 18,\n color: \"#888\",\n },\n darkText: {\n color: \"#fff\",\n },\n lightText: {\n color: \"#000\",\n },\n darkBackground: {\n backgroundColor: \"#000\",\n },\n lightBackground: {\n backgroundColor: \"#fff\",\n },\n});\n","import { KvStoreContext } from \"../storage/kv-store-context.js\";\n\nexport * from \"./DemoAuthUI.js\";\n\nexport function clearUserCredentials() {\n const kvStore = KvStoreContext.getInstance().getStorage();\n\n // TODO: Migrate the Auth methods to use the same storage key/interface\n return Promise.all([\n kvStore.delete(\"demo-auth-logged-in-secret\"),\n kvStore.delete(\"jazz-clerk-auth\"),\n kvStore.delete(\"jazz-logged-in-secret\"),\n ]);\n}\n","import { useEffect } from \"react\";\n\nimport { CoValueClassOrSchema, parseInviteLink } from \"jazz-tools\";\nimport { useJazzContext } from \"jazz-tools/react-core\";\nimport { Linking } from \"react-native\";\n\nexport {\n useCoState,\n experimental_useInboxSender,\n useDemoAuth,\n usePassphraseAuth,\n useJazzContext,\n useAuthSecretStorage,\n useIsAuthenticated,\n useAccount,\n useCoStateWithSelector,\n useAccountWithSelector,\n} from \"jazz-tools/react-core\";\n\nexport function useAcceptInviteNative<S extends CoValueClassOrSchema>({\n invitedObjectSchema,\n onAccept,\n forValueHint,\n}: {\n invitedObjectSchema: S;\n onAccept: (projectID: string) => void;\n forValueHint?: string;\n}): void {\n const context = useJazzContext();\n\n if (!(\"me\" in context)) {\n throw new Error(\n \"useAcceptInviteNative can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n useEffect(() => {\n const handleDeepLink = ({ url }: { url: string }) => {\n const result = parseInviteLink(url);\n if (result && result.valueHint === forValueHint) {\n context.me\n .acceptInvite(\n result.valueID,\n result.inviteSecret,\n invitedObjectSchema,\n )\n .then(() => {\n onAccept(result.valueID);\n })\n .catch((e) => {\n console.error(\"Failed to accept invite\", e);\n });\n }\n };\n\n const linkingListener = Linking.addEventListener(\"url\", handleDeepLink);\n\n void Linking.getInitialURL().then((url) => {\n if (url) handleDeepLink({ url });\n });\n\n return () => {\n linkingListener.remove();\n };\n }, [context, onAccept, invitedObjectSchema, forValueHint]);\n}\n","import {\n Account,\n AccountClass,\n AnyAccountSchema,\n CoValueFromRaw,\n InstanceOfSchema,\n JazzContextType,\n KvStore,\n} from \"jazz-tools\";\nimport { JazzContext, JazzContextManagerContext } from \"jazz-tools/react-core\";\nimport React, { useEffect, useRef } from \"react\";\nimport type { JazzContextManagerProps } from \"./ReactNativeContextManager.js\";\nimport { ReactNativeContextManager } from \"./ReactNativeContextManager.js\";\nimport { setupKvStore } from \"./platform.js\";\n\nexport type JazzProviderProps<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> = {\n children: React.ReactNode;\n kvStore?: KvStore;\n} & JazzContextManagerProps<S>;\n\n/** @category Context & Hooks */\nexport function JazzProviderCore<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n>({\n children,\n guestMode,\n sync,\n storage,\n AccountSchema,\n defaultProfileName,\n onLogOut,\n logOutReplacement,\n onAnonymousAccountDiscarded,\n kvStore,\n CryptoProvider,\n}: JazzProviderProps<S>) {\n setupKvStore(kvStore);\n\n const [contextManager] = React.useState(\n () => new ReactNativeContextManager<S>(),\n );\n\n const onLogOutRefCallback = useRefCallback(onLogOut);\n const logOutReplacementRefCallback = useRefCallback(logOutReplacement);\n const onAnonymousAccountDiscardedRefCallback = useRefCallback(\n onAnonymousAccountDiscarded,\n );\n const logoutReplacementActiveRef = useRef(false);\n logoutReplacementActiveRef.current = Boolean(logOutReplacement);\n\n const value = React.useSyncExternalStore<\n JazzContextType<InstanceOfSchema<S>> | undefined\n >(\n React.useCallback(\n (callback) => {\n const props = {\n AccountSchema,\n guestMode,\n sync,\n storage,\n defaultProfileName,\n onLogOut: onLogOutRefCallback,\n logOutReplacement: logoutReplacementActiveRef.current\n ? logOutReplacementRefCallback\n : undefined,\n onAnonymousAccountDiscarded: onAnonymousAccountDiscardedRefCallback,\n CryptoProvider,\n } satisfies JazzContextManagerProps<S>;\n\n if (contextManager.propsChanged(props)) {\n contextManager.createContext(props).catch((error) => {\n console.log(error.stack);\n console.error(\"Error creating Jazz React Native context:\", error);\n });\n }\n\n return contextManager.subscribe(callback);\n },\n [sync, guestMode].concat(storage as any),\n ),\n () => contextManager.getCurrentValue(),\n () => contextManager.getCurrentValue(),\n );\n\n useEffect(() => {\n // In development mode we don't return a cleanup function because otherwise\n // the double effect execution would mark the context as done immediately.\n if (process.env.NODE_ENV === \"development\") return;\n\n return () => {\n contextManager.done();\n };\n }, []);\n\n return (\n <JazzContext.Provider value={value}>\n <JazzContextManagerContext.Provider value={contextManager}>\n {value && children}\n </JazzContextManagerContext.Provider>\n </JazzContext.Provider>\n );\n}\n\nfunction useRefCallback<T extends (...args: any[]) => any>(callback?: T) {\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n return useRef(\n (...args: Parameters<T>): ReturnType<T> => callbackRef.current?.(...args),\n ).current;\n}\n","import {\n Account,\n AccountClass,\n CoValueFromRaw,\n JazzContextManager,\n KvStore,\n SyncConfig,\n} from \"jazz-tools\";\nimport type {\n AnyAccountSchema,\n InstanceOfSchema,\n JazzContextManagerAuthProps,\n} from \"jazz-tools\";\nimport {\n BaseReactNativeContextOptions,\n createJazzReactNativeContext,\n createJazzReactNativeGuestContext,\n} from \"./platform.js\";\nimport { KvStoreContext } from \"./storage/kv-store-context.js\";\n\nexport type JazzContextManagerProps<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> = {\n guestMode?: boolean;\n sync: SyncConfig;\n onLogOut?: () => void;\n logOutReplacement?: () => void;\n storage?: BaseReactNativeContextOptions[\"storage\"];\n AccountSchema?: S;\n defaultProfileName?: string;\n onAnonymousAccountDiscarded?: (\n anonymousAccount: InstanceOfSchema<S>,\n ) => Promise<void>;\n CryptoProvider?: BaseReactNativeContextOptions[\"CryptoProvider\"];\n};\n\nexport class ReactNativeContextManager<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> extends JazzContextManager<InstanceOfSchema<S>, JazzContextManagerProps<S>> {\n async getNewContext(\n props: JazzContextManagerProps<S>,\n authProps?: JazzContextManagerAuthProps,\n ) {\n if (props.guestMode) {\n return createJazzReactNativeGuestContext({\n sync: props.sync,\n storage: props.storage,\n authSecretStorage: this.authSecretStorage,\n CryptoProvider: props.CryptoProvider,\n });\n } else {\n return createJazzReactNativeContext<S>({\n sync: props.sync,\n storage: props.storage,\n AccountSchema: props.AccountSchema,\n credentials: authProps?.credentials,\n newAccountProps: authProps?.newAccountProps,\n defaultProfileName: props.defaultProfileName,\n authSecretStorage: this.authSecretStorage,\n CryptoProvider: props.CryptoProvider,\n });\n }\n }\n\n getKvStore(): KvStore {\n return KvStoreContext.getInstance().getStorage();\n }\n\n propsChanged(props: JazzContextManagerProps<S>) {\n if (!this.props) {\n return true;\n }\n\n return (\n this.props.sync.when !== props.sync.when ||\n this.props.sync.peer !== props.sync.peer ||\n this.props.guestMode !== props.guestMode\n );\n }\n}\n","import NetInfo from \"@react-native-community/netinfo\";\nimport { LocalNode, Peer, RawAccountID, getSqliteStorageAsync } from \"cojson\";\nimport { PureJSCrypto } from \"cojson/dist/crypto/PureJSCrypto\"; // Importing from dist to not rely on the exports field\nimport {\n Account,\n AccountClass,\n AgentID,\n AnyAccountSchema,\n AuthCredentials,\n AuthSecretStorage,\n CoValue,\n CoValueFromRaw,\n CryptoProvider,\n ID,\n NewAccountProps,\n SessionID,\n SyncConfig,\n createInviteLink as baseCreateInviteLink,\n createAnonymousJazzContext,\n createJazzContext,\n} from \"jazz-tools\";\nimport { KvStore, KvStoreContext } from \"./storage/kv-store-context.js\";\n\nimport { SQLiteDatabaseDriverAsync } from \"cojson\";\nimport { WebSocketPeerWithReconnection } from \"cojson-transport-ws\";\nimport type { RNQuickCrypto } from \"jazz-tools/react-native-core/crypto\";\n\nexport type BaseReactNativeContextOptions = {\n sync: SyncConfig;\n reconnectionTimeout?: number;\n storage?: SQLiteDatabaseDriverAsync | \"disabled\";\n CryptoProvider?: typeof PureJSCrypto | typeof RNQuickCrypto;\n authSecretStorage: AuthSecretStorage;\n};\n\nclass ReactNativeWebSocketPeerWithReconnection extends WebSocketPeerWithReconnection {\n onNetworkChange(callback: (connected: boolean) => void): () => void {\n return NetInfo.addEventListener((state) =>\n callback(state.isConnected ?? false),\n );\n }\n}\n\nasync function setupPeers(options: BaseReactNativeContextOptions) {\n const CryptoProvider = options.CryptoProvider || PureJSCrypto;\n const crypto = await CryptoProvider.create();\n let node: LocalNode | undefined = undefined;\n\n const peersToLoadFrom: Peer[] = [];\n\n const storage =\n options.storage && options.storage !== \"disabled\"\n ? await getSqliteStorageAsync(options.storage)\n : undefined;\n\n if (options.sync.when === \"never\") {\n return {\n toggleNetwork: () => {},\n peersToLoadFrom,\n setNode: () => {},\n crypto,\n storage,\n };\n }\n\n const wsPeer = new ReactNativeWebSocketPeerWithReconnection({\n peer: options.sync.peer,\n reconnectionTimeout: options.reconnectionTimeout,\n addPeer: (peer) => {\n if (node) {\n node.syncManager.addPeer(peer);\n } else {\n peersToLoadFrom.push(peer);\n }\n },\n removePeer: (peer) => {\n peersToLoadFrom.splice(peersToLoadFrom.indexOf(peer), 1);\n },\n });\n\n function toggleNetwork(enabled: boolean) {\n if (enabled) {\n wsPeer.enable();\n } else {\n wsPeer.disable();\n }\n }\n\n function setNode(value: LocalNode) {\n node = value;\n }\n\n if (options.sync.when === \"always\" || !options.sync.when) {\n toggleNetwork(true);\n }\n\n return {\n toggleNetwork,\n peersToLoadFrom,\n setNode,\n crypto,\n storage,\n };\n}\n\nexport async function createJazzReactNativeGuestContext(\n options: BaseReactNativeContextOptions,\n) {\n const { toggleNetwork, peersToLoadFrom, setNode, crypto, storage } =\n await setupPeers(options);\n\n const context = createAnonymousJazzContext({\n crypto,\n peersToLoadFrom,\n storage,\n });\n\n setNode(context.agent.node);\n\n options.authSecretStorage.emitUpdate(null);\n\n return {\n guest: context.agent,\n node: context.agent.node,\n done: () => {\n // TODO: Sync all the covalues before closing the connection & context\n toggleNetwork(false);\n context.done();\n },\n logOut: () => {\n return context.logOut();\n },\n };\n}\n\nexport type ReactNativeContextOptions<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> = {\n credentials?: AuthCredentials;\n AccountSchema?: S;\n newAccountProps?: NewAccountProps;\n defaultProfileName?: string;\n} & BaseReactNativeContextOptions;\n\nexport async function createJazzReactNativeContext<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n>(options: ReactNativeContextOptions<S>) {\n const { toggleNetwork, peersToLoadFrom, setNode, crypto, storage } =\n await setupPeers(options);\n\n let unsubscribeAuthUpdate = () => {};\n\n if (options.sync.when === \"signedUp\") {\n const authSecretStorage = options.authSecretStorage;\n const credentials = options.credentials ?? (await authSecretStorage.get());\n\n // To update the internal state with the current credentials\n authSecretStorage.emitUpdate(credentials);\n\n function handleAuthUpdate(isAuthenticated: boolean) {\n if (isAuthenticated) {\n toggleNetwork(true);\n } else {\n toggleNetwork(false);\n }\n }\n\n unsubscribeAuthUpdate = authSecretStorage.onUpdate(handleAuthUpdate);\n handleAuthUpdate(authSecretStorage.isAuthenticated);\n }\n\n const context = await createJazzContext({\n credentials: options.credentials,\n newAccountProps: options.newAccountProps,\n peersToLoadFrom,\n crypto,\n defaultProfileName: options.defaultProfileName,\n AccountSchema: options.AccountSchema,\n sessionProvider: provideLockSession,\n authSecretStorage: options.authSecretStorage,\n storage,\n });\n\n setNode(context.node);\n\n return {\n me: context.account,\n node: context.node,\n authSecretStorage: context.authSecretStorage,\n done: () => {\n // TODO: Sync all the covalues before closing the connection & context\n toggleNetwork(false);\n unsubscribeAuthUpdate();\n context.done();\n },\n logOut: () => {\n unsubscribeAuthUpdate();\n return context.logOut();\n },\n };\n}\n\n/** @category Auth Providers */\nexport type SessionProvider = (\n accountID: ID<Account> | AgentID,\n) => Promise<SessionID>;\n\nexport async function provideLockSession(\n accountID: ID<Account> | AgentID,\n crypto: CryptoProvider,\n) {\n const sessionDone = () => {};\n\n const kvStore = KvStoreContext.getInstance().getStorage();\n\n const sessionID =\n ((await kvStore.get(accountID)) as SessionID) ||\n crypto.newRandomSessionID(accountID as RawAccountID | AgentID);\n await kvStore.set(accountID, sessionID);\n\n return Promise.resolve({\n sessionID,\n sessionDone,\n });\n}\n\n/** @category Invite Links */\nexport function createInviteLink<C extends CoValue>(\n value: C,\n role: \"reader\" | \"writer\" | \"admin\",\n { baseURL, valueHint }: { baseURL?: string; valueHint?: string } = {},\n): string {\n return baseCreateInviteLink(value, role, baseURL ?? \"\", valueHint);\n}\n\nexport function setupKvStore(\n kvStore: KvStore | undefined,\n): KvStore | undefined {\n if (!kvStore) {\n return undefined;\n }\n KvStoreContext.getInstance().initialize(kvStore);\n return kvStore;\n}\n","import { FileStream, ImageDefinition } from \"jazz-tools\";\nimport { highestResAvailable } from \"jazz-tools/media\";\nimport { forwardRef, useEffect, useMemo, useState } from \"react\";\nimport { Image as RNImage, ImageProps as RNImageProps } from \"react-native\";\nimport { useCoState } from \"../hooks.js\";\n\nexport type ImageProps = Omit<RNImageProps, \"width\" | \"height\" | \"source\"> & {\n /** The ID of the ImageDefinition to display */\n imageId: string;\n /**\n * Width of the image. Can be a number or \"original\" to use the original image width.\n * When set to \"original\", the component will calculate the appropriate height to maintain aspect ratio.\n *\n * @example\n * ```tsx\n * // Fixed width, auto-calculated height\n * <Image imageId=\"123\" width={600} />\n *\n * // Original width\n * <Image imageId=\"123\" width=\"original\" />\n * ```\n */\n width?: number | \"original\";\n /**\n * Height of the image. Can be a number or \"original\" to use the original image height.\n * When set to \"original\", the component will calculate the appropriate width to maintain aspect ratio.\n *\n * @example\n * ```tsx\n * // Fixed height, auto-calculated width\n * <Image imageId=\"123\" height={400} />\n *\n * // Original height\n * <Image imageId=\"123\" height=\"original\" />\n * ```\n */\n height?: number | \"original\";\n};\n\n/**\n * A React Native Image component that integrates with Jazz's ImageDefinition system.\n *\n * @example\n * ```tsx\n * import { Image } from \"jazz-tools/react-native\";\n * import { StyleSheet } from \"react-native\";\n *\n * function ProfilePicture({ imageId }) {\n * return (\n * <Image\n * imageId={imageId}\n * style={styles.profilePic}\n * width={100}\n * height={100}\n * resizeMode=\"cover\"\n * />\n * );\n * }\n *\n * const styles = StyleSheet.create({\n * profilePic: {\n * borderRadius: 50,\n * }\n * });\n * ```\n */\nexport const Image = forwardRef<RNImage, ImageProps>(function Image(\n { imageId, width, height, ...props },\n ref,\n) {\n const image = useCoState(ImageDefinition, imageId);\n const [src, setSrc] = useState<string | undefined>(image?.placeholderDataURL);\n\n const dimensions: { width: number | undefined; height: number | undefined } =\n useMemo(() => {\n const originalWidth = image?.originalSize?.[0];\n const originalHeight = image?.originalSize?.[1];\n\n // Both width and height are \"original\"\n if (width === \"original\" && height === \"original\") {\n return { width: originalWidth, height: originalHeight };\n }\n\n // Width is \"original\", height is a number\n if (width === \"original\" && typeof height === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width: Math.round((height * originalWidth) / originalHeight),\n height,\n };\n }\n return { width: undefined, height };\n }\n\n // Height is \"original\", width is a number\n if (height === \"original\" && typeof width === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width,\n height: Math.round((width * originalHeight) / originalWidth),\n };\n }\n return { width, height: undefined };\n }\n\n // In all other cases, use the property value:\n return {\n width: width === \"original\" ? originalWidth : width,\n height: height === \"original\" ? originalHeight : height,\n };\n }, [image?.originalSize, width, height]);\n\n useEffect(() => {\n if (!image) return;\n\n let lastBestImage: FileStream | string | undefined =\n image.placeholderDataURL;\n\n const unsub = image.$jazz.subscribe({}, (update) => {\n if (lastBestImage === undefined && update.placeholderDataURL) {\n setSrc(update.placeholderDataURL);\n lastBestImage = update.placeholderDataURL;\n }\n\n const bestImage = highestResAvailable(\n update,\n dimensions.width || dimensions.height || 9999,\n dimensions.height || dimensions.width || 9999,\n );\n\n if (!bestImage) return;\n\n if (lastBestImage === bestImage.image) return;\n\n const url = bestImage.image.asBase64({ dataURL: true });\n\n if (url) {\n setSrc(url);\n lastBestImage = bestImage.image;\n }\n });\n\n return unsub;\n }, [image]);\n\n if (!image) {\n return null;\n }\n\n return (\n <RNImage\n ref={ref}\n source={{ uri: src }}\n width={dimensions.width}\n height={dimensions.height}\n {...props}\n />\n );\n});\n","export * from \"./auth/auth.js\";\nexport * from \"./hooks.js\";\nexport * from \"./provider.js\";\nexport * from \"./storage/kv-store-context.js\";\nexport * from \"./media/image.js\";\n\nexport { SQLiteDatabaseDriverAsync } from \"cojson\";\nexport { parseInviteLink } from \"jazz-tools\";\nexport { createInviteLink, setupKvStore } from \"./platform.js\";\nexport {\n ReactNativeContextManager,\n type JazzContextManagerProps,\n} from \"./ReactNativeContextManager.js\";\n"],"mappings":";AAOO,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAIlB,cAAc;AAFtB,SAAQ,kBAAkC;AAAA,EAEnB;AAAA,EAEvB,OAAc,cAA8B;AAC1C,QAAI,CAAC,gBAAe,UAAU;AAC5B,sBAAe,WAAW,IAAI,gBAAe;AAAA,IAC/C;AACA,WAAO,gBAAe;AAAA,EACxB;AAAA,EAEO,gBAAyB;AAC9B,WAAO,KAAK,oBAAoB;AAAA,EAClC;AAAA,EAEO,WAAW,OAAsB;AACtC,QAAI,CAAC,KAAK,iBAAiB;AACzB,WAAK,kBAAkB;AAAA,IACzB;AAAA,EACF;AAAA,EAEO,aAAsB;AAC3B,QAAI,CAAC,KAAK,iBAAiB;AACzB,YAAM,IAAI,MAAM,sCAAsC;AAAA,IACxD;AACA,WAAO,KAAK;AAAA,EACd;AACF;;;ACnCA,SAAgB,gBAAgB;AAChC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA4CC,cA8CM,YA9CN;AA1CD,IAAM,kBAAkB,CAAC;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AACF,MAIM;AACJ,QAAM,cAAc,eAAe;AACnC,QAAM,WAAW,gBAAgB;AACjC,QAAM,CAAC,UAAU,WAAW,IAAI,SAAiB,EAAE;AACnD,QAAM,CAAC,cAAc,eAAe,IAAI,SAAwB,IAAI;AAEpE,QAAM,eAAe,MAAM;AACzB,oBAAgB,IAAI;AAEpB,SAAK,OAAO,QAAQ,EAAE,MAAM,CAAC,UAAU;AACrC,sBAAgB,MAAM,OAAO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O;AAAA,MACL,OAAO,UAAU,aAAa,gBAAgB;AAAA,MAC9C,QAAQ,WAAW,aAAa,iBAAiB;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,OAAO,cAAc,OAAO,MAAM,CAAC;AAEzC,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,MAAO;AAEZ,QAAI,gBACF,MAAM;AAER,UAAM,QAAQ,MAAM,MAAM,UAAU,CAAC,GAAG,CAAC,WAAW;AAClD,UAAI,kBAAkB,UAAa,OAAO,oBAAoB;AAC5D,eAAO,OAAO,kBAAkB;AAChC,wBAAgB,OAAO;AAAA,MACzB;AAEA,YAAM,YAAY;AAAA,QAChB;AAAA,QACA,WAAW,SAAS,WAAW,UAAU;AAAA,QACzC,WAAW,UAAU,WAAW,SAAS;AAAA,MAC3C;AAEA,UAAI,CAAC,UAAW;AAEhB,UAAI,kBAAkB,UAAU,MAAO;AAEvC,YAAM,MAAM,UAAU,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC;AAEtD,UAAI,KAAK;AACP,eAAO,GAAG;AACV,wBAAgB,UAAU;AAAA,MAC5B;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,KAAK,CAAC;AAEV,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SACE,gBAAAH;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,QAAQ,EAAE,KAAK,IAAI;AAAA,MACnB,OAAO,WAAW;AAAA,MAClB,QAAQ,WAAW;AAAA,MAClB,GAAG;AAAA;AAAA,EACN;AAEJ,CAAC;;;ACxJD,SAAS,iCAAiC;AAC1C,SAAS,mBAAAI,wBAAuB;","names":["username","useJazzContext","React","useEffect","CryptoProvider","handleAuthUpdate","jsx","CryptoProvider","React","useEffect","useEffect","useState","jsx","Image","useState","useEffect","parseInviteLink"]}
|
1
|
+
{"version":3,"sources":["../../src/react-native-core/storage/kv-store-context.ts","../../src/react-native-core/auth/DemoAuthUI.tsx","../../src/react-native-core/auth/auth.ts","../../src/react-native-core/hooks.tsx","../../src/react-native-core/provider.tsx","../../src/react-native-core/ReactNativeContextManager.ts","../../src/react-native-core/platform.ts","../../src/react-native-core/media/image.tsx","../../src/react-native-core/index.ts"],"sourcesContent":["export interface KvStore {\n get(key: string): Promise<string | null>;\n set(key: string, value: string): Promise<void>;\n delete(key: string): Promise<void>;\n clearAll(): Promise<void>;\n}\n\nexport class KvStoreContext {\n private static instance: KvStoreContext;\n private storageInstance: KvStore | null = null;\n\n private constructor() {}\n\n public static getInstance(): KvStoreContext {\n if (!KvStoreContext.instance) {\n KvStoreContext.instance = new KvStoreContext();\n }\n return KvStoreContext.instance;\n }\n\n public isInitialized(): boolean {\n return this.storageInstance !== null;\n }\n\n public initialize(store: KvStore): void {\n if (!this.storageInstance) {\n this.storageInstance = store;\n }\n }\n\n public getStorage(): KvStore {\n if (!this.storageInstance) {\n throw new Error(\"Storage instance is not initialized.\");\n }\n return this.storageInstance;\n }\n}\n\nexport default KvStoreContext;\n","import { useDemoAuth } from \"jazz-tools/react-core\";\nimport React, { useState } from \"react\";\nimport {\n StyleSheet,\n Text,\n TextInput,\n TouchableOpacity,\n View,\n useColorScheme,\n} from \"react-native\";\n\nexport const DemoAuthBasicUI = ({\n appName,\n auth,\n children,\n}: {\n appName: string;\n auth: ReturnType<typeof useDemoAuth>;\n children: React.ReactNode;\n}) => {\n const colorScheme = useColorScheme();\n const darkMode = colorScheme === \"dark\";\n const [username, setUsername] = useState<string>(\"\");\n const [errorMessage, setErrorMessage] = useState<string | null>(null);\n\n const handleSignUp = () => {\n setErrorMessage(null);\n\n auth.signUp(username).catch((error) => {\n setErrorMessage(error.message);\n });\n };\n\n const handleLogIn = (username: string) => {\n setErrorMessage(null);\n\n auth.logIn(username).catch((error) => {\n setErrorMessage(error.message);\n });\n };\n\n if (auth.state === \"signedIn\") {\n return children;\n }\n\n return (\n <View\n style={[\n styles.container,\n darkMode ? styles.darkBackground : styles.lightBackground,\n ]}\n >\n <View style={styles.formContainer}>\n <Text\n style={[\n styles.headerText,\n darkMode ? styles.darkText : styles.lightText,\n ]}\n >\n {appName}\n </Text>\n\n {errorMessage && <Text style={styles.errorText}>{errorMessage}</Text>}\n\n <TextInput\n placeholder=\"Display name\"\n value={username}\n onChangeText={setUsername}\n placeholderTextColor={darkMode ? \"#fff\" : \"#000\"}\n style={[\n styles.textInput,\n darkMode ? styles.darkInput : styles.lightInput,\n ]}\n />\n\n <TouchableOpacity\n onPress={handleSignUp}\n style={[\n styles.button,\n darkMode ? styles.darkButton : styles.lightButton,\n ]}\n >\n <Text\n style={darkMode ? styles.darkButtonText : styles.lightButtonText}\n >\n Sign Up as new account\n </Text>\n </TouchableOpacity>\n\n <View style={styles.existingUsersContainer}>\n {auth.existingUsers.map((user) => (\n <TouchableOpacity\n key={user}\n onPress={() => handleLogIn(user)}\n style={[\n styles.existingUserButton,\n darkMode ? styles.darkUserButton : styles.lightUserButton,\n ]}\n >\n <Text style={darkMode ? styles.darkText : styles.lightText}>\n Log In as \"{user}\"\n </Text>\n </TouchableOpacity>\n ))}\n </View>\n </View>\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: \"center\",\n alignItems: \"center\",\n padding: 20,\n },\n formContainer: {\n width: \"80%\",\n alignItems: \"center\",\n justifyContent: \"center\",\n },\n headerText: {\n fontSize: 24,\n marginBottom: 20,\n },\n errorText: {\n color: \"red\",\n marginVertical: 5,\n textAlign: \"center\",\n },\n textInput: {\n borderWidth: 1,\n padding: 10,\n marginVertical: 10,\n width: \"100%\",\n borderRadius: 6,\n },\n darkInput: {\n borderColor: \"#444\",\n backgroundColor: \"#000\",\n color: \"#fff\",\n },\n lightInput: {\n borderColor: \"#ddd\",\n backgroundColor: \"#fff\",\n color: \"#000\",\n },\n button: {\n paddingVertical: 15,\n paddingHorizontal: 10,\n borderRadius: 6,\n width: \"100%\",\n marginVertical: 10,\n },\n darkButton: {\n backgroundColor: \"#444\",\n },\n lightButton: {\n backgroundColor: \"#ddd\",\n },\n darkButtonText: {\n color: \"#fff\",\n textAlign: \"center\",\n },\n lightButtonText: {\n color: \"#000\",\n textAlign: \"center\",\n },\n existingUsersContainer: {\n width: \"100%\",\n marginTop: 20,\n },\n existingUserButton: {\n paddingVertical: 15,\n paddingHorizontal: 10,\n borderRadius: 6,\n marginVertical: 5,\n },\n darkUserButton: {\n backgroundColor: \"#222\",\n },\n lightUserButton: {\n backgroundColor: \"#eee\",\n },\n loadingText: {\n fontSize: 18,\n color: \"#888\",\n },\n darkText: {\n color: \"#fff\",\n },\n lightText: {\n color: \"#000\",\n },\n darkBackground: {\n backgroundColor: \"#000\",\n },\n lightBackground: {\n backgroundColor: \"#fff\",\n },\n});\n","import { KvStoreContext } from \"../storage/kv-store-context.js\";\n\nexport * from \"./DemoAuthUI.js\";\n\nexport function clearUserCredentials() {\n const kvStore = KvStoreContext.getInstance().getStorage();\n\n // TODO: Migrate the Auth methods to use the same storage key/interface\n return Promise.all([\n kvStore.delete(\"demo-auth-logged-in-secret\"),\n kvStore.delete(\"jazz-clerk-auth\"),\n kvStore.delete(\"jazz-logged-in-secret\"),\n ]);\n}\n","import { useEffect } from \"react\";\n\nimport { CoValueClassOrSchema, parseInviteLink } from \"jazz-tools\";\nimport { useJazzContext } from \"jazz-tools/react-core\";\nimport { Linking } from \"react-native\";\n\nexport {\n useCoState,\n experimental_useInboxSender,\n useDemoAuth,\n usePassphraseAuth,\n useJazzContext,\n useAuthSecretStorage,\n useIsAuthenticated,\n useAccount,\n useCoStateWithSelector,\n useAccountWithSelector,\n useSyncConnectionStatus,\n} from \"jazz-tools/react-core\";\n\nexport function useAcceptInviteNative<S extends CoValueClassOrSchema>({\n invitedObjectSchema,\n onAccept,\n forValueHint,\n}: {\n invitedObjectSchema: S;\n onAccept: (projectID: string) => void;\n forValueHint?: string;\n}): void {\n const context = useJazzContext();\n\n if (!(\"me\" in context)) {\n throw new Error(\n \"useAcceptInviteNative can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n useEffect(() => {\n const handleDeepLink = ({ url }: { url: string }) => {\n const result = parseInviteLink(url);\n if (result && result.valueHint === forValueHint) {\n context.me\n .acceptInvite(\n result.valueID,\n result.inviteSecret,\n invitedObjectSchema,\n )\n .then(() => {\n onAccept(result.valueID);\n })\n .catch((e) => {\n console.error(\"Failed to accept invite\", e);\n });\n }\n };\n\n const linkingListener = Linking.addEventListener(\"url\", handleDeepLink);\n\n void Linking.getInitialURL().then((url) => {\n if (url) handleDeepLink({ url });\n });\n\n return () => {\n linkingListener.remove();\n };\n }, [context, onAccept, invitedObjectSchema, forValueHint]);\n}\n","import {\n Account,\n AccountClass,\n AnyAccountSchema,\n CoValueFromRaw,\n InstanceOfSchema,\n JazzContextType,\n KvStore,\n} from \"jazz-tools\";\nimport { JazzContext, JazzContextManagerContext } from \"jazz-tools/react-core\";\nimport React, { useEffect, useRef } from \"react\";\nimport type { JazzContextManagerProps } from \"./ReactNativeContextManager.js\";\nimport { ReactNativeContextManager } from \"./ReactNativeContextManager.js\";\nimport { setupKvStore } from \"./platform.js\";\n\nexport type JazzProviderProps<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> = {\n children: React.ReactNode;\n kvStore?: KvStore;\n} & JazzContextManagerProps<S>;\n\n/** @category Context & Hooks */\nexport function JazzProviderCore<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n>({\n children,\n guestMode,\n sync,\n storage,\n AccountSchema,\n defaultProfileName,\n onLogOut,\n logOutReplacement,\n onAnonymousAccountDiscarded,\n kvStore,\n CryptoProvider,\n}: JazzProviderProps<S>) {\n setupKvStore(kvStore);\n\n const [contextManager] = React.useState(\n () => new ReactNativeContextManager<S>(),\n );\n\n const onLogOutRefCallback = useRefCallback(onLogOut);\n const logOutReplacementRefCallback = useRefCallback(logOutReplacement);\n const onAnonymousAccountDiscardedRefCallback = useRefCallback(\n onAnonymousAccountDiscarded,\n );\n const logoutReplacementActiveRef = useRef(false);\n logoutReplacementActiveRef.current = Boolean(logOutReplacement);\n\n const value = React.useSyncExternalStore<\n JazzContextType<InstanceOfSchema<S>> | undefined\n >(\n React.useCallback(\n (callback) => {\n const props = {\n AccountSchema,\n guestMode,\n sync,\n storage,\n defaultProfileName,\n onLogOut: onLogOutRefCallback,\n logOutReplacement: logoutReplacementActiveRef.current\n ? logOutReplacementRefCallback\n : undefined,\n onAnonymousAccountDiscarded: onAnonymousAccountDiscardedRefCallback,\n CryptoProvider,\n } satisfies JazzContextManagerProps<S>;\n\n if (contextManager.propsChanged(props)) {\n contextManager.createContext(props).catch((error) => {\n console.log(error.stack);\n console.error(\"Error creating Jazz React Native context:\", error);\n });\n }\n\n return contextManager.subscribe(callback);\n },\n [sync, guestMode].concat(storage as any),\n ),\n () => contextManager.getCurrentValue(),\n () => contextManager.getCurrentValue(),\n );\n\n useEffect(() => {\n // In development mode we don't return a cleanup function because otherwise\n // the double effect execution would mark the context as done immediately.\n if (process.env.NODE_ENV === \"development\") return;\n\n return () => {\n contextManager.done();\n };\n }, []);\n\n return (\n <JazzContext.Provider value={value}>\n <JazzContextManagerContext.Provider value={contextManager}>\n {value && children}\n </JazzContextManagerContext.Provider>\n </JazzContext.Provider>\n );\n}\n\nfunction useRefCallback<T extends (...args: any[]) => any>(callback?: T) {\n const callbackRef = React.useRef(callback);\n callbackRef.current = callback;\n return useRef(\n (...args: Parameters<T>): ReturnType<T> => callbackRef.current?.(...args),\n ).current;\n}\n","import {\n Account,\n AccountClass,\n CoValueFromRaw,\n JazzContextManager,\n KvStore,\n SyncConfig,\n} from \"jazz-tools\";\nimport type {\n AnyAccountSchema,\n InstanceOfSchema,\n JazzContextManagerAuthProps,\n} from \"jazz-tools\";\nimport {\n BaseReactNativeContextOptions,\n createJazzReactNativeContext,\n createJazzReactNativeGuestContext,\n} from \"./platform.js\";\nimport { KvStoreContext } from \"./storage/kv-store-context.js\";\n\nexport type JazzContextManagerProps<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> = {\n guestMode?: boolean;\n sync: SyncConfig;\n onLogOut?: () => void;\n logOutReplacement?: () => void;\n storage?: BaseReactNativeContextOptions[\"storage\"];\n AccountSchema?: S;\n defaultProfileName?: string;\n onAnonymousAccountDiscarded?: (\n anonymousAccount: InstanceOfSchema<S>,\n ) => Promise<void>;\n CryptoProvider?: BaseReactNativeContextOptions[\"CryptoProvider\"];\n};\n\nexport class ReactNativeContextManager<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> extends JazzContextManager<InstanceOfSchema<S>, JazzContextManagerProps<S>> {\n async getNewContext(\n props: JazzContextManagerProps<S>,\n authProps?: JazzContextManagerAuthProps,\n ) {\n if (props.guestMode) {\n return createJazzReactNativeGuestContext({\n sync: props.sync,\n storage: props.storage,\n authSecretStorage: this.authSecretStorage,\n CryptoProvider: props.CryptoProvider,\n });\n } else {\n return createJazzReactNativeContext<S>({\n sync: props.sync,\n storage: props.storage,\n AccountSchema: props.AccountSchema,\n credentials: authProps?.credentials,\n newAccountProps: authProps?.newAccountProps,\n defaultProfileName: props.defaultProfileName,\n authSecretStorage: this.authSecretStorage,\n CryptoProvider: props.CryptoProvider,\n });\n }\n }\n\n getKvStore(): KvStore {\n return KvStoreContext.getInstance().getStorage();\n }\n\n propsChanged(props: JazzContextManagerProps<S>) {\n if (!this.props) {\n return true;\n }\n\n return (\n this.props.sync.when !== props.sync.when ||\n this.props.sync.peer !== props.sync.peer ||\n this.props.guestMode !== props.guestMode\n );\n }\n}\n","import NetInfo from \"@react-native-community/netinfo\";\nimport { LocalNode, Peer, RawAccountID, getSqliteStorageAsync } from \"cojson\";\nimport { PureJSCrypto } from \"cojson/dist/crypto/PureJSCrypto\"; // Importing from dist to not rely on the exports field\nimport {\n Account,\n AccountClass,\n AgentID,\n AnyAccountSchema,\n AuthCredentials,\n AuthSecretStorage,\n CoValue,\n CoValueFromRaw,\n CryptoProvider,\n ID,\n NewAccountProps,\n SessionID,\n SyncConfig,\n createInviteLink as baseCreateInviteLink,\n createAnonymousJazzContext,\n createJazzContext,\n} from \"jazz-tools\";\nimport { KvStore, KvStoreContext } from \"./storage/kv-store-context.js\";\n\nimport { SQLiteDatabaseDriverAsync } from \"cojson\";\nimport { WebSocketPeerWithReconnection } from \"cojson-transport-ws\";\nimport type { RNQuickCrypto } from \"jazz-tools/react-native-core/crypto\";\n\nexport type BaseReactNativeContextOptions = {\n sync: SyncConfig;\n reconnectionTimeout?: number;\n storage?: SQLiteDatabaseDriverAsync | \"disabled\";\n CryptoProvider?: typeof PureJSCrypto | typeof RNQuickCrypto;\n authSecretStorage: AuthSecretStorage;\n};\n\nclass ReactNativeWebSocketPeerWithReconnection extends WebSocketPeerWithReconnection {\n onNetworkChange(callback: (connected: boolean) => void): () => void {\n return NetInfo.addEventListener((state) =>\n callback(state.isConnected ?? false),\n );\n }\n}\n\nasync function setupPeers(options: BaseReactNativeContextOptions) {\n const CryptoProvider = options.CryptoProvider || PureJSCrypto;\n const crypto = await CryptoProvider.create();\n let node: LocalNode | undefined = undefined;\n\n const peersToLoadFrom: Peer[] = [];\n\n const storage =\n options.storage && options.storage !== \"disabled\"\n ? await getSqliteStorageAsync(options.storage)\n : undefined;\n\n if (options.sync.when === \"never\") {\n return {\n toggleNetwork: () => {},\n addConnectionListener: () => () => {},\n connected: () => false,\n peersToLoadFrom,\n setNode: () => {},\n crypto,\n storage,\n };\n }\n\n const wsPeer = new ReactNativeWebSocketPeerWithReconnection({\n peer: options.sync.peer,\n reconnectionTimeout: options.reconnectionTimeout,\n addPeer: (peer) => {\n if (node) {\n node.syncManager.addPeer(peer);\n } else {\n peersToLoadFrom.push(peer);\n }\n },\n removePeer: (peer) => {\n peersToLoadFrom.splice(peersToLoadFrom.indexOf(peer), 1);\n },\n });\n\n function toggleNetwork(enabled: boolean) {\n if (enabled) {\n wsPeer.enable();\n } else {\n wsPeer.disable();\n }\n }\n\n function setNode(value: LocalNode) {\n node = value;\n }\n\n if (options.sync.when === \"always\" || !options.sync.when) {\n toggleNetwork(true);\n }\n\n return {\n toggleNetwork,\n addConnectionListener(listener: (connected: boolean) => void) {\n wsPeer.subscribe(listener);\n\n return () => {\n wsPeer.unsubscribe(listener);\n };\n },\n connected: () => wsPeer.connected,\n peersToLoadFrom,\n setNode,\n crypto,\n storage,\n };\n}\n\nexport async function createJazzReactNativeGuestContext(\n options: BaseReactNativeContextOptions,\n) {\n const {\n toggleNetwork,\n peersToLoadFrom,\n setNode,\n crypto,\n storage,\n addConnectionListener,\n connected,\n } = await setupPeers(options);\n\n const context = createAnonymousJazzContext({\n crypto,\n peersToLoadFrom,\n storage,\n });\n\n setNode(context.agent.node);\n\n options.authSecretStorage.emitUpdate(null);\n\n return {\n guest: context.agent,\n node: context.agent.node,\n done: () => {\n // TODO: Sync all the covalues before closing the connection & context\n toggleNetwork(false);\n context.done();\n },\n logOut: () => {\n return context.logOut();\n },\n addConnectionListener,\n connected,\n };\n}\n\nexport type ReactNativeContextOptions<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n> = {\n credentials?: AuthCredentials;\n AccountSchema?: S;\n newAccountProps?: NewAccountProps;\n defaultProfileName?: string;\n} & BaseReactNativeContextOptions;\n\nexport async function createJazzReactNativeContext<\n S extends\n | (AccountClass<Account> & CoValueFromRaw<Account>)\n | AnyAccountSchema,\n>(options: ReactNativeContextOptions<S>) {\n const {\n toggleNetwork,\n peersToLoadFrom,\n setNode,\n crypto,\n storage,\n addConnectionListener,\n connected,\n } = await setupPeers(options);\n\n let unsubscribeAuthUpdate = () => {};\n\n if (options.sync.when === \"signedUp\") {\n const authSecretStorage = options.authSecretStorage;\n const credentials = options.credentials ?? (await authSecretStorage.get());\n\n // To update the internal state with the current credentials\n authSecretStorage.emitUpdate(credentials);\n\n function handleAuthUpdate(isAuthenticated: boolean) {\n if (isAuthenticated) {\n toggleNetwork(true);\n } else {\n toggleNetwork(false);\n }\n }\n\n unsubscribeAuthUpdate = authSecretStorage.onUpdate(handleAuthUpdate);\n handleAuthUpdate(authSecretStorage.isAuthenticated);\n }\n\n const context = await createJazzContext({\n credentials: options.credentials,\n newAccountProps: options.newAccountProps,\n peersToLoadFrom,\n crypto,\n defaultProfileName: options.defaultProfileName,\n AccountSchema: options.AccountSchema,\n sessionProvider: provideLockSession,\n authSecretStorage: options.authSecretStorage,\n storage,\n });\n\n setNode(context.node);\n\n return {\n me: context.account,\n node: context.node,\n authSecretStorage: context.authSecretStorage,\n done: () => {\n // TODO: Sync all the covalues before closing the connection & context\n toggleNetwork(false);\n unsubscribeAuthUpdate();\n context.done();\n },\n logOut: () => {\n unsubscribeAuthUpdate();\n return context.logOut();\n },\n addConnectionListener,\n connected,\n };\n}\n\n/** @category Auth Providers */\nexport type SessionProvider = (\n accountID: ID<Account> | AgentID,\n) => Promise<SessionID>;\n\nexport async function provideLockSession(\n accountID: ID<Account> | AgentID,\n crypto: CryptoProvider,\n) {\n const sessionDone = () => {};\n\n const kvStore = KvStoreContext.getInstance().getStorage();\n\n const sessionID =\n ((await kvStore.get(accountID)) as SessionID) ||\n crypto.newRandomSessionID(accountID as RawAccountID | AgentID);\n await kvStore.set(accountID, sessionID);\n\n return Promise.resolve({\n sessionID,\n sessionDone,\n });\n}\n\n/** @category Invite Links */\nexport function createInviteLink<C extends CoValue>(\n value: C,\n role: \"reader\" | \"writer\" | \"admin\",\n { baseURL, valueHint }: { baseURL?: string; valueHint?: string } = {},\n): string {\n return baseCreateInviteLink(value, role, baseURL ?? \"\", valueHint);\n}\n\nexport function setupKvStore(\n kvStore: KvStore | undefined,\n): KvStore | undefined {\n if (!kvStore) {\n return undefined;\n }\n KvStoreContext.getInstance().initialize(kvStore);\n return kvStore;\n}\n","import { FileStream, ImageDefinition } from \"jazz-tools\";\nimport { highestResAvailable } from \"jazz-tools/media\";\nimport { forwardRef, useEffect, useMemo, useState } from \"react\";\nimport { Image as RNImage, ImageProps as RNImageProps } from \"react-native\";\nimport { useCoState } from \"../hooks.js\";\n\nexport type ImageProps = Omit<RNImageProps, \"width\" | \"height\" | \"source\"> & {\n /** The ID of the ImageDefinition to display */\n imageId: string;\n /**\n * Width of the image. Can be a number or \"original\" to use the original image width.\n * When set to \"original\", the component will calculate the appropriate height to maintain aspect ratio.\n *\n * @example\n * ```tsx\n * // Fixed width, auto-calculated height\n * <Image imageId=\"123\" width={600} />\n *\n * // Original width\n * <Image imageId=\"123\" width=\"original\" />\n * ```\n */\n width?: number | \"original\";\n /**\n * Height of the image. Can be a number or \"original\" to use the original image height.\n * When set to \"original\", the component will calculate the appropriate width to maintain aspect ratio.\n *\n * @example\n * ```tsx\n * // Fixed height, auto-calculated width\n * <Image imageId=\"123\" height={400} />\n *\n * // Original height\n * <Image imageId=\"123\" height=\"original\" />\n * ```\n */\n height?: number | \"original\";\n};\n\n/**\n * A React Native Image component that integrates with Jazz's ImageDefinition system.\n *\n * @example\n * ```tsx\n * import { Image } from \"jazz-tools/react-native\";\n * import { StyleSheet } from \"react-native\";\n *\n * function ProfilePicture({ imageId }) {\n * return (\n * <Image\n * imageId={imageId}\n * style={styles.profilePic}\n * width={100}\n * height={100}\n * resizeMode=\"cover\"\n * />\n * );\n * }\n *\n * const styles = StyleSheet.create({\n * profilePic: {\n * borderRadius: 50,\n * }\n * });\n * ```\n */\nexport const Image = forwardRef<RNImage, ImageProps>(function Image(\n { imageId, width, height, ...props },\n ref,\n) {\n const image = useCoState(ImageDefinition, imageId);\n const [src, setSrc] = useState<string | undefined>(\n image?.placeholderDataURL ??\n \"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==\",\n );\n\n const dimensions: { width: number | undefined; height: number | undefined } =\n useMemo(() => {\n const originalWidth = image?.originalSize?.[0];\n const originalHeight = image?.originalSize?.[1];\n\n // Both width and height are \"original\"\n if (width === \"original\" && height === \"original\") {\n return { width: originalWidth, height: originalHeight };\n }\n\n // Width is \"original\", height is a number\n if (width === \"original\" && typeof height === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width: Math.round((height * originalWidth) / originalHeight),\n height,\n };\n }\n return { width: undefined, height };\n }\n\n // Height is \"original\", width is a number\n if (height === \"original\" && typeof width === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width,\n height: Math.round((width * originalHeight) / originalWidth),\n };\n }\n return { width, height: undefined };\n }\n\n // In all other cases, use the property value:\n return {\n width: width === \"original\" ? originalWidth : width,\n height: height === \"original\" ? originalHeight : height,\n };\n }, [image?.originalSize, width, height]);\n\n useEffect(() => {\n if (!image) return;\n\n let lastBestImage: FileStream | string | undefined =\n image.placeholderDataURL;\n\n const unsub = image.$jazz.subscribe({}, (update) => {\n if (lastBestImage === undefined && update.placeholderDataURL) {\n setSrc(update.placeholderDataURL);\n lastBestImage = update.placeholderDataURL;\n }\n\n const bestImage = highestResAvailable(\n update,\n dimensions.width || dimensions.height || 9999,\n dimensions.height || dimensions.width || 9999,\n );\n\n if (!bestImage) return;\n\n if (lastBestImage === bestImage.image) return;\n\n const url = bestImage.image.asBase64({ dataURL: true });\n\n if (url) {\n setSrc(url);\n lastBestImage = bestImage.image;\n }\n });\n\n return unsub;\n }, [image]);\n\n if (!image) {\n return null;\n }\n\n return (\n <RNImage\n ref={ref}\n source={{ uri: src }}\n width={dimensions.width}\n height={dimensions.height}\n {...props}\n />\n );\n});\n","export * from \"./auth/auth.js\";\nexport * from \"./hooks.js\";\nexport * from \"./provider.js\";\nexport * from \"./storage/kv-store-context.js\";\nexport * from \"./media/image.js\";\n\nexport { SQLiteDatabaseDriverAsync } from \"cojson\";\nexport { parseInviteLink } from \"jazz-tools\";\nexport { createInviteLink, setupKvStore } from \"./platform.js\";\nexport {\n ReactNativeContextManager,\n type JazzContextManagerProps,\n} from \"./ReactNativeContextManager.js\";\n"],"mappings":";AAOO,IAAM,iBAAN,MAAM,gBAAe;AAAA,EAIlB,cAAc;AAFtB,SAAQ,kBAAkC;AAAA,EAEn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O,EAAE,OAAO,QAAQ,OAAU;AAAA,IACpC;AAGA,WAAO;AAAA,MACL,OAAO,UAAU,aAAa,gBAAgB;AAAA,MAC9C,QAAQ,WAAW,aAAa,iBAAiB;AAAA,IACnD;AAAA,EACF,GAAG,CAAC,OAAO,cAAc,OAAO,MAAM,CAAC;AAEzC,EAAAC,WAAU,MAAM;AACd,QAAI,CAAC,MAAO;AAEZ,QAAI,gBACF,MAAM;AAER,UAAM,QAAQ,MAAM,MAAM,UAAU,CAAC,GAAG,CAAC,WAAW;AAClD,UAAI,kBAAkB,UAAa,OAAO,oBAAoB;AAC5D,eAAO,OAAO,kBAAkB;AAChC,wBAAgB,OAAO;AAAA,MACzB;AAEA,YAAM,YAAY;AAAA,QAChB;AAAA,QACA,WAAW,SAAS,WAAW,UAAU;AAAA,QACzC,WAAW,UAAU,WAAW,SAAS;AAAA,MAC3C;AAEA,UAAI,CAAC,UAAW;AAEhB,UAAI,kBAAkB,UAAU,MAAO;AAEvC,YAAM,MAAM,UAAU,MAAM,SAAS,EAAE,SAAS,KAAK,CAAC;AAEtD,UAAI,KAAK;AACP,eAAO,GAAG;AACV,wBAAgB,UAAU;AAAA,MAC5B;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT,GAAG,CAAC,KAAK,CAAC;AAEV,MAAI,CAAC,OAAO;AACV,WAAO;AAAA,EACT;AAEA,SACE,gBAAAH;AAAA,IAAC;AAAA;AAAA,MACC;AAAA,MACA,QAAQ,EAAE,KAAK,IAAI;AAAA,MACnB,OAAO,WAAW;AAAA,MAClB,QAAQ,WAAW;AAAA,MAClB,GAAG;AAAA;AAAA,EACN;AAEJ,CAAC;;;AC3JD,SAAS,iCAAiC;AAC1C,SAAS,mBAAAI,wBAAuB;","names":["username","useJazzContext","React","useEffect","CryptoProvider","handleAuthUpdate","jsx","CryptoProvider","React","useEffect","useEffect","useState","jsx","Image","useState","useEffect","parseInviteLink"]}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/react-native-core/media/image.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5E,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG;IAC3E,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,KAAK;IA3DhB,+CAA+C;aACtC,MAAM;IACf;;;;;;;;;;;;OAYG;YACK,MAAM,GAAG,UAAU;IAC3B;;;;;;;;;;;;OAYG;aACM,MAAM,GAAG,UAAU;
|
1
|
+
{"version":3,"file":"image.d.ts","sourceRoot":"","sources":["../../../src/react-native-core/media/image.tsx"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,IAAI,OAAO,EAAE,UAAU,IAAI,YAAY,EAAE,MAAM,cAAc,CAAC;AAG5E,MAAM,MAAM,UAAU,GAAG,IAAI,CAAC,YAAY,EAAE,OAAO,GAAG,QAAQ,GAAG,QAAQ,CAAC,GAAG;IAC3E,+CAA+C;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;IAC5B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,EAAE,MAAM,GAAG,UAAU,CAAC;CAC9B,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,eAAO,MAAM,KAAK;IA3DhB,+CAA+C;aACtC,MAAM;IACf;;;;;;;;;;;;OAYG;YACK,MAAM,GAAG,UAAU;IAC3B;;;;;;;;;;;;OAYG;aACM,MAAM,GAAG,UAAU;2CA6H5B,CAAC"}
|
@@ -16,6 +16,8 @@ export declare function createJazzReactNativeGuestContext(options: BaseReactNati
|
|
16
16
|
node: LocalNode;
|
17
17
|
done: () => void;
|
18
18
|
logOut: () => Promise<void>;
|
19
|
+
addConnectionListener: (listener: (connected: boolean) => void) => () => void;
|
20
|
+
connected: () => boolean;
|
19
21
|
}>;
|
20
22
|
export type ReactNativeContextOptions<S extends (AccountClass<Account> & CoValueFromRaw<Account>) | AnyAccountSchema> = {
|
21
23
|
credentials?: AuthCredentials;
|
@@ -29,6 +31,8 @@ export declare function createJazzReactNativeContext<S extends (AccountClass<Acc
|
|
29
31
|
authSecretStorage: AuthSecretStorage;
|
30
32
|
done: () => void;
|
31
33
|
logOut: () => Promise<void>;
|
34
|
+
addConnectionListener: (listener: (connected: boolean) => void) => () => void;
|
35
|
+
connected: () => boolean;
|
32
36
|
}>;
|
33
37
|
/** @category Auth Providers */
|
34
38
|
export type SessionProvider = (accountID: ID<Account> | AgentID) => Promise<SessionID>;
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../src/react-native-core/platform.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAQ,YAAY,EAAyB,MAAM,QAAQ,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,iCAAiC,CAAC;AAC/D,OAAO,EACL,OAAO,EACP,YAAY,EACZ,OAAO,EACP,gBAAgB,EAChB,eAAe,EACf,iBAAiB,EACjB,OAAO,EACP,cAAc,EACd,cAAc,EACd,EAAE,EACF,eAAe,EACf,SAAS,EACT,UAAU,EAIX,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,OAAO,EAAkB,MAAM,+BAA+B,CAAC;AAExE,OAAO,EAAE,yBAAyB,EAAE,MAAM,QAAQ,CAAC;AAEnD,OAAO,KAAK,EAAE,aAAa,EA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