@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.
|
@@ -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
|
|
105
|
-
|
|
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
|
-
|
|
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
|
|
605
|
-
|
|
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
|
+
"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": {
|