react-iiif-vault 0.9.15 → 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 -3
- package/dist/bundle/cjs/index.js.map +1 -1
- package/dist/bundle/esm/index.mjs +1020 -214
- package/dist/bundle/esm/index.mjs.map +1 -1
- package/dist/canvas-panel/cjs/canvas-panel.js +5 -3
- package/dist/canvas-panel/cjs/canvas-panel.js.map +1 -1
- package/dist/canvas-panel/esm/canvas-panel.mjs +729 -94
- package/dist/canvas-panel/esm/canvas-panel.mjs.map +1 -1
- package/dist/index.umd.js +22 -20
- 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 +13 -8
|
@@ -31,11 +31,12 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
};
|
|
32
32
|
import * as React from "react";
|
|
33
33
|
import React__default, { useContext, useMemo, useState, useEffect, createContext, useRef, useLayoutEffect, useCallback, Fragment, useReducer } from "react";
|
|
34
|
-
import { AtlasAuto, mergeStyles, RegionHighlight, TileSet } from "@atlas-viewer/atlas";
|
|
34
|
+
import { AtlasAuto, mergeStyles, RegionHighlight, TileSet, HTMLPortal } from "@atlas-viewer/atlas";
|
|
35
35
|
import { jsx, jsxs, Fragment as Fragment$1 } from "react/jsx-runtime";
|
|
36
36
|
import { globalVault, Vault } from "@iiif/vault";
|
|
37
37
|
import { createAction } from "typesafe-actions";
|
|
38
|
-
import
|
|
38
|
+
import { createRoot } from "react-dom/client";
|
|
39
|
+
import { expandTarget as expandTarget$1 } from "@iiif/vault-helpers";
|
|
39
40
|
import { ImageServiceLoader, getImageServices, getFixedSizeFromImage } from "@atlas-viewer/iiif-image-api";
|
|
40
41
|
function _setPrototypeOf(o, p) {
|
|
41
42
|
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
|
|
@@ -220,6 +221,22 @@ function useVisibleCanvases() {
|
|
|
220
221
|
return ids.map((id) => state.iiif.entities.Canvas[id]).filter(Boolean);
|
|
221
222
|
}, [ids]);
|
|
222
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
|
+
}
|
|
223
240
|
const noop = () => {
|
|
224
241
|
};
|
|
225
242
|
const SimpleViewerReactContext = createContext({
|
|
@@ -227,9 +244,10 @@ const SimpleViewerReactContext = createContext({
|
|
|
227
244
|
setCurrentCanvasIndex: noop,
|
|
228
245
|
nextCanvas: noop,
|
|
229
246
|
previousCanvas: noop,
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
items: [],
|
|
248
|
+
sequence: [],
|
|
249
|
+
setSequenceIndex: noop,
|
|
250
|
+
currentSequenceIndex: 0
|
|
233
251
|
});
|
|
234
252
|
function useContextBridge() {
|
|
235
253
|
return {
|
|
@@ -435,11 +453,6 @@ function DefaultCanvasFallback({
|
|
|
435
453
|
children: "Unknown error"
|
|
436
454
|
});
|
|
437
455
|
}
|
|
438
|
-
var createRoot;
|
|
439
|
-
var m = require$$0;
|
|
440
|
-
{
|
|
441
|
-
createRoot = m.createRoot;
|
|
442
|
-
}
|
|
443
456
|
const ViewerPresetContext = createContext(null);
|
|
444
457
|
function useViewerPreset() {
|
|
445
458
|
return useContext(ViewerPresetContext);
|
|
@@ -451,26 +464,16 @@ function CanvasPortal({
|
|
|
451
464
|
overlay
|
|
452
465
|
}) {
|
|
453
466
|
const htmlElement = useContext(overlay ? OverlayPortalContext : PortalContext);
|
|
454
|
-
const rootRef = useRef(null);
|
|
455
467
|
const preset = useViewerPreset();
|
|
456
468
|
useLayoutEffect(() => {
|
|
457
|
-
if (
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
rootRef.current = null;
|
|
466
|
-
};
|
|
467
|
-
}, []);
|
|
468
|
-
useLayoutEffect(() => {
|
|
469
|
-
if (rootRef.current) {
|
|
470
|
-
rootRef.current.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
471
|
-
value: preset,
|
|
472
|
-
children
|
|
473
|
-
}));
|
|
469
|
+
if (htmlElement) {
|
|
470
|
+
try {
|
|
471
|
+
htmlElement.render(/* @__PURE__ */ jsx(ViewerPresetContext.Provider, {
|
|
472
|
+
value: preset,
|
|
473
|
+
children
|
|
474
|
+
}));
|
|
475
|
+
} catch (e) {
|
|
476
|
+
}
|
|
474
477
|
}
|
|
475
478
|
}, [children, preset]);
|
|
476
479
|
return null;
|
|
@@ -493,8 +496,31 @@ function Viewer(_a) {
|
|
|
493
496
|
const bridge = useContextBridge();
|
|
494
497
|
const ErrorFallback = errorFallback || DefaultCanvasFallback;
|
|
495
498
|
useLayoutEffect(() => {
|
|
496
|
-
|
|
497
|
-
|
|
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
|
+
};
|
|
498
524
|
}, []);
|
|
499
525
|
return /* @__PURE__ */ jsxs(ErrorBoundary, {
|
|
500
526
|
fallbackRender: () => /* @__PURE__ */ jsx(ErrorFallback, __spreadValues({}, props)),
|
|
@@ -617,25 +643,25 @@ function useStyles(resource, scope) {
|
|
|
617
643
|
return styles ? scope ? styles[scope] : styles : void 0;
|
|
618
644
|
}, [resource, scope]);
|
|
619
645
|
}
|
|
620
|
-
var
|
|
621
|
-
var
|
|
622
|
-
var
|
|
623
|
-
var
|
|
624
|
-
var
|
|
625
|
-
var
|
|
626
|
-
var
|
|
627
|
-
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) => {
|
|
628
654
|
for (var prop in b || (b = {}))
|
|
629
|
-
if (
|
|
630
|
-
|
|
631
|
-
if (
|
|
632
|
-
for (var prop of
|
|
633
|
-
if (
|
|
634
|
-
|
|
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]);
|
|
635
661
|
}
|
|
636
662
|
return a;
|
|
637
663
|
};
|
|
638
|
-
var
|
|
664
|
+
var __spreadProps$1 = (a, b) => __defProps$1(a, __getOwnPropDescs$1(b));
|
|
639
665
|
const BOX_SELECTOR = /&?(xywh=)?(pixel:|percent:|pct:)?([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?),([0-9]+(?:\.[0-9]+)?)/;
|
|
640
666
|
const TEMPORAL_SELECTOR = /&?(t=)(npt:)?([0-9]+(.[0-9]+)?)?(,([0-9]+(.[0-9]+)?))?/;
|
|
641
667
|
function parseSelector(source) {
|
|
@@ -780,7 +806,7 @@ function expandTarget(target, options = {}) {
|
|
|
780
806
|
if (!fragment) {
|
|
781
807
|
return {
|
|
782
808
|
type: "SpecificResource",
|
|
783
|
-
source:
|
|
809
|
+
source: __spreadProps$1(__spreadValues$1({}, target), {
|
|
784
810
|
id
|
|
785
811
|
}),
|
|
786
812
|
selector: null,
|
|
@@ -789,7 +815,7 @@ function expandTarget(target, options = {}) {
|
|
|
789
815
|
}
|
|
790
816
|
return expandTarget({
|
|
791
817
|
type: "SpecificResource",
|
|
792
|
-
source:
|
|
818
|
+
source: __spreadProps$1(__spreadValues$1({}, target), {
|
|
793
819
|
id
|
|
794
820
|
}),
|
|
795
821
|
selector: {
|
|
@@ -898,20 +924,21 @@ function RenderImage({
|
|
|
898
924
|
isStatic,
|
|
899
925
|
x = 0,
|
|
900
926
|
y = 0,
|
|
901
|
-
|
|
902
|
-
|
|
927
|
+
children,
|
|
928
|
+
onClick
|
|
903
929
|
}) {
|
|
904
930
|
var _a, _b, _c, _d;
|
|
905
931
|
return /* @__PURE__ */ jsx(Fragment, {
|
|
906
932
|
children: !image.service ? /* @__PURE__ */ jsxs(Fragment, {
|
|
907
933
|
children: [/* @__PURE__ */ jsx("world-image", {
|
|
934
|
+
onClick,
|
|
908
935
|
uri: image.id,
|
|
909
936
|
target: image.target.spatial,
|
|
910
937
|
display: image.width && image.height ? {
|
|
911
938
|
width: image.width,
|
|
912
939
|
height: image.height
|
|
913
940
|
} : void 0
|
|
914
|
-
}),
|
|
941
|
+
}), children]
|
|
915
942
|
}, "no-service") : /* @__PURE__ */ jsxs(Fragment, {
|
|
916
943
|
children: [/* @__PURE__ */ jsx(TileSet, {
|
|
917
944
|
tiles: {
|
|
@@ -924,8 +951,9 @@ function RenderImage({
|
|
|
924
951
|
x: ((_a = image.target) == null ? void 0 : _a.spatial.x) + x,
|
|
925
952
|
y: ((_b = image.target) == null ? void 0 : _b.spatial.y) + y,
|
|
926
953
|
width: (_c = image.target) == null ? void 0 : _c.spatial.width,
|
|
927
|
-
height: (_d = image.target) == null ? void 0 : _d.spatial.height
|
|
928
|
-
|
|
954
|
+
height: (_d = image.target) == null ? void 0 : _d.spatial.height,
|
|
955
|
+
onClick
|
|
956
|
+
}), children]
|
|
929
957
|
}, "service")
|
|
930
958
|
}, id);
|
|
931
959
|
}
|
|
@@ -966,6 +994,7 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
|
|
|
966
994
|
types.push(type);
|
|
967
995
|
}
|
|
968
996
|
items.push({
|
|
997
|
+
annotationId: annotation.id,
|
|
969
998
|
type,
|
|
970
999
|
resource: body,
|
|
971
1000
|
target: annotation.target,
|
|
@@ -979,6 +1008,29 @@ function getPaintables(vault, paintingAnnotations, enabledChoices) {
|
|
|
979
1008
|
choice
|
|
980
1009
|
};
|
|
981
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
|
+
}
|
|
982
1034
|
const emptyActions = {
|
|
983
1035
|
makeChoice: () => {
|
|
984
1036
|
}
|
|
@@ -987,22 +1039,9 @@ const unknownResponse = { type: "unknown" };
|
|
|
987
1039
|
const unsupportedStrategy = (reason) => {
|
|
988
1040
|
return { type: "unknown", reason, annotations: { pages: [] } };
|
|
989
1041
|
};
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
useVault();
|
|
994
|
-
const manifestId = id ? id : ctx.manifest;
|
|
995
|
-
const manifest = useVaultSelector((s) => manifestId ? s.iiif.entities.Manifest[manifestId] : void 0, [manifestId]);
|
|
996
|
-
return useMemo(() => {
|
|
997
|
-
if (!manifest) {
|
|
998
|
-
return void 0;
|
|
999
|
-
}
|
|
1000
|
-
if (selector) {
|
|
1001
|
-
return selector(manifest);
|
|
1002
|
-
}
|
|
1003
|
-
return manifest;
|
|
1004
|
-
}, [manifest, selector, ...deps]);
|
|
1005
|
-
}
|
|
1042
|
+
const emptyStrategy = (width, height) => {
|
|
1043
|
+
return { type: "empty", width, height, annotations: { pages: [] }, image: null, images: [] };
|
|
1044
|
+
};
|
|
1006
1045
|
function getMeta$1(state, resourceId) {
|
|
1007
1046
|
var _a;
|
|
1008
1047
|
const resourceMeta = (_a = state == null ? void 0 : state.iiif) == null ? void 0 : _a.meta[resourceId];
|
|
@@ -1256,10 +1295,6 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1256
1295
|
imageService = loadImageService(imageServices[0], canvas);
|
|
1257
1296
|
}
|
|
1258
1297
|
}
|
|
1259
|
-
const { selector: imageTarget, source } = expandTarget(singleImage.target);
|
|
1260
|
-
if (source.id !== canvas.id) {
|
|
1261
|
-
continue;
|
|
1262
|
-
}
|
|
1263
1298
|
const defaultTarget = {
|
|
1264
1299
|
type: "BoxSelector",
|
|
1265
1300
|
spatial: {
|
|
@@ -1269,11 +1304,10 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1269
1304
|
height: canvas.height
|
|
1270
1305
|
}
|
|
1271
1306
|
};
|
|
1272
|
-
const target =
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
} : imageTarget : null;
|
|
1307
|
+
const [target, source] = getParsedTargetSelector(canvas, singleImage.target);
|
|
1308
|
+
if (source.id !== canvas.id) {
|
|
1309
|
+
continue;
|
|
1310
|
+
}
|
|
1277
1311
|
const defaultImageSelector = {
|
|
1278
1312
|
type: "BoxSelector",
|
|
1279
1313
|
spatial: {
|
|
@@ -1299,6 +1333,7 @@ function getImageStrategy(canvas, paintables, loadImageService) {
|
|
|
1299
1333
|
const imageType = {
|
|
1300
1334
|
id: resource.id,
|
|
1301
1335
|
type: "Image",
|
|
1336
|
+
annotationId: singleImage.annotationId,
|
|
1302
1337
|
width: target ? resource.width : canvas.width,
|
|
1303
1338
|
height: target ? resource.height : canvas.height,
|
|
1304
1339
|
service: imageService,
|
|
@@ -1348,6 +1383,7 @@ function getAudioStrategy(canvas, paintables) {
|
|
|
1348
1383
|
return {
|
|
1349
1384
|
type: "media",
|
|
1350
1385
|
media: {
|
|
1386
|
+
annotationId: paintables.items[0].annotationId,
|
|
1351
1387
|
duration: canvas.duration,
|
|
1352
1388
|
url: audioResource.id,
|
|
1353
1389
|
type: "Sound",
|
|
@@ -1391,6 +1427,7 @@ function getVideoStrategy(canvas, paintables) {
|
|
|
1391
1427
|
return {
|
|
1392
1428
|
type: "media",
|
|
1393
1429
|
media: {
|
|
1430
|
+
annotationId: paintables.items[0].annotationId,
|
|
1394
1431
|
duration: canvas.duration,
|
|
1395
1432
|
url: audioResource.id,
|
|
1396
1433
|
type: "Video",
|
|
@@ -1416,6 +1453,38 @@ function getVideoStrategy(canvas, paintables) {
|
|
|
1416
1453
|
}
|
|
1417
1454
|
};
|
|
1418
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
|
+
}
|
|
1419
1488
|
function useRenderingStrategy(options) {
|
|
1420
1489
|
const manifest = useManifest();
|
|
1421
1490
|
const canvas = useCanvas();
|
|
@@ -1425,10 +1494,22 @@ function useRenderingStrategy(options) {
|
|
|
1425
1494
|
all: false
|
|
1426
1495
|
});
|
|
1427
1496
|
const enabledPages = useResources(enabledPageIds, "AnnotationPage");
|
|
1428
|
-
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
|
+
];
|
|
1429
1504
|
const [paintables, actions] = usePaintables(options, [imageServiceStatus]);
|
|
1430
1505
|
const strategy = useMemo(() => {
|
|
1431
|
-
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
|
+
}
|
|
1432
1513
|
return unknownResponse;
|
|
1433
1514
|
}
|
|
1434
1515
|
if (paintables.types.length !== 1) {
|
|
@@ -1454,6 +1535,12 @@ function useRenderingStrategy(options) {
|
|
|
1454
1535
|
}
|
|
1455
1536
|
return get3dStrategy(canvas, paintables);
|
|
1456
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
|
+
}
|
|
1457
1544
|
if (mainType === "sound" || mainType === "audio") {
|
|
1458
1545
|
if (supports.indexOf("media") === -1) {
|
|
1459
1546
|
return unsupportedStrategy("Media not supported");
|
|
@@ -1573,6 +1660,7 @@ function useThumbnail(request, dereference, { canvasId, manifestId } = {}) {
|
|
|
1573
1660
|
const subject = canvas ? canvas : manifest;
|
|
1574
1661
|
const didUnmount = useRef(false);
|
|
1575
1662
|
useEffect(() => {
|
|
1663
|
+
didUnmount.current = false;
|
|
1576
1664
|
return () => {
|
|
1577
1665
|
didUnmount.current = true;
|
|
1578
1666
|
};
|
|
@@ -1872,6 +1960,533 @@ function Model({
|
|
|
1872
1960
|
})]
|
|
1873
1961
|
});
|
|
1874
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
|
+
};
|
|
1875
2490
|
function RenderCanvas({
|
|
1876
2491
|
x,
|
|
1877
2492
|
y,
|
|
@@ -1882,6 +2497,9 @@ function RenderCanvas({
|
|
|
1882
2497
|
renderViewerControls,
|
|
1883
2498
|
renderMediaControls,
|
|
1884
2499
|
strategies,
|
|
2500
|
+
backgroundStyle,
|
|
2501
|
+
alwaysShowBackground,
|
|
2502
|
+
onClickPaintingAnnotation,
|
|
1885
2503
|
children
|
|
1886
2504
|
}) {
|
|
1887
2505
|
const canvas = useCanvas();
|
|
@@ -1968,19 +2586,35 @@ function RenderCanvas({
|
|
|
1968
2586
|
x,
|
|
1969
2587
|
y
|
|
1970
2588
|
}, elementProps), {
|
|
1971
|
-
children: [strategy.type === "
|
|
1972
|
-
|
|
1973
|
-
|
|
1974
|
-
|
|
1975
|
-
|
|
1976
|
-
|
|
1977
|
-
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
|
|
1981
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
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)
|
|
1984
2618
|
}) : null, strategy.type === "3d-model" ? /* @__PURE__ */ jsx(Model, {
|
|
1985
2619
|
model: strategy.model
|
|
1986
2620
|
}) : null, strategy.type === "media" ? /* @__PURE__ */ jsx(Fragment$1, {
|
|
@@ -1992,7 +2626,7 @@ function RenderCanvas({
|
|
|
1992
2626
|
children: [thumbnailFallbackImage, renderMediaControls ? renderMediaControls(strategy) : null]
|
|
1993
2627
|
}) : null
|
|
1994
2628
|
}) : null]
|
|
1995
|
-
}), 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, {
|
|
1996
2630
|
canvas: accompanyingCanvas.id,
|
|
1997
2631
|
children: /* @__PURE__ */ jsx(RenderCanvas, {
|
|
1998
2632
|
renderViewerControls
|
|
@@ -2005,7 +2639,8 @@ const CanvasPanel = {
|
|
|
2005
2639
|
RenderCanvas,
|
|
2006
2640
|
RenderAnnotationPage,
|
|
2007
2641
|
RenderAnnotation,
|
|
2008
|
-
Viewer
|
|
2642
|
+
Viewer,
|
|
2643
|
+
CanvasBackground
|
|
2009
2644
|
};
|
|
2010
2645
|
export { CanvasPanel };
|
|
2011
2646
|
//# sourceMappingURL=canvas-panel.mjs.map
|