@supermousejs/vue 2.3.1 → 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 +22 -5
- package/dist/index.mjs +31 -18
- package/dist/index.umd.js +1 -1
- package/dist/vue/src/index.d.ts +13 -9
- package/dist/vue/src/index.d.ts.map +1 -1
- package/package.json +4 -3
package/README.md
CHANGED
|
@@ -10,27 +10,44 @@ pnpm add @supermousejs/vue @supermousejs/core
|
|
|
10
10
|
|
|
11
11
|
## Usage
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
|
2
|
-
import { Supermouse as
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
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
|
|
15
|
-
const o =
|
|
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
|
-
),
|
|
27
|
+
), {
|
|
28
|
+
instance: s(null),
|
|
29
|
+
isEnabled: t(!0)
|
|
30
|
+
});
|
|
19
31
|
}
|
|
20
32
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
|
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"})}));
|
package/dist/vue/src/index.d.ts
CHANGED
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import { Ref, InjectionKey } from 'vue';
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
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
|
-
*
|
|
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[]):
|
|
15
|
+
export declare function provideSupermouse(options?: SupermouseOptions, plugins?: SupermousePlugin[]): SupermouseContext;
|
|
12
16
|
/**
|
|
13
|
-
* Injects the global Supermouse instance
|
|
14
|
-
* @returns
|
|
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():
|
|
18
|
-
export
|
|
20
|
+
export declare function useSupermouse(): SupermouseContext;
|
|
21
|
+
export { Supermouse } from '../packages/core/src';
|
|
22
|
+
export type { SupermouseInstance, SupermouseOptions, SupermousePlugin } from '../packages/core/src';
|
|
19
23
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
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,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supermousejs/vue",
|
|
3
|
-
"version": "2.
|
|
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",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist",
|
|
9
10
|
"README.md"
|
|
@@ -13,11 +14,11 @@
|
|
|
13
14
|
"license": "MIT",
|
|
14
15
|
"peerDependencies": {
|
|
15
16
|
"vue": "^3.2.0",
|
|
16
|
-
"@supermousejs/core": "2.
|
|
17
|
+
"@supermousejs/core": "2.4.0"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
19
20
|
"vue": "^3.2.0",
|
|
20
|
-
"@supermousejs/core": "2.
|
|
21
|
+
"@supermousejs/core": "2.4.0"
|
|
21
22
|
},
|
|
22
23
|
"repository": {
|
|
23
24
|
"type": "git",
|