jazz-tools 0.18.37 → 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 +53 -53
- package/CHANGELOG.md +33 -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/inspector/{custom-element-SUVJ7CPN.js → custom-element-QESCMFY7.js} +13 -3
- package/dist/inspector/{custom-element-SUVJ7CPN.js.map → custom-element-QESCMFY7.js.map} +1 -1
- package/dist/inspector/index.js +12 -2
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/inspector/viewer/history-view.d.ts.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 +74 -10
- package/src/inspector/viewer/history-view.tsx +14 -5
- 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,10 +1,10 @@
|
|
|
1
|
-
import { Account, AccountClass, AnonymousJazzAgent, AnyAccountSchema, CoValue, CoValueClassOrSchema, JazzContextManager, JazzContextType, Loaded, ResolveQuery, ResolveQueryStrict, type BranchDefinition } from "jazz-tools";
|
|
1
|
+
import { Account, AccountClass, AnonymousJazzAgent, AnyAccountSchema, CoValue, CoValueClassOrSchema, JazzContextManager, JazzContextType, Loaded, MaybeLoaded, ResolveQuery, ResolveQueryStrict, SchemaResolveQuery, type BranchDefinition } from "jazz-tools";
|
|
2
2
|
import { CoValueSubscription } from "./types.js";
|
|
3
3
|
export declare function useJazzContext<Acc extends Account>(): JazzContextType<Acc>;
|
|
4
4
|
export declare function useJazzContextManager<Acc extends Account>(): JazzContextManager<Acc, {}>;
|
|
5
5
|
export declare function useAuthSecretStorage(): import("jazz-tools").AuthSecretStorage;
|
|
6
6
|
export declare function useIsAuthenticated(): boolean;
|
|
7
|
-
export declare function useCoValueSubscription<S extends CoValueClassOrSchema, const R extends ResolveQuery<S>>(Schema: S, id: string | undefined | null, options?: {
|
|
7
|
+
export declare function useCoValueSubscription<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = SchemaResolveQuery<S>>(Schema: S, id: string | undefined | null, options?: {
|
|
8
8
|
resolve?: ResolveQueryStrict<S, R>;
|
|
9
9
|
unstable_branch?: BranchDefinition;
|
|
10
10
|
}): CoValueSubscription<S, R>;
|
|
@@ -15,7 +15,38 @@ export declare function useCoValueSubscription<S extends CoValueClassOrSchema, c
|
|
|
15
15
|
* handles the subscription lifecycle (subscribe on mount, unsubscribe on unmount).
|
|
16
16
|
* It also supports deep loading of nested CoValues through resolve queries.
|
|
17
17
|
*
|
|
18
|
-
*
|
|
18
|
+
* The {@param options.select} function allows returning only specific parts of the CoValue data,
|
|
19
|
+
* which helps reduce unnecessary re-renders by narrowing down the returned data.
|
|
20
|
+
* Additionally, you can provide a custom {@param options.equalityFn} to further optimize
|
|
21
|
+
* performance by controlling when the component should re-render based on the selected data.
|
|
22
|
+
*
|
|
23
|
+
* @returns The loaded CoValue, or an {@link NotLoaded} value. Use `$isLoaded` to check whether the
|
|
24
|
+
* CoValue is loaded, or use {@link MaybeLoaded.$jazz.loadingState} to get the detailed loading state.
|
|
25
|
+
* If a selector function is provided, returns the result of the selector function.
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* ```tsx
|
|
29
|
+
* // Select only specific fields to reduce re-renders
|
|
30
|
+
* const Project = co.map({
|
|
31
|
+
* name: z.string(),
|
|
32
|
+
* description: z.string(),
|
|
33
|
+
* tasks: co.list(Task),
|
|
34
|
+
* lastModified: z.date(),
|
|
35
|
+
* });
|
|
36
|
+
*
|
|
37
|
+
* function ProjectTitle({ projectId }: { projectId: string }) {
|
|
38
|
+
* // Only re-render when the project name changes, not other fields
|
|
39
|
+
* const projectName = useCoState(
|
|
40
|
+
* Project,
|
|
41
|
+
* projectId,
|
|
42
|
+
* {
|
|
43
|
+
* select: (project) => !project.$isLoading ? project.name : "Loading...",
|
|
44
|
+
* }
|
|
45
|
+
* );
|
|
46
|
+
*
|
|
47
|
+
* return <h1>{projectName}</h1>;
|
|
48
|
+
* }
|
|
49
|
+
* ```
|
|
19
50
|
*
|
|
20
51
|
* @example
|
|
21
52
|
* ```tsx
|
|
@@ -34,10 +65,15 @@ export declare function useCoValueSubscription<S extends CoValueClassOrSchema, c
|
|
|
34
65
|
* },
|
|
35
66
|
* });
|
|
36
67
|
*
|
|
37
|
-
* if (!project) {
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
68
|
+
* if (!project.$isLoaded) {
|
|
69
|
+
* switch (project.$jazz.loadingState) {
|
|
70
|
+
* case "unauthorized":
|
|
71
|
+
* return "Project not accessible";
|
|
72
|
+
* case "unavailable":
|
|
73
|
+
* return "Project not found";
|
|
74
|
+
* case "loading":
|
|
75
|
+
* return "Loading project...";
|
|
76
|
+
* }
|
|
41
77
|
* }
|
|
42
78
|
*
|
|
43
79
|
* return (
|
|
@@ -67,14 +103,19 @@ export declare function useCoValueSubscription<S extends CoValueClassOrSchema, c
|
|
|
67
103
|
* const task = useCoState(Task, taskId, {
|
|
68
104
|
* resolve: {
|
|
69
105
|
* assignee: true,
|
|
70
|
-
* subtasks: { $each: { $onError:
|
|
106
|
+
* subtasks: { $each: { $onError: 'catch' } },
|
|
71
107
|
* },
|
|
72
108
|
* });
|
|
73
109
|
*
|
|
74
|
-
* if (!task) {
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
110
|
+
* if (!task.$isLoaded) {
|
|
111
|
+
* switch (task.$jazz.loadingState) {
|
|
112
|
+
* case "unauthorized":
|
|
113
|
+
* return "Task not accessible";
|
|
114
|
+
* case "unavailable":
|
|
115
|
+
* return "Task not found";
|
|
116
|
+
* case "loading":
|
|
117
|
+
* return "Loading task...";
|
|
118
|
+
* }
|
|
78
119
|
* }
|
|
79
120
|
*
|
|
80
121
|
* return (
|
|
@@ -83,7 +124,7 @@ export declare function useCoValueSubscription<S extends CoValueClassOrSchema, c
|
|
|
83
124
|
* {task.assignee && <p>Assigned to: {task.assignee.name}</p>}
|
|
84
125
|
* <ul>
|
|
85
126
|
* {task.subtasks.map((subtask, index) => (
|
|
86
|
-
* subtask ? <li key={subtask.id}>{subtask.title}</li> : <li key={index}>Inaccessible subtask</li>
|
|
127
|
+
* subtask.$isLoaded ? <li key={subtask.id}>{subtask.title}</li> : <li key={index}>Inaccessible subtask</li>
|
|
87
128
|
* ))}
|
|
88
129
|
* </ul>
|
|
89
130
|
* </div>
|
|
@@ -91,84 +132,19 @@ export declare function useCoValueSubscription<S extends CoValueClassOrSchema, c
|
|
|
91
132
|
* }
|
|
92
133
|
* ```
|
|
93
134
|
*
|
|
94
|
-
* For more examples, see the [subscription and deep loading](https://jazz.tools/docs/react/using-covalues/subscription-and-loading) documentation.
|
|
95
|
-
*/
|
|
96
|
-
export declare function useCoState<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = true>(
|
|
97
|
-
/** The CoValue schema or class constructor */
|
|
98
|
-
Schema: S,
|
|
99
|
-
/** The ID of the CoValue to subscribe to. If `undefined`, returns `null` */
|
|
100
|
-
id: string | undefined,
|
|
101
|
-
/** Optional configuration for the subscription */
|
|
102
|
-
options?: {
|
|
103
|
-
/** Resolve query to specify which nested CoValues to load */
|
|
104
|
-
resolve?: ResolveQueryStrict<S, R>;
|
|
105
|
-
/**
|
|
106
|
-
* Create or load a branch for isolated editing.
|
|
107
|
-
*
|
|
108
|
-
* Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.
|
|
109
|
-
* It's a fork of your data graph: the same schema, but with diverging values.
|
|
110
|
-
*
|
|
111
|
-
* The checkout of the branch is applied on all the resolved values.
|
|
112
|
-
*
|
|
113
|
-
* @param name - A unique name for the branch. This identifies the branch
|
|
114
|
-
* and can be used to switch between different branches of the same CoValue.
|
|
115
|
-
* @param owner - The owner of the branch. Determines who can access and modify
|
|
116
|
-
* the branch. If not provided, the branch is owned by the current user.
|
|
117
|
-
*
|
|
118
|
-
* For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.
|
|
119
|
-
*/
|
|
120
|
-
unstable_branch?: BranchDefinition;
|
|
121
|
-
}): Loaded<S, R> | undefined | null;
|
|
122
|
-
/**
|
|
123
|
-
* React hook for subscribing to CoValues with selective data extraction and custom equality checking.
|
|
124
|
-
*
|
|
125
|
-
* This hook extends `useCoState` by allowing you to select only specific parts of the CoValue data
|
|
126
|
-
* through a selector function, which helps reduce unnecessary re-renders by narrowing down the
|
|
127
|
-
* returned data. Additionally, you can provide a custom equality function to further optimize
|
|
128
|
-
* performance by controlling when the component should re-render based on the selected data.
|
|
129
|
-
*
|
|
130
|
-
* The hook automatically handles the subscription lifecycle and supports deep loading of nested
|
|
131
|
-
* CoValues through resolve queries, just like `useCoState`.
|
|
132
|
-
*
|
|
133
|
-
* @returns The result of the selector function applied to the loaded CoValue data
|
|
134
|
-
*
|
|
135
|
-
* @example
|
|
136
|
-
* ```tsx
|
|
137
|
-
* // Select only specific fields to reduce re-renders
|
|
138
|
-
* const Project = co.map({
|
|
139
|
-
* name: z.string(),
|
|
140
|
-
* description: z.string(),
|
|
141
|
-
* tasks: co.list(Task),
|
|
142
|
-
* lastModified: z.date(),
|
|
143
|
-
* });
|
|
144
|
-
*
|
|
145
|
-
* function ProjectTitle({ projectId }: { projectId: string }) {
|
|
146
|
-
* // Only re-render when the project name changes, not other fields
|
|
147
|
-
* const projectName = useCoStateWithSelector(
|
|
148
|
-
* Project,
|
|
149
|
-
* projectId,
|
|
150
|
-
* {
|
|
151
|
-
* select: (project) => project?.name ?? "Loading...",
|
|
152
|
-
* }
|
|
153
|
-
* );
|
|
154
|
-
*
|
|
155
|
-
* return <h1>{projectName}</h1>;
|
|
156
|
-
* }
|
|
157
|
-
* ```
|
|
158
|
-
*
|
|
159
135
|
* @example
|
|
160
136
|
* ```tsx
|
|
161
137
|
* // Use custom equality function for complex data structures
|
|
162
138
|
* const TaskList = co.list(Task);
|
|
163
139
|
*
|
|
164
140
|
* function TaskCount({ listId }: { listId: string }) {
|
|
165
|
-
* const taskStats =
|
|
141
|
+
* const taskStats = useCoState(
|
|
166
142
|
* TaskList,
|
|
167
143
|
* listId,
|
|
168
144
|
* {
|
|
169
145
|
* resolve: { $each: true },
|
|
170
146
|
* select: (tasks) => {
|
|
171
|
-
* if (!tasks) return { total: 0, completed: 0 };
|
|
147
|
+
* if (!tasks.$isLoaded) return { total: 0, completed: 0 };
|
|
172
148
|
* return {
|
|
173
149
|
* total: tasks.length,
|
|
174
150
|
* completed: tasks.filter(task => task.completed).length,
|
|
@@ -187,68 +163,19 @@ options?: {
|
|
|
187
163
|
* }
|
|
188
164
|
* ```
|
|
189
165
|
*
|
|
190
|
-
* @example
|
|
191
|
-
* ```tsx
|
|
192
|
-
* // Combine with deep loading and complex selectors
|
|
193
|
-
* const Team = co.map({
|
|
194
|
-
* name: z.string(),
|
|
195
|
-
* members: co.list(TeamMember),
|
|
196
|
-
* projects: co.list(Project),
|
|
197
|
-
* });
|
|
198
|
-
*
|
|
199
|
-
* function TeamSummary({ teamId }: { teamId: string }) {
|
|
200
|
-
* const summary = useCoStateWithSelector(
|
|
201
|
-
* Team,
|
|
202
|
-
* teamId,
|
|
203
|
-
* {
|
|
204
|
-
* resolve: {
|
|
205
|
-
* members: { $each: true },
|
|
206
|
-
* projects: { $each: { tasks: { $each: true } } },
|
|
207
|
-
* },
|
|
208
|
-
* select: (team) => {
|
|
209
|
-
* if (!team) return null;
|
|
210
|
-
*
|
|
211
|
-
* const totalTasks = team.projects.reduce(
|
|
212
|
-
* (sum, project) => sum + project.tasks.length,
|
|
213
|
-
* 0
|
|
214
|
-
* );
|
|
215
|
-
*
|
|
216
|
-
* return {
|
|
217
|
-
* teamName: team.name,
|
|
218
|
-
* memberCount: team.members.length,
|
|
219
|
-
* projectCount: team.projects.length,
|
|
220
|
-
* totalTasks,
|
|
221
|
-
* };
|
|
222
|
-
* },
|
|
223
|
-
* }
|
|
224
|
-
* );
|
|
225
|
-
*
|
|
226
|
-
* if (!summary) return <div>Loading team summary...</div>;
|
|
227
|
-
*
|
|
228
|
-
* return (
|
|
229
|
-
* <div>
|
|
230
|
-
* <h2>{summary.teamName}</h2>
|
|
231
|
-
* <p>{summary.memberCount} members</p>
|
|
232
|
-
* <p>{summary.projectCount} projects</p>
|
|
233
|
-
* <p>{summary.totalTasks} total tasks</p>
|
|
234
|
-
* </div>
|
|
235
|
-
* );
|
|
236
|
-
* }
|
|
237
|
-
* ```
|
|
238
|
-
*
|
|
239
166
|
* For more examples, see the [subscription and deep loading](https://jazz.tools/docs/react/using-covalues/subscription-and-loading) documentation.
|
|
240
167
|
*/
|
|
241
|
-
export declare function
|
|
168
|
+
export declare function useCoState<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = SchemaResolveQuery<S>, TSelectorReturn = MaybeLoaded<Loaded<S, R>>>(
|
|
242
169
|
/** The CoValue schema or class constructor */
|
|
243
170
|
Schema: S,
|
|
244
|
-
/** The ID of the CoValue to subscribe to. If `undefined`, returns
|
|
171
|
+
/** The ID of the CoValue to subscribe to. If `undefined`, returns an `unavailable` value */
|
|
245
172
|
id: string | undefined,
|
|
246
173
|
/** Optional configuration for the subscription */
|
|
247
|
-
options
|
|
174
|
+
options?: {
|
|
248
175
|
/** Resolve query to specify which nested CoValues to load */
|
|
249
176
|
resolve?: ResolveQueryStrict<S, R>;
|
|
250
177
|
/** Select which value to return */
|
|
251
|
-
select
|
|
178
|
+
select?: (value: MaybeLoaded<Loaded<S, R>>) => TSelectorReturn;
|
|
252
179
|
/** Equality function to determine if the selected value has changed, defaults to `Object.is` */
|
|
253
180
|
equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;
|
|
254
181
|
/**
|
|
@@ -268,31 +195,64 @@ options: {
|
|
|
268
195
|
*/
|
|
269
196
|
unstable_branch?: BranchDefinition;
|
|
270
197
|
}): TSelectorReturn;
|
|
271
|
-
export declare function useSubscriptionSelector<S extends CoValueClassOrSchema, R extends ResolveQuery<S>, TSelectorReturn = Loaded<S, R
|
|
272
|
-
select?: (value: Loaded<S, R
|
|
198
|
+
export declare function useSubscriptionSelector<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = SchemaResolveQuery<S>, TSelectorReturn = MaybeLoaded<Loaded<S, R>>>(subscription: CoValueSubscription<S, R>, options?: {
|
|
199
|
+
select?: (value: MaybeLoaded<Loaded<S, R>>) => TSelectorReturn;
|
|
273
200
|
equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;
|
|
274
201
|
}): TSelectorReturn;
|
|
275
|
-
export declare function useAccountSubscription<S extends AccountClass<Account> | AnyAccountSchema, const R extends ResolveQuery<S>>(Schema: S, options?: {
|
|
202
|
+
export declare function useAccountSubscription<S extends AccountClass<Account> | AnyAccountSchema, const R extends ResolveQuery<S> = SchemaResolveQuery<S>>(Schema: S, options?: {
|
|
276
203
|
resolve?: ResolveQueryStrict<S, R>;
|
|
277
204
|
unstable_branch?: BranchDefinition;
|
|
278
205
|
}): CoValueSubscription<S, R>;
|
|
279
206
|
/**
|
|
280
|
-
* React hook for accessing the current user's account
|
|
207
|
+
* React hook for accessing the current user's account.
|
|
208
|
+
*
|
|
209
|
+
* This hook provides access to the current user's account profile and root data.
|
|
210
|
+
* It automatically handles the subscription lifecycle and supports deep loading of nested
|
|
211
|
+
* CoValues through resolve queries.
|
|
212
|
+
*
|
|
213
|
+
* The {@param options.select} function allows returning only specific parts of the account data,
|
|
214
|
+
* which helps reduce unnecessary re-renders by narrowing down the returned data.
|
|
215
|
+
* Additionally, you can provide a custom {@param options.equalityFn} to further optimize
|
|
216
|
+
* performance by controlling when the component should re-render based on the selected data.
|
|
217
|
+
*
|
|
218
|
+
* @returns The account data, or an {@link NotLoaded} value. Use `$isLoaded` to check whether the
|
|
219
|
+
* CoValue is loaded, or use {@link MaybeLoaded.$jazz.loadingState} to get the detailed loading state.
|
|
220
|
+
* If a selector function is provided, returns the result of the selector function.
|
|
221
|
+
*
|
|
222
|
+
* @example
|
|
223
|
+
* ```tsx
|
|
224
|
+
* // Select only specific fields to reduce re-renders
|
|
225
|
+
* const MyAppAccount = co.account({
|
|
226
|
+
* profile: co.profile(),
|
|
227
|
+
* root: co.map({
|
|
228
|
+
* name: z.string(),
|
|
229
|
+
* email: z.string(),
|
|
230
|
+
* lastLogin: z.date(),
|
|
231
|
+
* }),
|
|
232
|
+
* });
|
|
281
233
|
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
234
|
+
* function UserProfile({ accountId }: { accountId: string }) {
|
|
235
|
+
* // Only re-render when the profile name changes, not other fields
|
|
236
|
+
* const profileName = useAccount(
|
|
237
|
+
* MyAppAccount,
|
|
238
|
+
* {
|
|
239
|
+
* resolve: {
|
|
240
|
+
* profile: true,
|
|
241
|
+
* root: true,
|
|
242
|
+
* },
|
|
243
|
+
* select: (account) => account.$isLoaded ? account.profile.name : "Loading...",
|
|
244
|
+
* }
|
|
245
|
+
* );
|
|
246
|
+
*
|
|
247
|
+
* return <h1>{profileName}</h1>;
|
|
248
|
+
* }
|
|
249
|
+
* ```
|
|
285
250
|
*
|
|
286
|
-
* @returns An object containing:
|
|
287
|
-
* - `me`: The loaded account data, or `undefined` if loading, or `null` if not authenticated
|
|
288
|
-
* - `agent`: The current agent (anonymous or authenticated user). Can be used as `loadAs` parameter for load and subscribe methods.
|
|
289
|
-
* - `logOut`: Function to log out the current user
|
|
290
|
-
|
|
291
251
|
* @example
|
|
292
252
|
* ```tsx
|
|
293
253
|
* // Deep loading with resolve queries
|
|
294
254
|
* function ProjectListWithDetails() {
|
|
295
|
-
* const
|
|
255
|
+
* const me = useAccount(MyAppAccount, {
|
|
296
256
|
* resolve: {
|
|
297
257
|
* profile: true,
|
|
298
258
|
* root: {
|
|
@@ -305,10 +265,15 @@ export declare function useAccountSubscription<S extends AccountClass<Account> |
|
|
|
305
265
|
* },
|
|
306
266
|
* });
|
|
307
267
|
*
|
|
308
|
-
* if (!me) {
|
|
309
|
-
*
|
|
310
|
-
*
|
|
311
|
-
*
|
|
268
|
+
* if (!me.$isLoaded) {
|
|
269
|
+
* switch (me.$jazz.loadingState) {
|
|
270
|
+
* case "unauthorized":
|
|
271
|
+
* return "Account not accessible";
|
|
272
|
+
* case "unavailable":
|
|
273
|
+
* return "Account not found";
|
|
274
|
+
* case "loading":
|
|
275
|
+
* return "Loading account...";
|
|
276
|
+
* }
|
|
312
277
|
* }
|
|
313
278
|
*
|
|
314
279
|
* return (
|
|
@@ -327,87 +292,15 @@ export declare function useAccountSubscription<S extends AccountClass<Account> |
|
|
|
327
292
|
* ```
|
|
328
293
|
*
|
|
329
294
|
*/
|
|
330
|
-
export declare function useAccount<A extends AccountClass<Account> | AnyAccountSchema, R extends ResolveQuery<A> =
|
|
295
|
+
export declare function useAccount<A extends AccountClass<Account> | AnyAccountSchema, const R extends ResolveQuery<A> = SchemaResolveQuery<A>, TSelectorReturn = MaybeLoaded<Loaded<A, R>>>(
|
|
331
296
|
/** The account schema to use. Defaults to the base Account schema */
|
|
332
297
|
AccountSchema?: A,
|
|
333
298
|
/** Optional configuration for the subscription */
|
|
334
299
|
options?: {
|
|
335
|
-
/** Resolve query to specify which nested CoValues to load from the account */
|
|
336
|
-
resolve?: ResolveQueryStrict<A, R>;
|
|
337
|
-
/**
|
|
338
|
-
* Create or load a branch for isolated editing.
|
|
339
|
-
*
|
|
340
|
-
* Branching lets you take a snapshot of the current state and start modifying it without affecting the canonical/shared version.
|
|
341
|
-
* It's a fork of your data graph: the same schema, but with diverging values.
|
|
342
|
-
*
|
|
343
|
-
* The checkout of the branch is applied on all the resolved values.
|
|
344
|
-
*
|
|
345
|
-
* @param name - A unique name for the branch. This identifies the branch
|
|
346
|
-
* and can be used to switch between different branches of the same CoValue.
|
|
347
|
-
* @param owner - The owner of the branch. Determines who can access and modify
|
|
348
|
-
* the branch. If not provided, the branch is owned by the current user.
|
|
349
|
-
*
|
|
350
|
-
* For more info see the [branching](https://jazz.tools/docs/react/using-covalues/version-control) documentation.
|
|
351
|
-
*/
|
|
352
|
-
unstable_branch?: BranchDefinition;
|
|
353
|
-
}): {
|
|
354
|
-
me: Loaded<A, R> | undefined | null;
|
|
355
|
-
agent: AnonymousJazzAgent | Loaded<A, true>;
|
|
356
|
-
logOut: () => void;
|
|
357
|
-
};
|
|
358
|
-
/**
|
|
359
|
-
* React hook for accessing the current user's account with selective data extraction and custom equality checking.
|
|
360
|
-
*
|
|
361
|
-
* This hook extends `useAccount` by allowing you to select only specific parts of the account data
|
|
362
|
-
* through a selector function, which helps reduce unnecessary re-renders by narrowing down the
|
|
363
|
-
* returned data. Additionally, you can provide a custom equality function to further optimize
|
|
364
|
-
* performance by controlling when the component should re-render based on the selected data.
|
|
365
|
-
*
|
|
366
|
-
* The hook automatically handles the subscription lifecycle and supports deep loading of nested
|
|
367
|
-
* CoValues through resolve queries, just like `useAccount`.
|
|
368
|
-
*
|
|
369
|
-
* @returns The result of the selector function applied to the loaded account data
|
|
370
|
-
*
|
|
371
|
-
* @example
|
|
372
|
-
* ```tsx
|
|
373
|
-
* // Select only specific fields to reduce re-renders
|
|
374
|
-
* const MyAppAccount = co.account({
|
|
375
|
-
* profile: co.profile(),
|
|
376
|
-
* root: co.map({
|
|
377
|
-
* name: z.string(),
|
|
378
|
-
* email: z.string(),
|
|
379
|
-
* lastLogin: z.date(),
|
|
380
|
-
* }),
|
|
381
|
-
* });
|
|
382
|
-
*
|
|
383
|
-
* function UserProfile({ accountId }: { accountId: string }) {
|
|
384
|
-
* // Only re-render when the profile name changes, not other fields
|
|
385
|
-
* const profileName = useAccountWithSelector(
|
|
386
|
-
* MyAppAccount,
|
|
387
|
-
* {
|
|
388
|
-
* resolve: {
|
|
389
|
-
* profile: true,
|
|
390
|
-
* root: true,
|
|
391
|
-
* },
|
|
392
|
-
* select: (account) => account?.profile?.name ?? "Loading...",
|
|
393
|
-
* }
|
|
394
|
-
* );
|
|
395
|
-
*
|
|
396
|
-
* return <h1>{profileName}</h1>;
|
|
397
|
-
* }
|
|
398
|
-
* ```
|
|
399
|
-
*
|
|
400
|
-
* For more examples, see the [subscription and deep loading](https://jazz.tools/docs/react/using-covalues/subscription-and-loading) documentation.
|
|
401
|
-
*/
|
|
402
|
-
export declare function useAccountWithSelector<A extends AccountClass<Account> | AnyAccountSchema, TSelectorReturn, R extends ResolveQuery<A> = true>(
|
|
403
|
-
/** The account schema to use. Defaults to the base Account schema */
|
|
404
|
-
AccountSchema: A | undefined,
|
|
405
|
-
/** Configuration for the subscription and selection */
|
|
406
|
-
options: {
|
|
407
300
|
/** Resolve query to specify which nested CoValues to load from the account */
|
|
408
301
|
resolve?: ResolveQueryStrict<A, R>;
|
|
409
302
|
/** Select which value to return from the account data */
|
|
410
|
-
select
|
|
303
|
+
select?: (account: MaybeLoaded<Loaded<A, R>>) => TSelectorReturn;
|
|
411
304
|
/** Equality function to determine if the selected value has changed, defaults to `Object.is` */
|
|
412
305
|
equalityFn?: (a: TSelectorReturn, b: TSelectorReturn) => boolean;
|
|
413
306
|
/**
|
|
@@ -431,6 +324,15 @@ options: {
|
|
|
431
324
|
* Returns a function for logging out of the current account.
|
|
432
325
|
*/
|
|
433
326
|
export declare function useLogOut(): () => void;
|
|
327
|
+
/**
|
|
328
|
+
* React hook for accessing the current agent. An agent can either be:
|
|
329
|
+
* - an Authenticated Account, if the user is logged in
|
|
330
|
+
* - an Anonymous Account, if the user didn't log in
|
|
331
|
+
* - or an anonymous agent, if in guest mode
|
|
332
|
+
*
|
|
333
|
+
* The agent can be used as the `loadAs` parameter for load and subscribe methods.
|
|
334
|
+
*/
|
|
335
|
+
export declare function useAgent<A extends AccountClass<Account> | AnyAccountSchema = typeof Account>(): AnonymousJazzAgent | Loaded<A, true>;
|
|
434
336
|
export declare function experimental_useInboxSender<I extends CoValue, O extends CoValue | undefined>(inboxOwnerID: string | undefined): (message: I) => Promise<O extends CoValue ? string : undefined>;
|
|
435
337
|
/**
|
|
436
338
|
* Hook that returns the current connection status to the Jazz sync server.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react-core/hooks.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,oBAAoB,
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/react-core/hooks.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,oBAAoB,EAIpB,kBAAkB,EAClB,eAAe,EACf,MAAM,EACN,WAAW,EAEX,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAIlB,KAAK,gBAAgB,EACtB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,wBAAgB,cAAc,CAAC,GAAG,SAAS,OAAO,0BAUjD;AAED,wBAAgB,qBAAqB,CAAC,GAAG,SAAS,OAAO,iCAaxD;AAED,wBAAgB,oBAAoB,2CAUnC;AAED,wBAAgB,kBAAkB,YAajC;AAED,wBAAgB,sBAAsB,CACpC,CAAC,SAAS,oBAAoB,EAE9B,KAAK,CAAC,CAAC,SAAS,YAAY,CAAC,CAA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