community-jazz-vue 0.19.3 → 0.19.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +20 -0
- package/dist/composables.d.ts +3 -3
- package/dist/index.js +16 -22
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
- package/src/composables.ts +19 -24
- package/src/tests/useCoState.test.ts +71 -1
- package/src/tests/useInboxSender.test.ts +60 -0
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
> community-jazz-vue@0.19.
|
|
2
|
+
> community-jazz-vue@0.19.5 build /home/runner/_work/jazz/jazz/packages/community-jazz-vue
|
|
3
3
|
> pnpm typecheck && rm -rf ./dist && vite build
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> community-jazz-vue@0.19.
|
|
6
|
+
> community-jazz-vue@0.19.5 typecheck /home/runner/_work/jazz/jazz/packages/community-jazz-vue
|
|
7
7
|
> vue-tsc --noEmit
|
|
8
8
|
|
|
9
9
|
[36mvite v6.3.5 [32mbuilding for production...[36m[39m
|
|
@@ -15,7 +15,7 @@ rendering chunks...
|
|
|
15
15
|
computing gzip size...
|
|
16
16
|
[2mdist/[22m[36mtesting.js [39m[1m[2m 1.28 kB[22m[1m[22m[2m │ gzip: 0.54 kB[22m[2m │ map: 1.84 kB[22m
|
|
17
17
|
[2mdist/[22m[36mprovider-CCZVJj45.js [39m[1m[2m 4.15 kB[22m[1m[22m[2m │ gzip: 1.25 kB[22m[2m │ map: 7.94 kB[22m
|
|
18
|
-
[2mdist/[22m[36mindex.js [39m[1m[
|
|
19
|
-
[vite:dts] Declaration files built in
|
|
18
|
+
[2mdist/[22m[36mindex.js [39m[1m[2m20.93 kB[22m[1m[22m[2m │ gzip: 5.16 kB[22m[2m │ map: 37.48 kB[22m
|
|
19
|
+
[vite:dts] Declaration files built in 2437ms.
|
|
20
20
|
|
|
21
|
-
[32m✓ built in 2.
|
|
21
|
+
[32m✓ built in 2.56s[39m
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
1
|
# jazz-react
|
|
2
2
|
|
|
3
|
+
## 0.19.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [343c2e4]
|
|
8
|
+
- cojson@0.19.5
|
|
9
|
+
- jazz-tools@0.19.5
|
|
10
|
+
|
|
11
|
+
## 0.19.4
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [78dfffd]
|
|
16
|
+
- Updated dependencies [de2f8b5]
|
|
17
|
+
- Updated dependencies [763977a]
|
|
18
|
+
- Updated dependencies [e02e14c]
|
|
19
|
+
- Updated dependencies [3aaba61]
|
|
20
|
+
- jazz-tools@0.19.4
|
|
21
|
+
- cojson@0.19.4
|
|
22
|
+
|
|
3
23
|
## 0.19.3
|
|
4
24
|
|
|
5
25
|
### Patch Changes
|
package/dist/composables.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Account, AccountClass, AnonymousJazzAgent, AnyAccountSchema, AuthSecretStorage, CoValue, CoValueClassOrSchema, JazzContextManager, JazzContextType, Loaded, MaybeLoaded, ResolveQuery, ResolveQueryStrict } from 'jazz-tools';
|
|
2
|
-
import { ComputedRef, Ref } from 'vue';
|
|
2
|
+
import { ComputedRef, MaybeRefOrGetter, Ref } from 'vue';
|
|
3
3
|
export declare const logoutHandler: Ref<(() => void) | undefined, (() => void) | undefined>;
|
|
4
4
|
export declare function useJazzContext<Acc extends Account>(): Ref<JazzContextType<Acc>, JazzContextType<Acc>>;
|
|
5
5
|
export declare function useJazzContextManager<Acc extends Account>(): Ref<JazzContextManager<Acc, {}>, JazzContextManager<Acc, {}>>;
|
|
@@ -20,7 +20,7 @@ export declare function useLogOut(): () => void;
|
|
|
20
20
|
* The agent can be used as the `loadAs` parameter for load and subscribe methods.
|
|
21
21
|
*/
|
|
22
22
|
export declare function useAgent<A extends AccountClass<Account> | AnyAccountSchema = typeof Account>(): AnonymousJazzAgent | Loaded<A, true>;
|
|
23
|
-
export declare function useCoState<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = true>(Schema: S, id: string | undefined
|
|
23
|
+
export declare function useCoState<S extends CoValueClassOrSchema, const R extends ResolveQuery<S> = true>(Schema: S, id: MaybeRefOrGetter<string | undefined>, options?: {
|
|
24
24
|
resolve?: ResolveQueryStrict<S, R>;
|
|
25
25
|
}): Ref<MaybeLoaded<Loaded<S, R>>>;
|
|
26
26
|
export declare function useAcceptInvite<S extends CoValueClassOrSchema>({ invitedObjectSchema, onAccept, forValueHint, }: {
|
|
@@ -28,4 +28,4 @@ export declare function useAcceptInvite<S extends CoValueClassOrSchema>({ invite
|
|
|
28
28
|
onAccept: (projectID: string) => void;
|
|
29
29
|
forValueHint?: string;
|
|
30
30
|
}): void;
|
|
31
|
-
export declare function experimental_useInboxSender<I extends CoValue, O extends CoValue | undefined>(inboxOwnerID: string | undefined): (message: I) => Promise<O extends CoValue ? string : undefined>;
|
|
31
|
+
export declare function experimental_useInboxSender<I extends CoValue, O extends CoValue | undefined>(inboxOwnerID: MaybeRefOrGetter<string | undefined>): (message: I) => Promise<O extends CoValue ? string : undefined>;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Account, createUnloadedCoValue, CoValueLoadingState, subscribeToCoValue, coValueClassFromCoValueClassOrSchema, InboxSender, PassphraseAuth, JazzClerkAuth, KvStoreContext, InMemoryKVStore, ImageDefinition } from "jazz-tools";
|
|
2
2
|
import { consumeInviteLinkFromWindowLocation, BrowserPasskeyAuth, LocalStorageKVStore } from "jazz-tools/browser";
|
|
3
3
|
import { createInviteLink, parseInviteLink } from "jazz-tools/browser";
|
|
4
|
-
import { ref, inject, shallowRef, watch, toRaw, onUnmounted, computed, markRaw, onMounted, watchEffect, defineComponent, h, createElementBlock, unref, openBlock, renderSlot, createElementVNode, createCommentVNode, toDisplayString, withModifiers, withDirectives, vModelText, normalizeStyle, normalizeClass } from "vue";
|
|
4
|
+
import { ref, inject, shallowRef, toValue, watch, toRaw, onUnmounted, computed, markRaw, onMounted, watchEffect, defineComponent, h, createElementBlock, unref, openBlock, renderSlot, createElementVNode, createCommentVNode, toDisplayString, withModifiers, withDirectives, vModelText, normalizeStyle, normalizeClass } from "vue";
|
|
5
5
|
import { J as JazzContextSymbol, a as JazzAuthContextSymbol, b as JazzContextManagerSymbol, c as JazzVueProvider } from "./provider-CCZVJj45.js";
|
|
6
6
|
import { d } from "./provider-CCZVJj45.js";
|
|
7
7
|
import { highestResAvailable } from "jazz-tools/media";
|
|
@@ -72,7 +72,7 @@ function useAgent() {
|
|
|
72
72
|
}
|
|
73
73
|
function useCoState(Schema, id, options) {
|
|
74
74
|
const state = shallowRef(
|
|
75
|
-
createUnloadedCoValue(id ?? "", CoValueLoadingState.LOADING)
|
|
75
|
+
createUnloadedCoValue(toValue(id) ?? "", CoValueLoadingState.LOADING)
|
|
76
76
|
);
|
|
77
77
|
const context = useJazzContext();
|
|
78
78
|
if (!context.value) {
|
|
@@ -84,7 +84,7 @@ function useCoState(Schema, id, options) {
|
|
|
84
84
|
state.value = markRaw(value);
|
|
85
85
|
};
|
|
86
86
|
watch(
|
|
87
|
-
[() => id, context],
|
|
87
|
+
[() => toValue(id), context],
|
|
88
88
|
([currentId, currentContext]) => {
|
|
89
89
|
if (unsubscribe) {
|
|
90
90
|
unsubscribe();
|
|
@@ -114,21 +114,11 @@ function useCoState(Schema, id, options) {
|
|
|
114
114
|
{
|
|
115
115
|
resolve: options == null ? void 0 : options.resolve,
|
|
116
116
|
loadAs: safeLoadAsAgent,
|
|
117
|
-
onUnavailable: () => {
|
|
118
|
-
updateState(
|
|
119
|
-
createUnloadedCoValue(
|
|
120
|
-
currentId,
|
|
121
|
-
CoValueLoadingState.UNAVAILABLE
|
|
122
|
-
)
|
|
123
|
-
);
|
|
117
|
+
onUnavailable: (value) => {
|
|
118
|
+
updateState(value);
|
|
124
119
|
},
|
|
125
|
-
onUnauthorized: () => {
|
|
126
|
-
updateState(
|
|
127
|
-
createUnloadedCoValue(
|
|
128
|
-
currentId,
|
|
129
|
-
CoValueLoadingState.UNAUTHORIZED
|
|
130
|
-
)
|
|
131
|
-
);
|
|
120
|
+
onUnauthorized: (value) => {
|
|
121
|
+
updateState(value);
|
|
132
122
|
},
|
|
133
123
|
syncResolution: true
|
|
134
124
|
},
|
|
@@ -208,21 +198,25 @@ function experimental_useInboxSender(inboxOwnerID) {
|
|
|
208
198
|
const me = computed(() => context.value.me);
|
|
209
199
|
const inboxRef = ref(void 0);
|
|
210
200
|
const sendMessage = async (message) => {
|
|
211
|
-
|
|
201
|
+
const resolvedInboxOwnerID = toValue(inboxOwnerID);
|
|
202
|
+
if (!resolvedInboxOwnerID) throw new Error("Inbox owner ID is required");
|
|
212
203
|
if (!inboxRef.value) {
|
|
213
|
-
const inbox2 = InboxSender.load(
|
|
204
|
+
const inbox2 = InboxSender.load(
|
|
205
|
+
resolvedInboxOwnerID,
|
|
206
|
+
toRaw(me.value)
|
|
207
|
+
);
|
|
214
208
|
inboxRef.value = inbox2;
|
|
215
209
|
}
|
|
216
210
|
let inbox = await inboxRef.value;
|
|
217
|
-
if (inbox.owner.id !==
|
|
218
|
-
const req = InboxSender.load(
|
|
211
|
+
if (inbox.owner.id !== resolvedInboxOwnerID) {
|
|
212
|
+
const req = InboxSender.load(resolvedInboxOwnerID, toRaw(me.value));
|
|
219
213
|
inboxRef.value = req;
|
|
220
214
|
inbox = await req;
|
|
221
215
|
}
|
|
222
216
|
return inbox.sendMessage(message);
|
|
223
217
|
};
|
|
224
218
|
watch(
|
|
225
|
-
() => inboxOwnerID,
|
|
219
|
+
() => toValue(inboxOwnerID),
|
|
226
220
|
() => {
|
|
227
221
|
inboxRef.value = void 0;
|
|
228
222
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../src/composables.ts","../src/auth/useIsAuthenticated.ts","../src/auth/usePassphraseAuth.ts","../src/auth/usePasskeyAuth.ts","../src/auth/useClerkAuth.ts","../src/auth/JazzVueProviderWithClerk.ts","../src/auth/PasskeyAuthBasicUI.vue","../src/Image.vue"],"sourcesContent":["import {\n Account,\n AccountClass,\n AnonymousJazzAgent,\n AnyAccountSchema,\n type AuthSecretStorage,\n type CoValue,\n CoValueClassOrSchema,\n InboxSender,\n InstanceOfSchema,\n type JazzAuthContext,\n JazzContextManager,\n type JazzContextType,\n type Loaded,\n type MaybeLoaded,\n CoValueLoadingState,\n type ResolveQuery,\n ResolveQueryStrict,\n coValueClassFromCoValueClassOrSchema,\n subscribeToCoValue,\n createUnloadedCoValue,\n} from \"jazz-tools\";\nimport { consumeInviteLinkFromWindowLocation } from \"jazz-tools/browser\";\nimport {\n type ComputedRef,\n type Ref,\n type ShallowRef,\n computed,\n inject,\n markRaw,\n nextTick,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n toRaw,\n watch,\n} from \"vue\";\n\nimport {\n JazzAuthContextSymbol,\n JazzContextManagerSymbol,\n JazzContextSymbol,\n} from \"./provider.js\";\n\nexport const logoutHandler = ref<() => void>();\n\nfunction getCurrentAccountFromContextManager<Acc extends Account>(\n contextManager: JazzContextManager<Acc, any>,\n) {\n const context = contextManager.getCurrentValue();\n\n if (!context) {\n throw new Error(\"No context found\");\n }\n\n return \"me\" in context ? context.me : context.guest;\n}\n\nexport function useJazzContext<Acc extends Account>(): Ref<\n JazzContextType<Acc>,\n JazzContextType<Acc>\n> {\n const context = inject<Ref<JazzContextType<Acc>>>(JazzContextSymbol);\n if (!context) {\n throw new Error(\"useJazzContext must be used within a JazzProvider\");\n }\n return context;\n}\n\nexport function useJazzContextManager<Acc extends Account>() {\n const context = inject<Ref<JazzContextManager<Acc, {}>>>(\n JazzContextManagerSymbol,\n );\n\n if (!context?.value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this hook.\",\n );\n }\n\n return context;\n}\n\nexport function useAuthSecretStorage() {\n const context = inject<AuthSecretStorage>(JazzAuthContextSymbol);\n if (!context) {\n throw new Error(\"useAuthSecretStorage must be used within a JazzProvider\");\n }\n return context;\n}\n\nexport function useAccount<\n A extends AccountClass<Account> | AnyAccountSchema = typeof Account,\n R extends ResolveQuery<A> = true,\n>(\n AccountSchema: A = Account as unknown as A,\n options?: {\n resolve?: ResolveQueryStrict<A, R>;\n },\n): ComputedRef<MaybeLoaded<Loaded<A, R>>> {\n const context = useJazzContext();\n\n if (!context.value) {\n throw new Error(\"useAccount must be used within a JazzProvider\");\n }\n\n // Handle guest mode - return null for the account data\n if (!(\"me\" in context.value)) {\n return computed(() => null) as any;\n }\n\n const contextMe = context.value.me as InstanceOfSchema<A>;\n\n const me = useCoState(\n AccountSchema as any,\n toRaw(contextMe).$jazz.id,\n options as any,\n );\n\n return computed(() => {\n const value =\n options?.resolve === undefined ? me.value || contextMe : me.value;\n return value ? markRaw(value) : value;\n }) as any;\n}\n\n/**\n * Returns a function for logging out the current account.\n */\nexport function useLogOut(): () => void {\n const context = useJazzContext();\n if (!context.value) {\n throw new Error(\"useLogOut must be used within a JazzProvider\");\n }\n return context.value.logOut;\n}\n\n/**\n * Hook for accessing the current agent. An agent can either be:\n * - an Authenticated Account, if the user is logged in\n * - an Anonymous Account, if the user didn't log in\n * - or an anonymous agent, if in guest mode\n *\n * The agent can be used as the `loadAs` parameter for load and subscribe methods.\n */\nexport function useAgent<\n A extends AccountClass<Account> | AnyAccountSchema = typeof Account,\n>(): AnonymousJazzAgent | Loaded<A, true> {\n const contextManager = useJazzContextManager<InstanceOfSchema<A>>();\n const agent = getCurrentAccountFromContextManager(contextManager.value);\n return agent as AnonymousJazzAgent | Loaded<A, true>;\n}\n\nexport function useCoState<\n S extends CoValueClassOrSchema,\n const R extends ResolveQuery<S> = true,\n>(\n Schema: S,\n id: string | undefined,\n options?: { resolve?: ResolveQueryStrict<S, R> },\n): Ref<MaybeLoaded<Loaded<S, R>>> {\n const state: ShallowRef<MaybeLoaded<Loaded<S, R>>> = shallowRef(\n createUnloadedCoValue(id ?? \"\", CoValueLoadingState.LOADING),\n );\n const context = useJazzContext();\n\n if (!context.value) {\n throw new Error(\"useCoState must be used within a JazzProvider\");\n }\n\n let unsubscribe: (() => void) | undefined;\n\n const updateState = (value: MaybeLoaded<Loaded<S, R>>) => {\n if (shouldSkipUpdate(value, state.value)) return;\n // Use markRaw to prevent Vue from making Jazz objects reactive\n // but still allow property access and mutations\n state.value = markRaw(value);\n };\n\n watch(\n [() => id, context],\n ([currentId, currentContext]) => {\n if (unsubscribe) {\n unsubscribe();\n unsubscribe = undefined;\n }\n\n if (!currentId || !currentContext) {\n updateState(\n createUnloadedCoValue(\n currentId ?? \"\",\n CoValueLoadingState.UNAVAILABLE,\n ),\n );\n return;\n }\n\n const loadAsAgent =\n \"me\" in currentContext ? currentContext.me : currentContext.guest;\n if (!loadAsAgent) {\n updateState(\n createUnloadedCoValue(currentId, CoValueLoadingState.UNAVAILABLE),\n );\n return;\n }\n\n const safeLoadAsAgent = toRaw(loadAsAgent);\n\n try {\n unsubscribe = subscribeToCoValue(\n coValueClassFromCoValueClassOrSchema(Schema),\n currentId as any,\n {\n resolve: options?.resolve as any,\n loadAs: safeLoadAsAgent,\n onUnavailable: () => {\n updateState(\n createUnloadedCoValue(\n currentId,\n CoValueLoadingState.UNAVAILABLE,\n ),\n );\n },\n onUnauthorized: () => {\n updateState(\n createUnloadedCoValue(\n currentId,\n CoValueLoadingState.UNAUTHORIZED,\n ),\n );\n },\n syncResolution: true,\n },\n (value: any) => {\n updateState(value);\n },\n );\n } catch (error) {\n console.error(\"Error in useCoState subscription:\", error);\n updateState(\n createUnloadedCoValue(currentId, CoValueLoadingState.UNAVAILABLE),\n );\n }\n },\n { immediate: true },\n );\n\n onUnmounted(() => {\n if (unsubscribe) {\n unsubscribe();\n unsubscribe = undefined;\n }\n });\n\n return state;\n}\n\nexport function useAcceptInvite<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 (!context.value) {\n throw new Error(\"useAcceptInvite must be used within a JazzProvider\");\n }\n\n if (!(\"me\" in context.value)) {\n throw new Error(\n \"useAcceptInvite can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n const handleInvite = () => {\n const result = consumeInviteLinkFromWindowLocation({\n as: toRaw((context.value as JazzAuthContext<Account>).me),\n invitedObjectSchema,\n forValueHint,\n });\n\n result\n .then((res) => res && onAccept(res.valueID))\n .catch((e) => {\n console.error(\"Failed to accept invite\", e);\n });\n };\n\n onMounted(() => {\n handleInvite();\n window.addEventListener(\"hashchange\", handleInvite);\n });\n\n onUnmounted(() => {\n window.removeEventListener(\"hashchange\", handleInvite);\n });\n\n watch(\n () => onAccept,\n (newOnAccept, oldOnAccept) => {\n if (newOnAccept !== oldOnAccept) {\n handleInvite();\n }\n },\n );\n}\n\nexport function experimental_useInboxSender<\n I extends CoValue,\n O extends CoValue | undefined,\n>(inboxOwnerID: string | undefined) {\n const context = useJazzContext();\n\n if (!context.value) {\n throw new Error(\n \"experimental_useInboxSender must be used within a JazzProvider\",\n );\n }\n\n if (!(\"me\" in context.value)) {\n throw new Error(\n \"experimental_useInboxSender can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n const me = computed(() => (context.value as JazzAuthContext<Account>).me);\n const inboxRef = ref<Promise<InboxSender<I, O>> | undefined>(undefined);\n\n const sendMessage = async (message: I) => {\n if (!inboxOwnerID) throw new Error(\"Inbox owner ID is required\");\n\n if (!inboxRef.value) {\n const inbox = InboxSender.load<I, O>(inboxOwnerID, toRaw(me.value));\n inboxRef.value = inbox;\n }\n\n let inbox = await inboxRef.value;\n\n if (inbox.owner.id !== inboxOwnerID) {\n const req = InboxSender.load<I, O>(inboxOwnerID, toRaw(me.value));\n inboxRef.value = req;\n inbox = await req;\n }\n\n return inbox.sendMessage(message);\n };\n\n watch(\n () => inboxOwnerID,\n () => {\n inboxRef.value = undefined;\n },\n );\n\n return sendMessage;\n}\n\n// useAccountOrGuest has been removed in v0.15.4 to match React library.\n// It has been merged into useAccount which now handles both authenticated and guest scenarios.\n// This change maintains 1:1 API compatibility with the React Jazz library.\n// If you were using useAccountOrGuest, please migrate to useAccount.\n\nfunction shouldSkipUpdate(\n newValue: MaybeLoaded<CoValue>,\n previousValue: MaybeLoaded<CoValue>,\n) {\n if (previousValue === newValue) return true;\n // Avoid re-renders if the value is not loaded and didn't change\n return (\n previousValue.$jazz.id === newValue.$jazz.id &&\n !previousValue.$isLoaded &&\n !newValue.$isLoaded &&\n previousValue.$jazz.loadingState === newValue.$jazz.loadingState\n );\n}\n","import { onUnmounted, ref } from \"vue\";\nimport { useAuthSecretStorage } from \"../composables.js\";\n\nexport function useIsAuthenticated() {\n const authSecretStorage = useAuthSecretStorage();\n const isAuthenticated = ref(authSecretStorage.isAuthenticated);\n\n const handleUpdate = (newIsAuthenticated: boolean) => {\n isAuthenticated.value = newIsAuthenticated;\n };\n\n // Set up the listener immediately, not waiting for onMounted\n // This ensures we catch auth state changes that happen before mounting\n const cleanup = authSecretStorage.onUpdate(handleUpdate);\n\n onUnmounted(() => {\n cleanup();\n });\n\n return isAuthenticated;\n}\n","import { PassphraseAuth } from \"jazz-tools\";\nimport { computed, markRaw, ref, watchEffect } from \"vue\";\nimport { useAuthSecretStorage, useJazzContext } from \"../composables.js\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated.js\";\n\n/**\n * `usePassphraseAuth` composable provides a `JazzAuth` object for passphrase authentication.\n *\n * @example\n * ```ts\n * const auth = usePassphraseAuth({ wordlist });\n * ```\n *\n * @category Auth Providers\n */\nexport function usePassphraseAuth({ wordlist }: { wordlist: string[] }) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n const isAuthenticated = useIsAuthenticated();\n\n if (\"guest\" in context.value) {\n throw new Error(\"Passphrase auth is not supported in guest mode\");\n }\n\n const authMethod = computed(() => {\n return markRaw(\n new PassphraseAuth(\n context.value.node.crypto,\n context.value.authenticate,\n context.value.register,\n authSecretStorage,\n wordlist,\n ),\n );\n });\n\n const passphrase = ref(authMethod.value.passphrase);\n\n watchEffect((onCleanup) => {\n authMethod.value.loadCurrentAccountPassphrase();\n\n const unsubscribe = authMethod.value.subscribe(() => {\n passphrase.value = authMethod.value.passphrase;\n });\n\n onCleanup(unsubscribe);\n });\n\n return computed(() => ({\n state: isAuthenticated.value ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.value.logIn,\n signUp: authMethod.value.signUp,\n registerNewAccount: authMethod.value.registerNewAccount,\n generateRandomPassphrase: authMethod.value.generateRandomPassphrase,\n passphrase: passphrase.value,\n }));\n}\n","import { BrowserPasskeyAuth } from \"jazz-tools/browser\";\nimport { computed, markRaw } from \"vue\";\nimport { useAuthSecretStorage, useJazzContext } from \"../composables.js\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated.js\";\n\n/**\n * `usePasskeyAuth` composable provides a `JazzAuth` object for passkey authentication.\n *\n * @example\n * ```ts\n * const auth = usePasskeyAuth({ appName, appHostname });\n * ```\n *\n * @category Auth Providers\n */\nexport function usePasskeyAuth({\n appName,\n appHostname,\n}: {\n appName: string;\n appHostname?: string;\n}) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n const isAuthenticated = useIsAuthenticated();\n\n if (\"guest\" in context.value) {\n throw new Error(\"Passkey auth is not supported in guest mode\");\n }\n\n const authMethod = computed(() => {\n return markRaw(\n new BrowserPasskeyAuth(\n context.value.node.crypto,\n context.value.authenticate,\n authSecretStorage,\n appName,\n appHostname,\n ),\n );\n });\n\n return computed(() => ({\n state: isAuthenticated.value ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.value.logIn,\n signUp: authMethod.value.signUp,\n }));\n}\n","import { JazzClerkAuth, type MinimalClerkClient } from \"jazz-tools\";\nimport { computed, markRaw, onMounted, onUnmounted } from \"vue\";\nimport { useAuthSecretStorage, useJazzContext } from \"../composables.js\";\n\nexport function useClerkAuth(clerk: MinimalClerkClient) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n\n if (\"guest\" in context.value) {\n throw new Error(\"Clerk auth is not supported in guest mode\");\n }\n\n // Create auth method similar to React's useMemo pattern\n const authMethod = computed(() => {\n return markRaw(\n new JazzClerkAuth(\n context.value.authenticate,\n context.value.logOut,\n authSecretStorage,\n ),\n );\n });\n\n onMounted(() => {\n const cleanup = authMethod.value.registerListener(clerk) as\n | (() => void)\n | void;\n\n onUnmounted(() => {\n // Clerk's addListener returns a cleanup function, but the type says void\n // Handle both cases for type safety\n if (typeof cleanup === \"function\") {\n cleanup();\n }\n });\n });\n\n return authMethod.value;\n}\n","import type {\n Account,\n AccountClass,\n AnyAccountSchema,\n CoValueFromRaw,\n SyncConfig,\n} from \"jazz-tools\";\nimport {\n InMemoryKVStore,\n JazzClerkAuth,\n KvStoreContext,\n type MinimalClerkClient,\n} from \"jazz-tools\";\nimport { LocalStorageKVStore } from \"jazz-tools/browser\";\nimport { type PropType, defineComponent, h, onMounted, ref } from \"vue\";\nimport { JazzVueProvider } from \"../provider.js\";\nimport { useClerkAuth } from \"./useClerkAuth.js\";\n\nfunction setupKvStore() {\n KvStoreContext.getInstance().initialize(\n typeof window === \"undefined\"\n ? new InMemoryKVStore()\n : new LocalStorageKVStore(),\n );\n}\n\nconst RegisterClerkAuth = defineComponent({\n name: \"RegisterClerkAuth\",\n props: {\n clerk: {\n type: Object as PropType<MinimalClerkClient>,\n required: true,\n },\n },\n setup(props, { slots }) {\n useClerkAuth(props.clerk);\n return () => slots.default?.();\n },\n});\n\nexport const JazzVueProviderWithClerk = defineComponent({\n name: \"JazzVueProviderWithClerk\",\n props: {\n clerk: {\n type: Object as PropType<MinimalClerkClient>,\n required: true,\n },\n AccountSchema: {\n type: [Function, Object] as unknown as PropType<\n (AccountClass<Account> & CoValueFromRaw<Account>) | AnyAccountSchema\n >,\n required: false,\n },\n guestMode: {\n type: Boolean,\n default: false,\n },\n sync: {\n type: Object as PropType<SyncConfig>,\n required: true,\n },\n storage: {\n type: String as PropType<\"indexedDB\">,\n default: undefined,\n },\n defaultProfileName: {\n type: String,\n required: false,\n },\n onLogOut: {\n type: Function as PropType<() => void>,\n required: false,\n },\n onAnonymousAccountDiscarded: {\n type: Function as PropType<(anonymousAccount: Account) => Promise<void>>,\n required: false,\n },\n enableSSR: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n const isLoaded = ref(false);\n\n onMounted(async () => {\n try {\n setupKvStore();\n await JazzClerkAuth.initializeAuth(props.clerk);\n isLoaded.value = true;\n } catch (error) {\n console.error(\"Jazz + Clerk initialization error:\", error);\n // Still render even if auth init fails\n isLoaded.value = true;\n }\n });\n\n return () => {\n if (!isLoaded.value) {\n return null;\n }\n\n // Destructure props to exclude 'clerk' which JazzVueProvider doesn't accept\n const { clerk, ...jazzProviderProps } = props;\n\n return h(\n JazzVueProvider,\n {\n ...jazzProviderProps,\n logOutReplacement: clerk.signOut,\n },\n {\n default: () =>\n h(\n RegisterClerkAuth,\n { clerk },\n { default: () => slots.default?.() },\n ),\n },\n );\n };\n },\n});\n","<template>\n <div v-if=\"auth.state === 'signedIn'\">\n <slot />\n </div>\n <div v-else :style=\"containerStyle\">\n <div :style=\"cardStyle\">\n <h1 :style=\"headingStyle\">{{ appName }}</h1>\n \n <div v-if=\"error\" :style=\"errorStyle\">\n {{ error }}\n </div>\n\n <form @submit.prevent=\"handleSignUp\" :style=\"formStyle\">\n <input\n v-model=\"username\"\n type=\"text\"\n placeholder=\"Display name\"\n autocomplete=\"name\"\n :style=\"inputStyle\"\n />\n <button type=\"submit\" :style=\"primaryButtonStyle\">\n Sign up\n </button>\n </form>\n\n <button @click=\"handleLogIn\" :style=\"secondaryButtonStyle\">\n Log in with existing account\n </button>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nimport { usePasskeyAuth } from \"./usePasskeyAuth.js\";\n\ninterface Props {\n appName: string;\n appHostname?: string;\n}\n\nconst props = defineProps<Props>();\n\nconst username = ref(\"\");\nconst error = ref<string | null>(null);\n\nconst auth = usePasskeyAuth({\n appName: props.appName,\n appHostname: props.appHostname,\n});\n\nfunction handleError(err: Error) {\n if (err.cause instanceof Error) {\n error.value = err.cause.message;\n } else {\n error.value = err.message;\n }\n}\n\nconst handleSignUp = async () => {\n if (!username.value.trim()) {\n error.value = \"Name is required\";\n return;\n }\n\n error.value = null;\n try {\n await auth.value.signUp(username.value.trim());\n } catch (err) {\n handleError(err as Error);\n }\n};\n\nconst handleLogIn = async () => {\n error.value = null;\n try {\n await auth.value.logIn();\n } catch (err) {\n handleError(err as Error);\n }\n};\n\n// Styles (matching React version)\nconst containerStyle = {\n width: \"100vw\",\n height: \"100vh\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: \"#f3f4f6\",\n padding: \"1rem\",\n};\n\nconst cardStyle = {\n backgroundColor: \"white\",\n padding: \"2rem\",\n borderRadius: \"0.5rem\",\n boxShadow: \"0 10px 15px -3px rgba(0, 0, 0, 0.1)\",\n width: \"100%\",\n maxWidth: \"18rem\",\n display: \"flex\",\n flexDirection: \"column\" as const,\n gap: \"2rem\",\n};\n\nconst headingStyle = {\n fontSize: \"1.5rem\",\n fontWeight: \"bold\",\n textAlign: \"center\" as const,\n margin: \"0\",\n};\n\nconst errorStyle = {\n color: \"red\",\n fontSize: \"0.875rem\",\n textAlign: \"center\" as const,\n};\n\nconst formStyle = {\n display: \"flex\",\n flexDirection: \"column\" as const,\n gap: \"0.5rem\",\n};\n\nconst inputStyle = {\n padding: \"0.75rem\",\n border: \"1px solid #d1d5db\",\n borderRadius: \"0.375rem\",\n fontSize: \"1rem\",\n};\n\nconst primaryButtonStyle = {\n backgroundColor: \"#3b82f6\",\n color: \"white\",\n padding: \"0.75rem 1rem\",\n border: \"none\",\n borderRadius: \"0.375rem\",\n cursor: \"pointer\",\n fontSize: \"1rem\",\n fontWeight: \"500\",\n};\n\nconst secondaryButtonStyle = {\n backgroundColor: \"#e5e7eb\",\n color: \"#374151\",\n padding: \"0.75rem 1rem\",\n border: \"none\",\n borderRadius: \"0.375rem\",\n cursor: \"pointer\",\n fontSize: \"1rem\",\n fontWeight: \"500\",\n};\n</script>\n","<script setup lang=\"ts\">\nimport { ImageDefinition } from \"jazz-tools\";\nimport { highestResAvailable } from \"jazz-tools/media\";\nimport { onUnmounted, ref, watch, computed } from \"vue\";\nimport { useCoState } from \"./composables.js\";\n\nexport interface ImageProps {\n /** The ID of the ImageDefinition to display */\n imageId: string;\n /**\n * The desired width of the image. Can be a number in pixels or \"original\" to use the image's original width.\n * When set to a number, the component will select the best available resolution and maintain aspect ratio.\n */\n width?: number | \"original\";\n /**\n * The desired height of the image. Can be a number in pixels or \"original\" to use the image's original height.\n * When set to a number, the component will select the best available resolution and maintain aspect ratio.\n */\n height?: number | \"original\";\n /** Alt text for the image */\n alt?: string;\n /** CSS classes to apply to the image */\n classNames?: string;\n /** CSS styles to apply to the image */\n style?: string | Record<string, string>;\n /** Loading strategy for the image */\n loading?: \"lazy\" | \"eager\";\n}\n\nconst props = withDefaults(defineProps<ImageProps>(), {\n loading: \"eager\",\n});\n\nconst image = useCoState(ImageDefinition, props.imageId, {});\nlet lastBestImage: [string, string] | null = null;\n\n/**\n * For lazy loading, we use the browser's strategy for images with loading=\"lazy\".\n * We use an empty image, and when the browser triggers the load event, we load the best available image.\n */\nconst waitingLazyLoading = ref(props.loading === \"lazy\");\nconst lazyPlaceholder = computed(() =>\n waitingLazyLoading.value ? URL.createObjectURL(emptyPixelBlob) : undefined,\n);\n\nconst dimensions = computed(() => {\n const originalSize = image.value.$isLoaded\n ? image.value.originalSize\n : undefined;\n const originalWidth = originalSize?.[0];\n const originalHeight = originalSize?.[1];\n\n // Both width and height are \"original\"\n if (props.width === \"original\" && props.height === \"original\") {\n return { width: originalWidth, height: originalHeight };\n }\n\n // Width is \"original\", height is a number\n if (props.width === \"original\" && typeof props.height === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width: Math.round((props.height * originalWidth) / originalHeight),\n height: props.height,\n };\n }\n return { width: undefined, height: props.height };\n }\n\n // Height is \"original\", width is a number\n if (props.height === \"original\" && typeof props.width === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width: props.width,\n height: Math.round((props.width * originalHeight) / originalWidth),\n };\n }\n return { width: props.width, height: undefined };\n }\n\n // In all other cases, use the property value:\n return {\n width: props.width === \"original\" ? originalWidth : props.width,\n height: props.height === \"original\" ? originalHeight : props.height,\n };\n});\n\nconst src = computed(() => {\n if (waitingLazyLoading.value) {\n return lazyPlaceholder.value;\n }\n\n if (!image.value.$isLoaded) return undefined;\n\n const bestImage = highestResAvailable(\n image.value,\n dimensions.value.width || dimensions.value.height || 9999,\n dimensions.value.height || dimensions.value.width || 9999,\n );\n\n if (!bestImage) return image.value.placeholderDataURL;\n if (lastBestImage?.[0] === bestImage.image.$jazz.id)\n return lastBestImage?.[1];\n\n const blob = bestImage.image.toBlob();\n\n if (blob) {\n const url = URL.createObjectURL(blob);\n revokeObjectURL(lastBestImage?.[1]);\n lastBestImage = [bestImage.image.$jazz.id, url];\n return url;\n }\n\n return image.value.placeholderDataURL;\n});\n\nconst onThresholdReached = () => {\n waitingLazyLoading.value = false;\n};\n\n// Cleanup object URL on component destroy\nonUnmounted(() => {\n revokeObjectURL(lastBestImage?.[1]);\n});\n\nfunction revokeObjectURL(url: string | undefined) {\n if (url && url.startsWith(\"blob:\")) {\n URL.revokeObjectURL(url);\n }\n}\n\nconst emptyPixelBlob = new Blob(\n [\n Uint8Array.from(\n atob(\n \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=\",\n ),\n (c) => c.charCodeAt(0),\n ),\n ],\n { type: \"image/png\" },\n);\n</script>\n\n<template>\n <img\n :src=\"src\"\n :width=\"dimensions.width\"\n :height=\"dimensions.height\"\n :alt=\"alt\"\n :class=\"classNames\"\n :style=\"style\"\n :loading=\"loading\"\n @load=\"waitingLazyLoading ? onThresholdReached() : undefined\"\n />\n</template>\n"],"names":["inbox"],"mappings":";;;;;;;;AA6CO,MAAM,gBAAgB,IAAgB;AAE7C,SAAS,oCACP,gBACA;AACM,QAAA,UAAU,eAAe,gBAAgB;AAE/C,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,kBAAkB;AAAA,EAAA;AAGpC,SAAO,QAAQ,UAAU,QAAQ,KAAK,QAAQ;AAChD;AAEO,SAAS,iBAGd;AACM,QAAA,UAAU,OAAkC,iBAAiB;AACnE,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,mDAAmD;AAAA,EAAA;AAE9D,SAAA;AACT;AAEO,SAAS,wBAA6C;AAC3D,QAAM,UAAU;AAAA,IACd;AAAA,EACF;AAEI,MAAA,EAAC,mCAAS,QAAO;AACnB,UAAM,IAAI;AAAA,MACR;AAAA,IACF;AAAA,EAAA;AAGK,SAAA;AACT;AAEO,SAAS,uBAAuB;AAC/B,QAAA,UAAU,OAA0B,qBAAqB;AAC/D,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,yDAAyD;AAAA,EAAA;AAEpE,SAAA;AACT;AAEgB,SAAA,WAId,gBAAmB,SACnB,SAGwC;AACxC,QAAM,UAAU,eAAe;AAE3B,MAAA,CAAC,QAAQ,OAAO;AACZ,UAAA,IAAI,MAAM,+CAA+C;AAAA,EAAA;AAI7D,MAAA,EAAE,QAAQ,QAAQ,QAAQ;AACrB,WAAA,SAAS,MAAM,IAAI;AAAA,EAAA;AAGtB,QAAA,YAAY,QAAQ,MAAM;AAEhC,QAAM,KAAK;AAAA,IACT;AAAA,IACA,MAAM,SAAS,EAAE,MAAM;AAAA,IACvB;AAAA,EACF;AAEA,SAAO,SAAS,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AEpC,UAAI,MAAM;AACF,cAAA,MAAM,IAAI,gBAAgB,IAAI;AACpB,wBAAA,+CAAgB,EAAE;AAClC,wBAAgB,CAAC,UAAU,MAAM,MAAM,IAAI,GAAG;AACvC,eAAA;AAAA,MAAA;AAGT,aAAO,MAAM,MAAM;AAAA,IAAA,CACpB;AAED,UAAM,qBAAqB,MAAM;AAC/B,yBAAmB,QAAQ;AAAA,IAC7B;AAGA,gBAAY,MAAM;AACA,sBAAA,+CAAgB,EAAE;AAAA,IAAA,CACnC;AAED,aAAS,gBAAgB,KAAyB;AAChD,UAAI,OAAO,IAAI,WAAW,OAAO,GAAG;AAClC,YAAI,gBAAgB,GAAG;AAAA,MAAA;AAAA,IACzB;AAGF,UAAM,iBAAiB,IAAI;AAAA,MACzB;AAAA,QACE,WAAW;AAAA,UACT;AAAA,YACE;AAAA,UACF;AAAA,UACA,CAAC,MAAM,EAAE,WAAW,CAAC;AAAA,QAAA;AAAA,MAEzB;AAAA,MACA,EAAE,MAAM,YAAY;AAAA,IACtB;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/composables.ts","../src/auth/useIsAuthenticated.ts","../src/auth/usePassphraseAuth.ts","../src/auth/usePasskeyAuth.ts","../src/auth/useClerkAuth.ts","../src/auth/JazzVueProviderWithClerk.ts","../src/auth/PasskeyAuthBasicUI.vue","../src/Image.vue"],"sourcesContent":["import {\n Account,\n AccountClass,\n AnonymousJazzAgent,\n AnyAccountSchema,\n type AuthSecretStorage,\n type CoValue,\n CoValueClassOrSchema,\n InboxSender,\n InstanceOfSchema,\n type JazzAuthContext,\n JazzContextManager,\n type JazzContextType,\n type Loaded,\n type MaybeLoaded,\n CoValueLoadingState,\n type ResolveQuery,\n ResolveQueryStrict,\n coValueClassFromCoValueClassOrSchema,\n subscribeToCoValue,\n createUnloadedCoValue,\n} from \"jazz-tools\";\nimport { consumeInviteLinkFromWindowLocation } from \"jazz-tools/browser\";\nimport {\n type ComputedRef,\n type MaybeRefOrGetter,\n type Ref,\n type ShallowRef,\n computed,\n inject,\n markRaw,\n onMounted,\n onUnmounted,\n ref,\n shallowRef,\n toRaw,\n toValue,\n watch,\n} from \"vue\";\n\nimport {\n JazzAuthContextSymbol,\n JazzContextManagerSymbol,\n JazzContextSymbol,\n} from \"./provider.js\";\n\nexport const logoutHandler = ref<() => void>();\n\nfunction getCurrentAccountFromContextManager<Acc extends Account>(\n contextManager: JazzContextManager<Acc, any>,\n) {\n const context = contextManager.getCurrentValue();\n\n if (!context) {\n throw new Error(\"No context found\");\n }\n\n return \"me\" in context ? context.me : context.guest;\n}\n\nexport function useJazzContext<Acc extends Account>(): Ref<\n JazzContextType<Acc>,\n JazzContextType<Acc>\n> {\n const context = inject<Ref<JazzContextType<Acc>>>(JazzContextSymbol);\n if (!context) {\n throw new Error(\"useJazzContext must be used within a JazzProvider\");\n }\n return context;\n}\n\nexport function useJazzContextManager<Acc extends Account>() {\n const context = inject<Ref<JazzContextManager<Acc, {}>>>(\n JazzContextManagerSymbol,\n );\n\n if (!context?.value) {\n throw new Error(\n \"You need to set up a JazzProvider on top of your app to use this hook.\",\n );\n }\n\n return context;\n}\n\nexport function useAuthSecretStorage() {\n const context = inject<AuthSecretStorage>(JazzAuthContextSymbol);\n if (!context) {\n throw new Error(\"useAuthSecretStorage must be used within a JazzProvider\");\n }\n return context;\n}\n\nexport function useAccount<\n A extends AccountClass<Account> | AnyAccountSchema = typeof Account,\n R extends ResolveQuery<A> = true,\n>(\n AccountSchema: A = Account as unknown as A,\n options?: {\n resolve?: ResolveQueryStrict<A, R>;\n },\n): ComputedRef<MaybeLoaded<Loaded<A, R>>> {\n const context = useJazzContext();\n\n if (!context.value) {\n throw new Error(\"useAccount must be used within a JazzProvider\");\n }\n\n // Handle guest mode - return null for the account data\n if (!(\"me\" in context.value)) {\n return computed(() => null) as any;\n }\n\n const contextMe = context.value.me as InstanceOfSchema<A>;\n\n const me = useCoState(\n AccountSchema as any,\n toRaw(contextMe).$jazz.id,\n options as any,\n );\n\n return computed(() => {\n const value =\n options?.resolve === undefined ? me.value || contextMe : me.value;\n return value ? markRaw(value) : value;\n }) as any;\n}\n\n/**\n * Returns a function for logging out the current account.\n */\nexport function useLogOut(): () => void {\n const context = useJazzContext();\n if (!context.value) {\n throw new Error(\"useLogOut must be used within a JazzProvider\");\n }\n return context.value.logOut;\n}\n\n/**\n * Hook for accessing the current agent. An agent can either be:\n * - an Authenticated Account, if the user is logged in\n * - an Anonymous Account, if the user didn't log in\n * - or an anonymous agent, if in guest mode\n *\n * The agent can be used as the `loadAs` parameter for load and subscribe methods.\n */\nexport function useAgent<\n A extends AccountClass<Account> | AnyAccountSchema = typeof Account,\n>(): AnonymousJazzAgent | Loaded<A, true> {\n const contextManager = useJazzContextManager<InstanceOfSchema<A>>();\n const agent = getCurrentAccountFromContextManager(contextManager.value);\n return agent as AnonymousJazzAgent | Loaded<A, true>;\n}\n\nexport function useCoState<\n S extends CoValueClassOrSchema,\n const R extends ResolveQuery<S> = true,\n>(\n Schema: S,\n id: MaybeRefOrGetter<string | undefined>,\n options?: { resolve?: ResolveQueryStrict<S, R> },\n): Ref<MaybeLoaded<Loaded<S, R>>> {\n const state: ShallowRef<MaybeLoaded<Loaded<S, R>>> = shallowRef(\n createUnloadedCoValue(toValue(id) ?? \"\", CoValueLoadingState.LOADING),\n );\n const context = useJazzContext();\n\n if (!context.value) {\n throw new Error(\"useCoState must be used within a JazzProvider\");\n }\n\n let unsubscribe: (() => void) | undefined;\n\n const updateState = (value: MaybeLoaded<Loaded<S, R>>) => {\n if (shouldSkipUpdate(value, state.value)) return;\n // Use markRaw to prevent Vue from making Jazz objects reactive\n // but still allow property access and mutations\n state.value = markRaw(value);\n };\n\n watch(\n [() => toValue(id), context],\n ([currentId, currentContext]) => {\n if (unsubscribe) {\n unsubscribe();\n unsubscribe = undefined;\n }\n\n if (!currentId || !currentContext) {\n updateState(\n createUnloadedCoValue(\n currentId ?? \"\",\n CoValueLoadingState.UNAVAILABLE,\n ),\n );\n return;\n }\n\n const loadAsAgent =\n \"me\" in currentContext ? currentContext.me : currentContext.guest;\n if (!loadAsAgent) {\n updateState(\n createUnloadedCoValue(currentId, CoValueLoadingState.UNAVAILABLE),\n );\n return;\n }\n\n const safeLoadAsAgent = toRaw(loadAsAgent);\n\n try {\n unsubscribe = subscribeToCoValue(\n coValueClassFromCoValueClassOrSchema(Schema),\n currentId as any,\n {\n resolve: options?.resolve as any,\n loadAs: safeLoadAsAgent,\n onUnavailable: (value) => {\n updateState(value);\n },\n onUnauthorized: (value) => {\n updateState(value);\n },\n syncResolution: true,\n },\n (value: any) => {\n updateState(value);\n },\n );\n } catch (error) {\n console.error(\"Error in useCoState subscription:\", error);\n updateState(\n createUnloadedCoValue(currentId, CoValueLoadingState.UNAVAILABLE),\n );\n }\n },\n { immediate: true },\n );\n\n onUnmounted(() => {\n if (unsubscribe) {\n unsubscribe();\n unsubscribe = undefined;\n }\n });\n\n return state;\n}\n\nexport function useAcceptInvite<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 (!context.value) {\n throw new Error(\"useAcceptInvite must be used within a JazzProvider\");\n }\n\n if (!(\"me\" in context.value)) {\n throw new Error(\n \"useAcceptInvite can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n const handleInvite = () => {\n const result = consumeInviteLinkFromWindowLocation({\n as: toRaw((context.value as JazzAuthContext<Account>).me),\n invitedObjectSchema,\n forValueHint,\n });\n\n result\n .then((res) => res && onAccept(res.valueID))\n .catch((e) => {\n console.error(\"Failed to accept invite\", e);\n });\n };\n\n onMounted(() => {\n handleInvite();\n window.addEventListener(\"hashchange\", handleInvite);\n });\n\n onUnmounted(() => {\n window.removeEventListener(\"hashchange\", handleInvite);\n });\n\n watch(\n () => onAccept,\n (newOnAccept, oldOnAccept) => {\n if (newOnAccept !== oldOnAccept) {\n handleInvite();\n }\n },\n );\n}\n\nexport function experimental_useInboxSender<\n I extends CoValue,\n O extends CoValue | undefined,\n>(inboxOwnerID: MaybeRefOrGetter<string | undefined>) {\n const context = useJazzContext();\n\n if (!context.value) {\n throw new Error(\n \"experimental_useInboxSender must be used within a JazzProvider\",\n );\n }\n\n if (!(\"me\" in context.value)) {\n throw new Error(\n \"experimental_useInboxSender can't be used in a JazzProvider with auth === 'guest'.\",\n );\n }\n\n const me = computed(() => (context.value as JazzAuthContext<Account>).me);\n const inboxRef = ref<Promise<InboxSender<I, O>> | undefined>(undefined);\n\n const sendMessage = async (message: I) => {\n const resolvedInboxOwnerID = toValue(inboxOwnerID);\n if (!resolvedInboxOwnerID) throw new Error(\"Inbox owner ID is required\");\n\n if (!inboxRef.value) {\n const inbox = InboxSender.load<I, O>(\n resolvedInboxOwnerID,\n toRaw(me.value),\n );\n inboxRef.value = inbox;\n }\n\n let inbox = await inboxRef.value;\n\n if (inbox.owner.id !== resolvedInboxOwnerID) {\n const req = InboxSender.load<I, O>(resolvedInboxOwnerID, toRaw(me.value));\n inboxRef.value = req;\n inbox = await req;\n }\n\n return inbox.sendMessage(message);\n };\n\n watch(\n () => toValue(inboxOwnerID),\n () => {\n inboxRef.value = undefined;\n },\n );\n\n return sendMessage;\n}\n\n// useAccountOrGuest has been removed in v0.15.4 to match React library.\n// It has been merged into useAccount which now handles both authenticated and guest scenarios.\n// This change maintains 1:1 API compatibility with the React Jazz library.\n// If you were using useAccountOrGuest, please migrate to useAccount.\n\nfunction shouldSkipUpdate(\n newValue: MaybeLoaded<CoValue>,\n previousValue: MaybeLoaded<CoValue>,\n) {\n if (previousValue === newValue) return true;\n // Avoid re-renders if the value is not loaded and didn't change\n return (\n previousValue.$jazz.id === newValue.$jazz.id &&\n !previousValue.$isLoaded &&\n !newValue.$isLoaded &&\n previousValue.$jazz.loadingState === newValue.$jazz.loadingState\n );\n}\n","import { onUnmounted, ref } from \"vue\";\nimport { useAuthSecretStorage } from \"../composables.js\";\n\nexport function useIsAuthenticated() {\n const authSecretStorage = useAuthSecretStorage();\n const isAuthenticated = ref(authSecretStorage.isAuthenticated);\n\n const handleUpdate = (newIsAuthenticated: boolean) => {\n isAuthenticated.value = newIsAuthenticated;\n };\n\n // Set up the listener immediately, not waiting for onMounted\n // This ensures we catch auth state changes that happen before mounting\n const cleanup = authSecretStorage.onUpdate(handleUpdate);\n\n onUnmounted(() => {\n cleanup();\n });\n\n return isAuthenticated;\n}\n","import { PassphraseAuth } from \"jazz-tools\";\nimport { computed, markRaw, ref, watchEffect } from \"vue\";\nimport { useAuthSecretStorage, useJazzContext } from \"../composables.js\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated.js\";\n\n/**\n * `usePassphraseAuth` composable provides a `JazzAuth` object for passphrase authentication.\n *\n * @example\n * ```ts\n * const auth = usePassphraseAuth({ wordlist });\n * ```\n *\n * @category Auth Providers\n */\nexport function usePassphraseAuth({ wordlist }: { wordlist: string[] }) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n const isAuthenticated = useIsAuthenticated();\n\n if (\"guest\" in context.value) {\n throw new Error(\"Passphrase auth is not supported in guest mode\");\n }\n\n const authMethod = computed(() => {\n return markRaw(\n new PassphraseAuth(\n context.value.node.crypto,\n context.value.authenticate,\n context.value.register,\n authSecretStorage,\n wordlist,\n ),\n );\n });\n\n const passphrase = ref(authMethod.value.passphrase);\n\n watchEffect((onCleanup) => {\n authMethod.value.loadCurrentAccountPassphrase();\n\n const unsubscribe = authMethod.value.subscribe(() => {\n passphrase.value = authMethod.value.passphrase;\n });\n\n onCleanup(unsubscribe);\n });\n\n return computed(() => ({\n state: isAuthenticated.value ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.value.logIn,\n signUp: authMethod.value.signUp,\n registerNewAccount: authMethod.value.registerNewAccount,\n generateRandomPassphrase: authMethod.value.generateRandomPassphrase,\n passphrase: passphrase.value,\n }));\n}\n","import { BrowserPasskeyAuth } from \"jazz-tools/browser\";\nimport { computed, markRaw } from \"vue\";\nimport { useAuthSecretStorage, useJazzContext } from \"../composables.js\";\nimport { useIsAuthenticated } from \"./useIsAuthenticated.js\";\n\n/**\n * `usePasskeyAuth` composable provides a `JazzAuth` object for passkey authentication.\n *\n * @example\n * ```ts\n * const auth = usePasskeyAuth({ appName, appHostname });\n * ```\n *\n * @category Auth Providers\n */\nexport function usePasskeyAuth({\n appName,\n appHostname,\n}: {\n appName: string;\n appHostname?: string;\n}) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n const isAuthenticated = useIsAuthenticated();\n\n if (\"guest\" in context.value) {\n throw new Error(\"Passkey auth is not supported in guest mode\");\n }\n\n const authMethod = computed(() => {\n return markRaw(\n new BrowserPasskeyAuth(\n context.value.node.crypto,\n context.value.authenticate,\n authSecretStorage,\n appName,\n appHostname,\n ),\n );\n });\n\n return computed(() => ({\n state: isAuthenticated.value ? \"signedIn\" : \"anonymous\",\n logIn: authMethod.value.logIn,\n signUp: authMethod.value.signUp,\n }));\n}\n","import { JazzClerkAuth, type MinimalClerkClient } from \"jazz-tools\";\nimport { computed, markRaw, onMounted, onUnmounted } from \"vue\";\nimport { useAuthSecretStorage, useJazzContext } from \"../composables.js\";\n\nexport function useClerkAuth(clerk: MinimalClerkClient) {\n const context = useJazzContext();\n const authSecretStorage = useAuthSecretStorage();\n\n if (\"guest\" in context.value) {\n throw new Error(\"Clerk auth is not supported in guest mode\");\n }\n\n // Create auth method similar to React's useMemo pattern\n const authMethod = computed(() => {\n return markRaw(\n new JazzClerkAuth(\n context.value.authenticate,\n context.value.logOut,\n authSecretStorage,\n ),\n );\n });\n\n onMounted(() => {\n const cleanup = authMethod.value.registerListener(clerk) as\n | (() => void)\n | void;\n\n onUnmounted(() => {\n // Clerk's addListener returns a cleanup function, but the type says void\n // Handle both cases for type safety\n if (typeof cleanup === \"function\") {\n cleanup();\n }\n });\n });\n\n return authMethod.value;\n}\n","import type {\n Account,\n AccountClass,\n AnyAccountSchema,\n CoValueFromRaw,\n SyncConfig,\n} from \"jazz-tools\";\nimport {\n InMemoryKVStore,\n JazzClerkAuth,\n KvStoreContext,\n type MinimalClerkClient,\n} from \"jazz-tools\";\nimport { LocalStorageKVStore } from \"jazz-tools/browser\";\nimport { type PropType, defineComponent, h, onMounted, ref } from \"vue\";\nimport { JazzVueProvider } from \"../provider.js\";\nimport { useClerkAuth } from \"./useClerkAuth.js\";\n\nfunction setupKvStore() {\n KvStoreContext.getInstance().initialize(\n typeof window === \"undefined\"\n ? new InMemoryKVStore()\n : new LocalStorageKVStore(),\n );\n}\n\nconst RegisterClerkAuth = defineComponent({\n name: \"RegisterClerkAuth\",\n props: {\n clerk: {\n type: Object as PropType<MinimalClerkClient>,\n required: true,\n },\n },\n setup(props, { slots }) {\n useClerkAuth(props.clerk);\n return () => slots.default?.();\n },\n});\n\nexport const JazzVueProviderWithClerk = defineComponent({\n name: \"JazzVueProviderWithClerk\",\n props: {\n clerk: {\n type: Object as PropType<MinimalClerkClient>,\n required: true,\n },\n AccountSchema: {\n type: [Function, Object] as unknown as PropType<\n (AccountClass<Account> & CoValueFromRaw<Account>) | AnyAccountSchema\n >,\n required: false,\n },\n guestMode: {\n type: Boolean,\n default: false,\n },\n sync: {\n type: Object as PropType<SyncConfig>,\n required: true,\n },\n storage: {\n type: String as PropType<\"indexedDB\">,\n default: undefined,\n },\n defaultProfileName: {\n type: String,\n required: false,\n },\n onLogOut: {\n type: Function as PropType<() => void>,\n required: false,\n },\n onAnonymousAccountDiscarded: {\n type: Function as PropType<(anonymousAccount: Account) => Promise<void>>,\n required: false,\n },\n enableSSR: {\n type: Boolean,\n default: false,\n },\n },\n setup(props, { slots }) {\n const isLoaded = ref(false);\n\n onMounted(async () => {\n try {\n setupKvStore();\n await JazzClerkAuth.initializeAuth(props.clerk);\n isLoaded.value = true;\n } catch (error) {\n console.error(\"Jazz + Clerk initialization error:\", error);\n // Still render even if auth init fails\n isLoaded.value = true;\n }\n });\n\n return () => {\n if (!isLoaded.value) {\n return null;\n }\n\n // Destructure props to exclude 'clerk' which JazzVueProvider doesn't accept\n const { clerk, ...jazzProviderProps } = props;\n\n return h(\n JazzVueProvider,\n {\n ...jazzProviderProps,\n logOutReplacement: clerk.signOut,\n },\n {\n default: () =>\n h(\n RegisterClerkAuth,\n { clerk },\n { default: () => slots.default?.() },\n ),\n },\n );\n };\n },\n});\n","<template>\n <div v-if=\"auth.state === 'signedIn'\">\n <slot />\n </div>\n <div v-else :style=\"containerStyle\">\n <div :style=\"cardStyle\">\n <h1 :style=\"headingStyle\">{{ appName }}</h1>\n \n <div v-if=\"error\" :style=\"errorStyle\">\n {{ error }}\n </div>\n\n <form @submit.prevent=\"handleSignUp\" :style=\"formStyle\">\n <input\n v-model=\"username\"\n type=\"text\"\n placeholder=\"Display name\"\n autocomplete=\"name\"\n :style=\"inputStyle\"\n />\n <button type=\"submit\" :style=\"primaryButtonStyle\">\n Sign up\n </button>\n </form>\n\n <button @click=\"handleLogIn\" :style=\"secondaryButtonStyle\">\n Log in with existing account\n </button>\n </div>\n </div>\n</template>\n\n<script setup lang=\"ts\">\nimport { ref } from \"vue\";\nimport { usePasskeyAuth } from \"./usePasskeyAuth.js\";\n\ninterface Props {\n appName: string;\n appHostname?: string;\n}\n\nconst props = defineProps<Props>();\n\nconst username = ref(\"\");\nconst error = ref<string | null>(null);\n\nconst auth = usePasskeyAuth({\n appName: props.appName,\n appHostname: props.appHostname,\n});\n\nfunction handleError(err: Error) {\n if (err.cause instanceof Error) {\n error.value = err.cause.message;\n } else {\n error.value = err.message;\n }\n}\n\nconst handleSignUp = async () => {\n if (!username.value.trim()) {\n error.value = \"Name is required\";\n return;\n }\n\n error.value = null;\n try {\n await auth.value.signUp(username.value.trim());\n } catch (err) {\n handleError(err as Error);\n }\n};\n\nconst handleLogIn = async () => {\n error.value = null;\n try {\n await auth.value.logIn();\n } catch (err) {\n handleError(err as Error);\n }\n};\n\n// Styles (matching React version)\nconst containerStyle = {\n width: \"100vw\",\n height: \"100vh\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n backgroundColor: \"#f3f4f6\",\n padding: \"1rem\",\n};\n\nconst cardStyle = {\n backgroundColor: \"white\",\n padding: \"2rem\",\n borderRadius: \"0.5rem\",\n boxShadow: \"0 10px 15px -3px rgba(0, 0, 0, 0.1)\",\n width: \"100%\",\n maxWidth: \"18rem\",\n display: \"flex\",\n flexDirection: \"column\" as const,\n gap: \"2rem\",\n};\n\nconst headingStyle = {\n fontSize: \"1.5rem\",\n fontWeight: \"bold\",\n textAlign: \"center\" as const,\n margin: \"0\",\n};\n\nconst errorStyle = {\n color: \"red\",\n fontSize: \"0.875rem\",\n textAlign: \"center\" as const,\n};\n\nconst formStyle = {\n display: \"flex\",\n flexDirection: \"column\" as const,\n gap: \"0.5rem\",\n};\n\nconst inputStyle = {\n padding: \"0.75rem\",\n border: \"1px solid #d1d5db\",\n borderRadius: \"0.375rem\",\n fontSize: \"1rem\",\n};\n\nconst primaryButtonStyle = {\n backgroundColor: \"#3b82f6\",\n color: \"white\",\n padding: \"0.75rem 1rem\",\n border: \"none\",\n borderRadius: \"0.375rem\",\n cursor: \"pointer\",\n fontSize: \"1rem\",\n fontWeight: \"500\",\n};\n\nconst secondaryButtonStyle = {\n backgroundColor: \"#e5e7eb\",\n color: \"#374151\",\n padding: \"0.75rem 1rem\",\n border: \"none\",\n borderRadius: \"0.375rem\",\n cursor: \"pointer\",\n fontSize: \"1rem\",\n fontWeight: \"500\",\n};\n</script>\n","<script setup lang=\"ts\">\nimport { ImageDefinition } from \"jazz-tools\";\nimport { highestResAvailable } from \"jazz-tools/media\";\nimport { onUnmounted, ref, watch, computed } from \"vue\";\nimport { useCoState } from \"./composables.js\";\n\nexport interface ImageProps {\n /** The ID of the ImageDefinition to display */\n imageId: string;\n /**\n * The desired width of the image. Can be a number in pixels or \"original\" to use the image's original width.\n * When set to a number, the component will select the best available resolution and maintain aspect ratio.\n */\n width?: number | \"original\";\n /**\n * The desired height of the image. Can be a number in pixels or \"original\" to use the image's original height.\n * When set to a number, the component will select the best available resolution and maintain aspect ratio.\n */\n height?: number | \"original\";\n /** Alt text for the image */\n alt?: string;\n /** CSS classes to apply to the image */\n classNames?: string;\n /** CSS styles to apply to the image */\n style?: string | Record<string, string>;\n /** Loading strategy for the image */\n loading?: \"lazy\" | \"eager\";\n}\n\nconst props = withDefaults(defineProps<ImageProps>(), {\n loading: \"eager\",\n});\n\nconst image = useCoState(ImageDefinition, props.imageId, {});\nlet lastBestImage: [string, string] | null = null;\n\n/**\n * For lazy loading, we use the browser's strategy for images with loading=\"lazy\".\n * We use an empty image, and when the browser triggers the load event, we load the best available image.\n */\nconst waitingLazyLoading = ref(props.loading === \"lazy\");\nconst lazyPlaceholder = computed(() =>\n waitingLazyLoading.value ? URL.createObjectURL(emptyPixelBlob) : undefined,\n);\n\nconst dimensions = computed(() => {\n const originalSize = image.value.$isLoaded\n ? image.value.originalSize\n : undefined;\n const originalWidth = originalSize?.[0];\n const originalHeight = originalSize?.[1];\n\n // Both width and height are \"original\"\n if (props.width === \"original\" && props.height === \"original\") {\n return { width: originalWidth, height: originalHeight };\n }\n\n // Width is \"original\", height is a number\n if (props.width === \"original\" && typeof props.height === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width: Math.round((props.height * originalWidth) / originalHeight),\n height: props.height,\n };\n }\n return { width: undefined, height: props.height };\n }\n\n // Height is \"original\", width is a number\n if (props.height === \"original\" && typeof props.width === \"number\") {\n if (originalWidth && originalHeight) {\n return {\n width: props.width,\n height: Math.round((props.width * originalHeight) / originalWidth),\n };\n }\n return { width: props.width, height: undefined };\n }\n\n // In all other cases, use the property value:\n return {\n width: props.width === \"original\" ? originalWidth : props.width,\n height: props.height === \"original\" ? originalHeight : props.height,\n };\n});\n\nconst src = computed(() => {\n if (waitingLazyLoading.value) {\n return lazyPlaceholder.value;\n }\n\n if (!image.value.$isLoaded) return undefined;\n\n const bestImage = highestResAvailable(\n image.value,\n dimensions.value.width || dimensions.value.height || 9999,\n dimensions.value.height || dimensions.value.width || 9999,\n );\n\n if (!bestImage) return image.value.placeholderDataURL;\n if (lastBestImage?.[0] === bestImage.image.$jazz.id)\n return lastBestImage?.[1];\n\n const blob = bestImage.image.toBlob();\n\n if (blob) {\n const url = URL.createObjectURL(blob);\n revokeObjectURL(lastBestImage?.[1]);\n lastBestImage = [bestImage.image.$jazz.id, url];\n return url;\n }\n\n return image.value.placeholderDataURL;\n});\n\nconst onThresholdReached = () => {\n waitingLazyLoading.value = false;\n};\n\n// Cleanup object URL on component destroy\nonUnmounted(() => {\n revokeObjectURL(lastBestImage?.[1]);\n});\n\nfunction revokeObjectURL(url: string | undefined) {\n if (url && url.startsWith(\"blob:\")) {\n URL.revokeObjectURL(url);\n }\n}\n\nconst emptyPixelBlob = new Blob(\n [\n Uint8Array.from(\n atob(\n \"iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=\",\n ),\n (c) => c.charCodeAt(0),\n ),\n ],\n { type: \"image/png\" },\n);\n</script>\n\n<template>\n <img\n :src=\"src\"\n :width=\"dimensions.width\"\n :height=\"dimensions.height\"\n :alt=\"alt\"\n :class=\"classNames\"\n :style=\"style\"\n :loading=\"loading\"\n @load=\"waitingLazyLoading ? onThresholdReached() : undefined\"\n />\n</template>\n"],"names":["inbox"],"mappings":";;;;;;;;AA8CO,MAAM,gBAAgB,IAAgB;AAE7C,SAAS,oCACP,gBACA;AACM,QAAA,UAAU,eAAe,gBAAgB;AAE/C,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,kBAAkB;AAAA,EAAA;AAGpC,SAAO,QAAQ,UAAU,QAAQ,KAAK,QAAQ;AAChD;AAEO,SAAS,iBAGd;AACM,QAAA,UAAU,OAAkC,iBAAiB;AACnE,MAAI,CAAC,SAAS;AACN,UAAA,IAAI,MAAM,mDAAmD;AAAA,EAAA;AAE9D,SAAA;A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AW,CAAC;AAAA,QAAA;AAAA,MAEzB;AAAA,MACA,EAAE,MAAM,YAAY;AAAA,IACtB;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "community-jazz-vue",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "src/index.ts",
|
|
@@ -24,8 +24,8 @@
|
|
|
24
24
|
}
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"cojson": "0.19.
|
|
28
|
-
"jazz-tools": "0.19.
|
|
27
|
+
"cojson": "0.19.5",
|
|
28
|
+
"jazz-tools": "0.19.5"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@babel/plugin-syntax-jsx": "^7.25.0",
|
package/src/composables.ts
CHANGED
|
@@ -23,17 +23,18 @@ import {
|
|
|
23
23
|
import { consumeInviteLinkFromWindowLocation } from "jazz-tools/browser";
|
|
24
24
|
import {
|
|
25
25
|
type ComputedRef,
|
|
26
|
+
type MaybeRefOrGetter,
|
|
26
27
|
type Ref,
|
|
27
28
|
type ShallowRef,
|
|
28
29
|
computed,
|
|
29
30
|
inject,
|
|
30
31
|
markRaw,
|
|
31
|
-
nextTick,
|
|
32
32
|
onMounted,
|
|
33
33
|
onUnmounted,
|
|
34
34
|
ref,
|
|
35
35
|
shallowRef,
|
|
36
36
|
toRaw,
|
|
37
|
+
toValue,
|
|
37
38
|
watch,
|
|
38
39
|
} from "vue";
|
|
39
40
|
|
|
@@ -157,11 +158,11 @@ export function useCoState<
|
|
|
157
158
|
const R extends ResolveQuery<S> = true,
|
|
158
159
|
>(
|
|
159
160
|
Schema: S,
|
|
160
|
-
id: string | undefined
|
|
161
|
+
id: MaybeRefOrGetter<string | undefined>,
|
|
161
162
|
options?: { resolve?: ResolveQueryStrict<S, R> },
|
|
162
163
|
): Ref<MaybeLoaded<Loaded<S, R>>> {
|
|
163
164
|
const state: ShallowRef<MaybeLoaded<Loaded<S, R>>> = shallowRef(
|
|
164
|
-
createUnloadedCoValue(id ?? "", CoValueLoadingState.LOADING),
|
|
165
|
+
createUnloadedCoValue(toValue(id) ?? "", CoValueLoadingState.LOADING),
|
|
165
166
|
);
|
|
166
167
|
const context = useJazzContext();
|
|
167
168
|
|
|
@@ -179,7 +180,7 @@ export function useCoState<
|
|
|
179
180
|
};
|
|
180
181
|
|
|
181
182
|
watch(
|
|
182
|
-
[() => id, context],
|
|
183
|
+
[() => toValue(id), context],
|
|
183
184
|
([currentId, currentContext]) => {
|
|
184
185
|
if (unsubscribe) {
|
|
185
186
|
unsubscribe();
|
|
@@ -214,21 +215,11 @@ export function useCoState<
|
|
|
214
215
|
{
|
|
215
216
|
resolve: options?.resolve as any,
|
|
216
217
|
loadAs: safeLoadAsAgent,
|
|
217
|
-
onUnavailable: () => {
|
|
218
|
-
updateState(
|
|
219
|
-
createUnloadedCoValue(
|
|
220
|
-
currentId,
|
|
221
|
-
CoValueLoadingState.UNAVAILABLE,
|
|
222
|
-
),
|
|
223
|
-
);
|
|
218
|
+
onUnavailable: (value) => {
|
|
219
|
+
updateState(value);
|
|
224
220
|
},
|
|
225
|
-
onUnauthorized: () => {
|
|
226
|
-
updateState(
|
|
227
|
-
createUnloadedCoValue(
|
|
228
|
-
currentId,
|
|
229
|
-
CoValueLoadingState.UNAUTHORIZED,
|
|
230
|
-
),
|
|
231
|
-
);
|
|
221
|
+
onUnauthorized: (value) => {
|
|
222
|
+
updateState(value);
|
|
232
223
|
},
|
|
233
224
|
syncResolution: true,
|
|
234
225
|
},
|
|
@@ -313,7 +304,7 @@ export function useAcceptInvite<S extends CoValueClassOrSchema>({
|
|
|
313
304
|
export function experimental_useInboxSender<
|
|
314
305
|
I extends CoValue,
|
|
315
306
|
O extends CoValue | undefined,
|
|
316
|
-
>(inboxOwnerID: string | undefined) {
|
|
307
|
+
>(inboxOwnerID: MaybeRefOrGetter<string | undefined>) {
|
|
317
308
|
const context = useJazzContext();
|
|
318
309
|
|
|
319
310
|
if (!context.value) {
|
|
@@ -332,17 +323,21 @@ export function experimental_useInboxSender<
|
|
|
332
323
|
const inboxRef = ref<Promise<InboxSender<I, O>> | undefined>(undefined);
|
|
333
324
|
|
|
334
325
|
const sendMessage = async (message: I) => {
|
|
335
|
-
|
|
326
|
+
const resolvedInboxOwnerID = toValue(inboxOwnerID);
|
|
327
|
+
if (!resolvedInboxOwnerID) throw new Error("Inbox owner ID is required");
|
|
336
328
|
|
|
337
329
|
if (!inboxRef.value) {
|
|
338
|
-
const inbox = InboxSender.load<I, O>(
|
|
330
|
+
const inbox = InboxSender.load<I, O>(
|
|
331
|
+
resolvedInboxOwnerID,
|
|
332
|
+
toRaw(me.value),
|
|
333
|
+
);
|
|
339
334
|
inboxRef.value = inbox;
|
|
340
335
|
}
|
|
341
336
|
|
|
342
337
|
let inbox = await inboxRef.value;
|
|
343
338
|
|
|
344
|
-
if (inbox.owner.id !==
|
|
345
|
-
const req = InboxSender.load<I, O>(
|
|
339
|
+
if (inbox.owner.id !== resolvedInboxOwnerID) {
|
|
340
|
+
const req = InboxSender.load<I, O>(resolvedInboxOwnerID, toRaw(me.value));
|
|
346
341
|
inboxRef.value = req;
|
|
347
342
|
inbox = await req;
|
|
348
343
|
}
|
|
@@ -351,7 +346,7 @@ export function experimental_useInboxSender<
|
|
|
351
346
|
};
|
|
352
347
|
|
|
353
348
|
watch(
|
|
354
|
-
() => inboxOwnerID,
|
|
349
|
+
() => toValue(inboxOwnerID),
|
|
355
350
|
() => {
|
|
356
351
|
inboxRef.value = undefined;
|
|
357
352
|
},
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
setupJazzTestSync,
|
|
16
16
|
} from "jazz-tools/testing";
|
|
17
17
|
import { beforeEach, describe, expect, expectTypeOf, it } from "vitest";
|
|
18
|
-
import
|
|
18
|
+
import { nextTick, ref, type Ref } from "vue";
|
|
19
19
|
import { useCoState } from "../index.js";
|
|
20
20
|
import { waitFor, withJazzTestSetup } from "./testUtils.js";
|
|
21
21
|
|
|
@@ -200,4 +200,74 @@ describe("useCoState", () => {
|
|
|
200
200
|
Ref<MaybeLoaded<co.loaded<typeof TestMap>>>
|
|
201
201
|
>();
|
|
202
202
|
});
|
|
203
|
+
|
|
204
|
+
it("should accept ref input", async () => {
|
|
205
|
+
const TestMap = co.map({
|
|
206
|
+
content: z.string(),
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
const account = await createJazzTestAccount();
|
|
210
|
+
|
|
211
|
+
const map1 = TestMap.create(
|
|
212
|
+
{
|
|
213
|
+
content: "123",
|
|
214
|
+
},
|
|
215
|
+
{ owner: account },
|
|
216
|
+
);
|
|
217
|
+
const map2 = TestMap.create(
|
|
218
|
+
{
|
|
219
|
+
content: "456",
|
|
220
|
+
},
|
|
221
|
+
{ owner: account },
|
|
222
|
+
);
|
|
223
|
+
|
|
224
|
+
const id = ref(map1.$jazz.id);
|
|
225
|
+
const [result] = withJazzTestSetup(() => useCoState(TestMap, id, {}), {
|
|
226
|
+
account,
|
|
227
|
+
});
|
|
228
|
+
|
|
229
|
+
assertLoaded(result.value);
|
|
230
|
+
expect(result.value.content).toBe("123");
|
|
231
|
+
id.value = map2.$jazz.id;
|
|
232
|
+
await nextTick();
|
|
233
|
+
assertLoaded(result.value);
|
|
234
|
+
expect(result.value.content).toBe("456");
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it("should accept getter input", async () => {
|
|
238
|
+
const TestMap = co.map({
|
|
239
|
+
content: z.string(),
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
const account = await createJazzTestAccount();
|
|
243
|
+
|
|
244
|
+
const map1 = TestMap.create(
|
|
245
|
+
{
|
|
246
|
+
content: "123",
|
|
247
|
+
},
|
|
248
|
+
{ owner: account },
|
|
249
|
+
);
|
|
250
|
+
const map2 = TestMap.create(
|
|
251
|
+
{
|
|
252
|
+
content: "456",
|
|
253
|
+
},
|
|
254
|
+
{ owner: account },
|
|
255
|
+
);
|
|
256
|
+
|
|
257
|
+
// simulate a getter here, in a vue app you would use a getter to access props
|
|
258
|
+
const id = ref(map1.$jazz.id);
|
|
259
|
+
const [result] = withJazzTestSetup(
|
|
260
|
+
() => useCoState(TestMap, () => id.value, {}),
|
|
261
|
+
{
|
|
262
|
+
account,
|
|
263
|
+
},
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
assertLoaded(result.value);
|
|
267
|
+
expect(result.value.content).toBe("123");
|
|
268
|
+
id.value = map2.$jazz.id;
|
|
269
|
+
await nextTick();
|
|
270
|
+
assertLoaded(result.value);
|
|
271
|
+
expect(result.value.content).toBe("456");
|
|
272
|
+
});
|
|
203
273
|
});
|
|
@@ -6,6 +6,7 @@ import { describe, expect, it } from "vitest";
|
|
|
6
6
|
import { experimental_useInboxSender } from "../composables.js";
|
|
7
7
|
import { createJazzTestAccount, linkAccounts } from "../testing.js";
|
|
8
8
|
import { withJazzTestSetup } from "./testUtils.js";
|
|
9
|
+
import { ref } from "vue";
|
|
9
10
|
|
|
10
11
|
describe("useInboxSender", () => {
|
|
11
12
|
it("should send the message to the inbox", async () => {
|
|
@@ -60,4 +61,63 @@ describe("useInboxSender", () => {
|
|
|
60
61
|
assertLoaded(responseMap);
|
|
61
62
|
expect(responseMap.value).toEqual("got it");
|
|
62
63
|
});
|
|
64
|
+
|
|
65
|
+
it("should accept reactive input", async () => {
|
|
66
|
+
const TestMap = co.map({
|
|
67
|
+
value: z.string(),
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const account = await createJazzTestAccount();
|
|
71
|
+
const inboxReceiver1 = await createJazzTestAccount();
|
|
72
|
+
const inboxReceiver2 = await createJazzTestAccount();
|
|
73
|
+
|
|
74
|
+
await linkAccounts(account, inboxReceiver1);
|
|
75
|
+
await linkAccounts(account, inboxReceiver2);
|
|
76
|
+
|
|
77
|
+
const id = ref(inboxReceiver1.$jazz.id);
|
|
78
|
+
const [result] = withJazzTestSetup(
|
|
79
|
+
() =>
|
|
80
|
+
experimental_useInboxSender<
|
|
81
|
+
Loaded<typeof TestMap>,
|
|
82
|
+
Loaded<typeof TestMap>
|
|
83
|
+
>(id),
|
|
84
|
+
{
|
|
85
|
+
account,
|
|
86
|
+
},
|
|
87
|
+
);
|
|
88
|
+
|
|
89
|
+
const sendMessage = result;
|
|
90
|
+
|
|
91
|
+
sendMessage(
|
|
92
|
+
TestMap.create(
|
|
93
|
+
{ value: "hello" },
|
|
94
|
+
{ owner: Group.create({ owner: account }) },
|
|
95
|
+
),
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const inbox1 = await Inbox.load(inboxReceiver1);
|
|
99
|
+
|
|
100
|
+
const incoming1 = await new Promise<Loaded<typeof TestMap>>((resolve) => {
|
|
101
|
+
inbox1.subscribe(TestMap, async (message) => resolve(message));
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
expect(incoming1.value).toEqual("hello");
|
|
105
|
+
|
|
106
|
+
// now the second inbox
|
|
107
|
+
id.value = inboxReceiver2.$jazz.id;
|
|
108
|
+
|
|
109
|
+
sendMessage(
|
|
110
|
+
TestMap.create(
|
|
111
|
+
{ value: "hello to you too" },
|
|
112
|
+
{ owner: Group.create({ owner: account }) },
|
|
113
|
+
),
|
|
114
|
+
);
|
|
115
|
+
const inbox2 = await Inbox.load(inboxReceiver2);
|
|
116
|
+
|
|
117
|
+
const incoming2 = await new Promise<Loaded<typeof TestMap>>((resolve) => {
|
|
118
|
+
inbox2.subscribe(TestMap, async (message) => resolve(message));
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
expect(incoming2.value).toEqual("hello to you too");
|
|
122
|
+
});
|
|
63
123
|
});
|