@trackunit/shared-utils
Advanced tools
Comparing version 1.0.3 to 1.1.1
@@ -117,4 +117,4 @@ 'use strict'; | ||
const unionArraysByKey = (key, previous, newArray) => { | ||
const previousIds = (previous === null || previous === void 0 ? void 0 : previous.map(edge => edge[key])) || []; | ||
const newIds = (newArray === null || newArray === void 0 ? void 0 : newArray.map(edge => edge[key])) || []; | ||
const previousIds = previous?.map(edge => edge[key]) || []; | ||
const newIds = newArray?.map(edge => edge[key]) || []; | ||
const mergedIds = [...previousIds, ...newIds]; | ||
@@ -124,4 +124,4 @@ const uniqueIds = [...new Set(mergedIds)]; | ||
.map(id => { | ||
const previousEdge = previous === null || previous === void 0 ? void 0 : previous.find(edge => edge[key] === id); | ||
const newEdge = newArray === null || newArray === void 0 ? void 0 : newArray.find(edge => edge[key] === id); | ||
const previousEdge = previous?.find(edge => edge[key] === id); | ||
const newEdge = newArray?.find(edge => edge[key] === id); | ||
return newEdge || previousEdge; | ||
@@ -534,3 +534,3 @@ }) | ||
*/ | ||
const toIDs = (ids) => { var _a; return (_a = ids === null || ids === void 0 ? void 0 : ids.filter(id => !isNaN(toID(id))).map(id => toID(id))) !== null && _a !== void 0 ? _a : []; }; | ||
const toIDs = (ids) => ids?.filter(id => !isNaN(toID(id))).map(id => toID(id)) ?? []; | ||
@@ -550,5 +550,4 @@ /** | ||
const toPNG = ({ image, dimensions, maxHeight, maxWidth, idealArea, }) => { | ||
var _a, _b; | ||
let width = (_a = dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) !== null && _a !== void 0 ? _a : image.width; | ||
let height = (_b = dimensions === null || dimensions === void 0 ? void 0 : dimensions.height) !== null && _b !== void 0 ? _b : image.height; | ||
let width = dimensions?.width ?? image.width; | ||
let height = dimensions?.height ?? image.height; | ||
const scale = calculateImageScaleRatio(width, height, maxWidth, maxHeight, idealArea); | ||
@@ -758,7 +757,6 @@ width = Math.round(width * scale); | ||
const dataURItoBlob = (dataURI) => { | ||
var _a, _b, _c, _d, _e; | ||
const bytes = ((_a = dataURI.split(",")[0]) !== null && _a !== void 0 ? _a : "").indexOf("base64") >= 0 | ||
? atob((_b = dataURI.split(",")[1]) !== null && _b !== void 0 ? _b : "") | ||
: unescape((_c = dataURI.split(",")[1]) !== null && _c !== void 0 ? _c : ""); | ||
const mime = (_e = (_d = dataURI.split(",")[0]) === null || _d === void 0 ? void 0 : _d.split(":")[1]) === null || _e === void 0 ? void 0 : _e.split(";")[0]; | ||
const bytes = (dataURI.split(",")[0] ?? "").indexOf("base64") >= 0 | ||
? atob(dataURI.split(",")[1] ?? "") | ||
: unescape(dataURI.split(",")[1] ?? ""); | ||
const mime = dataURI.split(",")[0]?.split(":")[1]?.split(";")[0]; | ||
const max = bytes.length; | ||
@@ -1096,3 +1094,3 @@ const ia = new Uint8Array(max); | ||
*/ | ||
const removeLeftPadding = (id) => Number(id === null || id === void 0 ? void 0 : id.replace(/-/g, "").replace(/^0+/, "")); | ||
const removeLeftPadding = (id) => Number(id?.replace(/-/g, "").replace(/^0+/, "")); | ||
/** | ||
@@ -1116,5 +1114,7 @@ * Removes hidden characters from a string. | ||
const rgb2hex = (rgb) => { | ||
var _a; | ||
const hexColor = (_a = rgb | ||
.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)) === null || _a === void 0 ? void 0 : _a.slice(1).map(n => parseInt(n, 10).toString(16).padStart(2, "0")).join(""); | ||
const hexColor = rgb | ||
.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/) | ||
?.slice(1) | ||
.map(n => parseInt(n, 10).toString(16).padStart(2, "0")) | ||
.join(""); | ||
return hexColor ? `#${hexColor}` : rgb; | ||
@@ -1187,5 +1187,4 @@ }; | ||
svgImage.querySelectorAll("style").forEach(element => { | ||
var _a; | ||
const cssRules = (_a = element.sheet) === null || _a === void 0 ? void 0 : _a.cssRules; | ||
if (cssRules === null || cssRules === void 0 ? void 0 : cssRules.length) { | ||
const cssRules = element.sheet?.cssRules; | ||
if (cssRules?.length) { | ||
for (let i = 0; i < cssRules.length; i++) { | ||
@@ -1204,4 +1203,3 @@ // Checking if the style attribute exists | ||
svgImage.querySelectorAll("[fill]").forEach(element => { | ||
var _a; | ||
const color = (_a = element.attributes.getNamedItem("fill")) === null || _a === void 0 ? void 0 : _a.value; | ||
const color = element.attributes.getNamedItem("fill")?.value; | ||
if (color) { | ||
@@ -1213,4 +1211,3 @@ colors.push(color); | ||
svgImage.querySelectorAll("[stroke]").forEach(element => { | ||
var _a; | ||
const color = (_a = element.attributes.getNamedItem("stroke")) === null || _a === void 0 ? void 0 : _a.value; | ||
const color = element.attributes.getNamedItem("stroke")?.value; | ||
if (color) { | ||
@@ -1222,4 +1219,3 @@ colors.push(color); | ||
svgImage.querySelectorAll("[stop-color]").forEach(element => { | ||
var _a; | ||
const color = (_a = element.attributes.getNamedItem("stop-color")) === null || _a === void 0 ? void 0 : _a.value; | ||
const color = element.attributes.getNamedItem("stop-color")?.value; | ||
if (color) { | ||
@@ -1226,0 +1222,0 @@ colors.push(color); |
@@ -115,4 +115,4 @@ import { v3, v4, v5 } from 'uuid'; | ||
const unionArraysByKey = (key, previous, newArray) => { | ||
const previousIds = (previous === null || previous === void 0 ? void 0 : previous.map(edge => edge[key])) || []; | ||
const newIds = (newArray === null || newArray === void 0 ? void 0 : newArray.map(edge => edge[key])) || []; | ||
const previousIds = previous?.map(edge => edge[key]) || []; | ||
const newIds = newArray?.map(edge => edge[key]) || []; | ||
const mergedIds = [...previousIds, ...newIds]; | ||
@@ -122,4 +122,4 @@ const uniqueIds = [...new Set(mergedIds)]; | ||
.map(id => { | ||
const previousEdge = previous === null || previous === void 0 ? void 0 : previous.find(edge => edge[key] === id); | ||
const newEdge = newArray === null || newArray === void 0 ? void 0 : newArray.find(edge => edge[key] === id); | ||
const previousEdge = previous?.find(edge => edge[key] === id); | ||
const newEdge = newArray?.find(edge => edge[key] === id); | ||
return newEdge || previousEdge; | ||
@@ -532,3 +532,3 @@ }) | ||
*/ | ||
const toIDs = (ids) => { var _a; return (_a = ids === null || ids === void 0 ? void 0 : ids.filter(id => !isNaN(toID(id))).map(id => toID(id))) !== null && _a !== void 0 ? _a : []; }; | ||
const toIDs = (ids) => ids?.filter(id => !isNaN(toID(id))).map(id => toID(id)) ?? []; | ||
@@ -548,5 +548,4 @@ /** | ||
const toPNG = ({ image, dimensions, maxHeight, maxWidth, idealArea, }) => { | ||
var _a, _b; | ||
let width = (_a = dimensions === null || dimensions === void 0 ? void 0 : dimensions.width) !== null && _a !== void 0 ? _a : image.width; | ||
let height = (_b = dimensions === null || dimensions === void 0 ? void 0 : dimensions.height) !== null && _b !== void 0 ? _b : image.height; | ||
let width = dimensions?.width ?? image.width; | ||
let height = dimensions?.height ?? image.height; | ||
const scale = calculateImageScaleRatio(width, height, maxWidth, maxHeight, idealArea); | ||
@@ -756,7 +755,6 @@ width = Math.round(width * scale); | ||
const dataURItoBlob = (dataURI) => { | ||
var _a, _b, _c, _d, _e; | ||
const bytes = ((_a = dataURI.split(",")[0]) !== null && _a !== void 0 ? _a : "").indexOf("base64") >= 0 | ||
? atob((_b = dataURI.split(",")[1]) !== null && _b !== void 0 ? _b : "") | ||
: unescape((_c = dataURI.split(",")[1]) !== null && _c !== void 0 ? _c : ""); | ||
const mime = (_e = (_d = dataURI.split(",")[0]) === null || _d === void 0 ? void 0 : _d.split(":")[1]) === null || _e === void 0 ? void 0 : _e.split(";")[0]; | ||
const bytes = (dataURI.split(",")[0] ?? "").indexOf("base64") >= 0 | ||
? atob(dataURI.split(",")[1] ?? "") | ||
: unescape(dataURI.split(",")[1] ?? ""); | ||
const mime = dataURI.split(",")[0]?.split(":")[1]?.split(";")[0]; | ||
const max = bytes.length; | ||
@@ -1094,3 +1092,3 @@ const ia = new Uint8Array(max); | ||
*/ | ||
const removeLeftPadding = (id) => Number(id === null || id === void 0 ? void 0 : id.replace(/-/g, "").replace(/^0+/, "")); | ||
const removeLeftPadding = (id) => Number(id?.replace(/-/g, "").replace(/^0+/, "")); | ||
/** | ||
@@ -1114,5 +1112,7 @@ * Removes hidden characters from a string. | ||
const rgb2hex = (rgb) => { | ||
var _a; | ||
const hexColor = (_a = rgb | ||
.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/)) === null || _a === void 0 ? void 0 : _a.slice(1).map(n => parseInt(n, 10).toString(16).padStart(2, "0")).join(""); | ||
const hexColor = rgb | ||
.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/) | ||
?.slice(1) | ||
.map(n => parseInt(n, 10).toString(16).padStart(2, "0")) | ||
.join(""); | ||
return hexColor ? `#${hexColor}` : rgb; | ||
@@ -1185,5 +1185,4 @@ }; | ||
svgImage.querySelectorAll("style").forEach(element => { | ||
var _a; | ||
const cssRules = (_a = element.sheet) === null || _a === void 0 ? void 0 : _a.cssRules; | ||
if (cssRules === null || cssRules === void 0 ? void 0 : cssRules.length) { | ||
const cssRules = element.sheet?.cssRules; | ||
if (cssRules?.length) { | ||
for (let i = 0; i < cssRules.length; i++) { | ||
@@ -1202,4 +1201,3 @@ // Checking if the style attribute exists | ||
svgImage.querySelectorAll("[fill]").forEach(element => { | ||
var _a; | ||
const color = (_a = element.attributes.getNamedItem("fill")) === null || _a === void 0 ? void 0 : _a.value; | ||
const color = element.attributes.getNamedItem("fill")?.value; | ||
if (color) { | ||
@@ -1211,4 +1209,3 @@ colors.push(color); | ||
svgImage.querySelectorAll("[stroke]").forEach(element => { | ||
var _a; | ||
const color = (_a = element.attributes.getNamedItem("stroke")) === null || _a === void 0 ? void 0 : _a.value; | ||
const color = element.attributes.getNamedItem("stroke")?.value; | ||
if (color) { | ||
@@ -1220,4 +1217,3 @@ colors.push(color); | ||
svgImage.querySelectorAll("[stop-color]").forEach(element => { | ||
var _a; | ||
const color = (_a = element.attributes.getNamedItem("stop-color")) === null || _a === void 0 ? void 0 : _a.value; | ||
const color = element.attributes.getNamedItem("stop-color")?.value; | ||
if (color) { | ||
@@ -1224,0 +1220,0 @@ colors.push(color); |
{ | ||
"name": "@trackunit/shared-utils", | ||
"version": "1.0.3", | ||
"version": "1.1.1", | ||
"repository": "https://github.com/Trackunit/manager", | ||
@@ -5,0 +5,0 @@ "engines": { |
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
0
126743
3423