create-opentray 0.19.1 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +136 -133
- package/assets/create-opentray-logo.png +0 -0
- package/dist/bin-Dl6P1QjJ.mjs +2213 -0
- package/dist/bin-Dl6P1QjJ.mjs.map +1 -0
- package/dist/bin.d.mts +15 -2
- package/dist/bin.d.mts.map +1 -0
- package/dist/bin.mjs +1 -1
- package/dist/index.d.mts +71 -351
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +2 -1
- package/dist/shell/assets/browse.js +1 -1
- package/dist/shell/assets/index.css +1 -1
- package/dist/shell/assets/index.js +7 -7
- package/dist/shell/assets/input.js +1 -1
- package/dist/shell/assets/main.js +24 -43
- package/dist/shell/assets/terminal-pane.js +1 -1
- package/dist/shell/browse.html +3 -0
- package/dist/shell/favicon-16.png +0 -0
- package/dist/shell/favicon-32.png +0 -0
- package/dist/shell/favicon-64.png +0 -0
- package/dist/shell/index.html +3 -0
- package/dist/shell/logo.png +0 -0
- package/dist/shell/terminal.html +3 -0
- package/dist/skill/SKILL.md +156 -0
- package/dist/skill/references/cli-reference.md +77 -0
- package/dist/skill/references/how-it-works.md +49 -0
- package/dist/webui/assets/browse.js +1 -1
- package/dist/webui/assets/index.css +1 -1
- package/dist/webui/assets/index.js +7 -7
- package/dist/webui/assets/input.js +1 -1
- package/dist/webui/assets/main.js +24 -43
- package/dist/webui/assets/terminal-pane.js +1 -1
- package/dist/webui/browse.html +3 -0
- package/dist/webui/favicon-16.png +0 -0
- package/dist/webui/favicon-32.png +0 -0
- package/dist/webui/favicon-64.png +0 -0
- package/dist/webui/index.html +3 -0
- package/dist/webui/logo.png +0 -0
- package/dist/webui/terminal.html +3 -0
- package/package.json +12 -6
- package/skill/SKILL.md +156 -0
- package/skill/references/cli-reference.md +77 -0
- package/skill/references/how-it-works.md +49 -0
- package/dist/bin-B9VeXatR.mjs +0 -3830
- package/dist/bin-B9VeXatR.mjs.map +0 -1
- package/dist/bin-CeFW1wxR.d.mts +0 -15
- package/dist/bin-CeFW1wxR.d.mts.map +0 -1
- package/dist/icon-codec-BQ3cGV1n.mjs +0 -13
- package/dist/icon-codec-BQ3cGV1n.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,308 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { WizardCliOptions, main, parseWizardCli } from "./bin.mjs";
|
|
2
|
+
import { DiscoveredService, DiscoveredService as DiscoveredService$1, FamilyFormState, FaviconCandidate, LaunchVector, MaterializeContext, MaterializeContext as MaterializeContext$1, MaterializeInput, MaterializeLogEvent, MaterializeResult, MaterializeResult as MaterializeResult$1, ScaffoldAppConfig, ScaffoldOptions, ScaffoldResult, ScrapeResult, ScrapedIcon, TokenizeResult, createPortDiscovery, deriveDefaultAppId, deriveDefaultAppName, detectPackageManager, expectedDarwinBundlePath, extractFaviconCandidates, extractTitle, faviconCandidateSize, isDirectoryOccupied, isValidAppId, materialize, openMaterializedApp, parseLsofPorts, parseNetstatPorts, parsePowerShellPorts, parseShebangInterpreter, pinningHint, rankFaviconCandidates, resolveFaviconUrl, resolveLaunchVector, resolveLaunchVector as resolveLaunchVector$1, resolveOnPath, resolveOnPath as resolveOnPath$1, scrapeService, scrapeService as scrapeService$1, serviceUrl, startCommandRun, toProjectDirectoryName, tokenizeCommandLine, verifyHttpService, waitForTcpPort, writeScaffold } from "@create-opentray/core";
|
|
3
3
|
import { IncomingMessage } from "node:http";
|
|
4
4
|
|
|
5
|
-
//#region src/port-scan.d.ts
|
|
6
|
-
interface DiscoveredService {
|
|
7
|
-
readonly port: number;
|
|
8
|
-
readonly url: string;
|
|
9
|
-
readonly firstSeenAt: number;
|
|
10
|
-
title?: string;
|
|
11
|
-
}
|
|
12
|
-
type ListenersRunner = (platform: NodeJS.Platform) => Promise<ReadonlySet<number>>;
|
|
13
|
-
/** Listener snapshot with process ownership: port -> owning PIDs. */
|
|
14
|
-
type ListenerOwners = ReadonlyMap<number, ReadonlySet<number>>;
|
|
15
|
-
/** Loopback service URL for a discovered port. */
|
|
16
|
-
declare const serviceUrl: (port: number) => string;
|
|
17
|
-
declare const parseLsofPorts: (stdout: string) => ReadonlySet<number>;
|
|
18
|
-
/** Parses `netstat -ano -p tcp` output; keeps LISTENING rows. */
|
|
19
|
-
declare const parseNetstatPorts: (stdout: string) => ReadonlySet<number>;
|
|
20
|
-
declare const parsePowerShellPorts: (stdout: string) => ReadonlySet<number>;
|
|
21
|
-
/** TCP-connect probe used by the generated app and discovery verification. */
|
|
22
|
-
declare const waitForTcpPort: (port: number, timeoutMs: number, intervalMs?: number, host?: string) => Promise<boolean>;
|
|
23
|
-
/** Verify a port answers with an HTTP response (any status counts). */
|
|
24
|
-
declare const verifyHttpService: (port: number, timeoutMs?: number) => Promise<boolean>;
|
|
25
|
-
interface PortDiscoveryOptions {
|
|
26
|
-
readonly platform?: NodeJS.Platform;
|
|
27
|
-
readonly baseline: ReadonlySet<number>;
|
|
28
|
-
readonly listListeners?: ListenersRunner;
|
|
29
|
-
readonly verifyHttp?: (port: number) => Promise<boolean>;
|
|
30
|
-
/** Resolves the PIDs whose listeners count as services (preview process tree). */
|
|
31
|
-
readonly resolveOwnerPids?: () => Promise<ReadonlySet<number>>;
|
|
32
|
-
readonly listOwners?: () => Promise<ListenerOwners>;
|
|
33
|
-
readonly intervalMs?: number;
|
|
34
|
-
}
|
|
35
|
-
interface PortDiscoverySession {
|
|
36
|
-
/** Known new services, first-seen order. */
|
|
37
|
-
services(): readonly DiscoveredService[];
|
|
38
|
-
/** One polling pass; resolves to services discovered during this pass. */
|
|
39
|
-
poll(): Promise<readonly DiscoveredService[]>;
|
|
40
|
-
stop(): void;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Diff-based port discovery. Each poll re-enumerates listeners, keeps ports
|
|
44
|
-
* absent from the baseline, and adds HTTP-verified ones in first-seen order.
|
|
45
|
-
*/
|
|
46
|
-
declare const createPortDiscovery: (options: PortDiscoveryOptions) => PortDiscoverySession;
|
|
47
|
-
//#endregion
|
|
48
|
-
//#region src/command-run.d.ts
|
|
49
|
-
interface CommandRunEvent {
|
|
50
|
-
readonly type: "stdout" | "stderr" | "exit" | "spawn-error" | "pty-ready" | "pty-unavailable";
|
|
51
|
-
/** The PTY binding's output chunk, verbatim; rendering is the frontend's job. */
|
|
52
|
-
readonly chunk?: string;
|
|
53
|
-
readonly code?: number | null;
|
|
54
|
-
readonly message?: string;
|
|
55
|
-
}
|
|
56
|
-
interface CommandRunTerminalSize {
|
|
57
|
-
readonly cols: number;
|
|
58
|
-
readonly rows: number;
|
|
59
|
-
}
|
|
60
|
-
interface CommandRunOptions {
|
|
61
|
-
readonly tokens: readonly string[];
|
|
62
|
-
readonly cwd?: string;
|
|
63
|
-
readonly env?: NodeJS.ProcessEnv;
|
|
64
|
-
readonly ringLimit?: number;
|
|
65
|
-
/** Attach through a PTY when available; defaults to true. */
|
|
66
|
-
readonly pty?: boolean;
|
|
67
|
-
readonly terminalSize?: CommandRunTerminalSize;
|
|
68
|
-
readonly onEvent: (event: CommandRunEvent) => void;
|
|
69
|
-
}
|
|
70
|
-
interface CommandRun {
|
|
71
|
-
readonly pid: number | undefined;
|
|
72
|
-
readonly pty: boolean;
|
|
73
|
-
readonly exited: Promise<{
|
|
74
|
-
code: number | null;
|
|
75
|
-
spawnError?: string;
|
|
76
|
-
}>;
|
|
77
|
-
readonly output: readonly string[];
|
|
78
|
-
/** Write terminal input bytes to the command's stdin (PTY mode only). */
|
|
79
|
-
write(data: string): void;
|
|
80
|
-
/** Resize the pseudo-terminal (PTY mode only). */
|
|
81
|
-
resize(size: CommandRunTerminalSize): void;
|
|
82
|
-
kill(): Promise<void>;
|
|
83
|
-
}
|
|
84
|
-
declare const startCommandRun: (options: CommandRunOptions) => Promise<CommandRun>;
|
|
85
|
-
//#endregion
|
|
86
|
-
//#region src/scrape.d.ts
|
|
87
|
-
/** Variant tag: the original art, or a solid-color silhouette derived from it. */
|
|
88
|
-
type IconVariant = "original" | "solid-black" | "solid-white";
|
|
89
|
-
/** One scraped icon candidate, ranked and deduplicated. */
|
|
90
|
-
interface ScrapedIcon {
|
|
91
|
-
/** Index within the candidate list (stable for /api/icon-data/:port/:index). */
|
|
92
|
-
readonly index: number;
|
|
93
|
-
/** Absolute URL the bytes came from (variants inherit their source URL). */
|
|
94
|
-
readonly url: string;
|
|
95
|
-
/** Absolute temp file holding the icon bytes. */
|
|
96
|
-
readonly path: string;
|
|
97
|
-
/** True pixel clarity (largest dimension; SVG uses intrinsic or 512). */
|
|
98
|
-
readonly width: number;
|
|
99
|
-
readonly height: number;
|
|
100
|
-
/** png | svg | jpeg | webp | gif | ico (ico payloads are extracted to png). */
|
|
101
|
-
readonly format: string;
|
|
102
|
-
/** Which art this entry carries (originals feed the app-icon picker; the
|
|
103
|
-
* advanced tray picker also shows solid variants). */
|
|
104
|
-
readonly variant: IconVariant;
|
|
105
|
-
/** Index of the original candidate a variant was derived from. */
|
|
106
|
-
readonly variantOf?: number;
|
|
107
|
-
}
|
|
108
|
-
interface ScrapeResult {
|
|
109
|
-
readonly ok: boolean;
|
|
110
|
-
readonly title: string | undefined;
|
|
111
|
-
/** Absolute temp file holding the chosen (clearest) favicon bytes, when found. */
|
|
112
|
-
readonly iconPath: string | undefined;
|
|
113
|
-
readonly iconUrl?: string;
|
|
114
|
-
/** All viable candidates ranked by clarity, near-duplicates removed. */
|
|
115
|
-
readonly icons: readonly ScrapedIcon[];
|
|
116
|
-
}
|
|
117
|
-
interface FaviconCandidate {
|
|
118
|
-
readonly href: string;
|
|
119
|
-
readonly rel: string;
|
|
120
|
-
readonly sizes?: string;
|
|
121
|
-
}
|
|
122
|
-
/** Extract `<title>` text from HTML. */
|
|
123
|
-
declare const extractTitle: (html: string) => string | undefined;
|
|
124
|
-
/** Extract `<link rel=... href=...>` favicon candidates from HTML head. */
|
|
125
|
-
declare const extractFaviconCandidates: (html: string) => readonly FaviconCandidate[];
|
|
126
|
-
/** Largest dimension of a `sizes` attribute value such as `32x32` or `any`. */
|
|
127
|
-
declare const faviconCandidateSize: (candidate: FaviconCandidate) => number;
|
|
128
|
-
/** Resolve a favicon href against the service origin. */
|
|
129
|
-
declare const resolveFaviconUrl: (href: string, origin: string) => string | undefined;
|
|
130
|
-
/** Order candidates: declared-size icons descending, then apple-touch-icon, then others. */
|
|
131
|
-
declare const rankFaviconCandidates: (candidates: readonly FaviconCandidate[]) => readonly FaviconCandidate[];
|
|
132
|
-
interface ScrapePage {
|
|
133
|
-
readonly ok: boolean;
|
|
134
|
-
readonly status: number;
|
|
135
|
-
readonly body: string;
|
|
136
|
-
readonly headers: Record<string, string>;
|
|
137
|
-
}
|
|
138
|
-
interface ScrapeBytes {
|
|
139
|
-
readonly ok: boolean;
|
|
140
|
-
readonly status: number;
|
|
141
|
-
readonly bytes: Buffer;
|
|
142
|
-
readonly contentType: string;
|
|
143
|
-
}
|
|
144
|
-
interface ScrapeFetch {
|
|
145
|
-
page(url: string, timeoutMs?: number): Promise<ScrapePage>;
|
|
146
|
-
bytes(url: string, timeoutMs?: number): Promise<ScrapeBytes>;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Scrape title and ALL icon candidates from a service port. Never throws:
|
|
150
|
-
* failures return `ok: false` with whatever partial identity was found.
|
|
151
|
-
*/
|
|
152
|
-
declare const scrapeService: (port: number, options?: {
|
|
153
|
-
fetch?: ScrapeFetch;
|
|
154
|
-
tempDir?: string;
|
|
155
|
-
}) => Promise<ScrapeResult>;
|
|
156
|
-
//#endregion
|
|
157
|
-
//#region src/icon-compose.d.ts
|
|
158
|
-
type IconBackground = "black" | "white" | "transparent";
|
|
159
|
-
//#endregion
|
|
160
|
-
//#region src/launch-vector.d.ts
|
|
161
|
-
interface LaunchVector {
|
|
162
|
-
readonly command: string;
|
|
163
|
-
readonly args: readonly string[];
|
|
164
|
-
readonly cwd: string;
|
|
165
|
-
/** Optional explicit env overlay merged over the runtime environment. */
|
|
166
|
-
readonly env?: Readonly<Record<string, string>>;
|
|
167
|
-
}
|
|
168
|
-
interface ResolveLaunchVectorOptions {
|
|
169
|
-
readonly tokens: readonly string[];
|
|
170
|
-
readonly cwd: string;
|
|
171
|
-
readonly platform?: NodeJS.Platform;
|
|
172
|
-
readonly pathEnv?: string;
|
|
173
|
-
readonly accessFile?: (path: string) => Promise<void>;
|
|
174
|
-
readonly firstLine?: (path: string) => Promise<string | undefined>;
|
|
175
|
-
}
|
|
176
|
-
/** Resolve a bare command name against PATH; returns undefined when absent. */
|
|
177
|
-
declare const resolveOnPath: (command: string, options: Pick<ResolveLaunchVectorOptions, "platform" | "pathEnv" | "accessFile">) => Promise<string | undefined>;
|
|
178
|
-
/** Read a `#!/usr/bin/env <interpreter>` shebang; undefined for other files. */
|
|
179
|
-
declare const parseShebangInterpreter: (firstLine: string | undefined) => {
|
|
180
|
-
interpreter: string;
|
|
181
|
-
args: readonly string[];
|
|
182
|
-
} | undefined;
|
|
183
|
-
/**
|
|
184
|
-
* Resolve the user's command tokens to a PATH-independent vector:
|
|
185
|
-
* - absolute-ize bare executables through PATH lookup;
|
|
186
|
-
* - resolve relative script paths against cwd;
|
|
187
|
-
* - when the executable is an `env <interpreter>` shebang script, run the
|
|
188
|
-
* interpreter directly with the script as its first argument.
|
|
189
|
-
* The persisted descriptor never includes an environment map.
|
|
190
|
-
*/
|
|
191
|
-
declare const resolveLaunchVector: (options: ResolveLaunchVectorOptions) => Promise<LaunchVector>;
|
|
192
|
-
//#endregion
|
|
193
|
-
//#region src/scaffold.d.ts
|
|
194
|
-
interface ScaffoldAppConfig {
|
|
195
|
-
readonly schemaVersion: 1;
|
|
196
|
-
readonly appId: string;
|
|
197
|
-
readonly appName: string;
|
|
198
|
-
readonly command: LaunchVector;
|
|
199
|
-
readonly service: {
|
|
200
|
-
readonly port: number;
|
|
201
|
-
};
|
|
202
|
-
readonly window: {
|
|
203
|
-
readonly width: number;
|
|
204
|
-
readonly height: number;
|
|
205
|
-
};
|
|
206
|
-
/** Tray icon asset (written by materialize); omitted → text-only tray. */
|
|
207
|
-
readonly trayIcon?: {
|
|
208
|
-
readonly path: string;
|
|
209
|
-
readonly template: boolean;
|
|
210
|
-
};
|
|
211
|
-
/** Generated-app shell (startup terminal / address-bar tabs). */
|
|
212
|
-
readonly shell?: {
|
|
213
|
-
readonly showTerminal: boolean;
|
|
214
|
-
readonly showAddressBar: boolean;
|
|
215
|
-
};
|
|
216
|
-
}
|
|
217
|
-
interface ScaffoldOptions {
|
|
218
|
-
readonly config: ScaffoldAppConfig;
|
|
219
|
-
readonly targetDir: string;
|
|
220
|
-
/** opentray/@opentray/ext-webview version range written into package.json. */
|
|
221
|
-
readonly dependencyRange: string;
|
|
222
|
-
/** Whether install will be skipped; only affects README guidance text. */
|
|
223
|
-
readonly skipInstall?: boolean;
|
|
224
|
-
/** Directory holding the prebuilt shell UI (copied to app-shell/ when the
|
|
225
|
-
* shell is enabled). */
|
|
226
|
-
readonly shellAssetsDir?: string;
|
|
227
|
-
}
|
|
228
|
-
interface ScaffoldResult {
|
|
229
|
-
readonly projectDir: string;
|
|
230
|
-
readonly entryPath: string;
|
|
231
|
-
readonly configPath: string;
|
|
232
|
-
readonly appIconDir: string;
|
|
233
|
-
readonly writtenFiles: readonly string[];
|
|
234
|
-
}
|
|
235
|
-
declare const writeScaffold: (options: ScaffoldOptions) => Promise<ScaffoldResult>;
|
|
236
|
-
//#endregion
|
|
237
|
-
//#region src/materialize.d.ts
|
|
238
|
-
type MaterializeLogEvent = {
|
|
239
|
-
readonly type: "step";
|
|
240
|
-
readonly step: string;
|
|
241
|
-
readonly message: string;
|
|
242
|
-
} | {
|
|
243
|
-
readonly type: "log";
|
|
244
|
-
readonly message: string;
|
|
245
|
-
};
|
|
246
|
-
interface MaterializeInput {
|
|
247
|
-
readonly config: ScaffoldAppConfig;
|
|
248
|
-
readonly targetDir: string;
|
|
249
|
-
readonly dependencyRange: string;
|
|
250
|
-
readonly iconSourcePath: string | undefined;
|
|
251
|
-
/** True when the tray source is a solid silhouette (darwin template). */
|
|
252
|
-
readonly trayIconIsSolid?: boolean;
|
|
253
|
-
/** Icon composition (owner round-12): background + foreground scale. */
|
|
254
|
-
readonly iconBackground?: IconBackground;
|
|
255
|
-
readonly iconScale?: number;
|
|
256
|
-
/** Tray icon source; defaults to the app icon source when omitted. */
|
|
257
|
-
readonly trayIconSourcePath?: string;
|
|
258
|
-
/** Generated-app shell options (startup terminal / address bar). */
|
|
259
|
-
readonly shell?: {
|
|
260
|
-
showTerminal: boolean;
|
|
261
|
-
showAddressBar: boolean;
|
|
262
|
-
};
|
|
263
|
-
readonly packageManager: "npm" | "pnpm" | "bun";
|
|
264
|
-
readonly skipInstall: boolean;
|
|
265
|
-
readonly force: boolean;
|
|
266
|
-
}
|
|
267
|
-
interface MaterializeResult {
|
|
268
|
-
readonly scaffold: ScaffoldResult;
|
|
269
|
-
readonly projectDir: string;
|
|
270
|
-
readonly bundlePath: string | undefined;
|
|
271
|
-
/** Absent under --skip-install (no node_modules → no first launch). */
|
|
272
|
-
readonly firstLaunch?: {
|
|
273
|
-
readonly pid: number;
|
|
274
|
-
};
|
|
275
|
-
}
|
|
276
|
-
interface MaterializeContext {
|
|
277
|
-
readonly log: (event: MaterializeLogEvent) => void;
|
|
278
|
-
readonly generateIcon?: typeof generateOpenTrayAppIcon;
|
|
279
|
-
readonly runInstall?: (options: RunInstallOptions) => Promise<void>;
|
|
280
|
-
readonly firstLaunchEntry?: (projectDir: string) => Promise<FirstLaunchHandle> | FirstLaunchHandle;
|
|
281
|
-
readonly platform?: NodeJS.Platform;
|
|
282
|
-
readonly waitMs?: (ms: number) => Promise<void>;
|
|
283
|
-
readonly bundleTimeoutMs?: number;
|
|
284
|
-
}
|
|
285
|
-
interface RunInstallOptions {
|
|
286
|
-
readonly projectDir: string;
|
|
287
|
-
readonly packageManager: "npm" | "pnpm" | "bun";
|
|
288
|
-
readonly log: (message: string) => void;
|
|
289
|
-
}
|
|
290
|
-
interface FirstLaunchHandle {
|
|
291
|
-
readonly pid: number;
|
|
292
|
-
/** Resolves when the entry prints its ready marker; rejects on early exit. */
|
|
293
|
-
readonly ready: Promise<void>;
|
|
294
|
-
}
|
|
295
|
-
/** True when the directory exists and contains anything beyond ignorable files. */
|
|
296
|
-
declare const isDirectoryOccupied: (dir: string) => Promise<boolean>;
|
|
297
|
-
/** Detect package manager from lockfiles then npm_config_user_agent. */
|
|
298
|
-
declare const detectPackageManager: (files: readonly string[], userAgent: string | undefined) => "npm" | "pnpm" | "bun";
|
|
299
|
-
/** Expected stable Darwin bundle path for the generated project's identity. */
|
|
300
|
-
declare const expectedDarwinBundlePath: (config: {
|
|
301
|
-
appName: string;
|
|
302
|
-
appId: string;
|
|
303
|
-
}) => string;
|
|
304
|
-
declare const materialize: (input: MaterializeInput, context: MaterializeContext) => Promise<MaterializeResult>;
|
|
305
|
-
//#endregion
|
|
306
5
|
//#region src/wizard.d.ts
|
|
307
6
|
interface WizardEnvEntry {
|
|
308
7
|
readonly key: string;
|
|
@@ -330,6 +29,13 @@ interface WizardCommandOptions {
|
|
|
330
29
|
readonly cwd: string;
|
|
331
30
|
readonly env: readonly WizardEnvEntry[];
|
|
332
31
|
readonly argsMode: "string" | "array";
|
|
32
|
+
/**
|
|
33
|
+
* 系列作者状态(plan.md D11 / Codex B1):显式投影是系列/appId 推导的
|
|
34
|
+
* 服务端权威(Rust 的 crate/binary 无法从命令串恢复);null = 按命令串派生。
|
|
35
|
+
* 命令串始终是执行/持久化向量。env 预设(npm_config_yes 等)不再有隐形
|
|
36
|
+
* 注入开关——env 行是唯一可信源(R10 用户拍板)。
|
|
37
|
+
*/
|
|
38
|
+
readonly family: FamilyFormState | null;
|
|
333
39
|
}
|
|
334
40
|
type WizardState = "idle" | "running" | "discovered" | "failed" | "frozen" | "materializing" | "success";
|
|
335
41
|
interface WizardFormValues {
|
|
@@ -348,6 +54,10 @@ interface WizardFormValues {
|
|
|
348
54
|
readonly showStartupTerminal: boolean;
|
|
349
55
|
/** Advanced: address-bar service tabs in the generated app (default false). */
|
|
350
56
|
readonly showAddressBar: boolean;
|
|
57
|
+
/** Advanced v1 sampling intent: false keeps pixel-art edges (default true). */
|
|
58
|
+
readonly imageSmoothingEnabled: boolean;
|
|
59
|
+
/** Advanced v1 developer mode: only WebView DevTools admission (default false). */
|
|
60
|
+
readonly developerMode: boolean;
|
|
351
61
|
}
|
|
352
62
|
/** Placeholder suggestions shown in the form; empty fields resolve to these. */
|
|
353
63
|
interface WizardFormDefaults {
|
|
@@ -387,7 +97,7 @@ type WizardEvent = {
|
|
|
387
97
|
readonly defaultCwd: string;
|
|
388
98
|
} | {
|
|
389
99
|
readonly type: "services";
|
|
390
|
-
readonly services: readonly DiscoveredService[];
|
|
100
|
+
readonly services: readonly DiscoveredService$1[];
|
|
391
101
|
readonly selectedPort: number | undefined;
|
|
392
102
|
} | {
|
|
393
103
|
readonly type: "scrape";
|
|
@@ -415,6 +125,20 @@ type WizardEvent = {
|
|
|
415
125
|
readonly projectDir: string;
|
|
416
126
|
readonly bundlePath?: string;
|
|
417
127
|
readonly pinHint: string;
|
|
128
|
+
} /** Authoritative whole-session state; sent to every NEW SSE client first. */ | {
|
|
129
|
+
readonly type: "snapshot";
|
|
130
|
+
readonly state: WizardState;
|
|
131
|
+
readonly runAlive: boolean;
|
|
132
|
+
readonly command: string;
|
|
133
|
+
readonly commandOptions: WizardCommandOptions;
|
|
134
|
+
readonly form: WizardFormValues;
|
|
135
|
+
readonly defaults: WizardFormDefaults;
|
|
136
|
+
readonly targetDirExists: boolean;
|
|
137
|
+
readonly services: readonly DiscoveredService$1[];
|
|
138
|
+
readonly selectedPort?: number | undefined;
|
|
139
|
+
readonly iconCandidates: readonly ScrapedIcon[];
|
|
140
|
+
readonly iconsPort?: number | undefined;
|
|
141
|
+
readonly interactive: boolean;
|
|
418
142
|
};
|
|
419
143
|
interface WizardOptions {
|
|
420
144
|
readonly cwd: string;
|
|
@@ -435,18 +159,20 @@ interface WizardOptions {
|
|
|
435
159
|
readonly listListeners?: () => Promise<ReadonlySet<number>>;
|
|
436
160
|
readonly verifyHttp?: (port: number) => Promise<boolean>;
|
|
437
161
|
/** Test/embedding seam for listener ownership. */
|
|
438
|
-
readonly listPortOwners?: () => Promise<ListenerOwners>;
|
|
439
|
-
readonly scrape?: typeof scrapeService;
|
|
440
|
-
readonly resolveVector?: typeof resolveLaunchVector;
|
|
162
|
+
readonly listPortOwners?: () => Promise<import("@create-opentray/core").ListenerOwners>;
|
|
163
|
+
readonly scrape?: typeof scrapeService$1;
|
|
164
|
+
readonly resolveVector?: typeof resolveLaunchVector$1;
|
|
165
|
+
/** Test/embedding seam for PATH resolution of the cargo-install guard. */
|
|
166
|
+
readonly resolveOnPath?: typeof resolveOnPath$1;
|
|
441
167
|
/** Test/embedding seam for the materialize pipeline. */
|
|
442
|
-
readonly materializeContext?: Partial<MaterializeContext>;
|
|
168
|
+
readonly materializeContext?: Partial<MaterializeContext$1>;
|
|
443
169
|
readonly platform?: NodeJS.Platform;
|
|
444
170
|
readonly pollIntervalMs?: number;
|
|
445
171
|
readonly scrapeIntervalMs?: number;
|
|
446
172
|
}
|
|
447
173
|
interface WizardSession {
|
|
448
174
|
readonly state: WizardState;
|
|
449
|
-
readonly services: readonly DiscoveredService[];
|
|
175
|
+
readonly services: readonly DiscoveredService$1[];
|
|
450
176
|
readonly selectedPort: number | undefined;
|
|
451
177
|
/** True while the preview process is alive (Run button shows Interrupt). */
|
|
452
178
|
readonly runAlive: boolean;
|
|
@@ -477,7 +203,9 @@ interface WizardSession {
|
|
|
477
203
|
/** Auto-suggestion for the foreground (background + reason). */
|
|
478
204
|
analyzeIconForeground(foregroundPath: string): Promise<WizardIconAnalysis>;
|
|
479
205
|
readonly form: WizardFormValues;
|
|
480
|
-
readonly result: MaterializeResult | undefined;
|
|
206
|
+
readonly result: MaterializeResult$1 | undefined;
|
|
207
|
+
/** Whole-session state for reconnecting clients (page refresh recovery). */
|
|
208
|
+
snapshot(): WizardEvent;
|
|
481
209
|
/** String form is tokenized; array form is taken as argv verbatim (array
|
|
482
210
|
* input mode — no string splitting is ever applied to it). */
|
|
483
211
|
submitCommand(command: string | readonly string[]): Promise<void>;
|
|
@@ -493,9 +221,42 @@ interface WizardSession {
|
|
|
493
221
|
rows: number;
|
|
494
222
|
}): void;
|
|
495
223
|
confirm(): void;
|
|
224
|
+
/** Abort a frozen confirmation and return to the editable pre-freeze state. */
|
|
225
|
+
cancel(): void;
|
|
226
|
+
/**
|
|
227
|
+
* Share the FROZEN parameters (wizard-share-and-list-scan D3): build an
|
|
228
|
+
* export artifact from the confirmation state WITHOUT running the command
|
|
229
|
+
* or materializing anything. Works pre-create. Scraped web icons keep
|
|
230
|
+
* their http source URL plus the icon-generation flags by default;
|
|
231
|
+
* `inlineIcon` opts into embedding the bytes instead.
|
|
232
|
+
*/
|
|
233
|
+
exportFrozen(options: {
|
|
234
|
+
readonly format: "command" | "sh" | "ps1";
|
|
235
|
+
readonly acknowledgeEnv?: boolean;
|
|
236
|
+
readonly forceCopy?: boolean; /** true=内嵌字节;false=按引用分享(URL/本地路径);缺省=按来源默认。 */
|
|
237
|
+
readonly inlineIcon?: boolean;
|
|
238
|
+
}): Promise<WizardExportResult>;
|
|
496
239
|
create(): Promise<void>;
|
|
497
240
|
stop(): Promise<void>;
|
|
498
241
|
}
|
|
242
|
+
type WizardExportResult = {
|
|
243
|
+
readonly ok: true;
|
|
244
|
+
readonly kind: "command";
|
|
245
|
+
readonly command: string;
|
|
246
|
+
} | {
|
|
247
|
+
readonly ok: true;
|
|
248
|
+
readonly kind: "script";
|
|
249
|
+
readonly filename: string;
|
|
250
|
+
readonly content: string; /** 核心调用行(不含注释/脚手架),复制命令用。 */
|
|
251
|
+
readonly commandLine: string;
|
|
252
|
+
readonly requiresEnvAcknowledgement: boolean; /** How the app icon actually traveled in this artifact. */
|
|
253
|
+
readonly iconSharedAs: "url" | "embedded" | "local" | "none"; /** What the icon source CAN be shared as: url / local path / none. */
|
|
254
|
+
readonly iconReference: "url" | "local" | "none";
|
|
255
|
+
} | {
|
|
256
|
+
readonly ok: false;
|
|
257
|
+
readonly code: "state_error" | "resolve_failed" | "env_ack_required" | "export_unsafe";
|
|
258
|
+
readonly message: string;
|
|
259
|
+
};
|
|
499
260
|
declare const createWizardSession: (options: WizardOptions) => WizardSession;
|
|
500
261
|
//#endregion
|
|
501
262
|
//#region src/server.d.ts
|
|
@@ -512,46 +273,5 @@ declare const createWizardServer: (createSession: (emit: (event: WizardEvent) =>
|
|
|
512
273
|
declare const isAuthorized: (request: IncomingMessage, url: URL, token: string) => boolean;
|
|
513
274
|
declare const isLoopbackHost: (request: IncomingMessage) => boolean;
|
|
514
275
|
//#endregion
|
|
515
|
-
//#region src/tokenize.d.ts
|
|
516
|
-
interface TokenizeResult {
|
|
517
|
-
readonly ok: boolean;
|
|
518
|
-
readonly tokens: readonly string[];
|
|
519
|
-
readonly error: string | undefined;
|
|
520
|
-
}
|
|
521
|
-
/**
|
|
522
|
-
* Shell-style tokenizer for the wizard command input. Supports single quotes,
|
|
523
|
-
* double quotes, and backslash escapes outside quotes. It never executes
|
|
524
|
-
* anything; it only produces the argv that will be spawned.
|
|
525
|
-
*/
|
|
526
|
-
declare const tokenizeCommandLine: (input: string) => TokenizeResult;
|
|
527
|
-
//#endregion
|
|
528
|
-
//#region src/app-id.d.ts
|
|
529
|
-
/**
|
|
530
|
-
* Default appId derivation. `npx somecommand start --xx` keeps the pre-option
|
|
531
|
-
* tokens `["npx", "somecommand", "start"]`, reverses them, and dot-joins:
|
|
532
|
-
* `start.somecommand.npx`.
|
|
533
|
-
*/
|
|
534
|
-
declare const deriveDefaultAppId: (tokens: readonly string[]) => string;
|
|
535
|
-
/** Human display name from the appId derivation: `Somecommand Start`. */
|
|
536
|
-
declare const deriveDefaultAppName: (tokens: readonly string[]) => string;
|
|
537
|
-
/** Directory-safe project name from an appId (mirrors packaging normalizeAppId semantics). */
|
|
538
|
-
declare const toProjectDirectoryName: (appId: string) => string;
|
|
539
|
-
/** True when the appId has the shape consumers expect for stable identity. */
|
|
540
|
-
declare const isValidAppId: (appId: string) => boolean;
|
|
541
|
-
//#endregion
|
|
542
|
-
//#region src/open-app.d.ts
|
|
543
|
-
interface OpenAppInput {
|
|
544
|
-
readonly projectDir: string;
|
|
545
|
-
readonly bundlePath: string | undefined;
|
|
546
|
-
readonly platform?: NodeJS.Platform | undefined;
|
|
547
|
-
}
|
|
548
|
-
interface OpenAppResult {
|
|
549
|
-
readonly ok: boolean;
|
|
550
|
-
readonly detail: string;
|
|
551
|
-
}
|
|
552
|
-
declare const openMaterializedApp: (input: OpenAppInput) => Promise<OpenAppResult>;
|
|
553
|
-
/** Platform-truthful pinning hint; makes no Windows persistence claim. */
|
|
554
|
-
declare const pinningHint: (platform?: NodeJS.Platform) => string;
|
|
555
|
-
//#endregion
|
|
556
276
|
export { type DiscoveredService, type FaviconCandidate, type LaunchVector, type MaterializeContext, type MaterializeInput, type MaterializeLogEvent, type MaterializeResult, type ScaffoldAppConfig, type ScaffoldOptions, type ScaffoldResult, type ScrapeResult, type TokenizeResult, type WizardCliOptions, type WizardEvent, type WizardFormValues, type WizardServerHandle, type WizardSession, type WizardState, createPortDiscovery, createWizardServer, createWizardSession, deriveDefaultAppId, deriveDefaultAppName, detectPackageManager, expectedDarwinBundlePath, extractFaviconCandidates, extractTitle, faviconCandidateSize, isAuthorized, isDirectoryOccupied, isLoopbackHost, isValidAppId, materialize, openMaterializedApp, parseLsofPorts, parseNetstatPorts, parsePowerShellPorts, parseShebangInterpreter, parseWizardCli, pinningHint, rankFaviconCandidates, resolveFaviconUrl, resolveLaunchVector, resolveOnPath, main as runWizardMain, scrapeService, serviceUrl, toProjectDirectoryName, tokenizeCommandLine, verifyHttpService, waitForTcpPort, writeScaffold };
|
|
557
277
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.m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,GAAkB,OAAwB,EAAf,eAAe"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as isAuthorized, i as createWizardServer, o as isLoopbackHost, r as parseWizardCli, s as createWizardSession, t as main } from "./bin-Dl6P1QjJ.mjs";
|
|
2
|
+
import { createPortDiscovery, deriveDefaultAppId, deriveDefaultAppName, detectPackageManager, expectedDarwinBundlePath, extractFaviconCandidates, extractTitle, faviconCandidateSize, isDirectoryOccupied, isValidAppId, materialize, openMaterializedApp, parseLsofPorts, parseNetstatPorts, parsePowerShellPorts, parseShebangInterpreter, pinningHint, rankFaviconCandidates, resolveFaviconUrl, resolveLaunchVector, resolveOnPath, scrapeService, serviceUrl, toProjectDirectoryName, tokenizeCommandLine, verifyHttpService, waitForTcpPort, writeScaffold } from "@create-opentray/core";
|
|
2
3
|
export { createPortDiscovery, createWizardServer, createWizardSession, deriveDefaultAppId, deriveDefaultAppName, detectPackageManager, expectedDarwinBundlePath, extractFaviconCandidates, extractTitle, faviconCandidateSize, isAuthorized, isDirectoryOccupied, isLoopbackHost, isValidAppId, materialize, openMaterializedApp, parseLsofPorts, parseNetstatPorts, parsePowerShellPorts, parseShebangInterpreter, parseWizardCli, pinningHint, rankFaviconCandidates, resolveFaviconUrl, resolveLaunchVector, resolveOnPath, main as runWizardMain, scrapeService, serviceUrl, toProjectDirectoryName, tokenizeCommandLine, verifyHttpService, waitForTcpPort, writeScaffold };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as a,j as r,R as
|
|
1
|
+
import{r as a,j as r,R as C,a as S}from"./index.js";import{B as m,A as N,a as U,R as z,G as B,I}from"./input.js";const A=()=>typeof window<"u"&&"navigation"in window?window.navigation:void 0,v=s=>{const c=s.trim();if(c.length!==0)try{return new URL(/^https?:\/\//iu.test(c)?c:`http://${c}`).href}catch{return}},T=s=>`${location.pathname}?url=${encodeURIComponent(s)}`,D=()=>{const s=new URLSearchParams(location.search).get("url");return v(s??"")??"about:blank"};function P(){const s=a.useRef(D()),[c,x]=a.useState(s.current),[g,b]=a.useState(s.current),o=a.useRef([s.current]),t=a.useRef(0),i=a.useRef(A()),h=a.useRef(null),[$,y]=a.useState(0),d=a.useCallback(e=>{b(e),x(e)},[]);a.useEffect(()=>{const e=i.current;if(e===void 0)return;const n=u=>{!u.canIntercept||u.hashChange||u.intercept({handler:()=>{const p=new URLSearchParams(new URL(u.destination.url).search).get("url");if(p===null)return;const w=v(p);w!==void 0&&d(w)}})},l=()=>y(u=>u+1);return e.addEventListener("navigate",n),e.addEventListener("currententrychange",l),()=>{e.removeEventListener("navigate",n),e.removeEventListener("currententrychange",l)}},[]);const R=e=>{const n=i.current;if(n!==void 0)try{n.navigate(T(e));return}catch{}o.current=[...o.current.slice(0,t.current+1),e],t.current=o.current.length-1,d(e)},j=()=>{const e=i.current;if(e!==void 0&&e.currentEntry!==null&&e.currentEntry.index>0){const n=e.entries()[e.currentEntry.index-1];if(n!==void 0)try{e.traverseTo(n.key);return}catch{}}t.current>0&&(t.current-=1,d(o.current[t.current]))},E=()=>{const e=i.current;if(e!==void 0&&e.currentEntry!==null){const l=e.entries()[e.currentEntry.index+1];if(l!==void 0)try{e.traverseTo(l.key);return}catch{}}t.current<o.current.length-1&&(t.current+=1,d(o.current[t.current]))},f=i.current?.currentEntry??null,k=f!==null?f.index>0:t.current>0,L=f!==null?f.index<(i.current?.entries().length??1)-1:t.current<o.current.length-1;return r.jsxs("div",{className:"flex h-screen flex-col overflow-hidden",children:[r.jsxs("div",{className:"flex h-11 shrink-0 items-center gap-2 border-b border-border bg-card px-3",children:[r.jsx(m,{variant:"ghost",size:"icon-sm",disabled:!k,onClick:j,"aria-label":"后退",children:r.jsx(N,{})}),r.jsx(m,{variant:"ghost",size:"icon-sm",disabled:!L,onClick:E,"aria-label":"前进",children:r.jsx(U,{})}),r.jsx(m,{variant:"ghost",size:"icon-sm",onClick:()=>{h.current!==null&&(h.current.src=g)},"aria-label":"重新加载",children:r.jsx(z,{})}),r.jsx(B,{className:"size-4 shrink-0 text-muted-foreground"}),r.jsx(I,{className:"h-7 font-mono text-xs",value:c,placeholder:"输入 URL 跳转",onChange:e=>x(e.target.value),onKeyDown:e=>{if(e.key!=="Enter")return;const n=v(c);n!==void 0&&R(n)}})]}),r.jsx("iframe",{ref:h,title:"service",src:g,className:"min-h-0 flex-1 border-0 bg-white",sandbox:"allow-same-origin allow-scripts allow-forms"})]})}C.createRoot(document.getElementById("root")).render(r.jsx(S.StrictMode,{children:r.jsx(P,{})}));
|