create-opentray 0.19.0 → 0.20.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-sZB5nWq0.mjs +2142 -0
- package/dist/bin-sZB5nWq0.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 +62 -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 +21 -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 +21 -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-BT_kcLuP.mjs +0 -3823
- package/dist/bin-BT_kcLuP.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, 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, 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;
|
|
@@ -348,6 +47,10 @@ interface WizardFormValues {
|
|
|
348
47
|
readonly showStartupTerminal: boolean;
|
|
349
48
|
/** Advanced: address-bar service tabs in the generated app (default false). */
|
|
350
49
|
readonly showAddressBar: boolean;
|
|
50
|
+
/** Advanced v1 sampling intent: false keeps pixel-art edges (default true). */
|
|
51
|
+
readonly imageSmoothingEnabled: boolean;
|
|
52
|
+
/** Advanced v1 developer mode: only WebView DevTools admission (default false). */
|
|
53
|
+
readonly developerMode: boolean;
|
|
351
54
|
}
|
|
352
55
|
/** Placeholder suggestions shown in the form; empty fields resolve to these. */
|
|
353
56
|
interface WizardFormDefaults {
|
|
@@ -387,7 +90,7 @@ type WizardEvent = {
|
|
|
387
90
|
readonly defaultCwd: string;
|
|
388
91
|
} | {
|
|
389
92
|
readonly type: "services";
|
|
390
|
-
readonly services: readonly DiscoveredService[];
|
|
93
|
+
readonly services: readonly DiscoveredService$1[];
|
|
391
94
|
readonly selectedPort: number | undefined;
|
|
392
95
|
} | {
|
|
393
96
|
readonly type: "scrape";
|
|
@@ -415,6 +118,20 @@ type WizardEvent = {
|
|
|
415
118
|
readonly projectDir: string;
|
|
416
119
|
readonly bundlePath?: string;
|
|
417
120
|
readonly pinHint: string;
|
|
121
|
+
} /** Authoritative whole-session state; sent to every NEW SSE client first. */ | {
|
|
122
|
+
readonly type: "snapshot";
|
|
123
|
+
readonly state: WizardState;
|
|
124
|
+
readonly runAlive: boolean;
|
|
125
|
+
readonly command: string;
|
|
126
|
+
readonly commandOptions: WizardCommandOptions;
|
|
127
|
+
readonly form: WizardFormValues;
|
|
128
|
+
readonly defaults: WizardFormDefaults;
|
|
129
|
+
readonly targetDirExists: boolean;
|
|
130
|
+
readonly services: readonly DiscoveredService$1[];
|
|
131
|
+
readonly selectedPort?: number | undefined;
|
|
132
|
+
readonly iconCandidates: readonly ScrapedIcon[];
|
|
133
|
+
readonly iconsPort?: number | undefined;
|
|
134
|
+
readonly interactive: boolean;
|
|
418
135
|
};
|
|
419
136
|
interface WizardOptions {
|
|
420
137
|
readonly cwd: string;
|
|
@@ -435,18 +152,18 @@ interface WizardOptions {
|
|
|
435
152
|
readonly listListeners?: () => Promise<ReadonlySet<number>>;
|
|
436
153
|
readonly verifyHttp?: (port: number) => Promise<boolean>;
|
|
437
154
|
/** Test/embedding seam for listener ownership. */
|
|
438
|
-
readonly listPortOwners?: () => Promise<ListenerOwners>;
|
|
439
|
-
readonly scrape?: typeof scrapeService;
|
|
440
|
-
readonly resolveVector?: typeof resolveLaunchVector;
|
|
155
|
+
readonly listPortOwners?: () => Promise<import("@create-opentray/core").ListenerOwners>;
|
|
156
|
+
readonly scrape?: typeof scrapeService$1;
|
|
157
|
+
readonly resolveVector?: typeof resolveLaunchVector$1;
|
|
441
158
|
/** Test/embedding seam for the materialize pipeline. */
|
|
442
|
-
readonly materializeContext?: Partial<MaterializeContext>;
|
|
159
|
+
readonly materializeContext?: Partial<MaterializeContext$1>;
|
|
443
160
|
readonly platform?: NodeJS.Platform;
|
|
444
161
|
readonly pollIntervalMs?: number;
|
|
445
162
|
readonly scrapeIntervalMs?: number;
|
|
446
163
|
}
|
|
447
164
|
interface WizardSession {
|
|
448
165
|
readonly state: WizardState;
|
|
449
|
-
readonly services: readonly DiscoveredService[];
|
|
166
|
+
readonly services: readonly DiscoveredService$1[];
|
|
450
167
|
readonly selectedPort: number | undefined;
|
|
451
168
|
/** True while the preview process is alive (Run button shows Interrupt). */
|
|
452
169
|
readonly runAlive: boolean;
|
|
@@ -477,7 +194,9 @@ interface WizardSession {
|
|
|
477
194
|
/** Auto-suggestion for the foreground (background + reason). */
|
|
478
195
|
analyzeIconForeground(foregroundPath: string): Promise<WizardIconAnalysis>;
|
|
479
196
|
readonly form: WizardFormValues;
|
|
480
|
-
readonly result: MaterializeResult | undefined;
|
|
197
|
+
readonly result: MaterializeResult$1 | undefined;
|
|
198
|
+
/** Whole-session state for reconnecting clients (page refresh recovery). */
|
|
199
|
+
snapshot(): WizardEvent;
|
|
481
200
|
/** String form is tokenized; array form is taken as argv verbatim (array
|
|
482
201
|
* input mode — no string splitting is ever applied to it). */
|
|
483
202
|
submitCommand(command: string | readonly string[]): Promise<void>;
|
|
@@ -493,9 +212,42 @@ interface WizardSession {
|
|
|
493
212
|
rows: number;
|
|
494
213
|
}): void;
|
|
495
214
|
confirm(): void;
|
|
215
|
+
/** Abort a frozen confirmation and return to the editable pre-freeze state. */
|
|
216
|
+
cancel(): void;
|
|
217
|
+
/**
|
|
218
|
+
* Share the FROZEN parameters (wizard-share-and-list-scan D3): build an
|
|
219
|
+
* export artifact from the confirmation state WITHOUT running the command
|
|
220
|
+
* or materializing anything. Works pre-create. Scraped web icons keep
|
|
221
|
+
* their http source URL plus the icon-generation flags by default;
|
|
222
|
+
* `inlineIcon` opts into embedding the bytes instead.
|
|
223
|
+
*/
|
|
224
|
+
exportFrozen(options: {
|
|
225
|
+
readonly format: "command" | "sh" | "ps1";
|
|
226
|
+
readonly acknowledgeEnv?: boolean;
|
|
227
|
+
readonly forceCopy?: boolean; /** true=内嵌字节;false=按引用分享(URL/本地路径);缺省=按来源默认。 */
|
|
228
|
+
readonly inlineIcon?: boolean;
|
|
229
|
+
}): Promise<WizardExportResult>;
|
|
496
230
|
create(): Promise<void>;
|
|
497
231
|
stop(): Promise<void>;
|
|
498
232
|
}
|
|
233
|
+
type WizardExportResult = {
|
|
234
|
+
readonly ok: true;
|
|
235
|
+
readonly kind: "command";
|
|
236
|
+
readonly command: string;
|
|
237
|
+
} | {
|
|
238
|
+
readonly ok: true;
|
|
239
|
+
readonly kind: "script";
|
|
240
|
+
readonly filename: string;
|
|
241
|
+
readonly content: string; /** 核心调用行(不含注释/脚手架),复制命令用。 */
|
|
242
|
+
readonly commandLine: string;
|
|
243
|
+
readonly requiresEnvAcknowledgement: boolean; /** How the app icon actually traveled in this artifact. */
|
|
244
|
+
readonly iconSharedAs: "url" | "embedded" | "local" | "none"; /** What the icon source CAN be shared as: url / local path / none. */
|
|
245
|
+
readonly iconReference: "url" | "local" | "none";
|
|
246
|
+
} | {
|
|
247
|
+
readonly ok: false;
|
|
248
|
+
readonly code: "state_error" | "resolve_failed" | "env_ack_required" | "export_unsafe";
|
|
249
|
+
readonly message: string;
|
|
250
|
+
};
|
|
499
251
|
declare const createWizardSession: (options: WizardOptions) => WizardSession;
|
|
500
252
|
//#endregion
|
|
501
253
|
//#region src/server.d.ts
|
|
@@ -512,46 +264,5 @@ declare const createWizardServer: (createSession: (emit: (event: WizardEvent) =>
|
|
|
512
264
|
declare const isAuthorized: (request: IncomingMessage, url: URL, token: string) => boolean;
|
|
513
265
|
declare const isLoopbackHost: (request: IncomingMessage) => boolean;
|
|
514
266
|
//#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
267
|
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
268
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/wizard.ts","../src/server.ts"],"mappings":";;;;;UAoDiB,cAAA;EAAA,SACN,GAAA;EAAA,SACA,KAAK;AAAA;AAAA;AAKhB;AALgB,KAKJ,oBAAA;AAAA,UAIK,qBAAA;EAAA,SACN,GAAA;EAAA,SACA,aAAA;EAAA,SACA,SAAA;EAAA,SACA,UAAA,EAAY,oBAAoB;AAAA;AAAA,UAG1B,kBAAA;EAAA,SACN,SAAA;EAAA,SACA,QAAA;EAAA,SACA,SAAA,EAAW,oBAAoB;AAAA;;AANC;AAG3C;UASiB,oBAAA;;WAEN,GAAA;EAAA,SACA,GAAA,WAAc,cAAc;EAAA,SAC5B,QAAA;AAAA;AAAA,KASC,WAAA;AAAA,UASK,gBAAA;EAAA,SACN,KAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA;EAtB4B;EAAA,SAwB5B,cAAA,EAAgB,oBAAoB;EAAA,SACpC,SAAA;EAzBc;EAAA,SA2Bd,Y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8EI,aAAA;AAAA;EAAA,SAGA,EAAA;EAAA,SACA,IAAA;EAAA,SACA,OAAA;AAAA;AAAA,cAkBF,mBAAA,GAAuB,OAAA,EAAS,aAAA,KAAgB,aAy/B5D;;;UC3xCgB,kBAAA;EAAA,SACN,GAAA;EAAA,SACA,IAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA,EAAS,aAAA;EAClB,KAAA,IAAS,OAAO;AAAA;AAAA,cAKL,kBAAA,GACX,aAAA,GAAgB,IAAA,GAAO,KAAA,EAAO,WAAA,cAAyB,aAAA,EACvD,OAAA;EAAA,SAAoB,IAAA;AAAA,MACnB,OAAA,CAAQ,kBAAA;AAAA,cAqtBE,YAAA,GACX,OAAA,EAAS,eAAA,EACT,GAAA,EAAK,GAAG,EACR,KAAA;AAAA,cASW,cAAA,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-sZB5nWq0.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,{})}));
|