@volter/tabnode 0.5.49 → 0.5.51
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/__sw__.js +17 -6
- package/dist/assets/{runtime-worker-C1IV4qnr.js → runtime-worker-Cu2mr9G9.js} +1076 -67
- package/dist/index.mjs +1083 -81
- package/dist/{port-bridge-CixAESwA.js → port-bridge-Cergvxli.js} +22 -18
- package/dist/port-bridge.d.ts +5 -0
- package/dist/port-bridge.mjs +1 -1
- package/dist/shims/crypto-cipher.d.ts +203 -0
- package/dist/shims/crypto.d.ts +465 -1
- package/package.json +2 -1
- package/src/port-bridge.ts +21 -15
- package/src/shims/crypto-cipher.ts +354 -0
- package/src/shims/crypto.ts +27 -2
package/dist/__sw__.js
CHANGED
|
@@ -99,6 +99,16 @@ let requestId = 0;
|
|
|
99
99
|
const controlledUploads = new Set();
|
|
100
100
|
const MAX_STREAM_CHUNK_BYTES = 65536;
|
|
101
101
|
|
|
102
|
+
// A response chunk as the host sent it: its bytes, transferred, from a bridge this worker told it
|
|
103
|
+
// takes them (`sw-capabilities`), or base64 from one that predates that. Base64 cost the page's
|
|
104
|
+
// own thread an encode of every byte a virtual server sent (5.4 s of 46 while a 307 MB document
|
|
105
|
+
// crossed, measured in the hosted model editor) and left a third more garbage than the bytes.
|
|
106
|
+
function chunkBytes(data) {
|
|
107
|
+
if (data?.chunk instanceof Uint8Array) return data.chunk;
|
|
108
|
+
if (typeof data?.chunkBase64 === 'string') return base64ToBytes(data.chunkBase64);
|
|
109
|
+
return null;
|
|
110
|
+
}
|
|
111
|
+
|
|
102
112
|
function updateFlowControl(host, type, data) {
|
|
103
113
|
if (type === 'server-registered' || type === 'server-unregistered') {
|
|
104
114
|
for (const upload of controlledUploads) {
|
|
@@ -157,6 +167,7 @@ self.addEventListener('message', (event) => {
|
|
|
157
167
|
mainPort.onmessage = (message) => {
|
|
158
168
|
if (hosts.get(host.id) === host && host.port === initializedPort) handleMainMessage(host, message);
|
|
159
169
|
};
|
|
170
|
+
mainPort.postMessage({ type: 'sw-capabilities', data: { binaryChunks: 1 } });
|
|
160
171
|
if (data && Array.isArray(data.ownDocuments)) host.ownDocuments = new Set(data.ownDocuments.map((path) => ownPath(String(path))));
|
|
161
172
|
// Markup a frame's document served from this host's servers starts with
|
|
162
173
|
// (after its doctype): the page's first script, before the document's own.
|
|
@@ -257,9 +268,8 @@ function handleMainMessage(host, event) {
|
|
|
257
268
|
const pending = pendingRequests.get(id);
|
|
258
269
|
if (pending && pending.streamController) {
|
|
259
270
|
try {
|
|
260
|
-
|
|
261
|
-
if (
|
|
262
|
-
const bytes = base64ToBytes(data.chunkBase64);
|
|
271
|
+
const bytes = chunkBytes(data);
|
|
272
|
+
if (bytes && bytes.byteLength > 0) {
|
|
263
273
|
pending.streamController.enqueue(bytes);
|
|
264
274
|
DEBUG && console.log('[SW] chunk enqueued, bytes:', bytes.length);
|
|
265
275
|
}
|
|
@@ -428,10 +438,11 @@ async function sendControlledRequest(host, port, method, url, headers, body, sig
|
|
|
428
438
|
clearTimeout(headerTimeout);
|
|
429
439
|
resolveHeaders(data);
|
|
430
440
|
} else if (type === 'stream-chunk' && headed && credited) {
|
|
431
|
-
if (typeof data?.chunkBase64
|
|
432
|
-
|
|
441
|
+
if (typeof data?.chunkBase64 === 'string'
|
|
442
|
+
&& data.chunkBase64.length > Math.ceil(MAX_STREAM_CHUNK_BYTES / 3) * 4)
|
|
433
443
|
throw new Error('Stream chunk exceeds transport limit');
|
|
434
|
-
const bytes =
|
|
444
|
+
const bytes = chunkBytes(data);
|
|
445
|
+
if (!bytes) throw new Error('Stream chunk carries no bytes');
|
|
435
446
|
if (bytes.byteLength > MAX_STREAM_CHUNK_BYTES)
|
|
436
447
|
throw new Error('Stream chunk exceeds transport limit');
|
|
437
448
|
credited = false;
|