@triiiceratops/plugin-image-export 1.0.0-rc.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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 David Flood
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,11 @@
1
+ import type { LocaleCatalog } from '@triiiceratops/plugin-sdk';
2
+ /**
3
+ * The plugin's package-owned localization catalog (CONTEXT.md **Active
4
+ * locale**). These strings previously lived in core's `messages/en.json` /
5
+ * `messages/de.json`; migrating the plugin out of core moves them here so the
6
+ * catalog ships with (and evolves with) the plugin, and core's catalogs carry
7
+ * no plugin keys. `en` is the required fallback; a missing key resolves to `en`
8
+ * and then to the key itself. `image_download_result_downloaded` interpolates a
9
+ * `{filename}` param through the locale service.
10
+ */
11
+ export declare const catalog: LocaleCatalog;
@@ -0,0 +1,17 @@
1
+ import type { PluginContext } from '@triiiceratops/plugin-sdk';
2
+ /**
3
+ * Shared key for handing the SDK {@link PluginContext} to the panel through
4
+ * Svelte's component-context map. `getContext` returns a plain (non-reactive)
5
+ * value, which is exactly right here: the activation context is stable for the
6
+ * lifetime of a mount (a fresh mount gets a fresh context), so it must not be
7
+ * treated as reactive state. Cross-runtime viewer reactivity is bridged
8
+ * explicitly inside the panel through `context.viewerState.subscribe` /
9
+ * `context.selectors`, never through the plugin runtime's own reactivity reading
10
+ * core's `$state`.
11
+ */
12
+ export declare const PLUGIN_CONTEXT_KEY: unique symbol;
13
+ /** What `view.mount` passes to the panel through the context map. */
14
+ export interface PanelContext {
15
+ /** The SDK activation context (viewer state, selectors, services). */
16
+ readonly context: PluginContext;
17
+ }
@@ -0,0 +1,46 @@
1
+ import type { ViewerState } from 'triiiceratops';
2
+ import { type ExportSizeOption, type ResolvedCanvasImage } from 'triiiceratops/image-export';
3
+ export type ImageDownloadFormat = 'image/png' | 'image/jpeg';
4
+ export type ImageDownloadMode = 'composite' | 'single' | 'world';
5
+ export declare function buildImageDownloadFilename(canvasLabel: string, mode: ImageDownloadMode, format: ImageDownloadFormat): string;
6
+ type ExportOptions = {
7
+ format?: ImageDownloadFormat;
8
+ getSelectedChoice?: (canvasId: string) => string | undefined;
9
+ };
10
+ /**
11
+ * Every painting image on `canvas` resolved for the "single image" picker
12
+ * and to detect whether "composite canvas" mode has more than one image to
13
+ * offer.
14
+ */
15
+ export declare function getCanvasImageChoices(canvas: any, getSelectedChoice?: (canvasId: string) => string | undefined): ResolvedCanvasImage[];
16
+ /**
17
+ * Resolution options for downloading a single image from a canvas.
18
+ */
19
+ export declare function resolveSingleImageSizeOptions(resolvedImage: ResolvedCanvasImage): Promise<ExportSizeOption[]>;
20
+ /**
21
+ * Resolution options for downloading an entire (possibly composite) canvas.
22
+ * There's no single canonical request URL once there's more than one image,
23
+ * so this always returns a relative Original/50%/25% ladder based on the
24
+ * canvas's own declared IIIF dimensions.
25
+ */
26
+ export declare function resolveCompositeCanvasSizeOptions(canvas: any, getSelectedChoice?: (canvasId: string) => string | undefined): ExportSizeOption[];
27
+ export declare function exportSingleImage(resolvedImage: ResolvedCanvasImage, sizeOption: ExportSizeOption): Promise<Blob>;
28
+ export declare function exportCompositeCanvas(canvas: any, sizeOption: ExportSizeOption, options?: ExportOptions): Promise<Blob>;
29
+ /**
30
+ * Every canvas currently laid out together in the viewer (e.g. both pages of
31
+ * a spread in `paged` mode). Used both to build the "current view" composite
32
+ * and to let "single image" mode target one of several visible canvases
33
+ * instead of only ever the active one.
34
+ */
35
+ export declare function getVisibleCanvasesForDownload(viewerState: ViewerState): any[];
36
+ /**
37
+ * Resolution options for downloading everything currently laid out together
38
+ * in the viewer (e.g. a two-page spread in `paged` viewing mode). Reuses the
39
+ * same layout math OSD itself uses (`getCanvasDisplayLayouts`), so the
40
+ * downloaded image matches what's on screen; there's no single native
41
+ * reference size across canvases, so this offers a relative ladder against
42
+ * the first image's own native width as the reference scale.
43
+ */
44
+ export declare function resolveWorldSizeOptions(viewerState: ViewerState, getSelectedChoice?: (canvasId: string) => string | undefined): ExportSizeOption[];
45
+ export declare function exportCurrentWorld(viewerState: ViewerState, sizeOption: ExportSizeOption, options?: ExportOptions): Promise<Blob>;
46
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type IconDescriptor } from '@triiiceratops/plugin-sdk';
2
+ /** The toolbar icon descriptor (the download glyph), validated by `svgIcon`. */
3
+ export declare const DOWNLOAD_ICON: IconDescriptor;
package/dist/iife.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Self-contained IIFE entry — loadable from a `<script>` tag with no bundler.
3
+ *
4
+ * Loading this bundle bootstraps the `window.Triiiceratops` namespace if absent
5
+ * and registers the plugin factory into `window.Triiiceratops.plugins` (SPEC.md
6
+ * "Browser IIFEs register package-qualified factories in one `window.Triiiceratops`
7
+ * namespace"). It does NOT activate anything — activation is explicit and per
8
+ * viewer:
9
+ *
10
+ * ```html
11
+ * <script src="triiiceratops-element.iife.js"></script>
12
+ * <script src="triiiceratops-plugin-image-export.iife.js"></script>
13
+ * <script>
14
+ * const viewer = document.querySelector('triiiceratops-viewer');
15
+ * viewer.plugins = [
16
+ * window.Triiiceratops.plugins.get('@triiiceratops/plugin-image-export'),
17
+ * ];
18
+ * </script>
19
+ * ```
20
+ *
21
+ * The plugin script may load before OR after core: the registry is bootstrapped
22
+ * order-independently, so both script orders work.
23
+ */
24
+ export {};