@trackunit/react-components 2.1.29 → 2.1.31
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 +50 -55
- package/index.esm.js +50 -55
- package/package.json +6 -6
- package/src/hooks/encoding/utils/customEncoding.d.ts +0 -14
package/index.cjs.js
CHANGED
|
@@ -10533,58 +10533,6 @@ const b64urlDecode = (s) => {
|
|
|
10533
10533
|
}
|
|
10534
10534
|
return out;
|
|
10535
10535
|
};
|
|
10536
|
-
/**
|
|
10537
|
-
* Encode a value with the same gzip + base64url format used by useCustomEncoding.
|
|
10538
|
-
*
|
|
10539
|
-
* @param input - The value to encode.
|
|
10540
|
-
* @returns {string} The compressed URL-safe encoded value, or an empty string on failure.
|
|
10541
|
-
*/
|
|
10542
|
-
const encodeCustomValue = (input) => {
|
|
10543
|
-
try {
|
|
10544
|
-
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10545
|
-
const textInput = new TextEncoder().encode(json);
|
|
10546
|
-
const compressed = fflate.gzipSync(textInput, { mtime: 0 });
|
|
10547
|
-
return b64urlEncode(compressed);
|
|
10548
|
-
}
|
|
10549
|
-
catch (_) {
|
|
10550
|
-
return "";
|
|
10551
|
-
}
|
|
10552
|
-
};
|
|
10553
|
-
/**
|
|
10554
|
-
* Decode a value produced by encodeCustomValue.
|
|
10555
|
-
*
|
|
10556
|
-
* @param str - The compressed URL-safe encoded value.
|
|
10557
|
-
* @returns {object | Array<object> | string} The decoded object/string value, or an empty string on failure.
|
|
10558
|
-
*/
|
|
10559
|
-
const decodeCustomValue = (str) => {
|
|
10560
|
-
try {
|
|
10561
|
-
try {
|
|
10562
|
-
const bytes = b64urlDecode(str);
|
|
10563
|
-
const decompressed = fflate.gunzipSync(bytes);
|
|
10564
|
-
const json = new TextDecoder().decode(decompressed);
|
|
10565
|
-
try {
|
|
10566
|
-
return JSON.parse(json);
|
|
10567
|
-
}
|
|
10568
|
-
catch (_) {
|
|
10569
|
-
return json;
|
|
10570
|
-
}
|
|
10571
|
-
}
|
|
10572
|
-
catch (_) {
|
|
10573
|
-
// If compression decoding fails, fall back to regular decoding.
|
|
10574
|
-
}
|
|
10575
|
-
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10576
|
-
try {
|
|
10577
|
-
return JSON.parse(decoded);
|
|
10578
|
-
}
|
|
10579
|
-
catch (_) {
|
|
10580
|
-
return decoded;
|
|
10581
|
-
}
|
|
10582
|
-
}
|
|
10583
|
-
catch (_) {
|
|
10584
|
-
return "";
|
|
10585
|
-
}
|
|
10586
|
-
};
|
|
10587
|
-
|
|
10588
10536
|
/**
|
|
10589
10537
|
* React hook for safe base64 encoding/decoding with UTF-8 support and compression
|
|
10590
10538
|
*
|
|
@@ -10604,7 +10552,22 @@ const useCustomEncoding = () => {
|
|
|
10604
10552
|
* @param input - The object or string to encode
|
|
10605
10553
|
* @returns The compressed and encoded string
|
|
10606
10554
|
*/
|
|
10607
|
-
const encode = react.useCallback((input) =>
|
|
10555
|
+
const encode = react.useCallback((input) => {
|
|
10556
|
+
try {
|
|
10557
|
+
// If it's already a string, use it directly; otherwise stringify the object
|
|
10558
|
+
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10559
|
+
const textInput = new TextEncoder().encode(json);
|
|
10560
|
+
// Use fflate for synchronous gzip compression.
|
|
10561
|
+
// mtime: 0 ensures deterministic output — without it the gzip header
|
|
10562
|
+
// includes the current timestamp, making the same input produce a
|
|
10563
|
+
// different encoded string on every call.
|
|
10564
|
+
const compressed = fflate.gzipSync(textInput, { mtime: 0 });
|
|
10565
|
+
return b64urlEncode(compressed);
|
|
10566
|
+
}
|
|
10567
|
+
catch (_) {
|
|
10568
|
+
return "";
|
|
10569
|
+
}
|
|
10570
|
+
}, []);
|
|
10608
10571
|
/**
|
|
10609
10572
|
* Safely decode a compressed and encoded string back to its original form
|
|
10610
10573
|
*
|
|
@@ -10612,9 +10575,41 @@ const useCustomEncoding = () => {
|
|
|
10612
10575
|
* and returning the original object or string.
|
|
10613
10576
|
*
|
|
10614
10577
|
* @param str - The compressed and encoded string to decode
|
|
10615
|
-
* @returns The decoded object or string, or
|
|
10578
|
+
* @returns The decoded object or string, or null if decoding fails
|
|
10616
10579
|
*/
|
|
10617
|
-
const decode = react.useCallback((str) =>
|
|
10580
|
+
const decode = react.useCallback((str) => {
|
|
10581
|
+
try {
|
|
10582
|
+
// Try to decode as compressed data first
|
|
10583
|
+
try {
|
|
10584
|
+
const bytes = b64urlDecode(str);
|
|
10585
|
+
const decompressed = fflate.gunzipSync(bytes);
|
|
10586
|
+
const json = new TextDecoder().decode(decompressed);
|
|
10587
|
+
// Try to parse as JSON first (for objects)
|
|
10588
|
+
try {
|
|
10589
|
+
return JSON.parse(json);
|
|
10590
|
+
}
|
|
10591
|
+
catch (_) {
|
|
10592
|
+
// If JSON parsing fails, return the string as-is
|
|
10593
|
+
return json;
|
|
10594
|
+
}
|
|
10595
|
+
}
|
|
10596
|
+
catch (_) {
|
|
10597
|
+
// If compression decoding fails, fall back to regular decoding
|
|
10598
|
+
}
|
|
10599
|
+
// Fallback: use regular base64 decoding
|
|
10600
|
+
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10601
|
+
try {
|
|
10602
|
+
return JSON.parse(decoded);
|
|
10603
|
+
}
|
|
10604
|
+
catch (_) {
|
|
10605
|
+
// If JSON parsing fails, return the string as-is
|
|
10606
|
+
return decoded;
|
|
10607
|
+
}
|
|
10608
|
+
}
|
|
10609
|
+
catch (_) {
|
|
10610
|
+
return "";
|
|
10611
|
+
}
|
|
10612
|
+
}, []);
|
|
10618
10613
|
return react.useMemo(() => ({ encode, decode }), [encode, decode]);
|
|
10619
10614
|
};
|
|
10620
10615
|
|
package/index.esm.js
CHANGED
|
@@ -10531,58 +10531,6 @@ const b64urlDecode = (s) => {
|
|
|
10531
10531
|
}
|
|
10532
10532
|
return out;
|
|
10533
10533
|
};
|
|
10534
|
-
/**
|
|
10535
|
-
* Encode a value with the same gzip + base64url format used by useCustomEncoding.
|
|
10536
|
-
*
|
|
10537
|
-
* @param input - The value to encode.
|
|
10538
|
-
* @returns {string} The compressed URL-safe encoded value, or an empty string on failure.
|
|
10539
|
-
*/
|
|
10540
|
-
const encodeCustomValue = (input) => {
|
|
10541
|
-
try {
|
|
10542
|
-
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10543
|
-
const textInput = new TextEncoder().encode(json);
|
|
10544
|
-
const compressed = gzipSync(textInput, { mtime: 0 });
|
|
10545
|
-
return b64urlEncode(compressed);
|
|
10546
|
-
}
|
|
10547
|
-
catch (_) {
|
|
10548
|
-
return "";
|
|
10549
|
-
}
|
|
10550
|
-
};
|
|
10551
|
-
/**
|
|
10552
|
-
* Decode a value produced by encodeCustomValue.
|
|
10553
|
-
*
|
|
10554
|
-
* @param str - The compressed URL-safe encoded value.
|
|
10555
|
-
* @returns {object | Array<object> | string} The decoded object/string value, or an empty string on failure.
|
|
10556
|
-
*/
|
|
10557
|
-
const decodeCustomValue = (str) => {
|
|
10558
|
-
try {
|
|
10559
|
-
try {
|
|
10560
|
-
const bytes = b64urlDecode(str);
|
|
10561
|
-
const decompressed = gunzipSync(bytes);
|
|
10562
|
-
const json = new TextDecoder().decode(decompressed);
|
|
10563
|
-
try {
|
|
10564
|
-
return JSON.parse(json);
|
|
10565
|
-
}
|
|
10566
|
-
catch (_) {
|
|
10567
|
-
return json;
|
|
10568
|
-
}
|
|
10569
|
-
}
|
|
10570
|
-
catch (_) {
|
|
10571
|
-
// If compression decoding fails, fall back to regular decoding.
|
|
10572
|
-
}
|
|
10573
|
-
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10574
|
-
try {
|
|
10575
|
-
return JSON.parse(decoded);
|
|
10576
|
-
}
|
|
10577
|
-
catch (_) {
|
|
10578
|
-
return decoded;
|
|
10579
|
-
}
|
|
10580
|
-
}
|
|
10581
|
-
catch (_) {
|
|
10582
|
-
return "";
|
|
10583
|
-
}
|
|
10584
|
-
};
|
|
10585
|
-
|
|
10586
10534
|
/**
|
|
10587
10535
|
* React hook for safe base64 encoding/decoding with UTF-8 support and compression
|
|
10588
10536
|
*
|
|
@@ -10602,7 +10550,22 @@ const useCustomEncoding = () => {
|
|
|
10602
10550
|
* @param input - The object or string to encode
|
|
10603
10551
|
* @returns The compressed and encoded string
|
|
10604
10552
|
*/
|
|
10605
|
-
const encode = useCallback((input) =>
|
|
10553
|
+
const encode = useCallback((input) => {
|
|
10554
|
+
try {
|
|
10555
|
+
// If it's already a string, use it directly; otherwise stringify the object
|
|
10556
|
+
const json = typeof input === "string" ? input : JSON.stringify(input);
|
|
10557
|
+
const textInput = new TextEncoder().encode(json);
|
|
10558
|
+
// Use fflate for synchronous gzip compression.
|
|
10559
|
+
// mtime: 0 ensures deterministic output — without it the gzip header
|
|
10560
|
+
// includes the current timestamp, making the same input produce a
|
|
10561
|
+
// different encoded string on every call.
|
|
10562
|
+
const compressed = gzipSync(textInput, { mtime: 0 });
|
|
10563
|
+
return b64urlEncode(compressed);
|
|
10564
|
+
}
|
|
10565
|
+
catch (_) {
|
|
10566
|
+
return "";
|
|
10567
|
+
}
|
|
10568
|
+
}, []);
|
|
10606
10569
|
/**
|
|
10607
10570
|
* Safely decode a compressed and encoded string back to its original form
|
|
10608
10571
|
*
|
|
@@ -10610,9 +10573,41 @@ const useCustomEncoding = () => {
|
|
|
10610
10573
|
* and returning the original object or string.
|
|
10611
10574
|
*
|
|
10612
10575
|
* @param str - The compressed and encoded string to decode
|
|
10613
|
-
* @returns The decoded object or string, or
|
|
10576
|
+
* @returns The decoded object or string, or null if decoding fails
|
|
10614
10577
|
*/
|
|
10615
|
-
const decode = useCallback((str) =>
|
|
10578
|
+
const decode = useCallback((str) => {
|
|
10579
|
+
try {
|
|
10580
|
+
// Try to decode as compressed data first
|
|
10581
|
+
try {
|
|
10582
|
+
const bytes = b64urlDecode(str);
|
|
10583
|
+
const decompressed = gunzipSync(bytes);
|
|
10584
|
+
const json = new TextDecoder().decode(decompressed);
|
|
10585
|
+
// Try to parse as JSON first (for objects)
|
|
10586
|
+
try {
|
|
10587
|
+
return JSON.parse(json);
|
|
10588
|
+
}
|
|
10589
|
+
catch (_) {
|
|
10590
|
+
// If JSON parsing fails, return the string as-is
|
|
10591
|
+
return json;
|
|
10592
|
+
}
|
|
10593
|
+
}
|
|
10594
|
+
catch (_) {
|
|
10595
|
+
// If compression decoding fails, fall back to regular decoding
|
|
10596
|
+
}
|
|
10597
|
+
// Fallback: use regular base64 decoding
|
|
10598
|
+
const decoded = decodeURIComponent(escape(atob(str)));
|
|
10599
|
+
try {
|
|
10600
|
+
return JSON.parse(decoded);
|
|
10601
|
+
}
|
|
10602
|
+
catch (_) {
|
|
10603
|
+
// If JSON parsing fails, return the string as-is
|
|
10604
|
+
return decoded;
|
|
10605
|
+
}
|
|
10606
|
+
}
|
|
10607
|
+
catch (_) {
|
|
10608
|
+
return "";
|
|
10609
|
+
}
|
|
10610
|
+
}, []);
|
|
10616
10611
|
return useMemo(() => ({ encode, decode }), [encode, decode]);
|
|
10617
10612
|
};
|
|
10618
10613
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trackunit/react-components",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.31",
|
|
4
4
|
"repository": "https://github.com/Trackunit/manager",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE.txt",
|
|
6
6
|
"migrations": "./migrations.json",
|
|
@@ -14,17 +14,17 @@
|
|
|
14
14
|
"@floating-ui/react": "^0.26.25",
|
|
15
15
|
"string-ts": "^2.0.0",
|
|
16
16
|
"tailwind-merge": "^2.0.0",
|
|
17
|
-
"@trackunit/ui-design-tokens": "1.13.
|
|
18
|
-
"@trackunit/css-class-variance-utilities": "1.13.
|
|
19
|
-
"@trackunit/shared-utils": "1.15.
|
|
20
|
-
"@trackunit/ui-icons": "1.13.
|
|
17
|
+
"@trackunit/ui-design-tokens": "1.13.35",
|
|
18
|
+
"@trackunit/css-class-variance-utilities": "1.13.35",
|
|
19
|
+
"@trackunit/shared-utils": "1.15.35",
|
|
20
|
+
"@trackunit/ui-icons": "1.13.37",
|
|
21
21
|
"es-toolkit": "^1.39.10",
|
|
22
22
|
"@tanstack/react-virtual": "3.13.12",
|
|
23
23
|
"dequal": "^2.0.3",
|
|
24
24
|
"fflate": "^0.8.2",
|
|
25
25
|
"superjson": "^2.2.6",
|
|
26
26
|
"zod": "^3.25.76",
|
|
27
|
-
"@trackunit/i18n-library-translation": "2.0.
|
|
27
|
+
"@trackunit/i18n-library-translation": "2.0.32"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
30
|
"react": "^19.0.0",
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Encode a value with the same gzip + base64url format used by useCustomEncoding.
|
|
3
|
-
*
|
|
4
|
-
* @param input - The value to encode.
|
|
5
|
-
* @returns {string} The compressed URL-safe encoded value, or an empty string on failure.
|
|
6
|
-
*/
|
|
7
|
-
export declare const encodeCustomValue: (input: string | object | Array<object>) => string;
|
|
8
|
-
/**
|
|
9
|
-
* Decode a value produced by encodeCustomValue.
|
|
10
|
-
*
|
|
11
|
-
* @param str - The compressed URL-safe encoded value.
|
|
12
|
-
* @returns {object | Array<object> | string} The decoded object/string value, or an empty string on failure.
|
|
13
|
-
*/
|
|
14
|
-
export declare const decodeCustomValue: (str: string) => object | Array<object> | string;
|