fix: worker use only i18n keys instead of full i18n

This commit is contained in:
2026-09-13 12:44:51 +05:00
parent 49d0a9444e
commit c2f3838485
12 changed files with 111 additions and 38 deletions
+6 -1
View File
@@ -95,6 +95,7 @@ function ensureWorker(): Worker | null {
data: Uint8ClampedArray;
}[];
text?: string;
textVars?: Record<string, string | number>;
error?: string;
errorKey?: string;
errorVars?: Record<string, string | number>;
@@ -120,7 +121,11 @@ function ensureWorker(): Worker | null {
})),
});
} else if (payload.ok && typeof payload.text === "string") {
entry.resolve(payload.text);
entry.resolve(
payload.textVars
? { key: payload.text, vars: payload.textVars }
: payload.text,
);
} else if (payload.errorKey) {
entry.reject(new ToolError(payload.errorKey, payload.errorVars));
} else {
+10
View File
@@ -20,6 +20,7 @@ type WorkerResponse =
height?: number;
data?: Uint8ClampedArray;
text?: string;
textVars?: Record<string, string | number>;
files?: WorkerImageFile[];
}
| {
@@ -67,6 +68,15 @@ async function handle(request: WorkerRequest): Promise<void> {
} satisfies WorkerResponse);
return;
}
if ("key" in output) {
(self as unknown as Worker).postMessage({
id: request.id,
ok: true,
text: output.key,
textVars: output.vars,
} satisfies WorkerResponse);
return;
}
if ("files" in output) {
const files = output.files.map((file) => ({
name: file.name,