react-iiif-vault 0.9.8 → 0.9.11
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 +989 -271
- package/dist/esm/index.mjs +925 -219
- package/dist/index.d.ts +101 -26
- package/dist/index.umd.js +27593 -26878
- package/package.json +14 -11
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,178 @@ 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 rootRef = React$1.useRef(null);
|
|
723
|
+
const preset = useViewerPreset();
|
|
724
|
+
React$1.useLayoutEffect(() => {
|
|
725
|
+
if (!rootRef.current) {
|
|
726
|
+
rootRef.current = htmlElement ? createRoot(htmlElement) : null;
|
|
727
|
+
}
|
|
728
|
+
}, []);
|
|
729
|
+
React$1.useLayoutEffect(() => {
|
|
730
|
+
return () => {
|
|
731
|
+
var _a;
|
|
732
|
+
(_a = rootRef.current) == null ? void 0 : _a.unmount();
|
|
733
|
+
rootRef.current = null;
|
|
734
|
+
};
|
|
735
|
+
}, []);
|
|
736
|
+
React$1.useLayoutEffect(() => {
|
|
737
|
+
if (rootRef.current) {
|
|
738
|
+
rootRef.current.render(/* @__PURE__ */ React__default["default"].createElement(ViewerPresetContext.Provider, {
|
|
739
|
+
value: preset
|
|
740
|
+
}, children));
|
|
741
|
+
}
|
|
742
|
+
}, [children, preset]);
|
|
743
|
+
return null;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
var __defProp$8 = Object.defineProperty;
|
|
747
|
+
var __defProps$6 = Object.defineProperties;
|
|
748
|
+
var __getOwnPropDescs$6 = Object.getOwnPropertyDescriptors;
|
|
749
|
+
var __getOwnPropSymbols$8 = Object.getOwnPropertySymbols;
|
|
750
|
+
var __hasOwnProp$8 = Object.prototype.hasOwnProperty;
|
|
751
|
+
var __propIsEnum$8 = Object.prototype.propertyIsEnumerable;
|
|
752
|
+
var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
753
|
+
var __spreadValues$8 = (a, b) => {
|
|
754
|
+
for (var prop in b || (b = {}))
|
|
755
|
+
if (__hasOwnProp$8.call(b, prop))
|
|
756
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
757
|
+
if (__getOwnPropSymbols$8)
|
|
758
|
+
for (var prop of __getOwnPropSymbols$8(b)) {
|
|
759
|
+
if (__propIsEnum$8.call(b, prop))
|
|
760
|
+
__defNormalProp$8(a, prop, b[prop]);
|
|
761
|
+
}
|
|
762
|
+
return a;
|
|
763
|
+
};
|
|
764
|
+
var __spreadProps$6 = (a, b) => __defProps$6(a, __getOwnPropDescs$6(b));
|
|
488
765
|
var __objRest = (source, exclude) => {
|
|
489
766
|
var target = {};
|
|
490
767
|
for (var prop in source)
|
|
491
|
-
if (__hasOwnProp$
|
|
768
|
+
if (__hasOwnProp$8.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
492
769
|
target[prop] = source[prop];
|
|
493
|
-
if (source != null && __getOwnPropSymbols$
|
|
494
|
-
for (var prop of __getOwnPropSymbols$
|
|
495
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum$
|
|
770
|
+
if (source != null && __getOwnPropSymbols$8)
|
|
771
|
+
for (var prop of __getOwnPropSymbols$8(source)) {
|
|
772
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum$8.call(source, prop))
|
|
496
773
|
target[prop] = source[prop];
|
|
497
774
|
}
|
|
498
775
|
return target;
|
|
499
776
|
};
|
|
500
777
|
function Viewer(_a) {
|
|
501
778
|
var _b = _a, {
|
|
502
|
-
children
|
|
779
|
+
children,
|
|
780
|
+
errorFallback,
|
|
781
|
+
outerContainerProps = {}
|
|
503
782
|
} = _b, props = __objRest(_b, [
|
|
504
|
-
"children"
|
|
783
|
+
"children",
|
|
784
|
+
"errorFallback",
|
|
785
|
+
"outerContainerProps"
|
|
505
786
|
]);
|
|
787
|
+
const portal = React$1.useRef(null);
|
|
788
|
+
const [portalElement, setPortalElement] = React$1.useState();
|
|
789
|
+
const [viewerPreset, setViewerPreset] = React$1.useState();
|
|
790
|
+
const overlayPortal = React$1.useRef(null);
|
|
791
|
+
const [overlayPortalElement, setOverlayPortalElement] = React$1.useState();
|
|
506
792
|
const bridge = useContextBridge();
|
|
507
|
-
|
|
793
|
+
const ErrorFallback = errorFallback || DefaultCanvasFallback;
|
|
794
|
+
React$1.useLayoutEffect(() => {
|
|
795
|
+
setPortalElement(portal.current);
|
|
796
|
+
setOverlayPortalElement(overlayPortal.current);
|
|
797
|
+
}, []);
|
|
798
|
+
return /* @__PURE__ */ React__default["default"].createElement(reactErrorBoundary_umd.exports.ErrorBoundary, {
|
|
799
|
+
fallbackRender: () => /* @__PURE__ */ React__default["default"].createElement(ErrorFallback, __spreadValues$8({}, props))
|
|
800
|
+
}, /* @__PURE__ */ React__default["default"].createElement(atlas.AtlasAuto, __spreadProps$6(__spreadValues$8({}, props), {
|
|
801
|
+
containerProps: __spreadValues$8({ style: { position: "relative" } }, props.containerProps || {}),
|
|
802
|
+
htmlChildren: /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
803
|
+
ref: overlayPortal
|
|
804
|
+
}),
|
|
805
|
+
onCreated: (preset) => {
|
|
806
|
+
setViewerPreset(preset);
|
|
807
|
+
if (props.onCreated) {
|
|
808
|
+
props.onCreated(preset);
|
|
809
|
+
}
|
|
810
|
+
}
|
|
811
|
+
}), /* @__PURE__ */ React__default["default"].createElement(ViewerPresetContext.Provider, {
|
|
812
|
+
value: viewerPreset
|
|
813
|
+
}, /* @__PURE__ */ React__default["default"].createElement(PortalContext.Provider, {
|
|
814
|
+
value: portalElement
|
|
815
|
+
}, /* @__PURE__ */ React__default["default"].createElement(OverlayPortalContext.Provider, {
|
|
816
|
+
value: overlayPortalElement
|
|
817
|
+
}, /* @__PURE__ */ React__default["default"].createElement(ContextBridge, {
|
|
508
818
|
bridge
|
|
509
|
-
}, /* @__PURE__ */ React__default["default"].createElement(VirtualAnnotationProvider, null, children)))
|
|
819
|
+
}, /* @__PURE__ */ React__default["default"].createElement(VirtualAnnotationProvider, null, children)))))), /* @__PURE__ */ React__default["default"].createElement("div", {
|
|
820
|
+
ref: portal
|
|
821
|
+
}));
|
|
510
822
|
}
|
|
511
823
|
|
|
512
824
|
function useResourceEvents(resource, scope) {
|
|
513
825
|
const vault = useVault();
|
|
514
|
-
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
826
|
+
const helper = React$1.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
515
827
|
const hooks = useVaultSelector(() => {
|
|
516
828
|
if (resource && resource.id) {
|
|
517
829
|
return vault.getResourceMeta(resource.id, "eventManager");
|
|
518
830
|
}
|
|
519
831
|
return null;
|
|
520
832
|
}, [resource]);
|
|
521
|
-
return React.useMemo(() => {
|
|
833
|
+
return React$1.useMemo(() => {
|
|
522
834
|
return resource ? helper.getListenersAsProps(resource, scope) : {};
|
|
523
835
|
}, [hooks, resource, vault, scope]);
|
|
524
836
|
}
|
|
525
837
|
|
|
526
838
|
function useStyles(resource, scope) {
|
|
527
839
|
const vault = useVault();
|
|
528
|
-
const helper = React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
840
|
+
const helper = React$1.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
529
841
|
return useVaultSelector(() => {
|
|
530
842
|
if (!resource) {
|
|
531
843
|
return null;
|
|
@@ -624,25 +936,25 @@ function parseSelector(source) {
|
|
|
624
936
|
};
|
|
625
937
|
}
|
|
626
938
|
|
|
627
|
-
var __defProp$
|
|
628
|
-
var __defProps$
|
|
629
|
-
var __getOwnPropDescs$
|
|
630
|
-
var __getOwnPropSymbols$
|
|
631
|
-
var __hasOwnProp$
|
|
632
|
-
var __propIsEnum$
|
|
633
|
-
var __defNormalProp$
|
|
634
|
-
var __spreadValues$
|
|
939
|
+
var __defProp$7 = Object.defineProperty;
|
|
940
|
+
var __defProps$5 = Object.defineProperties;
|
|
941
|
+
var __getOwnPropDescs$5 = Object.getOwnPropertyDescriptors;
|
|
942
|
+
var __getOwnPropSymbols$7 = Object.getOwnPropertySymbols;
|
|
943
|
+
var __hasOwnProp$7 = Object.prototype.hasOwnProperty;
|
|
944
|
+
var __propIsEnum$7 = Object.prototype.propertyIsEnumerable;
|
|
945
|
+
var __defNormalProp$7 = (obj, key, value) => key in obj ? __defProp$7(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
946
|
+
var __spreadValues$7 = (a, b) => {
|
|
635
947
|
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$
|
|
948
|
+
if (__hasOwnProp$7.call(b, prop))
|
|
949
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
950
|
+
if (__getOwnPropSymbols$7)
|
|
951
|
+
for (var prop of __getOwnPropSymbols$7(b)) {
|
|
952
|
+
if (__propIsEnum$7.call(b, prop))
|
|
953
|
+
__defNormalProp$7(a, prop, b[prop]);
|
|
642
954
|
}
|
|
643
955
|
return a;
|
|
644
956
|
};
|
|
645
|
-
var __spreadProps$
|
|
957
|
+
var __spreadProps$5 = (a, b) => __defProps$5(a, __getOwnPropDescs$5(b));
|
|
646
958
|
function expandTarget(target, options = {}) {
|
|
647
959
|
if (Array.isArray(target)) {
|
|
648
960
|
return expandTarget(target[0]);
|
|
@@ -699,7 +1011,7 @@ function expandTarget(target, options = {}) {
|
|
|
699
1011
|
if (!fragment) {
|
|
700
1012
|
return {
|
|
701
1013
|
type: "SpecificResource",
|
|
702
|
-
source: __spreadProps$
|
|
1014
|
+
source: __spreadProps$5(__spreadValues$7({}, target), {
|
|
703
1015
|
id
|
|
704
1016
|
}),
|
|
705
1017
|
selector: null,
|
|
@@ -708,7 +1020,7 @@ function expandTarget(target, options = {}) {
|
|
|
708
1020
|
}
|
|
709
1021
|
return expandTarget({
|
|
710
1022
|
type: "SpecificResource",
|
|
711
|
-
source: __spreadProps$
|
|
1023
|
+
source: __spreadProps$5(__spreadValues$7({}, target), {
|
|
712
1024
|
id
|
|
713
1025
|
}),
|
|
714
1026
|
selector: {
|
|
@@ -725,25 +1037,25 @@ function expandTarget(target, options = {}) {
|
|
|
725
1037
|
};
|
|
726
1038
|
}
|
|
727
1039
|
|
|
728
|
-
var __defProp$
|
|
729
|
-
var __defProps$
|
|
730
|
-
var __getOwnPropDescs$
|
|
731
|
-
var __getOwnPropSymbols$
|
|
732
|
-
var __hasOwnProp$
|
|
733
|
-
var __propIsEnum$
|
|
734
|
-
var __defNormalProp$
|
|
735
|
-
var __spreadValues$
|
|
1040
|
+
var __defProp$6 = Object.defineProperty;
|
|
1041
|
+
var __defProps$4 = Object.defineProperties;
|
|
1042
|
+
var __getOwnPropDescs$4 = Object.getOwnPropertyDescriptors;
|
|
1043
|
+
var __getOwnPropSymbols$6 = Object.getOwnPropertySymbols;
|
|
1044
|
+
var __hasOwnProp$6 = Object.prototype.hasOwnProperty;
|
|
1045
|
+
var __propIsEnum$6 = Object.prototype.propertyIsEnumerable;
|
|
1046
|
+
var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1047
|
+
var __spreadValues$6 = (a, b) => {
|
|
736
1048
|
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$
|
|
1049
|
+
if (__hasOwnProp$6.call(b, prop))
|
|
1050
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
1051
|
+
if (__getOwnPropSymbols$6)
|
|
1052
|
+
for (var prop of __getOwnPropSymbols$6(b)) {
|
|
1053
|
+
if (__propIsEnum$6.call(b, prop))
|
|
1054
|
+
__defNormalProp$6(a, prop, b[prop]);
|
|
743
1055
|
}
|
|
744
1056
|
return a;
|
|
745
1057
|
};
|
|
746
|
-
var __spreadProps$
|
|
1058
|
+
var __spreadProps$4 = (a, b) => __defProps$4(a, __getOwnPropDescs$4(b));
|
|
747
1059
|
function useAnnotation(options = {}, deps = []) {
|
|
748
1060
|
const { id, selector } = options;
|
|
749
1061
|
const ctx = useResourceContext();
|
|
@@ -751,11 +1063,11 @@ function useAnnotation(options = {}, deps = []) {
|
|
|
751
1063
|
const annotationId = id ? id : ctx.annotation;
|
|
752
1064
|
const annotation = useVaultSelector((s) => annotationId ? s.iiif.entities.Annotation[annotationId] : void 0, [annotationId]);
|
|
753
1065
|
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(() => {
|
|
1066
|
+
return React$1.useMemo(() => {
|
|
755
1067
|
if (!annotation) {
|
|
756
1068
|
return void 0;
|
|
757
1069
|
}
|
|
758
|
-
const newAnnotation = __spreadProps$
|
|
1070
|
+
const newAnnotation = __spreadProps$4(__spreadValues$6({}, annotation), {
|
|
759
1071
|
body,
|
|
760
1072
|
target: expandTarget(annotation.target, { typeMap: vault.getState().iiif.mapping })
|
|
761
1073
|
});
|
|
@@ -771,7 +1083,7 @@ function useCanvas(options = {}, deps = []) {
|
|
|
771
1083
|
const ctx = useResourceContext();
|
|
772
1084
|
const canvasId = id ? id : ctx.canvas;
|
|
773
1085
|
const canvas = useVaultSelector((s) => canvasId ? s.iiif.entities.Canvas[canvasId] : void 0, [canvasId]);
|
|
774
|
-
return React.useMemo(() => {
|
|
1086
|
+
return React$1.useMemo(() => {
|
|
775
1087
|
if (!canvas) {
|
|
776
1088
|
return void 0;
|
|
777
1089
|
}
|
|
@@ -782,19 +1094,19 @@ function useCanvas(options = {}, deps = []) {
|
|
|
782
1094
|
}, [canvas, selector, ...deps]);
|
|
783
1095
|
}
|
|
784
1096
|
|
|
785
|
-
var __defProp$
|
|
786
|
-
var __getOwnPropSymbols$
|
|
787
|
-
var __hasOwnProp$
|
|
788
|
-
var __propIsEnum$
|
|
789
|
-
var __defNormalProp$
|
|
790
|
-
var __spreadValues$
|
|
1097
|
+
var __defProp$5 = Object.defineProperty;
|
|
1098
|
+
var __getOwnPropSymbols$5 = Object.getOwnPropertySymbols;
|
|
1099
|
+
var __hasOwnProp$5 = Object.prototype.hasOwnProperty;
|
|
1100
|
+
var __propIsEnum$5 = Object.prototype.propertyIsEnumerable;
|
|
1101
|
+
var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1102
|
+
var __spreadValues$5 = (a, b) => {
|
|
791
1103
|
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$
|
|
1104
|
+
if (__hasOwnProp$5.call(b, prop))
|
|
1105
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
1106
|
+
if (__getOwnPropSymbols$5)
|
|
1107
|
+
for (var prop of __getOwnPropSymbols$5(b)) {
|
|
1108
|
+
if (__propIsEnum$5.call(b, prop))
|
|
1109
|
+
__defNormalProp$5(a, prop, b[prop]);
|
|
798
1110
|
}
|
|
799
1111
|
return a;
|
|
800
1112
|
};
|
|
@@ -809,14 +1121,14 @@ const RenderAnnotation = ({
|
|
|
809
1121
|
const html = useStyles(annotation, "html");
|
|
810
1122
|
const events = useResourceEvents(annotation, ["atlas"]);
|
|
811
1123
|
const canvas = useCanvas();
|
|
812
|
-
const allStyles = React.useMemo(() => {
|
|
1124
|
+
const allStyles = React$1.useMemo(() => {
|
|
813
1125
|
return atlas.mergeStyles(defaultStyle, style);
|
|
814
1126
|
}, [defaultStyle, style]);
|
|
815
1127
|
const isValid = canvas && annotation && annotation.target && annotation.target.selector && annotation.target.selector.type === "BoxSelector" && annotation.target.source && annotation.target.source.id === canvas.id;
|
|
816
1128
|
if (!isValid) {
|
|
817
1129
|
return null;
|
|
818
1130
|
}
|
|
819
|
-
return /* @__PURE__ */ React__default["default"].createElement(atlas.RegionHighlight, __spreadValues$
|
|
1131
|
+
return /* @__PURE__ */ React__default["default"].createElement(atlas.RegionHighlight, __spreadValues$5({
|
|
820
1132
|
id: annotation.id,
|
|
821
1133
|
isEditing: true,
|
|
822
1134
|
region: annotation.target.selector.spatial,
|
|
@@ -837,7 +1149,7 @@ const RenderAnnotationPage = ({
|
|
|
837
1149
|
const style = useStyles(page, "atlas");
|
|
838
1150
|
const html = useStyles(page, "html");
|
|
839
1151
|
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) => {
|
|
1152
|
+
return /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, null, (_a = page.items) == null ? void 0 : _a.map((annotation) => {
|
|
841
1153
|
return /* @__PURE__ */ React__default["default"].createElement(RenderAnnotation, {
|
|
842
1154
|
key: annotation.id,
|
|
843
1155
|
id: annotation.id,
|
|
@@ -855,12 +1167,13 @@ function RenderImage({
|
|
|
855
1167
|
isStatic,
|
|
856
1168
|
x = 0,
|
|
857
1169
|
y = 0,
|
|
858
|
-
annotations
|
|
1170
|
+
annotations,
|
|
1171
|
+
children
|
|
859
1172
|
}) {
|
|
860
1173
|
var _a, _b, _c, _d;
|
|
861
|
-
return /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
1174
|
+
return /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, {
|
|
862
1175
|
key: id
|
|
863
|
-
}, !image.service ? /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
1176
|
+
}, !image.service ? /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, {
|
|
864
1177
|
key: "no-service"
|
|
865
1178
|
}, /* @__PURE__ */ React__default["default"].createElement("world-image", {
|
|
866
1179
|
uri: image.id,
|
|
@@ -869,7 +1182,7 @@ function RenderImage({
|
|
|
869
1182
|
width: image.width,
|
|
870
1183
|
height: image.height
|
|
871
1184
|
} : void 0
|
|
872
|
-
}), annotations) : /* @__PURE__ */ React__default["default"].createElement(React.Fragment, {
|
|
1185
|
+
}), annotations, children) : /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, {
|
|
873
1186
|
key: "service"
|
|
874
1187
|
}, /* @__PURE__ */ React__default["default"].createElement(TileSet, {
|
|
875
1188
|
viewport: isStatic,
|
|
@@ -884,7 +1197,7 @@ function RenderImage({
|
|
|
884
1197
|
y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
|
|
885
1198
|
width: (_c = image.target) == null ? void 0 : _c.spatial.width,
|
|
886
1199
|
height: (_d = image.target) == null ? void 0 : _d.spatial.height
|
|
887
|
-
}), annotations));
|
|
1200
|
+
}), annotations, children));
|
|
888
1201
|
}
|
|
889
1202
|
|
|
890
1203
|
function parseSpecificResource(resource) {
|
|
@@ -952,7 +1265,7 @@ function useManifest(options = {}, deps = []) {
|
|
|
952
1265
|
useVault();
|
|
953
1266
|
const manifestId = id ? id : ctx.manifest;
|
|
954
1267
|
const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
|
|
955
|
-
return React.useMemo(() => {
|
|
1268
|
+
return React$1.useMemo(() => {
|
|
956
1269
|
if (!manifest) {
|
|
957
1270
|
return void 0;
|
|
958
1271
|
}
|
|
@@ -1024,25 +1337,25 @@ function flattenAnnotationPageIds({
|
|
|
1024
1337
|
return foundIds;
|
|
1025
1338
|
}
|
|
1026
1339
|
|
|
1027
|
-
var __defProp$
|
|
1028
|
-
var __defProps$
|
|
1029
|
-
var __getOwnPropDescs$
|
|
1030
|
-
var __getOwnPropSymbols$
|
|
1031
|
-
var __hasOwnProp$
|
|
1032
|
-
var __propIsEnum$
|
|
1033
|
-
var __defNormalProp$
|
|
1034
|
-
var __spreadValues$
|
|
1340
|
+
var __defProp$4 = Object.defineProperty;
|
|
1341
|
+
var __defProps$3 = Object.defineProperties;
|
|
1342
|
+
var __getOwnPropDescs$3 = Object.getOwnPropertyDescriptors;
|
|
1343
|
+
var __getOwnPropSymbols$4 = Object.getOwnPropertySymbols;
|
|
1344
|
+
var __hasOwnProp$4 = Object.prototype.hasOwnProperty;
|
|
1345
|
+
var __propIsEnum$4 = Object.prototype.propertyIsEnumerable;
|
|
1346
|
+
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1347
|
+
var __spreadValues$4 = (a, b) => {
|
|
1035
1348
|
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$
|
|
1349
|
+
if (__hasOwnProp$4.call(b, prop))
|
|
1350
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1351
|
+
if (__getOwnPropSymbols$4)
|
|
1352
|
+
for (var prop of __getOwnPropSymbols$4(b)) {
|
|
1353
|
+
if (__propIsEnum$4.call(b, prop))
|
|
1354
|
+
__defNormalProp$4(a, prop, b[prop]);
|
|
1042
1355
|
}
|
|
1043
1356
|
return a;
|
|
1044
1357
|
};
|
|
1045
|
-
var __spreadProps$
|
|
1358
|
+
var __spreadProps$3 = (a, b) => __defProps$3(a, __getOwnPropDescs$3(b));
|
|
1046
1359
|
function getMeta(state, resourceId) {
|
|
1047
1360
|
var _a;
|
|
1048
1361
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1056,7 +1369,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1056
1369
|
const manifest = useManifest();
|
|
1057
1370
|
const canvas = useCanvas();
|
|
1058
1371
|
const canvases = useVisibleCanvases();
|
|
1059
|
-
const availablePageIds = React.useMemo(() => {
|
|
1372
|
+
const availablePageIds = React$1.useMemo(() => {
|
|
1060
1373
|
return flattenAnnotationPageIds({
|
|
1061
1374
|
all: options.all,
|
|
1062
1375
|
manifest,
|
|
@@ -1065,7 +1378,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1065
1378
|
});
|
|
1066
1379
|
}, [options.all, canvas, canvases, manifest]);
|
|
1067
1380
|
const enabledPageIds = useEnabledAnnotationPageIds(resourceId, options.all ? void 0 : availablePageIds);
|
|
1068
|
-
const setPageDisabled = React.useCallback((deselectId) => {
|
|
1381
|
+
const setPageDisabled = React$1.useCallback((deselectId) => {
|
|
1069
1382
|
if (!resourceId) {
|
|
1070
1383
|
return;
|
|
1071
1384
|
}
|
|
@@ -1073,12 +1386,12 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1073
1386
|
if (existingResources && !existingResources[resourceId]) {
|
|
1074
1387
|
return existingResources;
|
|
1075
1388
|
}
|
|
1076
|
-
return __spreadProps$
|
|
1389
|
+
return __spreadProps$3(__spreadValues$4({}, existingResources || {}), {
|
|
1077
1390
|
[resourceId]: false
|
|
1078
1391
|
});
|
|
1079
1392
|
});
|
|
1080
1393
|
}, [resourceId, vault]);
|
|
1081
|
-
const setPageEnabled = React.useCallback((id, opt = {}) => {
|
|
1394
|
+
const setPageEnabled = React$1.useCallback((id, opt = {}) => {
|
|
1082
1395
|
if (!resourceId) {
|
|
1083
1396
|
return;
|
|
1084
1397
|
}
|
|
@@ -1100,7 +1413,7 @@ function useAnnotationPageManager(resourceId, options = {}) {
|
|
|
1100
1413
|
if (existingResources && existingResources[resourceId]) {
|
|
1101
1414
|
return existingResources;
|
|
1102
1415
|
}
|
|
1103
|
-
return __spreadProps$
|
|
1416
|
+
return __spreadProps$3(__spreadValues$4({}, existingResources || {}), {
|
|
1104
1417
|
[resourceId]: true
|
|
1105
1418
|
});
|
|
1106
1419
|
});
|
|
@@ -1119,51 +1432,52 @@ function useResources(ids, type) {
|
|
|
1119
1432
|
|
|
1120
1433
|
const ImageServiceLoaderContext = React__default["default"].createContext(new iiifImageApi.ImageServiceLoader());
|
|
1121
1434
|
function useImageServiceLoader() {
|
|
1122
|
-
return React.useContext(ImageServiceLoaderContext);
|
|
1435
|
+
return React$1.useContext(ImageServiceLoaderContext);
|
|
1123
1436
|
}
|
|
1124
1437
|
|
|
1125
|
-
var __defProp$
|
|
1126
|
-
var __defProps$
|
|
1127
|
-
var __getOwnPropDescs$
|
|
1128
|
-
var __getOwnPropSymbols$
|
|
1129
|
-
var __hasOwnProp$
|
|
1130
|
-
var __propIsEnum$
|
|
1131
|
-
var __defNormalProp$
|
|
1132
|
-
var __spreadValues$
|
|
1438
|
+
var __defProp$3 = Object.defineProperty;
|
|
1439
|
+
var __defProps$2 = Object.defineProperties;
|
|
1440
|
+
var __getOwnPropDescs$2 = Object.getOwnPropertyDescriptors;
|
|
1441
|
+
var __getOwnPropSymbols$3 = Object.getOwnPropertySymbols;
|
|
1442
|
+
var __hasOwnProp$3 = Object.prototype.hasOwnProperty;
|
|
1443
|
+
var __propIsEnum$3 = Object.prototype.propertyIsEnumerable;
|
|
1444
|
+
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1445
|
+
var __spreadValues$3 = (a, b) => {
|
|
1133
1446
|
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$
|
|
1447
|
+
if (__hasOwnProp$3.call(b, prop))
|
|
1448
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1449
|
+
if (__getOwnPropSymbols$3)
|
|
1450
|
+
for (var prop of __getOwnPropSymbols$3(b)) {
|
|
1451
|
+
if (__propIsEnum$3.call(b, prop))
|
|
1452
|
+
__defNormalProp$3(a, prop, b[prop]);
|
|
1140
1453
|
}
|
|
1141
1454
|
return a;
|
|
1142
1455
|
};
|
|
1143
|
-
var __spreadProps$
|
|
1456
|
+
var __spreadProps$2 = (a, b) => __defProps$2(a, __getOwnPropDescs$2(b));
|
|
1144
1457
|
function useLoadImageService() {
|
|
1145
1458
|
const loader = useImageServiceLoader();
|
|
1146
|
-
const [imageServiceStatus, setImageServiceStatus] = React.useState({});
|
|
1147
|
-
const didUnmount = React.useRef(false);
|
|
1148
|
-
React.useEffect(() => {
|
|
1459
|
+
const [imageServiceStatus, setImageServiceStatus] = React$1.useState({});
|
|
1460
|
+
const didUnmount = React$1.useRef(false);
|
|
1461
|
+
React$1.useEffect(() => {
|
|
1149
1462
|
return () => {
|
|
1150
1463
|
didUnmount.current = true;
|
|
1151
1464
|
};
|
|
1152
1465
|
}, []);
|
|
1153
|
-
const loadImageService = React.useCallback((imageService, { height, width }) => {
|
|
1466
|
+
const loadImageService = React$1.useCallback((imageService, { height, width }) => {
|
|
1154
1467
|
if (imageService) {
|
|
1155
1468
|
const imageServiceId = imageService.id || imageService["@id"];
|
|
1156
1469
|
const syncLoaded = loader.loadServiceSync({
|
|
1157
1470
|
id: imageServiceId,
|
|
1158
1471
|
width: imageService.width || width,
|
|
1159
|
-
height: imageService.height || height
|
|
1472
|
+
height: imageService.height || height,
|
|
1473
|
+
source: imageService
|
|
1160
1474
|
});
|
|
1161
1475
|
if (syncLoaded) {
|
|
1162
1476
|
imageService = syncLoaded;
|
|
1163
1477
|
} else if (!imageServiceStatus[imageServiceId]) {
|
|
1164
1478
|
if (!didUnmount.current) {
|
|
1165
1479
|
setImageServiceStatus((r) => {
|
|
1166
|
-
return __spreadProps$
|
|
1480
|
+
return __spreadProps$2(__spreadValues$3({}, r), {
|
|
1167
1481
|
[imageServiceId]: "loading"
|
|
1168
1482
|
});
|
|
1169
1483
|
});
|
|
@@ -1175,7 +1489,7 @@ function useLoadImageService() {
|
|
|
1175
1489
|
}).then(() => {
|
|
1176
1490
|
if (!didUnmount.current) {
|
|
1177
1491
|
setImageServiceStatus((r) => {
|
|
1178
|
-
return __spreadProps$
|
|
1492
|
+
return __spreadProps$2(__spreadValues$3({}, r), {
|
|
1179
1493
|
[imageServiceId]: "done"
|
|
1180
1494
|
});
|
|
1181
1495
|
});
|
|
@@ -1206,9 +1520,9 @@ function usePaintingAnnotations(options = {}) {
|
|
|
1206
1520
|
function usePaintables(options, deps = []) {
|
|
1207
1521
|
const vault = useVault();
|
|
1208
1522
|
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 } = {}) => {
|
|
1523
|
+
const [enabledChoices, setEnabledChoices] = React$1.useState((options == null ? void 0 : options.defaultChoices) || []);
|
|
1524
|
+
const paintables = React$1.useMemo(() => getPaintables(vault, paintingAnnotations, enabledChoices), [vault, paintingAnnotations, enabledChoices, ...deps]);
|
|
1525
|
+
const makeChoice = React$1.useCallback((id, { deselectOthers = true, deselect = false } = {}) => {
|
|
1212
1526
|
if (paintables.choice) {
|
|
1213
1527
|
if (paintables.choice.type !== "single-choice") {
|
|
1214
1528
|
throw new Error("Complex choice not supported yet");
|
|
@@ -1324,37 +1638,126 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1324
1638
|
const supportedFormats = ["model/gltf-binary"];
|
|
1325
1639
|
function get3dStrategy(canvas, paintables) {
|
|
1326
1640
|
const first = paintables.items[0];
|
|
1327
|
-
|
|
1641
|
+
const resource = first.resource;
|
|
1642
|
+
if (!resource.format) {
|
|
1328
1643
|
return unsupportedStrategy("Unknown format");
|
|
1329
1644
|
}
|
|
1330
|
-
if (supportedFormats.indexOf(
|
|
1331
|
-
return unsupportedStrategy(`3D format: ${
|
|
1645
|
+
if (supportedFormats.indexOf(resource.format) === -1) {
|
|
1646
|
+
return unsupportedStrategy(`3D format: ${resource.format} is unsupported`);
|
|
1332
1647
|
}
|
|
1333
1648
|
return {
|
|
1334
1649
|
type: "3d-model",
|
|
1335
|
-
model:
|
|
1650
|
+
model: resource
|
|
1336
1651
|
};
|
|
1337
1652
|
}
|
|
1338
1653
|
|
|
1339
|
-
|
|
1340
|
-
var
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1654
|
+
function getAudioStrategy(canvas, paintables) {
|
|
1655
|
+
var _a;
|
|
1656
|
+
if (!canvas.duration) {
|
|
1657
|
+
return unsupportedStrategy("No duration on canvas");
|
|
1658
|
+
}
|
|
1659
|
+
if (paintables.items.length > 1) {
|
|
1660
|
+
return unsupportedStrategy("Only one audio source supported");
|
|
1661
|
+
}
|
|
1662
|
+
const audioResource = (_a = paintables.items[0]) == null ? void 0 : _a.resource;
|
|
1663
|
+
if (!audioResource) {
|
|
1664
|
+
return unsupportedStrategy("Unknown audio");
|
|
1665
|
+
}
|
|
1666
|
+
if (!audioResource.format) {
|
|
1667
|
+
return unsupportedStrategy("Audio does not have format");
|
|
1668
|
+
}
|
|
1669
|
+
return {
|
|
1670
|
+
type: "media",
|
|
1671
|
+
media: {
|
|
1672
|
+
duration: canvas.duration,
|
|
1673
|
+
url: audioResource.id,
|
|
1674
|
+
type: "Sound",
|
|
1675
|
+
target: {
|
|
1676
|
+
type: "TemporalSelector",
|
|
1677
|
+
temporal: {
|
|
1678
|
+
startTime: 0,
|
|
1679
|
+
endTime: canvas.duration
|
|
1680
|
+
}
|
|
1681
|
+
},
|
|
1682
|
+
format: audioResource.format,
|
|
1683
|
+
selector: {
|
|
1684
|
+
type: "TemporalSelector",
|
|
1685
|
+
temporal: {
|
|
1686
|
+
startTime: 0,
|
|
1687
|
+
endTime: canvas.duration
|
|
1688
|
+
}
|
|
1689
|
+
}
|
|
1690
|
+
},
|
|
1691
|
+
annotations: {
|
|
1692
|
+
pages: []
|
|
1693
|
+
}
|
|
1694
|
+
};
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
function getVideoStrategy(canvas, paintables) {
|
|
1698
|
+
var _a;
|
|
1699
|
+
const videoPaintables = paintables.items.filter((t) => t.type === "video");
|
|
1700
|
+
if (!canvas.duration) {
|
|
1701
|
+
return unsupportedStrategy("No duration on canvas");
|
|
1702
|
+
}
|
|
1703
|
+
if (videoPaintables.length > 1) {
|
|
1704
|
+
return unsupportedStrategy("Only one video source supported");
|
|
1705
|
+
}
|
|
1706
|
+
const audioResource = (_a = videoPaintables[0]) == null ? void 0 : _a.resource;
|
|
1707
|
+
if (!audioResource) {
|
|
1708
|
+
return unsupportedStrategy("Unknown video");
|
|
1709
|
+
}
|
|
1710
|
+
if (!audioResource.format) {
|
|
1711
|
+
return unsupportedStrategy("Video does not have format");
|
|
1712
|
+
}
|
|
1713
|
+
return {
|
|
1714
|
+
type: "media",
|
|
1715
|
+
media: {
|
|
1716
|
+
duration: canvas.duration,
|
|
1717
|
+
url: audioResource.id,
|
|
1718
|
+
type: "Video",
|
|
1719
|
+
items: [],
|
|
1720
|
+
target: {
|
|
1721
|
+
type: "TemporalSelector",
|
|
1722
|
+
temporal: {
|
|
1723
|
+
startTime: 0,
|
|
1724
|
+
endTime: canvas.duration
|
|
1725
|
+
}
|
|
1726
|
+
},
|
|
1727
|
+
format: audioResource.format,
|
|
1728
|
+
selector: {
|
|
1729
|
+
type: "TemporalSelector",
|
|
1730
|
+
temporal: {
|
|
1731
|
+
startTime: 0,
|
|
1732
|
+
endTime: canvas.duration
|
|
1733
|
+
}
|
|
1734
|
+
}
|
|
1735
|
+
},
|
|
1736
|
+
annotations: {
|
|
1737
|
+
pages: []
|
|
1738
|
+
}
|
|
1739
|
+
};
|
|
1740
|
+
}
|
|
1741
|
+
|
|
1742
|
+
var __defProp$2 = Object.defineProperty;
|
|
1743
|
+
var __defProps$1 = Object.defineProperties;
|
|
1744
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
1745
|
+
var __getOwnPropSymbols$2 = Object.getOwnPropertySymbols;
|
|
1746
|
+
var __hasOwnProp$2 = Object.prototype.hasOwnProperty;
|
|
1747
|
+
var __propIsEnum$2 = Object.prototype.propertyIsEnumerable;
|
|
1748
|
+
var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1749
|
+
var __spreadValues$2 = (a, b) => {
|
|
1347
1750
|
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$
|
|
1751
|
+
if (__hasOwnProp$2.call(b, prop))
|
|
1752
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1753
|
+
if (__getOwnPropSymbols$2)
|
|
1754
|
+
for (var prop of __getOwnPropSymbols$2(b)) {
|
|
1755
|
+
if (__propIsEnum$2.call(b, prop))
|
|
1756
|
+
__defNormalProp$2(a, prop, b[prop]);
|
|
1354
1757
|
}
|
|
1355
1758
|
return a;
|
|
1356
1759
|
};
|
|
1357
|
-
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1760
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
1358
1761
|
function useRenderingStrategy(options) {
|
|
1359
1762
|
const manifest = useManifest();
|
|
1360
1763
|
const canvas = useCanvas();
|
|
@@ -1366,15 +1769,19 @@ function useRenderingStrategy(options) {
|
|
|
1366
1769
|
const enabledPages = useResources(enabledPageIds, "AnnotationPage");
|
|
1367
1770
|
const supports = (options == null ? void 0 : options.strategies) || ["images", "media", "complex-timeline"];
|
|
1368
1771
|
const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
|
|
1369
|
-
const strategy = React.useMemo(() => {
|
|
1772
|
+
const strategy = React$1.useMemo(() => {
|
|
1370
1773
|
if (!canvas || paintables.types.length === 0) {
|
|
1371
1774
|
return unknownResponse;
|
|
1372
1775
|
}
|
|
1373
1776
|
if (paintables.types.length !== 1) {
|
|
1374
|
-
if (
|
|
1375
|
-
|
|
1777
|
+
if (paintables.types.length === 2 && paintables.types.indexOf("text") !== -1) {
|
|
1778
|
+
paintables.types = paintables.types.filter((t) => t !== "text");
|
|
1779
|
+
} else {
|
|
1780
|
+
if (supports.indexOf("complex-timeline") === -1) {
|
|
1781
|
+
return unsupportedStrategy("Complex timeline not supported");
|
|
1782
|
+
}
|
|
1783
|
+
return unsupportedStrategy("ComplexTimelineStrategy not yet supported");
|
|
1376
1784
|
}
|
|
1377
|
-
return unsupportedStrategy("ComplexTimelineStrategy not yet supported");
|
|
1378
1785
|
}
|
|
1379
1786
|
const mainType = paintables.types[0];
|
|
1380
1787
|
if (mainType === "image") {
|
|
@@ -1383,32 +1790,32 @@ function useRenderingStrategy(options) {
|
|
|
1383
1790
|
}
|
|
1384
1791
|
return getImageStrategy(canvas, paintables, loadImageService);
|
|
1385
1792
|
}
|
|
1386
|
-
if (mainType === "Model") {
|
|
1793
|
+
if (mainType === "Model" || mainType === "model") {
|
|
1387
1794
|
if (supports.indexOf("3d-model") === -1) {
|
|
1388
1795
|
return unsupportedStrategy("3D not supported");
|
|
1389
1796
|
}
|
|
1390
1797
|
return get3dStrategy(canvas, paintables);
|
|
1391
1798
|
}
|
|
1392
|
-
if (mainType === "audio") {
|
|
1799
|
+
if (mainType === "sound" || mainType === "audio") {
|
|
1393
1800
|
if (supports.indexOf("media") === -1) {
|
|
1394
1801
|
return unsupportedStrategy("Media not supported");
|
|
1395
1802
|
}
|
|
1396
|
-
return
|
|
1803
|
+
return getAudioStrategy(canvas, paintables);
|
|
1397
1804
|
}
|
|
1398
1805
|
if (mainType === "video") {
|
|
1399
1806
|
if (supports.indexOf("media") === -1) {
|
|
1400
1807
|
return unsupportedStrategy("Media not supported");
|
|
1401
1808
|
}
|
|
1402
|
-
return
|
|
1809
|
+
return getVideoStrategy(canvas, paintables);
|
|
1403
1810
|
}
|
|
1404
1811
|
return unknownResponse;
|
|
1405
1812
|
}, [canvas, paintables, vault, actions.makeChoice]);
|
|
1406
|
-
return React.useMemo(() => {
|
|
1813
|
+
return React$1.useMemo(() => {
|
|
1407
1814
|
if (strategy.type === "unknown") {
|
|
1408
1815
|
return [strategy, emptyActions];
|
|
1409
1816
|
}
|
|
1410
1817
|
return [
|
|
1411
|
-
__spreadProps(__spreadValues$
|
|
1818
|
+
__spreadProps$1(__spreadValues$2({}, strategy), {
|
|
1412
1819
|
annotations: { pages: enabledPages }
|
|
1413
1820
|
}),
|
|
1414
1821
|
actions
|
|
@@ -1418,7 +1825,7 @@ function useRenderingStrategy(options) {
|
|
|
1418
1825
|
|
|
1419
1826
|
const useVaultEffect = (callback, deps = []) => {
|
|
1420
1827
|
const vault = useVault();
|
|
1421
|
-
React.useEffect(() => {
|
|
1828
|
+
React$1.useEffect(() => {
|
|
1422
1829
|
callback(vault);
|
|
1423
1830
|
}, [vault, ...deps]);
|
|
1424
1831
|
};
|
|
@@ -1426,13 +1833,13 @@ const useVaultEffect = (callback, deps = []) => {
|
|
|
1426
1833
|
function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
1427
1834
|
const vault = useVault();
|
|
1428
1835
|
const loader = useImageServiceLoader();
|
|
1429
|
-
const helper = React.useMemo(() => vaultHelpers.createThumbnailHelper(vault, { imageServiceLoader: loader }), [vault, loader]);
|
|
1430
|
-
const [thumbnail, setThumbnail] = React.useState();
|
|
1836
|
+
const helper = React$1.useMemo(() => vaultHelpers.createThumbnailHelper(vault, { imageServiceLoader: loader }), [vault, loader]);
|
|
1837
|
+
const [thumbnail, setThumbnail] = React$1.useState();
|
|
1431
1838
|
const manifest = useManifest(manifestId ? { id: manifestId } : void 0);
|
|
1432
1839
|
const canvas = useCanvas(canvasId ? { id: canvasId } : void 0);
|
|
1433
1840
|
const subject = canvas ? canvas : manifest;
|
|
1434
|
-
const didUnmount = React.useRef(false);
|
|
1435
|
-
React.useEffect(() => {
|
|
1841
|
+
const didUnmount = React$1.useRef(false);
|
|
1842
|
+
React$1.useEffect(() => {
|
|
1436
1843
|
return () => {
|
|
1437
1844
|
didUnmount.current = true;
|
|
1438
1845
|
};
|
|
@@ -1450,6 +1857,283 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
|
1450
1857
|
return thumbnail;
|
|
1451
1858
|
}
|
|
1452
1859
|
|
|
1860
|
+
var __defProp$1 = Object.defineProperty;
|
|
1861
|
+
var __defProps = Object.defineProperties;
|
|
1862
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
1863
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
1864
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
1865
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
1866
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
1867
|
+
var __spreadValues$1 = (a, b) => {
|
|
1868
|
+
for (var prop in b || (b = {}))
|
|
1869
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
1870
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1871
|
+
if (__getOwnPropSymbols$1)
|
|
1872
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
1873
|
+
if (__propIsEnum$1.call(b, prop))
|
|
1874
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
1875
|
+
}
|
|
1876
|
+
return a;
|
|
1877
|
+
};
|
|
1878
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
1879
|
+
function getDefaultState(duration) {
|
|
1880
|
+
return { isMuted: false, playRequested: false, isPlaying: false, isFinished: false, volume: 100, duration };
|
|
1881
|
+
}
|
|
1882
|
+
function reducer(state, action) {
|
|
1883
|
+
switch (action.type) {
|
|
1884
|
+
case "FINISHED":
|
|
1885
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: true, isPlaying: false, playRequested: false });
|
|
1886
|
+
case "PLAY_PAUSE":
|
|
1887
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: false, isPlaying: !state.isPlaying });
|
|
1888
|
+
case "PLAY_REQUESTED":
|
|
1889
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: false, playRequested: true });
|
|
1890
|
+
case "PAUSE":
|
|
1891
|
+
return __spreadProps(__spreadValues$1({}, state), { isPlaying: false });
|
|
1892
|
+
case "PLAY":
|
|
1893
|
+
return __spreadProps(__spreadValues$1({}, state), { isFinished: false, playRequested: false, isPlaying: true });
|
|
1894
|
+
case "MUTE":
|
|
1895
|
+
return __spreadProps(__spreadValues$1({}, state), { isMuted: true });
|
|
1896
|
+
case "SET_VOLUME":
|
|
1897
|
+
return __spreadProps(__spreadValues$1({}, state), { volume: action.volume, isMuted: action.volume === 0 });
|
|
1898
|
+
case "TOGGLE_MUTE":
|
|
1899
|
+
return __spreadProps(__spreadValues$1({}, state), { isMuted: !state.isMuted });
|
|
1900
|
+
case "UNMUTE":
|
|
1901
|
+
return __spreadProps(__spreadValues$1({}, state), { isMuted: false });
|
|
1902
|
+
}
|
|
1903
|
+
return state;
|
|
1904
|
+
}
|
|
1905
|
+
function formatTime(time) {
|
|
1906
|
+
const seconds = Math.round(time);
|
|
1907
|
+
return `${Math.floor(seconds / 60)}:${`${seconds % 60}`.padStart(2, "0")}`;
|
|
1908
|
+
}
|
|
1909
|
+
function useSimpleMediaPlayer(props) {
|
|
1910
|
+
const [state, dispatch] = React$1.useReducer(reducer, getDefaultState(props.duration));
|
|
1911
|
+
const media = React$1.useRef(null);
|
|
1912
|
+
const currentTime = React$1.useRef(null);
|
|
1913
|
+
const progress = React$1.useRef(null);
|
|
1914
|
+
const _isMuted = React$1.useRef(false);
|
|
1915
|
+
const _updateCurrentTime = React$1.useCallback(() => {
|
|
1916
|
+
if (currentTime.current && media.current) {
|
|
1917
|
+
currentTime.current.innerHTML = formatTime(media.current.currentTime);
|
|
1918
|
+
if (progress.current) {
|
|
1919
|
+
progress.current.style.width = `${media.current.currentTime / props.duration * 100}%`;
|
|
1920
|
+
}
|
|
1921
|
+
if (_isMuted.current !== media.current.muted) {
|
|
1922
|
+
_isMuted.current = media.current.muted;
|
|
1923
|
+
dispatch(media.current.muted ? { type: "MUTE" } : { type: "UNMUTE" });
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
}, [props.duration]);
|
|
1927
|
+
const play = React$1.useCallback(() => {
|
|
1928
|
+
if (media.current) {
|
|
1929
|
+
dispatch({ type: "PLAY_REQUESTED" });
|
|
1930
|
+
media.current.play().then(() => {
|
|
1931
|
+
dispatch({ type: "PLAY" });
|
|
1932
|
+
});
|
|
1933
|
+
_updateCurrentTime();
|
|
1934
|
+
}
|
|
1935
|
+
}, [_updateCurrentTime]);
|
|
1936
|
+
const playPause = React$1.useCallback(() => {
|
|
1937
|
+
if (media.current) {
|
|
1938
|
+
if (media.current.duration > 0 && media.current.paused) {
|
|
1939
|
+
play();
|
|
1940
|
+
} else {
|
|
1941
|
+
pause();
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
}, [_updateCurrentTime]);
|
|
1945
|
+
const pause = React$1.useCallback(() => {
|
|
1946
|
+
if (media.current) {
|
|
1947
|
+
media.current.pause();
|
|
1948
|
+
dispatch({ type: "PAUSE" });
|
|
1949
|
+
_updateCurrentTime();
|
|
1950
|
+
}
|
|
1951
|
+
}, [_updateCurrentTime]);
|
|
1952
|
+
const toggleMute = React$1.useCallback(() => {
|
|
1953
|
+
if (media.current) {
|
|
1954
|
+
media.current.muted = !media.current.muted;
|
|
1955
|
+
dispatch(media.current.muted ? { type: "MUTE" } : { type: "UNMUTE" });
|
|
1956
|
+
}
|
|
1957
|
+
}, []);
|
|
1958
|
+
const mute = React$1.useCallback(() => {
|
|
1959
|
+
if (media.current) {
|
|
1960
|
+
media.current.muted = true;
|
|
1961
|
+
dispatch({ type: "MUTE" });
|
|
1962
|
+
}
|
|
1963
|
+
}, []);
|
|
1964
|
+
const unmute = React$1.useCallback(() => {
|
|
1965
|
+
if (media.current) {
|
|
1966
|
+
media.current.muted = false;
|
|
1967
|
+
dispatch({ type: "UNMUTE" });
|
|
1968
|
+
}
|
|
1969
|
+
}, []);
|
|
1970
|
+
const setVolume = React$1.useCallback((newVolume) => {
|
|
1971
|
+
if (media.current) {
|
|
1972
|
+
media.current.muted = false;
|
|
1973
|
+
media.current.volume = newVolume / 100;
|
|
1974
|
+
dispatch({ type: "SET_VOLUME", volume: newVolume });
|
|
1975
|
+
}
|
|
1976
|
+
}, []);
|
|
1977
|
+
const setDurationPercent = React$1.useCallback((percent) => {
|
|
1978
|
+
if (media.current) {
|
|
1979
|
+
media.current.currentTime = Math.max(0, Math.min(percent * props.duration, props.duration));
|
|
1980
|
+
_updateCurrentTime();
|
|
1981
|
+
}
|
|
1982
|
+
}, []);
|
|
1983
|
+
const setTime = React$1.useCallback((time) => {
|
|
1984
|
+
if (media.current) {
|
|
1985
|
+
media.current.currentTime = Math.max(0, Math.min(time, props.duration));
|
|
1986
|
+
_updateCurrentTime();
|
|
1987
|
+
}
|
|
1988
|
+
}, []);
|
|
1989
|
+
React$1.useEffect(() => {
|
|
1990
|
+
const interval = setInterval(() => {
|
|
1991
|
+
_updateCurrentTime();
|
|
1992
|
+
}, 350);
|
|
1993
|
+
return () => clearInterval(interval);
|
|
1994
|
+
}, [_updateCurrentTime, props.duration]);
|
|
1995
|
+
React$1.useEffect(() => {
|
|
1996
|
+
const ended = () => {
|
|
1997
|
+
dispatch({ type: "FINISHED" });
|
|
1998
|
+
};
|
|
1999
|
+
const _media = media.current;
|
|
2000
|
+
_media == null ? void 0 : _media.addEventListener("ended", ended);
|
|
2001
|
+
return () => _media == null ? void 0 : _media.removeEventListener("ended", ended);
|
|
2002
|
+
}, []);
|
|
2003
|
+
return [
|
|
2004
|
+
{ element: media, currentTime, progress },
|
|
2005
|
+
state,
|
|
2006
|
+
{
|
|
2007
|
+
play,
|
|
2008
|
+
pause,
|
|
2009
|
+
playPause,
|
|
2010
|
+
mute,
|
|
2011
|
+
unmute,
|
|
2012
|
+
toggleMute,
|
|
2013
|
+
setVolume,
|
|
2014
|
+
setDurationPercent,
|
|
2015
|
+
setTime
|
|
2016
|
+
}
|
|
2017
|
+
];
|
|
2018
|
+
}
|
|
2019
|
+
|
|
2020
|
+
const MediaReactContextState = React$1.createContext(null);
|
|
2021
|
+
const MediaReactContextActions = React$1.createContext(null);
|
|
2022
|
+
const MediaReactContextElements = React$1.createContext(null);
|
|
2023
|
+
function useMediaState() {
|
|
2024
|
+
const ctx = React$1.useContext(MediaReactContextState);
|
|
2025
|
+
if (!ctx) {
|
|
2026
|
+
throw new Error("Ctx not found");
|
|
2027
|
+
}
|
|
2028
|
+
return ctx;
|
|
2029
|
+
}
|
|
2030
|
+
function useMediaActions() {
|
|
2031
|
+
const ctx = React$1.useContext(MediaReactContextActions);
|
|
2032
|
+
if (!ctx) {
|
|
2033
|
+
throw new Error("Ctx not found");
|
|
2034
|
+
}
|
|
2035
|
+
return ctx;
|
|
2036
|
+
}
|
|
2037
|
+
function useMediaElements() {
|
|
2038
|
+
const ctx = React$1.useContext(MediaReactContextElements);
|
|
2039
|
+
if (!ctx) {
|
|
2040
|
+
throw new Error("Ctx not found");
|
|
2041
|
+
}
|
|
2042
|
+
return ctx;
|
|
2043
|
+
}
|
|
2044
|
+
function MediaPlayerProvider({
|
|
2045
|
+
actions,
|
|
2046
|
+
state,
|
|
2047
|
+
children,
|
|
2048
|
+
currentTime,
|
|
2049
|
+
progress,
|
|
2050
|
+
element
|
|
2051
|
+
}) {
|
|
2052
|
+
return /* @__PURE__ */ React.createElement(MediaReactContextElements.Provider, {
|
|
2053
|
+
value: { currentTime, progress, element }
|
|
2054
|
+
}, /* @__PURE__ */ React.createElement(MediaReactContextActions.Provider, {
|
|
2055
|
+
value: actions
|
|
2056
|
+
}, /* @__PURE__ */ React.createElement(MediaReactContextState.Provider, {
|
|
2057
|
+
value: state
|
|
2058
|
+
}, children)));
|
|
2059
|
+
}
|
|
2060
|
+
|
|
2061
|
+
function Audio({ media, children }) {
|
|
2062
|
+
const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });
|
|
2063
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CanvasPortal, null, /* @__PURE__ */ React.createElement(MediaPlayerProvider, {
|
|
2064
|
+
state,
|
|
2065
|
+
actions,
|
|
2066
|
+
currentTime,
|
|
2067
|
+
progress,
|
|
2068
|
+
element
|
|
2069
|
+
}, /* @__PURE__ */ React.createElement("audio", {
|
|
2070
|
+
ref: element,
|
|
2071
|
+
src: media.url
|
|
2072
|
+
}), children)));
|
|
2073
|
+
}
|
|
2074
|
+
|
|
2075
|
+
function Video({ media, children }) {
|
|
2076
|
+
const [{ element, currentTime, progress }, state, actions] = useSimpleMediaPlayer({ duration: media.duration });
|
|
2077
|
+
const Component = "div";
|
|
2078
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(CanvasPortal, {
|
|
2079
|
+
overlay: true
|
|
2080
|
+
}, /* @__PURE__ */ React.createElement("style", null, `
|
|
2081
|
+
.video-container {
|
|
2082
|
+
position: absolute;
|
|
2083
|
+
top: 0;
|
|
2084
|
+
bottom: 0;
|
|
2085
|
+
left: 0;
|
|
2086
|
+
right: 0;
|
|
2087
|
+
background: #000;
|
|
2088
|
+
z-index: 13;
|
|
2089
|
+
display: flex;
|
|
2090
|
+
justify-content: center;
|
|
2091
|
+
pointer-events: visible;
|
|
2092
|
+
}
|
|
2093
|
+
`), /* @__PURE__ */ React.createElement(Component, {
|
|
2094
|
+
className: "video-container",
|
|
2095
|
+
part: "video-container",
|
|
2096
|
+
onClick: () => actions.playPause()
|
|
2097
|
+
}, /* @__PURE__ */ React.createElement("video", {
|
|
2098
|
+
ref: element,
|
|
2099
|
+
src: media.url,
|
|
2100
|
+
style: { width: "100%", objectFit: "contain" }
|
|
2101
|
+
}))), /* @__PURE__ */ React.createElement(CanvasPortal, null, /* @__PURE__ */ React.createElement(MediaPlayerProvider, {
|
|
2102
|
+
state,
|
|
2103
|
+
actions,
|
|
2104
|
+
currentTime,
|
|
2105
|
+
progress,
|
|
2106
|
+
element
|
|
2107
|
+
}, children)));
|
|
2108
|
+
}
|
|
2109
|
+
|
|
2110
|
+
function Model({ model }) {
|
|
2111
|
+
return /* @__PURE__ */ React.createElement(CanvasPortal, {
|
|
2112
|
+
overlay: true
|
|
2113
|
+
}, /* @__PURE__ */ React.createElement("style", null, `
|
|
2114
|
+
.model-container {
|
|
2115
|
+
position: absolute;
|
|
2116
|
+
top: 0;
|
|
2117
|
+
bottom: 0;
|
|
2118
|
+
left: 0;
|
|
2119
|
+
right: 0;
|
|
2120
|
+
background: #000;
|
|
2121
|
+
z-index: 13;
|
|
2122
|
+
display: flex;
|
|
2123
|
+
justify-content: center;
|
|
2124
|
+
pointer-events: visible;
|
|
2125
|
+
}
|
|
2126
|
+
`), /* @__PURE__ */ React.createElement("div", {
|
|
2127
|
+
className: "model-container"
|
|
2128
|
+
}, /* @__PURE__ */ React.createElement("model-viewer", {
|
|
2129
|
+
"interaction-prompt": "none",
|
|
2130
|
+
style: { width: "100%", height: "100%" },
|
|
2131
|
+
"camera-controls": "",
|
|
2132
|
+
"ar-status": "not-presenting",
|
|
2133
|
+
src: model.id
|
|
2134
|
+
})));
|
|
2135
|
+
}
|
|
2136
|
+
|
|
1453
2137
|
var __defProp = Object.defineProperty;
|
|
1454
2138
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
1455
2139
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -1466,23 +2150,34 @@ var __spreadValues = (a, b) => {
|
|
|
1466
2150
|
}
|
|
1467
2151
|
return a;
|
|
1468
2152
|
};
|
|
1469
|
-
function RenderCanvas({
|
|
2153
|
+
function RenderCanvas({
|
|
2154
|
+
x,
|
|
2155
|
+
y,
|
|
2156
|
+
onChoiceChange,
|
|
2157
|
+
registerActions,
|
|
2158
|
+
defaultChoices,
|
|
2159
|
+
isStatic,
|
|
2160
|
+
renderViewerControls,
|
|
2161
|
+
renderMediaControls,
|
|
2162
|
+
strategies,
|
|
2163
|
+
children
|
|
2164
|
+
}) {
|
|
1470
2165
|
const canvas = useCanvas();
|
|
1471
2166
|
const elementProps = useResourceEvents(canvas, ["deep-zoom"]);
|
|
1472
2167
|
const [virtualPage] = useVirtualAnnotationPageContext();
|
|
1473
2168
|
const vault = useVault();
|
|
1474
|
-
const helper = React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
2169
|
+
const helper = React$1.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
1475
2170
|
const [strategy, actions] = useRenderingStrategy({
|
|
1476
|
-
strategies: ["images"],
|
|
2171
|
+
strategies: strategies || ["images"],
|
|
1477
2172
|
defaultChoices: defaultChoices == null ? void 0 : defaultChoices.map(({ id }) => id)
|
|
1478
2173
|
});
|
|
1479
2174
|
const choice = strategy.type === "images" ? strategy.choice : void 0;
|
|
1480
|
-
React.useEffect(() => {
|
|
2175
|
+
React$1.useEffect(() => {
|
|
1481
2176
|
if (registerActions) {
|
|
1482
2177
|
registerActions(actions);
|
|
1483
2178
|
}
|
|
1484
2179
|
}, [strategy.annotations]);
|
|
1485
|
-
React.useEffect(() => {
|
|
2180
|
+
React$1.useEffect(() => {
|
|
1486
2181
|
if (defaultChoices) {
|
|
1487
2182
|
for (const choice2 of defaultChoices) {
|
|
1488
2183
|
if (typeof choice2.opacity !== "undefined") {
|
|
@@ -1493,7 +2188,7 @@ function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, i
|
|
|
1493
2188
|
}
|
|
1494
2189
|
}
|
|
1495
2190
|
}, [defaultChoices]);
|
|
1496
|
-
React.useLayoutEffect(() => {
|
|
2191
|
+
React$1.useLayoutEffect(() => {
|
|
1497
2192
|
if (onChoiceChange) {
|
|
1498
2193
|
onChoiceChange(choice);
|
|
1499
2194
|
}
|
|
@@ -1502,39 +2197,41 @@ function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, i
|
|
|
1502
2197
|
if (!canvas) {
|
|
1503
2198
|
return null;
|
|
1504
2199
|
}
|
|
2200
|
+
const accompanyingCanvas = canvas.accompanyingCanvas;
|
|
2201
|
+
const thumbnailFallbackImage = thumbnail && thumbnail.type === "fixed" ? /* @__PURE__ */ React__default["default"].createElement("world-object", {
|
|
2202
|
+
height: canvas.height,
|
|
2203
|
+
width: canvas.width,
|
|
2204
|
+
x,
|
|
2205
|
+
y
|
|
2206
|
+
}, /* @__PURE__ */ React__default["default"].createElement("world-image", {
|
|
2207
|
+
uri: thumbnail.id,
|
|
2208
|
+
target: { x: 0, y: 0, width: canvas.width, height: canvas.height },
|
|
2209
|
+
display: thumbnail.width && thumbnail.height ? {
|
|
2210
|
+
width: thumbnail.width,
|
|
2211
|
+
height: thumbnail.height
|
|
2212
|
+
} : void 0
|
|
2213
|
+
})) : null;
|
|
1505
2214
|
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");
|
|
2215
|
+
if (thumbnailFallbackImage) {
|
|
2216
|
+
return thumbnailFallbackImage;
|
|
2217
|
+
}
|
|
2218
|
+
throw new Error(strategy.reason || "Unknown image strategy");
|
|
1522
2219
|
}
|
|
1523
|
-
const annotations = /* @__PURE__ */ React__default["default"].createElement(React.Fragment, null, virtualPage ? /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
2220
|
+
const annotations = /* @__PURE__ */ React__default["default"].createElement(React$1.Fragment, null, virtualPage ? /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
1524
2221
|
page: virtualPage
|
|
1525
2222
|
}) : null, strategy.annotations && strategy.annotations.pages ? strategy.annotations.pages.map((page) => {
|
|
1526
2223
|
return /* @__PURE__ */ React__default["default"].createElement(RenderAnnotationPage, {
|
|
1527
2224
|
key: page.id,
|
|
1528
2225
|
page
|
|
1529
2226
|
});
|
|
1530
|
-
}) : null);
|
|
1531
|
-
return /* @__PURE__ */ React__default["default"].createElement("world-object", __spreadValues({
|
|
2227
|
+
}) : null, children);
|
|
2228
|
+
return /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, /* @__PURE__ */ React__default["default"].createElement("world-object", __spreadValues({
|
|
1532
2229
|
key: strategy.type,
|
|
1533
2230
|
height: canvas.height,
|
|
1534
2231
|
width: canvas.width,
|
|
1535
2232
|
x,
|
|
1536
2233
|
y
|
|
1537
|
-
}, elementProps), strategy.type === "images" ? strategy.images.map((image, idx) => {
|
|
2234
|
+
}, elementProps), strategy.type === "images" ? /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, strategy.images.map((image, idx) => {
|
|
1538
2235
|
return /* @__PURE__ */ React__default["default"].createElement(RenderImage, {
|
|
1539
2236
|
isStatic,
|
|
1540
2237
|
key: image.id,
|
|
@@ -1543,7 +2240,17 @@ function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, i
|
|
|
1543
2240
|
thumbnail: idx === 0 ? thumbnail : void 0,
|
|
1544
2241
|
annotations
|
|
1545
2242
|
});
|
|
1546
|
-
})
|
|
2243
|
+
}), renderViewerControls ? /* @__PURE__ */ React__default["default"].createElement(CanvasPortal, {
|
|
2244
|
+
overlay: true
|
|
2245
|
+
}, renderViewerControls(strategy)) : null) : null, strategy.type === "3d-model" ? /* @__PURE__ */ React__default["default"].createElement(Model, {
|
|
2246
|
+
model: strategy.model
|
|
2247
|
+
}) : null, strategy.type === "media" ? /* @__PURE__ */ React__default["default"].createElement(React__default["default"].Fragment, null, strategy.media.type === "Sound" ? /* @__PURE__ */ React__default["default"].createElement(Audio, {
|
|
2248
|
+
media: strategy.media
|
|
2249
|
+
}, thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null) : strategy.media.type === "Video" ? /* @__PURE__ */ React__default["default"].createElement(Video, {
|
|
2250
|
+
media: strategy.media
|
|
2251
|
+
}, thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null) : null) : null), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ React__default["default"].createElement(CanvasContext, {
|
|
2252
|
+
canvas: accompanyingCanvas.id
|
|
2253
|
+
}, /* @__PURE__ */ React__default["default"].createElement(RenderCanvas, null)) : null);
|
|
1547
2254
|
}
|
|
1548
2255
|
|
|
1549
2256
|
const CanvasPanel = {
|
|
@@ -1554,23 +2261,23 @@ const CanvasPanel = {
|
|
|
1554
2261
|
Viewer
|
|
1555
2262
|
};
|
|
1556
2263
|
|
|
1557
|
-
|
|
2264
|
+
function AnnotationContext({ annotation, children }) {
|
|
1558
2265
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1559
2266
|
value: { annotation }
|
|
1560
2267
|
}, children);
|
|
1561
|
-
}
|
|
2268
|
+
}
|
|
1562
2269
|
|
|
1563
|
-
|
|
2270
|
+
function CollectionContext({ collection, children }) {
|
|
1564
2271
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1565
2272
|
value: { collection }
|
|
1566
2273
|
}, children);
|
|
1567
|
-
}
|
|
2274
|
+
}
|
|
1568
2275
|
|
|
1569
|
-
|
|
2276
|
+
function RangeContext({ range, children }) {
|
|
1570
2277
|
return /* @__PURE__ */ React__default["default"].createElement(ResourceProvider, {
|
|
1571
2278
|
value: { range }
|
|
1572
2279
|
}, children);
|
|
1573
|
-
}
|
|
2280
|
+
}
|
|
1574
2281
|
|
|
1575
2282
|
function useAnnotationsAtTime(time, options = {}) {
|
|
1576
2283
|
const allAnnotations = usePaintingAnnotations(options);
|
|
@@ -1585,7 +2292,7 @@ function useCollection(options, deps = []) {
|
|
|
1585
2292
|
const ctx = useResourceContext();
|
|
1586
2293
|
const collectionId = id ? id : ctx.collection;
|
|
1587
2294
|
const collection = useVaultSelector((s) => collectionId ? s.iiif.entities.Collection[collectionId] : void 0, [collectionId]);
|
|
1588
|
-
return React.useMemo(() => {
|
|
2295
|
+
return React$1.useMemo(() => {
|
|
1589
2296
|
if (!collection) {
|
|
1590
2297
|
return void 0;
|
|
1591
2298
|
}
|
|
@@ -1598,8 +2305,8 @@ function useCollection(options, deps = []) {
|
|
|
1598
2305
|
|
|
1599
2306
|
function useEventListener(resource, name, listener, scope, deps = []) {
|
|
1600
2307
|
const vault = useVault();
|
|
1601
|
-
const helper = React.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
1602
|
-
React.useEffect(() => {
|
|
2308
|
+
const helper = React$1.useMemo(() => vaultHelpers.createEventsHelper(vault), [vault]);
|
|
2309
|
+
React$1.useEffect(() => {
|
|
1603
2310
|
const currentResource = resource;
|
|
1604
2311
|
if (!currentResource) {
|
|
1605
2312
|
return () => {
|
|
@@ -1613,7 +2320,7 @@ function useEventListener(resource, name, listener, scope, deps = []) {
|
|
|
1613
2320
|
}
|
|
1614
2321
|
|
|
1615
2322
|
function useExistingVault() {
|
|
1616
|
-
const oldContext = React.useContext(ReactVaultContext);
|
|
2323
|
+
const oldContext = React$1.useContext(ReactVaultContext);
|
|
1617
2324
|
return oldContext && oldContext.vault ? oldContext.vault : vault.globalVault();
|
|
1618
2325
|
}
|
|
1619
2326
|
|
|
@@ -1647,12 +2354,12 @@ function useImageService({ cacheKey } = {}) {
|
|
|
1647
2354
|
const annotations = usePaintingAnnotations();
|
|
1648
2355
|
const vault = useVault();
|
|
1649
2356
|
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);
|
|
2357
|
+
const [_data, setData] = React$1.useState(void 0);
|
|
2358
|
+
const [isFetching, setIsFetching] = React$1.useState(false);
|
|
2359
|
+
const [status, setStatus] = React$1.useState("idle");
|
|
2360
|
+
const [error, setError] = React$1.useState(void 0);
|
|
1654
2361
|
const key = canvas ? canvas.id : "undefined";
|
|
1655
|
-
const initialData = React.useMemo(() => {
|
|
2362
|
+
const initialData = React$1.useMemo(() => {
|
|
1656
2363
|
try {
|
|
1657
2364
|
if (canvas && annotations.length) {
|
|
1658
2365
|
const annotation = annotations[0];
|
|
@@ -1674,7 +2381,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
1674
2381
|
return void 0;
|
|
1675
2382
|
}, [key, cacheKey, canvas]);
|
|
1676
2383
|
const data = status === "success" && _data ? _data : initialData;
|
|
1677
|
-
React.useEffect(() => {
|
|
2384
|
+
React$1.useEffect(() => {
|
|
1678
2385
|
(() => __async(this, null, function* () {
|
|
1679
2386
|
try {
|
|
1680
2387
|
if (canvas && annotations.length) {
|
|
@@ -1707,7 +2414,7 @@ function useImageService({ cacheKey } = {}) {
|
|
|
1707
2414
|
}
|
|
1708
2415
|
}))();
|
|
1709
2416
|
}, [key, cacheKey]);
|
|
1710
|
-
return React.useMemo(() => {
|
|
2417
|
+
return React$1.useMemo(() => {
|
|
1711
2418
|
return {
|
|
1712
2419
|
data,
|
|
1713
2420
|
isFetching,
|
|
@@ -1736,7 +2443,7 @@ function useRange(options = {}, deps = []) {
|
|
|
1736
2443
|
const ctx = useResourceContext();
|
|
1737
2444
|
const rangeId = id ? id : ctx.range;
|
|
1738
2445
|
const range = useVaultSelector((s) => rangeId ? s.iiif.entities.Range[rangeId] : void 0, [rangeId]);
|
|
1739
|
-
return React.useMemo(() => {
|
|
2446
|
+
return React$1.useMemo(() => {
|
|
1740
2447
|
if (!range) {
|
|
1741
2448
|
return void 0;
|
|
1742
2449
|
}
|
|
@@ -1754,16 +2461,20 @@ function useSearchService() {
|
|
|
1754
2461
|
|
|
1755
2462
|
function useStyleHelper() {
|
|
1756
2463
|
const vault = useVault();
|
|
1757
|
-
return React.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
2464
|
+
return React$1.useMemo(() => vaultHelpers.createStylesHelper(vault), [vault]);
|
|
1758
2465
|
}
|
|
1759
2466
|
|
|
1760
2467
|
exports.AnnotationContext = AnnotationContext;
|
|
1761
2468
|
exports.CanvasContext = CanvasContext;
|
|
1762
2469
|
exports.CanvasPanel = CanvasPanel;
|
|
2470
|
+
exports.CanvasPortal = CanvasPortal;
|
|
1763
2471
|
exports.CollectionContext = CollectionContext;
|
|
1764
2472
|
exports.ContextBridge = ContextBridge;
|
|
1765
2473
|
exports.ImageServiceLoaderContext = ImageServiceLoaderContext;
|
|
1766
2474
|
exports.ManifestContext = ManifestContext;
|
|
2475
|
+
exports.MediaPlayerProvider = MediaPlayerProvider;
|
|
2476
|
+
exports.OverlayPortalContext = OverlayPortalContext;
|
|
2477
|
+
exports.PortalContext = PortalContext;
|
|
1767
2478
|
exports.RangeContext = RangeContext;
|
|
1768
2479
|
exports.ReactVaultContext = ReactVaultContext;
|
|
1769
2480
|
exports.ResourceProvider = ResourceProvider;
|
|
@@ -1771,11 +2482,13 @@ exports.ResourceReactContext = ResourceReactContext;
|
|
|
1771
2482
|
exports.SimpleViewerProvider = SimpleViewerProvider;
|
|
1772
2483
|
exports.SimpleViewerReactContext = SimpleViewerReactContext;
|
|
1773
2484
|
exports.VaultProvider = VaultProvider;
|
|
2485
|
+
exports.ViewerPresetContext = ViewerPresetContext;
|
|
1774
2486
|
exports.VirtualAnnotationProvider = VirtualAnnotationProvider;
|
|
1775
2487
|
exports.VisibleCanvasReactContext = VisibleCanvasReactContext;
|
|
1776
2488
|
exports.emptyActions = emptyActions;
|
|
1777
2489
|
exports.expandTarget = expandTarget;
|
|
1778
2490
|
exports.flattenAnnotationPageIds = flattenAnnotationPageIds;
|
|
2491
|
+
exports.formatTime = formatTime;
|
|
1779
2492
|
exports.getImageStrategy = getImageStrategy;
|
|
1780
2493
|
exports.getPaintables = getPaintables;
|
|
1781
2494
|
exports.parseSelector = parseSelector;
|
|
@@ -1800,6 +2513,9 @@ exports.useImageServiceLoader = useImageServiceLoader;
|
|
|
1800
2513
|
exports.useImageTile = useImageTile;
|
|
1801
2514
|
exports.useLoadImageService = useLoadImageService;
|
|
1802
2515
|
exports.useManifest = useManifest;
|
|
2516
|
+
exports.useMediaActions = useMediaActions;
|
|
2517
|
+
exports.useMediaElements = useMediaElements;
|
|
2518
|
+
exports.useMediaState = useMediaState;
|
|
1803
2519
|
exports.usePaintables = usePaintables;
|
|
1804
2520
|
exports.usePaintingAnnotations = usePaintingAnnotations;
|
|
1805
2521
|
exports.useRange = useRange;
|
|
@@ -1808,6 +2524,7 @@ exports.useResourceContext = useResourceContext;
|
|
|
1808
2524
|
exports.useResourceEvents = useResourceEvents;
|
|
1809
2525
|
exports.useResources = useResources;
|
|
1810
2526
|
exports.useSearchService = useSearchService;
|
|
2527
|
+
exports.useSimpleMediaPlayer = useSimpleMediaPlayer;
|
|
1811
2528
|
exports.useSimpleViewer = useSimpleViewer;
|
|
1812
2529
|
exports.useStyleHelper = useStyleHelper;
|
|
1813
2530
|
exports.useStyles = useStyles;
|
|
@@ -1815,6 +2532,7 @@ exports.useThumbnail = useThumbnail;
|
|
|
1815
2532
|
exports.useVault = useVault;
|
|
1816
2533
|
exports.useVaultEffect = useVaultEffect;
|
|
1817
2534
|
exports.useVaultSelector = useVaultSelector;
|
|
2535
|
+
exports.useViewerPreset = useViewerPreset;
|
|
1818
2536
|
exports.useVirtualAnnotationPage = useVirtualAnnotationPage;
|
|
1819
2537
|
exports.useVirtualAnnotationPageContext = useVirtualAnnotationPageContext;
|
|
1820
2538
|
exports.useVisibleCanvases = useVisibleCanvases;
|