triiiceratops 0.11.2 → 0.12.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.
Files changed (39) hide show
  1. package/dist/{ArrowCounterClockwise-B_hB6fl1.js → ArrowCounterClockwise-CM9mGGcp.js} +1 -1
  2. package/dist/X-Bn7S7vUL.js +963 -0
  3. package/dist/{annotation_tool_point-rZvdAtGa.js → annotation_tool_point-LoRp_nrI.js} +1 -1
  4. package/dist/components/DemoHeader.svelte +69 -0
  5. package/dist/components/OSDViewer.svelte +31 -1
  6. package/dist/components/ThumbnailGallery.svelte +226 -35
  7. package/dist/components/Toolbar.svelte +102 -3
  8. package/dist/components/TriiiceratopsViewer.svelte +37 -12
  9. package/dist/{image_filters_reset-CAUhlDWt.js → image_filters_reset-CmWuQiOc.js} +1 -1
  10. package/dist/paraglide/messages/_index.d.ts +9 -0
  11. package/dist/paraglide/messages/_index.js +10 -1
  12. package/dist/paraglide/messages/settings_toggle_show_viewing_mode.d.ts +4 -0
  13. package/dist/paraglide/messages/settings_toggle_show_viewing_mode.js +33 -0
  14. package/dist/paraglide/messages/show_mode_toggle.d.ts +4 -0
  15. package/dist/paraglide/messages/show_mode_toggle.js +33 -0
  16. package/dist/paraglide/messages/toggle_single_page_mode.d.ts +4 -0
  17. package/dist/paraglide/messages/toggle_single_page_mode.js +33 -0
  18. package/dist/paraglide/messages/toggle_two_page_mode.d.ts +4 -0
  19. package/dist/paraglide/messages/toggle_two_page_mode.js +33 -0
  20. package/dist/paraglide/messages/two_page_mode.d.ts +4 -0
  21. package/dist/paraglide/messages/two_page_mode.js +33 -0
  22. package/dist/paraglide/messages/viewing_mode_individuals.d.ts +4 -0
  23. package/dist/paraglide/messages/viewing_mode_individuals.js +33 -0
  24. package/dist/paraglide/messages/viewing_mode_label.d.ts +4 -0
  25. package/dist/paraglide/messages/viewing_mode_label.js +33 -0
  26. package/dist/paraglide/messages/viewing_mode_paged.d.ts +4 -0
  27. package/dist/paraglide/messages/viewing_mode_paged.js +33 -0
  28. package/dist/paraglide/messages/viewing_mode_shift_pairing.d.ts +4 -0
  29. package/dist/paraglide/messages/viewing_mode_shift_pairing.js +33 -0
  30. package/dist/plugins/annotation-editor.js +3 -3
  31. package/dist/plugins/image-manipulation.js +3 -3
  32. package/dist/state/viewer.svelte.d.ts +18 -0
  33. package/dist/state/viewer.svelte.js +142 -8
  34. package/dist/triiiceratops-bundle.js +3047 -2511
  35. package/dist/triiiceratops-element.iife.js +25 -25
  36. package/dist/triiiceratops.css +1 -1
  37. package/dist/types/config.d.ts +33 -0
  38. package/package.json +1 -1
  39. package/dist/X-Boj9jj2h.js +0 -890
@@ -24,6 +24,17 @@ export class ViewerState {
24
24
  get showZoomControls() {
25
25
  return this.config.showZoomControls ?? true;
26
26
  }
27
+ get galleryFixedHeight() {
28
+ return this.config.gallery?.fixedHeight ?? 120;
29
+ }
30
+ get viewingMode() {
31
+ return this.config.viewingMode ?? 'individuals';
32
+ }
33
+ set viewingMode(value) {
34
+ this.config.viewingMode = value;
35
+ }
36
+ // Pairing offset for paged mode: 0 = default (pairs start at 1+2), 1 = shifted (page 1 alone, pairs start at 2+3)
37
+ pagedOffset = $state(0);
27
38
  // Gallery State (Lifted for persistence during re-docking)
28
39
  galleryPosition = $state({ x: 20, y: 100 });
29
40
  gallerySize = $state({ width: 300, height: 400 });
@@ -75,6 +86,9 @@ export class ViewerState {
75
86
  searchQuery: this.searchQuery,
76
87
  isFullScreen: this.isFullScreen,
77
88
  dockSide: this.dockSide,
89
+ viewingMode: this.viewingMode,
90
+ galleryPosition: this.galleryPosition,
91
+ gallerySize: this.gallerySize,
78
92
  };
79
93
  }
