jazz-tools 0.7.0-alpha.1 → 0.7.0-alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +12 -0
- package/dist/coValues/account.js +7 -7
- package/dist/coValues/account.js.map +1 -1
- package/dist/coValues/coList.js +8 -8
- package/dist/coValues/coList.js.map +1 -1
- package/dist/coValues/coMap.js +15 -15
- package/dist/coValues/coMap.js.map +1 -1
- package/dist/coValues/coStream.js +8 -8
- package/dist/coValues/coStream.js.map +1 -1
- package/dist/coValues/extensions/imageDef.js +6 -11
- package/dist/coValues/extensions/imageDef.js.map +1 -1
- package/dist/coValues/group.js +13 -16
- package/dist/coValues/group.js.map +1 -1
- package/dist/implementation/refs.js +5 -4
- package/dist/implementation/refs.js.map +1 -1
- package/dist/index.js +0 -16
- package/dist/index.js.map +1 -1
- package/dist/tests/coList.test.js +5 -5
- package/dist/tests/coList.test.js.map +1 -1
- package/dist/tests/coMap.test.js +31 -48
- package/dist/tests/coMap.test.js.map +1 -1
- package/dist/tests/coStream.test.js +10 -10
- package/dist/tests/coStream.test.js.map +1 -1
- package/package.json +1 -1
- package/src/coValues/account.ts +11 -11
- package/src/coValues/coList.ts +10 -10
- package/src/coValues/coMap.ts +22 -22
- package/src/coValues/coStream.ts +10 -10
- package/src/coValues/extensions/imageDef.ts +14 -13
- package/src/coValues/group.ts +15 -16
- package/src/implementation/refs.ts +33 -10
- package/src/index.ts +0 -17
- package/src/tests/coList.test.ts +5 -5
- package/src/tests/coMap.test.ts +32 -46
- package/src/tests/coStream.test.ts +10 -10
@@ -4,7 +4,7 @@ import { webcrypto } from "node:crypto";
|
|
4
4
|
import { connectedPeers } from "cojson/src/streamUtils.js";
|
5
5
|
import { newRandomSessionID } from "cojson/src/coValueCore.js";
|
6
6
|
import { Effect, Queue } from "effect";
|
7
|
-
import { BinaryCoStream,
|
7
|
+
import { BinaryCoStream, ID, Account, jazzReady, CoStream } from "..";
|
8
8
|
import { Simplify } from "effect/Types";
|
9
9
|
|
10
10
|
if (!("crypto" in globalThis)) {
|
@@ -21,7 +21,7 @@ describe("Simple CoStream operations", async () => {
|
|
21
21
|
name: "Hermes Puggington",
|
22
22
|
});
|
23
23
|
|
24
|
-
class TestStream extends
|
24
|
+
class TestStream extends CoStream<string> {}
|
25
25
|
TestStream.encoding({ _item: "json" });
|
26
26
|
|
27
27
|
const stream = new TestStream(["milk"], { owner: me });
|
@@ -45,17 +45,17 @@ describe("Simple CoStream operations", async () => {
|
|
45
45
|
});
|
46
46
|
|
47
47
|
describe("CoStream resolution", async () => {
|
48
|
-
class TwiceNestedStream extends
|
48
|
+
class TwiceNestedStream extends CoStream<string> {
|
49
49
|
fancyValueOf(account: ID<Account>) {
|
50
50
|
return "Sir " + this.by[account]?.value;
|
51
51
|
}
|
52
52
|
}
|
53
53
|
TwiceNestedStream.encoding({ _item: "json" });
|
54
54
|
|
55
|
-
class NestedStream extends
|
55
|
+
class NestedStream extends CoStream<TwiceNestedStream | null>{}
|
56
56
|
NestedStream.encoding({ _item: {ref: () => TwiceNestedStream} });
|
57
57
|
|
58
|
-
class TestStream extends
|
58
|
+
class TestStream extends CoStream<NestedStream | null> {}
|
59
59
|
TestStream.encoding({ _item: {ref: () => NestedStream} });
|
60
60
|
|
61
61
|
const initNodeAndStream = async () => {
|
@@ -265,7 +265,7 @@ describe("Simple BinaryCoStream operations", async () => {
|
|
265
265
|
name: "Hermes Puggington",
|
266
266
|
});
|
267
267
|
|
268
|
-
const stream = new
|
268
|
+
const stream = new BinaryCoStream(undefined, { owner: me });
|
269
269
|
|
270
270
|
test("Construction", () => {
|
271
271
|
expect(stream.getChunks()).toBe(undefined);
|
@@ -293,7 +293,7 @@ describe("BinaryCoStream loading & Subscription", async () => {
|
|
293
293
|
name: "Hermes Puggington",
|
294
294
|
});
|
295
295
|
|
296
|
-
const stream = new
|
296
|
+
const stream = new BinaryCoStream(undefined, { owner: me });
|
297
297
|
|
298
298
|
stream.start({ mimeType: "text/plain" });
|
299
299
|
stream.push(new Uint8Array([1, 2, 3]));
|
@@ -327,7 +327,7 @@ describe("BinaryCoStream loading & Subscription", async () => {
|
|
327
327
|
sessionID: newRandomSessionID(me.id as any),
|
328
328
|
});
|
329
329
|
|
330
|
-
const loadedStream = await
|
330
|
+
const loadedStream = await BinaryCoStream.load(stream.id, {
|
331
331
|
as: meOnSecondPeer,
|
332
332
|
});
|
333
333
|
|
@@ -341,7 +341,7 @@ describe("BinaryCoStream loading & Subscription", async () => {
|
|
341
341
|
test("Subscription", async () => {
|
342
342
|
const { me } = await initNodeAndStream();
|
343
343
|
|
344
|
-
const stream = new
|
344
|
+
const stream = new BinaryCoStream(undefined, { owner: me });
|
345
345
|
|
346
346
|
const [initialAsPeer, secondAsPeer] = connectedPeers(
|
347
347
|
"initial",
|
@@ -362,7 +362,7 @@ describe("BinaryCoStream loading & Subscription", async () => {
|
|
362
362
|
Effect.gen(function* ($) {
|
363
363
|
const queue = yield* $(Queue.unbounded<BinaryCoStream>());
|
364
364
|
|
365
|
-
|
365
|
+
BinaryCoStream.subscribe(
|
366
366
|
stream.id,
|
367
367
|
{ as: meOnSecondPeer },
|
368
368
|
(subscribedStream) => {
|