@genomdev/vue
Vue bindings for the Genom viewer
13 exported symbols across 1 entry point
@genomdev/vue
Classes
Functions
Creates a viewer mounted into the given element.
Binds a {@link Viewer} to a Vue component's lifecycle. The viewer is created when `containerRef` receives an element rather than on setup: there is no DOM node before the component mounts, and the viewer needs one in its constructor.
Interfaces
A format: everything one file type needs, in one value. `@genomdev/docx` exports one of these for Word, covering both generations. Nothing else has to know that `.doc` exists.
A format that has not been loaded yet. The descriptor carries the recognition rules, so the registry can decide whether this is the module it needs before paying for it. `load` resolves to the module itself, which in a bundler is a chunk of its own.
One bus, named events, typed payloads. What this replaces: a callback per format, declared in that format's options. `onSelectionChange` existed only for workbooks, nothing equivalent existed for slides, and every framework wrapper had to know which formats had which callbacks. A wrapper subscribing to one bus is the same size whatever the formats are, which is why Angular and Vue cost a hundred lines each. Format-specific events keep their format as a prefix — `sheet:select`, `slide:change` — so a name says where it came from and two formats cannot collide.
An extension that gets the viewer itself. Returns its own teardown.
Type aliases
Either an already-loaded format or a promise of one.
The viewer: bytes in, a document on the screen, and a way to reach it after. The one place that knows the whole path — recognise, load the module, open, mount. The React, Vue and Angular wrappers are adapters over this class, so their behaviour is identical by construction rather than by convention. Three things here are the API rather than the implementation. **Formats are values.** `formats: [docx, pdf]` — eager modules or lazy descriptors, mixed freely. Nothing is registered globally, nothing is discovered, and an application that shows PDFs ships no Word parser. **Options are addressed by format.** `options: { xlsx: { formulaBar: false } }` rather than one flat bag whose keys collide the moment two formats want the same word. **Everything reports through one bus.** `viewer.on('page:change', …)`, and the format-specific events carry their format in the name. Extension has two levels, and the cheap one comes first: `decorate` changes an element a renderer already produced, which survives the renderer being rewritten; `plugins` get the viewer itself, for what nobody anticipated.
Values
A document viewer component for Vue 3. Written with a render function rather than as a single-file component: the package is built with the monorepo's shared toolchain, and this avoids adding a separate SFC compilation step for what amounts to one container element.