@volter/tabnode 0.5.34 → 0.5.35

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,
@@ -853,8 +853,8 @@ async function handleVirtualRequest(request, port, path, rooted = false) {
853
853
  /**
854
854
  * Handle a streaming request
855
855
  */
856
- async function handleStreamingRequest(host, port, method, path, headers, body) {
857
- const { stream, headersPromise, id } = await sendStreamingRequest(host, port, method, path, headers, body);
856
+ async function handleStreamingRequest(host, port, method, path, headers, body, destination = '') {
857
+ const { stream, headersPromise, id } = await sendStreamingRequest(host, port, method, path, headers, body, destination);
858
858
 
859
859
  // Wait for headers to arrive
860
860
  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 = Function.prototype.apply;
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 = functionApply;
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 = functionApply;
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 = functionApply;
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-DsSAHE2C.js",
40296
+ "/assets/runtime-worker-DEgP1CYS.js",
40297
40297
  import.meta.url
40298
40298
  ),
40299
40299
  { type: "module" }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@volter/tabnode",
3
- "version": "0.5.34",
3
+ "version": "0.5.35",
4
4
  "description": "Node's own library, in a browser tab.",
5
5
  "type": "module",
6
6
  "license": "MIT",