@studiometa/js-toolkit 2.0.0-beta.0 → 2.0.0-beta.12
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 +287 -0
- package/Base/index.d.ts +27 -1
- package/Base/index.js +149 -179
- package/Base/managers/ChildrenManager.cjs +122 -0
- package/Base/managers/ChildrenManager.js +29 -55
- package/Base/managers/EventsManager.cjs +182 -0
- package/Base/managers/EventsManager.d.ts +3 -1
- package/Base/managers/EventsManager.js +85 -127
- package/Base/managers/OptionsManager.cjs +167 -0
- package/Base/managers/OptionsManager.d.ts +2 -0
- package/Base/managers/OptionsManager.js +46 -88
- package/Base/managers/RefsManager.cjs +96 -0
- package/Base/managers/RefsManager.d.ts +2 -0
- package/Base/managers/RefsManager.js +24 -35
- package/Base/managers/ServicesManager.cjs +130 -0
- package/Base/managers/ServicesManager.d.ts +29 -4
- package/Base/managers/ServicesManager.js +33 -63
- package/Base/utils.cjs +43 -0
- package/Base/utils.js +12 -11
- package/README.md +13 -70
- package/decorators/index.cjs +47 -0
- package/decorators/index.d.ts +8 -9
- package/decorators/index.js +18 -9
- package/decorators/withBreakpointManager.cjs +89 -0
- package/decorators/withBreakpointManager.js +18 -39
- package/decorators/withBreakpointObserver.cjs +114 -0
- package/decorators/withBreakpointObserver.js +40 -88
- package/decorators/withDrag.cjs +52 -0
- package/decorators/withDrag.js +16 -18
- package/decorators/withExtraConfig.cjs +42 -0
- package/decorators/withExtraConfig.js +11 -12
- package/decorators/withIntersectionObserver.cjs +59 -0
- package/decorators/withIntersectionObserver.js +23 -31
- package/decorators/withMountWhenInView.cjs +66 -0
- package/decorators/withMountWhenInView.js +31 -55
- package/decorators/withScrolledInView.cjs +110 -0
- package/decorators/withScrolledInView.d.ts +4 -1
- package/decorators/withScrolledInView.js +77 -73
- package/decorators/withVue2.cjs +58 -0
- package/decorators/withVue2.js +21 -32
- package/helpers/createApp.cjs +54 -0
- package/helpers/createApp.js +12 -12
- package/helpers/importOnInteraction.cjs +54 -0
- package/helpers/importOnInteraction.js +17 -18
- package/helpers/importWhenIdle.cjs +50 -0
- package/helpers/importWhenIdle.js +13 -17
- package/helpers/importWhenVisible.cjs +52 -0
- package/helpers/importWhenVisible.js +16 -18
- package/helpers/index.cjs +39 -0
- package/helpers/index.d.ts +4 -5
- package/helpers/index.js +10 -5
- package/helpers/utils.cjs +37 -0
- package/helpers/utils.js +7 -6
- package/index.cjs +36 -0
- package/index.d.ts +4 -21
- package/index.js +7 -5
- package/package.json +14 -3
- package/services/Service.cjs +73 -0
- package/services/Service.d.ts +22 -17
- package/services/Service.js +14 -28
- package/services/drag.cjs +192 -0
- package/services/drag.d.ts +4 -18
- package/services/drag.js +103 -156
- package/services/index.cjs +45 -0
- package/services/index.d.ts +13 -10
- package/services/index.js +16 -8
- package/services/key.cjs +99 -0
- package/services/key.d.ts +4 -13
- package/services/key.js +58 -77
- package/services/load.cjs +68 -0
- package/services/load.d.ts +3 -13
- package/services/load.js +31 -36
- package/services/pointer.cjs +157 -0
- package/services/pointer.d.ts +4 -13
- package/services/pointer.js +91 -121
- package/services/raf.cjs +79 -0
- package/services/raf.d.ts +3 -13
- package/services/raf.js +32 -52
- package/services/resize.cjs +104 -0
- package/services/resize.d.ts +3 -13
- package/services/resize.js +52 -52
- package/services/scroll.cjs +127 -0
- package/services/scroll.d.ts +3 -13
- package/services/scroll.js +75 -89
- package/utils/collide/boundingRectToCircle.cjs +36 -0
- package/utils/collide/boundingRectToCircle.d.ts +1 -1
- package/utils/collide/boundingRectToCircle.js +7 -10
- package/utils/collide/collideCircleCircle.cjs +36 -0
- package/utils/collide/collideCircleCircle.js +8 -7
- package/utils/collide/collideCircleRect.cjs +48 -0
- package/utils/collide/collideCircleRect.js +10 -12
- package/utils/collide/collidePointCircle.cjs +33 -0
- package/utils/collide/collidePointCircle.js +8 -5
- package/utils/collide/collidePointRect.cjs +30 -0
- package/utils/collide/collidePointRect.js +5 -2
- package/utils/collide/collideRectRect.cjs +30 -0
- package/utils/collide/collideRectRect.js +5 -2
- package/utils/collide/index.cjs +43 -0
- package/utils/collide/index.d.ts +6 -7
- package/utils/collide/index.js +14 -7
- package/utils/css/classes.cjs +46 -0
- package/utils/css/classes.js +13 -12
- package/utils/css/index.cjs +39 -0
- package/utils/css/index.d.ts +4 -5
- package/utils/css/index.js +10 -5
- package/utils/css/matrix.cjs +31 -0
- package/utils/css/matrix.js +6 -5
- package/utils/css/styles.cjs +49 -0
- package/utils/css/styles.js +13 -12
- package/utils/css/transition.cjs +119 -0
- package/utils/css/transition.js +62 -117
- package/utils/debounce.cjs +36 -0
- package/utils/debounce.js +7 -9
- package/utils/focusTrap.cjs +86 -0
- package/utils/focusTrap.js +30 -21
- package/utils/history.cjs +93 -0
- package/utils/history.js +28 -57
- package/utils/index.cjs +55 -0
- package/utils/index.d.ts +12 -35
- package/utils/index.js +30 -17
- package/utils/keyCodes.cjs +37 -0
- package/utils/keyCodes.js +5 -2
- package/utils/math/clamp.cjs +30 -0
- package/utils/math/clamp.js +5 -2
- package/utils/math/clamp01.cjs +36 -0
- package/utils/math/clamp01.js +6 -3
- package/utils/math/damp.cjs +30 -0
- package/utils/math/damp.js +5 -4
- package/utils/math/ease.cjs +90 -0
- package/utils/math/ease.d.ts +78 -0
- package/utils/math/ease.js +66 -0
- package/utils/math/index.cjs +46 -0
- package/utils/math/index.d.ts +8 -8
- package/utils/math/index.js +17 -8
- package/utils/math/inertiaFinalValue.cjs +39 -0
- package/utils/math/inertiaFinalValue.js +8 -10
- package/utils/math/lerp.cjs +30 -0
- package/utils/math/lerp.js +5 -2
- package/utils/math/map.cjs +30 -0
- package/utils/math/map.js +5 -2
- package/utils/math/round.cjs +30 -0
- package/utils/math/round.js +5 -3
- package/utils/memoize.cjs +45 -0
- package/utils/memoize.js +10 -19
- package/utils/nextFrame.cjs +42 -0
- package/utils/nextFrame.js +14 -9
- package/utils/object/autoBind.cjs +53 -0
- package/utils/object/autoBind.js +12 -22
- package/utils/object/getAllProperties.cjs +39 -0
- package/utils/object/getAllProperties.js +11 -14
- package/utils/object/index.cjs +37 -0
- package/utils/object/index.d.ts +3 -4
- package/utils/object/index.js +8 -4
- package/utils/object/isObject.cjs +30 -0
- package/utils/object/isObject.js +6 -3
- package/utils/scrollTo.cjs +84 -0
- package/utils/scrollTo.js +20 -40
- package/utils/string/index.cjs +51 -0
- package/utils/string/index.d.ts +10 -11
- package/utils/string/index.js +22 -11
- package/utils/string/withLeadingCharacters.cjs +36 -0
- package/utils/string/withLeadingCharacters.js +7 -4
- package/utils/string/withLeadingSlash.cjs +36 -0
- package/utils/string/withLeadingSlash.js +7 -4
- package/utils/string/withTrailingCharacters.cjs +36 -0
- package/utils/string/withTrailingCharacters.js +7 -4
- package/utils/string/withTrailingSlash.cjs +36 -0
- package/utils/string/withTrailingSlash.js +7 -4
- package/utils/string/withoutLeadingCharacters.cjs +30 -0
- package/utils/string/withoutLeadingCharacters.js +6 -3
- package/utils/string/withoutLeadingCharactersRecursive.cjs +41 -0
- package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
- package/utils/string/withoutLeadingSlash.cjs +36 -0
- package/utils/string/withoutLeadingSlash.js +7 -4
- package/utils/string/withoutTrailingCharacters.cjs +30 -0
- package/utils/string/withoutTrailingCharacters.js +6 -3
- package/utils/string/withoutTrailingCharactersRecursive.cjs +41 -0
- package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
- package/utils/string/withoutTrailingSlash.cjs +36 -0
- package/utils/string/withoutTrailingSlash.js +7 -4
- package/utils/throttle.cjs +38 -0
- package/utils/throttle.js +9 -9
- package/index.modern.js +0 -1
- package/index.umd.js +0 -1
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
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var inertiaFinalValue_exports = {};
|
|
24
|
+
__export(inertiaFinalValue_exports, {
|
|
25
|
+
default: () => inertiaFinalValue
|
|
26
|
+
});
|
|
27
|
+
function inertiaFinalValue(initialValue, initialDelta, dampFactor = 0.85) {
|
|
28
|
+
if (dampFactor >= 1 || dampFactor <= 0) {
|
|
29
|
+
throw new Error(`The \`factor\` parameter must be a number greater than 0 and smaller than 1, \`${dampFactor}\` given.`);
|
|
30
|
+
}
|
|
31
|
+
let delta = initialDelta;
|
|
32
|
+
let finalValue = initialValue;
|
|
33
|
+
while (Math.abs(delta) > 0.1) {
|
|
34
|
+
finalValue += delta;
|
|
35
|
+
delta *= dampFactor;
|
|
36
|
+
}
|
|
37
|
+
return finalValue;
|
|
38
|
+
}
|
|
39
|
+
module.exports = __toCommonJS(inertiaFinalValue_exports);
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
var dampFactor = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0.85;
|
|
3
|
-
|
|
1
|
+
function inertiaFinalValue(initialValue, initialDelta, dampFactor = 0.85) {
|
|
4
2
|
if (dampFactor >= 1 || dampFactor <= 0) {
|
|
5
|
-
throw new Error(
|
|
3
|
+
throw new Error(`The \`factor\` parameter must be a number greater than 0 and smaller than 1, \`${dampFactor}\` given.`);
|
|
6
4
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var finalValue = initialValue;
|
|
10
|
-
|
|
5
|
+
let delta = initialDelta;
|
|
6
|
+
let finalValue = initialValue;
|
|
11
7
|
while (Math.abs(delta) > 0.1) {
|
|
12
8
|
finalValue += delta;
|
|
13
9
|
delta *= dampFactor;
|
|
14
10
|
}
|
|
15
|
-
|
|
16
11
|
return finalValue;
|
|
17
|
-
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
inertiaFinalValue as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var lerp_exports = {};
|
|
24
|
+
__export(lerp_exports, {
|
|
25
|
+
default: () => lerp
|
|
26
|
+
});
|
|
27
|
+
function lerp(min, max, ratio) {
|
|
28
|
+
return (1 - ratio) * min + ratio * max;
|
|
29
|
+
}
|
|
30
|
+
module.exports = __toCommonJS(lerp_exports);
|
package/utils/math/lerp.js
CHANGED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var map_exports = {};
|
|
24
|
+
__export(map_exports, {
|
|
25
|
+
default: () => map
|
|
26
|
+
});
|
|
27
|
+
function map(value, inputMin, inputMax, outputMin, outputMax) {
|
|
28
|
+
return (value - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin;
|
|
29
|
+
}
|
|
30
|
+
module.exports = __toCommonJS(map_exports);
|
package/utils/math/map.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
function map(value, inputMin, inputMax, outputMin, outputMax) {
|
|
2
2
|
return (value - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin;
|
|
3
|
-
}
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
map as default
|
|
6
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var round_exports = {};
|
|
24
|
+
__export(round_exports, {
|
|
25
|
+
default: () => round
|
|
26
|
+
});
|
|
27
|
+
function round(value, decimals = 0) {
|
|
28
|
+
return Number(value.toFixed(decimals));
|
|
29
|
+
}
|
|
30
|
+
module.exports = __toCommonJS(round_exports);
|
package/utils/math/round.js
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var memoize_exports = {};
|
|
24
|
+
__export(memoize_exports, {
|
|
25
|
+
default: () => memoize
|
|
26
|
+
});
|
|
27
|
+
function memoize(fn, { maxAge = Number.POSITIVE_INFINITY, cacheKey = JSON.stringify, cache = /* @__PURE__ */ new Map() } = {}) {
|
|
28
|
+
return function memoized(...args) {
|
|
29
|
+
const key = cacheKey(args);
|
|
30
|
+
const date = Date.now();
|
|
31
|
+
if (cache.has(key)) {
|
|
32
|
+
const cached = cache.get(key);
|
|
33
|
+
if (date - cached.date < maxAge) {
|
|
34
|
+
return cached.data;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const data = fn(...args);
|
|
38
|
+
cache.set(key, {
|
|
39
|
+
data,
|
|
40
|
+
date: Date.now()
|
|
41
|
+
});
|
|
42
|
+
return data;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
module.exports = __toCommonJS(memoize_exports);
|
package/utils/memoize.js
CHANGED
|
@@ -1,30 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
cache = new Map()
|
|
6
|
-
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
7
|
-
return function memoized() {
|
|
8
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
9
|
-
args[_key] = arguments[_key];
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
var key = cacheKey(args);
|
|
13
|
-
var date = Date.now();
|
|
14
|
-
|
|
1
|
+
function memoize(fn, { maxAge = Number.POSITIVE_INFINITY, cacheKey = JSON.stringify, cache = /* @__PURE__ */ new Map() } = {}) {
|
|
2
|
+
return function memoized(...args) {
|
|
3
|
+
const key = cacheKey(args);
|
|
4
|
+
const date = Date.now();
|
|
15
5
|
if (cache.has(key)) {
|
|
16
|
-
|
|
17
|
-
|
|
6
|
+
const cached = cache.get(key);
|
|
18
7
|
if (date - cached.date < maxAge) {
|
|
19
8
|
return cached.data;
|
|
20
9
|
}
|
|
21
10
|
}
|
|
22
|
-
|
|
23
|
-
var data = fn(...args);
|
|
11
|
+
const data = fn(...args);
|
|
24
12
|
cache.set(key, {
|
|
25
13
|
data,
|
|
26
14
|
date: Date.now()
|
|
27
15
|
});
|
|
28
16
|
return data;
|
|
29
17
|
};
|
|
30
|
-
}
|
|
18
|
+
}
|
|
19
|
+
export {
|
|
20
|
+
memoize as default
|
|
21
|
+
};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var nextFrame_exports = {};
|
|
24
|
+
__export(nextFrame_exports, {
|
|
25
|
+
default: () => nextFrame,
|
|
26
|
+
getCancelRaf: () => getCancelRaf,
|
|
27
|
+
getRaf: () => getRaf
|
|
28
|
+
});
|
|
29
|
+
function getRaf() {
|
|
30
|
+
return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
|
|
31
|
+
}
|
|
32
|
+
function getCancelRaf() {
|
|
33
|
+
return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
|
|
34
|
+
}
|
|
35
|
+
function nextFrame(fn = () => {
|
|
36
|
+
}) {
|
|
37
|
+
const raf = getRaf();
|
|
38
|
+
return new Promise((resolve) => {
|
|
39
|
+
raf(() => raf(() => resolve(fn())));
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
module.exports = __toCommonJS(nextFrame_exports);
|
package/utils/nextFrame.js
CHANGED
|
@@ -1,13 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
return typeof window !==
|
|
1
|
+
function getRaf() {
|
|
2
|
+
return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
|
|
3
3
|
}
|
|
4
|
-
|
|
5
|
-
return typeof window !==
|
|
4
|
+
function getCancelRaf() {
|
|
5
|
+
return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
|
|
6
6
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return new Promise(resolve => {
|
|
7
|
+
function nextFrame(fn = () => {
|
|
8
|
+
}) {
|
|
9
|
+
const raf = getRaf();
|
|
10
|
+
return new Promise((resolve) => {
|
|
11
11
|
raf(() => raf(() => resolve(fn())));
|
|
12
12
|
});
|
|
13
|
-
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
nextFrame as default,
|
|
16
|
+
getCancelRaf,
|
|
17
|
+
getRaf
|
|
18
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var autoBind_exports = {};
|
|
29
|
+
__export(autoBind_exports, {
|
|
30
|
+
default: () => autoBind
|
|
31
|
+
});
|
|
32
|
+
var import_getAllProperties = __toESM(require("./getAllProperties.js"), 1);
|
|
33
|
+
function autoBind(instance, options) {
|
|
34
|
+
const { exclude, include } = options || {};
|
|
35
|
+
const filter = (key) => {
|
|
36
|
+
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
37
|
+
if (include) {
|
|
38
|
+
return include.some(match);
|
|
39
|
+
}
|
|
40
|
+
if (exclude) {
|
|
41
|
+
return !exclude.some(match);
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
};
|
|
45
|
+
(0, import_getAllProperties.default)(instance).filter(([key]) => key !== "constructor" && filter(key)).forEach(([key, object]) => {
|
|
46
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
47
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
48
|
+
instance[key] = instance[key].bind(instance);
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return instance;
|
|
52
|
+
}
|
|
53
|
+
module.exports = __toCommonJS(autoBind_exports);
|
package/utils/object/autoBind.js
CHANGED
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import getAllProperties from
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} = options || {};
|
|
7
|
-
|
|
8
|
-
var filter = key => {
|
|
9
|
-
var match = pattern => typeof pattern === 'string' ? key === pattern : pattern.test(key);
|
|
10
|
-
|
|
1
|
+
import getAllProperties from "./getAllProperties.js";
|
|
2
|
+
function autoBind(instance, options) {
|
|
3
|
+
const { exclude, include } = options || {};
|
|
4
|
+
const filter = (key) => {
|
|
5
|
+
const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
|
|
11
6
|
if (include) {
|
|
12
7
|
return include.some(match);
|
|
13
8
|
}
|
|
14
|
-
|
|
15
9
|
if (exclude) {
|
|
16
10
|
return !exclude.some(match);
|
|
17
11
|
}
|
|
18
|
-
|
|
19
12
|
return true;
|
|
20
13
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
return key !== 'constructor' && filter(key);
|
|
25
|
-
}).forEach(_ref2 => {
|
|
26
|
-
var [key, object] = _ref2;
|
|
27
|
-
var descriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
28
|
-
|
|
29
|
-
if (descriptor && typeof descriptor.value === 'function') {
|
|
14
|
+
getAllProperties(instance).filter(([key]) => key !== "constructor" && filter(key)).forEach(([key, object]) => {
|
|
15
|
+
const descriptor = Object.getOwnPropertyDescriptor(object, key);
|
|
16
|
+
if (descriptor && typeof descriptor.value === "function") {
|
|
30
17
|
instance[key] = instance[key].bind(instance);
|
|
31
18
|
}
|
|
32
19
|
});
|
|
33
20
|
return instance;
|
|
34
|
-
}
|
|
21
|
+
}
|
|
22
|
+
export {
|
|
23
|
+
autoBind as default
|
|
24
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var getAllProperties_exports = {};
|
|
24
|
+
__export(getAllProperties_exports, {
|
|
25
|
+
default: () => getAllProperties
|
|
26
|
+
});
|
|
27
|
+
function getAllProperties(object, props = [], testFn = null) {
|
|
28
|
+
const proto = Object.getPrototypeOf(object);
|
|
29
|
+
if (proto === Object.prototype || proto === null) {
|
|
30
|
+
return props;
|
|
31
|
+
}
|
|
32
|
+
let foundProps = Object.getOwnPropertyNames(proto);
|
|
33
|
+
if (typeof testFn === "function") {
|
|
34
|
+
foundProps = foundProps.filter((name) => testFn(name, proto));
|
|
35
|
+
}
|
|
36
|
+
foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);
|
|
37
|
+
return getAllProperties(proto, foundProps, testFn);
|
|
38
|
+
}
|
|
39
|
+
module.exports = __toCommonJS(getAllProperties_exports);
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var proto = Object.getPrototypeOf(object);
|
|
5
|
-
|
|
6
|
-
if (proto === Object.prototype) {
|
|
1
|
+
function getAllProperties(object, props = [], testFn = null) {
|
|
2
|
+
const proto = Object.getPrototypeOf(object);
|
|
3
|
+
if (proto === Object.prototype || proto === null) {
|
|
7
4
|
return props;
|
|
8
5
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
if (typeof testFn === 'function') {
|
|
13
|
-
foundProps = foundProps.filter(name => testFn(name, proto));
|
|
6
|
+
let foundProps = Object.getOwnPropertyNames(proto);
|
|
7
|
+
if (typeof testFn === "function") {
|
|
8
|
+
foundProps = foundProps.filter((name) => testFn(name, proto));
|
|
14
9
|
}
|
|
15
|
-
|
|
16
|
-
foundProps = foundProps.map(name => [name, proto]).reduce((acc, val) => [...acc, val], props);
|
|
10
|
+
foundProps = foundProps.map((name) => [name, proto]).reduce((acc, val) => [...acc, val], props);
|
|
17
11
|
return getAllProperties(proto, foundProps, testFn);
|
|
18
|
-
}
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
getAllProperties as default
|
|
15
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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 __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
13
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(module2))
|
|
15
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
16
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return target;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (module2, isNodeMode) => {
|
|
21
|
+
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", !isNodeMode && module2 && module2.__esModule ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
22
|
+
};
|
|
23
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
24
|
+
return (module2, temp) => {
|
|
25
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
26
|
+
};
|
|
27
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
28
|
+
var object_exports = {};
|
|
29
|
+
__export(object_exports, {
|
|
30
|
+
autoBind: () => import_autoBind.default,
|
|
31
|
+
getAllProperties: () => import_getAllProperties.default,
|
|
32
|
+
isObject: () => import_isObject.default
|
|
33
|
+
});
|
|
34
|
+
var import_autoBind = __toESM(require("./autoBind.js"), 1);
|
|
35
|
+
var import_getAllProperties = __toESM(require("./getAllProperties.js"), 1);
|
|
36
|
+
var import_isObject = __toESM(require("./isObject.js"), 1);
|
|
37
|
+
module.exports = __toCommonJS(object_exports);
|
package/utils/object/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
export { autoBind, getAllProperties, isObject };
|
|
1
|
+
export { default as autoBind } from "./autoBind.js";
|
|
2
|
+
export { default as getAllProperties } from "./getAllProperties.js";
|
|
3
|
+
export { default as isObject } from "./isObject.js";
|
package/utils/object/index.js
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
export {
|
|
1
|
+
import { default as default2 } from "./autoBind.js";
|
|
2
|
+
import { default as default3 } from "./getAllProperties.js";
|
|
3
|
+
import { default as default4 } from "./isObject.js";
|
|
4
|
+
export {
|
|
5
|
+
default2 as autoBind,
|
|
6
|
+
default3 as getAllProperties,
|
|
7
|
+
default4 as isObject
|
|
8
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __reExport = (target, module2, copyDefault, desc) => {
|
|
11
|
+
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(module2))
|
|
13
|
+
if (!__hasOwnProp.call(target, key) && (copyDefault || key !== "default"))
|
|
14
|
+
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return target;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = /* @__PURE__ */ ((cache) => {
|
|
19
|
+
return (module2, temp) => {
|
|
20
|
+
return cache && cache.get(module2) || (temp = __reExport(__markAsModule({}), module2, 1), cache && cache.set(module2, temp), temp);
|
|
21
|
+
};
|
|
22
|
+
})(typeof WeakMap !== "undefined" ? /* @__PURE__ */ new WeakMap() : 0);
|
|
23
|
+
var isObject_exports = {};
|
|
24
|
+
__export(isObject_exports, {
|
|
25
|
+
default: () => isObject
|
|
26
|
+
});
|
|
27
|
+
function isObject(value) {
|
|
28
|
+
return typeof value === "object" && !!value && value.toString() === "[object Object]";
|
|
29
|
+
}
|
|
30
|
+
module.exports = __toCommonJS(isObject_exports);
|
package/utils/object/isObject.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
return typeof value ===
|
|
3
|
-
}
|
|
1
|
+
function isObject(value) {
|
|
2
|
+
return typeof value === "object" && !!value && value.toString() === "[object Object]";
|
|
3
|
+
}
|
|
4
|
+
export {
|
|
5
|
+
isObject as default
|
|
6
|
+
};
|