@triiiceratops/plugin-pdf-export 1.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/catalog.d.ts +15 -0
- package/dist/contextKey.d.ts +18 -0
- package/dist/exportPdf.d.ts +124 -0
- package/dist/icons.d.ts +9 -0
- package/dist/iife.d.ts +26 -0
- package/dist/iife.js +160 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +4111 -0
- package/dist/plugin.d.ts +31 -0
- package/dist/reportError.d.ts +15 -0
- package/dist/styles.d.ts +16 -0
- package/dist/types.d.ts +28 -0
- package/package.json +71 -0
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The PDF-export plugin, authored entirely on `@triiiceratops/plugin-sdk`.
|
|
3
|
+
*
|
|
4
|
+
* `definePlugin` returns the framework-neutral factory core activates through the
|
|
5
|
+
* structural seam (it carries its own `activate(host)`); core never imports this
|
|
6
|
+
* package, its Svelte runtime, or its `pdf-lib` dependency. The UI is Svelte,
|
|
7
|
+
* mounted through the neutral `view.mount(container, context)` contract and torn
|
|
8
|
+
* down by the returned cleanup. Styles install through the SDK style service
|
|
9
|
+
* (root-aware), strings resolve through the per-viewer locale service over this
|
|
10
|
+
* package's catalog, and the toolbar glyph is a `svgIcon` descriptor.
|
|
11
|
+
*
|
|
12
|
+
* The factory-with-config authoring API is preserved: `createPdfExportPlugin(config)`
|
|
13
|
+
* stays the public entry (a consumer can supply a cover sheet, filename provider,
|
|
14
|
+
* OCR overlay provider, custom image loader, etc.), adapted to `definePlugin`
|
|
15
|
+
* internally. The consumer `config` is captured in the `view.mount` closure and
|
|
16
|
+
* handed to the panel through Svelte's context map, so each activation renders
|
|
17
|
+
* with its own configuration. A preconfigured default (`PdfExportPlugin`) is
|
|
18
|
+
* exported alongside it.
|
|
19
|
+
*
|
|
20
|
+
* The plugin reads the raw OSD viewer (`ViewerState.osdViewer`) to size export
|
|
21
|
+
* requests, so it declares `requiredCapabilities: ['osd@5']`.
|
|
22
|
+
*/
|
|
23
|
+
import { type SdkPlugin } from '@triiiceratops/plugin-sdk';
|
|
24
|
+
import type { PdfExportConfig } from './types';
|
|
25
|
+
/**
|
|
26
|
+
* Create a PDF-export plugin factory with consumer configuration. Activate the
|
|
27
|
+
* returned factory explicitly, per viewer.
|
|
28
|
+
*/
|
|
29
|
+
export declare function createPdfExportPlugin(config?: PdfExportConfig): SdkPlugin;
|
|
30
|
+
/** A preconfigured PDF-export plugin (no consumer config). */
|
|
31
|
+
export declare const PdfExportPlugin: SdkPlugin;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Route an actionable export failure to the host through the structured
|
|
3
|
+
* `pluginerror` channel (ticket 09 shape, {@link PluginError}) instead of the
|
|
4
|
+
* browser console; `node` is the panel's own root element, which lives inside the viewer
|
|
5
|
+
* root, so a bubbling + composed event reaches the host's `pluginerror` listener
|
|
6
|
+
* and escapes the shadow root for a Web Component host — the same delivery core
|
|
7
|
+
* uses for lifecycle failures. The event name is core's `PLUGIN_ERROR_EVENT`
|
|
8
|
+
* (`'pluginerror'`); it is used as a string literal so this framework-neutral
|
|
9
|
+
* bundle never pulls in core's runtime entry.
|
|
10
|
+
*
|
|
11
|
+
* `phase` is `'command'`: the failure occurred while carrying out a user-driven
|
|
12
|
+
* viewer operation (the export action), the closest lifecycle phase in
|
|
13
|
+
* {@link PluginError}. `retry` re-runs that operation.
|
|
14
|
+
*/
|
|
15
|
+
export declare function reportPdfExportError(node: EventTarget, error: unknown, retry: () => void): void;
|
package/dist/styles.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The plugin's package-owned global CSS + its style-service install id, shaped
|
|
3
|
+
* by {@link definePluginStyles} into the `STYLES` / `STYLE_ID` exports the
|
|
4
|
+
* activation installs. Class names are namespaced `tri-pdf-*` since these rules
|
|
5
|
+
* are not Svelte-scoped.
|
|
6
|
+
*
|
|
7
|
+
* Chrome ownership (epic restore-plugin-toolbar-chrome, ticket 05): core owns
|
|
8
|
+
* the toolbar button and the docked panel chrome (surface, sticky header, radius,
|
|
9
|
+
* open/close). These rules therefore style ONLY the panel's content body — no
|
|
10
|
+
* self-positioned toggle, no `position: absolute`, no panel surface/border. The
|
|
11
|
+
* body layout mirrors core's former `PdfExportPanel` embedded look; the range
|
|
12
|
+
* `Select`s and export `Button` are themed by the shared `@triiiceratops/ui`
|
|
13
|
+
* primitives, so no bespoke control styling lives here. Tokens are the current
|
|
14
|
+
* `--tri-` theme variables.
|
|
15
|
+
*/
|
|
16
|
+
export declare const STYLES: string, STYLE_ID: string;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { PdfCanvasOcrOverlayProvider, PdfCoverSheetConfig, PdfExportFilenameProvider, PdfImageLoader, PdfImageRequestConfig, PdfOcrPlacementMode, PdfOcrSizingMode, PdfOcrVisibilityMode } from './exportPdf';
|
|
2
|
+
/**
|
|
3
|
+
* Consumer-facing configuration for the PDF export plugin. This is the same
|
|
4
|
+
* public shape the plugin exposed before it moved to its own package (ticket 16
|
|
5
|
+
* moved it here unchanged), so `createPdfExportPlugin(config)` keeps its
|
|
6
|
+
* factory-with-config authoring contract.
|
|
7
|
+
*/
|
|
8
|
+
export type PdfExportConfig = {
|
|
9
|
+
coverSheet?: PdfCoverSheetConfig;
|
|
10
|
+
filename?: string;
|
|
11
|
+
getFilename?: PdfExportFilenameProvider;
|
|
12
|
+
ocrAnnotationSource?: string;
|
|
13
|
+
getCanvasOcrOverlays?: PdfCanvasOcrOverlayProvider;
|
|
14
|
+
imageRequest?: PdfImageRequestConfig;
|
|
15
|
+
loadImageBlob?: PdfImageLoader;
|
|
16
|
+
ocrPlacementMode?: PdfOcrPlacementMode;
|
|
17
|
+
ocrSizingMode?: PdfOcrSizingMode;
|
|
18
|
+
ocrVisibilityMode?: PdfOcrVisibilityMode;
|
|
19
|
+
onSelectionChange?: PdfExportSelectionChangeHandler;
|
|
20
|
+
};
|
|
21
|
+
/** The current start/end selection reported through `onSelectionChange`. */
|
|
22
|
+
export type PdfExportSelection = {
|
|
23
|
+
startIndex: number | null;
|
|
24
|
+
endIndex: number | null;
|
|
25
|
+
startCanvas: any | null;
|
|
26
|
+
endCanvas: any | null;
|
|
27
|
+
};
|
|
28
|
+
export type PdfExportSelectionChangeHandler = (selection: PdfExportSelection) => void;
|
package/package.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@triiiceratops/plugin-pdf-export",
|
|
3
|
+
"version": "1.0.0-rc.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "PDF export plugin for the triiiceratops IIIF viewer, authored on @triiiceratops/plugin-sdk. Owns its own pdf-lib dependency.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"author": "David Flood",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+https://github.com/d-flood/triiiceratops.git",
|
|
11
|
+
"directory": "packages/plugin-pdf-export"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://d-flood.github.io/triiiceratops/",
|
|
14
|
+
"publishConfig": {
|
|
15
|
+
"access": "public",
|
|
16
|
+
"provenance": true
|
|
17
|
+
},
|
|
18
|
+
"private": false,
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=22"
|
|
21
|
+
},
|
|
22
|
+
"sideEffects": [
|
|
23
|
+
"./dist/iife.js"
|
|
24
|
+
],
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"LICENSE"
|
|
28
|
+
],
|
|
29
|
+
"main": "./dist/index.js",
|
|
30
|
+
"module": "./dist/index.js",
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"exports": {
|
|
33
|
+
".": {
|
|
34
|
+
"types": "./dist/index.d.ts",
|
|
35
|
+
"import": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./iife": "./dist/iife.js"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "pnpm build:esm && pnpm build:iife && pnpm build:types",
|
|
41
|
+
"build:esm": "BUILD_FORMAT=es vite build",
|
|
42
|
+
"build:iife": "BUILD_FORMAT=iife vite build",
|
|
43
|
+
"build:types": "tsc -p tsconfig.build.json",
|
|
44
|
+
"check": "svelte-check --tsconfig ./tsconfig.json --fail-on-warnings && tsc -p tsconfig.build.json --noEmit",
|
|
45
|
+
"test": "vitest run",
|
|
46
|
+
"clean": "rm -rf dist",
|
|
47
|
+
"test:coverage": "vitest run --coverage",
|
|
48
|
+
"lint": "eslint . --max-warnings 0",
|
|
49
|
+
"lint:fix": "eslint . --fix --max-warnings 0"
|
|
50
|
+
},
|
|
51
|
+
"peerDependencies": {
|
|
52
|
+
"triiiceratops": "workspace:^",
|
|
53
|
+
"@triiiceratops/plugin-sdk": "workspace:^"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"pdf-lib": "^1.17.1"
|
|
57
|
+
},
|
|
58
|
+
"devDependencies": {
|
|
59
|
+
"@sveltejs/vite-plugin-svelte": "^6.2.1",
|
|
60
|
+
"@triiiceratops/plugin-sdk": "workspace:*",
|
|
61
|
+
"@triiiceratops/ui": "workspace:*",
|
|
62
|
+
"@vitest/coverage-v8": "4.0.15",
|
|
63
|
+
"happy-dom": "^20.0.11",
|
|
64
|
+
"svelte": "5.45.5",
|
|
65
|
+
"svelte-check": "^4.3.4",
|
|
66
|
+
"triiiceratops": "workspace:*",
|
|
67
|
+
"typescript": "~5.9.3",
|
|
68
|
+
"vite": "^6.0.0",
|
|
69
|
+
"vitest": "^4.0.15"
|
|
70
|
+
}
|
|
71
|
+
}
|