@hachej/boring-ui-kit 0.4.12 → 0.4.13

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 (48) hide show
  1. package/package.json +2 -2
  2. package/r/agent-target.json +4 -4
  3. package/r/app-shell.json +9 -9
  4. package/r/board-viewer.json +12 -6
  5. package/r/button.json +1 -1
  6. package/r/diagram-viewer.json +8 -2
  7. package/r/dock.json +1 -1
  8. package/r/documents.json +14 -12
  9. package/r/feedback-preview.json +1 -1
  10. package/r/feedback.json +6 -6
  11. package/r/file-tree.json +5 -5
  12. package/r/highlights.json +3 -3
  13. package/r/html-viewer.json +3 -3
  14. package/r/looks-viewer.json +9 -3
  15. package/r/maquette-viewer.json +9 -3
  16. package/r/markdown-editor.json +3 -3
  17. package/r/mockup-viewer.json +14 -2
  18. package/r/pi-ambient.json +10 -10
  19. package/r/pi-app.json +31 -20
  20. package/r/pi-artifacts.json +3 -3
  21. package/r/pi-chat-approval.json +1 -1
  22. package/r/pi-chat-attachments.json +1 -1
  23. package/r/pi-chat-markdown.json +2 -2
  24. package/r/pi-chat-mentions.json +1 -1
  25. package/r/pi-chat-pickers.json +1 -1
  26. package/r/pi-chat-plugins.json +11 -11
  27. package/r/pi-chat-question.json +1 -1
  28. package/r/pi-chat-slash.json +1 -1
  29. package/r/pi-chat-subagent.json +1 -1
  30. package/r/pi-chat-voice.json +2 -2
  31. package/r/pi-chat.json +5 -5
  32. package/r/pi-workspace.json +4 -4
  33. package/r/placed-agent.json +4 -4
  34. package/r/provider-setup.json +2 -2
  35. package/r/record-viewer.json +8 -2
  36. package/r/registry.json +396 -203
  37. package/r/requests-board.json +1 -1
  38. package/r/shared-chat.json +6 -6
  39. package/r/task-list-viewer.json +2 -2
  40. package/r/version-history.json +3 -3
  41. package/r/viewer-code.json +36 -0
  42. package/r/viewer-frame.json +447 -0
  43. package/r/viewer-html.json +32 -0
  44. package/r/viewer-image.json +36 -0
  45. package/r/viewer-markdown.json +47 -0
  46. package/r/viewer-pdf.json +45 -0
  47. package/r/viewers.json +8 -491
  48. package/r/windows.json +1 -1
package/r/viewers.json CHANGED
@@ -2,498 +2,15 @@
2
2
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
3
3
  "name": "viewers",
4
4
  "title": "Viewers",
