@funkit/utils 1.0.0

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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ ## FunkitUtils
2
+
3
+ The `@funkit/utils` centralizes all utilities & consts for usage across all funkit apps and packages. Largely made for internal use only.
@@ -0,0 +1,20 @@
1
+ export * from './address';
2
+ export * from './browsers';
3
+ export * from './capitalize';
4
+ export * from './colors';
5
+ export * from './debounce';
6
+ export * from './deepMerge';
7
+ export * from './exhaustiveCheck';
8
+ export * from './formatFees';
9
+ export * from './formatNumber';
10
+ export * from './formatTimestamp';
11
+ export * from './groupBy';
12
+ export * from './indexBy';
13
+ export * from './isMobile';
14
+ export * from './isNotNullish';
15
+ export * from './locale';
16
+ export * from './mobile';
17
+ export * from './noop';
18
+ export * from './omitUndefinedValues';
19
+ export * from './type';
20
+ //# sourceMappingURL=index.d.ts.map
package/dist/index.js ADDED
@@ -0,0 +1,552 @@
1
+ // src/utils/address.ts
2
+ function formatAddress(address) {
3
+ const leadingChars = 4;
4
+ const trailingChars = 4;
5
+ return address.length < leadingChars + trailingChars ? address : `${address.substring(0, leadingChars)}\u2026${address.substring(
6
+ address.length - trailingChars
7
+ )}`;
8
+ }
9
+ function formatAddressLastFour(address) {
10
+ const trailingChars = 4;
11
+ return address.length < trailingChars ? address : `\u2026${address.substring(address.length - trailingChars)}`;
12
+ }
13
+
14
+ // src/utils/browsers.ts
15
+ function isSafari() {
16
+ return typeof navigator !== "undefined" && typeof navigator.userAgent !== "undefined" && /Version\/([0-9._]+).*Safari/.test(navigator.userAgent);
17
+ }
18
+ function isArc() {
19
+ return typeof document !== "undefined" && getComputedStyle(document.body).getPropertyValue("--arc-palette-focus") !== "";
20
+ }
21
+ var BrowserType = /* @__PURE__ */ ((BrowserType2) => {
22
+ BrowserType2["Arc"] = "Arc";
23
+ BrowserType2["Brave"] = "Brave";
24
+ BrowserType2["Browser"] = "Browser";
25
+ BrowserType2["Chrome"] = "Chrome";
26
+ BrowserType2["Edge"] = "Edge";
27
+ BrowserType2["Firefox"] = "Firefox";
28
+ BrowserType2["Opera"] = "Opera";
29
+ BrowserType2["Safari"] = "Safari";
30
+ return BrowserType2;
31
+ })(BrowserType || {});
32
+ function getBrowser() {
33
+ if (typeof navigator === "undefined") return "Browser" /* Browser */;
34
+ const ua = navigator.userAgent?.toLowerCase();
35
+ if (navigator.brave?.isBrave) return "Brave" /* Brave */;
36
+ if (ua?.indexOf("edg/") > -1) return "Edge" /* Edge */;
37
+ if (ua?.indexOf("op") > -1) return "Opera" /* Opera */;
38
+ if (isArc()) return "Arc" /* Arc */;
39
+ if (ua?.indexOf("chrome") > -1) return "Chrome" /* Chrome */;
40
+ if (ua?.indexOf("firefox") > -1) return "Firefox" /* Firefox */;
41
+ if (isSafari()) return "Safari" /* Safari */;
42
+ return "Browser" /* Browser */;
43
+ }
44
+
45
+ // src/utils/capitalize.ts
46
+ function capitalizeFirstLetter(val) {
47
+ return String(val).charAt(0).toUpperCase() + String(val).slice(1);
48
+ }
49
+
50
+ // src/utils/colors.ts
51
+ function colorToHex(color) {
52
+ const rgbMatch = color.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
53
+ if (rgbMatch) {
54
+ const [, r, g, b] = rgbMatch.map(Number);
55
+ const rHex = r.toString(16).padStart(2, "0");
56
+ const gHex = g.toString(16).padStart(2, "0");
57
+ const bHex = b.toString(16).padStart(2, "0");
58
+ return `#${rHex}${gHex}${bHex}`;
59
+ }
60
+ const hexMatch = color.match(/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i);
61
+ if (hexMatch) {
62
+ return hexMatch[0].toLowerCase();
63
+ }
64
+ return color;
65
+ }
66
+ var convertHexToRGBA = (hexCode, opacity = 1) => {
67
+ let hex = hexCode.replace("#", "");
68
+ if (hex.length === 3) {
69
+ hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`;
70
+ }
71
+ const r = Number.parseInt(hex.substring(0, 2), 16);
72
+ const g = Number.parseInt(hex.substring(2, 4), 16);
73
+ const b = Number.parseInt(hex.substring(4, 6), 16);
74
+ const finalOpacity = opacity > 1 && opacity <= 100 ? opacity / 100 : opacity;
75
+ return `rgba(${r},${g},${b},${finalOpacity})`;
76
+ };
77
+ var isHexString = (color) => {
78
+ return /^#([0-9a-f]{3}){1,2}$/i.test(color);
79
+ };
80
+
81
+ // src/utils/debounce.ts
82
+ function debounce(fn, ms) {
83
+ let timer;
84
+ return () => {
85
+ if (timer) {
86
+ clearTimeout(timer);
87
+ }
88
+ timer = setTimeout(() => {
89
+ timer = null;
90
+ fn();
91
+ }, ms);
92
+ };
93
+ }
94
+
95
+ // src/utils/deepMerge.ts
96
+ function deepClone(obj) {
97
+ return JSON.parse(JSON.stringify(obj));
98
+ }
99
+ function deepMerge(origin, ...objects) {
100
+ const target = deepClone(origin);
101
+ for (const obj of objects) {
102
+ for (const key in obj) {
103
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
104
+ const value = obj[key];
105
+ if (Array.isArray(value)) {
106
+ target[key] = value;
107
+ } else if (typeof value === "object" && value !== null) {
108
+ target[key] = deepMerge(target[key], value);
109
+ } else {
110
+ target[key] = value;
111
+ }
112
+ }
113
+ }
114
+ }
115
+ return target;
116
+ }
117
+
118
+ // src/utils/exhaustiveCheck.ts
119
+ function exhaustiveCheck(_value) {
120
+ if (false) {
121
+ throw new Error("exhaustiveCheck: should not reach this point");
122
+ }
123
+ }
124
+
125
+ // src/utils/isNotNullish.ts
126
+ function isNotNullish(value) {
127
+ return value != null;
128
+ }
129
+
130
+ // src/utils/formatNumber.ts
131
+ var FORMAT_NUMBER_DEFAULT = {
132
+ minBeforeUseScientific: 1e-5,
133
+ maxBeforeAggresiveDecimalTruncation: 1,
134
+ softDecimalPrecision: 5,
135
+ aggresiveDecimalPrecision: 5,
136
+ maxBeforeUseSuffix: 1e6,
137
+ decimalPrecisionForSuffix: 5,
138
+ maxSuffixSize: 1e6,
139
+ maxNumberPartSizeForSuffix: 1e3,
140
+ minimumSignificantDigits: 5
141
+ };
142
+ function formatNumberAndStringify(number, options = FORMAT_NUMBER_DEFAULT, numberFormatOptions = {}) {
143
+ const {
144
+ minBeforeUseScientific,
145
+ softDecimalPrecision,
146
+ maxBeforeAggresiveDecimalTruncation,
147
+ aggresiveDecimalPrecision,
148
+ maxBeforeUseSuffix,
149
+ decimalPrecisionForSuffix,
150
+ maxSuffixSize,
151
+ maxNumberPartSizeForSuffix
152
+ } = { ...FORMAT_NUMBER_DEFAULT, ...options };
153
+ if (number === 0) {
154
+ return number.toLocaleString("en", { ...numberFormatOptions });
155
+ }
156
+ if (!number) {
157
+ return "";
158
+ }
159
+ const absoluteNumber = Math.abs(number);
160
+ const roundedForSuffix = absoluteNumber.toFixed(decimalPrecisionForSuffix);
161
+ if (Number(roundedForSuffix) >= maxBeforeUseSuffix) {
162
+ return _formatTruncated(
163
+ number,
164
+ decimalPrecisionForSuffix,
165
+ false,
166
+ true,
167
+ maxSuffixSize,
168
+ maxNumberPartSizeForSuffix,
169
+ numberFormatOptions
170
+ );
171
+ }
172
+ if (absoluteNumber >= maxBeforeAggresiveDecimalTruncation) {
173
+ return number.toLocaleString("en", {
174
+ maximumFractionDigits: aggresiveDecimalPrecision,
175
+ ...numberFormatOptions
176
+ });
177
+ }
178
+ if (absoluteNumber < minBeforeUseScientific) {
179
+ return number.toLocaleString("en", {
180
+ notation: "scientific",
181
+ maximumFractionDigits: aggresiveDecimalPrecision,
182
+ ...numberFormatOptions
183
+ });
184
+ }
185
+ return number.toLocaleString("en", {
186
+ maximumFractionDigits: softDecimalPrecision,
187
+ // minimumSignificantDigits,
188
+ // maximumSignificantDigits: minimumSignificantDigits,
189
+ ...numberFormatOptions
190
+ });
191
+ }
192
+ function formatCurrencyAndStringify(amount, options = {}, numberFormatOptions = {}) {
193
+ const defaultOptions = {
194
+ maxSuffixSize: 1e12,
195
+ minBeforeUseScientific: 1e-6,
196
+ decimalPrecisionForSuffix: 2,
197
+ aggresiveDecimalPrecision: 2,
198
+ softDecimalPrecision: 6,
199
+ minimumSignificantDigits: 2
200
+ };
201
+ const defaultNumberFormatOptions = {
202
+ style: "currency",
203
+ currency: "USD",
204
+ minimumFractionDigits: 2,
205
+ // This enforces two decimal places
206
+ maximumFractionDigits: 2,
207
+ // This limits to two decimal places, ensuring consistency
208
+ compactDisplay: "long"
209
+ };
210
+ const formattedAsString = formatNumberAndStringify(
211
+ amount,
212
+ { ...defaultOptions, ...options },
213
+ {
214
+ ...defaultNumberFormatOptions,
215
+ ...numberFormatOptions
216
+ }
217
+ );
218
+ return formattedAsString;
219
+ }
220
+ function formatPercent(percent, decimalPlaces = 2) {
221
+ const maxDecimal = String(percent).split(".")[1]?.length || 2;
222
+ const finalDecimal = Math.max(Math.min(maxDecimal, decimalPlaces), 2);
223
+ return percent.toFixed(finalDecimal) + "%";
224
+ }
225
+ function formatCryptoAndStringify(amount, platform = "", useCurrencyAbbreviation = true, options) {
226
+ const defaultOptions = {
227
+ minimumSignificantDigits: 5
228
+ };
229
+ const defaultNumberFormatOptions = {
230
+ minimumFractionDigits: 5,
231
+ // This enforces two decimal places
232
+ maximumFractionDigits: 5
233
+ // This limits to two decimal places, ensuring consistency
234
+ };
235
+ const formattedAsString = formatNumberAndStringify(
236
+ amount,
237
+ { ...defaultOptions, ...options },
238
+ defaultNumberFormatOptions
239
+ );
240
+ const abbr = platform;
241
+ let result = formattedAsString;
242
+ if (useCurrencyAbbreviation && abbr) {
243
+ result = `${formattedAsString} ${abbr}`;
244
+ }
245
+ return result;
246
+ }
247
+ function _formatTruncated(value, precision = 2, keepTrailingZeros = false, useComma = false, maxSuffixValue = 1e12, maxNumberPartSizeForSuffix = 1e3, numberFormatOptions = {}) {
248
+ if (!Number.isFinite(value)) {
249
+ throw new Error("invalid number for `value` passed in to `formatTruncated`");
250
+ }
251
+ const negative = value < 0;
252
+ const absValue = Math.abs(value);
253
+ function getFormattedNumberPartAndSuffix(divideBy, suffixStr = "", nextSuffixStr = "") {
254
+ const dividedVal = absValue / divideBy;
255
+ const rawDividedValRounded = dividedVal.toFixed(precision);
256
+ const useScientific = Number(rawDividedValRounded) >= maxNumberPartSizeForSuffix || divideBy === 1e12 && Number(rawDividedValRounded) >= 1e3;
257
+ const incrementToNextSuffix = maxSuffixValue > divideBy && Number(rawDividedValRounded) >= 1e3;
258
+ const suffix2 = !incrementToNextSuffix ? suffixStr : nextSuffixStr;
259
+ const dividedValRounded = !incrementToNextSuffix ? rawDividedValRounded : (Number(rawDividedValRounded) / 1e3).toFixed(precision);
260
+ if (useComma || useScientific) {
261
+ return [
262
+ Number(dividedValRounded).toLocaleString("en", {
263
+ // don't use sci notation if the dividedValRounded is 1 because otherwise we get "1EB" instead of "1B"
264
+ ...useScientific && Number(dividedValRounded) !== 1 && { notation: "scientific" },
265
+ maximumFractionDigits: precision,
266
+ ...numberFormatOptions
267
+ }),
268
+ suffix2
269
+ ];
270
+ }
271
+ return [dividedValRounded, suffix2];
272
+ }
273
+ let [formatted, suffix] = getFormattedNumberPartAndSuffix(1, "", "K");
274
+ if (absValue >= 1e3 && (absValue < 1e6 || maxSuffixValue === 1e3)) {
275
+ ;
276
+ [formatted, suffix] = getFormattedNumberPartAndSuffix(1e3, "K", "M");
277
+ } else if (absValue >= 1e6 && (absValue < 1e9 || maxSuffixValue === 1e6)) {
278
+ ;
279
+ [formatted, suffix] = getFormattedNumberPartAndSuffix(1e6, "M", "B");
280
+ } else if (absValue >= 1e9 && (absValue < 1e12 || maxSuffixValue === 1e9)) {
281
+ ;
282
+ [formatted, suffix] = getFormattedNumberPartAndSuffix(1e9, "B", "T");
283
+ } else if (absValue >= 1e12) {
284
+ ;
285
+ [formatted, suffix] = getFormattedNumberPartAndSuffix(1e12, "T");
286
+ }
287
+ if (!keepTrailingZeros && !formatted?.includes("E")) {
288
+ const [before, after] = formatted.split(".");
289
+ const trimmedAfter = after?.replace(/0+$/gm, "");
290
+ formatted = before;
291
+ if (trimmedAfter?.length > 0) {
292
+ formatted += "." + trimmedAfter;
293
+ }
294
+ }
295
+ if (negative) {
296
+ formatted = "-" + formatted;
297
+ }
298
+ formatted += suffix;
299
+ return formatted;
300
+ }
301
+ function parseInputToNumber(input) {
302
+ return Number.parseFloat((input || 0).toString());
303
+ }
304
+ function roundUpToXDecimalPlaces(inputNumber, decimalPlaces) {
305
+ const multiplier = 10 ** decimalPlaces;
306
+ const roundedString = (Math.ceil(Number.parseFloat(inputNumber) * multiplier) / multiplier).toFixed(decimalPlaces);
307
+ const roundedNumber = Number.parseFloat(roundedString);
308
+ return roundedNumber;
309
+ }
310
+ var MIN_NUMBER = 0.01;
311
+ function normalizeSmallUsdNumber(usdNumber) {
312
+ if (!isNotNullish(usdNumber)) return 0;
313
+ const parsedNumber = Number.parseFloat(usdNumber.toString());
314
+ if (parsedNumber > 0 && parsedNumber < MIN_NUMBER) return MIN_NUMBER;
315
+ return parsedNumber;
316
+ }
317
+ function round(value, decimals, method = "round") {
318
+ return Math[method](value * 10 ** decimals) / 10 ** decimals;
319
+ }
320
+
321
+ // src/utils/formatFees.ts
322
+ function formatDynamicFeeUsd(fee, total, options = {}) {
323
+ const { percentThreshold = 2.5 } = options;
324
+ if (fee < 0.01) {
325
+ return `<${formatCurrencyAndStringify(0.01)}`;
326
+ }
327
+ if (percentThreshold !== null && fee > percentThreshold) {
328
+ return formatPercent(fee / total * 100);
329
+ }
330
+ return formatCurrencyAndStringify(fee);
331
+ }
332
+ function formatDynamicFeeToken(fee, symbol) {
333
+ if (fee < 1e-5) {
334
+ return `<${formatCryptoAndStringify(1e-5, symbol)}`;
335
+ }
336
+ return formatCryptoAndStringify(fee, symbol);
337
+ }
338
+
339
+ // src/utils/formatTimestamp.ts
340
+ var fullMonthNames = [
341
+ "January",
342
+ "February",
343
+ "March",
344
+ "April",
345
+ "May",
346
+ "June",
347
+ "July",
348
+ "August",
349
+ "September",
350
+ "October",
351
+ "November",
352
+ "December"
353
+ ];
354
+ var shortenedMonthNames = [
355
+ "Jan",
356
+ "Feb",
357
+ "Mar",
358
+ "Apr",
359
+ "May",
360
+ "Jun",
361
+ "Jul",
362
+ "Aug",
363
+ "Sep",
364
+ "Oct",
365
+ "Nov",
366
+ "Dec"
367
+ ];
368
+ function getDaySuffix(day) {
369
+ if (day >= 11 && day <= 13) {
370
+ return "th";
371
+ }
372
+ const lastDigit = day % 10;
373
+ switch (lastDigit) {
374
+ case 1:
375
+ return "st";
376
+ case 2:
377
+ return "nd";
378
+ case 3:
379
+ return "rd";
380
+ default:
381
+ return "th";
382
+ }
383
+ }
384
+ function formatTimestampToDate(date, { year = "full", month = "full" } = {}) {
385
+ const monthIdx = date.getMonth();
386
+ const monthStr = month === "short" ? shortenedMonthNames[monthIdx] : fullMonthNames[monthIdx];
387
+ const day = date.getDate();
388
+ const yearStr = year === "none" ? "" : date.getFullYear().toString().slice(year === "full" ? 0 : 2);
389
+ const daySuffix = getDaySuffix(day);
390
+ return `${monthStr} ${day}${daySuffix}${yearStr ? `, ${yearStr}` : ""}`;
391
+ }
392
+ function formatTimestamp(date, opt = {}) {
393
+ const { hours = "12hr", seconds } = opt;
394
+ const minutes = date.getMinutes();
395
+ const sec = date.getSeconds();
396
+ const secondsStr = seconds === "none" ? "" : sec < 10 ? "0" + sec : sec;
397
+ const hrs = date.getHours();
398
+ const hoursStr = hours === "24hr" ? hrs : hrs % 12 || 12;
399
+ const ampm = hours === "24hr" ? "" : hrs >= 12 ? "PM" : "AM";
400
+ return `${formatTimestampToDate(date, opt)} \xB7 ${hoursStr}:${minutes < 10 ? "0" : ""}${minutes}${secondsStr ? `:${secondsStr}` : ""}${ampm ? " " + ampm : ""}`;
401
+ }
402
+ function formatSecondsToReadableForm(seconds, specifyUnderMinute = false, omitSeconds = false) {
403
+ const normalizedSeconds = Math.ceil(seconds);
404
+ if (normalizedSeconds <= 60) {
405
+ return specifyUnderMinute ? "< 1min" : `${normalizedSeconds} seconds`;
406
+ }
407
+ const s = omitSeconds ? 0 : normalizedSeconds % 60;
408
+ const m = Math.ceil((normalizedSeconds - s) / 60) % 60;
409
+ const h = Math.ceil((normalizedSeconds - s - m * 60) / 60 / 60);
410
+ if (h === 1 && m === 0 && s === 0) {
411
+ return "60min";
412
+ }
413
+ return [h ? `${h}h` : "", m ? `${m}min` : "", s ? `${s}s` : ""].filter(Boolean).join(" ");
414
+ }
415
+ function formatSecondsToCountdownForm(seconds) {
416
+ const normalizedSeconds = Math.ceil(seconds);
417
+ const mins = Math.floor(normalizedSeconds / 60);
418
+ const remainingSecs = normalizedSeconds % 60;
419
+ return `${(mins < 10 ? "0" : "") + mins}:${(remainingSecs < 10 ? "0" : "") + remainingSecs}`;
420
+ }
421
+
422
+ // src/utils/groupBy.ts
423
+ function groupBy(items, getKey) {
424
+ const groupedItems = {};
425
+ for (const item of items) {
426
+ const key = getKey(item);
427
+ if (!key) {
428
+ continue;
429
+ }
430
+ if (!groupedItems[key]) {
431
+ groupedItems[key] = [];
432
+ }
433
+ groupedItems[key].push(item);
434
+ }
435
+ return groupedItems;
436
+ }
437
+
438
+ // src/utils/indexBy.ts
439
+ function indexBy(items, getKey) {
440
+ const indexedItems = {};
441
+ for (const item of items) {
442
+ const key = getKey(item);
443
+ if (!key) {
444
+ continue;
445
+ }
446
+ indexedItems[key] = item;
447
+ }
448
+ return indexedItems;
449
+ }
450
+
451
+ // src/utils/isMobile.ts
452
+ function isAndroid() {
453
+ return typeof navigator !== "undefined" && /android/i.test(navigator.userAgent);
454
+ }
455
+ function isSmallIOS() {
456
+ return typeof navigator !== "undefined" && /iPhone|iPod/.test(navigator.userAgent);
457
+ }
458
+ function isLargeIOS() {
459
+ return typeof navigator !== "undefined" && (/iPad/.test(navigator.userAgent) || navigator.platform === "MacIntel" && navigator.maxTouchPoints > 1);
460
+ }
461
+ function isIOS() {
462
+ return isSmallIOS() || isLargeIOS();
463
+ }
464
+ function isMobile() {
465
+ return isAndroid() || isIOS();
466
+ }
467
+
468
+ // src/utils/locale.ts
469
+ var detectedBrowserLocale = () => {
470
+ if (typeof window !== "undefined" && typeof navigator !== "undefined") {
471
+ if (navigator.languages?.length) {
472
+ return navigator.languages[0];
473
+ }
474
+ if (navigator.language) {
475
+ return navigator.language;
476
+ }
477
+ }
478
+ };
479
+
480
+ // src/utils/mobile.ts
481
+ function redirectInMobile(mobileUri) {
482
+ if (typeof window !== "undefined" && document) {
483
+ if (mobileUri.startsWith("http")) {
484
+ const link = document.createElement("a");
485
+ link.href = mobileUri;
486
+ link.target = "_blank";
487
+ link.rel = "noreferrer noopener";
488
+ link.click();
489
+ } else {
490
+ window.location.href = mobileUri;
491
+ }
492
+ }
493
+ }
494
+
495
+ // src/utils/noop.ts
496
+ var noop = () => void 0;
497
+
498
+ // src/utils/omitUndefinedValues.ts
499
+ function omitUndefinedValues(obj) {
500
+ return Object.fromEntries(
501
+ Object.entries(obj).filter(([, value]) => value !== void 0)
502
+ );
503
+ }
504
+
505
+ // src/utils/type.ts
506
+ var isRecord = (x) => {
507
+ return typeof x === "object" && x !== null;
508
+ };
509
+ export {
510
+ BrowserType,
511
+ capitalizeFirstLetter,
512
+ colorToHex,
513
+ convertHexToRGBA,
514
+ debounce,
515
+ deepMerge,
516
+ detectedBrowserLocale,
517
+ exhaustiveCheck,
518
+ formatAddress,
519
+ formatAddressLastFour,
520
+ formatCryptoAndStringify,
521
+ formatCurrencyAndStringify,
522
+ formatDynamicFeeToken,
523
+ formatDynamicFeeUsd,
524
+ formatNumberAndStringify,
525
+ formatPercent,
526
+ formatSecondsToCountdownForm,
527
+ formatSecondsToReadableForm,
528
+ formatTimestamp,
529
+ formatTimestampToDate,
530
+ fullMonthNames,
531
+ getBrowser,
532
+ groupBy,
533
+ indexBy,
534
+ isAndroid,
535
+ isArc,
536
+ isHexString,
537
+ isIOS,
538
+ isLargeIOS,
539
+ isMobile,
540
+ isNotNullish,
541
+ isRecord,
542
+ isSafari,
543
+ isSmallIOS,
544
+ noop,
545
+ normalizeSmallUsdNumber,
546
+ omitUndefinedValues,
547
+ parseInputToNumber,
548
+ redirectInMobile,
549
+ round,
550
+ roundUpToXDecimalPlaces
551
+ };
552
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/utils/address.ts", "../src/utils/browsers.ts", "../src/utils/capitalize.ts", "../src/utils/colors.ts", "../src/utils/debounce.ts", "../src/utils/deepMerge.ts", "../src/utils/exhaustiveCheck.ts", "../src/utils/isNotNullish.ts", "../src/utils/formatNumber.ts", "../src/utils/formatFees.ts", "../src/utils/formatTimestamp.ts", "../src/utils/groupBy.ts", "../src/utils/indexBy.ts", "../src/utils/isMobile.ts", "../src/utils/locale.ts", "../src/utils/mobile.ts", "../src/utils/noop.ts", "../src/utils/omitUndefinedValues.ts", "../src/utils/type.ts"],
4
+ "sourcesContent": ["export function formatAddress(address: string): string {\n const leadingChars = 4\n const trailingChars = 4\n\n return address.length < leadingChars + trailingChars\n ? address\n : `${address.substring(0, leadingChars)}\\u2026${address.substring(\n address.length - trailingChars,\n )}`\n}\n\nexport function formatAddressLastFour(address: string): string {\n const trailingChars = 4\n return address.length < trailingChars\n ? address\n : `\\u2026${address.substring(address.length - trailingChars)}`\n}\n", "export function isSafari(): boolean {\n return (\n typeof navigator !== 'undefined' &&\n typeof navigator.userAgent !== 'undefined' &&\n /Version\\/([0-9._]+).*Safari/.test(navigator.userAgent) // Source: https://github.com/DamonOehlman/detect-browser/blob/master/src/index.ts\n )\n}\n\nexport function isArc(): boolean {\n return (\n typeof document !== 'undefined' &&\n getComputedStyle(document.body).getPropertyValue('--arc-palette-focus') !==\n ''\n )\n}\n\nexport enum BrowserType {\n Arc = 'Arc',\n Brave = 'Brave',\n Browser = 'Browser',\n Chrome = 'Chrome',\n Edge = 'Edge',\n Firefox = 'Firefox',\n Opera = 'Opera',\n Safari = 'Safari',\n}\n\nexport function getBrowser(): BrowserType {\n // bail out if `navigator` or `navigator.userAgent` is not available\n if (typeof navigator === 'undefined') return BrowserType.Browser\n const ua = navigator.userAgent?.toLowerCase()\n // @ts-expect-error - brave is not in the navigator type\n if (navigator.brave?.isBrave) return BrowserType.Brave\n if (ua?.indexOf('edg/') > -1) return BrowserType.Edge\n if (ua?.indexOf('op') > -1) return BrowserType.Opera\n if (isArc()) return BrowserType.Arc\n if (ua?.indexOf('chrome') > -1) return BrowserType.Chrome\n if (ua?.indexOf('firefox') > -1) return BrowserType.Firefox\n if (isSafari()) return BrowserType.Safari\n return BrowserType.Browser\n}\n", "export function capitalizeFirstLetter(val: string) {\n return String(val).charAt(0).toUpperCase() + String(val).slice(1)\n}\n", "export function colorToHex(color: string): string {\n // Check if the input is in RGB format\n const rgbMatch = color.match(/^rgb\\((\\d+),\\s*(\\d+),\\s*(\\d+)\\)$/)\n if (rgbMatch) {\n const [, r, g, b] = rgbMatch.map(Number)\n // Convert RGB to HEX\n const rHex = r.toString(16).padStart(2, '0')\n const gHex = g.toString(16).padStart(2, '0')\n const bHex = b.toString(16).padStart(2, '0')\n return `#${rHex}${gHex}${bHex}`\n }\n\n // Check if the input is in HEX format\n const hexMatch = color.match(/^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i)\n if (hexMatch) {\n return hexMatch[0].toLowerCase()\n }\n\n return color\n}\n\nexport const convertHexToRGBA = (hexCode: string, opacity = 1): string => {\n let hex = hexCode.replace('#', '')\n\n if (hex.length === 3) {\n hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`\n }\n\n const r = Number.parseInt(hex.substring(0, 2), 16)\n const g = Number.parseInt(hex.substring(2, 4), 16)\n const b = Number.parseInt(hex.substring(4, 6), 16)\n\n /* Backward compatibility for whole number based opacity values. */\n const finalOpacity = opacity > 1 && opacity <= 100 ? opacity / 100 : opacity\n\n return `rgba(${r},${g},${b},${finalOpacity})`\n}\n\nexport const isHexString = (color: string): boolean => {\n return /^#([0-9a-f]{3}){1,2}$/i.test(color)\n}\n", "export function debounce(fn: () => void, ms: number) {\n let timer: NodeJS.Timeout | null\n\n return () => {\n if (timer) {\n clearTimeout(timer)\n }\n\n timer = setTimeout(() => {\n timer = null\n fn()\n }, ms)\n }\n}\n", "export type DeepPartial<T> = T extends\n | number\n | string\n | boolean\n | null\n | undefined\n ? T\n : {\n [P in keyof T]?: DeepPartial<T[P]>\n }\n\nfunction deepClone<T extends object>(obj: T): T {\n return JSON.parse(JSON.stringify(obj))\n}\n\n/** NOTE: merging arrays is undefined behavior */\nexport function deepMerge<T extends object>(\n origin: T,\n ...objects: DeepPartial<T>[]\n): T {\n const target = deepClone(origin) as T\n\n for (const obj of objects) {\n for (const key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) {\n const value = obj[key]\n if (Array.isArray(value)) {\n // @ts-expect-error\n target[key] = value\n } else if (typeof value === 'object' && value !== null) {\n // @ts-expect-error\n target[key] = deepMerge(target[key], value)\n } else {\n // @ts-expect-error\n target[key] = value\n }\n }\n }\n }\n\n return target\n}\n", "export function exhaustiveCheck(_value: never): any {\n if (process.env.NODE_ENV === 'local') {\n throw new Error('exhaustiveCheck: should not reach this point')\n }\n}\n", "export function isNotNullish<T>(value: T | null | undefined): value is T {\n return value != null\n}\n", "import { isNotNullish } from './isNotNullish'\n\ninterface FormatNumberOptions {\n /** Numbers smaller than this will be converted to scientific notation */\n minBeforeUseScientific?: number\n /** If the number part for suffixed # is >= this, will use sci notation (e.g. 1,000M -> 1E3M) */\n maxNumberPartSizeForSuffix?: number\n /** The amount of decimal places to truncate to when softly truncating (to specify decimal places for suffix-truncation, e.g. 1.23M, use decimalPrecisionForSuffix) */\n softDecimalPrecision?: number\n /** Numbers >= this will have their decimals truncated aggressively */\n maxBeforeAggresiveDecimalTruncation?: number\n /** The amount of decimal places to truncate to when aggressively truncating (to specify decimal places for suffix-truncation, e.g. 1.23M, use decimalPrecisionForSuffix) */\n aggresiveDecimalPrecision?: number\n /** Numbers >= this will have a suffix added during truncation (e.g. 1.23M) */\n maxBeforeUseSuffix?: number\n /** The amount of decimal places to truncate suffix-truncated numbers to (e.g. 1.23M vs 1.2312M)*/\n decimalPrecisionForSuffix?: number\n /** The largest suffix to use (e.g. if 1000000, we will stop at M and not use the B suffix) */\n maxSuffixSize?: 1e3 | 1e6 | 1e9 | 1e12\n numberFormatOptions?: Intl.NumberFormatOptions\n /** Adds minimum significant digits value to force numbers to show decimal precision even when there are none 5 -> 5.00 */\n minimumSignificantDigits?: number\n}\n\nconst FORMAT_NUMBER_DEFAULT = {\n minBeforeUseScientific: 0.00001,\n maxBeforeAggresiveDecimalTruncation: 1,\n softDecimalPrecision: 5,\n aggresiveDecimalPrecision: 5,\n maxBeforeUseSuffix: 1000000,\n decimalPrecisionForSuffix: 5,\n maxSuffixSize: 1000000,\n maxNumberPartSizeForSuffix: 1e3,\n minimumSignificantDigits: 5,\n} satisfies FormatNumberOptions\n\n/**\n * Formats a number with conditional truncation, suffixation, and scientific notation.\n * @param number\n * @param options Customize the formatting conditions/behavior\n * @example Visualization, using default values:\n * ```\n * <--(1.23E-7)---0.00001------(0.12121)-------1-------(123,423.26)---1,000,000---(1.22M)--(100.23M)-->\n * _______<-minBeforeScientific maxBeforeAggressive-> maxBeforeUseSuffix-> ^ w/ maxSuffixSize\n * ```\n */\nexport function formatNumberAndStringify(\n number: number,\n options: FormatNumberOptions = FORMAT_NUMBER_DEFAULT,\n numberFormatOptions = {},\n) {\n const {\n minBeforeUseScientific,\n softDecimalPrecision,\n maxBeforeAggresiveDecimalTruncation,\n aggresiveDecimalPrecision,\n maxBeforeUseSuffix,\n decimalPrecisionForSuffix,\n maxSuffixSize,\n maxNumberPartSizeForSuffix,\n } = { ...FORMAT_NUMBER_DEFAULT, ...options }\n\n if (number === 0) {\n return number.toLocaleString('en', { ...numberFormatOptions })\n }\n if (!number) {\n return ''\n }\n const absoluteNumber = Math.abs(number)\n\n const roundedForSuffix = absoluteNumber.toFixed(decimalPrecisionForSuffix)\n // rounding to decimal precision may increment the number high enough to require a suffix\n if (Number(roundedForSuffix) >= maxBeforeUseSuffix) {\n return _formatTruncated(\n number,\n decimalPrecisionForSuffix,\n false,\n true,\n maxSuffixSize,\n maxNumberPartSizeForSuffix,\n numberFormatOptions,\n )\n }\n if (absoluteNumber >= maxBeforeAggresiveDecimalTruncation) {\n return number.toLocaleString('en', {\n maximumFractionDigits: aggresiveDecimalPrecision,\n ...numberFormatOptions,\n })\n }\n if (absoluteNumber < minBeforeUseScientific) {\n return number.toLocaleString('en', {\n notation: 'scientific',\n maximumFractionDigits: aggresiveDecimalPrecision,\n ...numberFormatOptions,\n })\n }\n // else, minBeforeScientific <= number < maxBeforeAggresive\n return number.toLocaleString('en', {\n maximumFractionDigits: softDecimalPrecision,\n // minimumSignificantDigits,\n // maximumSignificantDigits: minimumSignificantDigits,\n ...numberFormatOptions,\n })\n}\n\n/** Formats a number for currency (default $) display */\nexport function formatCurrencyAndStringify(\n amount: number,\n /** Options to pass `formatNumberAndStringify */\n options: FormatNumberOptions = {},\n /** Options to pass toLocaleString */\n numberFormatOptions: Intl.NumberFormatOptions = {},\n) {\n const defaultOptions: FormatNumberOptions = {\n maxSuffixSize: 1e12,\n minBeforeUseScientific: 0.000001,\n decimalPrecisionForSuffix: 2,\n aggresiveDecimalPrecision: 2,\n softDecimalPrecision: 6,\n minimumSignificantDigits: 2,\n }\n const defaultNumberFormatOptions: Intl.NumberFormatOptions = {\n style: 'currency',\n currency: 'USD',\n minimumFractionDigits: 2, // This enforces two decimal places\n maximumFractionDigits: 2, // This limits to two decimal places, ensuring consistency\n compactDisplay: 'long',\n }\n\n const formattedAsString = formatNumberAndStringify(\n amount,\n { ...defaultOptions, ...options },\n {\n ...defaultNumberFormatOptions,\n ...numberFormatOptions,\n },\n )\n return formattedAsString\n}\n\nexport function formatPercent(percent: number, decimalPlaces = 2) {\n const maxDecimal = String(percent).split('.')[1]?.length || 2\n const finalDecimal = Math.max(Math.min(maxDecimal, decimalPlaces), 2)\n return percent.toFixed(finalDecimal) + '%'\n}\n\n/**\n * Formats a cryptocurrency amount as a string for display.\n *\n * Can customize with options and whether to display currency abbreviation.\n */\nexport function formatCryptoAndStringify(\n /** The currency amount **/\n amount: number,\n /** The currency abbreviation e.g. ETH, USDC, ... **/\n platform = '',\n /** Displays abbreviation after amount, e.g. '1.25 ETH'; default true **/\n useCurrencyAbbreviation = true,\n /** Used to format the number, can be used to customize decimal truncation etc. **/\n options?: FormatNumberOptions,\n) {\n const defaultOptions: FormatNumberOptions = {\n minimumSignificantDigits: 5,\n }\n const defaultNumberFormatOptions: Intl.NumberFormatOptions = {\n minimumFractionDigits: 5, // This enforces two decimal places\n maximumFractionDigits: 5, // This limits to two decimal places, ensuring consistency\n }\n const formattedAsString = formatNumberAndStringify(\n amount,\n { ...defaultOptions, ...options },\n defaultNumberFormatOptions,\n )\n // get currency\n const abbr = platform\n\n let result = formattedAsString\n if (useCurrencyAbbreviation && abbr) {\n result = `${formattedAsString} ${abbr}`\n }\n return result\n}\n\nfunction _formatTruncated(\n value: number,\n precision = 2,\n keepTrailingZeros = false,\n useComma = false,\n maxSuffixValue = 1e12,\n maxNumberPartSizeForSuffix = 1e3,\n numberFormatOptions = {},\n) {\n if (!Number.isFinite(value)) {\n throw new Error('invalid number for `value` passed in to `formatTruncated`')\n }\n\n const negative = value < 0\n const absValue = Math.abs(value)\n\n function getFormattedNumberPartAndSuffix(\n divideBy: number,\n suffixStr = '',\n nextSuffixStr = '',\n ): [formatted: string, suffix: string] {\n const dividedVal = absValue / divideBy\n const rawDividedValRounded = dividedVal.toFixed(precision)\n\n // use sci notation for large number parts\n const useScientific =\n Number(rawDividedValRounded) >= maxNumberPartSizeForSuffix ||\n (divideBy === 1e12 && Number(rawDividedValRounded) >= 1e3) // anything >= 1,000T should be sci notation\n\n // the rounding that occurs due to decimal precision can increase the suffix size, e.g. 999.999999 -> 1K\n const incrementToNextSuffix =\n maxSuffixValue > divideBy && Number(rawDividedValRounded) >= 1000\n const suffix = !incrementToNextSuffix ? suffixStr : nextSuffixStr\n const dividedValRounded = !incrementToNextSuffix\n ? rawDividedValRounded\n : (Number(rawDividedValRounded) / 1000).toFixed(precision)\n\n if (useComma || useScientific) {\n return [\n Number(dividedValRounded).toLocaleString('en', {\n // don't use sci notation if the dividedValRounded is 1 because otherwise we get \"1EB\" instead of \"1B\"\n ...(useScientific &&\n Number(dividedValRounded) !== 1 && { notation: 'scientific' }),\n maximumFractionDigits: precision,\n ...numberFormatOptions,\n }),\n suffix,\n ]\n }\n return [dividedValRounded, suffix]\n }\n\n let [formatted, suffix] = getFormattedNumberPartAndSuffix(1, '', 'K')\n if (absValue >= 1e3 && (absValue < 1e6 || maxSuffixValue === 1e3)) {\n ;[formatted, suffix] = getFormattedNumberPartAndSuffix(1e3, 'K', 'M')\n } else if (absValue >= 1e6 && (absValue < 1e9 || maxSuffixValue === 1e6)) {\n ;[formatted, suffix] = getFormattedNumberPartAndSuffix(1e6, 'M', 'B')\n } else if (absValue >= 1e9 && (absValue < 1e12 || maxSuffixValue === 1e9)) {\n ;[formatted, suffix] = getFormattedNumberPartAndSuffix(1e9, 'B', 'T')\n } else if (absValue >= 1e12) {\n ;[formatted, suffix] = getFormattedNumberPartAndSuffix(1e12, 'T')\n }\n\n if (!keepTrailingZeros && !formatted?.includes('E')) {\n const [before, after] = formatted.split('.')\n const trimmedAfter = after?.replace(/0+$/gm, '')\n formatted = before\n if (trimmedAfter?.length > 0) {\n formatted += '.' + trimmedAfter\n }\n }\n if (negative) {\n formatted = '-' + formatted\n }\n formatted += suffix\n return formatted\n}\n\nexport function parseInputToNumber(input: string | number | undefined): number {\n return Number.parseFloat((input || 0).toString())\n}\n\n// Rounds up a number to the number of specified decimal places\n// DO NOT use for display purposes (it will do 41.80 -> 41.8).\n// Use formatNumberAndStringify(amount, {}, { maximumFractionDigits: 2, minimumFractionDigits: 2 }) instead.\nexport function roundUpToXDecimalPlaces(\n inputNumber: string,\n decimalPlaces: number,\n) {\n // Using toFixed to round up to X decimal places\n const multiplier = 10 ** decimalPlaces\n const roundedString = (\n Math.ceil(Number.parseFloat(inputNumber) * multiplier) / multiplier\n ).toFixed(decimalPlaces)\n\n // Converting the rounded string back to a number\n const roundedNumber = Number.parseFloat(roundedString)\n return roundedNumber\n}\n\nconst MIN_NUMBER = 0.01\nexport function normalizeSmallUsdNumber(usdNumber: string | number | null) {\n if (!isNotNullish(usdNumber)) return 0\n const parsedNumber = Number.parseFloat(usdNumber.toString())\n if (parsedNumber > 0 && parsedNumber < MIN_NUMBER) return MIN_NUMBER\n return parsedNumber\n}\n\nexport function round(\n value: number,\n decimals: number,\n /**\n * Whether to round up ('ceil'), down ('floor'), or nearest ('round')\n *\n * Defauls to 'round'\n **/\n method: 'ceil' | 'floor' | 'round' = 'round',\n): number {\n return Math[method](value * 10 ** decimals) / 10 ** decimals\n}\n", "import {\n formatCryptoAndStringify,\n formatCurrencyAndStringify,\n formatPercent,\n} from './formatNumber'\n\nexport interface FormatDynamicFeeUsdOptions {\n /**\n * Threshold in USD above which the fee should be displayed in %\n *\n * Defauls to 2.5\n *\n * Pass null to disable % format altogether\n */\n percentThreshold?: number | null\n}\n\n// For any fees, if the total fee amounts to less than $2.50, show the fee as a strict dollar value.\n// If the fee is greater than $2.50, show it as a percent.\n// If the fee is less than $0.01, show <$0.01 instead.\nexport function formatDynamicFeeUsd(\n fee: number,\n total: number,\n options: FormatDynamicFeeUsdOptions = {},\n) {\n const { percentThreshold = 2.5 } = options\n\n if (fee < 0.01) {\n return `<${formatCurrencyAndStringify(0.01)}`\n }\n\n if (percentThreshold !== null && fee > percentThreshold) {\n return formatPercent((fee / total) * 100)\n }\n\n return formatCurrencyAndStringify(fee)\n}\n\n// If the fee is less than 0.00001, show <0.00001 instead.\nexport function formatDynamicFeeToken(fee: number, symbol: string) {\n if (fee < 0.00001) {\n return `<${formatCryptoAndStringify(0.00001, symbol)}`\n }\n\n return formatCryptoAndStringify(fee, symbol)\n}\n", "export const fullMonthNames = [\n 'January',\n 'February',\n 'March',\n 'April',\n 'May',\n 'June',\n 'July',\n 'August',\n 'September',\n 'October',\n 'November',\n 'December',\n]\n\nconst shortenedMonthNames = [\n 'Jan',\n 'Feb',\n 'Mar',\n 'Apr',\n 'May',\n 'Jun',\n 'Jul',\n 'Aug',\n 'Sep',\n 'Oct',\n 'Nov',\n 'Dec',\n]\n\nfunction getDaySuffix(day: number): string {\n if (day >= 11 && day <= 13) {\n return 'th'\n }\n const lastDigit = day % 10\n switch (lastDigit) {\n case 1:\n return 'st'\n case 2:\n return 'nd'\n case 3:\n return 'rd'\n default:\n return 'th'\n }\n}\n\ninterface FormatDateOption {\n year?: 'full' | 'short' | 'none'\n month?: 'full' | 'short'\n}\n\nexport function formatTimestampToDate(\n date: Date,\n { year = 'full', month = 'full' }: FormatDateOption = {},\n) {\n const monthIdx = date.getMonth()\n const monthStr =\n month === 'short' ? shortenedMonthNames[monthIdx] : fullMonthNames[monthIdx]\n const day = date.getDate()\n const yearStr =\n year === 'none'\n ? ''\n : date\n .getFullYear()\n .toString()\n .slice(year === 'full' ? 0 : 2)\n const daySuffix = getDaySuffix(day)\n return `${monthStr} ${day}${daySuffix}${yearStr ? `, ${yearStr}` : ''}`\n}\n\ninterface FormatTimeOption extends FormatDateOption {\n hours?: '24hr' | '12hr'\n seconds?: 'none'\n}\n\nexport function formatTimestamp(\n date: Date,\n opt: FormatTimeOption = {},\n): string {\n const { hours = '12hr', seconds } = opt\n const minutes = date.getMinutes()\n const sec = date.getSeconds()\n const secondsStr = seconds === 'none' ? '' : sec < 10 ? '0' + sec : sec\n const hrs = date.getHours()\n const hoursStr = hours === '24hr' ? hrs : hrs % 12 || 12\n const ampm = hours === '24hr' ? '' : hrs >= 12 ? 'PM' : 'AM'\n\n return `${formatTimestampToDate(date, opt)} \u00B7 ${hoursStr}:${\n minutes < 10 ? '0' : ''\n }${minutes}${secondsStr ? `:${secondsStr}` : ''}${ampm ? ' ' + ampm : ''}`\n}\n\n/**\n * Formats seconds to mins and seconds string\n * - seconds = 10, output = '10 seconds'\n * - seconds = 20.3, output = '21 seconds'\n * - seconds = 20.3, specifyUnderMinute=true, output = '< 1min'\n * - seconds = 60, output = '60 seconds'\n * - seconds = 61, output = '1min 1s'\n * - seconds = 300, output = '5min'\n * - seconds = 320, output = '5min 20s'\n * - seconds = 320, omitSeconds=true, output = '6min'\n * - seconds = 3600, output = '60min'\n * - seconds = 3900, output = '1h 5min'\n * - seconds = 3920, output = '1h 5min 20s'\n */\nexport function formatSecondsToReadableForm(\n seconds: number,\n specifyUnderMinute = false,\n omitSeconds = false,\n): string {\n const normalizedSeconds = Math.ceil(seconds)\n\n if (normalizedSeconds <= 60) {\n return specifyUnderMinute ? '< 1min' : `${normalizedSeconds} seconds`\n }\n\n const s = omitSeconds ? 0 : normalizedSeconds % 60\n const m = Math.ceil((normalizedSeconds - s) / 60) % 60\n const h = Math.ceil((normalizedSeconds - s - m * 60) / 60 / 60)\n\n // Special case - show '60min' instead of '1h'\n if (h === 1 && m === 0 && s === 0) {\n return '60min'\n }\n\n return [h ? `${h}h` : '', m ? `${m}min` : '', s ? `${s}s` : '']\n .filter(Boolean)\n .join(' ')\n}\n\nexport function formatSecondsToCountdownForm(seconds: number) {\n const normalizedSeconds = Math.ceil(seconds)\n const mins = Math.floor(normalizedSeconds / 60)\n const remainingSecs = normalizedSeconds % 60\n return `${(mins < 10 ? '0' : '') + mins}:${\n (remainingSecs < 10 ? '0' : '') + remainingSecs\n }`\n}\n", "export function groupBy<Item>(\n items: Item[],\n getKey: (item: Item) => string,\n): Record<string, Item[]> {\n const groupedItems: Record<string, Item[]> = {}\n\n for (const item of items) {\n const key = getKey(item)\n\n if (!key) {\n continue\n }\n\n if (!groupedItems[key]) {\n groupedItems[key] = []\n }\n\n groupedItems[key].push(item)\n }\n\n return groupedItems\n}\n", "export function indexBy<Item>(\n items: Item[],\n getKey: (item: Item) => string,\n): Record<string, Item> {\n const indexedItems: Record<string, Item> = {}\n\n for (const item of items) {\n const key = getKey(item)\n\n if (!key) {\n continue\n }\n\n indexedItems[key] = item\n }\n\n return indexedItems\n}\n", "export function isAndroid(): boolean {\n return (\n typeof navigator !== 'undefined' && /android/i.test(navigator.userAgent)\n )\n}\n\nexport function isSmallIOS(): boolean {\n return (\n typeof navigator !== 'undefined' && /iPhone|iPod/.test(navigator.userAgent)\n )\n}\n\nexport function isLargeIOS(): boolean {\n return (\n typeof navigator !== 'undefined' &&\n (/iPad/.test(navigator.userAgent) ||\n (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1))\n )\n}\n\nexport function isIOS(): boolean {\n return isSmallIOS() || isLargeIOS()\n}\n\nexport function isMobile(): boolean {\n return isAndroid() || isIOS()\n}\n", "// Detect user locale from browser user agent\nexport const detectedBrowserLocale = () => {\n if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {\n if (navigator.languages?.length) {\n return navigator.languages[0]\n }\n\n if (navigator.language) {\n return navigator.language\n }\n }\n}\n", "export function redirectInMobile(mobileUri: string) {\n if (typeof window !== 'undefined' && document) {\n if (mobileUri.startsWith('http')) {\n // Workaround for https://github.com/rainbow-me/rainbowkit/issues/524.\n // Using 'window.open' causes issues on iOS in non-Safari browsers and\n // WebViews where a blank tab is left behind after connecting.\n // This is especially bad in some WebView scenarios (e.g. following a\n // link from Twitter) where the user doesn't have any mechanism for\n // closing the blank tab.\n // For whatever reason, links with a target of \"_blank\" don't suffer\n // from this problem, and programmatically clicking a detached link\n // element with the same attributes also avoids the issue.\n const link = document.createElement('a')\n link.href = mobileUri\n link.target = '_blank'\n link.rel = 'noreferrer noopener'\n link.click()\n } else {\n window.location.href = mobileUri\n }\n }\n}\n", "export const noop = () => void {}\n", "export function omitUndefinedValues<T extends object>(obj: T): T {\n return Object.fromEntries(\n Object.entries(obj).filter(([, value]) => value !== undefined),\n ) as T\n}\n", "export const isRecord = (x: unknown): x is Record<string, unknown> => {\n return typeof x === 'object' && x !== null\n}\n"],
5
+ "mappings": ";AAAO,SAAS,cAAc,SAAyB;AACrD,QAAM,eAAe;AACrB,QAAM,gBAAgB;AAEtB,SA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,CAAC,EAAE,KAAK,MAAM,UAAU,MAAS;AAAA,EAC/D;AACF;;;ACJO,IAAM,WAAW,CAAC,MAA6C;AACpE,SAAO,OAAO,MAAM,YAAY,MAAM;AACxC;",
6
+ "names": ["BrowserType", "suffix"]
7
+ }
package/package.json ADDED
@@ -0,0 +1,52 @@
1
+ {
2
+ "name": "@funkit/utils",
3
+ "version": "1.0.0",
4
+ "description": "Funkit Utils SDK centralizes all utilities & consts for usage across all funkit apps and packages.",
5
+ "files": [
6
+ "dist/src",
7
+ "dist/index.d.ts",
8
+ "dist/index.js",
9
+ "dist/index.js.map"
10
+ ],
11
+ "type": "module",
12
+ "main": "./dist/index.js",
13
+ "types": "./dist/index.d.ts",
14
+ "sideEffects": false,
15
+ "engines": {
16
+ "node": ">=18"
17
+ },
18
+ "publishConfig": {
19
+ "access": "public"
20
+ },
21
+ "keywords": [
22
+ "blockchain",
23
+ "funkit"
24
+ ],
25
+ "author": "https://fun.xyz/",
26
+ "license": "MIT",
27
+ "devDependencies": {
28
+ "@testing-library/jest-dom": "^6.2.0",
29
+ "@testing-library/react": "^16.0.1",
30
+ "@testing-library/user-event": "^14.5.2",
31
+ "jsdom": "^23.0.1",
32
+ "react": "^18.3.0",
33
+ "vitest": "^2.0.5"
34
+ },
35
+ "repository": {
36
+ "type": "git",
37
+ "url": "git+https://github.com/fun-xyz/funkit.git",
38
+ "directory": "packages/utils"
39
+ },
40
+ "homepage": "https://github.com/fun-xyz/funkit/tree/main/packages/utils",
41
+ "scripts": {
42
+ "build": "node build.js && pnpm typecheck",
43
+ "build:watch": "node build.js --watch",
44
+ "dev": "pnpm build:watch & pnpm typegen:watch",
45
+ "prebuild": "pnpm typegen",
46
+ "typecheck": "pnpm tsc --project tsconfig.test.json --noEmit",
47
+ "typegen": "tsc --emitDeclarationOnly || true",
48
+ "typegen:watch": "tsc --emitDeclarationOnly --watch",
49
+ "lint": "biome check",
50
+ "lint:fix": "biome check --fix"
51
+ }
52
+ }