@bramas/simulant-ui 0.0.0-stage → 0.1.1

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.
Files changed (53) hide show
  1. package/LICENCE.txt +515 -0
  2. package/dist/SimulatorApp.jsx +601 -0
  3. package/dist/components/AlgorithmViewer.css +270 -0
  4. package/dist/components/AlgorithmViewer.jsx +218 -0
  5. package/dist/components/BranchPicker.css +96 -0
  6. package/dist/components/BranchPicker.jsx +65 -0
  7. package/dist/components/ConfigGraphGenerator.css +129 -0
  8. package/dist/components/ConfigGraphGenerator.jsx +408 -0
  9. package/dist/components/GenericEditor.jsx +228 -0
  10. package/dist/components/LeanView.jsx +133 -0
  11. package/dist/components/ModelView.css +520 -0
  12. package/dist/components/ModelView.jsx +272 -0
  13. package/dist/components/SettingsLibrary.jsx +61 -0
  14. package/dist/components/StateInspector.css +136 -0
  15. package/dist/components/StateInspector.jsx +103 -0
  16. package/dist/components/highlight.js +99 -0
  17. package/dist/pico.min.css +4 -0
  18. package/dist/renderers/define.js +28 -0
  19. package/dist/renderers/ring.js +103 -0
  20. package/dist/sim/branches.js +28 -0
  21. package/dist/sim/describe.js +408 -0
  22. package/dist/sim/execution.js +42 -0
  23. package/dist/sim/project.js +349 -0
  24. package/dist/sim/snapshot.js +29 -0
  25. package/dist/sim/types.js +1 -0
  26. package/dist/simulator.css +593 -0
  27. package/package.json +50 -3
  28. package/src/SimulatorApp.tsx +661 -0
  29. package/src/components/AlgorithmViewer.css +270 -0
  30. package/src/components/AlgorithmViewer.tsx +256 -0
  31. package/src/components/BranchPicker.css +96 -0
  32. package/src/components/BranchPicker.tsx +90 -0
  33. package/src/components/ConfigGraphGenerator.css +129 -0
  34. package/src/components/ConfigGraphGenerator.tsx +448 -0
  35. package/src/components/GenericEditor.tsx +413 -0
  36. package/src/components/LeanView.tsx +162 -0
  37. package/src/components/ModelView.css +520 -0
  38. package/src/components/ModelView.tsx +317 -0
  39. package/src/components/SettingsLibrary.tsx +84 -0
  40. package/src/components/StateInspector.css +136 -0
  41. package/src/components/StateInspector.tsx +125 -0
  42. package/src/components/highlight.ts +100 -0
  43. package/src/pico.min.css +4 -0
  44. package/src/renderers/define.ts +54 -0
  45. package/src/renderers/ring.ts +112 -0
  46. package/src/sim/branches.ts +30 -0
  47. package/src/sim/describe.ts +416 -0
  48. package/src/sim/execution.ts +65 -0
  49. package/src/sim/project.ts +377 -0
  50. package/src/sim/snapshot.ts +60 -0
  51. package/src/sim/types.ts +28 -0
  52. package/src/simulator.css +593 -0
  53. package/README.md +0 -3
