@thready-web/dsh-bot-plugin 0.1.0-beta.1 → 0.1.0-beta.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +109 -1
- package/client.js +646 -621
- package/dist/approvals.js +160 -0
- package/dist/authorization.js +225 -0
- package/dist/canvas-http.js +248 -0
- package/dist/canvas-skills.js +56 -0
- package/dist/canvas-store.js +794 -0
- package/dist/canvas-tools.js +211 -0
- package/dist/cli.js +32 -12
- package/dist/context.js +60 -17
- package/dist/cron.js +1 -1
- package/dist/cua-access.js +79 -0
- package/dist/desk.js +314 -37
- package/dist/engine.js +178 -84
- package/dist/fs-safe.js +1 -1
- package/dist/host.js +1 -0
- package/dist/http-plugin.js +14 -4
- package/dist/http.js +402 -85
- package/dist/inbox.js +51 -40
- package/dist/index.js +201 -47
- package/dist/live-diff.js +3 -1
- package/dist/live-snapshot.js +2 -13
- package/dist/log/canonical.js +37 -0
- package/dist/log/plan.js +62 -0
- package/dist/log/routes.js +144 -0
- package/dist/log/snapshot-service.js +76 -0
- package/dist/log/source.js +173 -0
- package/dist/memory-catalog.js +798 -0
- package/dist/permissions.js +86 -0
- package/dist/provision.js +2 -0
- package/dist/questions.js +407 -0
- package/dist/runtime-registry.js +4 -4
- package/dist/session-files.js +2 -2
- package/dist/session-previews.js +5 -1
- package/dist/store.js +20 -5
- package/dist/tools.js +150 -32
- package/dist/triggers.js +83 -39
- package/dist/work-admit.js +222 -25
- package/dist/work-child.js +17 -9
- package/dist/work-http.js +52 -2
- package/dist/work-ledger.js +256 -16
- package/dist/work-mock-host.js +9 -6
- package/dist/work-mock.js +29 -19
- package/dist/work-tickets.js +423 -96
- package/dist/work-tools.js +43 -6
- package/dist/work-worker.js +1033 -207
- package/dist/workspace-files.js +319 -0
- package/dist/workspace-image.js +91 -0
- package/fixtures/mock-llm.mjs +17 -2
- package/package.json +16 -5
- package/public/assets/SourceEditor-CJwK846Z.css +1 -0
- package/public/assets/SourceEditor-uu0G7jsM.js +669 -0
- package/public/assets/abap-CRCWOmpq.js +1 -0
- package/public/assets/apex-DnsZk_dE.js +1 -0
- package/public/assets/azcli-1IWB1ccx.js +1 -0
- package/public/assets/bat-DPkNLes8.js +1 -0
- package/public/assets/bicep-Corcdgou.js +2 -0
- package/public/assets/cameligo-CGrWLZr3.js +1 -0
- package/public/assets/clojure-D9WOWImG.js +1 -0
- package/public/assets/codicon-DCmgc-ay.ttf +0 -0
- package/public/assets/coffee-B7EJu28W.js +1 -0
- package/public/assets/cpp-SEyurbux.js +1 -0
- package/public/assets/csharp-BoL64M5l.js +1 -0
- package/public/assets/csp-C46ZqvIl.js +1 -0
- package/public/assets/css-DQU6DXDx.js +3 -0
- package/public/assets/css.worker-DYpkewsP.js +79 -0
- package/public/assets/cssMode-C5DAFF5H.js +4 -0
- package/public/assets/cypher-D84EuPTj.js +1 -0
- package/public/assets/dart-D8lhlL1r.js +1 -0
- package/public/assets/dockerfile-DLk6rpji.js +1 -0
- package/public/assets/ecl-BO6FnfXk.js +1 -0
- package/public/assets/editor.worker-B4pQIWZD.js +12 -0
- package/public/assets/elixir-BRjLKONM.js +1 -0
- package/public/assets/flow9-Cac8vKd7.js +1 -0
- package/public/assets/freemarker2-DExNwSiZ.js +3 -0
- package/public/assets/fsharp-fd1GTHhf.js +1 -0
- package/public/assets/go-O9LJTZXk.js +1 -0
- package/public/assets/graphql-LQdxqEYJ.js +1 -0
- package/public/assets/handlebars-BK7YAvpQ.js +1 -0
- package/public/assets/hcl-DxDQ3s82.js +1 -0
- package/public/assets/html-CdDm_zae.js +1 -0
- package/public/assets/html.worker-tnXziJOq.js +456 -0
- package/public/assets/htmlMode-CLdn9oa1.js +4 -0
- package/public/assets/index-BB-QDSf2.css +1 -0
- package/public/assets/index-CsX-_qbo.js +62 -0
- package/public/assets/ini-BvajGCUy.js +1 -0
- package/public/assets/java-SYsfObOQ.js +1 -0
- package/public/assets/javascript-mLl83_3W.js +1 -0
- package/public/assets/json.worker-aFakAbRR.js +44 -0
- package/public/assets/jsonMode-B1-bihFd.js +10 -0
- package/public/assets/julia-DQXNmw_w.js +1 -0
- package/public/assets/kotlin-qQ0MG-9I.js +1 -0
- package/public/assets/less-GGFNNJHn.js +2 -0
- package/public/assets/lexon-Canl7DCW.js +1 -0
- package/public/assets/liquid-Cv8m0HUb.js +1 -0
- package/public/assets/lua-D28Ae8-K.js +1 -0
- package/public/assets/m3-DPitgjJI.js +1 -0
- package/public/assets/markdown-B811l8j2.js +1 -0
- package/public/assets/mdx-Q12b91rL.js +1 -0
- package/public/assets/mips-CdjsipkG.js +1 -0
- package/public/assets/msdax-CYqgjx_P.js +1 -0
- package/public/assets/mysql-BHd6q0vd.js +1 -0
- package/public/assets/objective-c-B1aVtJYH.js +1 -0
- package/public/assets/pascal-BhNW15KB.js +1 -0
- package/public/assets/pascaligo-5jv8CcQD.js +1 -0
- package/public/assets/perl-DlYyT36c.js +1 -0
- package/public/assets/pgsql-Dy0bjov7.js +1 -0
- package/public/assets/php-120yhfDK.js +1 -0
- package/public/assets/pla-CjnFlu4u.js +1 -0
- package/public/assets/postiats-CQpG440k.js +1 -0
- package/public/assets/powerquery-DdJtto1Z.js +1 -0
- package/public/assets/powershell-Bu_VLpJB.js +1 -0
- package/public/assets/protobuf-IBS6jZEB.js +2 -0
- package/public/assets/pug-kFxLfcjb.js +1 -0
- package/public/assets/python-Kda811W0.js +1 -0
- package/public/assets/qsharp-q7JyzKFN.js +1 -0
- package/public/assets/r-BIFz-_sK.js +1 -0
- package/public/assets/razor-CRuCpdOW.js +1 -0
- package/public/assets/redis-CHOsPHWR.js +1 -0
- package/public/assets/redshift-CBifECDb.js +1 -0
- package/public/assets/restructuredtext-CghPJEOS.js +1 -0
- package/public/assets/ruby-CYWGW-b1.js +1 -0
- package/public/assets/rust-DMDD0SHb.js +1 -0
- package/public/assets/sb-BYAiYHFx.js +1 -0
- package/public/assets/scala-Bqvq8jcR.js +1 -0
- package/public/assets/scheme-Dhb-2j9p.js +1 -0
- package/public/assets/scss-CTwUZ5N7.js +3 -0
- package/public/assets/shell-CsDZo4DB.js +1 -0
- package/public/assets/solidity-CME5AdoB.js +1 -0
- package/public/assets/sophia-RYC1BQQz.js +1 -0
- package/public/assets/sparql-KEyrF7De.js +1 -0
- package/public/assets/sql-BdTr02Mf.js +1 -0
- package/public/assets/st-C7iG7M4S.js +1 -0
- package/public/assets/swift-D7IUmUK8.js +1 -0
- package/public/assets/systemverilog-DgMryOEJ.js +1 -0
- package/public/assets/tcl-PloMZuKG.js +1 -0
- package/public/assets/ts.worker-Bij5J2kb.js +51316 -0
- package/public/assets/tsMode-BGHcz-M3.js +11 -0
- package/public/assets/twig-BfRIq3la.js +1 -0
- package/public/assets/typescript-Db1e0DCT.js +1 -0
- package/public/assets/typespec-CzxlYoT_.js +1 -0
- package/public/assets/vb-BwAE3J76.js +1 -0
- package/public/assets/wgsl-B_1kOXbF.js +298 -0
- package/public/assets/xml-H3zzFmnd.js +1 -0
- package/public/assets/yaml-BQrKvmTF.js +1 -0
- package/public/index.html +2 -2
- package/skills/ui/baseline-ui/SKILL.md +85 -0
- package/skills/ui/bencium-innovative-ux-designer/SKILL.md +227 -0
- package/skills/ui/better-ui/SKILL.md +133 -0
- package/skills/ui/design-lab/SKILL.md +920 -0
- package/skills/ui/frontend-design/SKILL.md +71 -0
- package/skills/ui/impeccable/SKILL.md +93 -0
- package/skills/ui/interface-design/SKILL.md +320 -0
- package/skills/ui/sources.json +66 -0
- package/skills/ui/ui-design/SKILL.md +35 -0
- package/skills/ui/ui-skills-root/SKILL.md +59 -0
- package/skills/ui/visual-design-foundations/SKILL.md +318 -0
- package/skills/ui/web-design-guidelines/SKILL.md +39 -0
- package/public/assets/index-Be82iGwe.css +0 -1
- package/public/assets/index-ByU9a3Lh.js +0 -61
package/client.js
CHANGED
|
@@ -23,624 +23,649 @@
|
|
|
23
23
|
*
|
|
24
24
|
* Bundled for the DSH client loader; no rendering, no slots.
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
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
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
26
|
+
/** @type {Window & { __ModuleLoader__: { load: (spec: { id: string, factory: (require: (id: string) => unknown) => unknown }) => void } }} */
|
|
27
|
+
const hostWindow =
|
|
28
|
+
/** @type {Window & { __ModuleLoader__: { load: (spec: { id: string, factory: (require: (id: string) => unknown) => unknown }) => void } }} */ (
|
|
29
|
+
/** @type {unknown} */ (window)
|
|
30
|
+
)
|
|
31
|
+
hostWindow.__ModuleLoader__.load({
|
|
32
|
+
id: '@thready-web/dsh-bot-plugin',
|
|
33
|
+
factory: (/** @type {(id: string) => unknown} */ require) => {
|
|
34
|
+
/** @type {{ exports: { inject?: string[], apply?: (ctx: { layout?: any, uiWorkspace?: any, get?: (name: string) => any, effect: (setup: () => (() => void) | void, label?: string) => void }) => void } }} */
|
|
35
|
+
var module = { exports: {} }
|
|
36
|
+
var exports = module.exports
|
|
37
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
|
|
38
|
+
|
|
39
|
+
/** Hash segment naming a Session. */
|
|
40
|
+
const SEG_SESSION = 's'
|
|
41
|
+
/** Hash segment naming a main panel. */
|
|
42
|
+
const SEG_PANEL = 'p'
|
|
43
|
+
/** Hash segment naming how many overlays are stacked above the view. */
|
|
44
|
+
const SEG_OVERLAY = 'o'
|
|
45
|
+
/** How long after a history event echoes are folded into `replaceState`. */
|
|
46
|
+
const SETTLE_MS = 1500
|
|
47
|
+
/**
|
|
48
|
+
* How long a deep link keeps reasserting itself while the app boots. The
|
|
49
|
+
* workspace restores its persisted Session asynchronously once both the
|
|
50
|
+
* Workspace and Session catalogs are ready, which over a slow link can
|
|
51
|
+
* take a few seconds.
|
|
52
|
+
*/
|
|
53
|
+
const BOOT_MS = 8000
|
|
54
|
+
/** Attempts allowed per deep-link segment before it is abandoned. */
|
|
55
|
+
const BOOT_TRIES = 3
|
|
56
|
+
/** The core's own modal dialogs: a portal on `body`, topmost last. */
|
|
57
|
+
const DIALOG_SELECTOR = '[role="dialog"][aria-modal="true"]'
|
|
58
|
+
/** Overlay depth is capped so a runaway stack cannot fill the address bar. */
|
|
59
|
+
const MAX_OVERLAY = 9
|
|
60
|
+
/** A batch of DOM mutations settles this long before the overlay is measured. */
|
|
61
|
+
const SCAN_DEBOUNCE_MS = 80
|
|
62
|
+
/** Fallback poll for overlay changes no mutation reports (column expansion). */
|
|
63
|
+
const SCAN_INTERVAL_MS = 350
|
|
64
|
+
/** One overlay close gets this long to commit before the next step. */
|
|
65
|
+
const CLOSE_STEP_MS = 40
|
|
66
|
+
/** Close steps allowed for one Back press. */
|
|
67
|
+
const CLOSE_TRIES = 12
|
|
68
|
+
/** Our own `history.back()` gets this long to land before it is given up on. */
|
|
69
|
+
const BACK_MS = 1200
|
|
70
|
+
/** Key of the marker this plugin keeps in `history.state`. */
|
|
71
|
+
const STATE_KEY = '__dshUiRouter'
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* @param {string} value - value to escape.
|
|
75
|
+
* @returns the escaped segment.
|
|
76
|
+
*/
|
|
77
|
+
function encodeSegment(value) {
|
|
78
|
+
try {
|
|
79
|
+
return encodeURIComponent(value)
|
|
80
|
+
} catch (_error) {
|
|
81
|
+
return value
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* @param {string} value - escaped segment.
|
|
87
|
+
* @returns the decoded segment.
|
|
88
|
+
*/
|
|
89
|
+
function decodeSegment(value) {
|
|
90
|
+
try {
|
|
91
|
+
return decodeURIComponent(value)
|
|
92
|
+
} catch (_error) {
|
|
93
|
+
return value
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Read a route out of a location hash.
|
|
99
|
+
* @param {string} hash - `location.hash`, with or without the leading `#`.
|
|
100
|
+
* @returns the session id (undefined when absent), the panel id (null when
|
|
101
|
+
* absent) and the overlay depth (0 when absent).
|
|
102
|
+
*/
|
|
103
|
+
function parseHash(hash) {
|
|
104
|
+
/** @type {{ sessionId?: string, panelId: string | null, overlay: number }} */
|
|
105
|
+
const route = { sessionId: undefined, panelId: null, overlay: 0 }
|
|
106
|
+
if (typeof hash !== 'string' || hash.length === 0) return route
|
|
107
|
+
const parts = hash
|
|
108
|
+
.replace(/^#/, '')
|
|
109
|
+
.split('/')
|
|
110
|
+
.filter(segment => segment.length > 0)
|
|
111
|
+
.map(decodeSegment)
|
|
112
|
+
for (let index = 0; index + 1 < parts.length; index += 2) {
|
|
113
|
+
const key = parts[index]
|
|
114
|
+
const value = parts[index + 1]
|
|
115
|
+
if (key === SEG_SESSION && value.length > 0) route.sessionId = value
|
|
116
|
+
else if (key === SEG_PANEL && value.length > 0) route.panelId = value
|
|
117
|
+
else if (key === SEG_OVERLAY) {
|
|
118
|
+
const depth = Number.parseInt(value, 10)
|
|
119
|
+
if (Number.isFinite(depth) && depth > 0) route.overlay = Math.min(depth, MAX_OVERLAY)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return route
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* @param {{ sessionId?: string, panelId?: string | null, overlay?: number }} route - session id, panel id and overlay depth.
|
|
127
|
+
* @returns the hash for that route, empty when nothing is addressable.
|
|
128
|
+
*/
|
|
129
|
+
function formatHash(route) {
|
|
130
|
+
const segments = []
|
|
131
|
+
if (typeof route.sessionId === 'string' && route.sessionId.length > 0)
|
|
132
|
+
segments.push(SEG_SESSION, encodeSegment(route.sessionId))
|
|
133
|
+
if (typeof route.panelId === 'string' && route.panelId.length > 0)
|
|
134
|
+
segments.push(SEG_PANEL, encodeSegment(route.panelId))
|
|
135
|
+
if (typeof route.overlay === 'number' && route.overlay > 0)
|
|
136
|
+
segments.push(SEG_OVERLAY, String(Math.min(route.overlay, MAX_OVERLAY)))
|
|
137
|
+
return segments.length === 0 ? '' : '#/' + segments.join('/')
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** Services required from the client runtime. */
|
|
141
|
+
exports.inject = ['layout', 'uiWorkspace']
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Mirror the active Session, main panel and overlay stack into the URL and
|
|
145
|
+
* drive them from it.
|
|
146
|
+
* @param {{ layout?: any, uiWorkspace?: any, get?: (name: string) => any, effect: (setup: () => (() => void) | void, label?: string) => void }} ctx - client plugin context.
|
|
147
|
+
*/
|
|
148
|
+
function apply(ctx) {
|
|
149
|
+
if (typeof window === 'undefined' || window.location === void 0 || window.history === void 0) return
|
|
150
|
+
const location = window.location
|
|
151
|
+
const history = window.history
|
|
152
|
+
|
|
153
|
+
const layout = ctx.layout
|
|
154
|
+
const workspace = ctx.uiWorkspace
|
|
155
|
+
const panelInfo = layout.panelInfo
|
|
156
|
+
const selection = workspace.selection
|
|
157
|
+
const sessionList = workspace.sessions.list
|
|
158
|
+
|
|
159
|
+
/** The route the page was opened with; consumed one item at a time. */
|
|
160
|
+
const boot = parseHash(location.hash)
|
|
161
|
+
let bootSession = boot.sessionId
|
|
162
|
+
let bootPanel = boot.panelId
|
|
163
|
+
const bootUntil = Date.now() + BOOT_MS
|
|
164
|
+
let sessionTries = 0
|
|
165
|
+
let panelTries = 0
|
|
166
|
+
/** False until the boot route has been applied (or given up on). */
|
|
167
|
+
let live = false
|
|
168
|
+
/** Echoes until this timestamp rewrite the URL in place. */
|
|
169
|
+
let settleUntil = Date.now() + SETTLE_MS
|
|
170
|
+
/** A deferred `sync` is pending. */
|
|
171
|
+
let queued = false
|
|
172
|
+
/** Overlay depth the current history entry is believed to describe. */
|
|
173
|
+
let publishedOverlay = boot.overlay
|
|
174
|
+
/** Non-zero while our own `history.back()` is in flight. */
|
|
175
|
+
let backAt = 0
|
|
176
|
+
/** Overlay depth a Back press asked for, while the closes run. */
|
|
177
|
+
/** @type {number | null} */
|
|
178
|
+
let settleTarget = null
|
|
179
|
+
/** Pending debounced overlay scan. */
|
|
180
|
+
let scanTimer = 0
|
|
181
|
+
|
|
182
|
+
/** @returns the current app route. */
|
|
183
|
+
const readRoute = () => ({
|
|
184
|
+
sessionId: selection.getSnapshot().sessionId,
|
|
185
|
+
panelId: panelInfo.getSnapshot().activePanelId,
|
|
186
|
+
})
|
|
187
|
+
|
|
188
|
+
const currentUrl = () => location.pathname + location.search + location.hash
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* @param {{ sessionId?: string, panelId?: string | null, overlay?: number }} route - target route.
|
|
192
|
+
* @returns the absolute URL for it, keeping path and query.
|
|
193
|
+
*/
|
|
194
|
+
const urlFor = route => location.pathname + location.search + formatHash(route)
|
|
195
|
+
|
|
196
|
+
/** @returns the right-column service, or undefined when it is not mounted. */
|
|
197
|
+
const sidebarRight = () => {
|
|
198
|
+
if (typeof ctx.get !== 'function') return void 0
|
|
199
|
+
try {
|
|
200
|
+
return ctx.get('sidebarRight')
|
|
201
|
+
} catch (_error) {
|
|
202
|
+
return void 0
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** @returns the marker this plugin left on the current history entry. */
|
|
207
|
+
const entryTag = () => {
|
|
208
|
+
let state
|
|
209
|
+
try {
|
|
210
|
+
state = history.state
|
|
211
|
+
} catch (_error) {
|
|
212
|
+
return void 0
|
|
213
|
+
}
|
|
214
|
+
if (state === null || typeof state !== 'object') return void 0
|
|
215
|
+
const tag = state[STATE_KEY]
|
|
216
|
+
return tag !== null && typeof tag === 'object' ? tag : void 0
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/**
|
|
220
|
+
* @param {Record<string, unknown>} tag - marker to record.
|
|
221
|
+
* @returns the state object to write, keeping whatever the page already stored.
|
|
222
|
+
*/
|
|
223
|
+
const withTag = tag => {
|
|
224
|
+
let state
|
|
225
|
+
try {
|
|
226
|
+
state = history.state
|
|
227
|
+
} catch (_error) {
|
|
228
|
+
state = null
|
|
229
|
+
}
|
|
230
|
+
const base = state !== null && typeof state === 'object' ? { ...state } : {}
|
|
231
|
+
base[STATE_KEY] = tag
|
|
232
|
+
return base
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* Write the route into the address bar.
|
|
237
|
+
* @param {{ sessionId?: string, panelId?: string | null, overlay?: number }} route - route to publish.
|
|
238
|
+
* @param {string} mode - `push` for a new entry, `replace` to rewrite in place.
|
|
239
|
+
* @param {string} kind - why the entry exists: `overlay` for one this plugin opened
|
|
240
|
+
* for an overlay, `route` for a Session / panel move or a rewrite.
|
|
241
|
+
*/
|
|
242
|
+
const publish = (route, mode, kind) => {
|
|
243
|
+
publishedOverlay = route.overlay ?? 0
|
|
244
|
+
const url = urlFor(route)
|
|
245
|
+
if (url === currentUrl()) return
|
|
246
|
+
const state = withTag({ kind, depth: route.overlay })
|
|
247
|
+
try {
|
|
248
|
+
if (mode === 'replace') history.replaceState(state, '', url)
|
|
249
|
+
else history.pushState(state, '', url)
|
|
250
|
+
} catch (_error) {
|
|
251
|
+
/* History may be unavailable in a sandboxed frame; the app still works. */
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** @returns the dialogs the core currently shows, topmost last. */
|
|
256
|
+
const visibleDialogs = () => {
|
|
257
|
+
if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return []
|
|
258
|
+
let nodes
|
|
259
|
+
try {
|
|
260
|
+
nodes = document.querySelectorAll(DIALOG_SELECTOR)
|
|
261
|
+
} catch (_error) {
|
|
262
|
+
return []
|
|
263
|
+
}
|
|
264
|
+
const open = []
|
|
265
|
+
for (let index = 0; index < nodes.length; index += 1) {
|
|
266
|
+
const node = nodes[index]
|
|
267
|
+
if (node === null || node === void 0) continue
|
|
268
|
+
// A dialog kept mounted while hidden is not an overlay.
|
|
269
|
+
if (typeof node.getClientRects === 'function' && node.getClientRects().length === 0) continue
|
|
270
|
+
open.push(node)
|
|
271
|
+
}
|
|
272
|
+
return open
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
/** @returns whether the right column is showing its panel. */
|
|
276
|
+
const sidebarExpanded = () => {
|
|
277
|
+
const sidebar = sidebarRight()
|
|
278
|
+
if (sidebar === void 0 || typeof sidebar.isExpanded !== 'function') return false
|
|
279
|
+
try {
|
|
280
|
+
return sidebar.isExpanded() === true
|
|
281
|
+
} catch (_error) {
|
|
282
|
+
return false
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Count what is stacked above the plain view: every modal dialog, plus
|
|
288
|
+
* the right column (the file / code preview lives there) when expanded.
|
|
289
|
+
* @returns the overlay depth, 0 for a bare view.
|
|
290
|
+
*/
|
|
291
|
+
const overlayDepth = () => Math.min(visibleDialogs().length + (sidebarExpanded() ? 1 : 0), MAX_OVERLAY)
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Send the core's own Escape handling to the topmost modal, which is what
|
|
295
|
+
* its dialog stack listens for.
|
|
296
|
+
* @returns whether an event could be dispatched.
|
|
297
|
+
*/
|
|
298
|
+
const pressEscape = () => {
|
|
299
|
+
if (typeof document === 'undefined' || typeof document.dispatchEvent !== 'function') return false
|
|
300
|
+
const ctor =
|
|
301
|
+
typeof window.KeyboardEvent === 'function'
|
|
302
|
+
? window.KeyboardEvent
|
|
303
|
+
: typeof KeyboardEvent === 'function'
|
|
304
|
+
? KeyboardEvent
|
|
305
|
+
: void 0
|
|
306
|
+
if (ctor === void 0) return false
|
|
307
|
+
let event
|
|
308
|
+
try {
|
|
309
|
+
event = new ctor('keydown', {
|
|
310
|
+
key: 'Escape',
|
|
311
|
+
code: 'Escape',
|
|
312
|
+
keyCode: 27,
|
|
313
|
+
which: 27,
|
|
314
|
+
bubbles: true,
|
|
315
|
+
cancelable: true,
|
|
316
|
+
})
|
|
317
|
+
} catch (_error) {
|
|
318
|
+
return false
|
|
319
|
+
}
|
|
320
|
+
try {
|
|
321
|
+
document.dispatchEvent(event)
|
|
322
|
+
return true
|
|
323
|
+
} catch (_error) {
|
|
324
|
+
return false
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* Ask the dialog's own close affordances, for a modal that ignores Escape.
|
|
330
|
+
* @param {Element} dialog - the topmost dialog.
|
|
331
|
+
* @returns whether something was clicked.
|
|
332
|
+
*/
|
|
333
|
+
const clickDialogClose = dialog => {
|
|
334
|
+
if (typeof dialog.querySelector !== 'function') return false
|
|
335
|
+
const candidates = ['button[aria-label]', '.mask']
|
|
336
|
+
for (const selector of candidates) {
|
|
337
|
+
let node
|
|
338
|
+
try {
|
|
339
|
+
node = dialog.querySelector(selector)
|
|
340
|
+
} catch (_error) {
|
|
341
|
+
continue
|
|
342
|
+
}
|
|
343
|
+
if (node !== null && node !== void 0 && 'click' in node && typeof node.click === 'function') {
|
|
344
|
+
try {
|
|
345
|
+
node.click()
|
|
346
|
+
return true
|
|
347
|
+
} catch (_error) {
|
|
348
|
+
/* Keep to the next affordance. */
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
return false
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
/**
|
|
356
|
+
* Close whatever is on top: the last modal first, then the right column.
|
|
357
|
+
* @param {boolean} control - true to use the dialog's own close control instead of
|
|
358
|
+
* sending Escape, for a modal that does not take the key.
|
|
359
|
+
* @returns whether a close was requested.
|
|
360
|
+
*/
|
|
361
|
+
const closeTopOverlay = control => {
|
|
362
|
+
const dialogs = visibleDialogs()
|
|
363
|
+
if (dialogs.length > 0) {
|
|
364
|
+
if (!control && pressEscape()) return true
|
|
365
|
+
return clickDialogClose(dialogs[dialogs.length - 1])
|
|
366
|
+
}
|
|
367
|
+
if (sidebarExpanded()) {
|
|
368
|
+
const sidebar = sidebarRight()
|
|
369
|
+
try {
|
|
370
|
+
sidebar.toggleExpanded()
|
|
371
|
+
return true
|
|
372
|
+
} catch (_error) {
|
|
373
|
+
return false
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return false
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/**
|
|
380
|
+
* @param {string} sessionId - candidate Session id.
|
|
381
|
+
* @returns whether the catalog already knows that Session.
|
|
382
|
+
*/
|
|
383
|
+
const knownSession = sessionId => {
|
|
384
|
+
const snapshot = sessionList.getSnapshot()
|
|
385
|
+
return snapshot !== void 0 && snapshot.byId !== void 0 && snapshot.byId[sessionId] !== void 0
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** @returns whether the Session catalog has finished its first load. */
|
|
389
|
+
const catalogReady = () => {
|
|
390
|
+
const snapshot = sessionList.getSnapshot()
|
|
391
|
+
return snapshot !== void 0 && snapshot.phase === 'ready'
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
/**
|
|
395
|
+
* Apply one pending piece of the boot route. A segment is only dropped
|
|
396
|
+
* once the app actually shows it, because the workspace restore runs
|
|
397
|
+
* after this plugin mounts and may briefly override both.
|
|
398
|
+
* @returns true while the route still waits for data or for the app to
|
|
399
|
+
* follow the change it just triggered.
|
|
400
|
+
*/
|
|
401
|
+
const adopt = () => {
|
|
402
|
+
if (Date.now() > bootUntil) {
|
|
403
|
+
bootSession = void 0
|
|
404
|
+
bootPanel = null
|
|
405
|
+
return false
|
|
406
|
+
}
|
|
407
|
+
const route = readRoute()
|
|
408
|
+
if (bootSession !== void 0) {
|
|
409
|
+
if (route.sessionId === bootSession) bootSession = void 0
|
|
410
|
+
else if (!knownSession(bootSession)) {
|
|
411
|
+
if (!catalogReady()) return true
|
|
412
|
+
bootSession = void 0
|
|
413
|
+
} else if (sessionTries < BOOT_TRIES) {
|
|
414
|
+
sessionTries += 1
|
|
415
|
+
try {
|
|
416
|
+
workspace.openSession(bootSession)
|
|
417
|
+
} catch (error) {
|
|
418
|
+
console.warn('ui-router: cannot open the Session named by the URL', error)
|
|
419
|
+
bootSession = void 0
|
|
420
|
+
}
|
|
421
|
+
return true
|
|
422
|
+
} else bootSession = void 0
|
|
423
|
+
}
|
|
424
|
+
if (bootPanel !== null) {
|
|
425
|
+
if (route.panelId === bootPanel) bootPanel = null
|
|
426
|
+
else if (!layout.hasMainPanel(bootPanel)) bootPanel = null
|
|
427
|
+
else if (panelTries < BOOT_TRIES) {
|
|
428
|
+
panelTries += 1
|
|
429
|
+
try {
|
|
430
|
+
layout.selectPanel(bootPanel)
|
|
431
|
+
} catch (error) {
|
|
432
|
+
console.warn('ui-router: cannot open the panel named by the URL', error)
|
|
433
|
+
bootPanel = null
|
|
434
|
+
}
|
|
435
|
+
return true
|
|
436
|
+
} else bootPanel = null
|
|
437
|
+
}
|
|
438
|
+
return false
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
/**
|
|
442
|
+
* Publish the current route and overlay depth, or finish adopting the
|
|
443
|
+
* boot route first.
|
|
444
|
+
*/
|
|
445
|
+
const sync = () => {
|
|
446
|
+
if (settleTarget !== null) return
|
|
447
|
+
if (backAt !== 0) {
|
|
448
|
+
if (Date.now() - backAt <= BACK_MS) return
|
|
449
|
+
backAt = 0
|
|
450
|
+
}
|
|
451
|
+
const overlay = overlayDepth()
|
|
452
|
+
if (!live) {
|
|
453
|
+
if (adopt()) return
|
|
454
|
+
live = true
|
|
455
|
+
publish({ ...readRoute(), overlay }, 'replace', 'route')
|
|
456
|
+
return
|
|
457
|
+
}
|
|
458
|
+
const route = { ...readRoute(), overlay }
|
|
459
|
+
const fresh = Date.now() >= settleUntil
|
|
460
|
+
if (overlay > publishedOverlay) {
|
|
461
|
+
// An overlay appearing is always the user's doing, so it always gets
|
|
462
|
+
// its own entry, even right after a history move.
|
|
463
|
+
publish(route, 'push', 'overlay')
|
|
464
|
+
return
|
|
465
|
+
}
|
|
466
|
+
if (overlay < publishedOverlay) {
|
|
467
|
+
const tag = entryTag()
|
|
468
|
+
// The current entry exists only for the overlay that just closed, so
|
|
469
|
+
// stepping back removes it instead of leaving a dead entry behind.
|
|
470
|
+
if (
|
|
471
|
+
fresh &&
|
|
472
|
+
overlay === publishedOverlay - 1 &&
|
|
473
|
+
tag !== void 0 &&
|
|
474
|
+
tag.kind === 'overlay' &&
|
|
475
|
+
tag.depth === publishedOverlay
|
|
476
|
+
) {
|
|
477
|
+
backAt = Date.now()
|
|
478
|
+
try {
|
|
479
|
+
history.back()
|
|
480
|
+
return
|
|
481
|
+
} catch (_error) {
|
|
482
|
+
backAt = 0
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
publish(route, 'replace', 'route')
|
|
486
|
+
return
|
|
487
|
+
}
|
|
488
|
+
publish(route, fresh ? 'push' : 'replace', 'route')
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* Defer `sync` to the next microtask: the workspace keeps writing state
|
|
493
|
+
* after the listener returns (`replaceMain` closes the panel once the
|
|
494
|
+
* Session is selected), so reacting inside the notification would race
|
|
495
|
+
* with the very change that triggered it.
|
|
496
|
+
*/
|
|
497
|
+
const queue = () => {
|
|
498
|
+
if (queued) return
|
|
499
|
+
queued = true
|
|
500
|
+
queueMicrotask(() => {
|
|
501
|
+
queued = false
|
|
502
|
+
sync()
|
|
503
|
+
})
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
/**
|
|
507
|
+
* Measure the overlay stack after a batch of DOM mutations.
|
|
508
|
+
*/
|
|
509
|
+
const scheduleScan = () => {
|
|
510
|
+
if (scanTimer !== 0) return
|
|
511
|
+
scanTimer = setTimeout(() => {
|
|
512
|
+
scanTimer = 0
|
|
513
|
+
sync()
|
|
514
|
+
}, SCAN_DEBOUNCE_MS)
|
|
515
|
+
const nodeTimer = /** @type {{ unref?: () => void }} */ (/** @type {unknown} */ (scanTimer))
|
|
516
|
+
if (typeof nodeTimer.unref === 'function') nodeTimer.unref()
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Close overlays until only `target` are left, then let the address bar
|
|
521
|
+
* drive the rest of the navigation. Closes commit asynchronously, so this
|
|
522
|
+
* walks one step per turn instead of closing everything at once.
|
|
523
|
+
* @param {number} target - overlay depth the Back press asked for.
|
|
524
|
+
*/
|
|
525
|
+
const closeToDepth = target => {
|
|
526
|
+
settleTarget = target
|
|
527
|
+
let tries = 0
|
|
528
|
+
const step = () => {
|
|
529
|
+
if (overlayDepth() <= target || tries >= CLOSE_TRIES) {
|
|
530
|
+
settleTarget = null
|
|
531
|
+
applyHash(true)
|
|
532
|
+
return
|
|
533
|
+
}
|
|
534
|
+
tries += 1
|
|
535
|
+
// Alternate the key and the dialog's own control, so a modal that
|
|
536
|
+
// ignores Escape still closes.
|
|
537
|
+
if (!closeTopOverlay(tries % 2 === 0)) {
|
|
538
|
+
settleTarget = null
|
|
539
|
+
applyHash(true)
|
|
540
|
+
return
|
|
541
|
+
}
|
|
542
|
+
setTimeout(step, CLOSE_STEP_MS)
|
|
543
|
+
}
|
|
544
|
+
// Off the event path: the history handlers may run mid-commit.
|
|
545
|
+
setTimeout(step, 0)
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Bring the app to the route the address bar now names.
|
|
550
|
+
* @param {boolean} forced - true when the overlay stack is already settled, so a
|
|
551
|
+
* lower depth must not start another close sequence.
|
|
552
|
+
*/
|
|
553
|
+
const applyHash = forced => {
|
|
554
|
+
// A history move of our own, or the user's, has now landed.
|
|
555
|
+
backAt = 0
|
|
556
|
+
if (!forced && settleTarget !== null) return
|
|
557
|
+
const target = parseHash(location.hash)
|
|
558
|
+
const depth = overlayDepth()
|
|
559
|
+
if (forced !== true && target.overlay < depth) {
|
|
560
|
+
closeToDepth(target.overlay)
|
|
561
|
+
return
|
|
562
|
+
}
|
|
563
|
+
publishedOverlay = target.overlay
|
|
564
|
+
settleUntil = Date.now() + SETTLE_MS
|
|
565
|
+
// A deliberate history move supersedes whatever the page was opened with.
|
|
566
|
+
bootSession = void 0
|
|
567
|
+
bootPanel = null
|
|
568
|
+
live = true
|
|
569
|
+
const route = readRoute()
|
|
570
|
+
if (target.sessionId !== void 0 && target.sessionId !== route.sessionId && knownSession(target.sessionId)) {
|
|
571
|
+
try {
|
|
572
|
+
workspace.openSession(target.sessionId)
|
|
573
|
+
} catch (error) {
|
|
574
|
+
console.warn('ui-router: cannot open the Session named by the URL', error)
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
// The panel goes last: opening a Session reveals the conversation and
|
|
578
|
+
// would close a panel selected before it.
|
|
579
|
+
const shown = readRoute()
|
|
580
|
+
if (target.panelId !== shown.panelId) {
|
|
581
|
+
if (target.panelId === null) layout.selectPanel(null)
|
|
582
|
+
else if (layout.hasMainPanel(target.panelId)) layout.selectPanel(target.panelId)
|
|
583
|
+
}
|
|
584
|
+
// Correct the address bar when part of the target was not reachable.
|
|
585
|
+
queue()
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/** `popstate` / `hashchange`: the event object is not an argument here. */
|
|
589
|
+
const onHistory = () => applyHash(false)
|
|
590
|
+
|
|
591
|
+
ctx.effect(() => {
|
|
592
|
+
const disposers = [panelInfo.subscribe(queue), selection.subscribe(queue), sessionList.subscribe(queue)]
|
|
593
|
+
// The right column reports its own tab moves; expansion has no
|
|
594
|
+
// observable, so the fallback poll below covers that half.
|
|
595
|
+
const sidebar = sidebarRight()
|
|
596
|
+
if (sidebar !== void 0) {
|
|
597
|
+
for (const source of [sidebar.openTabs, sidebar.mounted]) {
|
|
598
|
+
if (source === void 0 || typeof source.subscribe !== 'function') continue
|
|
599
|
+
try {
|
|
600
|
+
disposers.push(source.subscribe(scheduleScan))
|
|
601
|
+
} catch (_error) {
|
|
602
|
+
/* A store already torn down by the runtime. */
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
window.addEventListener('popstate', onHistory)
|
|
607
|
+
window.addEventListener('hashchange', onHistory)
|
|
608
|
+
|
|
609
|
+
// Dialogs are portals appended to `body`, so watching its direct
|
|
610
|
+
// children catches them without paying for every streamed token.
|
|
611
|
+
const Observer =
|
|
612
|
+
typeof window.MutationObserver === 'function'
|
|
613
|
+
? window.MutationObserver
|
|
614
|
+
: typeof MutationObserver === 'function'
|
|
615
|
+
? MutationObserver
|
|
616
|
+
: void 0
|
|
617
|
+
/** @type {MutationObserver | undefined} */
|
|
618
|
+
let observer
|
|
619
|
+
if (
|
|
620
|
+
Observer !== void 0 &&
|
|
621
|
+
typeof document !== 'undefined' &&
|
|
622
|
+
document.body !== null &&
|
|
623
|
+
document.body !== void 0
|
|
624
|
+
) {
|
|
625
|
+
try {
|
|
626
|
+
observer = new Observer(scheduleScan)
|
|
627
|
+
observer.observe(document.body, { childList: true })
|
|
628
|
+
} catch (_error) {
|
|
629
|
+
observer = void 0
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
const poll = setInterval(() => {
|
|
634
|
+
if (typeof document !== 'undefined' && document.visibilityState === 'hidden') return
|
|
635
|
+
sync()
|
|
636
|
+
}, SCAN_INTERVAL_MS)
|
|
637
|
+
const nodePoll = /** @type {{ unref?: () => void }} */ (/** @type {unknown} */ (poll))
|
|
638
|
+
if (typeof nodePoll.unref === 'function') nodePoll.unref()
|
|
639
|
+
|
|
640
|
+
return () => {
|
|
641
|
+
window.removeEventListener('popstate', onHistory)
|
|
642
|
+
window.removeEventListener('hashchange', onHistory)
|
|
643
|
+
clearInterval(poll)
|
|
644
|
+
if (scanTimer !== 0) {
|
|
645
|
+
clearTimeout(scanTimer)
|
|
646
|
+
scanTimer = 0
|
|
647
|
+
}
|
|
648
|
+
if (observer !== void 0) {
|
|
649
|
+
try {
|
|
650
|
+
observer.disconnect()
|
|
651
|
+
} catch (_error) {
|
|
652
|
+
/* Already disconnected. */
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
for (const dispose of disposers) {
|
|
656
|
+
try {
|
|
657
|
+
dispose()
|
|
658
|
+
} catch (_error) {
|
|
659
|
+
/* A store already torn down by the runtime. */
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
}
|
|
663
|
+
}, 'ui-router: history')
|
|
664
|
+
|
|
665
|
+
queue()
|
|
666
|
+
}
|
|
667
|
+
|
|
668
|
+
exports.apply = apply
|
|
669
|
+
return module.exports
|
|
670
|
+
},
|
|
671
|
+
})
|