jazz-tools 0.18.38 → 0.19.0
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 +8 -8
- package/.svelte-kit/__package__/jazz.class.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/jazz.class.svelte.js +39 -14
- package/.svelte-kit/__package__/media/image.svelte +6 -5
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.d.ts +2 -0
- package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/AccountCoState.svelte.test-d.js +19 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test-d.d.ts +2 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test-d.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test-d.js +16 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test.d.ts +2 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test.d.ts.map +1 -0
- package/.svelte-kit/__package__/tests/CoState.svelte.test.js +42 -0
- package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte +23 -0
- package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte.d.ts +12 -0
- package/.svelte-kit/__package__/tests/TestCoStateWrapper.svelte.d.ts.map +1 -0
- package/.turbo/turbo-build.log +57 -57
- package/CHANGELOG.md +22 -0
- package/dist/better-auth/database-adapter/index.js +14 -11
- package/dist/better-auth/database-adapter/index.js.map +1 -1
- package/dist/better-auth/database-adapter/repository/generic.d.ts +1 -1
- package/dist/better-auth/database-adapter/repository/generic.d.ts.map +1 -1
- package/dist/better-auth/database-adapter/repository/user.d.ts.map +1 -1
- package/dist/{chunk-OSQ7S47Q.js → chunk-P3YLNFN4.js} +504 -232
- package/dist/chunk-P3YLNFN4.js.map +1 -0
- package/dist/index.js +14 -6
- package/dist/index.js.map +1 -1
- package/dist/media/{chunk-K6GCHLQU.js → chunk-3LKBM3G3.js} +23 -15
- package/dist/media/chunk-3LKBM3G3.js.map +1 -0
- package/dist/media/create-image/browser.d.ts +2 -2
- package/dist/media/create-image/react-native.d.ts +2 -2
- package/dist/media/create-image/server.d.ts +2 -2
- package/dist/media/create-image-factory.d.ts +2 -2
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.js +1 -1
- package/dist/media/index.server.js +1 -1
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/react/hooks.d.ts +1 -1
- package/dist/react/hooks.d.ts.map +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +31 -15
- 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 +126 -224
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +65 -63
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/subscription-provider.d.ts.map +1 -1
- package/dist/react-core/tests/createCoValueSubscriptionContext.test.d.ts +2 -0
- package/dist/react-core/tests/createCoValueSubscriptionContext.test.d.ts.map +1 -0
- package/dist/react-core/tests/useAccount.selector.test.d.ts +2 -0
- package/dist/react-core/tests/useAccount.selector.test.d.ts.map +1 -0
- package/dist/react-core/tests/useCoState.selector.test.d.ts +2 -0
- package/dist/react-core/tests/useCoState.selector.test.d.ts.map +1 -0
- package/dist/react-native-core/hooks.d.ts +1 -1
- package/dist/react-native-core/hooks.d.ts.map +1 -1
- package/dist/react-native-core/index.js +7 -5
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/react-native-core/media/image.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.d.ts +8 -8
- package/dist/svelte/jazz.class.svelte.d.ts.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +39 -14
- package/dist/svelte/media/image.svelte +6 -5
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/tests/AccountCoState.svelte.test-d.d.ts +2 -0
- package/dist/svelte/tests/AccountCoState.svelte.test-d.d.ts.map +1 -0
- package/dist/svelte/tests/AccountCoState.svelte.test-d.js +19 -0
- package/dist/svelte/tests/CoState.svelte.test-d.d.ts +2 -0
- package/dist/svelte/tests/CoState.svelte.test-d.d.ts.map +1 -0
- package/dist/svelte/tests/CoState.svelte.test-d.js +16 -0
- package/dist/svelte/tests/CoState.svelte.test.d.ts +2 -0
- package/dist/svelte/tests/CoState.svelte.test.d.ts.map +1 -0
- package/dist/svelte/tests/CoState.svelte.test.js +42 -0
- package/dist/svelte/tests/TestCoStateWrapper.svelte +23 -0
- package/dist/svelte/tests/TestCoStateWrapper.svelte.d.ts +12 -0
- package/dist/svelte/tests/TestCoStateWrapper.svelte.d.ts.map +1 -0
- package/dist/testing.js +3 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoValueBase.d.ts +4 -1
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +6 -6
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +5 -5
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +9 -8
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +17 -17
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +3 -3
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/coVector.d.ts +3 -3
- package/dist/tools/coValues/coVector.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +66 -36
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts.map +1 -1
- package/dist/tools/coValues/group.d.ts +2 -2
- package/dist/tools/coValues/group.d.ts.map +1 -1
- package/dist/tools/coValues/inbox.d.ts.map +1 -1
- package/dist/tools/coValues/interfaces.d.ts +14 -6
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/request.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +2 -2
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +3 -3
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/refs.d.ts +3 -3
- package/dist/tools/implementation/refs.d.ts.map +1 -1
- package/dist/tools/implementation/schema.d.ts +2 -2
- package/dist/tools/implementation/schema.d.ts.map +1 -1
- package/dist/tools/implementation/schemaUtils.d.ts +8 -0
- package/dist/tools/implementation/schemaUtils.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +33 -18
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts +5 -4
- package/dist/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +23 -12
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +29 -18
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +39 -22
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts +1 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +30 -19
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts +5 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/CoValueSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts +6 -5
- package/dist/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/GroupSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +3 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +3 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesMaybeLoaded.d.ts +22 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesMaybeLoaded.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.d.ts +9 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts +7 -6
- package/dist/tools/implementation/zodSchema/zodSchema.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +3 -3
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/utils.d.ts +14 -0
- package/dist/tools/lib/utils.d.ts.map +1 -0
- package/dist/tools/lib/utils.test.d.ts +2 -0
- package/dist/tools/lib/utils.test.d.ts.map +1 -0
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts +3 -2
- package/dist/tools/subscribe/CoValueCoreSubscription.d.ts.map +1 -1
- package/dist/tools/subscribe/JazzError.d.ts +4 -3
- package/dist/tools/subscribe/JazzError.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts +6 -5
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/dist/tools/subscribe/types.d.ts +23 -3
- package/dist/tools/subscribe/types.d.ts.map +1 -1
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts +3 -2
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/schema.resolved.test.d.ts +2 -0
- package/dist/tools/tests/schema.resolved.test.d.ts.map +1 -0
- package/dist/tools/tests/utils.d.ts +2 -1
- package/dist/tools/tests/utils.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/better-auth/database-adapter/index.ts +2 -2
- package/src/better-auth/database-adapter/repository/account.ts +3 -3
- package/src/better-auth/database-adapter/repository/generic.ts +9 -6
- package/src/better-auth/database-adapter/repository/user.ts +6 -2
- package/src/better-auth/database-adapter/schema.ts +1 -1
- package/src/better-auth/database-adapter/tests/index.test.ts +3 -4
- package/src/inspector/tests/viewer/history-view.test.tsx +6 -2
- package/src/media/utils.test.ts +5 -0
- package/src/media/utils.ts +25 -16
- package/src/react/hooks.tsx +2 -2
- package/src/react/index.ts +2 -2
- package/src/react/media/image.tsx +10 -2
- package/src/react/tests/useAcceptInvite.test.ts +3 -1
- package/src/react-core/hooks.ts +226 -304
- package/src/react-core/subscription-provider.tsx +14 -7
- package/src/react-core/tests/createCoValueSubscriptionContext.test.tsx +233 -0
- package/src/react-core/tests/subscription.bench.tsx +32 -15
- package/src/react-core/tests/{useAccountWithSelector.test.ts → useAccount.selector.test.ts} +72 -24
- package/src/react-core/tests/useAccount.test.ts +92 -106
- package/src/react-core/tests/{useCoStateWithSelector.test.ts → useCoState.selector.test.ts} +23 -8
- package/src/react-core/tests/useCoState.test.ts +173 -49
- package/src/react-core/tests/useInboxSender.test.ts +3 -1
- package/src/react-core/tests/usePassPhraseAuth.test.ts +11 -82
- package/src/react-core/tests/useSubscriptionSelector.test.ts +48 -14
- package/src/react-native-core/hooks.tsx +2 -2
- package/src/react-native-core/media/image.tsx +3 -1
- package/src/svelte/jazz.class.svelte.ts +103 -27
- package/src/svelte/media/image.svelte +6 -5
- package/src/svelte/tests/AccountCoState.svelte.test-d.ts +23 -0
- package/src/svelte/tests/CoState.svelte.test-d.ts +20 -0
- package/src/svelte/tests/CoState.svelte.test.ts +57 -0
- package/src/svelte/tests/TestCoStateWrapper.svelte +23 -0
- package/src/tools/coValues/CoValueBase.ts +12 -0
- package/src/tools/coValues/account.ts +17 -12
- package/src/tools/coValues/coFeed.ts +38 -15
- package/src/tools/coValues/coList.ts +16 -11
- package/src/tools/coValues/coMap.ts +15 -14
- package/src/tools/coValues/coPlainText.ts +6 -3
- package/src/tools/coValues/coVector.ts +6 -5
- package/src/tools/coValues/deepLoading.ts +98 -51
- package/src/tools/coValues/group.ts +3 -2
- package/src/tools/coValues/inbox.ts +11 -10
- package/src/tools/coValues/interfaces.ts +49 -27
- package/src/tools/coValues/request.ts +8 -6
- package/src/tools/coValues/schemaUnion.ts +2 -1
- package/src/tools/exports.ts +11 -1
- package/src/tools/implementation/refs.ts +19 -13
- package/src/tools/implementation/schema.ts +5 -4
- package/src/tools/implementation/schemaUtils.ts +15 -0
- package/src/tools/implementation/zodSchema/runtimeConverters/coValueSchemaTransformation.ts +4 -4
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +131 -95
- package/src/tools/implementation/zodSchema/schemaTypes/CoDiscriminatedUnionSchema.ts +19 -9
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +73 -22
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +86 -28
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +204 -148
- package/src/tools/implementation/zodSchema/schemaTypes/CoOptionalSchema.ts +1 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +71 -27
- package/src/tools/implementation/zodSchema/schemaTypes/CoValueSchema.ts +7 -0
- package/src/tools/implementation/zodSchema/schemaTypes/CoVectorSchema.ts +8 -6
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/schemaTypes/GroupSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +4 -1
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +3 -0
- package/src/tools/implementation/zodSchema/typeConverters/{InstanceOfSchemaCoValuesNullable.ts → InstanceOfSchemaCoValuesMaybeLoaded.ts} +47 -39
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchema.ts +4 -0
- package/src/tools/implementation/zodSchema/typeConverters/{InstanceOrPrimitiveOfSchemaCoValuesNullable.ts → InstanceOrPrimitiveOfSchemaCoValuesMaybeLoaded.ts} +7 -3
- package/src/tools/implementation/zodSchema/zodSchema.ts +15 -7
- package/src/tools/internal.ts +3 -3
- package/src/tools/lib/utils.test.ts +56 -0
- package/src/tools/lib/utils.ts +32 -0
- package/src/tools/subscribe/CoValueCoreSubscription.ts +13 -8
- package/src/tools/subscribe/JazzError.ts +8 -2
- package/src/tools/subscribe/SubscriptionScope.ts +55 -44
- package/src/tools/subscribe/index.ts +12 -4
- package/src/tools/subscribe/types.ts +36 -2
- package/src/tools/subscribe/utils.ts +2 -1
- package/src/tools/testing.ts +5 -0
- package/src/tools/tests/CoValueCoreSubscription.test.ts +10 -4
- package/src/tools/tests/ContextManager.test.ts +12 -5
- package/src/tools/tests/account.test.ts +22 -12
- package/src/tools/tests/coDiscriminatedUnion.test.ts +8 -4
- package/src/tools/tests/coFeed.branch.test.ts +48 -32
- package/src/tools/tests/coFeed.test-d.ts +17 -10
- package/src/tools/tests/coFeed.test.ts +52 -30
- package/src/tools/tests/coList.branch.test.ts +21 -21
- package/src/tools/tests/coList.test-d.ts +39 -23
- package/src/tools/tests/coList.test.ts +51 -25
- package/src/tools/tests/coList.unique.test.ts +34 -29
- package/src/tools/tests/coMap.branch.test.ts +20 -21
- package/src/tools/tests/coMap.record.test-d.ts +28 -26
- package/src/tools/tests/coMap.record.test.ts +30 -20
- package/src/tools/tests/coMap.test-d.ts +31 -29
- package/src/tools/tests/coMap.test.ts +67 -40
- package/src/tools/tests/coMap.unique.test.ts +25 -24
- package/src/tools/tests/coVector.test.ts +29 -15
- package/src/tools/tests/createContext.test.ts +5 -3
- package/src/tools/tests/deepLoading.test.ts +314 -117
- package/src/tools/tests/exportImport.test.ts +16 -15
- package/src/tools/tests/groupsAndAccounts.test.ts +39 -16
- package/src/tools/tests/inbox.test.ts +3 -1
- package/src/tools/tests/load.test.ts +29 -23
- package/src/tools/tests/patterns/quest.test.ts +3 -2
- package/src/tools/tests/patterns/requestToJoin.test.ts +17 -17
- package/src/tools/tests/request.test.ts +12 -2
- package/src/tools/tests/schema.resolved.test.ts +723 -0
- package/src/tools/tests/schemaUnion.test.ts +7 -3
- package/src/tools/tests/subscribe.test.ts +39 -21
- package/src/tools/tests/testing.test.ts +3 -2
- package/src/tools/tests/utils.ts +15 -2
- package/dist/chunk-OSQ7S47Q.js.map +0 -1
- package/dist/media/chunk-K6GCHLQU.js.map +0 -1
- package/dist/react-core/tests/useAccountWithSelector.test.d.ts +0 -2
- package/dist/react-core/tests/useAccountWithSelector.test.d.ts.map +0 -1
- package/dist/react-core/tests/useCoStateWithSelector.test.d.ts +0 -2
- package/dist/react-core/tests/useCoStateWithSelector.test.d.ts.map +0 -1
- package/dist/tools/implementation/errors.d.ts +0 -2
- package/dist/tools/implementation/errors.d.ts.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +0 -19
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts +0 -5
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOrPrimitiveOfSchemaCoValuesNullable.d.ts.map +0 -1
- package/dist/tools/lib/id.d.ts +0 -2
- package/dist/tools/lib/id.d.ts.map +0 -1
- package/src/tools/implementation/errors.ts +0 -1
- package/src/tools/lib/id.ts +0 -3
|
@@ -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 useSyncConnectionStatus,\n useCoValueSubscription,\n useAccountSubscription,\n useSubscriptionSelector,\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 authSecretStorageKey?: string;\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 authSecretStorageKey,\n}: JazzProviderProps<S>) {\n setupKvStore(kvStore);\n\n const [contextManager] = React.useState(\n () => new ReactNativeContextManager<S>({ authSecretStorageKey }),\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 peers: 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 peers,\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 peers.push(peer);\n }\n },\n removePeer: (peer) => {\n peers.splice(peers.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 peers,\n setNode,\n crypto,\n storage,\n };\n}\n\nexport async function createJazzReactNativeGuestContext(\n options: BaseReactNativeContextOptions,\n) {\n const {\n toggleNetwork,\n peers,\n setNode,\n crypto,\n storage,\n addConnectionListener,\n connected,\n } = await setupPeers(options);\n\n const context = createAnonymousJazzContext({\n crypto,\n peers,\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 peers,\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 peers,\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 * A custom placeholder to display while an image is loading. This will\n * be passed as the src of the img tag, so a data URL works well here.\n * This will be used as a fallback if no images are ready and no placeholder\n * is available otherwise.\n */\n placeholder?: string;\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 * placeholder=\"/placeholder.png\"\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, placeholder, ...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 ?? placeholder;\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 (!src) {\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 {\n createCoValueSubscriptionContext,\n createAccountSubscriptionContext,\n type CoValueSubscription,\n} from \"jazz-tools/react-core\";\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,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ACL,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,OAAO,sBAAsB;AAE/B,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,KAAK;AACR,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;;;ACnKD;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,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 useAgent,\n useLogOut,\n useSyncConnectionStatus,\n useCoValueSubscription,\n useAccountSubscription,\n useSubscriptionSelector,\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 authSecretStorageKey?: string;\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 authSecretStorageKey,\n}: JazzProviderProps<S>) {\n setupKvStore(kvStore);\n\n const [contextManager] = React.useState(\n () => new ReactNativeContextManager<S>({ authSecretStorageKey }),\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 peers: 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 peers,\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 peers.push(peer);\n }\n },\n removePeer: (peer) => {\n peers.splice(peers.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 peers,\n setNode,\n crypto,\n storage,\n };\n}\n\nexport async function createJazzReactNativeGuestContext(\n options: BaseReactNativeContextOptions,\n) {\n const {\n toggleNetwork,\n peers,\n setNode,\n crypto,\n storage,\n addConnectionListener,\n connected,\n } = await setupPeers(options);\n\n const context = createAnonymousJazzContext({\n crypto,\n peers,\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 peers,\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 peers,\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 * A custom placeholder to display while an image is loading. This will\n * be passed as the src of the img tag, so a data URL works well here.\n * This will be used as a fallback if no images are ready and no placeholder\n * is available otherwise.\n */\n placeholder?: string;\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 * placeholder=\"/placeholder.png\"\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, placeholder, ...props },\n ref,\n) {\n const image = useCoState(ImageDefinition, imageId, {\n select: (image) => (image.$isLoaded ? image : null),\n });\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 ?? placeholder;\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 (!src) {\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 {\n createCoValueSubscriptionContext,\n createAccountSubscriptionContext,\n type CoValueSubscription,\n} from \"jazz-tools/react-core\";\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;AAAA,IAC/B,CAAC;AAAA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K,CAAC;AAEV,MAAI,CAAC,KAAK;AACR,WAAO;AAAA,EACT;AAEA,SACE,gBAAAJ;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;;;ACrKD;AAAA,EACE;AAAA,EACA;AAAA,OAEK;AAEP,SAAS,iCAAiC;AAC1C,SAAS,mBAAAK,wBAAuB;","names":["username","useJazzContext","React","useEffect","CryptoProvider","handleAuthUpdate","jsx","CryptoProvider","React","useEffect","useEffect","useState","jsx","Image","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;IAC7B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,KAAK;IAnEhB,+CAA+C;aACtC,MAAM;IACf;;;;;;;;;;;;OAYG;YACK,MAAM,GAAG,UAAU;IAC3B;;;;;;;;;;;;OAYG;aACM,MAAM,GAAG,UAAU;IAC5B;;;;;OAKG;kBACW,MAAM;
|
|
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;IAC7B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,eAAO,MAAM,KAAK;IAnEhB,+CAA+C;aACtC,MAAM;IACf;;;;;;;;;;;;OAYG;YACK,MAAM,GAAG,UAAU;IAC3B;;;;;;;;;;;;OAYG;aACM,MAAM,GAAG,UAAU;IAC5B;;;;;OAKG;kBACW,MAAM;2CAgIpB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Account, AccountClass, AnyAccountSchema, BranchDefinition, CoValueClassOrSchema, CoValueFromRaw, InstanceOfSchema, Loaded, ResolveQuery, ResolveQueryStrict } from "jazz-tools";
|
|
1
|
+
import type { Account, AccountClass, AnyAccountSchema, BranchDefinition, CoValueClassOrSchema, CoValueFromRaw, SchemaResolveQuery, InstanceOfSchema, Loaded, MaybeLoaded, ResolveQuery, ResolveQueryStrict } from "jazz-tools";
|
|
2
2
|
type CoStateOptions<V extends CoValueClassOrSchema, R extends ResolveQuery<V>> = {
|
|
3
3
|
resolve?: ResolveQueryStrict<V, R>;
|
|
4
4
|
/**
|
|
@@ -15,22 +15,22 @@ type CoStateOptions<V extends CoValueClassOrSchema, R extends ResolveQuery<V>> =
|
|
|
15
15
|
* the branch. If not provided, the branch is owned by the current user.
|
|
16
16
|
*
|
|
17
17
|
* For more info see the [branching](https://jazz.tools/docs/svelte/using-covalues/version-control) documentation.
|
|
18
|
-
|
|
18
|
+
*/
|
|
19
19
|
unstable_branch?: BranchDefinition;
|
|
20
20
|
};
|
|
21
21
|
type CoStateId = string | undefined | null;
|
|
22
|
-
export declare class CoState<V extends CoValueClassOrSchema, R extends ResolveQuery<V> =
|
|
22
|
+
export declare class CoState<V extends CoValueClassOrSchema, R extends ResolveQuery<V> = SchemaResolveQuery<V>> {
|
|
23
23
|
#private;
|
|
24
24
|
constructor(Schema: V, id: CoStateId | (() => CoStateId), options?: CoStateOptions<V, R> | (() => CoStateOptions<V, R>));
|
|
25
|
-
update(value: Loaded<V, R
|
|
26
|
-
get current(): Loaded<V, R
|
|
25
|
+
update(value: MaybeLoaded<Loaded<V, R>>): void;
|
|
26
|
+
get current(): MaybeLoaded<Loaded<V, R>>;
|
|
27
27
|
}
|
|
28
|
-
export declare class AccountCoState<A extends (AccountClass<Account> & CoValueFromRaw<Account>) | AnyAccountSchema, R extends ResolveQuery<A> =
|
|
28
|
+
export declare class AccountCoState<A extends (AccountClass<Account> & CoValueFromRaw<Account>) | AnyAccountSchema, R extends ResolveQuery<A> = SchemaResolveQuery<A>> {
|
|
29
29
|
#private;
|
|
30
30
|
constructor(Schema: A, options?: CoStateOptions<A, R> | (() => CoStateOptions<A, R>));
|
|
31
|
-
update(value: Loaded<A, R
|
|
31
|
+
update(value: MaybeLoaded<Loaded<A, R>>): void;
|
|
32
32
|
logOut: () => void;
|
|
33
|
-
get current(): Loaded<A, R
|
|
33
|
+
get current(): MaybeLoaded<Loaded<A, R>>;
|
|
34
34
|
get agent(): import("jazz-tools").AnonymousJazzAgent | InstanceOfSchema<A>;
|
|
35
35
|
get isAuthenticated(): boolean;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jazz.class.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/jazz.class.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,
|
|
1
|
+
{"version":3,"file":"jazz.class.svelte.d.ts","sourceRoot":"","sources":["../../../src/svelte/jazz.class.svelte.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,OAAO,EACP,YAAY,EACZ,gBAAgB,EAChB,gBAAgB,EAEhB,oBAAoB,EACpB,cAAc,EACd,kBAAkB,EAClB,gBAAgB,EAChB,MAAM,EACN,WAAW,EAEX,YAAY,EACZ,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAYpB,KAAK,cAAc,CACjB,CAAC,SAAS,oBAAoB,EAC9B,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,IACvB;IACF,OAAO,CAAC,EAAE,kBAAkB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACnC;;;;;;;;;;;;;;OAcG;IACH,eAAe,CAAC,EAAE,gBAAgB,CAAC;CACpC,CAAC;AAEF,KAAK,SAAS,GAAG,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;AAE3C,qBAAa,OAAO,CAClB,CAAC,SAAS,oBAAoB,EAE9B,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC;;gBAc/C,MAAM,EAAE,CAAC,EACT,EAAE,EAAE,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,EACjC,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAyD/D,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IASvC,IAAI,OAAO,8BAGV;CACF;AAED,qBAAa,cAAc,CACzB,CAAC,SACG,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,GACjD,gBAAgB,EAEpB,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,GAAG,kBAAkB,CAAC,CAAC,CAAC;;gBAY/C,MAAM,EAAE,CAAC,EACT,OAAO,CAAC,EAAE,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,MAAM,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IA6D/D,MAAM,CAAC,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAMvC,MAAM,aAEJ;IAEF,IAAI,OAAO,8BAIV;IAED,IAAI,KAAK,kEAQR;IAID,IAAI,eAAe,YAElB;CACF;AAgBD;;;;;;;;GAQG;AACH,qBAAa,oBAAoB;;;IA6B/B,IAAI,OAAO,YAGV;CACF"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { coValueClassFromCoValueClassOrSchema, subscribeToCoValue, } from "jazz-tools";
|
|
1
|
+
import { coValueClassFromCoValueClassOrSchema, subscribeToCoValue, createUnloadedCoValue, CoValueLoadingState, } from "jazz-tools";
|
|
2
2
|
import { untrack } from "svelte";
|
|
3
3
|
import { createSubscriber } from "svelte/reactivity";
|
|
4
4
|
import { useIsAuthenticated } from "./auth/useIsAuthenticated.svelte.js";
|
|
5
5
|
import { getJazzContext } from "./jazz.svelte";
|
|
6
6
|
export class CoState {
|
|
7
|
-
#value =
|
|
7
|
+
#value = createUnloadedCoValue("", CoValueLoadingState.LOADING);
|
|
8
|
+
#previousValue = undefined;
|
|
8
9
|
#ctx = getJazzContext();
|
|
9
10
|
#id;
|
|
10
11
|
#subscribe;
|
|
@@ -22,18 +23,19 @@ export class CoState {
|
|
|
22
23
|
const options = this.#options;
|
|
23
24
|
return untrack(() => {
|
|
24
25
|
if (!ctx || !id) {
|
|
25
|
-
return this.update(
|
|
26
|
+
return this.update(createUnloadedCoValue(id ?? "", CoValueLoadingState.UNAVAILABLE));
|
|
26
27
|
}
|
|
27
28
|
const agent = "me" in ctx ? ctx.me : ctx.guest;
|
|
29
|
+
const resolve = getResolveQuery(Schema, options?.resolve);
|
|
28
30
|
const unsubscribe = subscribeToCoValue(coValueClassFromCoValueClassOrSchema(Schema), id, {
|
|
29
31
|
// @ts-expect-error The resolve query type isn't compatible with the coValueClassFromCoValueClassOrSchema conversion
|
|
30
|
-
resolve
|
|
32
|
+
resolve,
|
|
31
33
|
loadAs: agent,
|
|
32
34
|
onUnavailable: () => {
|
|
33
|
-
this.update(
|
|
35
|
+
this.update(createUnloadedCoValue(id, CoValueLoadingState.UNAVAILABLE));
|
|
34
36
|
},
|
|
35
37
|
onUnauthorized: () => {
|
|
36
|
-
this.update(
|
|
38
|
+
this.update(createUnloadedCoValue(id, CoValueLoadingState.UNAUTHORIZED));
|
|
37
39
|
},
|
|
38
40
|
syncResolution: true,
|
|
39
41
|
unstable_branch: options?.unstable_branch,
|
|
@@ -47,8 +49,10 @@ export class CoState {
|
|
|
47
49
|
});
|
|
48
50
|
}
|
|
49
51
|
update(value) {
|
|
50
|
-
if (this.#value
|
|
52
|
+
if (shouldSkipUpdate(value, this.#value)) {
|
|
51
53
|
return;
|
|
54
|
+
}
|
|
55
|
+
this.#previousValue = value;
|
|
52
56
|
this.#value = value;
|
|
53
57
|
this.#update();
|
|
54
58
|
}
|
|
@@ -58,7 +62,7 @@ export class CoState {
|
|
|
58
62
|
}
|
|
59
63
|
}
|
|
60
64
|
export class AccountCoState {
|
|
61
|
-
#value =
|
|
65
|
+
#value = createUnloadedCoValue("", CoValueLoadingState.LOADING);
|
|
62
66
|
#ctx = getJazzContext();
|
|
63
67
|
#subscribe;
|
|
64
68
|
#options;
|
|
@@ -73,18 +77,18 @@ export class AccountCoState {
|
|
|
73
77
|
const options = this.#options;
|
|
74
78
|
return untrack(() => {
|
|
75
79
|
if (!ctx || !("me" in ctx)) {
|
|
76
|
-
return this.update(
|
|
80
|
+
return this.update(createUnloadedCoValue("", CoValueLoadingState.UNAVAILABLE));
|
|
77
81
|
}
|
|
78
82
|
const me = ctx.me;
|
|
83
|
+
const resolve = getResolveQuery(Schema, options?.resolve);
|
|
79
84
|
const unsubscribe = subscribeToCoValue(coValueClassFromCoValueClassOrSchema(Schema), me.$jazz.id, {
|
|
80
|
-
|
|
81
|
-
resolve: options?.resolve,
|
|
85
|
+
resolve,
|
|
82
86
|
loadAs: me,
|
|
83
87
|
onUnavailable: () => {
|
|
84
|
-
this.update(
|
|
88
|
+
this.update(createUnloadedCoValue(me.$jazz.id, CoValueLoadingState.UNAVAILABLE));
|
|
85
89
|
},
|
|
86
90
|
onUnauthorized: () => {
|
|
87
|
-
this.update(
|
|
91
|
+
this.update(createUnloadedCoValue(me.$jazz.id, CoValueLoadingState.UNAUTHORIZED));
|
|
88
92
|
},
|
|
89
93
|
syncResolution: true,
|
|
90
94
|
unstable_branch: options?.unstable_branch,
|
|
@@ -98,7 +102,7 @@ export class AccountCoState {
|
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
update(value) {
|
|
101
|
-
if (this.#value
|
|
105
|
+
if (shouldSkipUpdate(value, this.#value))
|
|
102
106
|
return;
|
|
103
107
|
this.#value = value;
|
|
104
108
|
this.#update();
|
|
@@ -123,6 +127,15 @@ export class AccountCoState {
|
|
|
123
127
|
return this.#isAuthenticated.current;
|
|
124
128
|
}
|
|
125
129
|
}
|
|
130
|
+
function shouldSkipUpdate(newValue, previousValue) {
|
|
131
|
+
if (previousValue === newValue)
|
|
132
|
+
return true;
|
|
133
|
+
// Avoid re-renders if the value is not loaded and didn't change
|
|
134
|
+
return (previousValue.$jazz.id === newValue.$jazz.id &&
|
|
135
|
+
!previousValue.$isLoaded &&
|
|
136
|
+
!newValue.$isLoaded &&
|
|
137
|
+
previousValue.$jazz.loadingState === newValue.$jazz.loadingState);
|
|
138
|
+
}
|
|
126
139
|
/**
|
|
127
140
|
* Class that provides the current connection status to the Jazz sync server.
|
|
128
141
|
*
|
|
@@ -160,3 +173,15 @@ export class SyncConnectionStatus {
|
|
|
160
173
|
return this.#ctx.current?.connected() ?? false;
|
|
161
174
|
}
|
|
162
175
|
}
|
|
176
|
+
function getResolveQuery(Schema,
|
|
177
|
+
// We don't need type validation here, since this is an internal API
|
|
178
|
+
resolveQuery) {
|
|
179
|
+
if (resolveQuery) {
|
|
180
|
+
return resolveQuery;
|
|
181
|
+
}
|
|
182
|
+
// Check the schema is a CoValue schema (and not a CoValue class)
|
|
183
|
+
if ("resolveQuery" in Schema) {
|
|
184
|
+
return Schema.resolveQuery;
|
|
185
|
+
}
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import { ImageDefinition } from "jazz-tools";
|
|
2
|
+
import { CoValueLoadingState, ImageDefinition } from "jazz-tools";
|
|
3
3
|
import { highestResAvailable } from "jazz-tools/media";
|
|
4
4
|
import { onDestroy } from "svelte";
|
|
5
5
|
import { CoState } from "../jazz.class.svelte";
|
|
@@ -25,8 +25,9 @@
|
|
|
25
25
|
width: number | undefined;
|
|
26
26
|
height: number | undefined;
|
|
27
27
|
}>(() => {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
28
|
+
const originalSize = imageState.current.$isLoaded ? imageState.current.originalSize : undefined;
|
|
29
|
+
const originalWidth = originalSize?.[0];
|
|
30
|
+
const originalHeight = originalSize?.[1];
|
|
30
31
|
|
|
31
32
|
// Both width and height are "original"
|
|
32
33
|
if (width === "original" && height === "original") {
|
|
@@ -68,13 +69,13 @@
|
|
|
68
69
|
}
|
|
69
70
|
|
|
70
71
|
const image = imageState.current;
|
|
71
|
-
if (image ===
|
|
72
|
+
if (image.$jazz.loadingState === CoValueLoadingState.LOADING)
|
|
72
73
|
return (
|
|
73
74
|
placeholder ??
|
|
74
75
|
"data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="
|
|
75
76
|
);
|
|
76
77
|
|
|
77
|
-
if (!image) return undefined;
|
|
78
|
+
if (!image.$isLoaded) return undefined;
|
|
78
79
|
|
|
79
80
|
const bestImage = highestResAvailable(
|
|
80
81
|
image,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"image.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/media/image.svelte.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAqInD,QAAA,MAAM,KAAK,gDAAsC,CAAC;AAClD,KAAK,KAAK,GAAG,UAAU,CAAC,OAAO,KAAK,CAAC,CAAC;AACtC,eAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AccountCoState.svelte.test-d.d.ts","sourceRoot":"","sources":["../../../../src/svelte/tests/AccountCoState.svelte.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { co } from "jazz-tools";
|
|
2
|
+
import { assertLoaded, createJazzTestAccount, setupJazzTestSync } from "jazz-tools/testing";
|
|
3
|
+
import { beforeEach, describe, expectTypeOf, test } from "vitest";
|
|
4
|
+
import { AccountCoState } from "../jazz.class.svelte";
|
|
5
|
+
describe("AccountCoState", () => {
|
|
6
|
+
beforeEach(async () => {
|
|
7
|
+
await setupJazzTestSync();
|
|
8
|
+
await createJazzTestAccount({
|
|
9
|
+
isCurrentActiveAccount: true,
|
|
10
|
+
creationProps: { name: "Hermes Puggington" },
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
test("should use the schema's resolve query if no resolve query is provided", async () => {
|
|
14
|
+
const AccountWithProfile = co.account().resolved({ profile: true });
|
|
15
|
+
const loadedAccount = new AccountCoState(AccountWithProfile);
|
|
16
|
+
assertLoaded(loadedAccount.current);
|
|
17
|
+
expectTypeOf().toEqualTypeOf();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoState.svelte.test-d.d.ts","sourceRoot":"","sources":["../../../../src/svelte/tests/CoState.svelte.test-d.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { co } from "jazz-tools";
|
|
2
|
+
import { assertLoaded } from "jazz-tools/testing";
|
|
3
|
+
import { describe, expectTypeOf, test } from "vitest";
|
|
4
|
+
import { CoState } from "../jazz.class.svelte";
|
|
5
|
+
describe("CoState", () => {
|
|
6
|
+
test("should use the schema's resolve query if no resolve query is provided", async () => {
|
|
7
|
+
const Person = co.map({
|
|
8
|
+
name: co.plainText(),
|
|
9
|
+
});
|
|
10
|
+
const PersonWithName = Person.resolved({ name: true });
|
|
11
|
+
const person = Person.create({ name: "John Doe" });
|
|
12
|
+
const loadedPerson = new CoState(PersonWithName, person.$jazz.id);
|
|
13
|
+
assertLoaded(loadedPerson.current);
|
|
14
|
+
expectTypeOf().toEqualTypeOf();
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoState.svelte.test.d.ts","sourceRoot":"","sources":["../../../../src/svelte/tests/CoState.svelte.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// @vitest-environment happy-dom
|
|
2
|
+
import { co, Account, CoValueLoadingState, Group } from "jazz-tools";
|
|
3
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
4
|
+
import { createJazzTestAccount, setupJazzTestSync } from "../testing";
|
|
5
|
+
import { render, screen, waitFor } from "./testUtils";
|
|
6
|
+
import TestCoStateWrapper from "./TestCoStateWrapper.svelte";
|
|
7
|
+
describe("CoState", () => {
|
|
8
|
+
let serverAccount;
|
|
9
|
+
let clientAccount;
|
|
10
|
+
let publicGroup;
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
await setupJazzTestSync();
|
|
13
|
+
await createJazzTestAccount({
|
|
14
|
+
creationProps: { name: "Server" },
|
|
15
|
+
isCurrentActiveAccount: true,
|
|
16
|
+
});
|
|
17
|
+
serverAccount = Account.getMe();
|
|
18
|
+
clientAccount = await createJazzTestAccount({
|
|
19
|
+
creationProps: { name: "Client" },
|
|
20
|
+
});
|
|
21
|
+
publicGroup = Group.create(serverAccount).makePublic("reader");
|
|
22
|
+
});
|
|
23
|
+
it("should use the schema's resolve query if no resolve query is provided", async () => {
|
|
24
|
+
const Person = co.map({
|
|
25
|
+
name: co.plainText(),
|
|
26
|
+
});
|
|
27
|
+
const PersonWithName = Person.resolved({ name: true });
|
|
28
|
+
const person = Person.create({ name: "John Doe" }, publicGroup);
|
|
29
|
+
render(TestCoStateWrapper, {
|
|
30
|
+
Schema: PersonWithName,
|
|
31
|
+
id: person.$jazz.id,
|
|
32
|
+
}, {
|
|
33
|
+
account: clientAccount,
|
|
34
|
+
});
|
|
35
|
+
await waitFor(() => {
|
|
36
|
+
expect(screen.getByTestId("loading-state").textContent).toBe(CoValueLoadingState.LOADED);
|
|
37
|
+
});
|
|
38
|
+
expect(screen.getByTestId("is-loaded").textContent).toBe("true");
|
|
39
|
+
const stateValue = JSON.parse(screen.getByTestId("state-value").textContent ?? "");
|
|
40
|
+
expect(stateValue.name).toBe("John Doe");
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { CoValueClassOrSchema, ResolveQuery } from 'jazz-tools';
|
|
3
|
+
import { CoState } from '../jazz.class.svelte';
|
|
4
|
+
|
|
5
|
+
type Props<V extends CoValueClassOrSchema, R extends ResolveQuery<V>> = {
|
|
6
|
+
Schema: V;
|
|
7
|
+
id: string;
|
|
8
|
+
options?: { resolve?: R };
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
let { Schema, id, options }: Props<any, any> = $props();
|
|
12
|
+
|
|
13
|
+
const state = new CoState(Schema, id, options);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<div data-testid="costate-wrapper">
|
|
17
|
+
<div data-testid="loading-state">{state.current.$jazz.loadingState}</div>
|
|
18
|
+
<div data-testid="is-loaded">{state.current.$isLoaded ? 'true' : 'false'}</div>
|
|
19
|
+
{#if state.current.$isLoaded}
|
|
20
|
+
<div data-testid="state-value">{JSON.stringify(state.current.toJSON())}</div>
|
|
21
|
+
{/if}
|
|
22
|
+
</div>
|
|
23
|
+
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { CoValueClassOrSchema, ResolveQuery } from 'jazz-tools';
|
|
2
|
+
type Props<V extends CoValueClassOrSchema, R extends ResolveQuery<V>> = {
|
|
3
|
+
Schema: V;
|
|
4
|
+
id: string;
|
|
5
|
+
options?: {
|
|
6
|
+
resolve?: R;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
declare const TestCoStateWrapper: import("svelte").Component<Props<any, any>, {}, "">;
|
|
10
|
+
type TestCoStateWrapper = ReturnType<typeof TestCoStateWrapper>;
|
|
11
|
+
export default TestCoStateWrapper;
|
|
12
|
+
//# sourceMappingURL=TestCoStateWrapper.svelte.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TestCoStateWrapper.svelte.d.ts","sourceRoot":"","sources":["../../../../src/svelte/tests/TestCoStateWrapper.svelte.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAInE,KAAK,KAAK,CAAC,CAAC,SAAS,oBAAoB,EAAE,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,IAAI;IACtE,MAAM,EAAE,CAAC,CAAC;IACV,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,CAAC,EAAE;QAAE,OAAO,CAAC,EAAE,CAAC,CAAA;KAAE,CAAC;CAC3B,CAAC;AAsBJ,QAAA,MAAM,kBAAkB,qDAAsC,CAAC;AAC/D,KAAK,kBAAkB,GAAG,UAAU,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAChE,eAAe,kBAAkB,CAAC"}
|
package/dist/testing.js
CHANGED
|
@@ -2,11 +2,12 @@ import {
|
|
|
2
2
|
Account,
|
|
3
3
|
JazzContextManager,
|
|
4
4
|
activeAccountContext,
|
|
5
|
+
assertLoaded,
|
|
5
6
|
coValueClassFromCoValueClassOrSchema,
|
|
6
7
|
createAnonymousJazzContext,
|
|
7
8
|
createJazzContext,
|
|
8
9
|
randomSessionProvider
|
|
9
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-P3YLNFN4.js";
|
|
10
11
|
import "./chunk-PZ5AY32C.js";
|
|
11
12
|
|
|
12
13
|
// src/tools/testing.ts
|
|
@@ -278,6 +279,7 @@ export {
|
|
|
278
279
|
MockConnectionStatus,
|
|
279
280
|
TestJSCrypto,
|
|
280
281
|
TestJazzContextManager,
|
|
282
|
+
assertLoaded,
|
|
281
283
|
createJazzTestAccount,
|
|
282
284
|
createJazzTestGuest,
|
|
283
285
|
disableJazzTestSync,
|