@studiometa/js-toolkit 2.2.2 → 2.2.3

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 (45) hide show
  1. package/Base/index.cjs +3 -4
  2. package/Base/index.js +1 -2
  3. package/Base/managers/ServicesManager.cjs +4 -5
  4. package/Base/managers/ServicesManager.js +4 -5
  5. package/Base/utils.cjs +1 -5
  6. package/Base/utils.d.ts +0 -8
  7. package/Base/utils.js +1 -5
  8. package/package.json +1 -1
  9. package/services/drag.cjs +126 -148
  10. package/services/drag.d.ts +10 -10
  11. package/services/drag.js +125 -148
  12. package/services/index.cjs +3 -1
  13. package/services/index.d.ts +1 -0
  14. package/services/index.js +3 -1
  15. package/services/key.cjs +48 -63
  16. package/services/key.d.ts +0 -8
  17. package/services/key.js +47 -63
  18. package/services/load.cjs +24 -40
  19. package/services/load.d.ts +0 -8
  20. package/services/load.js +23 -37
  21. package/services/pointer.cjs +73 -103
  22. package/services/pointer.d.ts +1 -9
  23. package/services/pointer.js +72 -100
  24. package/services/raf.cjs +36 -53
  25. package/services/raf.d.ts +0 -8
  26. package/services/raf.js +36 -54
  27. package/services/resize.cjs +59 -68
  28. package/services/resize.d.ts +0 -7
  29. package/services/resize.js +58 -68
  30. package/services/scroll.cjs +49 -71
  31. package/services/scroll.js +48 -71
  32. package/services/service.cjs +68 -0
  33. package/services/service.d.ts +18 -0
  34. package/services/service.js +46 -0
  35. package/utils/css/animate.cjs +3 -7
  36. package/utils/css/animate.js +2 -6
  37. package/utils/index.cjs +1 -0
  38. package/utils/index.d.ts +1 -0
  39. package/utils/index.js +1 -0
  40. package/utils/noop.cjs +31 -0
  41. package/utils/noop.d.ts +12 -0
  42. package/utils/noop.js +9 -0
  43. package/services/Service.cjs +0 -76
  44. package/services/Service.d.ts +0 -76
  45. package/services/Service.js +0 -55
@@ -1,76 +0,0 @@
1
- /**
2
- * Service abstract class
3
- */
4
- export default class Service {
5
- /**
6
- * Map containing the callbacks.
7
- * @type {Map<string, Function>}
8
- */
9
- callbacks: Map<string, Function>;
10
- /**
11
- * State flag.
12
- * @type {boolean}
13
- */
14
- isInit: boolean;
15
- /**
16
- * @type {unknown}
17
- */
18
- props: unknown;
19
- /**
20
- * Method to update the services properties.
21
- * This method MUST be implemented by the service extending this class.
22
- *
23
- * @param {...any} args
24
- * @returns {this['props']}
25
- */
26
- updateProps(...args: any[]): unknown;
27
- /**
28
- * Method to initialize the service behaviors.
29
- * This method MUST be implemented by the service extending this class.
30
- *
31
- * @returns {void}
32
- */
33
- init(): void;
34
- /**
35
- * Method to kill the service behaviors.
36
- * This method MUST be implemented by the service extending this class.
37
- *
38
- * @returns {void}
39
- */
40
- kill(): void;
41
- /**
42
- * Add a callback.
43
- *
44
- * @param {string} key The callback's identifier
45
- * @param {Function} callback The callback function
46
- * @returns {void}
47
- */
48
- add(key: string, callback: Function): void;
49
- /**
50
- * Test if a callback with the given key has already been added.
51
- *
52
- * @param {string} key The identifier to test
53
- * @returns {boolean} Whether or not the identifier already exists
54
- */
55
- has(key: string): boolean;
56
- /**
57
- * Get the callback tied to the given key.
58
- *
59
- * @param {string} key The identifier to get
60
- * @returns {Function} The callback function
61
- */
62
- get(key: string): Function;
63
- /**
64
- * Remove the callback tied to the given key.
65
- *
66
- * @param {string} key The identifier to remove
67
- */
68
- remove(key: string): void;
69
- /**
70
- * Trigger each added callback with the given arguments.
71
- *
72
- * @param {...any} args All the arguments to apply to the callback
73
- * @returns {this} The current instance
74
- */
75
- trigger(...args: any[]): this;
76
- }
@@ -1,55 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => {
4
- __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
- return value;
6
- };
7
- class Service {
8
- constructor() {
9
- __publicField(this, "callbacks", /* @__PURE__ */ new Map());
10
- __publicField(this, "isInit", false);
11
- __publicField(this, "props");
12
- }
13
- updateProps(...args) {
14
- this.props = args;
15
- throw new Error("The `updateProps` method must be implemented.");
16
- }
17
- init() {
18
- throw new Error("The `init` method must be implemented.");
19
- }
20
- kill() {
21
- throw new Error("The `kill` method must be implemented.");
22
- }
23
- add(key, callback) {
24
- if (this.has(key)) {
25
- throw new Error(`A callback with the key \`${key}\` has already been registered.`);
26
- }
27
- if (this.callbacks.size === 0 && !this.isInit) {
28
- this.init();
29
- this.isInit = true;
30
- }
31
- this.callbacks.set(key, callback);
32
- }
33
- has(key) {
34
- return this.callbacks.has(key);
35
- }
36
- get(key) {
37
- return this.callbacks.get(key);
38
- }
39
- remove(key) {
40
- this.callbacks.delete(key);
41
- if (this.callbacks.size === 0 && this.isInit) {
42
- this.kill();
43
- this.isInit = false;
44
- }
45
- }
46
- trigger(...args) {
47
- this.callbacks.forEach(function forEachCallback(callback) {
48
- callback(...args);
49
- });
50
- return this;
51
- }
52
- }
53
- export {
54
- Service as default
55
- };