@studiometa/js-toolkit 2.0.0-beta.1 → 2.0.0-beta.13

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.
Files changed (184) hide show
  1. package/Base/index.cjs +294 -0
  2. package/Base/index.d.ts +27 -1
  3. package/Base/index.js +149 -179
  4. package/Base/managers/ChildrenManager.cjs +124 -0
  5. package/Base/managers/ChildrenManager.js +29 -55
  6. package/Base/managers/EventsManager.cjs +184 -0
  7. package/Base/managers/EventsManager.d.ts +3 -1
  8. package/Base/managers/EventsManager.js +85 -127
  9. package/Base/managers/OptionsManager.cjs +175 -0
  10. package/Base/managers/OptionsManager.d.ts +2 -0
  11. package/Base/managers/OptionsManager.js +46 -88
  12. package/Base/managers/RefsManager.cjs +98 -0
  13. package/Base/managers/RefsManager.d.ts +2 -0
  14. package/Base/managers/RefsManager.js +24 -35
  15. package/Base/managers/ServicesManager.cjs +132 -0
  16. package/Base/managers/ServicesManager.d.ts +29 -4
  17. package/Base/managers/ServicesManager.js +33 -63
  18. package/Base/utils.cjs +45 -0
  19. package/Base/utils.js +12 -11
  20. package/README.md +13 -70
  21. package/decorators/index.cjs +49 -0
  22. package/decorators/index.d.ts +8 -9
  23. package/decorators/index.js +18 -9
  24. package/decorators/withBreakpointManager.cjs +91 -0
  25. package/decorators/withBreakpointManager.js +18 -39
  26. package/decorators/withBreakpointObserver.cjs +116 -0
  27. package/decorators/withBreakpointObserver.js +40 -88
  28. package/decorators/withDrag.cjs +54 -0
  29. package/decorators/withDrag.js +16 -18
  30. package/decorators/withExtraConfig.cjs +44 -0
  31. package/decorators/withExtraConfig.js +11 -12
  32. package/decorators/withIntersectionObserver.cjs +61 -0
  33. package/decorators/withIntersectionObserver.js +23 -31
  34. package/decorators/withMountWhenInView.cjs +68 -0
  35. package/decorators/withMountWhenInView.js +31 -55
  36. package/decorators/withScrolledInView.cjs +112 -0
  37. package/decorators/withScrolledInView.d.ts +4 -1
  38. package/decorators/withScrolledInView.js +77 -73
  39. package/decorators/withVue2.cjs +60 -0
  40. package/decorators/withVue2.js +21 -32
  41. package/helpers/createApp.cjs +56 -0
  42. package/helpers/createApp.js +12 -12
  43. package/helpers/importOnInteraction.cjs +56 -0
  44. package/helpers/importOnInteraction.js +17 -18
  45. package/helpers/importWhenIdle.cjs +52 -0
  46. package/helpers/importWhenIdle.js +13 -17
  47. package/helpers/importWhenVisible.cjs +54 -0
  48. package/helpers/importWhenVisible.js +16 -18
  49. package/helpers/index.cjs +41 -0
  50. package/helpers/index.d.ts +4 -5
  51. package/helpers/index.js +10 -5
  52. package/helpers/utils.cjs +39 -0
  53. package/helpers/utils.js +7 -6
  54. package/index.cjs +38 -0
  55. package/index.d.ts +4 -21
  56. package/index.js +7 -5
  57. package/package.json +14 -3
  58. package/services/Service.cjs +75 -0
  59. package/services/Service.d.ts +22 -17
  60. package/services/Service.js +14 -28
  61. package/services/drag.cjs +194 -0
  62. package/services/drag.d.ts +4 -18
  63. package/services/drag.js +103 -156
  64. package/services/index.cjs +47 -0
  65. package/services/index.d.ts +13 -10
  66. package/services/index.js +16 -8
  67. package/services/key.cjs +101 -0
  68. package/services/key.d.ts +4 -13
  69. package/services/key.js +58 -77
  70. package/services/load.cjs +70 -0
  71. package/services/load.d.ts +3 -13
  72. package/services/load.js +31 -36
  73. package/services/pointer.cjs +159 -0
  74. package/services/pointer.d.ts +4 -13
  75. package/services/pointer.js +91 -121
  76. package/services/raf.cjs +81 -0
  77. package/services/raf.d.ts +3 -13
  78. package/services/raf.js +32 -52
  79. package/services/resize.cjs +106 -0
  80. package/services/resize.d.ts +3 -13
  81. package/services/resize.js +52 -52
  82. package/services/scroll.cjs +129 -0
  83. package/services/scroll.d.ts +3 -13
  84. package/services/scroll.js +75 -89
  85. package/utils/collide/boundingRectToCircle.cjs +38 -0
  86. package/utils/collide/boundingRectToCircle.d.ts +1 -1
  87. package/utils/collide/boundingRectToCircle.js +7 -10
  88. package/utils/collide/collideCircleCircle.cjs +38 -0
  89. package/utils/collide/collideCircleCircle.js +8 -7
  90. package/utils/collide/collideCircleRect.cjs +50 -0
  91. package/utils/collide/collideCircleRect.js +10 -12
  92. package/utils/collide/collidePointCircle.cjs +35 -0
  93. package/utils/collide/collidePointCircle.js +8 -5
  94. package/utils/collide/collidePointRect.cjs +32 -0
  95. package/utils/collide/collidePointRect.js +5 -2
  96. package/utils/collide/collideRectRect.cjs +32 -0
  97. package/utils/collide/collideRectRect.js +5 -2
  98. package/utils/collide/index.cjs +45 -0
  99. package/utils/collide/index.d.ts +6 -7
  100. package/utils/collide/index.js +14 -7
  101. package/utils/css/classes.cjs +48 -0
  102. package/utils/css/classes.js +13 -12
  103. package/utils/css/index.cjs +41 -0
  104. package/utils/css/index.d.ts +4 -5
  105. package/utils/css/index.js +10 -5
  106. package/utils/css/matrix.cjs +33 -0
  107. package/utils/css/matrix.js +6 -5
  108. package/utils/css/styles.cjs +51 -0
  109. package/utils/css/styles.js +13 -12
  110. package/utils/css/transition.cjs +121 -0
  111. package/utils/css/transition.js +62 -117
  112. package/utils/debounce.cjs +38 -0
  113. package/utils/debounce.js +7 -9
  114. package/utils/focusTrap.cjs +88 -0
  115. package/utils/focusTrap.js +30 -21
  116. package/utils/history.cjs +95 -0
  117. package/utils/history.js +28 -57
  118. package/utils/index.cjs +57 -0
  119. package/utils/index.d.ts +12 -35
  120. package/utils/index.js +30 -17
  121. package/utils/keyCodes.cjs +39 -0
  122. package/utils/keyCodes.js +5 -2
  123. package/utils/math/clamp.cjs +32 -0
  124. package/utils/math/clamp.js +5 -2
  125. package/utils/math/clamp01.cjs +38 -0
  126. package/utils/math/clamp01.js +6 -3
  127. package/utils/math/damp.cjs +32 -0
  128. package/utils/math/damp.js +5 -4
  129. package/utils/math/ease.cjs +92 -0
  130. package/utils/math/ease.d.ts +78 -0
  131. package/utils/math/ease.js +66 -0
  132. package/utils/math/index.cjs +48 -0
  133. package/utils/math/index.d.ts +8 -8
  134. package/utils/math/index.js +17 -8
  135. package/utils/math/inertiaFinalValue.cjs +41 -0
  136. package/utils/math/inertiaFinalValue.js +8 -10
  137. package/utils/math/lerp.cjs +32 -0
  138. package/utils/math/lerp.js +5 -2
  139. package/utils/math/map.cjs +32 -0
  140. package/utils/math/map.js +5 -2
  141. package/utils/math/round.cjs +32 -0
  142. package/utils/math/round.js +5 -3
  143. package/utils/memoize.cjs +47 -0
  144. package/utils/memoize.js +10 -19
  145. package/utils/nextFrame.cjs +44 -0
  146. package/utils/nextFrame.js +14 -9
  147. package/utils/object/autoBind.cjs +55 -0
  148. package/utils/object/autoBind.js +12 -22
  149. package/utils/object/getAllProperties.cjs +41 -0
  150. package/utils/object/getAllProperties.js +11 -14
  151. package/utils/object/index.cjs +39 -0
  152. package/utils/object/index.d.ts +3 -4
  153. package/utils/object/index.js +8 -4
  154. package/utils/object/isObject.cjs +32 -0
  155. package/utils/object/isObject.js +6 -3
  156. package/utils/scrollTo.cjs +86 -0
  157. package/utils/scrollTo.js +20 -40
  158. package/utils/string/index.cjs +53 -0
  159. package/utils/string/index.d.ts +10 -11
  160. package/utils/string/index.js +22 -11
  161. package/utils/string/withLeadingCharacters.cjs +38 -0
  162. package/utils/string/withLeadingCharacters.js +7 -4
  163. package/utils/string/withLeadingSlash.cjs +38 -0
  164. package/utils/string/withLeadingSlash.js +7 -4
  165. package/utils/string/withTrailingCharacters.cjs +38 -0
  166. package/utils/string/withTrailingCharacters.js +7 -4
  167. package/utils/string/withTrailingSlash.cjs +38 -0
  168. package/utils/string/withTrailingSlash.js +7 -4
  169. package/utils/string/withoutLeadingCharacters.cjs +32 -0
  170. package/utils/string/withoutLeadingCharacters.js +6 -3
  171. package/utils/string/withoutLeadingCharactersRecursive.cjs +43 -0
  172. package/utils/string/withoutLeadingCharactersRecursive.js +8 -7
  173. package/utils/string/withoutLeadingSlash.cjs +38 -0
  174. package/utils/string/withoutLeadingSlash.js +7 -4
  175. package/utils/string/withoutTrailingCharacters.cjs +32 -0
  176. package/utils/string/withoutTrailingCharacters.js +6 -3
  177. package/utils/string/withoutTrailingCharactersRecursive.cjs +43 -0
  178. package/utils/string/withoutTrailingCharactersRecursive.js +8 -7
  179. package/utils/string/withoutTrailingSlash.cjs +38 -0
  180. package/utils/string/withoutTrailingSlash.js +7 -4
  181. package/utils/throttle.cjs +40 -0
  182. package/utils/throttle.js +9 -9
  183. package/index.modern.js +0 -1
  184. package/index.umd.js +0 -1
