@livestore/webmesh 0.5.0-dev.0 → 0.5.0-dev.1
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/dist/.tsbuildinfo +1 -1
- package/dist/channel/direct-channel-internal.d.ts.map +1 -1
- package/dist/channel/direct-channel-internal.js +3 -3
- package/dist/channel/direct-channel-internal.js.map +1 -1
- package/dist/channel/direct-channel.d.ts.map +1 -1
- package/dist/channel/direct-channel.js +2 -2
- package/dist/channel/proxy-channel.d.ts.map +1 -1
- package/dist/channel/proxy-channel.js +2 -2
- package/dist/channel/proxy-channel.js.map +1 -1
- package/dist/common.d.ts +16 -16
- package/dist/common.d.ts.map +1 -1
- package/dist/mesh-schema.d.ts +37 -37
- package/dist/mesh-schema.d.ts.map +1 -1
- package/dist/mod.js +4 -4
- package/dist/node.d.ts.map +1 -1
- package/dist/node.js +6 -6
- package/dist/node.js.map +1 -1
- package/dist/node.test.js +6 -6
- package/dist/node.test.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/dist/websocket-edge.d.ts +2 -2
- package/dist/websocket-edge.d.ts.map +1 -1
- package/dist/websocket-edge.js +7 -12
- package/dist/websocket-edge.js.map +1 -1
- package/dist/websocket-edge.test.js +10 -10
- package/dist/websocket-edge.test.js.map +1 -1
- package/dist/worker/mod.d.ts.map +1 -1
- package/dist/worker/mod.js +4 -4
- package/dist/worker/mod.js.map +1 -1
- package/package.json +35 -35
- package/src/node.test.ts +5 -5
- package/src/node.ts +1 -1
- package/src/websocket-edge.test.ts +9 -9
- package/src/websocket-edge.ts +6 -13
package/dist/worker/mod.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.js","sourceRoot":"","sources":["../../src/worker/mod.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,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;QAC5D,IAAI,EAAE,EAAE,CAAC,KAAK;QACd,MAAM,EAAE,aAAa,CAAC,MAAM;KAC7B,CAAC,CAAA;IAEF,KAAK,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,gBAAgB,EAAE,eAAe,EAAE,IAAI,EAAE,CAAC,CAAA;IAErF,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACpB,KAAK,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,oDAAoD,IAAI,CAAC,QAAQ,OAAO,MAAM,EAAE,CAAC,CAAA;IAC1G,CAAC;AACH,CAAC,CAAC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
1
|
{
|
|
2
|
+
"$genie": {
|
|
3
|
+
"source": "package.json.genie.ts",
|
|
4
|
+
"warning": "DO NOT EDIT - changes will be overwritten",
|
|
5
|
+
"workspaceClosureDirs": [
|
|
6
|
+
"packages/@livestore/utils",
|
|
7
|
+
"packages/@livestore/utils-dev",
|
|
8
|
+
"packages/@livestore/webmesh"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
2
11
|
"name": "@livestore/webmesh",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
12
|
+
"version": "0.5.0-dev.1",
|
|
13
|
+
"type": "module",
|
|
14
|
+
"sideEffects": false,
|
|
4
15
|
"license": "Apache-2.0",
|
|
5
16
|
"repository": {
|
|
6
17
|
"type": "git",
|
|
7
18
|
"url": "git+https://github.com/livestorejs/livestore.git"
|
|
8
19
|
},
|
|
20
|
+
"exports": {
|
|
21
|
+
".": "./dist/mod.js",
|
|
22
|
+
"./worker": "./dist/worker/mod.js"
|
|
23
|
+
},
|
|
9
24
|
"files": [
|
|
10
25
|
"dist",
|
|
11
26
|
"package.json",
|
|
12
27
|
"src"
|
|
13
28
|
],
|
|
14
|
-
"type": "module",
|
|
15
|
-
"sideEffects": false,
|
|
16
|
-
"exports": {
|
|
17
|
-
".": "./dist/mod.js",
|
|
18
|
-
"./worker": "./dist/worker/mod.js"
|
|
19
|
-
},
|
|
20
|
-
"publishConfig": {
|
|
21
|
-
"access": "public"
|
|
22
|
-
},
|
|
23
29
|
"dependencies": {
|
|
24
|
-
"@livestore/utils": "^0.5.0-dev.
|
|
30
|
+
"@livestore/utils": "^0.5.0-dev.1"
|
|
25
31
|
},
|
|
26
32
|
"devDependencies": {
|
|
27
|
-
"@effect/opentelemetry": "4.0.
|
|
28
|
-
"@effect/platform-browser": "4.0.
|
|
29
|
-
"@effect/platform-bun": "4.0.
|
|
30
|
-
"@effect/platform-node": "4.0.
|
|
31
|
-
"@effect/platform-node-shared": "4.0.
|
|
32
|
-
"@effect/vitest": "4.0.
|
|
33
|
+
"@effect/opentelemetry": "4.0.3",
|
|
34
|
+
"@effect/platform-browser": "4.0.3",
|
|
35
|
+
"@effect/platform-bun": "4.0.3",
|
|
36
|
+
"@effect/platform-node": "4.0.3",
|
|
37
|
+
"@effect/platform-node-shared": "4.0.3",
|
|
38
|
+
"@effect/vitest": "4.0.3",
|
|
39
|
+
"@livestore/utils-dev": "^0.5.0-dev.1",
|
|
33
40
|
"@opentelemetry/api": "1.9.0",
|
|
34
41
|
"@opentelemetry/resources": "2.2.0",
|
|
35
42
|
"@standard-schema/spec": "1.1.0",
|
|
36
|
-
"effect": "4.0.
|
|
37
|
-
"vitest": "4.1.9"
|
|
38
|
-
"@livestore/utils-dev": "^0.5.0-dev.0"
|
|
43
|
+
"effect": "4.0.3",
|
|
44
|
+
"vitest": "4.1.9"
|
|
39
45
|
},
|
|
40
46
|
"peerDependencies": {
|
|
41
|
-
"@effect/opentelemetry": "^4.0.
|
|
42
|
-
"@effect/platform-browser": "^4.0.
|
|
43
|
-
"@effect/platform-bun": "^4.0.
|
|
44
|
-
"@effect/platform-node": "^4.0.
|
|
45
|
-
"@effect/platform-node-shared": "^4.0.
|
|
46
|
-
"@effect/vitest": "^4.0.
|
|
47
|
+
"@effect/opentelemetry": "^4.0.3",
|
|
48
|
+
"@effect/platform-browser": "^4.0.3",
|
|
49
|
+
"@effect/platform-bun": "^4.0.3",
|
|
50
|
+
"@effect/platform-node": "^4.0.3",
|
|
51
|
+
"@effect/platform-node-shared": "^4.0.3",
|
|
52
|
+
"@effect/vitest": "^4.0.3",
|
|
47
53
|
"@opentelemetry/api": "^1.9.0",
|
|
48
54
|
"@opentelemetry/resources": "^2.2.0",
|
|
49
55
|
"@standard-schema/spec": "^1.1.0",
|
|
50
|
-
"effect": "^4.0.
|
|
56
|
+
"effect": "^4.0.3"
|
|
51
57
|
},
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"warning": "DO NOT EDIT - changes will be overwritten",
|
|
55
|
-
"workspaceClosureDirs": [
|
|
56
|
-
"packages/@livestore/utils",
|
|
57
|
-
"packages/@livestore/utils-dev",
|
|
58
|
-
"packages/@livestore/webmesh"
|
|
59
|
-
]
|
|
58
|
+
"publishConfig": {
|
|
59
|
+
"access": "public"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"test": "vitest"
|
package/src/node.test.ts
CHANGED
|
@@ -204,7 +204,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
204
204
|
suffix: `delayX=${delayX} delayY=${delayY} connectDelay=${connectDelay} channelType=${channelType} nodeNames=${nodeNames.join(',')}`,
|
|
205
205
|
}),
|
|
206
206
|
),
|
|
207
|
-
// {
|
|
207
|
+
// { arbitrary: { runs: 20 } },
|
|
208
208
|
)
|
|
209
209
|
// const waitForOfflineDelay = undefined
|
|
210
210
|
// const sleepDelay = 0
|
|
@@ -283,7 +283,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
283
283
|
suffix: `waitForOfflineDelay=${waitForOfflineDelay} sleepDelay=${sleepDelay} channelType=${channelType}`,
|
|
284
284
|
}),
|
|
285
285
|
),
|
|
286
|
-
{
|
|
286
|
+
{ arbitrary: { runs: 20 } },
|
|
287
287
|
)
|
|
288
288
|
|
|
289
289
|
Vitest.live('reconnect with re-created node', (test) =>
|
|
@@ -395,7 +395,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
395
395
|
suffix: `channelType=${channelType} nodeNames=${nodeNames.join(',')}`,
|
|
396
396
|
}),
|
|
397
397
|
),
|
|
398
|
-
{
|
|
398
|
+
{ arbitrary: { runs: 10 } },
|
|
399
399
|
)
|
|
400
400
|
|
|
401
401
|
Vitest.describe('TODO improve latency', () => {
|
|
@@ -459,7 +459,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
459
459
|
timeout: testTimeout * 2,
|
|
460
460
|
}),
|
|
461
461
|
),
|
|
462
|
-
{
|
|
462
|
+
{ arbitrary: { runs: 10 } },
|
|
463
463
|
)
|
|
464
464
|
})
|
|
465
465
|
})
|
|
@@ -1266,7 +1266,7 @@ Vitest.describe('webmesh node', { timeout: testTimeout }, () => {
|
|
|
1266
1266
|
timeout: testTimeout * 2,
|
|
1267
1267
|
}),
|
|
1268
1268
|
),
|
|
1269
|
-
{
|
|
1269
|
+
{ arbitrary: { runs: 10 } },
|
|
1270
1270
|
)
|
|
1271
1271
|
})
|
|
1272
1272
|
})
|
package/src/node.ts
CHANGED
|
@@ -365,7 +365,7 @@ export const makeMeshNode = <TName extends MeshNodeName>(
|
|
|
365
365
|
Stream.mapEffect(Effect.fromResult),
|
|
366
366
|
Stream.tap((message) =>
|
|
367
367
|
Effect.gen(function* () {
|
|
368
|
-
const packet = yield* Schema.
|
|
368
|
+
const packet = yield* Schema.decodeEffect(WebmeshSchema.Packet)(message)
|
|
369
369
|
|
|
370
370
|
// console.debug(nodeName, 'recv', packet._tag, packet.source, packet.target)
|
|
371
371
|
|
|
@@ -10,21 +10,21 @@ import { Vitest } from '@livestore/utils-dev/node-vitest'
|
|
|
10
10
|
import { Effect, Result, Schema, WebChannel } from '@livestore/utils/effect'
|
|
11
11
|
|
|
12
12
|
import * as MeshSchema from './mesh-schema.ts'
|
|
13
|
-
import {
|
|
13
|
+
import { MessageBinary, WSEdgeInit, WSEdgePayload } from './websocket-edge.ts'
|
|
14
14
|
|
|
15
15
|
Vitest.describe('websocket-edge', () => {
|
|
16
16
|
/**
|
|
17
|
-
* Test that WSEdgeInit messages can be encoded/decoded via
|
|
17
|
+
* Test that WSEdgeInit messages can be encoded/decoded via MessageBinary.
|
|
18
18
|
*/
|
|
19
19
|
Vitest.live('should encode/decode WSEdgeInit', (test) =>
|
|
20
20
|
Effect.gen(function* () {
|
|
21
21
|
const initMessage = WSEdgeInit.make({ from: 'test-node' })
|
|
22
22
|
|
|
23
|
-
// Encode to
|
|
24
|
-
const encoded = yield* Schema.encodeEffect(
|
|
23
|
+
// Encode to binary
|
|
24
|
+
const encoded = yield* Schema.encodeEffect(MessageBinary)(initMessage)
|
|
25
25
|
|
|
26
26
|
// Decode back
|
|
27
|
-
const decoded = yield* Schema.decodeEffect(
|
|
27
|
+
const decoded = yield* Schema.decodeEffect(MessageBinary)(encoded)
|
|
28
28
|
|
|
29
29
|
expect(decoded._tag).toBe('WSEdgeInit')
|
|
30
30
|
if (decoded._tag === 'WSEdgeInit') {
|
|
@@ -46,11 +46,11 @@ Vitest.describe('websocket-edge', () => {
|
|
|
46
46
|
}
|
|
47
47
|
const wsMessage = WSEdgePayload.make({ from: 'test-node', payload: packet })
|
|
48
48
|
|
|
49
|
-
// Encode to
|
|
50
|
-
const encoded = yield* Schema.encodeEffect(
|
|
49
|
+
// Encode to binary
|
|
50
|
+
const encoded = yield* Schema.encodeEffect(MessageBinary)(wsMessage)
|
|
51
51
|
|
|
52
52
|
// Decode back
|
|
53
|
-
const decoded = yield* Schema.decodeEffect(
|
|
53
|
+
const decoded = yield* Schema.decodeEffect(MessageBinary)(encoded)
|
|
54
54
|
|
|
55
55
|
expect(decoded._tag).toBe('WSEdgePayload')
|
|
56
56
|
if (decoded._tag === 'WSEdgePayload') {
|
|
@@ -91,7 +91,7 @@ Vitest.describe('websocket-edge', () => {
|
|
|
91
91
|
target: 'node-b',
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
const result = yield* Schema.
|
|
94
|
+
const result = yield* Schema.decodeEffect(schema.listen)(packet)
|
|
95
95
|
expect(result._tag).toBe('NetworkEdgeAdded')
|
|
96
96
|
}).pipe(Vitest.withTestCtx(test)),
|
|
97
97
|
)
|
package/src/websocket-edge.ts
CHANGED
|
@@ -6,11 +6,10 @@ import {
|
|
|
6
6
|
Result,
|
|
7
7
|
Exit,
|
|
8
8
|
Latch,
|
|
9
|
-
Layer,
|
|
10
|
-
Msgpack,
|
|
11
9
|
Queue,
|
|
12
10
|
Schedule,
|
|
13
11
|
Schema,
|
|
12
|
+
SchemaBinary,
|
|
14
13
|
Scope,
|
|
15
14
|
Socket,
|
|
16
15
|
Stream,
|
|
@@ -31,7 +30,7 @@ export const WSEdgePayload = Schema.TaggedStruct('WSEdgePayload', {
|
|
|
31
30
|
|
|
32
31
|
export const WSEdgeMessage = Schema.Union([WSEdgeInit, WSEdgePayload])
|
|
33
32
|
|
|
34
|
-
export const
|
|
33
|
+
export const MessageBinary = SchemaBinary.toCodec(WSEdgeMessage)
|
|
35
34
|
|
|
36
35
|
export type SocketType =
|
|
37
36
|
| {
|
|
@@ -66,13 +65,7 @@ export const connectViaWebSocket = ({
|
|
|
66
65
|
)
|
|
67
66
|
|
|
68
67
|
yield* Deferred.await(edgeChannel.webChannel.closedDeferred)
|
|
69
|
-
}).pipe(Effect.scoped, Effect.forever, Effect.interruptible, Effect.provide(
|
|
70
|
-
|
|
71
|
-
const binaryWebSocketConstructorLayer = Layer.succeed(Socket.WebSocketConstructor, (url, protocols) => {
|
|
72
|
-
const socket = new globalThis.WebSocket(url, protocols)
|
|
73
|
-
socket.binaryType = 'arraybuffer'
|
|
74
|
-
return socket
|
|
75
|
-
})
|
|
68
|
+
}).pipe(Effect.scoped, Effect.forever, Effect.interruptible, Effect.provide(Socket.layerWebSocketConstructorGlobal))
|
|
76
69
|
|
|
77
70
|
export const makeWebSocketEdge = ({
|
|
78
71
|
socket,
|
|
@@ -132,7 +125,7 @@ export const makeWebSocketEdge = ({
|
|
|
132
125
|
Stream.retry(retryOpenErrorSchedule),
|
|
133
126
|
Stream.tap(
|
|
134
127
|
Effect.fn(function* (bytes) {
|
|
135
|
-
const msg = yield* Schema.decodeEffect(
|
|
128
|
+
const msg = yield* Schema.decodeEffect(MessageBinary)(new Uint8Array(bytes))
|
|
136
129
|
if (msg._tag === 'WSEdgeInit') {
|
|
137
130
|
yield* Deferred.succeed(fromDeferred, msg.from)
|
|
138
131
|
} else {
|
|
@@ -155,7 +148,7 @@ export const makeWebSocketEdge = ({
|
|
|
155
148
|
)
|
|
156
149
|
|
|
157
150
|
const initHandshake = (from: string) =>
|
|
158
|
-
sendToSocket(Schema.encodeSync(
|
|
151
|
+
sendToSocket.write(Schema.encodeSync(MessageBinary)({ _tag: 'WSEdgeInit', from }))
|
|
159
152
|
|
|
160
153
|
if (socketType._tag === 'leaf') {
|
|
161
154
|
yield* initHandshake(socketType.from)
|
|
@@ -172,7 +165,7 @@ export const makeWebSocketEdge = ({
|
|
|
172
165
|
Effect.gen(function* () {
|
|
173
166
|
yield* isConnectedLatch.await
|
|
174
167
|
const payload = yield* Schema.encodeEffect(schema.send)(message)
|
|
175
|
-
yield* sendToSocket(yield* Schema.encodeEffect(
|
|
168
|
+
yield* sendToSocket.write(yield* Schema.encodeEffect(MessageBinary)({ _tag: 'WSEdgePayload', payload, from }))
|
|
176
169
|
}).pipe(Effect.orDie)
|
|
177
170
|
|
|
178
171
|
const listen = Stream.fromQueue(listenQueue).pipe(
|