@buoy-gg/core 7.0.74 → 7.0.75
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 +5 -5
- package/bundlers/vite.d.ts +11 -4
- package/bundlers/vite.mjs +4 -4
- package/lib/commonjs/floatingMenu/AppHost.web.js +1 -1
- package/lib/commonjs/floatingMenu/DevToolsSettingsModal.shared.js +1 -1
- package/lib/commonjs/floatingMenu/FloatingDevTools.js +1 -1
- package/lib/commonjs/floatingMenu/FloatingDevTools.web.js +1 -1
- package/lib/commonjs/floatingMenu/FloatingMenu.js +1 -1
- package/lib/commonjs/floatingMenu/TeamToolCloser.js +1 -0
- package/lib/commonjs/floatingMenu/dial/DialDevTools.js +1 -1
- package/lib/commonjs/floatingMenu/dial/DialDevTools.web.js +1 -1
- package/lib/commonjs/floatingMenu/teamToolsNote.js +1 -0
- package/lib/commonjs/telemetry/installPing.js +1 -1
- package/lib/commonjs/version.js +1 -1
- package/lib/module/floatingMenu/AppHost.web.js +1 -1
- package/lib/module/floatingMenu/DevToolsSettingsModal.shared.js +1 -1
- package/lib/module/floatingMenu/FloatingDevTools.js +1 -1
- package/lib/module/floatingMenu/FloatingDevTools.web.js +1 -1
- package/lib/module/floatingMenu/FloatingMenu.js +1 -1
- package/lib/module/floatingMenu/TeamToolCloser.js +1 -0
- package/lib/module/floatingMenu/dial/DialDevTools.js +1 -1
- package/lib/module/floatingMenu/dial/DialDevTools.web.js +1 -1
- package/lib/module/floatingMenu/teamToolsNote.js +1 -0
- package/lib/module/telemetry/installPing.js +1 -1
- package/lib/module/version.js +1 -1
- package/lib/typescript/commonjs/Buoy.d.ts +2 -0
- package/lib/typescript/commonjs/floatingMenu/FloatingMenu.d.ts +2 -0
- package/lib/typescript/commonjs/floatingMenu/TeamToolCloser.d.ts +13 -0
- package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.d.ts +2 -0
- package/lib/typescript/commonjs/floatingMenu/dial/DialDevTools.web.d.ts +3 -1
- package/lib/typescript/commonjs/floatingMenu/teamToolsNote.d.ts +6 -0
- package/lib/typescript/commonjs/version.d.ts +1 -1
- package/lib/typescript/module/Buoy.d.ts +2 -0
- package/lib/typescript/module/floatingMenu/FloatingMenu.d.ts +2 -0
- package/lib/typescript/module/floatingMenu/TeamToolCloser.d.ts +13 -0
- package/lib/typescript/module/floatingMenu/dial/DialDevTools.d.ts +2 -0
- package/lib/typescript/module/floatingMenu/dial/DialDevTools.web.d.ts +3 -1
- package/lib/typescript/module/floatingMenu/teamToolsNote.d.ts +6 -0
- package/lib/typescript/module/version.d.ts +1 -1
- package/lib/web/auto.mjs +1 -1
- package/lib/web/chunks/FloatingDevTools.web-NMBTDON7.mjs +1 -0
- package/lib/web/chunks/chunk-2N5IPIMV.mjs +10 -0
- package/lib/web/chunks/chunk-C6HZO5XT.mjs +1 -0
- package/lib/web/chunks/chunk-LU4GPZ5L.mjs +2 -2
- package/lib/web/chunks/chunk-RBPDZUHO.mjs +1 -1
- package/lib/web/chunks/chunk-V4BVRDHL.mjs +1 -0
- package/lib/web/chunks/chunk-Z6I7ZD34.mjs +1 -1
- package/lib/web/index.mjs +1 -1
- package/lib/web/toolkit.mjs +1 -1
- package/package.json +5 -5
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);const yellow=color(33);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
|
|
5
|
-
`}fs.writeFileSync(t,
|
|
4
|
+
`);process.exit(1)}function openBrowser(e){const n=process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open";const s=process.platform==="win32"?["/c","start","",e]:[e];try{const o=spawn(n,s,{stdio:"ignore",detached:true});o.on("error",()=>{});o.unref()}catch{}}function listsDependency(e,n){try{const s=JSON.parse(fs.readFileSync(path.join(e,"package.json"),"utf8"));return Boolean(Object.assign({},s.dependencies,s.devDependencies)[n])}catch{return false}}function viteKeySnippet(e){if(listsDependency(e,"@buoy-gg/solid")){return{code:" <Buoy />",note:"Buoy for Solid reads VITE_BUOY_KEY for you. Reload the app."}}if(listsDependency(e,"@buoy-gg/vue")){if(listsDependency(e,"nuxt")){return{code:" modules: ['@buoy-gg/vue/nuxt'],",note:"Buoy for Nuxt reads VITE_BUOY_KEY for you. Restart the dev server."}}return{code:" createApp(App).use(buoy).mount('#app')",note:"Buoy for Vue reads VITE_BUOY_KEY for you. Restart the dev server."}}return{code:" <FloatingDevTools modules={modules} licenseKey={import.meta.env.VITE_BUOY_KEY} />",note:"Keep your existing tool modules and providers, then reload the web app."}}function detectEnvVarName(e){let n=null;try{const s=path.join(e,"package.json");if(fs.existsSync(s)){const t=JSON.parse(fs.readFileSync(s,"utf8"));const i=Object.assign({},t.dependencies,t.devDependencies);if(i.expo)return"EXPO_PUBLIC_BUOY_KEY";if(i.nuxt)return"VITE_BUOY_KEY";if(i.next)n="NEXT_PUBLIC_BUOY_KEY";else if(i.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 o=path.join(e,"app.json");if(fs.existsSync(o)){const t=JSON.parse(fs.readFileSync(o,"utf8"));if(t&&t.expo)return"EXPO_PUBLIC_BUOY_KEY"}}catch{}return n||"BUOY_KEY"}function isMauiProject(e){try{return fs.readdirSync(e).filter(n=>n.endsWith(".csproj")).some(n=>/<UseMaui>\s*true\s*<\/UseMaui>/i.test(fs.readFileSync(path.join(e,n),"utf8")))}catch{return false}}const ANGULAR_KEY_HEADER="// Buoy key file. Do not commit this file.\n";function angularKeyFile(e,n){const s=path.join(e,"angular.json");if(!fs.existsSync(s))return null;const o=fs.readFileSync(s,"utf8").replace(/"(?:\\.|[^"\\])*"|\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/g,d=>d.startsWith('"')?d:" ").replace(/"(?:\\.|[^"\\])*"|,(\s*[}\]])/g,(d,p)=>p||d);const t=JSON.parse(o);const i=Object.entries(t.projects||{}).filter(([,d])=>d.projectType==="application");const r=n||t.defaultProject;const c=r?t.projects[r]:i.length===1?i[0][1]:null;if(!c||c.projectType!=="application")throw new Error("Pass --project <name> to pick one Angular app.");const a=path.resolve(e,c.sourceRoot||path.join(c.root||"","src"),"environments/buoy.ts");const l=path.relative(e,a);if(l.startsWith("..")||path.isAbsolute(l))throw new Error("The app source root must be in this workspace.");if(fs.existsSync(a)&&!fs.readFileSync(a,"utf8").startsWith(ANGULAR_KEY_HEADER)){throw new Error("The Buoy key file has your code in it. Move it before you run login.")}return l}function writeAngularKey(e,n,s,o){const t=angularKeyFile(e,o);if(!t)return null;const i=path.join(e,t);const r=JSON.stringify(n);const c=ANGULAR_KEY_HEADER+(s?'declare const ngDevMode: boolean | undefined;\nexport const BUOY_KEY = (typeof ngDevMode === "undefined" || ngDevMode) ? '+r+' : "";\n':"export const BUOY_KEY = "+r+";\n");fs.mkdirSync(path.dirname(i),{recursive:true});fs.writeFileSync(i,c,{mode:384});if(!fs.existsSync(path.join(e,".gitignore")))fs.writeFileSync(path.join(e,".gitignore"),"",{flag:"wx"});ensureGitignored(e,t);return t}function envFileFor(e,n,s=false){if(!s&&!["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,s){const o=path.join(e,s);let t;try{t=fs.readFileSync(o,"utf8")}catch{return false}const i=new RegExp("^"+n+"=.*\\n?","m");if(!i.test(t))return false;fs.writeFileSync(o,t.replace(i,""),{mode:384});return true}function writeEnvVar(e,n,s,o=".env.local"){const t=path.join(e,o);let i="";try{i=fs.readFileSync(t,"utf8")}catch{}const r=`${n}=${s}`;const c=new RegExp("^"+n+"=.*$","m");if(c.test(i)){i=i.replace(c,r)}else{if(i&&!i.endsWith("\n"))i+="\n";i+=`${r}
|
|
5
|
+
`}fs.writeFileSync(t,i,{mode:384});return t}function ensureGitignored(e,n=".env.local"){const s=path.join(e,".gitignore");let o="";try{o=fs.readFileSync(s,"utf8")}catch{return false}const t=new RegExp("^"+n.replace(/\./g,"\\.")+"$","m");if(t.test(o)||n.startsWith(".env")&&/^\.env\*$|^\.env\*\.local$/m.test(o)||n.endsWith(".local")&&/^\*\.local$/m.test(o))return false;if(o&&!o.endsWith("\n"))o+="\n";o+=`
|
|
6
6
|
# Buoy license key (per developer - do not commit)
|
|
7
7
|
${n}
|
|
8
|
-
`;fs.writeFileSync(
|
|
9
|
-
${n}`));openBrowser(n)}})}async function checkSignIn(e){if(typeof e.checkAvailability==="function")return e.checkAvailability();return await e.isAvailable()?{state:"enabled"}:{state:"unknown"}}async function signInAndGetDevToken(e=loadSessionClient()){if(!e)return{fallback:{state:"unsupported",computerSignedIn:false}};const n=cliSession(e);const
|
|
10
|
-
No env file was changed.`);return}const r=o?"BUOY_KEY":detectEnvVarName(e);const c=isMauiProject(e);const a=envFileFor(r,t.devToken?"free":t.tier,c||!!o);const
|
|
8
|
+
`;fs.writeFileSync(s,o);return true}const KEY_NAMES=["BUOY_LICENSE_KEY","BUOY_KEY","EXPO_PUBLIC_BUOY_KEY","VITE_BUOY_KEY","NEXT_PUBLIC_BUOY_KEY","REACT_APP_BUOY_KEY"];function findProjectKey(e,n=process.env){for(const s of KEY_NAMES){if(n[s]!==void 0){const o=n[s].trim();return o?{name:s,source:"environment",value:o}:null}}for(const s of[".env.development.local",".env.local",".env"]){let o;try{o=fs.readFileSync(path.join(e,s),"utf8")}catch{continue}const t=new Map;for(const i of o.split(/\r?\n/)){const r=i.match(/^\s*(?:export\s+)?([A-Z_][A-Z_0-9]*)\s*=\s*(.*)$/);if(!r)continue;const c=r[2].trim();const a=c.match(/^(['"])(.*?)\1\s*(?:#.*)?$/);t.set(r[1],a?a[2]:c.split("#")[0].trim())}for(const i of KEY_NAMES){if(!t.has(i))continue;const r=t.get(i).trim();return r?{name:i,source:s,value:r}:null}}return null}function awaitKeyFromBrowser(){return new Promise((e,n)=>{const s=crypto.randomBytes(16).toString("hex");const o=http.createServer((t,i)=>{if(t.headers.origin===SITE){i.setHeader("Access-Control-Allow-Origin",SITE);i.setHeader("Access-Control-Allow-Headers","Content-Type");i.setHeader("Access-Control-Allow-Methods","POST, OPTIONS");i.setHeader("Access-Control-Allow-Private-Network","true")}if(t.method==="OPTIONS"){i.writeHead(204).end();return}if(t.method!=="POST"){i.writeHead(405).end();return}let r="";t.on("data",c=>{r+=c;if(r.length>4096)t.destroy()});t.on("end",()=>{let c={};try{c=JSON.parse(r)}catch{}if(c.state!==s||typeof c.key!=="string"||!c.key){i.writeHead(400).end();return}i.writeHead(200,{"Content-Type":"application/json"});i.end('{"ok":true}');o.close();e({key:c.key.trim(),tier:c.tier||"free",email:c.email||""})})});o.on("error",n);o.listen(0,"127.0.0.1",()=>{const{port:t}=o.address();const i=`${SITE}/cli/login?port=${t}&state=${s}`;log("");log(` Opening ${cyan(i)}`);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(i)});setTimeout(()=>{o.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 checkSignIn(e){if(typeof e.checkAvailability==="function")return e.checkAvailability();return await e.isAvailable()?{state:"enabled"}:{state:"unknown"}}async function signInAndGetDevToken(e=loadSessionClient()){if(!e)return{fallback:{state:"unsupported",computerSignedIn:false}};const n=cliSession(e);const s=await checkSignIn(n);if(s.state!=="enabled"){const t=await n.load().catch(()=>null);return{fallback:{...s,computerSignedIn:Boolean(t&&t.state==="active")}}}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{result:{key:o.token,tier:o.tier,email:"",devToken:true}}}function fallbackWarning(e){if(!e)return null;if(e.state==="unknown"){return[`${yellow("!")} This computer could not be signed in. Node may not reach ${SITE}.`," A VPN, proxy or firewall may block it outside your browser."," Update @buoy-gg/license to see the exact reason."]}if(e.state!=="unreachable")return null;const n=[`${yellow("!")} Node could not reach ${SITE} (${e.detail}).`," A VPN, proxy or firewall may block it outside your browser."," The browser can still sign in this project, but not this computer."];if(e.hint)n.push(` ${e.hint}`);return n}function projectOnlyNotes(e,n){const s=e&&e.computerSignedIn?[" This login signed in only this project."," This computer keeps its earlier sign-in, which the MCP uses."," That may be a different account. Check with `npx --package=@buoy-gg/core buoy whoami`."]:[" Only this project is signed in. This computer is not,"," so `npx --package=@buoy-gg/core buoy whoami` will say so.",` The MCP reads the key from ${n} when it runs in this folder.`];if(e&&(e.state==="unreachable"||e.state==="unknown")){s.push(` The MCP checks keys with ${SITE} too, so it needs that to work.`)}return s}async function login(){const e=process.cwd();const n=process.argv.indexOf("--project");const s=n<0?void 0:process.argv[n+1];if(n>=0&&(!s||s.startsWith("--")))throw new Error("Pass a name after --project.");const o=angularKeyFile(e,s);let t;let i=null;try{const u=await signInAndGetDevToken();if(u.result){t=u.result}else{i=u.fallback;const g=fallbackWarning(i);if(g){log("");g.forEach(m=>log(m))}t=await awaitKeyFromBrowser()}}catch(u){fail(`${u.message}
|
|
10
|
+
No env file was changed.`);return}const r=o?"BUOY_KEY":detectEnvVarName(e);const c=isMauiProject(e);const a=envFileFor(r,t.devToken?"free":t.tier,c||!!o);const l=o?writeAngularKey(e,t.key,!!t.devToken||!["pro","business"].includes(t.tier),s):null;const d=writeEnvVar(e,r,t.key,a);const p=a===".env.local"?".env.development.local":".env.local";const y=removeEnvVar(e,r,p);const h=ensureGitignored(e,a);const f=path.relative(e,d)||a;log("");log(`${green("OK")} Signed in${t.email?" as "+bold(t.email):""} - ${bold(t.tier)} tier`);log(` Wrote ${cyan(r)} to ${cyan(f)}`);if(l)log(` Wrote the Angular key to ${cyan(l)}. Git ignores this file.`);if(t.devToken){log(dim(" It is a dev token: it works in dev builds and sims for 30 days. Then run npx --package=@buoy-gg/core buoy login again."));log(dim(" This computer is signed in to Buoy too. The MCP uses it. Sign out: npx --package=@buoy-gg/core buoy logout"))}else{projectOnlyNotes(i,f).forEach(u=>log(dim(u)))}if(y)log(dim(` Removed the old ${r} line from ${p}`));if(a===".env.development.local"){log(dim(" This file is loaded in development, keeping the key out of production builds."))}if(h)log(dim(` Added ${a} to .gitignore`));log("");log(" Use it in your app:");log("");if(l){log(dim(` Import BUOY_KEY from ${l.replace(/\.ts$/,"")}.`));log(dim(" Pass it as licenseKey in provideBuoy. Keep the dev guard."));log(dim(" Reload the app to use the key."))}else if(r==="VITE_BUOY_KEY"){const u=viteKeySnippet(e);log(cyan(u.code));log("");log(dim(` ${u.note}`))}else if(r==="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 if(c){log(dim(" Buoy for .NET MAUI reads BUOY_KEY from this file when the app builds."));log(dim(" Rebuild and run your app. Nothing to add to MauiProgram.cs."))}else{log(cyan(` Buoy.init({ licenseKey: ${r} });`));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 s=await n.load();await n.signOut();log(s.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(e=process.cwd(),n=loadSessionClient()){if(!n)fail("This version of Buoy cannot sign in. Update @buoy-gg/core.");const s=await cliSession(n).load();const o=findProjectKey(e);const t=o&&typeof n.isDevToken==="function"&&n.isDevToken(o.value)?"a dev token":"a key";const i=o&&(o.source==="environment"?"your shell environment":o.source);const r=t==="a dev token"&&typeof n.checkDevToken==="function"?n.checkDevToken(o.value):null;const c=r&&!r.ok?r.message:null;if(s.state==="active"){log(`${green("Signed in")} - ${bold(s.claims.tier)} plan${s.grace?dim(" (offline, using the grace period)"):""}`);if(o)log(dim(` This project has ${t} in ${i} (${o.name}).`));if(c)log(` ${yellow("!")} ${c}`);return}if(!o){log("Not signed in. Run: npx --package=@buoy-gg/core buoy login");return}log("Not signed in on this computer.");log(`${green("This project")} has ${t} in ${cyan(i)} (${o.name}).`);if(c)log(` ${yellow("!")} ${c}`);log(dim(" Your app uses that key. The MCP can too, when it runs in this folder."));log(dim(" To sign in this computer as well, run npx --package=@buoy-gg/core buoy login when Node can reach buoy.gg."))}function help(){log(`
|
|
11
11
|
${bold("buoy")} - React Buoy CLI
|
|
12
12
|
|
|
13
13
|
${bold("Usage")}
|
package/bundlers/vite.d.ts
CHANGED
|
@@ -3,15 +3,18 @@ export interface BuoyVitePluginOptions {
|
|
|
3
3
|
exclude?: string[];
|
|
4
4
|
/**
|
|
5
5
|
* Add Buoy's early hook ahead of index.html's first module script. Defaults
|
|
6
|
-
* to true: `@buoy-gg/solid/register` in an app
|
|
7
|
-
*
|
|
6
|
+
* to true: `@buoy-gg/solid/register` or `@buoy-gg/vue/register` in an app
|
|
7
|
+
* that lists @buoy-gg/solid or @buoy-gg/vue, otherwise
|
|
8
|
+
* `@buoy-gg/core/web/register`. 'react' or 'network' forces the
|
|
8
9
|
* full hook or `@buoy-gg/core/web/register-network`. Turn it off if you
|
|
9
10
|
* import a hook yourself in a page with no index.html.
|
|
10
11
|
*/
|
|
11
12
|
register?: boolean | 'react' | 'network';
|
|
12
13
|
/**
|
|
13
|
-
* Keep Buoy in a production build of a Solid app. Without it, Buoy
|
|
14
|
-
* resolve to their `buoy-disabled` builds and no early hook is
|
|
14
|
+
* Keep Buoy in a production build of a Solid or Vue app. Without it, Buoy
|
|
15
|
+
* imports resolve to their `buoy-disabled` builds and no early hook is
|
|
16
|
+
* added. In a Vue app it also turns on `__VUE_PROD_DEVTOOLS__`, which
|
|
17
|
+
* Highlight Updates and component names need.
|
|
15
18
|
*/
|
|
16
19
|
enableInRelease?: boolean;
|
|
17
20
|
}
|
|
@@ -20,6 +23,8 @@ export interface BuoyVitePluginOptions {
|
|
|
20
23
|
* Buoy for Vite: loads every installed tool into FloatingDevTools and
|
|
21
24
|
* BuoyDevTools when they get no `modules`, and adds the early hook to
|
|
22
25
|
* index.html. Vite accepts it without a runtime dependency on Vite.
|
|
26
|
+
* When Buoy is linked from outside the app, as in a pnpm workspace, it also
|
|
27
|
+
* points React at one copy and lets Vite serve Buoy's files.
|
|
23
28
|
*/
|
|
24
29
|
export declare function buoy(options?: BuoyVitePluginOptions): {
|
|
25
30
|
name: string;
|
|
@@ -43,6 +48,8 @@ export declare function injectRegister(html: string, hook?: string): string | un
|
|
|
43
48
|
export declare function earlyHook(root: string, register?: boolean | 'react' | 'network'): string | undefined;
|
|
44
49
|
/** True when the app's package.json asks for Solid 2, where Buoy stays off for now. */
|
|
45
50
|
export declare function wantsSolid2(root: string): boolean;
|
|
51
|
+
/** The framework package (@buoy-gg/solid or @buoy-gg/vue) the app's package.json lists. */
|
|
52
|
+
export declare function frameworkHost(root: string): { name: 'solid' | 'vue'; pkg: string; register: string } | undefined;
|
|
46
53
|
export declare function disabledEntry(root: string, source: string): string | undefined;
|
|
47
54
|
export declare function solidLinksModule(root: string, found: { id: string; key: string }[]): string;
|
|
48
55
|
export declare function assetListUrl(base: string, filename: string, command: 'serve' | 'build'): string | undefined;
|
package/bundlers/vite.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{existsSync as
|
|
1
|
+
import{existsSync as x,readFileSync as w,realpathSync as R}from"node:fs";import c from"node:path";const L=[["network","network"],["storage","storage"],["events","events"],["console","console"],["env","env"],["redux","redux"],["zustand","zustand"],["jotai","jotai"],["react-query","react-query"],["route-events","route-events"],["time-machine","time-machine"],["clock","clock"],["lifecycle","lifecycle"],["location","location"],["permissions","permissions"],["notifications","push-notifications"],["scenarios","scenarios"],["sentry","sentry"],["ask-buoy","ask-buoy"],["impersonate","impersonate"],["perf-monitor","perf-monitor"],["js-top","js-top"],["highlight-updates","highlight-updates"],["debug-borders","debug-borders"],["images","images"],["assets","assets"],["image-overlay","image-overlay"],["tv-remote","tv-remote"],["focus-inspector","focus-inspector"],["external-sync","external-sync"]];const O="@buoy-gg/core/web/installed-tools";const D="@buoy-gg/core/web/register";const q="@buoy-gg/core/web/register-network";const N="\0buoy:installed-tools";const U="@buoy-gg/solid";const W="@buoy-gg/solid/register";const B=["solid-js","solid-js/web","solid-js/store"];const z="#buoy-solid-auto";const J="\0buoy:solid-links";const H=["@buoy-gg/solid","@buoy-gg/solid/register","@buoy-gg/solid/router","@buoy-gg/solid/store","@buoy-gg/solid/highlights"];const v="@buoy-gg/vue";const M="@buoy-gg/vue/register";const P=[{name:"solid",pkg:U,register:W,dedupe:()=>B},{name:"vue",pkg:v,register:M,dedupe:t=>["vue",...t["@tanstack/vue-query"]?["@tanstack/query-core"]:[]]}];export function frameworkHost(t){const e=S(t);return P.find(n=>e[n.pkg])}function I(t){for(let e=t;;e=c.dirname(e)){const n=c.join(e,"package.json");if(x(n))return n;if(c.dirname(e)===e)return void 0}}function S(t){const e=I(t);try{const n=e?JSON.parse(w(e,"utf8")):{};return{...n.dependencies,...n.devDependencies,...n.optionalDependencies,...n.peerDependencies}}catch{return{}}}export function wantsSolid2(t){const e=String(S(t)["solid-js"]??"");return e==="next"||/^[\s^~>=v]*2(?:\.|$)/.test(e)}export function earlyHook(t,e=true){if(e===false)return void 0;if(e==="react")return D;if(e==="network")return q;return frameworkHost(t)?.register??D}export function disabledEntry(t,e){const[n,o,...s]=e.split("/");if(n!=="@buoy-gg"||!o)return void 0;const r=c.join(E(t,`${n}/${o}`)??"","package.json");if(!x(r))return void 0;try{const i=JSON.parse(w(r,"utf8")).exports?.[s.length?`./${s.join("/")}`:"."];const u=i&&typeof i==="object"?i["buoy-disabled"]:void 0;return typeof u==="string"?c.join(c.dirname(r),u):void 0}catch{return void 0}}function E(t,e){for(let n=t;;n=c.dirname(n)){const o=c.join(n,"node_modules",e);if(x(c.join(o,"package.json")))return o;if(c.dirname(n)===n)return void 0}}export function solidLinksModule(t,e){const n=S(t);const o=new Set(e.map(({key:i})=>i));const s=Boolean(n["@tanstack/solid-query"])&&o.has("react-query");const r=Boolean(n["@solidjs/router"])&&o.has("route-events");return[s||r?"import { useContext, getOwner } from 'solid-js';":"",s?"import { QueryClientContext } from '@tanstack/solid-query';":"",r?"import { useLocation, useCurrentMatches, useNavigate } from '@solidjs/router';":"","export function useBuoyLinks(options) {"," const links = {};",s?" const client = useContext(QueryClientContext);\n if (client) links.queryClient = client();":"",r?[" try {"," const location = useLocation(), matches = useCurrentMatches(), navigate = useNavigate(), owner = getOwner();"," links.router = () => import('@buoy-gg/solid/router').then((m) => m.connectBuoyRouter({ location, matches, navigate, routes: options.routes, owner }));"," } catch { /* not inside <Router> */ }"].join("\n"):""," return links;","}",""].filter(Boolean).join("\n")}function A(t){const e=new Map;const n=(o,s)=>{for(const r of s){const i=r.startsWith("@buoy-gg/")&&!e.has(r)?E(o,r):void 0;if(!i)continue;const u=R(i);e.set(r,u);let d=[];try{d=Object.keys(JSON.parse(w(c.join(u,"package.json"),"utf8")).dependencies??{})}catch{}n(u,d)}};n(t,[...Object.keys(S(t)),"@buoy-gg/core"]);return[...e.values()]}function V(t,e){const n=(r,i)=>{for(const u of i){const d=E(u,r);if(d)return d}return void 0};const o=n("react-dom",[t,...e]);const s={react:n("react",[...o?[R(o)]:[],t,...e]),"react-dom":o,"react-native-web":n("react-native-web",[t,...e])};return Object.fromEntries(Object.entries(s).filter(([,r])=>r))}function G(t,e){for(let n=t;;n=c.dirname(n)){const o=c.join(n,"node_modules",e,"package.json");if(x(o)){try{return JSON.parse(w(o,"utf8"))}catch{return void 0}}if(c.dirname(n)===n)return void 0}}export function findInstalledTools(t,{exclude:e=[]}={}){const n=I(t);let o;try{const u=n?JSON.parse(w(n,"utf8")):{};const d={...u.dependencies,...u.devDependencies,...u.optionalDependencies,...u.peerDependencies};if(d["@buoy-gg/core"])o=new Set(Object.keys(d))}catch{}const s=new Set(e.map(u=>u.replace(/^@buoy-gg\//,"")));const r=[];const i=[];for(const[u,d]of L){const y=`@buoy-gg/${u}`;if(s.has(u)||s.has(d)||o&&!o.has(y))continue;const m=G(t,y);if(!m)continue;if(m.exports&&typeof m.exports==="object"&&m.exports["./web"])r.push({id:y,key:d});else i.push(y)}return{found:r,missingWeb:i}}export function installedToolsModule(t,{assetList:e}={}){const n=t.map(({id:i},u)=>`import * as t${u} from ${JSON.stringify(`${i}/web`)};`);const o=t.map(({key:i},u)=>`${JSON.stringify(i)}: t${u}`);const s=t.findIndex(({key:i})=>i==="assets");const r=e&&s!==-1?`t${s}.loadBrowserAssetManifest?.(${JSON.stringify(e)})?.catch?.(() => {});
|
|
2
2
|
`:"";return`${n.join("\n")}
|
|
3
|
-
${
|
|
3
|
+
${r}export const installedTools = { ${o.join(", ")} };
|
|
4
4
|
export const installedToolsFound = true;
|
|
5
|
-
`}function
|
|
6
|
-
${
|
|
5
|
+
`}function F(t){return t.replace(/<!--[\s\S]*?(?:-->|$)/g,e=>" ".repeat(e.length))}export function injectRegister(t,e=D){const n=`<script type="module">import ${JSON.stringify(e)};<\/script>`;const o=F(t).search(/<script\b[^>]*\btype\s*=\s*["']?module["']?[^>]*>/i);return o===-1?void 0:`${t.slice(0,o)}${n}
|
|
6
|
+
${t.slice(o)}`}function Q(t,e){const n=I(t);const o=new Set(e.map(s=>s.replace(/^@buoy-gg\//,"")));try{const s=n?JSON.parse(w(n,"utf8")):{};const r={...s.dependencies,...s.devDependencies,...s.optionalDependencies,...s.peerDependencies};return L.filter(([i,u])=>r[`@buoy-gg/${i}`]&&!o.has(i)&&!o.has(u)).map(([i])=>`@buoy-gg/${i}`).join()}catch{return""}}export function assetListUrl(t,e,n){const o=n==="serve"&&!/^(?:\/|[a-z]+:)/i.test(t)?"/":t;return/^(?:\/|[a-z]+:)/i.test(o)?`${o.endsWith("/")?o:`${o}/`}${e}`:void 0}export function buoy({exclude:t=[],register:e=true,enableInRelease:n=false}={}){let o={found:[],missingWeb:[]};let s=process.cwd();let r=e===false?void 0:D;let i=false;let u=false;let d=[];let y;let m;let T;const $=()=>{clearInterval(T);T=void 0};return{name:"buoy",enforce:"pre",config(a,l){s=c.resolve(a.root??process.cwd());o=findInstalledTools(s,{exclude:t});const f=frameworkHost(s);const b=f?.name==="solid";u=b;const p=b&&wantsSolid2(s);if(p)console.warn("[buoy] This app uses Solid 2, and @buoy-gg/solid supports Solid 1.8 and 1.9 for now. Buoy is off, so your app still runs.");const g=l?.command==="build";i=Boolean(f)&&(p||g&&!n);r=i?void 0:earlyHook(s,e);d=A(s);const j=d.some(k=>!k.split(c.sep).includes("node_modules"))?V(s,d):void 0;const h=o.found.map(({id:k})=>`${k}/web`);if(f?.name==="vue"){if(r)h.unshift(r);const k=new Set(o.found.map(({key:C})=>C));h.push("@buoy-gg/core/web","@buoy-gg/core/web/register-network",`${v}/register`);h.push(v,`${v}/pinia`,...k.has("route-events")?[`${v}/router`]:[],...k.has("highlight-updates")?[`${v}/highlights`]:[]);const _={optimizeDeps:{exclude:[O],include:h},resolve:{dedupe:f.dedupe(S(s)),alias:j}};return g&&!i?{..._,define:{__VUE_PROD_DEVTOOLS__:"true"}}:_}if(!b){if(r)h.unshift(r);return{optimizeDeps:{exclude:[O],include:h},resolve:{alias:j}}}h.unshift("@buoy-gg/core/web","@buoy-gg/core/web/register-network","@buoy-gg/solid > @buoy-gg/shared-ui/web/utils");return{optimizeDeps:{exclude:[O,...H],include:h},resolve:{dedupe:B,alias:j}}},configResolved(a){y=a.logger;const l=a.plugins.find(p=>p.name==="buoy-asset-manifest");m=l?assetListUrl(a.base,l.api?.filename??"buoy-assets.json",a.command):void 0;if(l&&!m)y.warn(`[buoy] base '${a.base}' is relative, so load the asset list yourself with loadBrowserAssetManifest().`);const f=a.server?.fs?.allow;for(const p of f?d.map(g=>g.split(c.sep).join("/")):[]){if(!f.some(g=>`${p}/`.startsWith(`${g.replace(/\/$/,"")}/`)))f.push(p)}if(a.command!=="serve"||i)return;const b=o.found.map(({key:p})=>p).join(", ")||"none";y.info(`[buoy] tools: ${b}`);if(o.missingWeb.length)y.warn(`[buoy] these have no browser build; update them to the same release as @buoy-gg/core: ${o.missingWeb.join(", ")}`)},configureServer(a){const l=I(s);if(!l)return;const f=g=>g.map(({id:j})=>j).join();const b=()=>{if(f(findInstalledTools(s,{exclude:t}).found)===f(o.found))return false;$();void a.restart();return true};const p=()=>{$();if(Q(s,t)===f(o.found))return;let g=0;T=setInterval(()=>{if(!b()&&++g>=120)$()},1e3)};a.watcher.add(l);a.watcher.on("change",g=>{if(c.resolve(g)===c.resolve(l)&&!b())p()});p()},closeBundle(){$()},resolveId(a){if(a===O)return N;if(a===z&&u)return J;if(i&&a.startsWith("@buoy-gg/"))return disabledEntry(s,a);return void 0},load(a){if(a===N)return installedToolsModule(o.found,{assetList:m});if(a===J)return solidLinksModule(s,o.found);return void 0},transformIndexHtml:{order:"pre",handler(a){if(!r)return a;const l=injectRegister(a,r);if(l===void 0)y?.warn(`[buoy] index.html has no module script, so the early hook wasn't added. Import '${r}' first in your entry file.`);return l??a}}}}export default buoy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useAppHost=exports.AppOverlay=exports.AppHostProvider=void 0;var _floating=require("@buoy-gg/shared-ui/floating");var _sharedUi=require("@buoy-gg/shared-ui");var _react=require("react");var _AppHostLogic=require("./AppHostLogic.js");var _AppIcon=require("./AppIcon");var _ToolHost=require("./ToolHost.js");var _DevToolsSettingsModalShared=require("./DevToolsSettingsModal.shared.js");var _floatingToolsWeb=require("./floatingTools.web.js");var _capacitorBackButton=require("./capacitorBackButton.js");var _jsxRuntime=require("react/jsx-runtime");const AppHostContext=(0,_react.createContext)(null);const STORAGE_KEY_OPEN_APPS="@react_buoy_open_apps";const ICON_SIZE=44;const ICON_GAP=12;const BOTTOM_OFFSET=100;const RIGHT_OFFSET=16;const dockIconPosition=t=>({x:window.innerWidth-ICON_SIZE-RIGHT_OFFSET,y:window.innerHeight-BOTTOM_OFFSET-ICON_SIZE-t*(ICON_SIZE+ICON_GAP)});const AppHostProvider=({children:t})=>{const[s,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useAppHost=exports.AppOverlay=exports.AppHostProvider=void 0;var _floating=require("@buoy-gg/shared-ui/floating");var _sharedUi=require("@buoy-gg/shared-ui");var _react=require("react");var _AppHostLogic=require("./AppHostLogic.js");var _AppIcon=require("./AppIcon");var _ToolHost=require("./ToolHost.js");var _DevToolsSettingsModalShared=require("./DevToolsSettingsModal.shared.js");var _floatingToolsWeb=require("./floatingTools.web.js");var _capacitorBackButton=require("./capacitorBackButton.js");var _jsxRuntime=require("react/jsx-runtime");const AppHostContext=(0,_react.createContext)(null);const STORAGE_KEY_OPEN_APPS="@react_buoy_open_apps";const ICON_SIZE=44;const ICON_GAP=12;const BOTTOM_OFFSET=100;const RIGHT_OFFSET=16;const dockIconPosition=t=>({x:window.innerWidth-ICON_SIZE-RIGHT_OFFSET,y:window.innerHeight-BOTTOM_OFFSET-ICON_SIZE-t*(ICON_SIZE+ICON_GAP)});const AppHostProvider=({children:t})=>{const[s,a]=(0,_react.useState)([]);const[c,d]=(0,_react.useState)(false);const p=(0,_react.useRef)([]);const u=(0,_react.useRef)(null);const r=(0,_react.useRef)(false);const f=(0,_react.useRef)(false);const h=(0,_react.useRef)(false);const v=(0,_react.useCallback)(n=>{let o="";a(i=>{const{apps:e,instanceId:l}=(0,_AppHostLogic.resolveOpenAppsState)(i,n,()=>`${n.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`);o=l;return e});return o},[]);const b=(0,_react.useCallback)(()=>{if(r.current||!f.current||!h.current)return;r.current=true;const n=u.current;if(!n||n.length===0){d(true);return}u.current=null;n.forEach(({id:o,minimized:i})=>{const e=p.current.find(l=>l.id===o);if(e&&e.component){const l=(0,_AppIcon.renderAppIcon)(e.icon,{slot:"dial",size:20,color:e.color});v({id:e.id,title:e.name,component:e.component,props:e.props,modal:e.modal,launchMode:e.launchMode||"self-modal",singleton:e.singleton??true,icon:l,color:e.color,minimized:i})}});d(true)},[v]);(0,_react.useEffect)(()=>{let n=false;const o=async()=>{try{const i=await _sharedUi.persistentStorage.getItem(STORAGE_KEY_OPEN_APPS);if(n)return;if(i){const e=JSON.parse(i);let l;if(Array.isArray(e)&&e.length>0){if(typeof e[0]==="string"){l=e.map(g=>({id:g,minimized:false}))}else{l=e.filter(g=>typeof g==="object"&&g!==null&&typeof g.id==="string")}if(l.length){u.current=l}}}}catch{}if(n)return;f.current=true;b()};void o();return()=>{n=true}},[b]);(0,_react.useEffect)(()=>{if(!c)return;const n=s.map(o=>({id:o.id,minimized:o.minimized??false}));void _sharedUi.persistentStorage.setItem(STORAGE_KEY_OPEN_APPS,JSON.stringify(n))},[s,c]);const A=(0,_react.useCallback)(n=>{p.current=n;h.current=true;b()},[b]);const m=(0,_react.useCallback)(n=>{a(o=>{if(!o.length)return o;if(!n)return o.slice(0,-1);return o.filter(i=>i.instanceId!==n)})},[]);const S=(0,_react.useCallback)(()=>a([]),[]);const x=(0,_react.useCallback)((n,o)=>{a(i=>i.map(e=>e.instanceId===n?{...e,minimized:true,restoreState:o}:e))},[]);const I=(0,_react.useCallback)((n,o)=>{a(i=>{const e=i.find(l=>l.instanceId===n);if(!e)return i;return[...i.filter(l=>l!==e),{...e,minimized:false,restoreState:o??e.restoreState}]})},[]);const M=(0,_react.useCallback)(n=>{const o=s.find(i=>i.instanceId===n);return o?.minimized??false},[s]);const y=s.some(n=>n.launchMode!=="toggle-only"&&!n.minimized);(0,_react.useEffect)(()=>{if(!y)return;const n=o=>{if(o.key!=="Escape")return;if(o.defaultPrevented)return;const i=[...s].reverse().find(e=>e.launchMode!=="toggle-only"&&!e.minimized);if(i)m(i.instanceId)};return(0,_floating.listenBuoyKeydown)(n)},[y,m,s]);(0,_capacitorBackButton.useCapacitorBackButton)(s.length>0,()=>m());const C=(0,_react.useMemo)(()=>({openApps:s,isAnyOpen:y,open:v,close:m,closeAll:S,registerApps:A,minimize:x,restore:I,isMinimized:M}),[s,y,v,m,S,A,x,I,M]);return(0,_jsxRuntime.jsx)(AppHostContext.Provider,{value:C,children:t})};exports.AppHostProvider=AppHostProvider;const useAppHost=()=>{const t=(0,_react.useContext)(AppHostContext);if(!t){return{openApps:[],isAnyOpen:false,open:()=>"",close:()=>{},closeAll:()=>{},registerApps:()=>{},minimize:()=>{},restore:()=>{},isMinimized:()=>false}}return t};exports.useAppHost=useAppHost;const BASE_ZINDEX=9e3;const backdropStyle={position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.28)",display:"flex",alignItems:"center",justifyContent:"center"};const cardStyle={maxHeight:"90%",width:"94%",borderRadius:12,backgroundColor:"white",overflow:"hidden"};const AppRenderer=({app:t,zIndex:s,onClose:a,onMinimize:c,minimizeTargetPosition:d,enableSharedModalDimensions:p})=>{const u=t.component;const r=!t.minimized;const f={...t.props??{},...p?{enableSharedModalDimensions:true}:{}};if(t.modal&&(!t.launchMode||t.launchMode==="self-modal")){return(0,_jsxRuntime.jsx)("div",{"data-testid":`buoy-tool-instance-${t.id}`,style:{position:"fixed",inset:0,zIndex:s,pointerEvents:"none"},children:(0,_jsxRuntime.jsx)(_ToolHost.ToolModalShell,{app:t,config:t.modal,visible:r,zIndex:s,onClose:a,onMinimize:c,initialModalState:t.restoreState,enableSharedModalDimensions:p,bodyProps:f})})}if(t.launchMode==="self-modal"){return(0,_jsxRuntime.jsx)("div",{"data-testid":`buoy-tool-instance-${t.id}`,style:{position:"fixed",inset:0,zIndex:s,pointerEvents:"none"},children:(0,_jsxRuntime.jsx)(u,{...f,visible:r,onClose:a,onRequestClose:a,onMinimize:c,minimizeTargetPosition:d,instanceId:t.instanceId,zIndex:s,initialModalState:t.restoreState})})}if(t.launchMode==="inline"){if(!r)return null;return(0,_jsxRuntime.jsx)("div",{"data-testid":`buoy-tool-instance-${t.id}`,style:{position:"fixed",inset:0,zIndex:s,pointerEvents:"none"},children:(0,_jsxRuntime.jsx)(u,{...f,onClose:a,onMinimize:c,minimizeTargetPosition:d,initialModalState:t.restoreState,instanceId:t.instanceId})})}return(0,_jsxRuntime.jsx)("div",{"data-testid":`buoy-tool-instance-${t.id}`,style:{...backdropStyle,zIndex:s,display:r?"flex":"none"},children:(0,_jsxRuntime.jsx)("div",{style:cardStyle,children:(0,_jsxRuntime.jsx)(u,{...f,onClose:a,onMinimize:c,minimizeTargetPosition:d,initialModalState:t.restoreState,instanceId:t.instanceId})})})};const AppOverlay=()=>{const{openApps:t,close:s,minimize:a}=useAppHost();const{settings:c}=(0,_DevToolsSettingsModalShared.useDevToolsSettings)();(0,_react.useEffect)(()=>{(0,_sharedUi.setExpandableWindowControls)(c.globalSettings?.expandableWindowControls!==false)},[c.globalSettings?.expandableWindowControls]);const d=t.filter(r=>r.launchMode!=="toggle-only");if(d.length===0)return null;const p=d.filter(r=>r.minimized).length;const u=(0,_floatingToolsWeb.getBubbleAnchorPosition)()??dockIconPosition(p);return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:d.map((r,f)=>(0,_jsxRuntime.jsx)(AppRenderer,{app:r,zIndex:BASE_ZINDEX+f,onClose:()=>s(r.instanceId),onMinimize:h=>a(r.instanceId,h),enableSharedModalDimensions:c.globalSettings?.enableSharedModalDimensions===true,minimizeTargetPosition:u},r.instanceId))})};exports.AppOverlay=AppOverlay;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useDevToolsSettings=exports.DevToolsSettingsModal=void 0;var _react=require("react");var _reactNative=require("react-native");var _settingsBus=require("./settingsBus.js");var _useDesktopSyncStatus=require("./useDesktopSyncStatus");var _sharedUi=require("@buoy-gg/shared-ui");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _AppIcon=require("./AppIcon");var _jsxRuntime=require("react/jsx-runtime");const STORAGE_KEY="@react_buoy_dev_tools_settings";const MAX_DIAL_SLOTS=6;const enforceDialLimit=r=>{let a=MAX_DIAL_SLOTS;const n={};for(const[c,s]of Object.entries(r)){if(s&&a>0){n[c]=true;a-=1}else{n[c]=false}}return n};const sanitizeFloating=(r,a)=>{const{userStatus:n,environment:c,...s}=r;const l=a?Object.entries(s).filter(([d])=>a.includes(d)):Object.entries(s);return{...Object.fromEntries(l),environment:c??false}};const mergeWithDefaults=(r,a,n)=>{if(!a)return r;const c={...r.dialTools,...a.dialTools??{}};const s=n?.allowedDialKeys?Object.entries(c).filter(([d])=>n.allowedDialKeys?.includes(d)):Object.entries(c);const l=enforceDialLimit(Object.fromEntries(s));return{dialTools:l,floatingTools:sanitizeFloating({...r.floatingTools,...a.floatingTools??{}},n?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...a.globalSettings??{}}}};const generateDefaultSettings=(r=[],a,n)=>{const c={};const s={};const l=new Set(a??[]);const d=new Set(n??[]);const g=!n||n.length===0;for(const x of r){const{id:i,slot:S="both"}=x;if(S==="dial"||S==="both"){c[i]=g?true:d.has(i)}if(S==="row"||S==="both"){s[i]=l.has(i)}}return{dialTools:enforceDialLimit(c),floatingTools:{...s,environment:l.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}};const DevToolsSettingsModal=({visible:r,onClose:a,onSettingsChange:n,initialSettings:c,availableApps:s=[],storage:l=_sharedUi.persistentStorage,zIndex:d})=>{const{defaultFloatingTools:g,defaultDialTools:x}=(0,_DefaultConfigContext.useDefaultConfig)();const i=(0,_react.useMemo)(()=>generateDefaultSettings(s,g,x),[s,g,x]);const S=(0,_react.useMemo)(()=>Object.keys(i.dialTools),[i]);const R=(0,_react.useMemo)(()=>Object.keys(i.floatingTools).filter(e=>e!=="environment"),[i]);const[f,b]=(0,_react.useState)(c||cachedSettings||i);const[w,E]=(0,_react.useState)(cachedActiveTab??"floating");const[F,G]=(0,_react.useState)(cachedActiveTab!==null);const[C,Y]=(0,_react.useState)(new Set);const[$,N]=(0,_react.useState)(false);const[Q,X]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{const e=requestAnimationFrame(()=>X(true));return()=>cancelAnimationFrame(e)},[]);const u=(0,_useDesktopSyncStatus.useDesktopSyncStatus)();(0,_react.useEffect)(()=>{const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.settings.activeTab());if(t&&["floating","settings","pro"].includes(t)){const o=t;cachedActiveTab=o;E(y=>y===o?y:o)}}catch(t){}finally{G(true)}};e()},[]);(0,_react.useEffect)(()=>{if(!F)return;_sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.settings.activeTab(),w).catch(e=>{console.warn("[Buoy]","Failed to save settings active tab:",e)})},[w,F]);const Z=(0,_sharedUi.getUseLicense)();const m=Z?.();const j=m?.isPro??false;const B=!j&&m?.licenseKey?m.error:null;const ee=m?.errorKind==="transport";const[h,te]=(0,_react.useState)(cachedStorageBackend);const[I,O]=(0,_react.useState)(false);const[z,D]=(0,_react.useState)(false);const[T,oe]=(0,_react.useState)(false);const[L,k]=(0,_react.useState)([]);const[V,P]=(0,_react.useState)(false);const H=(0,_sharedUi.useSafeAreaInsets)();const M=_reactNative.Dimensions.get("window").height;const K=_reactNative.Dimensions.get("window").width;const ne=Math.floor(M*.33);const se=Math.min(K-32,400);const _=(0,_react.useCallback)(async()=>{try{const e=await l.getItem(STORAGE_KEY);if(e){const t=JSON.parse(e);const o=mergeWithDefaults(i,t,{allowedDialKeys:S,allowedFloatingKeys:R});cachedSettings=o;b(y=>sameSettings(y,o)?y:o);return}cachedSettings=i;b(t=>sameSettings(t,i)?t:i)}catch(e){console.error("[Buoy]","Failed to load dev tools settings:",e);b(i)}},[i,S,R,l]);(0,_react.useEffect)(()=>{_()},[_]);(0,_react.useEffect)(()=>{(0,_sharedUi.getStorageBackendType)().then(e=>{cachedStorageBackend=e;te(t=>t===e?t:e)})},[]);(0,_react.useEffect)(()=>{if(T){P(true);_sharedUi.persistentStorage.getAllKeys().then(e=>{k(e.sort())}).catch(()=>{k([])}).finally(()=>{P(false)})}},[T]);const A=async e=>{try{const t={...e,dialTools:enforceDialLimit(e.dialTools)};await l.setItem(STORAGE_KEY,JSON.stringify(t));cachedSettings=t;b(t);n?.(t);_settingsBus.settingsBus.emit(t)}catch(t){console.error("[Buoy]","Failed to save dev tools settings:",t)}};const ie=e=>{const t={...f,floatingTools:{...f.floatingTools,[e]:!f.floatingTools[e]}};A(t)};const re=e=>{const t={...f,globalSettings:{...f.globalSettings,[e]:!f.globalSettings?.[e]}};A(t)};const ae=async()=>{O(true);D(false);try{await _sharedUi.persistentStorage.clear();D(true);b(i);if(l!==_sharedUi.persistentStorage)await l.setItem(STORAGE_KEY,JSON.stringify(i));n?.(i);_settingsBus.settingsBus.emit(i);setTimeout(()=>D(false),2e3)}catch(e){console.error("[Buoy]","Failed to clear storage:",e)}finally{O(false)}};const le=(0,_react.useCallback)(e=>{},[]);const ce=e=>{const t=s.find(o=>o.id===e);if(t?.description){return t.description}if(e==="environment"){return"Environment badge."}return""};const W=e=>{if(e==="environment"){return"Env Badge"}const t=s.find(o=>o.id===e);return t?.name??e.toUpperCase().replace(/_/g," ")};const de=e=>{if(!Q)return null;switch(e){case"query":return(0,_jsxRuntime.jsx)(_floatingToolsCore.QueryIcon,{size:18});case"env":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"sentry":return(0,_jsxRuntime.jsx)(_sharedUi.SentryIcon,{size:18,color:"#9945FF"});case"storage":return(0,_jsxRuntime.jsx)(_floatingToolsCore.StorageIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"wifi":case"query-wifi-toggle":return(0,_jsxRuntime.jsx)(_sharedUi.WifiCircuitIcon,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.RoutesIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"network":return(0,_jsxRuntime.jsx)(_floatingToolsCore.NetworkIcon,{size:18});case"environment":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"debug-borders":return(0,_jsxRuntime.jsx)(_sharedUi.Layers,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates":return(0,_jsxRuntime.jsx)(_sharedUi.RenderCountIcon,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates-modal":return(0,_jsxRuntime.jsx)(_floatingToolsCore.HighlighterIcon,{size:18});case"redux":return(0,_jsxRuntime.jsx)(_floatingToolsCore.ReduxIcon,{size:18});case"image-overlay":return(0,_jsxRuntime.jsx)(_sharedUi.ImageOverlayIcon,{size:18});case"events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EventsIcon,{size:18});case"zustand":try{const{ZustandIcon:t}=require("@buoy-gg/zustand");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}case"jotai":try{const{JotaiIcon:t}=require("@buoy-gg/jotai");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}default:{const t=s.find(o=>o.id===e);if(t?.icon!=null){return(0,_AppIcon.renderAppIcon)(t.icon,{slot:"row",size:18,color:t.color})}return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}}};const ge=(e,t,o,y)=>{const v=ce(e);return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:o?1:.7,onPress:()=>!o&&y(),accessibilityLabel:W(e),accessibilityRole:"button",style:[styles.toolRow,o&&styles.rowDisabled],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.toolIconSlot,children:de(e)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.rowLabel,children:[W(e),o?" \xB7 max 6":""]}),v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:1,children:v}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:t,disabled:o,onValueChange:()=>y()})]},e)};const q=e=>{Y(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})};const U=(e,t,o,y,v)=>{const ye=f.globalSettings?.[e]??false;const J=C.has(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q(e),accessibilityLabel:t,style:styles.settingRow,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:t}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:J?0:1,children:o})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:ye,onValueChange:()=>re(e)})]}),J&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:y}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyHint,children:v})]})]},e)};const p=(e,t,o)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:e}),t,o]});const ue=h==="filesystem"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"File System",tone:"accent"}):h==="asyncstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Async Storage",tone:"warning"}):h==="localstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Local Storage",tone:"accent"}):h==="memory"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Memory",tone:"danger"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Loading\u2026",tone:"neutral"});const he=()=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:styles.scrollContainer,children:[w==="floating"&&(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:p("Floating Tools",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:Object.entries(f.floatingTools).map(([e,t])=>ge(e,t,false,()=>ie(e)))})}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:"Tools switched on here appear in the floating bubble row."}))}),w==="settings"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("Background",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,padded:true,children:(0,_jsxRuntime.jsx)(_sharedUi.BackgroundSwitcher,{embedded:true})})),p("Storage",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>oe(!T),accessibilityLabel:"Storage Type",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Storage Type"})}),ue,T?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),T&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:h==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":h==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":h==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":h==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),h==="asyncstorage"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),h==="memory"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSeparator,{}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpanded,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpandedHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedTitle,children:"SAVED SETTINGS"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedCount,children:V?"\u2026":`${L.length} keys`})]}),V?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"Loading\u2026"}):L.length===0?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"No settings saved yet"}):(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:L.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.storageKeyItem,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyText,numberOfLines:1,children:e.replace("@react_buoy_","")})},e))})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.cardButtonWrap,children:(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:z?"Cleared":I?"Clearing\u2026":"Clear All Settings",variant:z?"secondary":"destructive",size:"md",disabled:I,onPress:ae,icon:z?(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:15,color:_sharedUi.night.color.accent}):(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:15,color:I?_sharedUi.night.color.textTertiary:_sharedUi.night.color.danger})})})]})]})),u&&u.state!=="idle"&&p("Desktop Sync",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q("desktopSync"),accessibilityLabel:"Buoy Desktop",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Buoy Desktop"})}),u.state==="connected"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connected",tone:"accent"}):u.state==="connecting"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connecting\u2026",tone:"neutral"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Retrying",tone:"warning"}),C.has("desktopSync")?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),C.has("desktopSync")&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.settingRowBodyText,children:[u.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.footnoteMono,children:u.targetURL??"(unknown URL)"}),u.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),u.state==="retrying"&&u.lastError&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:["Last error: ",u.lastError]})]})]})),p("Modal Behavior",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[U("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),(0,_sharedUi.expandableWindowControlsSupported)(_reactNative.Platform.OS==="web")?U("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),w==="pro"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("License",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"License Status"})}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"buoy-settings-license-status",accessibilityLabel:j?"License: Active":"License: Free",children:j?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Active",tone:"accent"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Free",tone:"neutral"})})]}),m?.tierSource==="session"?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Signed in with Buoy"})}),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void(0,_sharedUi.signOutOfBuoy)(),testID:"buoy-settings-signout"})]}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:j?"You have full access to all Buoy DevTools features.":B?ee?`Couldn't reach the license server (${B}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${B}.`:"Upgrade to Pro to unlock all features and support development."})),!j&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[p("Pro Features",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:["Advanced Settings","Priority Support"].map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.featureRow,children:[(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:16,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:e})]},e))})})),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>N(true)})]})]})]}),(0,_jsxRuntime.jsx)(_sharedUi.BuoyUpgradeSheet,{visible:$,onClose:()=>N(false)})]});return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:r,onClose:a,zIndex:d,variant:"night",header:{showToggleButton:false,customContent:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerRow,children:(0,_jsxRuntime.jsx)(_sharedUi.NightSegmented,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:w,onChange:e=>E(e)})})},initialMode:"bottomSheet",onModeChange:le,persistenceKey:_sharedUi.devToolsStorageKeys.settings.root(),enablePersistence:true,maxHeight:M-H.top,initialHeight:ne,initialFloatingPosition:{x:(K-se)/2,y:H.top+20},enableGlitchEffects:true,children:he()})};exports.DevToolsSettingsModal=DevToolsSettingsModal;const basicDefaultSettings={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}};const createDefaultsFromConfig=(r,a)=>{const n=new Set(r??[]);const c=new Set(a??[]);const s={};for(const d of c){s[d]=true}const l={environment:n.has("environment")};for(const d of n){if(d!=="environment"){l[d]=true}}return{dialTools:enforceDialLimit(s),floatingTools:l,globalSettings:{enableSharedModalDimensions:false}}};let cachedSettings=null;let cachedActiveTab=null;let cachedStorageBackend=null;const sameSettings=(r,a)=>JSON.stringify(r)===JSON.stringify(a);_settingsBus.settingsBus.addListener(r=>{if(r)cachedSettings=r});const useDevToolsSettings=()=>{const{defaultFloatingTools:r,defaultDialTools:a}=(0,_DefaultConfigContext.useDefaultConfig)();const n=(0,_react.useMemo)(()=>{if(!r&&!a){return basicDefaultSettings}return createDefaultsFromConfig(r,a)},[r,a]);const[c,s]=(0,_react.useState)(n);const l=(0,_react.useCallback)(async()=>{try{const g=await _sharedUi.persistentStorage.getItem(STORAGE_KEY);if(g){const x=JSON.parse(g);const i=mergeWithDefaults(n,x);s(i);return}s(n)}catch(g){console.error("[Buoy]","Failed to load dev tools settings:",g);s(n)}},[n]);(0,_react.useEffect)(()=>(0,_sharedUi.onSettingsApplied)(g=>{if(g.includes(STORAGE_KEY))void l()}),[l]);(0,_react.useEffect)(()=>{l();const g=_settingsBus.settingsBus.addListener(x=>{try{if(x){s(x)}}catch(i){}});return()=>{g()}},[l]);const d=(0,_react.useCallback)(()=>{l()},[l]);return{settings:c,refreshSettings:d}};exports.useDevToolsSettings=useDevToolsSettings;const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:_sharedUi.night.gutter,paddingRight:_sharedUi.night.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:8,paddingBottom:24,gap:_sharedUi.night.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:_sharedUi.night.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,fontWeight:"500"},rowCaption:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.label},settingRowBody:{paddingHorizontal:_sharedUi.night.rowPadH,paddingBottom:_sharedUi.night.rowPadV,gap:6},settingRowBodyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},settingRowBodyHint:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},bodyWarning:{color:_sharedUi.night.color.warning},bodyDanger:{color:_sharedUi.night.color.danger},cardButtonWrap:{paddingHorizontal:_sharedUi.night.cardPad,paddingTop:10,paddingBottom:_sharedUi.night.cardPad},storageExpanded:{paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:_sharedUi.night.color.glassElevated,borderRadius:_sharedUi.night.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontFamily:_sharedUi.monoFont},storageKeyEmpty:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:_sharedUi.monoFont,fontSize:_sharedUi.night.font.label,color:_sharedUi.night.color.textSecondary}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.useDevToolsSettings=exports.DevToolsSettingsModal=void 0;var _react=require("react");var _reactNative=require("react-native");var _settingsBus=require("./settingsBus.js");var _useDesktopSyncStatus=require("./useDesktopSyncStatus");var _sharedUi=require("@buoy-gg/shared-ui");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _AppIcon=require("./AppIcon");var _jsxRuntime=require("react/jsx-runtime");const STORAGE_KEY="@react_buoy_dev_tools_settings";const MAX_DIAL_SLOTS=6;const enforceDialLimit=a=>{let l=MAX_DIAL_SLOTS;const s={};for(const[c,n]of Object.entries(a)){if(n&&l>0){s[c]=true;l-=1}else{s[c]=false}}return s};const sanitizeFloating=(a,l)=>{const{userStatus:s,environment:c,...n}=a;const i=l?Object.entries(n).filter(([d])=>l.includes(d)):Object.entries(n);return{...Object.fromEntries(i),environment:c??false}};const mergeWithDefaults=(a,l,s)=>{if(!l)return a;const c={...a.dialTools,...l.dialTools??{}};const n=s?.allowedDialKeys?Object.entries(c).filter(([d])=>s.allowedDialKeys?.includes(d)):Object.entries(c);const i=enforceDialLimit(Object.fromEntries(n));return{dialTools:i,floatingTools:sanitizeFloating({...a.floatingTools,...l.floatingTools??{}},s?.allowedFloatingKeys),globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true,...l.globalSettings??{}}}};const generateDefaultSettings=(a=[],l,s)=>{const c={};const n={};const i=new Set(l??[]);const d=new Set(s??[]);const g=!s||s.length===0;for(const x of a){const{id:r,slot:p="both"}=x;if(p==="dial"||p==="both"){c[r]=g?true:d.has(r)}if(p==="row"||p==="both"){n[r]=i.has(r)}}return{dialTools:enforceDialLimit(c),floatingTools:{...n,environment:i.has("environment")},globalSettings:{enableSharedModalDimensions:false,expandableWindowControls:true}}};const DevToolsSettingsModal=({visible:a,onClose:l,onSettingsChange:s,initialSettings:c,availableApps:n=[],storage:i=_sharedUi.persistentStorage,zIndex:d})=>{const{defaultFloatingTools:g,defaultDialTools:x}=(0,_DefaultConfigContext.useDefaultConfig)();const r=(0,_react.useMemo)(()=>generateDefaultSettings(n,g,x),[n,g,x]);const p=(0,_react.useMemo)(()=>Object.keys(r.dialTools),[r]);const E=(0,_react.useMemo)(()=>Object.keys(r.floatingTools).filter(e=>e!=="environment"),[r]);const[f,m]=(0,_react.useState)(c||cachedSettings||r);const[b,F]=(0,_react.useState)(cachedActiveTab??"floating");const[N,G]=(0,_react.useState)(cachedActiveTab!==null);const[C,Y]=(0,_react.useState)(new Set);const[$,O]=(0,_react.useState)(false);const[Q,X]=(0,_react.useState)(false);(0,_react.useEffect)(()=>{const e=requestAnimationFrame(()=>X(true));return()=>cancelAnimationFrame(e)},[]);const h=(0,_useDesktopSyncStatus.useDesktopSyncStatus)();(0,_react.useEffect)(()=>{const e=async()=>{try{const t=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.settings.activeTab());if(t&&["floating","settings","pro"].includes(t)){const o=t;cachedActiveTab=o;F(u=>u===o?u:o)}}catch(t){}finally{G(true)}};e()},[]);(0,_react.useEffect)(()=>{if(!N)return;_sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.settings.activeTab(),b).catch(e=>{console.warn("[Buoy]","Failed to save settings active tab:",e)})},[b,N]);const Z=(0,_sharedUi.getUseLicense)();const S=Z?.();const j=S?.isPro??false;const I=!j&&S?.licenseKey?S.error:null;const ee=S?.errorKind==="transport";const[y,te]=(0,_react.useState)(cachedStorageBackend);const[B,V]=(0,_react.useState)(false);const[z,D]=(0,_react.useState)(false);const[T,oe]=(0,_react.useState)(false);const[R,k]=(0,_react.useState)([]);const[P,H]=(0,_react.useState)(false);const M=(0,_sharedUi.useSafeAreaInsets)();const K=_reactNative.Dimensions.get("window").height;const _=_reactNative.Dimensions.get("window").width;const se=Math.floor(K*.33);const ne=Math.min(_-32,400);const A=(0,_react.useCallback)(async()=>{try{const e=await i.getItem(STORAGE_KEY);if(e){const t=JSON.parse(e);const o=mergeWithDefaults(r,t,{allowedDialKeys:p,allowedFloatingKeys:E});cachedSettings=o;m(u=>sameSettings(u,o)?u:o);return}cachedSettings=r;m(t=>sameSettings(t,r)?t:r)}catch(e){console.error("[Buoy]","Failed to load dev tools settings:",e);m(r)}},[r,p,E,i]);(0,_react.useEffect)(()=>{A()},[A]);(0,_react.useEffect)(()=>{(0,_sharedUi.getStorageBackendType)().then(e=>{cachedStorageBackend=e;te(t=>t===e?t:e)})},[]);(0,_react.useEffect)(()=>{if(T){H(true);_sharedUi.persistentStorage.getAllKeys().then(e=>{k(e.sort())}).catch(()=>{k([])}).finally(()=>{H(false)})}},[T]);const W=async e=>{try{let t=null;try{const u=await i?.getItem(STORAGE_KEY);t=u?JSON.parse(u):null}catch{}const o={...e,dialTools:{...t?.dialTools,...enforceDialLimit(e.dialTools)},floatingTools:{...t?.floatingTools,...e.floatingTools}};await i.setItem(STORAGE_KEY,JSON.stringify(o));cachedSettings=o;m(o);s?.(o);_settingsBus.settingsBus.emit(o)}catch(t){console.error("[Buoy]","Failed to save dev tools settings:",t)}};const ie=e=>{const t={...f,floatingTools:{...f.floatingTools,[e]:!f.floatingTools[e]}};W(t)};const re=e=>{const t={...f,globalSettings:{...f.globalSettings,[e]:!f.globalSettings?.[e]}};W(t)};const ae=async()=>{V(true);D(false);try{await _sharedUi.persistentStorage.clear();D(true);m(r);if(i!==_sharedUi.persistentStorage)await i.setItem(STORAGE_KEY,JSON.stringify(r));s?.(r);_settingsBus.settingsBus.emit(r);setTimeout(()=>D(false),2e3)}catch(e){console.error("[Buoy]","Failed to clear storage:",e)}finally{V(false)}};const le=(0,_react.useCallback)(e=>{},[]);const ce=e=>{const t=n.find(o=>o.id===e);if(t?.description){return t.description}if(e==="environment"){return"Environment badge."}return""};const L=e=>{if(e==="environment"){return"Env Badge"}const t=n.find(o=>o.id===e);return t?.name??e.toUpperCase().replace(/_/g," ")};const de=e=>{if(!Q)return null;switch(e){case"query":return(0,_jsxRuntime.jsx)(_floatingToolsCore.QueryIcon,{size:18});case"env":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"sentry":return(0,_jsxRuntime.jsx)(_sharedUi.SentryIcon,{size:18,color:"#9945FF"});case"storage":return(0,_jsxRuntime.jsx)(_floatingToolsCore.StorageIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"wifi":case"query-wifi-toggle":return(0,_jsxRuntime.jsx)(_sharedUi.WifiCircuitIcon,{size:18,colorPreset:"green",strength:4,noBackground:true});case"route-events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.RoutesIcon,{size:18,bgColor:_sharedUi.night.color.surface});case"network":return(0,_jsxRuntime.jsx)(_floatingToolsCore.NetworkIcon,{size:18});case"environment":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EnvIcon,{size:18});case"debug-borders":return(0,_jsxRuntime.jsx)(_sharedUi.Layers,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates":return(0,_jsxRuntime.jsx)(_sharedUi.RenderCountIcon,{size:18,color:_sharedUi.night.color.accent});case"highlight-updates-modal":return(0,_jsxRuntime.jsx)(_floatingToolsCore.HighlighterIcon,{size:18});case"redux":return(0,_jsxRuntime.jsx)(_floatingToolsCore.ReduxIcon,{size:18});case"image-overlay":return(0,_jsxRuntime.jsx)(_sharedUi.ImageOverlayIcon,{size:18});case"events":return(0,_jsxRuntime.jsx)(_floatingToolsCore.EventsIcon,{size:18});case"zustand":try{const{ZustandIcon:t}=require("@buoy-gg/zustand");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}case"jotai":try{const{JotaiIcon:t}=require("@buoy-gg/jotai");return(0,_jsxRuntime.jsx)(t,{size:18})}catch{return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}default:{const t=n.find(o=>o.id===e);if(t?.icon!=null){return(0,_AppIcon.renderAppIcon)(t.icon,{slot:"row",size:18,color:t.color})}return(0,_jsxRuntime.jsx)(_sharedUi.Info,{size:18,color:_sharedUi.night.color.textSecondary})}}};const ge=(e,t,o,u)=>{const v=ce(e);return(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:o?1:.7,onPress:()=>!o&&u(),accessibilityLabel:L(e),accessibilityRole:"button",style:[styles.toolRow,o&&styles.rowDisabled],children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.toolIconSlot,children:de(e)}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.rowLabel,children:[L(e),o?" \xB7 max 6":""]}),v?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:1,children:v}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:t,disabled:o,onValueChange:()=>u(),accessibilityLabel:L(e)})]},e)};const q=e=>{Y(t=>{const o=new Set(t);if(o.has(e)){o.delete(e)}else{o.add(e)}return o})};const J=(e,t,o,u,v)=>{const ye=f.globalSettings?.[e]??false;const U=C.has(e);return(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q(e),accessibilityLabel:t,style:styles.settingRow,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:t}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,numberOfLines:U?0:1,children:o})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSwitch,{value:ye,onValueChange:()=>re(e),accessibilityLabel:t})]}),U&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:u}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyHint,children:v})]})]},e)};const w=(e,t,o)=>(0,_jsxRuntime.jsxs)(_reactNative.View,{children:[(0,_jsxRuntime.jsx)(_sharedUi.NightSectionLabel,{children:e}),t,o]});const ue=y==="filesystem"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"File System",tone:"accent"}):y==="asyncstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Async Storage",tone:"warning"}):y==="localstorage"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Local Storage",tone:"accent"}):y==="memory"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Memory",tone:"danger"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Loading\u2026",tone:"neutral"});const he=()=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.container,children:[(0,_jsxRuntime.jsxs)(_reactNative.ScrollView,{style:styles.scrollContent,showsVerticalScrollIndicator:false,contentContainerStyle:styles.scrollContainer,children:[b==="floating"&&(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:w("Floating Tools",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:Object.entries(f.floatingTools).map(([e,t])=>ge(e,t,false,()=>ie(e)))})}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:"Tools switched on here appear in the floating bubble row."}))}),b==="settings"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[w("Background",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,padded:true,children:(0,_jsxRuntime.jsx)(_sharedUi.BackgroundSwitcher,{embedded:true})})),w("Storage",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>oe(!T),accessibilityLabel:"Storage Type",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Storage Type"})}),ue,T?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),T&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.settingRowBodyText,children:y==="filesystem"?"Settings persist independently and survive AsyncStorage.clear() calls during logout.":y==="asyncstorage"?"Settings may be lost if AsyncStorage is cleared during logout.":y==="localstorage"?"Settings are saved in this browser. Clearing site data removes them.":y==="memory"?"Settings are stored in memory only and will be lost on app restart.":"Checking storage backend\u2026"}),y==="asyncstorage"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:"Install expo-file-system to persist settings through logout flows."}),y==="memory"&&(0,_jsxRuntime.jsx)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyDanger],children:"No persistent storage available \u2014 install expo-file-system (best) or @react-native-async-storage/async-storage."})]}),(0,_jsxRuntime.jsx)(_sharedUi.NightSeparator,{}),(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpanded,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.storageExpandedHeader,children:[(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedTitle,children:"SAVED SETTINGS"}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageExpandedCount,children:P?"\u2026":`${R.length} keys`})]}),P?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"Loading\u2026"}):R.length===0?(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyEmpty,children:"No settings saved yet"}):(0,_jsxRuntime.jsx)(_reactNative.ScrollView,{style:styles.storageKeysList,nestedScrollEnabled:true,showsVerticalScrollIndicator:true,children:R.map(e=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.storageKeyItem,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.storageKeyText,numberOfLines:1,children:e.replace("@react_buoy_","")})},e))})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.cardButtonWrap,children:(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:z?"Cleared":B?"Clearing\u2026":"Clear All Settings",variant:z?"secondary":"destructive",size:"md",disabled:B,onPress:ae,icon:z?(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:15,color:_sharedUi.night.color.accent}):(0,_jsxRuntime.jsx)(_sharedUi.Trash2,{size:15,color:B?_sharedUi.night.color.textTertiary:_sharedUi.night.color.danger})})})]})]})),h&&h.state!=="idle"&&w("Desktop Sync",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.TouchableOpacity,{activeOpacity:.7,onPress:()=>q("desktopSync"),accessibilityLabel:"Buoy Desktop",style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Buoy Desktop"})}),h.state==="connected"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connected",tone:"accent"}):h.state==="connecting"?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Connecting\u2026",tone:"neutral"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Retrying",tone:"warning"}),C.has("desktopSync")?(0,_jsxRuntime.jsx)(_sharedUi.ChevronDown,{size:16,color:_sharedUi.night.color.textTertiary}):(0,_jsxRuntime.jsx)(_sharedUi.ChevronRightIcon,{size:16,color:_sharedUi.night.color.textTertiary})]}),C.has("desktopSync")&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRowBody,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.settingRowBodyText,children:[h.state==="connected"?"Streaming tool data to Buoy Desktop at ":"Trying to reach Buoy Desktop at ",(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.footnoteMono,children:h.targetURL??"(unknown URL)"}),h.state!=="connected"&&" \u2014 is the desktop app running? Override with the externalSync socketURL option if it runs elsewhere."]}),h.state==="retrying"&&h.lastError&&(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:[styles.settingRowBodyText,styles.bodyWarning],children:["Last error: ",h.lastError]})]})]})),w("Modal Behavior",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsxs)(_sharedUi.NightRows,{children:[J("enableSharedModalDimensions","Shared Modal Size","Sync dimensions across all tools","When enabled, all tool modals will share the same size and position. Resizing one modal will affect all others. When disabled, each tool remembers its own size and position independently.","Keep OFF for the best experience. This allows you to customize each tool's modal size separately."),(0,_sharedUi.expandableWindowControlsSupported)(_reactNative.Platform.OS==="web")?J("expandableWindowControls","Expand Controls","iPad-style expandable window buttons","When enabled, the window control buttons (minimize, toggle mode, close) start as small dots and expand into larger, easy-to-tap buttons when pressed. When disabled, buttons are directly tappable at their small size.","Keep ON for touch devices where the small buttons are hard to press. Turn OFF if you prefer direct single-tap access."):null]})}))]}),b==="pro"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[w("License",(0,_jsxRuntime.jsxs)(_sharedUi.NightCard,{glass:true,children:[(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"License Status"})}),(0,_jsxRuntime.jsx)(_reactNative.View,{testID:"buoy-settings-license-status",accessibilityLabel:j?"License: Active":"License: Free",children:j?(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Active",tone:"accent"}):(0,_jsxRuntime.jsx)(_sharedUi.NightBadge,{label:"Free",tone:"neutral"})})]}),S?.tierSource==="session"?(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.settingRow,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.rowInfo,children:(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:"Signed in with Buoy"})}),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Sign out",variant:"secondary",size:"md",onPress:()=>void(0,_sharedUi.signOutOfBuoy)(),testID:"buoy-settings-signout"})]}):null,S?.teamRole?(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.settingRow,testID:"buoy-settings-team-role",children:(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.rowInfo,children:[(0,_jsxRuntime.jsxs)(_reactNative.Text,{style:styles.rowLabel,children:["Role: ",S.teamRole]}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowCaption,children:S.allowedTools?"Your team picks the tools you see.":"You see all tools."})]})}):null]}),(0,_jsxRuntime.jsx)(_sharedUi.NightFootnote,{children:j?"You have full access to all Buoy DevTools features.":I?ee?`Couldn't reach the license server (${I}). A VPN or corporate proxy can block buoy.gg \u2014 turn it off and reload. Your key hasn't been rejected.`:`License check failed: ${I}.`:"Upgrade to Pro to unlock all features and support development."})),!j&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[w("Pro Features",(0,_jsxRuntime.jsx)(_sharedUi.NightCard,{glass:true,children:(0,_jsxRuntime.jsx)(_sharedUi.NightRows,{children:["Advanced Settings","Priority Support"].map(e=>(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.featureRow,children:[(0,_jsxRuntime.jsx)(_sharedUi.CheckCircle2,{size:16,color:_sharedUi.night.color.accent}),(0,_jsxRuntime.jsx)(_reactNative.Text,{style:styles.rowLabel,children:e})]},e))})})),(0,_jsxRuntime.jsx)(_sharedUi.NightButton,{label:"Upgrade to Pro",variant:"primary",size:"lg",onPress:()=>O(true)})]})]})]}),(0,_jsxRuntime.jsx)(_sharedUi.BuoyUpgradeSheet,{visible:$,onClose:()=>O(false)})]});return(0,_jsxRuntime.jsx)(_sharedUi.JsModal,{visible:a,onClose:l,zIndex:d,variant:"night",header:{showToggleButton:false,customContent:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.headerRow,children:(0,_jsxRuntime.jsx)(_sharedUi.NightSegmented,{glass:true,tabs:[{key:"floating",label:"Floating"},{key:"settings",label:"Settings"},{key:"pro",label:"Pro"}],activeKey:b,onChange:e=>F(e)})})},initialMode:"bottomSheet",onModeChange:le,persistenceKey:_sharedUi.devToolsStorageKeys.settings.root(),enablePersistence:true,maxHeight:K-M.top,initialHeight:se,initialFloatingPosition:{x:(_-ne)/2,y:M.top+20},enableGlitchEffects:true,children:he()})};exports.DevToolsSettingsModal=DevToolsSettingsModal;const basicDefaultSettings={dialTools:{},floatingTools:{environment:false},globalSettings:{enableSharedModalDimensions:false}};const createDefaultsFromConfig=(a,l)=>{const s=new Set(a??[]);const c=new Set(l??[]);const n={};for(const d of c){n[d]=true}const i={environment:s.has("environment")};for(const d of s){if(d!=="environment"){i[d]=true}}return{dialTools:enforceDialLimit(n),floatingTools:i,globalSettings:{enableSharedModalDimensions:false}}};let cachedSettings=null;let cachedActiveTab=null;let cachedStorageBackend=null;const sameSettings=(a,l)=>JSON.stringify(a)===JSON.stringify(l);_settingsBus.settingsBus.addListener(a=>{if(a)cachedSettings=a});const useDevToolsSettings=()=>{const{defaultFloatingTools:a,defaultDialTools:l}=(0,_DefaultConfigContext.useDefaultConfig)();const s=(0,_react.useMemo)(()=>{if(!a&&!l){return basicDefaultSettings}return createDefaultsFromConfig(a,l)},[a,l]);const[c,n]=(0,_react.useState)(s);const i=(0,_react.useCallback)(async()=>{try{const g=await _sharedUi.persistentStorage.getItem(STORAGE_KEY);if(g){const x=JSON.parse(g);const r=mergeWithDefaults(s,x);n(r);return}n(s)}catch(g){console.error("[Buoy]","Failed to load dev tools settings:",g);n(s)}},[s]);(0,_react.useEffect)(()=>(0,_sharedUi.onSettingsApplied)(g=>{if(g.includes(STORAGE_KEY))void i()}),[i]);(0,_react.useEffect)(()=>{i();const g=_settingsBus.settingsBus.addListener(x=>{try{if(x){n(x)}}catch(r){}});return()=>{g()}},[i]);const d=(0,_react.useCallback)(()=>{i()},[i]);return{settings:c,refreshSettings:d}};exports.useDevToolsSettings=useDevToolsSettings;const styles=_reactNative.StyleSheet.create({container:{flex:1,backgroundColor:"transparent"},headerRow:{flexDirection:"row",alignItems:"center",paddingLeft:_sharedUi.night.gutter,paddingRight:_sharedUi.night.gutter,paddingBottom:8},scrollContent:{flex:1},scrollContainer:{paddingHorizontal:_sharedUi.night.gutter,paddingTop:8,paddingBottom:24,gap:_sharedUi.night.groupGap},toolRow:{flexDirection:"row",alignItems:"center",gap:12,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},settingRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:_sharedUi.night.rowPadV,minHeight:52},featureRow:{flexDirection:"row",alignItems:"center",gap:10,paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12},rowDisabled:{opacity:.4},toolIconSlot:{width:24,alignItems:"center"},rowInfo:{flex:1,gap:2},rowLabel:{color:_sharedUi.night.color.text,fontSize:_sharedUi.night.font.row,fontWeight:"500"},rowCaption:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.label},settingRowBody:{paddingHorizontal:_sharedUi.night.rowPadH,paddingBottom:_sharedUi.night.rowPadV,gap:6},settingRowBodyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},settingRowBodyHint:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,lineHeight:_sharedUi.night.font.caption*1.45},bodyWarning:{color:_sharedUi.night.color.warning},bodyDanger:{color:_sharedUi.night.color.danger},cardButtonWrap:{paddingHorizontal:_sharedUi.night.cardPad,paddingTop:10,paddingBottom:_sharedUi.night.cardPad},storageExpanded:{paddingHorizontal:_sharedUi.night.rowPadH,paddingVertical:12,gap:8},storageExpandedHeader:{flexDirection:"row",alignItems:"center"},storageExpandedTitle:{flex:1,color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontWeight:"600",letterSpacing:.5},storageExpandedCount:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.micro},storageKeysList:{maxHeight:150},storageKeyItem:{backgroundColor:_sharedUi.night.color.glassElevated,borderRadius:_sharedUi.night.radius.segment,paddingHorizontal:10,paddingVertical:7,marginBottom:4},storageKeyText:{color:_sharedUi.night.color.textSecondary,fontSize:_sharedUi.night.font.micro,fontFamily:_sharedUi.monoFont},storageKeyEmpty:{color:_sharedUi.night.color.textTertiary,fontSize:_sharedUi.night.font.caption,fontStyle:"italic"},footnoteMono:{fontFamily:_sharedUi.monoFont,fontSize:_sharedUi.night.font.label,color:_sharedUi.night.color.textSecondary}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FloatingDevTools=void 0;var _sharedUi=require("@buoy-gg/shared-ui");var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _AppHost=require("./AppHost");var _FloatingMenu=require("./FloatingMenu.js");var _ToolOpenerBridge=require("./ToolOpenerBridge.js");var _autoDiscoverPresets=require("./autoDiscoverPresets.js");var _installPing=require("../telemetry/installPing.js");var _Buoy=require("../Buoy.js");var _AppIcon=require("./AppIcon");var _DevToolsVisibilityContext=require("./DevToolsVisibilityContext.js");var _optionalRequire=require("./optionalRequire.js");var _MinimizedToolsContext=require("./MinimizedToolsContext.js");var _defaultConfig=require("./defaultConfig.js");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _license=_interopRequireWildcard(require("@buoy-gg/license"));var licenseModule=_license;var _BuoySignIn=require("./BuoySignIn");var _autoExternalSync=require("./autoExternalSync.js");var _externalSyncGate=require("./externalSyncGate.js");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(t,n){if("function"==typeof WeakMap)var s=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(r,x){if(!x&&r&&r.__esModule)return r;var l,u,g={__proto__:null,default:r};if(null===r||"object"!=typeof r&&"function"!=typeof r)return g;if(l=x?a:s){if(l.has(r))return l.get(r);l.set(r,g)}for(const i in r)"default"!==i&&{}.hasOwnProperty.call(r,i)&&((u=(l=Object.defineProperty)&&Object.getOwnPropertyDescriptor(r,i))&&(u.get||u.set)?l(g,i,u):g[i]=r[i]);return g})(t,n)}let warnedReleaseTransport=null;function warnReleaseTransportOnce(t){if(!t||t===warnedReleaseTransport)return;warnedReleaseTransport=t;console.warn("[Buoy]",t)}function resolveSignInAppId(t){if(t&&typeof t==="object"&&t.appId)return t.appId;try{const{Platform:n}=require("react-native");const s=require("expo-constants");const a=(s?.default??s)?.expoConfig;const r=n.OS==="android"?a?.android?.package:a?.ios?.bundleIdentifier;if(typeof r==="string"&&r)return r}catch{}try{const n=require("expo-application");const s=(n?.default??n)?.applicationId;if(typeof s==="string"&&s)return s}catch{}return null}const FloatingDevTools=({apps:t,requiredEnvVars:n,requiredStorageKeys:s,askBuoy:a,children:r,disableHints:x=false,defaultFloatingTools:l,defaultDialTools:u,requireLicense:g,licenseKey:i,zustandStores:q,environment:U,externalSync:b=true,headless:O=false,signIn:j,...D})=>{const N=U??(0,_sharedUi.normalizeEnvironment)(process.env.NODE_ENV??"dev");const{isLicensed:h}=(0,_license.useProAccess)();const{licenseKey:_,isInitialized:C,tier:m,access:c}=(0,_license.useLicense)();const G=i===void 0||(0,_license.sameLicenseKey)(i,_);const E=G&&c.status==="admitted";(0,_react.useEffect)(()=>{if(!C||c.status==="initializing")return;void(0,_installPing.sendInstallPing)({tier:c.status==="admitted"?m:"locked",enabled:(0,_Buoy.isTelemetryEnabled)()})},[C,c.status,m]);const R=j?resolveSignInAppId(j):null;(0,_react.useEffect)(()=>{if(!R)return;const e=licenseModule.SessionManager;if(!e)return;e.configure({audience:`app:${R}`});void e.load().catch(()=>{})},[R]);(0,_react.useEffect)(()=>{void _license.LicenseManager.configure(i).catch(()=>{})},[i]);(0,_react.useEffect)(()=>{if(E)(0,_sharedUi.startSettingsSync)()},[E]);(0,_react.useEffect)(()=>{if(!q||c.status==="locked")return;try{const{watchStores:e}=require("@buoy-gg/zustand");return e(q)}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/zustand",e)}},[q,c.status]);const J=(0,_react.useMemo)(()=>{if(u){return(0,_defaultConfig.validateDialConfig)(u)}return u},[u]);const M=(0,_react.useMemo)(()=>{const e=[];if(n&&n.length>0){try{const{createEnvTool:o,createEnvVarConfig:P}=require("@buoy-gg/env");e.push(o({requiredEnvVars:P(n)}))}catch(o){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/env",o)}}if(s&&s.length>0){try{const{createStorageTool:o}=require("@buoy-gg/storage");e.push(o({requiredStorageKeys:s}))}catch(o){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/storage",o)}}if(a){try{const{createAskBuoyTool:o}=require("@buoy-gg/ask-buoy");e.push(o(a))}catch(o){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/ask-buoy",o)}}return e},[n,s,a]);const T=(0,_react.useMemo)(()=>{if(!t&&M.length===0)return void 0;return[...t||[],...M]},[t,M]);const f=(0,_react.useMemo)(()=>T?(0,_autoDiscoverPresets.autoDiscoverPresetsWithCustom)(T):(0,_autoDiscoverPresets.autoDiscoverPresets)(),[T]);const A=(0,_react.useMemo)(()=>f.filter(e=>e.sync),[f]);const k=(0,_react.useMemo)(()=>{try{const{DebugBordersStandaloneOverlay:e}=require("@buoy-gg/debug-borders");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/debug-borders",e);return null}},[]);const F=(0,_react.useMemo)(()=>{try{const{HighlightUpdatesOverlay:e}=require("@buoy-gg/highlight-updates");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/highlight-updates",e);return null}},[]);const B=(0,_react.useMemo)(()=>{try{const{ImageOverlayStandalone:e}=require("@buoy-gg/image-overlay");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/image-overlay",e);return null}},[]);const w=(0,_react.useMemo)(()=>{try{const{PerfMonitorOverlay:e}=require("@buoy-gg/perf-monitor");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/perf-monitor",e);return null}},[]);const z=(0,_react.useMemo)(()=>{try{const{JsTopHudOverlay:e}=require("@buoy-gg/js-top");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/js-top",e);return null}},[]);const p=(0,_react.useMemo)(()=>{try{const{RouteTracker:e}=require("@buoy-gg/route-events");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/route-events",e);return null}},[]);const y=(0,_react.useMemo)(()=>{try{const{ReactQueryTracker:e}=require("@buoy-gg/react-query");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/react-query",e);return null}},[]);const H=(0,_react.useMemo)(()=>{try{const{ImpersonateOverlay:e}=require("@buoy-gg/impersonate");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/impersonate",e);return null}},[]);const L=(0,_react.useMemo)(()=>{try{const{ScenariosOverlay:e}=require("@buoy-gg/scenarios");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/scenarios",e);return null}},[]);const d=(0,_react.useMemo)(()=>{try{const{ReduxAutoInstrument:e}=require("@buoy-gg/redux");return e??null}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/redux",e);return null}},[]);const v=(0,_react.useMemo)(()=>{try{const{ConsoleRoot:e}=require("@buoy-gg/console");return e??null}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/console",e);return null}},[]);const Q=(0,_react.useCallback)(e=>{const o=f.find(P=>P.id===e);if(!o)return null;return(0,_AppIcon.renderAppIcon)(o.icon,{slot:"dial",size:20,color:o.color})},[f]);const S=typeof __DEV__!=="undefined"&&__DEV__;if(!S&&!h){return j&&!O?(0,_jsxRuntime.jsx)(_BuoySignIn.BuoySignIn,{needsPlan:true}):null}const V=(0,_externalSyncGate.shouldMountExternalSync)({isDevelopment:S,isLicensed:h,externalSync:b,isAvailable:(0,_autoExternalSync.isExternalSyncAvailable)()});const I=(0,_externalSyncGate.externalSyncOptions)(b);if(!S&&I?.enableInRelease){warnReleaseTransportOnce((0,_externalSyncGate.releaseTransportProblem)(I.socketURL,I))}const W=(0,_jsxRuntime.jsx)(_autoExternalSync.ToolRegistryPublisher,{requiredEnvVars:n,customApps:A});if(!E){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[c.status==="initializing"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[d&&(0,_jsxRuntime.jsx)(d,{}),v&&(0,_jsxRuntime.jsx)(v,{}),p&&(0,_jsxRuntime.jsx)(p,{}),y&&(0,_jsxRuntime.jsx)(y,{})]}),!O&&(j?(0,_jsxRuntime.jsx)(_BuoySignIn.BuoySignIn,{}):(0,_jsxRuntime.jsx)(_sharedUi.AccountSetup,{}))]})}if(O){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[d&&(0,_jsxRuntime.jsx)(d,{}),v&&(0,_jsxRuntime.jsx)(v,{}),p&&(0,_jsxRuntime.jsx)(p,{}),y&&(0,_jsxRuntime.jsx)(y,{}),W,V&&(0,_jsxRuntime.jsx)(_autoExternalSync.AutoExternalSync,{options:(0,_externalSyncGate.externalSyncOptions)(b),requiredEnvVars:n,isPro:h,tier:m,licenseKey:_,customApps:A})]})}return(0,_jsxRuntime.jsx)(_DefaultConfigContext.DefaultConfigProvider,{defaultFloatingTools:l,defaultDialTools:J,children:(0,_jsxRuntime.jsx)(_sharedUi.HintsProvider,{disableHints:x,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,pointerEvents:"box-none",__buoyDevToolsRoot:true,children:(0,_jsxRuntime.jsxs)(_DevToolsVisibilityContext.DevToolsVisibilityProvider,{children:[B&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",collapsable:false,children:(0,_jsxRuntime.jsx)(B,{})}),(0,_jsxRuntime.jsx)(_AppHost.AppHostProvider,{children:(0,_jsxRuntime.jsxs)(_MinimizedToolsContext.MinimizedToolsProvider,{getToolIcon:Q,children:[(0,_jsxRuntime.jsx)(_FloatingMenu.FloatingMenu,{...D,apps:f,environment:N}),D.hidden?null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_AppHost.AppOverlay,{}),(0,_jsxRuntime.jsx)(_sharedUi.FloatingToolHost,{})]}),(0,_jsxRuntime.jsx)(_ToolOpenerBridge.ToolOpenerBridge,{})]})}),r,k&&(0,_jsxRuntime.jsx)(k,{}),F&&(0,_jsxRuntime.jsx)(F,{}),w&&(0,_jsxRuntime.jsx)(w,{}),z&&(0,_jsxRuntime.jsx)(z,{}),H&&(0,_jsxRuntime.jsx)(H,{}),L&&(0,_jsxRuntime.jsx)(L,{}),d&&(0,_jsxRuntime.jsx)(d,{}),v&&(0,_jsxRuntime.jsx)(v,{}),p&&(0,_jsxRuntime.jsx)(p,{}),y&&(0,_jsxRuntime.jsx)(y,{}),W,V&&(0,_jsxRuntime.jsx)(_autoExternalSync.AutoExternalSync,{options:(0,_externalSyncGate.externalSyncOptions)(b),requiredEnvVars:n,isPro:h,tier:m,licenseKey:_,customApps:A})]})})})})};exports.FloatingDevTools=FloatingDevTools;const styles=_reactNative.StyleSheet.create({container:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:9999}});
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FloatingDevTools=void 0;var _sharedUi=require("@buoy-gg/shared-ui");var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _AppHost=require("./AppHost");var _TeamToolCloser=require("./TeamToolCloser.js");var _teamToolsNote=require("./teamToolsNote.js");var _FloatingMenu=require("./FloatingMenu.js");var _ToolOpenerBridge=require("./ToolOpenerBridge.js");var _autoDiscoverPresets=require("./autoDiscoverPresets.js");var _installPing=require("../telemetry/installPing.js");var _Buoy=require("../Buoy.js");var _AppIcon=require("./AppIcon");var _DevToolsVisibilityContext=require("./DevToolsVisibilityContext.js");var _optionalRequire=require("./optionalRequire.js");var _MinimizedToolsContext=require("./MinimizedToolsContext.js");var _defaultConfig=require("./defaultConfig.js");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _license=_interopRequireWildcard(require("@buoy-gg/license"));var licenseModule=_license;var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _BuoySignIn=require("./BuoySignIn");var _autoExternalSync=require("./autoExternalSync.js");var _externalSyncGate=require("./externalSyncGate.js");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(t,n){if("function"==typeof WeakMap)var s=new WeakMap,a=new WeakMap;return(_interopRequireWildcard=function(r,x){if(!x&&r&&r.__esModule)return r;var l,u,g={__proto__:null,default:r};if(null===r||"object"!=typeof r&&"function"!=typeof r)return g;if(l=x?a:s){if(l.has(r))return l.get(r);l.set(r,g)}for(const i in r)"default"!==i&&{}.hasOwnProperty.call(r,i)&&((u=(l=Object.defineProperty)&&Object.getOwnPropertyDescriptor(r,i))&&(u.get||u.set)?l(g,i,u):g[i]=r[i]);return g})(t,n)}let warnedReleaseTransport=null;function warnReleaseTransportOnce(t){if(!t||t===warnedReleaseTransport)return;warnedReleaseTransport=t;console.warn("[Buoy]",t)}function resolveSignInAppId(t){if(t&&typeof t==="object"&&t.appId)return t.appId;try{const{Platform:n}=require("react-native");const s=require("expo-constants");const a=(s?.default??s)?.expoConfig;const r=n.OS==="android"?a?.android?.package:a?.ios?.bundleIdentifier;if(typeof r==="string"&&r)return r}catch{}try{const n=require("expo-application");const s=(n?.default??n)?.applicationId;if(typeof s==="string"&&s)return s}catch{}return null}const FloatingDevTools=({apps:t,requiredEnvVars:n,requiredStorageKeys:s,askBuoy:a,children:r,disableHints:x=false,defaultFloatingTools:l,defaultDialTools:u,requireLicense:g,licenseKey:i,zustandStores:O,environment:U,externalSync:m=true,headless:T=false,signIn:b,...D})=>{const G=U??(0,_sharedUi.normalizeEnvironment)(process.env.NODE_ENV??"dev");const{isLicensed:j}=(0,_license.useProAccess)();const{licenseKey:_,isInitialized:k,tier:q,access:c,allowedTools:h}=(0,_license.useLicense)();const J=i===void 0||(0,_license.sameLicenseKey)(i,_);const E=J&&c.status==="admitted";(0,_react.useEffect)(()=>{if(!k||c.status==="initializing")return;void(0,_installPing.sendInstallPing)({tier:c.status==="admitted"?q:"locked",enabled:(0,_Buoy.isTelemetryEnabled)()})},[k,c.status,q]);const M=b?resolveSignInAppId(b):null;(0,_react.useEffect)(()=>{if(!M)return;const e=licenseModule.SessionManager;if(!e)return;e.configure({audience:`app:${M}`});void e.load().catch(()=>{})},[M]);(0,_react.useEffect)(()=>{void _license.LicenseManager.configure(i).catch(()=>{})},[i]);(0,_react.useEffect)(()=>{if(E)(0,_sharedUi.startSettingsSync)()},[E]);(0,_react.useEffect)(()=>{if(!O||c.status==="locked")return;try{const{watchStores:e}=require("@buoy-gg/zustand");return e(O)}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/zustand",e)}},[O,c.status]);const Q=(0,_react.useMemo)(()=>{if(u){return(0,_defaultConfig.validateDialConfig)(u)}return u},[u]);const R=(0,_react.useMemo)(()=>{const e=[];if(n&&n.length>0){try{const{createEnvTool:o,createEnvVarConfig:P}=require("@buoy-gg/env");e.push(o({requiredEnvVars:P(n)}))}catch(o){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/env",o)}}if(s&&s.length>0){try{const{createStorageTool:o}=require("@buoy-gg/storage");e.push(o({requiredStorageKeys:s}))}catch(o){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/storage",o)}}if(a){try{const{createAskBuoyTool:o}=require("@buoy-gg/ask-buoy");e.push(o(a))}catch(o){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/ask-buoy",o)}}return e},[n,s,a]);const A=(0,_react.useMemo)(()=>{if(!t&&R.length===0)return void 0;return[...t||[],...R]},[t,R]);const p=(0,_react.useMemo)(()=>A?(0,_autoDiscoverPresets.autoDiscoverPresetsWithCustom)(A):(0,_autoDiscoverPresets.autoDiscoverPresets)(),[A]);const S=(0,_react.useMemo)(()=>p.filter(e=>e.sync),[p]);const $=(0,_react.useMemo)(()=>(0,_floatingToolsCore.filterTeamTools)(p,h),[p,h]);const F=(0,_react.useMemo)(()=>{try{const{DebugBordersStandaloneOverlay:e}=require("@buoy-gg/debug-borders");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/debug-borders",e);return null}},[]);const w=(0,_react.useMemo)(()=>{try{const{HighlightUpdatesOverlay:e}=require("@buoy-gg/highlight-updates");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/highlight-updates",e);return null}},[]);const B=(0,_react.useMemo)(()=>{try{const{ImageOverlayStandalone:e}=require("@buoy-gg/image-overlay");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/image-overlay",e);return null}},[]);const z=(0,_react.useMemo)(()=>{try{const{PerfMonitorOverlay:e}=require("@buoy-gg/perf-monitor");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/perf-monitor",e);return null}},[]);const H=(0,_react.useMemo)(()=>{try{const{JsTopHudOverlay:e}=require("@buoy-gg/js-top");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/js-top",e);return null}},[]);const y=(0,_react.useMemo)(()=>{try{const{RouteTracker:e}=require("@buoy-gg/route-events");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/route-events",e);return null}},[]);const d=(0,_react.useMemo)(()=>{try{const{ReactQueryTracker:e}=require("@buoy-gg/react-query");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/react-query",e);return null}},[]);const L=(0,_react.useMemo)(()=>{try{const{ImpersonateOverlay:e}=require("@buoy-gg/impersonate");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/impersonate",e);return null}},[]);const N=(0,_react.useMemo)(()=>{try{const{ScenariosOverlay:e}=require("@buoy-gg/scenarios");return e}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/scenarios",e);return null}},[]);const f=(0,_react.useMemo)(()=>{try{const{ReduxAutoInstrument:e}=require("@buoy-gg/redux");return e??null}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/redux",e);return null}},[]);const v=(0,_react.useMemo)(()=>{try{const{ConsoleRoot:e}=require("@buoy-gg/console");return e??null}catch(e){(0,_optionalRequire.reportOptionalRequireError)("@buoy-gg/console",e);return null}},[]);const X=(0,_react.useCallback)(e=>{const o=p.find(P=>P.id===e);if(!o)return null;return(0,_AppIcon.renderAppIcon)(o.icon,{slot:"dial",size:20,color:o.color})},[p]);const C=typeof __DEV__!=="undefined"&&__DEV__;if(!C&&!j){return b&&!T?(0,_jsxRuntime.jsx)(_BuoySignIn.BuoySignIn,{needsPlan:true}):null}const V=(0,_externalSyncGate.shouldMountExternalSync)({isDevelopment:C,isLicensed:j,externalSync:m,isAvailable:(0,_autoExternalSync.isExternalSyncAvailable)()});const I=(0,_externalSyncGate.externalSyncOptions)(m);if(!C&&I?.enableInRelease){warnReleaseTransportOnce((0,_externalSyncGate.releaseTransportProblem)(I.socketURL,I))}const W=(0,_jsxRuntime.jsx)(_autoExternalSync.ToolRegistryPublisher,{requiredEnvVars:n,customApps:S});if(!E){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[c.status==="initializing"&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[f&&(0,_jsxRuntime.jsx)(f,{}),v&&(0,_jsxRuntime.jsx)(v,{}),y&&(0,_jsxRuntime.jsx)(y,{}),d&&(0,_jsxRuntime.jsx)(d,{})]}),!T&&(b?(0,_jsxRuntime.jsx)(_BuoySignIn.BuoySignIn,{}):(0,_jsxRuntime.jsx)(_sharedUi.AccountSetup,{}))]})}if(T){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[f&&(0,_jsxRuntime.jsx)(f,{}),v&&(0,_jsxRuntime.jsx)(v,{}),y&&(0,_jsxRuntime.jsx)(y,{}),d&&(0,_jsxRuntime.jsx)(d,{}),W,V&&(0,_jsxRuntime.jsx)(_autoExternalSync.AutoExternalSync,{options:(0,_externalSyncGate.externalSyncOptions)(m),requiredEnvVars:n,isPro:j,tier:q,licenseKey:_,customApps:S})]})}return(0,_jsxRuntime.jsx)(_DefaultConfigContext.DefaultConfigProvider,{defaultFloatingTools:l,defaultDialTools:Q,children:(0,_jsxRuntime.jsx)(_sharedUi.HintsProvider,{disableHints:x,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.container,pointerEvents:"box-none",__buoyDevToolsRoot:true,children:(0,_jsxRuntime.jsxs)(_DevToolsVisibilityContext.DevToolsVisibilityProvider,{children:[B&&(0,_jsxRuntime.jsx)(_reactNative.View,{style:_reactNative.StyleSheet.absoluteFill,pointerEvents:"box-none",collapsable:false,children:(0,_jsxRuntime.jsx)(B,{})}),(0,_jsxRuntime.jsx)(_AppHost.AppHostProvider,{children:(0,_jsxRuntime.jsxs)(_MinimizedToolsContext.MinimizedToolsProvider,{getToolIcon:X,children:[(0,_jsxRuntime.jsx)(_FloatingMenu.FloatingMenu,{...D,apps:$,emptyNote:h?_teamToolsNote.NO_TEAM_TOOLS_NOTE:void 0,environment:G}),D.hidden?null:(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_AppHost.AppOverlay,{}),(0,_jsxRuntime.jsx)(_sharedUi.FloatingToolHost,{})]}),(0,_jsxRuntime.jsx)(_ToolOpenerBridge.ToolOpenerBridge,{}),(0,_jsxRuntime.jsx)(_TeamToolCloser.TeamToolCloser,{allowedTools:h??null})]})}),r,F&&(0,_jsxRuntime.jsx)(F,{}),w&&(0,_jsxRuntime.jsx)(w,{}),z&&(0,_jsxRuntime.jsx)(z,{}),H&&(0,_jsxRuntime.jsx)(H,{}),L&&(0,_jsxRuntime.jsx)(L,{}),N&&(0,_jsxRuntime.jsx)(N,{}),f&&(0,_jsxRuntime.jsx)(f,{}),v&&(0,_jsxRuntime.jsx)(v,{}),y&&(0,_jsxRuntime.jsx)(y,{}),d&&(0,_jsxRuntime.jsx)(d,{}),W,V&&(0,_jsxRuntime.jsx)(_autoExternalSync.AutoExternalSync,{options:(0,_externalSyncGate.externalSyncOptions)(m),requiredEnvVars:n,isPro:j,tier:q,licenseKey:_,customApps:S})]})})})})};exports.FloatingDevTools=FloatingDevTools;const styles=_reactNative.StyleSheet.create({container:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:9999}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FloatingDevTools=FloatingDevTools;var _floating=require("@buoy-gg/shared-ui/floating");var _license=_interopRequireWildcard(require("@buoy-gg/license"));var licenseModule=_license;var _sharedUi=require("@buoy-gg/shared-ui");var _react=require("react");var _floatingToolsReact=require("@buoy-gg/floating-tools-react");var _autoDiscoverPresetsWeb=require("../utils/autoDiscoverPresets.web.js");var _floatingToolsWeb=require("./floatingTools.web.js");var _DialDevToolsWeb=require("./dial/DialDevTools.web.js");var _dialUsageStore=require("./dial/dialUsageStore.js");var _OnboardingTooltipWeb=require("./dial/OnboardingTooltip.web.js");var _DevToolsSettingsModalWeb=require("./DevToolsSettingsModal.web.js");var _AppHostWeb=require("./AppHost.web.js");var _MinimizedToolsStackWeb=require("./MinimizedToolsStack.web.js");var _createWebTools=require("../utils/createWebTools.js");var _BrowserToolRuntime=require("./BrowserToolRuntime.js");var _releaseOptIn=require("../releaseOptIn.js");var _BuoySignInWeb=require("./BuoySignIn.web.js");var _BuoyCodeSignIn=require("./BuoyCodeSignIn.js");var _DevToolsVisibilityContext=require("./DevToolsVisibilityContext.js");var _createWebTool=require("../utils/createWebTool.js");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _DevToolsSettingsModalShared=require("./DevToolsSettingsModal.shared.js");var _defaultConfig=require("./defaultConfig.js");var _installedTools=require("../installedTools.js");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(n,i){if("function"==typeof WeakMap)var s=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(t,r){if(!r&&t&&t.__esModule)return t;var a,c,p={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return p;if(a=r?l:s){if(a.has(t))return a.get(t);a.set(t,p)}for(const d in t)"default"!==d&&{}.hasOwnProperty.call(t,d)&&((c=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,d))&&(c.get||c.set)?a(p,d,c):p[d]=t[d]);return p})(n,i)}const EMPTY_MODULES={};const MENU_TOOLTIP_KEY="@react_buoy_floating_menu_tooltip_shown";const webSettingsStorage=_sharedUi.persistentStorage;function MenuLauncherIcon({size:n=14,color:i="#20C997"}){const s=Math.max(2,n/4);const l=Math.max(1,n/16);return(0,_jsxRuntime.jsx)("div",{style:{display:"grid",gridTemplateColumns:`repeat(3, ${s}px)`,gap:l,width:n,height:n,alignContent:"center",justifyContent:"center"},children:Array.from({length:9}).map((t,r)=>(0,_jsxRuntime.jsx)("div",{style:{width:s,height:s,borderRadius:s/2,backgroundColor:i}},r))})}function AdmittedFloatingDevTools(n){const{defaultFloatingTools:i,defaultDialTools:s,disableHints:l=false,children:t}=n;const r=(0,_react.useMemo)(()=>s?(0,_defaultConfig.validateDialConfig)(s):s,[s]);return(0,_jsxRuntime.jsx)(_DefaultConfigContext.DefaultConfigProvider,{defaultFloatingTools:i,defaultDialTools:r,children:(0,_jsxRuntime.jsx)(_sharedUi.HintsProvider,{disableHints:l,children:(0,_jsxRuntime.jsxs)(_DevToolsVisibilityContext.DevToolsVisibilityProvider,{children:[(0,_jsxRuntime.jsx)(_AppHostWeb.AppHostProvider,{children:(0,_jsxRuntime.jsx)(FloatingDevToolsInner,{...n})}),t]})})})}const STARTUP_ROOTS=["ReduxAutoInstrument","ConsoleRoot","RouteTracker","ReactQueryTracker"];function StartupCapture({modules:n=EMPTY_MODULES}){return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:Object.entries(n).flatMap(([i,s])=>STARTUP_ROOTS.map(l=>{const t=s[l];return t?(0,_jsxRuntime.jsx)(t,{},`${i}:${l}`):null}))})}function WebToolOpenerBridge(){const{openApps:n,restore:i}=(0,_AppHostWeb.useAppHost)();(0,_react.useEffect)(()=>(0,_sharedUi.registerToolOpener)(s=>{const l=n.find(t=>t.id===s);if(!l)return false;i(l.instanceId);return true}),[n,i]);return null}function defaultEnvironment(){const n=(0,_license.capacitorDebug)();const i=n===null?process.env.NODE_ENV:n?"development":"production";return(0,_sharedUi.normalizeEnvironment)(i??"dev")}function configOverrides(n,i,s,l){const t=x=>Object.entries(n).find(([m])=>m.replace(/^@buoy-gg\//,"").replace(/\/web$/,"")===x)?.[1];const r=[];const a=t("env");if(i?.length&&a?.createEnvTool&&a.createEnvVarConfig){r.push((0,_createWebTool.createWebTool)(a.createEnvTool({requiredEnvVars:a.createEnvVarConfig(i)})))}const c=t("storage");if(s?.length&&c?.createStorageTool){r.push((0,_createWebTool.createWebTool)(c.createStorageTool({requiredStorageKeys:s})))}const p=t("ask-buoy");const d=l==="hosted"?p?.hostedAskBuoy?.():l;if(d&&p?.createAskBuoyTool)r.push((0,_createWebTool.createWebTool)(p.createAskBuoyTool(d)));return r}function FloatingDevToolsInner({environment:n,userRole:i="admin",availableEnvironments:s,onEnvironmentSwitch:l,apps:t,modules:r=EMPTY_MODULES,externalSync:a,requiredEnvVars:c,sentryGetClient:p,disableHints:d=false,headless:x=false,hidden:m=false,defaultFloatingTools:Y,defaultDialTools:O,zustandStores:E,requiredStorageKeys:W,askBuoy:q}){const M=n??defaultEnvironment();const G=(0,_react.useMemo)(()=>O?(0,_defaultConfig.validateDialConfig)(O):void 0,[O]);const[g,j]=(0,_react.useState)(false);const[b,_]=(0,_react.useState)(false);const w=(0,_react.useRef)(false);const v=(0,_AppHostWeb.useAppHost)();const R=(0,_react.useMemo)(()=>configOverrides(r,c,W,q),[r,c,W,q]);const f=(0,_react.useMemo)(()=>(0,_autoDiscoverPresetsWeb.autoDiscoverWithCustom)([...(0,_createWebTools.createWebTools)(r),...t??[],...R]),[t,r,R]);const I=(0,_react.useMemo)(()=>Object.entries(r).find(([e])=>e.replace(/^@buoy-gg\//,"").replace(/\/web$/,"")==="zustand")?.[1],[r]);(0,_react.useEffect)(()=>{if(!E||typeof I?.watchStores!=="function")return;const e=I.watchStores(E);return typeof e==="function"?e:void 0},[E,I]);const D=(0,_DevToolsVisibilityContext.useDevToolsVisibility)();const B=v.openApps.some(e=>!e.minimized);(0,_react.useEffect)(()=>{D.setDialOpen(g)},[g,D.setDialOpen]);(0,_react.useEffect)(()=>{D.setToolOpen(B||b)},[B,b,D.setToolOpen]);const{registerApps:F}=v;(0,_react.useEffect)(()=>{F(f.map(e=>{const o=e.icon;return{...e,icon:typeof o==="function"?({size:u})=>o(u):o}}))},[F,f]);const Q=(0,_react.useMemo)(()=>f.map(e=>({id:e.id,name:e.name,description:e.description,slot:e.slot})),[f]);(0,_floatingToolsReact.useSettings)({availableTools:Q,storage:webSettingsStorage});(0,_react.useEffect)(()=>{let e=false;const o=async()=>{const[u,T]=await Promise.all([_sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.dial.isOpen()),_sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.settings.modalOpen())]);if(e)return;if(u==="true")j(true);if(T==="true"){j(true);_(true)}w.current=true};void o();return()=>{e=true}},[]);(0,_react.useEffect)(()=>{if(!w.current)return;void _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.dial.isOpen(),g?"true":"false")},[g]);(0,_react.useEffect)(()=>{if(!w.current)return;void _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.settings.modalOpen(),b?"true":"false")},[b]);const S=(0,_react.useCallback)(e=>{void(0,_dialUsageStore.recordToolUsage)(e.id);if(e.launchMode==="toggle-only"){e.onPress?.();return}if(e.component){const o=typeof e.icon==="function"?e.icon(20):e.icon;v.open({id:e.id,title:e.name||(0,_floatingToolsReact.getToolLabel)(e.id),component:e.component,props:e.props,modal:e.modal,launchMode:e.launchMode||"self-modal",singleton:e.singleton??true,icon:o,color:e.color||(0,_floatingToolsReact.getToolColor)(e.id)})}else{e.onPress?.()}},[v]);const L=(0,_react.useRef)({tools:f,openApps:v.openApps,openTool:S});L.current={tools:f,openApps:v.openApps,openTool:S};(0,_react.useEffect)(()=>(0,_sharedUi.registerToolOpener)(e=>{const{tools:o,openApps:u,openTool:T}=L.current;if(u.some(P=>P.id===e))return false;const A=o.find(P=>P.id===e);if(!A||A.launchMode==="toggle-only")return false;T(A);return true}),[]);const C=(0,_react.useMemo)(()=>{const e=(0,_autoDiscoverPresetsWeb.getToolsBySlot)(f,"dial");return e.map(o=>{const u=o.color||(0,_floatingToolsReact.getToolColor)(o.id);let T;if(typeof o.icon==="string"){T=o.icon}else if(typeof o.icon==="function"){T=o.icon(32)}else{T=null}return{id:o.id,name:o.name||(0,_floatingToolsReact.getToolLabel)(o.id),icon:T,unavailable:!o.component&&!o.onPress,color:u,onPress:()=>{S(o);j(false)}}})},[f,S]);const J=(0,_react.useMemo)(()=>{if(!g)return C;const e=new Map(C.map(o=>[o.id,o]));return(0,_dialUsageStore.getRankedToolIds)(C.map(o=>o.id)).map(o=>e.get(o)).filter(o=>Boolean(o))},[g,C]);const{settings:k}=(0,_DevToolsSettingsModalShared.useDevToolsSettings)();const X=(0,_react.useMemo)(()=>(0,_autoDiscoverPresetsWeb.getToolsBySlot)(f,"row").filter(e=>(k.floatingTools[e.id]??false)===true&&(e.component||e.onPress)),[f,k.floatingTools]);const Z=(0,_react.useMemo)(()=>f.map(e=>({id:e.id,name:e.name||(0,_floatingToolsReact.getToolLabel)(e.id),description:e.description||(0,_floatingToolsReact.getToolDescription)(e.id),slot:e.slot,icon:e.icon,color:e.color})),[f]);const[ee,V]=(0,_react.useState)(false);const z=v.openApps.some(e=>!e.minimized);(0,_react.useEffect)(()=>{if(d)return;let e=false;const o=setTimeout(async()=>{const u=await _sharedUi.persistentStorage.getItem(MENU_TOOLTIP_KEY);if(!e&&!u)V(true)},1e3);return()=>{e=true;clearTimeout(o)}},[d]);const y=(0,_react.useCallback)(()=>{V(false);void _sharedUi.persistentStorage.setItem(MENU_TOOLTIP_KEY,"true")},[]);const K=(0,_react.useCallback)(()=>{y();j(true)},[y]);const ne=(0,_react.useCallback)(()=>{j(false);_(false)},[]);const te=(0,_react.useCallback)(()=>{_(e=>!e)},[]);const oe=(0,_react.useCallback)(()=>_(false),[]);const H=Boolean(s?.length&&l);const U=k.floatingTools.environment!==false;const h=ee&&!g&&!z&&!m;(0,_react.useEffect)(()=>{if(!h)return;const e=u=>{if(!(u.target instanceof Element)||!u.target.closest("[data-buoy-root]"))y()};const o=u=>{if(u.key==="Escape")y()};document.addEventListener("pointerdown",e,true);document.addEventListener("keydown",o);return()=>{document.removeEventListener("pointerdown",e,true);document.removeEventListener("keydown",o)}},[h,y]);const N=v.openApps.some(e=>e.minimized&&e.launchMode!=="toggle-only");const $=(0,_jsxRuntime.jsx)(_BrowserToolRuntime.BrowserToolRuntime,{modules:r,apps:t,requiredEnvVars:c,externalSync:a,headless:x,sentryGetClient:p});if(x)return $;return(0,_jsxRuntime.jsxs)("div",{"data-buoy-root":"",style:{display:"contents"},children:[$,(0,_jsxRuntime.jsx)(WebToolOpenerBridge,{}),h&&(0,_jsxRuntime.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.85)",zIndex:1e4,pointerEvents:"none"}}),(0,_jsxRuntime.jsx)("div",{style:m?{visibility:"hidden"}:{display:"contents"},"aria-hidden":m||void 0,children:(0,_jsxRuntime.jsxs)(_floatingToolsWeb.FloatingTools,{enablePositionPersistence:!h,pushToSide:g||z,suspendPointerEvents:g,centerOnboarding:h,minimizedStack:N?(0,_jsxRuntime.jsx)(_MinimizedToolsStackWeb.MinimizedToolsStack,{}):void 0,hasMinimizedStack:N,children:[M&&U&&!H&&(0,_jsxRuntime.jsx)(_sharedUi.EnvironmentIndicator,{environment:M}),H&&U&&(0,_jsxRuntime.jsx)(_sharedUi.EnvironmentSelectorInline,{currentEnvironment:M??"local",availableEnvironments:s,onSelect:l}),i?(0,_jsxRuntime.jsx)(_floatingToolsWeb.UserStatus,{userRole:i,onPress:K}):(0,_jsxRuntime.jsx)("button",{"aria-label":"Open dev tools",onClick:K,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",background:"none",border:"none",cursor:"pointer"},children:(0,_jsxRuntime.jsx)(MenuLauncherIcon,{})}),X.map(e=>(0,_jsxRuntime.jsx)("button",{"aria-label":e.name||(0,_floatingToolsReact.getToolLabel)(e.id),title:e.description,onClick:()=>S(e),style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",borderRadius:6,background:"none",border:"none",cursor:"pointer"},children:typeof e.icon==="function"?e.icon(16):e.icon},e.id))]})}),h&&(0,_jsxRuntime.jsx)(_OnboardingTooltipWeb.OnboardingTooltip,{title:"Welcome to Buoy!",message:"Grab and position this menu wherever you want, then tap the icon to open your tools.",onDismiss:y}),g&&!m&&(0,_jsxRuntime.jsx)(_DialDevToolsWeb.DialMenu,{icons:J,onClose:ne,centerLabel:"BUOY",onCenterPress:te,settingsOpen:b,hintsDisabled:d}),b&&!m&&(0,_jsxRuntime.jsx)(_DevToolsSettingsModalWeb.SettingsModal,{visible:true,onClose:oe,availableTools:Z,defaultFloatingTools:Y,defaultDialTools:G,onSettingsChange:e=>{}}),!m&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_AppHostWeb.AppOverlay,{}),(0,_jsxRuntime.jsx)(_floating.FloatingToolHost,{})]})]})}function useCapacitorSignInAudience(n){const i=n&&typeof n==="object"?n.appId:void 0;const s=!!n;(0,_react.useEffect)(()=>{if(!s)return;let l=false;const t=licenseModule.SessionManager;if(!t)return;const r=a=>{if(l||!a)return;t.configure({audience:`app:${a}`});void t.load().catch(()=>{})};if(i)r(i);else void(0,_license.loadCapacitorAppHost)().then(a=>r(a?.bundleId)).catch(()=>{});return()=>{l=true}},[s,i])}let warnedNoTools=false;function withInstalledTools(n){if(n.modules)return n;if(!_installedTools.installedToolsFound&&!warnedNoTools&&typeof console!=="undefined"){warnedNoTools=true;console.info("[Buoy] No tools loaded. Add buoy() from '@buoy-gg/core/vite' to your Vite plugins, or pass modules to FloatingDevTools.")}return{...n,modules:_installedTools.installedTools}}function FloatingDevTools(n){return(0,_jsxRuntime.jsx)(_floating.BuoyPortal,{children:(0,_jsxRuntime.jsx)(FloatingDevToolsContent,{...withInstalledTools(n)})})}function FloatingDevToolsContent(n){const{access:i,isPro:s,licenseKey:l}=(0,_license.useLicense)();(0,_react.useEffect)(()=>{void _license.LicenseManager.configure(n.licenseKey)},[n.licenseKey]);const t=n.licenseKey===void 0||(0,_license.sameLicenseKey)(n.licenseKey,l);const r=(0,_license.resolveDevBuild)(typeof __DEV__!=="undefined"?__DEV__:process.env.NODE_ENV!=="production");const a=t&&i.status==="admitted";(0,_react.useEffect)(()=>{if(a)(0,_sharedUi.startSettingsSync)()},[a]);(0,_react.useEffect)(()=>{if(r||i.status==="initializing")return;if(s&&a)(0,_releaseOptIn.markReleaseOptIn)();else(0,_releaseOptIn.clearReleaseOptIn)()},[r,s,a,i.status]);const c=(0,_license.isCapacitorNative)();useCapacitorSignInAudience(c?n.signIn:void 0);if(!r&&!s){if(!n.signIn||n.headless)return null;return c?(0,_jsxRuntime.jsx)(_BuoyCodeSignIn.BuoySignIn,{needsPlan:true}):(0,_jsxRuntime.jsx)(_BuoySignInWeb.BuoySignIn,{})}if(!a){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[i.status==="initializing"&&(0,_jsxRuntime.jsx)(StartupCapture,{modules:n.modules}),n.headless?null:n.signIn&&c?(0,_jsxRuntime.jsx)(_BuoyCodeSignIn.BuoySignIn,{}):(0,_jsxRuntime.jsx)(_sharedUi.AccountSetup,{})]})}return(0,_jsxRuntime.jsx)(AdmittedFloatingDevTools,{...n})}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FloatingDevTools=FloatingDevTools;var _floating=require("@buoy-gg/shared-ui/floating");var _license=_interopRequireWildcard(require("@buoy-gg/license"));var licenseModule=_license;var _sharedUi=require("@buoy-gg/shared-ui");var _react=require("react");var _floatingToolsReact=require("@buoy-gg/floating-tools-react");var _autoDiscoverPresetsWeb=require("../utils/autoDiscoverPresets.web.js");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _teamToolsNote=require("./teamToolsNote.js");var _floatingToolsWeb=require("./floatingTools.web.js");var _DialDevToolsWeb=require("./dial/DialDevTools.web.js");var _dialUsageStore=require("./dial/dialUsageStore.js");var _OnboardingTooltipWeb=require("./dial/OnboardingTooltip.web.js");var _DevToolsSettingsModalWeb=require("./DevToolsSettingsModal.web.js");var _AppHostWeb=require("./AppHost.web.js");var _MinimizedToolsStackWeb=require("./MinimizedToolsStack.web.js");var _createWebTools=require("../utils/createWebTools.js");var _BrowserToolRuntime=require("./BrowserToolRuntime.js");var _releaseOptIn=require("../releaseOptIn.js");var _BuoySignInWeb=require("./BuoySignIn.web.js");var _BuoyCodeSignIn=require("./BuoyCodeSignIn.js");var _DevToolsVisibilityContext=require("./DevToolsVisibilityContext.js");var _createWebTool=require("../utils/createWebTool.js");var _DefaultConfigContext=require("./DefaultConfigContext.js");var _DevToolsSettingsModalShared=require("./DevToolsSettingsModal.shared.js");var _defaultConfig=require("./defaultConfig.js");var _installedTools=require("../installedTools.js");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(n,i){if("function"==typeof WeakMap)var s=new WeakMap,l=new WeakMap;return(_interopRequireWildcard=function(t,r){if(!r&&t&&t.__esModule)return t;var a,c,p={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return p;if(a=r?l:s){if(a.has(t))return a.get(t);a.set(t,p)}for(const d in t)"default"!==d&&{}.hasOwnProperty.call(t,d)&&((c=(a=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,d))&&(c.get||c.set)?a(p,d,c):p[d]=t[d]);return p})(n,i)}const EMPTY_MODULES={};const MENU_TOOLTIP_KEY="@react_buoy_floating_menu_tooltip_shown";const webSettingsStorage=_sharedUi.persistentStorage;function MenuLauncherIcon({size:n=14,color:i="#20C997"}){const s=Math.max(2,n/4);const l=Math.max(1,n/16);return(0,_jsxRuntime.jsx)("div",{style:{display:"grid",gridTemplateColumns:`repeat(3, ${s}px)`,gap:l,width:n,height:n,alignContent:"center",justifyContent:"center"},children:Array.from({length:9}).map((t,r)=>(0,_jsxRuntime.jsx)("div",{style:{width:s,height:s,borderRadius:s/2,backgroundColor:i}},r))})}function AdmittedFloatingDevTools(n){const{defaultFloatingTools:i,defaultDialTools:s,disableHints:l=false,children:t}=n;const r=(0,_react.useMemo)(()=>s?(0,_defaultConfig.validateDialConfig)(s):s,[s]);return(0,_jsxRuntime.jsx)(_DefaultConfigContext.DefaultConfigProvider,{defaultFloatingTools:i,defaultDialTools:r,children:(0,_jsxRuntime.jsx)(_sharedUi.HintsProvider,{disableHints:l,children:(0,_jsxRuntime.jsxs)(_DevToolsVisibilityContext.DevToolsVisibilityProvider,{children:[(0,_jsxRuntime.jsx)(_AppHostWeb.AppHostProvider,{children:(0,_jsxRuntime.jsx)(FloatingDevToolsInner,{...n})}),t]})})})}const STARTUP_ROOTS=["ReduxAutoInstrument","ConsoleRoot","RouteTracker","ReactQueryTracker"];function StartupCapture({modules:n=EMPTY_MODULES}){return(0,_jsxRuntime.jsx)(_jsxRuntime.Fragment,{children:Object.entries(n).flatMap(([i,s])=>STARTUP_ROOTS.map(l=>{const t=s[l];return t?(0,_jsxRuntime.jsx)(t,{},`${i}:${l}`):null}))})}function WebToolOpenerBridge(){const{openApps:n,restore:i}=(0,_AppHostWeb.useAppHost)();(0,_react.useEffect)(()=>(0,_sharedUi.registerToolOpener)(s=>{const l=n.find(t=>t.id===s);if(!l)return false;i(l.instanceId);return true}),[n,i]);return null}function defaultEnvironment(){const n=(0,_license.capacitorDebug)();const i=n===null?process.env.NODE_ENV:n?"development":"production";return(0,_sharedUi.normalizeEnvironment)(i??"dev")}function configOverrides(n,i,s,l){const t=x=>Object.entries(n).find(([v])=>v.replace(/^@buoy-gg\//,"").replace(/\/web$/,"")===x)?.[1];const r=[];const a=t("env");if(i?.length&&a?.createEnvTool&&a.createEnvVarConfig){r.push((0,_createWebTool.createWebTool)(a.createEnvTool({requiredEnvVars:a.createEnvVarConfig(i)})))}const c=t("storage");if(s?.length&&c?.createStorageTool){r.push((0,_createWebTool.createWebTool)(c.createStorageTool({requiredStorageKeys:s})))}const p=t("ask-buoy");const d=l==="hosted"?p?.hostedAskBuoy?.():l;if(d&&p?.createAskBuoyTool)r.push((0,_createWebTool.createWebTool)(p.createAskBuoyTool(d)));return r}function FloatingDevToolsInner({environment:n,userRole:i="admin",availableEnvironments:s,onEnvironmentSwitch:l,apps:t,modules:r=EMPTY_MODULES,externalSync:a,requiredEnvVars:c,sentryGetClient:p,disableHints:d=false,headless:x=false,hidden:v=false,defaultFloatingTools:X,defaultDialTools:E,zustandStores:w,requiredStorageKeys:q,askBuoy:R}){const M=n??defaultEnvironment();const Z=(0,_react.useMemo)(()=>E?(0,_defaultConfig.validateDialConfig)(E):void 0,[E]);const[g,S]=(0,_react.useState)(false);const[b,C]=(0,_react.useState)(false);const I=(0,_react.useRef)(false);const m=(0,_AppHostWeb.useAppHost)();const B=(0,_react.useMemo)(()=>configOverrides(r,c,q,R),[r,c,q,R]);const{allowedTools:y}=(0,_license.useLicense)();const f=(0,_react.useMemo)(()=>(0,_floatingToolsCore.filterTeamTools)((0,_autoDiscoverPresetsWeb.autoDiscoverWithCustom)([...(0,_createWebTools.createWebTools)(r),...t??[],...B]),y),[t,r,B,y]);const{openApps:L,close:F}=m;(0,_react.useEffect)(()=>{if(!y)return;for(const e of L){if(!(0,_floatingToolsCore.isTeamToolAllowed)(e.id,y))F(e.instanceId)}},[L,y,F]);const k=(0,_react.useMemo)(()=>Object.entries(r).find(([e])=>e.replace(/^@buoy-gg\//,"").replace(/\/web$/,"")==="zustand")?.[1],[r]);(0,_react.useEffect)(()=>{if(!w||typeof k?.watchStores!=="function")return;const e=k.watchStores(w);return typeof e==="function"?e:void 0},[w,k]);const D=(0,_DevToolsVisibilityContext.useDevToolsVisibility)();const N=m.openApps.some(e=>!e.minimized);(0,_react.useEffect)(()=>{D.setDialOpen(g)},[g,D.setDialOpen]);(0,_react.useEffect)(()=>{D.setToolOpen(N||b)},[N,b,D.setToolOpen]);const{registerApps:V}=m;(0,_react.useEffect)(()=>{V(f.map(e=>{const o=e.icon;return{...e,icon:typeof o==="function"?({size:u})=>o(u):o}}))},[V,f]);const ee=(0,_react.useMemo)(()=>f.map(e=>({id:e.id,name:e.name,description:e.description,slot:e.slot})),[f]);(0,_floatingToolsReact.useSettings)({availableTools:ee,storage:webSettingsStorage});(0,_react.useEffect)(()=>{let e=false;const o=async()=>{const[u,T]=await Promise.all([_sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.dial.isOpen()),_sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.settings.modalOpen())]);if(e)return;if(u==="true")S(true);if(T==="true"){S(true);C(true)}I.current=true};void o();return()=>{e=true}},[]);(0,_react.useEffect)(()=>{if(!I.current)return;void _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.dial.isOpen(),g?"true":"false")},[g]);(0,_react.useEffect)(()=>{if(!I.current)return;void _sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.settings.modalOpen(),b?"true":"false")},[b]);const _=(0,_react.useCallback)(e=>{void(0,_dialUsageStore.recordToolUsage)(e.id);if(e.launchMode==="toggle-only"){e.onPress?.();return}if(e.component){const o=typeof e.icon==="function"?e.icon(20):e.icon;m.open({id:e.id,title:e.name||(0,_floatingToolsReact.getToolLabel)(e.id),component:e.component,props:e.props,modal:e.modal,launchMode:e.launchMode||"self-modal",singleton:e.singleton??true,icon:o,color:e.color||(0,_floatingToolsReact.getToolColor)(e.id)})}else{e.onPress?.()}},[m]);const z=(0,_react.useRef)({tools:f,openApps:m.openApps,openTool:_});z.current={tools:f,openApps:m.openApps,openTool:_};(0,_react.useEffect)(()=>(0,_sharedUi.registerToolOpener)(e=>{const{tools:o,openApps:u,openTool:T}=z.current;if(u.some(W=>W.id===e))return false;const P=o.find(W=>W.id===e);if(!P||P.launchMode==="toggle-only")return false;T(P);return true}),[]);const O=(0,_react.useMemo)(()=>{const e=(0,_autoDiscoverPresetsWeb.getToolsBySlot)(f,"dial");return e.map(o=>{const u=o.color||(0,_floatingToolsReact.getToolColor)(o.id);let T;if(typeof o.icon==="string"){T=o.icon}else if(typeof o.icon==="function"){T=o.icon(32)}else{T=null}return{id:o.id,name:o.name||(0,_floatingToolsReact.getToolLabel)(o.id),icon:T,unavailable:!o.component&&!o.onPress,color:u,onPress:()=>{_(o);S(false)}}})},[f,_]);const K=(0,_react.useMemo)(()=>{if(!g)return O;const e=new Map(O.map(o=>[o.id,o]));return(0,_dialUsageStore.getRankedToolIds)(O.map(o=>o.id)).map(o=>e.get(o)).filter(o=>Boolean(o))},[g,O]);const{settings:A}=(0,_DevToolsSettingsModalShared.useDevToolsSettings)();const ne=(0,_react.useMemo)(()=>(0,_autoDiscoverPresetsWeb.getToolsBySlot)(f,"row").filter(e=>(A.floatingTools[e.id]??false)===true&&(e.component||e.onPress)),[f,A.floatingTools]);const te=(0,_react.useMemo)(()=>f.map(e=>({id:e.id,name:e.name||(0,_floatingToolsReact.getToolLabel)(e.id),description:e.description||(0,_floatingToolsReact.getToolDescription)(e.id),slot:e.slot,icon:e.icon,color:e.color})),[f]);const[oe,H]=(0,_react.useState)(false);const U=m.openApps.some(e=>!e.minimized);(0,_react.useEffect)(()=>{if(d)return;let e=false;const o=setTimeout(async()=>{const u=await _sharedUi.persistentStorage.getItem(MENU_TOOLTIP_KEY);if(!e&&!u)H(true)},1e3);return()=>{e=true;clearTimeout(o)}},[d]);const h=(0,_react.useCallback)(()=>{H(false);void _sharedUi.persistentStorage.setItem(MENU_TOOLTIP_KEY,"true")},[]);const $=(0,_react.useCallback)(()=>{h();S(true)},[h]);const se=(0,_react.useCallback)(()=>{S(false);C(false)},[]);const ie=(0,_react.useCallback)(()=>{C(e=>!e)},[]);const re=(0,_react.useCallback)(()=>C(false),[]);const Y=Boolean(s?.length&&l);const G=A.floatingTools.environment!==false;const j=oe&&!g&&!U&&!v;(0,_react.useEffect)(()=>{if(!j)return;const e=u=>{if(!(u.target instanceof Element)||!u.target.closest("[data-buoy-root]"))h()};const o=u=>{if(u.key==="Escape")h()};document.addEventListener("pointerdown",e,true);document.addEventListener("keydown",o);return()=>{document.removeEventListener("pointerdown",e,true);document.removeEventListener("keydown",o)}},[j,h]);const Q=m.openApps.some(e=>e.minimized&&e.launchMode!=="toggle-only");const J=(0,_jsxRuntime.jsx)(_BrowserToolRuntime.BrowserToolRuntime,{modules:r,apps:t,requiredEnvVars:c,externalSync:a,headless:x,sentryGetClient:p});if(x)return J;return(0,_jsxRuntime.jsxs)("div",{"data-buoy-root":"",style:{display:"contents"},children:[J,(0,_jsxRuntime.jsx)(WebToolOpenerBridge,{}),j&&(0,_jsxRuntime.jsx)("div",{style:{position:"fixed",inset:0,backgroundColor:"rgba(0,0,0,0.85)",zIndex:1e4,pointerEvents:"none"}}),(0,_jsxRuntime.jsx)("div",{style:v?{visibility:"hidden"}:{display:"contents"},"aria-hidden":v||void 0,children:(0,_jsxRuntime.jsxs)(_floatingToolsWeb.FloatingTools,{enablePositionPersistence:!j,pushToSide:g||U,suspendPointerEvents:g,centerOnboarding:j,minimizedStack:Q?(0,_jsxRuntime.jsx)(_MinimizedToolsStackWeb.MinimizedToolsStack,{}):void 0,hasMinimizedStack:Q,children:[M&&G&&!Y&&(0,_jsxRuntime.jsx)(_sharedUi.EnvironmentIndicator,{environment:M}),Y&&G&&(0,_jsxRuntime.jsx)(_sharedUi.EnvironmentSelectorInline,{currentEnvironment:M??"local",availableEnvironments:s,onSelect:l}),i?(0,_jsxRuntime.jsx)(_floatingToolsWeb.UserStatus,{userRole:i,onPress:$}):(0,_jsxRuntime.jsx)("button",{"aria-label":"Open dev tools",onClick:$,style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"6px 8px",background:"none",border:"none",cursor:"pointer"},children:(0,_jsxRuntime.jsx)(MenuLauncherIcon,{})}),ne.map(e=>(0,_jsxRuntime.jsx)("button",{"aria-label":e.name||(0,_floatingToolsReact.getToolLabel)(e.id),title:e.description,onClick:()=>_(e),style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"4px 6px",borderRadius:6,background:"none",border:"none",cursor:"pointer"},children:typeof e.icon==="function"?e.icon(16):e.icon},e.id))]})}),j&&(0,_jsxRuntime.jsx)(_OnboardingTooltipWeb.OnboardingTooltip,{title:"Welcome to Buoy!",message:"Grab and position this menu wherever you want, then tap the icon to open your tools.",onDismiss:h}),g&&!v&&(0,_jsxRuntime.jsx)(_DialDevToolsWeb.DialMenu,{icons:K,onClose:se,centerLabel:"BUOY",onCenterPress:ie,settingsOpen:b,hintsDisabled:d,emptyNote:y&&K.length===0?_teamToolsNote.NO_TEAM_TOOLS_NOTE:void 0}),b&&!v&&(0,_jsxRuntime.jsx)(_DevToolsSettingsModalWeb.SettingsModal,{visible:true,onClose:re,availableTools:te,defaultFloatingTools:X,defaultDialTools:Z,onSettingsChange:e=>{}}),!v&&(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[(0,_jsxRuntime.jsx)(_AppHostWeb.AppOverlay,{}),(0,_jsxRuntime.jsx)(_floating.FloatingToolHost,{})]})]})}function useCapacitorSignInAudience(n){const i=n&&typeof n==="object"?n.appId:void 0;const s=!!n;(0,_react.useEffect)(()=>{if(!s)return;let l=false;const t=licenseModule.SessionManager;if(!t)return;const r=a=>{if(l||!a)return;t.configure({audience:`app:${a}`});void t.load().catch(()=>{})};if(i)r(i);else void(0,_license.loadCapacitorAppHost)().then(a=>r(a?.bundleId)).catch(()=>{});return()=>{l=true}},[s,i])}let warnedNoTools=false;function withInstalledTools(n){if(n.modules)return n;if(!_installedTools.installedToolsFound&&!warnedNoTools&&typeof console!=="undefined"){warnedNoTools=true;console.info("[Buoy] No tools loaded. Add buoy() from '@buoy-gg/core/vite' to your Vite plugins, or pass modules to FloatingDevTools.")}return{...n,modules:_installedTools.installedTools}}function FloatingDevTools(n){return(0,_jsxRuntime.jsx)(_floating.BuoyPortal,{children:(0,_jsxRuntime.jsx)(FloatingDevToolsContent,{...withInstalledTools(n)})})}function FloatingDevToolsContent(n){const{access:i,isPro:s,licenseKey:l}=(0,_license.useLicense)();(0,_react.useEffect)(()=>{void _license.LicenseManager.configure(n.licenseKey)},[n.licenseKey]);const t=n.licenseKey===void 0||(0,_license.sameLicenseKey)(n.licenseKey,l);const r=(0,_license.resolveDevBuild)(typeof __DEV__!=="undefined"?__DEV__:process.env.NODE_ENV!=="production");const a=t&&i.status==="admitted";(0,_react.useEffect)(()=>{if(a)(0,_sharedUi.startSettingsSync)()},[a]);(0,_react.useEffect)(()=>{if(r||i.status==="initializing")return;if(s&&a)(0,_releaseOptIn.markReleaseOptIn)();else(0,_releaseOptIn.clearReleaseOptIn)()},[r,s,a,i.status]);const c=(0,_license.isCapacitorNative)();useCapacitorSignInAudience(c?n.signIn:void 0);if(!r&&!s){if(!n.signIn||n.headless)return null;return c?(0,_jsxRuntime.jsx)(_BuoyCodeSignIn.BuoySignIn,{needsPlan:true}):(0,_jsxRuntime.jsx)(_BuoySignInWeb.BuoySignIn,{})}if(!a){return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[i.status==="initializing"&&(0,_jsxRuntime.jsx)(StartupCapture,{modules:n.modules}),n.headless?null:n.signIn&&c?(0,_jsxRuntime.jsx)(_BuoyCodeSignIn.BuoySignIn,{}):(0,_jsxRuntime.jsx)(_sharedUi.AccountSetup,{})]})}return(0,_jsxRuntime.jsx)(AdmittedFloatingDevTools,{...n})}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FloatingMenu=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _floatingTools=require("./floatingTools");var _AppIcon=require("./AppIcon");var _DialDevTools=require("./dial/DialDevTools");var _DevToolsSettingsModal=require("./DevToolsSettingsModal");var _AppHost=require("./AppHost");var _DevToolsVisibilityContext=require("./DevToolsVisibilityContext.js");var _ToggleStateManager=require("./ToggleStateManager.js");var _OnboardingTooltip=require("./dial/OnboardingTooltip");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(o,
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.FloatingMenu=void 0;var _react=_interopRequireWildcard(require("react"));var _reactNative=require("react-native");var _sharedUi=require("@buoy-gg/shared-ui");var _floatingTools=require("./floatingTools");var _AppIcon=require("./AppIcon");var _DialDevTools=require("./dial/DialDevTools");var _DevToolsSettingsModal=require("./DevToolsSettingsModal");var _AppHost=require("./AppHost");var _DevToolsVisibilityContext=require("./DevToolsVisibilityContext.js");var _ToggleStateManager=require("./ToggleStateManager.js");var _OnboardingTooltip=require("./dial/OnboardingTooltip");var _jsxRuntime=require("react/jsx-runtime");function _interopRequireWildcard(o,g){if("function"==typeof WeakMap)var c=new WeakMap,f=new WeakMap;return(_interopRequireWildcard=function(t,u){if(!u&&t&&t.__esModule)return t;var s,d,l={__proto__:null,default:t};if(null===t||"object"!=typeof t&&"function"!=typeof t)return l;if(s=u?f:c){if(s.has(t))return s.get(t);s.set(t,l)}for(const r in t)"default"!==r&&{}.hasOwnProperty.call(t,r)&&((d=(s=Object.defineProperty)&&Object.getOwnPropertyDescriptor(t,r))&&(d.get||d.set)?s(l,r,d):l[r]=t[r]);return l})(o,g)}const FLOATING_MENU_ONBOARDING_KEY="@react_buoy_floating_menu_tooltip_shown";const ONBOARDING_STEP_KEY="@react_buoy_onboarding_step";const FloatingMenu=({apps:o,emptyNote:g,state:c,actions:f,hidden:t,environment:u,userRole:s="admin",availableEnvironments:d,onEnvironmentSwitch:l})=>{const[r,m]=(0,_react.useState)(false);const[i,h]=(0,_react.useState)(false);const[O,B]=(0,_react.useState)(false);const[V,x]=(0,_react.useState)(null);const[,M]=(0,_react.useState)(0);const j=(0,_react.useRef)(false);const y=(0,_sharedUi.useHintsDisabled)();(0,_react.useEffect)(()=>{const e=async()=>{try{const n=await _sharedUi.persistentStorage.getItem(_sharedUi.devToolsStorageKeys.dial.isOpen());if(n==="true"){h(true)}}catch(n){}finally{B(true)}};e()},[]);(0,_react.useEffect)(()=>{if(!O)return;_sharedUi.persistentStorage.setItem(_sharedUi.devToolsStorageKeys.dial.isOpen(),i?"true":"false").catch(e=>{console.warn("[Buoy]","Failed to save dial state:",e)})},[i,O]);const I=Boolean(d?.length&&l);const{isAnyOpen:a,open:H,registerApps:v,openApps:E}=(0,_AppHost.useAppHost)();const A=(0,_react.useRef)(a);const{setDialOpen:C,setToolOpen:P}=(0,_DevToolsVisibilityContext.useDevToolsVisibility)();(0,_react.useEffect)(()=>{if(y){return}const e=async()=>{try{const n=await _sharedUi.persistentStorage.getItem(FLOATING_MENU_ONBOARDING_KEY);if(!n){setTimeout(()=>{x("positioning")},1e3)}}catch(n){}};e()},[y]);(0,_react.useEffect)(()=>{const e=_ToggleStateManager.toggleStateManager.subscribe(()=>{M(n=>n+1)});return e},[]);(0,_react.useEffect)(()=>{C(i)},[i,C]);(0,_react.useEffect)(()=>{P(a)},[a,P]);const k=(0,_react.useMemo)(()=>Boolean(i||a),[i,a]);const S=(0,_react.useMemo)(()=>Boolean(t??r),[t,r]);const{settings:p}=(0,_DevToolsSettingsModal.useDevToolsSettings)();(0,_react.useEffect)(()=>{if(v){v(o)}},[o,v]);const _=(0,_react.useMemo)(()=>{return{...f??{},closeMenu:()=>h(false),hideFloatingRow:()=>m(true),showFloatingRow:()=>m(false),notifyToggleChange:()=>M(e=>e+1)}},[f]);(0,_react.useEffect)(()=>{if(A.current&&!a){m(false);h(false)}A.current=a},[a]);const W=e=>{if(!p)return false;return p.floatingTools[e]??false};const T=e=>{e?.onPress?.(_);if(e.launchMode!=="toggle-only"){const n=(0,_AppIcon.renderAppIcon)(e.icon,{slot:"dial",size:20,color:e.color});H({id:e.id,title:e.name,component:e.component,props:e.props,launchMode:e.launchMode??"self-modal",singleton:e.singleton??true,icon:n,color:e.color,modal:e.modal})}};const R=(0,_react.useRef)({apps:o,openApps:E,handlePress:T});R.current={apps:o,openApps:E,handlePress:T};(0,_react.useEffect)(()=>(0,_sharedUi.registerToolOpener)(e=>{const{apps:n,openApps:z,handlePress:L}=R.current;if(z.some(D=>D.id===e))return false;const w=n.find(D=>D.id===e);if(!w||w.launchMode==="toggle-only")return false;L(w);return true}),[]);const q=()=>{j.current=true;x(null);_sharedUi.persistentStorage.setItem(FLOATING_MENU_ONBOARDING_KEY,"true").catch(e=>{console.warn("[Buoy]","Failed to save onboarding state:",e)})};const F=()=>{if(b){q()}h(true)};const b=V==="positioning"&&!j.current&&!y;const N=!b;return(0,_jsxRuntime.jsxs)(_jsxRuntime.Fragment,{children:[b&&!i&&!a&&(0,_jsxRuntime.jsxs)(_reactNative.View,{style:styles.onboardingContainer,children:[(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.onboardingBackdrop}),(0,_jsxRuntime.jsx)(_OnboardingTooltip.OnboardingTooltip,{visible:true,onDismiss:q,title:"Welcome to Buoy!",message:"Grab and position this menu wherever you want, then tap the icon to open your tools."})]}),(0,_jsxRuntime.jsx)(_reactNative.View,{nativeID:"floating-devtools-root",pointerEvents:S||i?"none":"box-none",style:{position:"absolute",top:0,left:0,right:0,bottom:0,zIndex:b?10001:9999,opacity:S?0:1},children:(0,_jsxRuntime.jsxs)(_floatingTools.FloatingTools,{enablePositionPersistence:N,pushToSide:k,centerOnboarding:b,environment:u,availableEnvironments:d,onEnvironmentSwitch:l,showEnvironmentSelector:I&&p?.floatingTools?.environment,children:[u&&p?.floatingTools?.environment!==false&&!I?(0,_jsxRuntime.jsx)(_sharedUi.EnvironmentIndicator,{environment:u}):null,s?(0,_jsxRuntime.jsx)(_floatingTools.UserStatus,{userRole:s,onPress:F}):(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{accessibilityLabel:"Open Dev Tools Menu",onPress:F,style:styles.fab,children:(0,_jsxRuntime.jsx)(_reactNative.View,{style:styles.menuButton,children:(0,_jsxRuntime.jsx)(MenuLauncherIcon,{size:14})})}),o.filter(e=>(e.slot??"both")!=="dial"&&W(e.id)).map(e=>(0,_jsxRuntime.jsx)(_reactNative.TouchableOpacity,{accessibilityLabel:e.name,onPress:()=>T(e),style:styles.fab,children:(()=>{if(typeof e.icon==="function"){const n=e.icon;return(0,_jsxRuntime.jsx)(n,{slot:"row",size:16,state:c,actions:_})}return(0,_AppIcon.renderAppIcon)(e.icon,{slot:"row",size:16,color:e.color})})()},`row-${e.id}`))]})}),i&&!S&&(0,_jsxRuntime.jsx)(_DialDevTools.DialDevTools,{apps:o,emptyNote:g,state:c,actions:_,onClose:()=>{h(false)}})]})};exports.FloatingMenu=FloatingMenu;const styles=_reactNative.StyleSheet.create({fab:{paddingHorizontal:6,paddingVertical:4,borderRadius:6,marginRight:4,alignItems:"center",justifyContent:"center",minWidth:0,minHeight:0,backgroundColor:"transparent"},menuButton:{paddingHorizontal:4,paddingVertical:2,minWidth:16,alignItems:"center",justifyContent:"center"},menuDots:{color:"#8CA2C8",fontSize:14,fontWeight:"900"},onboardingContainer:{..._sharedUi.absoluteFill,zIndex:1e4},onboardingBackdrop:{..._sharedUi.absoluteFill,backgroundColor:"rgba(0, 0, 0, 0.85)"}});const MenuLauncherIcon=({size:o=14,color:g=_sharedUi.buoyColors.primary})=>{const c=Math.max(2,Math.floor(o/4));const f=Math.max(1,Math.floor(o/16));const t=Array.from({length:9});return(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:o,height:o,flexDirection:"row",flexWrap:"wrap",alignContent:"center",justifyContent:"center"},children:t.map((u,s)=>(0,_jsxRuntime.jsx)(_reactNative.View,{style:{width:c,height:c,margin:f,borderRadius:2,backgroundColor:g}},s))})};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.TeamToolCloser=TeamToolCloser;var _react=require("react");var _floatingToolsCore=require("@buoy-gg/floating-tools-core");var _AppHost=require("./AppHost");function TeamToolCloser({allowedTools:e}){const{openApps:o,close:r}=(0,_AppHost.useAppHost)();(0,_react.useEffect)(()=>{if(!e)return;for(const t of o){if(!(0,_floatingToolsCore.isTeamToolAllowed)(t.id,e))r(t.instanceId)}},[o,e,r]);return null}
|