supermousejs 2.1.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 ADDED
@@ -0,0 +1,42 @@
1
+ # supermousejs
2
+
3
+ ## 2.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 0a1652d: fixed build architecture and updated plugin metadata
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies [0a1652d]
12
+ - @supermousejs/ring@2.1.0
13
+ - @supermousejs/dot@2.1.0
14
+
15
+ ## 2.0.2
16
+
17
+ ### Patch Changes
18
+
19
+ - Fixed export options causing build failure
20
+
21
+ ## 2.0.1
22
+
23
+ ### Patch Changes
24
+
25
+ - 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
26
+ - Updated dependencies [993dc67]
27
+ - @supermousejs/core@2.0.4
28
+ - @supermousejs/ring@2.0.4
29
+ - @supermousejs/dot@2.0.4
30
+
31
+ ## 2.0.0
32
+
33
+ ### Major Changes
34
+
35
+ - Initialized Supermousejs canon package
36
+
37
+ ### Patch Changes
38
+
39
+ - Updated dependencies
40
+ - @supermousejs/core@2.0.3
41
+ - @supermousejs/dot@2.0.3
42
+ - @supermousejs/ring@2.0.3
package/LICENSE.md ADDED
@@ -0,0 +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.
package/README.md ADDED
@@ -0,0 +1,39 @@
1
+ # supermousejs
2
+
3
+ The official all-in-one bundle for **Supermouse v2**.
4
+
5
+ This package provides a convenient, unscoped entry point for the Supermouse ecosystem. It bundles `@supermousejs/core` with the standard `Dot` and `Ring` plugins.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ pnpm add supermousejs
11
+ ```
12
+ or
13
+ ```bash
14
+ npm install supermousejs
15
+ ```
16
+
17
+ ## Usage
18
+
19
+ ```ts
20
+ import Supermouse, { Dot, Ring } from 'supermousejs';
21
+
22
+ const mouse = new Supermouse({
23
+ smoothness: 0.15
24
+ });
25
+
26
+ mouse.use(Dot({ size: 8 }));
27
+ mouse.use(Ring({ size: 24 }));
28
+ ```
29
+
30
+ ## Why use this over scoped packages?
31
+
32
+ If you prefer clean import paths or are using a CDN (like unpkg) and want a single file that "just works" with the standard cursor look, this is the package for you.
33
+
34
+ For advanced users or those looking to minimize bundle size, we recommend using the modular packages:
35
+ `@supermousejs/core`, `@supermousejs/dot`, etc.
36
+
37
+ ## Documentation
38
+
39
+ Full documentation and interactive playground available at [supermouse](https://supermouse.vercel.app) or [check out the repo](https://github.com/Whitestar14/supermouse-js).
@@ -0,0 +1,11 @@
1
+ import { Dot } from '@supermousejs/dot';
2
+ import { Ring } from '@supermousejs/ring';
3
+
4
+ export { Dot }
5
+
6
+ export { Ring }
7
+
8
+
9
+ export * from "@supermousejs/core";
10
+
11
+ export { }
package/dist/index.mjs ADDED
@@ -0,0 +1,627 @@
1
+ let C = 0;
2
+ class x {
3
+ constructor(t = document.body, e) {
4
+ if (this.container = t, this.hideNativeCursor = e, !t || !(t instanceof HTMLElement))
5
+ throw new Error(`[Supermouse] Invalid container: ${t}. Must be an HTMLElement.`);
6
+ const o = C++;
7
+ this.id = `supermouse-style-${o}`, this.scopeClass = `supermouse-scope-${o}`;
8
+ const i = t === document.body;
9
+ this.element = document.createElement("div"), Object.assign(this.element.style, {
10
+ position: i ? "fixed" : "absolute",
11
+ top: "0",
12
+ left: "0",
13
+ width: "100%",
14
+ height: "100%",
15
+ pointerEvents: "none",
16
+ zIndex: "9999",
17
+ opacity: "1",
18
+ transition: "opacity 0.15s ease"
19
+ }), i || window.getComputedStyle(t).position === "static" && (t.style.position = "relative"), t.appendChild(this.element), this.styleTag = document.createElement("style"), this.styleTag.id = this.id, document.head.appendChild(this.styleTag), this.container.classList.add(this.scopeClass), this.hideNativeCursor && this.setNativeCursor("none");
20
+ }
21
+ /** The container element appended to the document. Plugins must append here. */
22
+ element;
23
+ styleTag;
24
+ id;
25
+ scopeClass;
26
+ // Cache to prevent redundant DOM updates
27
+ currentCursorState = null;
28
+ // Defaults for CSS hiding. We must override user-agent styles on these elements
29
+ // to prevent the native cursor from popping through.
30
+ selectors = /* @__PURE__ */ new Set([
31
+ "a",
32
+ "button",
33
+ "input",
34
+ "textarea",
35
+ "select",
36
+ '[role="button"]',
37
+ "[tabindex]"
38
+ ]);
39
+ /**
40
+ * Adds a new CSS selector to the "Hide Native Cursor" list.
41
+ * Called by `Supermouse` (and subsequently plugins) during install to ensure
42
+ * the native cursor is hidden on their specific interactive targets.
43
+ */
44
+ addSelector(t) {
45
+ this.selectors.add(t), this.hideNativeCursor && this.updateCursorCSS();
46
+ }
47
+ /**
48
+ * Controls the opacity of the entire stage (all custom cursor elements).
49
+ */
50
+ setVisibility(t) {
51
+ this.element.style.opacity = t ? "1" : "0";
52
+ }
53
+ /**
54
+ * Toggles the visibility of the native cursor via CSS injection.
55
+ * @param type 'none' to hide, 'auto' to show.
56
+ */
57
+ setNativeCursor(t) {
58
+ !this.hideNativeCursor && t === "none" || t !== this.currentCursorState && (this.currentCursorState = t, t === "none" ? (this.container.style.cursor = "none", this.updateCursorCSS()) : (this.container.style.cursor = "", this.styleTag.innerText = ""));
59
+ }
60
+ updateCursorCSS() {
61
+ const t = Array.from(this.selectors);
62
+ if (t.length === 0) {
63
+ this.styleTag.innerText = "";
64
+ return;
65
+ }
66
+ const e = t.map((o) => `.${this.scopeClass} ${o}`).join(", ");
67
+ this.styleTag.innerText = `
68
+ ${e} {
69
+ cursor: none !important;
70
+ }
71
+ `;
72
+ }
73
+ destroy() {
74
+ this.element.remove(), this.styleTag.remove(), this.container.style.cursor = "", this.container.classList.remove(this.scopeClass);
75
+ }
76
+ }
77
+ let w = class {
78
+ constructor(t, e, o, i) {
79
+ this.state = t, this.options = e, this.getHoverSelector = o, this.onEnableChange = i, this.checkDeviceCapability(), this.checkMotionPreference(), this.bindEvents();
80
+ }
81
+ mediaQueryList;
82
+ mediaQueryHandler;
83
+ motionQuery;
84
+ /**
85
+ * Master switch for input processing.
86
+ * Toggled by `Supermouse.enable()`/`disable()` or automatically by device capability checks.
87
+ */
88
+ isEnabled = !0;
89
+ /**
90
+ * Performance Optimization:
91
+ * We cache the resolved InteractionState for every element we encounter in a WeakMap.
92
+ */
93
+ interactionCache = /* @__PURE__ */ new WeakMap();
94
+ /**
95
+ * Automatically disables the custom cursor on devices without fine pointer control (e.g. phones/tablets).
96
+ * Relies on `matchMedia('(pointer: fine)')`.
97
+ */
98
+ checkDeviceCapability() {
99
+ this.options.autoDisableOnMobile && (this.mediaQueryList = window.matchMedia("(pointer: fine)"), this.updateEnabledState(this.mediaQueryList.matches), this.mediaQueryHandler = (t) => {
100
+ this.updateEnabledState(t.matches);
101
+ }, this.mediaQueryList.addEventListener("change", this.mediaQueryHandler));
102
+ }
103
+ /**
104
+ * Checks for `prefers-reduced-motion`.
105
+ * If true, the core physics engine will switch to instant snapping (high damping) to avoid motion sickness.
106
+ */
107
+ checkMotionPreference() {
108
+ this.motionQuery = window.matchMedia("(prefer-reduced-motion: reduce)"), this.state.reducedMotion = this.motionQuery.matches, this.motionQuery.addEventListener("change", (t) => {
109
+ this.state.reducedMotion = t.matches;
110
+ });
111
+ }
112
+ updateEnabledState(t) {
113
+ this.isEnabled = t, this.onEnableChange(t);
114
+ }
115
+ // --- Interaction Parsing ---
116
+ /**
117
+ * Scrapes the DOM element for metadata to populate `state.interaction`.
118
+ *
119
+ * **Strategy:**
120
+ * 1. Check WeakMap cache.
121
+ * 2. Apply config-based `rules`.
122
+ * 3. Scrape `dataset` (supermouse*).
123
+ * 4. Cache result.
124
+ */
125
+ parseDOMInteraction(t) {
126
+ if (this.options.resolveInteraction) {
127
+ this.state.interaction = this.options.resolveInteraction(t);
128
+ return;
129
+ }
130
+ if (this.interactionCache.has(t)) {
131
+ this.state.interaction = this.interactionCache.get(t);
132
+ return;
133
+ }
134
+ const e = {};
135
+ if (this.options.rules)
136
+ for (const [i, n] of Object.entries(this.options.rules))
137
+ t.matches(i) && Object.assign(e, n);
138
+ const o = t.dataset;
139
+ for (const i in o)
140
+ if (i.startsWith("supermouse")) {
141
+ const n = i.slice(10);
142
+ if (n) {
143
+ const a = n.charAt(0).toLowerCase() + n.slice(1), r = o[i];
144
+ e[a] = r === "" ? !0 : r;
145
+ }
146
+ }
147
+ this.interactionCache.set(t, e), this.state.interaction = e;
148
+ }
149
+ // --- Handlers ---
150
+ // Unified Pointer Event Handler
151
+ handleMove = (t) => {
152
+ if (!this.isEnabled || this.options.autoDisableOnMobile && t.pointerType === "touch") return;
153
+ let e = t.clientX, o = t.clientY;
154
+ if (this.options.container && this.options.container !== document.body) {
155
+ const i = this.options.container.getBoundingClientRect();
156
+ e -= i.left, o -= i.top;
157
+ }
158
+ this.state.pointer.x = e, this.state.pointer.y = o, this.state.hasReceivedInput || (this.state.hasReceivedInput = !0, this.state.target.x = this.state.smooth.x = e, this.state.target.y = this.state.smooth.y = o);
159
+ };
160
+ handleDown = () => {
161
+ this.isEnabled && (this.state.isDown = !0);
162
+ };
163
+ handleUp = () => {
164
+ this.isEnabled && (this.state.isDown = !1);
165
+ };
166
+ handleMouseOver = (t) => {
167
+ if (!this.isEnabled) return;
168
+ const e = t.target;
169
+ if (e.closest("[data-supermouse-ignore]")) {
170
+ this.state.isNative = !0;
171
+ return;
172
+ }
173
+ const o = this.getHoverSelector(), i = e.closest(o);
174
+ i && (this.state.isHover = !0, this.state.hoverTarget = i, this.parseDOMInteraction(this.state.hoverTarget));
175
+ const n = this.options.ignoreOnNative;
176
+ if (n) {
177
+ const a = n === !0 || n === "auto" || n === "tag", r = n === !0 || n === "auto" || n === "css";
178
+ let h = !1;
179
+ if (a) {
180
+ const l = e.localName;
181
+ (l === "input" || l === "textarea" || l === "select" || e.isContentEditable) && (h = !0);
182
+ }
183
+ if (!h && r) {
184
+ const l = window.getComputedStyle(e).cursor;
185
+ ["default", "auto", "pointer", "none", "inherit"].includes(l) || (h = !0);
186
+ }
187
+ h && (this.state.isNative = !0);
188
+ }
189
+ };
190
+ handleMouseOut = (t) => {
191
+ if (!this.isEnabled) return;
192
+ const e = t.target;
193
+ (e === this.state.hoverTarget || e.contains(this.state.hoverTarget)) && (!t.relatedTarget || !this.state.hoverTarget?.contains(t.relatedTarget)) && (this.state.isHover = !1, this.state.hoverTarget = null, this.state.interaction = {}), this.state.isNative && (this.state.isNative = !1);
194
+ };
195
+ handleWindowLeave = () => {
196
+ this.options.hideOnLeave && (this.state.hasReceivedInput = !1);
197
+ };
198
+ bindEvents() {
199
+ window.addEventListener("pointermove", this.handleMove, { passive: !0 }), window.addEventListener("pointerdown", this.handleDown, { passive: !0 }), window.addEventListener("pointerup", this.handleUp), document.addEventListener("mouseover", this.handleMouseOver), document.addEventListener("mouseout", this.handleMouseOut), document.addEventListener("mouseleave", this.handleWindowLeave);
200
+ }
201
+ destroy() {
202
+ this.mediaQueryList && this.mediaQueryHandler && this.mediaQueryList.removeEventListener("change", this.mediaQueryHandler), window.removeEventListener("pointermove", this.handleMove), window.removeEventListener("pointerdown", this.handleDown), window.removeEventListener("pointerup", this.handleUp), document.removeEventListener("mouseover", this.handleMouseOver), document.removeEventListener("mouseout", this.handleMouseOut), document.removeEventListener("mouseleave", this.handleWindowLeave);
203
+ }
204
+ };
205
+ function L(s, t, e) {
206
+ return s + (t - s) * e;
207
+ }
208
+ function f(s, t, e, o) {
209
+ return L(s, t, 1 - Math.exp(-e * o));
210
+ }
211
+ function M(s, t) {
212
+ return Math.atan2(t, s) * (180 / Math.PI);
213
+ }
214
+ const T = [
215
+ "a",
216
+ "button",
217
+ "input",
218
+ "textarea",
219
+ "[data-hover]",
220
+ "[data-cursor]"
221
+ ];
222
+ class N {
223
+ /** The current version of Supermouse.js */
224
+ static version = "2.0.4";
225
+ version = "2.0.4";
226
+ /**
227
+ * The Single Source of Truth.
228
+ *
229
+ * This object is shared by reference. `Input` writes to it; `Supermouse` physics reads/writes to it;
230
+ * Plugins read/write to it.
231
+ */
232
+ state;
233
+ /**
234
+ * Configuration options.
235
+ */
236
+ options;
237
+ /**
238
+ * Registry of active plugins.
239
+ * @internal Use `use()`, `enablePlugin()`, or `disablePlugin()` to interact with this.
240
+ */
241
+ plugins = [];
242
+ /**
243
+ * The Stage System responsible for the DOM container and CSS injection.
244
+ * @internal
245
+ */
246
+ stage;
247
+ /**
248
+ * The Input System responsible for event listeners.
249
+ * @internal
250
+ */
251
+ input;
252
+ rafId = 0;
253
+ lastTime = 0;
254
+ isRunning = !1;
255
+ hoverSelectors;
256
+ /**
257
+ * Creates a new Supermouse instance.
258
+ *
259
+ * @param options - Global configuration options.
260
+ * @throws Will throw if running in a non-browser environment (window/document undefined).
261
+ */
262
+ constructor(t = {}) {
263
+ this.options = {
264
+ smoothness: 0.15,
265
+ enableTouch: !1,
266
+ autoDisableOnMobile: !0,
267
+ ignoreOnNative: "auto",
268
+ hideCursor: !0,
269
+ hideOnLeave: !0,
270
+ autoStart: !0,
271
+ container: document.body,
272
+ ...t
273
+ }, this.options.container || (this.options.container = document.body), this.state = {
274
+ pointer: { x: -100, y: -100 },
275
+ target: { x: -100, y: -100 },
276
+ smooth: { x: -100, y: -100 },
277
+ velocity: { x: 0, y: 0 },
278
+ angle: 0,
279
+ isDown: !1,
280
+ isHover: !1,
281
+ isNative: !1,
282
+ forcedCursor: null,
283
+ hoverTarget: null,
284
+ reducedMotion: !1,
285
+ hasReceivedInput: !1,
286
+ shape: null,
287
+ interaction: {}
288
+ }, this.options.hoverSelectors ? this.hoverSelectors = new Set(this.options.hoverSelectors) : this.hoverSelectors = new Set(T), this.stage = new x(this.options.container, !!this.options.hideCursor), this.hoverSelectors.forEach((e) => this.stage.addSelector(e)), this.input = new w(
289
+ this.state,
290
+ this.options,
291
+ () => Array.from(this.hoverSelectors).join(", "),
292
+ (e) => {
293
+ e || this.resetPosition();
294
+ }
295
+ ), this.options.plugins && this.options.plugins.forEach((e) => this.use(e)), this.init();
296
+ }
297
+ /**
298
+ * Retrieves a registered plugin instance by its unique name.
299
+ */
300
+ getPlugin(t) {
301
+ return this.plugins.find((e) => e.name === t);
302
+ }
303
+ /**
304
+ * Returns whether the cursor system is currently enabled (processing input).
305
+ */
306
+ get isEnabled() {
307
+ return this.input.isEnabled;
308
+ }
309
+ /**
310
+ * Enables a specific plugin by name.
311
+ * Triggers the `onEnable` lifecycle hook of the plugin.
312
+ */
313
+ enablePlugin(t) {
314
+ const e = this.getPlugin(t);
315
+ e && e.isEnabled === !1 && (e.isEnabled = !0, e.onEnable?.(this));
316
+ }
317
+ /**
318
+ * Disables a specific plugin by name.
319
+ * Triggers the `onDisable` lifecycle hook.
320
+ */
321
+ disablePlugin(t) {
322
+ const e = this.getPlugin(t);
323
+ e && e.isEnabled !== !1 && (e.isEnabled = !1, e.onDisable?.(this));
324
+ }
325
+ /**
326
+ * Toggles the enabled state of a plugin.
327
+ */
328
+ togglePlugin(t) {
329
+ const e = this.getPlugin(t);
330
+ e && (e.isEnabled === !1 ? this.enablePlugin(t) : this.disablePlugin(t));
331
+ }
332
+ /**
333
+ * Registers a CSS selector as an "Interactive Target".
334
+ *
335
+ * When the mouse hovers over an element matching this selector:
336
+ * 1. `state.isHover` becomes `true`.
337
+ * 2. `state.hoverTarget` is set to the element.
338
+ * 3. The `Stage` system injects CSS to hide the native cursor for this element (if `hideCursor: true`).
339
+ *
340
+ * @param selector - A valid CSS selector string (e.g., `.my-button`, `[data-trigger]`).
341
+ */
342
+ registerHoverTarget(t) {
343
+ this.hoverSelectors.has(t) || (this.hoverSelectors.add(t), this.stage.addSelector(t));
344
+ }
345
+ /**
346
+ * The fixed container element where plugins should append their DOM nodes.
347
+ */
348
+ get container() {
349
+ return this.stage.element;
350
+ }
351
+ /**
352
+ * Manually override the native cursor visibility.
353
+ * Useful for drag-and-drop operations, modals, or special UI states.
354
+ *
355
+ * @param type 'auto' (Show Native), 'none' (Hide Native), or null (Resume Auto-detection)
356
+ */
357
+ setCursor(t) {
358
+ this.state.forcedCursor = t;
359
+ }
360
+ init() {
361
+ this.options.autoStart && this.startLoop();
362
+ }
363
+ /**
364
+ * Starts the update loop and enables input listeners.
365
+ * Hides the native cursor if configured.
366
+ */
367
+ enable() {
368
+ this.input.isEnabled = !0, this.stage.setNativeCursor("none");
369
+ }
370
+ /**
371
+ * Stops the update loop, disables listeners, and restores the native cursor.
372
+ * Resets internal state positions to off-screen.
373
+ */
374
+ disable() {
375
+ this.input.isEnabled = !1, this.stage.setNativeCursor("auto"), this.resetPosition();
376
+ }
377
+ /**
378
+ * Registers a new plugin.
379
+ *
380
+ * @remarks
381
+ * Plugins are sorted by `priority` immediately after registration.
382
+ * - **Negative Priority (< 0)**: Logic plugins (run before physics).
383
+ * - **Positive Priority (>= 0)**: Visual plugins (run after physics).
384
+ *
385
+ * @param plugin - The plugin object to install.
386
+ */
387
+ use(t) {
388
+ return this.plugins.find((e) => e.name === t.name) ? (console.warn(`[Supermouse] Plugin "${t.name}" already installed.`), this) : (t.isEnabled === void 0 && (t.isEnabled = !0), this.plugins.push(t), this.plugins.sort((e, o) => (e.priority || 0) - (o.priority || 0)), t.install?.(this), this);
389
+ }
390
+ resetPosition() {
391
+ const t = { x: -100, y: -100 };
392
+ this.state.pointer = { ...t }, this.state.target = { ...t }, this.state.smooth = { ...t }, this.state.velocity = { x: 0, y: 0 }, this.state.angle = 0, this.state.hasReceivedInput = !1, this.state.shape = null, this.state.interaction = {};
393
+ }
394
+ startLoop() {
395
+ this.isRunning || (this.isRunning = !0, this.lastTime = performance.now(), this.tick(this.lastTime));
396
+ }
397
+ /**
398
+ * Manually steps the animation loop.
399
+ * Useful when integrating with external game loops (e.g., Three.js, PixiJS) where
400
+ * you want to disable the internal RAF and drive `Supermouse` from your own ticker.
401
+ *
402
+ * @param time Current timestamp in milliseconds.
403
+ */
404
+ step(t) {
405
+ this.tick(t);
406
+ }
407
+ runPluginSafe(t, e) {
408
+ if (t.isEnabled !== !1)
409
+ try {
410
+ t.update?.(this, e);
411
+ } catch (o) {
412
+ console.error(`[Supermouse] Plugin '${t.name}' crashed and has been disabled.`, o), t.isEnabled = !1, t.onDisable?.(this);
413
+ }
414
+ }
415
+ /**
416
+ * The Heartbeat.
417
+ * Runs on every animation frame.
418
+ */
419
+ tick = (t) => {
420
+ const e = t - this.lastTime, o = Math.min(e / 1e3, 0.1);
421
+ this.lastTime = t;
422
+ const i = this.input.isEnabled && !this.state.isNative && this.state.hasReceivedInput;
423
+ if (this.stage.setVisibility(i), this.input.isEnabled && this.options.hideCursor) {
424
+ let n = "auto";
425
+ this.state.forcedCursor !== null ? n = this.state.forcedCursor : n = this.state.isNative || !this.state.hasReceivedInput ? "auto" : "none", this.stage.setNativeCursor(n);
426
+ }
427
+ if (this.input.isEnabled) {
428
+ this.state.target.x = this.state.pointer.x, this.state.target.y = this.state.pointer.y;
429
+ for (let l = 0; l < this.plugins.length; l++)
430
+ this.runPluginSafe(this.plugins[l], e);
431
+ const n = this.options.smoothness, a = this.state.reducedMotion ? 1e3 : 1 / n * 2;
432
+ this.state.smooth.x = f(this.state.smooth.x, this.state.target.x, a, o), this.state.smooth.y = f(this.state.smooth.y, this.state.target.y, a, o);
433
+ const r = this.state.target.x - this.state.smooth.x, h = this.state.target.y - this.state.smooth.y;
434
+ this.state.velocity.x = r, this.state.velocity.y = h, (Math.abs(r) > 0.1 || Math.abs(h) > 0.1) && (this.state.angle = M(r, h));
435
+ } else {
436
+ this.state.smooth.x = -100, this.state.smooth.y = -100, this.state.pointer.x = -100, this.state.pointer.y = -100, this.state.velocity.x = 0, this.state.velocity.y = 0;
437
+ for (let n = 0; n < this.plugins.length; n++)
438
+ this.runPluginSafe(this.plugins[n], e);
439
+ }
440
+ this.options.autoStart && this.isRunning && (this.rafId = requestAnimationFrame(this.tick));
441
+ };
442
+ /**
443
+ * Destroys the instance.
444
+ * Stops the loop, removes all DOM elements, removes all event listeners, and calls destroy on all plugins.
445
+ */
446
+ destroy() {
447
+ this.isRunning = !1, cancelAnimationFrame(this.rafId), this.input.destroy(), this.stage.destroy(), this.plugins.forEach((t) => t.destroy?.(this)), this.plugins = [];
448
+ }
449
+ }
450
+ function y(s, t) {
451
+ Object.assign(s.style, t);
452
+ }
453
+ const b = /* @__PURE__ */ new WeakMap();
454
+ function g(s, t, e) {
455
+ let o = b.get(s);
456
+ o || (o = {}, b.set(s, o)), o[t] !== e && (s.style[t] = e, o[t] = e);
457
+ }
458
+ function O(s, t, e, o = 0, i = 1, n = 1, a = 0, r = 0) {
459
+ s.style.transform = `
460
+ translate3d(${t}px, ${e}px, 0)
461
+ translate(-50%, -50%)
462
+ rotate(${o}deg)
463
+ skew(${a}deg, ${r}deg)
464
+ scale(${i}, ${n})
465
+ `;
466
+ }
467
+ function $(s, t = document.body) {
468
+ const e = s.getBoundingClientRect();
469
+ if (t !== document.body) {
470
+ const o = t.getBoundingClientRect(), i = e.left - o.left, n = e.top - o.top;
471
+ return {
472
+ x: i,
473
+ y: n,
474
+ width: e.width,
475
+ height: e.height,
476
+ top: n,
477
+ left: i,
478
+ right: i + e.width,
479
+ bottom: n + e.height,
480
+ toJSON: () => ({})
481
+ };
482
+ }
483
+ return e;
484
+ }
485
+ function v(s = "div") {
486
+ const t = document.createElement(s);
487
+ return y(t, {
488
+ position: "absolute",
489
+ top: "0",
490
+ left: "0",
491
+ pointerEvents: "none",
492
+ boxSizing: "border-box",
493
+ display: "block",
494
+ willChange: "transform"
495
+ }), t;
496
+ }
497
+ function R(s, t) {
498
+ const e = v("div");
499
+ return y(e, {
500
+ width: `${s}px`,
501
+ height: `${s}px`,
502
+ borderRadius: "50%",
503
+ backgroundColor: t
504
+ }), e;
505
+ }
506
+ function P() {
507
+ return v("div");
508
+ }
509
+ const c = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
510
+ __proto__: null,
511
+ applyStyles: y,
512
+ createActor: v,
513
+ createCircle: R,
514
+ createDiv: P,
515
+ projectRect: $,
516
+ setStyle: g,
517
+ setTransform: O
518
+ }, Symbol.toStringTag, { value: "Module" })), E = {
519
+ /** The main cursor layer. For the primary Dot/Pointer. */
520
+ CURSOR: "300",
521
+ /** The secondary layer. For Rings, brackets, or followers. */
522
+ FOLLOWER: "200"
523
+ };
524
+ function u(s, t) {
525
+ return s === void 0 ? () => t : typeof s == "function" ? s : () => s;
526
+ }
527
+ function D(s) {
528
+ return "create" in s && typeof s.create == "function";
529
+ }
530
+ function S(s, t = {}) {
531
+ const e = t.name || s.name, o = t.isEnabled ?? !0;
532
+ if (D(s)) {
533
+ let i;
534
+ const n = [];
535
+ if (s.styles)
536
+ for (const [a, r] of Object.entries(s.styles)) {
537
+ const h = u(t[a], void 0), l = r;
538
+ n.push((d, m) => {
539
+ const p = h(d.state);
540
+ p !== void 0 && g(m, l, p);
541
+ });
542
+ }
543
+ return {
544
+ name: e,
545
+ isEnabled: o,
546
+ install(a) {
547
+ i = s.create(a), s.selector && a.registerHoverTarget(s.selector), this.isEnabled === !1 && (i.style.opacity = "0"), a.container.appendChild(i);
548
+ },
549
+ update(a, r) {
550
+ if (i) {
551
+ for (let h = 0; h < n.length; h++)
552
+ n[h](a, i);
553
+ s.update?.(a, i, r);
554
+ }
555
+ },
556
+ onDisable(a) {
557
+ i && (g(i, "opacity", 0), s.onDisable?.(a, i));
558
+ },
559
+ onEnable(a) {
560
+ i && (g(i, "opacity", 1), s.onEnable?.(a, i));
561
+ },
562
+ destroy() {
563
+ i && (s.cleanup?.(i), i.remove());
564
+ }
565
+ };
566
+ } else
567
+ return {
568
+ ...s,
569
+ name: e,
570
+ isEnabled: o
571
+ };
572
+ }
573
+ const k = (s = {}) => {
574
+ const t = "#750c7e", e = s.hideOnShape ?? !0, o = u(s.size, 8), i = u(s.color, t), n = u(s.opacity, 1);
575
+ return S({
576
+ name: "dot",
577
+ selector: "[data-supermouse-color]",
578
+ create: (a) => {
579
+ const r = o(a.state), h = i(a.state), l = c.createCircle(r, h);
580
+ return c.applyStyles(l, {
581
+ zIndex: s.zIndex || E.CURSOR,
582
+ mixBlendMode: s.mixBlendMode || "difference",
583
+ transition: "background-color 0.2s ease, opacity 0.2s ease"
584
+ }), l;
585
+ },
586
+ styles: {},
587
+ update: (a, r) => {
588
+ const h = o(a.state);
589
+ c.setStyle(r, "width", `${h}px`), c.setStyle(r, "height", `${h}px`);
590
+ const l = a.state.interaction.color;
591
+ l ? c.setStyle(r, "backgroundColor", l) : c.setStyle(r, "backgroundColor", i(a.state));
592
+ let d = n(a.state);
593
+ e && a.state.shape && (d = 0), c.setStyle(r, "opacity", String(d));
594
+ const { x: m, y: p } = a.state.target;
595
+ c.setTransform(r, m, p);
596
+ }
597
+ }, s);
598
+ }, H = (s = {}) => {
599
+ const t = u(s.size, 20), e = u(s.color, "#ffffff"), o = u(s.borderWidth, 2), i = u(s.opacity, 1);
600
+ return S({
601
+ name: s.name || "ring",
602
+ selector: "[data-supermouse-color]",
603
+ create: (n) => {
604
+ const a = c.createCircle(t(n.state), "transparent");
605
+ return c.applyStyles(a, {
606
+ zIndex: E.FOLLOWER,
607
+ mixBlendMode: s.mixBlendMode || "difference",
608
+ borderStyle: "solid",
609
+ transition: "opacity 0.2s ease",
610
+ boxSizing: "border-box"
611
+ }), a;
612
+ },
613
+ update: (n, a) => {
614
+ const r = t(n.state);
615
+ let h = e(n.state);
616
+ n.state.interaction.color && (h = n.state.interaction.color), c.setStyle(a, "width", `${r}px`), c.setStyle(a, "height", `${r}px`), c.setStyle(a, "borderRadius", "50%"), c.setStyle(a, "borderColor", h), c.setStyle(a, "borderWidth", `${o(n.state)}px`), c.setStyle(a, "opacity", String(i(n.state)));
617
+ const { x: l, y: d } = n.state.smooth;
618
+ c.setTransform(a, l, d);
619
+ }
620
+ }, s);
621
+ };
622
+ export {
623
+ T as DEFAULT_HOVER_SELECTORS,
624
+ k as Dot,
625
+ H as Ring,
626
+ N as Supermouse
627
+ };
@@ -0,0 +1,11 @@
1
+ (function(u,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(u=typeof globalThis<"u"?globalThis:u||self,g(u.Supermouse={}))})(this,(function(u){"use strict";let g=0;class T{constructor(t=document.body,e){if(this.container=t,this.hideNativeCursor=e,!t||!(t instanceof HTMLElement))throw new Error(`[Supermouse] Invalid container: ${t}. Must be an HTMLElement.`);const o=g++;this.id=`supermouse-style-${o}`,this.scopeClass=`supermouse-scope-${o}`;const i=t===document.body;this.element=document.createElement("div"),Object.assign(this.element.style,{position:i?"fixed":"absolute",top:"0",left:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:"9999",opacity:"1",transition:"opacity 0.15s ease"}),i||window.getComputedStyle(t).position==="static"&&(t.style.position="relative"),t.appendChild(this.element),this.styleTag=document.createElement("style"),this.styleTag.id=this.id,document.head.appendChild(this.styleTag),this.container.classList.add(this.scopeClass),this.hideNativeCursor&&this.setNativeCursor("none")}element;styleTag;id;scopeClass;currentCursorState=null;selectors=new Set(["a","button","input","textarea","select",'[role="button"]',"[tabindex]"]);addSelector(t){this.selectors.add(t),this.hideNativeCursor&&this.updateCursorCSS()}setVisibility(t){this.element.style.opacity=t?"1":"0"}setNativeCursor(t){!this.hideNativeCursor&&t==="none"||t!==this.currentCursorState&&(this.currentCursorState=t,t==="none"?(this.container.style.cursor="none",this.updateCursorCSS()):(this.container.style.cursor="",this.styleTag.innerText=""))}updateCursorCSS(){const t=Array.from(this.selectors);if(t.length===0){this.styleTag.innerText="";return}const e=t.map(o=>`.${this.scopeClass} ${o}`).join(", ");this.styleTag.innerText=`
2
+ ${e} {
3
+ cursor: none !important;
4
+ }
5
+ `}destroy(){this.element.remove(),this.styleTag.remove(),this.container.style.cursor="",this.container.classList.remove(this.scopeClass)}}let L=class{constructor(t,e,o,i){this.state=t,this.options=e,this.getHoverSelector=o,this.onEnableChange=i,this.checkDeviceCapability(),this.checkMotionPreference(),this.bindEvents()}mediaQueryList;mediaQueryHandler;motionQuery;isEnabled=!0;interactionCache=new WeakMap;checkDeviceCapability(){this.options.autoDisableOnMobile&&(this.mediaQueryList=window.matchMedia("(pointer: fine)"),this.updateEnabledState(this.mediaQueryList.matches),this.mediaQueryHandler=t=>{this.updateEnabledState(t.matches)},this.mediaQueryList.addEventListener("change",this.mediaQueryHandler))}checkMotionPreference(){this.motionQuery=window.matchMedia("(prefer-reduced-motion: reduce)"),this.state.reducedMotion=this.motionQuery.matches,this.motionQuery.addEventListener("change",t=>{this.state.reducedMotion=t.matches})}updateEnabledState(t){this.isEnabled=t,this.onEnableChange(t)}parseDOMInteraction(t){if(this.options.resolveInteraction){this.state.interaction=this.options.resolveInteraction(t);return}if(this.interactionCache.has(t)){this.state.interaction=this.interactionCache.get(t);return}const e={};if(this.options.rules)for(const[i,n]of Object.entries(this.options.rules))t.matches(i)&&Object.assign(e,n);const o=t.dataset;for(const i in o)if(i.startsWith("supermouse")){const n=i.slice(10);if(n){const a=n.charAt(0).toLowerCase()+n.slice(1),r=o[i];e[a]=r===""?!0:r}}this.interactionCache.set(t,e),this.state.interaction=e}handleMove=t=>{if(!this.isEnabled||this.options.autoDisableOnMobile&&t.pointerType==="touch")return;let e=t.clientX,o=t.clientY;if(this.options.container&&this.options.container!==document.body){const i=this.options.container.getBoundingClientRect();e-=i.left,o-=i.top}this.state.pointer.x=e,this.state.pointer.y=o,this.state.hasReceivedInput||(this.state.hasReceivedInput=!0,this.state.target.x=this.state.smooth.x=e,this.state.target.y=this.state.smooth.y=o)};handleDown=()=>{this.isEnabled&&(this.state.isDown=!0)};handleUp=()=>{this.isEnabled&&(this.state.isDown=!1)};handleMouseOver=t=>{if(!this.isEnabled)return;const e=t.target;if(e.closest("[data-supermouse-ignore]")){this.state.isNative=!0;return}const o=this.getHoverSelector(),i=e.closest(o);i&&(this.state.isHover=!0,this.state.hoverTarget=i,this.parseDOMInteraction(this.state.hoverTarget));const n=this.options.ignoreOnNative;if(n){const a=n===!0||n==="auto"||n==="tag",r=n===!0||n==="auto"||n==="css";let h=!1;if(a){const l=e.localName;(l==="input"||l==="textarea"||l==="select"||e.isContentEditable)&&(h=!0)}if(!h&&r){const l=window.getComputedStyle(e).cursor;["default","auto","pointer","none","inherit"].includes(l)||(h=!0)}h&&(this.state.isNative=!0)}};handleMouseOut=t=>{if(!this.isEnabled)return;const e=t.target;(e===this.state.hoverTarget||e.contains(this.state.hoverTarget))&&(!t.relatedTarget||!this.state.hoverTarget?.contains(t.relatedTarget))&&(this.state.isHover=!1,this.state.hoverTarget=null,this.state.interaction={}),this.state.isNative&&(this.state.isNative=!1)};handleWindowLeave=()=>{this.options.hideOnLeave&&(this.state.hasReceivedInput=!1)};bindEvents(){window.addEventListener("pointermove",this.handleMove,{passive:!0}),window.addEventListener("pointerdown",this.handleDown,{passive:!0}),window.addEventListener("pointerup",this.handleUp),document.addEventListener("mouseover",this.handleMouseOver),document.addEventListener("mouseout",this.handleMouseOut),document.addEventListener("mouseleave",this.handleWindowLeave)}destroy(){this.mediaQueryList&&this.mediaQueryHandler&&this.mediaQueryList.removeEventListener("change",this.mediaQueryHandler),window.removeEventListener("pointermove",this.handleMove),window.removeEventListener("pointerdown",this.handleDown),window.removeEventListener("pointerup",this.handleUp),document.removeEventListener("mouseover",this.handleMouseOver),document.removeEventListener("mouseout",this.handleMouseOut),document.removeEventListener("mouseleave",this.handleWindowLeave)}};function M(s,t,e){return s+(t-s)*e}function S(s,t,e,o){return M(s,t,1-Math.exp(-e*o))}function O(s,t){return Math.atan2(t,s)*(180/Math.PI)}const E=["a","button","input","textarea","[data-hover]","[data-cursor]"];class ${static version="2.0.4";version="2.0.4";state;options;plugins=[];stage;input;rafId=0;lastTime=0;isRunning=!1;hoverSelectors;constructor(t={}){this.options={smoothness:.15,enableTouch:!1,autoDisableOnMobile:!0,ignoreOnNative:"auto",hideCursor:!0,hideOnLeave:!0,autoStart:!0,container:document.body,...t},this.options.container||(this.options.container=document.body),this.state={pointer:{x:-100,y:-100},target:{x:-100,y:-100},smooth:{x:-100,y:-100},velocity:{x:0,y:0},angle:0,isDown:!1,isHover:!1,isNative:!1,forcedCursor:null,hoverTarget:null,reducedMotion:!1,hasReceivedInput:!1,shape:null,interaction:{}},this.options.hoverSelectors?this.hoverSelectors=new Set(this.options.hoverSelectors):this.hoverSelectors=new Set(E),this.stage=new T(this.options.container,!!this.options.hideCursor),this.hoverSelectors.forEach(e=>this.stage.addSelector(e)),this.input=new L(this.state,this.options,()=>Array.from(this.hoverSelectors).join(", "),e=>{e||this.resetPosition()}),this.options.plugins&&this.options.plugins.forEach(e=>this.use(e)),this.init()}getPlugin(t){return this.plugins.find(e=>e.name===t)}get isEnabled(){return this.input.isEnabled}enablePlugin(t){const e=this.getPlugin(t);e&&e.isEnabled===!1&&(e.isEnabled=!0,e.onEnable?.(this))}disablePlugin(t){const e=this.getPlugin(t);e&&e.isEnabled!==!1&&(e.isEnabled=!1,e.onDisable?.(this))}togglePlugin(t){const e=this.getPlugin(t);e&&(e.isEnabled===!1?this.enablePlugin(t):this.disablePlugin(t))}registerHoverTarget(t){this.hoverSelectors.has(t)||(this.hoverSelectors.add(t),this.stage.addSelector(t))}get container(){return this.stage.element}setCursor(t){this.state.forcedCursor=t}init(){this.options.autoStart&&this.startLoop()}enable(){this.input.isEnabled=!0,this.stage.setNativeCursor("none")}disable(){this.input.isEnabled=!1,this.stage.setNativeCursor("auto"),this.resetPosition()}use(t){return this.plugins.find(e=>e.name===t.name)?(console.warn(`[Supermouse] Plugin "${t.name}" already installed.`),this):(t.isEnabled===void 0&&(t.isEnabled=!0),this.plugins.push(t),this.plugins.sort((e,o)=>(e.priority||0)-(o.priority||0)),t.install?.(this),this)}resetPosition(){const t={x:-100,y:-100};this.state.pointer={...t},this.state.target={...t},this.state.smooth={...t},this.state.velocity={x:0,y:0},this.state.angle=0,this.state.hasReceivedInput=!1,this.state.shape=null,this.state.interaction={}}startLoop(){this.isRunning||(this.isRunning=!0,this.lastTime=performance.now(),this.tick(this.lastTime))}step(t){this.tick(t)}runPluginSafe(t,e){if(t.isEnabled!==!1)try{t.update?.(this,e)}catch(o){console.error(`[Supermouse] Plugin '${t.name}' crashed and has been disabled.`,o),t.isEnabled=!1,t.onDisable?.(this)}}tick=t=>{const e=t-this.lastTime,o=Math.min(e/1e3,.1);this.lastTime=t;const i=this.input.isEnabled&&!this.state.isNative&&this.state.hasReceivedInput;if(this.stage.setVisibility(i),this.input.isEnabled&&this.options.hideCursor){let n="auto";this.state.forcedCursor!==null?n=this.state.forcedCursor:n=this.state.isNative||!this.state.hasReceivedInput?"auto":"none",this.stage.setNativeCursor(n)}if(this.input.isEnabled){this.state.target.x=this.state.pointer.x,this.state.target.y=this.state.pointer.y;for(let l=0;l<this.plugins.length;l++)this.runPluginSafe(this.plugins[l],e);const n=this.options.smoothness,a=this.state.reducedMotion?1e3:1/n*2;this.state.smooth.x=S(this.state.smooth.x,this.state.target.x,a,o),this.state.smooth.y=S(this.state.smooth.y,this.state.target.y,a,o);const r=this.state.target.x-this.state.smooth.x,h=this.state.target.y-this.state.smooth.y;this.state.velocity.x=r,this.state.velocity.y=h,(Math.abs(r)>.1||Math.abs(h)>.1)&&(this.state.angle=O(r,h))}else{this.state.smooth.x=-100,this.state.smooth.y=-100,this.state.pointer.x=-100,this.state.pointer.y=-100,this.state.velocity.x=0,this.state.velocity.y=0;for(let n=0;n<this.plugins.length;n++)this.runPluginSafe(this.plugins[n],e)}this.options.autoStart&&this.isRunning&&(this.rafId=requestAnimationFrame(this.tick))};destroy(){this.isRunning=!1,cancelAnimationFrame(this.rafId),this.input.destroy(),this.stage.destroy(),this.plugins.forEach(t=>t.destroy?.(this)),this.plugins=[]}}function f(s,t){Object.assign(s.style,t)}const C=new WeakMap;function m(s,t,e){let o=C.get(s);o||(o={},C.set(s,o)),o[t]!==e&&(s.style[t]=e,o[t]=e)}function R(s,t,e,o=0,i=1,n=1,a=0,r=0){s.style.transform=`
6
+ translate3d(${t}px, ${e}px, 0)
7
+ translate(-50%, -50%)
8
+ rotate(${o}deg)
9
+ skew(${a}deg, ${r}deg)
10
+ scale(${i}, ${n})
11
+ `}function P(s,t=document.body){const e=s.getBoundingClientRect();if(t!==document.body){const o=t.getBoundingClientRect(),i=e.left-o.left,n=e.top-o.top;return{x:i,y:n,width:e.width,height:e.height,top:n,left:i,right:i+e.width,bottom:n+e.height,toJSON:()=>({})}}return e}function v(s="div"){const t=document.createElement(s);return f(t,{position:"absolute",top:"0",left:"0",pointerEvents:"none",boxSizing:"border-box",display:"block",willChange:"transform"}),t}function D(s,t){const e=v("div");return f(e,{width:`${s}px`,height:`${s}px`,borderRadius:"50%",backgroundColor:t}),e}function I(){return v("div")}const c=Object.freeze(Object.defineProperty({__proto__:null,applyStyles:f,createActor:v,createCircle:D,createDiv:I,projectRect:P,setStyle:m,setTransform:R},Symbol.toStringTag,{value:"Module"})),x={CURSOR:"300",FOLLOWER:"200"};function d(s,t){return s===void 0?()=>t:typeof s=="function"?s:()=>s}function N(s){return"create"in s&&typeof s.create=="function"}function w(s,t={}){const e=t.name||s.name,o=t.isEnabled??!0;if(N(s)){let i;const n=[];if(s.styles)for(const[a,r]of Object.entries(s.styles)){const h=d(t[a],void 0),l=r;n.push((p,b)=>{const y=h(p.state);y!==void 0&&m(b,l,y)})}return{name:e,isEnabled:o,install(a){i=s.create(a),s.selector&&a.registerHoverTarget(s.selector),this.isEnabled===!1&&(i.style.opacity="0"),a.container.appendChild(i)},update(a,r){if(i){for(let h=0;h<n.length;h++)n[h](a,i);s.update?.(a,i,r)}},onDisable(a){i&&(m(i,"opacity",0),s.onDisable?.(a,i))},onEnable(a){i&&(m(i,"opacity",1),s.onEnable?.(a,i))},destroy(){i&&(s.cleanup?.(i),i.remove())}}}else return{...s,name:e,isEnabled:o}}const k=(s={})=>{const t="#750c7e",e=s.hideOnShape??!0,o=d(s.size,8),i=d(s.color,t),n=d(s.opacity,1);return w({name:"dot",selector:"[data-supermouse-color]",create:a=>{const r=o(a.state),h=i(a.state),l=c.createCircle(r,h);return c.applyStyles(l,{zIndex:s.zIndex||x.CURSOR,mixBlendMode:s.mixBlendMode||"difference",transition:"background-color 0.2s ease, opacity 0.2s ease"}),l},styles:{},update:(a,r)=>{const h=o(a.state);c.setStyle(r,"width",`${h}px`),c.setStyle(r,"height",`${h}px`);const l=a.state.interaction.color;l?c.setStyle(r,"backgroundColor",l):c.setStyle(r,"backgroundColor",i(a.state));let p=n(a.state);e&&a.state.shape&&(p=0),c.setStyle(r,"opacity",String(p));const{x:b,y}=a.state.target;c.setTransform(r,b,y)}},s)},H=(s={})=>{const t=d(s.size,20),e=d(s.color,"#ffffff"),o=d(s.borderWidth,2),i=d(s.opacity,1);return w({name:s.name||"ring",selector:"[data-supermouse-color]",create:n=>{const a=c.createCircle(t(n.state),"transparent");return c.applyStyles(a,{zIndex:x.FOLLOWER,mixBlendMode:s.mixBlendMode||"difference",borderStyle:"solid",transition:"opacity 0.2s ease",boxSizing:"border-box"}),a},update:(n,a)=>{const r=t(n.state);let h=e(n.state);n.state.interaction.color&&(h=n.state.interaction.color),c.setStyle(a,"width",`${r}px`),c.setStyle(a,"height",`${r}px`),c.setStyle(a,"borderRadius","50%"),c.setStyle(a,"borderColor",h),c.setStyle(a,"borderWidth",`${o(n.state)}px`),c.setStyle(a,"opacity",String(i(n.state)));const{x:l,y:p}=n.state.smooth;c.setTransform(a,l,p)}},s)};u.DEFAULT_HOVER_SELECTORS=E,u.Dot=k,u.Ring=H,u.Supermouse=$,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
package/meta.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "id": "supermousejs",
3
+ "name": "Supermouse JS (Standard)",
4
+ "package": "supermousejs",
5
+ "description": "The official unscoped bundle for v2. Quickest way to get started with the standard Dot & Ring setup.",
6
+ "code": "import Supermouse, { Dot, Ring } from 'supermousejs';\n\nconst app = new Supermouse();\napp.use(Dot()).use(Ring());",
7
+ "icon": "dot"
8
+ }
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "supermousejs",
3
+ "version": "2.1.0",
4
+ "description": "The official all-in-one bundle for Supermouse.js v2. High-performance, modular cursor engine.",
5
+ "main": "dist/index.umd.js",
6
+ "module": "dist/index.mjs",
7
+ "types": "dist/index.d.ts",
8
+ "url": "https://github.com/Whitestar14/supermouse-js",
9
+ "keywords": [
10
+ "cursor",
11
+ "pointer",
12
+ "mouse",
13
+ "animation",
14
+ "supermouse",
15
+ "supermousejs"
16
+ ],
17
+ "author": "O.S David",
18
+ "license": "MIT",
19
+ "dependencies": {
20
+ "@supermousejs/dot": "2.1.0",
21
+ "@supermousejs/ring": "2.1.0"
22
+ },
23
+ "exports": {
24
+ ".": {
25
+ "types": "./dist/index.d.ts",
26
+ "import": "./dist/index.mjs",
27
+ "require": "./dist/index.umd.js"
28
+ }
29
+ },
30
+ "peerDependencies": {
31
+ "@supermousejs/core": "2.0.4"
32
+ },
33
+ "devDependencies": {
34
+ "@supermousejs/core": "2.0.4"
35
+ },
36
+ "scripts": {
37
+ "build": "vite build"
38
+ }
39
+ }
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from '@supermousejs/core';
2
+ export { Dot } from '@supermousejs/dot';
3
+ export { Ring } from '@supermousejs/ring';
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": ["src"],
4
+ "compilerOptions": {
5
+ "outDir": "dist",
6
+ "baseUrl": ".",
7
+ }
8
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { defineConfig } from 'vite';
2
+ import dts from 'vite-plugin-dts';
3
+ import path from 'path';
4
+
5
+ export default defineConfig({
6
+ build: {
7
+ lib: {
8
+ entry: path.resolve(__dirname, 'src/index.ts'),
9
+ name: 'Supermouse',
10
+ fileName: (format) => format === 'es' ? 'index.mjs' : 'index.umd.js',
11
+ },
12
+ rollupOptions: {
13
+ external: [],
14
+ output: {
15
+ globals: {}
16
+ }
17
+ }
18
+ },
19
+ plugins: [dts({ rollupTypes: true })]
20
+ });