@supermousejs/vue 2.3.0 → 2.4.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/README.md CHANGED
@@ -10,27 +10,44 @@ pnpm add @supermousejs/vue @supermousejs/core
10
10
 
11
11
  ## Usage
12
12
 
13
- **In `App.vue` (Root):**
13
+ In `App.vue`/root file:
14
14
 
15
15
  ```vue
16
16
  <script setup>
17
17
  import { provideSupermouse } from "@supermousejs/vue";
18
18
  import { Dot } from "@supermousejs/dot";
19
19
 
20
- provideSupermouse({ smoothness: 0.15 }, [Dot({ size: 8 })]);
20
+ const { instance, isEnabled } = provideSupermouse({ smoothness: 0.15 }, [Dot({ size: 8 })]);
21
21
  </script>
22
22
  ```
23
23
 
24
- **In Components:**
24
+ And in your components:
25
25
 
26
26
  ```vue
27
27
  <script setup>
28
28
  import { useSupermouse } from "@supermousejs/vue";
29
29
 
30
- const mouse = useSupermouse(); // Returns Ref<Supermouse | null>
30
+ const { instance, isEnabled } = useSupermouse();
31
+
32
+ function toggleCursor() {
33
+ if (instance.value) {
34
+ if (isEnabled.value) instance.value.disable();
35
+ else instance.value.enable();
36
+ }
37
+ }
31
38
  </script>
39
+
40
+ <template>
41
+ <button @click="toggleCursor">{{ isEnabled ? "Disable" : "Enable" }} Cursor</button>
42
+ </template>
32
43
  ```
33
44
 
45
+ `provideSupermouse()` and `useSupermouse()` both return:
46
+
47
+ - `instance`: A `Ref<SupermouseInstance | null>`.
48
+ - `isEnabled`: A `Ref<boolean>` that stays in sync with `enable()` / `disable()`.
49
+
34
50
  ## Documentation
35
51
 
