@supermousejs/utils 2.1.0 → 2.2.0
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/CHANGELOG.md +74 -49
- package/LICENSE.md +21 -21
- package/README.md +14 -15
- package/dist/css.d.ts +12 -0
- package/dist/css.d.ts.map +1 -0
- package/dist/doctor.d.ts +5 -0
- package/dist/doctor.d.ts.map +1 -0
- package/dist/dom.d.ts +58 -0
- package/dist/dom.d.ts.map +1 -0
- package/dist/effects.d.ts +14 -0
- package/dist/effects.d.ts.map +1 -0
- package/dist/index.d.ts +10 -227
- package/dist/index.d.ts.map +1 -0
- package/dist/index.mjs +92 -92
- package/dist/index.umd.js +1 -7
- package/dist/layers.d.ts +15 -0
- package/dist/layers.d.ts.map +1 -0
- package/dist/math.d.ts +38 -0
- package/dist/math.d.ts.map +1 -0
- package/dist/options.d.ts +11 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/plugin.d.ts +34 -0
- package/dist/plugin.d.ts.map +1 -0
- package/package.json +12 -3
- package/src/css.ts +11 -11
- package/src/doctor.ts +47 -49
- package/src/dom.ts +64 -50
- package/src/effects.ts +5 -6
- package/src/index.ts +10 -10
- package/src/layers.ts +17 -17
- package/src/math.ts +1 -1
- package/src/options.ts +22 -22
- package/src/plugin.ts +16 -16
- package/tsconfig.json +9 -13
- package/tsconfig.tsbuildinfo +1 -0
- package/vite.config.ts +22 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,49 +1,74 @@
|
|
|
1
|
-
# @supermousejs/utils
|
|
2
|
-
|
|
3
|
-
## 2.
|
|
4
|
-
|
|
5
|
-
### Minor Changes
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
- Updated
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
1
|
+
# @supermousejs/utils
|
|
2
|
+
|
|
3
|
+
## 2.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 9fe1a7b: - Implemented idiomatic approach to using supermouse/utils
|
|
8
|
+
- Rewrote `applyStyles`, `setTransform` and `setStyles` to share a global cache registry
|
|
9
|
+
- 9fa6ece: Add `injectStyles` to safely handle injecting global CSS styles into the document head
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 6d70c18: remove legacy package and update supermouse domain in readme
|
|
14
|
+
- 14fb5b6: Updated tsconfig to be reference-compliant with core, utils and zoetrope when required
|
|
15
|
+
- Updated dependencies [6d70c18]
|
|
16
|
+
- Updated dependencies [2590af3]
|
|
17
|
+
- Updated dependencies [14fb5b6]
|
|
18
|
+
- @supermousejs/core@2.1.0
|
|
19
|
+
|
|
20
|
+
## 2.1.1
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- 67f771b: Add relevant npm metadata to package.json file
|
|
25
|
+
- Updated dependencies [67f771b]
|
|
26
|
+
- @supermousejs/core@2.0.5
|
|
27
|
+
|
|
28
|
+
## 2.1.0
|
|
29
|
+
|
|
30
|
+
### Minor Changes
|
|
31
|
+
|
|
32
|
+
- 0a1652d: fixed build architecture and updated plugin metadata
|
|
33
|
+
|
|
34
|
+
## 2.0.4
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
|
|
39
|
+
- Updated dependencies [993dc67]
|
|
40
|
+
- @supermousejs/core@2.0.4
|
|
41
|
+
|
|
42
|
+
## 2.0.3
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Updated dependencies
|
|
47
|
+
- @supermousejs/core@2.0.3
|
|
48
|
+
|
|
49
|
+
## 2.0.2
|
|
50
|
+
|
|
51
|
+
### Patch Changes
|
|
52
|
+
|
|
53
|
+
- ae219a0: Update READMEs with correct link to documentation
|
|
54
|
+
- Updated dependencies [ae219a0]
|
|
55
|
+
- @supermousejs/core@2.0.2
|
|
56
|
+
|
|
57
|
+
## 2.0.1
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Add minimal README.md files to packages
|
|
62
|
+
- Updated dependencies
|
|
63
|
+
- @supermousejs/core@2.0.1
|
|
64
|
+
|
|
65
|
+
## 2.0.0
|
|
66
|
+
|
|
67
|
+
### Major Changes
|
|
68
|
+
|
|
69
|
+
- Initial v2.0.0 release
|
|
70
|
+
|
|
71
|
+
### Patch Changes
|
|
72
|
+
|
|
73
|
+
- Updated dependencies
|
|
74
|
+
- @supermousejs/core@2.0.0
|
package/LICENSE.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Sijibomi Olusunmbola
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Sijibomi Olusunmbola
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
- **
|
|
10
|
-
- **
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
Full documentation and interactive playground available at [supermouse](https://supermouse.vercel.app) or [check out the repo](https://github.com/Whitestar14/supermouse-js).
|
|
1
|
+
# @supermousejs/utils
|
|
2
|
+
|
|
3
|
+
Shared utilities and helpers for the Supermouse ecosystem.
|
|
4
|
+
Used primarily by plugin authors.
|
|
5
|
+
|
|
6
|
+
## Features
|
|
7
|
+
|
|
8
|
+
- **Math:** `lerp`, `damp` (frame-independent), `angle`, `dist`.
|
|
9
|
+
- **DOM:** `createActor`, `setStyle` (cached), `setTransform`.
|
|
10
|
+
- **Plugin:** `definePlugin` helper for type-safe plugin creation.
|
|
11
|
+
|
|
12
|
+
## Documentation
|
|
13
|
+
|
|
14
|
+
Full documentation and interactive playground available at [supermouse](https://supermouse.js.org) or [check out the repo](https://github.com/Whitestar14/supermouse-js).
|
package/dist/css.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Common cubic-bezier easing strings for CSS transitions.
|
|
3
|
+
*/
|
|
4
|
+
export declare const Easings: {
|
|
5
|
+
/** Good for entrance animations (starts fast, slows down) */
|
|
6
|
+
readonly EASE_OUT_EXPO: "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
7
|
+
/** Good for elastic/bouncy UI elements */
|
|
8
|
+
readonly ELASTIC_OUT: "cubic-bezier(0.34, 1.56, 0.64, 1)";
|
|
9
|
+
/** Standard smooth movement */
|
|
10
|
+
readonly SMOOTH: "ease-out";
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=css.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../src/css.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,OAAO;IAClB,6DAA6D;;IAE7D,0CAA0C;;IAE1C,+BAA+B;;CAEvB,CAAC"}
|
package/dist/doctor.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../src/doctor.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,wBAAgB,MAAM,SA2CrB"}
|
package/dist/dom.d.ts
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Injects global CSS styles into the document head safely.
|
|
3
|
+
* Checks for existing IDs to prevent duplication during SPA routing or HMR.
|
|
4
|
+
*
|
|
5
|
+
* @param id A unique identifier for this style block
|
|
6
|
+
* @param css A string of CSS rules to inject.
|
|
7
|
+
*/
|
|
8
|
+
export declare const injectStyles: (id: string, css: string) => void;
|
|
9
|
+
/**
|
|
10
|
+
* Smart Style Setter (Batch).
|
|
11
|
+
* Only writes to the DOM if the value has actually changed.
|
|
12
|
+
* @param el The element to style
|
|
13
|
+
* @param styles An object of CSS properties and values
|
|
14
|
+
*/
|
|
15
|
+
export declare function applyStyles(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
|
|
16
|
+
/**
|
|
17
|
+
* Smart Style Setter (Single).
|
|
18
|
+
* Proxies to applyStyles for consistency.
|
|
19
|
+
* @param el The element to style
|
|
20
|
+
* @param property The CSS property to set
|
|
21
|
+
* @param value The value to set for the property
|
|
22
|
+
*/
|
|
23
|
+
export declare function setStyle(el: HTMLElement, property: keyof CSSStyleDeclaration, value: string | number): void;
|
|
24
|
+
/**
|
|
25
|
+
* Universal Transform Setter.
|
|
26
|
+
* Handles centering (-50%) automatically.
|
|
27
|
+
*
|
|
28
|
+
* @param el The element
|
|
29
|
+
* @param x X Position (px)
|
|
30
|
+
* @param y Y Position (px)
|
|
31
|
+
* @param rotation Rotation (deg) - Default 0
|
|
32
|
+
* @param scaleX Scale X - Default 1
|
|
33
|
+
* @param scaleY Scale Y - Default 1
|
|
34
|
+
* @param skewX Skew X (deg) - Default 0
|
|
35
|
+
* @param skewY Skew Y (deg) - Default 0
|
|
36
|
+
*/
|
|
37
|
+
export declare function setTransform(el: HTMLElement, x: number, y: number, rotation?: number, scaleX?: number, scaleY?: number, skewX?: number, skewY?: number): void;
|
|
38
|
+
/**
|
|
39
|
+
* Calculates the bounding rectangle of an element relative to a container.
|
|
40
|
+
*/
|
|
41
|
+
export declare function projectRect(element: HTMLElement, container?: HTMLElement): DOMRect;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a standard Supermouse actor element with optimal performance settings.
|
|
44
|
+
* Includes absolute positioning, pointer-events: none, and will-change: transform.
|
|
45
|
+
*
|
|
46
|
+
* @param tagName The HTML tag to create (default: 'div')
|
|
47
|
+
*/
|
|
48
|
+
export declare function createActor(tagName?: string): HTMLElement;
|
|
49
|
+
/**
|
|
50
|
+
* Creates a circular HTML div using the standard actor base.
|
|
51
|
+
*/
|
|
52
|
+
export declare function createCircle(size: number, color: string): HTMLDivElement;
|
|
53
|
+
/**
|
|
54
|
+
* Legacy alias for createActor.
|
|
55
|
+
* @deprecated Use createActor() instead.
|
|
56
|
+
*/
|
|
57
|
+
export declare function createDiv(): HTMLDivElement;
|
|
58
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../src/dom.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,EAAE,KAAK,MAAM,SAQnD,CAAC;AAKF;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,mBAAmB,CAAC,QAgBhF;AAED;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,EAAE,EAAE,WAAW,EACf,QAAQ,EAAE,MAAM,mBAAmB,EACnC,KAAK,EAAE,MAAM,GAAG,MAAM,QAGvB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,YAAY,CAC1B,EAAE,EAAE,WAAW,EACf,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,QAAQ,GAAE,MAAU,EACpB,MAAM,GAAE,MAAU,EAClB,MAAM,GAAE,MAAU,EAClB,KAAK,GAAE,MAAU,EACjB,KAAK,GAAE,MAAU,QAKlB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,WAAW,EAAE,SAAS,GAAE,WAA2B,GAAG,OAAO,CAYjG;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,GAAE,MAAc,GAAG,WAAW,CAYhE;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,cAAc,CASxE;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,cAAc,CAE1C"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Calculates Rotation and Scale based on velocity to create a "Squash and Stretch" effect.
|
|
3
|
+
*
|
|
4
|
+
* @param vx Velocity X
|
|
5
|
+
* @param vy Velocity Y
|
|
6
|
+
* @param intensity Stretch factor (default: 0.004)
|
|
7
|
+
* @param maxStretch Max stretch percentage (default: 0.5 = 150% length)
|
|
8
|
+
*/
|
|
9
|
+
export declare function getVelocityDistortion(vx: number, vy: number, intensity?: number, maxStretch?: number): {
|
|
10
|
+
rotation: number;
|
|
11
|
+
scaleX: number;
|
|
12
|
+
scaleY: number;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=effects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../src/effects.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,SAAS,SAAQ,EAAE,UAAU,SAAM;;;;EAuBhG"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,227 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Applies a dictionary of styles to an HTMLElement.
|
|
13
|
-
*/
|
|
14
|
-
declare function applyStyles(el: HTMLElement, styles: Partial<CSSStyleDeclaration>): void;
|
|
15
|
-
|
|
16
|
-
export declare interface BasePluginOptions {
|
|
17
|
-
name?: string;
|
|
18
|
-
isEnabled?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Constrains a value between a minimum and maximum.
|
|
23
|
-
*/
|
|
24
|
-
declare function clamp(value: number, min: number, max: number): number;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Creates a standard Supermouse actor element with optimal performance settings.
|
|
28
|
-
* Includes absolute positioning, pointer-events: none, and will-change: transform.
|
|
29
|
-
*
|
|
30
|
-
* @param tagName The HTML tag to create (default: 'div')
|
|
31
|
-
*/
|
|
32
|
-
declare function createActor(tagName?: string): HTMLElement;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Creates a circular HTML div using the standard actor base.
|
|
36
|
-
*/
|
|
37
|
-
declare function createCircle(size: number, color: string): HTMLDivElement;
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Legacy alias for createActor.
|
|
41
|
-
* @deprecated Use createActor() instead.
|
|
42
|
-
*/
|
|
43
|
-
declare function createDiv(): HTMLDivElement;
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Frame-rate independent damping (Time-based Lerp).
|
|
47
|
-
* Ensures smooth animation consistent across 60hz, 120hz, etc.
|
|
48
|
-
*
|
|
49
|
-
* @param a Current value
|
|
50
|
-
* @param b Target value
|
|
51
|
-
* @param lambda Smoothing factor (approx 1-20). Higher is faster.
|
|
52
|
-
* @param dt Delta time in seconds (not milliseconds)
|
|
53
|
-
*/
|
|
54
|
-
declare function damp(a: number, b: number, lambda: number, dt: number): number;
|
|
55
|
-
|
|
56
|
-
export declare function definePlugin<E extends HTMLElement, O extends BasePluginOptions>(config: VisualConfig<E, O>, userOptions?: O): SupermousePlugin;
|
|
57
|
-
|
|
58
|
-
export declare function definePlugin(config: LogicConfig, userOptions?: BasePluginOptions): SupermousePlugin;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Calculates the distance (hypotenuse) between two points (or magnitude of a vector).
|
|
62
|
-
* If x2/y2 are omitted, calculates magnitude of vector x1/y1.
|
|
63
|
-
*/
|
|
64
|
-
declare function dist(x1: number, y1: number, x2?: number, y2?: number): number;
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Supermouse Doctor
|
|
68
|
-
* A diagnostic utility to find common CSS conflicts that cause "Double Cursor" glitches.
|
|
69
|
-
*/
|
|
70
|
-
export declare function doctor(): void;
|
|
71
|
-
|
|
72
|
-
declare namespace dom {
|
|
73
|
-
export {
|
|
74
|
-
applyStyles,
|
|
75
|
-
setStyle,
|
|
76
|
-
setTransform,
|
|
77
|
-
projectRect,
|
|
78
|
-
createActor,
|
|
79
|
-
createCircle,
|
|
80
|
-
createDiv
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
export { dom }
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Common cubic-bezier easing strings for CSS transitions.
|
|
87
|
-
*/
|
|
88
|
-
export declare const Easings: {
|
|
89
|
-
/** Good for entrance animations (starts fast, slows down) */
|
|
90
|
-
readonly EASE_OUT_EXPO: "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
91
|
-
/** Good for elastic/bouncy UI elements */
|
|
92
|
-
readonly ELASTIC_OUT: "cubic-bezier(0.34, 1.56, 0.64, 1)";
|
|
93
|
-
/** Standard smooth movement */
|
|
94
|
-
readonly SMOOTH: "ease-out";
|
|
95
|
-
};
|
|
96
|
-
|
|
97
|
-
declare namespace effects {
|
|
98
|
-
export {
|
|
99
|
-
getVelocityDistortion
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export { effects }
|
|
103
|
-
|
|
104
|
-
/**
|
|
105
|
-
* Calculates Rotation and Scale based on velocity to create a "Squash and Stretch" effect.
|
|
106
|
-
*
|
|
107
|
-
* @param vx Velocity X
|
|
108
|
-
* @param vy Velocity Y
|
|
109
|
-
* @param intensity Stretch factor (default: 0.004)
|
|
110
|
-
* @param maxStretch Max stretch percentage (default: 0.5 = 150% length)
|
|
111
|
-
*/
|
|
112
|
-
declare function getVelocityDistortion(vx: number, vy: number, intensity?: number, maxStretch?: number): {
|
|
113
|
-
rotation: number;
|
|
114
|
-
scaleX: number;
|
|
115
|
-
scaleY: number;
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Standard Z-Index layers for the Supermouse ecosystem.
|
|
120
|
-
* Relative to the Supermouse Container.
|
|
121
|
-
*/
|
|
122
|
-
export declare const Layers: {
|
|
123
|
-
/** The top-most layer. For text, tooltips, and crucial UI. */
|
|
124
|
-
readonly OVERLAY: "400";
|
|
125
|
-
/** The main cursor layer. For the primary Dot/Pointer. */
|
|
126
|
-
readonly CURSOR: "300";
|
|
127
|
-
/** The secondary layer. For Rings, brackets, or followers. */
|
|
128
|
-
readonly FOLLOWER: "200";
|
|
129
|
-
/** The background layer. For trails, sparkles, and particles. */
|
|
130
|
-
readonly TRACE: "100";
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Linear Interpolation between two values.
|
|
135
|
-
*/
|
|
136
|
-
declare function lerp(start: number, end: number, factor: number): number;
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Linear Interpolation between two angles in degrees, taking the shortest path.
|
|
140
|
-
* Handles wrap-around at 360 degrees.
|
|
141
|
-
*/
|
|
142
|
-
declare function lerpAngle(start: number, end: number, factor: number): number;
|
|
143
|
-
|
|
144
|
-
declare interface LogicConfig {
|
|
145
|
-
name: string;
|
|
146
|
-
priority?: number;
|
|
147
|
-
install?: (app: Supermouse) => void;
|
|
148
|
-
update?: (app: Supermouse, deltaTime: number) => void;
|
|
149
|
-
destroy?: (app: Supermouse) => void;
|
|
150
|
-
onEnable?: (app: Supermouse) => void;
|
|
151
|
-
onDisable?: (app: Supermouse) => void;
|
|
152
|
-
create?: never;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
declare namespace math {
|
|
156
|
-
export {
|
|
157
|
-
lerp,
|
|
158
|
-
damp,
|
|
159
|
-
lerpAngle,
|
|
160
|
-
random,
|
|
161
|
-
clamp,
|
|
162
|
-
dist,
|
|
163
|
-
angle
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
export { math }
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Returns a function that always resolves the option value.
|
|
170
|
-
* Eliminates 'typeof' checks inside the render loop by normalizing
|
|
171
|
-
* static values into getter functions during initialization.
|
|
172
|
-
*
|
|
173
|
-
* @param option The option passed by the user
|
|
174
|
-
* @param defaultValue Fallback value
|
|
175
|
-
*/
|
|
176
|
-
export declare function normalize<T>(option: ValueOrGetter<T> | undefined, defaultValue: T): (state: MouseState) => T;
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Calculates the bounding rectangle of an element relative to a container.
|
|
180
|
-
* Useful for logic plugins when the cursor is confined to a specific div.
|
|
181
|
-
*/
|
|
182
|
-
declare function projectRect(element: HTMLElement, container?: HTMLElement): DOMRect;
|
|
183
|
-
|
|
184
|
-
/**
|
|
185
|
-
* Returns a random number between min and max.
|
|
186
|
-
* Usage: math.random(10, 20) -> 14.5
|
|
187
|
-
*/
|
|
188
|
-
declare function random(min: number, max: number): number;
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* Smart Style Setter.
|
|
192
|
-
* Only writes to the DOM if the value has actually changed.
|
|
193
|
-
*/
|
|
194
|
-
declare function setStyle(el: HTMLElement, property: keyof CSSStyleDeclaration, value: string | number): void;
|
|
195
|
-
|
|
196
|
-
/**
|
|
197
|
-
* Universal Transform Setter.
|
|
198
|
-
* Handles centering (-50%) automatically.
|
|
199
|
-
*
|
|
200
|
-
* @param el The element
|
|
201
|
-
* @param x X Position (px)
|
|
202
|
-
* @param y Y Position (px)
|
|
203
|
-
* @param rotation Rotation (deg) - Default 0
|
|
204
|
-
* @param scaleX Scale X - Default 1
|
|
205
|
-
* @param scaleY Scale Y - Default 1
|
|
206
|
-
* @param skewX Skew X (deg) - Default 0
|
|
207
|
-
* @param skewY Skew Y (deg) - Default 0
|
|
208
|
-
*/
|
|
209
|
-
declare function setTransform(el: HTMLElement, x: number, y: number, rotation?: number, scaleX?: number, scaleY?: number, skewX?: number, skewY?: number): void;
|
|
210
|
-
|
|
211
|
-
declare interface VisualConfig<E extends HTMLElement, O extends object> {
|
|
212
|
-
name: string;
|
|
213
|
-
/** Automatically register this attribute selector */
|
|
214
|
-
selector?: string;
|
|
215
|
-
/** Create and return the DOM Element */
|
|
216
|
-
create: (app: Supermouse) => E;
|
|
217
|
-
/** Map option keys to CSS properties */
|
|
218
|
-
styles?: Partial<Record<keyof O, keyof CSSStyleDeclaration>>;
|
|
219
|
-
/** Update loop with access to the element */
|
|
220
|
-
update?: (app: Supermouse, element: E, deltaTime: number) => void;
|
|
221
|
-
onEnable?: (app: Supermouse, element: E) => void;
|
|
222
|
-
onDisable?: (app: Supermouse, element: E) => void;
|
|
223
|
-
cleanup?: (element: E) => void;
|
|
224
|
-
destroy?: never;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
export { }
|
|
1
|
+
import * as math from "./math";
|
|
2
|
+
import * as dom from "./dom";
|
|
3
|
+
import * as effects from "./effects";
|
|
4
|
+
export { math, dom, effects };
|
|
5
|
+
export * from './layers';
|
|
6
|
+
export * from './css';
|
|
7
|
+
export * from './plugin';
|
|
8
|
+
export * from './options';
|
|
9
|
+
export * from './doctor';
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,GAAG,MAAM,OAAO,CAAC;AAC7B,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,CAAC;AAC9B,cAAc,UAAU,CAAC;AACzB,cAAc,OAAO,CAAC;AACtB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|