@domicile-desktop/sdk 0.0.0-alpha-e1457b57e6b2 → 0.0.0-alpha-e2ddcb67524d

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/dist/portal.d.ts CHANGED
@@ -45,6 +45,12 @@ export declare enum PortalKind {
45
45
  /** A kind this SDK cannot parse. Answer it with {@link PortalAnswer.Refused}. */
46
46
  Unknown = 15
47
47
  }
48
+ /**
49
+ * The {@link PortalRequestBase.appId} of a dialog the shell asked for itself,
50
+ * such as the one `system(host).screenshot()` puts up. No application can have
51
+ * it.
52
+ */
53
+ export declare const SHELL_APP_ID = "domicile:shell";
48
54
  /** What every request carries. */
49
55
  export type PortalRequestBase = {
50
56
  /** The id {@link answerPortalRequest} takes. */
package/dist/portal.js CHANGED
@@ -53,6 +53,12 @@ export var PortalKind;
53
53
  /** A kind this SDK cannot parse. Answer it with {@link PortalAnswer.Refused}. */
54
54
  PortalKind[PortalKind["Unknown"] = 15] = "Unknown";
55
55
  })(PortalKind || (PortalKind = {}));
56
+ /**
57
+ * The {@link PortalRequestBase.appId} of a dialog the shell asked for itself,
58
+ * such as the one `system(host).screenshot()` puts up. No application can have
59
+ * it.
60
+ */
61
+ export const SHELL_APP_ID = "domicile:shell";
56
62
  /** Which `FileChooser` method asked. */
57
63
  export var FileChooserMode;
