Make PDF Viewer a native feature
- Move the PDF Viewer plugin into src/lib/features/pdf/ with pdfjs-dist 6.4.299 (minified builds). - A static pdf document type marks PDF files and opens them as tabs. The first PDF tab loads the module. - The worker, the character maps, the fonts, and the decoders come from the app. One worker for each tab. - The toolbar uses IconButton and the shared tooltip, with the new zoom-in, zoom-out, fit-width, and rotate icons. - Add THIRD_PARTY_NOTICES.md for PDF.js and xterm. - Update the tests, the menu inventory, the docs, and UI-059.
This commit is contained in:
+6
-3
@@ -209,16 +209,16 @@ Errors of the plugin API stay in English, because they are for plugin developers
|
||||
|
||||
## Native features
|
||||
|
||||
Git, Background, and Terminal are native features: host code with an off switch in **Settings → Features**. They do not use the plugin API.
|
||||
Git, Background, Terminal, and PDF Viewer are native features: host code with an off switch in **Settings → Features**. They do not use the plugin API.
|
||||
|
||||
| Part | File |
|
||||
| --- | --- |
|
||||
| The catalog: ID, old plugin ID, name, views, and commands | `src/lib/features/catalog.ts` |
|
||||
| The catalog: ID, old plugin ID, name, views, commands, and document types | `src/lib/features/catalog.ts` |
|
||||
| The switches: the `features` settings section | `src/lib/features/state.ts` |
|
||||
| The first start: each switch takes the state of the old plugin package, or the default of the feature when `followsPackage` is false | `src/lib/features/migration.ts` and `src-tauri/src/features.rs` |
|
||||
| One import at first need in each window | `src/lib/features/loader.ts` |
|
||||
| A start without a view: the launch rules, also the rule for browser windows | `src/lib/features/launch.ts` |
|
||||
| Views and commands in the workbench | `src/lib/features/session.ts` and `src/lib/plugins/external.ts` |
|
||||
| Views, commands, and document tabs in the workbench | `src/lib/features/session.ts` and `src/lib/plugins/external.ts` |
|
||||
| The feature code | `src/lib/features/<feature>/index.ts` and its components |
|
||||
|
||||
- The catalog holds only static data, so the main bundle stays small. The feature code loads when the user first opens a view, a tab, or a command of the feature. An off feature loads nothing.
|
||||
@@ -227,6 +227,9 @@ Git, Background, and Terminal are native features: host code with an off switch
|
||||
- The first start makes the `background` section from the kept settings of the Background Slideshow plugin and from the old background image. `background_migrate` copies the folder of the old plugin grant to the host only when the host has no folder.
|
||||
- Terminal has no view and no launch rule. `TerminalHost.svelte` puts the panel in the workbench and in the terminal window, and the first use loads the module. `terminalKeys.ts` holds the shortcuts and the Help rows. Settings → Terminal (`TerminalSettings.svelte`) loads no xterm.
|
||||
- `@xterm/xterm` and `@xterm/addon-fit` are host dependencies. `pnpm check:features` keeps them out of the start chunks.
|
||||
- PDF Viewer has a document type and no view. The file tree marks PDF files through `identifyPdf` in `src/lib/features/pdfDocument.ts`, in the main bundle. The first PDF tab loads the module and calls `FeatureInstance.mountDocument`. Each tab reads its file with `workspace_read_bytes` and starts its own PDF.js worker. Closing the tab, or Off, stops the worker.
|
||||
- `pdfjs-dist` is a host dependency. `src/lib/features/pdf/engine.ts` loads the minified build. The worker, the character maps, the standard fonts, and the image decoders are Vite assets of the app, so PDF.js makes no network request. `build.assetsInlineLimit` in `vite.config.js` keeps these files out of the code.
|
||||
- [THIRD_PARTY_NOTICES.md](../THIRD_PARTY_NOTICES.md) gives the version, license, and source of each third-party package that a feature includes. Update it when you add or update such a package.
|
||||
- The first start makes the `terminal` section from the `runestone.terminal` key of `localStorage`, which the Terminal plugin wrote. The old key stays.
|
||||
- Before Terminal goes off, Settings asks `pty_running` for the shells of all windows. Off closes the sessions of each window.
|
||||
- Host code never imports a feature folder statically. `pnpm check:features` builds the app. It fails when a feature module, or a library that only a feature needs, is in a chunk that loads at start.
|
||||
|
||||
Reference in New Issue
Block a user