dev-inspector 1.1.0 → 1.1.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.
Files changed (37) hide show
  1. package/package.json +3 -2
  2. package/lib/integrations/index.d.ts +0 -2
  3. package/lib/integrations/index.js +0 -7
  4. package/lib/integrations/jira/adf.d.ts +0 -11
  5. package/lib/integrations/jira/adf.js +0 -17
  6. package/lib/integrations/jira/client.d.ts +0 -4
  7. package/lib/integrations/jira/client.js +0 -113
  8. package/lib/integrations/jira/errors.d.ts +0 -10
  9. package/lib/integrations/jira/errors.js +0 -13
  10. package/lib/integrations/jira/index.d.ts +0 -2
  11. package/lib/integrations/jira/index.js +0 -8
  12. package/lib/integrations/types.d.ts +0 -54
  13. package/lib/integrations/types.js +0 -2
  14. package/lib/storage/localStorage.d.ts +0 -30
  15. package/lib/storage/localStorage.js +0 -166
  16. package/lib/ui/logList.d.ts +0 -7
  17. package/lib/ui/logList.js +0 -117
  18. package/lib/ui/panel/integrations/icons.d.ts +0 -1
  19. package/lib/ui/panel/integrations/icons.js +0 -7
  20. package/lib/ui/panel/integrations/index.d.ts +0 -1
  21. package/lib/ui/panel/integrations/index.js +0 -5
  22. package/lib/ui/panel/integrations/jiraDialog.d.ts +0 -6
  23. package/lib/ui/panel/integrations/jiraDialog.js +0 -234
  24. package/lib/ui/panel/integrations/screenshot.d.ts +0 -4
  25. package/lib/ui/panel/integrations/screenshot.js +0 -51
  26. package/lib/ui/panel/localStorage/createLocalStorageView.d.ts +0 -4
  27. package/lib/ui/panel/localStorage/createLocalStorageView.js +0 -108
  28. package/lib/ui/panel/localStorage/index.d.ts +0 -3
  29. package/lib/ui/panel/localStorage/index.js +0 -7
  30. package/lib/ui/panel/localStorage/setupLocalStorageSync.d.ts +0 -9
  31. package/lib/ui/panel/localStorage/setupLocalStorageSync.js +0 -30
  32. package/lib/ui/panel/localStorage/types.d.ts +0 -6
  33. package/lib/ui/panel/localStorage/types.js +0 -2
  34. package/lib/ui/panel.d.ts +0 -15
  35. package/lib/ui/panel.js +0 -375
  36. package/lib/ui/shared/copy.d.ts +0 -2
  37. package/lib/ui/shared/copy.js +0 -101
