@studiometa/js-toolkit 3.1.1 → 3.3.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/Base/Base.d.ts +14 -12
- package/Base/Base.js +17 -16
- package/Base/Base.js.map +2 -2
- package/Base/managers/AbstractManager.d.ts +1 -1
- package/Base/managers/ChildrenManager.d.ts +2 -2
- package/Base/managers/ChildrenManager.js +4 -4
- package/Base/managers/ChildrenManager.js.map +2 -2
- package/Base/managers/EventsManager.d.ts +10 -10
- package/Base/managers/EventsManager.js +10 -10
- package/Base/managers/EventsManager.js.map +1 -1
- package/Base/managers/ResponsiveOptionsManager.d.ts +6 -6
- package/Base/managers/ResponsiveOptionsManager.js +6 -6
- package/Base/managers/ResponsiveOptionsManager.js.map +1 -1
- package/Base/managers/ServicesManager.d.ts +2 -2
- package/Base/managers/ServicesManager.js +2 -2
- package/Base/managers/ServicesManager.js.map +1 -1
- package/Base/utils.d.ts +3 -2
- package/Base/utils.js +7 -5
- package/Base/utils.js.map +2 -2
- package/decorators/index.d.ts +1 -0
- package/decorators/index.js +1 -0
- package/decorators/index.js.map +2 -2
- package/decorators/withBreakpointManager.d.ts +2 -1
- package/decorators/withBreakpointManager.js.map +2 -2
- package/decorators/withBreakpointObserver.d.ts +2 -1
- package/decorators/withBreakpointObserver.js.map +2 -2
- package/decorators/withDrag.d.ts +2 -1
- package/decorators/withDrag.js.map +2 -2
- package/decorators/withExtraConfig.d.ts +2 -1
- package/decorators/withExtraConfig.js.map +2 -2
- package/decorators/withFreezedOptions.d.ts +2 -1
- package/decorators/withFreezedOptions.js.map +2 -2
- package/decorators/withGroup.d.ts +16 -0
- package/decorators/withGroup.js +39 -0
- package/decorators/withGroup.js.map +7 -0
- package/decorators/withIntersectionObserver.d.ts +2 -1
- package/decorators/withIntersectionObserver.js.map +2 -2
- package/decorators/withMountOnMediaQuery.d.ts +2 -1
- package/decorators/withMountOnMediaQuery.js.map +2 -2
- package/decorators/withMountWhenInView.d.ts +2 -1
- package/decorators/withMountWhenInView.js.map +2 -2
- package/decorators/withMountWhenPrefersMotion.d.ts +3 -0
- package/decorators/withMountWhenPrefersMotion.js.map +2 -2
- package/decorators/withMutation.d.ts +2 -1
- package/decorators/withMutation.js.map +2 -2
- package/decorators/withRelativePointer.d.ts +2 -1
- package/decorators/withRelativePointer.js.map +2 -2
- package/decorators/withResponsiveOptions.d.ts +2 -1
- package/decorators/withResponsiveOptions.js.map +2 -2
- package/decorators/withScrolledInView/withScrolledInView.d.ts +2 -1
- package/decorators/withScrolledInView/withScrolledInView.js.map +2 -2
- package/helpers/createApp.d.ts +2 -1
- package/helpers/createApp.js.map +2 -2
- package/helpers/getClosestParent.d.ts +2 -1
- package/helpers/getClosestParent.js.map +2 -2
- package/helpers/getDirectChildren.d.ts +13 -11
- package/helpers/getDirectChildren.js.map +2 -2
- package/helpers/getInstanceFromElement.d.ts +2 -1
- package/helpers/getInstanceFromElement.js +2 -2
- package/helpers/getInstanceFromElement.js.map +2 -2
- package/helpers/importOnInteraction.d.ts +3 -2
- package/helpers/importOnInteraction.js.map +2 -2
- package/helpers/importOnMediaQuery.d.ts +3 -2
- package/helpers/importOnMediaQuery.js.map +2 -2
- package/helpers/importWhenIdle.d.ts +3 -2
- package/helpers/importWhenIdle.js.map +2 -2
- package/helpers/importWhenPrefersMotion.d.ts +3 -2
- package/helpers/importWhenPrefersMotion.js.map +2 -2
- package/helpers/importWhenVisible.d.ts +3 -2
- package/helpers/importWhenVisible.js.map +2 -2
- package/helpers/index.d.ts +1 -0
- package/helpers/index.js +1 -0
- package/helpers/index.js.map +2 -2
- package/helpers/registerComponent.d.ts +10 -0
- package/helpers/registerComponent.js +11 -0
- package/helpers/registerComponent.js.map +7 -0
- package/helpers/utils.d.ts +1 -1
- package/helpers/utils.js.map +1 -1
- package/index.d.ts +1 -0
- package/index.js +4 -0
- package/index.js.map +2 -2
- package/package.json +1 -1
- package/services/AbstractService.d.ts +1 -1
- package/services/AbstractService.js.map +1 -1
- package/services/DragService.d.ts +3 -2
- package/services/DragService.js +5 -1
- package/services/DragService.js.map +2 -2
- package/services/KeyService.d.ts +2 -1
- package/services/KeyService.js.map +2 -2
- package/services/LoadService.d.ts +2 -1
- package/services/LoadService.js.map +2 -2
- package/services/MutationService.d.ts +2 -1
- package/services/MutationService.js.map +2 -2
- package/services/PointerService.d.ts +2 -1
- package/services/PointerService.js.map +2 -2
- package/services/RafService.d.ts +2 -1
- package/services/RafService.js.map +2 -2
- package/services/ResizeService.d.ts +2 -1
- package/services/ResizeService.js.map +2 -2
- package/services/ScrollService.d.ts +2 -1
- package/services/ScrollService.js.map +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/utils/SmartQueue.js.map +1 -1
- package/utils/cache.d.ts +2 -1
- package/utils/cache.js.map +2 -2
- package/utils/collide/boundingRectToCircle.d.ts +3 -2
- package/utils/collide/boundingRectToCircle.js.map +2 -2
- package/utils/collide/collideCircleCircle.d.ts +3 -2
- package/utils/collide/collideCircleCircle.js.map +2 -2
- package/utils/collide/collideCircleRect.d.ts +3 -2
- package/utils/collide/collideCircleRect.js.map +2 -2
- package/utils/collide/collidePointCircle.d.ts +3 -2
- package/utils/collide/collidePointCircle.js.map +2 -2
- package/utils/collide/collidePointRect.d.ts +3 -2
- package/utils/collide/collidePointRect.js.map +2 -2
- package/utils/collide/collideRectRect.d.ts +3 -2
- package/utils/collide/collideRectRect.js.map +2 -2
- package/utils/css/animate.d.ts +2 -1
- package/utils/css/animate.js.map +2 -2
- package/utils/css/classes.d.ts +6 -3
- package/utils/css/classes.js.map +2 -2
- package/utils/css/getOffsetSizes.d.ts +2 -1
- package/utils/css/getOffsetSizes.js.map +2 -2
- package/utils/css/matrix.d.ts +10 -9
- package/utils/css/matrix.js.map +2 -2
- package/utils/css/styles.d.ts +4 -2
- package/utils/css/styles.js.map +2 -2
- package/utils/css/transform.d.ts +2 -1
- package/utils/css/transform.js.map +2 -2
- package/utils/css/transition.d.ts +3 -2
- package/utils/css/transition.js +1 -1
- package/utils/css/transition.js.map +2 -2
- package/utils/debounce.d.ts +5 -4
- package/utils/debounce.js.map +2 -2
- package/utils/dom/createElement.d.ts +24 -1
- package/utils/dom/createElement.js +8 -2
- package/utils/dom/createElement.js.map +2 -2
- package/utils/getComponentResolver.d.ts +1 -1
- package/utils/getComponentResolver.js.map +1 -1
- package/utils/history.d.ts +17 -14
- package/utils/history.js.map +2 -2
- package/utils/is.d.ts +25 -9
- package/utils/is.js.map +2 -2
- package/utils/keyCodes.d.ts +3 -0
- package/utils/keyCodes.js.map +2 -2
- package/utils/loadElement.d.ts +10 -5
- package/utils/loadElement.js.map +2 -2
- package/utils/math/clamp.d.ts +2 -6
- package/utils/math/clamp.js.map +2 -2
- package/utils/math/clamp01.d.ts +2 -4
- package/utils/math/clamp01.js.map +2 -2
- package/utils/math/createEases.d.ts +13 -5
- package/utils/math/createEases.js.map +2 -2
- package/utils/math/createRange.d.ts +2 -1
- package/utils/math/createRange.js.map +2 -2
- package/utils/math/damp.d.ts +7 -6
- package/utils/math/damp.js.map +2 -2
- package/utils/math/ease.d.ts +23 -14
- package/utils/math/ease.js.map +2 -2
- package/utils/math/inertiaFinalValue.d.ts +6 -5
- package/utils/math/inertiaFinalValue.js.map +2 -2
- package/utils/math/lerp.d.ts +6 -5
- package/utils/math/lerp.js.map +2 -2
- package/utils/math/map.d.ts +3 -2
- package/utils/math/map.js.map +2 -2
- package/utils/math/mean.d.ts +3 -0
- package/utils/math/mean.js.map +2 -2
- package/utils/math/round.d.ts +5 -4
- package/utils/math/round.js.map +2 -2
- package/utils/math/smoothTo.d.ts +1 -1
- package/utils/math/smoothTo.js.map +1 -1
- package/utils/math/spring.d.ts +9 -9
- package/utils/math/spring.js.map +1 -1
- package/utils/math/wrap.d.ts +2 -1
- package/utils/math/wrap.js.map +2 -2
- package/utils/memo.d.ts +2 -1
- package/utils/memo.js.map +2 -2
- package/utils/memoize.d.ts +2 -1
- package/utils/memoize.js.map +2 -2
- package/utils/nextFrame.d.ts +2 -1
- package/utils/nextFrame.js.map +2 -2
- package/utils/nextMicrotask.d.ts +2 -1
- package/utils/nextMicrotask.js.map +2 -2
- package/utils/nextTick.d.ts +2 -1
- package/utils/nextTick.js.map +2 -2
- package/utils/noop.d.ts +1 -1
- package/utils/noop.js.map +1 -1
- package/utils/object/getAllProperties.d.ts +1 -1
- package/utils/object/getAllProperties.js.map +1 -1
- package/utils/random.d.ts +11 -8
- package/utils/random.js.map +2 -2
- package/utils/scheduler.d.ts +6 -1
- package/utils/scheduler.js.map +2 -2
- package/utils/scrollTo.d.ts +3 -2
- package/utils/scrollTo.js.map +2 -2
- package/utils/string/changeCase.d.ts +12 -6
- package/utils/string/changeCase.js.map +2 -2
- package/utils/string/endsWith.d.ts +2 -1
- package/utils/string/endsWith.js.map +2 -2
- package/utils/string/startsWith.d.ts +2 -1
- package/utils/string/startsWith.js.map +2 -2
- package/utils/string/withLeadingCharacters.d.ts +5 -4
- package/utils/string/withLeadingCharacters.js.map +2 -2
- package/utils/string/withLeadingSlash.d.ts +3 -2
- package/utils/string/withLeadingSlash.js.map +2 -2
- package/utils/string/withTrailingCharacters.d.ts +5 -4
- package/utils/string/withTrailingCharacters.js.map +2 -2
- package/utils/string/withTrailingSlash.d.ts +3 -2
- package/utils/string/withTrailingSlash.js.map +2 -2
- package/utils/string/withoutLeadingCharacters.d.ts +5 -4
- package/utils/string/withoutLeadingCharacters.js.map +2 -2
- package/utils/string/withoutLeadingCharactersRecursive.d.ts +5 -4
- package/utils/string/withoutLeadingCharactersRecursive.js.map +2 -2
- package/utils/string/withoutLeadingSlash.d.ts +3 -2
- package/utils/string/withoutLeadingSlash.js.map +2 -2
- package/utils/string/withoutTrailingCharacters.d.ts +5 -4
- package/utils/string/withoutTrailingCharacters.js.map +2 -2
- package/utils/string/withoutTrailingCharactersRecursive.d.ts +5 -4
- package/utils/string/withoutTrailingCharactersRecursive.js.map +2 -2
- package/utils/string/withoutTrailingSlash.d.ts +3 -2
- package/utils/string/withoutTrailingSlash.js.map +2 -2
- package/utils/throttle.d.ts +3 -2
- package/utils/throttle.js.map +2 -2
- package/utils/trapFocus.d.ts +4 -2
- package/utils/trapFocus.js.map +2 -2
- package/utils/tween.d.ts +1 -1
- package/utils/tween.js.map +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withLeadingCharacters.ts"],
|
|
4
|
-
"sourcesContent": ["import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';\n\n/**\n * Add the given characters to the start of the given string.\n *\n * @param
|
|
5
|
-
"mappings": "AAAA,SAAS,gCAAgC;
|
|
4
|
+
"sourcesContent": ["import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';\n\n/**\n * Add the given characters to the start of the given string.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to add to the start.\n * @return {string}\n * @link https://js-toolkit.studiometa.dev/utils/string/withLeadingCharacters.html\n*/\nexport function withLeadingCharacters(string: string, characters: string): string {\n return `${characters}${withoutLeadingCharacters(string, characters)}`;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gCAAgC;AAUlC,SAAS,sBAAsB,QAAgB,YAA4B;AAChF,SAAO,GAAG,UAAU,GAAG,yBAAyB,QAAQ,UAAU,CAAC;AACrE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Add a leading slash to a string.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} string The string to modify.
|
|
5
|
-
* @
|
|
6
|
-
|
|
5
|
+
* @return {string} The string with a leading slash.
|
|
6
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withLeadingSlash.html
|
|
7
|
+
*/
|
|
7
8
|
export declare function withLeadingSlash(string: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withLeadingSlash.ts"],
|
|
4
|
-
"sourcesContent": ["import { withLeadingCharacters } from './withLeadingCharacters.js';\n\n/**\n * Add a leading slash to a string.\n *\n * @param {string} string The string to modify.\n * @
|
|
5
|
-
"mappings": "AAAA,SAAS,6BAA6B;
|
|
4
|
+
"sourcesContent": ["import { withLeadingCharacters } from './withLeadingCharacters.js';\n\n/**\n * Add a leading slash to a string.\n *\n * @param {string} string The string to modify.\n * @return {string} The string with a leading slash.\n * @link https://js-toolkit.studiometa.dev/utils/string/withLeadingSlash.html\n*/\nexport function withLeadingSlash(string: string): string {\n return withLeadingCharacters(string, '/');\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,6BAA6B;AAS/B,SAAS,iBAAiB,QAAwB;AACvD,SAAO,sBAAsB,QAAQ,GAAG;AAC1C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Add the given characters to the end of the given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
7
|
-
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to add to the end.
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withTrailingCharacters.html
|
|
8
|
+
*/
|
|
8
9
|
export declare function withTrailingCharacters(string: string, characters: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withTrailingCharacters.ts"],
|
|
4
|
-
"sourcesContent": ["import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';\n\n/**\n * Add the given characters to the end of the given string.\n *\n * @param
|
|
5
|
-
"mappings": "AAAA,SAAS,iCAAiC;
|
|
4
|
+
"sourcesContent": ["import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';\n\n/**\n * Add the given characters to the end of the given string.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to add to the end.\n * @return {string}\n * @link https://js-toolkit.studiometa.dev/utils/string/withTrailingCharacters.html\n*/\nexport function withTrailingCharacters(string: string, characters: string): string {\n return `${withoutTrailingCharacters(string, characters)}${characters}`;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAUnC,SAAS,uBAAuB,QAAgB,YAA4B;AACjF,SAAO,GAAG,0BAA0B,QAAQ,UAAU,CAAC,GAAG,UAAU;AACtE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Add a trailing slash to a string.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} string The string to modify.
|
|
5
|
-
* @
|
|
6
|
-
|
|
5
|
+
* @return {string} The string with a trailing slash.
|
|
6
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withTrailingSlash.html
|
|
7
|
+
*/
|
|
7
8
|
export declare function withTrailingSlash(string: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withTrailingSlash.ts"],
|
|
4
|
-
"sourcesContent": ["import { withTrailingCharacters } from './withTrailingCharacters.js';\n\n/**\n * Add a trailing slash to a string.\n *\n * @param {string} string The string to modify.\n * @
|
|
5
|
-
"mappings": "AAAA,SAAS,8BAA8B;
|
|
4
|
+
"sourcesContent": ["import { withTrailingCharacters } from './withTrailingCharacters.js';\n\n/**\n * Add a trailing slash to a string.\n *\n * @param {string} string The string to modify.\n * @return {string} The string with a trailing slash.\n * @link https://js-toolkit.studiometa.dev/utils/string/withTrailingSlash.html\n*/\nexport function withTrailingSlash(string: string): string {\n return withTrailingCharacters(string, '/');\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,8BAA8B;AAShC,SAAS,kBAAkB,QAAwB;AACxD,SAAO,uBAAuB,QAAQ,GAAG;AAC3C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove the given characters from the start of the given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
7
|
-
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to remove from the start.
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingCharacters.html
|
|
8
|
+
*/
|
|
8
9
|
export declare function withoutLeadingCharacters(string: string, characters: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutLeadingCharacters.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Remove the given characters from the start of the given string.\n *\n * @param
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Remove the given characters from the start of the given string.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to remove from the start.\n * @return {string}\n * @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingCharacters.html\n*/\nexport function withoutLeadingCharacters(string: string, characters: string): string {\n return string.replace(new RegExp(`^${characters}`), '');\n}\n"],
|
|
5
|
+
"mappings": "AAQO,SAAS,yBAAyB,QAAgB,YAA4B;AACnF,SAAO,OAAO,QAAQ,IAAI,OAAO,IAAI,UAAU,EAAE,GAAG,EAAE;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove the given characters to the start of the given string recursively.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
7
|
-
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to add to the start.
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingCharactersRecursive.html
|
|
8
|
+
*/
|
|
8
9
|
export declare function withoutLeadingCharactersRecursive(string: string, characters: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutLeadingCharactersRecursive.ts"],
|
|
4
|
-
"sourcesContent": ["import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';\n\n/**\n * Remove the given characters to the start of the given string recursively.\n *\n * @param
|
|
5
|
-
"mappings": "AAAA,SAAS,gCAAgC;
|
|
4
|
+
"sourcesContent": ["import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';\n\n/**\n * Remove the given characters to the start of the given string recursively.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to add to the start.\n * @return {string}\n * @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingCharactersRecursive.html\n*/\nexport function withoutLeadingCharactersRecursive(string: string, characters: string): string {\n let str = withoutLeadingCharacters(string, characters);\n const regex = new RegExp(`^${characters}`);\n\n while (regex.test(str)) {\n str = withoutLeadingCharacters(str, characters);\n }\n\n return str;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gCAAgC;AAUlC,SAAS,kCAAkC,QAAgB,YAA4B;AAC5F,MAAI,MAAM,yBAAyB,QAAQ,UAAU;AACrD,QAAM,QAAQ,IAAI,OAAO,IAAI,UAAU,EAAE;AAEzC,SAAO,MAAM,KAAK,GAAG,GAAG;AACtB,UAAM,yBAAyB,KAAK,UAAU;AAAA,EAChD;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Remove the leading slash from a string.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} string The string to modify.
|
|
5
|
-
* @
|
|
6
|
-
|
|
5
|
+
* @return {string} The string without leading slash.
|
|
6
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingSlash.html
|
|
7
|
+
*/
|
|
7
8
|
export declare function withoutLeadingSlash(string: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutLeadingSlash.ts"],
|
|
4
|
-
"sourcesContent": ["import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';\n\n/**\n * Remove the leading slash from a string.\n *\n * @param {string} string The string to modify.\n * @
|
|
5
|
-
"mappings": "AAAA,SAAS,gCAAgC;
|
|
4
|
+
"sourcesContent": ["import { withoutLeadingCharacters } from './withoutLeadingCharacters.js';\n\n/**\n * Remove the leading slash from a string.\n *\n * @param {string} string The string to modify.\n * @return {string} The string without leading slash.\n * @link https://js-toolkit.studiometa.dev/utils/string/withoutLeadingSlash.html\n*/\nexport function withoutLeadingSlash(string: string): string {\n return withoutLeadingCharacters(string, '/');\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gCAAgC;AASlC,SAAS,oBAAoB,QAAwB;AAC1D,SAAO,yBAAyB,QAAQ,GAAG;AAC7C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove the given characters from the end of the given string.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
7
|
-
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to remove from the end.
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingCharacters.html
|
|
8
|
+
*/
|
|
8
9
|
export declare function withoutTrailingCharacters(string: string, characters: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutTrailingCharacters.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Remove the given characters from the end of the given string.\n *\n * @param
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Remove the given characters from the end of the given string.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to remove from the end.\n * @return {string}\n * @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingCharacters.html\n*/\nexport function withoutTrailingCharacters(string: string, characters: string): string {\n return string.replace(new RegExp(`${characters}$`), '');\n}\n"],
|
|
5
|
+
"mappings": "AAQO,SAAS,0BAA0B,QAAgB,YAA4B;AACpF,SAAO,OAAO,QAAQ,IAAI,OAAO,GAAG,UAAU,GAAG,GAAG,EAAE;AACxD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Remove the given characters to the start of the given string recursively.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @
|
|
7
|
-
|
|
4
|
+
* @param {string} string The string to modify.
|
|
5
|
+
* @param {string} characters The characters to add to the start.
|
|
6
|
+
* @return {string}
|
|
7
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingCharactersRecursive.html
|
|
8
|
+
*/
|
|
8
9
|
export declare function withoutTrailingCharactersRecursive(string: string, characters: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutTrailingCharactersRecursive.ts"],
|
|
4
|
-
"sourcesContent": ["import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';\n\n/**\n * Remove the given characters to the start of the given string recursively.\n *\n * @param
|
|
5
|
-
"mappings": "AAAA,SAAS,iCAAiC;
|
|
4
|
+
"sourcesContent": ["import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';\n\n/**\n * Remove the given characters to the start of the given string recursively.\n *\n * @param {string} string The string to modify.\n * @param {string} characters The characters to add to the start.\n * @return {string}\n * @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingCharactersRecursive.html\n*/\nexport function withoutTrailingCharactersRecursive(string: string, characters: string): string {\n let str = withoutTrailingCharacters(string, characters);\n const regex = new RegExp(`${characters}$`);\n\n while (regex.test(str)) {\n str = withoutTrailingCharacters(str, characters);\n }\n\n return str;\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AAUnC,SAAS,mCAAmC,QAAgB,YAA4B;AAC7F,MAAI,MAAM,0BAA0B,QAAQ,UAAU;AACtD,QAAM,QAAQ,IAAI,OAAO,GAAG,UAAU,GAAG;AAEzC,SAAO,MAAM,KAAK,GAAG,GAAG;AACtB,UAAM,0BAA0B,KAAK,UAAU;AAAA,EACjD;AAEA,SAAO;AACT;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Remove the trailing slash from a string.
|
|
3
3
|
*
|
|
4
4
|
* @param {string} string The string to modify.
|
|
5
|
-
* @
|
|
6
|
-
|
|
5
|
+
* @return {string} The string without trailing slash.
|
|
6
|
+
* @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingSlash.html
|
|
7
|
+
*/
|
|
7
8
|
export declare function withoutTrailingSlash(string: string): string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../packages/js-toolkit/utils/string/withoutTrailingSlash.ts"],
|
|
4
|
-
"sourcesContent": ["import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';\n\n/**\n * Remove the trailing slash from a string.\n *\n * @param {string} string The string to modify.\n * @
|
|
5
|
-
"mappings": "AAAA,SAAS,iCAAiC;
|
|
4
|
+
"sourcesContent": ["import { withoutTrailingCharacters } from './withoutTrailingCharacters.js';\n\n/**\n * Remove the trailing slash from a string.\n *\n * @param {string} string The string to modify.\n * @return {string} The string without trailing slash.\n * @link https://js-toolkit.studiometa.dev/utils/string/withoutTrailingSlash.html\n*/\nexport function withoutTrailingSlash(string: string): string {\n return withoutTrailingCharacters(string, '/');\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,iCAAiC;AASnC,SAAS,qBAAqB,QAAwB;AAC3D,SAAO,0BAA0B,QAAQ,GAAG;AAC9C;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/utils/throttle.d.ts
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @param {Function} fn The function to throttle
|
|
5
5
|
* @param {number} [delay] The delay in ms
|
|
6
|
-
* @
|
|
7
|
-
|
|
6
|
+
* @return {Function} The throttled function.
|
|
7
|
+
* @link https://js-toolkit.studiometa.dev/utils/throttle.html
|
|
8
|
+
*/
|
|
8
9
|
export declare function throttle(fn: (...args: unknown[]) => void, delay?: number): (...args: unknown[]) => void;
|
package/utils/throttle.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/utils/throttle.ts"],
|
|
4
|
-
"sourcesContent": ["/**\n * Simple throttling helper that limits a function to only run once every {delay}ms.\n *\n * @param {Function} fn The function to throttle\n * @param {number} [delay] The delay in ms\n * @
|
|
5
|
-
"mappings": "
|
|
4
|
+
"sourcesContent": ["/**\n * Simple throttling helper that limits a function to only run once every {delay}ms.\n *\n * @param {Function} fn The function to throttle\n * @param {number} [delay] The delay in ms\n * @return {Function} The throttled function.\n * @link https://js-toolkit.studiometa.dev/utils/throttle.html\n*/\nexport function throttle(\n fn: (...args: unknown[]) => void,\n delay = 16,\n): (...args: unknown[]) => void {\n let lastCall = 0;\n return function throttled(...args) {\n const now = Date.now();\n if (now - lastCall < delay) {\n return;\n }\n lastCall = now;\n // eslint-disable-next-line consistent-return\n return fn(...args);\n };\n}\n"],
|
|
5
|
+
"mappings": "AAQO,SAAS,SACd,IACA,QAAQ,IACsB;AAC9B,MAAI,WAAW;AACf,SAAO,SAAS,aAAa,MAAM;AACjC,UAAM,MAAM,KAAK,IAAI;AACrB,QAAI,MAAM,WAAW,OAAO;AAC1B;AAAA,IACF;AACA,eAAW;AAEX,WAAO,GAAG,GAAG,IAAI;AAAA,EACnB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/utils/trapFocus.d.ts
CHANGED
|
@@ -7,9 +7,11 @@ export declare function saveActiveElement(): void;
|
|
|
7
7
|
*
|
|
8
8
|
* @param {HTMLElement} element The element in which to trap the tabulations.
|
|
9
9
|
* @param {KeyboardEvent} event The keydown or keyup event.
|
|
10
|
-
|
|
10
|
+
* @link https://js-toolkit.studiometa.dev/utils/trapFocus.html
|
|
11
|
+
*/
|
|
11
12
|
export declare function trapFocus(element: HTMLElement, event: KeyboardEvent): void;
|
|
12
13
|
/**
|
|
13
14
|
* Untrap the tab navigation.
|
|
14
|
-
|
|
15
|
+
* @link https://js-toolkit.studiometa.dev/utils/trapFocus.html
|
|
16
|
+
*/
|
|
15
17
|
export declare function untrapFocus(): void;
|
package/utils/trapFocus.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/utils/trapFocus.ts"],
|
|
4
|
-
"sourcesContent": ["import { keyCodes } from './keyCodes.js';\nimport { isFunction } from './is.js';\n\nconst FOCUSABLE_ELEMENTS = [\n 'a[href]:not([tabindex^=\"-\"]):not([inert])',\n 'area[href]:not([tabindex^=\"-\"]):not([inert])',\n 'input:not([disabled]):not([inert])',\n 'select:not([disabled]):not([inert])',\n 'textarea:not([disabled]):not([inert])',\n 'button:not([disabled]):not([inert])',\n 'iframe:not([tabindex^=\"-\"]):not([inert])',\n 'audio:not([tabindex^=\"-\"]):not([inert])',\n 'video:not([tabindex^=\"-\"]):not([inert])',\n '[contenteditable]:not([tabindex^=\"-\"]):not([inert])',\n '[tabindex]:not([tabindex^=\"-\"]):not([inert])',\n];\n\nlet focusedBefore;\n\n/**\n * Save the current active element.\n */\nexport function saveActiveElement() {\n focusedBefore = document.activeElement;\n}\n\n/**\n * Trap tab navigation inside the given element.\n *\n * @param {HTMLElement} element The element in which to trap the tabulations.\n * @param {KeyboardEvent} event The keydown or keyup event.\n */\nexport function trapFocus(element: HTMLElement, event: KeyboardEvent) {\n if (event.keyCode !== keyCodes.TAB) {\n return;\n }\n\n // Save the previous focused element\n if (!focusedBefore) {\n focusedBefore = document.activeElement;\n }\n\n const focusableChildren: HTMLElement[] = Array.from(\n element.querySelectorAll(FOCUSABLE_ELEMENTS.join(', ')),\n ) as HTMLElement[];\n const focusedItemIndex =\n document.activeElement instanceof HTMLElement\n ? focusableChildren.indexOf(document.activeElement)\n : -1;\n\n if (!focusableChildren.length) {\n return;\n }\n\n if (focusedItemIndex < 0) {\n focusableChildren[0].focus();\n event.preventDefault();\n }\n\n // If the SHIFT key is being pressed while tabbing (moving backwards) and\n // the currently focused item is the first one, move the focus to the last\n // focusable item from the dialog element\n if (event.shiftKey && focusedItemIndex === 0) {\n focusableChildren.at(-1).focus();\n event.preventDefault();\n }\n\n // If the SHIFT key is not being pressed (moving forwards) and the currently\n // focused item is the last one, move the focus to the first focusable item\n // from the dialog element\n else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {\n focusableChildren[0].focus();\n event.preventDefault();\n }\n}\n\n/**\n * Untrap the tab navigation.\n */\nexport function untrapFocus() {\n if (focusedBefore && isFunction(focusedBefore.focus)) {\n focusedBefore.focus();\n focusedBefore = null;\n }\n}\n"],
|
|
5
|
-
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAE3B,MAAM,qBAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAI;AAKG,SAAS,oBAAoB;AAClC,kBAAgB,SAAS;AAC3B;
|
|
4
|
+
"sourcesContent": ["import { keyCodes } from './keyCodes.js';\nimport { isFunction } from './is.js';\n\nconst FOCUSABLE_ELEMENTS = [\n 'a[href]:not([tabindex^=\"-\"]):not([inert])',\n 'area[href]:not([tabindex^=\"-\"]):not([inert])',\n 'input:not([disabled]):not([inert])',\n 'select:not([disabled]):not([inert])',\n 'textarea:not([disabled]):not([inert])',\n 'button:not([disabled]):not([inert])',\n 'iframe:not([tabindex^=\"-\"]):not([inert])',\n 'audio:not([tabindex^=\"-\"]):not([inert])',\n 'video:not([tabindex^=\"-\"]):not([inert])',\n '[contenteditable]:not([tabindex^=\"-\"]):not([inert])',\n '[tabindex]:not([tabindex^=\"-\"]):not([inert])',\n];\n\nlet focusedBefore;\n\n/**\n * Save the current active element.\n */\nexport function saveActiveElement() {\n focusedBefore = document.activeElement;\n}\n\n/**\n * Trap tab navigation inside the given element.\n *\n * @param {HTMLElement} element The element in which to trap the tabulations.\n * @param {KeyboardEvent} event The keydown or keyup event.\n * @link https://js-toolkit.studiometa.dev/utils/trapFocus.html\n*/\nexport function trapFocus(element: HTMLElement, event: KeyboardEvent) {\n if (event.keyCode !== keyCodes.TAB) {\n return;\n }\n\n // Save the previous focused element\n if (!focusedBefore) {\n focusedBefore = document.activeElement;\n }\n\n const focusableChildren: HTMLElement[] = Array.from(\n element.querySelectorAll(FOCUSABLE_ELEMENTS.join(', ')),\n ) as HTMLElement[];\n const focusedItemIndex =\n document.activeElement instanceof HTMLElement\n ? focusableChildren.indexOf(document.activeElement)\n : -1;\n\n if (!focusableChildren.length) {\n return;\n }\n\n if (focusedItemIndex < 0) {\n focusableChildren[0].focus();\n event.preventDefault();\n }\n\n // If the SHIFT key is being pressed while tabbing (moving backwards) and\n // the currently focused item is the first one, move the focus to the last\n // focusable item from the dialog element\n if (event.shiftKey && focusedItemIndex === 0) {\n focusableChildren.at(-1).focus();\n event.preventDefault();\n }\n\n // If the SHIFT key is not being pressed (moving forwards) and the currently\n // focused item is the last one, move the focus to the first focusable item\n // from the dialog element\n else if (!event.shiftKey && focusedItemIndex === focusableChildren.length - 1) {\n focusableChildren[0].focus();\n event.preventDefault();\n }\n}\n\n/**\n * Untrap the tab navigation.\n * @link https://js-toolkit.studiometa.dev/utils/trapFocus.html\n*/\nexport function untrapFocus() {\n if (focusedBefore && isFunction(focusedBefore.focus)) {\n focusedBefore.focus();\n focusedBefore = null;\n }\n}\n"],
|
|
5
|
+
"mappings": "AAAA,SAAS,gBAAgB;AACzB,SAAS,kBAAkB;AAE3B,MAAM,qBAAqB;AAAA,EACzB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,IAAI;AAKG,SAAS,oBAAoB;AAClC,kBAAgB,SAAS;AAC3B;AASO,SAAS,UAAU,SAAsB,OAAsB;AACpE,MAAI,MAAM,YAAY,SAAS,KAAK;AAClC;AAAA,EACF;AAGA,MAAI,CAAC,eAAe;AAClB,oBAAgB,SAAS;AAAA,EAC3B;AAEA,QAAM,oBAAmC,MAAM;AAAA,IAC7C,QAAQ,iBAAiB,mBAAmB,KAAK,IAAI,CAAC;AAAA,EACxD;AACA,QAAM,mBACJ,SAAS,yBAAyB,cAC9B,kBAAkB,QAAQ,SAAS,aAAa,IAChD;AAEN,MAAI,CAAC,kBAAkB,QAAQ;AAC7B;AAAA,EACF;AAEA,MAAI,mBAAmB,GAAG;AACxB,sBAAkB,CAAC,EAAE,MAAM;AAC3B,UAAM,eAAe;AAAA,EACvB;AAKA,MAAI,MAAM,YAAY,qBAAqB,GAAG;AAC5C,sBAAkB,GAAG,EAAE,EAAE,MAAM;AAC/B,UAAM,eAAe;AAAA,EACvB,WAKS,CAAC,MAAM,YAAY,qBAAqB,kBAAkB,SAAS,GAAG;AAC7E,sBAAkB,CAAC,EAAE,MAAM;AAC3B,UAAM,eAAe;AAAA,EACvB;AACF;AAMO,SAAS,cAAc;AAC5B,MAAI,iBAAiB,WAAW,cAAc,KAAK,GAAG;AACpD,kBAAc,MAAM;AACpB,oBAAgB;AAAA,EAClB;AACF;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/utils/tween.d.ts
CHANGED
|
@@ -78,6 +78,6 @@ export interface TweenOptions {
|
|
|
78
78
|
export declare function normalizeEase(ease: EasingFunction | BezierCurve): EasingFunction;
|
|
79
79
|
/**
|
|
80
80
|
* Tween from 0 to 1.
|
|
81
|
-
* @
|
|
81
|
+
* @link https://js-toolkit.studiometa.dev/utils/tween.html
|
|
82
82
|
*/
|
|
83
83
|
export declare function tween(callback: (progress: number) => unknown, options?: TweenOptions): Tween;
|
package/utils/tween.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../packages/js-toolkit/utils/tween.ts"],
|
|
4
|
-
"sourcesContent": ["import { cubicBezier } from '@motionone/easing';\nimport { lerp, map, clamp01, damp, inertiaFinalValue, spring } from './math/index.js';\nimport { isDefined, isArray, isNumber } from './is.js';\nimport { noop, noopValue as linear } from './noop.js';\nimport { useRaf } from '../services/RafService.js';\nimport type { EasingFunction } from './math/createEases.js';\n\nlet id = 0;\nconst DEFAULT_PROGRESS_PRECISION = 1 / 1e4;\n\nexport type BezierCurve = [number, number, number, number];\n\n/**\n * Controls for a tween.\n */\nexport interface Tween {\n /**\n * Start the tween from the beginning.\n */\n start: () => void;\n /**\n * Finish the tween and set its state to the end.\n */\n finish: () => void;\n /**\n * Pause the tween.\n */\n pause: () => void;\n /**\n * Start the tween from the current paused progress.\n */\n play: () => void;\n /**\n * Set and get the tween's progress.\n */\n progress: (progress?: number) => number;\n}\n\nexport interface TweenOptions {\n /**\n * The duration, in seconds.\n * Defaults to `1`.\n */\n duration?: number;\n /**\n * The delay, in seconds.\n * Defaults to `0`.\n */\n delay?: number;\n /**\n * The easing function or bezier curve to use.\n * Defaults to a linear easing function.\n */\n easing?: EasingFunction | BezierCurve;\n /**\n * The smooth factor. Setting this option to `true` or a `number` will disable the `duration` option.\n */\n smooth?: true | number;\n /**\n * Enable spring transition. Setting this option to `true` or a `number` will disable the `duration` option.\n * If `true`, a default stiffness of 0.1 will be used, if a `number` is given, it will be used instead.\n */\n spring?: true | number;\n /**\n * When spring physics are enabled, use the mass option to make the object heavier or lighter. Defaults to `1`.\n */\n mass?: number;\n /**\n * The precision for when to consider the tween finished.\n * Defaults to `0.00001`.\n */\n precision?: number;\n /**\n * A callback executed on start.\n */\n onStart?: (progress: number) => void;\n /**\n * A callback executed each time the progress is updated.\n */\n onProgress?: (progress: number) => void;\n /**\n * A callback executed when the tween is finished.\n */\n onFinish?: (progress: number) => void;\n}\n\n/**\n * Normalize a easing function with default fallbacks.\n */\nexport function normalizeEase(ease: EasingFunction | BezierCurve): EasingFunction {\n if (!isDefined(ease)) {\n return linear;\n }\n\n if (isArray(ease)) {\n return cubicBezier(...ease);\n }\n\n return ease;\n}\n\n/**\n * Tween from 0 to 1.\n * @
|
|
4
|
+
"sourcesContent": ["import { cubicBezier } from '@motionone/easing';\nimport { lerp, map, clamp01, damp, inertiaFinalValue, spring } from './math/index.js';\nimport { isDefined, isArray, isNumber } from './is.js';\nimport { noop, noopValue as linear } from './noop.js';\nimport { useRaf } from '../services/RafService.js';\nimport type { EasingFunction } from './math/createEases.js';\n\nlet id = 0;\nconst DEFAULT_PROGRESS_PRECISION = 1 / 1e4;\n\nexport type BezierCurve = [number, number, number, number];\n\n/**\n * Controls for a tween.\n */\nexport interface Tween {\n /**\n * Start the tween from the beginning.\n */\n start: () => void;\n /**\n * Finish the tween and set its state to the end.\n */\n finish: () => void;\n /**\n * Pause the tween.\n */\n pause: () => void;\n /**\n * Start the tween from the current paused progress.\n */\n play: () => void;\n /**\n * Set and get the tween's progress.\n */\n progress: (progress?: number) => number;\n}\n\nexport interface TweenOptions {\n /**\n * The duration, in seconds.\n * Defaults to `1`.\n */\n duration?: number;\n /**\n * The delay, in seconds.\n * Defaults to `0`.\n */\n delay?: number;\n /**\n * The easing function or bezier curve to use.\n * Defaults to a linear easing function.\n */\n easing?: EasingFunction | BezierCurve;\n /**\n * The smooth factor. Setting this option to `true` or a `number` will disable the `duration` option.\n */\n smooth?: true | number;\n /**\n * Enable spring transition. Setting this option to `true` or a `number` will disable the `duration` option.\n * If `true`, a default stiffness of 0.1 will be used, if a `number` is given, it will be used instead.\n */\n spring?: true | number;\n /**\n * When spring physics are enabled, use the mass option to make the object heavier or lighter. Defaults to `1`.\n */\n mass?: number;\n /**\n * The precision for when to consider the tween finished.\n * Defaults to `0.00001`.\n */\n precision?: number;\n /**\n * A callback executed on start.\n */\n onStart?: (progress: number) => void;\n /**\n * A callback executed each time the progress is updated.\n */\n onProgress?: (progress: number) => void;\n /**\n * A callback executed when the tween is finished.\n */\n onFinish?: (progress: number) => void;\n}\n\n/**\n * Normalize a easing function with default fallbacks.\n */\nexport function normalizeEase(ease: EasingFunction | BezierCurve): EasingFunction {\n if (!isDefined(ease)) {\n return linear;\n }\n\n if (isArray(ease)) {\n return cubicBezier(...ease);\n }\n\n return ease;\n}\n\n/**\n * Tween from 0 to 1.\n * @link https://js-toolkit.studiometa.dev/utils/tween.html\n */\nexport function tween(callback: (progress: number) => unknown, options: TweenOptions = {}): Tween {\n const raf = useRaf();\n\n let progressValue = 0;\n let easedProgress = 0;\n let velocity = 0;\n\n const isSmooth = isDefined(options.smooth) && (isNumber(options.smooth) || options.smooth);\n const isSpring = isDefined(options.spring) && (isNumber(options.spring) || options.spring);\n const stiffness = isNumber(options.spring) ? options.spring : 0.1;\n const mass = isNumber(options.mass) ? options.mass : 1;\n const damping = isNumber(options.smooth) ? options.smooth : 0.1;\n const precision = options.precision ?? DEFAULT_PROGRESS_PRECISION;\n const ease = normalizeEase(options.easing);\n\n let delay = options.delay ?? 0;\n delay *= 1000;\n let duration = options.duration ?? 1;\n duration *= 1000;\n\n /* eslint-disable @typescript-eslint/no-use-before-define */\n let startTime = getStartTime();\n let endTime = getEndTime(startTime);\n /* eslint-enable @typescript-eslint/no-use-before-define */\n\n const key = `tw-${id}`;\n id += 1;\n\n const { onStart = noop, onProgress = noop, onFinish = noop } = options;\n let isRunning = false;\n\n /**\n * Pause the animation.\n */\n function pause() {\n isRunning = false;\n raf.remove(key);\n }\n\n /**\n * Set the progress value.\n */\n function progress(newProgress: number) {\n if (!isDefined(newProgress)) {\n return easedProgress;\n }\n\n let shouldStop = false;\n\n progressValue = newProgress;\n if (isSpring) {\n [easedProgress, velocity] = spring(\n progressValue,\n easedProgress,\n velocity,\n stiffness,\n damping,\n mass,\n precision,\n );\n } else {\n easedProgress = isSmooth\n ? damp(progressValue, easedProgress, damping, precision)\n : ease(progressValue);\n }\n\n // Stop when reaching precision\n if (Math.abs(1 - easedProgress) < precision) {\n progressValue = 1;\n easedProgress = 1;\n shouldStop = true;\n }\n\n callback(easedProgress);\n onProgress(easedProgress);\n\n if (shouldStop) {\n pause();\n requestAnimationFrame(() => onFinish(easedProgress));\n }\n\n return easedProgress;\n }\n\n /**\n * Loop for rendering the animation.\n */\n function tick(props: { time: number }) {\n progress(clamp01(map(props.time, startTime, endTime, 0, 1)));\n }\n\n function getStartTime() {\n return performance.now() + delay;\n }\n\n function getEndTime(time: number) {\n return isSmooth ? inertiaFinalValue(time, 1) : time + duration;\n }\n\n /**\n * Play the animation.\n */\n function start() {\n onStart(0);\n startTime = getStartTime();\n endTime = getEndTime(startTime);\n progressValue = 0;\n easedProgress = 0;\n isRunning = true;\n\n raf.add(key, tick);\n }\n\n /**\n * Play a paused animation.\n */\n function play() {\n if (isRunning) {\n return;\n }\n\n startTime = getStartTime() - lerp(0, duration, progressValue);\n endTime = getEndTime(startTime);\n isRunning = true;\n\n raf.add(key, tick);\n }\n\n return {\n start,\n finish: () => progress(1),\n pause,\n play,\n progress,\n };\n}\n"],
|
|
5
5
|
"mappings": "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",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|