@defensestation/yjs-local-translator 0.3.0-dev.2.d2befbc
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/LICENSE +21 -0
- package/README.md +519 -0
- package/dist/blocknote.d.ts +62 -0
- package/dist/blocknote.d.ts.map +1 -0
- package/dist/blocknote.js +379 -0
- package/dist/blocknote.js.map +1 -0
- package/dist/browser-translator.d.ts +81 -0
- package/dist/browser-translator.d.ts.map +1 -0
- package/dist/browser-translator.js +452 -0
- package/dist/browser-translator.js.map +1 -0
- package/dist/chunking.d.ts +16 -0
- package/dist/chunking.d.ts.map +1 -0
- package/dist/chunking.js +95 -0
- package/dist/chunking.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/metadata.d.ts +26 -0
- package/dist/metadata.d.ts.map +1 -0
- package/dist/metadata.js +41 -0
- package/dist/metadata.js.map +1 -0
- package/dist/model-catalog.d.ts +14 -0
- package/dist/model-catalog.d.ts.map +1 -0
- package/dist/model-catalog.js +41 -0
- package/dist/model-catalog.js.map +1 -0
- package/dist/native-translation.d.ts +37 -0
- package/dist/native-translation.d.ts.map +1 -0
- package/dist/native-translation.js +80 -0
- package/dist/native-translation.js.map +1 -0
- package/dist/protocol.d.ts +59 -0
- package/dist/protocol.d.ts.map +1 -0
- package/dist/protocol.js +2 -0
- package/dist/protocol.js.map +1 -0
- package/dist/translation-memory.d.ts +50 -0
- package/dist/translation-memory.d.ts.map +1 -0
- package/dist/translation-memory.js +117 -0
- package/dist/translation-memory.js.map +1 -0
- package/dist/translator.worker.d.ts +2 -0
- package/dist/translator.worker.d.ts.map +1 -0
- package/dist/translator.worker.js +304 -0
- package/dist/translator.worker.js.map +1 -0
- package/dist/yjs.d.ts +98 -0
- package/dist/yjs.d.ts.map +1 -0
- package/dist/yjs.js +291 -0
- package/dist/yjs.js.map +1 -0
- package/package.json +78 -0
package/dist/metadata.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
const FNV_OFFSET_BASIS = 0xcbf29ce484222325n;
|
|
2
|
+
const FNV_PRIME = 0x100000001b3n;
|
|
3
|
+
const FNV_MASK = 0xffffffffffffffffn;
|
|
4
|
+
/**
|
|
5
|
+
* FNV-1a 64-bit hash of a string, returned as a fixed-width hex string.
|
|
6
|
+
* Used to compare a stored source snapshot against the current source
|
|
7
|
+
* without storing the full text.
|
|
8
|
+
*/
|
|
9
|
+
export function hashText(text) {
|
|
10
|
+
let hash = FNV_OFFSET_BASIS;
|
|
11
|
+
for (let index = 0; index < text.length; index += 1) {
|
|
12
|
+
hash ^= BigInt(text.charCodeAt(index));
|
|
13
|
+
hash = (hash * FNV_PRIME) & FNV_MASK;
|
|
14
|
+
}
|
|
15
|
+
return hash.toString(16).padStart(16, "0");
|
|
16
|
+
}
|
|
17
|
+
export function createTranslationMetadata(sourceText, result) {
|
|
18
|
+
return {
|
|
19
|
+
sourceHash: hashText(sourceText),
|
|
20
|
+
sourceLanguage: result.sourceLanguage,
|
|
21
|
+
targetLanguage: result.targetLanguage,
|
|
22
|
+
models: [...result.models],
|
|
23
|
+
engine: result.engine,
|
|
24
|
+
translatedAt: Date.now()
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Returns true when the metadata is missing, malformed, or was created from
|
|
29
|
+
* a different source text than the one passed in.
|
|
30
|
+
*/
|
|
31
|
+
export function isTranslationStale(sourceText, metadata) {
|
|
32
|
+
if (!metadata || typeof metadata !== "object") {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const sourceHash = metadata.sourceHash;
|
|
36
|
+
if (typeof sourceHash !== "string") {
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
return hashText(sourceText) !== sourceHash;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=metadata.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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K,QAAQ,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,QAAQ,CAAC,UAAU,CAAC,KAAK,UAAU,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export type LanguageCode = "en" | "fr" | "es" | "de" | "zh" | "ja" | "ar";
|
|
2
|
+
export interface TranslationModel {
|
|
3
|
+
id: string;
|
|
4
|
+
label: string;
|
|
5
|
+
}
|
|
6
|
+
export type ModelCatalog = Record<string, TranslationModel>;
|
|
7
|
+
export declare const DEFAULT_MODEL_CATALOG: ModelCatalog;
|
|
8
|
+
/**
|
|
9
|
+
* Normalizes a language tag to its lowercase primary subtag, so "EN",
|
|
10
|
+
* "en-US", and "en_GB" all resolve to "en".
|
|
11
|
+
*/
|
|
12
|
+
export declare function normalizeLanguageCode(code: string): string;
|
|
13
|
+
export declare function getTranslationRoute(sourceLanguage: string, targetLanguage: string, catalog?: ModelCatalog): TranslationModel[];
|
|
14
|
+
//# sourceMappingURL=model-catalog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-catalog.d.ts","sourceRoot":"","sources":["../src/model-catalog.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,CAAC;AAE1E,MAAM,WAAW,gBAAgB;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;AAE5D,eAAO,MAAM,qBAAqB,EAAE,YAanC,CAAC;AAEF;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED,wBAAgB,mBAAmB,CACjC,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,OAAO,GAAE,YAAoC,GAC5C,gBAAgB,EAAE,CAyBpB"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export const DEFAULT_MODEL_CATALOG = {
|
|
2
|
+
"en>fr": { id: "Xenova/opus-mt-en-fr", label: "English → French" },
|
|
3
|
+
"fr>en": { id: "Xenova/opus-mt-fr-en", label: "French → English" },
|
|
4
|
+
"en>es": { id: "Xenova/opus-mt-en-es", label: "English → Spanish" },
|
|
5
|
+
"es>en": { id: "Xenova/opus-mt-es-en", label: "Spanish → English" },
|
|
6
|
+
"en>de": { id: "Xenova/opus-mt-en-de", label: "English → German" },
|
|
7
|
+
"de>en": { id: "Xenova/opus-mt-de-en", label: "German → English" },
|
|
8
|
+
"en>zh": { id: "Xenova/opus-mt-en-zh", label: "English → Chinese" },
|
|
9
|
+
"zh>en": { id: "Xenova/opus-mt-zh-en", label: "Chinese → English" },
|
|
10
|
+
"en>ja": { id: "Xenova/opus-mt-en-jap", label: "English → Japanese" },
|
|
11
|
+
"ja>en": { id: "Xenova/opus-mt-ja-en", label: "Japanese → English" },
|
|
12
|
+
"en>ar": { id: "Xenova/opus-mt-en-ar", label: "English → Arabic" },
|
|
13
|
+
"ar>en": { id: "Xenova/opus-mt-ar-en", label: "Arabic → English" }
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Normalizes a language tag to its lowercase primary subtag, so "EN",
|
|
17
|
+
* "en-US", and "en_GB" all resolve to "en".
|
|
18
|
+
*/
|
|
19
|
+
export function normalizeLanguageCode(code) {
|
|
20
|
+
return code.trim().toLowerCase().split(/[-_]/, 1)[0] ?? "";
|
|
21
|
+
}
|
|
22
|
+
export function getTranslationRoute(sourceLanguage, targetLanguage, catalog = DEFAULT_MODEL_CATALOG) {
|
|
23
|
+
const source = normalizeLanguageCode(sourceLanguage);
|
|
24
|
+
const target = normalizeLanguageCode(targetLanguage);
|
|
25
|
+
if (source === target) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
const direct = catalog[`${source}>${target}`];
|
|
29
|
+
if (direct) {
|
|
30
|
+
return [direct];
|
|
31
|
+
}
|
|
32
|
+
if (source !== "en" && target !== "en") {
|
|
33
|
+
const toEnglish = catalog[`${source}>en`];
|
|
34
|
+
const fromEnglish = catalog[`en>${target}`];
|
|
35
|
+
if (toEnglish && fromEnglish) {
|
|
36
|
+
return [toEnglish, fromEnglish];
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
throw new Error(`The language pair "${sourceLanguage}" → "${targetLanguage}" is not configured.`);
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=model-catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-catalog.js","sourceRoot":"","sources":["../src/model-catalog.ts"],"names":[],"mappings":"AASA,MAAM,CAAC,MAAM,qBAAqB,GAAiB;IACjD,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,kBAAkB,EAAE;IAClE,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,kBAAkB,EAAE;IAClE,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,mBAAmB,EAAE;IACnE,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,mBAAmB,EAAE;IACnE,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,kBAAkB,EAAE;IAClE,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,kBAAkB,EAAE;IAClE,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,mBAAmB,EAAE;IACnE,OAAO,EAAE,EAAE,EAAE,EAAE,sBAAsB,EAAE,KAAK,EAAE,mBAAmB,EAAE;IACnE,OAAO,EAAE,EAAE,EAAE,EAAE,uBAAuB,EAAE,KAAK,EAAE,oBAAoB,EAAE;IACr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sB,CACjF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type NativeTranslationAvailability = "unavailable" | "downloadable" | "downloading" | "available";
|
|
2
|
+
export interface NativeTranslatorInstance {
|
|
3
|
+
translate(text: string, options?: {
|
|
4
|
+
signal?: AbortSignal;
|
|
5
|
+
}): Promise<string>;
|
|
6
|
+
translateStreaming?(text: string, options?: {
|
|
7
|
+
signal?: AbortSignal;
|
|
8
|
+
}): ReadableStream<string>;
|
|
9
|
+
destroy?(): void;
|
|
10
|
+
}
|
|
11
|
+
export interface NativeTranslatorApi {
|
|
12
|
+
availability(options: {
|
|
13
|
+
sourceLanguage: string;
|
|
14
|
+
targetLanguage: string;
|
|
15
|
+
}): Promise<NativeTranslationAvailability>;
|
|
16
|
+
create(options: {
|
|
17
|
+
sourceLanguage: string;
|
|
18
|
+
targetLanguage: string;
|
|
19
|
+
monitor?: (monitor: EventTarget) => void;
|
|
20
|
+
}): Promise<NativeTranslatorInstance>;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the browser's built-in Translator API (Chrome 138+, Edge) when it
|
|
24
|
+
* is exposed on globalThis, or undefined everywhere else.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getNativeTranslatorApi(): NativeTranslatorApi | undefined;
|
|
27
|
+
/**
|
|
28
|
+
* Caches one native translator instance per language pair. Creation failures
|
|
29
|
+
* and unavailable pairs resolve to undefined so the caller can fall back to
|
|
30
|
+
* the worker engine.
|
|
31
|
+
*/
|
|
32
|
+
export declare class NativeTranslatorPool {
|
|
33
|
+
private readonly instances;
|
|
34
|
+
acquire(sourceLanguage: string, targetLanguage: string, onDownloadProgress?: (progress: number) => void): Promise<NativeTranslatorInstance | undefined>;
|
|
35
|
+
destroyAll(): void;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=native-translation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-translation.d.ts","sourceRoot":"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
|
2
|
+
* Returns the browser's built-in Translator API (Chrome 138+, Edge) when it
|
|
3
|
+
* is exposed on globalThis, or undefined everywhere else.
|
|
4
|
+
*/
|
|
5
|
+
export function getNativeTranslatorApi() {
|
|
6
|
+
const candidate = globalThis.Translator;
|
|
7
|
+
if ((typeof candidate === "object" || typeof candidate === "function") &&
|
|
8
|
+
candidate !== null &&
|
|
9
|
+
typeof candidate.availability === "function" &&
|
|
10
|
+
typeof candidate.create === "function") {
|
|
11
|
+
return candidate;
|
|
12
|
+
}
|
|
13
|
+
return undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Caches one native translator instance per language pair. Creation failures
|
|
17
|
+
* and unavailable pairs resolve to undefined so the caller can fall back to
|
|
18
|
+
* the worker engine.
|
|
19
|
+
*/
|
|
20
|
+
export class NativeTranslatorPool {
|
|
21
|
+
instances = new Map();
|
|
22
|
+
async acquire(sourceLanguage, targetLanguage, onDownloadProgress) {
|
|
23
|
+
const api = getNativeTranslatorApi();
|
|
24
|
+
if (!api) {
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
const key = `${sourceLanguage}>${targetLanguage}`;
|
|
28
|
+
const existing = this.instances.get(key);
|
|
29
|
+
if (existing) {
|
|
30
|
+
try {
|
|
31
|
+
return await existing;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
this.instances.delete(key);
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
try {
|
|
39
|
+
const availability = await api.availability({
|
|
40
|
+
sourceLanguage,
|
|
41
|
+
targetLanguage
|
|
42
|
+
});
|
|
43
|
+
if (availability === "unavailable") {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return undefined;
|
|
49
|
+
}
|
|
50
|
+
const created = api.create({
|
|
51
|
+
sourceLanguage,
|
|
52
|
+
targetLanguage,
|
|
53
|
+
monitor(monitor) {
|
|
54
|
+
monitor.addEventListener("downloadprogress", (event) => {
|
|
55
|
+
const loaded = event.loaded;
|
|
56
|
+
if (typeof loaded === "number" && Number.isFinite(loaded)) {
|
|
57
|
+
onDownloadProgress?.(Math.min(Math.max(loaded, 0), 1) * 100);
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
this.instances.set(key, created);
|
|
63
|
+
try {
|
|
64
|
+
return await created;
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
this.instances.delete(key);
|
|
68
|
+
return undefined;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
destroyAll() {
|
|
72
|
+
for (const instance of this.instances.values()) {
|
|
73
|
+
void instance
|
|
74
|
+
.then((translator) => translator.destroy?.())
|
|
75
|
+
.catch(() => undefined);
|
|
76
|
+
}
|
|
77
|
+
this.instances.clear();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=native-translation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-translation.js","sourceRoot":"","sources":["../src/native-translation.ts"],"names":[],"mappings":"AA2BA;;;GAGG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,SAAS,GAAI,UAAuC,CAAC,UAAU,CAAC;IAEtE,IACE,CAAC,OAAO,SAAS,KAAK,QAAQ,IAAI,OAAO,SAAS,KAAK,UAAU,CAAC;QAClE,SAAS,KAAK,IAAI;QAClB,OAAQ,SAAiC,CAAC,YAAY,KAAK,UAAU;QACrE,OAAQ,SAAiC,CAAC,MAAM,KAAK,UAAU,EAC/D,CAAC;QACD,OAAO,SAAgC,CAAC;IAC1C,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IACd,SAAS,GAAG,IAAI,GAAG,EAGjC,CAAC;IAEJ,KAAK,CAAC,OAAO,CACX,cAAsB,EACtB,cAAsB,EACtB,kBAA+C;QAE/C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CAAC,CAAC;QAEH,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAEjC,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC3B,OAAO,SAAS,CAAC;QACnB,CAAC;IACH,CAAC;IAED,UAAU;QACR,KAAK,MAAM,QAAQ,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,EAAE,CAAC;YAC/C,KAAK,QAAQ;iBACV,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC;iBAC5C,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;QAC5B,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACzB,CAAC;CACF"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { ModelCatalog } from "./model-catalog.js";
|
|
2
|
+
export interface WorkerConfiguration {
|
|
3
|
+
transformersUrl: string;
|
|
4
|
+
dtype: string;
|
|
5
|
+
device: string;
|
|
6
|
+
graphOptimizationLevel: "disabled" | "basic" | "extended" | "all";
|
|
7
|
+
modelCatalog: ModelCatalog;
|
|
8
|
+
maxNewTokens?: number;
|
|
9
|
+
maxChunkLength?: number;
|
|
10
|
+
}
|
|
11
|
+
export type MainToWorkerMessage = {
|
|
12
|
+
type: "configure";
|
|
13
|
+
configuration: WorkerConfiguration;
|
|
14
|
+
} | {
|
|
15
|
+
type: "translate";
|
|
16
|
+
requestId: string;
|
|
17
|
+
text: string;
|
|
18
|
+
sourceLanguage: string;
|
|
19
|
+
targetLanguage: string;
|
|
20
|
+
} | {
|
|
21
|
+
type: "cancel";
|
|
22
|
+
requestId: string;
|
|
23
|
+
} | {
|
|
24
|
+
type: "unload-models";
|
|
25
|
+
};
|
|
26
|
+
export type WorkerToMainMessage = {
|
|
27
|
+
status: "route";
|
|
28
|
+
requestId: string;
|
|
29
|
+
models: string[];
|
|
30
|
+
message: string;
|
|
31
|
+
} | {
|
|
32
|
+
status: "loading" | "model-ready" | "processing";
|
|
33
|
+
requestId: string;
|
|
34
|
+
modelId?: string;
|
|
35
|
+
message: string;
|
|
36
|
+
} | {
|
|
37
|
+
status: "progress";
|
|
38
|
+
requestId: string;
|
|
39
|
+
modelId: string;
|
|
40
|
+
file?: string;
|
|
41
|
+
progress?: number;
|
|
42
|
+
loaded?: number;
|
|
43
|
+
total?: number;
|
|
44
|
+
message: string;
|
|
45
|
+
} | {
|
|
46
|
+
status: "partial";
|
|
47
|
+
requestId: string;
|
|
48
|
+
delta: string;
|
|
49
|
+
} | {
|
|
50
|
+
status: "success";
|
|
51
|
+
requestId: string;
|
|
52
|
+
translation: string;
|
|
53
|
+
models: string[];
|
|
54
|
+
} | {
|
|
55
|
+
status: "error";
|
|
56
|
+
requestId: string;
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=protocol.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAC;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,sBAAsB,EAAE,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,KAAK,CAAC;IAClE,YAAY,EAAE,YAAY,CAAC;IAC3B,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,MAAM,mBAAmB,GAC3B;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,aAAa,EAAE,mBAAmB,CAAC;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.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chunk-level cache of finished translations. When a memory is passed to
|
|
3
|
+
* BrowserTranslator, input is split into sentence chunks and only chunks
|
|
4
|
+
* missing from the memory are sent to a model, so editing one sentence in a
|
|
5
|
+
* long document costs one model call instead of a full retranslation.
|
|
6
|
+
*/
|
|
7
|
+
export interface TranslationMemory {
|
|
8
|
+
get(key: string): string | undefined | Promise<string | undefined>;
|
|
9
|
+
set(key: string, value: string): void | Promise<void>;
|
|
10
|
+
clear?(): void | Promise<void>;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Builds the cache key for one source chunk. The key contains the engine
|
|
14
|
+
* identity (native pair or model route), the language pair, and the full
|
|
15
|
+
* chunk text, so a hit can never return a translation produced by different
|
|
16
|
+
* models or for different text.
|
|
17
|
+
*/
|
|
18
|
+
export declare function createTranslationMemoryKey(engineId: string, sourceLanguage: string, targetLanguage: string, chunkText: string): string;
|
|
19
|
+
/**
|
|
20
|
+
* Map-backed memory with least-recently-used eviction. Suitable for a single
|
|
21
|
+
* session; pair it with IndexedDBTranslationMemory to persist across reloads.
|
|
22
|
+
*/
|
|
23
|
+
export declare class InMemoryTranslationMemory implements TranslationMemory {
|
|
24
|
+
private readonly entries;
|
|
25
|
+
private readonly maxEntries;
|
|
26
|
+
constructor(maxEntries?: number);
|
|
27
|
+
get size(): number;
|
|
28
|
+
get(key: string): string | undefined;
|
|
29
|
+
set(key: string, value: string): void;
|
|
30
|
+
clear(): void;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* IndexedDB-backed memory that persists translations across page loads. In
|
|
34
|
+
* environments without IndexedDB (server-side rendering, some tests) it
|
|
35
|
+
* degrades to a no-op: get resolves to undefined and set does nothing.
|
|
36
|
+
*/
|
|
37
|
+
export declare class IndexedDBTranslationMemory implements TranslationMemory {
|
|
38
|
+
private readonly databaseName;
|
|
39
|
+
private readonly storeName;
|
|
40
|
+
private databasePromise;
|
|
41
|
+
constructor(options?: {
|
|
42
|
+
databaseName?: string;
|
|
43
|
+
storeName?: string;
|
|
44
|
+
});
|
|
45
|
+
private open;
|
|
46
|
+
get(key: string): Promise<string | undefined>;
|
|
47
|
+
set(key: string, value: string): Promise<void>;
|
|
48
|
+
clear(): Promise<void>;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=translation-memory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-memory.d.ts","sourceRoot":"","sources":["../src/translation-memory.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,iBAAiB;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IACnE,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACtD,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED;;;;;GAKG;AACH,wBAAgB,0BAA0B,CACxC,QAAQ,EAAE,MAAM,EAChB,cAAc,EAAE,MAAM,EACtB,cAAc,EAAE,MAAM,EACtB,SAAS,EAAE,MAAM,GAChB,MAAM,CAER;AAED;;;GAGG;AACH,qBAAa,yBAA0B,YAAW,iBAAiB;IACjE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;gBAExB,UAAU,SAAO;IAI7B,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAWpC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;IAerC,KAAK,IAAI,IAAI;CAGd;AAED;;;;GAIG;AACH,qBAAa,0BAA2B,YAAW,iBAAiB;IAClE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;IACtC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAS;IACnC,OAAO,CAAC,eAAe,CAA+C;gBAE1D,OAAO,GAAE;QAAE,YAAY,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAO;IAKvE,OAAO,CAAC,IAAI;IAuBN,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAoB7C,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAiB9C,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAgB7B"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the cache key for one source chunk. The key contains the engine
|
|
3
|
+
* identity (native pair or model route), the language pair, and the full
|
|
4
|
+
* chunk text, so a hit can never return a translation produced by different
|
|
5
|
+
* models or for different text.
|
|
6
|
+
*/
|
|
7
|
+
export function createTranslationMemoryKey(engineId, sourceLanguage, targetLanguage, chunkText) {
|
|
8
|
+
return `v1|${engineId}|${sourceLanguage}>${targetLanguage}|${chunkText}`;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Map-backed memory with least-recently-used eviction. Suitable for a single
|
|
12
|
+
* session; pair it with IndexedDBTranslationMemory to persist across reloads.
|
|
13
|
+
*/
|
|
14
|
+
export class InMemoryTranslationMemory {
|
|
15
|
+
entries = new Map();
|
|
16
|
+
maxEntries;
|
|
17
|
+
constructor(maxEntries = 5000) {
|
|
18
|
+
this.maxEntries = Math.max(1, maxEntries);
|
|
19
|
+
}
|
|
20
|
+
get size() {
|
|
21
|
+
return this.entries.size;
|
|
22
|
+
}
|
|
23
|
+
get(key) {
|
|
24
|
+
const value = this.entries.get(key);
|
|
25
|
+
if (value !== undefined) {
|
|
26
|
+
this.entries.delete(key);
|
|
27
|
+
this.entries.set(key, value);
|
|
28
|
+
}
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
set(key, value) {
|
|
32
|
+
this.entries.delete(key);
|
|
33
|
+
this.entries.set(key, value);
|
|
34
|
+
while (this.entries.size > this.maxEntries) {
|
|
35
|
+
const oldest = this.entries.keys().next().value;
|
|
36
|
+
if (oldest === undefined) {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
this.entries.delete(oldest);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
clear() {
|
|
43
|
+
this.entries.clear();
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* IndexedDB-backed memory that persists translations across page loads. In
|
|
48
|
+
* environments without IndexedDB (server-side rendering, some tests) it
|
|
49
|
+
* degrades to a no-op: get resolves to undefined and set does nothing.
|
|
50
|
+
*/
|
|
51
|
+
export class IndexedDBTranslationMemory {
|
|
52
|
+
databaseName;
|
|
53
|
+
storeName;
|
|
54
|
+
databasePromise;
|
|
55
|
+
constructor(options = {}) {
|
|
56
|
+
this.databaseName = options.databaseName ?? "yjs-local-translator";
|
|
57
|
+
this.storeName = options.storeName ?? "translations";
|
|
58
|
+
}
|
|
59
|
+
open() {
|
|
60
|
+
if (!this.databasePromise) {
|
|
61
|
+
this.databasePromise = new Promise((resolve) => {
|
|
62
|
+
if (typeof indexedDB === "undefined") {
|
|
63
|
+
resolve(undefined);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const request = indexedDB.open(this.databaseName, 1);
|
|
67
|
+
request.onupgradeneeded = () => {
|
|
68
|
+
if (!request.result.objectStoreNames.contains(this.storeName)) {
|
|
69
|
+
request.result.createObjectStore(this.storeName);
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
request.onsuccess = () => resolve(request.result);
|
|
73
|
+
request.onerror = () => resolve(undefined);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return this.databasePromise;
|
|
77
|
+
}
|
|
78
|
+
async get(key) {
|
|
79
|
+
const database = await this.open();
|
|
80
|
+
if (!database) {
|
|
81
|
+
return undefined;
|
|
82
|
+
}
|
|
83
|
+
return new Promise((resolve, reject) => {
|
|
84
|
+
const request = database
|
|
85
|
+
.transaction(this.storeName, "readonly")
|
|
86
|
+
.objectStore(this.storeName)
|
|
87
|
+
.get(key);
|
|
88
|
+
request.onsuccess = () => resolve(typeof request.result === "string" ? request.result : undefined);
|
|
89
|
+
request.onerror = () => reject(request.error ?? new Error("Translation memory read failed."));
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
async set(key, value) {
|
|
93
|
+
const database = await this.open();
|
|
94
|
+
if (!database) {
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
return new Promise((resolve, reject) => {
|
|
98
|
+
const transaction = database.transaction(this.storeName, "readwrite");
|
|
99
|
+
transaction.objectStore(this.storeName).put(value, key);
|
|
100
|
+
transaction.oncomplete = () => resolve();
|
|
101
|
+
transaction.onerror = () => reject(transaction.error ?? new Error("Translation memory write failed."));
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
async clear() {
|
|
105
|
+
const database = await this.open();
|
|
106
|
+
if (!database) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
return new Promise((resolve, reject) => {
|
|
110
|
+
const transaction = database.transaction(this.storeName, "readwrite");
|
|
111
|
+
transaction.objectStore(this.storeName).clear();
|
|
112
|
+
transaction.oncomplete = () => resolve();
|
|
113
|
+
transaction.onerror = () => reject(transaction.error ?? new Error("Translation memory clear failed."));
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=translation-memory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"translation-memory.js","sour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