@@ -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,48 @@
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
+
29
+ // packages/js-toolkit/utils/math/index.js
30
+ var math_exports = {};
31
+ __export(math_exports, {
32
+ clamp: () => import_clamp.default,
33
+ clamp01: () => import_clamp01.default,
34
+ damp: () => import_damp.default,
35
+ inertiaFinalValue: () => import_inertiaFinalValue.default,
36
+ lerp: () => import_lerp.default,
37
+ map: () => import_map.default,
38
+ round: () => import_round.default
39
+ });
40
+ var import_clamp = __toESM(require("./clamp.cjs"), 1);
41
+ var import_clamp01 = __toESM(require("./clamp01.cjs"), 1);
42
+ var import_damp = __toESM(require("./damp.cjs"), 1);
43
+ var import_inertiaFinalValue = __toESM(require("./inertiaFinalValue.cjs"), 1);
44
+ var import_lerp = __toESM(require("./lerp.cjs"), 1);
45
+ var import_map = __toESM(require("./map.cjs"), 1);
46
+ var import_round = __toESM(require("./round.cjs"), 1);
47
+ __reExport(math_exports, require("./ease.cjs"));
48
+ module.exports = __toCommonJS(math_exports);
@@ -1,8 +1,8 @@
1
- import clamp from "./clamp.js";
2
- import clamp01 from "./clamp01.js";
3
- import damp from "./damp.js";
4
- import inertiaFinalValue from "./inertiaFinalValue.js";
5
- import lerp from "./lerp.js";
6
- import map from "./map.js";
7
- import round from "./round.js";
8
- export { clamp, clamp01, damp, inertiaFinalValue, lerp, map, round };
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";
@@ -1,8 +1,17 @@
1
- import clamp from './clamp.js';
2
- import clamp01 from './clamp01.js';
3
- import damp from './damp.js';
4
- import inertiaFinalValue from './inertiaFinalValue.js';
5
- import lerp from './lerp.js';
6
- import map from './map.js';
7
- import round from './round.js';
8
- export { clamp, clamp01, damp, inertiaFinalValue, lerp, map, round };
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,41 @@
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
+
24
+ // packages/js-toolkit/utils/math/inertiaFinalValue.js
25
+ var inertiaFinalValue_exports = {};
26
+ __export(inertiaFinalValue_exports, {
27
+ default: () => inertiaFinalValue
28
+ });
29
+ function inertiaFinalValue(initialValue, initialDelta, dampFactor = 0.85) {
30
+ if (dampFactor >= 1 || dampFactor <= 0) {
31
+ throw new Error(`The \`factor\` parameter must be a number greater than 0 and smaller than 1, \`${dampFactor}\` given.`);
32
+ }
33
+ let delta = initialDelta;
34
+ let finalValue = initialValue;
35
+ while (Math.abs(delta) > 0.1) {
36
+ finalValue += delta;
37
+ delta *= dampFactor;
38
+ }
39
+ return finalValue;
40
+ }
41
+ module.exports = __toCommonJS(inertiaFinalValue_exports);
@@ -1,17 +1,15 @@
1
- export default function inertiaFinalValue(initialValue, initialDelta) {
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("The `factor` parameter must be a number greater than 0 and smaller than 1, `".concat(dampFactor, "` given."));
3
+ throw new Error(`The \`factor\` parameter must be a number greater than 0 and smaller than 1, \`${dampFactor}\` given.`);
6
4
  }