80
94
  /**
@@ -142,23 +156,61 @@ export class ViewerState {
142
156
  });
143
157
  }
144
158
  get hasNext() {
145
- return this.currentCanvasIndex < this.canvases.length - 1;
159
+ if (this.viewingMode === 'paged') {
160
+ // Account for paged offset: with offset 1, page 1 is single, pairs start at 2+3
161
+ const singlePages = this.pagedOffset;
162
+ if (this.currentCanvasIndex < singlePages) {
163
+ return this.currentCanvasIndex < this.canvases.length - 1;
164
+ }
165
+ return this.currentCanvasIndex < this.canvases.length - 2;
166
+ }
167
+ else {
168
+ return this.currentCanvasIndex < this.canvases.length - 1;
169
+ }
146
170
  }
147
171
  get hasPrevious() {
148
172
  return this.currentCanvasIndex > 0;
149
173
  }
150
174
  nextCanvas() {
151
175
  if (this.hasNext) {
152
- const nextIndex = this.currentCanvasIndex + 1;
153
- const canvas = this.canvases[nextIndex];
154
- this.setCanvas(canvas.id);
176
+ if (this.viewingMode === 'paged') {
177
+ // Single pages at the start: pagedOffset (default 0, shifted = 1)
178
+ const singlePages = this.pagedOffset;
179
+ const nextIndex = this.currentCanvasIndex < singlePages
180
+ ? this.currentCanvasIndex + 1
181
+ : this.currentCanvasIndex + 2;
182
+ const canvas = this.canvases[nextIndex];
183
+ this.setCanvas(canvas.id);
184
+ }
185
+ else {
186
+ const nextIndex = this.currentCanvasIndex + 1;
187
+ const canvas = this.canvases[nextIndex];
188
+ this.setCanvas(canvas.id);
189
+ }
155
190
  }
156
191
  }
157
192
  previousCanvas() {
158
193
  if (this.hasPrevious) {
159
- const prevIndex = this.currentCanvasIndex - 1;
160
- const canvas = this.canvases[prevIndex];
161
- this.setCanvas(canvas.id);
194
+ if (this.viewingMode === 'paged') {
195
+ // Single pages at the start: pagedOffset (default 0, shifted = 1)
196
+ const singlePages = this.pagedOffset;
197
+ let prevIndex;
198
+ if (this.currentCanvasIndex <= singlePages) {
199
+ // Going back within single pages or to a single page
200
+ prevIndex = this.currentCanvasIndex - 1;
201
+ }
202
+ else {
203
+ // Going back in paired pages, but don't go past the last single page
204
+ prevIndex = Math.max(this.currentCanvasIndex - 2, singlePages);
205
+ }
206
+ const canvas = this.canvases[prevIndex];
207
+ this.setCanvas(canvas.id);
208
+ }
209
+ else {
210
+ const prevIndex = this.currentCanvasIndex - 1;
211
+ const canvas = this.canvases[prevIndex];
212
+ this.setCanvas(canvas.id);
213
+ }
162
214
  }
163
215
  }
164
216
  zoomIn() {
@@ -190,6 +242,10 @@ export class ViewerState {
190
242
  if (newConfig.toolbarOpen !== undefined) {
191
243
  this.toolbarOpen = newConfig.toolbarOpen;
192
244
  }
245
+ if (newConfig.viewingMode) {
246
+ // direct assignment works because of the setter
247
+ this.viewingMode = newConfig.viewingMode;
248
+ }
193
249
  if (newConfig.gallery) {
194
250
  if (newConfig.gallery.open !== undefined) {
195
251
  this.showThumbnailGallery = newConfig.gallery.open;
@@ -197,6 +253,18 @@ export class ViewerState {
197
253
  if (newConfig.gallery.dockPosition !== undefined) {
198
254
  this.dockSide = newConfig.gallery.dockPosition;
199
255
  }
256
+ if (newConfig.gallery.width !== undefined) {
257
+ this.gallerySize.width = newConfig.gallery.width;
258
+ }
259
+ if (newConfig.gallery.height !== undefined) {
260
+ this.gallerySize.height = newConfig.gallery.height;
261
+ }
262
+ if (newConfig.gallery.x !== undefined) {
263
+ this.galleryPosition.x = newConfig.gallery.x;
264
+ }
265
+ if (newConfig.gallery.y !== undefined) {
266
+ this.galleryPosition.y = newConfig.gallery.y;
267
+ }
200
268
  }
201
269
  if (newConfig.search) {
202
270
  if (newConfig.search.open !== undefined) {
@@ -263,6 +331,39 @@ export class ViewerState {
263
331
  toggleMetadataDialog() {
264
332
  this.showMetadataDialog = !this.showMetadataDialog;
265
333
  }
334
+ setViewingMode(mode) {
335
+ this.viewingMode = mode;
336
+ if (mode === 'paged') {
337
+ const singlePages = this.pagedOffset;
338
+ // If we're past the single pages, check if we're on a right-hand page
339
+ if (this.currentCanvasIndex >= singlePages) {
340
+ // Calculate position relative to where pairs start
341
+ const pairPosition = (this.currentCanvasIndex - singlePages) % 2;
342
+ if (pairPosition === 1) {
343
+ // We're on a right-hand page, move back one
344
+ const newIndex = this.currentCanvasIndex - 1;
345
+ const canvas = this.canvases[newIndex];
346
+ this.setCanvas(canvas.id);
347
+ }
348
+ }
349
+ }
350
+ this.dispatchStateChange();
351
+ }
352
+ togglePagedOffset() {
353
+ this.pagedOffset = this.pagedOffset === 0 ? 1 : 0;
354
+ // Adjust current canvas position if needed
355
+ const singlePages = this.pagedOffset;
356
+ if (this.currentCanvasIndex >= singlePages) {
357
+ const pairPosition = (this.currentCanvasIndex - singlePages) % 2;
358
+ if (pairPosition === 1) {
359
+ // We're now on a right-hand page after the shift, move back
360
+ const newIndex = this.currentCanvasIndex - 1;
361
+ const canvas = this.canvases[newIndex];
362
+ this.setCanvas(canvas.id);
363
+ }
364
+ }
365
+ this.dispatchStateChange();
366
+ }
266
367
  searchQuery = $state('');
267
368
  pendingSearchQuery = $state(null);
268
369
  searchResults = $state([]);
@@ -277,10 +378,43 @@ export class ViewerState {
277
378
  this.dispatchStateChange();
278
379
  }
279
380
  searchAnnotations = $state([]);
381
+ /**
382
+ * This function now accounts for two-page mode when returning current canvas search annotations offset accordingly.
383
+ */
280
384
  get currentCanvasSearchAnnotations() {
281
385
  if (!this.canvasId)
282
386
  return [];
283
- return this.searchAnnotations.filter((a) => a.canvasId === this.canvasId);
387
+ if (this.viewingMode === 'paged') {
388
+ let annotations = this.searchAnnotations.filter((a) => a.canvasId === this.canvasId);
389
+ const currentIndex = this.currentCanvasIndex;
390
+ const singlePages = this.pagedOffset;
391
+ // Only include next canvas annotations if we're in a two-page spread
392
+ if (currentIndex >= singlePages) {
393
+ const nextIndex = currentIndex + 1;
394
+ if (nextIndex < this.canvases.length) {
395
+ const nextCanvas = this.canvases[nextIndex];
396
+ const nextCanvasId = nextCanvas.id || nextCanvas['@id'];
397
+ const xOffset = 1.025; // account for small gap between pages
398
+ const annoOffset = this.canvases[currentIndex].getWidth() * xOffset;
399
+ const nextAnnotations = this.searchAnnotations.filter((a) => a.canvasId === nextCanvasId);
400
+ // update x coordinates for display on the right side in two-page mode
401
+ const nextAnnotationsUpdated = nextAnnotations.map((a) => {
402
+ const parts = a.on.split('#xywh=');
403
+ const coords = parts[1].split(',').map(Number);
404
+ const shiftedX = coords[0] + annoOffset;
405
+ return {
406
+ ...a,
407
+ on: `${parts[0]}#xywh=${shiftedX},${coords[1]},${coords[2]},${coords[3]}`,
408
+ };
409
+ });
410
+ annotations = annotations.concat(nextAnnotationsUpdated);
411
+ }
412
+ }
413
+ return annotations;
414
+ }
415
+ else {
416
+ return this.searchAnnotations.filter((a) => a.canvasId === this.canvasId);
417
+ }
284
418
  }
285
419
  async search(query) {
286
420
  this.dispatchStateChange();