dsh-cait 1.0.4 → 1.0.5
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/CHANGELOG.md +43 -0
- package/README.ja.md +53 -13
- package/README.md +58 -16
- package/README.zh-CN.md +53 -15
- package/client/components.js +32 -1
- package/client/locales.js +27 -6
- package/client/rpc.js +1 -1
- package/client.js +60 -8
- package/lib/docx.js +12 -9
- package/lib/epub.js +355 -0
- package/lib/formats.js +88 -33
- package/lib/html.js +271 -0
- package/lib/import-export.js +136 -91
- package/lib/persistence.js +20 -0
- package/lib/preprocess.js +65 -0
- package/lib/store-utils.js +6 -3
- package/lib/store.js +12 -0
- package/package.json +2 -2
package/lib/store.js
CHANGED
|
@@ -12,6 +12,7 @@ import { classifyMatchType, normalizeSource, normalizeText, similarity } from '.
|
|
|
12
12
|
import { MOCK_MODEL, MOCK_PROVIDER, NO_MODEL_MESSAGE, NO_ROUTE_MESSAGE, collectStreamText } from './mt.js'
|
|
13
13
|
import { buildTmx } from './tmx.js'
|
|
14
14
|
import { missingInlineTokens } from './formats.js'
|
|
15
|
+
import { normalizePreprocessOptions, preprocessSegments } from './preprocess.js'
|
|
15
16
|
|
|
16
17
|
export { CatError } from './errors.js'
|
|
17
18
|
export { canonicalLanguage } from './store-utils.js'
|
|
@@ -216,6 +217,7 @@ export class CatStore {
|
|
|
216
217
|
}
|
|
217
218
|
|
|
218
219
|
if (!rawSegments.length) throw new CatError('EMPTY_SOURCE', '没有可翻译的句段。')
|
|
220
|
+
rawSegments = preprocessSegments(rawSegments, this.settings.preprocess)
|
|
219
221
|
if (rawSegments.length > MAX_SEGMENTS) {
|
|
220
222
|
throw new CatError('TOO_MANY_SEGMENTS', `句段数量超过 ${MAX_SEGMENTS} 上限`)
|
|
221
223
|
}
|
|
@@ -251,6 +253,7 @@ export class CatStore {
|
|
|
251
253
|
if (existing) {
|
|
252
254
|
if (input.docxSource) this.attachDocxSource(existing, input.docxSource, input.docxName)
|
|
253
255
|
if (input.pptxSource) this.attachPptxSource(existing, input.pptxSource, input.pptxName)
|
|
256
|
+
if (input.epubSource) this.attachEpubSource(existing, input.epubSource, input.epubName)
|
|
254
257
|
if (input.format) existing.format = String(input.format).slice(0, 24)
|
|
255
258
|
if (formatMeta) existing.formatMeta = cleanFormatMeta({ ...(existing.formatMeta || {}), ...formatMeta })
|
|
256
259
|
this.activeDocId = existing.id
|
|
@@ -278,6 +281,7 @@ export class CatStore {
|
|
|
278
281
|
if (doc.cursor < 0) doc.cursor = 0
|
|
279
282
|
if (input.docxSource) this.attachDocxSource(doc, input.docxSource, input.docxName)
|
|
280
283
|
if (input.pptxSource) this.attachPptxSource(doc, input.pptxSource, input.pptxName)
|
|
284
|
+
if (input.epubSource) this.attachEpubSource(doc, input.epubSource, input.epubName)
|
|
281
285
|
|
|
282
286
|
this.docs.set(doc.id, doc)
|
|
283
287
|
this.activeDocId = doc.id
|
|
@@ -299,6 +303,7 @@ export class CatStore {
|
|
|
299
303
|
const tabIndex = this.openDocIds.indexOf(doc.id)
|
|
300
304
|
this.removeDocxSource(doc)
|
|
301
305
|
this.removePptxSource(doc)
|
|
306
|
+
this.removeEpubSource(doc)
|
|
302
307
|
this.docs.delete(doc.id)
|
|
303
308
|
this.openDocIds = this.openDocIds.filter((id) => id !== doc.id)
|
|
304
309
|
if (this.activeDocId === doc.id) {
|
|
@@ -473,6 +478,13 @@ export class CatStore {
|
|
|
473
478
|
this.settings.uiLang = uiLang
|
|
474
479
|
}
|
|
475
480
|
|
|
481
|
+
if (patch.preprocess && typeof patch.preprocess === 'object') {
|
|
482
|
+
this.settings.preprocess = normalizePreprocessOptions({
|
|
483
|
+
...this.settings.preprocess,
|
|
484
|
+
...patch.preprocess,
|
|
485
|
+
})
|
|
486
|
+
}
|
|
487
|
+
|
|
476
488
|
if (patch.mt && typeof patch.mt === 'object') {
|
|
477
489
|
const mt = patch.mt
|
|
478
490
|
if (mt.provider !== undefined) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-cait",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Jovi Lecca",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"bugs": {
|
|
18
18
|
"url": "https://github.com/JoviLecca/dsh-CAIT/issues"
|
|
19
19
|
},
|
|
20
|
-
"description": "CAIT — a CAT workbench for DeepSeek Harness with translation memory, glossary, document tabs, MT routes, and Office/subtitle/localization formats.",
|
|
20
|
+
"description": "CAIT — a CAT workbench for DeepSeek Harness with translation memory, glossary, document tabs, MT routes, and Office/EPUB/subtitle/localization formats.",
|
|
21
21
|
"type": "module",
|
|
22
22
|
"keywords": [
|
|
23
23
|
"dsh-plugin",
|