dynaura 0.0.0-stage → 0.1.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.
@@ -0,0 +1,86 @@
1
+ type Position = "top" | "top-left" | "top-center" | "top-right" | "bottom" | "bottom-left" | "bottom-center" | "bottom-right";
2
+ /** Any CSS color. Omitted keys fall back to the dark theme. */
3
+ interface CustomTheme {
4
+ background?: string;
5
+ foreground?: string;
6
+ muted?: string;
7
+ ring?: string;
8
+ button?: string;
9
+ success?: string;
10
+ error?: string;
11
+ warning?: string;
12
+ info?: string;
13
+ loading?: string;
14
+ live?: string;
15
+ }
16
+ interface ToasterOptions {
17
+ position?: Position;
18
+ /** px from the screen edge */
19
+ offset?: number;
20
+ /** "dark" | "light" | "system" (follows OS) | custom colors */
21
+ theme?: "dark" | "light" | "system" | CustomTheme;
22
+ /** thin time-remaining bar on timed toasts (default true) */
23
+ timer?: boolean;
24
+ /** navigator.vibrate on show (default true; no-op where unsupported) */
25
+ haptics?: boolean;
26
+ /** show toasts one after another instead of replacing (default false) */
27
+ queue?: boolean;
28
+ /** framework hook: mount non-string/non-Node content (e.g. a React element) into `el`; node=null unmounts */
29
+ render?: (el: HTMLElement, node: unknown) => void;
30
+ }
31
+ interface ToasterHandle {
32
+ set(o: ToasterOptions): void;
33
+ destroy(): void;
34
+ }
35
+ declare function createToaster(initial?: ToasterOptions): ToasterHandle;
36
+
37
+ type ToastType = "success" | "error" | "warning" | "info" | "loading" | "live";
38
+ /** string | number | DOM Node | framework node (React element when used with the React adapter) */
39
+ type Content = string | number | boolean | Node | object | null;
40
+ interface ToastOptions {
41
+ title: string;
42
+ description?: Content;
43
+ /** replaces the built-in icon (leading slot) */
44
+ icon?: Content;
45
+ /** compact right-side slot, e.g. a countdown */
46
+ trailing?: Content;
47
+ /** ms; null = sticky. Default 4000 (loading / live: null). */
48
+ duration?: number | null;
49
+ button?: {
50
+ title: string;
51
+ onClick: () => void;
52
+ };
53
+ /** 0..1. Shows a progress bar + rolling percent. Clear with update(id, { progress: undefined }). */
54
+ progress?: number;
55
+ /** burst of confetti when shown */
56
+ confetti?: boolean;
57
+ /** live activity flavor (type "live"): running timer or waveform */
58
+ kind?: "timer" | "wave";
59
+ /** "card": rich layout. Header tab + wider body joined by a curved notch; description is full-bleed custom content. */
60
+ variant?: "default" | "card";
61
+ /** per-toast override of the Toaster `queue` option */
62
+ queue?: boolean;
63
+ }
64
+ type Resolve<T> = ToastOptions | string | ((v: T) => ToastOptions | string);
65
+ declare const dynaura: {
66
+ success: (o: ToastOptions | string) => string;
67
+ error: (o: ToastOptions | string) => string;
68
+ warning: (o: ToastOptions | string) => string;
69
+ info: (o: ToastOptions | string) => string;
70
+ loading: (o: ToastOptions | string) => string;
71
+ /** Live activity: sticky island with a running timer (default) or waveform. */
72
+ live: (o: ToastOptions | string) => string;
73
+ update: (id: string, patch: Partial<ToastOptions> & {
74
+ type?: ToastType;
75
+ }) => void;
76
+ /** dismiss the current toast (next queued one shows) or a specific id */
77
+ dismiss: (id?: string) => void;
78
+ clear: () => void;
79
+ promise<T>(p: Promise<T>, o: {
80
+ loading: ToastOptions | string;
81
+ success: Resolve<T>;
82
+ error: Resolve<unknown>;
83
+ }): Promise<T>;
84
+ };
85
+
86
+ export { type Content, type CustomTheme, type Position, type ToastOptions, type ToastType, type ToasterHandle, type ToasterOptions, createToaster, dynaura };
@@ -0,0 +1,9 @@
1
+ "use client";
2
+ import {
3
+ createToaster,
4
+ dynaura
5
+ } from "./chunk-FNLIY6GQ.js";
6
+ export {
7
+ createToaster,
8
+ dynaura
9
+ };
package/dist/vue.cjs ADDED
@@ -0,0 +1,608 @@
1
+ "use client";
2
+ "use strict";
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __export = (target, all) => {
8
+ for (var name in all)
9
+ __defProp(target, name, { get: all[name], enumerable: true });
10
+ };
11
+ var __copyProps = (to, from, except, desc) => {
12
+ if (from && typeof from === "object" || typeof from === "function") {
13
+ for (let key of __getOwnPropNames(from))
14
+ if (!__hasOwnProp.call(to, key) && key !== except)
15
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
16
+ }
17
+ return to;
18
+ };
19
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
+
21
+ // src/vue.ts
22
+ var vue_exports = {};
23
+ __export(vue_exports, {
24
+ Toaster: () => Toaster,
25
+ dynaura: () => dynaura
26
+ });
27
+ module.exports = __toCommonJS(vue_exports);
28
+ var import_vue = require("vue");
29
+
30
+ // src/confetti.ts
31
+ function burst(x, y, color) {
32
+ const c = document.createElement("canvas");
33
+ const dpr = window.devicePixelRatio || 1;
34
+ const W = innerWidth, H = innerHeight;
35
+ c.width = W * dpr;
36
+ c.height = H * dpr;
37
+ c.style.cssText = `position:fixed;top:0;left:0;width:${W}px;height:${H}px;pointer-events:none;z-index:2147483647`;
38
+ document.body.append(c);
39
+ const ctx = c.getContext("2d");
40
+ if (!ctx) return c.remove();
41
+ ctx.scale(dpr, dpr);
42
+ const colors = [color, "#fff", color, "#ffd60a", "#0a84ff"];
43
+ const ps = Array.from({ length: 36 }, () => {
44
+ const a = Math.random() * Math.PI * 2, s = 3 + Math.random() * 6;
45
+ return { x, y, vx: Math.cos(a) * s, vy: Math.sin(a) * s - 3, r: 2 + Math.random() * 3, rot: Math.random() * 6, c: colors[Math.random() * colors.length | 0] };
46
+ });
47
+ const t0 = performance.now();
48
+ const frame = (t) => {
49
+ const k = (t - t0) / 1e3;
50
+ if (k >= 1) return c.remove();
51
+ ctx.clearRect(0, 0, W, H);
52
+ for (const p of ps) {
53
+ p.x += p.vx;
54
+ p.y += p.vy;
55
+ p.vy += 0.28;
56
+ p.vx *= 0.985;
57
+ p.rot += 0.2;
58
+ ctx.globalAlpha = 1 - k * k;
59
+ ctx.fillStyle = p.c;
60
+ ctx.save();
61
+ ctx.translate(p.x, p.y);
62
+ ctx.rotate(p.rot);
63
+ ctx.fillRect(-p.r, -p.r / 2, p.r * 2, p.r);
64
+ ctx.restore();
65
+ }
66
+ requestAnimationFrame(frame);
67
+ };
68
+ requestAnimationFrame(frame);
69
+ }
70
+
71
+ // src/store.ts
72
+ var g = globalThis;
73
+ var _a;
74
+ var S = (_a = g.__dynaura) != null ? _a : g.__dynaura = { current: null, queue: [], n: 0, subs: /* @__PURE__ */ new Set(), useQueue: false };
75
+ var set = (t) => {
76
+ S.current = t;
77
+ S.subs.forEach((f) => f());
78
+ };
79
+ var subscribe = (f) => {
80
+ S.subs.add(f);
81
+ return () => {
82
+ S.subs.delete(f);
83
+ };
84
+ };
85
+ var getCurrent = () => S.current;
86
+ var setQueue = (v) => {
87
+ S.useQueue = v;
88
+ };
89
+ var norm = (o) => typeof o === "string" ? { title: o } : o;
90
+ var make = (type) => (o) => {
91
+ var _a2;
92
+ const id = String(++S.n);
93
+ const sticky = type === "loading" || type === "live";
94
+ const t = { duration: sticky ? null : 4e3, ...type === "live" ? { kind: "timer" } : {}, ...norm(o), id, type };
95
+ if (S.current && ((_a2 = t.queue) != null ? _a2 : S.useQueue)) S.queue.push(t);
96
+ else set(t);
97
+ return id;
98
+ };
99
+ var update = (id, patch) => {
100
+ var _a2;
101
+ if (((_a2 = S.current) == null ? void 0 : _a2.id) === id) return set({ ...S.current, ...patch });
102
+ const i = S.queue.findIndex((t) => t.id === id);
103
+ if (i >= 0) S.queue[i] = { ...S.queue[i], ...patch };
104
+ };
105
+ var pick = (r, v) => norm(typeof r === "function" ? r(v) : r);
106
+ var dynaura = {
107
+ success: make("success"),
108
+ error: make("error"),
109
+ warning: make("warning"),
110
+ info: make("info"),
111
+ loading: make("loading"),
112
+ /** Live activity: sticky island with a running timer (default) or waveform. */
113
+ live: make("live"),
114
+ update,
115
+ /** dismiss the current toast (next queued one shows) or a specific id */
116
+ dismiss: (id) => {
117
+ var _a2, _b;
118
+ if (id && ((_a2 = S.current) == null ? void 0 : _a2.id) !== id) {
119
+ S.queue = S.queue.filter((t) => t.id !== id);
120
+ return;
121
+ }
122
+ set((_b = S.queue.shift()) != null ? _b : null);
123
+ },
124
+ clear: () => {
125
+ S.queue = [];
126
+ set(null);
127
+ },
128
+ promise(p, o) {
129
+ const id = make("loading")(o.loading);
130
+ p.then(
131
+ (v) => update(id, { duration: 4e3, ...pick(o.success, v), type: "success" }),
132
+ (e) => update(id, { duration: 4e3, ...pick(o.error, e), type: "error" })
133
+ );
134
+ return p;
135
+ }
136
+ };
137
+
138
+ // src/core.ts
139
+ var VAR = {
140
+ background: "bg",
141
+ foreground: "fg",
142
+ muted: "muted",
143
+ ring: "ring",
144
+ button: "btn",
145
+ success: "success",
146
+ error: "error",
147
+ warning: "warning",
148
+ info: "info",
149
+ loading: "loading",
150
+ live: "live"
151
+ };
152
+ var svg = (d) => `<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">${d}</svg>`;
153
+ var ICON = {
154
+ success: svg('<path class="dynaura-draw" d="M5 12.5l4.5 4.5L19 7.5"/>'),
155
+ error: svg('<path class="dynaura-draw" d="M7 7l10 10M17 7L7 17"/>'),
156
+ warning: svg('<path class="dynaura-draw" d="M12 6v7M12 17.5v.01"/>'),
157
+ info: svg('<path class="dynaura-draw" d="M12 11v6M12 7.5v.01"/>'),
158
+ loading: svg('<circle class="dynaura-spin" cx="12" cy="12" r="8" stroke-dasharray="30 50"/>')
159
+ };
160
+ var DOT = '<span class="dynaura-dot"></span>';
161
+ var WAVE = '<span class="dynaura-wave"><i></i><i></i><i></i><i></i></span>';
162
+ var VIBRATE = { success: [12], error: [24, 40, 24], warning: [30], info: [8], loading: [], live: [8] };
163
+ var f2 = (n) => +n.toFixed(2);
164
+ function outline(w, h2, cw, ch, hx) {
165
+ if (h2 <= ch + 1 || w <= cw + 1) {
166
+ const q = f2(Math.min(h2 / 2, w / 2, 32));
167
+ return `M${q} 0H${f2(w - q)}A${q} ${q} 0 0 1 ${f2(w)} ${q}V${f2(h2 - q)}A${q} ${q} 0 0 1 ${f2(w - q)} ${f2(h2)}H${q}A${q} ${q} 0 0 1 0 ${f2(h2 - q)}V${q}A${q} ${q} 0 0 1 ${q} 0Z`;
168
+ }
169
+ const r = f2(Math.min(ch / 2, 32));
170
+ const b = f2(Math.max(0, Math.min(28, (h2 - ch) / 2, (w - cw) / 2)));
171
+ const f = f2(Math.min(16, b));
172
+ const x0 = f2(hx), x1 = f2(hx + cw);
173
+ const flushL = hx < 1, flushR = hx + cw > w - 1;
174
+ let d = `M${f2(x0 + r)} 0H${f2(x1 - r)}A${r} ${r} 0 0 1 ${x1} ${r}`;
175
+ d += flushR ? `V${f2(h2 - b)}` : `V${f2(ch - f)}A${f} ${f} 0 0 0 ${f2(x1 + f)} ${f2(ch)}H${f2(w - b)}A${b} ${b} 0 0 1 ${f2(w)} ${f2(ch + b)}V${f2(h2 - b)}`;
176
+ d += `A${b} ${b} 0 0 1 ${f2(w - b)} ${f2(h2)}H${b}A${b} ${b} 0 0 1 0 ${f2(h2 - b)}`;
177
+ d += flushL ? `V${r}` : `V${f2(ch + b)}A${b} ${b} 0 0 1 ${b} ${f2(ch)}H${f2(x0 - f)}A${f} ${f} 0 0 0 ${x0} ${f2(ch - f)}V${r}`;
178
+ return d + `A${r} ${r} 0 0 1 ${f2(x0 + r)} 0Z`;
179
+ }
180
+ var h = (tag, cls, parent) => {
181
+ const e = document.createElement(tag);
182
+ e.className = cls;
183
+ parent == null ? void 0 : parent.append(e);
184
+ return e;
185
+ };
186
+ var restart = (e) => {
187
+ e.style.animation = "none";
188
+ void e.offsetWidth;
189
+ e.style.animation = "";
190
+ };
191
+ function roll(e, s) {
192
+ const sig = s.replace(/\d/g, "0");
193
+ if (e.dataset.sig !== sig) {
194
+ e.dataset.sig = sig;
195
+ e.replaceChildren();
196
+ e.setAttribute("role", "img");
197
+ for (const ch of s) {
198
+ if (/\d/.test(ch)) {
199
+ const d = h("span", "dynaura-digit", e);
200
+ d.setAttribute("aria-hidden", "true");
201
+ h("span", "dynaura-strip", d).innerHTML = "0123456789".replace(/\d/g, "<i>$&</i>");
202
+ } else h("span", "dynaura-char", e).textContent = ch;
203
+ }
204
+ }
205
+ e.setAttribute("aria-label", s);
206
+ [...s].forEach((ch, i) => {
207
+ if (/\d/.test(ch)) e.children[i].style.setProperty("--d", ch);
208
+ });
209
+ }
210
+ function createToaster(initial = {}) {
211
+ const o = { position: "top", offset: 12, theme: "dark", timer: true, haptics: true, queue: false };
212
+ const merge = (n) => {
213
+ for (const k in n) if (n[k] !== void 0) o[k] = n[k];
214
+ };
215
+ merge(initial);
216
+ const root = h("div", "dynaura-root");
217
+ const drag = h("div", "dynaura-drag", root);
218
+ const island = h("div", "dynaura-island", drag);
219
+ island.setAttribute("role", "status");
220
+ island.setAttribute("aria-live", "polite");
221
+ const inner = h("div", "dynaura-inner", island);
222
+ const row = h("div", "dynaura-row", inner);
223
+ const badge = h("span", "dynaura-badge", row);
224
+ const title = h("span", "dynaura-title", row);
225
+ const trail = h("span", "dynaura-trailing", row);
226
+ const body = h("div", "dynaura-body", inner);
227
+ const desc = h("div", "dynaura-desc", body);
228
+ const btn = h("button", "dynaura-button", body);
229
+ const bar = h("div", "dynaura-bar", island);
230
+ island.hidden = true;
231
+ island.dataset.expanded = "false";
232
+ island.dataset.paused = "false";
233
+ document.body.append(root);
234
+ let t = null;
235
+ let expanded = false, hovered = false, pinned = false, dragging = false, ready = false;
236
+ let hideT, expandT, collapseT, dismissT, liveI, lp;
237
+ let remaining = 0, startedAt = 0, liveStart = 0;
238
+ let sz = { cw: 0, ch: 0, ew: 0, eh: 0 };
239
+ let applied = [];
240
+ const hosts = /* @__PURE__ */ new Map();
241
+ const dir = () => o.position.startsWith("bottom") ? 1 : -1;
242
+ const hasBody = () => !!t && (t.description != null && typeof t.description !== "boolean" || !!t.button);
243
+ const paused = () => hovered || pinned || dragging;
244
+ function put(slot, c) {
245
+ var _a2;
246
+ const old = hosts.get(slot);
247
+ if (old) {
248
+ (_a2 = o.render) == null ? void 0 : _a2.call(o, old, null);
249
+ hosts.delete(slot);
250
+ }
251
+ slot.replaceChildren();
252
+ if (c == null || typeof c === "boolean") return;
253
+ if (typeof c === "string" || typeof c === "number") slot.textContent = String(c);
254
+ else if (c instanceof Node) slot.append(c);
255
+ else if (o.render) {
256
+ const host = h("span", "dynaura-host", slot);
257
+ hosts.set(slot, host);
258
+ o.render(host, c);
259
+ }
260
+ }
261
+ let raf = 0;
262
+ const isCard = () => (t == null ? void 0 : t.variant) === "card";
263
+ function shape() {
264
+ if (!isCard()) {
265
+ island.style.clipPath = "";
266
+ row.style.transform = "";
267
+ return;
268
+ }
269
+ const cs = getComputedStyle(island);
270
+ const w = parseFloat(cs.width), hh = parseFloat(cs.height);
271
+ if (!isFinite(w) || !isFinite(hh) || w <= 0) return;
272
+ const x = o.position.split("-")[1];
273
+ const hx = x === "left" ? 0 : x === "right" ? Math.max(0, w - sz.cw) : Math.max(0, (w - sz.cw) / 2);
274
+ row.style.transform = `translateX(${f2(hx)}px)`;
275
+ island.style.clipPath = `path('${outline(w, hh, sz.cw, sz.ch, hx)}')`;
276
+ }
277
+ function shapeLoop() {
278
+ cancelAnimationFrame(raf);
279
+ const end = performance.now() + 1300;
280
+ const f = () => {
281
+ shape();
282
+ if (performance.now() < end) raf = requestAnimationFrame(f);
283
+ };
284
+ f();
285
+ }
286
+ function size() {
287
+ if (!sz.cw) return;
288
+ const w = expanded ? sz.ew : sz.cw, hh = expanded ? sz.eh : sz.ch;
289
+ island.style.width = w + "px";
290
+ island.style.height = hh + "px";
291
+ island.style.borderRadius = isCard() ? "0" : Math.min(hh / 2, 32) + "px";
292
+ if (isCard()) shapeLoop();
293
+ else island.style.clipPath = "";
294
+ }
295
+ function measure() {
296
+ if (island.hidden) return;
297
+ sz = { cw: row.offsetWidth, ch: row.offsetHeight, ew: inner.offsetWidth, eh: inner.offsetHeight };
298
+ size();
299
+ if (!ready && sz.cw) requestAnimationFrame(() => {
300
+ ready = true;
301
+ island.dataset.ready = "true";
302
+ });
303
+ }
304
+ const ro = new ResizeObserver(measure);
305
+ ro.observe(row);
306
+ ro.observe(inner);
307
+ function setExpanded(v) {
308
+ v = v && hasBody();
309
+ if (v === expanded) return;
310
+ expanded = v;
311
+ island.dataset.expanded = String(v);
312
+ size();
313
+ }
314
+ function clear() {
315
+ if (startedAt) {
316
+ remaining -= Date.now() - startedAt;
317
+ startedAt = 0;
318
+ }
319
+ clearTimeout(collapseT);
320
+ clearTimeout(dismissT);
321
+ }
322
+ function arm() {
323
+ clear();
324
+ if (!t || t.duration == null || paused()) return;
325
+ const id = t.id;
326
+ startedAt = Date.now();
327
+ collapseT = setTimeout(() => {
328
+ if (!pinned) setExpanded(false);
329
+ }, Math.max(0, remaining - 500));
330
+ dismissT = setTimeout(() => dynaura.dismiss(id), remaining);
331
+ }
332
+ function sync() {
333
+ island.dataset.paused = String(paused());
334
+ if (paused()) {
335
+ clear();
336
+ if (hovered || pinned) setExpanded(true);
337
+ } else arm();
338
+ }
339
+ function tick() {
340
+ var _a2;
341
+ if (!t || t.trailing != null) return;
342
+ if (t.progress != null) roll(trail, Math.round(t.progress * 100) + "%");
343
+ else if (t.type === "live" && ((_a2 = t.kind) != null ? _a2 : "timer") === "timer") {
344
+ const s = Math.floor((Date.now() - liveStart) / 1e3);
345
+ roll(trail, `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`);
346
+ }
347
+ }
348
+ const hasTrail = (n) => {
349
+ var _a2;
350
+ return n.trailing != null || n.progress != null || n.type === "live" && ((_a2 = n.kind) != null ? _a2 : "timer") === "timer";
351
+ };
352
+ function apply(n, p) {
353
+ var _a2, _b, _c;
354
+ const ch = (k) => !p || n[k] !== p[k];
355
+ island.dataset.type = n.type;
356
+ island.dataset.variant = drag.dataset.variant = (_a2 = n.variant) != null ? _a2 : "default";
357
+ if (ch("type") || ch("icon") || ch("kind")) {
358
+ put(badge, void 0);
359
+ if (n.icon != null) put(badge, n.icon);
360
+ else badge.innerHTML = n.type === "live" ? ((_b = n.kind) != null ? _b : "timer") === "wave" ? WAVE : DOT : ICON[n.type];
361
+ restart(badge);
362
+ }
363
+ if (ch("title")) {
364
+ title.textContent = n.title;
365
+ restart(title);
366
+ }
367
+ if (ch("trailing") || ch("progress") || ch("type") || ch("kind")) {
368
+ trail.hidden = !hasTrail(n);
369
+ if (n.trailing != null) {
370
+ delete trail.dataset.sig;
371
+ trail.removeAttribute("aria-label");
372
+ put(trail, n.trailing);
373
+ } else if (!hasTrail(n)) {
374
+ delete trail.dataset.sig;
375
+ put(trail, void 0);
376
+ }
377
+ }
378
+ if (ch("description")) put(desc, n.description);
379
+ desc.hidden = n.description == null || typeof n.description === "boolean";
380
+ btn.hidden = !n.button;
381
+ if (n.button) btn.textContent = n.button.title;
382
+ body.hidden = !(n.description != null && typeof n.description !== "boolean") && !n.button;
383
+ bar.dataset.mode = n.progress != null ? "value" : n.duration != null ? "time" : "none";
384
+ bar.style.setProperty("--p", String((_c = n.progress) != null ? _c : 0));
385
+ }
386
+ function feedback(n) {
387
+ var _a2, _b;
388
+ const active = (_b = (_a2 = navigator.userActivation) == null ? void 0 : _a2.hasBeenActive) != null ? _b : true;
389
+ if (o.haptics && typeof navigator !== "undefined" && navigator.vibrate && active && VIBRATE[n.type].length) navigator.vibrate(VIBRATE[n.type]);
390
+ if (n.confetti && !matchMedia("(prefers-reduced-motion: reduce)").matches) {
391
+ requestAnimationFrame(() => {
392
+ const r = island.getBoundingClientRect();
393
+ burst(r.left + r.width / 2, r.top + r.height / 2, getComputedStyle(island).getPropertyValue("--state").trim() || "#30d158");
394
+ });
395
+ }
396
+ }
397
+ const onlyProgress = (p, n) => p.progress == null === (n.progress == null) && [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(p)])].every((k) => k === "progress" || n[k] === p[k]);
398
+ function render() {
399
+ var _a2, _b, _c;
400
+ const n = getCurrent();
401
+ const p = t;
402
+ if (!n) {
403
+ if (p) leave();
404
+ return;
405
+ }
406
+ const same = !!p && p.id === n.id;
407
+ if (same && onlyProgress(p, n)) {
408
+ t = n;
409
+ bar.style.setProperty("--p", String((_a2 = n.progress) != null ? _a2 : 0));
410
+ tick();
411
+ return;
412
+ }
413
+ t = n;
414
+ clearTimeout(hideT);
415
+ if (island.hidden) {
416
+ island.hidden = false;
417
+ drag.style.transform = "";
418
+ drag.style.opacity = "";
419
+ restart(island);
420
+ }
421
+ island.dataset.open = "true";
422
+ if (!same) {
423
+ liveStart = Date.now();
424
+ pinned = false;
425
+ }
426
+ apply(n, same ? p : null);
427
+ measure();
428
+ if (!same || n.type !== p.type) feedback(n);
429
+ clearInterval(liveI);
430
+ if (n.type === "live") liveI = setInterval(tick, 1e3);
431
+ tick();
432
+ clear();
433
+ startedAt = 0;
434
+ remaining = (_b = n.duration) != null ? _b : 0;
435
+ restart(bar);
436
+ bar.style.animationDuration = ((_c = n.duration) != null ? _c : 0) + "ms";
437
+ if (!pinned) setExpanded(false);
438
+ clearTimeout(expandT);
439
+ if (hasBody()) expandT = setTimeout(() => setExpanded(true), 450);
440
+ sync();
441
+ }
442
+ function leave() {
443
+ clear();
444
+ startedAt = 0;
445
+ clearTimeout(expandT);
446
+ clearInterval(liveI);
447
+ hovered = pinned = dragging = false;
448
+ t = null;
449
+ island.dataset.open = "false";
450
+ hideT = setTimeout(() => {
451
+ cancelAnimationFrame(raf);
452
+ island.style.clipPath = "";
453
+ island.hidden = true;
454
+ ready = false;
455
+ expanded = false;
456
+ delete island.dataset.ready;
457
+ island.dataset.expanded = "false";
458
+ island.style.width = island.style.height = island.style.borderRadius = "";
459
+ [badge, trail, desc].forEach((s) => put(s, void 0));
460
+ delete trail.dataset.sig;
461
+ }, 450);
462
+ }
463
+ btn.onclick = () => {
464
+ const c = t;
465
+ if (c == null ? void 0 : c.button) {
466
+ c.button.onClick();
467
+ dynaura.dismiss(c.id);
468
+ }
469
+ };
470
+ let sy = 0, t0 = 0, moved = false, longed = false;
471
+ island.addEventListener("pointerenter", (e) => {
472
+ if (e.pointerType === "mouse") {
473
+ hovered = true;
474
+ sync();
475
+ }
476
+ });
477
+ island.addEventListener("pointerleave", (e) => {
478
+ if (e.pointerType !== "mouse") return;
479
+ hovered = false;
480
+ if (!pinned) setExpanded(false);
481
+ sync();
482
+ });
483
+ drag.addEventListener("pointerdown", (e) => {
484
+ var _a2;
485
+ if (!t || e.target.closest("button")) return;
486
+ dragging = true;
487
+ moved = longed = false;
488
+ sy = e.clientY;
489
+ t0 = Date.now();
490
+ (_a2 = drag.setPointerCapture) == null ? void 0 : _a2.call(drag, e.pointerId);
491
+ drag.style.transition = "none";
492
+ lp = setTimeout(() => {
493
+ var _a3;
494
+ if (!moved) {
495
+ longed = true;
496
+ pinned = true;
497
+ if (o.haptics) (_a3 = navigator.vibrate) == null ? void 0 : _a3.call(navigator, 8);
498
+ sync();
499
+ }
500
+ }, 450);
501
+ sync();
502
+ });
503
+ drag.addEventListener("pointermove", (e) => {
504
+ if (!dragging) return;
505
+ const dy = e.clientY - sy;
506
+ if (Math.abs(dy) > 6) {
507
+ moved = true;
508
+ clearTimeout(lp);
509
+ }
510
+ if (!moved) return;
511
+ const d = dy * dir();
512
+ const off = d > 0 ? d : -Math.sqrt(-d) * 4;
513
+ drag.style.transform = `translateY(${off * dir()}px)`;
514
+ });
515
+ const up = (e) => {
516
+ if (!dragging) return;
517
+ dragging = false;
518
+ clearTimeout(lp);
519
+ drag.style.transition = "";
520
+ const d = (e.clientY - sy) * dir();
521
+ const v = d / Math.max(1, Date.now() - t0);
522
+ if (e.type === "pointerup" && moved && (d > 40 || v > 0.5 && d > 10) && t) {
523
+ dynaura.dismiss(t.id);
524
+ return;
525
+ }
526
+ drag.style.transform = "";
527
+ if (e.type === "pointerup" && !moved && !longed && hasBody()) {
528
+ pinned = !pinned;
529
+ if (!pinned && !hovered) setExpanded(false);
530
+ }
531
+ sync();
532
+ };
533
+ drag.addEventListener("pointerup", up);
534
+ drag.addEventListener("pointercancel", up);
535
+ const outside = (e) => {
536
+ if (pinned && !island.contains(e.target)) {
537
+ pinned = false;
538
+ if (!hovered) setExpanded(false);
539
+ sync();
540
+ }
541
+ };
542
+ document.addEventListener("pointerdown", outside);
543
+ function set2(n) {
544
+ merge(n);
545
+ setQueue(o.queue);
546
+ const [y, x = "center"] = o.position.split("-");
547
+ root.dataset.y = y;
548
+ root.dataset.x = x;
549
+ root.dataset.timer = String(o.timer);
550
+ root.dataset.theme = typeof o.theme === "object" ? "custom" : o.theme;
551
+ root.style.setProperty("--dynaura-offset", o.offset + "px");
552
+ applied.forEach((v) => root.style.removeProperty(v));
553
+ applied = [];
554
+ if (typeof o.theme === "object")
555
+ for (const k in o.theme) {
556
+ const v = `--dynaura-${VAR[k]}`;
557
+ root.style.setProperty(v, o.theme[k]);
558
+ applied.push(v);
559
+ }
560
+ }
561
+ set2({});
562
+ const unsub = subscribe(render);
563
+ render();
564
+ return {
565
+ set: set2,
566
+ destroy() {
567
+ unsub();
568
+ ro.disconnect();
569
+ cancelAnimationFrame(raf);
570
+ document.removeEventListener("pointerdown", outside);
571
+ clear();
572
+ [hideT, expandT, liveI, lp].forEach((x) => {
573
+ clearTimeout(x);
574
+ clearInterval(x);
575
+ });
576
+ [badge, trail, desc].forEach((s) => put(s, void 0));
577
+ root.remove();
578
+ }
579
+ };
580
+ }
581
+
582
+ // src/vue.ts
583
+ var clean = (p) => Object.fromEntries(Object.entries(p).filter(([, v]) => v !== void 0));
584
+ var Toaster = (0, import_vue.defineComponent)({
585
+ name: "DynauraToaster",
586
+ props: {
587
+ position: String,
588
+ offset: Number,
589
+ theme: [String, Object],
590
+ timer: { type: Boolean, default: void 0 },
591
+ haptics: { type: Boolean, default: void 0 },
592
+ queue: { type: Boolean, default: void 0 }
593
+ },
594
+ setup(props) {
595
+ let c;
596
+ (0, import_vue.onMounted)(() => {
597
+ c = createToaster(clean({ ...props }));
598
+ });
599
+ (0, import_vue.watch)(() => ({ ...props }), (p) => c == null ? void 0 : c.set(clean(p)), { deep: true });
600
+ (0, import_vue.onBeforeUnmount)(() => c == null ? void 0 : c.destroy());
601
+ return () => null;
602
+ }
603
+ });
604
+ // Annotate the CommonJS export names for ESM import in node:
605
+ 0 && (module.exports = {
606
+ Toaster,
607
+ dynaura
608
+ });