@studiometa/js-toolkit 2.0.0-beta.8 → 2.0.0-rc.2
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/index.cjs +285 -0
- package/Base/index.d.ts +11 -2
- package/Base/index.js +114 -197
- package/Base/managers/ChildrenManager.cjs +146 -0
- package/Base/managers/ChildrenManager.d.ts +9 -1
- package/Base/managers/ChildrenManager.js +60 -59
- package/Base/managers/EventsManager.cjs +183 -0
- package/Base/managers/EventsManager.js +72 -112
- package/Base/managers/OptionsManager.cjs +174 -0
- package/Base/managers/OptionsManager.d.ts +9 -5
- package/Base/managers/OptionsManager.js +60 -90
- package/Base/managers/RefsManager.cjs +99 -0
- package/Base/managers/RefsManager.js +30 -35
- package/Base/managers/ServicesManager.cjs +131 -0
- package/Base/managers/ServicesManager.js +39 -67
- package/Base/utils.cjs +41 -0
- package/Base/utils.js +12 -11
- package/README.md +13 -70
- package/decorators/index.cjs +45 -0
- package/decorators/index.d.ts +9 -9
- package/decorators/index.js +20 -9
- package/decorators/withBreakpointManager.cjs +85 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +115 -0
- package/decorators/withBreakpointObserver.js +44 -86
- package/decorators/withDrag.cjs +53 -0
- package/decorators/withDrag.js +24 -26
- package/decorators/withExtraConfig.cjs +43 -0
- package/decorators/withExtraConfig.js +17 -12
- package/decorators/withFreezedOptions.cjs +37 -0
- package/decorators/withFreezedOptions.d.ts +14 -0
- package/decorators/withFreezedOptions.js +15 -0
- package/decorators/withIntersectionObserver.cjs +62 -0
- package/decorators/withIntersectionObserver.js +29 -32
- package/decorators/withMountWhenInView.cjs +69 -0
- package/decorators/withMountWhenInView.js +31 -52
- package/decorators/withScrolledInView.cjs +114 -0
- package/decorators/withScrolledInView.d.ts +2 -1
- package/decorators/withScrolledInView.js +35 -39
- package/decorators/withVue2.cjs +61 -0
- package/decorators/withVue2.js +27 -32
- package/helpers/createApp.cjs +52 -0
- package/helpers/createApp.d.ts +2 -2
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +52 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +49 -0
- package/helpers/importWhenIdle.js +14 -17
- package/helpers/importWhenVisible.cjs +50 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +35 -0
- package/helpers/index.d.ts +4 -5
- package/helpers/index.js +10 -5
- package/helpers/utils.cjs +35 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +33 -0
- package/index.d.ts +4 -21
- package/index.js +7 -5
- package/package.json +14 -4
- package/services/Service.cjs +76 -0
- package/services/Service.js +19 -32
- package/services/drag.cjs +213 -0
- package/services/drag.d.ts +1 -0
- package/services/drag.js +64 -68
- package/services/index.cjs +41 -0
- package/services/index.d.ts +7 -8
- package/services/index.js +16 -8
- package/services/key.cjs +104 -0
- package/services/key.js +28 -36
- package/services/load.cjs +72 -0
- package/services/load.js +17 -19
- package/services/pointer.cjs +162 -0
- package/services/pointer.js +43 -60
- package/services/raf.cjs +83 -0
- package/services/raf.js +20 -28
- package/services/resize.cjs +108 -0
- package/services/resize.js +33 -42
- package/services/scroll.cjs +131 -0
- package/services/scroll.js +26 -35
- package/utils/collide/boundingRectToCircle.cjs +34 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +34 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +46 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +31 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +28 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +28 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +39 -0
- package/utils/collide/index.d.ts +6 -7
- package/utils/collide/index.js +14 -7
- package/utils/css/classes.cjs +47 -0
- package/utils/css/classes.d.ts +10 -9
- package/utils/css/classes.js +18 -14
- package/utils/css/index.cjs +38 -0
- package/utils/css/index.d.ts +4 -5
- package/utils/css/index.js +13 -5
- package/utils/css/matrix.cjs +30 -0
- package/utils/css/matrix.js +7 -5
- package/utils/css/styles.cjs +44 -0
- package/utils/css/styles.d.ts +6 -18
- package/utils/css/styles.js +12 -12
- package/utils/css/transition.cjs +120 -0
- package/utils/css/transition.d.ts +15 -9
- package/utils/css/transition.js +70 -119
- package/utils/debounce.cjs +34 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +82 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +89 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +54 -0
- package/utils/index.d.ts +14 -35
- package/utils/index.js +32 -17
- package/utils/keyCodes.cjs +35 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +28 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +32 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +28 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +88 -0
- package/utils/math/ease.d.ts +78 -0
- package/utils/math/ease.js +66 -0
- package/utils/math/index.cjs +43 -0
- package/utils/math/index.d.ts +8 -8
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +37 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +28 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +28 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +28 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +43 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +38 -0
- package/utils/nextFrame.d.ts +4 -3
- package/utils/nextFrame.js +13 -10
- package/utils/nextMicrotask.cjs +28 -0
- package/utils/nextMicrotask.d.ts +8 -0
- package/utils/nextMicrotask.js +6 -0
- package/utils/nextTick.cjs +30 -0
- package/utils/nextTick.d.ts +8 -0
- package/utils/nextTick.js +8 -0
- package/utils/object/autoBind.cjs +49 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +37 -0
- package/utils/object/getAllProperties.js +10 -13
- package/utils/object/index.cjs +33 -0
- package/utils/object/index.d.ts +3 -4
- package/utils/object/index.js +8 -4
- package/utils/object/isObject.cjs +28 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +80 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +47 -0
- package/utils/string/index.d.ts +10 -11
- package/utils/string/index.js +22 -11
- package/utils/string/withLeadingCharacters.cjs +32 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +32 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +32 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +32 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +28 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +32 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +28 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +37 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +32 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +36 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
package/utils/index.cjs
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
|
|
23
|
+
// packages/js-toolkit/utils/index.js
|
|
24
|
+
var utils_exports = {};
|
|
25
|
+
__export(utils_exports, {
|
|
26
|
+
debounce: () => import_debounce.default,
|
|
27
|
+
focusTrap: () => import_focusTrap.default,
|
|
28
|
+
historyPush: () => import_history.push,
|
|
29
|
+
historyReplace: () => import_history.replace,
|
|
30
|
+
keyCodes: () => import_keyCodes.default,
|
|
31
|
+
memoize: () => import_memoize.default,
|
|
32
|
+
nextFrame: () => import_nextFrame.default,
|
|
33
|
+
nextMicrotask: () => import_nextMicrotask.default,
|
|
34
|
+
nextTick: () => import_nextTick.default,
|
|
35
|
+
objectToURLSearchParams: () => import_history.objectToURLSearchParams,
|
|
36
|
+
scrollTo: () => import_scrollTo.default,
|
|
37
|
+
throttle: () => import_throttle.default
|
|
38
|
+
});
|
|
39
|
+
module.exports = __toCommonJS(utils_exports);
|
|
40
|
+
var import_debounce = __toESM(require("./debounce.cjs"), 1);
|
|
41
|
+
var import_focusTrap = __toESM(require("./focusTrap.cjs"), 1);
|
|
42
|
+
var import_keyCodes = __toESM(require("./keyCodes.cjs"), 1);
|
|
43
|
+
var import_memoize = __toESM(require("./memoize.cjs"), 1);
|
|
44
|
+
var import_nextFrame = __toESM(require("./nextFrame.cjs"), 1);
|
|
45
|
+
var import_nextTick = __toESM(require("./nextTick.cjs"), 1);
|
|
46
|
+
var import_nextMicrotask = __toESM(require("./nextMicrotask.cjs"), 1);
|
|
47
|
+
var import_throttle = __toESM(require("./throttle.cjs"), 1);
|
|
48
|
+
var import_scrollTo = __toESM(require("./scrollTo.cjs"), 1);
|
|
49
|
+
__reExport(utils_exports, require("./css/index.cjs"), module.exports);
|
|
50
|
+
var import_history = require("./history.cjs");
|
|
51
|
+
__reExport(utils_exports, require("./collide/index.cjs"), module.exports);
|
|
52
|
+
__reExport(utils_exports, require("./math/index.cjs"), module.exports);
|
|
53
|
+
__reExport(utils_exports, require("./string/index.cjs"), module.exports);
|
|
54
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/index.d.ts
CHANGED
|
@@ -1,35 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
import { inertiaFinalValue } from "./math/index.js";
|
|
16
|
-
import { lerp } from "./math/index.js";
|
|
17
|
-
import { map } from "./math/index.js";
|
|
18
|
-
import { round } from "./math/index.js";
|
|
19
|
-
import { withLeadingCharacters } from "./string/index.js";
|
|
20
|
-
import { withLeadingSlash } from "./string/index.js";
|
|
21
|
-
import { withoutLeadingCharacters } from "./string/index.js";
|
|
22
|
-
import { withoutLeadingCharactersRecursive } from "./string/index.js";
|
|
23
|
-
import { withoutLeadingSlash } from "./string/index.js";
|
|
24
|
-
import { withoutTrailingCharacters } from "./string/index.js";
|
|
25
|
-
import { withoutTrailingCharactersRecursive } from "./string/index.js";
|
|
26
|
-
import { withoutTrailingSlash } from "./string/index.js";
|
|
27
|
-
import { withTrailingCharacters } from "./string/index.js";
|
|
28
|
-
import { withTrailingSlash } from "./string/index.js";
|
|
29
|
-
import debounce from "./debounce.js";
|
|
30
|
-
import focusTrap from "./focusTrap.js";
|
|
31
|
-
import keyCodes from "./keyCodes.js";
|
|
32
|
-
import memoize from "./memoize.js";
|
|
33
|
-
import nextFrame from "./nextFrame.js";
|
|
34
|
-
import throttle from "./throttle.js";
|
|
35
|
-
export { matrix, transition, collidePointRect, collideRectRect, boundingRectToCircle, collideCircleRect, collideCircleCircle, collidePointCircle, objectToURLSearchParams, historyPush, historyReplace, clamp, clamp01, damp, inertiaFinalValue, lerp, map, round, withLeadingCharacters, withLeadingSlash, withoutLeadingCharacters, withoutLeadingCharactersRecursive, withoutLeadingSlash, withoutTrailingCharacters, withoutTrailingCharactersRecursive, withoutTrailingSlash, withTrailingCharacters, withTrailingSlash, debounce, focusTrap, keyCodes, memoize, nextFrame, throttle };
|
|
1
|
+
export { default as debounce } from "./debounce.js";
|
|
2
|
+
export { default as focusTrap } from "./focusTrap.js";
|
|
3
|
+
export { default as keyCodes } from "./keyCodes.js";
|
|
4
|
+
export { default as memoize } from "./memoize.js";
|
|
5
|
+
export { default as nextFrame } from "./nextFrame.js";
|
|
6
|
+
export { default as nextTick } from "./nextTick.js";
|
|
7
|
+
export { default as nextMicrotask } from "./nextMicrotask.js";
|
|
8
|
+
export { default as throttle } from "./throttle.js";
|
|
9
|
+
export { default as scrollTo } from "./scrollTo.js";
|
|
10
|
+
export * from "./css/index.js";
|
|
11
|
+
export * from "./collide/index.js";
|
|
12
|
+
export * from "./math/index.js";
|
|
13
|
+
export * from "./string/index.js";
|
|
14
|
+
export { objectToURLSearchParams, push as historyPush, replace as historyReplace } from "./history.js";
|
package/utils/index.js
CHANGED
|
@@ -1,17 +1,32 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export
|
|
17
|
-
export
|
|
1
|
+
import { default as default2 } from "./debounce.js";
|
|
2
|
+
import { default as default3 } from "./focusTrap.js";
|
|
3
|
+
import { default as default4 } from "./keyCodes.js";
|
|
4
|
+
import { default as default5 } from "./memoize.js";
|
|
5
|
+
import { default as default6 } from "./nextFrame.js";
|
|
6
|
+
import { default as default7 } from "./nextTick.js";
|
|
7
|
+
import { default as default8 } from "./nextMicrotask.js";
|
|
8
|
+
import { default as default9 } from "./throttle.js";
|
|
9
|
+
import { default as default10 } from "./scrollTo.js";
|
|
10
|
+
export * from "./css/index.js";
|
|
11
|
+
import {
|
|
12
|
+
objectToURLSearchParams,
|
|
13
|
+
push,
|
|
14
|
+
replace
|
|
15
|
+
} from "./history.js";
|
|
16
|
+
export * from "./collide/index.js";
|
|
17
|
+
export * from "./math/index.js";
|
|
18
|
+
export * from "./string/index.js";
|
|
19
|
+
export {
|
|
20
|
+
default2 as debounce,
|
|
21
|
+
default3 as focusTrap,
|
|
22
|
+
push as historyPush,
|
|
23
|
+
replace as historyReplace,
|
|
24
|
+
default4 as keyCodes,
|
|
25
|
+
default5 as memoize,
|
|
26
|
+
default6 as nextFrame,
|
|
27
|
+
default8 as nextMicrotask,
|
|
28
|
+
default7 as nextTick,
|
|
29
|
+
objectToURLSearchParams,
|
|
30
|
+
default10 as scrollTo,
|
|
31
|
+
default9 as throttle
|
|
32
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/keyCodes.js
|
|
20
|
+
var keyCodes_exports = {};
|
|
21
|
+
__export(keyCodes_exports, {
|
|
22
|
+
default: () => keyCodes_default
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(keyCodes_exports);
|
|
25
|
+
var keyCodes_default = {
|
|
26
|
+
ENTER: 13,
|
|
27
|
+
SPACE: 32,
|
|
28
|
+
TAB: 9,
|
|
29
|
+
ESC: 27,
|
|
30
|
+
LEFT: 37,
|
|
31
|
+
UP: 38,
|
|
32
|
+
RIGHT: 39,
|
|
33
|
+
DOWN: 40
|
|
34
|
+
};
|
|
35
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/keyCodes.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/math/clamp.js
|
|
20
|
+
var clamp_exports = {};
|
|
21
|
+
__export(clamp_exports, {
|
|
22
|
+
default: () => clamp
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(clamp_exports);
|
|
25
|
+
function clamp(value, min, max) {
|
|
26
|
+
return min < max ? value < min ? min : value > max ? max : value : value < max ? max : value > min ? min : value;
|
|
27
|
+
}
|
|
28
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/clamp.js
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
20
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
21
|
+
|
|
22
|
+
// packages/js-toolkit/utils/math/clamp01.js
|
|
23
|
+
var clamp01_exports = {};
|
|
24
|
+
__export(clamp01_exports, {
|
|
25
|
+
default: () => clamp01
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(clamp01_exports);
|
|
28
|
+
var import_clamp = __toESM(require("./clamp.cjs"), 1);
|
|
29
|
+
function clamp01(value) {
|
|
30
|
+
return (0, import_clamp.default)(value, 0, 1);
|
|
31
|
+
}
|
|
32
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/clamp01.js
CHANGED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/math/damp.js
|
|
20
|
+
var damp_exports = {};
|
|
21
|
+
__export(damp_exports, {
|
|
22
|
+
default: () => damp
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(damp_exports);
|
|
25
|
+
function damp(targetValue, currentValue, factor = 0.5, precision = 0.01) {
|
|
26
|
+
return Math.abs(targetValue - currentValue) < precision ? targetValue : currentValue + (targetValue - currentValue) * factor;
|
|
27
|
+
}
|
|
28
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/damp.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
var factor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.5;
|
|
3
|
-
var precision = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0.01;
|
|
1
|
+
function damp(targetValue, currentValue, factor = 0.5, precision = 0.01) {
|
|
4
2
|
return Math.abs(targetValue - currentValue) < precision ? targetValue : currentValue + (targetValue - currentValue) * factor;
|
|
5
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
damp as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// packages/js-toolkit/utils/math/ease.js
|
|
20
|
+
var ease_exports = {};
|
|
21
|
+
__export(ease_exports, {
|
|
22
|
+
createEaseInOut: () => createEaseInOut,
|
|
23
|
+
createEaseOut: () => createEaseOut,
|
|
24
|
+
easeInCirc: () => easeInCirc,
|
|
25
|
+
easeInCubic: () => easeInCubic,
|
|
26
|
+
easeInExpo: () => easeInExpo,
|
|
27
|
+
easeInOutCirc: () => easeInOutCirc,
|
|
28
|
+
easeInOutCubic: () => easeInOutCubic,
|
|
29
|
+
easeInOutExpo: () => easeInOutExpo,
|
|
30
|
+
easeInOutQuad: () => easeInOutQuad,
|
|
31
|
+
easeInOutQuart: () => easeInOutQuart,
|
|
32
|
+
easeInOutQuint: () => easeInOutQuint,
|
|
33
|
+
easeInOutSine: () => easeInOutSine,
|
|
34
|
+
easeInQuad: () => easeInQuad,
|
|
35
|
+
easeInQuart: () => easeInQuart,
|
|
36
|
+
easeInQuint: () => easeInQuint,
|
|
37
|
+
easeInSine: () => easeInSine,
|
|
38
|
+
easeOutCirc: () => easeOutCirc,
|
|
39
|
+
easeOutCubic: () => easeOutCubic,
|
|
40
|
+
easeOutExpo: () => easeOutExpo,
|
|
41
|
+
easeOutQuad: () => easeOutQuad,
|
|
42
|
+
easeOutQuart: () => easeOutQuart,
|
|
43
|
+
easeOutQuint: () => easeOutQuint,
|
|
44
|
+
easeOutSine: () => easeOutSine
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(ease_exports);
|
|
47
|
+
function createEaseOut(easeIn) {
|
|
48
|
+
return (progress) => 1 - easeIn(1 - progress);
|
|
49
|
+
}
|
|
50
|
+
function createEaseInOut(easeIn) {
|
|
51
|
+
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
52
|
+
}
|
|
53
|
+
function easeInQuad(progress) {
|
|
54
|
+
return progress ** 2;
|
|
55
|
+
}
|
|
56
|
+
var easeOutQuad = createEaseOut(easeInQuad);
|
|
57
|
+
var easeInOutQuad = createEaseInOut(easeInQuad);
|
|
58
|
+
function easeInCubic(progress) {
|
|
59
|
+
return progress ** 3;
|
|
60
|
+
}
|
|
61
|
+
var easeOutCubic = createEaseOut(easeInCubic);
|
|
62
|
+
var easeInOutCubic = createEaseInOut(easeInCubic);
|
|
63
|
+
function easeInQuart(progress) {
|
|
64
|
+
return progress ** 4;
|
|
65
|
+
}
|
|
66
|
+
var easeOutQuart = createEaseOut(easeInQuart);
|
|
67
|
+
var easeInOutQuart = createEaseInOut(easeInQuart);
|
|
68
|
+
function easeInQuint(progress) {
|
|
69
|
+
return progress ** 5;
|
|
70
|
+
}
|
|
71
|
+
var easeOutQuint = createEaseOut(easeInQuint);
|
|
72
|
+
var easeInOutQuint = createEaseInOut(easeInQuint);
|
|
73
|
+
function easeInSine(progress) {
|
|
74
|
+
return progress === 1 ? 1 : -Math.cos(progress * Math.PI / 2) + 1;
|
|
75
|
+
}
|
|
76
|
+
var easeOutSine = createEaseOut(easeInSine);
|
|
77
|
+
var easeInOutSine = createEaseInOut(easeInSine);
|
|
78
|
+
function easeInCirc(progress) {
|
|
79
|
+
return -(Math.sqrt(1 - progress * progress) - 1);
|
|
80
|
+
}
|
|
81
|
+
var easeOutCirc = createEaseOut(easeInCirc);
|
|
82
|
+
var easeInOutCirc = createEaseInOut(easeInCirc);
|
|
83
|
+
function easeInExpo(progress) {
|
|
84
|
+
return 2 ** (10 * (progress - 1));
|
|
85
|
+
}
|
|
86
|
+
var easeOutExpo = createEaseOut(easeInExpo);
|
|
87
|
+
var easeInOutExpo = createEaseInOut(easeInExpo);
|
|
88
|
+
if (module.exports.default) module.exports = module.exports.default;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {(progress: number) => number} EasingFunction
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Create an out easing function.
|
|
6
|
+
*
|
|
7
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
8
|
+
* @returns {EasingFunction} The out function.
|
|
9
|
+
*/
|
|
10
|
+
export function createEaseOut(easeIn: EasingFunction): EasingFunction;
|
|
11
|
+
/**
|
|
12
|
+
* Create an in-out easing function.
|
|
13
|
+
*
|
|
14
|
+
* @param {EasingFunction} easeIn The ease in function.
|
|
15
|
+
* @return {EasingFunction} The in-out function.
|
|
16
|
+
*/
|
|
17
|
+
export function createEaseInOut(easeIn: EasingFunction): EasingFunction;
|
|
18
|
+
/**
|
|
19
|
+
* @type {EasingFunction}
|
|
20
|
+
*/
|
|
21
|
+
export function easeInQuad(progress: number): number;
|
|
22
|
+
/**
|
|
23
|
+
* Ease in cubic.
|
|
24
|
+
*
|
|
25
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
26
|
+
* @return {number} Eased value between 0 and 1.
|
|
27
|
+
*/
|
|
28
|
+
export function easeInCubic(progress: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Ease in quart.
|
|
31
|
+
*
|
|
32
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
33
|
+
* @return {number} Eased value between 0 and 1.
|
|
34
|
+
*/
|
|
35
|
+
export function easeInQuart(progress: number): number;
|
|
36
|
+
/**
|
|
37
|
+
* Ease in quint.
|
|
38
|
+
*
|
|
39
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
40
|
+
* @return {number} Eased value between 0 and 1.
|
|
41
|
+
*/
|
|
42
|
+
export function easeInQuint(progress: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Ease in sine.
|
|
45
|
+
*
|
|
46
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
47
|
+
* @return {number} Eased value between 0 and 1.
|
|
48
|
+
*/
|
|
49
|
+
export function easeInSine(progress: number): number;
|
|
50
|
+
/**
|
|
51
|
+
* Ease in circ.
|
|
52
|
+
*
|
|
53
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
54
|
+
* @return {number} Eased value between 0 and 1.
|
|
55
|
+
*/
|
|
56
|
+
export function easeInCirc(progress: number): number;
|
|
57
|
+
/**
|
|
58
|
+
* Ease in exponential.
|
|
59
|
+
*
|
|
60
|
+
* @param {number} progress Progress value betwen 0 and 1.
|
|
61
|
+
* @return {number} Eased value between 0 and 1.
|
|
62
|
+
*/
|
|
63
|
+
export function easeInExpo(progress: number): number;
|
|
64
|
+
export function easeOutQuad(progress: number): number;
|
|
65
|
+
export function easeInOutQuad(progress: number): number;
|
|
66
|
+
export function easeOutCubic(progress: number): number;
|
|
67
|
+
export function easeInOutCubic(progress: number): number;
|
|
68
|
+
export function easeOutQuart(progress: number): number;
|
|
69
|
+
export function easeInOutQuart(progress: number): number;
|
|
70
|
+
export function easeOutQuint(progress: number): number;
|
|
71
|
+
export function easeInOutQuint(progress: number): number;
|
|
72
|
+
export function easeOutSine(progress: number): number;
|
|
73
|
+
export function easeInOutSine(progress: number): number;
|
|
74
|
+
export function easeOutCirc(progress: number): number;
|
|
75
|
+
export function easeInOutCirc(progress: number): number;
|
|
76
|
+
export function easeOutExpo(progress: number): number;
|
|
77
|
+
export function easeInOutExpo(progress: number): number;
|
|
78
|
+
export type EasingFunction = (progress: number) => number;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
function createEaseOut(easeIn) {
|
|
2
|
+
return (progress) => 1 - easeIn(1 - progress);
|
|
3
|
+
}
|
|
4
|
+
function createEaseInOut(easeIn) {
|
|
5
|
+
return (progress) => progress === 0 ? 0 : progress === 1 ? 1 : progress < 0.5 ? easeIn(progress * 2) / 2 : 1 - easeIn((1 - progress) * 2) / 2;
|
|
6
|
+
}
|
|
7
|
+
function easeInQuad(progress) {
|
|
8
|
+
return progress ** 2;
|
|
9
|
+
}
|
|
10
|
+
const easeOutQuad = createEaseOut(easeInQuad);
|
|
11
|
+
const easeInOutQuad = createEaseInOut(easeInQuad);
|
|
12
|
+
function easeInCubic(progress) {
|
|
13
|
+
return progress ** 3;
|
|
14
|
+
}
|
|
15
|
+
const easeOutCubic = createEaseOut(easeInCubic);
|
|
16
|
+
const easeInOutCubic = createEaseInOut(easeInCubic);
|
|
17
|
+
function easeInQuart(progress) {
|
|
18
|
+
return progress ** 4;
|
|
19
|
+
}
|
|
20
|
+
const easeOutQuart = createEaseOut(easeInQuart);
|
|
21
|
+
const easeInOutQuart = createEaseInOut(easeInQuart);
|
|
22
|
+
function easeInQuint(progress) {
|
|
23
|
+
return progress ** 5;
|
|
24
|
+
}
|
|
25
|
+
const easeOutQuint = createEaseOut(easeInQuint);
|
|
26
|
+
const easeInOutQuint = createEaseInOut(easeInQuint);
|
|
27
|
+
function easeInSine(progress) {
|
|
28
|
+
return progress === 1 ? 1 : -Math.cos(progress * Math.PI / 2) + 1;
|
|
29
|
+
}
|
|
30
|
+
const easeOutSine = createEaseOut(easeInSine);
|
|
31
|
+
const easeInOutSine = createEaseInOut(easeInSine);
|
|
32
|
+
function easeInCirc(progress) {
|
|
33
|
+
return -(Math.sqrt(1 - progress * progress) - 1);
|
|
34
|
+
}
|
|
35
|
+
const easeOutCirc = createEaseOut(easeInCirc);
|
|
36
|
+
const easeInOutCirc = createEaseInOut(easeInCirc);
|
|
37
|
+
function easeInExpo(progress) {
|
|
38
|
+
return 2 ** (10 * (progress - 1));
|
|
39
|
+
}
|
|
40
|
+
const easeOutExpo = createEaseOut(easeInExpo);
|
|
41
|
+
const easeInOutExpo = createEaseInOut(easeInExpo);
|
|
42
|
+
export {
|
|
43
|
+
createEaseInOut,
|
|
44
|
+
createEaseOut,
|
|
45
|
+
easeInCirc,
|
|
46
|
+
easeInCubic,
|
|
47
|
+
easeInExpo,
|
|
48
|
+
easeInOutCirc,
|
|
49
|
+
easeInOutCubic,
|
|
50
|
+
easeInOutExpo,
|
|
51
|
+
easeInOutQuad,
|
|
52
|
+
easeInOutQuart,
|
|
53
|
+
easeInOutQuint,
|
|
54
|
+
easeInOutSine,
|
|
55
|
+
easeInQuad,
|
|
56
|
+
easeInQuart,
|
|
57
|
+
easeInQuint,
|
|
58
|
+
easeInSine,
|
|
59
|
+
easeOutCirc,
|
|
60
|
+
easeOutCubic,
|
|
61
|
+
easeOutExpo,
|
|
62
|
+
easeOutQuad,
|
|
63
|
+
easeOutQuart,
|
|
64
|
+
easeOutQuint,
|
|
65
|
+
easeOutSine
|
|
66
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target, mod));
|
|
21
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
22
|
+
|
|
23
|
+
// packages/js-toolkit/utils/math/index.js
|
|
24
|
+
var math_exports = {};
|
|
25
|
+
__export(math_exports, {
|
|
26
|
+
clamp: () => import_clamp.default,
|
|
27
|
+
clamp01: () => import_clamp01.default,
|
|
28
|
+
damp: () => import_damp.default,
|
|
29
|
+
inertiaFinalValue: () => import_inertiaFinalValue.default,
|
|
30
|
+
lerp: () => import_lerp.default,
|
|
31
|
+
map: () => import_map.default,
|
|
32
|
+
round: () => import_round.default
|
|
33
|
+
});
|
|
34
|
+
module.exports = __toCommonJS(math_exports);
|
|
35
|
+
var import_clamp = __toESM(require("./clamp.cjs"), 1);
|
|
36
|
+
var import_clamp01 = __toESM(require("./clamp01.cjs"), 1);
|
|
37
|
+
var import_damp = __toESM(require("./damp.cjs"), 1);
|
|
38
|
+
var import_inertiaFinalValue = __toESM(require("./inertiaFinalValue.cjs"), 1);
|
|
39
|
+
var import_lerp = __toESM(require("./lerp.cjs"), 1);
|
|
40
|
+
var import_map = __toESM(require("./map.cjs"), 1);
|
|
41
|
+
var import_round = __toESM(require("./round.cjs"), 1);
|
|
42
|
+
__reExport(math_exports, require("./ease.cjs"), module.exports);
|
|
43
|
+
if (module.exports.default) module.exports = module.exports.default;
|
package/utils/math/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export
|
|
1
|
+
export { default as clamp } from "./clamp.js";
|
|
2
|
+
export { default as clamp01 } from "./clamp01.js";
|
|
3
|
+
export { default as damp } from "./damp.js";
|
|
4
|
+
export { default as inertiaFinalValue } from "./inertiaFinalValue.js";
|
|
5
|
+
export { default as lerp } from "./lerp.js";
|
|
6
|
+
export { default as map } from "./map.js";
|
|
7
|
+
export { default as round } from "./round.js";
|
|
8
|
+
export * from "./ease.js";
|
package/utils/math/index.js
CHANGED
|
@@ -1,8 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
export
|
|
1
|
+
import { default as default2 } from "./clamp.js";
|
|
2
|
+
import { default as default3 } from "./clamp01.js";
|
|
3
|
+
import { default as default4 } from "./damp.js";
|
|
4
|
+
import { default as default5 } from "./inertiaFinalValue.js";
|
|
5
|
+
import { default as default6 } from "./lerp.js";
|
|
6
|
+
import { default as default7 } from "./map.js";
|
|
7
|
+
import { default as default8 } from "./round.js";
|
|
8
|
+
export * from "./ease.js";
|
|
9
|
+
export {
|
|
10
|
+
default2 as clamp,
|
|
11
|
+
default3 as clamp01,
|
|
12
|
+
default4 as damp,
|
|
13
|
+
default5 as inertiaFinalValue,
|
|
14
|
+
default6 as lerp,
|
|
15
|
+
default7 as map,
|
|
16
|
+
default8 as round
|
|
17
|
+
};
|