@liminal-hq/plugin-desktop-integration 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +31 -5
- package/api-iife.js +8 -0
- package/dist-js/bindings/ShortcutChangedPayload.d.ts +11 -0
- package/dist-js/bindings/ShortcutChangedPayload.d.ts.map +1 -0
- package/dist-js/index.cjs +8 -0
- package/dist-js/index.cjs.map +1 -1
- package/dist-js/index.d.ts +10 -1
- package/dist-js/index.d.ts.map +1 -1
- package/dist-js/index.js +8 -0
- package/dist-js/index.js.map +1 -1
- package/dist-js/index.test.d.ts +2 -0
- package/dist-js/index.test.d.ts.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -64,6 +64,12 @@ confirmation dialog. Call `set_shortcut_window(&window)` once your first window
|
|
|
64
64
|
shown to kick off the deferred binding, and listen for the `shortcut-binding-result`
|
|
65
65
|
event to know when it resolves.
|
|
66
66
|
|
|
67
|
+
The compositor's own settings UI can also rebind the shortcut independently of the app
|
|
68
|
+
(e.g. GNOME Settings → Apps → <App> → Global Shortcuts) — listen for the
|
|
69
|
+
`shortcut-changed` event (Wayland-only) to keep your own UI in sync.
|
|
70
|
+
`DesktopIntegrationExt::last_shortcut_trigger_description` covers the race where the
|
|
71
|
+
rebind happens before your listener attaches.
|
|
72
|
+
|
|
67
73
|
### JavaScript
|
|
68
74
|
|
|
69
75
|
JS-only apps (no custom Rust command of their own) can register shortcuts directly —
|
|
@@ -90,18 +96,37 @@ Rust consumers should prefer calling `DesktopIntegrationExt::register_shortcut`
|
|
|
90
96
|
from `setup()` — it delivers activation via a real closure instead of an event
|
|
91
97
|
round-trip. The `register_shortcut` command exists specifically for JS-only consumers.
|
|
92
98
|
|
|
99
|
+
To detect an external rebind (Wayland-only), listen for `shortcut-changed` directly via
|
|
100
|
+
`@tauri-apps/api/event`, and use `checkShortcutTriggerDescription` as a race guard for
|
|
101
|
+
UI that mounts after a missed event:
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
import { listen } from '@tauri-apps/api/event';
|
|
105
|
+
import {
|
|
106
|
+
desktopIntegration,
|
|
107
|
+
type ShortcutChangedPayload,
|
|
108
|
+
} from '@liminal-hq/plugin-desktop-integration';
|
|
109
|
+
|
|
110
|
+
await listen<ShortcutChangedPayload>('shortcut-changed', ({ payload }) => {
|
|
111
|
+
console.log(`rebound externally to: ${payload.triggerDescription}`);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
const lastKnownTrigger = await desktopIntegration.checkShortcutTriggerDescription();
|
|
115
|
+
```
|
|
116
|
+
|
|
93
117
|
### Generated types
|
|
94
118
|
|
|
95
|
-
`ShortcutBindingResult` and `
|
|
96
|
-
`shortcut-binding-result` and `shortcut-
|
|
97
|
-
definitions via
|
|
98
|
-
`guest-js/bindings/` and re-exported
|
|
99
|
-
drift:
|
|
119
|
+
`ShortcutBindingResult`, `ShortcutActivatedPayload`, and `ShortcutChangedPayload` (the
|
|
120
|
+
payloads of the `shortcut-binding-result`, `shortcut-activated`, and `shortcut-changed`
|
|
121
|
+
events) are generated from their Rust definitions via
|
|
122
|
+
[`ts-rs`](https://github.com/Aleph-Alpha/ts-rs) into `guest-js/bindings/` and re-exported
|
|
123
|
+
from the package root, so the JS/Rust shapes can't drift:
|
|
100
124
|
|
|
101
125
|
```typescript
|
|
102
126
|
import type {
|
|
103
127
|
ShortcutActivatedPayload,
|
|
104
128
|
ShortcutBindingResult,
|
|
129
|
+
ShortcutChangedPayload,
|
|
105
130
|
} from '@liminal-hq/plugin-desktop-integration';
|
|
106
131
|
```
|
|
107
132
|
|
|
@@ -116,6 +141,7 @@ This plugin requires these permissions:
|
|
|
116
141
|
- `allow-register-shortcut`: Grants access to `register_shortcut`
|
|
117
142
|
- `allow-check-shortcut-binding-complete`: Grants access to `check_shortcut_binding_complete`
|
|
118
143
|
- `allow-check-shortcut-binding-error`: Grants access to `check_shortcut_binding_error`
|
|
144
|
+
- `allow-check-shortcut-trigger-description`: Grants access to `check_shortcut_trigger_description`
|
|
119
145
|
|
|
120
146
|
## Platform Support
|
|
121
147
|
|
package/api-iife.js
CHANGED
|
@@ -49,6 +49,14 @@ var __TAURI_PLUGIN_DESKTOP_INTEGRATION__ = (function (exports, core, event) {
|
|
|
49
49
|
* shortcut-binding-result listener — complements checkShortcutBindingComplete.
|
|
50
50
|
*/
|
|
51
51
|
checkShortcutBindingError: () => cmd('check_shortcut_binding_error'),
|
|
52
|
+
/**
|
|
53
|
+
* Returns the trigger description (e.g. "Super+E") from the most recent
|
|
54
|
+
* shortcut-changed event, or null if the shortcut hasn't been externally
|
|
55
|
+
* rebound yet this session. Use this to hydrate UI that mounts after a missed
|
|
56
|
+
* event — listen for the `shortcut-changed` event directly via
|
|
57
|
+
* `@tauri-apps/api/event`'s `listen()` for live updates.
|
|
58
|
+
*/
|
|
59
|
+
checkShortcutTriggerDescription: () => cmd('check_shortcut_trigger_description'),
|
|
52
60
|
};
|
|
53
61
|
|
|
54
62
|
exports.desktopIntegration = desktopIntegration;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payload emitted on the `shortcut-changed` event, fired when the user rebinds the
|
|
3
|
+
* shortcut through the compositor's own settings UI (e.g. GNOME Settings → Apps →
|
|
4
|
+
* <App> → Global Shortcuts) rather than through this app. Wayland-only — X11 direct
|
|
5
|
+
* grabs have no equivalent out-of-band rebind path, so this never fires there.
|
|
6
|
+
*/
|
|
7
|
+
export type ShortcutChangedPayload = {
|
|
8
|
+
sessionId: string;
|
|
9
|
+
triggerDescription: string;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=ShortcutChangedPayload.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ShortcutChangedPayload.d.ts","sourceRoot":"","sources":["../../guest-js/bindings/ShortcutChangedPayload.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,MAAM,sBAAsB,GAAG;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,kBAAkB,EAAE,MAAM,CAAC;CAAE,CAAC"}
|
package/dist-js/index.cjs
CHANGED
|
@@ -50,6 +50,14 @@ const desktopIntegration = {
|
|
|
50
50
|
* shortcut-binding-result listener — complements checkShortcutBindingComplete.
|
|
51
51
|
*/
|
|
52
52
|
checkShortcutBindingError: () => cmd('check_shortcut_binding_error'),
|
|
53
|
+
/**
|
|
54
|
+
* Returns the trigger description (e.g. "Super+E") from the most recent
|
|
55
|
+
* shortcut-changed event, or null if the shortcut hasn't been externally
|
|
56
|
+
* rebound yet this session. Use this to hydrate UI that mounts after a missed
|
|
57
|
+
* event — listen for the `shortcut-changed` event directly via
|
|
58
|
+
* `@tauri-apps/api/event`'s `listen()` for live updates.
|
|
59
|
+
*/
|
|
60
|
+
checkShortcutTriggerDescription: () => cmd('check_shortcut_trigger_description'),
|
|
53
61
|
};
|
|
54
62
|
|
|
55
63
|
exports.desktopIntegration = desktopIntegration;
|
package/dist-js/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":["invoke","listen"],"mappings":";;;;;AAAA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":["invoke","listen"],"mappings":";;;;;AAAA;AACA;AACA;AACA;AAUA,MAAM,MAAM,GAAG,6BAA6B;AAE5C,SAAS,GAAG,CAAI,IAAY,EAAE,IAA8B,EAAA;IAC3D,OAAOA,WAAM,CAAI,CAAA,EAAG,MAAM,CAAA,EAAG,IAAI,CAAA,CAAE,EAAE,IAAI,CAAC;AAC3C;AAEA,IAAI,kBAAkB,GAAwB,IAAI;AAClD,IAAI,mBAAmB,GAA4B,IAAI;AAEvD,SAAS,wBAAwB,GAAA;AAChC,IAAA,IAAI,mBAAmB;QAAE;AACzB,IAAA,mBAAmB,GAAGC,YAAM,CAA2B,oBAAoB,EAAE,MAAK;QACjF,kBAAkB,IAAI;AACvB,IAAA,CAAC,CAAC;AACH;AAEO,MAAM,kBAAkB,GAAG;AACjC;;;;;;;;;;;AAWG;IACH,gBAAgB,EAAE,CACjB,SAAiB,EACjB,kBAA0B,EAC1B,QAAgB,EAChB,WAAuB,KACL;QAClB,kBAAkB,GAAG,WAAW;AAChC,QAAA,wBAAwB,EAAE;AAC1B,QAAA,OAAO,GAAG,CAAC,mBAAmB,EAAE,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IAC7E,CAAC;AAED;;;;AAIG;AACH,IAAA,4BAA4B,EAAE,MAAM,GAAG,CAAU,iCAAiC,CAAC;AAEnF;;;;AAIG;AACH,IAAA,yBAAyB,EAAE,MAAM,GAAG,CAAgB,8BAA8B,CAAC;AAEnF;;;;;;AAMG;AACH,IAAA,+BAA+B,EAAE,MAAM,GAAG,CAAgB,oCAAoC,CAAC;;;;;"}
|
package/dist-js/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ShortcutActivatedPayload } from './bindings/ShortcutActivatedPayload';
|
|
2
2
|
import type { ShortcutBindingResult } from './bindings/ShortcutBindingResult';
|
|
3
|
-
|
|
3
|
+
import type { ShortcutChangedPayload } from './bindings/ShortcutChangedPayload';
|
|
4
|
+
export type { ShortcutActivatedPayload, ShortcutBindingResult, ShortcutChangedPayload };
|
|
4
5
|
export declare const desktopIntegration: {
|
|
5
6
|
/**
|
|
6
7
|
* Registers a global shortcut. On X11 it's bound immediately; on Wayland,
|
|
@@ -27,5 +28,13 @@ export declare const desktopIntegration: {
|
|
|
27
28
|
* shortcut-binding-result listener — complements checkShortcutBindingComplete.
|
|
28
29
|
*/
|
|
29
30
|
checkShortcutBindingError: () => Promise<string | null>;
|
|
31
|
+
/**
|
|
32
|
+
* Returns the trigger description (e.g. "Super+E") from the most recent
|
|
33
|
+
* shortcut-changed event, or null if the shortcut hasn't been externally
|
|
34
|
+
* rebound yet this session. Use this to hydrate UI that mounts after a missed
|
|
35
|
+
* event — listen for the `shortcut-changed` event directly via
|
|
36
|
+
* `@tauri-apps/api/event`'s `listen()` for live updates.
|
|
37
|
+
*/
|
|
38
|
+
checkShortcutTriggerDescription: () => Promise<string | null>;
|
|
30
39
|
};
|
|
31
40
|
//# sourceMappingURL=index.d.ts.map
|
package/dist-js/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../guest-js/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../guest-js/index.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AACpF,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAC9E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAEhF,YAAY,EAAE,wBAAwB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,CAAC;AAkBxF,eAAO,MAAM,kBAAkB;IAC9B;;;;;;;;;;;OAWG;kCAES,MAAM,sBACG,MAAM,YAChB,MAAM,eACH,MAAM,IAAI,KACrB,OAAO,CAAC,IAAI,CAAC;IAMhB;;;;OAIG;;IAGH;;;;OAIG;;IAGH;;;;;;OAMG;;CAEH,CAAC"}
|
package/dist-js/index.js
CHANGED
|
@@ -48,6 +48,14 @@ const desktopIntegration = {
|
|
|
48
48
|
* shortcut-binding-result listener — complements checkShortcutBindingComplete.
|
|
49
49
|
*/
|
|
50
50
|
checkShortcutBindingError: () => cmd('check_shortcut_binding_error'),
|
|
51
|
+
/**
|
|
52
|
+
* Returns the trigger description (e.g. "Super+E") from the most recent
|
|
53
|
+
* shortcut-changed event, or null if the shortcut hasn't been externally
|
|
54
|
+
* rebound yet this session. Use this to hydrate UI that mounts after a missed
|
|
55
|
+
* event — listen for the `shortcut-changed` event directly via
|
|
56
|
+
* `@tauri-apps/api/event`'s `listen()` for live updates.
|
|
57
|
+
*/
|
|
58
|
+
checkShortcutTriggerDescription: () => cmd('check_shortcut_trigger_description'),
|
|
51
59
|
};
|
|
52
60
|
|
|
53
61
|
export { desktopIntegration };
|
package/dist-js/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../guest-js/index.ts"],"sourcesContent":[null],"names":[],"mappings":";;;AAAA;AACA;AACA;AACA;AAUA,MAAM,MAAM,GAAG,6BAA6B;AAE5C,SAAS,GAAG,CAAI,IAAY,EAAE,IAA8B,EAAA;IAC3D,OAAO,MAAM,CAAI,CAAA,EAAG,MAAM,CAAA,EAAG,IAAI,CAAA,CAAE,EAAE,IAAI,CAAC;AAC3C;AAEA,IAAI,kBAAkB,GAAwB,IAAI;AAClD,IAAI,mBAAmB,GAA4B,IAAI;AAEvD,SAAS,wBAAwB,GAAA;AAChC,IAAA,IAAI,mBAAmB;QAAE;AACzB,IAAA,mBAAmB,GAAG,MAAM,CAA2B,oBAAoB,EAAE,MAAK;QACjF,kBAAkB,IAAI;AACvB,IAAA,CAAC,CAAC;AACH;AAEO,MAAM,kBAAkB,GAAG;AACjC;;;;;;;;;;;AAWG;IACH,gBAAgB,EAAE,CACjB,SAAiB,EACjB,kBAA0B,EAC1B,QAAgB,EAChB,WAAuB,KACL;QAClB,kBAAkB,GAAG,WAAW;AAChC,QAAA,wBAAwB,EAAE;AAC1B,QAAA,OAAO,GAAG,CAAC,mBAAmB,EAAE,EAAE,SAAS,EAAE,kBAAkB,EAAE,QAAQ,EAAE,CAAC;IAC7E,CAAC;AAED;;;;AAIG;AACH,IAAA,4BAA4B,EAAE,MAAM,GAAG,CAAU,iCAAiC,CAAC;AAEnF;;;;AAIG;AACH,IAAA,yBAAyB,EAAE,MAAM,GAAG,CAAgB,8BAA8B,CAAC;AAEnF;;;;;;AAMG;AACH,IAAA,+BAA+B,EAAE,MAAM,GAAG,CAAgB,oCAAoC,CAAC;;;;;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../guest-js/index.test.ts"],"names":[],"mappings":""}
|