@elabs-ai/components-viewer 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +143 -0
- package/dist/chunk-2NQ4RSJ3.js +18 -0
- package/dist/chunk-2NQ4RSJ3.js.map +1 -0
- package/dist/chunk-3U3MESBU.js +21 -0
- package/dist/chunk-3U3MESBU.js.map +1 -0
- package/dist/chunk-4OFQYALG.js +147 -0
- package/dist/chunk-4OFQYALG.js.map +1 -0
- package/dist/chunk-5OMONA2G.js +87 -0
- package/dist/chunk-5OMONA2G.js.map +1 -0
- package/dist/chunk-AORNMH77.js +58 -0
- package/dist/chunk-AORNMH77.js.map +1 -0
- package/dist/chunk-BCF3RWRL.js +18 -0
- package/dist/chunk-BCF3RWRL.js.map +1 -0
- package/dist/chunk-FELIAGKI.js +22 -0
- package/dist/chunk-FELIAGKI.js.map +1 -0
- package/dist/chunk-GGR7BNW4.js +18 -0
- package/dist/chunk-GGR7BNW4.js.map +1 -0
- package/dist/chunk-H3OAON3D.js +22 -0
- package/dist/chunk-H3OAON3D.js.map +1 -0
- package/dist/chunk-HMG2ERXH.js +17 -0
- package/dist/chunk-HMG2ERXH.js.map +1 -0
- package/dist/chunk-KOMDRWOU.js +21 -0
- package/dist/chunk-KOMDRWOU.js.map +1 -0
- package/dist/chunk-NMA57QZ7.js +117 -0
- package/dist/chunk-NMA57QZ7.js.map +1 -0
- package/dist/chunk-RGWDIQJR.js +26 -0
- package/dist/chunk-RGWDIQJR.js.map +1 -0
- package/dist/chunk-SLXRUYT3.js +91 -0
- package/dist/chunk-SLXRUYT3.js.map +1 -0
- package/dist/chunk-UJIJECEF.js +21 -0
- package/dist/chunk-UJIJECEF.js.map +1 -0
- package/dist/chunk-UL43NGUG.js +68 -0
- package/dist/chunk-UL43NGUG.js.map +1 -0
- package/dist/chunk-VO2273Z2.js +55 -0
- package/dist/chunk-VO2273Z2.js.map +1 -0
- package/dist/code-adapter-ADZ4UOGN.js +226 -0
- package/dist/code-adapter-ADZ4UOGN.js.map +1 -0
- package/dist/csv-adapter-6VU3FFVU.js +100 -0
- package/dist/csv-adapter-6VU3FFVU.js.map +1 -0
- package/dist/docx-adapter-5CQDHWTD.js +383 -0
- package/dist/docx-adapter-5CQDHWTD.js.map +1 -0
- package/dist/image-adapter-WOHZR24J.js +132 -0
- package/dist/image-adapter-WOHZR24J.js.map +1 -0
- package/dist/index.d.ts +1353 -0
- package/dist/index.js +1364 -0
- package/dist/index.js.map +1 -0
- package/dist/json-adapter-ZUW5GQHE.js +90 -0
- package/dist/json-adapter-ZUW5GQHE.js.map +1 -0
- package/dist/markdown-adapter-YC6WTBS4.js +214 -0
- package/dist/markdown-adapter-YC6WTBS4.js.map +1 -0
- package/dist/media-adapter-MCTB4GBH.js +78 -0
- package/dist/media-adapter-MCTB4GBH.js.map +1 -0
- package/dist/pdf-adapter-5PMKEXUD.js +424 -0
- package/dist/pdf-adapter-5PMKEXUD.js.map +1 -0
- package/dist/pptx-adapter-6GEQLS2Z.js +351 -0
- package/dist/pptx-adapter-6GEQLS2Z.js.map +1 -0
- package/dist/text-adapter-NFNWB5W3.js +81 -0
- package/dist/text-adapter-NFNWB5W3.js.map +1 -0
- package/dist/xlsx-adapter-CM2Y6AKQ.js +167 -0
- package/dist/xlsx-adapter-CM2Y6AKQ.js.map +1 -0
- package/package.json +103 -0
- package/src/adapters/code/code-adapter.test.tsx +221 -0
- package/src/adapters/code/code-adapter.tsx +272 -0
- package/src/adapters/code/code-language.test.ts +45 -0
- package/src/adapters/code/code-language.ts +100 -0
- package/src/adapters/code/code-manifest.ts +19 -0
- package/src/adapters/code/code-theme.test.ts +46 -0
- package/src/adapters/code/code-theme.ts +99 -0
- package/src/adapters/csv/csv-adapter.test.tsx +169 -0
- package/src/adapters/csv/csv-adapter.tsx +146 -0
- package/src/adapters/csv/csv-manifest.ts +20 -0
- package/src/adapters/docx/docx-adapter.test.tsx +192 -0
- package/src/adapters/docx/docx-adapter.tsx +328 -0
- package/src/adapters/docx/docx-manifest.ts +18 -0
- package/src/adapters/docx/docx-model.test.ts +181 -0
- package/src/adapters/docx/docx-model.ts +294 -0
- package/src/adapters/image/image-adapter.test.tsx +141 -0
- package/src/adapters/image/image-adapter.tsx +191 -0
- package/src/adapters/image/image-manifest.ts +15 -0
- package/src/adapters/index.ts +64 -0
- package/src/adapters/json/json-adapter.test.tsx +77 -0
- package/src/adapters/json/json-adapter.tsx +141 -0
- package/src/adapters/json/json-manifest.ts +11 -0
- package/src/adapters/markdown/markdown-adapter.test.tsx +228 -0
- package/src/adapters/markdown/markdown-adapter.tsx +353 -0
- package/src/adapters/markdown/markdown-manifest.ts +21 -0
- package/src/adapters/markdown/markdown-marks.test.ts +85 -0
- package/src/adapters/markdown/markdown-marks.ts +119 -0
- package/src/adapters/media/media-adapter.test.tsx +79 -0
- package/src/adapters/media/media-adapter.tsx +123 -0
- package/src/adapters/media/media-manifest.ts +17 -0
- package/src/adapters/office-fixture.ts +239 -0
- package/src/adapters/pdf/pdf-adapter.test.tsx +489 -0
- package/src/adapters/pdf/pdf-adapter.tsx +599 -0
- package/src/adapters/pdf/pdf-engine.ts +171 -0
- package/src/adapters/pdf/pdf-fixture.ts +27 -0
- package/src/adapters/pdf/pdf-manifest.ts +30 -0
- package/src/adapters/pdf/pdf-text.test.ts +171 -0
- package/src/adapters/pdf/pdf-text.ts +202 -0
- package/src/adapters/pptx/pptx-adapter.test.tsx +241 -0
- package/src/adapters/pptx/pptx-adapter.tsx +341 -0
- package/src/adapters/pptx/pptx-manifest.ts +19 -0
- package/src/adapters/pptx/pptx-model.test.ts +219 -0
- package/src/adapters/pptx/pptx-model.ts +248 -0
- package/src/adapters/text/text-adapter.test.tsx +125 -0
- package/src/adapters/text/text-adapter.tsx +117 -0
- package/src/adapters/text/text-manifest.ts +19 -0
- package/src/adapters/xlsx/xlsx-adapter.test.tsx +159 -0
- package/src/adapters/xlsx/xlsx-adapter.tsx +250 -0
- package/src/adapters/xlsx/xlsx-manifest.ts +26 -0
- package/src/components/grid-text.test.ts +68 -0
- package/src/components/grid-text.ts +77 -0
- package/src/components/marked-text.tsx +36 -0
- package/src/components/sheet-table.tsx +142 -0
- package/src/core/errors.ts +120 -0
- package/src/core/highlight-marks.test.ts +95 -0
- package/src/core/highlight-marks.ts +95 -0
- package/src/core/highlight-resolve.test.ts +208 -0
- package/src/core/highlight-resolve.ts +191 -0
- package/src/core/highlight.ts +125 -0
- package/src/core/registry.test.ts +172 -0
- package/src/core/registry.ts +188 -0
- package/src/core/scroll-host.ts +42 -0
- package/src/core/text-index.test.ts +95 -0
- package/src/core/text-index.ts +159 -0
- package/src/core/types.ts +285 -0
- package/src/core/use-highlight-scroll.ts +59 -0
- package/src/core/use-page-control.ts +47 -0
- package/src/core/use-paged-scroll.ts +194 -0
- package/src/core/use-viewport-size.ts +54 -0
- package/src/core/zoom.ts +56 -0
- package/src/file-viewer/file-viewer-context.tsx +239 -0
- package/src/file-viewer/file-viewer-find.tsx +204 -0
- package/src/file-viewer/file-viewer-pager.tsx +120 -0
- package/src/file-viewer/file-viewer-zoom.tsx +166 -0
- package/src/file-viewer/file-viewer.stories.tsx +947 -0
- package/src/file-viewer/file-viewer.test.tsx +947 -0
- package/src/file-viewer/file-viewer.tsx +1143 -0
- package/src/index.ts +157 -0
package/src/index.ts
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @elabs-ai/components-viewer — render any file in the browser.
|
|
3
|
+
*
|
|
4
|
+
* A Layer-2 leaf (`tokens → ui → viewer`, ADR 0024). Formats are adapters in a
|
|
5
|
+
* registry: an eager manifest plus a lazy loader, so an app that never opens a
|
|
6
|
+
* spreadsheet never downloads a spreadsheet parser. Every parser is an OPTIONAL
|
|
7
|
+
* peer — install only what you open.
|
|
8
|
+
*
|
|
9
|
+
* The input model (`FileSource`, `resolveFileKind`, `fileIconFor`) lives in
|
|
10
|
+
* `@elabs-ai/components-ui`, so `-ai`, `-viewer` and your own code
|
|
11
|
+
* all speak it.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
// Components
|
|
15
|
+
export {
|
|
16
|
+
FileViewer,
|
|
17
|
+
FileViewerContent,
|
|
18
|
+
FileViewerEmpty,
|
|
19
|
+
FileViewerError,
|
|
20
|
+
FileViewerFrame,
|
|
21
|
+
FileViewerHighlightStatus,
|
|
22
|
+
FileViewerProvider,
|
|
23
|
+
FileViewerSkeleton,
|
|
24
|
+
FileViewerToolbar,
|
|
25
|
+
type FileViewerContentProps,
|
|
26
|
+
type FileViewerFrameProps,
|
|
27
|
+
type FileViewerHighlightStatusProps,
|
|
28
|
+
type FileViewerProps,
|
|
29
|
+
type FileViewerProviderProps,
|
|
30
|
+
type FileViewerToolbarProps,
|
|
31
|
+
} from "./file-viewer/file-viewer";
|
|
32
|
+
export {
|
|
33
|
+
FileViewerFind,
|
|
34
|
+
isFindShortcut,
|
|
35
|
+
type FileViewerFindProps,
|
|
36
|
+
} from "./file-viewer/file-viewer-find";
|
|
37
|
+
// Page, scale and rotation chrome (ADR 0026). Parts, not adapter internals: an
|
|
38
|
+
// app can put any of them in its own header and drive the same provider state.
|
|
39
|
+
export { FileViewerPager, type FileViewerPagerProps } from "./file-viewer/file-viewer-pager";
|
|
40
|
+
export {
|
|
41
|
+
FileViewerRotate,
|
|
42
|
+
FileViewerZoom,
|
|
43
|
+
type FileViewerRotateProps,
|
|
44
|
+
type FileViewerZoomProps,
|
|
45
|
+
} from "./file-viewer/file-viewer-zoom";
|
|
46
|
+
export {
|
|
47
|
+
useFileViewer,
|
|
48
|
+
type FileViewerActions,
|
|
49
|
+
type FileViewerContextValue,
|
|
50
|
+
type FileViewerFindState,
|
|
51
|
+
type FileViewerLoadState,
|
|
52
|
+
type FileViewerState,
|
|
53
|
+
type FileViewerStatus,
|
|
54
|
+
type FileViewerViewState,
|
|
55
|
+
} from "./file-viewer/file-viewer-context";
|
|
56
|
+
// The zoom ladder is shared: the provider steps along it and the shell's control
|
|
57
|
+
// lists it, so a consumer building its own zoom UI reads the same one.
|
|
58
|
+
export { canStepZoom, DEFAULT_ZOOM, isZoomFit, stepZoom, VIEWER_ZOOM_STEPS } from "./core/zoom";
|
|
59
|
+
|
|
60
|
+
// Pointing the viewer at part of a document (ADR 0025). The ADDRESS vocabulary
|
|
61
|
+
// itself is in `@elabs-ai/components-ui` — a citation's producer and
|
|
62
|
+
// this consumer are sibling packages that may not import each other.
|
|
63
|
+
export {
|
|
64
|
+
FIND_MATCH_LIMIT,
|
|
65
|
+
findMatchId,
|
|
66
|
+
isFindMatchId,
|
|
67
|
+
type DocumentHighlight,
|
|
68
|
+
type HighlightMissReason,
|
|
69
|
+
type HighlightSource,
|
|
70
|
+
type HighlightStatus,
|
|
71
|
+
type HighlightSupport,
|
|
72
|
+
type ResolvedHighlight,
|
|
73
|
+
} from "./core/highlight";
|
|
74
|
+
export {
|
|
75
|
+
locateQuote,
|
|
76
|
+
resolveHighlights,
|
|
77
|
+
type HighlightResolveContext,
|
|
78
|
+
} from "./core/highlight-resolve";
|
|
79
|
+
// The PAINT half. Exported for the same reason the index half is: the registry
|
|
80
|
+
// is a documented extension point, so a third-party adapter has to be able to
|
|
81
|
+
// mark a passage the way the shipped ones do. Re-deriving it by hand means
|
|
82
|
+
// re-deriving the merge-vs-`activeIndex` correspondence and the
|
|
83
|
+
// `data-slot`/`data-active` scroll contract, and getting either wrong is silent.
|
|
84
|
+
export { localizeRanges, toMarkRanges, type MarkRanges } from "./core/highlight-marks";
|
|
85
|
+
export {
|
|
86
|
+
useScrollActiveHighlightIntoView,
|
|
87
|
+
ACTIVE_HIGHLIGHT_SELECTOR,
|
|
88
|
+
} from "./core/use-highlight-scroll";
|
|
89
|
+
// `MarkedText` itself stays internal on purpose: it renders a FRAGMENT, so it
|
|
90
|
+
// has no element to carry a `data-slot`, and giving it a wrapper would put a
|
|
91
|
+
// span around every unmarked run of every document to no one's benefit. It is
|
|
92
|
+
// four lines of glue over the two exports above — a third-party adapter composes
|
|
93
|
+
// `localizeRanges` with `MatchHighlight` from `@elabs-ai/components-ui`
|
|
94
|
+
// the same way.
|
|
95
|
+
export {
|
|
96
|
+
chunkOffset,
|
|
97
|
+
createTextIndexBuilder,
|
|
98
|
+
spanAt,
|
|
99
|
+
spansForRange,
|
|
100
|
+
type SpanOverlap,
|
|
101
|
+
type TextIndex,
|
|
102
|
+
type TextIndexBuilder,
|
|
103
|
+
type TextIndexBuilderOptions,
|
|
104
|
+
type TextSpan,
|
|
105
|
+
} from "./core/text-index";
|
|
106
|
+
|
|
107
|
+
// Registry — the extension point
|
|
108
|
+
export { createRegistry, scoreManifest, type ViewerRegistry } from "./core/registry";
|
|
109
|
+
export { createDefaultRegistry } from "./adapters";
|
|
110
|
+
export {
|
|
111
|
+
codeManifest,
|
|
112
|
+
csvManifest,
|
|
113
|
+
docxManifest,
|
|
114
|
+
imageManifest,
|
|
115
|
+
jsonManifest,
|
|
116
|
+
markdownManifest,
|
|
117
|
+
mediaManifest,
|
|
118
|
+
pdfManifest,
|
|
119
|
+
pptxManifest,
|
|
120
|
+
textManifest,
|
|
121
|
+
xlsxManifest,
|
|
122
|
+
} from "./adapters";
|
|
123
|
+
|
|
124
|
+
// PDF engine wiring. Exported so an app behind a strict CSP — or a bundler that
|
|
125
|
+
// cannot see through `new URL(…, import.meta.url)` — can serve the pdf.js worker
|
|
126
|
+
// and font assets itself. Types only; the engine stays behind a dynamic import.
|
|
127
|
+
export {
|
|
128
|
+
configurePdfEngine,
|
|
129
|
+
getPdfEngineConfig,
|
|
130
|
+
type PdfEngineConfig,
|
|
131
|
+
} from "./adapters/pdf/pdf-engine";
|
|
132
|
+
export {
|
|
133
|
+
PROTOCOL_VERSION,
|
|
134
|
+
type AdapterCapabilities,
|
|
135
|
+
type AdapterDocument,
|
|
136
|
+
type AdapterLoadContext,
|
|
137
|
+
type AdapterLoader,
|
|
138
|
+
type AdapterManifest,
|
|
139
|
+
type AdapterModule,
|
|
140
|
+
type AdapterRendererProps,
|
|
141
|
+
type DocumentRotation,
|
|
142
|
+
type FileAdapter,
|
|
143
|
+
type ZoomFit,
|
|
144
|
+
type ZoomLevel,
|
|
145
|
+
} from "./core/types";
|
|
146
|
+
|
|
147
|
+
// Failures — the `code` is the contract, not the message
|
|
148
|
+
export {
|
|
149
|
+
ViewerError,
|
|
150
|
+
isAbort,
|
|
151
|
+
isModuleNotFound,
|
|
152
|
+
isViewerError,
|
|
153
|
+
parserMissingError,
|
|
154
|
+
toViewerError,
|
|
155
|
+
type ViewerErrorCode,
|
|
156
|
+
type ViewerErrorOptions,
|
|
157
|
+
} from "./core/errors";
|