tauri-notice-window 1.0.8 → 1.0.10
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 +159 -67
- package/dist/components/NoticeLayout.d.ts.map +1 -1
- package/dist/hooks/useHideNotice.d.ts.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +331 -292
- package/dist/index.js.map +1 -1
- package/dist/stores/messageQueueStore.d.ts +4 -0
- package/dist/stores/messageQueueStore.d.ts.map +1 -1
- package/dist/utils/db.d.ts +2 -1
- package/dist/utils/db.d.ts.map +1 -1
- package/dist/utils/noticeWindow.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import { create as
|
|
2
|
-
import { syncTabs as
|
|
3
|
-
import
|
|
4
|
-
import { useCallback as
|
|
5
|
-
import { jsx as
|
|
6
|
-
const
|
|
1
|
+
import { create as ce } from "zustand";
|
|
2
|
+
import { syncTabs as we } from "zustand-sync";
|
|
3
|
+
import de from "dexie";
|
|
4
|
+
import { useCallback as M, useState as L, useEffect as G } from "react";
|
|
5
|
+
import { jsx as N, Fragment as he } from "react/jsx-runtime";
|
|
6
|
+
const K = "tauri-notice-config", Q = {
|
|
7
7
|
routePrefix: "/notice",
|
|
8
8
|
databaseName: "tauri-notice-db",
|
|
9
9
|
defaultWidth: 400,
|
|
10
10
|
defaultHeight: 300,
|
|
11
11
|
notFoundUrl: "/404"
|
|
12
12
|
// Default 404 page
|
|
13
|
-
},
|
|
13
|
+
}, X = () => {
|
|
14
14
|
try {
|
|
15
|
-
const t = localStorage.getItem(
|
|
15
|
+
const t = localStorage.getItem(K);
|
|
16
16
|
if (t)
|
|
17
|
-
return { ...
|
|
17
|
+
return { ...Q, ...JSON.parse(t) };
|
|
18
18
|
} catch (t) {
|
|
19
19
|
console.warn("Failed to load config from localStorage:", t);
|
|
20
20
|
}
|
|
21
|
-
return
|
|
22
|
-
},
|
|
21
|
+
return Q;
|
|
22
|
+
}, ge = (t) => {
|
|
23
23
|
try {
|
|
24
|
-
localStorage.setItem(
|
|
24
|
+
localStorage.setItem(K, JSON.stringify(t));
|
|
25
25
|
} catch (e) {
|
|
26
26
|
console.warn("Failed to save config to localStorage:", e);
|
|
27
27
|
}
|
|
28
|
-
},
|
|
29
|
-
const i = { ...
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
class
|
|
28
|
+
}, He = (t) => {
|
|
29
|
+
const i = { ...X(), ...t };
|
|
30
|
+
ge(i);
|
|
31
|
+
}, ee = () => X();
|
|
32
|
+
class ye extends de {
|
|
33
33
|
messages;
|
|
34
34
|
constructor(e) {
|
|
35
35
|
super(e), this.version(1).stores({
|
|
@@ -37,14 +37,14 @@ class he extends ce {
|
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
let
|
|
41
|
-
const
|
|
42
|
-
if (!
|
|
43
|
-
const t =
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return
|
|
47
|
-
}, h = () =>
|
|
40
|
+
let S = null;
|
|
41
|
+
const te = () => {
|
|
42
|
+
if (!S) {
|
|
43
|
+
const t = ee();
|
|
44
|
+
S = new ye(t.databaseName);
|
|
45
|
+
}
|
|
46
|
+
return S;
|
|
47
|
+
}, h = () => S || te(), be = async (t) => {
|
|
48
48
|
const e = {
|
|
49
49
|
...t,
|
|
50
50
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
@@ -54,30 +54,30 @@ const X = () => {
|
|
|
54
54
|
queuePosition: 0
|
|
55
55
|
};
|
|
56
56
|
await h().messages.put(e);
|
|
57
|
-
},
|
|
57
|
+
}, pe = async (t) => !!await h().messages.get(t), _e = async (t) => {
|
|
58
58
|
const e = await h().messages.get(t);
|
|
59
59
|
return e?.isShown === !0 || e?.queueStatus === "shown";
|
|
60
|
-
},
|
|
60
|
+
}, fe = async () => await h().messages.where("queueStatus").equals("pending").sortBy("queuePosition"), me = async (t, e) => {
|
|
61
61
|
await h().messages.update(t, { queueStatus: e });
|
|
62
|
-
},
|
|
62
|
+
}, ve = async (t) => {
|
|
63
63
|
await h().messages.update(t, {
|
|
64
64
|
queueStatus: "shown",
|
|
65
65
|
isShown: !0
|
|
66
66
|
});
|
|
67
|
-
},
|
|
67
|
+
}, We = async (t) => {
|
|
68
68
|
await h().messages.update(t, {
|
|
69
69
|
queueStatus: "hidden"
|
|
70
70
|
});
|
|
71
|
-
},
|
|
71
|
+
}, ie = async (t) => await h().messages.get(t), Se = async (t) => {
|
|
72
72
|
await h().messages.delete(t);
|
|
73
|
-
},
|
|
73
|
+
}, De = async () => {
|
|
74
74
|
await h().messages.where("queueStatus").anyOf(["pending", "showing"]).delete();
|
|
75
|
-
},
|
|
75
|
+
}, Ae = async (t) => {
|
|
76
76
|
const e = t.map(
|
|
77
77
|
(i) => h().messages.update(i.id, { queuePosition: i.position })
|
|
78
78
|
);
|
|
79
79
|
await Promise.all(e);
|
|
80
|
-
},
|
|
80
|
+
}, Ne = (t, e) => ({
|
|
81
81
|
// Initial state
|
|
82
82
|
queue: [],
|
|
83
83
|
currentMessage: null,
|
|
@@ -87,11 +87,11 @@ const X = () => {
|
|
|
87
87
|
// Enqueue a new message
|
|
88
88
|
enqueue: async (i) => {
|
|
89
89
|
const n = e();
|
|
90
|
-
if (await
|
|
90
|
+
if (await _e(i.id)) {
|
|
91
91
|
console.log(`Message ${i.id} was already shown, skipping`);
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
if (await
|
|
94
|
+
if (await pe(i.id) || await be(i), !n.queue.some((u) => u.id === i.id)) {
|
|
95
95
|
const u = [...n.queue, i];
|
|
96
96
|
t({ queue: u }), await e().persistQueue();
|
|
97
97
|
}
|
|
@@ -112,10 +112,14 @@ const X = () => {
|
|
|
112
112
|
t({ isProcessing: !1, currentMessage: null });
|
|
113
113
|
return;
|
|
114
114
|
}
|
|
115
|
+
if (!await ie(n.id)) {
|
|
116
|
+
console.log(`Message ${n.id} was deleted, skipping to next`), await e().showNext();
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
115
119
|
t({
|
|
116
120
|
currentMessage: n,
|
|
117
121
|
isProcessing: !0
|
|
118
|
-
}), await
|
|
122
|
+
}), await me(n.id, "showing"), await e().persistQueue();
|
|
119
123
|
},
|
|
120
124
|
// Clear current message and show next
|
|
121
125
|
clearCurrent: () => {
|
|
@@ -140,16 +144,16 @@ const X = () => {
|
|
|
140
144
|
initializeFromDatabase: async () => {
|
|
141
145
|
if (e().initialized) return;
|
|
142
146
|
t({ initialized: !0 });
|
|
143
|
-
const n = await
|
|
147
|
+
const n = await fe();
|
|
144
148
|
n.length > 0 && (t({ queue: n }), await e().showNext());
|
|
145
149
|
},
|
|
146
150
|
// Persist queue to database
|
|
147
151
|
persistQueue: async () => {
|
|
148
|
-
const n = e().queue.map((a,
|
|
152
|
+
const n = e().queue.map((a, l) => ({
|
|
149
153
|
id: a.id,
|
|
150
|
-
position:
|
|
154
|
+
position: l
|
|
151
155
|
}));
|
|
152
|
-
await
|
|
156
|
+
await Ae(n);
|
|
153
157
|
},
|
|
154
158
|
// Clear all messages on logout
|
|
155
159
|
clearOnLogout: async () => {
|
|
@@ -159,7 +163,24 @@ const X = () => {
|
|
|
159
163
|
isProcessing: !1,
|
|
160
164
|
activeWindowIds: [],
|
|
161
165
|
initialized: !1
|
|
162
|
-
}), await
|
|
166
|
+
}), await De();
|
|
167
|
+
},
|
|
168
|
+
// Remove a specific message from the queue by ID (memory only)
|
|
169
|
+
removeFromQueue: async (i) => {
|
|
170
|
+
const n = e(), a = n.queue.filter((l) => l.id !== i);
|
|
171
|
+
t({ queue: a }), await e().persistQueue(), n.currentMessage?.id === i && e().clearCurrent();
|
|
172
|
+
},
|
|
173
|
+
// Delete message completely (from both memory and database)
|
|
174
|
+
deleteMessage: async (i) => {
|
|
175
|
+
await Se(i), await e().removeFromQueue(i);
|
|
176
|
+
},
|
|
177
|
+
// Hide a message (mark as hidden and remove from queue)
|
|
178
|
+
hideMessage: async (i) => {
|
|
179
|
+
await We(i), await e().removeFromQueue(i);
|
|
180
|
+
},
|
|
181
|
+
// Mark message as shown in database
|
|
182
|
+
markMessageAsShown: async (i) => {
|
|
183
|
+
await ve(i);
|
|
163
184
|
},
|
|
164
185
|
// Add active window ID
|
|
165
186
|
addActiveWindow: (i) => {
|
|
@@ -170,7 +191,7 @@ const X = () => {
|
|
|
170
191
|
removeActiveWindow: (i) => {
|
|
171
192
|
const n = e(), a = String(i);
|
|
172
193
|
t({
|
|
173
|
-
activeWindowIds: n.activeWindowIds.filter((
|
|
194
|
+
activeWindowIds: n.activeWindowIds.filter((l) => l !== a)
|
|
174
195
|
});
|
|
175
196
|
},
|
|
176
197
|
// Check if window is active
|
|
@@ -178,46 +199,46 @@ const X = () => {
|
|
|
178
199
|
const n = e(), a = String(i);
|
|
179
200
|
return n.activeWindowIds.includes(a);
|
|
180
201
|
}
|
|
181
|
-
}),
|
|
182
|
-
|
|
202
|
+
}), w = ce()(
|
|
203
|
+
we(Ne, {
|
|
183
204
|
name: "tauri-notice-queue"
|
|
184
205
|
})
|
|
185
|
-
),
|
|
206
|
+
), z = {
|
|
186
207
|
queueLength: (t) => t.queue.length,
|
|
187
208
|
currentMessage: (t) => t.currentMessage,
|
|
188
209
|
isProcessing: (t) => t.isProcessing,
|
|
189
210
|
queue: (t) => t.queue
|
|
190
211
|
}, Ve = () => {
|
|
191
|
-
const t =
|
|
192
|
-
return { showNotice:
|
|
212
|
+
const t = w((i) => i.enqueue);
|
|
213
|
+
return { showNotice: M(
|
|
193
214
|
async (i) => {
|
|
194
215
|
await t(i);
|
|
195
216
|
},
|
|
196
217
|
[t]
|
|
197
218
|
) };
|
|
198
219
|
};
|
|
199
|
-
function
|
|
220
|
+
function ze(t, e, i, n) {
|
|
200
221
|
if (typeof e == "function" ? t !== e || !n : !e.has(t)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
201
222
|
return i === "m" ? n : i === "a" ? n.call(t) : n ? n.value : e.get(t);
|
|
202
223
|
}
|
|
203
|
-
function
|
|
224
|
+
function Oe(t, e, i, n, a) {
|
|
204
225
|
if (typeof e == "function" ? t !== e || !0 : !e.has(t)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
205
226
|
return e.set(t, i), i;
|
|
206
227
|
}
|
|
207
|
-
var
|
|
208
|
-
const
|
|
209
|
-
function
|
|
228
|
+
var O;
|
|
229
|
+
const d = "__TAURI_TO_IPC_KEY__";
|
|
230
|
+
function xe(t, e = !1) {
|
|
210
231
|
return window.__TAURI_INTERNALS__.transformCallback(t, e);
|
|
211
232
|
}
|
|
212
233
|
async function s(t, e = {}, i) {
|
|
213
234
|
return window.__TAURI_INTERNALS__.invoke(t, e, i);
|
|
214
235
|
}
|
|
215
|
-
class
|
|
236
|
+
class Pe {
|
|
216
237
|
get rid() {
|
|
217
|
-
return
|
|
238
|
+
return ze(this, O, "f");
|
|
218
239
|
}
|
|
219
240
|
constructor(e) {
|
|
220
|
-
|
|
241
|
+
O.set(this, void 0), Oe(this, O, e);
|
|
221
242
|
}
|
|
222
243
|
/**
|
|
223
244
|
* Destroys and cleans up this resource from memory.
|
|
@@ -229,8 +250,8 @@ class Ae {
|
|
|
229
250
|
});
|
|
230
251
|
}
|
|
231
252
|
}
|
|
232
|
-
|
|
233
|
-
class
|
|
253
|
+
O = /* @__PURE__ */ new WeakMap();
|
|
254
|
+
class ne {
|
|
234
255
|
constructor(...e) {
|
|
235
256
|
this.type = "Logical", e.length === 1 ? "Logical" in e[0] ? (this.width = e[0].Logical.width, this.height = e[0].Logical.height) : (this.width = e[0].width, this.height = e[0].height) : (this.width = e[0], this.height = e[1]);
|
|
236
257
|
}
|
|
@@ -250,19 +271,19 @@ class te {
|
|
|
250
271
|
* @since 2.0.0
|
|
251
272
|
*/
|
|
252
273
|
toPhysical(e) {
|
|
253
|
-
return new
|
|
274
|
+
return new y(this.width * e, this.height * e);
|
|
254
275
|
}
|
|
255
|
-
[
|
|
276
|
+
[d]() {
|
|
256
277
|
return {
|
|
257
278
|
width: this.width,
|
|
258
279
|
height: this.height
|
|
259
280
|
};
|
|
260
281
|
}
|
|
261
282
|
toJSON() {
|
|
262
|
-
return this[
|
|
283
|
+
return this[d]();
|
|
263
284
|
}
|
|
264
285
|
}
|
|
265
|
-
class
|
|
286
|
+
class y {
|
|
266
287
|
constructor(...e) {
|
|
267
288
|
this.type = "Physical", e.length === 1 ? "Physical" in e[0] ? (this.width = e[0].Physical.width, this.height = e[0].Physical.height) : (this.width = e[0].width, this.height = e[0].height) : (this.width = e[0], this.height = e[1]);
|
|
268
289
|
}
|
|
@@ -278,16 +299,16 @@ class b {
|
|
|
278
299
|
* ```
|
|
279
300
|
*/
|
|
280
301
|
toLogical(e) {
|
|
281
|
-
return new
|
|
302
|
+
return new ne(this.width / e, this.height / e);
|
|
282
303
|
}
|
|
283
|
-
[
|
|
304
|
+
[d]() {
|
|
284
305
|
return {
|
|
285
306
|
width: this.width,
|
|
286
307
|
height: this.height
|
|
287
308
|
};
|
|
288
309
|
}
|
|
289
310
|
toJSON() {
|
|
290
|
-
return this[
|
|
311
|
+
return this[d]();
|
|
291
312
|
}
|
|
292
313
|
}
|
|
293
314
|
class g {
|
|
@@ -295,12 +316,12 @@ class g {
|
|
|
295
316
|
this.size = e;
|
|
296
317
|
}
|
|
297
318
|
toLogical(e) {
|
|
298
|
-
return this.size instanceof
|
|
319
|
+
return this.size instanceof ne ? this.size : this.size.toLogical(e);
|
|
299
320
|
}
|
|
300
321
|
toPhysical(e) {
|
|
301
|
-
return this.size instanceof
|
|
322
|
+
return this.size instanceof y ? this.size : this.size.toPhysical(e);
|
|
302
323
|
}
|
|
303
|
-
[
|
|
324
|
+
[d]() {
|
|
304
325
|
return {
|
|
305
326
|
[`${this.size.type}`]: {
|
|
306
327
|
width: this.size.width,
|
|
@@ -309,10 +330,10 @@ class g {
|
|
|
309
330
|
};
|
|
310
331
|
}
|
|
311
332
|
toJSON() {
|
|
312
|
-
return this[
|
|
333
|
+
return this[d]();
|
|
313
334
|
}
|
|
314
335
|
}
|
|
315
|
-
class
|
|
336
|
+
class se {
|
|
316
337
|
constructor(...e) {
|
|
317
338
|
this.type = "Logical", e.length === 1 ? "Logical" in e[0] ? (this.x = e[0].Logical.x, this.y = e[0].Logical.y) : (this.x = e[0].x, this.y = e[0].y) : (this.x = e[0], this.y = e[1]);
|
|
318
339
|
}
|
|
@@ -334,14 +355,14 @@ class ie {
|
|
|
334
355
|
toPhysical(e) {
|
|
335
356
|
return new c(this.x * e, this.y * e);
|
|
336
357
|
}
|
|
337
|
-
[
|
|
358
|
+
[d]() {
|
|
338
359
|
return {
|
|
339
360
|
x: this.x,
|
|
340
361
|
y: this.y
|
|
341
362
|
};
|
|
342
363
|
}
|
|
343
364
|
toJSON() {
|
|
344
|
-
return this[
|
|
365
|
+
return this[d]();
|
|
345
366
|
}
|
|
346
367
|
}
|
|
347
368
|
class c {
|
|
@@ -364,29 +385,29 @@ class c {
|
|
|
364
385
|
* @since 2.0.0
|
|
365
386
|
*/
|
|
366
387
|
toLogical(e) {
|
|
367
|
-
return new
|
|
388
|
+
return new se(this.x / e, this.y / e);
|
|
368
389
|
}
|
|
369
|
-
[
|
|
390
|
+
[d]() {
|
|
370
391
|
return {
|
|
371
392
|
x: this.x,
|
|
372
393
|
y: this.y
|
|
373
394
|
};
|
|
374
395
|
}
|
|
375
396
|
toJSON() {
|
|
376
|
-
return this[
|
|
397
|
+
return this[d]();
|
|
377
398
|
}
|
|
378
399
|
}
|
|
379
|
-
class
|
|
400
|
+
class _ {
|
|
380
401
|
constructor(e) {
|
|
381
402
|
this.position = e;
|
|
382
403
|
}
|
|
383
404
|
toLogical(e) {
|
|
384
|
-
return this.position instanceof
|
|
405
|
+
return this.position instanceof se ? this.position : this.position.toLogical(e);
|
|
385
406
|
}
|
|
386
407
|
toPhysical(e) {
|
|
387
408
|
return this.position instanceof c ? this.position : this.position.toPhysical(e);
|
|
388
409
|
}
|
|
389
|
-
[
|
|
410
|
+
[d]() {
|
|
390
411
|
return {
|
|
391
412
|
[`${this.position.type}`]: {
|
|
392
413
|
x: this.position.x,
|
|
@@ -395,47 +416,47 @@ class p {
|
|
|
395
416
|
};
|
|
396
417
|
}
|
|
397
418
|
toJSON() {
|
|
398
|
-
return this[
|
|
419
|
+
return this[d]();
|
|
399
420
|
}
|
|
400
421
|
}
|
|
401
422
|
var o;
|
|
402
423
|
(function(t) {
|
|
403
424
|
t.WINDOW_RESIZED = "tauri://resize", t.WINDOW_MOVED = "tauri://move", t.WINDOW_CLOSE_REQUESTED = "tauri://close-requested", t.WINDOW_DESTROYED = "tauri://destroyed", t.WINDOW_FOCUS = "tauri://focus", t.WINDOW_BLUR = "tauri://blur", t.WINDOW_SCALE_FACTOR_CHANGED = "tauri://scale-change", t.WINDOW_THEME_CHANGED = "tauri://theme-changed", t.WINDOW_CREATED = "tauri://window-created", t.WEBVIEW_CREATED = "tauri://webview-created", t.DRAG_ENTER = "tauri://drag-enter", t.DRAG_OVER = "tauri://drag-over", t.DRAG_DROP = "tauri://drag-drop", t.DRAG_LEAVE = "tauri://drag-leave";
|
|
404
425
|
})(o || (o = {}));
|
|
405
|
-
async function
|
|
426
|
+
async function ae(t, e) {
|
|
406
427
|
window.__TAURI_EVENT_PLUGIN_INTERNALS__.unregisterListener(t, e), await s("plugin:event|unlisten", {
|
|
407
428
|
event: t,
|
|
408
429
|
eventId: e
|
|
409
430
|
});
|
|
410
431
|
}
|
|
411
|
-
async function
|
|
432
|
+
async function I(t, e, i) {
|
|
412
433
|
var n;
|
|
413
434
|
const a = typeof i?.target == "string" ? { kind: "AnyLabel", label: i.target } : (n = i?.target) !== null && n !== void 0 ? n : { kind: "Any" };
|
|
414
435
|
return s("plugin:event|listen", {
|
|
415
436
|
event: t,
|
|
416
437
|
target: a,
|
|
417
|
-
handler:
|
|
418
|
-
}).then((
|
|
438
|
+
handler: xe(e)
|
|
439
|
+
}).then((l) => async () => ae(t, l));
|
|
419
440
|
}
|
|
420
|
-
async function
|
|
421
|
-
return
|
|
422
|
-
|
|
441
|
+
async function F(t, e, i) {
|
|
442
|
+
return I(t, (n) => {
|
|
443
|
+
ae(t, n.id), e(n);
|
|
423
444
|
}, i);
|
|
424
445
|
}
|
|
425
|
-
async function
|
|
446
|
+
async function re(t, e) {
|
|
426
447
|
await s("plugin:event|emit", {
|
|
427
448
|
event: t,
|
|
428
449
|
payload: e
|
|
429
450
|
});
|
|
430
451
|
}
|
|
431
|
-
async function
|
|
452
|
+
async function le(t, e, i) {
|
|
432
453
|
await s("plugin:event|emit_to", {
|
|
433
454
|
target: typeof t == "string" ? { kind: "AnyLabel", label: t } : t,
|
|
434
455
|
event: e,
|
|
435
456
|
payload: i
|
|
436
457
|
});
|
|
437
458
|
}
|
|
438
|
-
class
|
|
459
|
+
class D extends Pe {
|
|
439
460
|
/**
|
|
440
461
|
* Creates an Image from a resource ID. For internal use only.
|
|
441
462
|
*
|
|
@@ -447,10 +468,10 @@ class W extends Ae {
|
|
|
447
468
|
/** Creates a new Image using RGBA data, in row-major order from top to bottom, and with specified width and height. */
|
|
448
469
|
static async new(e, i, n) {
|
|
449
470
|
return s("plugin:image|new", {
|
|
450
|
-
rgba:
|
|
471
|
+
rgba: P(e),
|
|
451
472
|
width: i,
|
|
452
473
|
height: n
|
|
453
|
-
}).then((a) => new
|
|
474
|
+
}).then((a) => new D(a));
|
|
454
475
|
}
|
|
455
476
|
/**
|
|
456
477
|
* Creates a new image using the provided bytes by inferring the file format.
|
|
@@ -467,8 +488,8 @@ class W extends Ae {
|
|
|
467
488
|
*/
|
|
468
489
|
static async fromBytes(e) {
|
|
469
490
|
return s("plugin:image|from_bytes", {
|
|
470
|
-
bytes:
|
|
471
|
-
}).then((i) => new
|
|
491
|
+
bytes: P(e)
|
|
492
|
+
}).then((i) => new D(i));
|
|
472
493
|
}
|
|
473
494
|
/**
|
|
474
495
|
* Creates a new image using the provided path.
|
|
@@ -483,7 +504,7 @@ class W extends Ae {
|
|
|
483
504
|
* ```
|
|
484
505
|
*/
|
|
485
506
|
static async fromPath(e) {
|
|
486
|
-
return s("plugin:image|from_path", { path: e }).then((i) => new
|
|
507
|
+
return s("plugin:image|from_path", { path: e }).then((i) => new D(i));
|
|
487
508
|
}
|
|
488
509
|
/** Returns the RGBA data for this image, in row-major order from top to bottom. */
|
|
489
510
|
async rgba() {
|
|
@@ -496,14 +517,14 @@ class W extends Ae {
|
|
|
496
517
|
return s("plugin:image|size", { rid: this.rid });
|
|
497
518
|
}
|
|
498
519
|
}
|
|
499
|
-
function
|
|
500
|
-
return t == null ? null : typeof t == "string" ? t : t instanceof
|
|
520
|
+
function P(t) {
|
|
521
|
+
return t == null ? null : typeof t == "string" ? t : t instanceof D ? t.rid : t;
|
|
501
522
|
}
|
|
502
|
-
var
|
|
523
|
+
var q;
|
|
503
524
|
(function(t) {
|
|
504
525
|
t[t.Critical = 1] = "Critical", t[t.Informational = 2] = "Informational";
|
|
505
|
-
})(
|
|
506
|
-
class
|
|
526
|
+
})(q || (q = {}));
|
|
527
|
+
class Me {
|
|
507
528
|
constructor(e) {
|
|
508
529
|
this._preventDefault = !1, this.event = e.event, this.id = e.id;
|
|
509
530
|
}
|
|
@@ -514,24 +535,24 @@ class Oe {
|
|
|
514
535
|
return this._preventDefault;
|
|
515
536
|
}
|
|
516
537
|
}
|
|
517
|
-
var
|
|
538
|
+
var H;
|
|
518
539
|
(function(t) {
|
|
519
540
|
t.None = "none", t.Normal = "normal", t.Indeterminate = "indeterminate", t.Paused = "paused", t.Error = "error";
|
|
520
|
-
})(
|
|
521
|
-
function
|
|
522
|
-
return new
|
|
541
|
+
})(H || (H = {}));
|
|
542
|
+
function oe() {
|
|
543
|
+
return new k(window.__TAURI_INTERNALS__.metadata.currentWindow.label, {
|
|
523
544
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
524
545
|
skip: !0
|
|
525
546
|
});
|
|
526
547
|
}
|
|
527
|
-
async function
|
|
528
|
-
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new
|
|
548
|
+
async function E() {
|
|
549
|
+
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new k(e, {
|
|
529
550
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
530
551
|
skip: !0
|
|
531
552
|
})));
|
|
532
553
|
}
|
|
533
|
-
const
|
|
534
|
-
class
|
|
554
|
+
const R = ["tauri://created", "tauri://error"];
|
|
555
|
+
class k {
|
|
535
556
|
/**
|
|
536
557
|
* Creates a new Window.
|
|
537
558
|
* @example
|
|
@@ -572,19 +593,19 @@ class P {
|
|
|
572
593
|
*/
|
|
573
594
|
static async getByLabel(e) {
|
|
574
595
|
var i;
|
|
575
|
-
return (i = (await
|
|
596
|
+
return (i = (await E()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
|
|
576
597
|
}
|
|
577
598
|
/**
|
|
578
599
|
* Get an instance of `Window` for the current window.
|
|
579
600
|
*/
|
|
580
601
|
static getCurrent() {
|
|
581
|
-
return
|
|
602
|
+
return oe();
|
|
582
603
|
}
|
|
583
604
|
/**
|
|
584
605
|
* Gets a list of instances of `Window` for all available windows.
|
|
585
606
|
*/
|
|
586
607
|
static async getAll() {
|
|
587
|
-
return
|
|
608
|
+
return E();
|
|
588
609
|
}
|
|
589
610
|
/**
|
|
590
611
|
* Gets the focused window.
|
|
@@ -597,7 +618,7 @@ class P {
|
|
|
597
618
|
* @returns The Window instance or `undefined` if there is not any focused window.
|
|
598
619
|
*/
|
|
599
620
|
static async getFocusedWindow() {
|
|
600
|
-
for (const e of await
|
|
621
|
+
for (const e of await E())
|
|
601
622
|
if (await e.isFocused())
|
|
602
623
|
return e;
|
|
603
624
|
return null;
|
|
@@ -625,7 +646,7 @@ class P {
|
|
|
625
646
|
return this._handleTauriEvent(e, i) ? () => {
|
|
626
647
|
const n = this.listeners[e];
|
|
627
648
|
n.splice(n.indexOf(i), 1);
|
|
628
|
-
} :
|
|
649
|
+
} : I(e, i, {
|
|
629
650
|
target: { kind: "Window", label: this.label }
|
|
630
651
|
});
|
|
631
652
|
}
|
|
@@ -652,7 +673,7 @@ class P {
|
|
|
652
673
|
return this._handleTauriEvent(e, i) ? () => {
|
|
653
674
|
const n = this.listeners[e];
|
|
654
675
|
n.splice(n.indexOf(i), 1);
|
|
655
|
-
} :
|
|
676
|
+
} : F(e, i, {
|
|
656
677
|
target: { kind: "Window", label: this.label }
|
|
657
678
|
});
|
|
658
679
|
}
|
|
@@ -668,7 +689,7 @@ class P {
|
|
|
668
689
|
* @param payload Event payload.
|
|
669
690
|
*/
|
|
670
691
|
async emit(e, i) {
|
|
671
|
-
if (
|
|
692
|
+
if (R.includes(e)) {
|
|
672
693
|
for (const n of this.listeners[e] || [])
|
|
673
694
|
n({
|
|
674
695
|
event: e,
|
|
@@ -677,7 +698,7 @@ class P {
|
|
|
677
698
|
});
|
|
678
699
|
return;
|
|
679
700
|
}
|
|
680
|
-
return
|
|
701
|
+
return re(e, i);
|
|
681
702
|
}
|
|
682
703
|
/**
|
|
683
704
|
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
@@ -692,7 +713,7 @@ class P {
|
|
|
692
713
|
* @param payload Event payload.
|
|
693
714
|
*/
|
|
694
715
|
async emitTo(e, i, n) {
|
|
695
|
-
if (
|
|
716
|
+
if (R.includes(i)) {
|
|
696
717
|
for (const a of this.listeners[i] || [])
|
|
697
718
|
a({
|
|
698
719
|
event: i,
|
|
@@ -701,11 +722,11 @@ class P {
|
|
|
701
722
|
});
|
|
702
723
|
return;
|
|
703
724
|
}
|
|
704
|
-
return
|
|
725
|
+
return le(e, i, n);
|
|
705
726
|
}
|
|
706
727
|
/** @ignore */
|
|
707
728
|
_handleTauriEvent(e, i) {
|
|
708
|
-
return
|
|
729
|
+
return R.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
|
|
709
730
|
}
|
|
710
731
|
// Getters
|
|
711
732
|
/**
|
|
@@ -767,7 +788,7 @@ class P {
|
|
|
767
788
|
async innerSize() {
|
|
768
789
|
return s("plugin:window|inner_size", {
|
|
769
790
|
label: this.label
|
|
770
|
-
}).then((e) => new
|
|
791
|
+
}).then((e) => new y(e));
|
|
771
792
|
}
|
|
772
793
|
/**
|
|
773
794
|
* The physical size of the entire window.
|
|
@@ -783,7 +804,7 @@ class P {
|
|
|
783
804
|
async outerSize() {
|
|
784
805
|
return s("plugin:window|outer_size", {
|
|
785
806
|
label: this.label
|
|
786
|
-
}).then((e) => new
|
|
807
|
+
}).then((e) => new y(e));
|
|
787
808
|
}
|
|
788
809
|
/**
|
|
789
810
|
* Gets the window's current fullscreen state.
|
|
@@ -1034,7 +1055,7 @@ class P {
|
|
|
1034
1055
|
*/
|
|
1035
1056
|
async requestUserAttention(e) {
|
|
1036
1057
|
let i = null;
|
|
1037
|
-
return e && (e ===
|
|
1058
|
+
return e && (e === q.Critical ? i = { type: "Critical" } : i = { type: "Informational" }), s("plugin:window|request_user_attention", {
|
|
1038
1059
|
label: this.label,
|
|
1039
1060
|
value: i
|
|
1040
1061
|
});
|
|
@@ -1510,7 +1531,7 @@ class P {
|
|
|
1510
1531
|
async setPosition(e) {
|
|
1511
1532
|
return s("plugin:window|set_position", {
|
|
1512
1533
|
label: this.label,
|
|
1513
|
-
value: e instanceof
|
|
1534
|
+
value: e instanceof _ ? e : new _(e)
|
|
1514
1535
|
});
|
|
1515
1536
|
}
|
|
1516
1537
|
/**
|
|
@@ -1604,7 +1625,7 @@ class P {
|
|
|
1604
1625
|
async setIcon(e) {
|
|
1605
1626
|
return s("plugin:window|set_icon", {
|
|
1606
1627
|
label: this.label,
|
|
1607
|
-
value:
|
|
1628
|
+
value: P(e)
|
|
1608
1629
|
});
|
|
1609
1630
|
}
|
|
1610
1631
|
/**
|
|
@@ -1722,7 +1743,7 @@ class P {
|
|
|
1722
1743
|
async setCursorPosition(e) {
|
|
1723
1744
|
return s("plugin:window|set_cursor_position", {
|
|
1724
1745
|
label: this.label,
|
|
1725
|
-
value: e instanceof
|
|
1746
|
+
value: e instanceof _ ? e : new _(e)
|
|
1726
1747
|
});
|
|
1727
1748
|
}
|
|
1728
1749
|
/**
|
|
@@ -1839,7 +1860,7 @@ class P {
|
|
|
1839
1860
|
async setOverlayIcon(e) {
|
|
1840
1861
|
return s("plugin:window|set_overlay_icon", {
|
|
1841
1862
|
label: this.label,
|
|
1842
|
-
value: e ?
|
|
1863
|
+
value: e ? P(e) : void 0
|
|
1843
1864
|
});
|
|
1844
1865
|
}
|
|
1845
1866
|
/**
|
|
@@ -1929,7 +1950,7 @@ class P {
|
|
|
1929
1950
|
*/
|
|
1930
1951
|
async onResized(e) {
|
|
1931
1952
|
return this.listen(o.WINDOW_RESIZED, (i) => {
|
|
1932
|
-
i.payload = new
|
|
1953
|
+
i.payload = new y(i.payload), e(i);
|
|
1933
1954
|
});
|
|
1934
1955
|
}
|
|
1935
1956
|
/**
|
|
@@ -1978,7 +1999,7 @@ class P {
|
|
|
1978
1999
|
*/
|
|
1979
2000
|
async onCloseRequested(e) {
|
|
1980
2001
|
return this.listen(o.WINDOW_CLOSE_REQUESTED, async (i) => {
|
|
1981
|
-
const n = new
|
|
2002
|
+
const n = new Me(i);
|
|
1982
2003
|
await e(n), n.isPreventDefault() || await this.destroy();
|
|
1983
2004
|
});
|
|
1984
2005
|
}
|
|
@@ -2008,37 +2029,37 @@ class P {
|
|
|
2008
2029
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2009
2030
|
*/
|
|
2010
2031
|
async onDragDropEvent(e) {
|
|
2011
|
-
const i = await this.listen(o.DRAG_ENTER, (
|
|
2032
|
+
const i = await this.listen(o.DRAG_ENTER, (r) => {
|
|
2012
2033
|
e({
|
|
2013
|
-
...
|
|
2034
|
+
...r,
|
|
2014
2035
|
payload: {
|
|
2015
2036
|
type: "enter",
|
|
2016
|
-
paths:
|
|
2017
|
-
position: new c(
|
|
2037
|
+
paths: r.payload.paths,
|
|
2038
|
+
position: new c(r.payload.position)
|
|
2018
2039
|
}
|
|
2019
2040
|
});
|
|
2020
|
-
}), n = await this.listen(o.DRAG_OVER, (
|
|
2041
|
+
}), n = await this.listen(o.DRAG_OVER, (r) => {
|
|
2021
2042
|
e({
|
|
2022
|
-
...
|
|
2043
|
+
...r,
|
|
2023
2044
|
payload: {
|
|
2024
2045
|
type: "over",
|
|
2025
|
-
position: new c(
|
|
2046
|
+
position: new c(r.payload.position)
|
|
2026
2047
|
}
|
|
2027
2048
|
});
|
|
2028
|
-
}), a = await this.listen(o.DRAG_DROP, (
|
|
2049
|
+
}), a = await this.listen(o.DRAG_DROP, (r) => {
|
|
2029
2050
|
e({
|
|
2030
|
-
...
|
|
2051
|
+
...r,
|
|
2031
2052
|
payload: {
|
|
2032
2053
|
type: "drop",
|
|
2033
|
-
paths:
|
|
2034
|
-
position: new c(
|
|
2054
|
+
paths: r.payload.paths,
|
|
2055
|
+
position: new c(r.payload.position)
|
|
2035
2056
|
}
|
|
2036
2057
|
});
|
|
2037
|
-
}),
|
|
2038
|
-
e({ ...
|
|
2058
|
+
}), l = await this.listen(o.DRAG_LEAVE, (r) => {
|
|
2059
|
+
e({ ...r, payload: { type: "leave" } });
|
|
2039
2060
|
});
|
|
2040
2061
|
return () => {
|
|
2041
|
-
i(), a(), n(),
|
|
2062
|
+
i(), a(), n(), l();
|
|
2042
2063
|
};
|
|
2043
2064
|
}
|
|
2044
2065
|
/**
|
|
@@ -2113,45 +2134,45 @@ class P {
|
|
|
2113
2134
|
return this.listen(o.WINDOW_THEME_CHANGED, e);
|
|
2114
2135
|
}
|
|
2115
2136
|
}
|
|
2116
|
-
var
|
|
2137
|
+
var V;
|
|
2117
2138
|
(function(t) {
|
|
2118
2139
|
t.Disabled = "disabled", t.Throttle = "throttle", t.Suspend = "suspend";
|
|
2119
|
-
})(
|
|
2120
|
-
var
|
|
2140
|
+
})(V || (V = {}));
|
|
2141
|
+
var j;
|
|
2121
2142
|
(function(t) {
|
|
2122
2143
|
t.Default = "default", t.FluentOverlay = "fluentOverlay";
|
|
2123
|
-
})(
|
|
2124
|
-
var
|
|
2144
|
+
})(j || (j = {}));
|
|
2145
|
+
var $;
|
|
2125
2146
|
(function(t) {
|
|
2126
2147
|
t.AppearanceBased = "appearanceBased", t.Light = "light", t.Dark = "dark", t.MediumLight = "mediumLight", t.UltraDark = "ultraDark", t.Titlebar = "titlebar", t.Selection = "selection", t.Menu = "menu", t.Popover = "popover", t.Sidebar = "sidebar", t.HeaderView = "headerView", t.Sheet = "sheet", t.WindowBackground = "windowBackground", t.HudWindow = "hudWindow", t.FullScreenUI = "fullScreenUI", t.Tooltip = "tooltip", t.ContentBackground = "contentBackground", t.UnderWindowBackground = "underWindowBackground", t.UnderPageBackground = "underPageBackground", t.Mica = "mica", t.Blur = "blur", t.Acrylic = "acrylic", t.Tabbed = "tabbed", t.TabbedDark = "tabbedDark", t.TabbedLight = "tabbedLight";
|
|
2127
|
-
})(
|
|
2128
|
-
var
|
|
2148
|
+
})($ || ($ = {}));
|
|
2149
|
+
var J;
|
|
2129
2150
|
(function(t) {
|
|
2130
2151
|
t.FollowsWindowActiveState = "followsWindowActiveState", t.Active = "active", t.Inactive = "inactive";
|
|
2131
|
-
})(
|
|
2132
|
-
function
|
|
2152
|
+
})(J || (J = {}));
|
|
2153
|
+
function Ie(t) {
|
|
2133
2154
|
return t === null ? null : {
|
|
2134
2155
|
name: t.name,
|
|
2135
2156
|
scaleFactor: t.scaleFactor,
|
|
2136
2157
|
position: new c(t.position),
|
|
2137
|
-
size: new
|
|
2158
|
+
size: new y(t.size),
|
|
2138
2159
|
workArea: {
|
|
2139
2160
|
position: new c(t.workArea.position),
|
|
2140
|
-
size: new
|
|
2161
|
+
size: new y(t.workArea.size)
|
|
2141
2162
|
}
|
|
2142
2163
|
};
|
|
2143
2164
|
}
|
|
2144
|
-
async function
|
|
2145
|
-
return s("plugin:window|primary_monitor").then(
|
|
2165
|
+
async function ke() {
|
|
2166
|
+
return s("plugin:window|primary_monitor").then(Ie);
|
|
2146
2167
|
}
|
|
2147
|
-
function
|
|
2148
|
-
return new
|
|
2168
|
+
function ue() {
|
|
2169
|
+
return new B(oe(), window.__TAURI_INTERNALS__.metadata.currentWebview.label, {
|
|
2149
2170
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
2150
2171
|
skip: !0
|
|
2151
2172
|
});
|
|
2152
2173
|
}
|
|
2153
|
-
async function
|
|
2154
|
-
return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new
|
|
2174
|
+
async function Z() {
|
|
2175
|
+
return s("plugin:webview|get_all_webviews").then((t) => t.map((e) => new B(new k(e.windowLabel, {
|
|
2155
2176
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
2156
2177
|
skip: !0
|
|
2157
2178
|
}), e.label, {
|
|
@@ -2159,8 +2180,8 @@ async function $() {
|
|
|
2159
2180
|
skip: !0
|
|
2160
2181
|
})));
|
|
2161
2182
|
}
|
|
2162
|
-
const
|
|
2163
|
-
class
|
|
2183
|
+
const T = ["tauri://created", "tauri://error"];
|
|
2184
|
+
class B {
|
|
2164
2185
|
/**
|
|
2165
2186
|
* Creates a new Webview.
|
|
2166
2187
|
* @example
|
|
@@ -2215,19 +2236,19 @@ class T {
|
|
|
2215
2236
|
*/
|
|
2216
2237
|
static async getByLabel(e) {
|
|
2217
2238
|
var i;
|
|
2218
|
-
return (i = (await
|
|
2239
|
+
return (i = (await Z()).find((n) => n.label === e)) !== null && i !== void 0 ? i : null;
|
|
2219
2240
|
}
|
|
2220
2241
|
/**
|
|
2221
2242
|
* Get an instance of `Webview` for the current webview.
|
|
2222
2243
|
*/
|
|
2223
2244
|
static getCurrent() {
|
|
2224
|
-
return
|
|
2245
|
+
return ue();
|
|
2225
2246
|
}
|
|
2226
2247
|
/**
|
|
2227
2248
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
2228
2249
|
*/
|
|
2229
2250
|
static async getAll() {
|
|
2230
|
-
return
|
|
2251
|
+
return Z();
|
|
2231
2252
|
}
|
|
2232
2253
|
/**
|
|
2233
2254
|
* Listen to an emitted event on this webview.
|
|
@@ -2252,7 +2273,7 @@ class T {
|
|
|
2252
2273
|
return this._handleTauriEvent(e, i) ? () => {
|
|
2253
2274
|
const n = this.listeners[e];
|
|
2254
2275
|
n.splice(n.indexOf(i), 1);
|
|
2255
|
-
} :
|
|
2276
|
+
} : I(e, i, {
|
|
2256
2277
|
target: { kind: "Webview", label: this.label }
|
|
2257
2278
|
});
|
|
2258
2279
|
}
|
|
@@ -2279,7 +2300,7 @@ class T {
|
|
|
2279
2300
|
return this._handleTauriEvent(e, i) ? () => {
|
|
2280
2301
|
const n = this.listeners[e];
|
|
2281
2302
|
n.splice(n.indexOf(i), 1);
|
|
2282
|
-
} :
|
|
2303
|
+
} : F(e, i, {
|
|
2283
2304
|
target: { kind: "Webview", label: this.label }
|
|
2284
2305
|
});
|
|
2285
2306
|
}
|
|
@@ -2296,7 +2317,7 @@ class T {
|
|
|
2296
2317
|
* @param payload Event payload.
|
|
2297
2318
|
*/
|
|
2298
2319
|
async emit(e, i) {
|
|
2299
|
-
if (
|
|
2320
|
+
if (T.includes(e)) {
|
|
2300
2321
|
for (const n of this.listeners[e] || [])
|
|
2301
2322
|
n({
|
|
2302
2323
|
event: e,
|
|
@@ -2305,7 +2326,7 @@ class T {
|
|
|
2305
2326
|
});
|
|
2306
2327
|
return;
|
|
2307
2328
|
}
|
|
2308
|
-
return
|
|
2329
|
+
return re(e, i);
|
|
2309
2330
|
}
|
|
2310
2331
|
/**
|
|
2311
2332
|
* Emits an event to all {@link EventTarget|targets} matching the given target.
|
|
@@ -2321,7 +2342,7 @@ class T {
|
|
|
2321
2342
|
* @param payload Event payload.
|
|
2322
2343
|
*/
|
|
2323
2344
|
async emitTo(e, i, n) {
|
|
2324
|
-
if (
|
|
2345
|
+
if (T.includes(i)) {
|
|
2325
2346
|
for (const a of this.listeners[i] || [])
|
|
2326
2347
|
a({
|
|
2327
2348
|
event: i,
|
|
@@ -2330,11 +2351,11 @@ class T {
|
|
|
2330
2351
|
});
|
|
2331
2352
|
return;
|
|
2332
2353
|
}
|
|
2333
|
-
return
|
|
2354
|
+
return le(e, i, n);
|
|
2334
2355
|
}
|
|
2335
2356
|
/** @ignore */
|
|
2336
2357
|
_handleTauriEvent(e, i) {
|
|
2337
|
-
return
|
|
2358
|
+
return T.includes(e) ? (e in this.listeners ? this.listeners[e].push(i) : this.listeners[e] = [i], !0) : !1;
|
|
2338
2359
|
}
|
|
2339
2360
|
// Getters
|
|
2340
2361
|
/**
|
|
@@ -2366,7 +2387,7 @@ class T {
|
|
|
2366
2387
|
async size() {
|
|
2367
2388
|
return s("plugin:webview|webview_size", {
|
|
2368
2389
|
label: this.label
|
|
2369
|
-
}).then((e) => new
|
|
2390
|
+
}).then((e) => new y(e));
|
|
2370
2391
|
}
|
|
2371
2392
|
// Setters
|
|
2372
2393
|
/**
|
|
@@ -2415,7 +2436,7 @@ class T {
|
|
|
2415
2436
|
async setPosition(e) {
|
|
2416
2437
|
return s("plugin:webview|set_webview_position", {
|
|
2417
2438
|
label: this.label,
|
|
2418
|
-
value: e instanceof
|
|
2439
|
+
value: e instanceof _ ? e : new _(e)
|
|
2419
2440
|
});
|
|
2420
2441
|
}
|
|
2421
2442
|
/**
|
|
@@ -2571,51 +2592,51 @@ class T {
|
|
|
2571
2592
|
* Note that removing the listener is required if your listener goes out of scope e.g. the component is unmounted.
|
|
2572
2593
|
*/
|
|
2573
2594
|
async onDragDropEvent(e) {
|
|
2574
|
-
const i = await this.listen(o.DRAG_ENTER, (
|
|
2595
|
+
const i = await this.listen(o.DRAG_ENTER, (r) => {
|
|
2575
2596
|
e({
|
|
2576
|
-
...
|
|
2597
|
+
...r,
|
|
2577
2598
|
payload: {
|
|
2578
2599
|
type: "enter",
|
|
2579
|
-
paths:
|
|
2580
|
-
position: new c(
|
|
2600
|
+
paths: r.payload.paths,
|
|
2601
|
+
position: new c(r.payload.position)
|
|
2581
2602
|
}
|
|
2582
2603
|
});
|
|
2583
|
-
}), n = await this.listen(o.DRAG_OVER, (
|
|
2604
|
+
}), n = await this.listen(o.DRAG_OVER, (r) => {
|
|
2584
2605
|
e({
|
|
2585
|
-
...
|
|
2606
|
+
...r,
|
|
2586
2607
|
payload: {
|
|
2587
2608
|
type: "over",
|
|
2588
|
-
position: new c(
|
|
2609
|
+
position: new c(r.payload.position)
|
|
2589
2610
|
}
|
|
2590
2611
|
});
|
|
2591
|
-
}), a = await this.listen(o.DRAG_DROP, (
|
|
2612
|
+
}), a = await this.listen(o.DRAG_DROP, (r) => {
|
|
2592
2613
|
e({
|
|
2593
|
-
...
|
|
2614
|
+
...r,
|
|
2594
2615
|
payload: {
|
|
2595
2616
|
type: "drop",
|
|
2596
|
-
paths:
|
|
2597
|
-
position: new c(
|
|
2617
|
+
paths: r.payload.paths,
|
|
2618
|
+
position: new c(r.payload.position)
|
|
2598
2619
|
}
|
|
2599
2620
|
});
|
|
2600
|
-
}),
|
|
2601
|
-
e({ ...
|
|
2621
|
+
}), l = await this.listen(o.DRAG_LEAVE, (r) => {
|
|
2622
|
+
e({ ...r, payload: { type: "leave" } });
|
|
2602
2623
|
});
|
|
2603
2624
|
return () => {
|
|
2604
|
-
i(), a(), n(),
|
|
2625
|
+
i(), a(), n(), l();
|
|
2605
2626
|
};
|
|
2606
2627
|
}
|
|
2607
2628
|
}
|
|
2608
|
-
function
|
|
2609
|
-
const t =
|
|
2610
|
-
return new
|
|
2629
|
+
function x() {
|
|
2630
|
+
const t = ue();
|
|
2631
|
+
return new f(t.label, { skip: !0 });
|
|
2611
2632
|
}
|
|
2612
|
-
async function
|
|
2613
|
-
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new
|
|
2633
|
+
async function Y() {
|
|
2634
|
+
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new f(e, {
|
|
2614
2635
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
2615
2636
|
skip: !0
|
|
2616
2637
|
})));
|
|
2617
2638
|
}
|
|
2618
|
-
class
|
|
2639
|
+
class f {
|
|
2619
2640
|
/**
|
|
2620
2641
|
* Creates a new {@link Window} hosting a {@link Webview}.
|
|
2621
2642
|
* @example
|
|
@@ -2658,20 +2679,20 @@ class _ {
|
|
|
2658
2679
|
*/
|
|
2659
2680
|
static async getByLabel(e) {
|
|
2660
2681
|
var i;
|
|
2661
|
-
const n = (i = (await
|
|
2662
|
-
return n ? new
|
|
2682
|
+
const n = (i = (await Y()).find((a) => a.label === e)) !== null && i !== void 0 ? i : null;
|
|
2683
|
+
return n ? new f(n.label, { skip: !0 }) : null;
|
|
2663
2684
|
}
|
|
2664
2685
|
/**
|
|
2665
2686
|
* Get an instance of `Webview` for the current webview.
|
|
2666
2687
|
*/
|
|
2667
2688
|
static getCurrent() {
|
|
2668
|
-
return
|
|
2689
|
+
return x();
|
|
2669
2690
|
}
|
|
2670
2691
|
/**
|
|
2671
2692
|
* Gets a list of instances of `Webview` for all available webviews.
|
|
2672
2693
|
*/
|
|
2673
2694
|
static async getAll() {
|
|
2674
|
-
return
|
|
2695
|
+
return Y();
|
|
2675
2696
|
}
|
|
2676
2697
|
/**
|
|
2677
2698
|
* Listen to an emitted event on this webivew window.
|
|
@@ -2696,7 +2717,7 @@ class _ {
|
|
|
2696
2717
|
return this._handleTauriEvent(e, i) ? () => {
|
|
2697
2718
|
const n = this.listeners[e];
|
|
2698
2719
|
n.splice(n.indexOf(i), 1);
|
|
2699
|
-
} :
|
|
2720
|
+
} : I(e, i, {
|
|
2700
2721
|
target: { kind: "WebviewWindow", label: this.label }
|
|
2701
2722
|
});
|
|
2702
2723
|
}
|
|
@@ -2723,7 +2744,7 @@ class _ {
|
|
|
2723
2744
|
return this._handleTauriEvent(e, i) ? () => {
|
|
2724
2745
|
const n = this.listeners[e];
|
|
2725
2746
|
n.splice(n.indexOf(i), 1);
|
|
2726
|
-
} :
|
|
2747
|
+
} : F(e, i, {
|
|
2727
2748
|
target: { kind: "WebviewWindow", label: this.label }
|
|
2728
2749
|
});
|
|
2729
2750
|
}
|
|
@@ -2747,8 +2768,8 @@ class _ {
|
|
|
2747
2768
|
return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
|
|
2748
2769
|
}
|
|
2749
2770
|
}
|
|
2750
|
-
|
|
2751
|
-
function
|
|
2771
|
+
Ce(f, [k, B]);
|
|
2772
|
+
function Ce(t, e) {
|
|
2752
2773
|
(Array.isArray(e) ? e : [e]).forEach((i) => {
|
|
2753
2774
|
Object.getOwnPropertyNames(i.prototype).forEach((n) => {
|
|
2754
2775
|
var a;
|
|
@@ -2761,21 +2782,21 @@ function ke(t, e) {
|
|
|
2761
2782
|
});
|
|
2762
2783
|
});
|
|
2763
2784
|
}
|
|
2764
|
-
const
|
|
2785
|
+
const A = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
2765
2786
|
if (!t || t.trim() === "") return !1;
|
|
2766
2787
|
try {
|
|
2767
2788
|
return !!(t.startsWith("/") || t.startsWith("http://") || t.startsWith("https://") || t.startsWith("tauri://"));
|
|
2768
2789
|
} catch {
|
|
2769
2790
|
return !1;
|
|
2770
2791
|
}
|
|
2771
|
-
},
|
|
2792
|
+
}, Ee = async (t, e, i) => {
|
|
2772
2793
|
const n = i?.padding ?? 20;
|
|
2773
2794
|
if (i?.x !== void 0 && i?.y !== void 0)
|
|
2774
2795
|
return { x: i.x, y: i.y };
|
|
2775
|
-
let a = 1920,
|
|
2796
|
+
let a = 1920, l = 1080;
|
|
2776
2797
|
try {
|
|
2777
|
-
const u = await
|
|
2778
|
-
u?.size && (a = u.size.width,
|
|
2798
|
+
const u = await ke();
|
|
2799
|
+
u?.size && (a = u.size.width, l = u.size.height);
|
|
2779
2800
|
} catch (u) {
|
|
2780
2801
|
console.warn("Failed to get monitor info, using defaults:", u);
|
|
2781
2802
|
}
|
|
@@ -2783,7 +2804,7 @@ const S = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2783
2804
|
case "right-bottom":
|
|
2784
2805
|
return {
|
|
2785
2806
|
x: a - t - n,
|
|
2786
|
-
y:
|
|
2807
|
+
y: l - e - n
|
|
2787
2808
|
};
|
|
2788
2809
|
case "right-top":
|
|
2789
2810
|
return {
|
|
@@ -2793,7 +2814,7 @@ const S = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2793
2814
|
case "left-bottom":
|
|
2794
2815
|
return {
|
|
2795
2816
|
x: n,
|
|
2796
|
-
y:
|
|
2817
|
+
y: l - e - n
|
|
2797
2818
|
};
|
|
2798
2819
|
case "left-top":
|
|
2799
2820
|
return {
|
|
@@ -2803,160 +2824,178 @@ const S = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2803
2824
|
case "center":
|
|
2804
2825
|
return {
|
|
2805
2826
|
x: (a - t) / 2,
|
|
2806
|
-
y: (
|
|
2827
|
+
y: (l - e) / 2
|
|
2807
2828
|
};
|
|
2808
2829
|
default:
|
|
2809
2830
|
return {
|
|
2810
2831
|
x: a - t - n,
|
|
2811
|
-
y:
|
|
2832
|
+
y: l - e - n
|
|
2812
2833
|
};
|
|
2813
2834
|
}
|
|
2814
|
-
},
|
|
2815
|
-
const e = String(t.id), i =
|
|
2835
|
+
}, Re = async (t) => {
|
|
2836
|
+
const e = String(t.id), i = w.getState();
|
|
2816
2837
|
if (i.isWindowActive(e)) {
|
|
2817
2838
|
console.log(`Notice window already open for message: ${e}`);
|
|
2818
2839
|
return;
|
|
2819
2840
|
}
|
|
2820
|
-
const n =
|
|
2821
|
-
let
|
|
2822
|
-
Le(
|
|
2823
|
-
const
|
|
2841
|
+
const n = ee(), a = `notice-${e}`;
|
|
2842
|
+
let l = `${n.routePrefix}/${t.type}?id=${t.id}`;
|
|
2843
|
+
Le(l) || (console.warn(`Invalid window URL: ${l}. Using fallback 404 page.`), l = n.notFoundUrl || "/404");
|
|
2844
|
+
const r = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, { x: m, y: v } = await Ee(r, u, t.windowPosition);
|
|
2824
2845
|
try {
|
|
2825
|
-
const
|
|
2826
|
-
url:
|
|
2846
|
+
const b = new f(a, {
|
|
2847
|
+
url: l,
|
|
2827
2848
|
title: t.title,
|
|
2828
|
-
width:
|
|
2849
|
+
width: r,
|
|
2829
2850
|
height: u,
|
|
2830
|
-
x:
|
|
2831
|
-
y:
|
|
2851
|
+
x: m,
|
|
2852
|
+
y: v,
|
|
2832
2853
|
resizable: !0,
|
|
2833
2854
|
decorations: !0,
|
|
2834
2855
|
skipTaskbar: !1,
|
|
2835
2856
|
alwaysOnTop: !0
|
|
2836
2857
|
});
|
|
2837
|
-
|
|
2838
|
-
|
|
2858
|
+
A.set(e, b), i.addActiveWindow(e), b.once("tauri://destroyed", async () => {
|
|
2859
|
+
A.delete(e), i.removeActiveWindow(e), await i.markMessageAsShown(e), i.clearCurrent();
|
|
2839
2860
|
}), console.log(`Created notice window: ${a}`);
|
|
2840
|
-
} catch (
|
|
2841
|
-
console.error("Failed to create notice window:",
|
|
2861
|
+
} catch (b) {
|
|
2862
|
+
console.error("Failed to create notice window:", b), i.removeActiveWindow(e), i.clearCurrent();
|
|
2842
2863
|
}
|
|
2843
|
-
},
|
|
2844
|
-
const e = String(t), i =
|
|
2864
|
+
}, U = async (t) => {
|
|
2865
|
+
const e = String(t), i = A.get(e), n = w.getState();
|
|
2845
2866
|
if (i)
|
|
2846
2867
|
try {
|
|
2847
|
-
await i.close(),
|
|
2868
|
+
await i.close(), A.delete(e), n.removeActiveWindow(e), await n.markMessageAsShown(e), n.clearCurrent(), console.log(`Closed notice window: ${e}`);
|
|
2848
2869
|
} catch (a) {
|
|
2849
2870
|
console.error("Failed to close notice window:", a);
|
|
2850
2871
|
}
|
|
2851
|
-
},
|
|
2852
|
-
const t = Array.from(
|
|
2853
|
-
(e) =>
|
|
2872
|
+
}, Te = async () => {
|
|
2873
|
+
const t = Array.from(A.keys()).map(
|
|
2874
|
+
(e) => U(e)
|
|
2854
2875
|
);
|
|
2855
2876
|
await Promise.all(t);
|
|
2856
|
-
},
|
|
2877
|
+
}, qe = () => {
|
|
2857
2878
|
let t = null;
|
|
2858
|
-
|
|
2879
|
+
w.subscribe((e) => {
|
|
2859
2880
|
const i = e.currentMessage;
|
|
2860
|
-
i && i !== t ? (t = i,
|
|
2881
|
+
i && i !== t ? (t = i, Re(i)) : i || (t = null);
|
|
2861
2882
|
}), console.log("Notice window system initialized");
|
|
2862
|
-
}, Qe = () => {
|
|
2863
|
-
const t = d((i) => i.currentMessage);
|
|
2864
|
-
return { closeNotice: A(async () => {
|
|
2865
|
-
t && await q(t.id);
|
|
2866
|
-
}, [t]) };
|
|
2867
2883
|
}, je = () => {
|
|
2868
|
-
const t =
|
|
2869
|
-
return {
|
|
2884
|
+
const t = w((i) => i.currentMessage);
|
|
2885
|
+
return { closeNotice: M(async () => {
|
|
2886
|
+
t && await U(t.id);
|
|
2887
|
+
}, [t]) };
|
|
2888
|
+
}, $e = () => {
|
|
2889
|
+
const t = w((i) => i.hideMessage);
|
|
2890
|
+
return { hideNotice: M(
|
|
2870
2891
|
async (i) => {
|
|
2871
|
-
await
|
|
2892
|
+
await t(i), await U(i);
|
|
2872
2893
|
},
|
|
2873
2894
|
[t]
|
|
2874
2895
|
) };
|
|
2875
|
-
}, $e = () => {
|
|
2876
|
-
const t = d((i) => i.clearOnLogout);
|
|
2877
|
-
return { hideAllNotices: A(async () => {
|
|
2878
|
-
await Re(), await t();
|
|
2879
|
-
}, [t]) };
|
|
2880
2896
|
}, Je = () => {
|
|
2881
|
-
const t =
|
|
2897
|
+
const t = w((i) => i.clearOnLogout);
|
|
2898
|
+
return { hideAllNotices: M(async () => {
|
|
2899
|
+
await Te(), await t();
|
|
2900
|
+
}, [t]) };
|
|
2901
|
+
}, Ze = () => {
|
|
2902
|
+
const t = w(z.queueLength), e = w(z.currentMessage), i = w(z.isProcessing), n = w(z.queue);
|
|
2882
2903
|
return {
|
|
2883
2904
|
queueLength: t,
|
|
2884
2905
|
currentMessage: e,
|
|
2885
2906
|
isProcessing: i,
|
|
2886
2907
|
queue: n
|
|
2887
2908
|
};
|
|
2888
|
-
},
|
|
2889
|
-
const [n, a] =
|
|
2890
|
-
return
|
|
2909
|
+
}, Ye = ({ children: t, onLoad: e, onClose: i }) => {
|
|
2910
|
+
const [n, a] = L(null), [l, r] = L(!0), [u, m] = L(null);
|
|
2911
|
+
return G(() => {
|
|
2891
2912
|
(async () => {
|
|
2892
2913
|
try {
|
|
2893
|
-
const
|
|
2894
|
-
if (!
|
|
2895
|
-
|
|
2914
|
+
const p = new URLSearchParams(window.location.search).get("id");
|
|
2915
|
+
if (!p) {
|
|
2916
|
+
m("No message ID provided"), r(!1), setTimeout(async () => {
|
|
2917
|
+
try {
|
|
2918
|
+
await x().close();
|
|
2919
|
+
} catch (W) {
|
|
2920
|
+
console.error("Failed to close window:", W);
|
|
2921
|
+
}
|
|
2922
|
+
}, 1e3);
|
|
2896
2923
|
return;
|
|
2897
2924
|
}
|
|
2898
|
-
const
|
|
2899
|
-
if (!
|
|
2900
|
-
|
|
2925
|
+
const C = await ie(p);
|
|
2926
|
+
if (!C) {
|
|
2927
|
+
console.log(`Message ${p} not found in database, closing window`), m("Message not found"), r(!1), setTimeout(async () => {
|
|
2928
|
+
try {
|
|
2929
|
+
await x().close();
|
|
2930
|
+
} catch (W) {
|
|
2931
|
+
console.error("Failed to close window:", W);
|
|
2932
|
+
}
|
|
2933
|
+
}, 500);
|
|
2901
2934
|
return;
|
|
2902
2935
|
}
|
|
2903
|
-
a(
|
|
2904
|
-
} catch (
|
|
2905
|
-
console.error("Failed to load message:",
|
|
2936
|
+
a(C), r(!1), e && e(C);
|
|
2937
|
+
} catch (b) {
|
|
2938
|
+
console.error("Failed to load message:", b), m("Failed to load message"), r(!1), setTimeout(async () => {
|
|
2939
|
+
try {
|
|
2940
|
+
await x().close();
|
|
2941
|
+
} catch (p) {
|
|
2942
|
+
console.error("Failed to close window:", p);
|
|
2943
|
+
}
|
|
2944
|
+
}, 1e3);
|
|
2906
2945
|
}
|
|
2907
2946
|
})();
|
|
2908
|
-
}, [e]),
|
|
2947
|
+
}, [e]), G(() => {
|
|
2909
2948
|
if (!n || !i) return;
|
|
2910
|
-
const
|
|
2949
|
+
const v = () => {
|
|
2911
2950
|
i(n);
|
|
2912
2951
|
};
|
|
2913
|
-
return window.addEventListener("beforeunload",
|
|
2914
|
-
window.removeEventListener("beforeunload",
|
|
2952
|
+
return window.addEventListener("beforeunload", v), () => {
|
|
2953
|
+
window.removeEventListener("beforeunload", v);
|
|
2915
2954
|
};
|
|
2916
|
-
}, [n, i]),
|
|
2955
|
+
}, [n, i]), l ? /* @__PURE__ */ N("div", { style: {
|
|
2917
2956
|
display: "flex",
|
|
2918
2957
|
justifyContent: "center",
|
|
2919
2958
|
alignItems: "center",
|
|
2920
2959
|
height: "100vh",
|
|
2921
2960
|
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
2922
|
-
}, children: "Loading..." }) : u
|
|
2961
|
+
}, children: "Loading..." }) : u ? /* @__PURE__ */ N("div", { style: {
|
|
2962
|
+
display: "flex",
|
|
2963
|
+
justifyContent: "center",
|
|
2964
|
+
alignItems: "center",
|
|
2965
|
+
height: "100vh",
|
|
2966
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
2967
|
+
color: "#ef4444"
|
|
2968
|
+
}, children: u }) : n ? /* @__PURE__ */ N(he, { children: t(n) }) : /* @__PURE__ */ N("div", { style: {
|
|
2923
2969
|
display: "flex",
|
|
2924
2970
|
justifyContent: "center",
|
|
2925
2971
|
alignItems: "center",
|
|
2926
2972
|
height: "100vh",
|
|
2927
2973
|
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
2928
2974
|
color: "#ef4444"
|
|
2929
|
-
}, children:
|
|
2930
|
-
},
|
|
2931
|
-
|
|
2932
|
-
const { initializeFromDatabase: t } =
|
|
2975
|
+
}, children: "Closing window..." });
|
|
2976
|
+
}, Ke = async () => {
|
|
2977
|
+
te(), qe();
|
|
2978
|
+
const { initializeFromDatabase: t } = w.getState();
|
|
2933
2979
|
await t(), console.log("Tauri Notice System initialized");
|
|
2934
2980
|
};
|
|
2935
2981
|
export {
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
|
|
2944
|
-
|
|
2945
|
-
|
|
2946
|
-
|
|
2947
|
-
|
|
2948
|
-
|
|
2949
|
-
|
|
2950
|
-
|
|
2951
|
-
|
|
2952
|
-
|
|
2953
|
-
ge as saveMessage,
|
|
2954
|
-
Ge as setNoticeConfig,
|
|
2955
|
-
Qe as useCloseNotice,
|
|
2956
|
-
$e as useHideAllNotices,
|
|
2957
|
-
je as useHideNotice,
|
|
2958
|
-
Je as useMessageQueue,
|
|
2959
|
-
d as useMessageQueueStore,
|
|
2982
|
+
Ye as NoticeLayout,
|
|
2983
|
+
Te as closeAllNoticeWindows,
|
|
2984
|
+
U as closeNoticeWindow,
|
|
2985
|
+
Re as createNoticeWindow,
|
|
2986
|
+
ie as getMessage,
|
|
2987
|
+
ee as getNoticeConfig,
|
|
2988
|
+
fe as getPendingMessages,
|
|
2989
|
+
te as initializeDatabase,
|
|
2990
|
+
Ke as initializeNoticeSystem,
|
|
2991
|
+
qe as initializeNoticeWindowSystem,
|
|
2992
|
+
z as messageQueueSelectors,
|
|
2993
|
+
He as setNoticeConfig,
|
|
2994
|
+
je as useCloseNotice,
|
|
2995
|
+
Je as useHideAllNotices,
|
|
2996
|
+
$e as useHideNotice,
|
|
2997
|
+
Ze as useMessageQueue,
|
|
2998
|
+
w as useMessageQueueStore,
|
|
2960
2999
|
Ve as useNoticeWindow
|
|
2961
3000
|
};
|
|
2962
3001
|
//# sourceMappingURL=index.js.map
|