5
- "description": "The standard viewer top bar (title, status, viewer controls, Refresh, Share, Copy, Download, Open in new tab, Close, overflow menu) with Tailwind panes over it: the Markdown editor with a formatting toolbar and prose styling, the passive HTML preview and source editor, an image viewer with zoom and pan, a PDF viewer, and LocalFileViewer for browser-only files. Owned, editable source over the borrowed controllers; no AI SDK.",
6
- "dependencies": [
7
- "@hachej/boring-ui-kit@^0.4.12",
8
- "@hachej/boring-files@^0.4.12",
9
- "react@^19.0.0",
10
- "react-dom@^19.0.0",
11
- "marked@^17.0.6",
12
- "@tiptap/core@^3.31.4",
13
- "@tiptap/react@^3.31.4",
14
- "@tiptap/pm@^3.31.4",
15
- "@tiptap/starter-kit@^3.31.4",
16
- "@tiptap/markdown@^3.31.4",
17
- "@tiptap/extensions@^3.31.4",
18
- "@tiptap/extension-list@^3.31.4",
19
- "@tiptap/extension-table@^3.31.4",
20
- "@tiptap/extension-image@^3.31.4",
21
- "@tiptap/extension-highlight@^3.31.4",
22
- "@tiptap/extension-bubble-menu@^3.31.4",
23
- "@tiptap/extension-floating-menu@^3.31.4",
24
- "lucide-react@^1.51.0",
25
- "pdfjs-dist@6.3.289"
26
- ],
5
+ "description": "Deprecated aggregate: installs every viewer item (viewer-frame, viewer-markdown, viewer-html, viewer-image, viewer-pdf, viewer-code). Add the items you use instead.",
27
6
  "registryDependencies": [
28
- "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.12/r/theme.json",
29
- "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.12/r/utils.json",
30
- "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.12/r/button.json",
31
- "button",
32
- "toggle",
33
- "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.12/r/version-history.json",
34
- "toggle-group",
35
- "dialog",
36
- "textarea",
37
- "badge",
38
- "dropdown-menu",
39
- "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.12/r/markdown-editor.json"
40
- ],
41
- "files": [
42
- {
43
- "path": "registry/viewers/download.ts",
44
- "content": "/** Offers `data` as a file download without navigating. The temporary object URL is revoked once the browser has taken the file. */\nexport function downloadFile(name: string, data: BlobPart, type: string): void {\n const url = URL.createObjectURL(new Blob([data], { type }));\n const link = Object.assign(document.createElement('a'), { href: url, download: name });\n document.body.append(link);\n link.click();\n link.remove();\n setTimeout(() => URL.revokeObjectURL(url), 1000);\n}\n\n/** A file name for a document title: lower case words joined by hyphens, with the extension of its type. */\nexport function fileNameFor(title: string, extension: string): string {\n const base = title.toLowerCase().replace(/\\.[a-z0-9]{1,8}$/, '').replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'document';\n return `${base}.${extension}`;\n}\n",
45
- "type": "registry:lib",
46
- "target": "components/viewers/download.ts"
47
- },
48
- {
49
- "path": "registry/viewers/html-pane.tsx",
50
- "content": "'use client';\n\nimport { useMemo, useState, useSyncExternalStore } from 'react';\nimport type { ReactNode } from 'react';\nimport { CodeXmlIcon, EyeIcon, RotateCcwIcon, SaveIcon, SearchCheckIcon } from 'lucide-react';\nimport { HtmlViewer } from '@hachej/boring-ui-kit/html-viewer';\nimport type { HtmlController } from '@hachej/boring-ui-kit/html';\nimport { Button } from '@/components/ui/button';\nimport { editorControls } from '../button/editor-controls';\nimport { downloadFile, fileNameFor } from './download';\nimport { copyText } from '../utils/utils';\nimport { InteractiveFrame } from './interactive-html';\nimport type { InteractiveHtml } from './interactive-html';\nimport { ViewerFrame, ViewerToggle } from './viewer-frame';\nimport type { ViewerShare, ViewerStatus } from './viewer-frame';\nimport { defaultViewerLabels, useViewerText } from './viewer-window';\nimport type { ViewerLabels } from './viewer-window';\n\nexport type HtmlPaneMode = 'preview' | 'source';\n\nexport interface HtmlPaneProps {\n /** Borrowed: the host owns the controller and disposes it. */\n readonly controller: HtmlController;\n readonly title?: string;\n readonly subtitle?: ReactNode;\n readonly target?: unknown;\n readonly revision?: string;\n readonly initialMode?: HtmlPaneMode;\n /** Reports the person's choice, so a host that remounts the pane (for a new revision) can start it in the same mode. */\n readonly onModeChange?: (mode: HtmlPaneMode) => void;\n /**\n * Host opt-in (off by default): the preview then runs the page's own scripts in a sandboxed frame with an opaque origin and a\n * Content-Security-Policy limited to inline code and `scriptSources`. See registry/README.md. Without it the preview is the passive,\n * script-free rendering of `@hachej/boring-ui-kit/html-viewer`.\n */\n readonly interactive?: InteractiveHtml;\n /** Leading header content, before the title. */\n readonly headerStart?: ReactNode;\n readonly controls?: ReactNode;\n readonly onRefresh?: () => unknown;\n readonly onShare?: ViewerShare;\n readonly onOpenInNewTab?: () => unknown;\n readonly onClose?: () => unknown;\n readonly testId?: string;\n /** Overrides the title's `data-testid` (default `<testId>-title`). */\n readonly titleTestId?: string;\n readonly className?: string;\n /** The pane's and its bar's words, over the window's and `defaultViewerLabels`. */\n readonly labels?: Partial<ViewerLabels> | undefined;\n}\n\nexport function htmlStatus(state: ReturnType<HtmlController['getSnapshot']>, labels: ViewerLabels = defaultViewerLabels): ViewerStatus {\n if (state.lifecycle === 'disposed') return { label: labels.closed };\n if (state.save.kind === 'pending') return { label: labels.saving, tone: 'warning' };\n if (state.save.kind === 'settled' && state.save.result.kind === 'unknown') return { label: labels.saveUnconfirmed, tone: 'danger' };\n if (state.remote !== null || state.save.kind === 'settled' && state.save.result.kind === 'conflict') return { label: labels.changedElsewhere, tone: 'danger' };\n if (state.readOnly) return { label: labels.readOnly, kind: 'read-only' };\n return state.dirty ? { label: labels.unsaved, tone: 'warning' } : { label: labels.saved, tone: 'success', kind: 'saved' };\n}\n\n/** The HTML safe preview and source editor in the standard viewer frame. The preview never runs scripts; a host-enabled interactive preview runs them, in a sandbox. */\nexport function HtmlPane({ controller, labels: ownLabels, title = 'HTML document', subtitle, target, revision, initialMode = 'preview', onModeChange, interactive, headerStart, controls, onRefresh, onShare, onOpenInNewTab, onClose, testId = 'viewer', titleTestId, className }: HtmlPaneProps) {\n const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);\n const { labels } = useViewerText(ownLabels);\n const [mode, setModeState] = useState<HtmlPaneMode>(initialMode);\n const setMode = (next: HtmlPaneMode) => { setModeState(next); onModeChange?.(next); };\n const [reload, setReload] = useState(0);\n const [error, setError] = useState<string>();\n const pending = state.save.kind === 'pending';\n const unconfirmed = state.save.kind === 'settled' && state.save.result.kind === 'unknown';\n const disposed = state.lifecycle === 'disposed';\n const perform = (action: () => Promise<{ readonly kind: string; readonly reason?: string }>) => {\n setError(undefined);\n void Promise.resolve().then(action).then(result => { if ((result.kind === 'denied' || result.kind === 'unavailable' || result.kind === 'file_too_large') && result.reason) setError(result.reason); })\n .catch(() => setError(labels.operationFailed));\n };\n const filename = useMemo(() => fileNameFor(title, 'html'), [title]);\n return <ViewerFrame title={title} subtitle={subtitle} headerStart={headerStart} status={htmlStatus(state, labels)} labels={labels} target={target} revision={revision} testId={testId} {...(titleTestId ? { titleTestId } : {})} className={className}\n onRefresh={() => { if (interactive && mode === 'preview') setReload(count => count + 1); return (onRefresh ?? (() => controller.actions.refresh()))(); }} onShare={onShare} onCopy={() => copyText(controller.getSnapshot().text)}\n onDownload={() => downloadFile(filename, controller.getSnapshot().text, 'text/html;charset=utf-8')} onOpenInNewTab={onOpenInNewTab} onClose={onClose}\n controls={<>\n <ViewerToggle label={labels.view} value={mode} onChange={setMode} options={[\n { id: 'preview', label: labels.htmlPreview, text: labels.preview, icon: <EyeIcon data-icon=\"inline-start\" aria-hidden=\"true\" />, testId: `${testId}-mode-preview` },\n { id: 'source', label: labels.htmlSource, text: labels.source, icon: <CodeXmlIcon data-icon=\"inline-start\" aria-hidden=\"true\" />, testId: `${testId}-mode-source` }]} />\n {!state.readOnly && state.dirty && <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.save} title={labels.save} data-testid={`${testId}-save`} disabled={disposed || pending || unconfirmed} onClick={() => perform(() => controller.flush(controller.actions.selection()))}><SaveIcon data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>}\n {unconfirmed && <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.checkSave} title={labels.checkSave} onClick={() => perform(controller.actions.reconcile)}><SearchCheckIcon data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>}\n {unconfirmed && <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.abandon} title={labels.abandon} onClick={() => perform(controller.actions.abandon)}><RotateCcwIcon data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>}\n {state.remote !== null && <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.discardLocal} title={labels.discardLocal} disabled={pending || unconfirmed} onClick={() => perform(controller.actions.discardToRemote)}><RotateCcwIcon data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>}\n {controls}\n </>}>\n {error && <p role=\"alert\" className=\"m-0 px-3 py-2\">{error}</p>}\n {interactive && mode === 'preview'\n ? <InteractiveFrame text={state.text} sources={interactive.scriptSources} reload={reload} title={`${title} (running)`} testId={testId} />\n : <HtmlViewer components={editorControls} controller={controller} title={title} header={false} mode={mode === 'source' ? 'source' : 'preview'} onModeChange={next => setMode(next)} className=\"boring-html-pane\" />}\n </ViewerFrame>;\n}\n",
51
- "type": "registry:component",
52
- "target": "components/viewers/html-pane.tsx"
53
- },
54
- {
55
- "path": "registry/viewers/image-pane.tsx",
56
- "content": "'use client';\n\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport type { PointerEvent, ReactNode } from 'react';\nimport { MaximizeIcon, ScanIcon, ZoomInIcon, ZoomOutIcon } from 'lucide-react';\nimport { Button } from '@/components/ui/button';\nimport { downloadFile } from './download';\nimport { formatBytes, useMediaUrl } from './media';\nimport type { MediaSource } from './media';\nimport { cn } from '../utils/utils';\nimport { useViewerBar, ViewerFrame } from './viewer-frame';\nimport type { ViewerShare, ViewerStatus } from './viewer-frame';\nimport { useViewerText } from './viewer-window';\n\nexport const IMAGE_TYPES: Readonly<Record<string, string>> = { 'image/png': 'PNG', 'image/jpeg': 'JPEG', 'image/gif': 'GIF', 'image/webp': 'WebP', 'image/svg+xml': 'SVG' };\nconst STEPS = [0.1, 0.25, 0.5, 0.75, 1, 1.5, 2, 3, 4, 6, 8];\n\nexport interface ImagePaneProps extends MediaSource {\n readonly name: string;\n readonly mediaType: string;\n readonly subtitle?: ReactNode;\n readonly status?: ViewerStatus;\n readonly target?: unknown;\n readonly revision?: string;\n /** Leading header content, before the title. */\n readonly headerStart?: ReactNode;\n readonly controls?: ReactNode;\n /** Re-reads the file; the host passes the new bytes, blob or URL back in. */\n readonly onRefresh?: () => unknown;\n readonly onShare?: ViewerShare;\n readonly onOpenInNewTab?: () => unknown;\n readonly onClose?: () => unknown;\n readonly testId?: string;\n /** Overrides the title's `data-testid` (default `<testId>-title`). */\n readonly titleTestId?: string;\n readonly className?: string;\n}\n\n/** Zoom steps and the level; on a narrow bar only the steps stay (the stage also zooms with + - 0). Fit and Actual size are in the \"…\" menu. */\nexport function ZoomControls({ testId, percent, ready, onStep, onFit }: { readonly testId: string; readonly percent: string; readonly ready: boolean; readonly onStep: (direction: 1 | -1) => void; readonly onFit: () => void }) {\n const { tight } = useViewerBar();\n const { labels } = useViewerText();\n return <div role=\"group\" aria-label={labels.zoom} className=\"flex items-center gap-0.5\">\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.zoomOut} title={labels.zoomOut} data-testid={`${testId}-zoom-out`} disabled={!ready} onClick={() => onStep(-1)}><ZoomOutIcon data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>\n {!tight && <Button variant=\"ghost\" size=\"sm\" data-testid={`${testId}-zoom-level`} aria-label={labels.zoomLevel(percent)} title={labels.fitToView} disabled={!ready} className=\"min-w-10\" onClick={onFit}>{percent}</Button>}\n <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.zoomIn} title={labels.zoomIn} data-testid={`${testId}-zoom-in`} disabled={!ready} onClick={() => onStep(1)}><ZoomInIcon data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>\n </div>;\n}\n\ntype Zoom = { readonly kind: 'fit' } | { readonly kind: 'scale'; readonly value: number };\n\n/**\n * A read-only image viewer in the standard frame: fit to view by default, zoom, actual size, drag to pan when zoomed, a checkerboard\n * behind transparency. Every type, SVG included, is shown through an `<img>` from an object URL, never as markup.\n */\nexport function ImagePane({ name, mediaType, bytes, blob, url: hostUrl, subtitle, status, target, revision, headerStart, controls, onRefresh, onShare, onOpenInNewTab, onClose, testId = 'viewer', titleTestId, className }: ImagePaneProps) {\n const source = useMemo<MediaSource>(() => ({ ...(bytes ? { bytes } : {}), ...(blob ? { blob } : {}), ...(hostUrl ? { url: hostUrl } : {}) }), [bytes, blob, hostUrl]);\n const { url, size, blob: made } = useMediaUrl(source, mediaType);\n const supported = mediaType in IMAGE_TYPES;\n const { labels } = useViewerText();\n const [zoom, setZoom] = useState<Zoom>({ kind: 'fit' });\n const [natural, setNatural] = useState<{ width: number; height: number } | undefined>(undefined);\n const [failed, setFailed] = useState(false);\n const [fitScale, setFitScale] = useState(1);\n const stage = useRef<HTMLDivElement>(null);\n const image = useRef<HTMLImageElement>(null);\n const drag = useRef<{ x: number; y: number; left: number; top: number } | undefined>(undefined);\n useEffect(() => { setNatural(undefined); setFailed(false); }, [url]);\n const measure = () => {\n const box = stage.current, img = image.current;\n if (box && img && img.naturalWidth) setFitScale(Math.min(1, (box.clientWidth - 32) / img.naturalWidth, (box.clientHeight - 32) / img.naturalHeight));\n };\n useEffect(() => {\n const box = stage.current;\n if (!box || typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(measure);\n observer.observe(box);\n return () => observer.disconnect();\n }, [url]);\n const current = zoom.kind === 'fit' ? fitScale : zoom.value;\n const step = (direction: 1 | -1) => {\n const now = Number(current.toFixed(3));\n const next = direction > 0 ? STEPS.find(value => value > now + 0.001) : [...STEPS].reverse().find(value => value < now - 0.001);\n if (next) setZoom({ kind: 'scale', value: next });\n };\n const label = IMAGE_TYPES[mediaType] ?? mediaType;\n const facts = [label, natural && `${natural.width} × ${natural.height}`, size !== undefined && formatBytes(size)].filter(Boolean) as string[];\n const panning = zoom.kind === 'scale' && natural !== undefined && (natural.width * zoom.value > (stage.current?.clientWidth ?? 0) || natural.height * zoom.value > (stage.current?.clientHeight ?? 0));\n const begin = (event: PointerEvent<HTMLDivElement>) => {\n const box = stage.current;\n if (!panning || !box || event.button !== 0) return;\n drag.current = { x: event.clientX, y: event.clientY, left: box.scrollLeft, top: box.scrollTop };\n box.setPointerCapture?.(event.pointerId);\n };\n const move = (event: PointerEvent<HTMLDivElement>) => {\n const box = stage.current, start = drag.current;\n if (!box || !start) return;\n box.scrollLeft = start.left - (event.clientX - start.x);\n box.scrollTop = start.top - (event.clientY - start.y);\n };\n const end = () => { drag.current = undefined; };\n const downloadName = name.split('/').pop() || 'image';\n const download = () => { const data = made; if (data) downloadFile(downloadName, data, mediaType); else if (url) { const link = Object.assign(document.createElement('a'), { href: url, download: downloadName }); document.body.append(link); link.click(); link.remove(); } };\n const percent = `${Math.round(current * 100)}%`;\n return <ViewerFrame title={name.split('/').pop() || name} subtitle={<>{subtitle}{subtitle && facts.length > 0 && <span aria-hidden=\"true\">·</span>}{facts.join(' · ')}</>} status={status} target={target} revision={revision} headerStart={headerStart} testId={testId} {...(titleTestId ? { titleTestId } : {})} className={className}\n onRefresh={onRefresh} onShare={onShare} onDownload={url ? download : undefined} onOpenInNewTab={onOpenInNewTab ?? (url ? () => { window.open(url, '_blank', 'noopener,noreferrer'); } : undefined)} onClose={onClose}\n menu={[\n { id: 'zoom-fit', label: labels.fitToView, icon: <ScanIcon className=\"size-4\" />, disabled: !natural, onSelect: () => setZoom({ kind: 'fit' }) },\n { id: 'zoom-actual', label: labels.actualSize, icon: <MaximizeIcon className=\"size-4\" />, disabled: !natural, onSelect: () => setZoom({ kind: 'scale', value: 1 }) }]}\n controls={<>\n <ZoomControls testId={testId} percent={percent} ready={Boolean(natural)} onStep={step} onFit={() => setZoom({ kind: 'fit' })} />\n {controls}\n </>}>\n <div ref={stage} data-testid={`${testId}-stage`} data-zoom={zoom.kind === 'fit' ? 'fit' : String(zoom.value)} data-panning={panning || undefined}\n onPointerDown={begin} onPointerMove={move} onPointerUp={end} onPointerCancel={end}\n className={cn('boring-viewer-stage relative min-h-0 flex-1 overflow-auto', panning && 'cursor-grab active:cursor-grabbing')} tabIndex={0} aria-label={labels.imageStage(name)}\n onKeyDown={event => { if (event.key === '+' || event.key === '=') step(1); else if (event.key === '-') step(-1); else if (event.key === '0') setZoom({ kind: 'fit' }); }}>\n {!supported ? <p role=\"alert\" className=\"m-auto p-6 text-center text-sm text-muted-foreground\">{labels.imageUnsupported(mediaType)}</p>\n : failed ? <p role=\"alert\" className=\"m-auto p-6 text-center text-sm text-muted-foreground\">{labels.imageUnreadable}</p>\n : url ? <div className=\"flex min-h-full min-w-full items-center justify-center p-4\">\n <img ref={image} src={url} alt={name} data-testid={`${testId}-image`} draggable={false} decoding=\"async\" referrerPolicy=\"no-referrer\"\n onLoad={event => { setNatural({ width: event.currentTarget.naturalWidth, height: event.currentTarget.naturalHeight }); measure(); }} onError={() => setFailed(true)}\n style={natural ? { width: natural.width * current, height: natural.height * current, maxWidth: 'none' } : undefined}\n className=\"boring-viewer-checker block shrink-0 select-none outline outline-1 outline-border\" />\n </div> : <p role=\"status\" className=\"m-auto p-6 text-sm text-muted-foreground\">{labels.loading}</p>}\n </div>\n </ViewerFrame>;\n}\n",
57
- "type": "registry:component",
58
- "target": "components/viewers/image-pane.tsx"
59
- },
60
- {
61
- "path": "registry/viewers/interactive-html.tsx",
62
- "content": "'use client';\n\nimport type { ReactNode, Ref } from 'react';\n\n/**\n * Host opt-in for running an HTML document's own scripts. `scriptSources` are the HTTPS origins the page may load libraries, styles and fonts\n * from (for example `https://cdnjs.cloudflare.com`). Everything else is closed: no network requests from the page, no frames, no forms.\n * Pinning library versions is the page's responsibility.\n */\nexport interface InteractiveHtml { readonly scriptSources: readonly string[] }\n\n/** An origin only: `https://host` with an optional port, no path, no wildcard, nothing that could add a second CSP directive. */\nconst ORIGIN = /^https:\\/\\/[a-z0-9]([a-z0-9-]*[a-z0-9])?(\\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*(:\\d{1,5})?$/i;\n\nexport function allowedOrigins(sources: readonly string[]): string[] {\n return [...new Set(sources.map(source => source.trim().toLowerCase()).filter(source => ORIGIN.test(source)))];\n}\n\n/** The Content-Security-Policy the running page gets: inline script and style, the allow-listed origins for libraries, nothing else. */\nexport function interactivePolicy(sources: readonly string[]): string {\n const origins = allowedOrigins(sources).join(' ');\n const list = (...extra: string[]) => [...extra, ...(origins ? [origins] : [])].join(' ');\n return [\n \"default-src 'none'\",\n `script-src ${list(\"'unsafe-inline'\")}`,\n `style-src ${list(\"'unsafe-inline'\")}`,\n 'img-src data: blob:',\n `font-src ${list('data:')}`,\n \"connect-src 'none'\",\n \"frame-src 'none'\",\n \"base-uri 'none'\",\n \"form-action 'none'\",\n ].join('; ');\n}\n\n/**\n * The document the frame loads: the policy and a no-referrer rule come first, so they apply before any of the page's own markup is parsed.\n * A second doctype or head in the page is ignored by the parser; a meta policy of the page's own can only tighten this one.\n */\nexport function interactiveDocument(text: string, sources: readonly string[]): string {\n return `<!doctype html><meta http-equiv=\"Content-Security-Policy\" content=\"${interactivePolicy(sources).replaceAll('\"', '&quot;')}\"><meta name=\"referrer\" content=\"no-referrer\">${text}`;\n}\n\n/**\n * The page running in a sandboxed frame: `allow-scripts` only. There is no `allow-same-origin`, so the page has an opaque origin (no cookies,\n * storage or access to this page), and no top navigation, popups, forms, downloads or modals. `allow=\"\"` withholds camera, microphone, location\n * and the other powerful features. Changing `reload` loads the page again from the start.\n */\nexport function InteractiveFrame({ text, sources, reload = 0, title = 'HTML page (running)', testId = 'viewer', children, frameRef, onLoad }: {\n readonly text: string;\n readonly sources: readonly string[];\n readonly reload?: number;\n readonly title?: string;\n readonly testId?: string;\n readonly children?: ReactNode;\n /** Host message bridges may identify the sender, never read the frame's document. */\n readonly frameRef?: Ref<HTMLIFrameElement> | undefined;\n readonly onLoad?: (() => void) | undefined;\n}) {\n return <div className=\"boring-html-run flex min-h-0 flex-1 flex-col\" data-testid={`${testId}-run`}>\n <iframe key={reload} ref={frameRef} onLoad={onLoad} title={title} sandbox=\"allow-scripts\" allow=\"\" referrerPolicy=\"no-referrer\" srcDoc={interactiveDocument(text, sources)}\n data-testid={`${testId}-run-frame`} className=\"size-full min-h-0 flex-1\" />\n {children}\n </div>;\n}\n",
63
- "type": "registry:component",
64
- "target": "components/viewers/interactive-html.tsx"
65
- },
66
- {
67
- "path": "registry/viewers/local-file-viewer.tsx",
68
- "content": "'use client';\n\nimport { useEffect, useMemo, useState } from 'react';\nimport { mediaTypeOf } from '@hachej/boring-files/file-types';\nimport { downloadFile } from './download';\nimport { IMAGE_TYPES, ImagePane } from './image-pane';\nimport { formatBytes } from './media';\nimport { PdfPane } from './pdf-pane';\nimport { ViewerFrame } from './viewer-frame';\nimport type { ViewerFrameProps } from './viewer-frame';\nimport { useViewerText } from './viewer-window';\n\nexport interface LocalFileViewerProps extends Pick<ViewerFrameProps, 'subtitle' | 'headerStart' | 'controls' | 'onClose' | 'testId' | 'titleTestId' | 'className'> {\n readonly name: string;\n /** Browser-only bytes. Nothing is uploaded or retained on reload. A File is also a Blob. */\n readonly blob: Blob;\n}\n\n/** A read-only browser file, without a resource client or locator. A specific Blob type wins; otherwise the name supplies the type. */\nexport function LocalFileViewer({ name, blob, ...frame }: LocalFileViewerProps) {\n const declared = blob.type.split(';')[0]?.trim().toLowerCase();\n const mediaType = !declared || declared === 'application/octet-stream' ? mediaTypeOf(name) : declared;\n const media = useMemo(() => blob.type === mediaType ? blob : blob.slice(0, blob.size, mediaType), [blob, mediaType]);\n if (Object.hasOwn(IMAGE_TYPES, mediaType)) return <ImagePane key={name} name={name} blob={media} mediaType={mediaType} {...frame} />;\n if (mediaType === 'application/pdf') return <PdfPane key={name} name={name} blob={media} {...frame} />;\n const text = mediaType.startsWith('text/') || mediaType === 'application/json' || mediaType === 'application/xml' || mediaType.endsWith('+json') || mediaType.endsWith('+xml');\n return <LocalText name={name} blob={blob} mediaType={mediaType} text={text} {...frame} />;\n}\n\ntype Preview = { readonly blob: Blob; readonly text: string | undefined };\n\n/** Text stays literal, including HTML. Unknown types and failed UTF-8 reads keep the original download. */\nfunction LocalText({ name, blob, mediaType, text: canRead, subtitle, testId = 'viewer', ...frame }: LocalFileViewerProps & { readonly mediaType: string; readonly text: boolean }) {\n const { labels } = useViewerText();\n const [preview, setPreview] = useState<Preview>();\n useEffect(() => {\n if (!canRead) return;\n let active = true;\n void (async () => {\n let text: string | undefined;\n try {\n const bytes = new Uint8Array(await blob.arrayBuffer());\n if (!bytes.includes(0)) text = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);\n } catch { /* A failed read leaves the original file available for download. */ }\n if (active) setPreview({ blob, text });\n })();\n return () => { active = false; };\n }, [blob, canRead]);\n const loading = canRead && preview?.blob !== blob;\n const text = canRead && preview?.blob === blob ? preview.text : undefined;\n const title = name.split('/').pop() || name;\n return <ViewerFrame title={title} testId={testId} {...frame}\n subtitle={<>{subtitle}{subtitle && <span aria-hidden=\"true\">·</span>}{mediaType} · {formatBytes(blob.size)}</>}\n onDownload={() => downloadFile(title, blob, blob.type || mediaType)}>\n {text === undefined\n ? <p role=\"status\" className=\"m-0 p-4 text-sm text-muted-foreground\">{loading ? labels.loading : labels.noPreview}</p>\n : <div className=\"min-h-0 flex-1 overflow-auto p-3\"><pre data-testid={`${testId}-text`} className=\"m-0 font-mono text-sm leading-relaxed break-words whitespace-pre-wrap\">{text}</pre></div>}\n </ViewerFrame>;\n}\n",
69
- "type": "registry:component",
70
- "target": "components/viewers/local-file-viewer.tsx"
71
- },
72
- {
73
- "path": "registry/viewers/markdown-pane.tsx",
74
- "content": "'use client';\n\nimport { useCallback, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from 'react';\nimport type { ReactNode } from 'react';\nimport { SaveIcon } from 'lucide-react';\nimport { MarkdownEditor } from '@hachej/boring-ui-kit/markdown-editor';\nimport type { MarkdownEditorProps, MarkdownImageResolver, MarkdownMountedTools, MarkdownRichSafety } from '@hachej/boring-ui-kit/markdown-editor';\nimport type { MarkdownController } from '@hachej/boring-ui-kit/markdown';\nimport { Button } from '@/components/ui/button';\nimport { DropdownMenuGroup, DropdownMenuItem, DropdownMenuSeparator } from '@/components/ui/dropdown-menu';\nimport { ActionMenuItemContent } from '../button/actions';\nimport { editorControls } from '../button/editor-controls';\nimport { MarkdownFormattingControl, MarkdownMenuItems } from '../markdown-editor/markdown-editor';\nimport { downloadFile, fileNameFor } from './download';\nimport { copyText } from '../utils/utils';\nimport { ViewerFrame } from './viewer-frame';\nimport type { ViewerShare, ViewerStatus } from './viewer-frame';\nimport { defaultViewerLabels, useViewerText, useViewerWindow } from './viewer-window';\nimport type { ViewerLabels } from './viewer-window';\n\nexport interface MarkdownPaneProps {\n /** Borrowed: the host owns the controller and disposes it. */\n readonly controller: MarkdownController;\n readonly title?: string;\n readonly subtitle?: ReactNode;\n readonly target?: unknown;\n readonly revision?: string;\n readonly initialMode?: 'rich' | 'source';\n /** Reports the person's choice, so a host that remounts the pane (for a new revision) can start it in the same mode. */\n readonly onModeChange?: (mode: 'rich' | 'source') => void;\n readonly placeholder?: string;\n /** Defaults to 1200ms idle autosave; false keeps the Save button. */\n readonly autosave?: MarkdownEditorProps['autosave'];\n /** Registers the flush for owner teardown; this is not a navigation guard. */\n readonly onAutosaveChange?: MarkdownEditorProps['onAutosaveChange'];\n /** Registers with a host navigation guard whose onClose handles refused saves and deliberate discard. */\n readonly onBeforeLeaveChange?: MarkdownEditorProps['onAutosaveChange'];\n /** Selection formatting by default. The header icon remembers the person's choice for this viewer session. */\n readonly formattingToolbar?: MarkdownEditorProps['formattingToolbar'];\n readonly onFormattingToolbarChange?: (toolbar: 'selection' | 'pinned') => void;\n /** Leading header content, before the title. */\n readonly headerStart?: ReactNode;\n /** Extra viewer controls, for example a version switcher. */\n readonly controls?: ReactNode;\n /** Defaults to the controller's refresh: a clean document follows the saved one, unsaved edits are kept and shown as changed elsewhere. */\n readonly onRefresh?: () => unknown;\n readonly onShare?: ViewerShare;\n readonly onOpenInNewTab?: () => unknown;\n readonly onClose?: () => unknown;\n /** Host mapping from an image address in the document to a loadable URL. Images stay inert without it. */\n readonly resolveImage?: MarkdownImageResolver;\n readonly onMountedTools?: (tools: MarkdownMountedTools | null) => void;\n readonly testId?: string;\n /** Overrides the title's `data-testid` (default `<testId>-title`). */\n readonly titleTestId?: string;\n readonly className?: string;\n /** The pane's and its bar's words, over the window's and `defaultViewerLabels`. */\n readonly labels?: Partial<ViewerLabels> | undefined;\n}\n\n/** The status dot for a Markdown controller: Saved (primary), Unsaved or Saving (muted), Save unconfirmed or Changed elsewhere (destructive, with words), Read-only. */\nexport function markdownStatus(state: ReturnType<MarkdownController['getSnapshot']>, labels: ViewerLabels = defaultViewerLabels): ViewerStatus {\n if (state.lifecycle === 'disposed') return { label: labels.closed };\n if (state.save.kind === 'pending') return { label: labels.saving, tone: 'warning' };\n if (state.save.kind === 'settled' && state.save.result.kind === 'unknown') return { label: labels.saveUnconfirmed, tone: 'danger' };\n if (state.save.kind === 'settled' && state.save.result.kind === 'conflict' || state.remote !== null) return { label: labels.changedElsewhere, tone: 'danger' };\n if (state.readOnly) return { label: labels.readOnly, kind: 'read-only' };\n return state.dirty ? { label: labels.unsaved, tone: 'warning' } : { label: labels.saved, tone: 'success', kind: 'saved' };\n}\n\n/** The Markdown editor in the standard viewer frame: Save while there are edits, with view choices and secondary actions under \"…\". */\nexport function MarkdownPane({ controller, title: givenTitle, labels: ownLabels, subtitle, target, revision, initialMode = 'rich', onModeChange, placeholder, formattingToolbar = 'selection', onFormattingToolbarChange, autosave: ownAutosave, onAutosaveChange, onBeforeLeaveChange, headerStart, controls, onRefresh, onShare, onOpenInNewTab, onClose, resolveImage, onMountedTools, testId = 'viewer', titleTestId, className }: MarkdownPaneProps) {\n const state = useSyncExternalStore(controller.subscribe, controller.getSnapshot, controller.getSnapshot);\n const { labels } = useViewerText(ownLabels);\n const window = useViewerWindow();\n const autosave = ownAutosave ?? window?.autosave ?? true;\n const flush = useRef<(() => Promise<boolean>) | null>(null);\n const registerAutosave = useCallback((save: (() => Promise<boolean>) | null) => { flush.current = save; onAutosaveChange?.(save); onBeforeLeaveChange?.(save); }, [onAutosaveChange, onBeforeLeaveChange]);\n const close = onClose ? async () => {\n if (autosave !== false && flush.current && !await flush.current() && !onBeforeLeaveChange) return false;\n return onClose();\n } : undefined;\n const title = givenTitle ?? labels.document;\n const [requested, setRequestedState] = useState<'rich' | 'source'>(initialMode);\n const setRequested = (next: 'rich' | 'source') => { setRequestedState(next); onModeChange?.(next); };\n const [toolbar, setToolbar] = useState(formattingToolbar);\n useLayoutEffect(() => setToolbar(formattingToolbar), [formattingToolbar]);\n const setFormatting = (next: 'selection' | 'pinned') => { setToolbar(next); onFormattingToolbarChange?.(next); };\n const [safety, setSafety] = useState<MarkdownRichSafety>({ safe: true });\n const mode = safety.safe ? requested : 'source';\n const unavailable = state.readOnly || state.lifecycle !== 'active';\n const pending = state.save.kind === 'pending';\n const unconfirmed = state.save.kind === 'settled' && state.save.result.kind === 'unknown';\n const [refused, setRefused] = useState<{ readonly save: typeof state.save; readonly label: string } | null>(null);\n const report: NonNullable<MarkdownEditorProps['onSaveResult']> = result => {\n if (result.kind === 'saved' || result.kind === 'conflict') setRefused(null);\n else if (result.kind === 'denied' || result.kind === 'unavailable' || result.kind === 'file_too_large') {\n const reason = result.reason ?? result.kind;\n setRefused({ save: controller.getSnapshot().save, label: labels.notSaved(reason.length > 48 ? `${reason.slice(0, 47)}…` : reason) });\n }\n };\n const save = () => {\n setRefused(null);\n void controller.flush(controller.actions.selection()).then(report, () => setRefused({ save: controller.getSnapshot().save, label: labels.notSaved(labels.saveFailedReason) }));\n };\n const manualSave = autosave === false && !state.readOnly && state.dirty;\n const saveItem = { id: 'save', label: labels.save, icon: <SaveIcon className=\"size-4\" />, disabled: unavailable || pending || unconfirmed, onSelect: save };\n const filename = useMemo(() => fileNameFor(title, 'md'), [title]);\n return <ViewerFrame showSavedStatus title={title} subtitle={subtitle} headerStart={headerStart} status={refused && refused.save === state.save && state.save.kind !== 'pending' ? { label: refused.label, tone: 'danger' } : markdownStatus(state, labels)} target={target} labels={labels} revision={revision} testId={testId} {...(titleTestId ? { titleTestId } : {})} className={className}\n onRefresh={onRefresh ?? (() => controller.actions.refresh())} onShare={onShare} onCopy={() => copyText(controller.getSnapshot().text)}\n onDownload={() => downloadFile(filename, controller.getSnapshot().text, 'text/markdown;charset=utf-8')} onOpenInNewTab={onOpenInNewTab} onClose={close}\n menuContent={<>\n <MarkdownMenuItems labels={labels} mode={mode} onModeChange={setRequested} richDisabledReason={safety.safe ? undefined : labels.richUnavailable(safety.reasons.join(', '))} testId={testId} />\n {manualSave && <><DropdownMenuSeparator className=\"min-[641px]:hidden\" /><DropdownMenuGroup className=\"min-[641px]:hidden\">\n <DropdownMenuItem aria-label={labels.save} data-testid={`${testId}-save-menu`} disabled={saveItem.disabled} onClick={save} className=\"min-h-8 max-sm:min-h-10 pointer-coarse:min-h-10\"><ActionMenuItemContent item={saveItem} testId={`${testId}-save-menu`} /></DropdownMenuItem>\n </DropdownMenuGroup></>}\n </>}\n mainControl={<>\n {mode === 'rich' && <MarkdownFormattingControl type=\"button\" aria-label={labels.formatting} title={labels.formatting} aria-pressed={toolbar === 'pinned'} data-testid={`${testId}-formatting`} onClick={() => setFormatting(toolbar === 'pinned' ? 'selection' : 'pinned')} />}\n {manualSave && <span className=\"max-[641px]:hidden\"><Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.save} title={labels.save} data-testid={`${testId}-save`} disabled={saveItem.disabled} onClick={save}><SaveIcon data-icon=\"inline-start\" aria-hidden=\"true\" /></Button></span>}\n </>}\n controls={controls}>\n <MarkdownEditor components={editorControls} controller={controller} title={title} header={false} autosave={autosave} onAutosaveChange={registerAutosave} onSaveResult={report} formattingToolbar={toolbar} mode={mode} onModeChange={setRequested} onRichSafety={setSafety}\n {...(placeholder === undefined ? {} : { placeholder })} {...(resolveImage ? { resolveImage } : {})} {...(onMountedTools ? { onMountedTools } : {})} className=\"boring-markdown-editor\" />\n </ViewerFrame>;\n}\n",
75
- "type": "registry:component",
76
- "target": "components/viewers/markdown-pane.tsx"
77
- },
78
- {
79
- "path": "registry/viewers/media.ts",
80
- "content": "import { useEffect, useMemo, useState } from 'react';\n\n/** What a read-only media viewer shows: bytes or a Blob (the viewer owns the object URL it makes) or a URL the host owns. */\nexport interface MediaSource {\n readonly bytes?: Uint8Array | ArrayBuffer;\n readonly blob?: Blob;\n readonly url?: string;\n}\n\n/** A Blob for the source, or `undefined` when the host gave a URL (or nothing). */\nexport function mediaBlob(source: MediaSource, mediaType: string): Blob | undefined {\n if (source.blob) return source.blob;\n if (source.bytes) return new Blob([source.bytes as BlobPart], { type: mediaType });\n return undefined;\n}\n\n/** An object URL for the source, revoked when the source changes or the viewer unmounts. A host `url` is passed through untouched. */\nexport function useMediaUrl(source: MediaSource, mediaType: string): { url: string | undefined; size: number | undefined; blob: Blob | undefined } {\n const blob = useMemo(() => mediaBlob(source, mediaType), [source.blob, source.bytes, mediaType]); // eslint-disable-line react-hooks/exhaustive-deps\n const [made, setMade] = useState<string>();\n useEffect(() => {\n if (!blob) { setMade(undefined); return; }\n const url = URL.createObjectURL(blob);\n setMade(url);\n return () => { URL.revokeObjectURL(url); setMade(current => current === url ? undefined : current); };\n }, [blob]);\n return { url: blob ? made : source.url, size: blob?.size, blob };\n}\n\nexport function formatBytes(size: number): string {\n if (size < 1024) return `${size} B`;\n if (size < 1024 * 1024) return `${(size / 1024).toFixed(size < 10240 ? 1 : 0)} KB`;\n return `${(size / 1024 / 1024).toFixed(1)} MB`;\n}\n",
81
- "type": "registry:lib",
82
- "target": "components/viewers/media.ts"
83
- },
84
- {
85
- "path": "registry/viewers/menu.tsx",
86
- "content": "'use client';\n\nimport { useState } from 'react';\nimport { HistoryIcon } from 'lucide-react';\nimport type { ReactNode } from 'react';\nimport { Button } from '@/components/ui/button';\nimport { DropdownMenu, DropdownMenuTrigger } from '@/components/ui/dropdown-menu';\nimport { ActionMenuContent, useMenuPortal } from '../button/actions';\nimport type { MenuItem } from '../button/actions';\nimport { versionHistoryItems } from '../version-history/version-history';\nimport type { VersionHistoryEntry } from '../version-history/version-history';\nimport { useViewerText } from './viewer-window';\n\nexport type ViewerMenuItem = MenuItem;\nexport interface ViewerActionsProps {\n readonly label: string;\n readonly icon: ReactNode;\n readonly items: readonly MenuItem[];\n readonly testId?: string;\n readonly align?: 'start' | 'end';\n readonly className?: string;\n readonly children?: ReactNode;\n readonly onOpenChange?: (open: boolean) => void;\n}\nexport type ViewerVersion = VersionHistoryEntry;\n\n/** The consumer's shadcn Base UI dropdown supplies positioning, dismissal and keyboard navigation. */\nexport function ViewerActions({ label, icon, items, testId = 'viewer-menu', align = 'end', className, children, onOpenChange }: ViewerActionsProps) {\n const portal = useMenuPortal();\n return <DropdownMenu onOpenChange={open => onOpenChange?.(open)}>\n <DropdownMenuTrigger render={<Button ref={portal.ref} variant=\"ghost\" size=\"icon-sm\" aria-label={label} title={label} data-testid={testId} className={className}>{icon}</Button>} />\n <ActionMenuContent label={label} testId={testId} items={items} align={align} container={portal.container}>{children}</ActionMenuContent>\n </DropdownMenu>;\n}\n\n/** Saved versions are view-only choices. Current is the displayed revision, not necessarily the latest one. */\nexport function ViewerVersions({ versions, current, onSelect, testId = 'viewer-versions', label }: {\n readonly versions: readonly ViewerVersion[];\n readonly current: string;\n readonly onSelect: (id: string) => void;\n readonly testId?: string;\n readonly label?: string;\n}) {\n const { labels } = useViewerText();\n const [now, setNow] = useState(Date.now);\n return <ViewerActions label={label ?? labels.versionHistory} testId={testId} align=\"end\" icon={<HistoryIcon data-icon=\"inline-start\" aria-hidden=\"true\" />} onOpenChange={open => { if (open) setNow(Date.now()); }}\n items={versionHistoryItems({ versions, current, onSelect, labels, now, testId })} />;\n}\n",
87
- "type": "registry:component",
88
- "target": "components/viewers/menu.tsx"
89
- },
90
- {
91
- "path": "registry/viewers/pdf-pane.tsx",
92
- "content": "'use client';\n\nimport { useEffect, useMemo, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { DownloadIcon, FileTextIcon } from 'lucide-react';\nimport { Badge } from '@/components/ui/badge';\nimport { Button } from '@/components/ui/button';\nimport { downloadFile } from './download';\nimport { ZoomControls } from './image-pane';\nimport { formatBytes, useMediaUrl } from './media';\nimport { PdfPages } from './pdf-pages';\nimport type { MediaSource } from './media';\nimport { ViewerFrame } from './viewer-frame';\nimport type { ViewerShare, ViewerStatus } from './viewer-frame';\nimport { useViewerText } from './viewer-window';\n\nexport interface PdfPaneProps extends MediaSource {\n readonly name: string;\n readonly subtitle?: ReactNode;\n readonly status?: ViewerStatus;\n readonly target?: unknown;\n readonly revision?: string;\n /** Leading header content, before the title. */\n readonly headerStart?: ReactNode;\n readonly controls?: ReactNode;\n readonly onRefresh?: () => unknown;\n readonly onShare?: ViewerShare;\n readonly onOpenInNewTab?: () => unknown;\n readonly onClose?: () => unknown;\n /** `false` draws the pages with pdf.js (for a host that knows its browser cannot render PDFs), `true` uses the browser's own viewer. Defaults to the browser's own report. */\n readonly inline?: boolean;\n /** How the browser's viewer opens the page: `width` (default) fits the page to the pane's width, `page` fits the whole page, `none` leaves the browser's own zoom. */\n readonly fit?: 'width' | 'page' | 'none';\n readonly testId?: string;\n /** Overrides the title's `data-testid` (default `<testId>-title`). */\n readonly titleTestId?: string;\n readonly className?: string;\n}\n\n/** The browser reports whether it has a built-in PDF viewer. Unknown (older browsers) is treated as yes: the frame is tried. */\nexport function browserShowsPdf(): boolean {\n const nav = globalThis.navigator as (Navigator & { pdfViewerEnabled?: boolean }) | undefined;\n return nav?.pdfViewerEnabled !== false;\n}\n\nconst STEPS = [0.5, 0.75, 1, 1.25, 1.5, 2, 3, 4];\n\n/**\n * A read-only PDF viewer in the standard frame, as in boring-ui v2: the browser's own PDF viewer in a frame over an object URL\n * (so its page navigation, zoom, search and print come with it). Where the browser cannot render PDFs inline (phones), pdf.js, loaded\n * only then, draws the pages with zoom and a page indicator; if that fails too (a damaged or password-protected file, no worker), a clear\n * message with Download and Open in new tab replaces it.\n */\nexport function PdfPane({ name, bytes, blob, url: hostUrl, subtitle, status, target, revision, headerStart, controls, onRefresh, onShare, onOpenInNewTab, onClose, inline, fit = 'width', testId = 'viewer', titleTestId, className }: PdfPaneProps) {\n const source = useMemo<MediaSource>(() => ({ ...(bytes ? { bytes } : {}), ...(blob ? { blob } : {}), ...(hostUrl ? { url: hostUrl } : {}) }), [bytes, blob, hostUrl]);\n const { url, size, blob: made } = useMediaUrl(source, 'application/pdf');\n // The browser's PDF viewer does not run in a sandboxed frame, so the frame is unsandboxed and loads only a blob typed application/pdf (a host `url` is the host's own).\n const isPdf = !made || made.type === 'application/pdf';\n const canShow = isPdf && (inline ?? browserShowsPdf());\n const { labels } = useViewerText();\n const downloadName = name.split('/').pop() || 'document.pdf';\n const download = () => { if (made) downloadFile(downloadName, made, 'application/pdf'); else if (url) { const link = Object.assign(document.createElement('a'), { href: url, download: downloadName }); document.body.append(link); link.click(); link.remove(); } };\n const open = onOpenInNewTab ?? (url ? () => { window.open(url, '_blank', 'noopener,noreferrer'); } : undefined);\n const [zoom, setZoom] = useState(1);\n const [pages, setPages] = useState<{ readonly count: number; readonly current: number }>();\n const [failed, setFailed] = useState(false);\n useEffect(() => { setPages(undefined); setFailed(false); }, [url]);\n const step = (direction: 1 | -1) => setZoom(now => (direction > 0 ? STEPS.find(value => value > now) : [...STEPS].reverse().find(value => value < now)) ?? now);\n const drawn = Boolean(url) && isPdf && !canShow && !failed;\n return <ViewerFrame title={downloadName} subtitle={<>{subtitle}{subtitle && size !== undefined && <span aria-hidden=\"true\">·</span>}{['PDF', size !== undefined && formatBytes(size)].filter(Boolean).join(' · ')}</>} status={status} target={target} revision={revision} headerStart={headerStart} testId={testId} {...(titleTestId ? { titleTestId } : {})} className={className}\n onRefresh={onRefresh} onShare={onShare} onDownload={url ? download : undefined} onOpenInNewTab={open} onClose={onClose}\n controls={drawn && pages ? <><ZoomControls testId={testId} percent={`${Math.round(zoom * 100)}%`} ready onStep={step} onFit={() => setZoom(1)} />{controls}</> : controls}>\n <div data-testid={`${testId}-stage`} data-pdf={url ? (canShow ? 'inline' : drawn ? 'pages' : 'fallback') : 'loading'} className=\"boring-viewer-stage relative flex min-h-0 flex-1\">\n {!url ? <p role=\"status\" className=\"m-auto p-6 text-sm text-muted-foreground\">{labels.loading}</p>\n : canShow ? <iframe src={fit === 'none' ? url : `${url}#view=${fit === 'page' ? 'Fit' : 'FitH'}`} title={`${downloadName} (PDF)`} data-testid={`${testId}-frame-pdf`} className=\"size-full min-h-0 flex-1 bg-background\" />\n : drawn ? <><PdfPages key={url} url={url} name={labels.pdfDocument(downloadName)} zoom={zoom} testId={testId} onLoad={count => setPages({ count, current: 1 })}\n onPage={current => setPages(now => now && now.current !== current ? { ...now, current } : now)} onError={() => setFailed(true)}\n onKey={key => { if (key === '+' || key === '=') step(1); else if (key === '-') step(-1); else if (key === '0') setZoom(1); }} />\n {pages && <Badge variant=\"secondary\" data-testid={`${testId}-pdf-page-indicator`} aria-live=\"polite\" className=\"pointer-events-none absolute bottom-3 left-1/2 -translate-x-1/2\">{labels.pdfPage(pages.current, pages.count)}</Badge>}</>\n : <div role=\"alert\" data-testid={`${testId}-pdf-fallback`} className=\"m-auto flex max-w-sm flex-col items-center gap-3 p-6 text-center\">\n <span className=\"grid size-12 place-items-center bg-muted text-muted-foreground\"><FileTextIcon className=\"size-6\" aria-hidden=\"true\" /></span>\n <p className=\"m-0 text-sm font-medium\">{labels.pdfUnsupported}</p>\n <p className=\"m-0 text-xs text-muted-foreground\">{labels.pdfHint(downloadName, Boolean(open))}</p>\n <div className=\"flex flex-wrap justify-center gap-2\">\n <Button variant=\"default\" size=\"sm\" data-testid={`${testId}-pdf-download`} onClick={download}><DownloadIcon data-icon=\"inline-start\" aria-hidden=\"true\" />{labels.download}</Button>\n {open && <Button variant=\"outline\" size=\"sm\" onClick={() => open()}>{labels.openInNewTab}</Button>}\n </div>\n </div>}\n </div>\n </ViewerFrame>;\n}\n",
93
- "type": "registry:component",
94
- "target": "components/viewers/pdf-pane.tsx"
95
- },
96
- {
97
- "path": "registry/viewers/pdf-pages.tsx",
98
- "content": "'use client';\n\nimport { useEffect, useRef, useState } from 'react';\nimport type { PDFDocumentProxy, PDFWorker, RenderTask } from 'pdfjs-dist';\nimport { useViewerText } from './viewer-window';\n\n/** Device pixels per CSS pixel are capped (3) and so is one page's canvas (about 8 megapixels) so a zoomed page stays within a phone's memory. */\nconst MAX_RATIO = 3;\nconst MAX_PIXELS = 8 * 1024 * 1024;\n\n/**\n * pdf.js's own worker, from the package's worker entry. `new Worker(new URL(<package path>, import.meta.url))` is the form Vite and\n * webpack (Next) bundle as a worker; a host bundler that leaves the URL as is (esbuild) serves that path itself. Resolves once the\n * worker reports ready and rejects when it cannot load, so a missing worker shows the Download fallback instead of a spinner forever.\n */\nfunction startWorker(signal: AbortSignal): Promise<Worker> {\n return new Promise((resolve, reject) => {\n const worker = new Worker(new URL('pdfjs-dist/build/pdf.worker.min.mjs', import.meta.url), { type: 'module' });\n const fail = () => { worker.terminate(); reject(new Error('The PDF worker could not start.')); };\n worker.addEventListener('message', () => { signal.removeEventListener('abort', fail); resolve(worker); }, { once: true });\n worker.addEventListener('error', fail, { once: true });\n signal.addEventListener('abort', fail, { once: true });\n });\n}\n\n/** Opens the document with pdf.js (loaded on demand) in its own worker. `close` destroys the document and stops the worker. */\nasync function openPdf(url: string, signal: AbortSignal): Promise<{ readonly document: PDFDocumentProxy; readonly close: () => void }> {\n const started = startWorker(signal);\n let worker: PDFWorker | undefined, task: { destroy(): Promise<void> } | undefined;\n const close = () => { void task?.destroy(); worker?.destroy(); void started.then(port => port.terminate(), () => {}); };\n try {\n const [pdfjs, port] = await Promise.all([import('pdfjs-dist'), started]);\n if (signal.aborted) throw signal.reason;\n worker = pdfjs.PDFWorker.create({ port });\n const loading = pdfjs.getDocument({ url, worker, verbosity: 0 });\n task = loading;\n const document = await loading.promise;\n if (signal.aborted) throw signal.reason;\n return { document, close };\n } catch (error) { close(); throw error; }\n}\n\nexport interface PdfPagesProps {\n readonly url: string;\n readonly name: string;\n /** 1 fits the page to the pane's width. */\n readonly zoom: number;\n readonly testId: string;\n readonly onLoad: (pages: number) => void;\n readonly onPage: (page: number) => void;\n readonly onError: (error: unknown) => void;\n readonly onKey?: (key: string) => void;\n}\n\n/**\n * The pages of a PDF drawn by pdf.js, for a browser without a PDF viewer of its own (phones): stacked, fit to the pane's width times\n * `zoom`, rendered only near the viewport, crisp at the device's pixel ratio. Unmounting cancels rendering and destroys the document.\n */\nexport function PdfPages({ url, name, zoom, testId, onLoad, onPage, onError, onKey }: PdfPagesProps) {\n const { labels } = useViewerText();\n const scroller = useRef<HTMLDivElement>(null);\n const [document, setDocument] = useState<PDFDocumentProxy>();\n const [ratio, setRatio] = useState(Math.SQRT2);\n const [width, setWidth] = useState(0);\n const latest = useRef({ onLoad, onError });\n latest.current = { onLoad, onError };\n useEffect(() => {\n const abort = new AbortController();\n let close: (() => void) | undefined;\n openPdf(url, abort.signal).then(async opened => {\n close = opened.close;\n if (abort.signal.aborted) { close(); return; }\n const first = (await opened.document.getPage(1)).getViewport({ scale: 1 });\n if (abort.signal.aborted) return;\n setRatio(first.height / first.width);\n setDocument(opened.document);\n latest.current.onLoad(opened.document.numPages);\n }).catch(error => { if (!abort.signal.aborted) latest.current.onError(error); });\n return () => { abort.abort(); close?.(); };\n }, [url]);\n useEffect(() => {\n const box = scroller.current;\n if (!box) return;\n const measure = () => setWidth(Math.max(0, box.clientWidth - 16));\n measure();\n if (typeof ResizeObserver === 'undefined') return;\n const observer = new ResizeObserver(measure);\n observer.observe(box);\n return () => observer.disconnect();\n }, []);\n const scrolled = () => {\n const box = scroller.current;\n if (!box) return;\n const line = box.scrollTop + box.clientHeight / 3;\n let page = 1;\n for (const element of box.querySelectorAll<HTMLElement>('[data-page]')) if (element.offsetTop <= line) page = Number(element.dataset.page);\n onPage(page);\n };\n const pageWidth = Math.floor(width * zoom);\n return <div ref={scroller} data-testid={`${testId}-pdf-pages`} aria-label={name} role=\"document\" tabIndex={0} onScroll={scrolled}\n onKeyDown={event => onKey?.(event.key)} className=\"relative min-h-0 min-w-0 flex-1 overflow-auto p-2\">\n {!document ? <p role=\"status\" className=\"m-0 p-6 text-center text-sm text-muted-foreground\">{labels.loading}</p>\n : <div className=\"flex w-max min-w-full flex-col items-center gap-2\">\n {Array.from({ length: document.numPages }, (_, index) => <PdfPage key={index} document={document} number={index + 1} width={pageWidth} ratio={ratio} root={scroller.current} testId={testId} />)}\n </div>}\n </div>;\n}\n\nfunction PdfPage({ document, number, width, ratio, root, testId }: { readonly document: PDFDocumentProxy; readonly number: number; readonly width: number; readonly ratio: number; readonly root: Element | null; readonly testId: string }) {\n const box = useRef<HTMLDivElement>(null);\n const canvas = useRef<HTMLCanvasElement>(null);\n const [near, setNear] = useState(false);\n const [own, setOwn] = useState<number>();\n const [rendered, setRendered] = useState(false);\n useEffect(() => {\n const element = box.current;\n if (!element || typeof IntersectionObserver === 'undefined') { setNear(true); return; }\n const observer = new IntersectionObserver(entries => { if (entries.some(entry => entry.isIntersecting)) setNear(true); }, { root, rootMargin: '100% 0px' });\n observer.observe(element);\n return () => observer.disconnect();\n }, [root]);\n useEffect(() => {\n const element = canvas.current;\n if (!near || !width || !element) return;\n let cancelled = false, task: RenderTask | undefined;\n void document.getPage(number).then(page => {\n if (cancelled) return;\n const base = page.getViewport({ scale: 1 });\n setOwn(base.height / base.width);\n const viewport = page.getViewport({ scale: width / base.width });\n const scale = Math.min(globalThis.devicePixelRatio || 1, MAX_RATIO, Math.sqrt(MAX_PIXELS / (viewport.width * viewport.height)));\n element.width = Math.floor(viewport.width * scale);\n element.height = Math.floor(viewport.height * scale);\n task = page.render({ canvas: element, viewport, ...(scale === 1 ? {} : { transform: [scale, 0, 0, scale, 0, 0] }) });\n return task.promise.then(() => { if (!cancelled) setRendered(true); });\n }).catch(() => {});\n return () => { cancelled = true; task?.cancel(); };\n }, [document, number, width, near]);\n return <div ref={box} data-page={number} data-testid={`${testId}-pdf-page`} data-rendered={rendered || undefined} className=\"relative shrink-0 bg-background outline outline-1 outline-border\"\n style={{ width, height: Math.round(width * (own ?? ratio)) }}>\n <canvas ref={canvas} data-testid={`${testId}-pdf-canvas`} className=\"absolute inset-0 size-full\" />\n </div>;\n}\n",
99
- "type": "registry:component",
100
- "target": "components/viewers/pdf-pages.tsx"
101
- },
102
- {
103
- "path": "registry/viewers/share.ts",
104
- "content": "import { copyText } from '../utils/utils';\n\n/** What the frame hands the host when the person presses Share. `target` and `revision` are the host's own identifiers for what is shown. */\nexport interface ViewerShareRequest {\n readonly title: string;\n readonly target: unknown;\n readonly revision: string | undefined;\n}\n\n/** `shared`: the system share sheet took it. `copied`: a link is on the clipboard (the frame says so). Nothing: the host confirmed it its own way. */\nexport type ViewerShareResult = 'shared' | 'copied' | undefined | void;\nexport type ViewerShare = (request: ViewerShareRequest) => ViewerShareResult | Promise<ViewerShareResult>;\n\n/**\n * The ready-made Share action. `link` turns the request into the URL a person can open to see the same thing. Uses the Web Share\n * API where the browser offers it (phones), otherwise copies the link (see `copyText`) and lets the frame show \"Link copied\". A cancelled share\n * sheet is not an error.\n */\nexport function createLinkShare(link: (request: ViewerShareRequest) => string): ViewerShare {\n return async request => {\n const url = link(request);\n const nav = globalThis.navigator;\n if (typeof nav?.share === 'function' && (typeof nav.canShare !== 'function' || nav.canShare({ title: request.title, url }))) {\n try { await nav.share({ title: request.title, url }); return 'shared'; }\n catch (error) { if ((error as { name?: string })?.name === 'AbortError') return undefined; /* fall back to the clipboard */ }\n }\n // Clipboard API, then execCommand; when neither works copyText throws ManualCopyError and the frame shows the link selected.\n await copyText(url);\n return 'copied';\n };\n}\n",
105
- "type": "registry:lib",
106
- "target": "components/viewers/share.ts"
107
- },
108
- {
109
- "path": "registry/viewers/viewer-frame.tsx",
110
- "content": "'use client';\n\nimport { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';\nimport type { ReactNode } from 'react';\nimport { ArrowLeftIcon, CheckIcon, CircleIcon, CopyIcon, DownloadIcon, ExternalLinkIcon, RefreshCwIcon } from 'lucide-react';\nimport { Button } from '@/components/ui/button';\nimport { Toggle } from '@/components/ui/toggle';\nimport { ToggleGroup, ToggleGroupItem } from '@/components/ui/toggle-group';\nimport { Badge } from '@/components/ui/badge';\nimport { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';\nimport { Textarea } from '@/components/ui/textarea';\nimport { DropdownMenuSeparator } from '@/components/ui/dropdown-menu';\nimport { ActionButton, actionMenuItem, headerActions, menuActions } from '../button/actions';\nimport type { BlockAction } from '../button/actions';\nimport { ViewerActions } from './menu';\nimport type { ViewerMenuItem } from './menu';\nimport { useViewerText, useViewerWindow } from './viewer-window';\nimport type { ViewerIcons, ViewerLabels } from './viewer-window';\nimport { cn } from '../utils/utils';\nimport type { ManualCopyError } from '../utils/utils';\nimport type { ViewerShare } from './share';\n\nexport type { ViewerShare, ViewerShareRequest, ViewerShareResult } from './share';\nexport { ViewerWindowProvider, defaultViewerIcons, defaultViewerLabels, useViewerText } from './viewer-window';\nexport type { ViewerIcons, ViewerLabels, ViewerWindow } from './viewer-window';\n\nexport type ViewerTone = 'neutral' | 'success' | 'warning' | 'danger';\n/**\n * `kind` says what the status is whatever its (translated) label: the bar hides a plain `saved` (unless `showSavedStatus`) and shows\n * `read-only` as a fact. The bar shows a dot in the default shadcn roles: `success` primary, `warning` and `neutral` muted-foreground, `danger` destructive. Only a\n * `danger` status also shows its words, because the person must act on it; the others keep the label in the tooltip and for screen readers.\n */\nexport interface ViewerStatus { readonly label: string; readonly tone?: ViewerTone; readonly kind?: 'saved' | 'read-only' | undefined }\n\nexport interface ViewerFrameProps {\n /** What is shown, for example the file name. */\n readonly title: string;\n /** Type, version, path, size: short facts under the title. */\n readonly subtitle?: ReactNode;\n /** Saved, Unsaved, Saving, Changed elsewhere, Read-only. */\n readonly status?: ViewerStatus | undefined;\n /** Keep a quiet saved acknowledgement visible, for autosaving editors. */\n readonly showSavedStatus?: boolean | undefined;\n /** Opaque identifiers handed to `onShare` so the host can build a link to this exact thing. */\n readonly target?: unknown;\n readonly revision?: string | undefined;\n /** Leading header content, for example Back before the file title. */\n readonly headerStart?: ReactNode;\n /** Viewer-specific controls that stay visible: a mode toggle, Save while there are edits, zoom steps, a version switcher when there are several. */\n readonly controls?: ReactNode;\n /**\n * The one control that matters most here (Comment on a version to try, for example), kept in the bar at every width. With the compact\n * header a phone folds `controls` into the \"…\" menu; this one stays beside it, so the main action is one tap away. Test id `<testId>-main`.\n */\n readonly mainControl?: ReactNode;\n /** Viewer-specific secondary actions, listed in the \"…\" menu after the standard ones. */\n readonly menu?: readonly ViewerMenuItem[];\n /** Viewer-specific native dropdown groups, before the standard secondary actions. */\n readonly menuContent?: ReactNode;\n /**\n * The host's actions for this bar, after the window's (`ViewerWindow.actions`): `header` ones as buttons beside Share, `menu` ones at the\n * end of the \"…\" menu. Test ids `<testId>-<id>`.\n */\n readonly actions?: readonly BlockAction[] | undefined;\n /** This bar's words and icons, over the window's and the defaults (`defaultViewerLabels`, `defaultViewerIcons`). */\n readonly labels?: Partial<ViewerLabels> | undefined;\n readonly icons?: Partial<ViewerIcons> | undefined;\n /** Each standard action appears only when its handler is supplied. Share is always visible; Reload, Copy, Download and Open in new tab live in the \"…\" menu. */\n readonly onRefresh?: () => unknown;\n readonly onShare?: ViewerShare;\n readonly onCopy?: () => unknown;\n readonly onDownload?: () => unknown;\n readonly onOpenInNewTab?: () => unknown;\n readonly onClose?: () => unknown;\n /** Prefix of the `data-testid` of the bar and its actions (`viewer-share`, `viewer-more`, and `viewer-refresh` for the menu's Reload, ...). */\n readonly testId?: string;\n readonly titleTestId?: string;\n /** Quiet one-row bar with secondary actions in the menu. False retains the former visible Share/fullscreen/close layout. */\n readonly compactHeader?: boolean;\n readonly className?: string;\n readonly children?: ReactNode;\n}\n\n\n/** Narrow panes drop optional controls. */\nconst TIGHT_WIDTH = { touch: 440, pointer: 340 };\nconst touchScreen = () => typeof matchMedia === 'function' && matchMedia('(max-width: 639px), (pointer: coarse)').matches;\n\n/** How much room the bar has, for a pane that wants to drop optional controls (the zoom percentage, for example) on a narrow panel. */\nexport interface ViewerBarSpace { readonly tight: boolean }\nconst ViewerBarContext = createContext<ViewerBarSpace>({ tight: false });\nexport const useViewerBar = (): ViewerBarSpace => useContext(ViewerBarContext);\nconst NOTICE_MS = 2600;\n\n/**\n * One choice of a mode toggle, for example Rich | Source. Icon only: `label` is the accessible name and the tooltip, `text` the short word\n * for hosts that want it (shown when there is no icon). A disabled choice shows `reason` as its tooltip.\n */\nexport interface ViewerToggleOption<T extends string> { readonly id: T; readonly label: string; readonly text: string; readonly icon?: ReactNode; readonly disabled?: boolean; readonly reason?: string | undefined; readonly testId?: string }\n\n/** A segmented control over the consumer's outlined ToggleGroup: the pressed segment is filled with a full-contrast icon, the others muted. */\nexport function ViewerToggle<T extends string>({ label, value, options, onChange }: { readonly label: string; readonly value: T; readonly options: readonly ViewerToggleOption<T>[]; readonly onChange: (id: T) => void }) {\n return <ToggleGroup aria-label={label} variant=\"outline\" size=\"sm\" spacing={1} value={[value]} onValueChange={values => {\n const selected = options.find(option => option.id === values[0] && !option.disabled);\n if (selected && selected.id !== value) onChange(selected.id);\n }}>\n {options.map(option => <ToggleGroupItem key={option.id} value={option.id} aria-label={option.label} title={option.disabled && option.reason ? option.reason : option.label} disabled={option.disabled}\n className=\"disabled:pointer-events-auto disabled:cursor-not-allowed\" data-testid={option.testId} data-mode={option.id}>\n <span className={cn('inline-flex items-center', value !== option.id && 'text-muted-foreground')}>{option.icon ?? option.text}</span></ToggleGroupItem>)}\n </ToggleGroup>;\n}\n\n/** The copy helper throws this when the browser allowed no automatic copy at all; the person copies by hand instead. */\nconst needsManualCopy = (error: unknown): error is ManualCopyError => (error as { name?: string } | null)?.name === 'ManualCopyError' && typeof (error as { text?: unknown }).text === 'string';\n\n/** Last resort for Copy and Share: the text, already selected, so Ctrl/Cmd+C or the long-press menu finishes the job. */\nfunction ManualCopy({ testId, link, text, onClose, labels }: { readonly testId: string; readonly link: boolean; readonly text: string; readonly onClose: () => void; readonly labels: ViewerLabels }) {\n const field = useRef<HTMLTextAreaElement>(null);\n return <Dialog open onOpenChange={open => { if (!open) onClose(); }}>\n <DialogContent showCloseButton={false} className=\"boring-viewer\" data-testid={`${testId}-manual-copy`} initialFocus={field}>\n <DialogHeader><DialogTitle>{labels.manualCopy(link)}</DialogTitle></DialogHeader>\n <Textarea ref={field} readOnly rows={Math.min(6, Math.max(2, Math.ceil(text.length / 48)))} value={text} data-testid={`${testId}-manual-copy-text`} onFocus={event => event.currentTarget.select()} />\n <div className=\"flex justify-end\"><Button variant=\"ghost\" size=\"sm\" data-testid={`${testId}-manual-copy-close`} onClick={onClose}>{labels.done}</Button></div>\n </DialogContent>\n </Dialog>;\n}\n\n/** Dot colours: default shadcn roles only. */\nconst DOTS: Record<ViewerTone, string> = {\n neutral: 'fill-muted-foreground',\n success: 'fill-primary',\n warning: 'fill-muted-foreground',\n danger: 'fill-destructive',\n};\n\n/** The save status as a coloured dot; the label is the tooltip and the screen-reader text, and is shown only when the person must act (`danger`). */\nfunction StatusMark({ status, testId }: { readonly status: ViewerStatus; readonly testId: string }) {\n const tone = status.tone ?? 'neutral';\n return <span role=\"status\" aria-label={status.label} title={status.label} data-testid={`${testId}-status`} data-tone={tone} data-kind={status.kind}\n className=\"inline-flex h-6 min-w-6 shrink-0 cursor-default items-center justify-center gap-1.5 text-xs\">\n <CircleIcon aria-hidden=\"true\" strokeWidth={0} className={cn('size-2 shrink-0', DOTS[tone])} />\n <span data-testid={`${testId}-status-text`} className={tone === 'danger' ? 'max-w-48 truncate text-destructive' : 'sr-only'}>{status.label}</span>\n </span>;\n}\n\n/** The one top bar of every viewer, always a single row: title and facts, viewer controls, a status dot when something needs attention, Share, full screen, Close and the \"…\" menu. */\nexport function ViewerFrame({ title, subtitle, status, showSavedStatus = false, target, revision, headerStart, controls, mainControl, menu, menuContent, actions, labels: ownLabels, icons: ownIcons, onRefresh, onShare, onCopy, onDownload, onOpenInNewTab, onClose, testId = 'viewer', titleTestId, compactHeader = true, className, children }: ViewerFrameProps) {\n const bar = useRef<HTMLElement>(null);\n const [space, setSpace] = useState<ViewerBarSpace>({ tight: false });\n const [busy, setBusy] = useState<'refresh' | 'share' | undefined>();\n const [notice, setNotice] = useState<{ readonly text: string; readonly tone: ViewerTone } | undefined>();\n const [copied, setCopied] = useState(false);\n const [manual, setManual] = useState<{ readonly text: string; readonly link: boolean } | undefined>();\n const host = useViewerWindow();\n const { labels, icons } = useViewerText(ownLabels, ownIcons);\n const mounted = useRef(true);\n useEffect(() => { mounted.current = true; return () => { mounted.current = false; }; }, []);\n useLayoutEffect(() => {\n const element = bar.current;\n if (!element || typeof ResizeObserver === 'undefined') return;\n const measure = () => {\n const width = element.getBoundingClientRect().width;\n const next = { tight: width > 0 && width < (touchScreen() ? TIGHT_WIDTH.touch : TIGHT_WIDTH.pointer) };\n setSpace(now => now.tight === next.tight ? now : next);\n };\n measure();\n const observer = new ResizeObserver(measure);\n observer.observe(element);\n return () => observer.disconnect();\n }, [host?.renderHeader]);\n useEffect(() => {\n if (!notice) return;\n const timer = setTimeout(() => setNotice(undefined), NOTICE_MS);\n return () => clearTimeout(timer);\n }, [notice]);\n\n const guarded = useCallback(async (kind: 'refresh' | 'share', run: () => unknown, failed: string) => {\n setBusy(kind);\n setNotice(undefined);\n try { return await run(); }\n catch (error) { if (mounted.current) { if (needsManualCopy(error)) setManual({ text: error.text, link: kind === 'share' }); else setNotice({ text: failed, tone: 'danger' }); } return undefined; }\n finally { if (mounted.current) setBusy(undefined); }\n }, []);\n const refresh = () => { if (onRefresh) void guarded('refresh', onRefresh, labels.refreshFailed); };\n const share = () => {\n if (!onShare) return;\n void guarded('share', () => onShare({ title, target, revision }), labels.shareFailed).then(result => {\n if (!mounted.current) return;\n if (result === 'copied') setNotice({ text: labels.linkCopied, tone: 'success' });\n else if (result === 'shared') setNotice({ text: labels.shared, tone: 'success' });\n });\n };\n const copy = () => {\n void Promise.resolve().then(onCopy).then(() => { if (mounted.current) { setCopied(true); setNotice({ text: labels.copied, tone: 'success' }); setTimeout(() => { if (mounted.current) setCopied(false); }, 1500); } })\n .catch(error => { if (!mounted.current) return; if (needsManualCopy(error)) setManual({ text: error.text, link: false }); else setNotice({ text: labels.copyFailed, tone: 'danger' }); });\n };\n const run = (action: (() => unknown) | undefined) => { void Promise.resolve().then(action).catch(() => { if (mounted.current) setNotice({ text: labels.actionFailed, tone: 'danger' }); }); };\n // The host's actions: the window's (every viewer in the panel), then this frame's. Each runs through `run`, so a failure shows as a notice.\n const hostActions = [...host?.actions ?? [], ...actions ?? []].map(action => ({ ...action, onSelect: () => run(action.onSelect) }));\n\n const reading = status?.kind === 'read-only' || status?.label === labels.readOnly;\n const menuItems: ViewerMenuItem[] = ([\n ...(compactHeader && onShare ? [{ id: 'share', label: labels.share, icon: <icons.share className=\"size-4\" />, onSelect: share }] : []),\n ...(compactHeader && host?.onFullscreenChange ? [{ id: 'fullscreen', label: host.fullscreen ? labels.exitFullscreen : labels.enterFullscreen, icon: <icons.enterFullscreen className=\"size-4\" />, onSelect: () => host.onFullscreenChange!(!host.fullscreen) }] : []),\n ...(onRefresh ? [{ id: 'refresh', separatorBefore: true, label: labels.reload, icon: <RefreshCwIcon className=\"size-4\" />, disabled: busy === 'refresh', onSelect: refresh }] : []),\n ...(onCopy ? [{ id: 'copy', label: labels.copy, icon: copied ? <CheckIcon className=\"size-4\" /> : <CopyIcon className=\"size-4\" />, onSelect: copy }] : []),\n ...(onDownload ? [{ id: 'download', label: labels.download, icon: <DownloadIcon className=\"size-4\" />, onSelect: () => run(onDownload) }] : []),\n ...(onOpenInNewTab ? [{ id: 'open', label: labels.openInNewTab, icon: <ExternalLinkIcon className=\"size-4\" />, onSelect: () => run(onOpenInNewTab) }] : []),\n ...(menu ?? []).map((item, index) => ({ ...item, separatorBefore: index === 0 || item.separatorBefore })),\n ...menuActions(hostActions).map((action, index) => ({ ...actionMenuItem(action, testId), separatorBefore: index === 0 })),\n ] as ViewerMenuItem[]).map(entry => ({ ...entry, testId: entry.testId ?? `${testId}-${entry.id}` }));\n\n const stacked = !compactHeader && host?.headerLayout === 'stacked';\n const toolbar = controls && <div data-testid={`${testId}-controls`} className={cn('flex shrink-0 items-center gap-1', compactHeader && 'max-[641px]:hidden', stacked && 'flex-wrap px-3 py-2')}>{controls}</div>;\n const titlebar = <>\n {compactHeader && !headerStart && onClose && <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.close} title={labels.close} data-testid={`${testId}-close`} onClick={() => run(onClose)}><ArrowLeftIcon data-icon=\"inline-start\" className=\"min-[641px]:hidden\" aria-hidden=\"true\" /><icons.close data-icon=\"inline-start\" className=\"hidden min-[641px]:block\" aria-hidden=\"true\" /></Button>}\n {headerStart}\n <div className=\"group/title relative min-w-0 flex-1 basis-0 text-left\">\n <h2 data-testid={titleTestId ?? `${testId}-title`} title={title} className=\"m-0 truncate text-sm leading-5 font-semibold tracking-tight\">{title}</h2>\n {(subtitle || reading) && <p data-testid={`${testId}-subtitle`} className={cn('m-0 flex min-w-0 items-center gap-x-1.5 text-xs leading-4 whitespace-nowrap text-muted-foreground', compactHeader ? 'hidden group-hover/title:flex max-[641px]:hidden' : 'overflow-hidden')}>{subtitle}{subtitle && reading && <span aria-hidden=\"true\">·</span>}{reading && <span data-testid={`${testId}-readonly`}>{labels.readOnly}</span>}</p>}\n </div>\n {!stacked && toolbar}\n {mainControl && <div data-testid={`${testId}-main`} className=\"flex shrink-0 items-center\">{mainControl}</div>}\n {status && !reading && (showSavedStatus || status.kind !== 'saved' && status.label !== labels.saved) && <StatusMark status={status} testId={testId} />}\n <div className=\"flex shrink-0 items-center gap-0.5\">\n {headerActions(hostActions).map(action => <ActionButton key={action.id} action={action} testId={testId} size=\"icon-sm\" />)}\n {!compactHeader && onShare && <Button variant=\"ghost\" size=\"icon-sm\" aria-label={labels.share} title={labels.share} data-testid={`${testId}-share`} disabled={busy === 'share'} onClick={share}><icons.share data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>}\n {(menuItems.length > 0 || controls || menuContent) && <ViewerActions label={labels.moreActions} testId={`${testId}-more`} icon={<icons.more data-icon=\"inline-start\" aria-hidden=\"true\" />} items={menuItems}>{menuContent}{menuContent && menuItems.length > 0 && <DropdownMenuSeparator />}{compactHeader && controls && <div className=\"boring-viewer flex flex-wrap items-center gap-2 p-2 min-[641px]:hidden\">{controls}</div>}</ViewerActions>}\n {!compactHeader && host?.onFullscreenChange && <Toggle size=\"sm\" aria-label={host.fullscreen ? labels.exitFullscreen : labels.enterFullscreen} title={host.fullscreen ? labels.exitFullscreen : labels.enterFullscreen} data-testid={`${testId}-fullscreen`} pressed={host.fullscreen === true}\n onPressedChange={pressed => host.onFullscreenChange!(pressed)}>{host.fullscreen ? <icons.exitFullscreen data-icon=\"inline-start\" aria-hidden=\"true\" /> : <icons.enterFullscreen data-icon=\"inline-start\" aria-hidden=\"true\" />}</Toggle>}\n {(!compactHeader || headerStart) && onClose && <Button variant=\"ghost\" size=\"icon-sm\" className={compactHeader ? 'max-[641px]:hidden' : undefined} aria-label={labels.close} title={labels.close} data-testid={`${testId}-close`} onClick={() => run(onClose)}><icons.close data-icon=\"inline-start\" aria-hidden=\"true\" /></Button>}\n </div>\n </>;\n const header = <header ref={bar} data-testid={`${testId}-bar`} data-layout={stacked ? 'stacked' : undefined}\n className={cn('relative flex shrink-0', stacked ? 'flex-col' : 'h-13 flex-nowrap items-center gap-x-1.5 px-2 sm:px-3')}>\n {stacked ? <><div data-testid={`${testId}-titlebar`} className=\"flex min-h-14 min-w-0 items-center gap-x-1.5 px-3 py-1.5\">{titlebar}</div>{toolbar}</> : titlebar}\n {notice && <Badge role=\"status\" aria-live=\"polite\" data-testid={`${testId}-notice`} data-tone={notice.tone} variant={notice.tone === 'danger' ? 'destructive' : 'secondary'}>{notice.text}</Badge>}\n {manual && <ManualCopy testId={testId} link={manual.link} text={manual.text} labels={labels} onClose={() => setManual(undefined)} />}\n </header>;\n return <ViewerBarContext.Provider value={space}>\n <section data-boring=\"viewer-frame\" data-testid={`${testId}-frame`} data-tight={space.tight || undefined}\n className={cn('boring-viewer isolate flex h-full min-h-0 min-w-0 flex-col bg-background text-foreground', className)}>\n {host?.renderHeader ? host.renderHeader(header) : header}\n <div data-testid={`${testId}-body`} className=\"flex min-h-0 min-w-0 flex-1 flex-col\">{children}</div>\n </section>\n </ViewerBarContext.Provider>;\n}\n",
111
- "type": "registry:component",
112
- "target": "components/viewers/viewer-frame.tsx"
113
- },
114
- {
115
- "path": "registry/viewers/viewer-window.ts",
116
- "content": "/*\n * The window a viewer sits in, and the viewers' words and icons as plain data. A host passes a partial `labels` (and `icons`) object to\n * `ViewerWindowProvider` (every viewer below reads it) or to one `ViewerFrame`; what it leaves out keeps the default below.\n */\nimport { createContext, useContext, useMemo } from 'react';\nimport { EllipsisIcon, Maximize2Icon, Minimize2Icon, Share2Icon, XIcon } from 'lucide-react';\nimport type { ReactNode } from 'react';\nimport type { MarkdownEditorProps } from '@hachej/boring-ui-kit/markdown-editor';\nimport type { BlockAction, BlockIcon } from '../button/actions';\nimport { withDefaults } from '../utils/utils';\nimport { defaultVersionHistoryLabels } from '../version-history/version-history';\n\nexport const defaultViewerLabels = {\n share: 'Share',\n moreActions: 'More actions',\n reload: 'Reload',\n copy: 'Copy',\n download: 'Download',\n openInNewTab: 'Open in new tab',\n enterFullscreen: 'Enter full screen',\n exitFullscreen: 'Exit full screen',\n close: 'Close',\n readOnly: 'Read-only',\n refreshFailed: 'Refresh failed',\n shareFailed: 'Could not share',\n linkCopied: 'Link copied',\n shared: 'Shared',\n copied: 'Copied',\n copyFailed: 'Could not copy',\n actionFailed: 'The action failed',\n /** Shown when the browser allowed no automatic copy: `link` is true for Share, false for Copy. */\n manualCopy: (link: boolean) => `This browser blocked automatic copying. Copy the ${link ? 'link' : 'text'} below.`,\n done: 'Done',\n ...defaultVersionHistoryLabels,\n versionViewOnly: 'Viewing an older version. Restore is not available in this viewer.',\n latest: 'Latest',\n loading: 'Loading…',\n // Save status\n saved: 'Saved',\n unsaved: 'Unsaved',\n saving: 'Saving…',\n saveUnconfirmed: 'Save unconfirmed',\n changedElsewhere: 'Changed elsewhere',\n closed: 'Closed',\n save: 'Save',\n checkSave: 'Check save outcome',\n abandon: 'Abandon and refresh, keeping my draft',\n discardLocal: 'Discard local edits',\n // Modes\n view: 'View',\n preview: 'Preview',\n source: 'Source',\n htmlPreview: 'HTML preview',\n htmlSource: 'HTML source',\n editorMode: 'Editor mode',\n rich: 'Rich',\n richText: 'Rich text',\n markdownSource: 'Markdown source',\n formatted: 'Formatted',\n markdown: 'Markdown',\n formatting: 'Formatting',\n showOutline: 'Show outline',\n /** Tooltip of the disabled Text mode: what the rich editor could not keep exactly. */\n richUnavailable: (reasons: string) => `Formatted is off: this document contains ${reasons}, which it could not keep exactly`,\n document: 'Document',\n // Images and PDFs\n zoom: 'Zoom',\n zoomIn: 'Zoom in',\n zoomOut: 'Zoom out',\n zoomLevel: (percent: string) => `Zoom ${percent}, fit to view`,\n fitToView: 'Fit to view',\n actualSize: 'Actual size',\n noPreview: 'No preview available. You can still download this file.',\n imageUnreadable: 'This file could not be read as an image.',\n imageUnsupported: (mediaType: string) => `This image type (${mediaType || 'unknown'}) cannot be shown here. You can still download it.`,\n imageStage: (name: string) => `${name} image`,\n pdfUnsupported: 'This browser cannot show PDFs inline.',\n pdfDocument: (name: string) => `${name} pages`,\n /** The page indicator of the drawn pages, for example `3 / 12`. */\n pdfPage: (current: number, count: number) => `${current} / ${count}`,\n pdfHint: (name: string, canOpen: boolean) => `Download ${name} to read it in a PDF app${canOpen ? ', or open it in a new tab' : ''}.`,\n notSaved: (reason: string) => `Not saved: ${reason}`,\n saveFailedReason: 'the save failed',\n changedElsewhereReason: 'changed elsewhere',\n operationFailed: 'The document operation failed. Your source has been retained.',\n};\nexport type ViewerLabels = typeof defaultViewerLabels;\n\nexport const defaultViewerIcons = {\n share: Share2Icon as BlockIcon,\n more: EllipsisIcon as BlockIcon,\n close: XIcon as BlockIcon,\n enterFullscreen: Maximize2Icon as BlockIcon,\n exitFullscreen: Minimize2Icon as BlockIcon,\n};\nexport type ViewerIcons = typeof defaultViewerIcons;\n\n/**\n * The window a viewer sits in, when the host lays viewers out in a panel (pi-app's `AgentWorkspace`, the ambient window). With\n * `onFullscreenChange`, every `ViewerFrame` below shows an \"Enter full screen\" / \"Exit full screen\" button; `actions` adds the host's\n * actions to every viewer bar (`header` ones as buttons, `menu` ones in its \"…\" menu, test ids `<frame testId>-<id>`); `labels` and\n * `icons` reach every viewer below. Without a provider nothing changes.\n */\nexport interface ViewerWindow {\n /** Markdown autosave policy for every pane below. Defaults to true, with a 1200ms idle delay. */\n readonly autosave?: MarkdownEditorProps['autosave'];\n /** Place the existing bar in a host-owned shared header (for example with createPortal). Default: above the viewer body. */\n readonly renderHeader?: ((header: ReactNode) => ReactNode) | undefined;\n /** `stacked` keeps the title and window actions above a separate content toolbar. Default: `inline`, one row. */\n readonly headerLayout?: 'inline' | 'stacked' | undefined;\n readonly fullscreen?: boolean | undefined;\n readonly onFullscreenChange?: ((next: boolean) => void) | undefined;\n readonly actions?: readonly BlockAction[] | undefined;\n readonly labels?: Partial<ViewerLabels> | undefined;\n readonly icons?: Partial<ViewerIcons> | undefined;\n}\nconst ViewerWindowContext = createContext<ViewerWindow | undefined>(undefined);\nexport const ViewerWindowProvider = ViewerWindowContext.Provider;\nexport const useViewerWindow = (): ViewerWindow | undefined => useContext(ViewerWindowContext);\n\n/** The viewers' labels and icons: the defaults, then the window's, then the frame's own. */\nexport function useViewerText(labels?: Partial<ViewerLabels>, icons?: Partial<ViewerIcons>): { readonly labels: ViewerLabels; readonly icons: ViewerIcons } {\n const host = useViewerWindow();\n return useMemo(() => ({ labels: withDefaults(defaultViewerLabels, host?.labels, labels), icons: withDefaults(defaultViewerIcons, host?.icons, icons) }), [host?.labels, host?.icons, labels, icons]);\n}\n",
117
- "type": "registry:lib",
118
- "target": "components/viewers/viewer-window.ts"
119
- },
120
- {
121
- "path": "registry/viewers/viewer-labels-fr.ts",
122
- "content": "/* The viewers' words in French, the `locale=\"fr\"` base of `AgentWorkspace`'s viewers. Typed as `ViewerLabels`, so a key added in English must be added here too. */\nimport type { ViewerLabels } from './viewer-window';\nimport { frenchVersionHistoryLabels } from '../version-history/version-history';\n\nexport const frenchViewerLabels: ViewerLabels = {\n share: 'Partager',\n moreActions: 'Plus d’actions',\n reload: 'Recharger',\n copy: 'Copier',\n download: 'Télécharger',\n openInNewTab: 'Ouvrir dans un nouvel onglet',\n enterFullscreen: 'Plein écran',\n exitFullscreen: 'Quitter le plein écran',\n close: 'Fermer',\n readOnly: 'Lecture seule',\n refreshFailed: 'Échec de l’actualisation',\n shareFailed: 'Partage impossible',\n linkCopied: 'Lien copié',\n shared: 'Partagé',\n copied: 'Copié',\n copyFailed: 'Copie impossible',\n actionFailed: 'L’action a échoué',\n manualCopy: link => `Ce navigateur a bloqué la copie automatique. Copiez ${link ? 'le lien' : 'le texte'} ci-dessous.`,\n done: 'Terminé',\n ...frenchVersionHistoryLabels,\n versionViewOnly: 'Ancienne version en lecture seule. La restauration n’est pas disponible dans cette vue.',\n latest: 'Dernière version',\n loading: 'Chargement…',\n saved: 'Enregistré',\n unsaved: 'Non enregistré',\n saving: 'Enregistrement',\n saveUnconfirmed: 'Enregistrement non confirmé',\n changedElsewhere: 'Modifié ailleurs',\n closed: 'Fermé',\n save: 'Enregistrer',\n checkSave: 'Vérifier l’enregistrement',\n abandon: 'Abandonner et actualiser, en gardant mon brouillon',\n discardLocal: 'Annuler mes modifications',\n view: 'Affichage',\n preview: 'Aperçu',\n source: 'Source',\n htmlPreview: 'Aperçu HTML',\n htmlSource: 'Source HTML',\n editorMode: 'Mode d’édition',\n rich: 'Mise en forme',\n richText: 'Texte mis en forme',\n markdownSource: 'Source Markdown',\n formatted: 'Mis en forme',\n markdown: 'Markdown',\n formatting: 'Mise en forme',\n showOutline: 'Afficher le plan',\n richUnavailable: reasons => `Texte mis en forme indisponible : ce document contient ${reasons}, qu’il ne pourrait pas conserver à l’identique`,\n document: 'Document',\n zoom: 'Zoom',\n zoomIn: 'Agrandir',\n zoomOut: 'Réduire',\n zoomLevel: percent => `Zoom ${percent}, ajuster à la vue`,\n fitToView: 'Ajuster à la vue',\n actualSize: 'Taille réelle',\n noPreview: 'Aucun aperçu disponible. Vous pouvez toujours télécharger ce fichier.',\n imageUnreadable: 'Ce fichier n’a pas pu être lu comme une image.',\n imageUnsupported: mediaType => `Ce type d’image (${mediaType || 'inconnu'}) ne peut pas être affiché ici. Vous pouvez toujours le télécharger.`,\n imageStage: name => `Image ${name}`,\n pdfUnsupported: 'Ce navigateur ne peut pas afficher les PDF directement.',\n pdfDocument: name => `Pages de ${name}`,\n pdfPage: (current, count) => `${current} / ${count}`,\n pdfHint: (name, canOpen) => `Téléchargez ${name} pour le lire dans une application PDF${canOpen ? ', ou ouvrez-le dans un nouvel onglet' : ''}.`,\n notSaved: reason => `Non enregistré : ${reason}`,\n saveFailedReason: 'l’enregistrement a échoué',\n changedElsewhereReason: 'modifié ailleurs',\n operationFailed: 'L’opération sur le document a échoué. Votre source est conservée.',\n};\n",
123
- "type": "registry:lib",
124
- "target": "components/viewers/viewer-labels-fr.ts"
125
- }
7
+ "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.13/r/viewer-frame.json",
8
+ "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.13/r/viewer-markdown.json",
9
+ "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.13/r/viewer-html.json",
10
+ "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.13/r/viewer-image.json",
11
+ "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.13/r/viewer-pdf.json",
12
+ "https://cdn.jsdelivr.net/npm/@hachej/boring-ui-kit@0.4.13/r/viewer-code.json"
126
13
  ],
