dsh-engramory 1.3.1 → 1.5.0
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.en.md +78 -15
- package/README.md +24 -6
- package/client.js +507 -23
- package/index.js +4961 -3495
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -29,13 +29,31 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
/** Relative to the page, as dsh's own pages fetch, so a mounted deployment keeps its prefix. */
|
|
30
30
|
const SETTINGS_API = 'api/engramory/settings'
|
|
31
31
|
const MEMORY_API = 'api/engramory/memory'
|
|
32
|
+
const STORE_API = 'api/engramory/store'
|
|
33
|
+
const PICK_API = 'api/engramory/store/pick'
|
|
34
|
+
/** How long the page waits on dsh's folder chooser: the route closes it after ten minutes. */
|
|
35
|
+
const PICK_WAIT_MS = 11 * 60 * 1000
|
|
36
|
+
/** How often the page asks after a move it started, and for how long in all. */
|
|
37
|
+
const MOVE_POLL_MS = 500
|
|
38
|
+
const MOVE_WATCH_MS = 120000
|
|
39
|
+
/** How often the page looks again at a move it did not start, while one is under way. */
|
|
40
|
+
const MOVE_FOLLOW_MS = 2000
|
|
32
41
|
/** This plugin's version, for the feedback footer; a test keeps it equal to package.json's. */
|
|
33
|
-
const VERSION = '1.
|
|
42
|
+
const VERSION = '1.5.0'
|
|
34
43
|
/** Where feedback goes: a new issue on the repository, or the project's mailbox. Opening
|
|
35
44
|
* the link is the browser's (the desktop app hands it to the system's); the footer submits
|
|
36
45
|
* nothing by itself. */
|
|
37
46
|
const ISSUES = 'https://github.com/tinqiao-oss/engramory/issues/new'
|
|
38
47
|
const EMAIL = 'engramory@agent.qq.com'
|
|
48
|
+
/** Where "Check for updates" asks for the latest version, in turn: npm's own registry, then
|
|
49
|
+
* npmmirror, its mirror in China, for when npm cannot be reached. Asked on that click only. */
|
|
50
|
+
const REGISTRIES = [['npm', 'https://registry.npmjs.org'], ['npmmirror', 'https://registry.npmmirror.com']]
|
|
51
|
+
/** Where to look when neither answers, and what a newer version changed. */
|
|
52
|
+
const NPM_PAGE = 'https://www.npmjs.com/package/dsh-engramory?activeTab=versions'
|
|
53
|
+
const RELEASE = 'https://github.com/tinqiao-oss/engramory/releases/tag/v'
|
|
54
|
+
/** A version as SemVer writes one: three numbers without leading zeros, then maybe a prerelease
|
|
55
|
+
* tag and build metadata, each in dot-separated identifiers (a numeric one without leading zeros). */
|
|
56
|
+
const SEMVER = /^(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})\.(0|[1-9]\d{0,8})(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/
|
|
39
57
|
/** The how-to's lines, in order. */
|
|
40
58
|
const HOW_TO = ['howToSay', 'howToRecall', 'howToEdit', 'howToMove', 'howToSocial']
|
|
41
59
|
/** A note past this is almost always a timeline under one slug (SKILL.md: "A note has a size
|
|
@@ -76,6 +94,59 @@ window.__ModuleLoader__.load({
|
|
|
76
94
|
overridden: '更高一层的配置覆盖了这些值,这里保存不了。',
|
|
77
95
|
invalid: '有一项填得不对:',
|
|
78
96
|
failed: '保存失败:',
|
|
97
|
+
place: '记忆库位置',
|
|
98
|
+
placeNow: '现在在',
|
|
99
|
+
placeIsDefault: '(默认位置)',
|
|
100
|
+
placeLoadFailed: '读不到记忆库在哪。',
|
|
101
|
+
placeLoading: '正在读取记忆库位置…',
|
|
102
|
+
placeChange: '更换存储地址',
|
|
103
|
+
globalAbsent: '全局记忆还没有建,AI 第一次往全局库存记忆时会自动建好。',
|
|
104
|
+
placeHide: '收起',
|
|
105
|
+
placeChoose: '选文件夹…',
|
|
106
|
+
placeChoosing: '在弹出的窗口里选…',
|
|
107
|
+
placeChosenInside: '选的文件夹里已经有东西,会在里面新建一个 {name} 文件夹来放记忆。',
|
|
108
|
+
placeChooseFailed: '打不开选文件夹的窗口:{reason}',
|
|
109
|
+
placeInput: '新位置',
|
|
110
|
+
placePlaceholder: '新位置:一个空文件夹或还不存在的文件夹,例如 D:\\同步盘\\AI记忆',
|
|
111
|
+
placeMove: '搬过去',
|
|
112
|
+
placeBack: '搬回默认位置',
|
|
113
|
+
placeHint: '整个记忆库连同归档一起搬过去,搬完旧位置自动清理;这台电脑上的桌面版和命令行都用这个位置。搬的那几秒 AI 存不了记忆,会过一会儿再存。放进网盘的话别让两台电脑同时写;放进 git 仓库会被一起提交;映射的网络盘可能让 dsh 卡顿。',
|
|
114
|
+
placeMoving: '正在搬…',
|
|
115
|
+
placeMoved: '搬好了,旧位置已经清理。',
|
|
116
|
+
placeMovedConflicts: '搬好了。有 {count} 个文件在搬的时候两边都被改过:旧位置那份放在新位置、名字里带 .old-,索引里也加了一行,记得合并。',
|
|
117
|
+
placeSame: '记忆库已经在这里了。',
|
|
118
|
+
placeStillMoving: '还在搬,过一会儿刷新这一页看看。',
|
|
119
|
+
placeEnded: '这次搬家已经结束,记忆库现在在上面写的位置。',
|
|
120
|
+
placeMoveFailed: '没搬成:{reason}',
|
|
121
|
+
placeResuming: '有一次搬家还没做完,dsh 会自动接着做完。',
|
|
122
|
+
placeResumingWhy: '上次停在:{reason}会自动再试。',
|
|
123
|
+
placePinned: '配置里固定了索引(indexPath),记忆库就在它所在的文件夹,这里不能搬。',
|
|
124
|
+
placeRemote: 'dsh 主目录在网络位置上,这里不能搬。',
|
|
125
|
+
placeProblem: '记录记忆库位置的文件读不懂,暂时找不到记忆库:{file}。把它改对后刷新这一页。',
|
|
126
|
+
placeCustomSkill: '你用的是自己写的记忆规则(skill),里面写的位置搬完要自己改。',
|
|
127
|
+
placeLegacy: 'dsh 主目录的 AGENTS.md 里还有不装插件时写进去的记忆规则,写的是默认位置;装了插件就用不着它了,可以用 engramory_init.py 卸掉。',
|
|
128
|
+
whyRelative: '要写完整路径(Windows 上带盘符)。',
|
|
129
|
+
whyNetwork: '不能放在网络路径上。',
|
|
130
|
+
whyRoot: '不能是整个盘。',
|
|
131
|
+
whyDeep: '路径太深了。',
|
|
132
|
+
whyInvalid: '路径里有 Windows 不认的名字或字符。',
|
|
133
|
+
whyReserved: '这个位置不能用:用户主目录、dsh 主目录和它们的上级都不行,名字也不能跟记忆库撞。',
|
|
134
|
+
whyNested: '新位置不能在记忆库里面,也不能把记忆库包在里面。',
|
|
135
|
+
whyNotEmpty: '那个文件夹里已经有东西了,要选空文件夹或还不存在的文件夹。',
|
|
136
|
+
whyNotDir: '那里是个文件,不是文件夹。',
|
|
137
|
+
whyLink: '新位置或记忆库里有目录链接,插件不替你搬,请手动处理。',
|
|
138
|
+
whyUnreadable: '读不了那个位置。',
|
|
139
|
+
whyUnavailable: '现在的记忆库找不到了,比如它所在的盘没接上。',
|
|
140
|
+
whyBusy: '正在搬家,等它做完。',
|
|
141
|
+
whyProblem: '记忆库位置的记录有问题,先修好它。',
|
|
142
|
+
whyTooMany: '文件太多了。',
|
|
143
|
+
whyTooBig: '太大了(超过 256 MB)。',
|
|
144
|
+
whyTooDeep: '文件夹层数太多了。',
|
|
145
|
+
whySpecial: '记忆库里有不是普通文件的东西。',
|
|
146
|
+
whyChanged: '搬的时候记忆库被别处换了位置。',
|
|
147
|
+
whyInterrupted: '上次搬到一半被打断了,已经撤销,记忆库还在原处。',
|
|
148
|
+
whyFailed: '文件操作出错了。',
|
|
149
|
+
locationUnknown: '记录记忆库位置的文件(dsh 主目录下的 .engramory-memory.json)读不懂,全局记忆这次没列出来。把它改对后点刷新。',
|
|
79
150
|
panel: '记忆',
|
|
80
151
|
panelTitle: 'Engramory 记忆',
|
|
81
152
|
refresh: '刷新',
|
|
@@ -95,7 +166,6 @@ window.__ModuleLoader__.load({
|
|
|
95
166
|
sizeKB: '{n} KB',
|
|
96
167
|
overHint: '超出上限了,AI 只读得到前面一部分,该压缩了。',
|
|
97
168
|
noIndex: '还没有索引',
|
|
98
|
-
openIndex: '打开索引',
|
|
99
169
|
openFolder: '打开文件夹',
|
|
100
170
|
opened: '已打开 {name}。',
|
|
101
171
|
revealed: '已在文件夹里显示 {name}。',
|
|
@@ -127,7 +197,7 @@ window.__ModuleLoader__.load({
|
|
|
127
197
|
howToSay: '想让 AI 记住什么,直接跟它说,比如「记住:我习惯用 pnpm」「把这个决定记下来」。平时它也会尽量自己挑值得长期记住的记下来,比如你纠正过它的做法。',
|
|
128
198
|
howToRecall: '默认每次对话都会带上记忆的目录(索引),AI 用到细节时再打开那条笔记,不用你提醒。',
|
|
129
199
|
howToEdit: '这里列出读得到的记忆,打开笔记就能直接改;想让 AI 忘掉什么,跟它说「忘掉……」就行。',
|
|
130
|
-
howToMove: '记忆是存在运行 dsh 那台电脑上的普通 markdown
|
|
200
|
+
howToMove: '记忆是存在运行 dsh 那台电脑上的普通 markdown 文件,位置写在每个库的标题下面。想放到别处(比如网盘里),点「全局记忆」右上角的「更换存储地址」,插件会整个搬过去。换电脑时,把那个文件夹拷到新电脑 dsh 主目录下的 .engramory-memory,想放别处再在新电脑上搬一次。',
|
|
131
201
|
howToSocial: '接了 QQ、微信等、别人也能跟你的 AI 聊的话,在上面打开「大肥鱼模式」,再把「记忆权限」改成「社交」:只有认得出是你本人的对话才拿得到记忆。这不是安全隔离,详见插件说明。',
|
|
132
202
|
feedbackLead: '遇到问题或有建议:',
|
|
133
203
|
feedbackIssue: '到 GitHub 提 issue',
|
|
@@ -135,7 +205,24 @@ window.__ModuleLoader__.load({
|
|
|
135
205
|
copy: '复制',
|
|
136
206
|
copied: '已复制',
|
|
137
207
|
copyFailed: '复制不了,请手动选中上面的地址。',
|
|
138
|
-
feedbackNote: '邮件会由 AI 助手协助整理,issue
|
|
208
|
+
feedbackNote: '邮件会由 AI 助手协助整理,issue 是公开的,两处都别把记忆内容原样贴上去。',
|
|
209
|
+
versionLine: '插件版本 {version}',
|
|
210
|
+
checkUpdate: '检查更新',
|
|
211
|
+
checking: '正在检查…',
|
|
212
|
+
updateNewer: '有新版本 {latest}(你装的是 {current})',
|
|
213
|
+
updateNotes: '看这一版改了什么',
|
|
214
|
+
updateHow: '升级时要写上版本号(只写名字的话,pnpm 默认不装发布不满 24 小时的版本):',
|
|
215
|
+
updateDesktop: '桌面版:在「插件」页卸载「Engramory 记忆」,再搜索安装',
|
|
216
|
+
updateCli: '命令行:',
|
|
217
|
+
updateProfile: '<名字>',
|
|
218
|
+
updateAfter: '装完重启 dsh(桌面版从托盘退出再打开)。记忆和设置都会保留。',
|
|
219
|
+
updateCurrent: '已是最新版本:{source} 上最新的就是 {latest}。',
|
|
220
|
+
updateAhead: '你装的 {current} 比 {source} 上最新的 {latest} 还新。',
|
|
221
|
+
updateMirror: 'npm 没有给出版本号,这是镜像 npmmirror 的结果,它有时比 npm 晚几分钟同步。',
|
|
222
|
+
updateFailed: '查不到最新版本:npm 和 npmmirror 都没有给出版本号。可以到网页上看:',
|
|
223
|
+
updateNpm: 'npm 上的版本列表',
|
|
224
|
+
copySpecFailed: '复制不了,请手动选中上面的版本号。',
|
|
225
|
+
updateNote: '检查更新会向 npm(连不上再试 npmmirror)查最新版本号,请求里不带任何记忆内容;不点就不联网。',
|
|
139
226
|
issueBody: '(写下遇到的问题或建议)\n\n---\ndsh-engramory {version}\n打开这个页面的电脑:{os}\ndsh 版本:',
|
|
140
227
|
statNote: '条记忆',
|
|
141
228
|
statNotes: '条记忆',
|
|
@@ -201,6 +288,59 @@ window.__ModuleLoader__.load({
|
|
|
201
288
|
overridden: 'A higher configuration layer overrides these values, so they cannot be saved here.',
|
|
202
289
|
invalid: 'One field is not acceptable: ',
|
|
203
290
|
failed: 'Saving failed: ',
|
|
291
|
+
place: 'Where the memory is',
|
|
292
|
+
placeNow: 'Now in',
|
|
293
|
+
placeIsDefault: ' (the default place)',
|
|
294
|
+
placeLoadFailed: 'Could not read where the memory is.',
|
|
295
|
+
placeLoading: 'Reading where the memory is…',
|
|
296
|
+
placeChange: 'Change location',
|
|
297
|
+
globalAbsent: 'No global memory yet: the global store is made the first time the AI saves to it.',
|
|
298
|
+
placeHide: 'Close',
|
|
299
|
+
placeChoose: 'Choose folder…',
|
|
300
|
+
placeChoosing: 'Choose in the window that opened…',
|
|
301
|
+
placeChosenInside: 'That folder holds something already: a {name} folder is made inside it for the memory.',
|
|
302
|
+
placeChooseFailed: 'The folder chooser did not open: {reason}',
|
|
303
|
+
placeInput: 'New place',
|
|
304
|
+
placePlaceholder: 'New place: an empty folder, or one not there yet, such as D:\\Sync\\AI memory',
|
|
305
|
+
placeMove: 'Move it there',
|
|
306
|
+
placeBack: 'Move it back to the default place',
|
|
307
|
+
placeHint: 'The whole store moves, archive and all, and the old place is cleared once it has; the desktop app and the command line on this computer both use the new place. For the few seconds it takes, the AI cannot save memory and tries again a little later. In a synced folder, do not let two computers write at once; in a git repository it gets committed with the rest; a mapped network drive may make dsh stall.',
|
|
308
|
+
placeMoving: 'Moving…',
|
|
309
|
+
placeMoved: 'Moved, and the old place is cleared.',
|
|
310
|
+
placeMovedConflicts: 'Moved. {count} file(s) changed in both places while it moved: the old place\'s copy is beside it in the new place, with .old- in its name and a line in the index. Merge them.',
|
|
311
|
+
placeSame: 'The memory is there already.',
|
|
312
|
+
placeStillMoving: 'Still moving. Refresh this page in a little while.',
|
|
313
|
+
placeEnded: 'The move is over: the memory is where it says above.',
|
|
314
|
+
placeMoveFailed: 'Not moved: {reason}',
|
|
315
|
+
placeResuming: 'A move is not finished yet; dsh finishes it on its own.',
|
|
316
|
+
placeResumingWhy: 'It last stopped at: {reason} It will try again.',
|
|
317
|
+
placePinned: 'An index is pinned (indexPath): the memory is in its folder, and is not moved here.',
|
|
318
|
+
placeRemote: 'dsh\'s home folder is on a network place: the memory is not moved here.',
|
|
319
|
+
placeProblem: 'The file that says where the memory is cannot be read as written, so the memory cannot be found for now: {file}. Correct it, then refresh this page.',
|
|
320
|
+
placeCustomSkill: 'You use memory rules of your own (skill): change the place they name once it has moved.',
|
|
321
|
+
placeLegacy: 'AGENTS.md in dsh\'s home folder still holds memory rules written there for a setup without the plugin, naming the default place. With the plugin they are not needed: engramory_init.py can take them out.',
|
|
322
|
+
whyRelative: 'Give the whole path (on Windows, with its drive).',
|
|
323
|
+
whyNetwork: 'It cannot be on a network path.',
|
|
324
|
+
whyRoot: 'It cannot be a whole drive.',
|
|
325
|
+
whyDeep: 'The path is too deep.',
|
|
326
|
+
whyInvalid: 'The path holds a name or a character Windows does not take.',
|
|
327
|
+
whyReserved: 'That place cannot be used: not your home folder, not dsh\'s, nor any folder holding them, and not a name the memory store uses.',
|
|
328
|
+
whyNested: 'The new place cannot be inside the store, nor hold it.',
|
|
329
|
+
whyNotEmpty: 'There is something in that folder already: choose an empty folder, or one not there yet.',
|
|
330
|
+
whyNotDir: 'That is a file, not a folder.',
|
|
331
|
+
whyLink: 'The new place or the store holds a folder link: the plugin does not move it for you. Sort it out by hand.',
|
|
332
|
+
whyUnreadable: 'That place cannot be read.',
|
|
333
|
+
whyUnavailable: 'The store cannot be found where it is now: its drive may not be connected.',
|
|
334
|
+
whyBusy: 'A move is under way: wait until it is done.',
|
|
335
|
+
whyProblem: 'The record of where the memory is has a problem: fix it first.',
|
|
336
|
+
whyTooMany: 'There are too many files.',
|
|
337
|
+
whyTooBig: 'It is too big (over 256 MB).',
|
|
338
|
+
whyTooDeep: 'Its folders go too deep.',
|
|
339
|
+
whySpecial: 'The store holds something that is not a plain file.',
|
|
340
|
+
whyChanged: 'The store was moved elsewhere while this move ran.',
|
|
341
|
+
whyInterrupted: 'The last move was cut short and has been undone: the store is where it was.',
|
|
342
|
+
whyFailed: 'A file operation failed.',
|
|
343
|
+
locationUnknown: 'The file that says where the memory is (.engramory-memory.json in dsh\'s home folder) cannot be read as written, so the global memory is not listed this time. Correct it, then refresh.',
|
|
204
344
|
panel: 'Memory',
|
|
205
345
|
panelTitle: 'Engramory memory',
|
|
206
346
|
refresh: 'Refresh',
|
|
@@ -220,7 +360,6 @@ window.__ModuleLoader__.load({
|
|
|
220
360
|
sizeKB: '{n} KB',
|
|
221
361
|
overHint: 'Over the cap: the AI reads only the first part. Time to compact it.',
|
|
222
362
|
noIndex: 'No index yet',
|
|
223
|
-
openIndex: 'Open the index',
|
|
224
363
|
openFolder: 'Open the folder',
|
|
225
364
|
opened: 'Opened {name}.',
|
|
226
365
|
revealed: 'Showed {name} in its folder.',
|
|
@@ -252,7 +391,7 @@ window.__ModuleLoader__.load({
|
|
|
252
391
|
howToSay: 'To have the AI remember something, just tell it: "remember that I use pnpm", "note this decision down". It also tries to keep what is worth keeping on its own, such as a way of working you corrected.',
|
|
253
392
|
howToRecall: 'By default every conversation carries the memory\'s table of contents (the index), and the AI opens a note when it needs the details; you do not have to remind it.',
|
|
254
393
|
howToEdit: 'The memory this page can read is listed here; open a note to edit it. To have the AI forget something, tell it "forget …".',
|
|
255
|
-
howToMove: 'The memory is plain markdown files on the computer dsh runs on, in the folder shown under each store\'s title. On a new computer, copy that folder to
|
|
394
|
+
howToMove: 'The memory is plain markdown files on the computer dsh runs on, in the folder shown under each store\'s title. To keep it elsewhere (a synced folder, say), click Change location at the top right of the global memory, and the plugin moves it all there. On a new computer, copy that folder to .engramory-memory in dsh\'s home folder there, then move it again if you want it elsewhere.',
|
|
256
395
|
howToSocial: 'If others can talk to your AI too (through QQ, WeChat and the like), turn on Companion mode above and set Memory access to Social: only conversations it can tell are yours get the memory. This is not a security boundary; see the plugin\'s README.',
|
|
257
396
|
feedbackLead: 'Found a problem or have an idea? ',
|
|
258
397
|
feedbackIssue: 'Open an issue on GitHub',
|
|
@@ -260,7 +399,24 @@ window.__ModuleLoader__.load({
|
|
|
260
399
|
copy: 'Copy',
|
|
261
400
|
copied: 'Copied',
|
|
262
401
|
copyFailed: 'Could not copy; select the address above by hand.',
|
|
263
|
-
feedbackNote: 'Emails are sorted with the help of an AI assistant, and issues are public: do not paste your memory notes into either.
|
|
402
|
+
feedbackNote: 'Emails are sorted with the help of an AI assistant, and issues are public: do not paste your memory notes into either.',
|
|
403
|
+
versionLine: 'Plugin version {version}',
|
|
404
|
+
checkUpdate: 'Check for updates',
|
|
405
|
+
checking: 'Checking…',
|
|
406
|
+
updateNewer: 'Version {latest} is out (you have {current})',
|
|
407
|
+
updateNotes: 'What changed',
|
|
408
|
+
updateHow: 'Name the version when you upgrade: by name alone, pnpm by default does not install a version published less than 24 hours ago.',
|
|
409
|
+
updateDesktop: 'Desktop app: on the Plugins page, uninstall Engramory memory, then search for and install',
|
|
410
|
+
updateCli: 'Command line: ',
|
|
411
|
+
updateProfile: '<name>',
|
|
412
|
+
updateAfter: 'Then restart dsh (in the desktop app, quit from the tray and open it again). Your memory and settings stay.',
|
|
413
|
+
updateCurrent: 'You have the latest version: the latest on {source} is {latest}.',
|
|
414
|
+
updateAhead: 'The {current} you have is newer than the latest on {source}, {latest}.',
|
|
415
|
+
updateMirror: 'npm gave no version, so this is from its mirror npmmirror, which can be a few minutes behind npm.',
|
|
416
|
+
updateFailed: 'Could not find the latest version: neither npm nor npmmirror gave one. The versions are listed on npm\'s site: ',
|
|
417
|
+
updateNpm: 'dsh-engramory on npm',
|
|
418
|
+
copySpecFailed: 'Could not copy; select the version above by hand.',
|
|
419
|
+
updateNote: 'Checking asks npm (or npmmirror, when npm cannot be reached) for the latest version number; nothing from your memory goes with it. Nothing is asked until you click.',
|
|
264
420
|
issueBody: '(What happened, or your idea)\n\n---\ndsh-engramory {version}\nComputer this page was opened on: {os}\ndsh version: ',
|
|
265
421
|
statNote: 'note',
|
|
266
422
|
statNotes: 'notes',
|
|
@@ -324,6 +480,12 @@ window.__ModuleLoader__.load({
|
|
|
324
480
|
.eng-cap{display:flex;gap:12px;align-items:center;flex-wrap:wrap;}
|
|
325
481
|
.eng-cap label{display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-secondary);font-size:12px;}
|
|
326
482
|
.eng-cap input{width:110px;}
|
|
483
|
+
.eng-empty{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
|
|
484
|
+
.eng-place{display:flex;flex-direction:column;gap:8px;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:14px;}
|
|
485
|
+
.eng-place-now{margin:0;font-size:12px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;}
|
|
486
|
+
.eng-place-now code{font-family:var(--ds-font-family-code,ui-monospace,monospace);color:var(--dsw-alias-label-primary);}
|
|
487
|
+
.eng-place-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
|
|
488
|
+
.eng-place-row .eng-input{flex:1 1 260px;}
|
|
327
489
|
.eng-btn{display:inline-flex;align-items:center;gap:6px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);border-radius:8px;padding:5px 14px;font:inherit;font-size:12px;line-height:18px;cursor:pointer;white-space:nowrap;}
|
|
328
490
|
.eng-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);}
|
|
329
491
|
.eng-btn:disabled{opacity:.5;cursor:default;}
|
|
@@ -341,6 +503,7 @@ window.__ModuleLoader__.load({
|
|
|
341
503
|
.eng-brand{display:flex;align-items:center;gap:14px;}
|
|
342
504
|
.eng-logo{border-radius:12px;box-shadow:0 0 0 1px rgba(110,231,200,.35);}
|
|
343
505
|
.eng-hero-title{margin:0;font-size:21px;font-weight:600;line-height:28px;letter-spacing:.01em;}
|
|
506
|
+
.eng-hero-version{margin-left:10px;font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:13px;font-weight:400;letter-spacing:0;color:rgba(232,243,240,.6);}
|
|
344
507
|
.eng-stats{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 0;}
|
|
345
508
|
.eng-stat{display:inline-flex;align-items:baseline;gap:6px;}
|
|
346
509
|
.eng-stat+.eng-stat{margin-left:18px;padding-left:18px;border-left:1px solid rgba(232,243,240,.18);}
|
|
@@ -439,6 +602,14 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
439
602
|
.eng-link:hover{opacity:.8;}
|
|
440
603
|
.eng-email{margin:0 8px 0 2px;font-family:var(--ds-font-family-code,ui-monospace,monospace);user-select:all;color:var(--dsw-alias-label-primary);}
|
|
441
604
|
.eng-feedback-note{color:var(--dsw-alias-label-tertiary);}
|
|
605
|
+
.eng-version,.eng-update{display:flex;flex-direction:column;gap:2px;}
|
|
606
|
+
.eng-update{margin:2px 0 6px;}
|
|
607
|
+
.eng-version>p>.eng-btn{margin-left:8px;}
|
|
608
|
+
.eng-update-new{margin-right:8px;font-weight:500;color:var(--dsw-alias-label-primary);}
|
|
609
|
+
.eng-update ul{margin:0;padding-left:18px;}
|
|
610
|
+
.eng-update li{margin:0;}
|
|
611
|
+
.eng-update li .eng-btn{margin-left:6px;}
|
|
612
|
+
.eng-code{margin:0 2px 0 6px;font-family:var(--ds-font-family-code,ui-monospace,monospace);user-select:all;color:var(--dsw-alias-label-primary);}
|
|
442
613
|
.eng-name:focus-visible,.eng-row:focus-visible,.eng-btn:focus-visible,.eng-tab:focus-visible,.eng-link:focus-visible,.eng-howto>summary:focus-visible,.eng-archive>summary:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-brand-primary));outline-offset:1px;}
|
|
443
614
|
`
|
|
444
615
|
|
|
@@ -458,9 +629,11 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
458
629
|
}
|
|
459
630
|
|
|
460
631
|
/** fetch with a deadline: a request the host never answers must not hold the page busy. */
|
|
461
|
-
async function request(url, init = {}) {
|
|
632
|
+
async function request(url, { timeout = 15000, signal, ...init } = {}) {
|
|
462
633
|
const deadline = new AbortController()
|
|
463
|
-
const timer = setTimeout(() => deadline.abort(),
|
|
634
|
+
const timer = setTimeout(() => deadline.abort(), timeout)
|
|
635
|
+
// the caller's own end too (a section closed while dsh's chooser is open)
|
|
636
|
+
signal?.addEventListener('abort', () => deadline.abort(), { once: true })
|
|
464
637
|
try {
|
|
465
638
|
const response = await fetch(url, { cache: 'no-store', ...init, signal: deadline.signal,
|
|
466
639
|
headers: { accept: 'application/json', ...(init.headers ?? {}) } })
|
|
@@ -668,6 +841,207 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
668
841
|
return h(SettingsForm, props)
|
|
669
842
|
}
|
|
670
843
|
|
|
844
|
+
/** "No memory yet", and where the store is to be made: it can be moved before there is any. */
|
|
845
|
+
function NoMemory({ t, onMoved, note = 'empty' }) {
|
|
846
|
+
const [placing, setPlacing] = useState(false)
|
|
847
|
+
return h('div', { className: 'eng-section' },
|
|
848
|
+
h('div', { className: 'eng-empty' },
|
|
849
|
+
h('p', { className: 'eng-note' }, t(note === 'global' ? 'globalAbsent' : 'empty')),
|
|
850
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-ghost', 'aria-expanded': placing,
|
|
851
|
+
onClick: () => setPlacing(!placing) }, icon('move', 14), t(placing ? 'placeHide' : 'placeChange'))),
|
|
852
|
+
placing ? h(PlaceSection, { t, onMoved, showNow: true }) : null)
|
|
853
|
+
}
|
|
854
|
+
|
|
855
|
+
/** Why the store route turned a move down, or a move stopped (its codes, index.js). */
|
|
856
|
+
function whyNot(t, code, detail) {
|
|
857
|
+
const why = {
|
|
858
|
+
relative: () => t('whyRelative'), network: () => t('whyNetwork'), root: () => t('whyRoot'),
|
|
859
|
+
deep: () => t('whyDeep'), invalid: () => t('whyInvalid'), reserved: () => t('whyReserved'),
|
|
860
|
+
nested: () => t('whyNested'), notEmpty: () => t('whyNotEmpty'), notDir: () => t('whyNotDir'),
|
|
861
|
+
link: () => t('whyLink'), unreadable: () => t('whyUnreadable'), unavailable: () => t('whyUnavailable'),
|
|
862
|
+
busy: () => t('whyBusy'), problem: () => t('whyProblem'), pinned: () => t('placePinned'),
|
|
863
|
+
remote: () => t('placeRemote'), tooMany: () => t('whyTooMany'), tooBig: () => t('whyTooBig'),
|
|
864
|
+
tooDeep: () => t('whyTooDeep'), special: () => t('whySpecial'), changed: () => t('whyChanged'),
|
|
865
|
+
interrupted: () => t('whyInterrupted'),
|
|
866
|
+
}[code]
|
|
867
|
+
return why === undefined ? `${t('whyFailed')}${typeof detail === 'string' ? ` (${detail})` : ''}` : why()
|
|
868
|
+
}
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Moving the global store: on the memory page, opened from the global store's own actions
|
|
872
|
+
* (or beside "no memory yet"). The folder comes from dsh's own chooser where it opens on this
|
|
873
|
+
* desktop, or is typed; the page starts a move and asks after it until it is done (the plugin
|
|
874
|
+
* carries it on whether or not the page stays), then has the listing read again (`onMoved`).
|
|
875
|
+
* `showNow`: say where the store is, where the page does not show it already.
|
|
876
|
+
*/
|
|
877
|
+
function PlaceSection({ t, onMoved, showNow = false }) {
|
|
878
|
+
const [state, setState] = useState({ phase: 'loading' })
|
|
879
|
+
const [text, setText] = useState('')
|
|
880
|
+
const [busy, setBusy] = useState(false)
|
|
881
|
+
const [choosing, setChoosing] = useState(false)
|
|
882
|
+
const [banner, setBanner] = useState(undefined)
|
|
883
|
+
const alive = useRef(true)
|
|
884
|
+
const moving = useRef(false)
|
|
885
|
+
const chooserRequest = useRef(undefined)
|
|
886
|
+
// a move on record the last time it was read: over now, the listing is read again
|
|
887
|
+
const wasMoving = useRef(false)
|
|
888
|
+
useEffect(() => () => {
|
|
889
|
+
alive.current = false
|
|
890
|
+
chooserRequest.current?.abort() // closed: the chooser it asked for closes with it
|
|
891
|
+
}, [])
|
|
892
|
+
const load = useCallback(async () => {
|
|
893
|
+
try {
|
|
894
|
+
const response = await request(STORE_API)
|
|
895
|
+
if (!response.ok || response.body === undefined) throw new Error(`HTTP ${response.status}`)
|
|
896
|
+
if (!alive.current) return
|
|
897
|
+
setState({ phase: 'ready', data: response.body })
|
|
898
|
+
const under = response.body.moving !== undefined
|
|
899
|
+
if (wasMoving.current && !under) onMoved?.()
|
|
900
|
+
wasMoving.current = under
|
|
901
|
+
} catch {
|
|
902
|
+
if (alive.current) setState((s) => (s.phase === 'ready' ? s : { phase: 'error' }))
|
|
903
|
+
}
|
|
904
|
+
}, [onMoved])
|
|
905
|
+
useEffect(() => { load() }, [load])
|
|
906
|
+
// a move under way when the page opened (another window's, or one carried on after a
|
|
907
|
+
// restart): asked after until it is over, as one this page starts
|
|
908
|
+
const underWay = state.phase === 'ready' && state.data.moving !== undefined && !busy
|
|
909
|
+
// each look, answered or not, schedules the next while the move is still on record
|
|
910
|
+
const [looks, setLooks] = useState(0)
|
|
911
|
+
useEffect(() => {
|
|
912
|
+
if (!underWay) return undefined
|
|
913
|
+
const timer = setTimeout(() => {
|
|
914
|
+
if (alive.current) load().finally(() => { if (alive.current) setLooks((n) => n + 1) })
|
|
915
|
+
}, MOVE_FOLLOW_MS)
|
|
916
|
+
return () => clearTimeout(timer)
|
|
917
|
+
}, [underWay, looks])
|
|
918
|
+
|
|
919
|
+
const choose = async () => {
|
|
920
|
+
if (moving.current || choosing) return
|
|
921
|
+
setChoosing(true)
|
|
922
|
+
setBanner(undefined)
|
|
923
|
+
try {
|
|
924
|
+
let response
|
|
925
|
+
const ending = new AbortController()
|
|
926
|
+
chooserRequest.current = ending
|
|
927
|
+
try {
|
|
928
|
+
response = await request(PICK_API, { method: 'POST', headers: { 'content-type': 'application/json' },
|
|
929
|
+
body: '{}', timeout: PICK_WAIT_MS, signal: ending.signal })
|
|
930
|
+
} catch (error) {
|
|
931
|
+
response = { ok: false, body: { message: String(error?.message ?? error) } }
|
|
932
|
+
} finally {
|
|
933
|
+
if (chooserRequest.current === ending) chooserRequest.current = undefined
|
|
934
|
+
}
|
|
935
|
+
if (!alive.current) return
|
|
936
|
+
const body = response.body ?? {}
|
|
937
|
+
if (response.ok && body.cancelled === true) return
|
|
938
|
+
if (response.ok && typeof body.to === 'string') {
|
|
939
|
+
setText(body.to)
|
|
940
|
+
if (typeof body.inside === 'string') setBanner({ tone: 'ok', text: t('placeChosenInside', { name: body.inside }) })
|
|
941
|
+
return
|
|
942
|
+
}
|
|
943
|
+
setBanner({ tone: 'error', text: t('placeChooseFailed', { reason: body.message ?? body.error ?? `HTTP ${response.status}` }) })
|
|
944
|
+
} finally {
|
|
945
|
+
if (alive.current) setChoosing(false)
|
|
946
|
+
}
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const move = async (to) => {
|
|
950
|
+
if (moving.current) return
|
|
951
|
+
moving.current = true
|
|
952
|
+
setBusy(true)
|
|
953
|
+
setBanner(undefined)
|
|
954
|
+
try {
|
|
955
|
+
let response
|
|
956
|
+
try {
|
|
957
|
+
response = await request(STORE_API, {
|
|
958
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ to }),
|
|
959
|
+
})
|
|
960
|
+
} catch (error) {
|
|
961
|
+
response = { ok: false, body: { error: 'failed', detail: String(error?.message ?? error) } }
|
|
962
|
+
}
|
|
963
|
+
if (!alive.current) return
|
|
964
|
+
const body = response.body ?? {}
|
|
965
|
+
if (response.ok && body.same === true) {
|
|
966
|
+
await load() // another dsh may have moved it there: the page shows where it is now
|
|
967
|
+
if (alive.current) setBanner({ tone: 'ok', text: t('placeSame') })
|
|
968
|
+
onMoved?.()
|
|
969
|
+
return
|
|
970
|
+
}
|
|
971
|
+
if (response.status !== 202 || typeof body.id !== 'string') {
|
|
972
|
+
setBanner({ tone: 'error', text: t('placeMoveFailed', { reason: whyNot(t, body.reason ?? body.error, body.detail) }) })
|
|
973
|
+
await load()
|
|
974
|
+
return
|
|
975
|
+
}
|
|
976
|
+
setBanner({ tone: 'ok', text: t('placeMoving') })
|
|
977
|
+
let outcome
|
|
978
|
+
// by the clock, not by count: each ask may itself wait out its own deadline
|
|
979
|
+
const until = Date.now() + MOVE_WATCH_MS
|
|
980
|
+
while (alive.current && outcome?.done !== true && Date.now() < until) {
|
|
981
|
+
await new Promise((resolve) => setTimeout(resolve, MOVE_POLL_MS))
|
|
982
|
+
try {
|
|
983
|
+
const polled = await request(`${STORE_API}?id=${encodeURIComponent(body.id)}`)
|
|
984
|
+
if (polled.ok && polled.body !== undefined && alive.current) {
|
|
985
|
+
setState({ phase: 'ready', data: polled.body })
|
|
986
|
+
outcome = polled.body.outcome
|
|
987
|
+
}
|
|
988
|
+
} catch { /* asked again */ }
|
|
989
|
+
}
|
|
990
|
+
if (!alive.current) return
|
|
991
|
+
if (outcome?.done === true && outcome.elsewhere === true) {
|
|
992
|
+
setText('')
|
|
993
|
+
setBanner({ tone: 'ok', text: t('placeEnded') })
|
|
994
|
+
onMoved?.()
|
|
995
|
+
} else if (outcome?.done === true && outcome.ok === true) {
|
|
996
|
+
setText('')
|
|
997
|
+
setBanner({ tone: 'ok', text: outcome.conflicts > 0
|
|
998
|
+
? t('placeMovedConflicts', { count: outcome.conflicts }) : t('placeMoved') })
|
|
999
|
+
onMoved?.()
|
|
1000
|
+
} else if (outcome?.done === true) {
|
|
1001
|
+
setBanner({ tone: 'error', text: t('placeMoveFailed', { reason: whyNot(t, outcome.error, outcome.detail) }) })
|
|
1002
|
+
} else {
|
|
1003
|
+
setBanner({ tone: 'error', text: t('placeStillMoving') })
|
|
1004
|
+
}
|
|
1005
|
+
} finally {
|
|
1006
|
+
moving.current = false
|
|
1007
|
+
if (alive.current) setBusy(false)
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
|
|
1011
|
+
if (state.phase === 'loading') return h('p', { className: 'eng-note' }, t('placeLoading'))
|
|
1012
|
+
if (state.phase === 'error') {
|
|
1013
|
+
return h('section', { className: 'eng-place', 'aria-label': t('place') },
|
|
1014
|
+
h('p', { className: 'eng-note' }, t('placeLoadFailed')),
|
|
1015
|
+
h('div', { className: 'eng-actions' }, h('button', { type: 'button', className: 'eng-btn', onClick: load }, t('retry'))))
|
|
1016
|
+
}
|
|
1017
|
+
const { data } = state
|
|
1018
|
+
const atDefault = typeof data.store === 'string' && data.store === data.default
|
|
1019
|
+
const blocked = data.pinned === true ? 'placePinned' : data.remote === true ? 'placeRemote' : undefined
|
|
1020
|
+
const stopped = data.moving !== undefined && !busy
|
|
1021
|
+
return h('section', { className: 'eng-place', 'aria-label': t('place') },
|
|
1022
|
+
showNow && typeof data.store === 'string' ? h('p', { className: 'eng-place-now' },
|
|
1023
|
+
`${t('placeNow')} `, h('code', null, legible(data.store)), atDefault ? t('placeIsDefault') : '') : null,
|
|
1024
|
+
data.problem !== undefined ? h('div', { className: 'eng-banner', 'data-tone': 'error' },
|
|
1025
|
+
t('placeProblem', { file: legible(data.file ?? '') })) : null,
|
|
1026
|
+
stopped ? h('p', { className: 'eng-note' }, t('placeResuming'),
|
|
1027
|
+
data.moving.error === undefined ? '' : ` ${t('placeResumingWhy', { reason: whyNot(t, data.moving.error) })}`) : null,
|
|
1028
|
+
blocked !== undefined ? h('p', { className: 'eng-note' }, t(blocked)) : data.problem === undefined ? [
|
|
1029
|
+
h('div', { className: 'eng-place-row', key: 'row' },
|
|
1030
|
+
data.chooser === true ? h('button', { type: 'button', className: 'eng-btn', disabled: busy || choosing,
|
|
1031
|
+
onClick: choose }, icon('folder', 14), t(choosing ? 'placeChoosing' : 'placeChoose')) : null,
|
|
1032
|
+
h('input', { className: 'eng-input', value: text, disabled: busy, placeholder: t('placePlaceholder'),
|
|
1033
|
+
'aria-label': t('placeInput'), spellCheck: false, onChange: (e) => { setText(e.target.value); setBanner(undefined) } }),
|
|
1034
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-primary', disabled: busy || choosing || text.trim() === '',
|
|
1035
|
+
onClick: () => move(text.trim()) }, busy ? t('placeMoving') : t('placeMove'))),
|
|
1036
|
+
atDefault ? null : h('div', { className: 'eng-actions', key: 'back' },
|
|
1037
|
+
h('button', { type: 'button', className: 'eng-btn', disabled: busy, onClick: () => move(null) }, t('placeBack'))),
|
|
1038
|
+
h('p', { className: 'eng-hint', key: 'hint' }, t('placeHint')),
|
|
1039
|
+
data.customSkill === true ? h('p', { className: 'eng-note', key: 'skill' }, t('placeCustomSkill')) : null,
|
|
1040
|
+
data.legacyRules === true ? h('p', { className: 'eng-note', key: 'legacy' }, t('placeLegacy')) : null,
|
|
1041
|
+
] : null,
|
|
1042
|
+
banner ? h('div', { className: 'eng-banner', 'data-tone': banner.tone, role: 'status' }, banner.text) : null)
|
|
1043
|
+
}
|
|
1044
|
+
|
|
671
1045
|
/**
|
|
672
1046
|
* The two settings that matter most, atop the memory page, each saved as it is switched;
|
|
673
1047
|
* what they mean, and the index cap, stay on the package's page.
|
|
@@ -811,7 +1185,8 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
811
1185
|
search: [['circle', { cx: 11, cy: 11, r: 7 }], ['path', { d: 'm20 20-3.5-3.5' }]],
|
|
812
1186
|
copy: [['rect', { x: 9, y: 9, width: 11, height: 11, rx: 2 }], ['path', { d: 'M5 15V5a2 2 0 0 1 2-2h8' }]],
|
|
813
1187
|
folder: [['path', { d: 'M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z' }]],
|
|
814
|
-
|
|
1188
|
+
move: [['path', { d: 'M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z' }],
|
|
1189
|
+
['path', { d: 'M9 13h6m-2-2 2 2-2 2' }]],
|
|
815
1190
|
tidy: [['path', { d: 'm4 20 11-11M14 4l1 2 2 1-2 1-1 2-1-2-2-1 2-1zM19 11l.7 1.3L21 13l-1.3.7L19 15l-.7-1.3L17 13l1.3-.7z' }]],
|
|
816
1191
|
archive: [['rect', { x: 3, y: 4, width: 18, height: 5, rx: 1 }], ['path', { d: 'M5 9v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V9M10 13h4' }]],
|
|
817
1192
|
alert: [['path', { d: 'M12 4 2.5 20h19z' }], ['path', { d: 'M12 10v4M12 17h.01' }]],
|
|
@@ -821,6 +1196,7 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
821
1196
|
book: [['path', { d: 'M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z' }], ['path', { d: 'M4 19V5' }]],
|
|
822
1197
|
issue: [['path', { d: 'M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z' }]],
|
|
823
1198
|
mail: [['rect', { x: 3, y: 5, width: 18, height: 14, rx: 2 }], ['path', { d: 'm3 7 9 6 9-6' }]],
|
|
1199
|
+
package: [['path', { d: 'M12 3 4 7v10l8 4 8-4V7z' }], ['path', { d: 'm4 7 8 4 8-4M12 11v10' }]],
|
|
824
1200
|
user: [['circle', { cx: 12, cy: 8.6, r: 3.6 }], ['path', { d: 'M5 19.5c1.2-3.3 3.9-5 7-5s5.8 1.7 7 5z' }]],
|
|
825
1201
|
feedback: [['path', { d: 'M4.5 6.5a2 2 0 0 1 2-2h11a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H11l-4 3v-3h-.5a2 2 0 0 1-2-2z' }],
|
|
826
1202
|
['path', { d: 'm9 10.3 2 2 4-4' }]],
|
|
@@ -852,10 +1228,10 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
852
1228
|
minute: '2-digit' })
|
|
853
1229
|
|
|
854
1230
|
/**
|
|
855
|
-
* The banner atop the memory page, in the project's own colours on any theme: its name
|
|
856
|
-
* listing in three numbers as read at `at` with a refresh beside the
|
|
857
|
-
* settings that matter most in a panel of their own. Numbers only once there
|
|
858
|
-
* with something to count.
|
|
1231
|
+
* The banner atop the memory page, in the project's own colours on any theme: its name with
|
|
1232
|
+
* the plugin's version, the listing in three numbers as read at `at` with a refresh beside the
|
|
1233
|
+
* time, and the two settings that matter most in a panel of their own. Numbers only once there
|
|
1234
|
+
* is a listing with something to count.
|
|
859
1235
|
*/
|
|
860
1236
|
function Hero({ data, at, refresh, t }) {
|
|
861
1237
|
const counted = data !== undefined && (data.stores.length > 0 || data.unreadable > 0)
|
|
@@ -864,7 +1240,8 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
864
1240
|
const stat = (n, label) => h('div', { className: 'eng-stat', key: label }, h('b', null, String(n)), h('span', null, label))
|
|
865
1241
|
return h('header', { className: 'eng-hero' },
|
|
866
1242
|
h('div', { className: 'eng-hero-main' },
|
|
867
|
-
h('div', { className: 'eng-brand' }, h(Logo), h('h1', { className: 'eng-hero-title' }, t('panelTitle')
|
|
1243
|
+
h('div', { className: 'eng-brand' }, h(Logo), h('h1', { className: 'eng-hero-title' }, t('panelTitle'),
|
|
1244
|
+
h('span', { className: 'eng-hero-version' }, `v${VERSION}`))),
|
|
868
1245
|
counted ? h('div', { className: 'eng-stats' },
|
|
869
1246
|
stat(notes, t(notes === 1 ? 'statNote' : 'statNotes')),
|
|
870
1247
|
stat(data.stores.length, t(data.stores.length === 1 ? 'statStore' : 'statStores')),
|
|
@@ -899,8 +1276,10 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
899
1276
|
* mark, the name, the type and size, and what stands out (a plan's day, a note grown past one
|
|
900
1277
|
* fact, one the index leaves out). While the page filters, the rows that match and no more.
|
|
901
1278
|
*/
|
|
902
|
-
function StoreSection({ store, cap, canOpen, open, match, kind, now, t }) {
|
|
1279
|
+
function StoreSection({ store, cap, canOpen, open, match, kind, now, t, onMoved }) {
|
|
903
1280
|
const [tidy, setTidy] = useState('idle')
|
|
1281
|
+
// the global store's: moving it, opened from its actions
|
|
1282
|
+
const [placing, setPlacing] = useState(false)
|
|
904
1283
|
const alive = useRef(true)
|
|
905
1284
|
useEffect(() => () => { alive.current = false }, [])
|
|
906
1285
|
const title = legible(store.kind === 'user' ? [t('storeUser'), ...store.titles].join(' · ')
|
|
@@ -1007,14 +1386,16 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1007
1386
|
h('span', { className: 'eng-meter-fill', style: { width: `${Math.min(100, Math.floor(fill * 100))}%` } })),
|
|
1008
1387
|
h('span', { className: 'eng-usage', 'data-over': index?.over === true, title: index?.over ? t('overHint') : undefined }, usage),
|
|
1009
1388
|
h('div', { className: 'eng-store-actions' },
|
|
1389
|
+
store.kind === 'user' ? h('button', { type: 'button', className: 'eng-btn eng-btn-ghost', key: 'place',
|
|
1390
|
+
'aria-expanded': placing, onClick: () => setPlacing(!placing) },
|
|
1391
|
+
icon('move', 14), t(placing ? 'placeHide' : 'placeChange')) : null,
|
|
1010
1392
|
attention ? null : tidyButton('eng-btn eng-btn-ghost'),
|
|
1011
1393
|
// the folder is shown with its index selected: no index, no folder to show
|
|
1012
1394
|
...(canOpen && index !== null ? [
|
|
1013
|
-
h('button', { type: 'button', className: 'eng-btn eng-btn-ghost', key: 'index',
|
|
1014
|
-
onClick: () => open(store, index.name, false) }, icon('index', 14), t('openIndex')),
|
|
1015
1395
|
h('button', { type: 'button', className: 'eng-btn eng-btn-ghost', key: 'folder',
|
|
1016
1396
|
onClick: () => open(store, undefined, false) }, icon('folder', 14), t('openFolder'))] : []))),
|
|
1017
1397
|
h('p', { className: 'eng-path' }, legible(store.dir)),
|
|
1398
|
+
placing ? h(PlaceSection, { t, onMoved }) : null,
|
|
1018
1399
|
!filtering && checked && findings.length === 0
|
|
1019
1400
|
? h('p', { className: 'eng-store-ok' }, icon('check', 13), t('healthOk')) : null,
|
|
1020
1401
|
attention ? h('div', { className: 'eng-attn', role: 'note' },
|
|
@@ -1060,10 +1441,107 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1060
1441
|
: /linux/i.test(platform) ? 'Linux' : 'unknown'
|
|
1061
1442
|
}
|
|
1062
1443
|
|
|
1444
|
+
/** The latest version on npm and the registry that said so, asked of each in turn until one
|
|
1445
|
+
* answers with a version; undefined when none does. Each gets 8 seconds, body included, and no cookie or
|
|
1446
|
+
* referrer goes with the request: the package's name is all it asks about. */
|
|
1447
|
+
async function latestVersion() {
|
|
1448
|
+
for (const [source, registry] of REGISTRIES) {
|
|
1449
|
+
const deadline = new AbortController()
|
|
1450
|
+
const timer = setTimeout(() => deadline.abort(), 8000)
|
|
1451
|
+
try {
|
|
1452
|
+
const response = await fetch(`${registry}/${PACKAGE}/latest`, { cache: 'no-store', credentials: 'omit',
|
|
1453
|
+
referrerPolicy: 'no-referrer', signal: deadline.signal, headers: { accept: 'application/json' } })
|
|
1454
|
+
const version = response.ok ? (await response.json())?.version : undefined
|
|
1455
|
+
if (typeof version === 'string' && version.length <= 64 && SEMVER.test(version)) return { version, source }
|
|
1456
|
+
} catch {
|
|
1457
|
+
// unreachable, refused, too slow or not JSON: the next registry
|
|
1458
|
+
} finally {
|
|
1459
|
+
clearTimeout(timer)
|
|
1460
|
+
// a body left unread (an error's) or half read is let go, not left streaming
|
|
1461
|
+
deadline.abort()
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
return undefined
|
|
1465
|
+
}
|
|
1466
|
+
|
|
1467
|
+
/** -1, 0 or 1 as version `a` is older than, the same as or newer than `b` (both SEMVER): by
|
|
1468
|
+
* the three numbers, then a prerelease before its release. Two prereleases of one release
|
|
1469
|
+
* count as the same; this package publishes none to npm's `latest`. */
|
|
1470
|
+
function compareVersions(a, b) {
|
|
1471
|
+
const x = SEMVER.exec(a)
|
|
1472
|
+
const y = SEMVER.exec(b)
|
|
1473
|
+
for (let i = 1; i <= 3; i++) {
|
|
1474
|
+
if (Number(x[i]) !== Number(y[i])) return Number(x[i]) < Number(y[i]) ? -1 : 1
|
|
1475
|
+
}
|
|
1476
|
+
return x[4] === y[4] || (x[4] !== undefined && y[4] !== undefined) ? 0 : x[4] === undefined ? 1 : -1
|
|
1477
|
+
}
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* The installed version and, on a click and only then, how it stands against the latest on
|
|
1481
|
+
* npm. A newer one comes with the steps that install it, the version named: by name alone,
|
|
1482
|
+
* pnpm (the desktop's, and the CLI's from pnpm 11) takes only a version a day old. dsh has no
|
|
1483
|
+
* update for a plugin outside its own catalog, so the desktop's way is uninstall and install.
|
|
1484
|
+
*/
|
|
1485
|
+
function UpdateCheck({ t }) {
|
|
1486
|
+
const [check, setCheck] = useState({ phase: 'idle' })
|
|
1487
|
+
const [copy, setCopy] = useState('copy')
|
|
1488
|
+
const alive = useRef(true)
|
|
1489
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1490
|
+
const run = async () => {
|
|
1491
|
+
setCheck({ phase: 'checking' })
|
|
1492
|
+
setCopy('copy')
|
|
1493
|
+
const found = await latestVersion()
|
|
1494
|
+
if (!alive.current) return
|
|
1495
|
+
setCheck(found === undefined ? { phase: 'failed' } : { phase: 'done', latest: found.version,
|
|
1496
|
+
source: found.source, order: compareVersions(found.version, VERSION) })
|
|
1497
|
+
}
|
|
1498
|
+
const spec = `${PACKAGE}@${check.latest}`
|
|
1499
|
+
const copySpec = async () => {
|
|
1500
|
+
const done = await copyText(spec)
|
|
1501
|
+
if (alive.current) setCopy(done ? 'copied' : 'copyFailed')
|
|
1502
|
+
}
|
|
1503
|
+
const external = (href, text) => h('a', { className: 'eng-link', href, target: '_blank', rel: 'noopener noreferrer' }, text)
|
|
1504
|
+
let result = null
|
|
1505
|
+
if (check.phase === 'failed') {
|
|
1506
|
+
result = h('p', { role: 'status' }, t('updateFailed'), external(NPM_PAGE, t('updateNpm')))
|
|
1507
|
+
} else if (check.phase === 'done' && check.order <= 0) {
|
|
1508
|
+
result = h('p', { role: 'status' },
|
|
1509
|
+
check.order === 0 ? t('updateCurrent', { latest: check.latest, source: check.source })
|
|
1510
|
+
: t('updateAhead', { latest: check.latest, current: VERSION, source: check.source }))
|
|
1511
|
+
} else if (check.phase === 'done') {
|
|
1512
|
+
result = h('div', { className: 'eng-update', role: 'status' },
|
|
1513
|
+
h('p', null,
|
|
1514
|
+
h('span', { className: 'eng-update-new' }, t('updateNewer', { latest: check.latest, current: VERSION })),
|
|
1515
|
+
external(`${RELEASE}${check.latest}`, t('updateNotes'))),
|
|
1516
|
+
h('p', null, t('updateHow')),
|
|
1517
|
+
h('ul', null,
|
|
1518
|
+
h('li', null, t('updateDesktop'), h('code', { className: 'eng-code' }, spec),
|
|
1519
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-small', onClick: copySpec },
|
|
1520
|
+
t(copy === 'copied' ? 'copied' : 'copy'))),
|
|
1521
|
+
h('li', null, t('updateCli'),
|
|
1522
|
+
h('code', { className: 'eng-code' }, `dsh plugin --profile ${t('updateProfile')} add ${spec}`))),
|
|
1523
|
+
copy === 'copyFailed' ? h('p', { className: 'eng-feedback-note' }, t('copySpecFailed')) : null,
|
|
1524
|
+
h('p', null, t('updateAfter')))
|
|
1525
|
+
}
|
|
1526
|
+
// a mirror's word, which may trail npm's, is said to be one
|
|
1527
|
+
const mirrored = check.phase === 'done' && check.source !== 'npm'
|
|
1528
|
+
? h('p', { className: 'eng-feedback-note' }, t('updateMirror')) : null
|
|
1529
|
+
return h('div', { className: 'eng-version' },
|
|
1530
|
+
h('p', null,
|
|
1531
|
+
icon('package', 14),
|
|
1532
|
+
t('versionLine', { version: VERSION }),
|
|
1533
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-small', disabled: check.phase === 'checking',
|
|
1534
|
+
onClick: run }, t(check.phase === 'checking' ? 'checking' : 'checkUpdate'))),
|
|
1535
|
+
result,
|
|
1536
|
+
mirrored,
|
|
1537
|
+
h('p', { className: 'eng-feedback-note' }, t('updateNote')))
|
|
1538
|
+
}
|
|
1539
|
+
|
|
1063
1540
|
/**
|
|
1064
1541
|
* Where to report a problem or send an idea: a new issue, its body started with the
|
|
1065
1542
|
* plugin's version and the OS (no path, no note), or the mailbox, whose address the
|
|
1066
|
-
* button copies — the desktop app opens only web links, not `mailto:`.
|
|
1543
|
+
* button copies — the desktop app opens only web links, not `mailto:`. Above them, the
|
|
1544
|
+
* version and the check for a newer one.
|
|
1067
1545
|
*/
|
|
1068
1546
|
function Feedback({ t }) {
|
|
1069
1547
|
const [copy, setCopy] = useState('copy')
|
|
@@ -1075,6 +1553,7 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1075
1553
|
}
|
|
1076
1554
|
const href = `${ISSUES}?body=${encodeURIComponent(t('issueBody', { version: VERSION, os: osName() }))}`
|
|
1077
1555
|
return h('footer', { className: 'eng-feedback' },
|
|
1556
|
+
h(UpdateCheck, { t }),
|
|
1078
1557
|
h('p', null,
|
|
1079
1558
|
icon('issue', 14),
|
|
1080
1559
|
t('feedbackLead'),
|
|
@@ -1084,7 +1563,7 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1084
1563
|
h('button', { type: 'button', className: 'eng-btn eng-btn-small', onClick: copyAddress },
|
|
1085
1564
|
t(copy === 'copied' ? 'copied' : 'copy'))),
|
|
1086
1565
|
copy === 'copyFailed' ? h('p', { className: 'eng-feedback-note', role: 'status' }, t('copyFailed')) : null,
|
|
1087
|
-
h('p', { className: 'eng-feedback-note' }, t('feedbackNote'
|
|
1566
|
+
h('p', { className: 'eng-feedback-note' }, t('feedbackNote')))
|
|
1088
1567
|
}
|
|
1089
1568
|
|
|
1090
1569
|
/**
|
|
@@ -1149,8 +1628,13 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1149
1628
|
(shown === undefined ? store.archive.filter(match).length : 0), 0)
|
|
1150
1629
|
body = [
|
|
1151
1630
|
data.pinned === 'relative' ? h('p', { className: 'eng-note', key: 'pinned' }, t('pinnedRelative')) : null,
|
|
1152
|
-
data.
|
|
1153
|
-
|
|
1631
|
+
data.location !== undefined ? h('p', { className: 'eng-note', key: 'location' }, t('locationUnknown')) : null,
|
|
1632
|
+
data.stores.length === 0 && data.pinned === undefined && data.location === undefined &&
|
|
1633
|
+
!(data.unreadable > 0) && data.more !== true
|
|
1634
|
+
? h(NoMemory, { key: 'empty', t, onMoved: load })
|
|
1635
|
+
// projects' stores listed, the global one not made yet: still to be moved from here
|
|
1636
|
+
: data.stores.length > 0 && data.global === 'absent'
|
|
1637
|
+
? h(NoMemory, { key: 'global', t, onMoved: load, note: 'global' }) : null,
|
|
1154
1638
|
notes.length + archived > 0 ? h('div', { className: 'eng-toolbar', key: 'toolbar' },
|
|
1155
1639
|
h('div', { className: 'eng-tabs', role: 'group', 'aria-label': t('typeLabel') },
|
|
1156
1640
|
tab(undefined, t('typeAll'), notes.length),
|
|
@@ -1161,7 +1645,7 @@ button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-ho
|
|
|
1161
1645
|
'aria-label': t('filterLabel'), onChange: (event) => setQuery(event.target.value) }))) : null,
|
|
1162
1646
|
match === undefined ? null : h('p', { className: 'eng-filter-count', key: 'count', role: 'status',
|
|
1163
1647
|
'aria-live': 'polite' }, t('filterCount', { count: matched })),
|
|
1164
|
-
...data.stores.map((store) => h(StoreSection, { key: store.id, store, cap: data.cap, canOpen, open, match,
|
|
1648
|
+
...data.stores.map((store) => h(StoreSection, { key: store.id, store, cap: data.cap, canOpen, open, match, onMoved: load,
|
|
1165
1649
|
kind: shown, now: state.at, t })),
|
|
1166
1650
|
data.more ? h('p', { className: 'eng-note', key: 'more' }, t('more')) : null,
|
|
1167
1651
|
]
|