@studiometa/js-toolkit 2.0.0-beta.7 → 2.0.0-rc.1

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