@crvouga/mockingbird-runtime 0.2.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -1
- package/dist/adapter-node.d.ts +38 -11
- package/dist/adapter-node.js +82 -174
- package/dist/adapter-node.js.map +4 -4
- package/dist/{chunk-4BRVNPWR.js → chunk-KD6FHYQP.js} +6 -6
- package/dist/{chunk-4BRVNPWR.js.map → chunk-KD6FHYQP.js.map} +2 -2
- package/dist/{chunk-LL6NKAJO.js → chunk-M4HUKBLC.js} +3 -2
- package/dist/chunk-M4HUKBLC.js.map +7 -0
- package/dist/chunk-RI2UQCHP.js +21 -0
- package/dist/chunk-RI2UQCHP.js.map +7 -0
- package/dist/{chunk-2Y25NPCV.js → chunk-U36J5GCB.js} +290 -1
- package/dist/{chunk-2Y25NPCV.js.map → chunk-U36J5GCB.js.map} +3 -3
- package/dist/{chunk-RO7FHXO3.js → chunk-ZQBZSSSP.js} +3 -3
- package/dist/core.d.ts +86 -2
- package/dist/core.js +23 -1
- package/dist/http-provider.js +7 -7
- package/dist/http-provider.js.map +1 -1
- package/dist/mqtt-broker/node.js +4 -4
- package/dist/mqtt-broker.js +4 -4
- package/dist/preview/artifacts.d.ts +4 -9
- package/dist/preview/artifacts.js +4 -16
- package/dist/preview/artifacts.js.map +2 -2
- package/dist/preview/bridge.d.ts +8 -8
- package/dist/preview/bridge.js +1 -1
- package/dist/preview/harness.d.ts +1 -1
- package/dist/preview/harness.js +10 -56
- package/dist/preview/harness.js.map +2 -2
- package/dist/preview/host.d.ts +4 -9
- package/dist/preview/host.js +30 -37
- package/dist/preview/host.js.map +2 -2
- package/dist/service/admin.js +2 -2
- package/dist/service.d.ts +3 -1
- package/dist/service.js +6 -4
- package/dist/ui.d.ts +1 -37
- package/dist/ui.js +2 -701
- package/dist/ui.js.map +3 -3
- package/package.json +7 -6
- package/dist/chunk-EBGYPQPA.js +0 -198
- package/dist/chunk-EBGYPQPA.js.map +0 -7
- package/dist/chunk-LL6NKAJO.js.map +0 -7
- /package/dist/{chunk-RO7FHXO3.js.map → chunk-ZQBZSSSP.js.map} +0 -0
package/dist/ui.js
CHANGED
|
@@ -1,702 +1,3 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
*::before,
|
|
4
|
-
*::after {
|
|
5
|
-
box-sizing: border-box;
|
|
6
|
-
margin: 0;
|
|
7
|
-
padding: 0;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
* {
|
|
11
|
-
scrollbar-width: thin;
|
|
12
|
-
scrollbar-color: color-mix(in srgb, CanvasText 35%, Canvas) Canvas;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
*::-webkit-scrollbar {
|
|
16
|
-
width: 12px;
|
|
17
|
-
height: 12px;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
*::-webkit-scrollbar-track,
|
|
21
|
-
*::-webkit-scrollbar-corner {
|
|
22
|
-
background: Canvas;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
*::-webkit-scrollbar-thumb {
|
|
26
|
-
background: color-mix(in srgb, CanvasText 35%, Canvas);
|
|
27
|
-
border: 3px solid Canvas;
|
|
28
|
-
border-radius: 999px;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
html {
|
|
32
|
-
hanging-punctuation: first allow-end last;
|
|
33
|
-
-webkit-text-size-adjust: none;
|
|
34
|
-
text-size-adjust: none;
|
|
35
|
-
tab-size: 4;
|
|
36
|
-
font-family:
|
|
37
|
-
ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI Variable", "Segoe UI",
|
|
38
|
-
"Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
|
|
39
|
-
font-size: 16px;
|
|
40
|
-
line-height: 1.5;
|
|
41
|
-
-webkit-font-smoothing: antialiased;
|
|
42
|
-
-moz-osx-font-smoothing: grayscale;
|
|
43
|
-
text-rendering: optimizeLegibility;
|
|
44
|
-
-webkit-tap-highlight-color: transparent;
|
|
45
|
-
scroll-behavior: smooth;
|
|
46
|
-
background: Canvas;
|
|
47
|
-
color: CanvasText;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
body {
|
|
51
|
-
min-height: 100svh;
|
|
52
|
-
line-height: 1.5;
|
|
53
|
-
background: Canvas;
|
|
54
|
-
color: CanvasText;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
h1 {
|
|
58
|
-
font-size: 2em;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
h2 {
|
|
62
|
-
font-size: 1.5em;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
h3 {
|
|
66
|
-
font-size: 1.17em;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
h4 {
|
|
70
|
-
font-size: 1em;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
h5 {
|
|
74
|
-
font-size: 0.83em;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
h6 {
|
|
78
|
-
font-size: 0.67em;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
h1,
|
|
82
|
-
h2,
|
|
83
|
-
h3,
|
|
84
|
-
h4,
|
|
85
|
-
h5,
|
|
86
|
-
h6 {
|
|
87
|
-
font-weight: 700;
|
|
88
|
-
line-height: 1.2;
|
|
89
|
-
text-wrap: balance;
|
|
90
|
-
overflow-wrap: break-word;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
p,
|
|
94
|
-
li,
|
|
95
|
-
figcaption,
|
|
96
|
-
dd,
|
|
97
|
-
dt,
|
|
98
|
-
blockquote {
|
|
99
|
-
overflow-wrap: break-word;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
p,
|
|
103
|
-
li,
|
|
104
|
-
figcaption,
|
|
105
|
-
blockquote {
|
|
106
|
-
text-wrap: pretty;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
ul,
|
|
110
|
-
ol,
|
|
111
|
-
menu {
|
|
112
|
-
list-style: none;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
a {
|
|
116
|
-
color: inherit;
|
|
117
|
-
text-decoration: underline;
|
|
118
|
-
text-decoration-thickness: 1px;
|
|
119
|
-
text-underline-offset: 0.15em;
|
|
120
|
-
text-decoration-skip-ink: auto;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
b,
|
|
124
|
-
strong {
|
|
125
|
-
font-weight: 700;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
small {
|
|
129
|
-
font-size: 0.875em;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
code,
|
|
133
|
-
kbd,
|
|
134
|
-
samp,
|
|
135
|
-
pre {
|
|
136
|
-
font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
|
|
137
|
-
font-size: 1em;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
sub,
|
|
141
|
-
sup {
|
|
142
|
-
font-size: 75%;
|
|
143
|
-
line-height: 0;
|
|
144
|
-
position: relative;
|
|
145
|
-
vertical-align: baseline;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
sub {
|
|
149
|
-
bottom: -0.25em;
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
sup {
|
|
153
|
-
top: -0.5em;
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
abbr[title] {
|
|
157
|
-
text-decoration: underline dotted;
|
|
158
|
-
text-underline-offset: 0.15em;
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
mark {
|
|
162
|
-
background: Mark;
|
|
163
|
-
color: MarkText;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
hr {
|
|
167
|
-
height: 0;
|
|
168
|
-
border: 0;
|
|
169
|
-
border-top: 1px solid color-mix(in srgb, CanvasText 20%, transparent);
|
|
170
|
-
color: inherit;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
img,
|
|
174
|
-
picture,
|
|
175
|
-
video,
|
|
176
|
-
canvas {
|
|
177
|
-
display: block;
|
|
178
|
-
max-width: 100%;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
img,
|
|
182
|
-
video {
|
|
183
|
-
height: auto;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
svg {
|
|
187
|
-
overflow: hidden;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
iframe {
|
|
191
|
-
border: 0;
|
|
192
|
-
max-width: 100%;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
table {
|
|
196
|
-
border-collapse: collapse;
|
|
197
|
-
border-spacing: 0;
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
fieldset {
|
|
201
|
-
border: 0;
|
|
202
|
-
min-inline-size: 0;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
legend {
|
|
206
|
-
padding: 0;
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
button,
|
|
210
|
-
input,
|
|
211
|
-
select,
|
|
212
|
-
textarea,
|
|
213
|
-
optgroup {
|
|
214
|
-
font: inherit;
|
|
215
|
-
letter-spacing: inherit;
|
|
216
|
-
color: inherit;
|
|
217
|
-
margin: 0;
|
|
218
|
-
vertical-align: middle;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
button,
|
|
222
|
-
input[type="button"],
|
|
223
|
-
input[type="submit"],
|
|
224
|
-
input[type="reset"] {
|
|
225
|
-
appearance: none;
|
|
226
|
-
background: none;
|
|
227
|
-
border: 0;
|
|
228
|
-
padding: 0;
|
|
229
|
-
cursor: pointer;
|
|
230
|
-
text-align: center;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
input,
|
|
234
|
-
textarea,
|
|
235
|
-
select {
|
|
236
|
-
background-color: Canvas;
|
|
237
|
-
border: 1px solid color-mix(in srgb, CanvasText 28%, transparent);
|
|
238
|
-
border-radius: 0;
|
|
239
|
-
padding: 0.5em 0.65em;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
input[type="checkbox"],
|
|
243
|
-
input[type="radio"],
|
|
244
|
-
input[type="range"],
|
|
245
|
-
input[type="file"],
|
|
246
|
-
input[type="color"],
|
|
247
|
-
input[type="button"],
|
|
248
|
-
input[type="submit"],
|
|
249
|
-
input[type="reset"],
|
|
250
|
-
input[type="image"],
|
|
251
|
-
input[type="hidden"] {
|
|
252
|
-
background: none;
|
|
253
|
-
border: 0;
|
|
254
|
-
padding: 0;
|
|
255
|
-
border-radius: 0;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
input[type="checkbox"],
|
|
259
|
-
input[type="radio"] {
|
|
260
|
-
accent-color: CanvasText;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
input[type="search"] {
|
|
264
|
-
appearance: none;
|
|
265
|
-
background-color: Canvas;
|
|
266
|
-
border: 1px solid color-mix(in srgb, CanvasText 28%, transparent);
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
input[type="search"]::-webkit-search-decoration,
|
|
270
|
-
input[type="search"]::-webkit-search-cancel-button,
|
|
271
|
-
input[type="search"]::-webkit-search-results-button,
|
|
272
|
-
input[type="search"]::-webkit-search-results-decoration {
|
|
273
|
-
-webkit-appearance: none;
|
|
274
|
-
display: none;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
input[type="number"] {
|
|
278
|
-
appearance: textfield;
|
|
279
|
-
background-color: Canvas;
|
|
280
|
-
border: 1px solid color-mix(in srgb, CanvasText 28%, transparent);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
input[type="number"]::-webkit-inner-spin-button,
|
|
284
|
-
input[type="number"]::-webkit-outer-spin-button {
|
|
285
|
-
-webkit-appearance: none;
|
|
286
|
-
margin: 0;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
textarea {
|
|
290
|
-
resize: vertical;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
::placeholder {
|
|
294
|
-
opacity: 1;
|
|
295
|
-
color: color-mix(in srgb, CanvasText 45%, transparent);
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
:focus-visible {
|
|
299
|
-
outline: 2px solid CanvasText;
|
|
300
|
-
outline-offset: 2px;
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
:focus:not(:focus-visible) {
|
|
304
|
-
outline: none;
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
:disabled,
|
|
308
|
-
[disabled] {
|
|
309
|
-
cursor: default;
|
|
310
|
-
opacity: 0.6;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
label,
|
|
314
|
-
summary,
|
|
315
|
-
select,
|
|
316
|
-
[role="button"] {
|
|
317
|
-
cursor: pointer;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
|
-
summary {
|
|
321
|
-
display: list-item;
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
details {
|
|
325
|
-
display: block;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
dialog {
|
|
329
|
-
margin: auto;
|
|
330
|
-
padding: 1rem;
|
|
331
|
-
border: 1px solid color-mix(in srgb, CanvasText 20%, transparent);
|
|
332
|
-
background: Canvas;
|
|
333
|
-
color: CanvasText;
|
|
334
|
-
max-width: calc(100vw - 2rem);
|
|
335
|
-
max-height: calc(100svh - 2rem);
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
dialog:not([open]) {
|
|
339
|
-
display: none;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
::backdrop {
|
|
343
|
-
background: color-mix(in srgb, CanvasText 40%, transparent);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
[hidden] {
|
|
347
|
-
display: none !important;
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
::selection {
|
|
351
|
-
background: Highlight;
|
|
352
|
-
color: HighlightText;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
@media (prefers-reduced-motion: reduce) {
|
|
356
|
-
*,
|
|
357
|
-
*::before,
|
|
358
|
-
*::after {
|
|
359
|
-
animation-duration: 0.01ms !important;
|
|
360
|
-
animation-iteration-count: 1 !important;
|
|
361
|
-
transition-duration: 0.01ms !important;
|
|
362
|
-
scroll-behavior: auto !important;
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
@media (pointer: coarse) {
|
|
367
|
-
input,
|
|
368
|
-
select,
|
|
369
|
-
textarea {
|
|
370
|
-
font-size: max(16px, 1em);
|
|
371
|
-
}
|
|
372
|
-
}`;
|
|
373
|
-
function scopeReset(root) {
|
|
374
|
-
return scopeStylesheet(CSS_RESET, root).replaceAll("100dvh", "100%").replaceAll("100svh", "100%").replaceAll("100vh", "100%");
|
|
375
|
-
}
|
|
376
|
-
function scopeStylesheet(css, root) {
|
|
377
|
-
let out = "";
|
|
378
|
-
let cursor = 0;
|
|
379
|
-
while (cursor < css.length) {
|
|
380
|
-
const brace = css.indexOf("{", cursor);
|
|
381
|
-
if (brace === -1) {
|
|
382
|
-
out += css.slice(cursor);
|
|
383
|
-
break;
|
|
384
|
-
}
|
|
385
|
-
const prelude = css.slice(cursor, brace);
|
|
386
|
-
const trimmed = prelude.trimStart();
|
|
387
|
-
if (trimmed.startsWith("@media") || trimmed.startsWith("@supports")) {
|
|
388
|
-
const end = skipBlock(css, brace);
|
|
389
|
-
const body = css.slice(brace + 1, end - 1);
|
|
390
|
-
out += `${css.slice(cursor, brace + 1)}${scopeStylesheet(body, root)}}`;
|
|
391
|
-
cursor = end;
|
|
392
|
-
continue;
|
|
393
|
-
}
|
|
394
|
-
if (trimmed.startsWith("@")) {
|
|
395
|
-
const end = skipBlock(css, brace);
|
|
396
|
-
out += css.slice(cursor, end);
|
|
397
|
-
cursor = end;
|
|
398
|
-
continue;
|
|
399
|
-
}
|
|
400
|
-
const close = prelude.lastIndexOf("}");
|
|
401
|
-
const head = close === -1 ? "" : prelude.slice(0, close + 1);
|
|
402
|
-
const selector = close === -1 ? prelude : prelude.slice(close + 1);
|
|
403
|
-
out += `${head}${scopeSelectorList(selector, root)}{`;
|
|
404
|
-
cursor = brace + 1;
|
|
405
|
-
}
|
|
406
|
-
return out;
|
|
407
|
-
}
|
|
408
|
-
function scopeSelectorList(selector, root) {
|
|
409
|
-
const where = `:where(${root})`;
|
|
410
|
-
return splitSelectors(selector).map((part) => scopeOne(part.trim(), where)).filter((part) => part !== "").join(",\n");
|
|
411
|
-
}
|
|
412
|
-
function scopeOne(selector, where) {
|
|
413
|
-
if (selector === "html" || selector === "body" || selector === ":root")
|
|
414
|
-
return where;
|
|
415
|
-
if (selector.startsWith("*")) {
|
|
416
|
-
const rest = selector.slice(1);
|
|
417
|
-
return `${where}${rest},
|
|
418
|
-
${where} ${selector}`;
|
|
419
|
-
}
|
|
420
|
-
if (selector.startsWith(":"))
|
|
421
|
-
return `${where}${selector},
|
|
422
|
-
${where} ${selector}`;
|
|
423
|
-
return `${where} ${selector}`;
|
|
424
|
-
}
|
|
425
|
-
function splitSelectors(selector) {
|
|
426
|
-
const parts = [];
|
|
427
|
-
let current = "";
|
|
428
|
-
let depth = 0;
|
|
429
|
-
for (const char of selector) {
|
|
430
|
-
if (char === "(")
|
|
431
|
-
depth++;
|
|
432
|
-
else if (char === ")")
|
|
433
|
-
depth = Math.max(0, depth - 1);
|
|
434
|
-
if (char === "," && depth === 0) {
|
|
435
|
-
parts.push(current);
|
|
436
|
-
current = "";
|
|
437
|
-
continue;
|
|
438
|
-
}
|
|
439
|
-
current += char;
|
|
440
|
-
}
|
|
441
|
-
parts.push(current);
|
|
442
|
-
return parts;
|
|
443
|
-
}
|
|
444
|
-
function skipBlock(css, openBrace) {
|
|
445
|
-
let depth = 0;
|
|
446
|
-
for (let index = openBrace; index < css.length; index++) {
|
|
447
|
-
const char = css[index];
|
|
448
|
-
if (char === "{")
|
|
449
|
-
depth++;
|
|
450
|
-
else if (char === "}") {
|
|
451
|
-
depth--;
|
|
452
|
-
if (depth === 0)
|
|
453
|
-
return index + 1;
|
|
454
|
-
}
|
|
455
|
-
}
|
|
456
|
-
return css.length;
|
|
457
|
-
}
|
|
458
|
-
|
|
459
|
-
// ../ui/dist/system-harness.js
|
|
460
|
-
function mountSystemHarness(host, surfaces, options = {}) {
|
|
461
|
-
const ids = /* @__PURE__ */ new Set(["system"]);
|
|
462
|
-
for (const surface of surfaces) {
|
|
463
|
-
if (!surface.id || ids.has(surface.id))
|
|
464
|
-
throw new Error(`Duplicate or reserved surface: ${surface.id}`);
|
|
465
|
-
ids.add(surface.id);
|
|
466
|
-
}
|
|
467
|
-
const doc = host.ownerDocument;
|
|
468
|
-
const win = doc.defaultView ?? window;
|
|
469
|
-
const shell = doc.createElement("div");
|
|
470
|
-
shell.className = "msh";
|
|
471
|
-
const style = doc.createElement("style");
|
|
472
|
-
style.textContent = `
|
|
473
|
-
.msh{position:relative;height:100%;min-height:240px;isolation:isolate;color:CanvasText;background:Canvas;font:14px system-ui}
|
|
474
|
-
.msh-panel{height:100%;overflow:auto}.msh [hidden]{display:none!important}
|
|
475
|
-
.msh-chrome{position:absolute;inset:0;pointer-events:none;z-index:1000}
|
|
476
|
-
.msh-handle{position:absolute;pointer-events:auto;touch-action:none;width:44px;height:44px;border-radius:50%;border:1px solid #777;background:#17212f;color:white;box-shadow:0 2px 12px #0004;cursor:grab;font:20px system-ui}
|
|
477
|
-
.msh-home button,.msh-status button{display:block;padding:12px;width:100%;text-align:left;border:0;border-radius:6px;background:transparent;color:inherit;font:inherit;cursor:pointer}
|
|
478
|
-
.msh-home button:hover{background:#8883}
|
|
479
|
-
.msh-home,.msh-status{max-width:640px;padding:32px;margin:auto}
|
|
480
|
-
.msh :focus-visible{outline:2px solid #477bff;outline-offset:2px}
|
|
481
|
-
`;
|
|
482
|
-
const chrome = doc.createElement("div");
|
|
483
|
-
chrome.className = "msh-chrome";
|
|
484
|
-
const handle = doc.createElement("button");
|
|
485
|
-
handle.type = "button";
|
|
486
|
-
handle.className = "msh-handle";
|
|
487
|
-
handle.textContent = "\u25A6";
|
|
488
|
-
handle.setAttribute("aria-label", "Switch apps");
|
|
489
|
-
handle.dataset.testid = "system-switcher";
|
|
490
|
-
handle.hidden = surfaces.length === 0;
|
|
491
|
-
chrome.append(handle);
|
|
492
|
-
shell.append(style, chrome);
|
|
493
|
-
host.append(shell);
|
|
494
|
-
let destroyed = false;
|
|
495
|
-
let current = "";
|
|
496
|
-
const controller = new AbortController();
|
|
497
|
-
const entries = [];
|
|
498
|
-
const all = [
|
|
499
|
-
{
|
|
500
|
-
id: "system",
|
|
501
|
-
label: "System",
|
|
502
|
-
mount(panel) {
|
|
503
|
-
const home = doc.createElement("div");
|
|
504
|
-
home.className = "msh-home";
|
|
505
|
-
const heading = doc.createElement("h1");
|
|
506
|
-
heading.textContent = "System";
|
|
507
|
-
const intro = doc.createElement("p");
|
|
508
|
-
intro.textContent = "Your whole system, running in this browser. Open an app or inspect the services behind it.";
|
|
509
|
-
home.append(heading, intro);
|
|
510
|
-
for (const surface of surfaces) {
|
|
511
|
-
const button = doc.createElement("button");
|
|
512
|
-
button.textContent = surface.label;
|
|
513
|
-
button.onclick = () => {
|
|
514
|
-
void show(surface.id);
|
|
515
|
-
};
|
|
516
|
-
home.append(button);
|
|
517
|
-
}
|
|
518
|
-
panel.append(home);
|
|
519
|
-
return () => home.remove();
|
|
520
|
-
}
|
|
521
|
-
},
|
|
522
|
-
...surfaces
|
|
523
|
-
];
|
|
524
|
-
for (const spec of all) {
|
|
525
|
-
const panel = doc.createElement("section");
|
|
526
|
-
panel.className = "msh-panel";
|
|
527
|
-
panel.dataset.surface = spec.id;
|
|
528
|
-
panel.setAttribute("aria-label", spec.label);
|
|
529
|
-
panel.tabIndex = -1;
|
|
530
|
-
panel.hidden = true;
|
|
531
|
-
shell.insertBefore(panel, chrome);
|
|
532
|
-
entries.push({ spec, panel });
|
|
533
|
-
}
|
|
534
|
-
function load(entry) {
|
|
535
|
-
if (entry.pending)
|
|
536
|
-
return entry.pending;
|
|
537
|
-
entry.panel.setAttribute("aria-busy", "true");
|
|
538
|
-
const status = doc.createElement("div");
|
|
539
|
-
status.className = "msh-status";
|
|
540
|
-
status.setAttribute("role", "status");
|
|
541
|
-
status.textContent = "Loading\u2026";
|
|
542
|
-
const content = doc.createElement("div");
|
|
543
|
-
content.style.height = "100%";
|
|
544
|
-
entry.panel.replaceChildren(status, content);
|
|
545
|
-
entry.pending = Promise.resolve().then(() => {
|
|
546
|
-
if (destroyed)
|
|
547
|
-
return;
|
|
548
|
-
return entry.spec.mount(content, controller.signal);
|
|
549
|
-
}).then((dispose) => {
|
|
550
|
-
status.remove();
|
|
551
|
-
if (destroyed)
|
|
552
|
-
dispose?.();
|
|
553
|
-
else
|
|
554
|
-
entry.dispose = dispose;
|
|
555
|
-
}).catch((error) => {
|
|
556
|
-
if (destroyed)
|
|
557
|
-
return;
|
|
558
|
-
content.remove();
|
|
559
|
-
status.textContent = `Unable to open ${entry.spec.label}: ${error instanceof Error ? error.message : String(error)}`;
|
|
560
|
-
const retry = doc.createElement("button");
|
|
561
|
-
retry.textContent = "Retry";
|
|
562
|
-
retry.onclick = () => {
|
|
563
|
-
entry.pending = void 0;
|
|
564
|
-
void load(entry);
|
|
565
|
-
};
|
|
566
|
-
status.append(retry);
|
|
567
|
-
}).finally(() => entry.panel.removeAttribute("aria-busy"));
|
|
568
|
-
return entry.pending;
|
|
569
|
-
}
|
|
570
|
-
async function show(id) {
|
|
571
|
-
if (destroyed)
|
|
572
|
-
return;
|
|
573
|
-
const entry = entries.find((e) => e.spec.id === id) ?? entries[0];
|
|
574
|
-
if (!entry)
|
|
575
|
-
return;
|
|
576
|
-
current = entry.spec.id;
|
|
577
|
-
const next = entries[(entries.indexOf(entry) + 1) % entries.length];
|
|
578
|
-
handle.title = `Switch to ${next?.spec.label ?? "System"}`;
|
|
579
|
-
handle.setAttribute("aria-description", handle.title);
|
|
580
|
-
for (const candidate of entries) {
|
|
581
|
-
candidate.panel.hidden = candidate !== entry;
|
|
582
|
-
candidate.panel.inert = candidate !== entry;
|
|
583
|
-
}
|
|
584
|
-
if (entries.some((candidate) => candidate.panel.hidden && candidate.panel.contains(doc.activeElement))) {
|
|
585
|
-
entry.panel.focus();
|
|
586
|
-
}
|
|
587
|
-
if (options.syncUrl) {
|
|
588
|
-
const url = new URL(win.location.href);
|
|
589
|
-
url.searchParams.set("surface", current);
|
|
590
|
-
if (url.href !== win.location.href)
|
|
591
|
-
win.history.pushState(null, "", url);
|
|
592
|
-
}
|
|
593
|
-
await load(entry);
|
|
594
|
-
}
|
|
595
|
-
handle.onclick = () => {
|
|
596
|
-
if (dragged) {
|
|
597
|
-
dragged = false;
|
|
598
|
-
return;
|
|
599
|
-
}
|
|
600
|
-
const next = entries[(entries.findIndex((entry) => entry.spec.id === current) + 1) % entries.length];
|
|
601
|
-
if (next)
|
|
602
|
-
void show(next.spec.id);
|
|
603
|
-
};
|
|
604
|
-
let x = Infinity;
|
|
605
|
-
let y = Infinity;
|
|
606
|
-
const position = () => {
|
|
607
|
-
x = Math.max(0, Math.min(x, shell.clientWidth - 52));
|
|
608
|
-
y = Math.max(0, Math.min(y, shell.clientHeight - 52));
|
|
609
|
-
handle.style.left = `${x}px`;
|
|
610
|
-
handle.style.top = `${y}px`;
|
|
611
|
-
};
|
|
612
|
-
const snap = () => {
|
|
613
|
-
const maxX = Math.max(0, shell.clientWidth - 52);
|
|
614
|
-
const maxY = Math.max(0, shell.clientHeight - 52);
|
|
615
|
-
const minX = Math.min(8, maxX);
|
|
616
|
-
const minY = Math.min(8, maxY);
|
|
617
|
-
x = Math.max(minX, Math.min(x, maxX));
|
|
618
|
-
y = Math.max(minY, Math.min(y, maxY));
|
|
619
|
-
const distances = [x - minX, maxX - x, y - minY, maxY - y];
|
|
620
|
-
const edge = distances.indexOf(Math.min(...distances));
|
|
621
|
-
if (edge === 0)
|
|
622
|
-
x = minX;
|
|
623
|
-
else if (edge === 1)
|
|
624
|
-
x = maxX;
|
|
625
|
-
else if (edge === 2)
|
|
626
|
-
y = minY;
|
|
627
|
-
else
|
|
628
|
-
y = maxY;
|
|
629
|
-
handle.style.transition = win.matchMedia("(prefers-reduced-motion: reduce)").matches ? "none" : "left 160ms ease-out, top 160ms ease-out";
|
|
630
|
-
position();
|
|
631
|
-
};
|
|
632
|
-
let drag;
|
|
633
|
-
let dragged = false;
|
|
634
|
-
handle.onpointerdown = (event) => {
|
|
635
|
-
if (event.button !== 0)
|
|
636
|
-
return;
|
|
637
|
-
dragged = false;
|
|
638
|
-
handle.style.transition = "none";
|
|
639
|
-
drag = { x: event.clientX, y: event.clientY, left: x, top: y };
|
|
640
|
-
handle.setPointerCapture(event.pointerId);
|
|
641
|
-
};
|
|
642
|
-
handle.onpointermove = (event) => {
|
|
643
|
-
if (!drag)
|
|
644
|
-
return;
|
|
645
|
-
const dx = event.clientX - drag.x;
|
|
646
|
-
const dy = event.clientY - drag.y;
|
|
647
|
-
if (Math.hypot(dx, dy) > 5)
|
|
648
|
-
dragged = true;
|
|
649
|
-
if (!dragged)
|
|
650
|
-
return;
|
|
651
|
-
x = drag.left + dx;
|
|
652
|
-
y = drag.top + dy;
|
|
653
|
-
position();
|
|
654
|
-
};
|
|
655
|
-
handle.onpointerup = () => {
|
|
656
|
-
drag = void 0;
|
|
657
|
-
snap();
|
|
658
|
-
};
|
|
659
|
-
handle.onpointercancel = () => {
|
|
660
|
-
drag = void 0;
|
|
661
|
-
dragged = false;
|
|
662
|
-
snap();
|
|
663
|
-
};
|
|
664
|
-
handle.onlostpointercapture = () => {
|
|
665
|
-
drag = void 0;
|
|
666
|
-
snap();
|
|
667
|
-
};
|
|
668
|
-
const resize = new ResizeObserver(snap);
|
|
669
|
-
resize.observe(shell);
|
|
670
|
-
const fromUrl = () => new URL(win.location.href).searchParams.get("surface") ?? options.initial ?? "system";
|
|
671
|
-
const pop = () => {
|
|
672
|
-
void show(fromUrl());
|
|
673
|
-
};
|
|
674
|
-
if (options.syncUrl)
|
|
675
|
-
win.addEventListener("popstate", pop);
|
|
676
|
-
void show(options.syncUrl ? fromUrl() : options.initial ?? "system");
|
|
677
|
-
return {
|
|
678
|
-
show,
|
|
679
|
-
active: () => current,
|
|
680
|
-
destroy() {
|
|
681
|
-
if (destroyed)
|
|
682
|
-
return;
|
|
683
|
-
destroyed = true;
|
|
684
|
-
controller.abort();
|
|
685
|
-
resize.disconnect();
|
|
686
|
-
win.removeEventListener("popstate", pop);
|
|
687
|
-
for (const entry of entries) {
|
|
688
|
-
try {
|
|
689
|
-
entry.dispose?.();
|
|
690
|
-
} catch {
|
|
691
|
-
}
|
|
692
|
-
}
|
|
693
|
-
shell.remove();
|
|
694
|
-
}
|
|
695
|
-
};
|
|
696
|
-
}
|
|
697
|
-
export {
|
|
698
|
-
CSS_RESET,
|
|
699
|
-
mountSystemHarness,
|
|
700
|
-
scopeReset
|
|
701
|
-
};
|
|
1
|
+
// src/ui.ts
|
|
2
|
+
export * from "@crvouga/mockingbird-ui";
|
|
702
3
|
//# sourceMappingURL=ui.js.map
|