devframe 0.0.0 → 0.1.16

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.
Files changed (73) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +62 -0
  3. package/dist/_shared-CU6dE-VX.mjs +20 -0
  4. package/dist/adapters/build.d.mts +37 -0
  5. package/dist/adapters/build.mjs +61 -0
  6. package/dist/adapters/cli.d.mts +35 -0
  7. package/dist/adapters/cli.mjs +357 -0
  8. package/dist/adapters/embedded.d.mts +19 -0
  9. package/dist/adapters/embedded.mjs +15 -0
  10. package/dist/adapters/kit.d.mts +23 -0
  11. package/dist/adapters/kit.mjs +16 -0
  12. package/dist/adapters/mcp.d.mts +39 -0
  13. package/dist/adapters/mcp.mjs +278 -0
  14. package/dist/adapters/vite.d.mts +32 -0
  15. package/dist/adapters/vite.mjs +31 -0
  16. package/dist/client/index.d.mts +227 -0
  17. package/dist/client/index.mjs +2 -0
  18. package/dist/client-4WrEozlH.mjs +1561 -0
  19. package/dist/constants.d.mts +20 -0
  20. package/dist/constants.mjs +34 -0
  21. package/dist/context-BrePWeyd.mjs +6776 -0
  22. package/dist/define-Bb4zh-Dc.mjs +11 -0
  23. package/dist/devtool-OJ3QW0ns.d.mts +1125 -0
  24. package/dist/helpers/nuxt/index.d.mts +46 -0
  25. package/dist/helpers/nuxt/index.mjs +58 -0
  26. package/dist/helpers/nuxt/runtime/plugin.client.d.mts +8 -0
  27. package/dist/helpers/nuxt/runtime/plugin.client.mjs +12 -0
  28. package/dist/human-id-CHS0s28X.mjs +844 -0
  29. package/dist/immer-HjMAm3b6.mjs +894 -0
  30. package/dist/index-DvKDO5H8.d.mts +333 -0
  31. package/dist/index.d.mts +10 -0
  32. package/dist/index.mjs +2 -0
  33. package/dist/main-DpINGndA.mjs +601 -0
  34. package/dist/node/index.d.mts +365 -0
  35. package/dist/node/index.mjs +69 -0
  36. package/dist/open-BtOOEldu.mjs +533 -0
  37. package/dist/recipes/open-helpers.d.mts +104 -0
  38. package/dist/recipes/open-helpers.mjs +69 -0
  39. package/dist/rpc/client.d.mts +9 -0
  40. package/dist/rpc/client.mjs +13 -0
  41. package/dist/rpc/index.d.mts +2 -0
  42. package/dist/rpc/index.mjs +3 -0
  43. package/dist/rpc/server.d.mts +8 -0
  44. package/dist/rpc/server.mjs +10 -0
  45. package/dist/rpc/transports/ws-client.d.mts +2 -0
  46. package/dist/rpc/transports/ws-client.mjs +43 -0
  47. package/dist/rpc/transports/ws-server.d.mts +2 -0
  48. package/dist/rpc/transports/ws-server.mjs +58 -0
  49. package/dist/rpc-9FNa3Inb.mjs +474 -0
  50. package/dist/server-DrBxa6ZV.mjs +49 -0
  51. package/dist/src-BoIqXRc9.mjs +85 -0
  52. package/dist/static-dump-CQUC1aIW.mjs +82 -0
  53. package/dist/transports-BPUzHhI2.mjs +15 -0
  54. package/dist/types/index.d.mts +4 -0
  55. package/dist/types/index.mjs +6 -0
  56. package/dist/utils/events.d.mts +9 -0
  57. package/dist/utils/events.mjs +40 -0
  58. package/dist/utils/human-id.d.mts +10 -0
  59. package/dist/utils/human-id.mjs +3 -0
  60. package/dist/utils/nanoid.d.mts +4 -0
  61. package/dist/utils/nanoid.mjs +10 -0
  62. package/dist/utils/promise.d.mts +8 -0
  63. package/dist/utils/promise.mjs +15 -0
  64. package/dist/utils/shared-state.d.mts +2 -0
  65. package/dist/utils/shared-state.mjs +36 -0
  66. package/dist/utils/state.d.mts +49 -0
  67. package/dist/utils/state.mjs +26 -0
  68. package/dist/utils/when.d.mts +2 -0
  69. package/dist/utils/when.mjs +424 -0
  70. package/dist/when-CGLewRtm.d.mts +401 -0
  71. package/dist/ws-client-CklfxUHE.d.mts +17 -0
  72. package/dist/ws-server--IuUAaGi.d.mts +37 -0
  73. package/package.json +116 -8
