triiiceratops 0.8.1 → 0.9.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 (94) hide show
  1. package/dist/chunks/TriiiceratopsViewer-BGtsfUPF.js +10298 -0
  2. package/dist/chunks/openseadragon-BTypULhm.js +12427 -0
  3. package/dist/components/AnnotationOverlay.svelte +288 -0
  4. package/dist/components/AnnotationOverlay.svelte.d.ts +3 -0
  5. package/dist/components/CanvasNavigation.svelte +32 -0
  6. package/dist/components/CanvasNavigation.svelte.d.ts +11 -0
  7. package/dist/components/DemoHeader.svelte +703 -0
  8. package/dist/components/DemoHeader.svelte.d.ts +9 -0
  9. package/dist/components/FloatingMenu.svelte +208 -0
  10. package/dist/components/FloatingMenu.svelte.d.ts +3 -0
  11. package/dist/components/LeftFab.svelte +69 -0
  12. package/dist/components/LeftFab.svelte.d.ts +3 -0
  13. package/dist/components/MetadataDialog.svelte +151 -0
  14. package/dist/components/MetadataDialog.svelte.d.ts +3 -0
  15. package/dist/components/OSDViewer.svelte +260 -0
  16. package/dist/components/OSDViewer.svelte.d.ts +8 -0
  17. package/dist/components/SearchPanel.svelte +150 -0
  18. package/dist/components/SearchPanel.svelte.d.ts +3 -0
  19. package/dist/components/ThemeToggle.svelte +118 -0
  20. package/dist/components/ThemeToggle.svelte.d.ts +3 -0
  21. package/dist/components/ThumbnailGallery.svelte +601 -0
  22. package/dist/components/ThumbnailGallery.svelte.d.ts +36 -0
  23. package/dist/components/TriiiceratopsViewer.svelte +434 -0
  24. package/dist/components/TriiiceratopsViewer.svelte.d.ts +20 -0
  25. package/dist/components/TriiiceratopsViewerElement.svelte +139 -0
  26. package/dist/components/TriiiceratopsViewerElement.svelte.d.ts +27 -0
  27. package/dist/components/TriiiceratopsViewerElementImage.svelte +143 -0
  28. package/dist/components/TriiiceratopsViewerElementImage.svelte.d.ts +27 -0
  29. package/dist/custom-element-image.d.ts +1 -0
  30. package/dist/custom-element-image.js +2 -0
  31. package/dist/custom-element.d.ts +1 -0
  32. package/dist/custom-element.js +3 -0
  33. package/dist/{src/lib/index.d.ts → index.d.ts} +1 -0
  34. package/dist/index.js +10 -4480
  35. package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte +134 -0
  36. package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte.d.ts +10 -0
  37. package/dist/{src/lib/plugins → plugins}/image-manipulation/ImageManipulationPlugin.svelte.d.ts +2 -2
  38. package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.js +122 -0
  39. package/dist/{src/lib/plugins → plugins}/image-manipulation/filters.d.ts +1 -1
  40. package/dist/plugins/image-manipulation/filters.js +48 -0
  41. package/dist/plugins/image-manipulation/index.js +2 -0
  42. package/dist/plugins/image-manipulation/types.js +7 -0
  43. package/dist/state/i18n.svelte.d.ts +4 -0
  44. package/dist/state/i18n.svelte.js +18 -0
  45. package/dist/state/manifests.svelte.js +210 -0
  46. package/dist/state/manifests.test.d.ts +1 -0
  47. package/dist/state/manifests.test.js +242 -0
  48. package/dist/{src/lib/state → state}/viewer.svelte.d.ts +4 -4
  49. package/dist/state/viewer.svelte.js +693 -0
  50. package/dist/theme/colorUtils.js +196 -0
  51. package/dist/theme/colorUtils.test.d.ts +1 -0
  52. package/dist/theme/colorUtils.test.js +90 -0
  53. package/dist/theme/index.js +52 -0
  54. package/dist/{src/lib/theme → theme}/themeManager.d.ts +4 -1
  55. package/dist/theme/themeManager.js +177 -0
  56. package/dist/theme/types.js +40 -0
  57. package/dist/triiiceratops-bundle.js +4676 -0
  58. package/dist/triiiceratops-element-image.js +1 -1
  59. package/dist/triiiceratops-element.js +1 -1
  60. package/dist/types/config.js +1 -0
  61. package/dist/{src/lib/types → types}/plugin.d.ts +3 -3
  62. package/dist/types/plugin.js +36 -0
  63. package/dist/utils/annotationAdapter.js +354 -0
  64. package/dist/utils/annotationAdapter.test.d.ts +1 -0
  65. package/dist/utils/annotationAdapter.test.js +91 -0
  66. package/package.json +6 -5
  67. package/dist/chunks/TriiiceratopsViewer-CyamQrMe.js +0 -22698
  68. package/dist/plugin-De14WKQl.js +0 -546
  69. package/dist/plugins/image-manipulation.js +0 -454
  70. package/dist/src/lib/components/AnnotationOverlay.svelte.d.ts +0 -1
  71. package/dist/src/lib/components/CanvasNavigation.svelte.d.ts +0 -1
  72. package/dist/src/lib/components/FloatingMenu.svelte.d.ts +0 -1
  73. package/dist/src/lib/components/LeftFab.svelte.d.ts +0 -1
  74. package/dist/src/lib/components/MetadataDialog.svelte.d.ts +0 -1
  75. package/dist/src/lib/components/OSDViewer.svelte.d.ts +0 -1
  76. package/dist/src/lib/components/SearchPanel.svelte.d.ts +0 -1
  77. package/dist/src/lib/components/ThumbnailGallery.svelte.d.ts +0 -1
  78. package/dist/src/lib/components/TriiiceratopsViewer.svelte.d.ts +0 -1
  79. package/dist/src/lib/custom-element-image.d.ts +0 -0
  80. package/dist/src/lib/custom-element.d.ts +0 -0
  81. package/dist/src/lib/paraglide/messages/de.d.ts +0 -96
  82. package/dist/src/lib/paraglide/messages/en.d.ts +0 -96
  83. package/dist/src/lib/paraglide/messages.d.ts +0 -272
  84. package/dist/src/lib/paraglide/runtime.d.ts +0 -52
  85. package/dist/src/lib/plugins/image-manipulation/ImageManipulationPanel.svelte.d.ts +0 -1
  86. package/dist/src/lib/state/i18n.svelte.d.ts +0 -5
  87. /package/dist/{src/lib/plugins → plugins}/image-manipulation/index.d.ts +0 -0
  88. /package/dist/{src/lib/plugins → plugins}/image-manipulation/types.d.ts +0 -0
  89. /package/dist/{src/lib/state → state}/manifests.svelte.d.ts +0 -0
  90. /package/dist/{src/lib/theme → theme}/colorUtils.d.ts +0 -0
  91. /package/dist/{src/lib/theme → theme}/index.d.ts +0 -0
  92. /package/dist/{src/lib/theme → theme}/types.d.ts +0 -0
  93. /package/dist/{src/lib/types → types}/config.d.ts +0 -0
  94. /package/dist/{src/lib/utils → utils}/annotationAdapter.d.ts +0 -0