58
64
  (function (FileChooserMode) {
@@ -33,10 +33,14 @@ declare const systemReplySchema: z.ZodObject<{
33
33
  signature: z.ZodString;
34
34
  }, z.core.$loose>, z.ZodObject<{
35
35
  kind: z.ZodLiteral<"started">;
36
+ }, z.core.$loose>, z.ZodObject<{
37
+ kind: z.ZodLiteral<"saved">;
38
+ path: z.ZodString;
36
39
  }, z.core.$loose>, z.ZodObject<{
37
40
  error: z.ZodObject<{
38
41
  kind: z.ZodEnum<{
39
42
  already_exists: "already_exists";
43
+ canceled: "canceled";
40
44
  dbus: "dbus";
41
45
  invalid_input: "invalid_input";
42
46
  is_a_directory: "is_a_directory";
@@ -86,6 +90,7 @@ declare const systemEndSchema: z.ZodObject<{
86
90
  error: z.ZodObject<{
87
91
  kind: z.ZodEnum<{
88
92
  already_exists: "already_exists";
93
+ canceled: "canceled";
89
94
  dbus: "dbus";
90
95
  invalid_input: "invalid_input";
91
96
  is_a_directory: "is_a_directory";
@@ -136,10 +141,14 @@ declare const systemMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
136
141
  signature: z.ZodString;
137
142
  }, z.core.$loose>, z.ZodObject<{
138
143
  kind: z.ZodLiteral<"started">;
144
+ }, z.core.$loose>, z.ZodObject<{
145
+ kind: z.ZodLiteral<"saved">;
146
+ path: z.ZodString;
139
147
  }, z.core.$loose>, z.ZodObject<{
140
148
  error: z.ZodObject<{
141
149
  kind: z.ZodEnum<{
142
150
  already_exists: "already_exists";
151
+ canceled: "canceled";
143
152
  dbus: "dbus";
144
153
  invalid_input: "invalid_input";
145
154
  is_a_directory: "is_a_directory";
@@ -187,6 +196,7 @@ declare const systemMessageSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
187
196
  error: z.ZodObject<{
188
197
  kind: z.ZodEnum<{
189
198
  already_exists: "already_exists";
199
+ canceled: "canceled";
190
200
  dbus: "dbus";
191
201
  invalid_input: "invalid_input";
192
202
  is_a_directory: "is_a_directory";
@@ -13,6 +13,7 @@ const systemErrorSchema = z.looseObject({
13
13
  "invalid_input",
14
14
  "locked",
15
15
  "dbus",
16
+ "canceled",
16
17
  "other",
17
18
  ]),
18
19
  message: z.string(),
@@ -40,6 +41,7 @@ const systemReplySchema = z.looseObject({
40
41
  signature: z.string(),
41
42
  }),
42
43
  z.looseObject({ kind: z.literal("started") }),
44
+ z.looseObject({ kind: z.literal("saved"), path: z.string() }),
43
45
  z.looseObject({ error: systemErrorSchema, kind: z.literal("failed") }),
44
46
  ]),
45
47
  type: z.literal("system_reply"),
package/dist/system.d.ts CHANGED
@@ -13,7 +13,9 @@ export declare enum SystemErrorKind {
13
13
  Locked = 6,
14
14
  /** A D-Bus method returned an error; the message starts with its name. */
15
15
  Dbus = 7,
16
- Other = 8
16
+ /** The user dismissed the dialog the call put up. */
17
+ Canceled = 8,
18
+ Other = 9
17
19
  }
18
20
  export type SystemError = {
19
21
  kind: SystemErrorKind;
@@ -144,6 +146,13 @@ export type System = {
144
146
  run: (argv: readonly string[], options?: Omit<SpawnOptions, "stdin">) => Promise<Result<Ran, SystemError>>;
145
147
  dbusCall: (call: DbusCall) => Promise<Result<DbusBody, SystemError>>;
146
148
  dbusMatch: (match: DbusMatch) => Promise<Result<Listening<DbusSignal>, SystemError>>;
149
+ /**
150
+ * Take a screenshot as an interactive Screenshot portal call takes one, as
151
+ * if the shell were the application: the desk freezes, `<PortalDialogs />`
152
+ * draws the screenshot dialog, and the area picked is saved under
153
+ * `$XDG_PICTURES_DIR/Screenshots/`. Resolves with the saved PNG's path.
154
+ */
155
+ screenshot: () => Promise<Result<string, SystemError>>;
147
156
  };
148
157
  /** What {@link system} needs of the desktop `Shell` is handed. */
149
158
  export type SystemHost = Pick<DomicileHost, "callSystem"> & {
package/dist/system.js CHANGED
@@ -21,7 +21,9 @@ export var SystemErrorKind;
21
21
  SystemErrorKind[SystemErrorKind["Locked"] = 6] = "Locked";
22
22
  /** A D-Bus method returned an error; the message starts with its name. */
23
23
  SystemErrorKind[SystemErrorKind["Dbus"] = 7] = "Dbus";
24
- SystemErrorKind[SystemErrorKind["Other"] = 8] = "Other";
24
+ /** The user dismissed the dialog the call put up. */
25
+ SystemErrorKind[SystemErrorKind["Canceled"] = 8] = "Canceled";
26
+ SystemErrorKind[SystemErrorKind["Other"] = 9] = "Other";
25
27
  })(SystemErrorKind || (SystemErrorKind = {}));
26
28
  export var FileType;
27
29
  (function (FileType) {
@@ -94,6 +96,7 @@ export const system = (host) => {
94
96
  ]);
95
97
  return exited.map((exit) => ({ ...exit, stderr, stdout }));
96
98
  }),
99
+ screenshot: () => oneShot(calls, { call: "screenshot" }, (reply) => reply.kind === "saved" ? reply.path : unexpected(reply)),
97
100
  spawn: (argv, options) => spawn(calls, argv, options),
98
101
  stat: (path) => oneShot(calls, { call: "stat", path }, (reply) => reply.kind === "stat"
99
102
  ? {
@@ -350,6 +353,9 @@ const errorKind = (kind) => {
350
353
  case "dbus": {
351
354
  return SystemErrorKind.Dbus;
352
355
  }
356
+ case "canceled": {
357
+ return SystemErrorKind.Canceled;
358
+ }
353
359
  case "other": {
354
360
  return SystemErrorKind.Other;
355
361
  }
package/package.json CHANGED
@@ -100,7 +100,7 @@
100
100
  "test:unit": "bun test"
101
101
  },
102
102
  "type": "module",
103
- "version": "0.0.0-alpha-e1457b57e6b2",
103
+ "version": "0.0.0-alpha-e2ddcb67524d",
104
104
  "repository": {
105
105
  "type": "git",
106
106
  "url": "git+https://github.com/cprussin/domicile.git",