7
-
8
- var delta = initialDelta;
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,32 @@
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
+
24
+ // packages/js-toolkit/utils/math/lerp.js
25
+ var lerp_exports = {};
26
+ __export(lerp_exports, {
27
+ default: () => lerp
28
+ });
29
+ function lerp(min, max, ratio) {
30
+ return (1 - ratio) * min + ratio * max;
31
+ }
32
+ module.exports = __toCommonJS(lerp_exports);
@@ -1,3 +1,6 @@
1
- export default function lerp(min, max, ratio) {
1
+ function lerp(min, max, ratio) {
2
2
  return (1 - ratio) * min + ratio * max;
3
- }
3
+ }
4
+ export {
5
+ lerp as default
6
+ };
@@ -0,0 +1,32 @@
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
+
24
+ // packages/js-toolkit/utils/math/map.js
25
+ var map_exports = {};
26
+ __export(map_exports, {
27
+ default: () => map
28
+ });
29
+ function map(value, inputMin, inputMax, outputMin, outputMax) {
30
+ return (value - inputMin) * (outputMax - outputMin) / (inputMax - inputMin) + outputMin;
31
+ }
32
+ module.exports = __toCommonJS(map_exports);
package/utils/math/map.js CHANGED
@@ -1,3 +1,6 @@
1
- export default function map(value, inputMin, inputMax, outputMin, outputMax) {
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,32 @@
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
+
24
+ // packages/js-toolkit/utils/math/round.js
25
+ var round_exports = {};
26
+ __export(round_exports, {
27
+ default: () => round
28
+ });
29
+ function round(value, decimals = 0) {
30
+ return Number(value.toFixed(decimals));
31
+ }
32
+ module.exports = __toCommonJS(round_exports);
@@ -1,4 +1,6 @@
1
- export default function round(value) {
2
- var decimals = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
1
+ function round(value, decimals = 0) {
3
2
  return Number(value.toFixed(decimals));
4
- }
3
+ }
4
+ export {
5
+ round as default
6
+ };
@@ -0,0 +1,47 @@
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
+
24
+ // packages/js-toolkit/utils/memoize.js
25
+ var memoize_exports = {};
26
+ __export(memoize_exports, {
27
+ default: () => memoize
28
+ });
29
+ function memoize(fn, { maxAge = Number.POSITIVE_INFINITY, cacheKey = JSON.stringify, cache = /* @__PURE__ */ new Map() } = {}) {
30
+ return function memoized(...args) {
31
+ const key = cacheKey(args);
32
+ const date = Date.now();
33
+ if (cache.has(key)) {
34
+ const cached = cache.get(key);
35
+ if (date - cached.date < maxAge) {
36
+ return cached.data;
37
+ }
38
+ }
39
+ const data = fn(...args);
40
+ cache.set(key, {
41
+ data,
42
+ date: Date.now()
43
+ });
44
+ return data;
45
+ };
46
+ }
47
+ module.exports = __toCommonJS(memoize_exports);
package/utils/memoize.js CHANGED
@@ -1,30 +1,21 @@
1
- export default function memoize(fn) {
2
- var {
3
- maxAge = Number.POSITIVE_INFINITY,
4
- cacheKey = JSON.stringify,
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
- var cached = cache.get(key);
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,44 @@
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
+
24
+ // packages/js-toolkit/utils/nextFrame.js
25
+ var nextFrame_exports = {};
26
+ __export(nextFrame_exports, {
27
+ default: () => nextFrame,
28
+ getCancelRaf: () => getCancelRaf,
29
+ getRaf: () => getRaf
30
+ });
31
+ function getRaf() {
32
+ return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
33
+ }
34
+ function getCancelRaf() {
35
+ return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
36
+ }
37
+ function nextFrame(fn = () => {
38
+ }) {
39
+ const raf = getRaf();
40
+ return new Promise((resolve) => {
41
+ raf(() => raf(() => resolve(fn())));
42
+ });
43
+ }
44
+ module.exports = __toCommonJS(nextFrame_exports);
@@ -1,13 +1,18 @@
1
- export function getRaf() {
2
- return typeof window !== 'undefined' && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
1
+ function getRaf() {
2
+ return typeof window !== "undefined" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : setTimeout;
3
3
  }
4
- export function getCancelRaf() {
5
- return typeof window !== 'undefined' && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
4
+ function getCancelRaf() {
5
+ return typeof window !== "undefined" && window.cancelAnimationFrame ? window.cancelAnimationFrame.bind(window) : clearTimeout;
6
6
  }
7
- export default function nextFrame() {
8
- var fn = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : () => {};
9
- var raf = getRaf();
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,55 @@
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
+
29
+ // packages/js-toolkit/utils/object/autoBind.js
30
+ var autoBind_exports = {};
31
+ __export(autoBind_exports, {
32
+ default: () => autoBind
33
+ });
34
+ var import_getAllProperties = __toESM(require("./getAllProperties.cjs"), 1);
35
+ function autoBind(instance, options) {
36
+ const { exclude, include } = options || {};
37
+ const filter = (key) => {
38
+ const match = (pattern) => typeof pattern === "string" ? key === pattern : pattern.test(key);
39
+ if (include) {
40
+ return include.some(match);
41
+ }
42
+ if (exclude) {
43
+ return !exclude.some(match);
44
+ }
45
+ return true;
46
+ };
47
+ (0, import_getAllProperties.default)(instance).filter(([key]) => key !== "constructor" && filter(key)).forEach(([key, object]) => {
48
+ const descriptor = Object.getOwnPropertyDescriptor(object, key);
49
+ if (descriptor && typeof descriptor.value === "function") {
50
+ instance[key] = instance[key].bind(instance);
51
+ }
52
+ });
53
+ return instance;
54
+ }
55
+ module.exports = __toCommonJS(autoBind_exports);
@@ -1,34 +1,24 @@
1
- import getAllProperties from './getAllProperties.js';
2
- export default function autoBind(instance, options) {
3
- var {
4
- exclude,
5
- include
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
- getAllProperties(instance).filter(_ref => {
23
- var [key] = _ref;
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
+ };