@supermousejs/trail 2.2.1 → 2.3.1

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
@@ -1,6 +1,6 @@
1
1
  # @supermousejs/trail
2
2
 
3
- Generates a procedural particle trail that follows the cursor.
3
+ Generates procedural particles that trail behind your motion.
4
4
 
5
5
  ## Installation
6
6
 
@@ -8,23 +8,27 @@ Generates a procedural particle trail that follows the cursor.
8
8
  pnpm add @supermousejs/trail
9
9
  ```
10
10
 
11
- ## Usage
11
+ ## Trail
12
+
13
+ Generates procedural particles that trail behind your motion.
14
+
15
+ ### Usage
12
16
 
13
17
  ```ts
14
18
  import { Supermouse } from "@supermousejs/core";
15
19
  import { Trail } from "@supermousejs/trail";
16
-
17
20
  const app = new Supermouse();
18
-
19
- app.use(
20
- Trail({
21
- length: 10, // Number of segments
22
- size: 6, // Particle size
23
- color: "#ff00ff"
24
- })
25
- );
21
+ app.use(Trail({ length: 12, color: '#f0f' }));
26
22
  ```
27
23
 
24
+ ### Options
25
+
26
+ | Name | Type | Default | Description |
27
+ | --- | --- | --- | --- |
28
+ | length | number | 10 | Number of trail segments. |
29
+ | size | number | 6 | Size of trail particles. |
30
+ | color | string | '#ff00ff' | Color of segments. |
31
+
28
32
  ## Documentation
29
33
 
30
34
  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/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { SupermousePlugin } from '../../core/src';
2
- import { ValueOrGetter } from '../../core/src';
1
+ import { SupermousePlugin } from '../packages/core/src';
2
+ import { ValueOrGetter } from '../packages/core/src';
3
3
 
4
4
  export declare const Trail: (options?: TrailOptions) => SupermousePlugin;
5
5
 
package/package.json CHANGED
@@ -1,20 +1,24 @@
1
1
  {
2
2
  "name": "@supermousejs/trail",
3
- "version": "2.2.1",
3
+ "version": "2.3.1",
4
4
  "main": "dist/index.umd.js",
5
5
  "module": "dist/index.mjs",
6
6
  "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
7
11
  "author": "O.S David",
8
12
  "url": "https://github.com/Whitestar14/supermouse-js",
9
13
  "license": "MIT",
10
14
  "dependencies": {
11
- "@supermousejs/utils": "2.2.0"
15
+ "@supermousejs/utils": "2.3.1"
12
16
  },
13
17
  "devDependencies": {
14
- "@supermousejs/core": "2.1.0"
18
+ "@supermousejs/core": "2.3.0"
15
19
  },
16
20
  "peerDependencies": {
17
- "@supermousejs/core": "2.1.0"
21
+ "@supermousejs/core": "2.3.0"
18
22
  },
19
23
  "repository": {
20
24
  "type": "git",
package/CHANGELOG.md DELETED
@@ -1,88 +0,0 @@
1
- # @supermousejs/trail
2
-
3
- ## 2.2.1
4
-
5
- ### Patch Changes
6
-
7
- - a72f5a3: bugfix: fixed a type declaration issue from missing `return` keyword with the Trail package export
8
-
9
- ## 2.2.0
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
- - Updated dependencies [9fe1a7b]
19
- - Updated dependencies [9fa6ece]
20
- - @supermousejs/core@2.1.0
21
- - @supermousejs/utils@2.2.0
22
-
23
- ## 2.1.1
24
-
25
- ### Patch Changes
26
-
27
- - 67f771b: Add relevant npm metadata to package.json file
28
- - Updated dependencies [67f771b]
29
- - @supermousejs/utils@2.1.1
30
- - @supermousejs/core@2.0.5
31
-
32
- ## 2.1.0
33
-
34
- ### Minor Changes
35
-
36
- - 0a1652d: fixed build architecture and updated plugin metadata
37
-
38
- ### Patch Changes
39
-
40
- - Updated dependencies [0a1652d]
41
- - @supermousejs/utils@2.1.0
42
-
43
- ## 2.0.4
44
-
45
- ### Patch Changes
46
-
47
- - 993dc67: Updated supemousejs packages with proper author, license and url descriptors to repo
48
- - Updated dependencies [993dc67]
49
- - @supermousejs/utils@2.0.4
50
- - @supermousejs/core@2.0.4
51
-
52
- ## 2.0.3
53
-
54
- ### Patch Changes
55
-
56
- - Updated dependencies
57
- - @supermousejs/core@2.0.3
58
- - @supermousejs/utils@2.0.3
59
-
60
- ## 2.0.2
61
-
62
- ### Patch Changes
63
-
64
- - ae219a0: Update READMEs with correct link to documentation
65
- - Updated dependencies [ae219a0]
66
- - @supermousejs/utils@2.0.2
67
- - @supermousejs/core@2.0.2
68
-
69
- ## 2.0.1
70
-
71
- ### Patch Changes
72
-
73
- - Add minimal README.md files to packages
74
- - Updated dependencies
75
- - @supermousejs/utils@2.0.1
76
- - @supermousejs/core@2.0.1
77
-
78
- ## 2.0.0
79
-
80
- ### Major Changes
81
-
82
- - Initial v2.0.0 release
83
-
84
- ### Patch Changes
85
-
86
- - Updated dependencies
87
- - @supermousejs/utils@2.0.0
88
- - @supermousejs/core@2.0.0
package/meta.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "id": "trail",
3
- "name": "Trail",
4
- "package": "@supermousejs/trail",
5
- "description": "Generates procedural particles that trail behind your motion.",
6
- "code": "app.use(Trail({ length: 12, color: '#f0f' }));",
7
- "recipeId": "ghost-trail",
8
- "icon": "trail",
9
- "options": [
10
- {
11
- "name": "length",
12
- "type": "number",
13
- "default": "10",
14
- "description": "Number of trail segments.",
15
- "reactive": false
16
- },
17
- {
18
- "name": "size",
19
- "type": "number",
20
- "default": "6",
21
- "description": "Size of trail particles.",
22
- "reactive": true
23
- },
24
- {
25
- "name": "color",
26
- "type": "string",
27
- "default": "'#ff00ff'",
28
- "description": "Color of segments.",
29
- "reactive": true
30
- }
31
- ]
32
- }
package/src/index.ts DELETED
@@ -1,66 +0,0 @@
1
- import type { ValueOrGetter, Supermouse } from "@supermousejs/core";
2
- import { definePlugin, normalize, dom, Layers } from "@supermousejs/utils";
3
-
4
- export interface TrailOptions {
5
- name?: string;
6
- isEnabled?: boolean;
7
- length?: number;
8
- size?: ValueOrGetter<number>;
9
- color?: ValueOrGetter<string>;
10
- }
11
-
12
- export const Trail = (options: TrailOptions = {}) => {
13
- const length = options.length || 10;
14
- const getSize = normalize(options.size, 6);
15
- const getColor = normalize(options.color, "#ff00ff");
16
-
17
- const segments: HTMLDivElement[] = [];
18
- const history: { x: number; y: number }[] = [];
19
-
20
- return definePlugin<HTMLDivElement, TrailOptions>(
21
- {
22
- name: options.name || "trail",
23
-
24
- create: () => {
25
- segments.length = 0;
26
- history.length = 0;
27
- const container = dom.createActor("div") as HTMLDivElement;
28
- container.style.zIndex = Layers.TRACE;
29
-
30
- for (let i = 0; i < length; i++) {
31
- const d = dom.createCircle(0, "#000");
32
- d.style.position = "absolute";
33
- d.style.opacity = String(1 - i / length);
34
- container.appendChild(d);
35
- segments.push(d);
36
- history.push({ x: -100, y: -100 });
37
- }
38
- return container;
39
- },
40
-
41
- update: (app: Supermouse) => {
42
- const { x, y } = app.state.smooth;
43
-
44
- // Shift history
45
- history.pop();
46
- history.unshift({ x, y });
47
-
48
- const baseSize = getSize(app.state);
49
- const color = getColor(app.state);
50
-
51
- segments.forEach((seg, i) => {
52
- const pos = history[i];
53
- const scale = 1 - i / length;
54
- const size = baseSize * scale;
55
-
56
- dom.setStyle(seg, "width", `${size}px`);
57
- dom.setStyle(seg, "height", `${size}px`);
58
- dom.setStyle(seg, "backgroundColor", color);
59
-
60
- dom.setTransform(seg, pos.x, pos.y);
61
- });
62
- }
63
- },
64
- options
65
- );
66
- };
package/tsconfig.json DELETED
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.plugin.json",
3
- "include": ["src"]
4
- }
package/vite.config.ts DELETED
@@ -1,23 +0,0 @@
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: "SupermouseTrail",
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
- },
22
- plugins: [dts({ rollupTypes: true })]
23
- });