Files
2025-12-02 16:27:21 +00:00

2 lines
6.3 KiB
JavaScript

(()=>{"use strict";var t={256:function(t,e,a){var n,o=this&&this.__createBinding||(Object.create?function(t,e,a,n){void 0===n&&(n=a);var o=Object.getOwnPropertyDescriptor(e,a);o&&!("get"in o?!e.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return e[a]}}),Object.defineProperty(t,n,o)}:function(t,e,a,n){void 0===n&&(n=a),t[n]=e[a]}),s=this&&this.__setModuleDefault||(Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e}),i=this&&this.__importStar||(n=function(t){return n=Object.getOwnPropertyNames||function(t){var e=[];for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(e[e.length]=a);return e},n(t)},function(t){if(t&&t.__esModule)return t;var e={};if(null!=t)for(var a=n(t),i=0;i<a.length;i++)"default"!==a[i]&&o(e,t,a[i]);return s(e,t),e});Object.defineProperty(e,"__esModule",{value:!0}),e.activate=function(t){T=Promise.resolve({context:t,state:null}),t.subscriptions.push(u.commands.registerCommand(A,_.bind(null,t))),t.subscriptions.push(u.workspace.onDidChangeConfiguration(t=>{(t.affectsConfiguration(`${x}.${j}`)||[...P].some(e=>t.affectsConfiguration(e)))&&k()})),$(O())},e.deactivate=async function(){await V()};const r=a(896),c=a(278),l=a(928),u=i(a(398)),d={disabled:u.l10n.t("Auto Attach: Disabled"),always:u.l10n.t("Auto Attach: Always"),smart:u.l10n.t("Auto Attach: Smart"),onlyWithFlag:u.l10n.t("Auto Attach: With Flag")},g={disabled:u.l10n.t("Disabled"),always:u.l10n.t("Always"),smart:u.l10n.t("Smart"),onlyWithFlag:u.l10n.t("Only With Flag")},f={disabled:u.l10n.t("Auto attach is disabled and not shown in status bar"),always:u.l10n.t("Auto attach to every Node.js process launched in the terminal"),smart:u.l10n.t("Auto attach when running scripts that aren't in a node_modules folder"),onlyWithFlag:u.l10n.t("Only auto attach when the `--inspect` flag is given")},h=u.l10n.t("Toggle Auto Attach"),p=u.l10n.t("Toggle auto attach in this workspace"),w=u.l10n.t("Toggle auto attach on this machine"),b=u.l10n.t("Temporarily disable auto attach in this session"),m=u.l10n.t("Re-enable auto attach"),y=u.l10n.t("Auto Attach: Disabled"),A="extension.node-debug.toggleAutoAttach",v="jsDebugIpcState",x="debug.javascript",j="autoAttachFilter",P=new Set(["autoAttachSmartPattern",j].map(t=>`${x}.${t}`));let T,C,D,S=!1;function k(){$("disabled"),$(O())}async function _(t,e){const a=u.workspace.getConfiguration(x);var n;const o=(e=e||((n=a.inspect(j))?n.workspaceFolderValue?u.ConfigurationTarget.WorkspaceFolder:n.workspaceValue?u.ConfigurationTarget.Workspace:(n.globalValue,u.ConfigurationTarget.Global):u.ConfigurationTarget.Global))===u.ConfigurationTarget.Global,s=u.window.createQuickPick(),i=O(),r=["always","smart","onlyWithFlag","disabled"].map(t=>({state:t,label:g[t],description:f[t],alwaysShow:!0}));"disabled"!==i&&r.unshift({setTempDisabled:!S,label:S?m:b,alwaysShow:!0}),s.items=r,s.activeItems=S?[r[0]]:s.items.filter(t=>"state"in t&&t.state===i),s.title=h,s.placeholder=o?w:p,s.buttons=[{iconPath:new u.ThemeIcon(o?"folder":"globe"),tooltip:o?p:w}],s.show();let c=await new Promise(t=>{s.onDidAccept(()=>t(s.selectedItems[0])),s.onDidHide(()=>t(void 0)),s.onDidTriggerButton(()=>{t({scope:o?u.ConfigurationTarget.Workspace:u.ConfigurationTarget.Global})})});if(s.dispose(),c){if("scope"in c)return await _(t,c.scope);"state"in c&&(c.state!==i?a.update(j,c.state,e):S&&(c={setTempDisabled:!1})),"setTempDisabled"in c&&(I(t,i,!0),S=c.setTempDisabled,c.setTempDisabled?await V():await F(t),I(t,i,!1))}}function O(){return u.workspace.getConfiguration(x).get(j)??"disabled"}async function F(t){const e=await async function(t){const e=t.workspaceState.get(v),a=u.extensions.getExtension("ms-vscode.js-debug-nightly")?.extensionPath||u.extensions.getExtension("ms-vscode.js-debug")?.extensionPath,n=function(){const t={},e=u.workspace.getConfiguration(x);for(const a of P)t[a]=e.get(a);return JSON.stringify(t)}();if(e?.jsDebugPath===a&&e?.settingsValue===n)return e.ipcAddress;const o=await u.commands.executeCommand("extension.js-debug.setAutoAttachVariables",e?.ipcAddress);if(!o)return;const s=o.ipcAddress;return await t.workspaceState.update(v,{ipcAddress:s,jsDebugPath:a,settingsValue:n}),s}(t);if(e)return D=W(e).catch(async t=>{if(console.error("[debug-auto-launch] Error creating auto attach server: ",t),"win32"!==process.platform)try{await r.promises.access((0,l.dirname)(e))}catch{return console.error("[debug-auto-launch] Refreshing variables from error"),void k()}}),await D}const W=async t=>{try{return await B(t)}catch(e){return await r.promises.unlink(t).catch(()=>{}),await B(t)}},B=t=>new Promise((e,a)=>{const n=(0,c.createServer)(t=>{const e=[];t.on("data",async a=>{if(0===a[a.length-1]){e.push(a.slice(0,-1));try{await u.commands.executeCommand("extension.js-debug.autoAttachToProcess",JSON.parse(Buffer.concat(e).toString())),t.write(Buffer.from([0]))}catch(e){t.write(Buffer.from([1])),console.error(e)}}else e.push(a)})}).on("error",a).listen(t,()=>e(n))});async function V(){const t=await D;t&&await new Promise(e=>t.close(e))}const M={async disabled(t){await async function(t){(D||await t.workspaceState.get(v))&&(await t.workspaceState.update(v,void 0),await u.commands.executeCommand("extension.js-debug.clearAutoAttachVariables"),await V())}(t)},async onlyWithFlag(t){await F(t)},async smart(t){await F(t)},async always(t){await F(t)}};function I(t,e,a=!1){if("disabled"===e&&!a)return void C?.hide();C||(C=u.window.createStatusBarItem("status.debug.autoAttach",u.StatusBarAlignment.Left),C.name=u.l10n.t("Debug Auto Attach"),C.command=A,C.tooltip=u.l10n.t("Automatically attach to node.js processes in debug mode"),t.subscriptions.push(C));let n=a?"$(loading) ":"";n+=S?y:d[e],C.text=n,C.show()}function $(t){T=T.then(async({context:e,state:a})=>t===a?{context:e,state:a}:(null!==a&&I(e,a,!0),await M[t](e),S=!1,I(e,t,!1),{context:e,state:t}))}},278:t=>{t.exports=require("net")},398:t=>{t.exports=require("vscode")},896:t=>{t.exports=require("fs")},928:t=>{t.exports=require("path")}},e={},a=function a(n){var o=e[n];if(void 0!==o)return o.exports;var s=e[n]={exports:{}};return t[n].call(s.exports,s,s.exports,a),s.exports}(256),n=exports;for(var o in a)n[o]=a[o];a.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
//# sourceMappingURL=https://main.vscode-cdn.net/sourcemaps/1e3c50d64110be466c0b4a45222e81d2c9352888/extensions/debug-auto-launch/dist/extension.js.map