@vicinae/api 0.3.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 +37 -0
- package/bin/run.js +9 -0
- package/dist/api/ai.d.ts +110 -0
- package/dist/api/ai.js +120 -0
- package/dist/api/alert.d.ts +22 -0
- package/dist/api/alert.js +61 -0
- package/dist/api/bus.d.ts +95 -0
- package/dist/api/bus.js +211 -0
- package/dist/api/cache.d.ts +117 -0
- package/dist/api/cache.js +52 -0
- package/dist/api/clipboard.d.ts +34 -0
- package/dist/api/clipboard.js +52 -0
- package/dist/api/color.d.ts +24 -0
- package/dist/api/color.js +24 -0
- package/dist/api/components/action-pannel.d.ts +23 -0
- package/dist/api/components/action-pannel.js +30 -0
- package/dist/api/components/actions.d.ts +52 -0
- package/dist/api/components/actions.js +81 -0
- package/dist/api/components/detail.d.ts +21 -0
- package/dist/api/components/detail.js +12 -0
- package/dist/api/components/dropdown.d.ts +36 -0
- package/dist/api/components/dropdown.js +21 -0
- package/dist/api/components/empty-view.d.ts +9 -0
- package/dist/api/components/empty-view.js +12 -0
- package/dist/api/components/form.d.ts +81 -0
- package/dist/api/components/form.js +53 -0
- package/dist/api/components/grid.d.ts +117 -0
- package/dist/api/components/grid.js +80 -0
- package/dist/api/components/index.d.ts +7 -0
- package/dist/api/components/index.js +23 -0
- package/dist/api/components/list.d.ts +109 -0
- package/dist/api/components/list.js +53 -0
- package/dist/api/components/menu-bar.d.ts +26 -0
- package/dist/api/components/menu-bar.js +25 -0
- package/dist/api/components/metadata.d.ts +23 -0
- package/dist/api/components/metadata.js +27 -0
- package/dist/api/components/tag.d.ts +16 -0
- package/dist/api/components/tag.js +28 -0
- package/dist/api/context/index.d.ts +1 -0
- package/dist/api/context/index.js +17 -0
- package/dist/api/context/navigation-context.d.ts +7 -0
- package/dist/api/context/navigation-context.js +8 -0
- package/dist/api/context/navigation-provider.d.ts +4 -0
- package/dist/api/context/navigation-provider.js +40 -0
- package/dist/api/controls.d.ts +3 -0
- package/dist/api/controls.js +20 -0
- package/dist/api/environment.d.ts +118 -0
- package/dist/api/environment.js +17 -0
- package/dist/api/hooks/index.d.ts +2 -0
- package/dist/api/hooks/index.js +18 -0
- package/dist/api/hooks/use-applications.d.ts +2 -0
- package/dist/api/hooks/use-applications.js +19 -0
- package/dist/api/hooks/use-imperative-form-handle.d.ts +3 -0
- package/dist/api/hooks/use-imperative-form-handle.js +25 -0
- package/dist/api/hooks/use-navigation.d.ts +4 -0
- package/dist/api/hooks/use-navigation.js +13 -0
- package/dist/api/hooks.d.ts +1 -0
- package/dist/api/hooks.js +24 -0
- package/dist/api/icon.d.ts +444 -0
- package/dist/api/icon.js +448 -0
- package/dist/api/image.d.ts +35 -0
- package/dist/api/image.js +84 -0
- package/dist/api/index.d.ts +19 -0
- package/dist/api/index.js +35 -0
- package/dist/api/keyboard.d.ts +16 -0
- package/dist/api/keyboard.js +12 -0
- package/dist/api/lib/result.d.ts +9 -0
- package/dist/api/lib/result.js +11 -0
- package/dist/api/local-storage.d.ts +13 -0
- package/dist/api/local-storage.js +31 -0
- package/dist/api/oauth.d.ts +319 -0
- package/dist/api/oauth.js +166 -0
- package/dist/api/preference.d.ts +5 -0
- package/dist/api/preference.js +18 -0
- package/dist/api/proto/application.d.ts +48 -0
- package/dist/api/proto/application.js +378 -0
- package/dist/api/proto/clipboard.d.ts +65 -0
- package/dist/api/proto/clipboard.js +614 -0
- package/dist/api/proto/common.d.ts +28 -0
- package/dist/api/proto/common.js +102 -0
- package/dist/api/proto/extension.d.ts +68 -0
- package/dist/api/proto/extension.js +604 -0
- package/dist/api/proto/google/protobuf/struct.d.ts +107 -0
- package/dist/api/proto/google/protobuf/struct.js +456 -0
- package/dist/api/proto/ipc.d.ts +64 -0
- package/dist/api/proto/ipc.js +604 -0
- package/dist/api/proto/manager.d.ts +82 -0
- package/dist/api/proto/manager.js +689 -0
- package/dist/api/proto/oauth.d.ts +55 -0
- package/dist/api/proto/oauth.js +379 -0
- package/dist/api/proto/storage.d.ts +80 -0
- package/dist/api/proto/storage.js +804 -0
- package/dist/api/proto/ui.d.ts +186 -0
- package/dist/api/proto/ui.js +1993 -0
- package/dist/api/toast.d.ts +168 -0
- package/dist/api/toast.js +152 -0
- package/dist/api/utils.d.ts +15 -0
- package/dist/api/utils.js +64 -0
- package/dist/commands/build/index.d.ts +11 -0
- package/dist/commands/build/index.js +123 -0
- package/dist/commands/develop/index.d.ts +10 -0
- package/dist/commands/develop/index.js +193 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +17 -0
- package/dist/schemas/manifest.d.ts +75 -0
- package/dist/schemas/manifest.js +4 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.js +38 -0
- package/dist/utils/utils.d.ts +2 -0
- package/dist/utils/utils.js +19 -0
- package/dist/utils/vicinae.d.ts +12 -0
- package/dist/utils/vicinae.js +33 -0
- package/package.json +73 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { Keyboard } from "./keyboard";
|
|
2
|
+
/**
|
|
3
|
+
* A Toast with a certain style, title, and message.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* import { showToast, Toast } from "@raycast/api";
|
|
8
|
+
* import { setTimeout } from "timers/promises";
|
|
9
|
+
*
|
|
10
|
+
* export default async () => {
|
|
11
|
+
* const toast = await showToast({ style: Toast.Style.Animated, title: "Uploading image" });
|
|
12
|
+
*
|
|
13
|
+
* await setTimeout(1000);
|
|
14
|
+
*
|
|
15
|
+
* toast.style = Toast.Style.Success;
|
|
16
|
+
* toast.title = "Uploaded image";
|
|
17
|
+
* };
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class Toast {
|
|
21
|
+
private options;
|
|
22
|
+
private callbacks;
|
|
23
|
+
private id;
|
|
24
|
+
private styleMap;
|
|
25
|
+
/**
|
|
26
|
+
* Deprecated - Use `showToast` instead
|
|
27
|
+
*/
|
|
28
|
+
constructor(props: Toast.Options);
|
|
29
|
+
/**
|
|
30
|
+
* The style of a Toast.
|
|
31
|
+
*/
|
|
32
|
+
get style(): Toast.Style;
|
|
33
|
+
set style(style: Toast.Style);
|
|
34
|
+
/**
|
|
35
|
+
* The title of a Toast. Displayed on the top.
|
|
36
|
+
*/
|
|
37
|
+
get title(): string;
|
|
38
|
+
set title(title: string);
|
|
39
|
+
/**
|
|
40
|
+
* An additional message for the Toast. Useful to show more information, e.g. an identifier of a newly created asset.
|
|
41
|
+
*/
|
|
42
|
+
get message(): string | undefined;
|
|
43
|
+
set message(message: string | undefined);
|
|
44
|
+
/**
|
|
45
|
+
* The primary Action the user can take when hovering on the Toast.
|
|
46
|
+
*/
|
|
47
|
+
get primaryAction(): Toast.ActionOptions | undefined;
|
|
48
|
+
set primaryAction(action: Toast.ActionOptions | undefined);
|
|
49
|
+
/**
|
|
50
|
+
* The secondary Action the user can take when hovering on the Toast.
|
|
51
|
+
*/
|
|
52
|
+
get secondaryAction(): Toast.ActionOptions | undefined;
|
|
53
|
+
set secondaryAction(action: Toast.ActionOptions | undefined);
|
|
54
|
+
/**
|
|
55
|
+
* Shows the Toast.
|
|
56
|
+
*
|
|
57
|
+
* @returns A Promise that resolves when the toast is shown.
|
|
58
|
+
*/
|
|
59
|
+
show(): Promise<void>;
|
|
60
|
+
/**
|
|
61
|
+
* Hides the Toast.
|
|
62
|
+
*
|
|
63
|
+
* @returns A Promise that resolves when toast is hidden.
|
|
64
|
+
*/
|
|
65
|
+
hide(): Promise<void>;
|
|
66
|
+
private update;
|
|
67
|
+
}
|
|
68
|
+
export declare namespace Toast {
|
|
69
|
+
/**
|
|
70
|
+
* The options to create a {@link Toast}.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* ```typescript
|
|
74
|
+
* import { showToast, Toast } from "@raycast/api";
|
|
75
|
+
*
|
|
76
|
+
* export default async () => {
|
|
77
|
+
* const options: Toast.Options = {
|
|
78
|
+
* style: Toast.Style.Success,
|
|
79
|
+
* title: "Finished cooking",
|
|
80
|
+
* message: "Delicious pasta for lunch",
|
|
81
|
+
* primaryAction: {
|
|
82
|
+
* title: 'Do something',
|
|
83
|
+
* onAction: () => {
|
|
84
|
+
* console.log("The toast action has been triggered")
|
|
85
|
+
* }
|
|
86
|
+
* }
|
|
87
|
+
* };
|
|
88
|
+
* await showToast(options);
|
|
89
|
+
* };
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
interface Options {
|
|
93
|
+
/**
|
|
94
|
+
* The title of a Toast. Displayed on the top.
|
|
95
|
+
*/
|
|
96
|
+
title: string;
|
|
97
|
+
/**
|
|
98
|
+
* An additional message for the Toast. Useful to show more information, e.g. an identifier of a newly created asset.
|
|
99
|
+
*/
|
|
100
|
+
message?: string;
|
|
101
|
+
/**
|
|
102
|
+
* The style of a Toast.
|
|
103
|
+
*/
|
|
104
|
+
style?: Style;
|
|
105
|
+
/**
|
|
106
|
+
* The primary Action the user can take when hovering on the Toast.
|
|
107
|
+
*/
|
|
108
|
+
primaryAction?: ActionOptions;
|
|
109
|
+
/**
|
|
110
|
+
* The secondary Action the user can take when hovering on the Toast.
|
|
111
|
+
*/
|
|
112
|
+
secondaryAction?: ActionOptions;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The options to create a {@link Toast} Action.
|
|
116
|
+
*/
|
|
117
|
+
interface ActionOptions {
|
|
118
|
+
/**
|
|
119
|
+
* The title of the action.
|
|
120
|
+
*/
|
|
121
|
+
title: string;
|
|
122
|
+
/**
|
|
123
|
+
* The keyboard shortcut for the action.
|
|
124
|
+
*/
|
|
125
|
+
shortcut?: Keyboard.Shortcut;
|
|
126
|
+
/**
|
|
127
|
+
* A callback called when the action is triggered.
|
|
128
|
+
*/
|
|
129
|
+
onAction: (toast: Toast) => void;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Defines the visual style of the Toast.
|
|
133
|
+
*
|
|
134
|
+
* @remarks
|
|
135
|
+
* Use {@link Toast.Style.Success} for confirmations and {@link Toast.Style.Failure} for displaying errors.
|
|
136
|
+
* Use {@link Toast.Style.Animated} when your Toast should be shown until a process is completed.
|
|
137
|
+
* You can hide it later by using {@link Toast.hide} or update the properties of an existing Toast.
|
|
138
|
+
*/
|
|
139
|
+
enum Style {
|
|
140
|
+
Success = "success",
|
|
141
|
+
Failure = "failure",
|
|
142
|
+
Animated = "animated"
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated Use {@link Toast.ActionOptions} instead
|
|
147
|
+
*/
|
|
148
|
+
export declare interface ToastActionOptions extends Toast.ActionOptions {
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* @deprecated Use {@link Toast.Options} instead
|
|
152
|
+
*/
|
|
153
|
+
export declare interface ToastOptions extends Toast.Options {
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* @deprecated Use {@link Toast.Style} instead
|
|
157
|
+
*/
|
|
158
|
+
export declare const ToastStyle: typeof Toast.Style;
|
|
159
|
+
export declare const showToast: (init: Toast.Style | Toast.Options, title?: string, message?: string) => Promise<Toast>;
|
|
160
|
+
export declare enum PopToRootType {
|
|
161
|
+
Default = "default",
|
|
162
|
+
Immediate = "immediate",
|
|
163
|
+
Suspended = "suspended"
|
|
164
|
+
}
|
|
165
|
+
export declare const showHUD: (title: string, options?: {
|
|
166
|
+
clearRootSearch?: boolean;
|
|
167
|
+
popToRootType?: PopToRootType;
|
|
168
|
+
}) => Promise<void>;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showHUD = exports.PopToRootType = exports.showToast = exports.Toast = void 0;
|
|
4
|
+
const crypto_1 = require("crypto");
|
|
5
|
+
const bus_1 = require("./bus");
|
|
6
|
+
const ui_1 = require("./proto/ui");
|
|
7
|
+
/**
|
|
8
|
+
* A Toast with a certain style, title, and message.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* import { showToast, Toast } from "@raycast/api";
|
|
13
|
+
* import { setTimeout } from "timers/promises";
|
|
14
|
+
*
|
|
15
|
+
* export default async () => {
|
|
16
|
+
* const toast = await showToast({ style: Toast.Style.Animated, title: "Uploading image" });
|
|
17
|
+
*
|
|
18
|
+
* await setTimeout(1000);
|
|
19
|
+
*
|
|
20
|
+
* toast.style = Toast.Style.Success;
|
|
21
|
+
* toast.title = "Uploaded image";
|
|
22
|
+
* };
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
class Toast {
|
|
26
|
+
options;
|
|
27
|
+
callbacks = {};
|
|
28
|
+
id;
|
|
29
|
+
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
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Deprecated - Use `showToast` instead
|
|
36
|
+
*/
|
|
37
|
+
constructor(props) {
|
|
38
|
+
this.id = `toast_${(0, crypto_1.randomBytes)(16).toString('hex')}`;
|
|
39
|
+
this.options = {
|
|
40
|
+
title: props.title,
|
|
41
|
+
style: props.style ?? Toast.Style.Success,
|
|
42
|
+
message: props.message
|
|
43
|
+
};
|
|
44
|
+
if (props.primaryAction) {
|
|
45
|
+
const { onAction } = props.primaryAction;
|
|
46
|
+
this.options.primaryAction = props.primaryAction;
|
|
47
|
+
this.callbacks.primary = (0, bus_1.createHandler)(() => onAction(this));
|
|
48
|
+
}
|
|
49
|
+
if (props.secondaryAction) {
|
|
50
|
+
const { onAction } = props.secondaryAction;
|
|
51
|
+
this.options.secondaryAction = props.secondaryAction;
|
|
52
|
+
this.callbacks.secondary = (0, bus_1.createHandler)(() => onAction(this));
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The style of a Toast.
|
|
57
|
+
*/
|
|
58
|
+
get style() { return this.options.style; }
|
|
59
|
+
set style(style) { this.options.style = style; }
|
|
60
|
+
/**
|
|
61
|
+
* The title of a Toast. Displayed on the top.
|
|
62
|
+
*/
|
|
63
|
+
get title() { return this.options.title; }
|
|
64
|
+
set title(title) { this.options.title = title; }
|
|
65
|
+
/**
|
|
66
|
+
* An additional message for the Toast. Useful to show more information, e.g. an identifier of a newly created asset.
|
|
67
|
+
*/
|
|
68
|
+
get message() { return this.options.message; }
|
|
69
|
+
set message(message) { this.options.message = message; }
|
|
70
|
+
/**
|
|
71
|
+
* The primary Action the user can take when hovering on the Toast.
|
|
72
|
+
*/
|
|
73
|
+
get primaryAction() { return this.options.primaryAction; }
|
|
74
|
+
set primaryAction(action) { this.options.primaryAction = action; }
|
|
75
|
+
/**
|
|
76
|
+
* The secondary Action the user can take when hovering on the Toast.
|
|
77
|
+
*/
|
|
78
|
+
get secondaryAction() { return this.options.secondaryAction; }
|
|
79
|
+
set secondaryAction(action) { this.options.secondaryAction = action; }
|
|
80
|
+
/**
|
|
81
|
+
* Shows the Toast.
|
|
82
|
+
*
|
|
83
|
+
* @returns A Promise that resolves when the toast is shown.
|
|
84
|
+
*/
|
|
85
|
+
async show() {
|
|
86
|
+
const payload = {
|
|
87
|
+
title: this.options.title,
|
|
88
|
+
message: this.options.message,
|
|
89
|
+
style: this.options.style,
|
|
90
|
+
};
|
|
91
|
+
if (this.options.primaryAction && this.callbacks.primary) {
|
|
92
|
+
const { title, shortcut } = this.options.primaryAction;
|
|
93
|
+
payload.primaryAction = {
|
|
94
|
+
title, shortcut, onAction: this.callbacks.primary
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
if (this.options.secondaryAction && this.callbacks.secondary) {
|
|
98
|
+
const { title, shortcut } = this.options.secondaryAction;
|
|
99
|
+
payload.secondaryAction = {
|
|
100
|
+
title, shortcut, onAction: this.callbacks.secondary
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
await bus_1.bus.turboRequest('ui.showToast', {
|
|
104
|
+
id: this.id,
|
|
105
|
+
title: payload.title,
|
|
106
|
+
style: this.styleMap[payload.style ?? Toast.Style.Success]
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Hides the Toast.
|
|
111
|
+
*
|
|
112
|
+
* @returns A Promise that resolves when toast is hidden.
|
|
113
|
+
*/
|
|
114
|
+
async hide() {
|
|
115
|
+
await bus_1.bus.turboRequest('ui.hideToast', { id: this.id });
|
|
116
|
+
}
|
|
117
|
+
update;
|
|
118
|
+
}
|
|
119
|
+
exports.Toast = Toast;
|
|
120
|
+
(function (Toast) {
|
|
121
|
+
/**
|
|
122
|
+
* Defines the visual style of the Toast.
|
|
123
|
+
*
|
|
124
|
+
* @remarks
|
|
125
|
+
* Use {@link Toast.Style.Success} for confirmations and {@link Toast.Style.Failure} for displaying errors.
|
|
126
|
+
* Use {@link Toast.Style.Animated} when your Toast should be shown until a process is completed.
|
|
127
|
+
* You can hide it later by using {@link Toast.hide} or update the properties of an existing Toast.
|
|
128
|
+
*/
|
|
129
|
+
let Style;
|
|
130
|
+
(function (Style) {
|
|
131
|
+
Style["Success"] = "success";
|
|
132
|
+
Style["Failure"] = "failure";
|
|
133
|
+
Style["Animated"] = "animated";
|
|
134
|
+
})(Style = Toast.Style || (Toast.Style = {}));
|
|
135
|
+
})(Toast || (exports.Toast = Toast = {}));
|
|
136
|
+
const showToast = async (init, title = "", message) => {
|
|
137
|
+
const toast = typeof init === 'string' ? new Toast({ style: init, message, title }) : new Toast(init);
|
|
138
|
+
await toast.show();
|
|
139
|
+
return toast;
|
|
140
|
+
};
|
|
141
|
+
exports.showToast = showToast;
|
|
142
|
+
var PopToRootType;
|
|
143
|
+
(function (PopToRootType) {
|
|
144
|
+
PopToRootType["Default"] = "default";
|
|
145
|
+
PopToRootType["Immediate"] = "immediate";
|
|
146
|
+
PopToRootType["Suspended"] = "suspended";
|
|
147
|
+
})(PopToRootType || (exports.PopToRootType = PopToRootType = {}));
|
|
148
|
+
;
|
|
149
|
+
const showHUD = async (title, options) => {
|
|
150
|
+
await bus_1.bus.request('ui.show-hud', { title, options });
|
|
151
|
+
};
|
|
152
|
+
exports.showHUD = showHUD;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { PathLike } from 'fs';
|
|
2
|
+
export declare const captureException: (exception: unknown) => void;
|
|
3
|
+
export declare const trash: (path: PathLike | PathLike[]) => Promise<void>;
|
|
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
|
+
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>;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.showInFinder = exports.getDefaultApplication = exports.getApplications = exports.getFrontmostApplication = exports.open = exports.trash = exports.captureException = void 0;
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
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;
|
|
11
|
+
// Linux systems usually do not have a trash, but maybe we should support one...
|
|
12
|
+
const trash = async (path) => {
|
|
13
|
+
const targets = Array.isArray(path) ? path : [path];
|
|
14
|
+
const promises = targets.map((p) => (0, promises_1.rm)(p, { recursive: true }));
|
|
15
|
+
await Promise.all(promises);
|
|
16
|
+
};
|
|
17
|
+
exports.trash = trash;
|
|
18
|
+
const open = async (target, app) => {
|
|
19
|
+
let appId;
|
|
20
|
+
if (app) {
|
|
21
|
+
if (typeof app === 'string') {
|
|
22
|
+
appId = app;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
appId = app.id;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
await bus_1.bus.turboRequest('app.open', {
|
|
29
|
+
target,
|
|
30
|
+
appId
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
exports.open = open;
|
|
34
|
+
const deserializeApp = (app) => ({ id: app.id, name: app.name, icon: { iconName: app.icon } });
|
|
35
|
+
const getFrontmostApplication = async () => {
|
|
36
|
+
const res = await bus_1.bus.request('apps.get-frontmost');
|
|
37
|
+
if (!res.data.app) {
|
|
38
|
+
throw new Error('couldnt get frontmost app');
|
|
39
|
+
}
|
|
40
|
+
return deserializeApp(res.data.app);
|
|
41
|
+
};
|
|
42
|
+
exports.getFrontmostApplication = getFrontmostApplication;
|
|
43
|
+
const getApplications = async (path) => {
|
|
44
|
+
const res = await bus_1.bus.turboRequest('app.list', {});
|
|
45
|
+
if (!res.ok)
|
|
46
|
+
return [];
|
|
47
|
+
console.log('got turbo apps', { apps: res.value });
|
|
48
|
+
return [];
|
|
49
|
+
};
|
|
50
|
+
exports.getApplications = getApplications;
|
|
51
|
+
const getDefaultApplication = async (path) => {
|
|
52
|
+
const res = await bus_1.bus.request('apps.get-default', {
|
|
53
|
+
target: path.toString()
|
|
54
|
+
});
|
|
55
|
+
if (!res.data.app) {
|
|
56
|
+
throw new Error('couldnt get default app');
|
|
57
|
+
}
|
|
58
|
+
return deserializeApp(res.data.app);
|
|
59
|
+
};
|
|
60
|
+
exports.getDefaultApplication = getDefaultApplication;
|
|
61
|
+
const showInFinder = async (path) => {
|
|
62
|
+
await bus_1.bus.request('show-in-finder');
|
|
63
|
+
};
|
|
64
|
+
exports.showInFinder = showInFinder;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class Build extends Command {
|
|
3
|
+
static args: {};
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
out: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
src: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
};
|
|
10
|
+
run(): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
const core_1 = require("@oclif/core");
|
|
40
|
+
const esbuild = __importStar(require("esbuild"));
|
|
41
|
+
const node_child_process_1 = require("node:child_process");
|
|
42
|
+
const node_fs_1 = require("node:fs");
|
|
43
|
+
const node_path_1 = require("node:path");
|
|
44
|
+
const logger_js_1 = require("../../utils/logger.js");
|
|
45
|
+
const utils_js_1 = require("../../utils/utils.js");
|
|
46
|
+
const manifest_js_1 = __importDefault(require("../../schemas/manifest.js"));
|
|
47
|
+
class Build extends core_1.Command {
|
|
48
|
+
static args = {};
|
|
49
|
+
static description = "Start an extension development session";
|
|
50
|
+
static examples = [
|
|
51
|
+
`<%= config.bin %> <%= command.id %> --target /path/to/extension`,
|
|
52
|
+
];
|
|
53
|
+
static flags = {
|
|
54
|
+
out: core_1.Flags.string({
|
|
55
|
+
aliases: ["output"],
|
|
56
|
+
char: "o",
|
|
57
|
+
description: "Path to output the compiled extension bundle to. Defaults to Vicinae extension directory.",
|
|
58
|
+
required: false,
|
|
59
|
+
}),
|
|
60
|
+
src: core_1.Flags.string({
|
|
61
|
+
aliases: ["src"],
|
|
62
|
+
char: "s",
|
|
63
|
+
default: process.cwd(),
|
|
64
|
+
defaultHelp: "The current working directory",
|
|
65
|
+
description: "Path to the extension source directory",
|
|
66
|
+
required: false,
|
|
67
|
+
}),
|
|
68
|
+
};
|
|
69
|
+
async run() {
|
|
70
|
+
const { flags } = await this.parse(Build);
|
|
71
|
+
const logger = new logger_js_1.Logger();
|
|
72
|
+
const src = flags.src ?? process.cwd();
|
|
73
|
+
const pkgPath = (0, node_path_1.join)(src, "package.json");
|
|
74
|
+
if (!(0, node_fs_1.existsSync)(pkgPath)) {
|
|
75
|
+
logger.logError(`No package.json found at ${pkgPath}. Does this location point to a valid extension repository?`);
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
const json = JSON.parse((0, node_fs_1.readFileSync)(pkgPath, 'utf8'));
|
|
79
|
+
const e = manifest_js_1.default.safeParse(json);
|
|
80
|
+
if (e.error) {
|
|
81
|
+
logger.logError(`${pkgPath} is not a valid extension manifest: ${e.error}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
const manifest = e.data;
|
|
85
|
+
const outDir = flags.out ?? (0, node_path_1.join)((0, utils_js_1.extensionDataDir)(), manifest.name);
|
|
86
|
+
const build = async (outDir) => {
|
|
87
|
+
const entryPoints = manifest.commands.map((cmd) => (0, node_path_1.join)("src", `${cmd.name}.tsx`));
|
|
88
|
+
logger.logInfo(`entrypoints [${entryPoints.join(", ")}]`);
|
|
89
|
+
const promises = manifest.commands.map((cmd) => {
|
|
90
|
+
const source = (0, node_path_1.join)(process.cwd(), "src", `${cmd.name}.tsx`);
|
|
91
|
+
return esbuild.build({
|
|
92
|
+
bundle: true,
|
|
93
|
+
entryPoints: [source],
|
|
94
|
+
external: ["react", "@vicinae/api"],
|
|
95
|
+
format: "cjs",
|
|
96
|
+
outfile: (0, node_path_1.join)(outDir, `${cmd.name}.js`),
|
|
97
|
+
platform: "node",
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
await Promise.all(promises);
|
|
101
|
+
const targetPkg = (0, node_path_1.join)(outDir, "package.json");
|
|
102
|
+
const targetAssets = (0, node_path_1.join)(outDir, "assets");
|
|
103
|
+
(0, node_fs_1.cpSync)("package.json", targetPkg, { force: true });
|
|
104
|
+
if ((0, node_fs_1.existsSync)("assets")) {
|
|
105
|
+
(0, node_fs_1.cpSync)("assets", targetAssets, { force: true, recursive: true });
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
(0, node_fs_1.mkdirSync)(targetAssets, { recursive: true });
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
process.chdir(src);
|
|
112
|
+
logger.logInfo("Checking types...");
|
|
113
|
+
const typeCheck = (0, node_child_process_1.spawnSync)("npx", ["tsc", "--noEmit"]);
|
|
114
|
+
if (typeCheck.error) {
|
|
115
|
+
logger.logError(`Type check failed: ${typeCheck.error}`);
|
|
116
|
+
process.exit(1);
|
|
117
|
+
}
|
|
118
|
+
(0, node_fs_1.mkdirSync)(outDir, { recursive: true });
|
|
119
|
+
await build(outDir);
|
|
120
|
+
logger.logReady(`built extension successfully - output at ${outDir}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
exports.default = Build;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Command } from "@oclif/core";
|
|
2
|
+
export default class Develop extends Command {
|
|
3
|
+
static args: {};
|
|
4
|
+
static description: string;
|
|
5
|
+
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
target: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
9
|
+
run(): Promise<void>;
|
|
10
|
+
}
|