@bigpixelrocket/uiok 0.2.3 → 0.4.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 +48 -1
- package/dist/charts/Sparkline.d.ts +20 -0
- package/dist/charts/Sparkline.js +12 -0
- package/dist/charts/Sparkline.logic.d.ts +9 -0
- package/dist/charts/Sparkline.logic.js +27 -0
- package/dist/charts/charts.css +17 -0
- package/dist/charts/index.d.ts +2 -0
- package/dist/charts/index.js +2 -0
- package/dist/dialog/ConfirmDialog.d.ts +17 -1
- package/dist/dialog/ConfirmDialog.js +4 -3
- package/dist/dialog/ModalDialog.d.ts +8 -0
- package/dist/dialog/ModalDialog.js +4 -2
- package/dist/dialog/ProgressDialog.d.ts +40 -0
- package/dist/dialog/ProgressDialog.js +40 -0
- package/dist/dialog/TypedNameDialog.d.ts +44 -0
- package/dist/dialog/TypedNameDialog.js +17 -0
- package/dist/dialog/index.d.ts +5 -2
- package/dist/dialog/index.js +4 -1
- 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/Switch.d.ts +26 -0
- package/dist/field/Switch.js +20 -0
- package/dist/field/index.d.ts +10 -6
- package/dist/field/index.js +10 -6
- package/dist/frame/AppRoot.d.ts +44 -0
- package/dist/frame/AppRoot.js +26 -0
- package/dist/frame/Dock.d.ts +88 -0
- package/dist/frame/Dock.js +129 -0
- package/dist/frame/FilterChips.d.ts +28 -0
- package/dist/frame/FilterChips.js +14 -0
- package/dist/frame/PageParts.d.ts +69 -0
- package/dist/frame/PageParts.js +60 -0
- package/dist/frame/PaneSplit.d.ts +74 -0
- package/dist/frame/PaneSplit.js +197 -0
- package/dist/frame/SidebarResizer.d.ts +35 -0
- package/dist/frame/SidebarResizer.js +43 -0
- package/dist/frame/StatusNotice.d.ts +20 -0
- package/dist/frame/StatusNotice.js +13 -0
- package/dist/frame/Tree.d.ts +147 -0
- package/dist/frame/Tree.js +164 -0
- package/dist/frame/TreeToggle.d.ts +18 -0
- package/dist/frame/TreeToggle.js +17 -0
- package/dist/frame/WindowFrame.d.ts +57 -0
- package/dist/frame/WindowFrame.js +19 -0
- package/dist/frame/frame.css +801 -0
- package/dist/frame/index.d.ts +22 -0
- package/dist/frame/index.js +22 -0
- package/dist/frame/sharedRef.d.ts +8 -0
- package/dist/frame/sharedRef.js +26 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/labels/UiokLabels.d.ts +6 -0
- package/dist/labels/UiokLabels.js +5 -1
- package/dist/labels/dialog.d.ts +12 -0
- package/dist/labels/dialog.js +7 -1
- package/dist/labels/index.d.ts +2 -0
- package/dist/labels/index.js +2 -0
- package/dist/labels/settings.d.ts +46 -0
- package/dist/labels/settings.js +29 -0
- package/dist/labels/viewer.d.ts +193 -0
- package/dist/labels/viewer.js +124 -0
- package/dist/listing/EmptyState.d.ts +40 -0
- package/dist/listing/EmptyState.js +14 -0
- package/dist/listing/PaneMessage.d.ts +28 -0
- package/dist/listing/PaneMessage.js +12 -0
- package/dist/listing/index.d.ts +5 -1
- package/dist/listing/index.js +5 -1
- package/dist/listing/listing.css +66 -2
- package/dist/log/LogWell.d.ts +34 -0
- package/dist/log/LogWell.js +39 -0
- package/dist/log/LogWell.logic.d.ts +16 -0
- package/dist/log/LogWell.logic.js +26 -0
- package/dist/log/index.d.ts +8 -0
- package/dist/log/index.js +8 -0
- package/dist/log/log.css +57 -0
- package/dist/pane/Pane.d.ts +49 -0
- package/dist/pane/Pane.js +17 -0
- package/dist/pane/PaneKeys.d.ts +10 -3
- package/dist/pane/PaneKeys.js +26 -7
- package/dist/pane/index.d.ts +4 -2
- package/dist/pane/index.js +4 -2
- package/dist/pane/usePaneKeys.js +9 -11
- package/dist/shell/AboutWindow.d.ts +21 -0
- package/dist/shell/AboutWindow.js +10 -0
- package/dist/shell/LanguageChoice.d.ts +27 -0
- package/dist/shell/LanguageChoice.js +17 -0
- package/dist/shell/LoadFailure.d.ts +22 -0
- package/dist/shell/LoadFailure.js +15 -0
- package/dist/shell/Lockup.d.ts +52 -0
- package/dist/shell/Lockup.js +30 -0
- package/dist/shell/SettingsDialog.d.ts +97 -0
- package/dist/shell/SettingsDialog.js +219 -0
- package/dist/shell/SettingsDialog.logic.d.ts +33 -0
- package/dist/shell/SettingsDialog.logic.js +42 -0
- package/dist/shell/SettingsFiles.d.ts +55 -0
- package/dist/shell/SettingsFiles.js +30 -0
- package/dist/shell/SettingsPageKeys.d.ts +42 -0
- package/dist/shell/SettingsPageKeys.js +70 -0
- package/dist/shell/SettingsSubsection.d.ts +34 -0
- package/dist/shell/SettingsSubsection.js +30 -0
- package/dist/shell/SignIn.d.ts +61 -0
- package/dist/shell/SignIn.js +36 -0
- package/dist/shell/ThemePicker.d.ts +74 -0
- package/dist/shell/ThemePicker.js +96 -0
- package/dist/shell/ThemePicker.logic.d.ts +13 -0
- package/dist/shell/ThemePicker.logic.js +26 -0
- package/dist/shell/TitleBar.d.ts +44 -0
- package/dist/shell/TitleBar.js +23 -0
- package/dist/shell/UpdatePill.d.ts +26 -0
- package/dist/shell/UpdatePill.js +17 -0
- package/dist/shell/Updates.d.ts +99 -0
- package/dist/shell/Updates.js +72 -0
- package/dist/shell/index.d.ts +27 -0
- package/dist/shell/index.js +27 -0
- package/dist/shell/shell.css +243 -4
- package/dist/styles.css +5 -0
- package/dist/surface/Card.d.ts +18 -0
- package/dist/surface/Card.js +10 -0
- package/dist/surface/Notice.d.ts +45 -0
- package/dist/surface/Notice.js +27 -0
- package/dist/surface/index.d.ts +5 -3
- package/dist/surface/index.js +5 -3
- package/dist/themes/catalog.js +4 -0
- package/dist/themes/themes.generated.css +245 -0
- package/dist/themes/tokens.d.ts +17 -5
- package/dist/themes/tokens.js +67 -1
- package/dist/tokens.css +11 -0
- 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
package/dist/themes/tokens.js
CHANGED
|
@@ -28,6 +28,8 @@ import { contrast, firstLegible, legibleOn, luminance, mix, rgbOf, translucent }
|
|
|
28
28
|
import { THEME_ATTRIBUTES, THEME_PREVIEW_ATTRIBUTE } from './ids.js';
|
|
29
29
|
const WHITE = '#ffffff';
|
|
30
30
|
const BLACK = '#000000';
|
|
31
|
+
/** The brand mark's constant plate: Catppuccin Mocha's crust in every theme. */
|
|
32
|
+
const BRAND_PLATE = '#11111b';
|
|
31
33
|
/** Body text and anything read as words. */
|
|
32
34
|
const TEXT_CONTRAST = 4.5;
|
|
33
35
|
/** Marks read by shape alone: a dot, a glyph, a control's outline, a chart line. */
|
|
@@ -637,6 +639,23 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
637
639
|
red: hues.red ?? palette.red
|
|
638
640
|
};
|
|
639
641
|
const shadow = look.shadow;
|
|
642
|
+
// The channel marker's tones (see '--channel-name' below).
|
|
643
|
+
const channelRamp = [
|
|
644
|
+
palette.overlay0,
|
|
645
|
+
palette.overlay1,
|
|
646
|
+
palette.overlay2,
|
|
647
|
+
palette.subtext0,
|
|
648
|
+
palette.subtext1,
|
|
649
|
+
palette.text
|
|
650
|
+
];
|
|
651
|
+
const channelName = contrast(rowMeta, header) >= TEXT_CONTRAST ? rowMeta : textDim;
|
|
652
|
+
const channelQuieter = channelRamp[channelRamp.indexOf(channelName) - 1];
|
|
653
|
+
const channelDetail = channelQuieter !== undefined && contrast(channelQuieter, header) >= TEXT_CONTRAST
|
|
654
|
+
? channelQuieter
|
|
655
|
+
: channelName;
|
|
656
|
+
const channelText = (channel) => legibleOn(channel, [ground, panel].map((on) => mix(channel, on, 14)), TEXT_CONTRAST);
|
|
657
|
+
const channelLatest = tuned('--channel-latest', palette.mauve);
|
|
658
|
+
const channelLocal = tuned('--channel-local', palette.peach);
|
|
640
659
|
return {
|
|
641
660
|
'--bg': ground,
|
|
642
661
|
'--bg-panel': panel,
|
|
@@ -832,6 +851,20 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
832
851
|
'--group-dot-ring': Object.values(groups).some((hue) => contrast(hue, recessed) < MARK_CONTRAST)
|
|
833
852
|
? `inset 0 0 0 1px ${translucent(palette.text, 28)}`
|
|
834
853
|
: 'none',
|
|
854
|
+
// A title bar's channel marker after the lockup: the channel's name in
|
|
855
|
+
// the row-meta tone where it keeps 4.5:1 on the bar (else --text-dim),
|
|
856
|
+
// then its build number or branch a step quieter on the neutral ramp
|
|
857
|
+
// where that keeps 4.5:1 too, else the name's tone.
|
|
858
|
+
'--channel-name': channelName === rowMeta ? 'var(--row-meta-text)' : 'var(--text-dim)',
|
|
859
|
+
'--channel-detail': channelDetail === channelName ? 'var(--channel-name)' : channelDetail,
|
|
860
|
+
// The release channels a build wears (`data-channel`): mauve for a
|
|
861
|
+
// prerelease (latest), peach for a local build, each with its tag's
|
|
862
|
+
// words moved until they keep 4.5:1 on the channel's 14% tint over the
|
|
863
|
+
// ground and a panel.
|
|
864
|
+
'--channel-latest': channelLatest,
|
|
865
|
+
'--channel-latest-text': tuned('--channel-latest-text', channelText(channelLatest)),
|
|
866
|
+
'--channel-local': channelLocal,
|
|
867
|
+
'--channel-local-text': tuned('--channel-local-text', channelText(channelLocal)),
|
|
835
868
|
// The chart series colours, in the order a chart assigns them
|
|
836
869
|
// (chartSeries): eight hues of the palette, pairwise distinct, each at
|
|
837
870
|
// 3:1 on a panel and the ground.
|
|
@@ -843,6 +876,13 @@ function derivedTokens(palette, terminal, appearance, overrides, hues) {
|
|
|
843
876
|
'--chart-6': series[5] ?? palette.red,
|
|
844
877
|
'--chart-7': series[6] ?? palette.yellow,
|
|
845
878
|
'--chart-8': series[7] ?? palette.pink,
|
|
879
|
+
// The words of a log's sources (a process's prefix in a combined log),
|
|
880
|
+
// one hue each in turn: the palette's hue moved until it keeps 4.5:1 as
|
|
881
|
+
// text on a panel and the ground, so a prefix reads as words.
|
|
882
|
+
...Object.fromEntries([palette.green, palette.pink, palette.blue, palette.peach, palette.teal, palette.mauve].map((hue, index) => [
|
|
883
|
+
`--log-source-${index + 1}`,
|
|
884
|
+
legibleOn(hue, [panel, ground], TEXT_CONTRAST)
|
|
885
|
+
])),
|
|
846
886
|
// A terminal, which a terminal engine reads as literal colours, so each
|
|
847
887
|
// is hex or rgb(): the theme's own terminal palette over its base, and
|
|
848
888
|
// the accent under the selection, which is drawn over the cell colours.
|
|
@@ -897,6 +937,16 @@ export function themeTokens(theme) {
|
|
|
897
937
|
* they play.
|
|
898
938
|
*/
|
|
899
939
|
export const FIXED_TOKENS = {
|
|
940
|
+
// A brand mark (BrandMark): the white its glyph and check are drawn in,
|
|
941
|
+
// the same in every theme as an app icon draws them, and the plate's
|
|
942
|
+
// constant dark tone, toward which a dark appearance deepens the plate and
|
|
943
|
+
// the badge so the white keeps its contrast on a light accent.
|
|
944
|
+
'--brand-white': WHITE,
|
|
945
|
+
'--brand-plate': BRAND_PLATE,
|
|
946
|
+
'--brand-plate-dark': 'color-mix(in srgb, var(--accent) 70%, var(--brand-plate))',
|
|
947
|
+
'--brand-badge-dark': 'color-mix(in srgb, var(--success) 70%, var(--brand-plate))',
|
|
948
|
+
// A video is letterboxed on black in every theme, as a media player shows it.
|
|
949
|
+
'--letterbox': BLACK,
|
|
900
950
|
// Surfaces: the three grounds by role. The body paints the ground once, a
|
|
901
951
|
// panel paints --surface, and what sits inside a panel paints no ground of
|
|
902
952
|
// its own. Surfaces that float over other content add --frost (the base
|
|
@@ -1063,6 +1113,8 @@ const BASE_TOKEN_NAMES = [
|
|
|
1063
1113
|
'--font-weight-regular',
|
|
1064
1114
|
'--font-weight-medium',
|
|
1065
1115
|
'--font-weight-strong',
|
|
1116
|
+
'--font-weight-light',
|
|
1117
|
+
'--font-weight-heavy',
|
|
1066
1118
|
'--tracking-caps',
|
|
1067
1119
|
'--space-1',
|
|
1068
1120
|
'--space-2',
|
|
@@ -1096,6 +1148,9 @@ const BASE_TOKEN_NAMES = [
|
|
|
1096
1148
|
'--bar-height',
|
|
1097
1149
|
'--bar-height-lg',
|
|
1098
1150
|
'--hit-target',
|
|
1151
|
+
'--shell-header-height',
|
|
1152
|
+
'--traffic-light-inset',
|
|
1153
|
+
'--sidebar-width',
|
|
1099
1154
|
'--focus-ring-width',
|
|
1100
1155
|
'--focus-offset',
|
|
1101
1156
|
'--focus-offset-flush',
|
|
@@ -1185,7 +1240,18 @@ const BASE_TOKEN_NAMES = [
|
|
|
1185
1240
|
'--data-grid-bar',
|
|
1186
1241
|
'--data-grid-ring',
|
|
1187
1242
|
'--row-level',
|
|
1188
|
-
'--field-columns'
|
|
1243
|
+
'--field-columns',
|
|
1244
|
+
'--channel',
|
|
1245
|
+
'--channel-text',
|
|
1246
|
+
'--lockup-size',
|
|
1247
|
+
'--brand-mark-plate',
|
|
1248
|
+
'--brand-mark-badge',
|
|
1249
|
+
'--window-band-width',
|
|
1250
|
+
'--tree-level',
|
|
1251
|
+
'--tree-indent',
|
|
1252
|
+
'--log-source',
|
|
1253
|
+
'--log-source-width',
|
|
1254
|
+
'--text-gutter-width'
|
|
1189
1255
|
];
|
|
1190
1256
|
/** Every token name uiok defines: the fixed tokens, those a theme sets, and the stylesheet's own. */
|
|
1191
1257
|
const UIOK_TOKEN_NAMES = new Set([
|
package/dist/tokens.css
CHANGED
|
@@ -43,6 +43,9 @@
|
|
|
43
43
|
--font-weight-regular: 400;
|
|
44
44
|
--font-weight-medium: 500;
|
|
45
45
|
--font-weight-strong: 600;
|
|
46
|
+
/* A product's wordmark (Lockup): its light first part, its heavy last. */
|
|
47
|
+
--font-weight-light: 300;
|
|
48
|
+
--font-weight-heavy: 700;
|
|
46
49
|
|
|
47
50
|
/* Letter-spacing of small uppercase headings. Key glyphs keep their own
|
|
48
51
|
spacing, which belongs to the glyph, not to a heading. */
|
|
@@ -133,6 +136,14 @@
|
|
|
133
136
|
--bar-height-lg: 34px;
|
|
134
137
|
--hit-target: 24px;
|
|
135
138
|
|
|
139
|
+
/* The window frame (frame.css): the top band, the title bar's and the
|
|
140
|
+
main pane's tabs, which every dialog keeps clear of; where macOS's
|
|
141
|
+
traffic lights end, which a title bar's brand clears (window geometry,
|
|
142
|
+
not a space step); and a sidebar's default width. */
|
|
143
|
+
--shell-header-height: var(--bar-height-lg);
|
|
144
|
+
--traffic-light-inset: 72px;
|
|
145
|
+
--sidebar-width: 240px;
|
|
146
|
+
|
|
136
147
|
/* Focus. One ring for everything focusable: a 2px accent line outside the
|
|
137
148
|
control at focus-offset, so it follows the control's corner one pixel
|
|
138
149
|
out. focus-offset-flush puts it on the control's edge, for a compact
|
|
@@ -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;
|