@jayyuen66/dsh-dir-prep-organize 0.1.9 → 0.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -27
- package/README.md +19 -17
- package/README.zh-CN.md +28 -26
- package/client.js +175 -44
- package/cordis.patch.yml +1 -4
- package/docs/DETAIL.zh.md +1 -1
- package/host.js +45 -45
- package/package.json +42 -44
- package/types/host.d.ts +40 -40
- package/types/src/client-entry.d.ts +2 -2
- package/types/src/client-timeouts.d.ts +2 -2
- package/types/src/host-messages.d.ts +6 -6
- package/types/src/input-writeback.d.ts +4 -4
- package/types/src/remote.d.ts +5 -5
- package/types/src/templates.d.ts +11 -11
- package/types/src/ui-messages.d.ts +9 -9
package/client.js
CHANGED
|
@@ -7,10 +7,9 @@ window.__ModuleLoader__.load({
|
|
|
7
7
|
let exports = module.exports;
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
9
9
|
let react = require("react");
|
|
10
|
-
let _jayyuen66_dsh_plugin_shared_client = require("@jayyuen66/dsh-plugin-shared/client");
|
|
11
10
|
let zod = require("zod");
|
|
12
11
|
// node_modules/@jayyuen66/dsh-plugin-shared/dist/record.js
|
|
13
|
-
function e(e) {
|
|
12
|
+
function e$1(e) {
|
|
14
13
|
return typeof e == `object` && !!e && !Array.isArray(e);
|
|
15
14
|
}
|
|
16
15
|
// src/templates.ts
|
|
@@ -20,7 +19,7 @@ function e(e) {
|
|
|
20
19
|
/** 视觉标记进入下拉前缀的最大字符数。 */
|
|
21
20
|
const EMOJI_MAX_LENGTH = 12;
|
|
22
21
|
/** 按 Unicode 码点截断:`String#slice` 数的是 UTF-16 码元,会把一个 emoji(代理对)或
|
|
23
|
-
* 组合字符劈成半个,落进模板后显示成空白方块。两个截断点(frontmatter
|
|
22
|
+
* 组合字符劈成半个,落进模板后显示成空白方块。两个截断点(frontmatter 解析与 `sanitizeTemplateList`)
|
|
24
23
|
* 共用这一份实现,scripts/gen-defaults-lib.mjs 有同源镜像。 */
|
|
25
24
|
function truncateCodePoints(value, max) {
|
|
26
25
|
const points = Array.from(value);
|
|
@@ -35,9 +34,9 @@ function uniqueEntryId(candidate, index, seen) {
|
|
|
35
34
|
return id;
|
|
36
35
|
}
|
|
37
36
|
/**
|
|
38
|
-
*
|
|
37
|
+
* 导入条目并入 `existing`(设置卡上未保存的 `draft` 列表):与既有 id 碰撞时确定性改写(追加 `-i` 直到唯一)。
|
|
39
38
|
* 返回新数组(不改输入),保证 pre-save 阶段 React key 唯一。sanitizeTemplateList 对**存量
|
|
40
|
-
* 快照**同样按序号补 id
|
|
39
|
+
* 快照**同样按序号补 id(缺失/空/撞名三档都管),这边要额外做的是避开 `existing` 里已有的 id
|
|
41
40
|
* ——两个入口各管一段,不靠对方兜底。
|
|
42
41
|
*/
|
|
43
42
|
function mergeImportedTemplates(existing, incoming) {
|
|
@@ -66,7 +65,7 @@ function trimField(value) {
|
|
|
66
65
|
* 返回 undefined 表示该条应被剔除。 */
|
|
67
66
|
function normalizeEntry(item, index, seen) {
|
|
68
67
|
let result;
|
|
69
|
-
if (e(item)) {
|
|
68
|
+
if (e$1(item)) {
|
|
70
69
|
const { id, name, description, text, group, emoji } = item;
|
|
71
70
|
const nextName = trimField(name);
|
|
72
71
|
const nextText = trimField(text);
|
|
@@ -85,7 +84,7 @@ function normalizeEntry(item, index, seen) {
|
|
|
85
84
|
}
|
|
86
85
|
return result;
|
|
87
86
|
}
|
|
88
|
-
/** 任意来源(settings 快照 /
|
|
87
|
+
/** 任意来源(settings 快照 / 设置卡未保存的 `draft`)→ 合法模板列表(纯函数,测试锁死)。
|
|
89
88
|
*
|
|
90
89
|
* - 非数组输入 → [](调用方自行决定是否回落 DEFAULT_TEMPLATES);
|
|
91
90
|
* - 剔除非对象条目与 name/text trim 后为空的条目;
|
|
@@ -105,7 +104,7 @@ function sanitizeTemplateList(raw) {
|
|
|
105
104
|
const BACKSLASH = String.fromCodePoint(92);
|
|
106
105
|
const WIN_DRIVE_LETTER = /^[A-Za-z]:$/u;
|
|
107
106
|
const TRAILING_SEPARATORS = /[/\\]+$/u;
|
|
108
|
-
/**
|
|
107
|
+
/** 绝对路径的形状(比 host 侧 path.isAbsolute 宽松一档的同一套判断:POSIX 根、win32 盘符、UNC)。
|
|
109
108
|
* client 半跑在浏览器里,没有 node:path 可用,故按形状判。 */
|
|
110
109
|
function isAbsolutePath(value) {
|
|
111
110
|
const winDrive = WIN_DRIVE_LETTER.test(value.slice(0, 2)) && (value[2] === "/" || value[2] === BACKSLASH);
|
|
@@ -118,7 +117,7 @@ function normalizeRootShape(value) {
|
|
|
118
117
|
if (stripped.length === 0 || WIN_DRIVE_LETTER.test(stripped)) return value;
|
|
119
118
|
return stripped;
|
|
120
119
|
}
|
|
121
|
-
/** 任意来源(settings 快照 /
|
|
120
|
+
/** 任意来源(settings 快照 / 设置卡未保存的 `rootsDraft`)→ 合法的「导入允许目录」列表(纯函数)。
|
|
122
121
|
* host 的导入策略是「会话 cwd + 内置角色库 + importAllowRoots」,绝对路径默认拒绝,
|
|
123
122
|
* 这里登记的每一项都是**放一个读盘口子**,故:
|
|
124
123
|
* - 非数组 → [](未设置 = 一条都不登记,不是"全放行");
|
|
@@ -127,9 +126,9 @@ function normalizeRootShape(value) {
|
|
|
127
126
|
* - **非绝对路径 → 丢弃**:契约是「额外允许的绝对目录」,相对项会被 host 按它自己的
|
|
128
127
|
* 进程 cwd 解析,等于登记了一条用户没写过、界面上也看不出指向哪里的允许根;`~`
|
|
129
128
|
* 靠 shell 展开,host 的 path.resolve 不展开它,同归这一档;
|
|
130
|
-
* - 末尾分隔符归一后去重(`/a` 与 `/a/`
|
|
129
|
+
* - 末尾分隔符归一后去重(`/a` 与 `/a/` 是同一棵目录树,不该在界面上摆两行);
|
|
131
130
|
* - 条数与单条长度都不设上限:静默丢一条就是「看着成功、内容没进去」;条目多撑长的
|
|
132
|
-
*
|
|
131
|
+
* 越界的回执由 host 侧的列举上限限制住。 */
|
|
133
132
|
function sanitizeAllowRoots(raw) {
|
|
134
133
|
const out = [];
|
|
135
134
|
if (Array.isArray(raw)) for (const item of raw) {
|
|
@@ -157,8 +156,8 @@ function isUsableTimeoutMs(value) {
|
|
|
157
156
|
/**
|
|
158
157
|
* `organizeTimeoutMs` 的前端取表。
|
|
159
158
|
*
|
|
160
|
-
* 上界与 host 同为 `[1, MAX_TIMER_MS]`:host
|
|
161
|
-
*
|
|
159
|
+
* 上界与 host 同为 `[1, MAX_TIMER_MS]`:host 自己夹了上界正是为了躲开上面那个静默的夹断,
|
|
160
|
+
* 而这里是**唯一**发起润色读取方法调用的地方,它要是没夹,host 夹得再对也没用。
|
|
162
161
|
*
|
|
163
162
|
* @param value - 配置表单投影值
|
|
164
163
|
* @returns `[1, MAX_TIMER_MS]` 区间内的整数;不合法时 undefined(回落默认)
|
|
@@ -410,25 +409,157 @@ const UI_MESSAGES = {
|
|
|
410
409
|
builtinRetry: "Retry"
|
|
411
410
|
}
|
|
412
411
|
};
|
|
412
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/card-ui-D2cuQvLS.js
|
|
413
|
+
const c = `
|
|
414
|
+
.dsu-form{display:flex;flex-direction:column}
|
|
415
|
+
.dsu-section{margin-top:24px;padding-top:24px;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
416
|
+
.dsu-form>.dsu-section:first-child{margin-top:0;padding-top:0;border-top:0}
|
|
417
|
+
.dsu-sectionTitle{margin:0;font-size:15px;font-weight:600;line-height:1.4;color:var(--dsw-alias-label-primary)}
|
|
418
|
+
.dsu-sectionHint{margin:4px 0 0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
419
|
+
.dsu-statusbar{display:flex;flex-wrap:wrap;gap:4px 8px;margin-top:8px;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
420
|
+
.dsu-field{display:grid;grid-template-columns:minmax(0,1fr) minmax(240px,360px);column-gap:32px;align-items:center;padding:12px 0;border-top:.5px solid var(--dsw-alias-border-l2)}
|
|
421
|
+
.dsu-fieldMeta{display:flex;flex-direction:column;gap:4px;min-width:0}
|
|
422
|
+
.dsu-labelRow{display:flex;align-items:center;gap:6px;min-width:0}
|
|
423
|
+
.dsu-label{font-size:13px;font-weight:500;line-height:1.5;color:var(--dsw-alias-label-primary)}
|
|
424
|
+
.dsu-labelMono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:12px}
|
|
425
|
+
.dsu-hint{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-label-tertiary)}
|
|
426
|
+
.dsu-control{min-width:0;display:flex;align-items:center;gap:8px}
|
|
427
|
+
.dsu-fieldWide{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
428
|
+
.dsu-fieldWide .dsu-control{width:100%;max-width:720px;margin-top:2px}
|
|
429
|
+
.dsu-help{display:inline-flex;align-items:center;gap:6px;min-width:0}
|
|
430
|
+
.dsu-helpBtn{appearance:none;border:0;background:transparent;padding:0;width:16px;height:16px;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-tertiary);cursor:help;border-radius:50%;flex:none}
|
|
431
|
+
.dsu-help:hover .dsu-helpBtn,.dsu-helpBtn:focus-visible{color:var(--dsw-alias-label-primary)}
|
|
432
|
+
.dsu-helpBtn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
433
|
+
.dsu-tip{position:fixed;z-index:60;box-sizing:border-box;max-width:min(340px,calc(100vw - 16px));max-height:calc(100vh - 16px);overflow:auto;overflow-wrap:anywhere;padding:10px 12px;border-radius:10px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);box-shadow:0 12px 32px rgb(0 0 0 / 45%);font-size:12px;line-height:1.6;font-weight:400;color:var(--dsw-alias-label-secondary)}
|
|
434
|
+
.dsu-input{width:100%;height:34px;padding:0 12px;border:.5px solid var(--dsw-alias-border-l4);border-radius:var(--dsw-radius-md);background:var(--dsw-alias-bg-layer-3);color:var(--dsw-alias-label-primary);font:inherit;font-size:13px}
|
|
435
|
+
.dsu-input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary)}
|
|
436
|
+
.dsu-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary)}
|
|
437
|
+
.dsu-input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}
|
|
438
|
+
.dsu-input::placeholder{color:var(--dsw-alias-label-tertiary)}
|
|
439
|
+
.dsu-textarea{height:auto;min-height:96px;padding:8px 12px;line-height:1.6;resize:vertical}
|
|
440
|
+
.dsu-mono{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace}
|
|
441
|
+
.dsu-numberWrap{display:flex;flex-direction:column;gap:4px;width:100%;min-width:0}
|
|
442
|
+
.dsu-number{display:flex;align-items:center;gap:8px;min-width:0}
|
|
443
|
+
.dsu-number .dsu-input{min-width:0}
|
|
444
|
+
.dsu-unit{flex:none;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
445
|
+
.dsu-error{margin:0;font-size:12px;line-height:1.5;color:var(--dsw-alias-state-error-primary)}
|
|
446
|
+
.dsu-switch{appearance:none;width:36px;height:20px;border-radius:999px;border:0;padding:2px;background:var(--dsw-alias-border-l3);display:flex;align-items:center;cursor:pointer;flex:none;transition:background-color .16s}
|
|
447
|
+
.dsu-knob{width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary);transition:transform .16s,background-color .16s}
|
|
448
|
+
.dsu-switch[aria-checked="true"]{background:var(--dsw-alias-label-primary)}
|
|
449
|
+
.dsu-switch[aria-checked="true"] .dsu-knob{transform:translateX(16px);background:var(--dsw-alias-label-primary-foreground)}
|
|
450
|
+
.dsu-switch:disabled{opacity:.4;cursor:not-allowed}
|
|
451
|
+
.dsu-switch:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:2px}
|
|
452
|
+
.dsu-selectWrap{position:relative;width:100%;min-width:0}
|
|
453
|
+
.dsu-select{display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;cursor:pointer}
|
|
454
|
+
.dsu-select[aria-expanded="true"]{border-color:var(--dsw-alias-state-business-primary)}
|
|
455
|
+
.dsu-selectValue{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
456
|
+
.dsu-chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s}
|
|
457
|
+
.dsu-select[aria-expanded="true"] .dsu-chevron{transform:rotate(180deg)}
|
|
458
|
+
.dsu-menu{position:fixed;position-area:block-end span-inline-start;justify-self:start;margin-top:6px;z-index:70;padding:4px;background:var(--dsw-alias-bg-layer-2);border:.5px solid var(--dsw-alias-border-l3);border-radius:12px;box-shadow:0 12px 32px rgb(0 0 0 / 50%);max-height:280px;overflow:auto}
|
|
459
|
+
.dsu-option{appearance:none;border:0;background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.4;width:100%;display:flex;align-items:center;justify-content:space-between;gap:12px;padding:8px 10px;border-radius:8px;cursor:pointer;text-align:left}
|
|
460
|
+
.dsu-option:hover,.dsu-option[data-active="true"]{background:var(--dsw-alias-bg-layer-3)}
|
|
461
|
+
.dsu-option:disabled{color:var(--dsw-alias-label-tertiary);cursor:not-allowed}
|
|
462
|
+
.dsu-option:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:-2px}
|
|
463
|
+
.dsu-optionGroup{padding:6px 10px 2px;font-size:11px;font-weight:600;color:var(--dsw-alias-label-tertiary)}
|
|
464
|
+
.dsu-check{opacity:0;flex:none}
|
|
465
|
+
.dsu-option[aria-selected="true"] .dsu-check{opacity:1}
|
|
466
|
+
.dsu-savebar{display:flex;align-items:center;gap:8px;padding:12px 0;margin-top:24px;border-top:.5px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-base)}
|
|
467
|
+
.dsu-savebar[data-dirty="true"]{position:sticky;bottom:0;z-index:2;box-shadow:0 -12px 24px rgb(0 0 0 / 35%)}
|
|
468
|
+
.dsu-btn{appearance:none;border:.5px solid var(--dsw-alias-border-l2);background:transparent;color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.5;border-radius:var(--dsw-radius-md);padding:5px 14px;cursor:pointer;transition:background-color .12s,border-color .12s,color .12s,filter .12s}
|
|
469
|
+
.dsu-btn:hover:not(:disabled){background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-border-l3)}
|
|
470
|
+
.dsu-btn:active:not(:disabled){background:var(--dsw-alias-bg-layer-1)}
|
|
471
|
+
.dsu-btn:focus-visible{outline:2px solid var(--dsw-alias-state-business-primary);outline-offset:1px}
|
|
472
|
+
.dsu-btn:disabled{opacity:.4;cursor:not-allowed}
|
|
473
|
+
.dsu-btnPrimary{background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
|
|
474
|
+
.dsu-btnPrimary:hover:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.9)}
|
|
475
|
+
.dsu-btnPrimary:active:not(:disabled){background:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-primary);filter:brightness(.84)}
|
|
476
|
+
.dsu-btnDanger{color:var(--dsw-alias-state-error-primary)}
|
|
477
|
+
.dsu-btnDanger:hover:not(:disabled){color:var(--dsw-alias-state-error-primary);border-color:var(--dsw-alias-state-error-primary);background:var(--dsw-alias-bg-layer-2)}
|
|
478
|
+
.dsu-status{margin-left:auto;font-size:12px;color:var(--dsw-alias-label-tertiary)}
|
|
479
|
+
.dsu-statusError{color:var(--dsw-alias-state-error-primary)}
|
|
480
|
+
.dsu-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(200px,100%),1fr));gap:0 24px}
|
|
481
|
+
.dsu-grid>.dsu-field{display:flex;flex-direction:column;align-items:stretch;gap:6px;padding:10px 0;border-top:.5px solid var(--dsw-alias-border-l1)}
|
|
482
|
+
.dsu-grid>.dsu-field .dsu-control{width:100%}
|
|
483
|
+
@media (max-width:640px){
|
|
484
|
+
.dsu-field{grid-template-columns:minmax(0,1fr);align-items:start}
|
|
485
|
+
.dsu-control{width:100%;max-width:720px}
|
|
486
|
+
.dsu-section{margin-top:20px;padding-top:20px}
|
|
487
|
+
}
|
|
488
|
+
@media (prefers-reduced-motion:reduce){
|
|
489
|
+
.dsu-switch,.dsu-knob,.dsu-chevron,.dsu-btn{transition:none}
|
|
490
|
+
}
|
|
491
|
+
`;
|
|
492
|
+
function u(t) {
|
|
493
|
+
return (0, react.createElement)(`div`, { className: `dsu-form` }, t.children);
|
|
494
|
+
}
|
|
495
|
+
function d(t) {
|
|
496
|
+
return (0, react.createElement)(`section`, { className: `dsu-section` }, (0, react.createElement)(`h2`, { className: `dsu-sectionTitle` }, t.title), t.hint === void 0 ? null : (0, react.createElement)(`p`, { className: `dsu-sectionHint` }, t.hint), t.children);
|
|
497
|
+
}
|
|
498
|
+
function C(t) {
|
|
499
|
+
let n = !t.writable || t.busy || !t.dirty, r;
|
|
500
|
+
return r = t.error === null ? t.writable ? t.dirty ? t.dirtyLabel : t.cleanLabel : t.readOnlyLabel : t.error, (0, react.createElement)(`div`, {
|
|
501
|
+
className: `dsu-savebar`,
|
|
502
|
+
"data-dirty": t.dirty
|
|
503
|
+
}, (0, react.createElement)(`button`, {
|
|
504
|
+
type: `button`,
|
|
505
|
+
className: `dsu-btn dsu-btnPrimary`,
|
|
506
|
+
"data-field": `save`,
|
|
507
|
+
disabled: n,
|
|
508
|
+
onClick: t.onSave
|
|
509
|
+
}, t.busy ? t.savingLabel : t.saveLabel), (0, react.createElement)(`button`, {
|
|
510
|
+
type: `button`,
|
|
511
|
+
className: `dsu-btn`,
|
|
512
|
+
"data-field": `discard`,
|
|
513
|
+
disabled: n,
|
|
514
|
+
onClick: t.onDiscard
|
|
515
|
+
}, t.revertLabel), (0, react.createElement)(`span`, { className: t.error === null ? `dsu-status` : `dsu-status dsu-statusError` }, r));
|
|
516
|
+
}
|
|
517
|
+
// node_modules/@jayyuen66/dsh-plugin-shared/dist/errors.js
|
|
518
|
+
function t(e) {
|
|
519
|
+
let t = Object.getOwnPropertyDescriptor(e, `message`);
|
|
520
|
+
return t !== void 0 && `value` in t && typeof t.value == `string` ? t.value : void 0;
|
|
521
|
+
}
|
|
522
|
+
function n(e, r) {
|
|
523
|
+
if (r.has(e)) return `<circular cause>`;
|
|
524
|
+
r.add(e);
|
|
525
|
+
try {
|
|
526
|
+
if (!(e instanceof Error)) {
|
|
527
|
+
if (typeof e == `object` && e) {
|
|
528
|
+
let n = t(e);
|
|
529
|
+
if (n !== void 0 && n !== ``) return n;
|
|
530
|
+
}
|
|
531
|
+
return String(e);
|
|
532
|
+
}
|
|
533
|
+
let i = e.message === `` ? e.name : e.message, a = typeof globalThis.AggregateError == `function` && e instanceof AggregateError && e.errors.length > 0 ? ` [${e.errors.map((e) => n(e, r)).join(`; `)}]` : ``, o = e.cause === void 0 || e.cause === null ? `` : n(e.cause, r);
|
|
534
|
+
return `${i}${a}${o === `` || o === i ? `` : `: ${o}`}`;
|
|
535
|
+
} catch {
|
|
536
|
+
return `<unrenderable value>`;
|
|
537
|
+
} finally {
|
|
538
|
+
r.delete(e);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
function r(e) {
|
|
542
|
+
return n(e, /* @__PURE__ */ new Set());
|
|
543
|
+
}
|
|
413
544
|
// src/input-writeback.ts
|
|
414
545
|
/**
|
|
415
546
|
* 输入框异步写回的凭据与判定。
|
|
416
547
|
*
|
|
417
|
-
*
|
|
548
|
+
* 润色结果是整稿替换:发起时记下会话、`draftRev` 与输入动作对象,返回时用**最新一帧**
|
|
418
549
|
* 核对。任一项在途中变了(用户继续编辑、宿主进入提交期、会话被切换、组件重挂成
|
|
419
550
|
* 另一份 facade),结果都不许落地——宁可报「未写回」,也不能覆盖用户后来的输入。
|
|
420
551
|
* 模板走插入语义(captureInsertion + insertText),由宿主按发起的选区做版本校验。
|
|
421
552
|
*/
|
|
422
|
-
/**
|
|
553
|
+
/** 宿主是否给了整稿替换接口(润色结果最后落到 setDraft)。 */
|
|
423
554
|
function hasDraftFace(actions) {
|
|
424
555
|
return actions !== void 0 && typeof actions.setDraft === "function";
|
|
425
556
|
}
|
|
426
|
-
/**
|
|
557
|
+
/** 宿主是否给了版本校验的插入接口(模板走这一对,不整稿覆盖)。 */
|
|
427
558
|
function hasInsertFace(actions) {
|
|
428
559
|
return actions !== void 0 && typeof actions.captureInsertion === "function" && typeof actions.insertText === "function";
|
|
429
560
|
}
|
|
430
561
|
/** 提交期(`phase !== "plain"`)也算失效:发送成功后编辑器会被清空,失败时原稿要留着,
|
|
431
|
-
*
|
|
562
|
+
* 两种情况下在途的润色结果都不该再经 `setDraft` 写回输入框。 */
|
|
432
563
|
function useWriteBack(input, messages) {
|
|
433
564
|
const latest = (0, react.useRef)(input);
|
|
434
565
|
const active = (0, react.useRef)(void 0);
|
|
@@ -472,7 +603,7 @@ function useWriteBack(input, messages) {
|
|
|
472
603
|
};
|
|
473
604
|
}
|
|
474
605
|
// src/remote.ts
|
|
475
|
-
/** Typert Remote 命名空间(client
|
|
606
|
+
/** Typert Remote 命名空间(client 半只用这一枚)。
|
|
476
607
|
*
|
|
477
608
|
* 宿主半的注册键在 host.ts 的 `DIR_PREP_REMOTE_NAMESPACE`——两半各自打包、client 包
|
|
478
609
|
* 不能 import host.ts,所以这一枚字面量必然有两份。两边取值必须一致:写岔了的表现是
|
|
@@ -594,13 +725,13 @@ const DIR_PREP_DESCRIPTORS = [
|
|
|
594
725
|
result: { mode: "src-json" }
|
|
595
726
|
}
|
|
596
727
|
];
|
|
597
|
-
const isMounter = (value) => (
|
|
598
|
-
const isNamespace = (value) => (
|
|
728
|
+
const isMounter = (value) => e$1(value) && typeof value["$mount"] === "function";
|
|
729
|
+
const isNamespace = (value) => e$1(value) && typeof value["defaults"] === "function" && typeof value["context"] === "function" && typeof value["model"] === "function" && typeof value["organize"] === "function" && typeof value["importTemplates"] === "function";
|
|
599
730
|
const unwrap = (raw) => {
|
|
600
|
-
if (!(
|
|
731
|
+
if (!e$1(raw) || typeof raw["ok"] !== "boolean") throw new TypeError("Typert Remote 应答不是 RemoteResult:缺少布尔字段 ok");
|
|
601
732
|
if (!raw["ok"]) {
|
|
602
733
|
const { error } = raw;
|
|
603
|
-
if (!(
|
|
734
|
+
if (!e$1(error) || typeof error["code"] !== "string" || typeof error["message"] !== "string") throw new TypeError("Typert Remote 应答的 error 分支缺 code/message");
|
|
604
735
|
throw new Error(`${error["code"]}: ${error["message"]}`);
|
|
605
736
|
}
|
|
606
737
|
if (!("value" in raw)) throw new TypeError("Typert Remote 应答的 ok 分支缺 value 字段");
|
|
@@ -635,12 +766,12 @@ function buildReader(ctx, remote) {
|
|
|
635
766
|
importTemplates: async (args) => call((namespace) => namespace.importTemplates(args))
|
|
636
767
|
};
|
|
637
768
|
}
|
|
638
|
-
/**
|
|
769
|
+
/** 造读取器;当前部署没有远程通道时 undefined(卡片只显示读不到)。
|
|
639
770
|
*
|
|
640
|
-
* `get`
|
|
771
|
+
* `get` 这两处的做法和 buildReader 里查命名空间时保持一致,都显式传 `strict = false`:
|
|
641
772
|
* 不传时 cordis 默认只返回「提供者 fiber 当前 active」的实现,而设置卡可能在 fiber
|
|
642
|
-
*
|
|
643
|
-
* `get`
|
|
773
|
+
* 就绪前就挂上——那时读取方法会拿到 undefined 并显示「读不到」,看起来是插件没装。
|
|
774
|
+
* `get` 本身也可能抛(宿主版本演进之后,反射接口可能不再接受 bool),接住它只是为了把这
|
|
644
775
|
* 一栏降级成「读不到」,不让整张卡片跟着炸。 */
|
|
645
776
|
function createDirPrepReader(ctx) {
|
|
646
777
|
let remote;
|
|
@@ -655,7 +786,7 @@ function createDirPrepReader(ctx) {
|
|
|
655
786
|
const NS = "dir-prep-organize";
|
|
656
787
|
const BUNDLE_PKG = "@jayyuen66/dsh-dir-prep-organize";
|
|
657
788
|
const ERROR_FLASH_MS = 4e3;
|
|
658
|
-
/**
|
|
789
|
+
/** 除润色之外的调用的等待上限。润色那一发有自己的超时(来自设置卡的 organizeTimeoutMs)。 */
|
|
659
790
|
const REMOTE_TIMEOUT_MS = 125e3;
|
|
660
791
|
const RESET_CONFIRM_MS = 4e3;
|
|
661
792
|
const EMOJI_PLACEHOLDER = "😀";
|
|
@@ -665,7 +796,7 @@ const CLASS_ROW_HEAD = "dpic-rowhead";
|
|
|
665
796
|
const CLASS_IMPORT_PATH = "dpic-importpath";
|
|
666
797
|
const SLOT_INPUT_RIGHT = "conversation.input.right";
|
|
667
798
|
function parseDirEntry(raw) {
|
|
668
|
-
const { name, isDir, sizeBytes, snippet } = (
|
|
799
|
+
const { name, isDir, sizeBytes, snippet } = e$1(raw) ? raw : {};
|
|
669
800
|
return {
|
|
670
801
|
name: typeof name === "string" ? name : "",
|
|
671
802
|
isDir: isDir === true,
|
|
@@ -696,7 +827,7 @@ function skipCountsOf(skips) {
|
|
|
696
827
|
];
|
|
697
828
|
}
|
|
698
829
|
function parseContextResponse(raw) {
|
|
699
|
-
const rec = (
|
|
830
|
+
const rec = e$1(raw) ? raw : {};
|
|
700
831
|
const { ok, truncated, entries } = rec;
|
|
701
832
|
const parsedEntries = Array.isArray(entries) ? entries.map((entry) => parseDirEntry(entry)) : void 0;
|
|
702
833
|
return {
|
|
@@ -708,7 +839,7 @@ function parseContextResponse(raw) {
|
|
|
708
839
|
};
|
|
709
840
|
}
|
|
710
841
|
function parseModelResponse(raw) {
|
|
711
|
-
const rec = (
|
|
842
|
+
const rec = e$1(raw) ? raw : {};
|
|
712
843
|
return {
|
|
713
844
|
ok: rec["ok"] === true,
|
|
714
845
|
...spreadIfDefined(optionalString(rec, "error"), "error"),
|
|
@@ -718,7 +849,7 @@ function parseModelResponse(raw) {
|
|
|
718
849
|
};
|
|
719
850
|
}
|
|
720
851
|
function parseOrganizeResponse(raw) {
|
|
721
|
-
const rec = (
|
|
852
|
+
const rec = e$1(raw) ? raw : {};
|
|
722
853
|
return {
|
|
723
854
|
ok: rec["ok"] === true,
|
|
724
855
|
...spreadIfDefined(optionalString(rec, "error"), "error"),
|
|
@@ -746,14 +877,14 @@ function formatImportSkips(t, skips) {
|
|
|
746
877
|
return parts.length === 0 ? "" : t("skipSummary", { list: parts.join(t("skipSeparator")) });
|
|
747
878
|
}
|
|
748
879
|
function parseImportResponse(raw) {
|
|
749
|
-
const { ok, error, count, truncated, skipped, entries } = (
|
|
880
|
+
const { ok, error, count, truncated, skipped, entries } = e$1(raw) ? raw : {};
|
|
750
881
|
const parsedEntries = Array.isArray(entries) ? sanitizeTemplateList(entries) : void 0;
|
|
751
882
|
return {
|
|
752
883
|
ok: ok === true,
|
|
753
884
|
...typeof error === "string" ? { error } : {},
|
|
754
885
|
...typeof count === "number" ? { count } : {},
|
|
755
886
|
...truncated === true ? { truncated: true } : {},
|
|
756
|
-
...(
|
|
887
|
+
...e$1(skipped) ? { skipped: parseImportSkips(skipped) } : {},
|
|
757
888
|
...parsedEntries === void 0 ? {} : { entries: parsedEntries }
|
|
758
889
|
};
|
|
759
890
|
}
|
|
@@ -796,7 +927,7 @@ function builtinTemplatesSnapshot() {
|
|
|
796
927
|
return builtinState;
|
|
797
928
|
}
|
|
798
929
|
let dirPrepReader;
|
|
799
|
-
/** 导出仅供单测:不经过 apply
|
|
930
|
+
/** 导出仅供单测:不经过 apply 的纯读取方法用例直接注入替身。 */
|
|
800
931
|
function setDirPrepReader(reader) {
|
|
801
932
|
dirPrepReader = reader;
|
|
802
933
|
}
|
|
@@ -819,7 +950,7 @@ var LocalizedOrganizeError = class extends Error {
|
|
|
819
950
|
this.params = params;
|
|
820
951
|
}
|
|
821
952
|
};
|
|
822
|
-
/**
|
|
953
|
+
/** 客户端的超时只影响等待:宿主侧的润色超时仍由它自己的 AbortController 收尾。 */
|
|
823
954
|
async function within(pending, timeoutMs) {
|
|
824
955
|
const gate = Promise.withResolvers();
|
|
825
956
|
const timer = setTimeout(() => {
|
|
@@ -844,7 +975,7 @@ async function loadBuiltinTemplates() {
|
|
|
844
975
|
let settled;
|
|
845
976
|
try {
|
|
846
977
|
const body = await within(requireReader().defaults(), REMOTE_TIMEOUT_MS);
|
|
847
|
-
const payload = (
|
|
978
|
+
const payload = e$1(body) ? body : void 0;
|
|
848
979
|
const okKey = "ok";
|
|
849
980
|
const templatesKey = "templates";
|
|
850
981
|
const rawReason = payload?.["error"];
|
|
@@ -861,7 +992,7 @@ async function loadBuiltinTemplates() {
|
|
|
861
992
|
settled = {
|
|
862
993
|
phase: "error",
|
|
863
994
|
list: [],
|
|
864
|
-
error: (
|
|
995
|
+
error: r(error)
|
|
865
996
|
};
|
|
866
997
|
} finally {
|
|
867
998
|
if (builtinGeneration === generation) builtinInflight = null;
|
|
@@ -1144,7 +1275,7 @@ async function runOrganizeClick(args) {
|
|
|
1144
1275
|
writeDraft(content);
|
|
1145
1276
|
} catch (error) {
|
|
1146
1277
|
if (seq.current !== mySeq) return;
|
|
1147
|
-
setFailed(error instanceof LocalizedOrganizeError ? t(error.messageKey, error.params) : (
|
|
1278
|
+
setFailed(error instanceof LocalizedOrganizeError ? t(error.messageKey, error.params) : r(error));
|
|
1148
1279
|
if (flashTimer.current !== null) clearTimeout(flashTimer.current);
|
|
1149
1280
|
flashTimer.current = setTimeout(() => {
|
|
1150
1281
|
setFailed(void 0);
|
|
@@ -1571,7 +1702,7 @@ function ImportPanel(props) {
|
|
|
1571
1702
|
skips: skipNote
|
|
1572
1703
|
}));
|
|
1573
1704
|
} catch (error) {
|
|
1574
|
-
setImportError((
|
|
1705
|
+
setImportError(r(error));
|
|
1575
1706
|
} finally {
|
|
1576
1707
|
setImportBusy(false);
|
|
1577
1708
|
}
|
|
@@ -1764,7 +1895,7 @@ function createPersistActions(args) {
|
|
|
1764
1895
|
const { t, editable, dirty, rootsDirty, anythingDirty, confirmReset, templates, allowRoots, draft, rootsDraft, set, unset, readBack, setDraft, setDraftFor, setRootsDraft, setBusy, setSaveError, setConfirmReset } = args;
|
|
1765
1896
|
function reportError(err) {
|
|
1766
1897
|
console.error("[dir-prep-organize] templates settings write failed:", err);
|
|
1767
|
-
setSaveError((
|
|
1898
|
+
setSaveError(r(err));
|
|
1768
1899
|
}
|
|
1769
1900
|
async function onSave() {
|
|
1770
1901
|
if (!editable || !anythingDirty) return;
|
|
@@ -1824,13 +1955,13 @@ function createPersistActions(args) {
|
|
|
1824
1955
|
onReset
|
|
1825
1956
|
};
|
|
1826
1957
|
}
|
|
1827
|
-
/** 卡片正文:状态提示 + 工具条 + 角色行表 +
|
|
1958
|
+
/** 卡片正文:状态提示 + 工具条 + 角色行表 + 导入区 + 允许目录区 + 保存条。 */
|
|
1828
1959
|
function createCardBody(view) {
|
|
1829
1960
|
const { t, statusHint, draft, rootsDraft, foot, editable, anythingDirty, busy, confirmReset, saveError } = view;
|
|
1830
1961
|
const { onCommit, onDelete, onAdd, onImported, onRootChange, onRootDelete, onRootAdd } = view.draftActions;
|
|
1831
1962
|
const { onSave, onDiscard, onReset } = view.persistActions;
|
|
1832
1963
|
const footHint = (0, react.createElement)("p", { className: "dpic-hint" }, t("footHint"));
|
|
1833
|
-
const saveBar = (0, react.createElement)(
|
|
1964
|
+
const saveBar = (0, react.createElement)(C, {
|
|
1834
1965
|
dirty: anythingDirty,
|
|
1835
1966
|
busy,
|
|
1836
1967
|
writable: editable,
|
|
@@ -1846,7 +1977,7 @@ function createCardBody(view) {
|
|
|
1846
1977
|
},
|
|
1847
1978
|
onDiscard
|
|
1848
1979
|
});
|
|
1849
|
-
return (0, react.createElement)(
|
|
1980
|
+
return (0, react.createElement)(u, null, statusHint === "" ? null : (0, react.createElement)("p", { className: "dpic-hint" }, statusHint), (0, react.createElement)(d, {
|
|
1850
1981
|
title: t("rolesSection"),
|
|
1851
1982
|
hint: t("rolesHint")
|
|
1852
1983
|
}, (0, react.createElement)(CardToolbar, {
|
|
@@ -2017,7 +2148,7 @@ function apply(ctx) {
|
|
|
2017
2148
|
ctx.effect(() => {
|
|
2018
2149
|
const tag = document.createElement("style");
|
|
2019
2150
|
tag.id = "dir-prep-organize-css";
|
|
2020
|
-
tag.textContent = `${CARD_STYLES}\n${
|
|
2151
|
+
tag.textContent = `${CARD_STYLES}\n${c}`;
|
|
2021
2152
|
document.head.append(tag);
|
|
2022
2153
|
return () => {
|
|
2023
2154
|
tag.remove();
|
package/cordis.patch.yml
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
# 本包提供的输入框「润色」与「模板」能力由 client 半注册成 dock 条目;这份 patch 只负责
|
|
2
|
-
# 把 bundle
|
|
2
|
+
# 把 bundle 插进插件层栈。设置卡的数据走官方 Typert Remote 的 dirPrepOrganize 命名空间,
|
|
3
3
|
# 内置精选集由 host 半从 templates.data.mjs 经 defaults 方法按需下发。
|
|
4
4
|
# 架构与数据流见 README 与 host.ts / src/client-entry.ts。
|
|
5
5
|
- insert:
|
|
6
|
-
# 故意不写 id:shared 是本包 patch 启用的内部组件行,不是用户可停用的独立组件;
|
|
7
|
-
# 写 id 会让插件页出现一个可关闭的组件,关闭后本包设置卡会失去组件供应。
|
|
8
|
-
- name: "@jayyuen66/dsh-plugin-shared"
|
|
9
6
|
- id: dir-prep-organize
|
|
10
7
|
name: "@jayyuen66/dsh-dir-prep-organize"
|
package/docs/DETAIL.zh.md
CHANGED