triiiceratops 0.8.2 → 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 (89) hide show
  1. package/dist/components/AnnotationOverlay.svelte +288 -0
  2. package/dist/components/AnnotationOverlay.svelte.d.ts +3 -0
  3. package/dist/components/CanvasNavigation.svelte +32 -0
  4. package/dist/components/CanvasNavigation.svelte.d.ts +11 -0
  5. package/dist/components/DemoHeader.svelte +703 -0
  6. package/dist/components/DemoHeader.svelte.d.ts +9 -0
  7. package/dist/components/FloatingMenu.svelte +208 -0
  8. package/dist/components/FloatingMenu.svelte.d.ts +3 -0
  9. package/dist/components/LeftFab.svelte +69 -0
  10. package/dist/components/LeftFab.svelte.d.ts +3 -0
  11. package/dist/components/MetadataDialog.svelte +151 -0
  12. package/dist/components/MetadataDialog.svelte.d.ts +3 -0
  13. package/dist/components/OSDViewer.svelte +260 -0
  14. package/dist/components/OSDViewer.svelte.d.ts +8 -0
  15. package/dist/components/SearchPanel.svelte +150 -0
  16. package/dist/components/SearchPanel.svelte.d.ts +3 -0
  17. package/dist/components/ThemeToggle.svelte +118 -0
  18. package/dist/components/ThemeToggle.svelte.d.ts +3 -0
  19. package/dist/components/ThumbnailGallery.svelte +601 -0
  20. package/dist/components/ThumbnailGallery.svelte.d.ts +36 -0
  21. package/dist/components/TriiiceratopsViewer.svelte +434 -0
  22. package/dist/components/TriiiceratopsViewer.svelte.d.ts +20 -0
  23. package/dist/components/TriiiceratopsViewerElement.svelte +139 -0
  24. package/dist/components/TriiiceratopsViewerElement.svelte.d.ts +27 -0
  25. package/dist/components/TriiiceratopsViewerElementImage.svelte +143 -0
  26. package/dist/components/TriiiceratopsViewerElementImage.svelte.d.ts +27 -0
  27. package/dist/custom-element-image.d.ts +1 -0
  28. package/dist/custom-element-image.js +2 -0
  29. package/dist/custom-element.d.ts +1 -0
  30. package/dist/custom-element.js +3 -0
  31. package/dist/{src/lib/index.d.ts → index.d.ts} +1 -0
  32. package/dist/index.js +10 -4153
  33. package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte +134 -0
  34. package/dist/plugins/image-manipulation/ImageManipulationPanel.svelte.d.ts +10 -0
  35. package/dist/{src/lib/plugins → plugins}/image-manipulation/ImageManipulationPlugin.svelte.d.ts +2 -2
  36. package/dist/plugins/image-manipulation/ImageManipulationPlugin.svelte.js +122 -0
  37. package/dist/{src/lib/plugins → plugins}/image-manipulation/filters.d.ts +1 -1
  38. package/dist/plugins/image-manipulation/filters.js +48 -0
  39. package/dist/plugins/image-manipulation/index.js +2 -0
  40. package/dist/plugins/image-manipulation/types.js +7 -0
  41. package/dist/state/i18n.svelte.d.ts +4 -0
  42. package/dist/state/i18n.svelte.js +18 -0
  43. package/dist/state/manifests.svelte.js +210 -0
  44. package/dist/state/manifests.test.d.ts +1 -0
  45. package/dist/state/manifests.test.js +242 -0
  46. package/dist/{src/lib/state → state}/viewer.svelte.d.ts +4 -4
  47. package/dist/state/viewer.svelte.js +693 -0
  48. package/dist/theme/colorUtils.js +196 -0
  49. package/dist/theme/colorUtils.test.d.ts +1 -0
  50. package/dist/theme/colorUtils.test.js +90 -0
  51. package/dist/theme/index.js +52 -0
  52. package/dist/{src/lib/theme → theme}/themeManager.d.ts +4 -1
  53. package/dist/theme/themeManager.js +177 -0
  54. package/dist/theme/types.js +40 -0
  55. package/dist/triiiceratops-bundle.js +4676 -0
  56. package/dist/types/config.js +1 -0
  57. package/dist/{src/lib/types → types}/plugin.d.ts +3 -3
  58. package/dist/types/plugin.js +36 -0
  59. package/dist/utils/annotationAdapter.js +354 -0
  60. package/dist/utils/annotationAdapter.test.d.ts +1 -0
  61. package/dist/utils/annotationAdapter.test.js +91 -0
  62. package/package.json +6 -5
  63. package/dist/plugin-CHYleMsW.js +0 -538
  64. package/dist/plugins/image-manipulation.js +0 -411
  65. package/dist/src/lib/components/AnnotationOverlay.svelte.d.ts +0 -1
  66. package/dist/src/lib/components/CanvasNavigation.svelte.d.ts +0 -1
  67. package/dist/src/lib/components/FloatingMenu.svelte.d.ts +0 -1
  68. package/dist/src/lib/components/LeftFab.svelte.d.ts +0 -1
  69. package/dist/src/lib/components/MetadataDialog.svelte.d.ts +0 -1
  70. package/dist/src/lib/components/OSDViewer.svelte.d.ts +0 -1
  71. package/dist/src/lib/components/SearchPanel.svelte.d.ts +0 -1
  72. package/dist/src/lib/components/ThumbnailGallery.svelte.d.ts +0 -1
  73. package/dist/src/lib/components/TriiiceratopsViewer.svelte.d.ts +0 -1
  74. package/dist/src/lib/custom-element-image.d.ts +0 -0
  75. package/dist/src/lib/custom-element.d.ts +0 -0
  76. package/dist/src/lib/paraglide/messages/de.d.ts +0 -96
  77. package/dist/src/lib/paraglide/messages/en.d.ts +0 -96
  78. package/dist/src/lib/paraglide/messages.d.ts +0 -272
  79. package/dist/src/lib/paraglide/runtime.d.ts +0 -52
  80. package/dist/src/lib/plugins/image-manipulation/ImageManipulationPanel.svelte.d.ts +0 -1
  81. package/dist/src/lib/state/i18n.svelte.d.ts +0 -5
  82. /package/dist/{src/lib/plugins → plugins}/image-manipulation/index.d.ts +0 -0
  83. /package/dist/{src/lib/plugins → plugins}/image-manipulation/types.d.ts +0 -0
  84. /package/dist/{src/lib/state → state}/manifests.svelte.d.ts +0 -0
  85. /package/dist/{src/lib/theme → theme}/colorUtils.d.ts +0 -0
  86. /package/dist/{src/lib/theme → theme}/index.d.ts +0 -0
  87. /package/dist/{src/lib/theme → theme}/types.d.ts +0 -0
  88. /package/dist/{src/lib/types → types}/config.d.ts +0 -0
  89. /package/dist/{src/lib/utils → utils}/annotationAdapter.d.ts +0 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -1,6 +1,6 @@
