jazz-tools 0.7.0-alpha.32 → 0.7.0-alpha.35

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
 
2
- > jazz-tools@0.7.0-alpha.31 build /Users/anselm/jazz/jazz/packages/jazz-tools
2
+ > jazz-tools@0.7.0-alpha.34 build /Users/anselm/jazz/jazz/packages/jazz-tools
3
3
  > npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
4
4
 
5
5
 
6
- > jazz-tools@0.7.0-alpha.31 lint
6
+ > jazz-tools@0.7.0-alpha.34 lint
7
7
  > eslint src/**/*.ts
8
8
 
9
9
 
@@ -76,7 +76,9 @@
76
76
  83:17 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
77
77
 
78
78
  /Users/anselm/jazz/jazz/packages/jazz-tools/src/implementation/subscriptionScope.ts
79
- 6:23 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
79
+ 13:23 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
80
+ 67:32 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
81
+ 69:32 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
80
82
 
81
83
  /Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/coList.test.ts
82
84
  0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
@@ -90,5 +92,5 @@
90
92
  /Users/anselm/jazz/jazz/packages/jazz-tools/src/tests/groupsAndAccounts.test.ts
91
93
  0:0 warning File ignored because of a matching ignore pattern. Use "--no-ignore" to override
92
94
 
93
- 59 problems (0 errors, 59 warnings)
95
+ 61 problems (0 errors, 61 warnings)
94
96
 
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # jazz-autosub
2
2
 
3
+ ## 0.7.0-alpha.35
4
+
5
+ ### Patch Changes
6
+
7
+ - Cache CoValue proxies
8
+ - Updated dependencies
9
+ - cojson@0.7.0-alpha.35
10
+ - cojson-transport-nodejs-ws@0.7.0-alpha.35
11
+
12
+ ## 0.7.0-alpha.34
13
+
14
+ ### Patch Changes
15
+
16
+ - Extract jazz cli into jazz-run package
17
+
3
18
  ## 0.7.0-alpha.32
4
19
 
5
20
  ### Patch Changes
@@ -1,5 +1,6 @@
1
1
  import { Effect } from "effect";
2
2
  import { instantiateRefEncoded, isRefEncoded, subscriptionsScopes, } from "../internal.js";
