@owear/core 0.1.0 → 0.1.3
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/app.d.ts +122 -0
- package/dist/app.js +276 -0
- package/dist/bridge.d.ts +79 -0
- package/dist/bridge.js +55 -0
- package/dist/browserwindow.d.ts +113 -0
- package/dist/browserwindow.js +226 -0
- package/dist/channel.d.ts +22 -0
- package/dist/channel.js +114 -0
- package/dist/dialog.d.ts +47 -0
- package/dist/dialog.js +22 -0
- package/dist/index.d.ts +76 -96
- package/dist/index.js +24 -253
- package/dist/installer.d.ts +112 -0
- package/dist/installer.js +72 -0
- package/dist/ipc/node.d.ts +7 -0
- package/dist/ipc/node.js +25 -0
- package/dist/menu.d.ts +56 -0
- package/dist/menu.js +208 -0
- package/dist/modules.d.ts +16 -0
- package/dist/modules.js +13 -0
- package/dist/nativeimage.d.ts +41 -0
- package/dist/nativeimage.js +376 -0
- package/dist/node/worker-runner.d.ts +1 -0
- package/dist/node/worker-runner.js +35 -0
- package/dist/node/worker.d.ts +29 -0
- package/dist/node/worker.js +61 -0
- package/dist/port.d.ts +28 -0
- package/dist/port.js +42 -0
- package/dist/power.d.ts +33 -0
- package/dist/power.js +99 -0
- package/dist/protocol.d.ts +14 -0
- package/dist/protocol.js +46 -0
- package/dist/safestorage.d.ts +16 -0
- package/dist/safestorage.js +21 -0
- package/dist/screen.d.ts +92 -0
- package/dist/screen.js +121 -0
- package/dist/session.d.ts +24 -0
- package/dist/session.js +42 -0
- package/dist/theme.d.ts +30 -0
- package/dist/theme.js +34 -0
- package/dist/tray.d.ts +30 -0
- package/dist/tray.js +69 -0
- package/dist/webcontents.d.ts +44 -0
- package/dist/webcontents.js +109 -0
- package/dist/webrequest.d.ts +23 -0
- package/dist/webrequest.js +76 -0
- package/package.json +4 -3
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// Copyright 2026 Owear Contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
//
|
|
4
|
+
// @owear/core/src/browserwindow.ts — BrowserWindow (C9).
|
|
5
|
+
import { EventEmitter } from 'node:events';
|
|
6
|
+
import { channel } from './channel.js';
|
|
7
|
+
import { readyPromise } from './app.js';
|
|
8
|
+
import { WebContents, WIN_EVENT_NAMES, WC_EVENT_NAMES } from './webcontents.js';
|
|
9
|
+
// ── BrowserWindow ───────────────────────────────────────────────────────────
|
|
10
|
+
/** Registro de ventanas por id (para resolver clicks de menú). */
|
|
11
|
+
export const windowsById = new Map();
|
|
12
|
+
/** Ventana con foco (para `BrowserWindow.getFocusedWindow`). */
|
|
13
|
+
let focusedWindowId = 0;
|
|
14
|
+
export class BrowserWindow extends EventEmitter {
|
|
15
|
+
_id = null;
|
|
16
|
+
_options;
|
|
17
|
+
_wc = new WebContents(null);
|
|
18
|
+
_onWindowEvent;
|
|
19
|
+
_onDisconnected;
|
|
20
|
+
constructor(options = {}) {
|
|
21
|
+
super();
|
|
22
|
+
this._options = options;
|
|
23
|
+
if (!readyPromise) {
|
|
24
|
+
throw new Error('BrowserWindow creado antes de app.whenReady()');
|
|
25
|
+
}
|
|
26
|
+
this._onWindowEvent = (params) => {
|
|
27
|
+
if (params.windowId !== this._id)
|
|
28
|
+
return;
|
|
29
|
+
this.emit(params.name, params.payload);
|
|
30
|
+
const dashWin = WIN_EVENT_NAMES[params.name];
|
|
31
|
+
if (dashWin)
|
|
32
|
+
this.emit(dashWin, params.payload);
|
|
33
|
+
this._wc.emit(WC_EVENT_NAMES[params.name] ?? params.name, params.payload);
|
|
34
|
+
if (params.name === 'focus' && this._id != null)
|
|
35
|
+
focusedWindowId = this._id;
|
|
36
|
+
if (params.name === 'blur' && this._id != null && focusedWindowId === this._id)
|
|
37
|
+
focusedWindowId = 0;
|
|
38
|
+
if (params.name === 'closed') {
|
|
39
|
+
if (this._id != null)
|
|
40
|
+
windowsById.delete(this._id);
|
|
41
|
+
this._unwireEvents();
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
this._onDisconnected = () => this.emit('disconnected');
|
|
45
|
+
readyPromise.then(() => this._create()).catch((e) => this.emit('error', e));
|
|
46
|
+
}
|
|
47
|
+
async _create() {
|
|
48
|
+
const params = { ...this._options };
|
|
49
|
+
const res = await channel.call('window.create', params);
|
|
50
|
+
this._id = res.windowId;
|
|
51
|
+
this._wc._setWindowId(res.windowId);
|
|
52
|
+
windowsById.set(res.windowId, this);
|
|
53
|
+
this._wireEvents();
|
|
54
|
+
this.emit('ready-to-show', this._id);
|
|
55
|
+
}
|
|
56
|
+
_wireEvents() {
|
|
57
|
+
channel.on('window.event', this._onWindowEvent);
|
|
58
|
+
channel.on('disconnected', this._onDisconnected);
|
|
59
|
+
}
|
|
60
|
+
_unwireEvents() {
|
|
61
|
+
channel.off('window.event', this._onWindowEvent);
|
|
62
|
+
channel.off('disconnected', this._onDisconnected);
|
|
63
|
+
}
|
|
64
|
+
get id() {
|
|
65
|
+
return this._id;
|
|
66
|
+
}
|
|
67
|
+
requireId() {
|
|
68
|
+
if (this._id == null)
|
|
69
|
+
throw new Error('ventana aún no creada');
|
|
70
|
+
return this._id;
|
|
71
|
+
}
|
|
72
|
+
// ── carga ──────────────────────────────────────────────────────────────
|
|
73
|
+
loadURL(url) {
|
|
74
|
+
return channel.call('window.loadURL', { windowId: this.requireId(), url });
|
|
75
|
+
}
|
|
76
|
+
/** Evalúa JS; devuelve el resultado JSON-serializado. */
|
|
77
|
+
eval(js) {
|
|
78
|
+
return channel.call('window.eval', { windowId: this.requireId(), js });
|
|
79
|
+
}
|
|
80
|
+
// ── ciclo de vida ──────────────────────────────────────────────────────
|
|
81
|
+
show() {
|
|
82
|
+
return channel.call('window.show', { windowId: this.requireId() });
|
|
83
|
+
}
|
|
84
|
+
hide() {
|
|
85
|
+
return channel.call('window.hide', { windowId: this.requireId() });
|
|
86
|
+
}
|
|
87
|
+
focus() {
|
|
88
|
+
return channel.call('window.focus', { windowId: this.requireId() });
|
|
89
|
+
}
|
|
90
|
+
close() {
|
|
91
|
+
return channel.call('window.close', { windowId: this.requireId() });
|
|
92
|
+
}
|
|
93
|
+
destroy() {
|
|
94
|
+
return channel.call('window.destroy', { windowId: this.requireId() });
|
|
95
|
+
}
|
|
96
|
+
minimize() {
|
|
97
|
+
return channel.call('window.minimize', { windowId: this.requireId() });
|
|
98
|
+
}
|
|
99
|
+
maximize() {
|
|
100
|
+
return channel.call('window.maximize', { windowId: this.requireId(), enabled: true });
|
|
101
|
+
}
|
|
102
|
+
unmaximize() {
|
|
103
|
+
return channel.call('window.maximize', { windowId: this.requireId(), enabled: false });
|
|
104
|
+
}
|
|
105
|
+
setFullScreen(enabled) {
|
|
106
|
+
return channel.call('window.setFullScreen', { windowId: this.requireId(), enabled });
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Responde a un `closeRequested` (F3.4).
|
|
110
|
+
* `allow=false` cancela el cierre; `true` destruye la ventana.
|
|
111
|
+
* Si nadie responde en `OW_CLOSE_TIMEOUT_MS` (default 1000 ms), el kernel
|
|
112
|
+
* cierra igualmente.
|
|
113
|
+
*/
|
|
114
|
+
closeRespond(requestId, allow) {
|
|
115
|
+
return channel.call('window.respondCloseRequest', {
|
|
116
|
+
windowId: this.requireId(),
|
|
117
|
+
requestId,
|
|
118
|
+
allow,
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
// ── estado ─────────────────────────────────────────────────────────────
|
|
122
|
+
isMaximized() {
|
|
123
|
+
return channel.call('window.isMaximized', { windowId: this.requireId() });
|
|
124
|
+
}
|
|
125
|
+
isMinimized() {
|
|
126
|
+
return channel.call('window.isMinimized', { windowId: this.requireId() });
|
|
127
|
+
}
|
|
128
|
+
getBounds() {
|
|
129
|
+
return channel.call('window.getBounds', { windowId: this.requireId() });
|
|
130
|
+
}
|
|
131
|
+
setBounds(b) {
|
|
132
|
+
return channel.call('window.setBounds', { windowId: this.requireId(), ...b });
|
|
133
|
+
}
|
|
134
|
+
setTitle(title) {
|
|
135
|
+
return channel.call('window.setTitle', { windowId: this.requireId(), title });
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Activa/desactiva o reconfigura los botones nativos de ventana
|
|
139
|
+
* (min/max/close) dentro de la titlebar custom (Linux: GTK `titlebutton`).
|
|
140
|
+
* `true` los activa con los valores por defecto.
|
|
141
|
+
*/
|
|
142
|
+
setTitleBarOverlay(overlay) {
|
|
143
|
+
return channel.call('window.setTitleBarOverlay', {
|
|
144
|
+
windowId: this.requireId(),
|
|
145
|
+
titleBarOverlay: overlay,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
// ── estado extendido (C9) ──────────────────────────────────────────────
|
|
149
|
+
isVisible() { return channel.call('window.isVisible', { windowId: this.requireId() }); }
|
|
150
|
+
isFocused() { return channel.call('window.isFocused', { windowId: this.requireId() }); }
|
|
151
|
+
isResizable() { return channel.call('window.isResizable', { windowId: this.requireId() }); }
|
|
152
|
+
isMovable() { return channel.call('window.isMovable', { windowId: this.requireId() }); }
|
|
153
|
+
isMinimizable() { return channel.call('window.isMinimizable', { windowId: this.requireId() }); }
|
|
154
|
+
isMaximizable() { return channel.call('window.isMaximizable', { windowId: this.requireId() }); }
|
|
155
|
+
isClosable() { return channel.call('window.isClosable', { windowId: this.requireId() }); }
|
|
156
|
+
isAlwaysOnTop() { return channel.call('window.isAlwaysOnTop', { windowId: this.requireId() }); }
|
|
157
|
+
isKiosk() { return channel.call('window.isKiosk', { windowId: this.requireId() }); }
|
|
158
|
+
isDestroyed() { return channel.call('window.isDestroyed', { windowId: this.requireId() }); }
|
|
159
|
+
isFullScreen() { return channel.call('window.isFullScreen', { windowId: this.requireId() }); }
|
|
160
|
+
setResizable(on = true) { return channel.call('window.setResizable', { windowId: this.requireId(), on }); }
|
|
161
|
+
setMovable(on = true) { return channel.call('window.setMovable', { windowId: this.requireId(), on }); }
|
|
162
|
+
setMinimizable(on = true) { return channel.call('window.setMinimizable', { windowId: this.requireId(), on }); }
|
|
163
|
+
setMaximizable(on = true) { return channel.call('window.setMaximizable', { windowId: this.requireId(), on }); }
|
|
164
|
+
setClosable(on = true) { return channel.call('window.setClosable', { windowId: this.requireId(), on }); }
|
|
165
|
+
setAlwaysOnTop(on = true, level = 0) { return channel.call('window.setAlwaysOnTop', { windowId: this.requireId(), on, level }); }
|
|
166
|
+
setSkipTaskbar(on = true) { return channel.call('window.setSkipTaskbar', { windowId: this.requireId(), on }); }
|
|
167
|
+
setHasShadow(on = true) { return channel.call('window.setHasShadow', { windowId: this.requireId(), on }); }
|
|
168
|
+
setKiosk(on = true) { return channel.call('window.setKiosk', { windowId: this.requireId(), on }); }
|
|
169
|
+
setIgnoreMouseEvents(ignore = true, options = {}) {
|
|
170
|
+
return channel.call('window.setIgnoreMouseEvents', { windowId: this.requireId(), ignore, forward: !!options.forward });
|
|
171
|
+
}
|
|
172
|
+
setProgressBar(value, options = {}) {
|
|
173
|
+
return channel.call('window.setProgressBar', { windowId: this.requireId(), value, mode: options.mode ?? 'normal' });
|
|
174
|
+
}
|
|
175
|
+
setBackgroundColor(color) {
|
|
176
|
+
return channel.call('window.setBackgroundColor', { windowId: this.requireId(), color });
|
|
177
|
+
}
|
|
178
|
+
moveTop() { return channel.call('window.moveTop', { windowId: this.requireId() }); }
|
|
179
|
+
setAspectRatio(ratio, extraSize) {
|
|
180
|
+
return channel.call('window.setAspectRatio', {
|
|
181
|
+
windowId: this.requireId(),
|
|
182
|
+
ratio,
|
|
183
|
+
extraW: extraSize?.width ?? 0,
|
|
184
|
+
extraH: extraSize?.height ?? 0,
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
getContentBounds() { return channel.call('window.getContentBounds', { windowId: this.requireId() }); }
|
|
188
|
+
setContentSize(width, height) {
|
|
189
|
+
return channel.call('window.setContentSize', { windowId: this.requireId(), width, height });
|
|
190
|
+
}
|
|
191
|
+
getContentSize() {
|
|
192
|
+
return channel.call('window.getContentSize', { windowId: this.requireId() });
|
|
193
|
+
}
|
|
194
|
+
getMinimumSize() {
|
|
195
|
+
return channel.call('window.getMinimumSize', { windowId: this.requireId() });
|
|
196
|
+
}
|
|
197
|
+
getMaximumSize() {
|
|
198
|
+
return channel.call('window.getMaximumSize', { windowId: this.requireId() });
|
|
199
|
+
}
|
|
200
|
+
setMinimumSize(width, height) {
|
|
201
|
+
return channel.call('window.setMinimumSize', { windowId: this.requireId(), width, height });
|
|
202
|
+
}
|
|
203
|
+
setMaximumSize(width, height) {
|
|
204
|
+
return channel.call('window.setMaximumSize', { windowId: this.requireId(), width, height });
|
|
205
|
+
}
|
|
206
|
+
// ── estáticos (C9) ─────────────────────────────────────────────────────
|
|
207
|
+
/** Ventanas creadas por esta app (orden de creación). Síncrono, como Electron. */
|
|
208
|
+
static getAllWindows() {
|
|
209
|
+
return [...windowsById.values()];
|
|
210
|
+
}
|
|
211
|
+
/** Ventana con foco, o `null`. Síncrono, como Electron. */
|
|
212
|
+
static getFocusedWindow() {
|
|
213
|
+
return focusedWindowId ? windowsById.get(focusedWindowId) ?? null : null;
|
|
214
|
+
}
|
|
215
|
+
static fromId(id) {
|
|
216
|
+
return windowsById.get(id) ?? null;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* `webContents` de esta ventana (estilo Electron): `send`, `capturePage`,
|
|
220
|
+
* eventos (`did-finish-load`, `before-input-event`, …) y
|
|
221
|
+
* `setWindowOpenHandler`.
|
|
222
|
+
*/
|
|
223
|
+
get webContents() {
|
|
224
|
+
return this._wc;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
export declare class ControlChannel extends EventEmitter {
|
|
3
|
+
private socket;
|
|
4
|
+
private buffer;
|
|
5
|
+
private nextId;
|
|
6
|
+
private pending;
|
|
7
|
+
connect(socketPath: string): Promise<void>;
|
|
8
|
+
private rejectAllPending;
|
|
9
|
+
private handleLine;
|
|
10
|
+
call<T = any>(cmd: string, params?: Record<string, unknown>): Promise<T>;
|
|
11
|
+
}
|
|
12
|
+
/** Canal singleton con el kernel. */
|
|
13
|
+
export declare const channel: ControlChannel;
|
|
14
|
+
/** Ruta del control socket (env o último de XDG_RUNTIME_DIR). */
|
|
15
|
+
export declare function socketPathFromEnv(): string;
|
|
16
|
+
/**
|
|
17
|
+
* Invoca un módulo nativo (.owm) desde el proceso principal. Equivalente a
|
|
18
|
+
* `ow.invoke()` del renderer, pero sin depender de una ventana.
|
|
19
|
+
*
|
|
20
|
+
* const txt = await invokeNative<string>('fs', 'readText', '/etc/hostname')
|
|
21
|
+
*/
|
|
22
|
+
export declare function invokeNative<T = unknown>(module: string, method: string, ...args: unknown[]): Promise<T>;
|
package/dist/channel.js
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
// Copyright 2026 Owear Contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
//
|
|
4
|
+
// @owear/core/src/channel.ts — canal de control (NDJSON) con el kernel.
|
|
5
|
+
//
|
|
6
|
+
// Piedra angular del SDK: sin dependencias de otras partes del paquete (evita
|
|
7
|
+
// ciclos). El resto de features importan `channel` / `invokeNative` de aquí.
|
|
8
|
+
import * as net from 'node:net';
|
|
9
|
+
import { EventEmitter } from 'node:events';
|
|
10
|
+
import * as fs from 'node:fs';
|
|
11
|
+
import * as path from 'node:path';
|
|
12
|
+
export class ControlChannel extends EventEmitter {
|
|
13
|
+
socket = null;
|
|
14
|
+
buffer = '';
|
|
15
|
+
nextId = 1;
|
|
16
|
+
pending = new Map();
|
|
17
|
+
connect(socketPath) {
|
|
18
|
+
return new Promise((resolve, reject) => {
|
|
19
|
+
const sock = net.connect(socketPath);
|
|
20
|
+
sock.once('connect', () => {
|
|
21
|
+
this.socket = sock;
|
|
22
|
+
resolve();
|
|
23
|
+
});
|
|
24
|
+
sock.once('error', (err) => {
|
|
25
|
+
this.socket = null;
|
|
26
|
+
this.rejectAllPending(err);
|
|
27
|
+
reject(err);
|
|
28
|
+
});
|
|
29
|
+
sock.on('data', (chunk) => {
|
|
30
|
+
this.buffer += chunk.toString('utf8');
|
|
31
|
+
let idx;
|
|
32
|
+
while ((idx = this.buffer.indexOf('\n')) >= 0) {
|
|
33
|
+
const line = this.buffer.slice(0, idx);
|
|
34
|
+
this.buffer = this.buffer.slice(idx + 1);
|
|
35
|
+
if (line.trim())
|
|
36
|
+
this.handleLine(line);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
sock.on('close', () => {
|
|
40
|
+
this.socket = null;
|
|
41
|
+
this.rejectAllPending(new Error('conexión cerrada'));
|
|
42
|
+
this.emit('disconnected');
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
rejectAllPending(err) {
|
|
47
|
+
for (const { reject } of this.pending.values()) {
|
|
48
|
+
reject(err);
|
|
49
|
+
}
|
|
50
|
+
this.pending.clear();
|
|
51
|
+
}
|
|
52
|
+
handleLine(line) {
|
|
53
|
+
let msg;
|
|
54
|
+
try {
|
|
55
|
+
msg = JSON.parse(line);
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (msg.event) {
|
|
61
|
+
this.emit(msg.event, msg.params);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const p = this.pending.get(msg.id);
|
|
65
|
+
if (!p)
|
|
66
|
+
return;
|
|
67
|
+
this.pending.delete(msg.id);
|
|
68
|
+
if (msg.ok)
|
|
69
|
+
p.resolve(msg.result);
|
|
70
|
+
else
|
|
71
|
+
p.reject(new Error(msg.error ?? 'error de control'));
|
|
72
|
+
}
|
|
73
|
+
call(cmd, params = {}) {
|
|
74
|
+
if (!this.socket)
|
|
75
|
+
return Promise.reject(new Error('control socket desconectado'));
|
|
76
|
+
const id = this.nextId++;
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
this.pending.set(id, { resolve, reject });
|
|
79
|
+
this.socket.write(JSON.stringify({ id, cmd, params }) + '\n');
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Canal singleton con el kernel. */
|
|
84
|
+
export const channel = new ControlChannel();
|
|
85
|
+
/** Ruta del control socket (env o último de XDG_RUNTIME_DIR). */
|
|
86
|
+
export function socketPathFromEnv() {
|
|
87
|
+
if (process.env.OW_CONTROL_SOCKET)
|
|
88
|
+
return process.env.OW_CONTROL_SOCKET;
|
|
89
|
+
// fallback: último socket vivo en XDG_RUNTIME_DIR (útil para depurar)
|
|
90
|
+
const dir = process.env.XDG_RUNTIME_DIR;
|
|
91
|
+
if (dir) {
|
|
92
|
+
try {
|
|
93
|
+
const socks = fs
|
|
94
|
+
.readdirSync(dir)
|
|
95
|
+
.filter((f) => f.startsWith('owear-') && f.endsWith('.sock'))
|
|
96
|
+
.sort();
|
|
97
|
+
if (socks.length)
|
|
98
|
+
return path.join(dir, socks[socks.length - 1]);
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
/* noop */
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
throw new Error('Owear: OW_CONTROL_SOCKET no definida. Lanza la app con `ow dev` o `ow build && owear`.');
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Invoca un módulo nativo (.owm) desde el proceso principal. Equivalente a
|
|
108
|
+
* `ow.invoke()` del renderer, pero sin depender de una ventana.
|
|
109
|
+
*
|
|
110
|
+
* const txt = await invokeNative<string>('fs', 'readText', '/etc/hostname')
|
|
111
|
+
*/
|
|
112
|
+
export function invokeNative(module, method, ...args) {
|
|
113
|
+
return channel.call('module.invoke', { module, method, args });
|
|
114
|
+
}
|
package/dist/dialog.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export interface FileFilter {
|
|
2
|
+
name: string;
|
|
3
|
+
extensions: string[];
|
|
4
|
+
}
|
|
5
|
+
export interface OpenDialogOptions {
|
|
6
|
+
title?: string;
|
|
7
|
+
defaultPath?: string;
|
|
8
|
+
buttonLabel?: string;
|
|
9
|
+
filters?: FileFilter[];
|
|
10
|
+
properties?: Array<'openFile' | 'openDirectory' | 'multiSelections' | 'showHiddenFiles' | 'createDirectory'>;
|
|
11
|
+
}
|
|
12
|
+
export interface SaveDialogOptions {
|
|
13
|
+
title?: string;
|
|
14
|
+
defaultPath?: string;
|
|
15
|
+
buttonLabel?: string;
|
|
16
|
+
filters?: FileFilter[];
|
|
17
|
+
}
|
|
18
|
+
export interface MessageBoxOptions {
|
|
19
|
+
type?: 'none' | 'info' | 'error' | 'question' | 'warning';
|
|
20
|
+
title?: string;
|
|
21
|
+
message: string;
|
|
22
|
+
detail?: string;
|
|
23
|
+
buttons?: string[];
|
|
24
|
+
defaultId?: number;
|
|
25
|
+
cancelId?: number;
|
|
26
|
+
checkboxLabel?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Diálogos nativos (módulo `dialog`).
|
|
30
|
+
* const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile','multiSelections'] })
|
|
31
|
+
* const { filePath } = await dialog.showSaveDialog({ defaultPath: '/tmp/x.txt' })
|
|
32
|
+
* const { response } = await dialog.showMessageBox({ message: '¿Seguir?', buttons: ['Sí','No'] })
|
|
33
|
+
*/
|
|
34
|
+
export declare const dialog: {
|
|
35
|
+
showOpenDialog(options?: OpenDialogOptions): Promise<{
|
|
36
|
+
canceled: boolean;
|
|
37
|
+
filePaths: string[];
|
|
38
|
+
}>;
|
|
39
|
+
showSaveDialog(options?: SaveDialogOptions): Promise<{
|
|
40
|
+
canceled: boolean;
|
|
41
|
+
filePath: string;
|
|
42
|
+
}>;
|
|
43
|
+
showMessageBox(options: MessageBoxOptions): Promise<{
|
|
44
|
+
response: number;
|
|
45
|
+
checkboxChecked: boolean;
|
|
46
|
+
}>;
|
|
47
|
+
};
|
package/dist/dialog.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2026 Owear Contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
//
|
|
4
|
+
// @owear/core/src/dialog.ts — diálogos nativos (módulo `dialog`).
|
|
5
|
+
import { invokeNative } from './channel.js';
|
|
6
|
+
/**
|
|
7
|
+
* Diálogos nativos (módulo `dialog`).
|
|
8
|
+
* const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile','multiSelections'] })
|
|
9
|
+
* const { filePath } = await dialog.showSaveDialog({ defaultPath: '/tmp/x.txt' })
|
|
10
|
+
* const { response } = await dialog.showMessageBox({ message: '¿Seguir?', buttons: ['Sí','No'] })
|
|
11
|
+
*/
|
|
12
|
+
export const dialog = {
|
|
13
|
+
showOpenDialog(options = {}) {
|
|
14
|
+
return invokeNative('dialog', 'showOpenDialog', options);
|
|
15
|
+
},
|
|
16
|
+
showSaveDialog(options = {}) {
|
|
17
|
+
return invokeNative('dialog', 'showSaveDialog', options);
|
|
18
|
+
},
|
|
19
|
+
showMessageBox(options) {
|
|
20
|
+
return invokeNative('dialog', 'showMessageBox', options);
|
|
21
|
+
},
|
|
22
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,47 @@
|
|
|
1
|
-
|
|
1
|
+
export { NativeImage, nativeImage } from './nativeimage.js';
|
|
2
|
+
export type { Size as NativeImageSize, Rectangle, ResizeOptions } from './nativeimage.js';
|
|
2
3
|
export interface WindowOptions {
|
|
3
4
|
title?: string;
|
|
4
5
|
width?: number;
|
|
5
6
|
height?: number;
|
|
6
7
|
x?: number;
|
|
7
8
|
y?: number;
|
|
9
|
+
minWidth?: number;
|
|
10
|
+
minHeight?: number;
|
|
11
|
+
maxWidth?: number;
|
|
12
|
+
maxHeight?: number;
|
|
8
13
|
resizable?: boolean;
|
|
14
|
+
movable?: boolean;
|
|
15
|
+
minimizable?: boolean;
|
|
16
|
+
maximizable?: boolean;
|
|
17
|
+
closable?: boolean;
|
|
18
|
+
fullscreenable?: boolean;
|
|
9
19
|
frameless?: boolean;
|
|
20
|
+
transparent?: boolean;
|
|
21
|
+
backgroundColor?: string;
|
|
22
|
+
show?: boolean;
|
|
23
|
+
skipTaskbar?: boolean;
|
|
24
|
+
alwaysOnTop?: boolean;
|
|
25
|
+
hasShadow?: boolean;
|
|
26
|
+
aspectRatio?: number;
|
|
27
|
+
/** Ventana padre (id de otra ventana) y si es modal respecto a ella. */
|
|
28
|
+
parent?: number;
|
|
29
|
+
modal?: boolean;
|
|
10
30
|
titleBarStyle?: 'default' | 'hidden' | 'custom';
|
|
11
|
-
titleBarOverlay?: {
|
|
31
|
+
titleBarOverlay?: boolean | {
|
|
32
|
+
enabled?: boolean;
|
|
12
33
|
color?: string;
|
|
13
34
|
symbolColor?: string;
|
|
35
|
+
buttonColor?: string;
|
|
14
36
|
height?: number;
|
|
15
37
|
};
|
|
16
38
|
url?: string;
|
|
39
|
+
/**
|
|
40
|
+
* Partición de sesión: aísla cookies/localStorage/IndexedDB/cache por perfil.
|
|
41
|
+
* Vacío = perfil por defecto de la app. Ej: "persist:cuenta-2".
|
|
42
|
+
* Crea la partición con `session.fromPartition(name)`.
|
|
43
|
+
*/
|
|
44
|
+
session?: string;
|
|
17
45
|
}
|
|
18
46
|
export interface Bounds {
|
|
19
47
|
x: number;
|
|
@@ -21,6 +49,16 @@ export interface Bounds {
|
|
|
21
49
|
width: number;
|
|
22
50
|
height: number;
|
|
23
51
|
}
|
|
52
|
+
/**
|
|
53
|
+
* Vista mínima de `webContents` (paridad con Electron) para el envío dirigido
|
|
54
|
+
* main → renderer. `send` llega al renderer como `ow.on(name, cb)`.
|
|
55
|
+
*/
|
|
56
|
+
export interface WebContentsHandle {
|
|
57
|
+
/** Id de la ventana/webContents (-1 si aún no se creó). */
|
|
58
|
+
readonly id: number;
|
|
59
|
+
/** Envía un evento SOLO a esta ventana. */
|
|
60
|
+
send(name: string, payload?: unknown): Promise<void>;
|
|
61
|
+
}
|
|
24
62
|
export type WindowEventMap = {
|
|
25
63
|
resize: Bounds;
|
|
26
64
|
move: Bounds;
|
|
@@ -35,99 +73,42 @@ export type WindowEventMap = {
|
|
|
35
73
|
};
|
|
36
74
|
closed: void;
|
|
37
75
|
};
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
export
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
* portar APIs de Electron al main process.
|
|
75
|
-
*
|
|
76
|
-
* const txt = await invokeNative<string>('fs', 'readText', '/etc/hostname')
|
|
77
|
-
*/
|
|
78
|
-
export declare function invokeNative<T = unknown>(module: string, method: string, ...args: unknown[]): Promise<T>;
|
|
79
|
-
/** Metadatos de un módulo nativo cargado en el kernel. */
|
|
80
|
-
export interface NativeModuleInfo {
|
|
81
|
-
name: string;
|
|
82
|
-
version: string;
|
|
83
|
-
/** Ruta del .owm o "builtin:<nombre>" para los enlazados al kernel. */
|
|
84
|
-
origin: string;
|
|
85
|
-
builtin: boolean;
|
|
86
|
-
/** Número de funciones (compat). */
|
|
87
|
-
functions: number;
|
|
88
|
-
/** Nombres de las funciones. */
|
|
89
|
-
functionNames: string[];
|
|
90
|
-
}
|
|
91
|
-
/** Módulos nativos cargados, con versión, origen y funciones. */
|
|
92
|
-
export declare function listNativeModules(): Promise<NativeModuleInfo[]>;
|
|
93
|
-
/** Metadatos de un módulo nativo concreto. Rechaza si no existe. */
|
|
94
|
-
export declare function nativeModuleInfo(name: string): Promise<NativeModuleInfo>;
|
|
95
|
-
export declare class BrowserWindow extends EventEmitter {
|
|
96
|
-
private _id;
|
|
97
|
-
private _options;
|
|
98
|
-
private _onWindowEvent;
|
|
99
|
-
private _onDisconnected;
|
|
100
|
-
constructor(options?: WindowOptions);
|
|
101
|
-
private _create;
|
|
102
|
-
private _wireEvents;
|
|
103
|
-
private _unwireEvents;
|
|
104
|
-
get id(): number | null;
|
|
105
|
-
private requireId;
|
|
106
|
-
loadURL(url: string): Promise<void>;
|
|
107
|
-
/** Evalúa JS; devuelve el resultado JSON-serializado. */
|
|
108
|
-
eval<T = unknown>(js: string): Promise<T>;
|
|
109
|
-
show(): Promise<void>;
|
|
110
|
-
hide(): Promise<void>;
|
|
111
|
-
focus(): Promise<void>;
|
|
112
|
-
close(): Promise<void>;
|
|
113
|
-
destroy(): Promise<void>;
|
|
114
|
-
minimize(): Promise<void>;
|
|
115
|
-
maximize(): Promise<void>;
|
|
116
|
-
unmaximize(): Promise<void>;
|
|
117
|
-
setFullScreen(enabled: boolean): Promise<void>;
|
|
118
|
-
/**
|
|
119
|
-
* Responde a un `closeRequested` (F3.4).
|
|
120
|
-
* `allow=false` cancela el cierre; `true` destruye la ventana.
|
|
121
|
-
* Si nadie responde en `OW_CLOSE_TIMEOUT_MS` (default 1000 ms), el kernel
|
|
122
|
-
* cierra igualmente.
|
|
123
|
-
*/
|
|
124
|
-
closeRespond(requestId: number, allow: boolean): Promise<void>;
|
|
125
|
-
isMaximized(): Promise<boolean>;
|
|
126
|
-
isMinimized(): Promise<boolean>;
|
|
127
|
-
getBounds(): Promise<Bounds>;
|
|
128
|
-
setBounds(b: Partial<Bounds>): Promise<void>;
|
|
129
|
-
setTitle(title: string): Promise<void>;
|
|
130
|
-
}
|
|
76
|
+
export { invokeNative } from './channel.js';
|
|
77
|
+
export { listNativeModules, nativeModuleInfo } from './modules.js';
|
|
78
|
+
export type { NativeModuleInfo } from './modules.js';
|
|
79
|
+
export { theme, nativeTheme } from './theme.js';
|
|
80
|
+
export type { ThemeInfo } from './theme.js';
|
|
81
|
+
export { screen } from './screen.js';
|
|
82
|
+
export type { DisplayBounds, DisplaySize, Display, DisplayMetric } from './screen.js';
|
|
83
|
+
export { powerMonitor, powerSaveBlocker } from './power.js';
|
|
84
|
+
export type { IdleState, PowerSaveBlockerType } from './power.js';
|
|
85
|
+
export { safeStorage } from './safestorage.js';
|
|
86
|
+
export type { SafeStorageResult } from './safestorage.js';
|
|
87
|
+
export { session } from './session.js';
|
|
88
|
+
export type { PermissionRequest, PermissionHandler } from './session.js';
|
|
89
|
+
export { webRequest } from './webrequest.js';
|
|
90
|
+
export type { WebRequestDetails, WebRequestResult, WebRequestHandler } from './webrequest.js';
|
|
91
|
+
export { dialog } from './dialog.js';
|
|
92
|
+
export type { FileFilter, OpenDialogOptions, SaveDialogOptions, MessageBoxOptions } from './dialog.js';
|
|
93
|
+
export { WebContents } from './webcontents.js';
|
|
94
|
+
export { BrowserWindow } from './browserwindow.js';
|
|
95
|
+
export { MenuItem, Menu } from './menu.js';
|
|
96
|
+
export { Tray } from './tray.js';
|
|
97
|
+
export type { TrayEvent } from './tray.js';
|
|
98
|
+
export { nodeHandlers, nodeContextHandlers } from './ipc/node.js';
|
|
99
|
+
export type { NodeHandler, ContextNodeHandler } from './ipc/node.js';
|
|
100
|
+
export { protocolHandlers } from './protocol.js';
|
|
101
|
+
export type { ProtocolRequest, ProtocolHandlerResult, ProtocolHandler } from './protocol.js';
|
|
102
|
+
export { portRecords, makeMainPort, allocPortId } from './port.js';
|
|
103
|
+
export type { MessagePortMain } from './port.js';
|
|
104
|
+
export { app } from './app.js';
|
|
105
|
+
export { readyPromise } from './app.js';
|
|
106
|
+
export { installer } from './installer.js';
|
|
107
|
+
export type { InstallerMode, PayloadEntry, InstallerInfo, PlanOptions, InstallOptions, InstallResult, UninstallResult, VerifyResult, StateResult, ShortcutOptions, LaunchOptions, } from './installer.js';
|
|
108
|
+
export { defineBridge } from './bridge.js';
|
|
109
|
+
export type { OwearBridge, BridgeApp, BridgeTarget, BridgePlatform, BridgeFormat, BridgeLayout, BridgePreset, BridgeGroup, BridgeProtect, BridgeNode, BridgeHooks, } from './bridge.js';
|
|
110
|
+
export { forkWorker, resolveWorkerEntry } from './node/worker.js';
|
|
111
|
+
export type { ForkWorkerOptions, WorkerHandle } from './node/worker.js';
|
|
131
112
|
/** Tipos de `window.ow` disponible dentro del WebView (inyectado por el kernel). */
|
|
132
113
|
export interface OwBridge {
|
|
133
114
|
invoke<T = unknown>(module: string, fn: string, ...args: unknown[]): Promise<T>;
|
|
@@ -141,4 +122,3 @@ declare global {
|
|
|
141
122
|
const ow: OwBridge;
|
|
142
123
|
}
|
|
143
124
|
export declare const platform: NodeJS.Platform;
|
|
144
|
-
export {};
|