@@ -0,0 +1,533 @@
1
+ import fs from "node:fs";
2
+ import { fileURLToPath } from "node:url";
3
+ import process from "node:process";
4
+ import path from "node:path";
5
+ import { promisify } from "node:util";
6
+ import os from "node:os";
7
+ import fs$1, { constants } from "node:fs/promises";
8
+ import childProcess, { execFile } from "node:child_process";
9
+ import { Buffer } from "node:buffer";
10
+ //#region ../../../node_modules/.pnpm/is-docker@3.0.0/node_modules/is-docker/index.js
11
+ let isDockerCached;
12
+ function hasDockerEnv() {
13
+ try {
14
+ fs.statSync("/.dockerenv");
15
+ return true;
16
+ } catch {
17
+ return false;
18
+ }
19
+ }
20
+ function hasDockerCGroup() {
21
+ try {
22
+ return fs.readFileSync("/proc/self/cgroup", "utf8").includes("docker");
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+ function isDocker() {
28
+ if (isDockerCached === void 0) isDockerCached = hasDockerEnv() || hasDockerCGroup();
29
+ return isDockerCached;
30
+ }
31
+ //#endregion
32
+ //#region ../../../node_modules/.pnpm/is-inside-container@1.0.0/node_modules/is-inside-container/index.js
33
+ let cachedResult;
34
+ const hasContainerEnv = () => {
35
+ try {
36
+ fs.statSync("/run/.containerenv");
37
+ return true;
38
+ } catch {
39
+ return false;
40
+ }
41
+ };
42
+ function isInsideContainer() {
43
+ if (cachedResult === void 0) cachedResult = hasContainerEnv() || isDocker();
44
+ return cachedResult;
45
+ }
46
+ //#endregion
47
+ //#region ../../../node_modules/.pnpm/is-wsl@3.1.0/node_modules/is-wsl/index.js
48
+ const isWsl = () => {
49
+ if (process.platform !== "linux") return false;
50
+ if (os.release().toLowerCase().includes("microsoft")) {
51
+ if (isInsideContainer()) return false;
52
+ return true;
53
+ }
54
+ try {
55
+ return fs.readFileSync("/proc/version", "utf8").toLowerCase().includes("microsoft") ? !isInsideContainer() : false;
56
+ } catch {
57
+ return false;
58
+ }
59
+ };
60
+ var is_wsl_default = process.env.__IS_WSL_TEST__ ? isWsl : isWsl();
61
+ //#endregion
62
+ //#region ../../../node_modules/.pnpm/powershell-utils@0.1.0/node_modules/powershell-utils/index.js
63
+ const execFile$2 = promisify(childProcess.execFile);
64
+ const powerShellPath$1 = () => `${process.env.SYSTEMROOT || process.env.windir || String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;
65
+ const executePowerShell = async (command, options = {}) => {
66
+ const { powerShellPath: psPath, ...execFileOptions } = options;
67
+ const encodedCommand = executePowerShell.encodeCommand(command);
68
+ return execFile$2(psPath ?? powerShellPath$1(), [...executePowerShell.argumentsPrefix, encodedCommand], {
69
+ encoding: "utf8",
70
+ ...execFileOptions
71
+ });
72
+ };
73
+ executePowerShell.argumentsPrefix = [
74
+ "-NoProfile",
75
+ "-NonInteractive",
76
+ "-ExecutionPolicy",
77
+ "Bypass",
78
+ "-EncodedCommand"
79
+ ];
80
+ executePowerShell.encodeCommand = (command) => Buffer.from(command, "utf16le").toString("base64");
81
+ executePowerShell.escapeArgument = (value) => `'${String(value).replaceAll("'", "''")}'`;
82
+ //#endregion
83
+ //#region ../../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/utilities.js
84
+ function parseMountPointFromConfig(content) {
85
+ for (const line of content.split("\n")) {
86
+ if (/^\s*#/.test(line)) continue;
87
+ const match = /^\s*root\s*=\s*(?<mountPoint>"[^"]*"|'[^']*'|[^#]*)/.exec(line);
88
+ if (!match) continue;
89
+ return match.groups.mountPoint.trim().replaceAll(/^["']|["']$/g, "");
90
+ }
91
+ }
92
+ //#endregion
93
+ //#region ../../../node_modules/.pnpm/wsl-utils@0.3.1/node_modules/wsl-utils/index.js
94
+ const execFile$1 = promisify(childProcess.execFile);
95
+ const wslDrivesMountPoint = (() => {
96
+ const defaultMountPoint = "/mnt/";
97
+ let mountPoint;
98
+ return async function() {
99
+ if (mountPoint) return mountPoint;
100
+ const configFilePath = "/etc/wsl.conf";
101
+ let isConfigFileExists = false;
102
+ try {
103
+ await fs$1.access(configFilePath, constants.F_OK);
104
+ isConfigFileExists = true;
105
+ } catch {}
106
+ if (!isConfigFileExists) return defaultMountPoint;
107
+ const parsedMountPoint = parseMountPointFromConfig(await fs$1.readFile(configFilePath, { encoding: "utf8" }));
108
+ if (parsedMountPoint === void 0) return defaultMountPoint;
109
+ mountPoint = parsedMountPoint;
110
+ mountPoint = mountPoint.endsWith("/") ? mountPoint : `${mountPoint}/`;
111
+ return mountPoint;
112
+ };
113
+ })();
114
+ const powerShellPathFromWsl = async () => {
115
+ return `${await wslDrivesMountPoint()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`;
116
+ };
117
+ const powerShellPath = is_wsl_default ? powerShellPathFromWsl : powerShellPath$1;
118
+ let canAccessPowerShellPromise;
119
+ const canAccessPowerShell = async () => {
120
+ canAccessPowerShellPromise ??= (async () => {
121
+ try {
122
+ const psPath = await powerShellPath();
123
+ await fs$1.access(psPath, constants.X_OK);
124
+ return true;
125
+ } catch {
126
+ return false;
127
+ }
128
+ })();
129
+ return canAccessPowerShellPromise;
130
+ };
131
+ const wslDefaultBrowser = async () => {
132
+ const psPath = await powerShellPath();
133
+ const { stdout } = await executePowerShell(String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`, { powerShellPath: psPath });
134
+ return stdout.trim();
135
+ };
136
+ const convertWslPathToWindows = async (path) => {
137
+ if (/^[a-z]+:\/\//i.test(path)) return path;
138
+ try {
139
+ const { stdout } = await execFile$1("wslpath", ["-aw", path], { encoding: "utf8" });
140
+ return stdout.trim();
141
+ } catch {
142
+ return path;
143
+ }
144
+ };
145
+ //#endregion
146
+ //#region ../../../node_modules/.pnpm/define-lazy-prop@3.0.0/node_modules/define-lazy-prop/index.js
147
+ function defineLazyProperty(object, propertyName, valueGetter) {
148
+ const define = (value) => Object.defineProperty(object, propertyName, {
149
+ value,
150
+ enumerable: true,
151
+ writable: true
152
+ });
153
+ Object.defineProperty(object, propertyName, {
154
+ configurable: true,
155
+ enumerable: true,
156
+ get() {
157
+ const result = valueGetter();
158
+ define(result);
159
+ return result;
160
+ },
161
+ set(value) {
162
+ define(value);
163
+ }
164
+ });
165
+ return object;
166
+ }
167
+ //#endregion
168
+ //#region ../../../node_modules/.pnpm/default-browser-id@5.0.1/node_modules/default-browser-id/index.js
169
+ const execFileAsync$3 = promisify(execFile);
170
+ async function defaultBrowserId() {
171
+ if (process.platform !== "darwin") throw new Error("macOS only");
172
+ const { stdout } = await execFileAsync$3("defaults", [
173
+ "read",
174
+ "com.apple.LaunchServices/com.apple.launchservices.secure",
175
+ "LSHandlers"
176
+ ]);
177
+ const browserId = /LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(stdout)?.groups.id ?? "com.apple.Safari";
178
+ if (browserId === "com.apple.safari") return "com.apple.Safari";
179
+ return browserId;
180
+ }
181
+ //#endregion
182
+ //#region ../../../node_modules/.pnpm/run-applescript@7.1.0/node_modules/run-applescript/index.js
183
+ const execFileAsync$2 = promisify(execFile);
184
+ async function runAppleScript(script, { humanReadableOutput = true, signal } = {}) {
185
+ if (process.platform !== "darwin") throw new Error("macOS only");
186
+ const outputArguments = humanReadableOutput ? [] : ["-ss"];
187
+ const execOptions = {};
188
+ if (signal) execOptions.signal = signal;
189
+ const { stdout } = await execFileAsync$2("osascript", [
190
+ "-e",
191
+ script,
192
+ outputArguments
193
+ ], execOptions);
194
+ return stdout.trim();
195
+ }
196
+ //#endregion
197
+ //#region ../../../node_modules/.pnpm/bundle-name@4.1.0/node_modules/bundle-name/index.js
198
+ async function bundleName(bundleId) {
199
+ return runAppleScript(`tell application "Finder" to set app_path to application file id "${bundleId}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`);
200
+ }
201
+ //#endregion
202
+ //#region ../../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/windows.js
203
+ const execFileAsync$1 = promisify(execFile);
204
+ const windowsBrowserProgIds = {
205
+ MSEdgeHTM: {
206
+ name: "Edge",
207
+ id: "com.microsoft.edge"
208
+ },
209
+ MSEdgeBHTML: {
210
+ name: "Edge Beta",
211
+ id: "com.microsoft.edge.beta"
212
+ },
213
+ MSEdgeDHTML: {
214
+ name: "Edge Dev",
215
+ id: "com.microsoft.edge.dev"
216
+ },
217
+ AppXq0fevzme2pys62n3e0fbqa7peapykr8v: {
218
+ name: "Edge",
219
+ id: "com.microsoft.edge.old"
220
+ },
221
+ ChromeHTML: {
222
+ name: "Chrome",
223
+ id: "com.google.chrome"
224
+ },
225
+ ChromeBHTML: {
226
+ name: "Chrome Beta",
227
+ id: "com.google.chrome.beta"
228
+ },
229
+ ChromeDHTML: {
230
+ name: "Chrome Dev",
231
+ id: "com.google.chrome.dev"
232
+ },
233
+ ChromiumHTM: {
234
+ name: "Chromium",
235
+ id: "org.chromium.Chromium"
236
+ },
237
+ BraveHTML: {
238
+ name: "Brave",
239
+ id: "com.brave.Browser"
240
+ },
241
+ BraveBHTML: {
242
+ name: "Brave Beta",
243
+ id: "com.brave.Browser.beta"
244
+ },
245
+ BraveDHTML: {
246
+ name: "Brave Dev",
247
+ id: "com.brave.Browser.dev"
248
+ },
249
+ BraveSSHTM: {
250
+ name: "Brave Nightly",
251
+ id: "com.brave.Browser.nightly"
252
+ },
253
+ FirefoxURL: {
254
+ name: "Firefox",
255
+ id: "org.mozilla.firefox"
256
+ },
257
+ OperaStable: {
258
+ name: "Opera",
259
+ id: "com.operasoftware.Opera"
260
+ },
261
+ VivaldiHTM: {
262
+ name: "Vivaldi",
263
+ id: "com.vivaldi.Vivaldi"
264
+ },
265
+ "IE.HTTP": {
266
+ name: "Internet Explorer",
267
+ id: "com.microsoft.ie"
268
+ }
269
+ };
270
+ const _windowsBrowserProgIdMap = new Map(Object.entries(windowsBrowserProgIds));
271
+ var UnknownBrowserError = class extends Error {};
272
+ async function defaultBrowser$1(_execFileAsync = execFileAsync$1) {
273
+ const { stdout } = await _execFileAsync("reg", [
274
+ "QUERY",
275
+ " HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice",
276
+ "/v",
277
+ "ProgId"
278
+ ]);
279
+ const match = /ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(stdout);
280
+ if (!match) throw new UnknownBrowserError(`Cannot find Windows browser in stdout: ${JSON.stringify(stdout)}`);
281
+ const { id } = match.groups;
282
+ const browser = windowsBrowserProgIds[id];
283
+ if (!browser) throw new UnknownBrowserError(`Unknown browser ID: ${id}`);
284
+ return browser;
285
+ }
286
+ //#endregion
287
+ //#region ../../../node_modules/.pnpm/default-browser@5.4.0/node_modules/default-browser/index.js
288
+ const execFileAsync = promisify(execFile);
289
+ const titleize = (string) => string.toLowerCase().replaceAll(/(?:^|\s|-)\S/g, (x) => x.toUpperCase());
290
+ async function defaultBrowser() {
291
+ if (process.platform === "darwin") {
292
+ const id = await defaultBrowserId();
293
+ return {
294
+ name: await bundleName(id),
295
+ id
296
+ };
297
+ }
298
+ if (process.platform === "linux") {
299
+ const { stdout } = await execFileAsync("xdg-mime", [
300
+ "query",
301
+ "default",
302
+ "x-scheme-handler/http"
303
+ ]);
304
+ const id = stdout.trim();
305
+ return {
306
+ name: titleize(id.replace(/.desktop$/, "").replace("-", " ")),
307
+ id
308
+ };
309
+ }
310
+ if (process.platform === "win32") return defaultBrowser$1();
311
+ throw new Error("Only macOS, Linux, and Windows are supported");
312
+ }
313
+ //#endregion
314
+ //#region ../../../node_modules/.pnpm/is-in-ssh@1.0.0/node_modules/is-in-ssh/index.js
315
+ const isInSsh = Boolean(process.env.SSH_CONNECTION || process.env.SSH_CLIENT || process.env.SSH_TTY);
316
+ //#endregion
317
+ //#region ../../../node_modules/.pnpm/open@11.0.0/node_modules/open/index.js
318
+ const fallbackAttemptSymbol = Symbol("fallbackAttempt");
319
+ const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : "";
320
+ const localXdgOpenPath = path.join(__dirname, "xdg-open");
321
+ const { platform, arch } = process;
322
+ const tryEachApp = async (apps, opener) => {
323
+ if (apps.length === 0) return;
324
+ const errors = [];
325
+ for (const app of apps) try {
326
+ return await opener(app);
327
+ } catch (error) {
328
+ errors.push(error);
329
+ }
330
+ throw new AggregateError(errors, "Failed to open in all supported apps");
331
+ };
332
+ const baseOpen = async (options) => {
333
+ options = {
334
+ wait: false,
335
+ background: false,
336
+ newInstance: false,
337
+ allowNonzeroExitCode: false,
338
+ ...options
339
+ };
340
+ const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
341
+ delete options[fallbackAttemptSymbol];
342
+ if (Array.isArray(options.app)) return tryEachApp(options.app, (singleApp) => baseOpen({
343
+ ...options,
344
+ app: singleApp,
345
+ [fallbackAttemptSymbol]: true
346
+ }));
347
+ let { name: app, arguments: appArguments = [] } = options.app ?? {};
348
+ appArguments = [...appArguments];
349
+ if (Array.isArray(app)) return tryEachApp(app, (appName) => baseOpen({
350
+ ...options,
351
+ app: {
352
+ name: appName,
353
+ arguments: appArguments
354
+ },
355
+ [fallbackAttemptSymbol]: true
356
+ }));
357
+ if (app === "browser" || app === "browserPrivate") {
358
+ const ids = {
359
+ "com.google.chrome": "chrome",
360
+ "google-chrome.desktop": "chrome",
361
+ "com.brave.browser": "brave",
362
+ "org.mozilla.firefox": "firefox",
363
+ "firefox.desktop": "firefox",
364
+ "com.microsoft.msedge": "edge",
365
+ "com.microsoft.edge": "edge",
366
+ "com.microsoft.edgemac": "edge",
367
+ "microsoft-edge.desktop": "edge",
368
+ "com.apple.safari": "safari"
369
+ };
370
+ const flags = {
371
+ chrome: "--incognito",
372
+ brave: "--incognito",
373
+ firefox: "--private-window",
374
+ edge: "--inPrivate"
375
+ };
376
+ let browser;
377
+ if (is_wsl_default) {
378
+ const progId = await wslDefaultBrowser();
379
+ browser = _windowsBrowserProgIdMap.get(progId) ?? {};
380
+ } else browser = await defaultBrowser();
381
+ if (browser.id in ids) {
382
+ const browserName = ids[browser.id.toLowerCase()];
383
+ if (app === "browserPrivate") {
384
+ if (browserName === "safari") throw new Error("Safari doesn't support opening in private mode via command line");
385
+ appArguments.push(flags[browserName]);
386
+ }
387
+ return baseOpen({
388
+ ...options,
389
+ app: {
390
+ name: apps[browserName],
391
+ arguments: appArguments
392
+ }
393
+ });
394
+ }
395
+ throw new Error(`${browser.name} is not supported as a default browser`);
396
+ }
397
+ let command;
398
+ const cliArguments = [];
399
+ const childProcessOptions = {};
400
+ let shouldUseWindowsInWsl = false;
401
+ if (is_wsl_default && !isInsideContainer() && !isInSsh && !app) shouldUseWindowsInWsl = await canAccessPowerShell();
402
+ if (platform === "darwin") {
403
+ command = "open";
404
+ if (options.wait) cliArguments.push("--wait-apps");
405
+ if (options.background) cliArguments.push("--background");
406
+ if (options.newInstance) cliArguments.push("--new");
407
+ if (app) cliArguments.push("-a", app);
408
+ } else if (platform === "win32" || shouldUseWindowsInWsl) {
409
+ command = await powerShellPath();
410
+ cliArguments.push(...executePowerShell.argumentsPrefix);
411
+ if (!is_wsl_default) childProcessOptions.windowsVerbatimArguments = true;
412
+ if (is_wsl_default && options.target) options.target = await convertWslPathToWindows(options.target);
413
+ const encodedArguments = ["$ProgressPreference = 'SilentlyContinue';", "Start"];
414
+ if (options.wait) encodedArguments.push("-Wait");
415
+ if (app) {
416
+ encodedArguments.push(executePowerShell.escapeArgument(app));
417
+ if (options.target) appArguments.push(options.target);
418
+ } else if (options.target) encodedArguments.push(executePowerShell.escapeArgument(options.target));
419
+ if (appArguments.length > 0) {
420
+ appArguments = appArguments.map((argument) => executePowerShell.escapeArgument(argument));
421
+ encodedArguments.push("-ArgumentList", appArguments.join(","));
422
+ }
423
+ options.target = executePowerShell.encodeCommand(encodedArguments.join(" "));
424
+ if (!options.wait) childProcessOptions.stdio = "ignore";
425
+ } else {
426
+ if (app) command = app;
427
+ else {
428
+ const isBundled = !__dirname || __dirname === "/";
429
+ let exeLocalXdgOpen = false;
430
+ try {
431
+ await fs$1.access(localXdgOpenPath, constants.X_OK);
432
+ exeLocalXdgOpen = true;
433
+ } catch {}
434
+ command = process.versions.electron ?? (platform === "android" || isBundled || !exeLocalXdgOpen) ? "xdg-open" : localXdgOpenPath;
435
+ }
436
+ if (appArguments.length > 0) cliArguments.push(...appArguments);
437
+ if (!options.wait) {
438
+ childProcessOptions.stdio = "ignore";
439
+ childProcessOptions.detached = true;
440
+ }
441
+ }
442
+ if (platform === "darwin" && appArguments.length > 0) cliArguments.push("--args", ...appArguments);
443
+ if (options.target) cliArguments.push(options.target);
444
+ const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
445
+ if (options.wait) return new Promise((resolve, reject) => {
446
+ subprocess.once("error", reject);
447
+ subprocess.once("close", (exitCode) => {
448
+ if (!options.allowNonzeroExitCode && exitCode !== 0) {
449
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
450
+ return;
451
+ }
452
+ resolve(subprocess);
453
+ });
454
+ });
455
+ if (isFallbackAttempt) return new Promise((resolve, reject) => {
456
+ subprocess.once("error", reject);
457
+ subprocess.once("spawn", () => {
458
+ subprocess.once("close", (exitCode) => {
459
+ subprocess.off("error", reject);
460
+ if (exitCode !== 0) {
461
+ reject(/* @__PURE__ */ new Error(`Exited with code ${exitCode}`));
462
+ return;
463
+ }
464
+ subprocess.unref();
465
+ resolve(subprocess);
466
+ });
467
+ });
468
+ });
469
+ subprocess.unref();
470
+ return new Promise((resolve, reject) => {
471
+ subprocess.once("error", reject);
472
+ subprocess.once("spawn", () => {
473
+ subprocess.off("error", reject);
474
+ resolve(subprocess);
475
+ });
476
+ });
477
+ };
478
+ const open = (target, options) => {
479
+ if (typeof target !== "string") throw new TypeError("Expected a `target`");
480
+ return baseOpen({
481
+ ...options,
482
+ target
483
+ });
484
+ };
485
+ function detectArchBinary(binary) {
486
+ if (typeof binary === "string" || Array.isArray(binary)) return binary;
487
+ const { [arch]: archBinary } = binary;
488
+ if (!archBinary) throw new Error(`${arch} is not supported`);
489
+ return archBinary;
490
+ }
491
+ function detectPlatformBinary({ [platform]: platformBinary }, { wsl } = {}) {
492
+ if (wsl && is_wsl_default) return detectArchBinary(wsl);
493
+ if (!platformBinary) throw new Error(`${platform} is not supported`);
494
+ return detectArchBinary(platformBinary);
495
+ }
496
+ const apps = {
497
+ browser: "browser",
498
+ browserPrivate: "browserPrivate"
499
+ };
500
+ defineLazyProperty(apps, "chrome", () => detectPlatformBinary({
501
+ darwin: "google chrome",
502
+ win32: "chrome",
503
+ linux: [
504
+ "google-chrome",
505
+ "google-chrome-stable",
506
+ "chromium",
507
+ "chromium-browser"
508
+ ]
509
+ }, { wsl: {
510
+ ia32: "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",
511
+ x64: ["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe", "/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]
512
+ } }));
513
+ defineLazyProperty(apps, "brave", () => detectPlatformBinary({
514
+ darwin: "brave browser",
515
+ win32: "brave",
516
+ linux: ["brave-browser", "brave"]
517
+ }, { wsl: {
518
+ ia32: "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",
519
+ x64: ["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe", "/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]
520
+ } }));
521
+ defineLazyProperty(apps, "firefox", () => detectPlatformBinary({
522
+ darwin: "firefox",
523
+ win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
524
+ linux: "firefox"
525
+ }, { wsl: "/mnt/c/Program Files/Mozilla Firefox/firefox.exe" }));
526
+ defineLazyProperty(apps, "edge", () => detectPlatformBinary({
527
+ darwin: "microsoft edge",
528
+ win32: "msedge",
529
+ linux: ["microsoft-edge", "microsoft-edge-dev"]
530
+ }, { wsl: "/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe" }));
531
+ defineLazyProperty(apps, "safari", () => detectPlatformBinary({ darwin: "Safari" }));
532
+ //#endregion
533
+ export { open as default };
@@ -0,0 +1,104 @@
1
+ import { A as RpcFunctionSetupResult, P as Thenable, _ as RpcDump, w as RpcFunctionAgentOptions } from "../index-DvKDO5H8.mjs";
2
+ import * as v from "valibot";
3
+
4
+ //#region src/recipes/open-helpers.d.ts
5
+ /**
6
+ * Prebuilt RPC action that opens a file in the user's configured editor
7
+ * via [`launch-editor`](https://www.npmjs.com/package/launch-editor).
8
+ *
9
+ * Registered name: `devframe:open-in-editor`.
10
+ *
11
+ * ```ts
12
+ * import { openInEditor } from 'devframe/recipes/open-helpers'
13
+ *
14
+ * defineDevtool({
15
+ * id: 'my-tool',
16
+ * name: 'My Tool',
17
+ * setup(ctx) {
18
+ * ctx.rpc.register(openInEditor)
19
+ * },
20
+ * })
21
+ * ```
22
+ *
23
+ * Requires `launch-editor` to be installed by the consumer (declared as
24
+ * an optional peer dependency on devframe).
25
+ */
26
+ declare const openInEditor: {
27
+ name: "devframe:open-in-editor";
28
+ type?: "action" | undefined;
29
+ cacheable?: boolean;
30
+ args: readonly [v.StringSchema<undefined>];
31
+ returns: v.VoidSchema<undefined>;
32
+ agent?: RpcFunctionAgentOptions;
33
+ setup?: ((context: undefined) => Thenable<RpcFunctionSetupResult<[string], void>>) | undefined;
34
+ handler?: ((args_0: string) => void) | undefined;
35
+ dump?: RpcDump<[string], void, undefined> | undefined;
36
+ snapshot?: boolean;
37
+ __resolved?: RpcFunctionSetupResult<[string], void> | undefined;
38
+ __promise?: Thenable<RpcFunctionSetupResult<[string], void>> | undefined;
39
+ };
40
+ /**
41
+ * Prebuilt RPC action that reveals a path in the OS file explorer via
42
+ * [`open`](https://www.npmjs.com/package/open).
43
+ *
44
+ * Registered name: `devframe:open-in-finder`.
45
+ *
46
+ * ```ts
47
+ * import { openInFinder } from 'devframe/recipes/open-helpers'
48
+ *
49
+ * ctx.rpc.register(openInFinder)
50
+ * ```
51
+ */
52
+ declare const openInFinder: {
53
+ name: "devframe:open-in-finder";
54
+ type?: "action" | undefined;
55
+ cacheable?: boolean;
56
+ args: readonly [v.StringSchema<undefined>];
57
+ returns: v.VoidSchema<undefined>;
58
+ agent?: RpcFunctionAgentOptions;
59
+ setup?: ((context: undefined) => Thenable<RpcFunctionSetupResult<[string], void>>) | undefined;
60
+ handler?: ((args_0: string) => void) | undefined;
61
+ dump?: RpcDump<[string], void, undefined> | undefined;
62
+ snapshot?: boolean;
63
+ __resolved?: RpcFunctionSetupResult<[string], void> | undefined;
64
+ __promise?: Thenable<RpcFunctionSetupResult<[string], void>> | undefined;
65
+ };
66
+ /**
67
+ * Convenience array bundling both helpers so callers can register them
68
+ * in a single `forEach`.
69
+ *
70
+ * ```ts
71
+ * import { openHelpers } from 'devframe/recipes/open-helpers'
72
+ *
73
+ * openHelpers.forEach(fn => ctx.rpc.register(fn))
74
+ * ```
75
+ */
76
+ declare const openHelpers: readonly [{
77
+ name: "devframe:open-in-editor";
78
+ type?: "action" | undefined;
79
+ cacheable?: boolean;
80
+ args: readonly [v.StringSchema<undefined>];
81
+ returns: v.VoidSchema<undefined>;
82
+ agent?: RpcFunctionAgentOptions;
83
+ setup?: ((context: undefined) => Thenable<RpcFunctionSetupResult<[string], void>>) | undefined;
84
+ handler?: ((args_0: string) => void) | undefined;
85
+ dump?: RpcDump<[string], void, undefined> | undefined;
86
+ snapshot?: boolean;
87
+ __resolved?: RpcFunctionSetupResult<[string], void> | undefined;
88
+ __promise?: Thenable<RpcFunctionSetupResult<[string], void>> | undefined;
89
+ }, {
90
+ name: "devframe:open-in-finder";
91
+ type?: "action" | undefined;
92
+ cacheable?: boolean;
93
+ args: readonly [v.StringSchema<undefined>];
94
+ returns: v.VoidSchema<undefined>;
95
+ agent?: RpcFunctionAgentOptions;
96
+ setup?: ((context: undefined) => Thenable<RpcFunctionSetupResult<[string], void>>) | undefined;
97
+ handler?: ((args_0: string) => void) | undefined;
98
+ dump?: RpcDump<[string], void, undefined> | undefined;
99
+ snapshot?: boolean;
100
+ __resolved?: RpcFunctionSetupResult<[string], void> | undefined;
101
+ __promise?: Thenable<RpcFunctionSetupResult<[string], void>> | undefined;
102
+ }];
103
+ //#endregion
104
+ export { openHelpers, openInEditor, openInFinder };