dsh-extra-paths 0.2.0 → 0.2.1
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 +3 -0
- package/README.zh.md +3 -0
- package/lib/client.js +236 -78
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -24,6 +24,9 @@ dsh plugin --profile <name> add /path/to/dsh-extra-paths # path = absolute pat
|
|
|
24
24
|
Then open **Extra writable paths** in the settings sidebar. In **Settings → Plugins** the same page lives on this
|
|
25
25
|
plugin's own row: open the `dsh-extra-paths` bundle, then hit that row's **Configure** button.
|
|
26
26
|
|
|
27
|
+
The page follows DSH's own language selection (**Settings → General → Language**): it ships Simplified Chinese and
|
|
28
|
+
English copy, and every other UI language falls back to English.
|
|
29
|
+
|
|
27
30
|
## Configuration
|
|
28
31
|
|
|
29
32
|
Write it into the `extra-paths` section of the settings document `~/.dsh/settings.yaml`, or just use the settings page
|
package/README.zh.md
CHANGED
|
@@ -23,6 +23,9 @@ dsh plugin --profile <name> add /path/to/dsh-extra-paths # 路径=本仓库的
|
|
|
23
23
|
装好后打开设置左栏的「额外可写路径」。在 **设置 → 插件** 里,同一页在这个插件自己那一行上:
|
|
24
24
|
打开 `dsh-extra-paths` 组合包,点该行的「配置」。
|
|
25
25
|
|
|
26
|
+
页面文案跟随 DSH 自己的语言选择(**设置 → 常规 → 语言**):内置简体中文与英文两套文案,
|
|
27
|
+
其它界面语言回落到英文。
|
|
28
|
+
|
|
26
29
|
## 配置
|
|
27
30
|
|
|
28
31
|
写进设置文档 `~/.dsh/settings.yaml` 的 `extra-paths` 段,或直接用设置页(**保存即生效,无需重启**)。
|
package/lib/client.js
CHANGED
|
@@ -29,6 +29,136 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
let react = require("react");
|
|
30
30
|
react = __toESM(react, 1);
|
|
31
31
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
32
|
+
//#region src/client/locales.ts
|
|
33
|
+
/** English copy — the fallback locale for every non-Chinese UI language. */
|
|
34
|
+
const en = {
|
|
35
|
+
navLabel: "Extra writable paths",
|
|
36
|
+
summaryLoading: "Extra writable paths: loading…",
|
|
37
|
+
summaryUnavailable: "Extra writable paths: not offered by this host",
|
|
38
|
+
summaryEmpty: "Extra writable paths: not configured yet",
|
|
39
|
+
summaryCount: "Extra writable paths: {count} saved · writing needs no approval",
|
|
40
|
+
introBefore: "These paths stay writable outside the session workspace, ",
|
|
41
|
+
introNoApproval: "without approval",
|
|
42
|
+
introAfter: "; both the write tools and the terminal honor the surfaces below.",
|
|
43
|
+
introRuleBefore: "Relative spellings resolve against the base workspace; enforcement uses ",
|
|
44
|
+
introRuleEmphasis: "each session's own workspace",
|
|
45
|
+
introRuleAfter: ", so one configuration points at different directories in different sessions.",
|
|
46
|
+
baseWorkspace: "Base workspace",
|
|
47
|
+
notSelected: "(none selected)",
|
|
48
|
+
basePlaceholder: "Absolute path, or start with ~/ (for example ~/projects)",
|
|
49
|
+
manualBase: "Type a path",
|
|
50
|
+
pickBase: "Pick from list",
|
|
51
|
+
baseHint: "Preview and inline resolution only",
|
|
52
|
+
save: "Save",
|
|
53
|
+
saving: "Saving…",
|
|
54
|
+
addPath: "Add path",
|
|
55
|
+
addParent: "Add the workspace parent (..)",
|
|
56
|
+
discard: "Discard changes",
|
|
57
|
+
dirty: "Unsaved changes",
|
|
58
|
+
synced: "In sync with the configuration",
|
|
59
|
+
emptyPaths: "No paths configured yet: start with \"Add path\" or \"Add the workspace parent (..)\" above.",
|
|
60
|
+
rowTitle: "Path {index}",
|
|
61
|
+
delete: "Remove",
|
|
62
|
+
pathPlaceholder: "~/projects/notes/home, ../some-repo, .. (parent), ~/projects/**/.worktrees/.. (pattern)",
|
|
63
|
+
patternResolved: "Pattern: the host expands it along the directory structure",
|
|
64
|
+
patternMatches: "{count} directories match (see the preview below)",
|
|
65
|
+
patternNoMatches: "(no matches yet, or capped by the expansion limit)",
|
|
66
|
+
resolvePendingEmpty: "The resolved path appears here once you type a path",
|
|
67
|
+
resolveNeedsBase: "A relative path needs a base workspace: choose or type one above",
|
|
68
|
+
resolveBaseInvalid: "The base workspace must be an absolute path or start with ~/ (for example ~/projects)",
|
|
69
|
+
resolveNeedsHome: "~ needs the host home directory (available after the first preview)",
|
|
70
|
+
resolvedAs: "Resolves to",
|
|
71
|
+
hostResolved: "(host resolves: {path})",
|
|
72
|
+
mode: "Applies under",
|
|
73
|
+
surfaces: "Surfaces",
|
|
74
|
+
surfaceFs: "Write tools",
|
|
75
|
+
surfaceShell: "Terminal",
|
|
76
|
+
scopeWrite: "Follows the session mode (denied under read-only)",
|
|
77
|
+
scopeAlways: "Always writable (allowed under read-only too)",
|
|
78
|
+
statusOk: "active",
|
|
79
|
+
statusMissing: "missing",
|
|
80
|
+
statusRejected: "rejected",
|
|
81
|
+
previewTitle: "Resolution preview",
|
|
82
|
+
previewDirty: " (including unsaved changes)",
|
|
83
|
+
previewEffective: "{count} effective roots",
|
|
84
|
+
previewNoBase: "Choose or type a base workspace above and the host's effective roots appear here.",
|
|
85
|
+
previewBadBase: "The base workspace must be absolute or start with ~/ (for example ~/projects); a relative path cannot be the base.",
|
|
86
|
+
previewExpandingHome: "Expanding ~: the host home directory arrives with the first preview.",
|
|
87
|
+
previewUnavailable: "Preview unavailable (the host did not offer the route, the connection is not ready, or it rejected the base workspace).",
|
|
88
|
+
previewEmpty: "Nothing to resolve yet.",
|
|
89
|
+
unresolved: "(unresolved)",
|
|
90
|
+
saveRefused: "The host refused the save: this configuration may be overridden by a home patch or a command-line overlay (the settings page only writes the profile cordis.patch.yml). Remove the same-id override from ~/.dsh/cordis.patch.yml, or edit the profile patch and restart."
|
|
91
|
+
};
|
|
92
|
+
/** Simplified Chinese copy. */
|
|
93
|
+
const zh = {
|
|
94
|
+
navLabel: "额外可写路径",
|
|
95
|
+
summaryLoading: "额外可写路径:读取中…",
|
|
96
|
+
summaryUnavailable: "额外可写路径:宿主未提供该设置",
|
|
97
|
+
summaryEmpty: "额外可写路径:尚未配置",
|
|
98
|
+
summaryCount: "额外可写路径:{count} 条 · 保存即生效,写入无需审批",
|
|
99
|
+
introBefore: "这些路径在会话工作区之外也可以写,",
|
|
100
|
+
introNoApproval: "不需要审批",
|
|
101
|
+
introAfter: ";写工具与终端都按下面的「作用面」生效。",
|
|
102
|
+
introRuleBefore: "相对路径按「基准工作区」解析——执法时用的是",
|
|
103
|
+
introRuleEmphasis: "各会话自己的工作区",
|
|
104
|
+
introRuleAfter: ",所以同一份配置在不同会话会指向不同目录。",
|
|
105
|
+
baseWorkspace: "基准工作区",
|
|
106
|
+
notSelected: "(未选择)",
|
|
107
|
+
basePlaceholder: "绝对路径,或以 ~/ 开头(例如 ~/projects)",
|
|
108
|
+
manualBase: "手填",
|
|
109
|
+
pickBase: "从列表选",
|
|
110
|
+
baseHint: "仅用于预览与行内解析",
|
|
111
|
+
save: "保存",
|
|
112
|
+
saving: "保存中…",
|
|
113
|
+
addPath: "添加路径",
|
|
114
|
+
addParent: "添加工作区上一层(..)",
|
|
115
|
+
discard: "放弃修改",
|
|
116
|
+
dirty: "有未保存的修改",
|
|
117
|
+
synced: "已与配置同步",
|
|
118
|
+
emptyPaths: "还没有配置路径:用上面的「添加路径」或「添加工作区上一层(..)」开始。",
|
|
119
|
+
rowTitle: "路径 {index}",
|
|
120
|
+
delete: "删除",
|
|
121
|
+
pathPlaceholder: "~/projects/notes/home、../某仓库、..(上一层)、~/projects/**/.worktrees/..(模式)",
|
|
122
|
+
patternResolved: "模式:由宿主按目录结构展开",
|
|
123
|
+
patternMatches: "当前命中 {count} 个目录(见下方预览)",
|
|
124
|
+
patternNoMatches: "(暂无命中,或被展开上限拦截)",
|
|
125
|
+
resolvePendingEmpty: "填入路径后这里会显示解析结果",
|
|
126
|
+
resolveNeedsBase: "相对路径需要基准工作区:请在上面选择或填写",
|
|
127
|
+
resolveBaseInvalid: "基准工作区需要绝对路径,或以 ~/ 开头(例如 ~/projects)",
|
|
128
|
+
resolveNeedsHome: "~ 需要宿主的家目录(第一次预览返回后即可解析)",
|
|
129
|
+
resolvedAs: "解析为",
|
|
130
|
+
hostResolved: "(宿主解析:{path})",
|
|
131
|
+
mode: "生效模式",
|
|
132
|
+
surfaces: "作用面",
|
|
133
|
+
surfaceFs: "写工具",
|
|
134
|
+
surfaceShell: "终端",
|
|
135
|
+
scopeWrite: "随会话模式(read-only 下拒绝)",
|
|
136
|
+
scopeAlways: "始终可写(read-only 下也允许)",
|
|
137
|
+
statusOk: "生效",
|
|
138
|
+
statusMissing: "目录不存在",
|
|
139
|
+
statusRejected: "已拒绝",
|
|
140
|
+
previewTitle: "解析预览",
|
|
141
|
+
previewDirty: "(含未保存修改)",
|
|
142
|
+
previewEffective: "生效根 {count} 条",
|
|
143
|
+
previewNoBase: "先在上面选择或填写「基准工作区」,这里就会显示宿主解析出的生效根。",
|
|
144
|
+
previewBadBase: "基准工作区需要绝对路径,或以 ~/ 开头(例如 ~/projects);相对路径不能当基准用。",
|
|
145
|
+
previewExpandingHome: "正在展开 ~:宿主的家目录会在第一次预览返回后给出。",
|
|
146
|
+
previewUnavailable: "预览不可用(宿主没提供该路由、连接还没就绪,或基准工作区被宿主拒绝)。",
|
|
147
|
+
previewEmpty: "还没有可解析的路径。",
|
|
148
|
+
unresolved: "(未解析)",
|
|
149
|
+
saveRefused: "保存被宿主拒绝:该配置可能被 home patch 或命令行覆盖(设置页只写 profile 的 cordis.patch.yml)。请删掉 ~/.dsh/cordis.patch.yml 里同 id 的覆盖,或直接改 profile patch 后重启。"
|
|
150
|
+
};
|
|
151
|
+
/** Fill `{name}` placeholders; unknown names stay verbatim, like the host seat. */
|
|
152
|
+
function format(template, params) {
|
|
153
|
+
if (params === void 0) return template;
|
|
154
|
+
return template.replace(/\{(\w+)\}/g, (match, name) => name in params ? String(params[name]) : match);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The built-in translate function: Chinese copy, `{name}` placeholders.
|
|
158
|
+
* Used when the host supplies no locale seat (0.1.5 slots, unit tests).
|
|
159
|
+
*/
|
|
160
|
+
const fallbackTranslate = (key, params) => format(zh[key], params);
|
|
161
|
+
//#endregion
|
|
32
162
|
//#region src/client/paths.ts
|
|
33
163
|
/**
|
|
34
164
|
* Lexical path resolution for the settings page's live column. It mirrors the
|
|
@@ -329,10 +459,15 @@ window.__ModuleLoader__.load({
|
|
|
329
459
|
//#endregion
|
|
330
460
|
//#region src/client/page.tsx
|
|
331
461
|
/**
|
|
332
|
-
* The Extra paths settings page: one card per configured path,
|
|
462
|
+
* The Extra paths settings page: one card per configured path, localized copy,
|
|
333
463
|
* a LIVE lexical resolution per row against a base workspace, quick add
|
|
334
464
|
* buttons, and the host's authoritative preview of the DRAFT (unsaved rows).
|
|
335
465
|
*
|
|
466
|
+
* Copy follows the host's own language selection: every string comes from the
|
|
467
|
+
* dictionaries registered by `../client/index` through the framework-injected
|
|
468
|
+
* `t` seat, and the Chinese dictionary is the built-in fallback for a host that
|
|
469
|
+
* supplies no seat at all (0.1.5 slots, unit tests).
|
|
470
|
+
*
|
|
336
471
|
* The base workspace comes from the shell's standard `useWorkspaces` hook when
|
|
337
472
|
* the slot supplies it — a snapshot read once during activation would be
|
|
338
473
|
* `undefined` whenever the registry had not loaded yet, which is exactly how the
|
|
@@ -341,30 +476,36 @@ window.__ModuleLoader__.load({
|
|
|
341
476
|
* @module dsh-extra-paths/client/page
|
|
342
477
|
*/
|
|
343
478
|
/**
|
|
344
|
-
*
|
|
345
|
-
*
|
|
479
|
+
* Marker carried by a refusal raised in the late-bound scope. The page maps it
|
|
480
|
+
* to localized copy instead of showing the scope's internal message.
|
|
346
481
|
*/
|
|
347
|
-
const
|
|
482
|
+
const SAVE_REFUSED_CODE = "extra-paths/save-refused";
|
|
483
|
+
/**
|
|
484
|
+
* Message carried by that marker error (Chinese). The page shows the localized
|
|
485
|
+
* `saveRefused` copy; this text only reaches logs/tests.
|
|
486
|
+
*/
|
|
487
|
+
const SAVE_REFUSED_MESSAGE = zh.saveRefused;
|
|
488
|
+
/** Build the refusal error the page recognizes. */
|
|
489
|
+
function saveRefusedError() {
|
|
490
|
+
const error = new Error(SAVE_REFUSED_MESSAGE);
|
|
491
|
+
error.code = SAVE_REFUSED_CODE;
|
|
492
|
+
return error;
|
|
493
|
+
}
|
|
494
|
+
/** Whether a rejected save is the host refusing the write. */
|
|
495
|
+
function isSaveRefused(cause) {
|
|
496
|
+
return cause?.code === SAVE_REFUSED_CODE;
|
|
497
|
+
}
|
|
348
498
|
const NOOP_HOOK = () => void 0;
|
|
349
499
|
const IDENTITY = (snapshot) => snapshot;
|
|
350
500
|
function itemsOf(value) {
|
|
351
501
|
const items = value?.items;
|
|
352
502
|
return Array.isArray(items) ? items : [];
|
|
353
503
|
}
|
|
354
|
-
const STATUS_LABEL = {
|
|
355
|
-
ok: "生效",
|
|
356
|
-
missing: "目录不存在",
|
|
357
|
-
rejected: "已拒绝"
|
|
358
|
-
};
|
|
359
504
|
const STATUS_STYLE = {
|
|
360
505
|
ok: styles.statusOk,
|
|
361
506
|
missing: styles.statusMissing,
|
|
362
507
|
rejected: styles.statusRejected
|
|
363
508
|
};
|
|
364
|
-
const SCOPE_LABEL = {
|
|
365
|
-
write: "随会话模式(read-only 下拒绝)",
|
|
366
|
-
"always-write": "始终可写(read-only 下也允许)"
|
|
367
|
-
};
|
|
368
509
|
function rowsOf(section) {
|
|
369
510
|
const rows = [];
|
|
370
511
|
for (const item of section?.paths ?? []) if (typeof item === "string") rows.push({
|
|
@@ -400,12 +541,13 @@ window.__ModuleLoader__.load({
|
|
|
400
541
|
* list, and the full view on the entry's own page. Rendering the editor for both
|
|
401
542
|
* is what used to fill the Plugins page with the whole form, so the summary is a
|
|
402
543
|
* separate component that can never grow one.
|
|
403
|
-
* @param props - the bound settings scope.
|
|
544
|
+
* @param props - the bound settings scope and the host's translate seat.
|
|
404
545
|
*/
|
|
405
|
-
function ExtraPathsSummary({ scope }) {
|
|
546
|
+
function ExtraPathsSummary({ scope, t }) {
|
|
547
|
+
const translate = t ?? fallbackTranslate;
|
|
406
548
|
const { status, value } = useSnapshot(scope);
|
|
407
549
|
const rows = rowsOf(value).filter((row) => row.path.trim() !== "");
|
|
408
|
-
const text = status === "loading" ? "
|
|
550
|
+
const text = status === "loading" ? translate("summaryLoading") : status === "unavailable" ? translate("summaryUnavailable") : rows.length === 0 ? translate("summaryEmpty") : translate("summaryCount", { count: rows.length });
|
|
409
551
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
410
552
|
style: styles.dim,
|
|
411
553
|
children: text
|
|
@@ -413,10 +555,12 @@ window.__ModuleLoader__.load({
|
|
|
413
555
|
}
|
|
414
556
|
/**
|
|
415
557
|
* Render the page.
|
|
416
|
-
* @param props - the bound settings scope, the
|
|
417
|
-
* lazy fallback used when the composition
|
|
558
|
+
* @param props - the bound settings scope, the host's translate seat, the
|
|
559
|
+
* standard workspace hook, and the lazy fallback used when the composition
|
|
560
|
+
* supplies no standard props.
|
|
418
561
|
*/
|
|
419
|
-
function ExtraPathsPage({ scope, getWorkspaces, useWorkspaces }) {
|
|
562
|
+
function ExtraPathsPage({ scope, t, getWorkspaces, useWorkspaces }) {
|
|
563
|
+
const tr = t ?? fallbackTranslate;
|
|
420
564
|
const snapshot = useSnapshot(scope);
|
|
421
565
|
const fromHook = itemsOf((useWorkspaces ?? NOOP_HOOK)(IDENTITY));
|
|
422
566
|
const candidates = (fromHook.length > 0 ? fromHook : itemsOf(getWorkspaces?.()?.list?.getSnapshot?.())).map((item) => item.path).filter((path) => typeof path === "string" && path !== "");
|
|
@@ -491,10 +635,10 @@ window.__ModuleLoader__.load({
|
|
|
491
635
|
setBusy(true);
|
|
492
636
|
setError(void 0);
|
|
493
637
|
scope.set("paths", payloadOf(rows)).then((accepted) => {
|
|
494
|
-
if (accepted === false) setError(
|
|
638
|
+
if (accepted === false) setError(tr("saveRefused"));
|
|
495
639
|
else setDirty(false);
|
|
496
640
|
}).catch((cause) => {
|
|
497
|
-
setError(cause instanceof Error ? cause.message : String(cause));
|
|
641
|
+
setError(isSaveRefused(cause) ? tr("saveRefused") : cause instanceof Error ? cause.message : String(cause));
|
|
498
642
|
}).finally(() => {
|
|
499
643
|
setBusy(false);
|
|
500
644
|
});
|
|
@@ -510,11 +654,12 @@ window.__ModuleLoader__.load({
|
|
|
510
654
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
511
655
|
style: styles.intro,
|
|
512
656
|
children: [
|
|
513
|
-
"
|
|
514
|
-
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: "
|
|
515
|
-
"
|
|
516
|
-
|
|
517
|
-
"
|
|
657
|
+
tr("introBefore"),
|
|
658
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: tr("introNoApproval") }),
|
|
659
|
+
tr("introAfter"),
|
|
660
|
+
tr("introRuleBefore"),
|
|
661
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("strong", { children: tr("introRuleEmphasis") }),
|
|
662
|
+
tr("introRuleAfter")
|
|
518
663
|
]
|
|
519
664
|
}),
|
|
520
665
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -522,7 +667,7 @@ window.__ModuleLoader__.load({
|
|
|
522
667
|
children: [
|
|
523
668
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
524
669
|
style: styles.cardTitle,
|
|
525
|
-
children: "
|
|
670
|
+
children: tr("baseWorkspace")
|
|
526
671
|
}),
|
|
527
672
|
picker ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
528
673
|
className: "xp-select",
|
|
@@ -534,7 +679,7 @@ window.__ModuleLoader__.load({
|
|
|
534
679
|
},
|
|
535
680
|
children: [known ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
536
681
|
value: typedBase,
|
|
537
|
-
children: typedBase === "" ? "
|
|
682
|
+
children: typedBase === "" ? tr("notSelected") : typedBase
|
|
538
683
|
}), candidates.map((path) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
539
684
|
value: path,
|
|
540
685
|
children: path
|
|
@@ -543,7 +688,7 @@ window.__ModuleLoader__.load({
|
|
|
543
688
|
className: "xp-input",
|
|
544
689
|
style: styles.baseField,
|
|
545
690
|
value: cwd,
|
|
546
|
-
placeholder: "
|
|
691
|
+
placeholder: tr("basePlaceholder"),
|
|
547
692
|
onChange: (event) => {
|
|
548
693
|
setCwdPinned(true);
|
|
549
694
|
setCwd(event.target.value);
|
|
@@ -555,11 +700,11 @@ window.__ModuleLoader__.load({
|
|
|
555
700
|
onClick: () => {
|
|
556
701
|
setManualBase(!manualBase);
|
|
557
702
|
},
|
|
558
|
-
children: picker ? "
|
|
703
|
+
children: picker ? tr("manualBase") : tr("pickBase")
|
|
559
704
|
}) : null,
|
|
560
705
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
561
706
|
style: styles.dim,
|
|
562
|
-
children: "
|
|
707
|
+
children: tr("baseHint")
|
|
563
708
|
})
|
|
564
709
|
]
|
|
565
710
|
}),
|
|
@@ -571,7 +716,7 @@ window.__ModuleLoader__.load({
|
|
|
571
716
|
className: "xp-button xp-button-on",
|
|
572
717
|
disabled: busy || !dirty,
|
|
573
718
|
onClick: save,
|
|
574
|
-
children: busy ? "
|
|
719
|
+
children: busy ? tr("saving") : tr("save")
|
|
575
720
|
}),
|
|
576
721
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
577
722
|
type: "button",
|
|
@@ -579,7 +724,7 @@ window.__ModuleLoader__.load({
|
|
|
579
724
|
onClick: () => {
|
|
580
725
|
append("");
|
|
581
726
|
},
|
|
582
|
-
children: "
|
|
727
|
+
children: tr("addPath")
|
|
583
728
|
}),
|
|
584
729
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
585
730
|
type: "button",
|
|
@@ -587,24 +732,24 @@ window.__ModuleLoader__.load({
|
|
|
587
732
|
onClick: () => {
|
|
588
733
|
append("..");
|
|
589
734
|
},
|
|
590
|
-
children: "
|
|
735
|
+
children: tr("addParent")
|
|
591
736
|
}),
|
|
592
737
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
593
738
|
type: "button",
|
|
594
739
|
className: "xp-button",
|
|
595
740
|
disabled: !dirty,
|
|
596
741
|
onClick: reset,
|
|
597
|
-
children: "
|
|
742
|
+
children: tr("discard")
|
|
598
743
|
}),
|
|
599
744
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
600
745
|
style: styles.dim,
|
|
601
|
-
children: dirty ? "
|
|
746
|
+
children: dirty ? tr("dirty") : tr("synced")
|
|
602
747
|
})
|
|
603
748
|
]
|
|
604
749
|
}),
|
|
605
750
|
rows.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
606
751
|
style: styles.dim,
|
|
607
|
-
children: "
|
|
752
|
+
children: tr("emptyPaths")
|
|
608
753
|
}) : null,
|
|
609
754
|
rows.map((row, index) => {
|
|
610
755
|
const patternRow = row.path.includes("*");
|
|
@@ -616,16 +761,16 @@ window.__ModuleLoader__.load({
|
|
|
616
761
|
children: [
|
|
617
762
|
/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
618
763
|
style: styles.cardHead,
|
|
619
|
-
children: [/* @__PURE__ */ (0, react_jsx_runtime.
|
|
764
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
620
765
|
style: styles.cardTitle,
|
|
621
|
-
children:
|
|
766
|
+
children: tr("rowTitle", { index: index + 1 })
|
|
622
767
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
623
768
|
style: styles.cardHeadRight,
|
|
624
769
|
children: [hostEntry !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
625
770
|
style: STATUS_STYLE[hostEntry.status],
|
|
626
771
|
children: [
|
|
627
772
|
"[",
|
|
628
|
-
|
|
773
|
+
tr(hostEntry.status === "ok" ? "statusOk" : hostEntry.status === "missing" ? "statusMissing" : "statusRejected"),
|
|
629
774
|
hostMatches.length > 1 ? ` ×${hostMatches.length}` : "",
|
|
630
775
|
"]"
|
|
631
776
|
]
|
|
@@ -636,7 +781,7 @@ window.__ModuleLoader__.load({
|
|
|
636
781
|
setDirty(true);
|
|
637
782
|
setRows((current) => current.filter((_, i) => i !== index));
|
|
638
783
|
},
|
|
639
|
-
children: "
|
|
784
|
+
children: tr("delete")
|
|
640
785
|
})]
|
|
641
786
|
})]
|
|
642
787
|
}),
|
|
@@ -644,7 +789,7 @@ window.__ModuleLoader__.load({
|
|
|
644
789
|
className: "xp-input",
|
|
645
790
|
style: styles.pathInput,
|
|
646
791
|
value: row.path,
|
|
647
|
-
placeholder: "
|
|
792
|
+
placeholder: tr("pathPlaceholder"),
|
|
648
793
|
onChange: (event) => {
|
|
649
794
|
update(index, { path: event.target.value });
|
|
650
795
|
}
|
|
@@ -654,29 +799,25 @@ window.__ModuleLoader__.load({
|
|
|
654
799
|
children: patternRow ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
655
800
|
style: styles.dim,
|
|
656
801
|
children: [
|
|
657
|
-
"
|
|
802
|
+
tr("patternResolved"),
|
|
658
803
|
" ",
|
|
659
|
-
hostMatches.length > 0 ?
|
|
804
|
+
hostMatches.length > 0 ? tr("patternMatches", { count: hostMatches.length }) : tr("patternNoMatches")
|
|
660
805
|
]
|
|
661
806
|
}) : resolved === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
662
807
|
style: styles.dim,
|
|
663
|
-
children: row.path.trim() === "" ? "
|
|
808
|
+
children: row.path.trim() === "" ? tr("resolvePendingEmpty") : typedBase === "" ? tr("resolveNeedsBase") : !usableBase ? tr("resolveBaseInvalid") : tr("resolveNeedsHome")
|
|
664
809
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
665
810
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
666
811
|
style: styles.dim,
|
|
667
|
-
children: "
|
|
812
|
+
children: tr("resolvedAs")
|
|
668
813
|
}),
|
|
669
814
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
670
815
|
style: styles.code,
|
|
671
816
|
children: resolved
|
|
672
817
|
}),
|
|
673
|
-
hostEntry !== void 0 && hostEntry.resolved !== resolved ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
818
|
+
hostEntry !== void 0 && hostEntry.resolved !== resolved ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
674
819
|
style: styles.dim,
|
|
675
|
-
children:
|
|
676
|
-
"(宿主解析:",
|
|
677
|
-
hostEntry.resolved,
|
|
678
|
-
")"
|
|
679
|
-
]
|
|
820
|
+
children: tr("hostResolved", { path: hostEntry.resolved })
|
|
680
821
|
}) : null
|
|
681
822
|
] })
|
|
682
823
|
}),
|
|
@@ -684,7 +825,7 @@ window.__ModuleLoader__.load({
|
|
|
684
825
|
style: styles.controlsRow,
|
|
685
826
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("label", {
|
|
686
827
|
style: styles.field,
|
|
687
|
-
children: ["
|
|
828
|
+
children: [tr("mode"), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("select", {
|
|
688
829
|
className: "xp-select",
|
|
689
830
|
value: row.scope,
|
|
690
831
|
onChange: (event) => {
|
|
@@ -692,10 +833,10 @@ window.__ModuleLoader__.load({
|
|
|
692
833
|
},
|
|
693
834
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
694
835
|
value: "write",
|
|
695
|
-
children:
|
|
836
|
+
children: tr("scopeWrite")
|
|
696
837
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("option", {
|
|
697
838
|
value: "always-write",
|
|
698
|
-
children:
|
|
839
|
+
children: tr("scopeAlways")
|
|
699
840
|
})]
|
|
700
841
|
})]
|
|
701
842
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
@@ -703,7 +844,7 @@ window.__ModuleLoader__.load({
|
|
|
703
844
|
children: [
|
|
704
845
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
705
846
|
style: styles.dim,
|
|
706
|
-
children: "
|
|
847
|
+
children: tr("surfaces")
|
|
707
848
|
}),
|
|
708
849
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
709
850
|
type: "button",
|
|
@@ -711,7 +852,7 @@ window.__ModuleLoader__.load({
|
|
|
711
852
|
onClick: () => {
|
|
712
853
|
toggleSurface(index, "fs");
|
|
713
854
|
},
|
|
714
|
-
children: "
|
|
855
|
+
children: tr("surfaceFs")
|
|
715
856
|
}),
|
|
716
857
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
717
858
|
type: "button",
|
|
@@ -719,7 +860,7 @@ window.__ModuleLoader__.load({
|
|
|
719
860
|
onClick: () => {
|
|
720
861
|
toggleSurface(index, "shell");
|
|
721
862
|
},
|
|
722
|
-
children: "
|
|
863
|
+
children: tr("surfaceShell")
|
|
723
864
|
})
|
|
724
865
|
]
|
|
725
866
|
})]
|
|
@@ -736,32 +877,28 @@ window.__ModuleLoader__.load({
|
|
|
736
877
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
737
878
|
style: styles.panelHead,
|
|
738
879
|
children: [
|
|
739
|
-
"
|
|
740
|
-
dirty ? "
|
|
741
|
-
preview !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.
|
|
880
|
+
tr("previewTitle"),
|
|
881
|
+
dirty ? tr("previewDirty") : "",
|
|
882
|
+
preview !== void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
742
883
|
style: styles.dim,
|
|
743
|
-
children:
|
|
744
|
-
"生效根 ",
|
|
745
|
-
preview.effective.length,
|
|
746
|
-
" 条"
|
|
747
|
-
]
|
|
884
|
+
children: tr("previewEffective", { count: preview.effective.length })
|
|
748
885
|
}) : null
|
|
749
886
|
]
|
|
750
887
|
}), typedBase === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
751
888
|
style: styles.dim,
|
|
752
|
-
children: "
|
|
889
|
+
children: tr("previewNoBase")
|
|
753
890
|
}) : !usableBase ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
754
891
|
style: styles.dim,
|
|
755
|
-
children: "
|
|
892
|
+
children: tr("previewBadBase")
|
|
756
893
|
}) : base === "" ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
757
894
|
style: styles.dim,
|
|
758
|
-
children: "
|
|
895
|
+
children: tr("previewExpandingHome")
|
|
759
896
|
}) : preview === void 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
760
897
|
style: styles.dim,
|
|
761
|
-
children: "
|
|
898
|
+
children: tr("previewUnavailable")
|
|
762
899
|
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [preview.entries.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
763
900
|
style: styles.dim,
|
|
764
|
-
children: "
|
|
901
|
+
children: tr("previewEmpty")
|
|
765
902
|
}) : preview.entries.map((entry, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
766
903
|
style: styles.entry,
|
|
767
904
|
children: [
|
|
@@ -769,7 +906,7 @@ window.__ModuleLoader__.load({
|
|
|
769
906
|
style: STATUS_STYLE[entry.status],
|
|
770
907
|
children: [
|
|
771
908
|
"[",
|
|
772
|
-
|
|
909
|
+
tr(entry.status === "ok" ? "statusOk" : entry.status === "missing" ? "statusMissing" : "statusRejected"),
|
|
773
910
|
"]"
|
|
774
911
|
]
|
|
775
912
|
}),
|
|
@@ -783,7 +920,7 @@ window.__ModuleLoader__.load({
|
|
|
783
920
|
}),
|
|
784
921
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("code", {
|
|
785
922
|
style: styles.code,
|
|
786
|
-
children: entry.resolved === "" ? "
|
|
923
|
+
children: entry.resolved === "" ? tr("unresolved") : entry.resolved
|
|
787
924
|
})
|
|
788
925
|
]
|
|
789
926
|
}, `${index}-${entry.raw}`)), preview.warnings.map((warning) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -834,6 +971,15 @@ window.__ModuleLoader__.load({
|
|
|
834
971
|
* nothing declares is inert under `ctx.slots.inject` (the callback never runs),
|
|
835
972
|
* which is what lets one build register into both generations.
|
|
836
973
|
*
|
|
974
|
+
* LOCALIZED COPY FOLLOWS THE HOST'S OWN LANGUAGE SELECTION. The client half
|
|
975
|
+
* registers its `zh`/`en` dictionaries under this plugin's namespace through
|
|
976
|
+
* `ctx.locale.register`, and every slot registration declares `locale: NAMESPACE`
|
|
977
|
+
* so the renderer hands each page render the framework `t` seat. Switching
|
|
978
|
+
* Settings → General → Language therefore switches this page too, without a
|
|
979
|
+
* reload; languages without a dictionary fall back to English (the host's
|
|
980
|
+
* documented baseline), and a host without a locale seat (0.1.5 slots, tests)
|
|
981
|
+
* falls back to the built-in Chinese copy.
|
|
982
|
+
*
|
|
837
983
|
* Every @deepseek-ai/* import here is TYPE-ONLY (erased): the runtime services
|
|
838
984
|
* arrive through cordis, and react resolves from the page's module table
|
|
839
985
|
* (see dsh.client in package.json).
|
|
@@ -842,11 +988,12 @@ window.__ModuleLoader__.load({
|
|
|
842
988
|
/**
|
|
843
989
|
* Client services this half needs.
|
|
844
990
|
*
|
|
845
|
-
*
|
|
991
|
+
* `locale` ships in every supported host generation and backs the framework `t`
|
|
992
|
+
* seat; the settings scope itself is fetched late-bound below, because the
|
|
846
993
|
* 0.1.5 (`settingsScope`) and 0.2.x (`configForms`) providers differ and an
|
|
847
994
|
* `inject` entry for a service that never appears would block activation.
|
|
848
995
|
*/
|
|
849
|
-
const inject = ["slots"];
|
|
996
|
+
const inject = ["slots", "locale"];
|
|
850
997
|
/** The settings namespace this page edits — the one the host half registers. */
|
|
851
998
|
const NAMESPACE = "extra-paths";
|
|
852
999
|
/**
|
|
@@ -886,7 +1033,7 @@ window.__ModuleLoader__.load({
|
|
|
886
1033
|
set: (field, value) => {
|
|
887
1034
|
if (real === void 0) return Promise.resolve();
|
|
888
1035
|
return real.set(field, value).then((accepted) => {
|
|
889
|
-
if (accepted === false) throw
|
|
1036
|
+
if (accepted === false) throw saveRefusedError();
|
|
890
1037
|
return accepted;
|
|
891
1038
|
});
|
|
892
1039
|
}
|
|
@@ -906,6 +1053,13 @@ window.__ModuleLoader__.load({
|
|
|
906
1053
|
*/
|
|
907
1054
|
function apply(ctx) {
|
|
908
1055
|
const { scope, attach } = lateBoundScope();
|
|
1056
|
+
const registerLocales = () => ctx.locale.register(NAMESPACE, {
|
|
1057
|
+
zh,
|
|
1058
|
+
en
|
|
1059
|
+
});
|
|
1060
|
+
if (typeof ctx.effect === "function") ctx.effect(registerLocales, "extra-paths: locales");
|
|
1061
|
+
else registerLocales();
|
|
1062
|
+
const t = ctx.locale.bind(NAMESPACE);
|
|
909
1063
|
ctx.inject(["settingsScope"], (child) => {
|
|
910
1064
|
const { settingsScope } = child;
|
|
911
1065
|
attach(settingsScope.bind({ namespace: NAMESPACE }));
|
|
@@ -926,16 +1080,20 @@ window.__ModuleLoader__.load({
|
|
|
926
1080
|
/** The editor, forwarding the shell's workspace hook when the slot carries one. */
|
|
927
1081
|
const renderPage = (slotProps) => react.createElement(ExtraPathsPage, {
|
|
928
1082
|
scope,
|
|
1083
|
+
t: typeof slotProps?.t === "function" ? slotProps.t : void 0,
|
|
929
1084
|
getWorkspaces,
|
|
930
1085
|
useWorkspaces: typeof slotProps?.useWorkspaces === "function" ? slotProps.useWorkspaces : void 0
|
|
931
1086
|
});
|
|
932
1087
|
/** The slot component: one line for `summary`, the editor for every other view. */
|
|
933
|
-
const card = (slotProps) => slotProps?.view === "summary" ? react.createElement(ExtraPathsSummary, {
|
|
1088
|
+
const card = (slotProps) => slotProps?.view === "summary" ? react.createElement(ExtraPathsSummary, {
|
|
1089
|
+
scope,
|
|
1090
|
+
t: typeof slotProps.t === "function" ? slotProps.t : void 0
|
|
1091
|
+
}) : renderPage(slotProps);
|
|
934
1092
|
ctx.slots.inject("settings.section", () => ctx.slots.register({
|
|
935
1093
|
name: "settings.section",
|
|
936
1094
|
id: NAMESPACE,
|
|
937
1095
|
order: 40,
|
|
938
|
-
label: () => "
|
|
1096
|
+
label: () => t("navLabel"),
|
|
939
1097
|
locale: NAMESPACE,
|
|
940
1098
|
inject: props
|
|
941
1099
|
}, card));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-extra-paths",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "配置一组额外可写根:fs 工具与受限 shell 首次尝试即可写、无需审批,带 Web 设置页与按目录结构锚定的路径模式。 · DSH plugin: configured extra writable roots for the fs tools and the sandboxed shell, with a Web settings page and structure-anchored path patterns.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"client": {
|
|
28
28
|
"platform": "web",
|
|
29
29
|
"inject": [
|
|
30
|
+
"@deepseek-ai/dsh-client-locale",
|
|
30
31
|
"@deepseek-ai/dsh-client-ui-settings",
|
|
31
32
|
"@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
32
33
|
]
|
|
@@ -34,6 +35,7 @@
|
|
|
34
35
|
},
|
|
35
36
|
"scripts": {
|
|
36
37
|
"paths": "node scripts/dsh-paths.mjs",
|
|
38
|
+
"check:sanitized": "node scripts/check-sanitized.mjs",
|
|
37
39
|
"prepare": "node scripts/dsh-paths.mjs --tolerant",
|
|
38
40
|
"build": "pnpm run build:host && pnpm run build:client",
|
|
39
41
|
"build:host": "node scripts/dsh-paths.mjs && tsc -p tsconfig.json",
|