react-iiif-vault 0.9.13 → 0.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.build/types/canvas-panel/Viewer.d.ts +1 -1
- package/.build/types/canvas-panel/index.d.ts +2 -0
- package/.build/types/canvas-panel/render/Canvas.d.ts +8 -3
- package/.build/types/canvas-panel/render/CanvasBackground.d.ts +4 -0
- package/.build/types/canvas-panel/render/Image.d.ts +2 -2
- package/.build/types/context/ContextBridge.d.ts +1 -9
- package/.build/types/context/PortalContext.d.ts +3 -2
- package/.build/types/features/rendering-strategy/3d-strategy.d.ts +1 -1
- package/.build/types/features/rendering-strategy/rendering-utils.d.ts +5 -1
- package/.build/types/features/rendering-strategy/resource-types.d.ts +3 -0
- package/.build/types/features/rendering-strategy/strategies.d.ts +10 -1
- package/.build/types/features/rendering-strategy/textual-content-strategy.d.ts +17 -0
- package/.build/types/future-helpers/ranges.d.ts +6 -0
- package/.build/types/future-helpers/sequences.d.ts +6 -0
- package/.build/types/hooks/useCanvasSubset.d.ts +2 -0
- package/.build/types/index.d.ts +5 -0
- package/.build/types/viewers/SimpleViewerContext.d.ts +4 -16
- package/.build/types/viewers/SimpleViewerContext.hooks.d.ts +14 -0
- package/.build/types/viewers/SimpleViewerContext.types.d.ts +42 -0
- package/dist/bundle/cjs/index.js +5 -11
- package/dist/bundle/cjs/index.js.map +1 -1
- package/dist/bundle/esm/index.mjs +1034 -260
- package/dist/bundle/esm/index.mjs.map +1 -1
- package/dist/canvas-panel/cjs/canvas-panel.js +5 -11
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
- package/dist/canvas-panel/esm/canvas-panel.mjs +744 -141
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
- package/dist/index.umd.js +30 -36
- package/dist/index.umd.js.map +1 -1
- package/dist/react17/cjs/index.js +30 -0
- package/dist/react17/cjs/index.js.map +1 -0
- package/dist/react17/esm/index.mjs +3186 -0
- package/dist/react17/esm/index.mjs.map +1 -0
- package/package.json +16 -11
|
@@ -30,18 +30,20 @@ var __objRest = (source, exclude) => {
|
|
|
30
30
|
return target;
|
|
31
31
|
};
|
|
32
32
|
import * as React from "react";
|
|
33
|
-
import React__default, { useContext, useMemo, useState, useEffect, createContext, useRef, useLayoutEffect, useCallback, Fragment
|
|
34
|
-
import { AtlasAuto, mergeStyles, RegionHighlight, TileSet } from "@atlas-viewer/atlas";
|
|
33
|
+
import React__default, { useContext, useMemo, useState, useEffect, createContext, useRef, useLayoutEffect, useCallback, Fragment, useReducer } from "react";
|
|
34
|
+
import { AtlasAuto, mergeStyles, RegionHighlight, TileSet, HTMLPortal } from "@atlas-viewer/atlas";
|
|
35
|
+
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
35
36
|
import { globalVault, Vault } from "@iiif/vault";
|
|
36
37
|
import { createAction } from "typesafe-actions";
|
|
37
|
-
import
|
|
38
|
+
import { createRoot } from "react-dom/client";
|
|
39
|
+
import { expandTarget as expandTarget$1 } from "@iiif/vault-helpers";
|
|
38
40
|
import { ImageServiceLoader, getImageServices, getFixedSizeFromImage } from "@atlas-viewer/iiif-image-api";
|
|
39
|
-
function _setPrototypeOf(o,
|
|
40
|
-
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2,
|
|
41
|
-
o2.__proto__ =
|
|
41
|
+
function _setPrototypeOf(o, p) {
|
|
42
|
+
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
|
43
|
+
o2.__proto__ = p2;
|
|
42
44
|
return o2;
|
|
43
45
|
};
|
|
44
|
-
return _setPrototypeOf(o,
|
|
46
|
+
return _setPrototypeOf(o, p);
|
|
45
47
|
}
|
|
46
48
|
function _inheritsLoose(subClass, superClass) {
|
|
47
49
|
subClass.prototype = Object.create(superClass.prototype);
|
|
@@ -125,39 +127,6 @@ var ErrorBoundary = /* @__PURE__ */ function(_React$Component) {
|
|
|
125
127
|
};
|
|
126
128
|
return ErrorBoundary2;
|
|
127
129
|
}(React.Component);
|
|
128
|
-
var jsxRuntime = { exports: {} };
|
|
129
|
-
var reactJsxRuntime_production_min = {};
|
|
130
|
-
/**
|
|
131
|
-
* @license React
|
|
132
|
-
* react-jsx-runtime.production.min.js
|
|
133
|
-
*
|
|
134
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
135
|
-
*
|
|
136
|
-
* This source code is licensed under the MIT license found in the
|
|
137
|
-
* LICENSE file in the root directory of this source tree.
|
|
138
|
-
*/
|
|
139
|
-
var f = React__default, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m$1 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
|
|
140
|
-
function q(c, a, g) {
|
|
141
|
-
var b, d = {}, e = null, h = null;
|
|
142
|
-
g !== void 0 && (e = "" + g);
|
|
143
|
-
a.key !== void 0 && (e = "" + a.key);
|
|
144
|
-
a.ref !== void 0 && (h = a.ref);
|
|
145
|
-
for (b in a)
|
|
146
|
-
m$1.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
|
|
147
|
-
if (c && c.defaultProps)
|
|
148
|
-
for (b in a = c.defaultProps, a)
|
|
149
|
-
d[b] === void 0 && (d[b] = a[b]);
|
|
150
|
-
return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
|
|
151
|
-
}
|
|
152
|
-
reactJsxRuntime_production_min.Fragment = l;
|
|
153
|
-
reactJsxRuntime_production_min.jsx = q;
|
|
154
|
-
reactJsxRuntime_production_min.jsxs = q;
|
|
155
|
-
{
|
|
156
|
-
jsxRuntime.exports = reactJsxRuntime_production_min;
|
|
157
|
-
}
|
|
158
|
-
const jsx = jsxRuntime.exports.jsx;
|
|
159
|
-
const jsxs = jsxRuntime.exports.jsxs;
|
|
160
|
-
const Fragment = jsxRuntime.exports.Fragment;
|
|
161
130
|
const defaultResourceContext = {
|
|
162
131
|
collection: void 0,
|
|
163
132
|
manifest: void 0,
|
|
@@ -252,6 +221,22 @@ function useVisibleCanvases() {
|
|
|
252
221
|
return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);
|
|
253
222
|
}, [ids]);
|
|
254
223
|
}
|
|
224
|
+
function useManifest(options = {}, deps = []) {
|
|
225
|
+
const { id, selector } = options;
|
|
226
|
+
const ctx = useResourceContext();
|
|
227
|
+
useVault();
|
|
228
|
+
const manifestId = id ? id : ctx.manifest;
|
|
229
|
+
const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
|
|
230
|
+
return useMemo(() => {
|
|
231
|
+
if (!manifest) {
|
|
232
|
+
return void 0;
|
|
233
|
+
}
|
|
234
|
+
if (selector) {
|
|
235
|
+
return selector(manifest);
|
|
236
|
+
}
|
|
237
|
+
return manifest;
|
|
238
|
+
}, [manifest, selector, ...deps]);
|
|
239
|
+
}
|
|
255
240
|
const noop = () => {
|
|
256
241
|
};
|
|
257
242
|
const SimpleViewerReactContext = createContext({
|
|
@@ -259,9 +244,10 @@ const SimpleViewerReactContext = createContext({
|
|
|
259
244
|
setCurrentCanvasIndex: noop,
|
|
260
245
|
nextCanvas: noop,
|
|
261
246
|
previousCanvas: noop,
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
247
|
+
items: [],
|
|
248
|
+
sequence: [],
|
|
249
|
+
setSequenceIndex: noop,
|
|
250
|
+
currentSequenceIndex: 0
|
|
265
251
|
});
|
|
266
252
|
function useContextBridge() {
|
|
267
253
|
return {
|
|
@@ -467,11 +453,6 @@ function DefaultCanvasFallback({
|
|
|
467
453
|
children: "Unknown error"
|
|
468
454
|
});
|
|
469
455
|
}
|
|
470
|
-
var createRoot;
|
|
471
|
-
var m = require$$0;
|
|
472
|
-
{
|
|
473
|
-
createRoot = m.createRoot;
|
|
474
|
-
}
|
|
475
456
|
const ViewerPresetContext = createContext(null);
|
|
476
457
|
function useViewerPreset() {
|
|
477
458
|
return useContext(ViewerPresetContext);
|
|
@@ -483,26 +464,16 @@ function CanvasPortal({
|
|
|
483
464
|
overlay
|
|
484
465
|
}) {
|
|
485
466
|
const htmlElement = useContext(overlay ? OverlayPortalContext : PortalContext);
|
|
486
|
-
const rootRef = useRef(null);
|
|
487
467
|
const preset = useViewerPreset();
|
|
488
468
|
useLayoutEffect(() => {
|
|
489
|
-
if (
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
rootRef.current = null;
|
|
498
|
-
};
|
|
499
|
-
}, []);
|
|
500
|
-
useLayoutEffect(() => {
|
|
501
|
-
if (rootRef.current) {
|
|
502
|
-
rootRef.current.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
503
|
-
value: preset,
|
|
504
|
-
children
|
|
505
|
-
}));
|
|
469
|
+
if (htmlElement) {
|
|
470
|
+
try {
|
|
471
|
+
htmlElement.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
472
|
+
value: preset,
|
|
473
|
+
children
|
|
474
|
+
}));
|
|
475
|
+
} catch (e) {
|
|
476
|
+
}
|
|
506
477
|
}
|
|
507
478
|
}, [children, preset]);
|
|
508
479
|
return null;
|
|
@@ -525,8 +496,31 @@ function Viewer(_a) {
|
|
|
525
496
|
const bridge = useContextBridge();
|
|
526
497
|
const ErrorFallback = errorFallback || DefaultCanvasFallback;
|
|
527
498
|
useLayoutEffect(() => {
|
|
528
|
-
|
|
529
|
-
|
|
499
|
+
const roots = {};
|
|
500
|
+
if (portal.current) {
|
|
501
|
+
const $el = document.createElement("div");
|
|
502
|
+
portal.current.appendChild($el);
|
|
503
|
+
roots.portal = createRoot($el);
|
|
504
|
+
setPortalElement(roots.portal);
|
|
505
|
+
}
|
|
506
|
+
if (overlayPortal.current) {
|
|
507
|
+
const $el = document.createElement("div");
|
|
508
|
+
overlayPortal.current.appendChild($el);
|
|
509
|
+
roots.overlayPortal = createRoot($el);
|
|
510
|
+
setOverlayPortalElement(roots.overlayPortal);
|
|
511
|
+
}
|
|
512
|
+
return () => {
|
|
513
|
+
setPortalElement(null);
|
|
514
|
+
setOverlayPortalElement(null);
|
|
515
|
+
setTimeout(() => {
|
|
516
|
+
if (roots.portal) {
|
|
517
|
+
roots.portal.unmount();
|
|
518
|
+
}
|
|
519
|
+
if (roots.overlayPortal) {
|
|
520
|
+
roots.overlayPortal.unmount();
|
|
521
|
+
}
|
|
522
|
+
}, 0);
|
|
523
|
+
};
|
|
530
524
|
}, []);
|
|
531
525
|
return /* @__PURE__ */ jsxs(ErrorBoundary, {
|
|
532
526
|
fallbackRender: () => /* @__PURE__ */ jsx(ErrorFallback, __spreadValues({}, props)),
|
|
@@ -649,25 +643,25 @@ function useStyles(resource, scope) {
|
|
|
649
643
|
return styles ? scope ? styles[scope] : styles : void 0;
|
|
650
644
|
}, [resource, scope]);
|
|
651
645
|
}
|
|
652
|
-
var
|
|
653
|
-
var
|
|
654
|
-
var
|
|
655
|
-
var
|
|
656
|
-
var
|
|
657
|
-
var
|
|
658
|
-
var
|
|
659
|
-
var
|
|
646
|
+
var __defProp$1 = Object.defineProperty;
|
|
647
|
+
var __defProps$1 = Object.defineProperties;
|
|
648
|
+
var __getOwnPropDescs$1 = Object.getOwnPropertyDescriptors;
|
|
649
|
+
var __getOwnPropSymbols$1 = Object.getOwnPropertySymbols;
|
|
650
|
+
var __hasOwnProp$1 = Object.prototype.hasOwnProperty;
|
|
651
|
+
var __propIsEnum$1 = Object.prototype.propertyIsEnumerable;
|
|
652
|
+
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
653
|
+
var __spreadValues$1 = (a, b) => {
|
|
660
654
|
for (var prop in b || (b = {}))
|
|
661
|
-
if (
|
|
662
|
-
|
|
663
|
-
if (
|
|
664
|
-
for (var prop of
|
|
665
|
-
if (
|
|
666
|
-
|
|
655
|
+
if (__hasOwnProp$1.call(b, prop))
|
|
656
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
657
|
+
if (__getOwnPropSymbols$1)
|
|
658
|
+
for (var prop of __getOwnPropSymbols$1(b)) {
|
|
659
|
+
if (__propIsEnum$1.call(b, prop))
|
|
660
|
+
__defNormalProp$1(a, prop, b[prop]);
|
|
667
661
|
}
|
|
668
662
|
return a;
|
|
669
663
|
};
|
|
670
|
-
var
|
|
664
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
671
665
|
const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
|
|
672
666
|
const TEMPORAL_SELECTOR = /&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;
|
|
673
667
|
function parseSelector(source) {
|
|
@@ -812,7 +806,7 @@ function expandTarget(target, options = {}) {
|
|
|
812
806
|
if (!fragment) {
|
|
813
807
|
return {
|
|
814
808
|
type: "SpecificResource",
|
|
815
|
-
source:
|
|
809
|
+
source: __spreadProps$1(__spreadValues$1({}, target), {
|
|
816
810
|
id
|
|
817
811
|
}),
|
|
818
812
|
selector: null,
|
|
@@ -821,7 +815,7 @@ function expandTarget(target, options = {}) {
|
|
|
821
815
|
}
|
|
822
816
|
return expandTarget({
|
|
823
817
|
type: "SpecificResource",
|
|
824
|
-
source:
|
|
818
|
+
source: __spreadProps$1(__spreadValues$1({}, target), {
|
|
825
819
|
id
|
|
826
820
|
}),
|
|
827
821
|
selector: {
|
|
@@ -913,7 +907,7 @@ const RenderAnnotationPage = ({
|
|
|
913
907
|
const style = useStyles(page, "atlas");
|
|
914
908
|
const html = useStyles(page, "html");
|
|
915
909
|
useVaultSelector((state) => page.id ? state.iiif.entities.AnnotationPage[page.id] : null, []);
|
|
916
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
910
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
917
911
|
children: (_a = page.items) == null ? void 0 : _a.map((annotation) => {
|
|
918
912
|
return /* @__PURE__ */ jsx(RenderAnnotation, {
|
|
919
913
|
id: annotation.id,
|
|
@@ -930,21 +924,22 @@ function RenderImage({
|
|
|
930
924
|
isStatic,
|
|
931
925
|
x = 0,
|
|
932
926
|
y = 0,
|
|
933
|
-
|
|
934
|
-
|
|
927
|
+
children,
|
|
928
|
+
onClick
|
|
935
929
|
}) {
|
|
936
930
|
var _a, _b, _c, _d;
|
|
937
|
-
return /* @__PURE__ */ jsx(Fragment
|
|
938
|
-
children: !image.service ? /* @__PURE__ */ jsxs(Fragment
|
|
931
|
+
return /* @__PURE__ */ jsx(Fragment, {
|
|
932
|
+
children: !image.service ? /* @__PURE__ */ jsxs(Fragment, {
|
|
939
933
|
children: [/* @__PURE__ */ jsx("world-image", {
|
|
934
|
+
onClick,
|
|
940
935
|
uri: image.id,
|
|
941
936
|
target: image.target.spatial,
|
|
942
937
|
display: image.width && image.height ? {
|
|
943
938
|
width: image.width,
|
|
944
939
|
height: image.height
|
|
945
940
|
} : void 0
|
|
946
|
-
}),
|
|
947
|
-
}, "no-service") : /* @__PURE__ */ jsxs(Fragment
|
|
941
|
+
}), children]
|
|
942
|
+
}, "no-service") : /* @__PURE__ */ jsxs(Fragment, {
|
|
948
943
|
children: [/* @__PURE__ */ jsx(TileSet, {
|
|
949
944
|
tiles: {
|
|
950
945
|
id: image.service.id || image.service["@id"] || "unknown",
|
|
@@ -956,8 +951,9 @@ function RenderImage({
|
|
|
956
951
|
x: ((_a = image.target) == null ? void 0 : _a.spatial.x) + x,
|
|
957
952
|
y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
|
|
958
953
|
width: (_c = image.target) == null ? void 0 : _c.spatial.width,
|
|
959
|
-
height: (_d = image.target) == null ? void 0 : _d.spatial.height
|
|
960
|
-
|
|
954
|
+
height: (_d = image.target) == null ? void 0 : _d.spatial.height,
|
|
955
|
+
onClick
|
|
956
|
+
}), children]
|
|
961
957
|
}, "service")
|
|
962
958
|
}, id);
|
|
963
959
|
}
|
|
@@ -998,6 +994,7 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
|
|
|
998
994
|
types.push(type);
|
|
999
995
|
}
|
|
1000
996
|
items.push({
|
|
997
|
+
annotationId: annotation.id,
|
|
1001
998
|
type,
|
|
1002
999
|
resource: body,
|
|
1003
1000
|
target: annotation.target,
|
|
@@ -1011,6 +1008,29 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
|
|
|
1011
1008
|
choice
|
|
1012
1009
|
};
|
|
1013
1010
|
}
|
|
1011
|
+
function getParsedTargetSelector(canvas, target) {
|
|
1012
|
+
const { selector: imageTarget, source } = expandTarget$1(target);
|
|
1013
|
+
if (source.id !== canvas.id) {
|
|
1014
|
+
return [null, source];
|
|
1015
|
+
}
|
|
1016
|
+
const defaultTarget = {
|
|
1017
|
+
type: "BoxSelector",
|
|
1018
|
+
spatial: {
|
|
1019
|
+
x: 0,
|
|
1020
|
+
y: 0,
|
|
1021
|
+
width: canvas.width,
|
|
1022
|
+
height: canvas.height
|
|
1023
|
+
}
|
|
1024
|
+
};
|
|
1025
|
+
return [
|
|
1026
|
+
imageTarget ? imageTarget.type === "TemporalSelector" ? {
|
|
1027
|
+
type: "TemporalBoxSelector",
|
|
1028
|
+
temporal: imageTarget.temporal,
|
|
1029
|
+
spatial: defaultTarget.spatial
|
|
1030
|
+
} : imageTarget : null,
|
|
1031
|
+
source
|
|
1032
|
+
];
|
|
1033
|
+
}
|
|
1014
1034
|
const emptyActions = {
|
|
1015
1035
|
makeChoice: () => {
|
|
1016
1036
|
}
|
|
@@ -1019,22 +1039,9 @@ const unknownResponse = { type: "unknown" };
|
|
|
1019
1039
|
const unsupportedStrategy = (reason) => {
|
|
1020
1040
|
return { type: "unknown", reason, annotations: { pages: [] } };
|
|
1021
1041
|
};
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
useVault();
|
|
1026
|
-
const manifestId = id ? id : ctx.manifest;
|
|
1027
|
-
const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
|
|
1028
|
-
return useMemo(() => {
|
|
1029
|
-
if (!manifest) {
|
|
1030
|
-
return void 0;
|
|
1031
|
-
}
|
|
1032
|
-
if (selector) {
|
|
1033
|
-
return selector(manifest);
|
|
1034
|
-
}
|
|
1035
|
-
return manifest;
|
|
1036
|
-
}, [manifest, selector, ...deps]);
|
|
1037
|
-
}
|
|
1042
|
+
const emptyStrategy = (width, height) => {
|
|
1043
|
+
return { type: "empty", width, height, annotations: { pages: [] }, image: null, images: [] };
|
|
1044
|
+
};
|
|
1038
1045
|
function getMeta$1(state, resourceId) {
|
|
1039
1046
|
var _a;
|
|
1040
1047
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1288,10 +1295,6 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1288
1295
|
imageService = loadImageService(imageServices[0], canvas);
|
|
1289
1296
|
}
|
|
1290
1297
|
}
|
|
1291
|
-
const { selector: imageTarget, source } = expandTarget(singleImage.target);
|
|
1292
|
-
if (source.id !== canvas.id) {
|
|
1293
|
-
continue;
|
|
1294
|
-
}
|
|
1295
1298
|
const defaultTarget = {
|
|
1296
1299
|
type: "BoxSelector",
|
|
1297
1300
|
spatial: {
|
|
@@ -1301,11 +1304,10 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1301
1304
|
height: canvas.height
|
|
1302
1305
|
}
|
|
1303
1306
|
};
|
|
1304
|
-
const target =
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
} : imageTarget : null;
|
|
1307
|
+
const [target, source] = getParsedTargetSelector(canvas, singleImage.target);
|
|
1308
|
+
if (source.id !== canvas.id) {
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1309
1311
|
const defaultImageSelector = {
|
|
1310
1312
|
type: "BoxSelector",
|
|
1311
1313
|
spatial: {
|
|
@@ -1331,6 +1333,7 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1331
1333
|
const imageType = {
|
|
1332
1334
|
id: resource.id,
|
|
1333
1335
|
type: "Image",
|
|
1336
|
+
annotationId: singleImage.annotationId,
|
|
1334
1337
|
width: target ? resource.width : canvas.width,
|
|
1335
1338
|
height: target ? resource.height : canvas.height,
|
|
1336
1339
|
service: imageService,
|
|
@@ -1380,6 +1383,7 @@ function getAudioStrategy(canvas, paintables) {
|
|
|
1380
1383
|
return {
|
|
1381
1384
|
type: "media",
|
|
1382
1385
|
media: {
|
|
1386
|
+
annotationId: paintables.items[0].annotationId,
|
|
1383
1387
|
duration: canvas.duration,
|
|
1384
1388
|
url: audioResource.id,
|
|
1385
1389
|
type: "Sound",
|
|
@@ -1423,6 +1427,7 @@ function getVideoStrategy(canvas, paintables) {
|
|
|
1423
1427
|
return {
|
|
1424
1428
|
type: "media",
|
|
1425
1429
|
media: {
|
|
1430
|
+
annotationId: paintables.items[0].annotationId,
|
|
1426
1431
|
duration: canvas.duration,
|
|
1427
1432
|
url: audioResource.id,
|
|
1428
1433
|
type: "Video",
|
|
@@ -1448,6 +1453,38 @@ function getVideoStrategy(canvas, paintables) {
|
|
|
1448
1453
|
}
|
|
1449
1454
|
};
|
|
1450
1455
|
}
|
|
1456
|
+
function parseType(item, languageMap = {}, lang) {
|
|
1457
|
+
const language = item.language || lang || "none";
|
|
1458
|
+
switch (item.type) {
|
|
1459
|
+
case "TextualBody": {
|
|
1460
|
+
if (typeof item.value !== "undefined") {
|
|
1461
|
+
languageMap[language] = item.value;
|
|
1462
|
+
}
|
|
1463
|
+
break;
|
|
1464
|
+
}
|
|
1465
|
+
case "List":
|
|
1466
|
+
case "Composite":
|
|
1467
|
+
case "Choice": {
|
|
1468
|
+
if (item.items) {
|
|
1469
|
+
item.items.forEach((inner) => parseType(inner, languageMap, language));
|
|
1470
|
+
}
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
1473
|
+
return languageMap;
|
|
1474
|
+
}
|
|
1475
|
+
function getTextualContentStrategy(canvas, paintables) {
|
|
1476
|
+
const items = [];
|
|
1477
|
+
paintables.items.forEach((item) => {
|
|
1478
|
+
if (item.resource) {
|
|
1479
|
+
const [target] = getParsedTargetSelector(canvas, item.target);
|
|
1480
|
+
items.push({ annotationId: item.annotationId, text: parseType(item.resource), target });
|
|
1481
|
+
}
|
|
1482
|
+
});
|
|
1483
|
+
return {
|
|
1484
|
+
type: "textual-content",
|
|
1485
|
+
items
|
|
1486
|
+
};
|
|
1487
|
+
}
|
|
1451
1488
|
function useRenderingStrategy(options) {
|
|
1452
1489
|
const manifest = useManifest();
|
|
1453
1490
|
const canvas = useCanvas();
|
|
@@ -1457,10 +1494,22 @@ function useRenderingStrategy(options) {
|
|
|
1457
1494
|
all: false
|
|
1458
1495
|
});
|
|
1459
1496
|
const enabledPages = useResources(enabledPageIds, "AnnotationPage");
|
|
1460
|
-
const supports = (options == null ? void 0 : options.strategies) || [
|
|
1497
|
+
const supports = (options == null ? void 0 : options.strategies) || [
|
|
1498
|
+
"empty",
|
|
1499
|
+
"images",
|
|
1500
|
+
"media",
|
|
1501
|
+
"textual-content",
|
|
1502
|
+
"complex-timeline"
|
|
1503
|
+
];
|
|
1461
1504
|
const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
|
|
1462
1505
|
const strategy = useMemo(() => {
|
|
1463
|
-
if (!canvas
|
|
1506
|
+
if (!canvas) {
|
|
1507
|
+
return unknownResponse;
|
|
1508
|
+
}
|
|
1509
|
+
if (paintables.types.length === 0) {
|
|
1510
|
+
if (supports.indexOf("empty") !== -1) {
|
|
1511
|
+
return emptyStrategy(canvas.width, canvas.height);
|
|
1512
|
+
}
|
|
1464
1513
|
return unknownResponse;
|
|
1465
1514
|
}
|
|
1466
1515
|
if (paintables.types.length !== 1) {
|
|
@@ -1486,6 +1535,12 @@ function useRenderingStrategy(options) {
|
|
|
1486
1535
|
}
|
|
1487
1536
|
return get3dStrategy(canvas, paintables);
|
|
1488
1537
|
}
|
|
1538
|
+
if (mainType === "textualbody") {
|
|
1539
|
+
if (supports.indexOf("textual-content") === -1) {
|
|
1540
|
+
return unsupportedStrategy("Textual content not supported");
|
|
1541
|
+
}
|
|
1542
|
+
return getTextualContentStrategy(canvas, paintables);
|
|
1543
|
+
}
|
|
1489
1544
|
if (mainType === "sound" || mainType === "audio") {
|
|
1490
1545
|
if (supports.indexOf("media") === -1) {
|
|
1491
1546
|
return unsupportedStrategy("Media not supported");
|
|
@@ -1605,6 +1660,7 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
|
1605
1660
|
const subject = canvas ? canvas : manifest;
|
|
1606
1661
|
const didUnmount = useRef(false);
|
|
1607
1662
|
useEffect(() => {
|
|
1663
|
+
didUnmount.current = false;
|
|
1608
1664
|
return () => {
|
|
1609
1665
|
didUnmount.current = true;
|
|
1610
1666
|
};
|
|
@@ -1798,7 +1854,7 @@ function Audio({
|
|
|
1798
1854
|
}, state, actions] = useSimpleMediaPlayer({
|
|
1799
1855
|
duration: media.duration
|
|
1800
1856
|
});
|
|
1801
|
-
return /* @__PURE__ */ jsx(Fragment, {
|
|
1857
|
+
return /* @__PURE__ */ jsx(Fragment$1, {
|
|
1802
1858
|
children: /* @__PURE__ */ jsx(CanvasPortal, {
|
|
1803
1859
|
children: /* @__PURE__ */ jsxs(MediaPlayerProvider, {
|
|
1804
1860
|
state,
|
|
@@ -1826,7 +1882,7 @@ function Video({
|
|
|
1826
1882
|
duration: media.duration
|
|
1827
1883
|
});
|
|
1828
1884
|
const Component = "div";
|
|
1829
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
1885
|
+
return /* @__PURE__ */ jsxs(Fragment$1, {
|
|
1830
1886
|
children: [/* @__PURE__ */ jsxs(CanvasPortal, {
|
|
1831
1887
|
overlay: true,
|
|
1832
1888
|
children: [/* @__PURE__ */ jsx("style", {
|
|
@@ -1904,6 +1960,533 @@ function Model({
|
|
|
1904
1960
|
})]
|
|
1905
1961
|
});
|
|
1906
1962
|
}
|
|
1963
|
+
function CanvasBackground({
|
|
1964
|
+
style
|
|
1965
|
+
}) {
|
|
1966
|
+
const canvas = useCanvas();
|
|
1967
|
+
if (!canvas || !canvas.height || !canvas.width) {
|
|
1968
|
+
return null;
|
|
1969
|
+
}
|
|
1970
|
+
return /* @__PURE__ */ jsx("box", {
|
|
1971
|
+
interactive: false,
|
|
1972
|
+
target: {
|
|
1973
|
+
x: 0,
|
|
1974
|
+
y: 0,
|
|
1975
|
+
width: canvas.width,
|
|
1976
|
+
height: canvas.height
|
|
1977
|
+
},
|
|
1978
|
+
style
|
|
1979
|
+
});
|
|
1980
|
+
}
|
|
1981
|
+
var __defProp2 = Object.defineProperty;
|
|
1982
|
+
var __defProps2 = Object.defineProperties;
|
|
1983
|
+
var __getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
1984
|
+
var __getOwnPropSymbols2 = Object.getOwnPropertySymbols;
|
|
1985
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
1986
|
+
var __propIsEnum2 = Object.prototype.propertyIsEnumerable;
|
|
1987
|
+
var __defNormalProp2 = (obj, key, value) => key in obj ? __defProp2(obj, key, {
|
|
1988
|
+
enumerable: true,
|
|
1989
|
+
configurable: true,
|
|
1990
|
+
writable: true,
|
|
1991
|
+
value
|
|
1992
|
+
}) : obj[key] = value;
|
|
1993
|
+
var __spreadValues2 = (a, b) => {
|
|
1994
|
+
for (var prop in b || (b = {}))
|
|
1995
|
+
if (__hasOwnProp2.call(b, prop))
|
|
1996
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
1997
|
+
if (__getOwnPropSymbols2)
|
|
1998
|
+
for (var prop of __getOwnPropSymbols2(b)) {
|
|
1999
|
+
if (__propIsEnum2.call(b, prop))
|
|
2000
|
+
__defNormalProp2(a, prop, b[prop]);
|
|
2001
|
+
}
|
|
2002
|
+
return a;
|
|
2003
|
+
};
|
|
2004
|
+
var __spreadProps2 = (a, b) => __defProps2(a, __getOwnPropDescs2(b));
|
|
2005
|
+
var __objRest2 = (source, exclude) => {
|
|
2006
|
+
var target = {};
|
|
2007
|
+
for (var prop in source)
|
|
2008
|
+
if (__hasOwnProp2.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
2009
|
+
target[prop] = source[prop];
|
|
2010
|
+
if (source != null && __getOwnPropSymbols2)
|
|
2011
|
+
for (var prop of __getOwnPropSymbols2(source)) {
|
|
2012
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum2.call(source, prop))
|
|
2013
|
+
target[prop] = source[prop];
|
|
2014
|
+
}
|
|
2015
|
+
return target;
|
|
2016
|
+
};
|
|
2017
|
+
function _defineProperty(obj, key, value) {
|
|
2018
|
+
if (key in obj) {
|
|
2019
|
+
Object.defineProperty(obj, key, {
|
|
2020
|
+
value,
|
|
2021
|
+
enumerable: true,
|
|
2022
|
+
configurable: true,
|
|
2023
|
+
writable: true
|
|
2024
|
+
});
|
|
2025
|
+
} else {
|
|
2026
|
+
obj[key] = value;
|
|
2027
|
+
}
|
|
2028
|
+
return obj;
|
|
2029
|
+
}
|
|
2030
|
+
function _classCallCheck(instance, Constructor) {
|
|
2031
|
+
if (!(instance instanceof Constructor)) {
|
|
2032
|
+
throw new TypeError("Cannot call a class as a function");
|
|
2033
|
+
}
|
|
2034
|
+
}
|
|
2035
|
+
function _defineProperties(target, props) {
|
|
2036
|
+
for (var i = 0; i < props.length; i++) {
|
|
2037
|
+
var descriptor = props[i];
|
|
2038
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
2039
|
+
descriptor.configurable = true;
|
|
2040
|
+
if ("value" in descriptor)
|
|
2041
|
+
descriptor.writable = true;
|
|
2042
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
2043
|
+
}
|
|
2044
|
+
}
|
|
2045
|
+
function _createClass(Constructor, protoProps, staticProps) {
|
|
2046
|
+
if (protoProps)
|
|
2047
|
+
_defineProperties(Constructor.prototype, protoProps);
|
|
2048
|
+
if (staticProps)
|
|
2049
|
+
_defineProperties(Constructor, staticProps);
|
|
2050
|
+
Object.defineProperty(Constructor, "prototype", {
|
|
2051
|
+
writable: false
|
|
2052
|
+
});
|
|
2053
|
+
return Constructor;
|
|
2054
|
+
}
|
|
2055
|
+
var defaultOptions = {
|
|
2056
|
+
bindI18n: "languageChanged",
|
|
2057
|
+
bindI18nStore: "",
|
|
2058
|
+
transEmptyNodeValue: "",
|
|
2059
|
+
transSupportBasicHtmlNodes: true,
|
|
2060
|
+
transWrapTextNodes: "",
|
|
2061
|
+
transKeepBasicHtmlNodesFor: ["br", "strong", "i", "p"],
|
|
2062
|
+
useSuspense: true
|
|
2063
|
+
};
|
|
2064
|
+
var i18nInstance;
|
|
2065
|
+
var I18nContext = React__default.createContext();
|
|
2066
|
+
function getDefaults() {
|
|
2067
|
+
return defaultOptions;
|
|
2068
|
+
}
|
|
2069
|
+
var ReportNamespaces = function() {
|
|
2070
|
+
function ReportNamespaces2() {
|
|
2071
|
+
_classCallCheck(this, ReportNamespaces2);
|
|
2072
|
+
this.usedNamespaces = {};
|
|
2073
|
+
}
|
|
2074
|
+
_createClass(ReportNamespaces2, [{
|
|
2075
|
+
key: "addUsedNamespaces",
|
|
2076
|
+
value: function addUsedNamespaces(namespaces) {
|
|
2077
|
+
var _this = this;
|
|
2078
|
+
namespaces.forEach(function(ns) {
|
|
2079
|
+
if (!_this.usedNamespaces[ns])
|
|
2080
|
+
_this.usedNamespaces[ns] = true;
|
|
2081
|
+
});
|
|
2082
|
+
}
|
|
2083
|
+
}, {
|
|
2084
|
+
key: "getUsedNamespaces",
|
|
2085
|
+
value: function getUsedNamespaces() {
|
|
2086
|
+
return Object.keys(this.usedNamespaces);
|
|
2087
|
+
}
|
|
2088
|
+
}]);
|
|
2089
|
+
return ReportNamespaces2;
|
|
2090
|
+
}();
|
|
2091
|
+
function getI18n() {
|
|
2092
|
+
return i18nInstance;
|
|
2093
|
+
}
|
|
2094
|
+
function warn() {
|
|
2095
|
+
if (console && console.warn) {
|
|
2096
|
+
var _console;
|
|
2097
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2098
|
+
args[_key] = arguments[_key];
|
|
2099
|
+
}
|
|
2100
|
+
if (typeof args[0] === "string")
|
|
2101
|
+
args[0] = "react-i18next:: ".concat(args[0]);
|
|
2102
|
+
(_console = console).warn.apply(_console, args);
|
|
2103
|
+
}
|
|
2104
|
+
}
|
|
2105
|
+
var alreadyWarned = {};
|
|
2106
|
+
function warnOnce() {
|
|
2107
|
+
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
2108
|
+
args[_key2] = arguments[_key2];
|
|
2109
|
+
}
|
|
2110
|
+
if (typeof args[0] === "string" && alreadyWarned[args[0]])
|
|
2111
|
+
return;
|
|
2112
|
+
if (typeof args[0] === "string")
|
|
2113
|
+
alreadyWarned[args[0]] = new Date();
|
|
2114
|
+
warn.apply(void 0, args);
|
|
2115
|
+
}
|
|
2116
|
+
function loadNamespaces(i18n, ns, cb) {
|
|
2117
|
+
i18n.loadNamespaces(ns, function() {
|
|
2118
|
+
if (i18n.isInitialized) {
|
|
2119
|
+
cb();
|
|
2120
|
+
} else {
|
|
2121
|
+
var initialized = function initialized2() {
|
|
2122
|
+
setTimeout(function() {
|
|
2123
|
+
i18n.off("initialized", initialized2);
|
|
2124
|
+
}, 0);
|
|
2125
|
+
cb();
|
|
2126
|
+
};
|
|
2127
|
+
i18n.on("initialized", initialized);
|
|
2128
|
+
}
|
|
2129
|
+
});
|
|
2130
|
+
}
|
|
2131
|
+
function hasLoadedNamespace(ns, i18n) {
|
|
2132
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
2133
|
+
if (!i18n.languages || !i18n.languages.length) {
|
|
2134
|
+
warnOnce("i18n.languages were undefined or empty", i18n.languages);
|
|
2135
|
+
return true;
|
|
2136
|
+
}
|
|
2137
|
+
var lng = i18n.languages[0];
|
|
2138
|
+
var fallbackLng = i18n.options ? i18n.options.fallbackLng : false;
|
|
2139
|
+
var lastLng = i18n.languages[i18n.languages.length - 1];
|
|
2140
|
+
if (lng.toLowerCase() === "cimode")
|
|
2141
|
+
return true;
|
|
2142
|
+
var loadNotPending = function loadNotPending2(l, n) {
|
|
2143
|
+
var loadState = i18n.services.backendConnector.state["".concat(l, "|").concat(n)];
|
|
2144
|
+
return loadState === -1 || loadState === 2;
|
|
2145
|
+
};
|
|
2146
|
+
if (options.bindI18n && options.bindI18n.indexOf("languageChanging") > -1 && i18n.services.backendConnector.backend && i18n.isLanguageChangingTo && !loadNotPending(i18n.isLanguageChangingTo, ns))
|
|
2147
|
+
return false;
|
|
2148
|
+
if (i18n.hasResourceBundle(lng, ns))
|
|
2149
|
+
return true;
|
|
2150
|
+
if (!i18n.services.backendConnector.backend)
|
|
2151
|
+
return true;
|
|
2152
|
+
if (loadNotPending(lng, ns) && (!fallbackLng || loadNotPending(lastLng, ns)))
|
|
2153
|
+
return true;
|
|
2154
|
+
return false;
|
|
2155
|
+
}
|
|
2156
|
+
function _arrayWithHoles(arr) {
|
|
2157
|
+
if (Array.isArray(arr))
|
|
2158
|
+
return arr;
|
|
2159
|
+
}
|
|
2160
|
+
function _iterableToArrayLimit(arr, i) {
|
|
2161
|
+
var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
|
|
2162
|
+
if (_i == null)
|
|
2163
|
+
return;
|
|
2164
|
+
var _arr = [];
|
|
2165
|
+
var _n = true;
|
|
2166
|
+
var _d = false;
|
|
2167
|
+
var _s, _e;
|
|
2168
|
+
try {
|
|
2169
|
+
for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
|
|
2170
|
+
_arr.push(_s.value);
|
|
2171
|
+
if (i && _arr.length === i)
|
|
2172
|
+
break;
|
|
2173
|
+
}
|
|
2174
|
+
} catch (err) {
|
|
2175
|
+
_d = true;
|
|
2176
|
+
_e = err;
|
|
2177
|
+
} finally {
|
|
2178
|
+
try {
|
|
2179
|
+
if (!_n && _i["return"] != null)
|
|
2180
|
+
_i["return"]();
|
|
2181
|
+
} finally {
|
|
2182
|
+
if (_d)
|
|
2183
|
+
throw _e;
|
|
2184
|
+
}
|
|
2185
|
+
}
|
|
2186
|
+
return _arr;
|
|
2187
|
+
}
|
|
2188
|
+
function _arrayLikeToArray(arr, len) {
|
|
2189
|
+
if (len == null || len > arr.length)
|
|
2190
|
+
len = arr.length;
|
|
2191
|
+
for (var i = 0, arr2 = new Array(len); i < len; i++) {
|
|
2192
|
+
arr2[i] = arr[i];
|
|
2193
|
+
}
|
|
2194
|
+
return arr2;
|
|
2195
|
+
}
|
|
2196
|
+
function _unsupportedIterableToArray(o, minLen) {
|
|
2197
|
+
if (!o)
|
|
2198
|
+
return;
|
|
2199
|
+
if (typeof o === "string")
|
|
2200
|
+
return _arrayLikeToArray(o, minLen);
|
|
2201
|
+
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
2202
|
+
if (n === "Object" && o.constructor)
|
|
2203
|
+
n = o.constructor.name;
|
|
2204
|
+
if (n === "Map" || n === "Set")
|
|
2205
|
+
return Array.from(o);
|
|
2206
|
+
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))
|
|
2207
|
+
return _arrayLikeToArray(o, minLen);
|
|
2208
|
+
}
|
|
2209
|
+
function _nonIterableRest() {
|
|
2210
|
+
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
2211
|
+
}
|
|
2212
|
+
function _slicedToArray(arr, i) {
|
|
2213
|
+
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
2214
|
+
}
|
|
2215
|
+
function ownKeys(object, enumerableOnly) {
|
|
2216
|
+
var keys = Object.keys(object);
|
|
2217
|
+
if (Object.getOwnPropertySymbols) {
|
|
2218
|
+
var symbols = Object.getOwnPropertySymbols(object);
|
|
2219
|
+
if (enumerableOnly) {
|
|
2220
|
+
symbols = symbols.filter(function(sym) {
|
|
2221
|
+
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
2222
|
+
});
|
|
2223
|
+
}
|
|
2224
|
+
keys.push.apply(keys, symbols);
|
|
2225
|
+
}
|
|
2226
|
+
return keys;
|
|
2227
|
+
}
|
|
2228
|
+
function _objectSpread(target) {
|
|
2229
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
2230
|
+
var source = arguments[i] != null ? arguments[i] : {};
|
|
2231
|
+
if (i % 2) {
|
|
2232
|
+
ownKeys(Object(source), true).forEach(function(key) {
|
|
2233
|
+
_defineProperty(target, key, source[key]);
|
|
2234
|
+
});
|
|
2235
|
+
} else if (Object.getOwnPropertyDescriptors) {
|
|
2236
|
+
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
2237
|
+
} else {
|
|
2238
|
+
ownKeys(Object(source)).forEach(function(key) {
|
|
2239
|
+
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
2240
|
+
});
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
return target;
|
|
2244
|
+
}
|
|
2245
|
+
function useTranslation(ns) {
|
|
2246
|
+
var props = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
2247
|
+
var i18nFromProps = props.i18n;
|
|
2248
|
+
var _ref = useContext(I18nContext) || {}, i18nFromContext = _ref.i18n, defaultNSFromContext = _ref.defaultNS;
|
|
2249
|
+
var i18n = i18nFromProps || i18nFromContext || getI18n();
|
|
2250
|
+
if (i18n && !i18n.reportNamespaces)
|
|
2251
|
+
i18n.reportNamespaces = new ReportNamespaces();
|
|
2252
|
+
if (!i18n) {
|
|
2253
|
+
warnOnce("You will need to pass in an i18next instance by using initReactI18next");
|
|
2254
|
+
var notReadyT = function notReadyT2(k) {
|
|
2255
|
+
return Array.isArray(k) ? k[k.length - 1] : k;
|
|
2256
|
+
};
|
|
2257
|
+
var retNotReady = [notReadyT, {}, false];
|
|
2258
|
+
retNotReady.t = notReadyT;
|
|
2259
|
+
retNotReady.i18n = {};
|
|
2260
|
+
retNotReady.ready = false;
|
|
2261
|
+
return retNotReady;
|
|
2262
|
+
}
|
|
2263
|
+
if (i18n.options.react && i18n.options.react.wait !== void 0)
|
|
2264
|
+
warnOnce("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
|
|
2265
|
+
var i18nOptions = _objectSpread(_objectSpread(_objectSpread({}, getDefaults()), i18n.options.react), props);
|
|
2266
|
+
var useSuspense = i18nOptions.useSuspense, keyPrefix = i18nOptions.keyPrefix;
|
|
2267
|
+
var namespaces = ns || defaultNSFromContext || i18n.options && i18n.options.defaultNS;
|
|
2268
|
+
namespaces = typeof namespaces === "string" ? [namespaces] : namespaces || ["translation"];
|
|
2269
|
+
if (i18n.reportNamespaces.addUsedNamespaces)
|
|
2270
|
+
i18n.reportNamespaces.addUsedNamespaces(namespaces);
|
|
2271
|
+
var ready = (i18n.isInitialized || i18n.initializedStoreOnce) && namespaces.every(function(n) {
|
|
2272
|
+
return hasLoadedNamespace(n, i18n, i18nOptions);
|
|
2273
|
+
});
|
|
2274
|
+
function getT() {
|
|
2275
|
+
return i18n.getFixedT(null, i18nOptions.nsMode === "fallback" ? namespaces : namespaces[0], keyPrefix);
|
|
2276
|
+
}
|
|
2277
|
+
var _useState = useState(getT), _useState2 = _slicedToArray(_useState, 2), t = _useState2[0], setT = _useState2[1];
|
|
2278
|
+
var isMounted = useRef(true);
|
|
2279
|
+
useEffect(function() {
|
|
2280
|
+
var bindI18n = i18nOptions.bindI18n, bindI18nStore = i18nOptions.bindI18nStore;
|
|
2281
|
+
isMounted.current = true;
|
|
2282
|
+
if (!ready && !useSuspense) {
|
|
2283
|
+
loadNamespaces(i18n, namespaces, function() {
|
|
2284
|
+
if (isMounted.current)
|
|
2285
|
+
setT(getT);
|
|
2286
|
+
});
|
|
2287
|
+
}
|
|
2288
|
+
function boundReset() {
|
|
2289
|
+
if (isMounted.current)
|
|
2290
|
+
setT(getT);
|
|
2291
|
+
}
|
|
2292
|
+
if (bindI18n && i18n)
|
|
2293
|
+
i18n.on(bindI18n, boundReset);
|
|
2294
|
+
if (bindI18nStore && i18n)
|
|
2295
|
+
i18n.store.on(bindI18nStore, boundReset);
|
|
2296
|
+
return function() {
|
|
2297
|
+
isMounted.current = false;
|
|
2298
|
+
if (bindI18n && i18n)
|
|
2299
|
+
bindI18n.split(" ").forEach(function(e) {
|
|
2300
|
+
return i18n.off(e, boundReset);
|
|
2301
|
+
});
|
|
2302
|
+
if (bindI18nStore && i18n)
|
|
2303
|
+
bindI18nStore.split(" ").forEach(function(e) {
|
|
2304
|
+
return i18n.store.off(e, boundReset);
|
|
2305
|
+
});
|
|
2306
|
+
};
|
|
2307
|
+
}, [i18n, namespaces.join()]);
|
|
2308
|
+
var isInitial = useRef(true);
|
|
2309
|
+
useEffect(function() {
|
|
2310
|
+
if (isMounted.current && !isInitial.current) {
|
|
2311
|
+
setT(getT);
|
|
2312
|
+
}
|
|
2313
|
+
isInitial.current = false;
|
|
2314
|
+
}, [i18n]);
|
|
2315
|
+
var ret = [t, i18n, ready];
|
|
2316
|
+
ret.t = t;
|
|
2317
|
+
ret.i18n = i18n;
|
|
2318
|
+
ret.ready = ready;
|
|
2319
|
+
if (ready)
|
|
2320
|
+
return ret;
|
|
2321
|
+
if (!ready && !useSuspense)
|
|
2322
|
+
return ret;
|
|
2323
|
+
throw new Promise(function(resolve) {
|
|
2324
|
+
loadNamespaces(i18n, namespaces, function() {
|
|
2325
|
+
resolve();
|
|
2326
|
+
});
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
function LanguageString(_a) {
|
|
2330
|
+
var _b = _a, {
|
|
2331
|
+
as: Component,
|
|
2332
|
+
language,
|
|
2333
|
+
children
|
|
2334
|
+
} = _b, props = __objRest2(_b, ["as", "language", "children"]);
|
|
2335
|
+
const {
|
|
2336
|
+
i18n
|
|
2337
|
+
} = useTranslation();
|
|
2338
|
+
const viewingDirection = useMemo(() => i18n.dir ? i18n.dir(language) : "ltr", [language]);
|
|
2339
|
+
const isSame = useMemo(() => {
|
|
2340
|
+
if (!i18n.services) {
|
|
2341
|
+
return false;
|
|
2342
|
+
}
|
|
2343
|
+
return i18n.services.languageUtils.getLanguagePartFromCode(i18n.language) === i18n.services.languageUtils.getLanguagePartFromCode(language);
|
|
2344
|
+
}, [i18n.language, language]);
|
|
2345
|
+
if (isSame) {
|
|
2346
|
+
if (Component) {
|
|
2347
|
+
return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, __spreadValues2({}, props)), {
|
|
2348
|
+
children
|
|
2349
|
+
}));
|
|
2350
|
+
}
|
|
2351
|
+
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, __spreadValues2({}, props)), {
|
|
2352
|
+
children
|
|
2353
|
+
}));
|
|
2354
|
+
}
|
|
2355
|
+
if (Component) {
|
|
2356
|
+
return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
|
|
2357
|
+
lang: language,
|
|
2358
|
+
dir: viewingDirection
|
|
2359
|
+
})), {
|
|
2360
|
+
children
|
|
2361
|
+
}));
|
|
2362
|
+
}
|
|
2363
|
+
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
|
|
2364
|
+
lang: language,
|
|
2365
|
+
dir: viewingDirection
|
|
2366
|
+
})), {
|
|
2367
|
+
children
|
|
2368
|
+
}));
|
|
2369
|
+
}
|
|
2370
|
+
function getClosestLanguage(i18nLanguage, languages, i18nLanguages = [], strictFallback = false) {
|
|
2371
|
+
if (!i18nLanguage || !languages || languages.length === 0) {
|
|
2372
|
+
return void 0;
|
|
2373
|
+
}
|
|
2374
|
+
if (languages.length === 1) {
|
|
2375
|
+
return languages[0];
|
|
2376
|
+
}
|
|
2377
|
+
if (languages.indexOf(i18nLanguage) !== -1) {
|
|
2378
|
+
return i18nLanguage;
|
|
2379
|
+
}
|
|
2380
|
+
const root = i18nLanguage.indexOf("-") !== -1 ? i18nLanguage.slice(0, i18nLanguage.indexOf("-")) : null;
|
|
2381
|
+
if (root && languages.indexOf(root) !== -1) {
|
|
2382
|
+
return root;
|
|
2383
|
+
}
|
|
2384
|
+
for (const lang of i18nLanguages) {
|
|
2385
|
+
if (languages.indexOf(lang) !== -1) {
|
|
2386
|
+
return lang;
|
|
2387
|
+
}
|
|
2388
|
+
}
|
|
2389
|
+
if (!strictFallback) {
|
|
2390
|
+
const inverseRoot = languages.map((l) => l.indexOf("-") !== -1 ? l.slice(0, l.indexOf("-")) : null);
|
|
2391
|
+
const inverseIdx = inverseRoot.indexOf(i18nLanguage);
|
|
2392
|
+
if (inverseIdx !== -1) {
|
|
2393
|
+
return languages[inverseIdx];
|
|
2394
|
+
}
|
|
2395
|
+
for (const lang of i18nLanguages) {
|
|
2396
|
+
const root2 = lang.indexOf("-") !== -1 ? lang.slice(0, lang.indexOf("-")) : null;
|
|
2397
|
+
const inverseIdx2 = root2 ? languages.indexOf(root2) : -1;
|
|
2398
|
+
if (inverseIdx2 !== -1) {
|
|
2399
|
+
return languages[inverseIdx2];
|
|
2400
|
+
}
|
|
2401
|
+
}
|
|
2402
|
+
}
|
|
2403
|
+
if (languages.indexOf("none") !== -1) {
|
|
2404
|
+
return "none";
|
|
2405
|
+
}
|
|
2406
|
+
if (languages.indexOf("@none") !== -1) {
|
|
2407
|
+
return "@none";
|
|
2408
|
+
}
|
|
2409
|
+
return languages[0];
|
|
2410
|
+
}
|
|
2411
|
+
function buildLocaleString(inputText, i18nLanguage, options = {}) {
|
|
2412
|
+
const {
|
|
2413
|
+
strictFallback = false,
|
|
2414
|
+
defaultText = "",
|
|
2415
|
+
separator = "\n",
|
|
2416
|
+
fallbackLanguages = [],
|
|
2417
|
+
closest
|
|
2418
|
+
} = options;
|
|
2419
|
+
const languages = Object.keys(inputText || {});
|
|
2420
|
+
const language = closest ? i18nLanguage : getClosestLanguage(i18nLanguage, languages, fallbackLanguages, strictFallback);
|
|
2421
|
+
if (!inputText) {
|
|
2422
|
+
return defaultText;
|
|
2423
|
+
}
|
|
2424
|
+
if (typeof inputText === "string") {
|
|
2425
|
+
return inputText;
|
|
2426
|
+
}
|
|
2427
|
+
const candidateText = language ? inputText[language] : void 0;
|
|
2428
|
+
if (candidateText) {
|
|
2429
|
+
if (typeof candidateText === "string") {
|
|
2430
|
+
return candidateText;
|
|
2431
|
+
}
|
|
2432
|
+
return candidateText.join(separator);
|
|
2433
|
+
}
|
|
2434
|
+
return "";
|
|
2435
|
+
}
|
|
2436
|
+
function useClosestLanguage(getLanguages, deps = []) {
|
|
2437
|
+
const {
|
|
2438
|
+
i18n
|
|
2439
|
+
} = useTranslation();
|
|
2440
|
+
const i18nLanguages = i18n && i18n.languages ? i18n.languages : [];
|
|
2441
|
+
const i18nLanguage = i18n && i18n.language ? i18n.language : "en";
|
|
2442
|
+
return useMemo(() => {
|
|
2443
|
+
const languages = getLanguages();
|
|
2444
|
+
return getClosestLanguage(i18nLanguage, languages, i18nLanguages);
|
|
2445
|
+
}, [i18nLanguages, i18nLanguage, ...deps]);
|
|
2446
|
+
}
|
|
2447
|
+
function useLocaleString(inputText, defaultText) {
|
|
2448
|
+
const language = useClosestLanguage(() => Object.keys(inputText || {}), [inputText]);
|
|
2449
|
+
return [useMemo(() => {
|
|
2450
|
+
return buildLocaleString(inputText, language, {
|
|
2451
|
+
defaultText,
|
|
2452
|
+
closest: true
|
|
2453
|
+
});
|
|
2454
|
+
}, [language, defaultText, inputText]), language];
|
|
2455
|
+
}
|
|
2456
|
+
const LocaleString = (_c) => {
|
|
2457
|
+
var _d = _c, {
|
|
2458
|
+
as: Component,
|
|
2459
|
+
defaultText,
|
|
2460
|
+
enableDangerouslySetInnerHTML,
|
|
2461
|
+
children
|
|
2462
|
+
} = _d, props = __objRest2(_d, ["as", "defaultText", "enableDangerouslySetInnerHTML", "children"]);
|
|
2463
|
+
const [text, language] = useLocaleString(children, defaultText);
|
|
2464
|
+
if (language) {
|
|
2465
|
+
return /* @__PURE__ */ jsx(LanguageString, __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
|
|
2466
|
+
as: Component,
|
|
2467
|
+
language,
|
|
2468
|
+
title: enableDangerouslySetInnerHTML ? void 0 : text,
|
|
2469
|
+
dangerouslySetInnerHTML: enableDangerouslySetInnerHTML ? {
|
|
2470
|
+
__html: text
|
|
2471
|
+
} : void 0
|
|
2472
|
+
})), {
|
|
2473
|
+
children: enableDangerouslySetInnerHTML ? void 0 : text
|
|
2474
|
+
}));
|
|
2475
|
+
}
|
|
2476
|
+
if (Component) {
|
|
2477
|
+
return /* @__PURE__ */ jsx(Component, __spreadProps(__spreadValues({}, __spreadValues2({}, props)), {
|
|
2478
|
+
children: text
|
|
2479
|
+
}));
|
|
2480
|
+
}
|
|
2481
|
+
return /* @__PURE__ */ jsx("span", __spreadProps(__spreadValues({}, __spreadProps2(__spreadValues2({}, props), {
|
|
2482
|
+
title: enableDangerouslySetInnerHTML ? void 0 : text,
|
|
2483
|
+
dangerouslySetInnerHTML: enableDangerouslySetInnerHTML ? {
|
|
2484
|
+
__html: text
|
|
2485
|
+
} : void 0
|
|
2486
|
+
})), {
|
|
2487
|
+
children: enableDangerouslySetInnerHTML ? void 0 : text
|
|
2488
|
+
}));
|
|
2489
|
+
};
|
|
1907
2490
|
function RenderCanvas({
|
|
1908
2491
|
x,
|
|
1909
2492
|
y,
|
|
@@ -1914,6 +2497,9 @@ function RenderCanvas({
|
|
|
1914
2497
|
renderViewerControls,
|
|
1915
2498
|
renderMediaControls,
|
|
1916
2499
|
strategies,
|
|
2500
|
+
backgroundStyle,
|
|
2501
|
+
alwaysShowBackground,
|
|
2502
|
+
onClickPaintingAnnotation,
|
|
1917
2503
|
children
|
|
1918
2504
|
}) {
|
|
1919
2505
|
const canvas = useCanvas();
|
|
@@ -1984,7 +2570,7 @@ function RenderCanvas({
|
|
|
1984
2570
|
}
|
|
1985
2571
|
throw new Error(strategy.reason || "Unknown image strategy");
|
|
1986
2572
|
}
|
|
1987
|
-
const annotations = /* @__PURE__ */ jsxs(Fragment
|
|
2573
|
+
const annotations = /* @__PURE__ */ jsxs(Fragment, {
|
|
1988
2574
|
children: [virtualPage ? /* @__PURE__ */ jsx(RenderAnnotationPage, {
|
|
1989
2575
|
page: virtualPage
|
|
1990
2576
|
}) : null, strategy.annotations && strategy.annotations.pages ? strategy.annotations.pages.map((page) => {
|
|
@@ -1993,29 +2579,45 @@ function RenderCanvas({
|
|
|
1993
2579
|
}, page.id);
|
|
1994
2580
|
}) : null, children]
|
|
1995
2581
|
});
|
|
1996
|
-
return /* @__PURE__ */ jsxs(Fragment, {
|
|
2582
|
+
return /* @__PURE__ */ jsxs(Fragment$1, {
|
|
1997
2583
|
children: [/* @__PURE__ */ jsxs("world-object", __spreadProps(__spreadValues({
|
|
1998
2584
|
height: canvas.height,
|
|
1999
2585
|
width: canvas.width,
|
|
2000
2586
|
x,
|
|
2001
2587
|
y
|
|
2002
2588
|
}, elementProps), {
|
|
2003
|
-
children: [strategy.type === "
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
|
|
2012
|
-
|
|
2013
|
-
|
|
2014
|
-
|
|
2015
|
-
|
|
2589
|
+
children: [strategy.type === "empty" || alwaysShowBackground ? /* @__PURE__ */ jsx(CanvasBackground, {
|
|
2590
|
+
style: backgroundStyle
|
|
2591
|
+
}) : null, strategy.type === "textual-content" ? strategy.items.map((item, n) => {
|
|
2592
|
+
return /* @__PURE__ */ jsxs(Fragment$1, {
|
|
2593
|
+
children: [/* @__PURE__ */ jsx(HTMLPortal, {
|
|
2594
|
+
onClick: onClickPaintingAnnotation ? (e) => {
|
|
2595
|
+
e.stopPropagation();
|
|
2596
|
+
onClickPaintingAnnotation(item.annotationId, item, e);
|
|
2597
|
+
} : void 0,
|
|
2598
|
+
target: item.target.spatial || void 0,
|
|
2599
|
+
children: /* @__PURE__ */ jsx(LocaleString, {
|
|
2600
|
+
children: item.text
|
|
2601
|
+
})
|
|
2602
|
+
}, n), annotations]
|
|
2603
|
+
});
|
|
2604
|
+
}) : null, strategy.type === "images" ? /* @__PURE__ */ jsxs(Fragment$1, {
|
|
2605
|
+
children: [strategy.images.map((image, idx) => /* @__PURE__ */ jsx(RenderImage, {
|
|
2606
|
+
isStatic,
|
|
2607
|
+
image,
|
|
2608
|
+
id: image.id,
|
|
2609
|
+
thumbnail: idx === 0 ? thumbnail : void 0,
|
|
2610
|
+
onClick: onClickPaintingAnnotation ? (e) => {
|
|
2611
|
+
e.stopPropagation();
|
|
2612
|
+
onClickPaintingAnnotation(image.annotationId, image, e);
|
|
2613
|
+
} : void 0
|
|
2614
|
+
}, image.id)), annotations]
|
|
2615
|
+
}) : null, (strategy.type === "images" || strategy.type === "empty" || strategy.type === "textual-content") && renderViewerControls ? /* @__PURE__ */ jsx(CanvasPortal, {
|
|
2616
|
+
overlay: true,
|
|
2617
|
+
children: renderViewerControls(strategy)
|
|
2016
2618
|
}) : null, strategy.type === "3d-model" ? /* @__PURE__ */ jsx(Model, {
|
|
2017
2619
|
model: strategy.model
|
|
2018
|
-
}) : null, strategy.type === "media" ? /* @__PURE__ */ jsx(Fragment, {
|
|
2620
|
+
}) : null, strategy.type === "media" ? /* @__PURE__ */ jsx(Fragment$1, {
|
|
2019
2621
|
children: strategy.media.type === "Sound" ? /* @__PURE__ */ jsxs(Audio, {
|
|
2020
2622
|
media: strategy.media,
|
|
2021
2623
|
children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
|
|
@@ -2024,7 +2626,7 @@ function RenderCanvas({
|
|
|
2024
2626
|
children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
|
|
2025
2627
|
}) : null
|
|
2026
2628
|
}) : null]
|
|
2027
|
-
}), strategy.type), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ jsx(CanvasContext, {
|
|
2629
|
+
}), `${canvas.id}/${strategy.type}`), strategy.type === "media" && strategy.media.type === "Sound" && accompanyingCanvas ? /* @__PURE__ */ jsx(CanvasContext, {
|
|
2028
2630
|
canvas: accompanyingCanvas.id,
|
|
2029
2631
|
children: /* @__PURE__ */ jsx(RenderCanvas, {
|
|
2030
2632
|
renderViewerControls
|
|
@@ -2037,7 +2639,8 @@ const CanvasPanel = {
|
|
|
2037
2639
|
RenderCanvas,
|
|
2038
2640
|
RenderAnnotationPage,
|
|
2039
2641
|
RenderAnnotation,
|
|
2040
|
-
Viewer
|
|
2642
|
+
Viewer,
|
|
2643
|
+
CanvasBackground
|
|
2041
2644
|
};
|
|
2042
2645
|
export { CanvasPanel };
|
|
2043
2646
|
//# sourceMappingURL=canvas-panel.mjs.map
|