@@ -0,0 +1,242 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
23
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
49
+ import { ManifestsState } from "./manifests.svelte";
50
+ import * as manifesto from "manifesto.js";
51
+ // Mock manifesto.js since it's an external dependency
52
+ vi.mock("manifesto.js", function (importOriginal) { return __awaiter(void 0, void 0, void 0, function () {
53
+ var actual;
54
+ return __generator(this, function (_a) {
55
+ switch (_a.label) {
56
+ case 0: return [4 /*yield*/, importOriginal()];
57
+ case 1:
58
+ actual = _a.sent();
59
+ return [2 /*return*/, __assign(__assign({}, actual), { parseManifest: vi.fn(function (json) {
60
+ // Minimal mock of a manifesto object
61
+ return {
62
+ getSequences: function () { return [
63
+ {
64
+ getCanvases: function () { return [{ id: "canvas1" }]; },
65
+ getCanvasById: function (id) {
66
+ if (id === "canvas1") {
67
+ return {
68
+ id: "canvas1",
69
+ __jsonld: {
70
+ otherContent: [
71
+ {
72
+ "@id": "http://example.org/list1",
73
+ "@type": "sc:AnnotationList",
74
+ },
75
+ ],
76
+ annotations: [
77
+ // v3 style
78
+ {
79
+ id: "http://example.org/list2",
80
+ type: "AnnotationPage",
81
+ },
82
+ ],
83
+ },
84
+ };
85
+ }
86
+ return null;
87
+ },
88
+ },
89
+ ]; },
90
+ };
91
+ }) })];
92
+ }
93
+ });
94
+ }); });
95
+ describe("ManifestsState", function () {
96
+ var state;
97
+ var mockFetch = vi.fn();
98
+ beforeEach(function () {
99
+ vi.stubGlobal("fetch", mockFetch);
100
+ state = new ManifestsState();
101
+ mockFetch.mockReset();
102
+ });
103
+ afterEach(function () {
104
+ vi.restoreAllMocks();
105
+ });
106
+ describe("fetchManifest", function () {
107
+ it("should fetch and store a manifest", function () { return __awaiter(void 0, void 0, void 0, function () {
108
+ var mockManifest;
109
+ return __generator(this, function (_a) {
110
+ switch (_a.label) {
111
+ case 0:
112
+ mockManifest = {
113
+ "@id": "http://example.org/manifest",
114
+ label: "Test Manifest",
115
+ };
116
+ mockFetch.mockResolvedValueOnce({
117
+ ok: true,
118
+ json: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
119
+ return [2 /*return*/, mockManifest];
120
+ }); }); },
121
+ });
122
+ return [4 /*yield*/, state.fetchManifest("http://example.org/manifest")];
123
+ case 1:
124
+ _a.sent();
125
+ expect(mockFetch).toHaveBeenCalledWith("http://example.org/manifest");
126
+ expect(state.manifests["http://example.org/manifest"]).toBeDefined();
127
+ expect(state.manifests["http://example.org/manifest"].json).toEqual(mockManifest);
128
+ expect(state.manifests["http://example.org/manifest"].isFetching).toBe(false);
129
+ expect(manifesto.parseManifest).toHaveBeenCalledWith(mockManifest);
130
+ return [2 /*return*/];
131
+ }
132
+ });
133
+ }); });
134
+ it("should handle fetch errors", function () { return __awaiter(void 0, void 0, void 0, function () {
135
+ return __generator(this, function (_a) {
136
+ switch (_a.label) {
137
+ case 0:
138
+ mockFetch.mockRejectedValueOnce(new Error("Network Error"));
139
+ return [4 /*yield*/, state.fetchManifest("http://example.org/error")];
140
+ case 1:
141
+ _a.sent();
142
+ expect(state.manifests["http://example.org/error"].error).toBe("Network Error");
143
+ expect(state.manifests["http://example.org/error"].isFetching).toBe(false);
144
+ return [2 /*return*/];
145
+ }
146
+ });
147
+ }); });
148
+ it("should not fetch if already fetched", function () { return __awaiter(void 0, void 0, void 0, function () {
149
+ return __generator(this, function (_a) {
150
+ switch (_a.label) {
151
+ case 0:
152
+ // Prime the state
153
+ state.manifests["http://example.org/cached"] = {
154
+ isFetching: false,
155
+ json: {},
156
+ };
157
+ return [4 /*yield*/, state.fetchManifest("http://example.org/cached")];
158
+ case 1:
159
+ _a.sent();
160
+ expect(mockFetch).not.toHaveBeenCalled();
161
+ return [2 /*return*/];
162
+ }
163
+ });
164
+ }); });
165
+ });
166
+ describe("getCanvases", function () {
167
+ it("should return canvases from parsed manifest", function () { return __awaiter(void 0, void 0, void 0, function () {
168
+ var canvases;
169
+ return __generator(this, function (_a) {
170
+ // Mock internal state directly to avoid fetch overhead
171
+ state.manifests["http://example.org/manifest"] = {
172
+ manifesto: {
173
+ getSequences: function () { return [
174
+ {
175
+ getCanvases: function () { return ["mockCanvas1", "mockCanvas2"]; },
176
+ },
177
+ ]; },
178
+ },
179
+ };
180
+ canvases = state.getCanvases("http://example.org/manifest");
181
+ expect(canvases).toEqual(["mockCanvas1", "mockCanvas2"]);
182
+ return [2 /*return*/];
183
+ });
184
+ }); });
185
+ it("should return empty array if manifest not found", function () {
186
+ var canvases = state.getCanvases("http://example.org/missing");
187
+ expect(canvases).toEqual([]);
188
+ });
189
+ });
190
+ describe("manualGetAnnotations", function () {
191
+ it("should extract annotations and trigger fetch for external lists", function () { return __awaiter(void 0, void 0, void 0, function () {
192
+ var annos;
193
+ return __generator(this, function (_a) {
194
+ switch (_a.label) {
195
+ case 0:
196
+ // Setup mock state with a manifest that has a canvas
197
+ state.manifests["http://example.org/manifest"] = {
198
+ manifesto: {
199
+ getSequences: function () { return [
200
+ {
201
+ getCanvasById: function () { return ({
202
+ __jsonld: {
203
+ otherContent: [{ "@id": "http://example.org/list1" }],
204
+ },
205
+ }); },
206
+ },
207
+ ]; },
208
+ },
209
+ };
210
+ // Mock the fetch for the annotation list
211
+ mockFetch.mockResolvedValue({
212
+ ok: true,
213
+ json: function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
214
+ return [2 /*return*/, ({ resources: [{ "@id": "anno1" }] })];
215
+ }); }); },
216
+ });
217
+ // First call triggers fetch
218
+ // manualGetAnnotations calls fetchAnnotationList which is async, but manualGetAnnotations itself is synchronous and returns partial data
219
+ state.manualGetAnnotations("http://example.org/manifest", "canvas1");
220
+ // We need to wait for the async fetchAnnotationList to complete.
221
+ // Since it's not returned, we can wait a tick or use `vi.waitFor` if available,
222
+ // but simpler here is just to await a small delay since we are mocking.
223
+ return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 0); })];
224
+ case 1:
225
+ // We need to wait for the async fetchAnnotationList to complete.
226
+ // Since it's not returned, we can wait a tick or use `vi.waitFor` if available,
227
+ // but simpler here is just to await a small delay since we are mocking.
228
+ _a.sent();
229
+ expect(mockFetch).toHaveBeenCalledWith("http://example.org/list1");
230
+ // Simulate update after fetch (in real app this is reactive, here we manually update state)
231
+ state.manifests["http://example.org/list1"] = {
232
+ json: { resources: [{ "@id": "anno1" }] },
233
+ };
234
+ annos = state.manualGetAnnotations("http://example.org/manifest", "canvas1");
235
+ expect(annos).toHaveLength(1);
236
+ expect(annos[0]["@id"]).toBe("anno1");
237
+ return [2 /*return*/];
238
+ }
239
+ });
240
+ }); });
241
+ });
242
+ });
@@ -1,5 +1,5 @@
1
- import { ViewerConfig } from '../types/config';
2
- import { TriiiceratopsPlugin, PluginMenuButton, PluginPanel } from '../types/plugin';
1
+ import type { ViewerConfig } from '../types/config';
2
+ import type { TriiiceratopsPlugin, PluginMenuButton, PluginPanel } 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.
@@ -43,8 +43,8 @@ export declare class ViewerState {
43
43
  x: number;
44
44
  y: number;
45
45
  };
46
- dragOverSide: "left" | "right" | "top" | "bottom" | null;
47
- galleryCenterPanelRect: DOMRect | null;
46
+ dragOverSide: "left" | "top" | "bottom" | "right";
47
+ galleryCenterPanelRect: DOMRect;
48
48
  /**
49
49
  * Event target for dispatching CustomEvents.
50
50
  * Only set by TriiiceratopsViewerElement (web component build).