triiiceratops 0.9.12 → 0.10.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/dist/ArrowCounterClockwise-aFffCOKw.js +136 -0
- package/dist/X-DZEgXrJ8.js +877 -0
- package/dist/annotation_tool_point-CZKsj4Nk.js +290 -0
- package/dist/components/AnnotationOverlay.svelte +179 -86
- package/dist/components/DemoHeader.svelte +12 -0
- package/dist/components/LeftFab.svelte +21 -9
- package/dist/components/OSDViewer.svelte +24 -4
- package/dist/components/SearchPanel.svelte +4 -1
- package/dist/components/TriiiceratopsViewer.svelte +114 -47
- package/dist/components/TriiiceratopsViewer.svelte.d.ts +5 -5
- package/dist/components/TriiiceratopsViewerElement.svelte +2 -2
- package/dist/components/TriiiceratopsViewerElement.svelte.d.ts +2 -2
- package/dist/custom-element.d.ts +10 -0
- package/dist/custom-element.js +13 -0
- package/dist/image_filters_reset-BEIf-_QA.js +108 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +0 -1
- package/dist/paraglide/messages/_index.d.ts +31 -0
- package/dist/paraglide/messages/_index.js +32 -1
- package/dist/paraglide/messages/annotation_editor_add_content.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_add_content.js +34 -0
- package/dist/paraglide/messages/annotation_editor_cancel.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_cancel.js +34 -0
- package/dist/paraglide/messages/annotation_editor_create_mode.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_create_mode.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete_message.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete_message.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete_title.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete_title.js +34 -0
- package/dist/paraglide/messages/annotation_editor_delete_tooltip.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_delete_tooltip.js +34 -0
- package/dist/paraglide/messages/annotation_editor_edit_mode.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_edit_mode.js +34 -0
- package/dist/paraglide/messages/annotation_editor_edit_section.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_edit_section.js +34 -0
- package/dist/paraglide/messages/annotation_editor_instruction_create.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_instruction_create.js +34 -0
- package/dist/paraglide/messages/annotation_editor_instruction_edit.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_instruction_edit.js +34 -0
- package/dist/paraglide/messages/annotation_editor_link_placeholder.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_link_placeholder.js +34 -0
- package/dist/paraglide/messages/annotation_editor_redo.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_redo.js +34 -0
- package/dist/paraglide/messages/annotation_editor_save.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_save.js +34 -0
- package/dist/paraglide/messages/annotation_editor_tag_placeholder.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_tag_placeholder.js +34 -0
- package/dist/paraglide/messages/annotation_editor_text_placeholder.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_text_placeholder.js +34 -0
- package/dist/paraglide/messages/annotation_editor_title.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_title.js +34 -0
- package/dist/paraglide/messages/annotation_editor_tool_label.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_tool_label.js +34 -0
- package/dist/paraglide/messages/annotation_editor_undo.d.ts +4 -0
- package/dist/paraglide/messages/annotation_editor_undo.js +34 -0
- package/dist/paraglide/messages/annotation_tool_point.d.ts +4 -0
- package/dist/paraglide/messages/annotation_tool_point.js +34 -0
- package/dist/paraglide/messages/annotation_tool_polygon.d.ts +4 -0
- package/dist/paraglide/messages/annotation_tool_polygon.js +34 -0
- package/dist/paraglide/messages/annotation_tool_rectangle.d.ts +4 -0
- package/dist/paraglide/messages/annotation_tool_rectangle.js +34 -0
- package/dist/paraglide/messages/image_adjustments_title.d.ts +4 -0
- package/dist/paraglide/messages/image_adjustments_title.js +34 -0
- package/dist/paraglide/messages/image_filters_brightness.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_brightness.js +34 -0
- package/dist/paraglide/messages/image_filters_contrast.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_contrast.js +34 -0
- package/dist/paraglide/messages/image_filters_effects.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_effects.js +34 -0
- package/dist/paraglide/messages/image_filters_grayscale.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_grayscale.js +34 -0
- package/dist/paraglide/messages/image_filters_invert.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_invert.js +34 -0
- package/dist/paraglide/messages/image_filters_reset.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_reset.js +34 -0
- package/dist/paraglide/messages/image_filters_saturation.d.ts +4 -0
- package/dist/paraglide/messages/image_filters_saturation.js +34 -0
- package/dist/paraglide/messages/plugins_tooltip.js +1 -1
- package/dist/paraglide/messages/settings_transparent_background.d.ts +4 -0
- package/dist/paraglide/messages/settings_transparent_background.js +34 -0
- package/dist/plugins/annotation-editor/AnnotationEditorController.svelte +166 -0
- package/dist/plugins/annotation-editor/AnnotationEditorController.svelte.d.ts +9 -0
- package/dist/plugins/annotation-editor/AnnotationEditorPanel.svelte +315 -0
- package/dist/plugins/annotation-editor/AnnotationEditorPanel.svelte.d.ts +24 -0
- package/dist/plugins/annotation-editor/AnnotationManager.svelte.d.ts +39 -0
- package/dist/plugins/annotation-editor/AnnotationManager.svelte.js +433 -0
- package/dist/plugins/annotation-editor/adapters/LocalStorageAdapter.d.ts +20 -0
- package/dist/plugins/annotation-editor/adapters/LocalStorageAdapter.js +67 -0
- package/dist/plugins/annotation-editor/adapters/index.d.ts +2 -0
- package/dist/plugins/annotation-editor/adapters/index.js +1 -0
- package/dist/plugins/annotation-editor/adapters/types.d.ts +23 -0
- package/dist/plugins/annotation-editor/adapters/types.js +1 -0
- package/dist/plugins/annotation-editor/iife-entry.d.ts +15 -0
- package/dist/plugins/annotation-editor/iife-entry.js +35 -0
- package/dist/plugins/annotation-editor/index.d.ts +41 -0
- package/dist/plugins/annotation-editor/index.js +57 -0
- package/dist/plugins/annotation-editor/loader.svelte.d.ts +7 -0
- package/dist/plugins/annotation-editor/loader.svelte.js +32 -0
- package/dist/plugins/annotation-editor/types.d.ts +41 -0
- package/dist/plugins/annotation-editor/types.js +13 -0
- package/dist/plugins/annotation-editor.js +32824 -0
- package/dist/plugins/image-manipulation/ImageManipulationController.svelte +54 -0
- package/dist/plugins/image-manipulation/ImageManipulationController.svelte.d.ts +6 -0
- package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte +19 -9
- package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte.d.ts +1 -0
- package/dist/plugins/image-manipulation/iife-entry.d.ts +13 -0
- package/dist/plugins/image-manipulation/iife-entry.js +17 -0
- package/dist/plugins/image-manipulation/index.d.ts +15 -1
- package/dist/plugins/image-manipulation/index.js +21 -1
- package/dist/plugins/image-manipulation.js +265 -0
- package/dist/state/i18n.svelte.js +4 -2
- package/dist/state/manifests.svelte.d.ts +5 -0
- package/dist/state/manifests.svelte.js +42 -13
- package/dist/state/viewer.svelte.d.ts +14 -13
- package/dist/state/viewer.svelte.js +63 -74
- package/dist/triiiceratops-bundle.js +3208 -3124
- package/dist/triiiceratops-element.iife.js +99 -0
- package/dist/triiiceratops.css +1 -1
- package/dist/types/config.d.ts +5 -0
- package/dist/types/plugin.d.ts +21 -62
- package/dist/types/plugin.js +1 -23
- package/dist/utils/annotationAdapter.d.ts +12 -1
- package/dist/utils/annotationAdapter.js +98 -39
- package/package.json +13 -6
- package/dist/chunks/TriiiceratopsViewer-DpZQA17w.js +0 -10435
- package/dist/chunks/openseadragon-5MHeYuQz.js +0 -12427
- package/dist/components/TriiiceratopsViewerElementImage.svelte +0 -143
- package/dist/components/TriiiceratopsViewerElementImage.svelte.d.ts +0 -27
- package/dist/custom-element-image.d.ts +0 -1
- package/dist/custom-element-image.js +0 -2
- package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.d.ts +0 -19
- package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.js +0 -87
- package/dist/triiiceratops-element-image.js +0 -555
- package/dist/triiiceratops-element.js +0 -114
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import { getContext } from 'svelte';
|
|
3
|
+
import {
|
|
4
|
+
VIEWER_STATE_KEY,
|
|
5
|
+
type ViewerState,
|
|
6
|
+
} from '../../state/viewer.svelte';
|
|
7
|
+
import { DEFAULT_FILTERS, type ImageFilters } from './types';
|
|
8
|
+
import { applyFilters } from './filters';
|
|
9
|
+
import ImageManipulationPanel from './ImageManipulationPanel.svelte';
|
|
10
|
+
|
|
11
|
+
// Props from the plugin system
|
|
12
|
+
let { isOpen = false, close } = $props();
|
|
13
|
+
|
|
14
|
+
const viewerState = getContext<ViewerState>(VIEWER_STATE_KEY);
|
|
15
|
+
let filters = $state<ImageFilters>({ ...DEFAULT_FILTERS });
|
|
16
|
+
|
|
17
|
+
// React to filter changes and apply to OSD
|
|
18
|
+
$effect(() => {
|
|
19
|
+
if (viewerState?.osdViewer) {
|
|
20
|
+
applyFilters(viewerState.osdViewer, filters);
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
// Reset filters when a new image is opened (canvas change)
|
|
25
|
+
let lastCanvasId = $state(viewerState?.canvasId);
|
|
26
|
+
$effect(() => {
|
|
27
|
+
if (viewerState?.canvasId !== lastCanvasId) {
|
|
28
|
+
lastCanvasId = viewerState?.canvasId;
|
|
29
|
+
filters = { ...DEFAULT_FILTERS };
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
function handleFilterChange(newFilters: ImageFilters) {
|
|
34
|
+
filters = newFilters;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function handleReset() {
|
|
38
|
+
filters = { ...DEFAULT_FILTERS };
|
|
39
|
+
}
|
|
40
|
+
</script>
|
|
41
|
+
|
|
42
|
+
<!--
|
|
43
|
+
We render the generic panel, passing our state and handlers.
|
|
44
|
+
The controller is responsible for the "Smart" logic (applying filters to OSD),
|
|
45
|
+
while the panel handles the UI.
|
|
46
|
+
-->
|
|
47
|
+
<div class="h-full">
|
|
48
|
+
<ImageManipulationPanel
|
|
49
|
+
{filters}
|
|
50
|
+
onFilterChange={handleFilterChange}
|
|
51
|
+
onReset={handleReset}
|
|
52
|
+
onClose={close}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import X from 'phosphor-svelte/lib/X';
|
|
3
3
|
import ArrowCounterClockwise from 'phosphor-svelte/lib/ArrowCounterClockwise';
|
|
4
|
+
import { setLocale, locales } from '../../paraglide/runtime';
|
|
5
|
+
import * as m from '../../paraglide/messages';
|
|
4
6
|
import type { ImageFilters } from './types';
|
|
5
7
|
|
|
6
8
|
let {
|
|
@@ -8,11 +10,13 @@
|
|
|
8
10
|
onFilterChange,
|
|
9
11
|
onReset,
|
|
10
12
|
onClose,
|
|
13
|
+
locale,
|
|
11
14
|
}: {
|
|
12
15
|
filters: ImageFilters;
|
|
13
16
|
onFilterChange: (filters: ImageFilters) => void;
|
|
14
17
|
onReset: () => void;
|
|
15
18
|
onClose: () => void;
|
|
19
|
+
locale?: string;
|
|
16
20
|
} = $props();
|
|
17
21
|
|
|
18
22
|
function updateFilter<K extends keyof ImageFilters>(
|
|
@@ -21,6 +25,12 @@
|
|
|
21
25
|
) {
|
|
22
26
|
onFilterChange({ ...filters, [key]: value });
|
|
23
27
|
}
|
|
28
|
+
|
|
29
|
+
$effect(() => {
|
|
30
|
+
if (locale && locales.includes(locale as any)) {
|
|
31
|
+
setLocale(locale as any);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
24
34
|
</script>
|
|
25
35
|
|
|
26
36
|
<div
|
|
@@ -28,11 +38,11 @@
|
|
|
28
38
|
>
|
|
29
39
|
<!-- Header -->
|
|
30
40
|
<div class="flex items-center justify-between p-4 border-b border-base-300">
|
|
31
|
-
<h2 class="text-lg font-semibold">
|
|
41
|
+
<h2 class="text-lg font-semibold">{m.image_adjustments_title()}</h2>
|
|
32
42
|
<button
|
|
33
43
|
class="btn btn-sm btn-ghost btn-circle"
|
|
34
44
|
onclick={onClose}
|
|
35
|
-
aria-label=
|
|
45
|
+
aria-label={m.close()}
|
|
36
46
|
>
|
|
37
47
|
<X size={20} />
|
|
38
48
|
</button>
|
|
@@ -43,7 +53,7 @@
|
|
|
43
53
|
<!-- Brightness -->
|
|
44
54
|
<div class="form-control">
|
|
45
55
|
<label class="label" for="brightness-slider">
|
|
46
|
-
<span class="label-text">
|
|
56
|
+
<span class="label-text">{m.image_filters_brightness()}</span>
|
|
47
57
|
<span class="label-text-alt">{filters.brightness}%</span>
|
|
48
58
|
</label>
|
|
49
59
|
<input
|
|
@@ -61,7 +71,7 @@
|
|
|
61
71
|
<!-- Contrast -->
|
|
62
72
|
<div class="form-control">
|
|
63
73
|
<label class="label" for="contrast-slider">
|
|
64
|
-
<span class="label-text">
|
|
74
|
+
<span class="label-text">{m.image_filters_contrast()}</span>
|
|
65
75
|
<span class="label-text-alt">{filters.contrast}%</span>
|
|
66
76
|
</label>
|
|
67
77
|
<input
|
|
@@ -79,7 +89,7 @@
|
|
|
79
89
|
<!-- Saturation -->
|
|
80
90
|
<div class="form-control">
|
|
81
91
|
<label class="label" for="saturation-slider">
|
|
82
|
-
<span class="label-text">
|
|
92
|
+
<span class="label-text">{m.image_filters_saturation()}</span>
|
|
83
93
|
<span class="label-text-alt">{filters.saturation}%</span>
|
|
84
94
|
</label>
|
|
85
95
|
<input
|
|
@@ -95,11 +105,11 @@
|
|
|
95
105
|
</div>
|
|
96
106
|
|
|
97
107
|
<!-- Effects -->
|
|
98
|
-
<div class="divider">
|
|
108
|
+
<div class="divider">{m.image_filters_effects()}</div>
|
|
99
109
|
|
|
100
110
|
<div class="form-control">
|
|
101
111
|
<label class="label cursor-pointer">
|
|
102
|
-
<span class="label-text">
|
|
112
|
+
<span class="label-text">{m.image_filters_invert()}</span>
|
|
103
113
|
<input
|
|
104
114
|
type="checkbox"
|
|
105
115
|
checked={filters.invert}
|
|
@@ -112,7 +122,7 @@
|
|
|
112
122
|
|
|
113
123
|
<div class="form-control">
|
|
114
124
|
<label class="label cursor-pointer">
|
|
115
|
-
<span class="label-text">
|
|
125
|
+
<span class="label-text">{m.image_filters_grayscale()}</span>
|
|
116
126
|
<input
|
|
117
127
|
type="checkbox"
|
|
118
128
|
checked={filters.grayscale}
|
|
@@ -128,7 +138,7 @@
|
|
|
128
138
|
<div class="p-4 border-t border-base-300">
|
|
129
139
|
<button class="btn btn-outline btn-block" onclick={onReset}>
|
|
130
140
|
<ArrowCounterClockwise size={20} />
|
|
131
|
-
|
|
141
|
+
{m.image_filters_reset()}
|
|
132
142
|
</button>
|
|
133
143
|
</div>
|
|
134
144
|
</div>
|
|
@@ -4,6 +4,7 @@ type $$ComponentProps = {
|
|
|
4
4
|
onFilterChange: (filters: ImageFilters) => void;
|
|
5
5
|
onReset: () => void;
|
|
6
6
|
onClose: () => void;
|
|
7
|
+
locale?: string;
|
|
7
8
|
};
|
|
8
9
|
declare const ImageManipulationPanel: import("svelte").Component<$$ComponentProps, {}, "">;
|
|
9
10
|
type ImageManipulationPanel = ReturnType<typeof ImageManipulationPanel>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IIFE entry point for the Image Manipulation plugin.
|
|
3
|
+
* This file is used to build a standalone script that can be loaded via <script> tag.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* <script src="triiiceratops-element.iife.js"></script>
|
|
7
|
+
* <script src="triiiceratops-plugin-image-manipulation.iife.js"></script>
|
|
8
|
+
* <script>
|
|
9
|
+
* const viewer = document.querySelector('triiiceratops-viewer');
|
|
10
|
+
* viewer.plugins = [window.TriiiceratopsPlugins.ImageManipulation];
|
|
11
|
+
* </script>
|
|
12
|
+
*/
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* IIFE entry point for the Image Manipulation plugin.
|
|
3
|
+
* This file is used to build a standalone script that can be loaded via <script> tag.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* <script src="triiiceratops-element.iife.js"></script>
|
|
7
|
+
* <script src="triiiceratops-plugin-image-manipulation.iife.js"></script>
|
|
8
|
+
* <script>
|
|
9
|
+
* const viewer = document.querySelector('triiiceratops-viewer');
|
|
10
|
+
* viewer.plugins = [window.TriiiceratopsPlugins.ImageManipulation];
|
|
11
|
+
* </script>
|
|
12
|
+
*/
|
|
13
|
+
import { ImageManipulationPlugin } from './index';
|
|
14
|
+
// Ensure the namespace exists (should already be created by the element script)
|
|
15
|
+
window.TriiiceratopsPlugins = window.TriiiceratopsPlugins || {};
|
|
16
|
+
// Register the plugin
|
|
17
|
+
window.TriiiceratopsPlugins.ImageManipulation = ImageManipulationPlugin;
|
|
@@ -1,3 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import type { PluginDef } from '../../types/plugin';
|
|
2
|
+
import ImageManipulationController from './ImageManipulationController.svelte';
|
|
3
|
+
import SlidersIcon from 'phosphor-svelte/lib/Sliders';
|
|
4
|
+
/**
|
|
5
|
+
* Pre-configured Image Manipulation plugin.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* ```svelte
|
|
9
|
+
* import { ImageManipulationPlugin } from 'triiiceratops/plugins/image-manipulation';
|
|
10
|
+
*
|
|
11
|
+
* <TriiiceratopsViewer plugins={[ImageManipulationPlugin]} />
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const ImageManipulationPlugin: PluginDef;
|
|
15
|
+
export { ImageManipulationController, SlidersIcon };
|
|
2
16
|
export type { ImageFilters } from './types';
|
|
3
17
|
export { DEFAULT_FILTERS } from './types';
|
|
@@ -1,2 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import ImageManipulationController from './ImageManipulationController.svelte';
|
|
2
|
+
import SlidersIcon from 'phosphor-svelte/lib/Sliders';
|
|
3
|
+
/**
|
|
4
|
+
* Pre-configured Image Manipulation plugin.
|
|
5
|
+
*
|
|
6
|
+
* Usage:
|
|
7
|
+
* ```svelte
|
|
8
|
+
* import { ImageManipulationPlugin } from 'triiiceratops/plugins/image-manipulation';
|
|
9
|
+
*
|
|
10
|
+
* <TriiiceratopsViewer plugins={[ImageManipulationPlugin]} />
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export const ImageManipulationPlugin = {
|
|
14
|
+
id: 'image-manipulation',
|
|
15
|
+
name: 'image_adjustments_title',
|
|
16
|
+
icon: SlidersIcon,
|
|
17
|
+
panel: ImageManipulationController,
|
|
18
|
+
position: 'left',
|
|
19
|
+
};
|
|
20
|
+
// Individual exports for customization
|
|
21
|
+
export { ImageManipulationController, SlidersIcon };
|
|
2
22
|
export { DEFAULT_FILTERS } from './types';
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
import "svelte/internal/disclose-version";
|
|
2
|
+
import * as e from "svelte/internal/client";
|
|
3
|
+
import { getContext as s0 } from "svelte";
|
|
4
|
+
import { l as l0, s as i0, X as n0, c as o0, V as c0, g as v0 } from "../X-DZEgXrJ8.js";
|
|
5
|
+
import { A as d0 } from "../ArrowCounterClockwise-aFffCOKw.js";
|
|
6
|
+
import { i as _0, a as g0, b as f0, g as u0, c as h0, e as m0, d as p0, f as b0 } from "../image_filters_reset-BEIf-_QA.js";
|
|
7
|
+
const G = {
|
|
8
|
+
brightness: 100,
|
|
9
|
+
contrast: 100,
|
|
10
|
+
saturation: 100,
|
|
11
|
+
invert: !1,
|
|
12
|
+
grayscale: !1
|
|
13
|
+
};
|
|
14
|
+
function V0(b, a) {
|
|
15
|
+
var l;
|
|
16
|
+
const t = (l = b.drawer) == null ? void 0 : l.canvas;
|
|
17
|
+
if (!t) return;
|
|
18
|
+
const r = [];
|
|
19
|
+
a.brightness !== 100 && r.push(`brightness(${a.brightness / 100})`), a.contrast !== 100 && r.push(`contrast(${a.contrast / 100})`), a.saturation !== 100 && r.push(`saturate(${a.saturation / 100})`), a.invert && r.push("invert(1)"), a.grayscale && r.push("grayscale(1)"), t.style.filter = r.length > 0 ? r.join(" ") : "none";
|
|
20
|
+
}
|
|
21
|
+
var x0 = e.from_html('<div class="w-72 h-full bg-base-200 border-l border-base-300 shadow-xl flex flex-col"><div class="flex items-center justify-between p-4 border-b border-base-300"><h2 class="text-lg font-semibold"> </h2> <button class="btn btn-sm btn-ghost btn-circle"><!></button></div> <div class="flex-1 overflow-y-auto p-4 space-y-6"><div class="form-control"><label class="label" for="brightness-slider"><span class="label-text"> </span> <span class="label-text-alt"> </span></label> <input id="brightness-slider" type="range" min="0" max="200" class="range range-sm range-primary"/></div> <div class="form-control"><label class="label" for="contrast-slider"><span class="label-text"> </span> <span class="label-text-alt"> </span></label> <input id="contrast-slider" type="range" min="0" max="200" class="range range-sm range-secondary"/></div> <div class="form-control"><label class="label" for="saturation-slider"><span class="label-text"> </span> <span class="label-text-alt"> </span></label> <input id="saturation-slider" type="range" min="0" max="200" class="range range-sm range-accent"/></div> <div class="divider"> </div> <div class="form-control"><label class="label cursor-pointer"><span class="label-text"> </span> <input type="checkbox" class="toggle toggle-primary"/></label></div> <div class="form-control"><label class="label cursor-pointer"><span class="label-text"> </span> <input type="checkbox" class="toggle toggle-secondary"/></label></div></div> <div class="p-4 border-t border-base-300"><button class="btn btn-outline btn-block"><!> </button></div></div>');
|
|
22
|
+
function Z0(b, a) {
|
|
23
|
+
e.push(a, !0);
|
|
24
|
+
function t(s, u) {
|
|
25
|
+
a.onFilterChange({ ...a.filters, [s]: u });
|
|
26
|
+
}
|
|
27
|
+
e.user_effect(() => {
|
|
28
|
+
a.locale && l0.includes(a.locale) && i0(a.locale);
|
|
29
|
+
});
|
|
30
|
+
var r = x0(), l = e.child(r), V = e.child(l), Z = e.child(V, !0);
|
|
31
|
+
e.reset(V);
|
|
32
|
+
var o = e.sibling(V, 2);
|
|
33
|
+
o.__click = function(...s) {
|
|
34
|
+
var u;
|
|
35
|
+
(u = a.onClose) == null || u.apply(this, s);
|
|
36
|
+
};
|
|
37
|
+
var A = e.child(o);
|
|
38
|
+
n0(A, { size: 20 }), e.reset(o), e.reset(l);
|
|
39
|
+
var c = e.sibling(l, 2), y = e.child(c), I = e.child(y), T = e.child(I), D = e.child(T, !0);
|
|
40
|
+
e.reset(T);
|
|
41
|
+
var j = e.sibling(T, 2), i = e.child(j);
|
|
42
|
+
e.reset(j), e.reset(I);
|
|
43
|
+
var n = e.sibling(I, 2);
|
|
44
|
+
e.remove_input_defaults(n), n.__input = (s) => t("brightness", +s.currentTarget.value), e.reset(y);
|
|
45
|
+
var h = e.sibling(y, 2), M = e.child(h), w = e.child(M), v = e.child(w, !0);
|
|
46
|
+
e.reset(w);
|
|
47
|
+
var x = e.sibling(w, 2), K = e.child(x);
|
|
48
|
+
e.reset(x), e.reset(M);
|
|
49
|
+
var F = e.sibling(M, 2);
|
|
50
|
+
e.remove_input_defaults(F), F.__input = (s) => t("contrast", +s.currentTarget.value), e.reset(h);
|
|
51
|
+
var z = e.sibling(h, 2), d = e.child(z), m = e.child(d), O = e.child(m, !0);
|
|
52
|
+
e.reset(m);
|
|
53
|
+
var L = e.sibling(m, 2), W = e.child(L);
|
|
54
|
+
e.reset(L), e.reset(d);
|
|
55
|
+
var _ = e.sibling(d, 2);
|
|
56
|
+
e.remove_input_defaults(_), _.__input = (s) => t("saturation", +s.currentTarget.value), e.reset(z);
|
|
57
|
+
var p = e.sibling(z, 2), X = e.child(p, !0);
|
|
58
|
+
e.reset(p);
|
|
59
|
+
var E = e.sibling(p, 2), P = e.child(E), g = e.child(P), C = e.child(g, !0);
|
|
60
|
+
e.reset(g);
|
|
61
|
+
var R = e.sibling(g, 2);
|
|
62
|
+
e.remove_input_defaults(R), R.__change = (s) => t("invert", s.currentTarget.checked), e.reset(P), e.reset(E);
|
|
63
|
+
var U = e.sibling(E, 2), B = e.child(U), f = e.child(B), k = e.child(f, !0);
|
|
64
|
+
e.reset(f);
|
|
65
|
+
var Y = e.sibling(f, 2);
|
|
66
|
+
e.remove_input_defaults(Y), Y.__change = (s) => t("grayscale", s.currentTarget.checked), e.reset(B), e.reset(U), e.reset(c);
|
|
67
|
+
var H = e.sibling(c, 2), q = e.child(H);
|
|
68
|
+
q.__click = function(...s) {
|
|
69
|
+
var u;
|
|
70
|
+
(u = a.onReset) == null || u.apply(this, s);
|
|
71
|
+
};
|
|
72
|
+
var J = e.child(q);
|
|
73
|
+
d0(J, { size: 20 });
|
|
74
|
+
var N = e.sibling(J);
|
|
75
|
+
e.reset(q), e.reset(H), e.reset(r), e.template_effect(
|
|
76
|
+
(s, u, Q, S, $, e0, a0, t0, r0) => {
|
|
77
|
+
e.set_text(Z, s), e.set_attribute(o, "aria-label", u), e.set_text(D, Q), e.set_text(i, `${a.filters.brightness ?? ""}%`), e.set_value(n, a.filters.brightness), e.set_text(v, S), e.set_text(K, `${a.filters.contrast ?? ""}%`), e.set_value(F, a.filters.contrast), e.set_text(O, $), e.set_text(W, `${a.filters.saturation ?? ""}%`), e.set_value(_, a.filters.saturation), e.set_text(X, e0), e.set_text(C, a0), e.set_checked(R, a.filters.invert), e.set_text(k, t0), e.set_checked(Y, a.filters.grayscale), e.set_text(N, ` ${r0 ?? ""}`);
|
|
78
|
+
},
|
|
79
|
+
[
|
|
80
|
+
() => _0(),
|
|
81
|
+
() => o0(),
|
|
82
|
+
() => g0(),
|
|
83
|
+
() => f0(),
|
|
84
|
+
() => u0(),
|
|
85
|
+
() => h0(),
|
|
86
|
+
() => m0(),
|
|
87
|
+
() => p0(),
|
|
88
|
+
() => b0()
|
|
89
|
+
]
|
|
90
|
+
), e.append(b, r), e.pop();
|
|
91
|
+
}
|
|
92
|
+
e.delegate(["click", "input", "change"]);
|
|
93
|
+
var A0 = e.from_html('<div class="h-full"><!></div>');
|
|
94
|
+
function y0(b, a) {
|
|
95
|
+
e.push(a, !0), e.prop(a, "isOpen", 3, !1);
|
|
96
|
+
const t = s0(c0);
|
|
97
|
+
let r = e.state(e.proxy({ ...G }));
|
|
98
|
+
e.user_effect(() => {
|
|
99
|
+
t != null && t.osdViewer && V0(t.osdViewer, e.get(r));
|
|
100
|
+
});
|
|
101
|
+
let l = e.state(e.proxy(t == null ? void 0 : t.canvasId));
|
|
102
|
+
e.user_effect(() => {
|
|
103
|
+
(t == null ? void 0 : t.canvasId) !== e.get(l) && (e.set(l, t == null ? void 0 : t.canvasId, !0), e.set(r, { ...G }, !0));
|
|
104
|
+
});
|
|
105
|
+
function V(c) {
|
|
106
|
+
e.set(r, c, !0);
|
|
107
|
+
}
|
|
108
|
+
function Z() {
|
|
109
|
+
e.set(r, { ...G }, !0);
|
|
110
|
+
}
|
|
111
|
+
var o = A0(), A = e.child(o);
|
|
112
|
+
Z0(A, {
|
|
113
|
+
get filters() {
|
|
114
|
+
return e.get(r);
|
|
115
|
+
},
|
|
116
|
+
onFilterChange: V,
|
|
117
|
+
onReset: Z,
|
|
118
|
+
get onClose() {
|
|
119
|
+
return a.close;
|
|
120
|
+
}
|
|
121
|
+
}), e.reset(o), e.append(b, o), e.pop();
|
|
122
|
+
}
|
|
123
|
+
var M0 = e.from_svg('<path d="M68,102.06V40a12,12,0,0,0-24,0v62.06a36,36,0,0,0,0,67.88V216a12,12,0,0,0,24,0V169.94a36,36,0,0,0,0-67.88ZM56,148a12,12,0,1,1,12-12A12,12,0,0,1,56,148ZM164,88a36.07,36.07,0,0,0-24-33.94V40a12,12,0,0,0-24,0V54.06a36,36,0,0,0,0,67.88V216a12,12,0,0,0,24,0V121.94A36.07,36.07,0,0,0,164,88Zm-36,12a12,12,0,1,1,12-12A12,12,0,0,1,128,100Zm108,68a36.07,36.07,0,0,0-24-33.94V40a12,12,0,0,0-24,0v94.06a36,36,0,0,0,0,67.88V216a12,12,0,0,0,24,0V201.94A36.07,36.07,0,0,0,236,168Zm-36,12a12,12,0,1,1,12-12A12,12,0,0,1,200,180Z"></path>'), w0 = e.from_svg('<path d="M80,136a24,24,0,1,1-24-24A24,24,0,0,1,80,136Zm48-72a24,24,0,1,0,24,24A24,24,0,0,0,128,64Zm72,80a24,24,0,1,0,24,24A24,24,0,0,0,200,144Z" opacity="0.2"></path><path d="M64,105V40a8,8,0,0,0-16,0v65a32,32,0,0,0,0,62v49a8,8,0,0,0,16,0V167a32,32,0,0,0,0-62Zm-8,47a16,16,0,1,1,16-16A16,16,0,0,1,56,152Zm80-95V40a8,8,0,0,0-16,0V57a32,32,0,0,0,0,62v97a8,8,0,0,0,16,0V119a32,32,0,0,0,0-62Zm-8,47a16,16,0,1,1,16-16A16,16,0,0,1,128,104Zm104,64a32.06,32.06,0,0,0-24-31V40a8,8,0,0,0-16,0v97a32,32,0,0,0,0,62v17a8,8,0,0,0,16,0V199A32.06,32.06,0,0,0,232,168Zm-32,16a16,16,0,1,1,16-16A16,16,0,0,1,200,184Z"></path>', 1), C0 = e.from_svg('<path d="M84,136a28,28,0,0,1-20,26.83V216a8,8,0,0,1-16,0V162.83a28,28,0,0,1,0-53.66V40a8,8,0,0,1,16,0v69.17A28,28,0,0,1,84,136Zm52-74.83V40a8,8,0,0,0-16,0V61.17a28,28,0,0,0,0,53.66V216a8,8,0,0,0,16,0V114.83a28,28,0,0,0,0-53.66Zm72,80V40a8,8,0,0,0-16,0V141.17a28,28,0,0,0,0,53.66V216a8,8,0,0,0,16,0V194.83a28,28,0,0,0,0-53.66Z"></path>'), k0 = e.from_svg('<path d="M62,106.6V40a6,6,0,0,0-12,0v66.6a30,30,0,0,0,0,58.8V216a6,6,0,0,0,12,0V165.4a30,30,0,0,0,0-58.8ZM56,154a18,18,0,1,1,18-18A18,18,0,0,1,56,154Zm78-95.4V40a6,6,0,0,0-12,0V58.6a30,30,0,0,0,0,58.8V216a6,6,0,0,0,12,0V117.4a30,30,0,0,0,0-58.8ZM128,106a18,18,0,1,1,18-18A18,18,0,0,1,128,106Zm102,62a30.05,30.05,0,0,0-24-29.4V40a6,6,0,0,0-12,0v98.6a30,30,0,0,0,0,58.8V216a6,6,0,0,0,12,0V197.4A30.05,30.05,0,0,0,230,168Zm-30,18a18,18,0,1,1,18-18A18,18,0,0,1,200,186Z"></path>'), I0 = e.from_svg('<path d="M64,105V40a8,8,0,0,0-16,0v65a32,32,0,0,0,0,62v49a8,8,0,0,0,16,0V167a32,32,0,0,0,0-62Zm-8,47a16,16,0,1,1,16-16A16,16,0,0,1,56,152Zm80-95V40a8,8,0,0,0-16,0V57a32,32,0,0,0,0,62v97a8,8,0,0,0,16,0V119a32,32,0,0,0,0-62Zm-8,47a16,16,0,1,1,16-16A16,16,0,0,1,128,104Zm104,64a32.06,32.06,0,0,0-24-31V40a8,8,0,0,0-16,0v97a32,32,0,0,0,0,62v17a8,8,0,0,0,16,0V199A32.06,32.06,0,0,0,232,168Zm-32,16a16,16,0,1,1,16-16A16,16,0,0,1,200,184Z"></path>'), T0 = e.from_svg('<path d="M60,108.29V40a4,4,0,0,0-8,0v68.29a28,28,0,0,0,0,55.42V216a4,4,0,0,0,8,0V163.71a28,28,0,0,0,0-55.42ZM56,156a20,20,0,1,1,20-20A20,20,0,0,1,56,156Zm76-95.71V40a4,4,0,0,0-8,0V60.29a28,28,0,0,0,0,55.42V216a4,4,0,0,0,8,0V115.71a28,28,0,0,0,0-55.42ZM128,108a20,20,0,1,1,20-20A20,20,0,0,1,128,108Zm100,60a28,28,0,0,0-24-27.71V40a4,4,0,0,0-8,0V140.29a28,28,0,0,0,0,55.42V216a4,4,0,0,0,8,0V195.71A28,28,0,0,0,228,168Zm-28,20a20,20,0,1,1,20-20A20,20,0,0,1,200,188Z"></path>'), F0 = e.from_svg('<svg><!><rect width="256" height="256" fill="none"></rect><!></svg>');
|
|
124
|
+
function z0(b, a) {
|
|
125
|
+
e.push(a, !0);
|
|
126
|
+
const t = v0();
|
|
127
|
+
let r = e.rest_props(a, ["$$slots", "$$events", "$$legacy", "children"]), l = e.derived(() => a.weight ?? t.weight ?? "regular"), V = e.derived(() => a.color ?? t.color ?? "currentColor"), Z = e.derived(() => a.size ?? t.size ?? "1em"), o = e.derived(() => a.mirrored ?? t.mirrored ?? !1);
|
|
128
|
+
function A(i) {
|
|
129
|
+
let { weight: n, color: h, size: M, mirrored: w, ...v } = i;
|
|
130
|
+
return v;
|
|
131
|
+
}
|
|
132
|
+
var c = F0();
|
|
133
|
+
e.attribute_effect(
|
|
134
|
+
c,
|
|
135
|
+
(i, n) => ({
|
|
136
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
137
|
+
role: "img",
|
|
138
|
+
width: e.get(Z),
|
|
139
|
+
height: e.get(Z),
|
|
140
|
+
fill: e.get(V),
|
|
141
|
+
transform: e.get(o) ? "scale(-1, 1)" : void 0,
|
|
142
|
+
viewBox: "0 0 256 256",
|
|
143
|
+
...i,
|
|
144
|
+
...n
|
|
145
|
+
}),
|
|
146
|
+
[() => A(t), () => A(r)]
|
|
147
|
+
);
|
|
148
|
+
var y = e.child(c);
|
|
149
|
+
{
|
|
150
|
+
var I = (i) => {
|
|
151
|
+
var n = e.comment(), h = e.first_child(n);
|
|
152
|
+
e.snippet(h, () => a.children), e.append(i, n);
|
|
153
|
+
};
|
|
154
|
+
e.if(y, (i) => {
|
|
155
|
+
a.children && i(I);
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
var T = e.sibling(y, 2);
|
|
159
|
+
{
|
|
160
|
+
var D = (i) => {
|
|
161
|
+
var n = M0();
|
|
162
|
+
e.append(i, n);
|
|
163
|
+
}, j = (i) => {
|
|
164
|
+
var n = e.comment(), h = e.first_child(n);
|
|
165
|
+
{
|
|
166
|
+
var M = (v) => {
|
|
167
|
+
var x = w0();
|
|
168
|
+
e.next(), e.append(v, x);
|
|
169
|
+
}, w = (v) => {
|
|
170
|
+
var x = e.comment(), K = e.first_child(x);
|
|
171
|
+
{
|
|
172
|
+
var F = (d) => {
|
|
173
|
+
var m = C0();
|
|
174
|
+
e.append(d, m);
|
|
175
|
+
}, z = (d) => {
|
|
176
|
+
var m = e.comment(), O = e.first_child(m);
|
|
177
|
+
{
|
|
178
|
+
var L = (_) => {
|
|
179
|
+
var p = k0();
|
|
180
|
+
e.append(_, p);
|
|
181
|
+
}, W = (_) => {
|
|
182
|
+
var p = e.comment(), X = e.first_child(p);
|
|
183
|
+
{
|
|
184
|
+
var E = (g) => {
|
|
185
|
+
var C = I0();
|
|
186
|
+
e.append(g, C);
|
|
187
|
+
}, P = (g) => {
|
|
188
|
+
var C = e.comment(), R = e.first_child(C);
|
|
189
|
+
{
|
|
190
|
+
var U = (f) => {
|
|
191
|
+
var k = T0();
|
|
192
|
+
e.append(f, k);
|
|
193
|
+
}, B = (f) => {
|
|
194
|
+
var k = e.text();
|
|
195
|
+
k.nodeValue = (console.error('Unsupported icon weight. Choose from "thin", "light", "regular", "bold", "fill", or "duotone".'), ""), e.append(f, k);
|
|
196
|
+
};
|
|
197
|
+
e.if(
|
|
198
|
+
R,
|
|
199
|
+
(f) => {
|
|
200
|
+
e.get(l) === "thin" ? f(U) : f(B, !1);
|
|
201
|
+
},
|
|
202
|
+
!0
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
e.append(g, C);
|
|
206
|
+
};
|
|
207
|
+
e.if(
|
|
208
|
+
X,
|
|
209
|
+
(g) => {
|
|
210
|
+
e.get(l) === "regular" ? g(E) : g(P, !1);
|
|
211
|
+
},
|
|
212
|
+
!0
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
e.append(_, p);
|
|
216
|
+
};
|
|
217
|
+
e.if(
|
|
218
|
+
O,
|
|
219
|
+
(_) => {
|
|
220
|
+
e.get(l) === "light" ? _(L) : _(W, !1);
|
|
221
|
+
},
|
|
222
|
+
!0
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
e.append(d, m);
|
|
226
|
+
};
|
|
227
|
+
e.if(
|
|
228
|
+
K,
|
|
229
|
+
(d) => {
|
|
230
|
+
e.get(l) === "fill" ? d(F) : d(z, !1);
|
|
231
|
+
},
|
|
232
|
+
!0
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
e.append(v, x);
|
|
236
|
+
};
|
|
237
|
+
e.if(
|
|
238
|
+
h,
|
|
239
|
+
(v) => {
|
|
240
|
+
e.get(l) === "duotone" ? v(M) : v(w, !1);
|
|
241
|
+
},
|
|
242
|
+
!0
|
|
243
|
+
);
|
|
244
|
+
}
|
|
245
|
+
e.append(i, n);
|
|
246
|
+
};
|
|
247
|
+
e.if(T, (i) => {
|
|
248
|
+
e.get(l) === "bold" ? i(D) : i(j, !1);
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
e.reset(c), e.append(b, c), e.pop();
|
|
252
|
+
}
|
|
253
|
+
const U0 = {
|
|
254
|
+
id: "image-manipulation",
|
|
255
|
+
name: "image_adjustments_title",
|
|
256
|
+
icon: z0,
|
|
257
|
+
panel: y0,
|
|
258
|
+
position: "left"
|
|
259
|
+
};
|
|
260
|
+
export {
|
|
261
|
+
G as DEFAULT_FILTERS,
|
|
262
|
+
y0 as ImageManipulationController,
|
|
263
|
+
U0 as ImageManipulationPlugin,
|
|
264
|
+
z0 as SlidersIcon
|
|
265
|
+
};
|
|
@@ -3,10 +3,12 @@
|
|
|
3
3
|
export { m } from '../paraglide/messages.js';
|
|
4
4
|
import { getLocale, setLocale as baseSetLocale, overwriteSetLocale, } from '../paraglide/runtime.js';
|
|
5
5
|
// For SSR compatibility, we use a simple variable instead of $state()
|
|
6
|
-
let currentLocale = getLocale();
|
|
6
|
+
let currentLocale = $state(getLocale());
|
|
7
|
+
// Capture the original setLocale before overwriting it
|
|
8
|
+
const originalSetLocale = baseSetLocale;
|
|
7
9
|
// Wrap setLocale to track locale changes
|
|
8
10
|
overwriteSetLocale((newLocale, options) => {
|
|
9
|
-
|
|
11
|
+
originalSetLocale(newLocale, options);
|
|
10
12
|
currentLocale = getLocale();
|
|
11
13
|
});
|
|
12
14
|
export const language = {
|
|
@@ -6,7 +6,12 @@ interface ManifestEntry {
|
|
|
6
6
|
}
|
|
7
7
|
export declare class ManifestsState {
|
|
8
8
|
manifests: Record<string, ManifestEntry>;
|
|
9
|
+
userAnnotations: Map<string, any[]>;
|
|
9
10
|
constructor();
|
|
11
|
+
private userAnnotationKey;
|
|
12
|
+
setUserAnnotations(manifestId: string, canvasId: string, annotations: any[]): void;
|
|
13
|
+
clearUserAnnotations(manifestId: string, canvasId: string): void;
|
|
14
|
+
getUserAnnotations(manifestId: string, canvasId: string): any[];
|
|
10
15
|
fetchManifest(manifestId: string): Promise<void>;
|
|
11
16
|
getManifest(manifestId: string): any;
|
|
12
17
|
fetchAnnotationList(url: string): Promise<void>;
|
|
@@ -1,7 +1,33 @@
|
|
|
1
|
-
import * as manifesto from
|
|
1
|
+
import * as manifesto from 'manifesto.js';
|
|
2
2
|
export class ManifestsState {
|
|
3
3
|
manifests = $state({});
|
|
4
|
+
// User-created annotations (from plugins like annotation editor)
|
|
5
|
+
userAnnotations = $state(new Map());
|
|
4
6
|
constructor() { }
|
|
7
|
+
// === User Annotations API ===
|
|
8
|
+
userAnnotationKey(manifestId, canvasId) {
|
|
9
|
+
return `${manifestId}::${canvasId}`;
|
|
10
|
+
}
|
|
11
|
+
setUserAnnotations(manifestId, canvasId, annotations) {
|
|
12
|
+
const key = this.userAnnotationKey(manifestId, canvasId);
|
|
13
|
+
// Create a new Map to trigger reactivity
|
|
14
|
+
const newMap = new Map(this.userAnnotations);
|
|
15
|
+
newMap.set(key, annotations);
|
|
16
|
+
this.userAnnotations = newMap;
|
|
17
|
+
}
|
|
18
|
+
clearUserAnnotations(manifestId, canvasId) {
|
|
19
|
+
const key = this.userAnnotationKey(manifestId, canvasId);
|
|
20
|
+
if (this.userAnnotations.has(key)) {
|
|
21
|
+
const newMap = new Map(this.userAnnotations);
|
|
22
|
+
newMap.delete(key);
|
|
23
|
+
this.userAnnotations = newMap;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
getUserAnnotations(manifestId, canvasId) {
|
|
27
|
+
const key = this.userAnnotationKey(manifestId, canvasId);
|
|
28
|
+
return this.userAnnotations.get(key) ?? [];
|
|
29
|
+
}
|
|
30
|
+
// === Manifest Fetching ===
|
|
5
31
|
async fetchManifest(manifestId) {
|
|
6
32
|
if (this.manifests[manifestId]) {
|
|
7
33
|
return; // Already fetched or fetching
|
|
@@ -21,7 +47,10 @@ export class ManifestsState {
|
|
|
21
47
|
};
|
|
22
48
|
}
|
|
23
49
|
catch (error) {
|
|
24
|
-
this.manifests[manifestId] = {
|
|
50
|
+
this.manifests[manifestId] = {
|
|
51
|
+
error: error.message,
|
|
52
|
+
isFetching: false,
|
|
53
|
+
};
|
|
25
54
|
}
|
|
26
55
|
}
|
|
27
56
|
getManifest(manifestId) {
|
|
@@ -57,21 +86,21 @@ export class ManifestsState {
|
|
|
57
86
|
return canvases;
|
|
58
87
|
}
|
|
59
88
|
getAnnotations(manifestId, canvasId) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
const annos = this.manualGetAnnotations(manifestId, canvasId);
|
|
67
|
-
return annos;
|
|
89
|
+
// Get manifest annotations
|
|
90
|
+
const manifestAnnos = this.manualGetAnnotations(manifestId, canvasId);
|
|
91
|
+
// Get user-created annotations
|
|
92
|
+
const userAnnos = this.getUserAnnotations(manifestId, canvasId);
|
|
93
|
+
// Merge both sources
|
|
94
|
+
return [...manifestAnnos, ...userAnnos];
|
|
68
95
|
}
|
|
69
96
|
// We can refactor this to use Manifesto's resource handling later if needed.
|
|
70
97
|
manualGetAnnotations(manifestId, canvasId) {
|
|
71
98
|
const manifestoObject = this.getManifest(manifestId);
|
|
72
99
|
if (!manifestoObject)
|
|
73
100
|
return [];
|
|
74
|
-
const canvas = manifestoObject
|
|
101
|
+
const canvas = manifestoObject
|
|
102
|
+
.getSequences()[0]
|
|
103
|
+
.getCanvasById(canvasId);
|
|
75
104
|
if (!canvas)
|
|
76
105
|
return [];
|
|
77
106
|
// Manifesto wraps the JSON. We can access the underlying JSON via canvas.__jsonld
|
|
@@ -87,7 +116,7 @@ export class ManifestsState {
|
|
|
87
116
|
// IIIF v2 otherContent
|
|
88
117
|
if (canvasJson.otherContent) {
|
|
89
118
|
canvasJson.otherContent.forEach((content) => {
|
|
90
|
-
const id = content[
|
|
119
|
+
const id = content['@id'] || content.id;
|
|
91
120
|
if (id && !content.resources) {
|
|
92
121
|
const externalList = this.manifests[id];
|
|
93
122
|
if (externalList) {
|
|
@@ -114,7 +143,7 @@ export class ManifestsState {
|
|
|
114
143
|
// IIIF v3 annotations
|
|
115
144
|
if (canvasJson.annotations) {
|
|
116
145
|
canvasJson.annotations.forEach((content) => {
|
|
117
|
-
const id = content.id || content[
|
|
146
|
+
const id = content.id || content['@id'];
|
|
118
147
|
if (id && !content.items) {
|
|
119
148
|
const externalList = this.manifests[id];
|
|
120
149
|
if (externalList) {
|