@supermousejs/dot 2.0.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,13 @@
1
+ # @supermousejs/dot
2
+
3
+ ## 2.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - Initial v2.0.0 release
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+ - @supermousejs/utils@2.0.0
13
+ - @supermousejs/core@2.0.0
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.
@@ -0,0 +1,18 @@
1
+ import { SupermousePlugin } from '../../core/src/index.ts';
2
+ import { ValueOrGetter } from '../../core/src/index.ts';
3
+
4
+ export declare const Dot: (options?: DotOptions) => SupermousePlugin;
5
+
6
+ export declare interface DotOptions {
7
+ name?: string;
8
+ isEnabled?: boolean;
9
+ size?: ValueOrGetter<number>;
10
+ color?: ValueOrGetter<string>;
11
+ opacity?: ValueOrGetter<number>;
12
+ zIndex?: string;
13
+ mixBlendMode?: string;
14
+ /** Whether to hide the dot when the cursor is in a 'shape' state (e.g. Stuck). Default true. */
15
+ hideOnShape?: boolean;
16
+ }
17
+
18
+ export { }
package/dist/index.mjs ADDED
@@ -0,0 +1,30 @@
1
+ import { normalize as n, definePlugin as u, dom as o, Layers as m } from "@supermousejs/utils";
2
+ const x = (s = {}) => {
3
+ const d = "#750c7e", y = s.hideOnShape ?? !0, a = n(s.size, 8), i = n(s.color, d), S = n(s.opacity, 1);
4
+ return u({
5
+ name: "dot",
6
+ selector: "[data-supermouse-color]",
7
+ create: (e) => {
8
+ const t = a(e.state), c = i(e.state), r = o.createCircle(t, c);
9
+ return o.applyStyles(r, {
10
+ zIndex: s.zIndex || m.CURSOR,
11
+ mixBlendMode: s.mixBlendMode || "difference",
12
+ transition: "background-color 0.2s ease, opacity 0.2s ease"
13
+ }), r;
14
+ },
15
+ styles: {},
16
+ update: (e, t) => {
17
+ const c = a(e.state);
18
+ o.setStyle(t, "width", `${c}px`), o.setStyle(t, "height", `${c}px`);
19
+ const r = e.state.interaction.color;
20
+ r ? o.setStyle(t, "backgroundColor", r) : o.setStyle(t, "backgroundColor", i(e.state));
21
+ let l = S(e.state);
22
+ y && e.state.shape && (l = 0), o.setStyle(t, "opacity", String(l));
23
+ const { x: g, y: f } = e.state.target;
24
+ o.setTransform(t, g, f);
25
+ }
26
+ }, s);
27
+ };
28
+ export {
29
+ x as Dot
30
+ };
@@ -0,0 +1 @@
1
+ (function(n,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("@supermousejs/utils")):typeof define=="function"&&define.amd?define(["exports","@supermousejs/utils"],e):(n=typeof globalThis<"u"?globalThis:n||self,e(n.SupermouseDot={},n.SupermouseUtils))})(this,(function(n,e){"use strict";const m=(r={})=>{const f="#750c7e",y=r.hideOnShape??!0,c=e.normalize(r.size,8),i=e.normalize(r.color,f),l=e.normalize(r.opacity,1);return e.definePlugin({name:"dot",selector:"[data-supermouse-color]",create:t=>{const o=c(t.state),d=i(t.state),s=e.dom.createCircle(o,d);return e.dom.applyStyles(s,{zIndex:r.zIndex||e.Layers.CURSOR,mixBlendMode:r.mixBlendMode||"difference",transition:"background-color 0.2s ease, opacity 0.2s ease"}),s},styles:{},update:(t,o)=>{const d=c(t.state);e.dom.setStyle(o,"width",`${d}px`),e.dom.setStyle(o,"height",`${d}px`);const s=t.state.interaction.color;s?e.dom.setStyle(o,"backgroundColor",s):e.dom.setStyle(o,"backgroundColor",i(t.state));let a=l(t.state);y&&t.state.shape&&(a=0),e.dom.setStyle(o,"opacity",String(a));const{x:u,y:S}=t.state.target;e.dom.setTransform(o,u,S)}},r)};n.Dot=m,Object.defineProperty(n,Symbol.toStringTag,{value:"Module"})}));
package/meta.json ADDED
@@ -0,0 +1,17 @@
1
+ {
2
+ "id": "dot",
3
+ "name": "Dot",
4
+ "package": "@supermousejs/dot",
5
+ "description": "A minimalist precision point that follows your movements perfectly.",
6
+ "code": "app.use(Dot({ size: 8, color: '#750c7e' }));",
7
+ "recipeId": "basic-dot",
8
+ "icon": "dot",
9
+ "options": [
10
+ { "name": "size", "type": "number", "default": "8", "description": "Diameter of the dot in pixels.", "reactive": true },
11
+ { "name": "color", "type": "string", "default": "'#750c7e'", "description": "Background color.", "reactive": true },
12
+ { "name": "opacity", "type": "number", "default": "1", "description": "Opacity level (0-1).", "reactive": true },
13
+ { "name": "mixBlendMode", "type": "string", "default": "'difference'", "description": "CSS blend mode.", "reactive": false },
14
+ { "name": "hideOnShape", "type": "boolean", "default": "true", "description": "Fade out when a shape (like Stick) is active.", "reactive": false },
15
+ { "name": "zIndex", "type": "string", "default": "'300'", "description": "CSS z-index.", "reactive": false }
16
+ ]
17
+ }
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@supermousejs/dot",
3
+ "version": "2.0.0",
4
+ "main": "dist/index.umd.js",
5
+ "module": "dist/index.mjs",
6
+ "types": "dist/index.d.ts",
7
+ "dependencies": {
8
+ "@supermousejs/core": "2.0.0",
9
+ "@supermousejs/utils": "2.0.0"
10
+ },
11
+ "devDependencies": {},
12
+ "peerDependencies": {},
13
+ "exports": {
14
+ ".": {
15
+ "types": "./dist/index.d.ts",
16
+ "import": "./dist/index.mjs",
17
+ "require": "./dist/index.umd.js"
18
+ }
19
+ },
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "scripts": {
24
+ "build": "vite build"
25
+ }
26
+ }
package/src/index.ts ADDED
@@ -0,0 +1,71 @@
1
+ import type { ValueOrGetter } from '@supermousejs/core';
2
+ import { definePlugin, normalize, dom, Layers } from '@supermousejs/utils';
3
+
4
+ export interface DotOptions {
5
+ name?: string;
6
+ isEnabled?: boolean;
7
+ size?: ValueOrGetter<number>;
8
+ color?: ValueOrGetter<string>;
9
+ opacity?: ValueOrGetter<number>;
10
+ zIndex?: string;
11
+ mixBlendMode?: string;
12
+ /** Whether to hide the dot when the cursor is in a 'shape' state (e.g. Stuck). Default true. */
13
+ hideOnShape?: boolean;
14
+ }
15
+
16
+ export const Dot = (options: DotOptions = {}) => {
17
+ const defSize = 8;
18
+ const defColor = '#750c7e';
19
+ const hideOnShape = options.hideOnShape ?? true;
20
+
21
+ // Normalize options once during setup
22
+ const getSize = normalize(options.size, defSize);
23
+ const getColor = normalize(options.color, defColor);
24
+ const getOpacity = normalize(options.opacity, 1);
25
+
26
+ return definePlugin<HTMLDivElement, DotOptions>({
27
+ name: 'dot',
28
+ selector: '[data-supermouse-color]',
29
+
30
+ create: (app) => {
31
+ // Initial values
32
+ const size = getSize(app.state);
33
+ const color = getColor(app.state);
34
+
35
+ const el = dom.createCircle(size, color);
36
+ dom.applyStyles(el, {
37
+ zIndex: options.zIndex || Layers.CURSOR,
38
+ mixBlendMode: options.mixBlendMode || 'difference',
39
+ transition: 'background-color 0.2s ease, opacity 0.2s ease'
40
+ });
41
+ return el;
42
+ },
43
+
44
+ styles: {},
45
+
46
+ update: (app, el) => {
47
+ const size = getSize(app.state);
48
+ dom.setStyle(el, 'width', `${size}px`);
49
+ dom.setStyle(el, 'height', `${size}px`);
50
+
51
+ // Handle Color via Interaction State
52
+ const interactionColor = app.state.interaction.color;
53
+ if (interactionColor) {
54
+ dom.setStyle(el, 'backgroundColor', interactionColor);
55
+ } else {
56
+ dom.setStyle(el, 'backgroundColor', getColor(app.state));
57
+ }
58
+
59
+ let targetOpacity = getOpacity(app.state);
60
+
61
+ if (hideOnShape && app.state.shape) {
62
+ targetOpacity = 0;
63
+ }
64
+
65
+ dom.setStyle(el, 'opacity', String(targetOpacity));
66
+
67
+ const { x, y } = app.state.target;
68
+ dom.setTransform(el, x, y);
69
+ }
70
+ }, options);
71
+ };
package/tsconfig.json ADDED
@@ -0,0 +1,18 @@
1
+ {
2
+ "extends": "../../tsconfig.base.json",
3
+ "include": [
4
+ "src"
5
+ ],
6
+ "compilerOptions": {
7
+ "outDir": "dist",
8
+ "baseUrl": ".",
9
+ "paths": {
10
+ "@supermousejs/core": [
11
+ "../core/src/index.ts"
12
+ ],
13
+ "@supermousejs/utils": [
14
+ "../utils/src/index.ts"
15
+ ]
16
+ }
17
+ }
18
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,22 @@
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: 'SupermouseDot',
10
+ fileName: (format) => format === 'es' ? 'index.mjs' : 'index.umd.js',
11
+ },
12
+ rollupOptions: {
13
+ external: ['@supermousejs/core', '@supermousejs/utils'],
14
+ output: {
15
+ globals: {
16
+ '@supermousejs/core': 'SupermouseCore'
17
+ , '@supermousejs/utils': 'SupermouseUtils'}
18
+ }
19
+ }
20
+ },
21
+ plugins: [dts({ rollupTypes: true })]
22
+ });