jazz-tools 0.17.14 → 0.18.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.js +1 -1
- package/.svelte-kit/__package__/media/image.svelte +3 -9
- package/.svelte-kit/__package__/media/image.svelte.d.ts +1 -6
- package/.svelte-kit/__package__/media/image.svelte.d.ts.map +1 -1
- package/.svelte-kit/__package__/media/image.types.d.ts +7 -0
- package/.svelte-kit/__package__/media/image.types.d.ts.map +1 -0
- package/.svelte-kit/__package__/media/image.types.js +1 -0
- package/.svelte-kit/__package__/tests/media/image.svelte.test.js +31 -31
- package/.turbo/turbo-build.log +50 -50
- package/CHANGELOG.md +31 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-LZOF6WP5.js → chunk-HJ3GTGY7.js} +1320 -1018
- package/dist/chunk-HJ3GTGY7.js.map +1 -0
- package/dist/index.js +18 -18
- package/dist/index.js.map +1 -1
- package/dist/inspector/{custom-element-ZSNTCECD.js → custom-element-WCY6D3QJ.js} +3 -3
- package/dist/inspector/{custom-element-ZSNTCECD.js.map → custom-element-WCY6D3QJ.js.map} +1 -1
- package/dist/inspector/index.js +1 -1
- package/dist/inspector/index.js.map +1 -1
- package/dist/inspector/register-custom-element.js +1 -1
- package/dist/media/{chunk-E5J3WLQW.js → chunk-KR2V6X2N.js} +14 -9
- package/dist/media/chunk-KR2V6X2N.js.map +1 -0
- package/dist/media/create-image.d.ts +6 -6
- package/dist/media/index.browser.d.ts +6 -6
- package/dist/media/index.browser.js +1 -1
- package/dist/media/index.d.ts +1 -1
- package/dist/media/index.js +1 -1
- package/dist/media/index.native.d.ts +6 -6
- package/dist/media/index.native.js +1 -1
- package/dist/media/utils.d.ts.map +1 -1
- package/dist/prosemirror/index.js +2 -2
- package/dist/prosemirror/index.js.map +1 -1
- package/dist/react/index.js +7 -5
- package/dist/react/index.js.map +1 -1
- package/dist/react-core/hooks.d.ts.map +1 -1
- package/dist/react-core/index.js +4658 -23
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-native-core/index.js +1 -1
- package/dist/react-native-core/index.js.map +1 -1
- package/dist/svelte/jazz.class.svelte.js +1 -1
- package/dist/svelte/media/image.svelte +3 -9
- package/dist/svelte/media/image.svelte.d.ts +1 -6
- package/dist/svelte/media/image.svelte.d.ts.map +1 -1
- package/dist/svelte/media/image.types.d.ts +7 -0
- package/dist/svelte/media/image.types.d.ts.map +1 -0
- package/dist/svelte/media/image.types.js +1 -0
- package/dist/svelte/tests/media/image.svelte.test.js +31 -31
- package/dist/testing.js +18 -14
- package/dist/testing.js.map +1 -1
- package/dist/tools/coValues/CoFieldInit.d.ts +13 -0
- package/dist/tools/coValues/CoFieldInit.d.ts.map +1 -0
- package/dist/tools/coValues/CoValueBase.d.ts +18 -15
- package/dist/tools/coValues/CoValueBase.d.ts.map +1 -1
- package/dist/tools/coValues/account.d.ts +100 -46
- package/dist/tools/coValues/account.d.ts.map +1 -1
- package/dist/tools/coValues/coFeed.d.ts +78 -62
- package/dist/tools/coValues/coFeed.d.ts.map +1 -1
- package/dist/tools/coValues/coList.d.ts +212 -99
- package/dist/tools/coValues/coList.d.ts.map +1 -1
- package/dist/tools/coValues/coMap.d.ts +200 -192
- package/dist/tools/coValues/coMap.d.ts.map +1 -1
- package/dist/tools/coValues/coPlainText.d.ts +30 -22
- package/dist/tools/coValues/coPlainText.d.ts.map +1 -1
- package/dist/tools/coValues/deepLoading.d.ts +13 -13
- package/dist/tools/coValues/deepLoading.d.ts.map +1 -1
- package/dist/tools/coValues/extensions/imageDef.d.ts +1 -1
- package/dist/tools/coValues/group.d.ts +32 -32
- 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 +18 -17
- package/dist/tools/coValues/interfaces.d.ts.map +1 -1
- package/dist/tools/coValues/profile.d.ts +6 -5
- package/dist/tools/coValues/profile.d.ts.map +1 -1
- package/dist/tools/coValues/schemaUnion.d.ts +3 -3
- package/dist/tools/coValues/schemaUnion.d.ts.map +1 -1
- package/dist/tools/exports.d.ts +1 -1
- package/dist/tools/exports.d.ts.map +1 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts +2 -1
- package/dist/tools/implementation/anonymousJazzAgent.d.ts.map +1 -1
- package/dist/tools/implementation/schema.d.ts +5 -5
- package/dist/tools/implementation/schema.d.ts.map +1 -1
- package/dist/tools/implementation/symbols.d.ts +2 -0
- package/dist/tools/implementation/symbols.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/AccountSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts +6 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts +8 -3
- package/dist/tools/implementation/zodSchema/schemaTypes/CoListSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts +12 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoMapSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts +13 -7
- package/dist/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts +11 -2
- package/dist/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts +4 -0
- package/dist/tools/implementation/zodSchema/schemaTypes/RichTextSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/{CoFieldInit.d.ts → CoFieldSchemaInit.d.ts} +7 -7
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldSchemaInit.d.ts.map +1 -0
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts +4 -4
- package/dist/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.d.ts.map +1 -1
- package/dist/tools/implementation/zodSchema/zodCo.d.ts +2 -2
- package/dist/tools/implementation/zodSchema/zodCo.d.ts.map +1 -1
- package/dist/tools/internal.d.ts +2 -1
- package/dist/tools/internal.d.ts.map +1 -1
- package/dist/tools/lib/migration.d.ts +1 -1
- package/dist/tools/lib/migration.d.ts.map +1 -1
- package/dist/tools/subscribe/SubscriptionScope.d.ts.map +1 -1
- package/dist/tools/subscribe/index.d.ts +1 -1
- package/dist/tools/subscribe/index.d.ts.map +1 -1
- package/dist/tools/subscribe/utils.d.ts +2 -2
- package/dist/tools/subscribe/utils.d.ts.map +1 -1
- package/dist/tools/testing.d.ts.map +1 -1
- package/dist/tools/tests/utils.d.ts +2 -6
- package/dist/tools/tests/utils.d.ts.map +1 -1
- package/dist/worker/index.js +3 -3
- package/dist/worker/index.js.map +1 -1
- package/package.json +4 -4
- package/src/browser/auth/PasskeyAuth.ts +2 -2
- package/src/browser/createBrowserContext.ts +2 -2
- package/src/browser/tests/PasskeyAuth.test.ts +2 -2
- package/src/inspector/custom-element.tsx +2 -2
- package/src/inspector/viewer/new-app.tsx +1 -1
- package/src/media/create-image.test.ts +7 -7
- package/src/media/create-image.ts +5 -3
- package/src/media/index.ts +1 -1
- package/src/media/utils.test.ts +72 -66
- package/src/media/utils.ts +9 -6
- package/src/prosemirror/lib/plugin.ts +1 -1
- package/src/prosemirror/lib/sync.ts +1 -1
- package/src/prosemirror/tests/plugin.test.ts +4 -4
- package/src/react/media/image.tsx +2 -2
- package/src/react/tests/media/image.test.tsx +52 -32
- package/src/react-core/hooks.ts +11 -5
- package/src/react-core/tests/useAccount.test.ts +16 -22
- package/src/react-core/tests/useCoState.test.ts +19 -19
- package/src/react-core/tests/useInboxSender.test.ts +5 -2
- package/src/react-core/tests/usePassPhraseAuth.test.ts +6 -6
- package/src/react-native-core/media/image.tsx +1 -1
- package/src/svelte/jazz.class.svelte.ts +1 -1
- package/src/svelte/media/image.svelte +3 -9
- package/src/svelte/media/image.types.ts +7 -0
- package/src/svelte/tests/media/image.svelte.test.ts +34 -32
- package/src/tools/auth/DemoAuth.ts +2 -2
- package/src/tools/auth/PassphraseAuth.ts +2 -2
- package/src/tools/auth/clerk/index.ts +2 -2
- package/src/tools/auth/clerk/tests/JazzClerkAuth.test.ts +1 -1
- package/src/tools/coValues/CoFieldInit.ts +20 -0
- package/src/tools/coValues/CoValueBase.ts +40 -60
- package/src/tools/coValues/account.ts +306 -232
- package/src/tools/coValues/coFeed.ts +185 -153
- package/src/tools/coValues/coList.ts +507 -334
- package/src/tools/coValues/coMap.ts +420 -286
- package/src/tools/coValues/coPlainText.ts +94 -110
- package/src/tools/coValues/deepLoading.ts +13 -13
- package/src/tools/coValues/group.ts +100 -114
- package/src/tools/coValues/inbox.ts +16 -14
- package/src/tools/coValues/interfaces.ts +49 -31
- package/src/tools/coValues/profile.ts +8 -6
- package/src/tools/coValues/request.ts +9 -9
- package/src/tools/coValues/schemaUnion.ts +11 -5
- package/src/tools/exports.ts +1 -1
- package/src/tools/implementation/ContextManager.ts +4 -4
- package/src/tools/implementation/anonymousJazzAgent.ts +2 -1
- package/src/tools/implementation/createContext.ts +1 -1
- package/src/tools/implementation/devtoolsFormatters.ts +9 -9
- package/src/tools/implementation/invites.ts +2 -2
- package/src/tools/implementation/schema.ts +7 -7
- package/src/tools/implementation/symbols.ts +3 -0
- package/src/tools/implementation/zodSchema/schemaTypes/AccountSchema.ts +2 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoFeedSchema.ts +11 -2
- package/src/tools/implementation/zodSchema/schemaTypes/CoListSchema.ts +18 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoMapSchema.ts +17 -7
- package/src/tools/implementation/zodSchema/schemaTypes/CoRecordSchema.ts +20 -11
- package/src/tools/implementation/zodSchema/schemaTypes/FileStreamSchema.ts +19 -2
- package/src/tools/implementation/zodSchema/schemaTypes/PlainTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/schemaTypes/RichTextSchema.ts +6 -0
- package/src/tools/implementation/zodSchema/typeConverters/{CoFieldInit.ts → CoFieldSchemaInit.ts} +11 -11
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchema.ts +4 -4
- package/src/tools/implementation/zodSchema/typeConverters/InstanceOfSchemaCoValuesNullable.ts +4 -4
- package/src/tools/implementation/zodSchema/zodCo.ts +2 -2
- package/src/tools/internal.ts +2 -1
- package/src/tools/lib/migration.ts +5 -5
- package/src/tools/subscribe/SubscriptionScope.ts +32 -24
- package/src/tools/subscribe/index.ts +4 -4
- package/src/tools/subscribe/utils.ts +11 -11
- package/src/tools/testing.ts +17 -13
- package/src/tools/tests/ContextManager.test.ts +68 -57
- package/src/tools/tests/PassphraseAuth.test.ts +2 -2
- package/src/tools/tests/account.test.ts +139 -69
- package/src/tools/tests/coDiscriminatedUnion.test-d.ts +12 -6
- package/src/tools/tests/coDiscriminatedUnion.test.ts +26 -17
- package/src/tools/tests/coFeed.test-d.ts +18 -17
- package/src/tools/tests/coFeed.test.ts +108 -97
- package/src/tools/tests/coList.test-d.ts +18 -23
- package/src/tools/tests/coList.test.ts +350 -165
- package/src/tools/tests/coMap.record.test-d.ts +9 -13
- package/src/tools/tests/coMap.record.test.ts +37 -23
- package/src/tools/tests/coMap.test-d.ts +43 -21
- package/src/tools/tests/coMap.test.ts +360 -182
- package/src/tools/tests/coOptional.test.ts +28 -13
- package/src/tools/tests/coPlainText.test.ts +15 -15
- package/src/tools/tests/createContext.test.ts +14 -14
- package/src/tools/tests/deepLoading.test.ts +95 -94
- package/src/tools/tests/exportImport.test.ts +61 -41
- package/src/tools/tests/groupsAndAccounts.test.ts +333 -116
- package/src/tools/tests/inbox.test.ts +22 -17
- package/src/tools/tests/interfaces.test.ts +12 -11
- package/src/tools/tests/invites.test.ts +6 -4
- package/src/tools/tests/load.test.ts +20 -18
- package/src/tools/tests/patterns/notifications.test.ts +6 -6
- package/src/tools/tests/patterns/quest.test.ts +3 -3
- package/src/tools/tests/patterns/requestToJoin.test.ts +22 -22
- package/src/tools/tests/request.test.ts +38 -39
- package/src/tools/tests/schemaUnion.test.ts +64 -10
- package/src/tools/tests/subscribe.test.ts +64 -64
- package/src/tools/tests/testing.test.ts +5 -9
- package/src/tools/tests/utils.ts +3 -3
- package/src/tools/tests/zod.test.ts +3 -3
- package/src/worker/index.ts +3 -3
- package/dist/chunk-LZOF6WP5.js.map +0 -1
- package/dist/media/chunk-E5J3WLQW.js.map +0 -1
- package/dist/tools/implementation/zodSchema/typeConverters/CoFieldInit.d.ts.map +0 -1
@@ -22,7 +22,7 @@ describe("useInboxSender", () => {
|
|
22
22
|
experimental_useInboxSender<
|
23
23
|
Loaded<typeof TestMap>,
|
24
24
|
Loaded<typeof TestMap>
|
25
|
-
>(inboxReceiver.id),
|
25
|
+
>(inboxReceiver.$jazz.id),
|
26
26
|
{
|
27
27
|
account,
|
28
28
|
},
|
@@ -43,7 +43,10 @@ describe("useInboxSender", () => {
|
|
43
43
|
inbox.subscribe(TestMap, async (message) => {
|
44
44
|
resolve(message);
|
45
45
|
|
46
|
-
return TestMap.create(
|
46
|
+
return TestMap.create(
|
47
|
+
{ value: "got it" },
|
48
|
+
{ owner: message.$jazz.owner },
|
49
|
+
);
|
47
50
|
});
|
48
51
|
});
|
49
52
|
|
@@ -119,13 +119,13 @@ describe("usePassphraseAuth", () => {
|
|
119
119
|
const account = useAccount();
|
120
120
|
|
121
121
|
if (account.me) {
|
122
|
-
if (!accounts.includes(account.me.id)) {
|
123
|
-
accounts.push(account.me.id);
|
122
|
+
if (!accounts.includes(account.me.$jazz.id)) {
|
123
|
+
accounts.push(account.me.$jazz.id);
|
124
124
|
}
|
125
125
|
|
126
126
|
updates.push({
|
127
127
|
state: passphraseAuth.state,
|
128
|
-
accountIndex: accounts.indexOf(account.me.id),
|
128
|
+
accountIndex: accounts.indexOf(account.me.$jazz.id),
|
129
129
|
});
|
130
130
|
}
|
131
131
|
|
@@ -140,21 +140,21 @@ describe("usePassphraseAuth", () => {
|
|
140
140
|
expect(result.current?.passphraseAuth.state).toBe("anonymous");
|
141
141
|
expect(result.current?.account?.me).toBeDefined();
|
142
142
|
|
143
|
-
const id = result.current?.account?.me
|
143
|
+
const id = result.current?.account?.me?.$jazz.id;
|
144
144
|
|
145
145
|
await act(async () => {
|
146
146
|
await result.current?.passphraseAuth.signUp();
|
147
147
|
});
|
148
148
|
|
149
149
|
expect(result.current?.passphraseAuth.state).toBe("signedIn");
|
150
|
-
expect(result.current?.account?.me
|
150
|
+
expect(result.current?.account?.me?.$jazz.id).toBe(id);
|
151
151
|
|
152
152
|
await act(async () => {
|
153
153
|
await result.current?.account?.logOut();
|
154
154
|
});
|
155
155
|
|
156
156
|
expect(result.current?.passphraseAuth.state).toBe("anonymous");
|
157
|
-
expect(result.current?.account?.me
|
157
|
+
expect(result.current?.account?.me?.$jazz.id).not.toBe(id);
|
158
158
|
|
159
159
|
expect(updates).toMatchInlineSnapshot(`
|
160
160
|
[
|
@@ -116,7 +116,7 @@ export const Image = forwardRef<RNImage, ImageProps>(function Image(
|
|
116
116
|
let lastBestImage: FileStream | string | undefined =
|
117
117
|
image.placeholderDataURL;
|
118
118
|
|
119
|
-
const unsub = image.subscribe({}, (update) => {
|
119
|
+
const unsub = image.$jazz.subscribe({}, (update) => {
|
120
120
|
if (lastBestImage === undefined && update.placeholderDataURL) {
|
121
121
|
setSrc(update.placeholderDataURL);
|
122
122
|
lastBestImage = update.placeholderDataURL;
|
@@ -116,7 +116,7 @@ export class AccountCoState<
|
|
116
116
|
|
117
117
|
const unsubscribe = subscribeToCoValue(
|
118
118
|
coValueClassFromCoValueClassOrSchema(Schema),
|
119
|
-
me.id,
|
119
|
+
me.$jazz.id,
|
120
120
|
{
|
121
121
|
// @ts-expect-error The resolve query type isn't compatible with the coValueClassFromCoValueClassOrSchema conversion
|
122
122
|
resolve: options?.resolve,
|
@@ -2,14 +2,8 @@
|
|
2
2
|
import { ImageDefinition } from "jazz-tools";
|
3
3
|
import { highestResAvailable } from "jazz-tools/media";
|
4
4
|
import { onDestroy } from "svelte";
|
5
|
-
import type { HTMLImgAttributes } from "svelte/elements";
|
6
5
|
import { CoState } from "../jazz.class.svelte";
|
7
|
-
|
8
|
-
interface ImageProps extends Omit<HTMLImgAttributes, "width" | "height"> {
|
9
|
-
imageId: string;
|
10
|
-
width?: number | "original";
|
11
|
-
height?: number | "original";
|
12
|
-
}
|
6
|
+
import type { ImageProps } from "./image.types.js";
|
13
7
|
|
14
8
|
const { imageId, width, height, ...rest }: ImageProps = $props();
|
15
9
|
|
@@ -83,14 +77,14 @@ const src = $derived.by(() => {
|
|
83
77
|
);
|
84
78
|
|
85
79
|
if (!bestImage) return image.placeholderDataURL;
|
86
|
-
if (lastBestImage?.[0] === bestImage.image.id) return lastBestImage?.[1];
|
80
|
+
if (lastBestImage?.[0] === bestImage.image.$jazz.id) return lastBestImage?.[1];
|
87
81
|
|
88
82
|
const blob = bestImage.image.toBlob();
|
89
83
|
|
90
84
|
if (blob) {
|
91
85
|
const url = URL.createObjectURL(blob);
|
92
86
|
revokeObjectURL(lastBestImage?.[1]);
|
93
|
-
lastBestImage = [bestImage.image.id, url];
|
87
|
+
lastBestImage = [bestImage.image.$jazz.id, url];
|
94
88
|
return url;
|
95
89
|
}
|
96
90
|
|
@@ -3,6 +3,7 @@ import { FileStream, ImageDefinition } from "jazz-tools";
|
|
3
3
|
import { createJazzTestAccount } from "jazz-tools/testing";
|
4
4
|
import { describe, expect, it, vi } from "vitest";
|
5
5
|
import Image from "../../media/image.svelte";
|
6
|
+
import type { ImageProps } from "../../media/image.types.js";
|
6
7
|
import { render, screen, waitFor } from "../testUtils";
|
7
8
|
|
8
9
|
describe("Image", async () => {
|
@@ -10,7 +11,8 @@ describe("Image", async () => {
|
|
10
11
|
isCurrentActiveAccount: true,
|
11
12
|
});
|
12
13
|
|
13
|
-
const renderWithAccount = (props:
|
14
|
+
const renderWithAccount = (props: ImageProps) =>
|
15
|
+
render(Image, props, { account });
|
14
16
|
|
15
17
|
describe("initial rendering", () => {
|
16
18
|
it("should render nothing if coValue is not found", async () => {
|
@@ -28,7 +30,7 @@ describe("Image", async () => {
|
|
28
30
|
});
|
29
31
|
|
30
32
|
it("should render an empty image if the image is not loaded yet", async () => {
|
31
|
-
const original = FileStream.create({ owner: account.
|
33
|
+
const original = FileStream.create({ owner: account.$jazz.owner });
|
32
34
|
original.start({ mimeType: "image/jpeg" });
|
33
35
|
// Don't end original, so it has no chunks
|
34
36
|
|
@@ -44,7 +46,7 @@ describe("Image", async () => {
|
|
44
46
|
);
|
45
47
|
|
46
48
|
const { container } = renderWithAccount({
|
47
|
-
imageId: im.id,
|
49
|
+
imageId: im.$jazz.id,
|
48
50
|
alt: "test",
|
49
51
|
});
|
50
52
|
|
@@ -60,7 +62,7 @@ describe("Image", async () => {
|
|
60
62
|
const placeholderDataUrl =
|
61
63
|
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";
|
62
64
|
|
63
|
-
const original = FileStream.create({ owner: account.
|
65
|
+
const original = FileStream.create({ owner: account.$jazz.owner });
|
64
66
|
original.start({ mimeType: "image/jpeg" });
|
65
67
|
// Don't end original, so it has no chunks
|
66
68
|
|
@@ -77,7 +79,7 @@ describe("Image", async () => {
|
|
77
79
|
);
|
78
80
|
|
79
81
|
const { container } = renderWithAccount({
|
80
|
-
imageId: im.id,
|
82
|
+
imageId: im.$jazz.id,
|
81
83
|
alt: "test",
|
82
84
|
});
|
83
85
|
|
@@ -108,7 +110,7 @@ describe("Image", async () => {
|
|
108
110
|
);
|
109
111
|
|
110
112
|
renderWithAccount({
|
111
|
-
imageId: im.id,
|
113
|
+
imageId: im.$jazz.id,
|
112
114
|
alt: "test-loading",
|
113
115
|
});
|
114
116
|
|
@@ -136,7 +138,7 @@ describe("Image", async () => {
|
|
136
138
|
);
|
137
139
|
|
138
140
|
const { container } = renderWithAccount({
|
139
|
-
imageId: im.id,
|
141
|
+
imageId: im.$jazz.id,
|
140
142
|
alt: "test",
|
141
143
|
});
|
142
144
|
|
@@ -159,7 +161,7 @@ describe("Image", async () => {
|
|
159
161
|
);
|
160
162
|
|
161
163
|
const { container } = renderWithAccount({
|
162
|
-
imageId: im.id,
|
164
|
+
imageId: im.$jazz.id,
|
163
165
|
alt: "test",
|
164
166
|
width: "original",
|
165
167
|
height: "original",
|
@@ -184,7 +186,7 @@ describe("Image", async () => {
|
|
184
186
|
);
|
185
187
|
|
186
188
|
const { container } = renderWithAccount({
|
187
|
-
imageId: im.id,
|
189
|
+
imageId: im.$jazz.id,
|
188
190
|
alt: "test",
|
189
191
|
width: "original",
|
190
192
|
height: 300,
|
@@ -209,7 +211,7 @@ describe("Image", async () => {
|
|
209
211
|
);
|
210
212
|
|
211
213
|
const { container } = renderWithAccount({
|
212
|
-
imageId: im.id,
|
214
|
+
imageId: im.$jazz.id,
|
213
215
|
alt: "test",
|
214
216
|
width: 50,
|
215
217
|
});
|
@@ -233,7 +235,7 @@ describe("Image", async () => {
|
|
233
235
|
);
|
234
236
|
|
235
237
|
const { container } = renderWithAccount({
|
236
|
-
imageId: im.id,
|
238
|
+
imageId: im.$jazz.id,
|
237
239
|
alt: "test",
|
238
240
|
height: 50,
|
239
241
|
});
|
@@ -257,7 +259,7 @@ describe("Image", async () => {
|
|
257
259
|
);
|
258
260
|
|
259
261
|
const { container } = renderWithAccount({
|
260
|
-
imageId: im.id,
|
262
|
+
imageId: im.$jazz.id,
|
261
263
|
alt: "test",
|
262
264
|
class: "test-class",
|
263
265
|
});
|
@@ -292,11 +294,11 @@ describe("Image", async () => {
|
|
292
294
|
},
|
293
295
|
);
|
294
296
|
|
295
|
-
im
|
296
|
-
im
|
297
|
+
im.$jazz.set("500x500", original);
|
298
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
297
299
|
|
298
300
|
const { container } = renderWithAccount({
|
299
|
-
imageId: im.id,
|
301
|
+
imageId: im.$jazz.id,
|
300
302
|
alt: "test-progressive",
|
301
303
|
width: 300,
|
302
304
|
});
|
@@ -333,11 +335,11 @@ describe("Image", async () => {
|
|
333
335
|
},
|
334
336
|
);
|
335
337
|
|
336
|
-
im
|
337
|
-
im
|
338
|
+
im.$jazz.set("1920x1080", original);
|
339
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
338
340
|
|
339
341
|
const { container } = renderWithAccount({
|
340
|
-
imageId: im.id,
|
342
|
+
imageId: im.$jazz.id,
|
341
343
|
alt: "test-progressive",
|
342
344
|
width: 1024,
|
343
345
|
});
|
@@ -351,7 +353,7 @@ describe("Image", async () => {
|
|
351
353
|
expect(createObjectURLSpy).toHaveBeenCalledTimes(1);
|
352
354
|
|
353
355
|
// Load higher resolution image
|
354
|
-
im
|
356
|
+
im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
|
355
357
|
|
356
358
|
await waitFor(() => {
|
357
359
|
expect((container.querySelector("img") as HTMLImageElement).src).toBe(
|
@@ -387,12 +389,12 @@ describe("Image", async () => {
|
|
387
389
|
},
|
388
390
|
);
|
389
391
|
|
390
|
-
im
|
391
|
-
im
|
392
|
-
im
|
392
|
+
im.$jazz.set("100x100", original);
|
393
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
394
|
+
im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
|
393
395
|
|
394
396
|
const { container } = renderWithAccount({
|
395
|
-
imageId: im.id,
|
397
|
+
imageId: im.$jazz.id,
|
396
398
|
alt: "test-progressive",
|
397
399
|
width: 256,
|
398
400
|
});
|
@@ -428,11 +430,11 @@ describe("Image", async () => {
|
|
428
430
|
},
|
429
431
|
);
|
430
432
|
|
431
|
-
im
|
432
|
-
im
|
433
|
+
im.$jazz.set("100x100", original);
|
434
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
433
435
|
|
434
436
|
const { container } = renderWithAccount({
|
435
|
-
imageId: im.id,
|
437
|
+
imageId: im.$jazz.id,
|
436
438
|
alt: "test-progressive",
|
437
439
|
width: 100,
|
438
440
|
});
|
@@ -467,11 +469,11 @@ describe("Image", async () => {
|
|
467
469
|
owner: account,
|
468
470
|
},
|
469
471
|
);
|
470
|
-
im
|
471
|
-
im
|
472
|
+
im.$jazz.set("256x256", original);
|
473
|
+
im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
|
472
474
|
|
473
475
|
const { container, rerender } = renderWithAccount({
|
474
|
-
imageId: im.id,
|
476
|
+
imageId: im.$jazz.id,
|
475
477
|
alt: "test-dynamic",
|
476
478
|
width: 256,
|
477
479
|
height: 256,
|
@@ -486,7 +488,7 @@ describe("Image", async () => {
|
|
486
488
|
expect(createObjectURLSpy).toHaveBeenCalledTimes(1);
|
487
489
|
|
488
490
|
rerender({
|
489
|
-
imageId: im.id,
|
491
|
+
imageId: im.$jazz.id,
|
490
492
|
alt: "test-dynamic",
|
491
493
|
width: 1024,
|
492
494
|
height: 1024,
|
@@ -516,7 +518,7 @@ describe("Image", async () => {
|
|
516
518
|
);
|
517
519
|
|
518
520
|
const { container } = renderWithAccount({
|
519
|
-
imageId: im.id,
|
521
|
+
imageId: im.$jazz.id,
|
520
522
|
alt: "test",
|
521
523
|
loading: "lazy",
|
522
524
|
});
|
@@ -548,7 +550,7 @@ describe("Image", async () => {
|
|
548
550
|
);
|
549
551
|
|
550
552
|
const { container } = renderWithAccount({
|
551
|
-
imageId: im.id,
|
553
|
+
imageId: im.$jazz.id,
|
552
554
|
alt: "test",
|
553
555
|
loading: "lazy",
|
554
556
|
});
|
@@ -64,13 +64,13 @@ export class DemoAuth {
|
|
64
64
|
throw new Error("No credentials found");
|
65
65
|
}
|
66
66
|
|
67
|
-
const currentAccount = await Account.getMe().ensureLoaded({
|
67
|
+
const currentAccount = await Account.getMe().$jazz.ensureLoaded({
|
68
68
|
resolve: {
|
69
69
|
profile: true,
|
70
70
|
},
|
71
71
|
});
|
72
72
|
|
73
|
-
currentAccount.profile.name
|
73
|
+
currentAccount.profile.$jazz.set("name", username);
|
74
74
|
|
75
75
|
await this.authSecretStorage.set({
|
76
76
|
accountID: credentials.accountID,
|
@@ -82,13 +82,13 @@ export class PassphraseAuth {
|
|
82
82
|
});
|
83
83
|
|
84
84
|
if (name?.trim()) {
|
85
|
-
const currentAccount = await Account.getMe().ensureLoaded({
|
85
|
+
const currentAccount = await Account.getMe().$jazz.ensureLoaded({
|
86
86
|
resolve: {
|
87
87
|
profile: true,
|
88
88
|
},
|
89
89
|
});
|
90
90
|
|
91
|
-
currentAccount.profile.name
|
91
|
+
currentAccount.profile.$jazz.set("name", name);
|
92
92
|
}
|
93
93
|
|
94
94
|
return passphrase;
|
@@ -145,7 +145,7 @@ export class JazzClerkAuth {
|
|
145
145
|
} satisfies ClerkCredentials,
|
146
146
|
});
|
147
147
|
|
148
|
-
const currentAccount = await Account.getMe().ensureLoaded({
|
148
|
+
const currentAccount = await Account.getMe().$jazz.ensureLoaded({
|
149
149
|
resolve: {
|
150
150
|
profile: true,
|
151
151
|
},
|
@@ -154,7 +154,7 @@ export class JazzClerkAuth {
|
|
154
154
|
const username = getClerkUsername(clerkClient);
|
155
155
|
|
156
156
|
if (username) {
|
157
|
-
currentAccount.profile.name
|
157
|
+
currentAccount.profile.$jazz.set("name", username);
|
158
158
|
}
|
159
159
|
|
160
160
|
await JazzClerkAuth.loadClerkAuthData(
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { CoFeed } from "./coFeed";
|
2
|
+
import { CoList } from "./coList";
|
3
|
+
import { CoMap, CoMapInit } from "./coMap";
|
4
|
+
import { CoPlainText } from "./coPlainText";
|
5
|
+
import { CoRichText } from "./coRichText";
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Returns the type of values that can be used to initialize a field of the provided type.
|
9
|
+
*
|
10
|
+
* For CoValue references, either a CoValue of the same type, or a plain JSON value that can be
|
11
|
+
* converted to the CoValue type are allowed.
|
12
|
+
*/
|
13
|
+
// Note: we don't define this type as V | ... because it prevents TS from inlining the type
|
14
|
+
export type CoFieldInit<V> = V extends CoMap
|
15
|
+
? V | CoMapInit<V>
|
16
|
+
: V extends CoList<infer T> | CoFeed<infer T>
|
17
|
+
? V | ReadonlyArray<CoFieldInit<T>>
|
18
|
+
: V extends CoPlainText | CoRichText
|
19
|
+
? V | string
|
20
|
+
: V;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { ControlledAccount,
|
1
|
+
import { ControlledAccount, LocalNode, type RawCoValue } from "cojson";
|
2
2
|
import { CoreCoValueSchema } from "../implementation/zodSchema/schemaTypes/CoValueSchema.js";
|
3
3
|
import {
|
4
4
|
AnonymousJazzAgent,
|
@@ -7,72 +7,33 @@ import {
|
|
7
7
|
CoValueFromRaw,
|
8
8
|
ID,
|
9
9
|
RegisteredSchemas,
|
10
|
-
accessChildById,
|
11
10
|
coValueClassFromCoValueClassOrSchema,
|
12
11
|
coValuesCache,
|
13
12
|
inspect,
|
14
|
-
isCoValueSchema,
|
15
13
|
} from "../internal.js";
|
16
|
-
import
|
17
|
-
Account,
|
14
|
+
import {
|
18
15
|
CoValueClassOrSchema,
|
19
16
|
Group,
|
20
17
|
InstanceOfSchemaCoValuesNullable,
|
18
|
+
TypeSym,
|
21
19
|
} from "../internal.js";
|
22
20
|
|
23
21
|
/** @internal */
|
22
|
+
export abstract class CoValueBase implements CoValue {
|
23
|
+
declare [TypeSym]: string;
|
24
24
|
|
25
|
-
|
26
|
-
declare id: ID<this>;
|
27
|
-
declare _type: string;
|
28
|
-
declare _raw: RawCoValue;
|
29
|
-
/** @category Internals */
|
30
|
-
declare _instanceID: string;
|
31
|
-
|
32
|
-
get _owner(): Account | Group {
|
33
|
-
const schema =
|
34
|
-
this._raw.group instanceof RawAccount
|
35
|
-
? RegisteredSchemas["Account"]
|
36
|
-
: RegisteredSchemas["Group"];
|
37
|
-
|
38
|
-
return accessChildById(this, this._raw.group.id, {
|
39
|
-
ref: schema,
|
40
|
-
optional: false,
|
41
|
-
});
|
42
|
-
}
|
43
|
-
|
44
|
-
/** @private */
|
45
|
-
get _loadedAs() {
|
46
|
-
const agent = this._raw.core.node.getCurrentAgent();
|
47
|
-
|
48
|
-
if (agent instanceof ControlledAccount) {
|
49
|
-
return coValuesCache.get(agent.account, () =>
|
50
|
-
coValueClassFromCoValueClassOrSchema(
|
51
|
-
RegisteredSchemas["Account"],
|
52
|
-
).fromRaw(agent.account),
|
53
|
-
);
|
54
|
-
}
|
55
|
-
|
56
|
-
return new AnonymousJazzAgent(this._raw.core.node);
|
57
|
-
}
|
58
|
-
|
59
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
60
|
-
constructor(..._args: any) {
|
61
|
-
Object.defineProperty(this, "_instanceID", {
|
62
|
-
value: `instance-${Math.random().toString(36).slice(2)}`,
|
63
|
-
enumerable: false,
|
64
|
-
});
|
65
|
-
}
|
25
|
+
declare abstract $jazz: CoValueJazzApi<this>;
|
66
26
|
|
67
27
|
/** @category Internals */
|
68
28
|
static fromRaw<V extends CoValue>(this: CoValueClass<V>, raw: RawCoValue): V {
|
69
29
|
return new this({ fromRaw: raw });
|
70
30
|
}
|
31
|
+
|
71
32
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
72
33
|
toJSON(): object | any[] | string {
|
73
34
|
return {
|
74
|
-
id: this.id,
|
75
|
-
type: this
|
35
|
+
id: this.$jazz.id,
|
36
|
+
type: this[TypeSym],
|
76
37
|
error: "unknown CoValue class",
|
77
38
|
};
|
78
39
|
}
|
@@ -80,21 +41,40 @@ export class CoValueBase implements CoValue {
|
|
80
41
|
[inspect]() {
|
81
42
|
return this.toJSON();
|
82
43
|
}
|
44
|
+
}
|
45
|
+
|
46
|
+
export abstract class CoValueJazzApi<V extends CoValue> {
|
47
|
+
/** @category Internals */
|
48
|
+
declare _instanceID: string;
|
83
49
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
? NonNullable<InstanceOfSchemaCoValuesNullable<S>>
|
91
|
-
: never {
|
92
|
-
const cl = isCoValueSchema(schema) ? schema.getCoValueClass() : schema;
|
50
|
+
constructor(private coValue: V) {
|
51
|
+
Object.defineProperty(this, "_instanceID", {
|
52
|
+
value: `instance-${Math.random().toString(36).slice(2)}`,
|
53
|
+
enumerable: false,
|
54
|
+
});
|
55
|
+
}
|
93
56
|
|
94
|
-
|
95
|
-
|
57
|
+
abstract get id(): ID<V>;
|
58
|
+
abstract get raw(): RawCoValue;
|
59
|
+
abstract get owner(): Group | undefined;
|
60
|
+
|
61
|
+
/** @internal */
|
62
|
+
get localNode(): LocalNode {
|
63
|
+
return this.raw.core.node;
|
64
|
+
}
|
65
|
+
|
66
|
+
/** @private */
|
67
|
+
get loadedAs() {
|
68
|
+
const agent = this.localNode.getCurrentAgent();
|
69
|
+
|
70
|
+
if (agent instanceof ControlledAccount) {
|
71
|
+
return coValuesCache.get(agent.account, () =>
|
72
|
+
coValueClassFromCoValueClassOrSchema(
|
73
|
+
RegisteredSchemas["Account"],
|
74
|
+
).fromRaw(agent.account),
|
75
|
+
);
|
96
76
|
}
|
97
77
|
|
98
|
-
return
|
78
|
+
return new AnonymousJazzAgent(this.localNode);
|
99
79
|
}
|
100
80
|
}
|