36
- Full documentation and interactive playground available at [supermouse](https://supermouse.js.org) or [check out the repo](https://github.com/Whitestar14/supermouse-js).
52
+ Full documentation and interactive playground: [supermouse.js.org](https://supermouse.js.org)
53
+ Repository: [github.com/Whitestar14/supermouse-js](https://github.com/Whitestar14/supermouse-js)
package/dist/index.mjs CHANGED
@@ -1,24 +1,37 @@
1
- import { shallowRef as u, onMounted as i, onUnmounted as l, provide as p, inject as m } from "vue";
2
- import { Supermouse as a } from "@supermousejs/core";
3
- const r = /* @__PURE__ */ Symbol("Supermouse");
4
- function f(o = {}, s = []) {
5
- const e = u(null);
6
- return i(() => {
7
- if (e.value) return;
8
- const n = new a(o);
9
- s.forEach((t) => n.use(t)), e.value = n;
10
- }), l(() => {
11
- e.value && (e.value.destroy(), e.value = null);
12
- }), p(r, e), e;
1
+ import { shallowRef as s, ref as t, onMounted as m, onUnmounted as d, provide as f, inject as v } from "vue";
2
+ import { Supermouse as b } from "@supermousejs/core";
3
+ import { Supermouse as h } from "@supermousejs/core";
4
+ const l = /* @__PURE__ */ Symbol("Supermouse");
5
+ function x(o = {}, a = []) {
6
+ const n = s(null), u = t(!0);
7
+ m(() => {
8
+ if (n.value) return;
9
+ const e = new b(o);
10
+ a.forEach((p) => e.use(p));
11
+ const i = e.enable.bind(e), c = e.disable.bind(e);
12
+ e.enable = () => {
13
+ i(), u.value = !0;
14
+ }, e.disable = () => {
15
+ c(), u.value = !1;
16
+ }, n.value = e;
17
+ }), d(() => {
18
+ n.value && (n.value.destroy(), n.value = null, u.value = !0);
19
+ });
20
+ const r = { instance: n, isEnabled: u };
21
+ return f(l, r), r;
13
22
  }
14
- function v() {
15
- const o = m(r);
23
+ function w() {
24
+ const o = v(l);
16
25
  return o || (console.warn(
17
26
  "[Supermouse] No instance provided. Ensure provideSupermouse() is called in a parent component."
18
- ), u(null));
27
+ ), {
28
+ instance: s(null),
29
+ isEnabled: t(!0)
30
+ });
19
31
  }
20
32
  export {
21
- r as SupermouseKey,
22
- f as provideSupermouse,
23
- v as useSupermouse
33
+ h as Supermouse,
34
+ l as SupermouseKey,
35
+ x as provideSupermouse,
36
+ w as useSupermouse
24
37
  };
package/dist/index.umd.js CHANGED
@@ -1 +1 @@
1
- (function(e,u){typeof exports=="object"&&typeof module<"u"?u(exports,require("vue"),require("@supermousejs/core")):typeof define=="function"&&define.amd?define(["exports","vue","@supermousejs/core"],u):(e=typeof globalThis<"u"?globalThis:e||self,u(e.SupermouseVue={},e.Vue,e.SupermouseCore))})(this,(function(e,u,i){"use strict";const r=Symbol("Supermouse");function t(n={},d=[]){const o=u.shallowRef(null);return u.onMounted(()=>{if(o.value)return;const s=new i.Supermouse(n);d.forEach(m=>s.use(m)),o.value=s}),u.onUnmounted(()=>{o.value&&(o.value.destroy(),o.value=null)}),u.provide(r,o),o}function p(){const n=u.inject(r);return n||(console.warn("[Supermouse] No instance provided. Ensure provideSupermouse() is called in a parent component."),u.shallowRef(null))}e.SupermouseKey=r,e.provideSupermouse=t,e.useSupermouse=p,Object.defineProperty(e,Symbol.toStringTag,{value:"Module"})}));
1
+ (function(u,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@supermousejs/core")):typeof define=="function"&&define.amd?define(["exports","vue","@supermousejs/core"],e):(u=typeof globalThis<"u"?globalThis:u||self,e(u.SupermouseVue={},u.Vue,u.SupermouseCore))})(this,(function(u,e,i){"use strict";const t=Symbol("Supermouse");function d(r={},a=[]){const o=e.shallowRef(null),s=e.ref(!0);e.onMounted(()=>{if(o.value)return;const n=new i.Supermouse(r);a.forEach(m=>n.use(m));const c=n.enable.bind(n),f=n.disable.bind(n);n.enable=()=>{c(),s.value=!0},n.disable=()=>{f(),s.value=!1},o.value=n}),e.onUnmounted(()=>{o.value&&(o.value.destroy(),o.value=null,s.value=!0)});const l={instance:o,isEnabled:s};return e.provide(t,l),l}function p(){const r=e.inject(t);return r||(console.warn("[Supermouse] No instance provided. Ensure provideSupermouse() is called in a parent component."),{instance:e.shallowRef(null),isEnabled:e.ref(!0)})}Object.defineProperty(u,"Supermouse",{enumerable:!0,get:()=>i.Supermouse}),u.SupermouseKey=t,u.provideSupermouse=d,u.useSupermouse=p,Object.defineProperty(u,Symbol.toStringTag,{value:"Module"})}));
@@ -1,18 +1,23 @@
1
1
  import { Ref, InjectionKey } from 'vue';
2
- import { Supermouse, SupermouseOptions, SupermousePlugin } from '../packages/core/src';
3
- export declare const SupermouseKey: InjectionKey<Ref<Supermouse | null>>;
2
+ import { SupermouseOptions, SupermousePlugin, SupermouseInstance } from '../packages/core/src';
3
+ export interface SupermouseContext {
4
+ instance: Ref<SupermouseInstance | null>;
5
+ isEnabled: Ref<boolean>;
6
+ }
7
+ export declare const SupermouseKey: InjectionKey<SupermouseContext>;
4
8
  /**
5
9
  * Initializes a Supermouse instance, handles its lifecycle, and provides it to the component tree.
6
- * Use this in your root component (e.g., App.vue).
10
+ * Also exposes a reactive `isEnabled` ref that stays in sync with the instance's enable/disable state.
7
11
  *
8
12
  * @param options Core configuration options
9
13
  * @param plugins Array of plugins to install immediately
10
14
  */
11
- export declare function provideSupermouse(options?: SupermouseOptions, plugins?: SupermousePlugin[]): Ref<Supermouse | null>;
15
+ export declare function provideSupermouse(options?: SupermouseOptions, plugins?: SupermousePlugin[]): SupermouseContext;
12
16
  /**
13
- * Injects the global Supermouse instance from a parent component.
14
- * @returns A Ref containing the Supermouse instance or null if not provided.
15
- * @warn Make sure to call provideSupermouse() in a parent component, otherwise this will return null.
17
+ * Injects the global Supermouse context (instance + reactive isEnabled).
18
+ * @returns The context, or a default empty context if not provided.
16
19
  */
17
- export declare function useSupermouse(): Ref<Supermouse | null>;
20
+ export declare function useSupermouse(): SupermouseContext;
21
+ export { Supermouse } from '../packages/core/src';
22
+ export type { SupermouseInstance, SupermouseOptions, SupermousePlugin } from '../packages/core/src';
18
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,UAAU,EAAE,KAAK,iBAAiB,EAAE,KAAK,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE/F,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,CAAwB,CAAC;AAExF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,iBAAsB,EAC/B,OAAO,GAAE,gBAAgB,EAAO,GAC/B,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,CAqBxB;AAED;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,GAAG,CAAC,UAAU,GAAG,IAAI,CAAC,CAStD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAOL,KAAK,GAAG,EACR,KAAK,YAAY,EAClB,MAAM,KAAK,CAAC;AAEb,OAAO,KAAK,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAElG,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,GAAG,CAAC,kBAAkB,GAAG,IAAI,CAAC,CAAC;IACzC,SAAS,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;CACzB;AAED,eAAO,MAAM,aAAa,EAAE,YAAY,CAAC,iBAAiB,CAAwB,CAAC;AAEnF;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,GAAE,iBAAsB,EAC/B,OAAO,GAAE,gBAAgB,EAAO,GAC/B,iBAAiB,CAsCnB;AAED;;;GAGG;AACH,wBAAgB,aAAa,IAAI,iBAAiB,CAYjD;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,YAAY,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC"}
package/package.json CHANGED
@@ -1,19 +1,24 @@
1
1
  {
2
2
  "name": "@supermousejs/vue",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "main": "dist/index.umd.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
7
+ "description": "Vue 3 integration for Supermouse",
8
+ "files": [
9
+ "dist",
10
+ "README.md"
11
+ ],
7
12
  "author": "O.S David",
8
13
  "url": "https://github.com/Whitestar14/supermouse-js",
9
14
  "license": "MIT",
10
15
  "peerDependencies": {
11
16
  "vue": "^3.2.0",
12
- "@supermousejs/core": "2.2.0"
17
+ "@supermousejs/core": "2.4.0"
13
18
  },
14
19
  "devDependencies": {
15
20
  "vue": "^3.2.0",
16
- "@supermousejs/core": "2.2.0"
21
+ "@supermousejs/core": "2.4.0"
17
22
  },
18
23
  "repository": {
19
24
  "type": "git",
package/CHANGELOG.md DELETED
@@ -1,80 +0,0 @@
1
- # @supermousejs/vue
2
-
3
- ## 2.3.0
4
-
5
- ### Patch Changes
6
-
7
- - Updated dependencies [f6f44b2]
8
- - @supermousejs/core@2.2.0
9
-
10
- ## 2.2.0
11
-
12
- ### Minor Changes
13
-
14
- - 9fe1a7b: - Implemented idiomatic approach to using supermouse/utils
15
- - Rewrote `applyStyles`, `setTransform` and `setStyles` to share a global cache registry
16
-
17
- ### Patch Changes
18
-
19
- - 6d70c18: remove legacy package and update supermouse domain in readme
20
- - 14fb5b6: Updated tsconfig to be reference-compliant with core, utils and zoetrope when required
21
- - Updated dependencies [6d70c18]
22
- - Updated dependencies [2590af3]
23
- - Updated dependencies [14fb5b6]
24
- - @supermousejs/core@2.1.0
25
-
26
- ## 2.1.1
27
-
28
- ### Patch Changes
29
-
30
- - 67f771b: Add relevant npm metadata to package.json file
31
- - Updated dependencies [67f771b]
32
- - @supermousejs/core@2.0.5
33
-
34
- ## 2.1.0
35
-
36
- ### Minor Changes
37
-
38
- - 0a1652d: fixed build architecture and updated plugin metadata
39
-
40
- ## 2.0.4
41
-
42
- ### Patch Changes
43
-
44
- - 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
45
- - Updated dependencies [993dc67]
46
- - @supermousejs/core@2.0.4
47
-
48
- ## 2.0.3
49
-
50
- ### Patch Changes
51
-
52
- - Updated dependencies
53
- - @supermousejs/core@2.0.3
54
-
55
- ## 2.0.2
56
-
57
- ### Patch Changes
58
-
59
- - ae219a0: Update READMEs with correct link to documentation
60
- - Updated dependencies [ae219a0]
61
- - @supermousejs/core@2.0.2
62
-
63
- ## 2.0.1
64
-
65
- ### Patch Changes
66
-
67
- - Add minimal README.md files to packages
68
- - Updated dependencies
69
- - @supermousejs/core@2.0.1
70
-
71
- ## 2.0.0
72
-
73
- ### Major Changes
74
-
75
- - Initial v2.0.0 release
76
-
77
- ### Patch Changes
78
-
79
- - Updated dependencies
80
- - @supermousejs/core@2.0.0
package/src/index.ts DELETED
@@ -1,61 +0,0 @@
1
- import {
2
- onMounted,
3
- onUnmounted,
4
- provide,
5
- inject,
6
- shallowRef,
7
- type Ref,
8
- type InjectionKey
9
- } from "vue";
10
- import { Supermouse, type SupermouseOptions, type SupermousePlugin } from "@supermousejs/core";
11
-
12
- export const SupermouseKey: InjectionKey<Ref<Supermouse | null>> = Symbol("Supermouse");
13
-
14
- /**
15
- * Initializes a Supermouse instance, handles its lifecycle, and provides it to the component tree.
16
- * Use this in your root component (e.g., App.vue).
17
- *
18
- * @param options Core configuration options
19
- * @param plugins Array of plugins to install immediately
20
- */
21
- export function provideSupermouse(
22
- options: SupermouseOptions = {},
23
- plugins: SupermousePlugin[] = []
24
- ): Ref<Supermouse | null> {
25
- const instance = shallowRef<Supermouse | null>(null);
26
-
27
- onMounted(() => {
28
- if (instance.value) return;
29
-
30
- const mouse = new Supermouse(options);
31
- plugins.forEach((p) => mouse.use(p));
32
- instance.value = mouse;
33
- });
34
-
35
- onUnmounted(() => {
36
- if (instance.value) {
37
- instance.value.destroy();
38
- instance.value = null;
39
- }
40
- });
41
-
42
- provide(SupermouseKey, instance);
43
-
44
- return instance;
45
- }
46
-
47
- /**
48
- * Injects the global Supermouse instance from a parent component.
49
- * @returns A Ref containing the Supermouse instance or null if not provided.
50
- * @warn Make sure to call provideSupermouse() in a parent component, otherwise this will return null.
51
- */
52
- export function useSupermouse(): Ref<Supermouse | null> {
53
- const instance = inject(SupermouseKey);
54
- if (!instance) {
55
- console.warn(
56
- "[Supermouse] No instance provided. Ensure provideSupermouse() is called in a parent component."
57
- );
58
- return shallowRef(null);
59
- }
60
- return instance;
61
- }
package/tsconfig.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.framework.json",
3
- "include": ["src"]
4
- }
package/vite.config.ts DELETED
@@ -1,34 +0,0 @@
1
- import { defineConfig } from "vite";
2
- import dts from "vite-plugin-dts";
3
- import path from "path";
4
- import { writeFileSync } from "fs";
5
-
6
- export default defineConfig({
7
- build: {
8
- lib: {
9
- entry: path.resolve(__dirname, "src/index.ts"),
10
- name: "SupermouseVue",
11
- fileName: (format) => (format === "es" ? "index.mjs" : "index.umd.js")
12
- },
13
- rollupOptions: {
14
- external: ["vue", "@supermousejs/core"],
15
- output: {
16
- globals: {
17
- vue: "Vue",
18
- "@supermousejs/core": "SupermouseCore"
19
- }
20
- }
21
- }
22
- },
23
- plugins: [
24
- dts({ rollupTypes: false }),
25
- {
26
- name: "dts-wrapper",
27
- apply: "build",
28
- closeBundle: async () => {
29
- const wrapperContent = `export * from "./vue/src/index";\n`;
30
- writeFileSync(path.resolve(__dirname, "dist/index.d.ts"), wrapperContent);
31
- }
32
- }
33
- ]
34
- });