@bigpixelrocket/uiok 0.3.0 → 0.5.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/CHANGELOG.md +50 -1
- package/dist/button/TextLink.d.ts +19 -3
- package/dist/button/TextLink.js +4 -3
- package/dist/dialog/ConfirmDialog.d.ts +7 -1
- package/dist/dialog/ConfirmDialog.js +2 -2
- package/dist/dialog/ModalDialog.js +8 -2
- package/dist/dialog/ProgressDialog.d.ts +7 -1
- package/dist/dialog/ProgressDialog.js +2 -2
- package/dist/dialog/TypedNameDialog.d.ts +8 -0
- package/dist/field/Check.d.ts +9 -2
- package/dist/field/Check.js +5 -4
- package/dist/field/Controls.d.ts +198 -0
- package/dist/field/Controls.js +94 -0
- package/dist/field/FieldLayout.d.ts +126 -0
- package/dist/field/FieldLayout.js +89 -0
- package/dist/field/index.d.ts +9 -6
- package/dist/field/index.js +9 -6
- package/dist/frame/Dock.js +1 -1
- package/dist/frame/SidebarResizer.js +1 -1
- package/dist/frame/Tree.d.ts +17 -4
- package/dist/frame/Tree.js +34 -9
- package/dist/frame/WindowFrame.js +2 -1
- package/dist/frame/frame.css +26 -4
- package/dist/icon/ProductMark.d.ts +57 -0
- package/dist/icon/ProductMark.js +26 -0
- package/dist/icon/icon.css +53 -0
- package/dist/icon/index.d.ts +3 -1
- package/dist/icon/index.js +3 -1
- package/dist/labels/UiokLabels.d.ts +3 -0
- package/dist/labels/UiokLabels.js +3 -1
- package/dist/labels/index.d.ts +1 -0
- package/dist/labels/index.js +1 -0
- package/dist/labels/settings.d.ts +6 -0
- package/dist/labels/settings.js +1 -0
- package/dist/labels/viewer.d.ts +193 -0
- package/dist/labels/viewer.js +124 -0
- package/dist/listing/Listing.d.ts +60 -4
- package/dist/listing/Listing.js +39 -10
- package/dist/listing/ListingScope.d.ts +7 -0
- package/dist/listing/ListingScope.js +8 -0
- package/dist/listing/PaneMessage.d.ts +28 -0
- package/dist/listing/PaneMessage.js +12 -0
- package/dist/listing/Timeline.d.ts +51 -0
- package/dist/listing/Timeline.js +28 -0
- package/dist/listing/index.d.ts +7 -3
- package/dist/listing/index.js +6 -2
- package/dist/listing/listing.css +185 -22
- package/dist/log/Ansi.logic.d.ts +27 -0
- package/dist/log/Ansi.logic.js +203 -0
- package/dist/log/LogWell.d.ts +11 -2
- package/dist/log/LogWell.js +15 -3
- package/dist/log/index.d.ts +1 -0
- package/dist/log/index.js +1 -0
- package/dist/log/log.css +80 -0
- package/dist/menu/Menu.d.ts +89 -0
- package/dist/menu/Menu.js +143 -0
- package/dist/menu/Menu.logic.d.ts +56 -0
- package/dist/menu/Menu.logic.js +64 -0
- package/dist/menu/index.d.ts +5 -1
- package/dist/menu/index.js +5 -1
- package/dist/menu/menu.css +51 -0
- package/dist/palette/Palette.d.ts +3 -2
- package/dist/palette/Palette.js +8 -4
- package/dist/palette/PaletteRows.d.ts +129 -0
- package/dist/palette/PaletteRows.js +74 -0
- package/dist/palette/index.d.ts +5 -2
- package/dist/palette/index.js +5 -2
- package/dist/pane/PaneFrame.d.ts +22 -1
- package/dist/pane/PaneFrame.js +42 -5
- package/dist/pane/index.d.ts +1 -1
- package/dist/shell/SettingsDialog.d.ts +20 -2
- package/dist/shell/SettingsDialog.js +13 -3
- package/dist/shell/index.d.ts +1 -1
- package/dist/styles.css +4 -0
- package/dist/surface/Card.d.ts +18 -0
- package/dist/surface/Card.js +10 -0
- package/dist/surface/FactTable.d.ts +44 -0
- package/dist/surface/FactTable.js +33 -0
- package/dist/surface/Notice.d.ts +45 -0
- package/dist/surface/Notice.js +27 -0
- package/dist/surface/index.d.ts +7 -3
- package/dist/surface/index.js +7 -3
- package/dist/surface/surface.css +64 -0
- package/dist/tabs/PageTabs.d.ts +6 -0
- package/dist/tabs/PageTabs.js +1 -1
- package/dist/tabs/tabs.css +14 -0
- package/dist/terminal/TerminalBox.d.ts +30 -0
- package/dist/terminal/TerminalBox.js +17 -0
- package/dist/terminal/index.d.ts +3 -1
- package/dist/terminal/index.js +3 -1
- package/dist/terminal/terminal.css +29 -0
- package/dist/themes/themes.generated.css +21 -0
- package/dist/themes/tokens.d.ts +1 -0
- package/dist/themes/tokens.js +16 -1
- package/dist/viewer/AudioView.d.ts +13 -0
- package/dist/viewer/AudioView.js +25 -0
- package/dist/viewer/HexJump.logic.d.ts +16 -0
- package/dist/viewer/HexJump.logic.js +27 -0
- package/dist/viewer/HexRows.logic.d.ts +55 -0
- package/dist/viewer/HexRows.logic.js +84 -0
- package/dist/viewer/HexSelection.logic.d.ts +57 -0
- package/dist/viewer/HexSelection.logic.js +68 -0
- package/dist/viewer/HexView.d.ts +10 -0
- package/dist/viewer/HexView.js +291 -0
- package/dist/viewer/HexViewport.logic.d.ts +61 -0
- package/dist/viewer/HexViewport.logic.js +79 -0
- package/dist/viewer/ImageView.d.ts +19 -0
- package/dist/viewer/ImageView.js +230 -0
- package/dist/viewer/ImageZoom.logic.d.ts +65 -0
- package/dist/viewer/ImageZoom.logic.js +119 -0
- package/dist/viewer/LatestRead.logic.d.ts +27 -0
- package/dist/viewer/LatestRead.logic.js +55 -0
- package/dist/viewer/MediaControls.d.ts +25 -0
- package/dist/viewer/MediaControls.js +183 -0
- package/dist/viewer/MediaPlayer.logic.d.ts +53 -0
- package/dist/viewer/MediaPlayer.logic.js +68 -0
- package/dist/viewer/PdfView.d.ts +23 -0
- package/dist/viewer/PdfView.js +25 -0
- package/dist/viewer/QuietFocus.d.ts +19 -0
- package/dist/viewer/QuietFocus.js +27 -0
- package/dist/viewer/ScaledScroll.logic.d.ts +30 -0
- package/dist/viewer/ScaledScroll.logic.js +28 -0
- package/dist/viewer/ScaledScrollbar.d.ts +19 -0
- package/dist/viewer/ScaledScrollbar.js +71 -0
- package/dist/viewer/SyntaxHighlighter.d.ts +29 -0
- package/dist/viewer/SyntaxHighlighter.js +144 -0
- package/dist/viewer/SyntaxLanguage.logic.d.ts +110 -0
- package/dist/viewer/SyntaxLanguage.logic.js +283 -0
- package/dist/viewer/SyntaxService.d.ts +75 -0
- package/dist/viewer/SyntaxService.js +49 -0
- package/dist/viewer/SyntaxSession.logic.d.ts +78 -0
- package/dist/viewer/SyntaxSession.logic.js +221 -0
- package/dist/viewer/SyntaxWorker.d.ts +6 -0
- package/dist/viewer/SyntaxWorker.js +8 -0
- package/dist/viewer/TextEncoding.logic.d.ts +35 -0
- package/dist/viewer/TextEncoding.logic.js +58 -0
- package/dist/viewer/TextRows.logic.d.ts +86 -0
- package/dist/viewer/TextRows.logic.js +241 -0
- package/dist/viewer/TextSelection.logic.d.ts +97 -0
- package/dist/viewer/TextSelection.logic.js +139 -0
- package/dist/viewer/TextView.d.ts +13 -0
- package/dist/viewer/TextView.js +448 -0
- package/dist/viewer/TextViewport.logic.d.ts +70 -0
- package/dist/viewer/TextViewport.logic.js +116 -0
- package/dist/viewer/VideoView.d.ts +18 -0
- package/dist/viewer/VideoView.js +53 -0
- package/dist/viewer/ViewerClipboard.d.ts +30 -0
- package/dist/viewer/ViewerClipboard.js +70 -0
- package/dist/viewer/ViewerFrame.logic.d.ts +61 -0
- package/dist/viewer/ViewerFrame.logic.js +130 -0
- package/dist/viewer/ViewerKeys.d.ts +16 -0
- package/dist/viewer/ViewerKeys.js +14 -0
- package/dist/viewer/ViewerScope.d.ts +12 -0
- package/dist/viewer/ViewerScope.js +22 -0
- package/dist/viewer/ViewerViews.d.ts +28 -0
- package/dist/viewer/ViewerViews.js +22 -0
- package/dist/viewer/ViewerWindow.d.ts +53 -0
- package/dist/viewer/ViewerWindow.js +219 -0
- package/dist/viewer/index.d.ts +12 -0
- package/dist/viewer/index.js +12 -0
- package/dist/viewer/types.d.ts +151 -0
- package/dist/viewer/types.js +26 -0
- package/dist/viewer/useElementHeight.d.ts +6 -0
- package/dist/viewer/useElementHeight.js +22 -0
- package/dist/viewer/useElementSize.d.ts +7 -0
- package/dist/viewer/useElementSize.js +24 -0
- package/dist/viewer/useEscapeToClear.d.ts +8 -0
- package/dist/viewer/useEscapeToClear.js +26 -0
- package/dist/viewer/useHexDocument.d.ts +41 -0
- package/dist/viewer/useHexDocument.js +144 -0
- package/dist/viewer/useMediaElement.d.ts +10 -0
- package/dist/viewer/useMediaElement.js +24 -0
- package/dist/viewer/useSyntaxHighlight.d.ts +24 -0
- package/dist/viewer/useSyntaxHighlight.js +133 -0
- package/dist/viewer/useTextDocument.d.ts +66 -0
- package/dist/viewer/useTextDocument.js +245 -0
- package/dist/viewer/viewer.css +645 -0
- package/package.json +7 -1
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
--brand-plate: #11111b;
|
|
16
16
|
--brand-plate-dark: color-mix(in srgb, var(--accent) 70%, var(--brand-plate));
|
|
17
17
|
--brand-badge-dark: color-mix(in srgb, var(--success) 70%, var(--brand-plate));
|
|
18
|
+
--letterbox: #000000;
|
|
18
19
|
--ground: var(--bg);
|
|
19
20
|
--surface: var(--bg-panel);
|
|
20
21
|
--surface-header: var(--bg-header);
|
|
@@ -95,6 +96,7 @@
|
|
|
95
96
|
--cursor-row-bg: #dae3f4;
|
|
96
97
|
--row-meta-text: #5c5f77;
|
|
97
98
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
99
|
+
--product-mark-mix: 100%;
|
|
98
100
|
--hover-wash: rgb(255 255 255 / 50%);
|
|
99
101
|
--pressed-wash: rgb(0 0 0 / 7%);
|
|
100
102
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -233,6 +235,7 @@
|
|
|
233
235
|
--cursor-row-bg: #2d334b;
|
|
234
236
|
--row-meta-text: #9399b2;
|
|
235
237
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
238
|
+
--product-mark-mix: 78%;
|
|
236
239
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
237
240
|
--pressed-wash: rgb(205 214 244 / 12%);
|
|
238
241
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -373,6 +376,7 @@
|
|
|
373
376
|
--cursor-row-bg: #dae3f4;
|
|
374
377
|
--row-meta-text: #5c5f77;
|
|
375
378
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
379
|
+
--product-mark-mix: 100%;
|
|
376
380
|
--hover-wash: rgb(255 255 255 / 50%);
|
|
377
381
|
--pressed-wash: rgb(0 0 0 / 7%);
|
|
378
382
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -510,6 +514,7 @@
|
|
|
510
514
|
--cursor-row-bg: #e6f0fb;
|
|
511
515
|
--row-meta-text: #57606a;
|
|
512
516
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
517
|
+
--product-mark-mix: 100%;
|
|
513
518
|
--hover-wash: rgb(31 35 40 / 3%);
|
|
514
519
|
--pressed-wash: rgb(0 0 0 / 8%);
|
|
515
520
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -647,6 +652,7 @@
|
|
|
647
652
|
--cursor-row-bg: #e9e5bc;
|
|
648
653
|
--row-meta-text: #665c54;
|
|
649
654
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
655
|
+
--product-mark-mix: 100%;
|
|
650
656
|
--hover-wash: rgb(255 255 255 / 50%);
|
|
651
657
|
--pressed-wash: rgb(0 0 0 / 7%);
|
|
652
658
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -784,6 +790,7 @@
|
|
|
784
790
|
--cursor-row-bg: #e7ebf6;
|
|
785
791
|
--row-meta-text: #595b66;
|
|
786
792
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
793
|
+
--product-mark-mix: 100%;
|
|
787
794
|
--hover-wash: rgb(56 58 66 / 3%);
|
|
788
795
|
--pressed-wash: rgb(0 0 0 / 8%);
|
|
789
796
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -921,6 +928,7 @@
|
|
|
921
928
|
--cursor-row-bg: #e5e6e2;
|
|
922
929
|
--row-meta-text: #656083;
|
|
923
930
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
931
|
+
--product-mark-mix: 100%;
|
|
924
932
|
--hover-wash: rgb(255 255 255 / 58%);
|
|
925
933
|
--pressed-wash: rgb(0 0 0 / 7%);
|
|
926
934
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -1058,6 +1066,7 @@
|
|
|
1058
1066
|
--cursor-row-bg: #e7eadf;
|
|
1059
1067
|
--row-meta-text: #47626a;
|
|
1060
1068
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
1069
|
+
--product-mark-mix: 100%;
|
|
1061
1070
|
--hover-wash: rgb(255 255 255 / 50%);
|
|
1062
1071
|
--pressed-wash: rgb(0 0 0 / 2%);
|
|
1063
1072
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -1195,6 +1204,7 @@
|
|
|
1195
1204
|
--cursor-row-bg: #cfd6e5;
|
|
1196
1205
|
--row-meta-text: #4d5a8b;
|
|
1197
1206
|
--glass-edge: rgb(255 255 255 / 60%);
|
|
1207
|
+
--product-mark-mix: 100%;
|
|
1198
1208
|
--hover-wash: rgb(255 255 255 / 50%);
|
|
1199
1209
|
--pressed-wash: rgb(0 0 0 / 5%);
|
|
1200
1210
|
--well-shade: rgb(0 0 0 / 7%);
|
|
@@ -1334,6 +1344,7 @@
|
|
|
1334
1344
|
--cursor-row-bg: #3d455e;
|
|
1335
1345
|
--row-meta-text: #a5adce;
|
|
1336
1346
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
1347
|
+
--product-mark-mix: 78%;
|
|
1337
1348
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
1338
1349
|
--pressed-wash: rgb(0 0 0 / 26%);
|
|
1339
1350
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -1472,6 +1483,7 @@
|
|
|
1472
1483
|
--cursor-row-bg: #323a54;
|
|
1473
1484
|
--row-meta-text: #a5adcb;
|
|
1474
1485
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
1486
|
+
--product-mark-mix: 78%;
|
|
1475
1487
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
1476
1488
|
--pressed-wash: rgb(202 211 245 / 13%);
|
|
1477
1489
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -1610,6 +1622,7 @@
|
|
|
1610
1622
|
--cursor-row-bg: #2d334b;
|
|
1611
1623
|
--row-meta-text: #9399b2;
|
|
1612
1624
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
1625
|
+
--product-mark-mix: 78%;
|
|
1613
1626
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
1614
1627
|
--pressed-wash: rgb(205 214 244 / 12%);
|
|
1615
1628
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -1748,6 +1761,7 @@
|
|
|
1748
1761
|
--cursor-row-bg: #3d3951;
|
|
1749
1762
|
--row-meta-text: #bcc2d3;
|
|
1750
1763
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
1764
|
+
--product-mark-mix: 78%;
|
|
1751
1765
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
1752
1766
|
--pressed-wash: rgb(248 248 242 / 11%);
|
|
1753
1767
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -1886,6 +1900,7 @@
|
|
|
1886
1900
|
--cursor-row-bg: #101e35;
|
|
1887
1901
|
--row-meta-text: #8b949e;
|
|
1888
1902
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
1903
|
+
--product-mark-mix: 78%;
|
|
1889
1904
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
1890
1905
|
--pressed-wash: rgb(230 237 243 / 12%);
|
|
1891
1906
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -2024,6 +2039,7 @@
|
|
|
2024
2039
|
--cursor-row-bg: #313831;
|
|
2025
2040
|
--row-meta-text: #bdae93;
|
|
2026
2041
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
2042
|
+
--product-mark-mix: 78%;
|
|
2027
2043
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
2028
2044
|
--pressed-wash: rgb(0 0 0 / 36%);
|
|
2029
2045
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -2162,6 +2178,7 @@
|
|
|
2162
2178
|
--cursor-row-bg: #3b4854;
|
|
2163
2179
|
--row-meta-text: #adb6c6;
|
|
2164
2180
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
2181
|
+
--product-mark-mix: 78%;
|
|
2165
2182
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
2166
2183
|
--pressed-wash: rgb(0 0 0 / 39%);
|
|
2167
2184
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -2300,6 +2317,7 @@
|
|
|
2300
2317
|
--cursor-row-bg: #303e4e;
|
|
2301
2318
|
--row-meta-text: #9da4b2;
|
|
2302
2319
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
2320
|
+
--product-mark-mix: 78%;
|
|
2303
2321
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
2304
2322
|
--pressed-wash: rgb(0 0 0 / 38%);
|
|
2305
2323
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -2438,6 +2456,7 @@
|
|
|
2438
2456
|
--cursor-row-bg: #312b3f;
|
|
2439
2457
|
--row-meta-text: #908caa;
|
|
2440
2458
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
2459
|
+
--product-mark-mix: 78%;
|
|
2441
2460
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
2442
2461
|
--pressed-wash: rgb(224 222 244 / 12%);
|
|
2443
2462
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -2576,6 +2595,7 @@
|
|
|
2576
2595
|
--cursor-row-bg: #05384c;
|
|
2577
2596
|
--row-meta-text: #93a1a1;
|
|
2578
2597
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
2598
|
+
--product-mark-mix: 78%;
|
|
2579
2599
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
2580
2600
|
--pressed-wash: rgb(147 161 161 / 13%);
|
|
2581
2601
|
--well-shade: rgb(0 0 0 / 24%);
|
|
@@ -2714,6 +2734,7 @@
|
|
|
2714
2734
|
--cursor-row-bg: #272e43;
|
|
2715
2735
|
--row-meta-text: #8e96bc;
|
|
2716
2736
|
--glass-edge: rgb(255 255 255 / 10%);
|
|
2737
|
+
--product-mark-mix: 78%;
|
|
2717
2738
|
--hover-wash: rgb(255 255 255 / 6%);
|
|
2718
2739
|
--pressed-wash: rgb(192 202 245 / 13%);
|
|
2719
2740
|
--well-shade: rgb(0 0 0 / 24%);
|
package/dist/themes/tokens.d.ts
CHANGED
|
@@ -109,6 +109,7 @@ declare function derivedTokens(palette: ThemePalette, terminal: TerminalPalette,
|
|
|
109
109
|
'--cursor-row-bg': `#${string}`;
|
|
110
110
|
'--row-meta-text': `#${string}`;
|
|
111
111
|
'--glass-edge': string;
|
|
112
|
+
'--product-mark-mix': `${number}%`;
|
|
112
113
|
'--hover-wash': string;
|
|
113
114
|
'--pressed-wash': string;
|
|
114
115
|
'--well-shade': string;
|
package/dist/themes/tokens.js
CHANGED
|
@@ -146,6 +146,7 @@ const BY_APPEARANCE = {
|
|
|
146
146
|
hoverWhite: 50,
|
|
147
147
|
fileListLift: 30,
|
|
148
148
|
terminalSelection: 22,
|
|
149
|
+
productMarkMix: '100%',
|
|
149
150
|
pressedBlack: 7,
|
|
150
151
|
shadow: { raised: 12, popover: 18, modal: 28, modalContact: 12, modalRing: 0 }
|
|
151
152
|
},
|
|
@@ -156,6 +157,7 @@ const BY_APPEARANCE = {
|
|
|
156
157
|
hoverWhite: 6,
|
|
157
158
|
fileListLift: 0,
|
|
158
159
|
terminalSelection: 28,
|
|
160
|
+
productMarkMix: '78%',
|
|
159
161
|
pressedBlack: 24,
|
|
160
162
|
shadow: { raised: 30, popover: 45, modal: 55, modalContact: 35, modalRing: 35 }
|
|
161
163
|
}
|
|
@@ -778,6 +780,9 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
778
780
|
// HOVER_FROM_REST from rest (white, or the text's tint on a white panel;
|
|
779
781
|
// see hoverShare); a pressed outlined control darkens instead.
|
|
780
782
|
'--glass-edge': look.glassEdge,
|
|
783
|
+
// How much of a product's brand colour its mark (ProductMark) shows, the
|
|
784
|
+
// rest the text tone; the brand colour itself is the app's data.
|
|
785
|
+
'--product-mark-mix': look.productMarkMix,
|
|
781
786
|
'--hover-wash': translucent(hoverTone, hoverShare),
|
|
782
787
|
// A pressed outlined control: black where it darkens the ground enough
|
|
783
788
|
// and keeps the text, else the text's tint (see pressedWash).
|
|
@@ -945,6 +950,8 @@ export const FIXED_TOKENS = {
|
|
|
945
950
|
'--brand-plate': BRAND_PLATE,
|
|
946
951
|
'--brand-plate-dark': 'color-mix(in srgb, var(--accent) 70%, var(--brand-plate))',
|
|
947
952
|
'--brand-badge-dark': 'color-mix(in srgb, var(--success) 70%, var(--brand-plate))',
|
|
953
|
+
// A video is letterboxed on black in every theme, as a media player shows it.
|
|
954
|
+
'--letterbox': BLACK,
|
|
948
955
|
// Surfaces: the three grounds by role. The body paints the ground once, a
|
|
949
956
|
// panel paints --surface, and what sits inside a panel paints no ground of
|
|
950
957
|
// its own. Surfaces that float over other content add --frost (the base
|
|
@@ -1248,7 +1255,15 @@ const BASE_TOKEN_NAMES = [
|
|
|
1248
1255
|
'--tree-level',
|
|
1249
1256
|
'--tree-indent',
|
|
1250
1257
|
'--log-source',
|
|
1251
|
-
'--log-source-width'
|
|
1258
|
+
'--log-source-width',
|
|
1259
|
+
'--text-gutter-width',
|
|
1260
|
+
'--terminal-box-height',
|
|
1261
|
+
'--product-mark-colour',
|
|
1262
|
+
'--product-mark-fill',
|
|
1263
|
+
'--product-mark-stroke',
|
|
1264
|
+
'--timeline-start',
|
|
1265
|
+
'--timeline-end',
|
|
1266
|
+
'--timeline-at'
|
|
1252
1267
|
];
|
|
1253
1268
|
/** Every token name uiok defines: the fixed tokens, those a theme sets, and the stylesheet's own. */
|
|
1254
1269
|
const UIOK_TOKEN_NAMES = new Set([
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { ViewerViewProps } from './ViewerViews.js';
|
|
3
|
+
/**
|
|
4
|
+
* The audio view: Chromium plays the file straight from its media URL
|
|
5
|
+
* (`info.mediaUrl`) in an `<audio>` element, under the player's
|
|
6
|
+
* control bar (`MediaControls`), and nothing here decodes a format. Only
|
|
7
|
+
* the metadata loads when the window opens, and nothing plays until the
|
|
8
|
+
* user asks; a seek reads from the new position through a range request,
|
|
9
|
+
* never the whole file first. A file Chromium cannot play (a codec it
|
|
10
|
+
* lacks, a decode failure) hands the window to hex with a note saying why.
|
|
11
|
+
*/
|
|
12
|
+
declare function AudioView({ info, onFallback }: ViewerViewProps): ReactElement;
|
|
13
|
+
export default AudioView;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from 'react';
|
|
3
|
+
import { AudioLines } from 'lucide-react';
|
|
4
|
+
import { useLabels } from '../labels/UiokProvider.js';
|
|
5
|
+
import MediaControls from './MediaControls.js';
|
|
6
|
+
import { mediaFallbackNote } from './MediaPlayer.logic.js';
|
|
7
|
+
import { useMediaElement } from './useMediaElement.js';
|
|
8
|
+
/** The stage's sound mark, larger than any control glyph: it stands in for a picture. */
|
|
9
|
+
const STAGE_GLYPH = 64;
|
|
10
|
+
/**
|
|
11
|
+
* The audio view: Chromium plays the file straight from its media URL
|
|
12
|
+
* (`info.mediaUrl`) in an `<audio>` element, under the player's
|
|
13
|
+
* control bar (`MediaControls`), and nothing here decodes a format. Only
|
|
14
|
+
* the metadata loads when the window opens, and nothing plays until the
|
|
15
|
+
* user asks; a seek reads from the new position through a range request,
|
|
16
|
+
* never the whole file first. A file Chromium cannot play (a codec it
|
|
17
|
+
* lacks, a decode failure) hands the window to hex with a note saying why.
|
|
18
|
+
*/
|
|
19
|
+
function AudioView({ info, onFallback }) {
|
|
20
|
+
const labels = useLabels().viewer;
|
|
21
|
+
const [audioRef, audio] = useMediaElement(info.mediaUrl);
|
|
22
|
+
const [player, setPlayer] = useState(null);
|
|
23
|
+
return (_jsxs("div", { className: "audio-view", ref: setPlayer, children: [_jsxs("div", { className: "audio-stage", children: [_jsx(AudioLines, { absoluteStrokeWidth: true, "aria-hidden": true, size: STAGE_GLYPH }), _jsx("audio", { "aria-label": info.name, onError: (event) => onFallback(mediaFallbackNote('audio', event.currentTarget.error?.code ?? null, labels)), preload: "metadata", ref: audioRef })] }), _jsx(MediaControls, { media: audio, player: player })] }));
|
|
24
|
+
}
|
|
25
|
+
export default AudioView;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jump to offset in the hex view. An offset is typed in hex, as the offset
|
|
3
|
+
* column prints it, with or without a `0x` prefix: `1F40` and `0x1F40` are
|
|
4
|
+
* the same byte. Decimal is not read, so a number never means two bytes.
|
|
5
|
+
* An offset past the file's last byte is refused with a message rather than
|
|
6
|
+
* moved, so a typo never lands somewhere that looks right.
|
|
7
|
+
*/
|
|
8
|
+
import type { ViewerLabels } from '../labels/viewer.js';
|
|
9
|
+
/** A byte to go to, or why the typed offset is not one. */
|
|
10
|
+
export type JumpResult = {
|
|
11
|
+
readonly offset: number;
|
|
12
|
+
} | {
|
|
13
|
+
readonly error: string;
|
|
14
|
+
};
|
|
15
|
+
/** The byte `input` names in a file of `sizeBytes` bytes, or why it names none. */
|
|
16
|
+
export declare function parseJumpOffset(input: string, sizeBytes: number, labels: ViewerLabels): JumpResult;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jump to offset in the hex view. An offset is typed in hex, as the offset
|
|
3
|
+
* column prints it, with or without a `0x` prefix: `1F40` and `0x1F40` are
|
|
4
|
+
* the same byte. Decimal is not read, so a number never means two bytes.
|
|
5
|
+
* An offset past the file's last byte is refused with a message rather than
|
|
6
|
+
* moved, so a typo never lands somewhere that looks right.
|
|
7
|
+
*/
|
|
8
|
+
import { formatOffset, offsetDigits } from './HexRows.logic.js';
|
|
9
|
+
const HEX_OFFSET = /^(?:0x)?([0-9a-f]+)$/i;
|
|
10
|
+
/** The byte `input` names in a file of `sizeBytes` bytes, or why it names none. */
|
|
11
|
+
export function parseJumpOffset(input, sizeBytes, labels) {
|
|
12
|
+
const match = HEX_OFFSET.exec(input.trim());
|
|
13
|
+
if (match?.[1] === undefined)
|
|
14
|
+
return { error: labels.hex.jumpInvalid };
|
|
15
|
+
if (sizeBytes <= 0)
|
|
16
|
+
return { error: labels.hex.jumpEmpty };
|
|
17
|
+
// Read as a bigint, so an offset too long for a number is still past the end.
|
|
18
|
+
const offset = BigInt(`0x${match[1]}`);
|
|
19
|
+
const last = sizeBytes - 1;
|
|
20
|
+
if (offset > BigInt(last)) {
|
|
21
|
+
const digits = offsetDigits(sizeBytes);
|
|
22
|
+
return {
|
|
23
|
+
error: labels.hex.jumpPastEnd(match[1].toUpperCase(), formatOffset(last, digits))
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
return { offset: Number(offset) };
|
|
27
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hex view's row layout. Row N holds bytes N×16 to N×16+15, printed as
|
|
3
|
+
*
|
|
4
|
+
* 00000000 4D 5A 50 00 02 00 00 00-04 00 0F 00 FF FF 00 00 MZP.............
|
|
5
|
+
*
|
|
6
|
+
* an offset of at least 8 uppercase hex digits (wider when the file's last
|
|
7
|
+
* offset needs more, the same width on every row), the 16 bytes in two groups
|
|
8
|
+
* of 8 joined by `-`, and the bytes again as text: printable ASCII as itself,
|
|
9
|
+
* every other byte as `.`. A short last row is padded so its text lines up.
|
|
10
|
+
*/
|
|
11
|
+
/** Bytes per row; row N starts at byte N × 16. */
|
|
12
|
+
export declare const BYTES_PER_ROW = 16;
|
|
13
|
+
/** Characters of the hex column: two digits a byte and one separator between bytes. */
|
|
14
|
+
export declare const HEX_COLUMN_CHARS: number;
|
|
15
|
+
/** Spaces between the offset and the hex column, and between the hex and text columns. */
|
|
16
|
+
export declare const COLUMN_GAP = " ";
|
|
17
|
+
/** The byte as two uppercase hex digits. */
|
|
18
|
+
export declare const hexByte: (byte: number) => string;
|
|
19
|
+
/** The byte as the text column prints it. */
|
|
20
|
+
export declare const textChar: (byte: number) => string;
|
|
21
|
+
/** Rows a file of `sizeBytes` bytes takes, the last one possibly short. */
|
|
22
|
+
export declare const rowCount: (sizeBytes: number) => number;
|
|
23
|
+
/**
|
|
24
|
+
* The offset column's width for a file: 8 digits, or as many as its last
|
|
25
|
+
* offset needs. A file of exactly 4 GB ends at FFFFFFFF and keeps 8; one byte
|
|
26
|
+
* more needs 9.
|
|
27
|
+
*/
|
|
28
|
+
export declare function offsetDigits(sizeBytes: number): number;
|
|
29
|
+
/** An offset in uppercase hex, zero-padded to `digits`. */
|
|
30
|
+
export declare const formatOffset: (offset: number, digits: number) => string;
|
|
31
|
+
/**
|
|
32
|
+
* A row's hex column: up to 16 bytes, a space between bytes and a `-`
|
|
33
|
+
* between the two groups, padded with spaces to the full column so the text
|
|
34
|
+
* column after it lines up on a short last row.
|
|
35
|
+
*/
|
|
36
|
+
export declare function hexColumn(bytes: Uint8Array): string;
|
|
37
|
+
/** A row's text column: one character a byte, padded with spaces to a full row. */
|
|
38
|
+
export declare function textColumn(bytes: Uint8Array): string;
|
|
39
|
+
/** A whole row as one line, the way the view lays it out. */
|
|
40
|
+
export declare function formatRow(offset: number, bytes: Uint8Array, digits: number): string;
|
|
41
|
+
/** Characters in a row's line: offset, gap, hex column, gap, text column. */
|
|
42
|
+
export declare const lineChars: (digits: number) => number;
|
|
43
|
+
/** Which column a byte was picked in, which decides the form copy takes. */
|
|
44
|
+
export type HexColumn = 'hex' | 'text';
|
|
45
|
+
/**
|
|
46
|
+
* The byte under character `char` of a row's line, counted from the line's
|
|
47
|
+
* start, and the column it is in. The offset and the gap after it point at
|
|
48
|
+
* the first byte; the gap between the columns splits between the hex
|
|
49
|
+
* column's last byte and the text column's first; anything past the text
|
|
50
|
+
* column points at the last byte.
|
|
51
|
+
*/
|
|
52
|
+
export declare function cellAt(char: number, digits: number): {
|
|
53
|
+
readonly column: HexColumn;
|
|
54
|
+
readonly index: number;
|
|
55
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hex view's row layout. Row N holds bytes N×16 to N×16+15, printed as
|
|
3
|
+
*
|
|
4
|
+
* 00000000 4D 5A 50 00 02 00 00 00-04 00 0F 00 FF FF 00 00 MZP.............
|
|
5
|
+
*
|
|
6
|
+
* an offset of at least 8 uppercase hex digits (wider when the file's last
|
|
7
|
+
* offset needs more, the same width on every row), the 16 bytes in two groups
|
|
8
|
+
* of 8 joined by `-`, and the bytes again as text: printable ASCII as itself,
|
|
9
|
+
* every other byte as `.`. A short last row is padded so its text lines up.
|
|
10
|
+
*/
|
|
11
|
+
/** Bytes per row; row N starts at byte N × 16. */
|
|
12
|
+
export const BYTES_PER_ROW = 16;
|
|
13
|
+
/** Bytes per group; a `-` joins the two groups of a row. */
|
|
14
|
+
const GROUP_BYTES = 8;
|
|
15
|
+
/** Characters of the hex column: two digits a byte and one separator between bytes. */
|
|
16
|
+
export const HEX_COLUMN_CHARS = BYTES_PER_ROW * 3 - 1;
|
|
17
|
+
/** Spaces between the offset and the hex column, and between the hex and text columns. */
|
|
18
|
+
export const COLUMN_GAP = ' ';
|
|
19
|
+
/** The fewest offset digits, enough for any offset below 4 GB. */
|
|
20
|
+
const MIN_OFFSET_DIGITS = 8;
|
|
21
|
+
const HEX_DIGITS = Array.from({ length: 256 }, (_, byte) => byte.toString(16).toUpperCase().padStart(2, '0'));
|
|
22
|
+
/** Printable ASCII, 0x20 to 0x7E, prints as itself; every other byte as `.`. */
|
|
23
|
+
const TEXT_CHARS = Array.from({ length: 256 }, (_, byte) => byte >= 0x20 && byte <= 0x7e ? String.fromCharCode(byte) : '.');
|
|
24
|
+
/** The byte as two uppercase hex digits. */
|
|
25
|
+
export const hexByte = (byte) => HEX_DIGITS[byte] ?? '??';
|
|
26
|
+
/** The byte as the text column prints it. */
|
|
27
|
+
export const textChar = (byte) => TEXT_CHARS[byte] ?? '.';
|
|
28
|
+
/** Rows a file of `sizeBytes` bytes takes, the last one possibly short. */
|
|
29
|
+
export const rowCount = (sizeBytes) => Math.ceil(sizeBytes / BYTES_PER_ROW);
|
|
30
|
+
/**
|
|
31
|
+
* The offset column's width for a file: 8 digits, or as many as its last
|
|
32
|
+
* offset needs. A file of exactly 4 GB ends at FFFFFFFF and keeps 8; one byte
|
|
33
|
+
* more needs 9.
|
|
34
|
+
*/
|
|
35
|
+
export function offsetDigits(sizeBytes) {
|
|
36
|
+
return Math.max(MIN_OFFSET_DIGITS, Math.max(0, sizeBytes - 1).toString(16).length);
|
|
37
|
+
}
|
|
38
|
+
/** An offset in uppercase hex, zero-padded to `digits`. */
|
|
39
|
+
export const formatOffset = (offset, digits) => offset.toString(16).toUpperCase().padStart(digits, '0');
|
|
40
|
+
/**
|
|
41
|
+
* A row's hex column: up to 16 bytes, a space between bytes and a `-`
|
|
42
|
+
* between the two groups, padded with spaces to the full column so the text
|
|
43
|
+
* column after it lines up on a short last row.
|
|
44
|
+
*/
|
|
45
|
+
export function hexColumn(bytes) {
|
|
46
|
+
let column = '';
|
|
47
|
+
for (let index = 0; index < BYTES_PER_ROW; index += 1) {
|
|
48
|
+
const byte = bytes[index];
|
|
49
|
+
if (index > 0)
|
|
50
|
+
column += index === GROUP_BYTES && byte !== undefined ? '-' : ' ';
|
|
51
|
+
column += byte === undefined ? ' ' : hexByte(byte);
|
|
52
|
+
}
|
|
53
|
+
return column;
|
|
54
|
+
}
|
|
55
|
+
/** A row's text column: one character a byte, padded with spaces to a full row. */
|
|
56
|
+
export function textColumn(bytes) {
|
|
57
|
+
let column = '';
|
|
58
|
+
for (let index = 0; index < BYTES_PER_ROW; index += 1) {
|
|
59
|
+
const byte = bytes[index];
|
|
60
|
+
column += byte === undefined ? ' ' : textChar(byte);
|
|
61
|
+
}
|
|
62
|
+
return column;
|
|
63
|
+
}
|
|
64
|
+
/** A whole row as one line, the way the view lays it out. */
|
|
65
|
+
export function formatRow(offset, bytes, digits) {
|
|
66
|
+
return [formatOffset(offset, digits), hexColumn(bytes), textColumn(bytes)].join(COLUMN_GAP);
|
|
67
|
+
}
|
|
68
|
+
/** Characters in a row's line: offset, gap, hex column, gap, text column. */
|
|
69
|
+
export const lineChars = (digits) => digits + COLUMN_GAP.length * 2 + HEX_COLUMN_CHARS + BYTES_PER_ROW;
|
|
70
|
+
/**
|
|
71
|
+
* The byte under character `char` of a row's line, counted from the line's
|
|
72
|
+
* start, and the column it is in. The offset and the gap after it point at
|
|
73
|
+
* the first byte; the gap between the columns splits between the hex
|
|
74
|
+
* column's last byte and the text column's first; anything past the text
|
|
75
|
+
* column points at the last byte.
|
|
76
|
+
*/
|
|
77
|
+
export function cellAt(char, digits) {
|
|
78
|
+
const hexStart = digits + COLUMN_GAP.length;
|
|
79
|
+
const textStart = hexStart + HEX_COLUMN_CHARS + COLUMN_GAP.length;
|
|
80
|
+
const clampIndex = (index) => Math.min(BYTES_PER_ROW - 1, Math.max(0, Math.floor(index)));
|
|
81
|
+
return char < textStart - 1
|
|
82
|
+
? { column: 'hex', index: clampIndex((char - hexStart) / 3) }
|
|
83
|
+
: { column: 'text', index: clampIndex(char - textStart) };
|
|
84
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hex view's selection and copy. A selection is a range of bytes, both
|
|
3
|
+
* ends included, kept in file terms so it survives scrolling, and remembers
|
|
4
|
+
* the column it was made in: Copy gives the hex digits for a selection made
|
|
5
|
+
* in the hex column and the text for one made in the text column, and the
|
|
6
|
+
* status bar copies either form. Copy reads at most one bounded read and
|
|
7
|
+
* refuses a larger selection with a message instead of reading more.
|
|
8
|
+
*/
|
|
9
|
+
import type { ViewerLabels } from '../labels/viewer.js';
|
|
10
|
+
import { type HexColumn } from './HexRows.logic.js';
|
|
11
|
+
/** Where a selection started and where it was taken to, both bytes included, and the column it was made in. */
|
|
12
|
+
export interface HexSelection {
|
|
13
|
+
readonly anchor: number;
|
|
14
|
+
readonly focus: number;
|
|
15
|
+
readonly column: HexColumn;
|
|
16
|
+
}
|
|
17
|
+
/** The largest selection copy reads, in bytes. */
|
|
18
|
+
export declare const MAX_HEX_COPY_BYTES: number;
|
|
19
|
+
/** Copy for a selection larger than copy will read. */
|
|
20
|
+
export declare function hexSelectionTooLarge(labels: ViewerLabels): string;
|
|
21
|
+
/** The selected bytes as [start, end): its first byte and one past its last. */
|
|
22
|
+
export declare function selectedRange(selection: HexSelection): {
|
|
23
|
+
readonly start: number;
|
|
24
|
+
readonly end: number;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* The part of a row of `length` bytes from `rowOffset` a selection covers,
|
|
28
|
+
* as byte indexes [from, to) into the row, or null when it covers none.
|
|
29
|
+
*/
|
|
30
|
+
export declare function selectedCells(selection: HexSelection, rowOffset: number, length: number): {
|
|
31
|
+
readonly from: number;
|
|
32
|
+
readonly to: number;
|
|
33
|
+
} | null;
|
|
34
|
+
/**
|
|
35
|
+
* The bytes copy reads for a selection, cut at `fileEnd`; null when that is
|
|
36
|
+
* more than copy will read.
|
|
37
|
+
*/
|
|
38
|
+
export declare function copyRange(selection: HexSelection, fileEnd: number): {
|
|
39
|
+
readonly offset: number;
|
|
40
|
+
readonly length: number;
|
|
41
|
+
} | null;
|
|
42
|
+
/** Bytes as copy gives them in hex: two uppercase digits each, a space between. */
|
|
43
|
+
export declare function hexCopy(bytes: Uint8Array): string;
|
|
44
|
+
/** Bytes as copy gives them as text: what the text column shows, `.` for every byte outside printable ASCII. */
|
|
45
|
+
export declare function textCopy(bytes: Uint8Array): string;
|
|
46
|
+
/** The steps Shift with an arrow takes the selection's moving end: a row up or down, a byte sideways. */
|
|
47
|
+
export declare const SELECTION_STEPS: {
|
|
48
|
+
readonly ArrowUp: number;
|
|
49
|
+
readonly ArrowDown: 16;
|
|
50
|
+
readonly ArrowLeft: -1;
|
|
51
|
+
readonly ArrowRight: 1;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* The selection with its moving end taken `delta` bytes, kept inside a file
|
|
55
|
+
* of `fileEnd` bytes. With no selection, it starts at byte `from`.
|
|
56
|
+
*/
|
|
57
|
+
export declare function extendSelection(selection: HexSelection | null, delta: number, from: number, fileEnd: number): HexSelection | null;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The hex view's selection and copy. A selection is a range of bytes, both
|
|
3
|
+
* ends included, kept in file terms so it survives scrolling, and remembers
|
|
4
|
+
* the column it was made in: Copy gives the hex digits for a selection made
|
|
5
|
+
* in the hex column and the text for one made in the text column, and the
|
|
6
|
+
* status bar copies either form. Copy reads at most one bounded read and
|
|
7
|
+
* refuses a larger selection with a message instead of reading more.
|
|
8
|
+
*/
|
|
9
|
+
import { VIEWER_MAX_READ_BYTES } from './types.js';
|
|
10
|
+
import { BYTES_PER_ROW, hexByte, textChar } from './HexRows.logic.js';
|
|
11
|
+
/** The largest selection copy reads, in bytes. */
|
|
12
|
+
export const MAX_HEX_COPY_BYTES = VIEWER_MAX_READ_BYTES;
|
|
13
|
+
/** Copy for a selection larger than copy will read. */
|
|
14
|
+
export function hexSelectionTooLarge(labels) {
|
|
15
|
+
return labels.hex.copyTooLarge(labels.size(MAX_HEX_COPY_BYTES));
|
|
16
|
+
}
|
|
17
|
+
/** The selected bytes as [start, end): its first byte and one past its last. */
|
|
18
|
+
export function selectedRange(selection) {
|
|
19
|
+
return {
|
|
20
|
+
start: Math.min(selection.anchor, selection.focus),
|
|
21
|
+
end: Math.max(selection.anchor, selection.focus) + 1
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The part of a row of `length` bytes from `rowOffset` a selection covers,
|
|
26
|
+
* as byte indexes [from, to) into the row, or null when it covers none.
|
|
27
|
+
*/
|
|
28
|
+
export function selectedCells(selection, rowOffset, length) {
|
|
29
|
+
const { start, end } = selectedRange(selection);
|
|
30
|
+
const from = Math.max(0, start - rowOffset);
|
|
31
|
+
const to = Math.min(length, end - rowOffset);
|
|
32
|
+
return to > from ? { from, to } : null;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* The bytes copy reads for a selection, cut at `fileEnd`; null when that is
|
|
36
|
+
* more than copy will read.
|
|
37
|
+
*/
|
|
38
|
+
export function copyRange(selection, fileEnd) {
|
|
39
|
+
const { start, end } = selectedRange(selection);
|
|
40
|
+
const length = Math.max(0, Math.min(end, fileEnd) - start);
|
|
41
|
+
return length <= MAX_HEX_COPY_BYTES ? { offset: start, length } : null;
|
|
42
|
+
}
|
|
43
|
+
/** Bytes as copy gives them in hex: two uppercase digits each, a space between. */
|
|
44
|
+
export function hexCopy(bytes) {
|
|
45
|
+
return Array.from(bytes, hexByte).join(' ');
|
|
46
|
+
}
|
|
47
|
+
/** Bytes as copy gives them as text: what the text column shows, `.` for every byte outside printable ASCII. */
|
|
48
|
+
export function textCopy(bytes) {
|
|
49
|
+
return Array.from(bytes, textChar).join('');
|
|
50
|
+
}
|
|
51
|
+
/** The steps Shift with an arrow takes the selection's moving end: a row up or down, a byte sideways. */
|
|
52
|
+
export const SELECTION_STEPS = {
|
|
53
|
+
ArrowUp: -BYTES_PER_ROW,
|
|
54
|
+
ArrowDown: BYTES_PER_ROW,
|
|
55
|
+
ArrowLeft: -1,
|
|
56
|
+
ArrowRight: 1
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The selection with its moving end taken `delta` bytes, kept inside a file
|
|
60
|
+
* of `fileEnd` bytes. With no selection, it starts at byte `from`.
|
|
61
|
+
*/
|
|
62
|
+
export function extendSelection(selection, delta, from, fileEnd) {
|
|
63
|
+
if (fileEnd <= 0)
|
|
64
|
+
return null;
|
|
65
|
+
const start = selection ?? { anchor: from, focus: from, column: 'hex' };
|
|
66
|
+
const focus = Math.max(0, Math.min(fileEnd - 1, start.focus + delta));
|
|
67
|
+
return { ...start, focus };
|
|
68
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type ReactElement } from 'react';
|
|
2
|
+
import type { ViewerViewProps } from './ViewerViews.js';
|
|
3
|
+
/**
|
|
4
|
+
* The hex view: 16 bytes a row, as hex and as text, any row one bounded read
|
|
5
|
+
* away. A scaled scrollbar maps the thumb to a byte; ⌘L jumps to an offset;
|
|
6
|
+
* a byte range selected with the mouse (or Shift with the arrows) copies as
|
|
7
|
+
* hex or as text, up to one bounded read.
|
|
8
|
+
*/
|
|
9
|
+
declare function HexView({ reader, info }: Pick<ViewerViewProps, 'reader' | 'info'>): ReactElement;
|
|
10
|
+
export default HexView;
|