@vicinae/api 0.20.8 → 0.20.10
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/alert.d.ts +1 -1
- package/dist/api/alert.js +9 -14
- package/dist/api/client.d.ts +7 -0
- package/dist/api/client.js +11 -0
- package/dist/api/clipboard.d.ts +4 -8
- package/dist/api/clipboard.js +13 -18
- package/dist/api/color.d.ts +4 -10
- package/dist/api/color.js +8 -47
- package/dist/api/command.js +4 -6
- package/dist/api/controls.js +9 -56
- package/dist/api/environment.d.ts +0 -11
- package/dist/api/environment.js +2 -1
- package/dist/api/file-search.d.ts +3 -4
- package/dist/api/file-search.js +6 -4
- package/dist/api/globals.d.ts +9 -0
- package/dist/api/globals.js +5 -0
- package/dist/api/hooks/use-imperative-form-handle.d.ts +1 -1
- package/dist/api/hooks/use-imperative-form-handle.js +6 -3
- package/dist/api/hooks/use-navigation.d.ts +2 -2
- package/dist/api/hooks/use-navigation.js +2 -5
- package/dist/api/image.d.ts +4 -4
- package/dist/api/image.js +12 -51
- package/dist/api/index.d.ts +0 -2
- package/dist/api/index.js +0 -2
- package/dist/api/local-storage.js +7 -14
- package/dist/api/oauth.d.ts +1 -1
- package/dist/api/oauth.js +7 -15
- package/dist/api/preference.d.ts +2 -4
- package/dist/api/preference.js +10 -6
- package/dist/api/proto/api.d.ts +240 -0
- package/dist/api/proto/api.js +271 -0
- package/dist/api/toast.js +7 -77
- package/dist/api/utils.d.ts +6 -2
- package/dist/api/utils.js +9 -26
- package/dist/api/window-management.d.ts +3 -5
- package/dist/api/window-management.js +14 -27
- package/dist/schemas/manifest.d.ts +3 -3
- package/package.json +1 -4
- package/dist/api/bus.d.ts +0 -125
- package/dist/api/bus.js +0 -201
- package/dist/api/context/index.d.ts +0 -1
- package/dist/api/context/index.js +0 -17
- package/dist/api/context/navigation-context.d.ts +0 -7
- package/dist/api/context/navigation-context.js +0 -12
- package/dist/api/context/navigation-provider.d.ts +0 -7
- package/dist/api/context/navigation-provider.js +0 -58
- package/dist/api/hooks.d.ts +0 -1
- package/dist/api/hooks.js +0 -30
- package/dist/api/proto/application.d.ts +0 -79
- package/dist/api/proto/application.js +0 -826
- package/dist/api/proto/clipboard.d.ts +0 -88
- package/dist/api/proto/clipboard.js +0 -929
- package/dist/api/proto/command.d.ts +0 -35
- package/dist/api/proto/command.js +0 -182
- package/dist/api/proto/common.d.ts +0 -28
- package/dist/api/proto/common.js +0 -102
- package/dist/api/proto/extension.d.ts +0 -106
- package/dist/api/proto/extension.js +0 -1122
- package/dist/api/proto/file-search.d.ts +0 -42
- package/dist/api/proto/file-search.js +0 -290
- package/dist/api/proto/google/protobuf/struct.d.ts +0 -107
- package/dist/api/proto/google/protobuf/struct.js +0 -456
- package/dist/api/proto/ipc.d.ts +0 -64
- package/dist/api/proto/ipc.js +0 -604
- package/dist/api/proto/manager.d.ts +0 -87
- package/dist/api/proto/manager.js +0 -776
- package/dist/api/proto/oauth.d.ts +0 -97
- package/dist/api/proto/oauth.js +0 -994
- package/dist/api/proto/storage.d.ts +0 -80
- package/dist/api/proto/storage.js +0 -804
- package/dist/api/proto/ui.d.ts +0 -208
- package/dist/api/proto/ui.js +0 -2316
- package/dist/api/proto/wlr-clipboard.d.ts +0 -30
- package/dist/api/proto/wlr-clipboard.js +0 -158
- package/dist/api/proto/wm.d.ts +0 -142
- package/dist/api/proto/wm.js +0 -1714
package/dist/api/bus.d.ts
DELETED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { type MessagePort } from "node:worker_threads";
|
|
2
|
-
import * as ipc from "./proto/ipc";
|
|
3
|
-
import * as extension from "./proto/extension";
|
|
4
|
-
import { type Result } from "./lib/result";
|
|
5
|
-
/**
|
|
6
|
-
* @ignore
|
|
7
|
-
*/
|
|
8
|
-
export type Message<T = Record<string, any>> = {
|
|
9
|
-
envelope: {
|
|
10
|
-
id: string;
|
|
11
|
-
type: "request" | "response" | "event";
|
|
12
|
-
action: string;
|
|
13
|
-
};
|
|
14
|
-
error: {
|
|
15
|
-
message?: string;
|
|
16
|
-
} | null;
|
|
17
|
-
data: T;
|
|
18
|
-
};
|
|
19
|
-
declare namespace EventListener {
|
|
20
|
-
type ArgValue = string | number | Record<any, any> | boolean | null | undefined;
|
|
21
|
-
type Callback = (...args: EventListener.ArgValue[]) => void;
|
|
22
|
-
}
|
|
23
|
-
type EventListenerInfo = {
|
|
24
|
-
callback: EventListener.Callback;
|
|
25
|
-
};
|
|
26
|
-
type Requests = {
|
|
27
|
-
[K in keyof Required<extension.RequestData>]: {
|
|
28
|
-
[R in keyof Required<Required<extension.RequestData>[K]>]: {
|
|
29
|
-
data: NonNullable<Required<extension.RequestData>[K][R]>;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
};
|
|
33
|
-
type Responses = {
|
|
34
|
-
[K in keyof Required<extension.ResponseData>]: {
|
|
35
|
-
[R in keyof Required<Required<extension.ResponseData>[K]>]: {
|
|
36
|
-
data: NonNullable<Required<extension.ResponseData>[K][R]>;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
type EndpointMapping = {
|
|
41
|
-
"app.list": "app.list";
|
|
42
|
-
"app.open": "app.open";
|
|
43
|
-
"app.getDefault": "app.getDefault";
|
|
44
|
-
"app.runInTerminal": "app.runInTerminal";
|
|
45
|
-
"app.showInFileBrowser": "app.showInFileBrowser";
|
|
46
|
-
"ui.render": "ui.render";
|
|
47
|
-
"ui.showToast": "ui.showToast";
|
|
48
|
-
"ui.hideToast": "ui.hideToast";
|
|
49
|
-
"ui.updateToast": "ui.updateToast";
|
|
50
|
-
"ui.pushView": "ui.pushView";
|
|
51
|
-
"ui.popView": "ui.popView";
|
|
52
|
-
"ui.closeMainWindow": "ui.closeMainWindow";
|
|
53
|
-
"ui.showHud": "ui.showHud";
|
|
54
|
-
"ui.setSearchText": "ui.setSearchText";
|
|
55
|
-
"ui.confirmAlert": "ui.confirmAlert";
|
|
56
|
-
"ui.getSelectedText": "ui.getSelectedText";
|
|
57
|
-
"wm.ping": "wm.ping";
|
|
58
|
-
"wm.getActiveWindow": "wm.getActiveWindow";
|
|
59
|
-
"wm.getActiveWorkspace": "wm.getActiveWorkspace";
|
|
60
|
-
"wm.getWindows": "wm.getWindows";
|
|
61
|
-
"wm.getScreens": "wm.getScreens";
|
|
62
|
-
"wm.getWorkspaces": "wm.getWorkspaces";
|
|
63
|
-
"wm.setWindowBounds": "wm.setWindowBounds";
|
|
64
|
-
"wm.focusWindow": "wm.focusWindow";
|
|
65
|
-
"fileSearch.search": "fileSearch.search";
|
|
66
|
-
"ui.popToRoot": "ui.popToRoot";
|
|
67
|
-
"command.updateCommandMetadata": "command.updateCommandMetadata";
|
|
68
|
-
"storage.get": "storage.get";
|
|
69
|
-
"storage.set": "storage.set";
|
|
70
|
-
"storage.remove": "storage.remove";
|
|
71
|
-
"storage.clear": "storage.clear";
|
|
72
|
-
"storage.list": "storage.list";
|
|
73
|
-
"oauth.authorize": "oauth.authorize";
|
|
74
|
-
"oauth.getTokens": "oauth.getTokens";
|
|
75
|
-
"oauth.setTokens": "oauth.setTokens";
|
|
76
|
-
"oauth.removeTokens": "oauth.removeTokens";
|
|
77
|
-
"clipboard.copy": "clipboard.copy";
|
|
78
|
-
"clipboard.paste": "clipboard.paste";
|
|
79
|
-
"clipboard.readContent": "clipboard.readContent";
|
|
80
|
-
"clipboard.clear": "clipboard.clear";
|
|
81
|
-
};
|
|
82
|
-
type RequestEndpoint = keyof EndpointMapping;
|
|
83
|
-
type ResponseEndpoint = EndpointMapping[RequestEndpoint];
|
|
84
|
-
type ExtractRequestType<T extends RequestEndpoint> = T extends `${infer Category}.${infer Action}` ? Category extends keyof Requests ? Action extends keyof Requests[Category] ? Requests[Category][Action] : never : never : never;
|
|
85
|
-
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;
|
|
86
|
-
type Map = {
|
|
87
|
-
[K in RequestEndpoint]: {
|
|
88
|
-
request: ExtractRequestType<K>["data"];
|
|
89
|
-
response: ExtractResponseType<EndpointMapping[K]>["data"];
|
|
90
|
-
};
|
|
91
|
-
};
|
|
92
|
-
type LaunchHandler = (data: extension.LaunchEventData) => void;
|
|
93
|
-
declare class Bus {
|
|
94
|
-
private readonly port;
|
|
95
|
-
private requestMap;
|
|
96
|
-
private safeRequestMap;
|
|
97
|
-
private eventListeners;
|
|
98
|
-
private onLaunchHandlers;
|
|
99
|
-
request<T extends RequestEndpoint>(endpoint: T, data: Map[T]["request"]): Promise<Result<Map[T]["response"], Error>>;
|
|
100
|
-
private handleSafeMessage;
|
|
101
|
-
onLaunch(handler: LaunchHandler): void;
|
|
102
|
-
emitCrash(errorText: string): void;
|
|
103
|
-
constructor(port: MessagePort);
|
|
104
|
-
listEventListeners(type: string): EventListenerInfo[];
|
|
105
|
-
subscribe(type: string, cb: EventListenerInfo["callback"]): {
|
|
106
|
-
unsubscribe: () => void;
|
|
107
|
-
};
|
|
108
|
-
emit(action: string, data: Record<string, any>): void;
|
|
109
|
-
sendMessage(message: ipc.ExtensionMessage): void;
|
|
110
|
-
addEventHandler(cb: EventListenerInfo["callback"]): {
|
|
111
|
-
id: string;
|
|
112
|
-
unsubscribe: () => void;
|
|
113
|
-
};
|
|
114
|
-
replaceEventHandler(id: string, handler: EventListenerInfo["callback"]): void;
|
|
115
|
-
removeEventHandler(id: string): void;
|
|
116
|
-
private requestImpl;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* @ignore
|
|
120
|
-
*
|
|
121
|
-
* IPC bus to communicate with the extension manager.
|
|
122
|
-
* If you are using this from inside your extension, you are WRONG and you should stop.
|
|
123
|
-
*/
|
|
124
|
-
export declare const bus: Bus;
|
|
125
|
-
export {};
|
package/dist/api/bus.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
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
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.bus = void 0;
|
|
37
|
-
const node_crypto_1 = require("node:crypto");
|
|
38
|
-
const node_worker_threads_1 = require("node:worker_threads");
|
|
39
|
-
const ipc = __importStar(require("./proto/ipc"));
|
|
40
|
-
const extension = __importStar(require("./proto/extension"));
|
|
41
|
-
const result_1 = require("./lib/result");
|
|
42
|
-
class Bus {
|
|
43
|
-
port;
|
|
44
|
-
requestMap = new Map();
|
|
45
|
-
safeRequestMap = new Map();
|
|
46
|
-
eventListeners = new Map();
|
|
47
|
-
onLaunchHandlers = [];
|
|
48
|
-
async request(endpoint, data) {
|
|
49
|
-
const [category, requestId] = endpoint.split(".");
|
|
50
|
-
const request = extension.RequestData.create({
|
|
51
|
-
[category]: { [requestId]: data },
|
|
52
|
-
});
|
|
53
|
-
const res = await this.requestImpl(request);
|
|
54
|
-
if (!res.ok) {
|
|
55
|
-
return (0, result_1.Err)(res.error);
|
|
56
|
-
}
|
|
57
|
-
const resData = res.value[category]?.[requestId];
|
|
58
|
-
if (!resData) {
|
|
59
|
-
return (0, result_1.Err)(Error(`Invalid response for request of type ${endpoint}: ${JSON.stringify(res, null, 2)}`));
|
|
60
|
-
}
|
|
61
|
-
return (0, result_1.Ok)(resData);
|
|
62
|
-
}
|
|
63
|
-
handleSafeMessage(message) {
|
|
64
|
-
if (message.response) {
|
|
65
|
-
//console.log('got response response', message.response.requestId);
|
|
66
|
-
const request = this.safeRequestMap.get(message.response.requestId);
|
|
67
|
-
if (!request) {
|
|
68
|
-
//console.error(`Received response for unknown request ${message.response.requestId}`);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
this.requestMap.delete(message.response.requestId);
|
|
72
|
-
request.resolve(message.response);
|
|
73
|
-
return;
|
|
74
|
-
}
|
|
75
|
-
if (message.event) {
|
|
76
|
-
const { id, generic, launch } = message.event;
|
|
77
|
-
if (launch) {
|
|
78
|
-
for (const fn of this.onLaunchHandlers) {
|
|
79
|
-
fn(launch);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
//console.error('got event with id', id);
|
|
83
|
-
if (generic) {
|
|
84
|
-
const listeners = this.listEventListeners(id);
|
|
85
|
-
const args = JSON.parse(generic.json);
|
|
86
|
-
for (const listener of listeners) {
|
|
87
|
-
listener.callback(...(args ?? []));
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
onLaunch(handler) {
|
|
93
|
-
this.onLaunchHandlers.push(handler);
|
|
94
|
-
}
|
|
95
|
-
emitCrash(errorText) {
|
|
96
|
-
this.sendMessage({
|
|
97
|
-
event: {
|
|
98
|
-
id: (0, node_crypto_1.randomUUID)(),
|
|
99
|
-
crash: { text: errorText },
|
|
100
|
-
},
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
constructor(port) {
|
|
104
|
-
this.port = port;
|
|
105
|
-
if (!port)
|
|
106
|
-
return;
|
|
107
|
-
port.on("message", (buf) => {
|
|
108
|
-
this.handleSafeMessage(ipc.ExtensionMessage.decode(buf));
|
|
109
|
-
});
|
|
110
|
-
port.on("messageerror", (error) => {
|
|
111
|
-
console.error(`Message error from manager`, error);
|
|
112
|
-
});
|
|
113
|
-
port.on("close", () => {
|
|
114
|
-
console.error(`Parent port closed prematurely`);
|
|
115
|
-
});
|
|
116
|
-
}
|
|
117
|
-
listEventListeners(type) {
|
|
118
|
-
return this.eventListeners.get(type) ?? [];
|
|
119
|
-
}
|
|
120
|
-
subscribe(type, cb) {
|
|
121
|
-
const item = { callback: cb };
|
|
122
|
-
const listeners = this.eventListeners.get(type);
|
|
123
|
-
if (!listeners) {
|
|
124
|
-
this.eventListeners.set(type, [item]);
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
listeners.push(item);
|
|
128
|
-
}
|
|
129
|
-
return {
|
|
130
|
-
unsubscribe: () => {
|
|
131
|
-
const listeners = this.eventListeners.get(type) ?? [];
|
|
132
|
-
const index = listeners.indexOf(item);
|
|
133
|
-
if (index != -1) {
|
|
134
|
-
listeners.splice(index, 1);
|
|
135
|
-
if (listeners.length === 0) {
|
|
136
|
-
this.eventListeners.delete(type);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
},
|
|
140
|
-
};
|
|
141
|
-
}
|
|
142
|
-
emit(action, data) {
|
|
143
|
-
const message = ipc.ExtensionMessage.create({
|
|
144
|
-
event: {
|
|
145
|
-
id: action,
|
|
146
|
-
generic: { json: JSON.stringify([data]) },
|
|
147
|
-
},
|
|
148
|
-
});
|
|
149
|
-
this.sendMessage(message);
|
|
150
|
-
}
|
|
151
|
-
sendMessage(message) {
|
|
152
|
-
this.port.postMessage(ipc.ExtensionMessage.encode(message).finish());
|
|
153
|
-
}
|
|
154
|
-
addEventHandler(cb) {
|
|
155
|
-
const id = `handler-${(0, node_crypto_1.randomUUID)()}`;
|
|
156
|
-
const { unsubscribe } = this.subscribe(id, cb);
|
|
157
|
-
return { id, unsubscribe };
|
|
158
|
-
}
|
|
159
|
-
replaceEventHandler(id, handler) {
|
|
160
|
-
for (const listener of this.eventListeners.get(id) ?? []) {
|
|
161
|
-
listener.callback = handler;
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
removeEventHandler(id) {
|
|
165
|
-
this.eventListeners.delete(id);
|
|
166
|
-
}
|
|
167
|
-
requestImpl(data, options = {}) {
|
|
168
|
-
const req = extension.Request.create({ requestId: (0, node_crypto_1.randomUUID)(), data });
|
|
169
|
-
return new Promise((resolve, reject) => {
|
|
170
|
-
let timeout;
|
|
171
|
-
if (options.timeout) {
|
|
172
|
-
timeout = setTimeout(() => resolve((0, result_1.Err)(Error(`request timed out`))), options.timeout);
|
|
173
|
-
}
|
|
174
|
-
const resolver = (response) => {
|
|
175
|
-
clearTimeout(timeout);
|
|
176
|
-
if (response.error) {
|
|
177
|
-
return resolve((0, result_1.Err)(new Error(response.error.errorText)));
|
|
178
|
-
}
|
|
179
|
-
if (!response.data) {
|
|
180
|
-
return resolve((0, result_1.Err)(new Error("No error and no data")));
|
|
181
|
-
}
|
|
182
|
-
resolve((0, result_1.Ok)(response.data));
|
|
183
|
-
};
|
|
184
|
-
try {
|
|
185
|
-
this.safeRequestMap.set(req.requestId, { resolve: resolver });
|
|
186
|
-
this.sendMessage({ request: req });
|
|
187
|
-
}
|
|
188
|
-
catch (error) {
|
|
189
|
-
reject(error);
|
|
190
|
-
}
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
/**
|
|
195
|
-
* @ignore
|
|
196
|
-
*
|
|
197
|
-
* IPC bus to communicate with the extension manager.
|
|
198
|
-
* If you are using this from inside your extension, you are WRONG and you should stop.
|
|
199
|
-
*/
|
|
200
|
-
exports.bus = new Bus(node_worker_threads_1.parentPort);
|
|
201
|
-
//e
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./navigation-provider";
|
|
@@ -1,17 +0,0 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./navigation-provider"), exports);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const react_1 = require("react");
|
|
4
|
-
const ctx = (0, react_1.createContext)({
|
|
5
|
-
pop: () => {
|
|
6
|
-
throw new Error("not implemented");
|
|
7
|
-
},
|
|
8
|
-
push: () => {
|
|
9
|
-
throw new Error("not implemented");
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
exports.default = ctx;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.NavigationProvider = void 0;
|
|
7
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
8
|
-
const react_1 = require("react");
|
|
9
|
-
const navigation_context_1 = __importDefault(require("./navigation-context"));
|
|
10
|
-
const bus_1 = require("../bus");
|
|
11
|
-
const View = ({ children }) => {
|
|
12
|
-
return (0, jsx_runtime_1.jsx)("view", { children: children });
|
|
13
|
-
};
|
|
14
|
-
/**
|
|
15
|
-
* @ignore
|
|
16
|
-
*/
|
|
17
|
-
const NavigationProvider = ({ root }) => {
|
|
18
|
-
const [navStack, setNavStack] = (0, react_1.useState)([root]);
|
|
19
|
-
const pendingShutdown = (0, react_1.useRef)(false);
|
|
20
|
-
const pop = () => {
|
|
21
|
-
if (pendingShutdown.current)
|
|
22
|
-
return;
|
|
23
|
-
// we ask Vicinae to pop the current view, but we need to wait
|
|
24
|
-
// for the pop-view event to be fired in order to dismount it from
|
|
25
|
-
// our local view stack: otherwise Vicinae might miss a render.
|
|
26
|
-
bus_1.bus.request("ui.popView", {});
|
|
27
|
-
};
|
|
28
|
-
const push = (node) => {
|
|
29
|
-
if (pendingShutdown.current)
|
|
30
|
-
return;
|
|
31
|
-
bus_1.bus.request("ui.pushView", {}).then(() => {
|
|
32
|
-
setNavStack((cur) => [...cur, node]);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
(0, react_1.useEffect)(() => {
|
|
36
|
-
if (pendingShutdown.current && navStack.length === 0) {
|
|
37
|
-
process.exit(0);
|
|
38
|
-
}
|
|
39
|
-
}, [navStack]);
|
|
40
|
-
(0, react_1.useEffect)(() => {
|
|
41
|
-
const shutdown = bus_1.bus.subscribe("shutdown", () => {
|
|
42
|
-
pendingShutdown.current = true;
|
|
43
|
-
setNavStack([]);
|
|
44
|
-
});
|
|
45
|
-
const listener = bus_1.bus.subscribe("pop-view", () => {
|
|
46
|
-
setNavStack((cur) => cur.slice(0, -1));
|
|
47
|
-
});
|
|
48
|
-
return () => {
|
|
49
|
-
shutdown.unsubscribe();
|
|
50
|
-
listener.unsubscribe();
|
|
51
|
-
};
|
|
52
|
-
}, []);
|
|
53
|
-
return ((0, jsx_runtime_1.jsx)(navigation_context_1.default.Provider, { value: {
|
|
54
|
-
push,
|
|
55
|
-
pop,
|
|
56
|
-
}, children: navStack.map((el, idx) => ((0, jsx_runtime_1.jsx)(View, { children: el }, idx))) }));
|
|
57
|
-
};
|
|
58
|
-
exports.NavigationProvider = NavigationProvider;
|
package/dist/api/hooks.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/api/hooks.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const handlerIdFactory = {
|
|
4
|
-
nextHandlerId: 0,
|
|
5
|
-
next() {
|
|
6
|
-
return this.nextHandlerId++;
|
|
7
|
-
},
|
|
8
|
-
};
|
|
9
|
-
/*
|
|
10
|
-
export const useEventListener = (
|
|
11
|
-
fn: ((...args: any[]) => void) | undefined,
|
|
12
|
-
) => {
|
|
13
|
-
const id = useRef(`handler:${handlerIdFactory.next()}`);
|
|
14
|
-
const callback = useRef<((...args: any[]) => void) | undefined>();
|
|
15
|
-
|
|
16
|
-
useEffect(() => {
|
|
17
|
-
const { unsubscribe } = bus.subscribe(id.current, (...args: any[]) => {
|
|
18
|
-
callback.current?.(...args);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
return unsubscribe;
|
|
22
|
-
}, []);
|
|
23
|
-
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
callback.current = fn;
|
|
26
|
-
}, [fn]);
|
|
27
|
-
|
|
28
|
-
return fn && id.current;
|
|
29
|
-
};
|
|
30
|
-
*/
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from "@bufbuild/protobuf/wire";
|
|
2
|
-
import { AckResponse } from "./common";
|
|
3
|
-
export declare const protobufPackage = "proto.ext.application";
|
|
4
|
-
export interface OpenApplicationRequest {
|
|
5
|
-
target: string;
|
|
6
|
-
appId?: string | undefined;
|
|
7
|
-
}
|
|
8
|
-
export interface RunInTerminalRequest {
|
|
9
|
-
cmdline: string[];
|
|
10
|
-
appId?: string | undefined;
|
|
11
|
-
workingDirectory?: string | undefined;
|
|
12
|
-
title?: string | undefined;
|
|
13
|
-
hold: boolean;
|
|
14
|
-
}
|
|
15
|
-
export interface ListApplicationRequest {
|
|
16
|
-
target?: string | undefined;
|
|
17
|
-
}
|
|
18
|
-
export interface ListApplicationResponse {
|
|
19
|
-
apps: Application[];
|
|
20
|
-
}
|
|
21
|
-
export interface GetDefaultApplicationRequest {
|
|
22
|
-
target: string;
|
|
23
|
-
}
|
|
24
|
-
export interface GetDefaultApplicationResponse {
|
|
25
|
-
app: Application | undefined;
|
|
26
|
-
}
|
|
27
|
-
export interface ShowInFileBrowserRequest {
|
|
28
|
-
target: string;
|
|
29
|
-
select: boolean;
|
|
30
|
-
}
|
|
31
|
-
export interface Request {
|
|
32
|
-
list?: ListApplicationRequest | undefined;
|
|
33
|
-
open?: OpenApplicationRequest | undefined;
|
|
34
|
-
getDefault?: GetDefaultApplicationRequest | undefined;
|
|
35
|
-
runInTerminal?: RunInTerminalRequest | undefined;
|
|
36
|
-
showInFileBrowser?: ShowInFileBrowserRequest | undefined;
|
|
37
|
-
}
|
|
38
|
-
export interface Response {
|
|
39
|
-
list?: ListApplicationResponse | undefined;
|
|
40
|
-
open?: AckResponse | undefined;
|
|
41
|
-
getDefault?: GetDefaultApplicationResponse | undefined;
|
|
42
|
-
runInTerminal?: AckResponse | undefined;
|
|
43
|
-
showInFileBrowser?: AckResponse | undefined;
|
|
44
|
-
}
|
|
45
|
-
export interface Application {
|
|
46
|
-
id: string;
|
|
47
|
-
name: string;
|
|
48
|
-
icon: string;
|
|
49
|
-
path: string;
|
|
50
|
-
}
|
|
51
|
-
export declare const OpenApplicationRequest: MessageFns<OpenApplicationRequest>;
|
|
52
|
-
export declare const RunInTerminalRequest: MessageFns<RunInTerminalRequest>;
|
|
53
|
-
export declare const ListApplicationRequest: MessageFns<ListApplicationRequest>;
|
|
54
|
-
export declare const ListApplicationResponse: MessageFns<ListApplicationResponse>;
|
|
55
|
-
export declare const GetDefaultApplicationRequest: MessageFns<GetDefaultApplicationRequest>;
|
|
56
|
-
export declare const GetDefaultApplicationResponse: MessageFns<GetDefaultApplicationResponse>;
|
|
57
|
-
export declare const ShowInFileBrowserRequest: MessageFns<ShowInFileBrowserRequest>;
|
|
58
|
-
export declare const Request: MessageFns<Request>;
|
|
59
|
-
export declare const Response: MessageFns<Response>;
|
|
60
|
-
export declare const Application: MessageFns<Application>;
|
|
61
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
|
|
62
|
-
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
63
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
64
|
-
} : Partial<T>;
|
|
65
|
-
type KeysOfUnion<T> = T extends T ? keyof T : never;
|
|
66
|
-
export type Exact<P, I extends P> = P extends Builtin ? P : P & {
|
|
67
|
-
[K in keyof P]: Exact<P[K], I[K]>;
|
|
68
|
-
} & {
|
|
69
|
-
[K in Exclude<keyof I, KeysOfUnion<P>>]: never;
|
|
70
|
-
};
|
|
71
|
-
export interface MessageFns<T> {
|
|
72
|
-
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
73
|
-
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
74
|
-
fromJSON(object: any): T;
|
|
75
|
-
toJSON(message: T): unknown;
|
|
76
|
-
create<I extends Exact<DeepPartial<T>, I>>(base?: I): T;
|
|
77
|
-
fromPartial<I extends Exact<DeepPartial<T>, I>>(object: I): T;
|
|
78
|
-
}
|
|
79
|
-
export {};
|