blink 0.1.52 → 0.1.53
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/dist/cli/auth-DFAAGrh0.js +30 -0
- package/dist/cli/chat-DstkfVtn.js +1 -0
- package/dist/cli/connect-CUOPse6P.js +1 -0
- package/dist/cli/connect-CswVxp7Y.js +26 -0
- package/dist/cli/{dev-DD1tf2AT.js → dev-D5eJ3-13.js} +66 -60
- package/dist/cli/dist-NqrnQGst.js +45 -0
- package/dist/cli/events-CWgtj8lb.js +1 -0
- package/dist/cli/{getMachineId-bsd-CY-GIKzh.js → getMachineId-bsd-C-mIkoX1.js} +1 -1
- package/dist/cli/{getMachineId-darwin-BvUyLisY.js → getMachineId-darwin-BndlBc-C.js} +1 -1
- package/dist/cli/{getMachineId-linux-CaBhu4UD.js → getMachineId-linux-DYz-C3hh.js} +1 -1
- package/dist/cli/{getMachineId-unsupported-DsibGvjs.js → getMachineId-unsupported-CcuIl2b-.js} +1 -1
- package/dist/cli/{getMachineId-win-_QXKq1ge.js → getMachineId-win-KRlx7d-Q.js} +1 -1
- package/dist/cli/index.js +6 -110
- package/dist/cli/init-BsN-peJw.js +80 -0
- package/dist/cli/login-CU2BqznA.js +1 -0
- package/dist/cli/main-DqOlaYW2.js +6 -0
- package/dist/cli/open-CSMQaj0E.js +1 -0
- package/dist/cli/serve-DYwdm-QS.js +1 -0
- package/dist/cli/serve-neuJCuqR.js +60 -0
- package/dist/cli/undici-jJcag_Yq.js +1 -0
- package/package.json +1 -1
- package/dist/cli/main-CiEwxfsi.js +0 -138
- package/dist/cli/undici-DjSrZtb9.js +0 -1
- /package/dist/cli/{devtools-D6beCbGn.js → devtools-BS9tk1Y9.js} +0 -0
- /package/dist/cli/{esm-DiE8Xvft.js → esm-CeJfCMPI.js} +0 -0
- /package/dist/cli/{execAsync-Cr3GNTA4.js → execAsync-q2CSWc1b.js} +0 -0
- /package/dist/cli/{undici-0ADe8h0l.js → undici-BG07ys6c.js} +0 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import{Ie as e,M as t,Se as n,pD as r,ve as i,xe as a}from"./dist-NqrnQGst.js";import{readdir as o,writeFile as s}from"fs/promises";import{basename as c,dirname as l,join as u}from"path";import{spawn as d}from"child_process";async function f(l){l||=process.cwd(),e(`Initializing a new Blink Agent`),(await o(l)).length>0&&(a("You must be in an empty directory to run `blink init`."),process.exit(1));let f=c(l).replace(/[^a-zA-Z0-9]/g,`-`),p;if(process.env.npm_config_user_agent?.includes(`bun/`)?p=`bun`:process.env.npm_config_user_agent?.includes(`pnpm/`)?p=`pnpm`:process.env.npm_config_user_agent?.includes(`yarn/`)?p=`yarn`:process.env.npm_config_user_agent?.includes(`npm/`)&&(p=`npm`),!p){let e=await i({options:[{label:`Bun`,value:`bun`},{label:`NPM`,value:`npm`},{label:`PNPM`,value:`pnpm`},{label:`Yarn`,value:`yarn`}],message:`What package manager do you want to use?`});r(e)&&process.exit(0),p=e}t.info(`Using ${p} as the package manager.`);let m={"package.json":JSON.stringify({name:f,main:`agent.ts`,type:`module`,private:!0}),"agent.ts":`import { convertToModelMessages, streamText, tool } from "ai";
|
|
2
|
+
import * as blink from "blink";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
|
|
5
|
+
export default blink.agent({
|
|
6
|
+
async sendMessages({ messages }) {
|
|
7
|
+
return streamText({
|
|
8
|
+
model: "openai/gpt-oss-120b",
|
|
9
|
+
system: \`You are a basic agent the user will customize.
|
|
10
|
+
|
|
11
|
+
Suggest the user adds tools to the agent. Demonstrate your capabilities with the IP tool.\`,
|
|
12
|
+
messages: convertToModelMessages(messages),
|
|
13
|
+
tools: {
|
|
14
|
+
get_ip_info: tool({
|
|
15
|
+
description: "Get IP address information of the computer.",
|
|
16
|
+
inputSchema: z.object({}),
|
|
17
|
+
execute: async () => {
|
|
18
|
+
const response = await fetch("https://ipinfo.io/json");
|
|
19
|
+
return response.json();
|
|
20
|
+
},
|
|
21
|
+
})
|
|
22
|
+
},
|
|
23
|
+
})
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
`,".gitignore":`# dependencies
|
|
27
|
+
node_modules
|
|
28
|
+
|
|
29
|
+
# config and build
|
|
30
|
+
.blink
|
|
31
|
+
|
|
32
|
+
# dotenv environment variables file
|
|
33
|
+
.env
|
|
34
|
+
.env.*
|
|
35
|
+
|
|
36
|
+
# Finder (MacOS) folder config
|
|
37
|
+
.DS_Store
|
|
38
|
+
`,".env.local":`
|
|
39
|
+
# Store local environment variables here.
|
|
40
|
+
# They will be used by blink dev for development.
|
|
41
|
+
# EXTERNAL_SERVICE_API_KEY=
|
|
42
|
+
`,".env.production":`
|
|
43
|
+
# Store production environment variables here.
|
|
44
|
+
# They will be upserted as secrets on blink deploy.
|
|
45
|
+
# EXTERNAL_SERVICE_API_KEY=
|
|
46
|
+
`,"AGENTS.md":`Assist the user in developing an agent.
|
|
47
|
+
|
|
48
|
+
- Use AI SDK v5 for tool-call syntax (inputSchema instead of parameters).
|
|
49
|
+
- Store local environment secrets in .env.local.
|
|
50
|
+
- Store production environment secrets in .env.production.
|
|
51
|
+
- Run "blink deploy" to deploy an agent to the cloud.
|
|
52
|
+
- Run "blink deploy --prod" to deploy to production.
|
|
53
|
+
- The user can run "blink dev" to start a development server.
|
|
54
|
+
`,"tsconfig.json":`{
|
|
55
|
+
"compilerOptions": {
|
|
56
|
+
"lib": ["ESNext"],
|
|
57
|
+
"target": "ESNext",
|
|
58
|
+
"module": "Preserve",
|
|
59
|
+
"moduleDetection": "force",
|
|
60
|
+
|
|
61
|
+
"moduleResolution": "bundler",
|
|
62
|
+
"allowImportingTsExtensions": true,
|
|
63
|
+
"verbatimModuleSyntax": true,
|
|
64
|
+
"resolveJsonModule": true,
|
|
65
|
+
"noEmit": true,
|
|
66
|
+
|
|
67
|
+
"strict": true,
|
|
68
|
+
"skipLibCheck": true,
|
|
69
|
+
"noFallthroughCasesInSwitch": true,
|
|
70
|
+
"noUncheckedIndexedAccess": true,
|
|
71
|
+
"noImplicitOverride": true,
|
|
72
|
+
|
|
73
|
+
"noUnusedLocals": false,
|
|
74
|
+
"noUnusedParameters": false,
|
|
75
|
+
|
|
76
|
+
"types": ["node"]
|
|
77
|
+
}
|
|
78
|
+
}`};await Promise.all(Object.entries(m).map(async([e,t])=>{await s(u(l,e),t)})),console.log(``);let h=d(p,[`install`,`--save-dev`,`zod`,`ai`,`blink`,`esbuild`,`@types/node`],{stdio:`inherit`,cwd:l});await new Promise((e,t)=>{h.on(`close`,t=>{t===0&&e(void 0)}),h.on(`error`,e=>{t(e)})}),console.log(``),t.success(`To get started, run:
|
|
79
|
+
|
|
80
|
+
${p} blink dev`),n(`Edit agent.ts to hot-reload your agent.`)}export{f as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{login as e}from"./auth-DFAAGrh0.js";import"./dist-NqrnQGst.js";import"./open-CSMQaj0E.js";async function t(){await e()}export{t as default};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{__commonJSMin as e,__require as t}from"./chunk-ByIbJXPc.js";import{mkdir as n,readFile as r,stat as i,writeFile as a}from"fs/promises";import{dirname as o,join as s,relative as c}from"path";import{builtinModules as l}from"module";async function u(e,{outdir:t}={}){t||=await p(e);let n=s(t,`agent.js`),r=g(),i=await r.build({...h,entryPoints:[e],outfile:n,write:!1});if(i.errors.length>0)throw Error(`Failed to build agent!`);let o=i.outputFiles[0];return await a(n,Buffer.from(o.contents),`utf-8`),{outfile:n}}async function d(e,{onErrors:t,onBuildStart:n,onBuildEnd:r,outdir:i}){let o=g();i||=await p(e);let c=s(i,`agent.js`),l=await o.context({...h,entryPoints:[e],logLevel:`silent`,outfile:c,plugins:[...h.plugins??[],{name:`blink-dev-server`,setup(e){e.onStart(()=>{n?.()}),e.onEnd(async e=>{if(e.errors.length>0){t?.(e.errors);return}let n=e.outputFiles[0];await a(c,Buffer.from(n.contents),`utf-8`),r?.({outfile:c})})}}],write:!1});return await l.watch(),{dispose:()=>{l.dispose()}}}async function f(e){let t=await m(e,`package.json`);if(!t)throw Error(`No package.json found in ${e}`);let n=JSON.parse(await r(t,`utf-8`)),a=n.main;if(!a)throw Error(`"main" is not set in ${c(process.cwd(),t)}. It should be set to the entrypoint of your agent.`);let l=s(o(t),a),u=await i(l);if(!u.isFile())throw Error(`${l} is not a file.`);return l}async function p(e){let t=await m(e,`node_modules`);if(!t){let t=await i(e);return t.isDirectory()?s(e,`.blink`):s(o(e),`.blink`)}let r=s(t,`.blink`);return await n(r,{recursive:!0}),r}async function m(e,t){let n=e;for(;n!==o(n);){let e=s(n,t);try{return await i(e),e}catch{}n=o(n)}}const h={bundle:!0,format:`esm`,platform:`node`,target:`node22`,mainFields:[`module`,`main`],conditions:[`import`,`module`],plugins:[{name:`blink-esm-require-to-import`,setup(e){e.onEnd(t=>{e.initialOptions.format!==`esm`||e.initialOptions.platform!==`node`||t.outputFiles?.forEach(e=>{if(e.path.endsWith(`.js`)||e.path.endsWith(`.mjs`)){let t=Buffer.from(e.contents).toString(`utf-8`),n=new Map,r=RegExp(`\\b__require\\("(${l.join(`|`)})"\\)`,`gm`);if(t=t.replace(r,(e,t)=>{let r=`__import_${t.toUpperCase().replace(/-/g,`_`)}`;return n.set(t,r),r}),n.size>0){let e=Array.from(n.entries()).map(([e,t])=>`import ${t} from "${e}";`).join(`
|
|
2
|
+
`);t=e+`
|
|
3
|
+
|
|
4
|
+
`+t}e.contents=Buffer.from(t,`utf-8`)}})})}}]},g=()=>{try{return t(`esbuild`)}catch{throw Error("esbuild is not installed. Please install it with `bun add esbuild`.")}};var _=e(((exports,t)=>{t.exports={name:`dotenv`,version:`16.4.7`,description:`Loads environment variables from .env file`,main:`lib/main.js`,types:`lib/main.d.ts`,exports:{".":{types:`./lib/main.d.ts`,require:`./lib/main.js`,default:`./lib/main.js`},"./config":`./config.js`,"./config.js":`./config.js`,"./lib/env-options":`./lib/env-options.js`,"./lib/env-options.js":`./lib/env-options.js`,"./lib/cli-options":`./lib/cli-options.js`,"./lib/cli-options.js":`./lib/cli-options.js`,"./package.json":`./package.json`},scripts:{"dts-check":`tsc --project tests/types/tsconfig.json`,lint:`standard`,pretest:`npm run lint && npm run dts-check`,test:`tap run --allow-empty-coverage --disable-coverage --timeout=60000`,"test:coverage":`tap run --show-full-coverage --timeout=60000 --coverage-report=lcov`,prerelease:`npm test`,release:`standard-version`},repository:{type:`git`,url:`git://github.com/motdotla/dotenv.git`},funding:`https://dotenvx.com`,keywords:[`dotenv`,`env`,`.env`,`environment`,`variables`,`config`,`settings`],readmeFilename:`README.md`,license:`BSD-2-Clause`,devDependencies:{"@types/node":`^18.11.3`,decache:`^4.6.2`,sinon:`^14.0.1`,standard:`^17.0.0`,"standard-version":`^9.5.0`,tap:`^19.2.0`,typescript:`^4.8.4`},engines:{node:`>=12`},browser:{fs:!1}}})),v=e(((exports,n)=>{let r=t(`fs`),i=t(`path`),a=t(`os`),o=t(`crypto`),s=_(),c=s.version,l=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function u(e){let t={},n=e.toString();n=n.replace(/\r\n?/gm,`
|
|
5
|
+
`);let r;for(;(r=l.exec(n))!=null;){let e=r[1],n=r[2]||``;n=n.trim();let i=n[0];n=n.replace(/^(['"`])([\s\S]*)\1$/gm,`$2`),i===`"`&&(n=n.replace(/\\n/g,`
|
|
6
|
+
`),n=n.replace(/\\r/g,`\r`)),t[e]=n}return t}function d(e){let t=v(e),n=T.configDotenv({path:t});if(!n.parsed){let e=Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw e.code=`MISSING_DATA`,e}let r=h(e).split(`,`),i=r.length,a;for(let e=0;e<i;e++)try{let t=r[e].trim(),i=g(n,t);a=T.decrypt(i.ciphertext,i.key);break}catch(t){if(e+1>=i)throw t}return T.parse(a)}function f(e){console.log(`[dotenv@${c}][INFO] ${e}`)}function p(e){console.log(`[dotenv@${c}][WARN] ${e}`)}function m(e){console.log(`[dotenv@${c}][DEBUG] ${e}`)}function h(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:``}function g(e,t){let n;try{n=new URL(t)}catch(e){if(e.code===`ERR_INVALID_URL`){let e=Error(`INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development`);throw e.code=`INVALID_DOTENV_KEY`,e}throw e}let r=n.password;if(!r){let e=Error(`INVALID_DOTENV_KEY: Missing key part`);throw e.code=`INVALID_DOTENV_KEY`,e}let i=n.searchParams.get(`environment`);if(!i){let e=Error(`INVALID_DOTENV_KEY: Missing environment part`);throw e.code=`INVALID_DOTENV_KEY`,e}let a=`DOTENV_VAULT_${i.toUpperCase()}`,o=e.parsed[a];if(!o){let e=Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${a} in your .env.vault file.`);throw e.code=`NOT_FOUND_DOTENV_ENVIRONMENT`,e}return{ciphertext:o,key:r}}function v(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let n of e.path)r.existsSync(n)&&(t=n.endsWith(`.vault`)?n:`${n}.vault`);else t=e.path.endsWith(`.vault`)?e.path:`${e.path}.vault`;else t=i.resolve(process.cwd(),`.env.vault`);return r.existsSync(t)?t:null}function y(e){return e[0]===`~`?i.join(a.homedir(),e.slice(1)):e}function b(e){f(`Loading env from encrypted .env.vault`);let t=T._parseVault(e),n=process.env;return e&&e.processEnv!=null&&(n=e.processEnv),T.populate(n,t,e),{parsed:t}}function x(e){let t=i.resolve(process.cwd(),`.env`),n=`utf8`,a=!!(e&&e.debug);e&&e.encoding?n=e.encoding:a&&m(`No encoding is specified. UTF-8 is used by default`);let o=[t];if(e&&e.path)if(!Array.isArray(e.path))o=[y(e.path)];else{o=[];for(let t of e.path)o.push(y(t))}let s,c={};for(let t of o)try{let i=T.parse(r.readFileSync(t,{encoding:n}));T.populate(c,i,e)}catch(e){a&&m(`Failed to load ${t} ${e.message}`),s=e}let l=process.env;return e&&e.processEnv!=null&&(l=e.processEnv),T.populate(l,c,e),s?{parsed:c,error:s}:{parsed:c}}function S(e){if(h(e).length===0)return T.configDotenv(e);let t=v(e);return t?T._configVault(e):(p(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`),T.configDotenv(e))}function C(e,t){let n=Buffer.from(t.slice(-64),`hex`),r=Buffer.from(e,`base64`),i=r.subarray(0,12),a=r.subarray(-16);r=r.subarray(12,-16);try{let e=o.createDecipheriv(`aes-256-gcm`,n,i);return e.setAuthTag(a),`${e.update(r)}${e.final()}`}catch(e){let t=e instanceof RangeError,n=e.message===`Invalid key length`,r=e.message===`Unsupported state or unable to authenticate data`;if(t||n){let e=Error(`INVALID_DOTENV_KEY: It must be 64 characters long (or more)`);throw e.code=`INVALID_DOTENV_KEY`,e}else if(r){let e=Error(`DECRYPTION_FAILED: Please check your DOTENV_KEY`);throw e.code=`DECRYPTION_FAILED`,e}else throw e}}function w(e,t,n={}){let r=!!(n&&n.debug),i=!!(n&&n.override);if(typeof t!=`object`){let e=Error(`OBJECT_REQUIRED: Please check the processEnv argument being passed to populate`);throw e.code=`OBJECT_REQUIRED`,e}for(let n of Object.keys(t))Object.prototype.hasOwnProperty.call(e,n)?(i===!0&&(e[n]=t[n]),r&&m(i===!0?`"${n}" is already defined and WAS overwritten`:`"${n}" is already defined and was NOT overwritten`)):e[n]=t[n]}let T={configDotenv:x,_configVault:b,_parseVault:d,config:S,decrypt:C,parse:u,populate:w};n.exports.configDotenv=T.configDotenv,n.exports._configVault=T._configVault,n.exports._parseVault=T._parseVault,n.exports.config=T.config,n.exports.decrypt=T.decrypt,n.exports.parse=T.parse,n.exports.populate=T.populate,n.exports=T}));export{u as build,m as findNearestEntry,v as require_main,f as resolveEntrypoint,d as watch};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import e,{execFile as t}from"node:child_process";import n from"node:path";import r from"node:fs";import i from"node:process";import a,{constants as o}from"node:fs/promises";import s from"node:os";import{promisify as c}from"node:util";import{Buffer as l}from"node:buffer";import{fileURLToPath as u}from"node:url";let d;function f(){try{return r.statSync(`/.dockerenv`),!0}catch{return!1}}function p(){try{return r.readFileSync(`/proc/self/cgroup`,`utf8`).includes(`docker`)}catch{return!1}}function m(){return d===void 0&&(d=f()||p()),d}let h;const g=()=>{try{return r.statSync(`/run/.containerenv`),!0}catch{return!1}};function _(){return h===void 0&&(h=g()||m()),h}const v=()=>{if(i.platform!==`linux`)return!1;if(s.release().toLowerCase().includes(`microsoft`))return!_();try{return r.readFileSync(`/proc/version`,`utf8`).toLowerCase().includes(`microsoft`)?!_():!1}catch{return!1}};var y=i.env.__IS_WSL_TEST__?v:v();const b=(()=>{let e=`/mnt/`,t;return async function(){if(t)return t;let n=`/etc/wsl.conf`,r=!1;try{await a.access(n,o.F_OK),r=!0}catch{}if(!r)return e;let i=await a.readFile(n,{encoding:`utf8`}),s=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(i);return s?(t=s.groups.mountPoint.trim(),t=t.endsWith(`/`)?t:`${t}/`,t):e}})(),x=async()=>{let e=await b();return`${e}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`},S=async()=>y?x():`${i.env.SYSTEMROOT||i.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function C(e,t,n){let r=n=>Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0});return Object.defineProperty(e,t,{configurable:!0,enumerable:!0,get(){let e=n();return r(e),e},set(e){r(e)}}),e}const w=c(t);async function T(){if(i.platform!==`darwin`)throw Error(`macOS only`);let{stdout:e}=await w(`defaults`,[`read`,`com.apple.LaunchServices/com.apple.launchservices.secure`,`LSHandlers`]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e);return t?.groups.id??`com.apple.Safari`}const E=c(t);async function D(e,{humanReadableOutput:t=!0}={}){if(i.platform!==`darwin`)throw Error(`macOS only`);let n=t?[]:[`-ss`],{stdout:r}=await E(`osascript`,[`-e`,e,n]);return r.trim()}async function O(e){return D(`tell application "Finder" to set app_path to application file id "${e}" as string\ntell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}const k=c(t),A={AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:`Edge`,id:`com.microsoft.edge.old`},MSEdgeDHTML:{name:`Edge`,id:`com.microsoft.edge`},MSEdgeHTM:{name:`Edge`,id:`com.microsoft.edge`},"IE.HTTP":{name:`Internet Explorer`,id:`com.microsoft.ie`},FirefoxURL:{name:`Firefox`,id:`org.mozilla.firefox`},ChromeHTML:{name:`Chrome`,id:`com.google.chrome`},BraveHTML:{name:`Brave`,id:`com.brave.Browser`},BraveBHTML:{name:`Brave Beta`,id:`com.brave.Browser.beta`},BraveSSHTM:{name:`Brave Nightly`,id:`com.brave.Browser.nightly`}};var j=class extends Error{};async function M(e=k){let{stdout:t}=await e(`reg`,[`QUERY`,` HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice`,`/v`,`ProgId`]),n=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(t);if(!n)throw new j(`Cannot find Windows browser in stdout: ${JSON.stringify(t)}`);let{id:r}=n.groups,i=A[r];if(!i)throw new j(`Unknown browser ID: ${r}`);return i}const N=c(t),P=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,e=>e.toUpperCase());async function F(){if(i.platform===`darwin`){let e=await T(),t=await O(e);return{name:t,id:e}}if(i.platform===`linux`){let{stdout:e}=await N(`xdg-mime`,[`query`,`default`,`x-scheme-handler/http`]),t=e.trim(),n=P(t.replace(/.desktop$/,``).replace(`-`,` `));return{name:n,id:t}}if(i.platform===`win32`)return M();throw Error(`Only macOS, Linux, and Windows are supported`)}const I=c(e.execFile),L=n.dirname(u(import.meta.url)),R=n.join(L,`xdg-open`),{platform:z,arch:B}=i;async function V(){let e=await S(),t=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,n=l.from(t,`utf16le`).toString(`base64`),{stdout:r}=await I(e,[`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`,n],{encoding:`utf8`}),i=r.trim(),a={ChromeHTML:`com.google.chrome`,BraveHTML:`com.brave.Browser`,MSEdgeHTM:`com.microsoft.edge`,FirefoxURL:`org.mozilla.firefox`};return a[i]?{id:a[i]}:{}}const H=async(e,t)=>{let n;for(let r of e)try{return await t(r)}catch(e){n=e}throw n},U=async t=>{if(t={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...t},Array.isArray(t.app))return H(t.app,e=>U({...t,app:e}));let{name:n,arguments:r=[]}=t.app??{};if(r=[...r],Array.isArray(n))return H(n,e=>U({...t,app:{name:e,arguments:r}}));if(n===`browser`||n===`browserPrivate`){let e={"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`},i={chrome:`--incognito`,brave:`--incognito`,firefox:`--private-window`,edge:`--inPrivate`},a=y?await V():await F();if(a.id in e){let o=e[a.id];return n===`browserPrivate`&&r.push(i[o]),U({...t,app:{name:q[o],arguments:r}})}throw Error(`${a.name} is not supported as a default browser`)}let s,c=[],u={};if(z===`darwin`)s=`open`,t.wait&&c.push(`--wait-apps`),t.background&&c.push(`--background`),t.newInstance&&c.push(`--new`),n&&c.push(`-a`,n);else if(z===`win32`||y&&!_()&&!n){s=await S(),c.push(`-NoProfile`,`-NonInteractive`,`-ExecutionPolicy`,`Bypass`,`-EncodedCommand`),y||(u.windowsVerbatimArguments=!0);let e=[`Start`];t.wait&&e.push(`-Wait`),n?(e.push(`"\`"${n}\`""`),t.target&&r.push(t.target)):t.target&&e.push(`"${t.target}"`),r.length>0&&(r=r.map(e=>`"\`"${e}\`""`),e.push(`-ArgumentList`,r.join(`,`))),t.target=l.from(e.join(` `),`utf16le`).toString(`base64`)}else{if(n)s=n;else{let e=!L||L===`/`,t=!1;try{await a.access(R,o.X_OK),t=!0}catch{}let n=i.versions.electron??(z===`android`||e||!t);s=n?`xdg-open`:R}r.length>0&&c.push(...r),t.wait||(u.stdio=`ignore`,u.detached=!0)}z===`darwin`&&r.length>0&&c.push(`--args`,...r),t.target&&c.push(t.target);let d=e.spawn(s,c,u);return t.wait?new Promise((e,n)=>{d.once(`error`,n),d.once(`close`,r=>{if(!t.allowNonzeroExitCode&&r>0){n(Error(`Exited with code ${r}`));return}e(d)})}):(d.unref(),d)},W=(e,t)=>{if(typeof e!=`string`)throw TypeError("Expected a `target`");return U({...t,target:e})};function G(e){if(typeof e==`string`||Array.isArray(e))return e;let{[B]:t}=e;if(!t)throw Error(`${B} is not supported`);return t}function K({[z]:e},{wsl:t}){if(t&&y)return G(t);if(!e)throw Error(`${z} is not supported`);return G(e)}const q={};C(q,`chrome`,()=>K({darwin:`google chrome`,win32:`chrome`,linux:[`google-chrome`,`google-chrome-stable`,`chromium`]},{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`]}})),C(q,`brave`,()=>K({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`]}})),C(q,`firefox`,()=>K({darwin:`firefox`,win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:`firefox`},{wsl:`/mnt/c/Program Files/Mozilla Firefox/firefox.exe`})),C(q,`edge`,()=>K({darwin:`microsoft edge`,win32:`msedge`,linux:[`microsoft-edge`,`microsoft-edge-dev`]},{wsl:`/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe`})),C(q,`browser`,()=>`browser`),C(q,`browserPrivate`,()=>`browserPrivate`);var J=W;export{J as open_default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./esm-CeJfCMPI.js";import"./events-CWgtj8lb.js";import{createServeClient as e,serve as t}from"./serve-neuJCuqR.js";export{e as createServeClient,t as default};
|