jazz-run 0.8.4 → 0.8.6
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/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +19 -0
- package/dist/startSync.js +19 -3
- package/dist/startSync.js.map +1 -1
- package/package.json +5 -5
- package/src/startSync.ts +21 -9
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
> jazz-run@0.8.
|
|
2
|
+
> jazz-run@0.8.5 build /Users/anselm/jazz/jazz/packages/jazz-run
|
|
3
3
|
> npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
> jazz-run@0.8.
|
|
6
|
+
> jazz-run@0.8.5 lint
|
|
7
7
|
> eslint . --ext ts,tsx
|
|
8
8
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
# jazz-run
|
|
2
2
|
|
|
3
|
+
## 0.8.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 5542fdb: Added batching to the WebSocket messsages
|
|
8
|
+
- Updated dependencies [5542fdb]
|
|
9
|
+
- cojson-transport-ws@0.8.6
|
|
10
|
+
|
|
11
|
+
## 0.8.5
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Updated dependencies [c3f4e6b]
|
|
16
|
+
- Updated dependencies [d9152ed]
|
|
17
|
+
- jazz-tools@0.8.5
|
|
18
|
+
- cojson@0.8.5
|
|
19
|
+
- cojson-storage-sqlite@0.8.5
|
|
20
|
+
- cojson-transport-ws@0.8.5
|
|
21
|
+
|
|
3
22
|
## 0.8.4
|
|
4
23
|
|
|
5
24
|
### Patch Changes
|
package/dist/startSync.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/* istanbul ignore file -- @preserve */
|
|
2
2
|
import { Command, Options } from "@effect/cli";
|
|
3
|
-
import { ControlledAgent, LocalNode, WasmCrypto
|
|
3
|
+
import { ControlledAgent, LocalNode, WasmCrypto } from "cojson";
|
|
4
4
|
import { WebSocketServer } from "ws";
|
|
5
|
+
import { createServer } from "http";
|
|
5
6
|
import { createWebSocketPeer } from "cojson-transport-ws";
|
|
6
7
|
import { Effect } from "effect";
|
|
7
8
|
import { SQLiteStorage } from "cojson-storage-sqlite";
|
|
@@ -18,8 +19,14 @@ const db = Options.file("db")
|
|
|
18
19
|
export const startSync = Command.make("sync", { port, inMemory, db }, ({ port, inMemory, db }) => {
|
|
19
20
|
return Effect.gen(function* () {
|
|
20
21
|
const crypto = yield* Effect.promise(() => WasmCrypto.create());
|
|
21
|
-
const
|
|
22
|
-
|
|
22
|
+
const server = createServer((req, res) => {
|
|
23
|
+
if (req.url === "/health") {
|
|
24
|
+
res.writeHead(200);
|
|
25
|
+
res.end("ok");
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
29
|
+
console.log("COJSON sync server listening on port " + port);
|
|
23
30
|
const agentSecret = crypto.newRandomAgentSecret();
|
|
24
31
|
const agentID = crypto.getAgentID(agentSecret);
|
|
25
32
|
const localNode = new LocalNode(new ControlledAgent(agentSecret, crypto), crypto.newRandomSessionID(agentID), crypto);
|
|
@@ -50,9 +57,18 @@ export const startSync = Command.make("sync", { port, inMemory, db }, ({ port, i
|
|
|
50
57
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
58
|
websocket: ws, // TODO: fix types
|
|
52
59
|
expectPings: false,
|
|
60
|
+
batchingByDefault: false
|
|
53
61
|
}));
|
|
54
62
|
ws.on("error", (e) => console.error(`Error on connection ${clientId}:`, e));
|
|
55
63
|
});
|
|
64
|
+
server.on("upgrade", function upgrade(req, socket, head) {
|
|
65
|
+
if (req.url !== "/health") {
|
|
66
|
+
wss.handleUpgrade(req, socket, head, function done(ws) {
|
|
67
|
+
wss.emit("connection", ws, req);
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
server.listen(parseInt(port));
|
|
56
72
|
// Keep the server up
|
|
57
73
|
yield* Effect.never;
|
|
58
74
|
});
|
package/dist/startSync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"startSync.js","sourceRoot":"","sources":["../src/startSync.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"startSync.js","sourceRoot":"","sources":["../src/startSync.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AACrC,OAAO,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AAEzC,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC;KAC5B,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;KAC5B,IAAI,CACD,OAAO,CAAC,eAAe,CACnB,mEAAmE,CACtE,CACJ;KACA,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;AAEvC,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,WA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AE,CAAC;YAEhE,SAAS,CAAC,WAAW,CAAC,OAAO,CACzB,mBAAmB,CAAC;gBAChB,EAAE,EAAE,QAAQ;gBACZ,IAAI,EAAE,QAAQ;gBACd,8DAA8D;gBAC9D,SAAS,EAAE,EAAS,EAAE,kBAAkB;gBACxC,WAAW,EAAE,KAAK;gBAClB,iBAAiB,EAAE,KAAK;aAC3B,CAAC,CACL,CAAC;YAEF,EAAE,CAAC,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE,CACjB,OAAO,CAAC,KAAK,CAAC,uBAAuB,QAAQ,GAAG,EAAE,CAAC,CAAC,CACvD,CAAC;QACN,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI;YACnD,IAAI,GAAG,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;gBACxB,GAAG,CAAC,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,IAAI,CAAC,EAAE;oBACjD,GAAG,CAAC,IAAI,CAAC,YAAY,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;gBACpC,CAAC,CAAC,CAAC;YACP,CAAC;QACL,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAE9B,qBAAqB;QACrB,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;IACxB,CAAC,CAAC,CAAC;AACP,CAAC,CACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"bin": "./dist/index.js",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "0.8.
|
|
6
|
+
"version": "0.8.6",
|
|
7
7
|
"dependencies": {
|
|
8
8
|
"@effect/cli": "^0.41.2",
|
|
9
9
|
"@effect/platform-node": "^0.57.2",
|
|
@@ -11,11 +11,11 @@
|
|
|
11
11
|
"@effect/printer-ansi": "^0.34.5",
|
|
12
12
|
"@effect/schema": "^0.71.1",
|
|
13
13
|
"@effect/typeclass": "^0.25.5",
|
|
14
|
-
"cojson": "0.8.
|
|
15
|
-
"cojson-storage-sqlite": "0.8.
|
|
16
|
-
"cojson-transport-ws": "0.8.
|
|
14
|
+
"cojson": "0.8.5",
|
|
15
|
+
"cojson-storage-sqlite": "0.8.5",
|
|
16
|
+
"cojson-transport-ws": "0.8.6",
|
|
17
17
|
"effect": "^3.6.5",
|
|
18
|
-
"jazz-tools": "0.8.
|
|
18
|
+
"jazz-tools": "0.8.5",
|
|
19
19
|
"ws": "^8.14.2"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
package/src/startSync.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
/* istanbul ignore file -- @preserve */
|
|
2
2
|
import { Command, Options } from "@effect/cli";
|
|
3
|
-
import {
|
|
4
|
-
ControlledAgent,
|
|
5
|
-
LocalNode,
|
|
6
|
-
WasmCrypto,
|
|
7
|
-
} from "cojson";
|
|
3
|
+
import { ControlledAgent, LocalNode, WasmCrypto } from "cojson";
|
|
8
4
|
import { WebSocketServer } from "ws";
|
|
5
|
+
import { createServer } from "http";
|
|
9
6
|
|
|
10
7
|
import { createWebSocketPeer } from "cojson-transport-ws";
|
|
11
8
|
import { Effect } from "effect";
|
|
@@ -41,11 +38,15 @@ export const startSync = Command.make(
|
|
|
41
38
|
return Effect.gen(function* () {
|
|
42
39
|
const crypto = yield* Effect.promise(() => WasmCrypto.create());
|
|
43
40
|
|
|
44
|
-
const
|
|
41
|
+
const server = createServer((req, res) => {
|
|
42
|
+
if (req.url === "/health") {
|
|
43
|
+
res.writeHead(200);
|
|
44
|
+
res.end("ok");
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
const wss = new WebSocketServer({ noServer: true });
|
|
45
48
|
|
|
46
|
-
console.log(
|
|
47
|
-
"COJSON sync server listening on port " + wss.options.port,
|
|
48
|
-
);
|
|
49
|
+
console.log("COJSON sync server listening on port " + port);
|
|
49
50
|
|
|
50
51
|
const agentSecret = crypto.newRandomAgentSecret();
|
|
51
52
|
const agentID = crypto.getAgentID(agentSecret);
|
|
@@ -98,6 +99,7 @@ export const startSync = Command.make(
|
|
|
98
99
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
99
100
|
websocket: ws as any, // TODO: fix types
|
|
100
101
|
expectPings: false,
|
|
102
|
+
batchingByDefault: false
|
|
101
103
|
}),
|
|
102
104
|
);
|
|
103
105
|
|
|
@@ -106,6 +108,16 @@ export const startSync = Command.make(
|
|
|
106
108
|
);
|
|
107
109
|
});
|
|
108
110
|
|
|
111
|
+
server.on("upgrade", function upgrade(req, socket, head) {
|
|
112
|
+
if (req.url !== "/health") {
|
|
113
|
+
wss.handleUpgrade(req, socket, head, function done(ws) {
|
|
114
|
+
wss.emit("connection", ws, req);
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
server.listen(parseInt(port));
|
|
120
|
+
|
|
109
121
|
// Keep the server up
|
|
110
122
|
yield* Effect.never;
|
|
111
123
|
});
|