@angular-helpers/worker-http 21.2.3 → 21.2.4

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.
@@ -117,7 +117,7 @@ function toSerializableRequest(req) {
117
117
  }
118
118
  return {
119
119
  method: req.method,
120
- url: req.urlWithParams,
120
+ url: req.url,
121
121
  headers,
122
122
  params,
123
123
  body: req.body,
@@ -101,10 +101,8 @@ function scanDirectory(dir, interceptors, rootDir) {
101
101
  * Converts relative paths to valid import specifiers.
102
102
  */
103
103
  function generateInterceptorImports(interceptorPaths, workerFilePath) {
104
- return interceptorPaths.map((interceptorPath, index) => {
105
- // Create a valid identifier from the path
106
- const identifier = `interceptor_${index}_${interceptorPath.replace(/[^a-zA-Z0-9]/g, '_')}`;
107
- return `import ${identifier} from '${interceptorPath}';`;
104
+ return interceptorPaths.map((interceptorPath) => {
105
+ return `import '${interceptorPath}';`;
108
106
  });
109
107
  }
110
108
  /**
@@ -1,3 +1,5 @@
1
+ import { detectTransferables } from '@angular-helpers/worker-http/transport';
2
+
1
3
  /**
2
4
  * Composes interceptor functions around a final handler, producing a single
3
5
  * `(req, signal?) => Promise<resp>` chain. Pure — no side effects.
@@ -94,7 +96,10 @@ function attachPortLoop(port, chain) {
94
96
  return;
95
97
  const responses = responseBuffer;
96
98
  responseBuffer = [];
97
- port.postMessage({ type: 'batch-response', responses });
99
+ const transferables = [
100
+ ...new Set(responses.flatMap((res) => res.type === 'response' && res.result ? detectTransferables(res.result.body) : [])),
101
+ ];
102
+ port.postMessage({ type: 'batch-response', responses }, transferables);
98
103
  });
99
104
  }
100
105
  const processMessage = async (msg) => {
@@ -599,13 +604,12 @@ function createConfigurableWorkerPipeline() {
599
604
  const specs = data.specs ?? [];
600
605
  const fns = specs.map((spec) => resolveSpec(spec));
601
606
  const chain = buildChain(fns, (req, signal) => executeFetch(req, signal));
607
+ // Clear initial handler to prevent double handling and infinite loops.
608
+ self.onmessage = null;
602
609
  // Swap to the regular request loop and replay any buffered messages.
603
610
  attachRequestLoop(chain);
604
- const handler = self.onmessage;
605
- if (handler) {
606
- for (const buffered of pending) {
607
- handler.call(self, buffered);
608
- }
611
+ for (const buffered of pending) {
612
+ self.dispatchEvent(buffered);
609
613
  }
610
614
  pending.length = 0;
611
615
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular-helpers/worker-http",
3
- "version": "21.2.3",
3
+ "version": "21.2.4",
4
4
  "description": "Angular HTTP over Web Workers — off-main-thread HTTP pipelines with configurable interceptors, WebCrypto security, and pluggable serialization",
5
5
  "schematics": "./schematics/collection.json",
6
6
  "exports": {