react-iiif-vault 0.9.8 → 0.9.9
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/dist/cjs/index.js +979 -271
- package/dist/esm/index.mjs +917 -219
- package/dist/index.d.ts +97 -26
- package/dist/index.umd.js +27573 -26870
- package/package.json +13 -10
package/dist/cjs/index.js
CHANGED
|
@@ -2,30 +2,223 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var React = require('react');
|
|
6
|
-
var vault = require('@iiif/vault');
|
|
5
|
+
var React$1 = require('react');
|
|
7
6
|
var atlas = require('@atlas-viewer/atlas');
|
|
7
|
+
var vault = require('@iiif/vault');
|
|
8
8
|
var typesafeActions = require('typesafe-actions');
|
|
9
|
+
var require$$0 = require('react-dom');
|
|
9
10
|
var vaultHelpers = require('@iiif/vault-helpers');
|
|
10
11
|
var iiifImageApi = require('@atlas-viewer/iiif-image-api');
|
|
11
12
|
|
|
12
13
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
14
|
|
|
14
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
15
|
+
var React__default = /*#__PURE__*/_interopDefaultLegacy(React$1);
|
|
16
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
17
|
+
|
|
18
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
19
|
+
|
|
20
|
+
var reactErrorBoundary_umd = {exports: {}};
|
|
21
|
+
|
|
22
|
+
(function (module, exports) {
|
|
23
|
+
(function (global, factory) {
|
|
24
|
+
factory(exports, React__default["default"]) ;
|
|
25
|
+
})(commonjsGlobal, (function (exports, React) {
|
|
26
|
+
function _interopNamespace(e) {
|
|
27
|
+
if (e && e.__esModule) return e;
|
|
28
|
+
var n = Object.create(null);
|
|
29
|
+
if (e) {
|
|
30
|
+
Object.keys(e).forEach(function (k) {
|
|
31
|
+
if (k !== 'default') {
|
|
32
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
33
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return e[k]; }
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
n["default"] = e;
|
|
41
|
+
return Object.freeze(n);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
var React__namespace = /*#__PURE__*/_interopNamespace(React);
|
|
15
45
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
46
|
+
function _setPrototypeOf(o, p) {
|
|
47
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
48
|
+
o.__proto__ = p;
|
|
49
|
+
return o;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return _setPrototypeOf(o, p);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function _inheritsLoose(subClass, superClass) {
|
|
56
|
+
subClass.prototype = Object.create(superClass.prototype);
|
|
57
|
+
subClass.prototype.constructor = subClass;
|
|
58
|
+
_setPrototypeOf(subClass, superClass);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var changedArray = function changedArray(a, b) {
|
|
62
|
+
if (a === void 0) {
|
|
63
|
+
a = [];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (b === void 0) {
|
|
67
|
+
b = [];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return a.length !== b.length || a.some(function (item, index) {
|
|
71
|
+
return !Object.is(item, b[index]);
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
var initialState = {
|
|
76
|
+
error: null
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
var ErrorBoundary = /*#__PURE__*/function (_React$Component) {
|
|
80
|
+
_inheritsLoose(ErrorBoundary, _React$Component);
|
|
81
|
+
|
|
82
|
+
function ErrorBoundary() {
|
|
83
|
+
var _this;
|
|
84
|
+
|
|
85
|
+
for (var _len = arguments.length, _args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
86
|
+
_args[_key] = arguments[_key];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
_this = _React$Component.call.apply(_React$Component, [this].concat(_args)) || this;
|
|
90
|
+
_this.state = initialState;
|
|
91
|
+
|
|
92
|
+
_this.resetErrorBoundary = function () {
|
|
93
|
+
var _this$props;
|
|
94
|
+
|
|
95
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
96
|
+
args[_key2] = arguments[_key2];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
_this.props.onReset == null ? void 0 : (_this$props = _this.props).onReset.apply(_this$props, args);
|
|
100
|
+
|
|
101
|
+
_this.reset();
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
return _this;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
ErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
|
|
108
|
+
return {
|
|
109
|
+
error: error
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
var _proto = ErrorBoundary.prototype;
|
|
114
|
+
|
|
115
|
+
_proto.reset = function reset() {
|
|
116
|
+
this.setState(initialState);
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
_proto.componentDidCatch = function componentDidCatch(error, info) {
|
|
120
|
+
var _this$props$onError, _this$props2;
|
|
121
|
+
|
|
122
|
+
(_this$props$onError = (_this$props2 = this.props).onError) == null ? void 0 : _this$props$onError.call(_this$props2, error, info);
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
_proto.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
|
|
126
|
+
var error = this.state.error;
|
|
127
|
+
var resetKeys = this.props.resetKeys; // There's an edge case where if the thing that triggered the error
|
|
128
|
+
// happens to *also* be in the resetKeys array, we'd end up resetting
|
|
129
|
+
// the error boundary immediately. This would likely trigger a second
|
|
130
|
+
// error to be thrown.
|
|
131
|
+
// So we make sure that we don't check the resetKeys on the first call
|
|
132
|
+
// of cDU after the error is set
|
|
133
|
+
|
|
134
|
+
if (error !== null && prevState.error !== null && changedArray(prevProps.resetKeys, resetKeys)) {
|
|
135
|
+
var _this$props$onResetKe, _this$props3;
|
|
136
|
+
|
|
137
|
+
(_this$props$onResetKe = (_this$props3 = this.props).onResetKeysChange) == null ? void 0 : _this$props$onResetKe.call(_this$props3, prevProps.resetKeys, resetKeys);
|
|
138
|
+
this.reset();
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
_proto.render = function render() {
|
|
143
|
+
var error = this.state.error;
|
|
144
|
+
var _this$props4 = this.props,
|
|
145
|
+
fallbackRender = _this$props4.fallbackRender,
|
|
146
|
+
FallbackComponent = _this$props4.FallbackComponent,
|
|
147
|
+
fallback = _this$props4.fallback;
|
|
148
|
+
|
|
149
|
+
if (error !== null) {
|
|
150
|
+
var _props = {
|
|
151
|
+
error: error,
|
|
152
|
+
resetErrorBoundary: this.resetErrorBoundary
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
if ( /*#__PURE__*/React__namespace.isValidElement(fallback)) {
|
|
156
|
+
return fallback;
|
|
157
|
+
} else if (typeof fallbackRender === 'function') {
|
|
158
|
+
return fallbackRender(_props);
|
|
159
|
+
} else if (FallbackComponent) {
|
|
160
|
+
return /*#__PURE__*/React__namespace.createElement(FallbackComponent, _props);
|
|
161
|
+
} else {
|
|
162
|
+
throw new Error('react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop');
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return this.props.children;
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
return ErrorBoundary;
|
|
170
|
+
}(React__namespace.Component);
|
|
171
|
+
|
|
172
|
+
function withErrorBoundary(Component, errorBoundaryProps) {
|
|
173
|
+
var Wrapped = function Wrapped(props) {
|
|
174
|
+
return /*#__PURE__*/React__namespace.createElement(ErrorBoundary, errorBoundaryProps, /*#__PURE__*/React__namespace.createElement(Component, props));
|
|
175
|
+
}; // Format for display in DevTools
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
var name = Component.displayName || Component.name || 'Unknown';
|
|
179
|
+
Wrapped.displayName = "withErrorBoundary(" + name + ")";
|
|
180
|
+
return Wrapped;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function useErrorHandler(givenError) {
|
|
184
|
+
var _React$useState = React__namespace.useState(null),
|
|
185
|
+
error = _React$useState[0],
|
|
186
|
+
setError = _React$useState[1];
|
|
187
|
+
|
|
188
|
+
if (givenError != null) throw givenError;
|
|
189
|
+
if (error != null) throw error;
|
|
190
|
+
return setError;
|
|
191
|
+
}
|
|
192
|
+
/*
|
|
193
|
+
eslint
|
|
194
|
+
@typescript-eslint/sort-type-union-intersection-members: "off",
|
|
195
|
+
@typescript-eslint/no-throw-literal: "off",
|
|
196
|
+
@typescript-eslint/prefer-nullish-coalescing: "off"
|
|
197
|
+
*/
|
|
198
|
+
|
|
199
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
200
|
+
exports.useErrorHandler = useErrorHandler;
|
|
201
|
+
exports.withErrorBoundary = withErrorBoundary;
|
|
202
|
+
|
|
203
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
204
|
+
|
|
205
|
+
}));
|
|
206
|
+
|
|
207
|
+
}(reactErrorBoundary_umd, reactErrorBoundary_umd.exports));
|
|
208
|
+
|
|
209
|
+
var __defProp$a = Object.defineProperty;
|
|
210
|
+
var __getOwnPropSymbols$a = Object.getOwnPropertySymbols;
|
|
211
|
+
var __hasOwnProp$a = Object.prototype.hasOwnProperty;
|
|
212
|
+
var __propIsEnum$a = Object.prototype.propertyIsEnumerable;
|
|
213
|
+
var __defNormalProp$a = (obj, key, value) => key in obj ? __defProp$a(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
214
|
+
var __spreadValues$a = (a, b) => {
|
|
22
215
|
for (var prop in b || (b = {}))
|
|
23
|
-
if (__hasOwnProp$
|
|
24
|
-
__defNormalProp$
|
|
25
|
-
if (__getOwnPropSymbols$
|
|
26
|
-
for (var prop of __getOwnPropSymbols$
|
|
27
|
-
if (__propIsEnum$
|
|
28
|
-
__defNormalProp$
|
|
216
|
+
if (__hasOwnProp$a.call(b, prop))
|
|
217
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
218
|
+
if (__getOwnPropSymbols$a)
|
|
219
|
+
for (var prop of __getOwnPropSymbols$a(b)) {
|
|
220
|
+
if (__propIsEnum$a.call(b, prop))
|
|
221
|
+
__defNormalProp$a(a, prop, b[prop]);
|
|
29
222
|
}
|
|
30
223
|
return a;
|
|
31
224
|
};
|
|
@@ -38,25 +231,31 @@ const defaultResourceContext = {
|
|
|
38
231
|
};
|
|
39
232
|
const ResourceReactContext = React__default["default"].createContext(defaultResourceContext);
|
|
40
233
|
const useResourceContext = () => {
|
|
41
|
-
return React.useContext(ResourceReactContext);
|
|
234
|
+
return React$1.useContext(ResourceReactContext);
|
|
42
235
|
};
|
|
43
|
-
|
|
236
|
+
function ResourceProvider({ value, children }) {
|
|
44
237
|
const parentContext = useResourceContext();
|
|
45
|
-
const newContext = React.useMemo(() => {
|
|
46
|
-
return __spreadValues$
|
|
238
|
+
const newContext = React$1.useMemo(() => {
|
|
239
|
+
return __spreadValues$a(__spreadValues$a({}, parentContext), value);
|
|
47
240
|
}, [value, parentContext]);
|
|
48
241
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceReactContext.Provider, {
|
|
49
242
|
value: newContext
|
|
50
243
|
}, children);
|
|
51
|
-
}
|
|
244
|
+
}
|
|
52
245
|
|
|
53
246
|
const ReactVaultContext = React__default["default"].createContext({
|
|
54
247
|
vault: null,
|
|
55
248
|
setVaultInstance: (vault) => {
|
|
56
249
|
}
|
|
57
250
|
});
|
|
58
|
-
|
|
59
|
-
|
|
251
|
+
function VaultProvider({
|
|
252
|
+
vault: vault$1,
|
|
253
|
+
vaultOptions,
|
|
254
|
+
useGlobal,
|
|
255
|
+
resources,
|
|
256
|
+
children
|
|
257
|
+
}) {
|
|
258
|
+
const [vaultInstance, setVaultInstance] = React$1.useState(() => {
|
|
60
259
|
if (vault$1) {
|
|
61
260
|
return vault$1;
|
|
62
261
|
}
|
|
@@ -73,10 +272,10 @@ const VaultProvider = ({ vault: vault$1, vaultOptions, useGlobal, resources, chi
|
|
|
73
272
|
}, /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
74
273
|
value: resources || {}
|
|
75
274
|
}, children));
|
|
76
|
-
}
|
|
275
|
+
}
|
|
77
276
|
|
|
78
277
|
const useVault = () => {
|
|
79
|
-
const { vault } = React.useContext(ReactVaultContext);
|
|
278
|
+
const { vault } = React$1.useContext(ReactVaultContext);
|
|
80
279
|
if (vault === null) {
|
|
81
280
|
throw new Error("Vault not found. Ensure you have your provider set up correctly.");
|
|
82
281
|
}
|
|
@@ -106,13 +305,13 @@ var __async$1 = (__this, __arguments, generator) => {
|
|
|
106
305
|
function useExternalResource(idOrRef, { noCache = false } = {}) {
|
|
107
306
|
const id = typeof idOrRef === "string" ? idOrRef : idOrRef.id;
|
|
108
307
|
const vault = useVault();
|
|
109
|
-
const [realId, setRealId] = React.useState(id);
|
|
110
|
-
const [error, setError] = React.useState(void 0);
|
|
111
|
-
const initialData = React.useMemo(() => {
|
|
308
|
+
const [realId, setRealId] = React$1.useState(id);
|
|
309
|
+
const [error, setError] = React$1.useState(void 0);
|
|
310
|
+
const initialData = React$1.useMemo(() => {
|
|
112
311
|
return vault.get(id, { skipSelfReturn: true }) || void 0;
|
|
113
312
|
}, [id, vault]);
|
|
114
|
-
const [resource, setResource] = React.useState(initialData);
|
|
115
|
-
React.useEffect(() => {
|
|
313
|
+
const [resource, setResource] = React$1.useState(initialData);
|
|
314
|
+
React$1.useEffect(() => {
|
|
116
315
|
(() => __async$1(this, null, function* () {
|
|
117
316
|
try {
|
|
118
317
|
const fetchedResource = initialData && !noCache ? initialData : yield vault.load(id);
|
|
@@ -141,30 +340,32 @@ function useExternalManifest(idOrRef, options) {
|
|
|
141
340
|
return { id, isLoaded, error, manifest: resource, requestId, cached };
|
|
142
341
|
}
|
|
143
342
|
|
|
144
|
-
|
|
343
|
+
function ManifestContext({ manifest, children }) {
|
|
145
344
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
146
345
|
value: { manifest }
|
|
147
346
|
}, children);
|
|
148
|
-
}
|
|
347
|
+
}
|
|
149
348
|
|
|
150
|
-
|
|
349
|
+
function CanvasContext({ canvas, children }) {
|
|
151
350
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
152
351
|
value: { canvas }
|
|
153
352
|
}, children);
|
|
154
|
-
}
|
|
353
|
+
}
|
|
155
354
|
|
|
156
355
|
function useVaultSelector(selector, deps = []) {
|
|
157
356
|
const vault = useVault();
|
|
158
|
-
const [selectedState, setSelectedState] = React.useState(() => selector(vault.getState(), vault));
|
|
159
|
-
React.useEffect(() => {
|
|
160
|
-
return vault.subscribe((s) => selector(s, vault),
|
|
357
|
+
const [selectedState, setSelectedState] = React$1.useState(() => selector(vault.getState(), vault));
|
|
358
|
+
React$1.useEffect(() => {
|
|
359
|
+
return vault.subscribe((s) => selector(s, vault), (s) => {
|
|
360
|
+
setSelectedState(s);
|
|
361
|
+
}, false);
|
|
161
362
|
}, deps);
|
|
162
363
|
return selectedState;
|
|
163
364
|
}
|
|
164
365
|
|
|
165
366
|
const VisibleCanvasReactContext = React__default["default"].createContext([]);
|
|
166
367
|
function useVisibleCanvases() {
|
|
167
|
-
const ids = React.useContext(VisibleCanvasReactContext);
|
|
368
|
+
const ids = React$1.useContext(VisibleCanvasReactContext);
|
|
168
369
|
return useVaultSelector((state) => {
|
|
169
370
|
return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);
|
|
170
371
|
}, [ids]);
|
|
@@ -172,7 +373,7 @@ function useVisibleCanvases() {
|
|
|
172
373
|
|
|
173
374
|
const noop = () => {
|
|
174
375
|
};
|
|
175
|
-
const SimpleViewerReactContext = React.createContext({
|
|
376
|
+
const SimpleViewerReactContext = React$1.createContext({
|
|
176
377
|
setCurrentCanvasId: noop,
|
|
177
378
|
setCurrentCanvasIndex: noop,
|
|
178
379
|
nextCanvas: noop,
|
|
@@ -181,24 +382,24 @@ const SimpleViewerReactContext = React.createContext({
|
|
|
181
382
|
totalCanvases: 0,
|
|
182
383
|
pagingView: true
|
|
183
384
|
});
|
|
184
|
-
|
|
385
|
+
function SimpleViewerProvider(props) {
|
|
185
386
|
const manifest = useExternalManifest(props.manifest);
|
|
186
|
-
const [currentCanvasId, setCurrentCanvasId] = React.useState("");
|
|
187
|
-
const [visible, setVisible] = React.useState([]);
|
|
387
|
+
const [currentCanvasId, setCurrentCanvasId] = React$1.useState("");
|
|
388
|
+
const [visible, setVisible] = React$1.useState([]);
|
|
188
389
|
const pagingView = (typeof props.pagingEnabled === "undefined" || props.pagingEnabled) && manifest.manifest && manifest.manifest.behavior && manifest.manifest.behavior.includes("paged");
|
|
189
|
-
React.useEffect(() => {
|
|
390
|
+
React$1.useEffect(() => {
|
|
190
391
|
var _a, _b;
|
|
191
392
|
if (manifest.manifest) {
|
|
192
393
|
setCurrentCanvasId((_a = manifest.manifest.items[0]) == null ? void 0 : _a.id);
|
|
193
394
|
setVisible([(_b = manifest.manifest.items[0]) == null ? void 0 : _b.id]);
|
|
194
395
|
}
|
|
195
396
|
}, [manifest.manifest, props.manifest]);
|
|
196
|
-
const canvasList = React.useMemo(() => {
|
|
397
|
+
const canvasList = React$1.useMemo(() => {
|
|
197
398
|
var _a;
|
|
198
399
|
return ((_a = manifest.manifest) == null ? void 0 : _a.items.map((c) => c.id)) || [];
|
|
199
400
|
}, [manifest.manifest, props.manifest]);
|
|
200
|
-
const currentCanvasIndex = React.useMemo(() => canvasList.indexOf(currentCanvasId), [canvasList, currentCanvasId]);
|
|
201
|
-
const nextCanvas = React.useCallback(() => {
|
|
401
|
+
const currentCanvasIndex = React$1.useMemo(() => canvasList.indexOf(currentCanvasId), [canvasList, currentCanvasId]);
|
|
402
|
+
const nextCanvas = React$1.useCallback(() => {
|
|
202
403
|
if (canvasList.length && currentCanvasId) {
|
|
203
404
|
if (currentCanvasIndex === -1) {
|
|
204
405
|
return;
|
|
@@ -214,7 +415,7 @@ const SimpleViewerProvider = (props) => {
|
|
|
214
415
|
}
|
|
215
416
|
}
|
|
216
417
|
}, [pagingView, canvasList, currentCanvasId, currentCanvasIndex]);
|
|
217
|
-
const previousCanvas = React.useCallback(() => {
|
|
418
|
+
const previousCanvas = React$1.useCallback(() => {
|
|
218
419
|
if (canvasList.length && currentCanvasId) {
|
|
219
420
|
if (currentCanvasIndex === 0 || currentCanvasIndex === -1) {
|
|
220
421
|
return;
|
|
@@ -227,7 +428,7 @@ const SimpleViewerProvider = (props) => {
|
|
|
227
428
|
}
|
|
228
429
|
}
|
|
229
430
|
}, [pagingView, canvasList, currentCanvasId, currentCanvasIndex]);
|
|
230
|
-
const setCurrentCanvasIndex = React.useCallback((idx) => {
|
|
431
|
+
const setCurrentCanvasIndex = React$1.useCallback((idx) => {
|
|
231
432
|
const realIdx = pagingView && idx % 2 === 1 ? idx - 1 : idx;
|
|
232
433
|
const newId = canvasList[realIdx];
|
|
233
434
|
const newNextId = pagingView && realIdx !== 0 ? canvasList[realIdx + 1] : null;
|
|
@@ -247,13 +448,13 @@ const SimpleViewerProvider = (props) => {
|
|
|
247
448
|
});
|
|
248
449
|
}
|
|
249
450
|
}, [pagingView, canvasList]);
|
|
250
|
-
const internalSetCurrentCanvasId = React.useCallback((nextId) => {
|
|
451
|
+
const internalSetCurrentCanvasId = React$1.useCallback((nextId) => {
|
|
251
452
|
const idx = canvasList.indexOf(nextId);
|
|
252
453
|
if (idx !== -1) {
|
|
253
454
|
setCurrentCanvasIndex(idx);
|
|
254
455
|
}
|
|
255
456
|
}, [canvasList, setCurrentCanvasIndex]);
|
|
256
|
-
const ctx = React.useMemo(() => ({
|
|
457
|
+
const ctx = React$1.useMemo(() => ({
|
|
257
458
|
setCurrentCanvasId: internalSetCurrentCanvasId,
|
|
258
459
|
nextCanvas,
|
|
259
460
|
previousCanvas,
|
|
@@ -278,20 +479,20 @@ const SimpleViewerProvider = (props) => {
|
|
|
278
479
|
}, /* @__PURE__ */ React__default["default"].createElement(CanvasContext, {
|
|
279
480
|
canvas: currentCanvasId
|
|
280
481
|
}, props.children))));
|
|
281
|
-
}
|
|
482
|
+
}
|
|
282
483
|
function useSimpleViewer() {
|
|
283
|
-
return React.useContext(SimpleViewerReactContext);
|
|
484
|
+
return React$1.useContext(SimpleViewerReactContext);
|
|
284
485
|
}
|
|
285
486
|
|
|
286
487
|
function useContextBridge() {
|
|
287
488
|
return {
|
|
288
|
-
VaultContext: React.useContext(ReactVaultContext),
|
|
289
|
-
ResourceContext: React.useContext(ResourceReactContext),
|
|
290
|
-
SimpleViewerReactContext: React.useContext(SimpleViewerReactContext),
|
|
291
|
-
VisibleCanvasReactContext: React.useContext(VisibleCanvasReactContext)
|
|
489
|
+
VaultContext: React$1.useContext(ReactVaultContext),
|
|
490
|
+
ResourceContext: React$1.useContext(ResourceReactContext),
|
|
491
|
+
SimpleViewerReactContext: React$1.useContext(SimpleViewerReactContext),
|
|
492
|
+
VisibleCanvasReactContext: React$1.useContext(VisibleCanvasReactContext)
|
|
292
493
|
};
|
|
293
494
|
}
|
|
294
|
-
|
|
495
|
+
function ContextBridge(props) {
|
|
295
496
|
return /* @__PURE__ */ React__default["default"].createElement(VaultProvider, {
|
|
296
497
|
vault: props.bridge.VaultContext.vault || void 0,
|
|
297
498
|
resources: props.bridge.ResourceContext
|
|
@@ -300,7 +501,7 @@ const ContextBridge = (props) => {
|
|
|
300
501
|
}, /* @__PURE__ */ React__default["default"].createElement(SimpleViewerReactContext.Provider, {
|
|
301
502
|
value: props.bridge.SimpleViewerReactContext
|
|
302
503
|
}, props.children)));
|
|
303
|
-
}
|
|
504
|
+
}
|
|
304
505
|
|
|
305
506
|
const IMPORT_ENTITIES = "@iiif/IMPORT_ENTITIES";
|
|
306
507
|
const MODIFY_ENTITY_FIELD = "@iiif/MODIFY_ENTITY_FIELD";
|
|
@@ -344,7 +545,7 @@ typesafeActions.createAction(BATCH_IMPORT)();
|
|
|
344
545
|
function useDispatch() {
|
|
345
546
|
const vault = useVault();
|
|
346
547
|
const store = vault.getStore();
|
|
347
|
-
return React.useMemo(() => {
|
|
548
|
+
return React$1.useMemo(() => {
|
|
348
549
|
return (action) => store.dispatch(action);
|
|
349
550
|
}, [store]);
|
|
350
551
|
}
|
|
@@ -354,12 +555,12 @@ function isVaultActivated(obj) {
|
|
|
354
555
|
}
|
|
355
556
|
function useVirtualAnnotationPage() {
|
|
356
557
|
const vault = useVault();
|
|
357
|
-
const sources = React.useRef([]);
|
|
558
|
+
const sources = React$1.useRef([]);
|
|
358
559
|
const dispatch = useDispatch();
|
|
359
|
-
const virtualId = React.useMemo(() => {
|
|
560
|
+
const virtualId = React$1.useMemo(() => {
|
|
360
561
|
return `vault://annotation-page/${new Date().getTime()}/${Math.round(Math.random() * 1e9).toString(16)}`;
|
|
361
562
|
}, []);
|
|
362
|
-
React.useLayoutEffect(() => {
|
|
563
|
+
React$1.useLayoutEffect(() => {
|
|
363
564
|
const page = {
|
|
364
565
|
id: virtualId,
|
|
365
566
|
type: "AnnotationPage",
|
|
@@ -388,7 +589,7 @@ function useVirtualAnnotationPage() {
|
|
|
388
589
|
}));
|
|
389
590
|
}, [virtualId]);
|
|
390
591
|
const fullPage = useVaultSelector((state) => virtualId ? state.iiif.entities.AnnotationPage[virtualId] : null, [virtualId]);
|
|
391
|
-
const addAnnotation = React.useCallback((id, atIndex) => {
|
|
592
|
+
const addAnnotation = React$1.useCallback((id, atIndex) => {
|
|
392
593
|
if (virtualId) {
|
|
393
594
|
if (isVaultActivated(id)) {
|
|
394
595
|
const display = id;
|
|
@@ -418,7 +619,7 @@ function useVirtualAnnotationPage() {
|
|
|
418
619
|
}
|
|
419
620
|
}
|
|
420
621
|
}, [virtualId]);
|
|
421
|
-
const removeAnnotation = React.useCallback((id) => {
|
|
622
|
+
const removeAnnotation = React$1.useCallback((id) => {
|
|
422
623
|
if (virtualId) {
|
|
423
624
|
if (isVaultActivated(id)) {
|
|
424
625
|
id = typeof id.source === "string" ? id.source : id.source.id;
|
|
@@ -451,9 +652,9 @@ function useVirtualAnnotationPage() {
|
|
|
451
652
|
];
|
|
452
653
|
}
|
|
453
654
|
|
|
454
|
-
const VirtualAnnotationPageContext = React.createContext(null);
|
|
655
|
+
const VirtualAnnotationPageContext = React$1.createContext(null);
|
|
455
656
|
function useVirtualAnnotationPageContext() {
|
|
456
|
-
const ctx = React.useContext(VirtualAnnotationPageContext);
|
|
657
|
+
const ctx = React$1.useContext(VirtualAnnotationPageContext);
|
|
457
658
|
return [
|
|
458
659
|
ctx.fullPage,
|
|
459
660
|
{
|
|
@@ -465,67 +666,170 @@ function useVirtualAnnotationPageContext() {
|
|
|
465
666
|
function VirtualAnnotationProvider({ children }) {
|
|
466
667
|
const [fullPage, { addAnnotation, removeAnnotation }] = useVirtualAnnotationPage();
|
|
467
668
|
return /* @__PURE__ */ React__default["default"].createElement(VirtualAnnotationPageContext.Provider, {
|
|
468
|
-
value: React.useMemo(() => ({ fullPage, addAnnotation, removeAnnotation }), [fullPage])
|
|
669
|
+
value: React$1.useMemo(() => ({ fullPage, addAnnotation, removeAnnotation }), [fullPage])
|
|
469
670
|
}, children);
|
|
470
671
|
}
|
|
471
672
|
|
|
472
|
-
var __defProp$
|
|
473
|
-
var
|
|
474
|
-
var
|
|
475
|
-
var
|
|
476
|
-
var
|
|
477
|
-
var
|
|
673
|
+
var __defProp$9 = Object.defineProperty;
|
|
674
|
+
var __defProps$7 = Object.defineProperties;
|
|
675
|
+
var __getOwnPropDescs$7 = Object.getOwnPropertyDescriptors;
|
|
676
|
+
var __getOwnPropSymbols$9 = Object.getOwnPropertySymbols;
|
|
677
|
+
var __hasOwnProp$9 = Object.prototype.hasOwnProperty;
|
|
678
|
+
var __propIsEnum$9 = Object.prototype.propertyIsEnumerable;
|
|
679
|
+
var __defNormalProp$9 = (obj, key, value) => key in obj ? __defProp$9(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
680
|
+
var __spreadValues$9 = (a, b) => {
|
|
478
681
|
for (var prop in b || (b = {}))
|
|
479
|
-
if (__hasOwnProp$
|
|
480
|
-
__defNormalProp$
|
|
481
|
-
if (__getOwnPropSymbols$
|
|
482
|
-
for (var prop of __getOwnPropSymbols$
|
|
483
|
-
if (__propIsEnum$
|
|
484
|
-
__defNormalProp$
|
|
682
|
+
if (__hasOwnProp$9.call(b, prop))
|
|
683
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
684
|
+
if (__getOwnPropSymbols$9)
|
|
685
|
+
for (var prop of __getOwnPropSymbols$9(b)) {
|
|
686
|
+
if (__propIsEnum$9.call(b, prop))
|
|
687
|
+
__defNormalProp$9(a, prop, b[prop]);
|
|
485
688
|
}
|
|
486
689
|
return a;
|
|
487
690
|
};
|
|
691
|
+
var __spreadProps$7 = (a, b) => __defProps$7(a, __getOwnPropDescs$7(b));
|
|
692
|
+
function DefaultCanvasFallback({ width, style, height }) {
|
|
693
|
+
return /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
694
|
+
style: __spreadProps$7(__spreadValues$9({ width, height, minHeight: 500 }, style || {}), { background: "#f9f9f9" })
|
|
695
|
+
}, "Unknown error");
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
var createRoot;
|
|
699
|
+
|
|
700
|
+
var m = require$$0__default["default"];
|
|
701
|
+
{
|
|
702
|
+
var i = m.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
703
|
+
createRoot = function(c, o) {
|
|
704
|
+
i.usingClientEntryPoint = true;
|
|
705
|
+
try {
|
|
706
|
+
return m.createRoot(c, o);
|
|
707
|
+
} finally {
|
|
708
|
+
i.usingClientEntryPoint = false;
|
|
709
|
+
}
|
|
710
|
+
};
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
const ViewerPresetContext = React$1.createContext(null);
|
|
714
|
+
function useViewerPreset() {
|
|
715
|
+
return React$1.useContext(ViewerPresetContext);
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const PortalContext = React__default["default"].createContext(null);
|
|
719
|
+
const OverlayPortalContext = React__default["default"].createContext(null);
|
|
720
|
+
function CanvasPortal({ children, overlay }) {
|
|
721
|
+
const htmlElement = React$1.useContext(overlay ? OverlayPortalContext : PortalContext);
|
|
722
|
+
const root = React$1.useMemo(() => htmlElement ? createRoot(htmlElement) : null, [htmlElement]);
|
|
723
|
+
const preset = useViewerPreset();
|
|
724
|
+
React$1.useLayoutEffect(() => {
|
|
725
|
+
return () => root == null ? void 0 : root.unmount();
|
|
726
|
+
}, [root]);
|
|
727
|
+
React$1.useLayoutEffect(() => {
|
|
728
|
+
if (root) {
|
|
729
|
+
root.render(/* @__PURE__ */ React__default["default"].createElement(ViewerPresetContext.Provider, {
|
|
730
|
+
value: preset
|
|
731
|
+
}, children));
|
|
732
|
+
}
|
|
733
|
+
}, [children, preset]);
|
|
734
|
+
return null;
|
|
735
|
+
}
|
|
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));
|
|
488
756
|
var __objRest = (source, exclude) => {
|
|
489
757
|
var target = {};
|
|
490
758
|
for (var prop in source)
|
|
491
|
-
if (__hasOwnProp$
|
|
759
|
+
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
492
760
|
target[prop] = source[prop];
|
|
493
|
-
if (source != null && __getOwnPropSymbols$
|
|
494
|
-
for (var prop of __getOwnPropSymbols$
|
|
495
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
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))
|
|
496
764
|
target[prop] = source[prop];
|
|
497
765
|
}
|
|
498
766
|
return target;
|
|
499
767
|
};
|
|
768
|
+
const AtlasAuto = atlas.AtlasAuto;
|
|
500
769
|
function Viewer(_a) {
|
|
501
770
|
var _b = _a, {
|
|
502
|
-
children
|
|
771
|
+
children,
|
|
772
|
+
errorFallback,
|
|
773
|
+
outerContainerProps = {}
|
|
503
774
|
} = _b, props = __objRest(_b, [
|
|
504
|
-
"children"
|
|
775
|
+
"children",
|
|
776
|
+
"errorFallback",
|
|
777
|
+
"outerContainerProps"
|
|
505
778
|
]);
|
|
779
|
+
const portal = React$1.useRef(null);
|
|
780
|
+
const [portalElement, setPortalElement] = React$1.useState();
|
|
781
|
+
const [viewerPreset, setViewerPreset] = React$1.useState();
|
|
782
|
+
const overlayPortal = React$1.useRef(null);
|
|
783
|
+
const [overlayPortalElement, setOverlayPortalElement] = React$1.useState();
|
|
506
784
|
const bridge = useContextBridge();
|
|
507
|
-
|
|
785
|
+
const ErrorFallback = errorFallback || DefaultCanvasFallback;
|
|
786
|
+
React$1.useLayoutEffect(() => {
|
|
787
|
+
setPortalElement(portal.current);
|
|
788
|
+
setOverlayPortalElement(overlayPortal.current);
|
|
789
|
+
}, []);
|
|
790
|
+
return /* @__PURE__ */ React__default["default"].createElement(reactErrorBoundary_umd.exports.ErrorBoundary, {
|
|
791
|
+
fallbackRender: () => /* @__PURE__ */ React__default["default"].createElement(ErrorFallback, __spreadValues$8({}, props))
|
|
792
|
+
}, /* @__PURE__ */ React__default["default"].createElement("div", __spreadValues$8({
|
|
793
|
+
style: { position: "relative" }
|
|
794
|
+
}, outerContainerProps), /* @__PURE__ */ React__default["default"].createElement(AtlasAuto, __spreadProps$6(__spreadValues$8({}, props), {
|
|
795
|
+
onCreated: (preset) => {
|
|
796
|
+
setViewerPreset(preset);
|
|
797
|
+
if (props.onCreated) {
|
|
798
|
+
props.onCreated(preset);
|
|
799
|
+
}
|
|
800
|
+
}
|
|
801
|
+
}), /* @__PURE__ */ React__default["default"].createElement(ViewerPresetContext.Provider, {
|
|
802
|
+
value: viewerPreset
|
|
803
|
+
}, /* @__PURE__ */ React__default["default"].createElement(PortalContext.Provider, {
|
|
804
|
+
value: portalElement
|
|
805
|
+
}, /* @__PURE__ */ React__default["default"].createElement(OverlayPortalContext.Provider, {
|
|
806
|
+
value: overlayPortalElement
|
|
807
|
+
}, /* @__PURE__ */ React__default["default"].createElement(ContextBridge, {
|
|
508
808
|
bridge
|
|
509
|
-
}, /* @__PURE__ */ React__default["default"].createElement(VirtualAnnotationProvider, null, children)))
|
|
809
|
+
}, /* @__PURE__ */ React__default["default"].createElement(VirtualAnnotationProvider, null, children)))))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
810
|
+
ref: overlayPortal
|
|
811
|
+
})), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
812
|
+
ref: portal
|
|
813
|
+
}));
|
|
510
814
|
}
|
|
511
815
|
|
|
512
816
|
function useResourceEvents(resource, scope) {
|
|
513
817
|
const vault = useVault();
|
|
514
|
-
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
818
|
+
const helper = React$1.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
515
819
|
const hooks = useVaultSelector(() => {
|
|
516
820
|
if (resource && resource.id) {
|
|
517
821
|
return vault.getResourceMeta(resource.id, "eventManager");
|
|
518
822
|
}
|
|
519
823
|
return null;
|
|
520
824
|
}, [resource]);
|
|
521
|
-
return React.useMemo(() => {
|
|
825
|
+
return React$1.useMemo(() => {
|
|
522
826
|
return resource ? helper.getListenersAsProps(resource, scope) : {};
|
|
523
827
|
}, [hooks, resource, vault, scope]);
|
|
524
828
|
}
|
|
525
829
|
|
|
526
830
|
function useStyles(resource, scope) {
|
|
527
831
|
const vault = useVault();
|
|
528
|
-
const helper = React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
832
|
+
const helper = React$1.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
529
833
|
return useVaultSelector(() => {
|
|
530
834
|
if (!resource) {
|
|
531
835
|
return null;
|
|
@@ -624,25 +928,25 @@ function parseSelector(source) {
|
|
|
624
928
|
};
|
|
625
929
|
}
|
|
626
930
|
|
|
627
|
-
var __defProp$
|
|
628
|
-
var __defProps$
|
|
629
|
-
var __getOwnPropDescs$
|
|
630
|
-
var __getOwnPropSymbols$
|
|
631
|
-
var __hasOwnProp$
|
|
632
|
-
var __propIsEnum$
|
|
633
|
-
var __defNormalProp$
|
|
634
|
-
var __spreadValues$
|
|
931
|
+
var __defProp$7 = Object.defineProperty;
|
|
932
|
+
var __defProps$5 = Object.defineProperties;
|
|
933
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
934
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
935
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
936
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
937
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
938
|
+
var __spreadValues$7 = (a, b) => {
|
|
635
939
|
for (var prop in b || (b = {}))
|
|
636
|
-
if (__hasOwnProp$
|
|
637
|
-
__defNormalProp$
|
|
638
|
-
if (__getOwnPropSymbols$
|
|
639
|
-
for (var prop of __getOwnPropSymbols$
|
|
640
|
-
if (__propIsEnum$
|
|
641
|
-
__defNormalProp$
|
|
940
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
941
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
942
|
+
if (__getOwnPropSymbols$7)
|
|
943
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
944
|
+
if (__propIsEnum$7.call(b, prop))
|
|
945
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
642
946
|
}
|
|
643
947
|
return a;
|
|
644
948
|
};
|
|
645
|
-
var __spreadProps$
|
|
949
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
646
950
|
function expandTarget(target, options = {}) {
|
|
647
951
|
if (Array.isArray(target)) {
|
|
648
952
|
return expandTarget(target[0]);
|
|
@@ -699,7 +1003,7 @@ function expandTarget(target, options = {}) {
|
|
|
699
1003
|
if (!fragment) {
|
|
700
1004
|
return {
|
|
701
1005
|
type: "SpecificResource",
|
|
702
|
-
source: __spreadProps$
|
|
1006
|
+
source: __spreadProps$5(__spreadValues$7({}, target), {
|
|
703
1007
|
id
|
|
704
1008
|
}),
|
|
705
1009
|
selector: null,
|
|
@@ -708,7 +1012,7 @@ function expandTarget(target, options = {}) {
|
|
|
708
1012
|
}
|
|
709
1013
|
return expandTarget({
|
|
710
1014
|
type: "SpecificResource",
|
|
711
|
-
source: __spreadProps$
|
|
1015
|
+
source: __spreadProps$5(__spreadValues$7({}, target), {
|
|
712
1016
|
id
|
|
713
1017
|
}),
|
|
714
1018
|
selector: {
|
|
@@ -725,25 +1029,25 @@ function expandTarget(target, options = {}) {
|
|
|
725
1029
|
};
|
|
726
1030
|
}
|
|
727
1031
|
|
|
728
|
-
var __defProp$
|
|
729
|
-
var __defProps$
|
|
730
|
-
var __getOwnPropDescs$
|
|
731
|
-
var __getOwnPropSymbols$
|
|
732
|
-
var __hasOwnProp$
|
|
733
|
-
var __propIsEnum$
|
|
734
|
-
var __defNormalProp$
|
|
735
|
-
var __spreadValues$
|
|
1032
|
+
var __defProp$6 = Object.defineProperty;
|
|
1033
|
+
var __defProps$4 = Object.defineProperties;
|
|
1034
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
1035
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1036
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1037
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1038
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1039
|
+
var __spreadValues$6 = (a, b) => {
|
|
736
1040
|
for (var prop in b || (b = {}))
|
|
737
|
-
if (__hasOwnProp$
|
|
738
|
-
__defNormalProp$
|
|
739
|
-
if (__getOwnPropSymbols$
|
|
740
|
-
for (var prop of __getOwnPropSymbols$
|
|
741
|
-
if (__propIsEnum$
|
|
742
|
-
__defNormalProp$
|
|
1041
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
1042
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1043
|
+
if (__getOwnPropSymbols$6)
|
|
1044
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1045
|
+
if (__propIsEnum$6.call(b, prop))
|
|
1046
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
743
1047
|
}
|
|
744
1048
|
return a;
|
|
745
1049
|
};
|
|
746
|
-
var __spreadProps$
|
|
1050
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
747
1051
|
function useAnnotation(options = {}, deps = []) {
|
|
748
1052
|
const { id, selector } = options;
|
|
749
1053
|
const ctx = useResourceContext();
|
|
@@ -751,11 +1055,11 @@ function useAnnotation(options = {}, deps = []) {
|
|
|
751
1055
|
const annotationId = id ? id : ctx.annotation;
|
|
752
1056
|
const annotation = useVaultSelector((s) => annotationId ? s.iiif.entities.Annotation[annotationId] : void 0, [annotationId]);
|
|
753
1057
|
const body = useVaultSelector((s) => annotation && annotation.body ? annotation.body.map((singleBody) => singleBody ? s.iiif.entities[singleBody.type][singleBody.id] : null).filter(Boolean) : [], [annotation]);
|
|
754
|
-
return React.useMemo(() => {
|
|
1058
|
+
return React$1.useMemo(() => {
|
|
755
1059
|
if (!annotation) {
|
|
756
1060
|
return void 0;
|
|
757
1061
|
}
|
|
758
|
-
const newAnnotation = __spreadProps$
|
|
1062
|
+
const newAnnotation = __spreadProps$4(__spreadValues$6({}, annotation), {
|
|
759
1063
|
body,
|
|
760
1064
|
target: expandTarget(annotation.target, { typeMap: vault.getState().iiif.mapping })
|
|
761
1065
|
});
|
|
@@ -771,7 +1075,7 @@ function useCanvas(options = {}, deps = []) {
|
|
|
771
1075
|
const ctx = useResourceContext();
|
|
772
1076
|
const canvasId = id ? id : ctx.canvas;
|
|
773
1077
|
const canvas = useVaultSelector((s) => canvasId ? s.iiif.entities.Canvas[canvasId] : void 0, [canvasId]);
|
|
774
|
-
return React.useMemo(() => {
|
|
1078
|
+
return React$1.useMemo(() => {
|
|
775
1079
|
if (!canvas) {
|
|
776
1080
|
return void 0;
|
|
777
1081
|
}
|
|
@@ -782,19 +1086,19 @@ function useCanvas(options = {}, deps = []) {
|
|
|
782
1086
|
}, [canvas, selector, ...deps]);
|
|
783
1087
|
}
|
|
784
1088
|
|
|
785
|
-
var __defProp$
|
|
786
|
-
var __getOwnPropSymbols$
|
|
787
|
-
var __hasOwnProp$
|
|
788
|
-
var __propIsEnum$
|
|
789
|
-
var __defNormalProp$
|
|
790
|
-
var __spreadValues$
|
|
1089
|
+
var __defProp$5 = Object.defineProperty;
|
|
1090
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1091
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1092
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1093
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1094
|
+
var __spreadValues$5 = (a, b) => {
|
|
791
1095
|
for (var prop in b || (b = {}))
|
|
792
|
-
if (__hasOwnProp$
|
|
793
|
-
__defNormalProp$
|
|
794
|
-
if (__getOwnPropSymbols$
|
|
795
|
-
for (var prop of __getOwnPropSymbols$
|
|
796
|
-
if (__propIsEnum$
|
|
797
|
-
__defNormalProp$
|
|
1096
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
1097
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
1098
|
+
if (__getOwnPropSymbols$5)
|
|
1099
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1100
|
+
if (__propIsEnum$5.call(b, prop))
|
|
1101
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
798
1102
|
}
|
|
799
1103
|
return a;
|
|
800
1104
|
};
|
|
@@ -809,14 +1113,14 @@ const RenderAnnotation = ({
|
|
|
809
1113
|
const html = useStyles(annotation, "html");
|
|
810
1114
|
const events = useResourceEvents(annotation, ["atlas"]);
|
|
811
1115
|
const canvas = useCanvas();
|
|
812
|
-
const allStyles = React.useMemo(() => {
|
|
1116
|
+
const allStyles = React$1.useMemo(() => {
|
|
813
1117
|
return atlas.mergeStyles(defaultStyle, style);
|
|
814
1118
|
}, [defaultStyle, style]);
|
|
815
1119
|
const isValid = canvas && annotation && annotation.target && annotation.target.selector && annotation.target.selector.type === "BoxSelector" && annotation.target.source && annotation.target.source.id === canvas.id;
|
|
816
1120
|
if (!isValid) {
|
|
817
1121
|
return null;
|
|
818
1122
|
}
|
|
819
|
-
return /* @__PURE__ */ React__default["default"].createElement(atlas.RegionHighlight, __spreadValues$
|
|
1123
|
+
return /* @__PURE__ */ React__default["default"].createElement(atlas.RegionHighlight, __spreadValues$5({
|
|
820
1124
|
id: annotation.id,
|
|
821
1125
|
isEditing: true,
|
|
822
1126
|
region: annotation.target.selector.spatial,
|
|
@@ -837,7 +1141,7 @@ const RenderAnnotationPage = ({
|
|
|
837
1141
|
const style = useStyles(page, "atlas");
|
|
838
1142
|
const html = useStyles(page, "html");
|
|
839
1143
|
useVaultSelector((state) => page.id ? state.iiif.entities.AnnotationPage[page.id] : null, []);
|
|
840
|
-
return /* @__PURE__ */ React__default["default"].createElement(React.Fragment, null, (_a = page.items) == null ? void 0 : _a.map((annotation) => {
|
|
1144
|
+
return /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, null, (_a = page.items) == null ? void 0 : _a.map((annotation) => {
|
|
841
1145
|
return /* @__PURE__ */ React__default["default"].createElement(RenderAnnotation, {
|
|
842
1146
|
key: annotation.id,
|
|
843
1147
|
id: annotation.id,
|
|
@@ -855,12 +1159,13 @@ function RenderImage({
|
|
|
855
1159
|
isStatic,
|
|
856
1160
|
x = 0,
|
|
857
1161
|
y = 0,
|
|
858
|
-
annotations
|
|
1162
|
+
annotations,
|
|
1163
|
+
children
|
|
859
1164
|
}) {
|
|
860
1165
|
var _a, _b, _c, _d;
|
|
861
|
-
return /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
1166
|
+
return /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, {
|
|
862
1167
|
key: id
|
|
863
|
-
}, !image.service ? /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
1168
|
+
}, !image.service ? /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, {
|
|
864
1169
|
key: "no-service"
|
|
865
1170
|
}, /* @__PURE__ */ React__default["default"].createElement("world-image", {
|
|
866
1171
|
uri: image.id,
|
|
@@ -869,7 +1174,7 @@ function RenderImage({
|
|
|
869
1174
|
width: image.width,
|
|
870
1175
|
height: image.height
|
|
871
1176
|
} : void 0
|
|
872
|
-
}), annotations) : /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
1177
|
+
}), annotations, children) : /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, {
|
|
873
1178
|
key: "service"
|
|
874
1179
|
}, /* @__PURE__ */ React__default["default"].createElement(TileSet, {
|
|
875
1180
|
viewport: isStatic,
|
|
@@ -884,7 +1189,7 @@ function RenderImage({
|
|
|
884
1189
|
y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
|
|
885
1190
|
width: (_c = image.target) == null ? void 0 : _c.spatial.width,
|
|
886
1191
|
height: (_d = image.target) == null ? void 0 : _d.spatial.height
|
|
887
|
-
}), annotations));
|
|
1192
|
+
}), annotations, children));
|
|
888
1193
|
}
|
|
889
1194
|
|
|
890
1195
|
function parseSpecificResource(resource) {
|
|
@@ -952,7 +1257,7 @@ function useManifest(options = {}, deps = []) {
|
|
|
952
1257
|
useVault();
|
|
953
1258
|
const manifestId = id ? id : ctx.manifest;
|
|
954
1259
|
const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
|
|
955
|
-
return React.useMemo(() => {
|
|
1260
|
+
return React$1.useMemo(() => {
|
|
956
1261
|
if (!manifest) {
|
|
957
1262
|
return void 0;
|
|
958
1263
|
}
|
|
@@ -1024,25 +1329,25 @@ function flattenAnnotationPageIds({
|
|
|
1024
1329
|
return foundIds;
|
|
1025
1330
|
}
|
|
1026
1331
|
|
|
1027
|
-
var __defProp$
|
|
1028
|
-
var __defProps$
|
|
1029
|
-
var __getOwnPropDescs$
|
|
1030
|
-
var __getOwnPropSymbols$
|
|
1031
|
-
var __hasOwnProp$
|
|
1032
|
-
var __propIsEnum$
|
|
1033
|
-
var __defNormalProp$
|
|
1034
|
-
var __spreadValues$
|
|
1332
|
+
var __defProp$4 = Object.defineProperty;
|
|
1333
|
+
var __defProps$3 = Object.defineProperties;
|
|
1334
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
1335
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1336
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1337
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1338
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1339
|
+
var __spreadValues$4 = (a, b) => {
|
|
1035
1340
|
for (var prop in b || (b = {}))
|
|
1036
|
-
if (__hasOwnProp$
|
|
1037
|
-
__defNormalProp$
|
|
1038
|
-
if (__getOwnPropSymbols$
|
|
1039
|
-
for (var prop of __getOwnPropSymbols$
|
|
1040
|
-
if (__propIsEnum$
|
|
1041
|
-
__defNormalProp$
|
|
1341
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1342
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1343
|
+
if (__getOwnPropSymbols$4)
|
|
1344
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1345
|
+
if (__propIsEnum$4.call(b, prop))
|
|
1346
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1042
1347
|
}
|
|
1043
1348
|
return a;
|
|
1044
1349
|
};
|
|
1045
|
-
var __spreadProps$
|
|
1350
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
1046
1351
|
function getMeta(state, resourceId) {
|
|
1047
1352
|
var _a;
|
|
1048
1353
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1056,7 +1361,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1056
1361
|
const manifest = useManifest();
|
|
1057
1362
|
const canvas = useCanvas();
|
|
1058
1363
|
const canvases = useVisibleCanvases();
|
|
1059
|
-
const availablePageIds = React.useMemo(() => {
|
|
1364
|
+
const availablePageIds = React$1.useMemo(() => {
|
|
1060
1365
|
return flattenAnnotationPageIds({
|
|
1061
1366
|
all: options.all,
|
|
1062
1367
|
manifest,
|
|
@@ -1065,7 +1370,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1065
1370
|
});
|
|
1066
1371
|
}, [options.all, canvas, canvases, manifest]);
|
|
1067
1372
|
const enabledPageIds = useEnabledAnnotationPageIds(resourceId, options.all ? void 0 : availablePageIds);
|
|
1068
|
-
const setPageDisabled = React.useCallback((deselectId) => {
|
|
1373
|
+
const setPageDisabled = React$1.useCallback((deselectId) => {
|
|
1069
1374
|
if (!resourceId) {
|
|
1070
1375
|
return;
|
|
1071
1376
|
}
|
|
@@ -1073,12 +1378,12 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1073
1378
|
if (existingResources && !existingResources[resourceId]) {
|
|
1074
1379
|
return existingResources;
|
|
1075
1380
|
}
|
|
1076
|
-
return __spreadProps$
|
|
1381
|
+
return __spreadProps$3(__spreadValues$4({}, existingResources || {}), {
|
|
1077
1382
|
[resourceId]: false
|
|
1078
1383
|
});
|
|
1079
1384
|
});
|
|
1080
1385
|
}, [resourceId, vault]);
|
|
1081
|
-
const setPageEnabled = React.useCallback((id, opt = {}) => {
|
|
1386
|
+
const setPageEnabled = React$1.useCallback((id, opt = {}) => {
|
|
1082
1387
|
if (!resourceId) {
|
|
1083
1388
|
return;
|
|
1084
1389
|
}
|
|
@@ -1100,7 +1405,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1100
1405
|
if (existingResources && existingResources[resourceId]) {
|
|
1101
1406
|
return existingResources;
|
|
1102
1407
|
}
|
|
1103
|
-
return __spreadProps$
|
|
1408
|
+
return __spreadProps$3(__spreadValues$4({}, existingResources || {}), {
|
|
1104
1409
|
[resourceId]: true
|
|
1105
1410
|
});
|
|
1106
1411
|
});
|
|
@@ -1119,51 +1424,52 @@ function useResources(ids, type) {
|
|
|
1119
1424
|
|
|
1120
1425
|
const ImageServiceLoaderContext = React__default["default"].createContext(new iiifImageApi.ImageServiceLoader());
|
|
1121
1426
|
function useImageServiceLoader() {
|
|
1122
|
-
return React.useContext(ImageServiceLoaderContext);
|
|
1427
|
+
return React$1.useContext(ImageServiceLoaderContext);
|
|
1123
1428
|
}
|
|
1124
1429
|
|
|
1125
|
-
var __defProp$
|
|
1126
|
-
var __defProps$
|
|
1127
|
-
var __getOwnPropDescs$
|
|
1128
|
-
var __getOwnPropSymbols$
|
|
1129
|
-
var __hasOwnProp$
|
|
1130
|
-
var __propIsEnum$
|
|
1131
|
-
var __defNormalProp$
|
|
1132
|
-
var __spreadValues$
|
|
1430
|
+
var __defProp$3 = Object.defineProperty;
|
|
1431
|
+
var __defProps$2 = Object.defineProperties;
|
|
1432
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1433
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1434
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1435
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1436
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1437
|
+
var __spreadValues$3 = (a, b) => {
|
|
1133
1438
|
for (var prop in b || (b = {}))
|
|
1134
|
-
if (__hasOwnProp$
|
|
1135
|
-
__defNormalProp$
|
|
1136
|
-
if (__getOwnPropSymbols$
|
|
1137
|
-
for (var prop of __getOwnPropSymbols$
|
|
1138
|
-
if (__propIsEnum$
|
|
1139
|
-
__defNormalProp$
|
|
1439
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1440
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1441
|
+
if (__getOwnPropSymbols$3)
|
|
1442
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1443
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1444
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1140
1445
|
}
|
|
1141
1446
|
return a;
|
|
1142
1447
|
};
|
|
1143
|
-
var __spreadProps$
|
|
1448
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1144
1449
|
function useLoadImageService() {
|
|
1145
1450
|
const loader = useImageServiceLoader();
|
|
1146
|
-
const [imageServiceStatus, setImageServiceStatus] = React.useState({});
|
|
1147
|
-
const didUnmount = React.useRef(false);
|
|
1148
|
-
React.useEffect(() => {
|
|
1451
|
+
const [imageServiceStatus, setImageServiceStatus] = React$1.useState({});
|
|
1452
|
+
const didUnmount = React$1.useRef(false);
|
|
1453
|
+
React$1.useEffect(() => {
|
|
1149
1454
|
return () => {
|
|
1150
1455
|
didUnmount.current = true;
|
|
1151
1456
|
};
|
|
1152
1457
|
}, []);
|
|
1153
|
-
const loadImageService = React.useCallback((imageService, { height, width }) => {
|
|
1458
|
+
const loadImageService = React$1.useCallback((imageService, { height, width }) => {
|
|
1154
1459
|
if (imageService) {
|
|
1155
1460
|
const imageServiceId = imageService.id || imageService["@id"];
|
|
1156
1461
|
const syncLoaded = loader.loadServiceSync({
|
|
1157
1462
|
id: imageServiceId,
|
|
1158
1463
|
width: imageService.width || width,
|
|
1159
|
-
height: imageService.height || height
|
|
1464
|
+
height: imageService.height || height,
|
|
1465
|
+
source: imageService
|
|
1160
1466
|
});
|
|
1161
1467
|
if (syncLoaded) {
|
|
1162
1468
|
imageService = syncLoaded;
|
|
1163
1469
|
} else if (!imageServiceStatus[imageServiceId]) {
|
|
1164
1470
|
if (!didUnmount.current) {
|
|
1165
1471
|
setImageServiceStatus((r) => {
|
|
1166
|
-
return __spreadProps$
|
|
1472
|
+
return __spreadProps$2(__spreadValues$3({}, r), {
|
|
1167
1473
|
[imageServiceId]: "loading"
|
|
1168
1474
|
});
|
|
1169
1475
|
});
|
|
@@ -1175,7 +1481,7 @@ function useLoadImageService() {
|
|
|
1175
1481
|
}).then(() => {
|
|
1176
1482
|
if (!didUnmount.current) {
|
|
1177
1483
|
setImageServiceStatus((r) => {
|
|
1178
|
-
return __spreadProps$
|
|
1484
|
+
return __spreadProps$2(__spreadValues$3({}, r), {
|
|
1179
1485
|
[imageServiceId]: "done"
|
|
1180
1486
|
});
|
|
1181
1487
|
});
|
|
@@ -1206,9 +1512,9 @@ function usePaintingAnnotations(options = {}) {
|
|
|
1206
1512
|
function usePaintables(options, deps = []) {
|
|
1207
1513
|
const vault = useVault();
|
|
1208
1514
|
const paintingAnnotations = usePaintingAnnotations();
|
|
1209
|
-
const [enabledChoices, setEnabledChoices] = React.useState((options == null ? void 0 : options.defaultChoices) || []);
|
|
1210
|
-
const paintables = React.useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
|
|
1211
|
-
const makeChoice = React.useCallback((id, { deselectOthers = true, deselect = false } = {}) => {
|
|
1515
|
+
const [enabledChoices, setEnabledChoices] = React$1.useState((options == null ? void 0 : options.defaultChoices) || []);
|
|
1516
|
+
const paintables = React$1.useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
|
|
1517
|
+
const makeChoice = React$1.useCallback((id, { deselectOthers = true, deselect = false } = {}) => {
|
|
1212
1518
|
if (paintables.choice) {
|
|
1213
1519
|
if (paintables.choice.type !== "single-choice") {
|
|
1214
1520
|
throw new Error("Complex choice not supported yet");
|
|
@@ -1324,37 +1630,126 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1324
1630
|
const supportedFormats = ["model/gltf-binary"];
|
|
1325
1631
|
function get3dStrategy(canvas, paintables) {
|
|
1326
1632
|
const first = paintables.items[0];
|
|
1327
|
-
|
|
1633
|
+
const resource = first.resource;
|
|
1634
|
+
if (!resource.format) {
|
|
1328
1635
|
return unsupportedStrategy("Unknown format");
|
|
1329
1636
|
}
|
|
1330
|
-
if (supportedFormats.indexOf(
|
|
1331
|
-
return unsupportedStrategy(`3D format: ${
|
|
1637
|
+
if (supportedFormats.indexOf(resource.format) === -1) {
|
|
1638
|
+
return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);
|
|
1332
1639
|
}
|
|
1333
1640
|
return {
|
|
1334
1641
|
type: "3d-model",
|
|
1335
|
-
model:
|
|
1642
|
+
model: resource
|
|
1336
1643
|
};
|
|
1337
1644
|
}
|
|
1338
1645
|
|
|
1339
|
-
|
|
1340
|
-
var
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1646
|
+
function getAudioStrategy(canvas, paintables) {
|
|
1647
|
+
var _a;
|
|
1648
|
+
if (!canvas.duration) {
|
|
1649
|
+
return unsupportedStrategy("No duration on canvas");
|
|
1650
|
+
}
|
|
1651
|
+
if (paintables.items.length > 1) {
|
|
1652
|
+
return unsupportedStrategy("Only one audio source supported");
|
|
1653
|
+
}
|
|
1654
|
+
const audioResource = (_a = paintables.items[0]) == null ? void 0 : _a.resource;
|
|
1655
|
+
if (!audioResource) {
|
|
1656
|
+
return unsupportedStrategy("Unknown audio");
|
|
1657
|
+
}
|
|
1658
|
+
if (!audioResource.format) {
|
|
1659
|
+
return unsupportedStrategy("Audio does not have format");
|
|
1660
|
+
}
|
|
1661
|
+
return {
|
|
1662
|
+
type: "media",
|
|
1663
|
+
media: {
|
|
1664
|
+
duration: canvas.duration,
|
|
1665
|
+
url: audioResource.id,
|
|
1666
|
+
type: "Sound",
|
|
1667
|
+
target: {
|
|
1668
|
+
type: "TemporalSelector",
|
|
1669
|
+
temporal: {
|
|
1670
|
+
startTime: 0,
|
|
1671
|
+
endTime: canvas.duration
|
|
1672
|
+
}
|
|
1673
|
+
},
|
|
1674
|
+
format: audioResource.format,
|
|
1675
|
+
selector: {
|
|
1676
|
+
type: "TemporalSelector",
|
|
1677
|
+
temporal: {
|
|
1678
|
+
startTime: 0,
|
|
1679
|
+
endTime: canvas.duration
|
|
1680
|
+
}
|
|
1681
|
+
}
|
|
1682
|
+
},
|
|
1683
|
+
annotations: {
|
|
1684
|
+
pages: []
|
|
1685
|
+
}
|
|
1686
|
+
};
|
|
1687
|
+
}
|
|
1688
|
+
|
|
1689
|
+
function getVideoStrategy(canvas, paintables) {
|
|
1690
|
+
var _a;
|
|
1691
|
+
const videoPaintables = paintables.items.filter((t) => t.type === "video");
|
|
1692
|
+
if (!canvas.duration) {
|
|
1693
|
+
return unsupportedStrategy("No duration on canvas");
|
|
1694
|
+
}
|
|
1695
|
+
if (videoPaintables.length > 1) {
|
|
1696
|
+
return unsupportedStrategy("Only one video source supported");
|
|
1697
|
+
}
|
|
1698
|
+
const audioResource = (_a = videoPaintables[0]) == null ? void 0 : _a.resource;
|
|
1699
|
+
if (!audioResource) {
|
|
1700
|
+
return unsupportedStrategy("Unknown video");
|
|
1701
|
+
}
|
|
1702
|
+
if (!audioResource.format) {
|
|
1703
|
+
return unsupportedStrategy("Video does not have format");
|
|
1704
|
+
}
|
|
1705
|
+
return {
|
|
1706
|
+
type: "media",
|
|
1707
|
+
media: {
|
|
1708
|
+
duration: canvas.duration,
|
|
1709
|
+
url: audioResource.id,
|
|
1710
|
+
type: "Video",
|
|
1711
|
+
items: [],
|
|
1712
|
+
target: {
|
|
1713
|
+
type: "TemporalSelector",
|
|
1714
|
+
temporal: {
|
|
1715
|
+
startTime: 0,
|
|
1716
|
+
endTime: canvas.duration
|
|
1717
|
+
}
|
|
1718
|
+
},
|
|
1719
|
+
format: audioResource.format,
|
|
1720
|
+
selector: {
|
|
1721
|
+
type: "TemporalSelector",
|
|
1722
|
+
temporal: {
|
|
1723
|
+
startTime: 0,
|
|
1724
|
+
endTime: canvas.duration
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
},
|
|
1728
|
+
annotations: {
|
|
1729
|
+
pages: []
|
|
1730
|
+
}
|
|
1731
|
+
};
|
|
1732
|
+
}
|
|
1733
|
+
|
|
1734
|
+
var __defProp$2 = Object.defineProperty;
|
|
1735
|
+
var __defProps$1 = Object.defineProperties;
|
|
1736
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1737
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1738
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1739
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1740
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1741
|
+
var __spreadValues$2 = (a, b) => {
|
|
1347
1742
|
for (var prop in b || (b = {}))
|
|
1348
|
-
if (__hasOwnProp$
|
|
1349
|
-
__defNormalProp$
|
|
1350
|
-
if (__getOwnPropSymbols$
|
|
1351
|
-
for (var prop of __getOwnPropSymbols$
|
|
1352
|
-
if (__propIsEnum$
|
|
1353
|
-
__defNormalProp$
|
|
1743
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
1744
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1745
|
+
if (__getOwnPropSymbols$2)
|
|
1746
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1747
|
+
if (__propIsEnum$2.call(b, prop))
|
|
1748
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1354
1749
|
}
|
|
1355
1750
|
return a;
|
|
1356
1751
|
};
|
|
1357
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1752
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1358
1753
|
function useRenderingStrategy(options) {
|
|
1359
1754
|
const manifest = useManifest();
|
|
1360
1755
|
const canvas = useCanvas();
|
|
@@ -1366,15 +1761,19 @@ function useRenderingStrategy(options) {
|
|
|
1366
1761
|
const enabledPages = useResources(enabledPageIds, "AnnotationPage");
|
|
1367
1762
|
const supports = (options == null ? void 0 : options.strategies) || ["images", "media", "complex-timeline"];
|
|
1368
1763
|
const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
|
|
1369
|
-
const strategy = React.useMemo(() => {
|
|
1764
|
+
const strategy = React$1.useMemo(() => {
|
|
1370
1765
|
if (!canvas || paintables.types.length === 0) {
|
|
1371
1766
|
return unknownResponse;
|
|
1372
1767
|
}
|
|
1373
1768
|
if (paintables.types.length !== 1) {
|
|
1374
|
-
if (
|
|
1375
|
-
|
|
1769
|
+
if (paintables.types.length === 2 && paintables.types.indexOf("text") !== -1) {
|
|
1770
|
+
paintables.types = paintables.types.filter((t) => t !== "text");
|
|
1771
|
+
} else {
|
|
1772
|
+
if (supports.indexOf("complex-timeline") === -1) {
|
|
1773
|
+
return unsupportedStrategy("Complex timeline not supported");
|
|
1774
|
+
}
|
|
1775
|
+
return unsupportedStrategy("ComplexTimelineStrategy not yet supported");
|
|
1376
1776
|
}
|
|
1377
|
-
return unsupportedStrategy("ComplexTimelineStrategy not yet supported");
|
|
1378
1777
|
}
|
|
1379
1778
|
const mainType = paintables.types[0];
|
|
1380
1779
|
if (mainType === "image") {
|
|
@@ -1383,32 +1782,32 @@ function useRenderingStrategy(options) {
|
|
|
1383
1782
|
}
|
|
1384
1783
|
return getImageStrategy(canvas, paintables, loadImageService);
|
|
1385
1784
|
}
|
|
1386
|
-
if (mainType === "Model") {
|
|
1785
|
+
if (mainType === "Model" || mainType === "model") {
|
|
1387
1786
|
if (supports.indexOf("3d-model") === -1) {
|
|
1388
1787
|
return unsupportedStrategy("3D not supported");
|
|
1389
1788
|
}
|
|
1390
1789
|
return get3dStrategy(canvas, paintables);
|
|
1391
1790
|
}
|
|
1392
|
-
if (mainType === "audio") {
|
|
1791
|
+
if (mainType === "sound" || mainType === "audio") {
|
|
1393
1792
|
if (supports.indexOf("media") === -1) {
|
|
1394
1793
|
return unsupportedStrategy("Media not supported");
|
|
1395
1794
|
}
|
|
1396
|
-
return
|
|
1795
|
+
return getAudioStrategy(canvas, paintables);
|
|
1397
1796
|
}
|
|
1398
1797
|
if (mainType === "video") {
|
|
1399
1798
|
if (supports.indexOf("media") === -1) {
|
|
1400
1799
|
return unsupportedStrategy("Media not supported");
|
|
1401
1800
|
}
|
|
1402
|
-
return
|
|
1801
|
+
return getVideoStrategy(canvas, paintables);
|
|
1403
1802
|
}
|
|
1404
1803
|
return unknownResponse;
|
|
1405
1804
|
}, [canvas, paintables, vault, actions.makeChoice]);
|
|
1406
|
-
return React.useMemo(() => {
|
|
1805
|
+
return React$1.useMemo(() => {
|
|
1407
1806
|
if (strategy.type === "unknown") {
|
|
1408
1807
|
return [strategy, emptyActions];
|
|
1409
1808
|
}
|
|
1410
1809
|
return [
|
|
1411
|
-
__spreadProps(__spreadValues$
|
|
1810
|
+
__spreadProps$1(__spreadValues$2({}, strategy), {
|
|
1412
1811
|
annotations: { pages: enabledPages }
|
|
1413
1812
|
}),
|
|
1414
1813
|
actions
|
|
@@ -1418,7 +1817,7 @@ function useRenderingStrategy(options) {
|
|
|
1418
1817
|
|
|
1419
1818
|
const useVaultEffect = (callback, deps = []) => {
|
|
1420
1819
|
const vault = useVault();
|
|
1421
|
-
React.useEffect(() => {
|
|
1820
|
+
React$1.useEffect(() => {
|
|
1422
1821
|
callback(vault);
|
|
1423
1822
|
}, [vault, ...deps]);
|
|
1424
1823
|
};
|
|
@@ -1426,13 +1825,13 @@ const useVaultEffect = (callback, deps = []) => {
|
|
|
1426
1825
|
function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
1427
1826
|
const vault = useVault();
|
|
1428
1827
|
const loader = useImageServiceLoader();
|
|
1429
|
-
const helper = React.useMemo(() => vaultHelpers.createThumbnailHelper(vault, { imageServiceLoader: loader }), [vault, loader]);
|
|
1430
|
-
const [thumbnail, setThumbnail] = React.useState();
|
|
1828
|
+
const helper = React$1.useMemo(() => vaultHelpers.createThumbnailHelper(vault, { imageServiceLoader: loader }), [vault, loader]);
|
|
1829
|
+
const [thumbnail, setThumbnail] = React$1.useState();
|
|
1431
1830
|
const manifest = useManifest(manifestId ? { id: manifestId } : void 0);
|
|
1432
1831
|
const canvas = useCanvas(canvasId ? { id: canvasId } : void 0);
|
|
1433
1832
|
const subject = canvas ? canvas : manifest;
|
|
1434
|
-
const didUnmount = React.useRef(false);
|
|
1435
|
-
React.useEffect(() => {
|
|
1833
|
+
const didUnmount = React$1.useRef(false);
|
|
1834
|
+
React$1.useEffect(() => {
|
|
1436
1835
|
return () => {
|
|
1437
1836
|
didUnmount.current = true;
|
|
1438
1837
|
};
|
|
@@ -1450,6 +1849,283 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
|
1450
1849
|
return thumbnail;
|
|
1451
1850
|
}
|
|
1452
1851
|
|
|
1852
|
+
var __defProp$1 = Object.defineProperty;
|
|
1853
|
+
var __defProps = Object.defineProperties;
|
|
1854
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1855
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1856
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1857
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1858
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1859
|
+
var __spreadValues$1 = (a, b) => {
|
|
1860
|
+
for (var prop in b || (b = {}))
|
|
1861
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
1862
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1863
|
+
if (__getOwnPropSymbols$1)
|
|
1864
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1865
|
+
if (__propIsEnum$1.call(b, prop))
|
|
1866
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1867
|
+
}
|
|
1868
|
+
return a;
|
|
1869
|
+
};
|
|
1870
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1871
|
+
function getDefaultState(duration) {
|
|
1872
|
+
return { isMuted: false, playRequested: false, isPlaying: false, isFinished: false, volume: 100, duration };
|
|
1873
|
+
}
|
|
1874
|
+
function reducer(state, action) {
|
|
1875
|
+
switch (action.type) {
|
|
1876
|
+
case "FINISHED":
|
|
1877
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: true, isPlaying: false, playRequested: false });
|
|
1878
|
+
case "PLAY_PAUSE":
|
|
1879
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: false, isPlaying: !state.isPlaying });
|
|
1880
|
+
case "PLAY_REQUESTED":
|
|
1881
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: false, playRequested: true });
|
|
1882
|
+
case "PAUSE":
|
|
1883
|
+
return __spreadProps(__spreadValues$1({}, state), { isPlaying: false });
|
|
1884
|
+
case "PLAY":
|
|
1885
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: false, playRequested: false, isPlaying: true });
|
|
1886
|
+
case "MUTE":
|
|
1887
|
+
return __spreadProps(__spreadValues$1({}, state), { isMuted: true });
|
|
1888
|
+
case "SET_VOLUME":
|
|
1889
|
+
return __spreadProps(__spreadValues$1({}, state), { volume: action.volume, isMuted: action.volume === 0 });
|
|
1890
|
+
case "TOGGLE_MUTE":
|
|
1891
|
+
return __spreadProps(__spreadValues$1({}, state), { isMuted: !state.isMuted });
|
|
1892
|
+
case "UNMUTE":
|
|
1893
|
+
return __spreadProps(__spreadValues$1({}, state), { isMuted: false });
|
|
1894
|
+
}
|
|
1895
|
+
return state;
|
|
1896
|
+
}
|
|
1897
|
+
function formatTime(time) {
|
|
1898
|
+
const seconds = Math.round(time);
|
|
1899
|
+
return `${Math.floor(seconds / 60)}:${`${seconds % 60}`.padStart(2, "0")}`;
|
|
1900
|
+
}
|
|
1901
|
+
function useSimpleMediaPlayer(props) {
|
|
1902
|
+
const [state, dispatch] = React$1.useReducer(reducer, getDefaultState(props.duration));
|
|
1903
|
+
const media = React$1.useRef(null);
|
|
1904
|
+
const currentTime = React$1.useRef(null);
|
|
1905
|
+
const progress = React$1.useRef(null);
|
|
1906
|
+
const _isMuted = React$1.useRef(false);
|
|
1907
|
+
const _updateCurrentTime = React$1.useCallback(() => {
|
|
1908
|
+
if (currentTime.current && media.current) {
|
|
1909
|
+
currentTime.current.innerHTML = formatTime(media.current.currentTime);
|
|
1910
|
+
if (progress.current) {
|
|
1911
|
+
progress.current.style.width = `${media.current.currentTime / props.duration * 100}%`;
|
|
1912
|
+
}
|
|
1913
|
+
if (_isMuted.current !== media.current.muted) {
|
|
1914
|
+
_isMuted.current = media.current.muted;
|
|
1915
|
+
dispatch(media.current.muted ? { type: "MUTE" } : { type: "UNMUTE" });
|
|
1916
|
+
}
|
|
1917
|
+
}
|
|
1918
|
+
}, [props.duration]);
|
|
1919
|
+
const play = React$1.useCallback(() => {
|
|
1920
|
+
if (media.current) {
|
|
1921
|
+
dispatch({ type: "PLAY_REQUESTED" });
|
|
1922
|
+
media.current.play().then(() => {
|
|
1923
|
+
dispatch({ type: "PLAY" });
|
|
1924
|
+
});
|
|
1925
|
+
_updateCurrentTime();
|
|
1926
|
+
}
|
|
1927
|
+
}, [_updateCurrentTime]);
|
|
1928
|
+
const playPause = React$1.useCallback(() => {
|
|
1929
|
+
if (media.current) {
|
|
1930
|
+
if (media.current.duration > 0 && media.current.paused) {
|
|
1931
|
+
play();
|
|
1932
|
+
} else {
|
|
1933
|
+
pause();
|
|
1934
|
+
}
|
|
1935
|
+
}
|
|
1936
|
+
}, [_updateCurrentTime]);
|
|
1937
|
+
const pause = React$1.useCallback(() => {
|
|
1938
|
+
if (media.current) {
|
|
1939
|
+
media.current.pause();
|
|
1940
|
+
dispatch({ type: "PAUSE" });
|
|
1941
|
+
_updateCurrentTime();
|
|
1942
|
+
}
|
|
1943
|
+
}, [_updateCurrentTime]);
|
|
1944
|
+
const toggleMute = React$1.useCallback(() => {
|
|
1945
|
+
if (media.current) {
|
|
1946
|
+
media.current.muted = !media.current.muted;
|
|
1947
|
+
dispatch(media.current.muted ? { type: "MUTE" } : { type: "UNMUTE" });
|
|
1948
|
+
}
|
|
1949
|
+
}, []);
|
|
1950
|
+
const mute = React$1.useCallback(() => {
|
|
1951
|
+
if (media.current) {
|
|
1952
|
+
media.current.muted = true;
|
|
1953
|
+
dispatch({ type: "MUTE" });
|
|
1954
|
+
}
|
|
1955
|
+
}, []);
|
|
1956
|
+
const unmute = React$1.useCallback(() => {
|
|
1957
|
+
if (media.current) {
|
|
1958
|
+
media.current.muted = false;
|
|
1959
|
+
dispatch({ type: "UNMUTE" });
|
|
1960
|
+
}
|
|
1961
|
+
}, []);
|
|
1962
|
+
const setVolume = React$1.useCallback((newVolume) => {
|
|
1963
|
+
if (media.current) {
|
|
1964
|
+
media.current.muted = false;
|
|
1965
|
+
media.current.volume = newVolume / 100;
|
|
1966
|
+
dispatch({ type: "SET_VOLUME", volume: newVolume });
|
|
1967
|
+
}
|
|
1968
|
+
}, []);
|
|
1969
|
+
const setDurationPercent = React$1.useCallback((percent) => {
|
|
1970
|
+
if (media.current) {
|
|
1971
|
+
media.current.currentTime = Math.max(0, Math.min(percent * props.duration, props.duration));
|
|
1972
|
+
_updateCurrentTime();
|
|
1973
|
+
}
|
|
1974
|
+
}, []);
|
|
1975
|
+
const setTime = React$1.useCallback((time) => {
|
|
1976
|
+
if (media.current) {
|
|
1977
|
+
media.current.currentTime = Math.max(0, Math.min(time, props.duration));
|
|
1978
|
+
_updateCurrentTime();
|
|
1979
|
+
}
|
|
1980
|
+
}, []);
|
|
1981
|
+
React$1.useEffect(() => {
|
|
1982
|
+
const interval = setInterval(() => {
|
|
1983
|
+
_updateCurrentTime();
|
|
1984
|
+
}, 350);
|
|
1985
|
+
return () => clearInterval(interval);
|
|
1986
|
+
}, [_updateCurrentTime, props.duration]);
|
|
1987
|
+
React$1.useEffect(() => {
|
|
1988
|
+
const ended = () => {
|
|
1989
|
+
dispatch({ type: "FINISHED" });
|
|
1990
|
+
};
|
|
1991
|
+
const _media = media.current;
|
|
1992
|
+
_media == null ? void 0 : _media.addEventListener("ended", ended);
|
|
1993
|
+
return () => _media == null ? void 0 : _media.removeEventListener("ended", ended);
|
|
1994
|
+
}, []);
|
|
1995
|
+
return [
|
|
1996
|
+
{ element: media, currentTime, progress },
|
|
1997
|
+
state,
|
|
1998
|
+
{
|
|
1999
|
+
play,
|
|
2000
|
+
pause,
|
|
2001
|
+
playPause,
|
|
2002
|
+
mute,
|
|
2003
|
+
unmute,
|
|
2004
|
+
toggleMute,
|
|
2005
|
+
setVolume,
|
|
2006
|
+
setDurationPercent,
|
|
2007
|
+
setTime
|
|
2008
|
+
}
|
|
2009
|
+
];
|
|
2010
|
+
}
|
|
2011
|
+
|
|
2012
|
+
const MediaReactContextState = React$1.createContext(null);
|
|
2013
|
+
const MediaReactContextActions = React$1.createContext(null);
|
|
2014
|
+
const MediaReactContextElements = React$1.createContext(null);
|
|
2015
|
+
function useMediaState() {
|
|
2016
|
+
const ctx = React$1.useContext(MediaReactContextState);
|
|
2017
|
+
if (!ctx) {
|
|
2018
|
+
throw new Error("Ctx not found");
|
|
2019
|
+
}
|
|
2020
|
+
return ctx;
|
|
2021
|
+
}
|
|
2022
|
+
function useMediaActions() {
|
|
2023
|
+
const ctx = React$1.useContext(MediaReactContextActions);
|
|
2024
|
+
if (!ctx) {
|
|
2025
|
+
throw new Error("Ctx not found");
|
|
2026
|
+
}
|
|
2027
|
+
return ctx;
|
|
2028
|
+
}
|
|
2029
|
+
function useMediaElements() {
|
|
2030
|
+
const ctx = React$1.useContext(MediaReactContextElements);
|
|
2031
|
+
if (!ctx) {
|
|
2032
|
+
throw new Error("Ctx not found");
|
|
2033
|
+
}
|
|
2034
|
+
return ctx;
|
|
2035
|
+
}
|
|
2036
|
+
function MediaPlayerProvider({
|
|
2037
|
+
actions,
|
|
2038
|
+
state,
|
|
2039
|
+
children,
|
|
2040
|
+
currentTime,
|
|
2041
|
+
progress,
|
|
2042
|
+
element
|
|
2043
|
+
}) {
|
|
2044
|
+
return /* @__PURE__ */ React.createElement(MediaReactContextElements.Provider, {
|
|
2045
|
+
value: { currentTime, progress, element }
|
|
2046
|
+
}, /* @__PURE__ */ React.createElement(MediaReactContextActions.Provider, {
|
|
2047
|
+
value: actions
|
|
2048
|
+
}, /* @__PURE__ */ React.createElement(MediaReactContextState.Provider, {
|
|
2049
|
+
value: state
|
|
2050
|
+
}, children)));
|
|
2051
|
+
}
|
|
2052
|
+
|
|
2053
|
+
function Audio({ media, children }) {
|
|
2054
|
+
const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });
|
|
2055
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CanvasPortal, null, /* @__PURE__ */ React.createElement(MediaPlayerProvider, {
|
|
2056
|
+
state,
|
|
2057
|
+
actions,
|
|
2058
|
+
currentTime,
|
|
2059
|
+
progress,
|
|
2060
|
+
element
|
|
2061
|
+
}, /* @__PURE__ */ React.createElement("audio", {
|
|
2062
|
+
ref: element,
|
|
2063
|
+
src: media.url
|
|
2064
|
+
}), children)));
|
|
2065
|
+
}
|
|
2066
|
+
|
|
2067
|
+
function Video({ media, children }) {
|
|
2068
|
+
const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });
|
|
2069
|
+
const Component = "div";
|
|
2070
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CanvasPortal, {
|
|
2071
|
+
overlay: true
|
|
2072
|
+
}, /* @__PURE__ */ React.createElement("style", null, `
|
|
2073
|
+
.video-container {
|
|
2074
|
+
position: absolute;
|
|
2075
|
+
top: 0;
|
|
2076
|
+
bottom: 0;
|
|
2077
|
+
left: 0;
|
|
2078
|
+
right: 0;
|
|
2079
|
+
background: #000;
|
|
2080
|
+
z-index: 13;
|
|
2081
|
+
display: flex;
|
|
2082
|
+
justify-content: center;
|
|
2083
|
+
pointer-events: visible;
|
|
2084
|
+
}
|
|
2085
|
+
`), /* @__PURE__ */ React.createElement(Component, {
|
|
2086
|
+
className: "video-container",
|
|
2087
|
+
part: "video-container",
|
|
2088
|
+
onClick: () => actions.playPause()
|
|
2089
|
+
}, /* @__PURE__ */ React.createElement("video", {
|
|
2090
|
+
ref: element,
|
|
2091
|
+
src: media.url,
|
|
2092
|
+
style: { width: "100%", objectFit: "contain" }
|
|
2093
|
+
}))), /* @__PURE__ */ React.createElement(CanvasPortal, null, /* @__PURE__ */ React.createElement(MediaPlayerProvider, {
|
|
2094
|
+
state,
|
|
2095
|
+
actions,
|
|
2096
|
+
currentTime,
|
|
2097
|
+
progress,
|
|
2098
|
+
element
|
|
2099
|
+
}, children)));
|
|
2100
|
+
}
|
|
2101
|
+
|
|
2102
|
+
function Model({ model }) {
|
|
2103
|
+
return /* @__PURE__ */ React.createElement(CanvasPortal, {
|
|
2104
|
+
overlay: true
|
|
2105
|
+
}, /* @__PURE__ */ React.createElement("style", null, `
|
|
2106
|
+
.model-container {
|
|
2107
|
+
position: absolute;
|
|
2108
|
+
top: 0;
|
|
2109
|
+
bottom: 0;
|
|
2110
|
+
left: 0;
|
|
2111
|
+
right: 0;
|
|
2112
|
+
background: #000;
|
|
2113
|
+
z-index: 13;
|
|
2114
|
+
display: flex;
|
|
2115
|
+
justify-content: center;
|
|
2116
|
+
pointer-events: visible;
|
|
2117
|
+
}
|
|
2118
|
+
`), /* @__PURE__ */ React.createElement("div", {
|
|
2119
|
+
className: "model-container"
|
|
2120
|
+
}, /* @__PURE__ */ React.createElement("model-viewer", {
|
|
2121
|
+
"interaction-prompt": "none",
|
|
2122
|
+
style: { width: "100%", height: "100%" },
|
|
2123
|
+
"camera-controls": "",
|
|
2124
|
+
"ar-status": "not-presenting",
|
|
2125
|
+
src: model.id
|
|
2126
|
+
})));
|
|
2127
|
+
}
|
|
2128
|
+
|
|
1453
2129
|
var __defProp = Object.defineProperty;
|
|
1454
2130
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1455
2131
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -1466,23 +2142,34 @@ var __spreadValues = (a, b) => {
|
|
|
1466
2142
|
}
|
|
1467
2143
|
return a;
|
|
1468
2144
|
};
|
|
1469
|
-
function RenderCanvas({
|
|
2145
|
+
function RenderCanvas({
|
|
2146
|
+
x,
|
|
2147
|
+
y,
|
|
2148
|
+
onChoiceChange,
|
|
2149
|
+
registerActions,
|
|
2150
|
+
defaultChoices,
|
|
2151
|
+
isStatic,
|
|
2152
|
+
renderViewerControls,
|
|
2153
|
+
renderMediaControls,
|
|
2154
|
+
strategies,
|
|
2155
|
+
children
|
|
2156
|
+
}) {
|
|
1470
2157
|
const canvas = useCanvas();
|
|
1471
2158
|
const elementProps = useResourceEvents(canvas, ["deep-zoom"]);
|
|
1472
2159
|
const [virtualPage] = useVirtualAnnotationPageContext();
|
|
1473
2160
|
const vault = useVault();
|
|
1474
|
-
const helper = React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
2161
|
+
const helper = React$1.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
1475
2162
|
const [strategy, actions] = useRenderingStrategy({
|
|
1476
|
-
strategies: ["images"],
|
|
2163
|
+
strategies: strategies || ["images"],
|
|
1477
2164
|
defaultChoices: defaultChoices == null ? void 0 : defaultChoices.map(({ id }) => id)
|
|
1478
2165
|
});
|
|
1479
2166
|
const choice = strategy.type === "images" ? strategy.choice : void 0;
|
|
1480
|
-
React.useEffect(() => {
|
|
2167
|
+
React$1.useEffect(() => {
|
|
1481
2168
|
if (registerActions) {
|
|
1482
2169
|
registerActions(actions);
|
|
1483
2170
|
}
|
|
1484
2171
|
}, [strategy.annotations]);
|
|
1485
|
-
React.useEffect(() => {
|
|
2172
|
+
React$1.useEffect(() => {
|
|
1486
2173
|
if (defaultChoices) {
|
|
1487
2174
|
for (const choice2 of defaultChoices) {
|
|
1488
2175
|
if (typeof choice2.opacity !== "undefined") {
|
|
@@ -1493,7 +2180,7 @@ function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, i
|
|
|
1493
2180
|
}
|
|
1494
2181
|
}
|
|
1495
2182
|
}, [defaultChoices]);
|
|
1496
|
-
React.useLayoutEffect(() => {
|
|
2183
|
+
React$1.useLayoutEffect(() => {
|
|
1497
2184
|
if (onChoiceChange) {
|
|
1498
2185
|
onChoiceChange(choice);
|
|
1499
2186
|
}
|
|
@@ -1502,39 +2189,41 @@ function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, i
|
|
|
1502
2189
|
if (!canvas) {
|
|
1503
2190
|
return null;
|
|
1504
2191
|
}
|
|
2192
|
+
const accompanyingCanvas = canvas.accompanyingCanvas;
|
|
2193
|
+
const thumbnailFallbackImage = thumbnail && thumbnail.type === "fixed" ? /* @__PURE__ */ React__default["default"].createElement("world-object", {
|
|
2194
|
+
height: canvas.height,
|
|
2195
|
+
width: canvas.width,
|
|
2196
|
+
x,
|
|
2197
|
+
y
|
|
2198
|
+
}, /* @__PURE__ */ React__default["default"].createElement("world-image", {
|
|
2199
|
+
uri: thumbnail.id,
|
|
2200
|
+
target: { x: 0, y: 0, width: canvas.width, height: canvas.height },
|
|
2201
|
+
display: thumbnail.width && thumbnail.height ? {
|
|
2202
|
+
width: thumbnail.width,
|
|
2203
|
+
height: thumbnail.height
|
|
2204
|
+
} : void 0
|
|
2205
|
+
})) : null;
|
|
1505
2206
|
if (strategy.type === "unknown") {
|
|
1506
|
-
if (
|
|
1507
|
-
return
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
x,
|
|
1511
|
-
y
|
|
1512
|
-
}, /* @__PURE__ */ React__default["default"].createElement("world-image", {
|
|
1513
|
-
uri: thumbnail.id,
|
|
1514
|
-
target: { x: 0, y: 0, width: canvas.width, height: canvas.height },
|
|
1515
|
-
display: thumbnail.width && thumbnail.height ? {
|
|
1516
|
-
width: thumbnail.width,
|
|
1517
|
-
height: thumbnail.height
|
|
1518
|
-
} : void 0
|
|
1519
|
-
}));
|
|
1520
|
-
}
|
|
1521
|
-
throw new Error("Unknown image strategy");
|
|
2207
|
+
if (thumbnailFallbackImage) {
|
|
2208
|
+
return thumbnailFallbackImage;
|
|
2209
|
+
}
|
|
2210
|
+
throw new Error(strategy.reason || "Unknown image strategy");
|
|
1522
2211
|
}
|
|
1523
|
-
const annotations = /* @__PURE__ */ React__default["default"].createElement(React.Fragment, null, virtualPage ? /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
2212
|
+
const annotations = /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, null, virtualPage ? /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
1524
2213
|
page: virtualPage
|
|
1525
2214
|
}) : null, strategy.annotations && strategy.annotations.pages ? strategy.annotations.pages.map((page) => {
|
|
1526
2215
|
return /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
1527
2216
|
key: page.id,
|
|
1528
2217
|
page
|
|
1529
2218
|
});
|
|
1530
|
-
}) : null);
|
|
1531
|
-
return /* @__PURE__ */ React__default["default"].createElement("world-object", __spreadValues({
|
|
2219
|
+
}) : null, children);
|
|
2220
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("world-object", __spreadValues({
|
|
1532
2221
|
key: strategy.type,
|
|
1533
2222
|
height: canvas.height,
|
|
1534
2223
|
width: canvas.width,
|
|
1535
2224
|
x,
|
|
1536
2225
|
y
|
|
1537
|
-
}, elementProps), strategy.type === "images" ? strategy.images.map((image, idx) => {
|
|
2226
|
+
}, elementProps), strategy.type === "images" ? /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, strategy.images.map((image, idx) => {
|
|
1538
2227
|
return /* @__PURE__ */ React__default["default"].createElement(RenderImage, {
|
|
1539
2228
|
isStatic,
|
|
1540
2229
|
key: image.id,
|
|
@@ -1543,7 +2232,17 @@ function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, i
|
|
|
1543
2232
|
thumbnail: idx === 0 ? thumbnail : void 0,
|
|
1544
2233
|
annotations
|
|
1545
2234
|
});
|
|
1546
|
-
})
|
|
2235
|
+
}), renderViewerControls ? /* @__PURE__ */ React__default["default"].createElement(CanvasPortal, {
|
|
2236
|
+
overlay: true
|
|
2237
|
+
}, renderViewerControls(strategy)) : null) : null, strategy.type === "3d-model" ? /* @__PURE__ */ React__default["default"].createElement(Model, {
|
|
2238
|
+
model: strategy.model
|
|
2239
|
+
}) : null, strategy.type === "media" ? /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, strategy.media.type === "Sound" ? /* @__PURE__ */ React__default["default"].createElement(Audio, {
|
|
2240
|
+
media: strategy.media
|
|
2241
|
+
}, thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null) : strategy.media.type === "Video" ? /* @__PURE__ */ React__default["default"].createElement(Video, {
|
|
2242
|
+
media: strategy.media
|
|
2243
|
+
}, thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null) : null) : null), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ React__default["default"].createElement(CanvasContext, {
|
|
2244
|
+
canvas: accompanyingCanvas.id
|
|
2245
|
+
}, /* @__PURE__ */ React__default["default"].createElement(RenderCanvas, null)) : null);
|
|
1547
2246
|
}
|
|
1548
2247
|
|
|
1549
2248
|
const CanvasPanel = {
|
|
@@ -1554,23 +2253,23 @@ const CanvasPanel = {
|
|
|
1554
2253
|
Viewer
|
|
1555
2254
|
};
|
|
1556
2255
|
|
|
1557
|
-
|
|
2256
|
+
function AnnotationContext({ annotation, children }) {
|
|
1558
2257
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1559
2258
|
value: { annotation }
|
|
1560
2259
|
}, children);
|
|
1561
|
-
}
|
|
2260
|
+
}
|
|
1562
2261
|
|
|
1563
|
-
|
|
2262
|
+
function CollectionContext({ collection, children }) {
|
|
1564
2263
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1565
2264
|
value: { collection }
|
|
1566
2265
|
}, children);
|
|
1567
|
-
}
|
|
2266
|
+
}
|
|
1568
2267
|
|
|
1569
|
-
|
|
2268
|
+
function RangeContext({ range, children }) {
|
|
1570
2269
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1571
2270
|
value: { range }
|
|
1572
2271
|
}, children);
|
|
1573
|
-
}
|
|
2272
|
+
}
|
|
1574
2273
|
|
|
1575
2274
|
function useAnnotationsAtTime(time, options = {}) {
|
|
1576
2275
|
const allAnnotations = usePaintingAnnotations(options);
|
|
@@ -1585,7 +2284,7 @@ function useCollection(options, deps = []) {
|
|
|
1585
2284
|
const ctx = useResourceContext();
|
|
1586
2285
|
const collectionId = id ? id : ctx.collection;
|
|
1587
2286
|
const collection = useVaultSelector((s) => collectionId ? s.iiif.entities.Collection[collectionId] : void 0, [collectionId]);
|
|
1588
|
-
return React.useMemo(() => {
|
|
2287
|
+
return React$1.useMemo(() => {
|
|
1589
2288
|
if (!collection) {
|
|
1590
2289
|
return void 0;
|
|
1591
2290
|
}
|
|
@@ -1598,8 +2297,8 @@ function useCollection(options, deps = []) {
|
|
|
1598
2297
|
|
|
1599
2298
|
function useEventListener(resource, name, listener, scope, deps = []) {
|
|
1600
2299
|
const vault = useVault();
|
|
1601
|
-
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
1602
|
-
React.useEffect(() => {
|
|
2300
|
+
const helper = React$1.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
2301
|
+
React$1.useEffect(() => {
|
|
1603
2302
|
const currentResource = resource;
|
|
1604
2303
|
if (!currentResource) {
|
|
1605
2304
|
return () => {
|
|
@@ -1613,7 +2312,7 @@ function useEventListener(resource, name, listener, scope, deps = []) {
|
|
|
1613
2312
|
}
|
|
1614
2313
|
|
|
1615
2314
|
function useExistingVault() {
|
|
1616
|
-
const oldContext = React.useContext(ReactVaultContext);
|
|
2315
|
+
const oldContext = React$1.useContext(ReactVaultContext);
|
|
1617
2316
|
return oldContext && oldContext.vault ? oldContext.vault : vault.globalVault();
|
|
1618
2317
|
}
|
|
1619
2318
|
|
|
@@ -1647,12 +2346,12 @@ function useImageService({ cacheKey } = {}) {
|
|
|
1647
2346
|
const annotations = usePaintingAnnotations();
|
|
1648
2347
|
const vault = useVault();
|
|
1649
2348
|
const imageService = useImageServiceLoader();
|
|
1650
|
-
const [_data, setData] = React.useState(void 0);
|
|
1651
|
-
const [isFetching, setIsFetching] = React.useState(false);
|
|
1652
|
-
const [status, setStatus] = React.useState("idle");
|
|
1653
|
-
const [error, setError] = React.useState(void 0);
|
|
2349
|
+
const [_data, setData] = React$1.useState(void 0);
|
|
2350
|
+
const [isFetching, setIsFetching] = React$1.useState(false);
|
|
2351
|
+
const [status, setStatus] = React$1.useState("idle");
|
|
2352
|
+
const [error, setError] = React$1.useState(void 0);
|
|
1654
2353
|
const key = canvas ? canvas.id : "undefined";
|
|
1655
|
-
const initialData = React.useMemo(() => {
|
|
2354
|
+
const initialData = React$1.useMemo(() => {
|
|
1656
2355
|
try {
|
|
1657
2356
|
if (canvas && annotations.length) {
|
|
1658
2357
|
const annotation = annotations[0];
|
|
@@ -1674,7 +2373,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
1674
2373
|
return void 0;
|
|
1675
2374
|
}, [key, cacheKey, canvas]);
|
|
1676
2375
|
const data = status === "success" && _data ? _data : initialData;
|
|
1677
|
-
React.useEffect(() => {
|
|
2376
|
+
React$1.useEffect(() => {
|
|
1678
2377
|
(() => __async(this, null, function* () {
|
|
1679
2378
|
try {
|
|
1680
2379
|
if (canvas && annotations.length) {
|
|
@@ -1707,7 +2406,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
1707
2406
|
}
|
|
1708
2407
|
}))();
|
|
1709
2408
|
}, [key, cacheKey]);
|
|
1710
|
-
return React.useMemo(() => {
|
|
2409
|
+
return React$1.useMemo(() => {
|
|
1711
2410
|
return {
|
|
1712
2411
|
data,
|
|
1713
2412
|
isFetching,
|
|
@@ -1736,7 +2435,7 @@ function useRange(options = {}, deps = []) {
|
|
|
1736
2435
|
const ctx = useResourceContext();
|
|
1737
2436
|
const rangeId = id ? id : ctx.range;
|
|
1738
2437
|
const range = useVaultSelector((s) => rangeId ? s.iiif.entities.Range[rangeId] : void 0, [rangeId]);
|
|
1739
|
-
return React.useMemo(() => {
|
|
2438
|
+
return React$1.useMemo(() => {
|
|
1740
2439
|
if (!range) {
|
|
1741
2440
|
return void 0;
|
|
1742
2441
|
}
|
|
@@ -1754,16 +2453,20 @@ function useSearchService() {
|
|
|
1754
2453
|
|
|
1755
2454
|
function useStyleHelper() {
|
|
1756
2455
|
const vault = useVault();
|
|
1757
|
-
return React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
2456
|
+
return React$1.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
1758
2457
|
}
|
|
1759
2458
|
|
|
1760
2459
|
exports.AnnotationContext = AnnotationContext;
|
|
1761
2460
|
exports.CanvasContext = CanvasContext;
|
|
1762
2461
|
exports.CanvasPanel = CanvasPanel;
|
|
2462
|
+
exports.CanvasPortal = CanvasPortal;
|
|
1763
2463
|
exports.CollectionContext = CollectionContext;
|
|
1764
2464
|
exports.ContextBridge = ContextBridge;
|
|
1765
2465
|
exports.ImageServiceLoaderContext = ImageServiceLoaderContext;
|
|
1766
2466
|
exports.ManifestContext = ManifestContext;
|
|
2467
|
+
exports.MediaPlayerProvider = MediaPlayerProvider;
|
|
2468
|
+
exports.OverlayPortalContext = OverlayPortalContext;
|
|
2469
|
+
exports.PortalContext = PortalContext;
|
|
1767
2470
|
exports.RangeContext = RangeContext;
|
|
1768
2471
|
exports.ReactVaultContext = ReactVaultContext;
|
|
1769
2472
|
exports.ResourceProvider = ResourceProvider;
|
|
@@ -1776,6 +2479,7 @@ exports.VisibleCanvasReactContext = VisibleCanvasReactContext;
|
|
|
1776
2479
|
exports.emptyActions = emptyActions;
|
|
1777
2480
|
exports.expandTarget = expandTarget;
|
|
1778
2481
|
exports.flattenAnnotationPageIds = flattenAnnotationPageIds;
|
|
2482
|
+
exports.formatTime = formatTime;
|
|
1779
2483
|
exports.getImageStrategy = getImageStrategy;
|
|
1780
2484
|
exports.getPaintables = getPaintables;
|
|
1781
2485
|
exports.parseSelector = parseSelector;
|
|
@@ -1800,6 +2504,9 @@ exports.useImageServiceLoader = useImageServiceLoader;
|
|
|
1800
2504
|
exports.useImageTile = useImageTile;
|
|
1801
2505
|
exports.useLoadImageService = useLoadImageService;
|
|
1802
2506
|
exports.useManifest = useManifest;
|
|
2507
|
+
exports.useMediaActions = useMediaActions;
|
|
2508
|
+
exports.useMediaElements = useMediaElements;
|
|
2509
|
+
exports.useMediaState = useMediaState;
|
|
1803
2510
|
exports.usePaintables = usePaintables;
|
|
1804
2511
|
exports.usePaintingAnnotations = usePaintingAnnotations;
|
|
1805
2512
|
exports.useRange = useRange;
|
|
@@ -1808,6 +2515,7 @@ exports.useResourceContext = useResourceContext;
|
|
|
1808
2515
|
exports.useResourceEvents = useResourceEvents;
|
|
1809
2516
|
exports.useResources = useResources;
|
|
1810
2517
|
exports.useSearchService = useSearchService;
|
|
2518
|
+
exports.useSimpleMediaPlayer = useSimpleMediaPlayer;
|
|
1811
2519
|
exports.useSimpleViewer = useSimpleViewer;
|
|
1812
2520
|
exports.useStyleHelper = useStyleHelper;
|
|
1813
2521
|
exports.useStyles = useStyles;
|