@vicinae/api 0.9.1 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/dist/api/ai.js +2 -41
  2. package/dist/api/alert.js +8 -21
  3. package/dist/api/bus.d.ts +10 -7
  4. package/dist/api/bus.js +0 -33
  5. package/dist/api/cache.d.ts +64 -73
  6. package/dist/api/cache.js +163 -14
  7. package/dist/api/clipboard.d.ts +1 -1
  8. package/dist/api/clipboard.js +3 -9
  9. package/dist/api/controls.d.ts +3 -0
  10. package/dist/api/controls.js +5 -1
  11. package/dist/api/environment.d.ts +5 -0
  12. package/dist/api/file-search.d.ts +49 -0
  13. package/dist/api/file-search.js +49 -0
  14. package/dist/api/index.d.ts +2 -1
  15. package/dist/api/index.js +2 -1
  16. package/dist/api/lib/result.d.ts +3 -1
  17. package/dist/api/lib/result.js +2 -2
  18. package/dist/api/preference.js +2 -3
  19. package/dist/api/proto/application.d.ts +14 -0
  20. package/dist/api/proto/application.js +207 -37
  21. package/dist/api/proto/clipboard.js +38 -71
  22. package/dist/api/proto/common.js +2 -6
  23. package/dist/api/proto/daemon.js +5 -15
  24. package/dist/api/proto/extension.d.ts +16 -10
  25. package/dist/api/proto/extension.js +118 -91
  26. package/dist/api/proto/file-search.d.ts +42 -0
  27. package/dist/api/proto/file-search.js +290 -0
  28. package/dist/api/proto/google/protobuf/struct.js +9 -26
  29. package/dist/api/proto/ipc.js +53 -100
  30. package/dist/api/proto/manager.d.ts +2 -0
  31. package/dist/api/proto/manager.js +54 -49
  32. package/dist/api/proto/oauth.js +15 -33
  33. package/dist/api/proto/storage.js +29 -67
  34. package/dist/api/proto/ui.d.ts +11 -2
  35. package/dist/api/proto/ui.js +267 -254
  36. package/dist/api/proto/wlr-clipboard.js +4 -12
  37. package/dist/api/proto/wm.d.ts +111 -0
  38. package/dist/api/proto/wm.js +1266 -0
  39. package/dist/api/raycast/index.d.ts +24 -0
  40. package/dist/api/raycast/index.js +40 -0
  41. package/dist/api/raycast/system.d.ts +20 -0
  42. package/dist/api/raycast/system.js +73 -0
  43. package/dist/api/raycast/window-management.d.ts +42 -0
  44. package/dist/api/raycast/window-management.js +82 -0
  45. package/dist/api/toast.js +47 -5
  46. package/dist/api/utils.d.ts +5 -11
  47. package/dist/api/utils.js +20 -31
  48. package/dist/api/window-management.d.ts +39 -0
  49. package/dist/api/window-management.js +55 -0
  50. package/package.json +1 -1
