@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
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CircleAlert } from 'lucide-react';
|
|
3
|
+
import { useCallback, useEffect, useId, useRef, useState } from 'react';
|
|
4
|
+
import { settleRead } from './types.js';
|
|
5
|
+
import { Button } from '../button/Button.js';
|
|
6
|
+
import { describedTooltip } from '../tooltip/Tooltip.logic.js';
|
|
7
|
+
import { NameCut } from '../namecut/NameCut.js';
|
|
8
|
+
import { nameParts } from '../namecut/NameCut.logic.js';
|
|
9
|
+
import { SegmentedChoice } from '../segmented/SegmentedChoice.js';
|
|
10
|
+
import { useLabels } from '../labels/UiokProvider.js';
|
|
11
|
+
import { Notice } from '../surface/Notice.js';
|
|
12
|
+
import { VisuallyHidden } from '../VisuallyHidden.js';
|
|
13
|
+
import { isViewerCloseKey } from './ViewerKeys.js';
|
|
14
|
+
import { isViewerEvent } from './ViewerScope.js';
|
|
15
|
+
import { openSyntaxWorker, SyntaxWorkerContext } from './SyntaxService.js';
|
|
16
|
+
import { changeNotice, factsTitle, fallbackViewFor, fileFacts, VIEWER_MODES, viewForKind } from './ViewerFrame.logic.js';
|
|
17
|
+
import { VIEWER_VIEWS } from './ViewerViews.js';
|
|
18
|
+
/** What a good inspect or reload of a `kind` file shows after `current`. */
|
|
19
|
+
const shownAfterOpen = (kind, current) => ({
|
|
20
|
+
view: viewForKind(kind, current !== null && current.fallbackNote === null ? current.view : null),
|
|
21
|
+
fallbackNote: null
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* A number per reader the viewer has been given, so a new reader remounts
|
|
25
|
+
* the viewer: nothing a read, reload, or check of the old file answers late
|
|
26
|
+
* can reach the new file's state.
|
|
27
|
+
*/
|
|
28
|
+
const readerKeys = new WeakMap();
|
|
29
|
+
let nextReaderKey = 1;
|
|
30
|
+
const readerKey = (reader) => {
|
|
31
|
+
if (reader === null)
|
|
32
|
+
return 0;
|
|
33
|
+
let key = readerKeys.get(reader);
|
|
34
|
+
if (key === undefined) {
|
|
35
|
+
key = nextReaderKey;
|
|
36
|
+
nextReaderKey += 1;
|
|
37
|
+
readerKeys.set(reader, key);
|
|
38
|
+
}
|
|
39
|
+
return key;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* A read-only file viewer filling its window: a header with the file's
|
|
43
|
+
* name, size, kind, and modification date and a switch between the modes
|
|
44
|
+
* its kind offers, and the view for the chosen mode (text with syntax
|
|
45
|
+
* highlighting and line numbers, hex, image, audio, video, or PDF), each
|
|
46
|
+
* reading only the bytes on screen through `reader`. The file is inspected
|
|
47
|
+
* once as the viewer opens and again each time its window comes to the
|
|
48
|
+
* front; when its source no longer matches, a notice says so and offers
|
|
49
|
+
* Reload, while the view keeps what it has. A native view that cannot show
|
|
50
|
+
* the file hands over to its kind's fallback (source for an SVG, hex
|
|
51
|
+
* otherwise) with a note saying why. Its keys and Copy listen on the window
|
|
52
|
+
* and answer when aimed inside it or at nothing, leaving the page's own
|
|
53
|
+
* controls theirs (`isViewerEvent`), so mount one per window or
|
|
54
|
+
* document; a new `reader` starts it afresh on that file.
|
|
55
|
+
*/
|
|
56
|
+
export function ViewerWindow(props) {
|
|
57
|
+
return _jsx(ViewerWindowFor, { ...props }, readerKey(props.reader));
|
|
58
|
+
}
|
|
59
|
+
/** The viewer bound to one reader for its whole life. */
|
|
60
|
+
function ViewerWindowFor({ reader, onClose, isCloseKey = isViewerCloseKey, trafficLights = false, syntaxWorker }) {
|
|
61
|
+
const labels = useLabels().viewer;
|
|
62
|
+
const modesLabelId = useId();
|
|
63
|
+
// Read when a call settles, so a new translation of the words neither
|
|
64
|
+
// inspects the file again nor resets what the viewer shows.
|
|
65
|
+
const noAnswer = useRef(labels.noAnswer);
|
|
66
|
+
useEffect(() => {
|
|
67
|
+
noAnswer.current = labels.noAnswer;
|
|
68
|
+
});
|
|
69
|
+
const [state, setState] = useState(reader ? { kind: 'loading' } : { kind: 'failed', message: null });
|
|
70
|
+
const onCloseRef = useRef(onClose);
|
|
71
|
+
const isCloseKeyRef = useRef(isCloseKey);
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
onCloseRef.current = onClose;
|
|
74
|
+
isCloseKeyRef.current = isCloseKey;
|
|
75
|
+
});
|
|
76
|
+
const [shown, setShown] = useState(null);
|
|
77
|
+
// The newest generation, advanced the moment a reload succeeds, so a
|
|
78
|
+
// fallback can be checked against it when it arrives rather than against
|
|
79
|
+
// whatever a render captured.
|
|
80
|
+
const latestGeneration = useRef(0);
|
|
81
|
+
const openedKind = state.kind === 'ready' ? state.info.content.kind : null;
|
|
82
|
+
const generation = state.kind === 'ready' ? state.generation : null;
|
|
83
|
+
// Bound to the generation the view was mounted on: a view a reload has
|
|
84
|
+
// replaced can still report its old file's failure late (an error event
|
|
85
|
+
// or a decode check still in flight), and that must not move the new
|
|
86
|
+
// generation's view to its fallback.
|
|
87
|
+
const fallBack = useCallback((note) => {
|
|
88
|
+
if (openedKind === null || generation !== latestGeneration.current)
|
|
89
|
+
return;
|
|
90
|
+
setShown({ view: fallbackViewFor(openedKind), fallbackNote: note });
|
|
91
|
+
}, [generation, openedKind]);
|
|
92
|
+
const chooseView = (next) => {
|
|
93
|
+
setShown({ view: next, fallbackNote: null });
|
|
94
|
+
};
|
|
95
|
+
useEffect(() => {
|
|
96
|
+
if (!reader)
|
|
97
|
+
return;
|
|
98
|
+
let cancelled = false;
|
|
99
|
+
void settleRead(noAnswer.current, () => reader.inspect()).then((result) => {
|
|
100
|
+
if (cancelled)
|
|
101
|
+
return;
|
|
102
|
+
if (!result.ok) {
|
|
103
|
+
setState({ kind: 'failed', message: result.error.message });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
setState({
|
|
107
|
+
kind: 'ready',
|
|
108
|
+
info: result.value,
|
|
109
|
+
generation: 0,
|
|
110
|
+
change: result.value.change,
|
|
111
|
+
reloading: false,
|
|
112
|
+
reloadFailure: null
|
|
113
|
+
});
|
|
114
|
+
setShown((current) => shownAfterOpen(result.value.content.kind, current));
|
|
115
|
+
});
|
|
116
|
+
return () => {
|
|
117
|
+
cancelled = true;
|
|
118
|
+
};
|
|
119
|
+
}, [reader]);
|
|
120
|
+
// Nothing watches the file, so the check runs when the user comes back to
|
|
121
|
+
// the window, the moment a change made elsewhere could matter. A failed
|
|
122
|
+
// check changes nothing on screen: the next one, or Reload, says more.
|
|
123
|
+
useEffect(() => {
|
|
124
|
+
if (!reader)
|
|
125
|
+
return;
|
|
126
|
+
// Checks can answer out of order: of those that answer for the open
|
|
127
|
+
// generation, only one asked after the last applied speaks.
|
|
128
|
+
let asked = 0;
|
|
129
|
+
let applied = { generation: -1, ticket: 0 };
|
|
130
|
+
const check = () => {
|
|
131
|
+
asked += 1;
|
|
132
|
+
const ticket = asked;
|
|
133
|
+
void settleRead(noAnswer.current, () => reader.inspect()).then((result) => {
|
|
134
|
+
if (!result.ok)
|
|
135
|
+
return;
|
|
136
|
+
// A disk that matches the open file again leaves nothing for an
|
|
137
|
+
// earlier failed reload to explain. A check that answers for an
|
|
138
|
+
// earlier generation (a reload overtook it) says nothing of the
|
|
139
|
+
// file open now, and moves nothing.
|
|
140
|
+
setState((current) => {
|
|
141
|
+
const { generation } = result.value;
|
|
142
|
+
if (current.kind !== 'ready' || current.reloading)
|
|
143
|
+
return current;
|
|
144
|
+
if (current.info.generation !== generation)
|
|
145
|
+
return current;
|
|
146
|
+
if (applied.generation === generation && ticket < applied.ticket)
|
|
147
|
+
return current;
|
|
148
|
+
applied = { generation, ticket };
|
|
149
|
+
return {
|
|
150
|
+
...current,
|
|
151
|
+
change: result.value.change,
|
|
152
|
+
reloadFailure: result.value.change === 'none' ? null : current.reloadFailure
|
|
153
|
+
};
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
};
|
|
157
|
+
window.addEventListener('focus', check);
|
|
158
|
+
return () => window.removeEventListener('focus', check);
|
|
159
|
+
}, [reader]);
|
|
160
|
+
// Escape, ⌘Y, and F3 close the window as ⌘W does (`isViewerCloseKey`),
|
|
161
|
+
// whatever it shows, a failure included. A key a view took first is the
|
|
162
|
+
// view's: Escape clearing a selection or the hex view's offset field. In
|
|
163
|
+
// full screen, Escape is the browser's, to leave it; other close keys still close.
|
|
164
|
+
useEffect(() => {
|
|
165
|
+
const onKeyDown = (event) => {
|
|
166
|
+
if (event.defaultPrevented || !isViewerEvent(event))
|
|
167
|
+
return;
|
|
168
|
+
if (!isCloseKeyRef.current(event))
|
|
169
|
+
return;
|
|
170
|
+
if (event.key === 'Escape' && document.fullscreenElement)
|
|
171
|
+
return;
|
|
172
|
+
event.preventDefault();
|
|
173
|
+
onCloseRef.current();
|
|
174
|
+
};
|
|
175
|
+
window.addEventListener('keydown', onKeyDown);
|
|
176
|
+
return () => window.removeEventListener('keydown', onKeyDown);
|
|
177
|
+
}, []);
|
|
178
|
+
const reload = useCallback(async () => {
|
|
179
|
+
if (!reader)
|
|
180
|
+
return;
|
|
181
|
+
setState((current) => current.kind === 'ready' ? { ...current, reloading: true, reloadFailure: null } : current);
|
|
182
|
+
const result = await settleRead(noAnswer.current, () => reader.reload());
|
|
183
|
+
if (result.ok)
|
|
184
|
+
latestGeneration.current += 1;
|
|
185
|
+
const next = latestGeneration.current;
|
|
186
|
+
setState((current) => {
|
|
187
|
+
if (current.kind !== 'ready')
|
|
188
|
+
return current;
|
|
189
|
+
return result.ok
|
|
190
|
+
? {
|
|
191
|
+
kind: 'ready',
|
|
192
|
+
info: result.value,
|
|
193
|
+
generation: next,
|
|
194
|
+
change: result.value.change,
|
|
195
|
+
reloading: false,
|
|
196
|
+
reloadFailure: null
|
|
197
|
+
}
|
|
198
|
+
: { ...current, reloading: false, reloadFailure: result.error.message };
|
|
199
|
+
});
|
|
200
|
+
if (result.ok) {
|
|
201
|
+
setShown((current) => shownAfterOpen(result.value.content.kind, current));
|
|
202
|
+
}
|
|
203
|
+
}, [reader]);
|
|
204
|
+
if (state.kind !== 'ready' || reader === null || shown === null) {
|
|
205
|
+
const failureText = state.kind === 'failed' ? (state.message ?? labels.unreachable) : null;
|
|
206
|
+
return (_jsxs("div", { className: "viewer-window", "data-traffic-lights": trafficLights ? '' : undefined, children: [_jsx("header", { className: "viewer-header", children: state.kind === 'failed' ? (_jsx("div", { className: "viewer-identity", children: _jsx("h1", { className: "viewer-name viewer-name-generic", children: labels.title }) })) : null }), _jsx("main", { className: "viewer-body", children: state.kind === 'failed' ? (_jsxs("div", { className: "viewer-failure", role: "alert", children: [_jsx(CircleAlert, { "aria-hidden": true, className: "viewer-failure-glyph" }), _jsx("p", { children: failureText })] })) : null })] }));
|
|
207
|
+
}
|
|
208
|
+
const { info } = state;
|
|
209
|
+
const modes = VIEWER_MODES[info.content.kind];
|
|
210
|
+
const notice = changeNotice(state.change, labels);
|
|
211
|
+
const noticeText = state.reloadFailure ?? notice?.text ?? null;
|
|
212
|
+
const noticeDanger = state.reloadFailure !== null || notice?.canReload === false;
|
|
213
|
+
const { view, fallbackNote } = shown;
|
|
214
|
+
const View = VIEWER_VIEWS[view];
|
|
215
|
+
return (_jsxs("div", { className: "viewer-window", "data-traffic-lights": trafficLights ? '' : undefined, children: [_jsxs("header", { className: "viewer-header", children: [_jsxs("div", { className: "viewer-identity", children: [_jsx("h1", { className: "viewer-name", children: _jsx(NameCut, { parts: nameParts([{ name: info.name }]) }) }), _jsx("p", { className: "viewer-facts", ...describedTooltip(`${fileFacts(info, labels)}\n${factsTitle(info, labels)}`), children: fileFacts(info, labels) })] }), modes.length > 1 ? (_jsxs("div", { className: "viewer-modes", children: [_jsx(VisuallyHidden, { id: modesLabelId, children: labels.modesLabel }), _jsx(SegmentedChoice, { choices: modes.map((mode) => mode.view), labelId: modesLabelId, onChange: chooseView, render: (choice) => {
|
|
216
|
+
const mode = modes.find((entry) => entry.view === choice);
|
|
217
|
+
return mode ? labels.modes[mode.label] : choice;
|
|
218
|
+
}, value: view })] })) : null] }), noticeText !== null && (_jsx("div", { className: "viewer-notice", children: _jsx(Notice, { actions: (notice?.canReload ?? true) && (_jsx(Button, { disabled: state.reloading, onClick: () => void reload(), size: "small", children: labels.reload })), tone: noticeDanger ? 'danger' : 'warning', children: noticeText }) })), fallbackNote !== null && (_jsx("div", { className: "viewer-notice", children: _jsx(Notice, { children: fallbackNote }) })), _jsx("main", { className: "viewer-body", children: _jsx(SyntaxWorkerContext, { value: syntaxWorker === undefined ? openSyntaxWorker : syntaxWorker, children: _jsx(View, { info: info, onFallback: fallBack, reader: reader }, state.generation) }) })] }));
|
|
219
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The read-only file viewer: `ViewerWindow`, one file shown as text with
|
|
3
|
+
* syntax highlighting, hex, image, audio, video, or PDF, read a bounded
|
|
4
|
+
* range at a time through a `ViewerReader` the app supplies. Imported on its
|
|
5
|
+
* own as `@bigpixelrocket/uiok/viewer`, never from the package root, so an
|
|
6
|
+
* app that shows no viewer never bundles its highlighting worker; its look
|
|
7
|
+
* is viewer.css, which the base stylesheet imports.
|
|
8
|
+
*/
|
|
9
|
+
export { ViewerWindow, type ViewerWindowProps } from './ViewerWindow.js';
|
|
10
|
+
export { isViewerCloseKey, type ViewerKeyStroke } from './ViewerKeys.js';
|
|
11
|
+
export { openSyntaxWorker, type SyntaxPort, type SyntaxWorkerFactory } from './SyntaxService.js';
|
|
12
|
+
export { VIEWER_MAX_READ_BYTES, type ViewerByteRange, type ViewerContentKind, type ViewerContentType, type ViewerFileChange, type ViewerFileInfo, type ViewerFileOrigin, type ViewerLineNumber, type ViewerLineNumberRequest, type ViewerReader, type ViewerReadFailure, type ViewerReadRangeRequest, type ViewerResult, type ViewerTextEncoding } from './types.js';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The read-only file viewer: `ViewerWindow`, one file shown as text with
|
|
3
|
+
* syntax highlighting, hex, image, audio, video, or PDF, read a bounded
|
|
4
|
+
* range at a time through a `ViewerReader` the app supplies. Imported on its
|
|
5
|
+
* own as `@bigpixelrocket/uiok/viewer`, never from the package root, so an
|
|
6
|
+
* app that shows no viewer never bundles its highlighting worker; its look
|
|
7
|
+
* is viewer.css, which the base stylesheet imports.
|
|
8
|
+
*/
|
|
9
|
+
export { ViewerWindow } from './ViewerWindow.js';
|
|
10
|
+
export { isViewerCloseKey } from './ViewerKeys.js';
|
|
11
|
+
export { openSyntaxWorker } from './SyntaxService.js';
|
|
12
|
+
export { VIEWER_MAX_READ_BYTES } from './types.js';
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the viewer reads its one file through, and what the reads return.
|
|
3
|
+
* The viewer never holds a path: every call acts on the file its reader is
|
|
4
|
+
* bound to, so an app can hand it a bridge that resolves the file from the
|
|
5
|
+
* calling window, a fetch over a server, or an in-memory buffer alike. The
|
|
6
|
+
* shapes are plain data, so an app's own schema-checked types fit them as
|
|
7
|
+
* long as they carry these fields.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* What a file holds, as far as the viewer cares: the view it opens in.
|
|
11
|
+
* `image`, `svg`, `audio`, `video`, and `pdf` are formats a browser shows
|
|
12
|
+
* natively; `text` was sniffed as text; `binary` is everything else, shown
|
|
13
|
+
* in hex.
|
|
14
|
+
*/
|
|
15
|
+
export type ViewerContentKind = 'text' | 'binary' | 'image' | 'svg' | 'audio' | 'video' | 'pdf';
|
|
16
|
+
/**
|
|
17
|
+
* The detected content: its kind and the media type it was detected as
|
|
18
|
+
* (`image/png`, `text/plain`), which a media view hands to the browser and
|
|
19
|
+
* the frame names in its facts ("PNG image").
|
|
20
|
+
*/
|
|
21
|
+
export interface ViewerContentType {
|
|
22
|
+
readonly kind: ViewerContentKind;
|
|
23
|
+
readonly mimeType: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* How the file at its source differs from the one the viewer opened:
|
|
27
|
+
* `none`; `modified` (same file, new size or date); `replaced` (the source
|
|
28
|
+
* now names a different file, as an atomic save leaves it); `removed`
|
|
29
|
+
* (nothing is there). The viewer keeps showing what it opened in every case,
|
|
30
|
+
* and offers Reload unless the file was removed.
|
|
31
|
+
*/
|
|
32
|
+
export type ViewerFileChange = 'none' | 'modified' | 'replaced' | 'removed';
|
|
33
|
+
/**
|
|
34
|
+
* Where a file came from when the viewer shows a copy of it: the container
|
|
35
|
+
* that holds it (an archive, a server), by name, and the file's place there
|
|
36
|
+
* (`src/report.txt`, `/var/log/app.log`). The frame names the container and
|
|
37
|
+
* says, on hover, that the window shows a read-only copy.
|
|
38
|
+
*/
|
|
39
|
+
export interface ViewerFileOrigin {
|
|
40
|
+
readonly archiveName: string;
|
|
41
|
+
readonly entryPath: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* One inspection of the viewer's file. `generation` counts the reloads that
|
|
45
|
+
* reopened it (0 as first opened), so a read in flight across a reload can
|
|
46
|
+
* be told from one of the new file; `sizeBytes` and `modifiedMs` describe
|
|
47
|
+
* the open file; `content` is the kind detected when this generation opened;
|
|
48
|
+
* `change` compares the source with the open file; `mediaUrl` is where a
|
|
49
|
+
* native view (image, audio, video, PDF) has the browser load the file from,
|
|
50
|
+
* loadable for as long as this generation is open, mode switches included,
|
|
51
|
+
* and retired by the reader after it (the PDF
|
|
52
|
+
* view appends `/<name>` to it, so a PDF's URL must serve the file whatever
|
|
53
|
+
* last segment follows, and frames it unsandboxed, so it must answer with
|
|
54
|
+
* the PDF alone); `origin` is set only for a copy.
|
|
55
|
+
*/
|
|
56
|
+
export interface ViewerFileInfo {
|
|
57
|
+
readonly generation: number;
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly sizeBytes: number;
|
|
60
|
+
readonly modifiedMs: number;
|
|
61
|
+
readonly content: ViewerContentType;
|
|
62
|
+
readonly change: ViewerFileChange;
|
|
63
|
+
readonly mediaUrl: string;
|
|
64
|
+
readonly origin?: ViewerFileOrigin | undefined;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Largest byte range one read asks for: a screenful of text or hex with
|
|
68
|
+
* plenty to spare. A reader may refuse anything larger.
|
|
69
|
+
*/
|
|
70
|
+
export declare const VIEWER_MAX_READ_BYTES: number;
|
|
71
|
+
/** A byte range to read: `length` bytes from `offset`, at least 1 and at most `VIEWER_MAX_READ_BYTES`. */
|
|
72
|
+
export interface ViewerReadRangeRequest {
|
|
73
|
+
readonly offset: number;
|
|
74
|
+
readonly length: number;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* The bytes a read found at `offset`: fewer than asked for, or none, when
|
|
78
|
+
* the range runs past the end. `endOfFile` is true when the range reaches
|
|
79
|
+
* the file's current end; `generation` names the file the bytes came from,
|
|
80
|
+
* so the viewer drops a read that a reload overtook.
|
|
81
|
+
*/
|
|
82
|
+
export interface ViewerByteRange {
|
|
83
|
+
readonly generation: number;
|
|
84
|
+
readonly offset: number;
|
|
85
|
+
readonly bytes: Uint8Array;
|
|
86
|
+
readonly endOfFile: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* The text encodings the text view decodes: UTF-8 with or without its byte
|
|
90
|
+
* order mark, UTF-16 in either byte order (only with its mark), and Latin-1
|
|
91
|
+
* for a file that is not valid UTF-8.
|
|
92
|
+
*/
|
|
93
|
+
export type ViewerTextEncoding = 'utf-8' | 'utf-16le' | 'utf-16be' | 'latin-1';
|
|
94
|
+
/** Asks for the number of the line holding byte `offset`, counting line breaks as `encoding` spells them. */
|
|
95
|
+
export interface ViewerLineNumberRequest {
|
|
96
|
+
readonly offset: number;
|
|
97
|
+
readonly encoding: ViewerTextEncoding;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The 1-based number of the line holding byte `offset` of the file
|
|
101
|
+
* `generation` names; null when the reader gave up on this ask (a newer ask
|
|
102
|
+
* replaced it, or the count stopped).
|
|
103
|
+
*/
|
|
104
|
+
export interface ViewerLineNumber {
|
|
105
|
+
readonly generation: number;
|
|
106
|
+
readonly offset: number;
|
|
107
|
+
readonly line: number | null;
|
|
108
|
+
}
|
|
109
|
+
/** Why a read failed, in finished copy the viewer shows as it is. */
|
|
110
|
+
export interface ViewerReadFailure {
|
|
111
|
+
readonly message: string;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A reader call's outcome: the value, or why there is none. A promise that
|
|
115
|
+
* rejects instead is shown as the `noAnswer` label, so a reader need not
|
|
116
|
+
* catch its own transport failures.
|
|
117
|
+
*/
|
|
118
|
+
export type ViewerResult<T> = {
|
|
119
|
+
readonly ok: true;
|
|
120
|
+
readonly value: T;
|
|
121
|
+
} | {
|
|
122
|
+
readonly ok: false;
|
|
123
|
+
readonly error: ViewerReadFailure;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* How the viewer reaches its one file. The app supplies it; the viewer asks
|
|
127
|
+
* nothing else of the app. Every method acts on the same file.
|
|
128
|
+
*/
|
|
129
|
+
export interface ViewerReader {
|
|
130
|
+
/** Size, date, and detected kind of the open file, and how its source has changed since. */
|
|
131
|
+
readonly inspect: () => Promise<ViewerResult<ViewerFileInfo>>;
|
|
132
|
+
/** One bounded byte range of the open file; a range past the end returns what exists. */
|
|
133
|
+
readonly readRange: (request: ViewerReadRangeRequest) => Promise<ViewerResult<ViewerByteRange>>;
|
|
134
|
+
/**
|
|
135
|
+
* Reopens the file from its source, so a changed file shows as it is now.
|
|
136
|
+
* A reload that fails keeps the file the viewer had.
|
|
137
|
+
*/
|
|
138
|
+
readonly reload: () => Promise<ViewerResult<ViewerFileInfo>>;
|
|
139
|
+
/**
|
|
140
|
+
* The line holding a byte. Until it answers, the text view shows byte
|
|
141
|
+
* offsets in its gutter; a reader that cannot count lines answers with a
|
|
142
|
+
* null line and the gutter keeps offsets.
|
|
143
|
+
*/
|
|
144
|
+
readonly lineNumber: (request: ViewerLineNumberRequest) => Promise<ViewerResult<ViewerLineNumber>>;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Runs a reader call and guarantees the promise resolves: a result passes
|
|
148
|
+
* through, and a rejection or a synchronous throw becomes a failure saying
|
|
149
|
+
* `noAnswer`.
|
|
150
|
+
*/
|
|
151
|
+
export declare function settleRead<T>(noAnswer: string, call: () => Promise<ViewerResult<T>>): Promise<ViewerResult<T>>;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the viewer reads its one file through, and what the reads return.
|
|
3
|
+
* The viewer never holds a path: every call acts on the file its reader is
|
|
4
|
+
* bound to, so an app can hand it a bridge that resolves the file from the
|
|
5
|
+
* calling window, a fetch over a server, or an in-memory buffer alike. The
|
|
6
|
+
* shapes are plain data, so an app's own schema-checked types fit them as
|
|
7
|
+
* long as they carry these fields.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Largest byte range one read asks for: a screenful of text or hex with
|
|
11
|
+
* plenty to spare. A reader may refuse anything larger.
|
|
12
|
+
*/
|
|
13
|
+
export const VIEWER_MAX_READ_BYTES = 1024 * 1024;
|
|
14
|
+
/**
|
|
15
|
+
* Runs a reader call and guarantees the promise resolves: a result passes
|
|
16
|
+
* through, and a rejection or a synchronous throw becomes a failure saying
|
|
17
|
+
* `noAnswer`.
|
|
18
|
+
*/
|
|
19
|
+
export async function settleRead(noAnswer, call) {
|
|
20
|
+
try {
|
|
21
|
+
return await call();
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
return { ok: false, error: { message: noAnswer } };
|
|
25
|
+
}
|
|
26
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Watches an element's content height: a ref callback for the element, and
|
|
3
|
+
* its height in pixels, null until measured (or where nothing measures, as
|
|
4
|
+
* in jsdom without a ResizeObserver).
|
|
5
|
+
*/
|
|
6
|
+
export declare function useElementHeight(): [(element: HTMLElement | null) => void, number | null];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Watches an element's content height: a ref callback for the element, and
|
|
4
|
+
* its height in pixels, null until measured (or where nothing measures, as
|
|
5
|
+
* in jsdom without a ResizeObserver).
|
|
6
|
+
*/
|
|
7
|
+
export function useElementHeight() {
|
|
8
|
+
const [height, setHeight] = useState(null);
|
|
9
|
+
const observer = useRef(null);
|
|
10
|
+
const ref = useCallback((element) => {
|
|
11
|
+
observer.current?.disconnect();
|
|
12
|
+
observer.current = null;
|
|
13
|
+
if (element === null || typeof ResizeObserver === 'undefined')
|
|
14
|
+
return;
|
|
15
|
+
observer.current = new ResizeObserver(([entry]) => {
|
|
16
|
+
if (entry)
|
|
17
|
+
setHeight(entry.contentRect.height);
|
|
18
|
+
});
|
|
19
|
+
observer.current.observe(element);
|
|
20
|
+
}, []);
|
|
21
|
+
return [ref, height];
|
|
22
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Size } from './ImageZoom.logic.js';
|
|
2
|
+
/**
|
|
3
|
+
* Watches an element's content box: a ref callback for the element, and its
|
|
4
|
+
* size in pixels, null until measured (or where nothing measures, as in
|
|
5
|
+
* jsdom without a ResizeObserver).
|
|
6
|
+
*/
|
|
7
|
+
export declare function useElementSize(): [(element: HTMLElement | null) => void, Size | null];
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useCallback, useRef, useState } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Watches an element's content box: a ref callback for the element, and its
|
|
4
|
+
* size in pixels, null until measured (or where nothing measures, as in
|
|
5
|
+
* jsdom without a ResizeObserver).
|
|
6
|
+
*/
|
|
7
|
+
export function useElementSize() {
|
|
8
|
+
const [size, setSize] = useState(null);
|
|
9
|
+
const observer = useRef(null);
|
|
10
|
+
const ref = useCallback((element) => {
|
|
11
|
+
observer.current?.disconnect();
|
|
12
|
+
observer.current = null;
|
|
13
|
+
if (element === null || typeof ResizeObserver === 'undefined')
|
|
14
|
+
return;
|
|
15
|
+
observer.current = new ResizeObserver(([entry]) => {
|
|
16
|
+
if (!entry)
|
|
17
|
+
return;
|
|
18
|
+
const { width, height } = entry.contentRect;
|
|
19
|
+
setSize((current) => current?.width === width && current.height === height ? current : { width, height });
|
|
20
|
+
});
|
|
21
|
+
observer.current.observe(element);
|
|
22
|
+
}, []);
|
|
23
|
+
return [ref, size];
|
|
24
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Lets a bare Escape clear what a view holds (its selection) wherever focus
|
|
3
|
+
* is in the viewer, the Wrap checkbox or a status bar button included, before
|
|
4
|
+
* the window's own Escape closes it (`ViewerWindow.tsx`). The listener sits on
|
|
5
|
+
* the document, which a keystroke reaches before the window, and takes Escape
|
|
6
|
+
* only while `active`; a key something inside took first stays with it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useEscapeToClear(active: boolean, clear: () => void): void;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect } from 'react';
|
|
2
|
+
import { isViewerEvent } from './ViewerScope.js';
|
|
3
|
+
/**
|
|
4
|
+
* Lets a bare Escape clear what a view holds (its selection) wherever focus
|
|
5
|
+
* is in the viewer, the Wrap checkbox or a status bar button included, before
|
|
6
|
+
* the window's own Escape closes it (`ViewerWindow.tsx`). The listener sits on
|
|
7
|
+
* the document, which a keystroke reaches before the window, and takes Escape
|
|
8
|
+
* only while `active`; a key something inside took first stays with it.
|
|
9
|
+
*/
|
|
10
|
+
export function useEscapeToClear(active, clear) {
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
if (!active)
|
|
13
|
+
return;
|
|
14
|
+
const onKeyDown = (event) => {
|
|
15
|
+
const bare = !event.metaKey && !event.ctrlKey && !event.altKey && !event.shiftKey;
|
|
16
|
+
if (event.defaultPrevented || event.key !== 'Escape' || !bare)
|
|
17
|
+
return;
|
|
18
|
+
if (!isViewerEvent(event))
|
|
19
|
+
return;
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
clear();
|
|
22
|
+
};
|
|
23
|
+
document.addEventListener('keydown', onKeyDown);
|
|
24
|
+
return () => document.removeEventListener('keydown', onKeyDown);
|
|
25
|
+
}, [active, clear]);
|
|
26
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { type ViewerReader, type ViewerFileInfo } from './types.js';
|
|
2
|
+
import type { HexColumn } from './HexRows.logic.js';
|
|
3
|
+
import { type HexSelection } from './HexSelection.logic.js';
|
|
4
|
+
import { type HexRow } from './HexViewport.logic.js';
|
|
5
|
+
import type { ViewerCopy } from './ViewerClipboard.js';
|
|
6
|
+
/** The screen the hex view draws: its top row, the rows from there, and where the readable bytes end. */
|
|
7
|
+
export interface HexScreen {
|
|
8
|
+
readonly top: number;
|
|
9
|
+
readonly rows: readonly HexRow[];
|
|
10
|
+
/** The opened size, or less once a read found the file shrunk. */
|
|
11
|
+
readonly end: number;
|
|
12
|
+
}
|
|
13
|
+
/** The hex view's file state: what is on screen, and the calls that move it. */
|
|
14
|
+
export interface HexDocument {
|
|
15
|
+
readonly screen: HexScreen | null;
|
|
16
|
+
/** Why the file could not be read, in the reader's copy. */
|
|
17
|
+
readonly failure: string | null;
|
|
18
|
+
/** Shows the screen whose top row is `row`, kept between the first row and the last screen. */
|
|
19
|
+
readonly go: (row: number) => void;
|
|
20
|
+
/** Moves `rows` rows from the newest target, so moves made while a read is in flight add up. */
|
|
21
|
+
readonly scroll: (rows: number) => void;
|
|
22
|
+
/** The selected bytes in hex or as text, read in one bounded read when the view does not hold them; or why not. */
|
|
23
|
+
readonly copy: (selection: HexSelection, as: HexColumn) => ViewerCopy;
|
|
24
|
+
}
|
|
25
|
+
/** The document's settings that change without a new file: the screen's height. */
|
|
26
|
+
export interface HexDocumentView {
|
|
27
|
+
/** Rows drawn, the last of which may show only in part. */
|
|
28
|
+
readonly screenRows: number;
|
|
29
|
+
/** Rows that fit whole, so the end of the file shows its last row fully. */
|
|
30
|
+
readonly fullRows: number;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Reads the window's file for the hex view: each screen comes from the bytes
|
|
34
|
+
* already held or from one bounded read around it, the newest target
|
|
35
|
+
* winning. A read about another generation of the file (one in flight across
|
|
36
|
+
* a reload) is dropped. A read that finds the file shrunk ends the view at
|
|
37
|
+
* the new end for as long as the view lives, pulling the screen back when it
|
|
38
|
+
* was past it; a read that lands wholly past the new end asks the file's size
|
|
39
|
+
* once, so the screen comes back in one more read however far it was.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useHexDocument(reader: ViewerReader, info: ViewerFileInfo, view: HexDocumentView): HexDocument;
|