@open-document/core 0.13.3 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/{build-CvsOak5B.js → build-I0cgoERP.js} +1 -1
  2. package/dist/{check-CbUBwYmf.js → check-Dys96QSL.js} +3 -3
  3. package/dist/cli/bin.js +10 -21
  4. package/dist/{config-BWtOZ1jc.d.ts → config-cAV1OCuY.d.ts} +9 -1
  5. package/dist/{context-CWgfsHoE.js → context-C-osJW5f.js} +1 -1
  6. package/dist/{dev-B8H2qT6G.js → dev-CC4PrIOC.js} +1 -1
  7. package/dist/{diff-BvIjjgnc.js → diff-DhutD4TJ.js} +2 -2
  8. package/dist/{export-DX30_s2q.js → export-KrajVJO7.js} +3 -3
  9. package/dist/{import-DgsdJT5e.js → import-Yv34za3L.js} +3 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/ops/index.d.ts +3 -1
  12. package/dist/ops/index.js +2 -2
  13. package/dist/ops-Dux5HlkH.js +401 -0
  14. package/dist/{preview-DYMUNjXL.js → preview-7eqn9Wzf.js} +1 -1
  15. package/dist/rolldown-runtime-D7D4PA-g.js +13 -0
  16. package/dist/{config-CltJJVsw.js → session-BSbrC5gK.js} +3268 -385
  17. package/dist/{templates-B5Tz0AKb.js → templates-s-VLTSRc.js} +3 -3
  18. package/dist/vite/index.d.ts +1 -1
  19. package/dist/vite/index.js +1 -1
  20. package/package.json +1 -1
  21. package/skills/create-doc/SKILL.md +1 -1
  22. package/skills/doc-authoring/SKILL.md +6 -0
  23. package/src/app/app.tsx +2 -0
  24. package/src/app/components/agent/agent-dock.tsx +75 -0
  25. package/src/app/components/agent/agent-markdown.tsx +45 -0
  26. package/src/app/components/agent/agent-panel.tsx +695 -0
  27. package/src/app/components/agent/agent-presence.tsx +74 -0
  28. package/src/app/components/agent/composer.tsx +120 -0
  29. package/src/app/components/agent/connect-view.tsx +183 -0
  30. package/src/app/components/agent/history-view.tsx +134 -0
  31. package/src/app/components/agent/provider-logo.tsx +23 -0
  32. package/src/app/components/agent/transcript.tsx +717 -0
  33. package/src/app/components/comments/comments-panel.tsx +26 -2
  34. package/src/app/components/inspector/inspector.tsx +17 -0
  35. package/src/app/components/note-markdown.tsx +85 -0
  36. package/src/app/components/page-error-boundary.tsx +84 -0
  37. package/src/app/components/page-frame.tsx +2 -1
  38. package/src/app/components/panel/resize-handle.tsx +129 -0
  39. package/src/app/components/ui/button.tsx +97 -0
  40. package/src/app/components/ui/popover.tsx +144 -0
  41. package/src/app/components/ui/tooltip.tsx +123 -0
  42. package/src/app/lib/agent/use-agent.ts +543 -0
  43. package/src/app/lib/diagnostics.ts +13 -0
  44. package/src/app/lib/export-dom.ts +2 -1
  45. package/src/app/lib/export-pdf.ts +2 -1
  46. package/src/app/lib/i18n-ja/agent-panel.ts +115 -0
  47. package/src/app/lib/i18n-ja/agent.ts +9 -0
  48. package/src/app/lib/i18n-ja/index.ts +9 -1
  49. package/src/app/lib/i18n-ko/agent-panel.ts +114 -0
  50. package/src/app/lib/i18n-ko/agent.ts +9 -0
  51. package/src/app/lib/i18n-ko/index.ts +9 -1
  52. package/src/app/lib/i18n-zh-cn/agent-panel.ts +113 -0
  53. package/src/app/lib/i18n-zh-cn/agent.ts +9 -0
  54. package/src/app/lib/i18n-zh-cn/index.ts +9 -1
  55. package/src/app/lib/i18n-zh-tw/agent-panel.ts +113 -0
  56. package/src/app/lib/i18n-zh-tw/agent.ts +9 -0
  57. package/src/app/lib/i18n-zh-tw/index.ts +9 -1
  58. package/src/app/lib/note-markdown.ts +116 -0
  59. package/src/app/lib/toast.ts +50 -0
  60. package/src/app/lib/use-auto-grow.ts +15 -0
  61. package/src/app/lib/use-doc-titles.ts +28 -0
  62. package/src/app/lib/use-locale.ts +151 -0
  63. package/src/app/lib/utils.ts +4 -0
  64. package/src/app/routes/doc-preview.tsx +103 -0
  65. package/src/app/routes/doc.tsx +118 -11
  66. package/src/app/routes/home.tsx +43 -8
  67. package/src/app/styles.css +193 -0
  68. package/dist/ops-CSR5RlrE.js +0 -1673
