jazz-tools 0.7.35-guest-auth.5 → 0.7.35-guest-auth.6
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +2 -2
- package/.turbo/turbo-lint.log +1 -1
- package/CHANGELOG.md +11 -26
- package/dist/coValues/coMap.js +14 -4
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +18 -1
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/implementation/createContext.js +23 -0
- package/dist/implementation/createContext.js.map +1 -1
- package/dist/implementation/devtoolsFormatters.js +1 -0
- package/dist/implementation/devtoolsFormatters.js.map +1 -1
- package/dist/implementation/schema.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/tests/coMap.test.js +92 -1
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +37 -0
- package/dist/tests/coStream.test.js.map +1 -1
- package/dist/tests/deepLoading.test.js +7 -7
- package/dist/tests/deepLoading.test.js.map +1 -1
- package/package.json +2 -2
- package/src/coValues/coMap.ts +50 -6
- package/src/coValues/coStream.ts +26 -1
- package/src/implementation/createContext.ts +45 -7
- package/src/implementation/devtoolsFormatters.ts +1 -0
- package/src/implementation/schema.ts +1 -0
- package/src/index.ts +1 -0
- package/src/tests/coMap.test.ts +139 -1
- package/src/tests/coStream.test.ts +53 -0
- package/src/tests/deepLoading.test.ts +7 -7
@@ -443,3 +443,56 @@ describe("BinaryCoStream loading & Subscription", async () => {
|
|
443
443
|
});
|
444
444
|
});
|
445
445
|
});
|
446
|
+
|
447
|
+
describe("BinaryCoStream.loadAsBlob", async () => {
|
448
|
+
async function setup() {
|
449
|
+
const me = await Account.create({
|
450
|
+
creationProps: { name: "Hermes Puggington" },
|
451
|
+
crypto: Crypto,
|
452
|
+
});
|
453
|
+
|
454
|
+
const stream = BinaryCoStream.create({ owner: me });
|
455
|
+
|
456
|
+
stream.start({ mimeType: "text/plain" });
|
457
|
+
|
458
|
+
return { stream, me };
|
459
|
+
}
|
460
|
+
|
461
|
+
test("resolves only when the stream is ended", async () => {
|
462
|
+
const { stream, me } = await setup();
|
463
|
+
stream.push(new Uint8Array([1]));
|
464
|
+
|
465
|
+
const promise = BinaryCoStream.loadAsBlob(stream.id, me);
|
466
|
+
|
467
|
+
await stream.ensureLoaded([]);
|
468
|
+
|
469
|
+
stream.push(new Uint8Array([2]));
|
470
|
+
stream.end();
|
471
|
+
|
472
|
+
const blob = await promise;
|
473
|
+
|
474
|
+
// The promise resolves only when the stream is ended
|
475
|
+
// so we get a blob with all the chunks
|
476
|
+
expect(blob?.size).toBe(2);
|
477
|
+
});
|
478
|
+
|
479
|
+
test("resolves with an unfinshed blob if allowUnfinished: true", async () => {
|
480
|
+
const { stream, me } = await setup();
|
481
|
+
stream.push(new Uint8Array([1]));
|
482
|
+
|
483
|
+
const promise = BinaryCoStream.loadAsBlob(stream.id, me, {
|
484
|
+
allowUnfinished: true,
|
485
|
+
});
|
486
|
+
|
487
|
+
await stream.ensureLoaded([]);
|
488
|
+
|
489
|
+
stream.push(new Uint8Array([2]));
|
490
|
+
stream.end();
|
491
|
+
|
492
|
+
const blob = await promise;
|
493
|
+
|
494
|
+
// The promise resolves before the stream is ended
|
495
|
+
// so we get a blob only with the first chunk
|
496
|
+
expect(blob?.size).toBe(1);
|
497
|
+
});
|
498
|
+
});
|
@@ -60,6 +60,7 @@ describe("Deep loading with depth arg", async () => {
|
|
60
60
|
});
|
61
61
|
|
62
62
|
test("loading a deeply nested object will wait until all required refs are loaded", async () => {
|
63
|
+
const ownership = { owner: me };
|
63
64
|
const map = TestMap.create(
|
64
65
|
{
|
65
66
|
list: TestList.create(
|
@@ -70,19 +71,19 @@ describe("Deep loading with depth arg", async () => {
|
|
70
71
|
[
|
71
72
|
InnermostMap.create(
|
72
73
|
{ value: "hello" },
|
73
|
-
|
74
|
+
ownership,
|
74
75
|
),
|
75
76
|
],
|
76
|
-
|
77
|
+
ownership,
|
77
78
|
),
|
78
79
|
},
|
79
|
-
|
80
|
+
ownership,
|
80
81
|
),
|
81
82
|
],
|
82
|
-
|
83
|
+
ownership,
|
83
84
|
),
|
84
85
|
},
|
85
|
-
|
86
|
+
ownership,
|
86
87
|
);
|
87
88
|
|
88
89
|
const map1 = await TestMap.load(map.id, meOnSecondPeer, {});
|
@@ -141,8 +142,7 @@ describe("Deep loading with depth arg", async () => {
|
|
141
142
|
throw new Error("map4 is undefined");
|
142
143
|
}
|
143
144
|
expect(map4.list[0]?.stream).not.toBe(null);
|
144
|
-
|
145
|
-
// expect(map4.list[0]?.stream?.[me.id]).toBe(undefined)
|
145
|
+
expect(map4.list[0]?.stream?.[me.id]).not.toBe(null);
|
146
146
|
expect(map4.list[0]?.stream?.byMe?.value).toBe(null);
|
147
147
|
|
148
148
|
const map5 = await TestMap.load(map.id, meOnSecondPeer, {
|