@vicinae/api 0.6.2 → 0.7.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 +1 -1
- package/bin/run.js +2 -2
- package/dist/api/ai.js +11 -10
- package/dist/api/alert.d.ts +1 -1
- package/dist/api/alert.js +4 -5
- package/dist/api/bus.d.ts +27 -27
- package/dist/api/bus.js +15 -15
- package/dist/api/cache.js +15 -6
- package/dist/api/clipboard.d.ts +2 -2
- package/dist/api/clipboard.js +14 -15
- package/dist/api/color.js +1 -3
- package/dist/api/components/action-pannel.js +2 -2
- package/dist/api/components/actions.d.ts +3 -3
- package/dist/api/components/actions.js +16 -16
- package/dist/api/components/detail.d.ts +1 -1
- package/dist/api/components/detail.js +1 -1
- package/dist/api/components/dropdown.js +3 -3
- package/dist/api/components/empty-view.d.ts +2 -2
- package/dist/api/components/empty-view.js +1 -1
- package/dist/api/components/form.d.ts +2 -2
- package/dist/api/components/form.js +4 -12
- package/dist/api/components/grid.d.ts +4 -4
- package/dist/api/components/grid.js +10 -10
- package/dist/api/components/index.d.ts +7 -7
- package/dist/api/components/list.d.ts +3 -3
- package/dist/api/components/list.js +6 -6
- package/dist/api/components/menu-bar.js +1 -1
- package/dist/api/components/metadata.d.ts +2 -2
- package/dist/api/components/metadata.js +1 -1
- package/dist/api/components/tag.d.ts +3 -3
- package/dist/api/components/tag.js +4 -3
- package/dist/api/context/index.d.ts +1 -1
- package/dist/api/context/navigation-context.js +6 -2
- package/dist/api/context/navigation-provider.d.ts +1 -1
- package/dist/api/context/navigation-provider.js +5 -5
- package/dist/api/controls.js +3 -3
- package/dist/api/environment.js +0 -2
- package/dist/api/hooks/index.d.ts +2 -2
- package/dist/api/hooks/use-imperative-form-handle.d.ts +2 -2
- package/dist/api/hooks/use-imperative-form-handle.js +3 -3
- package/dist/api/hooks.js +4 -2
- package/dist/api/image.d.ts +1 -1
- package/dist/api/image.js +5 -5
- package/dist/api/index.d.ts +19 -19
- package/dist/api/keyboard.js +4 -5
- package/dist/api/local-storage.js +5 -7
- package/dist/api/oauth.d.ts +1 -1
- package/dist/api/oauth.js +23 -20
- package/dist/api/preference.js +2 -2
- package/dist/api/proto/application.js +28 -13
- package/dist/api/proto/clipboard.js +70 -37
- package/dist/api/proto/common.js +5 -1
- package/dist/api/proto/extension.js +104 -49
- package/dist/api/proto/google/protobuf/struct.js +25 -8
- package/dist/api/proto/ipc.js +99 -52
- package/dist/api/proto/manager.js +56 -22
- package/dist/api/proto/oauth.js +32 -14
- package/dist/api/proto/storage.js +66 -28
- package/dist/api/proto/ui.js +233 -124
- package/dist/api/toast.js +46 -21
- package/dist/api/utils.d.ts +1 -1
- package/dist/api/utils.js +16 -12
- package/dist/commands/build/index.js +18 -2
- package/dist/commands/develop/index.js +18 -3
- package/dist/index.d.ts +1 -1
- package/dist/schemas/manifest.js +225 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/bin/run.js
CHANGED
package/dist/api/ai.js
CHANGED
|
@@ -37,13 +37,14 @@ var AI;
|
|
|
37
37
|
*/
|
|
38
38
|
function ask(prompt, options) {
|
|
39
39
|
const handlerId = (0, crypto_1.randomUUID)();
|
|
40
|
-
const emitter = new stream_1.EventEmitter;
|
|
40
|
+
const emitter = new stream_1.EventEmitter();
|
|
41
41
|
const promise = new Promise((resolve, reject) => {
|
|
42
|
-
let answer =
|
|
43
|
-
bus_1.bus
|
|
42
|
+
let answer = "";
|
|
43
|
+
bus_1.bus
|
|
44
|
+
.request("ai.create-completion", {
|
|
44
45
|
prompt,
|
|
45
46
|
options,
|
|
46
|
-
callback: handlerId
|
|
47
|
+
callback: handlerId,
|
|
47
48
|
})
|
|
48
49
|
.then(({ data }) => {
|
|
49
50
|
if (!data.started) {
|
|
@@ -52,24 +53,24 @@ var AI;
|
|
|
52
53
|
const { unsubscribe } = bus_1.bus.subscribe(handlerId, (...args) => {
|
|
53
54
|
const data = args[0];
|
|
54
55
|
answer += data.token;
|
|
55
|
-
emitter.emit(
|
|
56
|
+
emitter.emit("data", data.token);
|
|
56
57
|
if (data.done) {
|
|
57
58
|
unsubscribe();
|
|
58
59
|
resolve(answer);
|
|
59
60
|
}
|
|
60
61
|
});
|
|
61
62
|
if (options?.signal) {
|
|
62
|
-
options.signal.addEventListener(
|
|
63
|
-
bus_1.bus.request(
|
|
63
|
+
options.signal.addEventListener("abort", () => {
|
|
64
|
+
bus_1.bus.request("ai.abort-completion");
|
|
64
65
|
unsubscribe();
|
|
65
66
|
resolve(answer);
|
|
66
67
|
});
|
|
67
68
|
}
|
|
68
69
|
})
|
|
69
|
-
.catch(err => reject(err));
|
|
70
|
+
.catch((err) => reject(err));
|
|
70
71
|
});
|
|
71
72
|
return Object.assign(promise, {
|
|
72
|
-
on: emitter.on.bind(emitter)
|
|
73
|
+
on: emitter.on.bind(emitter),
|
|
73
74
|
});
|
|
74
75
|
}
|
|
75
76
|
AI.ask = ask;
|
|
@@ -114,7 +115,7 @@ var AI;
|
|
|
114
115
|
Model["OpenAI_GPT3.5-turbo"] = "openai-gpt-3.5-turbo";
|
|
115
116
|
})(Model = AI.Model || (AI.Model = {}));
|
|
116
117
|
AI.getModels = async () => {
|
|
117
|
-
const res = await bus_1.bus.request(
|
|
118
|
+
const res = await bus_1.bus.request("ai.get-models");
|
|
118
119
|
return res.data.models;
|
|
119
120
|
};
|
|
120
121
|
})(AI || (exports.AI = AI = {}));
|
package/dist/api/alert.d.ts
CHANGED
package/dist/api/alert.js
CHANGED
|
@@ -13,7 +13,6 @@ var Alert;
|
|
|
13
13
|
ActionStyle["Cancel"] = "cancel";
|
|
14
14
|
})(ActionStyle = Alert.ActionStyle || (Alert.ActionStyle = {}));
|
|
15
15
|
})(Alert || (exports.Alert = Alert = {}));
|
|
16
|
-
;
|
|
17
16
|
const styleMap = {
|
|
18
17
|
[Alert.ActionStyle.Default]: ui_1.ConfirmAlertActionStyle.Default,
|
|
19
18
|
[Alert.ActionStyle.Destructive]: ui_1.ConfirmAlertActionStyle.Destructive,
|
|
@@ -41,13 +40,13 @@ const confirmAlert = async (options) => {
|
|
|
41
40
|
description: options.message ?? "Are you sure?",
|
|
42
41
|
rememberUserChoice: false,
|
|
43
42
|
primaryAction: {
|
|
44
|
-
title: options.primaryAction?.title ??
|
|
43
|
+
title: options.primaryAction?.title ?? "Confirm",
|
|
45
44
|
style: styleMap[options.primaryAction?.style ?? Alert.ActionStyle.Default],
|
|
46
45
|
},
|
|
47
46
|
dismissAction: {
|
|
48
|
-
title: options.dismissAction?.title ??
|
|
47
|
+
title: options.dismissAction?.title ?? "Cancel",
|
|
49
48
|
style: styleMap[options.dismissAction?.style ?? Alert.ActionStyle.Cancel],
|
|
50
|
-
}
|
|
49
|
+
},
|
|
51
50
|
});
|
|
52
51
|
if (options.primaryAction?.onAction) {
|
|
53
52
|
confirmCallback = options.primaryAction.onAction;
|
|
@@ -55,7 +54,7 @@ const confirmAlert = async (options) => {
|
|
|
55
54
|
if (options.dismissAction?.onAction) {
|
|
56
55
|
cancelCallback = options.dismissAction.onAction;
|
|
57
56
|
}
|
|
58
|
-
await bus_1.bus.turboRequest(
|
|
57
|
+
await bus_1.bus.turboRequest("ui.confirmAlert", req);
|
|
59
58
|
});
|
|
60
59
|
};
|
|
61
60
|
exports.confirmAlert = confirmAlert;
|
package/dist/api/bus.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { MessagePort } from "worker_threads";
|
|
2
|
-
import * as ipc from
|
|
3
|
-
import * as extension from
|
|
4
|
-
import { Result } from
|
|
2
|
+
import * as ipc from "./proto/ipc";
|
|
3
|
+
import * as extension from "./proto/extension";
|
|
4
|
+
import { Result } from "./lib/result";
|
|
5
5
|
export type Message<T = Record<string, any>> = {
|
|
6
6
|
envelope: {
|
|
7
7
|
id: string;
|
|
8
|
-
type:
|
|
8
|
+
type: "request" | "response" | "event";
|
|
9
9
|
action: string;
|
|
10
10
|
};
|
|
11
11
|
error: {
|
|
@@ -37,25 +37,25 @@ type Responses = {
|
|
|
37
37
|
type EndpointMapping = {
|
|
38
38
|
"app.list": "app.list";
|
|
39
39
|
"app.open": "app.open";
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
"ui.render": "ui.render";
|
|
41
|
+
"ui.showToast": "ui.showToast";
|
|
42
|
+
"ui.hideToast": "ui.hideToast";
|
|
43
|
+
"ui.updateToast": "ui.updateToast";
|
|
44
|
+
"ui.pushView": "ui.pushView";
|
|
45
|
+
"ui.popView": "ui.popView";
|
|
46
|
+
"ui.closeMainWindow": "ui.closeMainWindow";
|
|
47
|
+
"ui.showHud": "ui.showHud";
|
|
48
|
+
"ui.setSearchText": "ui.setSearchText";
|
|
49
|
+
"ui.confirmAlert": "ui.confirmAlert";
|
|
50
|
+
"ui.getSelectedText": "ui.getSelectedText";
|
|
51
|
+
"storage.get": "storage.get";
|
|
52
|
+
"storage.set": "storage.set";
|
|
53
|
+
"storage.remove": "storage.remove";
|
|
54
|
+
"storage.clear": "storage.clear";
|
|
55
|
+
"storage.list": "storage.list";
|
|
56
|
+
"oauth.authorize": "oauth.authorize";
|
|
57
|
+
"clipboard.copy": "clipboard.copy";
|
|
58
|
+
"clipboard.paste": "clipboard.paste";
|
|
59
59
|
};
|
|
60
60
|
type RequestEndpoint = keyof EndpointMapping;
|
|
61
61
|
type ResponseEndpoint = EndpointMapping[RequestEndpoint];
|
|
@@ -63,8 +63,8 @@ type ExtractRequestType<T extends RequestEndpoint> = T extends `${infer Category
|
|
|
63
63
|
type ExtractResponseType<T extends ResponseEndpoint> = T extends `${infer Category}.${infer Action}` ? Category extends keyof Responses ? Action extends keyof Responses[Category] ? Responses[Category][Action] : never : never : never;
|
|
64
64
|
type Map = {
|
|
65
65
|
[K in RequestEndpoint]: {
|
|
66
|
-
request: ExtractRequestType<K>[
|
|
67
|
-
response: ExtractResponseType<EndpointMapping[K]>[
|
|
66
|
+
request: ExtractRequestType<K>["data"];
|
|
67
|
+
response: ExtractResponseType<EndpointMapping[K]>["data"];
|
|
68
68
|
};
|
|
69
69
|
};
|
|
70
70
|
declare class Bus {
|
|
@@ -72,12 +72,12 @@ declare class Bus {
|
|
|
72
72
|
private requestMap;
|
|
73
73
|
private safeRequestMap;
|
|
74
74
|
private eventListeners;
|
|
75
|
-
turboRequest<T extends RequestEndpoint>(endpoint: T, data: Map[T][
|
|
75
|
+
turboRequest<T extends RequestEndpoint>(endpoint: T, data: Map[T]["request"]): Promise<Result<Map[T]["response"], Error>>;
|
|
76
76
|
private handleSafeMessage;
|
|
77
77
|
emitCrash(errorText: string): void;
|
|
78
78
|
constructor(port: MessagePort);
|
|
79
79
|
listEventListeners(type: string): EventListenerInfo[];
|
|
80
|
-
subscribe(type: string, cb: EventListenerInfo[
|
|
80
|
+
subscribe(type: string, cb: EventListenerInfo["callback"]): {
|
|
81
81
|
unsubscribe: () => void;
|
|
82
82
|
};
|
|
83
83
|
emit(action: string, data: Record<string, any>): void;
|
package/dist/api/bus.js
CHANGED
|
@@ -39,15 +39,16 @@ const worker_threads_1 = require("worker_threads");
|
|
|
39
39
|
const ipc = __importStar(require("./proto/ipc"));
|
|
40
40
|
const extension = __importStar(require("./proto/extension"));
|
|
41
41
|
const result_1 = require("./lib/result");
|
|
42
|
-
;
|
|
43
42
|
class Bus {
|
|
44
43
|
port;
|
|
45
44
|
requestMap = new Map();
|
|
46
45
|
safeRequestMap = new Map();
|
|
47
46
|
eventListeners = new Map();
|
|
48
47
|
async turboRequest(endpoint, data) {
|
|
49
|
-
const [category, requestId] = endpoint.split(
|
|
50
|
-
const request = extension.RequestData.create({
|
|
48
|
+
const [category, requestId] = endpoint.split(".");
|
|
49
|
+
const request = extension.RequestData.create({
|
|
50
|
+
[category]: { [requestId]: data },
|
|
51
|
+
});
|
|
51
52
|
const res = await this.request2(request);
|
|
52
53
|
if (!res.ok) {
|
|
53
54
|
return (0, result_1.Err)(res.error);
|
|
@@ -86,21 +87,21 @@ class Bus {
|
|
|
86
87
|
this.sendMessage({
|
|
87
88
|
event: {
|
|
88
89
|
id: (0, crypto_1.randomUUID)(),
|
|
89
|
-
crash: { text: errorText }
|
|
90
|
-
}
|
|
90
|
+
crash: { text: errorText },
|
|
91
|
+
},
|
|
91
92
|
});
|
|
92
93
|
}
|
|
93
94
|
constructor(port) {
|
|
94
95
|
this.port = port;
|
|
95
96
|
if (!port)
|
|
96
97
|
return;
|
|
97
|
-
port.on(
|
|
98
|
+
port.on("message", (buf) => {
|
|
98
99
|
this.handleSafeMessage(ipc.ExtensionMessage.decode(buf));
|
|
99
100
|
});
|
|
100
|
-
port.on(
|
|
101
|
+
port.on("messageerror", (error) => {
|
|
101
102
|
console.error(`Message error from manager`, error);
|
|
102
103
|
});
|
|
103
|
-
port.on(
|
|
104
|
+
port.on("close", () => {
|
|
104
105
|
console.error(`Parent port closed prematurely`);
|
|
105
106
|
});
|
|
106
107
|
}
|
|
@@ -126,15 +127,15 @@ class Bus {
|
|
|
126
127
|
this.eventListeners.delete(type);
|
|
127
128
|
}
|
|
128
129
|
}
|
|
129
|
-
}
|
|
130
|
+
},
|
|
130
131
|
};
|
|
131
132
|
}
|
|
132
133
|
emit(action, data) {
|
|
133
134
|
const message = ipc.ExtensionMessage.create({
|
|
134
135
|
event: {
|
|
135
136
|
id: action,
|
|
136
|
-
generic: { json: JSON.stringify([data]) }
|
|
137
|
-
}
|
|
137
|
+
generic: { json: JSON.stringify([data]) },
|
|
138
|
+
},
|
|
138
139
|
});
|
|
139
140
|
this.sendMessage(message);
|
|
140
141
|
}
|
|
@@ -186,12 +187,12 @@ class Bus {
|
|
|
186
187
|
this.requestMap.set(id, { resolve: resolver });
|
|
187
188
|
const message = {
|
|
188
189
|
envelope: {
|
|
189
|
-
type:
|
|
190
|
+
type: "request",
|
|
190
191
|
action,
|
|
191
|
-
id
|
|
192
|
+
id,
|
|
192
193
|
},
|
|
193
194
|
data,
|
|
194
|
-
error: null
|
|
195
|
+
error: null,
|
|
195
196
|
};
|
|
196
197
|
this.port.postMessage(message);
|
|
197
198
|
}
|
|
@@ -201,7 +202,6 @@ class Bus {
|
|
|
201
202
|
});
|
|
202
203
|
}
|
|
203
204
|
}
|
|
204
|
-
;
|
|
205
205
|
const createHandler = (handler) => {
|
|
206
206
|
const id = (0, crypto_1.randomUUID)();
|
|
207
207
|
exports.bus.subscribe(id, handler);
|
package/dist/api/cache.js
CHANGED
|
@@ -6,21 +6,29 @@ class Cache {
|
|
|
6
6
|
/**
|
|
7
7
|
* @returns the full path to the directory where the data is stored on disk.
|
|
8
8
|
*/
|
|
9
|
-
get storageDirectory() {
|
|
9
|
+
get storageDirectory() {
|
|
10
|
+
return "";
|
|
11
|
+
}
|
|
10
12
|
/**
|
|
11
13
|
* @returns the data for the given key. If there is no data for the key, `undefined` is returned.
|
|
12
14
|
* @remarks If you want to just check for the existence of a key, use {@link has}.
|
|
13
15
|
*/
|
|
14
|
-
get(key) {
|
|
16
|
+
get(key) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
15
19
|
/**
|
|
16
20
|
* @returns `true` if data for the key exists, `false` otherwise.
|
|
17
21
|
* @remarks You can use this method to check for entries without affecting the LRU access.
|
|
18
22
|
*/
|
|
19
|
-
has(key) {
|
|
23
|
+
has(key) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
20
26
|
/**
|
|
21
27
|
* @returns `true` if the cache is empty, `false` otherwise.
|
|
22
28
|
*/
|
|
23
|
-
get isEmpty() {
|
|
29
|
+
get isEmpty() {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
24
32
|
/**
|
|
25
33
|
* Sets the data for the given key.
|
|
26
34
|
* If the data exceeds the configured `capacity`, the least recently used entries are removed.
|
|
@@ -32,7 +40,9 @@ class Cache {
|
|
|
32
40
|
* This also notifies registered subscribers (see {@link subscribe}).
|
|
33
41
|
* @returns `true` if data for the key was removed, `false` otherwise.
|
|
34
42
|
*/
|
|
35
|
-
remove(key) {
|
|
43
|
+
remove(key) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
36
46
|
/**
|
|
37
47
|
* Clears all stored data.
|
|
38
48
|
* This also notifies registered subscribers (see {@link subscribe}) unless the `notifySubscribers` option is set to `false`.
|
|
@@ -49,4 +59,3 @@ class Cache {
|
|
|
49
59
|
notifySubscribers;
|
|
50
60
|
}
|
|
51
61
|
exports.Cache = Cache;
|
|
52
|
-
;
|
package/dist/api/clipboard.d.ts
CHANGED
package/dist/api/clipboard.js
CHANGED
|
@@ -3,50 +3,49 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Clipboard = void 0;
|
|
4
4
|
const bus_1 = require("./bus");
|
|
5
5
|
const clipboard_1 = require("./proto/clipboard");
|
|
6
|
-
;
|
|
7
6
|
exports.Clipboard = {
|
|
8
7
|
mapContent(content) {
|
|
9
8
|
let ct = clipboard_1.ClipboardContent.create();
|
|
10
|
-
if (typeof content !=
|
|
9
|
+
if (typeof content != "object") {
|
|
11
10
|
ct.text = `${content}`;
|
|
12
11
|
}
|
|
13
12
|
else {
|
|
14
|
-
if (content[
|
|
15
|
-
ct.path = { path: content[
|
|
13
|
+
if (content["file"]) {
|
|
14
|
+
ct.path = { path: content["file"] };
|
|
16
15
|
}
|
|
17
|
-
else if (content[
|
|
18
|
-
ct.html = { html: content[
|
|
16
|
+
else if (content["html"]) {
|
|
17
|
+
ct.html = { html: content["html"], text: content["text"] };
|
|
19
18
|
}
|
|
20
19
|
else {
|
|
21
|
-
ct.text = content[
|
|
20
|
+
ct.text = content["text"];
|
|
22
21
|
}
|
|
23
22
|
}
|
|
24
23
|
return ct;
|
|
25
24
|
},
|
|
26
25
|
async copy(text, options = {}) {
|
|
27
|
-
await bus_1.bus.turboRequest(
|
|
26
|
+
await bus_1.bus.turboRequest("clipboard.copy", {
|
|
28
27
|
content: this.mapContent(text),
|
|
29
|
-
options: { concealed: options.concealed ?? false }
|
|
28
|
+
options: { concealed: options.concealed ?? false },
|
|
30
29
|
});
|
|
31
30
|
},
|
|
32
31
|
async paste(text) {
|
|
33
|
-
await bus_1.bus.turboRequest(
|
|
32
|
+
await bus_1.bus.turboRequest("clipboard.paste", {
|
|
34
33
|
content: this.mapContent(text),
|
|
35
34
|
});
|
|
36
35
|
},
|
|
37
36
|
async read(options) {
|
|
38
|
-
const res = await bus_1.bus.request(
|
|
39
|
-
options
|
|
37
|
+
const res = await bus_1.bus.request("clipboard.read", {
|
|
38
|
+
options,
|
|
40
39
|
});
|
|
41
40
|
return res.data.content;
|
|
42
41
|
},
|
|
43
42
|
async readText(options) {
|
|
44
|
-
const res = await bus_1.bus.request(
|
|
45
|
-
options
|
|
43
|
+
const res = await bus_1.bus.request("clipboard.read-text", {
|
|
44
|
+
options,
|
|
46
45
|
});
|
|
47
46
|
return res.data.content;
|
|
48
47
|
},
|
|
49
48
|
async clear(text) {
|
|
50
49
|
// TODO: implement
|
|
51
|
-
}
|
|
50
|
+
},
|
|
52
51
|
};
|
package/dist/api/color.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.serializeColorLike = exports.Color = void 0;
|
|
4
|
-
;
|
|
5
4
|
var Color;
|
|
6
5
|
(function (Color) {
|
|
7
6
|
Color["Blue"] = "blue";
|
|
@@ -14,9 +13,8 @@ var Color;
|
|
|
14
13
|
Color["PrimaryText"] = "primary-text";
|
|
15
14
|
Color["SecondaryText"] = "secondary-text";
|
|
16
15
|
})(Color || (exports.Color = Color = {}));
|
|
17
|
-
;
|
|
18
16
|
const serializeColorLike = (color) => {
|
|
19
|
-
if (typeof color ==
|
|
17
|
+
if (typeof color == "string") {
|
|
20
18
|
return color;
|
|
21
19
|
}
|
|
22
20
|
return color;
|
|
@@ -6,7 +6,7 @@ const image_1 = require("../image");
|
|
|
6
6
|
const hooks_1 = require("../hooks");
|
|
7
7
|
const ActionPanelRoot = (props) => {
|
|
8
8
|
const nativeProps = props;
|
|
9
|
-
return (
|
|
9
|
+
return (0, jsx_runtime_1.jsx)("action-panel", { ...nativeProps });
|
|
10
10
|
};
|
|
11
11
|
const ActionPanelSection = (props) => {
|
|
12
12
|
const nativeProps = {
|
|
@@ -22,7 +22,7 @@ const ActionPannelSubmenu = ({ icon, children, onOpen, onSearchTextChange, ...pr
|
|
|
22
22
|
nativeProps.onOpen = onOpenHandler;
|
|
23
23
|
if (icon)
|
|
24
24
|
nativeProps.icon = (0, image_1.serializeImageLike)(icon);
|
|
25
|
-
return (0, jsx_runtime_1.jsx)("action-panel-submenu", { ...nativeProps, children: children });
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)("action-panel-submenu", { ...nativeProps, children: children }));
|
|
26
26
|
};
|
|
27
27
|
exports.ActionPanel = Object.assign(ActionPanelRoot, {
|
|
28
28
|
Section: ActionPanelSection,
|
|
@@ -9,12 +9,12 @@ export type BaseActionProps = {
|
|
|
9
9
|
icon?: ImageLike;
|
|
10
10
|
shortcut?: Keyboard.Shortcut;
|
|
11
11
|
autoFocus?: boolean;
|
|
12
|
-
style?:
|
|
12
|
+
style?: "regular" | "destructive";
|
|
13
13
|
};
|
|
14
14
|
export type ActionProps = BaseActionProps & {
|
|
15
15
|
onAction: () => void;
|
|
16
16
|
};
|
|
17
|
-
export type CopyToClipboardProps = Omit<BaseActionProps,
|
|
17
|
+
export type CopyToClipboardProps = Omit<BaseActionProps, "title"> & {
|
|
18
18
|
content: string;
|
|
19
19
|
concealed?: boolean;
|
|
20
20
|
onCopy?: (content: string | number | Clipboard.Content) => void;
|
|
@@ -34,7 +34,7 @@ export type ActionPasteProps = BaseActionProps & {
|
|
|
34
34
|
export type ActionOpenInBrowserProps = BaseActionProps & {
|
|
35
35
|
url: string;
|
|
36
36
|
};
|
|
37
|
-
export type ActionSubmitFormProps = Omit<BaseActionProps,
|
|
37
|
+
export type ActionSubmitFormProps = Omit<BaseActionProps, "title"> & {
|
|
38
38
|
onSubmit: (input: Form.Values) => boolean | void | Promise<boolean | void>;
|
|
39
39
|
title?: string;
|
|
40
40
|
};
|
|
@@ -14,7 +14,7 @@ const ActionRoot = ({ icon, ...props }) => {
|
|
|
14
14
|
const nativeProps = {
|
|
15
15
|
...props,
|
|
16
16
|
icon,
|
|
17
|
-
onAction: handler
|
|
17
|
+
onAction: handler,
|
|
18
18
|
};
|
|
19
19
|
if (icon) {
|
|
20
20
|
nativeProps.icon = (0, image_1.serializeImageLike)(icon);
|
|
@@ -22,35 +22,35 @@ const ActionRoot = ({ icon, ...props }) => {
|
|
|
22
22
|
return (0, jsx_runtime_1.jsx)("action", { ...nativeProps });
|
|
23
23
|
};
|
|
24
24
|
const CopyToClipboard = ({ title = "Copy to clipboard", icon = icon_1.Icon.CopyClipboard, content, concealed = false, onCopy, ...props }) => {
|
|
25
|
-
return (0, jsx_runtime_1.jsx)(ActionRoot, { title: title, ...props, icon: icon_1.Icon.CopyClipboard, onAction: async () => {
|
|
25
|
+
return ((0, jsx_runtime_1.jsx)(ActionRoot, { title: title, ...props, icon: icon_1.Icon.CopyClipboard, onAction: async () => {
|
|
26
26
|
clipboard_1.Clipboard.copy(content, { concealed });
|
|
27
27
|
(0, controls_1.closeMainWindow)();
|
|
28
28
|
onCopy?.(content);
|
|
29
|
-
} });
|
|
29
|
+
} }));
|
|
30
30
|
};
|
|
31
31
|
const Paste = ({ title = "Paste to active window", icon = icon_1.Icon.CopyClipboard, content, onPaste, ...props }) => {
|
|
32
|
-
return (0, jsx_runtime_1.jsx)(ActionRoot, { title: title, ...props, icon: icon_1.Icon.CopyClipboard, onAction: async () => {
|
|
32
|
+
return ((0, jsx_runtime_1.jsx)(ActionRoot, { title: title, ...props, icon: icon_1.Icon.CopyClipboard, onAction: async () => {
|
|
33
33
|
(0, controls_1.closeMainWindow)(); // we close before pasting to make sure focus has been properly restored
|
|
34
34
|
clipboard_1.Clipboard.paste(content);
|
|
35
35
|
onPaste?.(content);
|
|
36
|
-
} });
|
|
36
|
+
} }));
|
|
37
37
|
};
|
|
38
38
|
const Open = ({ target, app, ...props }) => {
|
|
39
|
-
return (0, jsx_runtime_1.jsx)(ActionRoot, { ...props, onAction: () => {
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(ActionRoot, { ...props, onAction: () => {
|
|
40
40
|
(0, utils_1.open)(target, app);
|
|
41
|
-
} });
|
|
41
|
+
} }));
|
|
42
42
|
};
|
|
43
43
|
const OpenInBrowser = ({ url, ...props }) => {
|
|
44
|
-
return (0, jsx_runtime_1.jsx)(ActionRoot, { ...props, onAction: () => {
|
|
44
|
+
return ((0, jsx_runtime_1.jsx)(ActionRoot, { ...props, onAction: () => {
|
|
45
45
|
(0, utils_1.open)(url);
|
|
46
|
-
} });
|
|
46
|
+
} }));
|
|
47
47
|
};
|
|
48
48
|
const Push = ({ target, ...props }) => {
|
|
49
49
|
const { push } = (0, index_1.useNavigation)();
|
|
50
|
-
return (0, jsx_runtime_1.jsx)(ActionRoot, { ...props, onAction: () => {
|
|
51
|
-
console.log(
|
|
50
|
+
return ((0, jsx_runtime_1.jsx)(ActionRoot, { ...props, onAction: () => {
|
|
51
|
+
console.log("activate push action");
|
|
52
52
|
push(target);
|
|
53
|
-
} });
|
|
53
|
+
} }));
|
|
54
54
|
};
|
|
55
55
|
const SubmitForm = ({ onSubmit, icon, title = "Submit", ...props }) => {
|
|
56
56
|
const submitHandler = (0, hooks_1.useEventListener)(onSubmit);
|
|
@@ -60,7 +60,7 @@ const SubmitForm = ({ onSubmit, icon, title = "Submit", ...props }) => {
|
|
|
60
60
|
title,
|
|
61
61
|
icon,
|
|
62
62
|
onSubmit: submitHandler,
|
|
63
|
-
onAction: handler
|
|
63
|
+
onAction: handler,
|
|
64
64
|
};
|
|
65
65
|
if (icon) {
|
|
66
66
|
nativeProps.icon = (0, image_1.serializeImageLike)(icon);
|
|
@@ -75,7 +75,7 @@ exports.Action = Object.assign(ActionRoot, {
|
|
|
75
75
|
SubmitForm,
|
|
76
76
|
OpenInBrowser,
|
|
77
77
|
Style: {
|
|
78
|
-
Regular:
|
|
79
|
-
Destructive:
|
|
80
|
-
}
|
|
78
|
+
Regular: "regular",
|
|
79
|
+
Destructive: "destructive",
|
|
80
|
+
},
|
|
81
81
|
});
|
|
@@ -8,5 +8,5 @@ const DetailRoot = ({ metadata, actions, ...props }) => {
|
|
|
8
8
|
return ((0, jsx_runtime_1.jsxs)("detail", { ...nativeProps, children: [actions, metadata] }));
|
|
9
9
|
};
|
|
10
10
|
exports.Detail = Object.assign(DetailRoot, {
|
|
11
|
-
Metadata: metadata_1.Metadata
|
|
11
|
+
Metadata: metadata_1.Metadata,
|
|
12
12
|
});
|
|
@@ -10,12 +10,12 @@ const DropdownRoot = ({ children, ...props }) => {
|
|
|
10
10
|
return ((0, jsx_runtime_1.jsx)("dropdown", { onSearchTextChange: onSearchTextChange, onChange: onChange, children: children }));
|
|
11
11
|
};
|
|
12
12
|
const Item = ({ title, value, icon }) => {
|
|
13
|
-
return (0, jsx_runtime_1.jsx)("dropdown-item", { title: title, value: value, icon: icon && (0, image_1.serializeImageLike)(icon) });
|
|
13
|
+
return ((0, jsx_runtime_1.jsx)("dropdown-item", { title: title, value: value, icon: icon && (0, image_1.serializeImageLike)(icon) }));
|
|
14
14
|
};
|
|
15
15
|
const Section = ({ title, children }) => {
|
|
16
|
-
return (
|
|
16
|
+
return (0, jsx_runtime_1.jsx)("dropdown-section", { title: title, children: children });
|
|
17
17
|
};
|
|
18
18
|
exports.Dropdown = Object.assign(DropdownRoot, {
|
|
19
19
|
Item,
|
|
20
|
-
Section
|
|
20
|
+
Section,
|
|
21
21
|
});
|
|
@@ -7,6 +7,6 @@ const EmptyView = ({ icon, actions, ...props }) => {
|
|
|
7
7
|
const nativeProps = props;
|
|
8
8
|
if (icon)
|
|
9
9
|
nativeProps.icon = (0, image_1.serializeImageLike)(icon);
|
|
10
|
-
return (
|
|
10
|
+
return (0, jsx_runtime_1.jsx)("empty-view", { ...nativeProps, children: actions });
|
|
11
11
|
};
|
|
12
12
|
exports.EmptyView = EmptyView;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactNode, Ref } from
|
|
1
|
+
import { ReactNode, Ref } from "react";
|
|
2
2
|
type FormProps = {
|
|
3
3
|
actions?: React.ReactNode;
|
|
4
4
|
children?: React.ReactNode;
|
|
@@ -31,7 +31,7 @@ interface FormEvent<T extends Form.Value> {
|
|
|
31
31
|
};
|
|
32
32
|
type: FormEventType;
|
|
33
33
|
}
|
|
34
|
-
type FormEventType =
|
|
34
|
+
type FormEventType = "focus" | "blur";
|
|
35
35
|
export declare namespace Form {
|
|
36
36
|
type Props = FormProps;
|
|
37
37
|
type TextField = FormItemRef;
|