opentray 0.5.0 → 0.5.2
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 +51 -13
- package/assets/lynx-review/README.md +14 -0
- package/assets/lynx-review/main.lynx.bundle +0 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.d.mts.map +1 -1
- package/dist/cli.mjs +133 -20
- package/dist/cli.mjs.map +1 -1
- package/dist/{client-h6gZdeOk.d.mts → client-DQn3DLZw.d.mts} +27 -2
- package/dist/client-DQn3DLZw.d.mts.map +1 -0
- package/dist/{client-B_zxQOo5.mjs → client-DzcHIH-f.mjs} +91 -34
- package/dist/client-DzcHIH-f.mjs.map +1 -0
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/node.d.mts +1 -1
- package/package.json +9 -8
- package/dist/client-B_zxQOo5.mjs.map +0 -1
- package/dist/client-h6gZdeOk.d.mts.map +0 -1
package/README.md
CHANGED
|
@@ -34,15 +34,18 @@ const space = await createSpace({ id: "com.example.status", default: true });
|
|
|
34
34
|
await space.createTray({
|
|
35
35
|
trayId: "status",
|
|
36
36
|
title: "Status",
|
|
37
|
-
icon: { type: "
|
|
37
|
+
icon: { type: "file", path: "./assets/tray-icon.png" },
|
|
38
38
|
});
|
|
39
39
|
|
|
40
40
|
const defaultSpace = await resolveDefaultSpace();
|
|
41
|
-
await createTray(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
41
|
+
await createTray(
|
|
42
|
+
{
|
|
43
|
+
trayId: "secondary",
|
|
44
|
+
title: "Secondary",
|
|
45
|
+
icon: { type: "file", path: "./assets/tray-icon.png" },
|
|
46
|
+
},
|
|
47
|
+
{ space: defaultSpace.space }
|
|
48
|
+
);
|
|
46
49
|
```
|
|
47
50
|
|
|
48
51
|
`createTray()` resolves the broker default space when no explicit target is provided. If you already know the target, pass `space: defaultSpace.space` in the second argument instead of relying on default-space lookup.
|
|
@@ -62,6 +65,27 @@ pnpm --filter opentray example:webview-control
|
|
|
62
65
|
That demo opens a native WebView window immediately and puts the controls inside the page itself, so you can exercise frameless, transparent, keep-on-top, title, icon, screen, and navigation behavior without going through the tray menu first.
|
|
63
66
|
Treat `example:webview-control` as the API exercise surface. It is useful for probing capabilities and events, but it is not the canonical recipe for a tray-anchored glass shell.
|
|
64
67
|
|
|
68
|
+
Application code mounts WebView as a tray capability. The first WebView command loads the native extension automatically; ordinary code does not need to send `load-ext` manually:
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { WebviewExt } from "@opentray/ext-webview";
|
|
72
|
+
import { createTray } from "opentray";
|
|
73
|
+
|
|
74
|
+
const tray = (await createTray({
|
|
75
|
+
trayId: "status",
|
|
76
|
+
title: "Status",
|
|
77
|
+
icon: { type: "file", path: "./tray-icon.png" },
|
|
78
|
+
})).extend(WebviewExt);
|
|
79
|
+
|
|
80
|
+
const panel = tray.createWebviewWindow({
|
|
81
|
+
html: "<main>Status</main>",
|
|
82
|
+
width: 360,
|
|
83
|
+
height: 240,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
await panel.show();
|
|
87
|
+
```
|
|
88
|
+
|
|
65
89
|
Run the dedicated tray-panel demo:
|
|
66
90
|
|
|
67
91
|
```bash
|
|
@@ -88,15 +112,17 @@ Current WebView truth:
|
|
|
88
112
|
- some requests are `unsupported by design`, such as asking the macOS runtime to apply a Windows-only style family
|
|
89
113
|
- some results are `unavailable by context`, such as tray-bounds projection when the current session has no authoritative tray anchor
|
|
90
114
|
|
|
91
|
-
When run from the repo worktree, the example automatically discovers `target/debug` or `target/release` `libopentray_ext_webview` and wires it through `OPENTRAY_EXT_PATH` before starting the daemon.
|
|
115
|
+
When run from the repo worktree, the example automatically discovers `target/debug` or `target/release` `libopentray_ext_webview` and wires it through `OPENTRAY_EXT_PATH` before starting the daemon. The WebView mount still exercises the real generic extension loader, but example users do not author a manual `load-ext` request.
|
|
92
116
|
|
|
93
117
|
After installing from npm, use the published CLI smoke path instead of workspace scripts:
|
|
94
118
|
|
|
95
119
|
```bash
|
|
96
120
|
opentray smoke daemon-tray
|
|
97
|
-
opentray smoke daemon-lynx
|
|
121
|
+
opentray smoke daemon-lynx
|
|
98
122
|
```
|
|
99
123
|
|
|
124
|
+
`opentray smoke daemon-lynx` now uses the package-owned review bundle by default so a fresh npm install can perform the final visual audit without a workspace checkout. Keep `--bundle <path-to-main.lynx.bundle>` only when you want to override that official audit asset with a custom bundle.
|
|
125
|
+
|
|
100
126
|
This example starts or reuses the same-version daemon automatically, creates a real tray through the public SDK, and prints broker-routed menu events. Use manual lifecycle commands only for operator/debug control:
|
|
101
127
|
|
|
102
128
|
```bash
|
|
@@ -113,7 +139,19 @@ The host side of that example can call `await tray.getBounds()` to read the curr
|
|
|
113
139
|
|
|
114
140
|
The opened WebView also enables the injected page bridge so the rendered page can call `navigator.window` / `navigator.opentrayWindow` and, for the demo only, opt into `window.close()` / `window.moveTo()` / `window.resizeTo()` overrides. Use the in-page buttons to verify `getCapabilities`, `getStyle`, `setStyle({ frameless })`, move, resize, close, and tray-bounds behavior visually instead of relying only on terminal logs.
|
|
115
141
|
|
|
116
|
-
The Lynx smoke path uses the same generic extension loader but launches a real `
|
|
142
|
+
The Lynx smoke path uses the same generic extension loader but launches a real `OpenTrayLynxRuntime.app.zip` sidecar from `@opentray/ext-lynx-darwin-*`. It starts the requested `.lynx.bundle` in a fixed host shell, sets an initial title and icon, applies an explicit startup feature expression, and exposes `Show Window`, `Hide Window`, and `Quit Smoke` through tray-routed events. Inside the Lynx window, use the rendered controls to verify `getCapabilities`, `getStyle`, `getTitle`, `setTitle`, `getIcon`, `setIcon`, `navigator.screen.getScreenDetails()`, `resizeTo`, `moveTo`, frameless toggling, `window.resizeTo()`, `window.getScreenDetails()`, and close behavior visually. On macOS, the runtime Dock icon should no longer appear blank.
|
|
143
|
+
|
|
144
|
+
For Lynx, `frameless` currently means borderless only. It does not imply a full-window drag region, because that would steal clicks from the page content. When isolating host-feature regressions, `--features "*,!frameless"` is the fastest way to keep the bridge on while removing the borderless shell from the test.
|
|
145
|
+
|
|
146
|
+
When you need to validate a GitHub-built macOS artifact before publish, use the workspace launcher instead of hand-written `/tmp` scripts:
|
|
147
|
+
|
|
148
|
+
```bash
|
|
149
|
+
pnpm run smoke:lynx -- --run <github-actions-run-id> --bundle packages/cli/assets/lynx-review/main.lynx.bundle
|
|
150
|
+
pnpm run smoke:lynx -- --run <github-actions-run-id> --bundle packages/cli/assets/lynx-review/main.lynx.bundle --features "nativeWindowApi,bindWindowGlobals,nativeScreenApi,bindScreenGlobals"
|
|
151
|
+
pnpm run smoke:lynx -- --run <github-actions-run-id> --bundle packages/cli/assets/lynx-review/main.lynx.bundle --features "*,!nativeScreenApi"
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
The package-owned review bundle is the full human acceptance surface. The separate `input-probe.lynx.bundle` is only a low-level diagnostic asset for isolating raw click/scroll/input delivery. The empty feature set is the baseline carrier check. Use it to validate the physical window baseline: click, scroll, input, red/yellow/green controls, and resize/move. Only after that baseline is healthy should you validate explicit startup feature sets on top of the same carrier.
|
|
117
155
|
|
|
118
156
|
First-stage platform packages are published for macOS, Linux, and Windows. macOS is the current human-visual acceptance path. Linux and Windows artifacts are present for package topology validation, but unsupported broker/WebView capability must fail explicitly rather than pretending a visible UI exists. Lynx is intentionally macOS-first for now and should fail honestly on other platforms instead of pretending the runtime exists.
|
|
119
157
|
|
|
@@ -130,10 +168,10 @@ cargo build -p opentray-bin -p opentray-ext-webview -p opentray-ext-lynx
|
|
|
130
168
|
bun run scripts/binaries/stage-local.ts --kind daemon --source target/debug/opentray
|
|
131
169
|
bun run scripts/binaries/stage-local.ts --kind webview --source target/debug/libopentray_ext_webview.dylib
|
|
132
170
|
bun run scripts/binaries/stage-local.ts --kind lynx --source target/debug/libopentray_ext_lynx.dylib
|
|
133
|
-
bash scripts/release/build-lynx-runtime.sh /tmp/
|
|
134
|
-
bun run scripts/binaries/stage-local.ts --kind lynx-runtime --source /tmp/
|
|
171
|
+
bash scripts/release/build-lynx-runtime.sh /tmp/OpenTrayLynxRuntime.app.zip
|
|
172
|
+
bun run scripts/binaries/stage-local.ts --kind lynx-runtime --source /tmp/OpenTrayLynxRuntime.app.zip
|
|
135
173
|
OPENTRAY_EXAMPLE_WEBVIEW_SMOKE=1 pnpm --filter opentray cli -- smoke daemon-tray
|
|
136
|
-
pnpm --filter opentray cli -- smoke daemon-lynx
|
|
174
|
+
pnpm --filter opentray cli -- smoke daemon-lynx
|
|
137
175
|
```
|
|
138
176
|
|
|
139
177
|
During source-level daemon work, restart the daemon with the freshly built broker binary before testing tray behavior. Otherwise the CLI may reuse the already staged same-version daemon:
|
|
@@ -158,4 +196,4 @@ otool -L target/release/libopentray_ext_webview.dylib
|
|
|
158
196
|
otool -L target/release/libopentray_ext_lynx.dylib
|
|
159
197
|
```
|
|
160
198
|
|
|
161
|
-
|
|
199
|
+
The native `tray-icon` backend now normalizes `encoded` and `file` icon inputs into RGBA before native tray materialization. `rgba` still works when you already have pixel data, but ordinary app code can point at a PNG file instead of hand-building pixels.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
## Lynx Review Bundle
|
|
2
|
+
|
|
3
|
+
This directory contains the package-owned Lynx review bundle used by the public CLI smoke:
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
opentray smoke daemon-lynx
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
The goal is post-publish human verification. A fresh npm install must be able to open a real Lynx window without depending on a workspace checkout or `research/` paths.
|
|
10
|
+
|
|
11
|
+
TODO:
|
|
12
|
+
|
|
13
|
+
- move the source of this review app into a tracked repo-owned source root instead of relying on a copied research build artifact
|
|
14
|
+
- keep the bundle focused on visual/runtime acceptance, not on product features unrelated to extension-host verification
|
|
Binary file
|
package/dist/cli.d.mts
CHANGED
package/dist/cli.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.mts","names":[],"sources":["../src/cli.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"cli.d.mts","names":[],"sources":["../src/cli.ts"],"mappings":";;;KAuBK,UAAA;EACC,IAAA;EAAgB,MAAA;AAAA;EAChB,IAAA;EAAe,IAAA;AAAA;EAEf,IAAA;EACA,IAAA;EACA,UAAA;EACA,iBAAA;AAAA;EAEA,IAAA;AAAA;AAAA,cAEO,eAAA,GAAmB,IAAA,eAAiB,UA+BhD;AAAA,cAEY,MAAA,GAAgB,IAAA,eAAiB,OAAO;AAAA,cAwGxC,wBAAA,GAA4B,MAAoB,EAAZ,YAAY;AAAA,cAoBhD,eAAA,GACX,aAAA,sBACA,UAAkB"}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,19 +1,32 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as createClient } from "./client-
|
|
2
|
+
import { t as createClient } from "./client-DzcHIH-f.mjs";
|
|
3
3
|
import { a as inspectDaemon, c as stopDaemon, i as createNodeDaemonDriver, n as resolveDaemonPaths, o as restartDaemon, r as readPackageVersion, s as startDaemon, t as connectLocalBroker } from "./local-broker-CEIHPBcK.mjs";
|
|
4
4
|
import { homedir } from "node:os";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
import { existsSync, realpathSync } from "node:fs";
|
|
7
|
-
import { resolve } from "node:path";
|
|
7
|
+
import { dirname, join, resolve } from "node:path";
|
|
8
8
|
//#region src/smoke/daemon-lynx.ts
|
|
9
9
|
const menuLabels$1 = new Map([
|
|
10
|
-
[1, "
|
|
10
|
+
[1, "Show Window"],
|
|
11
11
|
[2, "Hide Window"],
|
|
12
12
|
[99, "Quit Smoke"]
|
|
13
13
|
]);
|
|
14
14
|
const DEFAULT_LYNX_BUNDLE_ENV = "OPENTRAY_LYNX_BUNDLE";
|
|
15
|
+
const DEFAULT_LYNX_HOST_FEATURES_ENV = "OPENTRAY_LYNX_HOST_FEATURES";
|
|
16
|
+
const DEFAULT_REVIEW_BUNDLE_RELATIVE_PATH = "assets/lynx-review/main.lynx.bundle";
|
|
17
|
+
const LYNX_HOST_FEATURES = [
|
|
18
|
+
"nativeWindowApi",
|
|
19
|
+
"bindWindowGlobals",
|
|
20
|
+
"nativeScreenApi",
|
|
21
|
+
"bindScreenGlobals",
|
|
22
|
+
"frameless"
|
|
23
|
+
];
|
|
15
24
|
const runDaemonLynxSmoke = async (options = {}) => {
|
|
16
25
|
const bundlePath = resolveLynxBundlePath(options.bundlePath);
|
|
26
|
+
const hostFeatures = resolveLynxHostFeatures(options.featureExpression);
|
|
27
|
+
if (process.env.OPENTRAY_LYNX_DEBUG) console.log(`lynx debug modes: ${process.env.OPENTRAY_LYNX_DEBUG}`);
|
|
28
|
+
if (process.env[DEFAULT_LYNX_HOST_FEATURES_ENV]) console.log(`lynx host features: ${process.env[DEFAULT_LYNX_HOST_FEATURES_ENV]}`);
|
|
29
|
+
if (process.env.OPENTRAY_LYNX_DEBUG_LOG_PATH) console.log(`lynx debug log path: ${process.env.OPENTRAY_LYNX_DEBUG_LOG_PATH}`);
|
|
17
30
|
const connection = await connectLocalBroker();
|
|
18
31
|
const client = createClient(connection, { requestIdPrefix: "daemon-lynx" });
|
|
19
32
|
console.log(`connected: endpoint=${connection.endpoint} session=${connection.sessionId}`);
|
|
@@ -35,7 +48,7 @@ const runDaemonLynxSmoke = async (options = {}) => {
|
|
|
35
48
|
{
|
|
36
49
|
type: "item",
|
|
37
50
|
id: 1,
|
|
38
|
-
title: "
|
|
51
|
+
title: "Show Window"
|
|
39
52
|
},
|
|
40
53
|
{
|
|
41
54
|
type: "item",
|
|
@@ -63,11 +76,12 @@ const runDaemonLynxSmoke = async (options = {}) => {
|
|
|
63
76
|
let exitTimer;
|
|
64
77
|
let resolveClosed;
|
|
65
78
|
const show = async () => {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
const command = createLynxShowCommand({
|
|
80
|
+
bundlePath,
|
|
81
|
+
hostFeatures
|
|
69
82
|
});
|
|
70
|
-
|
|
83
|
+
await tray.commandExtension("lynx", command);
|
|
84
|
+
console.log(`lynx command: show features=${describeLynxHostFeatures(hostFeatures)} bundle=${bundlePath}`);
|
|
71
85
|
};
|
|
72
86
|
const hide = async () => {
|
|
73
87
|
await tray.commandExtension("lynx", { type: "hide" });
|
|
@@ -125,7 +139,7 @@ const runDaemonLynxSmoke = async (options = {}) => {
|
|
|
125
139
|
}
|
|
126
140
|
try {
|
|
127
141
|
await show();
|
|
128
|
-
console.log(
|
|
142
|
+
console.log(`use the tray menu to re-show or hide the window, or press Ctrl+C to exit; features=${describeLynxHostFeatures(hostFeatures)}`);
|
|
129
143
|
} catch (error) {
|
|
130
144
|
await connection.close();
|
|
131
145
|
process.off("SIGINT", onSignal);
|
|
@@ -138,11 +152,96 @@ const runDaemonLynxSmoke = async (options = {}) => {
|
|
|
138
152
|
};
|
|
139
153
|
const resolveLynxBundlePath = (value) => {
|
|
140
154
|
const resolved = value ?? process.env[DEFAULT_LYNX_BUNDLE_ENV];
|
|
141
|
-
if (resolved === void 0 || resolved.length === 0)
|
|
155
|
+
if (resolved === void 0 || resolved.length === 0) {
|
|
156
|
+
const bundledReviewBundle = resolveBundledReviewBundlePath();
|
|
157
|
+
if (!existsSync(bundledReviewBundle)) throw new Error(`lynx smoke requires --bundle <path>, ${DEFAULT_LYNX_BUNDLE_ENV}=<path-to-main.lynx.bundle>, or a packaged review bundle at ${bundledReviewBundle}`);
|
|
158
|
+
return realpathSync(bundledReviewBundle);
|
|
159
|
+
}
|
|
142
160
|
const absolutePath = resolve(process.env.INIT_CWD ?? process.cwd(), resolved);
|
|
143
161
|
if (!existsSync(absolutePath)) throw new Error(`lynx smoke bundle does not exist: ${absolutePath}`);
|
|
144
162
|
return realpathSync(absolutePath);
|
|
145
163
|
};
|
|
164
|
+
const resolveLynxHostFeatures = (expression = process.env[DEFAULT_LYNX_HOST_FEATURES_ENV] ?? "") => {
|
|
165
|
+
const features = createEmptyLynxHostFeatures();
|
|
166
|
+
for (const rawToken of expression.split(",")) {
|
|
167
|
+
const token = rawToken.trim();
|
|
168
|
+
if (token.length === 0) continue;
|
|
169
|
+
applyLynxHostFeatureToken(features, token);
|
|
170
|
+
}
|
|
171
|
+
return features;
|
|
172
|
+
};
|
|
173
|
+
const createLynxShowCommand = ({ bundlePath, hostFeatures }) => {
|
|
174
|
+
const command = {
|
|
175
|
+
type: "show",
|
|
176
|
+
bundlePath,
|
|
177
|
+
width: 720,
|
|
178
|
+
height: 420,
|
|
179
|
+
minWidth: 320,
|
|
180
|
+
minHeight: 220,
|
|
181
|
+
maxWidth: 960,
|
|
182
|
+
maxHeight: 720,
|
|
183
|
+
nativeWindowApi: hostFeatures.nativeWindowApi,
|
|
184
|
+
bindWindowGlobals: hostFeatures.bindWindowGlobals,
|
|
185
|
+
nativeScreenApi: hostFeatures.nativeScreenApi,
|
|
186
|
+
bindScreenGlobals: hostFeatures.bindScreenGlobals,
|
|
187
|
+
title: `OpenTray Lynx Smoke (${describeLynxHostFeatures(hostFeatures)})`,
|
|
188
|
+
icon: createVisibleIcon$1()
|
|
189
|
+
};
|
|
190
|
+
if (hostFeatures.frameless) command.style = { frameless: true };
|
|
191
|
+
return command;
|
|
192
|
+
};
|
|
193
|
+
const describeLynxHostFeatures = (features) => {
|
|
194
|
+
const enabled = LYNX_HOST_FEATURES.filter((feature) => features[feature]);
|
|
195
|
+
return enabled.length === 0 ? "baseline" : enabled.join(",");
|
|
196
|
+
};
|
|
197
|
+
const resolveBundledReviewBundlePath = (moduleUrl = import.meta.url) => {
|
|
198
|
+
let currentDir = dirname(fileURLToPath(moduleUrl));
|
|
199
|
+
while (true) {
|
|
200
|
+
if (existsSync(join(currentDir, "package.json"))) return join(currentDir, DEFAULT_REVIEW_BUNDLE_RELATIVE_PATH);
|
|
201
|
+
const parent = dirname(currentDir);
|
|
202
|
+
if (parent === currentDir) throw new Error(`failed to resolve opentray package root from ${moduleUrl}`);
|
|
203
|
+
currentDir = parent;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
function createEmptyLynxHostFeatures() {
|
|
207
|
+
return {
|
|
208
|
+
nativeWindowApi: false,
|
|
209
|
+
bindWindowGlobals: false,
|
|
210
|
+
nativeScreenApi: false,
|
|
211
|
+
bindScreenGlobals: false,
|
|
212
|
+
frameless: false
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
function applyLynxHostFeatureToken(features, rawToken) {
|
|
216
|
+
const disabled = rawToken.startsWith("!");
|
|
217
|
+
const token = disabled ? rawToken.slice(1) : rawToken;
|
|
218
|
+
if (token === "*" || token === "full") {
|
|
219
|
+
for (const feature of LYNX_HOST_FEATURES) features[feature] = !disabled;
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
if (token === "baseline") {
|
|
223
|
+
for (const feature of LYNX_HOST_FEATURES) features[feature] = false;
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
if (!isLynxHostFeature(token)) throw new Error(`unsupported Lynx host feature token: ${rawToken}; supported tokens: baseline, full, *, !<feature>, ${LYNX_HOST_FEATURES.join(", ")}`);
|
|
227
|
+
features[token] = !disabled;
|
|
228
|
+
if (token === "nativeWindowApi" && disabled) {
|
|
229
|
+
features.bindWindowGlobals = false;
|
|
230
|
+
return;
|
|
231
|
+
}
|
|
232
|
+
if (token === "nativeScreenApi" && disabled) {
|
|
233
|
+
features.bindScreenGlobals = false;
|
|
234
|
+
return;
|
|
235
|
+
}
|
|
236
|
+
if (token === "bindWindowGlobals" && !disabled) {
|
|
237
|
+
features.nativeWindowApi = true;
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
if (token === "bindScreenGlobals" && !disabled) features.nativeScreenApi = true;
|
|
241
|
+
}
|
|
242
|
+
function isLynxHostFeature(value) {
|
|
243
|
+
return LYNX_HOST_FEATURES.includes(value);
|
|
244
|
+
}
|
|
146
245
|
function createVisibleIcon$1() {
|
|
147
246
|
const width = 32;
|
|
148
247
|
const height = 32;
|
|
@@ -397,14 +496,12 @@ const parseCliCommand = (argv) => {
|
|
|
397
496
|
name: "daemon-tray"
|
|
398
497
|
};
|
|
399
498
|
if (group === "smoke" && action === "daemon-lynx") {
|
|
400
|
-
const
|
|
401
|
-
return
|
|
402
|
-
type: "smoke",
|
|
403
|
-
name: "daemon-lynx"
|
|
404
|
-
} : {
|
|
499
|
+
const smokeOptions = parseSmokeOptions(rest);
|
|
500
|
+
return {
|
|
405
501
|
type: "smoke",
|
|
406
502
|
name: "daemon-lynx",
|
|
407
|
-
bundlePath
|
|
503
|
+
...smokeOptions.bundlePath ? { bundlePath: smokeOptions.bundlePath } : {},
|
|
504
|
+
...smokeOptions.featureExpression ? { featureExpression: smokeOptions.featureExpression } : {}
|
|
408
505
|
};
|
|
409
506
|
}
|
|
410
507
|
return { type: "help" };
|
|
@@ -428,7 +525,10 @@ const runCli = async (argv) => {
|
|
|
428
525
|
}
|
|
429
526
|
if (command.type === "smoke") {
|
|
430
527
|
if (command.name === "daemon-tray") await runDaemonTraySmoke();
|
|
431
|
-
else await runDaemonLynxSmoke(
|
|
528
|
+
else await runDaemonLynxSmoke({
|
|
529
|
+
...command.bundlePath === void 0 ? {} : { bundlePath: command.bundlePath },
|
|
530
|
+
...command.featureExpression === void 0 ? {} : { featureExpression: command.featureExpression }
|
|
531
|
+
});
|
|
432
532
|
return 0;
|
|
433
533
|
}
|
|
434
534
|
const driver = createNodeDaemonDriver(cliModulePath);
|
|
@@ -488,7 +588,8 @@ const runCli = async (argv) => {
|
|
|
488
588
|
const printHelp = () => {
|
|
489
589
|
console.error("Usage: opentray daemon <start|stop|restart|health>");
|
|
490
590
|
console.error(" opentray smoke daemon-tray");
|
|
491
|
-
console.error(" opentray smoke daemon-lynx --bundle <path-to-main.lynx.bundle>");
|
|
591
|
+
console.error(" opentray smoke daemon-lynx [--bundle <path-to-main.lynx.bundle>] [--features <baseline|full|*,!feature,...>]");
|
|
592
|
+
console.error(" default Lynx smoke uses the packaged review bundle");
|
|
492
593
|
};
|
|
493
594
|
const formatDaemonHealthOutput = (health) => {
|
|
494
595
|
const lines = [
|
|
@@ -513,8 +614,20 @@ const isCliEntrypoint = (argvEntryPath, modulePath) => {
|
|
|
513
614
|
return argvEntryPath === modulePath;
|
|
514
615
|
}
|
|
515
616
|
};
|
|
516
|
-
function
|
|
517
|
-
|
|
617
|
+
function parseSmokeOptions(argv) {
|
|
618
|
+
let bundlePath;
|
|
619
|
+
let featureExpression;
|
|
620
|
+
for (let index = 0; index < argv.length; index += 1) {
|
|
621
|
+
if (argv[index] === "--bundle") {
|
|
622
|
+
bundlePath = argv[index + 1];
|
|
623
|
+
continue;
|
|
624
|
+
}
|
|
625
|
+
if (argv[index] === "--features") featureExpression = argv[index + 1];
|
|
626
|
+
}
|
|
627
|
+
return {
|
|
628
|
+
...bundlePath === void 0 ? {} : { bundlePath },
|
|
629
|
+
...featureExpression === void 0 ? {} : { featureExpression }
|
|
630
|
+
};
|
|
518
631
|
}
|
|
519
632
|
if (isCliEntrypoint(process.argv[1], cliModulePath)) runCli(process.argv.slice(2)).then((code) => {
|
|
520
633
|
process.exitCode = code;
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","names":["menuLabels","createVisibleIcon"],"sources":["../src/smoke/daemon-lynx.ts","../src/smoke/daemon-tray.ts","../src/cli.ts"],"sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\n\nimport { createClient } from \"../client\";\nimport { connectLocalBroker } from \"../local-broker\";\n\nconst menuLabels = new Map<number, string>([\n [1, \"Reload Bundle\"],\n [2, \"Hide Window\"],\n [99, \"Quit Smoke\"],\n]);\n\nconst DEFAULT_LYNX_BUNDLE_ENV = \"OPENTRAY_LYNX_BUNDLE\";\n\nexport interface DaemonLynxSmokeOptions {\n bundlePath?: string;\n}\n\nexport const runDaemonLynxSmoke = async (\n options: DaemonLynxSmokeOptions = {},\n): Promise<void> => {\n const bundlePath = resolveLynxBundlePath(options.bundlePath);\n const connection = await connectLocalBroker();\n const client = createClient(connection, { requestIdPrefix: \"daemon-lynx\" });\n console.log(`connected: endpoint=${connection.endpoint} session=${connection.sessionId}`);\n\n const space = await client.createSpace({\n id: \"com.example.opentray.daemon-lynx\",\n title: \"OpenTray Lynx Smoke\",\n default: true,\n });\n console.log(`space: ${JSON.stringify(space.space)}`);\n\n const tray = await space.createTray({\n trayId: \"daemon-lynx-status\",\n title: \"OpenTray Lynx\",\n tooltip: {\n title: \"OpenTray Lynx\",\n description: \"Generic extension smoke for a real Lynx runtime window\",\n },\n icon: createVisibleIcon(),\n menu: {\n items: [\n { type: \"item\", id: 1, title: \"Reload Bundle\" },\n { type: \"item\", id: 2, title: \"Hide Window\" },\n { type: \"separator\" },\n { type: \"item\", id: 99, title: \"Quit Smoke\" },\n ],\n },\n });\n console.log(`tray: ${tray.trayId}`);\n\n await connection.request({\n type: \"load-ext\",\n requestId: \"daemon-lynx-load\",\n spaceId: space.space.spaceId,\n name: \"lynx\",\n path: \"@opentray/ext-lynx\",\n });\n console.log(\"lynx extension requested through the generic load-ext path\");\n\n let closed = false;\n let exitTimer: NodeJS.Timeout | undefined;\n let resolveClosed: (() => void) | undefined;\n\n const show = async (): Promise<void> => {\n await tray.commandExtension(\"lynx\", {\n type: \"show\",\n bundlePath,\n });\n console.log(`lynx command: show bundle=${bundlePath}`);\n };\n\n const hide = async (): Promise<void> => {\n await tray.commandExtension(\"lynx\", { type: \"hide\" });\n console.log(\"lynx command: hide\");\n };\n\n const shutdown = async (): Promise<void> => {\n if (closed) {\n return;\n }\n closed = true;\n if (exitTimer !== undefined) {\n clearTimeout(exitTimer);\n }\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n try {\n await hide();\n } catch (error) {\n console.error(`lynx hide during shutdown failed: ${String(error)}`);\n }\n await connection.close();\n resolveClosed?.();\n };\n\n const handleMenuClick = async (itemId: number): Promise<void> => {\n switch (itemId) {\n case 1:\n await show();\n return;\n case 2:\n await hide();\n return;\n case 99:\n console.log(\"quit item routed; closing lynx smoke connection\");\n await shutdown();\n return;\n default:\n return;\n }\n };\n\n connection.onEvent((frame) => {\n console.log(`broker -> client ${JSON.stringify(frame)}`);\n if (frame.type === \"event\" && frame.event.type === \"menuClick\") {\n console.log(`menu click: ${menuLabels.get(frame.event.itemId) ?? frame.event.itemId}`);\n void handleMenuClick(frame.event.itemId);\n return;\n }\n if (frame.type === \"ext-event\" && frame.ext === \"lynx\") {\n console.log(`lynx event: ${JSON.stringify(frame.data)}`);\n }\n });\n\n const onSignal = (): void => {\n void shutdown();\n };\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n\n const exitAfter = process.env.OPENTRAY_EXAMPLE_EXIT_AFTER_MS;\n if (exitAfter !== undefined && exitAfter.length > 0) {\n const duration = Number.parseInt(exitAfter, 10);\n if (Number.isInteger(duration) && duration > 0) {\n exitTimer = setTimeout(() => {\n void shutdown();\n }, duration);\n }\n }\n\n try {\n await show();\n console.log(\"use the tray menu to reload or hide the Lynx window, or press Ctrl+C to exit\");\n } catch (error) {\n await connection.close();\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n throw error;\n }\n\n await new Promise<void>((resolve) => {\n resolveClosed = resolve;\n });\n};\n\nexport const resolveLynxBundlePath = (value?: string): string => {\n const resolved = value ?? process.env[DEFAULT_LYNX_BUNDLE_ENV];\n if (resolved === undefined || resolved.length === 0) {\n throw new Error(\n `lynx smoke requires --bundle <path> or ${DEFAULT_LYNX_BUNDLE_ENV}=<path-to-main.lynx.bundle>`,\n );\n }\n const baseDir = process.env.INIT_CWD ?? process.cwd();\n const absolutePath = resolve(baseDir, resolved);\n if (!existsSync(absolutePath)) {\n throw new Error(`lynx smoke bundle does not exist: ${absolutePath}`);\n }\n return realpathSync(absolutePath);\n};\n\nfunction createVisibleIcon(): { type: \"rgba\"; width: number; height: number; data: number[] } {\n const width = 32;\n const height = 32;\n const data: number[] = [];\n\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n const inStroke = x <= 5 || (x >= 13 && x <= 18) || y >= 26;\n const inDiagonal = y >= x + 10 && x <= 18;\n const alpha = inStroke || inDiagonal ? 255 : 0;\n data.push(34, 92, 56, alpha);\n }\n }\n\n return { type: \"rgba\", width, height, data };\n}\n","import type { Rect } from \"@opentray/spec\";\n\nimport { createClient } from \"../client\";\nimport { connectLocalBroker } from \"../local-broker\";\n\nconst menuLabels = new Map<number, string>([\n [1, \"Open WebView\"],\n]);\n\ninterface WebviewShowCommand {\n type: \"show\";\n html?: string;\n url?: string;\n width?: number;\n height?: number;\n fallbackRect?: Rect;\n nativeWindowApi?: boolean;\n bindWindowGlobals?: boolean;\n nativeScreenApi?: boolean;\n bindScreenGlobals?: boolean;\n nativeTrayApi?: boolean;\n title?: string;\n icon?: { type: \"href\"; href: string };\n style?: {\n frameless?: boolean;\n transparent?: boolean;\n keepOnTop?: boolean;\n platform?: {\n macos?: {\n material?: string | null;\n materialState?: \"followsWindowActiveState\" | \"active\" | \"inactive\";\n cornerRadius?: number | null;\n };\n };\n };\n titleSync?: boolean | { documentToWindow?: boolean; windowToDocument?: boolean };\n iconSync?: boolean | { faviconToWindow?: boolean; windowToFavicon?: boolean };\n nativeApiPolicy?: {\n defaultSrc?: string[];\n window?: string[];\n screen?: string[];\n tray?: string[];\n windowGlobals?: string[];\n screenGlobals?: string[];\n titleSync?: string[];\n iconSync?: string[];\n };\n}\n\nexport const runDaemonTraySmoke = async (): Promise<void> => {\n const connection = await connectLocalBroker();\n const client = createClient(connection, { requestIdPrefix: \"daemon-smoke\" });\n console.log(`connected: endpoint=${connection.endpoint} session=${connection.sessionId}`);\n\n const space = await client.createSpace({\n id: \"com.example.opentray.daemon-smoke\",\n title: \"OpenTray Daemon Smoke\",\n default: true,\n });\n console.log(`space: ${JSON.stringify(space.space)}`);\n\n const tray = await space.createTray({\n trayId: \"daemon-smoke-status\",\n title: \"OpenTray\",\n tooltip: {\n title: \"OpenTray\",\n description: \"Single primary tray action; macOS direct-triggers without opening a menu\",\n },\n icon: createVisibleIcon(),\n menu: {\n items: [\n { type: \"item\", id: 1, title: \"Open WebView\", primaryEvent: true },\n ],\n },\n });\n console.log(`tray: ${tray.trayId}`);\n\n await connection.request({\n type: \"load-ext\",\n requestId: \"daemon-smoke-load-webview\",\n spaceId: space.space.spaceId,\n name: \"webview\",\n path: \"@opentray/ext-webview\",\n });\n console.log(\"webview extension requested through the generic load-ext path\");\n console.log(\"click the tray icon: macOS should direct-trigger the single primary action without opening a menu\");\n\n let closed = false;\n let exitTimer: NodeJS.Timeout | undefined;\n\n const shutdown = async (): Promise<void> => {\n if (closed) {\n return;\n }\n closed = true;\n if (exitTimer !== undefined) {\n clearTimeout(exitTimer);\n }\n await connection.close();\n };\n\n const commandWebview = async (command: WebviewShowCommand | Record<string, unknown>): Promise<void> => {\n await tray.commandExtension(\"webview\", command);\n };\n\n const handleMenuClick = async (itemId: number): Promise<void> => {\n if (itemId === 1) {\n const trayBounds = await tray.getBounds();\n console.log(`tray bounds: ${JSON.stringify(trayBounds)}`);\n await commandWebview({\n type: \"show\",\n html: createWebviewDemoHtml(),\n width: 420,\n height: 260,\n title: \"OpenTray WebView Smoke\",\n icon: {\n type: \"href\",\n href: \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=\",\n },\n style: {\n frameless: true,\n transparent: true,\n keepOnTop: true,\n platform: {\n macos: {\n material: \"hudWindow\",\n materialState: \"active\",\n },\n },\n },\n fallbackRect: trayBounds.rect ?? { x: 0, y: 0, width: 1, height: 1 },\n nativeWindowApi: true,\n bindWindowGlobals: true,\n nativeScreenApi: true,\n bindScreenGlobals: true,\n nativeTrayApi: true,\n titleSync: {\n documentToWindow: true,\n windowToDocument: true,\n },\n iconSync: true,\n nativeApiPolicy: {\n defaultSrc: [\"'local'\"],\n window: [\"https://example.com\"],\n screen: [\"https://example.com\"],\n tray: [\"https://example.com\"],\n titleSync: [\"https://example.com\"],\n iconSync: [\"https://example.com\"],\n },\n });\n console.log(\"primary tray action: webview show\");\n return;\n }\n };\n\n connection.onEvent((frame) => {\n console.log(`broker -> client ${JSON.stringify(frame)}`);\n if (frame.type === \"event\" && frame.event.type === \"menuClick\") {\n console.log(`menu click: ${menuLabels.get(frame.event.itemId) ?? frame.event.itemId}`);\n void handleMenuClick(frame.event.itemId);\n }\n });\n\n const exitAfter = process.env.OPENTRAY_EXAMPLE_EXIT_AFTER_MS;\n if (exitAfter !== undefined && exitAfter.length > 0) {\n const duration = Number.parseInt(exitAfter, 10);\n if (Number.isInteger(duration) && duration > 0) {\n exitTimer = setTimeout(() => {\n void shutdown();\n }, duration);\n }\n }\n\n const webviewSmoke = process.env.OPENTRAY_EXAMPLE_WEBVIEW_SMOKE;\n try {\n if (webviewSmoke === \"show\" || webviewSmoke === \"1\") {\n await handleMenuClick(1);\n }\n if (webviewSmoke === \"1\") {\n if (exitTimer !== undefined) {\n clearTimeout(exitTimer);\n exitTimer = undefined;\n }\n await sleep(300);\n await shutdown();\n }\n } catch (error) {\n await shutdown();\n throw error;\n }\n};\n\nfunction createVisibleIcon(): { type: \"rgba\"; width: number; height: number; data: number[] } {\n const width = 32;\n const height = 32;\n const data: number[] = [];\n\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n const dx = x - 15.5;\n const dy = y - 15.5;\n const distance = Math.sqrt(dx * dx + dy * dy);\n const inRing = distance >= 9 && distance <= 14;\n const inCore = distance <= 5;\n const inNeedle = Math.abs(dx + dy) <= 1.2 && x >= 9 && x <= 23 && y >= 9 && y <= 23;\n\n if (inRing || inCore || inNeedle) {\n data.push(inCore ? 255 : 24, inNeedle ? 240 : 132, inRing ? 72 : 96, 255);\n } else {\n data.push(0, 0, 0, 0);\n }\n }\n }\n\n return { type: \"rgba\", width, height, data };\n}\n\nfunction createWebviewDemoHtml(): string {\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>OpenTray WebView</title>\n <style>\n :root {\n color: #18220f;\n background: #f6edd8;\n font: 15px ui-rounded, \"SF Pro Rounded\", \"Avenir Next\", sans-serif;\n }\n body {\n margin: 0;\n }\n main {\n min-height: 100vh;\n box-sizing: border-box;\n padding: 22px;\n background:\n radial-gradient(circle at 84% 10%, rgba(34, 132, 96, 0.22), transparent 34%),\n linear-gradient(135deg, #fff8e7 0%, #e9f0d8 100%);\n }\n h1 {\n margin: 0 0 8px;\n font-size: 24px;\n letter-spacing: -0.04em;\n }\n p {\n margin: 0 0 16px;\n color: #526044;\n }\n section {\n display: grid;\n gap: 10px;\n }\n .card {\n border: 1px solid rgba(24, 34, 15, 0.16);\n border-radius: 14px;\n padding: 12px;\n background: rgba(255, 255, 255, 0.72);\n box-shadow: 0 12px 30px rgba(56, 72, 36, 0.12);\n }\n .label {\n margin-bottom: 5px;\n color: #7b5b1d;\n font-size: 12px;\n font-weight: 700;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n }\n code {\n word-break: break-word;\n }\n </style>\n </head>\n <body>\n <main>\n <h1>OpenTray WebView</h1>\n <p>This window was opened by the single primary tray action.</p>\n <section>\n <div class=\"card\">\n <div class=\"label\">primary event</div>\n <code>macOS single primary item direct-triggered menuClick -> WebView show</code>\n </div>\n </section>\n </main>\n </body>\n</html>`;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","#!/usr/bin/env node\nimport { realpathSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { fileURLToPath } from \"node:url\";\n\nimport type { DaemonHealth } from \"@opentray/spec\";\n\nimport { createNodeDaemonDriver, inspectDaemon, restartDaemon, startDaemon, stopDaemon } from \"./daemon/lifecycle\";\nimport { readPackageVersion } from \"./daemon/package-version\";\nimport { resolveDaemonPaths } from \"./daemon/paths\";\nimport { connectLocalBroker } from \"./local-broker\";\nimport { runDaemonLynxSmoke } from \"./smoke/daemon-lynx\";\nimport { runDaemonTraySmoke } from \"./smoke/daemon-tray\";\n\nconst packageJsonUrl = new URL(\"../package.json\", import.meta.url);\nconst cliModulePath = fileURLToPath(import.meta.url);\n\ntype CliCommand =\n | { type: \"daemon\"; action: \"start\" | \"stop\" | \"restart\" | \"health\" }\n | { type: \"smoke\"; name: \"daemon-tray\" }\n | { type: \"smoke\"; name: \"daemon-lynx\"; bundlePath?: string }\n | { type: \"help\" };\n\nexport const parseCliCommand = (argv: string[]): CliCommand => {\n const [group, action, ...rest] = argv;\n if (group !== \"daemon\") {\n if (group === \"smoke\" && action === \"daemon-tray\") {\n return { type: \"smoke\", name: \"daemon-tray\" };\n }\n if (group === \"smoke\" && action === \"daemon-lynx\") {\n const bundlePath = parseSmokeBundlePath(rest);\n return bundlePath === undefined\n ? { type: \"smoke\", name: \"daemon-lynx\" }\n : { type: \"smoke\", name: \"daemon-lynx\", bundlePath };\n }\n return { type: \"help\" };\n }\n if (action === \"start\" || action === \"stop\" || action === \"restart\" || action === \"health\") {\n return { type: \"daemon\", action };\n }\n\n return { type: \"help\" };\n};\n\nexport const runCli = async (argv: string[]): Promise<number> => {\n const command = parseCliCommand(argv);\n const packageVersion = process.env.OPENTRAY_DAEMON_PACKAGE_VERSION ?? (await readPackageVersion(packageJsonUrl));\n const paths = resolveDaemonPaths({\n homeDir: process.env.OPENTRAY_HOME ?? homedir(),\n packageVersion,\n });\n\n if (command.type === \"help\") {\n printHelp();\n return 1;\n }\n\n if (command.type === \"smoke\") {\n if (command.name === \"daemon-tray\") {\n await runDaemonTraySmoke();\n } else {\n await runDaemonLynxSmoke(\n command.bundlePath === undefined ? {} : { bundlePath: command.bundlePath },\n );\n }\n return 0;\n }\n\n const driver = createNodeDaemonDriver(cliModulePath);\n\n if (command.action === \"start\") {\n const result = await startDaemon({ paths, driver });\n console.log(`opentray daemon ${result.status}: pid=${result.pid} endpoint=${result.paths.endpoint}`);\n return 0;\n }\n\n if (command.action === \"stop\") {\n const result = await stopDaemon({ paths, driver });\n console.log(\n result.status === \"stopped\"\n ? `opentray daemon stopped: pid=${result.pid}`\n : \"opentray daemon not running\",\n );\n return 0;\n }\n\n if (command.action === \"restart\") {\n const result = await restartDaemon({ paths, driver });\n console.log(`opentray daemon ${result.status}: pid=${result.pid} endpoint=${result.paths.endpoint}`);\n return 0;\n }\n\n if (command.action === \"health\") {\n const inspected = await inspectDaemon({ paths, driver });\n if (inspected.status === \"not-running\") {\n console.log(\"opentray daemon not running\");\n return 0;\n }\n\n const connection = await connectLocalBroker({\n autoStart: false,\n endpoint: paths.endpoint,\n homeDir: paths.homeDir,\n packageVersion,\n });\n try {\n const response = await connection.request({\n type: \"health\",\n requestId: \"opentray-daemon-health\",\n });\n if (response.type !== \"daemon-health\") {\n throw new Error(`expected daemon-health response, received ${response.type}`);\n }\n console.log(formatDaemonHealthOutput(response.health));\n } finally {\n await connection.close();\n }\n return 0;\n }\n\n printHelp();\n return 1;\n};\n\nconst printHelp = (): void => {\n console.error(\"Usage: opentray daemon <start|stop|restart|health>\");\n console.error(\" opentray smoke daemon-tray\");\n console.error(\" opentray smoke daemon-lynx --bundle <path-to-main.lynx.bundle>\");\n};\n\nexport const formatDaemonHealthOutput = (health: DaemonHealth): string => {\n const lines = [\n \"opentray daemon running\",\n `pid: ${health.pid}`,\n `endpoint: ${health.endpoint}`,\n `packageVersion: ${health.packageVersion}`,\n `protocolVersion: ${health.protocolVersion}`,\n `sessions: ${health.sessionCount}`,\n ];\n\n for (const session of health.sessions) {\n const internalLease = session.internalLeaseId ?? \"(pending)\";\n lines.push(\n `- sessionId=${session.sessionId} initialized=${session.initialized} internalLeaseId=${internalLease}`,\n );\n }\n\n return lines.join(\"\\n\");\n};\n\nexport const isCliEntrypoint = (argvEntryPath: string | undefined, modulePath: string): boolean => {\n if (argvEntryPath === undefined) return false;\n try {\n return realpathSync(argvEntryPath) === realpathSync(modulePath);\n } catch {\n return argvEntryPath === modulePath;\n }\n};\n\nfunction parseSmokeBundlePath(argv: string[]): string | undefined {\n for (let index = 0; index < argv.length; index += 1) {\n if (argv[index] === \"--bundle\") {\n return argv[index + 1];\n }\n }\n return undefined;\n}\n\nif (isCliEntrypoint(process.argv[1], cliModulePath)) {\n runCli(process.argv.slice(2)).then((code) => {\n process.exitCode = code;\n });\n}\n"],"mappings":";;;;;;;;AAMA,MAAMA,eAAa,IAAI,IAAoB;CACzC,CAAC,GAAG,eAAe;CACnB,CAAC,GAAG,aAAa;CACjB,CAAC,IAAI,YAAY;AACnB,CAAC;AAED,MAAM,0BAA0B;AAMhC,MAAa,qBAAqB,OAChC,UAAkC,CAAC,MACjB;CAClB,MAAM,aAAa,sBAAsB,QAAQ,UAAU;CAC3D,MAAM,aAAa,MAAM,mBAAmB;CAC5C,MAAM,SAAS,aAAa,YAAY,EAAE,iBAAiB,cAAc,CAAC;CAC1E,QAAQ,IAAI,uBAAuB,WAAW,SAAS,WAAW,WAAW,WAAW;CAExF,MAAM,QAAQ,MAAM,OAAO,YAAY;EACrC,IAAI;EACJ,OAAO;EACP,SAAS;CACX,CAAC;CACD,QAAQ,IAAI,UAAU,KAAK,UAAU,MAAM,KAAK,GAAG;CAEnD,MAAM,OAAO,MAAM,MAAM,WAAW;EAClC,QAAQ;EACR,OAAO;EACP,SAAS;GACP,OAAO;GACP,aAAa;EACf;EACA,MAAMC,oBAAkB;EACxB,MAAM,EACJ,OAAO;GACL;IAAE,MAAM;IAAQ,IAAI;IAAG,OAAO;GAAgB;GAC9C;IAAE,MAAM;IAAQ,IAAI;IAAG,OAAO;GAAc;GAC5C,EAAE,MAAM,YAAY;GACpB;IAAE,MAAM;IAAQ,IAAI;IAAI,OAAO;GAAa;EAC9C,EACF;CACF,CAAC;CACD,QAAQ,IAAI,SAAS,KAAK,QAAQ;CAElC,MAAM,WAAW,QAAQ;EACvB,MAAM;EACN,WAAW;EACX,SAAS,MAAM,MAAM;EACrB,MAAM;EACN,MAAM;CACR,CAAC;CACD,QAA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AK,IAAI;AACxB;AAEA,MAAa,mBAAmB,eAAmC,eAAgC;CACjG,IAAI,kBAAkB,KAAA,GAAW,OAAO;CACxC,IAAI;EACF,OAAO,aAAa,aAAa,MAAM,aAAa,UAAU;CAChE,QAAQ;EACN,OAAO,kBAAkB;CAC3B;AACF;AAEA,SAAS,qBAAqB,MAAoC;CAChE,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAChD,IAAI,KAAK,WAAW,YAClB,OAAO,KAAK,QAAQ;AAI1B;AAEA,IAAI,gBAAgB,QAAQ,KAAK,IAAI,aAAa,GAChD,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,SAAS;CAC3C,QAAQ,WAAW;AACrB,CAAC"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","names":["menuLabels","createVisibleIcon"],"sources":["../src/smoke/daemon-lynx.ts","../src/smoke/daemon-tray.ts","../src/cli.ts"],"sourcesContent":["import { existsSync, realpathSync } from \"node:fs\";\nimport { dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nimport { createClient } from \"../client\";\nimport { connectLocalBroker } from \"../local-broker\";\n\nconst menuLabels = new Map<number, string>([\n [1, \"Show Window\"],\n [2, \"Hide Window\"],\n [99, \"Quit Smoke\"],\n]);\n\nconst DEFAULT_LYNX_BUNDLE_ENV = \"OPENTRAY_LYNX_BUNDLE\";\nconst DEFAULT_LYNX_HOST_FEATURES_ENV = \"OPENTRAY_LYNX_HOST_FEATURES\";\nconst DEFAULT_REVIEW_BUNDLE_RELATIVE_PATH =\n \"assets/lynx-review/main.lynx.bundle\";\nconst LYNX_HOST_FEATURES = [\n \"nativeWindowApi\",\n \"bindWindowGlobals\",\n \"nativeScreenApi\",\n \"bindScreenGlobals\",\n \"frameless\",\n] as const;\n\nexport type LynxHostFeature = (typeof LYNX_HOST_FEATURES)[number];\n\nexport interface LynxHostFeatureState {\n nativeWindowApi: boolean;\n bindWindowGlobals: boolean;\n nativeScreenApi: boolean;\n bindScreenGlobals: boolean;\n frameless: boolean;\n}\n\ninterface LynxSmokeShowCommand {\n type: \"show\";\n bundlePath: string;\n width: number;\n height: number;\n minWidth: number;\n minHeight: number;\n maxWidth: number;\n maxHeight: number;\n nativeWindowApi: boolean;\n bindWindowGlobals: boolean;\n nativeScreenApi: boolean;\n bindScreenGlobals: boolean;\n title: string;\n icon: ReturnType<typeof createVisibleIcon>;\n style?: {\n frameless: boolean;\n };\n}\n\nexport interface DaemonLynxSmokeOptions {\n bundlePath?: string;\n featureExpression?: string;\n}\n\nexport const runDaemonLynxSmoke = async (\n options: DaemonLynxSmokeOptions = {},\n): Promise<void> => {\n const bundlePath = resolveLynxBundlePath(options.bundlePath);\n const hostFeatures = resolveLynxHostFeatures(options.featureExpression);\n if (process.env.OPENTRAY_LYNX_DEBUG) {\n console.log(`lynx debug modes: ${process.env.OPENTRAY_LYNX_DEBUG}`);\n }\n if (process.env[DEFAULT_LYNX_HOST_FEATURES_ENV]) {\n console.log(\n `lynx host features: ${process.env[DEFAULT_LYNX_HOST_FEATURES_ENV]}`,\n );\n }\n if (process.env.OPENTRAY_LYNX_DEBUG_LOG_PATH) {\n console.log(\n `lynx debug log path: ${process.env.OPENTRAY_LYNX_DEBUG_LOG_PATH}`,\n );\n }\n const connection = await connectLocalBroker();\n const client = createClient(connection, { requestIdPrefix: \"daemon-lynx\" });\n console.log(\n `connected: endpoint=${connection.endpoint} session=${connection.sessionId}`,\n );\n\n const space = await client.createSpace({\n id: \"com.example.opentray.daemon-lynx\",\n title: \"OpenTray Lynx Smoke\",\n default: true,\n });\n console.log(`space: ${JSON.stringify(space.space)}`);\n\n const tray = await space.createTray({\n trayId: \"daemon-lynx-status\",\n title: \"OpenTray Lynx\",\n tooltip: {\n title: \"OpenTray Lynx\",\n description: \"Generic extension smoke for a real Lynx runtime window\",\n },\n icon: createVisibleIcon(),\n menu: {\n items: [\n { type: \"item\", id: 1, title: \"Show Window\" },\n { type: \"item\", id: 2, title: \"Hide Window\" },\n { type: \"separator\" },\n { type: \"item\", id: 99, title: \"Quit Smoke\" },\n ],\n },\n });\n console.log(`tray: ${tray.trayId}`);\n\n await connection.request({\n type: \"load-ext\",\n requestId: \"daemon-lynx-load\",\n spaceId: space.space.spaceId,\n name: \"lynx\",\n path: \"@opentray/ext-lynx\",\n });\n console.log(\"lynx extension requested through the generic load-ext path\");\n\n let closed = false;\n let exitTimer: NodeJS.Timeout | undefined;\n let resolveClosed: (() => void) | undefined;\n\n const show = async (): Promise<void> => {\n const command = createLynxShowCommand({\n bundlePath,\n hostFeatures,\n });\n await tray.commandExtension(\"lynx\", command);\n console.log(\n `lynx command: show features=${describeLynxHostFeatures(\n hostFeatures,\n )} bundle=${bundlePath}`,\n );\n };\n\n const hide = async (): Promise<void> => {\n await tray.commandExtension(\"lynx\", { type: \"hide\" });\n console.log(\"lynx command: hide\");\n };\n\n const shutdown = async (): Promise<void> => {\n if (closed) {\n return;\n }\n closed = true;\n if (exitTimer !== undefined) {\n clearTimeout(exitTimer);\n }\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n try {\n await hide();\n } catch (error) {\n console.error(`lynx hide during shutdown failed: ${String(error)}`);\n }\n await connection.close();\n resolveClosed?.();\n };\n\n const handleMenuClick = async (itemId: number): Promise<void> => {\n switch (itemId) {\n case 1:\n await show();\n return;\n case 2:\n await hide();\n return;\n case 99:\n console.log(\"quit item routed; closing lynx smoke connection\");\n await shutdown();\n return;\n default:\n return;\n }\n };\n\n connection.onEvent((frame) => {\n console.log(`broker -> client ${JSON.stringify(frame)}`);\n if (frame.type === \"event\" && frame.event.type === \"menuClick\") {\n console.log(\n `menu click: ${menuLabels.get(frame.event.itemId) ?? frame.event.itemId}`,\n );\n void handleMenuClick(frame.event.itemId);\n return;\n }\n if (frame.type === \"ext-event\" && frame.ext === \"lynx\") {\n console.log(`lynx event: ${JSON.stringify(frame.data)}`);\n }\n });\n\n const onSignal = (): void => {\n void shutdown();\n };\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n\n const exitAfter = process.env.OPENTRAY_EXAMPLE_EXIT_AFTER_MS;\n if (exitAfter !== undefined && exitAfter.length > 0) {\n const duration = Number.parseInt(exitAfter, 10);\n if (Number.isInteger(duration) && duration > 0) {\n exitTimer = setTimeout(() => {\n void shutdown();\n }, duration);\n }\n }\n\n try {\n await show();\n console.log(\n `use the tray menu to re-show or hide the window, or press Ctrl+C to exit; features=${describeLynxHostFeatures(\n hostFeatures,\n )}`,\n );\n } catch (error) {\n await connection.close();\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n throw error;\n }\n\n await new Promise<void>((resolve) => {\n resolveClosed = resolve;\n });\n};\n\nexport const resolveLynxBundlePath = (value?: string): string => {\n const resolved = value ?? process.env[DEFAULT_LYNX_BUNDLE_ENV];\n if (resolved === undefined || resolved.length === 0) {\n const bundledReviewBundle = resolveBundledReviewBundlePath();\n if (!existsSync(bundledReviewBundle)) {\n throw new Error(\n `lynx smoke requires --bundle <path>, ${DEFAULT_LYNX_BUNDLE_ENV}=<path-to-main.lynx.bundle>, or a packaged review bundle at ${bundledReviewBundle}`,\n );\n }\n return realpathSync(bundledReviewBundle);\n }\n const baseDir = process.env.INIT_CWD ?? process.cwd();\n const absolutePath = resolve(baseDir, resolved);\n if (!existsSync(absolutePath)) {\n throw new Error(`lynx smoke bundle does not exist: ${absolutePath}`);\n }\n return realpathSync(absolutePath);\n};\n\nexport const resolveLynxHostFeatures = (\n expression = process.env[DEFAULT_LYNX_HOST_FEATURES_ENV] ?? \"\",\n): LynxHostFeatureState => {\n const features = createEmptyLynxHostFeatures();\n for (const rawToken of expression.split(\",\")) {\n const token = rawToken.trim();\n if (token.length === 0) {\n continue;\n }\n applyLynxHostFeatureToken(features, token);\n }\n return features;\n};\n\nexport const createLynxShowCommand = ({\n bundlePath,\n hostFeatures,\n}: {\n bundlePath: string;\n hostFeatures: LynxHostFeatureState;\n}): LynxSmokeShowCommand => {\n const command: LynxSmokeShowCommand = {\n type: \"show\",\n bundlePath,\n width: 720,\n height: 420,\n minWidth: 320,\n minHeight: 220,\n maxWidth: 960,\n maxHeight: 720,\n nativeWindowApi: hostFeatures.nativeWindowApi,\n bindWindowGlobals: hostFeatures.bindWindowGlobals,\n nativeScreenApi: hostFeatures.nativeScreenApi,\n bindScreenGlobals: hostFeatures.bindScreenGlobals,\n title: `OpenTray Lynx Smoke (${describeLynxHostFeatures(hostFeatures)})`,\n icon: createVisibleIcon(),\n };\n if (hostFeatures.frameless) {\n command.style = { frameless: true };\n }\n return command;\n};\n\nexport const describeLynxHostFeatures = (\n features: LynxHostFeatureState,\n): string => {\n const enabled = LYNX_HOST_FEATURES.filter((feature) => features[feature]);\n return enabled.length === 0 ? \"baseline\" : enabled.join(\",\");\n};\n\nexport const resolveBundledReviewBundlePath = (\n moduleUrl = import.meta.url,\n): string => {\n let currentDir = dirname(fileURLToPath(moduleUrl));\n\n while (true) {\n const packageJson = join(currentDir, \"package.json\");\n if (existsSync(packageJson)) {\n return join(currentDir, DEFAULT_REVIEW_BUNDLE_RELATIVE_PATH);\n }\n\n const parent = dirname(currentDir);\n if (parent === currentDir) {\n throw new Error(`failed to resolve opentray package root from ${moduleUrl}`);\n }\n currentDir = parent;\n }\n};\n\nfunction createEmptyLynxHostFeatures(): LynxHostFeatureState {\n return {\n nativeWindowApi: false,\n bindWindowGlobals: false,\n nativeScreenApi: false,\n bindScreenGlobals: false,\n frameless: false,\n };\n}\n\nfunction applyLynxHostFeatureToken(\n features: LynxHostFeatureState,\n rawToken: string,\n): void {\n const disabled = rawToken.startsWith(\"!\");\n const token = disabled ? rawToken.slice(1) : rawToken;\n\n if (token === \"*\" || token === \"full\") {\n for (const feature of LYNX_HOST_FEATURES) {\n features[feature] = !disabled;\n }\n return;\n }\n if (token === \"baseline\") {\n for (const feature of LYNX_HOST_FEATURES) {\n features[feature] = false;\n }\n return;\n }\n if (!isLynxHostFeature(token)) {\n throw new Error(\n `unsupported Lynx host feature token: ${rawToken}; supported tokens: baseline, full, *, !<feature>, ${LYNX_HOST_FEATURES.join(\n \", \",\n )}`,\n );\n }\n features[token] = !disabled;\n if (token === \"nativeWindowApi\" && disabled) {\n features.bindWindowGlobals = false;\n return;\n }\n if (token === \"nativeScreenApi\" && disabled) {\n features.bindScreenGlobals = false;\n return;\n }\n if (token === \"bindWindowGlobals\" && !disabled) {\n features.nativeWindowApi = true;\n return;\n }\n if (token === \"bindScreenGlobals\" && !disabled) {\n features.nativeScreenApi = true;\n }\n}\n\nfunction isLynxHostFeature(value: string): value is LynxHostFeature {\n return (LYNX_HOST_FEATURES as readonly string[]).includes(value);\n}\n\nfunction createVisibleIcon(): {\n type: \"rgba\";\n width: number;\n height: number;\n data: number[];\n} {\n const width = 32;\n const height = 32;\n const data: number[] = [];\n\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n const inStroke = x <= 5 || (x >= 13 && x <= 18) || y >= 26;\n const inDiagonal = y >= x + 10 && x <= 18;\n const alpha = inStroke || inDiagonal ? 255 : 0;\n data.push(34, 92, 56, alpha);\n }\n }\n\n return { type: \"rgba\", width, height, data };\n}\n","import type { Rect } from \"@opentray/spec\";\n\nimport { createClient } from \"../client\";\nimport { connectLocalBroker } from \"../local-broker\";\n\nconst menuLabels = new Map<number, string>([\n [1, \"Open WebView\"],\n]);\n\ninterface WebviewShowCommand {\n type: \"show\";\n html?: string;\n url?: string;\n width?: number;\n height?: number;\n fallbackRect?: Rect;\n nativeWindowApi?: boolean;\n bindWindowGlobals?: boolean;\n nativeScreenApi?: boolean;\n bindScreenGlobals?: boolean;\n nativeTrayApi?: boolean;\n title?: string;\n icon?: { type: \"href\"; href: string };\n style?: {\n frameless?: boolean;\n transparent?: boolean;\n keepOnTop?: boolean;\n platform?: {\n macos?: {\n material?: string | null;\n materialState?: \"followsWindowActiveState\" | \"active\" | \"inactive\";\n cornerRadius?: number | null;\n };\n };\n };\n titleSync?: boolean | { documentToWindow?: boolean; windowToDocument?: boolean };\n iconSync?: boolean | { faviconToWindow?: boolean; windowToFavicon?: boolean };\n nativeApiPolicy?: {\n defaultSrc?: string[];\n window?: string[];\n screen?: string[];\n tray?: string[];\n windowGlobals?: string[];\n screenGlobals?: string[];\n titleSync?: string[];\n iconSync?: string[];\n };\n}\n\nexport const runDaemonTraySmoke = async (): Promise<void> => {\n const connection = await connectLocalBroker();\n const client = createClient(connection, { requestIdPrefix: \"daemon-smoke\" });\n console.log(`connected: endpoint=${connection.endpoint} session=${connection.sessionId}`);\n\n const space = await client.createSpace({\n id: \"com.example.opentray.daemon-smoke\",\n title: \"OpenTray Daemon Smoke\",\n default: true,\n });\n console.log(`space: ${JSON.stringify(space.space)}`);\n\n const tray = await space.createTray({\n trayId: \"daemon-smoke-status\",\n title: \"OpenTray\",\n tooltip: {\n title: \"OpenTray\",\n description: \"Single primary tray action; macOS direct-triggers without opening a menu\",\n },\n icon: createVisibleIcon(),\n menu: {\n items: [\n { type: \"item\", id: 1, title: \"Open WebView\", primaryEvent: true },\n ],\n },\n });\n console.log(`tray: ${tray.trayId}`);\n\n await connection.request({\n type: \"load-ext\",\n requestId: \"daemon-smoke-load-webview\",\n spaceId: space.space.spaceId,\n name: \"webview\",\n path: \"@opentray/ext-webview\",\n });\n console.log(\"webview extension requested through the generic load-ext path\");\n console.log(\"click the tray icon: macOS should direct-trigger the single primary action without opening a menu\");\n\n let closed = false;\n let exitTimer: NodeJS.Timeout | undefined;\n\n const shutdown = async (): Promise<void> => {\n if (closed) {\n return;\n }\n closed = true;\n if (exitTimer !== undefined) {\n clearTimeout(exitTimer);\n }\n await connection.close();\n };\n\n const commandWebview = async (command: WebviewShowCommand | Record<string, unknown>): Promise<void> => {\n await tray.commandExtension(\"webview\", command);\n };\n\n const handleMenuClick = async (itemId: number): Promise<void> => {\n if (itemId === 1) {\n const trayBounds = await tray.getBounds();\n console.log(`tray bounds: ${JSON.stringify(trayBounds)}`);\n await commandWebview({\n type: \"show\",\n html: createWebviewDemoHtml(),\n width: 420,\n height: 260,\n title: \"OpenTray WebView Smoke\",\n icon: {\n type: \"href\",\n href: \"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mP8/x8AAwMCAO+/p9sAAAAASUVORK5CYII=\",\n },\n style: {\n frameless: true,\n transparent: true,\n keepOnTop: true,\n platform: {\n macos: {\n material: \"hudWindow\",\n materialState: \"active\",\n },\n },\n },\n fallbackRect: trayBounds.rect ?? { x: 0, y: 0, width: 1, height: 1 },\n nativeWindowApi: true,\n bindWindowGlobals: true,\n nativeScreenApi: true,\n bindScreenGlobals: true,\n nativeTrayApi: true,\n titleSync: {\n documentToWindow: true,\n windowToDocument: true,\n },\n iconSync: true,\n nativeApiPolicy: {\n defaultSrc: [\"'local'\"],\n window: [\"https://example.com\"],\n screen: [\"https://example.com\"],\n tray: [\"https://example.com\"],\n titleSync: [\"https://example.com\"],\n iconSync: [\"https://example.com\"],\n },\n });\n console.log(\"primary tray action: webview show\");\n return;\n }\n };\n\n connection.onEvent((frame) => {\n console.log(`broker -> client ${JSON.stringify(frame)}`);\n if (frame.type === \"event\" && frame.event.type === \"menuClick\") {\n console.log(`menu click: ${menuLabels.get(frame.event.itemId) ?? frame.event.itemId}`);\n void handleMenuClick(frame.event.itemId);\n }\n });\n\n const exitAfter = process.env.OPENTRAY_EXAMPLE_EXIT_AFTER_MS;\n if (exitAfter !== undefined && exitAfter.length > 0) {\n const duration = Number.parseInt(exitAfter, 10);\n if (Number.isInteger(duration) && duration > 0) {\n exitTimer = setTimeout(() => {\n void shutdown();\n }, duration);\n }\n }\n\n const webviewSmoke = process.env.OPENTRAY_EXAMPLE_WEBVIEW_SMOKE;\n try {\n if (webviewSmoke === \"show\" || webviewSmoke === \"1\") {\n await handleMenuClick(1);\n }\n if (webviewSmoke === \"1\") {\n if (exitTimer !== undefined) {\n clearTimeout(exitTimer);\n exitTimer = undefined;\n }\n await sleep(300);\n await shutdown();\n }\n } catch (error) {\n await shutdown();\n throw error;\n }\n};\n\nfunction createVisibleIcon(): { type: \"rgba\"; width: number; height: number; data: number[] } {\n const width = 32;\n const height = 32;\n const data: number[] = [];\n\n for (let y = 0; y < height; y += 1) {\n for (let x = 0; x < width; x += 1) {\n const dx = x - 15.5;\n const dy = y - 15.5;\n const distance = Math.sqrt(dx * dx + dy * dy);\n const inRing = distance >= 9 && distance <= 14;\n const inCore = distance <= 5;\n const inNeedle = Math.abs(dx + dy) <= 1.2 && x >= 9 && x <= 23 && y >= 9 && y <= 23;\n\n if (inRing || inCore || inNeedle) {\n data.push(inCore ? 255 : 24, inNeedle ? 240 : 132, inRing ? 72 : 96, 255);\n } else {\n data.push(0, 0, 0, 0);\n }\n }\n }\n\n return { type: \"rgba\", width, height, data };\n}\n\nfunction createWebviewDemoHtml(): string {\n return `<!doctype html>\n<html lang=\"en\">\n <head>\n <meta charset=\"utf-8\" />\n <title>OpenTray WebView</title>\n <style>\n :root {\n color: #18220f;\n background: #f6edd8;\n font: 15px ui-rounded, \"SF Pro Rounded\", \"Avenir Next\", sans-serif;\n }\n body {\n margin: 0;\n }\n main {\n min-height: 100vh;\n box-sizing: border-box;\n padding: 22px;\n background:\n radial-gradient(circle at 84% 10%, rgba(34, 132, 96, 0.22), transparent 34%),\n linear-gradient(135deg, #fff8e7 0%, #e9f0d8 100%);\n }\n h1 {\n margin: 0 0 8px;\n font-size: 24px;\n letter-spacing: -0.04em;\n }\n p {\n margin: 0 0 16px;\n color: #526044;\n }\n section {\n display: grid;\n gap: 10px;\n }\n .card {\n border: 1px solid rgba(24, 34, 15, 0.16);\n border-radius: 14px;\n padding: 12px;\n background: rgba(255, 255, 255, 0.72);\n box-shadow: 0 12px 30px rgba(56, 72, 36, 0.12);\n }\n .label {\n margin-bottom: 5px;\n color: #7b5b1d;\n font-size: 12px;\n font-weight: 700;\n letter-spacing: 0.08em;\n text-transform: uppercase;\n }\n code {\n word-break: break-word;\n }\n </style>\n </head>\n <body>\n <main>\n <h1>OpenTray WebView</h1>\n <p>This window was opened by the single primary tray action.</p>\n <section>\n <div class=\"card\">\n <div class=\"label\">primary event</div>\n <code>macOS single primary item direct-triggered menuClick -> WebView show</code>\n </div>\n </section>\n </main>\n </body>\n</html>`;\n}\n\nfunction sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n","#!/usr/bin/env node\nimport { realpathSync } from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport { fileURLToPath } from \"node:url\";\n\nimport type { DaemonHealth } from \"@opentray/spec\";\n\nimport {\n createNodeDaemonDriver,\n inspectDaemon,\n restartDaemon,\n startDaemon,\n stopDaemon,\n} from \"./daemon/lifecycle\";\nimport { readPackageVersion } from \"./daemon/package-version\";\nimport { resolveDaemonPaths } from \"./daemon/paths\";\nimport { connectLocalBroker } from \"./local-broker\";\nimport { runDaemonLynxSmoke } from \"./smoke/daemon-lynx\";\nimport { runDaemonTraySmoke } from \"./smoke/daemon-tray\";\n\nconst packageJsonUrl = new URL(\"../package.json\", import.meta.url);\nconst cliModulePath = fileURLToPath(import.meta.url);\n\ntype CliCommand =\n | { type: \"daemon\"; action: \"start\" | \"stop\" | \"restart\" | \"health\" }\n | { type: \"smoke\"; name: \"daemon-tray\" }\n | {\n type: \"smoke\";\n name: \"daemon-lynx\";\n bundlePath?: string;\n featureExpression?: string;\n }\n | { type: \"help\" };\n\nexport const parseCliCommand = (argv: string[]): CliCommand => {\n const [group, action, ...rest] = argv;\n if (group !== \"daemon\") {\n if (group === \"smoke\" && action === \"daemon-tray\") {\n return { type: \"smoke\", name: \"daemon-tray\" };\n }\n if (group === \"smoke\" && action === \"daemon-lynx\") {\n const smokeOptions = parseSmokeOptions(rest);\n return {\n type: \"smoke\",\n name: \"daemon-lynx\",\n ...(smokeOptions.bundlePath\n ? { bundlePath: smokeOptions.bundlePath }\n : {}),\n ...(smokeOptions.featureExpression\n ? { featureExpression: smokeOptions.featureExpression }\n : {}),\n };\n }\n return { type: \"help\" };\n }\n if (\n action === \"start\" ||\n action === \"stop\" ||\n action === \"restart\" ||\n action === \"health\"\n ) {\n return { type: \"daemon\", action };\n }\n\n return { type: \"help\" };\n};\n\nexport const runCli = async (argv: string[]): Promise<number> => {\n const command = parseCliCommand(argv);\n const packageVersion =\n process.env.OPENTRAY_DAEMON_PACKAGE_VERSION ??\n (await readPackageVersion(packageJsonUrl));\n const paths = resolveDaemonPaths({\n homeDir: process.env.OPENTRAY_HOME ?? homedir(),\n packageVersion,\n });\n\n if (command.type === \"help\") {\n printHelp();\n return 1;\n }\n\n if (command.type === \"smoke\") {\n if (command.name === \"daemon-tray\") {\n await runDaemonTraySmoke();\n } else {\n await runDaemonLynxSmoke(\n {\n ...(command.bundlePath === undefined\n ? {}\n : { bundlePath: command.bundlePath }),\n ...(command.featureExpression === undefined\n ? {}\n : { featureExpression: command.featureExpression }),\n }\n );\n }\n return 0;\n }\n\n const driver = createNodeDaemonDriver(cliModulePath);\n\n if (command.action === \"start\") {\n const result = await startDaemon({ paths, driver });\n console.log(\n `opentray daemon ${result.status}: pid=${result.pid} endpoint=${result.paths.endpoint}`\n );\n return 0;\n }\n\n if (command.action === \"stop\") {\n const result = await stopDaemon({ paths, driver });\n console.log(\n result.status === \"stopped\"\n ? `opentray daemon stopped: pid=${result.pid}`\n : \"opentray daemon not running\"\n );\n return 0;\n }\n\n if (command.action === \"restart\") {\n const result = await restartDaemon({ paths, driver });\n console.log(\n `opentray daemon ${result.status}: pid=${result.pid} endpoint=${result.paths.endpoint}`\n );\n return 0;\n }\n\n if (command.action === \"health\") {\n const inspected = await inspectDaemon({ paths, driver });\n if (inspected.status === \"not-running\") {\n console.log(\"opentray daemon not running\");\n return 0;\n }\n\n const connection = await connectLocalBroker({\n autoStart: false,\n endpoint: paths.endpoint,\n homeDir: paths.homeDir,\n packageVersion,\n });\n try {\n const response = await connection.request({\n type: \"health\",\n requestId: \"opentray-daemon-health\",\n });\n if (response.type !== \"daemon-health\") {\n throw new Error(\n `expected daemon-health response, received ${response.type}`\n );\n }\n console.log(formatDaemonHealthOutput(response.health));\n } finally {\n await connection.close();\n }\n return 0;\n }\n\n printHelp();\n return 1;\n};\n\nconst printHelp = (): void => {\n console.error(\"Usage: opentray daemon <start|stop|restart|health>\");\n console.error(\" opentray smoke daemon-tray\");\n console.error(\n \" opentray smoke daemon-lynx [--bundle <path-to-main.lynx.bundle>] [--features <baseline|full|*,!feature,...>]\"\n );\n console.error(\" default Lynx smoke uses the packaged review bundle\");\n};\n\nexport const formatDaemonHealthOutput = (health: DaemonHealth): string => {\n const lines = [\n \"opentray daemon running\",\n `pid: ${health.pid}`,\n `endpoint: ${health.endpoint}`,\n `packageVersion: ${health.packageVersion}`,\n `protocolVersion: ${health.protocolVersion}`,\n `sessions: ${health.sessionCount}`,\n ];\n\n for (const session of health.sessions) {\n const internalLease = session.internalLeaseId ?? \"(pending)\";\n lines.push(\n `- sessionId=${session.sessionId} initialized=${session.initialized} internalLeaseId=${internalLease}`\n );\n }\n\n return lines.join(\"\\n\");\n};\n\nexport const isCliEntrypoint = (\n argvEntryPath: string | undefined,\n modulePath: string\n): boolean => {\n if (argvEntryPath === undefined) return false;\n try {\n return realpathSync(argvEntryPath) === realpathSync(modulePath);\n } catch {\n return argvEntryPath === modulePath;\n }\n};\n\nfunction parseSmokeOptions(argv: string[]): {\n bundlePath?: string;\n featureExpression?: string;\n} {\n let bundlePath: string | undefined;\n let featureExpression: string | undefined;\n for (let index = 0; index < argv.length; index += 1) {\n if (argv[index] === \"--bundle\") {\n bundlePath = argv[index + 1];\n continue;\n }\n if (argv[index] === \"--features\") {\n featureExpression = argv[index + 1];\n }\n }\n return {\n ...(bundlePath === undefined ? {} : { bundlePath }),\n ...(featureExpression === undefined ? {} : { featureExpression }),\n };\n}\n\nif (isCliEntrypoint(process.argv[1], cliModulePath)) {\n runCli(process.argv.slice(2)).then((code) => {\n process.exitCode = code;\n });\n}\n"],"mappings":";;;;;;;;AAOA,MAAMA,e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AQ;EACN,OAAO,kBAAkB;CAC3B;AACF;AAEA,SAAS,kBAAkB,MAGzB;CACA,IAAI;CACJ,IAAI;CACJ,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,QAAQ,SAAS,GAAG;EACnD,IAAI,KAAK,WAAW,YAAY;GAC9B,aAAa,KAAK,QAAQ;GAC1B;EACF;EACA,IAAI,KAAK,WAAW,cAClB,oBAAoB,KAAK,QAAQ;CAErC;CACA,OAAO;EACL,GAAI,eAAe,KAAA,IAAY,CAAC,IAAI,EAAE,WAAW;EACjD,GAAI,sBAAsB,KAAA,IAAY,CAAC,IAAI,EAAE,kBAAkB;CACjE;AACF;AAEA,IAAI,gBAAgB,QAAQ,KAAK,IAAI,aAAa,GAChD,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC,EAAE,MAAM,SAAS;CAC3C,QAAQ,WAAW;AACrB,CAAC"}
|
|
@@ -20,9 +20,34 @@ interface TrayHandle {
|
|
|
20
20
|
space: SpaceRef;
|
|
21
21
|
trayId: TrayId;
|
|
22
22
|
getBounds(): Promise<TrayBoundsResult>;
|
|
23
|
+
loadExtension(options: ExtensionLoadOptions): Promise<void>;
|
|
23
24
|
commandExtension(ext: string, data: unknown): Promise<void>;
|
|
25
|
+
extend<TCapability extends object, TOptions = undefined>(extension: TrayExtension<TCapability, TOptions>, options?: TOptions): TrayHandle & TCapability;
|
|
24
26
|
destroy(): Promise<void>;
|
|
25
27
|
}
|
|
28
|
+
interface ExtensionLoadOptions {
|
|
29
|
+
name: string;
|
|
30
|
+
path: string;
|
|
31
|
+
mountId?: string;
|
|
32
|
+
}
|
|
33
|
+
interface TrayExtensionMountSpec {
|
|
34
|
+
name?: string;
|
|
35
|
+
path?: string;
|
|
36
|
+
mountId?: string;
|
|
37
|
+
}
|
|
38
|
+
interface TrayExtensionContext {
|
|
39
|
+
readonly name: string;
|
|
40
|
+
readonly path: string;
|
|
41
|
+
readonly mountId: string;
|
|
42
|
+
ensureLoaded(): Promise<void>;
|
|
43
|
+
command(data: unknown): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
interface TrayExtension<TCapability extends object, TOptions = undefined> {
|
|
46
|
+
readonly name: string;
|
|
47
|
+
readonly path: string;
|
|
48
|
+
resolveMount?(options: TOptions | undefined): TrayExtensionMountSpec;
|
|
49
|
+
extend(tray: TrayHandle, context: TrayExtensionContext, options: TOptions | undefined): TCapability;
|
|
50
|
+
}
|
|
26
51
|
declare const createInitFrame: (clientVersion: string) => ClientFrame;
|
|
27
52
|
interface CreateClientOptions {
|
|
28
53
|
requestIdPrefix?: string;
|
|
@@ -33,5 +58,5 @@ declare const createSpaceHandle: (transport: OpenTrayTransport, space: SpaceRef,
|
|
|
33
58
|
declare const createSurfaceHandle: (transport: OpenTrayTransport, space: SpaceRef, nextRequestId?: () => RequestId) => SpaceHandle;
|
|
34
59
|
declare const createTrayHandle: (transport: OpenTrayTransport, space: SpaceRef, trayId: TrayId, nextRequestId?: () => RequestId) => TrayHandle;
|
|
35
60
|
//#endregion
|
|
36
|
-
export {
|
|
37
|
-
//# sourceMappingURL=client-
|
|
61
|
+
export { SpaceHandle as a, TrayExtensionContext as c, createClient as d, createInitFrame as f, createTrayHandle as h, OpenTrayTransport as i, TrayExtensionMountSpec as l, createSurfaceHandle as m, ExtensionLoadOptions as n, SurfaceHandle as o, createSpaceHandle as p, OpenTrayClient as r, TrayExtension as s, CreateClientOptions as t, TrayHandle as u };
|
|
62
|
+
//# sourceMappingURL=client-DQn3DLZw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-DQn3DLZw.d.mts","names":[],"sources":["../src/client.ts"],"mappings":";;;UAaiB,iBAAA;EACf,OAAA,CAAQ,KAAA,EAAO,kBAAA,GAAqB,OAAA,CAAQ,WAAA;AAAA;AAAA,UAG7B,cAAA;EACf,WAAA,CAAY,OAAA,EAAS,YAAA,GAAe,OAAA,CAAQ,WAAA;EAC5C,mBAAA,IAAuB,OAAA,CAAQ,WAAA;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,EAAO,QAAA,EACP,aAAA,SAAqB,SAAA,KACpB,WAAA;;cAgBU,mBAAA,GAAmB,SAAA,EAnBnB,iBAAA,EAAiB,KAAA,EACrB,QAAA,EAAQ,aAAA,SACM,SAAA,KACpB,WAAA;AAAA,cAkBU,gBAAA,GACX,SAAA,EAAW,iBAAA,EACX,KAAA,EAAO,QAAA,EACP,MAAA,EAAQ,MAAA,EACR,aAAA,SAAqB,SAAA,KACpB,UAAA"}
|
|
@@ -44,39 +44,96 @@ const createSpaceHandle = (transport, space, nextRequestId = createRequestIdFact
|
|
|
44
44
|
});
|
|
45
45
|
/** @deprecated Use `createSpaceHandle`. */
|
|
46
46
|
const createSurfaceHandle = createSpaceHandle;
|
|
47
|
-
const createTrayHandle = (transport, space, trayId, nextRequestId = createRequestIdFactory("opentray")) =>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
47
|
+
const createTrayHandle = (transport, space, trayId, nextRequestId = createRequestIdFactory("opentray")) => {
|
|
48
|
+
let nextMountOrdinal = 1;
|
|
49
|
+
const nextMountId = (extensionName) => {
|
|
50
|
+
const mountId = `${formatMountIdComponent(extensionName)}.${formatMountIdComponent(trayId)}.${nextMountOrdinal}`;
|
|
51
|
+
nextMountOrdinal += 1;
|
|
52
|
+
return mountId;
|
|
53
|
+
};
|
|
54
|
+
const handle = {
|
|
55
|
+
space,
|
|
56
|
+
trayId,
|
|
57
|
+
async getBounds() {
|
|
58
|
+
const requestId = nextRequestId();
|
|
59
|
+
return expectResponse(await transport.request({
|
|
60
|
+
type: "get-tray-bounds",
|
|
61
|
+
requestId,
|
|
62
|
+
spaceId: space.spaceId,
|
|
63
|
+
trayId
|
|
64
|
+
}), requestId, "tray-bounds").bounds;
|
|
65
|
+
},
|
|
66
|
+
async loadExtension(options) {
|
|
67
|
+
const requestId = nextRequestId();
|
|
68
|
+
expectResponse(await transport.request({
|
|
69
|
+
type: "load-ext",
|
|
70
|
+
requestId,
|
|
71
|
+
spaceId: space.spaceId,
|
|
72
|
+
name: options.name,
|
|
73
|
+
path: options.path,
|
|
74
|
+
...options.mountId === void 0 ? {} : { mountId: options.mountId }
|
|
75
|
+
}), requestId, "ack");
|
|
76
|
+
},
|
|
77
|
+
async commandExtension(ext, data) {
|
|
78
|
+
const requestId = nextRequestId();
|
|
79
|
+
expectResponse(await transport.request({
|
|
80
|
+
type: "ext-command",
|
|
81
|
+
requestId,
|
|
82
|
+
spaceId: space.spaceId,
|
|
83
|
+
trayId,
|
|
84
|
+
ext,
|
|
85
|
+
data
|
|
86
|
+
}), requestId, "ack");
|
|
87
|
+
},
|
|
88
|
+
extend(extension, options) {
|
|
89
|
+
const context = createTrayExtensionContext(handle, extension, options, nextMountId);
|
|
90
|
+
const capability = extension.extend(handle, context, options);
|
|
91
|
+
return Object.assign({}, handle, capability);
|
|
92
|
+
},
|
|
93
|
+
async destroy() {
|
|
94
|
+
const requestId = nextRequestId();
|
|
95
|
+
expectResponse(await transport.request({
|
|
96
|
+
type: "destroy-tray",
|
|
97
|
+
requestId,
|
|
98
|
+
spaceId: space.spaceId,
|
|
99
|
+
trayId
|
|
100
|
+
}), requestId, "ack");
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
return handle;
|
|
104
|
+
};
|
|
105
|
+
const createTrayExtensionContext = (tray, extension, options, nextMountId) => {
|
|
106
|
+
const mount = extension.resolveMount?.(options) ?? {};
|
|
107
|
+
const name = mount.name ?? extension.name;
|
|
108
|
+
const path = mount.path ?? extension.path;
|
|
109
|
+
const mountId = mount.mountId ?? nextMountId(name);
|
|
110
|
+
let loadPromise;
|
|
111
|
+
const ensureLoaded = async () => {
|
|
112
|
+
if (loadPromise === void 0) loadPromise = tray.loadExtension({
|
|
113
|
+
name,
|
|
114
|
+
path,
|
|
115
|
+
mountId
|
|
116
|
+
}).catch((error) => {
|
|
117
|
+
loadPromise = void 0;
|
|
118
|
+
throw error;
|
|
119
|
+
});
|
|
120
|
+
await loadPromise;
|
|
121
|
+
};
|
|
122
|
+
return {
|
|
123
|
+
name,
|
|
124
|
+
path,
|
|
125
|
+
mountId,
|
|
126
|
+
ensureLoaded,
|
|
127
|
+
async command(data) {
|
|
128
|
+
await ensureLoaded();
|
|
129
|
+
await tray.commandExtension(mountId, data);
|
|
130
|
+
}
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
const formatMountIdComponent = (value) => {
|
|
134
|
+
const formatted = value.replaceAll(/[^a-zA-Z0-9._+-]/g, "_");
|
|
135
|
+
return formatted.length > 0 ? formatted : "ext";
|
|
136
|
+
};
|
|
80
137
|
const createRequestIdFactory = (prefix) => {
|
|
81
138
|
let next = 1;
|
|
82
139
|
return () => {
|
|
@@ -108,4 +165,4 @@ const requestIdOf = (frame) => {
|
|
|
108
165
|
//#endregion
|
|
109
166
|
export { createTrayHandle as a, createSurfaceHandle as i, createInitFrame as n, createSpaceHandle as r, createClient as t };
|
|
110
167
|
|
|
111
|
-
//# sourceMappingURL=client-
|
|
168
|
+
//# sourceMappingURL=client-DzcHIH-f.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client-DzcHIH-f.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import {\n PROTOCOL_VERSION,\n type ClientFrame,\n type ClientRequestFrame,\n type RequestId,\n type ServerFrame,\n type SpaceOptions,\n type SpaceRef,\n type TrayBoundsResult,\n type TrayId,\n type TrayOptions,\n} from \"@opentray/spec\";\n\nexport interface OpenTrayTransport {\n request(frame: ClientRequestFrame): Promise<ServerFrame>;\n}\n\nexport interface OpenTrayClient {\n createSpace(options: SpaceOptions): Promise<SpaceHandle>;\n resolveDefaultSpace(): Promise<SpaceHandle>;\n /** @deprecated Use `createSpace`. */\n createSurface(options: SpaceOptions): Promise<SpaceHandle>;\n}\n\nexport interface SpaceHandle {\n space: SpaceRef;\n createTray(options: TrayOptions): Promise<TrayHandle>;\n}\n\n/** @deprecated Use `SpaceHandle`. */\nexport type SurfaceHandle = SpaceHandle;\n\nexport interface TrayHandle {\n space: SpaceRef;\n trayId: TrayId;\n getBounds(): Promise<TrayBoundsResult>;\n loadExtension(options: ExtensionLoadOptions): Promise<void>;\n commandExtension(ext: string, data: unknown): Promise<void>;\n extend<TCapability extends object, TOptions = undefined>(\n extension: TrayExtension<TCapability, TOptions>,\n options?: TOptions,\n ): TrayHandle & TCapability;\n destroy(): Promise<void>;\n}\n\nexport interface ExtensionLoadOptions {\n name: string;\n path: string;\n mountId?: string;\n}\n\nexport interface TrayExtensionMountSpec {\n name?: string;\n path?: string;\n mountId?: string;\n}\n\nexport interface TrayExtensionContext {\n readonly name: string;\n readonly path: string;\n readonly mountId: string;\n ensureLoaded(): Promise<void>;\n command(data: unknown): Promise<void>;\n}\n\nexport interface TrayExtension<TCapability extends object, TOptions = undefined> {\n readonly name: string;\n readonly path: string;\n resolveMount?(options: TOptions | undefined): TrayExtensionMountSpec;\n extend(tray: TrayHandle, context: TrayExtensionContext, options: TOptions | undefined): TCapability;\n}\n\nexport const createInitFrame = (clientVersion: string): ClientFrame => ({\n type: \"init\",\n protocolVersion: PROTOCOL_VERSION,\n clientVersion,\n});\n\nexport interface CreateClientOptions {\n requestIdPrefix?: string;\n}\n\nexport const createClient = (\n transport: OpenTrayTransport,\n options: CreateClientOptions = {},\n): OpenTrayClient => {\n const nextRequestId = createRequestIdFactory(options.requestIdPrefix ?? \"opentray\");\n\n return {\n async createSpace(spaceOptions): Promise<SpaceHandle> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"create-space\",\n requestId,\n ...spaceOptions,\n });\n const space = expectResponse(response, requestId, \"space-created\").space;\n return createSpaceHandle(transport, space, nextRequestId);\n },\n async resolveDefaultSpace(): Promise<SpaceHandle> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"resolve-default-space\",\n requestId,\n });\n const space = expectResponse(response, requestId, \"default-space\").space;\n return createSpaceHandle(transport, space, nextRequestId);\n },\n async createSurface(spaceOptions): Promise<SpaceHandle> {\n return this.createSpace(spaceOptions);\n },\n };\n};\n\nexport const createSpaceHandle = (\n transport: OpenTrayTransport,\n space: SpaceRef,\n nextRequestId: () => RequestId = createRequestIdFactory(\"opentray\"),\n): SpaceHandle => ({\n space,\n async createTray(options: TrayOptions): Promise<TrayHandle> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"create-tray\",\n requestId,\n space,\n tray: options,\n });\n const frame = expectResponse(response, requestId, \"tray-created\");\n return createTrayHandle(transport, space, frame.trayId, nextRequestId);\n },\n});\n\n/** @deprecated Use `createSpaceHandle`. */\nexport const createSurfaceHandle = createSpaceHandle;\n\nexport const createTrayHandle = (\n transport: OpenTrayTransport,\n space: SpaceRef,\n trayId: TrayId,\n nextRequestId: () => RequestId = createRequestIdFactory(\"opentray\"),\n): TrayHandle => {\n let nextMountOrdinal = 1;\n const nextMountId = (extensionName: string): string => {\n const mountId = `${formatMountIdComponent(extensionName)}.${formatMountIdComponent(trayId)}.${nextMountOrdinal}`;\n nextMountOrdinal += 1;\n return mountId;\n };\n const handle: TrayHandle = {\n space,\n trayId,\n async getBounds(): Promise<TrayBoundsResult> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"get-tray-bounds\",\n requestId,\n spaceId: space.spaceId,\n trayId,\n });\n return expectResponse(response, requestId, \"tray-bounds\").bounds;\n },\n async loadExtension(options): Promise<void> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"load-ext\",\n requestId,\n spaceId: space.spaceId,\n name: options.name,\n path: options.path,\n ...(options.mountId === undefined ? {} : { mountId: options.mountId }),\n });\n expectResponse(response, requestId, \"ack\");\n },\n async commandExtension(ext: string, data: unknown): Promise<void> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"ext-command\",\n requestId,\n spaceId: space.spaceId,\n trayId,\n ext,\n data,\n });\n expectResponse(response, requestId, \"ack\");\n },\n extend<TCapability extends object, TOptions = undefined>(\n extension: TrayExtension<TCapability, TOptions>,\n options?: TOptions,\n ): TrayHandle & TCapability {\n const context = createTrayExtensionContext(handle, extension, options, nextMountId);\n const capability = extension.extend(handle, context, options);\n return Object.assign({}, handle, capability);\n },\n async destroy(): Promise<void> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"destroy-tray\",\n requestId,\n spaceId: space.spaceId,\n trayId,\n });\n expectResponse(response, requestId, \"ack\");\n },\n };\n return handle;\n};\n\nconst createTrayExtensionContext = <TCapability extends object, TOptions>(\n tray: TrayHandle,\n extension: TrayExtension<TCapability, TOptions>,\n options: TOptions | undefined,\n nextMountId: (extensionName: string) => string,\n): TrayExtensionContext => {\n const mount = extension.resolveMount?.(options) ?? {};\n const name = mount.name ?? extension.name;\n const path = mount.path ?? extension.path;\n const mountId = mount.mountId ?? nextMountId(name);\n let loadPromise: Promise<void> | undefined;\n\n const ensureLoaded = async (): Promise<void> => {\n if (loadPromise === undefined) {\n loadPromise = tray.loadExtension({ name, path, mountId }).catch((error: unknown) => {\n loadPromise = undefined;\n throw error;\n });\n }\n await loadPromise;\n };\n\n return {\n name,\n path,\n mountId,\n ensureLoaded,\n async command(data: unknown): Promise<void> {\n await ensureLoaded();\n await tray.commandExtension(mountId, data);\n },\n };\n};\n\nconst formatMountIdComponent = (value: string): string => {\n const formatted = value.replaceAll(/[^a-zA-Z0-9._+-]/g, \"_\");\n return formatted.length > 0 ? formatted : \"ext\";\n};\n\nconst createRequestIdFactory = (prefix: string): (() => RequestId) => {\n let next = 1;\n return () => {\n const requestId = `${prefix}-${next}`;\n next += 1;\n return requestId;\n };\n};\n\nconst expectResponse = <TType extends ServerFrame[\"type\"]>(\n frame: ServerFrame,\n requestId: RequestId,\n type: TType,\n): Extract<ServerFrame, { type: TType }> => {\n if (frame.type === \"error\") {\n throw new Error(`${frame.code}: ${frame.message}`);\n }\n if (frame.type !== type) {\n throw new Error(`expected ${type} for ${requestId}, received ${frame.type}`);\n }\n if (requestIdOf(frame) !== requestId) {\n throw new Error(`expected response for ${requestId}, received ${requestIdOf(frame) ?? \"none\"}`);\n }\n return frame as Extract<ServerFrame, { type: TType }>;\n};\n\nconst requestIdOf = (frame: ServerFrame): RequestId | undefined => {\n switch (frame.type) {\n case \"space-created\":\n case \"default-space\":\n case \"tray-created\":\n case \"tray-bounds\":\n case \"ack\":\n case \"daemon-health\":\n return frame.requestId;\n case \"error\":\n return frame.requestId;\n case \"ready\":\n case \"event\":\n case \"ext-event\":\n return undefined;\n }\n};\n"],"mappings":";;AAwEA,MAAa,mBAAmB,mBAAwC;CACtE,MAAM;CACN,iBAAiB;CACjB;AACF;AAMA,MAAa,gBACX,WACA,UAA+B,CAAC,MACb;CACnB,MAAM,gBAAgB,uBAAuB,QAAQ,mBAAmB,UAAU;CAElF,OAAO;EACL,MAAM,YAAY,cAAoC;GACpD,MAAM,YAAY,cAAc;GAMhC,MAAM,QAAQ,eAAe,MALN,UAAU,QAAQ;IACvC,MAAM;IACN;IACA,GAAG;GACL,CAAC,GACsC,WAAW,eAAe,EAAE;GACnE,OAAO,kBAAkB,WAAW,OAAO,aAAa;EAC1D;EACA,MAAM,sBAA4C;GAChD,MAAM,YAAY,cAAc;GAKhC,MAAM,QAAQ,eAAe,MAJN,UAAU,QAAQ;IACvC,MAAM;IACN;GACF,CAAC,GACsC,WAAW,eAAe,EAAE;GACnE,OAAO,kBAAkB,WAAW,OAAO,aAAa;EAC1D;EACA,MAAM,cAAc,cAAoC;GACtD,OAAO,KAAK,YAAY,YAAY;EACtC;CACF;AACF;AAEA,MAAa,qBACX,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,YAAY,KAAK,MAAM,WACzB,MAAM,IAAI,MAAM,yBAAyB,UAAU,aAAa,YAAY,KAAK,KAAK,QAAQ;CAEhG,OAAO;AACT;AAEA,MAAM,eAAe,UAA8C;CACjE,QAAQ,MAAM,MAAd;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,iBACH,OAAO,MAAM;EACf,KAAK,SACH,OAAO,MAAM;EACf,KAAK;EACL,KAAK;EACL,KAAK,aACH;CACJ;AACF"}
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as SpaceHandle, c as TrayExtensionContext, d as createClient, f as createInitFrame, h as createTrayHandle, i as OpenTrayTransport, l as TrayExtensionMountSpec, m as createSurfaceHandle, n as ExtensionLoadOptions, o as SurfaceHandle, p as createSpaceHandle, r as OpenTrayClient, s as TrayExtension, t as CreateClientOptions, u as TrayHandle } from "./client-DQn3DLZw.mjs";
|
|
2
2
|
import { BrokerEndpointIdentity, BrokerEndpointIdentityOptions, PROTOCOL_VERSION, SpaceOptions, SpaceRef, TrayOptions, createBrokerEndpointIdentity, formatBrokerEndpointName, formatBrokerStateRoot, formatUnixSocketPath, formatWindowsPipeName, isSupportedProtocolVersion } from "@opentray/spec";
|
|
3
3
|
|
|
4
4
|
//#region src/sdk.d.ts
|
|
@@ -19,5 +19,5 @@ declare const createSurface: (options: SpaceOptions, brokerOptions?: BrokerConne
|
|
|
19
19
|
declare const resolveDefaultSpace: (brokerOptions?: BrokerConnectOptions) => Promise<SpaceHandle>;
|
|
20
20
|
declare const createTray: (options: TrayOptions, brokerOptions?: CreateTrayOptions) => Promise<TrayHandle>;
|
|
21
21
|
//#endregion
|
|
22
|
-
export { type BrokerConnectOptions, type BrokerEndpointIdentity, type BrokerEndpointIdentityOptions, type CreateClientOptions, type CreateTrayOptions, type OpenTrayClient, type OpenTrayTransport, PROTOCOL_VERSION, type SpaceHandle, type SurfaceHandle, type TrayHandle, createBrokerEndpointIdentity, createClient, createInitFrame, createSpace, createSpaceHandle, createSurface, createSurfaceHandle, createTray, createTrayHandle, formatBrokerEndpointName, formatBrokerStateRoot, formatUnixSocketPath, formatWindowsPipeName, isSupportedProtocolVersion, resolveDefaultSpace };
|
|
22
|
+
export { type BrokerConnectOptions, type BrokerEndpointIdentity, type BrokerEndpointIdentityOptions, type CreateClientOptions, type CreateTrayOptions, type ExtensionLoadOptions, type OpenTrayClient, type OpenTrayTransport, PROTOCOL_VERSION, type SpaceHandle, type SurfaceHandle, type TrayExtension, type TrayExtensionContext, type TrayExtensionMountSpec, type TrayHandle, createBrokerEndpointIdentity, createClient, createInitFrame, createSpace, createSpaceHandle, createSurface, createSurfaceHandle, createTray, createTrayHandle, formatBrokerEndpointName, formatBrokerStateRoot, formatUnixSocketPath, formatWindowsPipeName, isSupportedProtocolVersion, resolveDefaultSpace };
|
|
23
23
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as createTrayHandle, i as createSurfaceHandle, n as createInitFrame, r as createSpaceHandle, t as createClient } from "./client-
|
|
1
|
+
import { a as createTrayHandle, i as createSurfaceHandle, n as createInitFrame, r as createSpaceHandle, t as createClient } from "./client-DzcHIH-f.mjs";
|
|
2
2
|
import { t as connectLocalBroker } from "./local-broker-CEIHPBcK.mjs";
|
|
3
3
|
import { PROTOCOL_VERSION, createBrokerEndpointIdentity, formatBrokerEndpointName, formatBrokerStateRoot, formatUnixSocketPath, formatWindowsPipeName, isSupportedProtocolVersion } from "@opentray/spec";
|
|
4
4
|
//#region src/sdk.ts
|
package/dist/node.d.mts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "opentray",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Developer-facing OpenTray SDK and CLI package.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,11 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"files": [
|
|
26
26
|
"dist",
|
|
27
|
+
"assets",
|
|
27
28
|
"README.md"
|
|
28
29
|
],
|
|
29
30
|
"sideEffects": false,
|
|
30
31
|
"dependencies": {
|
|
31
|
-
"@opentray/spec": "0.4.
|
|
32
|
+
"@opentray/spec": "0.4.1"
|
|
32
33
|
},
|
|
33
34
|
"devDependencies": {
|
|
34
35
|
"tsdown": "^0.22.1",
|
|
@@ -36,12 +37,12 @@
|
|
|
36
37
|
"vitest": "^4.1.7"
|
|
37
38
|
},
|
|
38
39
|
"optionalDependencies": {
|
|
39
|
-
"@opentray/darwin-arm64": "0.5.
|
|
40
|
-
"@opentray/darwin-x64": "0.5.
|
|
41
|
-
"@opentray/linux-arm64": "0.5.
|
|
42
|
-
"@opentray/linux-x64": "0.5.
|
|
43
|
-
"@opentray/windows-arm64": "0.5.
|
|
44
|
-
"@opentray/windows-x64": "0.5.
|
|
40
|
+
"@opentray/darwin-arm64": "0.5.2",
|
|
41
|
+
"@opentray/darwin-x64": "0.5.2",
|
|
42
|
+
"@opentray/linux-arm64": "0.5.2",
|
|
43
|
+
"@opentray/linux-x64": "0.5.2",
|
|
44
|
+
"@opentray/windows-arm64": "0.5.2",
|
|
45
|
+
"@opentray/windows-x64": "0.5.2"
|
|
45
46
|
},
|
|
46
47
|
"scripts": {
|
|
47
48
|
"build": "tsdown src/index.ts src/node.ts src/cli.ts --format esm --dts",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"client-B_zxQOo5.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["import {\n PROTOCOL_VERSION,\n type ClientFrame,\n type ClientRequestFrame,\n type RequestId,\n type ServerFrame,\n type SpaceOptions,\n type SpaceRef,\n type TrayBoundsResult,\n type TrayId,\n type TrayOptions,\n} from \"@opentray/spec\";\n\nexport interface OpenTrayTransport {\n request(frame: ClientRequestFrame): Promise<ServerFrame>;\n}\n\nexport interface OpenTrayClient {\n createSpace(options: SpaceOptions): Promise<SpaceHandle>;\n resolveDefaultSpace(): Promise<SpaceHandle>;\n /** @deprecated Use `createSpace`. */\n createSurface(options: SpaceOptions): Promise<SpaceHandle>;\n}\n\nexport interface SpaceHandle {\n space: SpaceRef;\n createTray(options: TrayOptions): Promise<TrayHandle>;\n}\n\n/** @deprecated Use `SpaceHandle`. */\nexport type SurfaceHandle = SpaceHandle;\n\nexport interface TrayHandle {\n space: SpaceRef;\n trayId: TrayId;\n getBounds(): Promise<TrayBoundsResult>;\n commandExtension(ext: string, data: unknown): Promise<void>;\n destroy(): Promise<void>;\n}\n\nexport const createInitFrame = (clientVersion: string): ClientFrame => ({\n type: \"init\",\n protocolVersion: PROTOCOL_VERSION,\n clientVersion,\n});\n\nexport interface CreateClientOptions {\n requestIdPrefix?: string;\n}\n\nexport const createClient = (\n transport: OpenTrayTransport,\n options: CreateClientOptions = {},\n): OpenTrayClient => {\n const nextRequestId = createRequestIdFactory(options.requestIdPrefix ?? \"opentray\");\n\n return {\n async createSpace(spaceOptions): Promise<SpaceHandle> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"create-space\",\n requestId,\n ...spaceOptions,\n });\n const space = expectResponse(response, requestId, \"space-created\").space;\n return createSpaceHandle(transport, space, nextRequestId);\n },\n async resolveDefaultSpace(): Promise<SpaceHandle> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"resolve-default-space\",\n requestId,\n });\n const space = expectResponse(response, requestId, \"default-space\").space;\n return createSpaceHandle(transport, space, nextRequestId);\n },\n async createSurface(spaceOptions): Promise<SpaceHandle> {\n return this.createSpace(spaceOptions);\n },\n };\n};\n\nexport const createSpaceHandle = (\n transport: OpenTrayTransport,\n space: SpaceRef,\n nextRequestId: () => RequestId = createRequestIdFactory(\"opentray\"),\n): SpaceHandle => ({\n space,\n async createTray(options: TrayOptions): Promise<TrayHandle> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"create-tray\",\n requestId,\n space,\n tray: options,\n });\n const frame = expectResponse(response, requestId, \"tray-created\");\n return createTrayHandle(transport, space, frame.trayId, nextRequestId);\n },\n});\n\n/** @deprecated Use `createSpaceHandle`. */\nexport const createSurfaceHandle = createSpaceHandle;\n\nexport const createTrayHandle = (\n transport: OpenTrayTransport,\n space: SpaceRef,\n trayId: TrayId,\n nextRequestId: () => RequestId = createRequestIdFactory(\"opentray\"),\n): TrayHandle => ({\n space,\n trayId,\n async getBounds(): Promise<TrayBoundsResult> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"get-tray-bounds\",\n requestId,\n spaceId: space.spaceId,\n trayId,\n });\n return expectResponse(response, requestId, \"tray-bounds\").bounds;\n },\n async commandExtension(ext: string, data: unknown): Promise<void> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"ext-command\",\n requestId,\n spaceId: space.spaceId,\n trayId,\n ext,\n data,\n });\n expectResponse(response, requestId, \"ack\");\n },\n async destroy(): Promise<void> {\n const requestId = nextRequestId();\n const response = await transport.request({\n type: \"destroy-tray\",\n requestId,\n spaceId: space.spaceId,\n trayId,\n });\n expectResponse(response, requestId, \"ack\");\n },\n});\n\nconst createRequestIdFactory = (prefix: string): (() => RequestId) => {\n let next = 1;\n return () => {\n const requestId = `${prefix}-${next}`;\n next += 1;\n return requestId;\n };\n};\n\nconst expectResponse = <TType extends ServerFrame[\"type\"]>(\n frame: ServerFrame,\n requestId: RequestId,\n type: TType,\n): Extract<ServerFrame, { type: TType }> => {\n if (frame.type === \"error\") {\n throw new Error(`${frame.code}: ${frame.message}`);\n }\n if (frame.type !== type) {\n throw new Error(`expected ${type} for ${requestId}, received ${frame.type}`);\n }\n if (requestIdOf(frame) !== requestId) {\n throw new Error(`expected response for ${requestId}, received ${requestIdOf(frame) ?? \"none\"}`);\n }\n return frame as Extract<ServerFrame, { type: TType }>;\n};\n\nconst requestIdOf = (frame: ServerFrame): RequestId | undefined => {\n switch (frame.type) {\n case \"space-created\":\n case \"default-space\":\n case \"tray-created\":\n case \"tray-bounds\":\n case \"ack\":\n case \"daemon-health\":\n return frame.requestId;\n case \"error\":\n return frame.requestId;\n case \"ready\":\n case \"event\":\n case \"ext-event\":\n return undefined;\n }\n};\n"],"mappings":";;AAwCA,MAAa,mBAAmB,mBAAwC;CACtE,MAAM;CACN,iBAAiB;CACjB;AACF;AAMA,MAAa,gBACX,WACA,UAA+B,CAAC,MACb;CACnB,MAAM,gBAAgB,uBAAuB,QAAQ,mBAAmB,UAAU;CAElF,OAAO;EACL,MAAM,YAAY,cAAoC;GACpD,MAAM,YAAY,cAAc;GAMhC,MAAM,QAAQ,eAAe,MALN,UAAU,QAAQ;IACvC,MAAM;IACN;IACA,GAAG;GACL,CAAC,GACsC,WAAW,eAAe,EAAE;GACnE,OAAO,kBAAkB,WAAW,OAAO,aAAa;EAC1D;EACA,MAAM,sBAA4C;GAChD,MAAM,YAAY,cAAc;GAKhC,MAAM,QAAQ,eAAe,MAJN,UAAU,QAAQ;IACvC,MAAM;IACN;GACF,CAAC,GACsC,WAAW,eAAe,EAAE;GACnE,OAAO,kBAAkB,WAAW,OAAO,aAAa;EAC1D;EACA,MAAM,cAAc,cAAoC;GACtD,OAAO,KAAK,YAAY,YAAY;EACtC;CACF;AACF;AAEA,MAAa,qBACX,WACA,OACA,gBAAiC,uBAAuB,UAAU,OACjD;CACjB;CACA,MAAM,WAAW,SAA2C;EAC1D,MAAM,YAAY,cAAc;EAQhC,OAAO,iBAAiB,WAAW,OADrB,eAAe,MANN,UAAU,QAAQ;GACvC,MAAM;GACN;GACA;GACA,MAAM;EACR,CAAC,GACsC,WAAW,cACJ,EAAE,QAAQ,aAAa;CACvE;AACF;;AAGA,MAAa,sBAAsB;AAEnC,MAAa,oBACX,WACA,OACA,QACA,gBAAiC,uBAAuB,UAAU,OAClD;CAChB;CACA;CACA,MAAM,YAAuC;EAC3C,MAAM,YAAY,cAAc;EAOhC,OAAO,eAAe,MANC,UAA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