triiiceratops 0.9.13 → 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/LeftFab.svelte +21 -9
- package/dist/components/OSDViewer.svelte +20 -3
- package/dist/components/TriiiceratopsViewer.svelte +96 -43
- 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 +30 -0
- package/dist/paraglide/messages/_index.js +31 -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/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 -3126
- package/dist/triiiceratops-element.iife.js +99 -0
- package/dist/triiiceratops.css +1 -1
- 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-EViTQO_n.js +0 -10437
- package/dist/chunks/openseadragon-CHvATAD9.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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ViewerConfig } from '../types/config';
|
|
2
|
-
import type {
|
|
2
|
+
import type { PluginMenuButton, PluginPanel, PluginDef } from '../types/plugin';
|
|
3
3
|
/**
|
|
4
4
|
* Snapshot of viewer state for external consumers.
|
|
5
5
|
* Used by web component events to expose state without Svelte reactivity.
|
|
@@ -71,7 +71,7 @@ export declare class ViewerState {
|
|
|
71
71
|
* reactive cycle completes, preventing infinite update loops.
|
|
72
72
|
*/
|
|
73
73
|
private dispatchStateChange;
|
|
74
|
-
constructor(initialManifestId?: string | null, initialCanvasId?: string | null, initialPlugins?:
|
|
74
|
+
constructor(initialManifestId?: string | null, initialCanvasId?: string | null, initialPlugins?: PluginDef[]);
|
|
75
75
|
get manifest(): any;
|
|
76
76
|
get canvases(): any;
|
|
77
77
|
get currentCanvasIndex(): any;
|
|
@@ -95,8 +95,6 @@ export declare class ViewerState {
|
|
|
95
95
|
get currentCanvasSearchAnnotations(): any[];
|
|
96
96
|
search(query: string): Promise<void>;
|
|
97
97
|
private _performSearch;
|
|
98
|
-
/** Registered plugins */
|
|
99
|
-
plugins: TriiiceratopsPlugin[];
|
|
100
98
|
/** Plugin-registered menu buttons */
|
|
101
99
|
pluginMenuButtons: PluginMenuButton[];
|
|
102
100
|
/** Plugin-registered panels */
|
|
@@ -105,24 +103,27 @@ export declare class ViewerState {
|
|
|
105
103
|
osdViewer: any | null;
|
|
106
104
|
/** Event handlers for inter-plugin communication */
|
|
107
105
|
private pluginEventHandlers;
|
|
108
|
-
/**
|
|
109
|
-
* Create plugin context - the stable API surface for plugins.
|
|
110
|
-
*/
|
|
111
|
-
private createPluginContext;
|
|
112
106
|
/**
|
|
113
107
|
* Register a plugin with this viewer instance.
|
|
108
|
+
* Accepts a simple PluginDef object.
|
|
114
109
|
*/
|
|
115
|
-
registerPlugin(
|
|
110
|
+
registerPlugin(def: PluginDef): void;
|
|
116
111
|
/**
|
|
117
|
-
* Unregister a plugin by ID.
|
|
112
|
+
* Unregister a plugin's UI components by ID prefix.
|
|
113
|
+
* Note: This cleans up the menu button and panel, but doesn't remove listeners attached by the plugin itself
|
|
114
|
+
* since we don't have a handle on the plugin instance or its cleanup function anymore.
|
|
115
|
+
* Plugins should manage their own cleanup via component lifecycle (onDestroy) if possible.
|
|
118
116
|
*/
|
|
119
117
|
unregisterPlugin(pluginId: string): void;
|
|
120
118
|
/**
|
|
121
|
-
*
|
|
119
|
+
* Notify that OSD viewer is ready.
|
|
120
|
+
* With the component-based system, we don't notify plugins individually.
|
|
121
|
+
* Instead, plugins should use the OSDViewer instance from context or listen for 'osd-ready' event (if we emitted one).
|
|
122
|
+
* But since we have direct access to osdViewer in this state, components can just react to it.
|
|
122
123
|
*/
|
|
123
|
-
notifyOSDReady(viewer:
|
|
124
|
+
notifyOSDReady(viewer: OpenSeadragon.Viewer): void;
|
|
124
125
|
/**
|
|
125
|
-
*
|
|
126
|
+
* Cleanup everything.
|
|
126
127
|
*/
|
|
127
128
|
destroyAllPlugins(): void;
|
|
128
129
|
}
|
|
@@ -54,7 +54,13 @@ export class ViewerState {
|
|
|
54
54
|
let canvasIndex = -1;
|
|
55
55
|
if (this.manifestId && this.canvasId) {
|
|
56
56
|
const canvases = manifestsState.getCanvases(this.manifestId);
|
|
57
|
-
canvasIndex = canvases.findIndex((c) =>
|
|
57
|
+
canvasIndex = canvases.findIndex((c) => {
|
|
58
|
+
const id = c.id ||
|
|
59
|
+
c['@id'] ||
|
|
60
|
+
(c.getCanvasId ? c.getCanvasId() : null) ||
|
|
61
|
+
(c.getId ? c.getId() : null);
|
|
62
|
+
return id === this.canvasId;
|
|
63
|
+
});
|
|
58
64
|
}
|
|
59
65
|
return {
|
|
60
66
|
manifestId: this.manifestId,
|
|
@@ -126,8 +132,14 @@ export class ViewerState {
|
|
|
126
132
|
return 0;
|
|
127
133
|
return -1;
|
|
128
134
|
}
|
|
129
|
-
// Manifesto canvases have an id property
|
|
130
|
-
return this.canvases.findIndex((c) =>
|
|
135
|
+
// Manifesto canvases have an id property, but let's be robust and check multiple possibilities
|
|
136
|
+
return this.canvases.findIndex((c) => {
|
|
137
|
+
const id = c.id ||
|
|
138
|
+
c['@id'] ||
|
|
139
|
+
(c.getCanvasId ? c.getCanvasId() : null) ||
|
|
140
|
+
(c.getId ? c.getId() : null);
|
|
141
|
+
return id === this.canvasId;
|
|
142
|
+
});
|
|
131
143
|
}
|
|
132
144
|
get hasNext() {
|
|
133
145
|
return this.currentCanvasIndex < this.canvases.length - 1;
|
|
@@ -447,104 +459,81 @@ export class ViewerState {
|
|
|
447
459
|
}
|
|
448
460
|
}
|
|
449
461
|
// ==================== PLUGIN STATE ====================
|
|
450
|
-
/** Registered plugins */
|
|
451
|
-
plugins = $state([]);
|
|
452
462
|
/** Plugin-registered menu buttons */
|
|
453
463
|
pluginMenuButtons = $state([]);
|
|
454
464
|
/** Plugin-registered panels */
|
|
455
465
|
pluginPanels = $state([]);
|
|
456
466
|
/** OpenSeadragon viewer instance (set by OSDViewer) */
|
|
457
|
-
osdViewer = $state(null);
|
|
467
|
+
osdViewer = $state.raw(null);
|
|
458
468
|
/** Event handlers for inter-plugin communication */
|
|
459
469
|
pluginEventHandlers = new Map();
|
|
460
470
|
// ==================== PLUGIN METHODS ====================
|
|
461
471
|
/**
|
|
462
|
-
*
|
|
472
|
+
* Register a plugin with this viewer instance.
|
|
473
|
+
* Accepts a simple PluginDef object.
|
|
463
474
|
*/
|
|
464
|
-
|
|
465
|
-
const
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
},
|
|
477
|
-
unregisterMenuButton(buttonId) {
|
|
478
|
-
self.pluginMenuButtons = self.pluginMenuButtons.filter((b) => b.id !== buttonId);
|
|
475
|
+
registerPlugin(def) {
|
|
476
|
+
const id = def.id || `plugin-${Math.random().toString(36).substr(2, 9)}`;
|
|
477
|
+
// Create reactive state for this plugin's panel
|
|
478
|
+
// Svelte 5's $state works fine in closures if consumed in reactive context
|
|
479
|
+
let isOpen = $state(false);
|
|
480
|
+
// Register Menu Button
|
|
481
|
+
const button = {
|
|
482
|
+
id: `${id}:toggle`,
|
|
483
|
+
icon: def.icon,
|
|
484
|
+
tooltip: def.name,
|
|
485
|
+
onClick: () => {
|
|
486
|
+
isOpen = !isOpen;
|
|
479
487
|
},
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
self.pluginEventHandlers.get(eventName).add(handler);
|
|
497
|
-
return () => {
|
|
498
|
-
self.pluginEventHandlers.get(eventName)?.delete(handler);
|
|
499
|
-
};
|
|
488
|
+
isActive: () => isOpen,
|
|
489
|
+
order: 200, // Default order for simple plugins
|
|
490
|
+
};
|
|
491
|
+
// Register Panel
|
|
492
|
+
const panel = {
|
|
493
|
+
id: `${id}:panel`,
|
|
494
|
+
component: def.panel,
|
|
495
|
+
position: def.position || 'left',
|
|
496
|
+
isVisible: () => isOpen,
|
|
497
|
+
props: {
|
|
498
|
+
...def.props,
|
|
499
|
+
// Pass isOpen state and closer to component
|
|
500
|
+
isOpen: isOpen,
|
|
501
|
+
close: () => {
|
|
502
|
+
isOpen = false;
|
|
503
|
+
},
|
|
500
504
|
},
|
|
501
505
|
};
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
console.warn(`[Triiiceratops] Plugin "${plugin.id}" already registered`);
|
|
509
|
-
return;
|
|
510
|
-
}
|
|
511
|
-
this.plugins = [...this.plugins, plugin];
|
|
512
|
-
plugin.onRegister(this.createPluginContext());
|
|
513
|
-
// If OSD already ready, notify immediately
|
|
514
|
-
if (this.osdViewer && plugin.onViewerReady) {
|
|
515
|
-
plugin.onViewerReady(this.osdViewer);
|
|
506
|
+
// Add directly to lists
|
|
507
|
+
this.pluginMenuButtons = [...this.pluginMenuButtons, button];
|
|
508
|
+
this.pluginPanels = [...this.pluginPanels, panel];
|
|
509
|
+
// Execute lifecycle hook if present
|
|
510
|
+
if (def.onInit) {
|
|
511
|
+
def.onInit(this);
|
|
516
512
|
}
|
|
517
513
|
}
|
|
518
514
|
/**
|
|
519
|
-
* Unregister a plugin by ID.
|
|
515
|
+
* Unregister a plugin's UI components by ID prefix.
|
|
516
|
+
* Note: This cleans up the menu button and panel, but doesn't remove listeners attached by the plugin itself
|
|
517
|
+
* since we don't have a handle on the plugin instance or its cleanup function anymore.
|
|
518
|
+
* Plugins should manage their own cleanup via component lifecycle (onDestroy) if possible.
|
|
520
519
|
*/
|
|
521
520
|
unregisterPlugin(pluginId) {
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
plugin.onDestroy?.();
|
|
525
|
-
this.plugins = this.plugins.filter((p) => p.id !== pluginId);
|
|
526
|
-
// Remove plugin's UI registrations
|
|
527
|
-
this.pluginMenuButtons = this.pluginMenuButtons.filter((b) => !b.id.startsWith(`${pluginId}:`));
|
|
528
|
-
this.pluginPanels = this.pluginPanels.filter((p) => !p.id.startsWith(`${pluginId}:`));
|
|
529
|
-
}
|
|
521
|
+
this.pluginMenuButtons = this.pluginMenuButtons.filter((b) => !b.id.startsWith(`${pluginId}:`));
|
|
522
|
+
this.pluginPanels = this.pluginPanels.filter((p) => !p.id.startsWith(`${pluginId}:`));
|
|
530
523
|
}
|
|
531
524
|
/**
|
|
532
|
-
*
|
|
525
|
+
* Notify that OSD viewer is ready.
|
|
526
|
+
* With the component-based system, we don't notify plugins individually.
|
|
527
|
+
* Instead, plugins should use the OSDViewer instance from context or listen for 'osd-ready' event (if we emitted one).
|
|
528
|
+
* But since we have direct access to osdViewer in this state, components can just react to it.
|
|
533
529
|
*/
|
|
534
530
|
notifyOSDReady(viewer) {
|
|
535
531
|
this.osdViewer = viewer;
|
|
536
|
-
for (const plugin of this.plugins) {
|
|
537
|
-
plugin.onViewerReady?.(viewer);
|
|
538
|
-
}
|
|
539
532
|
}
|
|
540
533
|
/**
|
|
541
|
-
*
|
|
534
|
+
* Cleanup everything.
|
|
542
535
|
*/
|
|
543
536
|
destroyAllPlugins() {
|
|
544
|
-
for (const plugin of this.plugins) {
|
|
545
|
-
plugin.onDestroy?.();
|
|
546
|
-
}
|
|
547
|
-
this.plugins = [];
|
|
548
537
|
this.pluginMenuButtons = [];
|
|
549
538
|
this.pluginPanels = [];
|
|
550
539
|
this.pluginEventHandlers.clear();
|