修改后台权限
This commit is contained in:
158
node_modules/open/index.d.ts
generated
vendored
Normal file
158
node_modules/open/index.d.ts
generated
vendored
Normal file
@@ -0,0 +1,158 @@
|
||||
import {type ChildProcess} from 'node:child_process';
|
||||
|
||||
export type Options = {
|
||||
/**
|
||||
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
|
||||
|
||||
Note that it waits for the app to exit, not just for the window to close.
|
||||
|
||||
On Windows, you have to explicitly specify an app for it to be able to wait.
|
||||
|
||||
**Warning:** When opening URLs in browsers while the browser is already running, the `wait` option will not work as expected. Browsers use a single-instance architecture where new URLs are passed to the existing process, causing the command to exit immediately. Use the `newInstance` option on macOS to force a new browser instance, or avoid using `wait` with browsers.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly wait?: boolean;
|
||||
|
||||
/**
|
||||
__macOS only__
|
||||
|
||||
Do not bring the app to the foreground.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly background?: boolean;
|
||||
|
||||
/**
|
||||
__macOS only__
|
||||
|
||||
Open a new instance of the app even it's already running.
|
||||
|
||||
A new instance is always opened on other platforms.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly newInstance?: boolean;
|
||||
|
||||
/**
|
||||
Specify the `name` of the app to open the `target` with, and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
|
||||
|
||||
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use `apps` which auto-detects the correct binary to use.
|
||||
|
||||
You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
|
||||
|
||||
The app `arguments` are app dependent. Check the app's documentation for what arguments it accepts.
|
||||
*/
|
||||
readonly app?: App | readonly App[];
|
||||
|
||||
/**
|
||||
Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
|
||||
|
||||
We do not recommend setting this option. The convention for success is exit code zero.
|
||||
|
||||
@default false
|
||||
*/
|
||||
readonly allowNonzeroExitCode?: boolean;
|
||||
};
|
||||
|
||||
export type OpenAppOptions = {
|
||||
/**
|
||||
Arguments passed to the app.
|
||||
|
||||
These arguments are app dependent. Check the app's documentation for what arguments it accepts.
|
||||
*/
|
||||
readonly arguments?: readonly string[];
|
||||
} & Omit<Options, 'app'>;
|
||||
|
||||
export type AppName =
|
||||
| 'chrome'
|
||||
| 'brave'
|
||||
| 'firefox'
|
||||
| 'edge'
|
||||
| 'browser'
|
||||
| 'browserPrivate';
|
||||
|
||||
export type App = {
|
||||
name: string | readonly string[];
|
||||
arguments?: readonly string[];
|
||||
};
|
||||
|
||||
/**
|
||||
An object containing auto-detected binary names for common apps. Useful to work around cross-platform differences.
|
||||
|
||||
@example
|
||||
```
|
||||
import open, {apps} from 'open';
|
||||
|
||||
await open('https://google.com', {
|
||||
app: {
|
||||
name: apps.chrome
|
||||
}
|
||||
});
|
||||
```
|
||||
*/
|
||||
export const apps: Record<AppName, string | readonly string[]>;
|
||||
|
||||
/**
|
||||
Open stuff like URLs, files, executables. Cross-platform.
|
||||
|
||||
Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
||||
|
||||
@param target - The thing you want to open. Can be a URL, file, or executable. Opens in the default app for the file type. For example, URLs open in your default browser.
|
||||
@returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
||||
|
||||
@example
|
||||
```
|
||||
import open, {apps} from 'open';
|
||||
|
||||
// Opens the image in the default image viewer.
|
||||
await open('unicorn.png', {wait: true});
|
||||
console.log('The image viewer app quit');
|
||||
|
||||
// Opens the URL in the default browser.
|
||||
await open('https://sindresorhus.com');
|
||||
|
||||
// Opens the URL in a specified browser.
|
||||
await open('https://sindresorhus.com', {app: {name: 'firefox'}});
|
||||
|
||||
// Specify app arguments.
|
||||
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
|
||||
|
||||
// Opens the URL in the default browser in incognito mode.
|
||||
await open('https://sindresorhus.com', {app: {name: apps.browserPrivate}});
|
||||
```
|
||||
*/
|
||||
export default function open(
|
||||
target: string,
|
||||
options?: Options
|
||||
): Promise<ChildProcess>;
|
||||
|
||||
/**
|
||||
Open an app. Cross-platform.
|
||||
|
||||
Uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
||||
|
||||
@param name - The app you want to open. Can be either builtin supported `apps` names or other name supported in platform.
|
||||
@returns The [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
||||
|
||||
@example
|
||||
```
|
||||
import open, {openApp, apps} from 'open';
|
||||
|
||||
// Open Firefox.
|
||||
await openApp(apps.firefox);
|
||||
|
||||
// Open Chrome in incognito mode.
|
||||
await openApp(apps.chrome, {arguments: ['--incognito']});
|
||||
|
||||
// Open default browser.
|
||||
await openApp(apps.browser);
|
||||
|
||||
// Open default browser in incognito mode.
|
||||
await openApp(apps.browserPrivate);
|
||||
|
||||
// Open Xcode.
|
||||
await openApp('xcode');
|
||||
```
|
||||
*/
|
||||
export function openApp(name: App['name'], options?: OpenAppOptions): Promise<ChildProcess>;
|
||||
417
node_modules/open/index.js
generated
vendored
Normal file
417
node_modules/open/index.js
generated
vendored
Normal file
@@ -0,0 +1,417 @@
|
||||
import process from 'node:process';
|
||||
import path from 'node:path';
|
||||
import {fileURLToPath} from 'node:url';
|
||||
import childProcess from 'node:child_process';
|
||||
import fs, {constants as fsConstants} from 'node:fs/promises';
|
||||
import {
|
||||
isWsl,
|
||||
powerShellPath,
|
||||
convertWslPathToWindows,
|
||||
canAccessPowerShell,
|
||||
wslDefaultBrowser,
|
||||
} from 'wsl-utils';
|
||||
import {executePowerShell} from 'powershell-utils';
|
||||
import defineLazyProperty from 'define-lazy-prop';
|
||||
import defaultBrowser, {_windowsBrowserProgIdMap} from 'default-browser';
|
||||
import isInsideContainer from 'is-inside-container';
|
||||
import isInSsh from 'is-in-ssh';
|
||||
|
||||
const fallbackAttemptSymbol = Symbol('fallbackAttempt');
|
||||
|
||||
// Path to included `xdg-open`.
|
||||
const __dirname = import.meta.url ? path.dirname(fileURLToPath(import.meta.url)) : '';
|
||||
const localXdgOpenPath = path.join(__dirname, 'xdg-open');
|
||||
|
||||
const {platform, arch} = process;
|
||||
|
||||
const tryEachApp = async (apps, opener) => {
|
||||
if (apps.length === 0) {
|
||||
// No app was provided
|
||||
return;
|
||||
}
|
||||
|
||||
const errors = [];
|
||||
|
||||
for (const app of apps) {
|
||||
try {
|
||||
return await opener(app); // eslint-disable-line no-await-in-loop
|
||||
} catch (error) {
|
||||
errors.push(error);
|
||||
}
|
||||
}
|
||||
|
||||
throw new AggregateError(errors, 'Failed to open in all supported apps');
|
||||
};
|
||||
|
||||
// eslint-disable-next-line complexity
|
||||
const baseOpen = async options => {
|
||||
options = {
|
||||
wait: false,
|
||||
background: false,
|
||||
newInstance: false,
|
||||
allowNonzeroExitCode: false,
|
||||
...options,
|
||||
};
|
||||
|
||||
const isFallbackAttempt = options[fallbackAttemptSymbol] === true;
|
||||
delete options[fallbackAttemptSymbol];
|
||||
|
||||
if (Array.isArray(options.app)) {
|
||||
return tryEachApp(options.app, singleApp => baseOpen({
|
||||
...options,
|
||||
app: singleApp,
|
||||
[fallbackAttemptSymbol]: true,
|
||||
}));
|
||||
}
|
||||
|
||||
let {name: app, arguments: appArguments = []} = options.app ?? {};
|
||||
appArguments = [...appArguments];
|
||||
|
||||
if (Array.isArray(app)) {
|
||||
return tryEachApp(app, appName => baseOpen({
|
||||
...options,
|
||||
app: {
|
||||
name: appName,
|
||||
arguments: appArguments,
|
||||
},
|
||||
[fallbackAttemptSymbol]: true,
|
||||
}));
|
||||
}
|
||||
|
||||
if (app === 'browser' || app === 'browserPrivate') {
|
||||
// IDs from default-browser for macOS and windows are the same.
|
||||
// IDs are lowercased to increase chances of a match.
|
||||
const ids = {
|
||||
'com.google.chrome': 'chrome',
|
||||
'google-chrome.desktop': 'chrome',
|
||||
'com.brave.browser': 'brave',
|
||||
'org.mozilla.firefox': 'firefox',
|
||||
'firefox.desktop': 'firefox',
|
||||
'com.microsoft.msedge': 'edge',
|
||||
'com.microsoft.edge': 'edge',
|
||||
'com.microsoft.edgemac': 'edge',
|
||||
'microsoft-edge.desktop': 'edge',
|
||||
'com.apple.safari': 'safari',
|
||||
};
|
||||
|
||||
// Incognito flags for each browser in `apps`.
|
||||
const flags = {
|
||||
chrome: '--incognito',
|
||||
brave: '--incognito',
|
||||
firefox: '--private-window',
|
||||
edge: '--inPrivate',
|
||||
// Safari doesn't support private mode via command line
|
||||
};
|
||||
|
||||
let browser;
|
||||
if (isWsl) {
|
||||
const progId = await wslDefaultBrowser();
|
||||
const browserInfo = _windowsBrowserProgIdMap.get(progId);
|
||||
browser = browserInfo ?? {};
|
||||
} else {
|
||||
browser = await defaultBrowser();
|
||||
}
|
||||
|
||||
if (browser.id in ids) {
|
||||
const browserName = ids[browser.id.toLowerCase()];
|
||||
|
||||
if (app === 'browserPrivate') {
|
||||
// Safari doesn't support private mode via command line
|
||||
if (browserName === 'safari') {
|
||||
throw new Error('Safari doesn\'t support opening in private mode via command line');
|
||||
}
|
||||
|
||||
appArguments.push(flags[browserName]);
|
||||
}
|
||||
|
||||
return baseOpen({
|
||||
...options,
|
||||
app: {
|
||||
name: apps[browserName],
|
||||
arguments: appArguments,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
throw new Error(`${browser.name} is not supported as a default browser`);
|
||||
}
|
||||
|
||||
let command;
|
||||
const cliArguments = [];
|
||||
const childProcessOptions = {};
|
||||
|
||||
// Determine if we should use Windows/PowerShell behavior in WSL.
|
||||
// We only use Windows integration if PowerShell is actually accessible.
|
||||
// This allows the package to work in sandboxed WSL environments where Windows access is restricted.
|
||||
let shouldUseWindowsInWsl = false;
|
||||
if (isWsl && !isInsideContainer() && !isInSsh && !app) {
|
||||
shouldUseWindowsInWsl = await canAccessPowerShell();
|
||||
}
|
||||
|
||||
if (platform === 'darwin') {
|
||||
command = 'open';
|
||||
|
||||
if (options.wait) {
|
||||
cliArguments.push('--wait-apps');
|
||||
}
|
||||
|
||||
if (options.background) {
|
||||
cliArguments.push('--background');
|
||||
}
|
||||
|
||||
if (options.newInstance) {
|
||||
cliArguments.push('--new');
|
||||
}
|
||||
|
||||
if (app) {
|
||||
cliArguments.push('-a', app);
|
||||
}
|
||||
} else if (platform === 'win32' || shouldUseWindowsInWsl) {
|
||||
command = await powerShellPath();
|
||||
|
||||
cliArguments.push(...executePowerShell.argumentsPrefix);
|
||||
|
||||
if (!isWsl) {
|
||||
childProcessOptions.windowsVerbatimArguments = true;
|
||||
}
|
||||
|
||||
// Convert WSL Linux paths to Windows paths
|
||||
if (isWsl && options.target) {
|
||||
options.target = await convertWslPathToWindows(options.target);
|
||||
}
|
||||
|
||||
// Suppress PowerShell progress messages that are written to stderr
|
||||
const encodedArguments = ['$ProgressPreference = \'SilentlyContinue\';', 'Start'];
|
||||
|
||||
if (options.wait) {
|
||||
encodedArguments.push('-Wait');
|
||||
}
|
||||
|
||||
if (app) {
|
||||
encodedArguments.push(executePowerShell.escapeArgument(app));
|
||||
if (options.target) {
|
||||
appArguments.push(options.target);
|
||||
}
|
||||
} else if (options.target) {
|
||||
encodedArguments.push(executePowerShell.escapeArgument(options.target));
|
||||
}
|
||||
|
||||
if (appArguments.length > 0) {
|
||||
appArguments = appArguments.map(argument => executePowerShell.escapeArgument(argument));
|
||||
encodedArguments.push('-ArgumentList', appArguments.join(','));
|
||||
}
|
||||
|
||||
// Using Base64-encoded command, accepted by PowerShell, to allow special characters.
|
||||
options.target = executePowerShell.encodeCommand(encodedArguments.join(' '));
|
||||
|
||||
if (!options.wait) {
|
||||
// PowerShell will keep the parent process alive unless stdio is ignored.
|
||||
childProcessOptions.stdio = 'ignore';
|
||||
}
|
||||
} else {
|
||||
if (app) {
|
||||
command = app;
|
||||
} else {
|
||||
// When bundled by Webpack, there's no actual package file path and no local `xdg-open`.
|
||||
const isBundled = !__dirname || __dirname === '/';
|
||||
|
||||
// Check if local `xdg-open` exists and is executable.
|
||||
let exeLocalXdgOpen = false;
|
||||
try {
|
||||
await fs.access(localXdgOpenPath, fsConstants.X_OK);
|
||||
exeLocalXdgOpen = true;
|
||||
} catch {}
|
||||
|
||||
const useSystemXdgOpen = process.versions.electron
|
||||
?? (platform === 'android' || isBundled || !exeLocalXdgOpen);
|
||||
command = useSystemXdgOpen ? 'xdg-open' : localXdgOpenPath;
|
||||
}
|
||||
|
||||
if (appArguments.length > 0) {
|
||||
cliArguments.push(...appArguments);
|
||||
}
|
||||
|
||||
if (!options.wait) {
|
||||
// `xdg-open` will block the process unless stdio is ignored
|
||||
// and it's detached from the parent even if it's unref'd.
|
||||
childProcessOptions.stdio = 'ignore';
|
||||
childProcessOptions.detached = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (platform === 'darwin' && appArguments.length > 0) {
|
||||
cliArguments.push('--args', ...appArguments);
|
||||
}
|
||||
|
||||
// IMPORTANT: On macOS, the target MUST come AFTER '--args'.
|
||||
// When using --args, ALL following arguments are passed to the app.
|
||||
// Example: open -a "chrome" --args --incognito https://site.com
|
||||
// This passes BOTH --incognito AND https://site.com to Chrome.
|
||||
// Without this order, Chrome won't open in incognito. See #332.
|
||||
if (options.target) {
|
||||
cliArguments.push(options.target);
|
||||
}
|
||||
|
||||
const subprocess = childProcess.spawn(command, cliArguments, childProcessOptions);
|
||||
|
||||
if (options.wait) {
|
||||
return new Promise((resolve, reject) => {
|
||||
subprocess.once('error', reject);
|
||||
|
||||
subprocess.once('close', exitCode => {
|
||||
if (!options.allowNonzeroExitCode && exitCode !== 0) {
|
||||
reject(new Error(`Exited with code ${exitCode}`));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve(subprocess);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// When we're in a fallback attempt, we need to detect launch failures before trying the next app.
|
||||
// Wait for the close event to check the exit code before unreffing.
|
||||
// The launcher (open/xdg-open/PowerShell) exits quickly (~10-30ms) even on success.
|
||||
if (isFallbackAttempt) {
|
||||
return new Promise((resolve, reject) => {
|
||||
subprocess.once('error', reject);
|
||||
|
||||
subprocess.once('spawn', () => {
|
||||
// Keep error handler active for post-spawn errors
|
||||
subprocess.once('close', exitCode => {
|
||||
subprocess.off('error', reject);
|
||||
|
||||
if (exitCode !== 0) {
|
||||
reject(new Error(`Exited with code ${exitCode}`));
|
||||
return;
|
||||
}
|
||||
|
||||
subprocess.unref();
|
||||
resolve(subprocess);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
subprocess.unref();
|
||||
|
||||
// Handle spawn errors before the caller can attach listeners.
|
||||
// This prevents unhandled error events from crashing the process.
|
||||
return new Promise((resolve, reject) => {
|
||||
subprocess.once('error', reject);
|
||||
|
||||
// Wait for the subprocess to spawn before resolving.
|
||||
// This ensures the process is established before the caller continues,
|
||||
// preventing issues when process.exit() is called immediately after.
|
||||
subprocess.once('spawn', () => {
|
||||
subprocess.off('error', reject);
|
||||
resolve(subprocess);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const open = (target, options) => {
|
||||
if (typeof target !== 'string') {
|
||||
throw new TypeError('Expected a `target`');
|
||||
}
|
||||
|
||||
return baseOpen({
|
||||
...options,
|
||||
target,
|
||||
});
|
||||
};
|
||||
|
||||
export const openApp = (name, options) => {
|
||||
if (typeof name !== 'string' && !Array.isArray(name)) {
|
||||
throw new TypeError('Expected a valid `name`');
|
||||
}
|
||||
|
||||
const {arguments: appArguments = []} = options ?? {};
|
||||
if (appArguments !== undefined && appArguments !== null && !Array.isArray(appArguments)) {
|
||||
throw new TypeError('Expected `appArguments` as Array type');
|
||||
}
|
||||
|
||||
return baseOpen({
|
||||
...options,
|
||||
app: {
|
||||
name,
|
||||
arguments: appArguments,
|
||||
},
|
||||
});
|
||||
};
|
||||
|
||||
function detectArchBinary(binary) {
|
||||
if (typeof binary === 'string' || Array.isArray(binary)) {
|
||||
return binary;
|
||||
}
|
||||
|
||||
const {[arch]: archBinary} = binary;
|
||||
|
||||
if (!archBinary) {
|
||||
throw new Error(`${arch} is not supported`);
|
||||
}
|
||||
|
||||
return archBinary;
|
||||
}
|
||||
|
||||
function detectPlatformBinary({[platform]: platformBinary}, {wsl} = {}) {
|
||||
if (wsl && isWsl) {
|
||||
return detectArchBinary(wsl);
|
||||
}
|
||||
|
||||
if (!platformBinary) {
|
||||
throw new Error(`${platform} is not supported`);
|
||||
}
|
||||
|
||||
return detectArchBinary(platformBinary);
|
||||
}
|
||||
|
||||
export const apps = {
|
||||
browser: 'browser',
|
||||
browserPrivate: 'browserPrivate',
|
||||
};
|
||||
|
||||
defineLazyProperty(apps, 'chrome', () => detectPlatformBinary({
|
||||
darwin: 'google chrome',
|
||||
win32: 'chrome',
|
||||
// `chromium-browser` is the older deb package name used by Ubuntu/Debian before snap.
|
||||
linux: ['google-chrome', 'google-chrome-stable', 'chromium', 'chromium-browser'],
|
||||
}, {
|
||||
wsl: {
|
||||
ia32: '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe',
|
||||
x64: ['/mnt/c/Program Files/Google/Chrome/Application/chrome.exe', '/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe'],
|
||||
},
|
||||
}));
|
||||
|
||||
defineLazyProperty(apps, 'brave', () => detectPlatformBinary({
|
||||
darwin: 'brave browser',
|
||||
win32: 'brave',
|
||||
linux: ['brave-browser', 'brave'],
|
||||
}, {
|
||||
wsl: {
|
||||
ia32: '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe',
|
||||
x64: ['/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe', '/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe'],
|
||||
},
|
||||
}));
|
||||
|
||||
defineLazyProperty(apps, 'firefox', () => detectPlatformBinary({
|
||||
darwin: 'firefox',
|
||||
win32: String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,
|
||||
linux: 'firefox',
|
||||
}, {
|
||||
wsl: '/mnt/c/Program Files/Mozilla Firefox/firefox.exe',
|
||||
}));
|
||||
|
||||
defineLazyProperty(apps, 'edge', () => detectPlatformBinary({
|
||||
darwin: 'microsoft edge',
|
||||
win32: 'msedge',
|
||||
linux: ['microsoft-edge', 'microsoft-edge-dev'],
|
||||
}, {
|
||||
wsl: '/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe',
|
||||
}));
|
||||
|
||||
defineLazyProperty(apps, 'safari', () => detectPlatformBinary({
|
||||
darwin: 'Safari',
|
||||
}));
|
||||
|
||||
export default open;
|
||||
9
node_modules/open/license
generated
vendored
Normal file
9
node_modules/open/license
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
70
node_modules/open/package.json
generated
vendored
Normal file
70
node_modules/open/package.json
generated
vendored
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"name": "open",
|
||||
"version": "11.0.0",
|
||||
"description": "Open stuff like URLs, files, executables. Cross-platform.",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/open",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=20"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts",
|
||||
"xdg-open"
|
||||
],
|
||||
"keywords": [
|
||||
"app",
|
||||
"open",
|
||||
"opener",
|
||||
"opens",
|
||||
"launch",
|
||||
"start",
|
||||
"xdg-open",
|
||||
"xdg",
|
||||
"default",
|
||||
"cmd",
|
||||
"browser",
|
||||
"editor",
|
||||
"executable",
|
||||
"exe",
|
||||
"url",
|
||||
"urls",
|
||||
"arguments",
|
||||
"args",
|
||||
"spawn",
|
||||
"exec",
|
||||
"child",
|
||||
"process",
|
||||
"website",
|
||||
"file"
|
||||
],
|
||||
"dependencies": {
|
||||
"default-browser": "^5.4.0",
|
||||
"define-lazy-prop": "^3.0.0",
|
||||
"is-in-ssh": "^1.0.0",
|
||||
"is-inside-container": "^1.0.0",
|
||||
"powershell-utils": "^0.1.0",
|
||||
"wsl-utils": "^0.3.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.10.1",
|
||||
"ava": "^6.4.1",
|
||||
"tsd": "^0.33.0",
|
||||
"xo": "^1.2.3"
|
||||
}
|
||||
}
|
||||
197
node_modules/open/readme.md
generated
vendored
Normal file
197
node_modules/open/readme.md
generated
vendored
Normal file
@@ -0,0 +1,197 @@
|
||||
# open
|
||||
|
||||
> Open stuff like URLs, files, executables. Cross-platform.
|
||||
|
||||
This is meant to be used in command-line tools and scripts, not in the browser.
|
||||
|
||||
If you need this for Electron, use [`shell.openPath()`](https://www.electronjs.org/docs/api/shell#shellopenpathpath) instead.
|
||||
|
||||
This package does not make any security guarantees. If you pass in untrusted input, it's up to you to properly sanitize it.
|
||||
|
||||
#### Why?
|
||||
|
||||
- Actively maintained.
|
||||
- Supports app arguments.
|
||||
- Safer as it uses `spawn` instead of `exec`.
|
||||
- Fixes most of the original `node-open` issues.
|
||||
- Includes the latest [`xdg-open` script](https://gitlab.freedesktop.org/xdg/xdg-utils/-/blob/master/scripts/xdg-open.in) for Linux.
|
||||
- Supports WSL paths to Windows apps.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install open
|
||||
```
|
||||
|
||||
**Warning:** This package is native [ESM](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules) and no longer provides a CommonJS export. If your project uses CommonJS, you will have to [convert to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) or use the [dynamic `import()`](https://v8.dev/features/dynamic-import) function. Please don't open issues for questions regarding CommonJS / ESM.
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import open, {openApp, apps} from 'open';
|
||||
|
||||
// Opens the image in the default image viewer and waits for the opened app to quit.
|
||||
await open('unicorn.png', {wait: true});
|
||||
console.log('The image viewer app quit');
|
||||
|
||||
// Opens the URL in the default browser.
|
||||
await open('https://sindresorhus.com');
|
||||
|
||||
// Opens the URL in a specified browser.
|
||||
await open('https://sindresorhus.com', {app: {name: 'firefox'}});
|
||||
|
||||
// Specify app arguments.
|
||||
await open('https://sindresorhus.com', {app: {name: 'google chrome', arguments: ['--incognito']}});
|
||||
|
||||
// Opens the URL in the default browser in incognito mode.
|
||||
await open('https://sindresorhus.com', {app: {name: apps.browserPrivate}});
|
||||
|
||||
// Open an app.
|
||||
await openApp('xcode');
|
||||
|
||||
// Open an app with arguments.
|
||||
await openApp(apps.chrome, {arguments: ['--incognito']});
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
It uses the command `open` on macOS, `start` on Windows and `xdg-open` on other platforms.
|
||||
|
||||
### open(target, options?)
|
||||
|
||||
Returns a promise for the [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
||||
|
||||
#### target
|
||||
|
||||
Type: `string`
|
||||
|
||||
The thing you want to open. Can be a URL, file, or executable.
|
||||
|
||||
Opens in the default app for the file type. For example, URLs opens in your default browser.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### wait
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Wait for the opened app to exit before fulfilling the promise. If `false` it's fulfilled immediately when opening the app.
|
||||
|
||||
Note that it waits for the app to exit, not just for the window to close.
|
||||
|
||||
On Windows, you have to explicitly specify an app for it to be able to wait.
|
||||
|
||||
> [!WARNING]
|
||||
> When opening URLs in browsers while the browser is already running, the `wait` option will not work as expected. Browsers use a single-instance architecture where new URLs are passed to the existing process, causing the command to exit immediately. Use the `newInstance` option on macOS to force a new browser instance, or avoid using `wait` with browsers.
|
||||
|
||||
##### background <sup>(macOS only)</sup>
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Do not bring the app to the foreground.
|
||||
|
||||
##### newInstance <sup>(macOS only)</sup>
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Open a new instance of the app even it's already running.
|
||||
|
||||
A new instance is always opened on other platforms.
|
||||
|
||||
##### app
|
||||
|
||||
Type: `{name: string | string[], arguments?: string[]} | Array<{name: string | string[], arguments: string[]}>`
|
||||
|
||||
Specify the `name` of the app to open the `target` with, and optionally, app `arguments`. `app` can be an array of apps to try to open and `name` can be an array of app names to try. If each app fails, the last error will be thrown.
|
||||
|
||||
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use [`apps`](#apps) which auto-detects the correct binary to use.
|
||||
|
||||
You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
|
||||
|
||||
The app `arguments` are app dependent. Check the app's documentation for what arguments it accepts.
|
||||
|
||||
##### allowNonzeroExitCode
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `false`
|
||||
|
||||
Allow the opened app to exit with nonzero exit code when the `wait` option is `true`.
|
||||
|
||||
We do not recommend setting this option. The convention for success is exit code zero.
|
||||
|
||||
### openApp(name, options?)
|
||||
|
||||
Open an app.
|
||||
|
||||
Returns a promise for the [spawned child process](https://nodejs.org/api/child_process.html#child_process_class_childprocess). You would normally not need to use this for anything, but it can be useful if you'd like to attach custom event listeners or perform other operations directly on the spawned process.
|
||||
|
||||
#### name
|
||||
|
||||
Type: `string`
|
||||
|
||||
The app name is platform dependent. Don't hard code it in reusable modules. For example, Chrome is `google chrome` on macOS, `google-chrome` on Linux and `chrome` on Windows. If possible, use [`apps`](#apps) which auto-detects the correct binary to use.
|
||||
|
||||
You may also pass in the app's full path. For example on WSL, this can be `/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe` for the Windows installation of Chrome.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
Same options as [`open`](#options) except `app` and with the following additions:
|
||||
|
||||
##### arguments
|
||||
|
||||
Type: `string[]`\
|
||||
Default: `[]`
|
||||
|
||||
Arguments passed to the app.
|
||||
|
||||
These arguments are app dependent. Check the app's documentation for what arguments it accepts.
|
||||
|
||||
### apps
|
||||
|
||||
An object containing auto-detected binary names for common apps. Useful to work around [cross-platform differences](#app).
|
||||
|
||||
```js
|
||||
import open, {apps} from 'open';
|
||||
|
||||
await open('https://google.com', {
|
||||
app: {
|
||||
name: apps.chrome
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
`browser` and `browserPrivate` can also be used to access the user's default browser through [`default-browser`](https://github.com/sindresorhus/default-browser).
|
||||
|
||||
#### Supported apps
|
||||
|
||||
- [`chrome`](https://www.google.com/chrome) - Web browser
|
||||
- [`firefox`](https://www.mozilla.org/firefox) - Web browser
|
||||
- [`edge`](https://www.microsoft.com/edge) - Web browser
|
||||
- [`brave`](https://brave.com/) - Web browser
|
||||
- `browser` - Default web browser
|
||||
- `browserPrivate` - Default web browser in incognito mode
|
||||
|
||||
`browser` and `browserPrivate` only supports `chrome`, `firefox`, `edge`, and `brave`.
|
||||
|
||||
## WSL (Windows Subsystem for Linux)
|
||||
|
||||
The package automatically uses Windows integration (PowerShell) when available, and falls back to `xdg-open` if PowerShell is inaccessible (e.g., sandboxed environments).
|
||||
|
||||
To use Linux GUI apps instead:
|
||||
|
||||
```javascript
|
||||
await open('https://example.com', {app: {name: 'xdg-open'}});
|
||||
```
|
||||
|
||||
## Related
|
||||
|
||||
- [open-cli](https://github.com/sindresorhus/open-cli) - CLI for this module
|
||||
- [open-editor](https://github.com/sindresorhus/open-editor) - Open files in your editor at a specific line and column
|
||||
- [reveal-file](https://github.com/sindresorhus/reveal-file) - Reveal a file in the system file manager
|
||||
1267
node_modules/open/xdg-open
generated
vendored
Executable file
1267
node_modules/open/xdg-open
generated
vendored
Executable file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user