tauri-notice-window 1.0.12 → 1.0.13
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 +27 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -51
- package/dist/index.js.map +1 -1
- package/dist/utils/noticeWindow.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -228,7 +228,7 @@ function Me(t, e, i, n, a) {
|
|
|
228
228
|
return e.set(t, i), i;
|
|
229
229
|
}
|
|
230
230
|
var M;
|
|
231
|
-
const
|
|
231
|
+
const h = "__TAURI_TO_IPC_KEY__";
|
|
232
232
|
function Oe(t, e = !1) {
|
|
233
233
|
return window.__TAURI_INTERNALS__.transformCallback(t, e);
|
|
234
234
|
}
|
|
@@ -273,19 +273,19 @@ class ne {
|
|
|
273
273
|
* @since 2.0.0
|
|
274
274
|
*/
|
|
275
275
|
toPhysical(e) {
|
|
276
|
-
return new
|
|
276
|
+
return new p(this.width * e, this.height * e);
|
|
277
277
|
}
|
|
278
|
-
[
|
|
278
|
+
[h]() {
|
|
279
279
|
return {
|
|
280
280
|
width: this.width,
|
|
281
281
|
height: this.height
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
284
|
toJSON() {
|
|
285
|
-
return this[
|
|
285
|
+
return this[h]();
|
|
286
286
|
}
|
|
287
287
|
}
|
|
288
|
-
class
|
|
288
|
+
class p {
|
|
289
289
|
constructor(...e) {
|
|
290
290
|
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]);
|
|
291
291
|
}
|
|
@@ -303,17 +303,17 @@ class b {
|
|
|
303
303
|
toLogical(e) {
|
|
304
304
|
return new ne(this.width / e, this.height / e);
|
|
305
305
|
}
|
|
306
|
-
[
|
|
306
|
+
[h]() {
|
|
307
307
|
return {
|
|
308
308
|
width: this.width,
|
|
309
309
|
height: this.height
|
|
310
310
|
};
|
|
311
311
|
}
|
|
312
312
|
toJSON() {
|
|
313
|
-
return this[
|
|
313
|
+
return this[h]();
|
|
314
314
|
}
|
|
315
315
|
}
|
|
316
|
-
class
|
|
316
|
+
class b {
|
|
317
317
|
constructor(e) {
|
|
318
318
|
this.size = e;
|
|
319
319
|
}
|
|
@@ -321,9 +321,9 @@ class y {
|
|
|
321
321
|
return this.size instanceof ne ? this.size : this.size.toLogical(e);
|
|
322
322
|
}
|
|
323
323
|
toPhysical(e) {
|
|
324
|
-
return this.size instanceof
|
|
324
|
+
return this.size instanceof p ? this.size : this.size.toPhysical(e);
|
|
325
325
|
}
|
|
326
|
-
[
|
|
326
|
+
[h]() {
|
|
327
327
|
return {
|
|
328
328
|
[`${this.size.type}`]: {
|
|
329
329
|
width: this.size.width,
|
|
@@ -332,7 +332,7 @@ class y {
|
|
|
332
332
|
};
|
|
333
333
|
}
|
|
334
334
|
toJSON() {
|
|
335
|
-
return this[
|
|
335
|
+
return this[h]();
|
|
336
336
|
}
|
|
337
337
|
}
|
|
338
338
|
class se {
|
|
@@ -357,14 +357,14 @@ class se {
|
|
|
357
357
|
toPhysical(e) {
|
|
358
358
|
return new w(this.x * e, this.y * e);
|
|
359
359
|
}
|
|
360
|
-
[
|
|
360
|
+
[h]() {
|
|
361
361
|
return {
|
|
362
362
|
x: this.x,
|
|
363
363
|
y: this.y
|
|
364
364
|
};
|
|
365
365
|
}
|
|
366
366
|
toJSON() {
|
|
367
|
-
return this[
|
|
367
|
+
return this[h]();
|
|
368
368
|
}
|
|
369
369
|
}
|
|
370
370
|
class w {
|
|
@@ -389,17 +389,17 @@ class w {
|
|
|
389
389
|
toLogical(e) {
|
|
390
390
|
return new se(this.x / e, this.y / e);
|
|
391
391
|
}
|
|
392
|
-
[
|
|
392
|
+
[h]() {
|
|
393
393
|
return {
|
|
394
394
|
x: this.x,
|
|
395
395
|
y: this.y
|
|
396
396
|
};
|
|
397
397
|
}
|
|
398
398
|
toJSON() {
|
|
399
|
-
return this[
|
|
399
|
+
return this[h]();
|
|
400
400
|
}
|
|
401
401
|
}
|
|
402
|
-
class
|
|
402
|
+
class _ {
|
|
403
403
|
constructor(e) {
|
|
404
404
|
this.position = e;
|
|
405
405
|
}
|
|
@@ -409,7 +409,7 @@ class p {
|
|
|
409
409
|
toPhysical(e) {
|
|
410
410
|
return this.position instanceof w ? this.position : this.position.toPhysical(e);
|
|
411
411
|
}
|
|
412
|
-
[
|
|
412
|
+
[h]() {
|
|
413
413
|
return {
|
|
414
414
|
[`${this.position.type}`]: {
|
|
415
415
|
x: this.position.x,
|
|
@@ -418,7 +418,7 @@ class p {
|
|
|
418
418
|
};
|
|
419
419
|
}
|
|
420
420
|
toJSON() {
|
|
421
|
-
return this[
|
|
421
|
+
return this[h]();
|
|
422
422
|
}
|
|
423
423
|
}
|
|
424
424
|
var o;
|
|
@@ -790,7 +790,7 @@ class k {
|
|
|
790
790
|
async innerSize() {
|
|
791
791
|
return s("plugin:window|inner_size", {
|
|
792
792
|
label: this.label
|
|
793
|
-
}).then((e) => new
|
|
793
|
+
}).then((e) => new p(e));
|
|
794
794
|
}
|
|
795
795
|
/**
|
|
796
796
|
* The physical size of the entire window.
|
|
@@ -806,7 +806,7 @@ class k {
|
|
|
806
806
|
async outerSize() {
|
|
807
807
|
return s("plugin:window|outer_size", {
|
|
808
808
|
label: this.label
|
|
809
|
-
}).then((e) => new
|
|
809
|
+
}).then((e) => new p(e));
|
|
810
810
|
}
|
|
811
811
|
/**
|
|
812
812
|
* Gets the window's current fullscreen state.
|
|
@@ -1457,7 +1457,7 @@ class k {
|
|
|
1457
1457
|
async setSize(e) {
|
|
1458
1458
|
return s("plugin:window|set_size", {
|
|
1459
1459
|
label: this.label,
|
|
1460
|
-
value: e instanceof
|
|
1460
|
+
value: e instanceof b ? e : new b(e)
|
|
1461
1461
|
});
|
|
1462
1462
|
}
|
|
1463
1463
|
/**
|
|
@@ -1474,7 +1474,7 @@ class k {
|
|
|
1474
1474
|
async setMinSize(e) {
|
|
1475
1475
|
return s("plugin:window|set_min_size", {
|
|
1476
1476
|
label: this.label,
|
|
1477
|
-
value: e instanceof
|
|
1477
|
+
value: e instanceof b ? e : e ? new b(e) : null
|
|
1478
1478
|
});
|
|
1479
1479
|
}
|
|
1480
1480
|
/**
|
|
@@ -1491,7 +1491,7 @@ class k {
|
|
|
1491
1491
|
async setMaxSize(e) {
|
|
1492
1492
|
return s("plugin:window|set_max_size", {
|
|
1493
1493
|
label: this.label,
|
|
1494
|
-
value: e instanceof
|
|
1494
|
+
value: e instanceof b ? e : e ? new b(e) : null
|
|
1495
1495
|
});
|
|
1496
1496
|
}
|
|
1497
1497
|
/**
|
|
@@ -1533,7 +1533,7 @@ class k {
|
|
|
1533
1533
|
async setPosition(e) {
|
|
1534
1534
|
return s("plugin:window|set_position", {
|
|
1535
1535
|
label: this.label,
|
|
1536
|
-
value: e instanceof
|
|
1536
|
+
value: e instanceof _ ? e : new _(e)
|
|
1537
1537
|
});
|
|
1538
1538
|
}
|
|
1539
1539
|
/**
|
|
@@ -1745,7 +1745,7 @@ class k {
|
|
|
1745
1745
|
async setCursorPosition(e) {
|
|
1746
1746
|
return s("plugin:window|set_cursor_position", {
|
|
1747
1747
|
label: this.label,
|
|
1748
|
-
value: e instanceof
|
|
1748
|
+
value: e instanceof _ ? e : new _(e)
|
|
1749
1749
|
});
|
|
1750
1750
|
}
|
|
1751
1751
|
/**
|
|
@@ -1952,7 +1952,7 @@ class k {
|
|
|
1952
1952
|
*/
|
|
1953
1953
|
async onResized(e) {
|
|
1954
1954
|
return this.listen(o.WINDOW_RESIZED, (i) => {
|
|
1955
|
-
i.payload = new
|
|
1955
|
+
i.payload = new p(i.payload), e(i);
|
|
1956
1956
|
});
|
|
1957
1957
|
}
|
|
1958
1958
|
/**
|
|
@@ -2157,10 +2157,10 @@ function Ie(t) {
|
|
|
2157
2157
|
name: t.name,
|
|
2158
2158
|
scaleFactor: t.scaleFactor,
|
|
2159
2159
|
position: new w(t.position),
|
|
2160
|
-
size: new
|
|
2160
|
+
size: new p(t.size),
|
|
2161
2161
|
workArea: {
|
|
2162
2162
|
position: new w(t.workArea.position),
|
|
2163
|
-
size: new
|
|
2163
|
+
size: new p(t.workArea.size)
|
|
2164
2164
|
}
|
|
2165
2165
|
};
|
|
2166
2166
|
}
|
|
@@ -2389,7 +2389,7 @@ class B {
|
|
|
2389
2389
|
async size() {
|
|
2390
2390
|
return s("plugin:webview|webview_size", {
|
|
2391
2391
|
label: this.label
|
|
2392
|
-
}).then((e) => new
|
|
2392
|
+
}).then((e) => new p(e));
|
|
2393
2393
|
}
|
|
2394
2394
|
// Setters
|
|
2395
2395
|
/**
|
|
@@ -2421,7 +2421,7 @@ class B {
|
|
|
2421
2421
|
async setSize(e) {
|
|
2422
2422
|
return s("plugin:webview|set_webview_size", {
|
|
2423
2423
|
label: this.label,
|
|
2424
|
-
value: e instanceof
|
|
2424
|
+
value: e instanceof b ? e : new b(e)
|
|
2425
2425
|
});
|
|
2426
2426
|
}
|
|
2427
2427
|
/**
|
|
@@ -2438,7 +2438,7 @@ class B {
|
|
|
2438
2438
|
async setPosition(e) {
|
|
2439
2439
|
return s("plugin:webview|set_webview_position", {
|
|
2440
2440
|
label: this.label,
|
|
2441
|
-
value: e instanceof
|
|
2441
|
+
value: e instanceof _ ? e : new _(e)
|
|
2442
2442
|
});
|
|
2443
2443
|
}
|
|
2444
2444
|
/**
|
|
@@ -2630,15 +2630,15 @@ class B {
|
|
|
2630
2630
|
}
|
|
2631
2631
|
function O() {
|
|
2632
2632
|
const t = ue();
|
|
2633
|
-
return new
|
|
2633
|
+
return new f(t.label, { skip: !0 });
|
|
2634
2634
|
}
|
|
2635
2635
|
async function Y() {
|
|
2636
|
-
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new
|
|
2636
|
+
return s("plugin:window|get_all_windows").then((t) => t.map((e) => new f(e, {
|
|
2637
2637
|
// @ts-expect-error `skip` is not defined in the public API but it is handled by the constructor
|
|
2638
2638
|
skip: !0
|
|
2639
2639
|
})));
|
|
2640
2640
|
}
|
|
2641
|
-
class
|
|
2641
|
+
class f {
|
|
2642
2642
|
/**
|
|
2643
2643
|
* Creates a new {@link Window} hosting a {@link Webview}.
|
|
2644
2644
|
* @example
|
|
@@ -2682,7 +2682,7 @@ class _ {
|
|
|
2682
2682
|
static async getByLabel(e) {
|
|
2683
2683
|
var i;
|
|
2684
2684
|
const n = (i = (await Y()).find((a) => a.label === e)) !== null && i !== void 0 ? i : null;
|
|
2685
|
-
return n ? new
|
|
2685
|
+
return n ? new f(n.label, { skip: !0 }) : null;
|
|
2686
2686
|
}
|
|
2687
2687
|
/**
|
|
2688
2688
|
* Get an instance of `Webview` for the current webview.
|
|
@@ -2770,7 +2770,7 @@ class _ {
|
|
|
2770
2770
|
return s("plugin:window|set_background_color", { color: e }).then(() => s("plugin:webview|set_webview_background_color", { color: e }));
|
|
2771
2771
|
}
|
|
2772
2772
|
}
|
|
2773
|
-
Ce(
|
|
2773
|
+
Ce(f, [k, B]);
|
|
2774
2774
|
function Ce(t, e) {
|
|
2775
2775
|
(Array.isArray(e) ? e : [e]).forEach((i) => {
|
|
2776
2776
|
Object.getOwnPropertyNames(i.prototype).forEach((n) => {
|
|
@@ -2843,9 +2843,9 @@ const D = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2843
2843
|
const n = ee(), a = `notice-${e}`;
|
|
2844
2844
|
let l = `${n.routePrefix}/${t.type}?id=${t.id}`;
|
|
2845
2845
|
Le(l) || (console.warn(`Invalid window URL: ${l}. Using fallback 404 page.`), l = n.notFoundUrl || "/404");
|
|
2846
|
-
const r = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight,
|
|
2846
|
+
const r = t.min_width || n.defaultWidth, u = t.min_height || n.defaultHeight, y = t.decorations ?? n.defaultDecorations ?? !0, { x: m, y: A } = await Ee(r, u, t.windowPosition);
|
|
2847
2847
|
try {
|
|
2848
|
-
const
|
|
2848
|
+
const d = new f(a, {
|
|
2849
2849
|
url: l,
|
|
2850
2850
|
title: t.title,
|
|
2851
2851
|
width: r,
|
|
@@ -2853,15 +2853,21 @@ const D = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2853
2853
|
x: m,
|
|
2854
2854
|
y: A,
|
|
2855
2855
|
resizable: !0,
|
|
2856
|
-
decorations:
|
|
2856
|
+
decorations: y,
|
|
2857
|
+
transparent: !y,
|
|
2858
|
+
// Enable transparency for borderless windows (macOS fix)
|
|
2859
|
+
visible: y,
|
|
2860
|
+
// Start hidden if no decorations (macOS fix)
|
|
2857
2861
|
skipTaskbar: !1,
|
|
2858
2862
|
alwaysOnTop: !0
|
|
2859
2863
|
});
|
|
2860
|
-
D.set(e,
|
|
2864
|
+
D.set(e, d), i.addActiveWindow(e), y || d.once("tauri://created", async () => {
|
|
2865
|
+
await d.show();
|
|
2866
|
+
}), d.once("tauri://destroyed", async () => {
|
|
2861
2867
|
D.delete(e), i.removeActiveWindow(e), await i.markMessageAsShown(e), i.clearCurrent();
|
|
2862
2868
|
}), console.log(`Created notice window: ${a}`);
|
|
2863
|
-
} catch (
|
|
2864
|
-
console.error("Failed to create notice window:",
|
|
2869
|
+
} catch (d) {
|
|
2870
|
+
console.error("Failed to create notice window:", d), i.removeActiveWindow(e), i.clearCurrent();
|
|
2865
2871
|
}
|
|
2866
2872
|
}, U = async (t) => {
|
|
2867
2873
|
const e = String(t), i = D.get(e), n = c.getState();
|
|
@@ -2909,13 +2915,13 @@ const D = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2909
2915
|
queue: n
|
|
2910
2916
|
};
|
|
2911
2917
|
}, Ye = ({ children: t, onLoad: e, onClose: i }) => {
|
|
2912
|
-
const [n, a] = L(null), [l, r] = L(!0), [u,
|
|
2918
|
+
const [n, a] = L(null), [l, r] = L(!0), [u, y] = L(null);
|
|
2913
2919
|
return G(() => {
|
|
2914
2920
|
(async () => {
|
|
2915
2921
|
try {
|
|
2916
|
-
const
|
|
2917
|
-
if (!
|
|
2918
|
-
|
|
2922
|
+
const d = new URLSearchParams(window.location.search).get("id");
|
|
2923
|
+
if (!d) {
|
|
2924
|
+
y("No message ID provided"), r(!1), setTimeout(async () => {
|
|
2919
2925
|
try {
|
|
2920
2926
|
await O().close();
|
|
2921
2927
|
} catch (v) {
|
|
@@ -2924,9 +2930,9 @@ const D = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2924
2930
|
}, 1e3);
|
|
2925
2931
|
return;
|
|
2926
2932
|
}
|
|
2927
|
-
const C = await ie(
|
|
2933
|
+
const C = await ie(d);
|
|
2928
2934
|
if (!C) {
|
|
2929
|
-
console.log(`Message ${
|
|
2935
|
+
console.log(`Message ${d} not found in database, closing window`), y("Message not found"), r(!1), setTimeout(async () => {
|
|
2930
2936
|
try {
|
|
2931
2937
|
await O().close();
|
|
2932
2938
|
} catch (v) {
|
|
@@ -2937,11 +2943,11 @@ const D = /* @__PURE__ */ new Map(), Le = (t) => {
|
|
|
2937
2943
|
}
|
|
2938
2944
|
a(C), r(!1), e && e(C);
|
|
2939
2945
|
} catch (A) {
|
|
2940
|
-
console.error("Failed to load message:", A),
|
|
2946
|
+
console.error("Failed to load message:", A), y("Failed to load message"), r(!1), setTimeout(async () => {
|
|
2941
2947
|
try {
|
|
2942
2948
|
await O().close();
|
|
2943
|
-
} catch (
|
|
2944
|
-
console.error("Failed to close window:",
|
|
2949
|
+
} catch (d) {
|
|
2950
|
+
console.error("Failed to close window:", d);
|
|
2945
2951
|
}
|
|
2946
2952
|
}, 1e3);
|
|
2947
2953
|
}
|