@@ -0,0 +1,520 @@
1
+ /**
2
+ * The model view: facts on the left, the declarations as written on the right (tokens and code
3
+ * lines from simulator.css and AlgorithmViewer.css). The blocks are not <article>s: Pico gives an
4
+ * article's <header> negative margins, which pushed the header over the block's border.
5
+ */
6
+
7
+ .model-view {
8
+ display: flex;
9
+ flex-direction: column;
10
+ gap: 1.25rem;
11
+ }
12
+
13
+ .mv-intro-head {
14
+ display: flex;
15
+ align-items: center;
16
+ gap: 0.6rem 1rem;
17
+ flex-wrap: wrap;
18
+ }
19
+
20
+ .mv-intro h2 {
21
+ margin: 0;
22
+ font-size: 1.25rem;
23
+ font-family: var(--sim-mono);
24
+ }
25
+
26
+ .mv-chips {
27
+ display: flex;
28
+ flex-wrap: wrap;
29
+ gap: 0.35rem;
30
+ }
31
+
32
+ .mv-chips .sim-chip {
33
+ font-weight: 500;
34
+ color: var(--sim-text);
35
+ }
36
+
37
+ .mv-about {
38
+ margin: 0.75rem 0 0;
39
+ font-size: 0.92rem;
40
+ line-height: 1.5;
41
+ max-width: 60rem;
42
+ }
43
+
44
+ .mv-about p {
45
+ margin: 0 0 0.5rem;
46
+ }
47
+
48
+ .mv-about code {
49
+ font-size: 0.82rem;
50
+ padding: 0.05rem 0.3rem;
51
+ }
52
+
53
+ .mv-help {
54
+ margin: 0.5rem 0 0;
55
+ }
56
+
57
+ .mv-help code {
58
+ font-size: 0.8rem;
59
+ }
60
+
61
+ .mv-grid {
62
+ display: grid;
63
+ grid-template-columns: minmax(0, 5fr) minmax(0, 6fr);
64
+ gap: 1.25rem;
65
+ align-items: start;
66
+ }
67
+
68
+ .mv-grid.mv-grid-lean {
69
+ grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
70
+ }
71
+
72
+ @media (max-width: 1100px) {
73
+ .mv-grid, .mv-grid.mv-grid-lean { grid-template-columns: minmax(0, 1fr); }
74
+ }
75
+
76
+ .mv-column {
77
+ display: flex;
78
+ flex-direction: column;
79
+ gap: 1rem;
80
+ }
81
+
82
+ .mv-section > h3 .sim-muted {
83
+ font-weight: 400;
84
+ }
85
+
86
+ /* Facts: label, value with its references, explanation */
87
+
88
+ .mv-facts {
89
+ display: grid;
90
+ grid-template-columns: minmax(6.5rem, max-content) minmax(0, 1fr);
91
+ gap: 0.55rem 1rem;
92
+ margin: 0;
93
+ }
94
+
95
+ .mv-facts dt {
96
+ font-size: 0.8rem;
97
+ font-weight: 600;
98
+ color: var(--sim-muted);
99
+ padding-top: 0.12rem;
100
+ }
101
+
102
+ .mv-facts dd {
103
+ margin: 0;
104
+ min-width: 0;
105
+ }
106
+
107
+ .mv-value {
108
+ display: flex;
109
+ flex-wrap: wrap;
110
+ align-items: baseline;
111
+ gap: 0.25rem 0.5rem;
112
+ }
113
+
114
+ .mv-strong {
115
+ font-weight: 600;
116
+ }
117
+
118
+ .mv-code {
119
+ font-family: var(--sim-mono);
120
+ font-size: 0.85rem;
121
+ background: var(--sim-surface-2);
122
+ border: 1px solid var(--sim-border);
123
+ border-radius: 5px;
124
+ padding: 0 0.35rem;
125
+ overflow-wrap: anywhere;
126
+ }
127
+
128
+ .mv-note {
129
+ font-size: 0.85rem;
130
+ color: var(--sim-muted);
131
+ margin-top: 0.15rem;
132
+ line-height: 1.45;
133
+ }
134
+
135
+ .mv-details {
136
+ margin: 0.3rem 0 0;
137
+ padding-left: 1.1rem;
138
+ font-size: 0.82rem;
139
+ font-family: var(--sim-mono);
140
+ }
141
+
142
+ .mv-details li {
143
+ margin: 0.1rem 0;
144
+ list-style: disc;
145
+ }
146
+
147
+ .sim-app button.mv-ref {
148
+ background: none;
149
+ border: none;
150
+ padding: 0;
151
+ font-family: var(--sim-mono);
152
+ font-size: 0.75rem;
153
+ color: var(--sim-accent);
154
+ cursor: pointer;
155
+ text-decoration: underline dotted;
156
+ text-underline-offset: 2px;
157
+ }
158
+
159
+ .sim-app button.mv-ref:hover {
160
+ text-decoration: underline;
161
+ }
162
+
163
+ /* The round, as a numbered timeline */
164
+
165
+ .mv-round {
166
+ list-style: none;
167
+ margin: 0;
168
+ padding: 0;
169
+ counter-reset: phase;
170
+ }
171
+
172
+ .mv-round li {
173
+ list-style: none;
174
+ counter-increment: phase;
175
+ display: grid;
176
+ grid-template-columns: 8.5rem minmax(0, 1fr);
177
+ gap: 0.75rem;
178
+ padding: 0.45rem 0 0.45rem 0.6rem;
179
+ margin: 0;
180
+ border-left: 2px solid var(--sim-border);
181
+ font-size: 0.88rem;
182
+ }
183
+
184
+ .mv-round li.mv-idle {
185
+ opacity: 0.55;
186
+ }
187
+
188
+ .mv-phase {
189
+ font-weight: 600;
190
+ font-family: var(--sim-mono);
191
+ font-size: 0.82rem;
192
+ }
193
+
194
+ .mv-round li:first-child .mv-phase::before {
195
+ content: '';
196
+ }
197
+
198
+ .mv-round li:not(:first-child) .mv-phase::before {
199
+ content: counter(phase, decimal) '. ';
200
+ color: var(--sim-muted);
201
+ }
202
+
203
+ .mv-round li:first-child {
204
+ counter-increment: none;
205
+ border-left-style: dashed;
206
+ margin-bottom: 0.3rem;
207
+ }
208
+
209
+ .mv-phase-tags {
210
+ display: flex;
211
+ flex-wrap: wrap;
212
+ gap: 0.3rem;
213
+ margin-top: 0.3rem;
214
+ }
215
+
216
+ .mv-tag {
217
+ font-size: 0.75rem;
218
+ font-family: var(--sim-mono);
219
+ padding: 0.02rem 0.45rem;
220
+ border-radius: 999px;
221
+ background: var(--sim-accent-soft);
222
+ color: var(--sim-accent);
223
+ }
224
+
225
+ .mv-tag.mv-adversary {
226
+ background: var(--sim-failure-soft);
227
+ color: var(--sim-failure);
228
+ }
229
+
230
+ @media (max-width: 600px) {
231
+ .mv-round li { grid-template-columns: minmax(0, 1fr); gap: 0.2rem; }
232
+ .mv-facts { grid-template-columns: minmax(0, 1fr); gap: 0.15rem; }
233
+ .mv-facts dd { margin-bottom: 0.45rem; }
234
+ }
235
+
236
+ .mv-caveats ul {
237
+ margin: 0;
238
+ padding-left: 1.1rem;
239
+ font-size: 0.88rem;
240
+ }
241
+
242
+ .mv-caveats li {
243
+ list-style: disc;
244
+ margin: 0.2rem 0;
245
+ }
246
+
247
+ /* The declarations as written */
248
+
249
+ .mv-sources {
250
+ position: sticky;
251
+ top: 0.75rem;
252
+ display: flex;
253
+ flex-direction: column;
254
+ gap: 0.6rem;
255
+ max-height: calc(100vh - 1.5rem);
256
+ min-width: 0;
257
+ }
258
+
259
+ @media (max-width: 1100px) {
260
+ .mv-sources { position: static; max-height: none; }
261
+ }
262
+
263
+ .mv-toc {
264
+ display: flex;
265
+ flex-wrap: wrap;
266
+ gap: 0.3rem;
267
+ }
268
+
269
+ .sim-app button.mv-toc-item {
270
+ display: inline-flex;
271
+ align-items: baseline;
272
+ gap: 0.35rem;
273
+ font-family: var(--sim-mono);
274
+ font-size: 0.75rem;
275
+ padding: 0.1rem 0.5rem;
276
+ border-radius: 999px;
277
+ border: 1px solid var(--sim-border);
278
+ background: var(--sim-surface);
279
+ color: var(--sim-text);
280
+ }
281
+
282
+ .sim-app button.mv-toc-item:hover {
283
+ background: var(--sim-surface-2);
284
+ }
285
+
286
+ .mv-source-list {
287
+ overflow-y: auto;
288
+ min-height: 0;
289
+ display: flex;
290
+ flex-direction: column;
291
+ gap: 0.75rem;
292
+ padding-right: 0.15rem;
293
+ }
294
+
295
+ @media (max-width: 1100px) {
296
+ .mv-source-list { overflow: visible; }
297
+ }
298
+
299
+ .mv-source {
300
+ flex-shrink: 0;
301
+ scroll-margin-top: 0.25rem;
302
+ transition: box-shadow 0.3s;
303
+ }
304
+
305
+ .mv-source.mv-flash {
306
+ box-shadow: 0 0 0 3px var(--sim-highlight);
307
+ }
308
+
309
+ .mv-source .algorithm-line.mv-flash-line {
310
+ border-left-color: var(--sim-highlight);
311
+ background-color: var(--sim-highlight-soft);
312
+ }
313
+
314
+ .mv-source .algorithm-header {
315
+ flex-wrap: wrap;
316
+ }
317
+
318
+ .mv-source .algorithm-file {
319
+ font-family: var(--sim-mono);
320
+ }
321
+
322
+ .mv-kind {
323
+ font-family: var(--pico-font-family, system-ui, sans-serif);
324
+ font-size: 0.68rem;
325
+ font-weight: 600;
326
+ text-transform: uppercase;
327
+ letter-spacing: 0.04em;
328
+ color: var(--sim-muted);
329
+ }
330
+
331
+ .mv-source .mv-kind {
332
+ padding: 0.05rem 0.4rem;
333
+ border-radius: 4px;
334
+ background: var(--sim-surface-2);
335
+ border: 1px solid var(--sim-border);
336
+ }
337
+
338
+ /* The definitions: a folded group, each definition folded to its signature */
339
+
340
+ .mv-defs {
341
+ padding: 0;
342
+ }
343
+
344
+ .sim-app button.mv-defs-head,
345
+ .sim-app button.mv-def-head {
346
+ display: flex;
347
+ align-items: baseline;
348
+ gap: 0.6rem;
349
+ width: 100%;
350
+ background: transparent;
351
+ border: none;
352
+ border-radius: 0;
353
+ color: var(--sim-text);
354
+ text-align: left;
355
+ }
356
+
357
+ .sim-app button.mv-defs-head {
358
+ flex-wrap: wrap;
359
+ padding: 0.7rem 1rem;
360
+ }
361
+
362
+ .sim-app button.mv-defs-head .sim-muted {
363
+ font-family: var(--pico-font-family, system-ui, sans-serif);
364
+ font-size: 0.8rem;
365
+ }
366
+
367
+ .sim-app button.mv-defs-head:hover,
368
+ .sim-app button.mv-def-head:hover {
369
+ background: var(--sim-surface-2);
370
+ }
371
+
372
+ .mv-fold {
373
+ color: var(--sim-muted);
374
+ width: 0.8rem;
375
+ flex-shrink: 0;
376
+ }
377
+
378
+ .mv-defs-tools {
379
+ display: flex;
380
+ gap: 0.5rem;
381
+ padding: 0.5rem 1rem;
382
+ border-top: 1px solid var(--sim-border);
383
+ border-bottom: 1px solid var(--sim-border);
384
+ }
385
+
386
+ .mv-defs-tools input[type='search'] {
387
+ flex: 1;
388
+ min-width: 0;
389
+ font-family: var(--sim-mono);
390
+ font-size: 0.82rem;
391
+ }
392
+
393
+ .mv-defs-none {
394
+ padding: 0.5rem 1rem;
395
+ margin: 0;
396
+ }
397
+
398
+ .mv-def {
399
+ border-bottom: 1px solid var(--sim-border);
400
+ scroll-margin-top: 0.25rem;
401
+ }
402
+
403
+ .mv-def:last-child {
404
+ border-bottom: none;
405
+ }
406
+
407
+ .mv-def.mv-flash {
408
+ box-shadow: inset 3px 0 0 var(--sim-highlight);
409
+ }
410
+
411
+ .sim-app button.mv-def-head {
412
+ font-family: var(--sim-mono);
413
+ font-size: 0.8rem;
414
+ padding: 0.3rem 1rem;
415
+ }
416
+
417
+ .mv-def-signature {
418
+ flex: 1;
419
+ min-width: 0;
420
+ overflow: hidden;
421
+ text-overflow: ellipsis;
422
+ white-space: nowrap;
423
+ }
424
+
425
+ .mv-def .algorithm-body {
426
+ padding-top: 0;
427
+ }
428
+
429
+ /* The Lean model: a gutter says what each part translates */
430
+
431
+ .mv-lean {
432
+ display: flex;
433
+ flex-direction: column;
434
+ gap: 1rem;
435
+ min-width: 0;
436
+ }
437
+
438
+ .mv-lean-path {
439
+ font-family: var(--sim-mono);
440
+ font-weight: 400;
441
+ }
442
+
443
+ .mv-note code {
444
+ font-size: 0.78rem;
445
+ }
446
+
447
+ .mv-lean-file .algorithm-body {
448
+ font-size: 12px;
449
+ }
450
+
451
+ .mv-lean-line {
452
+ cursor: default;
453
+ }
454
+
455
+ .mv-lean-line.mv-linked {
456
+ cursor: pointer;
457
+ }
458
+
459
+ .mv-lean-line .line-content {
460
+ white-space: pre-wrap;
461
+ overflow-wrap: anywhere;
462
+ padding-left: 1.5em;
463
+ text-indent: -1.5em;
464
+ }
465
+
466
+ .mv-lean-line.mv-lean-hover {
467
+ background-color: var(--sim-accent-soft);
468
+ }
469
+
470
+ .mv-source .algorithm-line.mv-lean-line.mv-flash-line {
471
+ border-left-color: var(--sim-highlight);
472
+ background-color: var(--sim-highlight-soft);
473
+ }
474
+
475
+ .mv-gutter {
476
+ flex: 0 0 11.5rem;
477
+ display: flex;
478
+ flex-direction: column;
479
+ align-items: flex-end;
480
+ padding: 0 0.6rem 0 0.4rem;
481
+ font-family: var(--pico-font-family, system-ui, sans-serif);
482
+ font-size: 0.7rem;
483
+ line-height: 1.35;
484
+ text-align: right;
485
+ color: var(--sim-muted);
486
+ }
487
+
488
+ .mv-gutter-item {
489
+ display: flex;
490
+ flex-direction: column;
491
+ align-items: flex-end;
492
+ padding-top: 0.2em;
493
+ }
494
+
495
+ .mv-gutter-ref {
496
+ font-family: var(--sim-mono);
497
+ color: var(--sim-accent);
498
+ }
499
+
500
+ @media (max-width: 700px) {
501
+ .mv-lean-line { flex-wrap: wrap; }
502
+ .mv-gutter { flex-basis: 100%; align-items: flex-start; text-align: left; padding-left: 3rem; }
503
+ .mv-gutter:empty { display: none; }
504
+ .mv-gutter-item { flex-direction: row; gap: 0.4rem; }
505
+ }
506
+
507
+ .sim-app button.mv-lean-button {
508
+ font-size: 0.75rem !important;
509
+ --pico-form-element-spacing-vertical: 0.05rem;
510
+ --pico-form-element-spacing-horizontal: 0.5rem;
511
+ }
512
+
513
+ .mv-source .algorithm-line.mv-to-lean {
514
+ cursor: pointer;
515
+ }
516
+
517
+ .mv-source .algorithm-line.mv-to-lean-line .line-number {
518
+ color: var(--sim-accent);
519
+ font-weight: 600;
520
+ }