jazz-tools 0.17.14 → 0.18.1
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 +60 -46
- package/CHANGELOG.md +41 -0
- package/dist/better-auth/auth/client.d.ts +29 -0
- package/dist/better-auth/auth/client.d.ts.map +1 -0
- package/dist/better-auth/auth/client.js +127 -0
- package/dist/better-auth/auth/client.js.map +1 -0
- package/dist/better-auth/auth/react.d.ts +2170 -0
- package/dist/better-auth/auth/react.d.ts.map +1 -0
- package/dist/better-auth/auth/react.js +40 -0
- package/dist/better-auth/auth/react.js.map +1 -0
- package/dist/better-auth/auth/server.d.ts +14 -0
- package/dist/better-auth/auth/server.d.ts.map +1 -0
- package/dist/better-auth/auth/server.js +198 -0
- package/dist/better-auth/auth/server.js.map +1 -0
- package/dist/better-auth/auth/tests/client.test.d.ts +2 -0
- package/dist/better-auth/auth/tests/client.test.d.ts.map +1 -0
- package/dist/better-auth/auth/tests/server.test.d.ts +2 -0
- package/dist/better-auth/auth/tests/server.test.d.ts.map +1 -0
- package/dist/browser/index.js +2 -2
- package/dist/browser/index.js.map +1 -1
- package/dist/{chunk-LZOF6WP5.js → chunk-IERUTUXB.js} +1336 -1017
- package/dist/chunk-IERUTUXB.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 +4675 -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 +101 -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 +210 -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 +3 -3
- 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 +23 -4
- package/src/better-auth/auth/client.ts +169 -0
- package/src/better-auth/auth/react.tsx +105 -0
- package/src/better-auth/auth/server.ts +250 -0
- package/src/better-auth/auth/tests/client.test.ts +249 -0
- package/src/better-auth/auth/tests/server.test.ts +226 -0
- 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 +311 -232
- package/src/tools/coValues/coFeed.ts +185 -153
- package/src/tools/coValues/coList.ts +507 -334
- package/src/tools/coValues/coMap.ts +434 -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 +3 -3
- 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 +70 -59
- package/src/tools/tests/PassphraseAuth.test.ts +2 -2
- package/src/tools/tests/account.test.ts +188 -67
- 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 +459 -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 +7 -7
- 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 +7 -11
- 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/tsup.config.ts +9 -0
- 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
@@ -27,7 +27,7 @@ describe("Image", async () => {
|
|
27
27
|
});
|
28
28
|
|
29
29
|
it("should render an empty image if the image is not loaded yet", async () => {
|
30
|
-
const original = FileStream.create({ owner: account
|
30
|
+
const original = FileStream.create({ owner: account });
|
31
31
|
original.start({ mimeType: "image/jpeg" });
|
32
32
|
// Don't end original, so it has no chunks
|
33
33
|
|
@@ -42,7 +42,7 @@ describe("Image", async () => {
|
|
42
42
|
},
|
43
43
|
);
|
44
44
|
|
45
|
-
const { container } = render(<Image imageId={im.id} alt="test" />, {
|
45
|
+
const { container } = render(<Image imageId={im.$jazz.id} alt="test" />, {
|
46
46
|
account,
|
47
47
|
});
|
48
48
|
|
@@ -58,7 +58,7 @@ describe("Image", async () => {
|
|
58
58
|
const placeholderDataUrl =
|
59
59
|
"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNk+A8AAQUBAScY42YAAAAASUVORK5CYII=";
|
60
60
|
|
61
|
-
const original = FileStream.create({ owner: account
|
61
|
+
const original = FileStream.create({ owner: account });
|
62
62
|
original.start({ mimeType: "image/jpeg" });
|
63
63
|
// Don't end original, so it has no chunks
|
64
64
|
|
@@ -74,7 +74,7 @@ describe("Image", async () => {
|
|
74
74
|
},
|
75
75
|
);
|
76
76
|
|
77
|
-
const { container } = render(<Image imageId={im.id} alt="test" />, {
|
77
|
+
const { container } = render(<Image imageId={im.$jazz.id} alt="test" />, {
|
78
78
|
account,
|
79
79
|
});
|
80
80
|
|
@@ -104,7 +104,7 @@ describe("Image", async () => {
|
|
104
104
|
},
|
105
105
|
);
|
106
106
|
|
107
|
-
render(<Image imageId={im.id} alt="test-loading" />, { account });
|
107
|
+
render(<Image imageId={im.$jazz.id} alt="test-loading" />, { account });
|
108
108
|
|
109
109
|
await waitFor(() => {
|
110
110
|
expect(
|
@@ -129,7 +129,7 @@ describe("Image", async () => {
|
|
129
129
|
},
|
130
130
|
);
|
131
131
|
|
132
|
-
const { container } = render(<Image imageId={im.id} alt="test" />, {
|
132
|
+
const { container } = render(<Image imageId={im.$jazz.id} alt="test" />, {
|
133
133
|
account,
|
134
134
|
});
|
135
135
|
|
@@ -152,7 +152,12 @@ describe("Image", async () => {
|
|
152
152
|
);
|
153
153
|
|
154
154
|
const { container } = render(
|
155
|
-
<Image
|
155
|
+
<Image
|
156
|
+
imageId={im.$jazz.id}
|
157
|
+
alt="test"
|
158
|
+
width="original"
|
159
|
+
height="original"
|
160
|
+
/>,
|
156
161
|
{
|
157
162
|
account,
|
158
163
|
},
|
@@ -177,7 +182,12 @@ describe("Image", async () => {
|
|
177
182
|
);
|
178
183
|
|
179
184
|
const { container } = render(
|
180
|
-
<Image
|
185
|
+
<Image
|
186
|
+
imageId={im.$jazz.id}
|
187
|
+
alt="test"
|
188
|
+
width="original"
|
189
|
+
height={300}
|
190
|
+
/>,
|
181
191
|
{
|
182
192
|
account,
|
183
193
|
},
|
@@ -202,7 +212,7 @@ describe("Image", async () => {
|
|
202
212
|
);
|
203
213
|
|
204
214
|
const { container } = render(
|
205
|
-
<Image imageId={im.id} alt="test" width={50} />,
|
215
|
+
<Image imageId={im.$jazz.id} alt="test" width={50} />,
|
206
216
|
{ account },
|
207
217
|
);
|
208
218
|
|
@@ -225,7 +235,7 @@ describe("Image", async () => {
|
|
225
235
|
);
|
226
236
|
|
227
237
|
const { container } = render(
|
228
|
-
<Image imageId={im.id} alt="test" height={50} />,
|
238
|
+
<Image imageId={im.$jazz.id} alt="test" height={50} />,
|
229
239
|
{ account },
|
230
240
|
);
|
231
241
|
|
@@ -248,7 +258,7 @@ describe("Image", async () => {
|
|
248
258
|
);
|
249
259
|
|
250
260
|
const { container } = render(
|
251
|
-
<Image imageId={im.id} alt="test" className="test-class" />,
|
261
|
+
<Image imageId={im.$jazz.id} alt="test" className="test-class" />,
|
252
262
|
{ account },
|
253
263
|
);
|
254
264
|
|
@@ -282,11 +292,11 @@ describe("Image", async () => {
|
|
282
292
|
},
|
283
293
|
);
|
284
294
|
|
285
|
-
im
|
286
|
-
im
|
295
|
+
im.$jazz.set("500x500", original);
|
296
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
287
297
|
|
288
298
|
const { container } = render(
|
289
|
-
<Image imageId={im.id} alt="test-progressive" width={300} />,
|
299
|
+
<Image imageId={im.$jazz.id} alt="test-progressive" width={300} />,
|
290
300
|
{ account },
|
291
301
|
);
|
292
302
|
|
@@ -322,11 +332,11 @@ describe("Image", async () => {
|
|
322
332
|
},
|
323
333
|
);
|
324
334
|
|
325
|
-
im
|
326
|
-
im
|
335
|
+
im.$jazz.set("1920x1080", original);
|
336
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
327
337
|
|
328
338
|
const { container } = render(
|
329
|
-
<Image imageId={im.id} alt="test-progressive" width={1024} />,
|
339
|
+
<Image imageId={im.$jazz.id} alt="test-progressive" width={1024} />,
|
330
340
|
{ account },
|
331
341
|
);
|
332
342
|
|
@@ -339,7 +349,7 @@ describe("Image", async () => {
|
|
339
349
|
expect(createObjectURLSpy).toHaveBeenCalledTimes(1);
|
340
350
|
|
341
351
|
// Load higher resolution image
|
342
|
-
im
|
352
|
+
im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
|
343
353
|
|
344
354
|
await waitFor(() => {
|
345
355
|
expect((container.querySelector("img") as HTMLImageElement).src).toBe(
|
@@ -375,12 +385,12 @@ describe("Image", async () => {
|
|
375
385
|
},
|
376
386
|
);
|
377
387
|
|
378
|
-
im
|
379
|
-
im
|
380
|
-
im
|
388
|
+
im.$jazz.set("100x100", original);
|
389
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
390
|
+
im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
|
381
391
|
|
382
392
|
const { container } = render(
|
383
|
-
<Image imageId={im.id} alt="test-progressive" width={256} />,
|
393
|
+
<Image imageId={im.$jazz.id} alt="test-progressive" width={256} />,
|
384
394
|
{ account },
|
385
395
|
);
|
386
396
|
|
@@ -415,11 +425,11 @@ describe("Image", async () => {
|
|
415
425
|
},
|
416
426
|
);
|
417
427
|
|
418
|
-
im
|
419
|
-
im
|
428
|
+
im.$jazz.set("100x100", original);
|
429
|
+
im.$jazz.set("256x256", await createDummyFileStream(256, account));
|
420
430
|
|
421
431
|
const { container } = render(
|
422
|
-
<Image imageId={im.id} alt="test-progressive" width={100} />,
|
432
|
+
<Image imageId={im.$jazz.id} alt="test-progressive" width={100} />,
|
423
433
|
{ account },
|
424
434
|
);
|
425
435
|
|
@@ -453,11 +463,16 @@ describe("Image", async () => {
|
|
453
463
|
owner: account,
|
454
464
|
},
|
455
465
|
);
|
456
|
-
im
|
457
|
-
im
|
466
|
+
im.$jazz.set("256x256", original);
|
467
|
+
im.$jazz.set("1024x1024", await createDummyFileStream(1024, account));
|
458
468
|
|
459
469
|
const { container, rerender } = render(
|
460
|
-
<Image
|
470
|
+
<Image
|
471
|
+
imageId={im.$jazz.id}
|
472
|
+
alt="test-dynamic"
|
473
|
+
width={256}
|
474
|
+
height={256}
|
475
|
+
/>,
|
461
476
|
{ account },
|
462
477
|
);
|
463
478
|
|
@@ -470,7 +485,12 @@ describe("Image", async () => {
|
|
470
485
|
expect(createObjectURLSpy).toHaveBeenCalledTimes(1);
|
471
486
|
|
472
487
|
rerender(
|
473
|
-
<Image
|
488
|
+
<Image
|
489
|
+
imageId={im.$jazz.id}
|
490
|
+
alt="test-dynamic"
|
491
|
+
width={1024}
|
492
|
+
height={1024}
|
493
|
+
/>,
|
474
494
|
);
|
475
495
|
|
476
496
|
// After prop change, should load 1024x1024
|
@@ -499,7 +519,7 @@ describe("Image", async () => {
|
|
499
519
|
const ref = { current: null as HTMLImageElement | null };
|
500
520
|
|
501
521
|
const { container } = render(
|
502
|
-
<Image imageId={im.id} alt="test" ref={ref} />,
|
522
|
+
<Image imageId={im.$jazz.id} alt="test" ref={ref} />,
|
503
523
|
{ account },
|
504
524
|
);
|
505
525
|
|
@@ -523,7 +543,7 @@ describe("Image", async () => {
|
|
523
543
|
);
|
524
544
|
|
525
545
|
const { container } = render(
|
526
|
-
<Image imageId={im.id} alt="test" loading="lazy" />,
|
546
|
+
<Image imageId={im.$jazz.id} alt="test" loading="lazy" />,
|
527
547
|
{ account },
|
528
548
|
);
|
529
549
|
|
@@ -554,7 +574,7 @@ describe("Image", async () => {
|
|
554
574
|
);
|
555
575
|
|
556
576
|
const { container } = render(
|
557
|
-
<Image imageId={im.id} alt="test" loading="lazy" />,
|
577
|
+
<Image imageId={im.$jazz.id} alt="test" loading="lazy" />,
|
558
578
|
{ account },
|
559
579
|
);
|
560
580
|
|
package/src/react-core/hooks.ts
CHANGED
@@ -24,6 +24,7 @@ import {
|
|
24
24
|
} from "jazz-tools";
|
25
25
|
import { JazzContext, JazzContextManagerContext } from "./provider.js";
|
26
26
|
import { getCurrentAccountFromContextManager } from "./utils.js";
|
27
|
+
import { TypeSym } from "../tools/internal.js";
|
27
28
|
|
28
29
|
export function useJazzContext<Acc extends Account>() {
|
29
30
|
const value = useContext(JazzContext) as JazzContextType<Acc>;
|
@@ -274,7 +275,7 @@ function useAccountSubscription<
|
|
274
275
|
const createSubscription = () => {
|
275
276
|
const agent = getCurrentAccountFromContextManager(contextManager);
|
276
277
|
|
277
|
-
if (agent
|
278
|
+
if (agent[TypeSym] === "Anonymous") {
|
278
279
|
return {
|
279
280
|
subscription: null,
|
280
281
|
contextManager,
|
@@ -286,10 +287,15 @@ function useAccountSubscription<
|
|
286
287
|
const resolve: any = options?.resolve ?? true;
|
287
288
|
|
288
289
|
const node = contextManager.getCurrentValue()!.node;
|
289
|
-
const subscription = new SubscriptionScope<any>(
|
290
|
-
|
291
|
-
|
292
|
-
|
290
|
+
const subscription = new SubscriptionScope<any>(
|
291
|
+
node,
|
292
|
+
resolve,
|
293
|
+
agent.$jazz.id,
|
294
|
+
{
|
295
|
+
ref: coValueClassFromCoValueClassOrSchema(Schema),
|
296
|
+
optional: true,
|
297
|
+
},
|
298
|
+
);
|
293
299
|
|
294
300
|
return {
|
295
301
|
subscription,
|
@@ -37,11 +37,8 @@ describe("useAccount", () => {
|
|
37
37
|
profile: co.profile(),
|
38
38
|
})
|
39
39
|
.withMigration((account, creationProps) => {
|
40
|
-
if (!account.
|
41
|
-
account.root
|
42
|
-
{ value: "123" },
|
43
|
-
{ owner: account },
|
44
|
-
);
|
40
|
+
if (!account.$jazz.refs.root) {
|
41
|
+
account.$jazz.set("root", { value: "123" });
|
45
42
|
}
|
46
43
|
});
|
47
44
|
|
@@ -79,13 +76,13 @@ describe("useAccount", () => {
|
|
79
76
|
const account = useAccount();
|
80
77
|
|
81
78
|
if (account.me) {
|
82
|
-
if (!accounts.includes(account.me.id)) {
|
83
|
-
accounts.push(account.me.id);
|
79
|
+
if (!accounts.includes(account.me.$jazz.id)) {
|
80
|
+
accounts.push(account.me.$jazz.id);
|
84
81
|
}
|
85
82
|
|
86
83
|
updates.push({
|
87
84
|
isAuthenticated,
|
88
|
-
accountIndex: accounts.indexOf(account.me.id),
|
85
|
+
accountIndex: accounts.indexOf(account.me.$jazz.id),
|
89
86
|
});
|
90
87
|
}
|
91
88
|
|
@@ -100,14 +97,14 @@ describe("useAccount", () => {
|
|
100
97
|
expect(result.current?.isAuthenticated).toBe(true);
|
101
98
|
expect(result.current?.account?.me).toBeDefined();
|
102
99
|
|
103
|
-
const id = result.current?.account?.me
|
100
|
+
const id = result.current?.account?.me?.$jazz.id;
|
104
101
|
|
105
102
|
await act(async () => {
|
106
103
|
await result.current?.account?.logOut();
|
107
104
|
});
|
108
105
|
|
109
106
|
expect(result.current?.isAuthenticated).toBe(false);
|
110
|
-
expect(result.current?.account?.me
|
107
|
+
expect(result.current?.account?.me?.$jazz.id).not.toBe(id);
|
111
108
|
|
112
109
|
expect(updates).toMatchInlineSnapshot(`
|
113
110
|
[
|
@@ -141,13 +138,13 @@ describe("useAccount", () => {
|
|
141
138
|
const contextManager = useJazzContextManager();
|
142
139
|
|
143
140
|
if (account.me) {
|
144
|
-
if (!accounts.includes(account.me.id)) {
|
145
|
-
accounts.push(account.me.id);
|
141
|
+
if (!accounts.includes(account.me.$jazz.id)) {
|
142
|
+
accounts.push(account.me.$jazz.id);
|
146
143
|
}
|
147
144
|
|
148
145
|
updates.push({
|
149
146
|
isAuthenticated,
|
150
|
-
accountIndex: accounts.indexOf(account.me.id),
|
147
|
+
accountIndex: accounts.indexOf(account.me.$jazz.id),
|
151
148
|
});
|
152
149
|
}
|
153
150
|
|
@@ -162,18 +159,18 @@ describe("useAccount", () => {
|
|
162
159
|
expect(result.current?.isAuthenticated).toBe(false);
|
163
160
|
expect(result.current?.account?.me).toBeDefined();
|
164
161
|
|
165
|
-
const id = result.current?.account?.me
|
162
|
+
const id = result.current?.account?.me?.$jazz.id;
|
166
163
|
|
167
164
|
await act(async () => {
|
168
165
|
await result.current?.contextManager?.authenticate({
|
169
|
-
accountID: accountToAuthenticate.id,
|
166
|
+
accountID: accountToAuthenticate.$jazz.id,
|
170
167
|
accountSecret:
|
171
|
-
accountToAuthenticate.
|
168
|
+
accountToAuthenticate.$jazz.localNode.getCurrentAgent().agentSecret,
|
172
169
|
});
|
173
170
|
});
|
174
171
|
|
175
172
|
expect(result.current?.isAuthenticated).toBe(true);
|
176
|
-
expect(result.current?.account?.me
|
173
|
+
expect(result.current?.account?.me?.$jazz.id).not.toBe(id);
|
177
174
|
|
178
175
|
expect(updates).toMatchInlineSnapshot(`
|
179
176
|
[
|
@@ -200,11 +197,8 @@ describe("useAccount", () => {
|
|
200
197
|
profile: co.profile(),
|
201
198
|
})
|
202
199
|
.withMigration((account, creationProps) => {
|
203
|
-
if (!account.
|
204
|
-
account.root
|
205
|
-
{ value: "123" },
|
206
|
-
{ owner: account },
|
207
|
-
);
|
200
|
+
if (!account.$jazz.refs.root) {
|
201
|
+
account.$jazz.set("root", { value: "123" });
|
208
202
|
}
|
209
203
|
});
|
210
204
|
|
@@ -40,7 +40,7 @@ describe("useCoState", () => {
|
|
40
40
|
value: "123",
|
41
41
|
});
|
42
42
|
|
43
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id, {}), {
|
43
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id, {}), {
|
44
44
|
account,
|
45
45
|
});
|
46
46
|
|
@@ -80,14 +80,14 @@ describe("useCoState", () => {
|
|
80
80
|
value: "123",
|
81
81
|
});
|
82
82
|
|
83
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id, {}), {
|
83
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id, {}), {
|
84
84
|
account,
|
85
85
|
});
|
86
86
|
|
87
87
|
expect(result.current?.value).toBe("123");
|
88
88
|
|
89
89
|
act(() => {
|
90
|
-
map.value
|
90
|
+
map.$jazz.set("value", "456");
|
91
91
|
});
|
92
92
|
|
93
93
|
expect(result.current?.value).toBe("456");
|
@@ -116,7 +116,7 @@ describe("useCoState", () => {
|
|
116
116
|
|
117
117
|
const { result } = renderHook(
|
118
118
|
() =>
|
119
|
-
useCoState(TestMap, map.id, {
|
119
|
+
useCoState(TestMap, map.$jazz.id, {
|
120
120
|
resolve: {
|
121
121
|
nested: true,
|
122
122
|
},
|
@@ -151,7 +151,7 @@ describe("useCoState", () => {
|
|
151
151
|
}),
|
152
152
|
});
|
153
153
|
|
154
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id, {}), {
|
154
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id, {}), {
|
155
155
|
account,
|
156
156
|
});
|
157
157
|
|
@@ -172,11 +172,11 @@ describe("useCoState", () => {
|
|
172
172
|
isCurrentActiveAccount: true,
|
173
173
|
});
|
174
174
|
|
175
|
-
for (const peer of account.
|
175
|
+
for (const peer of account.$jazz.localNode.syncManager.getClientPeers()) {
|
176
176
|
peer.gracefulShutdown();
|
177
177
|
}
|
178
178
|
|
179
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id), {
|
179
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id), {
|
180
180
|
account,
|
181
181
|
});
|
182
182
|
|
@@ -205,7 +205,7 @@ describe("useCoState", () => {
|
|
205
205
|
isCurrentActiveAccount: true,
|
206
206
|
});
|
207
207
|
|
208
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id), {
|
208
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id), {
|
209
209
|
account,
|
210
210
|
});
|
211
211
|
|
@@ -237,7 +237,7 @@ describe("useCoState", () => {
|
|
237
237
|
isCurrentActiveAccount: true,
|
238
238
|
});
|
239
239
|
|
240
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id), {
|
240
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id), {
|
241
241
|
account,
|
242
242
|
});
|
243
243
|
|
@@ -268,7 +268,7 @@ describe("useCoState", () => {
|
|
268
268
|
isCurrentActiveAccount: true,
|
269
269
|
});
|
270
270
|
|
271
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id), {
|
271
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id), {
|
272
272
|
account,
|
273
273
|
});
|
274
274
|
|
@@ -307,11 +307,11 @@ describe("useCoState", () => {
|
|
307
307
|
isCurrentActiveAccount: true,
|
308
308
|
});
|
309
309
|
|
310
|
-
await account.waitForAllCoValuesSync();
|
310
|
+
await account.$jazz.waitForAllCoValuesSync();
|
311
311
|
|
312
312
|
group.addMember(account, "reader");
|
313
313
|
|
314
|
-
const { result } = renderHook(() => useCoState(TestMap, map.id), {
|
314
|
+
const { result } = renderHook(() => useCoState(TestMap, map.$jazz.id), {
|
315
315
|
account,
|
316
316
|
});
|
317
317
|
|
@@ -371,7 +371,7 @@ describe("useCoState", () => {
|
|
371
371
|
|
372
372
|
const { result } = renderHook(
|
373
373
|
() =>
|
374
|
-
useCoState(TestMap, map.id, {
|
374
|
+
useCoState(TestMap, map.$jazz.id, {
|
375
375
|
resolve: {
|
376
376
|
nested: true,
|
377
377
|
},
|
@@ -403,7 +403,7 @@ describe("useCoState", () => {
|
|
403
403
|
});
|
404
404
|
|
405
405
|
const { result } = renderHook(() =>
|
406
|
-
useCoState(TestMap, map.id as ID<CoValue>),
|
406
|
+
useCoState(TestMap, map.$jazz.id as ID<CoValue>),
|
407
407
|
);
|
408
408
|
expectTypeOf(result).toEqualTypeOf<{
|
409
409
|
current: Loaded<typeof TestMap> | null | undefined;
|
@@ -422,7 +422,7 @@ describe("useCoState", () => {
|
|
422
422
|
const { result, rerender } = renderHook(
|
423
423
|
(props) => useCoState(TestMap, props.id),
|
424
424
|
{
|
425
|
-
initialProps: { id: map.id } as { id: ID<CoValue> | undefined },
|
425
|
+
initialProps: { id: map.$jazz.id } as { id: ID<CoValue> | undefined },
|
426
426
|
},
|
427
427
|
);
|
428
428
|
|
@@ -457,7 +457,7 @@ describe("useCoState", () => {
|
|
457
457
|
renderHook(
|
458
458
|
() => {
|
459
459
|
renderCount++;
|
460
|
-
useCoState(TestList, list.id, { resolve: { $each: true } });
|
460
|
+
useCoState(TestList, list.$jazz.id, { resolve: { $each: true } });
|
461
461
|
},
|
462
462
|
{
|
463
463
|
account,
|
@@ -487,7 +487,7 @@ describe("useCoState", () => {
|
|
487
487
|
},
|
488
488
|
});
|
489
489
|
|
490
|
-
const janeOnJohn = await Account.load(jane.id, {
|
490
|
+
const janeOnJohn = await Account.load(jane.$jazz.id, {
|
491
491
|
loadAs: john,
|
492
492
|
});
|
493
493
|
|
@@ -504,7 +504,7 @@ describe("useCoState", () => {
|
|
504
504
|
);
|
505
505
|
|
506
506
|
const { result } = renderHook(
|
507
|
-
() => useCoState(Dog, dog.id)
|
507
|
+
() => useCoState(Dog, dog.$jazz.id)?.$jazz.owner.members,
|
508
508
|
{
|
509
509
|
account: john,
|
510
510
|
},
|
@@ -542,7 +542,7 @@ describe("useCoState", () => {
|
|
542
542
|
const renderings: boolean[] = [];
|
543
543
|
|
544
544
|
renderHook(() => {
|
545
|
-
const data = useCoState(Thread, thread.id, {
|
545
|
+
const data = useCoState(Thread, thread.$jazz.id, {
|
546
546
|
resolve: {
|
547
547
|
messages: {
|
548
548
|
$each: {
|
@@ -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
|
|