@react-hive/honey-utils 3.13.1 → 3.15.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 +8 -5
- package/dist/README.md +8 -5
- package/dist/a11y/focus/is-html-element-focusable.d.ts +1 -1
- package/dist/a11y/focus/move-focus-within-container.d.ts +1 -1
- package/dist/{async.d.ts → async/async.d.ts} +1 -1
- package/dist/async/delay.d.ts +26 -0
- package/dist/async/index.d.ts +4 -0
- package/dist/async/retry.d.ts +72 -0
- package/dist/async/timeout.d.ts +23 -0
- package/dist/file.d.ts +1 -17
- package/dist/function/function.d.ts +47 -0
- package/dist/function/index.d.ts +2 -0
- package/dist/function/invoke-if-function.d.ts +13 -0
- package/dist/geometry/apply-inertia-step.d.ts +134 -0
- package/dist/geometry/index.d.ts +2 -0
- package/dist/geometry/resolve-bounded-delta.d.ts +79 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.dev.cjs +719 -273
- package/dist/index.dev.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/math/hash-string.d.ts +25 -0
- package/dist/math/index.d.ts +2 -0
- package/dist/string/camel-to-dash-case.d.ts +20 -0
- package/dist/string/camel-to-words.d.ts +19 -0
- package/dist/string/index.d.ts +7 -0
- package/dist/string/is-nil-or-empty-string.d.ts +13 -0
- package/dist/string/is-string.d.ts +8 -0
- package/dist/string/parse-file-name.d.ts +16 -0
- package/dist/string/split-string-into-words.d.ts +8 -0
- package/dist/string/to-kebab-case.d.ts +18 -0
- package/package.json +1 -1
- package/dist/function.d.ts +0 -181
- package/dist/string.d.ts +0 -111
- /package/dist/{math.d.ts → math/math.d.ts} +0 -0
package/dist/index.dev.cjs
CHANGED
|
@@ -12,7 +12,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
12
12
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
13
13
|
/* harmony export */ getFocusableHtmlElements: () => (/* binding */ getFocusableHtmlElements)
|
|
14
14
|
/* harmony export */ });
|
|
15
|
-
/* harmony import */ var
|
|
15
|
+
/* harmony import */ var _a11y__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/a11y */ "./src/a11y/index.ts");
|
|
16
16
|
|
|
17
17
|
/**
|
|
18
18
|
* Collects all focusable descendant elements within a container.
|
|
@@ -25,7 +25,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
25
25
|
*
|
|
26
26
|
* @returns An array of focusable HTMLElements in DOM order.
|
|
27
27
|
*/
|
|
28
|
-
const getFocusableHtmlElements = (container) => Array.from(container.querySelectorAll('*')).filter(
|
|
28
|
+
const getFocusableHtmlElements = (container) => Array.from(container.querySelectorAll('*')).filter(_a11y__WEBPACK_IMPORTED_MODULE_0__.isHtmlElementFocusable);
|
|
29
29
|
|
|
30
30
|
|
|
31
31
|
/***/ }),
|
|
@@ -64,7 +64,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
64
64
|
/* harmony export */ FOCUSABLE_HTML_TAGS: () => (/* binding */ FOCUSABLE_HTML_TAGS),
|
|
65
65
|
/* harmony export */ isHtmlElementFocusable: () => (/* binding */ isHtmlElementFocusable)
|
|
66
66
|
/* harmony export */ });
|
|
67
|
-
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*!
|
|
67
|
+
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/dom */ "./src/dom/index.ts");
|
|
68
68
|
|
|
69
69
|
const FOCUSABLE_HTML_TAGS = ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON', 'A'];
|
|
70
70
|
/**
|
|
@@ -126,7 +126,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
126
126
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
127
127
|
/* harmony export */ moveFocusWithinContainer: () => (/* binding */ moveFocusWithinContainer)
|
|
128
128
|
/* harmony export */ });
|
|
129
|
-
/* harmony import */ var
|
|
129
|
+
/* harmony import */ var _a11y__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/a11y */ "./src/a11y/index.ts");
|
|
130
130
|
|
|
131
131
|
/**
|
|
132
132
|
* Moves focus to the next or previous focusable element within a container.
|
|
@@ -158,7 +158,7 @@ const moveFocusWithinContainer = (direction, container = null, { wrap = true, ge
|
|
|
158
158
|
if (!activeElement || !scope) {
|
|
159
159
|
return;
|
|
160
160
|
}
|
|
161
|
-
const focusableElements = (0,
|
|
161
|
+
const focusableElements = (0,_a11y__WEBPACK_IMPORTED_MODULE_0__.getFocusableHtmlElements)(scope);
|
|
162
162
|
if (focusableElements.length === 0) {
|
|
163
163
|
return;
|
|
164
164
|
}
|
|
@@ -230,7 +230,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
230
230
|
/* harmony export */ pipe: () => (/* binding */ pipe),
|
|
231
231
|
/* harmony export */ unique: () => (/* binding */ unique)
|
|
232
232
|
/* harmony export */ });
|
|
233
|
-
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*!
|
|
233
|
+
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/guards */ "./src/guards.ts");
|
|
234
234
|
|
|
235
235
|
/**
|
|
236
236
|
* Checks if a value is an array.
|
|
@@ -398,10 +398,10 @@ const compose = (...fns) => (arg) => fns.reduceRight((prev, fn) => fn(prev), arg
|
|
|
398
398
|
|
|
399
399
|
/***/ }),
|
|
400
400
|
|
|
401
|
-
/***/ "./src/async.ts":
|
|
402
|
-
|
|
403
|
-
!*** ./src/async.ts ***!
|
|
404
|
-
|
|
401
|
+
/***/ "./src/async/async.ts":
|
|
402
|
+
/*!****************************!*\
|
|
403
|
+
!*** ./src/async/async.ts ***!
|
|
404
|
+
\****************************/
|
|
405
405
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
406
406
|
|
|
407
407
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -416,8 +416,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
416
416
|
/* harmony export */ runSequential: () => (/* binding */ runSequential),
|
|
417
417
|
/* harmony export */ someAsync: () => (/* binding */ someAsync)
|
|
418
418
|
/* harmony export */ });
|
|
419
|
-
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*!
|
|
420
|
-
/* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*!
|
|
419
|
+
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/array */ "./src/array.ts");
|
|
420
|
+
/* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/function */ "./src/function/index.ts");
|
|
421
421
|
|
|
422
422
|
|
|
423
423
|
/**
|
|
@@ -614,6 +614,207 @@ const findAsync = async (array, predicate) => {
|
|
|
614
614
|
};
|
|
615
615
|
|
|
616
616
|
|
|
617
|
+
/***/ }),
|
|
618
|
+
|
|
619
|
+
/***/ "./src/async/delay.ts":
|
|
620
|
+
/*!****************************!*\
|
|
621
|
+
!*** ./src/async/delay.ts ***!
|
|
622
|
+
\****************************/
|
|
623
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
624
|
+
|
|
625
|
+
__webpack_require__.r(__webpack_exports__);
|
|
626
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
627
|
+
/* harmony export */ delay: () => (/* binding */ delay)
|
|
628
|
+
/* harmony export */ });
|
|
629
|
+
/**
|
|
630
|
+
* Creates a promise that resolves after the specified delay.
|
|
631
|
+
*
|
|
632
|
+
* Useful for creating artificial delays, implementing timeouts, or spacing operations.
|
|
633
|
+
*
|
|
634
|
+
* @param delayMs - The delay in milliseconds.
|
|
635
|
+
*
|
|
636
|
+
* @returns A promise that resolves after the specified delay.
|
|
637
|
+
*
|
|
638
|
+
* @example
|
|
639
|
+
* ```ts
|
|
640
|
+
* // Wait for 1 second
|
|
641
|
+
* await delay(1000);
|
|
642
|
+
* console.log('This logs after 1 second');
|
|
643
|
+
*
|
|
644
|
+
* // Use with other async operations
|
|
645
|
+
* const fetchWithTimeout = async () => {
|
|
646
|
+
* const timeoutPromise = delay(5000).then(() => {
|
|
647
|
+
* throw new Error('Request timed out');
|
|
648
|
+
* });
|
|
649
|
+
*
|
|
650
|
+
* return Promise.race([fetchData(), timeoutPromise]);
|
|
651
|
+
* }
|
|
652
|
+
* ```
|
|
653
|
+
*/
|
|
654
|
+
const delay = (delayMs) => new Promise(resolve => setTimeout(resolve, delayMs));
|
|
655
|
+
|
|
656
|
+
|
|
657
|
+
/***/ }),
|
|
658
|
+
|
|
659
|
+
/***/ "./src/async/index.ts":
|
|
660
|
+
/*!****************************!*\
|
|
661
|
+
!*** ./src/async/index.ts ***!
|
|
662
|
+
\****************************/
|
|
663
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
664
|
+
|
|
665
|
+
__webpack_require__.r(__webpack_exports__);
|
|
666
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
667
|
+
/* harmony export */ delay: () => (/* reexport safe */ _delay__WEBPACK_IMPORTED_MODULE_1__.delay),
|
|
668
|
+
/* harmony export */ everyAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.everyAsync),
|
|
669
|
+
/* harmony export */ filterParallel: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.filterParallel),
|
|
670
|
+
/* harmony export */ filterSequential: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.filterSequential),
|
|
671
|
+
/* harmony export */ findAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.findAsync),
|
|
672
|
+
/* harmony export */ isPromise: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.isPromise),
|
|
673
|
+
/* harmony export */ reduceAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.reduceAsync),
|
|
674
|
+
/* harmony export */ retry: () => (/* reexport safe */ _retry__WEBPACK_IMPORTED_MODULE_3__.retry),
|
|
675
|
+
/* harmony export */ runParallel: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.runParallel),
|
|
676
|
+
/* harmony export */ runSequential: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.runSequential),
|
|
677
|
+
/* harmony export */ someAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.someAsync),
|
|
678
|
+
/* harmony export */ timeout: () => (/* reexport safe */ _timeout__WEBPACK_IMPORTED_MODULE_2__.timeout)
|
|
679
|
+
/* harmony export */ });
|
|
680
|
+
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./async */ "./src/async/async.ts");
|
|
681
|
+
/* harmony import */ var _delay__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./delay */ "./src/async/delay.ts");
|
|
682
|
+
/* harmony import */ var _timeout__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeout */ "./src/async/timeout.ts");
|
|
683
|
+
/* harmony import */ var _retry__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./retry */ "./src/async/retry.ts");
|
|
684
|
+
|
|
685
|
+
|
|
686
|
+
|
|
687
|
+
|
|
688
|
+
|
|
689
|
+
|
|
690
|
+
/***/ }),
|
|
691
|
+
|
|
692
|
+
/***/ "./src/async/retry.ts":
|
|
693
|
+
/*!****************************!*\
|
|
694
|
+
!*** ./src/async/retry.ts ***!
|
|
695
|
+
\****************************/
|
|
696
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
697
|
+
|
|
698
|
+
__webpack_require__.r(__webpack_exports__);
|
|
699
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
700
|
+
/* harmony export */ retry: () => (/* binding */ retry)
|
|
701
|
+
/* harmony export */ });
|
|
702
|
+
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/async */ "./src/async/index.ts");
|
|
703
|
+
|
|
704
|
+
/**
|
|
705
|
+
* Wraps an asynchronous function with retry logic.
|
|
706
|
+
*
|
|
707
|
+
* The returned function will attempt to call the original function up to `maxAttempts` times,
|
|
708
|
+
* with a delay between retries. If all attempts fail, the last encountered error is thrown.
|
|
709
|
+
*
|
|
710
|
+
* Useful for operations that may fail intermittently, such as network requests.
|
|
711
|
+
*
|
|
712
|
+
* @template Task - The type of the async function to wrap.
|
|
713
|
+
* @template TaskResult - The result type of the async function.
|
|
714
|
+
*
|
|
715
|
+
* @param task - The async function to wrap with retry logic.
|
|
716
|
+
* @param options - Configuration options for retry behavior.
|
|
717
|
+
*
|
|
718
|
+
* @returns A function that wraps the original function with retry support.
|
|
719
|
+
*
|
|
720
|
+
* @example
|
|
721
|
+
* ```ts
|
|
722
|
+
* async function fetchData() {
|
|
723
|
+
* const response = await fetch('/api/data');
|
|
724
|
+
*
|
|
725
|
+
* if (!response.ok) {
|
|
726
|
+
* throw new Error('Network error');
|
|
727
|
+
* }
|
|
728
|
+
*
|
|
729
|
+
* return await response.json();
|
|
730
|
+
* }
|
|
731
|
+
*
|
|
732
|
+
* const fetchWithRetry = retry(fetchData, {
|
|
733
|
+
* maxAttempts: 5,
|
|
734
|
+
* delayMs: 500,
|
|
735
|
+
* onRetry: (attempt, error) => {
|
|
736
|
+
* console.warn(`Attempt ${attempt} failed:`, error);
|
|
737
|
+
* }
|
|
738
|
+
* });
|
|
739
|
+
*
|
|
740
|
+
* fetchWithRetry()
|
|
741
|
+
* .then(data => console.log('Success:', data))
|
|
742
|
+
* .catch(error => console.error('Failed after retries:', error));
|
|
743
|
+
* ```
|
|
744
|
+
*/
|
|
745
|
+
const retry = (task, { maxAttempts = 3, delayMs = 300, backoff = true, onRetry } = {}) => {
|
|
746
|
+
return async (...args) => {
|
|
747
|
+
let lastError;
|
|
748
|
+
for (let attempt = 1; attempt <= maxAttempts; attempt++) {
|
|
749
|
+
try {
|
|
750
|
+
return await task(...args);
|
|
751
|
+
}
|
|
752
|
+
catch (e) {
|
|
753
|
+
lastError = e;
|
|
754
|
+
if (attempt < maxAttempts) {
|
|
755
|
+
onRetry?.(attempt, e);
|
|
756
|
+
const delayTime = backoff ? delayMs * 2 ** (attempt - 1) : delayMs;
|
|
757
|
+
await (0,_async__WEBPACK_IMPORTED_MODULE_0__.delay)(delayTime);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
throw lastError;
|
|
762
|
+
};
|
|
763
|
+
};
|
|
764
|
+
|
|
765
|
+
|
|
766
|
+
/***/ }),
|
|
767
|
+
|
|
768
|
+
/***/ "./src/async/timeout.ts":
|
|
769
|
+
/*!******************************!*\
|
|
770
|
+
!*** ./src/async/timeout.ts ***!
|
|
771
|
+
\******************************/
|
|
772
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
773
|
+
|
|
774
|
+
__webpack_require__.r(__webpack_exports__);
|
|
775
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
776
|
+
/* harmony export */ timeout: () => (/* binding */ timeout)
|
|
777
|
+
/* harmony export */ });
|
|
778
|
+
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/async */ "./src/async/index.ts");
|
|
779
|
+
|
|
780
|
+
/**
|
|
781
|
+
* Wraps a promise with a timeout. If the promise does not settle within the specified time,
|
|
782
|
+
* it will reject with a timeout error.
|
|
783
|
+
*
|
|
784
|
+
* @template T - The type of the promise result.
|
|
785
|
+
*
|
|
786
|
+
* @param promise - The promise to wrap.
|
|
787
|
+
* @param timeoutMs - Timeout duration in milliseconds.
|
|
788
|
+
* @param errorMessage - Optional custom error message.
|
|
789
|
+
*
|
|
790
|
+
* @returns A promise that resolves or rejects with the original promise,
|
|
791
|
+
* or rejects with a timeout error if the duration is exceeded.
|
|
792
|
+
*
|
|
793
|
+
* @example
|
|
794
|
+
* ```ts
|
|
795
|
+
* // Rejects if fetch takes longer than 3 seconds
|
|
796
|
+
* const response = await timeout(fetch('/api/data'), 3000);
|
|
797
|
+
*
|
|
798
|
+
* // With custom message
|
|
799
|
+
* await timeout(fetchData(), 2000, 'Too long');
|
|
800
|
+
* ```
|
|
801
|
+
*/
|
|
802
|
+
const timeout = async (promise, timeoutMs, errorMessage = 'Operation timed out') => {
|
|
803
|
+
const timeoutId = null;
|
|
804
|
+
try {
|
|
805
|
+
return await Promise.race([
|
|
806
|
+
promise,
|
|
807
|
+
(0,_async__WEBPACK_IMPORTED_MODULE_0__.delay)(timeoutMs).then(() => Promise.reject(new Error(errorMessage))),
|
|
808
|
+
]);
|
|
809
|
+
}
|
|
810
|
+
finally {
|
|
811
|
+
if (timeoutId) {
|
|
812
|
+
clearTimeout(timeoutId);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
|
|
817
|
+
|
|
617
818
|
/***/ }),
|
|
618
819
|
|
|
619
820
|
/***/ "./src/dom/dom.ts":
|
|
@@ -685,8 +886,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
685
886
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
686
887
|
/* harmony export */ downloadFile: () => (/* binding */ downloadFile)
|
|
687
888
|
/* harmony export */ });
|
|
688
|
-
/* harmony import */ var _string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*!
|
|
689
|
-
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*!
|
|
889
|
+
/* harmony import */ var _string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/string */ "./src/string/index.ts");
|
|
890
|
+
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/guards */ "./src/guards.ts");
|
|
690
891
|
|
|
691
892
|
|
|
692
893
|
/**
|
|
@@ -801,8 +1002,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
801
1002
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
802
1003
|
/* harmony export */ centerElementInContainer: () => (/* binding */ centerElementInContainer)
|
|
803
1004
|
/* harmony export */ });
|
|
804
|
-
/* harmony import */ var
|
|
805
|
-
/* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*!
|
|
1005
|
+
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/dom */ "./src/dom/index.ts");
|
|
1006
|
+
/* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ~/geometry */ "./src/geometry/index.ts");
|
|
806
1007
|
|
|
807
1008
|
|
|
808
1009
|
/**
|
|
@@ -829,7 +1030,7 @@ const centerElementInContainer = (containerElement, elementToCenter, { axis = 'b
|
|
|
829
1030
|
let translateY = 0;
|
|
830
1031
|
if (axis === 'x' || axis === 'both') {
|
|
831
1032
|
translateX = (0,_geometry__WEBPACK_IMPORTED_MODULE_1__.calculateCenterOffset)({
|
|
832
|
-
overflowSize: (0,
|
|
1033
|
+
overflowSize: (0,_dom__WEBPACK_IMPORTED_MODULE_0__.getXOverflowWidth)(containerElement),
|
|
833
1034
|
containerSize: containerElement.clientWidth,
|
|
834
1035
|
elementOffset: elementToCenter.offsetLeft,
|
|
835
1036
|
elementSize: elementToCenter.clientWidth,
|
|
@@ -837,7 +1038,7 @@ const centerElementInContainer = (containerElement, elementToCenter, { axis = 'b
|
|
|
837
1038
|
}
|
|
838
1039
|
if (axis === 'y' || axis === 'both') {
|
|
839
1040
|
translateY = (0,_geometry__WEBPACK_IMPORTED_MODULE_1__.calculateCenterOffset)({
|
|
840
|
-
overflowSize: (0,
|
|
1041
|
+
overflowSize: (0,_dom__WEBPACK_IMPORTED_MODULE_0__.getYOverflowHeight)(containerElement),
|
|
841
1042
|
containerSize: containerElement.clientHeight,
|
|
842
1043
|
elementOffset: elementToCenter.offsetTop,
|
|
843
1044
|
elementSize: elementToCenter.clientHeight,
|
|
@@ -1123,11 +1324,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1123
1324
|
/* harmony export */ blobToFile: () => (/* binding */ blobToFile),
|
|
1124
1325
|
/* harmony export */ fileListToFiles: () => (/* binding */ fileListToFiles),
|
|
1125
1326
|
/* harmony export */ isFile: () => (/* binding */ isFile),
|
|
1126
|
-
/* harmony export */ parseFileName: () => (/* binding */ parseFileName),
|
|
1127
1327
|
/* harmony export */ readFilesFromDataTransfer: () => (/* binding */ readFilesFromDataTransfer),
|
|
1128
1328
|
/* harmony export */ traverseFileSystemDirectory: () => (/* binding */ traverseFileSystemDirectory)
|
|
1129
1329
|
/* harmony export */ });
|
|
1130
|
-
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*!
|
|
1330
|
+
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/async */ "./src/async/index.ts");
|
|
1131
1331
|
|
|
1132
1332
|
/**
|
|
1133
1333
|
* Checks if a value is a `File` object.
|
|
@@ -1137,29 +1337,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1137
1337
|
* @returns `true` if the value is a `File` object; otherwise, `false`.
|
|
1138
1338
|
*/
|
|
1139
1339
|
const isFile = (value) => value instanceof File;
|
|
1140
|
-
/**
|
|
1141
|
-
* Splits a file name into its base name and extension.
|
|
1142
|
-
*
|
|
1143
|
-
* Special cases:
|
|
1144
|
-
* - Files without a dot return `[fileName, ""]`
|
|
1145
|
-
* - Hidden files like `.gitignore` return `[".gitignore", ""]`
|
|
1146
|
-
* - Names ending with a trailing dot (e.g., `"file."`) return `["file.", ""]`
|
|
1147
|
-
* - Multi-dot names (e.g., `"archive.tar.gz"`) split on the last dot
|
|
1148
|
-
*
|
|
1149
|
-
* @param fileName - The full file name to parse.
|
|
1150
|
-
*
|
|
1151
|
-
* @returns A tuple where:
|
|
1152
|
-
* - index 0 is the base name
|
|
1153
|
-
* - index 1 is the file extension (lowercased), or an empty string if none exists
|
|
1154
|
-
*/
|
|
1155
|
-
const parseFileName = (fileName) => {
|
|
1156
|
-
const lastDotIndex = fileName.lastIndexOf('.');
|
|
1157
|
-
// No dot or leading dot with no extension (e.g., ".gitignore")
|
|
1158
|
-
if (lastDotIndex <= 0 || lastDotIndex === fileName.length - 1) {
|
|
1159
|
-
return [fileName, ''];
|
|
1160
|
-
}
|
|
1161
|
-
return [fileName.slice(0, lastDotIndex), fileName.slice(lastDotIndex + 1).toLowerCase()];
|
|
1162
|
-
};
|
|
1163
1340
|
/**
|
|
1164
1341
|
* Converts a `FileList` object to an array of `File` objects.
|
|
1165
1342
|
*
|
|
@@ -1318,22 +1495,18 @@ const readFilesFromDataTransfer = async (dataTransfer, traverseOptions = {}) =>
|
|
|
1318
1495
|
|
|
1319
1496
|
/***/ }),
|
|
1320
1497
|
|
|
1321
|
-
/***/ "./src/function.ts":
|
|
1322
|
-
|
|
1323
|
-
!*** ./src/function.ts ***!
|
|
1324
|
-
|
|
1498
|
+
/***/ "./src/function/function.ts":
|
|
1499
|
+
/*!**********************************!*\
|
|
1500
|
+
!*** ./src/function/function.ts ***!
|
|
1501
|
+
\**********************************/
|
|
1325
1502
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1326
1503
|
|
|
1327
1504
|
__webpack_require__.r(__webpack_exports__);
|
|
1328
1505
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1329
|
-
/* harmony export */ delay: () => (/* binding */ delay),
|
|
1330
|
-
/* harmony export */ invokeIfFunction: () => (/* binding */ invokeIfFunction),
|
|
1331
1506
|
/* harmony export */ isFunction: () => (/* binding */ isFunction),
|
|
1332
1507
|
/* harmony export */ noop: () => (/* binding */ noop),
|
|
1333
1508
|
/* harmony export */ not: () => (/* binding */ not),
|
|
1334
|
-
/* harmony export */ once: () => (/* binding */ once)
|
|
1335
|
-
/* harmony export */ retry: () => (/* binding */ retry),
|
|
1336
|
-
/* harmony export */ timeout: () => (/* binding */ timeout)
|
|
1509
|
+
/* harmony export */ once: () => (/* binding */ once)
|
|
1337
1510
|
/* harmony export */ });
|
|
1338
1511
|
const noop = () => { };
|
|
1339
1512
|
/**
|
|
@@ -1363,6 +1536,71 @@ const isFunction = (value) => typeof value === 'function';
|
|
|
1363
1536
|
* ```
|
|
1364
1537
|
*/
|
|
1365
1538
|
const not = (fn) => (...args) => !fn(...args);
|
|
1539
|
+
/**
|
|
1540
|
+
* Wraps a function so that it can only be executed once.
|
|
1541
|
+
* The wrapped function remembers (caches) the result of the first invocation
|
|
1542
|
+
* and returns that same result for all subsequent calls, regardless of the arguments provided.
|
|
1543
|
+
*
|
|
1544
|
+
* Common use cases include:
|
|
1545
|
+
* - initializing singletons
|
|
1546
|
+
* - running setup logic only once
|
|
1547
|
+
* - avoiding repeated expensive computations
|
|
1548
|
+
*
|
|
1549
|
+
* @template T - A function type whose return value should be cached.
|
|
1550
|
+
*
|
|
1551
|
+
* @param fn - The function to execute at most once.
|
|
1552
|
+
*
|
|
1553
|
+
* @returns A new function with the same signature as `fn`, but guaranteed to
|
|
1554
|
+
* execute `fn` only on the first call and return the cached result
|
|
1555
|
+
* thereafter.
|
|
1556
|
+
*/
|
|
1557
|
+
const once = (fn) => {
|
|
1558
|
+
let called = false;
|
|
1559
|
+
let result;
|
|
1560
|
+
return function (...args) {
|
|
1561
|
+
if (!called) {
|
|
1562
|
+
called = true;
|
|
1563
|
+
result = fn.apply(this, args);
|
|
1564
|
+
}
|
|
1565
|
+
return result;
|
|
1566
|
+
};
|
|
1567
|
+
};
|
|
1568
|
+
|
|
1569
|
+
|
|
1570
|
+
/***/ }),
|
|
1571
|
+
|
|
1572
|
+
/***/ "./src/function/index.ts":
|
|
1573
|
+
/*!*******************************!*\
|
|
1574
|
+
!*** ./src/function/index.ts ***!
|
|
1575
|
+
\*******************************/
|
|
1576
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1577
|
+
|
|
1578
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1579
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1580
|
+
/* harmony export */ invokeIfFunction: () => (/* reexport safe */ _invoke_if_function__WEBPACK_IMPORTED_MODULE_1__.invokeIfFunction),
|
|
1581
|
+
/* harmony export */ isFunction: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_0__.isFunction),
|
|
1582
|
+
/* harmony export */ noop: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_0__.noop),
|
|
1583
|
+
/* harmony export */ not: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_0__.not),
|
|
1584
|
+
/* harmony export */ once: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_0__.once)
|
|
1585
|
+
/* harmony export */ });
|
|
1586
|
+
/* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./function */ "./src/function/function.ts");
|
|
1587
|
+
/* harmony import */ var _invoke_if_function__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./invoke-if-function */ "./src/function/invoke-if-function.ts");
|
|
1588
|
+
|
|
1589
|
+
|
|
1590
|
+
|
|
1591
|
+
|
|
1592
|
+
/***/ }),
|
|
1593
|
+
|
|
1594
|
+
/***/ "./src/function/invoke-if-function.ts":
|
|
1595
|
+
/*!********************************************!*\
|
|
1596
|
+
!*** ./src/function/invoke-if-function.ts ***!
|
|
1597
|
+
\********************************************/
|
|
1598
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1599
|
+
|
|
1600
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1601
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1602
|
+
/* harmony export */ invokeIfFunction: () => (/* binding */ invokeIfFunction)
|
|
1603
|
+
/* harmony export */ });
|
|
1366
1604
|
/**
|
|
1367
1605
|
* Invokes the given input if it is a function, passing the provided arguments.
|
|
1368
1606
|
* Otherwise, returns the input as-is.
|
|
@@ -1376,155 +1614,108 @@ const not = (fn) => (...args) => !fn(...args);
|
|
|
1376
1614
|
* @returns The result of invoking the function, or the original value if it's not a function.
|
|
1377
1615
|
*/
|
|
1378
1616
|
const invokeIfFunction = (input, ...args) => (typeof input === 'function' ? input(...args) : input);
|
|
1617
|
+
|
|
1618
|
+
|
|
1619
|
+
/***/ }),
|
|
1620
|
+
|
|
1621
|
+
/***/ "./src/geometry/apply-inertia-step.ts":
|
|
1622
|
+
/*!********************************************!*\
|
|
1623
|
+
!*** ./src/geometry/apply-inertia-step.ts ***!
|
|
1624
|
+
\********************************************/
|
|
1625
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1626
|
+
|
|
1627
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1628
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1629
|
+
/* harmony export */ applyInertiaStep: () => (/* binding */ applyInertiaStep)
|
|
1630
|
+
/* harmony export */ });
|
|
1631
|
+
/* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/geometry */ "./src/geometry/index.ts");
|
|
1632
|
+
|
|
1379
1633
|
/**
|
|
1380
|
-
*
|
|
1381
|
-
*
|
|
1382
|
-
* Useful for creating artificial delays, implementing timeouts, or spacing operations.
|
|
1383
|
-
*
|
|
1384
|
-
* @param delayMs - The delay in milliseconds.
|
|
1385
|
-
*
|
|
1386
|
-
* @returns A promise that resolves after the specified delay.
|
|
1387
|
-
*
|
|
1388
|
-
* @example
|
|
1389
|
-
* ```ts
|
|
1390
|
-
* // Wait for 1 second
|
|
1391
|
-
* await delay(1000);
|
|
1392
|
-
* console.log('This logs after 1 second');
|
|
1393
|
-
*
|
|
1394
|
-
* // Use with other async operations
|
|
1395
|
-
* const fetchWithTimeout = async () => {
|
|
1396
|
-
* const timeoutPromise = delay(5000).then(() => {
|
|
1397
|
-
* throw new Error('Request timed out');
|
|
1398
|
-
* });
|
|
1399
|
-
*
|
|
1400
|
-
* return Promise.race([fetchData(), timeoutPromise]);
|
|
1401
|
-
* }
|
|
1402
|
-
* ```
|
|
1403
|
-
*/
|
|
1404
|
-
const delay = (delayMs) => new Promise(resolve => setTimeout(resolve, delayMs));
|
|
1405
|
-
/**
|
|
1406
|
-
* Wraps a promise with a timeout. If the promise does not settle within the specified time,
|
|
1407
|
-
* it will reject with a timeout error.
|
|
1408
|
-
*
|
|
1409
|
-
* @template T - The type of the promise result.
|
|
1410
|
-
*
|
|
1411
|
-
* @param promise - The promise to wrap.
|
|
1412
|
-
* @param timeoutMs - Timeout duration in milliseconds.
|
|
1413
|
-
* @param errorMessage - Optional custom error message.
|
|
1634
|
+
* Advances a value by one inertia step using velocity, friction, and hard bounds.
|
|
1414
1635
|
*
|
|
1415
|
-
*
|
|
1416
|
-
*
|
|
1417
|
-
*
|
|
1418
|
-
* @example
|
|
1419
|
-
* ```ts
|
|
1420
|
-
* // Rejects if fetch takes longer than 3 seconds
|
|
1421
|
-
* const response = await timeout(fetch('/api/data'), 3000);
|
|
1422
|
-
*
|
|
1423
|
-
* // With custom message
|
|
1424
|
-
* await timeout(fetchData(), 2000, 'Too long');
|
|
1425
|
-
* ```
|
|
1426
|
-
*/
|
|
1427
|
-
const timeout = async (promise, timeoutMs, errorMessage = 'Operation timed out') => {
|
|
1428
|
-
const timeoutId = null;
|
|
1429
|
-
try {
|
|
1430
|
-
return await Promise.race([
|
|
1431
|
-
promise,
|
|
1432
|
-
delay(timeoutMs).then(() => Promise.reject(new Error(errorMessage))),
|
|
1433
|
-
]);
|
|
1434
|
-
}
|
|
1435
|
-
finally {
|
|
1436
|
-
if (timeoutId) {
|
|
1437
|
-
clearTimeout(timeoutId);
|
|
1438
|
-
}
|
|
1439
|
-
}
|
|
1440
|
-
};
|
|
1441
|
-
/**
|
|
1442
|
-
* Wraps an asynchronous function with retry logic.
|
|
1636
|
+
* This utility models **inertial motion** (momentum + decay) on top of
|
|
1637
|
+
* {@link resolveBoundedDelta}, which acts as the authoritative constraint layer.
|
|
1443
1638
|
*
|
|
1444
|
-
* The
|
|
1445
|
-
*
|
|
1639
|
+
* The function:
|
|
1640
|
+
* - Integrates velocity over the elapsed time to produce a movement delta
|
|
1641
|
+
* - Resolves that delta against fixed bounds
|
|
1642
|
+
* - Applies exponential friction to gradually reduce velocity
|
|
1643
|
+
* - Stops immediately when a bound is hit or velocity falls below a threshold
|
|
1446
1644
|
*
|
|
1447
|
-
*
|
|
1645
|
+
* ⚠️ This function performs **one step only** and is intended to be called
|
|
1646
|
+
* repeatedly from an animation loop (e.g. `requestAnimationFrame`).
|
|
1448
1647
|
*
|
|
1449
|
-
*
|
|
1450
|
-
*
|
|
1648
|
+
* ### Common use cases
|
|
1649
|
+
* - Synthetic scrolling with momentum
|
|
1650
|
+
* - Carousels and sliders
|
|
1651
|
+
* - Timelines and scrubbers
|
|
1652
|
+
* - Drag-to-scroll interactions with inertia
|
|
1451
1653
|
*
|
|
1452
|
-
* @param
|
|
1453
|
-
* @param
|
|
1654
|
+
* @param value - Current value before applying inertia (e.g. translate position).
|
|
1655
|
+
* @param min - Minimum allowed value (inclusive).
|
|
1656
|
+
* @param max - Maximum allowed value (inclusive).
|
|
1657
|
+
* @param velocity - Current velocity in units per millisecond (e.g. px/ms).
|
|
1658
|
+
* @param deltaTime - Time elapsed since the previous step, in milliseconds.
|
|
1659
|
+
* @param friction - Exponential friction coefficient controlling decay rate.
|
|
1660
|
+
* @param minVelocity - Minimum velocity below which inertia stops.
|
|
1454
1661
|
*
|
|
1455
|
-
* @returns
|
|
1662
|
+
* @returns An object containing the updated value and velocity,
|
|
1663
|
+
* or `null` when inertia has completed or movement is no longer possible.
|
|
1456
1664
|
*
|
|
1457
1665
|
* @example
|
|
1458
1666
|
* ```ts
|
|
1459
|
-
*
|
|
1460
|
-
*
|
|
1667
|
+
* let value = translateX;
|
|
1668
|
+
* let velocity = releaseVelocity; // px/ms from drag end
|
|
1669
|
+
* let lastTime = performance.now();
|
|
1670
|
+
*
|
|
1671
|
+
* const step = (time: number) => {
|
|
1672
|
+
* const deltaTime = time - lastTime;
|
|
1673
|
+
* lastTime = time;
|
|
1674
|
+
*
|
|
1675
|
+
* const result = applyInertiaStep({
|
|
1676
|
+
* value,
|
|
1677
|
+
* velocity,
|
|
1678
|
+
* min: -maxOverflow,
|
|
1679
|
+
* max: 0,
|
|
1680
|
+
* deltaTime,
|
|
1681
|
+
* });
|
|
1461
1682
|
*
|
|
1462
|
-
* if (!
|
|
1463
|
-
*
|
|
1683
|
+
* if (!result) {
|
|
1684
|
+
* return; // inertia finished
|
|
1464
1685
|
* }
|
|
1465
1686
|
*
|
|
1466
|
-
*
|
|
1467
|
-
*
|
|
1687
|
+
* value = result.value;
|
|
1688
|
+
* velocity = result.velocity;
|
|
1468
1689
|
*
|
|
1469
|
-
*
|
|
1470
|
-
*
|
|
1471
|
-
*
|
|
1472
|
-
* onRetry: (attempt, error) => {
|
|
1473
|
-
* console.warn(`Attempt ${attempt} failed:`, error);
|
|
1474
|
-
* }
|
|
1475
|
-
* });
|
|
1690
|
+
* container.style.transform = `translateX(${value}px)`;
|
|
1691
|
+
* requestAnimationFrame(step);
|
|
1692
|
+
* };
|
|
1476
1693
|
*
|
|
1477
|
-
*
|
|
1478
|
-
* .then(data => console.log('Success:', data))
|
|
1479
|
-
* .catch(error => console.error('Failed after retries:', error));
|
|
1694
|
+
* requestAnimationFrame(step);
|
|
1480
1695
|
* ```
|
|
1481
1696
|
*/
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
* and returns that same result for all subsequent calls, regardless of the arguments provided.
|
|
1505
|
-
*
|
|
1506
|
-
* Common use cases include:
|
|
1507
|
-
* - initializing singletons
|
|
1508
|
-
* - running setup logic only once
|
|
1509
|
-
* - avoiding repeated expensive computations
|
|
1510
|
-
*
|
|
1511
|
-
* @template T - A function type whose return value should be cached.
|
|
1512
|
-
*
|
|
1513
|
-
* @param fn - The function to execute at most once.
|
|
1514
|
-
*
|
|
1515
|
-
* @returns A new function with the same signature as `fn`, but guaranteed to
|
|
1516
|
-
* execute `fn` only on the first call and return the cached result
|
|
1517
|
-
* thereafter.
|
|
1518
|
-
*/
|
|
1519
|
-
const once = (fn) => {
|
|
1520
|
-
let called = false;
|
|
1521
|
-
let result;
|
|
1522
|
-
return function (...args) {
|
|
1523
|
-
if (!called) {
|
|
1524
|
-
called = true;
|
|
1525
|
-
result = fn.apply(this, args);
|
|
1526
|
-
}
|
|
1527
|
-
return result;
|
|
1697
|
+
const applyInertiaStep = ({ value, min, max, velocity, deltaTime, friction = 0.002, minVelocity = 0.01, }) => {
|
|
1698
|
+
if (Math.abs(velocity) < minVelocity) {
|
|
1699
|
+
return null;
|
|
1700
|
+
}
|
|
1701
|
+
// Distance we want to move this frame
|
|
1702
|
+
const delta = velocity * deltaTime;
|
|
1703
|
+
const nextValue = (0,_geometry__WEBPACK_IMPORTED_MODULE_0__.resolveBoundedDelta)({
|
|
1704
|
+
delta,
|
|
1705
|
+
value,
|
|
1706
|
+
min,
|
|
1707
|
+
max,
|
|
1708
|
+
});
|
|
1709
|
+
// Hit a hard bound → stop inertia immediately
|
|
1710
|
+
if (nextValue === null) {
|
|
1711
|
+
return null;
|
|
1712
|
+
}
|
|
1713
|
+
// Apply exponential friction
|
|
1714
|
+
const decay = Math.exp(-friction * deltaTime);
|
|
1715
|
+
const nextVelocity = velocity * decay;
|
|
1716
|
+
return {
|
|
1717
|
+
value: nextValue,
|
|
1718
|
+
velocity: nextVelocity,
|
|
1528
1719
|
};
|
|
1529
1720
|
};
|
|
1530
1721
|
|
|
@@ -1539,9 +1730,15 @@ const once = (fn) => {
|
|
|
1539
1730
|
|
|
1540
1731
|
__webpack_require__.r(__webpack_exports__);
|
|
1541
1732
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1542
|
-
/* harmony export */
|
|
1733
|
+
/* harmony export */ applyInertiaStep: () => (/* reexport safe */ _apply_inertia_step__WEBPACK_IMPORTED_MODULE_2__.applyInertiaStep),
|
|
1734
|
+
/* harmony export */ calculateCenterOffset: () => (/* reexport safe */ _layout__WEBPACK_IMPORTED_MODULE_0__.calculateCenterOffset),
|
|
1735
|
+
/* harmony export */ resolveBoundedDelta: () => (/* reexport safe */ _resolve_bounded_delta__WEBPACK_IMPORTED_MODULE_1__.resolveBoundedDelta)
|
|
1543
1736
|
/* harmony export */ });
|
|
1544
1737
|
/* harmony import */ var _layout__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./layout */ "./src/geometry/layout/index.ts");
|
|
1738
|
+
/* harmony import */ var _resolve_bounded_delta__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./resolve-bounded-delta */ "./src/geometry/resolve-bounded-delta.ts");
|
|
1739
|
+
/* harmony import */ var _apply_inertia_step__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./apply-inertia-step */ "./src/geometry/apply-inertia-step.ts");
|
|
1740
|
+
|
|
1741
|
+
|
|
1545
1742
|
|
|
1546
1743
|
|
|
1547
1744
|
|
|
@@ -1595,6 +1792,83 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
1595
1792
|
|
|
1596
1793
|
|
|
1597
1794
|
|
|
1795
|
+
/***/ }),
|
|
1796
|
+
|
|
1797
|
+
/***/ "./src/geometry/resolve-bounded-delta.ts":
|
|
1798
|
+
/*!***********************************************!*\
|
|
1799
|
+
!*** ./src/geometry/resolve-bounded-delta.ts ***!
|
|
1800
|
+
\***********************************************/
|
|
1801
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1802
|
+
|
|
1803
|
+
__webpack_require__.r(__webpack_exports__);
|
|
1804
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
1805
|
+
/* harmony export */ resolveBoundedDelta: () => (/* binding */ resolveBoundedDelta)
|
|
1806
|
+
/* harmony export */ });
|
|
1807
|
+
/**
|
|
1808
|
+
* Resolves the next value by consuming a delta within fixed numeric bounds.
|
|
1809
|
+
*
|
|
1810
|
+
* This function applies **bounded delta consumption** rather than naive clamping:
|
|
1811
|
+
*
|
|
1812
|
+
* - The delta is applied in the given direction as long as movement is possible.
|
|
1813
|
+
* - If the delta would overshoot a bound, it is partially consumed so the
|
|
1814
|
+
* resulting value lands exactly on the boundary.
|
|
1815
|
+
* - If movement in the given direction is no longer possible, `null` is returned.
|
|
1816
|
+
*
|
|
1817
|
+
* This behavior mirrors how native scroll engines and drag constraints
|
|
1818
|
+
* handle fast input without jitter or overshoot.
|
|
1819
|
+
*
|
|
1820
|
+
* ### Key characteristics
|
|
1821
|
+
* - Direction-aware (positive and negative deltas behave independently)
|
|
1822
|
+
* - Prevents overshoot while preserving remaining movement
|
|
1823
|
+
* - Does **not** clamp unconditionally
|
|
1824
|
+
* - Side-effect free and fully deterministic
|
|
1825
|
+
*
|
|
1826
|
+
* ### Common use cases
|
|
1827
|
+
* - Synthetic scrolling
|
|
1828
|
+
* - Drag constraints
|
|
1829
|
+
* - Sliders and carousels
|
|
1830
|
+
* - Timelines and scrubbers
|
|
1831
|
+
* - Inertia and momentum systems
|
|
1832
|
+
*
|
|
1833
|
+
* @param delta - Incremental change to apply to the current value.
|
|
1834
|
+
* The sign determines the movement direction.
|
|
1835
|
+
* @param value - Current numeric value before applying the delta.
|
|
1836
|
+
* @param min - Minimum allowed value (inclusive).
|
|
1837
|
+
* @param max - Maximum allowed value (inclusive).
|
|
1838
|
+
*
|
|
1839
|
+
* @returns The next resolved value after applying the delta,
|
|
1840
|
+
* or `null` if movement in the given direction is not possible.
|
|
1841
|
+
*
|
|
1842
|
+
* @example
|
|
1843
|
+
* ```ts
|
|
1844
|
+
* // Simple bounded movement
|
|
1845
|
+
* resolveBoundedDelta({ value: 10, delta: -5, min: 0, max: 100 });
|
|
1846
|
+
* // → 5
|
|
1847
|
+
*
|
|
1848
|
+
* // Overshoot is clamped to the boundary
|
|
1849
|
+
* resolveBoundedDelta({ value: 2, delta: -10, min: 0, max: 100 });
|
|
1850
|
+
* // → 0
|
|
1851
|
+
*
|
|
1852
|
+
* // Movement blocked at the boundary
|
|
1853
|
+
* resolveBoundedDelta({ value: 0, delta: -5, min: 0, max: 100 });
|
|
1854
|
+
* // → null
|
|
1855
|
+
* ```
|
|
1856
|
+
*/
|
|
1857
|
+
const resolveBoundedDelta = ({ delta, value, min, max, }) => {
|
|
1858
|
+
if (delta === 0) {
|
|
1859
|
+
return null;
|
|
1860
|
+
}
|
|
1861
|
+
const candidate = value + delta;
|
|
1862
|
+
if (delta < 0) {
|
|
1863
|
+
return value <= min ? null : Math.max(candidate, min);
|
|
1864
|
+
}
|
|
1865
|
+
if (delta > 0) {
|
|
1866
|
+
return value >= max ? null : Math.min(candidate, max);
|
|
1867
|
+
}
|
|
1868
|
+
return null;
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
|
|
1598
1872
|
/***/ }),
|
|
1599
1873
|
|
|
1600
1874
|
/***/ "./src/guards.ts":
|
|
@@ -1953,10 +2227,76 @@ const resolveAxisDelta = (delta, axis, { allowFallback = true, invert = true } =
|
|
|
1953
2227
|
|
|
1954
2228
|
/***/ }),
|
|
1955
2229
|
|
|
1956
|
-
/***/ "./src/math.ts":
|
|
1957
|
-
|
|
1958
|
-
!*** ./src/math.ts ***!
|
|
1959
|
-
|
|
2230
|
+
/***/ "./src/math/hash-string.ts":
|
|
2231
|
+
/*!*********************************!*\
|
|
2232
|
+
!*** ./src/math/hash-string.ts ***!
|
|
2233
|
+
\*********************************/
|
|
2234
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2235
|
+
|
|
2236
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2237
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2238
|
+
/* harmony export */ hashString: () => (/* binding */ hashString)
|
|
2239
|
+
/* harmony export */ });
|
|
2240
|
+
/**
|
|
2241
|
+
* Generates a short, consistent hash string from an input string using a DJB2-inspired algorithm.
|
|
2242
|
+
*
|
|
2243
|
+
* This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm
|
|
2244
|
+
* based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,
|
|
2245
|
+
* which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.
|
|
2246
|
+
*
|
|
2247
|
+
* Useful for:
|
|
2248
|
+
* - Generating stable class names in CSS-in-JS libraries.
|
|
2249
|
+
* - Producing consistent cache keys.
|
|
2250
|
+
* - Quick and lightweight hashing needs where cryptographic security is not required.
|
|
2251
|
+
*
|
|
2252
|
+
* ⚠️ This is not cryptographically secure and should not be used for hashing passwords or sensitive data.
|
|
2253
|
+
*
|
|
2254
|
+
* @param input - The input string to hash.
|
|
2255
|
+
*
|
|
2256
|
+
* @returns A short, base-36 encoded hash string.
|
|
2257
|
+
*
|
|
2258
|
+
* @example
|
|
2259
|
+
* ```ts
|
|
2260
|
+
* const className = hashString('background-color: red;');
|
|
2261
|
+
* // → 'e4k1z0x'
|
|
2262
|
+
* ```
|
|
2263
|
+
*/
|
|
2264
|
+
const hashString = (input) => {
|
|
2265
|
+
let hash = 5381;
|
|
2266
|
+
for (let i = 0; i < input.length; i++) {
|
|
2267
|
+
hash = (hash * 33) ^ input.charCodeAt(i);
|
|
2268
|
+
}
|
|
2269
|
+
return (hash >>> 0).toString(36);
|
|
2270
|
+
};
|
|
2271
|
+
|
|
2272
|
+
|
|
2273
|
+
/***/ }),
|
|
2274
|
+
|
|
2275
|
+
/***/ "./src/math/index.ts":
|
|
2276
|
+
/*!***************************!*\
|
|
2277
|
+
!*** ./src/math/index.ts ***!
|
|
2278
|
+
\***************************/
|
|
2279
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2280
|
+
|
|
2281
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2282
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2283
|
+
/* harmony export */ calculateEuclideanDistance: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_0__.calculateEuclideanDistance),
|
|
2284
|
+
/* harmony export */ calculateMovingSpeed: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_0__.calculateMovingSpeed),
|
|
2285
|
+
/* harmony export */ calculatePercentage: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_0__.calculatePercentage),
|
|
2286
|
+
/* harmony export */ hashString: () => (/* reexport safe */ _hash_string__WEBPACK_IMPORTED_MODULE_1__.hashString)
|
|
2287
|
+
/* harmony export */ });
|
|
2288
|
+
/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math */ "./src/math/math.ts");
|
|
2289
|
+
/* harmony import */ var _hash_string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hash-string */ "./src/math/hash-string.ts");
|
|
2290
|
+
|
|
2291
|
+
|
|
2292
|
+
|
|
2293
|
+
|
|
2294
|
+
/***/ }),
|
|
2295
|
+
|
|
2296
|
+
/***/ "./src/math/math.ts":
|
|
2297
|
+
/*!**************************!*\
|
|
2298
|
+
!*** ./src/math/math.ts ***!
|
|
2299
|
+
\**************************/
|
|
1960
2300
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
1961
2301
|
|
|
1962
2302
|
__webpack_require__.r(__webpack_exports__);
|
|
@@ -2037,63 +2377,16 @@ const definedProps = (obj) => Object.entries(obj).reduce((result, [key, value])
|
|
|
2037
2377
|
|
|
2038
2378
|
/***/ }),
|
|
2039
2379
|
|
|
2040
|
-
/***/ "./src/string.ts":
|
|
2041
|
-
|
|
2042
|
-
!*** ./src/string.ts ***!
|
|
2043
|
-
|
|
2380
|
+
/***/ "./src/string/camel-to-dash-case.ts":
|
|
2381
|
+
/*!******************************************!*\
|
|
2382
|
+
!*** ./src/string/camel-to-dash-case.ts ***!
|
|
2383
|
+
\******************************************/
|
|
2044
2384
|
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2045
2385
|
|
|
2046
2386
|
__webpack_require__.r(__webpack_exports__);
|
|
2047
2387
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2048
|
-
/* harmony export */ camelToDashCase: () => (/* binding */ camelToDashCase)
|
|
2049
|
-
/* harmony export */ camelToWords: () => (/* binding */ camelToWords),
|
|
2050
|
-
/* harmony export */ hashString: () => (/* binding */ hashString),
|
|
2051
|
-
/* harmony export */ isNilOrEmptyString: () => (/* binding */ isNilOrEmptyString),
|
|
2052
|
-
/* harmony export */ isString: () => (/* binding */ isString),
|
|
2053
|
-
/* harmony export */ splitStringIntoWords: () => (/* binding */ splitStringIntoWords),
|
|
2054
|
-
/* harmony export */ toKebabCase: () => (/* binding */ toKebabCase)
|
|
2388
|
+
/* harmony export */ camelToDashCase: () => (/* binding */ camelToDashCase)
|
|
2055
2389
|
/* harmony export */ });
|
|
2056
|
-
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./guards */ "./src/guards.ts");
|
|
2057
|
-
|
|
2058
|
-
/**
|
|
2059
|
-
* Checks if a value is a string.
|
|
2060
|
-
*
|
|
2061
|
-
* @param value - The value to check.
|
|
2062
|
-
*
|
|
2063
|
-
* @returns `true` if the value is a string; otherwise, `false`.
|
|
2064
|
-
*/
|
|
2065
|
-
const isString = (value) => typeof value === 'string';
|
|
2066
|
-
/**
|
|
2067
|
-
* Checks whether the provided value is considered "empty".
|
|
2068
|
-
*
|
|
2069
|
-
* A value is considered empty if it is:
|
|
2070
|
-
* - `null`
|
|
2071
|
-
* - `undefined`
|
|
2072
|
-
* - `''`
|
|
2073
|
-
*
|
|
2074
|
-
* @param value - The value to check.
|
|
2075
|
-
*
|
|
2076
|
-
* @returns `true` if the value is empty; otherwise, `false`.
|
|
2077
|
-
*/
|
|
2078
|
-
const isNilOrEmptyString = (value) => value === '' || (0,_guards__WEBPACK_IMPORTED_MODULE_0__.isNil)(value);
|
|
2079
|
-
/**
|
|
2080
|
-
* Converts a string to kebab-case format.
|
|
2081
|
-
*
|
|
2082
|
-
* This function transforms camelCase or PascalCase strings into kebab-case by inserting
|
|
2083
|
-
* hyphens between lowercase and uppercase letters, then converting everything to lowercase.
|
|
2084
|
-
*
|
|
2085
|
-
* @param input - The string to convert to kebab-case.
|
|
2086
|
-
*
|
|
2087
|
-
* @returns The kebab-case formatted string.
|
|
2088
|
-
*
|
|
2089
|
-
* @example
|
|
2090
|
-
* ```ts
|
|
2091
|
-
* toKebabCase('helloWorld'); // → 'hello-world'
|
|
2092
|
-
* toKebabCase('HelloWorld'); // → 'hello-world'
|
|
2093
|
-
* toKebabCase('hello123World'); // → 'hello123-world'
|
|
2094
|
-
* ```
|
|
2095
|
-
*/
|
|
2096
|
-
const toKebabCase = (input) => input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2097
2390
|
/**
|
|
2098
2391
|
* Converts a camelCase string to dash-case format.
|
|
2099
2392
|
*
|
|
@@ -2117,12 +2410,26 @@ const camelToDashCase = (input) => {
|
|
|
2117
2410
|
// First handle the first character separately to avoid adding a hyphen at the start
|
|
2118
2411
|
const firstChar = input.charAt(0);
|
|
2119
2412
|
const restOfString = input.slice(1);
|
|
2120
|
-
// Convert the first character to lowercase without adding a hyphen
|
|
2413
|
+
// Convert the first character to the lowercase without adding a hyphen
|
|
2121
2414
|
const firstCharProcessed = firstChar.toLowerCase();
|
|
2122
2415
|
// Process the rest of the string normally, adding hyphens before uppercase letters
|
|
2123
2416
|
const restProcessed = restOfString.replace(/[A-Z]/g, letter => `-${letter.toLowerCase()}`);
|
|
2124
2417
|
return firstCharProcessed + restProcessed;
|
|
2125
2418
|
};
|
|
2419
|
+
|
|
2420
|
+
|
|
2421
|
+
/***/ }),
|
|
2422
|
+
|
|
2423
|
+
/***/ "./src/string/camel-to-words.ts":
|
|
2424
|
+
/*!**************************************!*\
|
|
2425
|
+
!*** ./src/string/camel-to-words.ts ***!
|
|
2426
|
+
\**************************************/
|
|
2427
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2428
|
+
|
|
2429
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2430
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2431
|
+
/* harmony export */ camelToWords: () => (/* binding */ camelToWords)
|
|
2432
|
+
/* harmony export */ });
|
|
2126
2433
|
/**
|
|
2127
2434
|
* Splits a camelCase or PascalCase string into separate words with spaces.
|
|
2128
2435
|
*
|
|
@@ -2142,6 +2449,142 @@ const camelToDashCase = (input) => {
|
|
|
2142
2449
|
* ```
|
|
2143
2450
|
*/
|
|
2144
2451
|
const camelToWords = (input) => input.replace(/([a-z0-9])([A-Z])/g, '$1 $2');
|
|
2452
|
+
|
|
2453
|
+
|
|
2454
|
+
/***/ }),
|
|
2455
|
+
|
|
2456
|
+
/***/ "./src/string/index.ts":
|
|
2457
|
+
/*!*****************************!*\
|
|
2458
|
+
!*** ./src/string/index.ts ***!
|
|
2459
|
+
\*****************************/
|
|
2460
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2461
|
+
|
|
2462
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2463
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2464
|
+
/* harmony export */ camelToDashCase: () => (/* reexport safe */ _camel_to_dash_case__WEBPACK_IMPORTED_MODULE_2__.camelToDashCase),
|
|
2465
|
+
/* harmony export */ camelToWords: () => (/* reexport safe */ _camel_to_words__WEBPACK_IMPORTED_MODULE_3__.camelToWords),
|
|
2466
|
+
/* harmony export */ isNilOrEmptyString: () => (/* reexport safe */ _is_nil_or_empty_string__WEBPACK_IMPORTED_MODULE_5__.isNilOrEmptyString),
|
|
2467
|
+
/* harmony export */ isString: () => (/* reexport safe */ _is_string__WEBPACK_IMPORTED_MODULE_0__.isString),
|
|
2468
|
+
/* harmony export */ parseFileName: () => (/* reexport safe */ _parse_file_name__WEBPACK_IMPORTED_MODULE_6__.parseFileName),
|
|
2469
|
+
/* harmony export */ splitStringIntoWords: () => (/* reexport safe */ _split_string_into_words__WEBPACK_IMPORTED_MODULE_4__.splitStringIntoWords),
|
|
2470
|
+
/* harmony export */ toKebabCase: () => (/* reexport safe */ _to_kebab_case__WEBPACK_IMPORTED_MODULE_1__.toKebabCase)
|
|
2471
|
+
/* harmony export */ });
|
|
2472
|
+
/* harmony import */ var _is_string__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./is-string */ "./src/string/is-string.ts");
|
|
2473
|
+
/* harmony import */ var _to_kebab_case__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./to-kebab-case */ "./src/string/to-kebab-case.ts");
|
|
2474
|
+
/* harmony import */ var _camel_to_dash_case__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camel-to-dash-case */ "./src/string/camel-to-dash-case.ts");
|
|
2475
|
+
/* harmony import */ var _camel_to_words__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./camel-to-words */ "./src/string/camel-to-words.ts");
|
|
2476
|
+
/* harmony import */ var _split_string_into_words__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./split-string-into-words */ "./src/string/split-string-into-words.ts");
|
|
2477
|
+
/* harmony import */ var _is_nil_or_empty_string__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./is-nil-or-empty-string */ "./src/string/is-nil-or-empty-string.ts");
|
|
2478
|
+
/* harmony import */ var _parse_file_name__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./parse-file-name */ "./src/string/parse-file-name.ts");
|
|
2479
|
+
|
|
2480
|
+
|
|
2481
|
+
|
|
2482
|
+
|
|
2483
|
+
|
|
2484
|
+
|
|
2485
|
+
|
|
2486
|
+
|
|
2487
|
+
|
|
2488
|
+
/***/ }),
|
|
2489
|
+
|
|
2490
|
+
/***/ "./src/string/is-nil-or-empty-string.ts":
|
|
2491
|
+
/*!**********************************************!*\
|
|
2492
|
+
!*** ./src/string/is-nil-or-empty-string.ts ***!
|
|
2493
|
+
\**********************************************/
|
|
2494
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2495
|
+
|
|
2496
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2497
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2498
|
+
/* harmony export */ isNilOrEmptyString: () => (/* binding */ isNilOrEmptyString)
|
|
2499
|
+
/* harmony export */ });
|
|
2500
|
+
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ~/guards */ "./src/guards.ts");
|
|
2501
|
+
|
|
2502
|
+
/**
|
|
2503
|
+
* Checks whether the provided value is considered "empty".
|
|
2504
|
+
*
|
|
2505
|
+
* A value is considered empty if it is:
|
|
2506
|
+
* - `null`
|
|
2507
|
+
* - `undefined`
|
|
2508
|
+
* - `''`
|
|
2509
|
+
*
|
|
2510
|
+
* @param value - The value to check.
|
|
2511
|
+
*
|
|
2512
|
+
* @returns `true` if the value is empty; otherwise, `false`.
|
|
2513
|
+
*/
|
|
2514
|
+
const isNilOrEmptyString = (value) => value === '' || (0,_guards__WEBPACK_IMPORTED_MODULE_0__.isNil)(value);
|
|
2515
|
+
|
|
2516
|
+
|
|
2517
|
+
/***/ }),
|
|
2518
|
+
|
|
2519
|
+
/***/ "./src/string/is-string.ts":
|
|
2520
|
+
/*!*********************************!*\
|
|
2521
|
+
!*** ./src/string/is-string.ts ***!
|
|
2522
|
+
\*********************************/
|
|
2523
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2524
|
+
|
|
2525
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2526
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2527
|
+
/* harmony export */ isString: () => (/* binding */ isString)
|
|
2528
|
+
/* harmony export */ });
|
|
2529
|
+
/**
|
|
2530
|
+
* Checks if a value is a string.
|
|
2531
|
+
*
|
|
2532
|
+
* @param value - The value to check.
|
|
2533
|
+
*
|
|
2534
|
+
* @returns `true` if the value is a string; otherwise, `false`.
|
|
2535
|
+
*/
|
|
2536
|
+
const isString = (value) => typeof value === 'string';
|
|
2537
|
+
|
|
2538
|
+
|
|
2539
|
+
/***/ }),
|
|
2540
|
+
|
|
2541
|
+
/***/ "./src/string/parse-file-name.ts":
|
|
2542
|
+
/*!***************************************!*\
|
|
2543
|
+
!*** ./src/string/parse-file-name.ts ***!
|
|
2544
|
+
\***************************************/
|
|
2545
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2546
|
+
|
|
2547
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2548
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2549
|
+
/* harmony export */ parseFileName: () => (/* binding */ parseFileName)
|
|
2550
|
+
/* harmony export */ });
|
|
2551
|
+
/**
|
|
2552
|
+
* Splits a file name into its base name and extension.
|
|
2553
|
+
*
|
|
2554
|
+
* Special cases:
|
|
2555
|
+
* - Files without a dot return `[fileName, ""]`
|
|
2556
|
+
* - Hidden files like `.gitignore` return `[".gitignore", ""]`
|
|
2557
|
+
* - Names ending with a trailing dot (e.g., `"file."`) return `["file.", ""]`
|
|
2558
|
+
* - Multi-dot names (e.g., `"archive.tar.gz"`) split on the last dot
|
|
2559
|
+
*
|
|
2560
|
+
* @param fileName - The full file name to parse.
|
|
2561
|
+
*
|
|
2562
|
+
* @returns A tuple where:
|
|
2563
|
+
* - index 0 is the base name
|
|
2564
|
+
* - index 1 is the file extension (lowercased), or an empty string if none exists
|
|
2565
|
+
*/
|
|
2566
|
+
const parseFileName = (fileName) => {
|
|
2567
|
+
const lastDotIndex = fileName.lastIndexOf('.');
|
|
2568
|
+
// No dot or leading dot with no extension (e.g., ".gitignore")
|
|
2569
|
+
if (lastDotIndex <= 0 || lastDotIndex === fileName.length - 1) {
|
|
2570
|
+
return [fileName, ''];
|
|
2571
|
+
}
|
|
2572
|
+
return [fileName.slice(0, lastDotIndex), fileName.slice(lastDotIndex + 1).toLowerCase()];
|
|
2573
|
+
};
|
|
2574
|
+
|
|
2575
|
+
|
|
2576
|
+
/***/ }),
|
|
2577
|
+
|
|
2578
|
+
/***/ "./src/string/split-string-into-words.ts":
|
|
2579
|
+
/*!***********************************************!*\
|
|
2580
|
+
!*** ./src/string/split-string-into-words.ts ***!
|
|
2581
|
+
\***********************************************/
|
|
2582
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2583
|
+
|
|
2584
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2585
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2586
|
+
/* harmony export */ splitStringIntoWords: () => (/* binding */ splitStringIntoWords)
|
|
2587
|
+
/* harmony export */ });
|
|
2145
2588
|
/**
|
|
2146
2589
|
* Splits a string into an array of filtered from redundant spaces words.
|
|
2147
2590
|
*
|
|
@@ -2150,37 +2593,38 @@ const camelToWords = (input) => input.replace(/([a-z0-9])([A-Z])/g, '$1 $2');
|
|
|
2150
2593
|
* @returns An array of words from the input string.
|
|
2151
2594
|
*/
|
|
2152
2595
|
const splitStringIntoWords = (input) => input.split(' ').filter(Boolean);
|
|
2596
|
+
|
|
2597
|
+
|
|
2598
|
+
/***/ }),
|
|
2599
|
+
|
|
2600
|
+
/***/ "./src/string/to-kebab-case.ts":
|
|
2601
|
+
/*!*************************************!*\
|
|
2602
|
+
!*** ./src/string/to-kebab-case.ts ***!
|
|
2603
|
+
\*************************************/
|
|
2604
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
2605
|
+
|
|
2606
|
+
__webpack_require__.r(__webpack_exports__);
|
|
2607
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2608
|
+
/* harmony export */ toKebabCase: () => (/* binding */ toKebabCase)
|
|
2609
|
+
/* harmony export */ });
|
|
2153
2610
|
/**
|
|
2154
|
-
*
|
|
2155
|
-
*
|
|
2156
|
-
* This function uses a variation of the DJB2 algorithm, which is a simple yet effective hashing algorithm
|
|
2157
|
-
* based on bitwise XOR (`^`) and multiplication by 33. It produces a non-negative 32-bit integer,
|
|
2158
|
-
* which is then converted to a base-36 string (digits + lowercase letters) to produce a compact output.
|
|
2159
|
-
*
|
|
2160
|
-
* Useful for:
|
|
2161
|
-
* - Generating stable class names in CSS-in-JS libraries.
|
|
2162
|
-
* - Producing consistent cache keys.
|
|
2163
|
-
* - Quick and lightweight hashing needs where cryptographic security is not required.
|
|
2611
|
+
* Converts a string to kebab-case format.
|
|
2164
2612
|
*
|
|
2165
|
-
*
|
|
2613
|
+
* This function transforms camelCase or PascalCase strings into kebab-case by inserting
|
|
2614
|
+
* hyphens between lowercase and uppercase letters, then converting everything to lowercase.
|
|
2166
2615
|
*
|
|
2167
|
-
* @param input - The
|
|
2616
|
+
* @param input - The string to convert to kebab-case.
|
|
2168
2617
|
*
|
|
2169
|
-
* @returns
|
|
2618
|
+
* @returns The kebab-case formatted string.
|
|
2170
2619
|
*
|
|
2171
2620
|
* @example
|
|
2172
2621
|
* ```ts
|
|
2173
|
-
*
|
|
2174
|
-
* // → '
|
|
2622
|
+
* toKebabCase('helloWorld'); // → 'hello-world'
|
|
2623
|
+
* toKebabCase('HelloWorld'); // → 'hello-world'
|
|
2624
|
+
* toKebabCase('hello123World'); // → 'hello123-world'
|
|
2175
2625
|
* ```
|
|
2176
2626
|
*/
|
|
2177
|
-
const
|
|
2178
|
-
let hash = 5381;
|
|
2179
|
-
for (let i = 0; i < input.length; i++) {
|
|
2180
|
-
hash = (hash * 33) ^ input.charCodeAt(i);
|
|
2181
|
-
}
|
|
2182
|
-
return (hash >>> 0).toString(36);
|
|
2183
|
-
};
|
|
2627
|
+
const toKebabCase = (input) => input.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
2184
2628
|
|
|
2185
2629
|
|
|
2186
2630
|
/***/ })
|
|
@@ -2250,6 +2694,7 @@ var __webpack_exports__ = {};
|
|
|
2250
2694
|
__webpack_require__.r(__webpack_exports__);
|
|
2251
2695
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
2252
2696
|
/* harmony export */ FOCUSABLE_HTML_TAGS: () => (/* reexport safe */ _a11y__WEBPACK_IMPORTED_MODULE_11__.FOCUSABLE_HTML_TAGS),
|
|
2697
|
+
/* harmony export */ applyInertiaStep: () => (/* reexport safe */ _geometry__WEBPACK_IMPORTED_MODULE_9__.applyInertiaStep),
|
|
2253
2698
|
/* harmony export */ assert: () => (/* reexport safe */ _guards__WEBPACK_IMPORTED_MODULE_4__.assert),
|
|
2254
2699
|
/* harmony export */ blobToFile: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_7__.blobToFile),
|
|
2255
2700
|
/* harmony export */ calculateCenterOffset: () => (/* reexport safe */ _geometry__WEBPACK_IMPORTED_MODULE_9__.calculateCenterOffset),
|
|
@@ -2264,7 +2709,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2264
2709
|
/* harmony export */ compact: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.compact),
|
|
2265
2710
|
/* harmony export */ compose: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.compose),
|
|
2266
2711
|
/* harmony export */ definedProps: () => (/* reexport safe */ _object__WEBPACK_IMPORTED_MODULE_8__.definedProps),
|
|
2267
|
-
/* harmony export */ delay: () => (/* reexport safe */
|
|
2712
|
+
/* harmony export */ delay: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.delay),
|
|
2268
2713
|
/* harmony export */ difference: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.difference),
|
|
2269
2714
|
/* harmony export */ downloadFile: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.downloadFile),
|
|
2270
2715
|
/* harmony export */ everyAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.everyAsync),
|
|
@@ -2280,7 +2725,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2280
2725
|
/* harmony export */ getYOverflowHeight: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.getYOverflowHeight),
|
|
2281
2726
|
/* harmony export */ hasXOverflow: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.hasXOverflow),
|
|
2282
2727
|
/* harmony export */ hasYOverflow: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.hasYOverflow),
|
|
2283
|
-
/* harmony export */ hashString: () => (/* reexport safe */
|
|
2728
|
+
/* harmony export */ hashString: () => (/* reexport safe */ _math__WEBPACK_IMPORTED_MODULE_5__.hashString),
|
|
2284
2729
|
/* harmony export */ intersection: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.intersection),
|
|
2285
2730
|
/* harmony export */ invokeIfFunction: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_3__.invokeIfFunction),
|
|
2286
2731
|
/* harmony export */ isAnchorHtmlElement: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.isAnchorHtmlElement),
|
|
@@ -2318,27 +2763,28 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
2318
2763
|
/* harmony export */ not: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_3__.not),
|
|
2319
2764
|
/* harmony export */ once: () => (/* reexport safe */ _function__WEBPACK_IMPORTED_MODULE_3__.once),
|
|
2320
2765
|
/* harmony export */ parse2DMatrix: () => (/* reexport safe */ _dom__WEBPACK_IMPORTED_MODULE_6__.parse2DMatrix),
|
|
2321
|
-
/* harmony export */ parseFileName: () => (/* reexport safe */
|
|
2766
|
+
/* harmony export */ parseFileName: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.parseFileName),
|
|
2322
2767
|
/* harmony export */ pipe: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.pipe),
|
|
2323
2768
|
/* harmony export */ readFilesFromDataTransfer: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_7__.readFilesFromDataTransfer),
|
|
2324
2769
|
/* harmony export */ reduceAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.reduceAsync),
|
|
2325
2770
|
/* harmony export */ resolveAxisDelta: () => (/* reexport safe */ _intersection__WEBPACK_IMPORTED_MODULE_10__.resolveAxisDelta),
|
|
2326
|
-
/* harmony export */
|
|
2771
|
+
/* harmony export */ resolveBoundedDelta: () => (/* reexport safe */ _geometry__WEBPACK_IMPORTED_MODULE_9__.resolveBoundedDelta),
|
|
2772
|
+
/* harmony export */ retry: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.retry),
|
|
2327
2773
|
/* harmony export */ runParallel: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.runParallel),
|
|
2328
2774
|
/* harmony export */ runSequential: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.runSequential),
|
|
2329
2775
|
/* harmony export */ someAsync: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.someAsync),
|
|
2330
2776
|
/* harmony export */ splitStringIntoWords: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.splitStringIntoWords),
|
|
2331
|
-
/* harmony export */ timeout: () => (/* reexport safe */
|
|
2777
|
+
/* harmony export */ timeout: () => (/* reexport safe */ _async__WEBPACK_IMPORTED_MODULE_0__.timeout),
|
|
2332
2778
|
/* harmony export */ toKebabCase: () => (/* reexport safe */ _string__WEBPACK_IMPORTED_MODULE_1__.toKebabCase),
|
|
2333
2779
|
/* harmony export */ traverseFileSystemDirectory: () => (/* reexport safe */ _file__WEBPACK_IMPORTED_MODULE_7__.traverseFileSystemDirectory),
|
|
2334
2780
|
/* harmony export */ unique: () => (/* reexport safe */ _array__WEBPACK_IMPORTED_MODULE_2__.unique)
|
|
2335
2781
|
/* harmony export */ });
|
|
2336
|
-
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./async */ "./src/async.ts");
|
|
2337
|
-
/* harmony import */ var _string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./string */ "./src/string.ts");
|
|
2782
|
+
/* harmony import */ var _async__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./async */ "./src/async/index.ts");
|
|
2783
|
+
/* harmony import */ var _string__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./string */ "./src/string/index.ts");
|
|
2338
2784
|
/* harmony import */ var _array__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./array */ "./src/array.ts");
|
|
2339
|
-
/* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./function */ "./src/function.ts");
|
|
2785
|
+
/* harmony import */ var _function__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./function */ "./src/function/index.ts");
|
|
2340
2786
|
/* harmony import */ var _guards__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./guards */ "./src/guards.ts");
|
|
2341
|
-
/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./math */ "./src/math.ts");
|
|
2787
|
+
/* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./math */ "./src/math/index.ts");
|
|
2342
2788
|
/* harmony import */ var _dom__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./dom */ "./src/dom/index.ts");
|
|
2343
2789
|
/* harmony import */ var _file__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./file */ "./src/file.ts");
|
|
2344
2790
|
/* harmony import */ var _object__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./object */ "./src/object.ts");
|