@vicinae/api 0.19.4 → 0.19.5
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/api/proto/ui.d.ts +0 -1
- package/dist/api/proto/ui.js +3 -18
- package/dist/api/toast.d.ts +16 -20
- package/dist/api/toast.js +13 -43
- package/package.json +1 -1
package/dist/api/proto/ui.d.ts
CHANGED
package/dist/api/proto/ui.js
CHANGED
|
@@ -180,7 +180,7 @@ function imageMaskToJSON(object) {
|
|
|
180
180
|
}
|
|
181
181
|
}
|
|
182
182
|
function createBaseShowToastRequest() {
|
|
183
|
-
return { id: "", title: "",
|
|
183
|
+
return { id: "", title: "", style: 0 };
|
|
184
184
|
}
|
|
185
185
|
exports.ShowToastRequest = {
|
|
186
186
|
encode(message, writer = new wire_1.BinaryWriter()) {
|
|
@@ -190,11 +190,8 @@ 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
|
-
}
|
|
196
193
|
if (message.style !== 0) {
|
|
197
|
-
writer.uint32(
|
|
194
|
+
writer.uint32(24).int32(message.style);
|
|
198
195
|
}
|
|
199
196
|
return writer;
|
|
200
197
|
},
|
|
@@ -220,14 +217,7 @@ exports.ShowToastRequest = {
|
|
|
220
217
|
continue;
|
|
221
218
|
}
|
|
222
219
|
case 3: {
|
|
223
|
-
if (tag !==
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
message.message = reader.string();
|
|
227
|
-
continue;
|
|
228
|
-
}
|
|
229
|
-
case 4: {
|
|
230
|
-
if (tag !== 32) {
|
|
220
|
+
if (tag !== 24) {
|
|
231
221
|
break;
|
|
232
222
|
}
|
|
233
223
|
message.style = reader.int32();
|
|
@@ -245,7 +235,6 @@ exports.ShowToastRequest = {
|
|
|
245
235
|
return {
|
|
246
236
|
id: isSet(object.id) ? globalThis.String(object.id) : "",
|
|
247
237
|
title: isSet(object.title) ? globalThis.String(object.title) : "",
|
|
248
|
-
message: isSet(object.message) ? globalThis.String(object.message) : "",
|
|
249
238
|
style: isSet(object.style) ? toastStyleFromJSON(object.style) : 0,
|
|
250
239
|
};
|
|
251
240
|
},
|
|
@@ -257,9 +246,6 @@ exports.ShowToastRequest = {
|
|
|
257
246
|
if (message.title !== "") {
|
|
258
247
|
obj.title = message.title;
|
|
259
248
|
}
|
|
260
|
-
if (message.message !== "") {
|
|
261
|
-
obj.message = message.message;
|
|
262
|
-
}
|
|
263
249
|
if (message.style !== 0) {
|
|
264
250
|
obj.style = toastStyleToJSON(message.style);
|
|
265
251
|
}
|
|
@@ -272,7 +258,6 @@ exports.ShowToastRequest = {
|
|
|
272
258
|
const message = createBaseShowToastRequest();
|
|
273
259
|
message.id = object.id ?? "";
|
|
274
260
|
message.title = object.title ?? "";
|
|
275
|
-
message.message = object.message ?? "";
|
|
276
261
|
message.style = object.style ?? 0;
|
|
277
262
|
return message;
|
|
278
263
|
},
|
package/dist/api/toast.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { Keyboard } from "./keyboard";
|
|
2
2
|
/**
|
|
3
3
|
* A Toast with a certain style, title, and message.
|
|
4
4
|
*
|
|
@@ -46,6 +46,13 @@ 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);
|
|
49
56
|
update(): Promise<void>;
|
|
50
57
|
/**
|
|
51
58
|
* Shows the Toast.
|
|
@@ -100,6 +107,14 @@ export declare namespace Toast {
|
|
|
100
107
|
* The style of a Toast.
|
|
101
108
|
*/
|
|
102
109
|
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;
|
|
103
118
|
}
|
|
104
119
|
/**
|
|
105
120
|
* The options to create a {@link Toast} Action.
|
|
@@ -147,25 +162,6 @@ export declare interface ToastOptions extends Toast.Options {
|
|
|
147
162
|
*/
|
|
148
163
|
export declare const ToastStyle: typeof Toast.Style;
|
|
149
164
|
/**
|
|
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
|
-
*
|
|
169
165
|
* @category Toast
|
|
170
166
|
*/
|
|
171
167
|
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
|
|
37
|
+
const crypto_1 = require("crypto");
|
|
38
38
|
const bus_1 = require("./bus");
|
|
39
39
|
const ui = __importStar(require("./proto/ui"));
|
|
40
40
|
/**
|
|
@@ -70,29 +70,24 @@ class Toast {
|
|
|
70
70
|
* Deprecated - Use `showToast` instead
|
|
71
71
|
*/
|
|
72
72
|
constructor(props) {
|
|
73
|
-
this.id = `toast_${(0,
|
|
73
|
+
this.id = `toast_${(0, 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
|
-
/*
|
|
80
79
|
if (props.primaryAction) {
|
|
81
80
|
const { onAction } = props.primaryAction;
|
|
82
|
-
const { id } = bus.addEventHandler(() => onAction(this));
|
|
83
|
-
|
|
84
|
-
//this.options.primaryAction = props.primaryAction;
|
|
81
|
+
const { id } = bus_1.bus.addEventHandler(() => onAction(this));
|
|
82
|
+
this.options.primaryAction = props.primaryAction;
|
|
85
83
|
this.callbacks.primary = id;
|
|
86
84
|
}
|
|
87
|
-
|
|
88
85
|
if (props.secondaryAction) {
|
|
89
86
|
const { onAction } = props.secondaryAction;
|
|
90
|
-
const { id } = bus.addEventHandler(() => onAction(this));
|
|
91
|
-
|
|
92
|
-
//this.options.secondaryAction = props.secondaryAction;
|
|
87
|
+
const { id } = bus_1.bus.addEventHandler(() => onAction(this));
|
|
88
|
+
this.options.secondaryAction = props.secondaryAction;
|
|
93
89
|
this.callbacks.secondary = id;
|
|
94
90
|
}
|
|
95
|
-
*/
|
|
96
91
|
}
|
|
97
92
|
/**
|
|
98
93
|
* The style of a Toast.
|
|
@@ -126,25 +121,25 @@ class Toast {
|
|
|
126
121
|
/**
|
|
127
122
|
* The primary Action the user can take when hovering on the Toast.
|
|
128
123
|
*/
|
|
129
|
-
|
|
130
|
-
get primaryAction(): Toast.ActionOptions | undefined {
|
|
124
|
+
get primaryAction() {
|
|
131
125
|
return this.options.primaryAction;
|
|
132
126
|
}
|
|
133
|
-
set primaryAction(action
|
|
127
|
+
set primaryAction(action) {
|
|
134
128
|
this.options.primaryAction = action;
|
|
135
129
|
}
|
|
136
|
-
|
|
130
|
+
/**
|
|
131
|
+
* The secondary Action the user can take when hovering on the Toast.
|
|
132
|
+
*/
|
|
133
|
+
get secondaryAction() {
|
|
137
134
|
return this.options.secondaryAction;
|
|
138
135
|
}
|
|
139
|
-
set secondaryAction(action
|
|
136
|
+
set secondaryAction(action) {
|
|
140
137
|
this.options.secondaryAction = action;
|
|
141
138
|
}
|
|
142
|
-
*/
|
|
143
139
|
async update() {
|
|
144
140
|
await bus_1.bus.request("ui.showToast", {
|
|
145
141
|
id: this.id,
|
|
146
142
|
title: this.title,
|
|
147
|
-
message: this.message ?? '',
|
|
148
143
|
style: this.styleMap[this.style],
|
|
149
144
|
});
|
|
150
145
|
}
|
|
@@ -159,31 +154,25 @@ class Toast {
|
|
|
159
154
|
message: this.options.message,
|
|
160
155
|
style: this.options.style,
|
|
161
156
|
};
|
|
162
|
-
/*
|
|
163
157
|
if (this.options.primaryAction && this.callbacks.primary) {
|
|
164
158
|
const { title, shortcut } = this.options.primaryAction;
|
|
165
|
-
|
|
166
159
|
payload.primaryAction = {
|
|
167
160
|
title,
|
|
168
161
|
shortcut,
|
|
169
162
|
onAction: this.callbacks.primary,
|
|
170
163
|
};
|
|
171
164
|
}
|
|
172
|
-
|
|
173
165
|
if (this.options.secondaryAction && this.callbacks.secondary) {
|
|
174
166
|
const { title, shortcut } = this.options.secondaryAction;
|
|
175
|
-
|
|
176
167
|
payload.secondaryAction = {
|
|
177
168
|
title,
|
|
178
169
|
shortcut,
|
|
179
170
|
onAction: this.callbacks.secondary,
|
|
180
171
|
};
|
|
181
172
|
}
|
|
182
|
-
*/
|
|
183
173
|
await bus_1.bus.request("ui.showToast", {
|
|
184
174
|
id: this.id,
|
|
185
175
|
title: payload.title,
|
|
186
|
-
message: payload.message ?? '',
|
|
187
176
|
style: this.styleMap[payload.style ?? Toast.Style.Success],
|
|
188
177
|
});
|
|
189
178
|
}
|
|
@@ -217,25 +206,6 @@ exports.Toast = Toast;
|
|
|
217
206
|
})(Style = Toast.Style || (Toast.Style = {}));
|
|
218
207
|
})(Toast || (exports.Toast = Toast = {}));
|
|
219
208
|
/**
|
|
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
|
-
*
|
|
239
209
|
* @category Toast
|
|
240
210
|
*/
|
|
241
211
|
const showToast = async (init, title = "", message) => {
|