UNPKG

@nuxt/devtools

Version:

The Nuxt DevTools gives you insights and transparency about your Nuxt App.

123 lines (118 loc) 5.89 kB
import { defineNuxtModule } from '@nuxt/kit'; import { isGlobalInstall } from '../dirs.mjs'; const r=Object.create(null),i=e=>globalThis.process?.env||import.meta.env||globalThis.Deno?.env.toObject()||globalThis.__env__||(e?r:globalThis),o=new Proxy(r,{get(e,s){return i()[s]??r[s]},has(e,s){const E=i();return s in E||s in r},set(e,s,E){const B=i(true);return B[s]=E,true},deleteProperty(e,s){if(!s)return false;const E=i(true);return delete E[s],true},ownKeys(){const e=i(true);return Object.keys(e)}}),t=typeof process<"u"&&process.env&&process.env.NODE_ENV||"",f=[["APPVEYOR"],["AWS_AMPLIFY","AWS_APP_ID",{ci:true}],["AZURE_PIPELINES","SYSTEM_TEAMFOUNDATIONCOLLECTIONURI"],["AZURE_STATIC","INPUT_AZURE_STATIC_WEB_APPS_API_TOKEN"],["APPCIRCLE","AC_APPCIRCLE"],["BAMBOO","bamboo_planKey"],["BITBUCKET","BITBUCKET_COMMIT"],["BITRISE","BITRISE_IO"],["BUDDY","BUDDY_WORKSPACE_ID"],["BUILDKITE"],["CIRCLE","CIRCLECI"],["CIRRUS","CIRRUS_CI"],["CLOUDFLARE_PAGES","CF_PAGES",{ci:true}],["CLOUDFLARE_WORKERS","WORKERS_CI",{ci:true}],["CODEBUILD","CODEBUILD_BUILD_ARN"],["CODEFRESH","CF_BUILD_ID"],["DRONE"],["DRONE","DRONE_BUILD_EVENT"],["DSARI"],["GITHUB_ACTIONS"],["GITLAB","GITLAB_CI"],["GITLAB","CI_MERGE_REQUEST_ID"],["GOCD","GO_PIPELINE_LABEL"],["LAYERCI"],["HUDSON","HUDSON_URL"],["JENKINS","JENKINS_URL"],["MAGNUM"],["NETLIFY"],["NETLIFY","NETLIFY_LOCAL",{ci:false}],["NEVERCODE"],["RENDER"],["SAIL","SAILCI"],["SEMAPHORE"],["SCREWDRIVER"],["SHIPPABLE"],["SOLANO","TDDIUM"],["STRIDER"],["TEAMCITY","TEAMCITY_VERSION"],["TRAVIS"],["VERCEL","NOW_BUILDER"],["VERCEL","VERCEL",{ci:false}],["VERCEL","VERCEL_ENV",{ci:false}],["APPCENTER","APPCENTER_BUILD_ID"],["CODESANDBOX","CODESANDBOX_SSE",{ci:false}],["CODESANDBOX","CODESANDBOX_HOST",{ci:false}],["STACKBLITZ"],["STORMKIT"],["CLEAVR"],["ZEABUR"],["CODESPHERE","CODESPHERE_APP_ID",{ci:true}],["RAILWAY","RAILWAY_PROJECT_ID"],["RAILWAY","RAILWAY_SERVICE_ID"],["DENO-DEPLOY","DENO_DEPLOYMENT_ID"],["FIREBASE_APP_HOSTING","FIREBASE_APP_HOSTING",{ci:true}]];function b(){if(globalThis.process?.env)for(const e of f){const s=e[1]||e[0];if(globalThis.process?.env[s])return {name:e[0].toLowerCase(),...e[2]}}return globalThis.process?.env?.SHELL==="/bin/jsh"&&globalThis.process?.versions?.webcontainer?{name:"stackblitz",ci:false}:{name:"",ci:false}}const l=b(),p=l.name;function n(e){return e?e!=="false":false}const I=globalThis.process?.platform||"",T=n(o.CI)||l.ci!==false,R=n(globalThis.process?.stdout&&globalThis.process?.stdout.isTTY);n(o.DEBUG);const a=t==="test"||n(o.TEST);n(o.MINIMAL)||T||a||!R;const A=/^win/i.test(I);!n(o.NO_COLOR)&&(n(o.FORCE_COLOR)||(R||A)&&o.TERM!=="dumb"||T);const C=(globalThis.process?.versions?.node||"").replace(/^v/,"")||null;Number(C?.split(".")[0])||null;const W=globalThis.process||Object.create(null),_={versions:{}};new Proxy(W,{get(e,s){if(s==="env")return o;if(s in e)return e[s];if(s in _)return _[s]}});const O=globalThis.process?.release?.name==="node",c=!!globalThis.Bun||!!globalThis.process?.versions?.bun,D=!!globalThis.Deno,L=!!globalThis.fastly,S=!!globalThis.Netlify,u=!!globalThis.EdgeRuntime,N=globalThis.navigator?.userAgent==="Cloudflare-Workers",F=[[S,"netlify"],[u,"edge-light"],[N,"workerd"],[L,"fastly"],[D,"deno"],[c,"bun"],[O,"node"]];function G(){const e=F.find(s=>s[0]);if(e)return {name:e[1]}}const P=G();P?.name||""; const WS_EVENT_NAME = "nuxt:devtools:rpc"; const isSandboxed = p === "stackblitz" || p === "codesandbox"; const defaultOptions = { enabled: void 0, // determine multiple conditions componentInspector: true, viteInspect: true, vscode: { enabled: true, startOnBoot: false, port: 3080, reuseExistingServer: true }, disableAuthorization: isSandboxed }; const defaultTabOptions = { behavior: { telemetry: null, openInEditor: void 0 }, ui: { componentsView: "list", componentsGraphShowNodeModules: false, componentsGraphShowGlobalComponents: true, componentsGraphShowPages: false, componentsGraphShowLayouts: false, componentsGraphShowWorkspace: true, interactionCloseOnOutsideClick: false, showExperimentalFeatures: false, showHelpButtons: true, showPanel: true, scale: 1, minimizePanelInactive: 5e3, hiddenTabs: [], pinnedTabs: [], hiddenTabCategories: [], sidebarExpanded: false, sidebarScrollable: false }, serverRoutes: { selectedRoute: null, view: "tree", inputDefaults: { query: [], body: [], headers: [] }, sendFrom: "app" }, serverTasks: { enabled: false, selectedTask: null, view: "list", inputDefaults: { query: [], body: [], headers: [{ active: true, key: "Content-Type", value: "application/json", type: "string" }] } }, assets: { view: "grid" } }; const defaultAllowedExtensions = [ "png", "jpg", "jpeg", "gif", "svg", "webp", "ico", "mp4", "ogg", "mp3", "wav", "mov", "mkv", "mpg", "txt", "ttf", "woff", "woff2", "eot", "json", "js", "jsx", "ts", "tsx", "md", "mdx", "vue", "webm" ]; const module = defineNuxtModule({ meta: { name: "@nuxt/devtools", configKey: "devtools" }, defaults: defaultOptions, setup(options, nuxt) { if (process.env.VITEST || process.env.TEST) return; if (typeof options === "boolean") options = { enabled: options }; if (options.enabled === false) return; if (isGlobalInstall()) { const globalOptions = nuxt.options.devtoolsGlobal || {}; if (options.enabled !== true && !globalOptions.projects?.includes(nuxt.options.rootDir)) return; } return import('../chunks/module-main.mjs').then(function (n) { return n.m; }).then(({ enableModule }) => enableModule(options, nuxt)); } }); export { WS_EVENT_NAME as W, defaultTabOptions as a, defaultAllowedExtensions as d, module as m };