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.
@@ -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, Co, ID, Account, jazzReady } from "..";
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 Co.Stream<string> {}
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 Co.Stream<string> {
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 Co.Stream<TwiceNestedStream | null>{}
55
+ class NestedStream extends CoStream<TwiceNestedStream | null>{}
56
56
  NestedStream.encoding({ _item: {ref: () => TwiceNestedStream} });
57
57
 
58
- class TestStream extends Co.Stream<NestedStream | null> {}
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 Co.BinaryStream(undefined, { owner: me });
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 Co.BinaryStream(undefined, { owner: me });
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 Co.BinaryStream.load(stream.id, {
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 Co.BinaryStream(undefined, { owner: me });
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
- Co.BinaryStream.subscribe(
365
+ BinaryCoStream.subscribe(
366
366
  stream.id,
367
367
  { as: meOnSecondPeer },
368
368
  (subscribedStream) => {