@volter/tabnode 0.5.34 → 0.5.36
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
CHANGED
|
@@ -289,7 +289,7 @@ function handleMainMessage(host, event) {
|
|
|
289
289
|
/**
|
|
290
290
|
* Send request to main thread and wait for response
|
|
291
291
|
*/
|
|
292
|
-
async function sendRequest(host, port, method, url, headers, body) {
|
|
292
|
+
async function sendRequest(host, port, method, url, headers, body, destination = '') {
|
|
293
293
|
DEBUG && console.log('[SW] sendRequest called, host:', !!host, 'url:', url);
|
|
294
294
|
|
|
295
295
|
if (!host) {
|
|
@@ -312,7 +312,7 @@ async function sendRequest(host, port, method, url, headers, body) {
|
|
|
312
312
|
host.port.postMessage({
|
|
313
313
|
type: 'request',
|
|
314
314
|
id,
|
|
315
|
-
data: { port, method, url, headers, body },
|
|
315
|
+
data: { port, method, url, headers, body, destination },
|
|
316
316
|
});
|
|
317
317
|
});
|
|
318
318
|
}
|
|
@@ -321,7 +321,7 @@ async function sendRequest(host, port, method, url, headers, body) {
|
|
|
321
321
|
* Send streaming request to main thread
|
|
322
322
|
* Returns a ReadableStream that receives chunks from main thread
|
|
323
323
|
*/
|
|
324
|
-
async function sendStreamingRequest(host, port, method, url, headers, body) {
|
|
324
|
+
async function sendStreamingRequest(host, port, method, url, headers, body, destination = '') {
|
|
325
325
|
DEBUG && console.log('[SW] sendStreamingRequest called, url:', url);
|
|
326
326
|
|
|
327
327
|
if (!host) {
|
|
@@ -351,7 +351,7 @@ async function sendStreamingRequest(host, port, method, url, headers, body) {
|
|
|
351
351
|
host.port.postMessage({
|
|
352
352
|
type: 'request',
|
|
353
353
|
id,
|
|
354
|
-
data: { port, method, url, headers, body, streaming: true },
|
|
354
|
+
data: { port, method, url, headers, body, streaming: true, destination },
|
|
355
355
|
});
|
|
356
356
|
},
|
|
357
357
|
cancel() {
|
|
@@ -365,7 +365,7 @@ async function sendStreamingRequest(host, port, method, url, headers, body) {
|
|
|
365
365
|
// A Node HTTP producer must stop when its consumer stops reading and must
|
|
366
366
|
// observe disconnect. One pull credit bounds the service-worker response queue;
|
|
367
367
|
// this protocol requires a paired host bridge and is negotiated per port.
|
|
368
|
-
async function sendControlledRequest(host, port, method, url, headers, body, signal) {
|
|
368
|
+
async function sendControlledRequest(host, port, method, url, headers, body, signal, destination = '') {
|
|
369
369
|
if (!host) throw new Error('Service Worker not initialized');
|
|
370
370
|
if (signal.aborted) throw signal.reason;
|
|
371
371
|
const channel = host.port;
|
|
@@ -450,7 +450,7 @@ async function sendControlledRequest(host, port, method, url, headers, body, sig
|
|
|
450
450
|
signal.addEventListener('abort', abort, { once: true });
|
|
451
451
|
try {
|
|
452
452
|
channel.postMessage({ type: 'request', id,
|
|
453
|
-
data: { port, method, url, headers, body, streaming: true, flowControl: 1 } });
|
|
453
|
+
data: { port, method, url, headers, body, streaming: true, flowControl: 1, destination } });
|
|
454
454
|
if (signal.aborted) abort();
|
|
455
455
|
const head = await headersPromise;
|
|
456
456
|
const noBody = method === 'HEAD' || [204, 205, 304].includes(head.statusCode);
|
|
@@ -775,7 +775,7 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
775
775
|
if (registration) {
|
|
776
776
|
if (host.flowControlledPorts.get(port) !== registration || host.port !== registration.channel || hosts.get(host.id) !== host)
|
|
777
777
|
throw new Error('Virtual server registration changed during upload');
|
|
778
|
-
return await sendControlledRequest(host, port, request.method, path, headers, body, request.signal);
|
|
778
|
+
return await sendControlledRequest(host, port, request.method, path, headers, body, request.signal, request.destination);
|
|
779
779
|
}
|
|
780
780
|
|
|
781
781
|
// Legacy peers retain their old selection until they negotiate flow control.
|
|
@@ -783,12 +783,12 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
783
783
|
|
|
784
784
|
if (isStreamingCandidate) {
|
|
785
785
|
DEBUG && console.log('[SW] Using streaming mode for:', path);
|
|
786
|
-
return handleStreamingRequest(host, port, request.method, path, headers, body);
|
|
786
|
+
return handleStreamingRequest(host, port, request.method, path, headers, body, request.destination);
|
|
787
787
|
}
|
|
788
788
|
DEBUG && console.log('[SW] Using non-streaming mode for:', request.method, path);
|
|
789
789
|
|
|
790
790
|
// Send to main thread
|
|
791
|
-
const response = await sendRequest(host, port, request.method, path, headers, body);
|
|
791
|
+
const response = await sendRequest(host, port, request.method, path, headers, body, request.destination);
|
|
792
792
|
|
|
793
793
|
DEBUG && console.log('[SW] Got response from main thread:', {
|
|
794
794
|
statusCode: response.statusCode,
|
|
@@ -796,6 +796,16 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
796
796
|
bodyBase64Length: response.bodyBase64?.length,
|
|
797
797
|
});
|
|
798
798
|
|
|
799
|
+
// The frame's embedding policy goes on every answer, an empty one too:
|
|
800
|
+
// the page is cross-origin isolated, and a document without these
|
|
801
|
+
// headers is blocked in its frame (an empty 200 lost the preview).
|
|
802
|
+
const respHeaders = new Headers(response.headers);
|
|
803
|
+
respHeaders.set('Cross-Origin-Embedder-Policy', 'credentialless');
|
|
804
|
+
respHeaders.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
805
|
+
respHeaders.set('Cross-Origin-Resource-Policy', 'cross-origin');
|
|
806
|
+
// Remove any headers that might block iframe loading
|
|
807
|
+
respHeaders.delete('X-Frame-Options');
|
|
808
|
+
|
|
799
809
|
// Decode base64 body and create response
|
|
800
810
|
let finalResponse;
|
|
801
811
|
if (response.bodyBase64 && response.bodyBase64.length > 0) {
|
|
@@ -803,19 +813,13 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
803
813
|
const bytes = base64ToBytes(response.bodyBase64);
|
|
804
814
|
DEBUG && console.log('[SW] Decoded body length:', bytes.length);
|
|
805
815
|
|
|
806
|
-
// Use Blob to ensure proper body handling
|
|
807
|
-
|
|
816
|
+
// Use Blob to ensure proper body handling. Its type is the server's,
|
|
817
|
+
// or none: a document the server gave no type is the browser's to
|
|
818
|
+
// sniff, and an invented octet-stream made a page a download.
|
|
819
|
+
const declared = new Headers(response.headers).get('content-type');
|
|
820
|
+
const blob = new Blob([bytes], declared ? { type: declared } : {});
|
|
808
821
|
DEBUG && console.log('[SW] Created blob size:', blob.size);
|
|
809
822
|
|
|
810
|
-
// Merge response headers with CORP/COEP headers to allow iframe embedding
|
|
811
|
-
// The parent page has COEP: credentialless, so we need matching headers
|
|
812
|
-
const respHeaders = new Headers(response.headers);
|
|
813
|
-
respHeaders.set('Cross-Origin-Embedder-Policy', 'credentialless');
|
|
814
|
-
respHeaders.set('Cross-Origin-Opener-Policy', 'same-origin');
|
|
815
|
-
respHeaders.set('Cross-Origin-Resource-Policy', 'cross-origin');
|
|
816
|
-
// Remove any headers that might block iframe loading
|
|
817
|
-
respHeaders.delete('X-Frame-Options');
|
|
818
|
-
|
|
819
823
|
finalResponse = new Response(blob, {
|
|
820
824
|
status: response.statusCode,
|
|
821
825
|
statusText: response.statusMessage,
|
|
@@ -832,7 +836,7 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
832
836
|
finalResponse = new Response(null, {
|
|
833
837
|
status: response.statusCode,
|
|
834
838
|
statusText: response.statusMessage,
|
|
835
|
-
headers:
|
|
839
|
+
headers: respHeaders,
|
|
836
840
|
});
|
|
837
841
|
}
|
|
838
842
|
|
|
@@ -853,8 +857,8 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
|
|
|
853
857
|
/**
|
|
854
858
|
* Handle a streaming request
|
|
855
859
|
*/
|
|
856
|
-
async function handleStreamingRequest(host, port, method, path, headers, body) {
|
|
857
|
-
const { stream, headersPromise, id } = await sendStreamingRequest(host, port, method, path, headers, body);
|
|
860
|
+
async function handleStreamingRequest(host, port, method, path, headers, body, destination = '') {
|
|
861
|
+
const { stream, headersPromise, id } = await sendStreamingRequest(host, port, method, path, headers, body, destination);
|
|
858
862
|
|
|
859
863
|
// Wait for headers to arrive
|
|
860
864
|
const responseData = await headersPromise;
|
|
@@ -21154,10 +21154,17 @@ var implementation$1 = function bind2(that) {
|
|
|
21154
21154
|
var implementation = implementation$1;
|
|
21155
21155
|
var functionBind = Function.prototype.bind || implementation;
|
|
21156
21156
|
var functionCall = Function.prototype.call;
|
|
21157
|
-
var functionApply
|
|
21157
|
+
var functionApply;
|
|
21158
|
+
var hasRequiredFunctionApply;
|
|
21159
|
+
function requireFunctionApply() {
|
|
21160
|
+
if (hasRequiredFunctionApply) return functionApply;
|
|
21161
|
+
hasRequiredFunctionApply = 1;
|
|
21162
|
+
functionApply = Function.prototype.apply;
|
|
21163
|
+
return functionApply;
|
|
21164
|
+
}
|
|
21158
21165
|
var reflectApply = typeof Reflect !== "undefined" && Reflect && Reflect.apply;
|
|
21159
21166
|
var bind$2 = functionBind;
|
|
21160
|
-
var $apply$1 =
|
|
21167
|
+
var $apply$1 = requireFunctionApply();
|
|
21161
21168
|
var $call$2 = functionCall;
|
|
21162
21169
|
var $reflectApply = reflectApply;
|
|
21163
21170
|
var actualApply = $reflectApply || bind$2.call($call$2, $apply$1);
|
|
@@ -21277,7 +21284,7 @@ var hasSymbols = requireHasSymbols()();
|
|
|
21277
21284
|
var getProto = requireGetProto();
|
|
21278
21285
|
var $ObjectGPO = requireObject_getPrototypeOf();
|
|
21279
21286
|
var $ReflectGPO = requireReflect_getPrototypeOf();
|
|
21280
|
-
var $apply =
|
|
21287
|
+
var $apply = requireFunctionApply();
|
|
21281
21288
|
var $call = functionCall;
|
|
21282
21289
|
var needsEval = {};
|
|
21283
21290
|
var TypedArray = typeof Uint8Array === "undefined" || !getProto ? undefined$1 : getProto(Uint8Array);
|
|
@@ -21918,7 +21925,7 @@ function requireApplyBind() {
|
|
|
21918
21925
|
if (hasRequiredApplyBind) return applyBind;
|
|
21919
21926
|
hasRequiredApplyBind = 1;
|
|
21920
21927
|
var bind3 = functionBind;
|
|
21921
|
-
var $apply2 =
|
|
21928
|
+
var $apply2 = requireFunctionApply();
|
|
21922
21929
|
var actualApply$1 = actualApply;
|
|
21923
21930
|
applyBind = function applyBind2() {
|
|
21924
21931
|
return actualApply$1(bind3, $apply2, arguments);
|
package/dist/index.mjs
CHANGED
|
@@ -40293,7 +40293,7 @@ class WorkerRuntime {
|
|
|
40293
40293
|
this.worker = new Worker(
|
|
40294
40294
|
new URL(
|
|
40295
40295
|
/* @vite-ignore */
|
|
40296
|
-
"/assets/runtime-worker-
|
|
40296
|
+
"/assets/runtime-worker-DEgP1CYS.js",
|
|
40297
40297
|
import.meta.url
|
|
40298
40298
|
),
|
|
40299
40299
|
{ type: "module" }
|