@sickr/replay 0.9.0-beta.3 → 0.9.0
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/live.js +28 -10
- package/package.json +3 -2
package/dist/live.js
CHANGED
|
@@ -183,16 +183,7 @@ async function sessionLoop(creds, urlid, opts) {
|
|
|
183
183
|
tailTimer = setInterval(() => pumpNewLines(ws, offsets, opts), 500);
|
|
184
184
|
});
|
|
185
185
|
ws.addEventListener('message', (ev) => {
|
|
186
|
-
|
|
187
|
-
// Buffer (not a string) on the browser-style addEventListener API.
|
|
188
|
-
// Without explicit decode we'd silently treat every message as '{}'.
|
|
189
|
-
let raw = '';
|
|
190
|
-
const d = ev.data;
|
|
191
|
-
if (typeof d === 'string')
|
|
192
|
-
raw = d;
|
|
193
|
-
else if (d && typeof d.toString === 'function') {
|
|
194
|
-
raw = d.toString('utf8');
|
|
195
|
-
}
|
|
186
|
+
const raw = decodeWsPayload(ev.data);
|
|
196
187
|
if (opts.verbose)
|
|
197
188
|
process.stderr.write(`sickr: ws recv (${raw.length}b): ${raw.slice(0, 120)}\n`);
|
|
198
189
|
let m;
|
|
@@ -268,6 +259,33 @@ function pumpNewLines(ws, offsets, opts) {
|
|
|
268
259
|
}
|
|
269
260
|
writeOffsets(offsets);
|
|
270
261
|
}
|
|
262
|
+
/** Decode a WebSocket `MessageEvent.data` payload into a UTF-8 string.
|
|
263
|
+
* The browser WebSocket gives strings for text frames; the Node `ws`
|
|
264
|
+
* package gives Buffers; some shims give ArrayBuffer/Uint8Array. Reading
|
|
265
|
+
* any of those as `typeof === 'string'` silently produces empty JSON,
|
|
266
|
+
* which dropped steer messages on the CLI side in 0.9.0-beta.2 (#bug6).
|
|
267
|
+
* Always run inbound frames through this. Exported for test coverage. */
|
|
268
|
+
export function decodeWsPayload(data) {
|
|
269
|
+
if (typeof data === 'string')
|
|
270
|
+
return data;
|
|
271
|
+
if (data == null)
|
|
272
|
+
return '';
|
|
273
|
+
// Buffer / Uint8Array / ArrayBuffer all expose toString — but ArrayBuffer's
|
|
274
|
+
// default toString returns "[object ArrayBuffer]", so coerce via Uint8Array.
|
|
275
|
+
if (data instanceof ArrayBuffer)
|
|
276
|
+
return Buffer.from(new Uint8Array(data)).toString('utf8');
|
|
277
|
+
if (ArrayBuffer.isView(data))
|
|
278
|
+
return Buffer.from(data.buffer, data.byteOffset, data.byteLength).toString('utf8');
|
|
279
|
+
if (typeof data.toString === 'function') {
|
|
280
|
+
try {
|
|
281
|
+
return data.toString('utf8');
|
|
282
|
+
}
|
|
283
|
+
catch {
|
|
284
|
+
return '';
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
return '';
|
|
288
|
+
}
|
|
271
289
|
function isAlive(pid) {
|
|
272
290
|
try {
|
|
273
291
|
process.kill(pid, 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sickr/replay",
|
|
3
|
-
"version": "0.9.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "npx @sickr/replay — local Claude Code audit + one-click share. The free wedge into SICKR.",
|
|
6
6
|
"bin": { "replay": "dist/cli.js", "sickr": "dist/cli.js" },
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
"scripts": {
|
|
10
10
|
"build": "tsc",
|
|
11
11
|
"test": "vitest run",
|
|
12
|
-
"dev": "tsc -w"
|
|
12
|
+
"dev": "tsc -w",
|
|
13
|
+
"prepublishOnly": "npm run build && npm test && node scripts/pre-publish-check.mjs"
|
|
13
14
|
},
|
|
14
15
|
"engines": { "node": ">=20" },
|
|
15
16
|
"license": "UNLICENSED",
|