@@ -0,0 +1,116 @@
1
+ export type NoteInline =
2
+ | { type: 'text'; text: string }
3
+ | { type: 'strong'; children: NoteInline[] }
4
+ | { type: 'em'; children: NoteInline[] }
5
+ | { type: 'code'; text: string };
6
+
7
+ export type NoteBlock =
8
+ | { type: 'paragraph'; lines: NoteInline[][] }
9
+ | { type: 'heading'; level: 1 | 2 | 3; children: NoteInline[] }
10
+ | { type: 'list'; ordered: boolean; items: NoteInline[][] };
11
+
12
+ const HEADING = /^(#{1,3})\s+(.*)$/;
13
+ // Ordered before the single-star branch so `**bold**` never parses as
14
+ // empty italics. Emphasis content must start and end with non-whitespace
15
+ // (CommonMark) so spaced stars like `2 * 3 … 5 * 4` never pair up, and `_`
16
+ // needs word boundaries to leave snake_case alone.
17
+ const INLINE =
18
+ /`([^`\n]+)`|\*\*(\S(?:[^\n]*?\S)?)\*\*|\*([^\s*](?:[^*\n]*[^\s*])?)\*|(?<![\w])_([^\s_](?:[^_\n]*[^\s_])?)_(?![\w])/g;
19
+
20
+ // Backslash-escaped punctuation is swapped for private-use characters before
21
+ // any block or inline matching, so an escaped delimiter can never open or
22
+ // close anything. Leaves swap them back — code spans keep the backslash,
23
+ // matching CommonMark's "no escapes inside code" rule.
24
+ const ESCAPABLE = '\\`*_#-.)';
25
+ const ESCAPE = /\\([\\`*_#\-.)])/g;
26
+ const HIDDEN = /[-]/g;
27
+
28
+ function hideEscapes(text: string): string {
29
+ return text
30
+ .replace(HIDDEN, '')
31
+ .replace(ESCAPE, (_, ch: string) => String.fromCharCode(0xe000 + ESCAPABLE.indexOf(ch)));
32
+ }
33
+
34
+ function restoreEscapes(text: string, keepBackslash: boolean): string {
35
+ return text.replace(HIDDEN, (ch) => {
36
+ const original = ESCAPABLE[ch.charCodeAt(0) - 0xe000];
37
+ return keepBackslash ? `\\${original}` : original;
38
+ });
39
+ }
40
+
41
+ function matchListItem(line: string): { ordered: boolean; content: string } | null {
42
+ const unordered = /^\s*[-*]\s+(.*)$/.exec(line);
43
+ if (unordered) return { ordered: false, content: unordered[1] };
44
+ const ordered = /^\s*\d{1,3}[.)]\s+(.*)$/.exec(line);
45
+ if (ordered) return { ordered: true, content: ordered[1] };
46
+ return null;
47
+ }
48
+
49
+ function parseInlineHidden(text: string): NoteInline[] {
50
+ const out: NoteInline[] = [];
51
+ const pushText = (raw: string) => {
52
+ if (raw) out.push({ type: 'text', text: restoreEscapes(raw, false) });
53
+ };
54
+ let last = 0;
55
+ for (const m of text.matchAll(INLINE)) {
56
+ pushText(text.slice(last, m.index));
57
+ if (m[1] !== undefined) out.push({ type: 'code', text: restoreEscapes(m[1], true) });
58
+ else if (m[2] !== undefined) out.push({ type: 'strong', children: parseInlineHidden(m[2]) });
59
+ else out.push({ type: 'em', children: parseInlineHidden(m[3] ?? m[4]) });
60
+ last = m.index + m[0].length;
61
+ }
62
+ pushText(text.slice(last));
63
+ return out;
64
+ }
65
+
66
+ export function parseInline(text: string): NoteInline[] {
67
+ return parseInlineHidden(hideEscapes(text));
68
+ }
69
+
70
+ export function parseNoteMarkdown(text: string): NoteBlock[] {
71
+ const lines = hideEscapes(text).split('\n');
72
+ const blocks: NoteBlock[] = [];
73
+ let i = 0;
74
+ while (i < lines.length) {
75
+ const trimmed = lines[i].trim();
76
+ if (trimmed === '') {
77
+ i++;
78
+ continue;
79
+ }
80
+ const heading = HEADING.exec(trimmed);
81
+ if (heading) {
82
+ blocks.push({
83
+ type: 'heading',
84
+ level: heading[1].length as 1 | 2 | 3,
85
+ children: parseInlineHidden(heading[2].trim()),
86
+ });
87
+ i++;
88
+ continue;
89
+ }
90
+ const item = matchListItem(lines[i]);
91
+ if (item) {
92
+ const items: NoteInline[][] = [];
93
+ while (i < lines.length) {
94
+ const next = matchListItem(lines[i]);
95
+ if (!next || next.ordered !== item.ordered) break;
96
+ items.push(parseInlineHidden(next.content.trim()));
97
+ i++;
98
+ }
99
+ blocks.push({ type: 'list', ordered: item.ordered, items });
100
+ continue;
101
+ }
102
+ // Paragraph lines keep leading whitespace (rendered with pre-wrap) so
103
+ // plain-text notes don't lose manual indentation or spacing.
104
+ const paragraph = [parseInlineHidden(lines[i].trimEnd())];
105
+ i++;
106
+ while (i < lines.length) {
107
+ const next = lines[i];
108
+ const nextTrimmed = next.trim();
109
+ if (nextTrimmed === '' || HEADING.test(nextTrimmed) || matchListItem(next)) break;
110
+ paragraph.push(parseInlineHidden(next.trimEnd()));
111
+ i++;
112
+ }
113
+ blocks.push({ type: 'paragraph', lines: paragraph });
114
+ }
115
+ return blocks;
116
+ }
@@ -0,0 +1,50 @@
1
+ /**
2
+ * A short notice in the corner of the window — the few the agent panel raises
3
+ * when something it started from a click fails or finishes. Drawn straight into
4
+ * the DOM rather than through a toast library, since the runtime ships to
5
+ * users; the call shape matches `sonner`'s so the panel reads the same.
6
+ */
7
+
8
+ type Kind = 'error' | 'success';
9
+ type Options = { description?: string };
10
+
11
+ const SHOWN_MS = 5000;
12
+
13
+ function host(): HTMLElement {
14
+ let el = document.getElementById('od-toasts');
15
+ if (!el) {
16
+ el = document.createElement('div');
17
+ el.id = 'od-toasts';
18
+ el.setAttribute('role', 'status');
19
+ el.setAttribute('aria-live', 'polite');
20
+ el.className =
21
+ 'pointer-events-none fixed right-4 bottom-4 z-[100] flex w-[320px] max-w-[calc(100vw-2rem)] flex-col gap-2';
22
+ document.body.append(el);
23
+ }
24
+ return el;
25
+ }
26
+
27
+ function show(kind: Kind, message: string, options?: Options): void {
28
+ if (typeof document === 'undefined') return;
29
+ const card = document.createElement('div');
30
+ card.className =
31
+ 'island-enter pointer-events-auto rounded-[8px] border border-hairline bg-popover px-3 py-2.5 text-[12.5px] text-popover-foreground shadow-floating';
32
+ card.dataset.kind = kind;
33
+ const title = document.createElement('p');
34
+ title.className = kind === 'error' ? 'font-medium text-destructive' : 'font-medium';
35
+ title.textContent = message;
36
+ card.append(title);
37
+ if (options?.description) {
38
+ const body = document.createElement('p');
39
+ body.className = 'mt-0.5 break-words text-[11.5px] text-muted-foreground';
40
+ body.textContent = options.description;
41
+ card.append(body);
42
+ }
43
+ host().append(card);
44
+ setTimeout(() => card.remove(), SHOWN_MS);
45
+ }
46
+
47
+ export const toast = {
48
+ error: (message: string, options?: Options) => show('error', message, options),
49
+ success: (message: string, options?: Options) => show('success', message, options),
50
+ };
@@ -0,0 +1,15 @@
1
+ import { type RefObject, useLayoutEffect } from 'react';
2
+
3
+ export function useAutoGrow(
4
+ ref: RefObject<HTMLTextAreaElement | null>,
5
+ value: string,
6
+ max: number,
7
+ ): void {
8
+ // biome-ignore lint/correctness/useExhaustiveDependencies: re-measure whenever the text changes
9
+ useLayoutEffect(() => {
10
+ const node = ref.current;
11
+ if (!node) return;
12
+ node.style.height = '0px';
13
+ node.style.height = `${Math.min(max, Math.max(40, node.scrollHeight))}px`;
14
+ }, [ref, value, max]);
15
+ }
@@ -0,0 +1,28 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import { docIds, loadDoc } from './docs';
3
+
4
+ /**
5
+ * Every document's display title, resolved once `enabled` first turns true —
6
+ * kept lazy since it imports every document module.
7
+ */
8
+ export function useDocTitles(enabled: boolean): Record<string, string> {
9
+ const [titles, setTitles] = useState<Record<string, string>>({});
10
+ const startedRef = useRef(false);
11
+
12
+ useEffect(() => {
13
+ if (!enabled || startedRef.current) return;
14
+ startedRef.current = true;
15
+ void Promise.all(
16
+ docIds.map(async (id): Promise<[string, string]> => {
17
+ try {
18
+ const mod = await loadDoc(id);
19
+ return [id, mod.meta?.title ?? id];
20
+ } catch {
21
+ return [id, id];
22
+ }
23
+ }),
24
+ ).then((entries) => setTitles(Object.fromEntries(entries)));
25
+ }, [enabled]);
26
+
27
+ return titles;
28
+ }
@@ -0,0 +1,151 @@
1
+ import { useMemo } from 'react';
2
+ import { useLocale as useAppLocale } from './i18n';
3
+
4
+ /**
5
+ * The agent panel's strings in the shape its components read them — `t.agent.x`,
6
+ * as in open-slide, so the panel stays easy to keep in step with it — each one
7
+ * translated through the app's own dictionaries, keyed by its English text.
8
+ */
9
+ const AGENT = {
10
+ title: 'Agent',
11
+ beta: 'Beta',
12
+ betaTitle: 'Early preview',
13
+ betaHint: 'Replies, edits and tool calls can occasionally fail or do something unexpected.',
14
+ open: 'Agent',
15
+ openTitle: 'Open the agent panel',
16
+ close: 'Close agent panel',
17
+ newSession: 'New chat',
18
+ sessions: 'History',
19
+ noSessions: 'No conversations yet.',
20
+ deleteSession: 'Delete conversation',
21
+ historyThisDoc: 'This document',
22
+ historyOtherDocs: 'Other documents',
23
+ historyEmptyHint: 'Chats you start in this panel show up here.',
24
+ sessionRunning: 'Working',
25
+ composerPlaceholder: 'Ask {provider} to create or edit documents…',
26
+ send: 'Send',
27
+ stop: 'Stop',
28
+ working: 'Working',
29
+ contextPage: 'Page {n}',
30
+ contextSelection: 'Selection',
31
+ pendingComments: {
32
+ one: '{count} comment',
33
+ other: '{count} comments',
34
+ },
35
+ applyComments: 'Apply comments',
36
+ applyCommentsWith: 'Apply with {provider}',
37
+ createDoc: 'Draft with agent',
38
+ createDocWith: 'Create a document with {provider}',
39
+ quickCreate: 'Draft a new document',
40
+ quickCreateHint:
41
+ 'Opens a blank document; describe it and the agent drafts it section by section.',
42
+ quickApply: 'Apply pending comments',
43
+ quickApplyHint: 'Resolves every @doc-comment marker in this document.',
44
+ quickTheme: 'Create a theme',
45
+ quickThemeHint: 'Extracts or designs a reusable theme under themes/.',
46
+ quickEdit: 'Edit this page',
47
+ quickEditHint: 'Describe a change to the page you are viewing.',
48
+ emptyTitle: 'What should we build?',
49
+ emptyHint: 'Describe a document, or pick a starting point.',
50
+ questionSubmit: 'Continue',
51
+ questionOther: 'Other',
52
+ questionOtherPlaceholder: 'Type your own answer',
53
+ questionCancelled: 'Dismissed',
54
+ permissionTitle: 'Needs approval',
55
+ allow: 'Allow',
56
+ deny: 'Deny',
57
+ allowed: 'Allowed',
58
+ denied: 'Denied',
59
+ autoApprove: 'Auto-approve',
60
+ autoApproveHint: 'Run commands without asking. Edits inside the workspace are always allowed.',
61
+ resultDone: 'Done',
62
+ resultStopped: 'Stopped',
63
+ resultSeconds: '{seconds}s',
64
+ errorEyebrow: 'Error',
65
+ statusLoading: 'Checking agents',
66
+ disabled: 'The agent panel is disabled in open-doc.config.ts.',
67
+ connectTitle: 'Connect an agent',
68
+ connectDescription:
69
+ 'Drive your coding agent from here instead of a terminal. Agents installed on this machine connect automatically and reuse their sign-in.',
70
+ connect: 'Connect',
71
+ connecting: 'Connecting',
72
+ connected: 'Connected',
73
+ connectInstallHint: 'Adds {pkg} to this workspace with {pm}.',
74
+ cliFound: 'CLI found · v{version}',
75
+ cliFoundNoVersion: 'CLI found',
76
+ cliMissing: 'CLI not found on PATH',
77
+ cliHint: 'Install the {name} CLI and sign in once; the panel reuses its login.',
78
+ needCliTitle: 'Install Codex first',
79
+ needCliDescription:
80
+ 'The panel drives the Codex CLI on this machine, and it was not found on your PATH. Install it, sign in once in a terminal with `codex`, then check again.',
81
+ checkAgain: 'Check again',
82
+ retry: 'Retry',
83
+ toastConnected: '{name} connected',
84
+ toastConnectFailed: 'Could not install {pkg}',
85
+ manageConnections: 'Manage agents',
86
+ backToChat: 'Back',
87
+ toastSendFailed: 'Could not send message',
88
+ newDocTitle: "What's this document about?",
89
+ newDocHint:
90
+ 'Describe the topic, audience and tone. {provider} drafts it section by section while you watch.',
91
+ newDocPlaceholder: 'A two-page project brief on…',
92
+ toastCreateDocFailed: 'Could not create a document',
93
+ steps: {
94
+ one: '{count} step',
95
+ other: '{count} steps',
96
+ },
97
+ questionSkip: 'Skip',
98
+ copyMessage: 'Copy',
99
+ copied: 'Copied',
100
+ editMessage: 'Edit',
101
+ cancelEdit: 'Cancel',
102
+ sendEdit: 'Send',
103
+ editHint:
104
+ 'Sending replaces the conversation after this message. Edits already made to files stay.',
105
+ modelDefault: 'Default',
106
+ reasoning: 'Reasoning',
107
+ effortAuto: 'Auto',
108
+ efforts: {
109
+ minimal: 'Minimal',
110
+ low: 'Low',
111
+ medium: 'Medium',
112
+ high: 'High',
113
+ xhigh: 'Extra high',
114
+ max: 'Max',
115
+ },
116
+ checkRunning: 'Checking the document…',
117
+ checkFailed: 'Could not check the document',
118
+ checkClean: 'Checked · no problems',
119
+ checkCleanPages: 'Checked · no problems · {count} pages',
120
+ checkFound: { one: 'The check found {count} problem', other: 'The check found {count} problems' },
121
+ checkMore: '+{count} more',
122
+ checkFix: 'Ask the agent to fix',
123
+ presenceEditing: '{provider} is editing',
124
+ presenceThinking: 'Thinking',
125
+ presenceWaiting: 'Waiting for you',
126
+ };
127
+
128
+ type Strings<T> = { [K in keyof T]: T[K] extends string ? string : Strings<T[K]> };
129
+
130
+ function translateTree<T extends object>(tree: T, t: (text: string) => string): Strings<T> {
131
+ const out: Record<string, unknown> = {};
132
+ for (const [key, value] of Object.entries(tree)) {
133
+ out[key] = typeof value === 'string' ? t(value) : translateTree(value as object, t);
134
+ }
135
+ return out as Strings<T>;
136
+ }
137
+
138
+ export function useLocale() {
139
+ const { locale, t } = useAppLocale();
140
+ return useMemo(() => ({ id: locale as string, agent: translateTree(AGENT, t) }), [locale, t]);
141
+ }
142
+
143
+ export function format(template: string, vars: Record<string, string | number>): string {
144
+ return template.replace(/\{(\w+)\}/g, (whole, key: string) =>
145
+ vars[key] === undefined ? whole : String(vars[key]),
146
+ );
147
+ }
148
+
149
+ export function plural(count: number, forms: { one: string; other: string }): string {
150
+ return count === 1 ? forms.one : forms.other;
151
+ }
@@ -4,3 +4,7 @@ import { twMerge } from 'tailwind-merge';
4
4
  export function cn(...inputs: ClassValue[]): string {
5
5
  return twMerge(clsx(inputs));
6
6
  }
7
+
8
+ export function clamp(value: number, min: number, max: number): number {
9
+ return Math.min(max, Math.max(min, value));
10
+ }
@@ -0,0 +1,103 @@
1
+ import { useEffect, useMemo, useRef, useState } from 'react';
2
+ import { useParams, useSearchParams } from 'react-router-dom';
3
+ import { PageFrame } from '../components/page-frame';
4
+ import { nextFrame, waitForFonts } from '../lib/print-ready';
5
+ import { scanDocument } from '../lib/scan';
6
+ import { pageLang, resolvePageGeometry } from '../lib/sdk';
7
+ import { useDocModule } from '../lib/use-doc-module';
8
+ import { useDocPages } from '../lib/use-doc-pages';
9
+
10
+ /** Set on the page once it is laid out, numbered and in its fonts — the moment a screenshot is true. */
11
+ export const PREVIEW_READY_ATTR = 'data-od-preview-ready';
12
+
13
+ /**
14
+ * One sheet at its true size with nothing around it: `/d/<id>/preview?p=3`.
15
+ * An agent screenshots it to see what it just changed. Every page is still
16
+ * drawn — contents, figure numbers and cross-references are counted across
17
+ * the whole document — but only the asked-for one is shown.
18
+ */
19
+ export function DocPreview() {
20
+ const { docId } = useParams<{ docId: string }>();
21
+ const [params] = useSearchParams();
22
+ const state = useDocModule(docId);
23
+ const doc = state.doc;
24
+ const geometry = useMemo(() => resolvePageGeometry(doc?.meta), [doc?.meta]);
25
+ const { pages, measuring } = useDocPages(doc, geometry);
26
+ const pagesRef = useRef<HTMLDivElement>(null);
27
+ const [ready, setReady] = useState(false);
28
+
29
+ const asked = Number.parseInt(params.get('p') ?? '1', 10);
30
+ const page = Number.isFinite(asked) ? Math.min(Math.max(asked, 1), Math.max(pages.length, 1)) : 1;
31
+
32
+ useEffect(() => {
33
+ setReady(false);
34
+ if (state.status !== 'ready' || measuring) return;
35
+ let cancelled = false;
36
+ (async () => {
37
+ await nextFrame();
38
+ await waitForFonts();
39
+ await nextFrame();
40
+ const root = pagesRef.current;
41
+ if (cancelled || !root) return;
42
+ scanDocument(root, doc?.meta);
43
+ // The numbers the scan resolved are drawn on the next commit.
44
+ await nextFrame();
45
+ await nextFrame();
46
+ if (!cancelled) setReady(true);
47
+ })();
48
+ return () => {
49
+ cancelled = true;
50
+ };
51
+ }, [state.status, doc, measuring]);
52
+
53
+ useEffect(() => {
54
+ document.title = doc ? `${doc.meta?.title ?? docId} · p. ${page}` : 'open-doc';
55
+ }, [doc, docId, page]);
56
+
57
+ if (state.status === 'error') {
58
+ return (
59
+ <p role="alert" className="p-6 font-mono text-sm">
60
+ {state.error.message}
61
+ </p>
62
+ );
63
+ }
64
+
65
+ return (
66
+ <div
67
+ className="min-h-screen bg-white"
68
+ {...{ [PREVIEW_READY_ATTR]: ready ? 'true' : 'false' }}
69
+ data-od-preview-page={page}
70
+ data-od-preview-pages={pages.length}
71
+ >
72
+ <div ref={pagesRef} data-od-viewer="">
73
+ {doc &&
74
+ pages.map((entry, index) => (
75
+ // The other sheets are laid out where they are, out of sight, so
76
+ // what the scan counts on them is counted as the viewer counts it.
77
+ <div
78
+ key={entry.key}
79
+ style={
80
+ index + 1 === page
81
+ ? undefined
82
+ : { position: 'absolute', left: -99999, top: 0, visibility: 'hidden' }
83
+ }
84
+ aria-hidden={index + 1 === page ? undefined : true}
85
+ >
86
+ <PageFrame
87
+ index={index}
88
+ total={pages.length}
89
+ geometry={geometry}
90
+ scale={1}
91
+ design={doc.design}
92
+ lang={pageLang(doc.meta)}
93
+ watermark={doc.meta?.watermark}
94
+ flat
95
+ >
96
+ {entry.content}
97
+ </PageFrame>
98
+ </div>
99
+ ))}
100
+ </div>
101
+ </div>
102
+ );
103
+ }