Translate transcripts with Opus-MT in a dedicated translation worker
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
82ed34c7f9
commit
a0748b5fa6
10 files changed
+615
-5
No files matched your search
+9
-1
@@ -223,7 +223,8 @@ async function productionServeOptions(): Promise<ServeOptions> {
|
||||
* Bun's bundler does not currently follow `new Worker(...)` graphs (verified
|
||||
* with Bun 1.3: both `bun build` and the dev server leave the call untouched),
|
||||
* so worker-like entrypoints are bundled at startup and served from stable
|
||||
* URLs. The UI spawns `new Worker("/inference.worker.js")`; the service
|
||||
* URLs. The UI spawns `new Worker("/inference.worker.js")` (and
|
||||
* "/translate.worker.js" for transcript translation, D-WS4b); the service
|
||||
* worker registers as "/sw.js".
|
||||
*/
|
||||
async function bundleEntrypoint(relativePath: string): Promise<string> {
|
||||
@@ -249,6 +250,8 @@ async function developmentServeOptions(): Promise<ServeOptions> {
|
||||
const { default: index } = await import("./index.html");
|
||||
|
||||
const workerScript = await bundleEntrypoint("./worker/inference.worker.ts");
|
||||
// Transcript translation runs in its own worker (D-WS4b).
|
||||
const translateWorkerScript = await bundleEntrypoint("./worker/translate.worker.ts");
|
||||
// Dev SW: empty precache list — assets are unhashed here, so the shell is
|
||||
// runtime-cached network-first instead (see src/pwa/sw.ts).
|
||||
const swScript = injectPrecacheManifest(
|
||||
@@ -283,6 +286,11 @@ async function developmentServeOptions(): Promise<ServeOptions> {
|
||||
if (pathname.endsWith("/inference.worker.js")) {
|
||||
return withIsolationHeaders(new Response(workerScript, { headers: scriptHeaders }));
|
||||
}
|
||||
if (pathname.endsWith("/translate.worker.js")) {
|
||||
return withIsolationHeaders(
|
||||
new Response(translateWorkerScript, { headers: scriptHeaders }),
|
||||
);
|
||||
}
|
||||
if (pathname.endsWith("/sw.js")) {
|
||||
return withIsolationHeaders(
|
||||
new Response(swScript, { headers: { ...scriptHeaders, "Cache-Control": "no-cache" } }),
|
||||
|
||||
Reference in new issue
Block a user