@buoy-gg/core 7.0.51 → 7.0.52

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/bin/buoy.js CHANGED
@@ -1,13 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict";const http=require("node:http");const fs=require("node:fs");const path=require("node:path");const crypto=require("node:crypto");const{spawn}=require("node:child_process");const SITE=process.env.BUOY_SITE_URL||"https://buoy.gg";const LOGIN_TIMEOUT_MS=5*60*1e3;const ESC="\x1B[";const color=e=>n=>`${ESC}${e}m${n}${ESC}0m`;const cyan=color(36);const green=color(32);const red=color(31);const dim=color(2);const bold=color(1);function log(e){process.stdout.write(`${e}
3
3
  `)}function fail(e){process.stderr.write(`${red("x")} ${e}
4
- `);process.exit(1)}function openBrowser(e){const n=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open";const t=process.platform==="win32"?["/c","start","",e]:[e];try{spawn(n,t,{stdio:"ignore",detached:true}).unref()}catch{}}function detectEnvVarName(e){let n=null;try{const t=path.join(e,"package.json");if(fs.existsSync(t)){const s=JSON.parse(fs.readFileSync(t,"utf8"));const o=Object.assign({},s.dependencies,s.devDependencies);if(o.expo)return"EXPO_PUBLIC_BUOY_KEY";if(o.next)n="NEXT_PUBLIC_BUOY_KEY";else if(o.vite)n="VITE_BUOY_KEY"}if(fs.existsSync(path.join(e,"app.config.js"))||fs.existsSync(path.join(e,"app.config.ts"))){return"EXPO_PUBLIC_BUOY_KEY"}const i=path.join(e,"app.json");if(fs.existsSync(i)){const s=JSON.parse(fs.readFileSync(i,"utf8"));if(s&&s.expo)return"EXPO_PUBLIC_BUOY_KEY"}}catch{}return n||"BUOY_KEY"}function envFileFor(e,n){if(!["EXPO_PUBLIC_BUOY_KEY","VITE_BUOY_KEY","NEXT_PUBLIC_BUOY_KEY"].includes(e))return".env.local";return n==="pro"||n==="business"?".env.local":".env.development.local"}function removeEnvVar(e,n,t){const i=path.join(e,t);let s;try{s=fs.readFileSync(i,"utf8")}catch{return false}const o=new RegExp("^"+n+"=.*\\n?","m");if(!o.test(s))return false;fs.writeFileSync(i,s.replace(o,""),{mode:384});return true}function writeEnvVar(e,n,t,i=".env.local"){const s=path.join(e,i);let o="";try{o=fs.readFileSync(s,"utf8")}catch{}const a=`${n}=${t}`;const r=new RegExp("^"+n+"=.*$","m");if(r.test(o)){o=o.replace(r,a)}else{if(o&&!o.endsWith("\n"))o+="\n";o+=`${a}
5
- `}fs.writeFileSync(s,o,{mode:384});return s}function ensureGitignored(e,n=".env.local"){const t=path.join(e,".gitignore");let i="";try{i=fs.readFileSync(t,"utf8")}catch{return false}const s=new RegExp("^"+n.replace(/\./g,"\\.")+"$","m");if(s.test(i)||/^\.env\*|^\*\.local$|^\.env\*\.local$/m.test(i))return false;if(i&&!i.endsWith("\n"))i+="\n";i+=`
4
+ `);process.exit(1)}function openBrowser(e){const n=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open";const o=process.platform==="win32"?["/c","start","",e]:[e];try{spawn(n,o,{stdio:"ignore",detached:true}).unref()}catch{}}function detectEnvVarName(e){let n=null;try{const o=path.join(e,"package.json");if(fs.existsSync(o)){const s=JSON.parse(fs.readFileSync(o,"utf8"));const t=Object.assign({},s.dependencies,s.devDependencies);if(t.expo)return"EXPO_PUBLIC_BUOY_KEY";if(t.next)n="NEXT_PUBLIC_BUOY_KEY";else if(t.vite)n="VITE_BUOY_KEY"}if(fs.existsSync(path.join(e,"app.config.js"))||fs.existsSync(path.join(e,"app.config.ts"))){return"EXPO_PUBLIC_BUOY_KEY"}const i=path.join(e,"app.json");if(fs.existsSync(i)){const s=JSON.parse(fs.readFileSync(i,"utf8"));if(s&&s.expo)return"EXPO_PUBLIC_BUOY_KEY"}}catch{}return n||"BUOY_KEY"}function envFileFor(e,n){if(!["EXPO_PUBLIC_BUOY_KEY","VITE_BUOY_KEY","NEXT_PUBLIC_BUOY_KEY"].includes(e))return".env.local";return n==="pro"||n==="business"?".env.local":".env.development.local"}function removeEnvVar(e,n,o){const i=path.join(e,o);let s;try{s=fs.readFileSync(i,"utf8")}catch{return false}const t=new RegExp("^"+n+"=.*\\n?","m");if(!t.test(s))return false;fs.writeFileSync(i,s.replace(t,""),{mode:384});return true}function writeEnvVar(e,n,o,i=".env.local"){const s=path.join(e,i);let t="";try{t=fs.readFileSync(s,"utf8")}catch{}const a=`${n}=${o}`;const r=new RegExp("^"+n+"=.*$","m");if(r.test(t)){t=t.replace(r,a)}else{if(t&&!t.endsWith("\n"))t+="\n";t+=`${a}
5
+ `}fs.writeFileSync(s,t,{mode:384});return s}function ensureGitignored(e,n=".env.local"){const o=path.join(e,".gitignore");let i="";try{i=fs.readFileSync(o,"utf8")}catch{return false}const s=new RegExp("^"+n.replace(/\./g,"\\.")+"$","m");if(s.test(i)||/^\.env\*|^\*\.local$|^\.env\*\.local$/m.test(i))return false;if(i&&!i.endsWith("\n"))i+="\n";i+=`
6
6
  # Buoy license key (per developer - do not commit)
