dsh-engramory 1.5.7 → 2.0.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 +284 -327
- package/README.md +136 -159
- package/client.js +1633 -1715
- package/index.js +3889 -5096
- package/package.json +72 -86
package/client.js
CHANGED
|
@@ -1,1715 +1,1633 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* dsh-engramory, browser half: the settings on the package's own page in the Plugins page,
|
|
3
|
-
* and the sidebar's Memory entry — a page listing the memory stores by name, with the two
|
|
4
|
-
* settings that matter most at its top. The settings go through the route index.js
|
|
5
|
-
* registers for them (the memory's language follows dsh's); the page lists the stores and
|
|
6
|
-
* opens a note in the desktop's own app through the memory route, so no note's text is
|
|
7
|
-
* ever read into the page.
|
|
8
|
-
*
|
|
9
|
-
* Plain script, no build step, like index.js: React comes from the page's module table,
|
|
10
|
-
* no Harness client package is loaded as a module (dsh's guidance — they change without
|
|
11
|
-
* notice), and the colours are the host's theme tokens, so light, dark and third-party themes
|
|
12
|
-
* follow — but for the memory page's banner, in the project's own navy and mint on any theme,
|
|
13
|
-
* that mint again in an index's fill bar and a clean check-up's tick, and the note types'
|
|
14
|
-
* marks, each a muted colour of its own leaned toward the theme's text.
|
|
15
|
-
* Visible text goes through the locale service.
|
|
16
|
-
*/
|
|
17
|
-
window.__ModuleLoader__.load({
|
|
18
|
-
id: 'dsh-engramory',
|
|
19
|
-
factory(require) {
|
|
20
|
-
const React = require('react')
|
|
21
|
-
const h = React.createElement
|
|
22
|
-
const { useCallback, useEffect, useRef, useState } = React
|
|
23
|
-
|
|
24
|
-
const NS = 'engramory'
|
|
25
|
-
/** The Plugins page keys a package's own settings by its package name. */
|
|
26
|
-
const PACKAGE = 'dsh-engramory'
|
|
27
|
-
/** The sidebar entry and the main-column page it opens share this id. */
|
|
28
|
-
const PANEL = 'engramory'
|
|
29
|
-
/** Relative to the page, as dsh's own pages fetch, so a mounted deployment keeps its prefix. */
|
|
30
|
-
const SETTINGS_API = 'api/engramory/settings'
|
|
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
|
|
37
|
-
const
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
/** Where
|
|
49
|
-
|
|
50
|
-
const
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
const
|
|
54
|
-
/**
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
.eng-
|
|
462
|
-
.eng-
|
|
463
|
-
.eng-
|
|
464
|
-
.eng-
|
|
465
|
-
.eng-
|
|
466
|
-
.eng-
|
|
467
|
-
.eng-
|
|
468
|
-
.eng-
|
|
469
|
-
.eng-
|
|
470
|
-
.eng-
|
|
471
|
-
.eng-
|
|
472
|
-
.eng-
|
|
473
|
-
.eng-
|
|
474
|
-
.eng-
|
|
475
|
-
.eng-
|
|
476
|
-
.eng-
|
|
477
|
-
.eng-
|
|
478
|
-
.eng-
|
|
479
|
-
.eng-
|
|
480
|
-
.eng-
|
|
481
|
-
.eng-
|
|
482
|
-
.eng-
|
|
483
|
-
.eng-
|
|
484
|
-
.eng-
|
|
485
|
-
.eng-
|
|
486
|
-
.eng-
|
|
487
|
-
.eng-
|
|
488
|
-
.eng-
|
|
489
|
-
.eng-
|
|
490
|
-
.eng-
|
|
491
|
-
.eng-
|
|
492
|
-
.eng-
|
|
493
|
-
.eng-
|
|
494
|
-
.eng-
|
|
495
|
-
.eng-
|
|
496
|
-
.eng-
|
|
497
|
-
.eng-
|
|
498
|
-
.eng-
|
|
499
|
-
.eng-
|
|
500
|
-
|
|
501
|
-
.eng-
|
|
502
|
-
.eng-
|
|
503
|
-
.eng-hero
|
|
504
|
-
.eng-hero-
|
|
505
|
-
.eng-
|
|
506
|
-
.eng-
|
|
507
|
-
.eng-hero-
|
|
508
|
-
.eng-
|
|
509
|
-
.eng-
|
|
510
|
-
.eng-
|
|
511
|
-
.eng-
|
|
512
|
-
.eng-
|
|
513
|
-
.eng-
|
|
514
|
-
.eng-
|
|
515
|
-
.eng-
|
|
516
|
-
.eng-
|
|
517
|
-
.eng-
|
|
518
|
-
.eng-
|
|
519
|
-
.eng-
|
|
520
|
-
.eng-
|
|
521
|
-
.eng-
|
|
522
|
-
.eng-
|
|
523
|
-
.eng-
|
|
524
|
-
.eng-
|
|
525
|
-
.eng-
|
|
526
|
-
.eng-
|
|
527
|
-
.eng-
|
|
528
|
-
.eng-
|
|
529
|
-
.eng-
|
|
530
|
-
.eng-
|
|
531
|
-
.eng-
|
|
532
|
-
.eng-
|
|
533
|
-
.eng-
|
|
534
|
-
.eng-
|
|
535
|
-
.eng-
|
|
536
|
-
.eng-
|
|
537
|
-
.eng-
|
|
538
|
-
.eng-
|
|
539
|
-
.eng-
|
|
540
|
-
.eng-
|
|
541
|
-
.eng-
|
|
542
|
-
.eng-
|
|
543
|
-
.eng-
|
|
544
|
-
.eng-
|
|
545
|
-
.eng-
|
|
546
|
-
.eng-
|
|
547
|
-
.eng-
|
|
548
|
-
.eng-
|
|
549
|
-
.eng-
|
|
550
|
-
.eng-
|
|
551
|
-
.eng-
|
|
552
|
-
.eng-
|
|
553
|
-
.eng-
|
|
554
|
-
.eng-
|
|
555
|
-
.eng-
|
|
556
|
-
.eng-
|
|
557
|
-
.eng-
|
|
558
|
-
.eng-
|
|
559
|
-
.eng-
|
|
560
|
-
.eng-
|
|
561
|
-
.eng-
|
|
562
|
-
.eng-
|
|
563
|
-
.eng-
|
|
564
|
-
.eng-
|
|
565
|
-
.eng-
|
|
566
|
-
.eng-
|
|
567
|
-
.eng-
|
|
568
|
-
.eng-
|
|
569
|
-
.eng-
|
|
570
|
-
.eng-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
.eng-
|
|
574
|
-
.eng-
|
|
575
|
-
.eng-
|
|
576
|
-
.eng-
|
|
577
|
-
.eng-
|
|
578
|
-
.eng-
|
|
579
|
-
.eng-
|
|
580
|
-
.eng-
|
|
581
|
-
.eng-
|
|
582
|
-
.eng-
|
|
583
|
-
.eng-
|
|
584
|
-
.eng-
|
|
585
|
-
.eng-
|
|
586
|
-
.eng-
|
|
587
|
-
.eng-
|
|
588
|
-
.eng-
|
|
589
|
-
.eng-
|
|
590
|
-
.eng-
|
|
591
|
-
.eng-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
.
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
.
|
|
598
|
-
.
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
.
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
.
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
return
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
if (
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
setBanner({ tone: '
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
return h('
|
|
786
|
-
h('
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
h(
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
const
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
return
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
/**
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
const
|
|
1065
|
-
|
|
1066
|
-
const
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
const
|
|
1087
|
-
|
|
1088
|
-
const
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
return
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
/**
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
[
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
function
|
|
1184
|
-
const
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
const
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
const
|
|
1299
|
-
:
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
const
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
const
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
}
|
|
1505
|
-
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
}
|
|
1533
|
-
// a
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
store.notes.filter((note) => (shown === undefined || note.type === shown) && match(note.name)).length +
|
|
1635
|
-
(shown === undefined ? store.archive.filter(match).length : 0), 0)
|
|
1636
|
-
body = [
|
|
1637
|
-
data.pinned === 'relative' ? h('p', { className: 'eng-note', key: 'pinned' }, t('pinnedRelative')) : null,
|
|
1638
|
-
data.location !== undefined ? h('p', { className: 'eng-note', key: 'location' }, t('locationUnknown')) : null,
|
|
1639
|
-
data.stores.length === 0 && data.pinned === undefined && data.location === undefined &&
|
|
1640
|
-
!(data.unreadable > 0) && data.more !== true
|
|
1641
|
-
? h(NoMemory, { key: 'empty', t, onMoved: load })
|
|
1642
|
-
// projects' stores listed, the global one not made yet: still to be moved from here
|
|
1643
|
-
: data.stores.length > 0 && data.global === 'absent'
|
|
1644
|
-
? h(NoMemory, { key: 'global', t, onMoved: load, note: 'global' }) : null,
|
|
1645
|
-
notes.length + archived > 0 ? h('div', { className: 'eng-toolbar', key: 'toolbar' },
|
|
1646
|
-
h('div', { className: 'eng-tabs', role: 'group', 'aria-label': t('typeLabel') },
|
|
1647
|
-
tab(undefined, t('typeAll'), notes.length),
|
|
1648
|
-
...counts.map(([type, count]) => tab(type, t(typeKey(type)), count))),
|
|
1649
|
-
h('label', { className: 'eng-search' },
|
|
1650
|
-
icon('search', 15),
|
|
1651
|
-
h('input', { type: 'search', className: 'eng-input', value: query, placeholder: t('filterPlaceholder'),
|
|
1652
|
-
'aria-label': t('filterLabel'), onChange: (event) => setQuery(event.target.value) }))) : null,
|
|
1653
|
-
match === undefined ? null : h('p', { className: 'eng-filter-count', key: 'count', role: 'status',
|
|
1654
|
-
'aria-live': 'polite' }, t('filterCount', { count: matched })),
|
|
1655
|
-
...data.stores.map((store) => h(StoreSection, { key: store.id, store, cap: data.cap, canOpen, open, match, onMoved: load,
|
|
1656
|
-
kind: shown, now: state.at, t })),
|
|
1657
|
-
data.more ? h('p', { className: 'eng-note', key: 'more' }, t('more')) : null,
|
|
1658
|
-
]
|
|
1659
|
-
}
|
|
1660
|
-
return h('div', { className: 'eng-memory' },
|
|
1661
|
-
h(Hero, { data, at: state.at, refresh: () => { setStatus(undefined); load() }, t }),
|
|
1662
|
-
data === undefined ? null : h(Caveats, { data, t }),
|
|
1663
|
-
status ? h('div', { className: 'eng-banner', 'data-tone': status.tone, role: 'status' }, status.text) : null,
|
|
1664
|
-
data !== undefined && !canOpen && data.stores.length > 0 ? h('p', { className: 'eng-note' }, t('openUnavailable')) : null,
|
|
1665
|
-
body,
|
|
1666
|
-
h(HowTo, { open: data !== undefined && data.pinned !== 'relative' && data.more !== true &&
|
|
1667
|
-
!(data.unreadable > 0) && !data.stores.some((store) => hasMemory(store) || readInPart(store)), t }),
|
|
1668
|
-
h(Feedback, { t }))
|
|
1669
|
-
}
|
|
1670
|
-
|
|
1671
|
-
/** The sidebar entry's icon: the logo, [[ ]] around a cursor, drawn in the row's own colour
|
|
1672
|
-
* (so it follows dsh's light and dark themes) at the size it asks for. */
|
|
1673
|
-
function MemoryIcon({ size }) {
|
|
1674
|
-
return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor',
|
|
1675
|
-
strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
|
|
1676
|
-
h('path', { d: 'M5.1 3.5H2.5v17h2.6M9.2 3.5H6.6v17h2.6' }),
|
|
1677
|
-
h('path', { d: 'M18.9 3.5h2.6v17h-2.6M14.8 3.5h2.6v17h-2.6' }),
|
|
1678
|
-
h('rect', { x: 10.4, y: 7, width: 3.2, height: 10, rx: 1, fill: 'currentColor', stroke: 'none' }))
|
|
1679
|
-
}
|
|
1680
|
-
|
|
1681
|
-
return {
|
|
1682
|
-
inject: ['slots', 'locale'],
|
|
1683
|
-
apply(ctx) {
|
|
1684
|
-
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-engramory: dictionaries')
|
|
1685
|
-
ctx.effect(() => {
|
|
1686
|
-
const tag = document.createElement('style')
|
|
1687
|
-
tag.dataset.plugin = 'dsh-engramory'
|
|
1688
|
-
tag.dataset.pluginCss = 'dsh-engramory/settings.css'
|
|
1689
|
-
tag.textContent = CSS
|
|
1690
|
-
document.head.appendChild(tag)
|
|
1691
|
-
return () => tag.remove()
|
|
1692
|
-
}, 'dsh-engramory: styles')
|
|
1693
|
-
ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
|
|
1694
|
-
name: 'plugins.bundle.config',
|
|
1695
|
-
key: PACKAGE,
|
|
1696
|
-
locale: NS,
|
|
1697
|
-
}, SettingsPage))
|
|
1698
|
-
const t = ctx.locale.bind(NS)
|
|
1699
|
-
ctx.slots.inject('main', () => ctx.slots.register({
|
|
1700
|
-
name: 'main',
|
|
1701
|
-
key: PANEL,
|
|
1702
|
-
locale: NS,
|
|
1703
|
-
}, MemoryPage))
|
|
1704
|
-
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
1705
|
-
name: 'sidebar.panellist',
|
|
1706
|
-
id: PANEL,
|
|
1707
|
-
// after dsh's own entries (Plugins 0, Automations 10)
|
|
1708
|
-
order: 20,
|
|
1709
|
-
locale: NS,
|
|
1710
|
-
label: () => t('panel'),
|
|
1711
|
-
}, MemoryIcon))
|
|
1712
|
-
},
|
|
1713
|
-
}
|
|
1714
|
-
},
|
|
1715
|
-
})
|
|
1
|
+
/**
|
|
2
|
+
* dsh-engramory, browser half: the settings on the package's own page in the Plugins page,
|
|
3
|
+
* and the sidebar's Memory entry — a page listing the memory stores by name, with the two
|
|
4
|
+
* settings that matter most at its top. The settings go through the route index.js
|
|
5
|
+
* registers for them (the memory's language follows dsh's); the page lists the stores and
|
|
6
|
+
* opens a note in the desktop's own app through the memory route, so no note's text is
|
|
7
|
+
* ever read into the page.
|
|
8
|
+
*
|
|
9
|
+
* Plain script, no build step, like index.js: React comes from the page's module table,
|
|
10
|
+
* no Harness client package is loaded as a module (dsh's guidance — they change without
|
|
11
|
+
* notice), and the colours are the host's theme tokens, so light, dark and third-party themes
|
|
12
|
+
* follow — but for the memory page's banner, in the project's own navy and mint on any theme,
|
|
13
|
+
* that mint again in an index's fill bar and a clean check-up's tick, and the note types'
|
|
14
|
+
* marks, each a muted colour of its own leaned toward the theme's text.
|
|
15
|
+
* Visible text goes through the locale service.
|
|
16
|
+
*/
|
|
17
|
+
window.__ModuleLoader__.load({
|
|
18
|
+
id: 'dsh-engramory',
|
|
19
|
+
factory(require) {
|
|
20
|
+
const React = require('react')
|
|
21
|
+
const h = React.createElement
|
|
22
|
+
const { useCallback, useEffect, useRef, useState } = React
|
|
23
|
+
|
|
24
|
+
const NS = 'engramory'
|
|
25
|
+
/** The Plugins page keys a package's own settings by its package name. */
|
|
26
|
+
const PACKAGE = 'dsh-engramory'
|
|
27
|
+
/** The sidebar entry and the main-column page it opens share this id. */
|
|
28
|
+
const PANEL = 'engramory'
|
|
29
|
+
/** Relative to the page, as dsh's own pages fetch, so a mounted deployment keeps its prefix. */
|
|
30
|
+
const SETTINGS_API = 'api/engramory/settings'
|
|
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 long the page waits on a move: the plugin answers once it is done (up to 256 MB copied). */
|
|
37
|
+
const MOVE_WAIT_MS = 10 * 60 * 1000
|
|
38
|
+
/** This plugin's version, for the feedback footer; a test keeps it equal to package.json's. */
|
|
39
|
+
const VERSION = '2.0.0'
|
|
40
|
+
/** Where feedback goes: a new issue on the repository, or the project's mailbox. Opening
|
|
41
|
+
* the link is the browser's (the desktop app hands it to the system's); the footer submits
|
|
42
|
+
* nothing by itself. */
|
|
43
|
+
const ISSUES = 'https://github.com/tinqiao-oss/engramory/issues/new'
|
|
44
|
+
const EMAIL = 'engramory@agent.qq.com'
|
|
45
|
+
/** Where "Check for updates" asks for the latest version, in turn: npm's own registry, then
|
|
46
|
+
* npmmirror, its mirror in China, for when npm cannot be reached. Asked on that click only. */
|
|
47
|
+
const REGISTRIES = [['npm', 'https://registry.npmjs.org'], ['npmmirror', 'https://registry.npmmirror.com']]
|
|
48
|
+
/** Where to look when neither answers, and what a newer version changed. */
|
|
49
|
+
const NPM_PAGE = 'https://www.npmjs.com/package/dsh-engramory?activeTab=versions'
|
|
50
|
+
const RELEASE = 'https://github.com/tinqiao-oss/engramory/releases/tag/v'
|
|
51
|
+
/** A version as SemVer writes one: three numbers without leading zeros, then maybe a prerelease
|
|
52
|
+
* tag and build metadata, each in dot-separated identifiers (a numeric one without leading zeros). */
|
|
53
|
+
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-]+)*)?$/
|
|
54
|
+
/** The how-to's lines, in order. */
|
|
55
|
+
const HOW_TO = ['howToSay', 'howToRecall', 'howToEdit', 'howToMove', 'howToSocial']
|
|
56
|
+
/** A note past this is almost always a timeline under one slug (SKILL.md: "A note has a size
|
|
57
|
+
* too"); the doctor warns at the same size (ENGRAMORY_NOTE_WARN_BYTES). */
|
|
58
|
+
const LARGE_NOTE = 12 * 1024
|
|
59
|
+
/** An `upcoming` note named with its date: `2026-10-31-interview`, `2026-10-31面试` (SKILL.md §2.2). */
|
|
60
|
+
const DATED = /^(\d{4})-(\d{2})-(\d{2})(?!\d)/
|
|
61
|
+
const DEFAULT_LINES = 200
|
|
62
|
+
const DEFAULT_BYTES = 25600
|
|
63
|
+
/** The order the memory page shows note types in (SKILL.md §2, §2.2). */
|
|
64
|
+
const TYPES = ['user', 'feedback', 'project', 'reference', 'moment', 'upcoming', 'self', 'other']
|
|
65
|
+
|
|
66
|
+
const zh = {
|
|
67
|
+
summary: '大肥鱼模式和记忆权限、索引上限。',
|
|
68
|
+
loading: '正在读取设置…',
|
|
69
|
+
loadFailed: '读不到设置。',
|
|
70
|
+
retry: '重试',
|
|
71
|
+
unavailable: '这个 dsh 不能在页面里保存这些设置(没有配置编辑服务)。请改配置文件 cordis.patch.yml,写法见插件说明。',
|
|
72
|
+
expression: '配置文件里有设置是用 !!js 表达式写的,这里显示不了它的实际值,所以只读。请直接改 cordis.patch.yml。',
|
|
73
|
+
companion: '大肥鱼模式',
|
|
74
|
+
companionHint: '多记三类:经历、约定、我自己,用角色口吻回忆。',
|
|
75
|
+
closedSocial: '社交模式在 2.0 去掉了。这个 profile 还设着它,所以 Engramory 现在不给任何对话记忆。接 QQ、微信等让别人也能聊的机器人,请给它另用一个 dsh 主目录(同一个主目录下的 profile 共用记忆库);在这里保存一次设置,记忆就恢复。',
|
|
76
|
+
reopen: '恢复记忆',
|
|
77
|
+
cap: '索引上限',
|
|
78
|
+
capHint: '默认 200 行 / 25600 字节,超过后 AI 要先压缩才能再写。',
|
|
79
|
+
capLines: '行',
|
|
80
|
+
capBytes: '字节',
|
|
81
|
+
save: '保存',
|
|
82
|
+
saving: '保存中…',
|
|
83
|
+
discard: '放弃修改',
|
|
84
|
+
reloading: '已保存,插件正在用新设置重新加载…',
|
|
85
|
+
saved: '已保存。',
|
|
86
|
+
savedUnconfirmed: '已保存,但重新读到的设置和刚才填的不一样(或者插件还没加载好)。请刷新页面看看。',
|
|
87
|
+
stale: '设置在别处被改过,已重新读取。请再改一次。',
|
|
88
|
+
overridden: '更高一层的配置覆盖了这些值,这里保存不了。',
|
|
89
|
+
invalid: '有一项填得不对:',
|
|
90
|
+
failed: '保存失败:',
|
|
91
|
+
place: '记忆库位置',
|
|
92
|
+
placeNow: '现在在',
|
|
93
|
+
placeIsDefault: '(默认位置)',
|
|
94
|
+
placeLoadFailed: '读不到记忆库在哪。',
|
|
95
|
+
placeLoading: '正在读取记忆库位置…',
|
|
96
|
+
placeChange: '更换存储地址',
|
|
97
|
+
globalAbsent: '全局记忆还没有建,AI 第一次往全局库存记忆时会自动建好。',
|
|
98
|
+
placeHide: '收起',
|
|
99
|
+
placeChoose: '选文件夹…',
|
|
100
|
+
placeChoosing: '在弹出的窗口里选…',
|
|
101
|
+
placeChosenInside: '选的文件夹里已经有东西,会在里面新建一个 {name} 文件夹来放记忆。',
|
|
102
|
+
placeChooseFailed: '打不开选文件夹的窗口:{reason}',
|
|
103
|
+
placeInput: '新位置',
|
|
104
|
+
placePlaceholder: '新位置:一个空文件夹或还不存在的文件夹,例如 D:\\同步盘\\AI记忆',
|
|
105
|
+
placeMove: '搬过去',
|
|
106
|
+
placeBack: '搬回默认位置',
|
|
107
|
+
placeHint: '整个记忆库连同归档复制到新位置,逐个文件核对后切换过去;旧库改名留在原处旁边作备份(名字后面加 .backup-日期),确认新位置没问题后可以自己删掉。这台电脑上的桌面版和命令行都用新位置。搬的那几秒 AI 存不了记忆,会过一会儿再存;同时开着的其他 dsh 窗口那几秒写进的内容只留在备份里,换位置前最好关掉它们。放进网盘的话别让两台电脑同时写;放进 git 仓库会被一起提交;映射的网络盘可能让 dsh 卡顿。',
|
|
108
|
+
placeMoving: '正在搬…',
|
|
109
|
+
placeMoved: '搬好了。',
|
|
110
|
+
placeMovedBackup: '搬好了。旧库改名留作备份:{backup},确认新位置没问题后可以删掉。',
|
|
111
|
+
placeMovedKept: '搬好了。旧库有文件正被占用,没能改名,原样留在 {backup} 作备份;确认新位置没问题后可以删掉。AI 不会再往那里写。',
|
|
112
|
+
placeSame: '记忆库已经在这里了。',
|
|
113
|
+
placeMoveFailed: '没搬成:{reason}',
|
|
114
|
+
placeCopyLeft: '新位置 {left} 留下了一份副本,用不着的话可以删掉。',
|
|
115
|
+
placePinned: '配置里固定了索引(indexPath),记忆库就在它所在的文件夹,这里不能搬。',
|
|
116
|
+
placeRemote: 'dsh 主目录在网络位置上,这里不能搬。',
|
|
117
|
+
placeProblem: '记录记忆库位置的文件读不懂,暂时找不到记忆库:{file}。把它改对后刷新这一页。',
|
|
118
|
+
placeCustomSkill: '你用的是自己写的记忆规则(skill),里面写的位置搬完要自己改。',
|
|
119
|
+
placeLegacy: 'dsh 主目录的 AGENTS.md 里还有不装插件时写进去的记忆规则,写的是默认位置;装了插件就用不着它了,可以用 engramory_init.py 卸掉。',
|
|
120
|
+
whyRelative: '要写完整路径(Windows 上带盘符)。',
|
|
121
|
+
whyNetwork: '不能放在网络路径上。',
|
|
122
|
+
whyRoot: '不能是整个盘。',
|
|
123
|
+
whyDeep: '路径太深了。',
|
|
124
|
+
whyInvalid: '路径里有 Windows 不认的名字或字符。',
|
|
125
|
+
whyReserved: '这个位置不能用:用户主目录、dsh 主目录和它们的上级都不行,名字也不能跟记忆库撞。',
|
|
126
|
+
whyNested: '新位置不能在记忆库里面,也不能把记忆库包在里面。',
|
|
127
|
+
whyNotEmpty: '那个文件夹里已经有东西了,要选空文件夹或还不存在的文件夹。',
|
|
128
|
+
whyNotDir: '那里是个文件,不是文件夹。',
|
|
129
|
+
whyLink: '新位置或记忆库里有目录链接,插件不替你搬,请手动处理。',
|
|
130
|
+
whyUnreadable: '读不了那个位置。',
|
|
131
|
+
whyUnavailable: '现在的记忆库找不到了,比如它所在的盘没接上。',
|
|
132
|
+
whyBusy: '正在搬家,等它做完。',
|
|
133
|
+
whyProblem: '记忆库位置的记录有问题,先修好它。',
|
|
134
|
+
whyTooMany: '文件太多了。',
|
|
135
|
+
whyTooBig: '太大了(超过 256 MB)。',
|
|
136
|
+
whyTooDeep: '文件夹层数太多了。',
|
|
137
|
+
whySpecial: '记忆库里有不是普通文件的东西。',
|
|
138
|
+
whyChanged: '搬的时候记忆库被别处换了位置。',
|
|
139
|
+
whyFailed: '文件操作出错了。',
|
|
140
|
+
locationUnknown: '记录记忆库位置的文件(dsh 主目录下的 .engramory-memory.json)读不懂,全局记忆这次没列出来。把它改对后点刷新。',
|
|
141
|
+
panel: '记忆',
|
|
142
|
+
panelTitle: 'Engramory 记忆',
|
|
143
|
+
refresh: '刷新',
|
|
144
|
+
stripNote: '说明和索引上限在「插件 → Engramory 记忆」。',
|
|
145
|
+
stripReadOnly: '这里改不了,见「插件 → Engramory 记忆」。',
|
|
146
|
+
listing: '正在读取记忆…',
|
|
147
|
+
listFailed: '读不到记忆库。',
|
|
148
|
+
listTimeout: '读取超时了,可能有工作区在连不上的网络盘上。稍后点刷新再试。',
|
|
149
|
+
empty: '还没有记忆。AI 第一次存记忆时会自动建好记忆库。',
|
|
150
|
+
pinnedRelative: '配置里固定的索引(indexPath)是相对路径,跟着每个会话的目录走,这里列不出来。改成绝对路径就能在这里看到。',
|
|
151
|
+
storeUser: '全局记忆',
|
|
152
|
+
storePinned: '固定的记忆库',
|
|
153
|
+
usage: '索引 {lines} / {maxLines} 行 · {size} / {maxSize}',
|
|
154
|
+
usageOver: '索引 {size} / {maxSize},超出上限',
|
|
155
|
+
usageSize: '索引 {size} / {maxSize}',
|
|
156
|
+
sizeBytes: '{n} B',
|
|
157
|
+
sizeKB: '{n} KB',
|
|
158
|
+
overHint: '超出上限了,AI 只读得到前面一部分,该压缩了。',
|
|
159
|
+
noIndex: '还没有索引',
|
|
160
|
+
openFolder: '打开文件夹',
|
|
161
|
+
opened: '已打开 {name}。',
|
|
162
|
+
revealed: '已在文件夹里显示 {name}。',
|
|
163
|
+
openUnavailable: '这台 dsh 不能在本机打开文件(比如远程访问时)。文件在上面写的位置。',
|
|
164
|
+
openMissing: '找不到这个文件了,可能刚被改名或删掉。点刷新看看。',
|
|
165
|
+
openBusy: '还在打开上一个,稍等一下再点。',
|
|
166
|
+
openFailed: '打不开:{reason}',
|
|
167
|
+
typeUser: '用户',
|
|
168
|
+
typeFeedback: '反馈',
|
|
169
|
+
typeProject: '项目',
|
|
170
|
+
typeReference: '参考',
|
|
171
|
+
typeMoment: '经历',
|
|
172
|
+
typeUpcoming: '约定',
|
|
173
|
+
typeSelf: '我自己',
|
|
174
|
+
typeOther: '其他',
|
|
175
|
+
archive: '归档 {count} 份',
|
|
176
|
+
more: '文件太多,这里只列出了一部分。',
|
|
177
|
+
healthOk: '体检:没发现问题。',
|
|
178
|
+
healthBroken: '索引里指向不存在的文件({count})',
|
|
179
|
+
healthBrokenMore: '索引里指向不存在的文件({count} 个以上)',
|
|
180
|
+
healthBrokenUnlisted: '索引里有指向不存在的文件,太多了,这里没列出。',
|
|
181
|
+
healthUnindexed: '不在索引里({count}):AI 回忆从索引开始,这些它通常找不到,除非别的笔记链到它们。',
|
|
182
|
+
healthUntyped: '没写类型或类型不认识({count}),列在「其他」里。',
|
|
183
|
+
healthFix: '完整检查可以用 engramory_doctor.py。',
|
|
184
|
+
healthLarge: '要核对的太多,没做体检。',
|
|
185
|
+
healthUnreadable: '有文件读不了,没做体检。',
|
|
186
|
+
healthPartial: '文件太多没列全,没做体检。',
|
|
187
|
+
howTo: '怎么用',
|
|
188
|
+
howToSay: '想让 AI 记住什么,直接跟它说,比如「记住:我习惯用 pnpm」「把这个决定记下来」。平时它也会尽量自己挑值得长期记住的记下来,比如你纠正过它的做法。',
|
|
189
|
+
howToRecall: '默认每次对话都会带上记忆的目录(索引),AI 用到细节时再打开那条笔记,不用你提醒。',
|
|
190
|
+
howToEdit: '这里列出读得到的记忆,打开笔记就能直接改;想让 AI 忘掉什么,跟它说「忘掉……」就行。',
|
|
191
|
+
howToMove: '记忆是存在运行 dsh 那台电脑上的普通 markdown 文件,位置写在每个库的标题下面。想放到别处(比如网盘里),点「全局记忆」右上角的「更换存储地址」,插件会整个复制过去,旧库留作备份。换电脑时,把那个文件夹拷到新电脑 dsh 主目录下的 .engramory-memory,想放别处再在新电脑上搬一次。',
|
|
192
|
+
howToSocial: '想让别人也能跟你的 AI 聊(接了 QQ、微信等)?给那个机器人另用一个 dsh 主目录(设 DSH_HOME),或者它在的 profile 里不装这个插件:同一个主目录下的 profile 共用记忆库,这里的每个对话都能用你的记忆。',
|
|
193
|
+
feedbackLead: '遇到问题或有建议:',
|
|
194
|
+
feedbackIssue: '到 GitHub 提 issue',
|
|
195
|
+
feedbackMail: ',或发邮件到',
|
|
196
|
+
copy: '复制',
|
|
197
|
+
copied: '已复制',
|
|
198
|
+
copyFailed: '复制不了,请手动选中上面的地址。',
|
|
199
|
+
feedbackNote: '邮件会由 AI 助手协助整理,issue 是公开的,两处都别把记忆内容原样贴上去。',
|
|
200
|
+
versionLine: '插件版本 {version}',
|
|
201
|
+
checkUpdate: '检查更新',
|
|
202
|
+
checking: '正在检查…',
|
|
203
|
+
updateNewer: '有新版本 {latest}(你装的是 {current})',
|
|
204
|
+
updateNotes: '看这一版改了什么',
|
|
205
|
+
updateHow: '升级时要写上版本号(只写名字的话,pnpm 默认不装发布不满 24 小时的版本):',
|
|
206
|
+
updateDesktop: '桌面版:dsh 0.2.2 起在「插件」页点「Engramory 记忆」的「更新」;更早的版本先卸载它,再搜索安装',
|
|
207
|
+
updateCli: '命令行:',
|
|
208
|
+
updateProfile: '<名字>',
|
|
209
|
+
updateAfter: '装完重启 dsh(桌面版从托盘退出再打开)。记忆和设置都会保留。',
|
|
210
|
+
updateCurrent: '已是最新版本:{source} 上最新的就是 {latest}。',
|
|
211
|
+
updateAhead: '你装的 {current} 比 {source} 上最新的 {latest} 还新。',
|
|
212
|
+
updateMirror: 'npm 没有给出版本号,这是镜像 npmmirror 的结果,它有时比 npm 晚几分钟同步。',
|
|
213
|
+
updateFailed: '查不到最新版本:npm 和 npmmirror 都没有给出版本号。可以到网页上看:',
|
|
214
|
+
updateNpm: 'npm 上的版本列表',
|
|
215
|
+
copySpecFailed: '复制不了,请手动选中上面的版本号。',
|
|
216
|
+
updateNote: '检查更新会向 npm(连不上再试 npmmirror)查最新版本号,请求里不带任何记忆内容;不点就不联网。',
|
|
217
|
+
issueBody: '(写下遇到的问题或建议)\n\n---\ndsh-engramory {version}\n打开这个页面的电脑:{os}\ndsh 版本:',
|
|
218
|
+
statNote: '条记忆',
|
|
219
|
+
statNotes: '条记忆',
|
|
220
|
+
statStore: '个记忆库',
|
|
221
|
+
statStores: '个记忆库',
|
|
222
|
+
statArchive: '份归档',
|
|
223
|
+
statsReadAt: '读取于 {time},约定的天数按这时算',
|
|
224
|
+
statsPartial: '列表太长,只列出了一部分,这些数字偏少。',
|
|
225
|
+
statsUnreadable: '有 {count} 处可能存放记忆库的位置没读到(读不了或查不了),没算在内。',
|
|
226
|
+
statsIncomplete: '有的库里有文件读不了,这些数字可能偏少。',
|
|
227
|
+
typeAll: '全部',
|
|
228
|
+
typeLabel: '按类型筛选',
|
|
229
|
+
storeCount: '{count} 条',
|
|
230
|
+
storeCountOne: '{count} 条',
|
|
231
|
+
noteMeta: '{type} · {size}',
|
|
232
|
+
noteUnread: '读不了',
|
|
233
|
+
archived: '已归档',
|
|
234
|
+
monthDay: '{m}月{d}日',
|
|
235
|
+
yearMonthDay: '{y}年{m}月{d}日',
|
|
236
|
+
badgePast: '{date} · 日期已过,待确认',
|
|
237
|
+
badgeToday: '就是今天',
|
|
238
|
+
badgeTomorrow: '{date} · 明天',
|
|
239
|
+
badgeSoon: '{date} · 还有 {days} 天',
|
|
240
|
+
badgeUndated: '未定日期',
|
|
241
|
+
badgeLarge: '偏大,建议拆分',
|
|
242
|
+
badgeUnindexed: '不在索引里',
|
|
243
|
+
attnTitle: '可以整理一下',
|
|
244
|
+
attnLarge: '超过 12 KB 的笔记 {count} 篇:一条笔记该只记一件事,可以让 AI 拆成几篇。',
|
|
245
|
+
filterLabel: '筛选笔记',
|
|
246
|
+
filterPlaceholder: '按名字筛选',
|
|
247
|
+
filterCount: '匹配 {count} 条(只在已列出的笔记里找)',
|
|
248
|
+
filterNone: '这个库里没有匹配的笔记。',
|
|
249
|
+
tidyCopy: '复制整理指令',
|
|
250
|
+
tidyCopied: '已复制,粘贴进对话发给 AI',
|
|
251
|
+
tidyFailed: '复制不了,请手动选中下面的指令:',
|
|
252
|
+
tidyPrompt: '请按 Engramory 的记忆规则整理这个记忆库:{dir}\n- 索引里指向不存在文件的链接:找得到对应笔记的就改对,确实没有了的只删这个链接;一行里没有别的有效链接了,才删掉整行。\n- 不在索引里的笔记:以后回忆用得上的补进索引,过时的移进 archive/ 或删掉;不要为了补齐全部加进去。\n- 没写类型的笔记补上 type。\n- 索引超出上限就先压缩:合并重复,细节挪回笔记,索引只留指针。\n- 超过约 12 KB 的笔记,按规则拆成几篇。\n- 日期已过的约定别删,问到结果再改写成经历。\n改完再看一遍索引有没有超出上限,然后告诉我改了什么。',
|
|
253
|
+
}
|
|
254
|
+
const en = {
|
|
255
|
+
summary: 'Companion mode and memory access, and the index cap.',
|
|
256
|
+
loading: 'Reading the settings…',
|
|
257
|
+
loadFailed: 'Could not read the settings.',
|
|
258
|
+
retry: 'Retry',
|
|
259
|
+
unavailable: 'This dsh cannot save these settings from a page (it has no config editor). Edit cordis.patch.yml instead; the plugin README shows how.',
|
|
260
|
+
expression: 'A setting in the config is written as a !!js expression, whose value this page cannot show, so it is read-only. Edit cordis.patch.yml directly.',
|
|
261
|
+
companion: 'Companion mode (大肥鱼模式)',
|
|
262
|
+
companionHint: 'Keeps three more kinds of note — moments, plans, the character itself — and recalls in character.',
|
|
263
|
+
closedSocial: 'Social mode was removed in 2.0. This profile is still set to it, so Engramory gives no conversation any memory now. Run a bot others talk to (through QQ, WeChat and the like) under a dsh home of its own (the profiles of one home share the store); save the settings here once and the memory is back.',
|
|
264
|
+
reopen: 'Restore memory',
|
|
265
|
+
cap: 'Index cap',
|
|
266
|
+
capHint: 'Default 200 lines / 25600 bytes; past it the AI must compact before writing more.',
|
|
267
|
+
capLines: 'lines',
|
|
268
|
+
capBytes: 'bytes',
|
|
269
|
+
save: 'Save',
|
|
270
|
+
saving: 'Saving…',
|
|
271
|
+
discard: 'Discard changes',
|
|
272
|
+
reloading: 'Saved; the plugin is reloading with the new settings…',
|
|
273
|
+
saved: 'Saved.',
|
|
274
|
+
savedUnconfirmed: 'Saved, but the settings read back differ from what you entered (or the plugin has not finished loading). Reload the page to check.',
|
|
275
|
+
stale: 'The settings changed elsewhere and were read again. Make your change once more.',
|
|
276
|
+
overridden: 'A higher configuration layer overrides these values, so they cannot be saved here.',
|
|
277
|
+
invalid: 'One field is not acceptable: ',
|
|
278
|
+
failed: 'Saving failed: ',
|
|
279
|
+
place: 'Where the memory is',
|
|
280
|
+
placeNow: 'Now in',
|
|
281
|
+
placeIsDefault: ' (the default place)',
|
|
282
|
+
placeLoadFailed: 'Could not read where the memory is.',
|
|
283
|
+
placeLoading: 'Reading where the memory is…',
|
|
284
|
+
placeChange: 'Change location',
|
|
285
|
+
globalAbsent: 'No global memory yet: the global store is made the first time the AI saves to it.',
|
|
286
|
+
placeHide: 'Close',
|
|
287
|
+
placeChoose: 'Choose folder…',
|
|
288
|
+
placeChoosing: 'Choose in the window that opened…',
|
|
289
|
+
placeChosenInside: 'That folder holds something already: a {name} folder is made inside it for the memory.',
|
|
290
|
+
placeChooseFailed: 'The folder chooser did not open: {reason}',
|
|
291
|
+
placeInput: 'New place',
|
|
292
|
+
placePlaceholder: 'New place: an empty folder, or one not there yet, such as D:\\Sync\\AI memory',
|
|
293
|
+
placeMove: 'Move it there',
|
|
294
|
+
placeBack: 'Move it back to the default place',
|
|
295
|
+
placeHint: 'The whole store, archive and all, is copied to the new place, each file checked, and then used from there; the old store is renamed and kept beside where it was as a backup (.backup- and the date added to its name), for you to delete once the new place looks right. 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; what another dsh window open meanwhile writes in those seconds stays in the backup only, so close the others first. 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.',
|
|
296
|
+
placeMoving: 'Moving…',
|
|
297
|
+
placeMoved: 'Moved.',
|
|
298
|
+
placeMovedBackup: 'Moved. The old store is kept as a backup: {backup}. Delete it once the new place looks right.',
|
|
299
|
+
placeMovedKept: 'Moved. A file in the old store was held open, so it could not be renamed: it stays at {backup} as the backup. Delete it once the new place looks right; the AI no longer writes there.',
|
|
300
|
+
placeSame: 'The memory is there already.',
|
|
301
|
+
placeMoveFailed: 'Not moved: {reason}',
|
|
302
|
+
placeCopyLeft: 'A copy was left at the new place, {left}: delete it if you do not need it.',
|
|
303
|
+
placePinned: 'An index is pinned (indexPath): the memory is in its folder, and is not moved here.',
|
|
304
|
+
placeRemote: 'dsh\'s home folder is on a network place: the memory is not moved here.',
|
|
305
|
+
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.',
|
|
306
|
+
placeCustomSkill: 'You use memory rules of your own (skill): change the place they name once it has moved.',
|
|
307
|
+
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.',
|
|
308
|
+
whyRelative: 'Give the whole path (on Windows, with its drive).',
|
|
309
|
+
whyNetwork: 'It cannot be on a network path.',
|
|
310
|
+
whyRoot: 'It cannot be a whole drive.',
|
|
311
|
+
whyDeep: 'The path is too deep.',
|
|
312
|
+
whyInvalid: 'The path holds a name or a character Windows does not take.',
|
|
313
|
+
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.',
|
|
314
|
+
whyNested: 'The new place cannot be inside the store, nor hold it.',
|
|
315
|
+
whyNotEmpty: 'There is something in that folder already: choose an empty folder, or one not there yet.',
|
|
316
|
+
whyNotDir: 'That is a file, not a folder.',
|
|
317
|
+
whyLink: 'The new place or the store holds a folder link: the plugin does not move it for you. Sort it out by hand.',
|
|
318
|
+
whyUnreadable: 'That place cannot be read.',
|
|
319
|
+
whyUnavailable: 'The store cannot be found where it is now: its drive may not be connected.',
|
|
320
|
+
whyBusy: 'A move is under way: wait until it is done.',
|
|
321
|
+
whyProblem: 'The record of where the memory is has a problem: fix it first.',
|
|
322
|
+
whyTooMany: 'There are too many files.',
|
|
323
|
+
whyTooBig: 'It is too big (over 256 MB).',
|
|
324
|
+
whyTooDeep: 'Its folders go too deep.',
|
|
325
|
+
whySpecial: 'The store holds something that is not a plain file.',
|
|
326
|
+
whyChanged: 'The store was moved elsewhere while this move ran.',
|
|
327
|
+
whyFailed: 'A file operation failed.',
|
|
328
|
+
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.',
|
|
329
|
+
panel: 'Memory',
|
|
330
|
+
panelTitle: 'Engramory memory',
|
|
331
|
+
refresh: 'Refresh',
|
|
332
|
+
stripNote: 'Explanations and the index cap: Plugins → Engramory memory.',
|
|
333
|
+
stripReadOnly: 'Cannot be changed here; see Plugins → Engramory memory.',
|
|
334
|
+
listing: 'Reading the memory…',
|
|
335
|
+
listFailed: 'Could not read the memory stores.',
|
|
336
|
+
listTimeout: 'Reading took too long — a workspace may be on a network drive that does not answer. Refresh to try again.',
|
|
337
|
+
empty: 'No memory yet. The store is created the first time the AI saves something.',
|
|
338
|
+
pinnedRelative: 'The pinned index (indexPath) is a relative path, which follows each conversation\'s directory, so it cannot be listed here. Pin an absolute path to see it here.',
|
|
339
|
+
storeUser: 'Global memory',
|
|
340
|
+
storePinned: 'Pinned store',
|
|
341
|
+
usage: 'Index {lines} / {maxLines} lines · {size} / {maxSize}',
|
|
342
|
+
usageOver: 'Index {size} / {maxSize}, over the cap',
|
|
343
|
+
usageSize: 'Index {size} / {maxSize}',
|
|
344
|
+
sizeBytes: '{n} B',
|
|
345
|
+
sizeKB: '{n} KB',
|
|
346
|
+
overHint: 'Over the cap: the AI reads only the first part. Time to compact it.',
|
|
347
|
+
noIndex: 'No index yet',
|
|
348
|
+
openFolder: 'Open the folder',
|
|
349
|
+
opened: 'Opened {name}.',
|
|
350
|
+
revealed: 'Showed {name} in its folder.',
|
|
351
|
+
openUnavailable: 'This dsh cannot open files on its own computer (when reached remotely, say). The files are where the path above says.',
|
|
352
|
+
openMissing: 'That file is gone — renamed or deleted just now, perhaps. Refresh to see.',
|
|
353
|
+
openBusy: 'Still opening the previous one — click again in a moment.',
|
|
354
|
+
openFailed: 'Could not open it: {reason}',
|
|
355
|
+
typeUser: 'User',
|
|
356
|
+
typeFeedback: 'Feedback',
|
|
357
|
+
typeProject: 'Project',
|
|
358
|
+
typeReference: 'Reference',
|
|
359
|
+
typeMoment: 'Moments',
|
|
360
|
+
typeUpcoming: 'Coming up',
|
|
361
|
+
typeSelf: 'Myself',
|
|
362
|
+
typeOther: 'Other',
|
|
363
|
+
archive: 'Archive ({count})',
|
|
364
|
+
more: 'Too many files: only some are listed here.',
|
|
365
|
+
healthOk: 'Check-up: nothing to fix.',
|
|
366
|
+
healthBroken: 'The index points to files that are not there ({count})',
|
|
367
|
+
healthBrokenMore: 'The index points to files that are not there (over {count})',
|
|
368
|
+
healthBrokenUnlisted: 'The index points to files that are not there: too many to list here.',
|
|
369
|
+
healthUnindexed: 'Not in the index ({count}): recall starts from the index, so the AI will not find these unless another note links to them.',
|
|
370
|
+
healthUntyped: 'No type, or one it does not know ({count}), listed under Other.',
|
|
371
|
+
healthFix: 'For a full check, run engramory_doctor.py.',
|
|
372
|
+
healthLarge: 'Too much to check here, so no check-up.',
|
|
373
|
+
healthUnreadable: 'Some files could not be read, so no check-up.',
|
|
374
|
+
healthPartial: 'Too many files to list them all, so no check-up here.',
|
|
375
|
+
howTo: 'How to use it',
|
|
376
|
+
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.',
|
|
377
|
+
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.',
|
|
378
|
+
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 …".',
|
|
379
|
+
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: the plugin copies it all there and keeps the old store as a backup. 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.',
|
|
380
|
+
howToSocial: 'Want others to talk to your AI too (through QQ, WeChat and the like)? Run that bot under a dsh home of its own (DSH_HOME), or without this plugin in its profile: the profiles of one home share the store, and every conversation here gets your memory.',
|
|
381
|
+
feedbackLead: 'Found a problem or have an idea? ',
|
|
382
|
+
feedbackIssue: 'Open an issue on GitHub',
|
|
383
|
+
feedbackMail: ', or email ',
|
|
384
|
+
copy: 'Copy',
|
|
385
|
+
copied: 'Copied',
|
|
386
|
+
copyFailed: 'Could not copy; select the address above by hand.',
|
|
387
|
+
feedbackNote: 'Emails are sorted with the help of an AI assistant, and issues are public: do not paste your memory notes into either.',
|
|
388
|
+
versionLine: 'Plugin version {version}',
|
|
389
|
+
checkUpdate: 'Check for updates',
|
|
390
|
+
checking: 'Checking…',
|
|
391
|
+
updateNewer: 'Version {latest} is out (you have {current})',
|
|
392
|
+
updateNotes: 'What changed',
|
|
393
|
+
updateHow: 'Name the version when you upgrade: by name alone, pnpm by default does not install a version published less than 24 hours ago.',
|
|
394
|
+
updateDesktop: 'Desktop app: from dsh 0.2.2, Update on Engramory memory in the Plugins page; before that, uninstall it, then search for and install',
|
|
395
|
+
updateCli: 'Command line: ',
|
|
396
|
+
updateProfile: '<name>',
|
|
397
|
+
updateAfter: 'Then restart dsh (in the desktop app, quit from the tray and open it again). Your memory and settings stay.',
|
|
398
|
+
updateCurrent: 'You have the latest version: the latest on {source} is {latest}.',
|
|
399
|
+
updateAhead: 'The {current} you have is newer than the latest on {source}, {latest}.',
|
|
400
|
+
updateMirror: 'npm gave no version, so this is from its mirror npmmirror, which can be a few minutes behind npm.',
|
|
401
|
+
updateFailed: 'Could not find the latest version: neither npm nor npmmirror gave one. The versions are listed on npm\'s site: ',
|
|
402
|
+
updateNpm: 'dsh-engramory on npm',
|
|
403
|
+
copySpecFailed: 'Could not copy; select the version above by hand.',
|
|
404
|
+
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.',
|
|
405
|
+
issueBody: '(What happened, or your idea)\n\n---\ndsh-engramory {version}\nComputer this page was opened on: {os}\ndsh version: ',
|
|
406
|
+
statNote: 'note',
|
|
407
|
+
statNotes: 'notes',
|
|
408
|
+
statStore: 'store',
|
|
409
|
+
statStores: 'stores',
|
|
410
|
+
statArchive: 'archived',
|
|
411
|
+
statsReadAt: 'Read at {time}; days to a plan count from then',
|
|
412
|
+
statsPartial: 'The listing was too long to finish, so these numbers fall short.',
|
|
413
|
+
statsUnreadable: '{count} places that may hold a memory store could not be read and are not counted.',
|
|
414
|
+
statsIncomplete: 'Some files in a store could not be read, so these numbers may fall short.',
|
|
415
|
+
typeAll: 'All',
|
|
416
|
+
typeLabel: 'Filter by type',
|
|
417
|
+
storeCount: '{count} notes',
|
|
418
|
+
storeCountOne: '{count} note',
|
|
419
|
+
noteMeta: '{type} · {size}',
|
|
420
|
+
noteUnread: 'Could not be read',
|
|
421
|
+
archived: 'Archived',
|
|
422
|
+
monthDay: '{m}/{d}',
|
|
423
|
+
yearMonthDay: '{y}/{m}/{d}',
|
|
424
|
+
badgePast: '{date} · passed, outcome to confirm',
|
|
425
|
+
badgeToday: 'Today',
|
|
426
|
+
badgeTomorrow: '{date} · tomorrow',
|
|
427
|
+
badgeSoon: '{date} · in {days} days',
|
|
428
|
+
badgeUndated: 'No date yet',
|
|
429
|
+
badgeLarge: 'Large: worth splitting',
|
|
430
|
+
badgeUnindexed: 'Not in the index',
|
|
431
|
+
attnTitle: 'Worth tidying up',
|
|
432
|
+
attnLarge: 'Notes past 12 KB: {count}. A note should hold one fact, and the AI can split these.',
|
|
433
|
+
filterLabel: 'Filter notes',
|
|
434
|
+
filterPlaceholder: 'Filter by name',
|
|
435
|
+
filterCount: '{count} matching (among the notes listed)',
|
|
436
|
+
filterNone: 'No matching notes in this store.',
|
|
437
|
+
tidyCopy: 'Copy tidy-up instructions',
|
|
438
|
+
tidyCopied: 'Copied; paste it into a conversation',
|
|
439
|
+
tidyFailed: 'Could not copy; select the instructions below by hand:',
|
|
440
|
+
tidyPrompt: 'Tidy up this memory store by the Engramory rules: {dir}\n- Links in the index to files that are not there: fix the ones whose note you can find; where there is none, remove that link alone, and the line only when it has no other live link left.\n- Notes the index does not name: add the ones recall will need, move the outdated ones into archive/ or delete them; do not add them all just to be complete.\n- Notes with no type: give them one.\n- An index over its cap: compact it first by merging duplicates and moving detail back into the notes, so the index holds pointers only.\n- Notes past about 12 KB: split them as the rules say.\n- Plans whose date has passed: do not delete them; rewrite them as what happened once you learn the outcome.\nThen check the index is within its cap, and tell me what you changed.',
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
const CSS = `
|
|
444
|
+
.eng-page{display:flex;flex-direction:column;gap:18px;font-size:13px;line-height:1.55;color:var(--dsw-alias-label-primary);max-width:760px;}
|
|
445
|
+
.eng-section{display:flex;flex-direction:column;gap:8px;}
|
|
446
|
+
.eng-title{font-size:14px;font-weight:600;margin:0;}
|
|
447
|
+
.eng-heading{display:flex;align-items:center;gap:10px;}
|
|
448
|
+
.eng-hint{margin:0;font-size:12px;color:var(--dsw-alias-label-secondary);}
|
|
449
|
+
.eng-note{margin:0;font-size:12px;color:var(--dsw-alias-label-tertiary);}
|
|
450
|
+
.eng-banner{padding:8px 12px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-1);font-size:12px;}
|
|
451
|
+
.eng-banner[data-tone="error"]{color:var(--dsw-alias-state-error-primary);}
|
|
452
|
+
.eng-banner[data-tone="ok"]{color:var(--dsw-alias-state-success-primary);}
|
|
453
|
+
.eng-switch{position:relative;width:32px;height:18px;border-radius:999px;border:0;padding:0;cursor:pointer;background:var(--dsw-alias-border-l2);flex:none;}
|
|
454
|
+
.eng-switch[aria-checked="true"]{background:var(--dsw-alias-brand-primary);}
|
|
455
|
+
.eng-switch:disabled{opacity:.5;cursor:default;}
|
|
456
|
+
.eng-switch::after{content:"";position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:var(--dsw-alias-switch-thumb,#fff);transition:transform .15s ease;}
|
|
457
|
+
.eng-switch[aria-checked="true"]::after{transform:translateX(14px);}
|
|
458
|
+
.eng-input{border:1px solid var(--dsw-alias-border-l1);border-radius:8px;background:var(--dsw-alias-bg-layer-1);color:inherit;padding:5px 9px;font:inherit;font-size:12px;outline:none;min-width:0;}
|
|
459
|
+
.eng-input:focus{border-color:var(--dsw-alias-brand-primary);}
|
|
460
|
+
.eng-input[aria-invalid="true"]{border-color:var(--dsw-alias-state-error-primary);}
|
|
461
|
+
.eng-cap{display:flex;gap:12px;align-items:center;flex-wrap:wrap;}
|
|
462
|
+
.eng-cap label{display:flex;align-items:center;gap:6px;color:var(--dsw-alias-label-secondary);font-size:12px;}
|
|
463
|
+
.eng-cap input{width:110px;}
|
|
464
|
+
.eng-empty{display:flex;align-items:center;gap:8px;flex-wrap:wrap;}
|
|
465
|
+
.eng-place{display:flex;flex-direction:column;gap:8px;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:14px;}
|
|
466
|
+
.eng-place-now{margin:0;font-size:12px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;}
|
|
467
|
+
.eng-place-now code{font-family:var(--ds-font-family-code,ui-monospace,monospace);color:var(--dsw-alias-label-primary);}
|
|
468
|
+
.eng-place-row{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
|
|
469
|
+
.eng-place-row .eng-input{flex:1 1 260px;}
|
|
470
|
+
.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;}
|
|
471
|
+
.eng-btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);}
|
|
472
|
+
.eng-btn:disabled{opacity:.5;cursor:default;}
|
|
473
|
+
.eng-btn-primary{background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-brand-primary));border-color:transparent;color:var(--dsw-alias-label-primary-foreground,#fff);}
|
|
474
|
+
.eng-btn-primary:hover:not(:disabled){background:var(--dsw-alias-button-primary-fill,var(--dsw-alias-brand-primary));opacity:.9;}
|
|
475
|
+
.eng-btn-ghost{border-color:transparent;background:transparent;color:var(--dsw-alias-label-secondary);padding:4px 8px;}
|
|
476
|
+
.eng-btn-small{padding:1px 8px;font-size:11.5px;}
|
|
477
|
+
.eng-actions{display:flex;gap:8px;align-items:center;flex-wrap:wrap;}
|
|
478
|
+
.eng-memory{box-sizing:border-box;height:100%;overflow:auto;display:flex;flex-direction:column;align-items:center;gap:20px;padding:28px clamp(24px,4vw,48px) 48px;color:var(--dsw-alias-label-primary);font-size:13px;line-height:20px;}
|
|
479
|
+
[data-platform=darwin] .eng-memory{padding-top:calc(28px + var(--dsh-frame-top-clearance,0px));}
|
|
480
|
+
.eng-memory>*{box-sizing:border-box;width:100%;max-width:960px;flex:none;}
|
|
481
|
+
.eng-memory svg{display:block;flex:none;}
|
|
482
|
+
.eng-hero{display:flex;justify-content:space-between;align-items:flex-start;flex-wrap:wrap;gap:24px 40px;padding:30px 32px;border-radius:24px;color:#e8f3f0;background:radial-gradient(120% 140% at 100% 0%,#1f4a5a 0%,rgba(31,74,90,0) 55%),linear-gradient(135deg,#0f1b2d 0%,#14263f 100%);box-shadow:0 12px 32px rgba(15,27,45,.18);}
|
|
483
|
+
.eng-hero-main{display:flex;flex-direction:column;gap:24px;flex:1 1 340px;min-width:0;}
|
|
484
|
+
.eng-brand{display:flex;align-items:center;gap:14px;}
|
|
485
|
+
.eng-logo{border-radius:12px;box-shadow:0 0 0 1px rgba(110,231,200,.35);}
|
|
486
|
+
.eng-hero-title{margin:0;font-size:21px;font-weight:600;line-height:28px;letter-spacing:.01em;}
|
|
487
|
+
.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);}
|
|
488
|
+
.eng-stats{display:flex;align-items:baseline;flex-wrap:wrap;gap:6px 0;}
|
|
489
|
+
.eng-stat{display:inline-flex;align-items:baseline;gap:6px;}
|
|
490
|
+
.eng-stat+.eng-stat{margin-left:18px;padding-left:18px;border-left:1px solid rgba(232,243,240,.18);}
|
|
491
|
+
.eng-stat b{font-size:40px;line-height:44px;font-weight:600;color:#6ee7c8;font-variant-numeric:tabular-nums;letter-spacing:-.02em;}
|
|
492
|
+
.eng-stat span{font-size:13px;color:rgba(232,243,240,.75);}
|
|
493
|
+
.eng-hero-foot{display:flex;align-items:center;flex-wrap:wrap;gap:8px 10px;}
|
|
494
|
+
.eng-hero-read{display:inline-flex;align-items:center;gap:6px;margin:0;padding:3px 10px;border-radius:999px;background:rgba(255,255,255,.06);font-size:12px;line-height:18px;color:rgba(232,243,240,.62);}
|
|
495
|
+
.eng-hero-side{display:flex;flex-direction:column;flex:0 1 300px;min-width:260px;}
|
|
496
|
+
.eng-hero .eng-strip{display:flex;flex-direction:column;gap:14px;padding:18px 20px;border-radius:18px;background:rgba(255,255,255,.06);box-shadow:inset 0 0 0 1px rgba(255,255,255,.08);}
|
|
497
|
+
.eng-hero .eng-strip-item{display:flex;align-items:center;justify-content:space-between;gap:20px;min-height:30px;font-size:13px;color:rgba(232,243,240,.8);}
|
|
498
|
+
.eng-hero .eng-strip-item:first-child{font-weight:600;color:#e8f3f0;}
|
|
499
|
+
.eng-hero .eng-strip-note{margin:0;font-size:11.5px;line-height:17px;color:rgba(232,243,240,.74);}
|
|
500
|
+
.eng-hero .eng-switch{width:46px;height:26px;background:rgba(255,255,255,.24);}
|
|
501
|
+
.eng-hero .eng-switch::after{top:3px;left:3px;width:20px;height:20px;}
|
|
502
|
+
.eng-hero .eng-switch[aria-checked="true"]::after{transform:translateX(20px);}
|
|
503
|
+
.eng-hero .eng-switch[aria-checked="true"]{background:#6ee7c8;}
|
|
504
|
+
.eng-hero .eng-switch[aria-checked="true"]::after{background:#0f1b2d;}
|
|
505
|
+
.eng-hero .eng-btn,.eng-hero-btn{display:inline-flex;align-items:center;gap:6px;height:30px;padding:0 12px;border:1px solid rgba(232,243,240,.22);border-radius:999px;background:transparent;color:#e8f3f0;font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;}
|
|
506
|
+
.eng-hero .eng-btn:hover:not(:disabled),.eng-hero-btn:hover{background:rgba(255,255,255,.08);}
|
|
507
|
+
.eng-hero :focus-visible{outline:2px solid #6ee7c8;outline-offset:2px;}
|
|
508
|
+
.eng-caveat{display:flex;align-items:flex-start;gap:8px;margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);}
|
|
509
|
+
.eng-caveat svg{margin-top:2px;color:var(--dsw-alias-state-warn-label);}
|
|
510
|
+
.eng-toolbar{display:flex;align-items:center;flex-wrap:wrap;gap:8px 12px;margin-top:6px;}
|
|
511
|
+
.eng-tabs{display:flex;flex-wrap:wrap;gap:2px;flex:1 1 auto;min-width:0;}
|
|
512
|
+
.eng-tab{display:inline-flex;align-items:center;gap:5px;height:30px;padding:0 10px;border:0;border-radius:9px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:13px;cursor:pointer;}
|
|
513
|
+
.eng-tab:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
514
|
+
.eng-tab[aria-pressed="true"]{background:var(--dsw-alias-interactive-bg-active);color:var(--dsw-alias-label-primary);font-weight:500;}
|
|
515
|
+
.eng-tab-count{font-size:11.5px;font-weight:400;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;}
|
|
516
|
+
.eng-search{position:relative;display:flex;align-items:center;flex:0 1 240px;min-width:160px;color:var(--dsw-alias-label-caption);}
|
|
517
|
+
.eng-search svg{position:absolute;left:10px;pointer-events:none;}
|
|
518
|
+
.eng-search .eng-input{width:100%;height:34px;padding-left:32px;border-radius:10px;font-size:13px;}
|
|
519
|
+
.eng-filter-count,.eng-filter-none{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);}
|
|
520
|
+
.eng-store{display:flex;flex-direction:column;gap:10px;margin-top:10px;}
|
|
521
|
+
.eng-store-head{display:flex;align-items:center;flex-wrap:wrap;gap:6px 10px;}
|
|
522
|
+
.eng-store-title{margin:0;font-size:15px;font-weight:600;line-height:22px;}
|
|
523
|
+
.eng-store-count{font-size:12px;color:var(--dsw-alias-label-tertiary);}
|
|
524
|
+
.eng-meter{display:inline-block;width:56px;height:4px;margin-left:4px;border-radius:999px;background:var(--dsw-alias-border-l2);overflow:hidden;}
|
|
525
|
+
.eng-meter-fill{display:block;height:100%;border-radius:999px;background:#2bb894;background:color-mix(in srgb,#2bb894 76%,var(--dsw-alias-label-primary));}
|
|
526
|
+
.eng-meter[data-over="true"] .eng-meter-fill{background:var(--dsw-alias-state-error-primary);}
|
|
527
|
+
.eng-usage{font-size:11.5px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums;}
|
|
528
|
+
.eng-usage[data-over="true"]{color:var(--dsw-alias-state-error-primary);}
|
|
529
|
+
.eng-store-actions{margin-left:auto;display:inline-flex;flex-wrap:wrap;gap:2px;}
|
|
530
|
+
.eng-path{margin:-8px 0 0;font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:11px;line-height:16px;color:var(--dsw-alias-label-tertiary);overflow-wrap:anywhere;}
|
|
531
|
+
.eng-store-ok{display:flex;align-items:center;gap:6px;margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary);}
|
|
532
|
+
.eng-store-ok svg{color:#2bb894;color:color-mix(in srgb,#2bb894 76%,var(--dsw-alias-label-primary));}
|
|
533
|
+
.eng-attn{display:flex;align-items:flex-start;gap:10px;padding:10px 10px 10px 14px;border-radius:14px;background:var(--dsw-alias-state-warn-tertiary);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 11%,transparent);}
|
|
534
|
+
.eng-attn>svg{margin-top:2px;color:var(--dsw-alias-state-warn-label);}
|
|
535
|
+
.eng-attn-body{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0;}
|
|
536
|
+
.eng-attn-title{margin:0;font-size:12.5px;font-weight:600;line-height:20px;color:var(--dsw-alias-state-warn-label);}
|
|
537
|
+
.eng-attn-item{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);}
|
|
538
|
+
.eng-broken{display:flex;flex-wrap:wrap;gap:4px;margin:4px 0 0;padding:0;list-style:none;}
|
|
539
|
+
.eng-broken code{padding:0 6px;border-radius:6px;background:var(--dsw-alias-interactive-bg-hover);font-family:var(--ds-font-family-code,ui-monospace,monospace);font-size:11px;line-height:18px;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere;}
|
|
540
|
+
.eng-attn>.eng-btn{flex:none;}
|
|
541
|
+
.eng-tidy{display:flex;flex-direction:column;gap:6px;}
|
|
542
|
+
.eng-tidy p{margin:0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);}
|
|
543
|
+
.eng-tidy textarea{box-sizing:border-box;width:100%;min-height:150px;resize:vertical;font:inherit;font-size:12px;line-height:18px;}
|
|
544
|
+
.eng-list{display:flex;flex-direction:column;padding:4px;border:.5px solid var(--dsw-alias-border-l3);border-radius:16px;}
|
|
545
|
+
.eng-rows{display:flex;flex-direction:column;margin:0;padding:0;list-style:none;}
|
|
546
|
+
.eng-row{box-sizing:border-box;display:flex;align-items:center;gap:12px;width:100%;min-height:52px;padding:6px 10px;border:0;border-radius:12px;background:transparent;color:inherit;font:inherit;text-align:left;}
|
|
547
|
+
button.eng-row{cursor:pointer;}
|
|
548
|
+
button.eng-row:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-hover);}
|
|
549
|
+
.eng-row[data-type="user"]{--eng-type:#6f86c6;}
|
|
550
|
+
.eng-row[data-type="feedback"]{--eng-type:#b39a45;}
|
|
551
|
+
.eng-row[data-type="project"]{--eng-type:#4e9a78;}
|
|
552
|
+
.eng-row[data-type="reference"]{--eng-type:#8b78c4;}
|
|
553
|
+
.eng-row[data-type="moment"]{--eng-type:#c07193;}
|
|
554
|
+
.eng-row[data-type="upcoming"]{--eng-type:#c9735c;}
|
|
555
|
+
.eng-row[data-type="self"]{--eng-type:#3f9aa6;}
|
|
556
|
+
.eng-mark{display:grid;place-items:center;width:32px;height:32px;flex:none;border-radius:10px;box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l4);color:var(--eng-type,var(--dsw-alias-label-tertiary));color:color-mix(in srgb,var(--eng-type,var(--dsw-alias-label-tertiary)) 80%,var(--dsw-alias-label-primary));}
|
|
557
|
+
.eng-row-text{display:flex;flex-direction:column;flex:1;min-width:0;}
|
|
558
|
+
.eng-name{font-size:13.5px;font-weight:500;line-height:19px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
559
|
+
.eng-row-meta{font-size:11.5px;line-height:16px;color:var(--dsw-alias-label-tertiary);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
|
|
560
|
+
.eng-badges{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:6px;max-width:55%;}
|
|
561
|
+
.eng-badge{padding:0 8px;border-radius:999px;background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-secondary);font-size:11.5px;line-height:20px;white-space:nowrap;}
|
|
562
|
+
.eng-badge[data-tone="warn"]{background:var(--dsw-alias-state-warn-tertiary);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary) 14%,transparent);color:var(--dsw-alias-state-warn-label);}
|
|
563
|
+
.eng-badge[data-tone="quiet"]{background:transparent;box-shadow:inset 0 0 0 .5px var(--dsw-alias-border-l3);color:var(--dsw-alias-label-tertiary);}
|
|
564
|
+
.eng-row-go{color:var(--dsw-alias-label-caption);}
|
|
565
|
+
.eng-archive{border-top:.5px dashed var(--dsw-alias-border-l2);margin-top:4px;padding-top:4px;}
|
|
566
|
+
.eng-list>.eng-archive:first-child{border-top:0;margin-top:0;padding-top:0;}
|
|
567
|
+
.eng-archive>summary{display:flex;align-items:center;gap:12px;min-height:44px;padding:4px 14px 4px 18px;border-radius:12px;cursor:pointer;font-size:12.5px;color:var(--dsw-alias-label-secondary);list-style:none;}
|
|
568
|
+
.eng-archive>summary::-webkit-details-marker{display:none;}
|
|
569
|
+
.eng-archive>summary::after,.eng-howto>summary::after{content:"";margin-left:auto;width:6px;height:6px;border-right:1.5px solid currentColor;border-bottom:1.5px solid currentColor;transform:rotate(-45deg);opacity:.55;}
|
|
570
|
+
.eng-archive[open]>summary::after,.eng-howto[open]>summary::after{transform:rotate(45deg);}
|
|
571
|
+
.eng-archive>summary:hover{background:var(--dsw-alias-interactive-bg-hover);}
|
|
572
|
+
.eng-howto{box-sizing:border-box;padding:12px 14px;border:.5px solid var(--dsw-alias-border-l3);border-radius:14px;}
|
|
573
|
+
.eng-howto>summary{display:flex;align-items:center;gap:8px;cursor:pointer;font-size:13px;font-weight:500;line-height:20px;list-style:none;}
|
|
574
|
+
.eng-howto>summary::-webkit-details-marker{display:none;}
|
|
575
|
+
.eng-howto ul{display:flex;flex-direction:column;gap:4px;margin:10px 0 2px;padding-left:18px;font-size:12px;line-height:18px;color:var(--dsw-alias-label-secondary);}
|
|
576
|
+
.eng-feedback{display:flex;flex-direction:column;gap:2px;padding-top:14px;border-top:.5px solid var(--dsw-alias-border-l2);font-size:12px;line-height:22px;color:var(--dsw-alias-label-secondary);}
|
|
577
|
+
.eng-feedback p{display:flex;align-items:center;flex-wrap:wrap;margin:0;}
|
|
578
|
+
.eng-feedback p svg{margin-right:6px;color:var(--dsw-alias-label-tertiary);}
|
|
579
|
+
.eng-link{color:var(--dsw-alias-brand-primary);text-decoration:underline;text-underline-offset:2px;}
|
|
580
|
+
.eng-link:hover{opacity:.8;}
|
|
581
|
+
.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);}
|
|
582
|
+
.eng-feedback-note{color:var(--dsw-alias-label-tertiary);}
|
|
583
|
+
.eng-version,.eng-update{display:flex;flex-direction:column;gap:2px;}
|
|
584
|
+
.eng-update{margin:2px 0 6px;}
|
|
585
|
+
.eng-version>p>.eng-btn{margin-left:8px;}
|
|
586
|
+
.eng-update-new{margin-right:8px;font-weight:500;color:var(--dsw-alias-label-primary);}
|
|
587
|
+
.eng-update ul{margin:0;padding-left:18px;}
|
|
588
|
+
.eng-update li{margin:0;}
|
|
589
|
+
.eng-update li .eng-btn{margin-left:6px;}
|
|
590
|
+
.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);}
|
|
591
|
+
.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;}
|
|
592
|
+
`
|
|
593
|
+
|
|
594
|
+
/** The settings the page edits, in the order the host computes its revision from. */
|
|
595
|
+
const settingsOf = (data) => ({
|
|
596
|
+
companion: data.companion === true,
|
|
597
|
+
maxLines: data.maxLines,
|
|
598
|
+
maxBytes: data.maxBytes,
|
|
599
|
+
})
|
|
600
|
+
const revisionOf = (settings) => JSON.stringify(settings)
|
|
601
|
+
const capOf = (text, max) => {
|
|
602
|
+
const value = Number(text)
|
|
603
|
+
return /^\s*\d+\s*$/.test(String(text)) && Number.isInteger(value) && value >= 1 && value <= max
|
|
604
|
+
? value
|
|
605
|
+
: undefined
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
/** fetch with a deadline: a request the host never answers must not hold the page busy. */
|
|
609
|
+
async function request(url, { timeout = 15000, signal, ...init } = {}) {
|
|
610
|
+
const deadline = new AbortController()
|
|
611
|
+
const timer = setTimeout(() => deadline.abort(), timeout)
|
|
612
|
+
// the caller's own end too (a section closed while dsh's chooser is open)
|
|
613
|
+
signal?.addEventListener('abort', () => deadline.abort(), { once: true })
|
|
614
|
+
try {
|
|
615
|
+
const response = await fetch(url, { cache: 'no-store', ...init, signal: deadline.signal,
|
|
616
|
+
headers: { accept: 'application/json', ...(init.headers ?? {}) } })
|
|
617
|
+
// the body is read under the same deadline: headers alone do not finish a request
|
|
618
|
+
const body = await response.json().catch(() => undefined)
|
|
619
|
+
return { ok: response.ok, status: response.status, body }
|
|
620
|
+
} finally {
|
|
621
|
+
clearTimeout(timer)
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
async function fetchSettings() {
|
|
626
|
+
const response = await request(SETTINGS_API)
|
|
627
|
+
if (!response.ok || response.body === undefined) throw new Error(`HTTP ${response.status}`)
|
|
628
|
+
return response.body
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/**
|
|
632
|
+
* The settings as the host has them, and a save that waits for the reloaded plugin to
|
|
633
|
+
* read them back. `onAdopt` hears every settings read, a save's included.
|
|
634
|
+
*/
|
|
635
|
+
function useSettings(t, onAdopt) {
|
|
636
|
+
const [state, setState] = useState({ phase: 'loading' })
|
|
637
|
+
const [busy, setBusy] = useState(false)
|
|
638
|
+
const [banner, setBanner] = useState(undefined)
|
|
639
|
+
const alive = useRef(true)
|
|
640
|
+
// a second click before the page re-renders as busy must not send a second save
|
|
641
|
+
const saving = useRef(false)
|
|
642
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
643
|
+
|
|
644
|
+
const adopt = useCallback((data) => {
|
|
645
|
+
const settings = settingsOf(data)
|
|
646
|
+
setState({ phase: 'ready', data, settings })
|
|
647
|
+
onAdopt?.(settings)
|
|
648
|
+
}, [onAdopt])
|
|
649
|
+
const load = useCallback(async () => {
|
|
650
|
+
setState((s) => (s.phase === 'ready' ? s : { phase: 'loading' }))
|
|
651
|
+
try {
|
|
652
|
+
const data = await fetchSettings()
|
|
653
|
+
if (alive.current) adopt(data)
|
|
654
|
+
} catch {
|
|
655
|
+
if (alive.current) setState({ phase: 'error' })
|
|
656
|
+
}
|
|
657
|
+
}, [adopt])
|
|
658
|
+
useEffect(() => { load() }, [load])
|
|
659
|
+
|
|
660
|
+
const save = async (next) => {
|
|
661
|
+
if (saving.current) return
|
|
662
|
+
saving.current = true
|
|
663
|
+
setBusy(true)
|
|
664
|
+
setBanner(undefined)
|
|
665
|
+
try {
|
|
666
|
+
let result
|
|
667
|
+
try {
|
|
668
|
+
const response = await request(SETTINGS_API, {
|
|
669
|
+
method: 'POST',
|
|
670
|
+
headers: { 'content-type': 'application/json' },
|
|
671
|
+
body: JSON.stringify({ revision: state.data.revision, ...next }),
|
|
672
|
+
})
|
|
673
|
+
result = response.body ?? { ok: false, error: 'failed', message: `HTTP ${response.status}` }
|
|
674
|
+
} catch (error) {
|
|
675
|
+
result = { ok: false, error: 'failed', message: String(error?.message ?? error) }
|
|
676
|
+
}
|
|
677
|
+
if (!alive.current) return
|
|
678
|
+
if (result.ok) {
|
|
679
|
+
// The plugin reloads with the new config; its route comes back with it.
|
|
680
|
+
setBanner({ tone: 'ok', text: t('reloading') })
|
|
681
|
+
const wanted = revisionOf(next)
|
|
682
|
+
let fresh
|
|
683
|
+
for (let i = 0; i < 20 && alive.current; i++) {
|
|
684
|
+
await new Promise((resolve) => setTimeout(resolve, 400))
|
|
685
|
+
try {
|
|
686
|
+
fresh = await fetchSettings()
|
|
687
|
+
// a save also takes social mode out (`closed`), with the settings shown unchanged
|
|
688
|
+
if (revisionOf(settingsOf(fresh)) === wanted && fresh.closed !== true) break
|
|
689
|
+
} catch { /* still reloading */ }
|
|
690
|
+
}
|
|
691
|
+
if (!alive.current) return
|
|
692
|
+
if (fresh !== undefined) adopt(fresh)
|
|
693
|
+
// The save landed either way; say so plainly when what came back differs.
|
|
694
|
+
setBanner(fresh !== undefined && revisionOf(settingsOf(fresh)) === wanted && fresh.closed !== true
|
|
695
|
+
? { tone: 'ok', text: t('saved') }
|
|
696
|
+
: { tone: 'error', text: t('savedUnconfirmed') })
|
|
697
|
+
} else if (result.error === 'stale') {
|
|
698
|
+
await load()
|
|
699
|
+
if (alive.current) setBanner({ tone: 'error', text: t('stale') })
|
|
700
|
+
} else if (result.error === 'expression') {
|
|
701
|
+
// the profile changed under the page: read it again, which makes the page read-only
|
|
702
|
+
await load()
|
|
703
|
+
if (alive.current) setBanner({ tone: 'error', text: t('expression') })
|
|
704
|
+
} else if (result.error === 'overridden') {
|
|
705
|
+
setBanner({ tone: 'error', text: t('overridden') })
|
|
706
|
+
} else if (result.error === 'invalid') {
|
|
707
|
+
setBanner({ tone: 'error', text: t('invalid') + (result.field ?? '') })
|
|
708
|
+
} else if (result.error === 'unavailable') {
|
|
709
|
+
setBanner({ tone: 'error', text: t('unavailable') })
|
|
710
|
+
} else {
|
|
711
|
+
setBanner({ tone: 'error', text: t('failed') + (result.message ?? '') })
|
|
712
|
+
}
|
|
713
|
+
} finally {
|
|
714
|
+
saving.current = false
|
|
715
|
+
if (alive.current) setBusy(false)
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
return { state, busy, banner, setBanner, load, save }
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
/** A host-styled switch: role=switch with aria-checked, as the host's own. */
|
|
722
|
+
function Switch({ checked, disabled, label, onChange }) {
|
|
723
|
+
return h('button', {
|
|
724
|
+
type: 'button', role: 'switch', className: 'eng-switch', 'aria-checked': checked,
|
|
725
|
+
'aria-label': label, disabled, onClick: () => onChange(!checked),
|
|
726
|
+
})
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
function CompanionSection({ draft, t, disabled, update }) {
|
|
730
|
+
return h('section', { className: 'eng-section' },
|
|
731
|
+
h('div', { className: 'eng-heading' },
|
|
732
|
+
h('h3', { className: 'eng-title' }, t('companion')),
|
|
733
|
+
h(Switch, { checked: draft.companion, disabled, label: t('companion'),
|
|
734
|
+
onChange: (on) => update({ companion: on }) })),
|
|
735
|
+
h('p', { className: 'eng-hint' }, t('companionHint')))
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function CapSection({ caps, t, disabled, setCaps }) {
|
|
739
|
+
const field = (key, label, max) => h('label', null,
|
|
740
|
+
h('input', { className: 'eng-input', inputMode: 'numeric', value: caps[key], disabled,
|
|
741
|
+
'aria-invalid': capOf(caps[key], max) === undefined,
|
|
742
|
+
onChange: (e) => setCaps({ ...caps, [key]: e.target.value }) }),
|
|
743
|
+
label)
|
|
744
|
+
return h('section', { className: 'eng-section' },
|
|
745
|
+
h('h3', { className: 'eng-title' }, t('cap')),
|
|
746
|
+
h('div', { className: 'eng-cap' },
|
|
747
|
+
field('maxLines', t('capLines'), Number.MAX_SAFE_INTEGER), field('maxBytes', t('capBytes'), Number.MAX_SAFE_INTEGER)),
|
|
748
|
+
h('p', { className: 'eng-hint' }, t('capHint')))
|
|
749
|
+
}
|
|
750
|
+
|
|
751
|
+
/** The whole form, with what each setting means: the package's page in the Plugins page. */
|
|
752
|
+
function SettingsForm({ t }) {
|
|
753
|
+
const [draft, setDraft] = useState(undefined)
|
|
754
|
+
const [caps, setCaps] = useState({ maxLines: String(DEFAULT_LINES), maxBytes: String(DEFAULT_BYTES) })
|
|
755
|
+
const onAdopt = useCallback((settings) => {
|
|
756
|
+
setDraft(settings)
|
|
757
|
+
setCaps({ maxLines: String(settings.maxLines), maxBytes: String(settings.maxBytes) })
|
|
758
|
+
}, [])
|
|
759
|
+
const { state, busy, banner, setBanner, load, save } = useSettings(t, onAdopt)
|
|
760
|
+
|
|
761
|
+
if (state.phase === 'loading' || draft === undefined && state.phase !== 'error') {
|
|
762
|
+
return h('p', { className: 'eng-note' }, t('loading'))
|
|
763
|
+
}
|
|
764
|
+
if (state.phase === 'error') {
|
|
765
|
+
return h('div', { className: 'eng-page' },
|
|
766
|
+
h('div', { className: 'eng-banner', 'data-tone': 'error' }, t('loadFailed')),
|
|
767
|
+
h('div', { className: 'eng-actions' }, h('button', { type: 'button', className: 'eng-btn', onClick: load }, t('retry'))))
|
|
768
|
+
}
|
|
769
|
+
|
|
770
|
+
const { data, settings } = state
|
|
771
|
+
const editable = data.editable === true
|
|
772
|
+
const disabled = !editable || busy
|
|
773
|
+
const maxLines = capOf(caps.maxLines, Number.MAX_SAFE_INTEGER)
|
|
774
|
+
const maxBytes = capOf(caps.maxBytes, Number.MAX_SAFE_INTEGER)
|
|
775
|
+
const next = { ...draft, maxLines: maxLines ?? draft.maxLines, maxBytes: maxBytes ?? draft.maxBytes }
|
|
776
|
+
const valid = maxLines !== undefined && maxBytes !== undefined
|
|
777
|
+
const dirty = revisionOf(next) !== revisionOf(settings)
|
|
778
|
+
const update = (patch) => { setDraft({ ...draft, ...patch }); setBanner(undefined) }
|
|
779
|
+
const discard = () => {
|
|
780
|
+
setDraft(settings)
|
|
781
|
+
setCaps({ maxLines: String(settings.maxLines), maxBytes: String(settings.maxBytes) })
|
|
782
|
+
setBanner(undefined)
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
return h('div', { className: 'eng-page' },
|
|
786
|
+
editable ? null : h('div', { className: 'eng-banner' },
|
|
787
|
+
t(data.readOnly === 'expression' ? 'expression' : 'unavailable')),
|
|
788
|
+
data.closed === true ? h('div', { className: 'eng-banner', 'data-tone': 'error' }, t('closedSocial')) : null,
|
|
789
|
+
h(CompanionSection, { draft, t, disabled, update }),
|
|
790
|
+
h(CapSection, { caps, t, disabled, setCaps }),
|
|
791
|
+
banner ? h('div', { className: 'eng-banner', 'data-tone': banner.tone, role: 'status' }, banner.text) : null,
|
|
792
|
+
editable ? h('div', { className: 'eng-actions' },
|
|
793
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-primary', disabled: busy || !(dirty || data.closed === true) || !valid, onClick: () => save(next) },
|
|
794
|
+
busy ? t('saving') : t('save')),
|
|
795
|
+
h('button', { type: 'button', className: 'eng-btn', disabled: busy || !dirty, onClick: discard }, t('discard')))
|
|
796
|
+
: null)
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
function SettingsPage(props) {
|
|
800
|
+
if (props.view === 'summary') return props.t('summary')
|
|
801
|
+
return h(SettingsForm, props)
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
/** "No memory yet", and where the store is to be made: it can be moved before there is any. */
|
|
805
|
+
function NoMemory({ t, onMoved, note = 'empty' }) {
|
|
806
|
+
const [placing, setPlacing] = useState(false)
|
|
807
|
+
return h('div', { className: 'eng-section' },
|
|
808
|
+
h('div', { className: 'eng-empty' },
|
|
809
|
+
h('p', { className: 'eng-note' }, t(note === 'global' ? 'globalAbsent' : 'empty')),
|
|
810
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-ghost', 'aria-expanded': placing,
|
|
811
|
+
onClick: () => setPlacing(!placing) }, icon('move', 14), t(placing ? 'placeHide' : 'placeChange'))),
|
|
812
|
+
placing ? h(PlaceSection, { t, onMoved, showNow: true }) : null)
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/** Why the store route turned a move down, or a move stopped (its codes, index.js). */
|
|
816
|
+
function whyNot(t, code, detail) {
|
|
817
|
+
const why = {
|
|
818
|
+
relative: () => t('whyRelative'), network: () => t('whyNetwork'), root: () => t('whyRoot'),
|
|
819
|
+
deep: () => t('whyDeep'), invalid: () => t('whyInvalid'), reserved: () => t('whyReserved'),
|
|
820
|
+
nested: () => t('whyNested'), notEmpty: () => t('whyNotEmpty'), notDir: () => t('whyNotDir'),
|
|
821
|
+
link: () => t('whyLink'), unreadable: () => t('whyUnreadable'), unavailable: () => t('whyUnavailable'),
|
|
822
|
+
busy: () => t('whyBusy'), problem: () => t('whyProblem'), pinned: () => t('placePinned'),
|
|
823
|
+
remote: () => t('placeRemote'), tooMany: () => t('whyTooMany'), tooBig: () => t('whyTooBig'),
|
|
824
|
+
tooDeep: () => t('whyTooDeep'), special: () => t('whySpecial'), changed: () => t('whyChanged'),
|
|
825
|
+
}[code]
|
|
826
|
+
return why === undefined ? `${t('whyFailed')}${typeof detail === 'string' ? ` (${detail})` : ''}` : why()
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
/**
|
|
830
|
+
* Moving the global store: on the memory page, opened from the global store's own actions
|
|
831
|
+
* (or beside "no memory yet"). The folder comes from dsh's own chooser where it opens on this
|
|
832
|
+
* desktop, or is typed; the plugin copies the store there, switches to it and keeps the old
|
|
833
|
+
* one as a backup, and answers once it is done; the listing is then read again (`onMoved`).
|
|
834
|
+
* `showNow`: say where the store is, where the page does not show it already.
|
|
835
|
+
*/
|
|
836
|
+
function PlaceSection({ t, onMoved, showNow = false }) {
|
|
837
|
+
const [state, setState] = useState({ phase: 'loading' })
|
|
838
|
+
const [text, setText] = useState('')
|
|
839
|
+
const [busy, setBusy] = useState(false)
|
|
840
|
+
const [choosing, setChoosing] = useState(false)
|
|
841
|
+
const [banner, setBanner] = useState(undefined)
|
|
842
|
+
const alive = useRef(true)
|
|
843
|
+
const moving = useRef(false)
|
|
844
|
+
const chooserRequest = useRef(undefined)
|
|
845
|
+
useEffect(() => () => {
|
|
846
|
+
alive.current = false
|
|
847
|
+
chooserRequest.current?.abort() // closed: the chooser it asked for closes with it
|
|
848
|
+
}, [])
|
|
849
|
+
// where the store is, as the plugin says now (undefined when that cannot be read)
|
|
850
|
+
const load = useCallback(async () => {
|
|
851
|
+
try {
|
|
852
|
+
const response = await request(STORE_API)
|
|
853
|
+
if (!response.ok || response.body === undefined) throw new Error(`HTTP ${response.status}`)
|
|
854
|
+
if (alive.current) setState({ phase: 'ready', data: response.body })
|
|
855
|
+
return response.body
|
|
856
|
+
} catch {
|
|
857
|
+
if (alive.current) setState((s) => (s.phase === 'ready' ? s : { phase: 'error' }))
|
|
858
|
+
return undefined
|
|
859
|
+
}
|
|
860
|
+
}, [])
|
|
861
|
+
useEffect(() => { load() }, [load])
|
|
862
|
+
|
|
863
|
+
const choose = async () => {
|
|
864
|
+
if (moving.current || choosing) return
|
|
865
|
+
setChoosing(true)
|
|
866
|
+
setBanner(undefined)
|
|
867
|
+
try {
|
|
868
|
+
let response
|
|
869
|
+
const ending = new AbortController()
|
|
870
|
+
chooserRequest.current = ending
|
|
871
|
+
try {
|
|
872
|
+
response = await request(PICK_API, { method: 'POST', headers: { 'content-type': 'application/json' },
|
|
873
|
+
body: '{}', timeout: PICK_WAIT_MS, signal: ending.signal })
|
|
874
|
+
} catch (error) {
|
|
875
|
+
response = { ok: false, body: { message: String(error?.message ?? error) } }
|
|
876
|
+
} finally {
|
|
877
|
+
if (chooserRequest.current === ending) chooserRequest.current = undefined
|
|
878
|
+
}
|
|
879
|
+
if (!alive.current) return
|
|
880
|
+
const body = response.body ?? {}
|
|
881
|
+
if (response.ok && body.cancelled === true) return
|
|
882
|
+
if (response.ok && typeof body.to === 'string') {
|
|
883
|
+
setText(body.to)
|
|
884
|
+
if (typeof body.inside === 'string') setBanner({ tone: 'ok', text: t('placeChosenInside', { name: body.inside }) })
|
|
885
|
+
return
|
|
886
|
+
}
|
|
887
|
+
setBanner({ tone: 'error', text: t('placeChooseFailed', { reason: body.message ?? body.error ?? `HTTP ${response.status}` }) })
|
|
888
|
+
} finally {
|
|
889
|
+
if (alive.current) setChoosing(false)
|
|
890
|
+
}
|
|
891
|
+
}
|
|
892
|
+
|
|
893
|
+
const move = async (to) => {
|
|
894
|
+
if (moving.current) return
|
|
895
|
+
const before = state.phase === 'ready' ? state.data.store : undefined
|
|
896
|
+
moving.current = true
|
|
897
|
+
setBusy(true)
|
|
898
|
+
setBanner(undefined)
|
|
899
|
+
try {
|
|
900
|
+
let response
|
|
901
|
+
try {
|
|
902
|
+
response = await request(STORE_API, {
|
|
903
|
+
method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ to }),
|
|
904
|
+
timeout: MOVE_WAIT_MS,
|
|
905
|
+
})
|
|
906
|
+
} catch (error) {
|
|
907
|
+
response = { ok: false, body: { error: 'failed', detail: String(error?.message ?? error) } }
|
|
908
|
+
}
|
|
909
|
+
if (!alive.current) return
|
|
910
|
+
const body = response.body ?? {}
|
|
911
|
+
if (response.ok && body.same === true) {
|
|
912
|
+
await load() // another dsh may have moved it there: the page shows where it is now
|
|
913
|
+
if (alive.current) setBanner({ tone: 'ok', text: t('placeSame') })
|
|
914
|
+
onMoved?.()
|
|
915
|
+
return
|
|
916
|
+
}
|
|
917
|
+
const now = await load() // where the store is now, moved or not
|
|
918
|
+
if (!alive.current) return
|
|
919
|
+
if (!response.ok || body.ok !== true) {
|
|
920
|
+
// the answer lost on its way back: where the store is now says it moved after all
|
|
921
|
+
if (typeof before === 'string' && typeof now?.store === 'string' && now.store !== before) {
|
|
922
|
+
setText('')
|
|
923
|
+
setBanner({ tone: 'ok', text: t('placeMoved') })
|
|
924
|
+
onMoved?.()
|
|
925
|
+
return
|
|
926
|
+
}
|
|
927
|
+
const left = typeof body.left === 'string' ? ` ${t('placeCopyLeft', { left: legible(body.left) })}` : ''
|
|
928
|
+
setBanner({ tone: 'error', text: t('placeMoveFailed', { reason: whyNot(t, body.reason ?? body.error, body.detail) }) + left })
|
|
929
|
+
return
|
|
930
|
+
}
|
|
931
|
+
setText('')
|
|
932
|
+
const backup = typeof body.backup === 'string' ? legible(body.backup) : undefined
|
|
933
|
+
setBanner({ tone: 'ok', text: backup === undefined ? t('placeMoved')
|
|
934
|
+
: t(body.kept === true ? 'placeMovedKept' : 'placeMovedBackup', { backup }) })
|
|
935
|
+
onMoved?.()
|
|
936
|
+
} finally {
|
|
937
|
+
moving.current = false
|
|
938
|
+
if (alive.current) setBusy(false)
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
if (state.phase === 'loading') return h('p', { className: 'eng-note' }, t('placeLoading'))
|
|
943
|
+
if (state.phase === 'error') {
|
|
944
|
+
return h('section', { className: 'eng-place', 'aria-label': t('place') },
|
|
945
|
+
h('p', { className: 'eng-note' }, t('placeLoadFailed')),
|
|
946
|
+
h('div', { className: 'eng-actions' }, h('button', { type: 'button', className: 'eng-btn', onClick: load }, t('retry'))))
|
|
947
|
+
}
|
|
948
|
+
const { data } = state
|
|
949
|
+
const atDefault = typeof data.store === 'string' && data.store === data.default
|
|
950
|
+
const blocked = data.pinned === true ? 'placePinned' : data.remote === true ? 'placeRemote' : undefined
|
|
951
|
+
return h('section', { className: 'eng-place', 'aria-label': t('place') },
|
|
952
|
+
showNow && typeof data.store === 'string' ? h('p', { className: 'eng-place-now' },
|
|
953
|
+
`${t('placeNow')} `, h('code', null, legible(data.store)), atDefault ? t('placeIsDefault') : '') : null,
|
|
954
|
+
data.problem !== undefined ? h('div', { className: 'eng-banner', 'data-tone': 'error' },
|
|
955
|
+
t('placeProblem', { file: legible(data.file ?? '') })) : null,
|
|
956
|
+
blocked !== undefined ? h('p', { className: 'eng-note' }, t(blocked)) : data.problem === undefined ? [
|
|
957
|
+
h('div', { className: 'eng-place-row', key: 'row' },
|
|
958
|
+
data.chooser === true ? h('button', { type: 'button', className: 'eng-btn', disabled: busy || choosing,
|
|
959
|
+
onClick: choose }, icon('folder', 14), t(choosing ? 'placeChoosing' : 'placeChoose')) : null,
|
|
960
|
+
h('input', { className: 'eng-input', value: text, disabled: busy, placeholder: t('placePlaceholder'),
|
|
961
|
+
'aria-label': t('placeInput'), spellCheck: false, onChange: (e) => { setText(e.target.value); setBanner(undefined) } }),
|
|
962
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-primary', disabled: busy || choosing || text.trim() === '',
|
|
963
|
+
onClick: () => move(text.trim()) }, busy ? t('placeMoving') : t('placeMove'))),
|
|
964
|
+
atDefault ? null : h('div', { className: 'eng-actions', key: 'back' },
|
|
965
|
+
h('button', { type: 'button', className: 'eng-btn', disabled: busy, onClick: () => move(null) }, t('placeBack'))),
|
|
966
|
+
h('p', { className: 'eng-hint', key: 'hint' }, t('placeHint')),
|
|
967
|
+
data.customSkill === true ? h('p', { className: 'eng-note', key: 'skill' }, t('placeCustomSkill')) : null,
|
|
968
|
+
data.legacyRules === true ? h('p', { className: 'eng-note', key: 'legacy' }, t('placeLegacy')) : null,
|
|
969
|
+
] : null,
|
|
970
|
+
banner ? h('div', { className: 'eng-banner', 'data-tone': banner.tone, role: 'status' }, banner.text) : null)
|
|
971
|
+
}
|
|
972
|
+
|
|
973
|
+
/**
|
|
974
|
+
* The two settings that matter most, atop the memory page, each saved as it is switched;
|
|
975
|
+
* what they mean, and the index cap, stay on the package's page.
|
|
976
|
+
*/
|
|
977
|
+
function SettingsStrip({ t }) {
|
|
978
|
+
const { state, busy, banner, load, save } = useSettings(t)
|
|
979
|
+
if (state.phase === 'error') {
|
|
980
|
+
return h('section', { className: 'eng-strip' },
|
|
981
|
+
h('p', { className: 'eng-strip-note' }, t('loadFailed')),
|
|
982
|
+
h('button', { type: 'button', className: 'eng-btn', onClick: load }, t('retry')))
|
|
983
|
+
}
|
|
984
|
+
if (state.phase !== 'ready') return null
|
|
985
|
+
const { data, settings } = state
|
|
986
|
+
const disabled = data.editable !== true || busy
|
|
987
|
+
const change = (patch) => save({ ...settings, ...patch })
|
|
988
|
+
return h('section', { className: 'eng-strip' },
|
|
989
|
+
h('div', { className: 'eng-strip-item' },
|
|
990
|
+
h('span', null, t('companion')),
|
|
991
|
+
h(Switch, { checked: settings.companion, disabled, label: t('companion'),
|
|
992
|
+
onChange: (on) => change({ companion: on }) })),
|
|
993
|
+
data.closed === true ? h('button', { type: 'button', className: 'eng-btn', disabled,
|
|
994
|
+
onClick: () => change({}) }, t('reopen')) : null,
|
|
995
|
+
h('p', { className: 'eng-strip-note', role: banner ? 'status' : undefined },
|
|
996
|
+
busy ? t('saving') : banner ? banner.text
|
|
997
|
+
: data.closed === true ? t('closedSocial') : t(data.editable === true ? 'stripNote' : 'stripReadOnly')))
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
/** The memory route's listing, read again on `load`; a reply that a later read overtook is dropped. */
|
|
1001
|
+
function useMemory() {
|
|
1002
|
+
const [state, setState] = useState({ phase: 'loading' })
|
|
1003
|
+
const alive = useRef(true)
|
|
1004
|
+
const generation = useRef(0)
|
|
1005
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1006
|
+
const load = useCallback(async () => {
|
|
1007
|
+
const mine = ++generation.current
|
|
1008
|
+
setState((s) => (s.phase === 'ready' ? s : { phase: 'loading' }))
|
|
1009
|
+
let next
|
|
1010
|
+
try {
|
|
1011
|
+
const response = await request(MEMORY_API)
|
|
1012
|
+
next = response.ok && Array.isArray(response.body?.stores)
|
|
1013
|
+
? { phase: 'ready', data: response.body, at: Date.now() }
|
|
1014
|
+
: { phase: 'error', reason: response.status === 503 ? 'listTimeout' : 'listFailed' }
|
|
1015
|
+
} catch {
|
|
1016
|
+
next = { phase: 'error', reason: 'listFailed' }
|
|
1017
|
+
}
|
|
1018
|
+
if (alive.current && mine === generation.current) setState(next)
|
|
1019
|
+
}, [])
|
|
1020
|
+
useEffect(() => { load() }, [load])
|
|
1021
|
+
return { state, load }
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
/** What the page says for each way the memory route declines to open a file. */
|
|
1025
|
+
const OPEN_FAILURES = {
|
|
1026
|
+
unavailable: 'openUnavailable', missing: 'openMissing', busy: 'openBusy', timeout: 'listTimeout',
|
|
1027
|
+
}
|
|
1028
|
+
const nameOf = (file) => file.replace(/\.md$/i, '')
|
|
1029
|
+
/**
|
|
1030
|
+
* A name or path from disk as the page shows it: a control character, a line or paragraph
|
|
1031
|
+
* separator, a bidirectional mark, embedding, override or isolate, or a character with no
|
|
1032
|
+
* width of its own (a zero-width space, a word joiner, a byte order mark) — any of which can
|
|
1033
|
+
* make a name read as another, or hide part of it — shown as its code point (`[U+202E]`).
|
|
1034
|
+
* The joiners some scripts and emoji are written with (U+200C, U+200D) are left as they are.
|
|
1035
|
+
* What the page sends back to open a file is the name as it is.
|
|
1036
|
+
*/
|
|
1037
|
+
const HIDDEN = [[0x0, 0x1f], [0x7f, 0x9f], [0x61c, 0x61c], [0x200b, 0x200b], [0x200e, 0x200f],
|
|
1038
|
+
[0x2028, 0x202e], [0x2060, 0x2064], [0x2066, 0x2069], [0xfeff, 0xfeff]]
|
|
1039
|
+
const legible = (text) => Array.from(String(text), (ch) => {
|
|
1040
|
+
const code = ch.codePointAt(0)
|
|
1041
|
+
return HIDDEN.some(([low, high]) => code >= low && code <= high)
|
|
1042
|
+
? `[U+${code.toString(16).toUpperCase().padStart(4, '0')}]`
|
|
1043
|
+
: ch
|
|
1044
|
+
}).join('')
|
|
1045
|
+
const sizeOf = (t, bytes) => (bytes < 1024 ? t('sizeBytes', { n: bytes }) : t('sizeKB', { n: (bytes / 1024).toFixed(1) }))
|
|
1046
|
+
const typeKey = (type) => `type${type[0].toUpperCase()}${type.slice(1)}`
|
|
1047
|
+
const collator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' })
|
|
1048
|
+
const byName = (a, b) => collator.compare(a, b)
|
|
1049
|
+
/** Notes in the protocol's order of types, then by name. */
|
|
1050
|
+
const byTypeThenName = (a, b) => TYPES.indexOf(a.type) - TYPES.indexOf(b.type) || byName(a.name, b.name)
|
|
1051
|
+
|
|
1052
|
+
/** Put `text` on the clipboard; false where there is none (a page over plain http) or it is refused. */
|
|
1053
|
+
async function copyText(text) {
|
|
1054
|
+
try {
|
|
1055
|
+
await globalThis.navigator.clipboard.writeText(text)
|
|
1056
|
+
return true
|
|
1057
|
+
} catch {
|
|
1058
|
+
return false
|
|
1059
|
+
}
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/** The date an `upcoming` note is named with, if it is a real day: `YYYY-MM-DD`, else undefined. */
|
|
1063
|
+
function dateOf(file) {
|
|
1064
|
+
const m = DATED.exec(nameOf(file))
|
|
1065
|
+
if (m === null) return undefined
|
|
1066
|
+
const [y, mo, d] = [Number(m[1]), Number(m[2]), Number(m[3])]
|
|
1067
|
+
const day = new Date(Date.UTC(y, mo - 1, d))
|
|
1068
|
+
return day.getUTCFullYear() === y && day.getUTCMonth() === mo - 1 && day.getUTCDate() === d
|
|
1069
|
+
? `${m[1]}-${m[2]}-${m[3]}` : undefined
|
|
1070
|
+
}
|
|
1071
|
+
/** A `YYYY-MM-DD` day as a number of days, to subtract one from another. */
|
|
1072
|
+
const dayNumber = (date) => Date.UTC(Number(date.slice(0, 4)), Number(date.slice(5, 7)) - 1,
|
|
1073
|
+
Number(date.slice(8, 10))) / 86400000
|
|
1074
|
+
/** Today on this computer's calendar, as `YYYY-MM-DD`. */
|
|
1075
|
+
function todayOf(now) {
|
|
1076
|
+
const d = new Date(now)
|
|
1077
|
+
return `${d.getFullYear()}-${String(d.getMonth() + 1).padStart(2, '0')}-${String(d.getDate()).padStart(2, '0')}`
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
/**
|
|
1081
|
+
* Where an `upcoming` note stands against today on this computer: a date passed only says
|
|
1082
|
+
* the outcome is yet to be asked about (SKILL.md §2.2 keeps the note until it is known),
|
|
1083
|
+
* so nothing here is called late or stale. No date, or no real one, is undated.
|
|
1084
|
+
*/
|
|
1085
|
+
function planOf(file, now) {
|
|
1086
|
+
const date = dateOf(file)
|
|
1087
|
+
if (date === undefined) return { status: 'undated' }
|
|
1088
|
+
const days = dayNumber(date) - dayNumber(todayOf(now))
|
|
1089
|
+
return { status: days < 0 ? 'past' : days === 0 ? 'today' : 'ahead', days, date }
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/** A note's name as listed: a plan's date is in its badge, so it is not said again before the name. */
|
|
1093
|
+
function shownName(file, plan) {
|
|
1094
|
+
const name = nameOf(file)
|
|
1095
|
+
if (plan?.date === undefined) return name
|
|
1096
|
+
const rest = name.slice(10).replace(/^[\s_-]+/, '')
|
|
1097
|
+
return rest === '' ? name : rest
|
|
1098
|
+
}
|
|
1099
|
+
|
|
1100
|
+
/** How full an index is, the nearer of its two caps; its lines only when they were counted. */
|
|
1101
|
+
function fillOf(index, cap) {
|
|
1102
|
+
const lines = index.lines === undefined ? 0 : index.lines / cap.maxLines
|
|
1103
|
+
return Math.max(lines, index.bytes / cap.maxBytes)
|
|
1104
|
+
}
|
|
1105
|
+
|
|
1106
|
+
/** Line icons on a 24-unit grid, in the current colour: [element, attributes] each. One per
|
|
1107
|
+
* note type (TYPES), drawn alike, so the type's colour tells them apart before the shape does. */
|
|
1108
|
+
const ICONS = {
|
|
1109
|
+
refresh: [['path', { d: 'M20 11a8 8 0 1 0-2.3 5.7' }], ['path', { d: 'M20 4v7h-7' }]],
|
|
1110
|
+
search: [['circle', { cx: 11, cy: 11, r: 7 }], ['path', { d: 'm20 20-3.5-3.5' }]],
|
|
1111
|
+
copy: [['rect', { x: 9, y: 9, width: 11, height: 11, rx: 2 }], ['path', { d: 'M5 15V5a2 2 0 0 1 2-2h8' }]],
|
|
1112
|
+
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' }]],
|
|
1113
|
+
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' }],
|
|
1114
|
+
['path', { d: 'M9 13h6m-2-2 2 2-2 2' }]],
|
|
1115
|
+
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' }]],
|
|
1116
|
+
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' }]],
|
|
1117
|
+
alert: [['path', { d: 'M12 4 2.5 20h19z' }], ['path', { d: 'M12 10v4M12 17h.01' }]],
|
|
1118
|
+
clock: [['circle', { cx: 12, cy: 12, r: 8.5 }], ['path', { d: 'M12 7.5V12l3 2' }]],
|
|
1119
|
+
check: [['path', { d: 'm5 12 5 5 9-10' }]],
|
|
1120
|
+
chevron: [['path', { d: 'm9 6 6 6-6 6' }]],
|
|
1121
|
+
book: [['path', { d: 'M4 5a2 2 0 0 1 2-2h13v16H6a2 2 0 0 0-2 2z' }], ['path', { d: 'M4 19V5' }]],
|
|
1122
|
+
issue: [['path', { d: 'M21 12a8 8 0 0 1-11.6 7.1L4 20l1-4.6A8 8 0 1 1 21 12z' }]],
|
|
1123
|
+
mail: [['rect', { x: 3, y: 5, width: 18, height: 14, rx: 2 }], ['path', { d: 'm3 7 9 6 9-6' }]],
|
|
1124
|
+
package: [['path', { d: 'M12 3 4 7v10l8 4 8-4V7z' }], ['path', { d: 'm4 7 8 4 8-4M12 11v10' }]],
|
|
1125
|
+
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' }]],
|
|
1126
|
+
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' }],
|
|
1127
|
+
['path', { d: 'm9 10.3 2 2 4-4' }]],
|
|
1128
|
+
project: [['path', { d: 'M12 4 3.5 8.5 12 13l8.5-4.5z' }], ['path', { d: 'm3.5 12.5 8.5 4.5 8.5-4.5M3.5 16.3 12 20.8l8.5-4.5' }]],
|
|
1129
|
+
reference: [['path', { d: 'M7 3.5h10a1 1 0 0 1 1 1v16l-6-3.8-6 3.8v-16a1 1 0 0 1 1-1z' }]],
|
|
1130
|
+
moment: [['path', { d: 'M10 3.5l1.6 4.4L16 9.5l-4.4 1.6L10 15.5l-1.6-4.4L4 9.5l4.4-1.6z' }],
|
|
1131
|
+
['path', { d: 'M17.5 14v5.5M14.75 16.75h5.5' }]],
|
|
1132
|
+
upcoming: [['rect', { x: 4, y: 5.5, width: 16, height: 14.5, rx: 2.5 }], ['path', { d: 'M4 10h16M8.5 3.5v4M15.5 3.5v4' }],
|
|
1133
|
+
['circle', { cx: 15.3, cy: 15, r: 1.3, fill: 'currentColor', stroke: 'none' }]],
|
|
1134
|
+
self: [['path', { d: 'M12 19.5s-7-4.3-7-9.6A3.9 3.9 0 0 1 12 7.6a3.9 3.9 0 0 1 7 2.3c0 5.3-7 9.6-7 9.6z' }]],
|
|
1135
|
+
other: [['path', { d: 'M13.5 3.5H7a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V9z' }], ['path', { d: 'M13.5 3.5V9H19' }]],
|
|
1136
|
+
}
|
|
1137
|
+
const icon = (name, size = 16, weight = 1.8) => h('svg', {
|
|
1138
|
+
width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: weight,
|
|
1139
|
+
strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true, focusable: 'false',
|
|
1140
|
+
}, ...ICONS[name].map(([tag, attributes], i) => h(tag, { key: i, ...attributes })))
|
|
1141
|
+
|
|
1142
|
+
/** The project's mark, [[▮]] in mint on its dark tile, as in its icon. */
|
|
1143
|
+
function Logo() {
|
|
1144
|
+
return h('svg', { className: 'eng-logo', width: 44, height: 44, viewBox: '0 0 64 64', 'aria-hidden': true, focusable: 'false' },
|
|
1145
|
+
h('rect', { width: 64, height: 64, rx: 14, fill: '#0F1B2D' }),
|
|
1146
|
+
h('path', { d: 'M13 17.5H9v29h4M22 17.5h-4v29h4M42 17.5h4v29h-4M51 17.5h4v29h-4', fill: 'none', stroke: '#6EE7C8',
|
|
1147
|
+
strokeWidth: 4, strokeLinecap: 'round', strokeLinejoin: 'round' }),
|
|
1148
|
+
h('rect', { x: 27.5, y: 23, width: 9, height: 18, rx: 2.4, fill: '#6EE7C8' }))
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
/** When a listing was read, its day with its time, as this computer shows them. */
|
|
1152
|
+
const timeOf = (at) => new Date(at).toLocaleString([], { month: '2-digit', day: '2-digit', hour: '2-digit',
|
|
1153
|
+
minute: '2-digit' })
|
|
1154
|
+
|
|
1155
|
+
/**
|
|
1156
|
+
* The banner atop the memory page, in the project's own colours on any theme: its name with
|
|
1157
|
+
* the plugin's version, the listing in three numbers as read at `at` with a refresh beside the
|
|
1158
|
+
* time, and the two settings that matter most in a panel of their own. Numbers only once there
|
|
1159
|
+
* is a listing with something to count.
|
|
1160
|
+
*/
|
|
1161
|
+
function Hero({ data, at, refresh, t }) {
|
|
1162
|
+
const counted = data !== undefined && (data.stores.length > 0 || data.unreadable > 0)
|
|
1163
|
+
const sum = (of) => data.stores.reduce((total, store) => total + of(store), 0)
|
|
1164
|
+
const notes = counted ? sum((store) => store.notes.length) : 0
|
|
1165
|
+
const stat = (n, label) => h('div', { className: 'eng-stat', key: label }, h('b', null, String(n)), h('span', null, label))
|
|
1166
|
+
return h('header', { className: 'eng-hero' },
|
|
1167
|
+
h('div', { className: 'eng-hero-main' },
|
|
1168
|
+
h('div', { className: 'eng-brand' }, h(Logo), h('h1', { className: 'eng-hero-title' }, t('panelTitle'),
|
|
1169
|
+
h('span', { className: 'eng-hero-version' }, `v${VERSION}`))),
|
|
1170
|
+
counted ? h('div', { className: 'eng-stats' },
|
|
1171
|
+
stat(notes, t(notes === 1 ? 'statNote' : 'statNotes')),
|
|
1172
|
+
stat(data.stores.length, t(data.stores.length === 1 ? 'statStore' : 'statStores')),
|
|
1173
|
+
stat(sum((store) => store.archive.length), t('statArchive'))) : null,
|
|
1174
|
+
h('div', { className: 'eng-hero-foot' },
|
|
1175
|
+
data === undefined ? null : h('p', { className: 'eng-hero-read' },
|
|
1176
|
+
icon('clock', 13), t('statsReadAt', { time: timeOf(at) })),
|
|
1177
|
+
h('button', { type: 'button', className: 'eng-hero-btn', onClick: refresh }, icon('refresh', 14), t('refresh')))),
|
|
1178
|
+
h('div', { className: 'eng-hero-side' }, h(SettingsStrip, { t })))
|
|
1179
|
+
}
|
|
1180
|
+
|
|
1181
|
+
/** What the numbers leave out — a listing cut short, files or stores it could not read — since
|
|
1182
|
+
* what was not listed is not counted as nothing. */
|
|
1183
|
+
function Caveats({ data, t }) {
|
|
1184
|
+
const partial = data.more === true || data.stores.some((store) => store.more)
|
|
1185
|
+
// a note or a folder it could not read: the store's check-up says so too
|
|
1186
|
+
const incomplete = data.stores.some((store) => store.health?.checked === false &&
|
|
1187
|
+
store.health.reason === 'unreadable')
|
|
1188
|
+
const lines = [
|
|
1189
|
+
partial ? t('statsPartial') : null,
|
|
1190
|
+
incomplete ? t('statsIncomplete') : null,
|
|
1191
|
+
data.unreadable > 0 ? t('statsUnreadable', { count: data.unreadable }) : null,
|
|
1192
|
+
].filter((line) => line !== null)
|
|
1193
|
+
return lines.length === 0 ? null
|
|
1194
|
+
: h('p', { className: 'eng-caveat' }, icon('alert', 14), h('span', null, lines.join(' ')))
|
|
1195
|
+
}
|
|
1196
|
+
|
|
1197
|
+
/**
|
|
1198
|
+
* One store: where it is, how full its index is (a bar to the nearer of its two caps), what
|
|
1199
|
+
* its check-up (index.js checkUp) found for the AI to tidy up — with the tidy-up instructions
|
|
1200
|
+
* to copy, or to select where there is no clipboard — and its notes, a row each: the type's
|
|
1201
|
+
* mark, the name, the type and size, and what stands out (a plan's day, a note grown past one
|
|
1202
|
+
* fact, one the index leaves out). While the page filters, the rows that match and no more.
|
|
1203
|
+
*/
|
|
1204
|
+
function StoreSection({ store, cap, canOpen, open, match, kind, now, t, onMoved }) {
|
|
1205
|
+
const [tidy, setTidy] = useState('idle')
|
|
1206
|
+
// the global store's: moving it, opened from its actions
|
|
1207
|
+
const [placing, setPlacing] = useState(false)
|
|
1208
|
+
const alive = useRef(true)
|
|
1209
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1210
|
+
const title = legible(store.kind === 'user' ? [t('storeUser'), ...store.titles].join(' · ')
|
|
1211
|
+
: store.kind === 'pinned' ? [t('storePinned'), ...store.titles].join(' · ')
|
|
1212
|
+
: store.titles.join(' · '))
|
|
1213
|
+
const { index } = store
|
|
1214
|
+
const sizes = index === null ? {} : { size: sizeOf(t, index.bytes), maxSize: sizeOf(t, cap.maxBytes) }
|
|
1215
|
+
// lines are counted only for an index read whole; past that, its bytes say over or not
|
|
1216
|
+
const usage = index === null ? t('noIndex')
|
|
1217
|
+
: index.lines !== undefined ? t('usage', { lines: index.lines, maxLines: cap.maxLines, ...sizes })
|
|
1218
|
+
: t(index.over ? 'usageOver' : 'usageSize', sizes)
|
|
1219
|
+
const fill = index === null ? undefined : fillOf(index, cap)
|
|
1220
|
+
const filtering = match !== undefined || kind !== undefined
|
|
1221
|
+
const keep = (file) => match === undefined || match(file)
|
|
1222
|
+
const notes = store.notes.filter((note) => (kind === undefined || note.type === kind) && keep(note.name))
|
|
1223
|
+
.sort(byTypeThenName)
|
|
1224
|
+
const archived = kind === undefined ? store.archive.filter(keep).sort(byName) : []
|
|
1225
|
+
|
|
1226
|
+
const check = store.health ?? undefined
|
|
1227
|
+
const checked = check?.checked === true
|
|
1228
|
+
const unindexed = new Set(checked ? check.unindexed : [])
|
|
1229
|
+
const untyped = store.notes.filter((note) => note.type === 'other').length
|
|
1230
|
+
const large = store.notes.filter((note) => note.bytes > LARGE_NOTE).length
|
|
1231
|
+
// pointers to nothing past what the page is told of are still pointers to nothing
|
|
1232
|
+
const broken = checked && (check.broken.length > 0 || check.brokenMore)
|
|
1233
|
+
const findings = [
|
|
1234
|
+
index?.over ? h('p', { className: 'eng-attn-item', key: 'over' }, t('overHint')) : null,
|
|
1235
|
+
broken ? h('div', { className: 'eng-attn-item', key: 'broken' },
|
|
1236
|
+
check.broken.length === 0 ? t('healthBrokenUnlisted')
|
|
1237
|
+
: t(check.brokenMore ? 'healthBrokenMore' : 'healthBroken', { count: check.broken.length }),
|
|
1238
|
+
// what the index says, as it says it: there is no file to open
|
|
1239
|
+
check.broken.length > 0 ? h('ul', { className: 'eng-broken' },
|
|
1240
|
+
check.broken.map((target) => h('li', { key: target }, h('code', null, legible(target))))) : null) : null,
|
|
1241
|
+
checked && check.unindexed.length > 0
|
|
1242
|
+
? h('p', { className: 'eng-attn-item', key: 'unindexed' }, t('healthUnindexed', { count: check.unindexed.length })) : null,
|
|
1243
|
+
checked && untyped > 0 ? h('p', { className: 'eng-attn-item', key: 'untyped' }, t('healthUntyped', { count: untyped })) : null,
|
|
1244
|
+
large > 0 ? h('p', { className: 'eng-attn-item', key: 'large' }, t('attnLarge', { count: large })) : null,
|
|
1245
|
+
].filter((finding) => finding !== null)
|
|
1246
|
+
// while filtering, the names that match and nothing else: the findings come back after
|
|
1247
|
+
const attention = !filtering && findings.length > 0
|
|
1248
|
+
// a check-up that did not run says why, except past the cap, which the findings say already
|
|
1249
|
+
const unchecked = check === undefined || check === null || check.checked ? undefined
|
|
1250
|
+
: { large: 'healthLarge', partial: 'healthPartial', unreadable: 'healthUnreadable' }[check.reason]
|
|
1251
|
+
|
|
1252
|
+
const prompt = t('tidyPrompt', { dir: store.dir })
|
|
1253
|
+
const copyTidy = async () => {
|
|
1254
|
+
const done = await copyText(prompt)
|
|
1255
|
+
if (alive.current) setTidy(done ? 'copied' : 'failed')
|
|
1256
|
+
}
|
|
1257
|
+
// one per store: in the findings where there are any, else among the store's own actions
|
|
1258
|
+
const tidyButton = (className) => h('button', { type: 'button', className, onClick: copyTidy },
|
|
1259
|
+
icon('tidy', 14), t(tidy === 'copied' ? 'tidyCopied' : 'tidyCopy'))
|
|
1260
|
+
|
|
1261
|
+
const planText = (plan) => {
|
|
1262
|
+
if (plan.status === 'undated') return t('badgeUndated')
|
|
1263
|
+
if (plan.status === 'today') return t('badgeToday')
|
|
1264
|
+
// the year where it is not this one, so last year's plan is not taken for this year's
|
|
1265
|
+
const year = Number(plan.date.slice(0, 4))
|
|
1266
|
+
const day = { m: Number(plan.date.slice(5, 7)), d: Number(plan.date.slice(8, 10)) }
|
|
1267
|
+
const date = year === new Date(now).getFullYear() ? t('monthDay', day) : t('yearMonthDay', { y: year, ...day })
|
|
1268
|
+
return plan.status === 'past' ? t('badgePast', { date })
|
|
1269
|
+
: plan.days === 1 ? t('badgeTomorrow', { date }) : t('badgeSoon', { date, days: plan.days })
|
|
1270
|
+
}
|
|
1271
|
+
/** A note's row, or an archived file's (no note given): to open where dsh can, else text. */
|
|
1272
|
+
const row = (file, note) => {
|
|
1273
|
+
const type = note === undefined ? 'archive' : note.type
|
|
1274
|
+
const plan = type === 'upcoming' ? planOf(file, now) : undefined
|
|
1275
|
+
const meta = note === undefined ? t('archived')
|
|
1276
|
+
: note.unread ? t('noteUnread')
|
|
1277
|
+
: note.bytes === undefined ? t(typeKey(type))
|
|
1278
|
+
: t('noteMeta', { type: t(typeKey(type)), size: sizeOf(t, note.bytes) })
|
|
1279
|
+
const badges = [
|
|
1280
|
+
plan === undefined ? null : h('span', { className: 'eng-badge', key: 'plan',
|
|
1281
|
+
'data-tone': plan.status === 'past' ? 'warn' : plan.status === 'undated' ? 'quiet' : undefined }, planText(plan)),
|
|
1282
|
+
note?.bytes > LARGE_NOTE ? h('span', { className: 'eng-badge', 'data-tone': 'warn', key: 'large' }, t('badgeLarge')) : null,
|
|
1283
|
+
note !== undefined && unindexed.has(file) ? h('span', { className: 'eng-badge', key: 'unindexed' }, t('badgeUnindexed')) : null,
|
|
1284
|
+
].filter((badge) => badge !== null)
|
|
1285
|
+
const parts = [
|
|
1286
|
+
h('span', { className: 'eng-mark', key: 'mark' }, icon(Object.hasOwn(ICONS, type) ? type : 'other', 18, 1.6)),
|
|
1287
|
+
h('span', { className: 'eng-row-text', key: 'text' },
|
|
1288
|
+
h('span', { className: 'eng-name' }, legible(shownName(file, plan))),
|
|
1289
|
+
h('span', { className: 'eng-row-meta' }, meta)),
|
|
1290
|
+
badges.length > 0 ? h('span', { className: 'eng-badges', key: 'badges' }, badges) : null,
|
|
1291
|
+
canOpen ? h('span', { className: 'eng-row-go', key: 'go' }, icon('chevron', 14)) : null,
|
|
1292
|
+
]
|
|
1293
|
+
const props = { className: 'eng-row', 'data-type': type, title: legible(file) }
|
|
1294
|
+
return h('li', { key: file }, canOpen
|
|
1295
|
+
? h('button', { type: 'button', ...props, onClick: () => open(store, file, note === undefined) }, ...parts)
|
|
1296
|
+
: h('div', props, ...parts))
|
|
1297
|
+
}
|
|
1298
|
+
const archive = archived.length === 0 ? null
|
|
1299
|
+
: h('details', { className: 'eng-archive', open: match === undefined ? undefined : true },
|
|
1300
|
+
h('summary', null, icon('archive', 16), h('span', null, t('archive', { count: archived.length }))),
|
|
1301
|
+
h('ul', { className: 'eng-rows' }, archived.map((file) => row(file, undefined))))
|
|
1302
|
+
|
|
1303
|
+
return h('section', { className: 'eng-store', 'aria-label': title },
|
|
1304
|
+
h('div', { className: 'eng-store-head' },
|
|
1305
|
+
h('h2', { className: 'eng-store-title' }, title),
|
|
1306
|
+
h('span', { className: 'eng-store-count' },
|
|
1307
|
+
t(store.notes.length === 1 ? 'storeCountOne' : 'storeCount', { count: store.notes.length })),
|
|
1308
|
+
// the nearer cap, whichever it is; over it, full and marked, not a bar that stops at the edge
|
|
1309
|
+
fill === undefined ? null : h('span', { className: 'eng-meter', 'data-over': index.over === true || fill > 1,
|
|
1310
|
+
'aria-hidden': true },
|
|
1311
|
+
h('span', { className: 'eng-meter-fill', style: { width: `${Math.min(100, Math.floor(fill * 100))}%` } })),
|
|
1312
|
+
h('span', { className: 'eng-usage', 'data-over': index?.over === true, title: index?.over ? t('overHint') : undefined }, usage),
|
|
1313
|
+
h('div', { className: 'eng-store-actions' },
|
|
1314
|
+
store.kind === 'user' ? h('button', { type: 'button', className: 'eng-btn eng-btn-ghost', key: 'place',
|
|
1315
|
+
'aria-expanded': placing, onClick: () => setPlacing(!placing) },
|
|
1316
|
+
icon('move', 14), t(placing ? 'placeHide' : 'placeChange')) : null,
|
|
1317
|
+
attention ? null : tidyButton('eng-btn eng-btn-ghost'),
|
|
1318
|
+
// the folder is shown with its index selected: no index, no folder to show
|
|
1319
|
+
...(canOpen && index !== null ? [
|
|
1320
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-ghost', key: 'folder',
|
|
1321
|
+
onClick: () => open(store, undefined, false) }, icon('folder', 14), t('openFolder'))] : []))),
|
|
1322
|
+
h('p', { className: 'eng-path' }, legible(store.dir)),
|
|
1323
|
+
placing ? h(PlaceSection, { t, onMoved }) : null,
|
|
1324
|
+
!filtering && checked && findings.length === 0
|
|
1325
|
+
? h('p', { className: 'eng-store-ok' }, icon('check', 13), t('healthOk')) : null,
|
|
1326
|
+
attention ? h('div', { className: 'eng-attn', role: 'note' },
|
|
1327
|
+
icon('alert', 16),
|
|
1328
|
+
h('div', { className: 'eng-attn-body' },
|
|
1329
|
+
h('h3', { className: 'eng-attn-title' }, t('attnTitle')),
|
|
1330
|
+
...findings,
|
|
1331
|
+
h('p', { className: 'eng-attn-item', key: 'doctor' }, t('healthFix'))),
|
|
1332
|
+
tidyButton('eng-btn')) : null,
|
|
1333
|
+
tidy === 'failed' ? h('div', { className: 'eng-tidy', role: 'status' },
|
|
1334
|
+
h('p', null, t('tidyFailed')),
|
|
1335
|
+
h('textarea', { readOnly: true, value: prompt, 'aria-label': t('tidyCopy'),
|
|
1336
|
+
onFocus: (event) => event.target.select() })) : null,
|
|
1337
|
+
!filtering && unchecked !== undefined ? h('p', { className: 'eng-note' }, t(unchecked)) : null,
|
|
1338
|
+
notes.length > 0 || archive !== null ? h('div', { className: 'eng-list' },
|
|
1339
|
+
notes.length > 0 ? h('ul', { className: 'eng-rows' }, notes.map((note) => row(note.name, note))) : null,
|
|
1340
|
+
archive) : null,
|
|
1341
|
+
filtering && notes.length === 0 && archived.length === 0
|
|
1342
|
+
? h('p', { className: 'eng-filter-none' }, t('filterNone')) : null,
|
|
1343
|
+
store.more ? h('p', { className: 'eng-note' }, t('more')) : null)
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
/** A store with anything in it: an index with text, a note, an archived note. A folder or an
|
|
1347
|
+
* empty index alone is not memory yet. */
|
|
1348
|
+
const hasMemory = (store) => (store.index !== null && store.index.bytes > 0) ||
|
|
1349
|
+
store.notes.length > 0 || store.archive.length > 0
|
|
1350
|
+
|
|
1351
|
+
/** A store not read to its end: a listing cut short, or a file or folder it could not read. */
|
|
1352
|
+
const readInPart = (store) => store.more === true ||
|
|
1353
|
+
(store.health?.checked === false && store.health.reason === 'unreadable')
|
|
1354
|
+
|
|
1355
|
+
/** How to use it, in a few lines: open while there is no memory yet, folded once there is. */
|
|
1356
|
+
function HowTo({ open, t }) {
|
|
1357
|
+
return h('details', { className: 'eng-howto', open },
|
|
1358
|
+
h('summary', null, icon('book', 15), t('howTo')),
|
|
1359
|
+
h('ul', null, HOW_TO.map((key) => h('li', { key }, t(key)))))
|
|
1360
|
+
}
|
|
1361
|
+
|
|
1362
|
+
/** The OS family for a bug report, and nothing that tells one machine from another. */
|
|
1363
|
+
function osName() {
|
|
1364
|
+
const platform = String(globalThis.navigator?.userAgentData?.platform ?? globalThis.navigator?.platform ?? '')
|
|
1365
|
+
return /^win/i.test(platform) ? 'Windows' : /^mac/i.test(platform) ? 'macOS'
|
|
1366
|
+
: /linux/i.test(platform) ? 'Linux' : 'unknown'
|
|
1367
|
+
}
|
|
1368
|
+
|
|
1369
|
+
/** The latest version on npm and the registry that said so, asked of each in turn until one
|
|
1370
|
+
* answers with a version; undefined when none does. Each gets 8 seconds, body included, and no cookie or
|
|
1371
|
+
* referrer goes with the request: the package's name is all it asks about. */
|
|
1372
|
+
async function latestVersion() {
|
|
1373
|
+
for (const [source, registry] of REGISTRIES) {
|
|
1374
|
+
const deadline = new AbortController()
|
|
1375
|
+
const timer = setTimeout(() => deadline.abort(), 8000)
|
|
1376
|
+
try {
|
|
1377
|
+
const response = await fetch(`${registry}/${PACKAGE}/latest`, { cache: 'no-store', credentials: 'omit',
|
|
1378
|
+
referrerPolicy: 'no-referrer', signal: deadline.signal, headers: { accept: 'application/json' } })
|
|
1379
|
+
const version = response.ok ? (await response.json())?.version : undefined
|
|
1380
|
+
if (typeof version === 'string' && version.length <= 64 && SEMVER.test(version)) return { version, source }
|
|
1381
|
+
} catch {
|
|
1382
|
+
// unreachable, refused, too slow or not JSON: the next registry
|
|
1383
|
+
} finally {
|
|
1384
|
+
clearTimeout(timer)
|
|
1385
|
+
// a body left unread (an error's) or half read is let go, not left streaming
|
|
1386
|
+
deadline.abort()
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1389
|
+
return undefined
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1392
|
+
/** -1, 0 or 1 as version `a` is older than, the same as or newer than `b` (both SEMVER): by
|
|
1393
|
+
* the three numbers, then a prerelease before its release. Two prereleases of one release
|
|
1394
|
+
* count as the same; this package publishes none to npm's `latest`. */
|
|
1395
|
+
function compareVersions(a, b) {
|
|
1396
|
+
const x = SEMVER.exec(a)
|
|
1397
|
+
const y = SEMVER.exec(b)
|
|
1398
|
+
for (let i = 1; i <= 3; i++) {
|
|
1399
|
+
if (Number(x[i]) !== Number(y[i])) return Number(x[i]) < Number(y[i]) ? -1 : 1
|
|
1400
|
+
}
|
|
1401
|
+
return x[4] === y[4] || (x[4] !== undefined && y[4] !== undefined) ? 0 : x[4] === undefined ? 1 : -1
|
|
1402
|
+
}
|
|
1403
|
+
|
|
1404
|
+
/**
|
|
1405
|
+
* The installed version and, on a click and only then, how it stands against the latest on
|
|
1406
|
+
* npm. A newer one comes with the steps that install it, the version named: by name alone,
|
|
1407
|
+
* pnpm (the desktop's, and the CLI's from pnpm 11) takes only a version a day old. dsh has no
|
|
1408
|
+
* update for a plugin outside its own catalog, so the desktop's way is uninstall and install.
|
|
1409
|
+
*/
|
|
1410
|
+
function UpdateCheck({ t }) {
|
|
1411
|
+
const [check, setCheck] = useState({ phase: 'idle' })
|
|
1412
|
+
const [copy, setCopy] = useState('copy')
|
|
1413
|
+
const alive = useRef(true)
|
|
1414
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1415
|
+
const run = async () => {
|
|
1416
|
+
setCheck({ phase: 'checking' })
|
|
1417
|
+
setCopy('copy')
|
|
1418
|
+
const found = await latestVersion()
|
|
1419
|
+
if (!alive.current) return
|
|
1420
|
+
setCheck(found === undefined ? { phase: 'failed' } : { phase: 'done', latest: found.version,
|
|
1421
|
+
source: found.source, order: compareVersions(found.version, VERSION) })
|
|
1422
|
+
}
|
|
1423
|
+
const spec = `${PACKAGE}@${check.latest}`
|
|
1424
|
+
const copySpec = async () => {
|
|
1425
|
+
const done = await copyText(spec)
|
|
1426
|
+
if (alive.current) setCopy(done ? 'copied' : 'copyFailed')
|
|
1427
|
+
}
|
|
1428
|
+
const external = (href, text) => h('a', { className: 'eng-link', href, target: '_blank', rel: 'noopener noreferrer' }, text)
|
|
1429
|
+
let result = null
|
|
1430
|
+
if (check.phase === 'failed') {
|
|
1431
|
+
result = h('p', { role: 'status' }, t('updateFailed'), external(NPM_PAGE, t('updateNpm')))
|
|
1432
|
+
} else if (check.phase === 'done' && check.order <= 0) {
|
|
1433
|
+
result = h('p', { role: 'status' },
|
|
1434
|
+
check.order === 0 ? t('updateCurrent', { latest: check.latest, source: check.source })
|
|
1435
|
+
: t('updateAhead', { latest: check.latest, current: VERSION, source: check.source }))
|
|
1436
|
+
} else if (check.phase === 'done') {
|
|
1437
|
+
result = h('div', { className: 'eng-update', role: 'status' },
|
|
1438
|
+
h('p', null,
|
|
1439
|
+
h('span', { className: 'eng-update-new' }, t('updateNewer', { latest: check.latest, current: VERSION })),
|
|
1440
|
+
external(`${RELEASE}${check.latest}`, t('updateNotes'))),
|
|
1441
|
+
h('p', null, t('updateHow')),
|
|
1442
|
+
h('ul', null,
|
|
1443
|
+
h('li', null, t('updateDesktop'), h('code', { className: 'eng-code' }, spec),
|
|
1444
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-small', onClick: copySpec },
|
|
1445
|
+
t(copy === 'copied' ? 'copied' : 'copy'))),
|
|
1446
|
+
h('li', null, t('updateCli'),
|
|
1447
|
+
h('code', { className: 'eng-code' }, `dsh plugin --profile ${t('updateProfile')} add ${spec}`))),
|
|
1448
|
+
copy === 'copyFailed' ? h('p', { className: 'eng-feedback-note' }, t('copySpecFailed')) : null,
|
|
1449
|
+
h('p', null, t('updateAfter')))
|
|
1450
|
+
}
|
|
1451
|
+
// a mirror's word, which may trail npm's, is said to be one
|
|
1452
|
+
const mirrored = check.phase === 'done' && check.source !== 'npm'
|
|
1453
|
+
? h('p', { className: 'eng-feedback-note' }, t('updateMirror')) : null
|
|
1454
|
+
return h('div', { className: 'eng-version' },
|
|
1455
|
+
h('p', null,
|
|
1456
|
+
icon('package', 14),
|
|
1457
|
+
t('versionLine', { version: VERSION }),
|
|
1458
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-small', disabled: check.phase === 'checking',
|
|
1459
|
+
onClick: run }, t(check.phase === 'checking' ? 'checking' : 'checkUpdate'))),
|
|
1460
|
+
result,
|
|
1461
|
+
mirrored,
|
|
1462
|
+
h('p', { className: 'eng-feedback-note' }, t('updateNote')))
|
|
1463
|
+
}
|
|
1464
|
+
|
|
1465
|
+
/**
|
|
1466
|
+
* Where to report a problem or send an idea: a new issue, its body started with the
|
|
1467
|
+
* plugin's version and the OS (no path, no note), or the mailbox, whose address the
|
|
1468
|
+
* button copies — the desktop app opens only web links, not `mailto:`. Above them, the
|
|
1469
|
+
* version and the check for a newer one.
|
|
1470
|
+
*/
|
|
1471
|
+
function Feedback({ t }) {
|
|
1472
|
+
const [copy, setCopy] = useState('copy')
|
|
1473
|
+
const alive = useRef(true)
|
|
1474
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1475
|
+
const copyAddress = async () => {
|
|
1476
|
+
const done = await copyText(EMAIL)
|
|
1477
|
+
if (alive.current) setCopy(done ? 'copied' : 'copyFailed')
|
|
1478
|
+
}
|
|
1479
|
+
const href = `${ISSUES}?body=${encodeURIComponent(t('issueBody', { version: VERSION, os: osName() }))}`
|
|
1480
|
+
return h('footer', { className: 'eng-feedback' },
|
|
1481
|
+
h(UpdateCheck, { t }),
|
|
1482
|
+
h('p', null,
|
|
1483
|
+
icon('issue', 14),
|
|
1484
|
+
t('feedbackLead'),
|
|
1485
|
+
h('a', { className: 'eng-link', href, target: '_blank', rel: 'noopener noreferrer' }, t('feedbackIssue')),
|
|
1486
|
+
t('feedbackMail'),
|
|
1487
|
+
h('span', { className: 'eng-email' }, EMAIL),
|
|
1488
|
+
h('button', { type: 'button', className: 'eng-btn eng-btn-small', onClick: copyAddress },
|
|
1489
|
+
t(copy === 'copied' ? 'copied' : 'copy'))),
|
|
1490
|
+
copy === 'copyFailed' ? h('p', { className: 'eng-feedback-note', role: 'status' }, t('copyFailed')) : null,
|
|
1491
|
+
h('p', { className: 'eng-feedback-note' }, t('feedbackNote')))
|
|
1492
|
+
}
|
|
1493
|
+
|
|
1494
|
+
/**
|
|
1495
|
+
* The sidebar's Memory page: a banner with the listing's numbers and two settings, then the
|
|
1496
|
+
* stores recall can use, their notes a row each, by type and by name as the user filters.
|
|
1497
|
+
*/
|
|
1498
|
+
function MemoryPage({ t }) {
|
|
1499
|
+
const { state, load } = useMemory()
|
|
1500
|
+
const [status, setStatus] = useState(undefined)
|
|
1501
|
+
const [query, setQuery] = useState('')
|
|
1502
|
+
const [kind, setKind] = useState(undefined)
|
|
1503
|
+
const alive = useRef(true)
|
|
1504
|
+
useEffect(() => () => { alive.current = false }, [])
|
|
1505
|
+
|
|
1506
|
+
const open = async (store, file, archive) => {
|
|
1507
|
+
setStatus(undefined)
|
|
1508
|
+
let reply
|
|
1509
|
+
try {
|
|
1510
|
+
const response = await request(MEMORY_API, {
|
|
1511
|
+
method: 'POST',
|
|
1512
|
+
headers: { 'content-type': 'application/json' },
|
|
1513
|
+
body: JSON.stringify({ store: store.id, ...(file === undefined ? {} : { file }), ...(archive ? { archive: true } : {}) }),
|
|
1514
|
+
})
|
|
1515
|
+
reply = response.body ?? { ok: false, error: 'failed', message: `HTTP ${response.status}` }
|
|
1516
|
+
} catch (error) {
|
|
1517
|
+
reply = { ok: false, error: 'failed', message: String(error?.message ?? error) }
|
|
1518
|
+
}
|
|
1519
|
+
if (!alive.current) return
|
|
1520
|
+
// a file shown in its folder rather than opened (an index not named .md) is said to be
|
|
1521
|
+
setStatus(reply.ok ? { tone: 'ok', text: file === undefined ? t('opened', { name: legible(store.dir) })
|
|
1522
|
+
: t(reply.revealed === true ? 'revealed' : 'opened', { name: legible(nameOf(file)) }) }
|
|
1523
|
+
: Object.hasOwn(OPEN_FAILURES, reply.error) ? { tone: 'error', text: t(OPEN_FAILURES[reply.error]) }
|
|
1524
|
+
: { tone: 'error', text: t('openFailed', { reason: reply.message ?? reply.error ?? '' }) })
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1527
|
+
const data = state.phase === 'ready' ? state.data : undefined
|
|
1528
|
+
const canOpen = data?.canOpen === true
|
|
1529
|
+
// a type a refresh left with nothing is no longer a filter, nor one again when it returns
|
|
1530
|
+
const present = data === undefined || kind === undefined ||
|
|
1531
|
+
data.stores.some((store) => store.notes.some((note) => note.type === kind))
|
|
1532
|
+
useEffect(() => { if (!present) setKind(undefined) }, [present])
|
|
1533
|
+
// a name filter over what was listed: case- and width-insensitive, the .md left out — by
|
|
1534
|
+
// the name as it is or as the page shows it (legible), so what is on the page can be typed
|
|
1535
|
+
const needle = query.trim().normalize('NFKC').toLowerCase()
|
|
1536
|
+
const match = needle === '' ? undefined
|
|
1537
|
+
: (file) => [nameOf(file), legible(nameOf(file))]
|
|
1538
|
+
.some((name) => name.normalize('NFKC').toLowerCase().includes(needle))
|
|
1539
|
+
let body
|
|
1540
|
+
if (state.phase === 'loading') body = h('p', { className: 'eng-note' }, t('listing'))
|
|
1541
|
+
else if (state.phase === 'error') body = h('div', { className: 'eng-banner', 'data-tone': 'error' }, t(state.reason))
|
|
1542
|
+
else {
|
|
1543
|
+
const notes = data.stores.flatMap((store) => store.notes)
|
|
1544
|
+
const archived = data.stores.reduce((sum, store) => sum + store.archive.length, 0)
|
|
1545
|
+
const counts = TYPES.map((type) => [type, notes.filter((note) => note.type === type).length])
|
|
1546
|
+
.filter(([, count]) => count > 0)
|
|
1547
|
+
const shown = present ? kind : undefined
|
|
1548
|
+
const tab = (type, label, count) => h('button', { type: 'button', className: 'eng-tab', key: type ?? 'all',
|
|
1549
|
+
'data-type': type ?? 'all', 'aria-pressed': shown === type, onClick: () => setKind(type) },
|
|
1550
|
+
label, h('span', { className: 'eng-tab-count' }, String(count)))
|
|
1551
|
+
const matched = match === undefined ? 0 : data.stores.reduce((sum, store) => sum +
|
|
1552
|
+
store.notes.filter((note) => (shown === undefined || note.type === shown) && match(note.name)).length +
|
|
1553
|
+
(shown === undefined ? store.archive.filter(match).length : 0), 0)
|
|
1554
|
+
body = [
|
|
1555
|
+
data.pinned === 'relative' ? h('p', { className: 'eng-note', key: 'pinned' }, t('pinnedRelative')) : null,
|
|
1556
|
+
data.location !== undefined ? h('p', { className: 'eng-note', key: 'location' }, t('locationUnknown')) : null,
|
|
1557
|
+
data.stores.length === 0 && data.pinned === undefined && data.location === undefined &&
|
|
1558
|
+
!(data.unreadable > 0) && data.more !== true
|
|
1559
|
+
? h(NoMemory, { key: 'empty', t, onMoved: load })
|
|
1560
|
+
// projects' stores listed, the global one not made yet: still to be moved from here
|
|
1561
|
+
: data.stores.length > 0 && data.global === 'absent'
|
|
1562
|
+
? h(NoMemory, { key: 'global', t, onMoved: load, note: 'global' }) : null,
|
|
1563
|
+
notes.length + archived > 0 ? h('div', { className: 'eng-toolbar', key: 'toolbar' },
|
|
1564
|
+
h('div', { className: 'eng-tabs', role: 'group', 'aria-label': t('typeLabel') },
|
|
1565
|
+
tab(undefined, t('typeAll'), notes.length),
|
|
1566
|
+
...counts.map(([type, count]) => tab(type, t(typeKey(type)), count))),
|
|
1567
|
+
h('label', { className: 'eng-search' },
|
|
1568
|
+
icon('search', 15),
|
|
1569
|
+
h('input', { type: 'search', className: 'eng-input', value: query, placeholder: t('filterPlaceholder'),
|
|
1570
|
+
'aria-label': t('filterLabel'), onChange: (event) => setQuery(event.target.value) }))) : null,
|
|
1571
|
+
match === undefined ? null : h('p', { className: 'eng-filter-count', key: 'count', role: 'status',
|
|
1572
|
+
'aria-live': 'polite' }, t('filterCount', { count: matched })),
|
|
1573
|
+
...data.stores.map((store) => h(StoreSection, { key: store.id, store, cap: data.cap, canOpen, open, match, onMoved: load,
|
|
1574
|
+
kind: shown, now: state.at, t })),
|
|
1575
|
+
data.more ? h('p', { className: 'eng-note', key: 'more' }, t('more')) : null,
|
|
1576
|
+
]
|
|
1577
|
+
}
|
|
1578
|
+
return h('div', { className: 'eng-memory' },
|
|
1579
|
+
h(Hero, { data, at: state.at, refresh: () => { setStatus(undefined); load() }, t }),
|
|
1580
|
+
data === undefined ? null : h(Caveats, { data, t }),
|
|
1581
|
+
status ? h('div', { className: 'eng-banner', 'data-tone': status.tone, role: 'status' }, status.text) : null,
|
|
1582
|
+
data !== undefined && !canOpen && data.stores.length > 0 ? h('p', { className: 'eng-note' }, t('openUnavailable')) : null,
|
|
1583
|
+
body,
|
|
1584
|
+
h(HowTo, { open: data !== undefined && data.pinned !== 'relative' && data.more !== true &&
|
|
1585
|
+
!(data.unreadable > 0) && !data.stores.some((store) => hasMemory(store) || readInPart(store)), t }),
|
|
1586
|
+
h(Feedback, { t }))
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
/** The sidebar entry's icon: the logo, [[ ]] around a cursor, drawn in the row's own colour
|
|
1590
|
+
* (so it follows dsh's light and dark themes) at the size it asks for. */
|
|
1591
|
+
function MemoryIcon({ size }) {
|
|
1592
|
+
return h('svg', { width: size, height: size, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor',
|
|
1593
|
+
strokeWidth: 1.8, strokeLinecap: 'round', strokeLinejoin: 'round', 'aria-hidden': true },
|
|
1594
|
+
h('path', { d: 'M5.1 3.5H2.5v17h2.6M9.2 3.5H6.6v17h2.6' }),
|
|
1595
|
+
h('path', { d: 'M18.9 3.5h2.6v17h-2.6M14.8 3.5h2.6v17h-2.6' }),
|
|
1596
|
+
h('rect', { x: 10.4, y: 7, width: 3.2, height: 10, rx: 1, fill: 'currentColor', stroke: 'none' }))
|
|
1597
|
+
}
|
|
1598
|
+
|
|
1599
|
+
return {
|
|
1600
|
+
inject: ['slots', 'locale'],
|
|
1601
|
+
apply(ctx) {
|
|
1602
|
+
ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'dsh-engramory: dictionaries')
|
|
1603
|
+
ctx.effect(() => {
|
|
1604
|
+
const tag = document.createElement('style')
|
|
1605
|
+
tag.dataset.plugin = 'dsh-engramory'
|
|
1606
|
+
tag.dataset.pluginCss = 'dsh-engramory/settings.css'
|
|
1607
|
+
tag.textContent = CSS
|
|
1608
|
+
document.head.appendChild(tag)
|
|
1609
|
+
return () => tag.remove()
|
|
1610
|
+
}, 'dsh-engramory: styles')
|
|
1611
|
+
ctx.slots.inject('plugins.bundle.config', () => ctx.slots.register({
|
|
1612
|
+
name: 'plugins.bundle.config',
|
|
1613
|
+
key: PACKAGE,
|
|
1614
|
+
locale: NS,
|
|
1615
|
+
}, SettingsPage))
|
|
1616
|
+
const t = ctx.locale.bind(NS)
|
|
1617
|
+
ctx.slots.inject('main', () => ctx.slots.register({
|
|
1618
|
+
name: 'main',
|
|
1619
|
+
key: PANEL,
|
|
1620
|
+
locale: NS,
|
|
1621
|
+
}, MemoryPage))
|
|
1622
|
+
ctx.slots.inject('sidebar.panellist', () => ctx.slots.register({
|
|
1623
|
+
name: 'sidebar.panellist',
|
|
1624
|
+
id: PANEL,
|
|
1625
|
+
// after dsh's own entries (Plugins 0, Automations 10)
|
|
1626
|
+
order: 20,
|
|
1627
|
+
locale: NS,
|
|
1628
|
+
label: () => t('panel'),
|
|
1629
|
+
}, MemoryIcon))
|
|
1630
|
+
},
|
|
1631
|
+
}
|
|
1632
|
+
},
|
|
1633
|
+
})
|