3
+ const refCache = new WeakMap();
3
4
  export class Ref {
4
5
  constructor(id, controlledAccount, schema) {
5
6
  this.id = id;
@@ -10,13 +11,17 @@ export class Ref {
10
11
  }
11
12
  }
12
13
  get value() {
13
- if (this.cachedValue)
14
- return this.cachedValue;
15
14
  // TODO: cache it for object identity!!!
16
15
  const raw = this.controlledAccount._raw.core.node.getLoaded(this.id);
17
16
  if (raw) {
18
- const value = instantiateRefEncoded(this.schema, raw);
19
- this.cachedValue = value;
17
+ let value = refCache.get(raw);
18
+ if (value) {
19
+ // console.log("Using cached value for " + this.id);
20
+ }
21
+ else {
22
+ value = instantiateRefEncoded(this.schema, raw);
23
+ refCache.set(raw, value);
24
+ }
20
25
  return value;
21
26
  }
22
27
  else {
@@ -1 +1 @@
1
- {"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/implementation/refs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAUhC,OAAO,EACH,qBAAqB,EACrB,YAAY,EACZ,mBAAmB,GACtB,MAAM,gBAAgB,CAAC;AAExB,MAAM,OAAO,GAAG;IAGZ,YACa,EAAS,EACT,iBAA+B,EAC/B,MAAqB;QAFrB,OAAE,GAAF,EAAE,CAAO;QACT,sBAAiB,GAAjB,iBAAiB,CAAc;QAC/B,WAAM,GAAN,MAAM,CAAe;QAE9B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,EAAE,CAAC;YACxB,MAAM,IAAI,KAAK,CAAC,2CAA2C,CAAC,CAAC;QACjE,CAAC;IACL,CAAC;IAED,IAAI,KAAK;QACL,IAAI,IAAI,CAAC,WAAW;YAAE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CAAC,CAAC;AACP,CAAC"}
package/package.json CHANGED
@@ -3,24 +3,19 @@
3
3
  "module": "./dist/index.js",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./src/index.ts",
6
- "bin": "./dist/cli/index.js",
7
6
  "type": "module",
8
7
  "license": "MIT",
9
- "version": "0.7.0-alpha.32",
8
+ "version": "0.7.0-alpha.35",
10
9
  "dependencies": {
11
- "@effect/cli": "^0.36.21",
12
- "@effect/platform-node": "^0.49.2",
13
10
  "@effect/schema": "^0.66.16",
14
11
  "effect": "^3.1.3",
15
12
  "fast-check": "^3.17.2",
16
- "ws": "^8.14.2",
17
- "cojson": "0.7.0-alpha.29",
18
- "cojson-transport-nodejs-ws": "0.7.0-alpha.29"
13
+ "cojson": "0.7.0-alpha.35",
14
+ "cojson-transport-nodejs-ws": "0.7.0-alpha.35"
19
15
  },
20
16
  "devDependencies": {
21
17
  "typescript": "^5.3.3",
22
- "vitest": "^0.34.6",
23
- "@types/ws": "^8.5.5"
18
+ "vitest": "^0.34.6"
24
19
  },
25
20
  "madge": {
26
21
  "detectiveOptions": {
@@ -14,9 +14,9 @@ import {
14
14
  subscriptionsScopes,
15
15
  } from "../internal.js";
16
16
 
17
- export class Ref<out V extends CoValue> {
18
- private cachedValue: V | undefined;
17
+ const refCache = new WeakMap<RawCoValue, CoValue>();
19
18
 
19
+ export class Ref<out V extends CoValue> {
20
20
  constructor(
21
21
  readonly id: ID<V>,
22
22
  readonly controlledAccount: Account & Me,
@@ -28,15 +28,19 @@ export class Ref<out V extends CoValue> {
28
28
  }
29
29
 
30
30
  get value() {
31
- if (this.cachedValue) return this.cachedValue;
32
31
  // TODO: cache it for object identity!!!
33
32
  const raw = this.controlledAccount._raw.core.node.getLoaded(
34
33
  this.id as unknown as CoID<RawCoValue>
35
34
  );
36
35
  if (raw) {
37
- const value = instantiateRefEncoded(this.schema, raw);
38
- this.cachedValue = value;
39
- return value;
36
+ let value = refCache.get(raw);
37
+ if (value) {
38
+ // console.log("Using cached value for " + this.id);
39
+ } else {
40
+ value = instantiateRefEncoded(this.schema, raw);
41
+ refCache.set(raw, value);
42
+ }
43
+ return value as V;
40
44
  } else {
41
45
  return null;
42
46
  }
package/dist/cli/index.js DELETED
@@ -1,46 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command, Options } from "@effect/cli";
3
- import { NodeContext, NodeRuntime } from "@effect/platform-node";
4
- import { Console, Effect } from "effect";
5
- import { websocketReadableStream, websocketWritableStream, } from "cojson-transport-nodejs-ws";
6
- import { WebSocket } from "ws";
7
- import { Account, jazzReady } from "../index.js";
8
- import { webcrypto } from "node:crypto";
9
- const jazzTools = Command.make("jazz-tools");
10
- if (!("crypto" in globalThis)) {
11
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
12
- globalThis.crypto = webcrypto;
13
- }
14
- const name = Options.text("name").pipe(Options.withAlias("n"));
15
- const peer = Options.text("peer")
16
- .pipe(Options.withAlias("p"))
17
- .pipe(Options.withDefault("wss://mesh.jazz.tools"));
18
- const accountCreate = Command.make("create", { name, peer }, ({ name, peer }) => {
19
- return Effect.gen(function* () {
20
- const ws = new WebSocket(peer);
21
- const account = yield* Effect.promise(() => jazzReady.then(() => Account.create({
22
- creationProps: { name },
23
- peersToLoadFrom: [
24
- {
25
- id: "upstream",
26
- role: "server",
27
- incoming: websocketReadableStream(ws),
28
- outgoing: websocketWritableStream(ws),
29
- },
30
- ],
31
- })));
32
- yield* Console.log(`# Credentials for Jazz account "${name}":
33
- JAZZ_WORKER_ACCOUNT=${account.id}
34
- JAZZ_WORKER_SECRET=${account._raw.agentSecret}
35
- `);
36
- });
37
- });
38
- const accountBase = Command.make("account");
39
- const account = accountBase.pipe(Command.withSubcommands([accountCreate]));
40
- const command = jazzTools.pipe(Command.withSubcommands([account]));
41
- const cli = Command.run(command, {
42
- name: "Jazz CLI Tools",
43
- version: "v0.7.0",
44
- });
45
- Effect.suspend(() => cli(process.argv)).pipe(Effect.provide(NodeContext.layer), NodeRuntime.runMain);
46
- //# s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tB,CAAC"}
package/src/cli/index.ts DELETED
@@ -1,69 +0,0 @@
1
- #!/usr/bin/env node
2
- import { Command, Options } from "@effect/cli";
3
- import { NodeContext, NodeRuntime } from "@effect/platform-node";
4
- import { Console, Effect } from "effect";
5
- import {
6
- websocketReadableStream,
7
- websocketWritableStream,
8
- } from "cojson-transport-nodejs-ws";
9
- import { WebSocket } from "ws";
10
- import { Account, jazzReady } from "../index.js";
11
- import { webcrypto } from "node:crypto";
12
-
13
- const jazzTools = Command.make("jazz-tools");
14
-
15
- if (!("crypto" in globalThis)) {
16
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
- (globalThis as any).crypto = webcrypto;
18
- }
19
-
20
- const name = Options.text("name").pipe(Options.withAlias("n"));
21
- const peer = Options.text("peer")
22
- .pipe(Options.withAlias("p"))
23
- .pipe(Options.withDefault("wss://mesh.jazz.tools"));
24
- const accountCreate = Command.make(
25
- "create",
26
- { name, peer },
27
- ({ name, peer }) => {
28
- return Effect.gen(function* () {
29
- const ws = new WebSocket(peer);
30
-
31
- const account = yield* Effect.promise(() =>
32
- jazzReady.then(() =>
33
- Account.create({
34
- creationProps: { name },
35
- peersToLoadFrom: [
36
- {
37
- id: "upstream",
38
- role: "server",
39
- incoming: websocketReadableStream(ws),
40
- outgoing: websocketWritableStream(ws),
41
- },
42
- ],
43
- })
44
- )
45
- );
46
-
47
- yield* Console.log(`# Credentials for Jazz account "${name}":
48
- JAZZ_WORKER_ACCOUNT=${account.id}
49
- JAZZ_WORKER_SECRET=${account._raw.agentSecret}
50
- `);
51
- });
52
- }
53
- );
54
-
55
- const accountBase = Command.make("account");
56
-
57
- const account = accountBase.pipe(Command.withSubcommands([accountCreate]));
58
-
59
- const command = jazzTools.pipe(Command.withSubcommands([account]));
60
-
61
- const cli = Command.run(command, {
62
- name: "Jazz CLI Tools",
63
- version: "v0.7.0",
64
- });
65
-
66
- Effect.suspend(() => cli(process.argv)).pipe(
67
- Effect.provide(NodeContext.layer),
68
- NodeRuntime.runMain
69
- );