1
- import { Component } from 'svelte';
2
- import { default as OpenSeadragon } from 'openseadragon';
3
- import { ViewerState } from '../state/viewer.svelte';
1
+ import type { Component } from 'svelte';
2
+ import type OpenSeadragon from 'openseadragon';
3
+ import type { ViewerState } from '../state/viewer.svelte';
4
4
  /**
5
5
  * Context object passed to plugins during registration.
6
6
  * This is the stable public API that plugins depend on.
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Optional base class providing common plugin functionality.
3
+ */
4
+ var BasePlugin = /** @class */ (function () {
5
+ function BasePlugin() {
6
+ this.context = null;
7
+ }
8
+ BasePlugin.prototype.onRegister = function (context) {
9
+ this.context = context;
10
+ };
11
+ BasePlugin.prototype.onDestroy = function () {
12
+ this.context = null;
13
+ };
14
+ Object.defineProperty(BasePlugin.prototype, "viewerState", {
15
+ /** Convenience getter for ViewerState */
16
+ get: function () {
17
+ if (!this.context) {
18
+ throw new Error("Plugin ".concat(this.id, " accessed viewerState before registration"));
19
+ }
20
+ return this.context.viewerState;
21
+ },
22
+ enumerable: false,
23
+ configurable: true
24
+ });
25
+ Object.defineProperty(BasePlugin.prototype, "osdViewer", {
26
+ /** Convenience getter for OSD viewer */
27
+ get: function () {
28
+ var _a, _b;
29
+ return (_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.getOSDViewer()) !== null && _b !== void 0 ? _b : null;
30
+ },
31
+ enumerable: false,
32
+ configurable: true
33
+ });
34
+ return BasePlugin;
35
+ }());
36
+ export { BasePlugin };
@@ -0,0 +1,354 @@
1
+ /**
2
+ * Helper to extract ID from annotation object
3
+ * Handles Manifesto objects and raw JSON
4
+ */
5
+ function getAnnotationId(anno) {
6
+ return anno.id || anno['@id'] || (typeof anno.getId === 'function' ? anno.getId() : '');
7
+ }
8
+ /**
9
+ * Parse xywh media fragment from target string
10
+ * Format: "canvas-id#xywh=x,y,w,h"
11
+ */
12
+ function parseXywh(targetStr) {
13
+ if (!targetStr)
14
+ return null;
15
+ var match = targetStr.match(/xywh=(\d+),(\d+),(\d+),(\d+)/);
16
+ if (match) {
17
+ return {
18
+ x: parseInt(match[1], 10),
19
+ y: parseInt(match[2], 10),
20
+ w: parseInt(match[3], 10),
21
+ h: parseInt(match[4], 10),
22
+ };
23
+ }
24
+ return null;
25
+ }
26
+ /**
27
+ * Extract target geometry from various annotation formats
28
+ */
29
+ function extractGeometry(annotation) {
30
+ // Try to find SVG selector first
31
+ var svgSelector = findSvgSelector(annotation);
32
+ if (svgSelector) {
33
+ return convertSvgToPolygon(svgSelector);
34
+ }
35
+ // Extract xywh from target
36
+ var xywh = extractXywhFromTarget(annotation);
37
+ if (xywh) {
38
+ return {
39
+ type: 'RECTANGLE',
40
+ x: xywh.x,
41
+ y: xywh.y,
42
+ w: xywh.w,
43
+ h: xywh.h,
44
+ };
45
+ }
46
+ return null;
47
+ }
48
+ /**
49
+ * Find SVG selector in annotation target
50
+ */
51
+ function findSvgSelector(annotation) {
52
+ var _a, _b;
53
+ // Try Manifesto method
54
+ if (typeof annotation.getTarget === 'function') {
55
+ // For Manifesto, check raw JSON for SVG
56
+ var rawOn = ((_a = annotation.__jsonld) === null || _a === void 0 ? void 0 : _a.on) || ((_b = annotation.__jsonld) === null || _b === void 0 ? void 0 : _b.target);
57
+ if (rawOn) {
58
+ return extractSvgFromTarget(rawOn);
59
+ }
60
+ }
61
+ // Check common locations in raw JSON
62
+ var target = annotation.target || annotation.on;
63
+ if (target) {
64
+ return extractSvgFromTarget(target);
65
+ }
66
+ return null;
67
+ }
68
+ /**
69
+ * Extract SVG from target object/array
70
+ */
71
+ function extractSvgFromTarget(target) {
72
+ if (!target)
73
+ return null;
74
+ // Handle array of targets
75
+ if (Array.isArray(target)) {
76
+ for (var _i = 0, target_1 = target; _i < target_1.length; _i++) {
77
+ var t = target_1[_i];
78
+ var svg = extractSvgValue(t);
79
+ if (svg)
80
+ return svg;
81
+ }
82
+ }
83
+ else {
84
+ return extractSvgValue(target);
85
+ }
86
+ return null;
87
+ }
88
+ /**
89
+ * Extract SVG value from single target object
90
+ */
91
+ function extractSvgValue(target) {
92
+ var _a;
93
+ if (!target)
94
+ return null;
95
+ // Check for SvgSelector
96
+ var selector = target.selector || target;
97
+ if ((selector === null || selector === void 0 ? void 0 : selector.type) === 'SvgSelector' && selector.value) {
98
+ return selector.value;
99
+ }
100
+ // Check item (sometimes nested)
101
+ if (((_a = selector === null || selector === void 0 ? void 0 : selector.item) === null || _a === void 0 ? void 0 : _a.type) === 'SvgSelector' && selector.item.value) {
102
+ return selector.item.value;
103
+ }
104
+ return null;
105
+ }
106
+ /**
107
+ * Convert SVG string to POLYGON geometry
108
+ * Parses points from SVG path or polygon element
109
+ */
110
+ function convertSvgToPolygon(svgString) {
111
+ try {
112
+ var parser = new DOMParser();
113
+ var doc = parser.parseFromString(svgString, 'image/svg+xml');
114
+ if (doc.documentElement.nodeName === 'parsererror') {
115
+ console.warn('Failed to parse SVG selector:', svgString);
116
+ return null;
117
+ }
118
+ var points = [];
119
+ // Extract points from polygon elements
120
+ var polygons = doc.querySelectorAll('polygon');
121
+ for (var _i = 0, polygons_1 = polygons; _i < polygons_1.length; _i++) {
122
+ var poly = polygons_1[_i];
123
+ var pointsAttr = poly.getAttribute('points');
124
+ if (pointsAttr) {
125
+ var polyPoints = parsePolygonPoints(pointsAttr);
126
+ points.push.apply(points, polyPoints);
127
+ }
128
+ }
129
+ // Extract points from path elements (simple conversion, doesn't handle curves)
130
+ var paths = doc.querySelectorAll('path');
131
+ for (var _a = 0, paths_1 = paths; _a < paths_1.length; _a++) {
132
+ var path = paths_1[_a];
133
+ var d = path.getAttribute('d');
134
+ if (d) {
135
+ var pathPoints = parsePathData(d);
136
+ points.push.apply(points, pathPoints);
137
+ }
138
+ }
139
+ // Extract points from circle/ellipse (approximate as polygon)
140
+ var circles = doc.querySelectorAll('circle');
141
+ for (var _b = 0, circles_1 = circles; _b < circles_1.length; _b++) {
142
+ var circle = circles_1[_b];
143
+ var cx = parseFloat(circle.getAttribute('cx') || '0');
144
+ var cy = parseFloat(circle.getAttribute('cy') || '0');
145
+ var r = parseFloat(circle.getAttribute('r') || '0');
146
+ var circlePoints = generateCirclePoints(cx, cy, r);
147
+ points.push.apply(points, circlePoints);
148
+ }
149
+ if (points.length === 0) {
150
+ return null;
151
+ }
152
+ return {
153
+ type: 'POLYGON',
154
+ points: points,
155
+ };
156
+ }
157
+ catch (e) {
158
+ console.warn('Failed to convert SVG to polygon:', e);
159
+ return null;
160
+ }
161
+ }
162
+ /**
163
+ * Parse polygon points attribute
164
+ * Format: "x1,y1 x2,y2 x3,y3"
165
+ */
166
+ function parsePolygonPoints(pointsStr) {
167
+ var points = [];
168
+ var pairs = pointsStr.trim().split(/\s+/);
169
+ for (var _i = 0, pairs_1 = pairs; _i < pairs_1.length; _i++) {
170
+ var pair = pairs_1[_i];
171
+ var _a = pair.split(',').map(function (v) { return parseFloat(v); }), x = _a[0], y = _a[1];
172
+ if (!isNaN(x) && !isNaN(y)) {
173
+ points.push([x, y]);
174
+ }
175
+ }
176
+ return points;
177
+ }
178
+ /**
179
+ * Parse SVG path data (simplified)
180
+ * Extracts M (moveto) and L (lineto) commands
181
+ */
182
+ function parsePathData(d) {
183
+ var points = [];
184
+ // Simple regex: match M and L commands followed by coordinates
185
+ var commandRegex = /[ML]\s*([\d.]+)[,\s]+([\d.]+)/g;
186
+ var match;
187
+ while ((match = commandRegex.exec(d)) !== null) {
188
+ var x = parseFloat(match[1]);
189
+ var y = parseFloat(match[2]);
190
+ if (!isNaN(x) && !isNaN(y)) {
191
+ points.push([x, y]);
192
+ }
193
+ }
194
+ return points;
195
+ }
196
+ /**
197
+ * Generate polygon points approximating a circle
198
+ */
199
+ function generateCirclePoints(cx, cy, r, numPoints) {
200
+ if (numPoints === void 0) { numPoints = 8; }
201
+ var points = [];
202
+ for (var i = 0; i < numPoints; i++) {
203
+ var angle = (i / numPoints) * Math.PI * 2;
204
+ var x = cx + r * Math.cos(angle);
205
+ var y = cy + r * Math.sin(angle);
206
+ points.push([x, y]);
207
+ }
208
+ return points;
209
+ }
210
+ /**
211
+ * Extract xywh from annotation target (multiple formats)
212
+ */
213
+ function extractXywhFromTarget(annotation) {
214
+ var _a;
215
+ // Try Manifesto getTarget method
216
+ if (typeof annotation.getTarget === 'function') {
217
+ var target_2 = annotation.getTarget();
218
+ if (typeof target_2 === 'string' && target_2.includes('xywh=')) {
219
+ return parseXywh(target_2);
220
+ }
221
+ // Check raw JSON as fallback
222
+ var rawOn = (_a = annotation.__jsonld) === null || _a === void 0 ? void 0 : _a.on;
223
+ if (rawOn) {
224
+ var xywh = extractXywhFromRawTarget(rawOn);
225
+ if (xywh)
226
+ return xywh;
227
+ }
228
+ }
229
+ // Check raw annotation formats (v2 and v3)
230
+ var target = annotation.target || annotation.on;
231
+ if (target) {
232
+ return extractXywhFromRawTarget(target);
233
+ }
234
+ return null;
235
+ }
236
+ /**
237
+ * Extract xywh from raw target object/array
238
+ */
239
+ function extractXywhFromRawTarget(target) {
240
+ if (!target)
241
+ return null;
242
+ // Handle arrays
243
+ if (Array.isArray(target)) {
244
+ for (var _i = 0, target_3 = target; _i < target_3.length; _i++) {
245
+ var t = target_3[_i];
246
+ var xywh = extractXywhFromRawTarget(t);
247
+ if (xywh)
248
+ return xywh;
249
+ }
250
+ }
251
+ // Handle string targets with xywh
252
+ if (typeof target === 'string' && target.includes('xywh=')) {
253
+ return parseXywh(target);
254
+ }
255
+ // Handle object with selector
256
+ if (target.selector) {
257
+ var sel = target.selector;
258
+ var item = sel.item || sel;
259
+ if (item.value && typeof item.value === 'string' && item.value.includes('xywh=')) {
260
+ return parseXywh(item.value);
261
+ }
262
+ }
263
+ return null;
264
+ }
265
+ /**
266
+ * Extract annotation body content (text, label, etc)
267
+ */
268
+ function extractBody(annotation) {
269
+ var value = '';
270
+ var isHtml = false;
271
+ // Try Manifesto getBody method
272
+ if (typeof annotation.getBody === 'function') {
273
+ var body = annotation.getBody();
274
+ if (body && Array.isArray(body)) {
275
+ var values = [];
276
+ for (var _i = 0, body_1 = body; _i < body_1.length; _i++) {
277
+ var b = body_1[_i];
278
+ var val = b.getValue ? b.getValue() : '';
279
+ if (val) {
280
+ values.push(val);
281
+ var format = b.getFormat ? b.getFormat() : '';
282
+ if (format === 'text/html' || format === 'application/html') {
283
+ isHtml = true;
284
+ }
285
+ }
286
+ }
287
+ value = values.join(' ');
288
+ }
289
+ }
290
+ else {
291
+ // Handle raw JSON body/resource
292
+ var getText = function (r) {
293
+ if (!r)
294
+ return '';
295
+ return r.chars || r.value || r['cnt:chars'] || '';
296
+ };
297
+ var checkHtml = function (r) {
298
+ if (!r)
299
+ return false;
300
+ return r.format === 'text/html' || r.type === 'TextualBody';
301
+ };
302
+ if (annotation.resource) {
303
+ var resources = Array.isArray(annotation.resource) ? annotation.resource : [annotation.resource];
304
+ value = resources.map(getText).filter(Boolean).join(' ');
305
+ isHtml = resources.some(checkHtml);
306
+ }
307
+ else if (annotation.body) {
308
+ var bodyArr = Array.isArray(annotation.body) ? annotation.body : [annotation.body];
309
+ value = bodyArr.map(getText).filter(Boolean).join(' ');
310
+ isHtml = bodyArr.some(checkHtml);
311
+ }
312
+ }
313
+ // Try to extract label if no body content found
314
+ if (!value) {
315
+ if (typeof annotation.getLabel === 'function') {
316
+ value = annotation.getLabel() || '';
317
+ }
318
+ else if (annotation.label) {
319
+ value = Array.isArray(annotation.label) ? annotation.label.join(' ') : annotation.label;
320
+ }
321
+ }
322
+ return { value: value || 'Annotation', isHtml: isHtml };
323
+ }
324
+ /**
325
+ * Parse Manifesto/IIIF annotation to internal format
326
+ */
327
+ export function parseAnnotation(annotation, index, isSearchHit) {
328
+ if (isSearchHit === void 0) { isSearchHit = false; }
329
+ var id = getAnnotationId(annotation) || "anno-".concat(index);
330
+ var geometry = extractGeometry(annotation);
331
+ // Skip annotations without geometry
332
+ if (!geometry) {
333
+ return null;
334
+ }
335
+ var body = extractBody(annotation);
336
+ return {
337
+ id: id,
338
+ geometry: geometry,
339
+ body: body,
340
+ isSearchHit: isSearchHit,
341
+ };
342
+ }
343
+ /**
344
+ * Batch parse annotations
345
+ */
346
+ export function parseAnnotations(annotations, searchHitIds) {
347
+ if (searchHitIds === void 0) { searchHitIds = new Set(); }
348
+ return annotations
349
+ .map(function (anno, idx) {
350
+ var isSearchHit = searchHitIds.has(getAnnotationId(anno));
351
+ return parseAnnotation(anno, idx, isSearchHit);
352
+ })
353
+ .filter(function (anno) { return anno !== null; });
354
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,91 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { parseAnnotation } from "./annotationAdapter";
3
+ describe("annotationAdapter", function () {
4
+ describe("parseAnnotation", function () {
5
+ it("should correctly parse a simple xywh string target", function () {
6
+ var annotation = {
7
+ "@id": "http://example.org/anno1",
8
+ on: "http://example.org/image1#xywh=10,20,100,200",
9
+ label: "Test Annotation",
10
+ };
11
+ var result = parseAnnotation(annotation, 0);
12
+ expect(result).not.toBeNull();
13
+ if (!result)
14
+ return;
15
+ expect(result.geometry.type).toBe("RECTANGLE");
16
+ var geometry = result.geometry;
17
+ if ("x" in geometry) {
18
+ expect(geometry).toEqual({
19
+ type: "RECTANGLE",
20
+ x: 10,
21
+ y: 20,
22
+ w: 100,
23
+ h: 200,
24
+ });
25
+ }
26
+ else {
27
+ throw new Error("Geometry should be RECTANGLE type with x, y, w, h");
28
+ }
29
+ });
30
+ it("should extract SVG selector geometry", function () {
31
+ var annotation = {
32
+ "@id": "http://example.org/anno2",
33
+ on: {
34
+ selector: {
35
+ type: "SvgSelector",
36
+ value: '<svg><polygon points="10,10 50,10 50,50 10,50" /></svg>',
37
+ },
38
+ },
39
+ };
40
+ var result = parseAnnotation(annotation, 1);
41
+ expect(result).not.toBeNull();
42
+ if (!result)
43
+ return;
44
+ expect(result.geometry.type).toBe("POLYGON");
45
+ var geometry = result.geometry;
46
+ if ("points" in geometry) {
47
+ expect(geometry.points).toHaveLength(4);
48
+ expect(geometry.points).toEqual([
49
+ [10, 10],
50
+ [50, 10],
51
+ [50, 50],
52
+ [10, 50],
53
+ ]);
54
+ }
55
+ else {
56
+ throw new Error("Geometry should be POLYGON type with points");
57
+ }
58
+ });
59
+ it("should handle Manifesto-style getTarget and getId methods", function () {
60
+ var mockManifestoAnno = {
61
+ getId: function () { return "http://example.org/manifesto-anno"; },
62
+ getTarget: function () { return "http://example.org/canvas1#xywh=5,5,50,50"; },
63
+ getBody: function () { return [
64
+ { getValue: function () { return "Manifesto Body"; }, getFormat: function () { return "text/plain"; } },
65
+ ]; },
66
+ };
67
+ // @ts-ignore - mocking complex object
68
+ var result = parseAnnotation(mockManifestoAnno, 2);
69
+ expect(result === null || result === void 0 ? void 0 : result.id).toBe("http://example.org/manifesto-anno");
70
+ var geometry = result === null || result === void 0 ? void 0 : result.geometry;
71
+ if (geometry && "x" in geometry) {
72
+ expect(geometry).toMatchObject({
73
+ type: "RECTANGLE",
74
+ x: 5,
75
+ y: 5,
76
+ w: 50,
77
+ h: 50,
78
+ });
79
+ }
80
+ expect(result === null || result === void 0 ? void 0 : result.body.value).toBe("Manifesto Body");
81
+ });
82
+ it("should return null for invalid annotations with no geometry", function () {
83
+ var invalidAnno = {
84
+ "@id": "bad-anno",
85
+ on: "http://example.org/canvas1", // No media fragment or selector
86
+ };
87
+ var result = parseAnnotation(invalidAnno, 3);
88
+ expect(result).toBeNull();
89
+ });
90
+ });
91
+ });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "triiiceratops",
3
- "version": "0.8.2",
3
+ "version": "0.9.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,16 +18,16 @@
18
18
  "module": "./dist/index.js",
19
19
  "svelte": "./dist/index.js",
20
20
  "style": "./dist/triiiceratops.css",
21
- "types": "./dist/src/lib/index.d.ts",
21
+ "types": "./dist/index.d.ts",
22
22
  "exports": {
23
23
  ".": {
24
- "types": "./dist/src/lib/index.d.ts",
24
+ "types": "./dist/index.d.ts",
25
25
  "style": "./dist/triiiceratops.css",
26
26
  "svelte": "./dist/index.js",
27
27
  "import": "./dist/index.js"
28
28
  },
29
29
  "./plugins/image-manipulation": {
30
- "types": "./dist/src/lib/plugins/image-manipulation/index.d.ts",
30
+ "types": "./dist/plugins/image-manipulation/index.d.ts",
31
31
  "svelte": "./dist/plugins/image-manipulation.js",
32
32
  "import": "./dist/plugins/image-manipulation.js"
33
33
  },
@@ -52,6 +52,7 @@
52
52
  "@inlang/paraglide-js": "^2.5.0",
53
53
  "@inlang/paraglide-vite": "^1.4.0",
54
54
  "@playwright/test": "^1.57.0",
55
+ "@sveltejs/package": "^2.5.7",
55
56
  "@sveltejs/vite-plugin-svelte": "^6.2.1",
56
57
  "@tsconfig/svelte": "^5.0.6",
57
58
  "@types/node": "^24.10.1",
@@ -78,7 +79,7 @@
78
79
  "scripts": {
79
80
  "dev": "vite",
80
81
  "build": "vite build",
81
- "build:lib": "vite build --config vite.config.lib.ts",
82
+ "build:lib": "svelte-package && vite build --config vite.config.lib.ts",
82
83
  "build:element": "vite build --config vite.config.element.ts",
83
84
  "build:demo": "vite build --config vite.config.demo.ts",
84
85
  "build:consumer": "vite build --config vite.config.demo-consumer.ts",