@vicinae/api 0.19.3 → 0.19.4

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.
@@ -38,6 +38,7 @@ export declare function imageMaskToJSON(object: ImageMask): string;
38
38
  export interface ShowToastRequest {
39
39
  id: string;
40
40
  title: string;
41
+ message: string;
41
42
  style: ToastStyle;
42
43
  }
43
44
  export interface HideToastRequest {
@@ -180,7 +180,7 @@ function imageMaskToJSON(object) {
180
180
  }
181
181
  }
182
182
  function createBaseShowToastRequest() {
183
- return { id: "", title: "", style: 0 };
183
+ return { id: "", title: "", message: "", style: 0 };
184
184
  }
185
185
  exports.ShowToastRequest = {
186
186
  encode(message, writer = new wire_1.BinaryWriter()) {
@@ -190,8 +190,11 @@ exports.ShowToastRequest = {
190
190
  if (message.title !== "") {
191
191
  writer.uint32(18).string(message.title);
192
192
  }
193
+ if (message.message !== "") {
194
+ writer.uint32(26).string(message.message);
195
+ }
193
196
  if (message.style !== 0) {
194
- writer.uint32(24).int32(message.style);
197
+ writer.uint32(32).int32(message.style);
195
198
  }
196
199
  return writer;
197
200
  },
@@ -217,7 +220,14 @@ exports.ShowToastRequest = {
217
220
  continue;
218
221
  }
219
222
  case 3: {
220
- if (tag !== 24) {
223
+ if (tag !== 26) {
224
+ break;
225
+ }
226
+ message.message = reader.string();
227
+ continue;
228
+ }
229
+ case 4: {
230
+ if (tag !== 32) {
221
231
  break;
222
232
  }
223
233
  message.style = reader.int32();
@@ -235,6 +245,7 @@ exports.ShowToastRequest = {
235
245
  return {
236
246
  id: isSet(object.id) ? globalThis.String(object.id) : "",
237
247
  title: isSet(object.title) ? globalThis.String(object.title) : "",
248
+ message: isSet(object.message) ? globalThis.String(object.message) : "",
238
249
  style: isSet(object.style) ? toastStyleFromJSON(object.style) : 0,
239
250
  };
240
251
  },
@@ -246,6 +257,9 @@ exports.ShowToastRequest = {
246
257
  if (message.title !== "") {
247
258
  obj.title = message.title;
248
259
  }
260
+ if (message.message !== "") {
261
+ obj.message = message.message;
262
+ }
249
263
  if (message.style !== 0) {
250
264
  obj.style = toastStyleToJSON(message.style);
251
265
  }
@@ -258,6 +272,7 @@ exports.ShowToastRequest = {
258
272
  const message = createBaseShowToastRequest();
259
273
  message.id = object.id ?? "";
260
274
  message.title = object.title ?? "";
275
+ message.message = object.message ?? "";
261
276
  message.style = object.style ?? 0;
262
277
  return message;
263
278
  },
@@ -1,4 +1,4 @@
1
- import { Keyboard } from "./keyboard";
1
+ import type { Keyboard } from "./keyboard";
2
2
  /**
3
3
  * A Toast with a certain style, title, and message.
4
4
  *
@@ -46,13 +46,6 @@ export declare class Toast {
46
46
  /**
47
47
  * The primary Action the user can take when hovering on the Toast.
48
48
  */
49
- get primaryAction(): Toast.ActionOptions | undefined;
50
- set primaryAction(action: Toast.ActionOptions | undefined);
51
- /**
52
- * The secondary Action the user can take when hovering on the Toast.
53
- */
54
- get secondaryAction(): Toast.ActionOptions | undefined;
55
- set secondaryAction(action: Toast.ActionOptions | undefined);
56
49
  update(): Promise<void>;
57
50
  /**
58
51
  * Shows the Toast.
@@ -107,14 +100,6 @@ export declare namespace Toast {
107
100
  * The style of a Toast.
108
101
  */
109
102
  style?: Style;
110
- /**
111
- * The primary Action the user can take when hovering on the Toast.
112
- */
113
- primaryAction?: ActionOptions;
114
- /**
115
- * The secondary Action the user can take when hovering on the Toast.
116
- */
117
- secondaryAction?: ActionOptions;
118
103
  }
119
104
  /**
120
105
  * The options to create a {@link Toast} Action.
@@ -162,6 +147,25 @@ export declare interface ToastOptions extends Toast.Options {
162
147
  */
163
148
  export declare const ToastStyle: typeof Toast.Style;
164
149
  /**
150
+ * Show a toast notification on the bottom left of the Vicinae window, briefly replacing the navigation title.
151
+ * Toast can have different style depending on the nature of the notification, and can even use `Toast.Style.Animated`
152
+ * to display a loading spinner and refresh the title in realtime.
153
+ *
154
+ * @example
155
+ * ```typescript
156
+ * import { showToast, Toast } from "@raycast/api";
157
+ * import { setTimeout } from "timers/promises";
158
+ *
159
+ * export default async () => {
160
+ * const toast = await showToast({ style: Toast.Style.Animated, title: "Uploading image" });
161
+ *
162
+ * await setTimeout(1000);
163
+ *
164
+ * toast.style = Toast.Style.Success;
165
+ * toast.title = "Uploaded image";
166
+ * };
167
+ * ```
168
+ *
165
169
  * @category Toast
166
170
  */
167
171
  export declare const showToast: (init: Toast.Style | Toast.Options, title?: string, message?: string) => Promise<Toast>;
package/dist/api/toast.js CHANGED
@@ -34,7 +34,7 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.showToast = exports.Toast = void 0;
37
- const crypto_1 = require("crypto");
37
+ const node_crypto_1 = require("node:crypto");
38
38
  const bus_1 = require("./bus");
39
39
  const ui = __importStar(require("./proto/ui"));
40
40
  /**
@@ -70,24 +70,29 @@ class Toast {
70
70
  * Deprecated - Use `showToast` instead
71
71
  */
72
72
  constructor(props) {
73
- this.id = `toast_${(0, crypto_1.randomBytes)(16).toString("hex")}`;
73
+ this.id = `toast_${(0, node_crypto_1.randomBytes)(16).toString("hex")}`;
74
74
  this.options = {
75
75
  title: props.title,
76
76
  style: props.style ?? Toast.Style.Success,
77
77
  message: props.message,
78
78
  };
79
+ /*
79
80
  if (props.primaryAction) {
80
81
  const { onAction } = props.primaryAction;
81
- const { id } = bus_1.bus.addEventHandler(() => onAction(this));
82
- this.options.primaryAction = props.primaryAction;
82
+ const { id } = bus.addEventHandler(() => onAction(this));
83
+
84
+ //this.options.primaryAction = props.primaryAction;
83
85
  this.callbacks.primary = id;
84
86
  }
87
+
85
88
  if (props.secondaryAction) {
86
89
  const { onAction } = props.secondaryAction;
87
- const { id } = bus_1.bus.addEventHandler(() => onAction(this));
88
- this.options.secondaryAction = props.secondaryAction;
90
+ const { id } = bus.addEventHandler(() => onAction(this));
91
+
92
+ //this.options.secondaryAction = props.secondaryAction;
89
93
  this.callbacks.secondary = id;
90
94
  }
95
+ */
91
96
  }
92
97
  /**
93
98
  * The style of a Toast.
@@ -121,25 +126,25 @@ class Toast {
121
126
  /**
122
127
  * The primary Action the user can take when hovering on the Toast.
123
128
  */
124
- get primaryAction() {
129
+ /*
130
+ get primaryAction(): Toast.ActionOptions | undefined {
125
131
  return this.options.primaryAction;
126
132
  }
127
- set primaryAction(action) {
133
+ set primaryAction(action: Toast.ActionOptions | undefined) {
128
134
  this.options.primaryAction = action;
129
135
  }
130
- /**
131
- * The secondary Action the user can take when hovering on the Toast.
132
- */
133
- get secondaryAction() {
136
+ get secondaryAction(): Toast.ActionOptions | undefined {
134
137
  return this.options.secondaryAction;
135
138
  }
136
- set secondaryAction(action) {
139
+ set secondaryAction(action: Toast.ActionOptions | undefined) {
137
140
  this.options.secondaryAction = action;
138
141
  }
142
+ */
139
143
  async update() {
140
144
  await bus_1.bus.request("ui.showToast", {
141
145
  id: this.id,
142
146
  title: this.title,
147
+ message: this.message ?? '',
143
148
  style: this.styleMap[this.style],
144
149
  });
145
150
  }
@@ -154,25 +159,31 @@ class Toast {
154
159
  message: this.options.message,
155
160
  style: this.options.style,
156
161
  };
162
+ /*
157
163
  if (this.options.primaryAction && this.callbacks.primary) {
158
164
  const { title, shortcut } = this.options.primaryAction;
165
+
159
166
  payload.primaryAction = {
160
167
  title,
161
168
  shortcut,
162
169
  onAction: this.callbacks.primary,
163
170
  };
164
171
  }
172
+
165
173
  if (this.options.secondaryAction && this.callbacks.secondary) {
166
174
  const { title, shortcut } = this.options.secondaryAction;
175
+
167
176
  payload.secondaryAction = {
168
177
  title,
169
178
  shortcut,
170
179
  onAction: this.callbacks.secondary,
171
180
  };
172
181
  }
182
+ */
173
183
  await bus_1.bus.request("ui.showToast", {
174
184
  id: this.id,
175
185
  title: payload.title,
186
+ message: payload.message ?? '',
176
187
  style: this.styleMap[payload.style ?? Toast.Style.Success],
177
188
  });
178
189
  }
@@ -206,6 +217,25 @@ exports.Toast = Toast;
206
217
  })(Style = Toast.Style || (Toast.Style = {}));
207
218
  })(Toast || (exports.Toast = Toast = {}));
208
219
  /**
220
+ * Show a toast notification on the bottom left of the Vicinae window, briefly replacing the navigation title.
221
+ * Toast can have different style depending on the nature of the notification, and can even use `Toast.Style.Animated`
222
+ * to display a loading spinner and refresh the title in realtime.
223
+ *
224
+ * @example
225
+ * ```typescript
226
+ * import { showToast, Toast } from "@raycast/api";
227
+ * import { setTimeout } from "timers/promises";
228
+ *
229
+ * export default async () => {
230
+ * const toast = await showToast({ style: Toast.Style.Animated, title: "Uploading image" });
231
+ *
232
+ * await setTimeout(1000);
233
+ *
234
+ * toast.style = Toast.Style.Success;
235
+ * toast.title = "Uploaded image";
236
+ * };
237
+ * ```
238
+ *
209
239
  * @category Toast
210
240
  */
211
241
  const showToast = async (init, title = "", message) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vicinae/api",
3
- "version": "0.19.3",
3
+ "version": "0.19.4",
4
4
  "description": "TypeScript SDK to build Vicinae extensions",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1",