@swifttui/web 0.0.14 → 0.0.16

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 (92) hide show
  1. package/README.md +24 -10
  2. package/dist/index.d.ts +9 -0
  3. package/dist/index.js +9 -0
  4. package/dist/manifest.d.ts +2 -0
  5. package/dist/manifest.js +2 -0
  6. package/dist/src/AccessibilityTree.js +156 -0
  7. package/dist/src/AccessibilityTree.js.map +1 -0
  8. package/dist/src/BoxDrawingRenderer.js +1106 -0
  9. package/dist/src/BoxDrawingRenderer.js.map +1 -0
  10. package/dist/src/WebHostApp.d.ts +41 -0
  11. package/dist/src/WebHostApp.js +135 -0
  12. package/dist/src/WebHostApp.js.map +1 -0
  13. package/dist/src/WebHostSceneManifest.d.ts +18 -0
  14. package/dist/src/WebHostSceneManifest.js +70 -0
  15. package/dist/src/WebHostSceneManifest.js.map +1 -0
  16. package/dist/src/WebHostSceneRuntime.d.ts +112 -0
  17. package/dist/src/WebHostSceneRuntime.js +651 -0
  18. package/dist/src/WebHostSceneRuntime.js.map +1 -0
  19. package/dist/src/WebHostSurfaceTransport.d.ts +166 -0
  20. package/dist/src/WebHostSurfaceTransport.js +252 -0
  21. package/dist/src/WebHostSurfaceTransport.js.map +1 -0
  22. package/dist/src/WebHostTerminalStyle.d.ts +92 -0
  23. package/dist/src/WebHostTerminalStyle.js +277 -0
  24. package/dist/src/WebHostTerminalStyle.js.map +1 -0
  25. package/dist/src/WebHostTestFixtures.d.ts +5 -0
  26. package/dist/src/WebHostTestFixtures.js +9 -0
  27. package/dist/src/WebHostTestFixtures.js.map +1 -0
  28. package/dist/src/WebSocketSceneBridge.d.ts +53 -0
  29. package/dist/src/WebSocketSceneBridge.js +124 -0
  30. package/dist/src/WebSocketSceneBridge.js.map +1 -0
  31. package/dist/src/wasi/BrowserWASIBridge.d.ts +33 -0
  32. package/dist/src/wasi/BrowserWASIBridge.js +97 -0
  33. package/dist/src/wasi/BrowserWASIBridge.js.map +1 -0
  34. package/dist/src/wasi/SharedInputQueue.d.ts +31 -0
  35. package/dist/src/wasi/SharedInputQueue.js +102 -0
  36. package/dist/src/wasi/SharedInputQueue.js.map +1 -0
  37. package/dist/src/wasi/StdIOPipe.d.ts +15 -0
  38. package/dist/src/wasi/StdIOPipe.js +56 -0
  39. package/dist/src/wasi/StdIOPipe.js.map +1 -0
  40. package/dist/src/wasi/WasiPollScheduler.js +114 -0
  41. package/dist/src/wasi/WasiPollScheduler.js.map +1 -0
  42. package/dist/src/wasi/WasmSceneRuntime.d.ts +23 -0
  43. package/dist/src/wasi/WasmSceneRuntime.js +119 -0
  44. package/dist/src/wasi/WasmSceneRuntime.js.map +1 -0
  45. package/dist/src/wasi/WasmSceneWorker.d.ts +27 -0
  46. package/dist/src/wasi/WasmSceneWorker.js +109 -0
  47. package/dist/src/wasi/WasmSceneWorker.js.map +1 -0
  48. package/dist/testing.d.ts +2 -0
  49. package/dist/testing.js +2 -0
  50. package/dist/wasi-worker.d.ts +2 -0
  51. package/dist/wasi-worker.js +2 -0
  52. package/dist/wasi.d.ts +6 -0
  53. package/dist/wasi.js +6 -0
  54. package/dist/websocket.d.ts +2 -0
  55. package/dist/websocket.js +2 -0
  56. package/package.json +49 -18
  57. package/AGENTS.md +0 -52
  58. package/cli.ts +0 -168
  59. package/index.html +0 -50
  60. package/index.ts +0 -8
  61. package/manifest.ts +0 -1
  62. package/src/AccessibilityTree.ts +0 -262
  63. package/src/BoxDrawingRenderer.ts +0 -585
  64. package/src/PublicEntrypointBoundary.test.ts +0 -20
  65. package/src/WebHostApp.test.ts +0 -222
  66. package/src/WebHostApp.ts +0 -269
  67. package/src/WebHostSceneManifest.test.ts +0 -38
  68. package/src/WebHostSceneManifest.ts +0 -156
  69. package/src/WebHostSceneRuntime.test.ts +0 -1982
  70. package/src/WebHostSceneRuntime.ts +0 -1142
  71. package/src/WebHostSurfaceTransport.test.ts +0 -362
  72. package/src/WebHostSurfaceTransport.ts +0 -691
  73. package/src/WebHostTerminalStyle.test.ts +0 -123
  74. package/src/WebHostTerminalStyle.ts +0 -471
  75. package/src/WebHostTestFixtures.ts +0 -10
  76. package/src/WebSocketSceneBridge.test.ts +0 -198
  77. package/src/WebSocketSceneBridge.ts +0 -233
  78. package/src/browser.ts +0 -59
  79. package/src/wasi/BrowserWASIBridge.test.ts +0 -168
  80. package/src/wasi/BrowserWASIBridge.ts +0 -167
  81. package/src/wasi/SharedInputQueue.test.ts +0 -146
  82. package/src/wasi/SharedInputQueue.ts +0 -199
  83. package/src/wasi/StdIOPipe.ts +0 -72
  84. package/src/wasi/WasiPollScheduler.test.ts +0 -176
  85. package/src/wasi/WasiPollScheduler.ts +0 -305
  86. package/src/wasi/WasmSceneRuntime.ts +0 -205
  87. package/src/wasi/WasmSceneWorker.ts +0 -182
  88. package/testing.ts +0 -1
  89. package/tsconfig.json +0 -29
  90. package/wasi-worker.ts +0 -1
  91. package/wasi.ts +0 -4
  92. package/websocket.ts +0 -1