package/lib/ui/panel.js DELETED
@@ -1,375 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createPanel = createPanel;
4
- const logList_1 = require("./logList");
5
- const panelStyles_1 = require("./panelStyles");
6
- function getWindow() {
7
- return globalThis;
8
- }
9
- function queryOrThrow(root, selector) {
10
- const el = root.querySelector(selector);
11
- if (!el)
12
- throw new Error(`Missing required element: ${selector}`);
13
- return el;
14
- }
15
- const TOGGLE_BUTTON_HTML = `<span class="di-toggleTitle">Dev Inspector</span>` +
16
- `<span class="di-toggleMeta">` +
17
- `<span class="di-toggleBadge" data-di-toggle-count="console">` +
18
- `<svg class="di-toggleIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 5.5C4 4.67 4.67 4 5.5 4H18.5C19.33 4 20 4.67 20 5.5V15.5C20 16.33 19.33 17 18.5 17H13.5L12 18.5L10.5 17H5.5C4.67 17 4 16.33 4 15.5V5.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M7 8H17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M7 11H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>` +
19
- `<span data-di-toggle-count-value="console">0</span>` +
20
- `<span class="di-toggleErr" data-di-toggle-error="console" aria-label="Console errors">` +
21
- `<span class="di-toggleErrIcon">!</span>` +
22
- `<span data-di-toggle-error-value="console">0</span>` +
23
- `</span>` +
24
- `</span>` +
25
- `<span class="di-toggleBadge" data-di-toggle-count="network">` +
26
- `<svg class="di-toggleIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 12C4 7.58 7.58 4 12 4C16.42 4 20 7.58 20 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M6 12C6 8.69 8.69 6 12 6C15.31 6 18 8.69 18 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M8.5 12C8.5 10.07 10.07 8.5 12 8.5C13.93 8.5 15.5 10.07 15.5 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M12 12L12 20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="12" cy="20" r="1.5" fill="currentColor"/></svg>` +
27
- `<span data-di-toggle-count-value="network">0</span>` +
28
- `<span class="di-toggleErr" data-di-toggle-error="network" aria-label="Network errors">` +
29
- `<span class="di-toggleErrIcon">!</span>` +
30
- `<span data-di-toggle-error-value="network">0</span>` +
31
- `</span>` +
32
- `</span>` +
33
- `</span>`;
34
- const CONSOLE_TAB_HTML = `<svg class="di-tabIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 5.5C4 4.67 4.67 4 5.5 4H18.5C19.33 4 20 4.67 20 5.5V15.5C20 16.33 19.33 17 18.5 17H13.5L12 18.5L10.5 17H5.5C4.67 17 4 16.33 4 15.5V5.5Z" stroke="currentColor" stroke-width="1.5" stroke-linejoin="round"/><path d="M7 8H17" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M7 11H14" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/></svg>` +
35
- `<span>Console</span>` +
36
- `<span class="di-badge" data-di-count="console">0</span>`;
37
- const NETWORK_TAB_HTML = `<svg class="di-tabIcon" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 12C4 7.58 7.58 4 12 4C16.42 4 20 7.58 20 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M6 12C6 8.69 8.69 6 12 6C15.31 6 18 8.69 18 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M8.5 12C8.5 10.07 10.07 8.5 12 8.5C13.93 8.5 15.5 10.07 15.5 12" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><path d="M12 12L12 20" stroke="currentColor" stroke-width="1.5" stroke-linecap="round"/><circle cx="12" cy="20" r="1.5" fill="currentColor"/></svg>` +
38
- `<span>Network</span>` +
39
- `<span class="di-badge" data-di-count="network">0</span>`;
40
- function clamp(n, min, max) {
41
- return Math.max(min, Math.min(max, n));
42
- }
43
- function ensureDocument() {
44
- if (typeof document === "undefined") {
45
- throw new Error("Panel UI requires a browser-like environment with document.");
46
- }
47
- return document;
48
- }
49
- function ensureStyle(doc) {
50
- const id = "dev-inspector-panel-style";
51
- const existing = doc.getElementById(id);
52
- if (existing)
53
- return;
54
- const style = doc.createElement("style");
55
- style.id = id;
56
- style.textContent = panelStyles_1.PANEL_CSS;
57
- doc.head.append(style);
58
- }
59
- function createPanelState(initiallyOpen) {
60
- return {
61
- open: initiallyOpen,
62
- tab: "console",
63
- entries: { console: [], network: [] },
64
- errorCounts: { console: 0, network: 0 },
65
- };
66
- }
67
- function buildPanelDOM(doc, options) {
68
- var _a, _b;
69
- const mount = (_a = options.mount) !== null && _a !== void 0 ? _a : doc.body;
70
- const title = (_b = options.title) !== null && _b !== void 0 ? _b : "Dev Inspector";
71
- const root = doc.createElement("div");
72
- root.className = "di-root";
73
- const toggleBtn = doc.createElement("button");
74
- toggleBtn.type = "button";
75
- toggleBtn.className = "di-toggle";
76
- toggleBtn.setAttribute("aria-label", "Dev Inspector");
77
- toggleBtn.innerHTML = TOGGLE_BUTTON_HTML;
78
- const panel = doc.createElement("div");
79
- panel.className = "di-panel";
80
- const resizeHandle = doc.createElement("div");
81
- resizeHandle.className = "di-resizeHandle";
82
- resizeHandle.setAttribute("role", "separator");
83
- resizeHandle.setAttribute("aria-label", "Resize panel");
84
- const header = doc.createElement("div");
85
- header.className = "di-header";
86
- const headerRow = doc.createElement("div");
87
- headerRow.className = "di-headerRow";
88
- const titleEl = doc.createElement("div");
89
- titleEl.className = "di-title";
90
- titleEl.textContent = title;
91
- const actions = doc.createElement("div");
92
- actions.className = "di-actions";
93
- const clearBtn = doc.createElement("button");
94
- clearBtn.type = "button";
95
- clearBtn.className = "di-btn";
96
- clearBtn.textContent = "Clear";
97
- const closeBtn = doc.createElement("button");
98
- closeBtn.type = "button";
99
- closeBtn.className = "di-btn";
100
- closeBtn.textContent = "Close";
101
- actions.append(clearBtn, closeBtn);
102
- headerRow.append(resizeHandle, titleEl, actions);
103
- const tabs = doc.createElement("div");
104
- tabs.className = "di-tabs";
105
- const consoleTab = doc.createElement("button");
106
- consoleTab.type = "button";
107
- consoleTab.className = "di-tab";
108
- consoleTab.innerHTML = CONSOLE_TAB_HTML;
109
- const networkTab = doc.createElement("button");
110
- networkTab.type = "button";
111
- networkTab.className = "di-tab";
112
- networkTab.innerHTML = NETWORK_TAB_HTML;
113
- tabs.append(consoleTab, networkTab);
114
- header.append(headerRow, tabs);
115
- const body = doc.createElement("div");
116
- body.className = "di-body";
117
- const list = (0, logList_1.createLogList)(doc);
118
- body.append(list.el);
119
- panel.append(header, body);
120
- root.append(toggleBtn, panel);
121
- mount.append(root);
122
- const counters = {
123
- headerConsoleCount: queryOrThrow(header, '[data-di-count="console"]'),
124
- headerNetworkCount: queryOrThrow(header, '[data-di-count="network"]'),
125
- toggleConsoleCount: queryOrThrow(toggleBtn, '[data-di-toggle-count-value="console"]'),
126
- toggleNetworkCount: queryOrThrow(toggleBtn, '[data-di-toggle-count-value="network"]'),
127
- toggleConsoleErrorCount: queryOrThrow(toggleBtn, '[data-di-toggle-error-value="console"]'),
128
- toggleNetworkErrorCount: queryOrThrow(toggleBtn, '[data-di-toggle-error-value="network"]'),
129
- toggleConsoleErrorWrap: queryOrThrow(toggleBtn, '[data-di-toggle-error="console"]'),
130
- toggleNetworkErrorWrap: queryOrThrow(toggleBtn, '[data-di-toggle-error="network"]'),
131
- };
132
- return { root, toggleBtn, panel, header, body, closeBtn, clearBtn, consoleTab, networkTab, resizeHandle, list, counters };
133
- }
134
- function attachResizeHandling(panel, resizeHandle) {
135
- var _a;
136
- const MAX_WIDTH_CAP = 920;
137
- const MAX_HEIGHT_CAP = 720;
138
- const MARGIN_X = 24;
139
- const MARGIN_Y = 68;
140
- const minSize = (() => {
141
- const r = panel.getBoundingClientRect();
142
- return { w: Math.round(r.width), h: Math.round(r.height) };
143
- })();
144
- const getMaxSize = () => {
145
- const win = getWindow();
146
- const vw = typeof win.innerWidth === "number" ? win.innerWidth : 0;
147
- const vh = typeof win.innerHeight === "number" ? win.innerHeight : 0;
148
- return {
149
- w: Math.max(200, Math.min(MAX_WIDTH_CAP, vw - MARGIN_X)),
150
- h: Math.max(180, Math.min(MAX_HEIGHT_CAP, vh - MARGIN_Y)),
151
- };
152
- };
153
- const getCurrentSize = () => {
154
- const r = panel.getBoundingClientRect();
155
- return { w: Math.round(r.width), h: Math.round(r.height) };
156
- };
157
- const applySize = (next) => {
158
- const max = getMaxSize();
159
- const effMinW = Math.min(minSize.w, max.w);
160
- const effMinH = Math.min(minSize.h, max.h);
161
- const w = clamp(next.w, effMinW, max.w);
162
- const h = clamp(next.h, effMinH, max.h);
163
- panel.style.width = `${w}px`;
164
- panel.style.height = `${h}px`;
165
- };
166
- const ensureWithinViewport = () => {
167
- if (!panel.style.width && !panel.style.height)
168
- return;
169
- applySize(getCurrentSize());
170
- };
171
- let resizing = false;
172
- let startX = 0;
173
- let startY = 0;
174
- let startW = 0;
175
- let startH = 0;
176
- const onResizeMove = (ev) => {
177
- if (!resizing)
178
- return;
179
- const dx = startX - ev.clientX;
180
- const dy = startY - ev.clientY;
181
- applySize({ w: startW + dx, h: startH + dy });
182
- };
183
- const stopResize = () => {
184
- var _a, _b, _c;
185
- if (!resizing)
186
- return;
187
- resizing = false;
188
- const win = getWindow();
189
- (_a = win.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "pointermove", onResizeMove);
190
- (_b = win.removeEventListener) === null || _b === void 0 ? void 0 : _b.call(win, "pointerup", stopResize);
191
- (_c = win.removeEventListener) === null || _c === void 0 ? void 0 : _c.call(win, "pointercancel", stopResize);
192
- };
193
- const onResizeStart = (ev) => {
194
- var _a, _b, _c;
195
- resizing = true;
196
- startX = ev.clientX;
197
- startY = ev.clientY;
198
- const cur = getCurrentSize();
199
- startW = cur.w;
200
- startH = cur.h;
201
- try {
202
- resizeHandle.setPointerCapture(ev.pointerId);
203
- }
204
- catch (_d) {
205
- void 0;
206
- }
207
- const win = getWindow();
208
- (_a = win.addEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "pointermove", onResizeMove);
209
- (_b = win.addEventListener) === null || _b === void 0 ? void 0 : _b.call(win, "pointerup", stopResize);
210
- (_c = win.addEventListener) === null || _c === void 0 ? void 0 : _c.call(win, "pointercancel", stopResize);
211
- };
212
- const onWindowResize = () => ensureWithinViewport();
213
- const win = getWindow();
214
- (_a = win.addEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "resize", onWindowResize);
215
- resizeHandle.addEventListener("pointerdown", onResizeStart);
216
- const destroy = () => {
217
- var _a;
218
- resizeHandle.removeEventListener("pointerdown", onResizeStart);
219
- stopResize();
220
- (_a = win.removeEventListener) === null || _a === void 0 ? void 0 : _a.call(win, "resize", onWindowResize);
221
- };
222
- return { destroy };
223
- }
224
- function bindStorageToPanelView(args) {
225
- const isConsoleError = (e) => e.source === "console" && e.level === "error";
226
- const isNetworkError = (e) => e.source === "network" && (typeof e.status !== "number" || e.status >= 400);
227
- const updateCounts = () => {
228
- args.counters.headerConsoleCount.textContent = String(args.state.entries.console.length);
229
- args.counters.headerNetworkCount.textContent = String(args.state.entries.network.length);
230
- args.counters.toggleConsoleCount.textContent = String(args.state.entries.console.length);
231
- args.counters.toggleNetworkCount.textContent = String(args.state.entries.network.length);
232
- args.counters.toggleConsoleErrorCount.textContent = String(args.state.errorCounts.console);
233
- args.counters.toggleNetworkErrorCount.textContent = String(args.state.errorCounts.network);
234
- args.counters.toggleConsoleErrorWrap.style.display = args.state.errorCounts.console > 0 ? "inline-flex" : "none";
235
- args.counters.toggleNetworkErrorWrap.style.display = args.state.errorCounts.network > 0 ? "inline-flex" : "none";
236
- };
237
- const renderActiveTab = () => {
238
- args.list.clear();
239
- args.state.entries[args.state.tab].forEach((e) => args.list.append(e));
240
- args.body.scrollTop = args.body.scrollHeight;
241
- };
242
- const hydrate = () => {
243
- args.state.entries.console = [];
244
- args.state.entries.network = [];
245
- args.state.errorCounts.console = 0;
246
- args.state.errorCounts.network = 0;
247
- args.storage.getAll().forEach((e) => {
248
- if (e.source === "network") {
249
- args.state.entries.network.push(e);
250
- if (isNetworkError(e))
251
- args.state.errorCounts.network += 1;
252
- }
253
- else {
254
- args.state.entries.console.push(e);
255
- if (isConsoleError(e))
256
- args.state.errorCounts.console += 1;
257
- }
258
- });
259
- updateCounts();
260
- args.updateTabStyles();
261
- renderActiveTab();
262
- };
263
- const onNewLog = (entry) => {
264
- if (entry.source === "network") {
265
- args.state.entries.network.push(entry);
266
- if (isNetworkError(entry))
267
- args.state.errorCounts.network += 1;
268
- }
269
- else {
270
- args.state.entries.console.push(entry);
271
- if (isConsoleError(entry))
272
- args.state.errorCounts.console += 1;
273
- }
274
- updateCounts();
275
- if (entry.source === args.state.tab) {
276
- args.list.append(entry);
277
- args.body.scrollTop = args.body.scrollHeight;
278
- }
279
- };
280
- const unsub = args.storage.onNewLog(onNewLog);
281
- const onCleared = () => {
282
- args.state.entries.console = [];
283
- args.state.entries.network = [];
284
- args.state.errorCounts.console = 0;
285
- args.state.errorCounts.network = 0;
286
- updateCounts();
287
- renderActiveTab();
288
- };
289
- args.storage.addEventListener("cleared", onCleared);
290
- hydrate();
291
- const destroy = () => {
292
- args.storage.removeEventListener("cleared", onCleared);
293
- unsub();
294
- };
295
- return { destroy, renderActiveTab, hydrate };
296
- }
297
- function setupPanelBehavior(dom, state, storage) {
298
- const applyVisibility = () => {
299
- if (state.open)
300
- dom.panel.classList.remove("di-hidden");
301
- else
302
- dom.panel.classList.add("di-hidden");
303
- };
304
- const updateTabStyles = () => {
305
- if (state.tab === "console") {
306
- dom.consoleTab.classList.add("di-tabActive");
307
- dom.networkTab.classList.remove("di-tabActive");
308
- }
309
- else {
310
- dom.networkTab.classList.add("di-tabActive");
311
- dom.consoleTab.classList.remove("di-tabActive");
312
- }
313
- };
314
- const bindings = bindStorageToPanelView({
315
- storage,
316
- state,
317
- list: dom.list,
318
- body: dom.body,
319
- counters: dom.counters,
320
- updateTabStyles,
321
- });
322
- applyVisibility();
323
- updateTabStyles();
324
- const resizeControls = attachResizeHandling(dom.panel, dom.resizeHandle);
325
- const open = () => {
326
- state.open = true;
327
- applyVisibility();
328
- };
329
- const close = () => {
330
- state.open = false;
331
- applyVisibility();
332
- };
333
- const toggle = () => {
334
- state.open = !state.open;
335
- applyVisibility();
336
- };
337
- const onToggleClick = () => toggle();
338
- const onCloseClick = () => close();
339
- const onClearClick = () => storage.clear();
340
- const onConsoleTab = () => {
341
- state.tab = "console";
342
- updateTabStyles();
343
- bindings.renderActiveTab();
344
- };
345
- const onNetworkTab = () => {
346
- state.tab = "network";
347
- updateTabStyles();
348
- bindings.renderActiveTab();
349
- };
350
- dom.toggleBtn.addEventListener("click", onToggleClick);
351
- dom.closeBtn.addEventListener("click", onCloseClick);
352
- dom.clearBtn.addEventListener("click", onClearClick);
353
- dom.consoleTab.addEventListener("click", onConsoleTab);
354
- dom.networkTab.addEventListener("click", onNetworkTab);
355
- const destroy = () => {
356
- dom.toggleBtn.removeEventListener("click", onToggleClick);
357
- dom.closeBtn.removeEventListener("click", onCloseClick);
358
- dom.clearBtn.removeEventListener("click", onClearClick);
359
- dom.consoleTab.removeEventListener("click", onConsoleTab);
360
- dom.networkTab.removeEventListener("click", onNetworkTab);
361
- resizeControls.destroy();
362
- bindings.destroy();
363
- dom.root.remove();
364
- };
365
- return { open, close, toggle, destroy, isOpen: () => state.open };
366
- }
367
- function createPanel(options) {
368
- var _a;
369
- const doc = ensureDocument();
370
- ensureStyle(doc);
371
- const dom = buildPanelDOM(doc, options);
372
- const state = createPanelState((_a = options.initiallyOpen) !== null && _a !== void 0 ? _a : false);
373
- const handle = setupPanelBehavior(dom, state, options.storage);
374
- return handle;
375
- }
@@ -1,2 +0,0 @@
1
- export declare function launchMiniConfetti(anchor: HTMLElement): void;
2
- export declare function copyText(text: string): Promise<boolean>;
@@ -1,101 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.launchMiniConfetti = launchMiniConfetti;
4
- exports.copyText = copyText;
5
- function prefersReducedMotion() {
6
- var _a, _b;
7
- try {
8
- const mm = globalThis;
9
- return ((_b = (_a = mm.matchMedia) === null || _a === void 0 ? void 0 : _a.call(mm, "(prefers-reduced-motion: reduce)")) === null || _b === void 0 ? void 0 : _b.matches) === true;
10
- }
11
- catch (_c) {
12
- return false;
13
- }
14
- }
15
- function rand(min, max) {
16
- return min + Math.random() * (max - min);
17
- }
18
- function launchMiniConfetti(anchor) {
19
- if (prefersReducedMotion())
20
- return;
21
- if (typeof document === "undefined")
22
- return;
23
- const rect = anchor.getBoundingClientRect();
24
- const cx = rect.left + rect.width / 2;
25
- const cy = rect.top + rect.height / 2;
26
- const root = document.createElement("div");
27
- root.style.position = "fixed";
28
- root.style.left = "0";
29
- root.style.top = "0";
30
- root.style.width = "0";
31
- root.style.height = "0";
32
- root.style.pointerEvents = "none";
33
- root.style.zIndex = "2147483647";
34
- document.body.append(root);
35
- const colors = ["#a7ff00", "#7c5cff", "#00c4ff", "#ff9030", "#ef4444"];
36
- const n = 14;
37
- const duration = 520;
38
- for (let i = 0; i < n; i += 1) {
39
- const p = document.createElement("span");
40
- const size = Math.round(rand(3, 6));
41
- p.style.position = "fixed";
42
- p.style.left = `${cx}px`;
43
- p.style.top = `${cy}px`;
44
- p.style.width = `${size}px`;
45
- p.style.height = `${size}px`;
46
- p.style.borderRadius = Math.random() < 0.35 ? "999px" : "2px";
47
- p.style.background = colors[i % colors.length];
48
- p.style.opacity = "1";
49
- p.style.willChange = "transform, opacity";
50
- root.append(p);
51
- const angle = rand(0, Math.PI * 2);
52
- const dist = rand(18, 46);
53
- const dx = Math.cos(angle) * dist;
54
- const dy = Math.sin(angle) * dist + rand(8, 16);
55
- const rot = rand(-220, 220);
56
- const delay = Math.round(rand(0, 60));
57
- try {
58
- const anim = p.animate([
59
- { transform: `translate(-50%, -50%) translate(0px, 0px) rotate(0deg) scale(1)`, opacity: 1 },
60
- { transform: `translate(-50%, -50%) translate(${dx}px, ${dy}px) rotate(${rot}deg) scale(0.9)`, opacity: 0 },
61
- ], { duration, delay, easing: "cubic-bezier(0.2, 0.7, 0.2, 1)", fill: "forwards" });
62
- anim.addEventListener("finish", () => p.remove());
63
- }
64
- catch (_a) {
65
- globalThis.setTimeout(() => p.remove(), duration + delay + 50);
66
- }
67
- }
68
- globalThis.setTimeout(() => root.remove(), duration + 120);
69
- }
70
- async function copyText(text) {
71
- var _a, _b;
72
- try {
73
- const nav = globalThis;
74
- const fn = (_b = (_a = nav.navigator) === null || _a === void 0 ? void 0 : _a.clipboard) === null || _b === void 0 ? void 0 : _b.writeText;
75
- if (typeof fn === "function") {
76
- await fn(text);
77
- return true;
78
- }
79
- }
80
- catch (_c) {
81
- void 0;
82
- }
83
- try {
84
- if (typeof document === "undefined")
85
- return false;
86
- const ta = document.createElement("textarea");
87
- ta.value = text;
88
- ta.setAttribute("readonly", "true");
89
- ta.style.position = "fixed";
90
- ta.style.left = "-9999px";
91
- ta.style.top = "0";
92
- document.body.append(ta);
93
- ta.select();
94
- const ok = document.execCommand("copy");
95
- ta.remove();
96
- return ok;
97
- }
98
- catch (_d) {
99
- return false;
100
- }
101
- }