@seelen-ui/lib 2.5.7 → 2.5.8-next.2604111036
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/esm/gen/types/ClipboardData.d.ts +15 -0
- package/esm/gen/types/ClipboardData.d.ts.map +1 -0
- package/esm/gen/types/ClipboardData.js +1 -0
- package/esm/gen/types/ClipboardEntry.d.ts +24 -0
- package/esm/gen/types/ClipboardEntry.d.ts.map +1 -0
- package/esm/gen/types/ClipboardEntry.js +1 -0
- package/esm/gen/types/ClipboardEntryContent.d.ts +16 -0
- package/esm/gen/types/ClipboardEntryContent.d.ts.map +1 -0
- package/esm/gen/types/ClipboardEntryContent.js +2 -0
- package/esm/gen/types/Resource.d.ts +3 -5
- package/esm/gen/types/Resource.d.ts.map +1 -1
- package/esm/gen/types/ResourceId.d.ts +6 -2
- package/esm/gen/types/ResourceId.d.ts.map +1 -1
- package/esm/gen/types/ResourceMetadata.d.ts +4 -0
- package/esm/gen/types/ResourceMetadata.d.ts.map +1 -1
- package/esm/gen/types/SeelenCommandArgument.d.ts +19 -0
- package/esm/gen/types/SeelenCommandArgument.d.ts.map +1 -1
- package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts +4 -0
- package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts.map +1 -0
- package/esm/gen/types/SeelenCommandClipboardDeleteEntryArgs.js +2 -0
- package/esm/gen/types/SeelenCommandClipboardPasteArgs.d.ts +4 -0
- package/esm/gen/types/SeelenCommandClipboardPasteArgs.d.ts.map +1 -0
- package/esm/gen/types/SeelenCommandClipboardPasteArgs.js +2 -0
- package/esm/gen/types/SeelenCommandClipboardSetContentArgs.d.ts +4 -0
- package/esm/gen/types/SeelenCommandClipboardSetContentArgs.d.ts.map +1 -0
- package/esm/gen/types/SeelenCommandClipboardSetContentArgs.js +2 -0
- package/esm/gen/types/SeelenCommandReturn.d.ts +18 -0
- package/esm/gen/types/SeelenCommandReturn.d.ts.map +1 -1
- package/esm/gen/types/SeelenEventPayload.d.ts +6 -0
- package/esm/gen/types/SeelenEventPayload.d.ts.map +1 -1
- package/esm/gen/types/SeelenSession.d.ts +15 -0
- package/esm/gen/types/SeelenSession.d.ts.map +1 -0
- package/esm/gen/types/SeelenSession.js +2 -0
- package/esm/gen/types/Settings.d.ts +5 -0
- package/esm/gen/types/Settings.d.ts.map +1 -1
- package/esm/gen/types/SluHotkeyAction.d.ts +2 -0
- package/esm/gen/types/SluHotkeyAction.d.ts.map +1 -1
- package/esm/gen/types/Slug.d.ts +9 -0
- package/esm/gen/types/Slug.d.ts.map +1 -0
- package/esm/gen/types/Slug.js +2 -0
- package/esm/gen/types/mod.d.ts +252 -244
- package/esm/gen/types/mod.d.ts.map +1 -1
- package/esm/gen/types/mod.js +252 -244
- package/esm/src/handlers/commands.d.ts +9 -1
- package/esm/src/handlers/commands.d.ts.map +1 -1
- package/esm/src/handlers/commands.js +8 -0
- package/esm/src/handlers/events.d.ts +3 -1
- package/esm/src/handlers/events.d.ts.map +1 -1
- package/esm/src/handlers/events.js +2 -0
- package/esm/src/state/theme/theming.d.ts +1 -0
- package/esm/src/state/theme/theming.d.ts.map +1 -1
- package/esm/src/state/theme/theming.js +21 -1
- package/esm/src/state/widget/interfaces.d.ts +11 -0
- package/esm/src/state/widget/interfaces.d.ts.map +1 -1
- package/esm/src/state/widget/mod.d.ts +9 -6
- package/esm/src/state/widget/mod.d.ts.map +1 -1
- package/esm/src/state/widget/mod.js +62 -79
- package/esm/src/state/widget/sizing.d.ts +14 -3
- package/esm/src/state/widget/sizing.d.ts.map +1 -1
- package/esm/src/state/widget/sizing.js +60 -17
- package/esm/src/utils/async.d.ts +12 -0
- package/esm/src/utils/async.d.ts.map +1 -1
- package/esm/src/utils/async.js +46 -0
- package/esm/src/utils/mod.d.ts +1 -0
- package/esm/src/utils/mod.d.ts.map +1 -1
- package/esm/src/utils/mod.js +4 -0
- package/package.json +1 -1
- package/script/gen/types/ClipboardData.d.ts +15 -0
- package/script/gen/types/ClipboardData.d.ts.map +1 -0
- package/script/gen/types/ClipboardData.js +2 -0
- package/script/gen/types/ClipboardEntry.d.ts +24 -0
- package/script/gen/types/ClipboardEntry.d.ts.map +1 -0
- package/script/gen/types/ClipboardEntry.js +2 -0
- package/script/gen/types/ClipboardEntryContent.d.ts +16 -0
- package/script/gen/types/ClipboardEntryContent.d.ts.map +1 -0
- package/script/gen/types/ClipboardEntryContent.js +3 -0
- package/script/gen/types/Resource.d.ts +3 -5
- package/script/gen/types/Resource.d.ts.map +1 -1
- package/script/gen/types/ResourceId.d.ts +6 -2
- package/script/gen/types/ResourceId.d.ts.map +1 -1
- package/script/gen/types/ResourceMetadata.d.ts +4 -0
- package/script/gen/types/ResourceMetadata.d.ts.map +1 -1
- package/script/gen/types/SeelenCommandArgument.d.ts +19 -0
- package/script/gen/types/SeelenCommandArgument.d.ts.map +1 -1
- package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts +4 -0
- package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.d.ts.map +1 -0
- package/script/gen/types/SeelenCommandClipboardDeleteEntryArgs.js +3 -0
- package/script/gen/types/SeelenCommandClipboardPasteArgs.d.ts +4 -0
- package/script/gen/types/SeelenCommandClipboardPasteArgs.d.ts.map +1 -0
- package/script/gen/types/SeelenCommandClipboardPasteArgs.js +3 -0
- package/script/gen/types/SeelenCommandClipboardSetContentArgs.d.ts +4 -0
- package/script/gen/types/SeelenCommandClipboardSetContentArgs.d.ts.map +1 -0
- package/script/gen/types/SeelenCommandClipboardSetContentArgs.js +3 -0
- package/script/gen/types/SeelenCommandReturn.d.ts +18 -0
- package/script/gen/types/SeelenCommandReturn.d.ts.map +1 -1
- package/script/gen/types/SeelenEventPayload.d.ts +6 -0
- package/script/gen/types/SeelenEventPayload.d.ts.map +1 -1
- package/script/gen/types/SeelenSession.d.ts +15 -0
- package/script/gen/types/SeelenSession.d.ts.map +1 -0
- package/script/gen/types/SeelenSession.js +3 -0
- package/script/gen/types/Settings.d.ts +5 -0
- package/script/gen/types/Settings.d.ts.map +1 -1
- package/script/gen/types/SluHotkeyAction.d.ts +2 -0
- package/script/gen/types/SluHotkeyAction.d.ts.map +1 -1
- package/script/gen/types/Slug.d.ts +9 -0
- package/script/gen/types/Slug.d.ts.map +1 -0
- package/script/gen/types/Slug.js +3 -0
- package/script/gen/types/mod.d.ts +252 -244
- package/script/gen/types/mod.d.ts.map +1 -1
- package/script/gen/types/mod.js +252 -244
- package/script/src/handlers/commands.d.ts +9 -1
- package/script/src/handlers/commands.d.ts.map +1 -1
- package/script/src/handlers/commands.js +8 -0
- package/script/src/handlers/events.d.ts +3 -1
- package/script/src/handlers/events.d.ts.map +1 -1
- package/script/src/handlers/events.js +2 -0
- package/script/src/state/theme/theming.d.ts +1 -0
- package/script/src/state/theme/theming.d.ts.map +1 -1
- package/script/src/state/theme/theming.js +22 -1
- package/script/src/state/widget/interfaces.d.ts +11 -0
- package/script/src/state/widget/interfaces.d.ts.map +1 -1
- package/script/src/state/widget/mod.d.ts +9 -6
- package/script/src/state/widget/mod.d.ts.map +1 -1
- package/script/src/state/widget/mod.js +61 -78
- package/script/src/state/widget/sizing.d.ts +14 -3
- package/script/src/state/widget/sizing.d.ts.map +1 -1
- package/script/src/state/widget/sizing.js +61 -18
- package/script/src/utils/async.d.ts +12 -0
- package/script/src/utils/async.d.ts.map +1 -1
- package/script/src/utils/async.js +49 -0
- package/script/src/utils/mod.d.ts +1 -0
- package/script/src/utils/mod.d.ts.map +1 -1
- package/script/src/utils/mod.js +5 -0
|
@@ -19,6 +19,17 @@ export interface InitWidgetOptions {
|
|
|
19
19
|
* @default undefined
|
|
20
20
|
*/
|
|
21
21
|
autoSizeByContent?: HTMLElement | null;
|
|
22
|
+
/**
|
|
23
|
+
* If autoSizeByContent is set, and this is true, will auto size the widget and
|
|
24
|
+
* adjusts the position to fit on screen
|
|
25
|
+
* @default true
|
|
26
|
+
*/
|
|
27
|
+
autoSizeFitOnScreen?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Will normalize the device pixel ratio to 1:1
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
normalizeDevicePixelRatio?: boolean;
|
|
22
33
|
/**
|
|
23
34
|
* Will save the position and size of the widget on change.
|
|
24
35
|
* This is intedeed to be used when the size and position of the widget is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gEAAgE;IAChE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,EAAE;QAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM;KAAE,CAAC;CAC/C;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
|
|
1
|
+
{"version":3,"file":"interfaces.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/interfaces.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,4BAA4B;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,kEAAkE;IAClE,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gEAAgE;IAChE,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,0CAA0C;IAC1C,MAAM,EAAE;QAAE,QAAQ,EAAE,GAAG,IAAI,MAAM,CAAC,CAAC,EAAE,MAAM;KAAE,CAAC;CAC/C;AAED,MAAM,WAAW,iBAAiB;IAChC;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,WAAW,GAAG,IAAI,CAAC;IACvC;;;;OAIG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;OAMG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;;;OAIG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,WAAW,kBAAkB;IACjC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Frame, type Rect, type ThirdPartyWidgetSettings, type Widget as IWidget, type WidgetId, type WidgetTriggerPayload } from "../../../gen/types/mod.js";
|
|
1
|
+
import { type Alignment, type Frame, type Rect, type ThirdPartyWidgetSettings, type Widget as IWidget, type WidgetId, type WidgetTriggerPayload } from "../../../gen/types/mod.js";
|
|
2
2
|
import type { InitWidgetOptions, ReadyWidgetOptions, WidgetInformation } from "./interfaces.js";
|
|
3
3
|
import { type Webview } from "@tauri-apps/api/webview";
|
|
4
4
|
import { type Window } from "@tauri-apps/api/window";
|
|
@@ -28,11 +28,8 @@ export declare class Widget {
|
|
|
28
28
|
private constructor();
|
|
29
29
|
/** Returns the current window id of the widget */
|
|
30
30
|
get windowId(): number;
|
|
31
|
-
/** Returns the current position and size of the widget */
|
|
32
|
-
get frame(): Frame;
|
|
33
31
|
/** Returns the default config of the widget, declared on the widget definition */
|
|
34
32
|
getDefaultConfig(): ThirdPartyWidgetSettings;
|
|
35
|
-
private applyInvisiblePreset;
|
|
36
33
|
/** Will apply the recommended settings for a desktop widget */
|
|
37
34
|
private applyDesktopPreset;
|
|
38
35
|
/** Will apply the recommended settings for an overlay widget */
|
|
@@ -43,7 +40,8 @@ export declare class Widget {
|
|
|
43
40
|
* Will restore the saved position and size of the widget on start,
|
|
44
41
|
* after that will store the position and size of the widget on change.
|
|
45
42
|
*/
|
|
46
|
-
persistPositionAndSize
|
|
43
|
+
private persistPositionAndSize;
|
|
44
|
+
private normalizeDevicePixelRatio;
|
|
47
45
|
/**
|
|
48
46
|
* Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
|
|
49
47
|
* This should be called before any other action on the widget. After this you should call
|
|
@@ -58,7 +56,12 @@ export declare class Widget {
|
|
|
58
56
|
*/
|
|
59
57
|
ready(options?: ReadyWidgetOptions): Promise<void>;
|
|
60
58
|
onTrigger(cb: (args: WidgetTriggerPayload) => void): void;
|
|
61
|
-
|
|
59
|
+
__unsafe_setPosition(rect: Rect, ref: Frame): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* This will adjust the position of the widget based on the current placement and alignX/alignY arguments.
|
|
62
|
+
* This makes the widget fit into the monitor where it was placed, avoiding monitor overflow.
|
|
63
|
+
*/
|
|
64
|
+
adjustAndSetPosition(x: number, y: number, alignX?: Alignment | null, alignY?: Alignment | null): Promise<void>;
|
|
62
65
|
setPosition(rect: Rect): Promise<void>;
|
|
63
66
|
show(): Promise<void>;
|
|
64
67
|
/** Will force foreground the widget */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/mod.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,MAAM,IAAI,OAAO,EAEtB,KAAK,QAAQ,EAIb,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAOnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEhG,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/mod.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,SAAS,EACd,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,wBAAwB,EAC7B,KAAK,MAAM,IAAI,OAAO,EAEtB,KAAK,QAAQ,EAIb,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAOnC,OAAO,KAAK,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEhG,OAAO,EAAqB,KAAK,OAAO,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAoB,KAAK,MAAM,EAAE,MAAM,wBAAwB,CAAC;AASvE;;GAEG;AACH,qBAAa,MAAM;IACjB;;;OAGG;IACH,MAAM,CAAC,UAAU,IAAI,MAAM;IAU3B,iCAAiC;IACjC,MAAM,KAAK,IAAI,IAAI,MAAM,CAExB;IAED,gBAAgB;IAChB,SAAgB,EAAE,EAAE,QAAQ,CAAC;IAC7B,wBAAwB;IACxB,SAAgB,GAAG,EAAE,OAAO,CAAC;IAC7B,0CAA0C;IAC1C,SAAgB,OAAO,EAAE,iBAAiB,CAAC;IAC3C,kDAAkD;IAClD,SAAgB,OAAO,EAAE,OAAO,CAAC;IACjC,iDAAiD;IACjD,SAAgB,MAAM,EAAE,MAAM,CAAC;IAE/B,OAAO,CAAC,SAAS,CAAC,CAAkB;IAEpC,OAAO,CAAC,YAAY,CAKlB;IAEF,OAAO;IAkBP,kDAAkD;IAClD,IAAI,QAAQ,IAAI,MAAM,CAErB;IAED,kFAAkF;IAC3E,gBAAgB,IAAI,wBAAwB;IAQnD,+DAA+D;IAC/D,OAAO,CAAC,kBAAkB;IAE1B,gEAAgE;IAChE,OAAO,CAAC,kBAAkB;IAE1B,6DAA6D;IAC7D,OAAO,CAAC,gBAAgB;IA0BxB;;;OAGG;YACW,sBAAsB;YAwCtB,yBAAyB;IAavC;;;;OAIG;IACU,IAAI,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,IAAI,CAAC;IAmDjE;;;;;OAKG;IACU,KAAK,CAAC,OAAO,GAAE,kBAAuB,GAAG,OAAO,CAAC,IAAI,CAAC;IAwB5D,SAAS,CAAC,EAAE,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,IAAI,GAAG,IAAI;IAMnD,oBAAoB,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBxE;;;OAGG;IACU,oBAAoB,CAC/B,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EACT,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,EACzB,MAAM,CAAC,EAAE,SAAS,GAAG,IAAI,GACxB,OAAO,CAAC,IAAI,CAAC;IAyBH,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAMtC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAKlC,uCAAuC;IAC1B,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAU5B,IAAI,CAAC,oBAAoB,CAAC,EAAE,OAAO,GAAG,IAAI;CAMlD;AAWD,eAAO,MAAM,sBAAsB,EAAE,QAAyC,CAAC;AAC/E,eAAO,MAAM,mBAAmB,EAAE,QAAsC,CAAC;AACzE,eAAO,MAAM,iBAAiB,EAAE,QAAoC,CAAC;AACrE,eAAO,MAAM,qBAAqB,EAAE,QAA8C,CAAC;AACnF,eAAO,MAAM,2BAA2B,EAAE,QAA+C,CAAC;AAC1F,eAAO,MAAM,kBAAkB,EAAE,QAAkD,CAAC"}
|
|
@@ -3,7 +3,7 @@ import { WidgetPreset, WidgetStatus, } from "../../../gen/types/mod.js";
|
|
|
3
3
|
import { invoke, SeelenCommand, SeelenEvent } from "../../handlers/mod.js";
|
|
4
4
|
import { decodeBase64Url } from "../../../deps/jsr.io/@std/encoding/1.0.10/mod.js";
|
|
5
5
|
import { debounce } from "../../utils/async.js";
|
|
6
|
-
import { WidgetAutoSizer } from "./sizing.js";
|
|
6
|
+
import { OPTIMISTIC_FRAME, WidgetAutoSizer } from "./sizing.js";
|
|
7
7
|
import { adjustPositionByPlacement, fitIntoMonitor, initMonitorsState } from "./positioning.js";
|
|
8
8
|
import { startThemingTool } from "../theme/theming.js";
|
|
9
9
|
import { disableAnimationsOnPerformanceMode } from "./performance.js";
|
|
@@ -43,14 +43,6 @@ export class Widget {
|
|
|
43
43
|
hwnd: 0,
|
|
44
44
|
initialized: false,
|
|
45
45
|
ready: false,
|
|
46
|
-
position: {
|
|
47
|
-
x: 0,
|
|
48
|
-
y: 0,
|
|
49
|
-
},
|
|
50
|
-
size: {
|
|
51
|
-
width: 0,
|
|
52
|
-
height: 0,
|
|
53
|
-
},
|
|
54
46
|
firstFocus: true,
|
|
55
47
|
};
|
|
56
48
|
constructor(widget) {
|
|
@@ -72,15 +64,6 @@ export class Widget {
|
|
|
72
64
|
get windowId() {
|
|
73
65
|
return this.runtimeState.hwnd;
|
|
74
66
|
}
|
|
75
|
-
/** Returns the current position and size of the widget */
|
|
76
|
-
get frame() {
|
|
77
|
-
return {
|
|
78
|
-
x: this.runtimeState.position.x,
|
|
79
|
-
y: this.runtimeState.position.y,
|
|
80
|
-
width: this.runtimeState.size.width,
|
|
81
|
-
height: this.runtimeState.size.height,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
67
|
/** Returns the default config of the widget, declared on the widget definition */
|
|
85
68
|
getDefaultConfig() {
|
|
86
69
|
const config = { enabled: true };
|
|
@@ -89,29 +72,12 @@ export class Widget {
|
|
|
89
72
|
}
|
|
90
73
|
return config;
|
|
91
74
|
}
|
|
92
|
-
applyInvisiblePreset() {
|
|
93
|
-
return [
|
|
94
|
-
this.window.setDecorations(false), // no title bar
|
|
95
|
-
this.window.setShadow(false), // no shadows
|
|
96
|
-
// hide from native shell
|
|
97
|
-
this.window.setSkipTaskbar(true),
|
|
98
|
-
// as a (desktop/overlay) widget we don't wanna allow nothing of these
|
|
99
|
-
this.window.setMinimizable(false),
|
|
100
|
-
this.window.setMaximizable(false),
|
|
101
|
-
this.window.setClosable(false),
|
|
102
|
-
];
|
|
103
|
-
}
|
|
104
75
|
/** Will apply the recommended settings for a desktop widget */
|
|
105
|
-
|
|
106
|
-
await Promise.all([...this.applyInvisiblePreset(), this.window.setAlwaysOnBottom(true)]);
|
|
107
|
-
}
|
|
76
|
+
applyDesktopPreset() { }
|
|
108
77
|
/** Will apply the recommended settings for an overlay widget */
|
|
109
|
-
|
|
110
|
-
await Promise.all([...this.applyInvisiblePreset(), this.window.setAlwaysOnTop(true)]);
|
|
111
|
-
}
|
|
78
|
+
applyOverlayPreset() { }
|
|
112
79
|
/** Will apply the recommended settings for a popup widget */
|
|
113
|
-
|
|
114
|
-
await Promise.all([...this.applyInvisiblePreset(), this.window.setAlwaysOnTop(true)]);
|
|
80
|
+
applyPopupPreset() {
|
|
115
81
|
const hideWidget = debounce(() => {
|
|
116
82
|
this.hide(true);
|
|
117
83
|
}, 100);
|
|
@@ -126,27 +92,8 @@ export class Widget {
|
|
|
126
92
|
this.onTrigger(async ({ desiredPosition, alignX, alignY }) => {
|
|
127
93
|
// avoid flickering when clicking a button that triggers the widget
|
|
128
94
|
hideWidget.cancel();
|
|
129
|
-
if (this.autoSizer && alignX && alignY) {
|
|
130
|
-
this.autoSizer.originX = alignX;
|
|
131
|
-
this.autoSizer.originY = alignY;
|
|
132
|
-
}
|
|
133
95
|
if (desiredPosition) {
|
|
134
|
-
|
|
135
|
-
frame: {
|
|
136
|
-
x: desiredPosition.x,
|
|
137
|
-
y: desiredPosition.y,
|
|
138
|
-
width: this.runtimeState.size.width,
|
|
139
|
-
height: this.runtimeState.size.height,
|
|
140
|
-
},
|
|
141
|
-
originX: alignX,
|
|
142
|
-
originY: alignY,
|
|
143
|
-
});
|
|
144
|
-
await this.setPosition({
|
|
145
|
-
left: adjusted.x,
|
|
146
|
-
top: adjusted.y,
|
|
147
|
-
right: adjusted.x + adjusted.width,
|
|
148
|
-
bottom: adjusted.y + adjusted.height,
|
|
149
|
-
});
|
|
96
|
+
await this.adjustAndSetPosition(desiredPosition.x, desiredPosition.y, alignX, alignY);
|
|
150
97
|
}
|
|
151
98
|
await this.show();
|
|
152
99
|
await this.focus();
|
|
@@ -187,6 +134,18 @@ export class Widget {
|
|
|
187
134
|
console.info(`Widget size saved: ${width} ${height}`);
|
|
188
135
|
}, 500));
|
|
189
136
|
}
|
|
137
|
+
async normalizeDevicePixelRatio() {
|
|
138
|
+
// play with zoom level to reset device pixel ratio to 1:1
|
|
139
|
+
let oldDPR = globalThis.devicePixelRatio;
|
|
140
|
+
await this.webview.setZoom(1 / oldDPR);
|
|
141
|
+
this.window.onScaleChanged(() => {
|
|
142
|
+
if (globalThis.devicePixelRatio !== oldDPR) {
|
|
143
|
+
// when zoom was set dpr changed, so in case of change this is accomulative unit
|
|
144
|
+
oldDPR = oldDPR * globalThis.devicePixelRatio;
|
|
145
|
+
this.webview.setZoom(1 / (oldDPR * globalThis.devicePixelRatio));
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
}
|
|
190
149
|
/**
|
|
191
150
|
* Will initialize the widget based on the preset and mark it as `pending`, this function won't show the widget.
|
|
192
151
|
* This should be called before any other action on the widget. After this you should call
|
|
@@ -199,8 +158,11 @@ export class Widget {
|
|
|
199
158
|
}
|
|
200
159
|
this.runtimeState.hwnd = await invoke(SeelenCommand.GetSelfWindowId);
|
|
201
160
|
this.runtimeState.initialized = true;
|
|
161
|
+
if (options.normalizeDevicePixelRatio) {
|
|
162
|
+
await this.normalizeDevicePixelRatio();
|
|
163
|
+
}
|
|
202
164
|
if (options.autoSizeByContent) {
|
|
203
|
-
this.autoSizer = new WidgetAutoSizer(this, options.autoSizeByContent);
|
|
165
|
+
this.autoSizer = new WidgetAutoSizer(this, options.autoSizeByContent, options.autoSizeFitOnScreen ?? true);
|
|
204
166
|
}
|
|
205
167
|
else if (options.saveAndRestoreLastRect ?? this.def.preset === WidgetPreset.Desktop) {
|
|
206
168
|
await this.persistPositionAndSize();
|
|
@@ -209,13 +171,13 @@ export class Widget {
|
|
|
209
171
|
case WidgetPreset.None:
|
|
210
172
|
break;
|
|
211
173
|
case WidgetPreset.Desktop:
|
|
212
|
-
|
|
174
|
+
this.applyDesktopPreset();
|
|
213
175
|
break;
|
|
214
176
|
case WidgetPreset.Overlay:
|
|
215
|
-
|
|
177
|
+
this.applyOverlayPreset();
|
|
216
178
|
break;
|
|
217
179
|
case WidgetPreset.Popup:
|
|
218
|
-
|
|
180
|
+
this.applyPopupPreset();
|
|
219
181
|
break;
|
|
220
182
|
}
|
|
221
183
|
await startThemingTool();
|
|
@@ -226,16 +188,8 @@ export class Widget {
|
|
|
226
188
|
else {
|
|
227
189
|
console.trace("Animations won't be disabled because widget configuration");
|
|
228
190
|
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
this.runtimeState.position = await this.window.outerPosition();
|
|
232
|
-
this.window.onResized((e) => {
|
|
233
|
-
this.runtimeState.size.width = e.payload.width;
|
|
234
|
-
this.runtimeState.size.height = e.payload.height;
|
|
235
|
-
});
|
|
236
|
-
this.window.onMoved((e) => {
|
|
237
|
-
this.runtimeState.position.x = e.payload.x;
|
|
238
|
-
this.runtimeState.position.y = e.payload.y;
|
|
191
|
+
await OPTIMISTIC_FRAME.runExclusive(async (state) => {
|
|
192
|
+
await state.init(this);
|
|
239
193
|
});
|
|
240
194
|
}
|
|
241
195
|
/**
|
|
@@ -267,13 +221,8 @@ export class Widget {
|
|
|
267
221
|
cb(payload);
|
|
268
222
|
});
|
|
269
223
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
this.runtimeState.position.x = rect.left;
|
|
273
|
-
this.runtimeState.position.y = rect.top;
|
|
274
|
-
this.runtimeState.size.width = rect.right - rect.left;
|
|
275
|
-
this.runtimeState.size.height = rect.bottom - rect.top;
|
|
276
|
-
return invoke(SeelenCommand.SetSelfPosition, {
|
|
224
|
+
async __unsafe_setPosition(rect, ref) {
|
|
225
|
+
await invoke(SeelenCommand.SetSelfPosition, {
|
|
277
226
|
rect: {
|
|
278
227
|
left: Math.round(rect.left),
|
|
279
228
|
top: Math.round(rect.top),
|
|
@@ -281,6 +230,40 @@ export class Widget {
|
|
|
281
230
|
bottom: Math.round(rect.bottom),
|
|
282
231
|
},
|
|
283
232
|
});
|
|
233
|
+
// optimistically update state, as arrived event after change is async
|
|
234
|
+
ref.x = rect.left;
|
|
235
|
+
ref.y = rect.top;
|
|
236
|
+
ref.width = rect.right - rect.left;
|
|
237
|
+
ref.height = rect.bottom - rect.top;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* This will adjust the position of the widget based on the current placement and alignX/alignY arguments.
|
|
241
|
+
* This makes the widget fit into the monitor where it was placed, avoiding monitor overflow.
|
|
242
|
+
*/
|
|
243
|
+
async adjustAndSetPosition(x, y, alignX, alignY) {
|
|
244
|
+
await OPTIMISTIC_FRAME.runExclusive(async (ref) => {
|
|
245
|
+
const adjusted = adjustPositionByPlacement({
|
|
246
|
+
frame: {
|
|
247
|
+
x,
|
|
248
|
+
y,
|
|
249
|
+
width: ref.width,
|
|
250
|
+
height: ref.height,
|
|
251
|
+
},
|
|
252
|
+
originX: alignX,
|
|
253
|
+
originY: alignY,
|
|
254
|
+
});
|
|
255
|
+
await Widget.self.__unsafe_setPosition({
|
|
256
|
+
left: adjusted.x,
|
|
257
|
+
top: adjusted.y,
|
|
258
|
+
right: adjusted.x + adjusted.width,
|
|
259
|
+
bottom: adjusted.y + adjusted.height,
|
|
260
|
+
}, ref);
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
async setPosition(rect) {
|
|
264
|
+
await OPTIMISTIC_FRAME.runExclusive(async (frame) => {
|
|
265
|
+
await this.__unsafe_setPosition(rect, frame);
|
|
266
|
+
});
|
|
284
267
|
}
|
|
285
268
|
async show() {
|
|
286
269
|
debouncedClose.cancel();
|
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import type { Widget } from "./mod.js";
|
|
2
2
|
import { Alignment } from "../../../gen/types/mod.js";
|
|
3
|
+
import { Mutex } from "../../utils/async.js";
|
|
4
|
+
declare class OptimisiticFrame {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
width: number;
|
|
8
|
+
height: number;
|
|
9
|
+
init(widget: Widget): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
export declare const OPTIMISTIC_FRAME: Mutex<OptimisiticFrame>;
|
|
3
12
|
export declare class WidgetAutoSizer {
|
|
4
13
|
private widget;
|
|
5
14
|
private element;
|
|
15
|
+
private fitOnScreen;
|
|
6
16
|
/** From which side the widget will grow */
|
|
7
|
-
originX
|
|
17
|
+
originX?: Alignment | null;
|
|
8
18
|
/** From which side the widget will grow */
|
|
9
|
-
originY
|
|
10
|
-
constructor(widget: Widget, element: HTMLElement);
|
|
19
|
+
originY?: Alignment | null;
|
|
20
|
+
constructor(widget: Widget, element: HTMLElement, fitOnScreen: boolean);
|
|
11
21
|
private setup;
|
|
12
22
|
execute(): Promise<void>;
|
|
13
23
|
}
|
|
24
|
+
export {};
|
|
14
25
|
//# sourceMappingURL=sizing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sizing.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/sizing.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sizing.d.ts","sourceRoot":"","sources":["../../../../src/src/state/widget/sizing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAG7C,cAAM,gBAAgB;IACpB,CAAC,EAAE,MAAM,CAAK;IACd,CAAC,EAAE,MAAM,CAAK;IACd,KAAK,EAAE,MAAM,CAAK;IAClB,MAAM,EAAE,MAAM,CAAK;IAEb,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAuB1C;AAED,eAAO,MAAM,gBAAgB,yBAAoC,CAAC;AAElE,qBAAa,eAAe;IAOxB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,WAAW;IARrB,2CAA2C;IAC3C,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;IAC3B,2CAA2C;IAC3C,OAAO,CAAC,EAAE,SAAS,GAAG,IAAI,CAAC;gBAGjB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,WAAW,EACpB,WAAW,EAAE,OAAO;IAM9B,OAAO,CAAC,KAAK;IAqBP,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAsD/B"}
|
|
@@ -1,21 +1,57 @@
|
|
|
1
|
-
import { PhysicalSize } from "@tauri-apps/api/dpi";
|
|
2
1
|
import { Alignment } from "../../../gen/types/mod.js";
|
|
2
|
+
import { Mutex } from "../../utils/async.js";
|
|
3
|
+
import { fitIntoMonitor } from "./positioning.js";
|
|
4
|
+
class OptimisiticFrame {
|
|
5
|
+
x = 0;
|
|
6
|
+
y = 0;
|
|
7
|
+
width = 0;
|
|
8
|
+
height = 0;
|
|
9
|
+
async init(widget) {
|
|
10
|
+
const { width, height } = await widget.window.outerSize();
|
|
11
|
+
const { x, y } = await widget.window.outerPosition();
|
|
12
|
+
this.width = width;
|
|
13
|
+
this.height = height;
|
|
14
|
+
this.x = x;
|
|
15
|
+
this.y = y;
|
|
16
|
+
widget.window.onResized((e) => {
|
|
17
|
+
OPTIMISTIC_FRAME.runExclusive((ref) => {
|
|
18
|
+
ref.width = e.payload.width;
|
|
19
|
+
ref.height = e.payload.height;
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
widget.window.onMoved((e) => {
|
|
23
|
+
OPTIMISTIC_FRAME.runExclusive((ref) => {
|
|
24
|
+
ref.x = e.payload.x;
|
|
25
|
+
ref.y = e.payload.y;
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
export const OPTIMISTIC_FRAME = new Mutex(new OptimisiticFrame());
|
|
3
31
|
export class WidgetAutoSizer {
|
|
4
32
|
widget;
|
|
5
33
|
element;
|
|
34
|
+
fitOnScreen;
|
|
6
35
|
/** From which side the widget will grow */
|
|
7
|
-
originX
|
|
36
|
+
originX;
|
|
8
37
|
/** From which side the widget will grow */
|
|
9
|
-
originY
|
|
10
|
-
constructor(widget, element) {
|
|
38
|
+
originY;
|
|
39
|
+
constructor(widget, element, fitOnScreen) {
|
|
11
40
|
this.widget = widget;
|
|
12
41
|
this.element = element;
|
|
42
|
+
this.fitOnScreen = fitOnScreen;
|
|
13
43
|
this.execute = this.execute.bind(this);
|
|
14
44
|
this.setup();
|
|
15
45
|
}
|
|
16
46
|
setup() {
|
|
17
47
|
// Disable resizing by the user
|
|
18
48
|
this.widget.window.setResizable(false);
|
|
49
|
+
this.widget.onTrigger(({ alignX, alignY }) => {
|
|
50
|
+
OPTIMISTIC_FRAME.runExclusive(() => {
|
|
51
|
+
this.originX = alignX;
|
|
52
|
+
this.originY = alignY;
|
|
53
|
+
});
|
|
54
|
+
});
|
|
19
55
|
const observer = new ResizeObserver(this.execute);
|
|
20
56
|
observer.observe(this.element, {
|
|
21
57
|
box: "border-box",
|
|
@@ -25,8 +61,9 @@ export class WidgetAutoSizer {
|
|
|
25
61
|
};
|
|
26
62
|
}
|
|
27
63
|
async execute() {
|
|
28
|
-
const
|
|
29
|
-
const
|
|
64
|
+
const guard = await OPTIMISTIC_FRAME.acquire();
|
|
65
|
+
const { x, y, width, height } = guard.value;
|
|
66
|
+
let frame = {
|
|
30
67
|
x,
|
|
31
68
|
y,
|
|
32
69
|
width: Math.ceil(this.element.scrollWidth * globalThis.window.devicePixelRatio),
|
|
@@ -36,9 +73,12 @@ export class WidgetAutoSizer {
|
|
|
36
73
|
const heightDiff = frame.height - height;
|
|
37
74
|
// Only update if the difference is more than 1px (avoid infinite loops from decimal differences)
|
|
38
75
|
if (widthDiff === 0 && heightDiff === 0) {
|
|
76
|
+
guard.release();
|
|
39
77
|
return;
|
|
40
78
|
}
|
|
41
|
-
console.
|
|
79
|
+
/* console.debug(
|
|
80
|
+
`Auto resizing from ${width}x${height} to ${frame.width}x${frame.height} using ${this.originX}/${this.originY} origin`,
|
|
81
|
+
); */
|
|
42
82
|
if (this.originX === Alignment.Center) {
|
|
43
83
|
frame.x -= widthDiff / 2;
|
|
44
84
|
}
|
|
@@ -51,16 +91,19 @@ export class WidgetAutoSizer {
|
|
|
51
91
|
else if (this.originY === Alignment.End) {
|
|
52
92
|
frame.y -= heightDiff;
|
|
53
93
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
94
|
+
if (this.fitOnScreen) {
|
|
95
|
+
frame = fitIntoMonitor(frame);
|
|
96
|
+
}
|
|
97
|
+
try {
|
|
98
|
+
await this.widget.__unsafe_setPosition({
|
|
99
|
+
left: frame.x,
|
|
100
|
+
top: frame.y,
|
|
101
|
+
right: frame.x + frame.width,
|
|
102
|
+
bottom: frame.y + frame.height,
|
|
103
|
+
}, guard.value);
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
guard.release();
|
|
58
107
|
}
|
|
59
|
-
await this.widget.setPosition({
|
|
60
|
-
left: frame.x,
|
|
61
|
-
top: frame.y,
|
|
62
|
-
right: frame.x + frame.width,
|
|
63
|
-
bottom: frame.y + frame.height,
|
|
64
|
-
});
|
|
65
108
|
}
|
|
66
109
|
}
|
package/esm/src/utils/async.d.ts
CHANGED
|
@@ -5,4 +5,16 @@ export interface DebouncedFunction<T extends (...args: any[]) => any> {
|
|
|
5
5
|
pending(): boolean;
|
|
6
6
|
}
|
|
7
7
|
export declare function debounce<T extends (...args: any[]) => any>(fn: T, delay: number): DebouncedFunction<T>;
|
|
8
|
+
export declare class Mutex<T> {
|
|
9
|
+
private _rawValue;
|
|
10
|
+
constructor(_rawValue: T);
|
|
11
|
+
private lock;
|
|
12
|
+
acquire(): Promise<Guard<T>>;
|
|
13
|
+
runExclusive<U>(fn: (v: T) => U): Promise<U>;
|
|
14
|
+
}
|
|
15
|
+
export declare class Guard<T> {
|
|
16
|
+
value: T;
|
|
17
|
+
release: () => void;
|
|
18
|
+
constructor(value: T, release: () => void);
|
|
19
|
+
}
|
|
8
20
|
//# sourceMappingURL=async.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/src/utils/async.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;IAClE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/B,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,IAAI,OAAO,CAAC;CACpB;AAGD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,iBAAiB,CAAC,CAAC,CAAC,CA6CtB"}
|
|
1
|
+
{"version":3,"file":"async.d.ts","sourceRoot":"","sources":["../../../src/src/utils/async.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,iBAAiB,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG;IAClE,CAAC,GAAG,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/B,MAAM,IAAI,IAAI,CAAC;IACf,KAAK,IAAI,IAAI,CAAC;IACd,OAAO,IAAI,OAAO,CAAC;CACpB;AAGD,wBAAgB,QAAQ,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,EACxD,EAAE,EAAE,CAAC,EACL,KAAK,EAAE,MAAM,GACZ,iBAAiB,CAAC,CAAC,CAAC,CA6CtB;AAED,qBAAa,KAAK,CAAC,CAAC;IACN,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,CAAC;IAEhC,OAAO,CAAC,IAAI,CAII;IAEV,OAAO,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IA0B5B,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CAQnD;AAED,qBAAa,KAAK,CAAC,CAAC;IAET,KAAK,EAAE,CAAC;IACR,OAAO,EAAE,MAAM,IAAI;gBADnB,KAAK,EAAE,CAAC,EACR,OAAO,EAAE,MAAM,IAAI;CAE7B"}
|
package/esm/src/utils/async.js
CHANGED
|
@@ -37,3 +37,49 @@ export function debounce(fn, delay) {
|
|
|
37
37
|
};
|
|
38
38
|
return debounced;
|
|
39
39
|
}
|
|
40
|
+
export class Mutex {
|
|
41
|
+
_rawValue;
|
|
42
|
+
constructor(_rawValue) {
|
|
43
|
+
this._rawValue = _rawValue;
|
|
44
|
+
}
|
|
45
|
+
lock = null;
|
|
46
|
+
async acquire() {
|
|
47
|
+
if (this.lock) {
|
|
48
|
+
await this.lock.__promise;
|
|
49
|
+
}
|
|
50
|
+
// deno-lint-ignore no-explicit-any
|
|
51
|
+
let __resolve;
|
|
52
|
+
// deno-lint-ignore no-explicit-any
|
|
53
|
+
let __reject;
|
|
54
|
+
const __promise = new Promise((resolve, reject) => {
|
|
55
|
+
__resolve = resolve;
|
|
56
|
+
__reject = reject;
|
|
57
|
+
});
|
|
58
|
+
this.lock = {
|
|
59
|
+
__promise,
|
|
60
|
+
__resolve,
|
|
61
|
+
__reject,
|
|
62
|
+
};
|
|
63
|
+
return new Guard(this._rawValue, () => {
|
|
64
|
+
this.lock = null;
|
|
65
|
+
__resolve();
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
async runExclusive(fn) {
|
|
69
|
+
const guard = await this.acquire();
|
|
70
|
+
try {
|
|
71
|
+
return await fn(guard.value);
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
guard.release();
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
export class Guard {
|
|
79
|
+
value;
|
|
80
|
+
release;
|
|
81
|
+
constructor(value, release) {
|
|
82
|
+
this.value = value;
|
|
83
|
+
this.release = release;
|
|
84
|
+
}
|
|
85
|
+
}
|
package/esm/src/utils/mod.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/utils/mod.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;IACf,IAAI,SAAK;IACT,GAAG,SAAK;IACR,KAAK,SAAK;IACV,MAAM,SAAK;CACZ"}
|
|
1
|
+
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../src/src/utils/mod.ts"],"names":[],"mappings":"AAAA,qBAAa,IAAI;IACf,IAAI,SAAK;IACT,GAAG,SAAK;IACR,KAAK,SAAK;IACV,MAAM,SAAK;CACZ;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAG3C"}
|
package/esm/src/utils/mod.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ClipboardEntry } from "./ClipboardEntry.js";
|
|
2
|
+
/**
|
|
3
|
+
* Full clipboard state — emitted as a single payload on every relevant change.
|
|
4
|
+
*/
|
|
5
|
+
export type ClipboardData = {
|
|
6
|
+
/**
|
|
7
|
+
* Whether the user has enabled clipboard history in Windows Settings.
|
|
8
|
+
*/
|
|
9
|
+
isHistoryEnabled: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* All clipboard history entries, newest first.
|
|
12
|
+
*/
|
|
13
|
+
history: Array<ClipboardEntry>;
|
|
14
|
+
};
|
|
15
|
+
//# sourceMappingURL=ClipboardData.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClipboardData.d.ts","sourceRoot":"","sources":["../../../src/gen/types/ClipboardData.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,aAAa,GAAG;IAC5B;;OAEG;IACH,gBAAgB,EAAE,OAAO,CAAC;IAC1B;;OAEG;IACH,OAAO,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ClipboardEntryContent } from "./ClipboardEntryContent.js";
|
|
2
|
+
/**
|
|
3
|
+
* A single entry in the Windows clipboard history.
|
|
4
|
+
*/
|
|
5
|
+
export type ClipboardEntry = {
|
|
6
|
+
/**
|
|
7
|
+
* Unique identifier assigned by Windows.
|
|
8
|
+
*/
|
|
9
|
+
id: string;
|
|
10
|
+
/**
|
|
11
|
+
* Windows FILETIME (100-ns ticks since 1601-01-01).
|
|
12
|
+
*/
|
|
13
|
+
timestamp: number;
|
|
14
|
+
/**
|
|
15
|
+
* Display name of the application that placed the entry on the clipboard.
|
|
16
|
+
*/
|
|
17
|
+
sourceAppName: string | null;
|
|
18
|
+
/**
|
|
19
|
+
* Base64-encoded WebP image of the app logo.
|
|
20
|
+
*/
|
|
21
|
+
sourceAppLogo: string | null;
|
|
22
|
+
content: ClipboardEntryContent;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=ClipboardEntry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClipboardEntry.d.ts","sourceRoot":"","sources":["../../../src/gen/types/ClipboardEntry.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AAExE;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG;IAC7B;;OAEG;IACH,EAAE,EAAE,MAAM,CAAC;IACX;;OAEG;IACH,SAAS,EAAE,MAAM,CAAC;IAClB;;OAEG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B;;OAEG;IACH,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,qBAAqB,CAAC;CAAE,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content of a clipboard entry.
|
|
3
|
+
*/
|
|
4
|
+
export type ClipboardEntryContent = {
|
|
5
|
+
text: string | null;
|
|
6
|
+
html: string | null;
|
|
7
|
+
rtf: string | null;
|
|
8
|
+
applicationLink: string | null;
|
|
9
|
+
webLink: string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Base64-encoded WebP image.
|
|
12
|
+
*/
|
|
13
|
+
bitmap: string | null;
|
|
14
|
+
files: Array<string> | null;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=ClipboardEntryContent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClipboardEntryContent.d.ts","sourceRoot":"","sources":["../../../src/gen/types/ClipboardEntryContent.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3J;;OAEG;IACH,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CAAE,CAAC"}
|