127
- "css": {
128
- "@layer utilities": {
129
- "@media (max-width: 640px), (pointer: coarse)": {
130
- ".boring-viewer :is([data-slot=\"button\"], [data-slot=\"toggle\"], [data-slot=\"toggle-group-item\"], [class~=\"group/button\"], [class~=\"group/toggle\"])": {
131
- "min-height": "2.75rem",
132
- "min-width": "2.75rem"
133
- },
134
- ".boring-viewer.boring-markdown-bubble :is([data-slot=\"button\"], [data-slot=\"toggle\"])": {
135
- "min-height": "2.75rem",
136
- "min-width": "2.75rem"
137
- }
138
- }
139
- },
140
- "@layer components": {
141
- ".boring-viewer .boring-markdown-editor, .boring-viewer .boring-html-pane": {
142
- "display": "flex",
143
- "flex-direction": "column",
144
- "flex": "1 1 auto",
145
- "min-height": "0",
146
- "min-width": "0",
147
- "container-type": "inline-size"
148
- },
149
- ".boring-viewer .boring-markdown-surface": {
150
- "flex": "1 1 auto",
151
- "min-height": "0",
152
- "overflow": "auto"
153
- },
154
- ".boring-viewer .boring-markdown-toolbar, .boring-viewer.boring-markdown-bubble": {
155
- "display": "flex",
156
- "flex": "none",
157
- "align-items": "center",
158
- "gap": "0.25rem",
159
- "max-width": "calc(100vw - 24px)"
160
- },
161
- ".boring-viewer .boring-markdown-toolbar": {
162
- "padding": "0.375rem 1.5rem 0.375rem 0.75rem",
163
- "overflow-x": "auto",
164
- "scrollbar-width": "none",
165
- "mask-image": "linear-gradient(to right, black calc(100% - 2rem), transparent)"
166
- },
167
- ".boring-viewer .boring-markdown-toolbar::-webkit-scrollbar": {
168
- "display": "none"
169
- },
170
- ".boring-viewer .boring-markdown-tool": {
171
- "flex": "none"
172
- },
173
- ".boring-viewer .boring-markdown-separator": {
174
- "flex": "none",
175
- "margin-inline": "0.25rem"
176
- },
177
- ".boring-viewer span.boring-markdown-separator": {
178
- "width": "0.5rem",
179
- "margin": "0"
180
- },
181
- ".boring-viewer .boring-markdown-icon": {
182
- "display": "block"
183
- },
184
- ".boring-viewer .boring-markdown-link, .boring-viewer .boring-markdown-alert, .boring-viewer .boring-markdown-proposal, .boring-viewer [data-boring=\"text-draft-controls\"]": {
185
- "display": "flex",
186
- "flex": "none",
187
- "flex-wrap": "wrap",
188
- "align-items": "center",
189
- "gap": "0.5rem",
190
- "padding": "0.5rem 0.75rem"
191
- },
192
- ".boring-viewer .boring-markdown-link [data-slot=\"input\"]": {
193
- "flex": "1 1 14rem",
194
- "min-width": "0"
195
- },
196
- ".boring-viewer .boring-markdown-notice": {
197
- "margin": "0.75rem"
198
- },
199
- ".boring-viewer .boring-markdown-proposal :is(h3, details)": {
200
- "flex": "1 1 100%",
201
- "min-width": "0"
202
- },
203
- ".boring-viewer .boring-markdown-proposal pre": {
204
- "max-height": "12rem",
205
- "overflow": "auto",
206
- "white-space": "pre-wrap"
207
- },
208
- ".boring-viewer .boring-markdown-editor nav[aria-label=\"Document outline\"]": {
209
- "display": "none"
210
- },
211
- "@container (min-width: 46rem)": {
212
- ".boring-viewer .boring-markdown-editor nav[aria-label=\"Document outline\"]": {
213
- "display": "block",
214
- "flex": "none",
215
- "overflow-x": "auto",
216
- "padding": "0.375rem 0.75rem"
217
- },
218
- ".boring-viewer .boring-markdown-editor nav[aria-label=\"Document outline\"] ol": {
219
- "display": "flex",
220
- "gap": "0.25rem",
221
- "list-style": "none",
222
- "margin": "0",
223
- "padding": "0"
224
- }
225
- },
226
- ".boring-viewer .boring-markdown-source, .boring-viewer .boring-html-viewer__source": {
227
- "flex": "1 1 auto",
228
- "width": "100%",
229
- "min-height": "0",
230
- "resize": "none"
231
- },
232
- ".boring-viewer .boring-markdown-content": {
233
- "max-width": "68ch",
234
- "min-height": "100%",
235
- "margin": "0 auto",
236
- "padding": "1.5rem 1.5rem 3rem",
237
- "overflow-wrap": "anywhere",
238
- "color": "var(--foreground)",
239
- "font-size": "var(--text-base)",
240
- "line-height": "var(--leading-relaxed)"
241
- },
242
- ".boring-viewer .boring-markdown-content:focus": {
243
- "outline": "none"
244
- },
245
- ".boring-viewer .boring-markdown-content > :first-child": {
246
- "margin-top": "0"
247
- },
248
- ".boring-viewer .boring-markdown-content p": {
249
- "margin": "0.75rem 0"
250
- },
251
- ".boring-viewer .boring-markdown-content p.is-editor-empty:first-child::before": {
252
- "content": "attr(data-placeholder)",
253
- "float": "left",
254
- "height": "0",
255
- "color": "var(--muted-foreground)",
256
- "pointer-events": "none"
257
- },
258
- ".boring-viewer .boring-markdown-content :is(h1, h2, h3, h4, h5, h6)": {
259
- "font-weight": "var(--font-weight-semibold)",
260
- "line-height": "var(--leading-tight)"
261
- },
262
- ".boring-viewer .boring-markdown-content h1": {
263
- "margin": "1.75rem 0 0.75rem",
264
- "font-size": "var(--text-2xl)"
265
- },
266
- ".boring-viewer .boring-markdown-content h2": {
267
- "margin": "2rem 0 0.75rem",
268
- "font-size": "var(--text-xl)"
269
- },
270
- ".boring-viewer .boring-markdown-content h3": {
271
- "margin": "1.25rem 0 0.5rem",
272
- "font-size": "var(--text-lg)"
273
- },
274
- ".boring-viewer .boring-markdown-content :is(h4, h5, h6)": {
275
- "margin": "1rem 0 0.4rem",
276
- "font-size": "var(--text-base)"
277
- },
278
- ".boring-viewer .boring-markdown-content :is(ul, ol)": {
279
- "margin": "0.75rem 0",
280
- "padding-left": "1.5rem"
281
- },
282
- ".boring-viewer .boring-markdown-content ul": {
283
- "list-style": "disc"
284
- },
285
- ".boring-viewer .boring-markdown-content ol": {
286
- "list-style": "decimal"
287
- },
288
- ".boring-viewer .boring-markdown-content li": {
289
- "margin": "0.25rem 0"
290
- },
291
- ".boring-viewer .boring-markdown-content li > p": {
292
- "margin": "0"
293
- },
294
- ".boring-viewer .boring-markdown-content ul[data-type=\"taskList\"]": {
295
- "padding-left": "0",
296
- "list-style": "none"
297
- },
298
- ".boring-viewer .boring-markdown-content ul[data-type=\"taskList\"] li": {
299
- "display": "flex",
300
- "align-items": "flex-start",
301
- "gap": "0.5rem"
302
- },
303
- ".boring-viewer .boring-markdown-content ul[data-type=\"taskList\"] li > label": {
304
- "display": "inline-flex",
305
- "flex": "none",
306
- "align-items": "center",
307
- "height": "1.7em",
308
- "margin": "0",
309
- "user-select": "none"
310
- },
311
- ".boring-viewer .boring-markdown-content ul[data-type=\"taskList\"] li > label input[type=\"checkbox\"]": {
312
- "width": "1rem",
313
- "height": "1rem",
314
- "margin": "0",
315
- "accent-color": "var(--primary)",
316
- "cursor": "pointer"
317
- },
318
- ".boring-viewer .boring-markdown-content ul[data-type=\"taskList\"] li > div": {
319
- "flex": "1 1 auto",
320
- "min-width": "0"
321
- },
322
- ".boring-viewer .boring-markdown-content li[data-checked=\"true\"] > div": {
323
- "color": "var(--muted-foreground)",
324
- "text-decoration": "line-through"
325
- },
326
- ".boring-viewer .boring-markdown-content strong": {
327
- "font-weight": "var(--font-weight-semibold)"
328
- },
329
- ".boring-viewer .boring-markdown-content code": {
330
- "padding": "0.1em 0.35em",
331
- "border-radius": "var(--radius-sm)",
332
- "background": "var(--muted)",
333
- "font-family": "var(--font-mono)",
334
- "font-size": "var(--text-sm)"
335
- },
336
- ".boring-viewer .boring-markdown-content pre": {
337
- "margin": "1rem 0",
338
- "padding": "0.875rem 1rem",
339
- "overflow-x": "auto",
340
- "border": "var(--default-border-width) solid var(--border)",
341
- "border-radius": "var(--radius-lg)",
342
- "background": "var(--muted)",
343
- "font-family": "var(--font-mono)",
344
- "font-size": "var(--text-sm)"
345
- },
346
- ".boring-viewer .boring-markdown-content pre code": {
347
- "padding": "0",
348
- "background": "transparent",
349
- "font": "inherit"
350
- },
351
- ".boring-viewer .boring-markdown-content blockquote": {
352
- "margin": "1rem 0",
353
- "padding": "0.5rem 1rem",
354
- "border-inline-start": "var(--default-border-width) solid var(--border)",
355
- "color": "var(--muted-foreground)"
356
- },
357
- ".boring-viewer .boring-markdown-content a": {
358
- "color": "var(--foreground)",
359
- "text-decoration": "underline",
360
- "cursor": "text"
361
- },
362
- ".boring-viewer .boring-markdown-content hr": {
363
- "margin": "1.5rem 0",
364
- "border": "0",
365
- "border-top": "var(--default-border-width) solid var(--border)"
366
- },
367
- ".boring-viewer .boring-markdown-content mark": {
368
- "background": "var(--accent)",
369
- "color": "var(--accent-foreground)"
370
- },
371
- ".boring-viewer .boring-markdown-content .tableWrapper": {
372
- "margin": "1rem 0",
373
- "overflow-x": "auto"
374
- },
375
- ".boring-viewer .boring-markdown-content table": {
376
- "width": "100%",
377
- "border-collapse": "collapse",
378
- "font-size": "var(--text-sm)"
379
- },
380
- ".boring-viewer .boring-markdown-content :is(th, td)": {
381
- "min-width": "4rem",
382
- "padding": "0.5rem 0.75rem",
383
- "border": "var(--default-border-width) solid var(--border)",
384
- "text-align": "left",
385
- "vertical-align": "top"
386
- },
387
- ".boring-viewer .boring-markdown-content th": {
388
- "background": "var(--muted)",
389
- "font-weight": "var(--font-weight-semibold)"
390
- },
391
- ".boring-viewer .boring-markdown-content :is(th, td) > p": {
392
- "margin": "0"
393
- },
394
- ".boring-viewer .boring-markdown-content .selectedCell": {
395
- "background": "var(--accent)"
396
- },
397
- ".boring-viewer .boring-markdown-content img": {
398
- "display": "block",
399
- "max-width": "100%",
400
- "height": "auto",
401
- "margin": "1rem 0"
402
- },
403
- ".boring-viewer .boring-markdown-content .boring-markdown-preserved": {
404
- "margin": "0.75rem 0",
405
- "color": "var(--muted-foreground)",
406
- "font-family": "var(--font-mono)",
407
- "font-size": "var(--text-sm)"
408
- },
409
- ".boring-viewer .boring-markdown-content .boring-markdown-preserved small": {
410
- "font-size": "var(--text-xs)"
411
- },
412
- ".boring-viewer .boring-markdown-content .boring-markdown-preserved pre": {
413
- "margin": "0.25rem 0",
414
- "padding": "0.5rem 0.75rem",
415
- "white-space": "pre-wrap",
416
- "overflow-wrap": "anywhere"
417
- },
418
- ".boring-viewer .boring-markdown-content .boring-markdown-preserved-inline": {
419
- "color": "var(--muted-foreground)",
420
- "font-family": "var(--font-mono)",
421
- "font-size": "var(--text-sm)"
422
- },
423
- ".boring-viewer .boring-markdown-content .boring-markdown-image": {
424
- "display": "inline-flex",
425
- "max-width": "100%",
426
- "margin": "0.125rem 0",
427
- "padding": "0.125rem 0.5rem",
428
- "background": "var(--muted)",
429
- "color": "var(--muted-foreground)"
430
- },
431
- ".boring-viewer .boring-html-viewer__preview": {
432
- "display": "flex",
433
- "flex": "1 1 auto",
434
- "flex-direction": "column",
435
- "min-height": "0"
436
- },
437
- ".boring-viewer .boring-html-viewer__preview > p": {
438
- "flex": "none",
439
- "margin": "0",
440
- "padding": "0.375rem 0.75rem"
441
- },
442
- ".boring-viewer .boring-html-viewer__preview > div": {
443
- "display": "flex",
444
- "flex": "1 1 auto",
445
- "min-height": "0"
446
- },
447
- ".boring-viewer .boring-html-viewer__frame": {
448
- "flex": "1 1 auto",
449
- "width": "100%",
450
- "height": "100%",
451
- "min-height": "0",
452
- "border": "0"
453
- },
454
- ".boring-viewer .boring-viewer-checker": {
455
- "background-color": "var(--background)",
456
- "background-image": "linear-gradient(45deg, var(--muted) 25%, transparent 25%, transparent 75%, var(--muted) 75%), linear-gradient(45deg, var(--muted) 25%, transparent 25%, transparent 75%, var(--muted) 75%)",
457
- "background-position": "0 0, 8px 8px",
458
- "background-size": "16px 16px"
459
- },
460
- ".boring-viewer .boring-viewer-stage": {
461
- "overflow": "auto"
462
- },
463
- "@media (max-width: 640px)": {
464
- ".boring-viewer .boring-markdown-content": {
465
- "padding": "1.25rem 1.25rem 3rem"
466
- },
467
- ".boring-viewer .boring-markdown-toolbar": {
468
- "display": "none"
469
- },
470
- ".boring-viewer.boring-markdown-dock": {
471
- "display": "flex",
472
- "align-items": "center",
473
- "gap": "0.125rem",
474
- "overflow-x": "auto",
475
- "scrollbar-width": "none",
476
- "position": "fixed",
477
- "inset-inline": "0",
478
- "z-index": "50",
479
- "padding": "0.25rem 1.5rem 0.25rem 0.5rem",
480
- "padding-bottom": "calc(0.25rem + env(safe-area-inset-bottom, 0px))",
481
- "background": "var(--background)",
482
- "mask-image": "linear-gradient(to right, black calc(100% - 2rem), transparent)"
483
- },
484
- ".boring-viewer.boring-markdown-dock[data-keyboard]": {
485
- "padding-bottom": "0.25rem"
486
- },
487
- ".boring-viewer.boring-markdown-dock > .boring-markdown-dock-rule": {
488
- "position": "absolute",
489
- "inset-inline": "0",
490
- "top": "0"
491
- },
492
- ".boring-viewer [data-boring=\"markdown-editor\"][data-dock] .boring-markdown-content": {
493
- "padding-bottom": "6rem"
494
- }
495
- }
496
- }
497
- },
14
+ "files": [],
498
15
  "type": "registry:component"
499
16
  }