@digitalculture/ochre-sdk 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +20 -16
- package/dist/index.js +20 -16
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1327,7 +1327,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1327
1327
|
const links = elementResource.links ? parseLinks(
|
|
1328
1328
|
Array.isArray(elementResource.links) ? elementResource.links : [elementResource.links]
|
|
1329
1329
|
) : [];
|
|
1330
|
-
const
|
|
1330
|
+
const imageLinks = links.filter((link) => link.type === "image");
|
|
1331
1331
|
let document = elementResource.document ? parseDocument(elementResource.document.content) : null;
|
|
1332
1332
|
if (document === null) {
|
|
1333
1333
|
const documentLink = links.find((link) => link.type === "internalDocument");
|
|
@@ -1350,7 +1350,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1350
1350
|
break;
|
|
1351
1351
|
}
|
|
1352
1352
|
case "annotated-image": {
|
|
1353
|
-
if (
|
|
1353
|
+
if (imageLinks.length === 0) {
|
|
1354
1354
|
throw new Error(
|
|
1355
1355
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1356
1356
|
);
|
|
@@ -1359,7 +1359,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1359
1359
|
componentProperty.properties,
|
|
1360
1360
|
"is-searchable"
|
|
1361
1361
|
) === "Yes";
|
|
1362
|
-
properties.imageUuid =
|
|
1362
|
+
properties.imageUuid = imageLinks[0].uuid;
|
|
1363
1363
|
properties.isSearchable = isSearchable;
|
|
1364
1364
|
break;
|
|
1365
1365
|
}
|
|
@@ -1458,7 +1458,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1458
1458
|
break;
|
|
1459
1459
|
}
|
|
1460
1460
|
case "image": {
|
|
1461
|
-
if (
|
|
1461
|
+
if (imageLinks.length === 0) {
|
|
1462
1462
|
throw new Error(
|
|
1463
1463
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1464
1464
|
);
|
|
@@ -1491,12 +1491,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1491
1491
|
if (altTextSource === null) {
|
|
1492
1492
|
altTextSource = "name";
|
|
1493
1493
|
}
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1494
|
+
const images = [];
|
|
1495
|
+
for (const imageLink of imageLinks) {
|
|
1496
|
+
images.push({
|
|
1497
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
|
|
1498
|
+
label: imageLink.identification?.label ?? null,
|
|
1499
|
+
width: imageLink.image?.width ?? 0,
|
|
1500
|
+
height: imageLink.image?.height ?? 0
|
|
1501
|
+
});
|
|
1502
|
+
}
|
|
1503
|
+
properties.images = images;
|
|
1500
1504
|
properties.imageQuality = imageQuality;
|
|
1501
1505
|
properties.captionLayout = captionLayout;
|
|
1502
1506
|
properties.captionSource = captionSource;
|
|
@@ -1606,10 +1610,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1606
1610
|
if (captionLayout === null) {
|
|
1607
1611
|
captionLayout = "bottom";
|
|
1608
1612
|
}
|
|
1609
|
-
const
|
|
1613
|
+
const imageLink = links.find(
|
|
1610
1614
|
(link) => link.type === "image" || link.type === "IIIF"
|
|
1611
1615
|
);
|
|
1612
|
-
if (!
|
|
1616
|
+
if (!imageLink) {
|
|
1613
1617
|
throw new Error(
|
|
1614
1618
|
`Image link not found for the following component: \u201C${componentName}\u201D: ${JSON.stringify(
|
|
1615
1619
|
links
|
|
@@ -1639,10 +1643,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1639
1643
|
}
|
|
1640
1644
|
properties.variant = variant;
|
|
1641
1645
|
properties.image = {
|
|
1642
|
-
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${
|
|
1643
|
-
label:
|
|
1644
|
-
width:
|
|
1645
|
-
height:
|
|
1646
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&preview`,
|
|
1647
|
+
label: imageLink.identification?.label ?? null,
|
|
1648
|
+
width: imageLink.image?.width ?? 0,
|
|
1649
|
+
height: imageLink.image?.height ?? 0
|
|
1646
1650
|
};
|
|
1647
1651
|
properties.imageQuality = imageQuality;
|
|
1648
1652
|
properties.layout = layout;
|
package/dist/index.js
CHANGED
|
@@ -1250,7 +1250,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1250
1250
|
const links = elementResource.links ? parseLinks(
|
|
1251
1251
|
Array.isArray(elementResource.links) ? elementResource.links : [elementResource.links]
|
|
1252
1252
|
) : [];
|
|
1253
|
-
const
|
|
1253
|
+
const imageLinks = links.filter((link) => link.type === "image");
|
|
1254
1254
|
let document = elementResource.document ? parseDocument(elementResource.document.content) : null;
|
|
1255
1255
|
if (document === null) {
|
|
1256
1256
|
const documentLink = links.find((link) => link.type === "internalDocument");
|
|
@@ -1273,7 +1273,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1273
1273
|
break;
|
|
1274
1274
|
}
|
|
1275
1275
|
case "annotated-image": {
|
|
1276
|
-
if (
|
|
1276
|
+
if (imageLinks.length === 0) {
|
|
1277
1277
|
throw new Error(
|
|
1278
1278
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1279
1279
|
);
|
|
@@ -1282,7 +1282,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1282
1282
|
componentProperty.properties,
|
|
1283
1283
|
"is-searchable"
|
|
1284
1284
|
) === "Yes";
|
|
1285
|
-
properties.imageUuid =
|
|
1285
|
+
properties.imageUuid = imageLinks[0].uuid;
|
|
1286
1286
|
properties.isSearchable = isSearchable;
|
|
1287
1287
|
break;
|
|
1288
1288
|
}
|
|
@@ -1381,7 +1381,7 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1381
1381
|
break;
|
|
1382
1382
|
}
|
|
1383
1383
|
case "image": {
|
|
1384
|
-
if (
|
|
1384
|
+
if (imageLinks.length === 0) {
|
|
1385
1385
|
throw new Error(
|
|
1386
1386
|
`Image link not found for the following component: \u201C${componentName}\u201D`
|
|
1387
1387
|
);
|
|
@@ -1414,12 +1414,16 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1414
1414
|
if (altTextSource === null) {
|
|
1415
1415
|
altTextSource = "name";
|
|
1416
1416
|
}
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1417
|
+
const images = [];
|
|
1418
|
+
for (const imageLink of imageLinks) {
|
|
1419
|
+
images.push({
|
|
1420
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&load`,
|
|
1421
|
+
label: imageLink.identification?.label ?? null,
|
|
1422
|
+
width: imageLink.image?.width ?? 0,
|
|
1423
|
+
height: imageLink.image?.height ?? 0
|
|
1424
|
+
});
|
|
1425
|
+
}
|
|
1426
|
+
properties.images = images;
|
|
1423
1427
|
properties.imageQuality = imageQuality;
|
|
1424
1428
|
properties.captionLayout = captionLayout;
|
|
1425
1429
|
properties.captionSource = captionSource;
|
|
@@ -1529,10 +1533,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1529
1533
|
if (captionLayout === null) {
|
|
1530
1534
|
captionLayout = "bottom";
|
|
1531
1535
|
}
|
|
1532
|
-
const
|
|
1536
|
+
const imageLink = links.find(
|
|
1533
1537
|
(link) => link.type === "image" || link.type === "IIIF"
|
|
1534
1538
|
);
|
|
1535
|
-
if (!
|
|
1539
|
+
if (!imageLink) {
|
|
1536
1540
|
throw new Error(
|
|
1537
1541
|
`Image link not found for the following component: \u201C${componentName}\u201D: ${JSON.stringify(
|
|
1538
1542
|
links
|
|
@@ -1562,10 +1566,10 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1562
1566
|
}
|
|
1563
1567
|
properties.variant = variant;
|
|
1564
1568
|
properties.image = {
|
|
1565
|
-
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${
|
|
1566
|
-
label:
|
|
1567
|
-
width:
|
|
1568
|
-
height:
|
|
1569
|
+
url: `https://ochre.lib.uchicago.edu/ochre?uuid=${imageLink.uuid}&preview`,
|
|
1570
|
+
label: imageLink.identification?.label ?? null,
|
|
1571
|
+
width: imageLink.image?.width ?? 0,
|
|
1572
|
+
height: imageLink.image?.height ?? 0
|
|
1569
1573
|
};
|
|
1570
1574
|
properties.imageQuality = imageQuality;
|
|
1571
1575
|
properties.layout = layout;
|
package/package.json
CHANGED