@langlink/memoq-mcp 0.2.2 → 0.2.4
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 +1885 -409
- 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
|
}
|
|
@@ -23595,7 +23595,8 @@ var CONTROL_ROUTES = {
|
|
|
23595
23595
|
liveConfig: "/bridge/live-config",
|
|
23596
23596
|
qaCatalog: "/bridge/qa/catalog",
|
|
23597
23597
|
qaRun: "/bridge/qa/run",
|
|
23598
|
-
reviewUrl: "/bridge/review-url"
|
|
23598
|
+
reviewUrl: "/bridge/review-url",
|
|
23599
|
+
shutdown: "/bridge/shutdown"
|
|
23599
23600
|
};
|
|
23600
23601
|
var ERROR_CODES = {
|
|
23601
23602
|
contractVersionMismatch: "CONTRACT_VERSION_MISMATCH",
|
|
@@ -24378,18 +24379,18 @@ function createPreviewClient(options = {}) {
|
|
|
24378
24379
|
}
|
|
24379
24380
|
const id = randomUUID();
|
|
24380
24381
|
const message = JSON.stringify({ ...payload, id }) + "\n";
|
|
24381
|
-
return new Promise((
|
|
24382
|
+
return new Promise((resolve7) => {
|
|
24382
24383
|
const timer = setTimeout(() => {
|
|
24383
24384
|
pendingAcks.delete(id);
|
|
24384
|
-
|
|
24385
|
+
resolve7({ ok: false, error: `Preview helper command timed out (${String(payload.type ?? "unknown")}).` });
|
|
24385
24386
|
}, timeoutMs);
|
|
24386
|
-
pendingAcks.set(id, { resolve:
|
|
24387
|
+
pendingAcks.set(id, { resolve: resolve7, timer });
|
|
24387
24388
|
try {
|
|
24388
24389
|
child.stdin.write(message, "utf8");
|
|
24389
24390
|
} catch (error2) {
|
|
24390
24391
|
clearTimeout(timer);
|
|
24391
24392
|
pendingAcks.delete(id);
|
|
24392
|
-
|
|
24393
|
+
resolve7({ ok: false, error: error2 instanceof Error ? error2.message : String(error2) });
|
|
24393
24394
|
}
|
|
24394
24395
|
});
|
|
24395
24396
|
}
|
|
@@ -24527,9 +24528,9 @@ function createPreviewClient(options = {}) {
|
|
|
24527
24528
|
const settleMs = Math.max(0, Math.min(500, query.settleMs ?? 80));
|
|
24528
24529
|
if (settleMs > 0 && lastEventAtMs > 0 && Date.now() - lastEventAtMs < settleMs) {
|
|
24529
24530
|
const firstRev = revision;
|
|
24530
|
-
await new Promise((
|
|
24531
|
+
await new Promise((resolve7) => setTimeout(resolve7, settleMs));
|
|
24531
24532
|
if (revision !== firstRev) {
|
|
24532
|
-
await new Promise((
|
|
24533
|
+
await new Promise((resolve7) => setTimeout(resolve7, settleMs));
|
|
24533
24534
|
}
|
|
24534
24535
|
}
|
|
24535
24536
|
const doc = resolveDocument();
|
|
@@ -28039,17 +28040,23 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28039
28040
|
<head>
|
|
28040
28041
|
<meta charset="utf-8" />
|
|
28041
28042
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
28042
|
-
<title>LangLink memoQ \u53CC\u8BED\u5BA1\u6821\u4E0E QA \u5DE5\u4F5C\u53F0</title>
|
|
28043
|
+
<title>LangLink memoQ CAT \u53CC\u8BED\u5BA1\u6821\u4E0E QA \u5DE5\u4F5C\u53F0</title>
|
|
28043
28044
|
<style>
|
|
28044
28045
|
:root {
|
|
28045
28046
|
color-scheme: light dark;
|
|
28046
|
-
--bg: #
|
|
28047
|
-
--
|
|
28047
|
+
--bg: #eef2f6;
|
|
28048
|
+
--panel: #ffffff;
|
|
28048
28049
|
--subtle: #f8fafc;
|
|
28049
|
-
--
|
|
28050
|
-
--
|
|
28051
|
-
--
|
|
28050
|
+
--grid-head: #f1f5f9;
|
|
28051
|
+
--row-hover: #f8fafc;
|
|
28052
|
+
--row-active: #eff6ff;
|
|
28053
|
+
--text: #0f172a;
|
|
28054
|
+
--muted: #475569;
|
|
28055
|
+
--faint: #64748b;
|
|
28056
|
+
--border: #cbd5e1;
|
|
28057
|
+
--border-soft: #e2e8f0;
|
|
28052
28058
|
--accent: #1d4ed8;
|
|
28059
|
+
--accent-solid: #2563eb;
|
|
28053
28060
|
--accent-soft: #dbeafe;
|
|
28054
28061
|
--ok: #15803d;
|
|
28055
28062
|
--ok-soft: #dcfce7;
|
|
@@ -28059,16 +28066,25 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28059
28066
|
--err-soft: #fee2e2;
|
|
28060
28067
|
--rev: #6d28d9;
|
|
28061
28068
|
--rev-soft: #ede9fe;
|
|
28069
|
+
--tag-bg: #e0f2fe;
|
|
28070
|
+
--tag-fg: #0369a1;
|
|
28071
|
+
--tag-border: #bae6fd;
|
|
28062
28072
|
}
|
|
28063
28073
|
@media (prefers-color-scheme: dark) {
|
|
28064
28074
|
:root {
|
|
28065
|
-
--bg: #
|
|
28066
|
-
--
|
|
28075
|
+
--bg: #0b1120;
|
|
28076
|
+
--panel: #111827;
|
|
28067
28077
|
--subtle: #0f172a;
|
|
28078
|
+
--grid-head: #1e293b;
|
|
28079
|
+
--row-hover: #172033;
|
|
28080
|
+
--row-active: #172554;
|
|
28068
28081
|
--text: #f1f5f9;
|
|
28069
28082
|
--muted: #94a3b8;
|
|
28083
|
+
--faint: #64748b;
|
|
28070
28084
|
--border: #334155;
|
|
28085
|
+
--border-soft: #1e293b;
|
|
28071
28086
|
--accent: #60a5fa;
|
|
28087
|
+
--accent-solid: #3b82f6;
|
|
28072
28088
|
--accent-soft: #1e3a8a;
|
|
28073
28089
|
--ok: #4ade80;
|
|
28074
28090
|
--ok-soft: #14532d;
|
|
@@ -28078,253 +28094,634 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28078
28094
|
--err-soft: #450a0a;
|
|
28079
28095
|
--rev: #c4b5fd;
|
|
28080
28096
|
--rev-soft: #2e1065;
|
|
28097
|
+
--tag-bg: #0c4a6e;
|
|
28098
|
+
--tag-fg: #7dd3fc;
|
|
28099
|
+
--tag-border: #0369a1;
|
|
28081
28100
|
}
|
|
28082
28101
|
}
|
|
28083
28102
|
* { box-sizing: border-box; }
|
|
28103
|
+
html, body { height: 100%; margin: 0; }
|
|
28084
28104
|
body {
|
|
28085
|
-
margin: 0;
|
|
28086
|
-
padding: 16px;
|
|
28087
28105
|
background: var(--bg);
|
|
28088
28106
|
color: var(--text);
|
|
28089
|
-
font:
|
|
28107
|
+
font: 13px/1.45 "Segoe UI", -apple-system, BlinkMacSystemFont, "Microsoft YaHei UI", sans-serif;
|
|
28108
|
+
display: flex;
|
|
28109
|
+
flex-direction: column;
|
|
28110
|
+
overflow: hidden;
|
|
28111
|
+
}
|
|
28112
|
+
.hidden { display: none !important; }
|
|
28113
|
+
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; }
|
|
28114
|
+
|
|
28115
|
+
/* Top CAT Ribbon */
|
|
28116
|
+
.cat-ribbon {
|
|
28117
|
+
flex-shrink: 0;
|
|
28118
|
+
min-height: 46px;
|
|
28119
|
+
background: var(--panel);
|
|
28120
|
+
border-bottom: 1px solid var(--border);
|
|
28121
|
+
padding: 6px 12px;
|
|
28122
|
+
display: flex;
|
|
28123
|
+
flex-wrap: wrap;
|
|
28124
|
+
align-items: center;
|
|
28125
|
+
justify-content: space-between;
|
|
28126
|
+
gap: 8px;
|
|
28127
|
+
}
|
|
28128
|
+
.ribbon-left, .ribbon-right {
|
|
28129
|
+
display: flex;
|
|
28130
|
+
flex-wrap: wrap;
|
|
28131
|
+
align-items: center;
|
|
28132
|
+
gap: 8px;
|
|
28133
|
+
min-width: 0;
|
|
28134
|
+
}
|
|
28135
|
+
.brand-chip {
|
|
28136
|
+
display: inline-flex;
|
|
28137
|
+
align-items: center;
|
|
28138
|
+
gap: 6px;
|
|
28139
|
+
font-weight: 700;
|
|
28140
|
+
font-size: 13px;
|
|
28141
|
+
letter-spacing: -0.01em;
|
|
28142
|
+
}
|
|
28143
|
+
.brand-badge {
|
|
28144
|
+
background: var(--accent-solid);
|
|
28145
|
+
color: #ffffff;
|
|
28146
|
+
border-radius: 5px;
|
|
28147
|
+
padding: 2px 6px;
|
|
28148
|
+
font-size: 11px;
|
|
28149
|
+
font-weight: 700;
|
|
28090
28150
|
}
|
|
28091
|
-
.
|
|
28092
|
-
|
|
28093
|
-
|
|
28151
|
+
.doc-title {
|
|
28152
|
+
margin: 0;
|
|
28153
|
+
font-size: 13px;
|
|
28154
|
+
font-weight: 600;
|
|
28155
|
+
max-width: 240px;
|
|
28156
|
+
white-space: nowrap;
|
|
28157
|
+
overflow: hidden;
|
|
28158
|
+
text-overflow: ellipsis;
|
|
28159
|
+
}
|
|
28160
|
+
.doc-select {
|
|
28161
|
+
max-width: 280px;
|
|
28162
|
+
height: 28px;
|
|
28163
|
+
padding: 2px 8px;
|
|
28094
28164
|
border: 1px solid var(--border);
|
|
28095
|
-
border-radius:
|
|
28096
|
-
|
|
28165
|
+
border-radius: 6px;
|
|
28166
|
+
background: var(--subtle);
|
|
28167
|
+
color: var(--text);
|
|
28168
|
+
font-size: 12px;
|
|
28097
28169
|
}
|
|
28098
|
-
|
|
28170
|
+
|
|
28171
|
+
/* Sub-toolbar */
|
|
28172
|
+
.cat-subbar {
|
|
28173
|
+
flex-shrink: 0;
|
|
28174
|
+
min-height: 38px;
|
|
28175
|
+
background: var(--panel);
|
|
28176
|
+
border-bottom: 1px solid var(--border);
|
|
28177
|
+
padding: 4px 12px;
|
|
28099
28178
|
display: flex;
|
|
28100
28179
|
flex-wrap: wrap;
|
|
28101
28180
|
align-items: center;
|
|
28102
28181
|
justify-content: space-between;
|
|
28103
|
-
gap:
|
|
28182
|
+
gap: 8px;
|
|
28104
28183
|
}
|
|
28105
|
-
.
|
|
28106
|
-
.
|
|
28107
|
-
|
|
28108
|
-
|
|
28109
|
-
|
|
28110
|
-
padding:
|
|
28111
|
-
border:
|
|
28184
|
+
.tabs { display: flex; gap: 4px; align-items: center; }
|
|
28185
|
+
.tab-btn {
|
|
28186
|
+
border: 1px solid transparent;
|
|
28187
|
+
background: transparent;
|
|
28188
|
+
color: var(--muted);
|
|
28189
|
+
padding: 4px 10px;
|
|
28190
|
+
border-radius: 5px;
|
|
28191
|
+
font-size: 12px;
|
|
28192
|
+
font-weight: 600;
|
|
28193
|
+
cursor: pointer;
|
|
28112
28194
|
}
|
|
28113
|
-
.
|
|
28114
|
-
|
|
28115
|
-
|
|
28116
|
-
|
|
28117
|
-
|
|
28118
|
-
.
|
|
28119
|
-
.
|
|
28195
|
+
.tab-btn.active {
|
|
28196
|
+
background: var(--accent-soft);
|
|
28197
|
+
color: var(--accent);
|
|
28198
|
+
border-color: var(--accent);
|
|
28199
|
+
}
|
|
28200
|
+
.v-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }
|
|
28201
|
+
.filter-pills { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
|
|
28202
|
+
.filter-pill {
|
|
28203
|
+
padding: 3px 9px;
|
|
28204
|
+
border-radius: 999px;
|
|
28205
|
+
font-size: 11px;
|
|
28206
|
+
font-weight: 500;
|
|
28207
|
+
border: 1px solid var(--border);
|
|
28208
|
+
background: var(--subtle);
|
|
28209
|
+
color: var(--text);
|
|
28210
|
+
cursor: pointer;
|
|
28211
|
+
}
|
|
28212
|
+
.filter-pill.active {
|
|
28213
|
+
background: var(--accent-solid);
|
|
28214
|
+
color: #ffffff;
|
|
28215
|
+
border-color: var(--accent-solid);
|
|
28216
|
+
}
|
|
28217
|
+
.search-wrap { display: flex; align-items: center; gap: 8px; }
|
|
28218
|
+
.kbd-hint { font-size: 11px; color: var(--faint); white-space: nowrap; }
|
|
28219
|
+
|
|
28220
|
+
/* Buttons & Inputs */
|
|
28120
28221
|
button {
|
|
28121
28222
|
cursor: pointer;
|
|
28122
|
-
border-radius:
|
|
28223
|
+
border-radius: 6px;
|
|
28123
28224
|
border: 1px solid var(--border);
|
|
28124
|
-
background: var(--
|
|
28225
|
+
background: var(--panel);
|
|
28125
28226
|
color: var(--text);
|
|
28126
|
-
padding:
|
|
28227
|
+
padding: 4px 10px;
|
|
28127
28228
|
font: inherit;
|
|
28128
|
-
font-size:
|
|
28229
|
+
font-size: 12px;
|
|
28129
28230
|
font-weight: 600;
|
|
28231
|
+
line-height: 1.35;
|
|
28130
28232
|
}
|
|
28131
|
-
button:hover {
|
|
28132
|
-
button.primary { background: var(--accent); color: #ffffff; border-color: var(--accent); }
|
|
28233
|
+
button:hover { border-color: var(--accent); }
|
|
28234
|
+
button.primary { background: var(--accent-solid); color: #ffffff; border-color: var(--accent-solid); }
|
|
28133
28235
|
button.success { background: #15803d; color: #ffffff; border-color: #15803d; }
|
|
28134
28236
|
button.warn { background: #b45309; color: #ffffff; border-color: #b45309; }
|
|
28135
|
-
button.sm { padding:
|
|
28237
|
+
button.sm { padding: 3px 7px; font-size: 11px; }
|
|
28238
|
+
button.active-toggle { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
|
|
28136
28239
|
button:disabled { opacity: 0.5; cursor: not-allowed; }
|
|
28137
|
-
|
|
28240
|
+
input[type="text"], textarea, select {
|
|
28241
|
+
border: 1px solid var(--border);
|
|
28242
|
+
background: var(--subtle);
|
|
28243
|
+
color: var(--text);
|
|
28244
|
+
border-radius: 5px;
|
|
28245
|
+
padding: 4px 8px;
|
|
28246
|
+
font: inherit;
|
|
28247
|
+
font-size: 12px;
|
|
28248
|
+
}
|
|
28249
|
+
|
|
28250
|
+
/* Pills */
|
|
28251
|
+
.pill {
|
|
28252
|
+
display: inline-flex;
|
|
28253
|
+
align-items: center;
|
|
28254
|
+
gap: 4px;
|
|
28255
|
+
padding: 2px 8px;
|
|
28256
|
+
border-radius: 999px;
|
|
28257
|
+
font-size: 11px;
|
|
28258
|
+
font-weight: 600;
|
|
28259
|
+
border: 1px solid var(--border);
|
|
28260
|
+
background: var(--subtle);
|
|
28261
|
+
white-space: nowrap;
|
|
28262
|
+
}
|
|
28263
|
+
.pill.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
|
|
28264
|
+
.pill.warn { color: var(--warn); background: var(--warn-soft); border-color: transparent; }
|
|
28265
|
+
.pill.err { color: var(--err); background: var(--err-soft); border-color: transparent; }
|
|
28266
|
+
.pill.rev { color: var(--rev); background: var(--rev-soft); border-color: transparent; }
|
|
28267
|
+
.pill.info { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
|
|
28268
|
+
|
|
28269
|
+
/* Collapsible QA Config & Banners */
|
|
28270
|
+
.qa-panel {
|
|
28271
|
+
flex-shrink: 0;
|
|
28272
|
+
background: var(--subtle);
|
|
28273
|
+
border-bottom: 1px solid var(--border);
|
|
28138
28274
|
padding: 10px 14px;
|
|
28139
|
-
|
|
28140
|
-
|
|
28275
|
+
max-height: 280px;
|
|
28276
|
+
overflow-y: auto;
|
|
28277
|
+
}
|
|
28278
|
+
.rule-grid {
|
|
28279
|
+
display: grid;
|
|
28280
|
+
grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
|
|
28281
|
+
gap: 4px 10px;
|
|
28282
|
+
margin-top: 6px;
|
|
28283
|
+
}
|
|
28284
|
+
.rule-item { display: flex; gap: 6px; align-items: flex-start; font-size: 11px; }
|
|
28285
|
+
.box-label { font-size: 11px; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
|
|
28286
|
+
.banner {
|
|
28287
|
+
flex-shrink: 0;
|
|
28288
|
+
padding: 6px 14px;
|
|
28289
|
+
font-size: 12px;
|
|
28290
|
+
border-bottom: 1px solid var(--border);
|
|
28141
28291
|
display: flex;
|
|
28142
28292
|
flex-wrap: wrap;
|
|
28143
28293
|
align-items: center;
|
|
28144
28294
|
justify-content: space-between;
|
|
28145
|
-
gap:
|
|
28295
|
+
gap: 8px;
|
|
28146
28296
|
}
|
|
28147
28297
|
.banner.ok { background: var(--ok-soft); color: var(--ok); }
|
|
28148
28298
|
.banner.warn { background: var(--warn-soft); color: var(--warn); }
|
|
28149
28299
|
.banner.err { background: var(--err-soft); color: var(--err); }
|
|
28150
28300
|
.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;
|
|
28301
|
+
|
|
28302
|
+
/* Main Split CAT Workspace */
|
|
28303
|
+
.cat-workspace {
|
|
28304
|
+
flex: 1;
|
|
28305
|
+
min-height: 0;
|
|
28306
|
+
display: grid;
|
|
28307
|
+
grid-template-columns: minmax(0, 1fr) 336px;
|
|
28308
|
+
background: var(--bg);
|
|
28167
28309
|
}
|
|
28168
|
-
|
|
28169
|
-
|
|
28170
|
-
|
|
28171
|
-
|
|
28172
|
-
|
|
28173
|
-
|
|
28174
|
-
background: var(--card);
|
|
28310
|
+
.cat-workspace.inspector-collapsed {
|
|
28311
|
+
grid-template-columns: minmax(0, 1fr);
|
|
28312
|
+
}
|
|
28313
|
+
.cat-main {
|
|
28314
|
+
min-width: 0;
|
|
28315
|
+
min-height: 0;
|
|
28175
28316
|
display: flex;
|
|
28176
28317
|
flex-direction: column;
|
|
28177
|
-
|
|
28318
|
+
background: var(--panel);
|
|
28319
|
+
overflow: hidden;
|
|
28320
|
+
}
|
|
28321
|
+
.cat-grid-scroll {
|
|
28322
|
+
flex: 1;
|
|
28323
|
+
min-height: 0;
|
|
28324
|
+
overflow: auto;
|
|
28325
|
+
scrollbar-gutter: stable;
|
|
28326
|
+
}
|
|
28327
|
+
|
|
28328
|
+
/* Classic 4-column CAT Bilingual Grid */
|
|
28329
|
+
.cat-grid-head, .cat-row {
|
|
28330
|
+
display: grid;
|
|
28331
|
+
grid-template-columns: 60px minmax(0, 1fr) minmax(0, 1fr) 128px;
|
|
28332
|
+
align-items: stretch;
|
|
28333
|
+
}
|
|
28334
|
+
.cat-grid-head {
|
|
28335
|
+
position: sticky;
|
|
28336
|
+
top: 0;
|
|
28337
|
+
z-index: 3;
|
|
28338
|
+
background: var(--grid-head);
|
|
28339
|
+
border-bottom: 1px solid var(--border);
|
|
28340
|
+
font-size: 11px;
|
|
28341
|
+
font-weight: 700;
|
|
28342
|
+
color: var(--muted);
|
|
28343
|
+
text-transform: uppercase;
|
|
28344
|
+
letter-spacing: 0.02em;
|
|
28345
|
+
}
|
|
28346
|
+
.cat-grid-head > div {
|
|
28347
|
+
padding: 7px 10px;
|
|
28348
|
+
}
|
|
28349
|
+
.cat-grid-head > div:nth-child(3),
|
|
28350
|
+
.cat-grid-head > div:nth-child(4) {
|
|
28351
|
+
border-left: 1px solid var(--border-soft);
|
|
28352
|
+
}
|
|
28353
|
+
|
|
28354
|
+
.cat-row {
|
|
28355
|
+
border-bottom: 1px solid var(--border-soft);
|
|
28356
|
+
background: var(--panel);
|
|
28357
|
+
transition: background 120ms ease;
|
|
28358
|
+
}
|
|
28359
|
+
.cat-row:hover { background: var(--row-hover); }
|
|
28360
|
+
.cat-row.active-row {
|
|
28361
|
+
background: var(--row-active);
|
|
28362
|
+
}
|
|
28363
|
+
.cat-rail {
|
|
28364
|
+
padding: 9px 6px;
|
|
28365
|
+
display: flex;
|
|
28366
|
+
flex-direction: column;
|
|
28367
|
+
align-items: center;
|
|
28368
|
+
gap: 4px;
|
|
28369
|
+
border-left: 3px solid transparent;
|
|
28370
|
+
color: var(--muted);
|
|
28371
|
+
font-variant-numeric: tabular-nums;
|
|
28372
|
+
font-size: 11px;
|
|
28373
|
+
user-select: none;
|
|
28374
|
+
}
|
|
28375
|
+
.cat-row.st-approved .cat-rail { border-left-color: var(--ok); }
|
|
28376
|
+
.cat-row.st-draft .cat-rail { border-left-color: var(--warn); }
|
|
28377
|
+
.cat-row.st-needs_revision .cat-rail { border-left-color: var(--rev); }
|
|
28378
|
+
.cat-row.st-memoq .cat-rail { border-left-color: var(--border); }
|
|
28379
|
+
.cat-row.active-row .cat-rail { border-left-color: var(--accent-solid); }
|
|
28380
|
+
|
|
28381
|
+
.doc-chip {
|
|
28382
|
+
font-size: 10px;
|
|
28383
|
+
padding: 1px 4px;
|
|
28384
|
+
border-radius: 3px;
|
|
28385
|
+
background: var(--accent-soft);
|
|
28386
|
+
color: var(--accent);
|
|
28387
|
+
max-width: 50px;
|
|
28388
|
+
overflow: hidden;
|
|
28389
|
+
text-overflow: ellipsis;
|
|
28390
|
+
white-space: nowrap;
|
|
28391
|
+
}
|
|
28392
|
+
.cat-source {
|
|
28393
|
+
min-width: 0;
|
|
28394
|
+
padding: 9px 12px;
|
|
28395
|
+
border-left: 1px solid var(--border-soft);
|
|
28396
|
+
display: flex;
|
|
28397
|
+
flex-direction: column;
|
|
28398
|
+
gap: 6px;
|
|
28178
28399
|
}
|
|
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 {
|
|
28400
|
+
.src-text {
|
|
28185
28401
|
white-space: pre-wrap;
|
|
28186
28402
|
word-break: break-word;
|
|
28187
|
-
background: var(--subtle);
|
|
28188
|
-
border: 1px solid var(--border);
|
|
28189
|
-
border-radius: 6px;
|
|
28190
|
-
padding: 8px 10px;
|
|
28191
28403
|
font-size: 13px;
|
|
28404
|
+
line-height: 1.65;
|
|
28405
|
+
color: var(--text);
|
|
28406
|
+
}
|
|
28407
|
+
.cat-tag {
|
|
28408
|
+
display: inline-block;
|
|
28409
|
+
margin: 0 1px;
|
|
28410
|
+
padding: 0 4px;
|
|
28411
|
+
border-radius: 3px;
|
|
28412
|
+
font-family: ui-monospace, Consolas, monospace;
|
|
28413
|
+
font-size: 11px;
|
|
28414
|
+
line-height: 1.4;
|
|
28415
|
+
background: var(--tag-bg);
|
|
28416
|
+
color: var(--tag-fg);
|
|
28417
|
+
border: 1px solid var(--tag-border);
|
|
28418
|
+
vertical-align: baseline;
|
|
28419
|
+
}
|
|
28420
|
+
.cat-target {
|
|
28421
|
+
min-width: 0;
|
|
28422
|
+
padding: 7px 10px;
|
|
28423
|
+
border-left: 1px solid var(--border-soft);
|
|
28424
|
+
display: flex;
|
|
28425
|
+
flex-direction: column;
|
|
28426
|
+
gap: 4px;
|
|
28427
|
+
}
|
|
28428
|
+
.tgt-edit {
|
|
28429
|
+
width: 100%;
|
|
28192
28430
|
min-height: 44px;
|
|
28431
|
+
padding: 5px 7px;
|
|
28432
|
+
border: 1px solid transparent;
|
|
28433
|
+
border-radius: 5px;
|
|
28434
|
+
background: transparent;
|
|
28435
|
+
color: var(--text);
|
|
28436
|
+
font: 13px/1.65 "Segoe UI", -apple-system, BlinkMacSystemFont, "Microsoft YaHei UI", sans-serif;
|
|
28437
|
+
resize: vertical;
|
|
28438
|
+
outline: none;
|
|
28439
|
+
}
|
|
28440
|
+
.cat-row:hover .tgt-edit { border-color: var(--border-soft); background: var(--panel); }
|
|
28441
|
+
.tgt-edit:focus {
|
|
28442
|
+
border-color: var(--accent-solid);
|
|
28443
|
+
background: var(--panel);
|
|
28444
|
+
box-shadow: 0 0 0 2px var(--accent-soft);
|
|
28445
|
+
}
|
|
28446
|
+
.memoq-ref-line {
|
|
28447
|
+
font-size: 11px;
|
|
28448
|
+
color: var(--muted);
|
|
28449
|
+
padding: 3px 6px;
|
|
28450
|
+
border-left: 2px solid var(--border);
|
|
28451
|
+
background: var(--subtle);
|
|
28452
|
+
white-space: pre-wrap;
|
|
28453
|
+
word-break: break-word;
|
|
28454
|
+
}
|
|
28455
|
+
.cmt-chip {
|
|
28456
|
+
font-size: 11px;
|
|
28457
|
+
color: var(--rev);
|
|
28458
|
+
background: var(--rev-soft);
|
|
28459
|
+
padding: 2px 7px;
|
|
28460
|
+
border-radius: 4px;
|
|
28461
|
+
width: fit-content;
|
|
28462
|
+
max-width: 100%;
|
|
28463
|
+
word-break: break-word;
|
|
28464
|
+
}
|
|
28465
|
+
.dirty-tag {
|
|
28466
|
+
display: inline-block;
|
|
28467
|
+
font-size: 10px;
|
|
28468
|
+
color: var(--warn);
|
|
28469
|
+
font-weight: 600;
|
|
28193
28470
|
}
|
|
28194
|
-
|
|
28195
|
-
|
|
28196
|
-
padding:
|
|
28197
|
-
border-left:
|
|
28471
|
+
|
|
28472
|
+
.cat-status {
|
|
28473
|
+
padding: 8px 8px;
|
|
28474
|
+
border-left: 1px solid var(--border-soft);
|
|
28475
|
+
display: flex;
|
|
28476
|
+
flex-direction: column;
|
|
28477
|
+
align-items: flex-start;
|
|
28478
|
+
gap: 5px;
|
|
28479
|
+
}
|
|
28480
|
+
.row-mini-btns {
|
|
28481
|
+
display: flex;
|
|
28482
|
+
flex-wrap: wrap;
|
|
28483
|
+
gap: 4px;
|
|
28484
|
+
}
|
|
28485
|
+
.badge-list { display: flex; flex-wrap: wrap; gap: 4px; }
|
|
28486
|
+
|
|
28487
|
+
/* Docked CAT Inspector */
|
|
28488
|
+
.cat-inspector {
|
|
28489
|
+
min-width: 0;
|
|
28490
|
+
min-height: 0;
|
|
28491
|
+
border-left: 1px solid var(--border);
|
|
28492
|
+
background: var(--panel);
|
|
28493
|
+
display: flex;
|
|
28494
|
+
flex-direction: column;
|
|
28495
|
+
overflow-y: auto;
|
|
28496
|
+
padding: 12px;
|
|
28497
|
+
gap: 12px;
|
|
28498
|
+
}
|
|
28499
|
+
.cat-workspace.inspector-collapsed .cat-inspector { display: none; }
|
|
28500
|
+
.insp-section {
|
|
28501
|
+
border: 1px solid var(--border-soft);
|
|
28502
|
+
border-radius: 7px;
|
|
28503
|
+
padding: 9px 10px;
|
|
28198
28504
|
background: var(--subtle);
|
|
28505
|
+
display: flex;
|
|
28506
|
+
flex-direction: column;
|
|
28507
|
+
gap: 6px;
|
|
28508
|
+
}
|
|
28509
|
+
.insp-title {
|
|
28510
|
+
font-size: 11px;
|
|
28511
|
+
font-weight: 700;
|
|
28512
|
+
color: var(--muted);
|
|
28513
|
+
text-transform: uppercase;
|
|
28514
|
+
letter-spacing: 0.02em;
|
|
28515
|
+
display: flex;
|
|
28516
|
+
align-items: center;
|
|
28517
|
+
justify-content: space-between;
|
|
28518
|
+
gap: 6px;
|
|
28519
|
+
}
|
|
28520
|
+
.insp-ref-text {
|
|
28199
28521
|
font-size: 12px;
|
|
28200
28522
|
white-space: pre-wrap;
|
|
28201
28523
|
word-break: break-word;
|
|
28524
|
+
line-height: 1.5;
|
|
28525
|
+
}
|
|
28526
|
+
.qa-issue-card {
|
|
28527
|
+
border: 1px solid var(--border-soft);
|
|
28528
|
+
border-radius: 6px;
|
|
28529
|
+
padding: 7px 8px;
|
|
28530
|
+
background: var(--panel);
|
|
28531
|
+
font-size: 12px;
|
|
28532
|
+
display: flex;
|
|
28533
|
+
flex-direction: column;
|
|
28534
|
+
gap: 3px;
|
|
28535
|
+
}
|
|
28536
|
+
|
|
28537
|
+
/* QA Report Tab */
|
|
28538
|
+
.qa-table { width: 100%; border-collapse: collapse; font-size: 12px; }
|
|
28539
|
+
.qa-table th, .qa-table td {
|
|
28540
|
+
border-bottom: 1px solid var(--border-soft);
|
|
28541
|
+
padding: 7px 10px;
|
|
28542
|
+
text-align: left;
|
|
28543
|
+
vertical-align: top;
|
|
28544
|
+
}
|
|
28545
|
+
.qa-table th {
|
|
28546
|
+
position: sticky;
|
|
28547
|
+
top: 0;
|
|
28548
|
+
background: var(--grid-head);
|
|
28549
|
+
font-size: 11px;
|
|
28550
|
+
color: var(--muted);
|
|
28551
|
+
border-bottom: 1px solid var(--border);
|
|
28552
|
+
}
|
|
28553
|
+
|
|
28554
|
+
/* Bottom CAT Status Bar */
|
|
28555
|
+
.cat-statusbar {
|
|
28556
|
+
flex-shrink: 0;
|
|
28557
|
+
min-height: 30px;
|
|
28558
|
+
background: var(--panel);
|
|
28559
|
+
border-top: 1px solid var(--border);
|
|
28560
|
+
padding: 4px 12px;
|
|
28561
|
+
display: flex;
|
|
28562
|
+
flex-wrap: wrap;
|
|
28563
|
+
align-items: center;
|
|
28564
|
+
justify-content: space-between;
|
|
28565
|
+
gap: 10px;
|
|
28566
|
+
font-size: 11px;
|
|
28567
|
+
color: var(--muted);
|
|
28568
|
+
}
|
|
28569
|
+
.status-group { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
|
|
28570
|
+
.progress-track {
|
|
28571
|
+
width: 110px;
|
|
28572
|
+
height: 6px;
|
|
28573
|
+
border-radius: 999px;
|
|
28574
|
+
background: var(--border-soft);
|
|
28575
|
+
overflow: hidden;
|
|
28576
|
+
display: inline-block;
|
|
28577
|
+
vertical-align: middle;
|
|
28578
|
+
}
|
|
28579
|
+
.progress-fill {
|
|
28580
|
+
height: 100%;
|
|
28581
|
+
width: 0%;
|
|
28582
|
+
background: var(--ok);
|
|
28583
|
+
transition: width 200ms ease;
|
|
28584
|
+
}
|
|
28585
|
+
.empty-state {
|
|
28586
|
+
padding: 36px 20px;
|
|
28587
|
+
text-align: center;
|
|
28588
|
+
color: var(--muted);
|
|
28589
|
+
font-size: 13px;
|
|
28590
|
+
}
|
|
28591
|
+
@media (max-width: 1024px) {
|
|
28592
|
+
.cat-workspace { grid-template-columns: minmax(0, 1fr); }
|
|
28593
|
+
.cat-inspector { display: none; }
|
|
28594
|
+
.kbd-hint { display: none; }
|
|
28202
28595
|
}
|
|
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
28596
|
</style>
|
|
28215
28597
|
</head>
|
|
28216
28598
|
<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>
|
|
28599
|
+
<header class="cat-ribbon">
|
|
28600
|
+
<div class="ribbon-left">
|
|
28601
|
+
<span class="brand-chip"><span class="brand-badge">CAT</span><span id="docTitle" class="doc-title">LangLink memoQ \u5DE5\u4F5C\u53F0</span></span>
|
|
28602
|
+
<select id="docSelector" class="doc-select" aria-label="\u6587\u6863\u5207\u6362"></select>
|
|
28603
|
+
<span id="langPair" class="pill">- \u2192 -</span>
|
|
28604
|
+
<span id="previewBadge" class="pill">Preview: \u68C0\u6D4B\u4E2D</span>
|
|
28605
|
+
<span id="docIdLine" class="mono" style="color:var(--faint);"></span>
|
|
28606
|
+
</div>
|
|
28607
|
+
<div class="ribbon-right">
|
|
28608
|
+
<button id="btnApproveAll" class="success" type="button">\u4E00\u952E\u653E\u884C\u5168\u90E8\u5B9A\u7A3F\u5230 memoQ</button>
|
|
28609
|
+
<button id="btnRevokeAll" type="button">\u64A4\u56DE\u5168\u90E8\u4E3A\u8349\u7A3F</button>
|
|
28610
|
+
<button id="btnRunQa" class="primary" type="button">\u8FD0\u884C QA \u68C0\u67E5</button>
|
|
28611
|
+
<button id="btnToggleQaCfg" type="button">QA \u53C2\u6570 \u25BE</button>
|
|
28612
|
+
<button id="btnToggleInspector" class="active-toggle" type="button">\u8BE6\u60C5\u9762\u677F</button>
|
|
28613
|
+
<label style="font-size:11px;display:inline-flex;align-items:center;gap:4px;cursor:pointer;">
|
|
28614
|
+
<input id="chkAutoPoll" type="checkbox" checked /> \u81EA\u52A8\u540C\u6B65 (3s)
|
|
28615
|
+
</label>
|
|
28616
|
+
<button id="btnRefresh" type="button">\u5237\u65B0</button>
|
|
28241
28617
|
</div>
|
|
28618
|
+
</header>
|
|
28242
28619
|
|
|
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>
|
|
28620
|
+
<nav class="cat-subbar">
|
|
28621
|
+
<div class="ribbon-left">
|
|
28622
|
+
<div class="tabs">
|
|
28623
|
+
<button id="tabBtnReview" class="tab-btn active" type="button">\u53CC\u8BED\u7F51\u683C</button>
|
|
28624
|
+
<button id="tabBtnQa" class="tab-btn" type="button">QA \u68C0\u67E5\u6E05\u5355</button>
|
|
28257
28625
|
</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>
|
|
28626
|
+
<span class="v-sep"></span>
|
|
28627
|
+
<div class="filter-pills" id="filterPills">
|
|
28628
|
+
<button class="filter-pill active" data-filter="all" type="button">\u5168\u90E8</button>
|
|
28629
|
+
<button class="filter-pill" data-filter="draft" type="button">\u5F85\u5BA1\u8349\u7A3F</button>
|
|
28630
|
+
<button class="filter-pill" data-filter="needs_revision" type="button">\u9700\u4FEE\u8BA2</button>
|
|
28631
|
+
<button class="filter-pill" data-filter="approved" type="button">\u5DF2\u653E\u884C</button>
|
|
28632
|
+
<button class="filter-pill" data-filter="qa_issue" type="button">\u6709 QA \u95EE\u9898</button>
|
|
28633
|
+
<button class="filter-pill" data-filter="diff" type="button">\u4E0E memoQ \u4E0D\u540C</button>
|
|
28634
|
+
<button class="filter-pill" data-filter="comment" type="button">\u6709\u6279\u6CE8</button>
|
|
28288
28635
|
</div>
|
|
28289
28636
|
</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>
|
|
28637
|
+
<div class="search-wrap">
|
|
28638
|
+
<span class="kbd-hint">Ctrl+Enter \u653E\u884C\u5E76\u4E0B\u4E00\u53E5 \xB7 Ctrl+S \u4FDD\u5B58 \xB7 Alt+\u2191\u2193 \u5207\u6362</span>
|
|
28639
|
+
<input id="searchBox" type="text" style="width:220px;" placeholder="\u641C\u7D22\u539F\u6587 / \u8BD1\u6587 / \u6279\u6CE8..." />
|
|
28295
28640
|
</div>
|
|
28296
|
-
|
|
28297
|
-
|
|
28298
|
-
|
|
28299
|
-
|
|
28300
|
-
|
|
28641
|
+
</nav>
|
|
28642
|
+
|
|
28643
|
+
<section id="qaConfigPanel" class="qa-panel hidden">
|
|
28644
|
+
<div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;justify-content:space-between;">
|
|
28645
|
+
<div style="display:flex;flex-wrap:wrap;gap:10px;align-items:center;font-size:12px;">
|
|
28646
|
+
<strong>\u68C0\u67E5\u5BF9\u8C61\uFF1A</strong>
|
|
28647
|
+
<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>
|
|
28648
|
+
<label><input type="radio" name="qaScope" value="memoq" /> \u4EC5 memoQ \u73B0\u6709\u8BD1\u6587</label>
|
|
28649
|
+
<label><input type="radio" name="qaScope" value="staged" /> \u4EC5 Agent \u6682\u5B58\u8BD1\u6587</label>
|
|
28650
|
+
</div>
|
|
28651
|
+
<div style="display:flex;gap:6px;">
|
|
28652
|
+
<button id="btnRulesDefault" class="sm" type="button">\u9ED8\u8BA4\u89C4\u5219</button>
|
|
28653
|
+
<button id="btnRulesAll" class="sm" type="button">\u5168\u90E8\u89C4\u5219</button>
|
|
28654
|
+
<button id="btnRulesCritical" class="sm" type="button">\u4EC5\u4E25\u91CD\u9519\u8BEF</button>
|
|
28655
|
+
</div>
|
|
28656
|
+
</div>
|
|
28657
|
+
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(220px,1fr));gap:8px;margin-top:8px;">
|
|
28658
|
+
<div>
|
|
28659
|
+
<div class="box-label">\u672F\u8BED\u8868\u6587\u4EF6\u8DEF\u5F84\uFF08\u53EF\u9009 .csv/.tsv/.tbx\uFF09</div>
|
|
28660
|
+
<input id="inpGlossaryPath" type="text" style="width:100%;" placeholder="\u4F8B\u5982 D:\\project\\terms.csv" />
|
|
28301
28661
|
</div>
|
|
28662
|
+
<div>
|
|
28663
|
+
<div class="box-label">\u9879\u76EE\u76EE\u5F55\uFF08\u53EF\u9009\uFF0C\u81EA\u52A8\u8BFB\u53D6 .langlink/manifest.json\uFF09</div>
|
|
28664
|
+
<input id="inpProjectDir" type="text" style="width:100%;" placeholder="\u7559\u7A7A\u5219\u6CBF\u7528\u5DF2\u914D\u7F6E\u9879\u76EE\u76EE\u5F55" />
|
|
28665
|
+
</div>
|
|
28666
|
+
<div>
|
|
28667
|
+
<div class="box-label">\u539F\u6587\u514D\u67E5\u767D\u540D\u5355\uFF08UNTRANSLATED_COPY\uFF0C\u9017\u53F7\u5206\u9694\uFF09</div>
|
|
28668
|
+
<input id="inpWhitelist" type="text" style="width:100%;" placeholder="\u4F8B\u5982 Gold Coin, Discord, X" />
|
|
28669
|
+
</div>
|
|
28670
|
+
</div>
|
|
28671
|
+
<div id="qaRulesContainer" style="margin-top:8px;"></div>
|
|
28672
|
+
</section>
|
|
28673
|
+
|
|
28674
|
+
<div id="statusBanner" class="banner hidden"></div>
|
|
28675
|
+
<div id="revBanner" class="banner rev hidden">
|
|
28676
|
+
<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>
|
|
28677
|
+
<button id="btnCopyPrompt" class="sm primary" type="button">\u590D\u5236\u7ED9 Agent \u7684\u4FEE\u8BA2\u6307\u4EE4</button>
|
|
28678
|
+
</div>
|
|
28302
28679
|
|
|
28303
|
-
|
|
28304
|
-
|
|
28305
|
-
|
|
28306
|
-
|
|
28307
|
-
|
|
28308
|
-
|
|
28309
|
-
|
|
28310
|
-
|
|
28311
|
-
<button class="filter-pill" data-filter="diff" type="button">\u4E0E memoQ \u4E0D\u540C</button>
|
|
28312
|
-
<button class="filter-pill" data-filter="comment" type="button">\u6709\u6279\u6CE8</button>
|
|
28313
|
-
</div>
|
|
28314
|
-
<input id="searchBox" type="text" style="min-width:260px;" placeholder="\u641C\u7D22\u539F\u6587 / \u8BD1\u6587 / \u6279\u6CE8..." />
|
|
28680
|
+
<main id="catWorkspace" class="cat-workspace">
|
|
28681
|
+
<section class="cat-main">
|
|
28682
|
+
<div id="panelReview" class="cat-grid-scroll">
|
|
28683
|
+
<div class="cat-grid-head">
|
|
28684
|
+
<div>#</div>
|
|
28685
|
+
<div>\u539F\u6587 (Source)</div>
|
|
28686
|
+
<div>\u8BD1\u6587 (Target)</div>
|
|
28687
|
+
<div>\u72B6\u6001 / \u64CD\u4F5C</div>
|
|
28315
28688
|
</div>
|
|
28316
|
-
<div id="segmentList"
|
|
28689
|
+
<div id="segmentList"></div>
|
|
28317
28690
|
</div>
|
|
28318
|
-
|
|
28319
|
-
|
|
28320
|
-
<div id="qaSummaryArea" style="margin-bottom:12px;"></div>
|
|
28691
|
+
<div id="panelQa" class="cat-grid-scroll hidden" style="padding:12px;">
|
|
28692
|
+
<div id="qaSummaryArea" style="margin-bottom:10px;"></div>
|
|
28321
28693
|
<div id="qaIssuesArea"></div>
|
|
28322
28694
|
</div>
|
|
28695
|
+
</section>
|
|
28696
|
+
|
|
28697
|
+
<aside id="inspectorPane" class="cat-inspector" aria-label="\u53E5\u6BB5\u8BE6\u60C5\u9762\u677F">
|
|
28698
|
+
<div id="inspectorContent"></div>
|
|
28699
|
+
</aside>
|
|
28700
|
+
</main>
|
|
28701
|
+
|
|
28702
|
+
<footer class="cat-statusbar">
|
|
28703
|
+
<div class="status-group">
|
|
28704
|
+
<span id="pillTotal">\u603B\u53E5\u6BB5: 0</span>
|
|
28705
|
+
<span>\u653E\u884C\u8FDB\u5EA6: <span class="progress-track"><span id="progressFill" class="progress-fill"></span></span> <strong id="progressPct">0%</strong></span>
|
|
28706
|
+
<span class="pill warn" id="pillDraft">\u8349\u7A3F\u5F85\u5BA1: 0</span>
|
|
28707
|
+
<span class="pill rev" id="pillRev">\u9700\u4FEE\u8BA2: 0</span>
|
|
28708
|
+
<span class="pill ok" id="pillApproved">\u5DF2\u653E\u884C: 0</span>
|
|
28709
|
+
<span class="pill err" id="pillQa">QA \u95EE\u9898: -</span>
|
|
28710
|
+
<span class="pill info" id="pillMqm">MQM: -</span>
|
|
28323
28711
|
</div>
|
|
28324
|
-
|
|
28712
|
+
<div class="status-group">
|
|
28713
|
+
<span id="bridgeStatusPill" class="pill ok">\u25CF \u6865\u63A5\u5DF2\u8FDE\u63A5</span>
|
|
28714
|
+
</div>
|
|
28715
|
+
</footer>
|
|
28325
28716
|
|
|
28326
28717
|
<script nonce="${options.nonce}">
|
|
28327
28718
|
const BOOT = ${bootJson};
|
|
28719
|
+
if (window.location.search) {
|
|
28720
|
+
try {
|
|
28721
|
+
history.replaceState(null, "", window.location.pathname);
|
|
28722
|
+
} catch {}
|
|
28723
|
+
}
|
|
28724
|
+
|
|
28328
28725
|
const state = {
|
|
28329
28726
|
data: null,
|
|
28330
28727
|
qa: null,
|
|
@@ -28336,7 +28733,10 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28336
28733
|
selectedRules: null,
|
|
28337
28734
|
dirtyTexts: new Map(),
|
|
28338
28735
|
dirtyComments: new Map(),
|
|
28339
|
-
|
|
28736
|
+
activeRowKey: "",
|
|
28737
|
+
lastFilteredKeys: [],
|
|
28738
|
+
inspectorOpen: true,
|
|
28739
|
+
bridgeConnected: true
|
|
28340
28740
|
};
|
|
28341
28741
|
|
|
28342
28742
|
const headers = () => ({
|
|
@@ -28352,6 +28752,34 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28352
28752
|
.replace(/"/g, """);
|
|
28353
28753
|
}
|
|
28354
28754
|
|
|
28755
|
+
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;
|
|
28756
|
+
|
|
28757
|
+
function formatSourceHtml(rawText) {
|
|
28758
|
+
const text = String(rawText ?? "");
|
|
28759
|
+
if (!text) return "";
|
|
28760
|
+
let out = "";
|
|
28761
|
+
let lastIndex = 0;
|
|
28762
|
+
TAG_TOKEN_RE.lastIndex = 0;
|
|
28763
|
+
let match;
|
|
28764
|
+
while ((match = TAG_TOKEN_RE.exec(text)) !== null) {
|
|
28765
|
+
const idx = match.index;
|
|
28766
|
+
if (idx > lastIndex) {
|
|
28767
|
+
out += esc(text.slice(lastIndex, idx));
|
|
28768
|
+
}
|
|
28769
|
+
const tok = match[0];
|
|
28770
|
+
if (tok === "\\n" || tok === "\\r\\n") {
|
|
28771
|
+
out += '<span class="cat-tag" title="\u6362\u884C">\u21B5</span>\\n';
|
|
28772
|
+
} else {
|
|
28773
|
+
out += '<span class="cat-tag">' + esc(tok) + "</span>";
|
|
28774
|
+
}
|
|
28775
|
+
lastIndex = idx + tok.length;
|
|
28776
|
+
}
|
|
28777
|
+
if (lastIndex < text.length) {
|
|
28778
|
+
out += esc(text.slice(lastIndex));
|
|
28779
|
+
}
|
|
28780
|
+
return out;
|
|
28781
|
+
}
|
|
28782
|
+
|
|
28355
28783
|
function showBanner(type, text) {
|
|
28356
28784
|
const el = document.getElementById("statusBanner");
|
|
28357
28785
|
el.className = "banner " + type;
|
|
@@ -28363,20 +28791,55 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28363
28791
|
document.getElementById("statusBanner").classList.add("hidden");
|
|
28364
28792
|
}
|
|
28365
28793
|
|
|
28366
|
-
|
|
28367
|
-
const
|
|
28368
|
-
|
|
28369
|
-
if (
|
|
28370
|
-
|
|
28794
|
+
function renderBridgePill() {
|
|
28795
|
+
const el = document.getElementById("bridgeStatusPill");
|
|
28796
|
+
if (!el) return;
|
|
28797
|
+
if (state.bridgeConnected) {
|
|
28798
|
+
el.className = "pill ok";
|
|
28799
|
+
el.textContent = "\u25CF \u6865\u63A5\u5DF2\u8FDE\u63A5";
|
|
28800
|
+
} else {
|
|
28801
|
+
el.className = "pill warn";
|
|
28802
|
+
el.textContent = "\u25CB \u6865\u63A5\u91CD\u8FDE\u4E2D\u2026";
|
|
28803
|
+
}
|
|
28371
28804
|
}
|
|
28372
28805
|
|
|
28373
|
-
async function
|
|
28374
|
-
|
|
28375
|
-
|
|
28376
|
-
|
|
28806
|
+
async function apiRequest(method, path, body) {
|
|
28807
|
+
let res;
|
|
28808
|
+
try {
|
|
28809
|
+
res = await fetch(path, {
|
|
28810
|
+
method,
|
|
28811
|
+
headers: method === "GET" ? { "X-Review-Token": BOOT.reviewToken } : headers(),
|
|
28812
|
+
...(body === undefined ? {} : { body: JSON.stringify(body) })
|
|
28813
|
+
});
|
|
28814
|
+
} catch (networkErr) {
|
|
28815
|
+
state.bridgeConnected = false;
|
|
28816
|
+
renderBridgePill();
|
|
28817
|
+
throw networkErr;
|
|
28818
|
+
}
|
|
28819
|
+
|
|
28820
|
+
if (res.status === 401) {
|
|
28821
|
+
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");
|
|
28822
|
+
}
|
|
28823
|
+
|
|
28824
|
+
const data = await res.json().catch(() => ({}));
|
|
28825
|
+
if (!res.ok) {
|
|
28826
|
+
throw new Error(data.error || ("HTTP " + res.status));
|
|
28827
|
+
}
|
|
28828
|
+
if (!state.bridgeConnected) {
|
|
28829
|
+
state.bridgeConnected = true;
|
|
28830
|
+
renderBridgePill();
|
|
28831
|
+
}
|
|
28377
28832
|
return data;
|
|
28378
28833
|
}
|
|
28379
28834
|
|
|
28835
|
+
function apiGet(path) {
|
|
28836
|
+
return apiRequest("GET", path);
|
|
28837
|
+
}
|
|
28838
|
+
|
|
28839
|
+
function apiPost(path, body) {
|
|
28840
|
+
return apiRequest("POST", path, body);
|
|
28841
|
+
}
|
|
28842
|
+
|
|
28380
28843
|
function mergeRows() {
|
|
28381
28844
|
const previewSegs = (state.data && state.data.previewSegments) || [];
|
|
28382
28845
|
const stagedItems = (state.data && state.data.staged && state.data.staged.items) || [];
|
|
@@ -28472,11 +28935,18 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28472
28935
|
return map;
|
|
28473
28936
|
}
|
|
28474
28937
|
|
|
28938
|
+
function rowStatusClass(staged) {
|
|
28939
|
+
if (!staged) return "st-memoq";
|
|
28940
|
+
if (staged.status === "approved") return "st-approved";
|
|
28941
|
+
if (staged.status === "needs_revision") return "st-needs_revision";
|
|
28942
|
+
return "st-draft";
|
|
28943
|
+
}
|
|
28944
|
+
|
|
28475
28945
|
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>";
|
|
28946
|
+
if (!staged) return '<span class="pill">\u4EC5 memoQ</span>';
|
|
28947
|
+
if (staged.status === "approved") return '<span class="pill ok">\u2713 \u5DF2\u653E\u884C v' + staged.revision + "</span>";
|
|
28478
28948
|
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
|
|
28949
|
+
return '<span class="pill warn">\u8349\u7A3F v' + staged.revision + "</span>";
|
|
28480
28950
|
}
|
|
28481
28951
|
|
|
28482
28952
|
function renderRulesCatalog() {
|
|
@@ -28498,7 +28968,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28498
28968
|
for (const g of groups) {
|
|
28499
28969
|
const items = catalog.filter((r) => r.category === g.key);
|
|
28500
28970
|
if (!items.length) continue;
|
|
28501
|
-
html += '<div style="margin-top:
|
|
28971
|
+
html += '<div style="margin-top:6px;"><strong style="font-size:11px;">' + esc(g.title) + '</strong><div class="rule-grid">';
|
|
28502
28972
|
for (const r of items) {
|
|
28503
28973
|
const checked = state.selectedRules.has(r.ruleId) ? "checked" : "";
|
|
28504
28974
|
html += '<label class="rule-item" title="' + esc(r.description) + '">' +
|
|
@@ -28519,19 +28989,19 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28519
28989
|
const total = Math.max(previewSegCount, (d.staged && d.staged.total) || 0);
|
|
28520
28990
|
|
|
28521
28991
|
document.getElementById("docTitle").textContent =
|
|
28522
|
-
(doc.documentName || BOOT.initialDocumentName || "memoQ \u5F53\u524D\u6587\u6863")
|
|
28992
|
+
(doc.documentName || BOOT.initialDocumentName || "memoQ \u5F53\u524D\u6587\u6863");
|
|
28523
28993
|
document.getElementById("langPair").textContent =
|
|
28524
|
-
|
|
28994
|
+
(doc.sourceLanguage || "-") + " \u2192 " + (doc.targetLanguage || "-");
|
|
28525
28995
|
document.getElementById("docIdLine").textContent = doc.documentId && doc.documentId !== "__all__"
|
|
28526
|
-
?
|
|
28527
|
-
: (doc.documentId === "__all__" ? "\u8DE8\u6587\u6863
|
|
28996
|
+
? doc.documentId.slice(0, 8)
|
|
28997
|
+
: (doc.documentId === "__all__" ? "\u8DE8\u6587\u6863" : "");
|
|
28528
28998
|
|
|
28529
28999
|
const sel = document.getElementById("docSelector");
|
|
28530
29000
|
const docsList = d.documents || [];
|
|
28531
29001
|
const currentVal = state.selectedDocumentId || d.selectedDocumentId || doc.documentId || "";
|
|
28532
|
-
let optHtml = '<option value="">\u5F53\u524D\u6D3B\u8DC3\u6587\u6863\uFF08\u8DDF\u968F memoQ
|
|
29002
|
+
let optHtml = '<option value="">\u5F53\u524D\u6D3B\u8DC3\u6587\u6863\uFF08\u8DDF\u968F memoQ\uFF09</option>';
|
|
28533
29003
|
if (docsList.length > 0) {
|
|
28534
|
-
optHtml += '<option value="__all__"' + (currentVal === "__all__" ? " selected" : "") + '>\u5168\u90E8\u5DF2\u6253\u5F00\u6587\u6863
|
|
29004
|
+
optHtml += '<option value="__all__"' + (currentVal === "__all__" ? " selected" : "") + '>\u5168\u90E8\u5DF2\u6253\u5F00\u6587\u6863 (\u5171 ' + docsList.length + ' \u4EFD)</option>';
|
|
28535
29005
|
}
|
|
28536
29006
|
for (const item of docsList) {
|
|
28537
29007
|
const activeTag = item.isActive ? "[\u6D3B\u8DC3] " : "";
|
|
@@ -28551,6 +29021,9 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28551
29021
|
document.getElementById("pillDraft").textContent = "\u8349\u7A3F\u5F85\u5BA1: " + counts.draft;
|
|
28552
29022
|
document.getElementById("pillRev").textContent = "\u9700\u4FEE\u8BA2: " + counts.needsRevision;
|
|
28553
29023
|
document.getElementById("pillApproved").textContent = "\u5DF2\u653E\u884C: " + counts.approved;
|
|
29024
|
+
const pct = total > 0 ? Math.min(100, Math.round((counts.approved / total) * 100)) : 0;
|
|
29025
|
+
document.getElementById("progressFill").style.width = pct + "%";
|
|
29026
|
+
document.getElementById("progressPct").textContent = pct + "%";
|
|
28554
29027
|
|
|
28555
29028
|
const revBanner = document.getElementById("revBanner");
|
|
28556
29029
|
document.getElementById("revCount").textContent = String(counts.needsRevision);
|
|
@@ -28567,6 +29040,110 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28567
29040
|
|
|
28568
29041
|
const projInput = document.getElementById("inpProjectDir");
|
|
28569
29042
|
if (!projInput.value && d.projectDir) projInput.value = d.projectDir;
|
|
29043
|
+
renderBridgePill();
|
|
29044
|
+
}
|
|
29045
|
+
|
|
29046
|
+
function autoSizeTextarea(el) {
|
|
29047
|
+
if (!el) return;
|
|
29048
|
+
el.style.height = "auto";
|
|
29049
|
+
el.style.height = Math.max(44, Math.min(el.scrollHeight + 2, 240)) + "px";
|
|
29050
|
+
}
|
|
29051
|
+
|
|
29052
|
+
function renderInspector() {
|
|
29053
|
+
const box = document.getElementById("inspectorContent");
|
|
29054
|
+
if (!box) return;
|
|
29055
|
+
const rows = mergeRows();
|
|
29056
|
+
const row = rows.find((r) => r.rowKey === state.activeRowKey) || null;
|
|
29057
|
+
if (!row) {
|
|
29058
|
+
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>';
|
|
29059
|
+
return;
|
|
29060
|
+
}
|
|
29061
|
+
|
|
29062
|
+
const s = row.staged;
|
|
29063
|
+
const issueMap = issuesByRowMap();
|
|
29064
|
+
const rowIssues = issueMap.get(row.rowKey)
|
|
29065
|
+
|| issueMap.get(row.previewPartId)
|
|
29066
|
+
|| (s ? issueMap.get("staged:" + s.id) : null)
|
|
29067
|
+
|| [];
|
|
29068
|
+
const currentComment = state.dirtyComments.has(row.rowKey)
|
|
29069
|
+
? state.dirtyComments.get(row.rowKey)
|
|
29070
|
+
: (s ? s.reviewComment : "");
|
|
29071
|
+
|
|
29072
|
+
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>';
|
|
29073
|
+
if (s && Array.isArray(s.history) && s.history.length > 0) {
|
|
29074
|
+
historyHtml = '<div style="display:flex;gap:6px;align-items:center;">' +
|
|
29075
|
+
'<select class="rev-select" style="flex:1;min-width:0;" data-row="' + esc(row.rowKey) + '" data-id="' + esc(s.id) + '">' +
|
|
29076
|
+
s.history.slice().reverse().map((h) =>
|
|
29077
|
+
'<option value="' + h.revision + '">v' + h.revision + " (" + esc(h.editedBy) + "): " + esc(h.targetText.slice(0, 36)) + "</option>"
|
|
29078
|
+
).join("") +
|
|
29079
|
+
'</select><button class="sm btn-revert" data-id="' + esc(s.id) + '" data-row="' + esc(row.rowKey) + '" type="button">\u56DE\u9000</button></div>';
|
|
29080
|
+
}
|
|
29081
|
+
|
|
29082
|
+
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>";
|
|
29083
|
+
if (rowIssues.length > 0) {
|
|
29084
|
+
qaHtml = rowIssues.map((iss) => {
|
|
29085
|
+
const cls = iss.severity === "critical" ? "err" : (iss.severity === "major" ? "warn" : "info");
|
|
29086
|
+
return '<div class="qa-issue-card">' +
|
|
29087
|
+
'<div><span class="pill ' + cls + '">' + esc(iss.severity) + '</span> <strong>' + esc(iss.ruleLabel) + "</strong></div>" +
|
|
29088
|
+
'<div>' + esc(iss.message) + "</div>" +
|
|
29089
|
+
(iss.evidence ? '<div class="mono" style="color:var(--muted);">' + esc(iss.evidence) + "</div>" : "") +
|
|
29090
|
+
(iss.suggestion ? '<div style="color:var(--ok);font-size:11px;">\u5EFA\u8BAE: ' + esc(iss.suggestion) + "</div>" : "") +
|
|
29091
|
+
"</div>";
|
|
29092
|
+
}).join("");
|
|
29093
|
+
}
|
|
29094
|
+
|
|
29095
|
+
const memoqText = row.memoqTargetText || "";
|
|
29096
|
+
const fillBtn = memoqText
|
|
29097
|
+
? '<button id="btnFillMemoqTarget" class="sm" data-row="' + esc(row.rowKey) + '" type="button">\u586B\u5165\u7F16\u8F91\u6846</button>'
|
|
29098
|
+
: "";
|
|
29099
|
+
const focusBtn = row.previewPartId
|
|
29100
|
+
? '<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>'
|
|
29101
|
+
: "";
|
|
29102
|
+
|
|
29103
|
+
box.innerHTML =
|
|
29104
|
+
'<div class="insp-section">' +
|
|
29105
|
+
'<div class="insp-title"><span>\u53E5\u6BB5 #' + (row.index + 1) + '</span>' + statusBadgeHtml(s) + "</div>" +
|
|
29106
|
+
'<div style="font-size:11px;color:var(--muted);">' +
|
|
29107
|
+
(row.documentName ? esc(row.documentName) + " \xB7 " : "") +
|
|
29108
|
+
esc(row.sourceLanguage || "-") + " \u2192 " + esc(row.targetLanguage || "-") +
|
|
29109
|
+
(s && s.stagedBy ? (" \xB7 by " + esc(s.stagedBy)) : "") +
|
|
29110
|
+
"</div>" +
|
|
29111
|
+
(focusBtn ? '<div style="margin-top:2px;">' + focusBtn + "</div>" : "") +
|
|
29112
|
+
"</div>" +
|
|
29113
|
+
'<div class="insp-section">' +
|
|
29114
|
+
'<div class="insp-title"><span>memoQ \u5B9E\u65F6\u8BD1\u6587\u5BF9\u7167</span>' + fillBtn + "</div>" +
|
|
29115
|
+
'<div class="insp-ref-text">' + (memoqText ? esc(memoqText) : '<span style="color:var(--faint);">(memoQ \u4E2D\u5F53\u524D\u4E3A\u7A7A)</span>') + "</div>" +
|
|
29116
|
+
"</div>" +
|
|
29117
|
+
'<div class="insp-section">' +
|
|
29118
|
+
'<div class="insp-title"><span>\u7ED9 Agent \u7684\u4FEE\u6539\u610F\u89C1</span></div>' +
|
|
29119
|
+
'<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>" +
|
|
29120
|
+
'<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>' +
|
|
29121
|
+
"</div>" +
|
|
29122
|
+
'<div class="insp-section">' +
|
|
29123
|
+
'<div class="insp-title"><span>\u591A\u8F6E\u4FEE\u8BA2\u5386\u53F2</span></div>' +
|
|
29124
|
+
historyHtml +
|
|
29125
|
+
"</div>" +
|
|
29126
|
+
'<div class="insp-section">' +
|
|
29127
|
+
'<div class="insp-title"><span>\u53E5\u6BB5 QA \u8BCA\u65AD (' + rowIssues.length + ")</span></div>" +
|
|
29128
|
+
qaHtml +
|
|
29129
|
+
"</div>";
|
|
29130
|
+
}
|
|
29131
|
+
|
|
29132
|
+
function selectActiveRow(rowKey, focusEditor = false) {
|
|
29133
|
+
if (!rowKey) return;
|
|
29134
|
+
state.activeRowKey = rowKey;
|
|
29135
|
+
for (const el of document.querySelectorAll("[data-row-card]")) {
|
|
29136
|
+
el.classList.toggle("active-row", el.getAttribute("data-row-card") === rowKey);
|
|
29137
|
+
}
|
|
29138
|
+
renderInspector();
|
|
29139
|
+
if (focusEditor) {
|
|
29140
|
+
const card = document.querySelector('[data-row-card="' + CSS.escape(rowKey) + '"]');
|
|
29141
|
+
const ta = card && card.querySelector(".tgt-edit");
|
|
29142
|
+
if (ta) {
|
|
29143
|
+
ta.focus();
|
|
29144
|
+
ta.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
29145
|
+
}
|
|
29146
|
+
}
|
|
28570
29147
|
}
|
|
28571
29148
|
|
|
28572
29149
|
function renderReviewList() {
|
|
@@ -28577,7 +29154,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28577
29154
|
|
|
28578
29155
|
const filtered = rows.filter((row) => {
|
|
28579
29156
|
const s = row.staged;
|
|
28580
|
-
const rowIssues = issueMap.get(row.rowKey) || (s ? issueMap.get("staged:" + s.id) : null) || [];
|
|
29157
|
+
const rowIssues = issueMap.get(row.rowKey) || issueMap.get(row.previewPartId) || (s ? issueMap.get("staged:" + s.id) : null) || [];
|
|
28581
29158
|
if (state.filter === "draft" && (!s || s.status !== "draft")) return false;
|
|
28582
29159
|
if (state.filter === "needs_revision" && (!s || s.status !== "needs_revision")) return false;
|
|
28583
29160
|
if (state.filter === "approved" && (!s || s.status !== "approved")) return false;
|
|
@@ -28598,11 +29175,18 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28598
29175
|
return true;
|
|
28599
29176
|
});
|
|
28600
29177
|
|
|
29178
|
+
state.lastFilteredKeys = filtered.map((r) => r.rowKey);
|
|
28601
29179
|
if (filtered.length === 0) {
|
|
28602
|
-
|
|
29180
|
+
state.activeRowKey = "";
|
|
29181
|
+
container.innerHTML = '<div class="empty-state">\u5F53\u524D\u7B5B\u9009\u6761\u4EF6\u4E0B\u6CA1\u6709\u53E5\u6BB5\u3002</div>';
|
|
29182
|
+
renderInspector();
|
|
28603
29183
|
return;
|
|
28604
29184
|
}
|
|
28605
29185
|
|
|
29186
|
+
if (!state.activeRowKey || !filtered.some((r) => r.rowKey === state.activeRowKey)) {
|
|
29187
|
+
state.activeRowKey = filtered[0].rowKey;
|
|
29188
|
+
}
|
|
29189
|
+
|
|
28606
29190
|
const showDocBadge = state.selectedDocumentId === "__all__"
|
|
28607
29191
|
|| (state.data && state.data.selectedDocumentId === "__all__")
|
|
28608
29192
|
|| (state.data && Array.isArray(state.data.documents) && state.data.documents.length > 1);
|
|
@@ -28615,80 +29199,64 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28615
29199
|
|| issueMap.get(row.previewPartId)
|
|
28616
29200
|
|| (s ? issueMap.get("staged:" + s.id) : null)
|
|
28617
29201
|
|| [];
|
|
28618
|
-
const
|
|
29202
|
+
const isDirty = state.dirtyTexts.has(row.rowKey);
|
|
29203
|
+
const currentTarget = isDirty
|
|
28619
29204
|
? state.dirtyTexts.get(row.rowKey)
|
|
28620
29205
|
: (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" : "";
|
|
29206
|
+
const activeClass = state.activeRowKey === row.rowKey ? " active-row" : "";
|
|
28625
29207
|
const docBadge = showDocBadge && row.documentName
|
|
28626
|
-
? '<span class="
|
|
29208
|
+
? '<span class="doc-chip" title="' + esc(row.documentName) + '">' + esc(row.documentName) + "</span>"
|
|
28627
29209
|
: "";
|
|
28628
29210
|
|
|
28629
29211
|
let issuesBadges = "";
|
|
28630
29212
|
if (rowIssues.length > 0) {
|
|
28631
|
-
issuesBadges = '<div class="badge-list">' + rowIssues.map((iss) => {
|
|
29213
|
+
issuesBadges = '<div class="badge-list">' + rowIssues.slice(0, 3).map((iss) => {
|
|
28632
29214
|
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>';
|
|
29215
|
+
return '<span class="pill ' + cls + '" title="' + esc(iss.evidence) + '">' + esc(iss.ruleLabel) + "</span>";
|
|
29216
|
+
}).join("") + (rowIssues.length > 3 ? '<span class="pill info">+' + (rowIssues.length - 3) + "</span>" : "") + "</div>";
|
|
28644
29217
|
}
|
|
28645
29218
|
|
|
28646
29219
|
const memoqDiffHtml = s && row.memoqTargetText && row.memoqTargetText !== s.targetText
|
|
28647
|
-
? '<div class="memoq-ref"
|
|
28648
|
-
:
|
|
28649
|
-
|
|
28650
|
-
|
|
29220
|
+
? '<div class="memoq-ref-line">memoQ: ' + esc(row.memoqTargetText) + "</div>"
|
|
29221
|
+
: "";
|
|
29222
|
+
const cmtBadge = s && s.reviewComment
|
|
29223
|
+
? '<div class="cmt-chip">\u6279\u6CE8: ' + esc(s.reviewComment) + "</div>"
|
|
29224
|
+
: "";
|
|
28651
29225
|
|
|
28652
29226
|
const approveBtn = s
|
|
28653
29227
|
? (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"
|
|
29228
|
+
? '<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>'
|
|
29229
|
+
: '<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
29230
|
: "";
|
|
28657
|
-
|
|
28658
29231
|
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"
|
|
29232
|
+
? '<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
29233
|
: "";
|
|
28661
29234
|
|
|
28662
|
-
html += '<div class="
|
|
28663
|
-
'<div class="
|
|
28664
|
-
|
|
28665
|
-
|
|
28666
|
-
'<
|
|
29235
|
+
html += '<div class="cat-row ' + rowStatusClass(s) + activeClass + '" data-row-card="' + esc(row.rowKey) + '">' +
|
|
29236
|
+
'<div class="cat-rail"><strong>' + (row.index + 1) + "</strong>" + docBadge + (isDirty ? '<span class="dirty-tag">\u672A\u4FDD\u5B58</span>' : "") + "</div>" +
|
|
29237
|
+
'<div class="cat-source"><div class="src-text">' + formatSourceHtml(row.sourceText) + "</div>" + issuesBadges + "</div>" +
|
|
29238
|
+
'<div class="cat-target">' +
|
|
29239
|
+
'<textarea class="tgt-edit" data-row="' + esc(row.rowKey) + '" placeholder="\u8F93\u5165\u6216\u7F16\u8F91\u8BD1\u6587...">' + esc(currentTarget) + "</textarea>" +
|
|
29240
|
+
memoqDiffHtml + cmtBadge +
|
|
28667
29241
|
"</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>" +
|
|
29242
|
+
'<div class="cat-status">' +
|
|
29243
|
+
statusBadgeHtml(s) +
|
|
29244
|
+
'<div class="row-mini-btns">' +
|
|
29245
|
+
'<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>" +
|
|
29246
|
+
approveBtn + focusBtn +
|
|
28683
29247
|
"</div>" +
|
|
28684
29248
|
"</div>" +
|
|
28685
|
-
|
|
29249
|
+
"</div>";
|
|
28686
29250
|
}
|
|
28687
29251
|
if (filtered.length > maxRender) {
|
|
28688
29252
|
const remaining = filtered.length - maxRender;
|
|
28689
|
-
html += '<div class="banner warn"><span>\
|
|
29253
|
+
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
29254
|
}
|
|
28691
29255
|
container.innerHTML = html;
|
|
29256
|
+
for (const ta of container.querySelectorAll(".tgt-edit")) {
|
|
29257
|
+
autoSizeTextarea(ta);
|
|
29258
|
+
}
|
|
29259
|
+
renderInspector();
|
|
28692
29260
|
}
|
|
28693
29261
|
|
|
28694
29262
|
function renderQaReport() {
|
|
@@ -28708,13 +29276,13 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28708
29276
|
? ("\u5DF2\u52A0\u8F7D\u672F\u8BED " + r.glossary.entriesCount + " \u6761\uFF08" + esc(r.glossary.sources.join(", ")) + "\uFF09")
|
|
28709
29277
|
: "\u672A\u52A0\u8F7D\u5916\u90E8\u672F\u8BED\u8868\uFF08\u672F\u8BED\u89C4\u5219\u5DF2\u8BDA\u5B9E\u6807\u6CE8 skipped\uFF09";
|
|
28710
29278
|
|
|
28711
|
-
const ruleSummaryHtml = '<details style="margin-top:
|
|
28712
|
-
'<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(
|
|
29279
|
+
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>' +
|
|
29280
|
+
'<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(250px,1fr));gap:4px 10px;margin-top:6px;font-size:11px;">' +
|
|
28713
29281
|
r.rules.map((rule) => '<div><strong>' + esc(rule.ruleId) + "</strong>: " + esc(rule.status) + " (" + rule.checkedSegments + ")" + (rule.reason ? " - " + esc(rule.reason) : "") + "</div>").join("") +
|
|
28714
29282
|
"</div></details>";
|
|
28715
29283
|
|
|
28716
29284
|
sumEl.innerHTML =
|
|
28717
|
-
'<div
|
|
29285
|
+
'<div style="display:flex;flex-wrap:wrap;gap:6px;align-items:center;margin-bottom:6px;">' +
|
|
28718
29286
|
'<span class="pill info">\u68C0\u67E5\u6A21\u5F0F: ' + esc(r.scope) + "</span>" +
|
|
28719
29287
|
'<span class="pill">\u603B\u53E5\u6BB5: ' + s.totalSegments + "</span>" +
|
|
28720
29288
|
'<span class="pill">\u5DF2\u8BD1/\u975E\u7A7A: ' + s.translatedSegments + " / \u7A7A\u8BD1: " + s.emptyTargetSegments + "</span>" +
|
|
@@ -28724,7 +29292,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28724
29292
|
'<span class="pill">MQM RQS: ' + s.mqm.rqs + " (APT=" + s.mqm.apt + ", EWC=" + s.mqm.ewc + ")</span>" +
|
|
28725
29293
|
covPill +
|
|
28726
29294
|
"</div>" +
|
|
28727
|
-
'<div
|
|
29295
|
+
'<div style="font-size:12px;color:var(--muted);">' + glossaryInfo +
|
|
28728
29296
|
(r.glossary.warnings.length ? (" | \u6CE8\u610F: " + esc(r.glossary.warnings.join("; "))) : "") +
|
|
28729
29297
|
"</div>" + ruleSummaryHtml;
|
|
28730
29298
|
|
|
@@ -28742,7 +29310,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28742
29310
|
const jumpKey = (iss.documentId && iss.previewPartId ? (iss.documentId + "::" + iss.previewPartId) : iss.previewPartId)
|
|
28743
29311
|
|| (iss.stagedId ? ("staged:" + iss.stagedId) : "");
|
|
28744
29312
|
const jumpBtn = jumpKey
|
|
28745
|
-
? '<button class="sm primary btn-jump-review" data-row="' + esc(jumpKey) + '" type="button">\u53BB\u5BA1\u6821
|
|
29313
|
+
? '<button class="sm primary btn-jump-review" data-row="' + esc(jumpKey) + '" type="button">\u53BB\u5BA1\u6821</button>'
|
|
28746
29314
|
: "";
|
|
28747
29315
|
const segCell = (r.allDocuments && iss.documentName)
|
|
28748
29316
|
? ('<div><span class="pill info">' + esc(iss.documentName) + "</span></div><div>#" + (iss.docSegmentNumber || iss.segmentNumber) + "</div>")
|
|
@@ -28752,12 +29320,12 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28752
29320
|
'<td><span class="pill ' + cls + '">' + esc(iss.severity) + "</span></td>" +
|
|
28753
29321
|
"<td><strong>" + esc(iss.ruleLabel) + '</strong><div class="mono">' + esc(iss.ruleId) + "</div></td>" +
|
|
28754
29322
|
"<td>" + segCell + "</td>" +
|
|
28755
|
-
"<td><div style='margin-bottom:
|
|
29323
|
+
"<td><div style='margin-bottom:3px;'><strong>\u6E90\uFF1A</strong>" + esc(iss.sourceText) + "</div>" +
|
|
28756
29324
|
"<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:
|
|
29325
|
+
"<td><div>" + esc(iss.message) + '</div><div class="mono" style="color:var(--muted);">' + esc(iss.evidence) + "</div>" +
|
|
29326
|
+
(iss.suggestion ? ('<div style="color:var(--ok);font-size:11px;">\u5EFA\u8BAE: ' + esc(iss.suggestion) + "</div>") : "") +
|
|
28759
29327
|
"</td>" +
|
|
28760
|
-
'<td><div
|
|
29328
|
+
'<td><div style="display:flex;gap:4px;flex-wrap:wrap;">' + focusBtn + jumpBtn + "</div></td>" +
|
|
28761
29329
|
"</tr>";
|
|
28762
29330
|
}
|
|
28763
29331
|
|
|
@@ -28782,6 +29350,24 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28782
29350
|
}
|
|
28783
29351
|
}
|
|
28784
29352
|
|
|
29353
|
+
async function saveRowDraft(rowKey, stagedId, targetText, nextStatus) {
|
|
29354
|
+
const row = mergeRows().find((r) => r.rowKey === rowKey);
|
|
29355
|
+
if (!row) return null;
|
|
29356
|
+
const res = await apiPost("/review/api/update", {
|
|
29357
|
+
...(stagedId ? { id: stagedId } : {}),
|
|
29358
|
+
targetText,
|
|
29359
|
+
...(nextStatus ? { status: nextStatus } : {}),
|
|
29360
|
+
editedBy: "translator",
|
|
29361
|
+
sourceText: row.sourceText,
|
|
29362
|
+
sourceLanguage: row.sourceLanguage || "eng",
|
|
29363
|
+
targetLanguage: row.targetLanguage || "zho-CN",
|
|
29364
|
+
documentId: row.documentId || "",
|
|
29365
|
+
previewPartId: row.previewPartId || ""
|
|
29366
|
+
});
|
|
29367
|
+
state.dirtyTexts.delete(rowKey);
|
|
29368
|
+
return res.entry || null;
|
|
29369
|
+
}
|
|
29370
|
+
|
|
28785
29371
|
async function runQa() {
|
|
28786
29372
|
const scopeEl = document.querySelector('input[name="qaScope"]:checked');
|
|
28787
29373
|
const scope = scopeEl ? scopeEl.value : "merged";
|
|
@@ -28834,10 +29420,6 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28834
29420
|
if (tab === "qa") renderQaReport();
|
|
28835
29421
|
}
|
|
28836
29422
|
|
|
28837
|
-
function findRowByKey(rowKey) {
|
|
28838
|
-
return mergeRows().find((r) => r.rowKey === rowKey);
|
|
28839
|
-
}
|
|
28840
|
-
|
|
28841
29423
|
document.getElementById("docSelector").addEventListener("change", (ev) => {
|
|
28842
29424
|
state.selectedDocumentId = ev.target.value || "";
|
|
28843
29425
|
state.renderLimit = 300;
|
|
@@ -28851,6 +29433,11 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28851
29433
|
document.getElementById("btnToggleQaCfg").addEventListener("click", () => {
|
|
28852
29434
|
document.getElementById("qaConfigPanel").classList.toggle("hidden");
|
|
28853
29435
|
});
|
|
29436
|
+
document.getElementById("btnToggleInspector").addEventListener("click", () => {
|
|
29437
|
+
state.inspectorOpen = !state.inspectorOpen;
|
|
29438
|
+
document.getElementById("catWorkspace").classList.toggle("inspector-collapsed", !state.inspectorOpen);
|
|
29439
|
+
document.getElementById("btnToggleInspector").classList.toggle("active-toggle", state.inspectorOpen);
|
|
29440
|
+
});
|
|
28854
29441
|
|
|
28855
29442
|
document.getElementById("btnRulesDefault").addEventListener("click", () => {
|
|
28856
29443
|
const cat = (state.data && state.data.qaCatalog) || [];
|
|
@@ -28881,7 +29468,7 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28881
29468
|
const docId = (state.data && state.data.document && state.data.document.documentId) || "";
|
|
28882
29469
|
const res = await apiPost("/review/api/approve", { ...(docId ? { documentId: docId } : {}), status: "approved" });
|
|
28883
29470
|
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\
|
|
29471
|
+
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
29472
|
} catch (err) {
|
|
28886
29473
|
showBanner("err", "\u653E\u884C\u5931\u8D25: " + (err.message || err));
|
|
28887
29474
|
}
|
|
@@ -28928,8 +29515,76 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28928
29515
|
if (!t || !t.getAttribute) return;
|
|
28929
29516
|
const rowKey = t.getAttribute("data-row");
|
|
28930
29517
|
if (!rowKey) return;
|
|
28931
|
-
if (t.classList.contains("tgt-edit"))
|
|
28932
|
-
|
|
29518
|
+
if (t.classList.contains("tgt-edit")) {
|
|
29519
|
+
state.dirtyTexts.set(rowKey, t.value);
|
|
29520
|
+
autoSizeTextarea(t);
|
|
29521
|
+
}
|
|
29522
|
+
if (t.classList.contains("cmt-edit")) {
|
|
29523
|
+
state.dirtyComments.set(rowKey, t.value);
|
|
29524
|
+
}
|
|
29525
|
+
});
|
|
29526
|
+
|
|
29527
|
+
document.addEventListener("focusin", (ev) => {
|
|
29528
|
+
const card = ev.target && ev.target.closest ? ev.target.closest("[data-row-card]") : null;
|
|
29529
|
+
if (card) {
|
|
29530
|
+
const rk = card.getAttribute("data-row-card");
|
|
29531
|
+
if (rk && rk !== state.activeRowKey) {
|
|
29532
|
+
selectActiveRow(rk, false);
|
|
29533
|
+
}
|
|
29534
|
+
}
|
|
29535
|
+
});
|
|
29536
|
+
|
|
29537
|
+
document.addEventListener("keydown", async (ev) => {
|
|
29538
|
+
const t = ev.target;
|
|
29539
|
+
if (!t || !t.classList || !t.classList.contains("tgt-edit")) return;
|
|
29540
|
+
const rowKey = t.getAttribute("data-row") || "";
|
|
29541
|
+
if (!rowKey) return;
|
|
29542
|
+
|
|
29543
|
+
if ((ev.ctrlKey || ev.metaKey) && ev.key === "Enter") {
|
|
29544
|
+
ev.preventDefault();
|
|
29545
|
+
const card = t.closest("[data-row-card]");
|
|
29546
|
+
const saveBtn = card && card.querySelector(".btn-save-edit");
|
|
29547
|
+
const stagedId = (saveBtn && saveBtn.getAttribute("data-id")) || "";
|
|
29548
|
+
const keys = state.lastFilteredKeys || [];
|
|
29549
|
+
const curIdx = keys.indexOf(rowKey);
|
|
29550
|
+
const nextKey = curIdx >= 0 && curIdx + 1 < keys.length ? keys[curIdx + 1] : rowKey;
|
|
29551
|
+
try {
|
|
29552
|
+
await saveRowDraft(rowKey, stagedId, t.value, "approved");
|
|
29553
|
+
state.activeRowKey = nextKey;
|
|
29554
|
+
await refreshState(true);
|
|
29555
|
+
selectActiveRow(nextKey, true);
|
|
29556
|
+
showBanner("ok", "\u5DF2\u653E\u884C\u5F53\u524D\u53E5\u6BB5\u5E76\u8DF3\u8F6C\u5230\u4E0B\u4E00\u53E5\u3002");
|
|
29557
|
+
} catch (err) {
|
|
29558
|
+
showBanner("err", "\u5FEB\u6377\u653E\u884C\u5931\u8D25: " + (err.message || err));
|
|
29559
|
+
}
|
|
29560
|
+
return;
|
|
29561
|
+
}
|
|
29562
|
+
|
|
29563
|
+
if ((ev.ctrlKey || ev.metaKey) && ev.key.toLowerCase() === "s") {
|
|
29564
|
+
ev.preventDefault();
|
|
29565
|
+
const card = t.closest("[data-row-card]");
|
|
29566
|
+
const saveBtn = card && card.querySelector(".btn-save-edit");
|
|
29567
|
+
const stagedId = (saveBtn && saveBtn.getAttribute("data-id")) || "";
|
|
29568
|
+
try {
|
|
29569
|
+
await saveRowDraft(rowKey, stagedId, t.value);
|
|
29570
|
+
await refreshState(true);
|
|
29571
|
+
selectActiveRow(rowKey, true);
|
|
29572
|
+
showBanner("ok", "\u5DF2\u4FDD\u5B58\u5F53\u524D\u4FEE\u8BA2\u7248\u672C\u3002");
|
|
29573
|
+
} catch (err) {
|
|
29574
|
+
showBanner("err", "\u4FDD\u5B58\u5931\u8D25: " + (err.message || err));
|
|
29575
|
+
}
|
|
29576
|
+
return;
|
|
29577
|
+
}
|
|
29578
|
+
|
|
29579
|
+
if (ev.altKey && (ev.key === "ArrowDown" || ev.key === "ArrowUp")) {
|
|
29580
|
+
ev.preventDefault();
|
|
29581
|
+
const keys = state.lastFilteredKeys || [];
|
|
29582
|
+
const curIdx = keys.indexOf(rowKey);
|
|
29583
|
+
if (curIdx < 0) return;
|
|
29584
|
+
const delta = ev.key === "ArrowDown" ? 1 : -1;
|
|
29585
|
+
const nextIdx = Math.max(0, Math.min(keys.length - 1, curIdx + delta));
|
|
29586
|
+
selectActiveRow(keys[nextIdx], true);
|
|
29587
|
+
}
|
|
28933
29588
|
});
|
|
28934
29589
|
|
|
28935
29590
|
document.addEventListener("click", async (ev) => {
|
|
@@ -28940,6 +29595,23 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28940
29595
|
return;
|
|
28941
29596
|
}
|
|
28942
29597
|
|
|
29598
|
+
const btnFillMemoq = ev.target.closest("#btnFillMemoqTarget");
|
|
29599
|
+
if (btnFillMemoq) {
|
|
29600
|
+
const rowKey = btnFillMemoq.getAttribute("data-row") || "";
|
|
29601
|
+
const row = mergeRows().find((r) => r.rowKey === rowKey);
|
|
29602
|
+
if (!row || !row.memoqTargetText) return;
|
|
29603
|
+
state.dirtyTexts.set(rowKey, row.memoqTargetText);
|
|
29604
|
+
const card = document.querySelector('[data-row-card="' + CSS.escape(rowKey) + '"]');
|
|
29605
|
+
const ta = card && card.querySelector(".tgt-edit");
|
|
29606
|
+
if (ta) {
|
|
29607
|
+
ta.value = row.memoqTargetText;
|
|
29608
|
+
autoSizeTextarea(ta);
|
|
29609
|
+
ta.focus();
|
|
29610
|
+
}
|
|
29611
|
+
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");
|
|
29612
|
+
return;
|
|
29613
|
+
}
|
|
29614
|
+
|
|
28943
29615
|
const btnFocus = ev.target.closest(".btn-focus");
|
|
28944
29616
|
if (btnFocus) {
|
|
28945
29617
|
try {
|
|
@@ -28958,24 +29630,12 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28958
29630
|
|
|
28959
29631
|
const btnSave = ev.target.closest(".btn-save-edit");
|
|
28960
29632
|
if (btnSave) {
|
|
28961
|
-
const rowKey = btnSave.getAttribute("data-row");
|
|
29633
|
+
const rowKey = btnSave.getAttribute("data-row") || "";
|
|
28962
29634
|
const id = btnSave.getAttribute("data-id") || "";
|
|
28963
|
-
const row = findRowByKey(rowKey);
|
|
28964
|
-
if (!row) return;
|
|
28965
29635
|
const card = btnSave.closest("[data-row-card]");
|
|
28966
29636
|
const targetText = card.querySelector(".tgt-edit").value;
|
|
28967
29637
|
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);
|
|
29638
|
+
await saveRowDraft(rowKey, id, targetText);
|
|
28979
29639
|
await refreshState(true);
|
|
28980
29640
|
showBanner("ok", "\u5DF2\u4FDD\u5B58\u4FEE\u8BA2\u7248\u672C\u3002");
|
|
28981
29641
|
} catch (err) {
|
|
@@ -28987,9 +29647,9 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
28987
29647
|
const btnRevert = ev.target.closest(".btn-revert");
|
|
28988
29648
|
if (btnRevert) {
|
|
28989
29649
|
const id = btnRevert.getAttribute("data-id");
|
|
28990
|
-
const rowKey = btnRevert.getAttribute("data-row");
|
|
28991
|
-
const
|
|
28992
|
-
const sel =
|
|
29650
|
+
const rowKey = btnRevert.getAttribute("data-row") || "";
|
|
29651
|
+
const insp = document.getElementById("inspectorPane");
|
|
29652
|
+
const sel = insp && insp.querySelector(".rev-select");
|
|
28993
29653
|
if (!id || !sel) return;
|
|
28994
29654
|
try {
|
|
28995
29655
|
await apiPost("/review/api/update", { id, revertToRevision: Number(sel.value), editedBy: "translator" });
|
|
@@ -29004,13 +29664,15 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
29004
29664
|
|
|
29005
29665
|
const btnFeedback = ev.target.closest(".btn-feedback");
|
|
29006
29666
|
if (btnFeedback) {
|
|
29007
|
-
const rowKey = btnFeedback.getAttribute("data-row");
|
|
29667
|
+
const rowKey = btnFeedback.getAttribute("data-row") || "";
|
|
29008
29668
|
const id = btnFeedback.getAttribute("data-id") || "";
|
|
29009
|
-
const row =
|
|
29669
|
+
const row = mergeRows().find((r) => r.rowKey === rowKey);
|
|
29010
29670
|
if (!row) return;
|
|
29011
|
-
const
|
|
29012
|
-
const comment =
|
|
29013
|
-
const
|
|
29671
|
+
const cmtInput = document.getElementById("inspectorCommentInput");
|
|
29672
|
+
const comment = cmtInput ? cmtInput.value : "";
|
|
29673
|
+
const card = document.querySelector('[data-row-card="' + CSS.escape(rowKey) + '"]');
|
|
29674
|
+
const ta = card && card.querySelector(".tgt-edit");
|
|
29675
|
+
const currentTarget = ta ? ta.value : (row.staged ? row.staged.targetText : row.memoqTargetText);
|
|
29014
29676
|
try {
|
|
29015
29677
|
await apiPost("/review/api/feedback", {
|
|
29016
29678
|
...(id ? { id } : {}),
|
|
@@ -29048,15 +29710,22 @@ function renderReviewWorkbenchHtml(options) {
|
|
|
29048
29710
|
const btnJump = ev.target.closest(".btn-jump-review");
|
|
29049
29711
|
if (btnJump) {
|
|
29050
29712
|
const rowKey = btnJump.getAttribute("data-row") || "";
|
|
29051
|
-
state.highlightedRowKey = rowKey;
|
|
29052
29713
|
state.filter = "all";
|
|
29053
29714
|
for (const el of document.querySelectorAll("#filterPills [data-filter]")) {
|
|
29054
29715
|
el.classList.toggle("active", el.getAttribute("data-filter") === "all");
|
|
29055
29716
|
}
|
|
29056
29717
|
switchTab("review");
|
|
29057
29718
|
renderReviewList();
|
|
29058
|
-
|
|
29059
|
-
|
|
29719
|
+
selectActiveRow(rowKey, true);
|
|
29720
|
+
return;
|
|
29721
|
+
}
|
|
29722
|
+
|
|
29723
|
+
const clickedCard = ev.target.closest("[data-row-card]");
|
|
29724
|
+
if (clickedCard) {
|
|
29725
|
+
const rk = clickedCard.getAttribute("data-row-card");
|
|
29726
|
+
if (rk && rk !== state.activeRowKey) {
|
|
29727
|
+
selectActiveRow(rk, false);
|
|
29728
|
+
}
|
|
29060
29729
|
}
|
|
29061
29730
|
});
|
|
29062
29731
|
|
|
@@ -29126,14 +29795,54 @@ function safeBearerEquals(headerValue, expectedToken) {
|
|
|
29126
29795
|
if (!headerValue || !headerValue.startsWith("Bearer ")) return false;
|
|
29127
29796
|
return safeTokenEquals(headerValue.slice("Bearer ".length), expectedToken);
|
|
29128
29797
|
}
|
|
29129
|
-
|
|
29798
|
+
var REVIEW_COOKIE_NAME = "memoq_review_token";
|
|
29799
|
+
var REVIEW_COOKIE_MAX_AGE_SECONDS = 31536e3;
|
|
29800
|
+
function readCookieValue(cookieHeader, cookieName) {
|
|
29801
|
+
if (!cookieHeader) return void 0;
|
|
29802
|
+
for (const part of cookieHeader.split(";")) {
|
|
29803
|
+
const eqIndex = part.indexOf("=");
|
|
29804
|
+
if (eqIndex <= 0) continue;
|
|
29805
|
+
const name = part.slice(0, eqIndex).trim();
|
|
29806
|
+
if (name !== cookieName) continue;
|
|
29807
|
+
const value = part.slice(eqIndex + 1).trim();
|
|
29808
|
+
return value || void 0;
|
|
29809
|
+
}
|
|
29810
|
+
return void 0;
|
|
29811
|
+
}
|
|
29812
|
+
function renderReviewUnauthorizedHtml() {
|
|
29813
|
+
return `<!DOCTYPE html>
|
|
29814
|
+
<html lang="zh-CN">
|
|
29815
|
+
<head>
|
|
29816
|
+
<meta charset="utf-8" />
|
|
29817
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
29818
|
+
<title>LangLink memoQ \u5DE5\u4F5C\u53F0\u9700\u8981\u6388\u6743\u94FE\u63A5</title>
|
|
29819
|
+
<style>
|
|
29820
|
+
body { margin: 0; padding: 36px 20px; font: 14px/1.6 "Segoe UI", "Microsoft YaHei UI", sans-serif; background: #f8fafc; color: #0f172a; }
|
|
29821
|
+
.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); }
|
|
29822
|
+
h1 { margin: 0 0 10px; font-size: 18px; }
|
|
29823
|
+
p { margin: 8px 0; color: #334155; }
|
|
29824
|
+
code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
|
|
29825
|
+
</style>
|
|
29826
|
+
</head>
|
|
29827
|
+
<body>
|
|
29828
|
+
<main class="card">
|
|
29829
|
+
<h1>\u9700\u8981\u6709\u6548\u7684 memoQ \u5BA1\u6821\u5DE5\u4F5C\u53F0\u6388\u6743\u94FE\u63A5</h1>
|
|
29830
|
+
<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>
|
|
29831
|
+
<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>
|
|
29832
|
+
<p style="color:#64748b;font-size:12px;">Unauthorized: present a valid persisted review token link via <code>memoq_open_review</code>.</p>
|
|
29833
|
+
</main>
|
|
29834
|
+
</body>
|
|
29835
|
+
</html>`;
|
|
29836
|
+
}
|
|
29837
|
+
function sendHtml(response, statusCode, html, csp, extraHeaders) {
|
|
29130
29838
|
response.writeHead(statusCode, {
|
|
29131
29839
|
"Content-Type": "text/html; charset=utf-8",
|
|
29132
29840
|
"Cache-Control": "no-store",
|
|
29133
29841
|
"Content-Security-Policy": csp,
|
|
29134
29842
|
"Referrer-Policy": "no-referrer",
|
|
29135
29843
|
"X-Frame-Options": "DENY",
|
|
29136
|
-
"X-Content-Type-Options": "nosniff"
|
|
29844
|
+
"X-Content-Type-Options": "nosniff",
|
|
29845
|
+
...extraHeaders
|
|
29137
29846
|
});
|
|
29138
29847
|
response.end(html);
|
|
29139
29848
|
}
|
|
@@ -29147,6 +29856,27 @@ function isAllowedOrigin(originHeader, boundHost, boundPort) {
|
|
|
29147
29856
|
const normalized = originHeader.toLowerCase();
|
|
29148
29857
|
return normalized === `http://${boundHost}:${boundPort}`.toLowerCase() || normalized === `http://localhost:${boundPort}` || normalized === `http://127.0.0.1:${boundPort}`;
|
|
29149
29858
|
}
|
|
29859
|
+
function isAllowedFetchSite(headerValue) {
|
|
29860
|
+
if (headerValue === void 0) return false;
|
|
29861
|
+
const raw = (Array.isArray(headerValue) ? headerValue[0] : headerValue) ?? "";
|
|
29862
|
+
return raw.trim().toLowerCase() === "same-origin";
|
|
29863
|
+
}
|
|
29864
|
+
function isAllowedReviewNavigation(request) {
|
|
29865
|
+
const fetchMode = request.headers["sec-fetch-mode"];
|
|
29866
|
+
const mode = (Array.isArray(fetchMode) ? fetchMode[0] : fetchMode)?.trim().toLowerCase() ?? "";
|
|
29867
|
+
if (mode === "no-cors") {
|
|
29868
|
+
return false;
|
|
29869
|
+
}
|
|
29870
|
+
const fetchSite = request.headers["sec-fetch-site"];
|
|
29871
|
+
const site = (Array.isArray(fetchSite) ? fetchSite[0] : fetchSite)?.trim().toLowerCase() ?? "";
|
|
29872
|
+
if (site === "cross-site" && mode !== "navigate") {
|
|
29873
|
+
return false;
|
|
29874
|
+
}
|
|
29875
|
+
if (mode && mode !== "navigate" && mode !== "same-origin" && mode !== "cors") {
|
|
29876
|
+
return false;
|
|
29877
|
+
}
|
|
29878
|
+
return true;
|
|
29879
|
+
}
|
|
29150
29880
|
async function createMtGateway(options) {
|
|
29151
29881
|
const host = options.host ?? DEFAULT_HOST;
|
|
29152
29882
|
const requestedPort = options.port ?? DEFAULT_PORT;
|
|
@@ -29752,14 +30482,21 @@ async function createMtGateway(options) {
|
|
|
29752
30482
|
response.setHeader("Referrer-Policy", "no-referrer");
|
|
29753
30483
|
response.setHeader("X-Frame-Options", "DENY");
|
|
29754
30484
|
if (method === "GET" && pathname === "/review") {
|
|
29755
|
-
|
|
29756
|
-
|
|
29757
|
-
|
|
30485
|
+
if (!isAllowedReviewNavigation(request)) {
|
|
30486
|
+
sendJson(response, 403, { success: false, error: "Rejected non-navigation review page fetch." });
|
|
30487
|
+
return;
|
|
30488
|
+
}
|
|
30489
|
+
const hasQueryTokenParam = url.searchParams.has("token");
|
|
30490
|
+
const queryToken = url.searchParams.get("token") ?? void 0;
|
|
30491
|
+
const cookieToken = readCookieValue(request.headers.cookie, REVIEW_COOKIE_NAME);
|
|
30492
|
+
const authenticatedByQuery = hasQueryTokenParam && safeTokenEquals(queryToken, reviewToken);
|
|
30493
|
+
const authenticatedByCookie = !hasQueryTokenParam && safeTokenEquals(cookieToken, reviewToken);
|
|
30494
|
+
if (!authenticatedByQuery && !authenticatedByCookie) {
|
|
29758
30495
|
sendHtml(
|
|
29759
30496
|
response,
|
|
29760
30497
|
401,
|
|
29761
|
-
|
|
29762
|
-
|
|
30498
|
+
renderReviewUnauthorizedHtml(),
|
|
30499
|
+
"default-src 'none'; style-src 'unsafe-inline'; frame-ancestors 'none'; base-uri 'none'"
|
|
29763
30500
|
);
|
|
29764
30501
|
return;
|
|
29765
30502
|
}
|
|
@@ -29774,14 +30511,25 @@ async function createMtGateway(options) {
|
|
|
29774
30511
|
reviewToken,
|
|
29775
30512
|
...initialDocName ? { initialDocumentName: initialDocName } : {}
|
|
29776
30513
|
}),
|
|
29777
|
-
csp
|
|
30514
|
+
csp,
|
|
30515
|
+
authenticatedByQuery ? {
|
|
30516
|
+
"Set-Cookie": `${REVIEW_COOKIE_NAME}=${reviewToken}; HttpOnly; SameSite=Strict; Path=/review; Max-Age=${REVIEW_COOKIE_MAX_AGE_SECONDS}`
|
|
30517
|
+
} : void 0
|
|
29778
30518
|
);
|
|
29779
30519
|
return;
|
|
29780
30520
|
}
|
|
30521
|
+
if (!isAllowedFetchSite(request.headers["sec-fetch-site"])) {
|
|
30522
|
+
sendJson(response, 403, { success: false, error: "Cross-site or missing Sec-Fetch-Site review API requests are not allowed." });
|
|
30523
|
+
return;
|
|
30524
|
+
}
|
|
29781
30525
|
const headerToken = request.headers["x-review-token"];
|
|
29782
30526
|
const providedHeader = Array.isArray(headerToken) ? headerToken[0] : headerToken;
|
|
29783
30527
|
if (!safeTokenEquals(providedHeader, reviewToken)) {
|
|
29784
|
-
sendJson(response, 401, {
|
|
30528
|
+
sendJson(response, 401, {
|
|
30529
|
+
success: false,
|
|
30530
|
+
code: "REVIEW_TOKEN_REQUIRED",
|
|
30531
|
+
error: "Valid review token is required."
|
|
30532
|
+
});
|
|
29785
30533
|
return;
|
|
29786
30534
|
}
|
|
29787
30535
|
if (method === "GET" && pathname === "/review/api/state") {
|
|
@@ -30133,16 +30881,32 @@ async function createMtGateway(options) {
|
|
|
30133
30881
|
return;
|
|
30134
30882
|
}
|
|
30135
30883
|
}
|
|
30884
|
+
if (method === "POST" && pathname === CONTROL_ROUTES.shutdown) {
|
|
30885
|
+
const triggerShutdown = options.onShutdown;
|
|
30886
|
+
if (!triggerShutdown) {
|
|
30887
|
+
sendJson(response, 400, { ok: false, error: "Graceful shutdown is not enabled for this host." });
|
|
30888
|
+
return;
|
|
30889
|
+
}
|
|
30890
|
+
response.setHeader("Connection", "close");
|
|
30891
|
+
response.once("finish", () => {
|
|
30892
|
+
setImmediate(() => {
|
|
30893
|
+
void Promise.resolve(triggerShutdown()).catch(() => {
|
|
30894
|
+
});
|
|
30895
|
+
});
|
|
30896
|
+
});
|
|
30897
|
+
sendJson(response, 200, { ok: true, shuttingDown: true });
|
|
30898
|
+
return;
|
|
30899
|
+
}
|
|
30136
30900
|
sendJson(response, 404, { error: `Unknown control route: ${pathname}` });
|
|
30137
30901
|
}
|
|
30138
|
-
await new Promise((
|
|
30902
|
+
await new Promise((resolve7, reject) => {
|
|
30139
30903
|
const onError = (error2) => {
|
|
30140
30904
|
server.off("listening", onListening);
|
|
30141
30905
|
reject(error2);
|
|
30142
30906
|
};
|
|
30143
30907
|
const onListening = () => {
|
|
30144
30908
|
server.off("error", onError);
|
|
30145
|
-
|
|
30909
|
+
resolve7();
|
|
30146
30910
|
};
|
|
30147
30911
|
server.once("error", onError);
|
|
30148
30912
|
server.once("listening", onListening);
|
|
@@ -30162,8 +30926,9 @@ async function createMtGateway(options) {
|
|
|
30162
30926
|
reviewUrl: getReviewUrl(),
|
|
30163
30927
|
close: () => {
|
|
30164
30928
|
options.stagingStore.flush?.();
|
|
30165
|
-
return new Promise((
|
|
30166
|
-
server.close((error2) => error2 ? reject(error2) :
|
|
30929
|
+
return new Promise((resolve7, reject) => {
|
|
30930
|
+
server.close((error2) => error2 ? reject(error2) : resolve7());
|
|
30931
|
+
server.closeIdleConnections?.();
|
|
30167
30932
|
});
|
|
30168
30933
|
},
|
|
30169
30934
|
handleTranslateForTest: processTranslate
|
|
@@ -30172,8 +30937,9 @@ async function createMtGateway(options) {
|
|
|
30172
30937
|
|
|
30173
30938
|
// packages/memoq-bridge/src/dll-assets.ts
|
|
30174
30939
|
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 {
|
|
30940
|
+
import { existsSync as existsSync4, mkdirSync as mkdirSync3, readdirSync, readFileSync as readFileSync4, renameSync as renameSync2, statSync as statSync2, writeFileSync as writeFileSync3 } from "node:fs";
|
|
30941
|
+
import { homedir as homedir2 } from "node:os";
|
|
30942
|
+
import { dirname as dirname4, join as join5, resolve as resolve3 } from "node:path";
|
|
30177
30943
|
import { unzipSync } from "fflate";
|
|
30178
30944
|
var DEFAULT_PLUGIN_DLL_MANIFEST = {
|
|
30179
30945
|
pluginDllName: PLUGIN_DLL_NAME,
|
|
@@ -30186,6 +30952,23 @@ var DEFAULT_PLUGIN_DLL_MANIFEST = {
|
|
|
30186
30952
|
releaseTag: "v1.0.59",
|
|
30187
30953
|
downloadUrl: "https://github.com/langlink-localization/memoq-ai-hub/releases/download/v1.0.59/memoq-ai-hub-win32-x64.zip"
|
|
30188
30954
|
};
|
|
30955
|
+
var MAX_DISCOVERY_DIR_ENTRIES = 200;
|
|
30956
|
+
var MAX_ZIP_INSPECT_BYTES = 200 * 1024 * 1024;
|
|
30957
|
+
var MAX_FAST_ZIP_HASH_BYTES = 25 * 1024 * 1024;
|
|
30958
|
+
var ZIP_CANDIDATE_NAME_RE = /memoq.*(?:ai[-_]?hub|plugin)|memoq\.ai\.hub\.plugin/iu;
|
|
30959
|
+
function acceptedPluginSha256s(explicitExpectedSha256) {
|
|
30960
|
+
const override = (explicitExpectedSha256?.trim() || process.env.MEMOQ_PLUGIN_DLL_SHA256?.trim() || "").toUpperCase();
|
|
30961
|
+
if (override) {
|
|
30962
|
+
return [override];
|
|
30963
|
+
}
|
|
30964
|
+
const all = [DEFAULT_PLUGIN_DLL_MANIFEST.sha256, ...DEFAULT_PLUGIN_DLL_MANIFEST.compatibleSha256s].map((s) => s.trim().toUpperCase()).filter(Boolean);
|
|
30965
|
+
return Array.from(new Set(all));
|
|
30966
|
+
}
|
|
30967
|
+
function matchesAcceptedSha256(actualSha256, explicitExpectedSha256) {
|
|
30968
|
+
const normalized = actualSha256.trim().toUpperCase();
|
|
30969
|
+
if (!normalized) return false;
|
|
30970
|
+
return acceptedPluginSha256s(explicitExpectedSha256).includes(normalized);
|
|
30971
|
+
}
|
|
30189
30972
|
function computeBufferSha256(bytes) {
|
|
30190
30973
|
return createHash2("sha256").update(bytes).digest("hex").toUpperCase();
|
|
30191
30974
|
}
|
|
@@ -30212,6 +30995,15 @@ function parseAllowedAssetUrl(raw) {
|
|
|
30212
30995
|
}
|
|
30213
30996
|
return url;
|
|
30214
30997
|
}
|
|
30998
|
+
function normalizeExpectedShaList(expectedSha256) {
|
|
30999
|
+
if (Array.isArray(expectedSha256)) {
|
|
31000
|
+
return Array.from(new Set(expectedSha256.map((s) => s.trim().toUpperCase()).filter(Boolean)));
|
|
31001
|
+
}
|
|
31002
|
+
if (typeof expectedSha256 === "string" && expectedSha256.trim()) {
|
|
31003
|
+
return [expectedSha256.trim().toUpperCase()];
|
|
31004
|
+
}
|
|
31005
|
+
return [];
|
|
31006
|
+
}
|
|
30215
31007
|
function extractPluginDllFromBytes(bytes, expectedSha256) {
|
|
30216
31008
|
if (bytes.length < 2) {
|
|
30217
31009
|
throw new Error("Downloaded plugin artifact is empty.");
|
|
@@ -30238,9 +31030,10 @@ function extractPluginDllFromBytes(bytes, expectedSha256) {
|
|
|
30238
31030
|
dllBytes = bytes;
|
|
30239
31031
|
}
|
|
30240
31032
|
const actualSha256 = computeBufferSha256(dllBytes);
|
|
30241
|
-
|
|
31033
|
+
const expectedList = normalizeExpectedShaList(expectedSha256);
|
|
31034
|
+
if (expectedList.length > 0 && !expectedList.includes(actualSha256)) {
|
|
30242
31035
|
throw new Error(
|
|
30243
|
-
`Plugin DLL SHA-256 mismatch. Expected ${
|
|
31036
|
+
`Plugin DLL SHA-256 mismatch. Expected ${expectedList.join(" or ")}, actual ${actualSha256}.`
|
|
30244
31037
|
);
|
|
30245
31038
|
}
|
|
30246
31039
|
return { dllBytes, sha256: actualSha256 };
|
|
@@ -30266,50 +31059,212 @@ function getPluginAssetCachePath(dataDir, version2 = DEFAULT_PLUGIN_DLL_MANIFEST
|
|
|
30266
31059
|
const root = dataDir ?? defaultBridgeDataDir();
|
|
30267
31060
|
return join5(root, "assets", version2, PLUGIN_DLL_NAME);
|
|
30268
31061
|
}
|
|
31062
|
+
function writeAtomicCacheDll(cachePath, dllBytes) {
|
|
31063
|
+
mkdirSync3(dirname4(cachePath), { recursive: true });
|
|
31064
|
+
const temp = `${cachePath}.${randomUUID4()}.tmp`;
|
|
31065
|
+
writeFileSync3(temp, dllBytes);
|
|
31066
|
+
renameSync2(temp, cachePath);
|
|
31067
|
+
}
|
|
31068
|
+
function inspectCandidateFile(filePath, source, acceptedShas, maxZipHashBytes) {
|
|
31069
|
+
try {
|
|
31070
|
+
const resolved = resolve3(filePath);
|
|
31071
|
+
if (!existsSync4(resolved)) return null;
|
|
31072
|
+
const stats = statSync2(resolved);
|
|
31073
|
+
if (!stats.isFile()) return null;
|
|
31074
|
+
const lower = resolved.toLowerCase();
|
|
31075
|
+
let isZip = lower.endsWith(".zip");
|
|
31076
|
+
if (!isZip && stats.size >= 2) {
|
|
31077
|
+
const head = readFileSync4(resolved).subarray(0, 2);
|
|
31078
|
+
isZip = head[0] === 80 && head[1] === 75;
|
|
31079
|
+
}
|
|
31080
|
+
if (isZip) {
|
|
31081
|
+
if (stats.size > MAX_ZIP_INSPECT_BYTES) return null;
|
|
31082
|
+
if (stats.size > maxZipHashBytes) {
|
|
31083
|
+
return {
|
|
31084
|
+
path: resolved,
|
|
31085
|
+
kind: "zip",
|
|
31086
|
+
source,
|
|
31087
|
+
sha256: "",
|
|
31088
|
+
sha256MatchesExpected: false,
|
|
31089
|
+
sizeBytes: stats.size
|
|
31090
|
+
};
|
|
31091
|
+
}
|
|
31092
|
+
const bytes2 = readFileSync4(resolved);
|
|
31093
|
+
const { sha256: sha2562 } = extractPluginDllFromBytes(bytes2);
|
|
31094
|
+
return {
|
|
31095
|
+
path: resolved,
|
|
31096
|
+
kind: "zip",
|
|
31097
|
+
source,
|
|
31098
|
+
sha256: sha2562,
|
|
31099
|
+
sha256MatchesExpected: acceptedShas.includes(sha2562),
|
|
31100
|
+
sizeBytes: stats.size
|
|
31101
|
+
};
|
|
31102
|
+
}
|
|
31103
|
+
const bytes = readFileSync4(resolved);
|
|
31104
|
+
if (bytes.length < 2 || bytes[0] !== 77 || bytes[1] !== 90) {
|
|
31105
|
+
return null;
|
|
31106
|
+
}
|
|
31107
|
+
const sha256 = computeBufferSha256(bytes);
|
|
31108
|
+
return {
|
|
31109
|
+
path: resolved,
|
|
31110
|
+
kind: "dll",
|
|
31111
|
+
source,
|
|
31112
|
+
sha256,
|
|
31113
|
+
sha256MatchesExpected: acceptedShas.includes(sha256),
|
|
31114
|
+
sizeBytes: stats.size
|
|
31115
|
+
};
|
|
31116
|
+
} catch {
|
|
31117
|
+
return null;
|
|
31118
|
+
}
|
|
31119
|
+
}
|
|
31120
|
+
function discoverLocalPluginDllCandidates(options = {}) {
|
|
31121
|
+
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
31122
|
+
const version2 = options.version ?? DEFAULT_PLUGIN_DLL_MANIFEST.version;
|
|
31123
|
+
const acceptedShas = acceptedPluginSha256s(options.expectedSha256);
|
|
31124
|
+
const candidates = [];
|
|
31125
|
+
const seenFiles = /* @__PURE__ */ new Set();
|
|
31126
|
+
const pushCandidate = (candidate) => {
|
|
31127
|
+
if (!candidate) return;
|
|
31128
|
+
const key = process.platform === "win32" ? candidate.path.toLowerCase() : candidate.path;
|
|
31129
|
+
if (seenFiles.has(key)) return;
|
|
31130
|
+
seenFiles.add(key);
|
|
31131
|
+
candidates.push(candidate);
|
|
31132
|
+
};
|
|
31133
|
+
const explicitPath = (options.dllPath ?? process.env.MEMOQ_PLUGIN_DLL_PATH ?? "").trim();
|
|
31134
|
+
if (explicitPath) {
|
|
31135
|
+
pushCandidate(inspectCandidateFile(explicitPath, "explicit", acceptedShas, MAX_ZIP_INSPECT_BYTES));
|
|
31136
|
+
}
|
|
31137
|
+
const cachePath = getPluginAssetCachePath(dataDir, version2);
|
|
31138
|
+
pushCandidate(inspectCandidateFile(cachePath, "cache", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
|
|
31139
|
+
for (const hubCandidate of defaultDiscoveryCandidates()) {
|
|
31140
|
+
pushCandidate(inspectCandidateFile(hubCandidate, "memoq-ai-hub", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
|
|
31141
|
+
}
|
|
31142
|
+
for (const extra of options.extraFilePaths ?? []) {
|
|
31143
|
+
if (!extra?.trim()) continue;
|
|
31144
|
+
pushCandidate(inspectCandidateFile(extra, "memoq-addins", acceptedShas, MAX_FAST_ZIP_HASH_BYTES));
|
|
31145
|
+
}
|
|
31146
|
+
const rawDirs = [...options.searchDirs ?? []];
|
|
31147
|
+
if (options.includeDefaultUserDirs !== false) {
|
|
31148
|
+
const home = homedir2();
|
|
31149
|
+
rawDirs.push(process.cwd(), join5(home, "Downloads"), join5(home, "Desktop"));
|
|
31150
|
+
}
|
|
31151
|
+
const seenDirs = /* @__PURE__ */ new Set();
|
|
31152
|
+
for (const rawDir of rawDirs) {
|
|
31153
|
+
if (!rawDir?.trim()) continue;
|
|
31154
|
+
let resolvedDir;
|
|
31155
|
+
try {
|
|
31156
|
+
resolvedDir = resolve3(rawDir.trim());
|
|
31157
|
+
} catch {
|
|
31158
|
+
continue;
|
|
31159
|
+
}
|
|
31160
|
+
const dirKey = process.platform === "win32" ? resolvedDir.toLowerCase() : resolvedDir;
|
|
31161
|
+
if (seenDirs.has(dirKey)) continue;
|
|
31162
|
+
seenDirs.add(dirKey);
|
|
31163
|
+
if (!existsSync4(resolvedDir)) continue;
|
|
31164
|
+
try {
|
|
31165
|
+
const entries = readdirSync(resolvedDir, { withFileTypes: true }).slice(0, MAX_DISCOVERY_DIR_ENTRIES);
|
|
31166
|
+
for (const entry of entries) {
|
|
31167
|
+
if (!entry.isFile()) continue;
|
|
31168
|
+
const lowerName = entry.name.toLowerCase();
|
|
31169
|
+
if (lowerName === PLUGIN_DLL_NAME.toLowerCase()) {
|
|
31170
|
+
pushCandidate(
|
|
31171
|
+
inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas, MAX_FAST_ZIP_HASH_BYTES)
|
|
31172
|
+
);
|
|
31173
|
+
} else if (lowerName.endsWith(".zip") && ZIP_CANDIDATE_NAME_RE.test(entry.name)) {
|
|
31174
|
+
pushCandidate(
|
|
31175
|
+
inspectCandidateFile(join5(resolvedDir, entry.name), "local-folder", acceptedShas, MAX_FAST_ZIP_HASH_BYTES)
|
|
31176
|
+
);
|
|
31177
|
+
}
|
|
31178
|
+
}
|
|
31179
|
+
} catch {
|
|
31180
|
+
}
|
|
31181
|
+
}
|
|
31182
|
+
return candidates.sort((a, b) => {
|
|
31183
|
+
const matchDiff = Number(b.sha256MatchesExpected) - Number(a.sha256MatchesExpected);
|
|
31184
|
+
if (matchDiff !== 0) return matchDiff;
|
|
31185
|
+
return Number(b.kind === "dll") - Number(a.kind === "dll");
|
|
31186
|
+
});
|
|
31187
|
+
}
|
|
30269
31188
|
async function resolvePluginDllAsset(options = {}) {
|
|
30270
31189
|
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
30271
31190
|
const version2 = options.version ?? DEFAULT_PLUGIN_DLL_MANIFEST.version;
|
|
30272
|
-
const
|
|
31191
|
+
const acceptedShas = acceptedPluginSha256s(options.expectedSha256);
|
|
31192
|
+
const expectedDisplay = acceptedShas.join(" or ");
|
|
31193
|
+
const cachePath = getPluginAssetCachePath(dataDir, version2);
|
|
30273
31194
|
const explicitPath = (options.dllPath ?? process.env.MEMOQ_PLUGIN_DLL_PATH ?? "").trim();
|
|
30274
31195
|
if (explicitPath) {
|
|
30275
31196
|
const resolved = resolve3(explicitPath);
|
|
30276
31197
|
if (!existsSync4(resolved)) {
|
|
30277
31198
|
throw new Error(`Configured MEMOQ_PLUGIN_DLL_PATH does not exist: ${resolved}`);
|
|
30278
31199
|
}
|
|
30279
|
-
const
|
|
30280
|
-
|
|
30281
|
-
|
|
31200
|
+
const rawBytes2 = readFileSync4(resolved);
|
|
31201
|
+
const isZip = rawBytes2.length >= 2 && rawBytes2[0] === 80 && rawBytes2[1] === 75;
|
|
31202
|
+
if (isZip) {
|
|
31203
|
+
const extracted = extractPluginDllFromBytes(
|
|
31204
|
+
rawBytes2,
|
|
31205
|
+
options.allowUnverifiedLocalDev ? void 0 : acceptedShas
|
|
31206
|
+
);
|
|
31207
|
+
writeAtomicCacheDll(cachePath, extracted.dllBytes);
|
|
31208
|
+
return {
|
|
31209
|
+
path: cachePath,
|
|
31210
|
+
sha256: extracted.sha256,
|
|
31211
|
+
version: version2,
|
|
31212
|
+
source: "explicit",
|
|
31213
|
+
verified: acceptedShas.includes(extracted.sha256)
|
|
31214
|
+
};
|
|
31215
|
+
}
|
|
31216
|
+
const isPe = rawBytes2.length >= 2 && rawBytes2[0] === 77 && rawBytes2[1] === 90;
|
|
31217
|
+
if (!isPe) {
|
|
31218
|
+
throw new Error(`File is neither a PE DLL nor a ZIP archive containing ${PLUGIN_DLL_NAME}: ${resolved}`);
|
|
31219
|
+
}
|
|
31220
|
+
const sha2562 = computeBufferSha256(rawBytes2);
|
|
31221
|
+
const verified = acceptedShas.includes(sha2562);
|
|
31222
|
+
if (!options.allowUnverifiedLocalDev && acceptedShas.length > 0 && !verified) {
|
|
31223
|
+
throw new Error(`Plugin DLL SHA-256 mismatch at ${resolved}. Expected ${expectedDisplay}, actual ${sha2562}.`);
|
|
30282
31224
|
}
|
|
30283
31225
|
return {
|
|
30284
31226
|
path: resolved,
|
|
30285
31227
|
sha256: sha2562,
|
|
30286
31228
|
version: version2,
|
|
30287
31229
|
source: "explicit",
|
|
30288
|
-
verified
|
|
31230
|
+
verified
|
|
30289
31231
|
};
|
|
30290
31232
|
}
|
|
30291
|
-
const cachePath = getPluginAssetCachePath(dataDir, version2);
|
|
30292
31233
|
if (existsSync4(cachePath)) {
|
|
30293
31234
|
const sha2562 = computeFileSha256(cachePath);
|
|
30294
|
-
if (
|
|
31235
|
+
if (acceptedShas.length === 0 || acceptedShas.includes(sha2562)) {
|
|
30295
31236
|
return {
|
|
30296
31237
|
path: cachePath,
|
|
30297
31238
|
sha256: sha2562,
|
|
30298
31239
|
version: version2,
|
|
30299
31240
|
source: "cache",
|
|
30300
|
-
verified:
|
|
31241
|
+
verified: acceptedShas.includes(sha2562)
|
|
30301
31242
|
};
|
|
30302
31243
|
}
|
|
30303
31244
|
}
|
|
30304
31245
|
const discoveryPaths = [...options.searchPaths ?? [], ...defaultDiscoveryCandidates()];
|
|
30305
31246
|
for (const candidate of discoveryPaths) {
|
|
30306
31247
|
if (!candidate || !existsSync4(candidate)) continue;
|
|
30307
|
-
const
|
|
30308
|
-
|
|
30309
|
-
|
|
30310
|
-
|
|
30311
|
-
|
|
30312
|
-
|
|
31248
|
+
const rawBytes2 = readFileSync4(candidate);
|
|
31249
|
+
const isZip = rawBytes2.length >= 2 && rawBytes2[0] === 80 && rawBytes2[1] === 75;
|
|
31250
|
+
if (isZip) {
|
|
31251
|
+
try {
|
|
31252
|
+
const extracted = extractPluginDllFromBytes(rawBytes2, acceptedShas);
|
|
31253
|
+
writeAtomicCacheDll(cachePath, extracted.dllBytes);
|
|
31254
|
+
return {
|
|
31255
|
+
path: cachePath,
|
|
31256
|
+
sha256: extracted.sha256,
|
|
31257
|
+
version: version2,
|
|
31258
|
+
source: "local-discovery",
|
|
31259
|
+
verified: true
|
|
31260
|
+
};
|
|
31261
|
+
} catch {
|
|
31262
|
+
continue;
|
|
31263
|
+
}
|
|
31264
|
+
}
|
|
31265
|
+
const sha2562 = computeBufferSha256(rawBytes2);
|
|
31266
|
+
if (acceptedShas.length > 0 && !acceptedShas.includes(sha2562)) continue;
|
|
31267
|
+
writeAtomicCacheDll(cachePath, rawBytes2);
|
|
30313
31268
|
return {
|
|
30314
31269
|
path: cachePath,
|
|
30315
31270
|
sha256: sha2562,
|
|
@@ -30318,9 +31273,46 @@ async function resolvePluginDllAsset(options = {}) {
|
|
|
30318
31273
|
verified: true
|
|
30319
31274
|
};
|
|
30320
31275
|
}
|
|
31276
|
+
if (options.searchDirs && options.searchDirs.length > 0 || options.includeDefaultUserDirs === true) {
|
|
31277
|
+
const folderCandidates = discoverLocalPluginDllCandidates({
|
|
31278
|
+
dataDir,
|
|
31279
|
+
...options.expectedSha256 === void 0 ? {} : { expectedSha256: options.expectedSha256 },
|
|
31280
|
+
version: version2,
|
|
31281
|
+
searchDirs: options.searchDirs ?? [],
|
|
31282
|
+
includeDefaultUserDirs: options.includeDefaultUserDirs === true
|
|
31283
|
+
});
|
|
31284
|
+
for (const candidate of folderCandidates) {
|
|
31285
|
+
try {
|
|
31286
|
+
const rawBytes2 = readFileSync4(candidate.path);
|
|
31287
|
+
if (candidate.kind === "zip") {
|
|
31288
|
+
const extracted = extractPluginDllFromBytes(rawBytes2, acceptedShas);
|
|
31289
|
+
writeAtomicCacheDll(cachePath, extracted.dllBytes);
|
|
31290
|
+
return {
|
|
31291
|
+
path: cachePath,
|
|
31292
|
+
sha256: extracted.sha256,
|
|
31293
|
+
version: version2,
|
|
31294
|
+
source: "local-discovery",
|
|
31295
|
+
verified: true
|
|
31296
|
+
};
|
|
31297
|
+
}
|
|
31298
|
+
const sha2562 = computeBufferSha256(rawBytes2);
|
|
31299
|
+
if (acceptedShas.length > 0 && !acceptedShas.includes(sha2562)) continue;
|
|
31300
|
+
writeAtomicCacheDll(cachePath, rawBytes2);
|
|
31301
|
+
return {
|
|
31302
|
+
path: cachePath,
|
|
31303
|
+
sha256: sha2562,
|
|
31304
|
+
version: version2,
|
|
31305
|
+
source: "local-discovery",
|
|
31306
|
+
verified: true
|
|
31307
|
+
};
|
|
31308
|
+
} catch {
|
|
31309
|
+
continue;
|
|
31310
|
+
}
|
|
31311
|
+
}
|
|
31312
|
+
}
|
|
30321
31313
|
if (options.allowDownload === false) {
|
|
30322
31314
|
throw new Error(
|
|
30323
|
-
`Plugin DLL ${PLUGIN_DLL_NAME} is not cached locally (expected SHA-256 ${
|
|
31315
|
+
`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
31316
|
);
|
|
30325
31317
|
}
|
|
30326
31318
|
const rawUrl = (options.downloadUrl ?? process.env.MEMOQ_PLUGIN_DLL_URL ?? DEFAULT_PLUGIN_DLL_MANIFEST.downloadUrl).trim();
|
|
@@ -30331,25 +31323,22 @@ async function resolvePluginDllAsset(options = {}) {
|
|
|
30331
31323
|
throw new Error(`Failed to download ${PLUGIN_DLL_NAME} (${response.status} ${response.statusText}).`);
|
|
30332
31324
|
}
|
|
30333
31325
|
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);
|
|
31326
|
+
const { dllBytes, sha256 } = extractPluginDllFromBytes(rawBytes, acceptedShas);
|
|
31327
|
+
writeAtomicCacheDll(cachePath, dllBytes);
|
|
30339
31328
|
return {
|
|
30340
31329
|
path: cachePath,
|
|
30341
31330
|
sha256,
|
|
30342
31331
|
version: version2,
|
|
30343
31332
|
source: "downloaded",
|
|
30344
|
-
verified:
|
|
31333
|
+
verified: acceptedShas.includes(sha256)
|
|
30345
31334
|
};
|
|
30346
31335
|
}
|
|
30347
31336
|
|
|
30348
31337
|
// packages/memoq-bridge/src/dll-installer.ts
|
|
30349
|
-
import { execFile } from "node:child_process";
|
|
31338
|
+
import { execFile, execFileSync } from "node:child_process";
|
|
30350
31339
|
import { randomUUID as randomUUID5 } from "node:crypto";
|
|
30351
31340
|
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";
|
|
31341
|
+
import { basename, join as join6, resolve as resolve4, win32 } from "node:path";
|
|
30353
31342
|
import { promisify } from "node:util";
|
|
30354
31343
|
var execFileAsync = promisify(execFile);
|
|
30355
31344
|
var SUPPORTED_VERSIONS = ["12", "11", "10"];
|
|
@@ -30378,18 +31367,92 @@ function readClientDevConfigState(programDataDir) {
|
|
|
30378
31367
|
return { path: filePath, exists: true, loadUnsignedPluginsEnabled: false };
|
|
30379
31368
|
}
|
|
30380
31369
|
}
|
|
31370
|
+
function discoverWindowsMemoQRoots(helperPath) {
|
|
31371
|
+
if (!helperPath || !existsSync5(helperPath)) {
|
|
31372
|
+
return [];
|
|
31373
|
+
}
|
|
31374
|
+
try {
|
|
31375
|
+
const stdout = execFileSync(helperPath, ["--discover-memoq"], {
|
|
31376
|
+
encoding: "utf8",
|
|
31377
|
+
timeout: 5e3,
|
|
31378
|
+
windowsHide: true
|
|
31379
|
+
});
|
|
31380
|
+
const parsed = JSON.parse(stdout.trim());
|
|
31381
|
+
if (!parsed?.ok || !Array.isArray(parsed.roots)) {
|
|
31382
|
+
return [];
|
|
31383
|
+
}
|
|
31384
|
+
const results = [];
|
|
31385
|
+
for (const entry of parsed.roots) {
|
|
31386
|
+
const rootDir = typeof entry?.rootDir === "string" ? entry.rootDir.trim() : "";
|
|
31387
|
+
if (!rootDir) continue;
|
|
31388
|
+
const version2 = typeof entry?.version === "string" && entry.version.trim() ? entry.version.trim() : "custom";
|
|
31389
|
+
const srcRaw = typeof entry?.source === "string" ? entry.source.trim() : "";
|
|
31390
|
+
const source = srcRaw === "running-process" || srcRaw === "registry" || srcRaw === "drive-scan" ? srcRaw : "drive-scan";
|
|
31391
|
+
results.push({ version: version2, rootDir, source });
|
|
31392
|
+
}
|
|
31393
|
+
return results;
|
|
31394
|
+
} catch {
|
|
31395
|
+
return [];
|
|
31396
|
+
}
|
|
31397
|
+
}
|
|
31398
|
+
function isProtectedWindowsPath(targetPath, programDataDir) {
|
|
31399
|
+
const checkOne = (raw) => {
|
|
31400
|
+
if (!raw || !raw.trim()) return false;
|
|
31401
|
+
const norm = raw.trim().replace(/\//gu, "\\").toLowerCase();
|
|
31402
|
+
const envProtected = [
|
|
31403
|
+
process.env.ProgramFiles,
|
|
31404
|
+
process.env["ProgramFiles(x86)"],
|
|
31405
|
+
process.env.ProgramData,
|
|
31406
|
+
process.env.SystemRoot,
|
|
31407
|
+
process.env.WINDIR
|
|
31408
|
+
].filter((v) => Boolean(v && v.trim())).map((v) => v.trim().replace(/\//gu, "\\").replace(/\\+$/u, "").toLowerCase());
|
|
31409
|
+
for (const base of envProtected) {
|
|
31410
|
+
if (norm === base || norm.startsWith(`${base}\\`)) {
|
|
31411
|
+
return true;
|
|
31412
|
+
}
|
|
31413
|
+
}
|
|
31414
|
+
return /^[a-z]:\\(?:program files(?: \(x86\))?|programdata|windows)(?:\\|$)/iu.test(norm);
|
|
31415
|
+
};
|
|
31416
|
+
return checkOne(targetPath) || (programDataDir ? checkOne(programDataDir) : false);
|
|
31417
|
+
}
|
|
30381
31418
|
function detectMemoQInstallations(options = {}) {
|
|
30382
|
-
const
|
|
31419
|
+
const platform = options.platform ?? process.platform;
|
|
30383
31420
|
const clientDevConfig = readClientDevConfigState(options.programDataDir);
|
|
30384
31421
|
const candidates = [];
|
|
30385
31422
|
const seen = /* @__PURE__ */ new Set();
|
|
30386
31423
|
if (options.customInstallDir?.trim()) {
|
|
30387
31424
|
const customRoot = options.customInstallDir.trim();
|
|
30388
31425
|
const versionMatch = /memoq[-_\s]?(\d+)/iu.exec(basename(customRoot));
|
|
30389
|
-
candidates.push({ version: versionMatch?.[1] ?? "custom", rootDir: customRoot });
|
|
31426
|
+
candidates.push({ version: versionMatch?.[1] ?? "custom", rootDir: customRoot, source: "custom" });
|
|
30390
31427
|
}
|
|
30391
|
-
|
|
30392
|
-
|
|
31428
|
+
if (options.defaultRoots !== void 0) {
|
|
31429
|
+
for (const item of options.defaultRoots) {
|
|
31430
|
+
candidates.push({ ...item, source: "default" });
|
|
31431
|
+
}
|
|
31432
|
+
} else {
|
|
31433
|
+
if (platform === "win32" && options.skipHostDiscovery !== true) {
|
|
31434
|
+
let helperPath = options.helperExecutablePath ?? null;
|
|
31435
|
+
if (!helperPath) {
|
|
31436
|
+
try {
|
|
31437
|
+
helperPath = ensureRunnableHelperBinary({
|
|
31438
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31439
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot }
|
|
31440
|
+
});
|
|
31441
|
+
} catch {
|
|
31442
|
+
helperPath = null;
|
|
31443
|
+
}
|
|
31444
|
+
}
|
|
31445
|
+
for (const discovered of discoverWindowsMemoQRoots(helperPath)) {
|
|
31446
|
+
candidates.push({
|
|
31447
|
+
version: discovered.version,
|
|
31448
|
+
rootDir: discovered.rootDir,
|
|
31449
|
+
source: discovered.source
|
|
31450
|
+
});
|
|
31451
|
+
}
|
|
31452
|
+
}
|
|
31453
|
+
for (const item of defaultMemoQRooDirs()) {
|
|
31454
|
+
candidates.push({ ...item, source: "default" });
|
|
31455
|
+
}
|
|
30393
31456
|
}
|
|
30394
31457
|
const installations = [];
|
|
30395
31458
|
for (const candidate of candidates) {
|
|
@@ -30404,7 +31467,7 @@ function detectMemoQInstallations(options = {}) {
|
|
|
30404
31467
|
const legacyPluginInstalled = existsSync5(legacyTarget);
|
|
30405
31468
|
const pluginSha256 = pluginInstalled ? computeFileSha256(pluginTarget) : "";
|
|
30406
31469
|
const sha256MatchesExpected = Boolean(
|
|
30407
|
-
pluginInstalled && (options.expectedSha256
|
|
31470
|
+
pluginInstalled && matchesAcceptedSha256(pluginSha256, options.expectedSha256)
|
|
30408
31471
|
);
|
|
30409
31472
|
let status = "not_installed";
|
|
30410
31473
|
if (pluginInstalled && clientDevConfig.loadUnsignedPluginsEnabled && !legacyPluginInstalled) {
|
|
@@ -30422,7 +31485,8 @@ function detectMemoQInstallations(options = {}) {
|
|
|
30422
31485
|
pluginSha256,
|
|
30423
31486
|
sha256MatchesExpected,
|
|
30424
31487
|
legacyPluginInstalled,
|
|
30425
|
-
status
|
|
31488
|
+
status,
|
|
31489
|
+
...candidate.source === void 0 ? {} : { discoverySource: candidate.source }
|
|
30426
31490
|
});
|
|
30427
31491
|
}
|
|
30428
31492
|
return { clientDevConfig, installations };
|
|
@@ -30564,13 +31628,243 @@ async function uninstallPluginWithHelper(options) {
|
|
|
30564
31628
|
}
|
|
30565
31629
|
return result;
|
|
30566
31630
|
}
|
|
31631
|
+
function buildPluginInstallPlan(options = {}) {
|
|
31632
|
+
const integration = getIntegrationStatus(options);
|
|
31633
|
+
const platform = integration.platform;
|
|
31634
|
+
const acceptedShas = acceptedPluginSha256s(options.expectedSha256);
|
|
31635
|
+
const expectedSha256 = acceptedShas[0] ?? integration.expectedPluginSha256;
|
|
31636
|
+
const effectiveProgramData = options.programDataDir ?? process.env.ProgramData ?? "C:\\ProgramData";
|
|
31637
|
+
const extraFilePaths = integration.installations.filter((item) => item.pluginInstalled).map((item) => item.pluginTarget);
|
|
31638
|
+
const discoveredDlls = discoverLocalPluginDllCandidates({
|
|
31639
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31640
|
+
...options.dllPath === void 0 ? {} : { dllPath: options.dllPath },
|
|
31641
|
+
...options.expectedSha256 === void 0 ? {} : { expectedSha256: options.expectedSha256 },
|
|
31642
|
+
...options.searchDirs === void 0 ? {} : { searchDirs: options.searchDirs },
|
|
31643
|
+
extraFilePaths,
|
|
31644
|
+
includeDefaultUserDirs: options.includeDefaultUserDirs ?? options.skipHostDiscovery !== true
|
|
31645
|
+
});
|
|
31646
|
+
const explicitDllPath = (options.dllPath ?? process.env.MEMOQ_PLUGIN_DLL_PATH ?? "").trim();
|
|
31647
|
+
const explicitResolved = explicitDllPath ? resolve4(explicitDllPath) : "";
|
|
31648
|
+
const explicitCandidate = explicitResolved ? discoveredDlls.find(
|
|
31649
|
+
(c) => (process.platform === "win32" ? c.path.toLowerCase() === explicitResolved.toLowerCase() : c.path === explicitResolved) || c.source === "explicit"
|
|
31650
|
+
) ?? null : null;
|
|
31651
|
+
const selectedDllCandidate = explicitDllPath ? explicitCandidate : discoveredDlls.find((c) => c.sha256MatchesExpected) ?? discoveredDlls.find((c) => c.kind === "zip" && c.sha256 === "") ?? null;
|
|
31652
|
+
const blockers = [];
|
|
31653
|
+
if (platform !== "win32") {
|
|
31654
|
+
blockers.push(`\u5F53\u524D\u7CFB\u7EDF (${platform}) \u4E0D\u652F\u6301\u5B89\u88C5 memoQ Desktop Windows \u63D2\u4EF6\u3002`);
|
|
31655
|
+
}
|
|
31656
|
+
if (options.customInstallDir?.trim()) {
|
|
31657
|
+
const customAddins = join6(options.customInstallDir.trim(), "Addins");
|
|
31658
|
+
if (!existsSync5(customAddins)) {
|
|
31659
|
+
blockers.push(`\u6307\u5B9A\u7684 memoQ \u76EE\u5F55\u4E0B\u672A\u627E\u5230 Addins \u5B50\u76EE\u5F55: ${customAddins}`);
|
|
31660
|
+
}
|
|
31661
|
+
}
|
|
31662
|
+
if (platform === "win32" && integration.installations.length === 0) {
|
|
31663
|
+
blockers.push(
|
|
31664
|
+
"\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"
|
|
31665
|
+
);
|
|
31666
|
+
}
|
|
31667
|
+
if (explicitDllPath) {
|
|
31668
|
+
if (!existsSync5(explicitResolved)) {
|
|
31669
|
+
blockers.push(`\u6307\u5B9A\u7684 DLL / ZIP \u8DEF\u5F84\u4E0D\u5B58\u5728: ${explicitResolved}`);
|
|
31670
|
+
} else if (!explicitCandidate) {
|
|
31671
|
+
blockers.push(`\u6307\u5B9A\u6587\u4EF6\u4E0D\u662F\u6709\u6548\u7684 ${PLUGIN_DLL_NAME} \u6216\u5305\u542B\u8BE5 DLL \u7684 ZIP \u5305: ${explicitResolved}`);
|
|
31672
|
+
} else if (!options.allowUnverifiedLocalDev && explicitCandidate.kind === "dll" && !explicitCandidate.sha256MatchesExpected) {
|
|
31673
|
+
blockers.push(
|
|
31674
|
+
`\u6307\u5B9A DLL \u7684 SHA-256 (${explicitCandidate.sha256}) \u4E0E\u9884\u671F (${acceptedShas.join(" or ")}) \u4E0D\u5339\u914D\u3002`
|
|
31675
|
+
);
|
|
31676
|
+
}
|
|
31677
|
+
} else if (!selectedDllCandidate && options.allowDownload === false) {
|
|
31678
|
+
blockers.push(
|
|
31679
|
+
`\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`
|
|
31680
|
+
);
|
|
31681
|
+
}
|
|
31682
|
+
let recommendedInst = null;
|
|
31683
|
+
if (options.customInstallDir?.trim()) {
|
|
31684
|
+
const normCustom = options.customInstallDir.trim().toLowerCase();
|
|
31685
|
+
recommendedInst = integration.installations.find((item) => item.rootDir.toLowerCase() === normCustom) ?? null;
|
|
31686
|
+
}
|
|
31687
|
+
if (!recommendedInst) {
|
|
31688
|
+
recommendedInst = integration.installations.find((item) => item.status === "not_installed" || item.status === "needs_repair") ?? integration.installations[0] ?? null;
|
|
31689
|
+
}
|
|
31690
|
+
const recommendedMemoqRoot = recommendedInst?.rootDir ?? null;
|
|
31691
|
+
const targetDllPath = recommendedInst?.pluginTarget ?? null;
|
|
31692
|
+
const clientDevConfigAction = !integration.clientDevConfig.exists ? "create_new" : integration.clientDevConfig.loadUnsignedPluginsEnabled ? "already_enabled" : "backup_and_merge";
|
|
31693
|
+
const requiresElevation = Boolean(
|
|
31694
|
+
platform === "win32" && recommendedMemoqRoot && isProtectedWindowsPath(recommendedMemoqRoot, effectiveProgramData)
|
|
31695
|
+
);
|
|
31696
|
+
const willDownloadFromRelease = !selectedDllCandidate && !explicitDllPath;
|
|
31697
|
+
return {
|
|
31698
|
+
platform,
|
|
31699
|
+
operation: "copy",
|
|
31700
|
+
preservesOriginalSource: true,
|
|
31701
|
+
readyToInstall: blockers.length === 0 && Boolean(recommendedMemoqRoot),
|
|
31702
|
+
alreadyInstalled: integration.status === "installed",
|
|
31703
|
+
canReuseExisting: integration.canReuseExisting,
|
|
31704
|
+
blockers,
|
|
31705
|
+
expectedPluginDllName: integration.expectedPluginDllName,
|
|
31706
|
+
expectedPluginVersion: integration.expectedPluginVersion,
|
|
31707
|
+
expectedSha256,
|
|
31708
|
+
acceptedSha256s: acceptedShas,
|
|
31709
|
+
recommendedMemoqRoot,
|
|
31710
|
+
installations: integration.installations,
|
|
31711
|
+
discoveredDlls,
|
|
31712
|
+
selectedDllCandidate,
|
|
31713
|
+
willDownloadFromRelease,
|
|
31714
|
+
downloadUrl: DEFAULT_PLUGIN_DLL_MANIFEST.downloadUrl,
|
|
31715
|
+
plannedChanges: {
|
|
31716
|
+
sourceDllPath: selectedDllCandidate?.path ?? null,
|
|
31717
|
+
sourceKind: selectedDllCandidate ? selectedDllCandidate.kind : "release-download",
|
|
31718
|
+
targetDllPath,
|
|
31719
|
+
clientDevConfigPath: integration.clientDevConfig.path,
|
|
31720
|
+
clientDevConfigAction,
|
|
31721
|
+
removesLegacyDll: Boolean(recommendedInst?.legacyPluginInstalled),
|
|
31722
|
+
removesMotw: true,
|
|
31723
|
+
requiresElevation,
|
|
31724
|
+
expectedSha256: selectedDllCandidate?.sha256 || expectedSha256
|
|
31725
|
+
}
|
|
31726
|
+
};
|
|
31727
|
+
}
|
|
31728
|
+
async function executeConfirmedPluginInstall(options = {}) {
|
|
31729
|
+
if (options.confirmed !== true) {
|
|
31730
|
+
throw new Error(
|
|
31731
|
+
"Confirmation required: present plannedChanges to the user and pass confirmed: true after explicit approval."
|
|
31732
|
+
);
|
|
31733
|
+
}
|
|
31734
|
+
const integrationBefore = getIntegrationStatus({
|
|
31735
|
+
...options,
|
|
31736
|
+
...options.memoqRoot?.trim() && !options.customInstallDir?.trim() ? { customInstallDir: options.memoqRoot.trim() } : {}
|
|
31737
|
+
});
|
|
31738
|
+
if (integrationBefore.platform !== "win32") {
|
|
31739
|
+
throw new Error(`memoQ plugin installation is only supported on Windows (current: ${integrationBefore.platform}).`);
|
|
31740
|
+
}
|
|
31741
|
+
let targetRoot = options.memoqRoot?.trim() || options.customInstallDir?.trim() || "";
|
|
31742
|
+
if (targetRoot) {
|
|
31743
|
+
const addins = join6(targetRoot, "Addins");
|
|
31744
|
+
if (!existsSync5(addins)) {
|
|
31745
|
+
throw new Error(`memoQ Addins directory was not found: ${addins}`);
|
|
31746
|
+
}
|
|
31747
|
+
} else if (integrationBefore.installations.length === 1) {
|
|
31748
|
+
targetRoot = integrationBefore.installations[0].rootDir;
|
|
31749
|
+
} else if (integrationBefore.installations.length > 1) {
|
|
31750
|
+
throw new Error(
|
|
31751
|
+
`Detected multiple memoQ installations (${integrationBefore.installations.map((i) => i.rootDir).join(", ")}). Please specify memoqRoot explicitly.`
|
|
31752
|
+
);
|
|
31753
|
+
} else {
|
|
31754
|
+
throw new Error("No memoQ installation directory was found (not_found). Please provide memoqRoot.");
|
|
31755
|
+
}
|
|
31756
|
+
const siblingDllPaths = integrationBefore.installations.filter((item) => item.pluginInstalled).map((item) => item.pluginTarget);
|
|
31757
|
+
const sourceAsset = await resolvePluginDllAsset({
|
|
31758
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31759
|
+
...options.dllPath === void 0 ? {} : { dllPath: options.dllPath },
|
|
31760
|
+
...options.downloadUrl === void 0 ? {} : { downloadUrl: options.downloadUrl },
|
|
31761
|
+
...options.expectedSha256 === void 0 ? {} : { expectedSha256: options.expectedSha256 },
|
|
31762
|
+
...options.allowDownload === void 0 ? {} : { allowDownload: options.allowDownload },
|
|
31763
|
+
...options.allowUnverifiedLocalDev === void 0 ? {} : { allowUnverifiedLocalDev: options.allowUnverifiedLocalDev },
|
|
31764
|
+
searchPaths: siblingDllPaths,
|
|
31765
|
+
...options.searchDirs === void 0 ? {} : { searchDirs: options.searchDirs },
|
|
31766
|
+
includeDefaultUserDirs: options.includeDefaultUserDirs ?? options.skipHostDiscovery !== true
|
|
31767
|
+
});
|
|
31768
|
+
const effectiveProgramData = options.programDataDir ?? process.env.ProgramData ?? "C:\\ProgramData";
|
|
31769
|
+
const shouldElevate = options.elevate ?? isProtectedWindowsPath(targetRoot, effectiveProgramData);
|
|
31770
|
+
const baseInstallParams = {
|
|
31771
|
+
memoqRoot: targetRoot,
|
|
31772
|
+
dllSource: sourceAsset.path,
|
|
31773
|
+
dllSha256: sourceAsset.sha256,
|
|
31774
|
+
programDataDir: effectiveProgramData,
|
|
31775
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31776
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
31777
|
+
...options.helperExecutablePath === void 0 ? {} : { helperExecutablePath: options.helperExecutablePath }
|
|
31778
|
+
};
|
|
31779
|
+
let result;
|
|
31780
|
+
try {
|
|
31781
|
+
result = await installPluginWithHelper({
|
|
31782
|
+
...baseInstallParams,
|
|
31783
|
+
elevate: shouldElevate
|
|
31784
|
+
});
|
|
31785
|
+
} catch (error2) {
|
|
31786
|
+
const message = error2 instanceof Error ? error2.message : String(error2);
|
|
31787
|
+
if (options.elevate === void 0 && !shouldElevate && /access|denied|unauthorized|permission/iu.test(message)) {
|
|
31788
|
+
result = await installPluginWithHelper({
|
|
31789
|
+
...baseInstallParams,
|
|
31790
|
+
elevate: true
|
|
31791
|
+
});
|
|
31792
|
+
} else {
|
|
31793
|
+
throw error2;
|
|
31794
|
+
}
|
|
31795
|
+
}
|
|
31796
|
+
const integrationAfter = getIntegrationStatus({
|
|
31797
|
+
...options,
|
|
31798
|
+
customInstallDir: targetRoot
|
|
31799
|
+
});
|
|
31800
|
+
return {
|
|
31801
|
+
ok: true,
|
|
31802
|
+
operation: "copy",
|
|
31803
|
+
preservesOriginalSource: true,
|
|
31804
|
+
sourceAsset,
|
|
31805
|
+
result,
|
|
31806
|
+
integration: integrationAfter,
|
|
31807
|
+
nextSteps: [
|
|
31808
|
+
"\u5B8C\u5168\u5173\u95ED\u5E76\u91CD\u65B0\u542F\u52A8 memoQ\uFF08memoQ \u4EC5\u5728\u542F\u52A8\u65F6\u626B\u63CF Addins \u76EE\u5F55\uFF09\u3002",
|
|
31809
|
+
"\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"
|
|
31810
|
+
]
|
|
31811
|
+
};
|
|
31812
|
+
}
|
|
31813
|
+
async function executeConfirmedPluginUninstall(options = {}) {
|
|
31814
|
+
if (options.confirmed !== true) {
|
|
31815
|
+
throw new Error(
|
|
31816
|
+
"Confirmation required: pass confirmed: true after explicit user approval to uninstall the memoQ plugin."
|
|
31817
|
+
);
|
|
31818
|
+
}
|
|
31819
|
+
const integrationBefore = getIntegrationStatus({
|
|
31820
|
+
...options,
|
|
31821
|
+
...options.memoqRoot?.trim() && !options.customInstallDir?.trim() ? { customInstallDir: options.memoqRoot.trim() } : {}
|
|
31822
|
+
});
|
|
31823
|
+
if (integrationBefore.platform !== "win32") {
|
|
31824
|
+
throw new Error(`memoQ plugin uninstallation is only supported on Windows (current: ${integrationBefore.platform}).`);
|
|
31825
|
+
}
|
|
31826
|
+
let targetRoot = options.memoqRoot?.trim() || options.customInstallDir?.trim() || "";
|
|
31827
|
+
if (!targetRoot) {
|
|
31828
|
+
const installedRoots = integrationBefore.installations.filter((item) => item.pluginInstalled);
|
|
31829
|
+
if (installedRoots.length === 1) {
|
|
31830
|
+
targetRoot = installedRoots[0].rootDir;
|
|
31831
|
+
} else if (integrationBefore.installations.length === 1) {
|
|
31832
|
+
targetRoot = integrationBefore.installations[0].rootDir;
|
|
31833
|
+
} else if (installedRoots.length > 1) {
|
|
31834
|
+
throw new Error(
|
|
31835
|
+
`Detected multiple installed memoQ copies (${installedRoots.map((i) => i.rootDir).join(", ")}). Please specify memoqRoot explicitly.`
|
|
31836
|
+
);
|
|
31837
|
+
} else {
|
|
31838
|
+
throw new Error("No memoQ installation directory was found (not_found). Please provide memoqRoot.");
|
|
31839
|
+
}
|
|
31840
|
+
}
|
|
31841
|
+
const effectiveProgramData = options.programDataDir ?? process.env.ProgramData ?? "C:\\ProgramData";
|
|
31842
|
+
const shouldElevate = options.elevate ?? isProtectedWindowsPath(targetRoot, effectiveProgramData);
|
|
31843
|
+
const result = await uninstallPluginWithHelper({
|
|
31844
|
+
memoqRoot: targetRoot,
|
|
31845
|
+
programDataDir: effectiveProgramData,
|
|
31846
|
+
elevate: shouldElevate,
|
|
31847
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
31848
|
+
...options.packageRoot === void 0 ? {} : { packageRoot: options.packageRoot },
|
|
31849
|
+
...options.helperExecutablePath === void 0 ? {} : { helperExecutablePath: options.helperExecutablePath }
|
|
31850
|
+
});
|
|
31851
|
+
const integrationAfter = getIntegrationStatus({
|
|
31852
|
+
...options,
|
|
31853
|
+
customInstallDir: targetRoot
|
|
31854
|
+
});
|
|
31855
|
+
return {
|
|
31856
|
+
ok: true,
|
|
31857
|
+
result,
|
|
31858
|
+
integration: integrationAfter
|
|
31859
|
+
};
|
|
31860
|
+
}
|
|
30567
31861
|
|
|
30568
31862
|
// packages/memoq-bridge/src/setup-page.ts
|
|
30569
31863
|
import { spawn as spawn2 } from "node:child_process";
|
|
30570
31864
|
import { randomBytes as randomBytes3, timingSafeEqual as timingSafeEqual2 } from "node:crypto";
|
|
30571
31865
|
import { existsSync as existsSync7, mkdirSync as mkdirSync5 } from "node:fs";
|
|
30572
31866
|
import { createServer as createServer2 } from "node:http";
|
|
30573
|
-
import { dirname as
|
|
31867
|
+
import { dirname as dirname5 } from "node:path";
|
|
30574
31868
|
|
|
30575
31869
|
// packages/memoq-bridge/src/daemon.ts
|
|
30576
31870
|
import { randomBytes as randomBytes2 } from "node:crypto";
|
|
@@ -30653,6 +31947,7 @@ function readDaemonRecord(dataDir = defaultBridgeDataDir()) {
|
|
|
30653
31947
|
port: Number(parsed.port),
|
|
30654
31948
|
controlToken: String(parsed.controlToken),
|
|
30655
31949
|
owner: String(parsed.owner ?? "bridge"),
|
|
31950
|
+
...typeof parsed.version === "string" && parsed.version.trim() ? { version: parsed.version.trim() } : {},
|
|
30656
31951
|
mode: parsed.mode === "dsh-live" ? "dsh-live" : "staging",
|
|
30657
31952
|
startedAt: String(parsed.startedAt ?? "")
|
|
30658
31953
|
};
|
|
@@ -30799,6 +32094,9 @@ var BridgeHttpClient = class {
|
|
|
30799
32094
|
updateLiveConfig(patch) {
|
|
30800
32095
|
return this.request("POST", CONTROL_ROUTES.liveConfig, patch);
|
|
30801
32096
|
}
|
|
32097
|
+
shutdown() {
|
|
32098
|
+
return this.request("POST", CONTROL_ROUTES.shutdown, {});
|
|
32099
|
+
}
|
|
30802
32100
|
};
|
|
30803
32101
|
async function startBridgeRuntime(options = {}) {
|
|
30804
32102
|
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
@@ -30827,6 +32125,7 @@ async function startBridgeRuntime(options = {}) {
|
|
|
30827
32125
|
host,
|
|
30828
32126
|
port: bindPort,
|
|
30829
32127
|
mode: options.mode ?? "staging",
|
|
32128
|
+
...options.version === void 0 ? {} : { desktopVersion: options.version },
|
|
30830
32129
|
...persistedReviewToken ? { reviewToken: persistedReviewToken } : {},
|
|
30831
32130
|
stagingStore,
|
|
30832
32131
|
previewClient,
|
|
@@ -30834,7 +32133,8 @@ async function startBridgeRuntime(options = {}) {
|
|
|
30834
32133
|
...options.liveTranslator === void 0 ? {} : { liveTranslator: options.liveTranslator },
|
|
30835
32134
|
...options.tagAligner === void 0 ? {} : { tagAligner: options.tagAligner },
|
|
30836
32135
|
...options.getLiveConfig === void 0 ? {} : { getLiveConfig: options.getLiveConfig },
|
|
30837
|
-
...options.updateLiveConfig === void 0 ? {} : { updateLiveConfig: options.updateLiveConfig }
|
|
32136
|
+
...options.updateLiveConfig === void 0 ? {} : { updateLiveConfig: options.updateLiveConfig },
|
|
32137
|
+
...options.onShutdown === void 0 ? {} : { onShutdown: options.onShutdown }
|
|
30838
32138
|
});
|
|
30839
32139
|
if (shouldWriteDaemon) {
|
|
30840
32140
|
writeDaemonRecord(
|
|
@@ -30844,6 +32144,7 @@ async function startBridgeRuntime(options = {}) {
|
|
|
30844
32144
|
port: gateway.port,
|
|
30845
32145
|
controlToken: gateway.controlToken,
|
|
30846
32146
|
owner: options.ownerLabel ?? "memoq-bridge",
|
|
32147
|
+
...options.version ? { version: options.version } : {},
|
|
30847
32148
|
mode: options.mode ?? "staging",
|
|
30848
32149
|
startedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
30849
32150
|
},
|
|
@@ -30964,6 +32265,11 @@ function renderSetupHtml(nonce, token, initialStatus) {
|
|
|
30964
32265
|
<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
32266
|
<input id="custom-dir" type="text" placeholder="\u4F8B\u5982 C:\\Program Files\\memoQ\\memoQ-12" />
|
|
30966
32267
|
</div>
|
|
32268
|
+
<div style="margin-top: 10px;">
|
|
32269
|
+
<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>
|
|
32270
|
+
<input id="custom-dll" type="text" placeholder="\u4F8B\u5982 C:\\Users\\...\\Downloads\\MemoQ.AI.Hub.Plugin.dll" />
|
|
32271
|
+
<div id="discovered-dlls" style="font-size: 12px; color: var(--muted); margin-top: 6px;"></div>
|
|
32272
|
+
</div>
|
|
30967
32273
|
</section>
|
|
30968
32274
|
|
|
30969
32275
|
<section class="card">
|
|
@@ -31053,6 +32359,25 @@ function renderSetupHtml(nonce, token, initialStatus) {
|
|
|
31053
32359
|
el.addEventListener("change", function (ev) { selectedRoot = ev.target.value; });
|
|
31054
32360
|
});
|
|
31055
32361
|
}
|
|
32362
|
+
|
|
32363
|
+
const dllsEl = document.getElementById("discovered-dlls");
|
|
32364
|
+
const dllList = state.discoveredDlls || [];
|
|
32365
|
+
if (dllsEl) {
|
|
32366
|
+
if (!dllList.length) {
|
|
32367
|
+
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";
|
|
32368
|
+
} else {
|
|
32369
|
+
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) {
|
|
32370
|
+
const ok = c.sha256MatchesExpected ? "\u2705" : "\u26A0\uFE0F";
|
|
32371
|
+
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>";
|
|
32372
|
+
}).join("");
|
|
32373
|
+
dllsEl.querySelectorAll(".pick-dll").forEach(function (btn) {
|
|
32374
|
+
btn.addEventListener("click", function () {
|
|
32375
|
+
const item = dllList[Number(btn.getAttribute("data-idx"))];
|
|
32376
|
+
if (item) document.getElementById("custom-dll").value = item.path;
|
|
32377
|
+
});
|
|
32378
|
+
});
|
|
32379
|
+
}
|
|
32380
|
+
}
|
|
31056
32381
|
}
|
|
31057
32382
|
|
|
31058
32383
|
function showMessage(text, isError) {
|
|
@@ -31096,11 +32421,13 @@ function renderSetupHtml(nonce, token, initialStatus) {
|
|
|
31096
32421
|
document.getElementById("btn-install").addEventListener("click", async function () {
|
|
31097
32422
|
const root = effectiveRoot();
|
|
31098
32423
|
if (!root) { showMessage("\u8BF7\u5148\u9009\u62E9\u6216\u8F93\u5165 memoQ \u5B89\u88C5\u76EE\u5F55\u3002", true); return; }
|
|
32424
|
+
const dllPath = (document.getElementById("custom-dll").value || "").trim();
|
|
31099
32425
|
const btn = document.getElementById("btn-install");
|
|
31100
32426
|
btn.disabled = true;
|
|
31101
32427
|
showMessage("\u6B63\u5728\u51C6\u5907 DLL \u5E76\u7B49\u5F85\u7CFB\u7EDF UAC \u786E\u8BA4\u2026", false);
|
|
31102
32428
|
try {
|
|
31103
|
-
const
|
|
32429
|
+
const payload = dllPath ? { memoqRoot: root, dllPath: dllPath } : { memoqRoot: root };
|
|
32430
|
+
const res = await api("/api/install", "POST", payload);
|
|
31104
32431
|
render(res.status);
|
|
31105
32432
|
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
32433
|
} catch (e) { showMessage("\u5B89\u88C5\u5931\u8D25\uFF1A" + e.message, true); }
|
|
@@ -31147,7 +32474,13 @@ async function startSetupServer(options = {}) {
|
|
|
31147
32474
|
Promise.resolve(getIntegrationStatus(detectOpts)),
|
|
31148
32475
|
probeGateway(gatewayPort)
|
|
31149
32476
|
]);
|
|
31150
|
-
|
|
32477
|
+
const discoveredDlls = discoverLocalPluginDllCandidates({
|
|
32478
|
+
dataDir,
|
|
32479
|
+
...options.detectOptions?.expectedSha256 === void 0 ? {} : { expectedSha256: options.detectOptions.expectedSha256 },
|
|
32480
|
+
extraFilePaths: integration.installations.filter((i) => i.pluginInstalled).map((i) => i.pluginTarget),
|
|
32481
|
+
includeDefaultUserDirs: options.detectOptions?.skipHostDiscovery ? false : true
|
|
32482
|
+
});
|
|
32483
|
+
return { integration, gateway, discoveredDlls };
|
|
31151
32484
|
}
|
|
31152
32485
|
let idleTimer;
|
|
31153
32486
|
const server = createServer2((request, response) => {
|
|
@@ -31188,12 +32521,14 @@ async function startSetupServer(options = {}) {
|
|
|
31188
32521
|
const body = await readJson(request);
|
|
31189
32522
|
if (url.pathname === "/api/install") {
|
|
31190
32523
|
const memoqRoot = String(body.memoqRoot ?? "").trim();
|
|
32524
|
+
const dllPath = typeof body.dllPath === "string" ? body.dllPath.trim() : "";
|
|
31191
32525
|
if (!memoqRoot) {
|
|
31192
32526
|
sendJson2(response, 400, { error: "memoqRoot \u4E0D\u80FD\u4E3A\u7A7A\u3002" });
|
|
31193
32527
|
return;
|
|
31194
32528
|
}
|
|
31195
32529
|
const resolvedAsset = await resolveDll({
|
|
31196
32530
|
dataDir,
|
|
32531
|
+
...dllPath ? { dllPath } : {},
|
|
31197
32532
|
...options.allowDownload === void 0 ? {} : { allowDownload: options.allowDownload },
|
|
31198
32533
|
...options.detectOptions?.expectedSha256 === void 0 ? {} : { expectedSha256: options.detectOptions.expectedSha256 }
|
|
31199
32534
|
});
|
|
@@ -31232,7 +32567,7 @@ async function startSetupServer(options = {}) {
|
|
|
31232
32567
|
return;
|
|
31233
32568
|
}
|
|
31234
32569
|
if (url.pathname === "/api/open-asset-dir") {
|
|
31235
|
-
const dir =
|
|
32570
|
+
const dir = dirname5(getPluginAssetCachePath(dataDir, DEFAULT_PLUGIN_DLL_MANIFEST.version));
|
|
31236
32571
|
mkdirSync5(dir, { recursive: true });
|
|
31237
32572
|
if (options.allowOpenFolder !== false && process.platform === "win32" && existsSync7(dir)) {
|
|
31238
32573
|
const child = spawn2("explorer.exe", [dir], { detached: true, windowsHide: true, stdio: "ignore" });
|
|
@@ -31246,14 +32581,14 @@ async function startSetupServer(options = {}) {
|
|
|
31246
32581
|
sendJson2(response, 500, { error: error2 instanceof Error ? error2.message : String(error2) });
|
|
31247
32582
|
});
|
|
31248
32583
|
});
|
|
31249
|
-
await new Promise((
|
|
32584
|
+
await new Promise((resolve7, reject) => {
|
|
31250
32585
|
const onError = (error2) => {
|
|
31251
32586
|
server.off("listening", onListening);
|
|
31252
32587
|
reject(error2);
|
|
31253
32588
|
};
|
|
31254
32589
|
const onListening = () => {
|
|
31255
32590
|
server.off("error", onError);
|
|
31256
|
-
|
|
32591
|
+
resolve7();
|
|
31257
32592
|
};
|
|
31258
32593
|
server.once("error", onError);
|
|
31259
32594
|
server.once("listening", onListening);
|
|
@@ -31266,11 +32601,11 @@ async function startSetupServer(options = {}) {
|
|
|
31266
32601
|
actualPort = addr.port;
|
|
31267
32602
|
expectedHost = `${host}:${actualPort}`;
|
|
31268
32603
|
expectedOrigin = `http://${expectedHost}`;
|
|
31269
|
-
const close = () => new Promise((
|
|
32604
|
+
const close = () => new Promise((resolve7) => {
|
|
31270
32605
|
clearTimeout(idleTimer);
|
|
31271
32606
|
server.close(() => {
|
|
31272
32607
|
options.onClose?.();
|
|
31273
|
-
|
|
32608
|
+
resolve7();
|
|
31274
32609
|
});
|
|
31275
32610
|
});
|
|
31276
32611
|
idleTimer = setTimeout(() => {
|
|
@@ -31290,8 +32625,8 @@ async function startSetupServer(options = {}) {
|
|
|
31290
32625
|
|
|
31291
32626
|
// packages/memoq-mcp/src/config.ts
|
|
31292
32627
|
import { copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
31293
|
-
import { homedir as
|
|
31294
|
-
import { dirname as
|
|
32628
|
+
import { homedir as homedir3 } from "node:os";
|
|
32629
|
+
import { dirname as dirname6, join as join8 } from "node:path";
|
|
31295
32630
|
var SERVER_NAME = "memoq";
|
|
31296
32631
|
var PACKAGE = "@langlink/memoq-mcp";
|
|
31297
32632
|
function packageSpec(updateMode, version2) {
|
|
@@ -31315,7 +32650,7 @@ function json(value) {
|
|
|
31315
32650
|
return `${JSON.stringify(value, null, 2)}
|
|
31316
32651
|
`;
|
|
31317
32652
|
}
|
|
31318
|
-
function clientRecipe(client, home =
|
|
32653
|
+
function clientRecipe(client, home = homedir3(), updateMode = "latest", version2) {
|
|
31319
32654
|
const withUpdate = { updateMode };
|
|
31320
32655
|
switch (client) {
|
|
31321
32656
|
case "codex":
|
|
@@ -31419,7 +32754,7 @@ async function mergeJson(recipe, target) {
|
|
|
31419
32754
|
}
|
|
31420
32755
|
throw new Error(`refusing to rewrite existing non-JSON config: ${target}`);
|
|
31421
32756
|
}
|
|
31422
|
-
await mkdir(
|
|
32757
|
+
await mkdir(dirname6(target), { recursive: true });
|
|
31423
32758
|
await writeFile(target, recipe.content, "utf8");
|
|
31424
32759
|
return { client: recipe.client, path: target, action: "created" };
|
|
31425
32760
|
}
|
|
@@ -31434,7 +32769,7 @@ async function writeRecipe(recipe) {
|
|
|
31434
32769
|
} catch (error2) {
|
|
31435
32770
|
if (error2.code !== "ENOENT") throw error2;
|
|
31436
32771
|
}
|
|
31437
|
-
await mkdir(
|
|
32772
|
+
await mkdir(dirname6(recipe.path), { recursive: true });
|
|
31438
32773
|
await writeFile(recipe.path, recipe.content, "utf8");
|
|
31439
32774
|
return { client: recipe.client, path: recipe.path, action: "created" };
|
|
31440
32775
|
}
|
|
@@ -31445,7 +32780,7 @@ async function writeRecipe(recipe) {
|
|
|
31445
32780
|
import { execFile as execFile2, spawn as spawn3 } from "node:child_process";
|
|
31446
32781
|
import { randomUUID as randomUUID6 } from "node:crypto";
|
|
31447
32782
|
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync7, rmSync as rmSync4, writeFileSync as writeFileSync4 } from "node:fs";
|
|
31448
|
-
import { dirname as
|
|
32783
|
+
import { dirname as dirname7, join as join9, resolve as resolve5 } from "node:path";
|
|
31449
32784
|
import { promisify as promisify2 } from "node:util";
|
|
31450
32785
|
var execFileAsync2 = promisify2(execFile2);
|
|
31451
32786
|
var MEMOQ_BRIDGE_DAEMON_FLAG = "--memoq-bridge-daemon";
|
|
@@ -31487,7 +32822,7 @@ async function trySpawnViaWindowsWmi(entrypoint, workerArgs, dataDir) {
|
|
|
31487
32822
|
if (process.platform !== "win32") return false;
|
|
31488
32823
|
const helperPath = ensureRunnableHelperBinary({
|
|
31489
32824
|
dataDir,
|
|
31490
|
-
packageRoot:
|
|
32825
|
+
packageRoot: resolve5(dirname7(entrypoint), "..")
|
|
31491
32826
|
});
|
|
31492
32827
|
if (!helperPath) return false;
|
|
31493
32828
|
const specFile = join9(dataDir, `launch-${randomUUID6()}.json`);
|
|
@@ -31498,7 +32833,7 @@ async function trySpawnViaWindowsWmi(entrypoint, workerArgs, dataDir) {
|
|
|
31498
32833
|
JSON.stringify({
|
|
31499
32834
|
executable: process.execPath,
|
|
31500
32835
|
args: workerArgs,
|
|
31501
|
-
workingDirectory:
|
|
32836
|
+
workingDirectory: dataDir
|
|
31502
32837
|
}),
|
|
31503
32838
|
"utf8"
|
|
31504
32839
|
);
|
|
@@ -31523,7 +32858,7 @@ function spawnViaNodeDetached(entrypoint, workerArgs, dataDir) {
|
|
|
31523
32858
|
detached: true,
|
|
31524
32859
|
windowsHide: true,
|
|
31525
32860
|
stdio: "ignore",
|
|
31526
|
-
cwd:
|
|
32861
|
+
cwd: dataDir,
|
|
31527
32862
|
env: { ...process.env, MEMOQ_BRIDGE_DATA_DIR: dataDir }
|
|
31528
32863
|
});
|
|
31529
32864
|
child.unref();
|
|
@@ -31593,18 +32928,69 @@ async function publishWorkerOutcome(readyFile, outcome) {
|
|
|
31593
32928
|
}
|
|
31594
32929
|
}
|
|
31595
32930
|
}
|
|
32931
|
+
async function waitForDaemonShutdown(client, timeoutMs = 3e3) {
|
|
32932
|
+
const deadline = Date.now() + timeoutMs;
|
|
32933
|
+
while (Date.now() < deadline) {
|
|
32934
|
+
try {
|
|
32935
|
+
await client.getStatus();
|
|
32936
|
+
} catch {
|
|
32937
|
+
return true;
|
|
32938
|
+
}
|
|
32939
|
+
await new Promise((res) => setTimeout(res, READY_POLL_INTERVAL_MS));
|
|
32940
|
+
}
|
|
32941
|
+
return false;
|
|
32942
|
+
}
|
|
31596
32943
|
async function connectOrLaunchBridgeClient(entrypoint, options = {}) {
|
|
31597
32944
|
const dataDir = options.dataDir ?? defaultBridgeDataDir();
|
|
31598
32945
|
const existing = readDaemonRecord(dataDir);
|
|
31599
32946
|
if (existing) {
|
|
31600
32947
|
const client = new BridgeHttpClient(`http://${existing.host}:${existing.port}`, existing.controlToken);
|
|
32948
|
+
let alive = false;
|
|
31601
32949
|
try {
|
|
31602
32950
|
await client.getStatus();
|
|
31603
|
-
|
|
32951
|
+
alive = true;
|
|
31604
32952
|
} catch {
|
|
32953
|
+
alive = false;
|
|
32954
|
+
}
|
|
32955
|
+
if (alive) {
|
|
32956
|
+
const shouldUpgrade = Boolean(options.expectedVersion) && existing.owner === "memoq-mcp-daemon" && existing.version !== options.expectedVersion;
|
|
32957
|
+
if (!shouldUpgrade) {
|
|
32958
|
+
return client;
|
|
32959
|
+
}
|
|
32960
|
+
let shutdownRequested = false;
|
|
32961
|
+
try {
|
|
32962
|
+
const res = await client.shutdown();
|
|
32963
|
+
shutdownRequested = res.ok === true;
|
|
32964
|
+
} catch {
|
|
32965
|
+
shutdownRequested = false;
|
|
32966
|
+
}
|
|
32967
|
+
if (shutdownRequested) {
|
|
32968
|
+
const stopped = await waitForDaemonShutdown(client);
|
|
32969
|
+
if (!stopped) {
|
|
32970
|
+
return client;
|
|
32971
|
+
}
|
|
32972
|
+
const refreshed = readDaemonRecord(dataDir);
|
|
32973
|
+
if (refreshed && refreshed.controlToken !== existing.controlToken) {
|
|
32974
|
+
const refreshedClient = new BridgeHttpClient(
|
|
32975
|
+
`http://${refreshed.host}:${refreshed.port}`,
|
|
32976
|
+
refreshed.controlToken
|
|
32977
|
+
);
|
|
32978
|
+
try {
|
|
32979
|
+
await refreshedClient.getStatus();
|
|
32980
|
+
return refreshedClient;
|
|
32981
|
+
} catch {
|
|
32982
|
+
}
|
|
32983
|
+
}
|
|
32984
|
+
} else {
|
|
32985
|
+
try {
|
|
32986
|
+
await client.getStatus();
|
|
32987
|
+
return client;
|
|
32988
|
+
} catch {
|
|
32989
|
+
}
|
|
32990
|
+
}
|
|
31605
32991
|
}
|
|
31606
32992
|
}
|
|
31607
|
-
const configuredPort = parseConfiguredBridgePort();
|
|
32993
|
+
const configuredPort = options.port ?? parseConfiguredBridgePort();
|
|
31608
32994
|
const payload = await spawnDetachedWorker(entrypoint, MEMOQ_BRIDGE_DAEMON_FLAG, {
|
|
31609
32995
|
dataDir,
|
|
31610
32996
|
...configuredPort === void 0 ? {} : { port: configuredPort }
|
|
@@ -31642,23 +33028,35 @@ function createSetupWizardLauncher(entrypoint, options = {}) {
|
|
|
31642
33028
|
return inFlight;
|
|
31643
33029
|
};
|
|
31644
33030
|
}
|
|
31645
|
-
async function runBridgeDaemonWorker(argv = process.argv.slice(2)) {
|
|
33031
|
+
async function runBridgeDaemonWorker(argv = process.argv.slice(2), version2, runtimeOptions = {}) {
|
|
31646
33032
|
const args = parseWorkerCliArgs(argv);
|
|
31647
33033
|
if (!args.readyFile && (!process.send || !process.connected)) {
|
|
31648
33034
|
throw new Error("memoQ bridge daemon requires --ready-file or IPC.");
|
|
31649
33035
|
}
|
|
31650
33036
|
const dataDir = args.dataDir ?? defaultBridgeDataDir();
|
|
31651
33037
|
try {
|
|
31652
|
-
|
|
33038
|
+
let closing = false;
|
|
33039
|
+
let runtime;
|
|
33040
|
+
const cleanup = () => {
|
|
33041
|
+
if (closing) return;
|
|
33042
|
+
closing = true;
|
|
33043
|
+
if (runtime) {
|
|
33044
|
+
removeDaemonRecord(runtime.gateway.controlToken, dataDir);
|
|
33045
|
+
void runtime.close().catch(() => {
|
|
33046
|
+
}).finally(() => process.exit(0));
|
|
33047
|
+
} else {
|
|
33048
|
+
process.exit(0);
|
|
33049
|
+
}
|
|
33050
|
+
};
|
|
33051
|
+
runtime = await startBridgeRuntime({
|
|
31653
33052
|
dataDir,
|
|
31654
33053
|
...args.port === void 0 ? {} : { preferredPort: args.port },
|
|
31655
33054
|
ownerLabel: "memoq-mcp-daemon",
|
|
31656
|
-
|
|
33055
|
+
...version2 ? { version: version2 } : {},
|
|
33056
|
+
...runtimeOptions.startPreview === void 0 ? {} : { startPreview: runtimeOptions.startPreview },
|
|
33057
|
+
mode: "staging",
|
|
33058
|
+
onShutdown: cleanup
|
|
31657
33059
|
});
|
|
31658
|
-
const cleanup = () => {
|
|
31659
|
-
removeDaemonRecord(runtime.gateway.controlToken, dataDir);
|
|
31660
|
-
void runtime.close().finally(() => process.exit(0));
|
|
31661
|
-
};
|
|
31662
33060
|
process.once("SIGINT", cleanup);
|
|
31663
33061
|
process.once("SIGTERM", cleanup);
|
|
31664
33062
|
try {
|
|
@@ -31719,17 +33117,19 @@ function textResult(value) {
|
|
|
31719
33117
|
content: [{ type: "text", text: typeof value === "string" ? value : JSON.stringify(value) }]
|
|
31720
33118
|
};
|
|
31721
33119
|
}
|
|
33120
|
+
var MEMOQ_MCP_VERSION = "0.2.4";
|
|
31722
33121
|
function createMemoqMcpServer(options = {}) {
|
|
31723
|
-
const server = new McpServer({ name: "langlink-memoq", version:
|
|
31724
|
-
const here =
|
|
33122
|
+
const server = new McpServer({ name: "langlink-memoq", version: MEMOQ_MCP_VERSION });
|
|
33123
|
+
const here = dirname8(fileURLToPath2(import.meta.url));
|
|
31725
33124
|
const entrypoint = fileURLToPath2(import.meta.url);
|
|
31726
|
-
const packageRoot =
|
|
33125
|
+
const packageRoot = resolve6(here, "..");
|
|
31727
33126
|
let clientPromise;
|
|
31728
33127
|
const resolveClient = async () => {
|
|
31729
33128
|
if (options.bridgeClient) return options.bridgeClient;
|
|
31730
33129
|
if (options.getBridgeClient) return options.getBridgeClient();
|
|
31731
33130
|
clientPromise ??= connectOrLaunchBridgeClient(entrypoint, {
|
|
31732
|
-
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir }
|
|
33131
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33132
|
+
expectedVersion: MEMOQ_MCP_VERSION
|
|
31733
33133
|
}).catch((error2) => {
|
|
31734
33134
|
clientPromise = void 0;
|
|
31735
33135
|
throw error2;
|
|
@@ -32061,25 +33461,100 @@ function createMemoqMcpServer(options = {}) {
|
|
|
32061
33461
|
server.registerTool(
|
|
32062
33462
|
"memoq_setup",
|
|
32063
33463
|
{
|
|
32064
|
-
description: "
|
|
33464
|
+
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
33465
|
inputSchema: {
|
|
32066
|
-
|
|
33466
|
+
action: _enum(["plan", "install", "uninstall"]).optional(),
|
|
33467
|
+
customInstallDir: string2().optional(),
|
|
33468
|
+
memoqRoot: string2().optional(),
|
|
33469
|
+
dllPath: string2().optional(),
|
|
33470
|
+
searchDirs: array(string2()).max(20).optional(),
|
|
33471
|
+
confirmed: boolean2().optional(),
|
|
33472
|
+
openWizard: boolean2().optional()
|
|
32067
33473
|
}
|
|
32068
33474
|
},
|
|
32069
|
-
async ({ customInstallDir }) => {
|
|
33475
|
+
async ({ action, customInstallDir, memoqRoot, dllPath, searchDirs, confirmed, openWizard }) => {
|
|
33476
|
+
const effectiveAction = action ?? "plan";
|
|
33477
|
+
const targetCustomDir = customInstallDir ?? memoqRoot;
|
|
33478
|
+
const planFn = options.buildInstallPlan ?? buildPluginInstallPlan;
|
|
33479
|
+
const installFn = options.installPlugin ?? executeConfirmedPluginInstall;
|
|
33480
|
+
const uninstallFn = options.uninstallPlugin ?? executeConfirmedPluginUninstall;
|
|
33481
|
+
if (effectiveAction === "install") {
|
|
33482
|
+
if (confirmed !== true) {
|
|
33483
|
+
const plan2 = planFn({
|
|
33484
|
+
packageRoot,
|
|
33485
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33486
|
+
...targetCustomDir === void 0 ? {} : { customInstallDir: targetCustomDir },
|
|
33487
|
+
...dllPath === void 0 ? {} : { dllPath },
|
|
33488
|
+
...searchDirs === void 0 ? {} : { searchDirs }
|
|
33489
|
+
});
|
|
33490
|
+
return textResult({
|
|
33491
|
+
action: "install",
|
|
33492
|
+
installed: false,
|
|
33493
|
+
confirmationRequired: true,
|
|
33494
|
+
plan: plan2,
|
|
33495
|
+
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"
|
|
33496
|
+
});
|
|
33497
|
+
}
|
|
33498
|
+
const installResult = await installFn({
|
|
33499
|
+
packageRoot,
|
|
33500
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33501
|
+
...customInstallDir === void 0 ? {} : { customInstallDir },
|
|
33502
|
+
...memoqRoot === void 0 ? {} : { memoqRoot },
|
|
33503
|
+
...dllPath === void 0 ? {} : { dllPath },
|
|
33504
|
+
...searchDirs === void 0 ? {} : { searchDirs },
|
|
33505
|
+
confirmed: true
|
|
33506
|
+
});
|
|
33507
|
+
return textResult({
|
|
33508
|
+
action: "install",
|
|
33509
|
+
installed: true,
|
|
33510
|
+
...installResult
|
|
33511
|
+
});
|
|
33512
|
+
}
|
|
33513
|
+
if (effectiveAction === "uninstall") {
|
|
33514
|
+
if (confirmed !== true) {
|
|
33515
|
+
return textResult({
|
|
33516
|
+
action: "uninstall",
|
|
33517
|
+
uninstalled: false,
|
|
33518
|
+
confirmationRequired: true,
|
|
33519
|
+
error: "\u5FC5\u987B\u5148\u83B7\u7528\u6237\u660E\u786E\u786E\u8BA4\u540E\u518D\u4F20 confirmed: true \u624D\u80FD\u5378\u8F7D memoQ \u63D2\u4EF6\u3002"
|
|
33520
|
+
});
|
|
33521
|
+
}
|
|
33522
|
+
const uninstallResult = await uninstallFn({
|
|
33523
|
+
packageRoot,
|
|
33524
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33525
|
+
...customInstallDir === void 0 ? {} : { customInstallDir },
|
|
33526
|
+
...memoqRoot === void 0 ? {} : { memoqRoot },
|
|
33527
|
+
confirmed: true
|
|
33528
|
+
});
|
|
33529
|
+
return textResult({
|
|
33530
|
+
action: "uninstall",
|
|
33531
|
+
uninstalled: true,
|
|
33532
|
+
...uninstallResult
|
|
33533
|
+
});
|
|
33534
|
+
}
|
|
32070
33535
|
const integration = getIntegrationStatus({
|
|
32071
33536
|
packageRoot,
|
|
32072
33537
|
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
32073
|
-
...
|
|
33538
|
+
...targetCustomDir === void 0 ? {} : { customInstallDir: targetCustomDir }
|
|
33539
|
+
});
|
|
33540
|
+
const plan = planFn({
|
|
33541
|
+
packageRoot,
|
|
33542
|
+
...options.dataDir === void 0 ? {} : { dataDir: options.dataDir },
|
|
33543
|
+
...targetCustomDir === void 0 ? {} : { customInstallDir: targetCustomDir },
|
|
33544
|
+
...dllPath === void 0 ? {} : { dllPath },
|
|
33545
|
+
...searchDirs === void 0 ? {} : { searchDirs }
|
|
32074
33546
|
});
|
|
32075
33547
|
const probe = await probeGatewayPort(Number(process.env.MEMOQ_BRIDGE_PORT || DEFAULT_PORT));
|
|
32076
|
-
const url = await launchSetup();
|
|
33548
|
+
const url = openWizard === false ? "" : await launchSetup();
|
|
32077
33549
|
return textResult({
|
|
32078
|
-
|
|
32079
|
-
link: `[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})
|
|
33550
|
+
action: "plan",
|
|
33551
|
+
...url ? { url, link: `[\u6253\u5F00 memoQ \u8FDE\u63A5\u5668\u5B89\u88C5\u4E0E\u8BCA\u65AD\u5411\u5BFC](${url})` } : {},
|
|
32080
33552
|
integration,
|
|
33553
|
+
plan,
|
|
32081
33554
|
gateway: probe,
|
|
32082
|
-
|
|
33555
|
+
confirmationRequired: true,
|
|
33556
|
+
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`,
|
|
33557
|
+
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
33558
|
});
|
|
32084
33559
|
}
|
|
32085
33560
|
);
|
|
@@ -32129,7 +33604,7 @@ async function runConfigCommand(args) {
|
|
|
32129
33604
|
async function main() {
|
|
32130
33605
|
const command = process.argv[2];
|
|
32131
33606
|
if (command === MEMOQ_BRIDGE_DAEMON_FLAG) {
|
|
32132
|
-
await runBridgeDaemonWorker(process.argv.slice(3));
|
|
33607
|
+
await runBridgeDaemonWorker(process.argv.slice(3), MEMOQ_MCP_VERSION);
|
|
32133
33608
|
return;
|
|
32134
33609
|
}
|
|
32135
33610
|
if (command === MEMOQ_SETUP_WORKER_FLAG) {
|
|
@@ -32158,6 +33633,7 @@ if (process.argv[1] && import.meta.url === pathToFileURL(realpathSync(process.ar
|
|
|
32158
33633
|
});
|
|
32159
33634
|
}
|
|
32160
33635
|
export {
|
|
33636
|
+
MEMOQ_MCP_VERSION,
|
|
32161
33637
|
createMemoqMcpServer
|
|
32162
33638
|
};
|
|
32163
33639
|
//# sourceMappingURL=index.js.map
|