react-iiif-vault 0.9.6 → 0.9.7
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/LICENSE +21 -0
- package/dist/cjs/index.js +937 -668
- package/dist/esm/index.mjs +936 -670
- package/dist/index.d.ts +164 -102
- package/dist/index.umd.js +30370 -894
- package/package.json +35 -25
package/dist/cjs/index.js
CHANGED
|
@@ -4,27 +4,28 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var React = require('react');
|
|
6
6
|
var vault = require('@iiif/vault');
|
|
7
|
-
var
|
|
8
|
-
var vaultHelpers = require('@iiif/vault-helpers');
|
|
7
|
+
var atlas = require('@atlas-viewer/atlas');
|
|
9
8
|
var typesafeActions = require('typesafe-actions');
|
|
9
|
+
var vaultHelpers = require('@iiif/vault-helpers');
|
|
10
|
+
var iiifImageApi = require('@atlas-viewer/iiif-image-api');
|
|
10
11
|
|
|
11
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
13
|
|
|
13
14
|
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
15
|
|
|
15
|
-
var __defProp$
|
|
16
|
-
var __getOwnPropSymbols$
|
|
17
|
-
var __hasOwnProp$
|
|
18
|
-
var __propIsEnum$
|
|
19
|
-
var __defNormalProp$
|
|
20
|
-
var __spreadValues$
|
|
16
|
+
var __defProp$8 = Object.defineProperty;
|
|
17
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
18
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
19
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
20
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
21
|
+
var __spreadValues$8 = (a, b) => {
|
|
21
22
|
for (var prop in b || (b = {}))
|
|
22
|
-
if (__hasOwnProp$
|
|
23
|
-
__defNormalProp$
|
|
24
|
-
if (__getOwnPropSymbols$
|
|
25
|
-
for (var prop of __getOwnPropSymbols$
|
|
26
|
-
if (__propIsEnum$
|
|
27
|
-
__defNormalProp$
|
|
23
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
24
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
25
|
+
if (__getOwnPropSymbols$8)
|
|
26
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
27
|
+
if (__propIsEnum$8.call(b, prop))
|
|
28
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
28
29
|
}
|
|
29
30
|
return a;
|
|
30
31
|
};
|
|
@@ -42,43 +43,13 @@ const useResourceContext = () => {
|
|
|
42
43
|
const ResourceProvider = ({ value, children }) => {
|
|
43
44
|
const parentContext = useResourceContext();
|
|
44
45
|
const newContext = React.useMemo(() => {
|
|
45
|
-
return __spreadValues$
|
|
46
|
+
return __spreadValues$8(__spreadValues$8({}, parentContext), value);
|
|
46
47
|
}, [value, parentContext]);
|
|
47
48
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceReactContext.Provider, {
|
|
48
49
|
value: newContext
|
|
49
50
|
}, children);
|
|
50
51
|
};
|
|
51
52
|
|
|
52
|
-
const AnnotationContext = ({ annotation, children }) => {
|
|
53
|
-
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
54
|
-
value: { annotation }
|
|
55
|
-
}, children);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const CanvasContext = ({ canvas, children }) => {
|
|
59
|
-
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
60
|
-
value: { canvas }
|
|
61
|
-
}, children);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const CollectionContext = ({ collection, children }) => {
|
|
65
|
-
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
66
|
-
value: { collection }
|
|
67
|
-
}, children);
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
const ManifestContext = ({ manifest, children }) => {
|
|
71
|
-
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
72
|
-
value: { manifest }
|
|
73
|
-
}, children);
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
const RangeContext = ({ range, children }) => {
|
|
77
|
-
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
78
|
-
value: { range }
|
|
79
|
-
}, children);
|
|
80
|
-
};
|
|
81
|
-
|
|
82
53
|
const ReactVaultContext = React__default["default"].createContext({
|
|
83
54
|
vault: null,
|
|
84
55
|
setVaultInstance: (vault) => {
|
|
@@ -170,13 +141,23 @@ function useExternalManifest(idOrRef, options) {
|
|
|
170
141
|
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
171
142
|
}
|
|
172
143
|
|
|
144
|
+
const ManifestContext = ({ manifest, children }) => {
|
|
145
|
+
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
146
|
+
value: { manifest }
|
|
147
|
+
}, children);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
const CanvasContext = ({ canvas, children }) => {
|
|
151
|
+
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
152
|
+
value: { canvas }
|
|
153
|
+
}, children);
|
|
154
|
+
};
|
|
155
|
+
|
|
173
156
|
function useVaultSelector(selector, deps = []) {
|
|
174
157
|
const vault = useVault();
|
|
175
158
|
const [selectedState, setSelectedState] = React.useState(() => selector(vault.getState(), vault));
|
|
176
159
|
React.useEffect(() => {
|
|
177
|
-
return vault.subscribe((s) => selector(s, vault),
|
|
178
|
-
setSelectedState(state);
|
|
179
|
-
}, false);
|
|
160
|
+
return vault.subscribe((s) => selector(s, vault), setSelectedState, false);
|
|
180
161
|
}, deps);
|
|
181
162
|
return selectedState;
|
|
182
163
|
}
|
|
@@ -321,9 +302,237 @@ const ContextBridge = (props) => {
|
|
|
321
302
|
}, props.children)));
|
|
322
303
|
};
|
|
323
304
|
|
|
324
|
-
const
|
|
325
|
-
|
|
326
|
-
|
|
305
|
+
const IMPORT_ENTITIES = "@iiif/IMPORT_ENTITIES";
|
|
306
|
+
const MODIFY_ENTITY_FIELD = "@iiif/MODIFY_ENTITY_FIELD";
|
|
307
|
+
const REORDER_ENTITY_FIELD = "@iiif/REORDER_ENTITY_FIELD";
|
|
308
|
+
const ADD_REFERENCE = "@iiif/ADD_REFERENCE";
|
|
309
|
+
const REMOVE_REFERENCE = "@iiif/REMOVE_REFERENCE";
|
|
310
|
+
const importEntities = typesafeActions.createAction(IMPORT_ENTITIES)();
|
|
311
|
+
const modifyEntityField = typesafeActions.createAction(MODIFY_ENTITY_FIELD)();
|
|
312
|
+
const reorderEntityField = typesafeActions.createAction(REORDER_ENTITY_FIELD)();
|
|
313
|
+
const addReference = typesafeActions.createAction(ADD_REFERENCE)();
|
|
314
|
+
const removeReference = typesafeActions.createAction(REMOVE_REFERENCE)();
|
|
315
|
+
const entityActions = { importEntities, modifyEntityField, reorderEntityField, addReference, removeReference };
|
|
316
|
+
|
|
317
|
+
const ADD_MAPPING = "@iiif/ADD_MAPPING";
|
|
318
|
+
const ADD_MAPPINGS = "@iiif/ADD_MAPPINGS";
|
|
319
|
+
typesafeActions.createAction(ADD_MAPPING)();
|
|
320
|
+
typesafeActions.createAction(ADD_MAPPINGS)();
|
|
321
|
+
|
|
322
|
+
const SET_META_VALUE = "@iiif/SET_META_VALUE";
|
|
323
|
+
const SET_META_VALUE_DYNAMIC = "@iiif/SET_META_VALUE_DYNAMIC";
|
|
324
|
+
const UNSET_META_VALUE = "@iiif/UNSET_META_VALUE";
|
|
325
|
+
typesafeActions.createAction(SET_META_VALUE)();
|
|
326
|
+
typesafeActions.createAction(SET_META_VALUE_DYNAMIC)();
|
|
327
|
+
typesafeActions.createAction(UNSET_META_VALUE)();
|
|
328
|
+
const REQUEST_RESOURCE = "@iiif/REQUEST_RESOURCE";
|
|
329
|
+
const REQUEST_ERROR = "@iiif/REQUEST_ERROR";
|
|
330
|
+
const REQUEST_MISMATCH = "@iiif/REQUEST_MISMATCH";
|
|
331
|
+
const REQUEST_COMPLETE = "@iiif/REQUEST_COMPLETE";
|
|
332
|
+
const REQUEST_OFFLINE_RESOURCE = "@iiif/REQUEST_OFFLINE_RESOURCE";
|
|
333
|
+
typesafeActions.createAction(REQUEST_RESOURCE)();
|
|
334
|
+
typesafeActions.createAction(REQUEST_ERROR)();
|
|
335
|
+
typesafeActions.createAction(REQUEST_MISMATCH)();
|
|
336
|
+
typesafeActions.createAction(REQUEST_COMPLETE)();
|
|
337
|
+
typesafeActions.createAction(REQUEST_OFFLINE_RESOURCE)();
|
|
338
|
+
|
|
339
|
+
const BATCH_ACTIONS = "@iiif/BATCH";
|
|
340
|
+
const BATCH_IMPORT = "@iiif/BATCH_IMPORT";
|
|
341
|
+
typesafeActions.createAction(BATCH_ACTIONS)();
|
|
342
|
+
typesafeActions.createAction(BATCH_IMPORT)();
|
|
343
|
+
|
|
344
|
+
function useDispatch() {
|
|
345
|
+
const vault = useVault();
|
|
346
|
+
const store = vault.getStore();
|
|
347
|
+
return React.useMemo(() => {
|
|
348
|
+
return (action) => store.dispatch(action);
|
|
349
|
+
}, [store]);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
function isVaultActivated(obj) {
|
|
353
|
+
return typeof obj !== "string" && obj && obj.bindToVault;
|
|
354
|
+
}
|
|
355
|
+
function useVirtualAnnotationPage() {
|
|
356
|
+
const vault = useVault();
|
|
357
|
+
const sources = React.useRef([]);
|
|
358
|
+
const dispatch = useDispatch();
|
|
359
|
+
const virtualId = React.useMemo(() => {
|
|
360
|
+
return `vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random() * 1e9).toString(16)}`;
|
|
361
|
+
}, []);
|
|
362
|
+
React.useLayoutEffect(() => {
|
|
363
|
+
const page = {
|
|
364
|
+
id: virtualId,
|
|
365
|
+
type: "AnnotationPage",
|
|
366
|
+
behavior: [],
|
|
367
|
+
motivation: null,
|
|
368
|
+
label: null,
|
|
369
|
+
thumbnail: [],
|
|
370
|
+
summary: null,
|
|
371
|
+
requiredStatement: null,
|
|
372
|
+
metadata: [],
|
|
373
|
+
rights: null,
|
|
374
|
+
provider: [],
|
|
375
|
+
items: [],
|
|
376
|
+
seeAlso: [],
|
|
377
|
+
homepage: [],
|
|
378
|
+
logo: [],
|
|
379
|
+
rendering: [],
|
|
380
|
+
service: []
|
|
381
|
+
};
|
|
382
|
+
dispatch(entityActions.importEntities({
|
|
383
|
+
entities: {
|
|
384
|
+
AnnotationPage: {
|
|
385
|
+
[page.id]: page
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}));
|
|
389
|
+
}, [virtualId]);
|
|
390
|
+
const fullPage = useVaultSelector((state) => virtualId ? state.iiif.entities.AnnotationPage[virtualId] : null, [virtualId]);
|
|
391
|
+
const addAnnotation = React.useCallback((id, atIndex) => {
|
|
392
|
+
if (virtualId) {
|
|
393
|
+
if (isVaultActivated(id)) {
|
|
394
|
+
const display = id;
|
|
395
|
+
if (!display.__vault) {
|
|
396
|
+
display.bindToVault(vault);
|
|
397
|
+
}
|
|
398
|
+
id = typeof display.source === "string" ? display.source : display.source.id;
|
|
399
|
+
sources.current[id] = display;
|
|
400
|
+
} else if (typeof id !== "string") {
|
|
401
|
+
id = id.id;
|
|
402
|
+
}
|
|
403
|
+
const full = vault.get({ id: virtualId, type: "AnnotationPage" });
|
|
404
|
+
const annotation = vault.get({ id, type: "Annotation" });
|
|
405
|
+
if (full && annotation) {
|
|
406
|
+
if (!full.items.find((r) => r.id === annotation.id)) {
|
|
407
|
+
dispatch(entityActions.addReference({
|
|
408
|
+
id: virtualId,
|
|
409
|
+
type: "AnnotationPage",
|
|
410
|
+
key: "items",
|
|
411
|
+
reference: {
|
|
412
|
+
id,
|
|
413
|
+
type: "Annotation"
|
|
414
|
+
},
|
|
415
|
+
index: atIndex
|
|
416
|
+
}));
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}, [virtualId]);
|
|
421
|
+
const removeAnnotation = React.useCallback((id) => {
|
|
422
|
+
if (virtualId) {
|
|
423
|
+
if (isVaultActivated(id)) {
|
|
424
|
+
id = typeof id.source === "string" ? id.source : id.source.id;
|
|
425
|
+
} else if (typeof id !== "string") {
|
|
426
|
+
id = id.id;
|
|
427
|
+
}
|
|
428
|
+
if (sources.current[id]) {
|
|
429
|
+
sources.current[id].beforeRemove();
|
|
430
|
+
}
|
|
431
|
+
const full = vault.get({ id: virtualId, type: "AnnotationPage" });
|
|
432
|
+
if (full) {
|
|
433
|
+
dispatch(entityActions.removeReference({
|
|
434
|
+
id: virtualId,
|
|
435
|
+
type: "AnnotationPage",
|
|
436
|
+
key: "items",
|
|
437
|
+
reference: {
|
|
438
|
+
id,
|
|
439
|
+
type: "Annotation"
|
|
440
|
+
}
|
|
441
|
+
}));
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
}, [virtualId]);
|
|
445
|
+
return [
|
|
446
|
+
fullPage,
|
|
447
|
+
{
|
|
448
|
+
addAnnotation,
|
|
449
|
+
removeAnnotation
|
|
450
|
+
}
|
|
451
|
+
];
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
const VirtualAnnotationPageContext = React.createContext(null);
|
|
455
|
+
function useVirtualAnnotationPageContext() {
|
|
456
|
+
const ctx = React.useContext(VirtualAnnotationPageContext);
|
|
457
|
+
return [
|
|
458
|
+
ctx.fullPage,
|
|
459
|
+
{
|
|
460
|
+
addAnnotation: ctx.addAnnotation,
|
|
461
|
+
removeAnnotation: ctx.removeAnnotation
|
|
462
|
+
}
|
|
463
|
+
];
|
|
464
|
+
}
|
|
465
|
+
function VirtualAnnotationProvider({ children }) {
|
|
466
|
+
const [fullPage, { addAnnotation, removeAnnotation }] = useVirtualAnnotationPage();
|
|
467
|
+
return /* @__PURE__ */ React__default["default"].createElement(VirtualAnnotationPageContext.Provider, {
|
|
468
|
+
value: React.useMemo(() => ({ fullPage, addAnnotation, removeAnnotation }), [fullPage])
|
|
469
|
+
}, children);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
var __defProp$7 = Object.defineProperty;
|
|
473
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
474
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
475
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
476
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
477
|
+
var __spreadValues$7 = (a, b) => {
|
|
478
|
+
for (var prop in b || (b = {}))
|
|
479
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
480
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
481
|
+
if (__getOwnPropSymbols$7)
|
|
482
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
483
|
+
if (__propIsEnum$7.call(b, prop))
|
|
484
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
485
|
+
}
|
|
486
|
+
return a;
|
|
487
|
+
};
|
|
488
|
+
var __objRest = (source, exclude) => {
|
|
489
|
+
var target = {};
|
|
490
|
+
for (var prop in source)
|
|
491
|
+
if (__hasOwnProp$7.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
492
|
+
target[prop] = source[prop];
|
|
493
|
+
if (source != null && __getOwnPropSymbols$7)
|
|
494
|
+
for (var prop of __getOwnPropSymbols$7(source)) {
|
|
495
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$7.call(source, prop))
|
|
496
|
+
target[prop] = source[prop];
|
|
497
|
+
}
|
|
498
|
+
return target;
|
|
499
|
+
};
|
|
500
|
+
function Viewer(_a) {
|
|
501
|
+
var _b = _a, {
|
|
502
|
+
children
|
|
503
|
+
} = _b, props = __objRest(_b, [
|
|
504
|
+
"children"
|
|
505
|
+
]);
|
|
506
|
+
const bridge = useContextBridge();
|
|
507
|
+
return /* @__PURE__ */ React__default["default"].createElement(atlas.AtlasAuto, __spreadValues$7({}, props), /* @__PURE__ */ React__default["default"].createElement(ContextBridge, {
|
|
508
|
+
bridge
|
|
509
|
+
}, /* @__PURE__ */ React__default["default"].createElement(VirtualAnnotationProvider, null, children)));
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
function useResourceEvents(resource, scope) {
|
|
513
|
+
const vault = useVault();
|
|
514
|
+
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
515
|
+
const hooks = useVaultSelector(() => {
|
|
516
|
+
if (resource && resource.id) {
|
|
517
|
+
return vault.getResourceMeta(resource.id, "eventManager");
|
|
518
|
+
}
|
|
519
|
+
return null;
|
|
520
|
+
}, [resource]);
|
|
521
|
+
return React.useMemo(() => {
|
|
522
|
+
return resource ? helper.getListenersAsProps(resource, scope) : {};
|
|
523
|
+
}, [hooks, resource, vault, scope]);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
function useStyles(resource, scope) {
|
|
527
|
+
const vault = useVault();
|
|
528
|
+
const helper = React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
529
|
+
return useVaultSelector(() => {
|
|
530
|
+
if (!resource) {
|
|
531
|
+
return null;
|
|
532
|
+
}
|
|
533
|
+
const styles = helper.getAppliedStyles(resource.id);
|
|
534
|
+
return styles ? scope ? styles[scope] : styles : void 0;
|
|
535
|
+
}, [resource, scope]);
|
|
327
536
|
}
|
|
328
537
|
|
|
329
538
|
const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
|
|
@@ -415,21 +624,21 @@ function parseSelector(source) {
|
|
|
415
624
|
};
|
|
416
625
|
}
|
|
417
626
|
|
|
418
|
-
var __defProp$
|
|
627
|
+
var __defProp$6 = Object.defineProperty;
|
|
419
628
|
var __defProps$4 = Object.defineProperties;
|
|
420
629
|
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
421
|
-
var __getOwnPropSymbols$
|
|
422
|
-
var __hasOwnProp$
|
|
423
|
-
var __propIsEnum$
|
|
424
|
-
var __defNormalProp$
|
|
425
|
-
var __spreadValues$
|
|
630
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
631
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
632
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
633
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
634
|
+
var __spreadValues$6 = (a, b) => {
|
|
426
635
|
for (var prop in b || (b = {}))
|
|
427
|
-
if (__hasOwnProp$
|
|
428
|
-
__defNormalProp$
|
|
429
|
-
if (__getOwnPropSymbols$
|
|
430
|
-
for (var prop of __getOwnPropSymbols$
|
|
431
|
-
if (__propIsEnum$
|
|
432
|
-
__defNormalProp$
|
|
636
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
637
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
638
|
+
if (__getOwnPropSymbols$6)
|
|
639
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
640
|
+
if (__propIsEnum$6.call(b, prop))
|
|
641
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
433
642
|
}
|
|
434
643
|
return a;
|
|
435
644
|
};
|
|
@@ -490,7 +699,7 @@ function expandTarget(target, options = {}) {
|
|
|
490
699
|
if (!fragment) {
|
|
491
700
|
return {
|
|
492
701
|
type: "SpecificResource",
|
|
493
|
-
source: __spreadProps$4(__spreadValues$
|
|
702
|
+
source: __spreadProps$4(__spreadValues$6({}, target), {
|
|
494
703
|
id
|
|
495
704
|
}),
|
|
496
705
|
selector: null,
|
|
@@ -499,7 +708,7 @@ function expandTarget(target, options = {}) {
|
|
|
499
708
|
}
|
|
500
709
|
return expandTarget({
|
|
501
710
|
type: "SpecificResource",
|
|
502
|
-
source: __spreadProps$4(__spreadValues$
|
|
711
|
+
source: __spreadProps$4(__spreadValues$6({}, target), {
|
|
503
712
|
id
|
|
504
713
|
}),
|
|
505
714
|
selector: {
|
|
@@ -516,6 +725,168 @@ function expandTarget(target, options = {}) {
|
|
|
516
725
|
};
|
|
517
726
|
}
|
|
518
727
|
|
|
728
|
+
var __defProp$5 = Object.defineProperty;
|
|
729
|
+
var __defProps$3 = Object.defineProperties;
|
|
730
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
731
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
732
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
733
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
734
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
735
|
+
var __spreadValues$5 = (a, b) => {
|
|
736
|
+
for (var prop in b || (b = {}))
|
|
737
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
738
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
739
|
+
if (__getOwnPropSymbols$5)
|
|
740
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
741
|
+
if (__propIsEnum$5.call(b, prop))
|
|
742
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
743
|
+
}
|
|
744
|
+
return a;
|
|
745
|
+
};
|
|
746
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
747
|
+
function useAnnotation(options = {}, deps = []) {
|
|
748
|
+
const { id, selector } = options;
|
|
749
|
+
const ctx = useResourceContext();
|
|
750
|
+
const vault = useVault();
|
|
751
|
+
const annotationId = id ? id : ctx.annotation;
|
|
752
|
+
const annotation = useVaultSelector((s) => annotationId ? s.iiif.entities.Annotation[annotationId] : void 0, [annotationId]);
|
|
753
|
+
const body = useVaultSelector((s) => annotation && annotation.body ? annotation.body.map((singleBody) => singleBody ? s.iiif.entities[singleBody.type][singleBody.id] : null).filter(Boolean) : [], [annotation]);
|
|
754
|
+
return React.useMemo(() => {
|
|
755
|
+
if (!annotation) {
|
|
756
|
+
return void 0;
|
|
757
|
+
}
|
|
758
|
+
const newAnnotation = __spreadProps$3(__spreadValues$5({}, annotation), {
|
|
759
|
+
body,
|
|
760
|
+
target: expandTarget(annotation.target, { typeMap: vault.getState().iiif.mapping })
|
|
761
|
+
});
|
|
762
|
+
if (selector) {
|
|
763
|
+
return selector(newAnnotation);
|
|
764
|
+
}
|
|
765
|
+
return newAnnotation;
|
|
766
|
+
}, [annotation, selector, body, ...deps]);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function useCanvas(options = {}, deps = []) {
|
|
770
|
+
const { id, selector } = options;
|
|
771
|
+
const ctx = useResourceContext();
|
|
772
|
+
const canvasId = id ? id : ctx.canvas;
|
|
773
|
+
const canvas = useVaultSelector((s) => canvasId ? s.iiif.entities.Canvas[canvasId] : void 0, [canvasId]);
|
|
774
|
+
return React.useMemo(() => {
|
|
775
|
+
if (!canvas) {
|
|
776
|
+
return void 0;
|
|
777
|
+
}
|
|
778
|
+
if (selector) {
|
|
779
|
+
return selector(canvas);
|
|
780
|
+
}
|
|
781
|
+
return canvas;
|
|
782
|
+
}, [canvas, selector, ...deps]);
|
|
783
|
+
}
|
|
784
|
+
|
|
785
|
+
var __defProp$4 = Object.defineProperty;
|
|
786
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
787
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
788
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
789
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
790
|
+
var __spreadValues$4 = (a, b) => {
|
|
791
|
+
for (var prop in b || (b = {}))
|
|
792
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
793
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
794
|
+
if (__getOwnPropSymbols$4)
|
|
795
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
796
|
+
if (__propIsEnum$4.call(b, prop))
|
|
797
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
798
|
+
}
|
|
799
|
+
return a;
|
|
800
|
+
};
|
|
801
|
+
const RenderAnnotation = ({
|
|
802
|
+
id,
|
|
803
|
+
style: defaultStyle,
|
|
804
|
+
className,
|
|
805
|
+
interactive
|
|
806
|
+
}) => {
|
|
807
|
+
const annotation = useAnnotation({ id });
|
|
808
|
+
const style = useStyles(annotation, "atlas");
|
|
809
|
+
const html = useStyles(annotation, "html");
|
|
810
|
+
const events = useResourceEvents(annotation, ["atlas"]);
|
|
811
|
+
const canvas = useCanvas();
|
|
812
|
+
const allStyles = React.useMemo(() => {
|
|
813
|
+
return atlas.mergeStyles(defaultStyle, style);
|
|
814
|
+
}, [defaultStyle, style]);
|
|
815
|
+
const isValid = canvas && annotation && annotation.target && annotation.target.selector && annotation.target.selector.type === "BoxSelector" && annotation.target.source && annotation.target.source.id === canvas.id;
|
|
816
|
+
if (!isValid) {
|
|
817
|
+
return null;
|
|
818
|
+
}
|
|
819
|
+
return /* @__PURE__ */ React__default["default"].createElement(atlas.RegionHighlight, __spreadValues$4({
|
|
820
|
+
id: annotation.id,
|
|
821
|
+
isEditing: true,
|
|
822
|
+
region: annotation.target.selector.spatial,
|
|
823
|
+
style: allStyles,
|
|
824
|
+
className: (html == null ? void 0 : html.className) || className,
|
|
825
|
+
interactive: !!((html == null ? void 0 : html.href) || interactive),
|
|
826
|
+
href: (html == null ? void 0 : html.href) || null,
|
|
827
|
+
title: (html == null ? void 0 : html.title) || null,
|
|
828
|
+
hrefTarget: (html == null ? void 0 : html.target) || null
|
|
829
|
+
}, events));
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
const RenderAnnotationPage = ({
|
|
833
|
+
className,
|
|
834
|
+
page
|
|
835
|
+
}) => {
|
|
836
|
+
var _a;
|
|
837
|
+
const style = useStyles(page, "atlas");
|
|
838
|
+
const html = useStyles(page, "html");
|
|
839
|
+
useVaultSelector((state) => page.id ? state.iiif.entities.AnnotationPage[page.id] : null, []);
|
|
840
|
+
return /* @__PURE__ */ React__default["default"].createElement(React.Fragment, null, (_a = page.items) == null ? void 0 : _a.map((annotation) => {
|
|
841
|
+
return /* @__PURE__ */ React__default["default"].createElement(RenderAnnotation, {
|
|
842
|
+
key: annotation.id,
|
|
843
|
+
id: annotation.id,
|
|
844
|
+
style,
|
|
845
|
+
className: (html == null ? void 0 : html.className) || className
|
|
846
|
+
});
|
|
847
|
+
}));
|
|
848
|
+
};
|
|
849
|
+
|
|
850
|
+
const TileSet = atlas.TileSet;
|
|
851
|
+
function RenderImage({
|
|
852
|
+
id,
|
|
853
|
+
image,
|
|
854
|
+
thumbnail,
|
|
855
|
+
isStatic,
|
|
856
|
+
x = 0,
|
|
857
|
+
y = 0,
|
|
858
|
+
annotations
|
|
859
|
+
}) {
|
|
860
|
+
var _a, _b, _c, _d;
|
|
861
|
+
return /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
862
|
+
key: id
|
|
863
|
+
}, !image.service ? /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
864
|
+
key: "no-service"
|
|
865
|
+
}, /* @__PURE__ */ React__default["default"].createElement("world-image", {
|
|
866
|
+
uri: image.id,
|
|
867
|
+
target: image.target.spatial,
|
|
868
|
+
display: image.width && image.height ? {
|
|
869
|
+
width: image.width,
|
|
870
|
+
height: image.height
|
|
871
|
+
} : void 0
|
|
872
|
+
}), annotations) : /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
873
|
+
key: "service"
|
|
874
|
+
}, /* @__PURE__ */ React__default["default"].createElement(TileSet, {
|
|
875
|
+
viewport: isStatic,
|
|
876
|
+
tiles: {
|
|
877
|
+
id: image.service.id,
|
|
878
|
+
height: image.height,
|
|
879
|
+
width: image.width,
|
|
880
|
+
imageService: image.service,
|
|
881
|
+
thumbnail: thumbnail && thumbnail.type === "fixed" ? thumbnail : void 0
|
|
882
|
+
},
|
|
883
|
+
x: ((_a = image.target) == null ? void 0 : _a.spatial.x) + x,
|
|
884
|
+
y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
|
|
885
|
+
width: (_c = image.target) == null ? void 0 : _c.spatial.width,
|
|
886
|
+
height: (_d = image.target) == null ? void 0 : _d.spatial.height
|
|
887
|
+
}), annotations));
|
|
888
|
+
}
|
|
889
|
+
|
|
519
890
|
function parseSpecificResource(resource) {
|
|
520
891
|
if (resource.type === "SpecificResource") {
|
|
521
892
|
return [resource.source, { selector: resource.selector }];
|
|
@@ -575,118 +946,6 @@ const unsupportedStrategy = (reason) => {
|
|
|
575
946
|
return { type: "unknown", reason, annotations: { pages: [] } };
|
|
576
947
|
};
|
|
577
948
|
|
|
578
|
-
function getImageStrategy(canvas, paintables, loadImageService) {
|
|
579
|
-
const imageTypes = [];
|
|
580
|
-
for (const singleImage of paintables.items) {
|
|
581
|
-
const resource = singleImage.resource && singleImage.resource.type === "SpecificResource" ? singleImage.resource.source : singleImage.resource;
|
|
582
|
-
if (!resource.id) {
|
|
583
|
-
return unsupportedStrategy("No resource Identifier");
|
|
584
|
-
}
|
|
585
|
-
let imageService = void 0;
|
|
586
|
-
if (resource.service) {
|
|
587
|
-
const imageServices = iiifImageApi.getImageServices(resource);
|
|
588
|
-
if (imageServices[0]) {
|
|
589
|
-
imageService = loadImageService(imageServices[0], canvas);
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
const { selector: imageTarget, source } = expandTarget(singleImage.target);
|
|
593
|
-
if (source.id !== canvas.id) {
|
|
594
|
-
continue;
|
|
595
|
-
}
|
|
596
|
-
const defaultTarget = {
|
|
597
|
-
type: "BoxSelector",
|
|
598
|
-
spatial: {
|
|
599
|
-
x: 0,
|
|
600
|
-
y: 0,
|
|
601
|
-
width: canvas.width,
|
|
602
|
-
height: canvas.height
|
|
603
|
-
}
|
|
604
|
-
};
|
|
605
|
-
const target = imageTarget ? imageTarget.type === "TemporalSelector" ? {
|
|
606
|
-
type: "TemporalBoxSelector",
|
|
607
|
-
temporal: imageTarget.temporal,
|
|
608
|
-
spatial: defaultTarget.spatial
|
|
609
|
-
} : imageTarget : null;
|
|
610
|
-
const defaultImageSelector = {
|
|
611
|
-
type: "BoxSelector",
|
|
612
|
-
spatial: {
|
|
613
|
-
x: 0,
|
|
614
|
-
y: 0,
|
|
615
|
-
width: canvas.width,
|
|
616
|
-
height: canvas.height
|
|
617
|
-
}
|
|
618
|
-
};
|
|
619
|
-
const imageSelector = singleImage.resource.type === "SpecificResource" ? expandTarget(singleImage.resource) : null;
|
|
620
|
-
const selector = imageSelector && imageSelector.selector && (imageSelector.selector.type === "BoxSelector" || imageSelector.selector.type === "TemporalBoxSelector") ? {
|
|
621
|
-
type: "BoxSelector",
|
|
622
|
-
spatial: {
|
|
623
|
-
x: imageSelector.selector.spatial.x,
|
|
624
|
-
y: imageSelector.selector.spatial.y,
|
|
625
|
-
width: imageSelector.selector.spatial.width,
|
|
626
|
-
height: imageSelector.selector.spatial.height
|
|
627
|
-
}
|
|
628
|
-
} : defaultImageSelector;
|
|
629
|
-
const imageType = {
|
|
630
|
-
id: resource.id,
|
|
631
|
-
type: "Image",
|
|
632
|
-
width: target ? resource.width : canvas.width,
|
|
633
|
-
height: target ? resource.height : canvas.height,
|
|
634
|
-
service: imageService,
|
|
635
|
-
sizes: imageService && imageService.sizes ? imageService.sizes : resource.width && resource.height ? [{ width: resource.width, height: resource.height }] : [],
|
|
636
|
-
target: target && target.type !== "PointSelector" ? target : defaultTarget,
|
|
637
|
-
selector
|
|
638
|
-
};
|
|
639
|
-
imageTypes.push(imageType);
|
|
640
|
-
}
|
|
641
|
-
return {
|
|
642
|
-
type: "images",
|
|
643
|
-
image: imageTypes[0],
|
|
644
|
-
images: imageTypes,
|
|
645
|
-
choice: paintables.choice
|
|
646
|
-
};
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
var __defProp$3 = Object.defineProperty;
|
|
650
|
-
var __defProps$3 = Object.defineProperties;
|
|
651
|
-
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
652
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
653
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
654
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
655
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
656
|
-
var __spreadValues$3 = (a, b) => {
|
|
657
|
-
for (var prop in b || (b = {}))
|
|
658
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
659
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
660
|
-
if (__getOwnPropSymbols$3)
|
|
661
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
662
|
-
if (__propIsEnum$3.call(b, prop))
|
|
663
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
664
|
-
}
|
|
665
|
-
return a;
|
|
666
|
-
};
|
|
667
|
-
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
668
|
-
function useAnnotation(options = {}, deps = []) {
|
|
669
|
-
const { id, selector } = options;
|
|
670
|
-
const ctx = useResourceContext();
|
|
671
|
-
const vault = useVault();
|
|
672
|
-
const annotationId = id ? id : ctx.annotation;
|
|
673
|
-
const annotation = useVaultSelector((s) => annotationId ? s.iiif.entities.Annotation[annotationId] : void 0, [annotationId]);
|
|
674
|
-
const body = useVaultSelector((s) => annotation && annotation.body ? annotation.body.map((singleBody) => singleBody ? s.iiif.entities[singleBody.type][singleBody.id] : null).filter(Boolean) : [], [annotation]);
|
|
675
|
-
return React.useMemo(() => {
|
|
676
|
-
if (!annotation) {
|
|
677
|
-
return void 0;
|
|
678
|
-
}
|
|
679
|
-
const newAnnotation = __spreadProps$3(__spreadValues$3({}, annotation), {
|
|
680
|
-
body,
|
|
681
|
-
target: expandTarget(annotation.target, { typeMap: vault.getState().iiif.mapping })
|
|
682
|
-
});
|
|
683
|
-
if (selector) {
|
|
684
|
-
return selector(newAnnotation);
|
|
685
|
-
}
|
|
686
|
-
return newAnnotation;
|
|
687
|
-
}, [annotation, selector, body, ...deps]);
|
|
688
|
-
}
|
|
689
|
-
|
|
690
949
|
function useManifest(options = {}, deps = []) {
|
|
691
950
|
const { id, selector } = options;
|
|
692
951
|
const ctx = useResourceContext();
|
|
@@ -704,22 +963,6 @@ function useManifest(options = {}, deps = []) {
|
|
|
704
963
|
}, [manifest, selector, ...deps]);
|
|
705
964
|
}
|
|
706
965
|
|
|
707
|
-
function useCanvas(options = {}, deps = []) {
|
|
708
|
-
const { id, selector } = options;
|
|
709
|
-
const ctx = useResourceContext();
|
|
710
|
-
const canvasId = id ? id : ctx.canvas;
|
|
711
|
-
const canvas = useVaultSelector((s) => canvasId ? s.iiif.entities.Canvas[canvasId] : void 0, [canvasId]);
|
|
712
|
-
return React.useMemo(() => {
|
|
713
|
-
if (!canvas) {
|
|
714
|
-
return void 0;
|
|
715
|
-
}
|
|
716
|
-
if (selector) {
|
|
717
|
-
return selector(canvas);
|
|
718
|
-
}
|
|
719
|
-
return canvas;
|
|
720
|
-
}, [canvas, selector, ...deps]);
|
|
721
|
-
}
|
|
722
|
-
|
|
723
966
|
function getMeta$1(state, resourceId) {
|
|
724
967
|
var _a;
|
|
725
968
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -781,21 +1024,21 @@ function flattenAnnotationPageIds({
|
|
|
781
1024
|
return foundIds;
|
|
782
1025
|
}
|
|
783
1026
|
|
|
784
|
-
var __defProp$
|
|
1027
|
+
var __defProp$3 = Object.defineProperty;
|
|
785
1028
|
var __defProps$2 = Object.defineProperties;
|
|
786
1029
|
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
787
|
-
var __getOwnPropSymbols$
|
|
788
|
-
var __hasOwnProp$
|
|
789
|
-
var __propIsEnum$
|
|
790
|
-
var __defNormalProp$
|
|
791
|
-
var __spreadValues$
|
|
1030
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1031
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1032
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1033
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1034
|
+
var __spreadValues$3 = (a, b) => {
|
|
792
1035
|
for (var prop in b || (b = {}))
|
|
793
|
-
if (__hasOwnProp$
|
|
794
|
-
__defNormalProp$
|
|
795
|
-
if (__getOwnPropSymbols$
|
|
796
|
-
for (var prop of __getOwnPropSymbols$
|
|
797
|
-
if (__propIsEnum$
|
|
798
|
-
__defNormalProp$
|
|
1036
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1037
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1038
|
+
if (__getOwnPropSymbols$3)
|
|
1039
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1040
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1041
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
799
1042
|
}
|
|
800
1043
|
return a;
|
|
801
1044
|
};
|
|
@@ -830,7 +1073,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
830
1073
|
if (existingResources && !existingResources[resourceId]) {
|
|
831
1074
|
return existingResources;
|
|
832
1075
|
}
|
|
833
|
-
return __spreadProps$2(__spreadValues$
|
|
1076
|
+
return __spreadProps$2(__spreadValues$3({}, existingResources || {}), {
|
|
834
1077
|
[resourceId]: false
|
|
835
1078
|
});
|
|
836
1079
|
});
|
|
@@ -857,7 +1100,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
857
1100
|
if (existingResources && existingResources[resourceId]) {
|
|
858
1101
|
return existingResources;
|
|
859
1102
|
}
|
|
860
|
-
return __spreadProps$2(__spreadValues$
|
|
1103
|
+
return __spreadProps$2(__spreadValues$3({}, existingResources || {}), {
|
|
861
1104
|
[resourceId]: true
|
|
862
1105
|
});
|
|
863
1106
|
});
|
|
@@ -870,186 +1113,94 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
870
1113
|
};
|
|
871
1114
|
}
|
|
872
1115
|
|
|
873
|
-
function
|
|
874
|
-
|
|
875
|
-
return useVaultSelector((state, vault) => {
|
|
876
|
-
if (!canvas) {
|
|
877
|
-
return [];
|
|
878
|
-
}
|
|
879
|
-
const annotationPages = vault.get(canvas.items);
|
|
880
|
-
const flatAnnotations = [];
|
|
881
|
-
for (const page of annotationPages) {
|
|
882
|
-
flatAnnotations.push(...vault.get(page.items));
|
|
883
|
-
}
|
|
884
|
-
return flatAnnotations;
|
|
885
|
-
}, [canvas]);
|
|
1116
|
+
function useResources(ids, type) {
|
|
1117
|
+
return useVaultSelector((state, vault) => vault.get(ids.map((id) => ({ id, type }))), [ids, type]);
|
|
886
1118
|
}
|
|
887
1119
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
return
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
function useCanvasClock(canvasId, autoplay = false) {
|
|
1120
|
+
const ImageServiceLoaderContext = React__default["default"].createContext(new iiifImageApi.ImageServiceLoader());
|
|
1121
|
+
function useImageServiceLoader() {
|
|
1122
|
+
return React.useContext(ImageServiceLoaderContext);
|
|
894
1123
|
}
|
|
895
1124
|
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (
|
|
906
|
-
|
|
1125
|
+
var __defProp$2 = Object.defineProperty;
|
|
1126
|
+
var __defProps$1 = Object.defineProperties;
|
|
1127
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1128
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1129
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1130
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1131
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1132
|
+
var __spreadValues$2 = (a, b) => {
|
|
1133
|
+
for (var prop in b || (b = {}))
|
|
1134
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
1135
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1136
|
+
if (__getOwnPropSymbols$2)
|
|
1137
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1138
|
+
if (__propIsEnum$2.call(b, prop))
|
|
1139
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
907
1140
|
}
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
const
|
|
914
|
-
const
|
|
915
|
-
return React.useMemo(() => {
|
|
916
|
-
return (action) => store.dispatch(action);
|
|
917
|
-
}, [store]);
|
|
918
|
-
}
|
|
919
|
-
|
|
920
|
-
function useEventListener(resource, name, listener, scope, deps = []) {
|
|
921
|
-
const vault = useVault();
|
|
922
|
-
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
1141
|
+
return a;
|
|
1142
|
+
};
|
|
1143
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1144
|
+
function useLoadImageService() {
|
|
1145
|
+
const loader = useImageServiceLoader();
|
|
1146
|
+
const [imageServiceStatus, setImageServiceStatus] = React.useState({});
|
|
1147
|
+
const didUnmount = React.useRef(false);
|
|
923
1148
|
React.useEffect(() => {
|
|
924
|
-
const currentResource = resource;
|
|
925
|
-
if (!currentResource) {
|
|
926
|
-
return () => {
|
|
927
|
-
};
|
|
928
|
-
}
|
|
929
|
-
helper.addEventListener(currentResource, name, listener, scope);
|
|
930
1149
|
return () => {
|
|
931
|
-
|
|
932
|
-
};
|
|
933
|
-
}, [helper, resource, name, ...deps]);
|
|
934
|
-
}
|
|
935
|
-
|
|
936
|
-
function useExistingVault() {
|
|
937
|
-
const oldContext = React.useContext(ReactVaultContext);
|
|
938
|
-
return oldContext && oldContext.vault ? oldContext.vault : vault.globalVault();
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
function useExternalCollection(idOrRef, options) {
|
|
942
|
-
const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
|
|
943
|
-
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
var __async = (__this, __arguments, generator) => {
|
|
947
|
-
return new Promise((resolve, reject) => {
|
|
948
|
-
var fulfilled = (value) => {
|
|
949
|
-
try {
|
|
950
|
-
step(generator.next(value));
|
|
951
|
-
} catch (e) {
|
|
952
|
-
reject(e);
|
|
953
|
-
}
|
|
954
|
-
};
|
|
955
|
-
var rejected = (value) => {
|
|
956
|
-
try {
|
|
957
|
-
step(generator.throw(value));
|
|
958
|
-
} catch (e) {
|
|
959
|
-
reject(e);
|
|
960
|
-
}
|
|
1150
|
+
didUnmount.current = true;
|
|
961
1151
|
};
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
const resource = vault.get(annotation.body[0]);
|
|
981
|
-
const imageServices = iiifImageApi.getImageServices(resource);
|
|
982
|
-
const firstImageService = imageServices[0];
|
|
983
|
-
if (!firstImageService) {
|
|
984
|
-
return void 0;
|
|
1152
|
+
}, []);
|
|
1153
|
+
const loadImageService = React.useCallback((imageService, { height, width }) => {
|
|
1154
|
+
if (imageService) {
|
|
1155
|
+
const imageServiceId = imageService.id || imageService["@id"];
|
|
1156
|
+
const syncLoaded = loader.loadServiceSync({
|
|
1157
|
+
id: imageServiceId,
|
|
1158
|
+
width: imageService.width || width,
|
|
1159
|
+
height: imageService.height || height
|
|
1160
|
+
});
|
|
1161
|
+
if (syncLoaded) {
|
|
1162
|
+
imageService = syncLoaded;
|
|
1163
|
+
} else if (!imageServiceStatus[imageServiceId]) {
|
|
1164
|
+
if (!didUnmount.current) {
|
|
1165
|
+
setImageServiceStatus((r) => {
|
|
1166
|
+
return __spreadProps$1(__spreadValues$2({}, r), {
|
|
1167
|
+
[imageServiceId]: "loading"
|
|
1168
|
+
});
|
|
1169
|
+
});
|
|
985
1170
|
}
|
|
986
|
-
|
|
987
|
-
id:
|
|
988
|
-
width:
|
|
989
|
-
height:
|
|
990
|
-
})
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
const data = status === "success" && _data ? _data : initialData;
|
|
998
|
-
React.useEffect(() => {
|
|
999
|
-
(() => __async(this, null, function* () {
|
|
1000
|
-
try {
|
|
1001
|
-
if (canvas && annotations.length) {
|
|
1002
|
-
const annotation = annotations[0];
|
|
1003
|
-
const resource = vault.get(annotation.body[0]);
|
|
1004
|
-
const imageServices = iiifImageApi.getImageServices(resource);
|
|
1005
|
-
const firstImageService = imageServices[0];
|
|
1006
|
-
if (!firstImageService) {
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
setIsFetching(true);
|
|
1010
|
-
setStatus("loading");
|
|
1011
|
-
try {
|
|
1012
|
-
const loadedService = (yield imageService.loadService({
|
|
1013
|
-
id: firstImageService.id || firstImageService["@id"],
|
|
1014
|
-
width: firstImageService.width || canvas.width,
|
|
1015
|
-
height: firstImageService.height || canvas.height
|
|
1016
|
-
})) || void 0;
|
|
1017
|
-
setData(loadedService);
|
|
1018
|
-
setStatus("success");
|
|
1019
|
-
setIsFetching(false);
|
|
1020
|
-
} catch (err) {
|
|
1021
|
-
setStatus("error");
|
|
1022
|
-
setError(err);
|
|
1171
|
+
loader.loadService({
|
|
1172
|
+
id: imageServiceId,
|
|
1173
|
+
width: imageService.width || width,
|
|
1174
|
+
height: imageService.height || height
|
|
1175
|
+
}).then(() => {
|
|
1176
|
+
if (!didUnmount.current) {
|
|
1177
|
+
setImageServiceStatus((r) => {
|
|
1178
|
+
return __spreadProps$1(__spreadValues$2({}, r), {
|
|
1179
|
+
[imageServiceId]: "done"
|
|
1180
|
+
});
|
|
1181
|
+
});
|
|
1023
1182
|
}
|
|
1024
|
-
}
|
|
1025
|
-
} catch (err) {
|
|
1026
|
-
setStatus("error");
|
|
1027
|
-
setError(err);
|
|
1183
|
+
});
|
|
1028
1184
|
}
|
|
1029
|
-
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
data,
|
|
1034
|
-
isFetching,
|
|
1035
|
-
status,
|
|
1036
|
-
error
|
|
1037
|
-
};
|
|
1038
|
-
}, [data, isFetching, status, error]);
|
|
1185
|
+
}
|
|
1186
|
+
return imageService;
|
|
1187
|
+
}, [loader, imageServiceStatus]);
|
|
1188
|
+
return [loadImageService, imageServiceStatus];
|
|
1039
1189
|
}
|
|
1040
1190
|
|
|
1041
|
-
function
|
|
1042
|
-
const
|
|
1043
|
-
return {
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
}
|
|
1052
|
-
|
|
1191
|
+
function usePaintingAnnotations(options = {}) {
|
|
1192
|
+
const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
|
|
1193
|
+
return useVaultSelector((state, vault) => {
|
|
1194
|
+
if (!canvas) {
|
|
1195
|
+
return [];
|
|
1196
|
+
}
|
|
1197
|
+
const annotationPages = vault.get(canvas.items);
|
|
1198
|
+
const flatAnnotations = [];
|
|
1199
|
+
for (const page of annotationPages) {
|
|
1200
|
+
flatAnnotations.push(...vault.get(page.items));
|
|
1201
|
+
}
|
|
1202
|
+
return flatAnnotations;
|
|
1203
|
+
}, [canvas]);
|
|
1053
1204
|
}
|
|
1054
1205
|
|
|
1055
1206
|
function usePaintables(options, deps = []) {
|
|
@@ -1096,60 +1247,149 @@ function usePaintables(options, deps = []) {
|
|
|
1096
1247
|
return [paintables, actions];
|
|
1097
1248
|
}
|
|
1098
1249
|
|
|
1099
|
-
function
|
|
1100
|
-
const
|
|
1101
|
-
const
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
if (!range) {
|
|
1106
|
-
return void 0;
|
|
1250
|
+
function getImageStrategy(canvas, paintables, loadImageService) {
|
|
1251
|
+
const imageTypes = [];
|
|
1252
|
+
for (const singleImage of paintables.items) {
|
|
1253
|
+
const resource = singleImage.resource && singleImage.resource.type === "SpecificResource" ? singleImage.resource.source : singleImage.resource;
|
|
1254
|
+
if (!resource.id) {
|
|
1255
|
+
return unsupportedStrategy("No resource Identifier");
|
|
1107
1256
|
}
|
|
1108
|
-
|
|
1109
|
-
|
|
1257
|
+
let imageService = void 0;
|
|
1258
|
+
if (resource.service) {
|
|
1259
|
+
const imageServices = iiifImageApi.getImageServices(resource);
|
|
1260
|
+
if (imageServices[0]) {
|
|
1261
|
+
imageService = loadImageService(imageServices[0], canvas);
|
|
1262
|
+
}
|
|
1110
1263
|
}
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
function useResourceEvents(resource, scope) {
|
|
1116
|
-
const vault = useVault();
|
|
1117
|
-
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
1118
|
-
const hooks = useVaultSelector(() => {
|
|
1119
|
-
if (resource && resource.id) {
|
|
1120
|
-
return vault.getResourceMeta(resource.id, "eventManager");
|
|
1264
|
+
const { selector: imageTarget, source } = expandTarget(singleImage.target);
|
|
1265
|
+
if (source.id !== canvas.id) {
|
|
1266
|
+
continue;
|
|
1121
1267
|
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1268
|
+
const defaultTarget = {
|
|
1269
|
+
type: "BoxSelector",
|
|
1270
|
+
spatial: {
|
|
1271
|
+
x: 0,
|
|
1272
|
+
y: 0,
|
|
1273
|
+
width: canvas.width,
|
|
1274
|
+
height: canvas.height
|
|
1275
|
+
}
|
|
1276
|
+
};
|
|
1277
|
+
const target = imageTarget ? imageTarget.type === "TemporalSelector" ? {
|
|
1278
|
+
type: "TemporalBoxSelector",
|
|
1279
|
+
temporal: imageTarget.temporal,
|
|
1280
|
+
spatial: defaultTarget.spatial
|
|
1281
|
+
} : imageTarget : null;
|
|
1282
|
+
const defaultImageSelector = {
|
|
1283
|
+
type: "BoxSelector",
|
|
1284
|
+
spatial: {
|
|
1285
|
+
x: 0,
|
|
1286
|
+
y: 0,
|
|
1287
|
+
width: canvas.width,
|
|
1288
|
+
height: canvas.height
|
|
1289
|
+
}
|
|
1290
|
+
};
|
|
1291
|
+
const imageSelector = singleImage.resource.type === "SpecificResource" ? expandTarget(singleImage.resource) : null;
|
|
1292
|
+
const selector = imageSelector && imageSelector.selector && (imageSelector.selector.type === "BoxSelector" || imageSelector.selector.type === "TemporalBoxSelector") ? {
|
|
1293
|
+
type: "BoxSelector",
|
|
1294
|
+
spatial: {
|
|
1295
|
+
x: imageSelector.selector.spatial.x,
|
|
1296
|
+
y: imageSelector.selector.spatial.y,
|
|
1297
|
+
width: imageSelector.selector.spatial.width,
|
|
1298
|
+
height: imageSelector.selector.spatial.height
|
|
1299
|
+
}
|
|
1300
|
+
} : defaultImageSelector;
|
|
1301
|
+
const imageType = {
|
|
1302
|
+
id: resource.id,
|
|
1303
|
+
type: "Image",
|
|
1304
|
+
width: target ? resource.width : canvas.width,
|
|
1305
|
+
height: target ? resource.height : canvas.height,
|
|
1306
|
+
service: imageService,
|
|
1307
|
+
sizes: imageService && imageService.sizes ? imageService.sizes : resource.width && resource.height ? [{ width: resource.width, height: resource.height }] : [],
|
|
1308
|
+
target: target && target.type !== "PointSelector" ? target : defaultTarget,
|
|
1309
|
+
selector
|
|
1310
|
+
};
|
|
1311
|
+
imageTypes.push(imageType);
|
|
1312
|
+
}
|
|
1313
|
+
return {
|
|
1314
|
+
type: "images",
|
|
1315
|
+
image: imageTypes[0],
|
|
1316
|
+
images: imageTypes,
|
|
1317
|
+
choice: paintables.choice
|
|
1318
|
+
};
|
|
1131
1319
|
}
|
|
1132
1320
|
|
|
1133
|
-
|
|
1321
|
+
var __defProp$1 = Object.defineProperty;
|
|
1322
|
+
var __defProps = Object.defineProperties;
|
|
1323
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1324
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1325
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1326
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1327
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1328
|
+
var __spreadValues$1 = (a, b) => {
|
|
1329
|
+
for (var prop in b || (b = {}))
|
|
1330
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
1331
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1332
|
+
if (__getOwnPropSymbols$1)
|
|
1333
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1334
|
+
if (__propIsEnum$1.call(b, prop))
|
|
1335
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1336
|
+
}
|
|
1337
|
+
return a;
|
|
1338
|
+
};
|
|
1339
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1340
|
+
function useRenderingStrategy(options) {
|
|
1134
1341
|
const manifest = useManifest();
|
|
1135
|
-
|
|
1136
|
-
}
|
|
1137
|
-
|
|
1138
|
-
function useStyleHelper() {
|
|
1139
|
-
const vault = useVault();
|
|
1140
|
-
return React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
function useStyles(resource, scope) {
|
|
1342
|
+
const canvas = useCanvas();
|
|
1144
1343
|
const vault = useVault();
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1344
|
+
const [loadImageService, imageServiceStatus] = useLoadImageService();
|
|
1345
|
+
const { enabledPageIds } = useAnnotationPageManager((options == null ? void 0 : options.annotationPageManagerId) || (manifest == null ? void 0 : manifest.id) || (canvas == null ? void 0 : canvas.id), {
|
|
1346
|
+
all: false
|
|
1347
|
+
});
|
|
1348
|
+
const enabledPages = useResources(enabledPageIds, "AnnotationPage");
|
|
1349
|
+
const supports = (options == null ? void 0 : options.strategies) || ["images", "media", "complex-timeline"];
|
|
1350
|
+
const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
|
|
1351
|
+
const strategy = React.useMemo(() => {
|
|
1352
|
+
if (!canvas || paintables.types.length === 0) {
|
|
1353
|
+
return unknownResponse;
|
|
1149
1354
|
}
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1355
|
+
if (paintables.types.length !== 1) {
|
|
1356
|
+
if (supports.indexOf("complex-timeline") === -1) {
|
|
1357
|
+
return unsupportedStrategy("Complex timeline not supported");
|
|
1358
|
+
}
|
|
1359
|
+
return unsupportedStrategy("ComplexTimelineStrategy not yet supported");
|
|
1360
|
+
}
|
|
1361
|
+
const mainType = paintables.types[0];
|
|
1362
|
+
if (mainType === "image") {
|
|
1363
|
+
if (supports.indexOf("images") === -1) {
|
|
1364
|
+
return unsupportedStrategy("Image not supported");
|
|
1365
|
+
}
|
|
1366
|
+
return getImageStrategy(canvas, paintables, loadImageService);
|
|
1367
|
+
}
|
|
1368
|
+
if (mainType === "audio") {
|
|
1369
|
+
if (supports.indexOf("media") === -1) {
|
|
1370
|
+
return unsupportedStrategy("Media not supported");
|
|
1371
|
+
}
|
|
1372
|
+
return unsupportedStrategy("Audio strategy not yet supported");
|
|
1373
|
+
}
|
|
1374
|
+
if (mainType === "video") {
|
|
1375
|
+
if (supports.indexOf("media") === -1) {
|
|
1376
|
+
return unsupportedStrategy("Media not supported");
|
|
1377
|
+
}
|
|
1378
|
+
return unsupportedStrategy("Video strategy not yet supported");
|
|
1379
|
+
}
|
|
1380
|
+
return unknownResponse;
|
|
1381
|
+
}, [canvas, paintables, vault, actions.makeChoice]);
|
|
1382
|
+
return React.useMemo(() => {
|
|
1383
|
+
if (strategy.type === "unknown") {
|
|
1384
|
+
return [strategy, emptyActions];
|
|
1385
|
+
}
|
|
1386
|
+
return [
|
|
1387
|
+
__spreadProps(__spreadValues$1({}, strategy), {
|
|
1388
|
+
annotations: { pages: enabledPages }
|
|
1389
|
+
}),
|
|
1390
|
+
actions
|
|
1391
|
+
];
|
|
1392
|
+
}, [strategy, enabledPages]);
|
|
1153
1393
|
}
|
|
1154
1394
|
|
|
1155
1395
|
const useVaultEffect = (callback, deps = []) => {
|
|
@@ -1186,289 +1426,316 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
|
1186
1426
|
return thumbnail;
|
|
1187
1427
|
}
|
|
1188
1428
|
|
|
1189
|
-
var __defProp
|
|
1190
|
-
var
|
|
1191
|
-
var
|
|
1192
|
-
var
|
|
1193
|
-
var
|
|
1194
|
-
var
|
|
1195
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1196
|
-
var __spreadValues$1 = (a, b) => {
|
|
1429
|
+
var __defProp = Object.defineProperty;
|
|
1430
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1431
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1432
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1433
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1434
|
+
var __spreadValues = (a, b) => {
|
|
1197
1435
|
for (var prop in b || (b = {}))
|
|
1198
|
-
if (__hasOwnProp
|
|
1199
|
-
__defNormalProp
|
|
1200
|
-
if (__getOwnPropSymbols
|
|
1201
|
-
for (var prop of __getOwnPropSymbols
|
|
1202
|
-
if (__propIsEnum
|
|
1203
|
-
__defNormalProp
|
|
1436
|
+
if (__hasOwnProp.call(b, prop))
|
|
1437
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1438
|
+
if (__getOwnPropSymbols)
|
|
1439
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
1440
|
+
if (__propIsEnum.call(b, prop))
|
|
1441
|
+
__defNormalProp(a, prop, b[prop]);
|
|
1204
1442
|
}
|
|
1205
1443
|
return a;
|
|
1206
1444
|
};
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
const
|
|
1210
|
-
const [
|
|
1211
|
-
const
|
|
1445
|
+
function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic }) {
|
|
1446
|
+
const canvas = useCanvas();
|
|
1447
|
+
const elementProps = useResourceEvents(canvas, ["deep-zoom"]);
|
|
1448
|
+
const [virtualPage] = useVirtualAnnotationPageContext();
|
|
1449
|
+
const vault = useVault();
|
|
1450
|
+
const helper = React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
1451
|
+
const [strategy, actions] = useRenderingStrategy({
|
|
1452
|
+
strategies: ["images"],
|
|
1453
|
+
defaultChoices: defaultChoices == null ? void 0 : defaultChoices.map(({ id }) => id)
|
|
1454
|
+
});
|
|
1455
|
+
const choice = strategy.type === "images" ? strategy.choice : void 0;
|
|
1212
1456
|
React.useEffect(() => {
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
}
|
|
1216
|
-
}, []);
|
|
1217
|
-
|
|
1218
|
-
if (
|
|
1219
|
-
const
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
height: imageService.height || height
|
|
1224
|
-
});
|
|
1225
|
-
if (syncLoaded) {
|
|
1226
|
-
imageService = syncLoaded;
|
|
1227
|
-
} else if (!imageServiceStatus[imageServiceId]) {
|
|
1228
|
-
if (!didUnmount.current) {
|
|
1229
|
-
setImageServiceStatus((r) => {
|
|
1230
|
-
return __spreadProps$1(__spreadValues$1({}, r), {
|
|
1231
|
-
[imageServiceId]: "loading"
|
|
1232
|
-
});
|
|
1457
|
+
if (registerActions) {
|
|
1458
|
+
registerActions(actions);
|
|
1459
|
+
}
|
|
1460
|
+
}, [strategy.annotations]);
|
|
1461
|
+
React.useEffect(() => {
|
|
1462
|
+
if (defaultChoices) {
|
|
1463
|
+
for (const choice2 of defaultChoices) {
|
|
1464
|
+
if (typeof choice2.opacity !== "undefined") {
|
|
1465
|
+
helper.applyStyles({ id: choice2.id }, "atlas", {
|
|
1466
|
+
opacity: choice2.opacity
|
|
1233
1467
|
});
|
|
1234
1468
|
}
|
|
1235
|
-
loader.loadService({
|
|
1236
|
-
id: imageServiceId,
|
|
1237
|
-
width: imageService.width || width,
|
|
1238
|
-
height: imageService.height || height
|
|
1239
|
-
}).then(() => {
|
|
1240
|
-
if (!didUnmount.current) {
|
|
1241
|
-
setImageServiceStatus((r) => {
|
|
1242
|
-
return __spreadProps$1(__spreadValues$1({}, r), {
|
|
1243
|
-
[imageServiceId]: "done"
|
|
1244
|
-
});
|
|
1245
|
-
});
|
|
1246
|
-
}
|
|
1247
|
-
});
|
|
1248
1469
|
}
|
|
1249
1470
|
}
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1471
|
+
}, [defaultChoices]);
|
|
1472
|
+
React.useLayoutEffect(() => {
|
|
1473
|
+
if (onChoiceChange) {
|
|
1474
|
+
onChoiceChange(choice);
|
|
1475
|
+
}
|
|
1476
|
+
}, [choice]);
|
|
1477
|
+
const thumbnail = useThumbnail({ maxWidth: 256, maxHeight: 256 });
|
|
1478
|
+
if (!canvas) {
|
|
1479
|
+
return null;
|
|
1480
|
+
}
|
|
1481
|
+
if (strategy.type === "unknown") {
|
|
1482
|
+
if (thumbnail && thumbnail.type === "fixed") {
|
|
1483
|
+
return /* @__PURE__ */ React__default["default"].createElement("world-object", {
|
|
1484
|
+
height: canvas.height,
|
|
1485
|
+
width: canvas.width,
|
|
1486
|
+
x,
|
|
1487
|
+
y
|
|
1488
|
+
}, /* @__PURE__ */ React__default["default"].createElement("world-image", {
|
|
1489
|
+
uri: thumbnail.id,
|
|
1490
|
+
target: { x: 0, y: 0, width: canvas.width, height: canvas.height },
|
|
1491
|
+
display: thumbnail.width && thumbnail.height ? {
|
|
1492
|
+
width: thumbnail.width,
|
|
1493
|
+
height: thumbnail.height
|
|
1494
|
+
} : void 0
|
|
1495
|
+
}));
|
|
1496
|
+
}
|
|
1497
|
+
throw new Error("Unknown image strategy");
|
|
1498
|
+
}
|
|
1499
|
+
const annotations = /* @__PURE__ */ React__default["default"].createElement(React.Fragment, null, virtualPage ? /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
1500
|
+
page: virtualPage
|
|
1501
|
+
}) : null, strategy.annotations && strategy.annotations.pages ? strategy.annotations.pages.map((page) => {
|
|
1502
|
+
return /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
1503
|
+
key: page.id,
|
|
1504
|
+
page
|
|
1505
|
+
});
|
|
1506
|
+
}) : null);
|
|
1507
|
+
return /* @__PURE__ */ React__default["default"].createElement("world-object", __spreadValues({
|
|
1508
|
+
key: strategy.type,
|
|
1509
|
+
height: canvas.height,
|
|
1510
|
+
width: canvas.width,
|
|
1511
|
+
x,
|
|
1512
|
+
y
|
|
1513
|
+
}, elementProps), strategy.type === "images" ? strategy.images.map((image, idx) => {
|
|
1514
|
+
return /* @__PURE__ */ React__default["default"].createElement(RenderImage, {
|
|
1515
|
+
isStatic,
|
|
1516
|
+
key: image.id,
|
|
1517
|
+
image,
|
|
1518
|
+
id: image.id,
|
|
1519
|
+
thumbnail: idx === 0 ? thumbnail : void 0,
|
|
1520
|
+
annotations
|
|
1521
|
+
});
|
|
1522
|
+
}) : null);
|
|
1253
1523
|
}
|
|
1254
1524
|
|
|
1255
|
-
const
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
const reorderEntityField = typesafeActions.createAction(REORDER_ENTITY_FIELD)();
|
|
1263
|
-
const addReference = typesafeActions.createAction(ADD_REFERENCE)();
|
|
1264
|
-
const removeReference = typesafeActions.createAction(REMOVE_REFERENCE)();
|
|
1265
|
-
const entityActions = { importEntities, modifyEntityField, reorderEntityField, addReference, removeReference };
|
|
1525
|
+
const CanvasPanel = {
|
|
1526
|
+
RenderImage,
|
|
1527
|
+
RenderCanvas,
|
|
1528
|
+
RenderAnnotationPage,
|
|
1529
|
+
RenderAnnotation,
|
|
1530
|
+
Viewer
|
|
1531
|
+
};
|
|
1266
1532
|
|
|
1267
|
-
const
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1533
|
+
const AnnotationContext = ({ annotation, children }) => {
|
|
1534
|
+
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1535
|
+
value: { annotation }
|
|
1536
|
+
}, children);
|
|
1537
|
+
};
|
|
1271
1538
|
|
|
1272
|
-
const
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
typesafeActions.createAction(UNSET_META_VALUE)();
|
|
1278
|
-
const REQUEST_RESOURCE = "@iiif/REQUEST_RESOURCE";
|
|
1279
|
-
const REQUEST_ERROR = "@iiif/REQUEST_ERROR";
|
|
1280
|
-
const REQUEST_MISMATCH = "@iiif/REQUEST_MISMATCH";
|
|
1281
|
-
const REQUEST_COMPLETE = "@iiif/REQUEST_COMPLETE";
|
|
1282
|
-
const REQUEST_OFFLINE_RESOURCE = "@iiif/REQUEST_OFFLINE_RESOURCE";
|
|
1283
|
-
typesafeActions.createAction(REQUEST_RESOURCE)();
|
|
1284
|
-
typesafeActions.createAction(REQUEST_ERROR)();
|
|
1285
|
-
typesafeActions.createAction(REQUEST_MISMATCH)();
|
|
1286
|
-
typesafeActions.createAction(REQUEST_COMPLETE)();
|
|
1287
|
-
typesafeActions.createAction(REQUEST_OFFLINE_RESOURCE)();
|
|
1539
|
+
const CollectionContext = ({ collection, children }) => {
|
|
1540
|
+
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1541
|
+
value: { collection }
|
|
1542
|
+
}, children);
|
|
1543
|
+
};
|
|
1288
1544
|
|
|
1289
|
-
const
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1545
|
+
const RangeContext = ({ range, children }) => {
|
|
1546
|
+
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1547
|
+
value: { range }
|
|
1548
|
+
}, children);
|
|
1549
|
+
};
|
|
1293
1550
|
|
|
1294
|
-
function
|
|
1295
|
-
|
|
1551
|
+
function useAnnotationsAtTime(time, options = {}) {
|
|
1552
|
+
const allAnnotations = usePaintingAnnotations(options);
|
|
1553
|
+
return allAnnotations;
|
|
1296
1554
|
}
|
|
1297
|
-
|
|
1555
|
+
|
|
1556
|
+
function useCanvasClock(canvasId, autoplay = false) {
|
|
1557
|
+
}
|
|
1558
|
+
|
|
1559
|
+
function useCollection(options, deps = []) {
|
|
1560
|
+
const { id, selector } = options;
|
|
1561
|
+
const ctx = useResourceContext();
|
|
1562
|
+
const collectionId = id ? id : ctx.collection;
|
|
1563
|
+
const collection = useVaultSelector((s) => collectionId ? s.iiif.entities.Collection[collectionId] : void 0, [collectionId]);
|
|
1564
|
+
return React.useMemo(() => {
|
|
1565
|
+
if (!collection) {
|
|
1566
|
+
return void 0;
|
|
1567
|
+
}
|
|
1568
|
+
if (selector) {
|
|
1569
|
+
return selector(collection);
|
|
1570
|
+
}
|
|
1571
|
+
return collection;
|
|
1572
|
+
}, [collection, selector, ...deps]);
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
function useEventListener(resource, name, listener, scope, deps = []) {
|
|
1298
1576
|
const vault = useVault();
|
|
1299
|
-
const
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
motivation: null,
|
|
1310
|
-
label: null,
|
|
1311
|
-
thumbnail: [],
|
|
1312
|
-
summary: null,
|
|
1313
|
-
requiredStatement: null,
|
|
1314
|
-
metadata: [],
|
|
1315
|
-
rights: null,
|
|
1316
|
-
provider: [],
|
|
1317
|
-
items: [],
|
|
1318
|
-
seeAlso: [],
|
|
1319
|
-
homepage: [],
|
|
1320
|
-
logo: [],
|
|
1321
|
-
rendering: [],
|
|
1322
|
-
service: []
|
|
1577
|
+
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
1578
|
+
React.useEffect(() => {
|
|
1579
|
+
const currentResource = resource;
|
|
1580
|
+
if (!currentResource) {
|
|
1581
|
+
return () => {
|
|
1582
|
+
};
|
|
1583
|
+
}
|
|
1584
|
+
helper.addEventListener(currentResource, name, listener, scope);
|
|
1585
|
+
return () => {
|
|
1586
|
+
helper.removeEventListener(currentResource, name, listener);
|
|
1323
1587
|
};
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1588
|
+
}, [helper, resource, name, ...deps]);
|
|
1589
|
+
}
|
|
1590
|
+
|
|
1591
|
+
function useExistingVault() {
|
|
1592
|
+
const oldContext = React.useContext(ReactVaultContext);
|
|
1593
|
+
return oldContext && oldContext.vault ? oldContext.vault : vault.globalVault();
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
function useExternalCollection(idOrRef, options) {
|
|
1597
|
+
const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
|
|
1598
|
+
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
1599
|
+
}
|
|
1600
|
+
|
|
1601
|
+
var __async = (__this, __arguments, generator) => {
|
|
1602
|
+
return new Promise((resolve, reject) => {
|
|
1603
|
+
var fulfilled = (value) => {
|
|
1604
|
+
try {
|
|
1605
|
+
step(generator.next(value));
|
|
1606
|
+
} catch (e) {
|
|
1607
|
+
reject(e);
|
|
1329
1608
|
}
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
const display = id;
|
|
1337
|
-
if (!display.__vault) {
|
|
1338
|
-
display.bindToVault(vault);
|
|
1339
|
-
}
|
|
1340
|
-
id = typeof display.source === "string" ? display.source : display.source.id;
|
|
1341
|
-
sources.current[id] = display;
|
|
1342
|
-
} else if (typeof id !== "string") {
|
|
1343
|
-
id = id.id;
|
|
1609
|
+
};
|
|
1610
|
+
var rejected = (value) => {
|
|
1611
|
+
try {
|
|
1612
|
+
step(generator.throw(value));
|
|
1613
|
+
} catch (e) {
|
|
1614
|
+
reject(e);
|
|
1344
1615
|
}
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1616
|
+
};
|
|
1617
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
1618
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
1619
|
+
});
|
|
1620
|
+
};
|
|
1621
|
+
function useImageService({ cacheKey } = {}) {
|
|
1622
|
+
const canvas = useCanvas();
|
|
1623
|
+
const annotations = usePaintingAnnotations();
|
|
1624
|
+
const vault = useVault();
|
|
1625
|
+
const imageService = useImageServiceLoader();
|
|
1626
|
+
const [_data, setData] = React.useState(void 0);
|
|
1627
|
+
const [isFetching, setIsFetching] = React.useState(false);
|
|
1628
|
+
const [status, setStatus] = React.useState("idle");
|
|
1629
|
+
const [error, setError] = React.useState(void 0);
|
|
1630
|
+
const key = canvas ? canvas.id : "undefined";
|
|
1631
|
+
const initialData = React.useMemo(() => {
|
|
1632
|
+
try {
|
|
1633
|
+
if (canvas && annotations.length) {
|
|
1634
|
+
const annotation = annotations[0];
|
|
1635
|
+
const resource = vault.get(annotation.body[0]);
|
|
1636
|
+
const imageServices = iiifImageApi.getImageServices(resource);
|
|
1637
|
+
const firstImageService = imageServices[0];
|
|
1638
|
+
if (!firstImageService) {
|
|
1639
|
+
return void 0;
|
|
1359
1640
|
}
|
|
1641
|
+
return imageService.loadServiceSync({
|
|
1642
|
+
id: firstImageService.id || firstImageService["@id"],
|
|
1643
|
+
width: firstImageService.width || canvas.width,
|
|
1644
|
+
height: firstImageService.height || canvas.height
|
|
1645
|
+
}) || void 0;
|
|
1360
1646
|
}
|
|
1647
|
+
} catch (e) {
|
|
1648
|
+
console.error(e);
|
|
1361
1649
|
}
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
dispatch(entityActions.removeReference({
|
|
1376
|
-
id: virtualId,
|
|
1377
|
-
type: "AnnotationPage",
|
|
1378
|
-
key: "items",
|
|
1379
|
-
reference: {
|
|
1380
|
-
id,
|
|
1381
|
-
type: "Annotation"
|
|
1650
|
+
return void 0;
|
|
1651
|
+
}, [key, cacheKey, canvas]);
|
|
1652
|
+
const data = status === "success" && _data ? _data : initialData;
|
|
1653
|
+
React.useEffect(() => {
|
|
1654
|
+
(() => __async(this, null, function* () {
|
|
1655
|
+
try {
|
|
1656
|
+
if (canvas && annotations.length) {
|
|
1657
|
+
const annotation = annotations[0];
|
|
1658
|
+
const resource = vault.get(annotation.body[0]);
|
|
1659
|
+
const imageServices = iiifImageApi.getImageServices(resource);
|
|
1660
|
+
const firstImageService = imageServices[0];
|
|
1661
|
+
if (!firstImageService) {
|
|
1662
|
+
return;
|
|
1382
1663
|
}
|
|
1383
|
-
|
|
1664
|
+
setIsFetching(true);
|
|
1665
|
+
setStatus("loading");
|
|
1666
|
+
try {
|
|
1667
|
+
const loadedService = (yield imageService.loadService({
|
|
1668
|
+
id: firstImageService.id || firstImageService["@id"],
|
|
1669
|
+
width: firstImageService.width || canvas.width,
|
|
1670
|
+
height: firstImageService.height || canvas.height
|
|
1671
|
+
})) || void 0;
|
|
1672
|
+
setData(loadedService);
|
|
1673
|
+
setStatus("success");
|
|
1674
|
+
setIsFetching(false);
|
|
1675
|
+
} catch (err) {
|
|
1676
|
+
setStatus("error");
|
|
1677
|
+
setError(err);
|
|
1678
|
+
}
|
|
1679
|
+
}
|
|
1680
|
+
} catch (err) {
|
|
1681
|
+
setStatus("error");
|
|
1682
|
+
setError(err);
|
|
1384
1683
|
}
|
|
1684
|
+
}))();
|
|
1685
|
+
}, [key, cacheKey]);
|
|
1686
|
+
return React.useMemo(() => {
|
|
1687
|
+
return {
|
|
1688
|
+
data,
|
|
1689
|
+
isFetching,
|
|
1690
|
+
status,
|
|
1691
|
+
error
|
|
1692
|
+
};
|
|
1693
|
+
}, [data, isFetching, status, error]);
|
|
1694
|
+
}
|
|
1695
|
+
|
|
1696
|
+
function useImageTile() {
|
|
1697
|
+
const imageService = useImageService();
|
|
1698
|
+
return {
|
|
1699
|
+
isLoading: imageService.isFetching,
|
|
1700
|
+
tile: imageService.data ? {
|
|
1701
|
+
id: imageService.data.id || imageService.data["@id"],
|
|
1702
|
+
width: imageService.data.width,
|
|
1703
|
+
height: imageService.data.height,
|
|
1704
|
+
imageService: imageService.data,
|
|
1705
|
+
thumbnail: void 0
|
|
1706
|
+
} : null
|
|
1707
|
+
};
|
|
1708
|
+
}
|
|
1709
|
+
|
|
1710
|
+
function useRange(options = {}, deps = []) {
|
|
1711
|
+
const { id, selector } = options;
|
|
1712
|
+
const ctx = useResourceContext();
|
|
1713
|
+
const rangeId = id ? id : ctx.range;
|
|
1714
|
+
const range = useVaultSelector((s) => rangeId ? s.iiif.entities.Range[rangeId] : void 0, [rangeId]);
|
|
1715
|
+
return React.useMemo(() => {
|
|
1716
|
+
if (!range) {
|
|
1717
|
+
return void 0;
|
|
1385
1718
|
}
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
fullPage,
|
|
1389
|
-
{
|
|
1390
|
-
addAnnotation,
|
|
1391
|
-
removeAnnotation
|
|
1719
|
+
if (selector) {
|
|
1720
|
+
return selector(range);
|
|
1392
1721
|
}
|
|
1393
|
-
|
|
1722
|
+
return range;
|
|
1723
|
+
}, [range, selector, ...deps]);
|
|
1394
1724
|
}
|
|
1395
1725
|
|
|
1396
|
-
|
|
1397
|
-
var __defProps = Object.defineProperties;
|
|
1398
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1399
|
-
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1400
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
1401
|
-
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
1402
|
-
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1403
|
-
var __spreadValues = (a, b) => {
|
|
1404
|
-
for (var prop in b || (b = {}))
|
|
1405
|
-
if (__hasOwnProp.call(b, prop))
|
|
1406
|
-
__defNormalProp(a, prop, b[prop]);
|
|
1407
|
-
if (__getOwnPropSymbols)
|
|
1408
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
1409
|
-
if (__propIsEnum.call(b, prop))
|
|
1410
|
-
__defNormalProp(a, prop, b[prop]);
|
|
1411
|
-
}
|
|
1412
|
-
return a;
|
|
1413
|
-
};
|
|
1414
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1415
|
-
function useRenderingStrategy(options) {
|
|
1726
|
+
function useSearchService() {
|
|
1416
1727
|
const manifest = useManifest();
|
|
1417
|
-
|
|
1728
|
+
return manifest ? manifest.service.find((service) => service.profile === "SearchService1" || service.profile === "http://iiif.io/api/search/1/search") : void 0;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
function useStyleHelper() {
|
|
1418
1732
|
const vault = useVault();
|
|
1419
|
-
|
|
1420
|
-
const { enabledPageIds } = useAnnotationPageManager((options == null ? void 0 : options.annotationPageManagerId) || (manifest == null ? void 0 : manifest.id) || (canvas == null ? void 0 : canvas.id), {
|
|
1421
|
-
all: false
|
|
1422
|
-
});
|
|
1423
|
-
const enabledPages = useResources(enabledPageIds, "AnnotationPage");
|
|
1424
|
-
const supports = (options == null ? void 0 : options.strategies) || ["images", "media", "complex-timeline"];
|
|
1425
|
-
const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
|
|
1426
|
-
const strategy = React.useMemo(() => {
|
|
1427
|
-
if (!canvas || paintables.types.length === 0) {
|
|
1428
|
-
return unknownResponse;
|
|
1429
|
-
}
|
|
1430
|
-
if (paintables.types.length !== 1) {
|
|
1431
|
-
if (supports.indexOf("complex-timeline") === -1) {
|
|
1432
|
-
return unsupportedStrategy("Complex timeline not supported");
|
|
1433
|
-
}
|
|
1434
|
-
return unsupportedStrategy("ComplexTimelineStrategy not yet supported");
|
|
1435
|
-
}
|
|
1436
|
-
const mainType = paintables.types[0];
|
|
1437
|
-
if (mainType === "image") {
|
|
1438
|
-
if (supports.indexOf("images") === -1) {
|
|
1439
|
-
return unsupportedStrategy("Image not supported");
|
|
1440
|
-
}
|
|
1441
|
-
return getImageStrategy(canvas, paintables, loadImageService);
|
|
1442
|
-
}
|
|
1443
|
-
if (mainType === "audio") {
|
|
1444
|
-
if (supports.indexOf("media") === -1) {
|
|
1445
|
-
return unsupportedStrategy("Media not supported");
|
|
1446
|
-
}
|
|
1447
|
-
return unsupportedStrategy("Audio strategy not yet supported");
|
|
1448
|
-
}
|
|
1449
|
-
if (mainType === "video") {
|
|
1450
|
-
if (supports.indexOf("media") === -1) {
|
|
1451
|
-
return unsupportedStrategy("Media not supported");
|
|
1452
|
-
}
|
|
1453
|
-
return unsupportedStrategy("Video strategy not yet supported");
|
|
1454
|
-
}
|
|
1455
|
-
return unknownResponse;
|
|
1456
|
-
}, [canvas, paintables, vault, actions.makeChoice]);
|
|
1457
|
-
return React.useMemo(() => {
|
|
1458
|
-
if (strategy.type === "unknown") {
|
|
1459
|
-
return [strategy, emptyActions];
|
|
1460
|
-
}
|
|
1461
|
-
return [
|
|
1462
|
-
__spreadProps(__spreadValues({}, strategy), {
|
|
1463
|
-
annotations: { pages: enabledPages }
|
|
1464
|
-
}),
|
|
1465
|
-
actions
|
|
1466
|
-
];
|
|
1467
|
-
}, [strategy, enabledPages]);
|
|
1733
|
+
return React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
1468
1734
|
}
|
|
1469
1735
|
|
|
1470
1736
|
exports.AnnotationContext = AnnotationContext;
|
|
1471
1737
|
exports.CanvasContext = CanvasContext;
|
|
1738
|
+
exports.CanvasPanel = CanvasPanel;
|
|
1472
1739
|
exports.CollectionContext = CollectionContext;
|
|
1473
1740
|
exports.ContextBridge = ContextBridge;
|
|
1474
1741
|
exports.ImageServiceLoaderContext = ImageServiceLoaderContext;
|
|
@@ -1480,6 +1747,7 @@ exports.ResourceReactContext = ResourceReactContext;
|
|
|
1480
1747
|
exports.SimpleViewerProvider = SimpleViewerProvider;
|
|
1481
1748
|
exports.SimpleViewerReactContext = SimpleViewerReactContext;
|
|
1482
1749
|
exports.VaultProvider = VaultProvider;
|
|
1750
|
+
exports.VirtualAnnotationProvider = VirtualAnnotationProvider;
|
|
1483
1751
|
exports.VisibleCanvasReactContext = VisibleCanvasReactContext;
|
|
1484
1752
|
exports.emptyActions = emptyActions;
|
|
1485
1753
|
exports.expandTarget = expandTarget;
|
|
@@ -1524,4 +1792,5 @@ exports.useVault = useVault;
|
|
|
1524
1792
|
exports.useVaultEffect = useVaultEffect;
|
|
1525
1793
|
exports.useVaultSelector = useVaultSelector;
|
|
1526
1794
|
exports.useVirtualAnnotationPage = useVirtualAnnotationPage;
|
|
1795
|
+
exports.useVirtualAnnotationPageContext = useVirtualAnnotationPageContext;
|
|
1527
1796
|
exports.useVisibleCanvases = useVisibleCanvases;
|