@c-rex/utils 0.3.0-build.35 → 0.3.0-build.38
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/directoryNodes.js +2 -2
- package/dist/directoryNodes.js.map +1 -1
- package/dist/directoryNodes.mjs +2 -2
- package/dist/directoryNodes.mjs.map +1 -1
- package/dist/index.d.mts +6 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +66 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1670,7 +1670,18 @@ var transformLanguageData = (data) => {
|
|
|
1670
1670
|
value: normalizedValue
|
|
1671
1671
|
};
|
|
1672
1672
|
});
|
|
1673
|
-
return countryCodeList.
|
|
1673
|
+
return countryCodeList.reduce((acc, item) => {
|
|
1674
|
+
const existingIndex = acc.findIndex((existing) => existing.lang === item.lang);
|
|
1675
|
+
if (existingIndex !== -1) {
|
|
1676
|
+
const existing = acc[existingIndex];
|
|
1677
|
+
if (item.value.includes("-") && !existing.value.includes("-")) {
|
|
1678
|
+
acc[existingIndex] = item;
|
|
1679
|
+
}
|
|
1680
|
+
} else {
|
|
1681
|
+
acc.push(item);
|
|
1682
|
+
}
|
|
1683
|
+
return acc;
|
|
1684
|
+
}, []).sort((a, b) => {
|
|
1674
1685
|
return a.value.localeCompare(b.value);
|
|
1675
1686
|
});
|
|
1676
1687
|
};
|
|
@@ -1715,10 +1726,10 @@ var getType = (classObj, lang = EN_LANG) => {
|
|
|
1715
1726
|
};
|
|
1716
1727
|
var getTitle = (titles, labels) => {
|
|
1717
1728
|
if (titles) {
|
|
1718
|
-
return titles[0]?.value;
|
|
1729
|
+
return titles[0]?.value || "NO TITLE";
|
|
1719
1730
|
}
|
|
1720
1731
|
if (labels) {
|
|
1721
|
-
return labels[0]?.value;
|
|
1732
|
+
return labels[0]?.value || "NO TITLE";
|
|
1722
1733
|
}
|
|
1723
1734
|
return "NO TITLE";
|
|
1724
1735
|
};
|
|
@@ -1745,21 +1756,24 @@ var parseHtmlContent = (html) => {
|
|
|
1745
1756
|
const content = $(el).attr("content");
|
|
1746
1757
|
return name && content ? { name, content } : null;
|
|
1747
1758
|
}).get().filter((tag) => tag !== null);
|
|
1748
|
-
const articleHtml = $("main").html() ||
|
|
1759
|
+
const articleHtml = $("main").html() || "";
|
|
1749
1760
|
return {
|
|
1750
1761
|
articleHtml,
|
|
1751
1762
|
metaTags
|
|
1752
1763
|
};
|
|
1753
1764
|
};
|
|
1754
|
-
var getHtmlRenditionViewUrl = (renditions, htmlFormats = ["application/xhtml+xml", "application/html", "text/html"]) => {
|
|
1755
|
-
const htmlRendition = getHtmlRendition(renditions, htmlFormats);
|
|
1756
|
-
const href = htmlRendition?.links?.find((link) => link.rel === "view")?.href;
|
|
1757
|
-
return href ?? void 0;
|
|
1758
|
-
};
|
|
1759
1765
|
var getHtmlRendition = (renditions, htmlFormats = ["application/xhtml+xml", "application/html", "text/html"]) => {
|
|
1760
1766
|
if (!renditions || renditions.length === 0) return void 0;
|
|
1761
1767
|
return renditions.find((rendition) => !!rendition.format && htmlFormats.includes(rendition.format));
|
|
1762
1768
|
};
|
|
1769
|
+
var getHtmlRenditionViewUrl = (renditions, htmlFormats = ["application/xhtml+xml", "application/html", "text/html"]) => {
|
|
1770
|
+
if (!renditions || renditions.length === 0) return void 0;
|
|
1771
|
+
const htmlRendition = renditions.find((rendition) => {
|
|
1772
|
+
return !!rendition.format && htmlFormats.includes(rendition.format);
|
|
1773
|
+
});
|
|
1774
|
+
const href = htmlRendition?.links?.find((link) => link.rel === "view")?.href;
|
|
1775
|
+
return href ?? void 0;
|
|
1776
|
+
};
|
|
1763
1777
|
var metaTagsToMetadata = (metaTags) => {
|
|
1764
1778
|
const description = metaTags.find((metaTag) => metaTag.name === "description")?.content;
|
|
1765
1779
|
const keywordsRaw = metaTags.find((metaTag) => metaTag.name === "keywords")?.content;
|
|
@@ -1798,6 +1812,43 @@ var findRelatedFragment = ({
|
|
|
1798
1812
|
var findRelatedFragmentShortId = (options) => {
|
|
1799
1813
|
return findRelatedFragment(options)?.shortId || void 0;
|
|
1800
1814
|
};
|
|
1815
|
+
|
|
1816
|
+
// src/local-storage.ts
|
|
1817
|
+
var getLocalStorage = () => {
|
|
1818
|
+
if (typeof window === "undefined") {
|
|
1819
|
+
return null;
|
|
1820
|
+
}
|
|
1821
|
+
return window.localStorage;
|
|
1822
|
+
};
|
|
1823
|
+
var getLocalStorageJson = (key) => {
|
|
1824
|
+
const storage = getLocalStorage();
|
|
1825
|
+
if (!storage) {
|
|
1826
|
+
return null;
|
|
1827
|
+
}
|
|
1828
|
+
const value = storage.getItem(key);
|
|
1829
|
+
if (!value) {
|
|
1830
|
+
return null;
|
|
1831
|
+
}
|
|
1832
|
+
try {
|
|
1833
|
+
return JSON.parse(value);
|
|
1834
|
+
} catch {
|
|
1835
|
+
return null;
|
|
1836
|
+
}
|
|
1837
|
+
};
|
|
1838
|
+
var setLocalStorageJson = (key, value) => {
|
|
1839
|
+
const storage = getLocalStorage();
|
|
1840
|
+
if (!storage) {
|
|
1841
|
+
return;
|
|
1842
|
+
}
|
|
1843
|
+
storage.setItem(key, JSON.stringify(value));
|
|
1844
|
+
};
|
|
1845
|
+
var removeLocalStorageItem = (key) => {
|
|
1846
|
+
const storage = getLocalStorage();
|
|
1847
|
+
if (!storage) {
|
|
1848
|
+
return;
|
|
1849
|
+
}
|
|
1850
|
+
storage.removeItem(key);
|
|
1851
|
+
};
|
|
1801
1852
|
export {
|
|
1802
1853
|
call,
|
|
1803
1854
|
cn,
|
|
@@ -1817,6 +1868,7 @@ export {
|
|
|
1817
1868
|
getHtmlRenditionViewUrl,
|
|
1818
1869
|
getLabelByLang,
|
|
1819
1870
|
getLanguage,
|
|
1871
|
+
getLocalStorageJson,
|
|
1820
1872
|
getTitle,
|
|
1821
1873
|
getType,
|
|
1822
1874
|
getVersions,
|
|
@@ -1826,9 +1878,11 @@ export {
|
|
|
1826
1878
|
normalizeLanguageCode,
|
|
1827
1879
|
parseHtmlContent,
|
|
1828
1880
|
processDataToLabelValuePairs,
|
|
1881
|
+
removeLocalStorageItem,
|
|
1829
1882
|
replacePathParams,
|
|
1830
1883
|
resolveLabelByLanguage,
|
|
1831
1884
|
resolvePreferredLanguage,
|
|
1885
|
+
setLocalStorageJson,
|
|
1832
1886
|
sortAndDeduplicateLanguages,
|
|
1833
1887
|
transformLanguageData
|
|
1834
1888
|
};
|