Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion src/ToolSocketNB.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
const { MESSAGE_BUNDLE_SCHEMA } = require('./schemas.js');

let nodeCrypto = null;
if (!isBrowser) { try { nodeCrypto = require('crypto'); } catch (_e) { /* no integrity */ } }

Check warning on line 73 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

This line has 3 statements. Maximum allowed is 1

Check warning on line 73 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

This line has 3 statements. Maximum allowed is 1

Check warning on line 73 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

This line has 3 statements. Maximum allowed is 1
const nowMs = (!isBrowser && typeof process !== 'undefined' && process.hrtime)
? () => Number(process.hrtime.bigint()) / 1e6 // sub-ms precision for rate/RTT estimation
: () => Date.now();
Expand All @@ -91,7 +91,7 @@
const CLASS_FORMATS = {
2: ['htm', 'html', 'js', 'css', 'csv', 'dat', 'xml', 'woff', 'webp'],
3: ['jpeg', 'jpg', 'gif', 'png', 'svg', 'ttf', 'otf', 'pdf'],
4: ['3dt', 'fbx', 'glb', 'map', 'mp4', 'obj', 'wasm', 'webm', 'zip'], // also DEFAULTS.defaultBinaryClass for unknown types
4: ['3dt', 'fbx', 'glb', 'map', 'mp4', 'ms4', 'obj', 'wasm', 'webm', 'zip'], // also DEFAULTS.defaultBinaryClass for unknown types
5: ['rad', 'radc', 'splat', 'ply', 'pvs', 'pvz'] // bulk: sent only when nothing else is queued
};
// Derived flat lookup (extension -> class). Kept reference-stable so code holding
Expand All @@ -109,8 +109,8 @@

const DEFAULTS = {
chunkSize: 256 * 1024, // hard-capped at 4MB below; 256KB = 4x fewer chunks than 64KB (less per-chunk
// scheduler/framing CPU on the legacy-fallback path), ~4ms preemption @1Gbit /

Check warning on line 112 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

Expected indentation of 4 spaces but found 33

Check warning on line 112 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

Expected indentation of 4 spaces but found 33

Check warning on line 112 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

Expected indentation of 4 spaces but found 33
// ~40ms @100Mbit — realtime still preempts bulk at chunk boundaries

Check warning on line 113 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

Expected indentation of 4 spaces but found 33

Check warning on line 113 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

Expected indentation of 4 spaces but found 33

Check warning on line 113 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

Expected indentation of 4 spaces but found 33
ackWindow: 4, // INITIAL chunks in flight per transfer (0 = flood/disable flow control)
adaptiveWindow: true, // grow/shrink the per-transfer window from measured ack RTT + delivery rate
latencyBudgetMs: 250, // adaptive cap: keep in-flight <= bandwidth x this budget (bounds JSON delay)
Expand All @@ -127,8 +127,8 @@
helloTimeoutMs: 3000, // peer capability handshake timeout -> legacy fallback
transferTimeoutMs: 120000, // GC for stale partial transfers at the receiver
integrity: false, // end-to-end sha256 (Node only); off by default — wss/TCP cover the wire,
// and structural checks (tid/seq/count/length) still catch protocol bugs.

Check warning on line 130 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

Expected indentation of 4 spaces but found 33

Check warning on line 130 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

Expected indentation of 4 spaces but found 33

Check warning on line 130 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

Expected indentation of 4 spaces but found 33
// Turn on during development of transport changes.

Check warning on line 131 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

Expected indentation of 4 spaces but found 33

Check warning on line 131 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

Expected indentation of 4 spaces but found 33

Check warning on line 131 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

Expected indentation of 4 spaces but found 33
reconnect: true, // auto-reconnect outgoing sockets
holdResumeJitterMs: 2000, // client-side random delay before the resume(false) callback fires (herd control)
maxPayload: 16 * MB, // ws frame cap: chunks are <=4MB, so 16MB is a guard rail
Expand Down Expand Up @@ -255,12 +255,12 @@
this.maybeLow();
if (!isBrowser) {
let pending = frames.length;
const next = () => { if (--pending === 0) defer(step); };

Check warning on line 258 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

This line has 2 statements. Maximum allowed is 1

Check warning on line 258 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

This line has 2 statements. Maximum allowed is 1

Check warning on line 258 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

This line has 2 statements. Maximum allowed is 1
for (const f of frames) {
try { sock.send(f, next); } catch (_e) { next(); }

Check warning on line 260 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

This line has 3 statements. Maximum allowed is 1

Check warning on line 260 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

This line has 3 statements. Maximum allowed is 1

Check warning on line 260 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

This line has 3 statements. Maximum allowed is 1
}
} else {
for (const f of frames) { try { sock.send(f); } catch (_e) { /* closed */ } }

Check warning on line 263 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

This line has 3 statements. Maximum allowed is 1

Check warning on line 263 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

This line has 3 statements. Maximum allowed is 1

Check warning on line 263 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

This line has 3 statements. Maximum allowed is 1
setTimeout(step, 0); // browsers: pace via bufferedAmount check above
}
};
Expand Down Expand Up @@ -331,8 +331,8 @@
minHoldMs: 2000 // never release a hold faster than this (flap guard)
};
const P = { cfg, held: false, seq: 0, manual: null, entries: new Set(),
listeners: new Set(), timer: null, heldSince: 0, last: { aggBytes: 0, rss: 0 } };

Check warning on line 334 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

Expected indentation of 8 spaces but found 16

Check warning on line 334 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

Expected indentation of 8 spaces but found 16

Check warning on line 334 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

Expected indentation of 8 spaces but found 16
function emit(ev) { for (const cb of P.listeners) { try { cb(ev); } catch (_e) { /* listener error */ } } }

Check warning on line 335 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (20.x)

This line has 4 statements. Maximum allowed is 1

Check warning on line 335 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (22.x)

This line has 4 statements. Maximum allowed is 1

Check warning on line 335 in src/ToolSocketNB.js

View workflow job for this annotation

GitHub Actions / Jest (18.x)

This line has 4 statements. Maximum allowed is 1
function broadcast() {
for (const e of P.entries) { try { if (e.ready()) e.sendHold(P.held, P.seq); } catch (_e) { /* socket race */ } }
}
Expand Down
2 changes: 1 addition & 1 deletion src/constants.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const MAX_MESSAGE_SIZE = 3000 * 1024 * 1024;
const VALID_FILETYPES = ['css', 'csv', 'dat', 'fbx', 'gif', 'glb', 'htm', 'html', 'jpg', 'jpeg', 'js', 'json', 'map', 'mp4', 'obj', 'otf', 'pdf', 'ply', 'png', 'pvs', 'pvz', 'splat', 'svg', 'ttf', 'wasm', 'webm', 'webp', 'woff', 'xml', 'zip', '3dt', 'rad', 'radc'];
const VALID_FILETYPES = ['css', 'csv', 'dat', 'fbx', 'gif', 'glb', 'htm', 'html', 'jpg', 'jpeg', 'js', 'json', 'map', 'mp4', 'ms4', 'obj', 'otf', 'pdf', 'ply', 'png', 'pvs', 'pvz', 'splat', 'svg', 'ttf', 'wasm', 'webm', 'webp', 'woff', 'xml', 'zip', '3dt', 'rad', 'radc'];
/**
* @typedef {'action' | 'beat' | 'delete' | 'get' | 'io' | 'keys' | 'message' | 'new' | 'patch' | 'ping' | 'post' | 'pub' | 'put' | 'res' | 'sub' | 'unsub' | 'meta'} MethodString
*/
Expand Down
Loading