@langlink/memoq-mcp 0.2.2 → 0.2.3
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/README.md +1 -1
- package/bin/MemoQ.Bridge.Helper.exe +0 -0
- package/dist/index.js +1781 -396
- package/dist/index.js.map +3 -3
- package/package.json +1 -1
- package/skills/memoq-setup-troubleshoot/SKILL.md +12 -4
package/dist/index.js
CHANGED
|
@@ -2985,7 +2985,7 @@ var require_compile = __commonJS({
|
|
|
2985
2985
|
const schOrFunc = root.refs[ref];
|
|
2986
2986
|
if (schOrFunc)
|
|
2987
2987
|
return schOrFunc;
|
|
2988
|
-
let _sch =
|
|
2988
|
+
let _sch = resolve7.call(this, root, ref);
|
|
2989
2989
|
if (_sch === void 0) {
|
|
2990
2990
|
const schema = (_a3 = root.localRefs) === null || _a3 === void 0 ? void 0 : _a3[ref];
|
|
2991
2991
|
const { schemaId } = this.opts;
|
|
@@ -3012,7 +3012,7 @@ var require_compile = __commonJS({
|
|
|
3012
3012
|
function sameSchemaEnv(s1, s2) {
|
|
3013
3013
|
return s1.schema === s2.schema && s1.root === s2.root && s1.baseId === s2.baseId;
|
|
3014
3014
|
}
|
|
3015
|
-
function
|
|
3015
|
+
function resolve7(root, ref) {
|
|
3016
3016
|
let sch;
|
|
3017
3017
|
while (typeof (sch = this.refs[ref]) == "string")
|
|
3018
3018
|
ref = sch;
|
|
@@ -3876,7 +3876,7 @@ var require_fast_uri = __commonJS({
|
|
|
3876
3876
|
}
|
|
3877
3877
|
return uri;
|
|
3878
3878
|
}
|
|
3879
|
-
function
|
|
3879
|
+
function resolve7(baseURI, relativeURI, options) {
|
|
3880
3880
|
const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
|
|
3881
3881
|
const {
|
|
3882
3882
|
parsed: baseParsed,
|
|
@@ -4267,7 +4267,7 @@ var require_fast_uri = __commonJS({
|
|
|
4267
4267
|
var fastUri = {
|
|
4268
4268
|
SCHEMES,
|
|
4269
4269
|
normalize,
|
|
4270
|
-
resolve:
|
|
4270
|
+
resolve: resolve7,
|
|
4271
4271
|
resolveComponent,
|
|
4272
4272
|
equal,
|
|
4273
4273
|
serialize,
|
|
@@ -7258,7 +7258,7 @@ var require_dist = __commonJS({
|
|
|
7258
7258
|
|
|
7259
7259
|
// packages/memoq-mcp/src/server.ts
|
|
7260
7260
|
import { realpathSync } from "node:fs";
|
|
7261
|
-
import { dirname as
|
|
7261
|
+
import { dirname as dirname8, resolve as resolve6 } from "node:path";
|
|
7262
7262
|
import { fileURLToPath as fileURLToPath2, pathToFileURL } from "node:url";
|
|
7263
7263
|
|
|
7264
7264
|
// node_modules/.pnpm/zod@4.6.7/node_modules/zod/v3/helpers/util.js
|
|
@@ -14510,7 +14510,7 @@ var recursive = /* @__PURE__ */ new WeakMap();
|
|
|
14510
14510
|
var NONE = 0;
|
|
14511
14511
|
var ASSUMED = 1;
|
|
14512
14512
|
var PROVEN = 2;
|
|
14513
|
-
function isRecursive(inst, stack,
|
|
14513
|
+
function isRecursive(inst, stack, resolve7) {
|
|
14514
14514
|
const cached2 = recursive.get(inst);
|
|
14515
14515
|
if (cached2 !== void 0)
|
|
14516
14516
|
return cached2 ? PROVEN : NONE;
|
|
@@ -14520,7 +14520,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
14520
14520
|
let result = NONE;
|
|
14521
14521
|
const check = (child) => {
|
|
14522
14522
|
if (result !== PROVEN && child?._zod) {
|
|
14523
|
-
const answer = isRecursive(child, stack,
|
|
14523
|
+
const answer = isRecursive(child, stack, resolve7);
|
|
14524
14524
|
if (answer > result)
|
|
14525
14525
|
result = answer;
|
|
14526
14526
|
}
|
|
@@ -14531,7 +14531,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
14531
14531
|
const desc = Object.getOwnPropertyDescriptor(sh, key);
|
|
14532
14532
|
if (spread && !desc.enumerable)
|
|
14533
14533
|
continue;
|
|
14534
|
-
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack,
|
|
14534
|
+
const child = desc.get ? ASSUMED : desc.value?._zod ? isRecursive(desc.value, stack, resolve7) : NONE;
|
|
14535
14535
|
if (child > answer)
|
|
14536
14536
|
answer = child;
|
|
14537
14537
|
}
|
|
@@ -14595,7 +14595,7 @@ function isRecursive(inst, stack, resolve6) {
|
|
|
14595
14595
|
break;
|
|
14596
14596
|
// `$ZodLazy` caches its inner on the def, so a resolved edge is followed exactly
|
|
14597
14597
|
case "lazy": {
|
|
14598
|
-
const inner = def._cachedInner ?? (
|
|
14598
|
+
const inner = def._cachedInner ?? (resolve7 ? inst._zod.innerType : void 0);
|
|
14599
14599
|
merge2(inner ? isRecursive(inner, stack, false) : ASSUMED);
|
|
14600
14600
|
break;
|
|
14601
14601
|
}
|
|
@@ -21381,7 +21381,7 @@ var Protocol = class {
|
|
|
21381
21381
|
return;
|
|
21382
21382
|
}
|
|
21383
21383
|
const pollInterval = task2.pollInterval ?? this._options?.defaultTaskPollInterval ?? 1e3;
|
|
21384
|
-
await new Promise((
|
|
21384
|
+
await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
|
|
21385
21385
|
options?.signal?.throwIfAborted();
|
|
21386
21386
|
}
|
|
21387
21387
|
} catch (error2) {
|
|
@@ -21398,7 +21398,7 @@ var Protocol = class {
|
|
|
21398
21398
|
*/
|
|
21399
21399
|
request(request, resultSchema, options) {
|
|
21400
21400
|
const { relatedRequestId, resumptionToken, onresumptiontoken, task, relatedTask } = options ?? {};
|
|
21401
|
-
return new Promise((
|
|
21401
|
+
return new Promise((resolve7, reject) => {
|
|
21402
21402
|
const earlyReject = (error2) => {
|
|
21403
21403
|
reject(error2);
|
|
21404
21404
|
};
|
|
@@ -21476,7 +21476,7 @@ var Protocol = class {
|
|
|
21476
21476
|
if (!parseResult.success) {
|
|
21477
21477
|
reject(parseResult.error);
|
|
21478
21478
|
} else {
|
|
21479
|
-
|
|
21479
|
+
resolve7(parseResult.data);
|
|
21480
21480
|
}
|
|
21481
21481
|
} catch (error2) {
|
|
21482
21482
|
reject(error2);
|
|
@@ -21738,12 +21738,12 @@ var Protocol = class {
|
|
|
21738
21738
|
}
|
|
21739
21739
|
} catch {
|
|
21740
21740
|
}
|
|
21741
|
-
return new Promise((
|
|
21741
|
+
return new Promise((resolve7, reject) => {
|
|
21742
21742
|
if (signal.aborted) {
|
|
21743
21743
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
21744
21744
|
return;
|
|
21745
21745
|
}
|
|
21746
|
-
const timeoutId = setTimeout(
|
|
21746
|
+
const timeoutId = setTimeout(resolve7, interval);
|
|
21747
21747
|
signal.addEventListener("abort", () => {
|
|
21748
21748
|
clearTimeout(timeoutId);
|
|
21749
21749
|
reject(new McpError(ErrorCode.InvalidRequest, "Request cancelled"));
|
|
@@ -22883,7 +22883,7 @@ var McpServer = class {
|
|
|
22883
22883
|
let task = createTaskResult.task;
|
|
22884
22884
|
const pollInterval = task.pollInterval ?? 5e3;
|
|
22885
22885
|
while (task.status !== "completed" && task.status !== "failed" && task.status !== "cancelled") {
|
|
22886
|
-
await new Promise((
|
|
22886
|
+
await new Promise((resolve7) => setTimeout(resolve7, pollInterval));
|
|
22887
22887
|
const updatedTask = await extra.taskStore.getTask(taskId);
|
|
22888
22888
|
if (!updatedTask) {
|
|
22889
22889
|
throw new McpError(ErrorCode.InternalError, `Task ${taskId} not found during polling`);
|
|
@@ -23547,12 +23547,12 @@ var StdioServerTransport = class {
|
|
|
23547
23547
|
this.onclose?.();
|
|
23548
23548
|
}
|
|
23549
23549
|
send(message) {
|
|
23550
|
-
return new Promise((
|
|
23550
|
+
return new Promise((resolve7) => {
|
|
23551
23551
|
const json2 = serializeMessage(message);
|
|
23552
23552
|
if (this._stdout.write(json2)) {
|
|
23553
|
-
|
|
23553
|
+
resolve7();
|
|
23554
23554
|
} else {
|
|
23555
|
-
this._stdout.once("drain",
|
|
23555
|
+
this._stdout.once("drain", resolve7);
|
|
23556
23556
|
}
|
|
23557
23557
|
});
|
|
23558
23558
|
}
|
|
@@ -24378,18 +24378,18 @@ function createPreviewClient(options = {}) {
|
|
|
24378
24378
|
}
|
|
24379
24379
|
const id = randomUUID();
|
|
24380
24380
|
const message = JSON.stringify({ ...payload, id }) + "\n";
|
|
24381
|
-
return new Promise((
|
|
24381
|
+
return new Promise((resolve7) => {
|
|
24382
24382
|
const timer = setTimeout(() => {
|
|
24383
24383
|
pendingAcks.delete(id);
|
|
24384
|
-
|
|
24384
|
+
resolve7({ ok: false, error: `Preview helper command timed out (${String(payload.type ?? "unknown")}).` });
|
|
24385
24385
|
}, timeoutMs);
|
|
24386
|
-
pendingAcks.set(id, { resolve:
|
|
24386
|
+
pendingAcks.set(id, { resolve: resolve7, timer });
|
|
24387
24387
|
try {
|
|
24388
24388
|
child.stdin.write(message, "utf8");
|
|
24389
24389
|
} catch (error2) {
|
|
24390
24390
|
clearTimeout(timer);
|
|
24391
24391
|
pendingAcks.delete(id);
|
|
24392
|
-
|
|
24392
|
+
resolve7({ ok: false, error: error2 instanceof Error ? error2.message : String(error2) });
|
|
24393
24393
|
}
|
|
24394
24394
|
});
|
|
24395
24395
|
}
|
|
@@ -24527,9 +24527,9 @@ function createPreviewClient(options = {}) {
|
|
|
24527
24527
|
const settleMs = Math.max(0, Math.min(500, query.settleMs ?? 80));
|
|
24528
24528
|
if (settleMs > 0 && lastEventAtMs > 0 && Date.now() - lastEventAtMs < settleMs) {
|
|
24529
24529
|
const firstRev = revision;
|
|
24530
|
-
await new Promise((
|
|
24530
|
+
await new Promise((resolve7) => setTimeout(resolve7, settleMs));
|
|
24531
24531
|
if (revision !== firstRev) {
|
|
24532
|
-
await new Promise((
|
|
24532
|
+
await new Promise((resolve7) => setTimeout(resolve7, settleMs));
|
|
24533
24533
|
}
|
|
24534
24534
|
}
|
|
24535
24535
|
const doc = resolveDocument();
|
|
@@ -28039,17 +28039,23 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28039
28039
|
<head>
|
|
28040
28040
|
<meta charset="utf-8" />
|
|
28041
28041
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
28042
|
-
<title>LangLink memoQ \u53CC\u8BED\u5BA1\u6821\u4E0E QA \u5DE5\u4F5C\u53F0</title>
|
|
28042
|
+
<title>LangLink memoQ CAT \u53CC\u8BED\u5BA1\u6821\u4E0E QA \u5DE5\u4F5C\u53F0</title>
|
|
28043
28043
|
<style>
|
|
28044
28044
|
:root {
|
|
28045
28045
|
color-scheme: light dark;
|
|
28046
|
-
--bg: #
|
|
28047
|
-
--
|
|
28046
|
+
--bg: #eef2f6;
|
|
28047
|
+
--panel: #ffffff;
|
|
28048
28048
|
--subtle: #f8fafc;
|
|
28049
|
-
--
|
|
28050
|
-
--
|
|
28051
|
-
--
|
|
28049
|
+
--grid-head: #f1f5f9;
|
|
28050
|
+
--row-hover: #f8fafc;
|
|
28051
|
+
--row-active: #eff6ff;
|
|
28052
|
+
--text: #0f172a;
|
|
28053
|
+
--muted: #475569;
|
|
28054
|
+
--faint: #64748b;
|
|
28055
|
+
--border: #cbd5e1;
|
|
28056
|
+
--border-soft: #e2e8f0;
|
|
28052
28057
|
--accent: #1d4ed8;
|
|
28058
|
+
--accent-solid: #2563eb;
|
|
28053
28059
|
--accent-soft: #dbeafe;
|
|
28054
28060
|
--ok: #15803d;
|
|
28055
28061
|
--ok-soft: #dcfce7;
|
|
@@ -28059,16 +28065,25 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28059
28065
|
--err-soft: #fee2e2;
|
|
28060
28066
|
--rev: #6d28d9;
|
|
28061
28067
|
--rev-soft: #ede9fe;
|
|
28068
|
+
--tag-bg: #e0f2fe;
|
|
28069
|
+
--tag-fg: #0369a1;
|
|
28070
|
+
--tag-border: #bae6fd;
|
|
28062
28071
|
}
|
|
28063
28072
|
@media (prefers-color-scheme: dark) {
|
|
28064
28073
|
:root {
|
|
28065
|
-
--bg: #
|
|
28066
|
-
--
|
|
28074
|
+
--bg: #0b1120;
|
|
28075
|
+
--panel: #111827;
|
|
28067
28076
|
--subtle: #0f172a;
|
|
28077
|
+
--grid-head: #1e293b;
|
|
28078
|
+
--row-hover: #172033;
|
|
28079
|
+
--row-active: #172554;
|
|
28068
28080
|
--text: #f1f5f9;
|
|
28069
28081
|
--muted: #94a3b8;
|
|
28082
|
+
--faint: #64748b;
|
|
28070
28083
|
--border: #334155;
|
|
28084
|
+
--border-soft: #1e293b;
|
|
28071
28085
|
--accent: #60a5fa;
|
|
28086
|
+
--accent-solid: #3b82f6;
|
|
28072
28087
|
--accent-soft: #1e3a8a;
|
|
28073
28088
|
--ok: #4ade80;
|
|
28074
28089
|
--ok-soft: #14532d;
|
|
@@ -28078,253 +28093,634 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28078
28093
|
--err-soft: #450a0a;
|
|
28079
28094
|
--rev: #c4b5fd;
|
|
28080
28095
|
--rev-soft: #2e1065;
|
|
28096
|
+
--tag-bg: #0c4a6e;
|
|
28097
|
+
--tag-fg: #7dd3fc;
|
|
28098
|
+
--tag-border: #0369a1;
|
|
28081
28099
|
}
|
|
28082
28100
|
}
|
|
28083
28101
|
* { box-sizing: border-box; }
|
|
28102
|
+
html, body { height: 100%; margin: 0; }
|
|
28084
28103
|
body {
|
|
28085
|
-
margin: 0;
|
|
28086
|
-
padding: 16px;
|
|
28087
28104
|
background: var(--bg);
|
|
28088
28105
|
color: var(--text);
|
|
28089
|
-
font:
|
|
28106
|
+
font: 13px/1.45 "Segoe UI", -apple-system, BlinkMacSystemFont, "Microsoft YaHei UI", sans-serif;
|
|
28107
|
+
display: flex;
|
|
28108
|
+
flex-direction: column;
|
|
28109
|
+
overflow: hidden;
|
|
28110
|
+
}
|
|
28111
|
+
.hidden { display: none !important; }
|
|
28112
|
+
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
|
|
28113
|
+
|
|
28114
|
+
/* Top CAT Ribbon */
|
|
28115
|
+
.cat-ribbon {
|
|
28116
|
+
flex-shrink: 0;
|
|
28117
|
+
min-height: 46px;
|
|
28118
|
+
background: var(--panel);
|
|
28119
|
+
border-bottom: 1px solid var(--border);
|
|
28120
|
+
padding: 6px 12px;
|
|
28121
|
+
display: flex;
|
|
28122
|
+
flex-wrap: wrap;
|
|
28123
|
+
align-items: center;
|
|
28124
|
+
justify-content: space-between;
|
|
28125
|
+
gap: 8px;
|
|
28126
|
+
}
|
|
28127
|
+
.ribbon-left, .ribbon-right {
|
|
28128
|
+
display: flex;
|
|
28129
|
+
flex-wrap: wrap;
|
|
28130
|
+
align-items: center;
|
|
28131
|
+
gap: 8px;
|
|
28132
|
+
min-width: 0;
|
|
28133
|
+
}
|
|
28134
|
+
.brand-chip {
|
|
28135
|
+
display: inline-flex;
|
|
28136
|
+
align-items: center;
|
|
28137
|
+
gap: 6px;
|
|
28138
|
+
font-weight: 700;
|
|
28139
|
+
font-size: 13px;
|
|
28140
|
+
letter-spacing: -0.01em;
|
|
28141
|
+
}
|
|
28142
|
+
.brand-badge {
|
|
28143
|
+
background: var(--accent-solid);
|
|
28144
|
+
color: #ffffff;
|
|
28145
|
+
border-radius: 5px;
|
|
28146
|
+
padding: 2px 6px;
|
|
28147
|
+
font-size: 11px;
|
|
28148
|
+
font-weight: 700;
|
|
28090
28149
|
}
|
|
28091
|
-
.
|
|
28092
|
-
|
|
28093
|
-
|
|
28150
|
+
.doc-title {
|
|
28151
|
+
margin: 0;
|
|
28152
|
+
font-size: 13px;
|
|
28153
|
+
font-weight: 600;
|
|
28154
|
+
max-width: 240px;
|
|
28155
|
+
white-space: nowrap;
|
|
28156
|
+
overflow: hidden;
|
|
28157
|
+
text-overflow: ellipsis;
|
|
28158
|
+
}
|
|
28159
|
+
.doc-select {
|
|
28160
|
+
max-width: 280px;
|
|
28161
|
+
height: 28px;
|
|
28162
|
+
padding: 2px 8px;
|
|
28094
28163
|
border: 1px solid var(--border);
|
|
28095
|
-
border-radius:
|
|
28096
|
-
|
|
28164
|
+
border-radius: 6px;
|
|
28165
|
+
background: var(--subtle);
|
|
28166
|
+
color: var(--text);
|
|
28167
|
+
font-size: 12px;
|
|
28097
28168
|
}
|
|
28098
|
-
|
|
28169
|
+
|
|
28170
|
+
/* Sub-toolbar */
|
|
28171
|
+
.cat-subbar {
|
|
28172
|
+
flex-shrink: 0;
|
|
28173
|
+
min-height: 38px;
|
|
28174
|
+
background: var(--panel);
|
|
28175
|
+
border-bottom: 1px solid var(--border);
|
|
28176
|
+
padding: 4px 12px;
|
|
28099
28177
|
display: flex;
|
|
28100
28178
|
flex-wrap: wrap;
|
|
28101
28179
|
align-items: center;
|
|
28102
28180
|
justify-content: space-between;
|
|
28103
|
-
gap:
|
|
28181
|
+
gap: 8px;
|
|
28104
28182
|
}
|
|
28105
|
-
.
|
|
28106
|
-
.
|
|
28107
|
-
|
|
28108
|
-
|
|
28109
|
-
|
|
28110
|
-
padding:
|
|
28111
|
-
border:
|
|
28183
|
+
.tabs { display: flex; gap: 4px; align-items: center; }
|
|
28184
|
+
.tab-btn {
|
|
28185
|
+
border: 1px solid transparent;
|
|
28186
|
+
background: transparent;
|
|
28187
|
+
color: var(--muted);
|
|
28188
|
+
padding: 4px 10px;
|
|
28189
|
+
border-radius: 5px;
|
|
28190
|
+
font-size: 12px;
|
|
28191
|
+
font-weight: 600;
|
|
28192
|
+
cursor: pointer;
|
|
28112
28193
|
}
|
|
28113
|
-
.
|
|
28114
|
-
|
|
28115
|
-
|
|
28116
|
-
|
|
28117
|
-
|
|
28118
|
-
.
|
|
28119
|
-
.
|
|
28194
|
+
.tab-btn.active {
|
|
28195
|
+
background: var(--accent-soft);
|
|
28196
|
+
color: var(--accent);
|
|
28197
|
+
border-color: var(--accent);
|
|
28198
|
+
}
|
|
28199
|
+
.v-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
|
|
28200
|
+
.filter-pills { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
|
|
28201
|
+
.filter-pill {
|
|
28202
|
+
padding: 3px 9px;
|
|
28203
|
+
border-radius: 999px;
|
|
28204
|
+
font-size: 11px;
|
|
28205
|
+
font-weight: 500;
|
|
28206
|
+
border: 1px solid var(--border);
|
|
28207
|
+
background: var(--subtle);
|
|
28208
|
+
color: var(--text);
|
|
28209
|
+
cursor: pointer;
|
|
28210
|
+
}
|
|
28211
|
+
.filter-pill.active {
|
|
28212
|
+
background: var(--accent-solid);
|
|
28213
|
+
color: #ffffff;
|
|
28214
|
+
border-color: var(--accent-solid);
|
|
28215
|
+
}
|
|
28216
|
+
.search-wrap { display: flex; align-items: center; gap: 8px; }
|
|
28217
|
+
.kbd-hint { font-size: 11px; color: var(--faint); white-space: nowrap; }
|
|
28218
|
+
|
|
28219
|
+
/* Buttons & Inputs */
|
|
28120
28220
|
button {
|
|
28121
28221
|
cursor: pointer;
|
|
28122
|
-
border-radius:
|
|
28222
|
+
border-radius: 6px;
|
|
28123
28223
|
border: 1px solid var(--border);
|
|
28124
|
-
background: var(--
|
|
28224
|
+
background: var(--panel);
|
|
28125
28225
|
color: var(--text);
|
|
28126
|
-
padding:
|
|
28226
|
+
padding: 4px 10px;
|
|
28127
28227
|
font: inherit;
|
|
28128
|
-
font-size:
|
|
28228
|
+
font-size: 12px;
|
|
28129
28229
|
font-weight: 600;
|
|
28230
|
+
line-height: 1.35;
|
|
28130
28231
|
}
|
|
28131
|
-
button:hover {
|
|
28132
|
-
button.primary { background: var(--accent); color: #ffffff; border-color: var(--accent); }
|
|
28232
|
+
button:hover { border-color: var(--accent); }
|
|
28233
|
+
button.primary { background: var(--accent-solid); color: #ffffff; border-color: var(--accent-solid); }
|
|
28133
28234
|
button.success { background: #15803d; color: #ffffff; border-color: #15803d; }
|
|
28134
28235
|
button.warn { background: #b45309; color: #ffffff; border-color: #b45309; }
|
|
28135
|
-
button.sm { padding:
|
|
28236
|
+
button.sm { padding: 3px 7px; font-size: 11px; }
|
|
28237
|
+
button.active-toggle { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
|
|
28136
28238
|
button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
28137
|
-
|
|
28239
|
+
input[type="text"], textarea, select {
|
|
28240
|
+
border: 1px solid var(--border);
|
|
28241
|
+
background: var(--subtle);
|
|
28242
|
+
color: var(--text);
|
|
28243
|
+
border-radius: 5px;
|
|
28244
|
+
padding: 4px 8px;
|
|
28245
|
+
font: inherit;
|
|
28246
|
+
font-size: 12px;
|
|
28247
|
+
}
|
|
28248
|
+
|
|
28249
|
+
/* Pills */
|
|
28250
|
+
.pill {
|
|
28251
|
+
display: inline-flex;
|
|
28252
|
+
align-items: center;
|
|
28253
|
+
gap: 4px;
|
|
28254
|
+
padding: 2px 8px;
|
|
28255
|
+
border-radius: 999px;
|
|
28256
|
+
font-size: 11px;
|
|
28257
|
+
font-weight: 600;
|
|
28258
|
+
border: 1px solid var(--border);
|
|
28259
|
+
background: var(--subtle);
|
|
28260
|
+
white-space: nowrap;
|
|
28261
|
+
}
|
|
28262
|
+
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
|
|
28263
|
+
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
|
|
28264
|
+
.pill.err { color: var(--err); background: var(--err-soft); border-color: transparent; }
|
|
28265
|
+
.pill.rev { color: var(--rev); background: var(--rev-soft); border-color: transparent; }
|
|
28266
|
+
.pill.info { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
|
|
28267
|
+
|
|
28268
|
+
/* Collapsible QA Config & Banners */
|
|
28269
|
+
.qa-panel {
|
|
28270
|
+
flex-shrink: 0;
|
|
28271
|
+
background: var(--subtle);
|
|
28272
|
+
border-bottom: 1px solid var(--border);
|
|
28138
28273
|
padding: 10px 14px;
|
|
28139
|
-
|
|
28140
|
-
|
|
28274
|
+
max-height: 280px;
|
|
28275
|
+
overflow-y: auto;
|
|
28276
|
+
}
|
|
28277
|
+
.rule-grid {
|
|
28278
|
+
display: grid;
|
|
28279
|
+
grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
|
|
28280
|
+
gap: 4px 10px;
|
|
28281
|
+
margin-top: 6px;
|
|
28282
|
+
}
|
|
28283
|
+
.rule-item { display: flex; gap: 6px; align-items: flex-start; font-size: 11px; }
|
|
28284
|
+
.box-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
|
|
28285
|
+
.banner {
|
|
28286
|
+
flex-shrink: 0;
|
|
28287
|
+
padding: 6px 14px;
|
|
28288
|
+
font-size: 12px;
|
|
28289
|
+
border-bottom: 1px solid var(--border);
|
|
28141
28290
|
display: flex;
|
|
28142
28291
|
flex-wrap: wrap;
|
|
28143
28292
|
align-items: center;
|
|
28144
28293
|
justify-content: space-between;
|
|
28145
|
-
gap:
|
|
28294
|
+
gap: 8px;
|
|
28146
28295
|
}
|
|
28147
28296
|
.banner.ok { background: var(--ok-soft); color: var(--ok); }
|
|
28148
28297
|
.banner.warn { background: var(--warn-soft); color: var(--warn); }
|
|
28149
28298
|
.banner.err { background: var(--err-soft); color: var(--err); }
|
|
28150
28299
|
.banner.rev { background: var(--rev-soft); color: var(--rev); }
|
|
28151
|
-
|
|
28152
|
-
|
|
28153
|
-
.
|
|
28154
|
-
|
|
28155
|
-
|
|
28156
|
-
|
|
28157
|
-
|
|
28158
|
-
|
|
28159
|
-
input[type="text"], textarea, select {
|
|
28160
|
-
border: 1px solid var(--border);
|
|
28161
|
-
background: var(--subtle);
|
|
28162
|
-
color: var(--text);
|
|
28163
|
-
border-radius: 6px;
|
|
28164
|
-
padding: 6px 8px;
|
|
28165
|
-
font: inherit;
|
|
28166
|
-
font-size: 13px;
|
|
28300
|
+
|
|
28301
|
+
/* Main Split CAT Workspace */
|
|
28302
|
+
.cat-workspace {
|
|
28303
|
+
flex: 1;
|
|
28304
|
+
min-height: 0;
|
|
28305
|
+
display: grid;
|
|
28306
|
+
grid-template-columns: minmax(0, 1fr) 336px;
|
|
28307
|
+
background: var(--bg);
|
|
28167
28308
|
}
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28171
|
-
|
|
28172
|
-
|
|
28173
|
-
|
|
28174
|
-
background: var(--card);
|
|
28309
|
+
.cat-workspace.inspector-collapsed {
|
|
28310
|
+
grid-template-columns: minmax(0, 1fr);
|
|
28311
|
+
}
|
|
28312
|
+
.cat-main {
|
|
28313
|
+
min-width: 0;
|
|
28314
|
+
min-height: 0;
|
|
28175
28315
|
display: flex;
|
|
28176
28316
|
flex-direction: column;
|
|
28177
|
-
|
|
28317
|
+
background: var(--panel);
|
|
28318
|
+
overflow: hidden;
|
|
28319
|
+
}
|
|
28320
|
+
.cat-grid-scroll {
|
|
28321
|
+
flex: 1;
|
|
28322
|
+
min-height: 0;
|
|
28323
|
+
overflow: auto;
|
|
28324
|
+
scrollbar-gutter: stable;
|
|
28325
|
+
}
|
|
28326
|
+
|
|
28327
|
+
/* Classic 4-column CAT Bilingual Grid */
|
|
28328
|
+
.cat-grid-head, .cat-row {
|
|
28329
|
+
display: grid;
|
|
28330
|
+
grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr) 128px;
|
|
28331
|
+
align-items: stretch;
|
|
28332
|
+
}
|
|
28333
|
+
.cat-grid-head {
|
|
28334
|
+
position: sticky;
|
|
28335
|
+
top: 0;
|
|
28336
|
+
z-index: 3;
|
|
28337
|
+
background: var(--grid-head);
|
|
28338
|
+
border-bottom: 1px solid var(--border);
|
|
28339
|
+
font-size: 11px;
|
|
28340
|
+
font-weight: 700;
|
|
28341
|
+
color: var(--muted);
|
|
28342
|
+
text-transform: uppercase;
|
|
28343
|
+
letter-spacing: 0.02em;
|
|
28344
|
+
}
|
|
28345
|
+
.cat-grid-head > div {
|
|
28346
|
+
padding: 7px 10px;
|
|
28347
|
+
}
|
|
28348
|
+
.cat-grid-head > div:nth-child(3),
|
|
28349
|
+
.cat-grid-head > div:nth-child(4) {
|
|
28350
|
+
border-left: 1px solid var(--border-soft);
|
|
28351
|
+
}
|
|
28352
|
+
|
|
28353
|
+
.cat-row {
|
|
28354
|
+
border-bottom: 1px solid var(--border-soft);
|
|
28355
|
+
background: var(--panel);
|
|
28356
|
+
transition: background 120ms ease;
|
|
28357
|
+
}
|
|
28358
|
+
.cat-row:hover { background: var(--row-hover); }
|
|
28359
|
+
.cat-row.active-row {
|
|
28360
|
+
background: var(--row-active);
|
|
28361
|
+
}
|
|
28362
|
+
.cat-rail {
|
|
28363
|
+
padding: 9px 6px;
|
|
28364
|
+
display: flex;
|
|
28365
|
+
flex-direction: column;
|
|
28366
|
+
align-items: center;
|
|
28367
|
+
gap: 4px;
|
|
28368
|
+
border-left: 3px solid transparent;
|
|
28369
|
+
color: var(--muted);
|
|
28370
|
+
font-variant-numeric: tabular-nums;
|
|
28371
|
+
font-size: 11px;
|
|
28372
|
+
user-select: none;
|
|
28373
|
+
}
|
|
28374
|
+
.cat-row.st-approved .cat-rail { border-left-color: var(--ok); }
|
|
28375
|
+
.cat-row.st-draft .cat-rail { border-left-color: var(--warn); }
|
|
28376
|
+
.cat-row.st-needs_revision .cat-rail { border-left-color: var(--rev); }
|
|
28377
|
+
.cat-row.st-memoq .cat-rail { border-left-color: var(--border); }
|
|
28378
|
+
.cat-row.active-row .cat-rail { border-left-color: var(--accent-solid); }
|
|
28379
|
+
|
|
28380
|
+
.doc-chip {
|
|
28381
|
+
font-size: 10px;
|
|
28382
|
+
padding: 1px 4px;
|
|
28383
|
+
border-radius: 3px;
|
|
28384
|
+
background: var(--accent-soft);
|
|
28385
|
+
color: var(--accent);
|
|
28386
|
+
max-width: 50px;
|
|
28387
|
+
overflow: hidden;
|
|
28388
|
+
text-overflow: ellipsis;
|
|
28389
|
+
white-space: nowrap;
|
|
28390
|
+
}
|
|
28391
|
+
.cat-source {
|
|
28392
|
+
min-width: 0;
|
|
28393
|
+
padding: 9px 12px;
|
|
28394
|
+
border-left: 1px solid var(--border-soft);
|
|
28395
|
+
display: flex;
|
|
28396
|
+
flex-direction: column;
|
|
28397
|
+
gap: 6px;
|
|
28178
28398
|
}
|
|
28179
|
-
.
|
|
28180
|
-
.seg-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
|
|
28181
|
-
.seg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
|
|
28182
|
-
@media (max-width: 900px) { .seg-grid { grid-template-columns: 1fr; } }
|
|
28183
|
-
.box-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 4px; display: flex; justify-content: space-between; gap: 8px; }
|
|
28184
|
-
.pre-text {
|
|
28399
|
+
.src-text {
|
|
28185
28400
|
white-space: pre-wrap;
|
|
28186
28401
|
word-break: break-word;
|
|
28187
|
-
background: var(--subtle);
|
|
28188
|
-
border: 1px solid var(--border);
|
|
28189
|
-
border-radius: 6px;
|
|
28190
|
-
padding: 8px 10px;
|
|
28191
28402
|
font-size: 13px;
|
|
28403
|
+
line-height: 1.65;
|
|
28404
|
+
color: var(--text);
|
|
28405
|
+
}
|
|
28406
|
+
.cat-tag {
|
|
28407
|
+
display: inline-block;
|
|
28408
|
+
margin: 0 1px;
|
|
28409
|
+
padding: 0 4px;
|
|
28410
|
+
border-radius: 3px;
|
|
28411
|
+
font-family: ui-monospace, Consolas, monospace;
|
|
28412
|
+
font-size: 11px;
|
|
28413
|
+
line-height: 1.4;
|
|
28414
|
+
background: var(--tag-bg);
|
|
28415
|
+
color: var(--tag-fg);
|
|
28416
|
+
border: 1px solid var(--tag-border);
|
|
28417
|
+
vertical-align: baseline;
|
|
28418
|
+
}
|
|
28419
|
+
.cat-target {
|
|
28420
|
+
min-width: 0;
|
|
28421
|
+
padding: 7px 10px;
|
|
28422
|
+
border-left: 1px solid var(--border-soft);
|
|
28423
|
+
display: flex;
|
|
28424
|
+
flex-direction: column;
|
|
28425
|
+
gap: 4px;
|
|
28426
|
+
}
|
|
28427
|
+
.tgt-edit {
|
|
28428
|
+
width: 100%;
|
|
28192
28429
|
min-height: 44px;
|
|
28430
|
+
padding: 5px 7px;
|
|
28431
|
+
border: 1px solid transparent;
|
|
28432
|
+
border-radius: 5px;
|
|
28433
|
+
background: transparent;
|
|
28434
|
+
color: var(--text);
|
|
28435
|
+
font: 13px/1.65 "Segoe UI", -apple-system, BlinkMacSystemFont, "Microsoft YaHei UI", sans-serif;
|
|
28436
|
+
resize: vertical;
|
|
28437
|
+
outline: none;
|
|
28438
|
+
}
|
|
28439
|
+
.cat-row:hover .tgt-edit { border-color: var(--border-soft); background: var(--panel); }
|
|
28440
|
+
.tgt-edit:focus {
|
|
28441
|
+
border-color: var(--accent-solid);
|
|
28442
|
+
background: var(--panel);
|
|
28443
|
+
box-shadow: 0 0 0 2px var(--accent-soft);
|
|
28444
|
+
}
|
|
28445
|
+
.memoq-ref-line {
|
|
28446
|
+
font-size: 11px;
|
|
28447
|
+
color: var(--muted);
|
|
28448
|
+
padding: 3px 6px;
|
|
28449
|
+
border-left: 2px solid var(--border);
|
|
28450
|
+
background: var(--subtle);
|
|
28451
|
+
white-space: pre-wrap;
|
|
28452
|
+
word-break: break-word;
|
|
28453
|
+
}
|
|
28454
|
+
.cmt-chip {
|
|
28455
|
+
font-size: 11px;
|
|
28456
|
+
color: var(--rev);
|
|
28457
|
+
background: var(--rev-soft);
|
|
28458
|
+
padding: 2px 7px;
|
|
28459
|
+
border-radius: 4px;
|
|
28460
|
+
width: fit-content;
|
|
28461
|
+
max-width: 100%;
|
|
28462
|
+
word-break: break-word;
|
|
28463
|
+
}
|
|
28464
|
+
.dirty-tag {
|
|
28465
|
+
display: inline-block;
|
|
28466
|
+
font-size: 10px;
|
|
28467
|
+
color: var(--warn);
|
|
28468
|
+
font-weight: 600;
|
|
28193
28469
|
}
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
padding:
|
|
28197
|
-
border-left:
|
|
28470
|
+
|
|
28471
|
+
.cat-status {
|
|
28472
|
+
padding: 8px 8px;
|
|
28473
|
+
border-left: 1px solid var(--border-soft);
|
|
28474
|
+
display: flex;
|
|
28475
|
+
flex-direction: column;
|
|
28476
|
+
align-items: flex-start;
|
|
28477
|
+
gap: 5px;
|
|
28478
|
+
}
|
|
28479
|
+
.row-mini-btns {
|
|
28480
|
+
display: flex;
|
|
28481
|
+
flex-wrap: wrap;
|
|
28482
|
+
gap: 4px;
|
|
28483
|
+
}
|
|
28484
|
+
.badge-list { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
28485
|
+
|
|
28486
|
+
/* Docked CAT Inspector */
|
|
28487
|
+
.cat-inspector {
|
|
28488
|
+
min-width: 0;
|
|
28489
|
+
min-height: 0;
|
|
28490
|
+
border-left: 1px solid var(--border);
|
|
28491
|
+
background: var(--panel);
|
|
28492
|
+
display: flex;
|
|
28493
|
+
flex-direction: column;
|
|
28494
|
+
overflow-y: auto;
|
|
28495
|
+
padding: 12px;
|
|
28496
|
+
gap: 12px;
|
|
28497
|
+
}
|
|
28498
|
+
.cat-workspace.inspector-collapsed .cat-inspector { display: none; }
|
|
28499
|
+
.insp-section {
|
|
28500
|
+
border: 1px solid var(--border-soft);
|
|
28501
|
+
border-radius: 7px;
|
|
28502
|
+
padding: 9px 10px;
|
|
28198
28503
|
background: var(--subtle);
|
|
28504
|
+
display: flex;
|
|
28505
|
+
flex-direction: column;
|
|
28506
|
+
gap: 6px;
|
|
28507
|
+
}
|
|
28508
|
+
.insp-title {
|
|
28509
|
+
font-size: 11px;
|
|
28510
|
+
font-weight: 700;
|
|
28511
|
+
color: var(--muted);
|
|
28512
|
+
text-transform: uppercase;
|
|
28513
|
+
letter-spacing: 0.02em;
|
|
28514
|
+
display: flex;
|
|
28515
|
+
align-items: center;
|
|
28516
|
+
justify-content: space-between;
|
|
28517
|
+
gap: 6px;
|
|
28518
|
+
}
|
|
28519
|
+
.insp-ref-text {
|
|
28199
28520
|
font-size: 12px;
|
|
28200
28521
|
white-space: pre-wrap;
|
|
28201
28522
|
word-break: break-word;
|
|
28523
|
+
line-height: 1.5;
|
|
28524
|
+
}
|
|
28525
|
+
.qa-issue-card {
|
|
28526
|
+
border: 1px solid var(--border-soft);
|
|
28527
|
+
border-radius: 6px;
|
|
28528
|
+
padding: 7px 8px;
|
|
28529
|
+
background: var(--panel);
|
|
28530
|
+
font-size: 12px;
|
|
28531
|
+
display: flex;
|
|
28532
|
+
flex-direction: column;
|
|
28533
|
+
gap: 3px;
|
|
28534
|
+
}
|
|
28535
|
+
|
|
28536
|
+
/* QA Report Tab */
|
|
28537
|
+
.qa-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
28538
|
+
.qa-table th, .qa-table td {
|
|
28539
|
+
border-bottom: 1px solid var(--border-soft);
|
|
28540
|
+
padding: 7px 10px;
|
|
28541
|
+
text-align: left;
|
|
28542
|
+
vertical-align: top;
|
|
28543
|
+
}
|
|
28544
|
+
.qa-table th {
|
|
28545
|
+
position: sticky;
|
|
28546
|
+
top: 0;
|
|
28547
|
+
background: var(--grid-head);
|
|
28548
|
+
font-size: 11px;
|
|
28549
|
+
color: var(--muted);
|
|
28550
|
+
border-bottom: 1px solid var(--border);
|
|
28551
|
+
}
|
|
28552
|
+
|
|
28553
|
+
/* Bottom CAT Status Bar */
|
|
28554
|
+
.cat-statusbar {
|
|
28555
|
+
flex-shrink: 0;
|
|
28556
|
+
min-height: 30px;
|
|
28557
|
+
background: var(--panel);
|
|
28558
|
+
border-top: 1px solid var(--border);
|
|
28559
|
+
padding: 4px 12px;
|
|
28560
|
+
display: flex;
|
|
28561
|
+
flex-wrap: wrap;
|
|
28562
|
+
align-items: center;
|
|
28563
|
+
justify-content: space-between;
|
|
28564
|
+
gap: 10px;
|
|
28565
|
+
font-size: 11px;
|
|
28566
|
+
color: var(--muted);
|
|
28567
|
+
}
|
|
28568
|
+
.status-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
|
|
28569
|
+
.progress-track {
|
|
28570
|
+
width: 110px;
|
|
28571
|
+
height: 6px;
|
|
28572
|
+
border-radius: 999px;
|
|
28573
|
+
background: var(--border-soft);
|
|
28574
|
+
overflow: hidden;
|
|
28575
|
+
display: inline-block;
|
|
28576
|
+
vertical-align: middle;
|
|
28577
|
+
}
|
|
28578
|
+
.progress-fill {
|
|
28579
|
+
height: 100%;
|
|
28580
|
+
width: 0%;
|
|
28581
|
+
background: var(--ok);
|
|
28582
|
+
transition: width 200ms ease;
|
|
28583
|
+
}
|
|
28584
|
+
.empty-state {
|
|
28585
|
+
padding: 36px 20px;
|
|
28586
|
+
text-align: center;
|
|
28587
|
+
color: var(--muted);
|
|
28588
|
+
font-size: 13px;
|
|
28589
|
+
}
|
|
28590
|
+
@media (max-width: 1024px) {
|
|
28591
|
+
.cat-workspace { grid-template-columns: minmax(0, 1fr); }
|
|
28592
|
+
.cat-inspector { display: none; }
|
|
28593
|
+
.kbd-hint { display: none; }
|
|
28202
28594
|
}
|
|
28203
|
-
.row-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
|
|
28204
|
-
.feedback-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; min-width: 260px; }
|
|
28205
|
-
.feedback-row input[type="text"] { flex: 1; min-width: 180px; }
|
|
28206
|
-
.qa-panel { border: 1px solid var(--border); border-radius: 8px; padding: 12px; background: var(--subtle); }
|
|
28207
|
-
.rule-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 6px 12px; margin-top: 8px; }
|
|
28208
|
-
.rule-item { display: flex; gap: 6px; align-items: flex-start; font-size: 12px; }
|
|
28209
|
-
.qa-table { width: 100%; border-collapse: collapse; font-size: 13px; }
|
|
28210
|
-
.qa-table th, .qa-table td { border-bottom: 1px solid var(--border); padding: 8px 10px; text-align: left; vertical-align: top; }
|
|
28211
|
-
.qa-table th { font-size: 12px; color: var(--muted); background: var(--subtle); }
|
|
28212
|
-
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
|
|
28213
|
-
.badge-list { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
28214
28595
|
</style>
|
|
28215
28596
|
</head>
|
|
28216
28597
|
<body>
|
|
28217
|
-
<
|
|
28218
|
-
<div class="
|
|
28219
|
-
<
|
|
28220
|
-
|
|
28221
|
-
|
|
28222
|
-
|
|
28223
|
-
|
|
28224
|
-
|
|
28225
|
-
|
|
28226
|
-
|
|
28227
|
-
|
|
28228
|
-
|
|
28229
|
-
|
|
28230
|
-
|
|
28231
|
-
|
|
28232
|
-
<
|
|
28233
|
-
|
|
28234
|
-
|
|
28235
|
-
<span class="pill rev" id="pillRev">\u9700\u4FEE\u8BA2: 0</span>
|
|
28236
|
-
<span class="pill ok" id="pillApproved">\u5DF2\u653E\u884C: 0</span>
|
|
28237
|
-
<span class="pill err" id="pillQa">QA \u95EE\u9898: -</span>
|
|
28238
|
-
<span class="pill info" id="pillMqm">MQM: -</span>
|
|
28239
|
-
</div>
|
|
28240
|
-
</div>
|
|
28598
|
+
<header class="cat-ribbon">
|
|
28599
|
+
<div class="ribbon-left">
|
|
28600
|
+
<span class="brand-chip"><span class="brand-badge">CAT</span><span id="docTitle" class="doc-title">LangLink memoQ \u5DE5\u4F5C\u53F0</span></span>
|
|
28601
|
+
<select id="docSelector" class="doc-select" aria-label="\u6587\u6863\u5207\u6362"></select>
|
|
28602
|
+
<span id="langPair" class="pill">- \u2192 -</span>
|
|
28603
|
+
<span id="previewBadge" class="pill">Preview: \u68C0\u6D4B\u4E2D</span>
|
|
28604
|
+
<span id="docIdLine" class="mono" style="color:var(--faint);"></span>
|
|
28605
|
+
</div>
|
|
28606
|
+
<div class="ribbon-right">
|
|
28607
|
+
<button id="btnApproveAll" class="success" type="button">\u4E00\u952E\u653E\u884C\u5168\u90E8\u5B9A\u7A3F\u5230 memoQ</button>
|
|
28608
|
+
<button id="btnRevokeAll" type="button">\u64A4\u56DE\u5168\u90E8\u4E3A\u8349\u7A3F</button>
|
|
28609
|
+
<button id="btnRunQa" class="primary" type="button">\u8FD0\u884C QA \u68C0\u67E5</button>
|
|
28610
|
+
<button id="btnToggleQaCfg" type="button">QA \u53C2\u6570 \u25BE</button>
|
|
28611
|
+
<button id="btnToggleInspector" class="active-toggle" type="button">\u8BE6\u60C5\u9762\u677F</button>
|
|
28612
|
+
<label style="font-size:11px;display:inline-flex;align-items:center;gap:4px;cursor:pointer;">
|
|
28613
|
+
<input id="chkAutoPoll" type="checkbox" checked /> \u81EA\u52A8\u540C\u6B65 (3s)
|
|
28614
|
+
</label>
|
|
28615
|
+
<button id="btnRefresh" type="button">\u5237\u65B0</button>
|
|
28241
28616
|
</div>
|
|
28617
|
+
</header>
|
|
28242
28618
|
|
|
28243
|
-
|
|
28244
|
-
|
|
28245
|
-
|
|
28246
|
-
|
|
28247
|
-
|
|
28248
|
-
<button id="btnRunQa" class="primary" type="button">\u8FD0\u884C QA \u68C0\u67E5</button>
|
|
28249
|
-
<button id="btnToggleQaCfg" type="button">QA \u89C4\u5219\u4E0E\u53C2\u6570 \u25BE</button>
|
|
28250
|
-
</div>
|
|
28251
|
-
<div class="btn-group">
|
|
28252
|
-
<label style="font-size:12px;display:inline-flex;align-items:center;gap:4px;cursor:pointer;">
|
|
28253
|
-
<input id="chkAutoPoll" type="checkbox" checked /> \u81EA\u52A8\u540C\u6B65 Agent \u66F4\u65B0 (3s)
|
|
28254
|
-
</label>
|
|
28255
|
-
<button id="btnRefresh" type="button">\u7ACB\u5373\u5237\u65B0</button>
|
|
28256
|
-
</div>
|
|
28619
|
+
<nav class="cat-subbar">
|
|
28620
|
+
<div class="ribbon-left">
|
|
28621
|
+
<div class="tabs">
|
|
28622
|
+
<button id="tabBtnReview" class="tab-btn active" type="button">\u53CC\u8BED\u7F51\u683C</button>
|
|
28623
|
+
<button id="tabBtnQa" class="tab-btn" type="button">QA \u68C0\u67E5\u6E05\u5355</button>
|
|
28257
28624
|
</div>
|
|
28258
|
-
|
|
28259
|
-
<div
|
|
28260
|
-
<
|
|
28261
|
-
|
|
28262
|
-
|
|
28263
|
-
|
|
28264
|
-
|
|
28265
|
-
|
|
28266
|
-
|
|
28267
|
-
<div class="btn-group">
|
|
28268
|
-
<button id="btnRulesDefault" class="sm" type="button">\u9ED8\u8BA4\u89C4\u5219</button>
|
|
28269
|
-
<button id="btnRulesAll" class="sm" type="button">\u5168\u90E8\u89C4\u5219</button>
|
|
28270
|
-
<button id="btnRulesCritical" class="sm" type="button">\u4EC5\u4E25\u91CD\u9519\u8BEF</button>
|
|
28271
|
-
</div>
|
|
28272
|
-
</div>
|
|
28273
|
-
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(240px,1fr));gap:10px;margin-top:10px;">
|
|
28274
|
-
<div>
|
|
28275
|
-
<div class="box-label">\u672F\u8BED\u8868\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009 .csv/.tsv/.tbx\uFF09</div>
|
|
28276
|
-
<input id="inpGlossaryPath" type="text" style="width:100%;" placeholder="\u4F8B\u5982 D:\\project\\terms.csv" />
|
|
28277
|
-
</div>
|
|
28278
|
-
<div>
|
|
28279
|
-
<div class="box-label">\u9879\u76EE\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u81EA\u52A8\u8BFB\u53D6 .langlink/manifest.json\uFF09</div>
|
|
28280
|
-
<input id="inpProjectDir" type="text" style="width:100%;" placeholder="\u7559\u7A7A\u5219\u6CBF\u7528\u5DF2\u914D\u7F6E\u9879\u76EE\u76EE\u5F55" />
|
|
28281
|
-
</div>
|
|
28282
|
-
<div>
|
|
28283
|
-
<div class="box-label">\u539F\u6587\u514D\u67E5\u767D\u540D\u5355\uFF08UNTRANSLATED_COPY\uFF0C\u9017\u53F7\u5206\u9694\uFF09</div>
|
|
28284
|
-
<input id="inpWhitelist" type="text" style="width:100%;" placeholder="\u4F8B\u5982 Gold Coin, Discord, X" />
|
|
28285
|
-
</div>
|
|
28286
|
-
</div>
|
|
28287
|
-
<div id="qaRulesContainer" style="margin-top:10px;"></div>
|
|
28625
|
+
<span class="v-sep"></span>
|
|
28626
|
+
<div class="filter-pills" id="filterPills">
|
|
28627
|
+
<button class="filter-pill active" data-filter="all" type="button">\u5168\u90E8</button>
|
|
28628
|
+
<button class="filter-pill" data-filter="draft" type="button">\u5F85\u5BA1\u8349\u7A3F</button>
|
|
28629
|
+
<button class="filter-pill" data-filter="needs_revision" type="button">\u9700\u4FEE\u8BA2</button>
|
|
28630
|
+
<button class="filter-pill" data-filter="approved" type="button">\u5DF2\u653E\u884C</button>
|
|
28631
|
+
<button class="filter-pill" data-filter="qa_issue" type="button">\u6709 QA \u95EE\u9898</button>
|
|
28632
|
+
<button class="filter-pill" data-filter="diff" type="button">\u4E0E memoQ \u4E0D\u540C</button>
|
|
28633
|
+
<button class="filter-pill" data-filter="comment" type="button">\u6709\u6279\u6CE8</button>
|
|
28288
28634
|
</div>
|
|
28289
28635
|
</div>
|
|
28290
|
-
|
|
28291
|
-
|
|
28292
|
-
|
|
28293
|
-
<span>\u5F53\u524D\u6709 <strong id="revCount">0</strong> \u6761\u53E5\u6BB5\u6807\u8BB0\u4E3A\u300C\u9700 Agent \u4FEE\u6539\u300D\u3002\u4F60\u53EF\u4EE5\u76F4\u63A5\u590D\u5236\u8FD9\u6761\u63D0\u793A\u8BCD\u56DE\u53D1\u7ED9\u5BF9\u8BDD\u91CC\u7684 Agent\uFF1A</span>
|
|
28294
|
-
<button id="btnCopyPrompt" class="sm primary" type="button">\u590D\u5236\u7ED9 Agent \u7684\u4FEE\u8BA2\u6307\u4EE4</button>
|
|
28636
|
+
<div class="search-wrap">
|
|
28637
|
+
<span class="kbd-hint">Ctrl+Enter \u653E\u884C\u5E76\u4E0B\u4E00\u53E5 \xB7 Ctrl+S \u4FDD\u5B58 \xB7 Alt+\u2191\u2193 \u5207\u6362</span>
|
|
28638
|
+
<input id="searchBox" type="text" style="width:220px;" placeholder="\u641C\u7D22\u539F\u6587 / \u8BD1\u6587 / \u6279\u6CE8..." />
|
|
28295
28639
|
</div>
|
|
28296
|
-
|
|
28297
|
-
|
|
28298
|
-
|
|
28299
|
-
|
|
28300
|
-
|
|
28640
|
+
</nav>
|
|
28641
|
+
|
|
28642
|
+
<section id="qaConfigPanel" class="qa-panel hidden">
|
|
28643
|
+
<div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between;">
|
|
28644
|
+
<div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;font-size:12px;">
|
|
28645
|
+
<strong>\u68C0\u67E5\u5BF9\u8C61\uFF1A</strong>
|
|
28646
|
+
<label><input type="radio" name="qaScope" value="merged" checked /> \u5408\u5E76\u89C6\u56FE\uFF08\u6682\u5B58\u4F18\u5148\uFF0C\u7A7A\u7F3A\u8865 memoQ\uFF09</label>
|
|
28647
|
+
<label><input type="radio" name="qaScope" value="memoq" /> \u4EC5 memoQ \u73B0\u6709\u8BD1\u6587</label>
|
|
28648
|
+
<label><input type="radio" name="qaScope" value="staged" /> \u4EC5 Agent \u6682\u5B58\u8BD1\u6587</label>
|
|
28649
|
+
</div>
|
|
28650
|
+
<div style="display:flex;gap:6px;">
|
|
28651
|
+
<button id="btnRulesDefault" class="sm" type="button">\u9ED8\u8BA4\u89C4\u5219</button>
|
|
28652
|
+
<button id="btnRulesAll" class="sm" type="button">\u5168\u90E8\u89C4\u5219</button>
|
|
28653
|
+
<button id="btnRulesCritical" class="sm" type="button">\u4EC5\u4E25\u91CD\u9519\u8BEF</button>
|
|
28654
|
+
</div>
|
|
28655
|
+
</div>
|
|
28656
|
+
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px;margin-top:8px;">
|
|
28657
|
+
<div>
|
|
28658
|
+
<div class="box-label">\u672F\u8BED\u8868\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009 .csv/.tsv/.tbx\uFF09</div>
|
|
28659
|
+
<input id="inpGlossaryPath" type="text" style="width:100%;" placeholder="\u4F8B\u5982 D:\\project\\terms.csv" />
|
|
28301
28660
|
</div>
|
|
28661
|
+
<div>
|
|
28662
|
+
<div class="box-label">\u9879\u76EE\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u81EA\u52A8\u8BFB\u53D6 .langlink/manifest.json\uFF09</div>
|
|
28663
|
+
<input id="inpProjectDir" type="text" style="width:100%;" placeholder="\u7559\u7A7A\u5219\u6CBF\u7528\u5DF2\u914D\u7F6E\u9879\u76EE\u76EE\u5F55" />
|
|
28664
|
+
</div>
|
|
28665
|
+
<div>
|
|
28666
|
+
<div class="box-label">\u539F\u6587\u514D\u67E5\u767D\u540D\u5355\uFF08UNTRANSLATED_COPY\uFF0C\u9017\u53F7\u5206\u9694\uFF09</div>
|
|
28667
|
+
<input id="inpWhitelist" type="text" style="width:100%;" placeholder="\u4F8B\u5982 Gold Coin, Discord, X" />
|
|
28668
|
+
</div>
|
|
28669
|
+
</div>
|
|
28670
|
+
<div id="qaRulesContainer" style="margin-top:8px;"></div>
|
|
28671
|
+
</section>
|
|
28302
28672
|
|
|
28303
|
-
|
|
28304
|
-
|
|
28305
|
-
|
|
28306
|
-
|
|
28307
|
-
|
|
28308
|
-
|
|
28309
|
-
|
|
28310
|
-
|
|
28311
|
-
|
|
28312
|
-
|
|
28313
|
-
|
|
28314
|
-
<
|
|
28673
|
+
<div id="statusBanner" class="banner hidden"></div>
|
|
28674
|
+
<div id="revBanner" class="banner rev hidden">
|
|
28675
|
+
<span>\u5F53\u524D\u6709 <strong id="revCount">0</strong> \u6761\u53E5\u6BB5\u6807\u8BB0\u4E3A\u300C\u9700 Agent \u4FEE\u6539\u300D\u3002\u53EF\u76F4\u63A5\u590D\u5236\u6307\u4EE4\u53D1\u9001\u7ED9\u5BF9\u8BDD\u91CC\u7684 Agent\uFF1A</span>
|
|
28676
|
+
<button id="btnCopyPrompt" class="sm primary" type="button">\u590D\u5236\u7ED9 Agent \u7684\u4FEE\u8BA2\u6307\u4EE4</button>
|
|
28677
|
+
</div>
|
|
28678
|
+
|
|
28679
|
+
<main id="catWorkspace" class="cat-workspace">
|
|
28680
|
+
<section class="cat-main">
|
|
28681
|
+
<div id="panelReview" class="cat-grid-scroll">
|
|
28682
|
+
<div class="cat-grid-head">
|
|
28683
|
+
<div>#</div>
|
|
28684
|
+
<div>\u539F\u6587 (Source)</div>
|
|
28685
|
+
<div>\u8BD1\u6587 (Target)</div>
|
|
28686
|
+
<div>\u72B6\u6001 / \u64CD\u4F5C</div>
|
|
28315
28687
|
</div>
|
|
28316
|
-
<div id="segmentList"
|
|
28688
|
+
<div id="segmentList"></div>
|
|
28317
28689
|
</div>
|
|
28318
|
-
|
|
28319
|
-
|
|
28320
|
-
<div id="qaSummaryArea" style="margin-bottom:12px;"></div>
|
|
28690
|
+
<div id="panelQa" class="cat-grid-scroll hidden" style="padding:12px;">
|
|
28691
|
+
<div id="qaSummaryArea" style="margin-bottom:10px;"></div>
|
|
28321
28692
|
<div id="qaIssuesArea"></div>
|
|
28322
28693
|
</div>
|
|
28694
|
+
</section>
|
|
28695
|
+
|
|
28696
|
+
<aside id="inspectorPane" class="cat-inspector" aria-label="\u53E5\u6BB5\u8BE6\u60C5\u9762\u677F">
|
|
28697
|
+
<div id="inspectorContent"></div>
|
|
28698
|
+
</aside>
|
|
28699
|
+
</main>
|
|
28700
|
+
|
|
28701
|
+
<footer class="cat-statusbar">
|
|
28702
|
+
<div class="status-group">
|
|
28703
|
+
<span id="pillTotal">\u603B\u53E5\u6BB5: 0</span>
|
|
28704
|
+
<span>\u653E\u884C\u8FDB\u5EA6: <span class="progress-track"><span id="progressFill" class="progress-fill"></span></span> <strong id="progressPct">0%</strong></span>
|
|
28705
|
+
<span class="pill warn" id="pillDraft">\u8349\u7A3F\u5F85\u5BA1: 0</span>
|
|
28706
|
+
<span class="pill rev" id="pillRev">\u9700\u4FEE\u8BA2: 0</span>
|
|
28707
|
+
<span class="pill ok" id="pillApproved">\u5DF2\u653E\u884C: 0</span>
|
|
28708
|
+
<span class="pill err" id="pillQa">QA \u95EE\u9898: -</span>
|
|
28709
|
+
<span class="pill info" id="pillMqm">MQM: -</span>
|
|
28323
28710
|
</div>
|
|
28324
|
-
|
|
28711
|
+
<div class="status-group">
|
|
28712
|
+
<span id="bridgeStatusPill" class="pill ok">\u25CF \u6865\u63A5\u5DF2\u8FDE\u63A5</span>
|
|
28713
|
+
</div>
|
|
28714
|
+
</footer>
|
|
28325
28715
|
|
|
28326
28716
|
<script nonce="${options.nonce}">
|
|
28327
28717
|
const BOOT = ${bootJson};
|
|
28718
|
+
if (window.location.search) {
|
|
28719
|
+
try {
|
|
28720
|
+
history.replaceState(null, "", window.location.pathname);
|
|
28721
|
+
} catch {}
|
|
28722
|
+
}
|
|
28723
|
+
|
|
28328
28724
|
const state = {
|
|
28329
28725
|
data: null,
|
|
28330
28726
|
qa: null,
|
|
@@ -28336,7 +28732,10 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28336
28732
|
selectedRules: null,
|
|
28337
28733
|
dirtyTexts: new Map(),
|
|
28338
28734
|
dirtyComments: new Map(),
|
|
28339
|
-
|
|
28735
|
+
activeRowKey: "",
|
|
28736
|
+
lastFilteredKeys: [],
|
|
28737
|
+
inspectorOpen: true,
|
|
28738
|
+
bridgeConnected: true
|
|
28340
28739
|
};
|
|
28341
28740
|
|
|
28342
28741
|
const headers = () => ({
|
|
@@ -28352,6 +28751,34 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28352
28751
|
.replace(/"/g, """);
|
|
28353
28752
|
}
|
|
28354
28753
|
|
|
28754
|
+
const TAG_TOKEN_RE = /<span\\b[^>]*\\bdata-mqitag=(?:"[^"]*"|'[^']*')[^>]*>[\\s\\S]*?<\\/span>|\\{\\{[^{}\\r\\n]+\\}\\}|\\$\\{[^{}\\r\\n]+\\}|\\{[^{}\\r\\n]+\\}|<\\/>|<\\/?[A-Za-z0-9_#][^\\r\\n<>]*>|%(?:\\d+\\$)?[-+#0]*(?:\\d+)?(?:\\.\\d+)?[hlL]?[sdifFeEgGxXoucpaA%](?![A-Za-z])|\\r?\\n|\\\\[nrt]/gu;
|
|
28755
|
+
|
|
28756
|
+
function formatSourceHtml(rawText) {
|
|
28757
|
+
const text = String(rawText ?? "");
|
|
28758
|
+
if (!text) return "";
|
|
28759
|
+
let out = "";
|
|
28760
|
+
let lastIndex = 0;
|
|
28761
|
+
TAG_TOKEN_RE.lastIndex = 0;
|
|
28762
|
+
let match;
|
|
28763
|
+
while ((match = TAG_TOKEN_RE.exec(text)) !== null) {
|
|
28764
|
+
const idx = match.index;
|
|
28765
|
+
if (idx > lastIndex) {
|
|
28766
|
+
out += esc(text.slice(lastIndex, idx));
|
|
28767
|
+
}
|
|
28768
|
+
const tok = match[0];
|
|
28769
|
+
if (tok === "\\n" || tok === "\\r\\n") {
|
|
28770
|
+
out += '<span class="cat-tag" title="\u6362\u884C">\u21B5</span>\\n';
|
|
28771
|
+
} else {
|
|
28772
|
+
out += '<span class="cat-tag">' + esc(tok) + "</span>";
|
|
28773
|
+
}
|
|
28774
|
+
lastIndex = idx + tok.length;
|
|
28775
|
+
}
|
|
28776
|
+
if (lastIndex < text.length) {
|
|
28777
|
+
out += esc(text.slice(lastIndex));
|
|
28778
|
+
}
|
|
28779
|
+
return out;
|
|
28780
|
+
}
|
|
28781
|
+
|
|
28355
28782
|
function showBanner(type, text) {
|
|
28356
28783
|
const el = document.getElementById("statusBanner");
|
|
28357
28784
|
el.className = "banner " + type;
|
|
@@ -28363,20 +28790,55 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28363
28790
|
document.getElementById("statusBanner").classList.add("hidden");
|
|
28364
28791
|
}
|
|
28365
28792
|
|
|
28366
|
-
|
|
28367
|
-
const
|
|
28368
|
-
|
|
28369
|
-
if (
|
|
28370
|
-
|
|
28793
|
+
function renderBridgePill() {
|
|
28794
|
+
const el = document.getElementById("bridgeStatusPill");
|
|
28795
|
+
if (!el) return;
|
|
28796
|
+
if (state.bridgeConnected) {
|
|
28797
|
+
el.className = "pill ok";
|
|
28798
|
+
el.textContent = "\u25CF \u6865\u63A5\u5DF2\u8FDE\u63A5";
|
|
28799
|
+
} else {
|
|
28800
|
+
el.className = "pill warn";
|
|
28801
|
+
el.textContent = "\u25CB \u6865\u63A5\u91CD\u8FDE\u4E2D\u2026";
|
|
28802
|
+
}
|
|
28371
28803
|
}
|
|
28372
28804
|
|
|
28373
|
-
async function
|
|
28374
|
-
|
|
28375
|
-
|
|
28376
|
-
|
|
28805
|
+
async function apiRequest(method, path, body) {
|
|
28806
|
+
let res;
|
|
28807
|
+
try {
|
|
28808
|
+
res = await fetch(path, {
|
|
28809
|
+
method,
|
|
28810
|
+
headers: method === "GET" ? { "X-Review-Token": BOOT.reviewToken } : headers(),
|
|
28811
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) })
|
|
28812
|
+
});
|
|
28813
|
+
} catch (networkErr) {
|
|
28814
|
+
state.bridgeConnected = false;
|
|
28815
|
+
renderBridgePill();
|
|
28816
|
+
throw networkErr;
|
|
28817
|
+
}
|
|
28818
|
+
|
|
28819
|
+
if (res.status === 401) {
|
|
28820
|
+
throw new Error("\u5BA1\u6821\u6388\u6743\u5DF2\u5931\u6548\uFF0C\u8BF7\u4FDD\u7559\u5F53\u524D\u7F16\u8F91\u5E76\u4ECE Agent \u5BF9\u8BDD\u91CD\u65B0\u6253\u5F00 memoq_open_review \u94FE\u63A5\u3002");
|
|
28821
|
+
}
|
|
28822
|
+
|
|
28823
|
+
const data = await res.json().catch(() => ({}));
|
|
28824
|
+
if (!res.ok) {
|
|
28825
|
+
throw new Error(data.error || ("HTTP " + res.status));
|
|
28826
|
+
}
|
|
28827
|
+
if (!state.bridgeConnected) {
|
|
28828
|
+
state.bridgeConnected = true;
|
|
28829
|
+
renderBridgePill();
|
|
28830
|
+
}
|
|
28377
28831
|
return data;
|
|
28378
28832
|
}
|
|
28379
28833
|
|
|
28834
|
+
function apiGet(path) {
|
|
28835
|
+
return apiRequest("GET", path);
|
|
28836
|
+
}
|
|
28837
|
+
|
|
28838
|
+
function apiPost(path, body) {
|
|
28839
|
+
return apiRequest("POST", path, body);
|
|
28840
|
+
}
|
|
28841
|
+
|
|
28380
28842
|
function mergeRows() {
|
|
28381
28843
|
const previewSegs = (state.data && state.data.previewSegments) || [];
|
|
28382
28844
|
const stagedItems = (state.data && state.data.staged && state.data.staged.items) || [];
|
|
@@ -28472,11 +28934,18 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28472
28934
|
return map;
|
|
28473
28935
|
}
|
|
28474
28936
|
|
|
28937
|
+
function rowStatusClass(staged) {
|
|
28938
|
+
if (!staged) return "st-memoq";
|
|
28939
|
+
if (staged.status === "approved") return "st-approved";
|
|
28940
|
+
if (staged.status === "needs_revision") return "st-needs_revision";
|
|
28941
|
+
return "st-draft";
|
|
28942
|
+
}
|
|
28943
|
+
|
|
28475
28944
|
function statusBadgeHtml(staged) {
|
|
28476
|
-
if (!staged) return '<span class="pill">\u4EC5 memoQ
|
|
28477
|
-
if (staged.status === "approved") return '<span class="pill ok">\u5DF2\u653E\u884C v' + staged.revision + "</span>";
|
|
28945
|
+
if (!staged) return '<span class="pill">\u4EC5 memoQ</span>';
|
|
28946
|
+
if (staged.status === "approved") return '<span class="pill ok">\u2713 \u5DF2\u653E\u884C v' + staged.revision + "</span>";
|
|
28478
28947
|
if (staged.status === "needs_revision") return '<span class="pill rev">\u9700\u4FEE\u8BA2 v' + staged.revision + "</span>";
|
|
28479
|
-
return '<span class="pill warn">\u8349\u7A3F
|
|
28948
|
+
return '<span class="pill warn">\u8349\u7A3F v' + staged.revision + "</span>";
|
|
28480
28949
|
}
|
|
28481
28950
|
|
|
28482
28951
|
function renderRulesCatalog() {
|
|
@@ -28498,7 +28967,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28498
28967
|
for (const g of groups) {
|
|
28499
28968
|
const items = catalog.filter((r) => r.category === g.key);
|
|
28500
28969
|
if (!items.length) continue;
|
|
28501
|
-
html += '<div style="margin-top:
|
|
28970
|
+
html += '<div style="margin-top:6px;"><strong style="font-size:11px;">' + esc(g.title) + '</strong><div class="rule-grid">';
|
|
28502
28971
|
for (const r of items) {
|
|
28503
28972
|
const checked = state.selectedRules.has(r.ruleId) ? "checked" : "";
|
|
28504
28973
|
html += '<label class="rule-item" title="' + esc(r.description) + '">' +
|
|
@@ -28519,19 +28988,19 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28519
28988
|
const total = Math.max(previewSegCount, (d.staged && d.staged.total) || 0);
|
|
28520
28989
|
|
|
28521
28990
|
document.getElementById("docTitle").textContent =
|
|
28522
|
-
(doc.documentName || BOOT.initialDocumentName || "memoQ \u5F53\u524D\u6587\u6863")
|
|
28991
|
+
(doc.documentName || BOOT.initialDocumentName || "memoQ \u5F53\u524D\u6587\u6863");
|
|
28523
28992
|
document.getElementById("langPair").textContent =
|
|
28524
|
-
|
|
28993
|
+
(doc.sourceLanguage || "-") + " \u2192 " + (doc.targetLanguage || "-");
|
|
28525
28994
|
document.getElementById("docIdLine").textContent = doc.documentId && doc.documentId !== "__all__"
|
|
28526
|
-
?
|
|
28527
|
-
: (doc.documentId === "__all__" ? "\u8DE8\u6587\u6863
|
|
28995
|
+
? doc.documentId.slice(0, 8)
|
|
28996
|
+
: (doc.documentId === "__all__" ? "\u8DE8\u6587\u6863" : "");
|
|
28528
28997
|
|
|
28529
28998
|
const sel = document.getElementById("docSelector");
|
|
28530
28999
|
const docsList = d.documents || [];
|
|
28531
29000
|
const currentVal = state.selectedDocumentId || d.selectedDocumentId || doc.documentId || "";
|
|
28532
|
-
let optHtml = '<option value="">\u5F53\u524D\u6D3B\u8DC3\u6587\u6863\uFF08\u8DDF\u968F memoQ
|
|
29001
|
+
let optHtml = '<option value="">\u5F53\u524D\u6D3B\u8DC3\u6587\u6863\uFF08\u8DDF\u968F memoQ\uFF09</option>';
|
|
28533
29002
|
if (docsList.length > 0) {
|
|
28534
|
-
optHtml += '<option value="__all__"' + (currentVal === "__all__" ? " selected" : "") + '>\u5168\u90E8\u5DF2\u6253\u5F00\u6587\u6863
|
|
29003
|
+
optHtml += '<option value="__all__"' + (currentVal === "__all__" ? " selected" : "") + '>\u5168\u90E8\u5DF2\u6253\u5F00\u6587\u6863 (\u5171 ' + docsList.length + ' \u4EFD)</option>';
|
|
28535
29004
|
}
|
|
28536
29005
|
for (const item of docsList) {
|
|
28537
29006
|
const activeTag = item.isActive ? "[\u6D3B\u8DC3] " : "";
|
|
@@ -28551,6 +29020,9 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28551
29020
|
document.getElementById("pillDraft").textContent = "\u8349\u7A3F\u5F85\u5BA1: " + counts.draft;
|
|
28552
29021
|
document.getElementById("pillRev").textContent = "\u9700\u4FEE\u8BA2: " + counts.needsRevision;
|
|
28553
29022
|
document.getElementById("pillApproved").textContent = "\u5DF2\u653E\u884C: " + counts.approved;
|
|
29023
|
+
const pct = total > 0 ? Math.min(100, Math.round((counts.approved / total) * 100)) : 0;
|
|
29024
|
+
document.getElementById("progressFill").style.width = pct + "%";
|
|
29025
|
+
document.getElementById("progressPct").textContent = pct + "%";
|
|
28554
29026
|
|
|
28555
29027
|
const revBanner = document.getElementById("revBanner");
|
|
28556
29028
|
document.getElementById("revCount").textContent = String(counts.needsRevision);
|
|
@@ -28567,6 +29039,110 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28567
29039
|
|
|
28568
29040
|
const projInput = document.getElementById("inpProjectDir");
|
|
28569
29041
|
if (!projInput.value && d.projectDir) projInput.value = d.projectDir;
|
|
29042
|
+
renderBridgePill();
|
|
29043
|
+
}
|
|
29044
|
+
|
|
29045
|
+
function autoSizeTextarea(el) {
|
|
29046
|
+
if (!el) return;
|
|
29047
|
+
el.style.height = "auto";
|
|
29048
|
+
el.style.height = Math.max(44, Math.min(el.scrollHeight + 2, 240)) + "px";
|
|
29049
|
+
}
|
|
29050
|
+
|
|
29051
|
+
function renderInspector() {
|
|
29052
|
+
const box = document.getElementById("inspectorContent");
|
|
29053
|
+
if (!box) return;
|
|
29054
|
+
const rows = mergeRows();
|
|
29055
|
+
const row = rows.find((r) => r.rowKey === state.activeRowKey) || null;
|
|
29056
|
+
if (!row) {
|
|
29057
|
+
box.innerHTML = '<div class="empty-state">\u5728\u5DE6\u4FA7\u53CC\u8BED\u7F51\u683C\u4E2D\u70B9\u51FB\u4EFB\u610F\u53E5\u6BB5\uFF0C\u5373\u53EF\u5728\u6B64\u67E5\u770B\u4FEE\u8BA2\u5386\u53F2\u3001memoQ \u5B9E\u65F6\u8BD1\u6587\u3001QA \u95EE\u9898\u5E76\u5199\u6279\u6CE8\u3002</div>';
|
|
29058
|
+
return;
|
|
29059
|
+
}
|
|
29060
|
+
|
|
29061
|
+
const s = row.staged;
|
|
29062
|
+
const issueMap = issuesByRowMap();
|
|
29063
|
+
const rowIssues = issueMap.get(row.rowKey)
|
|
29064
|
+
|| issueMap.get(row.previewPartId)
|
|
29065
|
+
|| (s ? issueMap.get("staged:" + s.id) : null)
|
|
29066
|
+
|| [];
|
|
29067
|
+
const currentComment = state.dirtyComments.has(row.rowKey)
|
|
29068
|
+
? state.dirtyComments.get(row.rowKey)
|
|
29069
|
+
: (s ? s.reviewComment : "");
|
|
29070
|
+
|
|
29071
|
+
let historyHtml = '<div style="font-size:12px;color:var(--muted);">\u6682\u65E0\u591A\u8F6E\u5386\u53F2\uFF08\u9996\u6B21\u4FDD\u5B58\u6216\u4FEE\u8BA2\u540E\u81EA\u52A8\u8BB0\u5F55\uFF09\u3002</div>';
|
|
29072
|
+
if (s && Array.isArray(s.history) && s.history.length > 0) {
|
|
29073
|
+
historyHtml = '<div style="display:flex;gap:6px;align-items:center;">' +
|
|
29074
|
+
'<select class="rev-select" style="flex:1;min-width:0;" data-row="' + esc(row.rowKey) + '" data-id="' + esc(s.id) + '">' +
|
|
29075
|
+
s.history.slice().reverse().map((h) =>
|
|
29076
|
+
'<option value="' + h.revision + '">v' + h.revision + " (" + esc(h.editedBy) + "): " + esc(h.targetText.slice(0, 36)) + "</option>"
|
|
29077
|
+
).join("") +
|
|
29078
|
+
'</select><button class="sm btn-revert" data-id="' + esc(s.id) + '" data-row="' + esc(row.rowKey) + '" type="button">\u56DE\u9000</button></div>';
|
|
29079
|
+
}
|
|
29080
|
+
|
|
29081
|
+
let qaHtml = '<div style="font-size:12px;color:var(--muted);">' + (state.qa ? "\u672C\u53E5\u6BB5\u672A\u68C0\u51FA QA \u95EE\u9898\u3002" : "\u5C1A\u672A\u8FD0\u884C QA \u68C0\u67E5\u3002") + "</div>";
|
|
29082
|
+
if (rowIssues.length > 0) {
|
|
29083
|
+
qaHtml = rowIssues.map((iss) => {
|
|
29084
|
+
const cls = iss.severity === "critical" ? "err" : (iss.severity === "major" ? "warn" : "info");
|
|
29085
|
+
return '<div class="qa-issue-card">' +
|
|
29086
|
+
'<div><span class="pill ' + cls + '">' + esc(iss.severity) + '</span> <strong>' + esc(iss.ruleLabel) + "</strong></div>" +
|
|
29087
|
+
'<div>' + esc(iss.message) + "</div>" +
|
|
29088
|
+
(iss.evidence ? '<div class="mono" style="color:var(--muted);">' + esc(iss.evidence) + "</div>" : "") +
|
|
29089
|
+
(iss.suggestion ? '<div style="color:var(--ok);font-size:11px;">\u5EFA\u8BAE: ' + esc(iss.suggestion) + "</div>" : "") +
|
|
29090
|
+
"</div>";
|
|
29091
|
+
}).join("");
|
|
29092
|
+
}
|
|
29093
|
+
|
|
29094
|
+
const memoqText = row.memoqTargetText || "";
|
|
29095
|
+
const fillBtn = memoqText
|
|
29096
|
+
? '<button id="btnFillMemoqTarget" class="sm" data-row="' + esc(row.rowKey) + '" type="button">\u586B\u5165\u7F16\u8F91\u6846</button>'
|
|
29097
|
+
: "";
|
|
29098
|
+
const focusBtn = row.previewPartId
|
|
29099
|
+
? '<button class="sm btn-focus" data-part="' + esc(row.previewPartId) + '" data-doc="' + esc(row.documentId) + '" data-src="' + esc(row.sourceText) + '" type="button">\u5B9A\u4F4D memoQ</button>'
|
|
29100
|
+
: "";
|
|
29101
|
+
|
|
29102
|
+
box.innerHTML =
|
|
29103
|
+
'<div class="insp-section">' +
|
|
29104
|
+
'<div class="insp-title"><span>\u53E5\u6BB5 #' + (row.index + 1) + '</span>' + statusBadgeHtml(s) + "</div>" +
|
|
29105
|
+
'<div style="font-size:11px;color:var(--muted);">' +
|
|
29106
|
+
(row.documentName ? esc(row.documentName) + " \xB7 " : "") +
|
|
29107
|
+
esc(row.sourceLanguage || "-") + " \u2192 " + esc(row.targetLanguage || "-") +
|
|
29108
|
+
(s && s.stagedBy ? (" \xB7 by " + esc(s.stagedBy)) : "") +
|
|
29109
|
+
"</div>" +
|
|
29110
|
+
(focusBtn ? '<div style="margin-top:2px;">' + focusBtn + "</div>" : "") +
|
|
29111
|
+
"</div>" +
|
|
29112
|
+
'<div class="insp-section">' +
|
|
29113
|
+
'<div class="insp-title"><span>memoQ \u5B9E\u65F6\u8BD1\u6587\u5BF9\u7167</span>' + fillBtn + "</div>" +
|
|
29114
|
+
'<div class="insp-ref-text">' + (memoqText ? esc(memoqText) : '<span style="color:var(--faint);">(memoQ \u4E2D\u5F53\u524D\u4E3A\u7A7A)</span>') + "</div>" +
|
|
29115
|
+
"</div>" +
|
|
29116
|
+
'<div class="insp-section">' +
|
|
29117
|
+
'<div class="insp-title"><span>\u7ED9 Agent \u7684\u4FEE\u6539\u610F\u89C1</span></div>' +
|
|
29118
|
+
'<textarea id="inspectorCommentInput" class="cmt-edit" data-row="' + esc(row.rowKey) + '" rows="2" placeholder="\u8F93\u5165\u6279\u6CE8\uFF08\u5982\uFF1A\u672F\u8BED\u6539\u7528\u201C\u73CD\u5947\u201D\uFF0C\u8BED\u6C14\u66F4\u53E3\u8BED\uFF09">' + esc(currentComment) + "</textarea>" +
|
|
29119
|
+
'<div><button class="sm warn btn-feedback" data-row="' + esc(row.rowKey) + '" data-id="' + esc(s ? s.id : "") + '" type="button">\u6807\u8BB0\u9700\u4FEE\u8BA2\u5E76\u4FDD\u5B58\u6279\u6CE8</button></div>' +
|
|
29120
|
+
"</div>" +
|
|
29121
|
+
'<div class="insp-section">' +
|
|
29122
|
+
'<div class="insp-title"><span>\u591A\u8F6E\u4FEE\u8BA2\u5386\u53F2</span></div>' +
|
|
29123
|
+
historyHtml +
|
|
29124
|
+
"</div>" +
|
|
29125
|
+
'<div class="insp-section">' +
|
|
29126
|
+
'<div class="insp-title"><span>\u53E5\u6BB5 QA \u8BCA\u65AD (' + rowIssues.length + ")</span></div>" +
|
|
29127
|
+
qaHtml +
|
|
29128
|
+
"</div>";
|
|
29129
|
+
}
|
|
29130
|
+
|
|
29131
|
+
function selectActiveRow(rowKey, focusEditor = false) {
|
|
29132
|
+
if (!rowKey) return;
|
|
29133
|
+
state.activeRowKey = rowKey;
|
|
29134
|
+
for (const el of document.querySelectorAll("[data-row-card]")) {
|
|
29135
|
+
el.classList.toggle("active-row", el.getAttribute("data-row-card") === rowKey);
|
|
29136
|
+
}
|
|
29137
|
+
renderInspector();
|
|
29138
|
+
if (focusEditor) {
|
|
29139
|
+
const card = document.querySelector('[data-row-card="' + CSS.escape(rowKey) + '"]');
|
|
29140
|
+
const ta = card && card.querySelector(".tgt-edit");
|
|
29141
|
+
if (ta) {
|
|
29142
|
+
ta.focus();
|
|
29143
|
+
ta.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
29144
|
+
}
|
|
29145
|
+
}
|
|
28570
29146
|
}
|
|
28571
29147
|
|
|
28572
29148
|
function renderReviewList() {
|
|
@@ -28577,7 +29153,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28577
29153
|
|
|
28578
29154
|
const filtered = rows.filter((row) => {
|
|
28579
29155
|
const s = row.staged;
|
|
28580
|
-
const rowIssues = issueMap.get(row.rowKey) || (s ? issueMap.get("staged:" + s.id) : null) || [];
|
|
29156
|
+
const rowIssues = issueMap.get(row.rowKey) || issueMap.get(row.previewPartId) || (s ? issueMap.get("staged:" + s.id) : null) || [];
|
|
28581
29157
|
if (state.filter === "draft" && (!s || s.status !== "draft")) return false;
|
|
28582
29158
|
if (state.filter === "needs_revision" && (!s || s.status !== "needs_revision")) return false;
|
|
28583
29159
|
if (state.filter === "approved" && (!s || s.status !== "approved")) return false;
|
|
@@ -28598,11 +29174,18 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28598
29174
|
return true;
|
|
28599
29175
|
});
|
|
28600
29176
|
|
|
29177
|
+
state.lastFilteredKeys = filtered.map((r) => r.rowKey);
|
|
28601
29178
|
if (filtered.length === 0) {
|
|
28602
|
-
|
|
29179
|
+
state.activeRowKey = "";
|
|
29180
|
+
container.innerHTML = '<div class="empty-state">\u5F53\u524D\u7B5B\u9009\u6761\u4EF6\u4E0B\u6CA1\u6709\u53E5\u6BB5\u3002</div>';
|
|
29181
|
+
renderInspector();
|
|
28603
29182
|
return;
|
|
28604
29183
|
}
|
|
28605
29184
|
|
|
29185
|
+
if (!state.activeRowKey || !filtered.some((r) => r.rowKey === state.activeRowKey)) {
|
|
29186
|
+
state.activeRowKey = filtered[0].rowKey;
|
|
29187
|
+
}
|
|
29188
|
+
|
|
28606
29189
|
const showDocBadge = state.selectedDocumentId === "__all__"
|
|
28607
29190
|
|| (state.data && state.data.selectedDocumentId === "__all__")
|
|
28608
29191
|
|| (state.data && Array.isArray(state.data.documents) && state.data.documents.length > 1);
|
|
@@ -28615,80 +29198,64 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28615
29198
|
|| issueMap.get(row.previewPartId)
|
|
28616
29199
|
|| (s ? issueMap.get("staged:" + s.id) : null)
|
|
28617
29200
|
|| [];
|
|
28618
|
-
const
|
|
29201
|
+
const isDirty = state.dirtyTexts.has(row.rowKey);
|
|
29202
|
+
const currentTarget = isDirty
|
|
28619
29203
|
? state.dirtyTexts.get(row.rowKey)
|
|
28620
29204
|
: (s ? s.targetText : row.memoqTargetText);
|
|
28621
|
-
const
|
|
28622
|
-
? state.dirtyComments.get(row.rowKey)
|
|
28623
|
-
: (s ? s.reviewComment : "");
|
|
28624
|
-
const focusClass = state.highlightedRowKey === row.rowKey ? " highlight-focus" : "";
|
|
29205
|
+
const activeClass = state.activeRowKey === row.rowKey ? " active-row" : "";
|
|
28625
29206
|
const docBadge = showDocBadge && row.documentName
|
|
28626
|
-
? '<span class="
|
|
29207
|
+
? '<span class="doc-chip" title="' + esc(row.documentName) + '">' + esc(row.documentName) + "</span>"
|
|
28627
29208
|
: "";
|
|
28628
29209
|
|
|
28629
29210
|
let issuesBadges = "";
|
|
28630
29211
|
if (rowIssues.length > 0) {
|
|
28631
|
-
issuesBadges = '<div class="badge-list">' + rowIssues.map((iss) => {
|
|
29212
|
+
issuesBadges = '<div class="badge-list">' + rowIssues.slice(0, 3).map((iss) => {
|
|
28632
29213
|
const cls = iss.severity === "critical" ? "err" : (iss.severity === "major" ? "warn" : "info");
|
|
28633
|
-
return '<span class="pill ' + cls + '" title="' + esc(iss.evidence) + '">' + esc(iss.ruleLabel) +
|
|
28634
|
-
}).join("") + "</div>";
|
|
28635
|
-
}
|
|
28636
|
-
|
|
28637
|
-
let historyHtml = "";
|
|
28638
|
-
if (s && Array.isArray(s.history) && s.history.length > 0) {
|
|
28639
|
-
historyHtml = '<select class="rev-select" data-row="' + esc(row.rowKey) + '" data-id="' + esc(s.id) + '">' +
|
|
28640
|
-
s.history.slice().reverse().map((h) =>
|
|
28641
|
-
'<option value="' + h.revision + '">v' + h.revision + " (" + esc(h.editedBy) + "): " + esc(h.targetText.slice(0, 32)) + "</option>"
|
|
28642
|
-
).join("") +
|
|
28643
|
-
'</select><button class="sm btn-revert" data-id="' + esc(s.id) + '" data-row="' + esc(row.rowKey) + '" type="button">\u56DE\u9000\u8BE5\u7248\u672C</button>';
|
|
29214
|
+
return '<span class="pill ' + cls + '" title="' + esc(iss.evidence) + '">' + esc(iss.ruleLabel) + "</span>";
|
|
29215
|
+
}).join("") + (rowIssues.length > 3 ? '<span class="pill info">+' + (rowIssues.length - 3) + "</span>" : "") + "</div>";
|
|
28644
29216
|
}
|
|
28645
29217
|
|
|
28646
29218
|
const memoqDiffHtml = s && row.memoqTargetText && row.memoqTargetText !== s.targetText
|
|
28647
|
-
? '<div class="memoq-ref"
|
|
28648
|
-
:
|
|
28649
|
-
|
|
28650
|
-
|
|
29219
|
+
? '<div class="memoq-ref-line">memoQ: ' + esc(row.memoqTargetText) + "</div>"
|
|
29220
|
+
: "";
|
|
29221
|
+
const cmtBadge = s && s.reviewComment
|
|
29222
|
+
? '<div class="cmt-chip">\u6279\u6CE8: ' + esc(s.reviewComment) + "</div>"
|
|
29223
|
+
: "";
|
|
28651
29224
|
|
|
28652
29225
|
const approveBtn = s
|
|
28653
29226
|
? (s.status === "approved"
|
|
28654
|
-
? '<button class="sm btn-toggle-approve" data-id="' + esc(s.id) + '" data-next="draft" type="button"
|
|
28655
|
-
: '<button class="sm success btn-toggle-approve" data-id="' + esc(s.id) + '" data-next="approved" type="button"
|
|
29227
|
+
? '<button class="sm btn-toggle-approve" data-id="' + esc(s.id) + '" data-next="draft" type="button" title="\u64A4\u56DE\u4E3A\u8349\u7A3F">\u64A4\u56DE</button>'
|
|
29228
|
+
: '<button class="sm success btn-toggle-approve" data-id="' + esc(s.id) + '" data-next="approved" type="button" title="\u653E\u884C\u5B9A\u7A3F\u5230 memoQ">\u2713</button>')
|
|
28656
29229
|
: "";
|
|
28657
|
-
|
|
28658
29230
|
const focusBtn = row.previewPartId
|
|
28659
|
-
? '<button class="sm btn-focus" data-part="' + esc(row.previewPartId) + '" data-doc="' + esc(row.documentId) + '" data-src="' + esc(row.sourceText) + '" data-tgt="' + esc(currentTarget) + '" type="button"
|
|
29231
|
+
? '<button class="sm btn-focus" data-part="' + esc(row.previewPartId) + '" data-doc="' + esc(row.documentId) + '" data-src="' + esc(row.sourceText) + '" data-tgt="' + esc(currentTarget) + '" type="button" title="\u5728 memoQ \u4E2D\u5B9A\u4F4D">\u2316</button>'
|
|
28660
29232
|
: "";
|
|
28661
29233
|
|
|
28662
|
-
html += '<div class="
|
|
28663
|
-
'<div class="
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
'<
|
|
29234
|
+
html += '<div class="cat-row ' + rowStatusClass(s) + activeClass + '" data-row-card="' + esc(row.rowKey) + '">' +
|
|
29235
|
+
'<div class="cat-rail"><strong>' + (row.index + 1) + "</strong>" + docBadge + (isDirty ? '<span class="dirty-tag">\u672A\u4FDD\u5B58</span>' : "") + "</div>" +
|
|
29236
|
+
'<div class="cat-source"><div class="src-text">' + formatSourceHtml(row.sourceText) + "</div>" + issuesBadges + "</div>" +
|
|
29237
|
+
'<div class="cat-target">' +
|
|
29238
|
+
'<textarea class="tgt-edit" data-row="' + esc(row.rowKey) + '" placeholder="\u8F93\u5165\u6216\u7F16\u8F91\u8BD1\u6587...">' + esc(currentTarget) + "</textarea>" +
|
|
29239
|
+
memoqDiffHtml + cmtBadge +
|
|
28667
29240
|
"</div>" +
|
|
28668
|
-
'<div class="
|
|
28669
|
-
|
|
28670
|
-
'<div class="
|
|
28671
|
-
|
|
28672
|
-
|
|
28673
|
-
'<textarea class="tgt-edit" data-row="' + esc(row.rowKey) + '">' + esc(currentTarget) + "</textarea>" +
|
|
28674
|
-
'<div class="row-actions" style="margin-top:6px;">' +
|
|
28675
|
-
'<div class="btn-group">' +
|
|
28676
|
-
'<button class="sm primary btn-save-edit" data-row="' + esc(row.rowKey) + '" data-id="' + esc(s ? s.id : "") + '" type="button">' + (s ? "\u4FDD\u5B58\u65B0\u7248\u672C" : "\u4FDD\u5B58\u4E3A\u8349\u7A3F") + "</button>" +
|
|
28677
|
-
historyHtml +
|
|
28678
|
-
"</div>" +
|
|
28679
|
-
'<div class="feedback-row">' +
|
|
28680
|
-
'<input type="text" class="cmt-edit" data-row="' + esc(row.rowKey) + '" value="' + esc(currentComment) + '" placeholder="\u5199\u7ED9 Agent \u7684\u4FEE\u6539\u610F\u89C1\uFF08\u5982\uFF1A\u672F\u8BED\u518D\u53E3\u8BED\u4E9B\uFF09" />' +
|
|
28681
|
-
'<button class="sm warn btn-feedback" data-row="' + esc(row.rowKey) + '" data-id="' + esc(s ? s.id : "") + '" type="button">\u6807\u8BB0\u9700\u4FEE\u6539</button>' +
|
|
28682
|
-
"</div>" +
|
|
29241
|
+
'<div class="cat-status">' +
|
|
29242
|
+
statusBadgeHtml(s) +
|
|
29243
|
+
'<div class="row-mini-btns">' +
|
|
29244
|
+
'<button class="sm primary btn-save-edit" data-row="' + esc(row.rowKey) + '" data-id="' + esc(s ? s.id : "") + '" type="button">' + (s ? "\u4FDD\u5B58" : "\u6682\u5B58") + "</button>" +
|
|
29245
|
+
approveBtn + focusBtn +
|
|
28683
29246
|
"</div>" +
|
|
28684
29247
|
"</div>" +
|
|
28685
|
-
|
|
29248
|
+
"</div>";
|
|
28686
29249
|
}
|
|
28687
29250
|
if (filtered.length > maxRender) {
|
|
28688
29251
|
const remaining = filtered.length - maxRender;
|
|
28689
|
-
html += '<div class="banner warn"><span>\
|
|
29252
|
+
html += '<div class="banner warn"><span>\u5DF2\u5C55\u793A\u524D ' + maxRender + " \u6761\uFF08\u5171\u5339\u914D " + filtered.length + " \u6761\uFF0C\u8FD8\u6709 " + remaining + ' \u6761\u672A\u5C55\u5F00\uFF09\u3002</span><button id="btnLoadMoreRows" class="sm primary" type="button">\u518D\u52A0\u8F7D 300 \u6761</button></div>';
|
|
28690
29253
|
}
|
|
28691
29254
|
container.innerHTML = html;
|
|
29255
|
+
for (const ta of container.querySelectorAll(".tgt-edit")) {
|
|
29256
|
+
autoSizeTextarea(ta);
|
|
29257
|
+
}
|
|
29258
|
+
renderInspector();
|
|
28692
29259
|
}
|
|
28693
29260
|
|
|
28694
29261
|
function renderQaReport() {
|
|
@@ -28708,13 +29275,13 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28708
29275
|
? ("\u5DF2\u52A0\u8F7D\u672F\u8BED " + r.glossary.entriesCount + " \u6761\uFF08" + esc(r.glossary.sources.join(", ")) + "\uFF09")
|
|
28709
29276
|
: "\u672A\u52A0\u8F7D\u5916\u90E8\u672F\u8BED\u8868\uFF08\u672F\u8BED\u89C4\u5219\u5DF2\u8BDA\u5B9E\u6807\u6CE8 skipped\uFF09";
|
|
28710
29277
|
|
|
28711
|
-
const ruleSummaryHtml = '<details style="margin-top:
|
|
28712
|
-
'<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(
|
|
29278
|
+
const ruleSummaryHtml = '<details style="margin-top:6px;font-size:12px;"><summary style="cursor:pointer;font-weight:600;">\u89C4\u5219\u6267\u884C\u660E\u7EC6\uFF08\u5171 ' + r.rules.length + ' \u6761\uFF09</summary>' +
|
|
29279
|
+
'<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:4px 10px;margin-top:6px;font-size:11px;">' +
|
|
28713
29280
|
r.rules.map((rule) => '<div><strong>' + esc(rule.ruleId) + "</strong>: " + esc(rule.status) + " (" + rule.checkedSegments + ")" + (rule.reason ? " - " + esc(rule.reason) : "") + "</div>").join("") +
|
|
28714
29281
|
"</div></details>";
|
|
28715
29282
|
|
|
28716
29283
|
sumEl.innerHTML =
|
|
28717
|
-
'<div
|
|
29284
|
+
'<div style="display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:6px;">' +
|
|
28718
29285
|
'<span class="pill info">\u68C0\u67E5\u6A21\u5F0F: ' + esc(r.scope) + "</span>" +
|
|
28719
29286
|
'<span class="pill">\u603B\u53E5\u6BB5: ' + s.totalSegments + "</span>" +
|
|
28720
29287
|
'<span class="pill">\u5DF2\u8BD1/\u975E\u7A7A: ' + s.translatedSegments + " / \u7A7A\u8BD1: " + s.emptyTargetSegments + "</span>" +
|
|
@@ -28724,7 +29291,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28724
29291
|
'<span class="pill">MQM RQS: ' + s.mqm.rqs + " (APT=" + s.mqm.apt + ", EWC=" + s.mqm.ewc + ")</span>" +
|
|
28725
29292
|
covPill +
|
|
28726
29293
|
"</div>" +
|
|
28727
|
-
'<div
|
|
29294
|
+
'<div style="font-size:12px;color:var(--muted);">' + glossaryInfo +
|
|
28728
29295
|
(r.glossary.warnings.length ? (" | \u6CE8\u610F: " + esc(r.glossary.warnings.join("; "))) : "") +
|
|
28729
29296
|
"</div>" + ruleSummaryHtml;
|
|
28730
29297
|
|
|
@@ -28742,7 +29309,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28742
29309
|
const jumpKey = (iss.documentId && iss.previewPartId ? (iss.documentId + "::" + iss.previewPartId) : iss.previewPartId)
|
|
28743
29310
|
|| (iss.stagedId ? ("staged:" + iss.stagedId) : "");
|
|
28744
29311
|
const jumpBtn = jumpKey
|
|
28745
|
-
? '<button class="sm primary btn-jump-review" data-row="' + esc(jumpKey) + '" type="button">\u53BB\u5BA1\u6821
|
|
29312
|
+
? '<button class="sm primary btn-jump-review" data-row="' + esc(jumpKey) + '" type="button">\u53BB\u5BA1\u6821</button>'
|
|
28746
29313
|
: "";
|
|
28747
29314
|
const segCell = (r.allDocuments && iss.documentName)
|
|
28748
29315
|
? ('<div><span class="pill info">' + esc(iss.documentName) + "</span></div><div>#" + (iss.docSegmentNumber || iss.segmentNumber) + "</div>")
|
|
@@ -28752,12 +29319,12 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28752
29319
|
'<td><span class="pill ' + cls + '">' + esc(iss.severity) + "</span></td>" +
|
|
28753
29320
|
"<td><strong>" + esc(iss.ruleLabel) + '</strong><div class="mono">' + esc(iss.ruleId) + "</div></td>" +
|
|
28754
29321
|
"<td>" + segCell + "</td>" +
|
|
28755
|
-
"<td><div style='margin-bottom:
|
|
29322
|
+
"<td><div style='margin-bottom:3px;'><strong>\u6E90\uFF1A</strong>" + esc(iss.sourceText) + "</div>" +
|
|
28756
29323
|
"<div><strong>\u8BD1\uFF1A</strong>" + esc(iss.targetText || "(\u7A7A)") + "</div></td>" +
|
|
28757
|
-
"<td><div>" + esc(iss.message) + '</div><div class="mono">' + esc(iss.evidence) + "</div>" +
|
|
28758
|
-
(iss.suggestion ? ('<div style="color:var(--ok);font-size:
|
|
29324
|
+
"<td><div>" + esc(iss.message) + '</div><div class="mono" style="color:var(--muted);">' + esc(iss.evidence) + "</div>" +
|
|
29325
|
+
(iss.suggestion ? ('<div style="color:var(--ok);font-size:11px;">\u5EFA\u8BAE: ' + esc(iss.suggestion) + "</div>") : "") +
|
|
28759
29326
|
"</td>" +
|
|
28760
|
-
'<td><div
|
|
29327
|
+
'<td><div style="display:flex;gap:4px;flex-wrap:wrap;">' + focusBtn + jumpBtn + "</div></td>" +
|
|
28761
29328
|
"</tr>";
|
|
28762
29329
|
}
|
|
28763
29330
|
|
|
@@ -28782,6 +29349,24 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28782
29349
|
}
|
|
28783
29350
|
}
|
|
28784
29351
|
|
|
29352
|
+
async function saveRowDraft(rowKey, stagedId, targetText, nextStatus) {
|
|
29353
|
+
const row = mergeRows().find((r) => r.rowKey === rowKey);
|
|
29354
|
+
if (!row) return null;
|
|
29355
|
+
const res = await apiPost("/review/api/update", {
|
|
29356
|
+
...(stagedId ? { id: stagedId } : {}),
|
|
29357
|
+
targetText,
|
|
29358
|
+
...(nextStatus ? { status: nextStatus } : {}),
|
|
29359
|
+
editedBy: "translator",
|
|
29360
|
+
sourceText: row.sourceText,
|
|
29361
|
+
sourceLanguage: row.sourceLanguage || "eng",
|
|
29362
|
+
targetLanguage: row.targetLanguage || "zho-CN",
|
|
29363
|
+
documentId: row.documentId || "",
|
|
29364
|
+
previewPartId: row.previewPartId || ""
|
|
29365
|
+
});
|
|
29366
|
+
state.dirtyTexts.delete(rowKey);
|
|
29367
|
+
return res.entry || null;
|
|
29368
|
+
}
|
|
29369
|
+
|
|
28785
29370
|
async function runQa() {
|
|
28786
29371
|
const scopeEl = document.querySelector('input[name="qaScope"]:checked');
|
|
28787
29372
|
const scope = scopeEl ? scopeEl.value : "merged";
|
|
@@ -28834,10 +29419,6 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28834
29419
|
if (tab === "qa") renderQaReport();
|
|
28835
29420
|
}
|
|
28836
29421
|
|
|
28837
|
-
function findRowByKey(rowKey) {
|
|
28838
|
-
return mergeRows().find((r) => r.rowKey === rowKey);
|
|
28839
|
-
}
|
|
28840
|
-
|
|
28841
29422
|
document.getElementById("docSelector").addEventListener("change", (ev) => {
|
|
28842
29423
|
state.selectedDocumentId = ev.target.value || "";
|
|
28843
29424
|
state.renderLimit = 300;
|
|
@@ -28851,6 +29432,11 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28851
29432
|
document.getElementById("btnToggleQaCfg").addEventListener("click", () => {
|
|
28852
29433
|
document.getElementById("qaConfigPanel").classList.toggle("hidden");
|
|
28853
29434
|
});
|
|
29435
|
+
document.getElementById("btnToggleInspector").addEventListener("click", () => {
|
|
29436
|
+
state.inspectorOpen = !state.inspectorOpen;
|
|
29437
|
+
document.getElementById("catWorkspace").classList.toggle("inspector-collapsed", !state.inspectorOpen);
|
|
29438
|
+
document.getElementById("btnToggleInspector").classList.toggle("active-toggle", state.inspectorOpen);
|
|
29439
|
+
});
|
|
28854
29440
|
|
|
28855
29441
|
document.getElementById("btnRulesDefault").addEventListener("click", () => {
|
|
28856
29442
|
const cat = (state.data && state.data.qaCatalog) || [];
|
|
@@ -28881,7 +29467,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28881
29467
|
const docId = (state.data && state.data.document && state.data.document.documentId) || "";
|
|
28882
29468
|
const res = await apiPost("/review/api/approve", { ...(docId ? { documentId: docId } : {}), status: "approved" });
|
|
28883
29469
|
await refreshState(true);
|
|
28884
|
-
showBanner("ok", "\u5DF2\u653E\u884C " + res.approvedTotal + " \u6761\u6700\u7EC8\u5B9A\u7A3F\uFF01\u8BF7\u5207\u56DE memoQ \u8FD0\u884C Pre-translate \u5373\u53EF\u6BEB\u79D2\u5199\u5165\
|
|
29470
|
+
showBanner("ok", "\u5DF2\u653E\u884C " + res.approvedTotal + " \u6761\u6700\u7EC8\u5B9A\u7A3F\uFF01\u8BF7\u5207\u56DE memoQ \u8FD0\u884C Pre-translate \u5373\u53EF\u6BEB\u79D2\u5199\u5165\u3002");
|
|
28885
29471
|
} catch (err) {
|
|
28886
29472
|
showBanner("err", "\u653E\u884C\u5931\u8D25: " + (err.message || err));
|
|
28887
29473
|
}
|
|
@@ -28928,8 +29514,76 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28928
29514
|
if (!t || !t.getAttribute) return;
|
|
28929
29515
|
const rowKey = t.getAttribute("data-row");
|
|
28930
29516
|
if (!rowKey) return;
|
|
28931
|
-
if (t.classList.contains("tgt-edit"))
|
|
28932
|
-
|
|
29517
|
+
if (t.classList.contains("tgt-edit")) {
|
|
29518
|
+
state.dirtyTexts.set(rowKey, t.value);
|
|
29519
|
+
autoSizeTextarea(t);
|
|
29520
|
+
}
|
|
29521
|
+
if (t.classList.contains("cmt-edit")) {
|
|
29522
|
+
state.dirtyComments.set(rowKey, t.value);
|
|
29523
|
+
}
|
|
29524
|
+
});
|
|
29525
|
+
|
|
29526
|
+
document.addEventListener("focusin", (ev) => {
|
|
29527
|
+
const card = ev.target && ev.target.closest ? ev.target.closest("[data-row-card]") : null;
|
|
29528
|
+
if (card) {
|
|
29529
|
+
const rk = card.getAttribute("data-row-card");
|
|
29530
|
+
if (rk && rk !== state.activeRowKey) {
|
|
29531
|
+
selectActiveRow(rk, false);
|
|
29532
|
+
}
|
|
29533
|
+
}
|
|
29534
|
+
});
|
|
29535
|
+
|
|
29536
|
+
document.addEventListener("keydown", async (ev) => {
|
|
29537
|
+
const t = ev.target;
|
|
29538
|
+
if (!t || !t.classList || !t.classList.contains("tgt-edit")) return;
|
|
29539
|
+
const rowKey = t.getAttribute("data-row") || "";
|
|
29540
|
+
if (!rowKey) return;
|
|
29541
|
+
|
|
29542
|
+
if ((ev.ctrlKey || ev.metaKey) && ev.key === "Enter") {
|
|
29543
|
+
ev.preventDefault();
|
|
29544
|
+
const card = t.closest("[data-row-card]");
|
|
29545
|
+
const saveBtn = card && card.querySelector(".btn-save-edit");
|
|
29546
|
+
const stagedId = (saveBtn && saveBtn.getAttribute("data-id")) || "";
|
|
29547
|
+
const keys = state.lastFilteredKeys || [];
|
|
29548
|
+
const curIdx = keys.indexOf(rowKey);
|
|
29549
|
+
const nextKey = curIdx >= 0 && curIdx + 1 < keys.length ? keys[curIdx + 1] : rowKey;
|
|
29550
|
+
try {
|
|
29551
|
+
await saveRowDraft(rowKey, stagedId, t.value, "approved");
|
|
29552
|
+
state.activeRowKey = nextKey;
|
|
29553
|
+
await refreshState(true);
|
|
29554
|
+
selectActiveRow(nextKey, true);
|
|
29555
|
+
showBanner("ok", "\u5DF2\u653E\u884C\u5F53\u524D\u53E5\u6BB5\u5E76\u8DF3\u8F6C\u5230\u4E0B\u4E00\u53E5\u3002");
|
|
29556
|
+
} catch (err) {
|
|
29557
|
+
showBanner("err", "\u5FEB\u6377\u653E\u884C\u5931\u8D25: " + (err.message || err));
|
|
29558
|
+
}
|
|
29559
|
+
return;
|
|
29560
|
+
}
|
|
29561
|
+
|
|
29562
|
+
if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === "s") {
|
|
29563
|
+
ev.preventDefault();
|
|
29564
|
+
const card = t.closest("[data-row-card]");
|
|
29565
|
+
const saveBtn = card && card.querySelector(".btn-save-edit");
|
|
29566
|
+
const stagedId = (saveBtn && saveBtn.getAttribute("data-id")) || "";
|
|
29567
|
+
try {
|
|
29568
|
+
await saveRowDraft(rowKey, stagedId, t.value);
|
|
29569
|
+
await refreshState(true);
|
|
29570
|
+
selectActiveRow(rowKey, true);
|
|
29571
|
+
showBanner("ok", "\u5DF2\u4FDD\u5B58\u5F53\u524D\u4FEE\u8BA2\u7248\u672C\u3002");
|
|
29572
|
+
} catch (err) {
|
|
29573
|
+
showBanner("err", "\u4FDD\u5B58\u5931\u8D25: " + (err.message || err));
|
|
29574
|
+
}
|
|
29575
|
+
return;
|
|
29576
|
+
}
|
|
29577
|
+
|
|
29578
|
+
if (ev.altKey && (ev.key === "ArrowDown" || ev.key === "ArrowUp")) {
|
|
29579
|
+
ev.preventDefault();
|
|
29580
|
+
const keys = state.lastFilteredKeys || [];
|
|
29581
|
+
const curIdx = keys.indexOf(rowKey);
|
|
29582
|
+
if (curIdx < 0) return;
|
|
29583
|
+
const delta = ev.key === "ArrowDown" ? 1 : -1;
|
|
29584
|
+
const nextIdx = Math.max(0, Math.min(keys.length - 1, curIdx + delta));
|
|
29585
|
+
selectActiveRow(keys[nextIdx], true);
|
|
29586
|
+
}
|
|
28933
29587
|
});
|
|
28934
29588
|
|
|
28935
29589
|
document.addEventListener("click", async (ev) => {
|
|
@@ -28940,6 +29594,23 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28940
29594
|
return;
|
|
28941
29595
|
}
|
|
28942
29596
|
|
|
29597
|
+
const btnFillMemoq = ev.target.closest("#btnFillMemoqTarget");
|
|
29598
|
+
if (btnFillMemoq) {
|
|
29599
|
+
const rowKey = btnFillMemoq.getAttribute("data-row") || "";
|
|
29600
|
+
const row = mergeRows().find((r) => r.rowKey === rowKey);
|
|
29601
|
+
if (!row || !row.memoqTargetText) return;
|
|
29602
|
+
state.dirtyTexts.set(rowKey, row.memoqTargetText);
|
|
29603
|
+
const card = document.querySelector('[data-row-card="' + CSS.escape(rowKey) + '"]');
|
|
29604
|
+
const ta = card && card.querySelector(".tgt-edit");
|
|
29605
|
+
if (ta) {
|
|
29606
|
+
ta.value = row.memoqTargetText;
|
|
29607
|
+
autoSizeTextarea(ta);
|
|
29608
|
+
ta.focus();
|
|
29609
|
+
}
|
|
29610
|
+
showBanner("ok", "\u5DF2\u5C06 memoQ \u5B9E\u65F6\u8BD1\u6587\u586B\u5165\u7F16\u8F91\u6846\uFF08\u522B\u5FD8\u4E86\u6309 Ctrl+S \u4FDD\u5B58\uFF09\u3002");
|
|
29611
|
+
return;
|
|
29612
|
+
}
|
|
29613
|
+
|
|
28943
29614
|
const btnFocus = ev.target.closest(".btn-focus");
|
|
28944
29615
|
if (btnFocus) {
|
|
28945
29616
|
try {
|
|
@@ -28958,24 +29629,12 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28958
29629
|
|
|
28959
29630
|
const btnSave = ev.target.closest(".btn-save-edit");
|
|
28960
29631
|
if (btnSave) {
|
|
28961
|
-
const rowKey = btnSave.getAttribute("data-row");
|
|
29632
|
+
const rowKey = btnSave.getAttribute("data-row") || "";
|
|
28962
29633
|
const id = btnSave.getAttribute("data-id") || "";
|
|
28963
|
-
const row = findRowByKey(rowKey);
|
|
28964
|
-
if (!row) return;
|
|
28965
29634
|
const card = btnSave.closest("[data-row-card]");
|
|
28966
29635
|
const targetText = card.querySelector(".tgt-edit").value;
|
|
28967
29636
|
try {
|
|
28968
|
-
await
|
|
28969
|
-
...(id ? { id } : {}),
|
|
28970
|
-
targetText,
|
|
28971
|
-
editedBy: "translator",
|
|
28972
|
-
sourceText: row.sourceText,
|
|
28973
|
-
sourceLanguage: row.sourceLanguage || "eng",
|
|
28974
|
-
targetLanguage: row.targetLanguage || "zho-CN",
|
|
28975
|
-
documentId: row.documentId || "",
|
|
28976
|
-
previewPartId: row.previewPartId || ""
|
|
28977
|
-
});
|
|
28978
|
-
state.dirtyTexts.delete(rowKey);
|
|
29637
|
+
await saveRowDraft(rowKey, id, targetText);
|
|
28979
29638
|
await refreshState(true);
|
|
28980
29639
|
showBanner("ok", "\u5DF2\u4FDD\u5B58\u4FEE\u8BA2\u7248\u672C\u3002");
|
|
28981
29640
|
} catch (err) {
|
|
@@ -28987,9 +29646,9 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28987
29646
|
const btnRevert = ev.target.closest(".btn-revert");
|
|
28988
29647
|
if (btnRevert) {
|
|
28989
29648
|
const id = btnRevert.getAttribute("data-id");
|
|
28990
|
-
const rowKey = btnRevert.getAttribute("data-row");
|
|
28991
|
-
const
|
|
28992
|
-
const sel =
|
|
29649
|
+
const rowKey = btnRevert.getAttribute("data-row") || "";
|
|
29650
|
+
const insp = document.getElementById("inspectorPane");
|
|
29651
|
+
const sel = insp && insp.querySelector(".rev-select");
|
|
28993
29652
|
if (!id || !sel) return;
|
|
28994
29653
|
try {
|
|
28995
29654
|
await apiPost("/review/api/update", { id, revertToRevision: Number(sel.value), editedBy: "translator" });
|
|
@@ -29004,13 +29663,15 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
29004
29663
|
|
|
29005
29664
|
const btnFeedback = ev.target.closest(".btn-feedback");
|
|
29006
29665
|
if (btnFeedback) {
|
|
29007
|
-
const rowKey = btnFeedback.getAttribute("data-row");
|
|
29666
|
+
const rowKey = btnFeedback.getAttribute("data-row") || "";
|
|
29008
29667
|
const id = btnFeedback.getAttribute("data-id") || "";
|
|
29009
|
-
const row =
|
|
29668
|
+
const row = mergeRows().find((r) => r.rowKey === rowKey);
|
|
29010
29669
|
if (!row) return;
|
|
29011
|
-
const
|
|
29012
|
-
const comment =
|
|
29013
|
-
const
|
|
29670
|
+
const cmtInput = document.getElementById("inspectorCommentInput");
|
|
29671
|
+
const comment = cmtInput ? cmtInput.value : "";
|
|
29672
|
+
const card = document.querySelector('[data-row-card="' + CSS.escape(rowKey) + '"]');
|
|
29673
|
+
const ta = card && card.querySelector(".tgt-edit");
|
|
29674
|
+
const currentTarget = ta ? ta.value : (row.staged ? row.staged.targetText : row.memoqTargetText);
|
|
29014
29675
|
try {
|
|
29015
29676
|
await apiPost("/review/api/feedback", {
|
|
29016
29677
|
...(id ? { id } : {}),
|
|
@@ -29048,15 +29709,22 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
29048
29709
|
const btnJump = ev.target.closest(".btn-jump-review");
|
|
29049
29710
|
if (btnJump) {
|
|
29050
29711
|
const rowKey = btnJump.getAttribute("data-row") || "";
|
|
29051
|
-
state.highlightedRowKey = rowKey;
|
|
29052
29712
|
state.filter = "all";
|
|
29053
29713
|
for (const el of document.querySelectorAll("#filterPills [data-filter]")) {
|
|
29054
29714
|
el.classList.toggle("active", el.getAttribute("data-filter") === "all");
|
|
29055
29715
|
}
|
|
29056
29716
|
switchTab("review");
|
|
29057
29717
|
renderReviewList();
|
|
29058
|
-
|
|
29059
|
-
|
|
29718
|
+
selectActiveRow(rowKey, true);
|
|
29719
|
+
return;
|
|
29720
|
+
}
|
|
29721
|
+
|
|
29722
|
+
const clickedCard = ev.target.closest("[data-row-card]");
|
|
29723
|
+
if (clickedCard) {
|
|
29724
|
+
const rk = clickedCard.getAttribute("data-row-card");
|
|
29725
|
+
if (rk && rk !== state.activeRowKey) {
|
|
29726
|
+
selectActiveRow(rk, false);
|
|
29727
|
+
}
|
|
29060
29728
|
}
|
|
29061
29729
|
});
|
|
29062
29730
|
|
|
@@ -29126,14 +29794,54 @@ function safeBearerEquals(headerValue, expectedToken) {
|
|
|
29126
29794
|
if (!headerValue || !headerValue.startsWith("Bearer ")) return false;
|
|
29127
29795
|
return safeTokenEquals(headerValue.slice("Bearer ".length), expectedToken);
|
|
29128
29796
|
}
|
|
29129
|
-
|
|
29797
|
+
var REVIEW_COOKIE_NAME = "memoq_review_token";
|
|
29798
|
+
var REVIEW_COOKIE_MAX_AGE_SECONDS = 31536e3;
|
|
29799
|
+
function readCookieValue(cookieHeader, cookieName) {
|
|
29800
|
+
if (!cookieHeader) return void 0;
|
|
29801
|
+
for (const part of cookieHeader.split(";")) {
|
|
29802
|
+
const eqIndex = part.indexOf("=");
|
|
29803
|
+
if (eqIndex <= 0) continue;
|
|
29804
|
+
const name = part.slice(0, eqIndex).trim();
|
|
29805
|
+
if (name !== cookieName) continue;
|
|
29806
|
+
const value = part.slice(eqIndex + 1).trim();
|
|
29807
|
+
return value || void 0;
|
|
29808
|
+
}
|
|
29809
|
+
return void 0;
|
|
29810
|
+
}
|
|
29811
|
+
function renderReviewUnauthorizedHtml() {
|
|
29812
|
+
return `<!DOCTYPE html>
|
|
29813
|
+
<html lang="zh-CN">
|
|
29814
|
+
<head>
|
|
29815
|
+
<meta charset="utf-8" />
|
|
29816
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
29817
|
+
<title>LangLink memoQ \u5DE5\u4F5C\u53F0\u9700\u8981\u6388\u6743\u94FE\u63A5</title>
|
|
29818
|
+
<style>
|
|
29819
|
+
body { margin: 0; padding: 36px 20px; font: 14px/1.6 "Segoe UI", "Microsoft YaHei UI", sans-serif; background: #f8fafc; color: #0f172a; }
|
|
29820
|
+
.card { max-width: 560px; margin: 40px auto; background: #ffffff; border: 1px solid #cbd5e1; border-radius: 10px; padding: 24px; box-shadow: 0 4px 16px rgba(15, 23, 42, 0.06); }
|
|
29821
|
+
h1 { margin: 0 0 10px; font-size: 18px; }
|
|
29822
|
+
p { margin: 8px 0; color: #334155; }
|
|
29823
|
+
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
|
|
29824
|
+
</style>
|
|
29825
|
+
</head>
|
|
29826
|
+
<body>
|
|
29827
|
+
<main class="card">
|
|
29828
|
+
<h1>\u9700\u8981\u6709\u6548\u7684 memoQ \u5BA1\u6821\u5DE5\u4F5C\u53F0\u6388\u6743\u94FE\u63A5</h1>
|
|
29829
|
+
<p>\u51FA\u4E8E\u672C\u5730\u5B89\u5168\u9694\u79BB\u8981\u6C42\uFF0C\u6253\u5F00\u5BA1\u6821\u5DE5\u4F5C\u53F0\u9700\u8981\u5148\u901A\u8FC7 <code>memoq_open_review</code> \u83B7\u53D6\u7684\u6301\u4E45\u5316\u4EE4\u724C\u94FE\u63A5\uFF08<code>/review?token=...</code>\uFF09\u3002</p>
|
|
29830
|
+
<p>\u5728\u540C\u4E00\u6D4F\u89C8\u5668\u4E2D\u901A\u8FC7\u6709\u6548\u94FE\u63A5\u6253\u5F00\u4E00\u6B21\u540E\uFF0C\u6D4F\u89C8\u5668\u4F1A\u81EA\u52A8\u4FDD\u7559\u53D7\u9650 Cookie \u6388\u6743\uFF1B\u6B64\u540E\u5237\u65B0\u9875\u9762\u3001\u4F7F\u7528\u4E66\u7B7E\u6216\u91CD\u542F\u540E\u53F0\u670D\u52A1\u540E\u518D\u6B21\u6253\u5F00\u5747\u53EF\u7EE7\u7EED\u4F7F\u7528\u3002</p>
|
|
29831
|
+
<p style="color:#64748b;font-size:12px;">Unauthorized: present a valid persisted review token link via <code>memoq_open_review</code>.</p>
|
|
29832
|
+
</main>
|
|
29833
|
+
</body>
|
|
29834
|
+
</html>`;
|
|
29835
|
+
}
|
|
29836
|
+
function sendHtml(response, statusCode, html, csp, extraHeaders) {
|
|
29130
29837
|
response.writeHead(statusCode, {
|
|
29131
29838
|
"Content-Type": "text/html; charset=utf-8",
|
|
29132
29839
|
"Cache-Control": "no-store",
|
|
29133
29840
|
"Content-Security-Policy": csp,
|
|
29134
29841
|
"Referrer-Policy": "no-referrer",
|
|
29135
29842
|
"X-Frame-Options": "DENY",
|
|
29136
|
-
"X-Content-Type-Options": "nosniff"
|
|
29843
|
+
"X-Content-Type-Options": "nosniff",
|
|
29844
|
+
...extraHeaders
|
|
29137
29845
|
});
|
|
29138
29846
|
response.end(html);
|
|
29139
29847
|
}
|
|
@@ -29147,6 +29855,27 @@ function isAllowedOrigin(originHeader, boundHost, boundPort) {
|
|
|
29147
29855
|
const normalized = originHeader.toLowerCase();
|
|
29148
29856
|
return normalized === `http://${boundHost}:${boundPort}`.toLowerCase() || normalized === `http://localhost:${boundPort}` || normalized === `http://127.0.0.1:${boundPort}`;
|
|
29149
29857
|
}
|
|
29858
|
+
function isAllowedFetchSite(headerValue) {
|
|
29859
|
+
if (headerValue === void 0) return false;
|
|
29860
|
+
const raw = (Array.isArray(headerValue) ? headerValue[0] : headerValue) ?? "";
|
|
29861
|
+
return raw.trim().toLowerCase() === "same-origin";
|
|
29862
|
+
}
|
|
29863
|
+
function isAllowedReviewNavigation(request) {
|
|
29864
|
+
const fetchMode = request.headers["sec-fetch-mode"];
|
|
29865
|
+
const mode = (Array.isArray(fetchMode) ? fetchMode[0] : fetchMode)?.trim().toLowerCase() ?? "";
|
|
29866
|
+
if (mode === "no-cors") {
|
|
29867
|
+
return false;
|
|
29868
|
+
}
|
|
29869
|
+
const fetchSite = request.headers["sec-fetch-site"];
|
|
29870
|
+
const site = (Array.isArray(fetchSite) ? fetchSite[0] : fetchSite)?.trim().toLowerCase() ?? "";
|
|
29871
|
+
if (site === "cross-site" && mode !== "navigate") {
|
|
29872
|
+
return false;
|
|
29873
|
+
}
|
|
29874
|
+
if (mode && mode !== "navigate" && mode !== "same-origin" && mode !== "cors") {
|
|
29875
|
+
return false;
|
|
29876
|
+
}
|
|
29877
|
+
return true;
|
|
29878
|
+
}
|
|
29150
29879
|
async function createMtGateway(options) {
|
|
29151
29880
|
const host = options.host ?? DEFAULT_HOST;
|
|
29152
29881
|
const requestedPort = options.port ?? DEFAULT_PORT;
|
|
@@ -29752,14 +30481,21 @@ async function createMtGateway(options) {
|
|
|
29752
30481
|
response.setHeader("Referrer-Policy", "no-referrer");
|
|
29753
30482
|
response.setHeader("X-Frame-Options", "DENY");
|
|
29754
30483
|
if (method === "GET" && pathname === "/review") {
|
|
29755
|
-
|
|
29756
|
-
|
|
29757
|
-
|
|
30484
|
+
if (!isAllowedReviewNavigation(request)) {
|
|
30485
|
+
sendJson(response, 403, { success: false, error: "Rejected non-navigation review page fetch." });
|
|
30486
|
+
return;
|
|
30487
|
+
}
|
|
30488
|
+
const hasQueryTokenParam = url.searchParams.has("token");
|
|
30489
|
+
const queryToken = url.searchParams.get("token") ?? void 0;
|
|
30490
|
+
const cookieToken = readCookieValue(request.headers.cookie, REVIEW_COOKIE_NAME);
|
|
30491
|
+
const authenticatedByQuery = hasQueryTokenParam && safeTokenEquals(queryToken, reviewToken);
|
|
30492
|
+
const authenticatedByCookie = !hasQueryTokenParam && safeTokenEquals(cookieToken, reviewToken);
|
|
30493
|
+
if (!authenticatedByQuery && !authenticatedByCookie) {
|
|
29758
30494
|
sendHtml(
|
|
29759
30495
|
response,
|
|
29760
30496
|
401,
|
|
29761
|
-
|
|
29762
|
-
|
|
30497
|
+
renderReviewUnauthorizedHtml(),
|
|
30498
|
+
"default-src 'none'; style-src 'unsafe-inline'; frame-ancestors 'none'; base-uri 'none'"
|
|
29763
30499
|
);
|
|
29764
30500
|
return;
|
|
29765
30501
|
}
|
|
@@ -29774,14 +30510,25 @@ async function createMtGateway(options) {
|
|
|
29774
30510
|
reviewToken,
|
|
29775
30511
|
...initialDocName ? { initialDocumentName: initialDocName } : {}
|
|
29776
30512
|
}),
|
|
29777
|
-
csp
|
|
30513
|
+
csp,
|
|
30514
|
+
authenticatedByQuery ? {
|
|
30515
|
+
"Set-Cookie": `${REVIEW_COOKIE_NAME}=${reviewToken}; HttpOnly; SameSite=Strict; Path=/review; Max-Age=${REVIEW_COOKIE_MAX_AGE_SECONDS}`
|
|
30516
|
+
} : void 0
|
|
29778
30517
|
);
|
|
29779
30518
|
return;
|
|
29780
30519
|
}
|
|
30520
|
+
if (!isAllowedFetchSite(request.headers["sec-fetch-site"])) {
|
|
30521
|
+
sendJson(response, 403, { success: false, error: "Cross-site or missing Sec-Fetch-Site review API requests are not allowed." });
|
|
30522
|
+
return;
|
|
30523
|
+
}
|
|
29781
30524
|
const headerToken = request.headers["x-review-token"];
|
|
29782
30525
|
const providedHeader = Array.isArray(headerToken) ? headerToken[0] : headerToken;
|
|
29783
30526
|
if (!safeTokenEquals(providedHeader, reviewToken)) {
|
|
29784
|
-
sendJson(response, 401, {
|
|
30527
|
+
sendJson(response, 401, {
|
|
30528
|
+
success: false,
|
|
30529
|
+
code: "REVIEW_TOKEN_REQUIRED",
|
|
30530
|
+
error: "Valid review token is required."
|
|
30531
|
+
});
|
|
29785
30532
|
return;
|
|
29786
30533
|
}
|
|
29787
30534
|
if (method === "GET" && pathname === "/review/api/state") {
|
|
@@ -30135,14 +30882,14 @@ async function createMtGateway(options) {
|
|
|
30135
30882
|
}
|
|
30136
30883
|
sendJson(response, 404, { error: `Unknown control route: ${pathname}` });
|
|
30137
30884
|
}
|
|
30138
|
-
await new Promise((
|
|
30885
|
+
await new Promise((resolve7, reject) => {
|
|
30139
30886
|
const onError = (error2) => {
|
|
30140
30887
|
server.off("listening", onListening);
|
|
30141
30888
|
reject(error2);
|
|
30142
30889
|
};
|
|
30143
30890
|
const onListening = () => {
|
|
30144
30891
|
server.off("error", onError);
|
|
30145
|
-
|
|
30892
|
+
resolve7();
|
|
30146
30893
|
};
|
|
30147
30894
|
server.once("error", onError);
|
|
30148
30895
|
server.once("listening", onListening);
|
|
@@ -30162,8 +30909,8 @@ async function createMtGateway(options) {
|
|
|
30162
30909
|
reviewUrl: getReviewUrl(),
|
|
30163
30910
|
close: () => {
|
|
30164
30911
|
options.stagingStore.flush?.();
|
|
30165
|
-
return new Promise((
|
|
30166
|
-
server.close((error2) => error2 ? reject(error2) :
|
|
30912
|
+
return new Promise((resolve7, reject) => {
|
|
30913
|
+
server.close((error2) => error2 ? reject(error2) : resolve7());
|
|
30167
30914
|
});
|
|
30168
30915
|
},
|
|
30169
30916
|
handleTranslateForTest: processTranslate
|
|
@@ -30172,8 +30919,9 @@ async function createMtGateway(options) {
|
|
|
30172
30919
|
|
|
30173
30920
|
// packages/memoq-bridge/src/dll-assets.ts
|
|
30174
30921
|
import { createHash as createHash2, randomUUID as randomUUID4 } from "node:crypto";
|
|
30175
|
-
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
30176
|
-
import {
|
|
30922
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync4, renameSync as renameSync2, statSync as statSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
30923
|
+
import { homedir as homedir2 } from "node:os";
|
|
30924
|
+
import { dirname as dirname4, join as join5, resolve as resolve3 } from "node:path";
|
|
30177
30925
|
import { unzipSync } from "fflate";
|
|
30178
30926
|
var DEFAULT_PLUGIN_DLL_MANIFEST = {
|
|
30179
30927
|
pluginDllName: PLUGIN_DLL_NAME,
|
|
@@ -30186,6 +30934,23 @@ var DEFAULT_PLUGIN_DLL_MANIFEST = {
|
|
|
30186
30934
|
releaseTag: "v1.0.59",
|
|
30187
30935
|
downloadUrl: "https://github.com/langlink-localization/memoq-ai-hub/releases/download/v1.0.59/memoq-ai-hub-win32-x64.zip"
|
|
30188
30936
|
};
|
|
30937
|
+
var MAX_DISCOVERY_DIR_ENTRIES = 200;
|
|
30938
|
+
var MAX_ZIP_INSPECT_BYTES = 200 * 1024 * 1024;
|
|
30939
|
+
var MAX_FAST_ZIP_HASH_BYTES = 25 * 1024 * 1024;
|
|
30940
|
+
var ZIP_CANDIDATE_NAME_RE = /memoq.*(?:ai[-_]?hub|plugin)|memoq\.ai\.hub\.plugin/iu;
|
|
30941
|
+
function acceptedPluginSha256s(explicitExpectedSha256) {
|
|
30942
|
+
const override = (explicitExpectedSha256?.trim() || process.env.MEMOQ_PLUGIN_DLL_SHA256?.trim() || "").toUpperCase();
|
|
30943
|
+
if (override) {
|
|
30944
|
+
return [override];
|
|
30945
|
+
}
|
|
30946
|
+
const all = [DEFAULT_PLUGIN_DLL_MANIFEST.sha256, ...DEFAULT_PLUGIN_DLL_MANIFEST.compatibleSha256s].map((s) => s.trim().toUpperCase()).filter(Boolean);
|
|
30947
|
+
return Array.from(new Set(all));
|
|
30948
|
+
}
|
|
30949
|
+
function matchesAcceptedSha256(actualSha256, explicitExpectedSha256) {
|
|
30950
|
+
const normalized = actualSha256.trim().toUpperCase();
|
|
30951
|
+
if (!normalized) return false;
|
|
30952
|
+
return acceptedPluginSha256s(explicitExpectedSha256).includes(normalized);
|
|
30953
|
+
}
|
|
30189
30954
|
function computeBufferSha256(bytes) {
|
|
30190
30955
|
return createHash2("sha256").update(bytes).digest("hex").toUpperCase();
|
|
30191
30956
|
}
|
|
@@ -30212,6 +30977,15 @@ function parseAllowedAssetUrl(raw) {
|
|
|
30212
30977
|
}
|
|
30213
30978
|
return url;
|
|
30214
30979
|
}
|
|
30980
|
+
function normalizeExpectedShaList(expectedSha256) {
|
|
30981
|
+
if (Array.isArray(expectedSha256)) {
|
|
30982
|
+
return Array.from(new Set(expectedSha256.map((s) => s.trim().toUpperCase()).filter(Boolean)));
|
|
30983
|
+
}
|
|
30984
|
+
if (typeof expectedSha256 === "string" && expectedSha256.trim()) {
|
|
30985
|
+
return [expectedSha256.trim().toUpperCase()];
|
|
30986
|
+
}
|
|
30987
|
+
return [];
|
|
30988
|
+
}
|
|
30215
30989
|
function extractPluginDllFromBytes(bytes, expectedSha256) {
|
|
30216
30990
|
if (bytes.length < 2) {
|
|
30217
30991
|
throw new Error("Downloaded plugin artifact is empty.");
|
|
@@ -30238,9 +31012,10 @@ function extractPluginDllFromBytes(bytes, expectedSha256) {
|
|
|
30238
31012
|
dllBytes = bytes;
|
|
30239
31013
|
}
|
|
30240
31014
|
const actualSha256 = computeBufferSha256(dllBytes);
|
|
30241
|
-
|
|
31015
|
+
const expectedList = normalizeExpectedShaList(expectedSha256);
|
|
31016
|
+
if (expectedList.length > 0 && !expectedList.includes(actualSha256)) {
|
|
30242
31017
|
throw new Error(
|
|
30243
|
-
`Plugin DLL SHA-256 mismatch. Expected ${
|
|
31018
|
+
`Plugin DLL SHA-256 mismatch. Expected ${expectedList.join(" or ")}, actual ${actualSha256}.`
|
|
30244
31019
|
);
|
|
30245
31020
|
}
|
|
30246
31021
|
return { dllBytes, sha256: actualSha256 };
|
|
@@ -30266,50 +31041,212 @@ function getPluginAssetCachePath(dataDir, version2 = DEFAULT_PLUGIN_DLL_MANIFEST
|
|
|
30266
31041
|
const root = dataDir ?? defaultBridgeDataDir();
|
|
30267
31042
|
return join5(root, "assets", version2, PLUGIN_DLL_NAME);
|
|
30268
31043
|
}
|
|
31044
|
+
function writeAtomicCacheDll(cachePath, dllBytes) {
|
|
31045
|
+
mkdirSync3(dirname4(cachePath), { recursive: true });
|
|
31046
|
+
const temp = `${cachePath}.${randomUUID4()}.tmp`;
|
|
31047
|
+
writeFileSync3(temp, dllBytes);
|
|
31048
|
+
renameSync2(temp, cachePath);
|
|
31049
|
+
}
|
|
31050
|
+
function inspectCandidateFile(filePath, source, acceptedShas, maxZipHashBytes) {
|
|
31051
|
+
try {
|
|
31052
|
+
const resolved = resolve3(filePath);
|
|
31053
|
+
if (!existsSync4(resolved)) return null;
|
|
31054
|
+
const stats = statSync2(resolved);
|
|
31055
|
+
if (!stats.isFile()) return null;
|
|
31056
|
+
const lower = resolved.toLowerCase();
|
|
31057
|
+
let isZip = lower.endsWith(".zip");
|
|
31058
|
+
if (!isZip && stats.size >= 2) {
|
|
31059
|
+
const head = readFileSync4(resolved).subarray(0, 2);
|
|
31060
|
+
isZip = head[0] === 80 && head[1] === 75;
|
|
31061
|
+
}
|
|
31062
|
+
if (isZip) {
|
|
31063
|
+
if (stats.size > MAX_ZIP_INSPECT_BYTES) return null;
|
|
31064
|
+
if (stats.size > maxZipHashBytes) {
|
|
31065
|
+
return {
|
|
31066
|
+
path: resolved,
|
|
31067
|
+
kind: "zip",
|
|
31068
|
+
source,
|
|
31069
|
+
sha256: "",
|
|
31070
|
+
sha256MatchesExpected: false,
|
|
31071
|
+
sizeBytes: stats.size
|
|
31072
|
+
};
|
|
31073
|
+
}
|
|
31074
|
+
const bytes2 = readFileSync4(resolved);
|
|
31075
|
+
const { sha256: sha2562 } = extractPluginDllFromBytes(bytes2);
|
|
31076
|
+
return {
|
|
31077
|
+
path: resolved,
|
|
31078
|
+
kind: "zip",
|
|
31079
|
+
source,
|
|
31080
|
+
sha256: sha2562,
|
|
31081
|
+
sha256MatchesExpected: acceptedShas.includes(sha2562),
|
|
31082
|
+
sizeBytes: stats.size
|
|
31083
|
+
};
|
|
31084
|
+
}
|
|
31085
|
+
const bytes = readFileSync4(resolved);
|
|
31086
|
+
if (bytes.length < 2 || bytes[0] !== 77 || bytes[1] !== 90) {
|
|
31087
|
+
return null;
|
|
31088
|
+
}
|
|
31089
|
+
const sha256 = computeBufferSha256(bytes);
|
|
31090
|
+
return {
|
|
31091
|
+
path: resolved,
|
|
31092
|
+
kind: "dll",
|
|
31093
|
+
source,
|
|
31094
|
+
sha256,
|
|
31095
|
+
sha256MatchesExpected: acceptedShas.includes(sha256),
|
|
31096
|
+
sizeBytes: stats.size
|
|
31097
|
+
};
|
|
31098
|
+
} catch {
|
|
31099
|
+
return null;
|
|
31100
|
+
}
|
|
31101
|
+
}
|
|
31102
|
+
function discoverLocalPluginDllCandidates(options = {}) {
|
|
31103
|
+
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
31104
|
+
const version2 = options.version ?? DEFAULT_PLUGIN_DLL_MANIFEST.version;
|
|
31105
|
+
const acceptedShas = acceptedPluginSha256s(options.expectedSha256);
|
|
31106
|
+
const candidates = [];
|
|
31107
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
31108
|
+
const pushCandidate = (candidate) => {
|
|
31109
|
+
if (!candidate) return;
|
|
31110
|
+
const key = process.platform === "win32" ? candidate.path.toLowerCase() : candidate.path;
|
|
31111
|
+
if (seenFiles.has(key)) return;
|
|
31112
|
+
seenFiles.add(key);
|
|
31113
|
+
candidates.push(candidate);
|
|
31114
|
+
};
|
|
31115
|
+
const explicitPath = (options.dllPath ?? process.env.MEMOQ_PLUGIN_DLL_PATH ?? "").trim();
|
|
31116
|
+
if (explicitPath) {
|
|
31117
|
+
pushCandidate(inspectCandidateFile(explicitPath, "explicit", acceptedShas, MAX_ZIP_INSPECT_BYTES));
|
|
31118
|
+
}
|
|
31119
|
+
const cachePath = getPluginAssetCachePath(dataDir, version2);
|
|
31120
|
+
pushCandidate(inspectCandidateFile(cachePath, "cache", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
|
|
31121
|
+
for (const hubCandidate of defaultDiscoveryCandidates()) {
|
|
31122
|
+
pushCandidate(inspectCandidateFile(hubCandidate, "memoq-ai-hub", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
|
|
31123
|
+
}
|
|
31124
|
+
for (const extra of options.extraFilePaths ?? []) {
|
|
31125
|
+
if (!extra?.trim()) continue;
|
|
31126
|
+
pushCandidate(inspectCandidateFile(extra, "memoq-addins", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
|
|
31127
|
+
}
|
|
31128
|
+
const rawDirs = [...options.searchDirs ?? []];
|
|
31129
|
+
if (options.includeDefaultUserDirs !== false) {
|
|
31130
|
+
const home = homedir2();
|
|
31131
|
+
rawDirs.push(process.cwd(), join5(home, "Downloads"), join5(home, "Desktop"));
|
|
31132
|
+
}
|
|
31133
|
+
const seenDirs = /* @__PURE__ */ new Set();
|
|
31134
|
+
for (const rawDir of rawDirs) {
|
|
31135
|
+
if (!rawDir?.trim()) continue;
|
|
31136
|
+
let resolvedDir;
|
|
31137
|
+
try {
|
|
31138
|
+
resolvedDir = resolve3(rawDir.trim());
|
|
31139
|
+
} catch {
|
|
31140
|
+
continue;
|
|
31141
|
+
}
|
|
31142
|
+
const dirKey = process.platform === "win32" ? resolvedDir.toLowerCase() : resolvedDir;
|
|
31143
|
+
if (seenDirs.has(dirKey)) continue;
|
|
31144
|
+
seenDirs.add(dirKey);
|
|
31145
|
+
if (!existsSync4(resolvedDir)) continue;
|
|
31146
|
+
try {
|
|
31147
|
+
const entries = readdirSync(resolvedDir, { withFileTypes: true }).slice(0, MAX_DISCOVERY_DIR_ENTRIES);
|
|
31148
|
+
for (const entry of entries) {
|
|
31149
|
+
if (!entry.isFile()) continue;
|
|
31150
|
+
const lowerName = entry.name.toLowerCase();
|
|
31151
|
+
if (lowerName === PLUGIN_DLL_NAME.toLowerCase()) {
|
|
31152
|
+
pushCandidate(
|
|
31153
|
+
inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas, MAX_FAST_ZIP_HASH_BYTES)
|
|
31154
|
+
);
|
|
31155
|
+
} else if (lowerName.endsWith(".zip") && ZIP_CANDIDATE_NAME_RE.test(entry.name)) {
|
|
31156
|
+
pushCandidate(
|
|
31157
|
+
inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas, MAX_FAST_ZIP_HASH_BYTES)
|
|
31158
|
+
);
|
|
31159
|
+
}
|
|
31160
|
+
}
|
|
31161
|
+
} catch {
|
|
31162
|
+
}
|
|
31163
|
+
}
|
|
31164
|
+
return candidates.sort((a, b) => {
|
|
31165
|
+
const matchDiff = Number(b.sha256MatchesExpected) - Number(a.sha256MatchesExpected);
|
|
31166
|
+
if (matchDiff !== 0) return matchDiff;
|
|
31167
|
+
return Number(b.kind === "dll") - Number(a.kind === "dll");
|
|
31168
|
+
});
|
|
31169
|
+
}
|
|
30269
31170
|
async function resolvePluginDllAsset(options = {}) {
|
|
30270
31171
|
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
30271
31172
|
const version2 = options.version ?? DEFAULT_PLUGIN_DLL_MANIFEST.version;
|
|
30272
|
-
const
|
|
31173
|
+
const acceptedShas = acceptedPluginSha256s(options.expectedSha256);
|
|
31174
|
+
const expectedDisplay = acceptedShas.join(" or ");
|
|
31175
|
+
const cachePath = getPluginAssetCachePath(dataDir, version2);
|
|
30273
31176
|
const explicitPath = (options.dllPath ?? process.env.MEMOQ_PLUGIN_DLL_PATH ?? "").trim();
|
|
30274
31177
|
if (explicitPath) {
|
|
30275
31178
|
const resolved = resolve3(explicitPath);
|
|
30276
31179
|
if (!existsSync4(resolved)) {
|
|
30277
31180
|
throw new Error(`Configured MEMOQ_PLUGIN_DLL_PATH does not exist: ${resolved}`);
|
|
30278
31181
|
}
|
|
30279
|
-
const
|
|
30280
|
-
|
|
30281
|
-
|
|
31182
|
+
const rawBytes2 = readFileSync4(resolved);
|
|
31183
|
+
const isZip = rawBytes2.length >= 2 && rawBytes2[0] === 80 && rawBytes2[1] === 75;
|
|
31184
|
+
if (isZip) {
|
|
31185
|
+
const extracted = extractPluginDllFromBytes(
|
|
31186
|
+
rawBytes2,
|
|
31187
|
+
options.allowUnverifiedLocalDev ? void 0 : acceptedShas
|
|
31188
|
+
);
|
|
31189
|
+
writeAtomicCacheDll(cachePath, extracted.dllBytes);
|
|
31190
|
+
return {
|
|
31191
|
+
path: cachePath,
|
|
31192
|
+
sha256: extracted.sha256,
|
|
31193
|
+
version: version2,
|
|
31194
|
+
source: "explicit",
|
|
31195
|
+
verified: acceptedShas.includes(extracted.sha256)
|
|
31196
|
+
};
|
|
31197
|
+
}
|
|
31198
|
+
const isPe = rawBytes2.length >= 2 && rawBytes2[0] === 77 && rawBytes2[1] === 90;
|
|
31199
|
+
if (!isPe) {
|
|
31200
|
+
throw new Error(`File is neither a PE DLL nor a ZIP archive containing ${PLUGIN_DLL_NAME}: ${resolved}`);
|
|
31201
|
+
}
|
|
31202
|
+
const sha2562 = computeBufferSha256(rawBytes2);
|
|
31203
|
+
const verified = acceptedShas.includes(sha2562);
|
|
31204
|
+
if (!options.allowUnverifiedLocalDev && acceptedShas.length > 0 && !verified) {
|
|
31205
|
+
throw new Error(`Plugin DLL SHA-256 mismatch at ${resolved}. Expected ${expectedDisplay}, actual ${sha2562}.`);
|
|
30282
31206
|
}
|
|
30283
31207
|
return {
|
|
30284
31208
|
path: resolved,
|
|
30285
31209
|
sha256: sha2562,
|
|
30286
31210
|
version: version2,
|
|
30287
31211
|
source: "explicit",
|
|
30288
|
-
verified
|
|
31212
|
+
verified
|
|
30289
31213
|
};
|
|
30290
31214
|
}
|
|
30291
|
-
const cachePath = getPluginAssetCachePath(dataDir, version2);
|
|
30292
31215
|
if (existsSync4(cachePath)) {
|
|
30293
31216
|
const sha2562 = computeFileSha256(cachePath);
|
|
30294
|
-
if (
|
|
31217
|
+
if (acceptedShas.length === 0 || acceptedShas.includes(sha2562)) {
|
|
30295
31218
|
return {
|
|
30296
31219
|
path: cachePath,
|
|
30297
31220
|
sha256: sha2562,
|
|
30298
31221
|
version: version2,
|
|
30299
31222
|
source: "cache",
|
|
30300
|
-
verified:
|
|
31223
|
+
verified: acceptedShas.includes(sha2562)
|
|
30301
31224
|
};
|
|
30302
31225
|
}
|
|
30303
31226
|
}
|
|
30304
31227
|
const discoveryPaths = [...options.searchPaths ?? [], ...defaultDiscoveryCandidates()];
|
|
30305
31228
|
for (const candidate of discoveryPaths) {
|
|
30306
31229
|
if (!candidate || !existsSync4(candidate)) continue;
|
|
30307
|
-
const
|
|
30308
|
-
|
|
30309
|
-
|
|
30310
|
-
|
|
30311
|
-
|
|
30312
|
-
|
|
31230
|
+
const rawBytes2 = readFileSync4(candidate);
|
|
31231
|
+
const isZip = rawBytes2.length >= 2 && rawBytes2[0] === 80 && rawBytes2[1] === 75;
|
|
31232
|
+
if (isZip) {
|
|
31233
|
+
try {
|
|
31234
|
+
const extracted = extractPluginDllFromBytes(rawBytes2, acceptedShas);
|
|
31235
|
+
writeAtomicCacheDll(cachePath, extracted.dllBytes);
|
|
31236
|
+
return {
|
|
31237
|
+
path: cachePath,
|
|
31238
|
+
sha256: extracted.sha256,
|
|
31239
|
+
version: version2,
|
|
31240
|
+
source: "local-discovery",
|
|
31241
|
+
verified: true
|
|
31242
|
+
};
|
|
31243
|
+
} catch {
|
|
31244
|
+
continue;
|
|
31245
|
+
}
|
|
31246
|
+
}
|
|
31247
|
+
const sha2562 = computeBufferSha256(rawBytes2);
|
|
31248
|
+
if (acceptedShas.length > 0 && !acceptedShas.includes(sha2562)) continue;
|
|
31249
|
+
writeAtomicCacheDll(cachePath, rawBytes2);
|
|
30313
31250
|
return {
|
|
30314
31251
|
path: cachePath,
|
|
30315
31252
|
sha256: sha2562,
|
|
@@ -30318,9 +31255,46 @@ async function resolvePluginDllAsset(options = {}) {
|
|
|
30318
31255
|
verified: true
|
|
30319
31256
|
};
|
|
30320
31257
|
}
|
|
31258
|
+
if (options.searchDirs && options.searchDirs.length > 0 || options.includeDefaultUserDirs === true) {
|
|
31259
|
+
const folderCandidates = discoverLocalPluginDllCandidates({
|
|
31260
|
+
dataDir,
|
|
31261
|
+
...options.expectedSha256 === void 0 ? {} : { expectedSha256: options.expectedSha256 },
|
|
31262
|
+
version: version2,
|
|
31263
|
+
searchDirs: options.searchDirs ?? [],
|
|
31264
|
+
includeDefaultUserDirs: options.includeDefaultUserDirs === true
|
|
31265
|
+
});
|
|
31266
|
+
for (const candidate of folderCandidates) {
|
|
31267
|
+
try {
|
|
31268
|
+
const rawBytes2 = readFileSync4(candidate.path);
|
|
31269
|
+
if (candidate.kind === "zip") {
|
|
31270
|
+
const extracted = extractPluginDllFromBytes(rawBytes2, acceptedShas);
|
|
31271
|
+
writeAtomicCacheDll(cachePath, extracted.dllBytes);
|
|
31272
|
+
return {
|
|
31273
|
+
path: cachePath,
|
|
31274
|
+
sha256: extracted.sha256,
|
|
31275
|
+
version: version2,
|
|
31276
|
+
source: "local-discovery",
|
|
31277
|
+
verified: true
|
|
31278
|
+
};
|
|
31279
|
+
}
|
|
31280
|
+
const sha2562 = computeBufferSha256(rawBytes2);
|
|
31281
|
+
if (acceptedShas.length > 0 && !acceptedShas.includes(sha2562)) continue;
|
|
31282
|
+
writeAtomicCacheDll(cachePath, rawBytes2);
|
|
31283
|
+
return {
|
|
31284
|
+
path: cachePath,
|
|
31285
|
+
sha256: sha2562,
|
|
31286
|
+
version: version2,
|
|
31287
|
+
source: "local-discovery",
|
|
31288
|
+
verified: true
|
|
31289
|
+
};
|
|
31290
|
+
} catch {
|
|
31291
|
+
continue;
|
|
31292
|
+
}
|
|
31293
|
+
}
|
|
31294
|
+
}
|
|
30321
31295
|
if (options.allowDownload === false) {
|
|
30322
31296
|
throw new Error(
|
|
30323
|
-
`Plugin DLL ${PLUGIN_DLL_NAME} is not cached locally (expected SHA-256 ${
|
|
31297
|
+
`Plugin DLL ${PLUGIN_DLL_NAME} is not cached locally (expected SHA-256 ${expectedDisplay}). Run memoq_setup to download or provide MEMOQ_PLUGIN_DLL_PATH.`
|
|
30324
31298
|
);
|
|
30325
31299
|
}
|
|
30326
31300
|
const rawUrl = (options.downloadUrl ?? process.env.MEMOQ_PLUGIN_DLL_URL ?? DEFAULT_PLUGIN_DLL_MANIFEST.downloadUrl).trim();
|
|
@@ -30331,25 +31305,22 @@ async function resolvePluginDllAsset(options = {}) {
|
|
|
30331
31305
|
throw new Error(`Failed to download ${PLUGIN_DLL_NAME} (${response.status} ${response.statusText}).`);
|
|
30332
31306
|
}
|
|
30333
31307
|
const rawBytes = new Uint8Array(await response.arrayBuffer());
|
|
30334
|
-
const { dllBytes, sha256 } = extractPluginDllFromBytes(rawBytes,
|
|
30335
|
-
|
|
30336
|
-
const temp = `${cachePath}.${randomUUID4()}.tmp`;
|
|
30337
|
-
writeFileSync3(temp, dllBytes);
|
|
30338
|
-
renameSync2(temp, cachePath);
|
|
31308
|
+
const { dllBytes, sha256 } = extractPluginDllFromBytes(rawBytes, acceptedShas);
|
|
31309
|
+
writeAtomicCacheDll(cachePath, dllBytes);
|
|
30339
31310
|
return {
|
|
30340
31311
|
path: cachePath,
|
|
30341
31312
|
sha256,
|
|
30342
31313
|
version: version2,
|
|
30343
31314
|
source: "downloaded",
|
|
30344
|
-
verified:
|
|
31315
|
+
verified: acceptedShas.includes(sha256)
|
|
30345
31316
|
};
|
|
30346
31317
|
}
|
|
30347
31318
|
|
|
30348
31319
|
// packages/memoq-bridge/src/dll-installer.ts
|
|
30349
|
-
import { execFile } from "node:child_process";
|
|
31320
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
30350
31321
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
30351
31322
|
import { existsSync as existsSync5, mkdirSync as mkdirSync4, readFileSync as readFileSync5, rmSync as rmSync2 } from "node:fs";
|
|
30352
|
-
import { basename, join as join6, win32 } from "node:path";
|
|
31323
|
+
import { basename, join as join6, resolve as resolve4, win32 } from "node:path";
|
|
30353
31324
|
import { promisify } from "node:util";
|
|
30354
31325
|
var execFileAsync = promisify(execFile);
|
|
30355
31326
|
var SUPPORTED_VERSIONS = ["12", "11", "10"];
|
|
@@ -30378,18 +31349,92 @@ function readClientDevConfigState(programDataDir) {
|
|
|
30378
31349
|
return { path: filePath, exists: true, loadUnsignedPluginsEnabled: false };
|
|
30379
31350
|
}
|
|
30380
31351
|
}
|
|
31352
|
+
function discoverWindowsMemoQRoots(helperPath) {
|
|
31353
|
+
if (!helperPath || !existsSync5(helperPath)) {
|
|
31354
|
+
return [];
|
|
31355
|
+
}
|
|
31356
|
+
try {
|
|
31357
|
+
const stdout = execFileSync(helperPath, ["--discover-memoq"], {
|
|
31358
|
+
encoding: "utf8",
|
|
31359
|
+
timeout: 5e3,
|
|
31360
|
+
windowsHide: true
|
|
31361
|
+
});
|
|
31362
|
+
const parsed = JSON.parse(stdout.trim());
|
|
31363
|
+
if (!parsed?.ok || !Array.isArray(parsed.roots)) {
|
|
31364
|
+
return [];
|
|
31365
|
+
}
|
|
31366
|
+
const results = [];
|
|
31367
|
+
for (const entry of parsed.roots) {
|
|
31368
|
+
const rootDir = typeof entry?.rootDir === "string" ? entry.rootDir.trim() : "";
|
|
31369
|
+
if (!rootDir) continue;
|
|
31370
|
+
const version2 = typeof entry?.version === "string" && entry.version.trim() ? entry.version.trim() : "custom";
|
|
31371
|
+
const srcRaw = typeof entry?.source === "string" ? entry.source.trim() : "";
|
|
31372
|
+
const source = srcRaw === "running-process" || srcRaw === "registry" || srcRaw === "drive-scan" ? srcRaw : "drive-scan";
|
|
31373
|
+
results.push({ version: version2, rootDir, source });
|
|
31374
|
+
}
|
|
31375
|
+
return results;
|
|
31376
|
+
} catch {
|
|
31377
|
+
return [];
|
|
31378
|
+
}
|
|
31379
|
+
}
|
|
31380
|
+
function isProtectedWindowsPath(targetPath, programDataDir) {
|
|
31381
|
+
const checkOne = (raw) => {
|
|
31382
|
+
if (!raw || !raw.trim()) return false;
|
|
31383
|
+
const norm = raw.trim().replace(/\//gu, "\\").toLowerCase();
|
|
31384
|
+
const envProtected = [
|
|
31385
|
+
process.env.ProgramFiles,
|
|
31386
|
+
process.env["ProgramFiles(x86)"],
|
|
31387
|
+
process.env.ProgramData,
|
|
31388
|
+
process.env.SystemRoot,
|
|
31389
|
+
process.env.WINDIR
|
|
31390
|
+
].filter((v) => Boolean(v && v.trim())).map((v) => v.trim().replace(/\//gu, "\\").replace(/\\+$/u, "").toLowerCase());
|
|
31391
|
+
for (const base of envProtected) {
|
|
31392
|
+
if (norm === base || norm.startsWith(`${base}\\`)) {
|
|
31393
|
+
return true;
|
|
31394
|
+
}
|
|
31395
|
+
}
|
|
31396
|
+
return /^[a-z]:\\(?:program files(?: \(x86\))?|programdata|windows)(?:\\|$)/iu.test(norm);
|
|
31397
|
+
};
|
|
31398
|
+
return checkOne(targetPath) || (programDataDir ? checkOne(programDataDir) : false);
|
|
31399
|
+
}
|
|
30381
31400
|
function detectMemoQInstallations(options = {}) {
|
|
30382
|
-
const
|
|
31401
|
+
const platform = options.platform ?? process.platform;
|
|
30383
31402
|
const clientDevConfig = readClientDevConfigState(options.programDataDir);
|
|
30384
31403
|
const candidates = [];
|
|
30385
31404
|
const seen = /* @__PURE__ */ new Set();
|
|
30386
31405
|
if (options.customInstallDir?.trim()) {
|
|
30387
31406
|
const customRoot = options.customInstallDir.trim();
|
|
30388
31407
|
const versionMatch = /memoq[-_\s]?(\d+)/iu.exec(basename(customRoot));
|
|
30389
|
-
candidates.push({ version: versionMatch?.[1] ?? "custom", rootDir: customRoot });
|
|
31408
|
+
candidates.push({ version: versionMatch?.[1] ?? "custom", rootDir: customRoot, source: "custom" });
|
|
30390
31409
|
}
|
|
30391
|
-
|
|
30392
|
-
|
|
31410
|
+
if (options.defaultRoots !== void 0) {
|
|
31411
|
+
for (const item of options.defaultRoots) {
|
|
31412
|
+
candidates.push({ ...item, source: "default" });
|
|
31413
|
+
}
|
|
31414
|
+
} else {
|
|
31415
|
+
if (platform === "win32" && options.skipHostDiscovery !== true) {
|
|
31416
|
+
let helperPath = options.helperExecutablePath ?? null;
|
|
31417
|
+
if (!helperPath) {
|
|
31418
|
+
try {
|
|
31419
|
+
helperPath = ensureRunnableHelperBinary({
|
|
31420
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31421
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot }
|
|
31422
|
+
});
|
|
31423
|
+
} catch {
|
|
31424
|
+
helperPath = null;
|
|
31425
|
+
}
|
|
31426
|
+
}
|
|
31427
|
+
for (const discovered of discoverWindowsMemoQRoots(helperPath)) {
|
|
31428
|
+
candidates.push({
|
|
31429
|
+
version: discovered.version,
|
|
31430
|
+
rootDir: discovered.rootDir,
|
|
31431
|
+
source: discovered.source
|
|
31432
|
+
});
|
|
31433
|
+
}
|
|
31434
|
+
}
|
|
31435
|
+
for (const item of defaultMemoQRooDirs()) {
|
|
31436
|
+
candidates.push({ ...item, source: "default" });
|
|
31437
|
+
}
|
|
30393
31438
|
}
|
|
30394
31439
|
const installations = [];
|
|
30395
31440
|
for (const candidate of candidates) {
|
|
@@ -30404,7 +31449,7 @@ function detectMemoQInstallations(options = {}) {
|
|
|
30404
31449
|
const legacyPluginInstalled = existsSync5(legacyTarget);
|
|
30405
31450
|
const pluginSha256 = pluginInstalled ? computeFileSha256(pluginTarget) : "";
|
|
30406
31451
|
const sha256MatchesExpected = Boolean(
|
|
30407
|
-
pluginInstalled && (options.expectedSha256
|
|
31452
|
+
pluginInstalled && matchesAcceptedSha256(pluginSha256, options.expectedSha256)
|
|
30408
31453
|
);
|
|
30409
31454
|
let status = "not_installed";
|
|
30410
31455
|
if (pluginInstalled && clientDevConfig.loadUnsignedPluginsEnabled && !legacyPluginInstalled) {
|
|
@@ -30422,7 +31467,8 @@ function detectMemoQInstallations(options = {}) {
|
|
|
30422
31467
|
pluginSha256,
|
|
30423
31468
|
sha256MatchesExpected,
|
|
30424
31469
|
legacyPluginInstalled,
|
|
30425
|
-
status
|
|
31470
|
+
status,
|
|
31471
|
+
...candidate.source === void 0 ? {} : { discoverySource: candidate.source }
|
|
30426
31472
|
});
|
|
30427
31473
|
}
|
|
30428
31474
|
return { clientDevConfig, installations };
|
|
@@ -30564,13 +31610,243 @@ async function uninstallPluginWithHelper(options) {
|
|
|
30564
31610
|
}
|
|
30565
31611
|
return result;
|
|
30566
31612
|
}
|
|
31613
|
+
function buildPluginInstallPlan(options = {}) {
|
|
31614
|
+
const integration = getIntegrationStatus(options);
|
|
31615
|
+
const platform = integration.platform;
|
|
31616
|
+
const acceptedShas = acceptedPluginSha256s(options.expectedSha256);
|
|
31617
|
+
const expectedSha256 = acceptedShas[0] ?? integration.expectedPluginSha256;
|
|
31618
|
+
const effectiveProgramData = options.programDataDir ?? process.env.ProgramData ?? "C:\\ProgramData";
|
|
31619
|
+
const extraFilePaths = integration.installations.filter((item) => item.pluginInstalled).map((item) => item.pluginTarget);
|
|
31620
|
+
const discoveredDlls = discoverLocalPluginDllCandidates({
|
|
31621
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31622
|
+
...options.dllPath === void 0 ? {} : { dllPath: options.dllPath },
|
|
31623
|
+
...options.expectedSha256 === void 0 ? {} : { expectedSha256: options.expectedSha256 },
|
|
31624
|
+
...options.searchDirs === void 0 ? {} : { searchDirs: options.searchDirs },
|
|
31625
|
+
extraFilePaths,
|
|
31626
|
+
includeDefaultUserDirs: options.includeDefaultUserDirs ?? options.skipHostDiscovery !== true
|
|
31627
|
+
});
|
|
31628
|
+
const explicitDllPath = (options.dllPath ?? process.env.MEMOQ_PLUGIN_DLL_PATH ?? "").trim();
|
|
31629
|
+
const explicitResolved = explicitDllPath ? resolve4(explicitDllPath) : "";
|
|
31630
|
+
const explicitCandidate = explicitResolved ? discoveredDlls.find(
|
|
31631
|
+
(c) => (process.platform === "win32" ? c.path.toLowerCase() === explicitResolved.toLowerCase() : c.path === explicitResolved) || c.source === "explicit"
|
|
31632
|
+
) ?? null : null;
|
|
31633
|
+
const selectedDllCandidate = explicitDllPath ? explicitCandidate : discoveredDlls.find((c) => c.sha256MatchesExpected) ?? discoveredDlls.find((c) => c.kind === "zip" && c.sha256 === "") ?? null;
|
|
31634
|
+
const blockers = [];
|
|
31635
|
+
if (platform !== "win32") {
|
|
31636
|
+
blockers.push(`\u5F53\u524D\u7CFB\u7EDF (${platform}) \u4E0D\u652F\u6301\u5B89\u88C5 memoQ Desktop Windows \u63D2\u4EF6\u3002`);
|
|
31637
|
+
}
|
|
31638
|
+
if (options.customInstallDir?.trim()) {
|
|
31639
|
+
const customAddins = join6(options.customInstallDir.trim(), "Addins");
|
|
31640
|
+
if (!existsSync5(customAddins)) {
|
|
31641
|
+
blockers.push(`\u6307\u5B9A\u7684 memoQ \u76EE\u5F55\u4E0B\u672A\u627E\u5230 Addins \u5B50\u76EE\u5F55: ${customAddins}`);
|
|
31642
|
+
}
|
|
31643
|
+
}
|
|
31644
|
+
if (platform === "win32" && integration.installations.length === 0) {
|
|
31645
|
+
blockers.push(
|
|
31646
|
+
"\u672A\u68C0\u6D4B\u5230 memoQ \u5B89\u88C5\u76EE\u5F55\uFF08\u5DF2\u68C0\u67E5\u8FD0\u884C\u4E2D\u8FDB\u7A0B\u3001\u6CE8\u518C\u8868\u3001\u672C\u5730\u78C1\u76D8\u53CA\u9ED8\u8BA4\u8DEF\u5F84\uFF09\u3002\u8BF7\u63D0\u4F9B customInstallDir \u6216 memoqRoot\u3002"
|
|
31647
|
+
);
|
|
31648
|
+
}
|
|
31649
|
+
if (explicitDllPath) {
|
|
31650
|
+
if (!existsSync5(explicitResolved)) {
|
|
31651
|
+
blockers.push(`\u6307\u5B9A\u7684 DLL / ZIP \u8DEF\u5F84\u4E0D\u5B58\u5728: ${explicitResolved}`);
|
|
31652
|
+
} else if (!explicitCandidate) {
|
|
31653
|
+
blockers.push(`\u6307\u5B9A\u6587\u4EF6\u4E0D\u662F\u6709\u6548\u7684 ${PLUGIN_DLL_NAME} \u6216\u5305\u542B\u8BE5 DLL \u7684 ZIP \u5305: ${explicitResolved}`);
|
|
31654
|
+
} else if (!options.allowUnverifiedLocalDev && explicitCandidate.kind === "dll" && !explicitCandidate.sha256MatchesExpected) {
|
|
31655
|
+
blockers.push(
|
|
31656
|
+
`\u6307\u5B9A DLL \u7684 SHA-256 (${explicitCandidate.sha256}) \u4E0E\u9884\u671F (${acceptedShas.join(" or ")}) \u4E0D\u5339\u914D\u3002`
|
|
31657
|
+
);
|
|
31658
|
+
}
|
|
31659
|
+
} else if (!selectedDllCandidate && options.allowDownload === false) {
|
|
31660
|
+
blockers.push(
|
|
31661
|
+
`\u672C\u673A\u672A\u627E\u5230\u53EF\u7528\u7684 ${PLUGIN_DLL_NAME} \u4E14\u7981\u7528\u4E86\u5728\u7EBF\u4E0B\u8F7D\uFF08\u671F\u671B SHA-256: ${expectedSha256}\uFF09\u3002\u8BF7\u63D0\u4F9B\u672C\u5730 DLL/ZIP \u7684 dllPath\u3002`
|
|
31662
|
+
);
|
|
31663
|
+
}
|
|
31664
|
+
let recommendedInst = null;
|
|
31665
|
+
if (options.customInstallDir?.trim()) {
|
|
31666
|
+
const normCustom = options.customInstallDir.trim().toLowerCase();
|
|
31667
|
+
recommendedInst = integration.installations.find((item) => item.rootDir.toLowerCase() === normCustom) ?? null;
|
|
31668
|
+
}
|
|
31669
|
+
if (!recommendedInst) {
|
|
31670
|
+
recommendedInst = integration.installations.find((item) => item.status === "not_installed" || item.status === "needs_repair") ?? integration.installations[0] ?? null;
|
|
31671
|
+
}
|
|
31672
|
+
const recommendedMemoqRoot = recommendedInst?.rootDir ?? null;
|
|
31673
|
+
const targetDllPath = recommendedInst?.pluginTarget ?? null;
|
|
31674
|
+
const clientDevConfigAction = !integration.clientDevConfig.exists ? "create_new" : integration.clientDevConfig.loadUnsignedPluginsEnabled ? "already_enabled" : "backup_and_merge";
|
|
31675
|
+
const requiresElevation = Boolean(
|
|
31676
|
+
platform === "win32" && recommendedMemoqRoot && isProtectedWindowsPath(recommendedMemoqRoot, effectiveProgramData)
|
|
31677
|
+
);
|
|
31678
|
+
const willDownloadFromRelease = !selectedDllCandidate && !explicitDllPath;
|
|
31679
|
+
return {
|
|
31680
|
+
platform,
|
|
31681
|
+
operation: "copy",
|
|
31682
|
+
preservesOriginalSource: true,
|
|
31683
|
+
readyToInstall: blockers.length === 0 && Boolean(recommendedMemoqRoot),
|
|
31684
|
+
alreadyInstalled: integration.status === "installed",
|
|
31685
|
+
canReuseExisting: integration.canReuseExisting,
|
|
31686
|
+
blockers,
|
|
31687
|
+
expectedPluginDllName: integration.expectedPluginDllName,
|
|
31688
|
+
expectedPluginVersion: integration.expectedPluginVersion,
|
|
31689
|
+
expectedSha256,
|
|
31690
|
+
acceptedSha256s: acceptedShas,
|
|
31691
|
+
recommendedMemoqRoot,
|
|
31692
|
+
installations: integration.installations,
|
|
31693
|
+
discoveredDlls,
|
|
31694
|
+
selectedDllCandidate,
|
|
31695
|
+
willDownloadFromRelease,
|
|
31696
|
+
downloadUrl: DEFAULT_PLUGIN_DLL_MANIFEST.downloadUrl,
|
|
31697
|
+
plannedChanges: {
|
|
31698
|
+
sourceDllPath: selectedDllCandidate?.path ?? null,
|
|
31699
|
+
sourceKind: selectedDllCandidate ? selectedDllCandidate.kind : "release-download",
|
|
31700
|
+
targetDllPath,
|
|
31701
|
+
clientDevConfigPath: integration.clientDevConfig.path,
|
|
31702
|
+
clientDevConfigAction,
|
|
31703
|
+
removesLegacyDll: Boolean(recommendedInst?.legacyPluginInstalled),
|
|
31704
|
+
removesMotw: true,
|
|
31705
|
+
requiresElevation,
|
|
31706
|
+
expectedSha256: selectedDllCandidate?.sha256 || expectedSha256
|
|
31707
|
+
}
|
|
31708
|
+
};
|
|
31709
|
+
}
|
|
31710
|
+
async function executeConfirmedPluginInstall(options = {}) {
|
|
31711
|
+
if (options.confirmed !== true) {
|
|
31712
|
+
throw new Error(
|
|
31713
|
+
"Confirmation required: present plannedChanges to the user and pass confirmed: true after explicit approval."
|
|
31714
|
+
);
|
|
31715
|
+
}
|
|
31716
|
+
const integrationBefore = getIntegrationStatus({
|
|
31717
|
+
...options,
|
|
31718
|
+
...options.memoqRoot?.trim() && !options.customInstallDir?.trim() ? { customInstallDir: options.memoqRoot.trim() } : {}
|
|
31719
|
+
});
|
|
31720
|
+
if (integrationBefore.platform !== "win32") {
|
|
31721
|
+
throw new Error(`memoQ plugin installation is only supported on Windows (current: ${integrationBefore.platform}).`);
|
|
31722
|
+
}
|
|
31723
|
+
let targetRoot = options.memoqRoot?.trim() || options.customInstallDir?.trim() || "";
|
|
31724
|
+
if (targetRoot) {
|
|
31725
|
+
const addins = join6(targetRoot, "Addins");
|
|
31726
|
+
if (!existsSync5(addins)) {
|
|
31727
|
+
throw new Error(`memoQ Addins directory was not found: ${addins}`);
|
|
31728
|
+
}
|
|
31729
|
+
} else if (integrationBefore.installations.length === 1) {
|
|
31730
|
+
targetRoot = integrationBefore.installations[0].rootDir;
|
|
31731
|
+
} else if (integrationBefore.installations.length > 1) {
|
|
31732
|
+
throw new Error(
|
|
31733
|
+
`Detected multiple memoQ installations (${integrationBefore.installations.map((i) => i.rootDir).join(", ")}). Please specify memoqRoot explicitly.`
|
|
31734
|
+
);
|
|
31735
|
+
} else {
|
|
31736
|
+
throw new Error("No memoQ installation directory was found (not_found). Please provide memoqRoot.");
|
|
31737
|
+
}
|
|
31738
|
+
const siblingDllPaths = integrationBefore.installations.filter((item) => item.pluginInstalled).map((item) => item.pluginTarget);
|
|
31739
|
+
const sourceAsset = await resolvePluginDllAsset({
|
|
31740
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31741
|
+
...options.dllPath === void 0 ? {} : { dllPath: options.dllPath },
|
|
31742
|
+
...options.downloadUrl === void 0 ? {} : { downloadUrl: options.downloadUrl },
|
|
31743
|
+
...options.expectedSha256 === void 0 ? {} : { expectedSha256: options.expectedSha256 },
|
|
31744
|
+
...options.allowDownload === void 0 ? {} : { allowDownload: options.allowDownload },
|
|
31745
|
+
...options.allowUnverifiedLocalDev === void 0 ? {} : { allowUnverifiedLocalDev: options.allowUnverifiedLocalDev },
|
|
31746
|
+
searchPaths: siblingDllPaths,
|
|
31747
|
+
...options.searchDirs === void 0 ? {} : { searchDirs: options.searchDirs },
|
|
31748
|
+
includeDefaultUserDirs: options.includeDefaultUserDirs ?? options.skipHostDiscovery !== true
|
|
31749
|
+
});
|
|
31750
|
+
const effectiveProgramData = options.programDataDir ?? process.env.ProgramData ?? "C:\\ProgramData";
|
|
31751
|
+
const shouldElevate = options.elevate ?? isProtectedWindowsPath(targetRoot, effectiveProgramData);
|
|
31752
|
+
const baseInstallParams = {
|
|
31753
|
+
memoqRoot: targetRoot,
|
|
31754
|
+
dllSource: sourceAsset.path,
|
|
31755
|
+
dllSha256: sourceAsset.sha256,
|
|
31756
|
+
programDataDir: effectiveProgramData,
|
|
31757
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31758
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
31759
|
+
...options.helperExecutablePath === void 0 ? {} : { helperExecutablePath: options.helperExecutablePath }
|
|
31760
|
+
};
|
|
31761
|
+
let result;
|
|
31762
|
+
try {
|
|
31763
|
+
result = await installPluginWithHelper({
|
|
31764
|
+
...baseInstallParams,
|
|
31765
|
+
elevate: shouldElevate
|
|
31766
|
+
});
|
|
31767
|
+
} catch (error2) {
|
|
31768
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
31769
|
+
if (options.elevate === void 0 && !shouldElevate && /access|denied|unauthorized|permission/iu.test(message)) {
|
|
31770
|
+
result = await installPluginWithHelper({
|
|
31771
|
+
...baseInstallParams,
|
|
31772
|
+
elevate: true
|
|
31773
|
+
});
|
|
31774
|
+
} else {
|
|
31775
|
+
throw error2;
|
|
31776
|
+
}
|
|
31777
|
+
}
|
|
31778
|
+
const integrationAfter = getIntegrationStatus({
|
|
31779
|
+
...options,
|
|
31780
|
+
customInstallDir: targetRoot
|
|
31781
|
+
});
|
|
31782
|
+
return {
|
|
31783
|
+
ok: true,
|
|
31784
|
+
operation: "copy",
|
|
31785
|
+
preservesOriginalSource: true,
|
|
31786
|
+
sourceAsset,
|
|
31787
|
+
result,
|
|
31788
|
+
integration: integrationAfter,
|
|
31789
|
+
nextSteps: [
|
|
31790
|
+
"\u5B8C\u5168\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8 memoQ\uFF08memoQ \u4EC5\u5728\u542F\u52A8\u65F6\u626B\u63CF Addins \u76EE\u5F55\uFF09\u3002",
|
|
31791
|
+
"\u5728 memoQ \u4E2D\u6253\u5F00 Options \u2192 Default resources \u2192 MT settings\uFF0C\u52FE\u9009\u542F\u7528 memoQ AI Hub\uFF08\u7AEF\u53E3\u4FDD\u6301 5271\uFF09\u3002"
|
|
31792
|
+
]
|
|
31793
|
+
};
|
|
31794
|
+
}
|
|
31795
|
+
async function executeConfirmedPluginUninstall(options = {}) {
|
|
31796
|
+
if (options.confirmed !== true) {
|
|
31797
|
+
throw new Error(
|
|
31798
|
+
"Confirmation required: pass confirmed: true after explicit user approval to uninstall the memoQ plugin."
|
|
31799
|
+
);
|
|
31800
|
+
}
|
|
31801
|
+
const integrationBefore = getIntegrationStatus({
|
|
31802
|
+
...options,
|
|
31803
|
+
...options.memoqRoot?.trim() && !options.customInstallDir?.trim() ? { customInstallDir: options.memoqRoot.trim() } : {}
|
|
31804
|
+
});
|
|
31805
|
+
if (integrationBefore.platform !== "win32") {
|
|
31806
|
+
throw new Error(`memoQ plugin uninstallation is only supported on Windows (current: ${integrationBefore.platform}).`);
|
|
31807
|
+
}
|
|
31808
|
+
let targetRoot = options.memoqRoot?.trim() || options.customInstallDir?.trim() || "";
|
|
31809
|
+
if (!targetRoot) {
|
|
31810
|
+
const installedRoots = integrationBefore.installations.filter((item) => item.pluginInstalled);
|
|
31811
|
+
if (installedRoots.length === 1) {
|
|
31812
|
+
targetRoot = installedRoots[0].rootDir;
|
|
31813
|
+
} else if (integrationBefore.installations.length === 1) {
|
|
31814
|
+
targetRoot = integrationBefore.installations[0].rootDir;
|
|
31815
|
+
} else if (installedRoots.length > 1) {
|
|
31816
|
+
throw new Error(
|
|
31817
|
+
`Detected multiple installed memoQ copies (${installedRoots.map((i) => i.rootDir).join(", ")}). Please specify memoqRoot explicitly.`
|
|
31818
|
+
);
|
|
31819
|
+
} else {
|
|
31820
|
+
throw new Error("No memoQ installation directory was found (not_found). Please provide memoqRoot.");
|
|
31821
|
+
}
|
|
31822
|
+
}
|
|
31823
|
+
const effectiveProgramData = options.programDataDir ?? process.env.ProgramData ?? "C:\\ProgramData";
|
|
31824
|
+
const shouldElevate = options.elevate ?? isProtectedWindowsPath(targetRoot, effectiveProgramData);
|
|
31825
|
+
const result = await uninstallPluginWithHelper({
|
|
31826
|
+
memoqRoot: targetRoot,
|
|
31827
|
+
programDataDir: effectiveProgramData,
|
|
31828
|
+
elevate: shouldElevate,
|
|
31829
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31830
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
31831
|
+
...options.helperExecutablePath === void 0 ? {} : { helperExecutablePath: options.helperExecutablePath }
|
|
31832
|
+
});
|
|
31833
|
+
const integrationAfter = getIntegrationStatus({
|
|
31834
|
+
...options,
|
|
31835
|
+
customInstallDir: targetRoot
|
|
31836
|
+
});
|
|
31837
|
+
return {
|
|
31838
|
+
ok: true,
|
|
31839
|
+
result,
|
|
31840
|
+
integration: integrationAfter
|
|
31841
|
+
};
|
|
31842
|
+
}
|
|
30567
31843
|
|
|
30568
31844
|
// packages/memoq-bridge/src/setup-page.ts
|
|
30569
31845
|
import { spawn as spawn2 } from "node:child_process";
|
|
30570
31846
|
import { randomBytes as randomBytes3, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
30571
31847
|
import { existsSync as existsSync7, mkdirSync as mkdirSync5 } from "node:fs";
|
|
30572
31848
|
import { createServer as createServer2 } from "node:http";
|
|
30573
|
-
import { dirname as
|
|
31849
|
+
import { dirname as dirname5 } from "node:path";
|
|
30574
31850
|
|
|
30575
31851
|
// packages/memoq-bridge/src/daemon.ts
|
|
30576
31852
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -30964,6 +32240,11 @@ function renderSetupHtml(nonce, token, initialStatus) {
|
|
|
30964
32240
|
<label for="custom-dir" style="font-size: 13px; color: var(--muted);">\u6216\u8F93\u5165\u81EA\u5B9A\u4E49 memoQ \u6839\u76EE\u5F55\uFF08\u5305\u542B Addins \u5B50\u76EE\u5F55\uFF09\uFF1A</label>
|
|
30965
32241
|
<input id="custom-dir" type="text" placeholder="\u4F8B\u5982 C:\\Program Files\\memoQ\\memoQ-12" />
|
|
30966
32242
|
</div>
|
|
32243
|
+
<div style="margin-top: 10px;">
|
|
32244
|
+
<label for="custom-dll" style="font-size: 13px; color: var(--muted);">\u53EF\u9009\uFF1A\u6307\u5B9A\u672C\u5730 DLL \u6216 ZIP \u8DEF\u5F84\uFF08\u7559\u7A7A\u5219\u81EA\u52A8\u67E5\u627E\u6216\u4ECE Release \u4E0B\u8F7D\uFF09\uFF1A</label>
|
|
32245
|
+
<input id="custom-dll" type="text" placeholder="\u4F8B\u5982 C:\\Users\\...\\Downloads\\MemoQ.AI.Hub.Plugin.dll" />
|
|
32246
|
+
<div id="discovered-dlls" style="font-size: 12px; color: var(--muted); margin-top: 6px;"></div>
|
|
32247
|
+
</div>
|
|
30967
32248
|
</section>
|
|
30968
32249
|
|
|
30969
32250
|
<section class="card">
|
|
@@ -31053,6 +32334,25 @@ function renderSetupHtml(nonce, token, initialStatus) {
|
|
|
31053
32334
|
el.addEventListener("change", function (ev) { selectedRoot = ev.target.value; });
|
|
31054
32335
|
});
|
|
31055
32336
|
}
|
|
32337
|
+
|
|
32338
|
+
const dllsEl = document.getElementById("discovered-dlls");
|
|
32339
|
+
const dllList = state.discoveredDlls || [];
|
|
32340
|
+
if (dllsEl) {
|
|
32341
|
+
if (!dllList.length) {
|
|
32342
|
+
dllsEl.textContent = "\u672A\u5728\u672C\u673A\u5E38\u7528\u76EE\u5F55\u9884\u53D1\u73B0 DLL\uFF1B\u70B9\u51FB\u5B89\u88C5\u65F6\u5C06\u6309\u9700\u4ECE\u5B89\u5168 Release \u62C9\u53D6\u5E76\u6821\u9A8C SHA-256\u3002";
|
|
32343
|
+
} else {
|
|
32344
|
+
dllsEl.innerHTML = "\u672C\u673A\u5DF2\u53D1\u73B0\u53EF\u7528\u5305\uFF08\u70B9\u51FB\u53EF\u586B\u5165\u8DEF\u5F84\uFF09\uFF1A" + dllList.slice(0, 4).map(function (c, i) {
|
|
32345
|
+
const ok = c.sha256MatchesExpected ? "\u2705" : "\u26A0\uFE0F";
|
|
32346
|
+
return '<button type="button" class="pick-dll" data-idx="' + i + '" style="margin:4px 6px 0 0;padding:3px 8px;font-size:12px;">' + ok + " " + c.path.replace(/</g, "<") + "</button>";
|
|
32347
|
+
}).join("");
|
|
32348
|
+
dllsEl.querySelectorAll(".pick-dll").forEach(function (btn) {
|
|
32349
|
+
btn.addEventListener("click", function () {
|
|
32350
|
+
const item = dllList[Number(btn.getAttribute("data-idx"))];
|
|
32351
|
+
if (item) document.getElementById("custom-dll").value = item.path;
|
|
32352
|
+
});
|
|
32353
|
+
});
|
|
32354
|
+
}
|
|
32355
|
+
}
|
|
31056
32356
|
}
|
|
31057
32357
|
|
|
31058
32358
|
function showMessage(text, isError) {
|
|
@@ -31096,11 +32396,13 @@ function renderSetupHtml(nonce, token, initialStatus) {
|
|
|
31096
32396
|
document.getElementById("btn-install").addEventListener("click", async function () {
|
|
31097
32397
|
const root = effectiveRoot();
|
|
31098
32398
|
if (!root) { showMessage("\u8BF7\u5148\u9009\u62E9\u6216\u8F93\u5165 memoQ \u5B89\u88C5\u76EE\u5F55\u3002", true); return; }
|
|
32399
|
+
const dllPath = (document.getElementById("custom-dll").value || "").trim();
|
|
31099
32400
|
const btn = document.getElementById("btn-install");
|
|
31100
32401
|
btn.disabled = true;
|
|
31101
32402
|
showMessage("\u6B63\u5728\u51C6\u5907 DLL \u5E76\u7B49\u5F85\u7CFB\u7EDF UAC \u786E\u8BA4\u2026", false);
|
|
31102
32403
|
try {
|
|
31103
|
-
const
|
|
32404
|
+
const payload = dllPath ? { memoqRoot: root, dllPath: dllPath } : { memoqRoot: root };
|
|
32405
|
+
const res = await api("/api/install", "POST", payload);
|
|
31104
32406
|
render(res.status);
|
|
31105
32407
|
showMessage("\u5B89\u88C5\u6210\u529F\uFF01DLL \u6821\u9A8C\u503C " + res.result.dllSha256 + "\u3002\u8BF7\u91CD\u542F memoQ \u5E76\u5728 MT settings \u4E2D\u542F\u7528\u3002", false);
|
|
31106
32408
|
} catch (e) { showMessage("\u5B89\u88C5\u5931\u8D25\uFF1A" + e.message, true); }
|
|
@@ -31147,7 +32449,13 @@ async function startSetupServer(options = {}) {
|
|
|
31147
32449
|
Promise.resolve(getIntegrationStatus(detectOpts)),
|
|
31148
32450
|
probeGateway(gatewayPort)
|
|
31149
32451
|
]);
|
|
31150
|
-
|
|
32452
|
+
const discoveredDlls = discoverLocalPluginDllCandidates({
|
|
32453
|
+
dataDir,
|
|
32454
|
+
...options.detectOptions?.expectedSha256 === void 0 ? {} : { expectedSha256: options.detectOptions.expectedSha256 },
|
|
32455
|
+
extraFilePaths: integration.installations.filter((i) => i.pluginInstalled).map((i) => i.pluginTarget),
|
|
32456
|
+
includeDefaultUserDirs: options.detectOptions?.skipHostDiscovery ? false : true
|
|
32457
|
+
});
|
|
32458
|
+
return { integration, gateway, discoveredDlls };
|
|
31151
32459
|
}
|
|
31152
32460
|
let idleTimer;
|
|
31153
32461
|
const server = createServer2((request, response) => {
|
|
@@ -31188,12 +32496,14 @@ async function startSetupServer(options = {}) {
|
|
|
31188
32496
|
const body = await readJson(request);
|
|
31189
32497
|
if (url.pathname === "/api/install") {
|
|
31190
32498
|
const memoqRoot = String(body.memoqRoot ?? "").trim();
|
|
32499
|
+
const dllPath = typeof body.dllPath === "string" ? body.dllPath.trim() : "";
|
|
31191
32500
|
if (!memoqRoot) {
|
|
31192
32501
|
sendJson2(response, 400, { error: "memoqRoot \u4E0D\u80FD\u4E3A\u7A7A\u3002" });
|
|
31193
32502
|
return;
|
|
31194
32503
|
}
|
|
31195
32504
|
const resolvedAsset = await resolveDll({
|
|
31196
32505
|
dataDir,
|
|
32506
|
+
...dllPath ? { dllPath } : {},
|
|
31197
32507
|
...options.allowDownload === void 0 ? {} : { allowDownload: options.allowDownload },
|
|
31198
32508
|
...options.detectOptions?.expectedSha256 === void 0 ? {} : { expectedSha256: options.detectOptions.expectedSha256 }
|
|
31199
32509
|
});
|
|
@@ -31232,7 +32542,7 @@ async function startSetupServer(options = {}) {
|
|
|
31232
32542
|
return;
|
|
31233
32543
|
}
|
|
31234
32544
|
if (url.pathname === "/api/open-asset-dir") {
|
|
31235
|
-
const dir =
|
|
32545
|
+
const dir = dirname5(getPluginAssetCachePath(dataDir, DEFAULT_PLUGIN_DLL_MANIFEST.version));
|
|
31236
32546
|
mkdirSync5(dir, { recursive: true });
|
|
31237
32547
|
if (options.allowOpenFolder !== false && process.platform === "win32" && existsSync7(dir)) {
|
|
31238
32548
|
const child = spawn2("explorer.exe", [dir], { detached: true, windowsHide: true, stdio: "ignore" });
|
|
@@ -31246,14 +32556,14 @@ async function startSetupServer(options = {}) {
|
|
|
31246
32556
|
sendJson2(response, 500, { error: error2 instanceof Error ? error2.message : String(error2) });
|
|
31247
32557
|
});
|
|
31248
32558
|
});
|
|
31249
|
-
await new Promise((
|
|
32559
|
+
await new Promise((resolve7, reject) => {
|
|
31250
32560
|
const onError = (error2) => {
|
|
31251
32561
|
server.off("listening", onListening);
|
|
31252
32562
|
reject(error2);
|
|
31253
32563
|
};
|
|
31254
32564
|
const onListening = () => {
|
|
31255
32565
|
server.off("error", onError);
|
|
31256
|
-
|
|
32566
|
+
resolve7();
|
|
31257
32567
|
};
|
|
31258
32568
|
server.once("error", onError);
|
|
31259
32569
|
server.once("listening", onListening);
|
|
@@ -31266,11 +32576,11 @@ async function startSetupServer(options = {}) {
|
|
|
31266
32576
|
actualPort = addr.port;
|
|
31267
32577
|
expectedHost = `${host}:${actualPort}`;
|
|
31268
32578
|
expectedOrigin = `http://${expectedHost}`;
|
|
31269
|
-
const close = () => new Promise((
|
|
32579
|
+
const close = () => new Promise((resolve7) => {
|
|
31270
32580
|
clearTimeout(idleTimer);
|
|
31271
32581
|
server.close(() => {
|
|
31272
32582
|
options.onClose?.();
|
|
31273
|
-
|
|
32583
|
+
resolve7();
|
|
31274
32584
|
});
|
|
31275
32585
|
});
|
|
31276
32586
|
idleTimer = setTimeout(() => {
|
|
@@ -31290,8 +32600,8 @@ async function startSetupServer(options = {}) {
|
|
|
31290
32600
|
|
|
31291
32601
|
// packages/memoq-mcp/src/config.ts
|
|
31292
32602
|
import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
31293
|
-
import { homedir as
|
|
31294
|
-
import { dirname as
|
|
32603
|
+
import { homedir as homedir3 } from "node:os";
|
|
32604
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
31295
32605
|
var SERVER_NAME = "memoq";
|
|
31296
32606
|
var PACKAGE = "@langlink/memoq-mcp";
|
|
31297
32607
|
function packageSpec(updateMode, version2) {
|
|
@@ -31315,7 +32625,7 @@ function json(value) {
|
|
|
31315
32625
|
return `${JSON.stringify(value, null, 2)}
|
|
31316
32626
|
`;
|
|
31317
32627
|
}
|
|
31318
|
-
function clientRecipe(client, home =
|
|
32628
|
+
function clientRecipe(client, home = homedir3(), updateMode = "latest", version2) {
|
|
31319
32629
|
const withUpdate = { updateMode };
|
|
31320
32630
|
switch (client) {
|
|
31321
32631
|
case "codex":
|
|
@@ -31419,7 +32729,7 @@ async function mergeJson(recipe, target) {
|
|
|
31419
32729
|
}
|
|
31420
32730
|
throw new Error(`refusing to rewrite existing non-JSON config: ${target}`);
|
|
31421
32731
|
}
|
|
31422
|
-
await mkdir(
|
|
32732
|
+
await mkdir(dirname6(target), { recursive: true });
|
|
31423
32733
|
await writeFile(target, recipe.content, "utf8");
|
|
31424
32734
|
return { client: recipe.client, path: target, action: "created" };
|
|
31425
32735
|
}
|
|
@@ -31434,7 +32744,7 @@ async function writeRecipe(recipe) {
|
|
|
31434
32744
|
} catch (error2) {
|
|
31435
32745
|
if (error2.code !== "ENOENT") throw error2;
|
|
31436
32746
|
}
|
|
31437
|
-
await mkdir(
|
|
32747
|
+
await mkdir(dirname6(recipe.path), { recursive: true });
|
|
31438
32748
|
await writeFile(recipe.path, recipe.content, "utf8");
|
|
31439
32749
|
return { client: recipe.client, path: recipe.path, action: "created" };
|
|
31440
32750
|
}
|
|
@@ -31445,7 +32755,7 @@ async function writeRecipe(recipe) {
|
|
|
31445
32755
|
import { execFile as execFile2, spawn as spawn3 } from "node:child_process";
|
|
31446
32756
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
31447
32757
|
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
31448
|
-
import { dirname as
|
|
32758
|
+
import { dirname as dirname7, join as join9, resolve as resolve5 } from "node:path";
|
|
31449
32759
|
import { promisify as promisify2 } from "node:util";
|
|
31450
32760
|
var execFileAsync2 = promisify2(execFile2);
|
|
31451
32761
|
var MEMOQ_BRIDGE_DAEMON_FLAG = "--memoq-bridge-daemon";
|
|
@@ -31487,7 +32797,7 @@ async function trySpawnViaWindowsWmi(entrypoint, workerArgs, dataDir) {
|
|
|
31487
32797
|
if (process.platform !== "win32") return false;
|
|
31488
32798
|
const helperPath = ensureRunnableHelperBinary({
|
|
31489
32799
|
dataDir,
|
|
31490
|
-
packageRoot:
|
|
32800
|
+
packageRoot: resolve5(dirname7(entrypoint), "..")
|
|
31491
32801
|
});
|
|
31492
32802
|
if (!helperPath) return false;
|
|
31493
32803
|
const specFile = join9(dataDir, `launch-${randomUUID6()}.json`);
|
|
@@ -31498,7 +32808,7 @@ async function trySpawnViaWindowsWmi(entrypoint, workerArgs, dataDir) {
|
|
|
31498
32808
|
JSON.stringify({
|
|
31499
32809
|
executable: process.execPath,
|
|
31500
32810
|
args: workerArgs,
|
|
31501
|
-
workingDirectory:
|
|
32811
|
+
workingDirectory: dirname7(entrypoint)
|
|
31502
32812
|
}),
|
|
31503
32813
|
"utf8"
|
|
31504
32814
|
);
|
|
@@ -31523,7 +32833,7 @@ function spawnViaNodeDetached(entrypoint, workerArgs, dataDir) {
|
|
|
31523
32833
|
detached: true,
|
|
31524
32834
|
windowsHide: true,
|
|
31525
32835
|
stdio: "ignore",
|
|
31526
|
-
cwd:
|
|
32836
|
+
cwd: dirname7(entrypoint),
|
|
31527
32837
|
env: { ...process.env, MEMOQ_BRIDGE_DATA_DIR: dataDir }
|
|
31528
32838
|
});
|
|
31529
32839
|
child.unref();
|
|
@@ -31720,10 +33030,10 @@ function textResult(value) {
|
|
|
31720
33030
|
};
|
|
31721
33031
|
}
|
|
31722
33032
|
function createMemoqMcpServer(options = {}) {
|
|
31723
|
-
const server = new McpServer({ name: "langlink-memoq", version: "0.2.
|
|
31724
|
-
const here =
|
|
33033
|
+
const server = new McpServer({ name: "langlink-memoq", version: "0.2.3" });
|
|
33034
|
+
const here = dirname8(fileURLToPath2(import.meta.url));
|
|
31725
33035
|
const entrypoint = fileURLToPath2(import.meta.url);
|
|
31726
|
-
const packageRoot =
|
|
33036
|
+
const packageRoot = resolve6(here, "..");
|
|
31727
33037
|
let clientPromise;
|
|
31728
33038
|
const resolveClient = async () => {
|
|
31729
33039
|
if (options.bridgeClient) return options.bridgeClient;
|
|
@@ -32061,25 +33371,100 @@ function createMemoqMcpServer(options = {}) {
|
|
|
32061
33371
|
server.registerTool(
|
|
32062
33372
|
"memoq_setup",
|
|
32063
33373
|
{
|
|
32064
|
-
description: "
|
|
33374
|
+
description: "Auto-discover memoQ Desktop installations and local MemoQ.AI.Hub.Plugin.dll / .zip packages (action='plan', read-only), present exact copy targets & SHA-256 for user confirmation, and execute verified helper copy + ClientDevConfig.xml merge once confirmed=true (with local visual wizard fallback).",
|
|
32065
33375
|
inputSchema: {
|
|
32066
|
-
|
|
33376
|
+
action: _enum(["plan", "install", "uninstall"]).optional(),
|
|
33377
|
+
customInstallDir: string2().optional(),
|
|
33378
|
+
memoqRoot: string2().optional(),
|
|
33379
|
+
dllPath: string2().optional(),
|
|
33380
|
+
searchDirs: array(string2()).max(20).optional(),
|
|
33381
|
+
confirmed: boolean2().optional(),
|
|
33382
|
+
openWizard: boolean2().optional()
|
|
32067
33383
|
}
|
|
32068
33384
|
},
|
|
32069
|
-
async ({ customInstallDir }) => {
|
|
33385
|
+
async ({ action, customInstallDir, memoqRoot, dllPath, searchDirs, confirmed, openWizard }) => {
|
|
33386
|
+
const effectiveAction = action ?? "plan";
|
|
33387
|
+
const targetCustomDir = customInstallDir ?? memoqRoot;
|
|
33388
|
+
const planFn = options.buildInstallPlan ?? buildPluginInstallPlan;
|
|
33389
|
+
const installFn = options.installPlugin ?? executeConfirmedPluginInstall;
|
|
33390
|
+
const uninstallFn = options.uninstallPlugin ?? executeConfirmedPluginUninstall;
|
|
33391
|
+
if (effectiveAction === "install") {
|
|
33392
|
+
if (confirmed !== true) {
|
|
33393
|
+
const plan2 = planFn({
|
|
33394
|
+
packageRoot,
|
|
33395
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33396
|
+
...targetCustomDir === void 0 ? {} : { customInstallDir: targetCustomDir },
|
|
33397
|
+
...dllPath === void 0 ? {} : { dllPath },
|
|
33398
|
+
...searchDirs === void 0 ? {} : { searchDirs }
|
|
33399
|
+
});
|
|
33400
|
+
return textResult({
|
|
33401
|
+
action: "install",
|
|
33402
|
+
installed: false,
|
|
33403
|
+
confirmationRequired: true,
|
|
33404
|
+
plan: plan2,
|
|
33405
|
+
error: "\u5FC5\u987B\u5148\u5411\u7528\u6237\u5C55\u793A\u62DF\u53D8\u66F4\u6E05\u5355\uFF08plan.plannedChanges\uFF1A\u6E90 DLL\u3001\u76EE\u6807 Addins \u590D\u5236\u8DEF\u5F84\u3001ClientDevConfig.xml \u53CA\u662F\u5426\u89E6\u53D1 UAC\uFF09\uFF0C\u5E76\u5728\u7528\u6237\u660E\u786E\u786E\u8BA4\u540E\u518D\u4F20 confirmed: true \u6267\u884C\u5B89\u88C5\u3002"
|
|
33406
|
+
});
|
|
33407
|
+
}
|
|
33408
|
+
const installResult = await installFn({
|
|
33409
|
+
packageRoot,
|
|
33410
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33411
|
+
...customInstallDir === void 0 ? {} : { customInstallDir },
|
|
33412
|
+
...memoqRoot === void 0 ? {} : { memoqRoot },
|
|
33413
|
+
...dllPath === void 0 ? {} : { dllPath },
|
|
33414
|
+
...searchDirs === void 0 ? {} : { searchDirs },
|
|
33415
|
+
confirmed: true
|
|
33416
|
+
});
|
|
33417
|
+
return textResult({
|
|
33418
|
+
action: "install",
|
|
33419
|
+
installed: true,
|
|
33420
|
+
...installResult
|
|
33421
|
+
});
|
|
33422
|
+
}
|
|
33423
|
+
if (effectiveAction === "uninstall") {
|
|
33424
|
+
if (confirmed !== true) {
|
|
33425
|
+
return textResult({
|
|
33426
|
+
action: "uninstall",
|
|
33427
|
+
uninstalled: false,
|
|
33428
|
+
confirmationRequired: true,
|
|
33429
|
+
error: "\u5FC5\u987B\u5148\u83B7\u7528\u6237\u660E\u786E\u786E\u8BA4\u540E\u518D\u4F20 confirmed: true \u624D\u80FD\u5378\u8F7D memoQ \u63D2\u4EF6\u3002"
|
|
33430
|
+
});
|
|
33431
|
+
}
|
|
33432
|
+
const uninstallResult = await uninstallFn({
|
|
33433
|
+
packageRoot,
|
|
33434
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33435
|
+
...customInstallDir === void 0 ? {} : { customInstallDir },
|
|
33436
|
+
...memoqRoot === void 0 ? {} : { memoqRoot },
|
|
33437
|
+
confirmed: true
|
|
33438
|
+
});
|
|
33439
|
+
return textResult({
|
|
33440
|
+
action: "uninstall",
|
|
33441
|
+
uninstalled: true,
|
|
33442
|
+
...uninstallResult
|
|
33443
|
+
});
|
|
33444
|
+
}
|
|
32070
33445
|
const integration = getIntegrationStatus({
|
|
32071
33446
|
packageRoot,
|
|
32072
33447
|
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
32073
|
-
...
|
|
33448
|
+
...targetCustomDir === void 0 ? {} : { customInstallDir: targetCustomDir }
|
|
33449
|
+
});
|
|
33450
|
+
const plan = planFn({
|
|
33451
|
+
packageRoot,
|
|
33452
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33453
|
+
...targetCustomDir === void 0 ? {} : { customInstallDir: targetCustomDir },
|
|
33454
|
+
...dllPath === void 0 ? {} : { dllPath },
|
|
33455
|
+
...searchDirs === void 0 ? {} : { searchDirs }
|
|
32074
33456
|
});
|
|
32075
33457
|
const probe = await probeGatewayPort(Number(process.env.MEMOQ_BRIDGE_PORT || DEFAULT_PORT));
|
|
32076
|
-
const url = await launchSetup();
|
|
33458
|
+
const url = openWizard === false ? "" : await launchSetup();
|
|
32077
33459
|
return textResult({
|
|
32078
|
-
|
|
32079
|
-
link: `[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})
|
|
33460
|
+
action: "plan",
|
|
33461
|
+
...url ? { url, link: `[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` } : {},
|
|
32080
33462
|
integration,
|
|
33463
|
+
plan,
|
|
32081
33464
|
gateway: probe,
|
|
32082
|
-
|
|
33465
|
+
confirmationRequired: true,
|
|
33466
|
+
nextStep: integration.canReuseExisting ? "\u68C0\u6D4B\u5230\u5DF2\u5B89\u88C5\u7684\u517C\u5BB9\u63D2\u4EF6\u53EF\u76F4\u63A5\u590D\u7528\u3002\u5982\u9700\u4FEE\u590D\u6216\u5B89\u88C5\u5230\u5176\u4ED6\u7248\u672C\uFF0C\u8BF7\u5411\u7528\u6237\u5C55\u793A plan.plannedChanges \u5E76\u83B7\u660E\u786E\u786E\u8BA4\u540E\u8C03\u7528 memoq_setup({ action: 'install', confirmed: true, memoqRoot, dllPath })\u3002" : plan.readyToInstall ? "\u5DF2\u5B9A\u4F4D\u76EE\u6807 memoQ \u76EE\u5F55\u4E0E\u6E90 DLL\u3002\u8BF7\u5148\u5728\u5BF9\u8BDD\u4E2D\u5217\u51FA plan.plannedChanges\uFF08\u6E90\u8DEF\u5F84\u3001\u590D\u5236\u76EE\u6807\u8DEF\u5F84\u3001SHA-256\u3001ClientDevConfig.xml \u5907\u4EFD\u5408\u5E76\u8BA1\u5212\u3001\u662F\u5426\u5F39 UAC\uFF09\uFF0C\u7B49\u7528\u6237\u786E\u8BA4\u540E\u518D\u8C03\u7528 memoq_setup({ action: 'install', confirmed: true, memoqRoot: plan.recommendedMemoqRoot, dllPath: plan.plannedChanges.sourceDllPath })\u3002" : `\u5C1A\u672A\u5C31\u7EEA\uFF1A${plan.blockers.join("\uFF1B")}\u3002\u8BF7\u5411\u7528\u6237\u786E\u8BA4 memoQ \u76EE\u5F55 (customInstallDir) \u6216\u672C\u5730 DLL/ZIP \u8DEF\u5F84 (dllPath)\uFF0C\u6216\u4F7F\u7528\u672C\u5730\u53EF\u89C6\u5316\u5411\u5BFC\u3002`,
|
|
33467
|
+
message: integration.canReuseExisting ? `\u68C0\u6D4B\u5230\u5DF2\u5B89\u88C5\u7684 memoQ \u63D2\u4EF6\u53EF\u76F4\u63A5\u590D\u7528\u3002${url ? `\u5982\u9700\u67E5\u770B\u8BE6\u60C5\u6216\u4FEE\u590D\uFF0C\u8BF7\u6253\u5F00\uFF1A[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` : ""}` : plan.readyToInstall ? `\u5DF2\u627E\u5230\u5B89\u88C5\u8DEF\u5F84\u4E0E\u63D2\u4EF6\u6587\u4EF6\uFF08\u5C06\u590D\u5236\u5E76\u4FDD\u7559\u539F\u4EF6\uFF09\u3002\u8BF7\u5728\u4E0E\u7528\u6237\u786E\u8BA4\u5177\u4F53\u53D8\u66F4\u8DEF\u5F84\u540E\u8C03\u7528 memoq_setup({ action: "install", confirmed: true, ... }) \u5B8C\u6210\u5B89\u88C5${url ? `\uFF0C\u6216\u6253\u5F00\u53EF\u89C6\u5316\u5411\u5BFC\uFF1A[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` : ""}\u3002` : `\u8BF7\u5728\u6D4F\u89C8\u5668\u4E2D\u6253\u5F00\u672C\u5730\u8BBE\u7F6E\u5411\u5BFC\u67E5\u770B\u5C06\u8981\u5199\u5165\u7684 2 \u4E2A\u8DEF\u5F84\u5E76\u70B9\u51FB\u5B89\u88C5${url ? `\uFF1A[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` : ""}`
|
|
32083
33468
|
});
|
|
32084
33469
|
}
|
|
32085
33470
|
);
|