@trackunit/shared-utils 1.15.60-alpha-6e520e95f87.0 → 1.15.61
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/index.cjs.js +23 -0
- package/index.esm.js +21 -1
- package/package.json +1 -1
- package/src/browserNavigationState.d.ts +14 -0
- package/src/index.d.ts +1 -0
package/index.cjs.js
CHANGED
|
@@ -141,6 +141,26 @@ const isArrayEqual = (a, b) => a.length === b.length && a.every((v, i) => v ===
|
|
|
141
141
|
*/
|
|
142
142
|
const arrayNotEmpty = (array) => array && array.length > 0 ? array : undefined;
|
|
143
143
|
|
|
144
|
+
let navigatingAway = false;
|
|
145
|
+
/**
|
|
146
|
+
* Marks that the app is about to perform a full browser navigation (e.g. `window.location.replace`
|
|
147
|
+
* or `window.location.reload`). The browser cancels any in-flight `fetch` requests as it tears down
|
|
148
|
+
* the current document, and those cancellations reject as a generic `TypeError: Failed to fetch`
|
|
149
|
+
* rather than an `AbortError` (since no `AbortController` was involved).
|
|
150
|
+
*
|
|
151
|
+
* Call this right before triggering such a navigation so callers can check `isNavigatingAway()`
|
|
152
|
+
* in their fetch `catch` blocks and skip reporting these expected, benign failures to Sentry.
|
|
153
|
+
*/
|
|
154
|
+
const markNavigatingAway = () => {
|
|
155
|
+
navigatingAway = true;
|
|
156
|
+
};
|
|
157
|
+
/** Returns whether {@link markNavigatingAway} has been called since the last page load. */
|
|
158
|
+
const isNavigatingAway = () => navigatingAway;
|
|
159
|
+
/** Test-only helper to reset the module-level flag between test cases. */
|
|
160
|
+
const resetNavigatingAwayForTests = () => {
|
|
161
|
+
navigatingAway = false;
|
|
162
|
+
};
|
|
163
|
+
|
|
144
164
|
const align = {
|
|
145
165
|
LEFT: "left",
|
|
146
166
|
CENTER: "center",
|
|
@@ -1639,11 +1659,13 @@ exports.groupTinyDataToOthers = groupTinyDataToOthers;
|
|
|
1639
1659
|
exports.hourIntervals = hourIntervals;
|
|
1640
1660
|
exports.intersection = intersection;
|
|
1641
1661
|
exports.isArrayEqual = isArrayEqual;
|
|
1662
|
+
exports.isNavigatingAway = isNavigatingAway;
|
|
1642
1663
|
exports.isSortByProperty = isSortByProperty;
|
|
1643
1664
|
exports.isSorted = isSorted;
|
|
1644
1665
|
exports.isUUID = isUUID;
|
|
1645
1666
|
exports.isValidImage = isValidImage;
|
|
1646
1667
|
exports.loadSVGDimensions = loadSVGDimensions;
|
|
1668
|
+
exports.markNavigatingAway = markNavigatingAway;
|
|
1647
1669
|
exports.nonNullable = nonNullable;
|
|
1648
1670
|
exports.numberCompare = numberCompare;
|
|
1649
1671
|
exports.numberCompareUnknownAfterHighest = numberCompareUnknownAfterHighest;
|
|
@@ -1659,6 +1681,7 @@ exports.removeLeftPadding = removeLeftPadding;
|
|
|
1659
1681
|
exports.removeProperties = removeProperties;
|
|
1660
1682
|
exports.removeProperty = removeProperty;
|
|
1661
1683
|
exports.replaceNullableNumbersWithZero = replaceNullableNumbersWithZero;
|
|
1684
|
+
exports.resetNavigatingAwayForTests = resetNavigatingAwayForTests;
|
|
1662
1685
|
exports.resizeBlob = resizeBlob;
|
|
1663
1686
|
exports.resizeImage = resizeImage;
|
|
1664
1687
|
exports.rgb2hex = rgb2hex;
|
package/index.esm.js
CHANGED
|
@@ -139,6 +139,26 @@ const isArrayEqual = (a, b) => a.length === b.length && a.every((v, i) => v ===
|
|
|
139
139
|
*/
|
|
140
140
|
const arrayNotEmpty = (array) => array && array.length > 0 ? array : undefined;
|
|
141
141
|
|
|
142
|
+
let navigatingAway = false;
|
|
143
|
+
/**
|
|
144
|
+
* Marks that the app is about to perform a full browser navigation (e.g. `window.location.replace`
|
|
145
|
+
* or `window.location.reload`). The browser cancels any in-flight `fetch` requests as it tears down
|
|
146
|
+
* the current document, and those cancellations reject as a generic `TypeError: Failed to fetch`
|
|
147
|
+
* rather than an `AbortError` (since no `AbortController` was involved).
|
|
148
|
+
*
|
|
149
|
+
* Call this right before triggering such a navigation so callers can check `isNavigatingAway()`
|
|
150
|
+
* in their fetch `catch` blocks and skip reporting these expected, benign failures to Sentry.
|
|
151
|
+
*/
|
|
152
|
+
const markNavigatingAway = () => {
|
|
153
|
+
navigatingAway = true;
|
|
154
|
+
};
|
|
155
|
+
/** Returns whether {@link markNavigatingAway} has been called since the last page load. */
|
|
156
|
+
const isNavigatingAway = () => navigatingAway;
|
|
157
|
+
/** Test-only helper to reset the module-level flag between test cases. */
|
|
158
|
+
const resetNavigatingAwayForTests = () => {
|
|
159
|
+
navigatingAway = false;
|
|
160
|
+
};
|
|
161
|
+
|
|
142
162
|
const align = {
|
|
143
163
|
LEFT: "left",
|
|
144
164
|
CENTER: "center",
|
|
@@ -1589,4 +1609,4 @@ const formatUsCustomaryDistance = (value) => {
|
|
|
1589
1609
|
}
|
|
1590
1610
|
};
|
|
1591
1611
|
|
|
1592
|
-
export { DateTimeFormat, HoursAndMinutesFormat, UnitsOfMeasurementSI, UnitsOfMeasurementUSCustomary, VISIBLE_ONLY_COLUMN_VISIBILITY_KEY, align, alphabeticallySort, arrayLengthCompare, arrayNotEmpty, booleanCompare, calculateImageScaleRatio, capitalize, colorsFromStyleDeclaration, convertBlobToBase64, convertMetersToKilometers, convertMetersToYards, convertYardsToMeters, convertYardsToMiles, dateCompare, deleteUndefinedKeys, difference, doNothing, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, fetchImageAsBase64, filterByMultiple, formatAddress, formatCoordinates, formatSiDistance, formatUsCustomaryDistance, fuzzySearch, getAllColors, getCountryName, getDifferenceBetweenDates, getEndOfDay, getFirstLevelObjectPropertyDifferences, getISOStringFromDate, getLoremIpsum, getMimeTypeFromDataURL, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isArrayEqual, isSortByProperty, isSorted, isUUID, isValidImage, loadSVGDimensions, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectEntries, objectFromEntries, objectKeys, objectValues, parseTailwindArbitraryValue, pick, preload, removeLeftPadding, removeProperties, removeProperty, replaceNullableNumbersWithZero, resizeBlob, resizeImage, rgb2hex, size, stringCompare, stringCompareFromKey, stringNaturalCompare, stripHiddenCharacters, svgToPNG, titleCase, toID, toIDs, toPNG, toUUID, trimIds, trimPath, truthy, unionArraysByKey, uuidv3, uuidv4, uuidv5 };
|
|
1612
|
+
export { DateTimeFormat, HoursAndMinutesFormat, UnitsOfMeasurementSI, UnitsOfMeasurementUSCustomary, VISIBLE_ONLY_COLUMN_VISIBILITY_KEY, align, alphabeticallySort, arrayLengthCompare, arrayNotEmpty, booleanCompare, calculateImageScaleRatio, capitalize, colorsFromStyleDeclaration, convertBlobToBase64, convertMetersToKilometers, convertMetersToYards, convertYardsToMeters, convertYardsToMiles, dateCompare, deleteUndefinedKeys, difference, doNothing, enumFromValue, enumFromValueTypesafe, enumOrUndefinedFromValue, exhaustiveCheck, fetchImageAsBase64, filterByMultiple, formatAddress, formatCoordinates, formatSiDistance, formatUsCustomaryDistance, fuzzySearch, getAllColors, getCountryName, getDifferenceBetweenDates, getEndOfDay, getFirstLevelObjectPropertyDifferences, getISOStringFromDate, getLoremIpsum, getMimeTypeFromDataURL, getResizedDimensions, getStartOfDay, groupBy, groupTinyDataToOthers, hourIntervals, intersection, isArrayEqual, isNavigatingAway, isSortByProperty, isSorted, isUUID, isValidImage, loadSVGDimensions, markNavigatingAway, nonNullable, numberCompare, numberCompareUnknownAfterHighest, objNotEmpty, objectEntries, objectFromEntries, objectKeys, objectValues, parseTailwindArbitraryValue, pick, preload, removeLeftPadding, removeProperties, removeProperty, replaceNullableNumbersWithZero, resetNavigatingAwayForTests, resizeBlob, resizeImage, rgb2hex, size, stringCompare, stringCompareFromKey, stringNaturalCompare, stripHiddenCharacters, svgToPNG, titleCase, toID, toIDs, toPNG, toUUID, trimIds, trimPath, truthy, unionArraysByKey, uuidv3, uuidv4, uuidv5 };
|
package/package.json
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Marks that the app is about to perform a full browser navigation (e.g. `window.location.replace`
|
|
3
|
+
* or `window.location.reload`). The browser cancels any in-flight `fetch` requests as it tears down
|
|
4
|
+
* the current document, and those cancellations reject as a generic `TypeError: Failed to fetch`
|
|
5
|
+
* rather than an `AbortError` (since no `AbortController` was involved).
|
|
6
|
+
*
|
|
7
|
+
* Call this right before triggering such a navigation so callers can check `isNavigatingAway()`
|
|
8
|
+
* in their fetch `catch` blocks and skip reporting these expected, benign failures to Sentry.
|
|
9
|
+
*/
|
|
10
|
+
export declare const markNavigatingAway: () => void;
|
|
11
|
+
/** Returns whether {@link markNavigatingAway} has been called since the last page load. */
|
|
12
|
+
export declare const isNavigatingAway: () => boolean;
|
|
13
|
+
/** Test-only helper to reset the module-level flag between test cases. */
|
|
14
|
+
export declare const resetNavigatingAwayForTests: () => void;
|