@rindle/remote 0.7.1 → 0.7.3-rc.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/transport.d.ts +4 -0
- package/dist/transport.d.ts.map +1 -1
- package/dist/transport.js +21 -3
- package/dist/transport.js.map +1 -1
- package/package.json +2 -2
- package/src/transport.ts +23 -4
package/dist/transport.d.ts
CHANGED
|
@@ -32,6 +32,10 @@ export declare class WsTransport implements Transport {
|
|
|
32
32
|
private handler;
|
|
33
33
|
private reconnectHandler;
|
|
34
34
|
private downHandler;
|
|
35
|
+
/** Buffered as PRE-SERIALIZED frames: serialization happens at `send` time so an
|
|
36
|
+
* unserializable message (a `bigint` query arg — `JSON.stringify` throws on bigint)
|
|
37
|
+
* throws typed INTO ITS CALLER instead of detonating later inside the socket's
|
|
38
|
+
* `open` listener, where it would strand every frame queued behind it. */
|
|
35
39
|
private readonly pending;
|
|
36
40
|
private open;
|
|
37
41
|
private everOpened;
|
package/dist/transport.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1D,MAAM,WAAW,SAAS;IACxB,uCAAuC;IACvC,IAAI,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,gEAAgE;IAChE,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,GAAG,IAAI,CAAC;IACnD;;wEAEoE;IACpE,WAAW,CAAC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACxC;;;;wCAIoC;IACpC,MAAM,CAAC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI,CAAC;IACnC,gCAAgC;IAChC,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;mFAGmF;A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IAAI,CAAS;IACrB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,YAAY,CAAS;IAC7B,OAAO,CAAC,OAAO,CAAK;IACpB,OAAO,CAAC,cAAc,CAA4C;IAClE,gGAAgG;IAChG,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC;;2CAEuC;IACvC,OAAO,CAAC,SAAS,CAAS;gBAEd,GAAG,EAAE,MAAM,EAAE,IAAI,GAAE;QAAE,aAAa,CAAC,EAAE,MAAM,CAAC;QAAC,YAAY,CAAC,EAAE,MAAM,MAAM,EAAE,CAAA;KAAO;IAO7F,OAAO,CAAC,OAAO;IAkCf,OAAO,CAAC,iBAAiB;IAiBzB,IAAI,CAAC,GAAG,EAAE,SAAS,GAAG,IAAI;IAmB1B,SAAS,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,SAAS,KAAK,IAAI,GAAG,IAAI;IAIlD,WAAW,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAItC,MAAM,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAIjC,KAAK,IAAI,IAAI;CAQd"}
|
package/dist/transport.js
CHANGED
|
@@ -16,6 +16,10 @@ export class WsTransport {
|
|
|
16
16
|
handler = () => { };
|
|
17
17
|
reconnectHandler = () => { };
|
|
18
18
|
downHandler = () => { };
|
|
19
|
+
/** Buffered as PRE-SERIALIZED frames: serialization happens at `send` time so an
|
|
20
|
+
* unserializable message (a `bigint` query arg — `JSON.stringify` throws on bigint)
|
|
21
|
+
* throws typed INTO ITS CALLER instead of detonating later inside the socket's
|
|
22
|
+
* `open` listener, where it would strand every frame queued behind it. */
|
|
19
23
|
pending = [];
|
|
20
24
|
open = false;
|
|
21
25
|
everOpened = false;
|
|
@@ -45,9 +49,10 @@ export class WsTransport {
|
|
|
45
49
|
this.downFired = false; // a fresh connection clears the down episode
|
|
46
50
|
if (!this.everOpened) {
|
|
47
51
|
// First connection: flush whatever was buffered eagerly (init + subscribes).
|
|
52
|
+
// Frames were serialized at `send` time, so this loop cannot throw.
|
|
48
53
|
this.everOpened = true;
|
|
49
54
|
for (const m of this.pending)
|
|
50
|
-
ws.send(
|
|
55
|
+
ws.send(m);
|
|
51
56
|
this.pending.length = 0;
|
|
52
57
|
}
|
|
53
58
|
else {
|
|
@@ -88,10 +93,23 @@ export class WsTransport {
|
|
|
88
93
|
}, delay);
|
|
89
94
|
}
|
|
90
95
|
send(msg) {
|
|
96
|
+
// Serialize HERE, open or not: a frame the wire cannot carry (a `bigint` query
|
|
97
|
+
// arg on the live-query plane — the browser bigint lane ships with design 226
|
|
98
|
+
// Stage E) must throw typed into its caller, never poison the pending queue or
|
|
99
|
+
// the socket's `open` flush.
|
|
100
|
+
let text;
|
|
101
|
+
try {
|
|
102
|
+
text = JSON.stringify(msg);
|
|
103
|
+
}
|
|
104
|
+
catch (e) {
|
|
105
|
+
throw new Error("query args must be JSON-serializable: bigint values are not supported on the " +
|
|
106
|
+
"live-query wire until the browser bigint lane ships (design 226) — " +
|
|
107
|
+
`${e instanceof Error ? e.message : String(e)}`);
|
|
108
|
+
}
|
|
91
109
|
if (this.open)
|
|
92
|
-
this.ws.send(
|
|
110
|
+
this.ws.send(text);
|
|
93
111
|
else
|
|
94
|
-
this.pending.push(
|
|
112
|
+
this.pending.push(text);
|
|
95
113
|
}
|
|
96
114
|
onMessage(handler) {
|
|
97
115
|
this.handler = handler;
|
package/dist/transport.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,0FAA0F;AAC1F,2FAA2F;AAC3F,gFAAgF;AAuBhF;;;mFAGmF;AACnF,MAAM,OAAO,WAAW;IACL,GAAG,CAAS;IAC7B;;;gDAG4C;IAC3B,YAAY,CAAkB;IACvC,EAAE,CAAY;IACd,OAAO,GAA6B,GAAG,EAAE,GAAE,CAAC,CAAC;IAC7C,gBAAgB,GAAe,GAAG,EAAE,GA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AClD,CAAC;QACJ,CAAC;QACD,IAAI,IAAI,CAAC,IAAI;YAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;;YAC7B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,SAAS,CAAC,OAAiC;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED,WAAW,CAAC,OAAmB;QAC7B,IAAI,CAAC,gBAAgB,GAAG,OAAO,CAAC;IAClC,CAAC;IAED,MAAM,CAAC,OAAmB;QACxB,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC;IAC7B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC;QACzB,IAAI,IAAI,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;YACtC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;YAClC,IAAI,CAAC,cAAc,GAAG,SAAS,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC;CACF"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rindle/remote",
|
|
3
|
-
"version": "0.7.1",
|
|
3
|
+
"version": "0.7.3-rc.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@rindle/client": "0.7.1"
|
|
28
|
+
"@rindle/client": "0.7.3-rc.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/node": "^22.10.0",
|
package/src/transport.ts
CHANGED
|
@@ -38,7 +38,11 @@ export class WsTransport implements Transport {
|
|
|
38
38
|
private handler: (msg: ServerMsg) => void = () => {};
|
|
39
39
|
private reconnectHandler: () => void = () => {};
|
|
40
40
|
private downHandler: () => void = () => {};
|
|
41
|
-
|
|
41
|
+
/** Buffered as PRE-SERIALIZED frames: serialization happens at `send` time so an
|
|
42
|
+
* unserializable message (a `bigint` query arg — `JSON.stringify` throws on bigint)
|
|
43
|
+
* throws typed INTO ITS CALLER instead of detonating later inside the socket's
|
|
44
|
+
* `open` listener, where it would strand every frame queued behind it. */
|
|
45
|
+
private readonly pending: string[] = [];
|
|
42
46
|
private open = false;
|
|
43
47
|
private everOpened = false;
|
|
44
48
|
private closedByUser = false;
|
|
@@ -69,8 +73,9 @@ export class WsTransport implements Transport {
|
|
|
69
73
|
this.downFired = false; // a fresh connection clears the down episode
|
|
70
74
|
if (!this.everOpened) {
|
|
71
75
|
// First connection: flush whatever was buffered eagerly (init + subscribes).
|
|
76
|
+
// Frames were serialized at `send` time, so this loop cannot throw.
|
|
72
77
|
this.everOpened = true;
|
|
73
|
-
for (const m of this.pending) ws.send(
|
|
78
|
+
for (const m of this.pending) ws.send(m);
|
|
74
79
|
this.pending.length = 0;
|
|
75
80
|
} else {
|
|
76
81
|
// A reconnect: drop any stale buffered frames — the source rebuilds the full desired
|
|
@@ -109,8 +114,22 @@ export class WsTransport implements Transport {
|
|
|
109
114
|
}
|
|
110
115
|
|
|
111
116
|
send(msg: ClientMsg): void {
|
|
112
|
-
|
|
113
|
-
|
|
117
|
+
// Serialize HERE, open or not: a frame the wire cannot carry (a `bigint` query
|
|
118
|
+
// arg on the live-query plane — the browser bigint lane ships with design 226
|
|
119
|
+
// Stage E) must throw typed into its caller, never poison the pending queue or
|
|
120
|
+
// the socket's `open` flush.
|
|
121
|
+
let text: string;
|
|
122
|
+
try {
|
|
123
|
+
text = JSON.stringify(msg);
|
|
124
|
+
} catch (e) {
|
|
125
|
+
throw new Error(
|
|
126
|
+
"query args must be JSON-serializable: bigint values are not supported on the " +
|
|
127
|
+
"live-query wire until the browser bigint lane ships (design 226) — " +
|
|
128
|
+
`${e instanceof Error ? e.message : String(e)}`,
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
if (this.open) this.ws.send(text);
|
|
132
|
+
else this.pending.push(text);
|
|
114
133
|
}
|
|
115
134
|
|
|
116
135
|
onMessage(handler: (msg: ServerMsg) => void): void {
|