7
7
  ${n}
8
- `;fs.writeFileSync(t,i);return true}function awaitKeyFromBrowser(){return new Promise((e,n)=>{const t=crypto.randomBytes(16).toString("hex");const i=http.createServer((s,o)=>{if(s.headers.origin===SITE){o.setHeader("Access-Control-Allow-Origin",SITE);o.setHeader("Access-Control-Allow-Headers","Content-Type");o.setHeader("Access-Control-Allow-Methods","POST, OPTIONS");o.setHeader("Access-Control-Allow-Private-Network","true")}if(s.method==="OPTIONS"){o.writeHead(204).end();return}if(s.method!=="POST"){o.writeHead(405).end();return}let a="";s.on("data",r=>{a+=r;if(a.length>4096)s.destroy()});s.on("end",()=>{let r={};try{r=JSON.parse(a)}catch{}if(r.state!==t||typeof r.key!=="string"||!r.key){o.writeHead(400).end();return}o.writeHead(200,{"Content-Type":"application/json"});o.end('{"ok":true}');i.close();e({key:r.key.trim(),tier:r.tier||"free",email:r.email||""})})});i.on("error",n);i.listen(0,"127.0.0.1",()=>{const{port:s}=i.address();const o=`${SITE}/cli/login?port=${s}&state=${t}`;log("");log(` Opening ${cyan(o)}`);log(dim(" If your browser did not open, paste that URL into a browser on this computer."));log("");log(dim(" Waiting for you to finish signing in..."));openBrowser(o)});setTimeout(()=>{i.close();n(new Error("Timed out waiting for the browser (5 minutes)."))},LOGIN_TIMEOUT_MS).unref()})}function loadSessionClient(){try{const e=require("@buoy-gg/license/headless");if(typeof e.createNodeSession!=="function")return null;return e}catch{return null}}function cliSession(e){return e.createNodeSession({audience:e.CLI_AUDIENCE,signinOrigin:SITE,openBrowser:n=>{log(`${cyan(">")} Opening ${dim(n.split("?")[0])} to sign in...`);log(dim(` If nothing opens, visit:
9
- ${n}`));openBrowser(n)}})}async function signInAndGetDevToken(){const e=loadSessionClient();if(!e)return null;const n=cliSession(e);if(!await n.isAvailable())return null;await n.signIn();const t=await n.devToken();if(!t.ok){throw new Error(`This computer is signed in to Buoy, but no dev token was made: ${t.detail}`)}return{key:t.token,tier:t.tier,email:"",devToken:true}}async function login(){const e=process.cwd();let n;try{n=await signInAndGetDevToken()||await awaitKeyFromBrowser()}catch(c){fail(`${c.message}
10
- No env file was changed.`);return}const t=detectEnvVarName(e);const i=envFileFor(t,n.devToken?"free":n.tier);const s=writeEnvVar(e,t,n.key,i);const o=i!==".env.local"&&removeEnvVar(e,t,".env.local");const a=ensureGitignored(e,i);const r=path.relative(e,s)||i;log("");log(`${green("OK")} Signed in${n.email?" as "+bold(n.email):""} - ${bold(n.tier)} tier`);log(` Wrote ${cyan(t)} to ${cyan(r)}`);if(n.devToken){log(dim(" It is a dev token: it works in dev builds and sims for 30 days. Then run npx buoy login again."));log(dim(" This computer is signed in to Buoy too. The MCP uses it. Sign out: npx buoy logout"))}if(o)log(dim(` Removed the old ${t} line from .env.local`));if(i===".env.development.local"){log(dim(" This file is loaded in development, keeping the key out of production builds."))}if(a)log(dim(` Added ${i} to .gitignore`));log("");log(" Use it in your app:");log("");if(t==="VITE_BUOY_KEY"){log(cyan(" <FloatingDevTools modules={modules} licenseKey={import.meta.env.VITE_BUOY_KEY} />"));log("");log(dim(" Keep your existing tool modules and providers, then reload the web app."))}else if(t==="NEXT_PUBLIC_BUOY_KEY"){log(cyan(" <FloatingDevTools modules={modules} licenseKey={process.env.NEXT_PUBLIC_BUOY_KEY} />"));log("");log(dim(" Restart next dev so it picks up the new variable."))}else{log(cyan(` Buoy.init({ licenseKey: ${t} });`));log("");log(dim(" Swift: pass the key through BuoyConfig.licenseKey in your development build."));log(dim(" Bare React Native does not load .env.local automatically; wire your existing env loader."))}log("")}async function logout(){const e=loadSessionClient();if(!e)fail("This version of Buoy cannot sign in or out. Update @buoy-gg/core.");const n=cliSession(e);const t=await n.load();await n.signOut();log(t.state==="active"?`${green("OK")} Signed out of Buoy on this computer.`:"This computer was not signed in.");log(dim(" Keys in your env files are not changed."))}async function whoami(){const e=loadSessionClient();if(!e)fail("This version of Buoy cannot sign in. Update @buoy-gg/core.");const n=await cliSession(e).load();if(n.state!=="active"){log("Not signed in. Run: npx buoy login");return}log(`${green("Signed in")} - ${bold(n.claims.tier)} plan${n.grace?dim(" (offline, using the grace period)"):""}`)}function help(){log(`
8
+ `;fs.writeFileSync(o,i);return true}function awaitKeyFromBrowser(){return new Promise((e,n)=>{const o=crypto.randomBytes(16).toString("hex");const i=http.createServer((s,t)=>{if(s.headers.origin===SITE){t.setHeader("Access-Control-Allow-Origin",SITE);t.setHeader("Access-Control-Allow-Headers","Content-Type");t.setHeader("Access-Control-Allow-Methods","POST, OPTIONS");t.setHeader("Access-Control-Allow-Private-Network","true")}if(s.method==="OPTIONS"){t.writeHead(204).end();return}if(s.method!=="POST"){t.writeHead(405).end();return}let a="";s.on("data",r=>{a+=r;if(a.length>4096)s.destroy()});s.on("end",()=>{let r={};try{r=JSON.parse(a)}catch{}if(r.state!==o||typeof r.key!=="string"||!r.key){t.writeHead(400).end();return}t.writeHead(200,{"Content-Type":"application/json"});t.end('{"ok":true}');i.close();e({key:r.key.trim(),tier:r.tier||"free",email:r.email||""})})});i.on("error",n);i.listen(0,"127.0.0.1",()=>{const{port:s}=i.address();const t=`${SITE}/cli/login?port=${s}&state=${o}`;log("");log(` Opening ${cyan(t)}`);log(dim(" If your browser did not open, paste that URL into a browser on this computer."));log("");log(dim(" Waiting for you to finish signing in..."));openBrowser(t)});setTimeout(()=>{i.close();n(new Error("Timed out waiting for the browser (5 minutes)."))},LOGIN_TIMEOUT_MS).unref()})}function loadSessionClient(){try{const e=require("@buoy-gg/license/headless");if(typeof e.createNodeSession!=="function")return null;return e}catch{return null}}function cliSession(e){return e.createNodeSession({audience:e.CLI_AUDIENCE,signinOrigin:SITE,openBrowser:n=>{log(`${cyan(">")} Opening ${dim(n.split("?")[0])} to sign in...`);log(dim(` If nothing opens, visit:
9
+ ${n}`));openBrowser(n)}})}async function signInAndGetDevToken(){const e=loadSessionClient();if(!e)return null;const n=cliSession(e);if(!await n.isAvailable())return null;await n.signIn();const o=await n.devToken();if(!o.ok){throw new Error(`This computer is signed in to Buoy, but no dev token was made: ${o.detail}`)}return{key:o.token,tier:o.tier,email:"",devToken:true}}async function login(){const e=process.cwd();let n;try{n=await signInAndGetDevToken()||await awaitKeyFromBrowser()}catch(c){fail(`${c.message}
10
+ No env file was changed.`);return}const o=detectEnvVarName(e);const i=envFileFor(o,n.devToken?"free":n.tier);const s=writeEnvVar(e,o,n.key,i);const t=i!==".env.local"&&removeEnvVar(e,o,".env.local");const a=ensureGitignored(e,i);const r=path.relative(e,s)||i;log("");log(`${green("OK")} Signed in${n.email?" as "+bold(n.email):""} - ${bold(n.tier)} tier`);log(` Wrote ${cyan(o)} to ${cyan(r)}`);if(n.devToken){log(dim(" It is a dev token: it works in dev builds and sims for 30 days. Then run npx buoy login again."));log(dim(" This computer is signed in to Buoy too. The MCP uses it. Sign out: npx buoy logout"))}if(t)log(dim(` Removed the old ${o} line from .env.local`));if(i===".env.development.local"){log(dim(" This file is loaded in development, keeping the key out of production builds."))}if(a)log(dim(` Added ${i} to .gitignore`));log("");log(" Use it in your app:");log("");if(o==="VITE_BUOY_KEY"){log(cyan(" <FloatingDevTools modules={modules} licenseKey={import.meta.env.VITE_BUOY_KEY} />"));log("");log(dim(" Keep your existing tool modules and providers, then reload the web app."))}else if(o==="NEXT_PUBLIC_BUOY_KEY"){log(cyan(" <FloatingDevTools modules={modules} licenseKey={process.env.NEXT_PUBLIC_BUOY_KEY} />"));log("");log(dim(" Restart next dev so it picks up the new variable."))}else{log(cyan(` Buoy.init({ licenseKey: ${o} });`));log("");log(dim(" Swift: pass the key through BuoyConfig.licenseKey in your development build."));log(dim(" Bare React Native does not load .env.local automatically; wire your existing env loader."))}log("")}async function logout(){const e=loadSessionClient();if(!e)fail("This version of Buoy cannot sign in or out. Update @buoy-gg/core.");const n=cliSession(e);const o=await n.load();await n.signOut();log(o.state==="active"?`${green("OK")} Signed out of Buoy on this computer.`:"This computer was not signed in.");log(dim(" Keys in your env files are not changed."))}async function whoami(){const e=loadSessionClient();if(!e)fail("This version of Buoy cannot sign in. Update @buoy-gg/core.");const n=await cliSession(e).load();if(n.state!=="active"){log("Not signed in. Run: npx buoy login");return}log(`${green("Signed in")} - ${bold(n.claims.tier)} plan${n.grace?dim(" (offline, using the grace period)"):""}`)}function help(){log(`
11
11
  ${bold("buoy")} - React Buoy CLI
