@digitalculture/ochre-sdk 0.4.7 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +22 -25
- package/dist/index.d.cts +3 -27
- package/dist/index.d.ts +3 -27
- package/dist/index.js +21 -22
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -71,9 +71,7 @@ __export(index_exports, {
|
|
|
71
71
|
parseStringDocumentItem: () => parseStringDocumentItem,
|
|
72
72
|
parseStringItem: () => parseStringItem,
|
|
73
73
|
parseTree: () => parseTree,
|
|
74
|
-
parseWebsite: () => parseWebsite
|
|
75
|
-
trimEndLineBreaks: () => trimEndLineBreaks,
|
|
76
|
-
trimStartLineBreaks: () => trimStartLineBreaks
|
|
74
|
+
parseWebsite: () => parseWebsite
|
|
77
75
|
});
|
|
78
76
|
module.exports = __toCommonJS(index_exports);
|
|
79
77
|
|
|
@@ -259,7 +257,7 @@ function parseStringItem(item) {
|
|
|
259
257
|
break;
|
|
260
258
|
}
|
|
261
259
|
}
|
|
262
|
-
return
|
|
260
|
+
return returnString;
|
|
263
261
|
}
|
|
264
262
|
function parseStringDocumentItem(item, footnotes) {
|
|
265
263
|
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
|
|
@@ -382,23 +380,7 @@ function parseStringDocumentItem(item, footnotes) {
|
|
|
382
380
|
);
|
|
383
381
|
}
|
|
384
382
|
}
|
|
385
|
-
return
|
|
386
|
-
}
|
|
387
|
-
function trimEndLineBreaks(string) {
|
|
388
|
-
const trimmedString = string.replaceAll(/^\n<br \/>|\n<br \/>$/g, "");
|
|
389
|
-
const finalLineBreaks = /\n<br \/>$/.exec(trimmedString);
|
|
390
|
-
if (finalLineBreaks) {
|
|
391
|
-
return trimEndLineBreaks(trimmedString);
|
|
392
|
-
}
|
|
393
|
-
return trimmedString;
|
|
394
|
-
}
|
|
395
|
-
function trimStartLineBreaks(string) {
|
|
396
|
-
const trimmedString = string.replaceAll(/^<br \/>\n|<br \/>\n$/g, "");
|
|
397
|
-
const leadingLineBreaks = /^<br \/>\n/.exec(trimmedString);
|
|
398
|
-
if (leadingLineBreaks) {
|
|
399
|
-
return trimStartLineBreaks(trimmedString);
|
|
400
|
-
}
|
|
401
|
-
return trimmedString;
|
|
383
|
+
return returnString;
|
|
402
384
|
}
|
|
403
385
|
function parseStringContent(content, language = "eng") {
|
|
404
386
|
switch (typeof content.content) {
|
|
@@ -801,7 +783,6 @@ function parseDocument(document, language = "eng") {
|
|
|
801
783
|
returnString += parseStringDocumentItem(item, footnotes);
|
|
802
784
|
}
|
|
803
785
|
}
|
|
804
|
-
returnString = trimEndLineBreaks(returnString);
|
|
805
786
|
return { content: returnString, footnotes };
|
|
806
787
|
}
|
|
807
788
|
function parseImage(image) {
|
|
@@ -1626,6 +1607,22 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1626
1607
|
if (altTextSource === null) {
|
|
1627
1608
|
altTextSource = "name";
|
|
1628
1609
|
}
|
|
1610
|
+
let isTransparentBackground = false;
|
|
1611
|
+
const isTransparentBackgroundProperty = getPropertyValueByLabel(
|
|
1612
|
+
componentProperty.properties,
|
|
1613
|
+
"is-transparent"
|
|
1614
|
+
);
|
|
1615
|
+
if (isTransparentBackgroundProperty !== null) {
|
|
1616
|
+
isTransparentBackground = isTransparentBackgroundProperty === "Yes";
|
|
1617
|
+
}
|
|
1618
|
+
let isCover = false;
|
|
1619
|
+
const isCoverProperty = getPropertyValueByLabel(
|
|
1620
|
+
componentProperty.properties,
|
|
1621
|
+
"is-cover"
|
|
1622
|
+
);
|
|
1623
|
+
if (isCoverProperty !== null) {
|
|
1624
|
+
isCover = isCoverProperty === "Yes";
|
|
1625
|
+
}
|
|
1629
1626
|
let carouselOptions = null;
|
|
1630
1627
|
if (images.length > 1) {
|
|
1631
1628
|
const variantProperty = getPropertyByLabel(
|
|
@@ -1656,6 +1653,8 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1656
1653
|
properties.captionLayout = captionLayout;
|
|
1657
1654
|
properties.captionSource = captionSource;
|
|
1658
1655
|
properties.altTextSource = altTextSource;
|
|
1656
|
+
properties.isTransparentBackground = isTransparentBackground;
|
|
1657
|
+
properties.isCover = isCover;
|
|
1659
1658
|
properties.carouselOptions = carouselOptions;
|
|
1660
1659
|
break;
|
|
1661
1660
|
}
|
|
@@ -2700,7 +2699,5 @@ async function fetchWebsite(abbreviation) {
|
|
|
2700
2699
|
parseStringDocumentItem,
|
|
2701
2700
|
parseStringItem,
|
|
2702
2701
|
parseTree,
|
|
2703
|
-
parseWebsite
|
|
2704
|
-
trimEndLineBreaks,
|
|
2705
|
-
trimStartLineBreaks
|
|
2702
|
+
parseWebsite
|
|
2706
2703
|
});
|
package/dist/index.d.cts
CHANGED
|
@@ -518,6 +518,8 @@ type WebElementComponent = {
|
|
|
518
518
|
captionSource: "name" | "abbreviation" | "description";
|
|
519
519
|
captionLayout: "top" | "bottom" | "suppress";
|
|
520
520
|
altTextSource: "name" | "abbreviation" | "description";
|
|
521
|
+
isTransparentBackground: boolean;
|
|
522
|
+
isCover: boolean;
|
|
521
523
|
carouselOptions: {
|
|
522
524
|
secondsPerImage: number;
|
|
523
525
|
} | null;
|
|
@@ -1827,32 +1829,6 @@ declare function parseStringItem(item: OchreStringItem): string;
|
|
|
1827
1829
|
* @returns Formatted string with HTML/markdown elements
|
|
1828
1830
|
*/
|
|
1829
1831
|
declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnotes?: Array<Footnote>): string;
|
|
1830
|
-
/**
|
|
1831
|
-
* Removes trailing line breaks from a string
|
|
1832
|
-
*
|
|
1833
|
-
* @param string - Input string to trim
|
|
1834
|
-
* @returns String with trailing line breaks removed
|
|
1835
|
-
*
|
|
1836
|
-
* @example
|
|
1837
|
-
* ```ts
|
|
1838
|
-
* const trimmed = trimEndLineBreaks("Hello\n<br />\n<br />");
|
|
1839
|
-
* // Returns: "Hello"
|
|
1840
|
-
* ```
|
|
1841
|
-
*/
|
|
1842
|
-
declare function trimEndLineBreaks(string: string): string;
|
|
1843
|
-
/**
|
|
1844
|
-
* Removes leading line breaks from a string
|
|
1845
|
-
*
|
|
1846
|
-
* @param string - Input string to trim
|
|
1847
|
-
* @returns String with leading line breaks removed
|
|
1848
|
-
*
|
|
1849
|
-
* @example
|
|
1850
|
-
* ```ts
|
|
1851
|
-
* const trimmed = trimStartLineBreaks("<br />\n<br />\nHello");
|
|
1852
|
-
* // Returns: "Hello"
|
|
1853
|
-
* ```
|
|
1854
|
-
*/
|
|
1855
|
-
declare function trimStartLineBreaks(string: string): string;
|
|
1856
1832
|
/**
|
|
1857
1833
|
* Parses raw string content into a formatted string
|
|
1858
1834
|
*
|
|
@@ -1862,4 +1838,4 @@ declare function trimStartLineBreaks(string: string): string;
|
|
|
1862
1838
|
*/
|
|
1863
1839
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1864
1840
|
|
|
1865
|
-
export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite
|
|
1841
|
+
export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
package/dist/index.d.ts
CHANGED
|
@@ -518,6 +518,8 @@ type WebElementComponent = {
|
|
|
518
518
|
captionSource: "name" | "abbreviation" | "description";
|
|
519
519
|
captionLayout: "top" | "bottom" | "suppress";
|
|
520
520
|
altTextSource: "name" | "abbreviation" | "description";
|
|
521
|
+
isTransparentBackground: boolean;
|
|
522
|
+
isCover: boolean;
|
|
521
523
|
carouselOptions: {
|
|
522
524
|
secondsPerImage: number;
|
|
523
525
|
} | null;
|
|
@@ -1827,32 +1829,6 @@ declare function parseStringItem(item: OchreStringItem): string;
|
|
|
1827
1829
|
* @returns Formatted string with HTML/markdown elements
|
|
1828
1830
|
*/
|
|
1829
1831
|
declare function parseStringDocumentItem(item: OchreStringRichTextItem, footnotes?: Array<Footnote>): string;
|
|
1830
|
-
/**
|
|
1831
|
-
* Removes trailing line breaks from a string
|
|
1832
|
-
*
|
|
1833
|
-
* @param string - Input string to trim
|
|
1834
|
-
* @returns String with trailing line breaks removed
|
|
1835
|
-
*
|
|
1836
|
-
* @example
|
|
1837
|
-
* ```ts
|
|
1838
|
-
* const trimmed = trimEndLineBreaks("Hello\n<br />\n<br />");
|
|
1839
|
-
* // Returns: "Hello"
|
|
1840
|
-
* ```
|
|
1841
|
-
*/
|
|
1842
|
-
declare function trimEndLineBreaks(string: string): string;
|
|
1843
|
-
/**
|
|
1844
|
-
* Removes leading line breaks from a string
|
|
1845
|
-
*
|
|
1846
|
-
* @param string - Input string to trim
|
|
1847
|
-
* @returns String with leading line breaks removed
|
|
1848
|
-
*
|
|
1849
|
-
* @example
|
|
1850
|
-
* ```ts
|
|
1851
|
-
* const trimmed = trimStartLineBreaks("<br />\n<br />\nHello");
|
|
1852
|
-
* // Returns: "Hello"
|
|
1853
|
-
* ```
|
|
1854
|
-
*/
|
|
1855
|
-
declare function trimStartLineBreaks(string: string): string;
|
|
1856
1832
|
/**
|
|
1857
1833
|
* Parses raw string content into a formatted string
|
|
1858
1834
|
*
|
|
@@ -1862,4 +1838,4 @@ declare function trimStartLineBreaks(string: string): string;
|
|
|
1862
1838
|
*/
|
|
1863
1839
|
declare function parseStringContent(content: OchreStringContent, language?: string): string;
|
|
1864
1840
|
|
|
1865
|
-
export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite
|
|
1841
|
+
export { type Bibliography, type Block, type Concept, type Context, type ContextItem, type ContextNode, type Coordinates, type Data, type Document, type Event, type Footnote, type Gallery, type Identification, type Image, type ImageMap, type ImageMapArea, type Interpretation, type License, type Link, type Metadata, type NestedConcept, type NestedResource, type NestedSpatialUnit, type Note, type Observation, type Period, type Person, type Property, type PropertyValue, type PropertyValueType, type Resource, type Set, type SpatialUnit, type Style, type Tree, type WebElement, type WebElementComponent, type WebImage, type Webpage, type WebpageProperties, type Website, type WebsiteProperties, fetchBibliography, fetchByUuid, fetchConcept, fetchGallery, fetchPeriod, fetchResource, fetchSet, fetchSpatialUnit, fetchTree, fetchWebsite, filterProperties, getAllPropertyLabels, getPropertyByLabel, getPropertyValueByLabel, getPropertyValuesByLabel, parseBibliographies, parseBibliography, parseConcept, parseConcepts, parseContext, parseCoordinates, parseDocument, parseEmailAndUrl, parseEvents, parseFakeString, parseIdentification, parseImage, parseImageMap, parseInterpretations, parseLanguages, parseLicense, parseLink, parseLinks, parseMetadata, parseNotes, parseObservation, parseObservations, parsePeriod, parsePeriods, parsePerson, parsePersons, parseProperties, parseResource, parseResources, parseSet, parseSpatialUnit, parseSpatialUnits, parseStringContent, parseStringDocumentItem, parseStringItem, parseTree, parseWebsite };
|
package/dist/index.js
CHANGED
|
@@ -180,7 +180,7 @@ function parseStringItem(item) {
|
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
|
-
return
|
|
183
|
+
return returnString;
|
|
184
184
|
}
|
|
185
185
|
function parseStringDocumentItem(item, footnotes) {
|
|
186
186
|
if (typeof item === "string" || typeof item === "number" || typeof item === "boolean") {
|
|
@@ -303,23 +303,7 @@ function parseStringDocumentItem(item, footnotes) {
|
|
|
303
303
|
);
|
|
304
304
|
}
|
|
305
305
|
}
|
|
306
|
-
return
|
|
307
|
-
}
|
|
308
|
-
function trimEndLineBreaks(string) {
|
|
309
|
-
const trimmedString = string.replaceAll(/^\n<br \/>|\n<br \/>$/g, "");
|
|
310
|
-
const finalLineBreaks = /\n<br \/>$/.exec(trimmedString);
|
|
311
|
-
if (finalLineBreaks) {
|
|
312
|
-
return trimEndLineBreaks(trimmedString);
|
|
313
|
-
}
|
|
314
|
-
return trimmedString;
|
|
315
|
-
}
|
|
316
|
-
function trimStartLineBreaks(string) {
|
|
317
|
-
const trimmedString = string.replaceAll(/^<br \/>\n|<br \/>\n$/g, "");
|
|
318
|
-
const leadingLineBreaks = /^<br \/>\n/.exec(trimmedString);
|
|
319
|
-
if (leadingLineBreaks) {
|
|
320
|
-
return trimStartLineBreaks(trimmedString);
|
|
321
|
-
}
|
|
322
|
-
return trimmedString;
|
|
306
|
+
return returnString;
|
|
323
307
|
}
|
|
324
308
|
function parseStringContent(content, language = "eng") {
|
|
325
309
|
switch (typeof content.content) {
|
|
@@ -722,7 +706,6 @@ function parseDocument(document, language = "eng") {
|
|
|
722
706
|
returnString += parseStringDocumentItem(item, footnotes);
|
|
723
707
|
}
|
|
724
708
|
}
|
|
725
|
-
returnString = trimEndLineBreaks(returnString);
|
|
726
709
|
return { content: returnString, footnotes };
|
|
727
710
|
}
|
|
728
711
|
function parseImage(image) {
|
|
@@ -1547,6 +1530,22 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1547
1530
|
if (altTextSource === null) {
|
|
1548
1531
|
altTextSource = "name";
|
|
1549
1532
|
}
|
|
1533
|
+
let isTransparentBackground = false;
|
|
1534
|
+
const isTransparentBackgroundProperty = getPropertyValueByLabel(
|
|
1535
|
+
componentProperty.properties,
|
|
1536
|
+
"is-transparent"
|
|
1537
|
+
);
|
|
1538
|
+
if (isTransparentBackgroundProperty !== null) {
|
|
1539
|
+
isTransparentBackground = isTransparentBackgroundProperty === "Yes";
|
|
1540
|
+
}
|
|
1541
|
+
let isCover = false;
|
|
1542
|
+
const isCoverProperty = getPropertyValueByLabel(
|
|
1543
|
+
componentProperty.properties,
|
|
1544
|
+
"is-cover"
|
|
1545
|
+
);
|
|
1546
|
+
if (isCoverProperty !== null) {
|
|
1547
|
+
isCover = isCoverProperty === "Yes";
|
|
1548
|
+
}
|
|
1550
1549
|
let carouselOptions = null;
|
|
1551
1550
|
if (images.length > 1) {
|
|
1552
1551
|
const variantProperty = getPropertyByLabel(
|
|
@@ -1577,6 +1576,8 @@ async function parseWebElementProperties(componentProperty, elementResource) {
|
|
|
1577
1576
|
properties.captionLayout = captionLayout;
|
|
1578
1577
|
properties.captionSource = captionSource;
|
|
1579
1578
|
properties.altTextSource = altTextSource;
|
|
1579
|
+
properties.isTransparentBackground = isTransparentBackground;
|
|
1580
|
+
properties.isCover = isCover;
|
|
1580
1581
|
properties.carouselOptions = carouselOptions;
|
|
1581
1582
|
break;
|
|
1582
1583
|
}
|
|
@@ -2620,7 +2621,5 @@ export {
|
|
|
2620
2621
|
parseStringDocumentItem,
|
|
2621
2622
|
parseStringItem,
|
|
2622
2623
|
parseTree,
|
|
2623
|
-
parseWebsite
|
|
2624
|
-
trimEndLineBreaks,
|
|
2625
|
-
trimStartLineBreaks
|
|
2624
|
+
parseWebsite
|
|
2626
2625
|
};
|
package/package.json
CHANGED