react-iiif-vault 0.9.11 → 0.9.12
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/selector-extensions.d.ts +53 -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 +56 -0
- package/.build/types/utility/expand-target.d.ts +19 -0
- package/.build/types/utility/flatten-annotation-page-ids.d.ts +7 -0
- package/.build/types/utility/parse-selector.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 +36 -0
- package/dist/bundle/cjs/index.js.map +1 -0
- package/dist/{esm → bundle/esm}/index.mjs +720 -790
- package/dist/bundle/esm/index.mjs.map +1 -0
- package/dist/canvas-panel/cjs/canvas-panel.js +36 -0
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -0
- package/dist/canvas-panel/esm/canvas-panel.mjs +2024 -0
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -0
- package/dist/index.umd.js +121 -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,163 @@
|
|
|
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 as Fragment$1, useReducer } from "react";
|
|
34
|
+
import { AtlasAuto, mergeStyles, RegionHighlight, TileSet } from "@atlas-viewer/atlas";
|
|
35
|
+
import { globalVault, Vault } from "@iiif/vault";
|
|
36
|
+
import { createAction } from "typesafe-actions";
|
|
37
|
+
import require$$0 from "react-dom";
|
|
38
|
+
import { ImageServiceLoader, getImageServices, getFixedSizeFromImage } from "@atlas-viewer/iiif-image-api";
|
|
39
|
+
function _setPrototypeOf(o, p2) {
|
|
40
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p3) {
|
|
41
|
+
o2.__proto__ = p3;
|
|
42
|
+
return o2;
|
|
43
|
+
};
|
|
44
|
+
return _setPrototypeOf(o, p2);
|
|
45
|
+
}
|
|
46
|
+
function _inheritsLoose(subClass, superClass) {
|
|
47
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
48
|
+
subClass.prototype.constructor = subClass;
|
|
49
|
+
_setPrototypeOf(subClass, superClass);
|
|
50
|
+
}
|
|
51
|
+
var changedArray = function changedArray2(a, b) {
|
|
52
|
+
if (a === void 0) {
|
|
53
|
+
a = [];
|
|
33
54
|
}
|
|
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);
|
|
55
|
+
if (b === void 0) {
|
|
56
|
+
b = [];
|
|
44
57
|
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
58
|
+
return a.length !== b.length || a.some(function(item, index) {
|
|
59
|
+
return !Object.is(item, b[index]);
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
var initialState = {
|
|
63
|
+
error: null
|
|
64
|
+
};
|
|
65
|
+
var ErrorBoundary = /* @__PURE__ */ function(_React$Component) {
|
|
66
|
+
_inheritsLoose(ErrorBoundary2, _React$Component);
|
|
67
|
+
function ErrorBoundary2() {
|
|
68
|
+
var _this;
|
|
69
|
+
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
70
|
+
_args[_key] = arguments[_key];
|
|
71
|
+
}
|
|
72
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
|
|
73
|
+
_this.state = initialState;
|
|
74
|
+
_this.resetErrorBoundary = function() {
|
|
75
|
+
var _this$props;
|
|
76
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
77
|
+
args[_key2] = arguments[_key2];
|
|
78
|
+
}
|
|
79
|
+
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args);
|
|
80
|
+
_this.reset();
|
|
81
|
+
};
|
|
82
|
+
return _this;
|
|
50
83
|
}
|
|
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
|
-
});
|
|
84
|
+
ErrorBoundary2.getDerivedStateFromError = function getDerivedStateFromError(error) {
|
|
85
|
+
return {
|
|
86
|
+
error
|
|
87
|
+
};
|
|
64
88
|
};
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
89
|
+
var _proto = ErrorBoundary2.prototype;
|
|
90
|
+
_proto.reset = function reset() {
|
|
91
|
+
this.setState(initialState);
|
|
68
92
|
};
|
|
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;
|
|
93
|
+
_proto.componentDidCatch = function componentDidCatch(error, info) {
|
|
94
|
+
var _this$props$onError, _this$props2;
|
|
95
|
+
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
96
|
+
};
|
|
97
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
98
|
+
var error = this.state.error;
|
|
99
|
+
var resetKeys = this.props.resetKeys;
|
|
100
|
+
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
101
|
+
var _this$props$onResetKe, _this$props3;
|
|
102
|
+
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
|
|
103
|
+
this.reset();
|
|
96
104
|
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
105
|
+
};
|
|
106
|
+
_proto.render = function render() {
|
|
107
|
+
var error = this.state.error;
|
|
108
|
+
var _this$props4 = this.props, fallbackRender = _this$props4.fallbackRender, FallbackComponent = _this$props4.FallbackComponent, fallback = _this$props4.fallback;
|
|
109
|
+
if (error !== null) {
|
|
110
|
+
var _props = {
|
|
111
|
+
error,
|
|
112
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
101
113
|
};
|
|
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
|
-
}
|
|
114
|
+
if (/* @__PURE__ */ React.isValidElement(fallback)) {
|
|
115
|
+
return fallback;
|
|
116
|
+
} else if (typeof fallbackRender === "function") {
|
|
117
|
+
return fallbackRender(_props);
|
|
118
|
+
} else if (FallbackComponent) {
|
|
119
|
+
return /* @__PURE__ */ React.createElement(FallbackComponent, _props);
|
|
120
|
+
} else {
|
|
121
|
+
throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop");
|
|
155
122
|
}
|
|
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
123
|
}
|
|
214
|
-
|
|
215
|
-
};
|
|
124
|
+
return this.props.children;
|
|
125
|
+
};
|
|
126
|
+
return ErrorBoundary2;
|
|
127
|
+
}(React.Component);
|
|
128
|
+
var jsxRuntime = { exports: {} };
|
|
129
|
+
var reactJsxRuntime_production_min = {};
|
|
130
|
+
/**
|
|
131
|
+
* @license React
|
|
132
|
+
* react-jsx-runtime.production.min.js
|
|
133
|
+
*
|
|
134
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
135
|
+
*
|
|
136
|
+
* This source code is licensed under the MIT license found in the
|
|
137
|
+
* LICENSE file in the root directory of this source tree.
|
|
138
|
+
*/
|
|
139
|
+
var f = React__default, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m$1 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
140
|
+
function q(c, a, g) {
|
|
141
|
+
var b, d = {}, e = null, h = null;
|
|
142
|
+
g !== void 0 && (e = "" + g);
|
|
143
|
+
a.key !== void 0 && (e = "" + a.key);
|
|
144
|
+
a.ref !== void 0 && (h = a.ref);
|
|
145
|
+
for (b in a)
|
|
146
|
+
m$1.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
147
|
+
if (c && c.defaultProps)
|
|
148
|
+
for (b in a = c.defaultProps, a)
|
|
149
|
+
d[b] === void 0 && (d[b] = a[b]);
|
|
150
|
+
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
151
|
+
}
|
|
152
|
+
reactJsxRuntime_production_min.Fragment = l;
|
|
153
|
+
reactJsxRuntime_production_min.jsx = q;
|
|
154
|
+
reactJsxRuntime_production_min.jsxs = q;
|
|
155
|
+
{
|
|
156
|
+
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
157
|
+
}
|
|
158
|
+
const jsx = jsxRuntime.exports.jsx;
|
|
159
|
+
const jsxs = jsxRuntime.exports.jsxs;
|
|
160
|
+
const Fragment = jsxRuntime.exports.Fragment;
|
|
216
161
|
const defaultResourceContext = {
|
|
217
162
|
collection: void 0,
|
|
218
163
|
manifest: void 0,
|
|
@@ -220,21 +165,24 @@ const defaultResourceContext = {
|
|
|
220
165
|
canvas: void 0,
|
|
221
166
|
annotation: void 0
|
|
222
167
|
};
|
|
223
|
-
const ResourceReactContext =
|
|
168
|
+
const ResourceReactContext = React__default.createContext(defaultResourceContext);
|
|
224
169
|
const useResourceContext = () => {
|
|
225
170
|
return useContext(ResourceReactContext);
|
|
226
171
|
};
|
|
227
|
-
function ResourceProvider({
|
|
172
|
+
function ResourceProvider({
|
|
173
|
+
value,
|
|
174
|
+
children
|
|
175
|
+
}) {
|
|
228
176
|
const parentContext = useResourceContext();
|
|
229
177
|
const newContext = useMemo(() => {
|
|
230
|
-
return __spreadValues
|
|
178
|
+
return __spreadValues(__spreadValues({}, parentContext), value);
|
|
231
179
|
}, [value, parentContext]);
|
|
232
|
-
return /* @__PURE__ */
|
|
233
|
-
value: newContext
|
|
234
|
-
|
|
180
|
+
return /* @__PURE__ */ jsx(ResourceReactContext.Provider, {
|
|
181
|
+
value: newContext,
|
|
182
|
+
children
|
|
183
|
+
});
|
|
235
184
|
}
|
|
236
|
-
|
|
237
|
-
const ReactVaultContext = React$1.createContext({
|
|
185
|
+
const ReactVaultContext = React__default.createContext({
|
|
238
186
|
vault: null,
|
|
239
187
|
setVaultInstance: (vault) => {
|
|
240
188
|
}
|
|
@@ -258,13 +206,17 @@ function VaultProvider({
|
|
|
258
206
|
}
|
|
259
207
|
return new Vault();
|
|
260
208
|
});
|
|
261
|
-
return /* @__PURE__ */
|
|
262
|
-
value: {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
209
|
+
return /* @__PURE__ */ jsx(ReactVaultContext.Provider, {
|
|
210
|
+
value: {
|
|
211
|
+
vault: vaultInstance,
|
|
212
|
+
setVaultInstance
|
|
213
|
+
},
|
|
214
|
+
children: /* @__PURE__ */ jsx(ResourceProvider, {
|
|
215
|
+
value: resources || {},
|
|
216
|
+
children
|
|
217
|
+
})
|
|
218
|
+
});
|
|
266
219
|
}
|
|
267
|
-
|
|
268
220
|
const useVault = () => {
|
|
269
221
|
const { vault } = useContext(ReactVaultContext);
|
|
270
222
|
if (vault === null) {
|
|
@@ -272,27 +224,6 @@ const useVault = () => {
|
|
|
272
224
|
}
|
|
273
225
|
return vault;
|
|
274
226
|
};
|
|
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
227
|
function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
297
228
|
const id = typeof idOrRef === "string" ? idOrRef : idOrRef.id;
|
|
298
229
|
const vault = useVault();
|
|
@@ -303,9 +234,9 @@ function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
|
303
234
|
}, [id, vault]);
|
|
304
235
|
const [resource, setResource] = useState(initialData);
|
|
305
236
|
useEffect(() => {
|
|
306
|
-
(() =>
|
|
237
|
+
(async () => {
|
|
307
238
|
try {
|
|
308
|
-
const fetchedResource = initialData && !noCache ? initialData :
|
|
239
|
+
const fetchedResource = initialData && !noCache ? initialData : await vault.load(id);
|
|
309
240
|
const _realId = fetchedResource ? fetchedResource.id || fetchedResource["@id"] : null;
|
|
310
241
|
if (fetchedResource && realId !== _realId) {
|
|
311
242
|
setRealId(_realId);
|
|
@@ -314,7 +245,7 @@ function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
|
314
245
|
} catch (err) {
|
|
315
246
|
setError(err);
|
|
316
247
|
}
|
|
317
|
-
})
|
|
248
|
+
})();
|
|
318
249
|
}, [id, noCache]);
|
|
319
250
|
return {
|
|
320
251
|
isLoaded: !!resource,
|
|
@@ -325,24 +256,32 @@ function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
|
325
256
|
cached: !!(resource && resource === initialData)
|
|
326
257
|
};
|
|
327
258
|
}
|
|
328
|
-
|
|
329
259
|
function useExternalManifest(idOrRef, options) {
|
|
330
260
|
const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
|
|
331
261
|
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
332
262
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
263
|
+
function ManifestContext({
|
|
264
|
+
manifest,
|
|
265
|
+
children
|
|
266
|
+
}) {
|
|
267
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
268
|
+
value: {
|
|
269
|
+
manifest
|
|
270
|
+
},
|
|
271
|
+
children
|
|
272
|
+
});
|
|
338
273
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
274
|
+
function CanvasContext({
|
|
275
|
+
canvas,
|
|
276
|
+
children
|
|
277
|
+
}) {
|
|
278
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
279
|
+
value: {
|
|
280
|
+
canvas
|
|
281
|
+
},
|
|
282
|
+
children
|
|
283
|
+
});
|
|
344
284
|
}
|
|
345
|
-
|
|
346
285
|
function useVaultSelector(selector, deps = []) {
|
|
347
286
|
const vault = useVault();
|
|
348
287
|
const [selectedState, setSelectedState] = useState(() => selector(vault.getState(), vault));
|
|
@@ -353,15 +292,13 @@ function useVaultSelector(selector, deps = []) {
|
|
|
353
292
|
}, deps);
|
|
354
293
|
return selectedState;
|
|
355
294
|
}
|
|
356
|
-
|
|
357
|
-
const VisibleCanvasReactContext = React$1.createContext([]);
|
|
295
|
+
const VisibleCanvasReactContext = React__default.createContext([]);
|
|
358
296
|
function useVisibleCanvases() {
|
|
359
297
|
const ids = useContext(VisibleCanvasReactContext);
|
|
360
298
|
return useVaultSelector((state) => {
|
|
361
299
|
return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);
|
|
362
300
|
}, [ids]);
|
|
363
301
|
}
|
|
364
|
-
|
|
365
302
|
const noop = () => {
|
|
366
303
|
};
|
|
367
304
|
const SimpleViewerReactContext = createContext({
|
|
@@ -456,25 +393,32 @@ function SimpleViewerProvider(props) {
|
|
|
456
393
|
}), [nextCanvas, previousCanvas, currentCanvasIndex, canvasList, setCurrentCanvasIndex, internalSetCurrentCanvasId]);
|
|
457
394
|
if (!manifest.manifest) {
|
|
458
395
|
console.warn("The manifest passed to the provider is not a valid IIIF manifest.");
|
|
459
|
-
return /* @__PURE__ */
|
|
396
|
+
return /* @__PURE__ */ jsx("div", {
|
|
397
|
+
children: "Sorry, something went wrong."
|
|
398
|
+
});
|
|
460
399
|
}
|
|
461
400
|
if (!manifest.isLoaded) {
|
|
462
|
-
return /* @__PURE__ */
|
|
401
|
+
return /* @__PURE__ */ jsx("div", {
|
|
402
|
+
children: "Loading..."
|
|
403
|
+
});
|
|
463
404
|
}
|
|
464
|
-
return /* @__PURE__ */
|
|
465
|
-
value: ctx
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
405
|
+
return /* @__PURE__ */ jsx(SimpleViewerReactContext.Provider, {
|
|
406
|
+
value: ctx,
|
|
407
|
+
children: /* @__PURE__ */ jsx(VisibleCanvasReactContext.Provider, {
|
|
408
|
+
value: visible,
|
|
409
|
+
children: /* @__PURE__ */ jsx(ManifestContext, {
|
|
410
|
+
manifest: manifest.manifest.id,
|
|
411
|
+
children: /* @__PURE__ */ jsx(CanvasContext, {
|
|
412
|
+
canvas: currentCanvasId,
|
|
413
|
+
children: props.children
|
|
414
|
+
})
|
|
415
|
+
})
|
|
416
|
+
})
|
|
417
|
+
});
|
|
473
418
|
}
|
|
474
419
|
function useSimpleViewer() {
|
|
475
420
|
return useContext(SimpleViewerReactContext);
|
|
476
421
|
}
|
|
477
|
-
|
|
478
422
|
function useContextBridge() {
|
|
479
423
|
return {
|
|
480
424
|
VaultContext: useContext(ReactVaultContext),
|
|
@@ -484,16 +428,18 @@ function useContextBridge() {
|
|
|
484
428
|
};
|
|
485
429
|
}
|
|
486
430
|
function ContextBridge(props) {
|
|
487
|
-
return /* @__PURE__ */
|
|
431
|
+
return /* @__PURE__ */ jsx(VaultProvider, {
|
|
488
432
|
vault: props.bridge.VaultContext.vault || void 0,
|
|
489
|
-
resources: props.bridge.ResourceContext
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
|
|
433
|
+
resources: props.bridge.ResourceContext,
|
|
434
|
+
children: /* @__PURE__ */ jsx(VisibleCanvasReactContext.Provider, {
|
|
435
|
+
value: props.bridge.VisibleCanvasReactContext,
|
|
436
|
+
children: /* @__PURE__ */ jsx(SimpleViewerReactContext.Provider, {
|
|
437
|
+
value: props.bridge.SimpleViewerReactContext,
|
|
438
|
+
children: props.children
|
|
439
|
+
})
|
|
440
|
+
})
|
|
441
|
+
});
|
|
442
|
+
}
|
|
497
443
|
const IMPORT_ENTITIES = "@iiif/IMPORT_ENTITIES";
|
|
498
444
|
const MODIFY_ENTITY_FIELD = "@iiif/MODIFY_ENTITY_FIELD";
|
|
499
445
|
const REORDER_ENTITY_FIELD = "@iiif/REORDER_ENTITY_FIELD";
|
|
@@ -505,12 +451,10 @@ const reorderEntityField = createAction(REORDER_ENTITY_FIELD)();
|
|
|
505
451
|
const addReference = createAction(ADD_REFERENCE)();
|
|
506
452
|
const removeReference = createAction(REMOVE_REFERENCE)();
|
|
507
453
|
const entityActions = { importEntities, modifyEntityField, reorderEntityField, addReference, removeReference };
|
|
508
|
-
|
|
509
454
|
const ADD_MAPPING = "@iiif/ADD_MAPPING";
|
|
510
455
|
const ADD_MAPPINGS = "@iiif/ADD_MAPPINGS";
|
|
511
456
|
createAction(ADD_MAPPING)();
|
|
512
457
|
createAction(ADD_MAPPINGS)();
|
|
513
|
-
|
|
514
458
|
const SET_META_VALUE = "@iiif/SET_META_VALUE";
|
|
515
459
|
const SET_META_VALUE_DYNAMIC = "@iiif/SET_META_VALUE_DYNAMIC";
|
|
516
460
|
const UNSET_META_VALUE = "@iiif/UNSET_META_VALUE";
|
|
@@ -527,12 +471,10 @@ createAction(REQUEST_ERROR)();
|
|
|
527
471
|
createAction(REQUEST_MISMATCH)();
|
|
528
472
|
createAction(REQUEST_COMPLETE)();
|
|
529
473
|
createAction(REQUEST_OFFLINE_RESOURCE)();
|
|
530
|
-
|
|
531
474
|
const BATCH_ACTIONS = "@iiif/BATCH";
|
|
532
475
|
const BATCH_IMPORT = "@iiif/BATCH_IMPORT";
|
|
533
476
|
createAction(BATCH_ACTIONS)();
|
|
534
477
|
createAction(BATCH_IMPORT)();
|
|
535
|
-
|
|
536
478
|
function useDispatch() {
|
|
537
479
|
const vault = useVault();
|
|
538
480
|
const store = vault.getStore();
|
|
@@ -540,7 +482,6 @@ function useDispatch() {
|
|
|
540
482
|
return (action) => store.dispatch(action);
|
|
541
483
|
}, [store]);
|
|
542
484
|
}
|
|
543
|
-
|
|
544
485
|
function isVaultActivated(obj) {
|
|
545
486
|
return typeof obj !== "string" && obj && obj.bindToVault;
|
|
546
487
|
}
|
|
@@ -642,73 +583,61 @@ function useVirtualAnnotationPage() {
|
|
|
642
583
|
}
|
|
643
584
|
];
|
|
644
585
|
}
|
|
645
|
-
|
|
646
586
|
const VirtualAnnotationPageContext = createContext(null);
|
|
647
587
|
function useVirtualAnnotationPageContext() {
|
|
648
588
|
const ctx = useContext(VirtualAnnotationPageContext);
|
|
649
|
-
return [
|
|
650
|
-
ctx.
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
removeAnnotation: ctx.removeAnnotation
|
|
654
|
-
}
|
|
655
|
-
];
|
|
589
|
+
return [ctx.fullPage, {
|
|
590
|
+
addAnnotation: ctx.addAnnotation,
|
|
591
|
+
removeAnnotation: ctx.removeAnnotation
|
|
592
|
+
}];
|
|
656
593
|
}
|
|
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
|
-
|
|
594
|
+
function VirtualAnnotationProvider({
|
|
595
|
+
children
|
|
596
|
+
}) {
|
|
597
|
+
const [fullPage, {
|
|
598
|
+
addAnnotation,
|
|
599
|
+
removeAnnotation
|
|
600
|
+
}] = useVirtualAnnotationPage();
|
|
601
|
+
return /* @__PURE__ */ jsx(VirtualAnnotationPageContext.Provider, {
|
|
602
|
+
value: useMemo(() => ({
|
|
603
|
+
fullPage,
|
|
604
|
+
addAnnotation,
|
|
605
|
+
removeAnnotation
|
|
606
|
+
}), [fullPage]),
|
|
607
|
+
children
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
function DefaultCanvasFallback({
|
|
611
|
+
width,
|
|
612
|
+
style,
|
|
613
|
+
height
|
|
614
|
+
}) {
|
|
615
|
+
return /* @__PURE__ */ jsx("div", {
|
|
616
|
+
style: __spreadProps(__spreadValues({
|
|
617
|
+
width,
|
|
618
|
+
height,
|
|
619
|
+
minHeight: 500
|
|
620
|
+
}, style || {}), {
|
|
621
|
+
background: "#f9f9f9"
|
|
622
|
+
}),
|
|
623
|
+
children: "Unknown error"
|
|
624
|
+
});
|
|
687
625
|
}
|
|
688
|
-
|
|
689
626
|
var createRoot;
|
|
690
|
-
|
|
691
627
|
var m = require$$0;
|
|
692
628
|
{
|
|
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
|
-
};
|
|
629
|
+
createRoot = m.createRoot;
|
|
702
630
|
}
|
|
703
|
-
|
|
704
631
|
const ViewerPresetContext = createContext(null);
|
|
705
632
|
function useViewerPreset() {
|
|
706
633
|
return useContext(ViewerPresetContext);
|
|
707
634
|
}
|
|
708
|
-
|
|
709
|
-
const
|
|
710
|
-
|
|
711
|
-
|
|
635
|
+
const PortalContext = React__default.createContext(null);
|
|
636
|
+
const OverlayPortalContext = React__default.createContext(null);
|
|
637
|
+
function CanvasPortal({
|
|
638
|
+
children,
|
|
639
|
+
overlay
|
|
640
|
+
}) {
|
|
712
641
|
const htmlElement = useContext(overlay ? OverlayPortalContext : PortalContext);
|
|
713
642
|
const rootRef = useRef(null);
|
|
714
643
|
const preset = useViewerPreset();
|
|
@@ -726,45 +655,14 @@ function CanvasPortal({ children, overlay }) {
|
|
|
726
655
|
}, []);
|
|
727
656
|
useLayoutEffect(() => {
|
|
728
657
|
if (rootRef.current) {
|
|
729
|
-
rootRef.current.render(/* @__PURE__ */
|
|
730
|
-
value: preset
|
|
731
|
-
|
|
658
|
+
rootRef.current.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
659
|
+
value: preset,
|
|
660
|
+
children
|
|
661
|
+
}));
|
|
732
662
|
}
|
|
733
663
|
}, [children, preset]);
|
|
734
664
|
return null;
|
|
735
665
|
}
|
|
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
666
|
function Viewer(_a) {
|
|
769
667
|
var _b = _a, {
|
|
770
668
|
children,
|
|
@@ -786,32 +684,91 @@ function Viewer(_a) {
|
|
|
786
684
|
setPortalElement(portal.current);
|
|
787
685
|
setOverlayPortalElement(overlayPortal.current);
|
|
788
686
|
}, []);
|
|
789
|
-
return /* @__PURE__ */
|
|
790
|
-
fallbackRender: () => /* @__PURE__ */
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
687
|
+
return /* @__PURE__ */ jsxs(ErrorBoundary, {
|
|
688
|
+
fallbackRender: () => /* @__PURE__ */ jsx(ErrorFallback, __spreadValues({}, props)),
|
|
689
|
+
children: [/* @__PURE__ */ jsx(AtlasAuto, __spreadProps(__spreadValues({}, props), {
|
|
690
|
+
containerProps: __spreadValues({
|
|
691
|
+
style: {
|
|
692
|
+
position: "relative"
|
|
693
|
+
}
|
|
694
|
+
}, props.containerProps || {}),
|
|
695
|
+
htmlChildren: /* @__PURE__ */ jsx("div", {
|
|
696
|
+
ref: overlayPortal
|
|
697
|
+
}),
|
|
698
|
+
onCreated: (preset) => {
|
|
699
|
+
setViewerPreset(preset);
|
|
700
|
+
if (props.onCreated) {
|
|
701
|
+
props.onCreated(preset);
|
|
702
|
+
}
|
|
703
|
+
},
|
|
704
|
+
children: /* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
705
|
+
value: viewerPreset,
|
|
706
|
+
children: /* @__PURE__ */ jsx(PortalContext.Provider, {
|
|
707
|
+
value: portalElement,
|
|
708
|
+
children: /* @__PURE__ */ jsx(OverlayPortalContext.Provider, {
|
|
709
|
+
value: overlayPortalElement,
|
|
710
|
+
children: /* @__PURE__ */ jsx(ContextBridge, {
|
|
711
|
+
bridge,
|
|
712
|
+
children: /* @__PURE__ */ jsx(VirtualAnnotationProvider, {
|
|
713
|
+
children
|
|
714
|
+
})
|
|
715
|
+
})
|
|
716
|
+
})
|
|
717
|
+
})
|
|
718
|
+
})
|
|
719
|
+
})), /* @__PURE__ */ jsx("div", {
|
|
720
|
+
ref: portal
|
|
721
|
+
})]
|
|
722
|
+
});
|
|
723
|
+
}
|
|
724
|
+
function createEventsHelper(vault) {
|
|
725
|
+
return {
|
|
726
|
+
addEventListener(resource, event, listener, scope) {
|
|
727
|
+
if (!resource) {
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
vault.setMetaValue([resource.id, "eventManager", event], (registeredCallbacks) => {
|
|
731
|
+
const callbacks = registeredCallbacks || [];
|
|
732
|
+
for (const registered of callbacks) {
|
|
733
|
+
if (registered.callback === listener) {
|
|
734
|
+
return callbacks;
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
return [...callbacks, { callback: listener, scope }];
|
|
738
|
+
});
|
|
739
|
+
return listener;
|
|
740
|
+
},
|
|
741
|
+
removeEventListener(resource, event, listener) {
|
|
742
|
+
if (!resource) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
vault.setMetaValue([resource.id, "eventManager", event], (registeredCallbacks) => {
|
|
746
|
+
return (registeredCallbacks || []).filter((registeredCallback) => registeredCallback.callback !== listener);
|
|
747
|
+
});
|
|
748
|
+
},
|
|
749
|
+
getListenersAsProps(resourceOrId, scope) {
|
|
750
|
+
const resource = typeof resourceOrId === "string" ? { id: resourceOrId } : resourceOrId;
|
|
751
|
+
if (!resource || !resource.id) {
|
|
752
|
+
return {};
|
|
800
753
|
}
|
|
754
|
+
const hooks = vault.getResourceMeta(resource.id, "eventManager");
|
|
755
|
+
const props = {};
|
|
756
|
+
if (hooks && resource) {
|
|
757
|
+
for (const hook of Object.keys(hooks)) {
|
|
758
|
+
props[hook] = (e) => {
|
|
759
|
+
const fullResource = vault.get(resource);
|
|
760
|
+
for (const { callback, scope: _scope } of hooks[hook] || []) {
|
|
761
|
+
if (!_scope || scope && _scope.indexOf(scope) !== -1) {
|
|
762
|
+
callback(e, fullResource);
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
};
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
return props;
|
|
801
769
|
}
|
|
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
|
-
|
|
770
|
+
};
|
|
771
|
+
}
|
|
815
772
|
function useResourceEvents(resource, scope) {
|
|
816
773
|
const vault = useVault();
|
|
817
774
|
const helper = useMemo(() => createEventsHelper(vault), [vault]);
|
|
@@ -825,7 +782,18 @@ function useResourceEvents(resource, scope) {
|
|
|
825
782
|
return resource ? helper.getListenersAsProps(resource, scope) : {};
|
|
826
783
|
}, [hooks, resource, vault, scope]);
|
|
827
784
|
}
|
|
828
|
-
|
|
785
|
+
function createStylesHelper(vault) {
|
|
786
|
+
return {
|
|
787
|
+
applyStyles(resource, scope, styles) {
|
|
788
|
+
const id = typeof resource === "string" ? resource : resource.id;
|
|
789
|
+
return vault.setMetaValue([id, "styles", scope], styles);
|
|
790
|
+
},
|
|
791
|
+
getAppliedStyles(resource) {
|
|
792
|
+
const id = typeof resource === "string" ? resource : resource.id;
|
|
793
|
+
return vault.getResourceMeta(id, "styles");
|
|
794
|
+
}
|
|
795
|
+
};
|
|
796
|
+
}
|
|
829
797
|
function useStyles(resource, scope) {
|
|
830
798
|
const vault = useVault();
|
|
831
799
|
const helper = useMemo(() => createStylesHelper(vault), [vault]);
|
|
@@ -837,8 +805,7 @@ function useStyles(resource, scope) {
|
|
|
837
805
|
return styles ? scope ? styles[scope] : styles : void 0;
|
|
838
806
|
}, [resource, scope]);
|
|
839
807
|
}
|
|
840
|
-
|
|
841
|
-
const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
|
|
808
|
+
const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
|
|
842
809
|
const TEMPORAL_SELECTOR = /&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;
|
|
843
810
|
function parseSelector(source) {
|
|
844
811
|
if (Array.isArray(source)) {
|
|
@@ -890,7 +857,7 @@ function parseSelector(source) {
|
|
|
890
857
|
const selector = {
|
|
891
858
|
type: "BoxSelector",
|
|
892
859
|
spatial: {
|
|
893
|
-
unit: matchBoxSelector[2] === "percent:" ? "percent" : "pixel",
|
|
860
|
+
unit: matchBoxSelector[2] === "percent:" || matchBoxSelector[2] === "pct:" ? "percent" : "pixel",
|
|
894
861
|
x: parseFloat(matchBoxSelector[3]),
|
|
895
862
|
y: parseFloat(matchBoxSelector[4]),
|
|
896
863
|
width: parseFloat(matchBoxSelector[5]),
|
|
@@ -926,26 +893,6 @@ function parseSelector(source) {
|
|
|
926
893
|
selectors: []
|
|
927
894
|
};
|
|
928
895
|
}
|
|
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
896
|
function expandTarget(target, options = {}) {
|
|
950
897
|
if (Array.isArray(target)) {
|
|
951
898
|
return expandTarget(target[0]);
|
|
@@ -1002,7 +949,7 @@ function expandTarget(target, options = {}) {
|
|
|
1002
949
|
if (!fragment) {
|
|
1003
950
|
return {
|
|
1004
951
|
type: "SpecificResource",
|
|
1005
|
-
source: __spreadProps
|
|
952
|
+
source: __spreadProps(__spreadValues({}, target), {
|
|
1006
953
|
id
|
|
1007
954
|
}),
|
|
1008
955
|
selector: null,
|
|
@@ -1011,7 +958,7 @@ function expandTarget(target, options = {}) {
|
|
|
1011
958
|
}
|
|
1012
959
|
return expandTarget({
|
|
1013
960
|
type: "SpecificResource",
|
|
1014
|
-
source: __spreadProps
|
|
961
|
+
source: __spreadProps(__spreadValues({}, target), {
|
|
1015
962
|
id
|
|
1016
963
|
}),
|
|
1017
964
|
selector: {
|
|
@@ -1027,26 +974,6 @@ function expandTarget(target, options = {}) {
|
|
|
1027
974
|
selectors: []
|
|
1028
975
|
};
|
|
1029
976
|
}
|
|
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
977
|
function useAnnotation(options = {}, deps = []) {
|
|
1051
978
|
const { id, selector } = options;
|
|
1052
979
|
const ctx = useResourceContext();
|
|
@@ -1058,7 +985,7 @@ function useAnnotation(options = {}, deps = []) {
|
|
|
1058
985
|
if (!annotation) {
|
|
1059
986
|
return void 0;
|
|
1060
987
|
}
|
|
1061
|
-
const newAnnotation = __spreadProps
|
|
988
|
+
const newAnnotation = __spreadProps(__spreadValues({}, annotation), {
|
|
1062
989
|
body,
|
|
1063
990
|
target: expandTarget(annotation.target, { typeMap: vault.getState().iiif.mapping })
|
|
1064
991
|
});
|
|
@@ -1068,7 +995,6 @@ function useAnnotation(options = {}, deps = []) {
|
|
|
1068
995
|
return newAnnotation;
|
|
1069
996
|
}, [annotation, selector, body, ...deps]);
|
|
1070
997
|
}
|
|
1071
|
-
|
|
1072
998
|
function useCanvas(options = {}, deps = []) {
|
|
1073
999
|
const { id, selector } = options;
|
|
1074
1000
|
const ctx = useResourceContext();
|
|
@@ -1084,30 +1010,15 @@ function useCanvas(options = {}, deps = []) {
|
|
|
1084
1010
|
return canvas;
|
|
1085
1011
|
}, [canvas, selector, ...deps]);
|
|
1086
1012
|
}
|
|
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
1013
|
const RenderAnnotation = ({
|
|
1105
1014
|
id,
|
|
1106
1015
|
style: defaultStyle,
|
|
1107
1016
|
className,
|
|
1108
1017
|
interactive
|
|
1109
1018
|
}) => {
|
|
1110
|
-
const annotation = useAnnotation({
|
|
1019
|
+
const annotation = useAnnotation({
|
|
1020
|
+
id
|
|
1021
|
+
});
|
|
1111
1022
|
const style = useStyles(annotation, "atlas");
|
|
1112
1023
|
const html = useStyles(annotation, "html");
|
|
1113
1024
|
const events = useResourceEvents(annotation, ["atlas"]);
|
|
@@ -1119,7 +1030,7 @@ const RenderAnnotation = ({
|
|
|
1119
1030
|
if (!isValid) {
|
|
1120
1031
|
return null;
|
|
1121
1032
|
}
|
|
1122
|
-
return /* @__PURE__ */
|
|
1033
|
+
return /* @__PURE__ */ jsx(RegionHighlight, __spreadValues({
|
|
1123
1034
|
id: annotation.id,
|
|
1124
1035
|
isEditing: true,
|
|
1125
1036
|
region: annotation.target.selector.spatial,
|
|
@@ -1131,7 +1042,6 @@ const RenderAnnotation = ({
|
|
|
1131
1042
|
hrefTarget: (html == null ? void 0 : html.target) || null
|
|
1132
1043
|
}, events));
|
|
1133
1044
|
};
|
|
1134
|
-
|
|
1135
1045
|
const RenderAnnotationPage = ({
|
|
1136
1046
|
className,
|
|
1137
1047
|
page
|
|
@@ -1140,17 +1050,16 @@ const RenderAnnotationPage = ({
|
|
|
1140
1050
|
const style = useStyles(page, "atlas");
|
|
1141
1051
|
const html = useStyles(page, "html");
|
|
1142
1052
|
useVaultSelector((state) => page.id ? state.iiif.entities.AnnotationPage[page.id] : null, []);
|
|
1143
|
-
return /* @__PURE__ */
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1053
|
+
return /* @__PURE__ */ jsx(Fragment$1, {
|
|
1054
|
+
children: (_a = page.items) == null ? void 0 : _a.map((annotation) => {
|
|
1055
|
+
return /* @__PURE__ */ jsx(RenderAnnotation, {
|
|
1056
|
+
id: annotation.id,
|
|
1057
|
+
style,
|
|
1058
|
+
className: (html == null ? void 0 : html.className) || className
|
|
1059
|
+
}, annotation.id);
|
|
1060
|
+
})
|
|
1061
|
+
});
|
|
1151
1062
|
};
|
|
1152
|
-
|
|
1153
|
-
const TileSet = TileSet$1;
|
|
1154
1063
|
function RenderImage({
|
|
1155
1064
|
id,
|
|
1156
1065
|
image,
|
|
@@ -1162,35 +1071,33 @@ function RenderImage({
|
|
|
1162
1071
|
children
|
|
1163
1072
|
}) {
|
|
1164
1073
|
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));
|
|
1074
|
+
return /* @__PURE__ */ jsx(Fragment$1, {
|
|
1075
|
+
children: !image.service ? /* @__PURE__ */ jsxs(Fragment$1, {
|
|
1076
|
+
children: [/* @__PURE__ */ jsx("world-image", {
|
|
1077
|
+
uri: image.id,
|
|
1078
|
+
target: image.target.spatial,
|
|
1079
|
+
display: image.width && image.height ? {
|
|
1080
|
+
width: image.width,
|
|
1081
|
+
height: image.height
|
|
1082
|
+
} : void 0
|
|
1083
|
+
}), annotations, children]
|
|
1084
|
+
}, "no-service") : /* @__PURE__ */ jsxs(Fragment$1, {
|
|
1085
|
+
children: [/* @__PURE__ */ jsx(TileSet, {
|
|
1086
|
+
tiles: {
|
|
1087
|
+
id: image.service.id || image.service["@id"] || "unknown",
|
|
1088
|
+
height: image.height,
|
|
1089
|
+
width: image.width,
|
|
1090
|
+
imageService: image.service,
|
|
1091
|
+
thumbnail: thumbnail && thumbnail.type === "fixed" ? thumbnail : void 0
|
|
1092
|
+
},
|
|
1093
|
+
x: ((_a = image.target) == null ? void 0 : _a.spatial.x) + x,
|
|
1094
|
+
y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
|
|
1095
|
+
width: (_c = image.target) == null ? void 0 : _c.spatial.width,
|
|
1096
|
+
height: (_d = image.target) == null ? void 0 : _d.spatial.height
|
|
1097
|
+
}), annotations, children]
|
|
1098
|
+
}, "service")
|
|
1099
|
+
}, id);
|
|
1192
1100
|
}
|
|
1193
|
-
|
|
1194
1101
|
function parseSpecificResource(resource) {
|
|
1195
1102
|
if (resource.type === "SpecificResource") {
|
|
1196
1103
|
return [resource.source, { selector: resource.selector }];
|
|
@@ -1249,7 +1156,6 @@ const unknownResponse = { type: "unknown" };
|
|
|
1249
1156
|
const unsupportedStrategy = (reason) => {
|
|
1250
1157
|
return { type: "unknown", reason, annotations: { pages: [] } };
|
|
1251
1158
|
};
|
|
1252
|
-
|
|
1253
1159
|
function useManifest(options = {}, deps = []) {
|
|
1254
1160
|
const { id, selector } = options;
|
|
1255
1161
|
const ctx = useResourceContext();
|
|
@@ -1266,7 +1172,6 @@ function useManifest(options = {}, deps = []) {
|
|
|
1266
1172
|
return manifest;
|
|
1267
1173
|
}, [manifest, selector, ...deps]);
|
|
1268
1174
|
}
|
|
1269
|
-
|
|
1270
1175
|
function getMeta$1(state, resourceId) {
|
|
1271
1176
|
var _a;
|
|
1272
1177
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1293,7 +1198,6 @@ function useEnabledAnnotationPageIds(resourceId, availablePageIds) {
|
|
|
1293
1198
|
return pageIds;
|
|
1294
1199
|
}, [resourceId, availablePageIds]);
|
|
1295
1200
|
}
|
|
1296
|
-
|
|
1297
1201
|
function flattenAnnotationPageIds({
|
|
1298
1202
|
canvas,
|
|
1299
1203
|
manifest,
|
|
@@ -1327,26 +1231,6 @@ function flattenAnnotationPageIds({
|
|
|
1327
1231
|
}
|
|
1328
1232
|
return foundIds;
|
|
1329
1233
|
}
|
|
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
1234
|
function getMeta(state, resourceId) {
|
|
1351
1235
|
var _a;
|
|
1352
1236
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1377,7 +1261,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1377
1261
|
if (existingResources && !existingResources[resourceId]) {
|
|
1378
1262
|
return existingResources;
|
|
1379
1263
|
}
|
|
1380
|
-
return __spreadProps
|
|
1264
|
+
return __spreadProps(__spreadValues({}, existingResources || {}), {
|
|
1381
1265
|
[resourceId]: false
|
|
1382
1266
|
});
|
|
1383
1267
|
});
|
|
@@ -1404,7 +1288,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1404
1288
|
if (existingResources && existingResources[resourceId]) {
|
|
1405
1289
|
return existingResources;
|
|
1406
1290
|
}
|
|
1407
|
-
return __spreadProps
|
|
1291
|
+
return __spreadProps(__spreadValues({}, existingResources || {}), {
|
|
1408
1292
|
[resourceId]: true
|
|
1409
1293
|
});
|
|
1410
1294
|
});
|
|
@@ -1416,35 +1300,13 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1416
1300
|
setPageDisabled
|
|
1417
1301
|
};
|
|
1418
1302
|
}
|
|
1419
|
-
|
|
1420
1303
|
function useResources(ids, type) {
|
|
1421
1304
|
return useVaultSelector((state, vault) => vault.get(ids.map((id) => ({ id, type }))), [ids, type]);
|
|
1422
1305
|
}
|
|
1423
|
-
|
|
1424
|
-
const ImageServiceLoaderContext = React$1.createContext(new ImageServiceLoader());
|
|
1306
|
+
const ImageServiceLoaderContext = React__default.createContext(new ImageServiceLoader());
|
|
1425
1307
|
function useImageServiceLoader() {
|
|
1426
1308
|
return useContext(ImageServiceLoaderContext);
|
|
1427
1309
|
}
|
|
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
1310
|
function useLoadImageService() {
|
|
1449
1311
|
const loader = useImageServiceLoader();
|
|
1450
1312
|
const [imageServiceStatus, setImageServiceStatus] = useState({});
|
|
@@ -1468,7 +1330,7 @@ function useLoadImageService() {
|
|
|
1468
1330
|
} else if (!imageServiceStatus[imageServiceId]) {
|
|
1469
1331
|
if (!didUnmount.current) {
|
|
1470
1332
|
setImageServiceStatus((r) => {
|
|
1471
|
-
return __spreadProps
|
|
1333
|
+
return __spreadProps(__spreadValues({}, r), {
|
|
1472
1334
|
[imageServiceId]: "loading"
|
|
1473
1335
|
});
|
|
1474
1336
|
});
|
|
@@ -1480,7 +1342,7 @@ function useLoadImageService() {
|
|
|
1480
1342
|
}).then(() => {
|
|
1481
1343
|
if (!didUnmount.current) {
|
|
1482
1344
|
setImageServiceStatus((r) => {
|
|
1483
|
-
return __spreadProps
|
|
1345
|
+
return __spreadProps(__spreadValues({}, r), {
|
|
1484
1346
|
[imageServiceId]: "done"
|
|
1485
1347
|
});
|
|
1486
1348
|
});
|
|
@@ -1492,7 +1354,6 @@ function useLoadImageService() {
|
|
|
1492
1354
|
}, [loader, imageServiceStatus]);
|
|
1493
1355
|
return [loadImageService, imageServiceStatus];
|
|
1494
1356
|
}
|
|
1495
|
-
|
|
1496
1357
|
function usePaintingAnnotations(options = {}) {
|
|
1497
1358
|
const canvas = useCanvas(options.canvasId ? { id: options.canvasId } : void 0);
|
|
1498
1359
|
return useVaultSelector((state, vault) => {
|
|
@@ -1507,7 +1368,6 @@ function usePaintingAnnotations(options = {}) {
|
|
|
1507
1368
|
return flatAnnotations;
|
|
1508
1369
|
}, [canvas]);
|
|
1509
1370
|
}
|
|
1510
|
-
|
|
1511
1371
|
function usePaintables(options, deps = []) {
|
|
1512
1372
|
const vault = useVault();
|
|
1513
1373
|
const paintingAnnotations = usePaintingAnnotations();
|
|
@@ -1551,7 +1411,6 @@ function usePaintables(options, deps = []) {
|
|
|
1551
1411
|
const actions = { makeChoice };
|
|
1552
1412
|
return [paintables, actions];
|
|
1553
1413
|
}
|
|
1554
|
-
|
|
1555
1414
|
function getImageStrategy(canvas, paintables, loadImageService) {
|
|
1556
1415
|
const imageTypes = [];
|
|
1557
1416
|
for (const singleImage of paintables.items) {
|
|
@@ -1625,7 +1484,6 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1625
1484
|
choice: paintables.choice
|
|
1626
1485
|
};
|
|
1627
1486
|
}
|
|
1628
|
-
|
|
1629
1487
|
const supportedFormats = ["model/gltf-binary"];
|
|
1630
1488
|
function get3dStrategy(canvas, paintables) {
|
|
1631
1489
|
const first = paintables.items[0];
|
|
@@ -1641,7 +1499,6 @@ function get3dStrategy(canvas, paintables) {
|
|
|
1641
1499
|
model: resource
|
|
1642
1500
|
};
|
|
1643
1501
|
}
|
|
1644
|
-
|
|
1645
1502
|
function getAudioStrategy(canvas, paintables) {
|
|
1646
1503
|
var _a;
|
|
1647
1504
|
if (!canvas.duration) {
|
|
@@ -1684,7 +1541,6 @@ function getAudioStrategy(canvas, paintables) {
|
|
|
1684
1541
|
}
|
|
1685
1542
|
};
|
|
1686
1543
|
}
|
|
1687
|
-
|
|
1688
1544
|
function getVideoStrategy(canvas, paintables) {
|
|
1689
1545
|
var _a;
|
|
1690
1546
|
const videoPaintables = paintables.items.filter((t) => t.type === "video");
|
|
@@ -1729,26 +1585,6 @@ function getVideoStrategy(canvas, paintables) {
|
|
|
1729
1585
|
}
|
|
1730
1586
|
};
|
|
1731
1587
|
}
|
|
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
1588
|
function useRenderingStrategy(options) {
|
|
1753
1589
|
const manifest = useManifest();
|
|
1754
1590
|
const canvas = useCanvas();
|
|
@@ -1806,21 +1642,96 @@ function useRenderingStrategy(options) {
|
|
|
1806
1642
|
return [strategy, emptyActions];
|
|
1807
1643
|
}
|
|
1808
1644
|
return [
|
|
1809
|
-
__spreadProps
|
|
1645
|
+
__spreadProps(__spreadValues({}, strategy), {
|
|
1810
1646
|
annotations: { pages: enabledPages }
|
|
1811
1647
|
}),
|
|
1812
1648
|
actions
|
|
1813
1649
|
];
|
|
1814
1650
|
}, [strategy, enabledPages]);
|
|
1815
1651
|
}
|
|
1816
|
-
|
|
1817
1652
|
const useVaultEffect = (callback, deps = []) => {
|
|
1818
1653
|
const vault = useVault();
|
|
1819
1654
|
useEffect(() => {
|
|
1820
1655
|
callback(vault);
|
|
1821
1656
|
}, [vault, ...deps]);
|
|
1822
1657
|
};
|
|
1823
|
-
|
|
1658
|
+
function createThumbnailHelper(vault, dependencies = {}) {
|
|
1659
|
+
const imageServiceLoader = dependencies.imageServiceLoader || new ImageServiceLoader();
|
|
1660
|
+
async function getBestThumbnailAtSize(input, request, dereference, candidates = [], dimensions) {
|
|
1661
|
+
if (typeof input === "string") {
|
|
1662
|
+
return { best: getFixedSizeFromImage(input), fallback: [], log: [] };
|
|
1663
|
+
}
|
|
1664
|
+
const fullInput = vault.get(input);
|
|
1665
|
+
if (typeof fullInput === "string") {
|
|
1666
|
+
return { best: getFixedSizeFromImage(fullInput), fallback: [], log: [] };
|
|
1667
|
+
}
|
|
1668
|
+
switch (fullInput.type) {
|
|
1669
|
+
case "Annotation": {
|
|
1670
|
+
const contentResources = fullInput.body;
|
|
1671
|
+
const firstContentResources = vault.get(contentResources[0]);
|
|
1672
|
+
if (dimensions && !firstContentResources.width) {
|
|
1673
|
+
firstContentResources.width = dimensions.width;
|
|
1674
|
+
firstContentResources.height = dimensions.height;
|
|
1675
|
+
}
|
|
1676
|
+
return await imageServiceLoader.getThumbnailFromResource(firstContentResources, request, dereference, candidates);
|
|
1677
|
+
}
|
|
1678
|
+
case "Canvas": {
|
|
1679
|
+
const canvas = fullInput;
|
|
1680
|
+
if (canvas.thumbnail && canvas.thumbnail.length) {
|
|
1681
|
+
const thumbnail = vault.get(canvas.thumbnail[0]);
|
|
1682
|
+
const potentialThumbnails = await imageServiceLoader.getImageCandidates(thumbnail, dereference);
|
|
1683
|
+
if (potentialThumbnails && potentialThumbnails.length) {
|
|
1684
|
+
candidates.push(...potentialThumbnails);
|
|
1685
|
+
}
|
|
1686
|
+
}
|
|
1687
|
+
return getBestThumbnailAtSize(canvas.items[0], request, dereference, candidates, {
|
|
1688
|
+
width: canvas.width,
|
|
1689
|
+
height: canvas.height
|
|
1690
|
+
});
|
|
1691
|
+
}
|
|
1692
|
+
case "AnnotationPage": {
|
|
1693
|
+
const annotationPage = fullInput;
|
|
1694
|
+
return getBestThumbnailAtSize(annotationPage.items[0], request, dereference, candidates, dimensions);
|
|
1695
|
+
}
|
|
1696
|
+
case "Choice": {
|
|
1697
|
+
const choice = fullInput;
|
|
1698
|
+
return getBestThumbnailAtSize(choice.items[0], request, dereference, candidates, dimensions);
|
|
1699
|
+
}
|
|
1700
|
+
case "Collection": {
|
|
1701
|
+
const collection = fullInput;
|
|
1702
|
+
const firstManifest = collection.items[0];
|
|
1703
|
+
return getBestThumbnailAtSize(firstManifest, request, dereference, candidates, dimensions);
|
|
1704
|
+
}
|
|
1705
|
+
case "Manifest": {
|
|
1706
|
+
const manifest = fullInput;
|
|
1707
|
+
const firstCanvas = manifest.items[0];
|
|
1708
|
+
return getBestThumbnailAtSize(firstCanvas, request, dereference, candidates, dimensions);
|
|
1709
|
+
}
|
|
1710
|
+
case "SpecificResource":
|
|
1711
|
+
case "Image":
|
|
1712
|
+
case "Dataset":
|
|
1713
|
+
case "Sound":
|
|
1714
|
+
case "Text":
|
|
1715
|
+
case "TextualBody":
|
|
1716
|
+
case "Video":
|
|
1717
|
+
if (dimensions && !fullInput.width) {
|
|
1718
|
+
fullInput.width = dimensions.width;
|
|
1719
|
+
fullInput.height = dimensions.height;
|
|
1720
|
+
}
|
|
1721
|
+
return imageServiceLoader.getThumbnailFromResource(fullInput, request, dereference, candidates);
|
|
1722
|
+
case "Service":
|
|
1723
|
+
case "Range":
|
|
1724
|
+
case "AnnotationCollection":
|
|
1725
|
+
case "CanvasReference":
|
|
1726
|
+
case "ContentResource":
|
|
1727
|
+
return { best: void 0, fallback: [], log: [] };
|
|
1728
|
+
}
|
|
1729
|
+
return { best: void 0, fallback: [], log: [] };
|
|
1730
|
+
}
|
|
1731
|
+
return {
|
|
1732
|
+
getBestThumbnailAtSize
|
|
1733
|
+
};
|
|
1734
|
+
}
|
|
1824
1735
|
function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
1825
1736
|
const vault = useVault();
|
|
1826
1737
|
const loader = useImageServiceLoader();
|
|
@@ -1847,49 +1758,29 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
|
1847
1758
|
}, [subject]);
|
|
1848
1759
|
return thumbnail;
|
|
1849
1760
|
}
|
|
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
1761
|
function getDefaultState(duration) {
|
|
1871
1762
|
return { isMuted: false, playRequested: false, isPlaying: false, isFinished: false, volume: 100, duration };
|
|
1872
1763
|
}
|
|
1873
1764
|
function reducer(state, action) {
|
|
1874
1765
|
switch (action.type) {
|
|
1875
1766
|
case "FINISHED":
|
|
1876
|
-
return __spreadProps(__spreadValues
|
|
1767
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: true, isPlaying: false, playRequested: false });
|
|
1877
1768
|
case "PLAY_PAUSE":
|
|
1878
|
-
return __spreadProps(__spreadValues
|
|
1769
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: false, isPlaying: !state.isPlaying });
|
|
1879
1770
|
case "PLAY_REQUESTED":
|
|
1880
|
-
return __spreadProps(__spreadValues
|
|
1771
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: false, playRequested: true });
|
|
1881
1772
|
case "PAUSE":
|
|
1882
|
-
return __spreadProps(__spreadValues
|
|
1773
|
+
return __spreadProps(__spreadValues({}, state), { isPlaying: false });
|
|
1883
1774
|
case "PLAY":
|
|
1884
|
-
return __spreadProps(__spreadValues
|
|
1775
|
+
return __spreadProps(__spreadValues({}, state), { isFinished: false, playRequested: false, isPlaying: true });
|
|
1885
1776
|
case "MUTE":
|
|
1886
|
-
return __spreadProps(__spreadValues
|
|
1777
|
+
return __spreadProps(__spreadValues({}, state), { isMuted: true });
|
|
1887
1778
|
case "SET_VOLUME":
|
|
1888
|
-
return __spreadProps(__spreadValues
|
|
1779
|
+
return __spreadProps(__spreadValues({}, state), { volume: action.volume, isMuted: action.volume === 0 });
|
|
1889
1780
|
case "TOGGLE_MUTE":
|
|
1890
|
-
return __spreadProps(__spreadValues
|
|
1781
|
+
return __spreadProps(__spreadValues({}, state), { isMuted: !state.isMuted });
|
|
1891
1782
|
case "UNMUTE":
|
|
1892
|
-
return __spreadProps(__spreadValues
|
|
1783
|
+
return __spreadProps(__spreadValues({}, state), { isMuted: false });
|
|
1893
1784
|
}
|
|
1894
1785
|
return state;
|
|
1895
1786
|
}
|
|
@@ -2007,7 +1898,6 @@ function useSimpleMediaPlayer(props) {
|
|
|
2007
1898
|
}
|
|
2008
1899
|
];
|
|
2009
1900
|
}
|
|
2010
|
-
|
|
2011
1901
|
const MediaReactContextState = createContext(null);
|
|
2012
1902
|
const MediaReactContextActions = createContext(null);
|
|
2013
1903
|
const MediaReactContextElements = createContext(null);
|
|
@@ -2040,35 +1930,65 @@ function MediaPlayerProvider({
|
|
|
2040
1930
|
progress,
|
|
2041
1931
|
element
|
|
2042
1932
|
}) {
|
|
2043
|
-
return /* @__PURE__ */
|
|
2044
|
-
value: {
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
|
|
2052
|
-
|
|
2053
|
-
|
|
2054
|
-
|
|
2055
|
-
|
|
2056
|
-
|
|
1933
|
+
return /* @__PURE__ */ jsx(MediaReactContextElements.Provider, {
|
|
1934
|
+
value: {
|
|
1935
|
+
currentTime,
|
|
1936
|
+
progress,
|
|
1937
|
+
element
|
|
1938
|
+
},
|
|
1939
|
+
children: /* @__PURE__ */ jsx(MediaReactContextActions.Provider, {
|
|
1940
|
+
value: actions,
|
|
1941
|
+
children: /* @__PURE__ */ jsx(MediaReactContextState.Provider, {
|
|
1942
|
+
value: state,
|
|
1943
|
+
children
|
|
1944
|
+
})
|
|
1945
|
+
})
|
|
1946
|
+
});
|
|
1947
|
+
}
|
|
1948
|
+
function Audio({
|
|
1949
|
+
media,
|
|
1950
|
+
children
|
|
1951
|
+
}) {
|
|
1952
|
+
const [{
|
|
1953
|
+
element,
|
|
2057
1954
|
currentTime,
|
|
2058
|
-
progress
|
|
2059
|
-
|
|
2060
|
-
|
|
2061
|
-
|
|
2062
|
-
|
|
2063
|
-
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
1955
|
+
progress
|
|
1956
|
+
}, state, actions] = useSimpleMediaPlayer({
|
|
1957
|
+
duration: media.duration
|
|
1958
|
+
});
|
|
1959
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
1960
|
+
children: /* @__PURE__ */ jsx(CanvasPortal, {
|
|
1961
|
+
children: /* @__PURE__ */ jsxs(MediaPlayerProvider, {
|
|
1962
|
+
state,
|
|
1963
|
+
actions,
|
|
1964
|
+
currentTime,
|
|
1965
|
+
progress,
|
|
1966
|
+
element,
|
|
1967
|
+
children: [/* @__PURE__ */ jsx("audio", {
|
|
1968
|
+
ref: element,
|
|
1969
|
+
src: media.url
|
|
1970
|
+
}), children]
|
|
1971
|
+
})
|
|
1972
|
+
})
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
function Video({
|
|
1976
|
+
media,
|
|
1977
|
+
children
|
|
1978
|
+
}) {
|
|
1979
|
+
const [{
|
|
1980
|
+
element,
|
|
1981
|
+
currentTime,
|
|
1982
|
+
progress
|
|
1983
|
+
}, state, actions] = useSimpleMediaPlayer({
|
|
1984
|
+
duration: media.duration
|
|
1985
|
+
});
|
|
2068
1986
|
const Component = "div";
|
|
2069
|
-
return /* @__PURE__ */
|
|
2070
|
-
|
|
2071
|
-
|
|
1987
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
1988
|
+
children: [/* @__PURE__ */ jsxs(CanvasPortal, {
|
|
1989
|
+
overlay: true,
|
|
1990
|
+
children: [/* @__PURE__ */ jsx("style", {
|
|
1991
|
+
children: `
|
|
2072
1992
|
.video-container {
|
|
2073
1993
|
position: absolute;
|
|
2074
1994
|
top: 0;
|
|
@@ -2081,27 +2001,39 @@ function Video({ media, children }) {
|
|
|
2081
2001
|
justify-content: center;
|
|
2082
2002
|
pointer-events: visible;
|
|
2083
2003
|
}
|
|
2084
|
-
`
|
|
2085
|
-
|
|
2086
|
-
|
|
2087
|
-
|
|
2088
|
-
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2004
|
+
`
|
|
2005
|
+
}), /* @__PURE__ */ jsx(Component, {
|
|
2006
|
+
className: "video-container",
|
|
2007
|
+
part: "video-container",
|
|
2008
|
+
onClick: () => actions.playPause(),
|
|
2009
|
+
children: /* @__PURE__ */ jsx("video", {
|
|
2010
|
+
ref: element,
|
|
2011
|
+
src: media.url,
|
|
2012
|
+
style: {
|
|
2013
|
+
width: "100%",
|
|
2014
|
+
objectFit: "contain"
|
|
2015
|
+
}
|
|
2016
|
+
})
|
|
2017
|
+
})]
|
|
2018
|
+
}), /* @__PURE__ */ jsx(CanvasPortal, {
|
|
2019
|
+
children: /* @__PURE__ */ jsx(MediaPlayerProvider, {
|
|
2020
|
+
state,
|
|
2021
|
+
actions,
|
|
2022
|
+
currentTime,
|
|
2023
|
+
progress,
|
|
2024
|
+
element,
|
|
2025
|
+
children
|
|
2026
|
+
})
|
|
2027
|
+
})]
|
|
2028
|
+
});
|
|
2029
|
+
}
|
|
2030
|
+
function Model({
|
|
2031
|
+
model
|
|
2032
|
+
}) {
|
|
2033
|
+
return /* @__PURE__ */ jsxs(CanvasPortal, {
|
|
2034
|
+
overlay: true,
|
|
2035
|
+
children: [/* @__PURE__ */ jsx("style", {
|
|
2036
|
+
children: `
|
|
2105
2037
|
.model-container {
|
|
2106
2038
|
position: absolute;
|
|
2107
2039
|
top: 0;
|
|
@@ -2114,33 +2046,22 @@ function Model({ model }) {
|
|
|
2114
2046
|
justify-content: center;
|
|
2115
2047
|
pointer-events: visible;
|
|
2116
2048
|
}
|
|
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
|
-
};
|
|
2049
|
+
`
|
|
2050
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
2051
|
+
className: "model-container",
|
|
2052
|
+
children: /* @__PURE__ */ jsx("model-viewer", {
|
|
2053
|
+
"interaction-prompt": "none",
|
|
2054
|
+
style: {
|
|
2055
|
+
width: "100%",
|
|
2056
|
+
height: "100%"
|
|
2057
|
+
},
|
|
2058
|
+
"camera-controls": "",
|
|
2059
|
+
"ar-status": "not-presenting",
|
|
2060
|
+
src: model.id
|
|
2061
|
+
})
|
|
2062
|
+
})]
|
|
2063
|
+
});
|
|
2064
|
+
}
|
|
2144
2065
|
function RenderCanvas({
|
|
2145
2066
|
x,
|
|
2146
2067
|
y,
|
|
@@ -2160,7 +2081,9 @@ function RenderCanvas({
|
|
|
2160
2081
|
const helper = useMemo(() => createStylesHelper(vault), [vault]);
|
|
2161
2082
|
const [strategy, actions] = useRenderingStrategy({
|
|
2162
2083
|
strategies: strategies || ["images"],
|
|
2163
|
-
defaultChoices: defaultChoices == null ? void 0 : defaultChoices.map(({
|
|
2084
|
+
defaultChoices: defaultChoices == null ? void 0 : defaultChoices.map(({
|
|
2085
|
+
id
|
|
2086
|
+
}) => id)
|
|
2164
2087
|
});
|
|
2165
2088
|
const choice = strategy.type === "images" ? strategy.choice : void 0;
|
|
2166
2089
|
useEffect(() => {
|
|
@@ -2172,7 +2095,9 @@ function RenderCanvas({
|
|
|
2172
2095
|
if (defaultChoices) {
|
|
2173
2096
|
for (const choice2 of defaultChoices) {
|
|
2174
2097
|
if (typeof choice2.opacity !== "undefined") {
|
|
2175
|
-
helper.applyStyles({
|
|
2098
|
+
helper.applyStyles({
|
|
2099
|
+
id: choice2.id
|
|
2100
|
+
}, "atlas", {
|
|
2176
2101
|
opacity: choice2.opacity
|
|
2177
2102
|
});
|
|
2178
2103
|
}
|
|
@@ -2184,66 +2109,87 @@ function RenderCanvas({
|
|
|
2184
2109
|
onChoiceChange(choice);
|
|
2185
2110
|
}
|
|
2186
2111
|
}, [choice]);
|
|
2187
|
-
const thumbnail = useThumbnail({
|
|
2112
|
+
const thumbnail = useThumbnail({
|
|
2113
|
+
maxWidth: 256,
|
|
2114
|
+
maxHeight: 256
|
|
2115
|
+
});
|
|
2188
2116
|
if (!canvas) {
|
|
2189
2117
|
return null;
|
|
2190
2118
|
}
|
|
2191
2119
|
const accompanyingCanvas = canvas.accompanyingCanvas;
|
|
2192
|
-
const thumbnailFallbackImage = thumbnail && thumbnail.type === "fixed" ? /* @__PURE__ */
|
|
2120
|
+
const thumbnailFallbackImage = thumbnail && thumbnail.type === "fixed" ? /* @__PURE__ */ jsx("world-object", {
|
|
2193
2121
|
height: canvas.height,
|
|
2194
2122
|
width: canvas.width,
|
|
2195
2123
|
x,
|
|
2196
|
-
y
|
|
2197
|
-
|
|
2198
|
-
|
|
2199
|
-
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
|
|
2204
|
-
|
|
2124
|
+
y,
|
|
2125
|
+
children: /* @__PURE__ */ jsx("world-image", {
|
|
2126
|
+
uri: thumbnail.id,
|
|
2127
|
+
target: {
|
|
2128
|
+
x: 0,
|
|
2129
|
+
y: 0,
|
|
2130
|
+
width: canvas.width,
|
|
2131
|
+
height: canvas.height
|
|
2132
|
+
},
|
|
2133
|
+
display: thumbnail.width && thumbnail.height ? {
|
|
2134
|
+
width: thumbnail.width,
|
|
2135
|
+
height: thumbnail.height
|
|
2136
|
+
} : void 0
|
|
2137
|
+
})
|
|
2138
|
+
}) : null;
|
|
2205
2139
|
if (strategy.type === "unknown") {
|
|
2206
2140
|
if (thumbnailFallbackImage) {
|
|
2207
2141
|
return thumbnailFallbackImage;
|
|
2208
2142
|
}
|
|
2209
2143
|
throw new Error(strategy.reason || "Unknown image strategy");
|
|
2210
2144
|
}
|
|
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
|
-
|
|
2145
|
+
const annotations = /* @__PURE__ */ jsxs(Fragment$1, {
|
|
2146
|
+
children: [virtualPage ? /* @__PURE__ */ jsx(RenderAnnotationPage, {
|
|
2147
|
+
page: virtualPage
|
|
2148
|
+
}) : null, strategy.annotations && strategy.annotations.pages ? strategy.annotations.pages.map((page) => {
|
|
2149
|
+
return /* @__PURE__ */ jsx(RenderAnnotationPage, {
|
|
2150
|
+
page
|
|
2151
|
+
}, page.id);
|
|
2152
|
+
}) : null, children]
|
|
2153
|
+
});
|
|
2154
|
+
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2155
|
+
children: [/* @__PURE__ */ jsxs("world-object", __spreadProps(__spreadValues({
|
|
2156
|
+
height: canvas.height,
|
|
2157
|
+
width: canvas.width,
|
|
2158
|
+
x,
|
|
2159
|
+
y
|
|
2160
|
+
}, elementProps), {
|
|
2161
|
+
children: [strategy.type === "images" ? /* @__PURE__ */ jsxs(Fragment, {
|
|
2162
|
+
children: [strategy.images.map((image, idx) => {
|
|
2163
|
+
return /* @__PURE__ */ jsx(RenderImage, {
|
|
2164
|
+
isStatic,
|
|
2165
|
+
image,
|
|
2166
|
+
id: image.id,
|
|
2167
|
+
thumbnail: idx === 0 ? thumbnail : void 0,
|
|
2168
|
+
annotations
|
|
2169
|
+
}, image.id);
|
|
2170
|
+
}), renderViewerControls ? /* @__PURE__ */ jsx(CanvasPortal, {
|
|
2171
|
+
overlay: true,
|
|
2172
|
+
children: renderViewerControls(strategy)
|
|
2173
|
+
}) : null]
|
|
2174
|
+
}) : null, strategy.type === "3d-model" ? /* @__PURE__ */ jsx(Model, {
|
|
2175
|
+
model: strategy.model
|
|
2176
|
+
}) : null, strategy.type === "media" ? /* @__PURE__ */ jsx(Fragment, {
|
|
2177
|
+
children: strategy.media.type === "Sound" ? /* @__PURE__ */ jsxs(Audio, {
|
|
2178
|
+
media: strategy.media,
|
|
2179
|
+
children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
|
|
2180
|
+
}) : strategy.media.type === "Video" ? /* @__PURE__ */ jsxs(Video, {
|
|
2181
|
+
media: strategy.media,
|
|
2182
|
+
children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
|
|
2183
|
+
}) : null
|
|
2184
|
+
}) : null]
|
|
2185
|
+
}), strategy.type), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ jsx(CanvasContext, {
|
|
2186
|
+
canvas: accompanyingCanvas.id,
|
|
2187
|
+
children: /* @__PURE__ */ jsx(RenderCanvas, {
|
|
2188
|
+
renderViewerControls
|
|
2189
|
+
})
|
|
2190
|
+
}) : null]
|
|
2191
|
+
});
|
|
2192
|
+
}
|
|
2247
2193
|
const CanvasPanel = {
|
|
2248
2194
|
RenderImage,
|
|
2249
2195
|
RenderCanvas,
|
|
@@ -2251,33 +2197,45 @@ const CanvasPanel = {
|
|
|
2251
2197
|
RenderAnnotation,
|
|
2252
2198
|
Viewer
|
|
2253
2199
|
};
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2271
|
-
|
|
2272
|
-
|
|
2200
|
+
function AnnotationContext({
|
|
2201
|
+
annotation,
|
|
2202
|
+
children
|
|
2203
|
+
}) {
|
|
2204
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
2205
|
+
value: {
|
|
2206
|
+
annotation
|
|
2207
|
+
},
|
|
2208
|
+
children
|
|
2209
|
+
});
|
|
2210
|
+
}
|
|
2211
|
+
function CollectionContext({
|
|
2212
|
+
collection,
|
|
2213
|
+
children
|
|
2214
|
+
}) {
|
|
2215
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
2216
|
+
value: {
|
|
2217
|
+
collection
|
|
2218
|
+
},
|
|
2219
|
+
children
|
|
2220
|
+
});
|
|
2221
|
+
}
|
|
2222
|
+
function RangeContext({
|
|
2223
|
+
range,
|
|
2224
|
+
children
|
|
2225
|
+
}) {
|
|
2226
|
+
return /* @__PURE__ */ jsx(ResourceProvider, {
|
|
2227
|
+
value: {
|
|
2228
|
+
range
|
|
2229
|
+
},
|
|
2230
|
+
children
|
|
2231
|
+
});
|
|
2232
|
+
}
|
|
2273
2233
|
function useAnnotationsAtTime(time, options = {}) {
|
|
2274
2234
|
const allAnnotations = usePaintingAnnotations(options);
|
|
2275
2235
|
return allAnnotations;
|
|
2276
2236
|
}
|
|
2277
|
-
|
|
2278
2237
|
function useCanvasClock(canvasId, autoplay = false) {
|
|
2279
2238
|
}
|
|
2280
|
-
|
|
2281
2239
|
function useCollection(options, deps = []) {
|
|
2282
2240
|
const { id, selector } = options;
|
|
2283
2241
|
const ctx = useResourceContext();
|
|
@@ -2293,7 +2251,6 @@ function useCollection(options, deps = []) {
|
|
|
2293
2251
|
return collection;
|
|
2294
2252
|
}, [collection, selector, ...deps]);
|
|
2295
2253
|
}
|
|
2296
|
-
|
|
2297
2254
|
function useEventListener(resource, name, listener, scope, deps = []) {
|
|
2298
2255
|
const vault = useVault();
|
|
2299
2256
|
const helper = useMemo(() => createEventsHelper(vault), [vault]);
|
|
@@ -2309,37 +2266,14 @@ function useEventListener(resource, name, listener, scope, deps = []) {
|
|
|
2309
2266
|
};
|
|
2310
2267
|
}, [helper, resource, name, ...deps]);
|
|
2311
2268
|
}
|
|
2312
|
-
|
|
2313
2269
|
function useExistingVault() {
|
|
2314
2270
|
const oldContext = useContext(ReactVaultContext);
|
|
2315
2271
|
return oldContext && oldContext.vault ? oldContext.vault : globalVault();
|
|
2316
2272
|
}
|
|
2317
|
-
|
|
2318
2273
|
function useExternalCollection(idOrRef, options) {
|
|
2319
2274
|
const { id, isLoaded, error, resource, requestId, cached } = useExternalResource(idOrRef, options);
|
|
2320
2275
|
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
2321
2276
|
}
|
|
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
2277
|
function useImageService({ cacheKey } = {}) {
|
|
2344
2278
|
const canvas = useCanvas();
|
|
2345
2279
|
const annotations = usePaintingAnnotations();
|
|
@@ -2373,7 +2307,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2373
2307
|
}, [key, cacheKey, canvas]);
|
|
2374
2308
|
const data = status === "success" && _data ? _data : initialData;
|
|
2375
2309
|
useEffect(() => {
|
|
2376
|
-
(() =>
|
|
2310
|
+
(async () => {
|
|
2377
2311
|
try {
|
|
2378
2312
|
if (canvas && annotations.length) {
|
|
2379
2313
|
const annotation = annotations[0];
|
|
@@ -2386,11 +2320,11 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2386
2320
|
setIsFetching(true);
|
|
2387
2321
|
setStatus("loading");
|
|
2388
2322
|
try {
|
|
2389
|
-
const loadedService =
|
|
2323
|
+
const loadedService = await imageService.loadService({
|
|
2390
2324
|
id: firstImageService.id || firstImageService["@id"],
|
|
2391
2325
|
width: firstImageService.width || canvas.width,
|
|
2392
2326
|
height: firstImageService.height || canvas.height
|
|
2393
|
-
})
|
|
2327
|
+
}) || void 0;
|
|
2394
2328
|
setData(loadedService);
|
|
2395
2329
|
setStatus("success");
|
|
2396
2330
|
setIsFetching(false);
|
|
@@ -2403,7 +2337,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2403
2337
|
setStatus("error");
|
|
2404
2338
|
setError(err);
|
|
2405
2339
|
}
|
|
2406
|
-
})
|
|
2340
|
+
})();
|
|
2407
2341
|
}, [key, cacheKey]);
|
|
2408
2342
|
return useMemo(() => {
|
|
2409
2343
|
return {
|
|
@@ -2414,7 +2348,6 @@ function useImageService({ cacheKey } = {}) {
|
|
|
2414
2348
|
};
|
|
2415
2349
|
}, [data, isFetching, status, error]);
|
|
2416
2350
|
}
|
|
2417
|
-
|
|
2418
2351
|
function useImageTile() {
|
|
2419
2352
|
const imageService = useImageService();
|
|
2420
2353
|
return {
|
|
@@ -2428,7 +2361,6 @@ function useImageTile() {
|
|
|
2428
2361
|
} : null
|
|
2429
2362
|
};
|
|
2430
2363
|
}
|
|
2431
|
-
|
|
2432
2364
|
function useRange(options = {}, deps = []) {
|
|
2433
2365
|
const { id, selector } = options;
|
|
2434
2366
|
const ctx = useResourceContext();
|
|
@@ -2444,15 +2376,13 @@ function useRange(options = {}, deps = []) {
|
|
|
2444
2376
|
return range;
|
|
2445
2377
|
}, [range, selector, ...deps]);
|
|
2446
2378
|
}
|
|
2447
|
-
|
|
2448
2379
|
function useSearchService() {
|
|
2449
2380
|
const manifest = useManifest();
|
|
2450
2381
|
return manifest ? manifest.service.find((service) => service.profile === "SearchService1" || service.profile === "http://iiif.io/api/search/1/search") : void 0;
|
|
2451
2382
|
}
|
|
2452
|
-
|
|
2453
2383
|
function useStyleHelper() {
|
|
2454
2384
|
const vault = useVault();
|
|
2455
2385
|
return useMemo(() => createStylesHelper(vault), [vault]);
|
|
2456
2386
|
}
|
|
2457
|
-
|
|
2458
2387
|
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 };
|
|
2388
|
+
//# sourceMappingURL=index.mjs.map
|