dsh-zju-lecture-note 2.2.6 → 2.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -1
- package/README.md +37 -31
- package/SECURITY.md +101 -36
- package/docs/technical.md +37 -24
- package/lib/bridge.js +278 -79
- package/lib/client.js +907 -758
- package/lib/index.js +232 -61
- package/lib/tools.js +26 -1
- package/lib/tools.schema.json +21 -1
- package/mcp_server.py +102 -24
- package/package.json +1 -1
- package/skills/scholia-notes/references/prelude.typ +9 -1
- package/skills/scholia-notes.manifest.json +3 -3
- package/skills/zju-lecture-summarizer/SKILL.md +1 -1
- package/skills/zju-lecture-summarizer/SLIDES.md +5 -3
- package/skills/zju-lecture-summarizer-help/SKILL.md +2 -2
- package/skills/zju-lecture-summarizer-help.manifest.json +4 -4
- package/skills/zju-lecture-summarizer-login/SKILL.md +1 -1
- package/skills/zju-lecture-summarizer-login.manifest.json +4 -4
- package/skills/zju-lecture-summarizer.manifest.json +6 -6
- package/zju_lecture/browser_login.py +17 -6
- package/zju_lecture/cli.py +26 -0
- package/zju_lecture/client.py +95 -18
- package/zju_lecture/courseware.py +37 -2
- package/zju_lecture/deps.py +98 -17
- package/zju_lecture/note_lint.py +34 -10
- package/zju_lecture/paths.py +57 -2
- package/zju_lecture/prelude.typ +9 -1
- package/zju_lecture/slides.py +73 -35
- package/zju_lecture/study_notes.py +36 -4
package/lib/client.js
CHANGED
|
@@ -1,758 +1,907 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Browser half of dsh-zju-lecture-note.
|
|
3
|
-
*
|
|
4
|
-
* The same page is mounted twice, from two seats the shell owns:
|
|
5
|
-
*
|
|
6
|
-
* - `settings.section` — 设置 → 浙大智云课堂讲义 (the deep link), id `zju-lecture`;
|
|
7
|
-
* - `sidebar.panellist` + `main` — the left-column row 智云讲义, whose click
|
|
8
|
-
* selects the global panel registered under the same id.
|
|
9
|
-
*
|
|
10
|
-
* Both render one component over one `PipelineSettings` controller, so a switch
|
|
11
|
-
* moved in either place shows up in the other without a reload.
|
|
12
|
-
*
|
|
13
|
-
* The page is built around the actual pipeline — 字幕 → 讲义 → PDF — and every
|
|
14
|
-
* optional module is a separate switch with its own dependency and cost, so a
|
|
15
|
-
* user can see what they are turning on before they turn it on.
|
|
16
|
-
*
|
|
17
|
-
* - `renderPdf` auto-typeset the written note into a reading PDF
|
|
18
|
-
* - `enableStudyNotes` fill-in study notes (+ scholia-notes Skill)
|
|
19
|
-
* - `enableSlides` projected-slide capture
|
|
20
|
-
* - `embedSlideImages` reference those screenshots in the note
|
|
21
|
-
* - `enableLoginTools` video URL / Edge-cookie helpers
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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
|
-
studyTitle2: 'Fill-in study notes',
|
|
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
|
-
'.zju-
|
|
214
|
-
'.zju-
|
|
215
|
-
'.zju-
|
|
216
|
-
'.zju-hero-
|
|
217
|
-
'.zju-hero-
|
|
218
|
-
'.zju-hero-
|
|
219
|
-
'.zju-
|
|
220
|
-
'.zju-pill{
|
|
221
|
-
'.zju-
|
|
222
|
-
'.zju-
|
|
223
|
-
'.zju-step{
|
|
224
|
-
'.zju-
|
|
225
|
-
'.zju-
|
|
226
|
-
'.zju-presets{
|
|
227
|
-
'.zju-
|
|
228
|
-
'.zju-preset
|
|
229
|
-
'.zju-preset:
|
|
230
|
-
'.zju-preset:
|
|
231
|
-
'.zju-preset
|
|
232
|
-
'.zju-preset-
|
|
233
|
-
'.zju-
|
|
234
|
-
'.zju-
|
|
235
|
-
'.zju-
|
|
236
|
-
'.zju-
|
|
237
|
-
'.zju-
|
|
238
|
-
'.zju-
|
|
239
|
-
'.zju-
|
|
240
|
-
'.zju-
|
|
241
|
-
'.zju-row:
|
|
242
|
-
'.zju-row.is-child{padding-left:
|
|
243
|
-
'.zju-copy{min-width:0}',
|
|
244
|
-
'.zju-row-title{font-size:13px;line-height:19px;color:var(--dsw-alias-label-primary)}',
|
|
245
|
-
'.zju-row-hint{margin-top:3px;font-size:11px;line-height:17px;color:var(--dsw-alias-label-secondary)}',
|
|
246
|
-
'.zju-
|
|
247
|
-
'.zju-
|
|
248
|
-
'.zju-
|
|
249
|
-
'.zju-
|
|
250
|
-
'.zju-
|
|
251
|
-
'.zju-
|
|
252
|
-
'.zju-
|
|
253
|
-
'.zju-
|
|
254
|
-
'.zju-
|
|
255
|
-
'.zju-
|
|
256
|
-
'.zju-
|
|
257
|
-
'.zju-
|
|
258
|
-
'
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
this.
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
this.
|
|
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
|
-
this.
|
|
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
|
-
this
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
this.
|
|
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
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
h(
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
),
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
h('div', { className: 'zju-
|
|
547
|
-
h(
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
h(
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
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
|
-
h(
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
h('div', { className: 'zju-
|
|
637
|
-
h('
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
),
|
|
641
|
-
h(
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Browser half of dsh-zju-lecture-note.
|
|
3
|
+
*
|
|
4
|
+
* The same page is mounted twice, from two seats the shell owns:
|
|
5
|
+
*
|
|
6
|
+
* - `settings.section` — 设置 → 浙大智云课堂讲义 (the deep link), id `zju-lecture`;
|
|
7
|
+
* - `sidebar.panellist` + `main` — the left-column row 智云讲义, whose click
|
|
8
|
+
* selects the global panel registered under the same id.
|
|
9
|
+
*
|
|
10
|
+
* Both render one component over one `PipelineSettings` controller, so a switch
|
|
11
|
+
* moved in either place shows up in the other without a reload.
|
|
12
|
+
*
|
|
13
|
+
* The page is built around the actual pipeline — 字幕 → 讲义 → PDF — and every
|
|
14
|
+
* optional module is a separate switch with its own dependency and cost, so a
|
|
15
|
+
* user can see what they are turning on before they turn it on.
|
|
16
|
+
*
|
|
17
|
+
* - `renderPdf` auto-typeset the written note into a reading PDF
|
|
18
|
+
* - `enableStudyNotes` fill-in study notes (+ scholia-notes Skill)
|
|
19
|
+
* - `enableSlides` projected-slide capture
|
|
20
|
+
* - `embedSlideImages` reference those screenshots in the note
|
|
21
|
+
* - `enableLoginTools` video URL / Edge-cookie helpers
|
|
22
|
+
* - `typstAutoInstall` install Typst on first use
|
|
23
|
+
* - `typstPath` / `typstMirror` pin the executable or a download mirror
|
|
24
|
+
* - `python` / `timeoutMs` / `registerSkill` advanced interpreter controls
|
|
25
|
+
*
|
|
26
|
+
* Volatile values are live: the plugin re-syncs tools, Skills, the prompt and
|
|
27
|
+
* its Python children when one is saved, so the agent reads the new setting on
|
|
28
|
+
* its next turn. The page therefore does not ask the user to restart dsh for a
|
|
29
|
+
* switch — only a plugin install/update still needs a restart.
|
|
30
|
+
*
|
|
31
|
+
* The Host exposes only `Config` fields marked `.volatile()`. Writes go
|
|
32
|
+
* through the shared `configForms` scope, so they carry the current revision
|
|
33
|
+
* and are refused rather than clobbering a newer value. Plain JavaScript,
|
|
34
|
+
* React from the host module table, no build step.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
window.__ModuleLoader__.load({
|
|
38
|
+
id: 'dsh-zju-lecture-note',
|
|
39
|
+
factory(require) {
|
|
40
|
+
const React = require('react')
|
|
41
|
+
const h = React.createElement
|
|
42
|
+
|
|
43
|
+
const NS = 'dsh-zju-lecture-note'
|
|
44
|
+
/**
|
|
45
|
+
* One id for both left-column seats: `sidebar.panellist` renders the row,
|
|
46
|
+
* `main` renders the page the row opens. The sidebar dispatches
|
|
47
|
+
* `ctx.layout.selectPanel(id)`, so the two registrations must agree.
|
|
48
|
+
*/
|
|
49
|
+
const PANEL_ID = 'zju-lecture'
|
|
50
|
+
const CANDIDATE_NAMESPACES = [
|
|
51
|
+
'include:dsh-zju-lecture-note',
|
|
52
|
+
'dsh-zju-lecture-note',
|
|
53
|
+
]
|
|
54
|
+
|
|
55
|
+
const en = {
|
|
56
|
+
sectionTitle: 'ZJU classroom lecture notes',
|
|
57
|
+
panelLabel: 'ZJU notes',
|
|
58
|
+
panelNote: 'Also available in Settings → ZJU classroom lecture notes.',
|
|
59
|
+
eyebrow: 'ZJU · CLASSROOM',
|
|
60
|
+
heroTitle: 'Turn a replay into review-ready notes',
|
|
61
|
+
heroBody: 'Transcripts are anonymous first; 401/403 retries once with the local login. PDF typesetting runs locally.',
|
|
62
|
+
pipelineTranscript: 'Transcript',
|
|
63
|
+
pipelineNotes: 'Markdown notes',
|
|
64
|
+
pipelinePdf: 'Reading PDF',
|
|
65
|
+
toolCountLabel: 'tools',
|
|
66
|
+
toolsNowPrefix: 'This config registers',
|
|
67
|
+
toolsNowSuffix: 'tools',
|
|
68
|
+
pdfOn: 'PDF on',
|
|
69
|
+
pdfOff: 'PDF off',
|
|
70
|
+
presetsTitle: 'Presets',
|
|
71
|
+
presetToken: 'Token saver',
|
|
72
|
+
presetStudy: 'Study mode',
|
|
73
|
+
presetFull: 'Everything',
|
|
74
|
+
presetTokenHint: 'PDF only',
|
|
75
|
+
presetStudyHint: 'PDF + fill-in notes',
|
|
76
|
+
presetFullHint: 'All modules',
|
|
77
|
+
coreTitle: 'Core pipeline',
|
|
78
|
+
coreBadge: 'Always on',
|
|
79
|
+
coreRowTitle: 'Transcript → notes → linting',
|
|
80
|
+
coreRowHint: 'No configuration required.',
|
|
81
|
+
outputTitle: 'Reading output',
|
|
82
|
+
outputBadge: 'Recommended',
|
|
83
|
+
outputBody: 'Markdown is the source; the PDF is the reading copy.',
|
|
84
|
+
pdfTitle: 'Auto-typeset PDF',
|
|
85
|
+
pdfHint: 'After each note write, typeset the same Markdown into a print-ready PDF. Failure leaves the Markdown intact.',
|
|
86
|
+
envTitle: 'Environment',
|
|
87
|
+
envBadge: 'Session check',
|
|
88
|
+
envBody: 'Typst, the CJK fonts and the Typst packages are prepared automatically.',
|
|
89
|
+
envAutoTitle: 'Install Typst automatically',
|
|
90
|
+
envAutoHint: 'Downloads the official release on first use (~20 MB) after SHA256 verification. Off: print install instructions instead.',
|
|
91
|
+
envPathTitle: 'Typst executable',
|
|
92
|
+
envPathHint: 'Leave empty to auto-detect; set an absolute path to pin a version.',
|
|
93
|
+
envPathPlaceholder: 'Empty = auto-detect',
|
|
94
|
+
envMirrorTitle: 'Typst download mirror',
|
|
95
|
+
envMirrorHint: 'Prefix for the GitHub release URL, e.g. https://ghfast.top/.',
|
|
96
|
+
envMirrorPlaceholder: 'https://ghfast.top/',
|
|
97
|
+
envHint: 'Run zju_doctor for actual versions and paths.',
|
|
98
|
+
studyTitle: 'Active recall',
|
|
99
|
+
studyBadge: 'Optional',
|
|
100
|
+
studyTitle2: 'Fill-in study notes',
|
|
101
|
+
studyHint: 'Adds zju_build_study_notes and the scholia-notes Skill.',
|
|
102
|
+
slidesTitle: 'Classroom projection',
|
|
103
|
+
slidesBadge: 'Needs login',
|
|
104
|
+
slidesTitle2: 'Capture projected slides',
|
|
105
|
+
slidesHint: 'Registers zju_fetch_slides. The transcript path is unaffected.',
|
|
106
|
+
imagesTitle: 'Reference screenshots in notes',
|
|
107
|
+
imagesHint: 'Only when capture is on; adds download time and vision tokens.',
|
|
108
|
+
dependency: 'Turn on capture first.',
|
|
109
|
+
loginTitle: 'Login helpers',
|
|
110
|
+
loginBadge: 'On demand',
|
|
111
|
+
loginBody: 'Sign-in is always available: run /zju-lecture-summarizer-login or ask the agent. A separate browser window is used; only the session is stored locally.',
|
|
112
|
+
loginTitle2: 'Video URL and credential tools',
|
|
113
|
+
loginHint: 'Adds zju_get_video_url and zju_read_browser_cookie. zju_login is unaffected.',
|
|
114
|
+
advancedTitle: 'Advanced',
|
|
115
|
+
advancedBadge: 'Rarely needed',
|
|
116
|
+
pythonTitle: 'Python interpreter',
|
|
117
|
+
pythonHint: 'Empty tries the bundled Python, then py -3, python and python3.',
|
|
118
|
+
pythonPlaceholder: 'Empty = auto-detect',
|
|
119
|
+
timeoutTitle: 'Tool timeout (ms)',
|
|
120
|
+
timeoutHint: 'Default 120000. PDF tools use at least 300000; downloads and login at least 600000.',
|
|
121
|
+
registerSkillTitle: 'Register bundled Skills',
|
|
122
|
+
registerSkillHint: 'Off hides the course workflow; tools stay available.',
|
|
123
|
+
toolsNowHint: 'Saved live; no restart required.',
|
|
124
|
+
saveIdle: '',
|
|
125
|
+
saveSaving: 'Saving…',
|
|
126
|
+
saveDone: 'Saved',
|
|
127
|
+
saveFailed: 'Not saved. Try again.',
|
|
128
|
+
loading: 'Loading this setting…',
|
|
129
|
+
unavailable: 'This setting is not available in the current profile.',
|
|
130
|
+
readOnly: 'This deployment stores plugin settings read-only.',
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const zh = {
|
|
134
|
+
sectionTitle: '浙大智云课堂讲义',
|
|
135
|
+
panelLabel: '智云讲义',
|
|
136
|
+
panelNote: '也可在「设置 → 浙大智云课堂讲义」中打开。',
|
|
137
|
+
eyebrow: 'ZJU · 智云课堂',
|
|
138
|
+
heroTitle: '把课程回放整理成可复习的讲义',
|
|
139
|
+
heroBody: '字幕先匿名;401/403 时用本机登录态重试一次。PDF 在本地排版。',
|
|
140
|
+
pipelineTranscript: '字幕',
|
|
141
|
+
pipelineNotes: 'Markdown 讲义',
|
|
142
|
+
pipelinePdf: '阅读 PDF',
|
|
143
|
+
toolCountLabel: '个工具',
|
|
144
|
+
toolsNowPrefix: '当前配置注册',
|
|
145
|
+
toolsNowSuffix: '个工具',
|
|
146
|
+
pdfOn: 'PDF 开',
|
|
147
|
+
pdfOff: 'PDF 关',
|
|
148
|
+
presetsTitle: '一键配置',
|
|
149
|
+
presetToken: '省 Token',
|
|
150
|
+
presetStudy: '复习模式',
|
|
151
|
+
presetFull: '全功能',
|
|
152
|
+
presetTokenHint: '仅 PDF',
|
|
153
|
+
presetStudyHint: 'PDF + 填空笔记',
|
|
154
|
+
presetFullHint: '全部模块',
|
|
155
|
+
coreTitle: '核心链路',
|
|
156
|
+
coreBadge: '始终开启',
|
|
157
|
+
coreRowTitle: '字幕 → 讲义 → 校验',
|
|
158
|
+
coreRowHint: '无需配置。',
|
|
159
|
+
outputTitle: '阅读输出',
|
|
160
|
+
outputBadge: '推荐',
|
|
161
|
+
outputBody: 'Markdown 是源文件,PDF 是阅读版。',
|
|
162
|
+
pdfTitle: '自动排版 PDF',
|
|
163
|
+
pdfHint: '写入讲义后生成同名 PDF;失败不影响 Markdown。',
|
|
164
|
+
envTitle: '环境',
|
|
165
|
+
envBadge: '会话内可查',
|
|
166
|
+
envBody: 'Typst、中文字体与 Typst 包自动准备。',
|
|
167
|
+
envAutoTitle: '自动安装 Typst',
|
|
168
|
+
envAutoHint: '首次使用时下载官方版本(约 20 MB)并校验 SHA256;关闭后只提示安装命令。',
|
|
169
|
+
envPathTitle: 'Typst 可执行文件',
|
|
170
|
+
envPathHint: '留空自动查找;填写绝对路径可固定版本。',
|
|
171
|
+
envPathPlaceholder: '留空 = 自动查找',
|
|
172
|
+
envMirrorTitle: 'Typst 下载镜像',
|
|
173
|
+
envMirrorHint: 'GitHub Release 前缀,例如 https://ghfast.top/。',
|
|
174
|
+
envMirrorPlaceholder: 'https://ghfast.top/',
|
|
175
|
+
envHint: '运行 zju_doctor 查看实际版本与路径。',
|
|
176
|
+
studyTitle: '主动回忆',
|
|
177
|
+
studyBadge: '可选',
|
|
178
|
+
studyTitle2: '填空式学习笔记',
|
|
179
|
+
studyHint: '额外注册 zju_build_study_notes 与 scholia-notes Skill。',
|
|
180
|
+
slidesTitle: '课堂投影',
|
|
181
|
+
slidesBadge: '需登录',
|
|
182
|
+
slidesTitle2: '抓取投影截图',
|
|
183
|
+
slidesHint: '注册 zju_fetch_slides;字幕链路不受影响。',
|
|
184
|
+
imagesTitle: '把截图引用进讲义',
|
|
185
|
+
imagesHint: '仅在投影抓取开启时生效;增加下载时间与视觉 token。',
|
|
186
|
+
dependency: '请先开启投影抓取。',
|
|
187
|
+
loginTitle: '登录辅助',
|
|
188
|
+
loginBadge: '按需',
|
|
189
|
+
loginBody: '登录入口始终可用:输入 /zju-lecture-summarizer-login 或让 Agent 登录。使用独立浏览器窗口,只在本机保存登录态。',
|
|
190
|
+
loginTitle2: '视频直链与登录态工具',
|
|
191
|
+
loginHint: '仅额外注册 zju_get_video_url 与 zju_read_browser_cookie;zju_login 不受影响。',
|
|
192
|
+
advancedTitle: '高级',
|
|
193
|
+
advancedBadge: '按需调整',
|
|
194
|
+
pythonTitle: 'Python 解释器',
|
|
195
|
+
pythonHint: '留空依次尝试自带 Python、py -3、python、python3。',
|
|
196
|
+
pythonPlaceholder: '留空 = 自动查找',
|
|
197
|
+
timeoutTitle: '工具超时(毫秒)',
|
|
198
|
+
timeoutHint: '默认 120000;PDF 工具至少 300000,下载与登录至少 600000。',
|
|
199
|
+
registerSkillTitle: '注册随包 Skill',
|
|
200
|
+
registerSkillHint: '关闭后不加载课程工作流;工具仍可用。',
|
|
201
|
+
toolsNowHint: '保存后立即同步,无需重启。',
|
|
202
|
+
saveIdle: '',
|
|
203
|
+
saveSaving: '正在保存…',
|
|
204
|
+
saveDone: '已保存',
|
|
205
|
+
saveFailed: '未保存,请重试。',
|
|
206
|
+
loading: '正在加载该设置…',
|
|
207
|
+
unavailable: '当前 profile 未提供该设置。',
|
|
208
|
+
readOnly: '本部署的插件设置为只读。',
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const CSS = [
|
|
212
|
+
'.zju-settings-page{display:flex;flex-direction:column;gap:14px;width:100%;max-width:760px;box-sizing:border-box}',
|
|
213
|
+
'.zju-hero{position:relative;overflow:hidden;box-sizing:border-box;padding:20px 20px 18px;border:1px solid var(--dsw-alias-border-l1);border-radius:14px;background-color:var(--dsw-alias-bg-layer-1);background-image:linear-gradient(135deg,color-mix(in srgb,var(--dsw-alias-brand-primary) 10%,var(--dsw-alias-bg-layer-1)) 0%,var(--dsw-alias-bg-layer-1) 52%,color-mix(in srgb,var(--dsw-alias-brand-primary) 5%,var(--dsw-alias-bg-layer-1)) 100%)}',
|
|
214
|
+
'.zju-eyebrow{font-size:11px;line-height:16px;letter-spacing:.16em;color:var(--dsw-alias-brand-primary);font-weight:600}',
|
|
215
|
+
'.zju-hero-title{margin:6px 0 0;font-size:20px;line-height:28px;font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
216
|
+
'.zju-hero-body{margin:6px 0 0;max-width:54em;font-size:12px;line-height:19px;color:var(--dsw-alias-label-secondary)}',
|
|
217
|
+
'.zju-hero-top{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}',
|
|
218
|
+
'.zju-hero-badges{display:flex;flex-wrap:wrap;gap:6px;justify-content:flex-end;flex:none}',
|
|
219
|
+
'.zju-pill{display:inline-flex;align-items:center;height:22px;padding:0 8px;border:1px solid var(--dsw-alias-border-l2);border-radius:999px;background:transparent;font-size:11px;line-height:20px;color:var(--dsw-alias-label-secondary);white-space:nowrap}',
|
|
220
|
+
'.zju-pill.is-on{border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 45%,transparent);color:var(--dsw-alias-brand-primary);background:color-mix(in srgb,var(--dsw-alias-brand-primary) 8%,transparent)}',
|
|
221
|
+
'.zju-pipeline{display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin-top:12px}',
|
|
222
|
+
'.zju-step{display:inline-flex;align-items:center;height:26px;padding:0 10px;border-radius:8px;border:1px solid var(--dsw-alias-border-l2);background:transparent;font-size:12px;line-height:24px;color:var(--dsw-alias-label-primary)}',
|
|
223
|
+
'.zju-step.is-off{color:var(--dsw-alias-label-tertiary);border-style:dashed;background:transparent}',
|
|
224
|
+
'.zju-arrow{font-size:12px;line-height:1;color:var(--dsw-alias-label-tertiary)}',
|
|
225
|
+
'.zju-presets{display:flex;align-items:center;gap:8px;flex-wrap:wrap}',
|
|
226
|
+
'.zju-presets-label{font-size:12px;color:var(--dsw-alias-label-secondary);margin-right:2px}',
|
|
227
|
+
'.zju-preset{display:inline-flex;flex-direction:column;align-items:flex-start;gap:1px;padding:6px 10px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;background:transparent;cursor:pointer;font:inherit;color:var(--dsw-alias-label-primary);text-align:left}',
|
|
228
|
+
'.zju-preset:hover:not(:disabled){border-color:color-mix(in srgb,var(--dsw-alias-brand-primary) 45%,var(--dsw-alias-border-l2));background:color-mix(in srgb,var(--dsw-alias-brand-primary) 5%,transparent)}',
|
|
229
|
+
'.zju-preset:disabled{opacity:.5;cursor:default}',
|
|
230
|
+
'.zju-preset:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}',
|
|
231
|
+
'.zju-preset-name{font-size:12px;line-height:17px;font-weight:500}',
|
|
232
|
+
'.zju-preset-hint{font-size:10px;line-height:14px;color:var(--dsw-alias-label-tertiary)}',
|
|
233
|
+
'.zju-groups{display:flex;flex-direction:column;border-top:1px solid color-mix(in srgb,var(--dsw-alias-label-tertiary) 26%,transparent)}',
|
|
234
|
+
'.zju-group{padding:16px 0 12px}',
|
|
235
|
+
'.zju-group + .zju-group{border-top:1px solid color-mix(in srgb,var(--dsw-alias-label-tertiary) 26%,transparent)}',
|
|
236
|
+
'.zju-group-head{display:flex;align-items:center;justify-content:space-between;gap:10px}',
|
|
237
|
+
'.zju-group-title{margin:0;font-size:13px;line-height:19px;font-weight:600;color:var(--dsw-alias-label-primary)}',
|
|
238
|
+
'.zju-group-body{margin:3px 0 0;font-size:11px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
239
|
+
'.zju-group-rows{padding-left:20px;padding-top:2px}',
|
|
240
|
+
'.zju-badge{flex:none;font-size:10px;line-height:15px;padding:0 6px;border-radius:5px;color:var(--dsw-alias-label-secondary);background:var(--dsw-alias-bg-layer-2)}',
|
|
241
|
+
'.zju-row{display:flex;justify-content:space-between;align-items:flex-start;gap:22px;padding:10px 0 0}',
|
|
242
|
+
'.zju-row.is-child{padding-left:20px}',
|
|
243
|
+
'.zju-copy{min-width:0}',
|
|
244
|
+
'.zju-row-title{font-size:13px;line-height:19px;color:var(--dsw-alias-label-primary)}',
|
|
245
|
+
'.zju-row-hint{margin-top:3px;font-size:11px;line-height:17px;color:var(--dsw-alias-label-secondary)}',
|
|
246
|
+
'.zju-field{flex:none;display:flex;align-items:center;gap:6px}',
|
|
247
|
+
'.zju-input{box-sizing:border-box;width:228px;height:30px;padding:0 8px;border:1px solid var(--dsw-alias-border-l2);border-radius:7px;background:var(--dsw-alias-bg-layer-1);color:var(--dsw-alias-label-primary);font:inherit;font-size:12px}',
|
|
248
|
+
'.zju-input::placeholder{color:var(--dsw-alias-label-tertiary)}',
|
|
249
|
+
'.zju-input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}',
|
|
250
|
+
'.zju-input:disabled{opacity:.45;cursor:default}',
|
|
251
|
+
'@media (max-width:560px){.zju-input{width:100%}.zju-field{width:100%}}',
|
|
252
|
+
'.zju-switch{position:relative;flex:none;width:36px;height:20px;padding:0;border:1px solid var(--dsw-alias-border-l2);border-radius:999px;background:var(--dsw-alias-bg-layer-2);cursor:pointer;transition:background-color .15s ease,border-color .15s ease}',
|
|
253
|
+
'.zju-switch[aria-checked="true"]{background:var(--dsw-alias-brand-primary);border-color:var(--dsw-alias-brand-primary)}',
|
|
254
|
+
'.zju-switch:disabled{opacity:.42;cursor:default}',
|
|
255
|
+
'.zju-switch:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}',
|
|
256
|
+
'.zju-knob{position:absolute;top:2px;left:2px;width:14px;height:14px;border-radius:50%;background:var(--dsw-alias-bg-layer-1);box-shadow:0 1px 2px rgba(0,0,0,.18);transition:left .15s ease}',
|
|
257
|
+
'.zju-switch[aria-checked="true"] .zju-knob{left:18px}',
|
|
258
|
+
'.zju-foot{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap;padding:0 2px;font-size:11px;line-height:17px;color:var(--dsw-alias-label-secondary)}',
|
|
259
|
+
'.zju-save[data-state="saved"]{color:var(--dsw-alias-state-success-primary)}',
|
|
260
|
+
'.zju-save[data-state="failed"]{color:var(--dsw-alias-state-error-primary)}',
|
|
261
|
+
'.zju-note{font-size:11px;line-height:17px;color:var(--dsw-alias-label-tertiary)}',
|
|
262
|
+
'.zju-panel{box-sizing:border-box;height:100%;overflow:auto;display:flex;justify-content:center;align-items:flex-start;padding:0 clamp(16px,3vw,32px) 40px}',
|
|
263
|
+
'.zju-panel-inner{box-sizing:border-box;width:100%;max-width:760px;padding-top:calc(20px + var(--dsh-frame-top-clearance,0px))}',
|
|
264
|
+
'@media (max-width:560px){.zju-hero-top{flex-direction:column}.zju-hero-badges{justify-content:flex-start}.zju-row{gap:12px}}',
|
|
265
|
+
].join('\n')
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* One settings controller, shared by every switch on the page.
|
|
269
|
+
*
|
|
270
|
+
* The Host serves configuration forms only for `Config` fields marked
|
|
271
|
+
* `.volatile()`. The mirror row is found by its namespace or by any known
|
|
272
|
+
* field in its schema, so this page keeps working when the bundle is
|
|
273
|
+
* composed under an `include:` entry id.
|
|
274
|
+
*/
|
|
275
|
+
class PipelineSettings {
|
|
276
|
+
constructor(ctx) {
|
|
277
|
+
this.ctx = ctx
|
|
278
|
+
this.listeners = new Set()
|
|
279
|
+
this.namespace = null
|
|
280
|
+
this.form = null
|
|
281
|
+
this.formUnsubscribe = null
|
|
282
|
+
this.mirror = ctx.configForms.describe()
|
|
283
|
+
this.snapshot = {
|
|
284
|
+
status: 'loading',
|
|
285
|
+
value: undefined,
|
|
286
|
+
writable: false,
|
|
287
|
+
revision: undefined,
|
|
288
|
+
error: null,
|
|
289
|
+
}
|
|
290
|
+
this.mirrorUnsubscribe = this.mirror.subscribe(() => this.sync())
|
|
291
|
+
void Promise.resolve(this.mirror.ensure()).catch(() => {})
|
|
292
|
+
this.sync()
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
subscribe = (listener) => {
|
|
296
|
+
this.listeners.add(listener)
|
|
297
|
+
return () => this.listeners.delete(listener)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
getSnapshot = () => this.snapshot
|
|
301
|
+
|
|
302
|
+
emit() {
|
|
303
|
+
for (const listener of [...this.listeners]) listener()
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
publish(snapshot) {
|
|
307
|
+
this.snapshot = snapshot
|
|
308
|
+
this.emit()
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
isOurs(row) {
|
|
312
|
+
if (!row || typeof row !== 'object') return false
|
|
313
|
+
if (CANDIDATE_NAMESPACES.includes(row.ns)) return true
|
|
314
|
+
if (typeof row.ns === 'string' && row.ns.includes('zju-lecture')) return true
|
|
315
|
+
const hasField = (value) => value && typeof value === 'object' && 'enableSlides' in value
|
|
316
|
+
if (hasField(row.value) || hasField(row.base)) return true
|
|
317
|
+
try {
|
|
318
|
+
return JSON.stringify(row.schema || '').includes('"enableSlides"')
|
|
319
|
+
} catch {
|
|
320
|
+
return false
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
sync() {
|
|
325
|
+
const view = this.mirror.getSnapshot()?.view
|
|
326
|
+
const rows = Array.isArray(view?.namespaces) ? view.namespaces : []
|
|
327
|
+
const row = rows.find((candidate) => this.isOurs(candidate))
|
|
328
|
+
if (!row) {
|
|
329
|
+
this.publish({
|
|
330
|
+
status: view === undefined ? 'loading' : 'unavailable',
|
|
331
|
+
value: undefined,
|
|
332
|
+
writable: false,
|
|
333
|
+
revision: undefined,
|
|
334
|
+
error: null,
|
|
335
|
+
})
|
|
336
|
+
return
|
|
337
|
+
}
|
|
338
|
+
if (row.ns !== this.namespace) {
|
|
339
|
+
this.namespace = row.ns
|
|
340
|
+
this.form = this.ctx.configForms.get(row.ns)
|
|
341
|
+
if (this.formUnsubscribe) this.formUnsubscribe()
|
|
342
|
+
this.formUnsubscribe = this.form.subscribe(() => this.publishForm())
|
|
343
|
+
}
|
|
344
|
+
this.publishForm()
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
publishForm() {
|
|
348
|
+
const form = this.form?.getSnapshot()
|
|
349
|
+
this.publish({
|
|
350
|
+
status: form?.status || 'unavailable',
|
|
351
|
+
value: form?.value || {},
|
|
352
|
+
writable: form?.writable === true,
|
|
353
|
+
revision: form?.revision,
|
|
354
|
+
error: this.snapshot.error || null,
|
|
355
|
+
})
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
async #writeOne(field, value) {
|
|
359
|
+
if (!this.form) return false
|
|
360
|
+
// `set` is the convenience path used by this plugin since 1.5.1;
|
|
361
|
+
// `mutate` is the lower-level scope API (revision-fenced batch). Try
|
|
362
|
+
// the convenience path first, fall back to one path-addressed op.
|
|
363
|
+
if (typeof this.form.set === 'function') {
|
|
364
|
+
return (await this.form.set(field, value)) !== false
|
|
365
|
+
}
|
|
366
|
+
if (typeof this.form.mutate === 'function') {
|
|
367
|
+
const current = this.form.getSnapshot()
|
|
368
|
+
const accepted = await this.form.mutate(
|
|
369
|
+
[{ op: 'set', path: field, value }],
|
|
370
|
+
current?.revision,
|
|
371
|
+
)
|
|
372
|
+
return accepted !== false
|
|
373
|
+
}
|
|
374
|
+
return false
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
async setField(field, value) {
|
|
378
|
+
try {
|
|
379
|
+
const accepted = await this.#writeOne(field, value)
|
|
380
|
+
this.publish({ ...this.snapshot, error: accepted ? null : 'saveFailed' })
|
|
381
|
+
return accepted
|
|
382
|
+
} catch {
|
|
383
|
+
this.publish({ ...this.snapshot, error: 'saveFailed' })
|
|
384
|
+
return false
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** Write several switches as one user action (preset button). */
|
|
389
|
+
async setFields(entries) {
|
|
390
|
+
// A batch is one revision-fenced write: the Host applies every field
|
|
391
|
+
// or none. Sequential writes could race a plugin reload between them.
|
|
392
|
+
if (this.form && typeof this.form.mutate === 'function') {
|
|
393
|
+
try {
|
|
394
|
+
const current = this.form.getSnapshot()
|
|
395
|
+
const ops = entries.map(([field, value]) => ({ op: 'set', path: field, value }))
|
|
396
|
+
const accepted = await this.form.mutate(ops, current?.revision)
|
|
397
|
+
if (accepted !== false) {
|
|
398
|
+
this.publish({ ...this.snapshot, error: null })
|
|
399
|
+
return true
|
|
400
|
+
}
|
|
401
|
+
} catch {
|
|
402
|
+
/* fall through to the per-field path */
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
for (const [field, value] of entries) {
|
|
406
|
+
try {
|
|
407
|
+
const accepted = await this.#writeOne(field, value)
|
|
408
|
+
if (!accepted) {
|
|
409
|
+
this.publish({ ...this.snapshot, error: 'saveFailed' })
|
|
410
|
+
return false
|
|
411
|
+
}
|
|
412
|
+
} catch {
|
|
413
|
+
this.publish({ ...this.snapshot, error: 'saveFailed' })
|
|
414
|
+
return false
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
this.publish({ ...this.snapshot, error: null })
|
|
418
|
+
return true
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
dispose() {
|
|
422
|
+
this.mirrorUnsubscribe?.()
|
|
423
|
+
this.formUnsubscribe?.()
|
|
424
|
+
this.listeners.clear()
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
function Toggle({ checked, disabled, label, onChange }) {
|
|
429
|
+
return h('button', {
|
|
430
|
+
type: 'button',
|
|
431
|
+
role: 'switch',
|
|
432
|
+
'aria-checked': checked ? 'true' : 'false',
|
|
433
|
+
'aria-label': label,
|
|
434
|
+
disabled,
|
|
435
|
+
className: 'zju-switch',
|
|
436
|
+
onClick: () => {
|
|
437
|
+
if (!disabled) onChange(!checked)
|
|
438
|
+
},
|
|
439
|
+
}, h('span', { className: 'zju-knob', 'aria-hidden': 'true' }))
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
/**
|
|
443
|
+
* One text or number input for the advanced settings.
|
|
444
|
+
*
|
|
445
|
+
* The field keeps a local draft so typing does not write to the Host on
|
|
446
|
+
* every keystroke; blur or Enter commits one revision-fenced write. A
|
|
447
|
+
* failed write leaves the previous value in the form snapshot, so the
|
|
448
|
+
* effect below resets the draft on the next render.
|
|
449
|
+
*/
|
|
450
|
+
function TextField({
|
|
451
|
+
label,
|
|
452
|
+
value,
|
|
453
|
+
placeholder,
|
|
454
|
+
disabled,
|
|
455
|
+
type = 'text',
|
|
456
|
+
min,
|
|
457
|
+
max,
|
|
458
|
+
step,
|
|
459
|
+
onCommit,
|
|
460
|
+
}) {
|
|
461
|
+
const [draft, setDraft] = React.useState(value ?? '')
|
|
462
|
+
React.useEffect(() => {
|
|
463
|
+
setDraft(value ?? '')
|
|
464
|
+
}, [value])
|
|
465
|
+
const commit = () => {
|
|
466
|
+
const text = String(draft).trim()
|
|
467
|
+
if (type === 'number') {
|
|
468
|
+
const number = Number(text)
|
|
469
|
+
if (!text || !Number.isFinite(number)) {
|
|
470
|
+
setDraft(value ?? '')
|
|
471
|
+
return
|
|
472
|
+
}
|
|
473
|
+
const clamped = Math.min(Number(max), Math.max(Number(min), Math.round(number)))
|
|
474
|
+
if (clamped !== Number(value)) onCommit(clamped)
|
|
475
|
+
else setDraft(String(value ?? ''))
|
|
476
|
+
return
|
|
477
|
+
}
|
|
478
|
+
if (text !== String(value ?? '')) onCommit(text)
|
|
479
|
+
}
|
|
480
|
+
return h('input', {
|
|
481
|
+
type,
|
|
482
|
+
className: 'zju-input',
|
|
483
|
+
value: draft,
|
|
484
|
+
placeholder,
|
|
485
|
+
disabled,
|
|
486
|
+
'aria-label': label,
|
|
487
|
+
min,
|
|
488
|
+
max,
|
|
489
|
+
step,
|
|
490
|
+
onChange: (event) => setDraft(event.target.value),
|
|
491
|
+
onBlur: commit,
|
|
492
|
+
onKeyDown: (event) => {
|
|
493
|
+
if (event.key === 'Enter') event.currentTarget.blur()
|
|
494
|
+
},
|
|
495
|
+
})
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
function useSettingsSnapshot(settings) {
|
|
499
|
+
const [snapshot, setSnapshot] = React.useState(settings.getSnapshot())
|
|
500
|
+
React.useEffect(() => {
|
|
501
|
+
setSnapshot(settings.getSnapshot())
|
|
502
|
+
return settings.subscribe(() => setSnapshot(settings.getSnapshot()))
|
|
503
|
+
}, [settings])
|
|
504
|
+
return snapshot
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
function useSaveState() {
|
|
508
|
+
const [state, setState] = React.useState('idle')
|
|
509
|
+
const run = async (action) => {
|
|
510
|
+
setState('saving')
|
|
511
|
+
const ok = await action()
|
|
512
|
+
setState(ok ? 'saved' : 'failed')
|
|
513
|
+
return ok
|
|
514
|
+
}
|
|
515
|
+
return [state, run]
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
function Row({ t, title, hint, checked, disabled, onChange }) {
|
|
519
|
+
return h('div', { className: 'zju-row' },
|
|
520
|
+
h('div', { className: 'zju-copy' },
|
|
521
|
+
h('div', { className: 'zju-row-title' }, t(title)),
|
|
522
|
+
h('div', { className: 'zju-row-hint' }, t(hint)),
|
|
523
|
+
),
|
|
524
|
+
h(Toggle, { checked, disabled, label: t(title), onChange }),
|
|
525
|
+
)
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function InputRow({
|
|
529
|
+
t,
|
|
530
|
+
title,
|
|
531
|
+
hint,
|
|
532
|
+
value,
|
|
533
|
+
placeholder,
|
|
534
|
+
type,
|
|
535
|
+
min,
|
|
536
|
+
max,
|
|
537
|
+
step,
|
|
538
|
+
disabled,
|
|
539
|
+
onCommit,
|
|
540
|
+
}) {
|
|
541
|
+
return h('div', { className: 'zju-row' },
|
|
542
|
+
h('div', { className: 'zju-copy' },
|
|
543
|
+
h('div', { className: 'zju-row-title' }, t(title)),
|
|
544
|
+
h('div', { className: 'zju-row-hint' }, t(hint)),
|
|
545
|
+
),
|
|
546
|
+
h('div', { className: 'zju-field' },
|
|
547
|
+
h(TextField, {
|
|
548
|
+
label: t(title),
|
|
549
|
+
value,
|
|
550
|
+
placeholder,
|
|
551
|
+
type,
|
|
552
|
+
min,
|
|
553
|
+
max,
|
|
554
|
+
step,
|
|
555
|
+
disabled,
|
|
556
|
+
onCommit,
|
|
557
|
+
}),
|
|
558
|
+
),
|
|
559
|
+
)
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
function Group({ title, body, badge, children }) {
|
|
563
|
+
return h('section', { className: 'zju-group' },
|
|
564
|
+
h('header', { className: 'zju-group-head' },
|
|
565
|
+
h('h3', { className: 'zju-group-title' }, title),
|
|
566
|
+
badge ? h('span', { className: 'zju-badge' }, badge) : null,
|
|
567
|
+
),
|
|
568
|
+
body ? h('p', { className: 'zju-group-body' }, body) : null,
|
|
569
|
+
h('div', { className: 'zju-group-rows' }, children),
|
|
570
|
+
)
|
|
571
|
+
}
|
|
572
|
+
|
|
573
|
+
function PipelineSection({ t, settings, asPage }) {
|
|
574
|
+
const snapshot = useSettingsSnapshot(settings)
|
|
575
|
+
const [saveState, runSave] = useSaveState()
|
|
576
|
+
const value = snapshot.value || {}
|
|
577
|
+
const enableSlides = value.enableSlides === true
|
|
578
|
+
const renderPdf = value.renderPdf !== false
|
|
579
|
+
const typstAutoInstall = value.typstAutoInstall !== false
|
|
580
|
+
const enableStudyNotes = value.enableStudyNotes === true
|
|
581
|
+
const enableLoginTools = value.enableLoginTools === true
|
|
582
|
+
const embedSlideImages = enableSlides && value.embedSlideImages === true
|
|
583
|
+
const registerSkill = value.registerSkill !== false
|
|
584
|
+
const python = typeof value.python === 'string' ? value.python : ''
|
|
585
|
+
const typstPath = typeof value.typstPath === 'string' ? value.typstPath : ''
|
|
586
|
+
const typstMirror = typeof value.typstMirror === 'string' ? value.typstMirror : ''
|
|
587
|
+
const timeoutMs = Number.isFinite(value.timeoutMs) ? value.timeoutMs : 120000
|
|
588
|
+
const ready = snapshot.status === 'ready'
|
|
589
|
+
const disabled = !ready || !snapshot.writable || saveState === 'saving'
|
|
590
|
+
const toolCount = 7
|
|
591
|
+
+ (enableStudyNotes ? 1 : 0)
|
|
592
|
+
+ (enableSlides ? 1 : 0)
|
|
593
|
+
+ (enableLoginTools ? 2 : 0)
|
|
594
|
+
const note = !ready && snapshot.status !== 'unavailable'
|
|
595
|
+
? t('loading')
|
|
596
|
+
: snapshot.status === 'unavailable'
|
|
597
|
+
? t('unavailable')
|
|
598
|
+
: ready && !snapshot.writable
|
|
599
|
+
? t('readOnly')
|
|
600
|
+
: null
|
|
601
|
+
const saveLabel = saveState === 'saving'
|
|
602
|
+
? t('saveSaving')
|
|
603
|
+
: saveState === 'saved'
|
|
604
|
+
? t('saveDone')
|
|
605
|
+
: saveState === 'failed'
|
|
606
|
+
? t('saveFailed')
|
|
607
|
+
: snapshot.error
|
|
608
|
+
? t('saveFailed')
|
|
609
|
+
: ''
|
|
610
|
+
|
|
611
|
+
const update = (field, next) => runSave(() => settings.setField(field, next))
|
|
612
|
+
|
|
613
|
+
const applyPreset = (preset) => runSave(async () => {
|
|
614
|
+
const sets = preset === 'token'
|
|
615
|
+
? [['renderPdf', true], ['enableStudyNotes', false], ['enableSlides', false], ['embedSlideImages', false], ['enableLoginTools', false]]
|
|
616
|
+
: preset === 'study'
|
|
617
|
+
? [['renderPdf', true], ['enableStudyNotes', true], ['enableSlides', false], ['embedSlideImages', false], ['enableLoginTools', false]]
|
|
618
|
+
: [['renderPdf', true], ['enableStudyNotes', true], ['enableSlides', true], ['embedSlideImages', true], ['enableLoginTools', true]]
|
|
619
|
+
return settings.setFields(sets)
|
|
620
|
+
})
|
|
621
|
+
|
|
622
|
+
return h('div', { className: 'zju-settings-page', 'data-zju-settings': 'pipeline' },
|
|
623
|
+
h('style', { 'data-plugin': '@plugin/dsh-zju-lecture-note' }, CSS),
|
|
624
|
+
h('header', { className: 'zju-hero' },
|
|
625
|
+
h('div', { className: 'zju-hero-top' },
|
|
626
|
+
h('div', null,
|
|
627
|
+
h('div', { className: 'zju-eyebrow' }, t('eyebrow')),
|
|
628
|
+
h(asPage ? 'h1' : 'h2', { className: 'zju-hero-title' }, t('heroTitle')),
|
|
629
|
+
h('p', { className: 'zju-hero-body' }, t('heroBody')),
|
|
630
|
+
),
|
|
631
|
+
h('div', { className: 'zju-hero-badges' },
|
|
632
|
+
h('span', { className: 'zju-pill' }, `${toolCount} ${t('toolCountLabel')}`),
|
|
633
|
+
h('span', { className: `zju-pill${renderPdf ? ' is-on' : ''}` }, renderPdf ? t('pdfOn') : t('pdfOff')),
|
|
634
|
+
),
|
|
635
|
+
),
|
|
636
|
+
h('div', { className: 'zju-pipeline', 'aria-hidden': 'true' },
|
|
637
|
+
h('span', { className: 'zju-step' }, t('pipelineTranscript')),
|
|
638
|
+
h('span', { className: 'zju-arrow' }, '→'),
|
|
639
|
+
h('span', { className: 'zju-step' }, t('pipelineNotes')),
|
|
640
|
+
h('span', { className: 'zju-arrow' }, '→'),
|
|
641
|
+
h('span', { className: `zju-step${renderPdf ? '' : ' is-off'}` }, t('pipelinePdf')),
|
|
642
|
+
),
|
|
643
|
+
),
|
|
644
|
+
note ? h('div', { className: 'zju-note', role: 'status' }, note) : null,
|
|
645
|
+
h('div', { className: 'zju-presets' },
|
|
646
|
+
h('span', { className: 'zju-presets-label' }, t('presetsTitle')),
|
|
647
|
+
h('button', { type: 'button', className: 'zju-preset', disabled, onClick: () => applyPreset('token') },
|
|
648
|
+
h('span', { className: 'zju-preset-name' }, t('presetToken')),
|
|
649
|
+
h('span', { className: 'zju-preset-hint' }, t('presetTokenHint')),
|
|
650
|
+
),
|
|
651
|
+
h('button', { type: 'button', className: 'zju-preset', disabled, onClick: () => applyPreset('study') },
|
|
652
|
+
h('span', { className: 'zju-preset-name' }, t('presetStudy')),
|
|
653
|
+
h('span', { className: 'zju-preset-hint' }, t('presetStudyHint')),
|
|
654
|
+
),
|
|
655
|
+
h('button', { type: 'button', className: 'zju-preset', disabled, onClick: () => applyPreset('full') },
|
|
656
|
+
h('span', { className: 'zju-preset-name' }, t('presetFull')),
|
|
657
|
+
h('span', { className: 'zju-preset-hint' }, t('presetFullHint')),
|
|
658
|
+
),
|
|
659
|
+
),
|
|
660
|
+
h('div', { className: 'zju-groups' },
|
|
661
|
+
h(Group, {
|
|
662
|
+
title: t('coreTitle'),
|
|
663
|
+
badge: t('coreBadge'),
|
|
664
|
+
},
|
|
665
|
+
h(Row, {
|
|
666
|
+
t,
|
|
667
|
+
title: 'coreRowTitle',
|
|
668
|
+
hint: 'coreRowHint',
|
|
669
|
+
checked: true,
|
|
670
|
+
disabled: true,
|
|
671
|
+
onChange: () => {},
|
|
672
|
+
}),
|
|
673
|
+
),
|
|
674
|
+
h(Group, {
|
|
675
|
+
title: t('outputTitle'),
|
|
676
|
+
body: t('outputBody'),
|
|
677
|
+
badge: t('outputBadge'),
|
|
678
|
+
},
|
|
679
|
+
h(Row, {
|
|
680
|
+
t,
|
|
681
|
+
title: 'pdfTitle',
|
|
682
|
+
hint: 'pdfHint',
|
|
683
|
+
checked: renderPdf,
|
|
684
|
+
disabled,
|
|
685
|
+
onChange: (next) => update('renderPdf', next),
|
|
686
|
+
}),
|
|
687
|
+
),
|
|
688
|
+
h(Group, {
|
|
689
|
+
title: t('envTitle'),
|
|
690
|
+
body: t('envBody'),
|
|
691
|
+
badge: t('envBadge'),
|
|
692
|
+
},
|
|
693
|
+
h(Row, {
|
|
694
|
+
t,
|
|
695
|
+
title: 'envAutoTitle',
|
|
696
|
+
hint: 'envAutoHint',
|
|
697
|
+
checked: typstAutoInstall,
|
|
698
|
+
disabled,
|
|
699
|
+
onChange: (next) => update('typstAutoInstall', next),
|
|
700
|
+
}),
|
|
701
|
+
h(InputRow, {
|
|
702
|
+
t,
|
|
703
|
+
title: 'envPathTitle',
|
|
704
|
+
hint: 'envPathHint',
|
|
705
|
+
value: typstPath,
|
|
706
|
+
placeholder: t('envPathPlaceholder'),
|
|
707
|
+
disabled,
|
|
708
|
+
onCommit: (next) => update('typstPath', next),
|
|
709
|
+
}),
|
|
710
|
+
h(InputRow, {
|
|
711
|
+
t,
|
|
712
|
+
title: 'envMirrorTitle',
|
|
713
|
+
hint: 'envMirrorHint',
|
|
714
|
+
value: typstMirror,
|
|
715
|
+
placeholder: t('envMirrorPlaceholder'),
|
|
716
|
+
disabled,
|
|
717
|
+
onCommit: (next) => update('typstMirror', next),
|
|
718
|
+
}),
|
|
719
|
+
h('div', { className: 'zju-row is-child' },
|
|
720
|
+
h('div', { className: 'zju-copy' },
|
|
721
|
+
h('div', { className: 'zju-row-hint' }, t('envHint')),
|
|
722
|
+
),
|
|
723
|
+
),
|
|
724
|
+
),
|
|
725
|
+
h(Group, {
|
|
726
|
+
title: t('studyTitle'),
|
|
727
|
+
badge: t('studyBadge'),
|
|
728
|
+
},
|
|
729
|
+
h(Row, {
|
|
730
|
+
t,
|
|
731
|
+
title: 'studyTitle2',
|
|
732
|
+
hint: 'studyHint',
|
|
733
|
+
checked: enableStudyNotes,
|
|
734
|
+
disabled,
|
|
735
|
+
onChange: (next) => update('enableStudyNotes', next),
|
|
736
|
+
}),
|
|
737
|
+
),
|
|
738
|
+
h(Group, {
|
|
739
|
+
title: t('slidesTitle'),
|
|
740
|
+
badge: t('slidesBadge'),
|
|
741
|
+
},
|
|
742
|
+
h(Row, {
|
|
743
|
+
t,
|
|
744
|
+
title: 'slidesTitle2',
|
|
745
|
+
hint: 'slidesHint',
|
|
746
|
+
checked: enableSlides,
|
|
747
|
+
disabled,
|
|
748
|
+
onChange: (next) => update('enableSlides', next),
|
|
749
|
+
}),
|
|
750
|
+
h('div', { className: 'zju-row is-child' },
|
|
751
|
+
h('div', { className: 'zju-copy' },
|
|
752
|
+
h('div', { className: 'zju-row-title' }, t('imagesTitle')),
|
|
753
|
+
h('div', { className: 'zju-row-hint' }, enableSlides ? t('imagesHint') : t('dependency')),
|
|
754
|
+
),
|
|
755
|
+
h(Toggle, {
|
|
756
|
+
checked: embedSlideImages,
|
|
757
|
+
disabled: disabled || !enableSlides,
|
|
758
|
+
label: t('imagesTitle'),
|
|
759
|
+
onChange: (next) => update('embedSlideImages', next),
|
|
760
|
+
}),
|
|
761
|
+
),
|
|
762
|
+
),
|
|
763
|
+
h(Group, {
|
|
764
|
+
title: t('loginTitle'),
|
|
765
|
+
body: t('loginBody'),
|
|
766
|
+
badge: t('loginBadge'),
|
|
767
|
+
},
|
|
768
|
+
h(Row, {
|
|
769
|
+
t,
|
|
770
|
+
title: 'loginTitle2',
|
|
771
|
+
hint: 'loginHint',
|
|
772
|
+
checked: enableLoginTools,
|
|
773
|
+
disabled,
|
|
774
|
+
onChange: (next) => update('enableLoginTools', next),
|
|
775
|
+
}),
|
|
776
|
+
),
|
|
777
|
+
h(Group, {
|
|
778
|
+
title: t('advancedTitle'),
|
|
779
|
+
badge: t('advancedBadge'),
|
|
780
|
+
},
|
|
781
|
+
h(InputRow, {
|
|
782
|
+
t,
|
|
783
|
+
title: 'pythonTitle',
|
|
784
|
+
hint: 'pythonHint',
|
|
785
|
+
value: python,
|
|
786
|
+
placeholder: t('pythonPlaceholder'),
|
|
787
|
+
disabled,
|
|
788
|
+
onCommit: (next) => update('python', next),
|
|
789
|
+
}),
|
|
790
|
+
h(InputRow, {
|
|
791
|
+
t,
|
|
792
|
+
title: 'timeoutTitle',
|
|
793
|
+
hint: 'timeoutHint',
|
|
794
|
+
value: timeoutMs,
|
|
795
|
+
type: 'number',
|
|
796
|
+
min: 1000,
|
|
797
|
+
max: 900000,
|
|
798
|
+
step: 1000,
|
|
799
|
+
disabled,
|
|
800
|
+
onCommit: (next) => update('timeoutMs', next),
|
|
801
|
+
}),
|
|
802
|
+
h(Row, {
|
|
803
|
+
t,
|
|
804
|
+
title: 'registerSkillTitle',
|
|
805
|
+
hint: 'registerSkillHint',
|
|
806
|
+
checked: registerSkill,
|
|
807
|
+
disabled,
|
|
808
|
+
onChange: (next) => update('registerSkill', next),
|
|
809
|
+
}),
|
|
810
|
+
),
|
|
811
|
+
),
|
|
812
|
+
h('footer', { className: 'zju-foot' },
|
|
813
|
+
h('span', { className: 'zju-note' }, `${t('toolsNowPrefix')} ${toolCount} ${t('toolsNowSuffix')} · ${t('toolsNowHint')}`),
|
|
814
|
+
h('span', {
|
|
815
|
+
className: 'zju-save',
|
|
816
|
+
'data-state': saveState,
|
|
817
|
+
'aria-live': 'polite',
|
|
818
|
+
}, saveLabel),
|
|
819
|
+
),
|
|
820
|
+
asPage ? h('p', { className: 'zju-note' }, t('panelNote')) : null,
|
|
821
|
+
)
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/**
|
|
825
|
+
* The left-column row's glyph. A `sidebar.panellist` entry draws its own
|
|
826
|
+
* icon — the slot hands it `size` and `active`, no icon field exists — and
|
|
827
|
+
* the row's own colour must come through, hence `currentColor`.
|
|
828
|
+
*/
|
|
829
|
+
function PanelIcon({ size = 18 }) {
|
|
830
|
+
return h('svg', {
|
|
831
|
+
width: size,
|
|
832
|
+
height: size,
|
|
833
|
+
viewBox: '0 0 20 20',
|
|
834
|
+
fill: 'none',
|
|
835
|
+
stroke: 'currentColor',
|
|
836
|
+
strokeWidth: 1.5,
|
|
837
|
+
strokeLinecap: 'round',
|
|
838
|
+
strokeLinejoin: 'round',
|
|
839
|
+
'aria-hidden': 'true',
|
|
840
|
+
focusable: 'false',
|
|
841
|
+
},
|
|
842
|
+
h('path', { d: 'M4.6 3.4h6.1l4.7 4.7v7.5a1 1 0 0 1-1 1H4.6a1 1 0 0 1-1-1V4.4a1 1 0 0 1 1-1Z' }),
|
|
843
|
+
h('path', { d: 'M10.6 3.5v4.7h4.7' }),
|
|
844
|
+
h('path', { d: 'M6.7 11.2h4.4' }),
|
|
845
|
+
h('path', { d: 'M6.7 13.7h6.2' }),
|
|
846
|
+
)
|
|
847
|
+
}
|
|
848
|
+
|
|
849
|
+
/**
|
|
850
|
+
* The page behind the left-column row.
|
|
851
|
+
*
|
|
852
|
+
* A `main` occupant is a full-height centre column, so it owns the page
|
|
853
|
+
* padding the shipped entry pages use: `--dsh-frame-top-clearance` keeps the
|
|
854
|
+
* first row below the window caption on Windows and under the traffic lights
|
|
855
|
+
* on macOS. The content itself is the settings section, unchanged.
|
|
856
|
+
*/
|
|
857
|
+
function SettingsPanelPage(props) {
|
|
858
|
+
return h('div', { className: 'zju-panel', 'data-zju-panel': PANEL_ID },
|
|
859
|
+
h('div', { className: 'zju-panel-inner' },
|
|
860
|
+
h(PipelineSection, { ...props, asPage: true }),
|
|
861
|
+
),
|
|
862
|
+
)
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
function apply(ctx) {
|
|
866
|
+
ctx.effect(() => ctx.locale.register(NS, { en, zh }), 'zju-lecture: settings dictionaries')
|
|
867
|
+
const t = ctx.locale.bind(NS)
|
|
868
|
+
const settings = new PipelineSettings(ctx)
|
|
869
|
+
ctx.effect(() => () => settings.dispose(), 'zju-lecture: settings form')
|
|
870
|
+
ctx.effect(() => ctx.slots.inject('settings.section', () => ctx.slots.register({
|
|
871
|
+
name: 'settings.section',
|
|
872
|
+
id: PANEL_ID,
|
|
873
|
+
order: 25,
|
|
874
|
+
label: () => t('sectionTitle'),
|
|
875
|
+
locale: NS,
|
|
876
|
+
inject: () => ({ settings }),
|
|
877
|
+
}, PipelineSection)), 'zju-lecture: settings section')
|
|
878
|
+
// The left column: one `sidebar.panellist` row and the `main` page under
|
|
879
|
+
// the same id. Registered from the inner callback so the row and its page
|
|
880
|
+
// appear together or not at all, exactly as the shipped panels do.
|
|
881
|
+
ctx.effect(() => ctx.slots.inject('main', () => ctx.slots.inject('sidebar.panellist', () => {
|
|
882
|
+
const stopPage = ctx.slots.register({
|
|
883
|
+
name: 'main',
|
|
884
|
+
key: PANEL_ID,
|
|
885
|
+
locale: NS,
|
|
886
|
+
inject: () => ({ settings }),
|
|
887
|
+
}, SettingsPanelPage)
|
|
888
|
+
const stopRow = ctx.slots.register({
|
|
889
|
+
name: 'sidebar.panellist',
|
|
890
|
+
id: PANEL_ID,
|
|
891
|
+
order: 30,
|
|
892
|
+
label: () => t('panelLabel'),
|
|
893
|
+
locale: NS,
|
|
894
|
+
}, PanelIcon)
|
|
895
|
+
return () => {
|
|
896
|
+
stopRow()
|
|
897
|
+
stopPage()
|
|
898
|
+
}
|
|
899
|
+
})), 'zju-lecture: sidebar entry')
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
return {
|
|
903
|
+
inject: ['slots', 'locale', 'configForms'],
|
|
904
|
+
apply,
|
|
905
|
+
}
|
|
906
|
+
},
|
|
907
|
+
})
|