@fluritheme/fairy-dust 0.0.0-stage → 1.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,5 @@
1
+ # Changelog
2
+
3
+ ## 1.0.0 — 2026-11-29
4
+
5
+ - First release.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 František Gejdoš (Fluri, https://fluri.xyz)
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 CHANGED
@@ -1,3 +1,103 @@
1
- # Temporary Holding Version
1
+ # Fairy Dust by Fluri
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Leave a little sparkle behind. Magic fairy dust cursor trail for any website.
4
+
5
+ **[Live demo →](https://fluri.xyz/fairy-dust/)** · [All Fluri themes](https://fluri.xyz/themes/) · No-code install for WordPress, Shopify, Wix & more at [fluri.xyz](https://fluri.xyz/fairy-dust/)
6
+
7
+ ![Fairy Dust by Fluri on a website](https://cdn.jsdelivr.net/npm/@fluritheme/fairy-dust@1/media/preview.png)
8
+
9
+ - Zero dependencies, about 5 KB minified
10
+ - One canvas with `pointer-events: none`: never blocks clicks, scrolling or text selection
11
+ - Respects `prefers-reduced-motion` and pauses when the tab is hidden
12
+ - Works with plain HTML, React, Vue, Svelte, Astro, Next.js and anything else
13
+ - TypeScript types included
14
+
15
+ ## Quick start: one line of HTML
16
+
17
+ Paste this before `</body>`:
18
+
19
+ ```html
20
+ <script src="https://cdn.jsdelivr.net/npm/@fluritheme/fairy-dust@1/dist/fairy-dust.global.js" data-auto></script>
21
+ ```
22
+
23
+ Pass options as JSON:
24
+
25
+ ```html
26
+ <script src="https://cdn.jsdelivr.net/npm/@fluritheme/fairy-dust@1/dist/fairy-dust.global.js" data-auto data-options='{"palette":"rainbow"}'></script>
27
+ ```
28
+
29
+ The running effect is available as `window.FluriFairyDust.instance`.
30
+
31
+ ## Install with npm
32
+
33
+ ```sh
34
+ npm install @fluritheme/fairy-dust
35
+ ```
36
+
37
+ ```ts
38
+ import { createFairyDust } from "@fluritheme/fairy-dust";
39
+
40
+ const dust = createFairyDust({
41
+ palette: "gold", // "rainbow" | "silver" | "rose" | "aurora"
42
+ density: 1,
43
+ });
44
+
45
+ dust.swirl(); // a sweeping swirl of sparkles
46
+ dust.burst(); // sparkle burst in the centre
47
+ dust.setPalette("aurora");
48
+
49
+ // When leaving the page or unmounting a component:
50
+ dust.destroy();
51
+ ```
52
+
53
+ ### React
54
+
55
+ ```tsx
56
+ import { useEffect } from "react";
57
+ import { createFairyDust } from "@fluritheme/fairy-dust";
58
+
59
+ export function FairyDust() {
60
+ useEffect(() => {
61
+ const effect = createFairyDust();
62
+ return () => effect.destroy();
63
+ }, []);
64
+ return null;
65
+ }
66
+ ```
67
+
68
+ ## Options
69
+
70
+ | Option | What it does | Default |
71
+ | --- | --- | --- |
72
+ | `palette` | "gold", "rainbow", "silver", "rose" or "aurora" | `"gold"` |
73
+ | `density` | How many sparkles, 0.2–2 | `1` |
74
+ | `size` | Sparkle size, 0.5–2 | `1` |
75
+ | `trail` | Seconds each sparkle lives, 0.4–2.5 | `1.1` |
76
+ | `clickBurst` | Burst of stars on click | `true` |
77
+ | `glow` | Soft glow around sparkles | `true` |
78
+ | `root` | Limit the effect to one element | document |
79
+ | `zIndex` | Stacking order of the canvas | `2147483000` |
80
+
81
+ ## Methods
82
+
83
+ - `swirl()`
84
+ - `burst(x?, y?)`
85
+ - `setPalette(name)`
86
+ - `update(options)`
87
+ - `pause()`
88
+ - `resume()`
89
+ - `destroy()`
90
+
91
+ ## Great for
92
+
93
+ - Portfolios, creators and personal sites
94
+ - Kids’ brands, toys and gift shops
95
+ - Weddings, beauty and anything magical
96
+
97
+ ## No code? Use Fluri
98
+
99
+ Don’t want to touch code? [Fluri](https://fluri.xyz/fairy-dust/) installs Fairy Dust on WordPress, Shopify, Webflow, Wix, Squarespace and Framer with one snippet, with live settings and a dashboard. There are more than a dozen animated themes, from a pet dragon to a koi pond. [See them all →](https://fluri.xyz/themes/)
100
+
101
+ ## License
102
+
103
+ MIT © František Gejdoš · [fluri.xyz](https://fluri.xyz)
@@ -0,0 +1,24 @@
1
+ export interface FairyDustOptions {
2
+ root?: HTMLElement;
3
+ palette?: "gold" | "rainbow" | "silver" | "rose" | "aurora";
4
+ density?: number;
5
+ size?: number;
6
+ trail?: number;
7
+ clickBurst?: boolean;
8
+ glow?: boolean;
9
+ zIndex?: number;
10
+ }
11
+ export declare function createFairyDust(options?: FairyDustOptions): {
12
+ pause: () => void;
13
+ resume: () => void;
14
+ destroy(): void;
15
+ /** A sweeping swirl of dust across the area. */
16
+ swirl(): void;
17
+ burst(x?: number, y?: number): void;
18
+ setPalette(p: FairyDustOptions["palette"]): void;
19
+ update(next: Partial<FairyDustOptions>): void;
20
+ getState: () => {
21
+ sparks: number;
22
+ palette: string;
23
+ };
24
+ };
@@ -0,0 +1,2 @@
1
+ /*! @fluritheme/fairy-dust v1.0.0 | MIT | https://fluri.xyz/fairy-dust/ */
2
+ (()=>{function I(i={}){var L,F,O,S;let n=document.createElement("canvas");n.setAttribute("aria-hidden","true"),n.dataset.fluri="overlay",Object.assign(n.style,{position:i.root?"absolute":"fixed",inset:"0",width:"100%",height:"100%",pointerEvents:"none",zIndex:String((L=i.zIndex)!=null?L:2147483e3),contain:"strict"});let o=(F=i.root)!=null?F:document.body;i.root&&getComputedStyle(i.root).position==="static"&&(i.root.style.position="relative"),o.append(n);let a=n.getContext("2d"),d=matchMedia("(prefers-reduced-motion: reduce)").matches,p=0,u=0,l=!1,m=!1,y=null,M=1e3/((O=i.maxFPS)!=null?O:60)-1,w={canvas:n,ctx:a,width:0,height:0,reduced:d,origin(){if(!i.root)return{x:0,y:0};let e=i.root.getBoundingClientRect();return{x:e.left,y:e.top}},start(e){y=e,x(performance.now())},pause(){l=!0,cancelAnimationFrame(p)},resume(){m||!l||(l=!1,u=performance.now(),x(u))},destroy(){m=!0,cancelAnimationFrame(p),E.disconnect(),removeEventListener("resize",f),document.removeEventListener("visibilitychange",v),n.remove()}};function f(){let e=Math.min(2,devicePixelRatio||1),r=i.root?i.root.clientWidth:innerWidth,t=i.root?i.root.clientHeight:innerHeight;w.width=r,w.height=t,n.width=Math.round(r*e),n.height=Math.round(t*e),a.setTransform(e,0,0,e,0,0)}function x(e){if(l||m||(p=requestAnimationFrame(x),e-u<M))return;let r=Math.min(.05,(e-(u||e))/1e3);u=e,y==null||y(r,e/1e3)}function v(){document.hidden?cancelAnimationFrame(p):!l&&!m&&(u=performance.now(),x(u))}let E=new ResizeObserver(f);return E.observe((S=i.root)!=null?S:document.documentElement),addEventListener("resize",f),document.addEventListener("visibilitychange",v),f(),w}var h=(i,n)=>i+Math.random()*(n-i);var k={gold:["#fff3b0","#ffd166","#ffe8a3","#f6bd60"],silver:["#ffffff","#e0e6ef","#c7d2e0","#f8f9ff"],rose:["#ffc8dd","#ffafcc","#ffe5ec","#f9a8d4"],aurora:["#a7f3d0","#93c5fd","#c4b5fd","#f0abfc"]};function D(i={}){var S;let n={palette:"gold",density:1,size:1,trail:1.1,clickBurst:!0,glow:!0,...i},o=I({root:n.root,zIndex:n.zIndex}),{ctx:a}=o,d=[],p=-1,u=-1,l=-1,m=-1,y=0,M=0,w=()=>{var r;if(n.palette==="rainbow")return y=(y+7)%360,`hsl(${y} 95% 72%)`;let e=(r=k[n.palette])!=null?r:k.gold;return e[Math.floor(Math.random()*e.length)]};function f(e,r,t,s=40,c=n.trail){for(let g=0;g<t;g++){let b=h(0,Math.PI*2),z=h(s*.2,s);d.push({x:e+h(-3,3),y:r+h(-3,3),vx:Math.cos(b)*z,vy:Math.sin(b)*z-10,life:h(c*.6,c),max:c,size:h(3,7)*n.size,color:w(),spin:h(0,Math.PI),kind:Math.random()<.55?0:1})}d.length>700&&d.splice(0,d.length-700)}function x(e,r,t,s){a.beginPath();for(let c=0;c<8;c++){let g=c%2?t*.28:t,b=s+c*Math.PI/4;a.lineTo(e+Math.cos(b)*g,r+Math.sin(b)*g)}a.closePath(),a.fill()}o.start(e=>{a.clearRect(0,0,o.width,o.height),M+=e,p>=0&&M>.35&&Math.random()<e*3*n.density&&!o.reduced&&f(p+h(-14,14),u+h(-14,14),1,10,n.trail*.8),a.globalCompositeOperation=n.glow?"lighter":"source-over";for(let r=d.length-1;r>=0;r--){let t=d[r];if(t.life-=e,t.life<=0){d.splice(r,1);continue}t.vy+=26*e,t.vx*=1-Math.min(1,e*2),t.x+=t.vx*e,t.y+=t.vy*e,t.spin+=e*2;let s=t.life/t.max,c=t.size*(.4+.6*s)*(.85+.15*Math.sin(t.spin*6));a.globalAlpha=Math.min(1,s*1.4),a.fillStyle=t.color,n.glow&&(a.shadowColor=t.color,a.shadowBlur=c*3),t.kind===0?x(t.x,t.y,c*1.6,t.spin):(a.beginPath(),a.arc(t.x,t.y,c*.45,0,Math.PI*2),a.fill())}a.shadowBlur=0,a.globalAlpha=1,a.globalCompositeOperation="source-over"});let v=(S=n.root)!=null?S:window,E=(e,r)=>!n.root||e>=0&&r>=0&&e<=o.width&&r<=o.height,L=e=>{let r=o.origin(),t=e.clientX-r.x,s=e.clientY-r.y;if(E(t,s)&&(p=t,u=s,M=0,!o.reduced)){if(l>=0){let c=Math.hypot(t-l,s-m),g=Math.min(10,Math.round(c/7*n.density));for(let b=0;b<g;b++){let z=(b+1)/g;f(l+(t-l)*z,m+(s-m)*z,1,24)}}l=t,m=s}},F=()=>{l=m=p=u=-1},O=e=>{if(!n.clickBurst)return;let r=o.origin(),t=e.clientX-r.x,s=e.clientY-r.y;E(t,s)&&f(t,s,o.reduced?6:Math.round(26*n.density),150,n.trail*.9)};return v.addEventListener("pointermove",L,{passive:!0}),v.addEventListener("pointerdown",O,{passive:!0}),v.addEventListener("pointerleave",F,{passive:!0}),{pause:()=>o.pause(),resume:()=>o.resume(),destroy(){v.removeEventListener("pointermove",L),v.removeEventListener("pointerdown",O),v.removeEventListener("pointerleave",F),o.destroy()},swirl(){let e=o.width,r=o.height,t=0,s=setInterval(()=>{t+=.05,f(e*(.15+.7*t),r*(.5+.25*Math.sin(t*12)),6,60),t>=1&&clearInterval(s)},16)},burst(e,r){f(e!=null?e:o.width/2,r!=null?r:o.height/2,60,200)},setPalette(e){e&&(n.palette=e)},update(e){Object.assign(n,e)},getState:()=>({sparks:d.length,palette:n.palette})}}var C={createFairyDust:D};window.FluriFairyDust=C;var P=document.currentScript;if(P&&P.hasAttribute("data-auto")){let i=()=>{let n={};try{n=JSON.parse(P.getAttribute("data-options")||"{}")}catch{}C.instance=D(n)};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",i,{once:!0}):i()}})();
@@ -0,0 +1 @@
1
+ export * from "./fairy-dust.js";
package/dist/index.js ADDED
@@ -0,0 +1,251 @@
1
+ /*! @fluritheme/fairy-dust v1.0.0 | MIT | https://fluri.xyz/fairy-dust/ */
2
+
3
+ // packages/fairy-dust/src/overlay.ts
4
+ function createOverlay(o = {}) {
5
+ const canvas = document.createElement("canvas");
6
+ canvas.setAttribute("aria-hidden", "true");
7
+ canvas.dataset.fluri = "overlay";
8
+ Object.assign(canvas.style, {
9
+ position: o.root ? "absolute" : "fixed",
10
+ inset: "0",
11
+ width: "100%",
12
+ height: "100%",
13
+ pointerEvents: "none",
14
+ zIndex: String(o.zIndex ?? 2147483e3),
15
+ contain: "strict"
16
+ });
17
+ const host = o.root ?? document.body;
18
+ if (o.root && getComputedStyle(o.root).position === "static")
19
+ o.root.style.position = "relative";
20
+ host.append(canvas);
21
+ const ctx = canvas.getContext("2d");
22
+ const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
23
+ let raf = 0, last = 0, paused = false, destroyed = false, frame = null;
24
+ const minStep = 1e3 / (o.maxFPS ?? 60) - 1;
25
+ const overlay = {
26
+ canvas,
27
+ ctx,
28
+ width: 0,
29
+ height: 0,
30
+ reduced,
31
+ origin() {
32
+ if (!o.root) return { x: 0, y: 0 };
33
+ const r = o.root.getBoundingClientRect();
34
+ return { x: r.left, y: r.top };
35
+ },
36
+ start(f) {
37
+ frame = f;
38
+ loop(performance.now());
39
+ },
40
+ pause() {
41
+ paused = true;
42
+ cancelAnimationFrame(raf);
43
+ },
44
+ resume() {
45
+ if (destroyed || !paused) return;
46
+ paused = false;
47
+ last = performance.now();
48
+ loop(last);
49
+ },
50
+ destroy() {
51
+ destroyed = true;
52
+ cancelAnimationFrame(raf);
53
+ ro.disconnect();
54
+ removeEventListener("resize", size);
55
+ document.removeEventListener("visibilitychange", vis);
56
+ canvas.remove();
57
+ }
58
+ };
59
+ function size() {
60
+ const dpr = Math.min(2, devicePixelRatio || 1);
61
+ const w = o.root ? o.root.clientWidth : innerWidth;
62
+ const h = o.root ? o.root.clientHeight : innerHeight;
63
+ overlay.width = w;
64
+ overlay.height = h;
65
+ canvas.width = Math.round(w * dpr);
66
+ canvas.height = Math.round(h * dpr);
67
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
68
+ }
69
+ function loop(t) {
70
+ if (paused || destroyed) return;
71
+ raf = requestAnimationFrame(loop);
72
+ if (t - last < minStep) return;
73
+ const dt = Math.min(0.05, (t - (last || t)) / 1e3);
74
+ last = t;
75
+ frame?.(dt, t / 1e3);
76
+ }
77
+ function vis() {
78
+ if (document.hidden) cancelAnimationFrame(raf);
79
+ else if (!paused && !destroyed) {
80
+ last = performance.now();
81
+ loop(last);
82
+ }
83
+ }
84
+ const ro = new ResizeObserver(size);
85
+ ro.observe(o.root ?? document.documentElement);
86
+ addEventListener("resize", size);
87
+ document.addEventListener("visibilitychange", vis);
88
+ size();
89
+ return overlay;
90
+ }
91
+ var rand = (a, b) => a + Math.random() * (b - a);
92
+
93
+ // packages/fairy-dust/src/fairy-dust.ts
94
+ var palettes = {
95
+ gold: ["#fff3b0", "#ffd166", "#ffe8a3", "#f6bd60"],
96
+ silver: ["#ffffff", "#e0e6ef", "#c7d2e0", "#f8f9ff"],
97
+ rose: ["#ffc8dd", "#ffafcc", "#ffe5ec", "#f9a8d4"],
98
+ aurora: ["#a7f3d0", "#93c5fd", "#c4b5fd", "#f0abfc"]
99
+ };
100
+ function createFairyDust(options = {}) {
101
+ const o = {
102
+ palette: "gold",
103
+ density: 1,
104
+ size: 1,
105
+ trail: 1.1,
106
+ clickBurst: true,
107
+ glow: true,
108
+ ...options
109
+ };
110
+ const overlay = createOverlay({ root: o.root, zIndex: o.zIndex });
111
+ const { ctx } = overlay;
112
+ const sparks = [];
113
+ let px = -1, py = -1, lastX = -1, lastY = -1, hue = 0, idle = 0;
114
+ const color = () => {
115
+ if (o.palette === "rainbow") {
116
+ hue = (hue + 7) % 360;
117
+ return `hsl(${hue} 95% 72%)`;
118
+ }
119
+ const c = palettes[o.palette] ?? palettes.gold;
120
+ return c[Math.floor(Math.random() * c.length)];
121
+ };
122
+ function emit(x, y, n, speed = 40, life = o.trail) {
123
+ for (let i = 0; i < n; i++) {
124
+ const a = rand(0, Math.PI * 2), v = rand(speed * 0.2, speed);
125
+ sparks.push({
126
+ x: x + rand(-3, 3),
127
+ y: y + rand(-3, 3),
128
+ vx: Math.cos(a) * v,
129
+ vy: Math.sin(a) * v - 10,
130
+ life: rand(life * 0.6, life),
131
+ max: life,
132
+ size: rand(3, 7) * o.size,
133
+ color: color(),
134
+ spin: rand(0, Math.PI),
135
+ kind: Math.random() < 0.55 ? 0 : 1
136
+ });
137
+ }
138
+ if (sparks.length > 700) sparks.splice(0, sparks.length - 700);
139
+ }
140
+ function star(x, y, r, rot) {
141
+ ctx.beginPath();
142
+ for (let i = 0; i < 8; i++) {
143
+ const rr = i % 2 ? r * 0.28 : r, a = rot + i * Math.PI / 4;
144
+ ctx.lineTo(x + Math.cos(a) * rr, y + Math.sin(a) * rr);
145
+ }
146
+ ctx.closePath();
147
+ ctx.fill();
148
+ }
149
+ overlay.start((dt) => {
150
+ ctx.clearRect(0, 0, overlay.width, overlay.height);
151
+ idle += dt;
152
+ if (px >= 0 && idle > 0.35 && Math.random() < dt * 3 * o.density && !overlay.reduced)
153
+ emit(px + rand(-14, 14), py + rand(-14, 14), 1, 10, o.trail * 0.8);
154
+ ctx.globalCompositeOperation = o.glow ? "lighter" : "source-over";
155
+ for (let i = sparks.length - 1; i >= 0; i--) {
156
+ const s = sparks[i];
157
+ s.life -= dt;
158
+ if (s.life <= 0) {
159
+ sparks.splice(i, 1);
160
+ continue;
161
+ }
162
+ s.vy += 26 * dt;
163
+ s.vx *= 1 - Math.min(1, dt * 2);
164
+ s.x += s.vx * dt;
165
+ s.y += s.vy * dt;
166
+ s.spin += dt * 2;
167
+ const k = s.life / s.max, r = s.size * (0.4 + 0.6 * k) * (0.85 + 0.15 * Math.sin(s.spin * 6));
168
+ ctx.globalAlpha = Math.min(1, k * 1.4);
169
+ ctx.fillStyle = s.color;
170
+ if (o.glow) {
171
+ ctx.shadowColor = s.color;
172
+ ctx.shadowBlur = r * 3;
173
+ }
174
+ if (s.kind === 0) star(s.x, s.y, r * 1.6, s.spin);
175
+ else {
176
+ ctx.beginPath();
177
+ ctx.arc(s.x, s.y, r * 0.45, 0, Math.PI * 2);
178
+ ctx.fill();
179
+ }
180
+ }
181
+ ctx.shadowBlur = 0;
182
+ ctx.globalAlpha = 1;
183
+ ctx.globalCompositeOperation = "source-over";
184
+ });
185
+ const scope = o.root ?? window;
186
+ const inside = (x, y) => !o.root || x >= 0 && y >= 0 && x <= overlay.width && y <= overlay.height;
187
+ const move = (e) => {
188
+ const og = overlay.origin();
189
+ const x = e.clientX - og.x, y = e.clientY - og.y;
190
+ if (!inside(x, y)) return;
191
+ px = x;
192
+ py = y;
193
+ idle = 0;
194
+ if (overlay.reduced) return;
195
+ if (lastX >= 0) {
196
+ const d = Math.hypot(x - lastX, y - lastY);
197
+ const n = Math.min(10, Math.round(d / 7 * o.density));
198
+ for (let i = 0; i < n; i++) {
199
+ const t = (i + 1) / n;
200
+ emit(lastX + (x - lastX) * t, lastY + (y - lastY) * t, 1, 24);
201
+ }
202
+ }
203
+ lastX = x;
204
+ lastY = y;
205
+ };
206
+ const leave = () => {
207
+ lastX = lastY = px = py = -1;
208
+ };
209
+ const down = (e) => {
210
+ if (!o.clickBurst) return;
211
+ const og = overlay.origin();
212
+ const x = e.clientX - og.x, y = e.clientY - og.y;
213
+ if (inside(x, y)) emit(x, y, overlay.reduced ? 6 : Math.round(26 * o.density), 150, o.trail * 0.9);
214
+ };
215
+ scope.addEventListener("pointermove", move, { passive: true });
216
+ scope.addEventListener("pointerdown", down, { passive: true });
217
+ scope.addEventListener("pointerleave", leave, { passive: true });
218
+ return {
219
+ pause: () => overlay.pause(),
220
+ resume: () => overlay.resume(),
221
+ destroy() {
222
+ scope.removeEventListener("pointermove", move);
223
+ scope.removeEventListener("pointerdown", down);
224
+ scope.removeEventListener("pointerleave", leave);
225
+ overlay.destroy();
226
+ },
227
+ /** A sweeping swirl of dust across the area. */
228
+ swirl() {
229
+ const w = overlay.width, h = overlay.height;
230
+ let t = 0;
231
+ const id = setInterval(() => {
232
+ t += 0.05;
233
+ emit(w * (0.15 + 0.7 * t), h * (0.5 + 0.25 * Math.sin(t * 12)), 6, 60);
234
+ if (t >= 1) clearInterval(id);
235
+ }, 16);
236
+ },
237
+ burst(x, y) {
238
+ emit(x ?? overlay.width / 2, y ?? overlay.height / 2, 60, 200);
239
+ },
240
+ setPalette(p) {
241
+ if (p) o.palette = p;
242
+ },
243
+ update(next) {
244
+ Object.assign(o, next);
245
+ },
246
+ getState: () => ({ sparks: sparks.length, palette: o.palette })
247
+ };
248
+ }
249
+ export {
250
+ createFairyDust
251
+ };
@@ -0,0 +1,26 @@
1
+ export interface OverlayOptions {
2
+ root?: HTMLElement | undefined;
3
+ zIndex?: number | undefined;
4
+ maxFPS?: number | undefined;
5
+ }
6
+ export interface Overlay {
7
+ canvas: HTMLCanvasElement;
8
+ ctx: CanvasRenderingContext2D;
9
+ /** CSS pixel size of the drawing area. */
10
+ width: number;
11
+ height: number;
12
+ /** Area origin in viewport coordinates (for converting client points). */
13
+ origin(): {
14
+ x: number;
15
+ y: number;
16
+ };
17
+ start(frame: (dt: number, t: number) => void): void;
18
+ pause(): void;
19
+ resume(): void;
20
+ destroy(): void;
21
+ reduced: boolean;
22
+ }
23
+ export declare function createOverlay(o?: OverlayOptions): Overlay;
24
+ export declare function surfacesIn(selector: string, root?: HTMLElement, limit?: number): HTMLElement[];
25
+ export declare const rand: (a: number, b: number) => number;
26
+ export declare const clamp: (v: number, a: number, b: number) => number;
Binary file
package/package.json CHANGED
@@ -1,6 +1,51 @@
1
1
  {
2
2
  "name": "@fluritheme/fairy-dust",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "1.0.0",
4
+ "description": "Magic fairy dust cursor trail for any website: glittering stars follow the pointer, twinkle as they fall and burst on click. Gold, rainbow, rose, silver and aurora. Zero dependencies, ~5 KB.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": {
8
+ "name": "František Gejdoš",
9
+ "url": "https://fluri.xyz/founder/",
10
+ "email": "fluritheme@gmail.com"
11
+ },
12
+ "homepage": "https://fluri.xyz/fairy-dust/",
13
+ "keywords": [
14
+ "cursor",
15
+ "cursor-trail",
16
+ "cursor-effect",
17
+ "sparkle",
18
+ "glitter",
19
+ "magic",
20
+ "fairy",
21
+ "stars",
22
+ "mouse-trail",
23
+ "animation",
24
+ "canvas",
25
+ "fluri"
26
+ ],
27
+ "sideEffects": false,
28
+ "files": [
29
+ "dist",
30
+ "media",
31
+ "README.md",
32
+ "LICENSE",
33
+ "CHANGELOG.md"
34
+ ],
35
+ "exports": {
36
+ ".": {
37
+ "types": "./dist/index.d.ts",
38
+ "import": "./dist/index.js"
39
+ },
40
+ "./global": "./dist/fairy-dust.global.js",
41
+ "./package.json": "./package.json"
42
+ },
43
+ "main": "./dist/index.js",
44
+ "module": "./dist/index.js",
45
+ "types": "./dist/index.d.ts",
46
+ "unpkg": "./dist/fairy-dust.global.js",
47
+ "jsdelivr": "./dist/fairy-dust.global.js",
48
+ "publishConfig": {
49
+ "access": "public"
50
+ }
51
+ }