12
12
 
13
13
  ${bold("Usage")}
@@ -16,17 +16,18 @@ ${n}
16
16
  ${dim("(if npx picks the wrong one)")}
17
17
 
18
18
  ${bold("Commands")}
19
- login Sign in and write your license key to an env file
19
+ login Sign in and write a dev token to an env file
20
20
  logout Sign this computer out of Buoy
21
21
  whoami Show whether this computer is signed in
22
22
  help Show this message
23
23
 
24
24
  ${bold("Notes")}
25
- Run login from your app directory. Complete browser sign-in to receive
26
- your account key. Expo uses EXPO_PUBLIC_BUOY_KEY, Vite uses VITE_BUOY_KEY
27
- and Next.js uses NEXT_PUBLIC_BUOY_KEY. For these, a free key goes to
28
- .env.development.local and a paid key goes to .env.local. Other projects receive BUOY_KEY in .env.local and must
29
- configure their own environment loader and variable mapping.
25
+ Run login from your app directory and click Allow in the browser. You get
26
+ a dev token that works in dev builds for 30 days. Expo uses
27
+ EXPO_PUBLIC_BUOY_KEY, Vite uses VITE_BUOY_KEY and Next.js uses
28
+ NEXT_PUBLIC_BUOY_KEY, all in .env.development.local. Other projects get
29
+ BUOY_KEY in .env.local and must pass it in with their own env loader.
30
+ For test and store builds, use Sign in with Buoy or a key instead.
30
31
  This command does not install tools or verify a Desktop connection.