@@ -0,0 +1,24 @@
1
+ /**
2
+ * This entrypoint is used instead of the normal index.ts when we are
3
+ * dealing with a Raycast extension, e.g an extension that makes use of
4
+ * `@raycast/api` package instead of `@vicinae/api`.
5
+ */
6
+ export * from "../components/index.js";
7
+ export * from "../hooks/index.js";
8
+ export * from "../context/index.js";
9
+ export * from "../bus.js";
10
+ export * from "../color.js";
11
+ export * from "../keyboard.js";
12
+ export * from "../image.js";
13
+ export * from "../icon.js";
14
+ export * from "../environment.js";
15
+ export * from "../controls.js";
16
+ export * from "../cache";
17
+ export * from "../toast";
18
+ export * from "../clipboard.js";
19
+ export * from "../local-storage.js";
20
+ export * from "../oauth.js";
21
+ export * from "../alert.js";
22
+ export * from "../preference.js";
23
+ export * from "./system.js";
24
+ export * from './window-management.js';
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ /**
3
+ * This entrypoint is used instead of the normal index.ts when we are
4
+ * dealing with a Raycast extension, e.g an extension that makes use of
5
+ * `@raycast/api` package instead of `@vicinae/api`.
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ __exportStar(require("../components/index.js"), exports);
23
+ __exportStar(require("../hooks/index.js"), exports);
24
+ __exportStar(require("../context/index.js"), exports);
25
+ __exportStar(require("../bus.js"), exports);
26
+ __exportStar(require("../color.js"), exports);
27
+ __exportStar(require("../keyboard.js"), exports);
28
+ __exportStar(require("../image.js"), exports);
29
+ __exportStar(require("../icon.js"), exports);
30
+ __exportStar(require("../environment.js"), exports);
31
+ __exportStar(require("../controls.js"), exports);
32
+ __exportStar(require("../cache"), exports);
33
+ __exportStar(require("../toast"), exports);
34
+ __exportStar(require("../clipboard.js"), exports);
35
+ __exportStar(require("../local-storage.js"), exports);
36
+ __exportStar(require("../oauth.js"), exports);
37
+ __exportStar(require("../alert.js"), exports);
38
+ __exportStar(require("../preference.js"), exports);
39
+ __exportStar(require("./system.js"), exports);
40
+ __exportStar(require("./window-management.js"), exports);
@@ -0,0 +1,20 @@
1
+ import { PathLike } from 'fs';
2
+ import * as vicinae from '..';
3
+ export type RaycastApplication = {
4
+ name: string;
5
+ path: string;
6
+ bundleId: string;
7
+ localizedName: string;
8
+ windowsAppId: string;
9
+ };
10
+ export declare const transformApp: (app: vicinae.Application) => RaycastApplication;
11
+ export declare const getApplications: (path?: PathLike) => Promise<RaycastApplication[]>;
12
+ export declare const getDefaultApplication: (path: PathLike) => Promise<RaycastApplication>;
13
+ export declare const open: (target: string, app?: vicinae.Application | string) => Promise<void>;
14
+ export declare const trash: (path: PathLike | PathLike[]) => Promise<void>;
15
+ export declare const getFrontmostApplication: () => Promise<RaycastApplication>;
16
+ export declare const captureException: (exception: unknown) => void;
17
+ export declare const showInFinder: (path: PathLike) => Promise<void>;
18
+ export declare const getSelectedFinderItems: () => Promise<{
19
+ path: string;
20
+ }[]>;
@@ -0,0 +1,73 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.getSelectedFinderItems = exports.showInFinder = exports.captureException = exports.getFrontmostApplication = exports.trash = exports.open = exports.getDefaultApplication = exports.getApplications = exports.transformApp = void 0;
37
+ const vicinae = __importStar(require(".."));
38
+ const transformApp = (app) => {
39
+ return {
40
+ bundleId: app.id,
41
+ name: app.name,
42
+ path: app.path,
43
+ localizedName: app.name,
44
+ windowsAppId: app.id,
45
+ };
46
+ };
47
+ exports.transformApp = transformApp;
48
+ const getApplications = async (path) => {
49
+ const apps = await vicinae.getApplications(path?.toString());
50
+ return apps.map(exports.transformApp);
51
+ };
52
+ exports.getApplications = getApplications;
53
+ const getDefaultApplication = async (path) => {
54
+ return (0, exports.transformApp)(await vicinae.getDefaultApplication(path.toString()));
55
+ };
56
+ exports.getDefaultApplication = getDefaultApplication;
57
+ exports.open = vicinae.open;
58
+ exports.trash = vicinae.trash;
59
+ const getFrontmostApplication = async () => {
60
+ return (0, exports.transformApp)(await vicinae.getFrontmostApplication());
61
+ };
62
+ exports.getFrontmostApplication = getFrontmostApplication;
63
+ const captureException = (exception) => {
64
+ // maybe one day, if we have a developer hub...
65
+ console.error("captureException called on", exception);
66
+ };
67
+ exports.captureException = captureException;
68
+ const showInFinder = (path) => vicinae.showInFileBrowser(path);
69
+ exports.showInFinder = showInFinder;
70
+ const getSelectedFinderItems = async () => {
71
+ throw new Error('getSelectedFinderItems is not implemented');
72
+ };
73
+ exports.getSelectedFinderItems = getSelectedFinderItems;
@@ -0,0 +1,42 @@
1
+ import { RaycastApplication } from './system';
2
+ type RaycastWindow = {
3
+ active: boolean;
4
+ bounds: {
5
+ position: {
6
+ x: number;
7
+ y: number;
8
+ };
9
+ size: {
10
+ height: number;
11
+ width: number;
12
+ };
13
+ } | "fullscreen";
14
+ desktopId: string;
15
+ fullScreenSettable: boolean;
16
+ id: string;
17
+ positionable: boolean;
18
+ resizable: boolean;
19
+ application?: RaycastApplication;
20
+ };
21
+ declare enum DesktopType {
22
+ User = 0,
23
+ FullScreen = 1
24
+ }
25
+ type RaycastDesktop = {
26
+ id: string;
27
+ screenId: string;
28
+ size: {
29
+ height: number;
30
+ width: number;
31
+ };
32
+ active: boolean;
33
+ type: DesktopType;
34
+ };
35
+ declare class RaycastWindowManagement {
36
+ getActiveWindow(): Promise<RaycastWindow>;
37
+ getDesktops(): Promise<RaycastDesktop[]>;
38
+ getWindowsOnActiveDesktop(): Promise<RaycastWindow[]>;
39
+ constructor();
40
+ }
41
+ export declare const WindowManagement: RaycastWindowManagement;
42
+ export {};
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.WindowManagement = void 0;
37
+ const system_1 = require("./system");
38
+ const vicinae = __importStar(require(".."));
39
+ var DesktopType;
40
+ (function (DesktopType) {
41
+ DesktopType[DesktopType["User"] = 0] = "User";
42
+ DesktopType[DesktopType["FullScreen"] = 1] = "FullScreen";
43
+ })(DesktopType || (DesktopType = {}));
44
+ ;
45
+ const transformNativeDesktop = (win) => {
46
+ return {
47
+ id: win.id,
48
+ screenId: win.monitorId,
49
+ size: { width: 0, height: 0 }, // FIXME: implement
50
+ active: win.active,
51
+ type: DesktopType.User
52
+ };
53
+ };
54
+ const transformNativeWindow = (win) => {
55
+ return {
56
+ id: win.id,
57
+ fullScreenSettable: true,
58
+ positionable: true,
59
+ resizable: true,
60
+ active: win.active,
61
+ bounds: win.bounds,
62
+ desktopId: win.workspaceId ?? '0',
63
+ application: win.application && (0, system_1.transformApp)(win.application)
64
+ };
65
+ };
66
+ class RaycastWindowManagement {
67
+ async getActiveWindow() {
68
+ const window = await vicinae.WindowManagement.getActiveWindow();
69
+ return transformNativeWindow(window);
70
+ }
71
+ async getDesktops() {
72
+ const workspaces = await vicinae.WindowManagement.getWorkspaces();
73
+ return workspaces.map(transformNativeDesktop);
74
+ }
75
+ async getWindowsOnActiveDesktop() {
76
+ const wins = await vicinae.WindowManagement.getWindowsOnActiveWorkspace();
77
+ return wins.map(transformNativeWindow);
78
+ }
79
+ constructor() { }
80
+ }
81
+ ;
82
+ exports.WindowManagement = new RaycastWindowManagement;
package/dist/api/toast.js CHANGED
@@ -1,9 +1,42 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
2
35
  Object.defineProperty(exports, "__esModule", { value: true });
3
36
  exports.showHUD = exports.PopToRootType = exports.showToast = exports.Toast = void 0;
4
37
  const crypto_1 = require("crypto");
5
38
  const bus_1 = require("./bus");
6
- const ui_1 = require("./proto/ui");
39
+ const ui = __importStar(require("./proto/ui"));
7
40
  /**
8
41
  * A Toast with a certain style, title, and message.
9
42
  *
@@ -27,9 +60,9 @@ class Toast {
27
60
  callbacks = {};
28
61
  id;
29
62
  styleMap = {
30
- [Toast.Style.Success]: ui_1.ToastStyle.Success,
31
- [Toast.Style.Failure]: ui_1.ToastStyle.Error,
32
- [Toast.Style.Animated]: ui_1.ToastStyle.Dynamic,
63
+ [Toast.Style.Success]: ui.ToastStyle.Success,
64
+ [Toast.Style.Failure]: ui.ToastStyle.Error,
65
+ [Toast.Style.Animated]: ui.ToastStyle.Dynamic,
33
66
  };
34
67
  /**
35
68
  * Deprecated - Use `showToast` instead
@@ -173,7 +206,16 @@ var PopToRootType;
173
206
  PopToRootType["Immediate"] = "immediate";
174
207
  PopToRootType["Suspended"] = "suspended";
175
208
  })(PopToRootType || (exports.PopToRootType = PopToRootType = {}));
209
+ const popToRootProtoMap = {
210
+ [PopToRootType.Default]: ui.PopToRootType.PopToRootDefault,
211
+ [PopToRootType.Immediate]: ui.PopToRootType.PopToRootImmediate,
212
+ [PopToRootType.Suspended]: ui.PopToRootType.PopToRootSuspended,
213
+ };
176
214
  const showHUD = async (title, options) => {
177
- await bus_1.bus.request("ui.show-hud", { title, options });
215
+ bus_1.bus.turboRequest('ui.showHud', {
216
+ text: title,
217
+ clearRootSearch: options?.clearRootSearch ?? false,
218
+ popToRoot: popToRootProtoMap[options?.popToRootType ?? PopToRootType.Default]
219
+ });
178
220
  };
179
221
  exports.showHUD = showHUD;
@@ -1,15 +1,9 @@
1
1
  import { PathLike } from "fs";
2
- export declare const captureException: (exception: unknown) => void;
2
+ import { Application } from "./proto/application";
3
3
  export declare const trash: (path: PathLike | PathLike[]) => Promise<void>;
4
4
  export declare const open: (target: string, app?: Application | string) => Promise<void>;
5
- export type Application = {
6
- id: string;
7
- name: string;
8
- icon: {
9
- iconName: string;
10
- };
11
- };
12
5
  export declare const getFrontmostApplication: () => Promise<Application>;
13
- export declare const getApplications: (path?: PathLike) => Promise<Application[]>;
14
- export declare const getDefaultApplication: (path: PathLike) => Promise<Application>;
15
- export declare const showInFinder: (path: PathLike) => Promise<void>;
6
+ export declare const getApplications: (target?: string) => Promise<Application[]>;
7
+ export declare const getDefaultApplication: (path: string) => Promise<Application>;
8
+ export declare const showInFileBrowser: (path: PathLike) => Promise<void>;
9
+ export { Application } from "./proto/application";
package/dist/api/utils.js CHANGED
@@ -1,13 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.showInFinder = exports.getDefaultApplication = exports.getApplications = exports.getFrontmostApplication = exports.open = exports.trash = exports.captureException = void 0;
3
+ exports.Application = exports.showInFileBrowser = exports.getDefaultApplication = exports.getApplications = exports.getFrontmostApplication = exports.open = exports.trash = void 0;
4
4
  const promises_1 = require("fs/promises");
5
5
  const bus_1 = require("./bus");
6
- const captureException = (exception) => {
7
- // maybe one day, if we have a developer hub, also...
8
- console.error("captureException called on", exception);
9
- };
10
- exports.captureException = captureException;
6
+ const window_management_1 = require("./window-management");
11
7
  // Linux systems usually do not have a trash, but maybe we should support one...
12
8
  const trash = async (path) => {
13
9
  const targets = Array.isArray(path) ? path : [path];
@@ -31,38 +27,31 @@ const open = async (target, app) => {
31
27
  });
32
28
  };
33
29
  exports.open = open;
34
- const deserializeApp = (app) => ({
35
- id: app.id,
36
- name: app.name,
37
- icon: { iconName: app.icon },
38
- });
39
30
  const getFrontmostApplication = async () => {
40
- const res = await bus_1.bus.request("apps.get-frontmost");
41
- if (!res.data.app) {
42
- throw new Error("couldnt get frontmost app");
31
+ const { application } = await window_management_1.WindowManagement.getActiveWindow();
32
+ if (!application) {
33
+ throw new Error(`Could not get frontmost application`);
43
34
  }
44
- return deserializeApp(res.data.app);
35
+ return application;
45
36
  };
46
37
  exports.getFrontmostApplication = getFrontmostApplication;
47
- const getApplications = async (path) => {
48
- const res = await bus_1.bus.turboRequest("app.list", {});
49
- if (!res.ok)
50
- return [];
51
- console.log("got turbo apps", { apps: res.value });
52
- return [];
38
+ const getApplications = async (target) => {
39
+ const res = await bus_1.bus.turboRequest("app.list", { target });
40
+ return res.unwrap().apps;
53
41
  };
54
42
  exports.getApplications = getApplications;
55
43
  const getDefaultApplication = async (path) => {
56
- const res = await bus_1.bus.request("apps.get-default", {
57
- target: path.toString(),
58
- });
59
- if (!res.data.app) {
60
- throw new Error("couldnt get default app");
61
- }
62
- return deserializeApp(res.data.app);
44
+ const res = await bus_1.bus.turboRequest('app.getDefault', { target: path });
45
+ const app = res.unwrap().app;
46
+ if (!app)
47
+ throw new Error(`No default application for target ${path}`);
48
+ return app;
63
49
  };
64
50
  exports.getDefaultApplication = getDefaultApplication;
65
- const showInFinder = async (path) => {
66
- await bus_1.bus.request("show-in-finder");
51
+ const showInFileBrowser = async (path) => {
52
+ const fileBrowser = await (0, exports.getDefaultApplication)("inode/directory"); // FIXME: we may want something more robust
53
+ await (0, exports.open)(path.toString(), fileBrowser);
67
54
  };
68
- exports.showInFinder = showInFinder;
55
+ exports.showInFileBrowser = showInFileBrowser;
56
+ var application_1 = require("./proto/application");
57
+ Object.defineProperty(exports, "Application", { enumerable: true, get: function () { return application_1.Application; } });
@@ -0,0 +1,39 @@
1
+ import { Application } from './proto/application';
2
+ import * as wm from './proto/wm';
3
+ export declare namespace WindowManagement {
4
+ type Window = {
5
+ id: string;
6
+ active: boolean;
7
+ bounds: {
8
+ position: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ size: {
13
+ height: number;
14
+ width: number;
15
+ };
16
+ };
17
+ workspaceId?: string;
18
+ application?: Application;
19
+ };
20
+ type Workspace = {
21
+ id: string;
22
+ name: string;
23
+ monitorId: string;
24
+ active: boolean;
25
+ };
26
+ }
27
+ /**
28
+ */
29
+ declare class WindowManagementImpl {
30
+ ping(): Promise<boolean>;
31
+ getWindows(options?: wm.GetWindowsRequest): Promise<WindowManagement.Window[]>;
32
+ getActiveWorkspace(): Promise<WindowManagement.Workspace>;
33
+ getWorkspaces(): Promise<WindowManagement.Workspace[]>;
34
+ getWindowsOnActiveWorkspace(): Promise<WindowManagement.Window[]>;
35
+ setWindowBounds(payload: wm.SetWindowBoundsRequest): Promise<void>;
36
+ getActiveWindow(): Promise<WindowManagement.Window>;
37
+ }
38
+ export declare const WindowManagement: WindowManagementImpl;
39
+ export {};
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.WindowManagement = void 0;
4
+ const bus_1 = require("./bus");
5
+ ;
6
+ const transformWorkspace = (proto) => {
7
+ return {
8
+ id: proto.id,
9
+ name: proto.name,
10
+ active: proto.active,
11
+ monitorId: proto.monitor
12
+ };
13
+ };
14
+ const transformWindow = (proto) => {
15
+ return {
16
+ id: proto.id,
17
+ workspaceId: proto.workspaceId,
18
+ active: proto.active,
19
+ bounds: { position: { x: proto.x, y: proto.y }, size: { width: proto.width, height: proto.height } },
20
+ application: proto.app
21
+ };
22
+ };
23
+ /**
24
+ */
25
+ class WindowManagementImpl {
26
+ async ping() {
27
+ const res = await bus_1.bus.turboRequest('wm.ping', {});
28
+ return res.unwrap().ok;
29
+ }
30
+ async getWindows(options = {}) {
31
+ const res = await bus_1.bus.turboRequest('wm.getWindows', options);
32
+ return res.unwrap().windows.map(transformWindow);
33
+ }
34
+ async getActiveWorkspace() {
35
+ const res = await bus_1.bus.turboRequest('wm.getActiveWorkspace', {});
36
+ return transformWorkspace(res.unwrap().workspace);
37
+ }
38
+ async getWorkspaces() {
39
+ const res = await bus_1.bus.turboRequest('wm.getWorkspaces', {});
40
+ return res.unwrap().workspaces.map(transformWorkspace);
41
+ }
42
+ async getWindowsOnActiveWorkspace() {
43
+ const workspace = await this.getActiveWorkspace();
44
+ return this.getWindows({ workspaceId: workspace.id });
45
+ }
46
+ async setWindowBounds(payload) {
47
+ await bus_1.bus.turboRequest('wm.setWindowBounds', payload);
48
+ }
49
+ async getActiveWindow() {
50
+ const res = await bus_1.bus.turboRequest('wm.getActiveWindow', {});
51
+ return transformWindow(res.unwrap().window);
52
+ }
53
+ }
54
+ ;
55
+ exports.WindowManagement = new WindowManagementImpl();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicinae/api",
3
- "version": "0.9.1",
3
+ "version": "0.9.2",
4
4
  "description": "TypeScript SDK to build Vicinae extensions",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",