@@ -0,0 +1,1106 @@
1
+ //#region src/BoxDrawingRenderer.ts
2
+ const none = 0;
3
+ const light = 1;
4
+ const heavy = 2;
5
+ const double = 3;
6
+ const lineSpecs = {
7
+ 9472: [
8
+ none,
9
+ light,
10
+ none,
11
+ light
12
+ ],
13
+ 9473: [
14
+ none,
15
+ heavy,
16
+ none,
17
+ heavy
18
+ ],
19
+ 9474: [
20
+ light,
21
+ none,
22
+ light,
23
+ none
24
+ ],
25
+ 9475: [
26
+ heavy,
27
+ none,
28
+ heavy,
29
+ none
30
+ ],
31
+ 9484: [
32
+ none,
33
+ light,
34
+ light,
35
+ none
36
+ ],
37
+ 9485: [
38
+ none,
39
+ heavy,
40
+ light,
41
+ none
42
+ ],
43
+ 9486: [
44
+ none,
45
+ light,
46
+ heavy,
47
+ none
48
+ ],
49
+ 9487: [
50
+ none,
51
+ heavy,
52
+ heavy,
53
+ none
54
+ ],
55
+ 9488: [
56
+ none,
57
+ none,
58
+ light,
59
+ light
60
+ ],
61
+ 9489: [
62
+ none,
63
+ none,
64
+ light,
65
+ heavy
66
+ ],
67
+ 9490: [
68
+ none,
69
+ none,
70
+ heavy,
71
+ light
72
+ ],
73
+ 9491: [
74
+ none,
75
+ none,
76
+ heavy,
77
+ heavy
78
+ ],
79
+ 9492: [
80
+ light,
81
+ light,
82
+ none,
83
+ none
84
+ ],
85
+ 9493: [
86
+ light,
87
+ heavy,
88
+ none,
89
+ none
90
+ ],
91
+ 9494: [
92
+ heavy,
93
+ light,
94
+ none,
95
+ none
96
+ ],
97
+ 9495: [
98
+ heavy,
99
+ heavy,
100
+ none,
101
+ none
102
+ ],
103
+ 9496: [
104
+ light,
105
+ none,
106
+ none,
107
+ light
108
+ ],
109
+ 9497: [
110
+ light,
111
+ none,
112
+ none,
113
+ heavy
114
+ ],
115
+ 9498: [
116
+ heavy,
117
+ none,
118
+ none,
119
+ light
120
+ ],
121
+ 9499: [
122
+ heavy,
123
+ none,
124
+ none,
125
+ heavy
126
+ ],
127
+ 9500: [
128
+ light,
129
+ light,
130
+ light,
131
+ none
132
+ ],
133
+ 9501: [
134
+ light,
135
+ heavy,
136
+ light,
137
+ none
138
+ ],
139
+ 9502: [
140
+ heavy,
141
+ light,
142
+ light,
143
+ none
144
+ ],
145
+ 9503: [
146
+ light,
147
+ light,
148
+ heavy,
149
+ none
150
+ ],
151
+ 9504: [
152
+ heavy,
153
+ light,
154
+ heavy,
155
+ none
156
+ ],
157
+ 9505: [
158
+ heavy,
159
+ heavy,
160
+ light,
161
+ none
162
+ ],
163
+ 9506: [
164
+ light,
165
+ heavy,
166
+ heavy,
167
+ none
168
+ ],
169
+ 9507: [
170
+ heavy,
171
+ heavy,
172
+ heavy,
173
+ none
174
+ ],
175
+ 9508: [
176
+ light,
177
+ none,
178
+ light,
179
+ light
180
+ ],
181
+ 9509: [
182
+ light,
183
+ none,
184
+ light,
185
+ heavy
186
+ ],
187
+ 9510: [
188
+ heavy,
189
+ none,
190
+ light,
191
+ light
192
+ ],
193
+ 9511: [
194
+ light,
195
+ none,
196
+ heavy,
197
+ light
198
+ ],
199
+ 9512: [
200
+ heavy,
201
+ none,
202
+ heavy,
203
+ light
204
+ ],
205
+ 9513: [
206
+ heavy,
207
+ none,
208
+ light,
209
+ heavy
210
+ ],
211
+ 9514: [
212
+ light,
213
+ none,
214
+ heavy,
215
+ heavy
216
+ ],
217
+ 9515: [
218
+ heavy,
219
+ none,
220
+ heavy,
221
+ heavy
222
+ ],
223
+ 9516: [
224
+ none,
225
+ light,
226
+ light,
227
+ light
228
+ ],
229
+ 9517: [
230
+ none,
231
+ light,
232
+ light,
233
+ heavy
234
+ ],
235
+ 9518: [
236
+ none,
237
+ heavy,
238
+ light,
239
+ light
240
+ ],
241
+ 9519: [
242
+ none,
243
+ heavy,
244
+ light,
245
+ heavy
246
+ ],
247
+ 9520: [
248
+ none,
249
+ light,
250
+ heavy,
251
+ light
252
+ ],
253
+ 9521: [
254
+ none,
255
+ light,
256
+ heavy,
257
+ heavy
258
+ ],
259
+ 9522: [
260
+ none,
261
+ heavy,
262
+ heavy,
263
+ light
264
+ ],
265
+ 9523: [
266
+ none,
267
+ heavy,
268
+ heavy,
269
+ heavy
270
+ ],
271
+ 9524: [
272
+ light,
273
+ light,
274
+ none,
275
+ light
276
+ ],
277
+ 9525: [
278
+ light,
279
+ light,
280
+ none,
281
+ heavy
282
+ ],
283
+ 9526: [
284
+ light,
285
+ heavy,
286
+ none,
287
+ light
288
+ ],
289
+ 9527: [
290
+ light,
291
+ heavy,
292
+ none,
293
+ heavy
294
+ ],
295
+ 9528: [
296
+ heavy,
297
+ light,
298
+ none,
299
+ light
300
+ ],
301
+ 9529: [
302
+ heavy,
303
+ light,
304
+ none,
305
+ heavy
306
+ ],
307
+ 9530: [
308
+ heavy,
309
+ heavy,
310
+ none,
311
+ light
312
+ ],
313
+ 9531: [
314
+ heavy,
315
+ heavy,
316
+ none,
317
+ heavy
318
+ ],
319
+ 9532: [
320
+ light,
321
+ light,
322
+ light,
323
+ light
324
+ ],
325
+ 9533: [
326
+ light,
327
+ light,
328
+ light,
329
+ heavy
330
+ ],
331
+ 9534: [
332
+ light,
333
+ heavy,
334
+ light,
335
+ light
336
+ ],
337
+ 9535: [
338
+ light,
339
+ heavy,
340
+ light,
341
+ heavy
342
+ ],
343
+ 9536: [
344
+ heavy,
345
+ light,
346
+ light,
347
+ light
348
+ ],
349
+ 9537: [
350
+ light,
351
+ light,
352
+ heavy,
353
+ light
354
+ ],
355
+ 9538: [
356
+ heavy,
357
+ light,
358
+ heavy,
359
+ light
360
+ ],
361
+ 9539: [
362
+ heavy,
363
+ light,
364
+ light,
365
+ heavy
366
+ ],
367
+ 9540: [
368
+ heavy,
369
+ heavy,
370
+ light,
371
+ light
372
+ ],
373
+ 9541: [
374
+ light,
375
+ light,
376
+ heavy,
377
+ heavy
378
+ ],
379
+ 9542: [
380
+ light,
381
+ heavy,
382
+ heavy,
383
+ light
384
+ ],
385
+ 9543: [
386
+ heavy,
387
+ heavy,
388
+ light,
389
+ heavy
390
+ ],
391
+ 9544: [
392
+ light,
393
+ heavy,
394
+ heavy,
395
+ heavy
396
+ ],
397
+ 9545: [
398
+ heavy,
399
+ light,
400
+ heavy,
401
+ heavy
402
+ ],
403
+ 9546: [
404
+ heavy,
405
+ heavy,
406
+ heavy,
407
+ light
408
+ ],
409
+ 9547: [
410
+ heavy,
411
+ heavy,
412
+ heavy,
413
+ heavy
414
+ ],
415
+ 9552: [
416
+ none,
417
+ double,
418
+ none,
419
+ double
420
+ ],
421
+ 9553: [
422
+ double,
423
+ none,
424
+ double,
425
+ none
426
+ ],
427
+ 9554: [
428
+ none,
429
+ double,
430
+ light,
431
+ none
432
+ ],
433
+ 9555: [
434
+ none,
435
+ light,
436
+ double,
437
+ none
438
+ ],
439
+ 9556: [
440
+ none,
441
+ double,
442
+ double,
443
+ none
444
+ ],
445
+ 9557: [
446
+ none,
447
+ none,
448
+ light,
449
+ double
450
+ ],
451
+ 9558: [
452
+ none,
453
+ none,
454
+ double,
455
+ light
456
+ ],
457
+ 9559: [
458
+ none,
459
+ none,
460
+ double,
461
+ double
462
+ ],
463
+ 9560: [
464
+ light,
465
+ double,
466
+ none,
467
+ none
468
+ ],
469
+ 9561: [
470
+ double,
471
+ light,
472
+ none,
473
+ none
474
+ ],
475
+ 9562: [
476
+ double,
477
+ double,
478
+ none,
479
+ none
480
+ ],
481
+ 9563: [
482
+ light,
483
+ none,
484
+ none,
485
+ double
486
+ ],
487
+ 9564: [
488
+ double,
489
+ none,
490
+ none,
491
+ light
492
+ ],
493
+ 9565: [
494
+ double,
495
+ none,
496
+ none,
497
+ double
498
+ ],
499
+ 9566: [
500
+ light,
501
+ double,
502
+ light,
503
+ none
504
+ ],
505
+ 9567: [
506
+ double,
507
+ light,
508
+ double,
509
+ none
510
+ ],
511
+ 9568: [
512
+ double,
513
+ double,
514
+ double,
515
+ none
516
+ ],
517
+ 9569: [
518
+ light,
519
+ none,
520
+ light,
521
+ double
522
+ ],
523
+ 9570: [
524
+ double,
525
+ none,
526
+ double,
527
+ light
528
+ ],
529
+ 9571: [
530
+ double,
531
+ none,
532
+ double,
533
+ double
534
+ ],
535
+ 9572: [
536
+ none,
537
+ double,
538
+ light,
539
+ double
540
+ ],
541
+ 9573: [
542
+ none,
543
+ light,
544
+ double,
545
+ light
546
+ ],
547
+ 9574: [
548
+ none,
549
+ double,
550
+ double,
551
+ double
552
+ ],
553
+ 9575: [
554
+ light,
555
+ double,
556
+ none,
557
+ double
558
+ ],
559
+ 9576: [
560
+ double,
561
+ light,
562
+ none,
563
+ light
564
+ ],
565
+ 9577: [
566
+ double,
567
+ double,
568
+ none,
569
+ double
570
+ ],
571
+ 9578: [
572
+ light,
573
+ double,
574
+ light,
575
+ double
576
+ ],
577
+ 9579: [
578
+ double,
579
+ light,
580
+ double,
581
+ light
582
+ ],
583
+ 9580: [
584
+ double,
585
+ double,
586
+ double,
587
+ double
588
+ ],
589
+ 9588: [
590
+ none,
591
+ none,
592
+ none,
593
+ light
594
+ ],
595
+ 9589: [
596
+ light,
597
+ none,
598
+ none,
599
+ none
600
+ ],
601
+ 9590: [
602
+ none,
603
+ light,
604
+ none,
605
+ none
606
+ ],
607
+ 9591: [
608
+ none,
609
+ none,
610
+ light,
611
+ none
612
+ ],
613
+ 9592: [
614
+ none,
615
+ none,
616
+ none,
617
+ heavy
618
+ ],
619
+ 9593: [
620
+ heavy,
621
+ none,
622
+ none,
623
+ none
624
+ ],
625
+ 9594: [
626
+ none,
627
+ heavy,
628
+ none,
629
+ none
630
+ ],
631
+ 9595: [
632
+ none,
633
+ none,
634
+ heavy,
635
+ none
636
+ ],
637
+ 9596: [
638
+ none,
639
+ heavy,
640
+ none,
641
+ light
642
+ ],
643
+ 9597: [
644
+ light,
645
+ none,
646
+ heavy,
647
+ none
648
+ ],
649
+ 9598: [
650
+ none,
651
+ light,
652
+ none,
653
+ heavy
654
+ ],
655
+ 9599: [
656
+ heavy,
657
+ none,
658
+ light,
659
+ none
660
+ ]
661
+ };
662
+ function canRenderBoxDrawing(text) {
663
+ const codePoint = singleCodePoint(text);
664
+ if (codePoint === void 0) return false;
665
+ return codePoint >= 9472 && codePoint <= 9631 || codePoint >= 10240 && codePoint <= 10495;
666
+ }
667
+ function drawBoxDrawing(context, text, rect) {
668
+ const codePoint = singleCodePoint(text);
669
+ if (codePoint === void 0) return false;
670
+ if (codePoint >= 9472 && codePoint <= 9599) return drawBoxDrawingCodePoint(context, codePoint, rect);
671
+ if (codePoint >= 9600 && codePoint <= 9631) return drawBlockElement(context, codePoint, rect);
672
+ if (codePoint >= 10240 && codePoint <= 10495) return drawBraille(context, codePoint, rect);
673
+ return false;
674
+ }
675
+ function singleCodePoint(text) {
676
+ const characters = Array.from(text);
677
+ if (characters.length !== 1) return;
678
+ return characters[0]?.codePointAt(0);
679
+ }
680
+ function drawBoxDrawingCodePoint(context, codePoint, rect) {
681
+ const spec = lineSpecs[codePoint];
682
+ if (spec) {
683
+ drawCellLines(context, spec, rect);
684
+ return true;
685
+ }
686
+ switch (codePoint) {
687
+ case 9476:
688
+ drawDashedHorizontal(context, rect, light, 3);
689
+ return true;
690
+ case 9477:
691
+ drawDashedHorizontal(context, rect, heavy, 3);
692
+ return true;
693
+ case 9478:
694
+ drawDashedVertical(context, rect, light, 3);
695
+ return true;
696
+ case 9479:
697
+ drawDashedVertical(context, rect, heavy, 3);
698
+ return true;
699
+ case 9480:
700
+ drawDashedHorizontal(context, rect, light, 4);
701
+ return true;
702
+ case 9481:
703
+ drawDashedHorizontal(context, rect, heavy, 4);
704
+ return true;
705
+ case 9482:
706
+ drawDashedVertical(context, rect, light, 4);
707
+ return true;
708
+ case 9483:
709
+ drawDashedVertical(context, rect, heavy, 4);
710
+ return true;
711
+ case 9548:
712
+ drawDashedHorizontal(context, rect, light, 2);
713
+ return true;
714
+ case 9549:
715
+ drawDashedHorizontal(context, rect, heavy, 2);
716
+ return true;
717
+ case 9550:
718
+ drawDashedVertical(context, rect, light, 2);
719
+ return true;
720
+ case 9551:
721
+ drawDashedVertical(context, rect, heavy, 2);
722
+ return true;
723
+ case 9585:
724
+ drawDiagonal(context, rect, false);
725
+ return true;
726
+ case 9586:
727
+ drawDiagonal(context, rect, true);
728
+ return true;
729
+ case 9587:
730
+ drawDiagonal(context, rect, false);
731
+ drawDiagonal(context, rect, true);
732
+ return true;
733
+ case 9581:
734
+ drawArc(context, rect, "topLeft");
735
+ return true;
736
+ case 9582:
737
+ drawArc(context, rect, "topRight");
738
+ return true;
739
+ case 9583:
740
+ drawArc(context, rect, "bottomRight");
741
+ return true;
742
+ case 9584:
743
+ drawArc(context, rect, "bottomLeft");
744
+ return true;
745
+ default: return false;
746
+ }
747
+ }
748
+ function strokeMetrics(rect) {
749
+ const unit = Math.max(1, Math.round(Math.min(rect.width, rect.height) / 16));
750
+ return {
751
+ light: unit,
752
+ heavy: unit * 2,
753
+ doubleGap: unit
754
+ };
755
+ }
756
+ function drawCellLines(context, spec, rect) {
757
+ const metrics = strokeMetrics(rect);
758
+ const edges = [
759
+ [spec[0], "north"],
760
+ [spec[1], "east"],
761
+ [spec[2], "south"],
762
+ [spec[3], "west"]
763
+ ];
764
+ for (const [weight, direction] of edges.sort((lhs, rhs) => lhs[0] - rhs[0])) drawHalfStroke(context, weight, direction, rect, metrics);
765
+ }
766
+ function drawHalfStroke(context, weight, direction, rect, metrics) {
767
+ if (weight === none) return;
768
+ const cx = rect.x + rect.width / 2;
769
+ const cy = rect.y + rect.height / 2;
770
+ const maxX = rect.x + rect.width;
771
+ const maxY = rect.y + rect.height;
772
+ const segment = (thickness, offset) => {
773
+ switch (direction) {
774
+ case "north":
775
+ context.fillRect(cx - thickness / 2 + offset, rect.y, thickness, cy - rect.y + thickness / 2);
776
+ break;
777
+ case "south":
778
+ context.fillRect(cx - thickness / 2 + offset, cy - thickness / 2, thickness, maxY - cy + thickness / 2);
779
+ break;
780
+ case "west":
781
+ context.fillRect(rect.x, cy - thickness / 2 + offset, cx - rect.x + thickness / 2, thickness);
782
+ break;
783
+ case "east":
784
+ context.fillRect(cx - thickness / 2, cy - thickness / 2 + offset, maxX - cx + thickness / 2, thickness);
785
+ break;
786
+ }
787
+ };
788
+ switch (weight) {
789
+ case light:
790
+ segment(metrics.light, 0);
791
+ break;
792
+ case heavy:
793
+ segment(metrics.heavy, 0);
794
+ break;
795
+ case double: {
796
+ const thickness = metrics.light;
797
+ const offset = (thickness + metrics.doubleGap) / 2;
798
+ segment(thickness, -offset);
799
+ segment(thickness, offset);
800
+ break;
801
+ }
802
+ }
803
+ }
804
+ function drawDashedHorizontal(context, rect, weight, segments) {
805
+ const metrics = strokeMetrics(rect);
806
+ const thickness = weight === heavy ? metrics.heavy : metrics.light;
807
+ const segmentWidth = rect.width / segments;
808
+ const dashWidth = segmentWidth * .55;
809
+ const gapWidth = segmentWidth - dashWidth;
810
+ const cy = rect.y + rect.height / 2;
811
+ for (let index = 0; index < segments; index += 1) {
812
+ const x = rect.x + index * segmentWidth + gapWidth / 2;
813
+ context.fillRect(x, cy - thickness / 2, dashWidth, thickness);
814
+ }
815
+ }
816
+ function drawDashedVertical(context, rect, weight, segments) {
817
+ const metrics = strokeMetrics(rect);
818
+ const thickness = weight === heavy ? metrics.heavy : metrics.light;
819
+ const segmentHeight = rect.height / segments;
820
+ const dashHeight = segmentHeight * .55;
821
+ const gapHeight = segmentHeight - dashHeight;
822
+ const cx = rect.x + rect.width / 2;
823
+ for (let index = 0; index < segments; index += 1) {
824
+ const y = rect.y + index * segmentHeight + gapHeight / 2;
825
+ context.fillRect(cx - thickness / 2, y, thickness, dashHeight);
826
+ }
827
+ }
828
+ function drawDiagonal(context, rect, descending) {
829
+ context.lineWidth = strokeMetrics(rect).light;
830
+ context.lineCap = "square";
831
+ context.setLineDash([]);
832
+ context.beginPath();
833
+ if (descending) {
834
+ context.moveTo(rect.x, rect.y);
835
+ context.lineTo(rect.x + rect.width, rect.y + rect.height);
836
+ } else {
837
+ context.moveTo(rect.x + rect.width, rect.y);
838
+ context.lineTo(rect.x, rect.y + rect.height);
839
+ }
840
+ context.stroke();
841
+ context.lineCap = "butt";
842
+ }
843
+ function drawArc(context, rect, corner) {
844
+ const metrics = strokeMetrics(rect);
845
+ const cx = rect.x + rect.width / 2;
846
+ const cy = rect.y + rect.height / 2;
847
+ const maxX = rect.x + rect.width;
848
+ const maxY = rect.y + rect.height;
849
+ const radius = Math.min(rect.width, rect.height) * .4;
850
+ const kappa = radius * .5523;
851
+ context.lineWidth = metrics.light;
852
+ context.lineCap = "butt";
853
+ context.setLineDash([]);
854
+ context.beginPath();
855
+ switch (corner) {
856
+ case "topLeft":
857
+ context.moveTo(cx, cy + radius);
858
+ context.lineTo(cx, maxY);
859
+ context.moveTo(cx + radius, cy);
860
+ context.lineTo(maxX, cy);
861
+ context.moveTo(cx, cy + radius);
862
+ context.bezierCurveTo(cx, cy + radius - kappa, cx + radius - kappa, cy, cx + radius, cy);
863
+ break;
864
+ case "topRight":
865
+ context.moveTo(cx, cy + radius);
866
+ context.lineTo(cx, maxY);
867
+ context.moveTo(cx - radius, cy);
868
+ context.lineTo(rect.x, cy);
869
+ context.moveTo(cx - radius, cy);
870
+ context.bezierCurveTo(cx - radius + kappa, cy, cx, cy + radius - kappa, cx, cy + radius);
871
+ break;
872
+ case "bottomRight":
873
+ context.moveTo(cx, cy - radius);
874
+ context.lineTo(cx, rect.y);
875
+ context.moveTo(cx - radius, cy);
876
+ context.lineTo(rect.x, cy);
877
+ context.moveTo(cx, cy - radius);
878
+ context.bezierCurveTo(cx, cy - radius + kappa, cx - radius + kappa, cy, cx - radius, cy);
879
+ break;
880
+ case "bottomLeft":
881
+ context.moveTo(cx, cy - radius);
882
+ context.lineTo(cx, rect.y);
883
+ context.moveTo(cx + radius, cy);
884
+ context.lineTo(maxX, cy);
885
+ context.moveTo(cx + radius, cy);
886
+ context.bezierCurveTo(cx + radius - kappa, cy, cx, cy - radius + kappa, cx, cy - radius);
887
+ break;
888
+ }
889
+ context.stroke();
890
+ }
891
+ function drawBlockElement(context, codePoint, rect) {
892
+ const maxX = rect.x + rect.width;
893
+ const maxY = rect.y + rect.height;
894
+ const lowerEighths = (count) => {
895
+ const height = rect.height * count / 8;
896
+ context.fillRect(rect.x, maxY - height, rect.width, height);
897
+ };
898
+ const leftEighths = (count) => {
899
+ const width = rect.width * count / 8;
900
+ context.fillRect(rect.x, rect.y, width, rect.height);
901
+ };
902
+ switch (codePoint) {
903
+ case 9600:
904
+ context.fillRect(rect.x, rect.y, rect.width, rect.height / 2);
905
+ return true;
906
+ case 9601:
907
+ lowerEighths(1);
908
+ return true;
909
+ case 9602:
910
+ lowerEighths(2);
911
+ return true;
912
+ case 9603:
913
+ lowerEighths(3);
914
+ return true;
915
+ case 9604:
916
+ lowerEighths(4);
917
+ return true;
918
+ case 9605:
919
+ lowerEighths(5);
920
+ return true;
921
+ case 9606:
922
+ lowerEighths(6);
923
+ return true;
924
+ case 9607:
925
+ lowerEighths(7);
926
+ return true;
927
+ case 9608:
928
+ context.fillRect(rect.x, rect.y, rect.width, rect.height);
929
+ return true;
930
+ case 9609:
931
+ leftEighths(7);
932
+ return true;
933
+ case 9610:
934
+ leftEighths(6);
935
+ return true;
936
+ case 9611:
937
+ leftEighths(5);
938
+ return true;
939
+ case 9612:
940
+ leftEighths(4);
941
+ return true;
942
+ case 9613:
943
+ leftEighths(3);
944
+ return true;
945
+ case 9614:
946
+ leftEighths(2);
947
+ return true;
948
+ case 9615:
949
+ leftEighths(1);
950
+ return true;
951
+ case 9616:
952
+ context.fillRect(rect.x + rect.width / 2, rect.y, rect.width / 2, rect.height);
953
+ return true;
954
+ case 9617:
955
+ drawShade(context, rect, "light");
956
+ return true;
957
+ case 9618:
958
+ drawShade(context, rect, "medium");
959
+ return true;
960
+ case 9619:
961
+ drawShade(context, rect, "dark");
962
+ return true;
963
+ case 9620:
964
+ context.fillRect(rect.x, rect.y, rect.width, rect.height / 8);
965
+ return true;
966
+ case 9621:
967
+ context.fillRect(maxX - rect.width / 8, rect.y, rect.width / 8, rect.height);
968
+ return true;
969
+ case 9622:
970
+ fillQuadrants(context, rect, ["bottomLeft"]);
971
+ return true;
972
+ case 9623:
973
+ fillQuadrants(context, rect, ["bottomRight"]);
974
+ return true;
975
+ case 9624:
976
+ fillQuadrants(context, rect, ["topLeft"]);
977
+ return true;
978
+ case 9625:
979
+ fillQuadrants(context, rect, [
980
+ "topLeft",
981
+ "bottomLeft",
982
+ "bottomRight"
983
+ ]);
984
+ return true;
985
+ case 9626:
986
+ fillQuadrants(context, rect, ["topLeft", "bottomRight"]);
987
+ return true;
988
+ case 9627:
989
+ fillQuadrants(context, rect, [
990
+ "topLeft",
991
+ "topRight",
992
+ "bottomLeft"
993
+ ]);
994
+ return true;
995
+ case 9628:
996
+ fillQuadrants(context, rect, [
997
+ "topLeft",
998
+ "topRight",
999
+ "bottomRight"
1000
+ ]);
1001
+ return true;
1002
+ case 9629:
1003
+ fillQuadrants(context, rect, ["topRight"]);
1004
+ return true;
1005
+ case 9630:
1006
+ fillQuadrants(context, rect, ["topRight", "bottomLeft"]);
1007
+ return true;
1008
+ case 9631:
1009
+ fillQuadrants(context, rect, [
1010
+ "topRight",
1011
+ "bottomLeft",
1012
+ "bottomRight"
1013
+ ]);
1014
+ return true;
1015
+ default: return false;
1016
+ }
1017
+ }
1018
+ function fillQuadrants(context, rect, quadrants) {
1019
+ const halfWidth = rect.width / 2;
1020
+ const halfHeight = rect.height / 2;
1021
+ for (const quadrant of quadrants) switch (quadrant) {
1022
+ case "topLeft":
1023
+ context.fillRect(rect.x, rect.y, halfWidth, halfHeight);
1024
+ break;
1025
+ case "topRight":
1026
+ context.fillRect(rect.x + halfWidth, rect.y, halfWidth, halfHeight);
1027
+ break;
1028
+ case "bottomLeft":
1029
+ context.fillRect(rect.x, rect.y + halfHeight, halfWidth, halfHeight);
1030
+ break;
1031
+ case "bottomRight":
1032
+ context.fillRect(rect.x + halfWidth, rect.y + halfHeight, halfWidth, halfHeight);
1033
+ break;
1034
+ }
1035
+ }
1036
+ function drawShade(context, rect, density) {
1037
+ const pixels = density === "light" ? [[0, 0]] : density === "medium" ? [[0, 0], [1, 1]] : [
1038
+ [0, 0],
1039
+ [1, 0],
1040
+ [0, 1]
1041
+ ];
1042
+ for (let y = rect.y; y < rect.y + rect.height; y += 2) for (let x = rect.x; x < rect.x + rect.width; x += 2) for (const [px, py] of pixels) {
1043
+ const dotX = x + (px ?? 0);
1044
+ const dotY = y + (py ?? 0);
1045
+ if (dotX < rect.x + rect.width && dotY < rect.y + rect.height) context.fillRect(dotX, dotY, 1, 1);
1046
+ }
1047
+ }
1048
+ const brailleSubpixels = [
1049
+ [
1050
+ 1,
1051
+ 0,
1052
+ 0
1053
+ ],
1054
+ [
1055
+ 8,
1056
+ 1,
1057
+ 0
1058
+ ],
1059
+ [
1060
+ 2,
1061
+ 0,
1062
+ 1
1063
+ ],
1064
+ [
1065
+ 16,
1066
+ 1,
1067
+ 1
1068
+ ],
1069
+ [
1070
+ 4,
1071
+ 0,
1072
+ 2
1073
+ ],
1074
+ [
1075
+ 32,
1076
+ 1,
1077
+ 2
1078
+ ],
1079
+ [
1080
+ 64,
1081
+ 0,
1082
+ 3
1083
+ ],
1084
+ [
1085
+ 128,
1086
+ 1,
1087
+ 3
1088
+ ]
1089
+ ];
1090
+ function drawBraille(context, codePoint, rect) {
1091
+ const mask = codePoint - 10240;
1092
+ if (mask === 0) return true;
1093
+ const cellWidth = rect.width / 2;
1094
+ const rowHeight = rect.height / 4;
1095
+ for (const [bit, col, row] of brailleSubpixels) {
1096
+ if ((mask & bit) === 0) continue;
1097
+ const x = rect.x + col * cellWidth;
1098
+ const y = rect.y + row * rowHeight;
1099
+ context.fillRect(x, y, cellWidth, rowHeight);
1100
+ }
1101
+ return true;
1102
+ }
1103
+ //#endregion
1104
+ export { canRenderBoxDrawing, drawBoxDrawing };
1105
+
1106
+ //# sourceMappingURL=BoxDrawingRenderer.js.map