@leiyi-works/dsh-session-tmpdir 0.9.9 → 0.9.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/README.md +4 -0
- package/client.js +50 -49
- package/index.js +20 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -239,3 +239,7 @@ v0.9.9 变更(2026-11-16):**白名单改为跨机同步(用户要求)*
|
|
|
239
239
|
- 一台机删除的批准不会被另一台机同步“复活”;
|
|
240
240
|
- 云端落在“加载之后、保存之前”也不会覆盖掉另一台机的条目。
|
|
241
241
|
4. 面板显示每条来源机器;移除任何机器的条目都写墓碑,其他机器同步后会一起消失。
|
|
242
|
+
|
|
243
|
+
v0.9.10 变更(2026-11-16):**面板只显示本机白名单**。跨机同步来的其他机器条目仍保留在白名单文件里(继续参与合并、墓碑与回收判定),但界面只展示本机条目,避免出现用不上的别机路径;条目上的机器标记随之去掉。顶部小字改为带标签的说明:`改写放行`(已存在文件是否免审批)、`临时根`(`_tmp/`)、`白名单文件`(同步文件的绝对路径)。
|
|
244
|
+
|
|
245
|
+
v0.9.11 变更(2026-11-16):**修复 0.9.10 客户端语法错误**(`client.js` 少一个括号,面板无法加载)。面板渲染重写为更简单的数组结构(同样的功能:右侧边栏标签页、5 秒自动刷新、本机白名单展示/移除、目标不存在标记),并补充「本机白名单」文案。
|
package/client.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* dsh-session-tmpdir — Client half(v0.9.
|
|
2
|
+
* dsh-session-tmpdir — Client half(v0.9.11).
|
|
3
3
|
*
|
|
4
4
|
* 左侧菜单「临时目录」入口:点击时切到**右侧边栏标签页**(和「常驻钥则」一致);
|
|
5
5
|
* 侧边栏不可用时回退到全页面板。
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
7
|
+
* 面板内容:**本机**长期落点白名单(别机条目同步在文件里但不展示),
|
|
8
|
+
* 5 秒自动刷新(仅页面可见时),支持「移除」;目标已不存在的条目由宿主自动回收。
|
|
9
9
|
*
|
|
10
10
|
* 宿主接口:
|
|
11
|
-
* GET /__dsh-session-tmpdir/state
|
|
11
|
+
* GET /__dsh-session-tmpdir/state 本机白名单清单 + 配置
|
|
12
12
|
* POST /__dsh-session-tmpdir/revoke { id } 移除一条
|
|
13
13
|
*/
|
|
14
14
|
window.__ModuleLoader__.load({
|
|
@@ -114,7 +114,9 @@ window.__ModuleLoader__.load({
|
|
|
114
114
|
const [busy, setBusy] = React.useState('')
|
|
115
115
|
const aliveRef = React.useRef(true)
|
|
116
116
|
|
|
117
|
-
React.useEffect(() => () => {
|
|
117
|
+
React.useEffect(() => () => {
|
|
118
|
+
aliveRef.current = false
|
|
119
|
+
}, [])
|
|
118
120
|
|
|
119
121
|
const load = React.useCallback(async (quiet = false) => {
|
|
120
122
|
if (!quiet) setState((prev) => ({ ...prev, loading: true, error: '' }))
|
|
@@ -164,7 +166,46 @@ window.__ModuleLoader__.load({
|
|
|
164
166
|
}
|
|
165
167
|
|
|
166
168
|
const data = state.data
|
|
167
|
-
const rows =
|
|
169
|
+
const rows = data && Array.isArray(data.approvals) ? data.approvals : []
|
|
170
|
+
|
|
171
|
+
const metaLine = data
|
|
172
|
+
? h(
|
|
173
|
+
'p',
|
|
174
|
+
{ style: styles.meta },
|
|
175
|
+
`改写放行:${data.allowOverwrite ? '是' : '否'} · 临时根:${data.rootDirName || '_tmp'}/ · 白名单文件:${data.approvalsFile || ''}`,
|
|
176
|
+
)
|
|
177
|
+
: null
|
|
178
|
+
|
|
179
|
+
const rowNodes = rows.map((row) => {
|
|
180
|
+
const meta = [
|
|
181
|
+
h('span', { key: 'kind', style: styles.tag }, row.kind === 'dir' ? '目录' : '文件'),
|
|
182
|
+
row.exists === false ? h('span', { key: 'missing', style: styles.tagWarn }, '目标不存在') : null,
|
|
183
|
+
h('span', { key: 'time', style: styles.meta }, `同意于 ${fmtTime(row.approvedAt) || '未知时间'}`),
|
|
184
|
+
row.sessionId
|
|
185
|
+
? h(
|
|
186
|
+
'span',
|
|
187
|
+
{ key: 'session', style: styles.meta },
|
|
188
|
+
`会话 ${shortSession(row.sessionId)}${row.current ? '(当前)' : ''}`,
|
|
189
|
+
)
|
|
190
|
+
: null,
|
|
191
|
+
row.reason ? h('span', { key: 'reason', style: styles.meta }, row.reason) : null,
|
|
192
|
+
].filter(Boolean)
|
|
193
|
+
return h(
|
|
194
|
+
'div',
|
|
195
|
+
{ key: row.id, style: styles.row },
|
|
196
|
+
h(
|
|
197
|
+
'div',
|
|
198
|
+
{ style: styles.rowMain },
|
|
199
|
+
h('div', { style: styles.path }, row.path),
|
|
200
|
+
h('div', { style: styles.rowMeta }, ...meta),
|
|
201
|
+
),
|
|
202
|
+
h(
|
|
203
|
+
'button',
|
|
204
|
+
{ style: styles.btnDanger, disabled: busy === row.id, onClick: () => void remove(row.id) },
|
|
205
|
+
busy === row.id ? '移除中…' : '移除',
|
|
206
|
+
),
|
|
207
|
+
)
|
|
208
|
+
})
|
|
168
209
|
|
|
169
210
|
return h(
|
|
170
211
|
'div',
|
|
@@ -176,15 +217,9 @@ window.__ModuleLoader__.load({
|
|
|
176
217
|
h(
|
|
177
218
|
'p',
|
|
178
219
|
{ style: styles.hint },
|
|
179
|
-
'
|
|
220
|
+
'本机长期落点白名单:在临时目录外**新建**产物要先经过你同意,同意后才会出现在这里;**改写已存在文件**按规则直接放行,不弹窗。目标被删除后条目会自动消失。',
|
|
180
221
|
),
|
|
181
|
-
|
|
182
|
-
? h(
|
|
183
|
-
'p',
|
|
184
|
-
{ style: styles.meta },
|
|
185
|
-
`改写放行:${data.allowOverwrite ? '是' : '否'} · 临时根:${data.rootDirName || '_tmp'}/ · ${data.approvalsFile || ''}`,
|
|
186
|
-
)
|
|
187
|
-
: null,
|
|
222
|
+
metaLine,
|
|
188
223
|
h(
|
|
189
224
|
'div',
|
|
190
225
|
{ style: styles.bar },
|
|
@@ -197,41 +232,7 @@ window.__ModuleLoader__.load({
|
|
|
197
232
|
state.error ? h('p', { style: styles.err }, state.error) : null,
|
|
198
233
|
rows.length === 0
|
|
199
234
|
? h('p', { style: styles.empty }, state.loading ? '' : '白名单为空。')
|
|
200
|
-
: h(
|
|
201
|
-
'div',
|
|
202
|
-
{ style: styles.table },
|
|
203
|
-
rows.map((row) =>
|
|
204
|
-
h(
|
|
205
|
-
'div',
|
|
206
|
-
{ key: row.id, style: styles.row },
|
|
207
|
-
h(
|
|
208
|
-
'div',
|
|
209
|
-
{ style: styles.rowMain },
|
|
210
|
-
h('div', { style: styles.path }, row.path),
|
|
211
|
-
h(
|
|
212
|
-
'div',
|
|
213
|
-
{ style: styles.rowMeta },
|
|
214
|
-
h('span', { style: styles.tag }, row.kind === 'dir' ? '目录' : '文件'),
|
|
215
|
-
row.exists === false ? h('span', { style: styles.tagWarn }, '目标不存在') : null,
|
|
216
|
-
h('span', { style: styles.meta }, `同意于 ${fmtTime(row.approvedAt) || '未知时间'}`),
|
|
217
|
-
row.sessionId
|
|
218
|
-
? h(
|
|
219
|
-
'span',
|
|
220
|
-
{ style: styles.meta },
|
|
221
|
-
`会话 ${shortSession(row.sessionId)}${row.current ? '(当前)' : ''}`,
|
|
222
|
-
)
|
|
223
|
-
: null,
|
|
224
|
-
row.reason ? h('span', { style: styles.meta }, row.reason) : null,
|
|
225
|
-
),
|
|
226
|
-
),
|
|
227
|
-
h(
|
|
228
|
-
'button',
|
|
229
|
-
{ style: styles.btnDanger, disabled: busy === row.id, onClick: () => void remove(row.id) },
|
|
230
|
-
busy === row.id ? '移除中…' : '移除',
|
|
231
|
-
),
|
|
232
|
-
),
|
|
233
|
-
),
|
|
234
|
-
),
|
|
235
|
+
: h('div', { style: styles.table }, ...rowNodes),
|
|
235
236
|
),
|
|
236
237
|
)
|
|
237
238
|
}
|
package/index.js
CHANGED
|
@@ -1698,26 +1698,26 @@ export function apply(ctx, config) {
|
|
|
1698
1698
|
.map((entry) => ({ path: entry.path, kind: entry.kind === 'dir' ? 'dir' : 'file' }))
|
|
1699
1699
|
}
|
|
1700
1700
|
|
|
1701
|
-
/**
|
|
1701
|
+
/** Whitelist entries for the panel: only this machine's entries (v0.9.10; foreign entries stay in the file for merge/prune but are not shown). */
|
|
1702
1702
|
function approvalEntriesForPanel() {
|
|
1703
|
-
return approvalState.entries
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1703
|
+
return approvalState.entries
|
|
1704
|
+
.filter((entry) => (entry.originMachine ?? '') === THIS_MACHINE)
|
|
1705
|
+
.map((entry) => ({
|
|
1706
|
+
id: entry.id,
|
|
1707
|
+
sessionId: entry.sessionId,
|
|
1708
|
+
path: entry.path,
|
|
1709
|
+
kind: entry.kind === 'dir' ? 'dir' : 'file',
|
|
1710
|
+
reason: entry.reason ?? '',
|
|
1711
|
+
basis: entry.basis ?? '',
|
|
1712
|
+
approvedAt: entry.approvedAt ?? 0,
|
|
1713
|
+
exists: (() => {
|
|
1714
|
+
try {
|
|
1715
|
+
return existsSync(entry.path)
|
|
1716
|
+
} catch {
|
|
1717
|
+
return false
|
|
1718
|
+
}
|
|
1719
|
+
})(),
|
|
1720
|
+
}))
|
|
1721
1721
|
}
|
|
1722
1722
|
|
|
1723
1723
|
/** Add a tombstone so a removal stays removed after the next cross-machine merge. */
|
|
@@ -2334,7 +2334,7 @@ export function apply(ctx, config) {
|
|
|
2334
2334
|
'',
|
|
2335
2335
|
'### Whitelist panel',
|
|
2336
2336
|
'',
|
|
2337
|
-
`Every approval is stored in the **cloud-synced** file \`<DSH_HOME>/data/tmpdir-guard/approvals.json\` (outside cloud-sync's \`data/session-tmpdir-*\` exclusions)
|
|
2337
|
+
`Every approval is stored in the **cloud-synced** file \`<DSH_HOME>/data/tmpdir-guard/approvals.json\` (outside cloud-sync's \`data/session-tmpdir-*\` exclusions). Entries carry their origin machine and are merged by id (with tombstones for removals), so an approval made on one machine reaches the others after the next sync; the panel lists only this machine's entries (foreign ones stay in the file for merging/pruning). Each machine only auto-prunes entries it created, and entries whose target no longer exists are pruned when the panel refreshes (foreign-machine entries are kept unless never seen anywhere for 7 days).`,
|
|
2338
2338
|
].join('\n'),
|
|
2339
2339
|
}),
|
|
2340
2340
|
)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leiyi-works/dsh-session-tmpdir",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Per-session task temp folder with a long-term write guard. v0.9 (方案3): creating a new file outside _tmp requires the user's approval (per file by default, per directory with mode=dir), overwriting an existing file is allowed without asking, every write channel is guarded (write/edit, shell including ffmpeg/pandoc/Export-*/IO APIs, publish copies, code runtimes, unknown tools), and the persisted whitelist is shown in a left-sidebar panel「临时目录」 where entries can be removed. Every session also gets _tmp/<session title>/ in its working directory, cleaned 7 days after the session is deleted; the same tick reclaims the attachment store.",
|
|
6
6
|
"exports": {
|