31
32
 
32
33
  Docs: ${SITE}/buoy/latest/docs/installation
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;const SDK_VERSION=exports.SDK_VERSION="7.0.51";
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.SDK_VERSION=void 0;const SDK_VERSION=exports.SDK_VERSION="7.0.52";
@@ -1 +1 @@
1
- "use strict";export const SDK_VERSION="7.0.51";
1
+ "use strict";export const SDK_VERSION="7.0.52";
@@ -9,5 +9,5 @@
9
9
  * Drift is prevented by a test that fails when this disagrees with
10
10
  * package.json, so a version bump that forgets this file cannot ship.
11
11
  */
12
- export declare const SDK_VERSION = "7.0.51";
12
+ export declare const SDK_VERSION = "7.0.52";
13
13
  //# sourceMappingURL=version.d.ts.map
@@ -9,5 +9,5 @@
9
9
  * Drift is prevented by a test that fails when this disagrees with
10
10
  * package.json, so a version bump that forgets this file cannot ship.
11
11
  */
12
- export declare const SDK_VERSION = "7.0.51";
12
+ export declare const SDK_VERSION = "7.0.52";
13
13
  //# sourceMappingURL=version.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@buoy-gg/core",
3
- "version": "7.0.51",
3
+ "version": "7.0.52",
4
4
  "description": "Floating developer menu and account setup for React Native. Add tool packages and configure Desktop or MCP connections separately.",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",
@@ -61,10 +61,10 @@
61
61
  ],
62
62
  "dependencies": {
63
63
  "react-devtools-core": "6.1.5",
64
- "@buoy-gg/floating-tools-core": "^7.0.51",
65
- "@buoy-gg/license": "^7.0.51",
66
- "@buoy-gg/floating-tools-react": "^7.0.51",
67
- "@buoy-gg/shared-ui": "^7.0.51"
64
+ "@buoy-gg/floating-tools-core": "^7.0.52",
65
+ "@buoy-gg/license": "^7.0.52",
66
+ "@buoy-gg/floating-tools-react": "^7.0.52",
67
+ "@buoy-gg/shared-ui": "^7.0.52"
68
68
  },
69
69
  "peerDependencies": {
70
70
  "react": "*"