react-iiif-vault 0.9.11 → 0.9.14
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/.build/types/canvas-panel/Viewer.d.ts +13 -0
- package/.build/types/canvas-panel/index.d.ts +18 -0
- package/.build/types/canvas-panel/render/Annotation.d.ts +8 -0
- package/.build/types/canvas-panel/render/AnnotationPage.d.ts +6 -0
- package/.build/types/canvas-panel/render/Audio.d.ts +6 -0
- package/.build/types/canvas-panel/render/Canvas.d.ts +23 -0
- package/.build/types/canvas-panel/render/DefaultCanvasFallback.d.ts +5 -0
- package/.build/types/canvas-panel/render/Image.d.ts +13 -0
- package/.build/types/canvas-panel/render/Model.d.ts +3 -0
- package/.build/types/canvas-panel/render/Video.d.ts +6 -0
- package/.build/types/context/AnnotationContext.d.ts +5 -0
- package/.build/types/context/CanvasContext.d.ts +5 -0
- package/.build/types/context/CollectionContext.d.ts +5 -0
- package/.build/types/context/ContextBridge.d.ts +22 -0
- package/.build/types/context/ImageServiceLoaderContext.d.ts +4 -0
- package/.build/types/context/ManifestContext.d.ts +5 -0
- package/.build/types/context/MediaContext.d.ts +17 -0
- package/.build/types/context/PortalContext.d.ts +7 -0
- package/.build/types/context/RangeContext.d.ts +5 -0
- package/.build/types/context/ResourceContext.d.ts +14 -0
- package/.build/types/context/VaultContext.d.ts +14 -0
- package/.build/types/context/ViewerPresetContext.d.ts +3 -0
- package/.build/types/context/VisibleCanvasContext.d.ts +4 -0
- package/.build/types/demo/demo.d.ts +1 -0
- package/.build/types/demo/media-controls.d.ts +1 -0
- package/.build/types/demo/viewer-controls.d.ts +1 -0
- package/.build/types/features/rendering-strategy/3d-strategy.d.ts +13 -0
- package/.build/types/features/rendering-strategy/audio-strategy.d.ts +3 -0
- package/.build/types/features/rendering-strategy/choice-types.d.ts +15 -0
- package/.build/types/features/rendering-strategy/image-strategy.d.ts +13 -0
- package/.build/types/features/rendering-strategy/rendering-utils.d.ts +21 -0
- package/.build/types/features/rendering-strategy/resource-types.d.ts +42 -0
- package/.build/types/features/rendering-strategy/strategies.d.ts +22 -0
- package/.build/types/features/rendering-strategy/video-strategy.d.ts +3 -0
- package/.build/types/hooks/useAnnotation.d.ts +8 -0
- package/.build/types/hooks/useAnnotationPageManager.d.ts +10 -0
- package/.build/types/hooks/useAnnotationsAtTime.d.ts +4 -0
- package/.build/types/hooks/useCanvas.d.ts +8 -0
- package/.build/types/hooks/useCanvasClock.d.ts +1 -0
- package/.build/types/hooks/useCanvasSelector.d.ts +0 -0
- package/.build/types/hooks/useCanvasTimeline.d.ts +0 -0
- package/.build/types/hooks/useCollection.d.ts +8 -0
- package/.build/types/hooks/useDispatch.d.ts +2 -0
- package/.build/types/hooks/useEnabledAnnotationPageIds.d.ts +1 -0
- package/.build/types/hooks/useEventListener.d.ts +4 -0
- package/.build/types/hooks/useExistingVault.d.ts +1 -0
- package/.build/types/hooks/useExternalCollection.d.ts +13 -0
- package/.build/types/hooks/useExternalManifest.d.ts +13 -0
- package/.build/types/hooks/useExternalResource.d.ts +16 -0
- package/.build/types/hooks/useImageService.d.ts +9 -0
- package/.build/types/hooks/useImageTile.d.ts +11 -0
- package/.build/types/hooks/useLoadImageService.d.ts +6 -0
- package/.build/types/hooks/useManifest.d.ts +8 -0
- package/.build/types/hooks/usePaintables.d.ts +8 -0
- package/.build/types/hooks/usePaintingAnnotations.d.ts +4 -0
- package/.build/types/hooks/useRange.d.ts +8 -0
- package/.build/types/hooks/useRenderingStrategy.d.ts +14 -0
- package/.build/types/hooks/useResourceEvents.d.ts +3 -0
- package/.build/types/hooks/useResources.d.ts +1 -0
- package/.build/types/hooks/useSearchService.d.ts +2 -0
- package/.build/types/hooks/useSimpleMediaPlayer.d.ts +32 -0
- package/.build/types/hooks/useStyleHelper.d.ts +1 -0
- package/.build/types/hooks/useStyles.d.ts +3 -0
- package/.build/types/hooks/useThumbnail.d.ts +5 -0
- package/.build/types/hooks/useVault.d.ts +2 -0
- package/.build/types/hooks/useVaultEffect.d.ts +2 -0
- package/.build/types/hooks/useVaultSelector.d.ts +2 -0
- package/.build/types/hooks/useVirtualAnnotationPage.d.ts +13 -0
- package/.build/types/hooks/useVirtualAnnotationPageContext.d.ts +9 -0
- package/.build/types/hooks/useVirtualCanvas.d.ts +0 -0
- package/.build/types/index.d.ts +54 -0
- package/.build/types/utility/flatten-annotation-page-ids.d.ts +7 -0
- package/.build/types/viewers/SimpleViewerContext.d.ts +18 -0
- package/.build/types/viewers/SingleCanvasContext.d.ts +1 -0
- package/dist/bundle/cjs/index.js +28 -0
- package/dist/bundle/cjs/index.js.map +1 -0
- package/dist/{esm → bundle/esm}/index.mjs +707 -790
- package/dist/bundle/esm/index.mjs.map +1 -0
- package/dist/canvas-panel/cjs/canvas-panel.js +28 -0
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -0
- package/dist/canvas-panel/esm/canvas-panel.mjs +2011 -0
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -0
- package/dist/index.umd.js +113 -31744
- package/dist/index.umd.js.map +1 -0
- package/package.json +38 -28
- package/dist/cjs/index.js +0 -2538
- package/dist/index.d.ts +0 -619
|
@@ -1,218 +1,131 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
(
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
})(commonjsGlobal, (function (exports, React) {
|
|
17
|
-
function _interopNamespace(e) {
|
|
18
|
-
if (e && e.__esModule) return e;
|
|
19
|
-
var n = Object.create(null);
|
|
20
|
-
if (e) {
|
|
21
|
-
Object.keys(e).forEach(function (k) {
|
|
22
|
-
if (k !== 'default') {
|
|
23
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
24
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
25
|
-
enumerable: true,
|
|
26
|
-
get: function () { return e[k]; }
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
});
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
30
16
|
}
|
|
31
|
-
|
|
32
|
-
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
var __objRest = (source, exclude) => {
|
|
21
|
+
var target = {};
|
|
22
|
+
for (var prop in source)
|
|
23
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
24
|
+
target[prop] = source[prop];
|
|
25
|
+
if (source != null && __getOwnPropSymbols)
|
|
26
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
27
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
}
|
|
30
|
+
return target;
|
|
31
|
+
};
|
|
32
|
+
import * as React from "react";
|
|
33
|
+
import React__default, { useContext, useMemo, useState, useEffect, createContext, useCallback, useRef, useLayoutEffect, Fragment, useReducer } from "react";
|
|
34
|
+
import { AtlasAuto, mergeStyles, RegionHighlight, TileSet } from "@atlas-viewer/atlas";
|
|
35
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
36
|
+
import { globalVault, Vault } from "@iiif/vault";
|
|
37
|
+
import { createAction } from "typesafe-actions";
|
|
38
|
+
import require$$0 from "react-dom";
|
|
39
|
+
import { ImageServiceLoader, getImageServices, getFixedSizeFromImage } from "@atlas-viewer/iiif-image-api";
|
|
40
|
+
function _setPrototypeOf(o, p) {
|
|
41
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
|
42
|
+
o2.__proto__ = p2;
|
|
43
|
+
return o2;
|
|
44
|
+
};
|
|
45
|
+
return _setPrototypeOf(o, p);
|
|
46
|
+
}
|
|
47
|
+
function _inheritsLoose(subClass, superClass) {
|
|
48
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
49
|
+
subClass.prototype.constructor = subClass;
|
|
50
|
+
_setPrototypeOf(subClass, superClass);
|
|
51
|
+
}
|
|
52
|
+
var changedArray = function changedArray2(a, b) {
|
|
53
|
+
if (a === void 0) {
|
|
54
|
+
a = [];
|
|
33
55
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
function _setPrototypeOf(o, p) {
|
|
38
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
39
|
-
o.__proto__ = p;
|
|
40
|
-
return o;
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
return _setPrototypeOf(o, p);
|
|
56
|
+
if (b === void 0) {
|
|
57
|
+
b = [];
|
|
44
58
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
return a.length !== b.length || a.some(function(item, index) {
|
|
60
|
+
return !Object.is(item, b[index]);
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
var initialState = {
|
|
64
|
+
error: null
|
|
65
|
+
};
|
|
66
|
+
var ErrorBoundary = /* @__PURE__ */ function(_React$Component) {
|
|
67
|
+
_inheritsLoose(ErrorBoundary2, _React$Component);
|
|
68
|
+
function ErrorBoundary2() {
|
|
69
|
+
var _this;
|
|
70
|
+
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
71
|
+
_args[_key] = arguments[_key];
|
|
72
|
+
}
|
|
73
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
|
|
74
|
+
_this.state = initialState;
|
|
75
|
+
_this.resetErrorBoundary = function() {
|
|
76
|
+
var _this$props;
|
|
77
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
78
|
+
args[_key2] = arguments[_key2];
|
|
79
|
+
}
|
|
80
|
+
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args);
|
|
81
|
+
_this.reset();
|
|
82
|
+
};
|
|
83
|
+
return _this;
|
|
50
84
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
if (b === void 0) {
|
|
58
|
-
b = [];
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return a.length !== b.length || a.some(function (item, index) {
|
|
62
|
-
return !Object.is(item, b[index]);
|
|
63
|
-
});
|
|
85
|
+
ErrorBoundary2.getDerivedStateFromError = function getDerivedStateFromError(error) {
|
|
86
|
+
return {
|
|
87
|
+
error
|
|
88
|
+
};
|
|
64
89
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
90
|
+
var _proto = ErrorBoundary2.prototype;
|
|
91
|
+
_proto.reset = function reset() {
|
|
92
|
+
this.setState(initialState);
|
|
68
93
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
|
|
81
|
-
_this.state = initialState;
|
|
82
|
-
|
|
83
|
-
_this.resetErrorBoundary = function () {
|
|
84
|
-
var _this$props;
|
|
85
|
-
|
|
86
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
87
|
-
args[_key2] = arguments[_key2];
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args);
|
|
91
|
-
|
|
92
|
-
_this.reset();
|
|
93
|
-
};
|
|
94
|
-
|
|
95
|
-
return _this;
|
|
94
|
+
_proto.componentDidCatch = function componentDidCatch(error, info) {
|
|
95
|
+
var _this$props$onError, _this$props2;
|
|
96
|
+
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
97
|
+
};
|
|
98
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
99
|
+
var error = this.state.error;
|
|
100
|
+
var resetKeys = this.props.resetKeys;
|
|
101
|
+
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
102
|
+
var _this$props$onResetKe, _this$props3;
|
|
103
|
+
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
|
|
104
|
+
this.reset();
|
|
96
105
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
106
|
+
};
|
|
107
|
+
_proto.render = function render() {
|
|
108
|
+
var error = this.state.error;
|
|
109
|
+
var _this$props4 = this.props, fallbackRender = _this$props4.fallbackRender, FallbackComponent = _this$props4.FallbackComponent, fallback = _this$props4.fallback;
|
|
110
|
+
if (error !== null) {
|
|
111
|
+
var _props = {
|
|
112
|
+
error,
|
|
113
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
101
114
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
_proto.componentDidCatch = function componentDidCatch(error, info) {
|
|
111
|
-
var _this$props$onError, _this$props2;
|
|
112
|
-
|
|
113
|
-
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
117
|
-
var error = this.state.error;
|
|
118
|
-
var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
|
|
119
|
-
// happens to *also* be in the resetKeys array, we'd end up resetting
|
|
120
|
-
// the error boundary immediately. This would likely trigger a second
|
|
121
|
-
// error to be thrown.
|
|
122
|
-
// So we make sure that we don't check the resetKeys on the first call
|
|
123
|
-
// of cDU after the error is set
|
|
124
|
-
|
|
125
|
-
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
126
|
-
var _this$props$onResetKe, _this$props3;
|
|
127
|
-
|
|
128
|
-
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
|
|
129
|
-
this.reset();
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
_proto.render = function render() {
|
|
134
|
-
var error = this.state.error;
|
|
135
|
-
var _this$props4 = this.props,
|
|
136
|
-
fallbackRender = _this$props4.fallbackRender,
|
|
137
|
-
FallbackComponent = _this$props4.FallbackComponent,
|
|
138
|
-
fallback = _this$props4.fallback;
|
|
139
|
-
|
|
140
|
-
if (error !== null) {
|
|
141
|
-
var _props = {
|
|
142
|
-
error: error,
|
|
143
|
-
resetErrorBoundary: this.resetErrorBoundary
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
if ( /*#__PURE__*/React__namespace.isValidElement(fallback)) {
|
|
147
|
-
return fallback;
|
|
148
|
-
} else if (typeof fallbackRender === 'function') {
|
|
149
|
-
return fallbackRender(_props);
|
|
150
|
-
} else if (FallbackComponent) {
|
|
151
|
-
return /*#__PURE__*/React__namespace.createElement(FallbackComponent, _props);
|
|
152
|
-
} else {
|
|
153
|
-
throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
|
|
154
|
-
}
|
|
115
|
+
if (/* @__PURE__ */ React.isValidElement(fallback)) {
|
|
116
|
+
return fallback;
|
|
117
|
+
} else if (typeof fallbackRender === "function") {
|
|
118
|
+
return fallbackRender(_props);
|
|
119
|
+
} else if (FallbackComponent) {
|
|
120
|
+
return /* @__PURE__ */ React.createElement(FallbackComponent, _props);
|
|
121
|
+
} else {
|
|
122
|
+
throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop");
|
|
155
123
|
}
|
|
156
|
-
|
|
157
|
-
return this.props.children;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
return ErrorBoundary;
|
|
161
|
-
}(React__namespace.Component);
|
|
162
|
-
|
|
163
|
-
function withErrorBoundary(Component, errorBoundaryProps) {
|
|
164
|
-
var Wrapped = function Wrapped(props) {
|
|
165
|
-
return /*#__PURE__*/React__namespace.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React__namespace.createElement(Component, props));
|
|
166
|
-
}; // Format for display in DevTools
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
var name = Component.displayName || Component.name || 'Unknown';
|
|
170
|
-
Wrapped.displayName = "withErrorBoundary(" + name + ")";
|
|
171
|
-
return Wrapped;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
function useErrorHandler(givenError) {
|
|
175
|
-
var _React$useState = React__namespace.useState(null),
|
|
176
|
-
error = _React$useState[0],
|
|
177
|
-
setError = _React$useState[1];
|
|
178
|
-
|
|
179
|
-
if (givenError != null) throw givenError;
|
|
180
|
-
if (error != null) throw error;
|
|
181
|
-
return setError;
|
|
182
|
-
}
|
|
183
|
-
/*
|
|
184
|
-
eslint
|
|
185
|
-
@typescript-eslint/sort-type-union-intersection-members: "off",
|
|
186
|
-
@typescript-eslint/no-throw-literal: "off",
|
|
187
|
-
@typescript-eslint/prefer-nullish-coalescing: "off"
|
|
188
|
-
*/
|
|
189
|
-
|
|
190
|
-
exports.ErrorBoundary = ErrorBoundary;
|
|
191
|
-
exports.useErrorHandler = useErrorHandler;
|
|
192
|
-
exports.withErrorBoundary = withErrorBoundary;
|
|
193
|
-
|
|
194
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
195
|
-
|
|
196
|
-
}));
|
|
197
|
-
|
|
198
|
-
}(reactErrorBoundary_umd, reactErrorBoundary_umd.exports));
|
|
199
|
-
|
|
200
|
-
var __defProp$a = Object.defineProperty;
|
|
201
|
-
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
202
|
-
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
203
|
-
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
204
|
-
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
205
|
-
var __spreadValues$a = (a, b) => {
|
|
206
|
-
for (var prop in b || (b = {}))
|
|
207
|
-
if (__hasOwnProp$a.call(b, prop))
|
|
208
|
-
__defNormalProp$a(a, prop, b[prop]);
|
|
209
|
-
if (__getOwnPropSymbols$a)
|
|
210
|
-
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
211
|
-
if (__propIsEnum$a.call(b, prop))
|
|
212
|
-
__defNormalProp$a(a, prop, b[prop]);
|
|
213
124
|
}
|
|
214
|
-
|
|
215
|
-
};
|
|
125
|
+
return this.props.children;
|
|
126
|
+
};
|
|
127
|
+
return ErrorBoundary2;
|
|
128
|
+
}(React.Component);
|
|
216
129
|
const defaultResourceContext = {
|
|
217
130
|
collection: void 0,
|
|
218
131
|
manifest: void 0,
|
|
@@ -220,21 +133,24 @@ const defaultResourceContext = {
|
|
|
220
133
|
canvas: void 0,
|
|
221
134
|
annotation: void 0
|
|
222
135
|
};
|
|
223
|
-
const ResourceReactContext =
|
|
136
|
+
const ResourceReactContext = React__default.createContext(defaultResourceContext);
|
|
224
137
|
const useResourceContext = () => {
|
|
225
138
|
return useContext(ResourceReactContext);
|
|
226
139
|
};
|
|
227
|
-
function ResourceProvider({
|
|
140
|
+
function ResourceProvider({
|
|
141
|
+
value,
|
|
142
|
+
children
|
|
143
|
+
}) {
|
|
228
144
|
const parentContext = useResourceContext();
|
|
229
145
|
const newContext = useMemo(() => {
|
|
230
|
-
return __spreadValues
|
|
146
|
+
return __spreadValues(__spreadValues({}, parentContext), value);
|
|
231
147
|
}, [value, parentContext]);
|
|
232
|
-
return /* @__PURE__ */
|
|
233
|
-
value: newContext
|
|
234
|
-
|
|
148
|
+
return /* @__PURE__ */ jsx(ResourceReactContext.Provider, {
|
|
149
|
+
value: newContext,
|
|
150
|
+
children
|
|
151
|
+
});
|
|
235
152
|
}
|
|
236
|
-
|
|
237
|
-
const ReactVaultContext = React$1.createContext({
|
|
153
|
+
const ReactVaultContext = React__default.createContext({
|
|
238
154
|
vault: null,
|
|
239
155
|
setVaultInstance: (vault) => {
|
|
240
156
|
}
|
|
@@ -258,13 +174,17 @@ function VaultProvider({
|
|
|
258
174
|
}
|
|
259
175
|
return new Vault();
|
|
260
176
|
});
|
|
261
|
-
return /* @__PURE__ */
|
|
262
|
-
value: {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
177
|
+
return /* @__PURE__ */ jsx(ReactVaultContext.Provider, {
|
|
178
|
+
value: {
|
|
179
|
+
vault: vaultInstance,
|
|
180
|
+
setVaultInstance
|
|
181
|
+
},
|
|
182
|
+
children: /* @__PURE__ */ jsx(ResourceProvider, {
|
|
183
|
+
value: resources || {},
|
|
184
|
+
children
|
|
185
|
+
})
|
|
186
|
+
});
|
|
266
187
|
}
|
|
267
|
-
|
|
268
188
|
const useVault = () => {
|
|
269
189
|
const { vault } = useContext(ReactVaultContext);
|
|
270
190
|
if (vault === null) {
|
|
@@ -272,27 +192,6 @@ const useVault = () => {
|
|
|
272
192
|
}
|
|
273
193
|
return vault;
|
|
274
194
|
};
|
|
275
|
-
|
|
276
|
-
var __async$1 = (__this, __arguments, generator) => {
|
|
277
|
-
return new Promise((resolve, reject) => {
|
|
278
|
-
var fulfilled = (value) => {
|
|
279
|
-
try {
|
|
280
|
-
step(generator.next(value));
|
|
281
|
-
} catch (e) {
|
|
282
|
-
reject(e);
|
|
283
|
-
}
|
|
284
|
-
};
|
|
285
|
-
var rejected = (value) => {
|
|
286
|
-
try {
|
|
287
|
-
step(generator.throw(value));
|
|
288
|
-
} catch (e) {
|
|
289
|
-
reject(e);
|
|
290
|
-
}
|
|
291
|
-
};
|
|
292
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
293
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
294
|
-
});
|
|
295
|
-
};
|
|
296
195
|
function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
297
196
|
const id = typeof idOrRef === "string" ? idOrRef : idOrRef.id;
|
|
298
197
|
const vault = useVault();
|
|
@@ -303,9 +202,9 @@ function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
|
303
202
|
}, [id, vault]);
|
|
304
203
|
const [resource, setResource] = useState(initialData);
|
|
305
204
|
useEffect(() => {
|
|
306
|
-
(() =>
|
|
205
|
+
(async () => {
|
|
307
206
|
try {
|
|
308
|
-
const fetchedResource = initialData && !noCache ? initialData :
|
|
207
|
+
const fetchedResource = initialData && !noCache ? initialData : await vault.load(id);
|
|
309
208
|
const _realId = fetchedResource ? fetchedResource.id || fetchedResource["@id"] : null;
|
|
310
209
|
if (fetchedResource && realId !== _realId) {
|
|
311
210
|
setRealId(_realId);
|
|
@@ -314,7 +213,7 @@ function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
|
314
213
|
} catch (err) {
|
|
315
214
|
setError(err);
|
|
316
215
|
}
|
|
317
|
-
})
|
|
216
|
+
})();
|
|
318
217
|
}, [id, noCache]);
|
|
319
218
|
return {
|
|
320
219
|
isLoaded: !!resource,
|
|
@@ -325,24 +224,32 @@ function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
|
325
224
|
cached: !!(resource && resource === initialData)
|
|
326
225
|
};
|
|
327
226
|
}
|
|
328
|
-
|
|
329
227
|
function useExternalManifest(idOrRef, options) {
|
|
330
228
|
const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
|
|
331
229
|
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
332
230
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
231
|
+
function ManifestContext({
|
|
232
|
+
manifest,
|
|
233
|
+
children
|
|
234
|
+
}) {
|
|
235
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
236
|
+
value: {
|
|
237
|
+
manifest
|
|
238
|
+
},
|
|
239
|
+
children
|
|
240
|
+
});
|
|
338
241
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
242
|
+
function CanvasContext({
|
|
243
|
+
canvas,
|
|
244
|
+
children
|
|
245
|
+
}) {
|
|
246
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
247
|
+
value: {
|
|
248
|
+
canvas
|
|
249
|
+
},
|
|
250
|
+
children
|
|
251
|
+
});
|
|
344
252
|
}
|
|
345
|
-
|
|
346
253
|
function useVaultSelector(selector, deps = []) {
|
|
347
254
|
const vault = useVault();
|
|
348
255
|
const [selectedState, setSelectedState] = useState(() => selector(vault.getState(), vault));
|
|
@@ -353,15 +260,13 @@ function useVaultSelector(selector, deps = []) {
|
|
|
353
260
|
}, deps);
|
|
354
261
|
return selectedState;
|
|
355
262
|
}
|
|
356
|
-
|
|
357
|
-
const VisibleCanvasReactContext = React$1.createContext([]);
|
|
263
|
+
const VisibleCanvasReactContext = React__default.createContext([]);
|
|
358
264
|
function useVisibleCanvases() {
|
|
359
265
|
const ids = useContext(VisibleCanvasReactContext);
|
|
360
266
|
return useVaultSelector((state) => {
|
|
361
267
|
return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);
|
|
362
268
|
}, [ids]);
|
|
363
269
|
}
|
|
364
|
-
|
|
365
270
|
const noop = () => {
|
|
366
271
|
};
|
|
367
272
|
const SimpleViewerReactContext = createContext({
|
|
@@ -456,25 +361,32 @@ function SimpleViewerProvider(props) {
|
|
|
456
361
|
}), [nextCanvas, previousCanvas, currentCanvasIndex, canvasList, setCurrentCanvasIndex, internalSetCurrentCanvasId]);
|
|
457
362
|
if (!manifest.manifest) {
|
|
458
363
|
console.warn("The manifest passed to the provider is not a valid IIIF manifest.");
|
|
459
|
-
return /* @__PURE__ */
|
|
364
|
+
return /* @__PURE__ */ jsx("div", {
|
|
365
|
+
children: "Sorry, something went wrong."
|
|
366
|
+
});
|
|
460
367
|
}
|
|
461
368
|
if (!manifest.isLoaded) {
|
|
462
|
-
return /* @__PURE__ */
|
|
369
|
+
return /* @__PURE__ */ jsx("div", {
|
|
370
|
+
children: "Loading..."
|
|
371
|
+
});
|
|
463
372
|
}
|
|
464
|
-
return /* @__PURE__ */
|
|
465
|
-
value: ctx
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
373
|
+
return /* @__PURE__ */ jsx(SimpleViewerReactContext.Provider, {
|
|
374
|
+
value: ctx,
|
|
375
|
+
children: /* @__PURE__ */ jsx(VisibleCanvasReactContext.Provider, {
|
|
376
|
+
value: visible,
|
|
377
|
+
children: /* @__PURE__ */ jsx(ManifestContext, {
|
|
378
|
+
manifest: manifest.manifest.id,
|
|
379
|
+
children: /* @__PURE__ */ jsx(CanvasContext, {
|
|
380
|
+
canvas: currentCanvasId,
|
|
381
|
+
children: props.children
|
|
382
|
+
})
|
|
383
|
+
})
|
|
384
|
+
})
|
|
385
|
+
});
|
|
473
386
|
}
|
|
474
387
|
function useSimpleViewer() {
|
|
475
388
|
return useContext(SimpleViewerReactContext);
|
|
476
389
|
}
|
|
477
|
-
|
|
478
390
|
function useContextBridge() {
|
|
479
391
|
return {
|
|
480
392
|
VaultContext: useContext(ReactVaultContext),
|
|
@@ -484,16 +396,18 @@ function useContextBridge() {
|
|
|
484
396
|
};
|
|
485
397
|
}
|
|
486
398
|
function ContextBridge(props) {
|
|
487
|
-
return /* @__PURE__ */
|
|
399
|
+
return /* @__PURE__ */ jsx(VaultProvider, {
|
|
488
400
|
vault: props.bridge.VaultContext.vault || void 0,
|
|
489
|
-
resources: props.bridge.ResourceContext
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
|
|
401
|
+
resources: props.bridge.ResourceContext,
|
|
402
|
+
children: /* @__PURE__ */ jsx(VisibleCanvasReactContext.Provider, {
|
|
403
|
+
value: props.bridge.VisibleCanvasReactContext,
|
|
404
|
+
children: /* @__PURE__ */ jsx(SimpleViewerReactContext.Provider, {
|
|
405
|
+
value: props.bridge.SimpleViewerReactContext,
|
|
406
|
+
children: props.children
|
|
407
|
+
})
|
|
408
|
+
})
|
|
409
|
+
});
|
|
410
|
+
}
|
|
497
411
|
const IMPORT_ENTITIES = "@iiif/IMPORT_ENTITIES";
|
|
498
412
|
const MODIFY_ENTITY_FIELD = "@iiif/MODIFY_ENTITY_FIELD";
|
|
499
413
|
const REORDER_ENTITY_FIELD = "@iiif/REORDER_ENTITY_FIELD";
|
|
@@ -505,12 +419,10 @@ const reorderEntityField = createAction(REORDER_ENTITY_FIELD)();
|
|
|
505
419
|
const addReference = createAction(ADD_REFERENCE)();
|
|
506
420
|
const removeReference = createAction(REMOVE_REFERENCE)();
|
|
507
421
|
const entityActions = { importEntities, modifyEntityField, reorderEntityField, addReference, removeReference };
|
|
508
|
-
|
|
509
422
|
const ADD_MAPPING = "@iiif/ADD_MAPPING";
|
|
510
423
|
const ADD_MAPPINGS = "@iiif/ADD_MAPPINGS";
|
|
511
424
|
createAction(ADD_MAPPING)();
|
|
512
425
|
createAction(ADD_MAPPINGS)();
|
|
513
|
-
|
|
514
426
|
const SET_META_VALUE = "@iiif/SET_META_VALUE";
|
|
515
427
|
const SET_META_VALUE_DYNAMIC = "@iiif/SET_META_VALUE_DYNAMIC";
|
|
516
428
|
const UNSET_META_VALUE = "@iiif/UNSET_META_VALUE";
|
|
@@ -527,12 +439,10 @@ createAction(REQUEST_ERROR)();
|
|
|
527
439
|
createAction(REQUEST_MISMATCH)();
|
|
528
440
|
createAction(REQUEST_COMPLETE)();
|
|
529
441
|
createAction(REQUEST_OFFLINE_RESOURCE)();
|
|
530
|
-
|
|
531
442
|
const BATCH_ACTIONS = "@iiif/BATCH";
|
|
532
443
|
const BATCH_IMPORT = "@iiif/BATCH_IMPORT";
|
|
533
444
|
createAction(BATCH_ACTIONS)();
|
|
534
445
|
createAction(BATCH_IMPORT)();
|
|
535
|
-
|
|
536
446
|
function useDispatch() {
|
|
537
447
|
const vault = useVault();
|
|
538
448
|
const store = vault.getStore();
|
|
@@ -540,7 +450,6 @@ function useDispatch() {
|
|
|
540
450
|
return (action) => store.dispatch(action);
|
|
541
451
|
}, [store]);
|
|
542
452
|
}
|
|
543
|
-
|
|
544
453
|
function isVaultActivated(obj) {
|
|
545
454
|
return typeof obj !== "string" && obj && obj.bindToVault;
|
|
546
455
|
}
|
|
@@ -642,73 +551,61 @@ function useVirtualAnnotationPage() {
|
|
|
642
551
|
}
|
|
643
552
|
];
|
|
644
553
|
}
|
|
645
|
-
|
|
646
554
|
const VirtualAnnotationPageContext = createContext(null);
|
|
647
555
|
function useVirtualAnnotationPageContext() {
|
|
648
556
|
const ctx = useContext(VirtualAnnotationPageContext);
|
|
649
|
-
return [
|
|
650
|
-
ctx.
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
removeAnnotation: ctx.removeAnnotation
|
|
654
|
-
}
|
|
655
|
-
];
|
|
557
|
+
return [ctx.fullPage, {
|
|
558
|
+
addAnnotation: ctx.addAnnotation,
|
|
559
|
+
removeAnnotation: ctx.removeAnnotation
|
|
560
|
+
}];
|
|
656
561
|
}
|
|
657
|
-
function VirtualAnnotationProvider({
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
562
|
+
function VirtualAnnotationProvider({
|
|
563
|
+
children
|
|
564
|
+
}) {
|
|
565
|
+
const [fullPage, {
|
|
566
|
+
addAnnotation,
|
|
567
|
+
removeAnnotation
|
|
568
|
+
}] = useVirtualAnnotationPage();
|
|
569
|
+
return /* @__PURE__ */ jsx(VirtualAnnotationPageContext.Provider, {
|
|
570
|
+
value: useMemo(() => ({
|
|
571
|
+
fullPage,
|
|
572
|
+
addAnnotation,
|
|
573
|
+
removeAnnotation
|
|
574
|
+
}), [fullPage]),
|
|
575
|
+
children
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
function DefaultCanvasFallback({
|
|
579
|
+
width,
|
|
580
|
+
style,
|
|
581
|
+
height
|
|
582
|
+
}) {
|
|
583
|
+
return /* @__PURE__ */ jsx("div", {
|
|
584
|
+
style: __spreadProps(__spreadValues({
|
|
585
|
+
width,
|
|
586
|
+
height,
|
|
587
|
+
minHeight: 500
|
|
588
|
+
}, style || {}), {
|
|
589
|
+
background: "#f9f9f9"
|
|
590
|
+
}),
|
|
591
|
+
children: "Unknown error"
|
|
592
|
+
});
|
|
687
593
|
}
|
|
688
|
-
|
|
689
594
|
var createRoot;
|
|
690
|
-
|
|
691
595
|
var m = require$$0;
|
|
692
596
|
{
|
|
693
|
-
|
|
694
|
-
createRoot = function(c, o) {
|
|
695
|
-
i.usingClientEntryPoint = true;
|
|
696
|
-
try {
|
|
697
|
-
return m.createRoot(c, o);
|
|
698
|
-
} finally {
|
|
699
|
-
i.usingClientEntryPoint = false;
|
|
700
|
-
}
|
|
701
|
-
};
|
|
597
|
+
createRoot = m.createRoot;
|
|
702
598
|
}
|
|
703
|
-
|
|
704
599
|
const ViewerPresetContext = createContext(null);
|
|
705
600
|
function useViewerPreset() {
|
|
706
601
|
return useContext(ViewerPresetContext);
|
|
707
602
|
}
|
|
708
|
-
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
603
|
+
const PortalContext = React__default.createContext(null);
|
|
604
|
+
const OverlayPortalContext = React__default.createContext(null);
|
|
605
|
+
function CanvasPortal({
|
|
606
|
+
children,
|
|
607
|
+
overlay
|
|
608
|
+
}) {
|
|
712
609
|
const htmlElement = useContext(overlay ? OverlayPortalContext : PortalContext);
|
|
713
610
|
const rootRef = useRef(null);
|
|
714
611
|
const preset = useViewerPreset();
|
|
@@ -726,45 +623,14 @@ function CanvasPortal({ children, overlay }) {
|
|
|
726
623
|
}, []);
|
|
727
624
|
useLayoutEffect(() => {
|
|
728
625
|
if (rootRef.current) {
|
|
729
|
-
rootRef.current.render(/* @__PURE__ */
|
|
730
|
-
value: preset
|
|
731
|
-
|
|
626
|
+
rootRef.current.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
627
|
+
value: preset,
|
|
628
|
+
children
|
|
629
|
+
}));
|
|
732
630
|
}
|
|
733
631
|
}, [children, preset]);
|
|
734
632
|
return null;
|
|
735
633
|
}
|
|
736
|
-
|
|
737
|
-
var __defProp$8 = Object.defineProperty;
|
|
738
|
-
var __defProps$6 = Object.defineProperties;
|
|
739
|
-
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
740
|
-
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
741
|
-
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
742
|
-
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
743
|
-
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
744
|
-
var __spreadValues$8 = (a, b) => {
|
|
745
|
-
for (var prop in b || (b = {}))
|
|
746
|
-
if (__hasOwnProp$8.call(b, prop))
|
|
747
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
748
|
-
if (__getOwnPropSymbols$8)
|
|
749
|
-
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
750
|
-
if (__propIsEnum$8.call(b, prop))
|
|
751
|
-
__defNormalProp$8(a, prop, b[prop]);
|
|
752
|
-
}
|
|
753
|
-
return a;
|
|
754
|
-
};
|
|
755
|
-
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
756
|
-
var __objRest = (source, exclude) => {
|
|
757
|
-
var target = {};
|
|
758
|
-
for (var prop in source)
|
|
759
|
-
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
760
|
-
target[prop] = source[prop];
|
|
761
|
-
if (source != null && __getOwnPropSymbols$8)
|
|
762
|
-
for (var prop of __getOwnPropSymbols$8(source)) {
|
|
763
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
|
|
764
|
-
target[prop] = source[prop];
|
|
765
|
-
}
|
|
766
|
-
return target;
|
|
767
|
-
};
|
|
768
634
|
function Viewer(_a) {
|
|
769
635
|
var _b = _a, {
|
|
770
636
|
children,
|
|
@@ -786,32 +652,91 @@ function Viewer(_a) {
|
|
|
786
652
|
setPortalElement(portal.current);
|
|
787
653
|
setOverlayPortalElement(overlayPortal.current);
|
|
788
654
|
}, []);
|
|
789
|
-
return /* @__PURE__ */
|
|
790
|
-
fallbackRender: () => /* @__PURE__ */
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
655
|
+
return /* @__PURE__ */ jsxs(ErrorBoundary, {
|
|
656
|
+
fallbackRender: () => /* @__PURE__ */ jsx(ErrorFallback, __spreadValues({}, props)),
|
|
657
|
+
children: [/* @__PURE__ */ jsx(AtlasAuto, __spreadProps(__spreadValues({}, props), {
|
|
658
|
+
containerProps: __spreadValues({
|
|
659
|
+
style: {
|
|
660
|
+
position: "relative"
|
|
661
|
+
}
|
|
662
|
+
}, props.containerProps || {}),
|
|
663
|
+
htmlChildren: /* @__PURE__ */ jsx("div", {
|
|
664
|
+
ref: overlayPortal
|
|
665
|
+
}),
|
|
666
|
+
onCreated: (preset) => {
|
|
667
|
+
setViewerPreset(preset);
|
|
668
|
+
if (props.onCreated) {
|
|
669
|
+
props.onCreated(preset);
|
|
670
|
+
}
|
|
671
|
+
},
|
|
672
|
+
children: /* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
673
|
+
value: viewerPreset,
|
|
674
|
+
children: /* @__PURE__ */ jsx(PortalContext.Provider, {
|
|
675
|
+
value: portalElement,
|
|
676
|
+
children: /* @__PURE__ */ jsx(OverlayPortalContext.Provider, {
|
|
677
|
+
value: overlayPortalElement,
|
|
678
|
+
children: /* @__PURE__ */ jsx(ContextBridge, {
|
|
679
|
+
bridge,
|
|
680
|
+
children: /* @__PURE__ */ jsx(VirtualAnnotationProvider, {
|
|
681
|
+
children
|
|
682
|
+
})
|
|
683
|
+
})
|
|
684
|
+
})
|
|
685
|
+
})
|
|
686
|
+
})
|
|
687
|
+
})), /* @__PURE__ */ jsx("div", {
|
|
688
|
+
ref: portal
|
|
689
|
+
})]
|
|
690
|
+
});
|
|
691
|
+
}
|
|
692
|
+
function createEventsHelper(vault) {
|
|
693
|
+
return {
|
|
694
|
+
addEventListener(resource, event, listener, scope) {
|
|
695
|
+
if (!resource) {
|
|
696
|
+
return;
|
|
697
|
+
}
|
|
698
|
+
vault.setMetaValue([resource.id, "eventManager", event], (registeredCallbacks) => {
|
|
699
|
+
const callbacks = registeredCallbacks || [];
|
|
700
|
+
for (const registered of callbacks) {
|
|
701
|
+
if (registered.callback === listener) {
|
|
702
|
+
return callbacks;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
return [...callbacks, { callback: listener, scope }];
|
|
706
|
+
});
|
|
707
|
+
return listener;
|
|
708
|
+
},
|
|
709
|
+
removeEventListener(resource, event, listener) {
|
|
710
|
+
if (!resource) {
|
|
711
|
+
return;
|
|
712
|
+
}
|
|
713
|
+
vault.setMetaValue([resource.id, "eventManager", event], (registeredCallbacks) => {
|
|
714
|
+
return (registeredCallbacks || []).filter((registeredCallback) => registeredCallback.callback !== listener);
|
|
715
|
+
});
|
|
716
|
+
},
|
|
717
|
+
getListenersAsProps(resourceOrId, scope) {
|
|
718
|
+
const resource = typeof resourceOrId === "string" ? { id: resourceOrId } : resourceOrId;
|
|
719
|
+
if (!resource || !resource.id) {
|
|
720
|
+
return {};
|
|
721
|
+
}
|
|
722
|
+
const hooks = vault.getResourceMeta(resource.id, "eventManager");
|
|
723
|
+
const props = {};
|
|
724
|
+
if (hooks && resource) {
|
|
725
|
+
for (const hook of Object.keys(hooks)) {
|
|
726
|
+
props[hook] = (e) => {
|
|
727
|
+
const fullResource = vault.get(resource);
|
|
728
|
+
for (const { callback, scope: _scope } of hooks[hook] || []) {
|
|
729
|
+
if (!_scope || scope && _scope.indexOf(scope) !== -1) {
|
|
730
|
+
callback(e, fullResource);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
};
|
|
734
|
+
}
|
|
800
735
|
}
|
|
736
|
+
return props;
|
|
801
737
|
}
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
}, /* @__PURE__ */ React$1.createElement(PortalContext.Provider, {
|
|
805
|
-
value: portalElement
|
|
806
|
-
}, /* @__PURE__ */ React$1.createElement(OverlayPortalContext.Provider, {
|
|
807
|
-
value: overlayPortalElement
|
|
808
|
-
}, /* @__PURE__ */ React$1.createElement(ContextBridge, {
|
|
809
|
-
bridge
|
|
810
|
-
}, /* @__PURE__ */ React$1.createElement(VirtualAnnotationProvider, null, children)))))), /* @__PURE__ */ React$1.createElement("div", {
|
|
811
|
-
ref: portal
|
|
812
|
-
}));
|
|
813
|
-
}
|
|
814
|
-
|
|
738
|
+
};
|
|
739
|
+
}
|
|
815
740
|
function useResourceEvents(resource, scope) {
|
|
816
741
|
const vault = useVault();
|
|
817
742
|
const helper = useMemo(() => createEventsHelper(vault), [vault]);
|
|
@@ -825,7 +750,18 @@ function useResourceEvents(resource, scope) {
|
|
|
825
750
|
return resource ? helper.getListenersAsProps(resource, scope) : {};
|
|
826
751
|
}, [hooks, resource, vault, scope]);
|
|
827
752
|
}
|
|
828
|
-
|
|
753
|
+
function createStylesHelper(vault) {
|
|
754
|
+
return {
|
|
755
|
+
applyStyles(resource, scope, styles) {
|
|
756
|
+
const id = typeof resource === "string" ? resource : resource.id;
|
|
757
|
+
return vault.setMetaValue([id, "styles", scope], styles);
|
|
758
|
+
},
|
|
759
|
+
getAppliedStyles(resource) {
|
|
760
|
+
const id = typeof resource === "string" ? resource : resource.id;
|
|
761
|
+
return vault.getResourceMeta(id, "styles");
|
|
762
|
+
}
|
|
763
|
+
};
|
|
764
|
+
}
|
|
829
765
|
function useStyles(resource, scope) {
|
|
830
766
|
const vault = useVault();
|
|
831
767
|
const helper = useMemo(() => createStylesHelper(vault), [vault]);
|
|
@@ -837,8 +773,26 @@ function useStyles(resource, scope) {
|
|
|
837
773
|
return styles ? scope ? styles[scope] : styles : void 0;
|
|
838
774
|
}, [resource, scope]);
|
|
839
775
|
}
|
|
840
|
-
|
|
841
|
-
|
|
776
|
+
var __defProp2 = Object.defineProperty;
|
|
777
|
+
var __defProps2 = Object.defineProperties;
|
|
778
|
+
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
779
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
780
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
781
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
782
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
783
|
+
var __spreadValues2 = (a, b) => {
|
|
784
|
+
for (var prop in b || (b = {}))
|
|
785
|
+
if (__hasOwnProp2.call(b, prop))
|
|
786
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
787
|
+
if (__getOwnPropSymbols2)
|
|
788
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
789
|
+
if (__propIsEnum2.call(b, prop))
|
|
790
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
791
|
+
}
|
|
792
|
+
return a;
|
|
793
|
+
};
|
|
794
|
+
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
795
|
+
const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
|
|
842
796
|
const TEMPORAL_SELECTOR = /&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;
|
|
843
797
|
function parseSelector(source) {
|
|
844
798
|
if (Array.isArray(source)) {
|
|
@@ -890,7 +844,7 @@ function parseSelector(source) {
|
|
|
890
844
|
const selector = {
|
|
891
845
|
type: "BoxSelector",
|
|
892
846
|
spatial: {
|
|
893
|
-
unit: matchBoxSelector[2] === "percent:" ? "percent" : "pixel",
|
|
847
|
+
unit: matchBoxSelector[2] === "percent:" || matchBoxSelector[2] === "pct:" ? "percent" : "pixel",
|
|
894
848
|
x: parseFloat(matchBoxSelector[3]),
|
|
895
849
|
y: parseFloat(matchBoxSelector[4]),
|
|
896
850
|
width: parseFloat(matchBoxSelector[5]),
|
|
@@ -926,26 +880,6 @@ function parseSelector(source) {
|
|
|
926
880
|
selectors: []
|
|
927
881
|
};
|
|
928
882
|
}
|
|
929
|
-
|
|
930
|
-
var __defProp$7 = Object.defineProperty;
|
|
931
|
-
var __defProps$5 = Object.defineProperties;
|
|
932
|
-
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
933
|
-
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
934
|
-
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
935
|
-
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
936
|
-
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
937
|
-
var __spreadValues$7 = (a, b) => {
|
|
938
|
-
for (var prop in b || (b = {}))
|
|
939
|
-
if (__hasOwnProp$7.call(b, prop))
|
|
940
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
941
|
-
if (__getOwnPropSymbols$7)
|
|
942
|
-
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
943
|
-
if (__propIsEnum$7.call(b, prop))
|
|
944
|
-
__defNormalProp$7(a, prop, b[prop]);
|
|
945
|
-
}
|
|
946
|
-
return a;
|
|
947
|
-
};
|
|
948
|
-
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
949
883
|
function expandTarget(target, options = {}) {
|
|
950
884
|
if (Array.isArray(target)) {
|
|
951
885
|
return expandTarget(target[0]);
|
|
@@ -1002,7 +936,7 @@ function expandTarget(target, options = {}) {
|
|
|
1002
936
|
if (!fragment) {
|
|
1003
937
|
return {
|
|
1004
938
|
type: "SpecificResource",
|
|
1005
|
-
source:
|
|
939
|
+
source: __spreadProps2(__spreadValues2({}, target), {
|
|
1006
940
|
id
|
|
1007
941
|
}),
|
|
1008
942
|
selector: null,
|
|
@@ -1011,7 +945,7 @@ function expandTarget(target, options = {}) {
|
|
|
1011
945
|
}
|
|
1012
946
|
return expandTarget({
|
|
1013
947
|
type: "SpecificResource",
|
|
1014
|
-
source:
|
|
948
|
+
source: __spreadProps2(__spreadValues2({}, target), {
|
|
1015
949
|
id
|
|
1016
950
|
}),
|
|
1017
951
|
selector: {
|
|
@@ -1027,26 +961,6 @@ function expandTarget(target, options = {}) {
|
|
|
1027
961
|
selectors: []
|
|
1028
962
|
};
|
|
1029
963
|
}
|
|
1030
|
-
|
|
1031
|
-
var __defProp$6 = Object.defineProperty;
|
|
1032
|
-
var __defProps$4 = Object.defineProperties;
|
|
1033
|
-
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
1034
|
-
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1035
|
-
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1036
|
-
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1037
|
-
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1038
|
-
var __spreadValues$6 = (a, b) => {
|
|
1039
|
-
for (var prop in b || (b = {}))
|
|
1040
|
-
if (__hasOwnProp$6.call(b, prop))
|
|
1041
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
1042
|
-
if (__getOwnPropSymbols$6)
|
|
1043
|
-
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1044
|
-
if (__propIsEnum$6.call(b, prop))
|
|
1045
|
-
__defNormalProp$6(a, prop, b[prop]);
|
|
1046
|
-
}
|
|
1047
|
-
return a;
|
|
1048
|
-
};
|
|
1049
|
-
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
1050
964
|
function useAnnotation(options = {}, deps = []) {
|
|
1051
965
|
const { id, selector } = options;
|
|
1052
966
|
const ctx = useResourceContext();
|
|
@@ -1058,7 +972,7 @@ function useAnnotation(options = {}, deps = []) {
|
|
|
1058
972
|
if (!annotation) {
|
|
1059
973
|
return void 0;
|
|
1060
974
|
}
|
|
1061
|
-
const newAnnotation = __spreadProps
|
|
975
|
+
const newAnnotation = __spreadProps(__spreadValues({}, annotation), {
|
|
1062
976
|
body,
|
|
1063
977
|
target: expandTarget(annotation.target, { typeMap: vault.getState().iiif.mapping })
|
|
1064
978
|
});
|
|
@@ -1068,7 +982,6 @@ function useAnnotation(options = {}, deps = []) {
|
|
|
1068
982
|
return newAnnotation;
|
|
1069
983
|
}, [annotation, selector, body, ...deps]);
|
|
1070
984
|
}
|
|
1071
|
-
|
|
1072
985
|
function useCanvas(options = {}, deps = []) {
|
|
1073
986
|
const { id, selector } = options;
|
|
1074
987
|
const ctx = useResourceContext();
|
|
@@ -1084,30 +997,15 @@ function useCanvas(options = {}, deps = []) {
|
|
|
1084
997
|
return canvas;
|
|
1085
998
|
}, [canvas, selector, ...deps]);
|
|
1086
999
|
}
|
|
1087
|
-
|
|
1088
|
-
var __defProp$5 = Object.defineProperty;
|
|
1089
|
-
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1090
|
-
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1091
|
-
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1092
|
-
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1093
|
-
var __spreadValues$5 = (a, b) => {
|
|
1094
|
-
for (var prop in b || (b = {}))
|
|
1095
|
-
if (__hasOwnProp$5.call(b, prop))
|
|
1096
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
1097
|
-
if (__getOwnPropSymbols$5)
|
|
1098
|
-
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1099
|
-
if (__propIsEnum$5.call(b, prop))
|
|
1100
|
-
__defNormalProp$5(a, prop, b[prop]);
|
|
1101
|
-
}
|
|
1102
|
-
return a;
|
|
1103
|
-
};
|
|
1104
1000
|
const RenderAnnotation = ({
|
|
1105
1001
|
id,
|
|
1106
1002
|
style: defaultStyle,
|
|
1107
1003
|
className,
|
|
1108
1004
|
interactive
|
|
1109
1005
|
}) => {
|
|
1110
|
-
const annotation = useAnnotation({
|
|
1006
|
+
const annotation = useAnnotation({
|
|
1007
|
+
id
|
|
1008
|
+
});
|
|
1111
1009
|
const style = useStyles(annotation, "atlas");
|
|
1112
1010
|
const html = useStyles(annotation, "html");
|
|
1113
1011
|
const events = useResourceEvents(annotation, ["atlas"]);
|
|
@@ -1119,7 +1017,7 @@ const RenderAnnotation = ({
|
|
|
1119
1017
|
if (!isValid) {
|
|
1120
1018
|
return null;
|
|
1121
1019
|
}
|
|
1122
|
-
return /* @__PURE__ */
|
|
1020
|
+
return /* @__PURE__ */ jsx(RegionHighlight, __spreadValues({
|
|
1123
1021
|
id: annotation.id,
|
|
1124
1022
|
isEditing: true,
|
|
1125
1023
|
region: annotation.target.selector.spatial,
|
|
@@ -1131,7 +1029,6 @@ const RenderAnnotation = ({
|
|
|
1131
1029
|
hrefTarget: (html == null ? void 0 : html.target) || null
|
|
1132
1030
|
}, events));
|
|
1133
1031
|
};
|
|
1134
|
-
|
|
1135
1032
|
const RenderAnnotationPage = ({
|
|
1136
1033
|
className,
|
|
1137
1034
|
page
|
|
@@ -1140,17 +1037,16 @@ const RenderAnnotationPage = ({
|
|
|
1140
1037
|
const style = useStyles(page, "atlas");
|
|
1141
1038
|
const html = useStyles(page, "html");
|
|
1142
1039
|
useVaultSelector((state) => page.id ? state.iiif.entities.AnnotationPage[page.id] : null, []);
|
|
1143
|
-
return /* @__PURE__ */
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1040
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
1041
|
+
children: (_a = page.items) == null ? void 0 : _a.map((annotation) => {
|
|
1042
|
+
return /* @__PURE__ */ jsx(RenderAnnotation, {
|
|
1043
|
+
id: annotation.id,
|
|
1044
|
+
style,
|
|
1045
|
+
className: (html == null ? void 0 : html.className) || className
|
|
1046
|
+
}, annotation.id);
|
|
1047
|
+
})
|
|
1048
|
+
});
|
|
1151
1049
|
};
|
|
1152
|
-
|
|
1153
|
-
const TileSet = TileSet$1;
|
|
1154
1050
|
function RenderImage({
|
|
1155
1051
|
id,
|
|
1156
1052
|
image,
|
|
@@ -1162,35 +1058,33 @@ function RenderImage({
|
|
|
1162
1058
|
children
|
|
1163
1059
|
}) {
|
|
1164
1060
|
var _a, _b, _c, _d;
|
|
1165
|
-
return /* @__PURE__ */
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
} :
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
}), annotations, children));
|
|
1061
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
1062
|
+
children: !image.service ? /* @__PURE__ */ jsxs(Fragment, {
|
|
1063
|
+
children: [/* @__PURE__ */ jsx("world-image", {
|
|
1064
|
+
uri: image.id,
|
|
1065
|
+
target: image.target.spatial,
|
|
1066
|
+
display: image.width && image.height ? {
|
|
1067
|
+
width: image.width,
|
|
1068
|
+
height: image.height
|
|
1069
|
+
} : void 0
|
|
1070
|
+
}), annotations, children]
|
|
1071
|
+
}, "no-service") : /* @__PURE__ */ jsxs(Fragment, {
|
|
1072
|
+
children: [/* @__PURE__ */ jsx(TileSet, {
|
|
1073
|
+
tiles: {
|
|
1074
|
+
id: image.service.id || image.service["@id"] || "unknown",
|
|
1075
|
+
height: image.height,
|
|
1076
|
+
width: image.width,
|
|
1077
|
+
imageService: image.service,
|
|
1078
|
+
thumbnail: thumbnail && thumbnail.type === "fixed" ? thumbnail : void 0
|
|
1079
|
+
},
|
|
1080
|
+
x: ((_a = image.target) == null ? void 0 : _a.spatial.x) + x,
|
|
1081
|
+
y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
|
|
1082
|
+
width: (_c = image.target) == null ? void 0 : _c.spatial.width,
|
|
1083
|
+
height: (_d = image.target) == null ? void 0 : _d.spatial.height
|
|
1084
|
+
}), annotations, children]
|
|
1085
|
+
}, "service")
|
|
1086
|
+
}, id);
|
|
1192
1087
|
}
|
|
1193
|
-
|
|
1194
1088
|
function parseSpecificResource(resource) {
|
|
1195
1089
|
if (resource.type === "SpecificResource") {
|
|
1196
1090
|
return [resource.source, { selector: resource.selector }];
|
|
@@ -1249,7 +1143,6 @@ const unknownResponse = { type: "unknown" };
|
|
|
1249
1143
|
const unsupportedStrategy = (reason) => {
|
|
1250
1144
|
return { type: "unknown", reason, annotations: { pages: [] } };
|
|
1251
1145
|
};
|
|
1252
|
-
|
|
1253
1146
|
function useManifest(options = {}, deps = []) {
|
|
1254
1147
|
const { id, selector } = options;
|
|
1255
1148
|
const ctx = useResourceContext();
|
|
@@ -1266,7 +1159,6 @@ function useManifest(options = {}, deps = []) {
|
|
|
1266
1159
|
return manifest;
|
|
1267
1160
|
}, [manifest, selector, ...deps]);
|
|
1268
1161
|
}
|
|
1269
|
-
|
|
1270
1162
|
function getMeta$1(state, resourceId) {
|
|
1271
1163
|
var _a;
|
|
1272
1164
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1293,7 +1185,6 @@ function useEnabledAnnotationPageIds(resourceId, availablePageIds) {
|
|
|
1293
1185
|
return pageIds;
|
|
1294
1186
|
}, [resourceId, availablePageIds]);
|
|
1295
1187
|
}
|
|
1296
|
-
|
|
1297
1188
|
function flattenAnnotationPageIds({
|
|
1298
1189
|
canvas,
|
|
1299
1190
|
manifest,
|
|
@@ -1327,26 +1218,6 @@ function flattenAnnotationPageIds({
|
|
|
1327
1218
|
}
|
|
1328
1219
|
return foundIds;
|
|
1329
1220
|
}
|
|
1330
|
-
|
|
1331
|
-
var __defProp$4 = Object.defineProperty;
|
|
1332
|
-
var __defProps$3 = Object.defineProperties;
|
|
1333
|
-
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
1334
|
-
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1335
|
-
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1336
|
-
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1337
|
-
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1338
|
-
var __spreadValues$4 = (a, b) => {
|
|
1339
|
-
for (var prop in b || (b = {}))
|
|
1340
|
-
if (__hasOwnProp$4.call(b, prop))
|
|
1341
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
1342
|
-
if (__getOwnPropSymbols$4)
|
|
1343
|
-
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1344
|
-
if (__propIsEnum$4.call(b, prop))
|
|
1345
|
-
__defNormalProp$4(a, prop, b[prop]);
|
|
1346
|
-
}
|
|
1347
|
-
return a;
|
|
1348
|
-
};
|
|
1349
|
-
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
1350
1221
|
function getMeta(state, resourceId) {
|
|
1351
1222
|
var _a;
|
|
1352
1223
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1377,7 +1248,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1377
1248
|
if (existingResources && !existingResources[resourceId]) {
|
|
1378
1249
|
return existingResources;
|
|
1379
1250
|
}
|
|
1380
|
-
return __spreadProps
|
|
1251
|
+
return __spreadProps(__spreadValues({}, existingResources || {}), {
|
|
1381
1252
|
[resourceId]: false
|
|
1382
1253
|
});
|
|
1383
1254
|
});
|
|
@@ -1404,7 +1275,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1404
1275
|
if (existingResources && existingResources[resourceId]) {
|
|
1405
1276
|
return existingResources;
|
|
1406
1277
|
}
|
|
1407
|
-
return __spreadProps
|
|
1278
|
+
return __spreadProps(__spreadValues({}, existingResources || {}), {
|
|
1408
1279
|
[resourceId]: true
|
|
1409
1280
|
});
|
|
1410
1281
|
});
|
|
@@ -1416,35 +1287,13 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1416
1287
|
setPageDisabled
|
|
1417
1288
|
};
|
|
1418
1289
|
}
|
|
1419
|
-
|
|
1420
1290
|
function useResources(ids, type) {
|
|
1421
1291
|
return useVaultSelector((state, vault) => vault.get(ids.map((id) => ({ id, type }))), [ids, type]);
|
|
1422
1292
|
}
|
|
1423
|
-
|
|
1424
|
-
const ImageServiceLoaderContext = React$1.createContext(new ImageServiceLoader());
|
|
1293
|
+
const ImageServiceLoaderContext = React__default.createContext(new ImageServiceLoader());
|
|
1425
1294
|
function useImageServiceLoader() {
|
|
1426
1295
|
return useContext(ImageServiceLoaderContext);
|
|
1427
1296
|
}
|
|
1428
|
-
|
|
1429
|
-
var __defProp$3 = Object.defineProperty;
|
|
1430
|
-
var __defProps$2 = Object.defineProperties;
|
|
1431
|
-
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1432
|
-
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1433
|
-
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1434
|
-
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1435
|
-
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1436
|
-
var __spreadValues$3 = (a, b) => {
|
|
1437
|
-
for (var prop in b || (b = {}))
|
|
1438
|
-
if (__hasOwnProp$3.call(b, prop))
|
|
1439
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
1440
|
-
if (__getOwnPropSymbols$3)
|
|
1441
|
-
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1442
|
-
if (__propIsEnum$3.call(b, prop))
|
|
1443
|
-
__defNormalProp$3(a, prop, b[prop]);
|
|
1444
|
-
}
|
|
1445
|
-
return a;
|
|
1446
|
-
};
|
|
1447
|
-
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1448
1297
|
function useLoadImageService() {
|
|
1449
1298
|
const loader = useImageServiceLoader();
|
|
1450
1299
|
const [imageServiceStatus, setImageServiceStatus] = useState({});
|
|
@@ -1468,7 +1317,7 @@ function useLoadImageService() {
|
|
|
1468
1317
|
} else if (!imageServiceStatus[imageServiceId]) {
|
|
1469
1318
|
if (!didUnmount.current) {
|
|
1470
1319
|
setImageServiceStatus((r) => {
|
|
1471
|
-
return __spreadProps
|
|
1320
|
+
return __spreadProps(__spreadValues({}, r), {
|
|
1472
1321
|
[imageServiceId]: "loading"
|
|
1473
1322
|
});
|
|
1474
1323
|
});
|
|
@@ -1480,7 +1329,7 @@ function useLoadImageService() {
|
|
|
1480
1329
|
}).then(() => {
|
|
1481
1330
|
if (!didUnmount.current) {
|
|
1482
1331
|
setImageServiceStatus((r) => {
|
|
1483
|
-
return __spreadProps
|
|
1332
|
+
return __spreadProps(__spreadValues({}, r), {
|
|
1484
1333
|
[imageServiceId]: "done"
|
|
1485
1334
|
});
|
|
1486
1335
|
});
|
|
@@ -1492,7 +1341,6 @@ function useLoadImageService() {
|
|
|
1492
1341
|
}, [loader, imageServiceStatus]);
|
|
1493
1342
|
return [loadImageService, imageServiceStatus];
|
|
1494
1343
|
}
|
|
1495
|
-
|
|
1496
1344
|
function usePaintingAnnotations(options = {}) {
|
|
1497
1345
|
const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
|
|
1498
1346
|
return useVaultSelector((state, vault) => {
|
|
@@ -1507,7 +1355,6 @@ function usePaintingAnnotations(options = {}) {
|
|
|
1507
1355
|
return flatAnnotations;
|
|
1508
1356
|
}, [canvas]);
|
|
1509
1357
|
}
|
|
1510
|
-
|
|
1511
1358
|
function usePaintables(options, deps = []) {
|
|
1512
1359
|
const vault = useVault();
|
|
1513
1360
|
const paintingAnnotations = usePaintingAnnotations();
|
|
@@ -1551,7 +1398,6 @@ function usePaintables(options, deps = []) {
|
|
|
1551
1398
|
const actions = { makeChoice };
|
|
1552
1399
|
return [paintables, actions];
|
|
1553
1400
|
}
|
|
1554
|
-
|
|
1555
1401
|
function getImageStrategy(canvas, paintables, loadImageService) {
|
|
1556
1402
|
const imageTypes = [];
|
|
1557
1403
|
for (const singleImage of paintables.items) {
|
|
@@ -1625,7 +1471,6 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1625
1471
|
choice: paintables.choice
|
|
1626
1472
|
};
|
|
1627
1473
|
}
|
|
1628
|
-
|
|
1629
1474
|
const supportedFormats = ["model/gltf-binary"];
|
|
1630
1475
|
function get3dStrategy(canvas, paintables) {
|
|
1631
1476
|
const first = paintables.items[0];
|
|
@@ -1641,7 +1486,6 @@ function get3dStrategy(canvas, paintables) {
|
|
|
1641
1486
|
model: resource
|
|
1642
1487
|
};
|
|
1643
1488
|
}
|
|
1644
|
-
|
|
1645
1489
|
function getAudioStrategy(canvas, paintables) {
|
|
1646
1490
|
var _a;
|
|
1647
1491
|
if (!canvas.duration) {
|
|
@@ -1684,7 +1528,6 @@ function getAudioStrategy(canvas, paintables) {
|
|
|
1684
1528
|
}
|
|
1685
1529
|
};
|
|
1686
1530
|
}
|
|
1687
|
-
|
|
1688
1531
|
function getVideoStrategy(canvas, paintables) {
|
|
1689
1532
|
var _a;
|
|
1690
1533
|
const videoPaintables = paintables.items.filter((t) => t.type === "video");
|
|
@@ -1729,26 +1572,6 @@ function getVideoStrategy(canvas, paintables) {
|
|
|
1729
1572
|
}
|
|
1730
1573
|
};
|
|
1731
1574
|
}
|
|
1732
|
-
|
|
1733
|
-
var __defProp$2 = Object.defineProperty;
|
|
1734
|
-
var __defProps$1 = Object.defineProperties;
|
|
1735
|
-
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1736
|
-
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1737
|
-
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1738
|
-
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1739
|
-
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1740
|
-
var __spreadValues$2 = (a, b) => {
|
|
1741
|
-
for (var prop in b || (b = {}))
|
|
1742
|
-
if (__hasOwnProp$2.call(b, prop))
|
|
1743
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
1744
|
-
if (__getOwnPropSymbols$2)
|
|
1745
|
-
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1746
|
-
if (__propIsEnum$2.call(b, prop))
|
|
1747
|
-
__defNormalProp$2(a, prop, b[prop]);
|
|
1748
|
-
}
|
|
1749
|
-
return a;
|
|
1750
|
-
};
|
|
1751
|
-
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1752
1575
|
function useRenderingStrategy(options) {
|
|
1753
1576
|
const manifest = useManifest();
|
|
1754
1577
|
const canvas = useCanvas();
|
|
@@ -1806,21 +1629,96 @@ function useRenderingStrategy(options) {
|
|
|
1806
1629
|
return [strategy, emptyActions];
|
|
1807
1630
|
}
|
|
1808
1631
|
return [
|
|
1809
|
-
__spreadProps
|
|
1632
|
+
__spreadProps(__spreadValues({}, strategy), {
|
|
1810
1633
|
annotations: { pages: enabledPages }
|
|
1811
1634
|
}),
|
|
1812
1635
|
actions
|
|
1813
1636
|
];
|
|
1814
1637
|
}, [strategy, enabledPages]);
|
|
1815
1638
|
}
|
|
1816
|
-
|
|
1817
1639
|
const useVaultEffect = (callback, deps = []) => {
|
|
1818
1640
|
const vault = useVault();
|
|
1819
1641
|
useEffect(() => {
|
|
1820
1642
|
callback(vault);
|
|
1821
1643
|
}, [vault, ...deps]);
|
|
1822
1644
|
};
|
|
1823
|
-
|
|
1645
|
+
function createThumbnailHelper(vault, dependencies = {}) {
|
|
1646
|
+
const imageServiceLoader = dependencies.imageServiceLoader || new ImageServiceLoader();
|
|
1647
|
+
async function getBestThumbnailAtSize(input, request, dereference, candidates = [], dimensions) {
|
|
1648
|
+
if (typeof input === "string") {
|
|
1649
|
+
return { best: getFixedSizeFromImage(input), fallback: [], log: [] };
|
|
1650
|
+
}
|
|
1651
|
+
const fullInput = vault.get(input);
|
|
1652
|
+
if (typeof fullInput === "string") {
|
|
1653
|
+
return { best: getFixedSizeFromImage(fullInput), fallback: [], log: [] };
|
|
1654
|
+
}
|
|
1655
|
+
switch (fullInput.type) {
|
|
1656
|
+
case "Annotation": {
|
|
1657
|
+
const contentResources = fullInput.body;
|
|
1658
|
+
const firstContentResources = vault.get(contentResources[0]);
|
|
1659
|
+
if (dimensions && !firstContentResources.width) {
|
|
1660
|
+
firstContentResources.width = dimensions.width;
|
|
1661
|
+
firstContentResources.height = dimensions.height;
|
|
1662
|
+
}
|
|
1663
|
+
return await imageServiceLoader.getThumbnailFromResource(firstContentResources, request, dereference, candidates);
|
|
1664
|
+
}
|
|
1665
|
+
case "Canvas": {
|
|
1666
|
+
const canvas = fullInput;
|
|
1667
|
+
if (canvas.thumbnail && canvas.thumbnail.length) {
|
|
1668
|
+
const thumbnail = vault.get(canvas.thumbnail[0]);
|
|
1669
|
+
const potentialThumbnails = await imageServiceLoader.getImageCandidates(thumbnail, dereference);
|
|
1670
|
+
if (potentialThumbnails && potentialThumbnails.length) {
|
|
1671
|
+
candidates.push(...potentialThumbnails);
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
return getBestThumbnailAtSize(canvas.items[0], request, dereference, candidates, {
|
|
1675
|
+
width: canvas.width,
|
|
1676
|
+
height: canvas.height
|
|
1677
|
+
});
|
|
1678
|
+
}
|
|
1679
|
+
case "AnnotationPage": {
|
|
1680
|
+
const annotationPage = fullInput;
|
|
1681
|
+
return getBestThumbnailAtSize(annotationPage.items[0], request, dereference, candidates, dimensions);
|
|
1682
|
+
}
|
|
1683
|
+
case "Choice": {
|
|
1684
|
+
const choice = fullInput;
|
|
1685
|
+
return getBestThumbnailAtSize(choice.items[0], request, dereference, candidates, dimensions);
|
|
1686
|
+
}
|
|
1687
|
+
case "Collection": {
|
|
1688
|
+
const collection = fullInput;
|
|
1689
|
+
const firstManifest = collection.items[0];
|
|
1690
|
+
return getBestThumbnailAtSize(firstManifest, request, dereference, candidates, dimensions);
|
|
1691
|
+
}
|
|
1692
|
+
case "Manifest": {
|
|
1693
|
+
const manifest = fullInput;
|
|
1694
|
+
const firstCanvas = manifest.items[0];
|
|
1695
|
+
return getBestThumbnailAtSize(firstCanvas, request, dereference, candidates, dimensions);
|
|
1696
|
+
}
|
|
1697
|
+
case "SpecificResource":
|
|
1698
|
+
case "Image":
|
|
1699
|
+
case "Dataset":
|
|
1700
|
+
case "Sound":
|
|
1701
|
+
case "Text":
|
|
1702
|
+
case "TextualBody":
|
|
1703
|
+
case "Video":
|
|
1704
|
+
if (dimensions && !fullInput.width) {
|
|
1705
|
+
fullInput.width = dimensions.width;
|
|
1706
|
+
fullInput.height = dimensions.height;
|
|
1707
|
+
}
|
|
1708
|
+
return imageServiceLoader.getThumbnailFromResource(fullInput, request, dereference, candidates);
|
|
1709
|
+
case "Service":
|
|
1710
|
+
case "Range":
|
|
1711
|
+
case "AnnotationCollection":
|
|
1712
|
+
case "CanvasReference":
|
|
1713
|
+
case "ContentResource":
|
|
1714
|
+
return { best: void 0, fallback: [], log: [] };
|
|
1715
|
+
}
|
|
1716
|
+
return { best: void 0, fallback: [], log: [] };
|
|
1717
|
+
}
|
|
1718
|
+
return {
|
|
1719
|
+
getBestThumbnailAtSize
|
|
1720
|
+
};
|
|
1721
|
+
}
|
|
1824
1722
|
function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
1825
1723
|
const vault = useVault();
|
|
1826
1724
|
const loader = useImageServiceLoader();
|
|
@@ -1847,49 +1745,29 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
|
1847
1745
|
}, [subject]);
|
|
1848
1746
|
return thumbnail;
|
|
1849
1747
|
}
|
|
1850
|
-
|
|
1851
|
-
var __defProp$1 = Object.defineProperty;
|
|
1852
|
-
var __defProps = Object.defineProperties;
|
|
1853
|
-
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1854
|
-
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1855
|
-
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1856
|
-
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1857
|
-
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1858
|
-
var __spreadValues$1 = (a, b) => {
|
|
1859
|
-
for (var prop in b || (b = {}))
|
|
1860
|
-
if (__hasOwnProp$1.call(b, prop))
|
|
1861
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
1862
|
-
if (__getOwnPropSymbols$1)
|
|
1863
|
-
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1864
|
-
if (__propIsEnum$1.call(b, prop))
|
|
1865
|
-
__defNormalProp$1(a, prop, b[prop]);
|
|
1866
|
-
}
|
|
1867
|
-
return a;
|
|
1868
|
-
};
|
|
1869
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1870
1748
|
function getDefaultState(duration) {
|
|
1871
1749
|
return { isMuted: false, playRequested: false, isPlaying: false, isFinished: false, volume: 100, duration };
|
|
1872
1750
|
}
|
|
1873
1751
|
function reducer(state, action) {
|
|
1874
1752
|
switch (action.type) {
|
|
1875
1753
|
case "FINISHED":
|
|
1876
|
-
return __spreadProps(__spreadValues
|
|
1754
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: true, isPlaying: false, playRequested: false });
|
|
1877
1755
|
case "PLAY_PAUSE":
|
|
1878
|
-
return __spreadProps(__spreadValues
|
|
1756
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: false, isPlaying: !state.isPlaying });
|
|
1879
1757
|
case "PLAY_REQUESTED":
|
|
1880
|
-
return __spreadProps(__spreadValues
|
|
1758
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: false, playRequested: true });
|
|
1881
1759
|
case "PAUSE":
|
|
1882
|
-
return __spreadProps(__spreadValues
|
|
1760
|
+
return __spreadProps(__spreadValues({}, state), { isPlaying: false });
|
|
1883
1761
|
case "PLAY":
|
|
1884
|
-
return __spreadProps(__spreadValues
|
|
1762
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: false, playRequested: false, isPlaying: true });
|
|
1885
1763
|
case "MUTE":
|
|
1886
|
-
return __spreadProps(__spreadValues
|
|
1764
|
+
return __spreadProps(__spreadValues({}, state), { isMuted: true });
|
|
1887
1765
|
case "SET_VOLUME":
|
|
1888
|
-
return __spreadProps(__spreadValues
|
|
1766
|
+
return __spreadProps(__spreadValues({}, state), { volume: action.volume, isMuted: action.volume === 0 });
|
|
1889
1767
|
case "TOGGLE_MUTE":
|
|
1890
|
-
return __spreadProps(__spreadValues
|
|
1768
|
+
return __spreadProps(__spreadValues({}, state), { isMuted: !state.isMuted });
|
|
1891
1769
|
case "UNMUTE":
|
|
1892
|
-
return __spreadProps(__spreadValues
|
|
1770
|
+
return __spreadProps(__spreadValues({}, state), { isMuted: false });
|
|
1893
1771
|
}
|
|
1894
1772
|
return state;
|
|
1895
1773
|
}
|
|
@@ -2007,7 +1885,6 @@ function useSimpleMediaPlayer(props) {
|
|
|
2007
1885
|
}
|
|
2008
1886
|
];
|
|
2009
1887
|
}
|
|
2010
|
-
|
|
2011
1888
|
const MediaReactContextState = createContext(null);
|
|
2012
1889
|
const MediaReactContextActions = createContext(null);
|
|
2013
1890
|
const MediaReactContextElements = createContext(null);
|
|
@@ -2040,35 +1917,65 @@ function MediaPlayerProvider({
|
|
|
2040
1917
|
progress,
|
|
2041
1918
|
element
|
|
2042
1919
|
}) {
|
|
2043
|
-
return /* @__PURE__ */
|
|
2044
|
-
value: {
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
1920
|
+
return /* @__PURE__ */ jsx(MediaReactContextElements.Provider, {
|
|
1921
|
+
value: {
|
|
1922
|
+
currentTime,
|
|
1923
|
+
progress,
|
|
1924
|
+
element
|
|
1925
|
+
},
|
|
1926
|
+
children: /* @__PURE__ */ jsx(MediaReactContextActions.Provider, {
|
|
1927
|
+
value: actions,
|
|
1928
|
+
children: /* @__PURE__ */ jsx(MediaReactContextState.Provider, {
|
|
1929
|
+
value: state,
|
|
1930
|
+
children
|
|
1931
|
+
})
|
|
1932
|
+
})
|
|
1933
|
+
});
|
|
1934
|
+
}
|
|
1935
|
+
function Audio({
|
|
1936
|
+
media,
|
|
1937
|
+
children
|
|
1938
|
+
}) {
|
|
1939
|
+
const [{
|
|
1940
|
+
element,
|
|
2057
1941
|
currentTime,
|
|
2058
|
-
progress
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
1942
|
+
progress
|
|
1943
|
+
}, state, actions] = useSimpleMediaPlayer({
|
|
1944
|
+
duration: media.duration
|
|
1945
|
+
});
|
|
1946
|
+
return /* @__PURE__ */ jsx(Fragment$1, {
|
|
1947
|
+
children: /* @__PURE__ */ jsx(CanvasPortal, {
|
|
1948
|
+
children: /* @__PURE__ */ jsxs(MediaPlayerProvider, {
|
|
1949
|
+
state,
|
|
1950
|
+
actions,
|
|
1951
|
+
currentTime,
|
|
1952
|
+
progress,
|
|
1953
|
+
element,
|
|
1954
|
+
children: [/* @__PURE__ */ jsx("audio", {
|
|
1955
|
+
ref: element,
|
|
1956
|
+
src: media.url
|
|
1957
|
+
}), children]
|
|
1958
|
+
})
|
|
1959
|
+
})
|
|
1960
|
+
});
|
|
1961
|
+
}
|
|
1962
|
+
function Video({
|
|
1963
|
+
media,
|
|
1964
|
+
children
|
|
1965
|
+
}) {
|
|
1966
|
+
const [{
|
|
1967
|
+
element,
|
|
1968
|
+
currentTime,
|
|
1969
|
+
progress
|
|
1970
|
+
}, state, actions] = useSimpleMediaPlayer({
|
|
1971
|
+
duration: media.duration
|
|
1972
|
+
});
|
|
2068
1973
|
const Component = "div";
|
|
2069
|
-
return /* @__PURE__ */
|
|
2070
|
-
|
|
2071
|
-
|
|
1974
|
+
return /* @__PURE__ */ jsxs(Fragment$1, {
|
|
1975
|
+
children: [/* @__PURE__ */ jsxs(CanvasPortal, {
|
|
1976
|
+
overlay: true,
|
|
1977
|
+
children: [/* @__PURE__ */ jsx("style", {
|
|
1978
|
+
children: `
|
|
2072
1979
|
.video-container {
|
|
2073
1980
|
position: absolute;
|
|
2074
1981
|
top: 0;
|
|
@@ -2081,27 +1988,39 @@ function Video({ media, children }) {
|
|
|
2081
1988
|
justify-content: center;
|
|
2082
1989
|
pointer-events: visible;
|
|
2083
1990
|
}
|
|
2084
|
-
`
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
1991
|
+
`
|
|
1992
|
+
}), /* @__PURE__ */ jsx(Component, {
|
|
1993
|
+
className: "video-container",
|
|
1994
|
+
part: "video-container",
|
|
1995
|
+
onClick: () => actions.playPause(),
|
|
1996
|
+
children: /* @__PURE__ */ jsx("video", {
|
|
1997
|
+
ref: element,
|
|
1998
|
+
src: media.url,
|
|
1999
|
+
style: {
|
|
2000
|
+
width: "100%",
|
|
2001
|
+
objectFit: "contain"
|
|
2002
|
+
}
|
|
2003
|
+
})
|
|
2004
|
+
})]
|
|
2005
|
+
}), /* @__PURE__ */ jsx(CanvasPortal, {
|
|
2006
|
+
children: /* @__PURE__ */ jsx(MediaPlayerProvider, {
|
|
2007
|
+
state,
|
|
2008
|
+
actions,
|
|
2009
|
+
currentTime,
|
|
2010
|
+
progress,
|
|
2011
|
+
element,
|
|
2012
|
+
children
|
|
2013
|
+
})
|
|
2014
|
+
})]
|
|
2015
|
+
});
|
|
2016
|
+
}
|
|
2017
|
+
function Model({
|
|
2018
|
+
model
|
|
2019
|
+
}) {
|
|
2020
|
+
return /* @__PURE__ */ jsxs(CanvasPortal, {
|
|
2021
|
+
overlay: true,
|
|
2022
|
+
children: [/* @__PURE__ */ jsx("style", {
|
|
2023
|
+
children: `
|
|
2105
2024
|
.model-container {
|
|
2106
2025
|
position: absolute;
|
|
2107
2026
|
top: 0;
|
|
@@ -2114,33 +2033,22 @@ function Model({ model }) {
|
|
|
2114
2033
|
justify-content: center;
|
|
2115
2034
|
pointer-events: visible;
|
|
2116
2035
|
}
|
|
2117
|
-
`
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2132
|
-
|
|
2133
|
-
var __spreadValues = (a, b) => {
|
|
2134
|
-
for (var prop in b || (b = {}))
|
|
2135
|
-
if (__hasOwnProp.call(b, prop))
|
|
2136
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2137
|
-
if (__getOwnPropSymbols)
|
|
2138
|
-
for (var prop of __getOwnPropSymbols(b)) {
|
|
2139
|
-
if (__propIsEnum.call(b, prop))
|
|
2140
|
-
__defNormalProp(a, prop, b[prop]);
|
|
2141
|
-
}
|
|
2142
|
-
return a;
|
|
2143
|
-
};
|
|
2036
|
+
`
|
|
2037
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
2038
|
+
className: "model-container",
|
|
2039
|
+
children: /* @__PURE__ */ jsx("model-viewer", {
|
|
2040
|
+
"interaction-prompt": "none",
|
|
2041
|
+
style: {
|
|
2042
|
+
width: "100%",
|
|
2043
|
+
height: "100%"
|
|
2044
|
+
},
|
|
2045
|
+
"camera-controls": "",
|
|
2046
|
+
"ar-status": "not-presenting",
|
|
2047
|
+
src: model.id
|
|
2048
|
+
})
|
|
2049
|
+
})]
|
|
2050
|
+
});
|
|
2051
|
+
}
|
|
2144
2052
|
function RenderCanvas({
|
|
2145
2053
|
x,
|
|
2146
2054
|
y,
|
|
@@ -2160,7 +2068,9 @@ function RenderCanvas({
|
|
|
2160
2068
|
const helper = useMemo(() => createStylesHelper(vault), [vault]);
|
|
2161
2069
|
const [strategy, actions] = useRenderingStrategy({
|
|
2162
2070
|
strategies: strategies || ["images"],
|
|
2163
|
-
defaultChoices: defaultChoices == null ? void 0 : defaultChoices.map(({
|
|
2071
|
+
defaultChoices: defaultChoices == null ? void 0 : defaultChoices.map(({
|
|
2072
|
+
id
|
|
2073
|
+
}) => id)
|
|
2164
2074
|
});
|
|
2165
2075
|
const choice = strategy.type === "images" ? strategy.choice : void 0;
|
|
2166
2076
|
useEffect(() => {
|
|
@@ -2172,7 +2082,9 @@ function RenderCanvas({
|
|
|
2172
2082
|
if (defaultChoices) {
|
|
2173
2083
|
for (const choice2 of defaultChoices) {
|
|
2174
2084
|
if (typeof choice2.opacity !== "undefined") {
|
|
2175
|
-
helper.applyStyles({
|
|
2085
|
+
helper.applyStyles({
|
|
2086
|
+
id: choice2.id
|
|
2087
|
+
}, "atlas", {
|
|
2176
2088
|
opacity: choice2.opacity
|
|
2177
2089
|
});
|
|
2178
2090
|
}
|
|
@@ -2184,66 +2096,87 @@ function RenderCanvas({
|
|
|
2184
2096
|
onChoiceChange(choice);
|
|
2185
2097
|
}
|
|
2186
2098
|
}, [choice]);
|
|
2187
|
-
const thumbnail = useThumbnail({
|
|
2099
|
+
const thumbnail = useThumbnail({
|
|
2100
|
+
maxWidth: 256,
|
|
2101
|
+
maxHeight: 256
|
|
2102
|
+
});
|
|
2188
2103
|
if (!canvas) {
|
|
2189
2104
|
return null;
|
|
2190
2105
|
}
|
|
2191
2106
|
const accompanyingCanvas = canvas.accompanyingCanvas;
|
|
2192
|
-
const thumbnailFallbackImage = thumbnail && thumbnail.type === "fixed" ? /* @__PURE__ */
|
|
2107
|
+
const thumbnailFallbackImage = thumbnail && thumbnail.type === "fixed" ? /* @__PURE__ */ jsx("world-object", {
|
|
2193
2108
|
height: canvas.height,
|
|
2194
2109
|
width: canvas.width,
|
|
2195
2110
|
x,
|
|
2196
|
-
y
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2111
|
+
y,
|
|
2112
|
+
children: /* @__PURE__ */ jsx("world-image", {
|
|
2113
|
+
uri: thumbnail.id,
|
|
2114
|
+
target: {
|
|
2115
|
+
x: 0,
|
|
2116
|
+
y: 0,
|
|
2117
|
+
width: canvas.width,
|
|
2118
|
+
height: canvas.height
|
|
2119
|
+
},
|
|
2120
|
+
display: thumbnail.width && thumbnail.height ? {
|
|
2121
|
+
width: thumbnail.width,
|
|
2122
|
+
height: thumbnail.height
|
|
2123
|
+
} : void 0
|
|
2124
|
+
})
|
|
2125
|
+
}) : null;
|
|
2205
2126
|
if (strategy.type === "unknown") {
|
|
2206
2127
|
if (thumbnailFallbackImage) {
|
|
2207
2128
|
return thumbnailFallbackImage;
|
|
2208
2129
|
}
|
|
2209
2130
|
throw new Error(strategy.reason || "Unknown image strategy");
|
|
2210
2131
|
}
|
|
2211
|
-
const annotations = /* @__PURE__ */
|
|
2212
|
-
|
|
2213
|
-
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
|
|
2226
|
-
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2246
|
-
|
|
2132
|
+
const annotations = /* @__PURE__ */ jsxs(Fragment, {
|
|
2133
|
+
children: [virtualPage ? /* @__PURE__ */ jsx(RenderAnnotationPage, {
|
|
2134
|
+
page: virtualPage
|
|
2135
|
+
}) : null, strategy.annotations && strategy.annotations.pages ? strategy.annotations.pages.map((page) => {
|
|
2136
|
+
return /* @__PURE__ */ jsx(RenderAnnotationPage, {
|
|
2137
|
+
page
|
|
2138
|
+
}, page.id);
|
|
2139
|
+
}) : null, children]
|
|
2140
|
+
});
|
|
2141
|
+
return /* @__PURE__ */ jsxs(Fragment$1, {
|
|
2142
|
+
children: [/* @__PURE__ */ jsxs("world-object", __spreadProps(__spreadValues({
|
|
2143
|
+
height: canvas.height,
|
|
2144
|
+
width: canvas.width,
|
|
2145
|
+
x,
|
|
2146
|
+
y
|
|
2147
|
+
}, elementProps), {
|
|
2148
|
+
children: [strategy.type === "images" ? /* @__PURE__ */ jsxs(Fragment$1, {
|
|
2149
|
+
children: [strategy.images.map((image, idx) => {
|
|
2150
|
+
return /* @__PURE__ */ jsx(RenderImage, {
|
|
2151
|
+
isStatic,
|
|
2152
|
+
image,
|
|
2153
|
+
id: image.id,
|
|
2154
|
+
thumbnail: idx === 0 ? thumbnail : void 0,
|
|
2155
|
+
annotations
|
|
2156
|
+
}, image.id);
|
|
2157
|
+
}), renderViewerControls ? /* @__PURE__ */ jsx(CanvasPortal, {
|
|
2158
|
+
overlay: true,
|
|
2159
|
+
children: renderViewerControls(strategy)
|
|
2160
|
+
}) : null]
|
|
2161
|
+
}) : null, strategy.type === "3d-model" ? /* @__PURE__ */ jsx(Model, {
|
|
2162
|
+
model: strategy.model
|
|
2163
|
+
}) : null, strategy.type === "media" ? /* @__PURE__ */ jsx(Fragment$1, {
|
|
2164
|
+
children: strategy.media.type === "Sound" ? /* @__PURE__ */ jsxs(Audio, {
|
|
2165
|
+
media: strategy.media,
|
|
2166
|
+
children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
|
|
2167
|
+
}) : strategy.media.type === "Video" ? /* @__PURE__ */ jsxs(Video, {
|
|
2168
|
+
media: strategy.media,
|
|
2169
|
+
children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
|
|
2170
|
+
}) : null
|
|
2171
|
+
}) : null]
|
|
2172
|
+
}), strategy.type), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ jsx(CanvasContext, {
|
|
2173
|
+
canvas: accompanyingCanvas.id,
|
|
2174
|
+
children: /* @__PURE__ */ jsx(RenderCanvas, {
|
|
2175
|
+
renderViewerControls
|
|
2176
|
+
})
|
|
2177
|
+
}) : null]
|
|
2178
|
+
});
|
|
2179
|
+
}
|
|
2247
2180
|
const CanvasPanel = {
|
|
2248
2181
|
RenderImage,
|
|
2249
2182
|
RenderCanvas,
|
|
@@ -2251,33 +2184,45 @@ const CanvasPanel = {
|
|
|
2251
2184
|
RenderAnnotation,
|
|
2252
2185
|
Viewer
|
|
2253
2186
|
};
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2187
|
+
function AnnotationContext({
|
|
2188
|
+
annotation,
|
|
2189
|
+
children
|
|
2190
|
+
}) {
|
|
2191
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
2192
|
+
value: {
|
|
2193
|
+
annotation
|
|
2194
|
+
},
|
|
2195
|
+
children
|
|
2196
|
+
});
|
|
2197
|
+
}
|
|
2198
|
+
function CollectionContext({
|
|
2199
|
+
collection,
|
|
2200
|
+
children
|
|
2201
|
+
}) {
|
|
2202
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
2203
|
+
value: {
|
|
2204
|
+
collection
|
|
2205
|
+
},
|
|
2206
|
+
children
|
|
2207
|
+
});
|
|
2208
|
+
}
|
|
2209
|
+
function RangeContext({
|
|
2210
|
+
range,
|
|
2211
|
+
children
|
|
2212
|
+
}) {
|
|
2213
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
2214
|
+
value: {
|
|
2215
|
+
range
|
|
2216
|
+
},
|
|
2217
|
+
children
|
|
2218
|
+
});
|
|
2219
|
+
}
|
|
2273
2220
|
function useAnnotationsAtTime(time, options = {}) {
|
|
2274
2221
|
const allAnnotations = usePaintingAnnotations(options);
|
|
2275
2222
|
return allAnnotations;
|
|
2276
2223
|
}
|
|
2277
|
-
|
|
2278
2224
|
function useCanvasClock(canvasId, autoplay = false) {
|
|
2279
2225
|
}
|
|
2280
|
-
|
|
2281
2226
|
function useCollection(options, deps = []) {
|
|
2282
2227
|
const { id, selector } = options;
|
|
2283
2228
|
const ctx = useResourceContext();
|
|
@@ -2293,7 +2238,6 @@ function useCollection(options, deps = []) {
|
|
|
2293
2238
|
return collection;
|
|
2294
2239
|
}, [collection, selector, ...deps]);
|
|
2295
2240
|
}
|
|
2296
|
-
|
|
2297
2241
|
function useEventListener(resource, name, listener, scope, deps = []) {
|
|
2298
2242
|
const vault = useVault();
|
|
2299
2243
|
const helper = useMemo(() => createEventsHelper(vault), [vault]);
|
|
@@ -2309,37 +2253,14 @@ function useEventListener(resource, name, listener, scope, deps = []) {
|
|
|
2309
2253
|
};
|
|
2310
2254
|
}, [helper, resource, name, ...deps]);
|
|
2311
2255
|
}
|
|
2312
|
-
|
|
2313
2256
|
function useExistingVault() {
|
|
2314
2257
|
const oldContext = useContext(ReactVaultContext);
|
|
2315
2258
|
return oldContext && oldContext.vault ? oldContext.vault : globalVault();
|
|
2316
2259
|
}
|
|
2317
|
-
|
|
2318
2260
|
function useExternalCollection(idOrRef, options) {
|
|
2319
2261
|
const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
|
|
2320
2262
|
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
2321
2263
|
}
|
|
2322
|
-
|
|
2323
|
-
var __async = (__this, __arguments, generator) => {
|
|
2324
|
-
return new Promise((resolve, reject) => {
|
|
2325
|
-
var fulfilled = (value) => {
|
|
2326
|
-
try {
|
|
2327
|
-
step(generator.next(value));
|
|
2328
|
-
} catch (e) {
|
|
2329
|
-
reject(e);
|
|
2330
|
-
}
|
|
2331
|
-
};
|
|
2332
|
-
var rejected = (value) => {
|
|
2333
|
-
try {
|
|
2334
|
-
step(generator.throw(value));
|
|
2335
|
-
} catch (e) {
|
|
2336
|
-
reject(e);
|
|
2337
|
-
}
|
|
2338
|
-
};
|
|
2339
|
-
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
2340
|
-
step((generator = generator.apply(__this, __arguments)).next());
|
|
2341
|
-
});
|
|
2342
|
-
};
|
|
2343
2264
|
function useImageService({ cacheKey } = {}) {
|
|
2344
2265
|
const canvas = useCanvas();
|
|
2345
2266
|
const annotations = usePaintingAnnotations();
|
|
@@ -2373,7 +2294,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2373
2294
|
}, [key, cacheKey, canvas]);
|
|
2374
2295
|
const data = status === "success" && _data ? _data : initialData;
|
|
2375
2296
|
useEffect(() => {
|
|
2376
|
-
(() =>
|
|
2297
|
+
(async () => {
|
|
2377
2298
|
try {
|
|
2378
2299
|
if (canvas && annotations.length) {
|
|
2379
2300
|
const annotation = annotations[0];
|
|
@@ -2386,11 +2307,11 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2386
2307
|
setIsFetching(true);
|
|
2387
2308
|
setStatus("loading");
|
|
2388
2309
|
try {
|
|
2389
|
-
const loadedService =
|
|
2310
|
+
const loadedService = await imageService.loadService({
|
|
2390
2311
|
id: firstImageService.id || firstImageService["@id"],
|
|
2391
2312
|
width: firstImageService.width || canvas.width,
|
|
2392
2313
|
height: firstImageService.height || canvas.height
|
|
2393
|
-
})
|
|
2314
|
+
}) || void 0;
|
|
2394
2315
|
setData(loadedService);
|
|
2395
2316
|
setStatus("success");
|
|
2396
2317
|
setIsFetching(false);
|
|
@@ -2403,7 +2324,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2403
2324
|
setStatus("error");
|
|
2404
2325
|
setError(err);
|
|
2405
2326
|
}
|
|
2406
|
-
})
|
|
2327
|
+
})();
|
|
2407
2328
|
}, [key, cacheKey]);
|
|
2408
2329
|
return useMemo(() => {
|
|
2409
2330
|
return {
|
|
@@ -2414,7 +2335,6 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2414
2335
|
};
|
|
2415
2336
|
}, [data, isFetching, status, error]);
|
|
2416
2337
|
}
|
|
2417
|
-
|
|
2418
2338
|
function useImageTile() {
|
|
2419
2339
|
const imageService = useImageService();
|
|
2420
2340
|
return {
|
|
@@ -2428,7 +2348,6 @@ function useImageTile() {
|
|
|
2428
2348
|
} : null
|
|
2429
2349
|
};
|
|
2430
2350
|
}
|
|
2431
|
-
|
|
2432
2351
|
function useRange(options = {}, deps = []) {
|
|
2433
2352
|
const { id, selector } = options;
|
|
2434
2353
|
const ctx = useResourceContext();
|
|
@@ -2444,15 +2363,13 @@ function useRange(options = {}, deps = []) {
|
|
|
2444
2363
|
return range;
|
|
2445
2364
|
}, [range, selector, ...deps]);
|
|
2446
2365
|
}
|
|
2447
|
-
|
|
2448
2366
|
function useSearchService() {
|
|
2449
2367
|
const manifest = useManifest();
|
|
2450
2368
|
return manifest ? manifest.service.find((service) => service.profile === "SearchService1" || service.profile === "http://iiif.io/api/search/1/search") : void 0;
|
|
2451
2369
|
}
|
|
2452
|
-
|
|
2453
2370
|
function useStyleHelper() {
|
|
2454
2371
|
const vault = useVault();
|
|
2455
2372
|
return useMemo(() => createStylesHelper(vault), [vault]);
|
|
2456
2373
|
}
|
|
2457
|
-
|
|
2458
2374
|
export { AnnotationContext, CanvasContext, CanvasPanel, CanvasPortal, CollectionContext, ContextBridge, ImageServiceLoaderContext, ManifestContext, MediaPlayerProvider, OverlayPortalContext, PortalContext, RangeContext, ReactVaultContext, ResourceProvider, ResourceReactContext, SimpleViewerProvider, SimpleViewerReactContext, VaultProvider, ViewerPresetContext, VirtualAnnotationProvider, VisibleCanvasReactContext, emptyActions, expandTarget, flattenAnnotationPageIds, formatTime, getImageStrategy, getPaintables, parseSelector, parseSpecificResource, unknownResponse, unsupportedStrategy, useAnnotation, useAnnotationPageManager, useAnnotationsAtTime, useCanvas, useCanvasClock, useCollection, useContextBridge, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useViewerPreset, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };
|
|
2375
|
+
//# sourceMappingURL=index.mjs.map
|